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

Side by Side Diff: chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.cc

Issue 10834106: Implement Keybinding for script badges. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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/gtk/extensions/extension_keybinding_registry_gtk.h" 5 #include "chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.h"
6 6
7 #include "chrome/browser/extensions/api/commands/command_service.h" 7 #include "chrome/browser/extensions/api/commands/command_service.h"
8 #include "chrome/browser/extensions/api/commands/command_service_factory.h" 8 #include "chrome/browser/extensions/api/commands/command_service_factory.h"
9 #include "chrome/browser/extensions/browser_event_router.h" 9 #include "chrome/browser/extensions/browser_event_router.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 extensions::CommandService* command_service = 59 extensions::CommandService* command_service =
60 extensions::CommandServiceFactory::GetForProfile(profile_); 60 extensions::CommandServiceFactory::GetForProfile(profile_);
61 extensions::CommandMap commands; 61 extensions::CommandMap commands;
62 if (!command_service->GetNamedCommands( 62 if (!command_service->GetNamedCommands(
63 extension->id(), 63 extension->id(),
64 extensions::CommandService::ACTIVE_ONLY, 64 extensions::CommandService::ACTIVE_ONLY,
65 &commands)) { 65 &commands)) {
66 return; 66 return;
67 } 67 }
68 68
69 extensions::CommandMap::const_iterator iter = commands.begin(); 69 for (extensions::CommandMap::const_iterator iter = commands.begin();
70 for (; iter != commands.end(); ++iter) { 70 iter != commands.end(); ++iter) {
71 if (!command_name.empty() && (iter->second.command_name() != command_name)) 71 if (!command_name.empty() && (iter->second.command_name() != command_name))
72 continue; 72 continue;
73 73
74 ui::AcceleratorGtk accelerator(iter->second.accelerator().key_code(), 74 ui::AcceleratorGtk accelerator(iter->second.accelerator().key_code(),
75 iter->second.accelerator().IsShiftDown(), 75 iter->second.accelerator().IsShiftDown(),
76 iter->second.accelerator().IsCtrlDown(), 76 iter->second.accelerator().IsCtrlDown(),
77 iter->second.accelerator().IsAltDown()); 77 iter->second.accelerator().IsAltDown());
78 event_targets_[accelerator] = 78 event_targets_[accelerator] =
79 std::make_pair(extension->id(), iter->second.command_name()); 79 std::make_pair(extension->id(), iter->second.command_name());
80 80
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 std::make_pair(extension->id(), page_action.command_name()); 122 std::make_pair(extension->id(), page_action.command_name());
123 } 123 }
124 } 124 }
125 125
126 void ExtensionKeybindingRegistryGtk::RemoveExtensionKeybinding( 126 void ExtensionKeybindingRegistryGtk::RemoveExtensionKeybinding(
127 const extensions::Extension* extension, 127 const extensions::Extension* extension,
128 const std::string& command_name) { 128 const std::string& command_name) {
129 EventTargets::iterator iter = event_targets_.begin(); 129 EventTargets::iterator iter = event_targets_.begin();
130 while (iter != event_targets_.end()) { 130 while (iter != event_targets_.end()) {
131 if (iter->second.first != extension->id() || 131 if (iter->second.first != extension->id() ||
132 (!command_name.empty() && (iter->second.second != command_name))) { 132 (!command_name.empty() && iter->second.second != command_name)) {
133 ++iter; 133 ++iter;
134 continue; // Not the extension or command we asked for. 134 continue; // Not the extension or command we asked for.
135 } 135 }
136 136
137 // On GTK, unlike Windows, the Event Targets contain all events but we must 137 // On GTK, unlike Windows, the Event Targets contain all events but we must
138 // only unregister the ones we own. 138 // only unregister the ones we own.
139 if (ShouldIgnoreCommand(iter->second.second)) { 139 if (ShouldIgnoreCommand(iter->second.second)) {
140 ++iter; 140 ++iter;
141 continue; 141 continue;
142 } 142 }
(...skipping 19 matching lines...) Expand all
162 if (it == event_targets_.end()) { 162 if (it == event_targets_.end()) {
163 NOTREACHED(); // Shouldn't get this event for something not registered. 163 NOTREACHED(); // Shouldn't get this event for something not registered.
164 return FALSE; 164 return FALSE;
165 } 165 }
166 166
167 service->browser_event_router()->CommandExecuted( 167 service->browser_event_router()->CommandExecuted(
168 profile_, it->second.first, it->second.second); 168 profile_, it->second.first, it->second.second);
169 169
170 return TRUE; 170 return TRUE;
171 } 171 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698