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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_lock_view.h" 5 #include "chrome/browser/chromeos/login/screen_lock_view.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" 8 #include "chrome/browser/chromeos/login/rounded_rect_painter.h"
9 #include "chrome/browser/chromeos/login/screen_locker.h" 9 #include "chrome/browser/chromeos/login/screen_locker.h"
10 #include "chrome/browser/chromeos/login/textfield_with_margin.h" 10 #include "chrome/browser/chromeos/login/textfield_with_margin.h"
11 #include "chrome/browser/chromeos/login/user_manager.h" 11 #include "chrome/browser/chromeos/login/user_manager.h"
12 #include "chrome/browser/chromeos/login/user_view.h" 12 #include "chrome/browser/chromeos/login/user_view.h"
13 #include "chrome/browser/chromeos/login/username_view.h" 13 #include "chrome/browser/chromeos/login/username_view.h"
14 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h" 14 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h"
15 #include "chrome/browser/chromeos/views/copy_background.h" 15 #include "chrome/browser/chromeos/views/copy_background.h"
16 #include "chrome/browser/profiles/profile_manager.h" 16 #include "chrome/browser/profiles/profile_manager.h"
17 #include "content/common/notification_service.h" 17 #include "content/common/notification_service.h"
18 #include "grit/generated_resources.h" 18 #include "grit/generated_resources.h"
19 #include "grit/theme_resources.h" 19 #include "grit/theme_resources.h"
20 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/base/resource/resource_bundle.h" 21 #include "ui/base/resource/resource_bundle.h"
22 #include "views/background.h" 22 #include "views/background.h"
23 #include "views/border.h" 23 #include "views/border.h"
24 #include "views/controls/image_view.h" 24 #include "views/controls/image_view.h"
25 #include "views/controls/label.h" 25 #include "views/controls/label.h"
26 #include "views/controls/textfield/textfield.h" 26 #include "views/controls/textfield/textfield.h"
27 #include "views/controls/textfield/native_textfield_wrapper.h"
Daniel Erat 2011/05/11 00:02:46 nit: move this up one line
27 #include "views/layout/grid_layout.h" 28 #include "views/layout/grid_layout.h"
28 29
29 namespace chromeos { 30 namespace chromeos {
30 31
31 namespace { 32 namespace {
32 33
33 const int kCornerRadius = 5; 34 const int kCornerRadius = 5;
34 35
35 // A Textfield for password, which also sets focus to itself 36 // A Textfield for password, which also sets focus to itself
36 // when a mouse is clicked on it. This is necessary in screen locker 37 // when a mouse is clicked on it. This is necessary in screen locker
37 // as mouse events are grabbed in the screen locker. 38 // as mouse events are grabbed in the screen locker.
38 class PasswordField : public TextfieldWithMargin { 39 class PasswordField : public TextfieldWithMargin {
39 public: 40 public:
40 PasswordField() 41 PasswordField()
41 : TextfieldWithMargin(views::Textfield::STYLE_PASSWORD) { 42 : TextfieldWithMargin(views::Textfield::STYLE_PASSWORD),
43 context_menu_disabled_(false) {
42 set_text_to_display_when_empty( 44 set_text_to_display_when_empty(
43 l10n_util::GetStringUTF16(IDS_LOGIN_POD_EMPTY_PASSWORD_TEXT)); 45 l10n_util::GetStringUTF16(IDS_LOGIN_POD_EMPTY_PASSWORD_TEXT));
44 } 46 }
45 47
46 // views::View overrides. 48 // views::View overrides.
47 virtual bool OnMousePressed(const views::MouseEvent& e) { 49 virtual bool OnMousePressed(const views::MouseEvent& e) {
48 RequestFocus(); 50 RequestFocus();
49 return false; 51 return false;
50 } 52 }
51 53
54 virtual void ViewHierarchyChanged(bool is_add,
55 views::View* parent,
56 views::View* child) OVERRIDE {
57 Textfield::ViewHierarchyChanged(is_add, parent, child);
58 // Wiat until native widget is created.
59 if (!context_menu_disabled_ && native_wrapper_) {
60 gfx::NativeView widget = native_wrapper_->GetTestingHandle();
61 if (widget) {
62 context_menu_disabled_ = true;
63 g_signal_connect(widget, "button-press-event",
64 G_CALLBACK(OnButtonPressEventThunk), this);
65 }
66 }
67 }
68
69 CHROMEGTK_CALLBACK_1(PasswordField, gboolean, OnButtonPressEvent,
70 GdkEventButton*);
71
52 private: 72 private:
73 bool context_menu_disabled_;
74
53 DISALLOW_COPY_AND_ASSIGN(PasswordField); 75 DISALLOW_COPY_AND_ASSIGN(PasswordField);
54 }; 76 };
55 77
78 gboolean PasswordField::OnButtonPressEvent(GtkWidget* widget,
79 GdkEventButton* event) {
80 // Eat button 2/3 and alt + any button to disable context menu.
81 return event->state & GDK_MOD1_MASK ||
82 event->button == 2 ||
83 event->button == 3;
84 }
85
56 } // namespace 86 } // namespace
57 87
58 using views::GridLayout; 88 using views::GridLayout;
59 using login::kBorderSize; 89 using login::kBorderSize;
60 90
61 ScreenLockView::ScreenLockView(ScreenLocker* screen_locker) 91 ScreenLockView::ScreenLockView(ScreenLocker* screen_locker)
62 : user_view_(NULL), 92 : user_view_(NULL),
63 password_field_(NULL), 93 password_field_(NULL),
64 screen_locker_(screen_locker), 94 screen_locker_(screen_locker),
65 main_(NULL), 95 main_(NULL),
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 if (type != NotificationType::LOGIN_USER_IMAGE_CHANGED || !user_view_) 243 if (type != NotificationType::LOGIN_USER_IMAGE_CHANGED || !user_view_)
214 return; 244 return;
215 245
216 UserManager::User* user = Details<UserManager::User>(details).ptr(); 246 UserManager::User* user = Details<UserManager::User>(details).ptr();
217 if (screen_locker_->user().email() != user->email()) 247 if (screen_locker_->user().email() != user->email())
218 return; 248 return;
219 user_view_->SetImage(user->image(), user->image()); 249 user_view_->SetImage(user->image(), user->image());
220 } 250 }
221 251
222 } // namespace chromeos 252 } // namespace chromeos
OLDNEW
« 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