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

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

Issue 566863002: Remove deprecated extension notification from ProcessManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the errors for untitest 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);
250 registrar_.Add(this, 251 registrar_.Add(this,
251 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED, 252 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED,
252 content::Source<BrowserContext>(original_context)); 253 content::Source<BrowserContext>(original_context));
253 registrar_.Add(this, 254 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,
260 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED, 255 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED,
261 content::Source<BrowserContext>(context)); 256 content::Source<BrowserContext>(context));
262 registrar_.Add(this, 257 registrar_.Add(this,
263 extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, 258 extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
264 content::Source<BrowserContext>(context)); 259 content::Source<BrowserContext>(context));
265 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 260 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
266 content::NotificationService::AllSources()); 261 content::NotificationService::AllSources());
267 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED, 262 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED,
268 content::NotificationService::AllSources()); 263 content::NotificationService::AllSources());
269 264
(...skipping 14 matching lines...) Expand all
284 event_page_suspending_time_ = 279 event_page_suspending_time_ =
285 base::TimeDelta::FromMilliseconds(suspending_time_msec); 280 base::TimeDelta::FromMilliseconds(suspending_time_msec);
286 } 281 }
287 282
288 content::DevToolsAgentHost::AddAgentStateCallback(devtools_callback_); 283 content::DevToolsAgentHost::AddAgentStateCallback(devtools_callback_);
289 284
290 OnKeepaliveImpulseCheck(); 285 OnKeepaliveImpulseCheck();
291 } 286 }
292 287
293 ProcessManager::~ProcessManager() { 288 ProcessManager::~ProcessManager() {
289 extension_registry_->RemoveObserver(this);
294 CloseBackgroundHosts(); 290 CloseBackgroundHosts();
295 DCHECK(background_hosts_.empty()); 291 DCHECK(background_hosts_.empty());
296 content::DevToolsAgentHost::RemoveAgentStateCallback(devtools_callback_); 292 content::DevToolsAgentHost::RemoveAgentStateCallback(devtools_callback_);
297 } 293 }
298 294
299 const ProcessManager::ViewSet ProcessManager::GetAllViews() const { 295 const ProcessManager::ViewSet ProcessManager::GetAllViews() const {
300 ViewSet result; 296 ViewSet result;
301 for (ExtensionRenderViews::const_iterator iter = 297 for (ExtensionRenderViews::const_iterator iter =
302 all_extension_views_.begin(); 298 all_extension_views_.begin();
303 iter != all_extension_views_.end(); ++iter) { 299 iter != all_extension_views_.end(); ++iter) {
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 const content::NotificationSource& source, 677 const content::NotificationSource& source,
682 const content::NotificationDetails& details) { 678 const content::NotificationDetails& details) {
683 switch (type) { 679 switch (type) {
684 case extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED: { 680 case extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED: {
685 // TODO(jamescook): Convert this to use ExtensionSystem::ready() instead 681 // TODO(jamescook): Convert this to use ExtensionSystem::ready() instead
686 // of a notification. 682 // of a notification.
687 MaybeCreateStartupBackgroundHosts(); 683 MaybeCreateStartupBackgroundHosts();
688 break; 684 break;
689 } 685 }
690 686
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
718 case extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED: { 687 case extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED: {
719 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); 688 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr();
720 if (background_hosts_.erase(host)) { 689 if (background_hosts_.erase(host)) {
721 ClearBackgroundPageData(host->extension()->id()); 690 ClearBackgroundPageData(host->extension()->id());
722 background_page_data_[host->extension()->id()].since_suspended.reset( 691 background_page_data_[host->extension()->id()].since_suspended.reset(
723 new base::ElapsedTimer()); 692 new base::ElapsedTimer());
724 } 693 }
725 break; 694 break;
726 } 695 }
727 696
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 content::Source<BrowserContext>(GetBrowserContext()), 742 content::Source<BrowserContext>(GetBrowserContext()),
774 content::Details<RenderViewHost>(contents->GetRenderViewHost())); 743 content::Details<RenderViewHost>(contents->GetRenderViewHost()));
775 break; 744 break;
776 } 745 }
777 746
778 default: 747 default:
779 NOTREACHED(); 748 NOTREACHED();
780 } 749 }
781 } 750 }
782 751
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
783 void ProcessManager::OnDevToolsStateChanged( 777 void ProcessManager::OnDevToolsStateChanged(
784 content::DevToolsAgentHost* agent_host, 778 content::DevToolsAgentHost* agent_host,
785 bool attached) { 779 bool attached) {
786 WebContents* web_contents = agent_host->GetWebContents(); 780 WebContents* web_contents = agent_host->GetWebContents();
787 // Ignore unrelated notifications. 781 // Ignore unrelated notifications.
788 if (!web_contents || web_contents->GetBrowserContext() != GetBrowserContext()) 782 if (!web_contents || web_contents->GetBrowserContext() != GetBrowserContext())
789 return; 783 return;
790 if (GetViewType(web_contents) != VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) 784 if (GetViewType(web_contents) != VIEW_TYPE_EXTENSION_BACKGROUND_PAGE)
791 return; 785 return;
792 const Extension* extension = 786 const Extension* extension =
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 SiteInstance* IncognitoProcessManager::GetSiteInstanceForURL(const GURL& url) { 939 SiteInstance* IncognitoProcessManager::GetSiteInstanceForURL(const GURL& url) {
946 const Extension* extension = 940 const Extension* extension =
947 extension_registry_->enabled_extensions().GetExtensionOrAppByURL(url); 941 extension_registry_->enabled_extensions().GetExtensionOrAppByURL(url);
948 if (extension && !IncognitoInfo::IsSplitMode(extension)) 942 if (extension && !IncognitoInfo::IsSplitMode(extension))
949 return original_manager_->GetSiteInstanceForURL(url); 943 return original_manager_->GetSiteInstanceForURL(url);
950 944
951 return ProcessManager::GetSiteInstanceForURL(url); 945 return ProcessManager::GetSiteInstanceForURL(url);
952 } 946 }
953 947
954 } // namespace extensions 948 } // 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