Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: chrome/browser/extensions/extension_process_manager.cc

Issue 5730004: Rename ExtensionsService to ExtensionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/browser_window.h" 7 #include "chrome/browser/browser_window.h"
8 #include "chrome/browser/browsing_instance.h" 8 #include "chrome/browser/browsing_instance.h"
9 #if defined(OS_MACOSX) 9 #if defined(OS_MACOSX)
10 #include "chrome/browser/extensions/extension_host_mac.h" 10 #include "chrome/browser/extensions/extension_host_mac.h"
11 #endif 11 #endif
12 #include "chrome/browser/extensions/extension_host.h" 12 #include "chrome/browser/extensions/extension_host.h"
13 #include "chrome/browser/extensions/extensions_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/renderer_host/site_instance.h" 15 #include "chrome/browser/renderer_host/site_instance.h"
16 #include "chrome/browser/renderer_host/render_view_host.h" 16 #include "chrome/browser/renderer_host/render_view_host.h"
17 #include "chrome/browser/tab_contents/tab_contents.h" 17 #include "chrome/browser/tab_contents/tab_contents.h"
18 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
19 #include "chrome/common/extensions/extension.h" 19 #include "chrome/common/extensions/extension.h"
20 #include "chrome/common/extensions/extension_action.h" 20 #include "chrome/common/extensions/extension_action.h"
21 #include "chrome/common/notification_service.h" 21 #include "chrome/common/notification_service.h"
22 #include "chrome/common/notification_type.h" 22 #include "chrome/common/notification_type.h"
23 #include "chrome/common/render_messages.h" 23 #include "chrome/common/render_messages.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 host->CreateView(browser); 128 host->CreateView(browser);
129 OnExtensionHostCreated(host, false); 129 OnExtensionHostCreated(host, false);
130 return host; 130 return host;
131 } 131 }
132 132
133 ExtensionHost* ExtensionProcessManager::CreateView(const GURL& url, 133 ExtensionHost* ExtensionProcessManager::CreateView(const GURL& url,
134 Browser* browser, 134 Browser* browser,
135 ViewType::Type view_type) { 135 ViewType::Type view_type) {
136 // A NULL browser may only be given for pop-up views. 136 // A NULL browser may only be given for pop-up views.
137 DCHECK(browser || (!browser && view_type == ViewType::EXTENSION_POPUP)); 137 DCHECK(browser || (!browser && view_type == ViewType::EXTENSION_POPUP));
138 ExtensionsService* service = 138 ExtensionService* service =
139 browsing_instance_->profile()->GetExtensionsService(); 139 browsing_instance_->profile()->GetExtensionService();
140 if (service) { 140 if (service) {
141 const Extension* extension = service->GetExtensionByURL(url); 141 const Extension* extension = service->GetExtensionByURL(url);
142 if (extension) 142 if (extension)
143 return CreateView(extension, url, browser, view_type); 143 return CreateView(extension, url, browser, view_type);
144 } 144 }
145 return NULL; 145 return NULL;
146 } 146 }
147 147
148 ExtensionHost* ExtensionProcessManager::CreatePopup(const Extension* extension, 148 ExtensionHost* ExtensionProcessManager::CreatePopup(const Extension* extension,
149 const GURL& url, 149 const GURL& url,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 // Is it necessary? 219 // Is it necessary?
220 ProcessIDMap::const_iterator it = process_ids_.find(extension_id); 220 ProcessIDMap::const_iterator it = process_ids_.find(extension_id);
221 if (it != process_ids_.end() && (*it).second == process_id) 221 if (it != process_ids_.end() && (*it).second == process_id)
222 return; 222 return;
223 223
224 // Extension ids should get removed from the map before the process ids get 224 // Extension ids should get removed from the map before the process ids get
225 // reused from a dead renderer. 225 // reused from a dead renderer.
226 DCHECK(it == process_ids_.end()); 226 DCHECK(it == process_ids_.end());
227 process_ids_[extension_id] = process_id; 227 process_ids_[extension_id] = process_id;
228 228
229 ExtensionsService* extension_service = 229 ExtensionService* extension_service =
230 browsing_instance_->profile()->GetExtensionsService(); 230 browsing_instance_->profile()->GetExtensionService();
231 231
232 std::vector<std::string> page_action_ids; 232 std::vector<std::string> page_action_ids;
233 const Extension* extension = 233 const Extension* extension =
234 extension_service->GetExtensionById(extension_id, false); 234 extension_service->GetExtensionById(extension_id, false);
235 if (extension->page_action()) 235 if (extension->page_action())
236 page_action_ids.push_back(extension->page_action()->id()); 236 page_action_ids.push_back(extension->page_action()->id());
237 237
238 RenderProcessHost* rph = RenderProcessHost::FromID(process_id); 238 RenderProcessHost* rph = RenderProcessHost::FromID(process_id);
239 rph->Send(new ViewMsg_Extension_UpdatePageActions(extension_id, 239 rph->Send(new ViewMsg_Extension_UpdatePageActions(extension_id,
240 page_action_ids)); 240 page_action_ids));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 bool ExtensionProcessManager::HasExtensionHost(ExtensionHost* host) const { 274 bool ExtensionProcessManager::HasExtensionHost(ExtensionHost* host) const {
275 return all_hosts_.find(host) != all_hosts_.end(); 275 return all_hosts_.find(host) != all_hosts_.end();
276 } 276 }
277 277
278 void ExtensionProcessManager::Observe(NotificationType type, 278 void ExtensionProcessManager::Observe(NotificationType type,
279 const NotificationSource& source, 279 const NotificationSource& source,
280 const NotificationDetails& details) { 280 const NotificationDetails& details) {
281 switch (type.value) { 281 switch (type.value) {
282 case NotificationType::EXTENSIONS_READY: { 282 case NotificationType::EXTENSIONS_READY: {
283 CreateBackgroundHosts(this, 283 CreateBackgroundHosts(this,
284 Source<Profile>(source).ptr()->GetExtensionsService()->extensions()); 284 Source<Profile>(source).ptr()->GetExtensionService()->extensions());
285 break; 285 break;
286 } 286 }
287 287
288 case NotificationType::EXTENSION_LOADED: { 288 case NotificationType::EXTENSION_LOADED: {
289 ExtensionsService* service = 289 ExtensionService* service =
290 Source<Profile>(source).ptr()->GetExtensionsService(); 290 Source<Profile>(source).ptr()->GetExtensionService();
291 if (service->is_ready()) { 291 if (service->is_ready()) {
292 const Extension* extension = Details<const Extension>(details).ptr(); 292 const Extension* extension = Details<const Extension>(details).ptr();
293 ::CreateBackgroundHost(this, extension); 293 ::CreateBackgroundHost(this, extension);
294 } 294 }
295 break; 295 break;
296 } 296 }
297 297
298 case NotificationType::EXTENSION_UNLOADED: { 298 case NotificationType::EXTENSION_UNLOADED: {
299 const Extension* extension = Details<const Extension>(details).ptr(); 299 const Extension* extension = Details<const Extension>(details).ptr();
300 for (ExtensionHostSet::iterator iter = background_hosts_.begin(); 300 for (ExtensionHostSet::iterator iter = background_hosts_.begin();
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 const Extension* extension = GetExtensionOrAppByURL(url); 420 const Extension* extension = GetExtensionOrAppByURL(url);
421 if (!extension || extension->incognito_split_mode()) { 421 if (!extension || extension->incognito_split_mode()) {
422 return ExtensionProcessManager::GetExtensionProcess(url); 422 return ExtensionProcessManager::GetExtensionProcess(url);
423 } else { 423 } else {
424 return original_manager_->GetExtensionProcess(url); 424 return original_manager_->GetExtensionProcess(url);
425 } 425 }
426 } 426 }
427 427
428 const Extension* IncognitoExtensionProcessManager::GetExtensionOrAppByURL( 428 const Extension* IncognitoExtensionProcessManager::GetExtensionOrAppByURL(
429 const GURL& url) { 429 const GURL& url) {
430 ExtensionsService* service = 430 ExtensionService* service =
431 browsing_instance_->profile()->GetExtensionsService(); 431 browsing_instance_->profile()->GetExtensionService();
432 if (!service) 432 if (!service)
433 return NULL; 433 return NULL;
434 return (url.SchemeIs(chrome::kExtensionScheme)) ? 434 return (url.SchemeIs(chrome::kExtensionScheme)) ?
435 service->GetExtensionByURL(url) : service->GetExtensionByWebExtent(url); 435 service->GetExtensionByURL(url) : service->GetExtensionByWebExtent(url);
436 } 436 }
437 437
438 bool IncognitoExtensionProcessManager::IsIncognitoEnabled( 438 bool IncognitoExtensionProcessManager::IsIncognitoEnabled(
439 const Extension* extension) { 439 const Extension* extension) {
440 ExtensionsService* service = 440 ExtensionService* service =
441 browsing_instance_->profile()->GetExtensionsService(); 441 browsing_instance_->profile()->GetExtensionService();
442 return service && service->IsIncognitoEnabled(extension); 442 return service && service->IsIncognitoEnabled(extension);
443 } 443 }
444 444
445 void IncognitoExtensionProcessManager::Observe( 445 void IncognitoExtensionProcessManager::Observe(
446 NotificationType type, 446 NotificationType type,
447 const NotificationSource& source, 447 const NotificationSource& source,
448 const NotificationDetails& details) { 448 const NotificationDetails& details) {
449 switch (type.value) { 449 switch (type.value) {
450 case NotificationType::BROWSER_WINDOW_READY: { 450 case NotificationType::BROWSER_WINDOW_READY: {
451 // We want to spawn our background hosts as soon as the user opens an 451 // We want to spawn our background hosts as soon as the user opens an
452 // incognito window. Watch for new browsers and create the hosts if 452 // incognito window. Watch for new browsers and create the hosts if
453 // it matches our profile. 453 // it matches our profile.
454 Browser* browser = Source<Browser>(source).ptr(); 454 Browser* browser = Source<Browser>(source).ptr();
455 if (browser->profile() == browsing_instance_->profile()) { 455 if (browser->profile() == browsing_instance_->profile()) {
456 // On Chrome OS, a login screen is implemented as a browser. 456 // On Chrome OS, a login screen is implemented as a browser.
457 // This browser has no extension service. In this case, 457 // This browser has no extension service. In this case,
458 // service will be NULL. 458 // service will be NULL.
459 ExtensionsService* service = 459 ExtensionService* service =
460 browsing_instance_->profile()->GetExtensionsService(); 460 browsing_instance_->profile()->GetExtensionService();
461 if (service && service->is_ready()) 461 if (service && service->is_ready())
462 CreateBackgroundHosts(this, service->extensions()); 462 CreateBackgroundHosts(this, service->extensions());
463 } 463 }
464 break; 464 break;
465 } 465 }
466 default: 466 default:
467 ExtensionProcessManager::Observe(type, source, details); 467 ExtensionProcessManager::Observe(type, source, details);
468 break; 468 break;
469 } 469 }
470 } 470 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_page_actions_module.cc ('k') | chrome/browser/extensions/extension_proxy_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698