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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa.mm

Issue 23812010: Implement first part of supporting global extension commands. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gclient sync Created 7 years, 2 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 | Annotate | Revision Log
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 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa .h" 5 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa .h"
6 6
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/extensions/api/commands/command_service.h" 8 #include "chrome/browser/extensions/api/commands/command_service.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 void ExtensionKeybindingRegistryCocoa::AddExtensionKeybinding( 78 void ExtensionKeybindingRegistryCocoa::AddExtensionKeybinding(
79 const extensions::Extension* extension, 79 const extensions::Extension* extension,
80 const std::string& command_name) { 80 const std::string& command_name) {
81 extensions::CommandService* command_service = 81 extensions::CommandService* command_service =
82 extensions::CommandService::Get(profile_); 82 extensions::CommandService::Get(profile_);
83 extensions::CommandMap commands; 83 extensions::CommandMap commands;
84 command_service->GetNamedCommands( 84 command_service->GetNamedCommands(
85 extension->id(), 85 extension->id(),
86 extensions::CommandService::ACTIVE_ONLY, 86 extensions::CommandService::ACTIVE_ONLY,
87 extensions::CommandService::REGULAR,
87 &commands); 88 &commands);
88 89
89 for (extensions::CommandMap::const_iterator iter = commands.begin(); 90 for (extensions::CommandMap::const_iterator iter = commands.begin();
90 iter != commands.end(); ++iter) { 91 iter != commands.end(); ++iter) {
91 if (!command_name.empty() && (iter->second.command_name() != command_name)) 92 if (!command_name.empty() && (iter->second.command_name() != command_name))
92 continue; 93 continue;
93 94
94 ui::Accelerator accelerator(iter->second.accelerator()); 95 ui::Accelerator accelerator(iter->second.accelerator());
95 event_targets_[accelerator] = 96 event_targets_[accelerator] =
96 std::make_pair(extension->id(), iter->second.command_name()); 97 std::make_pair(extension->id(), iter->second.command_name());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 extension->id(), 129 extension->id(),
129 extensions::CommandService::ACTIVE_ONLY, 130 extensions::CommandService::ACTIVE_ONLY,
130 &script_badge, 131 &script_badge,
131 NULL)) { 132 NULL)) {
132 ui::Accelerator accelerator(script_badge.accelerator()); 133 ui::Accelerator accelerator(script_badge.accelerator());
133 event_targets_[accelerator] = 134 event_targets_[accelerator] =
134 std::make_pair(extension->id(), script_badge.command_name()); 135 std::make_pair(extension->id(), script_badge.command_name());
135 } 136 }
136 } 137 }
137 138
138 void ExtensionKeybindingRegistryCocoa::RemoveExtensionKeybinding( 139 void ExtensionKeybindingRegistryCocoa::RemoveExtensionKeybindingImpl(
139 const extensions::Extension* extension, 140 const ui::Accelerator& accelerator,
140 const std::string& command_name) { 141 const std::string& command_name) {
141 EventTargets::iterator iter = event_targets_.begin();
142 while (iter != event_targets_.end()) {
143 EventTargets::iterator old = iter++;
144 if (old->second.first == extension->id() &&
145 (command_name.empty() || (old->second.second == command_name)))
146 event_targets_.erase(old);
147 }
148 } 142 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698