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

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

Issue 10317014: Move Command class out of the Extension class and into its own location (under chrome/common/exten… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | 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_EXTENSION_COMMAND_SERVICE_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_COMMANDS_EXTENSION_COMMAND_SERVICE_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_COMMANDS_EXTENSION_COMMAND_SERVICE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_COMMANDS_EXTENSION_COMMAND_SERVICE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "chrome/browser/profiles/profile_keyed_service.h" 12 #include "chrome/browser/profiles/profile_keyed_service.h"
13 #include "chrome/common/extensions/extension.h" 13 #include "chrome/common/extensions/extension.h"
14 #include "chrome/common/extensions/extension_commands.h"
14 #include "content/public/browser/notification_details.h" 15 #include "content/public/browser/notification_details.h"
15 #include "content/public/browser/notification_observer.h" 16 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_registrar.h" 17 #include "content/public/browser/notification_registrar.h"
17 #include "content/public/browser/notification_source.h" 18 #include "content/public/browser/notification_source.h"
18 19
19 class PrefService; 20 class PrefService;
20 class Profile; 21 class Profile;
21 22
22 namespace ui { 23 namespace ui {
23 class Accelerator; 24 class Accelerator;
24 } 25 }
25 26
26 // This service keeps track of preferences related to extension commands 27 // This service keeps track of preferences related to extension commands
27 // (assigning initial keybindings on install and removing them on deletion 28 // (assigning initial keybindings on install and removing them on deletion
28 // and answers questions related to which commands are active. 29 // and answers questions related to which commands are active.
29 class ExtensionCommandService : public ProfileKeyedService, 30 class ExtensionCommandService : public ProfileKeyedService,
30 public content::NotificationObserver { 31 public content::NotificationObserver {
31 public: 32 public:
32 // Register prefs for keybinding. 33 // Register prefs for keybinding.
33 static void RegisterUserPrefs(PrefService* user_prefs); 34 static void RegisterUserPrefs(PrefService* user_prefs);
34 35
35 // Constructs an ExtensionCommandService object for the given profile. 36 // Constructs an ExtensionCommandService object for the given profile.
36 explicit ExtensionCommandService(Profile* profile); 37 explicit ExtensionCommandService(Profile* profile);
37 virtual ~ExtensionCommandService(); 38 virtual ~ExtensionCommandService();
38 39
39 // Gets the active keybinding (if any) for the browser action of an extension 40 // Gets the active keybinding (if any) for the browser action of an extension
40 // given its |extension_id|. The function consults the master list to see if 41 // given its |extension_id|. The function consults the master list to see if
41 // the keybinding is active. Returns NULL if the extension has no browser 42 // the keybinding is active. Returns NULL if the extension has no browser
42 // action or no active keybinding for it. 43 // action or no active keybinding for it.
43 const Extension::Command* GetActiveBrowserActionCommand( 44 const extensions::Command* GetActiveBrowserActionCommand(
44 const std::string& extension_id); 45 const std::string& extension_id);
45 46
46 // Gets the active keybinding (if any) for the page action of an extension 47 // Gets the active keybinding (if any) for the page action of an extension
47 // given its |extension_id|. The function consults the master list to see if 48 // given its |extension_id|. The function consults the master list to see if
48 // the keybinding is active. Returns NULL if the extension has no page action 49 // the keybinding is active. Returns NULL if the extension has no page action
49 // or no active keybinding for it. 50 // or no active keybinding for it.
50 const Extension::Command* GetActivePageActionCommand( 51 const extensions::Command* GetActivePageActionCommand(
51 const std::string& extension_id); 52 const std::string& extension_id);
52 53
53 // Gets the active keybinding (if any) for the named commands of an extension 54 // Gets the active keybinding (if any) for the named commands of an extension
54 // given its |extension_id|. The function consults the master list to see if 55 // given its |extension_id|. The function consults the master list to see if
55 // the keybinding is active. Returns an empty map if the extension has no 56 // the keybinding is active. Returns an empty map if the extension has no
56 // named commands or no active keybinding for the commands. 57 // named commands or no active keybinding for the commands.
57 Extension::CommandMap GetActiveNamedCommands(const std::string& extension_id); 58 extensions::CommandMap GetActiveNamedCommands(
59 const std::string& extension_id);
58 60
59 // Checks to see if a keybinding |accelerator| for a given |command_name| in 61 // Checks to see if a keybinding |accelerator| for a given |command_name| in
60 // an extension with id |extension_id| is registered as active (by consulting 62 // an extension with id |extension_id| is registered as active (by consulting
61 // the master list in |user_prefs|). 63 // the master list in |user_prefs|).
62 bool IsKeybindingActive(const ui::Accelerator& accelerator, 64 bool IsKeybindingActive(const ui::Accelerator& accelerator,
63 std::string extension_id, 65 std::string extension_id,
64 std::string command_name); 66 std::string command_name);
65 67
66 // Records a keybinding |accelerator| as active for an extension with id 68 // Records a keybinding |accelerator| as active for an extension with id
67 // |extension_id| and command with the name |command_name|. If 69 // |extension_id| and command with the name |command_name|. If
(...skipping 26 matching lines...) Expand all
94 // The content notification registrar for listening to extension events. 96 // The content notification registrar for listening to extension events.
95 content::NotificationRegistrar registrar_; 97 content::NotificationRegistrar registrar_;
96 98
97 // A weak pointer to the profile we are associated with. Not owned by us. 99 // A weak pointer to the profile we are associated with. Not owned by us.
98 Profile* profile_; 100 Profile* profile_;
99 101
100 DISALLOW_COPY_AND_ASSIGN(ExtensionCommandService); 102 DISALLOW_COPY_AND_ASSIGN(ExtensionCommandService);
101 }; 103 };
102 104
103 #endif // CHROME_BROWSER_EXTENSIONS_API_COMMANDS_EXTENSION_COMMAND_SERVICE_H_ 105 #endif // CHROME_BROWSER_EXTENSIONS_API_COMMANDS_EXTENSION_COMMAND_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698