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

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 test failures on Mac Created 5 years, 8 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 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;
sadrul 2015/04/29 19:55:03 When can we have a null menu_, but a non-null clie
mohsen 2015/04/30 18:29:34 The above |Create| function returns nullptr if the
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_);
sadrul 2015/04/29 19:55:03 DCHECK_EQ
mohsen 2015/04/30 18:29:34 Done.
64 menu_ = nullptr;
65 client_ = nullptr;
66 }
67
68 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698