| OLD | NEW |
| 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/webview_jni_onload.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/android_webview_jni_registrar.h" | 7 #include "android_webview/browser/android_webview_jni_registrar.h" |
| 8 #include "android_webview/common/aw_version_info_values.h" | 8 #include "android_webview/common/aw_version_info_values.h" |
| 9 #include "android_webview/lib/main/aw_main_delegate.h" | 9 #include "android_webview/lib/aw_main_delegate.h" |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| 11 #include "base/android/jni_registrar.h" | 11 #include "base/android/jni_registrar.h" |
| 12 #include "base/android/library_loader/library_loader_hooks.h" | 12 #include "base/android/library_loader/library_loader_hooks.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "components/web_contents_delegate_android/component_jni_registrar.h" | 14 #include "components/web_contents_delegate_android/component_jni_registrar.h" |
| 15 #include "content/public/app/content_jni_onload.h" | 15 #include "content/public/app/content_jni_onload.h" |
| 16 #include "content/public/app/content_main.h" | 16 #include "content/public/app/content_main.h" |
| 17 #include "url/url_util.h" | 17 #include "url/url_util.h" |
| 18 | 18 |
| 19 namespace android_webview { | 19 namespace android_webview { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 static base::android::RegistrationMethod | 23 static base::android::RegistrationMethod kWebViewDependencyRegisteredMethods[] = |
| 24 kWebViewDependencyRegisteredMethods[] = { | 24 { |
| 25 { "WebContentsDelegateAndroid", | 25 {"WebContentsDelegateAndroid", |
| 26 web_contents_delegate_android::RegisterWebContentsDelegateAndroidJni }, | 26 web_contents_delegate_android::RegisterWebContentsDelegateAndroidJni}, |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 } // namespace | 29 } // namespace |
| 30 | 30 |
| 31 bool OnJNIOnLoadRegisterJNI(JNIEnv* env) { | 31 bool OnJNIOnLoadRegisterJNI(JNIEnv* env) { |
| 32 if (!content::android::OnJNIOnLoadRegisterJNI(env)) | 32 if (!content::android::OnJNIOnLoadRegisterJNI(env)) |
| 33 return false; | 33 return false; |
| 34 | 34 |
| 35 // Register JNI for components we depend on. | 35 // Register JNI for components we depend on. |
| 36 if (!RegisterNativeMethods( | 36 if (!RegisterNativeMethods(env, kWebViewDependencyRegisteredMethods, |
| 37 env, | 37 arraysize(kWebViewDependencyRegisteredMethods)) || |
| 38 kWebViewDependencyRegisteredMethods, | |
| 39 arraysize(kWebViewDependencyRegisteredMethods)) || | |
| 40 !android_webview::RegisterJni(env)) { | 38 !android_webview::RegisterJni(env)) { |
| 41 return false; | 39 return false; |
| 42 } | 40 } |
| 43 return true; | 41 return true; |
| 44 } | 42 } |
| 45 | 43 |
| 46 bool OnJNIOnLoadInit() { | 44 bool OnJNIOnLoadInit() { |
| 47 if (!content::android::OnJNIOnLoadInit()) | 45 if (!content::android::OnJNIOnLoadInit()) |
| 48 return false; | 46 return false; |
| 49 | 47 |
| 50 base::android::SetVersionNumber(PRODUCT_VERSION); | 48 base::android::SetVersionNumber(PRODUCT_VERSION); |
| 51 content::SetContentMainDelegate(new android_webview::AwMainDelegate()); | 49 content::SetContentMainDelegate(new android_webview::AwMainDelegate()); |
| 52 | 50 |
| 53 // Initialize url lib here while we are still single-threaded, in case we use | 51 // Initialize url lib here while we are still single-threaded, in case we use |
| 54 // CookieManager before initializing Chromium (which would normally have done | 52 // CookieManager before initializing Chromium (which would normally have done |
| 55 // this). It's safe to call this multiple times. | 53 // this). It's safe to call this multiple times. |
| 56 url::Initialize(); | 54 url::Initialize(); |
| 57 return true; | 55 return true; |
| 58 } | 56 } |
| 59 | 57 |
| 60 } // android_webview | 58 } // android_webview |
| OLD | NEW |