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_views.h" | 5 #include "chrome/browser/chromeos/login/screen_locker_views.h" |
6 | 6 |
7 #include <X11/extensions/XTest.h> | 7 #include <X11/extensions/XTest.h> |
8 #include <X11/keysym.h> | 8 #include <X11/keysym.h> |
9 #include <gdk/gdkkeysyms.h> | 9 #include <gdk/gdkkeysyms.h> |
10 #include <gdk/gdkx.h> | 10 #include <gdk/gdkx.h> |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/chromeos/status/status_area_view_chromeos.h" | 24 #include "chrome/browser/chromeos/status/status_area_view_chromeos.h" |
25 #include "chrome/browser/chromeos/view_ids.h" | 25 #include "chrome/browser/chromeos/view_ids.h" |
26 #include "chrome/browser/prefs/pref_service.h" | 26 #include "chrome/browser/prefs/pref_service.h" |
27 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
28 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
29 #include "content/browser/user_metrics.h" | 29 #include "content/browser/user_metrics.h" |
30 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" |
31 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
32 #include "ui/base/x/x11_util.h" | 32 #include "ui/base/x/x11_util.h" |
33 #include "ui/gfx/screen.h" | 33 #include "ui/gfx/screen.h" |
| 34 #include "views/controls/textfield/textfield.h" |
34 | 35 |
35 #if defined(TOOLKIT_USES_GTK) | 36 #if defined(TOOLKIT_USES_GTK) |
36 #include "chrome/browser/chromeos/legacy_window_manager/wm_ipc.h" | 37 #include "chrome/browser/chromeos/legacy_window_manager/wm_ipc.h" |
| 38 #include "ui/views/widget/native_widget_gtk.h" |
37 #endif | 39 #endif |
38 | 40 |
39 namespace { | 41 namespace { |
40 | 42 |
41 // The active ScreenLockerDelegate. | 43 // The active ScreenLockerDelegate. |
42 chromeos::ScreenLockerViews* screen_locker_view_ = NULL; | 44 chromeos::ScreenLockerViews* screen_locker_view_ = NULL; |
43 | 45 |
44 // The maximum duration for which locker should try to grab the keyboard and | 46 // The maximum duration for which locker should try to grab the keyboard and |
45 // mouse and its interval for regrabbing on failure. | 47 // mouse and its interval for regrabbing on failure. |
46 const int kMaxGrabFailureSec = 30; | 48 const int kMaxGrabFailureSec = 30; |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 screen_lock_view_->SetVisible(false); | 802 screen_lock_view_->SetVisible(false); |
801 grab_container_->SetScreenLockView(captcha_view_); | 803 grab_container_->SetScreenLockView(captcha_view_); |
802 background_container_->SetScreenLockView(captcha_view_); | 804 background_container_->SetScreenLockView(captcha_view_); |
803 captcha_view_->SetVisible(true); | 805 captcha_view_->SetVisible(true); |
804 // Take ScreenLockView ownership now that it's removed from grab_container_. | 806 // Take ScreenLockView ownership now that it's removed from grab_container_. |
805 secondary_view_.reset(screen_lock_view_); | 807 secondary_view_.reset(screen_lock_view_); |
806 } | 808 } |
807 | 809 |
808 void ScreenLockerViews::ClearErrors() { | 810 void ScreenLockerViews::ClearErrors() { |
809 if (error_info_) { | 811 if (error_info_) { |
810 error_info_->Close(); | 812 error_info_->GetWidget()->Close(); |
811 error_info_ = NULL; | 813 error_info_ = NULL; |
812 } | 814 } |
813 } | 815 } |
814 | 816 |
815 void ScreenLockerViews::BubbleClosing(Bubble* bubble, bool closed_by_escape) { | 817 void ScreenLockerViews::OnWidgetClosing(views::Widget* widget) { |
| 818 if (!error_info_ || error_info_->GetWidget() != widget) |
| 819 return; |
| 820 |
816 error_info_ = NULL; | 821 error_info_ = NULL; |
817 SetSignoutEnabled(true); | 822 SetSignoutEnabled(true); |
818 if (mouse_event_relay_.get()) { | 823 if (mouse_event_relay_.get()) { |
819 MessageLoopForUI::current()->RemoveObserver(mouse_event_relay_.get()); | 824 MessageLoopForUI::current()->RemoveObserver(mouse_event_relay_.get()); |
820 mouse_event_relay_.reset(); | 825 mouse_event_relay_.reset(); |
821 } | 826 } |
822 } | 827 } |
823 | 828 |
824 bool ScreenLockerViews::CloseOnEscape() { | |
825 return true; | |
826 } | |
827 | |
828 bool ScreenLockerViews::FadeInOnShow() { | |
829 return false; | |
830 } | |
831 | |
832 void ScreenLockerViews::OnLinkActivated(size_t index) { | |
833 } | |
834 | |
835 void ScreenLockerViews::OnCaptchaEntered(const std::string& captcha) { | 829 void ScreenLockerViews::OnCaptchaEntered(const std::string& captcha) { |
836 // Captcha dialog is only shown when LoginPerformer instance exists, | 830 // Captcha dialog is only shown when LoginPerformer instance exists, |
837 // i.e. blocking UI after password change is in place. | 831 // i.e. blocking UI after password change is in place. |
838 DCHECK(LoginPerformer::default_performer()); | 832 DCHECK(LoginPerformer::default_performer()); |
839 LoginPerformer::default_performer()->set_captcha(captcha); | 833 LoginPerformer::default_performer()->set_captcha(captcha); |
840 | 834 |
841 // ScreenLockView ownership is passed to grab_container_. | 835 // ScreenLockView ownership is passed to grab_container_. |
842 // Need to save return value here so that compile | 836 // Need to save return value here so that compile |
843 // doesn't fail with "unused result" warning. | 837 // doesn't fail with "unused result" warning. |
844 ignore_result(secondary_view_.release()); | 838 ignore_result(secondary_view_.release()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 void ScreenLockerViews::OnWindowManagerReady() { | 871 void ScreenLockerViews::OnWindowManagerReady() { |
878 DVLOG(1) << "OnClientEvent: drawn for lock"; | 872 DVLOG(1) << "OnClientEvent: drawn for lock"; |
879 drawn_ = true; | 873 drawn_ = true; |
880 if (input_grabbed_) | 874 if (input_grabbed_) |
881 ScreenLockReady(); | 875 ScreenLockReady(); |
882 } | 876 } |
883 | 877 |
884 void ScreenLockerViews::ShowErrorBubble( | 878 void ScreenLockerViews::ShowErrorBubble( |
885 const string16& message, | 879 const string16& message, |
886 views::BubbleBorder::ArrowLocation arrow_location) { | 880 views::BubbleBorder::ArrowLocation arrow_location) { |
887 if (error_info_) | 881 ClearErrors(); |
888 error_info_->Close(); | |
889 | 882 |
890 gfx::Rect rect = screen_lock_view_->GetPasswordBoundsRelativeTo( | 883 // TODO(nkostylev): Add help link. |
891 lock_widget_->GetRootView()); | 884 std::vector<string16> help_links; |
892 gfx::Rect lock_widget_bounds = lock_widget_->GetClientAreaScreenBounds(); | 885 error_info_ = new MessageBubble( |
893 rect.Offset(lock_widget_bounds.x(), lock_widget_bounds.y()); | 886 screen_lock_view_->password_field(), |
894 error_info_ = MessageBubble::ShowNoGrab( | |
895 lock_window_, | |
896 rect, | |
897 arrow_location, | 887 arrow_location, |
898 ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING), | 888 ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING), |
899 UTF16ToWide(message), | 889 message, |
900 UTF16ToWide(string16()), // TODO(nkostylev): Add help link. | 890 help_links); |
901 this); | 891 MessageBubble::ShowBubble(error_info_); |
| 892 error_info_->GetWidget()->AddObserver(this); |
902 | 893 |
903 #if !defined(TOUCH_UI) | 894 #if !defined(TOUCH_UI) |
904 if (mouse_event_relay_.get()) | 895 if (mouse_event_relay_.get()) |
905 MessageLoopForUI::current()->RemoveObserver(mouse_event_relay_.get()); | 896 MessageLoopForUI::current()->RemoveObserver(mouse_event_relay_.get()); |
| 897 // TODO(oshima|msw): Investigate MouseEventRelay problems: crosbug.com/23324. |
906 mouse_event_relay_.reset( | 898 mouse_event_relay_.reset( |
907 new MouseEventRelay(lock_widget_->GetNativeView()->window, | 899 new MouseEventRelay(lock_widget_->GetNativeView()->window, |
908 error_info_->GetNativeView()->window)); | 900 error_info_->GetWidget()->GetNativeView()->window)); |
909 MessageLoopForUI::current()->AddObserver(mouse_event_relay_.get()); | 901 MessageLoopForUI::current()->AddObserver(mouse_event_relay_.get()); |
910 #endif | 902 #endif |
911 } | 903 } |
912 | 904 |
913 bool ScreenLockerViews::AcceleratorPressed( | 905 bool ScreenLockerViews::AcceleratorPressed( |
914 const ui::Accelerator& accelerator) { | 906 const ui::Accelerator& accelerator) { |
915 if (!background_view_->IsScreenSaverVisible()) { | 907 if (!background_view_->IsScreenSaverVisible()) { |
916 screen_locker_view_->StartScreenSaver(); | 908 screen_locker_view_->StartScreenSaver(); |
917 return true; | 909 return true; |
918 } | 910 } |
919 return false; | 911 return false; |
920 } | 912 } |
921 | 913 |
922 void ScreenLockerViews::OnClientEvent(GtkWidget* widge, GdkEventClient* event) { | 914 void ScreenLockerViews::OnClientEvent(GtkWidget* widge, GdkEventClient* event) { |
923 #if defined(TOOLKIT_USES_GTK) | 915 #if defined(TOOLKIT_USES_GTK) |
924 WmIpc::Message msg; | 916 WmIpc::Message msg; |
925 WmIpc::instance()->DecodeMessage(*event, &msg); | 917 WmIpc::instance()->DecodeMessage(*event, &msg); |
926 if (msg.type() == WM_IPC_MESSAGE_CHROME_NOTIFY_SCREEN_REDRAWN_FOR_LOCK) { | 918 if (msg.type() == WM_IPC_MESSAGE_CHROME_NOTIFY_SCREEN_REDRAWN_FOR_LOCK) { |
927 OnWindowManagerReady(); | 919 OnWindowManagerReady(); |
928 } | 920 } |
929 #endif | 921 #endif |
930 } | 922 } |
931 | 923 |
932 } // namespace chromeos | 924 } // namespace chromeos |
OLD | NEW |