| 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/ui/gtk/browser_actions_toolbar_gtk.h" | 5 #include "chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
| 14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/browser/extensions/extension_browser_event_router.h" | 16 #include "chrome/browser/extensions/extension_browser_event_router.h" |
| 17 #include "chrome/browser/extensions/extension_context_menu_model.h" | 17 #include "chrome/browser/extensions/extension_context_menu_model.h" |
| 18 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
| 18 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "chrome/browser/extensions/image_loading_tracker.h" | 20 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/sessions/restore_tab_helper.h" | 22 #include "chrome/browser/sessions/restore_tab_helper.h" |
| 22 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 24 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
| 24 #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h" | 25 #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h" |
| 25 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" | 26 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" |
| 26 #include "chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.h" | 27 #include "chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.h" |
| 27 #include "chrome/browser/ui/gtk/gtk_util.h" | 28 #include "chrome/browser/ui/gtk/gtk_util.h" |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 // The handler for when the browser action is realized. |user_data| contains a | 360 // The handler for when the browser action is realized. |user_data| contains a |
| 360 // pointer to the BrowserAction shown. | 361 // pointer to the BrowserAction shown. |
| 361 static void OnRealize(GtkWidget* widget, void* user_data) { | 362 static void OnRealize(GtkWidget* widget, void* user_data) { |
| 362 BrowserActionButton* button = static_cast<BrowserActionButton*>(user_data); | 363 BrowserActionButton* button = static_cast<BrowserActionButton*>(user_data); |
| 363 button->ConnectBrowserActionPopupAccelerator(); | 364 button->ConnectBrowserActionPopupAccelerator(); |
| 364 } | 365 } |
| 365 | 366 |
| 366 // Connect the accelerator for the browser action popup. | 367 // Connect the accelerator for the browser action popup. |
| 367 void ConnectBrowserActionPopupAccelerator() { | 368 void ConnectBrowserActionPopupAccelerator() { |
| 368 const Extension::ExtensionKeybinding* command = | 369 const Extension::ExtensionKeybinding* command = |
| 369 extension_->browser_action_command(); | 370 ExtensionKeybindingRegistry::GetActiveBrowserActionCommand( |
| 371 toolbar_->browser()->profile(), extension_->id()); |
| 370 if (command) { | 372 if (command) { |
| 371 // Found the browser action shortcut command, register it. | 373 // Found the browser action shortcut command, register it. |
| 372 keybinding_.reset(new ui::AcceleratorGtk( | 374 keybinding_.reset(new ui::AcceleratorGtk( |
| 373 command->accelerator().key_code(), | 375 command->accelerator().key_code(), |
| 374 command->accelerator().IsShiftDown(), | 376 command->accelerator().IsShiftDown(), |
| 375 command->accelerator().IsCtrlDown(), | 377 command->accelerator().IsCtrlDown(), |
| 376 command->accelerator().IsAltDown())); | 378 command->accelerator().IsAltDown())); |
| 377 | 379 |
| 378 gfx::NativeWindow window = | 380 gfx::NativeWindow window = |
| 379 toolbar_->browser()->window()->GetNativeHandle(); | 381 toolbar_->browser()->window()->GetNativeHandle(); |
| (...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 | 1066 |
| 1065 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), | 1067 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), |
| 1066 event->time); | 1068 event->time); |
| 1067 return TRUE; | 1069 return TRUE; |
| 1068 } | 1070 } |
| 1069 | 1071 |
| 1070 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { | 1072 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { |
| 1071 if (!resize_animation_.is_animating()) | 1073 if (!resize_animation_.is_animating()) |
| 1072 UpdateChevronVisibility(); | 1074 UpdateChevronVisibility(); |
| 1073 } | 1075 } |
| OLD | NEW |