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

Commit 04d0d003 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "WebView: document Safe Browsing as 'on' by default"

parents 20b9219e fb92ee13
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
@@ -1670,9 +1673,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).