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.
......
...@@ -33,11 +33,7 @@ ...@@ -33,11 +33,7 @@
#include "extensions/common/manifest_constants.h" #include "extensions/common/manifest_constants.h"
#include "extensions/common/permissions/permissions_data.h" #include "extensions/common/permissions/permissions_data.h"
using extensions::Extension; namespace extensions {
using extensions::ExtensionPrefs;
using extensions::SettingsOverrides;
using extensions::UIOverrides;
namespace { namespace {
const char kExtension[] = "extension"; const char kExtension[] = "extension";
...@@ -50,22 +46,21 @@ const char kInitialBindingsHaveBeenAssigned[] = "initial_keybindings_set"; ...@@ -50,22 +46,21 @@ const char kInitialBindingsHaveBeenAssigned[] = "initial_keybindings_set";
std::string GetPlatformKeybindingKeyForAccelerator( std::string GetPlatformKeybindingKeyForAccelerator(
const ui::Accelerator& accelerator, const std::string extension_id) { const ui::Accelerator& accelerator, const std::string extension_id) {
std::string key = extensions::Command::CommandPlatform() + ":" + std::string key = Command::CommandPlatform() + ":" +
extensions::Command::AcceleratorToString(accelerator); Command::AcceleratorToString(accelerator);
// Media keys have a 1-to-many relationship with targets, unlike regular // Media keys have a 1-to-many relationship with targets, unlike regular
// shortcut (1-to-1 relationship). That means two or more extensions can // shortcut (1-to-1 relationship). That means two or more extensions can
// register for the same media key so the extension ID needs to be added to // register for the same media key so the extension ID needs to be added to
// the key to make sure the key is unique. // the key to make sure the key is unique.
if (extensions::Command::IsMediaKey(accelerator)) if (Command::IsMediaKey(accelerator))
key += ":" + extension_id; key += ":" + extension_id;
return key; return key;
} }
bool IsForCurrentPlatform(const std::string& key) { bool IsForCurrentPlatform(const std::string& key) {
return StartsWithASCII( return StartsWithASCII(key, Command::CommandPlatform() + ":", true);
key, extensions::Command::CommandPlatform() + ":", true);
} }
void SetInitialBindingsHaveBeenAssigned( void SetInitialBindingsHaveBeenAssigned(
...@@ -93,7 +88,7 @@ bool CanAutoAssign(const ui::Accelerator& accelerator, ...@@ -93,7 +88,7 @@ bool CanAutoAssign(const ui::Accelerator& accelerator,
bool is_named_command, bool is_named_command,
bool is_global) { bool is_global) {
// Media Keys are non-exclusive, so allow auto-assigning them. // Media Keys are non-exclusive, so allow auto-assigning them.
if (extensions::Command::IsMediaKey(accelerator)) if (Command::IsMediaKey(accelerator))
return true; return true;
if (is_global) { if (is_global) {
...@@ -115,9 +110,9 @@ bool CanAutoAssign(const ui::Accelerator& accelerator, ...@@ -115,9 +110,9 @@ bool CanAutoAssign(const ui::Accelerator& accelerator,
} else { } else {
// Not a global command, check if Chrome shortcut and whether // Not a global command, check if Chrome shortcut and whether
// we can override it. // we can override it.
if (accelerator == if (accelerator == chrome::GetPrimaryChromeAcceleratorForCommandId(
chrome::GetPrimaryChromeAcceleratorForCommandId(IDC_BOOKMARK_PAGE) && IDC_BOOKMARK_PAGE) &&
extensions::CommandService::RemovesBookmarkShortcut(extension)) { CommandService::RemovesBookmarkShortcut(extension)) {
// If this check fails it either means we have an API to override a // If this check fails it either means we have an API to override a
// key that isn't a ChromeAccelerator (and the API can therefore be // key that isn't a ChromeAccelerator (and the API can therefore be
// deprecated) or the IsChromeAccelerator isn't consistently // deprecated) or the IsChromeAccelerator isn't consistently
...@@ -132,8 +127,6 @@ bool CanAutoAssign(const ui::Accelerator& accelerator, ...@@ -132,8 +127,6 @@ bool CanAutoAssign(const ui::Accelerator& accelerator,
} // namespace } // namespace
namespace extensions {
// static // static
void CommandService::RegisterProfilePrefs( void CommandService::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) { user_prefs::PrefRegistrySyncable* registry) {
...@@ -143,16 +136,12 @@ void CommandService::RegisterProfilePrefs( ...@@ -143,16 +136,12 @@ void CommandService::RegisterProfilePrefs(
} }
CommandService::CommandService(content::BrowserContext* context) CommandService::CommandService(content::BrowserContext* context)
: profile_(Profile::FromBrowserContext(context)) { : profile_(Profile::FromBrowserContext(context)),
extension_registry_observer_(this) {
ExtensionFunctionRegistry::GetInstance()-> ExtensionFunctionRegistry::GetInstance()->
RegisterFunction<GetAllCommandsFunction>(); RegisterFunction<GetAllCommandsFunction>();
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_));
} }
CommandService::~CommandService() { CommandService::~CommandService() {
...@@ -173,8 +162,7 @@ CommandService* CommandService::Get(content::BrowserContext* context) { ...@@ -173,8 +162,7 @@ CommandService* CommandService::Get(content::BrowserContext* context) {
} }
// static // static
bool CommandService::RemovesBookmarkShortcut( bool CommandService::RemovesBookmarkShortcut(const Extension* extension) {
const extensions::Extension* extension) {
const UIOverrides* ui_overrides = UIOverrides::Get(extension); const UIOverrides* ui_overrides = UIOverrides::Get(extension);
const SettingsOverrides* settings_overrides = const SettingsOverrides* settings_overrides =
SettingsOverrides::Get(extension); SettingsOverrides::Get(extension);
...@@ -183,16 +171,14 @@ bool CommandService::RemovesBookmarkShortcut( ...@@ -183,16 +171,14 @@ bool CommandService::RemovesBookmarkShortcut(
SettingsOverrides::RemovesBookmarkShortcut(*settings_overrides)) || SettingsOverrides::RemovesBookmarkShortcut(*settings_overrides)) ||
(ui_overrides && (ui_overrides &&
UIOverrides::RemovesBookmarkShortcut(*ui_overrides))) && UIOverrides::RemovesBookmarkShortcut(*ui_overrides))) &&
(extensions::PermissionsData::HasAPIPermission( (PermissionsData::HasAPIPermission(
extension, extension, APIPermission::kBookmarkManagerPrivate) ||
extensions::APIPermission::kBookmarkManagerPrivate) || FeatureSwitch::enable_override_bookmarks_ui()->IsEnabled());
extensions::FeatureSwitch::enable_override_bookmarks_ui()->
IsEnabled());
} }
// static // static
bool CommandService::RemovesBookmarkOpenPagesShortcut( bool CommandService::RemovesBookmarkOpenPagesShortcut(
const extensions::Extension* extension) { const Extension* extension) {
const UIOverrides* ui_overrides = UIOverrides::Get(extension); const UIOverrides* ui_overrides = UIOverrides::Get(extension);
const SettingsOverrides* settings_overrides = const SettingsOverrides* settings_overrides =
SettingsOverrides::Get(extension); SettingsOverrides::Get(extension);
...@@ -202,16 +188,14 @@ bool CommandService::RemovesBookmarkOpenPagesShortcut( ...@@ -202,16 +188,14 @@ bool CommandService::RemovesBookmarkOpenPagesShortcut(
*settings_overrides)) || *settings_overrides)) ||
(ui_overrides && (ui_overrides &&
UIOverrides::RemovesBookmarkOpenPagesShortcut(*ui_overrides))) && UIOverrides::RemovesBookmarkOpenPagesShortcut(*ui_overrides))) &&
(extensions::PermissionsData::HasAPIPermission( (PermissionsData::HasAPIPermission(
extension, extension, APIPermission::kBookmarkManagerPrivate) ||
extensions::APIPermission::kBookmarkManagerPrivate) || FeatureSwitch::enable_override_bookmarks_ui()->IsEnabled());
extensions::FeatureSwitch::enable_override_bookmarks_ui()->
IsEnabled());
} }
bool CommandService::GetBrowserActionCommand(const std::string& extension_id, bool CommandService::GetBrowserActionCommand(const std::string& extension_id,
QueryType type, QueryType type,
extensions::Command* command, Command* command,
bool* active) const { bool* active) const {
return GetExtensionActionCommand( return GetExtensionActionCommand(
extension_id, type, command, active, BROWSER_ACTION); extension_id, type, command, active, BROWSER_ACTION);
...@@ -219,39 +203,37 @@ bool CommandService::GetBrowserActionCommand(const std::string& extension_id, ...@@ -219,39 +203,37 @@ bool CommandService::GetBrowserActionCommand(const std::string& extension_id,
bool CommandService::GetPageActionCommand(const std::string& extension_id, bool CommandService::GetPageActionCommand(const std::string& extension_id,
QueryType type, QueryType type,
extensions::Command* command, Command* command,
bool* active) const { bool* active) const {
return GetExtensionActionCommand( return GetExtensionActionCommand(
extension_id, type, command, active, PAGE_ACTION); extension_id, type, command, active, PAGE_ACTION);
} }
bool CommandService::GetNamedCommands( bool CommandService::GetNamedCommands(const std::string& extension_id,
const std::string& extension_id, QueryType type,
QueryType type, CommandScope scope,
CommandScope scope, CommandMap* command_map) const {
extensions::CommandMap* command_map) const {
const ExtensionSet& extensions = const ExtensionSet& extensions =
ExtensionRegistry::Get(profile_)->enabled_extensions(); ExtensionRegistry::Get(profile_)->enabled_extensions();
const Extension* extension = extensions.GetByID(extension_id); const Extension* extension = extensions.GetByID(extension_id);
CHECK(extension); CHECK(extension);
command_map->clear(); command_map->clear();
const extensions::CommandMap* commands = const CommandMap* commands = CommandsInfo::GetNamedCommands(extension);
CommandsInfo::GetNamedCommands(extension);
if (!commands) if (!commands)
return false; return false;
extensions::CommandMap::const_iterator iter = commands->begin(); CommandMap::const_iterator iter = commands->begin();
for (; iter != commands->end(); ++iter) { for (; iter != commands->end(); ++iter) {
// Look up to see if the user has overridden how the command should work. // Look up to see if the user has overridden how the command should work.
extensions::Command saved_command = Command saved_command =
FindCommandByName(extension_id, iter->second.command_name()); FindCommandByName(extension_id, iter->second.command_name());
ui::Accelerator shortcut_assigned = saved_command.accelerator(); ui::Accelerator shortcut_assigned = saved_command.accelerator();
if (type == ACTIVE_ONLY && shortcut_assigned.key_code() == ui::VKEY_UNKNOWN) if (type == ACTIVE_ONLY && shortcut_assigned.key_code() == ui::VKEY_UNKNOWN)
continue; continue;
extensions::Command command = iter->second; Command command = iter->second;
if (scope != ANY_SCOPE && ((scope == GLOBAL) != saved_command.global())) if (scope != ANY_SCOPE && ((scope == GLOBAL) != saved_command.global()))
continue; continue;
...@@ -320,30 +302,25 @@ bool CommandService::AddKeybindingPref( ...@@ -320,30 +302,25 @@ bool CommandService::AddKeybindingPref(
return true; return true;
} }
void CommandService::Observe( void CommandService::OnExtensionWillBeInstalled(
int type, content::BrowserContext* browser_context,
const content::NotificationSource& source, const Extension* extension,
const content::NotificationDetails& details) { bool is_update,
switch (type) { bool from_ephemeral,
case chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED: const std::string& old_name) {
AssignInitialKeybindings( AssignInitialKeybindings(extension);
content::Details<const InstalledExtensionInfo>(details)->extension); }
break;
case chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED: void CommandService::OnExtensionUninstalled(
RemoveKeybindingPrefs( content::BrowserContext* browser_context,
content::Details<const Extension>(details)->id(), const Extension* extension) {
std::string()); RemoveKeybindingPrefs(extension->id(), std::string());
break;
default:
NOTREACHED();
break;
}
} }
void CommandService::UpdateKeybindingPrefs(const std::string& extension_id, void CommandService::UpdateKeybindingPrefs(const std::string& extension_id,
const std::string& command_name, const std::string& command_name,
const std::string& keystroke) { const std::string& keystroke) {
extensions::Command command = FindCommandByName(extension_id, command_name); Command command = FindCommandByName(extension_id, command_name);
// The extension command might be assigned another shortcut. Remove that // The extension command might be assigned another shortcut. Remove that
// shortcut before proceeding. // shortcut before proceeding.
...@@ -358,7 +335,7 @@ void CommandService::UpdateKeybindingPrefs(const std::string& extension_id, ...@@ -358,7 +335,7 @@ void CommandService::UpdateKeybindingPrefs(const std::string& extension_id,
bool CommandService::SetScope(const std::string& extension_id, bool CommandService::SetScope(const std::string& extension_id,
const std::string& command_name, const std::string& command_name,
bool global) { bool global) {
extensions::Command command = FindCommandByName(extension_id, command_name); Command command = FindCommandByName(extension_id, command_name);
if (global == command.global()) if (global == command.global())
return false; return false;
...@@ -409,42 +386,43 @@ Command CommandService::FindCommandByName(const std::string& extension_id, ...@@ -409,42 +386,43 @@ Command CommandService::FindCommandByName(const std::string& extension_id,
bool CommandService::GetBoundExtensionCommand( bool CommandService::GetBoundExtensionCommand(
const std::string& extension_id, 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 {
const ExtensionSet& extensions = const Extension* extension =
ExtensionRegistry::Get(profile_)->enabled_extensions(); ExtensionRegistry::Get(profile_)
const Extension* extension = extensions.GetByID(extension_id); ->GetExtensionById(extension_id, ExtensionRegistry::ENABLED);
CHECK(extension); CHECK(extension);
extensions::Command prospective_command; Command prospective_command;
extensions::CommandMap command_map; CommandMap command_map;
bool active = false; bool active = false;
if (GetBrowserActionCommand(extension_id, if (GetBrowserActionCommand(extension_id,
extensions::CommandService::ACTIVE_ONLY, CommandService::ACTIVE_ONLY,
&prospective_command, &prospective_command,
&active) && active && &active) &&
accelerator == prospective_command.accelerator()) { active && accelerator == prospective_command.accelerator()) {
if (command) if (command)
*command = prospective_command; *command = prospective_command;
if (command_type) if (command_type)
*command_type = BROWSER_ACTION; *command_type = BROWSER_ACTION;
return true; return true;
} else if (GetPageActionCommand(extension_id, } else if (GetPageActionCommand(extension_id,
extensions::CommandService::ACTIVE_ONLY, CommandService::ACTIVE_ONLY,
&prospective_command, &prospective_command,
&active) && active && &active) &&
accelerator == prospective_command.accelerator()) { active && accelerator == prospective_command.accelerator()) {
if (command) if (command)
*command = prospective_command; *command = prospective_command;
if (command_type) if (command_type)
*command_type = PAGE_ACTION; *command_type = PAGE_ACTION;
return true; return true;
} else if (GetNamedCommands(extension_id, } else if (GetNamedCommands(extension_id,
extensions::CommandService::ACTIVE_ONLY, CommandService::ACTIVE_ONLY,
extensions::CommandService::REGULAR, CommandService::REGULAR,
&command_map)) { &command_map)) {
for (extensions::CommandMap::const_iterator it = command_map.begin(); for (CommandMap::const_iterator it = command_map.begin();
it != command_map.end(); ++it) { it != command_map.end();
++it) {
if (accelerator == it->second.accelerator()) { if (accelerator == it->second.accelerator()) {
if (command) if (command)
*command = it->second; *command = it->second;
...@@ -458,7 +436,7 @@ bool CommandService::GetBoundExtensionCommand( ...@@ -458,7 +436,7 @@ bool CommandService::GetBoundExtensionCommand(
} }
bool CommandService::OverridesBookmarkShortcut( bool CommandService::OverridesBookmarkShortcut(
const extensions::Extension* extension) const { const Extension* extension) const {
return RemovesBookmarkShortcut(extension) && return RemovesBookmarkShortcut(extension) &&
GetBoundExtensionCommand( GetBoundExtensionCommand(
extension->id(), extension->id(),
...@@ -468,8 +446,7 @@ bool CommandService::OverridesBookmarkShortcut( ...@@ -468,8 +446,7 @@ bool CommandService::OverridesBookmarkShortcut(
} }
void CommandService::AssignInitialKeybindings(const Extension* extension) { void CommandService::AssignInitialKeybindings(const Extension* extension) {
const extensions::CommandMap* commands = const CommandMap* commands = CommandsInfo::GetNamedCommands(extension);
CommandsInfo::GetNamedCommands(extension);
if (!commands) if (!commands)
return; return;
...@@ -478,9 +455,9 @@ void CommandService::AssignInitialKeybindings(const Extension* extension) { ...@@ -478,9 +455,9 @@ void CommandService::AssignInitialKeybindings(const Extension* extension) {
return; return;
SetInitialBindingsHaveBeenAssigned(extension_prefs, extension->id()); SetInitialBindingsHaveBeenAssigned(extension_prefs, extension->id());
extensions::CommandMap::const_iterator iter = commands->begin(); CommandMap::const_iterator iter = commands->begin();
for (; iter != commands->end(); ++iter) { for (; iter != commands->end(); ++iter) {
const extensions::Command command = iter->second; const Command command = iter->second;
if (CanAutoAssign(command.accelerator(), if (CanAutoAssign(command.accelerator(),
extension, extension,
profile_, profile_,
...@@ -494,7 +471,7 @@ void CommandService::AssignInitialKeybindings(const Extension* extension) { ...@@ -494,7 +471,7 @@ void CommandService::AssignInitialKeybindings(const Extension* extension) {
} }
} }
const extensions::Command* browser_action_command = const Command* browser_action_command =
CommandsInfo::GetBrowserActionCommand(extension); CommandsInfo::GetBrowserActionCommand(extension);
if (browser_action_command && if (browser_action_command &&
CanAutoAssign(browser_action_command->accelerator(), CanAutoAssign(browser_action_command->accelerator(),
...@@ -509,7 +486,7 @@ void CommandService::AssignInitialKeybindings(const Extension* extension) { ...@@ -509,7 +486,7 @@ void CommandService::AssignInitialKeybindings(const Extension* extension) {
false); // Not global. false); // Not global.
} }
const extensions::Command* page_action_command = const Command* page_action_command =
CommandsInfo::GetPageActionCommand(extension); CommandsInfo::GetPageActionCommand(extension);
if (page_action_command && if (page_action_command &&
CanAutoAssign(page_action_command->accelerator(), CanAutoAssign(page_action_command->accelerator(),
...@@ -577,7 +554,7 @@ void CommandService::RemoveKeybindingPrefs(const std::string& extension_id, ...@@ -577,7 +554,7 @@ void CommandService::RemoveKeybindingPrefs(const std::string& extension_id,
bool CommandService::GetExtensionActionCommand( bool CommandService::GetExtensionActionCommand(
const std::string& extension_id, 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 {
const ExtensionSet& extensions = const ExtensionSet& extensions =
...@@ -588,7 +565,7 @@ bool CommandService::GetExtensionActionCommand( ...@@ -588,7 +565,7 @@ bool CommandService::GetExtensionActionCommand(
if (active) if (active)
*active = false; *active = false;
const extensions::Command* requested_command = NULL; const Command* requested_command = NULL;
switch (action_type) { switch (action_type) {
case BROWSER_ACTION: case BROWSER_ACTION:
requested_command = CommandsInfo::GetBrowserActionCommand(extension); requested_command = CommandsInfo::GetBrowserActionCommand(extension);
...@@ -604,7 +581,7 @@ bool CommandService::GetExtensionActionCommand( ...@@ -604,7 +581,7 @@ bool CommandService::GetExtensionActionCommand(
return false; return false;
// Look up to see if the user has overridden how the command should work. // Look up to see if the user has overridden how the command should work.
extensions::Command saved_command = Command saved_command =
FindCommandByName(extension_id, requested_command->command_name()); FindCommandByName(extension_id, requested_command->command_name());
ui::Accelerator shortcut_assigned = saved_command.accelerator(); ui::Accelerator shortcut_assigned = saved_command.accelerator();
......
...@@ -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