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

Side by Side Diff: extensions/shell/browser/shell_desktop_controller.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 "extensions/shell/browser/shell_desktop_controller.h" 5 #include "extensions/shell/browser/shell_desktop_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 host_->window()->SetLayoutManager(new FillLayout); 269 host_->window()->SetLayoutManager(new FillLayout);
270 270
271 cursor_manager_.reset( 271 cursor_manager_.reset(
272 new wm::CursorManager(scoped_ptr<wm::NativeCursorManager>( 272 new wm::CursorManager(scoped_ptr<wm::NativeCursorManager>(
273 new ShellNativeCursorManager(host_.get())))); 273 new ShellNativeCursorManager(host_.get()))));
274 cursor_manager_->SetDisplay( 274 cursor_manager_->SetDisplay(
275 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay()); 275 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay());
276 cursor_manager_->SetCursor(ui::kCursorPointer); 276 cursor_manager_->SetCursor(ui::kCursorPointer);
277 aura::client::SetCursorClient(host_->window(), cursor_manager_.get()); 277 aura::client::SetCursorClient(host_->window(), cursor_manager_.get());
278 278
279 user_activity_detector_.reset(new wm::UserActivityDetector);
280 host_->event_processor()->GetRootTarget()->AddPreTargetHandler( 279 host_->event_processor()->GetRootTarget()->AddPreTargetHandler(
281 user_activity_detector_.get()); 280 wm::UserActivityDetector::Get());
282 #if defined(OS_CHROMEOS) 281 #if defined(OS_CHROMEOS)
283 user_activity_notifier_.reset( 282 user_activity_notifier_.reset(new ui::UserActivityPowerManagerNotifier(
284 new ui::UserActivityPowerManagerNotifier(user_activity_detector_.get())); 283 wm::UserActivityDetector::Get()));
285 #endif 284 #endif
286 } 285 }
287 286
288 void ShellDesktopController::CreateRootWindow() { 287 void ShellDesktopController::CreateRootWindow() {
289 // Set up basic pieces of ui::wm. 288 // Set up basic pieces of ui::wm.
290 gfx::Size size; 289 gfx::Size size;
291 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 290 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
292 if (command_line->HasSwitch(switches::kAppShellHostWindowBounds)) { 291 if (command_line->HasSwitch(switches::kAppShellHostWindowBounds)) {
293 const std::string size_str = 292 const std::string size_str =
294 command_line->GetSwitchValueASCII(switches::kAppShellHostWindowBounds); 293 command_line->GetSwitchValueASCII(switches::kAppShellHostWindowBounds);
(...skipping 21 matching lines...) Expand all
316 host_->AddObserver(this); 315 host_->AddObserver(this);
317 316
318 // Ensure the X window gets mapped. 317 // Ensure the X window gets mapped.
319 host_->Show(); 318 host_->Show();
320 } 319 }
321 320
322 void ShellDesktopController::DestroyRootWindow() { 321 void ShellDesktopController::DestroyRootWindow() {
323 host_->RemoveObserver(this); 322 host_->RemoveObserver(this);
324 if (input_method_filter_) 323 if (input_method_filter_)
325 root_window_event_filter_->RemoveHandler(input_method_filter_.get()); 324 root_window_event_filter_->RemoveHandler(input_method_filter_.get());
326 if (user_activity_detector_) { 325 host_->event_processor()->GetRootTarget()->RemovePreTargetHandler(
327 host_->event_processor()->GetRootTarget()->RemovePreTargetHandler( 326 wm::UserActivityDetector::Get());
328 user_activity_detector_.get());
329 }
330 wm::FocusController* focus_controller = 327 wm::FocusController* focus_controller =
331 static_cast<wm::FocusController*>(focus_client_.get()); 328 static_cast<wm::FocusController*>(focus_client_.get());
332 if (focus_controller) { 329 if (focus_controller) {
333 host_->window()->RemovePreTargetHandler(focus_controller); 330 host_->window()->RemovePreTargetHandler(focus_controller);
334 aura::client::SetActivationClient(host_->window(), NULL); 331 aura::client::SetActivationClient(host_->window(), NULL);
335 } 332 }
336 root_window_event_filter_.reset(); 333 root_window_event_filter_.reset();
337 capture_client_.reset(); 334 capture_client_.reset();
338 input_method_filter_.reset(); 335 input_method_filter_.reset();
339 focus_client_.reset(); 336 focus_client_.reset();
340 cursor_manager_.reset(); 337 cursor_manager_.reset();
341 #if defined(OS_CHROMEOS) 338 #if defined(OS_CHROMEOS)
342 user_activity_notifier_.reset(); 339 user_activity_notifier_.reset();
343 #endif 340 #endif
344 user_activity_detector_.reset();
345 host_.reset(); 341 host_.reset();
346 } 342 }
347 343
348 gfx::Size ShellDesktopController::GetPrimaryDisplaySize() { 344 gfx::Size ShellDesktopController::GetPrimaryDisplaySize() {
349 #if defined(OS_CHROMEOS) 345 #if defined(OS_CHROMEOS)
350 const std::vector<ui::DisplayConfigurator::DisplayState>& displays = 346 const std::vector<ui::DisplayConfigurator::DisplayState>& displays =
351 display_configurator_->cached_displays(); 347 display_configurator_->cached_displays();
352 if (displays.empty()) 348 if (displays.empty())
353 return gfx::Size(); 349 return gfx::Size();
354 const ui::DisplayMode* mode = displays[0].display->current_mode(); 350 const ui::DisplayMode* mode = displays[0].display->current_mode();
355 return mode ? mode->size() : gfx::Size(); 351 return mode ? mode->size() : gfx::Size();
356 #else 352 #else
357 return gfx::Size(); 353 return gfx::Size();
358 #endif 354 #endif
359 } 355 }
360 356
361 } // namespace extensions 357 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698