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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "chrome/browser/extensions/api/runtime/runtime_api.h" | 13 #include "chrome/browser/extensions/api/runtime/runtime_api.h" |
| 14 #include "chrome/browser/extensions/app_extension_host_delegate.h" |
14 #include "chrome/browser/extensions/extension_process_manager.h" | 15 #include "chrome/browser/extensions/extension_process_manager.h" |
15 #include "chrome/browser/extensions/extension_host.h" | 16 #include "chrome/browser/extensions/extension_host.h" |
16 #include "chrome/browser/extensions/extension_info_map.h" | 17 #include "chrome/browser/extensions/extension_info_map.h" |
17 #include "chrome/browser/extensions/extension_service.h" | 18 #include "chrome/browser/extensions/extension_service.h" |
18 #include "chrome/browser/extensions/extension_system.h" | 19 #include "chrome/browser/extensions/extension_system.h" |
19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/browser/ui/browser_finder.h" | 22 #include "chrome/browser/ui/browser_finder.h" |
22 #include "chrome/browser/ui/browser_tabstrip.h" | 23 #include "chrome/browser/ui/browser_tabstrip.h" |
23 #include "chrome/browser/ui/browser_window.h" | 24 #include "chrome/browser/ui/browser_window.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 ExtensionHost* ExtensionProcessManager::CreateViewHost( | 211 ExtensionHost* ExtensionProcessManager::CreateViewHost( |
211 const Extension* extension, | 212 const Extension* extension, |
212 const GURL& url, | 213 const GURL& url, |
213 Browser* browser, | 214 Browser* browser, |
214 chrome::ViewType view_type) { | 215 chrome::ViewType view_type) { |
215 DCHECK(extension); | 216 DCHECK(extension); |
216 EnsureBrowserWhenRequired(browser, view_type); | 217 EnsureBrowserWhenRequired(browser, view_type); |
217 ExtensionHost* host = | 218 ExtensionHost* host = |
218 #if defined(OS_MACOSX) | 219 #if defined(OS_MACOSX) |
219 new extensions::ExtensionHostMac( | 220 new extensions::ExtensionHostMac( |
220 extension, GetSiteInstanceForURL(url), url, view_type); | 221 extension, new ExtensionHost::Delegate(), |
| 222 GetSiteInstanceForURL(url), url, view_type); |
221 #else | 223 #else |
222 new ExtensionHost(extension, GetSiteInstanceForURL(url), url, view_type); | 224 new ExtensionHost(extension, new ExtensionHost::Delegate(), |
| 225 GetSiteInstanceForURL(url), url, view_type); |
223 #endif | 226 #endif |
224 host->CreateView(browser); | 227 host->CreateView(browser); |
225 OnExtensionHostCreated(host, false); | 228 OnExtensionHostCreated(host, false); |
226 return host; | 229 return host; |
227 } | 230 } |
228 | 231 |
229 ExtensionHost* ExtensionProcessManager::CreateViewHost( | 232 ExtensionHost* ExtensionProcessManager::CreateViewHost( |
230 const GURL& url, Browser* browser, chrome::ViewType view_type) { | 233 const GURL& url, Browser* browser, chrome::ViewType view_type) { |
231 EnsureBrowserWhenRequired(browser, view_type); | 234 EnsureBrowserWhenRequired(browser, view_type); |
232 ExtensionService* service = GetProfile()->GetExtensionService(); | 235 ExtensionService* service = GetProfile()->GetExtensionService(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 const Extension* extension, const GURL& url) { | 276 const Extension* extension, const GURL& url) { |
274 // Hosted apps are taken care of from BackgroundContentsService. Ignore them | 277 // Hosted apps are taken care of from BackgroundContentsService. Ignore them |
275 // here. | 278 // here. |
276 if (extension->is_hosted_app()) | 279 if (extension->is_hosted_app()) |
277 return; | 280 return; |
278 | 281 |
279 // Don't create multiple background hosts for an extension. | 282 // Don't create multiple background hosts for an extension. |
280 if (GetBackgroundHostForExtension(extension->id())) | 283 if (GetBackgroundHostForExtension(extension->id())) |
281 return; | 284 return; |
282 | 285 |
| 286 ExtensionHost::Delegate* host_delegate; |
| 287 if (extension->is_platform_app()) |
| 288 host_delegate = new extensions::AppBackgroundHostDelegate(); |
| 289 else |
| 290 host_delegate = new ExtensionHost::Delegate(); |
| 291 |
283 ExtensionHost* host = | 292 ExtensionHost* host = |
284 #if defined(OS_MACOSX) | 293 #if defined(OS_MACOSX) |
285 new extensions::ExtensionHostMac( | 294 new extensions::ExtensionHostMac( |
286 extension, GetSiteInstanceForURL(url), url, | 295 extension, host_delegate, GetSiteInstanceForURL(url), url, |
287 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); | 296 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); |
288 #else | 297 #else |
289 new ExtensionHost(extension, GetSiteInstanceForURL(url), url, | 298 new ExtensionHost(extension, host_delegate, GetSiteInstanceForURL(url), |
290 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); | 299 url, chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); |
291 #endif | 300 #endif |
292 | 301 |
293 host->CreateRenderViewSoon(); | 302 host->CreateRenderViewSoon(); |
294 OnExtensionHostCreated(host, true); | 303 OnExtensionHostCreated(host, true); |
295 } | 304 } |
296 | 305 |
297 void ExtensionProcessManager::OpenOptionsPage(const Extension* extension, | 306 void ExtensionProcessManager::OpenOptionsPage(const Extension* extension, |
298 Browser* browser) { | 307 Browser* browser) { |
299 DCHECK(!extension->options_url().is_empty()); | 308 DCHECK(!extension->options_url().is_empty()); |
300 | 309 |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 CreateBackgroundHostsForProfileStartup(GetProfile(), | 824 CreateBackgroundHostsForProfileStartup(GetProfile(), |
816 this, service->extensions()); | 825 this, service->extensions()); |
817 } | 826 } |
818 break; | 827 break; |
819 } | 828 } |
820 default: | 829 default: |
821 ExtensionProcessManager::Observe(type, source, details); | 830 ExtensionProcessManager::Observe(type, source, details); |
822 break; | 831 break; |
823 } | 832 } |
824 } | 833 } |
OLD | NEW |