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

Unified Diff: chrome/browser/extensions/extension_toolbar_model.cc

Issue 259843004: Remove some NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED from c/b/extensions Part2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comment Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_toolbar_model.cc
diff --git a/chrome/browser/extensions/extension_toolbar_model.cc b/chrome/browser/extensions/extension_toolbar_model.cc
index 3bd6c3d0e2a501e12ae3098c5bfb15fa4fd9ffda..90c065a53afcacc1fa326f4b6ebc0db386869f09 100644
--- a/chrome/browser/extensions/extension_toolbar_model.cc
+++ b/chrome/browser/extensions/extension_toolbar_model.cc
@@ -26,6 +26,7 @@
#include "content/public/browser/notification_source.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_prefs.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/pref_names.h"
#include "extensions/common/extension.h"
@@ -47,12 +48,10 @@ ExtensionToolbarModel::ExtensionToolbarModel(
prefs_(profile_->GetPrefs()),
extensions_initialized_(false),
is_highlighting_(false),
+ extension_registry_observer_(this),
weak_ptr_factory_(this) {
- registrar_.Add(this,
- chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
- content::Source<Profile>(profile_));
- registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
- content::Source<Profile>(profile_));
+ extension_registry_observer_.Add(ExtensionRegistry::Get(profile_));
+
registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY,
content::Source<Profile>(profile_));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
@@ -180,6 +179,29 @@ void ExtensionToolbarModel::SetVisibleIconCount(int count) {
}
}
+void ExtensionToolbarModel::OnExtensionLoaded(
+ content::BrowserContext* browser_context,
+ const Extension* extension) {
+ // We don't want to add the same extension twice. It may have already been
+ // added by EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED below, if the user
+ // hides the browser action and then disables and enables the extension.
+ for (size_t i = 0; i < toolbar_items_.size(); i++) {
+ if (toolbar_items_[i].get() == extension)
+ return;
+ }
+ if (ExtensionActionAPI::GetBrowserActionVisibility(extension_prefs_,
+ extension->id())) {
+ AddExtension(extension);
+ }
+}
+
+void ExtensionToolbarModel::OnExtensionUnloaded(
+ content::BrowserContext* browser_context,
+ const Extension* extension,
+ UnloadedExtensionInfo::Reason reason) {
+ RemoveExtension(extension);
+}
+
void ExtensionToolbarModel::Observe(
int type,
const content::NotificationSource& source,
@@ -194,29 +216,6 @@ void ExtensionToolbarModel::Observe(
case chrome::NOTIFICATION_EXTENSIONS_READY:
InitializeExtensionList(extension_service);
break;
- case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: {
- const Extension* extension =
- content::Details<const Extension>(details).ptr();
- // We don't want to add the same extension twice. It may have already been
- // added by EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED below, if the user
- // hides the browser action and then disables and enables the extension.
- for (size_t i = 0; i < toolbar_items_.size(); i++) {
- if (toolbar_items_[i].get() == extension)
- return; // Already exists.
- }
- if (ExtensionActionAPI::GetBrowserActionVisibility(extension_prefs_,
- extension->id())) {
- AddExtension(extension);
- }
- break;
- }
- case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: {
- const Extension* extension =
- content::Details<extensions::UnloadedExtensionInfo>(details)
- ->extension;
- RemoveExtension(extension);
- break;
- }
case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: {
const Extension* extension =
content::Details<const Extension>(details).ptr();
« no previous file with comments | « chrome/browser/extensions/extension_toolbar_model.h ('k') | chrome/browser/extensions/external_install_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698