summaryrefslogtreecommitdiffstats
path: root/ui/views/touchui/touch_selection_menu_runner_views.h
blob: 03a8967afa59e03a48879efe7f13b5995136ee7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// 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.

#ifndef UI_VIEWS_TOUCHUI_TOUCH_SELECTION_MENU_RUNNER_VIEWS_H_
#define UI_VIEWS_TOUCHUI_TOUCH_SELECTION_MENU_RUNNER_VIEWS_H_

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "ui/touch_selection/touch_selection_menu_runner.h"
#include "ui/views/views_export.h"

namespace views {
class Button;
class Widget;

// Views implementation for TouchSelectionMenuRunner.
class VIEWS_EXPORT TouchSelectionMenuRunnerViews
    : public ui::TouchSelectionMenuRunner {
 public:
  // Test API to access internal state in tests.
  class VIEWS_EXPORT TestApi {
   public:
    explicit TestApi(TouchSelectionMenuRunnerViews* menu_runner);
    ~TestApi();

    gfx::Rect GetAnchorRect() const;
    Button* GetFirstButton() const;
    Widget* GetWidget() const;

   private:
    TouchSelectionMenuRunnerViews* menu_runner_;

    DISALLOW_COPY_AND_ASSIGN(TestApi);
  };

  TouchSelectionMenuRunnerViews();
  ~TouchSelectionMenuRunnerViews() override;

 private:
  friend class TouchSelectionMenuRunnerViewsTestApi;
  class Menu;

  // ui::TouchSelectionMenuRunner:
  bool IsMenuAvailable(
      const ui::TouchSelectionMenuClient* client) const override;
  void OpenMenu(ui::TouchSelectionMenuClient* client,
                const gfx::Rect& anchor_rect,
                const gfx::Size& handle_image_size,
                aura::Window* context) override;
  void CloseMenu() override;
  bool IsRunning() const override;

  // A pointer to the currently running menu, or |nullptr| if no menu is
  // running. The menu manages its own lifetime and deletes itself when closed.
  Menu* menu_;

  DISALLOW_COPY_AND_ASSIGN(TouchSelectionMenuRunnerViews);
};

}  // namespace views

#endif  // UI_VIEWS_TOUCHUI_TOUCH_SELECTION_MENU_RUNNER_VIEWS_H_