OLD | NEW |
---|---|
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" |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 } | 272 } |
273 | 273 |
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()->GetExtensionsService()->extensions()); |
285 break; | 285 break; |
286 } | |
286 | 287 |
287 case NotificationType::EXTENSION_LOADED: { | 288 case NotificationType::EXTENSION_LOADED: { |
288 ExtensionsService* service = | 289 const Extension* extension = Details<const Extension>(details).ptr(); |
289 Source<Profile>(source).ptr()->GetExtensionsService(); | 290 ::CreateBackgroundHost(this, extension); |
290 if (service->is_ready()) { | |
291 const Extension* extension = Details<const Extension>(details).ptr(); | |
292 ::CreateBackgroundHost(this, extension); | |
293 } | |
294 break; | 291 break; |
295 } | 292 } |
296 | 293 |
297 case NotificationType::EXTENSION_UNLOADED: { | 294 case NotificationType::EXTENSION_UNLOADED: { |
298 const Extension* extension = Details<const Extension>(details).ptr(); | 295 const Extension* extension = Details<const Extension>(details).ptr(); |
299 for (ExtensionHostSet::iterator iter = background_hosts_.begin(); | 296 for (ExtensionHostSet::iterator iter = background_hosts_.begin(); |
300 iter != background_hosts_.end(); ++iter) { | 297 iter != background_hosts_.end(); ++iter) { |
301 ExtensionHost* host = *iter; | 298 ExtensionHost* host = *iter; |
302 if (host->extension()->id() == extension->id()) { | 299 if (host->extension()->id() == extension->id()) { |
303 delete host; | 300 delete host; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
447 const NotificationDetails& details) { | 444 const NotificationDetails& details) { |
448 switch (type.value) { | 445 switch (type.value) { |
449 case NotificationType::BROWSER_WINDOW_READY: { | 446 case NotificationType::BROWSER_WINDOW_READY: { |
450 // We want to spawn our background hosts as soon as the user opens an | 447 // We want to spawn our background hosts as soon as the user opens an |
451 // incognito window. Watch for new browsers and create the hosts if | 448 // incognito window. Watch for new browsers and create the hosts if |
452 // it matches our profile. | 449 // it matches our profile. |
453 Browser* browser = Source<Browser>(source).ptr(); | 450 Browser* browser = Source<Browser>(source).ptr(); |
454 if (browser->profile() == browsing_instance_->profile()) { | 451 if (browser->profile() == browsing_instance_->profile()) { |
455 ExtensionsService* service = | 452 ExtensionsService* service = |
456 browsing_instance_->profile()->GetExtensionsService(); | 453 browsing_instance_->profile()->GetExtensionsService(); |
457 if (service && service->is_ready()) | 454 if (service) |
Aaron Boodman
2010/11/18 07:49:03
service should always exist here.
Sam Kerner (Chrome)
2010/11/18 15:34:01
Done.
| |
458 CreateBackgroundHosts(this, service->extensions()); | 455 CreateBackgroundHosts(this, service->extensions()); |
459 } | 456 } |
460 break; | 457 break; |
461 } | 458 } |
462 default: | 459 default: |
463 ExtensionProcessManager::Observe(type, source, details); | 460 ExtensionProcessManager::Observe(type, source, details); |
464 break; | 461 break; |
465 } | 462 } |
466 } | 463 } |
OLD | NEW |