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

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

Issue 9812008: Polish the keybinding implementation a bit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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/extension_browser_event_router.h" 7 #include "chrome/browser/extensions/extension_browser_event_router.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
(...skipping 25 matching lines...) Expand all
36 event->state & GDK_SHIFT_MASK, 36 event->state & GDK_SHIFT_MASK,
37 event->state & GDK_CONTROL_MASK, 37 event->state & GDK_CONTROL_MASK,
38 event->state & GDK_MOD1_MASK); 38 event->state & GDK_MOD1_MASK);
39 return event_targets_.find(accelerator) != event_targets_.end(); 39 return event_targets_.find(accelerator) != event_targets_.end();
40 } 40 }
41 41
42 void ExtensionKeybindingRegistryGtk::AddExtensionKeybinding( 42 void ExtensionKeybindingRegistryGtk::AddExtensionKeybinding(
43 const Extension* extension) { 43 const Extension* extension) {
44 // Add all the keybindings (except pageAction and browserAction, which are 44 // Add all the keybindings (except pageAction and browserAction, which are
45 // handled elsewhere). 45 // handled elsewhere).
46 const std::vector<Extension::ExtensionKeybinding> commands = 46 const Extension::CommandMap& commands = extension->named_commands();
47 extension->keybindings(); 47 Extension::CommandMap::const_iterator iter = commands.begin();
48 for (size_t i = 0; i < commands.size(); ++i) { 48 for (; iter != commands.end(); ++iter) {
49 ui::AcceleratorGtk accelerator(commands[i].accelerator().key_code(), 49 ui::AcceleratorGtk accelerator(iter->second.accelerator().key_code(),
50 commands[i].accelerator().IsShiftDown(), 50 iter->second.accelerator().IsShiftDown(),
51 commands[i].accelerator().IsCtrlDown(), 51 iter->second.accelerator().IsCtrlDown(),
52 commands[i].accelerator().IsAltDown()); 52 iter->second.accelerator().IsAltDown());
53 event_targets_[accelerator] = 53 event_targets_[accelerator] =
54 std::make_pair(extension->id(), commands[i].command_name()); 54 std::make_pair(extension->id(), iter->second.command_name());
55 55
56 if (ShouldIgnoreCommand(commands[i].command_name())) 56 if (ShouldIgnoreCommand(iter->second.command_name()))
57 continue; 57 continue;
58 58
59 if (!accel_group_) { 59 if (!accel_group_) {
60 accel_group_ = gtk_accel_group_new(); 60 accel_group_ = gtk_accel_group_new();
61 gtk_window_add_accel_group(window_, accel_group_); 61 gtk_window_add_accel_group(window_, accel_group_);
62 } 62 }
63 63
64 gtk_accel_group_connect( 64 gtk_accel_group_connect(
65 accel_group_, 65 accel_group_,
66 accelerator.GetGdkKeyCode(), 66 accelerator.GetGdkKeyCode(),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 if (it == event_targets_.end()) { 106 if (it == event_targets_.end()) {
107 NOTREACHED(); // Shouldn't get this event for something not registered. 107 NOTREACHED(); // Shouldn't get this event for something not registered.
108 return FALSE; 108 return FALSE;
109 } 109 }
110 110
111 service->browser_event_router()->CommandExecuted( 111 service->browser_event_router()->CommandExecuted(
112 profile_, it->second.first, it->second.second); 112 profile_, it->second.first, it->second.second);
113 113
114 return TRUE; 114 return TRUE;
115 } 115 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc ('k') | chrome/browser/ui/gtk/location_bar_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698