OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 import android.content.SharedPreferences; | 8 import android.content.SharedPreferences; |
9 | 9 |
10 import org.chromium.base.PathUtils; | 10 import org.chromium.base.PathUtils; |
11 import org.chromium.base.ThreadUtils; | 11 import org.chromium.base.ThreadUtils; |
12 import org.chromium.content.app.LibraryLoader; | 12 import org.chromium.content.app.LibraryLoader; |
13 import org.chromium.content.browser.AndroidBrowserProcess; | 13 import org.chromium.content.browser.AndroidBrowserProcess; |
14 import org.chromium.content.common.ProcessInitException; | 14 import org.chromium.content.common.ProcessInitException; |
15 | 15 |
16 /** | 16 /** |
17 * Wrapper for the steps needed to initialize the java and native sides of webvi
ew chromium. | 17 * Wrapper for the steps needed to initialize the java and native sides of webvi
ew chromium. |
18 */ | 18 */ |
19 public abstract class AwBrowserProcess { | 19 public abstract class AwBrowserProcess { |
20 /** | |
21 * The name of the library to load. | |
22 */ | |
23 private static final String NATIVE_LIBRARY = "webviewchromium"; | |
24 | |
25 private static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "webview"; | 20 private static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "webview"; |
26 | 21 |
27 /** | 22 /** |
28 * Loads the native library, and performs basic static construction of objec
ts needed | 23 * Loads the native library, and performs basic static construction of objec
ts needed |
29 * to run webview in this process. Does not create threads; safe to call fro
m zygote. | 24 * to run webview in this process. Does not create threads; safe to call fro
m zygote. |
30 * Note: it is up to the caller to ensure this is only called once. | 25 * Note: it is up to the caller to ensure this is only called once. |
31 */ | 26 */ |
32 public static void loadLibrary() { | 27 public static void loadLibrary() { |
33 PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX); | 28 PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX); |
34 LibraryLoader.setLibraryToLoad(NATIVE_LIBRARY); | |
35 try { | 29 try { |
36 LibraryLoader.loadNow(); | 30 LibraryLoader.loadNow(); |
37 } catch (ProcessInitException e) { | 31 } catch (ProcessInitException e) { |
38 throw new RuntimeException("Cannot load WebView", e); | 32 throw new RuntimeException("Cannot load WebView", e); |
39 } | 33 } |
40 } | 34 } |
41 | 35 |
42 /** | 36 /** |
43 * Starts the chromium browser process running within this process. Creates
threads | 37 * Starts the chromium browser process running within this process. Creates
threads |
44 * and performs other per-app resource allocations; must not be called from
zygote. | 38 * and performs other per-app resource allocations; must not be called from
zygote. |
(...skipping 11 matching lines...) Expand all Loading... |
56 LibraryLoader.ensureInitialized(); | 50 LibraryLoader.ensureInitialized(); |
57 AndroidBrowserProcess.init(context, | 51 AndroidBrowserProcess.init(context, |
58 AndroidBrowserProcess.MAX_RENDERERS_SINGLE_PROCESS); | 52 AndroidBrowserProcess.MAX_RENDERERS_SINGLE_PROCESS); |
59 } catch (ProcessInitException e) { | 53 } catch (ProcessInitException e) { |
60 throw new RuntimeException("Cannot initialize WebView", e); | 54 throw new RuntimeException("Cannot initialize WebView", e); |
61 } | 55 } |
62 } | 56 } |
63 }); | 57 }); |
64 } | 58 } |
65 } | 59 } |
OLD | NEW |