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

Unified Diff: chrome/browser/ui/webui/extensions/command_handler.cc

Issue 280853004: Use EventRouter::Get instead of ExtensionSystem::Get(browser_context)->event_router() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 6 years, 7 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/ui/webui/extensions/command_handler.cc
diff --git a/chrome/browser/ui/webui/extensions/command_handler.cc b/chrome/browser/ui/webui/extensions/command_handler.cc
index e444592004a0845ba75671ee73296c95edbb210d..076117914731c4f521886c7ef2bf30c095ba0797 100644
--- a/chrome/browser/ui/webui/extensions/command_handler.cc
+++ b/chrome/browser/ui/webui/extensions/command_handler.cc
@@ -6,7 +6,6 @@
#include "base/bind.h"
#include "base/values.h"
-#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/api/commands/command_service.h"
#include "chrome/browser/extensions/extension_commands_global_registry.h"
#include "chrome/browser/extensions/extension_keybinding_registry.h"
@@ -14,6 +13,7 @@
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension_set.h"
#include "grit/generated_resources.h"
@@ -21,7 +21,8 @@
namespace extensions {
-CommandHandler::CommandHandler(Profile* profile) : profile_(profile) {
+CommandHandler::CommandHandler(Profile* profile)
+ : profile_(profile), extension_registry_observer_(this) {
}
CommandHandler::~CommandHandler() {
@@ -46,11 +47,8 @@ void CommandHandler::GetLocalizedValues(content::WebUIDataSource* source) {
}
void CommandHandler::RegisterMessages() {
- 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(
+ extensions::ExtensionRegistry::Get(profile_));
web_ui()->RegisterMessageCallback("extensionCommandsRequestExtensionsData",
base::Bind(&CommandHandler::HandleRequestExtensionsData,
@@ -66,12 +64,15 @@ void CommandHandler::RegisterMessages() {
base::Unretained(this)));
}
-void CommandHandler::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK(type == chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED ||
- type == chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED);
+void CommandHandler::OnExtensionLoaded(content::BrowserContext* browser_context,
+ const extensions::Extension* extension) {
+ UpdateCommandDataOnPage();
+}
+
+void CommandHandler::OnExtensionUnloaded(
+ content::BrowserContext* browser_context,
+ const extensions::Extension* extension,
+ extensions::UnloadedExtensionInfo::Reason reason) {
UpdateCommandDataOnPage();
}

Powered by Google App Engine
This is Rietveld 408576698