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

Side by Side Diff: chrome/browser/ui/webui/extensions/command_handler.h

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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_WEBUI_EXTENSIONS_COMMAND_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_EXTENSIONS_COMMAND_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_COMMAND_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_COMMAND_HANDLER_H_
7 7
8 #include "base/scoped_observer.h"
8 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
9 #include "content/public/browser/notification_observer.h"
10 #include "content/public/browser/notification_registrar.h"
11 #include "content/public/browser/web_ui_message_handler.h" 10 #include "content/public/browser/web_ui_message_handler.h"
11 #include "extensions/browser/extension_registry_observer.h"
12 12
13 namespace base { 13 namespace base {
14 class DictionaryValue; 14 class DictionaryValue;
15 class ListValue; 15 class ListValue;
16 } 16 }
17 17
18 namespace content { 18 namespace content {
19 class WebUIDataSource; 19 class WebUIDataSource;
20 } 20 }
21 21
22 namespace extensions { 22 namespace extensions {
23 class Command; 23 class Command;
24 class CommandService; 24 class CommandService;
25 class ExtensionRegistry;
25 } 26 }
26 27
27 class Extension; 28 class Extension;
28 class Profile; 29 class Profile;
29 30
30 namespace extensions { 31 namespace extensions {
31 32
32 // The handler page for the Extension Commands UI overlay. 33 // The handler page for the Extension Commands UI overlay.
33 class CommandHandler : public content::WebUIMessageHandler, 34 class CommandHandler : public content::WebUIMessageHandler,
34 public content::NotificationObserver { 35 public extensions::ExtensionRegistryObserver {
35 public: 36 public:
36 explicit CommandHandler(Profile* profile); 37 explicit CommandHandler(Profile* profile);
37 virtual ~CommandHandler(); 38 virtual ~CommandHandler();
38 39
39 // Fetches the localized values for the page and deposits them into |source|. 40 // Fetches the localized values for the page and deposits them into |source|.
40 void GetLocalizedValues(content::WebUIDataSource* source); 41 void GetLocalizedValues(content::WebUIDataSource* source);
41 42
42 // WebUIMessageHandler implementation. 43 // WebUIMessageHandler implementation.
43 virtual void RegisterMessages() OVERRIDE; 44 virtual void RegisterMessages() OVERRIDE;
44 45
45 // NotificationObserver implementation. 46 private:
46 virtual void Observe(int type, 47 // extension::ExtensionRegistryObserver implementation.
Devlin 2014/05/16 17:34:04 nit: extensions::
47 const content::NotificationSource& source, 48 virtual void OnExtensionLoaded(
48 const content::NotificationDetails& details) OVERRIDE; 49 content::BrowserContext* browser_context,
50 const extensions::Extension* extension) OVERRIDE;
51 virtual void OnExtensionUnloaded(
52 content::BrowserContext* browser_context,
53 const extensions::Extension* extension,
54 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE;
49 55
50 private:
51 // Update the list of extension commands in the config UI. 56 // Update the list of extension commands in the config UI.
52 void UpdateCommandDataOnPage(); 57 void UpdateCommandDataOnPage();
53 58
54 // Handles requests from javascript to fetch the extensions data, including 59 // Handles requests from javascript to fetch the extensions data, including
55 // the commands it contains. 60 // the commands it contains.
56 // Replies back through: ExtensionCommandsOverlay.returnExtensionsData. 61 // Replies back through: ExtensionCommandsOverlay.returnExtensionsData.
57 void HandleRequestExtensionsData(const base::ListValue* args); 62 void HandleRequestExtensionsData(const base::ListValue* args);
58 63
59 // Handles requests from javascript to set a particular keyboard shortcut 64 // Handles requests from javascript to set a particular keyboard shortcut
60 // for a given extension command. 65 // for a given extension command.
61 void HandleSetExtensionCommandShortcut(const base::ListValue* args); 66 void HandleSetExtensionCommandShortcut(const base::ListValue* args);
62 67
63 // Handles requests from javascript to change the scope of a particular 68 // Handles requests from javascript to change the scope of a particular
64 // keyboard shortcut for a given extension command. 69 // keyboard shortcut for a given extension command.
65 void HandleSetCommandScope(const base::ListValue* args); 70 void HandleSetCommandScope(const base::ListValue* args);
66 71
67 // Handles requests from javascript to temporarily disable general Chrome 72 // Handles requests from javascript to temporarily disable general Chrome
68 // shortcut handling while the web page is capturing which shortcut to use. 73 // shortcut handling while the web page is capturing which shortcut to use.
69 void HandleSetShortcutHandlingSuspended(const base::ListValue* args); 74 void HandleSetShortcutHandlingSuspended(const base::ListValue* args);
70 75
71 // Fetches all known commands, active and inactive and returns them through 76 // Fetches all known commands, active and inactive and returns them through
72 // |commands|. 77 // |commands|.
73 void GetAllCommands(base::DictionaryValue* commands); 78 void GetAllCommands(base::DictionaryValue* commands);
74 79
75 content::NotificationRegistrar registrar_; 80 Profile* profile_;
76 81
77 Profile* profile_; 82 ScopedObserver<extensions::ExtensionRegistry,
83 extensions::ExtensionRegistryObserver>
84 extension_registry_observer_;
78 85
79 DISALLOW_COPY_AND_ASSIGN(CommandHandler); 86 DISALLOW_COPY_AND_ASSIGN(CommandHandler);
80 }; 87 };
81 88
82 } // namespace extensions 89 } // namespace extensions
83 90
84 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_COMMAND_HANDLER_H_ 91 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_COMMAND_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698