Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(646)

Side by Side Diff: android_webview/lib/main/webview_jni_onload.cc

Issue 975253002: refactoring Android Webview JNI_OnLoad interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove at exit manager change Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « android_webview/lib/main/webview_jni_onload.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "android_webview/lib/main/webview_jni_onload.h" 5 #include "android_webview/lib/main/webview_jni_onload.h"
6 6
7 #include "android_webview/lib/main/aw_main_delegate.h" 7 #include "android_webview/lib/main/aw_main_delegate.h"
8 #include "android_webview/native/android_webview_jni_registrar.h" 8 #include "android_webview/native/android_webview_jni_registrar.h"
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_registrar.h" 10 #include "base/android/jni_registrar.h"
11 #include "base/bind.h"
11 #include "components/navigation_interception/component_jni_registrar.h" 12 #include "components/navigation_interception/component_jni_registrar.h"
12 #include "components/web_contents_delegate_android/component_jni_registrar.h" 13 #include "components/web_contents_delegate_android/component_jni_registrar.h"
14 #include "content/public/app/content_jni_onload.h"
13 #include "content/public/app/content_main.h" 15 #include "content/public/app/content_main.h"
14 #include "url/url_util.h" 16 #include "url/url_util.h"
15 17
16 namespace android_webview { 18 namespace android_webview {
17 19
18 namespace { 20 namespace {
19 21
20 static base::android::RegistrationMethod 22 static base::android::RegistrationMethod
21 kWebViewDependencyRegisteredMethods[] = { 23 kWebViewDependencyRegisteredMethods[] = {
22 { "NavigationInterception", 24 { "NavigationInterception",
23 navigation_interception::RegisterNavigationInterceptionJni }, 25 navigation_interception::RegisterNavigationInterceptionJni },
24 { "WebContentsDelegateAndroid", 26 { "WebContentsDelegateAndroid",
25 web_contents_delegate_android::RegisterWebContentsDelegateAndroidJni }, 27 web_contents_delegate_android::RegisterWebContentsDelegateAndroidJni },
26 }; 28 };
27 29
28 } // namespace
29
30 bool RegisterJNI(JNIEnv* env) { 30 bool RegisterJNI(JNIEnv* env) {
31 // Register JNI for components we depend on. 31 // Register JNI for components we depend on.
32 if (!RegisterNativeMethods( 32 if (!RegisterNativeMethods(
33 env, 33 env,
34 kWebViewDependencyRegisteredMethods, 34 kWebViewDependencyRegisteredMethods,
35 arraysize(kWebViewDependencyRegisteredMethods)) || 35 arraysize(kWebViewDependencyRegisteredMethods)) ||
36 !android_webview::RegisterJni(env)) { 36 !android_webview::RegisterJni(env)) {
37 return false; 37 return false;
38 } 38 }
39 return true; 39 return true;
40 } 40 }
41 41
42 bool Init() { 42 bool Init() {
43 content::SetContentMainDelegate(new android_webview::AwMainDelegate()); 43 content::SetContentMainDelegate(new android_webview::AwMainDelegate());
44 44
45 // Initialize url lib here while we are still single-threaded, in case we use 45 // Initialize url lib here while we are still single-threaded, in case we use
46 // CookieManager before initializing Chromium (which would normally have done 46 // CookieManager before initializing Chromium (which would normally have done
47 // this). It's safe to call this multiple times. 47 // this). It's safe to call this multiple times.
48 url::Initialize(); 48 url::Initialize();
49 return true; 49 return true;
50 } 50 }
51 51
52 } // namespace
53
54 bool OnJNIOnLoadRegisterJNI(JavaVM* vm) {
55 std::vector<base::android::RegisterCallback> register_callbacks;
56 register_callbacks.push_back(base::Bind(&RegisterJNI));
57 return content::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks);
58 }
59
60 bool OnJNIOnLoadInit() {
61 std::vector<base::android::InitCallback> init_callbacks;
62 init_callbacks.push_back(base::Bind(&Init));
63 return content::android::OnJNIOnLoadInit(init_callbacks);
64 }
65
52 } // android_webview 66 } // android_webview
OLDNEW
« no previous file with comments | « android_webview/lib/main/webview_jni_onload.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698