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

Side by Side 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: Fixed overrides in TouchHandleDrawableAura Created 5 years, 11 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 unified diff | Download patch
OLDNEW
(Empty)
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
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 SetInstance(this);
17 }
18
19 TouchSelectionMenuRunnerViews::~TouchSelectionMenuRunnerViews() {
20 SetInstance(nullptr);
21 }
22
23 void TouchSelectionMenuRunnerViews::RunMenu(
24 ui::TouchSelectionMenuClient* client,
25 const gfx::Rect& anchor_rect,
26 const gfx::Size& handle_image_size,
27 aura::Window* context) {
28 CloseMenu();
29
30 DCHECK(!menu_);
31 DCHECK(!client_);
32
33 client_ = client;
34 menu_ = TouchEditingMenuView::Create(this, anchor_rect, handle_image_size,
35 context);
36
37 if (!menu_)
38 client_ = nullptr;
39 }
40
41 void TouchSelectionMenuRunnerViews::CloseMenu() {
42 if (menu_) {
43 menu_->Close();
44 menu_ = nullptr;
45 client_ = nullptr;
46 }
47 }
48
49 bool TouchSelectionMenuRunnerViews::IsRunning() const {
50 return menu_ != nullptr;
51 }
52
53 bool TouchSelectionMenuRunnerViews::IsCommandIdEnabled(int command_id) const {
54 return client_->IsCommandIdEnabled(command_id);
55 }
56
57 void TouchSelectionMenuRunnerViews::ExecuteCommand(int command_id,
58 int event_flags) {
59 return client_->ExecuteCommand(command_id, event_flags);
60 }
61
62 void TouchSelectionMenuRunnerViews::OpenContextMenu() {
63 return client_->OpenContextMenu();
64 }
65
66 void TouchSelectionMenuRunnerViews::OnMenuClosed(TouchEditingMenuView* menu) {
67 DCHECK(menu == menu_); // or nullptr?
68 menu_ = nullptr;
69 client_ = nullptr;
70 }
71
72 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698