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

Side by Side Diff: chrome/browser/ui/gtk/back_forward_button_gtk.cc

Issue 14307023: chrome: Use base::MessageLoop. (Part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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/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"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 gboolean BackForwardButtonGtk::OnButtonPress(GtkWidget* widget, 99 gboolean BackForwardButtonGtk::OnButtonPress(GtkWidget* widget,
100 GdkEventButton* event) { 100 GdkEventButton* event) {
101 if (event->button == 3) 101 if (event->button == 3)
102 ShowBackForwardMenu(event->button, event->time); 102 ShowBackForwardMenu(event->button, event->time);
103 103
104 if (event->button != 1) 104 if (event->button != 1)
105 return FALSE; 105 return FALSE;
106 106
107 y_position_of_last_press_ = static_cast<int>(event->y); 107 y_position_of_last_press_ = static_cast<int>(event->y);
108 MessageLoop::current()->PostDelayedTask( 108 base::MessageLoop::current()->PostDelayedTask(
109 FROM_HERE, 109 FROM_HERE,
110 base::Bind(&BackForwardButtonGtk::ShowBackForwardMenu, 110 base::Bind(&BackForwardButtonGtk::ShowBackForwardMenu,
111 weak_factory_.GetWeakPtr(), 111 weak_factory_.GetWeakPtr(),
112 event->button, 112 event->button,
113 event->time), 113 event->time),
114 base::TimeDelta::FromMilliseconds(kMenuTimerDelay)); 114 base::TimeDelta::FromMilliseconds(kMenuTimerDelay));
115 return FALSE; 115 return FALSE;
116 } 116 }
117 117
118 gboolean BackForwardButtonGtk::OnMouseMove(GtkWidget* widget, 118 gboolean BackForwardButtonGtk::OnMouseMove(GtkWidget* widget,
119 GdkEventMotion* event) { 119 GdkEventMotion* event) {
120 // If we aren't waiting to show the back forward menu, do nothing. 120 // If we aren't waiting to show the back forward menu, do nothing.
121 if (!weak_factory_.HasWeakPtrs()) 121 if (!weak_factory_.HasWeakPtrs())
122 return FALSE; 122 return FALSE;
123 123
124 // We only count moves about a certain threshold. 124 // We only count moves about a certain threshold.
125 GtkSettings* settings = gtk_widget_get_settings(widget); 125 GtkSettings* settings = gtk_widget_get_settings(widget);
126 int drag_min_distance; 126 int drag_min_distance;
127 g_object_get(settings, "gtk-dnd-drag-threshold", &drag_min_distance, NULL); 127 g_object_get(settings, "gtk-dnd-drag-threshold", &drag_min_distance, NULL);
128 if (event->y - y_position_of_last_press_ < drag_min_distance) 128 if (event->y - y_position_of_last_press_ < drag_min_distance)
129 return FALSE; 129 return FALSE;
130 130
131 // We will show the menu now. Cancel the delayed event. 131 // We will show the menu now. Cancel the delayed event.
132 weak_factory_.InvalidateWeakPtrs(); 132 weak_factory_.InvalidateWeakPtrs();
133 ShowBackForwardMenu(/* button */ 1, event->time); 133 ShowBackForwardMenu(/* button */ 1, event->time);
134 return FALSE; 134 return FALSE;
135 } 135 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/avatar_menu_bubble_gtk.cc ('k') | chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698