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