Chromium Code Reviews| Index: chrome/browser/chromeos/login/screen_lock_view.cc |
| diff --git a/chrome/browser/chromeos/login/screen_lock_view.cc b/chrome/browser/chromeos/login/screen_lock_view.cc |
| index ac39b7b572ded34cde6b2615209279717a468ba3..6a7866cab5e1dcb435420312f7d80ea81d6d6708 100644 |
| --- a/chrome/browser/chromeos/login/screen_lock_view.cc |
| +++ b/chrome/browser/chromeos/login/screen_lock_view.cc |
| @@ -24,6 +24,7 @@ |
| #include "views/controls/image_view.h" |
| #include "views/controls/label.h" |
| #include "views/controls/textfield/textfield.h" |
| +#include "views/controls/textfield/native_textfield_wrapper.h" |
|
Daniel Erat
2011/05/11 00:02:46
nit: move this up one line
|
| #include "views/layout/grid_layout.h" |
| namespace chromeos { |
| @@ -38,7 +39,8 @@ const int kCornerRadius = 5; |
| class PasswordField : public TextfieldWithMargin { |
| public: |
| PasswordField() |
| - : TextfieldWithMargin(views::Textfield::STYLE_PASSWORD) { |
| + : TextfieldWithMargin(views::Textfield::STYLE_PASSWORD), |
| + context_menu_disabled_(false) { |
| set_text_to_display_when_empty( |
| l10n_util::GetStringUTF16(IDS_LOGIN_POD_EMPTY_PASSWORD_TEXT)); |
| } |
| @@ -49,10 +51,38 @@ class PasswordField : public TextfieldWithMargin { |
| return false; |
| } |
| + virtual void ViewHierarchyChanged(bool is_add, |
| + views::View* parent, |
| + views::View* child) OVERRIDE { |
| + Textfield::ViewHierarchyChanged(is_add, parent, child); |
| + // Wiat until native widget is created. |
| + if (!context_menu_disabled_ && native_wrapper_) { |
| + gfx::NativeView widget = native_wrapper_->GetTestingHandle(); |
| + if (widget) { |
| + context_menu_disabled_ = true; |
| + g_signal_connect(widget, "button-press-event", |
| + G_CALLBACK(OnButtonPressEventThunk), this); |
| + } |
| + } |
| + } |
| + |
| + CHROMEGTK_CALLBACK_1(PasswordField, gboolean, OnButtonPressEvent, |
| + GdkEventButton*); |
| + |
| private: |
| + bool context_menu_disabled_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(PasswordField); |
| }; |
| +gboolean PasswordField::OnButtonPressEvent(GtkWidget* widget, |
| + GdkEventButton* event) { |
| + // Eat button 2/3 and alt + any button to disable context menu. |
| + return event->state & GDK_MOD1_MASK || |
| + event->button == 2 || |
| + event->button == 3; |
| +} |
| + |
| } // namespace |
| using views::GridLayout; |