Commit 488949b7 authored by limasdf@gmail.com's avatar limasdf@gmail.com

Use ExtensionRegistryObserver instead of deprecated extension notification from c/b/extension

alarm, commands, declartive, storage api and extension_gcm_app_handler.

Also, removed unwanted extension:: namespace prefix.

R=rdevlin.cronin@chromium.org
BUG=376293

Review URL: https://codereview.chromium.org/299393002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273829 0039d316-1c4b-4281-b951-d872f2087c98
parent c89af887
...@@ -13,11 +13,9 @@ ...@@ -13,11 +13,9 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "base/value_conversions.h" #include "base/value_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/state_store.h" #include "chrome/browser/extensions/state_store.h"
#include "chrome/common/extensions/api/alarms.h" #include "chrome/common/extensions/api/alarms.h"
#include "content/public/browser/notification_service.h"
#include "extensions/browser/event_router.h" #include "extensions/browser/event_router.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h" #include "extensions/browser/extension_system.h"
...@@ -91,7 +89,6 @@ scoped_ptr<base::ListValue> AlarmsToValue(const std::vector<Alarm>& alarms) { ...@@ -91,7 +89,6 @@ scoped_ptr<base::ListValue> AlarmsToValue(const std::vector<Alarm>& alarms) {
return list.Pass(); return list.Pass();
} }
} // namespace } // namespace
// AlarmManager // AlarmManager
...@@ -102,9 +99,6 @@ AlarmManager::AlarmManager(content::BrowserContext* context) ...@@ -102,9 +99,6 @@ AlarmManager::AlarmManager(content::BrowserContext* context)
delegate_(new DefaultAlarmDelegate(context)), delegate_(new DefaultAlarmDelegate(context)),
extension_registry_observer_(this) { extension_registry_observer_(this) {
extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context_)); extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context_));
registrar_.Add(this,
chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED,
content::Source<content::BrowserContext>(browser_context_));
StateStore* storage = ExtensionSystem::Get(browser_context_)->state_store(); StateStore* storage = ExtensionSystem::Get(browser_context_)->state_store();
if (storage) if (storage)
...@@ -423,12 +417,9 @@ void AlarmManager::OnExtensionLoaded(content::BrowserContext* browser_context, ...@@ -423,12 +417,9 @@ void AlarmManager::OnExtensionLoaded(content::BrowserContext* browser_context,
} }
} }
void AlarmManager::Observe( void AlarmManager::OnExtensionUninstalled(
int type, content::BrowserContext* browser_context,
const content::NotificationSource& source, const Extension* extension) {
const content::NotificationDetails& details) {
DCHECK_EQ(type, chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED);
const Extension* extension = content::Details<const Extension>(details).ptr();
RemoveAllAlarms(extension->id(), base::Bind(RemoveAllOnUninstallCallback)); RemoveAllAlarms(extension->id(), base::Bind(RemoveAllOnUninstallCallback));
} }
......
...@@ -15,10 +15,7 @@ ...@@ -15,10 +15,7 @@
#include "base/scoped_observer.h" #include "base/scoped_observer.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "chrome/common/extensions/api/alarms.h" #include "chrome/common/extensions/api/alarms.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "extensions/browser/browser_context_keyed_api_factory.h" #include "extensions/browser/browser_context_keyed_api_factory.h"
#include "extensions/browser/extension_function.h"
#include "extensions/browser/extension_registry_observer.h" #include "extensions/browser/extension_registry_observer.h"
namespace base { namespace base {
...@@ -56,7 +53,6 @@ struct Alarm { ...@@ -56,7 +53,6 @@ struct Alarm {
// Manages the currently pending alarms for every extension in a profile. // Manages the currently pending alarms for every extension in a profile.
// There is one manager per virtual Profile. // There is one manager per virtual Profile.
class AlarmManager : public BrowserContextKeyedAPI, class AlarmManager : public BrowserContextKeyedAPI,
public content::NotificationObserver,
public ExtensionRegistryObserver, public ExtensionRegistryObserver,
public base::SupportsWeakPtr<AlarmManager> { public base::SupportsWeakPtr<AlarmManager> {
public: public:
...@@ -204,14 +200,11 @@ class AlarmManager : public BrowserContextKeyedAPI, ...@@ -204,14 +200,11 @@ class AlarmManager : public BrowserContextKeyedAPI,
// alarm data has been synced from the storage. // alarm data has been synced from the storage.
void RunWhenReady(const std::string& extension_id, const ReadyAction& action); void RunWhenReady(const std::string& extension_id, const ReadyAction& action);
// NotificationObserver: // ExtensionRegistryObserver implementation.
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
// Overridden from extensions::ExtensionRegistryObserver.
virtual void OnExtensionLoaded(content::BrowserContext* browser_context, virtual void OnExtensionLoaded(content::BrowserContext* browser_context,
const Extension* extension) OVERRIDE; const Extension* extension) OVERRIDE;
virtual void OnExtensionUninstalled(content::BrowserContext* browser_context,
const Extension* extension) OVERRIDE;
// BrowserContextKeyedAPI implementation. // BrowserContextKeyedAPI implementation.
static const char* service_name() { static const char* service_name() {
...@@ -221,7 +214,6 @@ class AlarmManager : public BrowserContextKeyedAPI, ...@@ -221,7 +214,6 @@ class AlarmManager : public BrowserContextKeyedAPI,
content::BrowserContext* const browser_context_; content::BrowserContext* const browser_context_;
scoped_ptr<base::Clock> clock_; scoped_ptr<base::Clock> clock_;
content::NotificationRegistrar registrar_;
scoped_ptr<Delegate> delegate_; scoped_ptr<Delegate> delegate_;
// Listen to extension load notifications. // Listen to extension load notifications.
......
...@@ -8,12 +8,10 @@ ...@@ -8,12 +8,10 @@
#include <string> #include <string>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/scoped_observer.h"
#include "chrome/common/extensions/command.h" #include "chrome/common/extensions/command.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_source.h"
#include "extensions/browser/browser_context_keyed_api_factory.h" #include "extensions/browser/browser_context_keyed_api_factory.h"
#include "extensions/browser/extension_registry_observer.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
class Profile; class Profile;
...@@ -35,12 +33,13 @@ class PrefRegistrySyncable; ...@@ -35,12 +33,13 @@ class PrefRegistrySyncable;
} }
namespace extensions { namespace extensions {
class ExtensionRegistry;
// This service keeps track of preferences related to extension commands // This service keeps track of preferences related to extension commands
// (assigning initial keybindings on install and removing them on deletion // (assigning initial keybindings on install and removing them on deletion
// and answers questions related to which commands are active. // and answers questions related to which commands are active.
class CommandService : public BrowserContextKeyedAPI, class CommandService : public BrowserContextKeyedAPI,
public content::NotificationObserver { public ExtensionRegistryObserver {
public: public:
// An enum specifying whether to fetch all extension commands or only active // An enum specifying whether to fetch all extension commands or only active
// ones. // ones.
...@@ -80,12 +79,11 @@ class CommandService : public BrowserContextKeyedAPI, ...@@ -80,12 +79,11 @@ class CommandService : public BrowserContextKeyedAPI,
// Returns true if |extension| is permitted to and does remove the bookmark // Returns true if |extension| is permitted to and does remove the bookmark
// shortcut key. // shortcut key.
static bool RemovesBookmarkShortcut(const extensions::Extension* extension); static bool RemovesBookmarkShortcut(const Extension* extension);
// Returns true if |extension| is permitted to and does remove the bookmark // Returns true if |extension| is permitted to and does remove the bookmark
// open pages shortcut key. // open pages shortcut key.
static bool RemovesBookmarkOpenPagesShortcut( static bool RemovesBookmarkOpenPagesShortcut(const Extension* extension);
const extensions::Extension* extension);
// Gets the command (if any) for the browser action of an extension given // Gets the command (if any) for the browser action of an extension given
// its |extension_id|. The function consults the master list to see if // its |extension_id|. The function consults the master list to see if
...@@ -95,7 +93,7 @@ class CommandService : public BrowserContextKeyedAPI, ...@@ -95,7 +93,7 @@ class CommandService : public BrowserContextKeyedAPI,
// NULL) contains whether |command| is active. // NULL) contains whether |command| is active.
bool GetBrowserActionCommand(const std::string& extension_id, bool GetBrowserActionCommand(const std::string& extension_id,
QueryType type, QueryType type,
extensions::Command* command, Command* command,
bool* active) const; bool* active) const;
// Gets the command (if any) for the page action of an extension given // Gets the command (if any) for the page action of an extension given
...@@ -106,7 +104,7 @@ class CommandService : public BrowserContextKeyedAPI, ...@@ -106,7 +104,7 @@ class CommandService : public BrowserContextKeyedAPI,
// NULL) contains whether |command| is active. // NULL) contains whether |command| is active.
bool GetPageActionCommand(const std::string& extension_id, bool GetPageActionCommand(const std::string& extension_id,
QueryType type, QueryType type,
extensions::Command* command, Command* command,
bool* active) const; bool* active) const;
// Gets the active named commands (if any) for the extension with // Gets the active named commands (if any) for the extension with
...@@ -117,7 +115,7 @@ class CommandService : public BrowserContextKeyedAPI, ...@@ -117,7 +115,7 @@ class CommandService : public BrowserContextKeyedAPI,
bool GetNamedCommands(const std::string& extension_id, bool GetNamedCommands(const std::string& extension_id,
QueryType type, QueryType type,
CommandScope scope, CommandScope scope,
extensions::CommandMap* command_map) const; CommandMap* command_map) const;
// Records a keybinding |accelerator| as active for an extension with id // Records a keybinding |accelerator| as active for an extension with id
// |extension_id| and command with the name |command_name|. If // |extension_id| and command with the name |command_name|. If
...@@ -164,17 +162,12 @@ class CommandService : public BrowserContextKeyedAPI, ...@@ -164,17 +162,12 @@ class CommandService : public BrowserContextKeyedAPI,
// its type if non-NULL. // its type if non-NULL.
bool GetBoundExtensionCommand(const std::string& extension_id, bool GetBoundExtensionCommand(const std::string& extension_id,
const ui::Accelerator& accelerator, const ui::Accelerator& accelerator,
extensions::Command* command, Command* command,
ExtensionCommandType* command_type) const; ExtensionCommandType* command_type) const;
// Returns true if |extension| is permitted to and does override the bookmark // Returns true if |extension| is permitted to and does override the bookmark
// shortcut key. // shortcut key.
bool OverridesBookmarkShortcut(const extensions::Extension* extension) const; bool OverridesBookmarkShortcut(const Extension* extension) const;
// Overridden from content::NotificationObserver.
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
private: private:
friend class BrowserContextKeyedAPIFactory<CommandService>; friend class BrowserContextKeyedAPIFactory<CommandService>;
...@@ -185,25 +178,35 @@ class CommandService : public BrowserContextKeyedAPI, ...@@ -185,25 +178,35 @@ class CommandService : public BrowserContextKeyedAPI,
} }
static const bool kServiceRedirectedInIncognito = true; static const bool kServiceRedirectedInIncognito = true;
// ExtensionRegistryObserver.
virtual void OnExtensionWillBeInstalled(
content::BrowserContext* browser_context,
const Extension* extension,
bool is_update,
bool from_ephemeral,
const std::string& old_name) OVERRIDE;
virtual void OnExtensionUninstalled(content::BrowserContext* browser_context,
const Extension* extension) OVERRIDE;
// Assigns initial keybinding for a given |extension|'s page action, browser // Assigns initial keybinding for a given |extension|'s page action, browser
// action and named commands. In each case, if the suggested keybinding is // action and named commands. In each case, if the suggested keybinding is
// free, it will be taken by this extension. If not, that keybinding request // free, it will be taken by this extension. If not, that keybinding request
// is ignored. |user_pref| is the PrefService used to record the new // is ignored. |user_pref| is the PrefService used to record the new
// keybinding assignment. // keybinding assignment.
void AssignInitialKeybindings(const extensions::Extension* extension); void AssignInitialKeybindings(const Extension* extension);
bool GetExtensionActionCommand(const std::string& extension_id, bool GetExtensionActionCommand(const std::string& extension_id,
QueryType query_type, QueryType query_type,
extensions::Command* command, Command* command,
bool* active, bool* active,
ExtensionCommandType action_type) const; ExtensionCommandType action_type) const;
// The content notification registrar for listening to extension events.
content::NotificationRegistrar registrar_;
// A weak pointer to the profile we are associated with. Not owned by us. // A weak pointer to the profile we are associated with. Not owned by us.
Profile* profile_; Profile* profile_;
ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
extension_registry_observer_;
DISALLOW_COPY_AND_ASSIGN(CommandService); DISALLOW_COPY_AND_ASSIGN(CommandService);
}; };
......
...@@ -48,9 +48,6 @@ RulesRegistryService::RulesRegistryService(content::BrowserContext* context) ...@@ -48,9 +48,6 @@ RulesRegistryService::RulesRegistryService(content::BrowserContext* context)
profile_(Profile::FromBrowserContext(context)) { profile_(Profile::FromBrowserContext(context)) {
if (profile_) { if (profile_) {
extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); extension_registry_observer_.Add(ExtensionRegistry::Get(profile_));
registrar_.Add(this,
chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED,
content::Source<Profile>(profile_->GetOriginalProfile()));
registrar_.Add( registrar_.Add(
this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
content::NotificationService::AllBrowserContextsAndSources()); content::NotificationService::AllBrowserContextsAndSources());
...@@ -216,28 +213,22 @@ void RulesRegistryService::OnExtensionUnloaded( ...@@ -216,28 +213,22 @@ void RulesRegistryService::OnExtensionUnloaded(
NotifyRegistriesHelper(&RulesRegistry::OnExtensionUnloaded, extension->id()); NotifyRegistriesHelper(&RulesRegistry::OnExtensionUnloaded, extension->id());
} }
void RulesRegistryService::OnExtensionUninstalled(
content::BrowserContext* browser_context,
const Extension* extension) {
NotifyRegistriesHelper(&RulesRegistry::OnExtensionUninstalled,
extension->id());
}
void RulesRegistryService::Observe( void RulesRegistryService::Observe(
int type, int type,
const content::NotificationSource& source, const content::NotificationSource& source,
const content::NotificationDetails& details) { const content::NotificationDetails& details) {
switch (type) { DCHECK_EQ(content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, type);
case chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED: {
const Extension* extension = content::RenderProcessHost* process =
content::Details<const Extension>(details).ptr(); content::Source<content::RenderProcessHost>(source).ptr();
NotifyRegistriesHelper(&RulesRegistry::OnExtensionUninstalled, RemoveWebViewRulesRegistries(process->GetID());
extension->id());
break;
}
case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: {
content::RenderProcessHost* process =
content::Source<content::RenderProcessHost>(source).ptr();
RemoveWebViewRulesRegistries(process->GetID());
break;
}
default:
NOTREACHED();
break;
}
} }
} // namespace extensions } // namespace extensions
...@@ -116,6 +116,8 @@ class RulesRegistryService : public BrowserContextKeyedAPI, ...@@ -116,6 +116,8 @@ class RulesRegistryService : public BrowserContextKeyedAPI,
content::BrowserContext* browser_context, content::BrowserContext* browser_context,
const Extension* extension, const Extension* extension,
UnloadedExtensionInfo::Reason reason) OVERRIDE; UnloadedExtensionInfo::Reason reason) OVERRIDE;
virtual void OnExtensionUninstalled(content::BrowserContext* browser_context,
const Extension* extension) OVERRIDE;
// Iterates over all registries, and calls |notification_callback| on them // Iterates over all registries, and calls |notification_callback| on them
// with |extension_id| as the argument. If a registry lives on a different // with |extension_id| as the argument. If a registry lives on a different
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/file_util.h" #include "base/file_util.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "chrome/browser/chrome_notification_types.h" #include "base/scoped_observer.h"
#include "chrome/browser/extensions/api/storage/policy_value_store.h" #include "chrome/browser/extensions/api/storage/policy_value_store.h"
#include "chrome/browser/policy/profile_policy_connector.h" #include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/policy/profile_policy_connector_factory.h" #include "chrome/browser/policy/profile_policy_connector_factory.h"
...@@ -23,13 +23,10 @@ ...@@ -23,13 +23,10 @@
#include "components/policy/core/common/schema_map.h" #include "components/policy/core/common/schema_map.h"
#include "components/policy/core/common/schema_registry.h" #include "components/policy/core/common/schema_registry.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_source.h"
#include "extensions/browser/api/storage/settings_storage_factory.h" #include "extensions/browser/api/storage/settings_storage_factory.h"
#include "extensions/browser/extension_prefs.h" #include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_registry_observer.h"
#include "extensions/browser/extension_system.h" #include "extensions/browser/extension_system.h"
#include "extensions/browser/value_store/value_store_change.h" #include "extensions/browser/value_store/value_store_change.h"
#include "extensions/common/api/storage.h" #include "extensions/common/api/storage.h"
...@@ -44,6 +41,7 @@ using content::BrowserContext; ...@@ -44,6 +41,7 @@ using content::BrowserContext;
using content::BrowserThread; using content::BrowserThread;
namespace extensions { namespace extensions {
class ExtensionRegistry;
namespace storage = core_api::storage; namespace storage = core_api::storage;
...@@ -67,17 +65,22 @@ const char kLegacyBrowserSupportExtensionId[] = ...@@ -67,17 +65,22 @@ const char kLegacyBrowserSupportExtensionId[] =
// to fetch cloud policy for those extensions, and allows its providers to // to fetch cloud policy for those extensions, and allows its providers to
// selectively load only extension policy that has users. // selectively load only extension policy that has users.
class ManagedValueStoreCache::ExtensionTracker class ManagedValueStoreCache::ExtensionTracker
: public content::NotificationObserver { : public ExtensionRegistryObserver {
public: public:
explicit ExtensionTracker(Profile* profile); explicit ExtensionTracker(Profile* profile);
virtual ~ExtensionTracker() {} virtual ~ExtensionTracker() {}
// NotificationObserver implementation:
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
private: private:
// ExtensionRegistryObserver implementation.
virtual void OnExtensionWillBeInstalled(
content::BrowserContext* browser_context,
const Extension* extension,
bool is_update,
bool from_ephemeral,
const std::string& old_name) OVERRIDE;
virtual void OnExtensionUninstalled(content::BrowserContext* browser_context,
const Extension* extension) OVERRIDE;
// Handler for the signal from ExtensionSystem::ready(). // Handler for the signal from ExtensionSystem::ready().
void OnExtensionsReady(); void OnExtensionsReady();
...@@ -93,7 +96,8 @@ class ManagedValueStoreCache::ExtensionTracker ...@@ -93,7 +96,8 @@ class ManagedValueStoreCache::ExtensionTracker
void Register(const policy::ComponentMap* components); void Register(const policy::ComponentMap* components);
Profile* profile_; Profile* profile_;
content::NotificationRegistrar registrar_; ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
extension_registry_observer_;
policy::SchemaRegistry* schema_registry_; policy::SchemaRegistry* schema_registry_;
base::WeakPtrFactory<ExtensionTracker> weak_factory_; base::WeakPtrFactory<ExtensionTracker> weak_factory_;
...@@ -102,16 +106,11 @@ class ManagedValueStoreCache::ExtensionTracker ...@@ -102,16 +106,11 @@ class ManagedValueStoreCache::ExtensionTracker
ManagedValueStoreCache::ExtensionTracker::ExtensionTracker(Profile* profile) ManagedValueStoreCache::ExtensionTracker::ExtensionTracker(Profile* profile)
: profile_(profile), : profile_(profile),
extension_registry_observer_(this),
schema_registry_( schema_registry_(
policy::SchemaRegistryServiceFactory::GetForContext(profile)), policy::SchemaRegistryServiceFactory::GetForContext(profile)),
weak_factory_(this) { weak_factory_(this) {
registrar_.Add(this, extension_registry_observer_.Add(ExtensionRegistry::Get(profile_));
chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED,
content::Source<Profile>(profile_));
registrar_.Add(this,
chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED,
content::Source<Profile>(profile_));
// Load schemas when the extension system is ready. It might be ready now. // Load schemas when the extension system is ready. It might be ready now.
ExtensionSystem::Get(profile_)->ready().Post( ExtensionSystem::Get(profile_)->ready().Post(
FROM_HERE, FROM_HERE,
...@@ -119,37 +118,31 @@ ManagedValueStoreCache::ExtensionTracker::ExtensionTracker(Profile* profile) ...@@ -119,37 +118,31 @@ ManagedValueStoreCache::ExtensionTracker::ExtensionTracker(Profile* profile)
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
} }
void ManagedValueStoreCache::ExtensionTracker::Observe( void ManagedValueStoreCache::ExtensionTracker::OnExtensionWillBeInstalled(
int type, content::BrowserContext* browser_context,
const content::NotificationSource& source, const Extension* extension,
const content::NotificationDetails& details) { bool is_update,
bool from_ephemeral,
const std::string& old_name) {
// Some extensions are installed on the first run before the ExtensionSystem // Some extensions are installed on the first run before the ExtensionSystem
// becomes ready. Wait until all of them are ready before registering the // becomes ready. Wait until all of them are ready before registering the
// schemas of managed extensions, so that the policy loaders are reloaded at // schemas of managed extensions, so that the policy loaders are reloaded at
// most once. // most once.
if (!ExtensionSystem::Get(profile_)->ready().is_signaled()) if (!ExtensionSystem::Get(profile_)->ready().is_signaled())
return; return;
scoped_ptr<ExtensionSet> added(new ExtensionSet);
added->Insert(extension);
LoadSchemas(added.Pass());
}
switch (type) { void ManagedValueStoreCache::ExtensionTracker::OnExtensionUninstalled(
case chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED: { content::BrowserContext* browser_context,
scoped_ptr<ExtensionSet> added(new ExtensionSet); const Extension* extension) {
added->Insert( if (!ExtensionSystem::Get(profile_)->ready().is_signaled())
content::Details<InstalledExtensionInfo>(details)->extension); return;
LoadSchemas(added.Pass()); if (extension && UsesManagedStorage(extension)) {
break; schema_registry_->UnregisterComponent(policy::PolicyNamespace(
} policy::POLICY_DOMAIN_EXTENSIONS, extension->id()));
case chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED: {
const Extension* removed =
content::Details<const Extension>(details).ptr();
if (removed && UsesManagedStorage(removed)) {
schema_registry_->UnregisterComponent(policy::PolicyNamespace(
policy::POLICY_DOMAIN_EXTENSIONS, removed->id()));
}
break;
}
default:
NOTREACHED();
return;
} }
} }
......
...@@ -12,8 +12,6 @@ ...@@ -12,8 +12,6 @@
#include "chrome/browser/services/gcm/gcm_profile_service.h" #include "chrome/browser/services/gcm/gcm_profile_service.h"
#include "chrome/browser/services/gcm/gcm_profile_service_factory.h" #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
#include "components/gcm_driver/gcm_driver.h" #include "components/gcm_driver/gcm_driver.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h" #include "extensions/browser/extension_system.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
...@@ -48,10 +46,6 @@ ExtensionGCMAppHandler::ExtensionGCMAppHandler(content::BrowserContext* context) ...@@ -48,10 +46,6 @@ ExtensionGCMAppHandler::ExtensionGCMAppHandler(content::BrowserContext* context)
extension_registry_observer_(this), extension_registry_observer_(this),
weak_factory_(this) { weak_factory_(this) {
extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); extension_registry_observer_.Add(ExtensionRegistry::Get(profile_));
registrar_.Add(this,
chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED,
content::Source<Profile>(profile_));
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
js_event_router_.reset(new extensions::GcmJsEventRouter(profile_)); js_event_router_.reset(new extensions::GcmJsEventRouter(profile_));
#endif #endif
...@@ -111,12 +105,9 @@ void ExtensionGCMAppHandler::OnExtensionUnloaded( ...@@ -111,12 +105,9 @@ void ExtensionGCMAppHandler::OnExtensionUnloaded(
GetGCMDriver()->RemoveAppHandler(extension->id()); GetGCMDriver()->RemoveAppHandler(extension->id());
} }
void ExtensionGCMAppHandler::Observe( void ExtensionGCMAppHandler::OnExtensionUninstalled(
int type, content::BrowserContext* browser_context,
const content::NotificationSource& source, const Extension* extension) {
const content::NotificationDetails& details) {
DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, type);
const Extension* extension = content::Details<Extension>(details).ptr();
if (IsGCMPermissionEnabled(extension)) { if (IsGCMPermissionEnabled(extension)) {
GetGCMDriver()->Unregister( GetGCMDriver()->Unregister(
extension->id(), extension->id(),
......
...@@ -13,8 +13,6 @@ ...@@ -13,8 +13,6 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h" #include "base/scoped_observer.h"
#include "components/gcm_driver/gcm_app_handler.h" #include "components/gcm_driver/gcm_app_handler.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "extensions/browser/browser_context_keyed_api_factory.h" #include "extensions/browser/browser_context_keyed_api_factory.h"
#include "extensions/browser/extension_registry_observer.h" #include "extensions/browser/extension_registry_observer.h"
#include "google_apis/gcm/gcm_client.h" #include "google_apis/gcm/gcm_client.h"
...@@ -38,7 +36,6 @@ class GcmJsEventRouter; ...@@ -38,7 +36,6 @@ class GcmJsEventRouter;
// Defines the interface to provide handling logic for a given app. // Defines the interface to provide handling logic for a given app.
class ExtensionGCMAppHandler : public gcm::GCMAppHandler, class ExtensionGCMAppHandler : public gcm::GCMAppHandler,
public BrowserContextKeyedAPI, public BrowserContextKeyedAPI,
public content::NotificationObserver,
public ExtensionRegistryObserver { public ExtensionRegistryObserver {
public: public:
explicit ExtensionGCMAppHandler(content::BrowserContext* context); explicit ExtensionGCMAppHandler(content::BrowserContext* context);
...@@ -65,11 +62,6 @@ class ExtensionGCMAppHandler : public gcm::GCMAppHandler, ...@@ -65,11 +62,6 @@ class ExtensionGCMAppHandler : public gcm::GCMAppHandler,
private: private:
friend class BrowserContextKeyedAPIFactory<ExtensionGCMAppHandler>; friend class BrowserContextKeyedAPIFactory<ExtensionGCMAppHandler>;
// content::NotificationObserver implementation.
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
// ExtensionRegistryObserver implementation. // ExtensionRegistryObserver implementation.
virtual void OnExtensionLoaded(content::BrowserContext* browser_context, virtual void OnExtensionLoaded(content::BrowserContext* browser_context,
const Extension* extension) OVERRIDE; const Extension* extension) OVERRIDE;
...@@ -77,6 +69,8 @@ class ExtensionGCMAppHandler : public gcm::GCMAppHandler, ...@@ -77,6 +69,8 @@ class ExtensionGCMAppHandler : public gcm::GCMAppHandler,
content::BrowserContext* browser_context, content::BrowserContext* browser_context,
const Extension* extension, const Extension* extension,
UnloadedExtensionInfo::Reason reason) OVERRIDE; UnloadedExtensionInfo::Reason reason) OVERRIDE;
virtual void OnExtensionUninstalled(content::BrowserContext* browser_context,
const Extension* extension) OVERRIDE;
gcm::GCMDriver* GetGCMDriver() const; gcm::GCMDriver* GetGCMDriver() const;
...@@ -85,7 +79,6 @@ class ExtensionGCMAppHandler : public gcm::GCMAppHandler, ...@@ -85,7 +79,6 @@ class ExtensionGCMAppHandler : public gcm::GCMAppHandler,
static const bool kServiceIsNULLWhileTesting = true; static const bool kServiceIsNULLWhileTesting = true;
Profile* profile_; Profile* profile_;
content::NotificationRegistrar registrar_;
// Listen to extension load, unloaded notifications. // Listen to extension load, unloaded notifications.
ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment