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

Side by Side Diff: chrome/browser/ui/views/toolbar/chevron_menu_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: Check for task runner instead of current message loop. 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chevron_menu_button.h" 5 #include "chrome/browser/ui/views/toolbar/chevron_menu_button.h"
6 6
7 #include "base/location.h"
7 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
8 #include "base/message_loop/message_loop.h" 9 #include "base/single_thread_task_runner.h"
9 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/thread_task_runner_handle.h"
10 #include "chrome/browser/extensions/extension_action.h" 12 #include "chrome/browser/extensions/extension_action.h"
11 #include "chrome/browser/extensions/extension_action_icon_factory.h" 13 #include "chrome/browser/extensions/extension_action_icon_factory.h"
12 #include "chrome/browser/extensions/extension_context_menu_model.h" 14 #include "chrome/browser/extensions/extension_context_menu_model.h"
13 #include "chrome/browser/extensions/extension_toolbar_model.h" 15 #include "chrome/browser/extensions/extension_toolbar_model.h"
14 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/extensions/extension_action_view_controller.h" 18 #include "chrome/browser/ui/extensions/extension_action_view_controller.h"
17 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" 19 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h"
18 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" 20 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
19 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h" 21 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 owner_, 192 owner_,
191 bounds, 193 bounds,
192 views::MENU_ANCHOR_TOPRIGHT, 194 views::MENU_ANCHOR_TOPRIGHT,
193 ui::MENU_SOURCE_NONE) == 195 ui::MENU_SOURCE_NONE) ==
194 views::MenuRunner::MENU_DELETED) 196 views::MenuRunner::MENU_DELETED)
195 return; 197 return;
196 198
197 if (!for_drop_) { 199 if (!for_drop_) {
198 // Give the context menu (if any) a chance to execute the user-selected 200 // Give the context menu (if any) a chance to execute the user-selected
199 // command. 201 // command.
200 base::MessageLoop::current()->PostTask( 202 base::ThreadTaskRunnerHandle::Get()->PostTask(
201 FROM_HERE, 203 FROM_HERE, base::Bind(&ChevronMenuButton::MenuDone,
202 base::Bind(&ChevronMenuButton::MenuDone, 204 owner_->weak_factory_.GetWeakPtr()));
203 owner_->weak_factory_.GetWeakPtr()));
204 } 205 }
205 } 206 }
206 207
207 void ChevronMenuButton::MenuController::CloseMenu() { 208 void ChevronMenuButton::MenuController::CloseMenu() {
208 menu_->Cancel(); 209 menu_->Cancel();
209 } 210 }
210 211
211 bool ChevronMenuButton::MenuController::IsCommandEnabled(int id) const { 212 bool ChevronMenuButton::MenuController::IsCommandEnabled(int id) const {
212 ToolbarActionView* view = 213 ToolbarActionView* view =
213 browser_actions_container_->GetToolbarActionViewAt(start_index_ + id - 1); 214 browser_actions_container_->GetToolbarActionViewAt(start_index_ + id - 1);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 } 389 }
389 390
390 bool ChevronMenuButton::CanDrop(const OSExchangeData& data) { 391 bool ChevronMenuButton::CanDrop(const OSExchangeData& data) {
391 return BrowserActionDragData::CanDrop( 392 return BrowserActionDragData::CanDrop(
392 data, browser_actions_container_->browser()->profile()); 393 data, browser_actions_container_->browser()->profile());
393 } 394 }
394 395
395 void ChevronMenuButton::OnDragEntered(const ui::DropTargetEvent& event) { 396 void ChevronMenuButton::OnDragEntered(const ui::DropTargetEvent& event) {
396 DCHECK(!weak_factory_.HasWeakPtrs()); 397 DCHECK(!weak_factory_.HasWeakPtrs());
397 if (!menu_controller_) { 398 if (!menu_controller_) {
398 base::MessageLoop::current()->PostDelayedTask( 399 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
399 FROM_HERE, 400 FROM_HERE, base::Bind(&ChevronMenuButton::ShowOverflowMenu,
400 base::Bind(&ChevronMenuButton::ShowOverflowMenu, 401 weak_factory_.GetWeakPtr(), true),
401 weak_factory_.GetWeakPtr(),
402 true),
403 base::TimeDelta::FromMilliseconds(views::GetMenuShowDelay())); 402 base::TimeDelta::FromMilliseconds(views::GetMenuShowDelay()));
404 } 403 }
405 } 404 }
406 405
407 int ChevronMenuButton::OnDragUpdated(const ui::DropTargetEvent& event) { 406 int ChevronMenuButton::OnDragUpdated(const ui::DropTargetEvent& event) {
408 return ui::DragDropTypes::DRAG_MOVE; 407 return ui::DragDropTypes::DRAG_MOVE;
409 } 408 }
410 409
411 void ChevronMenuButton::OnDragExited() { 410 void ChevronMenuButton::OnDragExited() {
412 weak_factory_.InvalidateWeakPtrs(); 411 weak_factory_.InvalidateWeakPtrs();
(...skipping 20 matching lines...) Expand all
433 // We should never try to show an overflow menu when one is already visible. 432 // We should never try to show an overflow menu when one is already visible.
434 DCHECK(!menu_controller_); 433 DCHECK(!menu_controller_);
435 menu_controller_.reset(new MenuController( 434 menu_controller_.reset(new MenuController(
436 this, browser_actions_container_, for_drop)); 435 this, browser_actions_container_, for_drop));
437 menu_controller_->RunMenu(GetWidget()); 436 menu_controller_->RunMenu(GetWidget());
438 } 437 }
439 438
440 void ChevronMenuButton::MenuDone() { 439 void ChevronMenuButton::MenuDone() {
441 menu_controller_.reset(); 440 menu_controller_.reset();
442 } 441 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698