Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/views/touchui/touch_selection_menu_runner_views.h" | |
| 6 | |
| 7 #include "ui/aura/window.h" | |
| 8 #include "ui/gfx/geometry/rect.h" | |
| 9 #include "ui/gfx/geometry/size.h" | |
| 10 | |
| 11 namespace views { | |
| 12 | |
| 13 TouchSelectionMenuRunnerViews::TouchSelectionMenuRunnerViews() | |
| 14 : menu_(nullptr), | |
| 15 client_(nullptr) {} | |
| 16 | |
| 17 TouchSelectionMenuRunnerViews::~TouchSelectionMenuRunnerViews() {} | |
| 18 | |
| 19 void TouchSelectionMenuRunnerViews::RunMenu( | |
| 20 ui::TouchSelectionMenuClient* client, | |
| 21 const gfx::Rect& anchor_rect, | |
| 22 const gfx::Size& handle_image_size, | |
| 23 aura::Window* context) { | |
| 24 CloseMenu(); | |
| 25 | |
| 26 DCHECK(!menu_); | |
| 27 DCHECK(!client_); | |
| 28 | |
| 29 client_ = client; | |
| 30 menu_ = TouchEditingMenuView::Create(this, anchor_rect, handle_image_size, | |
| 31 context); | |
| 32 | |
| 33 if (!menu_) | |
| 34 client_ = nullptr; | |
| 35 } | |
| 36 | |
| 37 void TouchSelectionMenuRunnerViews::CloseMenu() { | |
| 38 if (menu_) { | |
| 39 menu_->Close(); | |
| 40 menu_ = nullptr; | |
| 41 client_ = nullptr; | |
| 42 } | |
| 43 } | |
| 44 | |
| 45 bool TouchSelectionMenuRunnerViews::IsRunning() const { | |
| 46 return menu_ != nullptr; | |
| 47 } | |
| 48 | |
| 49 bool TouchSelectionMenuRunnerViews::IsCommandIdEnabled(int command_id) const { | |
| 50 return client_->IsCommandIdEnabled(command_id); | |
| 51 } | |
| 52 | |
| 53 void TouchSelectionMenuRunnerViews::ExecuteCommand(int command_id, | |
| 54 int event_flags) { | |
| 55 return client_->ExecuteCommand(command_id, event_flags); | |
| 56 } | |
| 57 | |
| 58 void TouchSelectionMenuRunnerViews::OpenContextMenu() { | |
| 59 return client_->OpenContextMenu(); | |
| 60 } | |
| 61 | |
| 62 void TouchSelectionMenuRunnerViews::OnMenuClosed(TouchEditingMenuView* menu) { | |
| 63 DCHECK(menu == menu_); // or nullptr? | |
|
sadrul
2015/03/05 12:37:03
?
mohsen
2015/03/06 23:10:08
Removed comment.
| |
| 64 menu_ = nullptr; | |
| 65 client_ = nullptr; | |
| 66 } | |
| 67 | |
| 68 } // namespace views | |
| OLD | NEW |