platformKeys: Add per-extension sign permissions.
[chromium-blink-merge.git] / ash / utility / partial_screenshot_controller.h
blob9536283ecb16bca4d03cc33fef3e276f44941fd3
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.
5 #ifndef ASH_UTILITY_PARTIAL_SCREENSHOT_CONTROLLER_H_
6 #define ASH_UTILITY_PARTIAL_SCREENSHOT_CONTROLLER_H_
8 #include <map>
10 #include "ash/ash_export.h"
11 #include "ash/shell_observer.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "ui/events/event_handler.h"
14 #include "ui/gfx/display_observer.h"
15 #include "ui/gfx/geometry/point.h"
17 namespace aura {
18 class Window;
21 namespace ui {
22 class LocatedEvent;
25 namespace ash {
26 class ScreenshotDelegate;
28 // This class controls a session of taking partial screenshot, i.e.: drawing
29 // region rectangles during drag, and changing the mouse cursor to indicate
30 // the current mode.
31 // This class does not use aura::Window / views::Widget intentionally to avoid
32 // the conflicts of window manager features like mouse captures or window focus.
33 class ASH_EXPORT PartialScreenshotController : public ui::EventHandler,
34 public ShellObserver,
35 public gfx::DisplayObserver {
36 public:
37 // Starts the UI for taking partial screenshot; dragging to select a region.
38 // PartialScreenshotController manage their own lifetime so caller must not
39 // delete the returned values.
40 static void StartPartialScreenshotSession(
41 ScreenshotDelegate* screenshot_delegate);
43 ~PartialScreenshotController() override;
45 private:
46 friend class PartialScreenshotControllerTest;
48 class ScopedCursorSetter;
49 class PartialScreenshotLayer;
51 static PartialScreenshotController* GetInstanceForTest();
53 PartialScreenshotController(ScreenshotDelegate* screenshot_delegate);
55 // Starts, ends, cancels, or updates the region selection.
56 void MaybeStart(const ui::LocatedEvent& event);
57 void Complete();
58 void Cancel();
59 void Update(const ui::LocatedEvent& event);
61 // ui::EventHandler:
62 void OnKeyEvent(ui::KeyEvent* event) override;
63 void OnMouseEvent(ui::MouseEvent* event) override;
64 void OnTouchEvent(ui::TouchEvent* event) override;
66 // ShellObserver:
67 void OnAppTerminating() override;
69 // gfx::DisplayObserver:
70 void OnDisplayAdded(const gfx::Display& new_display) override;
71 void OnDisplayRemoved(const gfx::Display& old_display) override;
72 void OnDisplayMetricsChanged(const gfx::Display& display,
73 uint32_t changed_metrics) override;
75 // The data to build the screenshot region.
76 gfx::Point start_position_;
77 aura::Window* root_window_;
79 // Layers to create the visual effect of region selection.
80 std::map<aura::Window*, PartialScreenshotLayer*> layers_;
82 // The object to specify the crosshair cursor.
83 scoped_ptr<ScopedCursorSetter> cursor_setter_;
85 // ScreenshotDelegate to take the actual screenshot. No ownership.
86 ScreenshotDelegate* screenshot_delegate_;
88 DISALLOW_COPY_AND_ASSIGN(PartialScreenshotController);
91 } // namespace ash
93 #endif // #ifndef ASH_WM_PARTIAL_SCREENSHOT_VIEW_H_