| OLD | NEW |
| 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> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 11 #include "base/supports_user_data.h" | 13 #include "base/supports_user_data.h" |
| 12 #include "ui/aura/aura_export.h" | 14 #include "ui/aura/aura_export.h" |
| 13 #include "ui/events/event_handler.h" | 15 #include "ui/events/event_handler.h" |
| 14 #include "ui/events/event_target.h" | 16 #include "ui/events/event_target.h" |
| 15 #include "ui/gfx/geometry/point.h" | 17 #include "ui/gfx/geometry/point.h" |
| 16 | 18 |
| 17 namespace ui { | 19 namespace ui { |
| 18 class ContextFactory; | 20 class ContextFactory; |
| 19 class PlatformEventSource; | 21 class PlatformEventSource; |
| 20 } | 22 } |
| 21 namespace aura { | 23 namespace aura { |
| 22 | 24 |
| 23 namespace test { | 25 namespace test { |
| 24 class EnvTestHelper; | 26 class EnvTestHelper; |
| 25 } | 27 } |
| 26 | 28 |
| 27 class EnvObserver; | 29 class EnvObserver; |
| 28 class InputStateLookup; | 30 class InputStateLookup; |
| 29 class Window; | 31 class Window; |
| 30 class WindowTreeHost; | 32 class WindowTreeHost; |
| 31 | 33 |
| 32 // A singleton object that tracks general state within Aura. | 34 // A singleton object that tracks general state within Aura. |
| 33 class AURA_EXPORT Env : public ui::EventTarget, public base::SupportsUserData { | 35 class AURA_EXPORT Env : public ui::EventTarget, public base::SupportsUserData { |
| 34 public: | 36 public: |
| 35 // Creates the single Env instance (if it hasn't been created yet). If | 37 ~Env() override; |
| 36 // |create_event_source| is true a PlatformEventSource is created. | 38 |
| 37 // TODO(sky): nuke |create_event_source|. Only necessary while mojo's | 39 static std::unique_ptr<Env> CreateInstance(); |
| 38 // nativeviewportservice lives in the same process as the viewmanager. | |
| 39 static void CreateInstance(bool create_event_source); | |
| 40 static Env* GetInstance(); | 40 static Env* GetInstance(); |
| 41 static Env* GetInstanceDontCreate(); | 41 static Env* GetInstanceDontCreate(); |
| 42 static void DeleteInstance(); | |
| 43 | 42 |
| 44 void AddObserver(EnvObserver* observer); | 43 void AddObserver(EnvObserver* observer); |
| 45 void RemoveObserver(EnvObserver* observer); | 44 void RemoveObserver(EnvObserver* observer); |
| 46 | 45 |
| 47 int mouse_button_flags() const { return mouse_button_flags_; } | 46 int mouse_button_flags() const { return mouse_button_flags_; } |
| 48 void set_mouse_button_flags(int mouse_button_flags) { | 47 void set_mouse_button_flags(int mouse_button_flags) { |
| 49 mouse_button_flags_ = mouse_button_flags; | 48 mouse_button_flags_ = mouse_button_flags; |
| 50 } | 49 } |
| 51 // Returns true if a mouse button is down. This may query the native OS, | 50 // Returns true if a mouse button is down. This may query the native OS, |
| 52 // otherwise it uses |mouse_button_flags_|. | 51 // otherwise it uses |mouse_button_flags_|. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 67 context_factory_ = context_factory; | 66 context_factory_ = context_factory; |
| 68 } | 67 } |
| 69 ui::ContextFactory* context_factory() { return context_factory_; } | 68 ui::ContextFactory* context_factory() { return context_factory_; } |
| 70 | 69 |
| 71 private: | 70 private: |
| 72 friend class test::EnvTestHelper; | 71 friend class test::EnvTestHelper; |
| 73 friend class Window; | 72 friend class Window; |
| 74 friend class WindowTreeHost; | 73 friend class WindowTreeHost; |
| 75 | 74 |
| 76 Env(); | 75 Env(); |
| 77 ~Env() override; | |
| 78 | 76 |
| 79 // See description of CreateInstance() for deatils of |create_event_source|. | 77 void Init(); |
| 80 void Init(bool create_event_source); | |
| 81 | 78 |
| 82 // Called by the Window when it is initialized. Notifies observers. | 79 // Called by the Window when it is initialized. Notifies observers. |
| 83 void NotifyWindowInitialized(Window* window); | 80 void NotifyWindowInitialized(Window* window); |
| 84 | 81 |
| 85 // Called by the WindowTreeHost when it is initialized. Notifies observers. | 82 // Called by the WindowTreeHost when it is initialized. Notifies observers. |
| 86 void NotifyHostInitialized(WindowTreeHost* host); | 83 void NotifyHostInitialized(WindowTreeHost* host); |
| 87 | 84 |
| 88 // Invoked by WindowTreeHost when it is activated. Notifies observers. | 85 // Invoked by WindowTreeHost when it is activated. Notifies observers. |
| 89 void NotifyHostActivated(WindowTreeHost* host); | 86 void NotifyHostActivated(WindowTreeHost* host); |
| 90 | 87 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 105 scoped_ptr<ui::PlatformEventSource> event_source_; | 102 scoped_ptr<ui::PlatformEventSource> event_source_; |
| 106 | 103 |
| 107 ui::ContextFactory* context_factory_; | 104 ui::ContextFactory* context_factory_; |
| 108 | 105 |
| 109 DISALLOW_COPY_AND_ASSIGN(Env); | 106 DISALLOW_COPY_AND_ASSIGN(Env); |
| 110 }; | 107 }; |
| 111 | 108 |
| 112 } // namespace aura | 109 } // namespace aura |
| 113 | 110 |
| 114 #endif // UI_AURA_ENV_H_ | 111 #endif // UI_AURA_ENV_H_ |
| OLD | NEW |