Index: ui/views/touchui/touch_selection_menu_runner_views.cc |
diff --git a/ui/views/touchui/touch_selection_menu_runner_views.cc b/ui/views/touchui/touch_selection_menu_runner_views.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2fbebcdf62b6b8d24c263cc52329ad005a4b69b9 |
--- /dev/null |
+++ b/ui/views/touchui/touch_selection_menu_runner_views.cc |
@@ -0,0 +1,68 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "ui/views/touchui/touch_selection_menu_runner_views.h" |
+ |
+#include "ui/aura/window.h" |
+#include "ui/gfx/geometry/rect.h" |
+#include "ui/gfx/geometry/size.h" |
+ |
+namespace views { |
+ |
+TouchSelectionMenuRunnerViews::TouchSelectionMenuRunnerViews() |
+ : menu_(nullptr), |
+ client_(nullptr) {} |
+ |
+TouchSelectionMenuRunnerViews::~TouchSelectionMenuRunnerViews() {} |
+ |
+void TouchSelectionMenuRunnerViews::RunMenu( |
+ ui::TouchSelectionMenuClient* client, |
+ const gfx::Rect& anchor_rect, |
+ const gfx::Size& handle_image_size, |
+ aura::Window* context) { |
+ CloseMenu(); |
+ |
+ DCHECK(!menu_); |
+ DCHECK(!client_); |
+ |
+ client_ = client; |
+ menu_ = TouchEditingMenuView::Create(this, anchor_rect, handle_image_size, |
+ context); |
+ |
+ if (!menu_) |
+ client_ = nullptr; |
+} |
+ |
+void TouchSelectionMenuRunnerViews::CloseMenu() { |
+ if (menu_) { |
+ menu_->Close(); |
+ menu_ = nullptr; |
+ client_ = nullptr; |
+ } |
+} |
+ |
+bool TouchSelectionMenuRunnerViews::IsRunning() const { |
+ return menu_ != nullptr; |
+} |
+ |
+bool TouchSelectionMenuRunnerViews::IsCommandIdEnabled(int command_id) const { |
+ return client_->IsCommandIdEnabled(command_id); |
+} |
+ |
+void TouchSelectionMenuRunnerViews::ExecuteCommand(int command_id, |
+ int event_flags) { |
+ return client_->ExecuteCommand(command_id, event_flags); |
+} |
+ |
+void TouchSelectionMenuRunnerViews::OpenContextMenu() { |
+ return client_->OpenContextMenu(); |
+} |
+ |
+void TouchSelectionMenuRunnerViews::OnMenuClosed(TouchEditingMenuView* menu) { |
+ DCHECK(menu == menu_); // or nullptr? |
sadrul
2015/03/05 12:37:03
?
mohsen
2015/03/06 23:10:08
Removed comment.
|
+ menu_ = nullptr; |
+ client_ = nullptr; |
+} |
+ |
+} // namespace views |