| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 | 8 |
| 9 import org.chromium.android_webview.policy.AwPolicyProvider; |
| 9 import org.chromium.base.CommandLine; | 10 import org.chromium.base.CommandLine; |
| 10 import org.chromium.base.PathUtils; | 11 import org.chromium.base.PathUtils; |
| 11 import org.chromium.base.ThreadUtils; | 12 import org.chromium.base.ThreadUtils; |
| 12 import org.chromium.base.library_loader.LibraryLoader; | 13 import org.chromium.base.library_loader.LibraryLoader; |
| 13 import org.chromium.base.library_loader.LibraryProcessType; | 14 import org.chromium.base.library_loader.LibraryProcessType; |
| 14 import org.chromium.base.library_loader.ProcessInitException; | 15 import org.chromium.base.library_loader.ProcessInitException; |
| 15 import org.chromium.content.browser.BrowserStartupController; | 16 import org.chromium.content.browser.BrowserStartupController; |
| 17 import org.chromium.policy.CombinedPolicyProvider; |
| 16 | 18 |
| 17 /** | 19 /** |
| 18 * Wrapper for the steps needed to initialize the java and native sides of webvi
ew chromium. | 20 * Wrapper for the steps needed to initialize the java and native sides of webvi
ew chromium. |
| 19 */ | 21 */ |
| 20 public abstract class AwBrowserProcess { | 22 public abstract class AwBrowserProcess { |
| 21 public static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "webview"; | 23 public static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "webview"; |
| 22 | 24 |
| 23 private static final String TAG = "AwBrowserProcess"; | 25 private static final String TAG = "AwBrowserProcess"; |
| 24 | 26 |
| 25 /** | 27 /** |
| (...skipping 21 matching lines...) Expand all Loading... |
| 47 * Note: it is up to the caller to ensure this is only called once. | 49 * Note: it is up to the caller to ensure this is only called once. |
| 48 * @param context The Android application context | 50 * @param context The Android application context |
| 49 */ | 51 */ |
| 50 public static void start(final Context context) { | 52 public static void start(final Context context) { |
| 51 // We must post to the UI thread to cover the case that the user | 53 // We must post to the UI thread to cover the case that the user |
| 52 // has invoked Chromium startup by using the (thread-safe) | 54 // has invoked Chromium startup by using the (thread-safe) |
| 53 // CookieManager rather than creating a WebView. | 55 // CookieManager rather than creating a WebView. |
| 54 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 56 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 55 @Override | 57 @Override |
| 56 public void run() { | 58 public void run() { |
| 59 // The policies are used by browser startup, so we need to regis
ter the policy |
| 60 // providers before starting the browser process. This only regi
sters java objects |
| 61 // and doesn't need the native library. |
| 62 CombinedPolicyProvider.get().registerProvider(new AwPolicyProvid
er(context)); |
| 63 |
| 57 try { | 64 try { |
| 58 BrowserStartupController.get(context, LibraryProcessType.PRO
CESS_WEBVIEW) | 65 BrowserStartupController.get(context, LibraryProcessType.PRO
CESS_WEBVIEW) |
| 59 .startBrowserProcessesSync(!CommandLine.getInstance(
).hasSwitch( | 66 .startBrowserProcessesSync(!CommandLine.getInstance(
).hasSwitch( |
| 60 AwSwitches.WEBVIEW_SANDBOXED_RENDERE
R)); | 67 AwSwitches.WEBVIEW_SANDBOXED_RENDERE
R)); |
| 61 } catch (ProcessInitException e) { | 68 } catch (ProcessInitException e) { |
| 62 throw new RuntimeException("Cannot initialize WebView", e); | 69 throw new RuntimeException("Cannot initialize WebView", e); |
| 63 } | 70 } |
| 64 } | 71 } |
| 65 }); | 72 }); |
| 66 } | 73 } |
| 67 } | 74 } |
| OLD | NEW |