BrowserSettings.java revision af55452d7f37c20201663b80ca77b64457323361
1
2/*
3 * Copyright (C) 2007 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18package com.android.browser;
19
20import com.android.browser.search.SearchEngine;
21import com.android.browser.search.SearchEngines;
22
23import android.app.ActivityManager;
24import android.content.ComponentName;
25import android.content.ContentResolver;
26import android.content.Context;
27import android.content.pm.ActivityInfo;
28import android.content.SharedPreferences;
29import android.content.SharedPreferences.Editor;
30import android.database.ContentObserver;
31import android.net.Uri;
32import android.os.Handler;
33import android.preference.PreferenceActivity;
34import android.preference.PreferenceScreen;
35import android.provider.Settings;
36import android.util.Log;
37import android.webkit.CookieManager;
38import android.webkit.GeolocationPermissions;
39import android.webkit.ValueCallback;
40import android.webkit.WebView;
41import android.webkit.WebViewDatabase;
42import android.webkit.WebIconDatabase;
43import android.webkit.WebSettings;
44import android.webkit.WebStorage;
45import android.preference.PreferenceManager;
46import android.provider.Browser;
47
48import java.util.HashMap;
49import java.util.Map;
50import java.util.Set;
51import java.util.Observable;
52
53/*
54 * Package level class for storing various WebView and Browser settings. To use
55 * this class:
56 * BrowserSettings s = BrowserSettings.getInstance();
57 * s.addObserver(webView.getSettings());
58 * s.loadFromDb(context); // Only needed on app startup
59 * s.javaScriptEnabled = true;
60 * ... // set any other settings
61 * s.update(); // this will update all the observers
62 *
63 * To remove an observer:
64 * s.deleteObserver(webView.getSettings());
65 */
66public class BrowserSettings extends Observable {
67
68    // Private variables for settings
69    // NOTE: these defaults need to be kept in sync with the XML
70    // until the performance of PreferenceManager.setDefaultValues()
71    // is improved.
72    // Note: boolean variables are set inside reset function.
73    private boolean loadsImagesAutomatically;
74    private boolean javaScriptEnabled;
75    private WebSettings.PluginState pluginState;
76    private boolean javaScriptCanOpenWindowsAutomatically;
77    private boolean showSecurityWarnings;
78    private boolean rememberPasswords;
79    private boolean saveFormData;
80    private boolean autoFillEnabled;
81    private boolean openInBackground;
82    private String defaultTextEncodingName;
83    private String homeUrl = "";
84    private SearchEngine searchEngine;
85    private boolean autoFitPage;
86    private boolean landscapeOnly;
87    private boolean loadsPageInOverviewMode;
88    private boolean showDebugSettings;
89    // HTML5 API flags
90    private boolean appCacheEnabled;
91    private boolean databaseEnabled;
92    private boolean domStorageEnabled;
93    private boolean geolocationEnabled;
94    private boolean workersEnabled;  // only affects V8. JSC does not have a similar setting
95    // HTML5 API configuration params
96    private long appCacheMaxSize = Long.MAX_VALUE;
97    private String appCachePath;  // default value set in loadFromDb().
98    private String databasePath; // default value set in loadFromDb()
99    private String geolocationDatabasePath; // default value set in loadFromDb()
100    private WebStorageSizeManager webStorageSizeManager;
101
102    private String jsFlags = "";
103
104    private final static String TAG = "BrowserSettings";
105
106    // Development settings
107    public WebSettings.LayoutAlgorithm layoutAlgorithm =
108        WebSettings.LayoutAlgorithm.NARROW_COLUMNS;
109    private boolean useWideViewPort = true;
110    private int userAgent = 0;
111    private boolean tracing = false;
112    private boolean lightTouch = false;
113    private boolean navDump = false;
114
115    // By default the error console is shown once the user navigates to about:debug.
116    // The setting can be then toggled from the settings menu.
117    private boolean showConsole = true;
118
119    // Private preconfigured values
120    private static int minimumFontSize = 1;
121    private static int minimumLogicalFontSize = 1;
122    private static int defaultFontSize = 16;
123    private static int defaultFixedFontSize = 13;
124    private static WebSettings.TextSize textSize =
125        WebSettings.TextSize.NORMAL;
126    private static WebSettings.ZoomDensity zoomDensity =
127        WebSettings.ZoomDensity.MEDIUM;
128    private static int pageCacheCapacity;
129
130    // Preference keys that are used outside this class
131    public final static String PREF_CLEAR_CACHE = "privacy_clear_cache";
132    public final static String PREF_CLEAR_COOKIES = "privacy_clear_cookies";
133    public final static String PREF_CLEAR_HISTORY = "privacy_clear_history";
134    public final static String PREF_HOMEPAGE = "homepage";
135    public final static String PREF_SEARCH_ENGINE = "search_engine";
136    public final static String PREF_CLEAR_FORM_DATA =
137            "privacy_clear_form_data";
138    public final static String PREF_CLEAR_PASSWORDS =
139            "privacy_clear_passwords";
140    public final static String PREF_EXTRAS_RESET_DEFAULTS =
141            "reset_default_preferences";
142    public final static String PREF_DEBUG_SETTINGS = "debug_menu";
143    public final static String PREF_WEBSITE_SETTINGS = "website_settings";
144    public final static String PREF_TEXT_SIZE = "text_size";
145    public final static String PREF_DEFAULT_ZOOM = "default_zoom";
146    public final static String PREF_DEFAULT_TEXT_ENCODING =
147            "default_text_encoding";
148    public final static String PREF_CLEAR_GEOLOCATION_ACCESS =
149            "privacy_clear_geolocation_access";
150    public final static String PREF_AUTOFILL_ENABLED = "autofill_enabled";
151    public final static String PREF_AUTOFILL_PROFILE = "autofill_profile";
152
153    private static final String DESKTOP_USERAGENT = "Mozilla/5.0 (Macintosh; " +
154            "U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/533.16 (KHTML, " +
155            "like Gecko) Version/5.0 Safari/533.16";
156
157    private static final String IPHONE_USERAGENT = "Mozilla/5.0 (iPhone; U; " +
158            "CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 " +
159            "(KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7";
160
161    private static final String IPAD_USERAGENT = "Mozilla/5.0 (iPad; U; " +
162            "CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 " +
163            "(KHTML, like Gecko) Version/4.0.4 Mobile/7B367 Safari/531.21.10";
164
165    private static final String FROYO_USERAGENT = "Mozilla/5.0 (Linux; U; " +
166            "Android 2.2; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 " +
167            "(KHTML, like Gecko) Version/4.0 Mobile Safari/533.1";
168
169    // Value to truncate strings when adding them to a TextView within
170    // a ListView
171    public final static int MAX_TEXTVIEW_LEN = 80;
172
173    public static final String RLZ_PROVIDER = "com.google.android.partnersetup.rlzappprovider";
174
175    public static final Uri RLZ_PROVIDER_URI = Uri.parse("content://" + RLZ_PROVIDER + "/");
176
177    private TabControl mTabControl;
178
179    // Single instance of the BrowserSettings for use in the Browser app.
180    private static BrowserSettings sSingleton;
181
182    // Private map of WebSettings to Observer objects used when deleting an
183    // observer.
184    private HashMap<WebSettings,Observer> mWebSettingsToObservers =
185        new HashMap<WebSettings,Observer>();
186
187    /*
188     * An observer wrapper for updating a WebSettings object with the new
189     * settings after a call to BrowserSettings.update().
190     */
191    static class Observer implements java.util.Observer {
192        // Private WebSettings object that will be updated.
193        private WebSettings mSettings;
194
195        Observer(WebSettings w) {
196            mSettings = w;
197        }
198
199        public void update(Observable o, Object arg) {
200            BrowserSettings b = (BrowserSettings)o;
201            WebSettings s = mSettings;
202
203            s.setLayoutAlgorithm(b.layoutAlgorithm);
204            if (b.userAgent == 0) {
205                // use the default ua string
206                s.setUserAgentString(null);
207            } else if (b.userAgent == 1) {
208                s.setUserAgentString(DESKTOP_USERAGENT);
209            } else if (b.userAgent == 2) {
210                s.setUserAgentString(IPHONE_USERAGENT);
211            } else if (b.userAgent == 3) {
212                s.setUserAgentString(IPAD_USERAGENT);
213            } else if (b.userAgent == 4) {
214                s.setUserAgentString(FROYO_USERAGENT);
215            }
216            s.setUseWideViewPort(b.useWideViewPort);
217            s.setLoadsImagesAutomatically(b.loadsImagesAutomatically);
218            s.setJavaScriptEnabled(b.javaScriptEnabled);
219            s.setPluginState(b.pluginState);
220            s.setJavaScriptCanOpenWindowsAutomatically(
221                    b.javaScriptCanOpenWindowsAutomatically);
222            s.setDefaultTextEncodingName(b.defaultTextEncodingName);
223            s.setMinimumFontSize(b.minimumFontSize);
224            s.setMinimumLogicalFontSize(b.minimumLogicalFontSize);
225            s.setDefaultFontSize(b.defaultFontSize);
226            s.setDefaultFixedFontSize(b.defaultFixedFontSize);
227            s.setNavDump(b.navDump);
228            s.setTextSize(b.textSize);
229            s.setDefaultZoom(b.zoomDensity);
230            s.setLightTouchEnabled(b.lightTouch);
231            s.setSaveFormData(b.saveFormData);
232            s.setAutoFillEnabled(b.autoFillEnabled);
233            s.setSavePassword(b.rememberPasswords);
234            s.setLoadWithOverviewMode(b.loadsPageInOverviewMode);
235            s.setPageCacheCapacity(pageCacheCapacity);
236
237            // WebView inside Browser doesn't want initial focus to be set.
238            s.setNeedInitialFocus(false);
239            // Browser supports multiple windows
240            s.setSupportMultipleWindows(true);
241            // enable smooth transition for better performance during panning or
242            // zooming
243            s.setEnableSmoothTransition(true);
244
245            // HTML5 API flags
246            s.setAppCacheEnabled(b.appCacheEnabled);
247            s.setDatabaseEnabled(b.databaseEnabled);
248            s.setDomStorageEnabled(b.domStorageEnabled);
249            s.setWorkersEnabled(b.workersEnabled);  // This only affects V8.
250            s.setGeolocationEnabled(b.geolocationEnabled);
251
252            // HTML5 configuration parameters.
253            s.setAppCacheMaxSize(b.appCacheMaxSize);
254            s.setAppCachePath(b.appCachePath);
255            s.setDatabasePath(b.databasePath);
256            s.setGeolocationDatabasePath(b.geolocationDatabasePath);
257
258            b.updateTabControlSettings();
259        }
260    }
261
262    /**
263     * Load settings from the browser app's database.
264     * NOTE: Strings used for the preferences must match those specified
265     * in the various preference XML files.
266     * @param ctx A Context object used to query the browser's settings
267     *            database. If the database exists, the saved settings will be
268     *            stored in this BrowserSettings object. This will update all
269     *            observers of this object.
270     */
271    public void loadFromDb(final Context ctx) {
272        SharedPreferences p =
273                PreferenceManager.getDefaultSharedPreferences(ctx);
274        // Set the default value for the Application Caches path.
275        appCachePath = ctx.getDir("appcache", 0).getPath();
276        // Determine the maximum size of the application cache.
277        webStorageSizeManager = new WebStorageSizeManager(
278                ctx,
279                new WebStorageSizeManager.StatFsDiskInfo(appCachePath),
280                new WebStorageSizeManager.WebKitAppCacheInfo(appCachePath));
281        appCacheMaxSize = webStorageSizeManager.getAppCacheMaxSize();
282        // Set the default value for the Database path.
283        databasePath = ctx.getDir("databases", 0).getPath();
284        // Set the default value for the Geolocation database path.
285        geolocationDatabasePath = ctx.getDir("geolocation", 0).getPath();
286
287        if (p.getString(PREF_HOMEPAGE, "") == "") {
288            // No home page preferences is set, set it to default.
289            setHomePage(ctx, getFactoryResetHomeUrl(ctx));
290        }
291
292        // the cost of one cached page is ~3M (measured using nytimes.com). For
293        // low end devices, we only cache one page. For high end devices, we try
294        // to cache more pages, currently choose 5.
295        ActivityManager am = (ActivityManager) ctx
296                .getSystemService(Context.ACTIVITY_SERVICE);
297        if (am.getMemoryClass() > 16) {
298            pageCacheCapacity = 5;
299        } else {
300            pageCacheCapacity = 1;
301        }
302
303        // PreferenceManager.setDefaultValues is TOO SLOW, need to manually keep
304        // the defaults in sync
305        syncSharedPreferences(ctx, p);
306    }
307
308    /* package */ void syncSharedPreferences(Context ctx, SharedPreferences p) {
309
310        homeUrl =
311            p.getString(PREF_HOMEPAGE, homeUrl);
312        String searchEngineName = p.getString(PREF_SEARCH_ENGINE,
313                SearchEngine.GOOGLE);
314        if (searchEngine == null || !searchEngine.getName().equals(searchEngineName)) {
315            if (searchEngine != null) {
316                if (searchEngine.supportsVoiceSearch()) {
317                    // One or more tabs could have been in voice search mode.
318                    // Clear it, since the new SearchEngine may not support
319                    // it, or may handle it differently.
320                    for (int i = 0; i < mTabControl.getTabCount(); i++) {
321                        mTabControl.getTab(i).revertVoiceSearchMode();
322                    }
323                }
324                searchEngine.close();
325            }
326            searchEngine = SearchEngines.get(ctx, searchEngineName);
327        }
328        Log.i(TAG, "Selected search engine: " + searchEngine);
329
330        loadsImagesAutomatically = p.getBoolean("load_images",
331                loadsImagesAutomatically);
332        javaScriptEnabled = p.getBoolean("enable_javascript",
333                javaScriptEnabled);
334        pluginState = WebSettings.PluginState.valueOf(
335                p.getString("plugin_state", pluginState.name()));
336        javaScriptCanOpenWindowsAutomatically = !p.getBoolean(
337            "block_popup_windows",
338            !javaScriptCanOpenWindowsAutomatically);
339        showSecurityWarnings = p.getBoolean("show_security_warnings",
340                showSecurityWarnings);
341        rememberPasswords = p.getBoolean("remember_passwords",
342                rememberPasswords);
343        saveFormData = p.getBoolean("save_formdata",
344                saveFormData);
345        autoFillEnabled = p.getBoolean("autofill_enabled", autoFillEnabled);
346        boolean accept_cookies = p.getBoolean("accept_cookies",
347                CookieManager.getInstance().acceptCookie());
348        CookieManager.getInstance().setAcceptCookie(accept_cookies);
349        openInBackground = p.getBoolean("open_in_background", openInBackground);
350        textSize = WebSettings.TextSize.valueOf(
351                p.getString(PREF_TEXT_SIZE, textSize.name()));
352        zoomDensity = WebSettings.ZoomDensity.valueOf(
353                p.getString(PREF_DEFAULT_ZOOM, zoomDensity.name()));
354        autoFitPage = p.getBoolean("autofit_pages", autoFitPage);
355        loadsPageInOverviewMode = p.getBoolean("load_page",
356                loadsPageInOverviewMode);
357        boolean landscapeOnlyTemp =
358                p.getBoolean("landscape_only", landscapeOnly);
359        if (landscapeOnlyTemp != landscapeOnly) {
360            landscapeOnly = landscapeOnlyTemp;
361        }
362        useWideViewPort = true; // use wide view port for either setting
363        if (autoFitPage) {
364            layoutAlgorithm = WebSettings.LayoutAlgorithm.NARROW_COLUMNS;
365        } else {
366            layoutAlgorithm = WebSettings.LayoutAlgorithm.NORMAL;
367        }
368        defaultTextEncodingName =
369                p.getString(PREF_DEFAULT_TEXT_ENCODING,
370                        defaultTextEncodingName);
371
372        showDebugSettings =
373                p.getBoolean(PREF_DEBUG_SETTINGS, showDebugSettings);
374        // Debug menu items have precidence if the menu is visible
375        if (showDebugSettings) {
376            boolean small_screen = p.getBoolean("small_screen",
377                    layoutAlgorithm ==
378                    WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
379            if (small_screen) {
380                layoutAlgorithm = WebSettings.LayoutAlgorithm.SINGLE_COLUMN;
381            } else {
382                boolean normal_layout = p.getBoolean("normal_layout",
383                        layoutAlgorithm == WebSettings.LayoutAlgorithm.NORMAL);
384                if (normal_layout) {
385                    layoutAlgorithm = WebSettings.LayoutAlgorithm.NORMAL;
386                } else {
387                    layoutAlgorithm =
388                            WebSettings.LayoutAlgorithm.NARROW_COLUMNS;
389                }
390            }
391            useWideViewPort = p.getBoolean("wide_viewport", useWideViewPort);
392            tracing = p.getBoolean("enable_tracing", tracing);
393            lightTouch = p.getBoolean("enable_light_touch", lightTouch);
394            navDump = p.getBoolean("enable_nav_dump", navDump);
395            userAgent = Integer.parseInt(p.getString("user_agent", "0"));
396        }
397        // JS flags is loaded from DB even if showDebugSettings is false,
398        // so that it can be set once and be effective all the time.
399        jsFlags = p.getString("js_engine_flags", "");
400
401        // Read the setting for showing/hiding the JS Console always so that should the
402        // user enable debug settings, we already know if we should show the console.
403        // The user will never see the console unless they navigate to about:debug,
404        // regardless of the setting we read here. This setting is only used after debug
405        // is enabled.
406        showConsole = p.getBoolean("javascript_console", showConsole);
407
408        // HTML5 API flags
409        appCacheEnabled = p.getBoolean("enable_appcache", appCacheEnabled);
410        databaseEnabled = p.getBoolean("enable_database", databaseEnabled);
411        domStorageEnabled = p.getBoolean("enable_domstorage", domStorageEnabled);
412        geolocationEnabled = p.getBoolean("enable_geolocation", geolocationEnabled);
413        workersEnabled = p.getBoolean("enable_workers", workersEnabled);
414
415        update();
416    }
417
418    public String getHomePage() {
419        return homeUrl;
420    }
421
422    public SearchEngine getSearchEngine() {
423        return searchEngine;
424    }
425
426    public String getJsFlags() {
427        return jsFlags;
428    }
429
430    public WebStorageSizeManager getWebStorageSizeManager() {
431        return webStorageSizeManager;
432    }
433
434    public void setHomePage(Context context, String url) {
435        Editor ed = PreferenceManager.
436                getDefaultSharedPreferences(context).edit();
437        ed.putString(PREF_HOMEPAGE, url);
438        ed.apply();
439        homeUrl = url;
440    }
441
442    public WebSettings.TextSize getTextSize() {
443        return textSize;
444    }
445
446    public WebSettings.ZoomDensity getDefaultZoom() {
447        return zoomDensity;
448    }
449
450    public boolean openInBackground() {
451        return openInBackground;
452    }
453
454    public boolean showSecurityWarnings() {
455        return showSecurityWarnings;
456    }
457
458    public boolean isTracing() {
459        return tracing;
460    }
461
462    public boolean isLightTouch() {
463        return lightTouch;
464    }
465
466    public boolean isNavDump() {
467        return navDump;
468    }
469
470    public boolean showDebugSettings() {
471        return showDebugSettings;
472    }
473
474    public void toggleDebugSettings() {
475        showDebugSettings = !showDebugSettings;
476        navDump = showDebugSettings;
477        update();
478    }
479
480    /**
481     * Add a WebSettings object to the list of observers that will be updated
482     * when update() is called.
483     *
484     * @param s A WebSettings object that is strictly tied to the life of a
485     *            WebView.
486     */
487    public Observer addObserver(WebSettings s) {
488        Observer old = mWebSettingsToObservers.get(s);
489        if (old != null) {
490            super.deleteObserver(old);
491        }
492        Observer o = new Observer(s);
493        mWebSettingsToObservers.put(s, o);
494        super.addObserver(o);
495        return o;
496    }
497
498    /**
499     * Delete the given WebSettings observer from the list of observers.
500     * @param s The WebSettings object to be deleted.
501     */
502    public void deleteObserver(WebSettings s) {
503        Observer o = mWebSettingsToObservers.get(s);
504        if (o != null) {
505            mWebSettingsToObservers.remove(s);
506            super.deleteObserver(o);
507        }
508    }
509
510    /*
511     * Package level method for obtaining a single app instance of the
512     * BrowserSettings.
513     */
514    /*package*/ static BrowserSettings getInstance() {
515        if (sSingleton == null ) {
516            sSingleton = new BrowserSettings();
517        }
518        return sSingleton;
519    }
520
521    /*
522     * Package level method for associating the BrowserSettings with TabControl
523     */
524    /* package */void setTabControl(TabControl tabControl) {
525        mTabControl = tabControl;
526        updateTabControlSettings();
527    }
528
529    /*
530     * Update all the observers of the object.
531     */
532    /*package*/ void update() {
533        setChanged();
534        notifyObservers();
535    }
536
537    /*package*/ void clearCache(Context context) {
538        WebIconDatabase.getInstance().removeAllIcons();
539        if (mTabControl != null) {
540            WebView current = mTabControl.getCurrentWebView();
541            if (current != null) {
542                current.clearCache(true);
543            }
544        }
545    }
546
547    /*package*/ void clearCookies(Context context) {
548        CookieManager.getInstance().removeAllCookie();
549    }
550
551    /* package */void clearHistory(Context context) {
552        ContentResolver resolver = context.getContentResolver();
553        Browser.clearHistory(resolver);
554        Browser.clearSearches(resolver);
555    }
556
557    /* package */ void clearFormData(Context context) {
558        WebViewDatabase.getInstance(context).clearFormData();
559        if (mTabControl != null) {
560            WebView currentTopView = mTabControl.getCurrentTopWebView();
561            if (currentTopView != null) {
562                currentTopView.clearFormData();
563            }
564        }
565    }
566
567    /*package*/ void clearPasswords(Context context) {
568        WebViewDatabase db = WebViewDatabase.getInstance(context);
569        db.clearUsernamePassword();
570        db.clearHttpAuthUsernamePassword();
571    }
572
573    private void updateTabControlSettings() {
574        // Enable/disable the error console.
575        mTabControl.getBrowserActivity().setShouldShowErrorConsole(
576            showDebugSettings && showConsole);
577        mTabControl.getBrowserActivity().setRequestedOrientation(
578            landscapeOnly ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
579            : ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
580    }
581
582    /*package*/ void clearDatabases(Context context) {
583        WebStorage.getInstance().deleteAllData();
584    }
585
586    /*package*/ void clearLocationAccess(Context context) {
587        GeolocationPermissions.getInstance().clearAll();
588    }
589
590    /*package*/ void resetDefaultPreferences(Context ctx) {
591        reset();
592        SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(ctx);
593        p.edit().clear().apply();
594        PreferenceManager.setDefaultValues(ctx, R.xml.page_content_preferences, true);
595        PreferenceManager.setDefaultValues(ctx, R.xml.personal_preferences, true);
596        PreferenceManager.setDefaultValues(ctx, R.xml.privacy_preferences, true);
597        PreferenceManager.setDefaultValues(ctx, R.xml.security_preferences, true);
598        PreferenceManager.setDefaultValues(ctx, R.xml.advanced_preferences, true);
599        // reset homeUrl
600        setHomePage(ctx, getFactoryResetHomeUrl(ctx));
601        // reset appcache max size
602        appCacheMaxSize = webStorageSizeManager.getAppCacheMaxSize();
603    }
604
605    private String getFactoryResetHomeUrl(Context context) {
606        String url = context.getResources().getString(R.string.homepage_base);
607        if (url.indexOf("{CID}") != -1) {
608            url = url.replace("{CID}",
609                    BrowserProvider.getClientId(context.getContentResolver()));
610        }
611        return url;
612    }
613
614    // Private constructor that does nothing.
615    private BrowserSettings() {
616        reset();
617    }
618
619    private void reset() {
620        // Private variables for settings
621        // NOTE: these defaults need to be kept in sync with the XML
622        // until the performance of PreferenceManager.setDefaultValues()
623        // is improved.
624        loadsImagesAutomatically = true;
625        javaScriptEnabled = true;
626        pluginState = WebSettings.PluginState.ON;
627        javaScriptCanOpenWindowsAutomatically = false;
628        showSecurityWarnings = true;
629        rememberPasswords = true;
630        saveFormData = true;
631        autoFillEnabled = false;
632        openInBackground = false;
633        autoFitPage = true;
634        landscapeOnly = false;
635        loadsPageInOverviewMode = true;
636        showDebugSettings = false;
637        // HTML5 API flags
638        appCacheEnabled = true;
639        databaseEnabled = true;
640        domStorageEnabled = true;
641        geolocationEnabled = true;
642        workersEnabled = true;  // only affects V8. JSC does not have a similar setting
643    }
644}
645