| 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_UI_VIEWS_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_VIEWS_H
_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_VIEWS_H
_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_VIEWS_H
_ | 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_VIEWS_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 "chrome/browser/extensions/extension_keybinding_registry.h" | 11 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
| 12 #include "ui/base/accelerators/accelerator.h" | 12 #include "ui/base/accelerators/accelerator.h" |
| 13 #include "ui/base/accelerators/accelerator_processor.h" |
| 13 | 14 |
| 14 class Profile; | 15 class Profile; |
| 15 | 16 |
| 16 namespace extensions { | 17 namespace extensions { |
| 17 class Extension; | 18 class Extension; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace views { | 21 namespace views { |
| 21 class FocusManager; | 22 class FocusManager; |
| 22 } | 23 } |
| 23 | 24 |
| 24 // ExtensionKeybindingRegistryViews is a class that handles Views-specific | 25 // ExtensionKeybindingRegistryViews is a class that handles Views-specific |
| 25 // implementation of the Extension Keybinding shortcuts (keyboard accelerators). | 26 // implementation of the Extension Keybinding shortcuts (keyboard accelerators). |
| 26 // Note: It handles regular extension commands (not browserAction and pageAction | 27 // Note: It handles regular extension commands (not browserAction and pageAction |
| 27 // popups, which are handled elsewhere). This class registers the accelerators | 28 // popups, which are handled elsewhere). This class registers the accelerators |
| 28 // on behalf of the extensions and routes the commands to them via the | 29 // on behalf of the extensions and routes the commands to them via the |
| 29 // BrowserEventRouter. | 30 // BrowserEventRouter. |
| 30 class ExtensionKeybindingRegistryViews | 31 class ExtensionKeybindingRegistryViews |
| 31 : public extensions::ExtensionKeybindingRegistry, | 32 : public extensions::ExtensionKeybindingRegistry, |
| 33 public ui::AcceleratorProcessor, |
| 32 public ui::AcceleratorTarget { | 34 public ui::AcceleratorTarget { |
| 33 public: | 35 public: |
| 34 ExtensionKeybindingRegistryViews(Profile* profile, | 36 ExtensionKeybindingRegistryViews(Profile* profile, |
| 35 views::FocusManager* focus_manager, | 37 views::FocusManager* focus_manager, |
| 36 ExtensionFilter extension_filter, | 38 ExtensionFilter extension_filter, |
| 37 Delegate* delegate); | 39 Delegate* delegate); |
| 38 ~ExtensionKeybindingRegistryViews() override; | 40 ~ExtensionKeybindingRegistryViews() override; |
| 39 | 41 |
| 42 // Overridden from ui::AcceleratorProcessor: |
| 43 bool ProcessAccelerator(const ui::Accelerator& accelerator) override; |
| 44 ui::AcceleratorTarget* GetTargetForAccelerator( |
| 45 const ui::Accelerator& accelerator) const override; |
| 46 |
| 40 // Overridden from ui::AcceleratorTarget. | 47 // Overridden from ui::AcceleratorTarget. |
| 41 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 48 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
| 42 bool CanHandleAccelerators() const override; | 49 bool CanHandleAccelerators() const override; |
| 43 | 50 |
| 44 private: | 51 private: |
| 45 // Overridden from ExtensionKeybindingRegistry: | 52 // Overridden from ExtensionKeybindingRegistry: |
| 46 void AddExtensionKeybinding(const extensions::Extension* extension, | 53 void AddExtensionKeybinding(const extensions::Extension* extension, |
| 47 const std::string& command_name) override; | 54 const std::string& command_name) override; |
| 48 void RemoveExtensionKeybindingImpl(const ui::Accelerator& accelerator, | 55 void RemoveExtensionKeybindingImpl(const ui::Accelerator& accelerator, |
| 49 const std::string& command_name) override; | 56 const std::string& command_name) override; |
| 50 | 57 |
| 51 // Weak pointer to the our profile. Not owned by us. | 58 // Weak pointer to the our profile. Not owned by us. |
| 52 Profile* profile_; | 59 Profile* profile_; |
| 53 | 60 |
| 54 // Weak pointer back to the focus manager to use to register and unregister | 61 // Weak pointer back to the focus manager to use to register and unregister |
| 55 // accelerators with. Not owned by us. | 62 // accelerators with. Not owned by us. |
| 56 views::FocusManager* focus_manager_; | 63 views::FocusManager* focus_manager_; |
| 57 | 64 |
| 58 // The content notification registrar for listening to extension events. | 65 // The content notification registrar for listening to extension events. |
| 59 content::NotificationRegistrar registrar_; | 66 content::NotificationRegistrar registrar_; |
| 60 | 67 |
| 61 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistryViews); | 68 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistryViews); |
| 62 }; | 69 }; |
| 63 | 70 |
| 64 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_VIEW
S_H_ | 71 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_VIEW
S_H_ |
| OLD | NEW |