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

Side by Side Diff: chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.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 (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 "chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.h" 5 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.h"
6 6
7 #include "ash/screensaver/screensaver_view.h" 7 #include "ash/screensaver/screensaver_view.h"
8 #include "ash/shell.h"
9 #include "base/bind.h" 8 #include "base/bind.h"
10 #include "base/callback.h" 9 #include "base/callback.h"
11 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
12 #include "base/logging.h" 11 #include "base/logging.h"
13 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" 14 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
16 #include "chrome/browser/chromeos/login/existing_user_controller.h" 15 #include "chrome/browser/chromeos/login/existing_user_controller.h"
17 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" 16 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
18 #include "chrome/browser/chromeos/policy/app_pack_updater.h" 17 #include "chrome/browser/chromeos/policy/app_pack_updater.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // Delete it. 191 // Delete it.
193 content::BrowserThread::PostTask( 192 content::BrowserThread::PostTask(
194 content::BrowserThread::FILE, 193 content::BrowserThread::FILE,
195 FROM_HERE, 194 FROM_HERE,
196 base::Bind( 195 base::Bind(
197 &extensions::file_util::DeleteFile, extension_base_path_, true)); 196 &extensions::file_util::DeleteFile, extension_base_path_, true));
198 } 197 }
199 198
200 // In case we're shutting down without ever triggering the active 199 // In case we're shutting down without ever triggering the active
201 // notification and/or logging in. 200 // notification and/or logging in.
202 if (ash::Shell::GetInstance() && 201 wm::UserActivityDetector* user_activity_detector =
203 ash::Shell::GetInstance()->user_activity_detector() && 202 wm::UserActivityDetector::Get();
204 ash::Shell::GetInstance()->user_activity_detector()->HasObserver(this)) 203 if (user_activity_detector && user_activity_detector->HasObserver(this))
205 ash::Shell::GetInstance()->user_activity_detector()->RemoveObserver(this); 204 user_activity_detector->RemoveObserver(this);
206 } 205 }
207 206
208 void KioskModeScreensaver::GetScreensaverCrxPath() { 207 void KioskModeScreensaver::GetScreensaverCrxPath() {
209 chromeos::KioskModeSettings::Get()->GetScreensaverPath( 208 chromeos::KioskModeSettings::Get()->GetScreensaverPath(
210 base::Bind(&KioskModeScreensaver::ScreensaverPathCallback, 209 base::Bind(&KioskModeScreensaver::ScreensaverPathCallback,
211 weak_ptr_factory_.GetWeakPtr())); 210 weak_ptr_factory_.GetWeakPtr()));
212 } 211 }
213 212
214 void KioskModeScreensaver::ScreensaverPathCallback( 213 void KioskModeScreensaver::ScreensaverPathCallback(
215 const base::FilePath& screensaver_crx) { 214 const base::FilePath& screensaver_crx) {
(...skipping 29 matching lines...) Expand all
245 void KioskModeScreensaver::SetupScreensaver( 244 void KioskModeScreensaver::SetupScreensaver(
246 scoped_refptr<Extension> extension, 245 scoped_refptr<Extension> extension,
247 const base::FilePath& extension_base_path) { 246 const base::FilePath& extension_base_path) {
248 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 247 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
249 extension_base_path_ = extension_base_path; 248 extension_base_path_ = extension_base_path;
250 249
251 // If the user is already logged in, don't need to display the screensaver. 250 // If the user is already logged in, don't need to display the screensaver.
252 if (chromeos::LoginState::Get()->IsUserLoggedIn()) 251 if (chromeos::LoginState::Get()->IsUserLoggedIn())
253 return; 252 return;
254 253
255 ash::Shell::GetInstance()->user_activity_detector()->AddObserver(this); 254 wm::UserActivityDetector::Get()->AddObserver(this);
256 255
257 ExtensionService* extension_service = GetDefaultExtensionService(); 256 ExtensionService* extension_service = GetDefaultExtensionService();
258 // Add the extension to the extension service and display the screensaver. 257 // Add the extension to the extension service and display the screensaver.
259 if (extension_service) { 258 if (extension_service) {
260 extension_service->AddExtension(extension.get()); 259 extension_service->AddExtension(extension.get());
261 ash::ShowScreensaver( 260 ash::ShowScreensaver(
262 extensions::AppLaunchInfo::GetFullLaunchURL(extension.get())); 261 extensions::AppLaunchInfo::GetFullLaunchURL(extension.get()));
263 } else { 262 } else {
264 LOG(ERROR) << "Couldn't get extension system. Unable to load screensaver!"; 263 LOG(ERROR) << "Couldn't get extension system. Unable to load screensaver!";
265 ShutdownKioskModeScreensaver(); 264 ShutdownKioskModeScreensaver();
266 } 265 }
267 } 266 }
268 267
269 void KioskModeScreensaver::OnUserActivity(const ui::Event* event) { 268 void KioskModeScreensaver::OnUserActivity(const ui::Event* event) {
270 // We don't want to handle further user notifications; we'll either login 269 // We don't want to handle further user notifications; we'll either login
271 // the user and close out or or at least close the screensaver. 270 // the user and close out or or at least close the screensaver.
272 ash::Shell::GetInstance()->user_activity_detector()->RemoveObserver(this); 271 wm::UserActivityDetector::Get()->RemoveObserver(this);
273 272
274 // Find the retail mode login page. 273 // Find the retail mode login page.
275 if (LoginDisplayHostImpl::default_host()) { 274 if (LoginDisplayHostImpl::default_host()) {
276 LoginDisplayHostImpl* webui_host = 275 LoginDisplayHostImpl* webui_host =
277 static_cast<LoginDisplayHostImpl*>( 276 static_cast<LoginDisplayHostImpl*>(
278 LoginDisplayHostImpl::default_host()); 277 LoginDisplayHostImpl::default_host());
279 OobeUI* oobe_ui = webui_host->GetOobeUI(); 278 OobeUI* oobe_ui = webui_host->GetOobeUI();
280 279
281 // Show the login spinner. 280 // Show the login spinner.
282 if (oobe_ui) 281 if (oobe_ui)
(...skipping 26 matching lines...) Expand all
309 308
310 g_kiosk_mode_screensaver = new KioskModeScreensaver(); 309 g_kiosk_mode_screensaver = new KioskModeScreensaver();
311 } 310 }
312 311
313 void ShutdownKioskModeScreensaver() { 312 void ShutdownKioskModeScreensaver() {
314 delete g_kiosk_mode_screensaver; 313 delete g_kiosk_mode_screensaver;
315 g_kiosk_mode_screensaver = NULL; 314 g_kiosk_mode_screensaver = NULL;
316 } 315 }
317 316
318 } // namespace chromeos 317 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698