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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "chrome/browser/extensions/extension_process_manager.h" | 7 #include "chrome/browser/extensions/extension_process_manager.h" |
8 | 8 |
9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
10 #include "content/browser/browsing_instance.h" | 10 #include "content/browser/browsing_instance.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // | 90 // |
91 | 91 |
92 // static | 92 // static |
93 ExtensionProcessManager* ExtensionProcessManager::Create(Profile* profile) { | 93 ExtensionProcessManager* ExtensionProcessManager::Create(Profile* profile) { |
94 return (profile->IsOffTheRecord()) ? | 94 return (profile->IsOffTheRecord()) ? |
95 new IncognitoExtensionProcessManager(profile) : | 95 new IncognitoExtensionProcessManager(profile) : |
96 new ExtensionProcessManager(profile); | 96 new ExtensionProcessManager(profile); |
97 } | 97 } |
98 | 98 |
99 ExtensionProcessManager::ExtensionProcessManager(Profile* profile) | 99 ExtensionProcessManager::ExtensionProcessManager(Profile* profile) |
100 : browsing_instance_(new BrowsingInstance(profile)) { | 100 : browsing_instance_(new BrowsingInstance(profile)), |
| 101 profile_(profile) { |
101 Profile* original_profile = profile->GetOriginalProfile(); | 102 Profile* original_profile = profile->GetOriginalProfile(); |
102 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, | 103 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, |
103 content::Source<Profile>(original_profile)); | 104 content::Source<Profile>(original_profile)); |
104 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 105 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
105 content::Source<Profile>(original_profile)); | 106 content::Source<Profile>(original_profile)); |
106 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 107 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
107 content::Source<Profile>(original_profile)); | 108 content::Source<Profile>(original_profile)); |
108 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | 109 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
109 content::Source<Profile>(profile)); | 110 content::Source<Profile>(profile)); |
110 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, | 111 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 | 530 |
530 void ExtensionProcessManager::OnExtensionHostCreated(ExtensionHost* host, | 531 void ExtensionProcessManager::OnExtensionHostCreated(ExtensionHost* host, |
531 bool is_background) { | 532 bool is_background) { |
532 DCHECK_EQ(browsing_instance_->browser_context(), host->profile()); | 533 DCHECK_EQ(browsing_instance_->browser_context(), host->profile()); |
533 | 534 |
534 all_hosts_.insert(host); | 535 all_hosts_.insert(host); |
535 if (is_background) | 536 if (is_background) |
536 background_hosts_.insert(host); | 537 background_hosts_.insert(host); |
537 content::NotificationService::current()->Notify( | 538 content::NotificationService::current()->Notify( |
538 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, | 539 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, |
539 content::Source<ExtensionProcessManager>(this), | 540 content::Source<Profile>(profile_), |
540 content::Details<ExtensionHost>(host)); | 541 content::Details<ExtensionHost>(host)); |
541 } | 542 } |
542 | 543 |
543 void ExtensionProcessManager::CloseBackgroundHost(ExtensionHost* host) { | 544 void ExtensionProcessManager::CloseBackgroundHost(ExtensionHost* host) { |
544 CHECK(host->extension_host_type() == | 545 CHECK(host->extension_host_type() == |
545 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); | 546 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); |
546 delete host; | 547 delete host; |
547 // |host| should deregister itself from our structures. | 548 // |host| should deregister itself from our structures. |
548 CHECK(background_hosts_.find(host) == background_hosts_.end()); | 549 CHECK(background_hosts_.find(host) == background_hosts_.end()); |
549 } | 550 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 if (service && service->is_ready()) | 678 if (service && service->is_ready()) |
678 CreateBackgroundHostsForProfileStartup(this, service->extensions()); | 679 CreateBackgroundHostsForProfileStartup(this, service->extensions()); |
679 } | 680 } |
680 break; | 681 break; |
681 } | 682 } |
682 default: | 683 default: |
683 ExtensionProcessManager::Observe(type, source, details); | 684 ExtensionProcessManager::Observe(type, source, details); |
684 break; | 685 break; |
685 } | 686 } |
686 } | 687 } |
OLD | NEW |