Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: chrome/browser/extensions/extension_keybinding_registry.h

Issue 838253004: MacViews: Fix duplicate definition of ExtensionKeyBindingRegistry::SetShortcutHandlingSuspended (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@DragBookmarks2
Patch Set: Fix Mac Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 }; 50 };
51 51
52 // If |extension_filter| is not ALL_EXTENSIONS, only keybindings by 52 // If |extension_filter| is not ALL_EXTENSIONS, only keybindings by
53 // by extensions that match the filter will be registered. 53 // by extensions that match the filter will be registered.
54 ExtensionKeybindingRegistry(content::BrowserContext* context, 54 ExtensionKeybindingRegistry(content::BrowserContext* context,
55 ExtensionFilter extension_filter, 55 ExtensionFilter extension_filter,
56 Delegate* delegate); 56 Delegate* delegate);
57 57
58 ~ExtensionKeybindingRegistry() override; 58 ~ExtensionKeybindingRegistry() override;
59 59
60 // Enables/Disables general shortcut handling in Chrome. Implemented in 60 // Enables/Disables general shortcut handling in Chrome.
61 // platform-specific ExtensionKeybindingsRegistry* files. 61 void SetShortcutHandlingSuspended(bool suspended);
62 static void SetShortcutHandlingSuspended(bool suspended); 62 bool shortcut_handling_suspended() const {
63 return shortcut_handling_suspended_;
64 }
63 65
64 // Execute the command bound to |accelerator| and provided by the extension 66 // Execute the command bound to |accelerator| and provided by the extension
65 // with |extension_id|, if it exists. 67 // with |extension_id|, if it exists.
66 void ExecuteCommand(const std::string& extension_id, 68 void ExecuteCommand(const std::string& extension_id,
67 const ui::Accelerator& accelerator); 69 const ui::Accelerator& accelerator);
68 70
69 // Check whether the specified |accelerator| has been registered. 71 // Check whether the specified |accelerator| has been registered.
70 bool IsAcceleratorRegistered(const ui::Accelerator& accelerator) const; 72 bool IsAcceleratorRegistered(const ui::Accelerator& accelerator) const;
71 73
72 protected: 74 protected:
73 // Add extension keybindings for the events defined by the |extension|. 75 // Add extension keybindings for the events defined by the |extension|.
74 // |command_name| is optional, but if not blank then only the command 76 // |command_name| is optional, but if not blank then only the command
75 // specified will be added. 77 // specified will be added.
76 virtual void AddExtensionKeybindings( 78 virtual void AddExtensionKeybindings(
77 const Extension* extension, 79 const Extension* extension,
78 const std::string& command_name) = 0; 80 const std::string& command_name) = 0;
79 // Remove extension bindings for |extension|. |command_name| is optional, 81 // Remove extension bindings for |extension|. |command_name| is optional,
80 // but if not blank then only the command specified will be removed. 82 // but if not blank then only the command specified will be removed.
81 void RemoveExtensionKeybinding( 83 void RemoveExtensionKeybinding(
82 const Extension* extension, 84 const Extension* extension,
83 const std::string& command_name); 85 const std::string& command_name);
84 // Overridden by platform specific implementations to provide additional 86 // Overridden by platform specific implementations to provide additional
85 // unregistration (which varies between platforms). 87 // unregistration (which varies between platforms).
86 virtual void RemoveExtensionKeybindingImpl( 88 virtual void RemoveExtensionKeybindingImpl(
87 const ui::Accelerator& accelerator, 89 const ui::Accelerator& accelerator,
88 const std::string& command_name) = 0; 90 const std::string& command_name) = 0;
89 91
92 // Called when shortcut handling is suspended or resumed.
93 virtual void OnShortcutHandlingSuspended(bool suspended) {}
94
90 // Make sure all extensions registered have keybindings added. 95 // Make sure all extensions registered have keybindings added.
91 void Init(); 96 void Init();
92 97
93 // Whether to ignore this command. Only browserAction commands and pageAction 98 // Whether to ignore this command. Only browserAction commands and pageAction
94 // commands are currently ignored, since they are handled elsewhere. 99 // commands are currently ignored, since they are handled elsewhere.
95 bool ShouldIgnoreCommand(const std::string& command) const; 100 bool ShouldIgnoreCommand(const std::string& command) const;
96 101
97 // Fire event targets which the specified |accelerator| is binding with. 102 // Fire event targets which the specified |accelerator| is binding with.
98 // Returns true if we can find the appropriate event targets. 103 // Returns true if we can find the appropriate event targets.
99 bool NotifyEventTargets(const ui::Accelerator& accelerator); 104 bool NotifyEventTargets(const ui::Accelerator& accelerator);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // accelerator (which isn't media keys) has only one target, while the media 171 // accelerator (which isn't media keys) has only one target, while the media
167 // keys can have more than one. 172 // keys can have more than one.
168 typedef std::list<std::pair<std::string, std::string> > TargetList; 173 typedef std::list<std::pair<std::string, std::string> > TargetList;
169 typedef std::map<ui::Accelerator, TargetList> EventTargets; 174 typedef std::map<ui::Accelerator, TargetList> EventTargets;
170 EventTargets event_targets_; 175 EventTargets event_targets_;
171 176
172 // Listen to extension load, unloaded notifications. 177 // Listen to extension load, unloaded notifications.
173 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 178 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
174 extension_registry_observer_; 179 extension_registry_observer_;
175 180
181 // Keeps track of whether shortcut handling is currently suspended. Shortcuts
182 // are suspended briefly while capturing which shortcut to assign to an
183 // extension command in the Config UI. If handling isn't suspended while
184 // capturing then trying to assign Ctrl+F to a command would instead result
185 // in the Find box opening.
186 bool shortcut_handling_suspended_;
187
176 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistry); 188 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistry);
177 }; 189 };
178 190
179 } // namespace extensions 191 } // namespace extensions
180 192
181 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ 193 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698