| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/shell/browser/shell_browser_main_parts.h" | 5 #include "content/shell/browser/shell_browser_main_parts.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
| 13 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "components/devtools_http_handler/devtools_http_handler.h" | |
| 16 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/devtools_agent_host.h" |
| 17 #include "content/public/browser/storage_partition.h" | 17 #include "content/public/browser/storage_partition.h" |
| 18 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
| 19 #include "content/public/common/main_function_params.h" | 19 #include "content/public/common/main_function_params.h" |
| 20 #include "content/public/common/url_constants.h" | 20 #include "content/public/common/url_constants.h" |
| 21 #include "content/shell/browser/shell.h" | 21 #include "content/shell/browser/shell.h" |
| 22 #include "content/shell/browser/shell_access_token_store.h" | 22 #include "content/shell/browser/shell_access_token_store.h" |
| 23 #include "content/shell/browser/shell_browser_context.h" | 23 #include "content/shell/browser/shell_browser_context.h" |
| 24 #include "content/shell/browser/shell_devtools_manager_delegate.h" | 24 #include "content/shell/browser/shell_devtools_manager_delegate.h" |
| 25 #include "content/shell/browser/shell_net_log.h" | 25 #include "content/shell/browser/shell_net_log.h" |
| 26 #include "content/shell/common/shell_switches.h" | 26 #include "content/shell/common/shell_switches.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 return html_data; | 103 return html_data; |
| 104 } | 104 } |
| 105 return base::StringPiece(); | 105 return base::StringPiece(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 } // namespace | 108 } // namespace |
| 109 | 109 |
| 110 ShellBrowserMainParts::ShellBrowserMainParts( | 110 ShellBrowserMainParts::ShellBrowserMainParts( |
| 111 const MainFunctionParams& parameters) | 111 const MainFunctionParams& parameters) |
| 112 : parameters_(parameters), | 112 : parameters_(parameters), |
| 113 run_message_loop_(true), | 113 run_message_loop_(true) { |
| 114 devtools_http_handler_(nullptr) { | |
| 115 } | 114 } |
| 116 | 115 |
| 117 ShellBrowserMainParts::~ShellBrowserMainParts() { | 116 ShellBrowserMainParts::~ShellBrowserMainParts() { |
| 118 DCHECK(!devtools_http_handler_); | |
| 119 } | 117 } |
| 120 | 118 |
| 121 #if !defined(OS_MACOSX) | 119 #if !defined(OS_MACOSX) |
| 122 void ShellBrowserMainParts::PreMainMessageLoopStart() { | 120 void ShellBrowserMainParts::PreMainMessageLoopStart() { |
| 123 #if defined(USE_AURA) && defined(USE_X11) | 121 #if defined(USE_AURA) && defined(USE_X11) |
| 124 ui::TouchFactory::SetTouchDeviceListFromCommandLine(); | 122 ui::TouchFactory::SetTouchDeviceListFromCommandLine(); |
| 125 #endif | 123 #endif |
| 126 } | 124 } |
| 127 #endif | 125 #endif |
| 128 | 126 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 } | 178 } |
| 181 #endif | 179 #endif |
| 182 | 180 |
| 183 void ShellBrowserMainParts::PreMainMessageLoopRun() { | 181 void ShellBrowserMainParts::PreMainMessageLoopRun() { |
| 184 net_log_.reset(new ShellNetLog("content_shell")); | 182 net_log_.reset(new ShellNetLog("content_shell")); |
| 185 InitializeBrowserContexts(); | 183 InitializeBrowserContexts(); |
| 186 device::GeolocationProvider::SetGeolocationDelegate( | 184 device::GeolocationProvider::SetGeolocationDelegate( |
| 187 new ShellGeolocationDelegate(browser_context())); | 185 new ShellGeolocationDelegate(browser_context())); |
| 188 Shell::Initialize(); | 186 Shell::Initialize(); |
| 189 net::NetModule::SetResourceProvider(PlatformResourceProvider); | 187 net::NetModule::SetResourceProvider(PlatformResourceProvider); |
| 190 | 188 ShellDevToolsManagerDelegate::StartHttpHandler(browser_context_.get()); |
| 191 devtools_http_handler_.reset( | |
| 192 ShellDevToolsManagerDelegate::CreateHttpHandler(browser_context_.get())); | |
| 193 | |
| 194 InitializeMessageLoopContext(); | 189 InitializeMessageLoopContext(); |
| 195 | 190 |
| 196 if (parameters_.ui_task) { | 191 if (parameters_.ui_task) { |
| 197 parameters_.ui_task->Run(); | 192 parameters_.ui_task->Run(); |
| 198 delete parameters_.ui_task; | 193 delete parameters_.ui_task; |
| 199 run_message_loop_ = false; | 194 run_message_loop_ = false; |
| 200 } | 195 } |
| 201 } | 196 } |
| 202 | 197 |
| 203 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { | 198 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { |
| 204 return !run_message_loop_; | 199 return !run_message_loop_; |
| 205 } | 200 } |
| 206 | 201 |
| 207 void ShellBrowserMainParts::PostMainMessageLoopRun() { | 202 void ShellBrowserMainParts::PostMainMessageLoopRun() { |
| 208 devtools_http_handler_.reset(); | 203 ShellDevToolsManagerDelegate::StopHttpHandler(); |
| 209 browser_context_.reset(); | 204 browser_context_.reset(); |
| 210 off_the_record_browser_context_.reset(); | 205 off_the_record_browser_context_.reset(); |
| 211 } | 206 } |
| 212 | 207 |
| 213 void ShellBrowserMainParts::PostDestroyThreads() { | 208 void ShellBrowserMainParts::PostDestroyThreads() { |
| 214 #if defined(OS_CHROMEOS) | 209 #if defined(OS_CHROMEOS) |
| 215 device::BluetoothAdapterFactory::Shutdown(); | 210 device::BluetoothAdapterFactory::Shutdown(); |
| 216 bluez::BluezDBusManager::Shutdown(); | 211 bluez::BluezDBusManager::Shutdown(); |
| 217 chromeos::DBusThreadManager::Shutdown(); | 212 chromeos::DBusThreadManager::Shutdown(); |
| 218 #elif defined(OS_LINUX) | 213 #elif defined(OS_LINUX) |
| 219 device::BluetoothAdapterFactory::Shutdown(); | 214 device::BluetoothAdapterFactory::Shutdown(); |
| 220 bluez::DBusBluezManagerWrapperLinux::Shutdown(); | 215 bluez::DBusBluezManagerWrapperLinux::Shutdown(); |
| 221 #endif | 216 #endif |
| 222 } | 217 } |
| 223 | 218 |
| 224 } // namespace | 219 } // namespace |
| OLD | NEW |