Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / extensions / extension_keybinding_registry_cocoa.h
blobe30bf2e00f1c5463ebe0c4b62bae9e8115e73bf0
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_COCOA_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_COCOA_H_
6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_COCOA_H_
8 #include <string>
9 #include <utility>
11 #include "chrome/browser/extensions/extension_keybinding_registry.h"
12 #include "ui/base/accelerators/accelerator.h"
13 #include "ui/base/accelerators/accelerator_manager.h"
14 #include "ui/gfx/native_widget_types.h"
16 class Profile;
18 namespace content {
19 struct NativeWebKeyboardEvent;
21 namespace extensions {
22 class Extension;
25 // The ExtensionKeybindingRegistryCocoa is the Cocoa specialization of the
26 // ExtensionKeybindingRegistry class that handles turning keyboard shortcuts
27 // into events that get sent to the extension.
29 // ExtensionKeybindingRegistryCocoa is a class that handles Cocoa-specific
30 // implemenation of the Extension Commands shortcuts (keyboard accelerators).
31 // It also routes the events to the intended recipient (ie. to the browser
32 // action button in case of browser action commands).
33 class ExtensionKeybindingRegistryCocoa
34 : public extensions::ExtensionKeybindingRegistry {
35 public:
36 ExtensionKeybindingRegistryCocoa(Profile* profile,
37 gfx::NativeWindow window,
38 ExtensionFilter extension_filter,
39 Delegate* delegate);
40 ~ExtensionKeybindingRegistryCocoa() override;
42 // For a given keyboard |event|, see if a known Extension Command registration
43 // exists and route the event to it. Returns true if the event was handled,
44 // false otherwise.
45 bool ProcessKeyEvent(const content::NativeWebKeyboardEvent& event,
46 ui::AcceleratorManager::HandlerPriority priority);
48 protected:
49 // Overridden from ExtensionKeybindingRegistry:
50 void AddExtensionKeybindings(const extensions::Extension* extension,
51 const std::string& command_name) override;
52 void RemoveExtensionKeybindingImpl(const ui::Accelerator& accelerator,
53 const std::string& command_name) override;
55 private:
56 // Weak pointer to the our profile. Not owned by us.
57 Profile* profile_;
59 // The window we are associated with.
60 gfx::NativeWindow window_;
62 // The content notification registrar for listening to extension events.
63 content::NotificationRegistrar registrar_;
65 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistryCocoa);
68 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_COCOA_H_