1 // Copyright 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;
11 import org.chromium.net.DefaultAndroidKeyStore;
14 * Java side of the Browser Context: contains all the java side objects needed to host one
15 * browing session (i.e. profile).
16 * Note that due to running in single process mode, and limitations on renderer process only
17 * being able to use a single browser context, currently there can only be one AwBrowserContext
18 * instance, so at this point the class mostly exists for conceptual clarity.
20 public class AwBrowserContext {
22 private static final String HTTP_AUTH_DATABASE_FILE = "http_auth.db";
24 private SharedPreferences mSharedPreferences;
26 private AwGeolocationPermissions mGeolocationPermissions;
27 private AwCookieManager mCookieManager;
28 private AwFormDatabase mFormDatabase;
29 private HttpAuthDatabase mHttpAuthDatabase;
30 private DefaultAndroidKeyStore mLocalKeyStore;
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;
64 public DefaultAndroidKeyStore getKeyStore() {
65 if (mLocalKeyStore == null) {
66 mLocalKeyStore = new DefaultAndroidKeyStore();
68 return mLocalKeyStore;
72 * @see android.webkit.WebView#pauseTimers()
74 public void pauseTimers() {
75 ContentViewStatics.setWebKitSharedTimersSuspended(true);
79 * @see android.webkit.WebView#resumeTimers()
81 public void resumeTimers() {
82 ContentViewStatics.setWebKitSharedTimersSuspended(false);