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