| 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 <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 23 matching lines...) Expand all  Loading... | 
|    34 #include "chrome/browser/chromeos/login/shutdown_button.h" |    34 #include "chrome/browser/chromeos/login/shutdown_button.h" | 
|    35 #include "chrome/browser/chromeos/system_key_event_listener.h" |    35 #include "chrome/browser/chromeos/system_key_event_listener.h" | 
|    36 #include "chrome/browser/chromeos/view_ids.h" |    36 #include "chrome/browser/chromeos/view_ids.h" | 
|    37 #include "chrome/browser/chromeos/wm_ipc.h" |    37 #include "chrome/browser/chromeos/wm_ipc.h" | 
|    38 #include "chrome/browser/profiles/profile.h" |    38 #include "chrome/browser/profiles/profile.h" | 
|    39 #include "chrome/browser/profiles/profile_manager.h" |    39 #include "chrome/browser/profiles/profile_manager.h" | 
|    40 #include "chrome/browser/sync/profile_sync_service.h" |    40 #include "chrome/browser/sync/profile_sync_service.h" | 
|    41 #include "chrome/browser/ui/browser.h" |    41 #include "chrome/browser/ui/browser.h" | 
|    42 #include "chrome/browser/ui/browser_list.h" |    42 #include "chrome/browser/ui/browser_list.h" | 
|    43 #include "chrome/browser/ui/browser_window.h" |    43 #include "chrome/browser/ui/browser_window.h" | 
 |    44 #include "chrome/common/chrome_notification_types.h" | 
