| Index: chrome/browser/chromeos/login/screen_locker_views.cc
|
| diff --git a/chrome/browser/chromeos/login/screen_locker_views.cc b/chrome/browser/chromeos/login/screen_locker_views.cc
|
| index a00434148916eca8e578dea10fbb76c5c93b4342..c745090978223290b42e0be48083a4e9378647d4 100644
|
| --- a/chrome/browser/chromeos/login/screen_locker_views.cc
|
| +++ b/chrome/browser/chromeos/login/screen_locker_views.cc
|
| @@ -31,9 +31,11 @@
|
| #include "ui/base/resource/resource_bundle.h"
|
| #include "ui/base/x/x11_util.h"
|
| #include "ui/gfx/screen.h"
|
| +#include "views/controls/textfield/textfield.h"
|
|
|
| #if defined(TOOLKIT_USES_GTK)
|
| #include "chrome/browser/chromeos/legacy_window_manager/wm_ipc.h"
|
| +#include "views/widget/native_widget_gtk.h"
|
| #endif
|
|
|
| namespace {
|
| @@ -61,6 +63,8 @@ class LockWindow : public views::NativeWidgetGtk {
|
| : views::NativeWidgetGtk(new views::Widget),
|
| toplevel_focus_widget_(NULL) {
|
| EnableDoubleBuffer(true);
|
| + g_signal_connect(GetNativeView(), "client-event",
|
| + G_CALLBACK(OnClientEventThunk), this);
|
| }
|
|
|
| // GTK propagates key events from parents to children.
|
| @@ -87,6 +91,9 @@ class LockWindow : public views::NativeWidgetGtk {
|
| gtk_widget_grab_focus(toplevel_focus_widget_);
|
| }
|
|
|
| + // Event handler for client-event.
|
| + CHROMEGTK_CALLBACK_1(LockWindow, void, OnClientEvent, GdkEventClient*);
|
| +
|
| // Sets the widget to move the focus to when clearning the native
|
| // widget's focus.
|
| void set_toplevel_focus_widget(GtkWidget* widget) {
|
| @@ -105,6 +112,17 @@ class LockWindow : public views::NativeWidgetGtk {
|
| DISALLOW_COPY_AND_ASSIGN(LockWindow);
|
| };
|
|
|
| +void LockWindow::OnClientEvent(GtkWidget* widget, GdkEventClient* event) {
|
| +#if defined(TOOLKIT_USES_GTK)
|
| + chromeos::WmIpc::Message msg;
|
| + chromeos::WmIpc::instance()->DecodeMessage(*event, &msg);
|
| + if (msg.type() ==
|
| + chromeos::WM_IPC_MESSAGE_CHROME_NOTIFY_SCREEN_REDRAWN_FOR_LOCK) {
|
| + screen_locker_view_->OnWindowManagerReady();
|
| + }
|
| +#endif
|
| +}
|
| +
|
| // GrabWidget's root view to layout the ScreenLockView at the center
|
| // and the Shutdown button at the left top.
|
| class GrabWidgetRootView
|
| @@ -616,9 +634,6 @@ void ScreenLockerViews::LockScreen(bool unlock_on_input) {
|
| gtk_widget_modify_bg(
|
| lock_window_->GetNativeView(), GTK_STATE_NORMAL, &kGdkBlack);
|
|
|
| - g_signal_connect(lock_window_->GetNativeView(), "client-event",
|
| - G_CALLBACK(OnClientEventThunk), this);
|
| -
|
| // GTK does not like zero width/height.
|
| if (!unlock_on_input) {
|
| screen_lock_view_ = new ScreenLockView(screen_locker_);
|
| @@ -806,13 +821,14 @@ void ScreenLockerViews::ShowCaptchaAndErrorMessage(const GURL& captcha_url,
|
| }
|
|
|
| void ScreenLockerViews::ClearErrors() {
|
| - if (error_info_) {
|
| - error_info_->Close();
|
| - error_info_ = NULL;
|
| - }
|
| + if (error_info_)
|
| + error_info_->GetWidget()->Close();
|
| }
|
|
|
| -void ScreenLockerViews::BubbleClosing(Bubble* bubble, bool closed_by_escape) {
|
| +void ScreenLockerViews::OnWidgetClosing(views::Widget* widget) {
|
| + if (!error_info_ || error_info_->GetWidget() != widget)
|
| + return;
|
| +
|
| error_info_ = NULL;
|
| SetSignoutEnabled(true);
|
| if (mouse_event_relay_.get()) {
|
| @@ -821,17 +837,6 @@ void ScreenLockerViews::BubbleClosing(Bubble* bubble, bool closed_by_escape) {
|
| }
|
| }
|
|
|
| -bool ScreenLockerViews::CloseOnEscape() {
|
| - return true;
|
| -}
|
| -
|
| -bool ScreenLockerViews::FadeInOnShow() {
|
| - return false;
|
| -}
|
| -
|
| -void ScreenLockerViews::OnLinkActivated(size_t index) {
|
| -}
|
| -
|
| void ScreenLockerViews::OnCaptchaEntered(const std::string& captcha) {
|
| // Captcha dialog is only shown when LoginPerformer instance exists,
|
| // i.e. blocking UI after password change is in place.
|
| @@ -854,6 +859,13 @@ void ScreenLockerViews::OnCaptchaEntered(const std::string& captcha) {
|
| postponed_error_message_.clear();
|
| }
|
|
|
| +void ScreenLockerViews::OnWindowManagerReady() {
|
| + DVLOG(1) << "OnClientEvent: drawn for lock";
|
| + drawn_ = true;
|
| + if (input_grabbed_)
|
| + ScreenLockReady();
|
| +}
|
| +
|
| ScreenLockerViews::~ScreenLockerViews() {
|
| if (input_event_observer_.get())
|
| MessageLoopForUI::current()->RemoveObserver(input_event_observer_.get());
|
| @@ -874,38 +886,27 @@ ScreenLockerViews::~ScreenLockerViews() {
|
| screen_locker_view_ = NULL;
|
| }
|
|
|
| -void ScreenLockerViews::OnWindowManagerReady() {
|
| - DVLOG(1) << "OnClientEvent: drawn for lock";
|
| - drawn_ = true;
|
| - if (input_grabbed_)
|
| - ScreenLockReady();
|
| -}
|
| -
|
| void ScreenLockerViews::ShowErrorBubble(
|
| const string16& message,
|
| views::BubbleBorder::ArrowLocation arrow_location) {
|
| - if (error_info_)
|
| - error_info_->Close();
|
| -
|
| - gfx::Rect rect = screen_lock_view_->GetPasswordBoundsRelativeTo(
|
| - lock_widget_->GetRootView());
|
| - gfx::Rect lock_widget_bounds = lock_widget_->GetClientAreaScreenBounds();
|
| - rect.Offset(lock_widget_bounds.x(), lock_widget_bounds.y());
|
| - error_info_ = MessageBubble::ShowNoGrab(
|
| - lock_window_,
|
| - rect,
|
| + ClearErrors();
|
| +
|
| + // TODO(nkostylev): Add help link.
|
| + error_info_ = new MessageBubble(
|
| + screen_lock_view_->password_field(),
|
| arrow_location,
|
| ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING),
|
| - UTF16ToWide(message),
|
| - UTF16ToWide(string16()), // TODO(nkostylev): Add help link.
|
| - this);
|
| + message,
|
| + string16());
|
| + MessageBubble::ShowBubble(error_info_);
|
| + error_info_->GetWidget()->AddObserver(this);
|
|
|
| #if !defined(TOUCH_UI)
|
| if (mouse_event_relay_.get())
|
| MessageLoopForUI::current()->RemoveObserver(mouse_event_relay_.get());
|
| mouse_event_relay_.reset(
|
| new MouseEventRelay(lock_widget_->GetNativeView()->window,
|
| - error_info_->GetNativeView()->window));
|
| + error_info_->GetWidget()->GetNativeView()->window));
|
| MessageLoopForUI::current()->AddObserver(mouse_event_relay_.get());
|
| #endif
|
| }
|
| @@ -919,14 +920,4 @@ bool ScreenLockerViews::AcceleratorPressed(
|
| return false;
|
| }
|
|
|
| -void ScreenLockerViews::OnClientEvent(GtkWidget* widge, GdkEventClient* event) {
|
| -#if defined(TOOLKIT_USES_GTK)
|
| - WmIpc::Message msg;
|
| - WmIpc::instance()->DecodeMessage(*event, &msg);
|
| - if (msg.type() == WM_IPC_MESSAGE_CHROME_NOTIFY_SCREEN_REDRAWN_FOR_LOCK) {
|
| - OnWindowManagerReady();
|
| - }
|
| -#endif
|
| -}
|
| -
|
| } // namespace chromeos
|
|
|