The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 1 | /* |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 2 | * Copyright (C) 2011 The Android Open Source Project |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.browser; |
| 18 | |
Grace Kloba | 9804c43 | 2009-12-02 11:07:40 -0800 | [diff] [blame] | 19 | import android.app.ActivityManager; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 20 | import android.content.ContentResolver; |
| 21 | import android.content.Context; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 22 | import android.content.SharedPreferences; |
John Reck | 812d2d6 | 2011-01-18 14:16:15 -0800 | [diff] [blame] | 23 | import android.content.SharedPreferences.OnSharedPreferenceChangeListener; |
John Reck | f48314f | 2011-04-27 17:52:17 -0700 | [diff] [blame] | 24 | import android.os.Build; |
Ben Murdoch | 23da30e | 2010-10-26 15:18:44 +0100 | [diff] [blame] | 25 | import android.os.Message; |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 26 | import android.preference.PreferenceManager; |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 27 | import android.provider.Browser; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 28 | import android.webkit.CookieManager; |
Steve Block | f344d03 | 2009-07-30 10:50:45 +0100 | [diff] [blame] | 29 | import android.webkit.GeolocationPermissions; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 30 | import android.webkit.WebIconDatabase; |
| 31 | import android.webkit.WebSettings; |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 32 | import android.webkit.WebSettings.AutoFillProfile; |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 33 | import android.webkit.WebSettings.LayoutAlgorithm; |
| 34 | import android.webkit.WebSettings.PluginState; |
| 35 | import android.webkit.WebSettings.TextSize; |
| 36 | import android.webkit.WebSettings.ZoomDensity; |
Nicolas Roard | 78a98e4 | 2009-05-11 13:34:17 +0100 | [diff] [blame] | 37 | import android.webkit.WebStorage; |
John Reck | 812d2d6 | 2011-01-18 14:16:15 -0800 | [diff] [blame] | 38 | import android.webkit.WebView; |
| 39 | import android.webkit.WebViewDatabase; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 40 | |
John Reck | 4650033 | 2011-06-07 14:36:10 -0700 | [diff] [blame] | 41 | import com.android.browser.homepages.HomeProvider; |
| 42 | import com.android.browser.provider.BrowserProvider; |
| 43 | import com.android.browser.search.SearchEngine; |
| 44 | import com.android.browser.search.SearchEngines; |
| 45 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 46 | import java.lang.ref.WeakReference; |
| 47 | import java.util.Iterator; |
| 48 | import java.util.LinkedList; |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 49 | import java.util.WeakHashMap; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 50 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 51 | /** |
| 52 | * Class for managing settings |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 53 | */ |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 54 | public class BrowserSettings implements OnSharedPreferenceChangeListener, |
| 55 | PreferenceKeys { |
Andrei Popescu | 0106870 | 2009-08-03 16:03:24 +0100 | [diff] [blame] | 56 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 57 | // TODO: Do something with this UserAgent stuff |
John Reck | 7fd1e8f | 2011-04-27 18:22:57 -0700 | [diff] [blame] | 58 | private static final String DESKTOP_USERAGENT = "Mozilla/5.0 (X11; " + |
| 59 | "Linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) " + |
| 60 | "Chrome/11.0.696.34 Safari/534.24"; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 61 | |
| 62 | private static final String IPHONE_USERAGENT = "Mozilla/5.0 (iPhone; U; " + |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 63 | "CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 " + |
| 64 | "(KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7"; |
Bart Sears | f6915fb | 2010-07-08 19:58:22 -0700 | [diff] [blame] | 65 | |
| 66 | private static final String IPAD_USERAGENT = "Mozilla/5.0 (iPad; U; " + |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 67 | "CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 " + |
| 68 | "(KHTML, like Gecko) Version/4.0.4 Mobile/7B367 Safari/531.21.10"; |
Bart Sears | f6915fb | 2010-07-08 19:58:22 -0700 | [diff] [blame] | 69 | |
| 70 | private static final String FROYO_USERAGENT = "Mozilla/5.0 (Linux; U; " + |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 71 | "Android 2.2; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 " + |
| 72 | "(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] | 73 | |
John Reck | 7fd1e8f | 2011-04-27 18:22:57 -0700 | [diff] [blame] | 74 | private static final String HONEYCOMB_USERAGENT = "Mozilla/5.0 (Linux; U; " + |
| 75 | "Android 3.1; en-us; Xoom Build/HMJ25) AppleWebKit/534.13 " + |
| 76 | "(KHTML, like Gecko) Version/4.0 Safari/534.13"; |
| 77 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 78 | private static final String USER_AGENTS[] = { null, |
| 79 | DESKTOP_USERAGENT, |
| 80 | IPHONE_USERAGENT, |
| 81 | IPAD_USERAGENT, |
John Reck | 7fd1e8f | 2011-04-27 18:22:57 -0700 | [diff] [blame] | 82 | FROYO_USERAGENT, |
| 83 | HONEYCOMB_USERAGENT, |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 84 | }; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 85 | |
John Reck | 8fc22a1 | 2011-06-16 14:57:41 -0700 | [diff] [blame] | 86 | // The minimum min font size |
| 87 | // Aka, the lower bounds for the min font size range |
| 88 | // which is 1:5..24 |
| 89 | private static final int MIN_FONT_SIZE_OFFSET = 5; |
John Reck | 7dc444b | 2011-06-16 17:44:29 -0700 | [diff] [blame] | 90 | // The initial value in the text zoom range |
| 91 | // This is what represents 100% in the SeekBarPreference range |
| 92 | private static final int TEXT_ZOOM_START_VAL = 10; |
| 93 | // The size of a single step in the text zoom range, in percent |
| 94 | private static final int TEXT_ZOOM_STEP = 5; |
John Reck | 8fc22a1 | 2011-06-16 14:57:41 -0700 | [diff] [blame] | 95 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 96 | private static BrowserSettings sInstance; |
Jeff Davidson | 4361029 | 2010-07-16 16:03:58 -0700 | [diff] [blame] | 97 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 98 | private Context mContext; |
| 99 | private SharedPreferences mPrefs; |
| 100 | private LinkedList<WeakReference<WebSettings>> mManagedSettings; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 101 | private Controller mController; |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 102 | private WebStorageSizeManager mWebStorageSizeManager; |
| 103 | private AutofillHandler mAutofillHandler; |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 104 | private WeakHashMap<WebSettings, String> mCustomUserAgents; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 105 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 106 | // Cached settings |
| 107 | private SearchEngine mSearchEngine; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 108 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 109 | public static void initialize(final Context context) { |
| 110 | sInstance = new BrowserSettings(context); |
| 111 | } |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 112 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 113 | public static BrowserSettings getInstance() { |
| 114 | return sInstance; |
| 115 | } |
Ben Murdoch | ef67165 | 2010-11-25 17:17:58 +0000 | [diff] [blame] | 116 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 117 | private BrowserSettings(Context context) { |
| 118 | mContext = context; |
| 119 | mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext); |
John Reck | f48314f | 2011-04-27 17:52:17 -0700 | [diff] [blame] | 120 | if (Build.VERSION.CODENAME.equals("REL")) { |
| 121 | // This is a release build, always startup with debug disabled |
| 122 | setDebugEnabled(false); |
| 123 | } |
John Reck | 7dc444b | 2011-06-16 17:44:29 -0700 | [diff] [blame] | 124 | if (mPrefs.contains(PREF_TEXT_SIZE)) { |
| 125 | /* |
| 126 | * Update from TextSize enum to zoom percent |
| 127 | * SMALLEST is 50% |
| 128 | * SMALLER is 75% |
| 129 | * NORMAL is 100% |
| 130 | * LARGER is 150% |
| 131 | * LARGEST is 200% |
| 132 | */ |
| 133 | switch (getTextSize()) { |
| 134 | case SMALLEST: |
| 135 | setTextZoom(50); |
| 136 | break; |
| 137 | case SMALLER: |
| 138 | setTextZoom(75); |
| 139 | break; |
| 140 | case LARGER: |
| 141 | setTextZoom(150); |
| 142 | break; |
| 143 | case LARGEST: |
| 144 | setTextZoom(200); |
| 145 | break; |
| 146 | } |
| 147 | mPrefs.edit().remove(PREF_TEXT_SIZE).apply(); |
| 148 | } |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 149 | mAutofillHandler = new AutofillHandler(mContext); |
| 150 | mManagedSettings = new LinkedList<WeakReference<WebSettings>>(); |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 151 | mCustomUserAgents = new WeakHashMap<WebSettings, String>(); |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 152 | mWebStorageSizeManager = new WebStorageSizeManager(mContext, |
| 153 | new WebStorageSizeManager.StatFsDiskInfo(getAppCachePath()), |
| 154 | new WebStorageSizeManager.WebKitAppCacheInfo(getAppCachePath())); |
| 155 | mPrefs.registerOnSharedPreferenceChangeListener(this); |
| 156 | mAutofillHandler.asyncLoadFromDb(); |
| 157 | } |
| 158 | |
| 159 | public void setController(Controller controller) { |
| 160 | mController = controller; |
| 161 | syncSharedSettings(); |
| 162 | |
| 163 | if (mController != null && (mSearchEngine instanceof InstantSearchEngine)) { |
| 164 | ((InstantSearchEngine) mSearchEngine).setController(mController); |
Ben Murdoch | ef67165 | 2010-11-25 17:17:58 +0000 | [diff] [blame] | 165 | } |
| 166 | } |
| 167 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 168 | public void startManagingSettings(WebSettings settings) { |
| 169 | synchronized (mManagedSettings) { |
| 170 | syncStaticSettings(settings); |
| 171 | syncSetting(settings); |
| 172 | mManagedSettings.add(new WeakReference<WebSettings>(settings)); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 173 | } |
| 174 | } |
| 175 | |
| 176 | /** |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 177 | * Syncs all the settings that have a Preference UI |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 178 | */ |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 179 | private void syncSetting(WebSettings settings) { |
| 180 | settings.setGeolocationEnabled(enableGeolocation()); |
| 181 | settings.setJavaScriptEnabled(enableJavascript()); |
| 182 | settings.setLightTouchEnabled(enableLightTouch()); |
| 183 | settings.setNavDump(enableNavDump()); |
| 184 | settings.setShowVisualIndicator(enableVisualIndicator()); |
| 185 | settings.setDefaultTextEncodingName(getDefaultTextEncoding()); |
| 186 | settings.setDefaultZoom(getDefaultZoom()); |
| 187 | settings.setMinimumFontSize(getMinimumFontSize()); |
| 188 | settings.setMinimumLogicalFontSize(getMinimumFontSize()); |
John Reck | 92f25f8 | 2011-04-26 16:57:10 -0700 | [diff] [blame] | 189 | settings.setForceUserScalable(forceEnableUserScalable()); |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 190 | settings.setPluginState(getPluginState()); |
John Reck | 7dc444b | 2011-06-16 17:44:29 -0700 | [diff] [blame] | 191 | settings.setTextZoom(getTextZoom()); |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 192 | settings.setAutoFillEnabled(isAutofillEnabled()); |
| 193 | settings.setLayoutAlgorithm(getLayoutAlgorithm()); |
| 194 | settings.setJavaScriptCanOpenWindowsAutomatically(blockPopupWindows()); |
| 195 | settings.setLoadsImagesAutomatically(loadImages()); |
| 196 | settings.setLoadWithOverviewMode(loadPageInOverviewMode()); |
| 197 | settings.setSavePassword(rememberPasswords()); |
| 198 | settings.setSaveFormData(saveFormdata()); |
| 199 | settings.setUseWideViewPort(isWideViewport()); |
| 200 | settings.setAutoFillProfile(getAutoFillProfile()); |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 201 | |
| 202 | String ua = mCustomUserAgents.get(settings); |
John Reck | 4650033 | 2011-06-07 14:36:10 -0700 | [diff] [blame] | 203 | if (ua != null) { |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 204 | settings.setUserAgentString(ua); |
| 205 | } else { |
| 206 | settings.setUserAgentString(USER_AGENTS[getUserAgent()]); |
| 207 | } |
Ben Murdoch | ef67165 | 2010-11-25 17:17:58 +0000 | [diff] [blame] | 208 | } |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 209 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 210 | /** |
| 211 | * Syncs all the settings that have no UI |
| 212 | * These cannot change, so we only need to set them once per WebSettings |
| 213 | */ |
| 214 | private void syncStaticSettings(WebSettings settings) { |
| 215 | settings.setDefaultFontSize(16); |
| 216 | settings.setDefaultFixedFontSize(13); |
| 217 | settings.setPageCacheCapacity(getPageCacheCapacity()); |
Ben Murdoch | ef67165 | 2010-11-25 17:17:58 +0000 | [diff] [blame] | 218 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 219 | // WebView inside Browser doesn't want initial focus to be set. |
| 220 | settings.setNeedInitialFocus(false); |
| 221 | // Browser supports multiple windows |
| 222 | settings.setSupportMultipleWindows(true); |
| 223 | // enable smooth transition for better performance during panning or |
| 224 | // zooming |
| 225 | settings.setEnableSmoothTransition(true); |
| 226 | // disable content url access |
| 227 | settings.setAllowContentAccess(false); |
| 228 | |
| 229 | // HTML5 API flags |
| 230 | settings.setAppCacheEnabled(true); |
| 231 | settings.setDatabaseEnabled(true); |
| 232 | settings.setDomStorageEnabled(true); |
| 233 | settings.setWorkersEnabled(true); // This only affects V8. |
| 234 | |
| 235 | // HTML5 configuration parametersettings. |
| 236 | settings.setAppCacheMaxSize(mWebStorageSizeManager.getAppCacheMaxSize()); |
| 237 | settings.setAppCachePath(getAppCachePath()); |
| 238 | settings.setDatabasePath(mContext.getDir("databases", 0).getPath()); |
| 239 | settings.setGeolocationDatabasePath(mContext.getDir("geolocation", 0).getPath()); |
| 240 | } |
| 241 | |
| 242 | private void syncSharedSettings() { |
| 243 | CookieManager.getInstance().setAcceptCookie(acceptCookies()); |
| 244 | if (mController != null) { |
| 245 | mController.setShouldShowErrorConsole(enableJavascriptConsole()); |
Shimeng (Simon) Wang | e83e906 | 2010-03-29 16:13:09 -0700 | [diff] [blame] | 246 | } |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 247 | } |
Ramanan Rajeswaran | dd4f429 | 2009-03-24 20:41:19 -0700 | [diff] [blame] | 248 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 249 | private void syncManagedSettings() { |
| 250 | syncSharedSettings(); |
| 251 | synchronized (mManagedSettings) { |
| 252 | Iterator<WeakReference<WebSettings>> iter = mManagedSettings.iterator(); |
| 253 | while (iter.hasNext()) { |
| 254 | WeakReference<WebSettings> ref = iter.next(); |
| 255 | WebSettings settings = ref.get(); |
| 256 | if (settings == null) { |
| 257 | iter.remove(); |
| 258 | continue; |
| 259 | } |
| 260 | syncSetting(settings); |
Ben Murdoch | ef67165 | 2010-11-25 17:17:58 +0000 | [diff] [blame] | 261 | } |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 262 | } |
| 263 | } |
Ben Murdoch | ef67165 | 2010-11-25 17:17:58 +0000 | [diff] [blame] | 264 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 265 | @Override |
| 266 | public void onSharedPreferenceChanged( |
| 267 | SharedPreferences sharedPreferences, String key) { |
| 268 | syncManagedSettings(); |
| 269 | if (PREF_SEARCH_ENGINE.equals(key)) { |
| 270 | updateSearchEngine(false); |
| 271 | } |
| 272 | if (PREF_USE_INSTANT_SEARCH.equals(key)) { |
| 273 | updateSearchEngine(true); |
| 274 | } |
Michael Kolb | c38c604 | 2011-04-27 10:46:06 -0700 | [diff] [blame] | 275 | if (PREF_FULLSCREEN.equals(key)) { |
| 276 | if (mController.getUi() != null) { |
| 277 | mController.getUi().setFullscreen(useFullscreen()); |
| 278 | } |
Michael Kolb | 0241e75 | 2011-07-07 14:58:50 -0700 | [diff] [blame] | 279 | } else if (PREF_ENABLE_QUICK_CONTROLS.equals(key)) { |
| 280 | if (mController.getUi() != null) { |
| 281 | mController.getUi().setUseQuickControls(sharedPreferences.getBoolean(key, false)); |
| 282 | } |
Michael Kolb | c38c604 | 2011-04-27 10:46:06 -0700 | [diff] [blame] | 283 | } |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 284 | } |
| 285 | |
John Reck | 961d35d | 2011-06-23 09:45:54 -0700 | [diff] [blame] | 286 | public static String getFactoryResetHomeUrl(Context context) { |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 287 | String url = context.getResources().getString(R.string.homepage_base); |
| 288 | if (url.indexOf("{CID}") != -1) { |
| 289 | url = url.replace("{CID}", |
| 290 | BrowserProvider.getClientId(context.getContentResolver())); |
| 291 | } |
| 292 | return url; |
| 293 | } |
| 294 | |
| 295 | public LayoutAlgorithm getLayoutAlgorithm() { |
| 296 | LayoutAlgorithm layoutAlgorithm = LayoutAlgorithm.NORMAL; |
| 297 | if (autofitPages()) { |
| 298 | layoutAlgorithm = LayoutAlgorithm.NARROW_COLUMNS; |
| 299 | } |
| 300 | if (isDebugEnabled()) { |
| 301 | if (isSmallScreen()) { |
| 302 | layoutAlgorithm = LayoutAlgorithm.SINGLE_COLUMN; |
Ben Murdoch | ef67165 | 2010-11-25 17:17:58 +0000 | [diff] [blame] | 303 | } else { |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 304 | if (isNormalLayout()) { |
| 305 | layoutAlgorithm = LayoutAlgorithm.NORMAL; |
| 306 | } else { |
| 307 | layoutAlgorithm = LayoutAlgorithm.NARROW_COLUMNS; |
| 308 | } |
Ben Murdoch | ef67165 | 2010-11-25 17:17:58 +0000 | [diff] [blame] | 309 | } |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 310 | } |
| 311 | return layoutAlgorithm; |
| 312 | } |
Ben Murdoch | ef67165 | 2010-11-25 17:17:58 +0000 | [diff] [blame] | 313 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 314 | // TODO: Cache |
| 315 | public int getPageCacheCapacity() { |
| 316 | // the cost of one cached page is ~3M (measured using nytimes.com). For |
| 317 | // low end devices, we only cache one page. For high end devices, we try |
| 318 | // to cache more pages, currently choose 5. |
| 319 | if (ActivityManager.staticGetMemoryClass() > 16) { |
| 320 | return 5; |
| 321 | } else { |
| 322 | return 1; |
Grace Kloba | 9804c43 | 2009-12-02 11:07:40 -0800 | [diff] [blame] | 323 | } |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 324 | } |
| 325 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 326 | public WebStorageSizeManager getWebStorageSizeManager() { |
| 327 | return mWebStorageSizeManager; |
| 328 | } |
| 329 | |
| 330 | // TODO: Cache |
| 331 | private String getAppCachePath() { |
| 332 | return mContext.getDir("appcache", 0).getPath(); |
| 333 | } |
| 334 | |
| 335 | private void updateSearchEngine(boolean force) { |
| 336 | String searchEngineName = getSearchEngineName(); |
| 337 | if (force || mSearchEngine == null || |
| 338 | !mSearchEngine.getName().equals(searchEngineName)) { |
| 339 | if (mSearchEngine != null) { |
| 340 | if (mSearchEngine.supportsVoiceSearch()) { |
Narayan Kamath | 5119edd | 2011-02-23 15:49:17 +0000 | [diff] [blame] | 341 | // One or more tabs could have been in voice search mode. |
| 342 | // Clear it, since the new SearchEngine may not support |
| 343 | // it, or may handle it differently. |
| 344 | for (int i = 0; i < mController.getTabControl().getTabCount(); i++) { |
| 345 | mController.getTabControl().getTab(i).revertVoiceSearchMode(); |
| 346 | } |
| 347 | } |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 348 | mSearchEngine.close(); |
Narayan Kamath | 5119edd | 2011-02-23 15:49:17 +0000 | [diff] [blame] | 349 | } |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 350 | mSearchEngine = SearchEngines.get(mContext, searchEngineName); |
Narayan Kamath | 5119edd | 2011-02-23 15:49:17 +0000 | [diff] [blame] | 351 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 352 | if (mController != null && (mSearchEngine instanceof InstantSearchEngine)) { |
| 353 | ((InstantSearchEngine) mSearchEngine).setController(mController); |
Narayan Kamath | 5119edd | 2011-02-23 15:49:17 +0000 | [diff] [blame] | 354 | } |
| 355 | } |
| 356 | } |
| 357 | |
Bjorn Bringert | d69f51d | 2010-09-13 14:06:41 +0100 | [diff] [blame] | 358 | public SearchEngine getSearchEngine() { |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 359 | if (mSearchEngine == null) { |
| 360 | updateSearchEngine(false); |
Ben Murdoch | 23da30e | 2010-10-26 15:18:44 +0100 | [diff] [blame] | 361 | } |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 362 | return mSearchEngine; |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 363 | } |
| 364 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 365 | public boolean isDebugEnabled() { |
| 366 | return mPrefs.getBoolean(PREF_DEBUG_MENU, false); |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 367 | } |
| 368 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 369 | public void setDebugEnabled(boolean value) { |
| 370 | mPrefs.edit().putBoolean(PREF_DEBUG_MENU, value).apply(); |
Ben Murdoch | 6fa32ba | 2010-10-20 14:01:25 +0100 | [diff] [blame] | 371 | } |
| 372 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 373 | public void clearCache() { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 374 | WebIconDatabase.getInstance().removeAllIcons(); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 375 | if (mController != null) { |
| 376 | WebView current = mController.getCurrentWebView(); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 377 | if (current != null) { |
| 378 | current.clearCache(true); |
| 379 | } |
| 380 | } |
| 381 | } |
| 382 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 383 | public void clearCookies() { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 384 | CookieManager.getInstance().removeAllCookie(); |
| 385 | } |
| 386 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 387 | public void clearHistory() { |
| 388 | ContentResolver resolver = mContext.getContentResolver(); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 389 | Browser.clearHistory(resolver); |
| 390 | Browser.clearSearches(resolver); |
| 391 | } |
| 392 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 393 | public void clearFormData() { |
| 394 | WebViewDatabase.getInstance(mContext).clearFormData(); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 395 | if (mController!= null) { |
| 396 | WebView currentTopView = mController.getCurrentTopWebView(); |
Henrik Baard | 794dc72 | 2010-02-19 16:28:06 +0100 | [diff] [blame] | 397 | if (currentTopView != null) { |
| 398 | currentTopView.clearFormData(); |
| 399 | } |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 400 | } |
| 401 | } |
| 402 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 403 | public void clearPasswords() { |
| 404 | WebViewDatabase db = WebViewDatabase.getInstance(mContext); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 405 | db.clearUsernamePassword(); |
| 406 | db.clearHttpAuthUsernamePassword(); |
| 407 | } |
| 408 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 409 | public void clearDatabases() { |
Andrei Popescu | 824faeb | 2009-07-21 18:24:06 +0100 | [diff] [blame] | 410 | WebStorage.getInstance().deleteAllData(); |
Steve Block | f344d03 | 2009-07-30 10:50:45 +0100 | [diff] [blame] | 411 | } |
| 412 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 413 | public void clearLocationAccess() { |
Steve Block | f344d03 | 2009-07-30 10:50:45 +0100 | [diff] [blame] | 414 | GeolocationPermissions.getInstance().clearAll(); |
Nicolas Roard | 78a98e4 | 2009-05-11 13:34:17 +0100 | [diff] [blame] | 415 | } |
| 416 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 417 | public void resetDefaultPreferences() { |
| 418 | mPrefs.edit().clear().apply(); |
| 419 | syncManagedSettings(); |
Grace Kloba | f2c5c1b | 2009-05-26 10:48:31 -0700 | [diff] [blame] | 420 | } |
| 421 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 422 | public AutoFillProfile getAutoFillProfile() { |
| 423 | mAutofillHandler.waitForLoad(); |
| 424 | return mAutofillHandler.getAutoFillProfile(); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 425 | } |
| 426 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 427 | public void setAutoFillProfile(AutoFillProfile profile, Message msg) { |
| 428 | mAutofillHandler.waitForLoad(); |
| 429 | mAutofillHandler.setAutoFillProfile(profile, msg); |
Ben Murdoch | 273330a | 2011-07-08 18:37:22 +0100 | [diff] [blame] | 430 | // Auto-fill will reuse the same profile ID when making edits to the profile, |
| 431 | // so we need to force a settings sync (otherwise the SharedPreferences |
| 432 | // manager will optimise out the call to onSharedPreferenceChanged(), as |
| 433 | // it thinks nothing has changed). |
| 434 | syncManagedSettings(); |
Shimeng (Simon) Wang | f739271 | 2010-03-10 16:44:31 -0800 | [diff] [blame] | 435 | } |
| 436 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 437 | public void toggleDebugSettings() { |
| 438 | setDebugEnabled(!isDebugEnabled()); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 439 | } |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 440 | |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 441 | public boolean hasDesktopUseragent(WebView view) { |
| 442 | return view != null && mCustomUserAgents.get(view.getSettings()) != null; |
| 443 | } |
| 444 | |
| 445 | public void toggleDesktopUseragent(WebView view) { |
John Reck | b0a86db | 2011-05-24 14:05:58 -0700 | [diff] [blame] | 446 | if (view == null) { |
| 447 | return; |
| 448 | } |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 449 | WebSettings settings = view.getSettings(); |
| 450 | if (mCustomUserAgents.get(settings) != null) { |
| 451 | mCustomUserAgents.remove(settings); |
| 452 | settings.setUserAgentString(USER_AGENTS[getUserAgent()]); |
| 453 | } else { |
| 454 | mCustomUserAgents.put(settings, DESKTOP_USERAGENT); |
| 455 | settings.setUserAgentString(DESKTOP_USERAGENT); |
| 456 | } |
| 457 | } |
| 458 | |
John Reck | 7dc444b | 2011-06-16 17:44:29 -0700 | [diff] [blame] | 459 | public static int getAdjustedMinimumFontSize(int rawValue) { |
| 460 | rawValue++; // Preference starts at 0, min font at 1 |
| 461 | if (rawValue > 1) { |
| 462 | rawValue += (MIN_FONT_SIZE_OFFSET - 2); |
| 463 | } |
| 464 | return rawValue; |
| 465 | } |
| 466 | |
| 467 | public static int getAdjustedTextZoom(int rawValue) { |
| 468 | rawValue = (rawValue - TEXT_ZOOM_START_VAL) * TEXT_ZOOM_STEP; |
| 469 | return rawValue + 100; |
| 470 | } |
| 471 | |
| 472 | static int getRawTextZoom(int percent) { |
| 473 | return (percent - 100) / TEXT_ZOOM_STEP + TEXT_ZOOM_START_VAL; |
| 474 | } |
| 475 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 476 | // ----------------------------- |
| 477 | // getter/setters for accessibility_preferences.xml |
| 478 | // ----------------------------- |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 479 | |
John Reck | 7dc444b | 2011-06-16 17:44:29 -0700 | [diff] [blame] | 480 | @Deprecated |
| 481 | private TextSize getTextSize() { |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 482 | String textSize = mPrefs.getString(PREF_TEXT_SIZE, "NORMAL"); |
| 483 | return TextSize.valueOf(textSize); |
Ben Murdoch | 23da30e | 2010-10-26 15:18:44 +0100 | [diff] [blame] | 484 | } |
| 485 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 486 | public int getMinimumFontSize() { |
John Reck | 8fc22a1 | 2011-06-16 14:57:41 -0700 | [diff] [blame] | 487 | int minFont = mPrefs.getInt(PREF_MIN_FONT_SIZE, 0); |
John Reck | 7dc444b | 2011-06-16 17:44:29 -0700 | [diff] [blame] | 488 | return getAdjustedMinimumFontSize(minFont); |
Ben Murdoch | 0cb8189 | 2010-10-08 12:41:33 +0100 | [diff] [blame] | 489 | } |
| 490 | |
John Reck | 92f25f8 | 2011-04-26 16:57:10 -0700 | [diff] [blame] | 491 | public boolean forceEnableUserScalable() { |
| 492 | return mPrefs.getBoolean(PREF_FORCE_USERSCALABLE, false); |
| 493 | } |
| 494 | |
John Reck | 7dc444b | 2011-06-16 17:44:29 -0700 | [diff] [blame] | 495 | public int getTextZoom() { |
| 496 | int textZoom = mPrefs.getInt(PREF_TEXT_ZOOM, 10); |
| 497 | return getAdjustedTextZoom(textZoom); |
| 498 | } |
| 499 | |
| 500 | public void setTextZoom(int percent) { |
| 501 | mPrefs.edit().putInt(PREF_TEXT_ZOOM, getRawTextZoom(percent)).apply(); |
| 502 | } |
| 503 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 504 | // ----------------------------- |
| 505 | // getter/setters for advanced_preferences.xml |
| 506 | // ----------------------------- |
Ben Murdoch | 23da30e | 2010-10-26 15:18:44 +0100 | [diff] [blame] | 507 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 508 | public String getSearchEngineName() { |
| 509 | return mPrefs.getString(PREF_SEARCH_ENGINE, SearchEngine.GOOGLE); |
Ben Murdoch | 23da30e | 2010-10-26 15:18:44 +0100 | [diff] [blame] | 510 | } |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 511 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 512 | public boolean openInBackground() { |
| 513 | return mPrefs.getBoolean(PREF_OPEN_IN_BACKGROUND, false); |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 514 | } |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 515 | |
| 516 | public boolean enableJavascript() { |
| 517 | return mPrefs.getBoolean(PREF_ENABLE_JAVASCRIPT, true); |
| 518 | } |
| 519 | |
| 520 | // TODO: Cache |
| 521 | public PluginState getPluginState() { |
| 522 | String state = mPrefs.getString(PREF_PLUGIN_STATE, "ON"); |
| 523 | return PluginState.valueOf(state); |
| 524 | } |
| 525 | |
| 526 | // TODO: Cache |
| 527 | public ZoomDensity getDefaultZoom() { |
| 528 | String zoom = mPrefs.getString(PREF_DEFAULT_ZOOM, "MEDIUM"); |
| 529 | return ZoomDensity.valueOf(zoom); |
| 530 | } |
| 531 | |
| 532 | public boolean loadPageInOverviewMode() { |
| 533 | return mPrefs.getBoolean(PREF_LOAD_PAGE, true); |
| 534 | } |
| 535 | |
| 536 | public boolean autofitPages() { |
| 537 | return mPrefs.getBoolean(PREF_AUTOFIT_PAGES, true); |
| 538 | } |
| 539 | |
| 540 | public boolean blockPopupWindows() { |
| 541 | return mPrefs.getBoolean(PREF_BLOCK_POPUP_WINDOWS, true); |
| 542 | } |
| 543 | |
| 544 | public boolean loadImages() { |
| 545 | return mPrefs.getBoolean(PREF_LOAD_IMAGES, true); |
| 546 | } |
| 547 | |
| 548 | public String getDefaultTextEncoding() { |
| 549 | return mPrefs.getString(PREF_DEFAULT_TEXT_ENCODING, null); |
| 550 | } |
| 551 | |
| 552 | // ----------------------------- |
| 553 | // getter/setters for general_preferences.xml |
| 554 | // ----------------------------- |
| 555 | |
| 556 | public String getHomePage() { |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 557 | return mPrefs.getString(PREF_HOMEPAGE, getFactoryResetHomeUrl(mContext)); |
| 558 | } |
| 559 | |
| 560 | public void setHomePage(String value) { |
| 561 | mPrefs.edit().putString(PREF_HOMEPAGE, value).apply(); |
| 562 | } |
| 563 | |
| 564 | public boolean isAutofillEnabled() { |
| 565 | return mPrefs.getBoolean(PREF_AUTOFILL_ENABLED, true); |
| 566 | } |
| 567 | |
| 568 | public void setAutofillEnabled(boolean value) { |
| 569 | mPrefs.edit().putBoolean(PREF_AUTOFILL_ENABLED, value).apply(); |
| 570 | } |
| 571 | |
| 572 | // ----------------------------- |
| 573 | // getter/setters for debug_preferences.xml |
| 574 | // ----------------------------- |
| 575 | |
| 576 | public boolean isHardwareAccelerated() { |
John Reck | f48314f | 2011-04-27 17:52:17 -0700 | [diff] [blame] | 577 | if (!isDebugEnabled()) { |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 578 | return true; |
| 579 | } |
| 580 | return mPrefs.getBoolean(PREF_ENABLE_HARDWARE_ACCEL, true); |
| 581 | } |
| 582 | |
| 583 | public int getUserAgent() { |
John Reck | f48314f | 2011-04-27 17:52:17 -0700 | [diff] [blame] | 584 | if (!isDebugEnabled()) { |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 585 | return 0; |
| 586 | } |
| 587 | return Integer.parseInt(mPrefs.getString(PREF_USER_AGENT, "0")); |
| 588 | } |
| 589 | |
| 590 | // ----------------------------- |
| 591 | // getter/setters for hidden_debug_preferences.xml |
| 592 | // ----------------------------- |
| 593 | |
| 594 | public boolean enableVisualIndicator() { |
| 595 | if (!isDebugEnabled()) { |
| 596 | return false; |
| 597 | } |
| 598 | return mPrefs.getBoolean(PREF_ENABLE_VISUAL_INDICATOR, false); |
| 599 | } |
| 600 | |
| 601 | public boolean enableJavascriptConsole() { |
| 602 | if (!isDebugEnabled()) { |
| 603 | return false; |
| 604 | } |
| 605 | return mPrefs.getBoolean(PREF_JAVASCRIPT_CONSOLE, true); |
| 606 | } |
| 607 | |
| 608 | public boolean isSmallScreen() { |
| 609 | if (!isDebugEnabled()) { |
| 610 | return false; |
| 611 | } |
| 612 | return mPrefs.getBoolean(PREF_SMALL_SCREEN, false); |
| 613 | } |
| 614 | |
| 615 | public boolean isWideViewport() { |
| 616 | if (!isDebugEnabled()) { |
| 617 | return true; |
| 618 | } |
| 619 | return mPrefs.getBoolean(PREF_WIDE_VIEWPORT, true); |
| 620 | } |
| 621 | |
| 622 | public boolean isNormalLayout() { |
| 623 | if (!isDebugEnabled()) { |
| 624 | return false; |
| 625 | } |
| 626 | return mPrefs.getBoolean(PREF_NORMAL_LAYOUT, false); |
| 627 | } |
| 628 | |
| 629 | public boolean isTracing() { |
| 630 | if (!isDebugEnabled()) { |
| 631 | return false; |
| 632 | } |
| 633 | return mPrefs.getBoolean(PREF_ENABLE_TRACING, false); |
| 634 | } |
| 635 | |
| 636 | public boolean enableLightTouch() { |
| 637 | if (!isDebugEnabled()) { |
| 638 | return false; |
| 639 | } |
| 640 | return mPrefs.getBoolean(PREF_ENABLE_LIGHT_TOUCH, false); |
| 641 | } |
| 642 | |
| 643 | public boolean enableNavDump() { |
| 644 | if (!isDebugEnabled()) { |
| 645 | return false; |
| 646 | } |
| 647 | return mPrefs.getBoolean(PREF_ENABLE_NAV_DUMP, false); |
| 648 | } |
| 649 | |
| 650 | public String getJsEngineFlags() { |
| 651 | if (!isDebugEnabled()) { |
| 652 | return ""; |
| 653 | } |
| 654 | return mPrefs.getString(PREF_JS_ENGINE_FLAGS, ""); |
| 655 | } |
| 656 | |
| 657 | // ----------------------------- |
| 658 | // getter/setters for lab_preferences.xml |
| 659 | // ----------------------------- |
| 660 | |
| 661 | public boolean useQuickControls() { |
| 662 | return mPrefs.getBoolean(PREF_ENABLE_QUICK_CONTROLS, false); |
| 663 | } |
| 664 | |
| 665 | public boolean useMostVisitedHomepage() { |
John Reck | 961d35d | 2011-06-23 09:45:54 -0700 | [diff] [blame] | 666 | return HomeProvider.MOST_VISITED.equals(getHomePage()); |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 667 | } |
| 668 | |
| 669 | public boolean useInstantSearch() { |
| 670 | return mPrefs.getBoolean(PREF_USE_INSTANT_SEARCH, false); |
| 671 | } |
| 672 | |
Michael Kolb | c38c604 | 2011-04-27 10:46:06 -0700 | [diff] [blame] | 673 | public boolean useFullscreen() { |
| 674 | return mPrefs.getBoolean(PREF_FULLSCREEN, false); |
| 675 | } |
| 676 | |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 677 | // ----------------------------- |
| 678 | // getter/setters for privacy_security_preferences.xml |
| 679 | // ----------------------------- |
| 680 | |
| 681 | public boolean showSecurityWarnings() { |
| 682 | return mPrefs.getBoolean(PREF_SHOW_SECURITY_WARNINGS, true); |
| 683 | } |
| 684 | |
| 685 | public boolean acceptCookies() { |
| 686 | return mPrefs.getBoolean(PREF_ACCEPT_COOKIES, true); |
| 687 | } |
| 688 | |
| 689 | public boolean saveFormdata() { |
| 690 | return mPrefs.getBoolean(PREF_SAVE_FORMDATA, true); |
| 691 | } |
| 692 | |
| 693 | public boolean enableGeolocation() { |
| 694 | return mPrefs.getBoolean(PREF_ENABLE_GEOLOCATION, true); |
| 695 | } |
| 696 | |
| 697 | public boolean rememberPasswords() { |
| 698 | return mPrefs.getBoolean(PREF_REMEMBER_PASSWORDS, true); |
| 699 | } |
| 700 | |
Michael Kolb | 1461244 | 2011-06-24 13:06:29 -0700 | [diff] [blame] | 701 | // ----------------------------- |
| 702 | // getter/setters for bandwidth_preferences.xml |
| 703 | // ----------------------------- |
| 704 | |
| 705 | public boolean isPreloadEnabled() { |
| 706 | return mPrefs.getBoolean(PREF_DATA_PRELOAD, false); |
| 707 | } |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 708 | } |