| 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 #include "android_webview/browser/aw_browser_main_parts.h" | 5 #include "android_webview/browser/aw_browser_main_parts.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/aw_browser_context.h" | 7 #include "android_webview/browser/aw_browser_context.h" |
| 8 #include "android_webview/browser/aw_dev_tools_discovery_provider.h" | 8 #include "android_webview/browser/aw_dev_tools_discovery_provider.h" |
| 9 #include "android_webview/browser/aw_result_codes.h" | 9 #include "android_webview/browser/aw_result_codes.h" |
| 10 #include "android_webview/browser/deferred_gpu_command_service.h" | 10 #include "android_webview/browser/deferred_gpu_command_service.h" |
| 11 #include "android_webview/browser/net/aw_network_change_notifier_factory.h" | 11 #include "android_webview/browser/net/aw_network_change_notifier_factory.h" |
| 12 #include "android_webview/common/aw_resource.h" | 12 #include "android_webview/common/aw_resource.h" |
| 13 #include "android_webview/common/aw_switches.h" | 13 #include "android_webview/common/aw_switches.h" |
| 14 #include "base/android/apk_assets.h" | 14 #include "base/android/apk_assets.h" |
| 15 #include "base/android/build_info.h" | 15 #include "base/android/build_info.h" |
| 16 #include "base/android/locale_utils.h" | 16 #include "base/android/locale_utils.h" |
| 17 #include "base/android/memory_pressure_listener_android.h" | 17 #include "base/android/memory_pressure_listener_android.h" |
| 18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
| 19 #include "base/files/file_path.h" | 19 #include "base/files/file_path.h" |
| 20 #include "base/i18n/rtl.h" | 20 #include "base/i18n/rtl.h" |
| 21 #include "base/path_service.h" | 21 #include "base/path_service.h" |
| 22 #include "components/crash/content/browser/crash_micro_dump_manager_android.h" | 22 #include "components/crash/content/browser/crash_micro_dump_manager_android.h" |
| 23 #include "content/public/browser/access_token_store.h" |
| 23 #include "content/public/browser/android/synchronous_compositor.h" | 24 #include "content/public/browser/android/synchronous_compositor.h" |
| 25 #include "content/public/browser/geolocation_delegate.h" |
| 26 #include "content/public/browser/geolocation_provider.h" |
| 24 #include "content/public/browser/render_frame_host.h" | 27 #include "content/public/browser/render_frame_host.h" |
| 25 #include "content/public/browser/render_process_host.h" | 28 #include "content/public/browser/render_process_host.h" |
| 26 #include "content/public/common/content_client.h" | 29 #include "content/public/common/content_client.h" |
| 27 #include "content/public/common/content_switches.h" | 30 #include "content/public/common/content_switches.h" |
| 28 #include "content/public/common/result_codes.h" | 31 #include "content/public/common/result_codes.h" |
| 29 #include "device/geolocation/access_token_store.h" | |
| 30 #include "device/geolocation/geolocation_delegate.h" | |
| 31 #include "device/geolocation/geolocation_provider.h" | |
| 32 #include "net/android/network_change_notifier_factory_android.h" | 32 #include "net/android/network_change_notifier_factory_android.h" |
| 33 #include "net/base/network_change_notifier.h" | 33 #include "net/base/network_change_notifier.h" |
| 34 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
| 35 #include "ui/base/layout.h" | 35 #include "ui/base/layout.h" |
| 36 #include "ui/base/resource/resource_bundle.h" | 36 #include "ui/base/resource/resource_bundle.h" |
| 37 #include "ui/base/resource/resource_bundle_android.h" | 37 #include "ui/base/resource/resource_bundle_android.h" |
| 38 #include "ui/base/ui_base_paths.h" | 38 #include "ui/base/ui_base_paths.h" |
| 39 #include "ui/gl/gl_surface.h" | 39 #include "ui/gl/gl_surface.h" |
| 40 | 40 |
| 41 namespace android_webview { | 41 namespace android_webview { |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 class AwAccessTokenStore : public device::AccessTokenStore { | 44 class AwAccessTokenStore : public content::AccessTokenStore { |
| 45 public: | 45 public: |
| 46 AwAccessTokenStore() { } | 46 AwAccessTokenStore() { } |
| 47 | 47 |
| 48 // device::AccessTokenStore implementation | 48 // content::AccessTokenStore implementation |
| 49 void LoadAccessTokens(const LoadAccessTokensCallback& request) override { | 49 void LoadAccessTokens(const LoadAccessTokensCallback& request) override { |
| 50 AccessTokenStore::AccessTokenMap access_token_map; | 50 AccessTokenStore::AccessTokenMap access_token_map; |
| 51 // AccessTokenMap and net::URLRequestContextGetter not used on Android, | 51 // AccessTokenMap and net::URLRequestContextGetter not used on Android, |
| 52 // but Run needs to be called to finish the geolocation setup. | 52 // but Run needs to be called to finish the geolocation setup. |
| 53 request.Run(access_token_map, NULL); | 53 request.Run(access_token_map, NULL); |
| 54 } | 54 } |
| 55 void SaveAccessToken(const GURL& server_url, | 55 void SaveAccessToken(const GURL& server_url, |
| 56 const base::string16& access_token) override {} | 56 const base::string16& access_token) override {} |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 ~AwAccessTokenStore() override {} | 59 ~AwAccessTokenStore() override {} |
| 60 | 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore); | 61 DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore); |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 // A provider of Geolocation services to override AccessTokenStore. | 64 // A provider of Geolocation services to override AccessTokenStore. |
| 65 class AwGeolocationDelegate : public device::GeolocationDelegate { | 65 class AwGeolocationDelegate : public content::GeolocationDelegate { |
| 66 public: | 66 public: |
| 67 AwGeolocationDelegate() = default; | 67 AwGeolocationDelegate() = default; |
| 68 | 68 |
| 69 scoped_refptr<device::AccessTokenStore> CreateAccessTokenStore() final { | 69 scoped_refptr<content::AccessTokenStore> CreateAccessTokenStore() final { |
| 70 return new AwAccessTokenStore(); | 70 return new AwAccessTokenStore(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 private: | 73 private: |
| 74 DISALLOW_COPY_AND_ASSIGN(AwGeolocationDelegate); | 74 DISALLOW_COPY_AND_ASSIGN(AwGeolocationDelegate); |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 } // anonymous namespace | 77 } // anonymous namespace |
| 78 | 78 |
| 79 AwBrowserMainParts::AwBrowserMainParts(AwBrowserContext* browser_context) | 79 AwBrowserMainParts::AwBrowserMainParts(AwBrowserContext* browser_context) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // Create the renderers crash manager on the UI thread. | 120 // Create the renderers crash manager on the UI thread. |
| 121 breakpad::CrashMicroDumpManager::GetInstance(); | 121 breakpad::CrashMicroDumpManager::GetInstance(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 return content::RESULT_CODE_NORMAL_EXIT; | 124 return content::RESULT_CODE_NORMAL_EXIT; |
| 125 } | 125 } |
| 126 | 126 |
| 127 void AwBrowserMainParts::PreMainMessageLoopRun() { | 127 void AwBrowserMainParts::PreMainMessageLoopRun() { |
| 128 browser_context_->PreMainMessageLoopRun(); | 128 browser_context_->PreMainMessageLoopRun(); |
| 129 | 129 |
| 130 device::GeolocationProvider::SetGeolocationDelegate( | 130 content::GeolocationProvider::SetGeolocationDelegate( |
| 131 new AwGeolocationDelegate()); | 131 new AwGeolocationDelegate()); |
| 132 | 132 |
| 133 AwDevToolsDiscoveryProvider::Install(); | 133 AwDevToolsDiscoveryProvider::Install(); |
| 134 | 134 |
| 135 content::RenderFrameHost::AllowInjectingJavaScriptForAndroidWebView(); | 135 content::RenderFrameHost::AllowInjectingJavaScriptForAndroidWebView(); |
| 136 } | 136 } |
| 137 | 137 |
| 138 bool AwBrowserMainParts::MainMessageLoopRun(int* result_code) { | 138 bool AwBrowserMainParts::MainMessageLoopRun(int* result_code) { |
| 139 // Android WebView does not use default MessageLoop. It has its own | 139 // Android WebView does not use default MessageLoop. It has its own |
| 140 // Android specific MessageLoop. | 140 // Android specific MessageLoop. |
| 141 return true; | 141 return true; |
| 142 } | 142 } |
| 143 | 143 |
| 144 } // namespace android_webview | 144 } // namespace android_webview |
| OLD | NEW |