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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_VIEWS_H_
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_VIEWS_H_
10 #include "base/compiler_specific.h"
11 #include "chrome/browser/extensions/extension_keybinding_registry.h"
12 #include "ui/base/accelerators/accelerator.h"
16 namespace extensions
{
24 // ExtensionKeybindingRegistryViews is a class that handles Views-specific
25 // implementation of the Extension Keybinding shortcuts (keyboard accelerators).
26 // Note: It handles regular extension commands (not browserAction and pageAction
27 // 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 // BrowserEventRouter.
30 class ExtensionKeybindingRegistryViews
31 : public extensions::ExtensionKeybindingRegistry
,
32 public ui::AcceleratorTarget
{
34 ExtensionKeybindingRegistryViews(Profile
* profile
,
35 views::FocusManager
* focus_manager
,
36 ExtensionFilter extension_filter
,
38 ~ExtensionKeybindingRegistryViews() override
;
40 // Overridden from ui::AcceleratorTarget.
41 bool AcceleratorPressed(const ui::Accelerator
& accelerator
) override
;
42 bool CanHandleAccelerators() const override
;
45 // Overridden from ExtensionKeybindingRegistry:
46 void AddExtensionKeybindings(const extensions::Extension
* extension
,
47 const std::string
& command_name
) override
;
48 void RemoveExtensionKeybindingImpl(const ui::Accelerator
& accelerator
,
49 const std::string
& command_name
) override
;
50 void OnShortcutHandlingSuspended(bool suspended
) override
;
52 // Weak pointer to the our profile. Not owned by us.
55 // Weak pointer back to the focus manager to use to register and unregister
56 // accelerators with. Not owned by us.
57 views::FocusManager
* focus_manager_
;
59 // The content notification registrar for listening to extension events.
60 content::NotificationRegistrar registrar_
;
62 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistryViews
);
65 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_VIEWS_H_