| OLD | NEW |
| 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> |
| 11 #include <X11/keysym.h> | 11 #include <X11/keysym.h> |
| 12 // Evil hack to undo X11 evil #define. See crosbug.com/ | 12 // Evil hack to undo X11 evil #define. See crosbug.com/ |
| 13 #undef Status | 13 #undef Status |
| 14 | 14 |
| 15 #include "app/l10n_util.h" | 15 #include "app/l10n_util.h" |
| 16 #include "app/resource_bundle.h" | 16 #include "app/resource_bundle.h" |
| 17 #include "app/x11_util.h" | 17 #include "app/x11_util.h" |
| 18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
| 19 #include "base/lazy_instance.h" |
| 19 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
| 20 #include "base/message_loop.h" | 21 #include "base/message_loop.h" |
| 21 #include "base/singleton.h" | |
| 22 #include "base/string_util.h" | 22 #include "base/string_util.h" |
| 23 #include "base/timer.h" | 23 #include "base/timer.h" |
| 24 #include "base/utf_string_conversions.h" | 24 #include "base/utf_string_conversions.h" |
| 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" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 } | 187 } |
| 188 | 188 |
| 189 NotificationRegistrar registrar_; | 189 NotificationRegistrar registrar_; |
| 190 std::string saved_previous_input_method_id_; | 190 std::string saved_previous_input_method_id_; |
| 191 std::string saved_current_input_method_id_; | 191 std::string saved_current_input_method_id_; |
| 192 std::vector<std::string> saved_active_input_method_list_; | 192 std::vector<std::string> saved_active_input_method_list_; |
| 193 | 193 |
| 194 DISALLOW_COPY_AND_ASSIGN(ScreenLockObserver); | 194 DISALLOW_COPY_AND_ASSIGN(ScreenLockObserver); |
| 195 }; | 195 }; |
| 196 | 196 |
| 197 static base::LazyInstance<ScreenLockObserver> g_screen_lock_observer( |
| 198 base::LINKER_INITIALIZED); |
| 199 |
| 197 // A ScreenLock window that covers entire screen to keep the keyboard | 200 // A ScreenLock window that covers entire screen to keep the keyboard |
| 198 // focus/events inside the grab widget. | 201 // focus/events inside the grab widget. |
| 199 class LockWindow : public views::WidgetGtk { | 202 class LockWindow : public views::WidgetGtk { |
| 200 public: | 203 public: |
| 201 LockWindow() | 204 LockWindow() |
| 202 : views::WidgetGtk(views::WidgetGtk::TYPE_WINDOW), | 205 : views::WidgetGtk(views::WidgetGtk::TYPE_WINDOW), |
| 203 toplevel_focus_widget_(NULL) { | 206 toplevel_focus_widget_(NULL) { |
| 204 EnableDoubleBuffer(true); | 207 EnableDoubleBuffer(true); |
| 205 } | 208 } |
| 206 | 209 |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 // This can happen when a user requested unlock, but PowerManager | 897 // This can happen when a user requested unlock, but PowerManager |
| 895 // rejected because the computer is closed, then PowerManager unlocked | 898 // rejected because the computer is closed, then PowerManager unlocked |
| 896 // because it's open again and the above failure message arrives. | 899 // because it's open again and the above failure message arrives. |
| 897 // This'd be extremely rare, but may still happen. | 900 // This'd be extremely rare, but may still happen. |
| 898 VLOG(1) << "UnlockScreenFailed: screen is already unlocked."; | 901 VLOG(1) << "UnlockScreenFailed: screen is already unlocked."; |
| 899 } | 902 } |
| 900 } | 903 } |
| 901 | 904 |
| 902 // static | 905 // static |
| 903 void ScreenLocker::InitClass() { | 906 void ScreenLocker::InitClass() { |
| 904 Singleton<ScreenLockObserver>::get(); | 907 g_screen_lock_observer.Get(); |
| 905 } | 908 } |
| 906 | 909 |
| 907 //////////////////////////////////////////////////////////////////////////////// | 910 //////////////////////////////////////////////////////////////////////////////// |
| 908 // ScreenLocker, private: | 911 // ScreenLocker, private: |
| 909 | 912 |
| 910 ScreenLocker::~ScreenLocker() { | 913 ScreenLocker::~ScreenLocker() { |
| 911 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); | 914 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); |
| 912 ClearErrors(); | 915 ClearErrors(); |
| 913 if (input_event_observer_.get()) | 916 if (input_event_observer_.get()) |
| 914 MessageLoopForUI::current()->RemoveObserver(input_event_observer_.get()); | 917 MessageLoopForUI::current()->RemoveObserver(input_event_observer_.get()); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 | 1040 |
| 1038 bool ScreenLocker::AcceleratorPressed(const views::Accelerator& accelerator) { | 1041 bool ScreenLocker::AcceleratorPressed(const views::Accelerator& accelerator) { |
| 1039 if (!background_view_->IsScreenSaverVisible()) { | 1042 if (!background_view_->IsScreenSaverVisible()) { |
| 1040 StartScreenSaver(); | 1043 StartScreenSaver(); |
| 1041 return true; | 1044 return true; |
| 1042 } | 1045 } |
| 1043 return false; | 1046 return false; |
| 1044 } | 1047 } |
| 1045 | 1048 |
| 1046 } // namespace chromeos | 1049 } // namespace chromeos |
| OLD | NEW |