|    44 #include "chrome/common/chrome_switches.h" |    45 #include "chrome/common/chrome_switches.h" | 
|    45 #include "content/browser/browser_thread.h" |    46 #include "content/browser/browser_thread.h" | 
|    46 #include "content/browser/user_metrics.h" |    47 #include "content/browser/user_metrics.h" | 
|    47 #include "content/common/notification_service.h" |    48 #include "content/common/notification_service.h" | 
|    48 #include "googleurl/src/gurl.h" |    49 #include "googleurl/src/gurl.h" | 
|    49 #include "grit/generated_resources.h" |    50 #include "grit/generated_resources.h" | 
|    50 #include "grit/theme_resources.h" |    51 #include "grit/theme_resources.h" | 
|    51 #include "third_party/cros/chromeos_wm_ipc_enums.h" |    52 #include "third_party/cros/chromeos_wm_ipc_enums.h" | 
|    52 #include "ui/base/l10n/l10n_util.h" |    53 #include "ui/base/l10n/l10n_util.h" | 
|    53 #include "ui/base/resource/resource_bundle.h" |    54 #include "ui/base/resource/resource_bundle.h" | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|    67 const int kMaxGrabFailures = kMaxGrabFailureSec * 1000 / kRetryGrabIntervalMs; |    68 const int kMaxGrabFailures = kMaxGrabFailureSec * 1000 / kRetryGrabIntervalMs; | 
|    68  |    69  | 
|    69 // A idle time to show the screen saver in seconds. |    70 // A idle time to show the screen saver in seconds. | 
|    70 const int kScreenSaverIdleTimeout = 15; |    71 const int kScreenSaverIdleTimeout = 15; | 
|    71  |    72  | 
|    72 // Observer to start ScreenLocker when the screen lock |    73 // Observer to start ScreenLocker when the screen lock | 
|    73 class ScreenLockObserver : public chromeos::ScreenLockLibrary::Observer, |    74 class ScreenLockObserver : public chromeos::ScreenLockLibrary::Observer, | 
|    74                            public NotificationObserver { |    75                            public NotificationObserver { | 
|    75  public: |    76  public: | 
|    76   ScreenLockObserver() { |    77   ScreenLockObserver() { | 
|    77     registrar_.Add(this, NotificationType::LOGIN_USER_CHANGED, |    78     registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 
|    78                    NotificationService::AllSources()); |    79                    NotificationService::AllSources()); | 
|    79   } |    80   } | 
|    80  |    81  | 
|    81   // NotificationObserver overrides: |    82   // NotificationObserver overrides: | 
|    82   virtual void Observe(NotificationType type, |    83   virtual void Observe(int type, | 
|    83                        const NotificationSource& source, |    84                        const NotificationSource& source, | 
|    84                        const NotificationDetails& details) OVERRIDE { |    85                        const NotificationDetails& details) OVERRIDE { | 
|    85     if (type == NotificationType::LOGIN_USER_CHANGED) { |    86     if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) { | 
|    86       // Register Screen Lock after login screen to make sure |    87       // Register Screen Lock after login screen to make sure | 
|    87       // we don't show the screen lock on top of the login screen by accident. |    88       // we don't show the screen lock on top of the login screen by accident. | 
|    88       if (chromeos::CrosLibrary::Get()->EnsureLoaded()) |    89       if (chromeos::CrosLibrary::Get()->EnsureLoaded()) | 
|    89         chromeos::CrosLibrary::Get()->GetScreenLockLibrary()->AddObserver(this); |    90         chromeos::CrosLibrary::Get()->GetScreenLockLibrary()->AddObserver(this); | 
|    90     } |    91     } | 
|    91   } |    92   } | 
|    92  |    93  | 
|    93   virtual void LockScreen(chromeos::ScreenLockLibrary* obj) OVERRIDE { |    94   virtual void LockScreen(chromeos::ScreenLockLibrary* obj) OVERRIDE { | 
|    94     VLOG(1) << "In: ScreenLockObserver::LockScreen"; |    95     VLOG(1) << "In: ScreenLockObserver::LockScreen"; | 
|    95     SetupInputMethodsForScreenLocker(); |    96     SetupInputMethodsForScreenLocker(); | 
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1105   gdk_keyboard_ungrab(GDK_CURRENT_TIME); |  1106   gdk_keyboard_ungrab(GDK_CURRENT_TIME); | 
|  1106   gdk_pointer_ungrab(GDK_CURRENT_TIME); |  1107   gdk_pointer_ungrab(GDK_CURRENT_TIME); | 
|  1107  |  1108  | 
|  1108   DCHECK(lock_window_); |  1109   DCHECK(lock_window_); | 
|  1109   VLOG(1) << "~ScreenLocker(): Closing ScreenLocker window."; |  1110   VLOG(1) << "~ScreenLocker(): Closing ScreenLocker window."; | 
|  1110   lock_window_->Close(); |  1111   lock_window_->Close(); | 
|  1111   // lock_widget_ will be deleted by gtk's destroy signal. |  1112   // lock_widget_ will be deleted by gtk's destroy signal. | 
|  1112   screen_locker_ = NULL; |  1113   screen_locker_ = NULL; | 
|  1113   bool state = false; |  1114   bool state = false; | 
|  1114   NotificationService::current()->Notify( |  1115   NotificationService::current()->Notify( | 
|  1115       NotificationType::SCREEN_LOCK_STATE_CHANGED, |  1116       chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 
|  1116       Source<ScreenLocker>(this), |  1117       Source<ScreenLocker>(this), | 
|  1117       Details<bool>(&state)); |  1118       Details<bool>(&state)); | 
|  1118   if (CrosLibrary::Get()->EnsureLoaded()) |  1119   if (CrosLibrary::Get()->EnsureLoaded()) | 
|  1119     CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenUnlockCompleted(); |  1120     CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenUnlockCompleted(); | 
|  1120 } |  1121 } | 
|  1121  |  1122  | 
|  1122 void ScreenLocker::SetAuthenticator(Authenticator* authenticator) { |  1123 void ScreenLocker::SetAuthenticator(Authenticator* authenticator) { | 
|  1123   authenticator_ = authenticator; |  1124   authenticator_ = authenticator; | 
|  1124 } |  1125 } | 
|  1125  |  1126  | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
|  1136     locker_input_event_observer_.reset(new LockerInputEventObserver(this)); |  1137     locker_input_event_observer_.reset(new LockerInputEventObserver(this)); | 
|  1137     MessageLoopForUI::current()->AddObserver( |  1138     MessageLoopForUI::current()->AddObserver( | 
|  1138         locker_input_event_observer_.get()); |  1139         locker_input_event_observer_.get()); | 
|  1139   } else { |  1140   } else { | 
|  1140     // Don't enable the password field until we grab all inputs. |  1141     // Don't enable the password field until we grab all inputs. | 
|  1141     EnableInput(); |  1142     EnableInput(); | 
|  1142   } |  1143   } | 
|  1143  |  1144  | 
|  1144   bool state = true; |  1145   bool state = true; | 
|  1145   NotificationService::current()->Notify( |  1146   NotificationService::current()->Notify( | 
|  1146       NotificationType::SCREEN_LOCK_STATE_CHANGED, |  1147       chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 
|  1147       Source<ScreenLocker>(this), |  1148       Source<ScreenLocker>(this), | 
|  1148       Details<bool>(&state)); |  1149       Details<bool>(&state)); | 
|  1149   if (CrosLibrary::Get()->EnsureLoaded()) |  1150   if (CrosLibrary::Get()->EnsureLoaded()) | 
|  1150     CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenLockCompleted(); |  1151     CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenLockCompleted(); | 
|  1151 } |  1152 } | 
|  1152  |  1153  | 
|  1153 void ScreenLocker::OnClientEvent(GtkWidget* widge, GdkEventClient* event) { |  1154 void ScreenLocker::OnClientEvent(GtkWidget* widge, GdkEventClient* event) { | 
|  1154   WmIpc::Message msg; |  1155   WmIpc::Message msg; | 
|  1155   WmIpc::instance()->DecodeMessage(*event, &msg); |  1156   WmIpc::instance()->DecodeMessage(*event, &msg); | 
|  1156   if (msg.type() == WM_IPC_MESSAGE_CHROME_NOTIFY_SCREEN_REDRAWN_FOR_LOCK) { |  1157   if (msg.type() == WM_IPC_MESSAGE_CHROME_NOTIFY_SCREEN_REDRAWN_FOR_LOCK) { | 
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1222  |  1223  | 
|  1223 bool ScreenLocker::AcceleratorPressed(const views::Accelerator& accelerator) { |  1224 bool ScreenLocker::AcceleratorPressed(const views::Accelerator& accelerator) { | 
|  1224   if (!background_view_->IsScreenSaverVisible()) { |  1225   if (!background_view_->IsScreenSaverVisible()) { | 
|  1225     StartScreenSaver(); |  1226     StartScreenSaver(); | 
|  1226     return true; |  1227     return true; | 
|  1227   } |  1228   } | 
|  1228   return false; |  1229   return false; | 
|  1229 } |  1230 } | 
|  1230  |  1231  | 
|  1231 }  // namespace chromeos |  1232 }  // namespace chromeos | 
| OLD | NEW |