| OLD | NEW |
| 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_action_view.h" | 5 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } else { | 169 } else { |
| 170 view_controller_->ExecuteAction(true); | 170 view_controller_->ExecuteAction(true); |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 void ToolbarActionView::OnMenuClosed() { | 174 void ToolbarActionView::OnMenuClosed() { |
| 175 menu_runner_.reset(); | 175 menu_runner_.reset(); |
| 176 menu_ = nullptr; | 176 menu_ = nullptr; |
| 177 view_controller_->OnContextMenuClosed(); | 177 view_controller_->OnContextMenuClosed(); |
| 178 menu_adapter_.reset(); | 178 menu_adapter_.reset(); |
| 179 ink_drop_delegate()->OnAction(views::InkDropState::DEACTIVATED); | |
| 180 } | 179 } |
| 181 | 180 |
| 182 gfx::ImageSkia ToolbarActionView::GetIconForTest() { | 181 gfx::ImageSkia ToolbarActionView::GetIconForTest() { |
| 183 return GetImage(views::Button::STATE_NORMAL); | 182 return GetImage(views::Button::STATE_NORMAL); |
| 184 } | 183 } |
| 185 | 184 |
| 186 void ToolbarActionView::set_context_menu_callback_for_testing( | 185 void ToolbarActionView::set_context_menu_callback_for_testing( |
| 187 base::Callback<void(ToolbarActionView*)>* callback) { | 186 base::Callback<void(ToolbarActionView*)>* callback) { |
| 188 context_menu_callback_for_test = callback; | 187 context_menu_callback_for_test = callback; |
| 189 } | 188 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 views::MenuRunner::CONTEXT_MENU | views::MenuRunner::ASYNC; | 290 views::MenuRunner::CONTEXT_MENU | views::MenuRunner::ASYNC; |
| 292 if (delegate_->ShownInsideMenu()) | 291 if (delegate_->ShownInsideMenu()) |
| 293 run_types |= views::MenuRunner::IS_NESTED; | 292 run_types |= views::MenuRunner::IS_NESTED; |
| 294 | 293 |
| 295 // RunMenuAt expects a nested menu to be parented by the same widget as the | 294 // RunMenuAt expects a nested menu to be parented by the same widget as the |
| 296 // already visible menu, in this case the Chrome menu. | 295 // already visible menu, in this case the Chrome menu. |
| 297 views::Widget* parent = delegate_->ShownInsideMenu() ? | 296 views::Widget* parent = delegate_->ShownInsideMenu() ? |
| 298 delegate_->GetOverflowReferenceView()->GetWidget() : | 297 delegate_->GetOverflowReferenceView()->GetWidget() : |
| 299 GetWidget(); | 298 GetWidget(); |
| 300 | 299 |
| 301 ink_drop_delegate()->OnAction(views::InkDropState::ACTIVATED); | |
| 302 // Unretained() is safe here as ToolbarActionView will always outlive the | 300 // Unretained() is safe here as ToolbarActionView will always outlive the |
| 303 // menu. Any action that would lead to the deletion of |this| first triggers | 301 // menu. Any action that would lead to the deletion of |this| first triggers |
| 304 // the closing of the menu through lost capture. | 302 // the closing of the menu through lost capture. |
| 305 menu_adapter_.reset(new views::MenuModelAdapter( | 303 menu_adapter_.reset(new views::MenuModelAdapter( |
| 306 context_menu_model, | 304 context_menu_model, |
| 307 base::Bind(&ToolbarActionView::OnMenuClosed, base::Unretained(this)))); | 305 base::Bind(&ToolbarActionView::OnMenuClosed, base::Unretained(this)))); |
| 308 menu_ = menu_adapter_->CreateMenu(); | 306 menu_ = menu_adapter_->CreateMenu(); |
| 309 menu_runner_.reset(new views::MenuRunner(menu_, run_types)); | 307 menu_runner_.reset(new views::MenuRunner(menu_, run_types)); |
| 310 | 308 |
| 311 if (context_menu_callback_for_test) | 309 if (context_menu_callback_for_test) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 328 if (menu_controller->in_nested_run()) { | 326 if (menu_controller->in_nested_run()) { |
| 329 // There is another menu showing. Close the outermost menu (since we are | 327 // There is another menu showing. Close the outermost menu (since we are |
| 330 // shown in the same menu, we don't want to close the whole thing). | 328 // shown in the same menu, we don't want to close the whole thing). |
| 331 menu_controller->Cancel(views::MenuController::EXIT_OUTERMOST); | 329 menu_controller->Cancel(views::MenuController::EXIT_OUTERMOST); |
| 332 return true; | 330 return true; |
| 333 } | 331 } |
| 334 } | 332 } |
| 335 | 333 |
| 336 return false; | 334 return false; |
| 337 } | 335 } |
| OLD | NEW |