summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_shelf.cc
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-20 20:47:25 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-20 20:47:25 +0000
commit6d7c8059b0b3c9e5f079bb8f0569b0de6a115330 (patch)
tree93b51fcbae522fdd93b0d8031922ab131a9eb2ac /chrome/browser/extensions/extension_shelf.cc
parentb674dc73f0b635aa2f7be660153e5b05f6a9b593 (diff)
downloadchromium_src-6d7c8059b0b3c9e5f079bb8f0569b0de6a115330.zip
chromium_src-6d7c8059b0b3c9e5f079bb8f0569b0de6a115330.tar.gz
chromium_src-6d7c8059b0b3c9e5f079bb8f0569b0de6a115330.tar.bz2
Hook up more of extension uninstall.
Also removed all external dependencies from ExtensionsService. It now only sends out notifications, which other services consume. This should allow us to unit test the ExtensionsService frontend, but I haven't added that yet. Review URL: http://codereview.chromium.org/113493 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16529 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_shelf.cc')
-rw-r--r--chrome/browser/extensions/extension_shelf.cc43
1 files changed, 32 insertions, 11 deletions
diff --git a/chrome/browser/extensions/extension_shelf.cc b/chrome/browser/extensions/extension_shelf.cc
index 17623b6..445f181e 100644
--- a/chrome/browser/extensions/extension_shelf.cc
+++ b/chrome/browser/extensions/extension_shelf.cc
@@ -145,11 +145,11 @@ ExtensionShelf::ExtensionShelf(Browser* browser)
handle_visible_(false),
current_handle_view_(NULL),
ALLOW_THIS_IN_INITIALIZER_LIST(timer_factory_(this)) {
- // Watch extensions loaded notification.
- NotificationService* ns = NotificationService::current();
- Source<Profile> ns_source(browser->profile()->GetOriginalProfile());
- ns->AddObserver(this, NotificationType::EXTENSIONS_LOADED,
- NotificationService::AllSources());
+ // Watch extensions loaded and unloaded notifications.
+ registrar_.Add(this, NotificationType::EXTENSIONS_LOADED,
+ NotificationService::AllSources());
+ registrar_.Add(this, NotificationType::EXTENSION_UNLOADED,
+ NotificationService::AllSources());
// Add any already-loaded extensions now, since we missed the notification for
// those.
@@ -162,12 +162,6 @@ ExtensionShelf::ExtensionShelf(Browser* browser)
}
}
-ExtensionShelf::~ExtensionShelf() {
- NotificationService* ns = NotificationService::current();
- ns->RemoveObserver(this, NotificationType::EXTENSIONS_LOADED,
- NotificationService::AllSources());
-}
-
BrowserBubble* ExtensionShelf::GetHandle() {
if (!handle_.get() && HasExtensionViews() && current_handle_view_) {
ExtensionShelfHandle* handle_view = new ExtensionShelfHandle(this);
@@ -271,6 +265,11 @@ void ExtensionShelf::Observe(NotificationType type,
AddExtensionViews(extensions);
break;
}
+ case NotificationType::EXTENSION_UNLOADED: {
+ Extension* extension = Details<Extension>(details).ptr();
+ RemoveExtensionViews(extension);
+ break;
+ }
default:
DCHECK(false) << "Unhandled notification of type: " << type.value;
break;
@@ -306,6 +305,28 @@ bool ExtensionShelf::AddExtensionViews(const ExtensionList* extensions) {
return added_toolstrip;
}
+bool ExtensionShelf::RemoveExtensionViews(Extension* extension) {
+ if (!HasExtensionViews())
+ return false;
+
+ bool removed_toolstrip = false;
+ int count = GetChildViewCount();
+ for (int i = count - 1; i >= 0; --i) {
+ ExtensionView* view = static_cast<ExtensionView*>(GetChildViewAt(i));
+ if (view->host()->extension()->id() == extension->id()) {
+ RemoveChildView(view);
+ delete view;
+ removed_toolstrip = true;
+ }
+ }
+
+ if (removed_toolstrip) {
+ SchedulePaint();
+ PreferredSizeChanged();
+ }
+ return removed_toolstrip;
+}
+
bool ExtensionShelf::HasExtensionViews() {
return GetChildViewCount() > 0;
}