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

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

Issue 23882007: Explicit initialization of aura::Env for browser shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased no-op Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura/env.h ('k') | ui/aura/test/aura_test_helper.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 #include "ui/aura/env.h" 5 #include "ui/aura/env.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "ui/aura/env_observer.h" 8 #include "ui/aura/env_observer.h"
9 #include "ui/aura/root_window_host.h" 9 #include "ui/aura/root_window_host.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
(...skipping 21 matching lines...) Expand all
32 #if defined(USE_X11) 32 #if defined(USE_X11)
33 base::MessagePumpX11::Current()->RemoveObserver( 33 base::MessagePumpX11::Current()->RemoveObserver(
34 &device_list_updater_aurax11_); 34 &device_list_updater_aurax11_);
35 #endif 35 #endif
36 36
37 FOR_EACH_OBSERVER(EnvObserver, observers_, OnWillDestroyEnv()); 37 FOR_EACH_OBSERVER(EnvObserver, observers_, OnWillDestroyEnv());
38 38
39 ui::Compositor::Terminate(); 39 ui::Compositor::Terminate();
40 } 40 }
41 41
42 //static
43 void Env::CreateInstance() {
44 if (!instance_) {
45 instance_ = new Env;
46 instance_->Init();
47 }
48 }
49
42 // static 50 // static
43 Env* Env::GetInstance() { 51 Env* Env::GetInstance() {
44 if (!instance_) { 52 DCHECK(instance_) << "Env::CreateInstance must be called before getting "
45 instance_ = new Env; 53 "the instance of Env.";
46 instance_->Init();
47 }
48 return instance_; 54 return instance_;
49 } 55 }
50 56
51 // static 57 // static
52 void Env::DeleteInstance() { 58 void Env::DeleteInstance() {
53 delete instance_; 59 delete instance_;
54 instance_ = NULL; 60 instance_ = NULL;
55 } 61 }
56 62
57 void Env::AddObserver(EnvObserver* observer) { 63 void Env::AddObserver(EnvObserver* observer) {
58 observers_.AddObserver(observer); 64 observers_.AddObserver(observer);
59 } 65 }
60 66
61 void Env::RemoveObserver(EnvObserver* observer) { 67 void Env::RemoveObserver(EnvObserver* observer) {
62 observers_.RemoveObserver(observer); 68 observers_.RemoveObserver(observer);
63 } 69 }
64 70
71 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) && \
72 !defined(USE_GTK_MESSAGE_PUMP)
65 base::MessageLoop::Dispatcher* Env::GetDispatcher() { 73 base::MessageLoop::Dispatcher* Env::GetDispatcher() {
66 #if defined(USE_X11) 74 #if defined(USE_X11)
67 return base::MessagePumpX11::Current(); 75 return base::MessagePumpX11::Current();
68 #else 76 #else
69 return dispatcher_.get(); 77 return dispatcher_.get();
70 #endif 78 #endif
71 } 79 }
80 #endif
72 81
73 void Env::RootWindowActivated(RootWindow* root_window) { 82 void Env::RootWindowActivated(RootWindow* root_window) {
74 FOR_EACH_OBSERVER(EnvObserver, observers_, 83 FOR_EACH_OBSERVER(EnvObserver, observers_,
75 OnRootWindowActivated(root_window)); 84 OnRootWindowActivated(root_window));
76 } 85 }
77 86
78 //////////////////////////////////////////////////////////////////////////////// 87 ////////////////////////////////////////////////////////////////////////////////
79 // Env, private: 88 // Env, private:
80 89
81 void Env::Init() { 90 void Env::Init() {
82 #if !defined(USE_X11) && !defined(USE_OZONE) 91 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) && !defined(USE_X11) && \
92 !defined(USE_OZONE)
83 dispatcher_.reset(CreateDispatcher()); 93 dispatcher_.reset(CreateDispatcher());
84 #endif 94 #endif
85 #if defined(USE_X11) 95 #if defined(USE_X11)
86 // We can't do this with a root window listener because XI_HierarchyChanged 96 // We can't do this with a root window listener because XI_HierarchyChanged
87 // messages don't have a target window. 97 // messages don't have a target window.
88 base::MessagePumpX11::Current()->AddObserver( 98 base::MessagePumpX11::Current()->AddObserver(
89 &device_list_updater_aurax11_); 99 &device_list_updater_aurax11_);
90 #endif 100 #endif
91 ui::Compositor::Initialize(); 101 ui::Compositor::Initialize();
92 } 102 }
(...skipping 13 matching lines...) Expand all
106 116
107 bool Env::CanAcceptEvent(const ui::Event& event) { 117 bool Env::CanAcceptEvent(const ui::Event& event) {
108 return true; 118 return true;
109 } 119 }
110 120
111 ui::EventTarget* Env::GetParentTarget() { 121 ui::EventTarget* Env::GetParentTarget() {
112 return NULL; 122 return NULL;
113 } 123 }
114 124
115 } // namespace aura 125 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/env.h ('k') | ui/aura/test/aura_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698