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_apps_client.h" |
7 #include "apps/shell/browser/shell_browser_context.h" | 8 #include "apps/shell/browser/shell_browser_context.h" |
8 #include "apps/shell/browser/shell_extension_system.h" | 9 #include "apps/shell/browser/shell_extension_system.h" |
9 #include "apps/shell/browser/shell_extension_system_factory.h" | 10 #include "apps/shell/browser/shell_extension_system_factory.h" |
10 #include "apps/shell/browser/shell_extensions_browser_client.h" | 11 #include "apps/shell/browser/shell_extensions_browser_client.h" |
11 #include "apps/shell/browser/web_view_window.h" | 12 #include "apps/shell/browser/web_view_window.h" |
12 #include "apps/shell/common/shell_extensions_client.h" | 13 #include "apps/shell/common/shell_extensions_client.h" |
13 #include "base/command_line.h" | 14 #include "base/command_line.h" |
14 #include "base/file_util.h" | 15 #include "base/file_util.h" |
15 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
16 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // Initialize our "profile" equivalent. | 105 // Initialize our "profile" equivalent. |
105 browser_context_.reset(new ShellBrowserContext); | 106 browser_context_.reset(new ShellBrowserContext); |
106 | 107 |
107 extensions_client_.reset(new ShellExtensionsClient()); | 108 extensions_client_.reset(new ShellExtensionsClient()); |
108 extensions::ExtensionsClient::Set(extensions_client_.get()); | 109 extensions::ExtensionsClient::Set(extensions_client_.get()); |
109 | 110 |
110 extensions_browser_client_.reset( | 111 extensions_browser_client_.reset( |
111 new extensions::ShellExtensionsBrowserClient(browser_context_.get())); | 112 new extensions::ShellExtensionsBrowserClient(browser_context_.get())); |
112 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); | 113 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); |
113 | 114 |
| 115 apps_client_.reset(new ShellAppsClient(browser_context_.get())); |
| 116 AppsClient::Set(apps_client_.get()); |
| 117 |
114 // Create our custom ExtensionSystem first because other | 118 // Create our custom ExtensionSystem first because other |
115 // BrowserContextKeyedServices depend on it. | 119 // BrowserContextKeyedServices depend on it. |
116 // TODO(yoz): Move this after EnsureBrowserContextKeyedServiceFactoriesBuilt. | 120 // TODO(yoz): Move this after EnsureBrowserContextKeyedServiceFactoriesBuilt. |
117 CreateExtensionSystem(); | 121 CreateExtensionSystem(); |
118 | 122 |
119 EnsureBrowserContextKeyedServiceFactoriesBuilt(); | 123 EnsureBrowserContextKeyedServiceFactoriesBuilt(); |
120 BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices( | 124 BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices( |
121 browser_context_.get()); | 125 browser_context_.get()); |
122 | 126 |
123 devtools_delegate_.reset( | 127 devtools_delegate_.reset( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 browser_context_.get()); | 160 browser_context_.get()); |
157 extension_system_ = NULL; | 161 extension_system_ = NULL; |
158 extensions::ExtensionsBrowserClient::Set(NULL); | 162 extensions::ExtensionsBrowserClient::Set(NULL); |
159 extensions_browser_client_.reset(); | 163 extensions_browser_client_.reset(); |
160 browser_context_.reset(); | 164 browser_context_.reset(); |
161 aura::Env::DeleteInstance(); | 165 aura::Env::DeleteInstance(); |
162 } | 166 } |
163 | 167 |
164 void ShellBrowserMainParts::OnWindowTreeHostCloseRequested( | 168 void ShellBrowserMainParts::OnWindowTreeHostCloseRequested( |
165 const aura::RootWindow* root) { | 169 const aura::RootWindow* root) { |
| 170 extension_system_->CloseApp(); |
166 base::MessageLoop::current()->PostTask(FROM_HERE, | 171 base::MessageLoop::current()->PostTask(FROM_HERE, |
167 base::MessageLoop::QuitClosure()); | 172 base::MessageLoop::QuitClosure()); |
168 } | 173 } |
169 | 174 |
170 void ShellBrowserMainParts::CreateRootWindow() { | 175 void ShellBrowserMainParts::CreateRootWindow() { |
171 test_screen_.reset(aura::TestScreen::Create()); | 176 test_screen_.reset(aura::TestScreen::Create()); |
172 // TODO(jamescook): Replace this with a real Screen implementation. | 177 // TODO(jamescook): Replace this with a real Screen implementation. |
173 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); | 178 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); |
174 // TODO(jamescook): Initialize a real input method. | 179 // TODO(jamescook): Initialize a real input method. |
175 ui::InitializeInputMethodForTesting(); | 180 ui::InitializeInputMethodForTesting(); |
(...skipping 26 matching lines...) Expand all Loading... |
202 } | 207 } |
203 | 208 |
204 void ShellBrowserMainParts::CreateExtensionSystem() { | 209 void ShellBrowserMainParts::CreateExtensionSystem() { |
205 DCHECK(browser_context_); | 210 DCHECK(browser_context_); |
206 extension_system_ = static_cast<ShellExtensionSystem*>( | 211 extension_system_ = static_cast<ShellExtensionSystem*>( |
207 ExtensionSystem::Get(browser_context_.get())); | 212 ExtensionSystem::Get(browser_context_.get())); |
208 extension_system_->InitForRegularProfile(true); | 213 extension_system_->InitForRegularProfile(true); |
209 } | 214 } |
210 | 215 |
211 } // namespace apps | 216 } // namespace apps |
OLD | NEW |