| 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..c9ba33e0af77927d47a9fee8b7f02c82810e9036
|
| --- /dev/null
|
| +++ b/ui/views/touchui/touch_selection_menu_runner_views.cc
|
| @@ -0,0 +1,72 @@
|
| +// Copyright 2014 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) {
|
| + SetInstance(this);
|
| +}
|
| +
|
| +TouchSelectionMenuRunnerViews::~TouchSelectionMenuRunnerViews() {
|
| + SetInstance(nullptr);
|
| +}
|
| +
|
| +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?
|
| + menu_ = nullptr;
|
| + client_ = nullptr;
|
| +}
|
| +
|
| +} // namespace views
|
|
|