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 virtual ~ExtensionKeybindingRegistryViews();
40 // Overridden from ui::AcceleratorTarget.
41 virtual bool AcceleratorPressed(const ui::Accelerator
& accelerator
) OVERRIDE
;
42 virtual bool CanHandleAccelerators() const OVERRIDE
;
45 // Overridden from ExtensionKeybindingRegistry:
46 virtual void AddExtensionKeybinding(
47 const extensions::Extension
* extension
,
48 const std::string
& command_name
) OVERRIDE
;
49 virtual void RemoveExtensionKeybindingImpl(
50 const ui::Accelerator
& accelerator
,
51 const std::string
& command_name
) OVERRIDE
;
53 // Weak pointer to the our profile. Not owned by us.
56 // Weak pointer back to the focus manager to use to register and unregister
57 // accelerators with. Not owned by us.
58 views::FocusManager
* focus_manager_
;
60 // The content notification registrar for listening to extension events.
61 content::NotificationRegistrar registrar_
;
63 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistryViews
);
66 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_VIEWS_H_