Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: ui/aura/env.h

Issue 2446893005: Adds a porting layer so aura can be made to work with mus (Closed)
Patch Set: better Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/aura/BUILD.gn ('k') | ui/aura/env.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_AURA_ENV_H_ 5 #ifndef UI_AURA_ENV_H_
6 #define UI_AURA_ENV_H_ 6 #define UI_AURA_ENV_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/observer_list.h" 12 #include "base/observer_list.h"
12 #include "base/supports_user_data.h" 13 #include "base/supports_user_data.h"
13 #include "ui/aura/aura_export.h" 14 #include "ui/aura/aura_export.h"
14 #include "ui/events/event_handler.h" 15 #include "ui/events/event_handler.h"
15 #include "ui/events/event_target.h" 16 #include "ui/events/event_target.h"
16 #include "ui/gfx/geometry/point.h" 17 #include "ui/gfx/geometry/point.h"
17 18
18 namespace ui { 19 namespace ui {
19 class ContextFactory; 20 class ContextFactory;
20 class PlatformEventSource; 21 class PlatformEventSource;
21 } 22 }
22 namespace aura { 23 namespace aura {
23 24
24 namespace test { 25 namespace test {
25 class EnvTestHelper; 26 class EnvTestHelper;
26 } 27 }
27 28
28 class EnvObserver; 29 class EnvObserver;
29 class InputStateLookup; 30 class InputStateLookup;
30 class Window; 31 class Window;
32 class WindowPort;
31 class WindowTreeHost; 33 class WindowTreeHost;
32 34
33 // A singleton object that tracks general state within Aura. 35 // A singleton object that tracks general state within Aura.
34 class AURA_EXPORT Env : public ui::EventTarget, public base::SupportsUserData { 36 class AURA_EXPORT Env : public ui::EventTarget, public base::SupportsUserData {
35 public: 37 public:
36 ~Env() override; 38 ~Env() override;
37 39
38 static std::unique_ptr<Env> CreateInstance(); 40 using WindowPortFactory =
41 base::Callback<std::unique_ptr<WindowPort>(Window* window)>;
42 static std::unique_ptr<Env> CreateInstance(
43 const WindowPortFactory& window_port_factory = WindowPortFactory());
39 static Env* GetInstance(); 44 static Env* GetInstance();
40 static Env* GetInstanceDontCreate(); 45 static Env* GetInstanceDontCreate();
41 46
47 // Called internally to create the appropriate WindowPort implementation.
48 std::unique_ptr<WindowPort> CreateWindowPort(Window* window);
49
42 void AddObserver(EnvObserver* observer); 50 void AddObserver(EnvObserver* observer);
43 void RemoveObserver(EnvObserver* observer); 51 void RemoveObserver(EnvObserver* observer);
44 52
45 int mouse_button_flags() const { return mouse_button_flags_; } 53 int mouse_button_flags() const { return mouse_button_flags_; }
46 void set_mouse_button_flags(int mouse_button_flags) { 54 void set_mouse_button_flags(int mouse_button_flags) {
47 mouse_button_flags_ = mouse_button_flags; 55 mouse_button_flags_ = mouse_button_flags;
48 } 56 }
49 // Returns true if a mouse button is down. This may query the native OS, 57 // Returns true if a mouse button is down. This may query the native OS,
50 // otherwise it uses |mouse_button_flags_|. 58 // otherwise it uses |mouse_button_flags_|.
51 bool IsMouseButtonDown() const; 59 bool IsMouseButtonDown() const;
(...skipping 12 matching lines...) Expand all
64 void set_context_factory(ui::ContextFactory* context_factory) { 72 void set_context_factory(ui::ContextFactory* context_factory) {
65 context_factory_ = context_factory; 73 context_factory_ = context_factory;
66 } 74 }
67 ui::ContextFactory* context_factory() { return context_factory_; } 75 ui::ContextFactory* context_factory() { return context_factory_; }
68 76
69 private: 77 private:
70 friend class test::EnvTestHelper; 78 friend class test::EnvTestHelper;
71 friend class Window; 79 friend class Window;
72 friend class WindowTreeHost; 80 friend class WindowTreeHost;
73 81
74 Env(); 82 explicit Env(const WindowPortFactory& window_port_factory);
75 83
76 void Init(); 84 void Init();
77 85
78 // Called by the Window when it is initialized. Notifies observers. 86 // Called by the Window when it is initialized. Notifies observers.
79 void NotifyWindowInitialized(Window* window); 87 void NotifyWindowInitialized(Window* window);
80 88
81 // Called by the WindowTreeHost when it is initialized. Notifies observers. 89 // Called by the WindowTreeHost when it is initialized. Notifies observers.
82 void NotifyHostInitialized(WindowTreeHost* host); 90 void NotifyHostInitialized(WindowTreeHost* host);
83 91
84 // Invoked by WindowTreeHost when it is activated. Notifies observers. 92 // Invoked by WindowTreeHost when it is activated. Notifies observers.
85 void NotifyHostActivated(WindowTreeHost* host); 93 void NotifyHostActivated(WindowTreeHost* host);
86 94
87 // Overridden from ui::EventTarget: 95 // Overridden from ui::EventTarget:
88 bool CanAcceptEvent(const ui::Event& event) override; 96 bool CanAcceptEvent(const ui::Event& event) override;
89 ui::EventTarget* GetParentTarget() override; 97 ui::EventTarget* GetParentTarget() override;
90 std::unique_ptr<ui::EventTargetIterator> GetChildIterator() const override; 98 std::unique_ptr<ui::EventTargetIterator> GetChildIterator() const override;
91 ui::EventTargeter* GetEventTargeter() override; 99 ui::EventTargeter* GetEventTargeter() override;
92 100
101 WindowPortFactory window_port_factory_;
102
93 base::ObserverList<EnvObserver> observers_; 103 base::ObserverList<EnvObserver> observers_;
94 104
95 int mouse_button_flags_; 105 int mouse_button_flags_;
96 // Location of last mouse event, in screen coordinates. 106 // Location of last mouse event, in screen coordinates.
97 gfx::Point last_mouse_location_; 107 gfx::Point last_mouse_location_;
98 bool is_touch_down_; 108 bool is_touch_down_;
99 109
100 std::unique_ptr<InputStateLookup> input_state_lookup_; 110 std::unique_ptr<InputStateLookup> input_state_lookup_;
101 std::unique_ptr<ui::PlatformEventSource> event_source_; 111 std::unique_ptr<ui::PlatformEventSource> event_source_;
102 112
103 ui::ContextFactory* context_factory_; 113 ui::ContextFactory* context_factory_;
104 114
105 DISALLOW_COPY_AND_ASSIGN(Env); 115 DISALLOW_COPY_AND_ASSIGN(Env);
106 }; 116 };
107 117
108 } // namespace aura 118 } // namespace aura
109 119
110 #endif // UI_AURA_ENV_H_ 120 #endif // UI_AURA_ENV_H_
OLDNEW
« no previous file with comments | « ui/aura/BUILD.gn ('k') | ui/aura/env.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698