| 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 "chrome/browser/extensions/base_extension_host.h" |
| 8 #include "chrome/browser/extensions/extension_event_router.h" | 9 #include "chrome/browser/extensions/extension_event_router.h" |
| 9 #include "chrome/browser/extensions/extension_process_manager.h" | 10 #include "chrome/browser/extensions/extension_process_manager.h" |
| 10 #include "chrome/browser/extensions/extension_host.h" | 11 #include "chrome/browser/extensions/extension_host.h" |
| 11 #include "chrome/browser/extensions/extension_info_map.h" | 12 #include "chrome/browser/extensions/extension_info_map.h" |
| 12 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/browser/extensions/platform_app_host.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 16 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
| 17 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/common/chrome_view_type.h" | 20 #include "chrome/common/chrome_view_type.h" |
| 19 #include "chrome/common/extensions/extension.h" | 21 #include "chrome/common/extensions/extension.h" |
| 20 #include "chrome/common/extensions/extension_messages.h" | 22 #include "chrome/common/extensions/extension_messages.h" |
| 21 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| 22 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 content::Source<content::BrowserContext>(profile)); | 143 content::Source<content::BrowserContext>(profile)); |
| 142 registrar_.Add(this, content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING, | 144 registrar_.Add(this, content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING, |
| 143 content::Source<content::BrowserContext>(profile)); | 145 content::Source<content::BrowserContext>(profile)); |
| 144 } | 146 } |
| 145 | 147 |
| 146 ExtensionProcessManager::~ExtensionProcessManager() { | 148 ExtensionProcessManager::~ExtensionProcessManager() { |
| 147 CloseBackgroundHosts(); | 149 CloseBackgroundHosts(); |
| 148 DCHECK(background_hosts_.empty()); | 150 DCHECK(background_hosts_.empty()); |
| 149 } | 151 } |
| 150 | 152 |
| 151 ExtensionHost* ExtensionProcessManager::CreateShellHost( | |
| 152 const Extension* extension, | |
| 153 const GURL& url) { | |
| 154 DCHECK(extension); | |
| 155 ExtensionHost* host = new ExtensionHost(extension, | |
| 156 GetSiteInstanceForURL(url), | |
| 157 url, | |
| 158 chrome::VIEW_TYPE_APP_SHELL); | |
| 159 host->CreateViewWithoutBrowser(); | |
| 160 content::WebContents* host_contents = host->host_contents(); | |
| 161 host_contents->GetMutableRendererPrefs()->browser_handles_all_requests = true; | |
| 162 host_contents->GetRenderViewHost()->SyncRendererPrefs(); | |
| 163 OnExtensionHostCreated(host, false /* not a background host */); | |
| 164 return host; | |
| 165 } | |
| 166 | |
| 167 void ExtensionProcessManager::EnsureBrowserWhenRequired( | 153 void ExtensionProcessManager::EnsureBrowserWhenRequired( |
| 168 Browser* browser, | 154 Browser* browser, |
| 169 content::ViewType view_type) { | 155 content::ViewType view_type) { |
| 170 if (!browser) { | 156 if (!browser) { |
| 171 #if defined (OS_CHROMEOS) | 157 #if defined (OS_CHROMEOS) |
| 172 // On ChromeOS we'll only use ExtensionView, which | 158 // On ChromeOS we'll only use ExtensionView, which |
| 173 // does not use the browser parameter. | 159 // does not use the browser parameter. |
| 174 // TODO(rkc): Remove all this once we create a new host for | 160 // TODO(rkc): Remove all this once we create a new host for |
| 175 // screensaver extensions (crosbug.com/28211). | 161 // screensaver extensions (crosbug.com/28211). |
| 176 DCHECK(view_type == chrome::VIEW_TYPE_EXTENSION_POPUP || | 162 DCHECK(view_type == chrome::VIEW_TYPE_EXTENSION_POPUP || |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 if (service && service->is_ready()) | 671 if (service && service->is_ready()) |
| 686 CreateBackgroundHostsForProfileStartup(this, service->extensions()); | 672 CreateBackgroundHostsForProfileStartup(this, service->extensions()); |
| 687 } | 673 } |
| 688 break; | 674 break; |
| 689 } | 675 } |
| 690 default: | 676 default: |
| 691 ExtensionProcessManager::Observe(type, source, details); | 677 ExtensionProcessManager::Observe(type, source, details); |
| 692 break; | 678 break; |
| 693 } | 679 } |
| 694 } | 680 } |
| OLD | NEW |