Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/android/base_jni_registrar.h" | 5 #include "base/android/base_jni_registrar.h" |
| 6 #include "base/android/jni_android.h" | 6 #include "base/android/jni_android.h" |
| 7 #include "base/android/library_loader/library_loader_hooks.h" | 7 #include "base/android/library_loader/library_loader_hooks.h" |
| 8 #include "chrome/app/android/chrome_android_initializer.h" | 8 #include "chrome/app/android/chrome_android_initializer.h" |
| 9 #include "chrome/app/android/chrome_main_delegate_android.h" | 9 #include "chrome/app/android/chrome_main_delegate_android.h" |
| 10 #include "components/devtools_bridge/android/session_dependency_factory_android. h" | 10 #include "components/devtools_bridge/android/session_dependency_factory_android. h" |
| 11 #include "components/devtools_bridge/client/web_client_controller.h" | |
| 11 #include "components/devtools_bridge/test/android/client/web_client_android.h" | 12 #include "components/devtools_bridge/test/android/client/web_client_android.h" |
| 13 #include "content/public/browser/web_ui_controller_factory.h" | |
| 14 #include "url/gurl.h" | |
| 12 | 15 |
| 13 using namespace devtools_bridge::android; | 16 using namespace devtools_bridge::android; |
| 14 | 17 |
| 15 namespace { | 18 namespace { |
| 16 | 19 |
| 20 class TestFactory : public content::WebUIControllerFactory { | |
| 21 public: | |
| 22 content::WebUI::TypeID GetWebUIType(content::BrowserContext* browser_context, | |
| 23 const GURL& url) const override { | |
| 24 return IsWebClientURL(url) ? const_cast<TestFactory*>(this) | |
| 25 : content::WebUI::kNoWebUI; | |
| 26 } | |
| 27 | |
| 28 bool UseWebUIForURL(content::BrowserContext* browser_context, | |
| 29 const GURL& url) const override { | |
| 30 return IsWebClientURL(url); | |
| 31 } | |
| 32 | |
| 33 bool UseWebUIBindingsForURL(content::BrowserContext* browser_context, | |
| 34 const GURL& url) const override { | |
| 35 return IsWebClientURL(url); | |
| 36 } | |
| 37 | |
| 38 content::WebUIController* CreateWebUIControllerForURL( | |
| 39 content::WebUI* web_ui, | |
| 40 const GURL& url) const override { | |
| 41 | |
| 42 return IsWebClientURL(url) | |
| 43 ? new devtools_bridge::WebClientController(web_ui) | |
| 44 : NULL; | |
| 45 } | |
| 46 | |
| 47 static bool IsWebClientURL(const GURL& url) { | |
| 48 return url.scheme() == "chrome-devtools" && url.host() == "bridge"; | |
| 49 } | |
| 50 }; | |
| 51 | |
| 52 static TestFactory s_factory; | |
|
mnaganov (inactive)
2014/11/24 11:47:20
We don't favor statics in Chromium (see https://gr
| |
| 53 | |
| 17 class Delegate : public ChromeMainDelegateAndroid { | 54 class Delegate : public ChromeMainDelegateAndroid { |
| 18 public: | 55 public: |
| 19 bool RegisterApplicationNativeMethods(JNIEnv* env) override { | 56 bool RegisterApplicationNativeMethods(JNIEnv* env) override { |
| 20 return ChromeMainDelegateAndroid::RegisterApplicationNativeMethods(env) && | 57 return ChromeMainDelegateAndroid::RegisterApplicationNativeMethods(env) && |
| 21 SessionDependencyFactoryAndroid::InitializeSSL() && | 58 SessionDependencyFactoryAndroid::InitializeSSL() && |
| 22 WebClientAndroid::RegisterNatives(env); | 59 WebClientAndroid::RegisterNatives(env); |
| 23 } | 60 } |
| 61 | |
| 62 bool BasicStartupComplete(int* exit_code) override { | |
| 63 content::WebUIControllerFactory::RegisterFactory(&s_factory); | |
| 64 | |
| 65 return ChromeMainDelegateAndroid::BasicStartupComplete(exit_code); | |
| 66 } | |
| 24 }; | 67 }; |
| 25 | 68 |
| 26 } // namespace | 69 } // namespace |
| 27 | 70 |
| 28 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { | 71 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { |
| 29 return RunChrome(vm, new Delegate()); | 72 return RunChrome(vm, new Delegate()); |
| 30 } | 73 } |
| OLD | NEW |