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 "net/android/network_change_notifier_factory_android.h" | 32 #include "net/android/network_change_notifier_factory_android.h" |
30 #include "net/base/network_change_notifier.h" | 33 #include "net/base/network_change_notifier.h" |
31 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
32 #include "ui/base/layout.h" | 35 #include "ui/base/layout.h" |
33 #include "ui/base/resource/resource_bundle.h" | 36 #include "ui/base/resource/resource_bundle.h" |
34 #include "ui/base/resource/resource_bundle_android.h" | 37 #include "ui/base/resource/resource_bundle_android.h" |
35 #include "ui/base/ui_base_paths.h" | 38 #include "ui/base/ui_base_paths.h" |
36 #include "ui/gl/gl_surface.h" | 39 #include "ui/gl/gl_surface.h" |
37 | 40 |
38 namespace android_webview { | 41 namespace android_webview { |
| 42 namespace { |
| 43 |
| 44 class AwAccessTokenStore : public content::AccessTokenStore { |
| 45 public: |
| 46 AwAccessTokenStore() { } |
| 47 |
| 48 // content::AccessTokenStore implementation |
| 49 void LoadAccessTokens(const LoadAccessTokensCallback& request) override { |
| 50 AccessTokenStore::AccessTokenMap access_token_map; |
| 51 // AccessTokenMap and net::URLRequestContextGetter not used on Android, |
| 52 // but Run needs to be called to finish the geolocation setup. |
| 53 request.Run(access_token_map, NULL); |
| 54 } |
| 55 void SaveAccessToken(const GURL& server_url, |
| 56 const base::string16& access_token) override {} |
| 57 |
| 58 private: |
| 59 ~AwAccessTokenStore() override {} |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore); |
| 62 }; |
| 63 |
| 64 // A provider of Geolocation services to override AccessTokenStore. |
| 65 class AwGeolocationDelegate : public content::GeolocationDelegate { |
| 66 public: |
| 67 AwGeolocationDelegate() = default; |
| 68 |
| 69 scoped_refptr<content::AccessTokenStore> CreateAccessTokenStore() final { |
| 70 return new AwAccessTokenStore(); |
| 71 } |
| 72 |
| 73 private: |
| 74 DISALLOW_COPY_AND_ASSIGN(AwGeolocationDelegate); |
| 75 }; |
| 76 |
| 77 } // anonymous namespace |
39 | 78 |
40 AwBrowserMainParts::AwBrowserMainParts(AwBrowserContext* browser_context) | 79 AwBrowserMainParts::AwBrowserMainParts(AwBrowserContext* browser_context) |
41 : browser_context_(browser_context) { | 80 : browser_context_(browser_context) { |
42 } | 81 } |
43 | 82 |
44 AwBrowserMainParts::~AwBrowserMainParts() { | 83 AwBrowserMainParts::~AwBrowserMainParts() { |
45 } | 84 } |
46 | 85 |
47 void AwBrowserMainParts::PreEarlyInitialization() { | 86 void AwBrowserMainParts::PreEarlyInitialization() { |
48 net::NetworkChangeNotifier::SetFactory(new AwNetworkChangeNotifierFactory()); | 87 net::NetworkChangeNotifier::SetFactory(new AwNetworkChangeNotifierFactory()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // Create the renderers crash manager on the UI thread. | 120 // Create the renderers crash manager on the UI thread. |
82 breakpad::CrashMicroDumpManager::GetInstance(); | 121 breakpad::CrashMicroDumpManager::GetInstance(); |
83 } | 122 } |
84 | 123 |
85 return content::RESULT_CODE_NORMAL_EXIT; | 124 return content::RESULT_CODE_NORMAL_EXIT; |
86 } | 125 } |
87 | 126 |
88 void AwBrowserMainParts::PreMainMessageLoopRun() { | 127 void AwBrowserMainParts::PreMainMessageLoopRun() { |
89 browser_context_->PreMainMessageLoopRun(); | 128 browser_context_->PreMainMessageLoopRun(); |
90 | 129 |
| 130 content::GeolocationProvider::SetGeolocationDelegate( |
| 131 new AwGeolocationDelegate()); |
| 132 |
91 AwDevToolsDiscoveryProvider::Install(); | 133 AwDevToolsDiscoveryProvider::Install(); |
92 | 134 |
93 content::RenderFrameHost::AllowInjectingJavaScriptForAndroidWebView(); | 135 content::RenderFrameHost::AllowInjectingJavaScriptForAndroidWebView(); |
94 } | 136 } |
95 | 137 |
96 bool AwBrowserMainParts::MainMessageLoopRun(int* result_code) { | 138 bool AwBrowserMainParts::MainMessageLoopRun(int* result_code) { |
97 // Android WebView does not use default MessageLoop. It has its own | 139 // Android WebView does not use default MessageLoop. It has its own |
98 // Android specific MessageLoop. | 140 // Android specific MessageLoop. |
99 return true; | 141 return true; |
100 } | 142 } |
101 | 143 |
102 } // namespace android_webview | 144 } // namespace android_webview |
OLD | NEW |