Chromium Code Reviews| 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..6a912ddb61fc56975c4b464fdc808fe91f5a8085 |
| --- /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; |
|
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
|
| +} |
| + |
| +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_); |
|
sadrul
2015/04/29 19:55:03
DCHECK_EQ
mohsen
2015/04/30 18:29:34
Done.
|
| + menu_ = nullptr; |
| + client_ = nullptr; |
| +} |
| + |
| +} // namespace views |