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

Side by Side Diff: chrome/browser/extensions/extension_keybinding_registry.h

Issue 10911020: Enable commands API for platform apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: filter by extension type instead of specific extensions Created 8 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_keybinding_registry.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_EXTENSION_KEYBINDING_REGISTRY_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "content/public/browser/notification_details.h" 11 #include "content/public/browser/notification_details.h"
12 #include "content/public/browser/notification_observer.h" 12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h" 13 #include "content/public/browser/notification_registrar.h"
14 #include "content/public/browser/notification_source.h" 14 #include "content/public/browser/notification_source.h"
15 15
16 class Profile; 16 class Profile;
17 17
18 namespace extensions { 18 namespace extensions {
19 19
20 class Extension; 20 class Extension;
21 21
22 // The ExtensionKeybindingRegistry is a class that handles the cross-platform 22 // The ExtensionKeybindingRegistry is a class that handles the cross-platform
23 // logic for keyboard accelerators. See platform-specific implementations for 23 // logic for keyboard accelerators. See platform-specific implementations for
24 // implementation details for each platform. 24 // implementation details for each platform.
25 class ExtensionKeybindingRegistry : public content::NotificationObserver { 25 class ExtensionKeybindingRegistry : public content::NotificationObserver {
26 public: 26 public:
27 explicit ExtensionKeybindingRegistry(Profile* profile); 27 enum ExtensionFilter {
28 ALL_EXTENSIONS,
29 PLATFORM_APP_ONLY
Mihai Parparita -not on Chrome 2012/09/04 22:09:46 Nit: call this PLATFORM_APPS_ONLY.
30 };
31
32 // If |extension_filter| is not ALL_EXTENSIONS, only keybindings by
33 // by extensions that match the filter will be registered.
34 ExtensionKeybindingRegistry(Profile* profile,
35 ExtensionFilter extension_filter);
28 virtual ~ExtensionKeybindingRegistry(); 36 virtual ~ExtensionKeybindingRegistry();
29 37
30 // Enables/Disables general shortcut handing in Chrome. Implemented in 38 // Enables/Disables general shortcut handing in Chrome. Implemented in
31 // platform-specific ExtensionKeybindingsRegistry* files. 39 // platform-specific ExtensionKeybindingsRegistry* files.
32 static void SetShortcutHandlingSuspended(bool suspended); 40 static void SetShortcutHandlingSuspended(bool suspended);
33 41
34 // Overridden from content::NotificationObserver: 42 // Overridden from content::NotificationObserver:
35 virtual void Observe(int type, 43 virtual void Observe(int type,
36 const content::NotificationSource& source, 44 const content::NotificationSource& source,
37 const content::NotificationDetails& details) OVERRIDE; 45 const content::NotificationDetails& details) OVERRIDE;
(...skipping 12 matching lines...) Expand all
50 const std::string& command_name) = 0; 58 const std::string& command_name) = 0;
51 59
52 // Make sure all extensions registered have keybindings added. 60 // Make sure all extensions registered have keybindings added.
53 void Init(); 61 void Init();
54 62
55 // Whether to ignore this command. Only browserAction commands and pageAction 63 // Whether to ignore this command. Only browserAction commands and pageAction
56 // commands are currently ignored, since they are handled elsewhere. 64 // commands are currently ignored, since they are handled elsewhere.
57 bool ShouldIgnoreCommand(const std::string& command) const; 65 bool ShouldIgnoreCommand(const std::string& command) const;
58 66
59 private: 67 private:
68 // Returns true if the |extension| matches our extension filter.
69 bool ExtensionMatchesFilter(const extensions::Extension* extension);
70
60 // The content notification registrar for listening to extension events. 71 // The content notification registrar for listening to extension events.
61 content::NotificationRegistrar registrar_; 72 content::NotificationRegistrar registrar_;
62 73
63 // Weak pointer to the our profile. Not owned by us. 74 // Weak pointer to our profile. Not owned by us.
64 Profile* profile_; 75 Profile* profile_;
65 76
77 // What extensions to register keybindings for.
78 ExtensionFilter extension_filter_;
79
66 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistry); 80 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistry);
67 }; 81 };
68 82
69 } // namespace extensions 83 } // namespace extensions
70 84
71 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ 85 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_keybinding_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698