| 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/back_forward_button_gtk.h" | 5 #include "chrome/browser/ui/gtk/back_forward_button_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_commands.h" |
| 14 #include "chrome/browser/ui/gtk/event_utils.h" | 15 #include "chrome/browser/ui/gtk/event_utils.h" |
| 15 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 16 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 16 #include "chrome/browser/ui/gtk/gtk_util.h" | 17 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 17 #include "chrome/browser/ui/gtk/menu_gtk.h" | 18 #include "chrome/browser/ui/gtk/menu_gtk.h" |
| 18 #include "chrome/browser/ui/toolbar/back_forward_menu_model.h" | 19 #include "chrome/browser/ui/toolbar/back_forward_menu_model.h" |
| 19 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
| 20 #include "grit/theme_resources.h" | 21 #include "grit/theme_resources.h" |
| 21 #include "grit/theme_resources_standard.h" | 22 #include "grit/theme_resources_standard.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 23 | 24 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 84 |
| 84 void BackForwardButtonGtk::ShowBackForwardMenu(int button, guint32 event_time) { | 85 void BackForwardButtonGtk::ShowBackForwardMenu(int button, guint32 event_time) { |
| 85 menu_.reset(new MenuGtk(this, menu_model_.get())); | 86 menu_.reset(new MenuGtk(this, menu_model_.get())); |
| 86 button_->SetPaintOverride(GTK_STATE_ACTIVE); | 87 button_->SetPaintOverride(GTK_STATE_ACTIVE); |
| 87 menu_->PopupForWidget(widget(), button, event_time); | 88 menu_->PopupForWidget(widget(), button, event_time); |
| 88 } | 89 } |
| 89 | 90 |
| 90 void BackForwardButtonGtk::OnClick(GtkWidget* widget) { | 91 void BackForwardButtonGtk::OnClick(GtkWidget* widget) { |
| 91 weak_factory_.InvalidateWeakPtrs(); | 92 weak_factory_.InvalidateWeakPtrs(); |
| 92 | 93 |
| 93 browser_->ExecuteCommandWithDisposition( | 94 chrome::ExecuteCommandWithDisposition( |
| 95 browser_, |
| 94 is_forward_ ? IDC_FORWARD : IDC_BACK, | 96 is_forward_ ? IDC_FORWARD : IDC_BACK, |
| 95 event_utils::DispositionForCurrentButtonPressEvent()); | 97 event_utils::DispositionForCurrentButtonPressEvent()); |
| 96 } | 98 } |
| 97 | 99 |
| 98 gboolean BackForwardButtonGtk::OnButtonPress(GtkWidget* widget, | 100 gboolean BackForwardButtonGtk::OnButtonPress(GtkWidget* widget, |
| 99 GdkEventButton* event) { | 101 GdkEventButton* event) { |
| 100 if (event->button == 3) | 102 if (event->button == 3) |
| 101 ShowBackForwardMenu(event->button, event->time); | 103 ShowBackForwardMenu(event->button, event->time); |
| 102 | 104 |
| 103 if (event->button != 1) | 105 if (event->button != 1) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 125 int drag_min_distance; | 127 int drag_min_distance; |
| 126 g_object_get(settings, "gtk-dnd-drag-threshold", &drag_min_distance, NULL); | 128 g_object_get(settings, "gtk-dnd-drag-threshold", &drag_min_distance, NULL); |
| 127 if (event->y - y_position_of_last_press_ < drag_min_distance) | 129 if (event->y - y_position_of_last_press_ < drag_min_distance) |
| 128 return FALSE; | 130 return FALSE; |
| 129 | 131 |
| 130 // We will show the menu now. Cancel the delayed event. | 132 // We will show the menu now. Cancel the delayed event. |
| 131 weak_factory_.InvalidateWeakPtrs(); | 133 weak_factory_.InvalidateWeakPtrs(); |
| 132 ShowBackForwardMenu(/* button */ 1, event->time); | 134 ShowBackForwardMenu(/* button */ 1, event->time); |
| 133 return FALSE; | 135 return FALSE; |
| 134 } | 136 } |
| OLD | NEW |