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

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

Issue 8919017: Split UserMetrics into API vs. implementation. Move API to content/public. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move to content namespace. Update usages. Update extract_actions tool. 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"
(...skipping 19 matching lines...) Expand all
30 #include "chrome/browser/chromeos/login/user_manager.h" 30 #include "chrome/browser/chromeos/login/user_manager.h"
31 #include "chrome/browser/chromeos/login/webui_screen_locker.h" 31 #include "chrome/browser/chromeos/login/webui_screen_locker.h"
32 #include "chrome/browser/profiles/profile.h" 32 #include "chrome/browser/profiles/profile.h"
33 #include "chrome/browser/profiles/profile_manager.h" 33 #include "chrome/browser/profiles/profile_manager.h"
34 #include "chrome/browser/sync/profile_sync_service.h" 34 #include "chrome/browser/sync/profile_sync_service.h"
35 #include "chrome/browser/ui/browser.h" 35 #include "chrome/browser/ui/browser.h"
36 #include "chrome/browser/ui/browser_list.h" 36 #include "chrome/browser/ui/browser_list.h"
37 #include "chrome/browser/ui/browser_window.h" 37 #include "chrome/browser/ui/browser_window.h"
38 #include "chrome/common/chrome_notification_types.h" 38 #include "chrome/common/chrome_notification_types.h"
39 #include "chrome/common/chrome_switches.h" 39 #include "chrome/common/chrome_switches.h"
40 #include "content/browser/user_metrics.h"
41 #include "content/public/browser/browser_thread.h" 40 #include "content/public/browser/browser_thread.h"
42 #include "content/public/browser/notification_service.h" 41 #include "content/public/browser/notification_service.h"
42 #include "content/public/browser/user_metrics.h"
43 #include "googleurl/src/gurl.h" 43 #include "googleurl/src/gurl.h"
44 #include "grit/generated_resources.h" 44 #include "grit/generated_resources.h"
45 #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"
46 #include "ui/base/l10n/l10n_util.h" 46 #include "ui/base/l10n/l10n_util.h"
47 47
48 #if defined(TOOLKIT_USES_GTK) 48 #if defined(TOOLKIT_USES_GTK)
49 #include "chrome/browser/chromeos/legacy_window_manager/wm_ipc.h" 49 #include "chrome/browser/chromeos/legacy_window_manager/wm_ipc.h"
50 #endif 50 #endif
51 51
52 #if !defined(USE_AURA) 52 #if !defined(USE_AURA)
53 #include "chrome/browser/chromeos/login/screen_locker_views.h" 53 #include "chrome/browser/chromeos/login/screen_locker_views.h"
54 #endif 54 #endif
55 55
56 using content::BrowserThread; 56 using content::BrowserThread;
57 using content::UserMetricsAction;
57 58
58 namespace { 59 namespace {
59 60
60 // Observer to start ScreenLocker when the screen lock 61 // Observer to start ScreenLocker when the screen lock
61 class ScreenLockObserver : public chromeos::ScreenLockLibrary::Observer, 62 class ScreenLockObserver : public chromeos::ScreenLockLibrary::Observer,
62 public content::NotificationObserver { 63 public content::NotificationObserver {
63 public: 64 public:
64 ScreenLockObserver() { 65 ScreenLockObserver() {
65 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_CHANGED, 66 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_CHANGED,
66 content::NotificationService::AllSources()); 67 content::NotificationService::AllSources());
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 if (UseWebUILockScreen()) 211 if (UseWebUILockScreen())
211 delegate_.reset(new WebUIScreenLocker(this)); 212 delegate_.reset(new WebUIScreenLocker(this));
212 else 213 else
213 delegate_.reset(new ScreenLockerViews(this)); 214 delegate_.reset(new ScreenLockerViews(this));
214 #endif 215 #endif
215 delegate_->LockScreen(unlock_on_input_); 216 delegate_->LockScreen(unlock_on_input_);
216 } 217 }
217 218
218 void ScreenLocker::OnLoginFailure(const LoginFailure& error) { 219 void ScreenLocker::OnLoginFailure(const LoginFailure& error) {
219 DVLOG(1) << "OnLoginFailure"; 220 DVLOG(1) << "OnLoginFailure";
220 UserMetrics::RecordAction(UserMetricsAction("ScreenLocker_OnLoginFailure")); 221 content::RecordAction(UserMetricsAction("ScreenLocker_OnLoginFailure"));
221 if (authentication_start_time_.is_null()) { 222 if (authentication_start_time_.is_null()) {
222 LOG(ERROR) << "authentication_start_time_ is not set"; 223 LOG(ERROR) << "authentication_start_time_ is not set";
223 } else { 224 } else {
224 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; 225 base::TimeDelta delta = base::Time::Now() - authentication_start_time_;
225 VLOG(1) << "Authentication failure time: " << delta.InSecondsF(); 226 VLOG(1) << "Authentication failure time: " << delta.InSecondsF();
226 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationFailureTime", delta); 227 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationFailureTime", delta);
227 } 228 }
228 229
229 EnableInput(); 230 EnableInput();
230 // Don't enable signout button here as we're showing 231 // Don't enable signout button here as we're showing
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 } 317 }
317 318
318 void ScreenLocker::EnableInput() { 319 void ScreenLocker::EnableInput() {
319 delegate_->SetInputEnabled(true); 320 delegate_->SetInputEnabled(true);
320 } 321 }
321 322
322 void ScreenLocker::Signout() { 323 void ScreenLocker::Signout() {
323 // TODO(flackr): For proper functionality, check if (error_info) is NULL 324 // TODO(flackr): For proper functionality, check if (error_info) is NULL
324 // (crbug.com/105267). 325 // (crbug.com/105267).
325 delegate_->ClearErrors(); 326 delegate_->ClearErrors();
326 UserMetrics::RecordAction(UserMetricsAction("ScreenLocker_Signout")); 327 content::RecordAction(UserMetricsAction("ScreenLocker_Signout"));
327 #if defined(TOOLKIT_USES_GTK) 328 #if defined(TOOLKIT_USES_GTK)
328 WmIpc::instance()->NotifyAboutSignout(); 329 WmIpc::instance()->NotifyAboutSignout();
329 #endif 330 #endif
330 DBusThreadManager::Get()->GetSessionManagerClient()->StopSession(); 331 DBusThreadManager::Get()->GetSessionManagerClient()->StopSession();
331 332
332 // Don't hide yet the locker because the chrome screen may become visible 333 // Don't hide yet the locker because the chrome screen may become visible
333 // briefly. 334 // briefly.
334 } 335 }
335 336
336 void ScreenLocker::ShowErrorMessage(const string16& message, 337 void ScreenLocker::ShowErrorMessage(const string16& message,
337 bool sign_out_only) { 338 bool sign_out_only) {
338 delegate_->SetInputEnabled(!sign_out_only); 339 delegate_->SetInputEnabled(!sign_out_only);
339 delegate_->SetSignoutEnabled(sign_out_only); 340 delegate_->SetSignoutEnabled(sign_out_only);
340 delegate_->ShowErrorMessage(message, sign_out_only); 341 delegate_->ShowErrorMessage(message, sign_out_only);
341 } 342 }
342 343
343 void ScreenLocker::SetLoginStatusConsumer( 344 void ScreenLocker::SetLoginStatusConsumer(
344 chromeos::LoginStatusConsumer* consumer) { 345 chromeos::LoginStatusConsumer* consumer) {
345 login_status_consumer_ = consumer; 346 login_status_consumer_ = consumer;
346 } 347 }
347 348
348 // static 349 // static
349 void ScreenLocker::Show() { 350 void ScreenLocker::Show() {
350 DVLOG(1) << "In ScreenLocker::Show"; 351 DVLOG(1) << "In ScreenLocker::Show";
351 UserMetrics::RecordAction(UserMetricsAction("ScreenLocker_Show")); 352 content::RecordAction(UserMetricsAction("ScreenLocker_Show"));
352 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); 353 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI);
353 354
354 // Check whether the currently logged in user is a guest account and if so, 355 // Check whether the currently logged in user is a guest account and if so,
355 // refuse to lock the screen (crosbug.com/23764). 356 // refuse to lock the screen (crosbug.com/23764).
356 // TODO(flackr): We can allow lock screen for guest accounts when 357 // TODO(flackr): We can allow lock screen for guest accounts when
357 // unlock_on_input is supported by the WebUI screen locker. 358 // unlock_on_input is supported by the WebUI screen locker.
358 if (UserManager::Get()->logged_in_user().email().empty()) { 359 if (UserManager::Get()->logged_in_user().email().empty()) {
359 DVLOG(1) << "Show: Refusing to lock screen for guest account."; 360 DVLOG(1) << "Show: Refusing to lock screen for guest account.";
360 return; 361 return;
361 } 362 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 451
451 bool state = true; 452 bool state = true;
452 content::NotificationService::current()->Notify( 453 content::NotificationService::current()->Notify(
453 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, 454 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED,
454 content::Source<ScreenLocker>(this), 455 content::Source<ScreenLocker>(this),
455 content::Details<bool>(&state)); 456 content::Details<bool>(&state));
456 CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenLockCompleted(); 457 CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenLockCompleted();
457 } 458 }
458 459
459 } // namespace chromeos 460 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698