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

Side by Side Diff: chrome/browser/extensions/api/commands/command_service.h

Issue 23812010: Implement first part of supporting global extension commands. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: No change, just reuploading (last attempt was incomplete) Created 7 years, 2 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 | Annotate | Revision Log
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_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 27 matching lines...) Expand all
38 class CommandService : public ProfileKeyedAPI, 38 class CommandService : public ProfileKeyedAPI,
39 public content::NotificationObserver { 39 public content::NotificationObserver {
40 public: 40 public:
41 // An enum specifying whether to fetch all extension commands or only active 41 // An enum specifying whether to fetch all extension commands or only active
42 // ones. 42 // ones.
43 enum QueryType { 43 enum QueryType {
44 ALL, 44 ALL,
45 ACTIVE_ONLY, 45 ACTIVE_ONLY,
46 }; 46 };
47 47
48 // An enum specifying whether the command is global in scope or not. Global
49 // commands -- unlike regular commands -- have a global keyboard hook
50 // associated with them (and therefore work when Chrome doesn't have focus).
51 enum CommandScope {
52 REGULAR,
53 GLOBAL,
54 ANY_SCOPE,
Yoyo Zhou 2013/10/03 22:08:50 What does this mean? (This is only used for queryi
Finnur 2013/10/04 17:57:02 Added comments. On 2013/10/03 22:08:50, Yoyo Zhou
55 };
56
48 // Register prefs for keybinding. 57 // Register prefs for keybinding.
49 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 58 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
50 59
51 // Constructs a CommandService object for the given profile. 60 // Constructs a CommandService object for the given profile.
52 explicit CommandService(Profile* profile); 61 explicit CommandService(Profile* profile);
53 virtual ~CommandService(); 62 virtual ~CommandService();
54 63
55 // ProfileKeyedAPI implementation. 64 // ProfileKeyedAPI implementation.
56 static ProfileKeyedAPIFactory<CommandService>* GetFactoryInstance(); 65 static ProfileKeyedAPIFactory<CommandService>* GetFactoryInstance();
57 66
(...skipping 29 matching lines...) Expand all
87 // is ACTIVE_ONLY. |command| contains the command found and |active| (if not 96 // is ACTIVE_ONLY. |command| contains the command found and |active| (if not
88 // NULL) contains whether |command| is active. 97 // NULL) contains whether |command| is active.
89 bool GetScriptBadgeCommand(const std::string& extension_id, 98 bool GetScriptBadgeCommand(const std::string& extension_id,
90 QueryType type, 99 QueryType type,
91 extensions::Command* command, 100 extensions::Command* command,
92 bool* active); 101 bool* active);
93 102
94 // Gets the active command (if any) for the named commands of an extension 103 // Gets the active command (if any) for the named commands of an extension
95 // given its |extension_id|. The function consults the master list to see if 104 // given its |extension_id|. The function consults the master list to see if
96 // the command is active. Returns an empty map if the extension has no 105 // the command is active. Returns an empty map if the extension has no
97 // named commands or no active named commands when |type| requested is 106 // named commands of the right |scope| or no active named commands when |type|
Yoyo Zhou 2013/10/03 22:08:50 ..."no such active named commands"...?
Finnur 2013/10/04 17:57:02 Done.
98 // ACTIVE_ONLY. 107 // requested is ACTIVE_ONLY.
99 bool GetNamedCommands(const std::string& extension_id, 108 bool GetNamedCommands(const std::string& extension_id,
100 QueryType type, 109 QueryType type,
110 CommandScope scope,
101 extensions::CommandMap* command_map); 111 extensions::CommandMap* command_map);
102 112
103 // Records a keybinding |accelerator| as active for an extension with id 113 // Records a keybinding |accelerator| as active for an extension with id
104 // |extension_id| and command with the name |command_name|. If 114 // |extension_id| and command with the name |command_name|. If
105 // |allow_overrides| is false, the keybinding must be free for the change to 115 // |allow_overrides| is false, the keybinding must be free for the change to
106 // be recorded (as determined by the master list in |user_prefs|). If 116 // be recorded (as determined by the master list in |user_prefs|). If
107 // |allow_overwrites| is true, any previously recorded keybinding for this 117 // |allow_overwrites| is true, any previously recorded keybinding for this
108 // |accelerator| will be overwritten. Returns true if the change was 118 // |accelerator| will be overwritten. Returns true if the change was
109 // successfully recorded. 119 // successfully recorded.
110 bool AddKeybindingPref(const ui::Accelerator& accelerator, 120 bool AddKeybindingPref(const ui::Accelerator& accelerator,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 181
172 // A weak pointer to the profile we are associated with. Not owned by us. 182 // A weak pointer to the profile we are associated with. Not owned by us.
173 Profile* profile_; 183 Profile* profile_;
174 184
175 DISALLOW_COPY_AND_ASSIGN(CommandService); 185 DISALLOW_COPY_AND_ASSIGN(CommandService);
176 }; 186 };
177 187
178 } // namespace extensions 188 } // namespace extensions
179 189
180 #endif // CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ 190 #endif // CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698