Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fb92ee13 authored by Nate Fischer's avatar Nate Fischer
Browse files

WebView: document Safe Browsing as 'on' by default

WebView Safe Browsing will be on by default. While previously it was
opt-in (applications needed to enable via manifest or API), now it is an
opt-out feature.

This CL updates documentation to mention that the feature is on by
default and provides steps for applications to opt-out if necessary.

This also makes the case of "Safe Browsing" consistent across
documentation.

Bug: 69579509
Test: make docs (manually verify)
Change-Id: I77683a684cd79d2e3cd313ddbff8c52fe510b72b
parent 6db6679a
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -1394,26 +1394,26 @@ public abstract class WebSettings {


    /**
     * Sets whether Safe Browsing is enabled. Safe browsing allows WebView to
     * Sets whether Safe Browsing is enabled. Safe Browsing allows WebView to
     * protect against malware and phishing attacks by verifying the links.
     *
     * <p>
     * Safe browsing is disabled by default. The recommended way to enable Safe browsing is using a
     * manifest tag to change the default value to enabled for all WebViews (read <a
     * href="{@docRoot}reference/android/webkit/WebView.html">general Safe Browsing info</a>).
     * Safe Browsing can be disabled for all WebViews using a manifest tag (read <a
     * href="{@docRoot}reference/android/webkit/WebView.html">general Safe Browsing info</a>). The
     * manifest tag has a lower precedence than this API.
     *
     * <p>
     * This API overrides the manifest tag value for this WebView.
     * Safe Browsing is enabled by default for devices which support it.
     *
     * @param enabled Whether Safe browsing is enabled.
     * @param enabled Whether Safe Browsing is enabled.
     */
    public abstract void setSafeBrowsingEnabled(boolean enabled);

    /**
     * Gets whether Safe browsing is enabled.
     * Gets whether Safe Browsing is enabled.
     * See {@link #setSafeBrowsingEnabled}.
     *
     * @return {@code true} if Safe browsing is enabled and {@code false} otherwise.
     * @return {@code true} if Safe Browsing is enabled and {@code false} otherwise.
     */
    public abstract boolean getSafeBrowsingEnabled();

+10 −8
Original line number Diff line number Diff line
@@ -327,22 +327,25 @@ import java.util.Map;
 * <h3>Safe Browsing</h3>
 *
 * <p>
 * If Safe Browsing is enabled, WebView will block malicious URLs and present a warning UI to the
 * user to allow them to navigate back safely or proceed to the malicious page.
 * With Safe Browsing, WebView will block malicious URLs and present a warning UI to the user to
 * allow them to navigate back safely or proceed to the malicious page.
 * <p>
 * The recommended way for apps to enable the feature is putting the following tag in the manifest's
 * {@code <application>} element:
 * Safe Browsing is enabled by default on devices which support it. If your app needs to disable
 * Safe Browsing for all WebViews, it can do so in the manifest's {@code <application>} element:
 * <p>
 * <pre>
 * &lt;manifest&gt;
 *     &lt;application&gt;
 *         ...
 *         &lt;meta-data android:name=&quot;android.webkit.WebView.EnableSafeBrowsing&quot;
 *             android:value=&quot;true&quot; /&gt;
 *             android:value=&quot;false&quot; /&gt;
 *     &lt;/application&gt;
 * &lt;/manifest&gt;
 * </pre>
 *
 * <p>
 * Otherwise, see {@link WebSettings#setSafeBrowsingEnabled}.
 *
 */
// Implementation notes.
// The WebView is a thin API class that delegates its public API to a backend WebViewProvider
@@ -1666,9 +1669,8 @@ public class WebView extends AbsoluteLayout
     * invoked with {@code true}. Safe Browsing is not fully supported on all devices. For those
     * devices {@code callback} will receive {@code false}.
     * <p>
     * This does not enable the Safe Browsing feature itself, and should only be called if Safe
     * Browsing is enabled by the manifest tag or {@link WebSettings#setSafeBrowsingEnabled}. This
     * prepares resources used for Safe Browsing.
     * This should not be called if Safe Browsing has been disabled by manifest tag or {@link
     * WebSettings#setSafeBrowsingEnabled}. This prepares resources used for Safe Browsing.
     * <p>
     * This should be called with the Application Context (and will always use the Application
     * context to do its work regardless).