Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/location.h" |
| 8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 if (!for_drop_) { | 205 if (!for_drop_) { |
| 206 // Give the context menu (if any) a chance to execute the user-selected | 206 // Give the context menu (if any) a chance to execute the user-selected |
| 207 // command. | 207 // command. |
| 208 base::ThreadTaskRunnerHandle::Get()->PostTask( | 208 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 209 FROM_HERE, base::Bind(&ChevronMenuButton::MenuDone, | 209 FROM_HERE, base::Bind(&ChevronMenuButton::MenuDone, |
| 210 owner_->weak_factory_.GetWeakPtr())); | 210 owner_->weak_factory_.GetWeakPtr())); |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 | 213 |
| 214 void ChevronMenuButton::MenuController::CloseMenu() { | 214 void ChevronMenuButton::MenuController::CloseMenu() { |
| 215 icon_updaters_.clear(); | |
|
Devlin
2015/10/27 21:15:02
Note: added this so that updaters were cleared whe
| |
| 215 menu_->Cancel(); | 216 menu_->Cancel(); |
| 216 } | 217 } |
| 217 | 218 |
| 218 bool ChevronMenuButton::MenuController::IsCommandEnabled(int id) const { | 219 bool ChevronMenuButton::MenuController::IsCommandEnabled(int id) const { |
| 219 ToolbarActionView* view = | 220 ToolbarActionView* view = |
| 220 browser_actions_container_->GetToolbarActionViewAt(start_index_ + id - 1); | 221 browser_actions_container_->GetToolbarActionViewAt(start_index_ + id - 1); |
| 221 return view->view_controller()->IsEnabled(view->GetCurrentWebContents()); | 222 return view->view_controller()->IsEnabled(view->GetCurrentWebContents()); |
| 222 } | 223 } |
| 223 | 224 |
| 224 void ChevronMenuButton::MenuController::ExecuteCommand(int id) { | 225 void ChevronMenuButton::MenuController::ExecuteCommand(int id) { |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 // We should never try to show an overflow menu when one is already visible. | 441 // We should never try to show an overflow menu when one is already visible. |
| 441 DCHECK(!menu_controller_); | 442 DCHECK(!menu_controller_); |
| 442 menu_controller_.reset(new MenuController( | 443 menu_controller_.reset(new MenuController( |
| 443 this, browser_actions_container_, for_drop)); | 444 this, browser_actions_container_, for_drop)); |
| 444 menu_controller_->RunMenu(GetWidget()); | 445 menu_controller_->RunMenu(GetWidget()); |
| 445 } | 446 } |
| 446 | 447 |
| 447 void ChevronMenuButton::MenuDone() { | 448 void ChevronMenuButton::MenuDone() { |
| 448 menu_controller_.reset(); | 449 menu_controller_.reset(); |
| 449 } | 450 } |
| OLD | NEW |