• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 package org.chromium.android_webview;
6 
7 import android.content.Context;
8 import android.content.SharedPreferences;
9 
10 import org.chromium.content.browser.ContentViewStatics;
11 import org.chromium.net.DefaultAndroidKeyStore;
12 
13 /**
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.
19  */
20 public class AwBrowserContext {
21 
22     private static final String HTTP_AUTH_DATABASE_FILE = "http_auth.db";
23 
24     private SharedPreferences mSharedPreferences;
25 
26     private AwGeolocationPermissions mGeolocationPermissions;
27     private AwCookieManager mCookieManager;
28     private AwFormDatabase mFormDatabase;
29     private HttpAuthDatabase mHttpAuthDatabase;
30     private DefaultAndroidKeyStore mLocalKeyStore;
31 
AwBrowserContext(SharedPreferences sharedPreferences)32     public AwBrowserContext(SharedPreferences sharedPreferences) {
33         mSharedPreferences = sharedPreferences;
34     }
35 
getGeolocationPermissions()36     public AwGeolocationPermissions getGeolocationPermissions() {
37         if (mGeolocationPermissions == null) {
38             mGeolocationPermissions = new AwGeolocationPermissions(mSharedPreferences);
39         }
40         return mGeolocationPermissions;
41     }
42 
getCookieManager()43     public AwCookieManager getCookieManager() {
44         if (mCookieManager == null) {
45             mCookieManager = new AwCookieManager();
46         }
47         return mCookieManager;
48     }
49 
getFormDatabase()50     public AwFormDatabase getFormDatabase() {
51         if (mFormDatabase == null) {
52             mFormDatabase = new AwFormDatabase();
53         }
54         return mFormDatabase;
55     }
56 
getHttpAuthDatabase(Context context)57     public HttpAuthDatabase getHttpAuthDatabase(Context context) {
58         if (mHttpAuthDatabase == null) {
59             mHttpAuthDatabase = new HttpAuthDatabase(context, HTTP_AUTH_DATABASE_FILE);
60         }
61         return mHttpAuthDatabase;
62     }
63 
getKeyStore()64     public DefaultAndroidKeyStore getKeyStore() {
65         if (mLocalKeyStore == null) {
66             mLocalKeyStore = new DefaultAndroidKeyStore();
67         }
68         return mLocalKeyStore;
69     }
70 
71     /**
72      * @see android.webkit.WebView#pauseTimers()
73      */
pauseTimers()74     public void pauseTimers() {
75         ContentViewStatics.setWebKitSharedTimersSuspended(true);
76     }
77 
78     /**
79      * @see android.webkit.WebView#resumeTimers()
80      */
resumeTimers()81     public void resumeTimers() {
82         ContentViewStatics.setWebKitSharedTimersSuspended(false);
83     }
84 }
85