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 #include "chrome/browser/extensions/extension_keybinding_registry.h" | 5 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/values.h" | 9 #include "base/values.h" |
8 #include "chrome/browser/extensions/active_tab_permission_granter.h" | 10 #include "chrome/browser/extensions/active_tab_permission_granter.h" |
9 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/common/extensions/command.h" | 12 #include "chrome/common/extensions/command.h" |
11 #include "content/public/browser/browser_context.h" | 13 #include "content/public/browser/browser_context.h" |
12 #include "extensions/browser/event_router.h" | 14 #include "extensions/browser/event_router.h" |
13 #include "extensions/browser/extension_registry.h" | 15 #include "extensions/browser/extension_registry.h" |
14 #include "extensions/browser/notification_types.h" | 16 #include "extensions/browser/notification_types.h" |
15 #include "extensions/common/extension_set.h" | 17 #include "extensions/common/extension_set.h" |
16 #include "extensions/common/manifest_constants.h" | 18 #include "extensions/common/manifest_constants.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // not set the delegate as it deals only with named commands (not page/browser | 115 // not set the delegate as it deals only with named commands (not page/browser |
114 // actions that are associated with the current page directly). | 116 // actions that are associated with the current page directly). |
115 ActiveTabPermissionGranter* granter = | 117 ActiveTabPermissionGranter* granter = |
116 delegate_ ? delegate_->GetActiveTabPermissionGranter() : NULL; | 118 delegate_ ? delegate_->GetActiveTabPermissionGranter() : NULL; |
117 if (granter) | 119 if (granter) |
118 granter->GrantIfRequested(extension); | 120 granter->GrantIfRequested(extension); |
119 | 121 |
120 scoped_ptr<base::ListValue> args(new base::ListValue()); | 122 scoped_ptr<base::ListValue> args(new base::ListValue()); |
121 args->Append(new base::StringValue(command)); | 123 args->Append(new base::StringValue(command)); |
122 | 124 |
123 scoped_ptr<Event> event( | 125 scoped_ptr<Event> event(new Event(events::COMMANDS_ON_COMMAND, |
124 new Event(events::COMMANDS_ON_COMMAND, kOnCommandEventName, args.Pass())); | 126 kOnCommandEventName, std::move(args))); |
125 event->restrict_to_browser_context = browser_context_; | 127 event->restrict_to_browser_context = browser_context_; |
126 event->user_gesture = EventRouter::USER_GESTURE_ENABLED; | 128 event->user_gesture = EventRouter::USER_GESTURE_ENABLED; |
127 EventRouter::Get(browser_context_) | 129 EventRouter::Get(browser_context_) |
128 ->DispatchEventToExtension(extension_id, event.Pass()); | 130 ->DispatchEventToExtension(extension_id, std::move(event)); |
129 } | 131 } |
130 | 132 |
131 bool ExtensionKeybindingRegistry::IsAcceleratorRegistered( | 133 bool ExtensionKeybindingRegistry::IsAcceleratorRegistered( |
132 const ui::Accelerator& accelerator) const { | 134 const ui::Accelerator& accelerator) const { |
133 return event_targets_.find(accelerator) != event_targets_.end(); | 135 return event_targets_.find(accelerator) != event_targets_.end(); |
134 } | 136 } |
135 | 137 |
136 void ExtensionKeybindingRegistry::AddEventTarget( | 138 void ExtensionKeybindingRegistry::AddEventTarget( |
137 const ui::Accelerator& accelerator, | 139 const ui::Accelerator& accelerator, |
138 const std::string& extension_id, | 140 const std::string& extension_id, |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 if (extension_id.empty() || it->first == extension_id) { | 257 if (extension_id.empty() || it->first == extension_id) { |
256 CommandExecuted(it->first, it->second); | 258 CommandExecuted(it->first, it->second); |
257 executed = true; | 259 executed = true; |
258 } | 260 } |
259 } | 261 } |
260 | 262 |
261 return executed; | 263 return executed; |
262 } | 264 } |
263 | 265 |
264 } // namespace extensions | 266 } // namespace extensions |
OLD | NEW |