| 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_browser_terminator.h" |
| 8 #include "android_webview/browser/aw_content_browser_client.h" | 9 #include "android_webview/browser/aw_content_browser_client.h" |
| 9 #include "android_webview/browser/aw_dev_tools_discovery_provider.h" | 10 #include "android_webview/browser/aw_dev_tools_discovery_provider.h" |
| 10 #include "android_webview/browser/aw_result_codes.h" | 11 #include "android_webview/browser/aw_result_codes.h" |
| 11 #include "android_webview/browser/deferred_gpu_command_service.h" | 12 #include "android_webview/browser/deferred_gpu_command_service.h" |
| 12 #include "android_webview/browser/net/aw_network_change_notifier_factory.h" | 13 #include "android_webview/browser/net/aw_network_change_notifier_factory.h" |
| 13 #include "android_webview/common/aw_resource.h" | 14 #include "android_webview/common/aw_resource.h" |
| 14 #include "android_webview/common/aw_switches.h" | 15 #include "android_webview/common/aw_switches.h" |
| 15 #include "base/android/apk_assets.h" | 16 #include "base/android/apk_assets.h" |
| 16 #include "base/android/build_info.h" | 17 #include "base/android/build_info.h" |
| 17 #include "base/android/locale_utils.h" | 18 #include "base/android/locale_utils.h" |
| 18 #include "base/android/memory_pressure_listener_android.h" | 19 #include "base/android/memory_pressure_listener_android.h" |
| 19 #include "base/command_line.h" | 20 #include "base/command_line.h" |
| 20 #include "base/files/file_path.h" | 21 #include "base/files/file_path.h" |
| 21 #include "base/i18n/rtl.h" | 22 #include "base/i18n/rtl.h" |
| 22 #include "base/path_service.h" | 23 #include "base/path_service.h" |
| 23 #include "components/crash/content/browser/crash_micro_dump_manager_android.h" | 24 #include "components/crash/content/browser/crash_dump_observer_android.h" |
| 24 #include "content/public/browser/android/synchronous_compositor.h" | 25 #include "content/public/browser/android/synchronous_compositor.h" |
| 25 #include "content/public/browser/render_frame_host.h" | 26 #include "content/public/browser/render_frame_host.h" |
| 26 #include "content/public/browser/render_process_host.h" | 27 #include "content/public/browser/render_process_host.h" |
| 27 #include "content/public/common/content_client.h" | 28 #include "content/public/common/content_client.h" |
| 28 #include "content/public/common/content_switches.h" | 29 #include "content/public/common/content_switches.h" |
| 29 #include "content/public/common/result_codes.h" | 30 #include "content/public/common/result_codes.h" |
| 30 #include "device/geolocation/access_token_store.h" | 31 #include "device/geolocation/access_token_store.h" |
| 31 #include "device/geolocation/geolocation_delegate.h" | 32 #include "device/geolocation/geolocation_delegate.h" |
| 32 #include "device/geolocation/geolocation_provider.h" | 33 #include "device/geolocation/geolocation_provider.h" |
| 33 #include "net/android/network_change_notifier_factory_android.h" | 34 #include "net/android/network_change_notifier_factory_android.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 DISALLOW_COPY_AND_ASSIGN(AwGeolocationDelegate); | 76 DISALLOW_COPY_AND_ASSIGN(AwGeolocationDelegate); |
| 76 }; | 77 }; |
| 77 | 78 |
| 78 } // anonymous namespace | 79 } // anonymous namespace |
| 79 | 80 |
| 80 AwBrowserMainParts::AwBrowserMainParts(AwContentBrowserClient* browser_client) | 81 AwBrowserMainParts::AwBrowserMainParts(AwContentBrowserClient* browser_client) |
| 81 : browser_client_(browser_client) { | 82 : browser_client_(browser_client) { |
| 82 } | 83 } |
| 83 | 84 |
| 84 AwBrowserMainParts::~AwBrowserMainParts() { | 85 AwBrowserMainParts::~AwBrowserMainParts() { |
| 86 breakpad::CrashDumpObserver::GetInstance()->UnregisterClient( |
| 87 aw_browser_terminator_.get()); |
| 85 } | 88 } |
| 86 | 89 |
| 87 void AwBrowserMainParts::PreEarlyInitialization() { | 90 void AwBrowserMainParts::PreEarlyInitialization() { |
| 88 net::NetworkChangeNotifier::SetFactory(new AwNetworkChangeNotifierFactory()); | 91 net::NetworkChangeNotifier::SetFactory(new AwNetworkChangeNotifierFactory()); |
| 89 | 92 |
| 90 // Android WebView does not use default MessageLoop. It has its own | 93 // Android WebView does not use default MessageLoop. It has its own |
| 91 // Android specific MessageLoop. Also see MainMessageLoopRun. | 94 // Android specific MessageLoop. Also see MainMessageLoopRun. |
| 92 DCHECK(!main_message_loop_.get()); | 95 DCHECK(!main_message_loop_.get()); |
| 93 main_message_loop_.reset(new base::MessageLoopForUI); | 96 main_message_loop_.reset(new base::MessageLoopForUI); |
| 94 base::MessageLoopForUI::current()->Start(); | 97 base::MessageLoopForUI::current()->Start(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 112 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &pak_file_path); | 115 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &pak_file_path); |
| 113 pak_file_path = pak_file_path.AppendASCII("resources.pak"); | 116 pak_file_path = pak_file_path.AppendASCII("resources.pak"); |
| 114 ui::LoadMainAndroidPackFile("assets/resources.pak", pak_file_path); | 117 ui::LoadMainAndroidPackFile("assets/resources.pak", pak_file_path); |
| 115 | 118 |
| 116 base::android::MemoryPressureListenerAndroid::RegisterSystemCallback( | 119 base::android::MemoryPressureListenerAndroid::RegisterSystemCallback( |
| 117 base::android::AttachCurrentThread()); | 120 base::android::AttachCurrentThread()); |
| 118 DeferredGpuCommandService::SetInstance(); | 121 DeferredGpuCommandService::SetInstance(); |
| 119 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 122 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 120 switches::kSingleProcess)) { | 123 switches::kSingleProcess)) { |
| 121 // Create the renderers crash manager on the UI thread. | 124 // Create the renderers crash manager on the UI thread. |
| 122 breakpad::CrashMicroDumpManager::GetInstance(); | 125 aw_browser_terminator_ = base::MakeUnique<AwBrowserTerminator>(); |
| 126 breakpad::CrashDumpObserver::GetInstance()->RegisterClient( |
| 127 aw_browser_terminator_.get()); |
| 123 } | 128 } |
| 124 | 129 |
| 125 return content::RESULT_CODE_NORMAL_EXIT; | 130 return content::RESULT_CODE_NORMAL_EXIT; |
| 126 } | 131 } |
| 127 | 132 |
| 128 void AwBrowserMainParts::PreMainMessageLoopRun() { | 133 void AwBrowserMainParts::PreMainMessageLoopRun() { |
| 129 browser_client_->InitBrowserContext()->PreMainMessageLoopRun(); | 134 browser_client_->InitBrowserContext()->PreMainMessageLoopRun(); |
| 130 | 135 |
| 131 device::GeolocationProvider::SetGeolocationDelegate( | 136 device::GeolocationProvider::SetGeolocationDelegate( |
| 132 new AwGeolocationDelegate()); | 137 new AwGeolocationDelegate()); |
| 133 | 138 |
| 134 AwDevToolsDiscoveryProvider::Install(); | 139 AwDevToolsDiscoveryProvider::Install(); |
| 135 | 140 |
| 136 content::RenderFrameHost::AllowInjectingJavaScriptForAndroidWebView(); | 141 content::RenderFrameHost::AllowInjectingJavaScriptForAndroidWebView(); |
| 137 } | 142 } |
| 138 | 143 |
| 139 bool AwBrowserMainParts::MainMessageLoopRun(int* result_code) { | 144 bool AwBrowserMainParts::MainMessageLoopRun(int* result_code) { |
| 140 // Android WebView does not use default MessageLoop. It has its own | 145 // Android WebView does not use default MessageLoop. It has its own |
| 141 // Android specific MessageLoop. | 146 // Android specific MessageLoop. |
| 142 return true; | 147 return true; |
| 143 } | 148 } |
| 144 | 149 |
| 145 } // namespace android_webview | 150 } // namespace android_webview |
| OLD | NEW |