Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4759)

Unified Diff: chrome/browser/chromeos/login/screen_lock_view.cc

Issue 6997007: Disable textfield's context menu in screen locker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/screen_locker.cc » ('j') | chrome/browser/chromeos/login/screen_locker.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698