1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.chromium.android_webview;
7 import android.content.Context;
8 import android.content.SharedPreferences;
10 import org.chromium.content.browser.ContentViewStatics;
13 * Java side of the Browser Context: contains all the java side objects needed to host one
14 * browing session (i.e. profile).
15 * Note that due to running in single process mode, and limitations on renderer process only
16 * being able to use a single browser context, currently there can only be one AwBrowserContext
17 * instance, so at this point the class mostly exists for conceptual clarity.
19 * Obtain the default (singleton) instance with AwBrowserProcess.getDefaultBrowserContext().
21 public class AwBrowserContext {
23 private static final String HTTP_AUTH_DATABASE_FILE = "http_auth.db";
25 private SharedPreferences mSharedPreferences;
27 private AwGeolocationPermissions mGeolocationPermissions;
28 private AwCookieManager mCookieManager;
29 private AwFormDatabase mFormDatabase;
30 private HttpAuthDatabase mHttpAuthDatabase;
32 public AwBrowserContext(SharedPreferences sharedPreferences) {
33 mSharedPreferences = sharedPreferences;
36 public AwGeolocationPermissions getGeolocationPermissions() {
37 if (mGeolocationPermissions == null) {
38 mGeolocationPermissions = new AwGeolocationPermissions(mSharedPreferences);
40 return mGeolocationPermissions;
43 public AwCookieManager getCookieManager() {
44 if (mCookieManager == null) {
45 mCookieManager = new AwCookieManager();
47 return mCookieManager;
50 public AwFormDatabase getFormDatabase() {
51 if (mFormDatabase == null) {
52 mFormDatabase = new AwFormDatabase();
57 public HttpAuthDatabase getHttpAuthDatabase(Context context) {
58 if (mHttpAuthDatabase == null) {
59 mHttpAuthDatabase = new HttpAuthDatabase(context, HTTP_AUTH_DATABASE_FILE);
61 return mHttpAuthDatabase;
65 * @see android.webkit.WebView#pauseTimers()
67 public void pauseTimers() {
68 ContentViewStatics.setWebKitSharedTimersSuspended(true);
72 * @see android.webkit.WebView#resumeTimers()
74 public void resumeTimers() {
75 ContentViewStatics.setWebKitSharedTimersSuspended(false);