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

Unified Diff: chrome/browser/ui/gtk/location_bar_view_gtk.cc

Issue 10834106: Implement Keybinding for script badges. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/gtk/location_bar_view_gtk.h ('k') | chrome/browser/ui/views/browser_action_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/location_bar_view_gtk.cc
===================================================================
--- chrome/browser/ui/gtk/location_bar_view_gtk.cc (revision 149159)
+++ chrome/browser/ui/gtk/location_bar_view_gtk.cc (working copy)
@@ -1905,28 +1905,55 @@
extensions::CommandService* command_service =
extensions::CommandServiceFactory::GetForProfile(
owner_->browser()->profile());
- extensions::Command command;
+
+ extensions::Command command_page_action;
Yoyo Zhou 2012/08/02 11:11:01 Same comment here: "page_action_command"
if (command_service->GetPageActionCommand(
extension->id(),
extensions::CommandService::ACTIVE_ONLY,
- &command,
+ &command_page_action,
NULL)) {
- // Found the browser action shortcut command, register it.
- keybinding_.reset(new ui::AcceleratorGtk(
- command.accelerator().key_code(),
- command.accelerator().IsShiftDown(),
- command.accelerator().IsCtrlDown(),
- command.accelerator().IsAltDown()));
+ // Found the page action shortcut command, register it.
+ page_action_keybinding_.reset(new ui::AcceleratorGtk(
+ command_page_action.accelerator().key_code(),
+ command_page_action.accelerator().IsShiftDown(),
+ command_page_action.accelerator().IsCtrlDown(),
+ command_page_action.accelerator().IsAltDown()));
+ }
+ extensions::Command command_script_badge;
+ if (command_service->GetScriptBadgeCommand(
+ extension->id(),
+ extensions::CommandService::ACTIVE_ONLY,
+ &command_script_badge,
+ NULL)) {
+ // Found the script badge shortcut command, register it.
+ script_badge_keybinding_.reset(new ui::AcceleratorGtk(
+ command_script_badge.accelerator().key_code(),
+ command_script_badge.accelerator().IsShiftDown(),
+ command_script_badge.accelerator().IsCtrlDown(),
+ command_script_badge.accelerator().IsAltDown()));
+ }
+
+ if (page_action_keybinding_.get() || script_badge_keybinding_.get()) {
accel_group_ = gtk_accel_group_new();
gtk_window_add_accel_group(window_, accel_group_);
- gtk_accel_group_connect(
- accel_group_,
- keybinding_->GetGdkKeyCode(),
- keybinding_->gdk_modifier_type(),
- GtkAccelFlags(0),
- g_cclosure_new(G_CALLBACK(OnGtkAccelerator), this, NULL));
+ if (page_action_keybinding_.get()) {
+ gtk_accel_group_connect(
+ accel_group_,
+ page_action_keybinding_->GetGdkKeyCode(),
+ page_action_keybinding_->gdk_modifier_type(),
+ GtkAccelFlags(0),
+ g_cclosure_new(G_CALLBACK(OnGtkAccelerator), this, NULL));
+ }
+ if (script_badge_keybinding_.get()) {
+ gtk_accel_group_connect(
+ accel_group_,
+ script_badge_keybinding_->GetGdkKeyCode(),
+ script_badge_keybinding_->gdk_modifier_type(),
+ GtkAccelFlags(0),
+ g_cclosure_new(G_CALLBACK(OnGtkAccelerator), this, NULL));
+ }
// Since we've added an accelerator, we'll need to unregister it before
// the window is closed, so we listen for the window being closed.
@@ -1943,14 +1970,25 @@
void LocationBarViewGtk::PageActionViewGtk::DisconnectPageActionAccelerator() {
if (accel_group_) {
- gtk_accel_group_disconnect_key(
- accel_group_,
- keybinding_.get()->GetGdkKeyCode(),
- static_cast<GdkModifierType>(keybinding_.get()->modifiers()));
+ if (page_action_keybinding_.get()) {
+ gtk_accel_group_disconnect_key(
+ accel_group_,
+ page_action_keybinding_->GetGdkKeyCode(),
+ static_cast<GdkModifierType>(
+ page_action_keybinding_->modifiers()));
+ }
+ if (script_badge_keybinding_.get()) {
+ gtk_accel_group_disconnect_key(
+ accel_group_,
+ script_badge_keybinding_->GetGdkKeyCode(),
+ static_cast<GdkModifierType>(
+ script_badge_keybinding_->modifiers()));
+ }
gtk_window_remove_accel_group(window_, accel_group_);
g_object_unref(accel_group_);
accel_group_ = NULL;
- keybinding_.reset(NULL);
+ page_action_keybinding_.reset(NULL);
+ script_badge_keybinding_.reset(NULL);
}
}
« no previous file with comments | « chrome/browser/ui/gtk/location_bar_view_gtk.h ('k') | chrome/browser/ui/views/browser_action_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698