| 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();
|
|
|