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

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

Issue 1293013002: aura: Require explicit ownership of the Env instance. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 4 months 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/demo/demo_main.cc ('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 "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/observer_list.h" 9 #include "base/observer_list.h"
10 #include "base/supports_user_data.h" 10 #include "base/supports_user_data.h"
(...skipping 13 matching lines...) Expand all
24 } 24 }
25 25
26 class EnvObserver; 26 class EnvObserver;
27 class InputStateLookup; 27 class InputStateLookup;
28 class Window; 28 class Window;
29 class WindowTreeHost; 29 class WindowTreeHost;
30 30
31 // A singleton object that tracks general state within Aura. 31 // A singleton object that tracks general state within Aura.
32 class AURA_EXPORT Env : public ui::EventTarget, public base::SupportsUserData { 32 class AURA_EXPORT Env : public ui::EventTarget, public base::SupportsUserData {
33 public: 33 public:
34 // Creates the single Env instance (if it hasn't been created yet). If 34 ~Env() override;
35 // |create_event_source| is true a PlatformEventSource is created. 35
36 // TODO(sky): nuke |create_event_source|. Only necessary while mojo's 36 static scoped_ptr<Env> CreateInstance();
37 // nativeviewportservice lives in the same process as the viewmanager.
38 static void CreateInstance(bool create_event_source);
39 static Env* GetInstance(); 37 static Env* GetInstance();
40 static Env* GetInstanceDontCreate(); 38 static Env* GetInstanceDontCreate();
41 static void DeleteInstance();
42 39
43 void AddObserver(EnvObserver* observer); 40 void AddObserver(EnvObserver* observer);
44 void RemoveObserver(EnvObserver* observer); 41 void RemoveObserver(EnvObserver* observer);
45 42
46 int mouse_button_flags() const { return mouse_button_flags_; } 43 int mouse_button_flags() const { return mouse_button_flags_; }
47 void set_mouse_button_flags(int mouse_button_flags) { 44 void set_mouse_button_flags(int mouse_button_flags) {
48 mouse_button_flags_ = mouse_button_flags; 45 mouse_button_flags_ = mouse_button_flags;
49 } 46 }
50 // Returns true if a mouse button is down. This may query the native OS, 47 // Returns true if a mouse button is down. This may query the native OS,
51 // otherwise it uses |mouse_button_flags_|. 48 // otherwise it uses |mouse_button_flags_|.
(...skipping 14 matching lines...) Expand all
66 context_factory_ = context_factory; 63 context_factory_ = context_factory;
67 } 64 }
68 ui::ContextFactory* context_factory() { return context_factory_; } 65 ui::ContextFactory* context_factory() { return context_factory_; }
69 66
70 private: 67 private:
71 friend class test::EnvTestHelper; 68 friend class test::EnvTestHelper;
72 friend class Window; 69 friend class Window;
73 friend class WindowTreeHost; 70 friend class WindowTreeHost;
74 71
75 Env(); 72 Env();
76 ~Env() override;
77 73
78 // See description of CreateInstance() for deatils of |create_event_source|. 74 void Init();
79 void Init(bool create_event_source);
80 75
81 // Called by the Window when it is initialized. Notifies observers. 76 // Called by the Window when it is initialized. Notifies observers.
82 void NotifyWindowInitialized(Window* window); 77 void NotifyWindowInitialized(Window* window);
83 78
84 // Called by the WindowTreeHost when it is initialized. Notifies observers. 79 // Called by the WindowTreeHost when it is initialized. Notifies observers.
85 void NotifyHostInitialized(WindowTreeHost* host); 80 void NotifyHostInitialized(WindowTreeHost* host);
86 81
87 // Invoked by WindowTreeHost when it is activated. Notifies observers. 82 // Invoked by WindowTreeHost when it is activated. Notifies observers.
88 void NotifyHostActivated(WindowTreeHost* host); 83 void NotifyHostActivated(WindowTreeHost* host);
89 84
(...skipping 14 matching lines...) Expand all
104 scoped_ptr<ui::PlatformEventSource> event_source_; 99 scoped_ptr<ui::PlatformEventSource> event_source_;
105 100
106 ui::ContextFactory* context_factory_; 101 ui::ContextFactory* context_factory_;
107 102
108 DISALLOW_COPY_AND_ASSIGN(Env); 103 DISALLOW_COPY_AND_ASSIGN(Env);
109 }; 104 };
110 105
111 } // namespace aura 106 } // namespace aura
112 107
113 #endif // UI_AURA_ENV_H_ 108 #endif // UI_AURA_ENV_H_
OLDNEW
« no previous file with comments | « ui/aura/demo/demo_main.cc ('k') | ui/aura/env.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698