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

Side by Side Diff: chrome/browser/chromeos/login/screen_locker.cc

Issue 8711003: Enable WebUI ScreenLocker for aura by abstracting lock window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reviewer comments. Created 9 years 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
OLDNEW
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
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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 screen_locker_->EnableInput(); 392 screen_locker_->EnableInput();
386 } else { 393 } else {
387 // This can happen when a user requested unlock, but PowerManager 394 // This can happen when a user requested unlock, but PowerManager
388 // rejected because the computer is closed, then PowerManager unlocked 395 // rejected because the computer is closed, then PowerManager unlocked
389 // because it's open again and the above failure message arrives. 396 // because it's open again and the above failure message arrives.
390 // This'd be extremely rare, but may still happen. 397 // This'd be extremely rare, but may still happen.
391 VLOG(1) << "UnlockScreenFailed: screen is already unlocked."; 398 VLOG(1) << "UnlockScreenFailed: screen is already unlocked.";
392 } 399 }
393 } 400 }
394 401
402 #if !defined(USE_AURA)
395 // static 403 // static
396 bool ScreenLocker::UseWebUILockScreen() { 404 bool ScreenLocker::UseWebUILockScreen() {
397 return !CommandLine::ForCurrentProcess()->HasSwitch( 405 return !CommandLine::ForCurrentProcess()->HasSwitch(
398 switches::kDisableWebUILockScreen); 406 switches::kDisableWebUILockScreen);
399 } 407 }
408 #endif
400 409
401 // static 410 // static
402 void ScreenLocker::InitClass() { 411 void ScreenLocker::InitClass() {
403 g_screen_lock_observer.Get(); 412 g_screen_lock_observer.Get();
404 } 413 }
405 414
406 //////////////////////////////////////////////////////////////////////////////// 415 ////////////////////////////////////////////////////////////////////////////////
407 // ScreenLocker, private: 416 // ScreenLocker, private:
408 417
409 ScreenLocker::~ScreenLocker() { 418 ScreenLocker::~ScreenLocker() {
(...skipping 22 matching lines...) Expand all
432 441
433 bool state = true; 442 bool state = true;
434 content::NotificationService::current()->Notify( 443 content::NotificationService::current()->Notify(
435 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, 444 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED,
436 content::Source<ScreenLocker>(this), 445 content::Source<ScreenLocker>(this),
437 content::Details<bool>(&state)); 446 content::Details<bool>(&state));
438 CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenLockCompleted(); 447 CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenLockCompleted();
439 } 448 }
440 449
441 } // namespace chromeos 450 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/screen_locker.h ('k') | chrome/browser/chromeos/login/webui_screen_locker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698