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

Side by Side Diff: extensions/browser/process_manager.cc

Issue 570073002: Revert of Remove deprecated extension notification from ProcessManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months 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
« no previous file with comments | « extensions/browser/process_manager.h ('k') | extensions/browser/process_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "extensions/browser/process_manager.h" 5 #include "extensions/browser/process_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 ExtensionRegistry* extension_registry) 240 ExtensionRegistry* extension_registry)
241 : site_instance_(SiteInstance::Create(context)), 241 : site_instance_(SiteInstance::Create(context)),
242 extension_registry_(extension_registry), 242 extension_registry_(extension_registry),
243 startup_background_hosts_created_(false), 243 startup_background_hosts_created_(false),
244 devtools_callback_(base::Bind(&ProcessManager::OnDevToolsStateChanged, 244 devtools_callback_(base::Bind(&ProcessManager::OnDevToolsStateChanged,
245 base::Unretained(this))), 245 base::Unretained(this))),
246 last_background_close_sequence_id_(0), 246 last_background_close_sequence_id_(0),
247 weak_ptr_factory_(this) { 247 weak_ptr_factory_(this) {
248 // ExtensionRegistry is shared between incognito and regular contexts. 248 // ExtensionRegistry is shared between incognito and regular contexts.
249 DCHECK_EQ(original_context, extension_registry_->browser_context()); 249 DCHECK_EQ(original_context, extension_registry_->browser_context());
250 extension_registry_->AddObserver(this);
251 registrar_.Add(this, 250 registrar_.Add(this,
252 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED, 251 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED,
253 content::Source<BrowserContext>(original_context)); 252 content::Source<BrowserContext>(original_context));
254 registrar_.Add(this, 253 registrar_.Add(this,
254 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
255 content::Source<BrowserContext>(original_context));
256 registrar_.Add(this,
257 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
258 content::Source<BrowserContext>(original_context));
259 registrar_.Add(this,
255 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED, 260 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED,
256 content::Source<BrowserContext>(context)); 261 content::Source<BrowserContext>(context));
257 registrar_.Add(this, 262 registrar_.Add(this,
258 extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, 263 extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
259 content::Source<BrowserContext>(context)); 264 content::Source<BrowserContext>(context));
260 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 265 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
261 content::NotificationService::AllSources()); 266 content::NotificationService::AllSources());
262 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED, 267 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED,
263 content::NotificationService::AllSources()); 268 content::NotificationService::AllSources());
264 269
(...skipping 14 matching lines...) Expand all
279 event_page_suspending_time_ = 284 event_page_suspending_time_ =
280 base::TimeDelta::FromMilliseconds(suspending_time_msec); 285 base::TimeDelta::FromMilliseconds(suspending_time_msec);
281 } 286 }
282 287
283 content::DevToolsAgentHost::AddAgentStateCallback(devtools_callback_); 288 content::DevToolsAgentHost::AddAgentStateCallback(devtools_callback_);
284 289
285 OnKeepaliveImpulseCheck(); 290 OnKeepaliveImpulseCheck();
286 } 291 }
287 292
288 ProcessManager::~ProcessManager() { 293 ProcessManager::~ProcessManager() {
289 extension_registry_->RemoveObserver(this);
290 CloseBackgroundHosts(); 294 CloseBackgroundHosts();
291 DCHECK(background_hosts_.empty()); 295 DCHECK(background_hosts_.empty());
292 content::DevToolsAgentHost::RemoveAgentStateCallback(devtools_callback_); 296 content::DevToolsAgentHost::RemoveAgentStateCallback(devtools_callback_);
293 } 297 }
294 298
295 const ProcessManager::ViewSet ProcessManager::GetAllViews() const { 299 const ProcessManager::ViewSet ProcessManager::GetAllViews() const {
296 ViewSet result; 300 ViewSet result;
297 for (ExtensionRenderViews::const_iterator iter = 301 for (ExtensionRenderViews::const_iterator iter =
298 all_extension_views_.begin(); 302 all_extension_views_.begin();
299 iter != all_extension_views_.end(); ++iter) { 303 iter != all_extension_views_.end(); ++iter) {
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 const content::NotificationSource& source, 681 const content::NotificationSource& source,
678 const content::NotificationDetails& details) { 682 const content::NotificationDetails& details) {
679 switch (type) { 683 switch (type) {
680 case extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED: { 684 case extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED: {
681 // TODO(jamescook): Convert this to use ExtensionSystem::ready() instead 685 // TODO(jamescook): Convert this to use ExtensionSystem::ready() instead
682 // of a notification. 686 // of a notification.
683 MaybeCreateStartupBackgroundHosts(); 687 MaybeCreateStartupBackgroundHosts();
684 break; 688 break;
685 } 689 }
686 690
691 case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: {
692 BrowserContext* context = content::Source<BrowserContext>(source).ptr();
693 ExtensionSystem* system = ExtensionSystem::Get(context);
694 if (system->ready().is_signaled()) {
695 // The extension system is ready, so create the background host.
696 const Extension* extension =
697 content::Details<const Extension>(details).ptr();
698 CreateBackgroundHostForExtensionLoad(this, extension);
699 }
700 break;
701 }
702
703 case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: {
704 const Extension* extension =
705 content::Details<UnloadedExtensionInfo>(details)->extension;
706 for (ExtensionHostSet::iterator iter = background_hosts_.begin();
707 iter != background_hosts_.end(); ++iter) {
708 ExtensionHost* host = *iter;
709 if (host->extension_id() == extension->id()) {
710 CloseBackgroundHost(host);
711 break;
712 }
713 }
714 UnregisterExtension(extension->id());
715 break;
716 }
717
687 case extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED: { 718 case extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED: {
688 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); 719 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr();
689 if (background_hosts_.erase(host)) { 720 if (background_hosts_.erase(host)) {
690 ClearBackgroundPageData(host->extension()->id()); 721 ClearBackgroundPageData(host->extension()->id());
691 background_page_data_[host->extension()->id()].since_suspended.reset( 722 background_page_data_[host->extension()->id()].since_suspended.reset(
692 new base::ElapsedTimer()); 723 new base::ElapsedTimer());
693 } 724 }
694 break; 725 break;
695 } 726 }
696 727
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 content::Source<BrowserContext>(GetBrowserContext()), 773 content::Source<BrowserContext>(GetBrowserContext()),
743 content::Details<RenderViewHost>(contents->GetRenderViewHost())); 774 content::Details<RenderViewHost>(contents->GetRenderViewHost()));
744 break; 775 break;
745 } 776 }
746 777
747 default: 778 default:
748 NOTREACHED(); 779 NOTREACHED();
749 } 780 }
750 } 781 }
751 782
752 void ProcessManager::OnExtensionLoaded(content::BrowserContext* browser_context,
753 const extensions::Extension* extension) {
754 ExtensionSystem* system = ExtensionSystem::Get(browser_context);
755 if (system->ready().is_signaled()) {
756 // The extension system is ready, so create the background host.
757 CreateBackgroundHostForExtensionLoad(this, extension);
758 }
759 }
760
761 void ProcessManager::OnExtensionUnloaded(
762 content::BrowserContext* browser_context,
763 const extensions::Extension* extension,
764 extensions::UnloadedExtensionInfo::Reason reason) {
765 for (ExtensionHostSet::iterator iter = background_hosts_.begin();
766 iter != background_hosts_.end();
767 ++iter) {
768 ExtensionHost* host = *iter;
769 if (host->extension_id() == extension->id()) {
770 CloseBackgroundHost(host);
771 break;
772 }
773 }
774 UnregisterExtension(extension->id());
775 }
776
777 void ProcessManager::OnDevToolsStateChanged( 783 void ProcessManager::OnDevToolsStateChanged(
778 content::DevToolsAgentHost* agent_host, 784 content::DevToolsAgentHost* agent_host,
779 bool attached) { 785 bool attached) {
780 WebContents* web_contents = agent_host->GetWebContents(); 786 WebContents* web_contents = agent_host->GetWebContents();
781 // Ignore unrelated notifications. 787 // Ignore unrelated notifications.
782 if (!web_contents || web_contents->GetBrowserContext() != GetBrowserContext()) 788 if (!web_contents || web_contents->GetBrowserContext() != GetBrowserContext())
783 return; 789 return;
784 if (GetViewType(web_contents) != VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) 790 if (GetViewType(web_contents) != VIEW_TYPE_EXTENSION_BACKGROUND_PAGE)
785 return; 791 return;
786 const Extension* extension = 792 const Extension* extension =
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 SiteInstance* IncognitoProcessManager::GetSiteInstanceForURL(const GURL& url) { 945 SiteInstance* IncognitoProcessManager::GetSiteInstanceForURL(const GURL& url) {
940 const Extension* extension = 946 const Extension* extension =
941 extension_registry_->enabled_extensions().GetExtensionOrAppByURL(url); 947 extension_registry_->enabled_extensions().GetExtensionOrAppByURL(url);
942 if (extension && !IncognitoInfo::IsSplitMode(extension)) 948 if (extension && !IncognitoInfo::IsSplitMode(extension))
943 return original_manager_->GetSiteInstanceForURL(url); 949 return original_manager_->GetSiteInstanceForURL(url);
944 950
945 return ProcessManager::GetSiteInstanceForURL(url); 951 return ProcessManager::GetSiteInstanceForURL(url);
946 } 952 }
947 953
948 } // namespace extensions 954 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/process_manager.h ('k') | extensions/browser/process_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698