[Android] Implement 3-way sensor fallback for Device Orientation.
[chromium-blink-merge.git] / ui / wm / core / window_modality_controller.h
blob1b3baaf398c1603843702a41bad24165925116a7
1 // Copyright (c) 2012 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 UI_WM_CORE_WINDOW_MODALITY_CONTROLLER_H_
6 #define UI_WM_CORE_WINDOW_MODALITY_CONTROLLER_H_
8 #include <vector>
10 #include "base/compiler_specific.h"
11 #include "ui/aura/env_observer.h"
12 #include "ui/aura/window_observer.h"
13 #include "ui/events/event_handler.h"
14 #include "ui/wm/wm_export.h"
16 namespace ui {
17 class EventTarget;
18 class LocatedEvent;
21 namespace wm {
23 // Sets the modal parent for the child.
24 WM_EXPORT void SetModalParent(aura::Window* child, aura::Window* parent);
26 // Returns the modal transient child of |window|, or NULL if |window| does not
27 // have any modal transient children.
28 WM_EXPORT aura::Window* GetModalTransient(aura::Window* window);
30 // WindowModalityController is an event filter that consumes events sent to
31 // windows that are the transient parents of window-modal windows. This filter
32 // must be added to the CompoundEventFilter so that activation works properly.
33 class WM_EXPORT WindowModalityController : public ui::EventHandler,
34 public aura::EnvObserver,
35 public aura::WindowObserver {
36 public:
37 explicit WindowModalityController(ui::EventTarget* event_target);
38 ~WindowModalityController() override;
40 // Overridden from ui::EventHandler:
41 void OnKeyEvent(ui::KeyEvent* event) override;
42 void OnMouseEvent(ui::MouseEvent* event) override;
43 void OnTouchEvent(ui::TouchEvent* event) override;
45 // Overridden from aura::EnvObserver:
46 void OnWindowInitialized(aura::Window* window) override;
48 // Overridden from aura::WindowObserver:
49 void OnWindowPropertyChanged(aura::Window* window,
50 const void* key,
51 intptr_t old) override;
52 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override;
53 void OnWindowDestroyed(aura::Window* window) override;
55 private:
56 // Processes a mouse/touch event, and returns true if the event should be
57 // consumed.
58 bool ProcessLocatedEvent(aura::Window* target,
59 ui::LocatedEvent* event);
61 std::vector<aura::Window*> windows_;
63 ui::EventTarget* event_target_;
65 DISALLOW_COPY_AND_ASSIGN(WindowModalityController);
68 } // namespace wm
70 #endif // UI_WM_CORE_WINDOW_MODALITY_CONTROLLER_H_