OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "chrome/browser/extensions/extension_process_manager.h" | 6 #include "chrome/browser/extensions/extension_process_manager.h" |
7 | 7 |
8 #include "chrome/browser/ui/browser_window.h" | 8 #include "chrome/browser/ui/browser_window.h" |
9 #include "content/browser/browsing_instance.h" | 9 #include "content/browser/browsing_instance.h" |
10 #if defined(OS_MACOSX) | 10 #if defined(OS_MACOSX) |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 : browsing_instance_(new BrowsingInstance(profile)) { | 93 : browsing_instance_(new BrowsingInstance(profile)) { |
94 Profile* original_profile = profile->GetOriginalProfile(); | 94 Profile* original_profile = profile->GetOriginalProfile(); |
95 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, | 95 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, |
96 Source<Profile>(original_profile)); | 96 Source<Profile>(original_profile)); |
97 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 97 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
98 Source<Profile>(original_profile)); | 98 Source<Profile>(original_profile)); |
99 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 99 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
100 Source<Profile>(original_profile)); | 100 Source<Profile>(original_profile)); |
101 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | 101 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
102 Source<Profile>(profile)); | 102 Source<Profile>(profile)); |
103 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, | |
104 Source<Profile>(profile)); | |
103 // We can listen to everything for SITE_INSTANCE_DELETED because we check the | 105 // We can listen to everything for SITE_INSTANCE_DELETED because we check the |
104 // |site_instance_id| in UnregisterExtensionSiteInstance. | 106 // |site_instance_id| in UnregisterExtensionSiteInstance. |
105 registrar_.Add(this, content::NOTIFICATION_SITE_INSTANCE_DELETED, | 107 registrar_.Add(this, content::NOTIFICATION_SITE_INSTANCE_DELETED, |
106 NotificationService::AllBrowserContextsAndSources()); | 108 NotificationService::AllBrowserContextsAndSources()); |
107 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, | 109 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, |
108 NotificationService::AllSources()); | 110 NotificationService::AllSources()); |
109 } | 111 } |
110 | 112 |
111 ExtensionProcessManager::~ExtensionProcessManager() { | 113 ExtensionProcessManager::~ExtensionProcessManager() { |
112 VLOG_IF(1, g_log_bug53991) << "~ExtensionProcessManager: " << this; | 114 VLOG_IF(1, g_log_bug53991) << "~ExtensionProcessManager: " << this; |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
329 background_hosts_.erase(host); | 331 background_hosts_.erase(host); |
330 break; | 332 break; |
331 } | 333 } |
332 | 334 |
333 case content::NOTIFICATION_SITE_INSTANCE_DELETED: { | 335 case content::NOTIFICATION_SITE_INSTANCE_DELETED: { |
334 SiteInstance* site_instance = Source<SiteInstance>(source).ptr(); | 336 SiteInstance* site_instance = Source<SiteInstance>(source).ptr(); |
335 UnregisterExtensionSiteInstance(site_instance->id()); | 337 UnregisterExtensionSiteInstance(site_instance->id()); |
336 break; | 338 break; |
337 } | 339 } |
338 | 340 |
341 case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: { | |
342 ExtensionHost* host = Details<ExtensionHost>(details).ptr(); | |
343 if (host->extension_host_type() == ViewType::EXTENSION_BACKGROUND_PAGE) { | |
344 delete host; | |
345 // |host| should deregister itself from our structures. | |
346 DCHECK(background_hosts_.find(host) == background_hosts_.end()); | |
Aaron Boodman
2011/09/06 19:47:04
Don't be a wuss! CHECK
Tessa MacDuff
2011/09/07 00:59:21
I'm no wuss! Done!
| |
347 } | |
348 break; | |
349 } | |
350 | |
339 case content::NOTIFICATION_APP_TERMINATING: { | 351 case content::NOTIFICATION_APP_TERMINATING: { |
340 // Close background hosts when the last browser is closed so that they | 352 // Close background hosts when the last browser is closed so that they |
341 // have time to shutdown various objects on different threads. Our | 353 // have time to shutdown various objects on different threads. Our |
342 // destructor is called too late in the shutdown sequence. | 354 // destructor is called too late in the shutdown sequence. |
343 CloseBackgroundHosts(); | 355 CloseBackgroundHosts(); |
344 break; | 356 break; |
345 } | 357 } |
346 | 358 |
347 default: | 359 default: |
348 NOTREACHED(); | 360 NOTREACHED(); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 if (service && service->is_ready()) | 503 if (service && service->is_ready()) |
492 CreateBackgroundHostsForProfileStartup(this, service->extensions()); | 504 CreateBackgroundHostsForProfileStartup(this, service->extensions()); |
493 } | 505 } |
494 break; | 506 break; |
495 } | 507 } |
496 default: | 508 default: |
497 ExtensionProcessManager::Observe(type, source, details); | 509 ExtensionProcessManager::Observe(type, source, details); |
498 break; | 510 break; |
499 } | 511 } |
500 } | 512 } |
OLD | NEW |