Cary Clark | f2407c6 | 2009-09-04 12:25:10 -0400 | [diff] [blame] | 1 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 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 | |
| 18 | package com.android.browser; |
| 19 | |
John Reck | bafe58a | 2011-01-11 10:26:02 -0800 | [diff] [blame] | 20 | import com.android.browser.homepages.HomeProvider; |
Bjorn Bringert | d69f51d | 2010-09-13 14:06:41 +0100 | [diff] [blame] | 21 | import com.android.browser.search.SearchEngine; |
| 22 | import com.android.browser.search.SearchEngines; |
| 23 | |
Grace Kloba | 9804c43 | 2009-12-02 11:07:40 -0800 | [diff] [blame] | 24 | import android.app.ActivityManager; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 25 | import android.content.ContentResolver; |
| 26 | import android.content.Context; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 27 | import android.content.SharedPreferences; |
| 28 | import android.content.SharedPreferences.Editor; |
John Reck | 812d2d6 | 2011-01-18 14:16:15 -0800 | [diff] [blame] | 29 | import android.content.SharedPreferences.OnSharedPreferenceChangeListener; |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 30 | import android.database.Cursor; |
Jeff Davidson | 4361029 | 2010-07-16 16:03:58 -0700 | [diff] [blame] | 31 | import android.net.Uri; |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 32 | import android.os.AsyncTask; |
Ben Murdoch | 23da30e | 2010-10-26 15:18:44 +0100 | [diff] [blame] | 33 | import android.os.Message; |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 34 | import android.preference.PreferenceManager; |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 35 | import android.provider.Browser; |
Bjorn Bringert | d69f51d | 2010-09-13 14:06:41 +0100 | [diff] [blame] | 36 | import android.util.Log; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 37 | import android.webkit.CookieManager; |
Steve Block | f344d03 | 2009-07-30 10:50:45 +0100 | [diff] [blame] | 38 | import android.webkit.GeolocationPermissions; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 39 | import android.webkit.WebIconDatabase; |
| 40 | import android.webkit.WebSettings; |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 41 | import android.webkit.WebSettings.AutoFillProfile; |
Nicolas Roard | 78a98e4 | 2009-05-11 13:34:17 +0100 | [diff] [blame] | 42 | import android.webkit.WebStorage; |
John Reck | 812d2d6 | 2011-01-18 14:16:15 -0800 | [diff] [blame] | 43 | import android.webkit.WebView; |
| 44 | import android.webkit.WebViewDatabase; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 45 | |
| 46 | import java.util.HashMap; |
| 47 | import java.util.Observable; |
| 48 | |
| 49 | /* |
| 50 | * Package level class for storing various WebView and Browser settings. To use |
| 51 | * this class: |
| 52 | * BrowserSettings s = BrowserSettings.getInstance(); |
| 53 | * s.addObserver(webView.getSettings()); |
| 54 | * s.loadFromDb(context); // Only needed on app startup |
| 55 | * s.javaScriptEnabled = true; |
| 56 | * ... // set any other settings |
| 57 | * s.update(); // this will update all the observers |
| 58 | * |
| 59 | * To remove an observer: |
| 60 | * s.deleteObserver(webView.getSettings()); |
| 61 | */ |
John Reck | 40badf2 | 2011-04-20 15:31:13 -0700 | [diff] [blame^] | 62 | // TODO: Really need to refactor this :/ |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 63 | public class BrowserSettings extends Observable implements OnSharedPreferenceChangeListener { |
Leon Scroggins | 9ac587d | 2009-04-20 12:53:46 -0400 | [diff] [blame] | 64 | // Private variables for settings |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 65 | // NOTE: these defaults need to be kept in sync with the XML |
| 66 | // until the performance of PreferenceManager.setDefaultValues() |
| 67 | // is improved. |
Shimeng (Simon) Wang | f739271 | 2010-03-10 16:44:31 -0800 | [diff] [blame] | 68 | // Note: boolean variables are set inside reset function. |
| 69 | private boolean loadsImagesAutomatically; |
| 70 | private boolean javaScriptEnabled; |
Patrick Scott | e536b33 | 2010-03-22 10:19:32 -0400 | [diff] [blame] | 71 | private WebSettings.PluginState pluginState; |
Shimeng (Simon) Wang | f739271 | 2010-03-10 16:44:31 -0800 | [diff] [blame] | 72 | private boolean javaScriptCanOpenWindowsAutomatically; |
| 73 | private boolean showSecurityWarnings; |
| 74 | private boolean rememberPasswords; |
| 75 | private boolean saveFormData; |
Ben Murdoch | ce549fc | 2010-09-09 10:28:08 +0100 | [diff] [blame] | 76 | private boolean autoFillEnabled; |
Shimeng (Simon) Wang | f739271 | 2010-03-10 16:44:31 -0800 | [diff] [blame] | 77 | private boolean openInBackground; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 78 | private String defaultTextEncodingName; |
Grace Kloba | f2c5c1b | 2009-05-26 10:48:31 -0700 | [diff] [blame] | 79 | private String homeUrl = ""; |
Bjorn Bringert | d69f51d | 2010-09-13 14:06:41 +0100 | [diff] [blame] | 80 | private SearchEngine searchEngine; |
Shimeng (Simon) Wang | f739271 | 2010-03-10 16:44:31 -0800 | [diff] [blame] | 81 | private boolean autoFitPage; |
Shimeng (Simon) Wang | f739271 | 2010-03-10 16:44:31 -0800 | [diff] [blame] | 82 | private boolean loadsPageInOverviewMode; |
| 83 | private boolean showDebugSettings; |
Andrei Popescu | 0106870 | 2009-08-03 16:03:24 +0100 | [diff] [blame] | 84 | // HTML5 API flags |
Shimeng (Simon) Wang | f739271 | 2010-03-10 16:44:31 -0800 | [diff] [blame] | 85 | private boolean appCacheEnabled; |
| 86 | private boolean databaseEnabled; |
| 87 | private boolean domStorageEnabled; |
| 88 | private boolean geolocationEnabled; |
| 89 | private boolean workersEnabled; // only affects V8. JSC does not have a similar setting |
Andrei Popescu | 0106870 | 2009-08-03 16:03:24 +0100 | [diff] [blame] | 90 | // HTML5 API configuration params |
| 91 | private long appCacheMaxSize = Long.MAX_VALUE; |
| 92 | private String appCachePath; // default value set in loadFromDb(). |
| 93 | private String databasePath; // default value set in loadFromDb() |
Steve Block | 5029cf0 | 2009-08-21 13:16:58 +0100 | [diff] [blame] | 94 | private String geolocationDatabasePath; // default value set in loadFromDb() |
Andrei Popescu | 0106870 | 2009-08-03 16:03:24 +0100 | [diff] [blame] | 95 | private WebStorageSizeManager webStorageSizeManager; |
John Reck | 40badf2 | 2011-04-20 15:31:13 -0700 | [diff] [blame^] | 96 | // Accessibility settings |
| 97 | private int minimumFontSize = 1; |
| 98 | private WebSettings.TextSize textSize = WebSettings.TextSize.NORMAL; |
Andrei Popescu | 0106870 | 2009-08-03 16:03:24 +0100 | [diff] [blame] | 99 | |
| 100 | private String jsFlags = ""; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 101 | |
Nicolas Roard | 78a98e4 | 2009-05-11 13:34:17 +0100 | [diff] [blame] | 102 | private final static String TAG = "BrowserSettings"; |
| 103 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 104 | // Development settings |
| 105 | public WebSettings.LayoutAlgorithm layoutAlgorithm = |
| 106 | WebSettings.LayoutAlgorithm.NARROW_COLUMNS; |
| 107 | private boolean useWideViewPort = true; |
| 108 | private int userAgent = 0; |
| 109 | private boolean tracing = false; |
| 110 | private boolean lightTouch = false; |
| 111 | private boolean navDump = false; |
Derek Sollenberger | 8de8285 | 2010-11-18 19:51:50 -0500 | [diff] [blame] | 112 | private boolean hardwareAccelerated = true; |
Teng-Hui Zhu | 930ea22 | 2011-02-16 11:22:21 -0800 | [diff] [blame] | 113 | private boolean showVisualIndicator = false; |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 114 | // Lab settings |
| 115 | private boolean quickControls = false; |
John Reck | bafe58a | 2011-01-11 10:26:02 -0800 | [diff] [blame] | 116 | private boolean useMostVisitedHomepage = false; |
Narayan Kamath | 5119edd | 2011-02-23 15:49:17 +0000 | [diff] [blame] | 117 | private boolean useInstant = false; |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 118 | |
Ben Murdoch | bff2d60 | 2009-07-01 20:19:05 +0100 | [diff] [blame] | 119 | // By default the error console is shown once the user navigates to about:debug. |
| 120 | // The setting can be then toggled from the settings menu. |
| 121 | private boolean showConsole = true; |
| 122 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 123 | // Private preconfigured values |
Shimeng (Simon) Wang | b4fb25c | 2010-07-13 15:18:10 -0700 | [diff] [blame] | 124 | private static int minimumLogicalFontSize = 1; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 125 | private static int defaultFontSize = 16; |
| 126 | private static int defaultFixedFontSize = 13; |
Grace Kloba | 2f83068 | 2009-06-25 11:08:53 -0700 | [diff] [blame] | 127 | private static WebSettings.ZoomDensity zoomDensity = |
| 128 | WebSettings.ZoomDensity.MEDIUM; |
Grace Kloba | 9804c43 | 2009-12-02 11:07:40 -0800 | [diff] [blame] | 129 | private static int pageCacheCapacity; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 130 | |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 131 | |
Ben Murdoch | 23da30e | 2010-10-26 15:18:44 +0100 | [diff] [blame] | 132 | private AutoFillProfile autoFillProfile; |
Ben Murdoch | 6fa32ba | 2010-10-20 14:01:25 +0100 | [diff] [blame] | 133 | // Default to zero. In the case no profile is set up, the initial |
| 134 | // value will come from the AutoFillSettingsFragment when the user |
| 135 | // creates a profile. Otherwise, we'll read the ID of the last used |
| 136 | // profile from the prefs db. |
| 137 | private int autoFillActiveProfileId; |
Ben Murdoch | 23da30e | 2010-10-26 15:18:44 +0100 | [diff] [blame] | 138 | private static final int NO_AUTOFILL_PROFILE_SET = 0; |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 139 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 140 | // Preference keys that are used outside this class |
| 141 | public final static String PREF_CLEAR_CACHE = "privacy_clear_cache"; |
| 142 | public final static String PREF_CLEAR_COOKIES = "privacy_clear_cookies"; |
| 143 | public final static String PREF_CLEAR_HISTORY = "privacy_clear_history"; |
| 144 | public final static String PREF_HOMEPAGE = "homepage"; |
Bjorn Bringert | d69f51d | 2010-09-13 14:06:41 +0100 | [diff] [blame] | 145 | public final static String PREF_SEARCH_ENGINE = "search_engine"; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 146 | public final static String PREF_CLEAR_FORM_DATA = |
| 147 | "privacy_clear_form_data"; |
| 148 | public final static String PREF_CLEAR_PASSWORDS = |
| 149 | "privacy_clear_passwords"; |
| 150 | public final static String PREF_EXTRAS_RESET_DEFAULTS = |
| 151 | "reset_default_preferences"; |
| 152 | public final static String PREF_DEBUG_SETTINGS = "debug_menu"; |
Nicolas Roard | e46990e | 2009-06-19 16:27:49 +0100 | [diff] [blame] | 153 | public final static String PREF_WEBSITE_SETTINGS = "website_settings"; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 154 | public final static String PREF_TEXT_SIZE = "text_size"; |
Grace Kloba | 2f83068 | 2009-06-25 11:08:53 -0700 | [diff] [blame] | 155 | public final static String PREF_DEFAULT_ZOOM = "default_zoom"; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 156 | public final static String PREF_DEFAULT_TEXT_ENCODING = |
| 157 | "default_text_encoding"; |
Steve Block | c6f577f | 2009-08-20 18:11:08 +0100 | [diff] [blame] | 158 | public final static String PREF_CLEAR_GEOLOCATION_ACCESS = |
| 159 | "privacy_clear_geolocation_access"; |
Ben Murdoch | af55452 | 2010-09-10 22:09:30 +0100 | [diff] [blame] | 160 | public final static String PREF_AUTOFILL_ENABLED = "autofill_enabled"; |
| 161 | public final static String PREF_AUTOFILL_PROFILE = "autofill_profile"; |
Ben Murdoch | 6fa32ba | 2010-10-20 14:01:25 +0100 | [diff] [blame] | 162 | public final static String PREF_AUTOFILL_ACTIVE_PROFILE_ID = "autofill_active_profile_id"; |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 163 | public final static String PREF_HARDWARE_ACCEL = "enable_hardware_accel"; |
Teng-Hui Zhu | 930ea22 | 2011-02-16 11:22:21 -0800 | [diff] [blame] | 164 | public final static String PREF_VISUAL_INDICATOR = "enable_visual_indicator"; |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 165 | public final static String PREF_USER_AGENT = "user_agent"; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 166 | |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 167 | public final static String PREF_QUICK_CONTROLS = "enable_quick_controls"; |
John Reck | bafe58a | 2011-01-11 10:26:02 -0800 | [diff] [blame] | 168 | public final static String PREF_MOST_VISITED_HOMEPAGE = "use_most_visited_homepage"; |
John Reck | 282431b | 2011-01-20 17:38:37 -0800 | [diff] [blame] | 169 | public final static String PREF_PLUGIN_STATE = "plugin_state"; |
Narayan Kamath | 5119edd | 2011-02-23 15:49:17 +0000 | [diff] [blame] | 170 | public final static String PREF_USE_INSTANT = "use_instant_search"; |
John Reck | 40badf2 | 2011-04-20 15:31:13 -0700 | [diff] [blame^] | 171 | public final static String PREF_MIN_FONT_SIZE = "min_font_size"; |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 172 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 173 | private static final String DESKTOP_USERAGENT = "Mozilla/5.0 (Macintosh; " + |
Bart Sears | f6915fb | 2010-07-08 19:58:22 -0700 | [diff] [blame] | 174 | "U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/533.16 (KHTML, " + |
| 175 | "like Gecko) Version/5.0 Safari/533.16"; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 176 | |
| 177 | private static final String IPHONE_USERAGENT = "Mozilla/5.0 (iPhone; U; " + |
Bart Sears | f6915fb | 2010-07-08 19:58:22 -0700 | [diff] [blame] | 178 | "CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 " + |
| 179 | "(KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7"; |
| 180 | |
| 181 | private static final String IPAD_USERAGENT = "Mozilla/5.0 (iPad; U; " + |
| 182 | "CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 " + |
| 183 | "(KHTML, like Gecko) Version/4.0.4 Mobile/7B367 Safari/531.21.10"; |
| 184 | |
| 185 | private static final String FROYO_USERAGENT = "Mozilla/5.0 (Linux; U; " + |
| 186 | "Android 2.2; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 " + |
| 187 | "(KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 188 | |
| 189 | // Value to truncate strings when adding them to a TextView within |
| 190 | // a ListView |
| 191 | public final static int MAX_TEXTVIEW_LEN = 80; |
| 192 | |
Jeff Davidson | 4361029 | 2010-07-16 16:03:58 -0700 | [diff] [blame] | 193 | public static final String RLZ_PROVIDER = "com.google.android.partnersetup.rlzappprovider"; |
| 194 | |
| 195 | public static final Uri RLZ_PROVIDER_URI = Uri.parse("content://" + RLZ_PROVIDER + "/"); |
| 196 | |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 197 | // Set to true to enable some of the about:debug options |
John Reck | e55880d | 2011-03-18 12:49:03 -0700 | [diff] [blame] | 198 | public static final boolean DEV_BUILD = true; |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 199 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 200 | private Controller mController; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 201 | |
| 202 | // Single instance of the BrowserSettings for use in the Browser app. |
| 203 | private static BrowserSettings sSingleton; |
| 204 | |
| 205 | // Private map of WebSettings to Observer objects used when deleting an |
| 206 | // observer. |
| 207 | private HashMap<WebSettings,Observer> mWebSettingsToObservers = |
| 208 | new HashMap<WebSettings,Observer>(); |
| 209 | |
Ben Murdoch | ef67165 | 2010-11-25 17:17:58 +0000 | [diff] [blame] | 210 | private boolean mLoadFromDbComplete; |
| 211 | |
| 212 | public void waitForLoadFromDbToComplete() { |
| 213 | synchronized (sSingleton) { |
| 214 | while (!mLoadFromDbComplete) { |
| 215 | try { |
| 216 | sSingleton.wait(); |
| 217 | } catch (InterruptedException e) { } |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 222 | /* |
| 223 | * An observer wrapper for updating a WebSettings object with the new |
| 224 | * settings after a call to BrowserSettings.update(). |
| 225 | */ |
John Reck | 40badf2 | 2011-04-20 15:31:13 -0700 | [diff] [blame^] | 226 | public static class Observer implements java.util.Observer { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 227 | // Private WebSettings object that will be updated. |
| 228 | private WebSettings mSettings; |
| 229 | |
| 230 | Observer(WebSettings w) { |
| 231 | mSettings = w; |
| 232 | } |
| 233 | |
| 234 | public void update(Observable o, Object arg) { |
| 235 | BrowserSettings b = (BrowserSettings)o; |
| 236 | WebSettings s = mSettings; |
| 237 | |
| 238 | s.setLayoutAlgorithm(b.layoutAlgorithm); |
| 239 | if (b.userAgent == 0) { |
| 240 | // use the default ua string |
| 241 | s.setUserAgentString(null); |
| 242 | } else if (b.userAgent == 1) { |
| 243 | s.setUserAgentString(DESKTOP_USERAGENT); |
| 244 | } else if (b.userAgent == 2) { |
| 245 | s.setUserAgentString(IPHONE_USERAGENT); |
Bart Sears | f6915fb | 2010-07-08 19:58:22 -0700 | [diff] [blame] | 246 | } else if (b.userAgent == 3) { |
| 247 | s.setUserAgentString(IPAD_USERAGENT); |
| 248 | } else if (b.userAgent == 4) { |
| 249 | s.setUserAgentString(FROYO_USERAGENT); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 250 | } |
| 251 | s.setUseWideViewPort(b.useWideViewPort); |
| 252 | s.setLoadsImagesAutomatically(b.loadsImagesAutomatically); |
| 253 | s.setJavaScriptEnabled(b.javaScriptEnabled); |
Teng-Hui Zhu | 930ea22 | 2011-02-16 11:22:21 -0800 | [diff] [blame] | 254 | s.setShowVisualIndicator(b.showVisualIndicator); |
Patrick Scott | e536b33 | 2010-03-22 10:19:32 -0400 | [diff] [blame] | 255 | s.setPluginState(b.pluginState); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 256 | s.setJavaScriptCanOpenWindowsAutomatically( |
| 257 | b.javaScriptCanOpenWindowsAutomatically); |
| 258 | s.setDefaultTextEncodingName(b.defaultTextEncodingName); |
| 259 | s.setMinimumFontSize(b.minimumFontSize); |
| 260 | s.setMinimumLogicalFontSize(b.minimumLogicalFontSize); |
| 261 | s.setDefaultFontSize(b.defaultFontSize); |
| 262 | s.setDefaultFixedFontSize(b.defaultFixedFontSize); |
| 263 | s.setNavDump(b.navDump); |
| 264 | s.setTextSize(b.textSize); |
Grace Kloba | 2f83068 | 2009-06-25 11:08:53 -0700 | [diff] [blame] | 265 | s.setDefaultZoom(b.zoomDensity); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 266 | s.setLightTouchEnabled(b.lightTouch); |
| 267 | s.setSaveFormData(b.saveFormData); |
Ben Murdoch | ce549fc | 2010-09-09 10:28:08 +0100 | [diff] [blame] | 268 | s.setAutoFillEnabled(b.autoFillEnabled); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 269 | s.setSavePassword(b.rememberPasswords); |
Grace Kloba | 5b4b8f1 | 2009-08-05 17:19:17 -0700 | [diff] [blame] | 270 | s.setLoadWithOverviewMode(b.loadsPageInOverviewMode); |
Grace Kloba | 7956503 | 2009-11-24 14:23:39 -0800 | [diff] [blame] | 271 | s.setPageCacheCapacity(pageCacheCapacity); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 272 | |
| 273 | // WebView inside Browser doesn't want initial focus to be set. |
| 274 | s.setNeedInitialFocus(false); |
| 275 | // Browser supports multiple windows |
| 276 | s.setSupportMultipleWindows(true); |
Grace Kloba | 61fc77c | 2010-06-22 09:57:33 -0700 | [diff] [blame] | 277 | // enable smooth transition for better performance during panning or |
| 278 | // zooming |
| 279 | s.setEnableSmoothTransition(true); |
Patrick Scott | b92bbb4 | 2011-01-05 11:38:58 -0500 | [diff] [blame] | 280 | // disable content url access |
| 281 | s.setAllowContentAccess(false); |
Ben Murdoch | 092dd5d | 2009-04-22 12:34:12 +0100 | [diff] [blame] | 282 | |
Andrei Popescu | 0106870 | 2009-08-03 16:03:24 +0100 | [diff] [blame] | 283 | // HTML5 API flags |
| 284 | s.setAppCacheEnabled(b.appCacheEnabled); |
Ben Murdoch | 092dd5d | 2009-04-22 12:34:12 +0100 | [diff] [blame] | 285 | s.setDatabaseEnabled(b.databaseEnabled); |
Ben Murdoch | 734a066 | 2009-06-02 19:11:52 +0100 | [diff] [blame] | 286 | s.setDomStorageEnabled(b.domStorageEnabled); |
Andrei Popescu | 0106870 | 2009-08-03 16:03:24 +0100 | [diff] [blame] | 287 | s.setWorkersEnabled(b.workersEnabled); // This only affects V8. |
Steve Block | 97b0802 | 2009-08-21 10:26:25 +0100 | [diff] [blame] | 288 | s.setGeolocationEnabled(b.geolocationEnabled); |
Ben Murdoch | 092dd5d | 2009-04-22 12:34:12 +0100 | [diff] [blame] | 289 | |
Andrei Popescu | 0106870 | 2009-08-03 16:03:24 +0100 | [diff] [blame] | 290 | // HTML5 configuration parameters. |
Andrei Popescu | 20634ce | 2009-07-22 16:46:55 +0100 | [diff] [blame] | 291 | s.setAppCacheMaxSize(b.appCacheMaxSize); |
Andrei Popescu | 0106870 | 2009-08-03 16:03:24 +0100 | [diff] [blame] | 292 | s.setAppCachePath(b.appCachePath); |
| 293 | s.setDatabasePath(b.databasePath); |
Steve Block | 5029cf0 | 2009-08-21 13:16:58 +0100 | [diff] [blame] | 294 | s.setGeolocationDatabasePath(b.geolocationDatabasePath); |
Ben Murdoch | bff2d60 | 2009-07-01 20:19:05 +0100 | [diff] [blame] | 295 | |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 296 | // Active AutoFill profile data. |
Ben Murdoch | 23da30e | 2010-10-26 15:18:44 +0100 | [diff] [blame] | 297 | s.setAutoFillProfile(b.autoFillProfile); |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 298 | |
Shimeng (Simon) Wang | 161974f | 2010-03-09 14:30:07 -0800 | [diff] [blame] | 299 | b.updateTabControlSettings(); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 300 | } |
| 301 | } |
| 302 | |
| 303 | /** |
Ben Murdoch | ef67165 | 2010-11-25 17:17:58 +0000 | [diff] [blame] | 304 | * Load settings from the browser app's database. It is performed in |
| 305 | * an AsyncTask as it involves plenty of slow disk IO. |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 306 | * NOTE: Strings used for the preferences must match those specified |
Jeff Hamilton | 175ab30 | 2010-10-04 12:53:49 -0500 | [diff] [blame] | 307 | * in the various preference XML files. |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 308 | * @param ctx A Context object used to query the browser's settings |
| 309 | * database. If the database exists, the saved settings will be |
| 310 | * stored in this BrowserSettings object. This will update all |
| 311 | * observers of this object. |
| 312 | */ |
Ben Murdoch | ef67165 | 2010-11-25 17:17:58 +0000 | [diff] [blame] | 313 | public void asyncLoadFromDb(final Context ctx) { |
| 314 | mLoadFromDbComplete = false; |
| 315 | // Run the initial settings load in an AsyncTask as it hits the |
| 316 | // disk multiple times through SharedPreferences and SQLite. We |
| 317 | // need to be certain though that this has completed before we start |
| 318 | // to load pages though, so in the worst case we will block waiting |
| 319 | // for it to finish in BrowserActivity.onCreate(). |
| 320 | new LoadFromDbTask(ctx).execute(); |
| 321 | } |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 322 | |
Ben Murdoch | ef67165 | 2010-11-25 17:17:58 +0000 | [diff] [blame] | 323 | private class LoadFromDbTask extends AsyncTask<Void, Void, Void> { |
| 324 | private Context mContext; |
| 325 | |
| 326 | public LoadFromDbTask(Context context) { |
| 327 | mContext = context; |
Shimeng (Simon) Wang | e83e906 | 2010-03-29 16:13:09 -0700 | [diff] [blame] | 328 | } |
Ramanan Rajeswaran | dd4f429 | 2009-03-24 20:41:19 -0700 | [diff] [blame] | 329 | |
Ben Murdoch | ef67165 | 2010-11-25 17:17:58 +0000 | [diff] [blame] | 330 | protected Void doInBackground(Void... unused) { |
| 331 | SharedPreferences p = |
| 332 | PreferenceManager.getDefaultSharedPreferences(mContext); |
| 333 | // Set the default value for the Application Caches path. |
| 334 | appCachePath = mContext.getDir("appcache", 0).getPath(); |
| 335 | // Determine the maximum size of the application cache. |
| 336 | webStorageSizeManager = new WebStorageSizeManager( |
| 337 | mContext, |
| 338 | new WebStorageSizeManager.StatFsDiskInfo(appCachePath), |
| 339 | new WebStorageSizeManager.WebKitAppCacheInfo(appCachePath)); |
| 340 | appCacheMaxSize = webStorageSizeManager.getAppCacheMaxSize(); |
| 341 | // Set the default value for the Database path. |
| 342 | databasePath = mContext.getDir("databases", 0).getPath(); |
| 343 | // Set the default value for the Geolocation database path. |
| 344 | geolocationDatabasePath = mContext.getDir("geolocation", 0).getPath(); |
| 345 | |
John Reck | ef07426 | 2010-12-02 16:09:14 -0800 | [diff] [blame] | 346 | if (p.getString(PREF_HOMEPAGE, null) == null) { |
Ben Murdoch | ef67165 | 2010-11-25 17:17:58 +0000 | [diff] [blame] | 347 | // No home page preferences is set, set it to default. |
| 348 | setHomePage(mContext, getFactoryResetHomeUrl(mContext)); |
| 349 | } |
| 350 | |
| 351 | // the cost of one cached page is ~3M (measured using nytimes.com). For |
| 352 | // low end devices, we only cache one page. For high end devices, we try |
| 353 | // to cache more pages, currently choose 5. |
| 354 | ActivityManager am = (ActivityManager) mContext |
| 355 | .getSystemService(Context.ACTIVITY_SERVICE); |
| 356 | if (am.getMemoryClass() > 16) { |
| 357 | pageCacheCapacity = 5; |
| 358 | } else { |
| 359 | pageCacheCapacity = 1; |
| 360 | } |
| 361 | |
| 362 | // Read the last active AutoFill profile id. |
| 363 | autoFillActiveProfileId = p.getInt( |
| 364 | PREF_AUTOFILL_ACTIVE_PROFILE_ID, autoFillActiveProfileId); |
| 365 | |
| 366 | // Load the autofill profile data from the database. We use a database separate |
| 367 | // to the browser preference DB to make it easier to support multiple profiles |
| 368 | // and switching between them. |
| 369 | AutoFillProfileDatabase autoFillDb = AutoFillProfileDatabase.getInstance(mContext); |
| 370 | Cursor c = autoFillDb.getProfile(autoFillActiveProfileId); |
| 371 | |
| 372 | if (c.getCount() > 0) { |
| 373 | c.moveToFirst(); |
| 374 | |
| 375 | String fullName = c.getString(c.getColumnIndex( |
| 376 | AutoFillProfileDatabase.Profiles.FULL_NAME)); |
| 377 | String email = c.getString(c.getColumnIndex( |
| 378 | AutoFillProfileDatabase.Profiles.EMAIL_ADDRESS)); |
| 379 | String company = c.getString(c.getColumnIndex( |
| 380 | AutoFillProfileDatabase.Profiles.COMPANY_NAME)); |
| 381 | String addressLine1 = c.getString(c.getColumnIndex( |
| 382 | AutoFillProfileDatabase.Profiles.ADDRESS_LINE_1)); |
| 383 | String addressLine2 = c.getString(c.getColumnIndex( |
| 384 | AutoFillProfileDatabase.Profiles.ADDRESS_LINE_2)); |
| 385 | String city = c.getString(c.getColumnIndex( |
| 386 | AutoFillProfileDatabase.Profiles.CITY)); |
| 387 | String state = c.getString(c.getColumnIndex( |
| 388 | AutoFillProfileDatabase.Profiles.STATE)); |
| 389 | String zip = c.getString(c.getColumnIndex( |
| 390 | AutoFillProfileDatabase.Profiles.ZIP_CODE)); |
| 391 | String country = c.getString(c.getColumnIndex( |
| 392 | AutoFillProfileDatabase.Profiles.COUNTRY)); |
| 393 | String phone = c.getString(c.getColumnIndex( |
| 394 | AutoFillProfileDatabase.Profiles.PHONE_NUMBER)); |
| 395 | autoFillProfile = new AutoFillProfile(autoFillActiveProfileId, |
| 396 | fullName, email, company, addressLine1, addressLine2, city, |
| 397 | state, zip, country, phone); |
| 398 | } |
| 399 | c.close(); |
| 400 | autoFillDb.close(); |
| 401 | |
| 402 | // PreferenceManager.setDefaultValues is TOO SLOW, need to manually keep |
| 403 | // the defaults in sync |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 404 | p.registerOnSharedPreferenceChangeListener(BrowserSettings.this); |
Ben Murdoch | ef67165 | 2010-11-25 17:17:58 +0000 | [diff] [blame] | 405 | syncSharedPreferences(mContext, p); |
| 406 | |
| 407 | synchronized (sSingleton) { |
| 408 | mLoadFromDbComplete = true; |
| 409 | sSingleton.notify(); |
| 410 | } |
| 411 | return null; |
Grace Kloba | 9804c43 | 2009-12-02 11:07:40 -0800 | [diff] [blame] | 412 | } |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 413 | } |
| 414 | |
Narayan Kamath | 5119edd | 2011-02-23 15:49:17 +0000 | [diff] [blame] | 415 | private void updateSearchEngine(Context ctx, String searchEngineName, boolean force) { |
| 416 | if (force || searchEngine == null || |
| 417 | !searchEngine.getName().equals(searchEngineName)) { |
| 418 | if (searchEngine != null) { |
| 419 | if (searchEngine.supportsVoiceSearch()) { |
| 420 | // One or more tabs could have been in voice search mode. |
| 421 | // Clear it, since the new SearchEngine may not support |
| 422 | // it, or may handle it differently. |
| 423 | for (int i = 0; i < mController.getTabControl().getTabCount(); i++) { |
| 424 | mController.getTabControl().getTab(i).revertVoiceSearchMode(); |
| 425 | } |
| 426 | } |
| 427 | searchEngine.close(); |
| 428 | } |
| 429 | searchEngine = SearchEngines.get(ctx, searchEngineName); |
| 430 | |
| 431 | if (mController != null && (searchEngine instanceof InstantSearchEngine)) { |
| 432 | ((InstantSearchEngine) searchEngine).setController(mController); |
| 433 | } |
| 434 | } |
| 435 | } |
| 436 | |
John Reck | 40badf2 | 2011-04-20 15:31:13 -0700 | [diff] [blame^] | 437 | public void syncSharedPreferences(Context ctx, SharedPreferences p) { |
Ramanan Rajeswaran | dd4f429 | 2009-03-24 20:41:19 -0700 | [diff] [blame] | 438 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 439 | homeUrl = |
| 440 | p.getString(PREF_HOMEPAGE, homeUrl); |
Narayan Kamath | 5119edd | 2011-02-23 15:49:17 +0000 | [diff] [blame] | 441 | |
| 442 | useInstant = p.getBoolean(PREF_USE_INSTANT, useInstant); |
Leon Scroggins III | 3130660 | 2010-09-17 11:10:29 -0400 | [diff] [blame] | 443 | String searchEngineName = p.getString(PREF_SEARCH_ENGINE, |
Narayan Kamath | 5119edd | 2011-02-23 15:49:17 +0000 | [diff] [blame] | 444 | SearchEngine.GOOGLE); |
| 445 | updateSearchEngine(ctx, searchEngineName, false); |
Ramanan Rajeswaran | dd4f429 | 2009-03-24 20:41:19 -0700 | [diff] [blame] | 446 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 447 | loadsImagesAutomatically = p.getBoolean("load_images", |
| 448 | loadsImagesAutomatically); |
| 449 | javaScriptEnabled = p.getBoolean("enable_javascript", |
| 450 | javaScriptEnabled); |
Patrick Scott | e536b33 | 2010-03-22 10:19:32 -0400 | [diff] [blame] | 451 | pluginState = WebSettings.PluginState.valueOf( |
John Reck | 282431b | 2011-01-20 17:38:37 -0800 | [diff] [blame] | 452 | p.getString(PREF_PLUGIN_STATE, pluginState.name())); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 453 | javaScriptCanOpenWindowsAutomatically = !p.getBoolean( |
| 454 | "block_popup_windows", |
| 455 | !javaScriptCanOpenWindowsAutomatically); |
| 456 | showSecurityWarnings = p.getBoolean("show_security_warnings", |
| 457 | showSecurityWarnings); |
| 458 | rememberPasswords = p.getBoolean("remember_passwords", |
| 459 | rememberPasswords); |
| 460 | saveFormData = p.getBoolean("save_formdata", |
| 461 | saveFormData); |
Ben Murdoch | af55452 | 2010-09-10 22:09:30 +0100 | [diff] [blame] | 462 | autoFillEnabled = p.getBoolean("autofill_enabled", autoFillEnabled); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 463 | boolean accept_cookies = p.getBoolean("accept_cookies", |
| 464 | CookieManager.getInstance().acceptCookie()); |
| 465 | CookieManager.getInstance().setAcceptCookie(accept_cookies); |
| 466 | openInBackground = p.getBoolean("open_in_background", openInBackground); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 467 | textSize = WebSettings.TextSize.valueOf( |
| 468 | p.getString(PREF_TEXT_SIZE, textSize.name())); |
John Reck | 40badf2 | 2011-04-20 15:31:13 -0700 | [diff] [blame^] | 469 | minimumFontSize = p.getInt(PREF_MIN_FONT_SIZE, 1); |
Grace Kloba | 2f83068 | 2009-06-25 11:08:53 -0700 | [diff] [blame] | 470 | zoomDensity = WebSettings.ZoomDensity.valueOf( |
| 471 | p.getString(PREF_DEFAULT_ZOOM, zoomDensity.name())); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 472 | autoFitPage = p.getBoolean("autofit_pages", autoFitPage); |
Grace Kloba | 5b4b8f1 | 2009-08-05 17:19:17 -0700 | [diff] [blame] | 473 | loadsPageInOverviewMode = p.getBoolean("load_page", |
| 474 | loadsPageInOverviewMode); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 475 | useWideViewPort = true; // use wide view port for either setting |
| 476 | if (autoFitPage) { |
| 477 | layoutAlgorithm = WebSettings.LayoutAlgorithm.NARROW_COLUMNS; |
| 478 | } else { |
| 479 | layoutAlgorithm = WebSettings.LayoutAlgorithm.NORMAL; |
| 480 | } |
| 481 | defaultTextEncodingName = |
| 482 | p.getString(PREF_DEFAULT_TEXT_ENCODING, |
| 483 | defaultTextEncodingName); |
| 484 | |
| 485 | showDebugSettings = |
| 486 | p.getBoolean(PREF_DEBUG_SETTINGS, showDebugSettings); |
| 487 | // Debug menu items have precidence if the menu is visible |
| 488 | if (showDebugSettings) { |
| 489 | boolean small_screen = p.getBoolean("small_screen", |
| 490 | layoutAlgorithm == |
| 491 | WebSettings.LayoutAlgorithm.SINGLE_COLUMN); |
| 492 | if (small_screen) { |
| 493 | layoutAlgorithm = WebSettings.LayoutAlgorithm.SINGLE_COLUMN; |
| 494 | } else { |
| 495 | boolean normal_layout = p.getBoolean("normal_layout", |
| 496 | layoutAlgorithm == WebSettings.LayoutAlgorithm.NORMAL); |
| 497 | if (normal_layout) { |
| 498 | layoutAlgorithm = WebSettings.LayoutAlgorithm.NORMAL; |
| 499 | } else { |
| 500 | layoutAlgorithm = |
| 501 | WebSettings.LayoutAlgorithm.NARROW_COLUMNS; |
| 502 | } |
| 503 | } |
| 504 | useWideViewPort = p.getBoolean("wide_viewport", useWideViewPort); |
| 505 | tracing = p.getBoolean("enable_tracing", tracing); |
| 506 | lightTouch = p.getBoolean("enable_light_touch", lightTouch); |
| 507 | navDump = p.getBoolean("enable_nav_dump", navDump); |
Teng-Hui Zhu | 930ea22 | 2011-02-16 11:22:21 -0800 | [diff] [blame] | 508 | showVisualIndicator = p.getBoolean(PREF_VISUAL_INDICATOR, showVisualIndicator); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 509 | } |
Derek Sollenberger | ffa561e | 2010-11-16 14:19:01 -0500 | [diff] [blame] | 510 | |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 511 | quickControls = p.getBoolean(PREF_QUICK_CONTROLS, quickControls); |
John Reck | bafe58a | 2011-01-11 10:26:02 -0800 | [diff] [blame] | 512 | useMostVisitedHomepage = p.getBoolean(PREF_MOST_VISITED_HOMEPAGE, useMostVisitedHomepage); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 513 | |
John Reck | 3db2e07 | 2011-01-24 14:57:18 -0800 | [diff] [blame] | 514 | // Only set these if this is a dev build or debug is enabled |
| 515 | if (DEV_BUILD || showDebugSettings()) { |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 516 | userAgent = Integer.parseInt(p.getString(PREF_USER_AGENT, "0")); |
| 517 | hardwareAccelerated = p.getBoolean(PREF_HARDWARE_ACCEL, hardwareAccelerated); |
| 518 | } |
Derek Sollenberger | ffa561e | 2010-11-16 14:19:01 -0500 | [diff] [blame] | 519 | |
Feng Qian | b3c02da | 2009-06-29 15:58:08 -0700 | [diff] [blame] | 520 | // JS flags is loaded from DB even if showDebugSettings is false, |
| 521 | // so that it can be set once and be effective all the time. |
| 522 | jsFlags = p.getString("js_engine_flags", ""); |
Ben Murdoch | bff2d60 | 2009-07-01 20:19:05 +0100 | [diff] [blame] | 523 | |
| 524 | // Read the setting for showing/hiding the JS Console always so that should the |
| 525 | // user enable debug settings, we already know if we should show the console. |
| 526 | // The user will never see the console unless they navigate to about:debug, |
| 527 | // regardless of the setting we read here. This setting is only used after debug |
| 528 | // is enabled. |
| 529 | showConsole = p.getBoolean("javascript_console", showConsole); |
Grace Kloba | d9ee139 | 2009-07-20 11:53:33 -0700 | [diff] [blame] | 530 | |
Andrei Popescu | 0106870 | 2009-08-03 16:03:24 +0100 | [diff] [blame] | 531 | // HTML5 API flags |
| 532 | appCacheEnabled = p.getBoolean("enable_appcache", appCacheEnabled); |
| 533 | databaseEnabled = p.getBoolean("enable_database", databaseEnabled); |
| 534 | domStorageEnabled = p.getBoolean("enable_domstorage", domStorageEnabled); |
Steve Block | f344d03 | 2009-07-30 10:50:45 +0100 | [diff] [blame] | 535 | geolocationEnabled = p.getBoolean("enable_geolocation", geolocationEnabled); |
Andrei Popescu | 0106870 | 2009-08-03 16:03:24 +0100 | [diff] [blame] | 536 | workersEnabled = p.getBoolean("enable_workers", workersEnabled); |
Steve Block | f344d03 | 2009-07-30 10:50:45 +0100 | [diff] [blame] | 537 | |
Grace Kloba | d9ee139 | 2009-07-20 11:53:33 -0700 | [diff] [blame] | 538 | update(); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 539 | } |
| 540 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 541 | public String getHomePage() { |
John Reck | bafe58a | 2011-01-11 10:26:02 -0800 | [diff] [blame] | 542 | if (useMostVisitedHomepage) { |
| 543 | return HomeProvider.MOST_VISITED; |
| 544 | } |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 545 | return homeUrl; |
| 546 | } |
| 547 | |
Bjorn Bringert | d69f51d | 2010-09-13 14:06:41 +0100 | [diff] [blame] | 548 | public SearchEngine getSearchEngine() { |
| 549 | return searchEngine; |
| 550 | } |
| 551 | |
Feng Qian | b3c02da | 2009-06-29 15:58:08 -0700 | [diff] [blame] | 552 | public String getJsFlags() { |
| 553 | return jsFlags; |
| 554 | } |
| 555 | |
Andrei Popescu | 79e82b7 | 2009-07-27 12:01:59 +0100 | [diff] [blame] | 556 | public WebStorageSizeManager getWebStorageSizeManager() { |
| 557 | return webStorageSizeManager; |
| 558 | } |
| 559 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 560 | public void setHomePage(Context context, String url) { |
| 561 | Editor ed = PreferenceManager. |
| 562 | getDefaultSharedPreferences(context).edit(); |
| 563 | ed.putString(PREF_HOMEPAGE, url); |
Brad Fitzpatrick | 1a6e0e8 | 2010-09-01 16:29:03 -0700 | [diff] [blame] | 564 | ed.apply(); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 565 | homeUrl = url; |
| 566 | } |
| 567 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 568 | public WebSettings.TextSize getTextSize() { |
| 569 | return textSize; |
| 570 | } |
| 571 | |
John Reck | 40badf2 | 2011-04-20 15:31:13 -0700 | [diff] [blame^] | 572 | public int getMinimumFontSize() { |
| 573 | return minimumFontSize; |
| 574 | } |
| 575 | |
Grace Kloba | 2f83068 | 2009-06-25 11:08:53 -0700 | [diff] [blame] | 576 | public WebSettings.ZoomDensity getDefaultZoom() { |
| 577 | return zoomDensity; |
| 578 | } |
| 579 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 580 | public boolean openInBackground() { |
| 581 | return openInBackground; |
| 582 | } |
| 583 | |
| 584 | public boolean showSecurityWarnings() { |
| 585 | return showSecurityWarnings; |
| 586 | } |
| 587 | |
| 588 | public boolean isTracing() { |
| 589 | return tracing; |
| 590 | } |
| 591 | |
| 592 | public boolean isLightTouch() { |
| 593 | return lightTouch; |
| 594 | } |
| 595 | |
| 596 | public boolean isNavDump() { |
| 597 | return navDump; |
| 598 | } |
| 599 | |
Derek Sollenberger | ffa561e | 2010-11-16 14:19:01 -0500 | [diff] [blame] | 600 | public boolean isHardwareAccelerated() { |
| 601 | return hardwareAccelerated; |
| 602 | } |
| 603 | |
Teng-Hui Zhu | 930ea22 | 2011-02-16 11:22:21 -0800 | [diff] [blame] | 604 | public boolean showVisualIndicator() { |
| 605 | return showVisualIndicator; |
| 606 | } |
| 607 | |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 608 | public boolean useQuickControls() { |
| 609 | return quickControls; |
| 610 | } |
| 611 | |
John Reck | bafe58a | 2011-01-11 10:26:02 -0800 | [diff] [blame] | 612 | public boolean useMostVisitedHomepage() { |
| 613 | return useMostVisitedHomepage; |
| 614 | } |
| 615 | |
Narayan Kamath | 5119edd | 2011-02-23 15:49:17 +0000 | [diff] [blame] | 616 | public boolean useInstant() { |
| 617 | return useInstant; |
| 618 | } |
| 619 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 620 | public boolean showDebugSettings() { |
| 621 | return showDebugSettings; |
| 622 | } |
| 623 | |
John Reck | 3db2e07 | 2011-01-24 14:57:18 -0800 | [diff] [blame] | 624 | public void toggleDebugSettings(Context context) { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 625 | showDebugSettings = !showDebugSettings; |
| 626 | navDump = showDebugSettings; |
John Reck | 3db2e07 | 2011-01-24 14:57:18 -0800 | [diff] [blame] | 627 | syncSharedPreferences(context, |
| 628 | PreferenceManager.getDefaultSharedPreferences(context)); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 629 | update(); |
| 630 | } |
| 631 | |
Ben Murdoch | 23da30e | 2010-10-26 15:18:44 +0100 | [diff] [blame] | 632 | public void setAutoFillProfile(Context ctx, AutoFillProfile profile, Message msg) { |
| 633 | if (profile != null) { |
| 634 | setActiveAutoFillProfileId(ctx, profile.getUniqueId()); |
| 635 | // Update the AutoFill DB with the new profile. |
| 636 | new SaveProfileToDbTask(ctx, msg).execute(profile); |
| 637 | } else { |
| 638 | // Delete the current profile. |
Ben Murdoch | e8a2833 | 2010-11-17 14:16:21 +0000 | [diff] [blame] | 639 | if (autoFillProfile != null) { |
| 640 | new DeleteProfileFromDbTask(ctx, msg).execute(autoFillProfile.getUniqueId()); |
| 641 | setActiveAutoFillProfileId(ctx, NO_AUTOFILL_PROFILE_SET); |
| 642 | } |
Ben Murdoch | 23da30e | 2010-10-26 15:18:44 +0100 | [diff] [blame] | 643 | } |
| 644 | autoFillProfile = profile; |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 645 | } |
| 646 | |
| 647 | public AutoFillProfile getAutoFillProfile() { |
Ben Murdoch | 23da30e | 2010-10-26 15:18:44 +0100 | [diff] [blame] | 648 | return autoFillProfile; |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 649 | } |
| 650 | |
Ben Murdoch | 6fa32ba | 2010-10-20 14:01:25 +0100 | [diff] [blame] | 651 | private void setActiveAutoFillProfileId(Context context, int activeProfileId) { |
| 652 | autoFillActiveProfileId = activeProfileId; |
| 653 | Editor ed = PreferenceManager. |
| 654 | getDefaultSharedPreferences(context).edit(); |
| 655 | ed.putInt(PREF_AUTOFILL_ACTIVE_PROFILE_ID, activeProfileId); |
| 656 | ed.apply(); |
| 657 | } |
| 658 | |
Ben Murdoch | 8029a77 | 2010-11-16 11:58:21 +0000 | [diff] [blame] | 659 | /* package */ void disableAutoFill(Context ctx) { |
| 660 | autoFillEnabled = false; |
| 661 | Editor ed = PreferenceManager.getDefaultSharedPreferences(ctx).edit(); |
| 662 | ed.putBoolean(PREF_AUTOFILL_ENABLED, false); |
| 663 | ed.apply(); |
| 664 | } |
| 665 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 666 | /** |
| 667 | * Add a WebSettings object to the list of observers that will be updated |
| 668 | * when update() is called. |
| 669 | * |
| 670 | * @param s A WebSettings object that is strictly tied to the life of a |
| 671 | * WebView. |
| 672 | */ |
| 673 | public Observer addObserver(WebSettings s) { |
| 674 | Observer old = mWebSettingsToObservers.get(s); |
| 675 | if (old != null) { |
| 676 | super.deleteObserver(old); |
| 677 | } |
| 678 | Observer o = new Observer(s); |
| 679 | mWebSettingsToObservers.put(s, o); |
| 680 | super.addObserver(o); |
| 681 | return o; |
| 682 | } |
| 683 | |
| 684 | /** |
| 685 | * Delete the given WebSettings observer from the list of observers. |
| 686 | * @param s The WebSettings object to be deleted. |
| 687 | */ |
| 688 | public void deleteObserver(WebSettings s) { |
| 689 | Observer o = mWebSettingsToObservers.get(s); |
| 690 | if (o != null) { |
| 691 | mWebSettingsToObservers.remove(s); |
| 692 | super.deleteObserver(o); |
| 693 | } |
| 694 | } |
| 695 | |
| 696 | /* |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 697 | * Application level method for obtaining a single app instance of the |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 698 | * BrowserSettings. |
| 699 | */ |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 700 | public static BrowserSettings getInstance() { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 701 | if (sSingleton == null ) { |
| 702 | sSingleton = new BrowserSettings(); |
| 703 | } |
| 704 | return sSingleton; |
| 705 | } |
| 706 | |
| 707 | /* |
| 708 | * Package level method for associating the BrowserSettings with TabControl |
| 709 | */ |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 710 | /* package */void setController(Controller ctrl) { |
| 711 | mController = ctrl; |
Shimeng (Simon) Wang | 161974f | 2010-03-09 14:30:07 -0800 | [diff] [blame] | 712 | updateTabControlSettings(); |
Narayan Kamath | 5119edd | 2011-02-23 15:49:17 +0000 | [diff] [blame] | 713 | |
| 714 | if (mController != null && (searchEngine instanceof InstantSearchEngine)) { |
| 715 | ((InstantSearchEngine) searchEngine).setController(mController); |
| 716 | } |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 717 | } |
| 718 | |
| 719 | /* |
| 720 | * Update all the observers of the object. |
| 721 | */ |
| 722 | /*package*/ void update() { |
| 723 | setChanged(); |
| 724 | notifyObservers(); |
| 725 | } |
| 726 | |
| 727 | /*package*/ void clearCache(Context context) { |
| 728 | WebIconDatabase.getInstance().removeAllIcons(); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 729 | if (mController != null) { |
| 730 | WebView current = mController.getCurrentWebView(); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 731 | if (current != null) { |
| 732 | current.clearCache(true); |
| 733 | } |
| 734 | } |
| 735 | } |
| 736 | |
| 737 | /*package*/ void clearCookies(Context context) { |
| 738 | CookieManager.getInstance().removeAllCookie(); |
| 739 | } |
| 740 | |
| 741 | /* package */void clearHistory(Context context) { |
| 742 | ContentResolver resolver = context.getContentResolver(); |
| 743 | Browser.clearHistory(resolver); |
| 744 | Browser.clearSearches(resolver); |
| 745 | } |
| 746 | |
| 747 | /* package */ void clearFormData(Context context) { |
| 748 | WebViewDatabase.getInstance(context).clearFormData(); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 749 | if (mController!= null) { |
| 750 | WebView currentTopView = mController.getCurrentTopWebView(); |
Henrik Baard | 794dc72 | 2010-02-19 16:28:06 +0100 | [diff] [blame] | 751 | if (currentTopView != null) { |
| 752 | currentTopView.clearFormData(); |
| 753 | } |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 754 | } |
| 755 | } |
| 756 | |
| 757 | /*package*/ void clearPasswords(Context context) { |
| 758 | WebViewDatabase db = WebViewDatabase.getInstance(context); |
| 759 | db.clearUsernamePassword(); |
| 760 | db.clearHttpAuthUsernamePassword(); |
| 761 | } |
| 762 | |
Shimeng (Simon) Wang | 161974f | 2010-03-09 14:30:07 -0800 | [diff] [blame] | 763 | private void updateTabControlSettings() { |
| 764 | // Enable/disable the error console. |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 765 | mController.setShouldShowErrorConsole( |
Shimeng (Simon) Wang | 161974f | 2010-03-09 14:30:07 -0800 | [diff] [blame] | 766 | showDebugSettings && showConsole); |
Shimeng (Simon) Wang | 161974f | 2010-03-09 14:30:07 -0800 | [diff] [blame] | 767 | } |
| 768 | |
Nicolas Roard | 78a98e4 | 2009-05-11 13:34:17 +0100 | [diff] [blame] | 769 | /*package*/ void clearDatabases(Context context) { |
Andrei Popescu | 824faeb | 2009-07-21 18:24:06 +0100 | [diff] [blame] | 770 | WebStorage.getInstance().deleteAllData(); |
Steve Block | f344d03 | 2009-07-30 10:50:45 +0100 | [diff] [blame] | 771 | } |
| 772 | |
| 773 | /*package*/ void clearLocationAccess(Context context) { |
| 774 | GeolocationPermissions.getInstance().clearAll(); |
Nicolas Roard | 78a98e4 | 2009-05-11 13:34:17 +0100 | [diff] [blame] | 775 | } |
| 776 | |
Leon Scroggins | 9ac587d | 2009-04-20 12:53:46 -0400 | [diff] [blame] | 777 | /*package*/ void resetDefaultPreferences(Context ctx) { |
Shimeng (Simon) Wang | f739271 | 2010-03-10 16:44:31 -0800 | [diff] [blame] | 778 | reset(); |
Jeff Hamilton | 462b8e8 | 2010-09-23 14:33:43 -0500 | [diff] [blame] | 779 | SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(ctx); |
Brad Fitzpatrick | 1a6e0e8 | 2010-09-01 16:29:03 -0700 | [diff] [blame] | 780 | p.edit().clear().apply(); |
John Reck | 035a564 | 2010-12-21 18:51:27 -0800 | [diff] [blame] | 781 | PreferenceManager.setDefaultValues(ctx, R.xml.general_preferences, true); |
| 782 | PreferenceManager.setDefaultValues(ctx, R.xml.privacy_security_preferences, true); |
Jeff Hamilton | 462b8e8 | 2010-09-23 14:33:43 -0500 | [diff] [blame] | 783 | PreferenceManager.setDefaultValues(ctx, R.xml.advanced_preferences, true); |
Grace Kloba | f2c5c1b | 2009-05-26 10:48:31 -0700 | [diff] [blame] | 784 | // reset homeUrl |
Grace Kloba | a3f90f0 | 2009-05-26 11:32:53 -0700 | [diff] [blame] | 785 | setHomePage(ctx, getFactoryResetHomeUrl(ctx)); |
Andrei Popescu | 79e82b7 | 2009-07-27 12:01:59 +0100 | [diff] [blame] | 786 | // reset appcache max size |
| 787 | appCacheMaxSize = webStorageSizeManager.getAppCacheMaxSize(); |
Ben Murdoch | 23da30e | 2010-10-26 15:18:44 +0100 | [diff] [blame] | 788 | setActiveAutoFillProfileId(ctx, NO_AUTOFILL_PROFILE_SET); |
Grace Kloba | f2c5c1b | 2009-05-26 10:48:31 -0700 | [diff] [blame] | 789 | } |
| 790 | |
John Reck | 33bbb80 | 2010-10-26 17:13:42 -0700 | [diff] [blame] | 791 | /*package*/ static String getFactoryResetHomeUrl(Context context) { |
Grace Kloba | f2c5c1b | 2009-05-26 10:48:31 -0700 | [diff] [blame] | 792 | String url = context.getResources().getString(R.string.homepage_base); |
| 793 | if (url.indexOf("{CID}") != -1) { |
Patrick Scott | 4391469 | 2010-02-19 10:10:10 -0500 | [diff] [blame] | 794 | url = url.replace("{CID}", |
| 795 | BrowserProvider.getClientId(context.getContentResolver())); |
Grace Kloba | f2c5c1b | 2009-05-26 10:48:31 -0700 | [diff] [blame] | 796 | } |
| 797 | return url; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 798 | } |
| 799 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 800 | // Private constructor that does nothing. |
| 801 | private BrowserSettings() { |
Shimeng (Simon) Wang | f739271 | 2010-03-10 16:44:31 -0800 | [diff] [blame] | 802 | reset(); |
| 803 | } |
| 804 | |
| 805 | private void reset() { |
| 806 | // Private variables for settings |
| 807 | // NOTE: these defaults need to be kept in sync with the XML |
| 808 | // until the performance of PreferenceManager.setDefaultValues() |
| 809 | // is improved. |
| 810 | loadsImagesAutomatically = true; |
| 811 | javaScriptEnabled = true; |
Patrick Scott | e536b33 | 2010-03-22 10:19:32 -0400 | [diff] [blame] | 812 | pluginState = WebSettings.PluginState.ON; |
Shimeng (Simon) Wang | f739271 | 2010-03-10 16:44:31 -0800 | [diff] [blame] | 813 | javaScriptCanOpenWindowsAutomatically = false; |
| 814 | showSecurityWarnings = true; |
| 815 | rememberPasswords = true; |
| 816 | saveFormData = true; |
Ben Murdoch | dc62cb9 | 2010-11-23 15:11:29 +0000 | [diff] [blame] | 817 | autoFillEnabled = true; |
Shimeng (Simon) Wang | f739271 | 2010-03-10 16:44:31 -0800 | [diff] [blame] | 818 | openInBackground = false; |
Shimeng (Simon) Wang | f739271 | 2010-03-10 16:44:31 -0800 | [diff] [blame] | 819 | autoFitPage = true; |
Shimeng (Simon) Wang | f739271 | 2010-03-10 16:44:31 -0800 | [diff] [blame] | 820 | loadsPageInOverviewMode = true; |
| 821 | showDebugSettings = false; |
| 822 | // HTML5 API flags |
| 823 | appCacheEnabled = true; |
| 824 | databaseEnabled = true; |
| 825 | domStorageEnabled = true; |
| 826 | geolocationEnabled = true; |
| 827 | workersEnabled = true; // only affects V8. JSC does not have a similar setting |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 828 | } |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 829 | |
Ben Murdoch | 23da30e | 2010-10-26 15:18:44 +0100 | [diff] [blame] | 830 | private abstract class AutoFillProfileDbTask<T> extends AsyncTask<T, Void, Void> { |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 831 | Context mContext; |
Ben Murdoch | 36a23dd | 2010-10-13 13:20:06 +0100 | [diff] [blame] | 832 | AutoFillProfileDatabase mAutoFillProfileDb; |
Ben Murdoch | 23da30e | 2010-10-26 15:18:44 +0100 | [diff] [blame] | 833 | Message mCompleteMessage; |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 834 | |
Ben Murdoch | 23da30e | 2010-10-26 15:18:44 +0100 | [diff] [blame] | 835 | public AutoFillProfileDbTask(Context ctx, Message msg) { |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 836 | mContext = ctx; |
Ben Murdoch | 23da30e | 2010-10-26 15:18:44 +0100 | [diff] [blame] | 837 | mCompleteMessage = msg; |
| 838 | } |
| 839 | |
| 840 | protected void onPostExecute(Void result) { |
| 841 | if (mCompleteMessage != null) { |
| 842 | mCompleteMessage.sendToTarget(); |
| 843 | } |
| 844 | mAutoFillProfileDb.close(); |
| 845 | } |
| 846 | |
| 847 | abstract protected Void doInBackground(T... values); |
| 848 | } |
| 849 | |
| 850 | |
| 851 | private class SaveProfileToDbTask extends AutoFillProfileDbTask<AutoFillProfile> { |
| 852 | public SaveProfileToDbTask(Context ctx, Message msg) { |
| 853 | super(ctx, msg); |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 854 | } |
| 855 | |
| 856 | protected Void doInBackground(AutoFillProfile... values) { |
Ben Murdoch | 36a23dd | 2010-10-13 13:20:06 +0100 | [diff] [blame] | 857 | mAutoFillProfileDb = AutoFillProfileDatabase.getInstance(mContext); |
Ben Murdoch | 23da30e | 2010-10-26 15:18:44 +0100 | [diff] [blame] | 858 | assert autoFillActiveProfileId != NO_AUTOFILL_PROFILE_SET; |
| 859 | AutoFillProfile newProfile = values[0]; |
| 860 | mAutoFillProfileDb.addOrUpdateProfile(autoFillActiveProfileId, newProfile); |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 861 | return null; |
| 862 | } |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 863 | } |
| 864 | |
Ben Murdoch | 23da30e | 2010-10-26 15:18:44 +0100 | [diff] [blame] | 865 | private class DeleteProfileFromDbTask extends AutoFillProfileDbTask<Integer> { |
| 866 | public DeleteProfileFromDbTask(Context ctx, Message msg) { |
| 867 | super(ctx, msg); |
| 868 | } |
| 869 | |
| 870 | protected Void doInBackground(Integer... values) { |
| 871 | mAutoFillProfileDb = AutoFillProfileDatabase.getInstance(mContext); |
| 872 | int id = values[0]; |
| 873 | assert id > 0; |
| 874 | mAutoFillProfileDb.dropProfile(id); |
| 875 | return null; |
| 876 | } |
| 877 | } |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 878 | |
| 879 | @Override |
| 880 | public void onSharedPreferenceChanged( |
| 881 | SharedPreferences p, String key) { |
| 882 | if (PREF_HARDWARE_ACCEL.equals(key)) { |
| 883 | hardwareAccelerated = p.getBoolean(PREF_HARDWARE_ACCEL, hardwareAccelerated); |
Teng-Hui Zhu | 930ea22 | 2011-02-16 11:22:21 -0800 | [diff] [blame] | 884 | } else if (PREF_VISUAL_INDICATOR.equals(key)) { |
| 885 | showVisualIndicator = p.getBoolean(PREF_VISUAL_INDICATOR, showVisualIndicator); |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 886 | } else if (PREF_USER_AGENT.equals(key)) { |
| 887 | userAgent = Integer.parseInt(p.getString(PREF_USER_AGENT, "0")); |
| 888 | update(); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 889 | } else if (PREF_QUICK_CONTROLS.equals(key)) { |
| 890 | quickControls = p.getBoolean(PREF_QUICK_CONTROLS, quickControls); |
John Reck | bafe58a | 2011-01-11 10:26:02 -0800 | [diff] [blame] | 891 | } else if (PREF_MOST_VISITED_HOMEPAGE.equals(key)) { |
| 892 | useMostVisitedHomepage = p.getBoolean(PREF_MOST_VISITED_HOMEPAGE, useMostVisitedHomepage); |
Narayan Kamath | 5119edd | 2011-02-23 15:49:17 +0000 | [diff] [blame] | 893 | } else if (PREF_USE_INSTANT.equals(key)) { |
| 894 | useInstant = p.getBoolean(PREF_USE_INSTANT, useInstant); |
| 895 | updateSearchEngine(mController.getActivity(), SearchEngine.GOOGLE, true); |
| 896 | } else if (PREF_SEARCH_ENGINE.equals(key)) { |
| 897 | final String searchEngineName = p.getString(PREF_SEARCH_ENGINE, |
| 898 | SearchEngine.GOOGLE); |
| 899 | updateSearchEngine(mController.getActivity(), searchEngineName, false); |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 900 | } |
| 901 | } |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 902 | } |