| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.android_webview; | 5 package org.chromium.android_webview; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.content.SharedPreferences; | 8 import android.content.SharedPreferences; |
| 9 | 9 |
| 10 import org.chromium.components.safe_browsing.SafeBrowsingApiBridge; | 10 import org.chromium.components.safe_browsing.SafeBrowsingApiBridge; |
| 11 import org.chromium.components.safe_browsing.SafeBrowsingApiHandler; | 11 import org.chromium.components.safe_browsing.SafeBrowsingApiHandler; |
| 12 import org.chromium.content.browser.AppWebMessagePortService; | |
| 13 import org.chromium.content.browser.ContentViewStatics; | 12 import org.chromium.content.browser.ContentViewStatics; |
| 14 | 13 |
| 15 /** | 14 /** |
| 16 * Java side of the Browser Context: contains all the java side objects needed t
o host one | 15 * Java side of the Browser Context: contains all the java side objects needed t
o host one |
| 17 * browing session (i.e. profile). | 16 * browing session (i.e. profile). |
| 18 * | 17 * |
| 19 * Note that historically WebView was running in single process mode, and limita
tions on renderer | 18 * Note that historically WebView was running in single process mode, and limita
tions on renderer |
| 20 * process only being able to use a single browser context, currently there can
only be one | 19 * process only being able to use a single browser context, currently there can
only be one |
| 21 * AwBrowserContext instance, so at this point the class mostly exists for conce
ptual clarity. | 20 * AwBrowserContext instance, so at this point the class mostly exists for conce
ptual clarity. |
| 22 */ | 21 */ |
| 23 public class AwBrowserContext { | 22 public class AwBrowserContext { |
| 24 private static final String TAG = "AwBrowserContext"; | 23 private static final String TAG = "AwBrowserContext"; |
| 25 private final SharedPreferences mSharedPreferences; | 24 private final SharedPreferences mSharedPreferences; |
| 26 | 25 |
| 27 private AwGeolocationPermissions mGeolocationPermissions; | 26 private AwGeolocationPermissions mGeolocationPermissions; |
| 28 private AwFormDatabase mFormDatabase; | 27 private AwFormDatabase mFormDatabase; |
| 29 private AppWebMessagePortService mMessagePortService; | |
| 30 private AwServiceWorkerController mServiceWorkerController; | 28 private AwServiceWorkerController mServiceWorkerController; |
| 31 private Context mApplicationContext; | 29 private Context mApplicationContext; |
| 32 | 30 |
| 33 public AwBrowserContext(SharedPreferences sharedPreferences, Context applica
tionContext) { | 31 public AwBrowserContext(SharedPreferences sharedPreferences, Context applica
tionContext) { |
| 34 mSharedPreferences = sharedPreferences; | 32 mSharedPreferences = sharedPreferences; |
| 35 mApplicationContext = applicationContext; | 33 mApplicationContext = applicationContext; |
| 36 | 34 |
| 37 if (AwContentsStatics.getSafeBrowsingEnabled()) { | 35 if (AwContentsStatics.getSafeBrowsingEnabled()) { |
| 38 initSafeBrowsingApiHandler(); | 36 initSafeBrowsingApiHandler(); |
| 39 } | 37 } |
| 40 } | 38 } |
| 41 | 39 |
| 42 public AwGeolocationPermissions getGeolocationPermissions() { | 40 public AwGeolocationPermissions getGeolocationPermissions() { |
| 43 if (mGeolocationPermissions == null) { | 41 if (mGeolocationPermissions == null) { |
| 44 mGeolocationPermissions = new AwGeolocationPermissions(mSharedPrefer
ences); | 42 mGeolocationPermissions = new AwGeolocationPermissions(mSharedPrefer
ences); |
| 45 } | 43 } |
| 46 return mGeolocationPermissions; | 44 return mGeolocationPermissions; |
| 47 } | 45 } |
| 48 | 46 |
| 49 public AwFormDatabase getFormDatabase() { | 47 public AwFormDatabase getFormDatabase() { |
| 50 if (mFormDatabase == null) { | 48 if (mFormDatabase == null) { |
| 51 mFormDatabase = new AwFormDatabase(); | 49 mFormDatabase = new AwFormDatabase(); |
| 52 } | 50 } |
| 53 return mFormDatabase; | 51 return mFormDatabase; |
| 54 } | 52 } |
| 55 | 53 |
| 56 public AppWebMessagePortService getMessagePortService() { | |
| 57 if (mMessagePortService == null) { | |
| 58 mMessagePortService = new AppWebMessagePortService(); | |
| 59 } | |
| 60 return mMessagePortService; | |
| 61 } | |
| 62 | |
| 63 public AwServiceWorkerController getServiceWorkerController() { | 54 public AwServiceWorkerController getServiceWorkerController() { |
| 64 if (mServiceWorkerController == null) { | 55 if (mServiceWorkerController == null) { |
| 65 mServiceWorkerController = new AwServiceWorkerController(mApplicatio
nContext, this); | 56 mServiceWorkerController = new AwServiceWorkerController(mApplicatio
nContext, this); |
| 66 } | 57 } |
| 67 return mServiceWorkerController; | 58 return mServiceWorkerController; |
| 68 } | 59 } |
| 69 | 60 |
| 70 /** | 61 /** |
| 71 * @see android.webkit.WebView#pauseTimers() | 62 * @see android.webkit.WebView#pauseTimers() |
| 72 */ | 63 */ |
| (...skipping 16 matching lines...) Expand all Loading... |
| 89 // Try to get a specialized service bridge. | 80 // Try to get a specialized service bridge. |
| 90 try { | 81 try { |
| 91 Class<? extends SafeBrowsingApiHandler> cls = | 82 Class<? extends SafeBrowsingApiHandler> cls = |
| 92 (Class<? extends SafeBrowsingApiHandler>) Class.forName(safe
BrowsingApiHandler); | 83 (Class<? extends SafeBrowsingApiHandler>) Class.forName(safe
BrowsingApiHandler); |
| 93 SafeBrowsingApiBridge.setSafeBrowsingHandlerType(cls); | 84 SafeBrowsingApiBridge.setSafeBrowsingHandlerType(cls); |
| 94 } catch (ClassNotFoundException e) { | 85 } catch (ClassNotFoundException e) { |
| 95 // This is not an error; it just means this device doesn't have spec
ialized services. | 86 // This is not an error; it just means this device doesn't have spec
ialized services. |
| 96 } | 87 } |
| 97 } | 88 } |
| 98 } | 89 } |
| OLD | NEW |