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 import android.os.AsyncTask; | 8 import android.os.AsyncTask; |
9 import android.os.StrictMode; | 9 import android.os.StrictMode; |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 private static final String TAG = "AwBrowserProcess"; | 36 private static final String TAG = "AwBrowserProcess"; |
37 private static final String EXCLUSIVE_LOCK_FILE = "webview_data.lock"; | 37 private static final String EXCLUSIVE_LOCK_FILE = "webview_data.lock"; |
38 private static FileLock sExclusiveFileLock; | 38 private static FileLock sExclusiveFileLock; |
39 | 39 |
40 /** | 40 /** |
41 * Loads the native library, and performs basic static construction of objec
ts needed | 41 * Loads the native library, and performs basic static construction of objec
ts needed |
42 * to run webview in this process. Does not create threads; safe to call fro
m zygote. | 42 * to run webview in this process. Does not create threads; safe to call fro
m zygote. |
43 * Note: it is up to the caller to ensure this is only called once. | 43 * Note: it is up to the caller to ensure this is only called once. |
44 */ | 44 */ |
45 public static void loadLibrary() { | 45 public static void loadLibrary() { |
46 PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX); | 46 Context appContext = ContextUtils.getApplicationContext(); |
| 47 PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, a
ppContext); |
47 try { | 48 try { |
48 LibraryLoader libraryLoader = LibraryLoader.get(LibraryProcessType.P
ROCESS_WEBVIEW); | 49 LibraryLoader libraryLoader = LibraryLoader.get(LibraryProcessType.P
ROCESS_WEBVIEW); |
49 libraryLoader.loadNow(); | 50 libraryLoader.loadNow(); |
50 // Switch the command line implementation from Java to native. | 51 // Switch the command line implementation from Java to native. |
51 // It's okay for the WebView to do this before initialization becaus
e we have | 52 // It's okay for the WebView to do this before initialization becaus
e we have |
52 // setup the JNI bindings by this point. | 53 // setup the JNI bindings by this point. |
53 libraryLoader.switchCommandLineForWebView(); | 54 libraryLoader.switchCommandLineForWebView(); |
54 } catch (ProcessInitException e) { | 55 } catch (ProcessInitException e) { |
55 throw new RuntimeException("Cannot load WebView", e); | 56 throw new RuntimeException("Cannot load WebView", e); |
56 } | 57 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 125 } |
125 if (!success) { | 126 if (!success) { |
126 Log.w(TAG, "The app may have another WebView opened in a separat
e process. " | 127 Log.w(TAG, "The app may have another WebView opened in a separat
e process. " |
127 + "This is not recommended and may stop working in futur
e versions."); | 128 + "This is not recommended and may stop working in futur
e versions."); |
128 } | 129 } |
129 } finally { | 130 } finally { |
130 StrictMode.setThreadPolicy(oldPolicy); | 131 StrictMode.setThreadPolicy(oldPolicy); |
131 } | 132 } |
132 } | 133 } |
133 } | 134 } |
OLD | NEW |