| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/extensions/extension_process_manager.h" | 5 #include "chrome/browser/extensions/extension_process_manager.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browsing_instance.h" | 7 #include "chrome/browser/browsing_instance.h" |
| 8 #include "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
| 9 #include "chrome/browser/extensions/extensions_service.h" | 9 #include "chrome/browser/extensions/extensions_service.h" |
| 10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 for (iter = to_delete.begin(); iter != to_delete.end(); ++iter) | 49 for (iter = to_delete.begin(); iter != to_delete.end(); ++iter) |
| 50 delete *iter; | 50 delete *iter; |
| 51 } | 51 } |
| 52 | 52 |
| 53 ExtensionHost* ExtensionProcessManager::CreateView(Extension* extension, | 53 ExtensionHost* ExtensionProcessManager::CreateView(Extension* extension, |
| 54 const GURL& url, | 54 const GURL& url, |
| 55 Browser* browser) { | 55 Browser* browser) { |
| 56 DCHECK(extension); | 56 DCHECK(extension); |
| 57 DCHECK(browser); | 57 DCHECK(browser); |
| 58 ExtensionHost* host = | 58 ExtensionHost* host = |
| 59 new ExtensionHost(extension, GetSiteInstanceForURL(url), url); | 59 new ExtensionHost(extension, GetSiteInstanceForURL(url), url, |
| 60 ViewType::EXTENSION_TOOLSTRIP); |
| 60 host->CreateView(browser); | 61 host->CreateView(browser); |
| 61 OnExtensionHostCreated(host, false); | 62 OnExtensionHostCreated(host, false); |
| 62 return host; | 63 return host; |
| 63 } | 64 } |
| 64 | 65 |
| 65 ExtensionHost* ExtensionProcessManager::CreateView(const GURL& url, | 66 ExtensionHost* ExtensionProcessManager::CreateView(const GURL& url, |
| 66 Browser* browser) { | 67 Browser* browser) { |
| 67 DCHECK(browser); | 68 DCHECK(browser); |
| 68 ExtensionsService* service = | 69 ExtensionsService* service = |
| 69 browsing_instance_->profile()->GetExtensionsService(); | 70 browsing_instance_->profile()->GetExtensionsService(); |
| 70 if (service) { | 71 if (service) { |
| 71 Extension* extension = service->GetExtensionByURL(url); | 72 Extension* extension = service->GetExtensionByURL(url); |
| 72 if (extension) | 73 if (extension) |
| 73 return CreateView(extension, url, browser); | 74 return CreateView(extension, url, browser); |
| 74 } | 75 } |
| 75 return NULL; | 76 return NULL; |
| 76 } | 77 } |
| 77 | 78 |
| 78 ExtensionHost* ExtensionProcessManager::CreateBackgroundHost( | 79 ExtensionHost* ExtensionProcessManager::CreateBackgroundHost( |
| 79 Extension* extension, const GURL& url) { | 80 Extension* extension, const GURL& url) { |
| 80 ExtensionHost* host = | 81 ExtensionHost* host = |
| 81 new ExtensionHost(extension, GetSiteInstanceForURL(url), url); | 82 new ExtensionHost(extension, GetSiteInstanceForURL(url), url, |
| 83 ViewType::EXTENSION_BACKGROUND_PAGE); |
| 82 host->CreateRenderView(NULL); // create a RenderViewHost with no view | 84 host->CreateRenderView(NULL); // create a RenderViewHost with no view |
| 83 OnExtensionHostCreated(host, true); | 85 OnExtensionHostCreated(host, true); |
| 84 return host; | 86 return host; |
| 85 } | 87 } |
| 86 | 88 |
| 87 void ExtensionProcessManager::RegisterExtensionProcess( | 89 void ExtensionProcessManager::RegisterExtensionProcess( |
| 88 const std::string& extension_id, int process_id) { | 90 const std::string& extension_id, int process_id) { |
| 89 ProcessIDMap::const_iterator it = process_ids_.find(extension_id); | 91 ProcessIDMap::const_iterator it = process_ids_.find(extension_id); |
| 90 if (it != process_ids_.end() && (*it).second == process_id) | 92 if (it != process_ids_.end() && (*it).second == process_id) |
| 91 return; | 93 return; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 void ExtensionProcessManager::OnExtensionHostCreated(ExtensionHost* host, | 192 void ExtensionProcessManager::OnExtensionHostCreated(ExtensionHost* host, |
| 191 bool is_background) { | 193 bool is_background) { |
| 192 all_hosts_.insert(host); | 194 all_hosts_.insert(host); |
| 193 if (is_background) | 195 if (is_background) |
| 194 background_hosts_.insert(host); | 196 background_hosts_.insert(host); |
| 195 NotificationService::current()->Notify( | 197 NotificationService::current()->Notify( |
| 196 NotificationType::EXTENSION_HOST_CREATED, | 198 NotificationType::EXTENSION_HOST_CREATED, |
| 197 Source<ExtensionProcessManager>(this), | 199 Source<ExtensionProcessManager>(this), |
| 198 Details<ExtensionHost>(host)); | 200 Details<ExtensionHost>(host)); |
| 199 } | 201 } |
| OLD | NEW |