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

Side by Side Diff: athena/env/athena_env_impl.cc

Issue 693643004: Make UserActivityDetector a singleton (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@athena_do_not_use_ash45
Patch Set: Created 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "athena/env/public/athena_env.h" 5 #include "athena/env/public/athena_env.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "athena/util/fill_layout_manager.h" 9 #include "athena/util/fill_layout_manager.h"
10 #include "base/sys_info.h" 10 #include "base/sys_info.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 root_window->SetLayoutManager(new FillLayoutManager(root_window)); 190 root_window->SetLayoutManager(new FillLayoutManager(root_window));
191 191
192 cursor_manager_.reset( 192 cursor_manager_.reset(
193 new wm::CursorManager(scoped_ptr<wm::NativeCursorManager>( 193 new wm::CursorManager(scoped_ptr<wm::NativeCursorManager>(
194 new AthenaNativeCursorManager(host_.get())))); 194 new AthenaNativeCursorManager(host_.get()))));
195 cursor_manager_->SetDisplay( 195 cursor_manager_->SetDisplay(
196 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay()); 196 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay());
197 cursor_manager_->SetCursor(ui::kCursorPointer); 197 cursor_manager_->SetCursor(ui::kCursorPointer);
198 aura::client::SetCursorClient(host_->window(), cursor_manager_.get()); 198 aura::client::SetCursorClient(host_->window(), cursor_manager_.get());
199 199
200 user_activity_detector_.reset(new wm::UserActivityDetector);
201 host_->event_processor()->GetRootTarget()->AddPreTargetHandler( 200 host_->event_processor()->GetRootTarget()->AddPreTargetHandler(
202 user_activity_detector_.get()); 201 wm::UserActivityDetector::Get());
203 user_activity_notifier_.reset(new ui::UserActivityPowerManagerNotifier( 202 user_activity_notifier_.reset(new ui::UserActivityPowerManagerNotifier(
204 user_activity_detector_.get())); 203 wm::UserActivityDetector::Get()));
205 204
206 host_->AddObserver(this); 205 host_->AddObserver(this);
207 host_->Show(); 206 host_->Show();
208 207
209 DCHECK(!instance); 208 DCHECK(!instance);
210 instance = this; 209 instance = this;
211 } 210 }
212 211
213 ~AthenaEnvImpl() override { 212 ~AthenaEnvImpl() override {
214 instance = nullptr; 213 instance = nullptr;
215 214
216 host_->RemoveObserver(this); 215 host_->RemoveObserver(this);
217 if (input_method_filter_) 216 if (input_method_filter_)
218 root_window_event_filter_->RemoveHandler(input_method_filter_.get()); 217 root_window_event_filter_->RemoveHandler(input_method_filter_.get());
219 if (user_activity_detector_) { 218 host_->event_processor()->GetRootTarget()->RemovePreTargetHandler(
220 host_->event_processor()->GetRootTarget()->RemovePreTargetHandler( 219 wm::UserActivityDetector::Get());
221 user_activity_detector_.get());
222 }
223 root_window_event_filter_.reset(); 220 root_window_event_filter_.reset();
224 capture_client_.reset(); 221 capture_client_.reset();
225 input_method_filter_.reset(); 222 input_method_filter_.reset();
226 cursor_manager_.reset(); 223 cursor_manager_.reset();
227 user_activity_notifier_.reset(); 224 user_activity_notifier_.reset();
228 user_activity_detector_.reset();
229 225
230 input_method_filter_.reset(); 226 input_method_filter_.reset();
231 host_.reset(); 227 host_.reset();
232 228
233 ScreenForShutdown::Create(screen_.get()); 229 ScreenForShutdown::Create(screen_.get());
234 screen_.reset(); 230 screen_.reset();
235 aura::Env::DeleteInstance(); 231 aura::Env::DeleteInstance();
236 232
237 display_configurator_->RemoveObserver(this); 233 display_configurator_->RemoveObserver(this);
238 display_configurator_.reset(); 234 display_configurator_.reset();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 return mode ? mode->size() : gfx::Size(); 302 return mode ? mode->size() : gfx::Size();
307 } 303 }
308 304
309 scoped_ptr<aura::TestScreen> screen_; 305 scoped_ptr<aura::TestScreen> screen_;
310 scoped_ptr<aura::WindowTreeHost> host_; 306 scoped_ptr<aura::WindowTreeHost> host_;
311 307
312 scoped_ptr<wm::InputMethodEventFilter> input_method_filter_; 308 scoped_ptr<wm::InputMethodEventFilter> input_method_filter_;
313 scoped_ptr<wm::CompoundEventFilter> root_window_event_filter_; 309 scoped_ptr<wm::CompoundEventFilter> root_window_event_filter_;
314 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; 310 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_;
315 scoped_ptr<wm::CursorManager> cursor_manager_; 311 scoped_ptr<wm::CursorManager> cursor_manager_;
316 scoped_ptr<wm::UserActivityDetector> user_activity_detector_;
317 scoped_ptr<ui::DisplayConfigurator> display_configurator_; 312 scoped_ptr<ui::DisplayConfigurator> display_configurator_;
318 scoped_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_; 313 scoped_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_;
319 314
320 std::vector<base::Closure> terminating_callbacks_; 315 std::vector<base::Closure> terminating_callbacks_;
321 316
322 DISALLOW_COPY_AND_ASSIGN(AthenaEnvImpl); 317 DISALLOW_COPY_AND_ASSIGN(AthenaEnvImpl);
323 }; 318 };
324 319
325 } // namespace 320 } // namespace
326 321
(...skipping 10 matching lines...) Expand all
337 332
338 // static 333 // static
339 334
340 // static 335 // static
341 void AthenaEnv::Shutdown() { 336 void AthenaEnv::Shutdown() {
342 DCHECK(instance); 337 DCHECK(instance);
343 delete instance; 338 delete instance;
344 } 339 }
345 340
346 } // namespace athena 341 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698