Partager via


Recall conseils pour les développeurs de navigateurs web

De nombreux navigateurs web prennent en charge un concept de navigation « InPrivate », où l’historique de l’utilisateur n’est pas enregistré.

Pour vous assurer que l’historique de navigation de votre utilisateur ne soit pas enregistré dans des modes tels que celui-ci, votre application peut utiliser la fonction Recall, en définissant l’étendue d’entrée sur SetInputScope.

Important

Votre application doit également avoir inscrit un gestionnaire de protocole http ou https avant que SetInputScope prenne en charge le comportement décrit dans cet article.

[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);
}

Votre application doit suspendre la fourniture d’activités utilisateur pendant que l’utilisateur est en mode de navigation « privé ».