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

Unified Diff: ui/views/touchui/touch_selection_menu_runner_views.cc

Issue 698253004: Reland: Implement Aura side of unified touch text selection for contents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased after addition of touch_handle_orientation file Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698