许多 Web 浏览器支持“InPrivate”浏览的概念,其中用户历史记录不会保存。
Recall确保在这种模式下不会保存用户的浏览历史记录,应用可以使用SetInputScope
函数将输入范围设置为IS_PASSWORD
。
重要
你的应用还必须注册一个 http
或 https
协议处理程序,然后 SetInputScope
才能支持本文中所述的行为。
[DllImport("msctf.dll", SetLastError = true)]
private static extern int SetInputScope(IntPtr hwnd, InputScope inputScope);
private new enum InputScope : int
{
IS_DEFAULT = 0,
IS_URL = 1,
IS_FILE_FULLFILEPATH = 2,
IS_PRIVATE = 0x1f // Input is treated as private (e.g. passwords)
}
private void EnterInPrivateMode()
{
// Get your HWND. This will vary based on your UI Framework. WPF can use WindowInteropHelper, passing in your current Window.
IntPtr hwnd = new WindowInteropHelper(this).Handle;
// Then, set the input scope on the HWND to private
SetInputScope(hwnd, InputScope.IS_PRIVATE);
}
private void ExitInPrivateMode()
{
// Get your HWND. This will vary based on your UI Framework. WPF can use WindowInteropHelper, passing in your current Window.
IntPtr hwnd = new WindowInteropHelper(this).Handle;
// Then, set the input scope on the HWND to default
SetInputScope(hwnd, InputScope.IS_DEFAULT);
}
当用户处于“专用”浏览模式时,你的应用应暂停提供用户活动。