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

Side by Side Diff: chrome/browser/ui/views/toolbar/toolbar_button.cc

Issue 1160073004: chrome/browser/ui: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments. Created 5 years, 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/views/toolbar/toolbar_button.h" 5 #include "chrome/browser/ui/views/toolbar/toolbar_button.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h"
8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 11 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
9 #include "ui/accessibility/ax_view_state.h" 12 #include "ui/accessibility/ax_view_state.h"
10 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
11 #include "ui/base/models/menu_model.h" 14 #include "ui/base/models/menu_model.h"
12 #include "ui/base/theme_provider.h" 15 #include "ui/base/theme_provider.h"
13 #include "ui/gfx/display.h" 16 #include "ui/gfx/display.h"
14 #include "ui/gfx/screen.h" 17 #include "ui/gfx/screen.h"
15 #include "ui/strings/grit/ui_strings.h" 18 #include "ui/strings/grit/ui_strings.h"
16 #include "ui/views/controls/button/label_button_border.h" 19 #include "ui/views/controls/button/label_button_border.h"
17 #include "ui/views/controls/menu/menu_item_view.h" 20 #include "ui/views/controls/menu/menu_item_view.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 bool ToolbarButton::OnMousePressed(const ui::MouseEvent& event) { 60 bool ToolbarButton::OnMousePressed(const ui::MouseEvent& event) {
58 if (enabled() && ShouldShowMenu() && 61 if (enabled() && ShouldShowMenu() &&
59 IsTriggerableEvent(event) && HitTestPoint(event.location())) { 62 IsTriggerableEvent(event) && HitTestPoint(event.location())) {
60 // Store the y pos of the mouse coordinates so we can use them later to 63 // Store the y pos of the mouse coordinates so we can use them later to
61 // determine if the user dragged the mouse down (which should pop up the 64 // determine if the user dragged the mouse down (which should pop up the
62 // drag down menu immediately, instead of waiting for the timer) 65 // drag down menu immediately, instead of waiting for the timer)
63 y_position_on_lbuttondown_ = event.y(); 66 y_position_on_lbuttondown_ = event.y();
64 67
65 // Schedule a task that will show the menu. 68 // Schedule a task that will show the menu.
66 const int kMenuTimerDelay = 500; 69 const int kMenuTimerDelay = 500;
67 base::MessageLoop::current()->PostDelayedTask( 70 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
68 FROM_HERE, 71 FROM_HERE, base::Bind(&ToolbarButton::ShowDropDownMenu,
69 base::Bind(&ToolbarButton::ShowDropDownMenu, 72 show_menu_factory_.GetWeakPtr(),
70 show_menu_factory_.GetWeakPtr(), 73 ui::GetMenuSourceTypeForEvent(event)),
71 ui::GetMenuSourceTypeForEvent(event)),
72 base::TimeDelta::FromMilliseconds(kMenuTimerDelay)); 74 base::TimeDelta::FromMilliseconds(kMenuTimerDelay));
73 } 75 }
74 return LabelButton::OnMousePressed(event); 76 return LabelButton::OnMousePressed(event);
75 } 77 }
76 78
77 bool ToolbarButton::OnMouseDragged(const ui::MouseEvent& event) { 79 bool ToolbarButton::OnMouseDragged(const ui::MouseEvent& event) {
78 bool result = LabelButton::OnMouseDragged(event); 80 bool result = LabelButton::OnMouseDragged(event);
79 81
80 if (show_menu_factory_.HasWeakPtrs()) { 82 if (show_menu_factory_.HasWeakPtrs()) {
81 // If the mouse is dragged to a y position lower than where it was when 83 // If the mouse is dragged to a y position lower than where it was when
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 SetMouseHandler(NULL); 247 SetMouseHandler(NULL);
246 248
247 // Set the state back to normal after the drop down menu is closed. 249 // Set the state back to normal after the drop down menu is closed.
248 if (state_ != STATE_DISABLED) 250 if (state_ != STATE_DISABLED)
249 SetState(STATE_NORMAL); 251 SetState(STATE_NORMAL);
250 } 252 }
251 253
252 const char* ToolbarButton::GetClassName() const { 254 const char* ToolbarButton::GetClassName() const {
253 return "ToolbarButton"; 255 return "ToolbarButton";
254 } 256 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698