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

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

Issue 5709001: Place the spinner in the right corner of the controls window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/browser/chromeos/login
Patch Set: Merged with trunk. Created 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <gdk/gdkx.h> 7 #include <gdk/gdkx.h>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 #include <X11/extensions/XTest.h> 10 #include <X11/extensions/XTest.h>
(...skipping 14 matching lines...) Expand all
25 #include "chrome/browser/browser_list.h" 25 #include "chrome/browser/browser_list.h"
26 #include "chrome/browser/browser_thread.h" 26 #include "chrome/browser/browser_thread.h"
27 #include "chrome/browser/browser_window.h" 27 #include "chrome/browser/browser_window.h"
28 #include "chrome/browser/chromeos/cros/input_method_library.h" 28 #include "chrome/browser/chromeos/cros/input_method_library.h"
29 #include "chrome/browser/chromeos/cros/keyboard_library.h" 29 #include "chrome/browser/chromeos/cros/keyboard_library.h"
30 #include "chrome/browser/chromeos/cros/login_library.h" 30 #include "chrome/browser/chromeos/cros/login_library.h"
31 #include "chrome/browser/chromeos/cros/screen_lock_library.h" 31 #include "chrome/browser/chromeos/cros/screen_lock_library.h"
32 #include "chrome/browser/chromeos/language_preferences.h" 32 #include "chrome/browser/chromeos/language_preferences.h"
33 #include "chrome/browser/chromeos/login/authenticator.h" 33 #include "chrome/browser/chromeos/login/authenticator.h"
34 #include "chrome/browser/chromeos/login/background_view.h" 34 #include "chrome/browser/chromeos/login/background_view.h"
35 #include "chrome/browser/chromeos/login/helper.h"
35 #include "chrome/browser/chromeos/login/login_performer.h" 36 #include "chrome/browser/chromeos/login/login_performer.h"
36 #include "chrome/browser/chromeos/login/login_utils.h" 37 #include "chrome/browser/chromeos/login/login_utils.h"
37 #include "chrome/browser/chromeos/login/message_bubble.h" 38 #include "chrome/browser/chromeos/login/message_bubble.h"
38 #include "chrome/browser/chromeos/login/screen_lock_view.h" 39 #include "chrome/browser/chromeos/login/screen_lock_view.h"
39 #include "chrome/browser/chromeos/login/shutdown_button.h" 40 #include "chrome/browser/chromeos/login/shutdown_button.h"
40 #include "chrome/browser/chromeos/system_key_event_listener.h" 41 #include "chrome/browser/chromeos/system_key_event_listener.h"
41 #include "chrome/browser/chromeos/wm_ipc.h" 42 #include "chrome/browser/chromeos/wm_ipc.h"
42 #include "chrome/browser/metrics/user_metrics.h" 43 #include "chrome/browser/metrics/user_metrics.h"
43 #include "chrome/browser/profiles/profile_manager.h" 44 #include "chrome/browser/profiles/profile_manager.h"
44 #include "chrome/browser/sync/profile_sync_service.h" 45 #include "chrome/browser/sync/profile_sync_service.h"
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 lock_widget_(NULL), 616 lock_widget_(NULL),
616 screen_lock_view_(NULL), 617 screen_lock_view_(NULL),
617 user_(user), 618 user_(user),
618 error_info_(NULL), 619 error_info_(NULL),
619 drawn_(false), 620 drawn_(false),
620 input_grabbed_(false), 621 input_grabbed_(false),
621 // TODO(oshima): support auto login mode (this is not implemented yet) 622 // TODO(oshima): support auto login mode (this is not implemented yet)
622 // http://crosbug.com/1881 623 // http://crosbug.com/1881
623 unlock_on_input_(user_.email().empty()), 624 unlock_on_input_(user_.email().empty()),
624 locked_(false), 625 locked_(false),
625 start_time_(base::Time::Now()) { 626 start_time_(base::Time::Now()),
627 throbber_manager_(new ThrobberManager) {
626 DCHECK(!screen_locker_); 628 DCHECK(!screen_locker_);
627 screen_locker_ = this; 629 screen_locker_ = this;
628 } 630 }
629 631
630 void ScreenLocker::Init() { 632 void ScreenLocker::Init() {
631 authenticator_ = LoginUtils::Get()->CreateAuthenticator(this); 633 authenticator_ = LoginUtils::Get()->CreateAuthenticator(this);
632 634
633 gfx::Point left_top(1, 1); 635 gfx::Point left_top(1, 1);
634 gfx::Rect init_bounds(views::Screen::GetMonitorAreaNearestPoint(left_top)); 636 gfx::Rect init_bounds(views::Screen::GetMonitorAreaNearestPoint(left_top));
635 637
636 LockWindow* lock_window = new LockWindow(); 638 LockWindow* lock_window = new LockWindow();
637 lock_window_ = lock_window; 639 lock_window_ = lock_window;
638 lock_window_->Init(NULL, init_bounds); 640 lock_window_->Init(NULL, init_bounds);
639 641
640 g_signal_connect(lock_window_->GetNativeView(), "client-event", 642 g_signal_connect(lock_window_->GetNativeView(), "client-event",
641 G_CALLBACK(OnClientEventThunk), this); 643 G_CALLBACK(OnClientEventThunk), this);
642 644
643 // GTK does not like zero width/height. 645 // GTK does not like zero width/height.
644 if (!unlock_on_input_) { 646 if (!unlock_on_input_) {
645 screen_lock_view_ = new ScreenLockView(this); 647 screen_lock_view_ = new ScreenLockView(this);
646 screen_lock_view_->Init(); 648 screen_lock_view_->Init();
647 screen_lock_view_->SetEnabled(false); 649 screen_lock_view_->SetEnabled(false);
650 StartThrobber();
Nikita (slow) 2010/12/09 15:33:22 As I understand this throbber is shown while Scree
648 } else { 651 } else {
649 input_event_observer_.reset(new InputEventObserver(this)); 652 input_event_observer_.reset(new InputEventObserver(this));
650 MessageLoopForUI::current()->AddObserver(input_event_observer_.get()); 653 MessageLoopForUI::current()->AddObserver(input_event_observer_.get());
651 } 654 }
652 655
653 // Hang on to a cast version of the grab widget so we can call its 656 // Hang on to a cast version of the grab widget so we can call its
654 // TryGrabAllInputs() method later. (Nobody else needs to use it, so moving 657 // TryGrabAllInputs() method later. (Nobody else needs to use it, so moving
655 // its declaration to the header instead of keeping it in an anonymous 658 // its declaration to the header instead of keeping it in an anonymous
656 // namespace feels a bit ugly.) 659 // namespace feels a bit ugly.)
657 GrabWidget* cast_lock_widget = new GrabWidget(this); 660 GrabWidget* cast_lock_widget = new GrabWidget(this);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 if (mouse_event_relay_.get()) { 777 if (mouse_event_relay_.get()) {
775 MessageLoopForUI::current()->RemoveObserver(mouse_event_relay_.get()); 778 MessageLoopForUI::current()->RemoveObserver(mouse_event_relay_.get());
776 mouse_event_relay_.reset(); 779 mouse_event_relay_.reset();
777 } 780 }
778 } 781 }
779 782
780 void ScreenLocker::Authenticate(const string16& password) { 783 void ScreenLocker::Authenticate(const string16& password) {
781 authentication_start_time_ = base::Time::Now(); 784 authentication_start_time_ = base::Time::Now();
782 screen_lock_view_->SetEnabled(false); 785 screen_lock_view_->SetEnabled(false);
783 screen_lock_view_->SetSignoutEnabled(false); 786 screen_lock_view_->SetSignoutEnabled(false);
787 StartThrobber();
784 788
785 // If LoginPerformer instance exists, 789 // If LoginPerformer instance exists,
786 // initial online login phase is still active. 790 // initial online login phase is still active.
787 if (LoginPerformer::default_performer()) { 791 if (LoginPerformer::default_performer()) {
788 DVLOG(1) << "Delegating authentication to LoginPerformer."; 792 DVLOG(1) << "Delegating authentication to LoginPerformer.";
789 LoginPerformer::default_performer()->Login(user_.email(), 793 LoginPerformer::default_performer()->Login(user_.email(),
790 UTF16ToUTF8(password)); 794 UTF16ToUTF8(password));
791 } else { 795 } else {
792 BrowserThread::PostTask( 796 BrowserThread::PostTask(
793 BrowserThread::UI, FROM_HERE, 797 BrowserThread::UI, FROM_HERE,
794 NewRunnableMethod(authenticator_.get(), 798 NewRunnableMethod(authenticator_.get(),
795 &Authenticator::AuthenticateToUnlock, 799 &Authenticator::AuthenticateToUnlock,
796 user_.email(), 800 user_.email(),
797 UTF16ToUTF8(password))); 801 UTF16ToUTF8(password)));
798 } 802 }
799 } 803 }
800 804
801 void ScreenLocker::ClearErrors() { 805 void ScreenLocker::ClearErrors() {
802 if (error_info_) { 806 if (error_info_) {
803 error_info_->Close(); 807 error_info_->Close();
804 error_info_ = NULL; 808 error_info_ = NULL;
805 } 809 }
806 } 810 }
807 811
808 void ScreenLocker::EnableInput() { 812 void ScreenLocker::EnableInput() {
809 if (screen_lock_view_) { 813 if (screen_lock_view_) {
810 screen_lock_view_->SetEnabled(true); 814 screen_lock_view_->SetEnabled(true);
811 screen_lock_view_->ClearAndSetFocusToPassword(); 815 screen_lock_view_->ClearAndSetFocusToPassword();
816 StopThrobber();
812 } 817 }
813 } 818 }
814 819
815 void ScreenLocker::Signout() { 820 void ScreenLocker::Signout() {
816 if (!error_info_) { 821 if (!error_info_) {
817 UserMetrics::RecordAction(UserMetricsAction("ScreenLocker_Signout")); 822 UserMetrics::RecordAction(UserMetricsAction("ScreenLocker_Signout"));
818 if (CrosLibrary::Get()->EnsureLoaded()) { 823 if (CrosLibrary::Get()->EnsureLoaded()) {
819 CrosLibrary::Get()->GetLoginLibrary()->StopSession(""); 824 CrosLibrary::Get()->GetLoginLibrary()->StopSession("");
820 } 825 }
821 826
822 // Don't hide yet the locker because the chrome screen may become visible 827 // Don't hide yet the locker because the chrome screen may become visible
823 // briefly. 828 // briefly.
824 } 829 }
825 } 830 }
826 831
827 void ScreenLocker::ShowErrorMessage(const std::wstring& message, 832 void ScreenLocker::ShowErrorMessage(const std::wstring& message,
828 bool sign_out_only) { 833 bool sign_out_only) {
829 if (sign_out_only) { 834 if (sign_out_only) {
830 screen_lock_view_->SetEnabled(false); 835 screen_lock_view_->SetEnabled(false);
836 StartThrobber();
Nikita (slow) 2010/12/09 15:33:22 Why show throbber along with error bubble?
oshima 2010/12/09 21:52:10 may be this is a bug from http://codereview.chromi
altimofeev 2010/12/10 16:37:40 Oshima-san is right. I have automatically copied t
831 } else { 837 } else {
832 EnableInput(); 838 EnableInput();
833 } 839 }
834 screen_lock_view_->SetSignoutEnabled(sign_out_only); 840 screen_lock_view_->SetSignoutEnabled(sign_out_only);
835 // Make sure that active Sign Out button is not hidden behind the bubble. 841 // Make sure that active Sign Out button is not hidden behind the bubble.
836 ShowErrorBubble(message, sign_out_only ? 842 ShowErrorBubble(message, sign_out_only ?
837 BubbleBorder::BOTTOM_RIGHT : BubbleBorder::BOTTOM_LEFT); 843 BubbleBorder::BOTTOM_RIGHT : BubbleBorder::BOTTOM_LEFT);
838 } 844 }
839 845
840 void ScreenLocker::OnGrabInputs() { 846 void ScreenLocker::OnGrabInputs() {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 screen_locker_ = NULL; 935 screen_locker_ = NULL;
930 bool state = false; 936 bool state = false;
931 NotificationService::current()->Notify( 937 NotificationService::current()->Notify(
932 NotificationType::SCREEN_LOCK_STATE_CHANGED, 938 NotificationType::SCREEN_LOCK_STATE_CHANGED,
933 Source<ScreenLocker>(this), 939 Source<ScreenLocker>(this),
934 Details<bool>(&state)); 940 Details<bool>(&state));
935 if (CrosLibrary::Get()->EnsureLoaded()) 941 if (CrosLibrary::Get()->EnsureLoaded())
936 CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenUnlockCompleted(); 942 CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenUnlockCompleted();
937 } 943 }
938 944
945 void ScreenLocker::StartThrobber() {
946 views::Widget* widget_under_throbber =
947 screen_lock_view_->GetWidgetForThrobber();
948 if (widget_under_throbber) {
949 throbber_manager_->StartShow(widget_under_throbber,
950 CreateDefaultSmoothedThrobber(),
951 login::kThrobberRightShift);
952 }
953 }
954
955 void ScreenLocker::StopThrobber() {
956 throbber_manager_->Stop();
957 }
958
939 void ScreenLocker::SetAuthenticator(Authenticator* authenticator) { 959 void ScreenLocker::SetAuthenticator(Authenticator* authenticator) {
940 authenticator_ = authenticator; 960 authenticator_ = authenticator;
941 } 961 }
942 962
943 void ScreenLocker::ScreenLockReady() { 963 void ScreenLocker::ScreenLockReady() {
944 VLOG(1) << "ScreenLockReady: sending completed signal to power manager."; 964 VLOG(1) << "ScreenLockReady: sending completed signal to power manager.";
945 locked_ = true; 965 locked_ = true;
946 base::TimeDelta delta = base::Time::Now() - start_time_; 966 base::TimeDelta delta = base::Time::Now() - start_time_;
947 VLOG(1) << "Screen lock time: " << delta.InSecondsF(); 967 VLOG(1) << "Screen lock time: " << delta.InSecondsF();
948 UMA_HISTOGRAM_TIMES("ScreenLocker.ScreenLockTime", delta); 968 UMA_HISTOGRAM_TIMES("ScreenLocker.ScreenLockTime", delta);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 1057
1038 bool ScreenLocker::AcceleratorPressed(const views::Accelerator& accelerator) { 1058 bool ScreenLocker::AcceleratorPressed(const views::Accelerator& accelerator) {
1039 if (!background_view_->IsScreenSaverVisible()) { 1059 if (!background_view_->IsScreenSaverVisible()) {
1040 StartScreenSaver(); 1060 StartScreenSaver();
1041 return true; 1061 return true;
1042 } 1062 }
1043 return false; 1063 return false;
1044 } 1064 }
1045 1065
1046 } // namespace chromeos 1066 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698