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

Commit d1c4faa5 authored by Jonathan Dixon's avatar Jonathan Dixon
Browse files

Small tidy up to getDefaultUserAgent

- no need for WebSettings to bounce via WebView to get to the factory
- move this static (non-factory) method into the Statics inner class.

Bug: 6329117
Change-Id: Ib56d5eaae59cd8d19fb0b71e4b8a41d1c0f5ba09
parent 003caf9e
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -17,8 +17,6 @@
package android.webkit;

import android.content.Context;
import android.os.Message;
import android.os.Build;

/**
 * Manages settings state for a WebView. When a WebView is first created, it
@@ -1266,7 +1264,7 @@ public abstract class WebSettings {
     * @param context a Context object used to access application assets
     */
    public static String getDefaultUserAgent(Context context) {
        return WebView.getFactory().getDefaultUserAgent(context);
        return WebViewFactory.getProvider().getStatics().getDefaultUserAgent(context);
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -1821,7 +1821,7 @@ public class WebView extends AbsoluteLayout
        }
    }

    static synchronized WebViewFactoryProvider getFactory() {
    private static synchronized WebViewFactoryProvider getFactory() {
        // For now the main purpose of this function (and the factory abstration) is to keep
        // us honest and minimize usage of WebViewClassic internals when binding the proxy.
        checkThread();
+6 −10
Original line number Diff line number Diff line
@@ -42,6 +42,12 @@ public interface WebViewFactoryProvider {
         * {@link android.webkit.WebView#disablePlatformNotifications()}
         */
        void setPlatformNotificationsEnabled(boolean enable);

        /**
         * Implements the API method:
         * {@link android.webkit.WebSettings#getDefaultUserAgent(Context) }
         */
        String getDefaultUserAgent(Context context);
    }

    Statics getStatics();
@@ -93,14 +99,4 @@ public interface WebViewFactoryProvider {
     * @return the singleton WebViewDatabase instance
     */
    WebViewDatabase getWebViewDatabase(Context context);

    /**
     * Returns the default User-Agent used by a WebView.
     * An instance of WebView could use a different User-Agent if a call
     * is made to {@link WebSettings#setUserAgent(int)} or
     * {@link WebSettings#setUserAgentString(String)}.
     *
     * @param context a Context object used to access application assets
     */
    String getDefaultUserAgent(Context context);
}