| OLD | NEW |
| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "content/public/browser/notification_details.h" | 12 #include "content/public/browser/notification_details.h" |
| 13 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
| 14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 15 #include "content/public/browser/notification_source.h" | 15 #include "content/public/browser/notification_source.h" |
| 16 | 16 |
| 17 class Extension; | |
| 18 class Profile; | 17 class Profile; |
| 19 | 18 |
| 20 namespace extensions { | 19 namespace extensions { |
| 21 | 20 |
| 21 class Extension; |
| 22 |
| 22 // The ExtensionKeybindingRegistry is a class that handles the cross-platform | 23 // The ExtensionKeybindingRegistry is a class that handles the cross-platform |
| 23 // logic for keyboard accelerators. See platform-specific implementations for | 24 // logic for keyboard accelerators. See platform-specific implementations for |
| 24 // implementation details for each platform. | 25 // implementation details for each platform. |
| 25 class ExtensionKeybindingRegistry : public content::NotificationObserver { | 26 class ExtensionKeybindingRegistry : public content::NotificationObserver { |
| 26 public: | 27 public: |
| 27 explicit ExtensionKeybindingRegistry(Profile* profile); | 28 explicit ExtensionKeybindingRegistry(Profile* profile); |
| 28 virtual ~ExtensionKeybindingRegistry(); | 29 virtual ~ExtensionKeybindingRegistry(); |
| 29 | 30 |
| 30 // Overridden from content::NotificationObserver: | 31 // Overridden from content::NotificationObserver: |
| 31 virtual void Observe(int type, | 32 virtual void Observe(int type, |
| 32 const content::NotificationSource& source, | 33 const content::NotificationSource& source, |
| 33 const content::NotificationDetails& details) OVERRIDE; | 34 const content::NotificationDetails& details) OVERRIDE; |
| 34 | 35 |
| 35 protected: | 36 protected: |
| 36 // Add extension keybinding for the events defined by the |extension|. | 37 // Add extension keybinding for the events defined by the |extension|. |
| 37 virtual void AddExtensionKeybinding(const Extension* extension) = 0; | 38 virtual void AddExtensionKeybinding( |
| 39 const Extension* extension) = 0; |
| 38 // Remove extension bindings for |extension|. | 40 // Remove extension bindings for |extension|. |
| 39 virtual void RemoveExtensionKeybinding(const Extension* extension) = 0; | 41 virtual void RemoveExtensionKeybinding( |
| 42 const Extension* extension) = 0; |
| 40 | 43 |
| 41 // Make sure all extensions registered have keybindings added. | 44 // Make sure all extensions registered have keybindings added. |
| 42 void Init(); | 45 void Init(); |
| 43 | 46 |
| 44 // Whether to ignore this command. Only browserAction commands and pageAction | 47 // Whether to ignore this command. Only browserAction commands and pageAction |
| 45 // commands are currently ignored, since they are handled elsewhere. | 48 // commands are currently ignored, since they are handled elsewhere. |
| 46 bool ShouldIgnoreCommand(const std::string& command) const; | 49 bool ShouldIgnoreCommand(const std::string& command) const; |
| 47 | 50 |
| 48 private: | 51 private: |
| 49 // The content notification registrar for listening to extension events. | 52 // The content notification registrar for listening to extension events. |
| 50 content::NotificationRegistrar registrar_; | 53 content::NotificationRegistrar registrar_; |
| 51 | 54 |
| 52 // Weak pointer to the our profile. Not owned by us. | 55 // Weak pointer to the our profile. Not owned by us. |
| 53 Profile* profile_; | 56 Profile* profile_; |
| 54 | 57 |
| 55 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistry); | 58 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistry); |
| 56 }; | 59 }; |
| 57 | 60 |
| 58 } // namespace extensions | 61 } // namespace extensions |
| 59 | 62 |
| 60 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ | 63 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ |
| OLD | NEW |