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