| 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 "apps/shell/browser/shell_browser_main_parts.h" | 5 #include "apps/shell/browser/shell_browser_main_parts.h" |
| 6 | 6 |
| 7 #include "apps/shell/browser/shell_browser_context.h" | 7 #include "apps/shell/browser/shell_browser_context.h" |
| 8 #include "apps/shell/browser/shell_extension_system.h" | 8 #include "apps/shell/browser/shell_extension_system.h" |
| 9 #include "apps/shell/browser/shell_extensions_browser_client.h" | 9 #include "apps/shell/browser/shell_extensions_browser_client.h" |
| 10 #include "apps/shell/browser/web_view_window.h" | 10 #include "apps/shell/browser/web_view_window.h" |
| 11 #include "apps/shell/common/shell_extensions_client.h" | 11 #include "apps/shell/common/shell_extensions_client.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 16 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
| 17 #include "content/public/common/result_codes.h" | 17 #include "content/public/common/result_codes.h" |
| 18 #include "content/shell/browser/shell_devtools_delegate.h" |
| 18 #include "content/shell/browser/shell_net_log.h" | 19 #include "content/shell/browser/shell_net_log.h" |
| 19 #include "extensions/browser/extension_system.h" | 20 #include "extensions/browser/extension_system.h" |
| 20 #include "extensions/browser/renderer_startup_helper.h" | 21 #include "extensions/browser/renderer_startup_helper.h" |
| 21 #include "ui/aura/env.h" | 22 #include "ui/aura/env.h" |
| 22 #include "ui/aura/root_window.h" | 23 #include "ui/aura/root_window.h" |
| 23 #include "ui/aura/test/test_screen.h" | 24 #include "ui/aura/test/test_screen.h" |
| 24 #include "ui/base/ime/input_method_initializer.h" | 25 #include "ui/base/ime/input_method_initializer.h" |
| 25 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
| 26 #include "ui/gfx/screen.h" | 27 #include "ui/gfx/screen.h" |
| 27 #include "ui/views/test/test_views_delegate.h" | 28 #include "ui/views/test/test_views_delegate.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); | 110 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); |
| 110 | 111 |
| 111 // Create our custom ExtensionSystem first because other | 112 // Create our custom ExtensionSystem first because other |
| 112 // BrowserContextKeyedServices depend on it. | 113 // BrowserContextKeyedServices depend on it. |
| 113 CreateExtensionSystem(); | 114 CreateExtensionSystem(); |
| 114 | 115 |
| 115 EnsureBrowserContextKeyedServiceFactoriesBuilt(); | 116 EnsureBrowserContextKeyedServiceFactoriesBuilt(); |
| 116 BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices( | 117 BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices( |
| 117 browser_context_.get()); | 118 browser_context_.get()); |
| 118 | 119 |
| 120 devtools_delegate_.reset( |
| 121 new content::ShellDevToolsDelegate(browser_context_.get())); |
| 122 |
| 119 CreateRootWindow(); | 123 CreateRootWindow(); |
| 120 CreateViewsDelegate(); | 124 CreateViewsDelegate(); |
| 121 | 125 |
| 122 const std::string kAppSwitch = "app"; | 126 const std::string kAppSwitch = "app"; |
| 123 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 127 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 124 if (command_line->HasSwitch(kAppSwitch)) { | 128 if (command_line->HasSwitch(kAppSwitch)) { |
| 125 base::FilePath app_dir(command_line->GetSwitchValueNative(kAppSwitch)); | 129 base::FilePath app_dir(command_line->GetSwitchValueNative(kAppSwitch)); |
| 126 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); | 130 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); |
| 127 extension_system_->LoadAndLaunchApp(app_absolute_dir); | 131 extension_system_->LoadAndLaunchApp(app_absolute_dir); |
| 128 } else { | 132 } else { |
| 129 // TODO(jamescook): For demo purposes create a window with a WebView just | 133 // TODO(jamescook): For demo purposes create a window with a WebView just |
| 130 // to ensure that the content module is properly initialized. | 134 // to ensure that the content module is properly initialized. |
| 131 webview_window_.reset(CreateWebViewWindow(browser_context_.get(), | 135 webview_window_.reset(CreateWebViewWindow(browser_context_.get(), |
| 132 wm_test_helper_->root_window()->window())); | 136 wm_test_helper_->root_window()->window())); |
| 133 webview_window_->Show(); | 137 webview_window_->Show(); |
| 134 } | 138 } |
| 135 } | 139 } |
| 136 | 140 |
| 137 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { | 141 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { |
| 138 base::RunLoop run_loop; | 142 base::RunLoop run_loop; |
| 139 run_loop.Run(); | 143 run_loop.Run(); |
| 140 *result_code = content::RESULT_CODE_NORMAL_EXIT; | 144 *result_code = content::RESULT_CODE_NORMAL_EXIT; |
| 141 return true; | 145 return true; |
| 142 } | 146 } |
| 143 | 147 |
| 144 void ShellBrowserMainParts::PostMainMessageLoopRun() { | 148 void ShellBrowserMainParts::PostMainMessageLoopRun() { |
| 149 devtools_delegate_->Stop(); |
| 145 DestroyViewsDelegate(); | 150 DestroyViewsDelegate(); |
| 146 DestroyRootWindow(); | 151 DestroyRootWindow(); |
| 147 BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices( | 152 BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices( |
| 148 browser_context_.get()); | 153 browser_context_.get()); |
| 149 extension_system_ = NULL; | 154 extension_system_ = NULL; |
| 150 extensions::ExtensionsBrowserClient::Set(NULL); | 155 extensions::ExtensionsBrowserClient::Set(NULL); |
| 151 extensions_browser_client_.reset(); | 156 extensions_browser_client_.reset(); |
| 152 browser_context_.reset(); | 157 browser_context_.reset(); |
| 153 aura::Env::DeleteInstance(); | 158 aura::Env::DeleteInstance(); |
| 154 } | 159 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 } | 199 } |
| 195 | 200 |
| 196 void ShellBrowserMainParts::CreateExtensionSystem() { | 201 void ShellBrowserMainParts::CreateExtensionSystem() { |
| 197 DCHECK(browser_context_); | 202 DCHECK(browser_context_); |
| 198 extension_system_ = static_cast<ShellExtensionSystem*>( | 203 extension_system_ = static_cast<ShellExtensionSystem*>( |
| 199 ExtensionSystem::Get(browser_context_.get())); | 204 ExtensionSystem::Get(browser_context_.get())); |
| 200 extension_system_->InitForRegularProfile(true); | 205 extension_system_->InitForRegularProfile(true); |
| 201 } | 206 } |
| 202 | 207 |
| 203 } // namespace apps | 208 } // namespace apps |
| OLD | NEW |