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.content.browser.AppWebMessagePortService; |
10 import org.chromium.content.browser.ContentViewStatics; | 11 import org.chromium.content.browser.ContentViewStatics; |
11 | 12 |
12 /** | 13 /** |
13 * Java side of the Browser Context: contains all the java side objects needed t
o host one | 14 * Java side of the Browser Context: contains all the java side objects needed t
o host one |
14 * browing session (i.e. profile). | 15 * browing session (i.e. profile). |
15 * | 16 * |
16 * Note that historically WebView was running in single process mode, and limita
tions on renderer | 17 * Note that historically WebView was running in single process mode, and limita
tions on renderer |
17 * process only being able to use a single browser context, currently there can
only be one | 18 * process only being able to use a single browser context, currently there can
only be one |
18 * AwBrowserContext instance, so at this point the class mostly exists for conce
ptual clarity. | 19 * AwBrowserContext instance, so at this point the class mostly exists for conce
ptual clarity. |
19 */ | 20 */ |
20 public class AwBrowserContext { | 21 public class AwBrowserContext { |
21 private final SharedPreferences mSharedPreferences; | 22 private final SharedPreferences mSharedPreferences; |
22 | 23 |
23 private AwGeolocationPermissions mGeolocationPermissions; | 24 private AwGeolocationPermissions mGeolocationPermissions; |
24 private AwFormDatabase mFormDatabase; | 25 private AwFormDatabase mFormDatabase; |
25 private AwMessagePortService mMessagePortService; | 26 private AppWebMessagePortService mMessagePortService; |
26 private AwMetricsServiceClient mMetricsServiceClient; | 27 private AwMetricsServiceClient mMetricsServiceClient; |
27 private AwServiceWorkerController mServiceWorkerController; | 28 private AwServiceWorkerController mServiceWorkerController; |
28 private Context mApplicationContext; | 29 private Context mApplicationContext; |
29 | 30 |
30 public AwBrowserContext(SharedPreferences sharedPreferences, Context applica
tionContext) { | 31 public AwBrowserContext(SharedPreferences sharedPreferences, Context applica
tionContext) { |
31 mSharedPreferences = sharedPreferences; | 32 mSharedPreferences = sharedPreferences; |
32 mMetricsServiceClient = new AwMetricsServiceClient(applicationContext); | 33 mMetricsServiceClient = new AwMetricsServiceClient(applicationContext); |
33 mApplicationContext = applicationContext; | 34 mApplicationContext = applicationContext; |
34 } | 35 } |
35 | 36 |
36 public AwGeolocationPermissions getGeolocationPermissions() { | 37 public AwGeolocationPermissions getGeolocationPermissions() { |
37 if (mGeolocationPermissions == null) { | 38 if (mGeolocationPermissions == null) { |
38 mGeolocationPermissions = new AwGeolocationPermissions(mSharedPrefer
ences); | 39 mGeolocationPermissions = new AwGeolocationPermissions(mSharedPrefer
ences); |
39 } | 40 } |
40 return mGeolocationPermissions; | 41 return mGeolocationPermissions; |
41 } | 42 } |
42 | 43 |
43 public AwFormDatabase getFormDatabase() { | 44 public AwFormDatabase getFormDatabase() { |
44 if (mFormDatabase == null) { | 45 if (mFormDatabase == null) { |
45 mFormDatabase = new AwFormDatabase(); | 46 mFormDatabase = new AwFormDatabase(); |
46 } | 47 } |
47 return mFormDatabase; | 48 return mFormDatabase; |
48 } | 49 } |
49 | 50 |
50 public AwMessagePortService getMessagePortService() { | 51 public AppWebMessagePortService getMessagePortService() { |
51 if (mMessagePortService == null) { | 52 if (mMessagePortService == null) { |
52 mMessagePortService = new AwMessagePortService(); | 53 mMessagePortService = new AppWebMessagePortService(); |
53 } | 54 } |
54 return mMessagePortService; | 55 return mMessagePortService; |
55 } | 56 } |
56 | 57 |
57 public AwMetricsServiceClient getMetricsServiceClient() { | 58 public AwMetricsServiceClient getMetricsServiceClient() { |
58 return mMetricsServiceClient; | 59 return mMetricsServiceClient; |
59 } | 60 } |
60 | 61 |
61 public AwServiceWorkerController getServiceWorkerController() { | 62 public AwServiceWorkerController getServiceWorkerController() { |
62 if (mServiceWorkerController == null) { | 63 if (mServiceWorkerController == null) { |
63 mServiceWorkerController = new AwServiceWorkerController(mApplicatio
nContext, this); | 64 mServiceWorkerController = new AwServiceWorkerController(mApplicatio
nContext, this); |
64 } | 65 } |
65 return mServiceWorkerController; | 66 return mServiceWorkerController; |
66 } | 67 } |
67 | 68 |
68 /** | 69 /** |
69 * @see android.webkit.WebView#pauseTimers() | 70 * @see android.webkit.WebView#pauseTimers() |
70 */ | 71 */ |
71 public void pauseTimers() { | 72 public void pauseTimers() { |
72 ContentViewStatics.setWebKitSharedTimersSuspended(true); | 73 ContentViewStatics.setWebKitSharedTimersSuspended(true); |
73 } | 74 } |
74 | 75 |
75 /** | 76 /** |
76 * @see android.webkit.WebView#resumeTimers() | 77 * @see android.webkit.WebView#resumeTimers() |
77 */ | 78 */ |
78 public void resumeTimers() { | 79 public void resumeTimers() { |
79 ContentViewStatics.setWebKitSharedTimersSuspended(false); | 80 ContentViewStatics.setWebKitSharedTimersSuspended(false); |
80 } | 81 } |
81 } | 82 } |
OLD | NEW |