OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/login/screen_locker.h" | 5 #include "chrome/browser/chromeos/login/screen_locker.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
17 #include "base/timer.h" | 17 #include "base/timer.h" |
18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
19 #include "chrome/browser/chromeos/cros/cros_library.h" | 19 #include "chrome/browser/chromeos/cros/cros_library.h" |
20 #include "chrome/browser/chromeos/cros/screen_lock_library.h" | 20 #include "chrome/browser/chromeos/cros/screen_lock_library.h" |
21 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" | 21 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
22 #include "chrome/browser/chromeos/dbus/session_manager_client.h" | 22 #include "chrome/browser/chromeos/dbus/session_manager_client.h" |
23 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 23 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
24 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 24 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
25 #include "chrome/browser/chromeos/input_method/xkeyboard.h" | 25 #include "chrome/browser/chromeos/input_method/xkeyboard.h" |
26 #include "chrome/browser/chromeos/language_preferences.h" | 26 #include "chrome/browser/chromeos/language_preferences.h" |
27 #include "chrome/browser/chromeos/login/authenticator.h" | 27 #include "chrome/browser/chromeos/login/authenticator.h" |
28 #include "chrome/browser/chromeos/login/login_performer.h" | 28 #include "chrome/browser/chromeos/login/login_performer.h" |
29 #include "chrome/browser/chromeos/login/login_utils.h" | 29 #include "chrome/browser/chromeos/login/login_utils.h" |
30 #include "chrome/browser/chromeos/login/screen_locker_views.h" | |
31 #include "chrome/browser/chromeos/login/user_manager.h" | 30 #include "chrome/browser/chromeos/login/user_manager.h" |
32 #include "chrome/browser/chromeos/login/webui_screen_locker.h" | 31 #include "chrome/browser/chromeos/login/webui_screen_locker.h" |
33 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
34 #include "chrome/browser/profiles/profile_manager.h" | 33 #include "chrome/browser/profiles/profile_manager.h" |
35 #include "chrome/browser/sync/profile_sync_service.h" | 34 #include "chrome/browser/sync/profile_sync_service.h" |
36 #include "chrome/browser/ui/browser.h" | 35 #include "chrome/browser/ui/browser.h" |
37 #include "chrome/browser/ui/browser_list.h" | 36 #include "chrome/browser/ui/browser_list.h" |
38 #include "chrome/browser/ui/browser_window.h" | 37 #include "chrome/browser/ui/browser_window.h" |
39 #include "chrome/common/chrome_notification_types.h" | 38 #include "chrome/common/chrome_notification_types.h" |
40 #include "chrome/common/chrome_switches.h" | 39 #include "chrome/common/chrome_switches.h" |
41 #include "content/browser/user_metrics.h" | 40 #include "content/browser/user_metrics.h" |
42 #include "content/public/browser/browser_thread.h" | 41 #include "content/public/browser/browser_thread.h" |
43 #include "content/public/browser/notification_service.h" | 42 #include "content/public/browser/notification_service.h" |
44 #include "googleurl/src/gurl.h" | 43 #include "googleurl/src/gurl.h" |
45 #include "grit/generated_resources.h" | 44 #include "grit/generated_resources.h" |
46 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" | 45 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" |
47 #include "ui/base/l10n/l10n_util.h" | 46 #include "ui/base/l10n/l10n_util.h" |
48 | 47 |
49 #if defined(TOOLKIT_USES_GTK) | 48 #if defined(TOOLKIT_USES_GTK) |
50 #include "chrome/browser/chromeos/legacy_window_manager/wm_ipc.h" | 49 #include "chrome/browser/chromeos/legacy_window_manager/wm_ipc.h" |
51 #endif | 50 #endif |
52 | 51 |
52 #if !defined(USE_AURA) | |
53 #include "chrome/browser/chromeos/login/screen_locker_views.h" | |
54 #endif | |
55 | |
53 using content::BrowserThread; | 56 using content::BrowserThread; |
54 | 57 |
55 namespace { | 58 namespace { |
56 | 59 |
57 // Observer to start ScreenLocker when the screen lock | 60 // Observer to start ScreenLocker when the screen lock |
58 class ScreenLockObserver : public chromeos::ScreenLockLibrary::Observer, | 61 class ScreenLockObserver : public chromeos::ScreenLockLibrary::Observer, |
59 public content::NotificationObserver { | 62 public content::NotificationObserver { |
60 public: | 63 public: |
61 ScreenLockObserver() { | 64 ScreenLockObserver() { |
62 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 65 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 unlock_on_input_(user_.email().empty()), | 197 unlock_on_input_(user_.email().empty()), |
195 locked_(false), | 198 locked_(false), |
196 start_time_(base::Time::Now()), | 199 start_time_(base::Time::Now()), |
197 login_status_consumer_(NULL) { | 200 login_status_consumer_(NULL) { |
198 DCHECK(!screen_locker_); | 201 DCHECK(!screen_locker_); |
199 screen_locker_ = this; | 202 screen_locker_ = this; |
200 } | 203 } |
201 | 204 |
202 void ScreenLocker::Init() { | 205 void ScreenLocker::Init() { |
203 authenticator_ = LoginUtils::Get()->CreateAuthenticator(this); | 206 authenticator_ = LoginUtils::Get()->CreateAuthenticator(this); |
207 #if defined(USE_AURA) | |
208 delegate_.reset(new WebUIScreenLocker(this)); | |
209 #else | |
204 if (UseWebUILockScreen()) | 210 if (UseWebUILockScreen()) |
205 delegate_.reset(new WebUIScreenLocker(this)); | 211 delegate_.reset(new WebUIScreenLocker(this)); |
206 else | 212 else |
207 delegate_.reset(new ScreenLockerViews(this)); | 213 delegate_.reset(new ScreenLockerViews(this)); |
214 #endif | |
208 delegate_->LockScreen(unlock_on_input_); | 215 delegate_->LockScreen(unlock_on_input_); |
209 } | 216 } |
210 | 217 |
211 void ScreenLocker::OnLoginFailure(const LoginFailure& error) { | 218 void ScreenLocker::OnLoginFailure(const LoginFailure& error) { |
212 DVLOG(1) << "OnLoginFailure"; | 219 DVLOG(1) << "OnLoginFailure"; |
213 UserMetrics::RecordAction(UserMetricsAction("ScreenLocker_OnLoginFailure")); | 220 UserMetrics::RecordAction(UserMetricsAction("ScreenLocker_OnLoginFailure")); |
214 if (authentication_start_time_.is_null()) { | 221 if (authentication_start_time_.is_null()) { |
215 LOG(ERROR) << "authentication_start_time_ is not set"; | 222 LOG(ERROR) << "authentication_start_time_ is not set"; |
216 } else { | 223 } else { |
217 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; | 224 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 // browser can be NULL if we receive a lock request before the first browser | 356 // browser can be NULL if we receive a lock request before the first browser |
350 // window is shown. | 357 // window is shown. |
351 if (browser && browser->window()->IsFullscreen()) { | 358 if (browser && browser->window()->IsFullscreen()) { |
352 browser->ToggleFullscreenMode(false); | 359 browser->ToggleFullscreenMode(false); |
353 } | 360 } |
354 | 361 |
355 if (!screen_locker_) { | 362 if (!screen_locker_) { |
356 VLOG(1) << "Show: Locking screen"; | 363 VLOG(1) << "Show: Locking screen"; |
357 ScreenLocker* locker = | 364 ScreenLocker* locker = |
358 new ScreenLocker(UserManager::Get()->logged_in_user()); | 365 new ScreenLocker(UserManager::Get()->logged_in_user()); |
359 #if defined(TOUCH_UI) | 366 #if defined(TOUCH_UI) |
oshima
2011/11/29 20:18:06
I thought TOUCH_UI has switched to AURA, correct?
flackr
2011/11/30 20:16:54
It either has or will soon. Done.
| |
360 // The views screen locker does not reliably work on TOUCH_UI builds. In | 367 // The views screen locker does not reliably work on TOUCH_UI builds. In |
361 // order to effectively "lock" the screen we will sign out the user for now. | 368 // order to effectively "lock" the screen we will sign out the user for now. |
362 // TODO(flackr): Implement lock screen in WebUI and remove this hack | 369 // TODO(flackr): Implement lock screen in WebUI and remove this hack |
363 // (crbug.com/105267). | 370 // (crbug.com/105267). |
364 if (ScreenLocker::UseWebUILockScreen()) | 371 if (ScreenLocker::UseWebUILockScreen()) |
365 locker->Init(); | 372 locker->Init(); |
366 else | 373 else |
367 locker->Signout(); | 374 locker->Signout(); |
368 #else | 375 #else |
369 locker->Init(); | 376 locker->Init(); |
(...skipping 28 matching lines...) Expand all Loading... | |
398 // This can happen when a user requested unlock, but PowerManager | 405 // This can happen when a user requested unlock, but PowerManager |
399 // rejected because the computer is closed, then PowerManager unlocked | 406 // rejected because the computer is closed, then PowerManager unlocked |
400 // because it's open again and the above failure message arrives. | 407 // because it's open again and the above failure message arrives. |
401 // This'd be extremely rare, but may still happen. | 408 // This'd be extremely rare, but may still happen. |
402 VLOG(1) << "UnlockScreenFailed: screen is already unlocked."; | 409 VLOG(1) << "UnlockScreenFailed: screen is already unlocked."; |
403 } | 410 } |
404 } | 411 } |
405 | 412 |
406 // static | 413 // static |
407 bool ScreenLocker::UseWebUILockScreen() { | 414 bool ScreenLocker::UseWebUILockScreen() { |
415 #if defined(USE_AURA) | |
416 return true; | |
417 #else | |
408 return !CommandLine::ForCurrentProcess()->HasSwitch( | 418 return !CommandLine::ForCurrentProcess()->HasSwitch( |
409 switches::kDisableWebUILockScreen); | 419 switches::kDisableWebUILockScreen); |
420 #endif | |
410 } | 421 } |
411 | 422 |
412 // static | 423 // static |
413 void ScreenLocker::InitClass() { | 424 void ScreenLocker::InitClass() { |
414 g_screen_lock_observer.Get(); | 425 g_screen_lock_observer.Get(); |
415 } | 426 } |
416 | 427 |
417 //////////////////////////////////////////////////////////////////////////////// | 428 //////////////////////////////////////////////////////////////////////////////// |
418 // ScreenLocker, private: | 429 // ScreenLocker, private: |
419 | 430 |
(...skipping 23 matching lines...) Expand all Loading... | |
443 | 454 |
444 bool state = true; | 455 bool state = true; |
445 content::NotificationService::current()->Notify( | 456 content::NotificationService::current()->Notify( |
446 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 457 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
447 content::Source<ScreenLocker>(this), | 458 content::Source<ScreenLocker>(this), |
448 content::Details<bool>(&state)); | 459 content::Details<bool>(&state)); |
449 CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenLockCompleted(); | 460 CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenLockCompleted(); |
450 } | 461 } |
451 | 462 |
452 } // namespace chromeos | 463 } // namespace chromeos |
OLD | NEW |