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

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

Issue 1297173003: Revert of 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 ~Env() override; 34 // Creates the single Env instance (if it hasn't been created yet). If
35 35 // |create_event_source| is true a PlatformEventSource is created.
36 static scoped_ptr<Env> CreateInstance(); 36 // TODO(sky): nuke |create_event_source|. Only necessary while mojo's
37 // nativeviewportservice lives in the same process as the viewmanager.
38 static void CreateInstance(bool create_event_source);
37 static Env* GetInstance(); 39 static Env* GetInstance();
38 static Env* GetInstanceDontCreate(); 40 static Env* GetInstanceDontCreate();
41 static void DeleteInstance();
39 42
40 void AddObserver(EnvObserver* observer); 43 void AddObserver(EnvObserver* observer);
41 void RemoveObserver(EnvObserver* observer); 44 void RemoveObserver(EnvObserver* observer);
42 45
43 int mouse_button_flags() const { return mouse_button_flags_; } 46 int mouse_button_flags() const { return mouse_button_flags_; }
44 void set_mouse_button_flags(int mouse_button_flags) { 47 void set_mouse_button_flags(int mouse_button_flags) {
45 mouse_button_flags_ = mouse_button_flags; 48 mouse_button_flags_ = mouse_button_flags;
46 } 49 }
47 // 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,
48 // otherwise it uses |mouse_button_flags_|. 51 // otherwise it uses |mouse_button_flags_|.
(...skipping 14 matching lines...) Expand all
63 context_factory_ = context_factory; 66 context_factory_ = context_factory;
64 } 67 }
65 ui::ContextFactory* context_factory() { return context_factory_; } 68 ui::ContextFactory* context_factory() { return context_factory_; }
66 69
67 private: 70 private:
68 friend class test::EnvTestHelper; 71 friend class test::EnvTestHelper;
69 friend class Window; 72 friend class Window;
70 friend class WindowTreeHost; 73 friend class WindowTreeHost;
71 74
72 Env(); 75 Env();
76 ~Env() override;
73 77
74 void Init(); 78 // See description of CreateInstance() for deatils of |create_event_source|.
79 void Init(bool create_event_source);
75 80
76 // Called by the Window when it is initialized. Notifies observers. 81 // Called by the Window when it is initialized. Notifies observers.
77 void NotifyWindowInitialized(Window* window); 82 void NotifyWindowInitialized(Window* window);
78 83
79 // Called by the WindowTreeHost when it is initialized. Notifies observers. 84 // Called by the WindowTreeHost when it is initialized. Notifies observers.
80 void NotifyHostInitialized(WindowTreeHost* host); 85 void NotifyHostInitialized(WindowTreeHost* host);
81 86
82 // Invoked by WindowTreeHost when it is activated. Notifies observers. 87 // Invoked by WindowTreeHost when it is activated. Notifies observers.
83 void NotifyHostActivated(WindowTreeHost* host); 88 void NotifyHostActivated(WindowTreeHost* host);
84 89
(...skipping 14 matching lines...) Expand all
99 scoped_ptr<ui::PlatformEventSource> event_source_; 104 scoped_ptr<ui::PlatformEventSource> event_source_;
100 105
101 ui::ContextFactory* context_factory_; 106 ui::ContextFactory* context_factory_;
102 107
103 DISALLOW_COPY_AND_ASSIGN(Env); 108 DISALLOW_COPY_AND_ASSIGN(Env);
104 }; 109 };
105 110
106 } // namespace aura 111 } // namespace aura
107 112
108 #endif // UI_AURA_ENV_H_ 113 #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