| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/shell/browser/shell_browser_main_parts.h" | 5 #include "extensions/shell/browser/shell_browser_main_parts.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 9 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 10 #include "components/omaha_query_params/omaha_query_params.h" | 10 #include "components/omaha_query_params/omaha_query_params.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 std::string install_crx_id = | 186 std::string install_crx_id = |
| 187 cmd->GetSwitchValueASCII(switches::kAppShellInstallCrx); | 187 cmd->GetSwitchValueASCII(switches::kAppShellInstallCrx); |
| 188 if (install_crx_id.size() != 0) { | 188 if (install_crx_id.size() != 0) { |
| 189 CHECK(install_crx_id.size() == 32) | 189 CHECK(install_crx_id.size() == 32) |
| 190 << "Extension ID must be exactly 32 characters long."; | 190 << "Extension ID must be exactly 32 characters long."; |
| 191 UpdateService* update_service = UpdateService::Get(browser_context_.get()); | 191 UpdateService* update_service = UpdateService::Get(browser_context_.get()); |
| 192 update_service->DownloadAndInstall(install_crx_id, | 192 update_service->DownloadAndInstall(install_crx_id, |
| 193 base::Bind(CrxInstallComplete)); | 193 base::Bind(CrxInstallComplete)); |
| 194 } | 194 } |
| 195 | 195 |
| 196 // CreateHttpHandler retains ownership over DevToolsHttpHandler. | 196 devtools_http_handler_.reset( |
| 197 devtools_http_handler_ = | |
| 198 content::ShellDevToolsManagerDelegate::CreateHttpHandler( | 197 content::ShellDevToolsManagerDelegate::CreateHttpHandler( |
| 199 browser_context_.get()); | 198 browser_context_.get())); |
| 200 if (parameters_.ui_task) { | 199 if (parameters_.ui_task) { |
| 201 // For running browser tests. | 200 // For running browser tests. |
| 202 parameters_.ui_task->Run(); | 201 parameters_.ui_task->Run(); |
| 203 delete parameters_.ui_task; | 202 delete parameters_.ui_task; |
| 204 run_message_loop_ = false; | 203 run_message_loop_ = false; |
| 205 } else { | 204 } else { |
| 206 browser_main_delegate_->Start(browser_context_.get()); | 205 browser_main_delegate_->Start(browser_context_.get()); |
| 207 } | 206 } |
| 208 } | 207 } |
| 209 | 208 |
| 210 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { | 209 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { |
| 211 if (!run_message_loop_) | 210 if (!run_message_loop_) |
| 212 return true; | 211 return true; |
| 213 // TODO(yoz): just return false here? | 212 // TODO(yoz): just return false here? |
| 214 base::RunLoop run_loop; | 213 base::RunLoop run_loop; |
| 215 run_loop.Run(); | 214 run_loop.Run(); |
| 216 *result_code = content::RESULT_CODE_NORMAL_EXIT; | 215 *result_code = content::RESULT_CODE_NORMAL_EXIT; |
| 217 return true; | 216 return true; |
| 218 } | 217 } |
| 219 | 218 |
| 220 void ShellBrowserMainParts::PostMainMessageLoopRun() { | 219 void ShellBrowserMainParts::PostMainMessageLoopRun() { |
| 221 browser_main_delegate_->Shutdown(); | 220 browser_main_delegate_->Shutdown(); |
| 222 if (devtools_http_handler_) { | 221 devtools_http_handler_.reset(); |
| 223 // Note that Stop destroys devtools_http_handler_. | |
| 224 devtools_http_handler_->Stop(); | |
| 225 devtools_http_handler_ = nullptr; | |
| 226 } | |
| 227 | 222 |
| 228 #if !defined(DISABLE_NACL) | 223 #if !defined(DISABLE_NACL) |
| 229 task_tracker_.TryCancelAll(); | 224 task_tracker_.TryCancelAll(); |
| 230 nacl::NaClBrowser::SetDelegate(nullptr); | 225 nacl::NaClBrowser::SetDelegate(nullptr); |
| 231 #endif | 226 #endif |
| 232 | 227 |
| 233 oauth2_token_service_.reset(); | 228 oauth2_token_service_.reset(); |
| 234 BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices( | 229 BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices( |
| 235 browser_context_.get()); | 230 browser_context_.get()); |
| 236 extension_system_ = NULL; | 231 extension_system_ = NULL; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 254 } | 249 } |
| 255 | 250 |
| 256 void ShellBrowserMainParts::CreateExtensionSystem() { | 251 void ShellBrowserMainParts::CreateExtensionSystem() { |
| 257 DCHECK(browser_context_); | 252 DCHECK(browser_context_); |
| 258 extension_system_ = static_cast<ShellExtensionSystem*>( | 253 extension_system_ = static_cast<ShellExtensionSystem*>( |
| 259 ExtensionSystem::Get(browser_context_.get())); | 254 ExtensionSystem::Get(browser_context_.get())); |
| 260 extension_system_->InitForRegularProfile(true); | 255 extension_system_->InitForRegularProfile(true); |
| 261 } | 256 } |
| 262 | 257 |
| 263 } // namespace extensions | 258 } // namespace extensions |
| OLD | NEW |