| 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 <string> |    7 #include <string> | 
|    8 #include <vector> |    8 #include <vector> | 
|    9  |    9  | 
|   10 #include "app/l10n_util.h" |   10 #include "app/l10n_util.h" | 
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  265       : views::WidgetGtk(views::WidgetGtk::TYPE_CHILD), |  265       : views::WidgetGtk(views::WidgetGtk::TYPE_CHILD), | 
|  266         screen_locker_(screen_locker), |  266         screen_locker_(screen_locker), | 
|  267         ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), |  267         ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), | 
|  268         grab_failure_count_(0), |  268         grab_failure_count_(0), | 
|  269         kbd_grab_status_(GDK_GRAB_INVALID_TIME), |  269         kbd_grab_status_(GDK_GRAB_INVALID_TIME), | 
|  270         mouse_grab_status_(GDK_GRAB_INVALID_TIME) { |  270         mouse_grab_status_(GDK_GRAB_INVALID_TIME) { | 
|  271   } |  271   } | 
|  272  |  272  | 
|  273   virtual void Show() { |  273   virtual void Show() { | 
|  274     views::WidgetGtk::Show(); |  274     views::WidgetGtk::Show(); | 
|  275     // Now steal all inputs. |  | 
|  276     TryGrabAllInputs(); |  | 
|  277   } |  275   } | 
|  278  |  276  | 
|  279   void ClearGrab() { |  277   void ClearGrab() { | 
|  280     GtkWidget* current_grab_window; |  278     GtkWidget* current_grab_window; | 
|  281     // Grab gtk input first so that the menu holding grab will close itself. |  279     // Grab gtk input first so that the menu holding grab will close itself. | 
|  282     gtk_grab_add(window_contents()); |  280     gtk_grab_add(window_contents()); | 
|  283  |  281  | 
|  284     // Make sure there is no grab widget so that gtk simply propagates |  282     // Make sure there is no grab widget so that gtk simply propagates | 
|  285     // an event.  This is necessary to allow message bubble and password |  283     // an event.  This is necessary to allow message bubble and password | 
|  286     // field, button to process events simultaneously. GTK |  284     // field, button to process events simultaneously. GTK | 
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  561 void ScreenLocker::Init() { |  559 void ScreenLocker::Init() { | 
|  562   authenticator_ = LoginUtils::Get()->CreateAuthenticator(this); |  560   authenticator_ = LoginUtils::Get()->CreateAuthenticator(this); | 
|  563  |  561  | 
|  564   gfx::Point left_top(1, 1); |  562   gfx::Point left_top(1, 1); | 
|  565   gfx::Rect init_bounds(views::Screen::GetMonitorAreaNearestPoint(left_top)); |  563   gfx::Rect init_bounds(views::Screen::GetMonitorAreaNearestPoint(left_top)); | 
|  566  |  564  | 
|  567   LockWindow* lock_window = new LockWindow(); |  565   LockWindow* lock_window = new LockWindow(); | 
|  568   lock_window_ = lock_window; |  566   lock_window_ = lock_window; | 
|  569   lock_window_->Init(NULL, init_bounds); |  567   lock_window_->Init(NULL, init_bounds); | 
|  570  |  568  | 
|  571   // Add the window to its own group so that its grab won't be stolen if |  | 
|  572   // gtk_grab_add() gets called on behalf on a non-screen-locker widget (e.g. |  | 
|  573   // a modal dialog) -- see http://crosbug.com/8999. |  | 
|  574   GtkWindowGroup* window_group = gtk_window_group_new(); |  | 
|  575   gtk_window_group_add_window(window_group, |  | 
|  576                               GTK_WINDOW(lock_window_->GetNativeView())); |  | 
|  577   g_object_unref(window_group); |  | 
|  578  |  | 
|  579   g_signal_connect(lock_window_->GetNativeView(), "client-event", |  569   g_signal_connect(lock_window_->GetNativeView(), "client-event", | 
|  580                    G_CALLBACK(OnClientEventThunk), this); |  570                    G_CALLBACK(OnClientEventThunk), this); | 
|  581  |  571  | 
|  582   // GTK does not like zero width/height. |  572   // GTK does not like zero width/height. | 
|  583   if (!unlock_on_input_) { |  573   if (!unlock_on_input_) { | 
|  584     screen_lock_view_ = new ScreenLockView(this); |  574     screen_lock_view_ = new ScreenLockView(this); | 
|  585     screen_lock_view_->Init(); |  575     screen_lock_view_->Init(); | 
|  586     screen_lock_view_->SetEnabled(false); |  576     screen_lock_view_->SetEnabled(false); | 
|  587   } else { |  577   } else { | 
|  588     input_event_observer_.reset(new InputEventObserver(this)); |  578     input_event_observer_.reset(new InputEventObserver(this)); | 
|  589     MessageLoopForUI::current()->AddObserver(input_event_observer_.get()); |  579     MessageLoopForUI::current()->AddObserver(input_event_observer_.get()); | 
|  590   } |  580   } | 
|  591  |  581  | 
|  592   lock_widget_ = new GrabWidget(this); |  582   // Hang on to a cast version of the grab widget so we can call its | 
 |  583   // TryGrabAllInputs() method later.  (Nobody else needs to use it, so moving | 
 |  584   // its declaration to the header instead of keeping it in an anonymous | 
 |  585   // namespace feels a bit ugly.) | 
 |  586   GrabWidget* cast_lock_widget = new GrabWidget(this); | 
 |  587   lock_widget_ = cast_lock_widget; | 
|  593   lock_widget_->MakeTransparent(); |  588   lock_widget_->MakeTransparent(); | 
|  594   lock_widget_->InitWithWidget(lock_window_, gfx::Rect()); |  589   lock_widget_->InitWithWidget(lock_window_, gfx::Rect()); | 
|  595   if (screen_lock_view_) { |  590   if (screen_lock_view_) { | 
|  596     lock_widget_->SetContentsView( |  591     lock_widget_->SetContentsView( | 
|  597         new GrabWidgetRootView(screen_lock_view_)); |  592         new GrabWidgetRootView(screen_lock_view_)); | 
|  598   } |  593   } | 
 |  594   lock_widget_->Show(); | 
|  599  |  595  | 
|  600   // Configuring the background url. |  596   // Configuring the background url. | 
|  601   std::string url_string = |  597   std::string url_string = | 
|  602       CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |  598       CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 
|  603           switches::kScreenSaverUrl); |  599           switches::kScreenSaverUrl); | 
|  604   background_view_ = new ScreenLockerBackgroundView(lock_widget_, |  600   background_view_ = new ScreenLockerBackgroundView(lock_widget_, | 
|  605                                                     screen_lock_view_); |  601                                                     screen_lock_view_); | 
|  606   background_view_->Init(GURL(url_string)); |  602   background_view_->Init(GURL(url_string)); | 
|  607   if (background_view_->ScreenSaverEnabled()) |  603   if (background_view_->ScreenSaverEnabled()) | 
|  608     StartScreenSaver(); |  604     StartScreenSaver(); | 
|  609  |  605  | 
|  610   DCHECK(GTK_WIDGET_REALIZED(lock_window_->GetNativeView())); |  606   DCHECK(GTK_WIDGET_REALIZED(lock_window_->GetNativeView())); | 
|  611   WmIpc::instance()->SetWindowType( |  607   WmIpc::instance()->SetWindowType( | 
|  612       lock_window_->GetNativeView(), |  608       lock_window_->GetNativeView(), | 
|  613       WM_IPC_WINDOW_CHROME_SCREEN_LOCKER, |  609       WM_IPC_WINDOW_CHROME_SCREEN_LOCKER, | 
|  614       NULL); |  610       NULL); | 
|  615  |  611  | 
|  616   lock_window_->SetContentsView(background_view_); |  612   lock_window_->SetContentsView(background_view_); | 
|  617   lock_window_->Show(); |  613   lock_window_->Show(); | 
|  618  |  614  | 
|  619   // Show lock_widget after the lock_window is shown so that |  615   cast_lock_widget->TryGrabAllInputs(); | 
|  620   // we can grab inputs immediately. |  616  | 
|  621   lock_widget_->Show(); |  617   // Add the window to its own group so that its grab won't be stolen if | 
 |  618   // gtk_grab_add() gets called on behalf on a non-screen-locker widget (e.g. | 
 |  619   // a modal dialog) -- see http://crosbug.com/8999.  We intentionally do this | 
 |  620   // after calling TryGrabAllInputs(), as want to be in the default window group | 
 |  621   // then so we can break any existing GTK grabs. | 
 |  622   GtkWindowGroup* window_group = gtk_window_group_new(); | 
 |  623   gtk_window_group_add_window(window_group, | 
 |  624                               GTK_WINDOW(lock_window_->GetNativeView())); | 
 |  625   g_object_unref(window_group); | 
|  622  |  626  | 
|  623   // Don't let X draw default background, which was causing flash on |  627   // Don't let X draw default background, which was causing flash on | 
|  624   // resume. |  628   // resume. | 
|  625   gdk_window_set_back_pixmap(lock_window_->GetNativeView()->window, |  629   gdk_window_set_back_pixmap(lock_window_->GetNativeView()->window, | 
|  626                              NULL, false); |  630                              NULL, false); | 
|  627   gdk_window_set_back_pixmap(lock_widget_->GetNativeView()->window, |  631   gdk_window_set_back_pixmap(lock_widget_->GetNativeView()->window, | 
|  628                              NULL, false); |  632                              NULL, false); | 
|  629   lock_window->set_toplevel_focus_widget(lock_widget_->window_contents()); |  633   lock_window->set_toplevel_focus_widget(lock_widget_->window_contents()); | 
|  630  |  634  | 
|  631   // Create the SystemKeyEventListener so it can listen for system keyboard |  635   // Create the SystemKeyEventListener so it can listen for system keyboard | 
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  921  |  925  | 
|  922 bool ScreenLocker::AcceleratorPressed(const views::Accelerator& accelerator) { |  926 bool ScreenLocker::AcceleratorPressed(const views::Accelerator& accelerator) { | 
|  923   if (!background_view_->IsScreenSaverVisible()) { |  927   if (!background_view_->IsScreenSaverVisible()) { | 
|  924     StartScreenSaver(); |  928     StartScreenSaver(); | 
|  925     return true; |  929     return true; | 
|  926   } |  930   } | 
|  927   return false; |  931   return false; | 
|  928 } |  932 } | 
|  929  |  933  | 
|  930 }  // namespace chromeos |  934 }  // namespace chromeos | 
| OLD | NEW |