| Index: ui/views/controls/textfield/native_textfield_views.cc
|
| diff --git a/ui/views/controls/textfield/native_textfield_views.cc b/ui/views/controls/textfield/native_textfield_views.cc
|
| index 5fd5e246b9b73a03c2268daae9d3eca4530bbe2d..ccd75505769842d94178a5eb3248cdf69825999b 100644
|
| --- a/ui/views/controls/textfield/native_textfield_views.cc
|
| +++ b/ui/views/controls/textfield/native_textfield_views.cc
|
| @@ -309,7 +309,8 @@ void NativeTextfieldViews::WriteDragDataForView(views::View* sender,
|
|
|
| int NativeTextfieldViews::GetDragOperationsForView(views::View* sender,
|
| const gfx::Point& p) {
|
| - if (!textfield_->enabled() || !GetRenderText()->IsPointInSelection(p))
|
| + if (!textfield_->enabled() || textfield_->IsObscured() ||
|
| + !GetRenderText()->IsPointInSelection(p))
|
| return ui::DragDropTypes::DRAG_NONE;
|
| if (sender == this && !textfield_->read_only())
|
| return ui::DragDropTypes::DRAG_MOVE | ui::DragDropTypes::DRAG_COPY;
|
| @@ -411,7 +412,7 @@ void NativeTextfieldViews::UpdateFont() {
|
| }
|
|
|
| void NativeTextfieldViews::UpdateIsObscured() {
|
| - // TODO(benrg): GetRenderText()->SetObscured(textfield_->IsObscured());
|
| + model_->SetObscured(textfield_->IsObscured());
|
| OnCaretBoundsChanged();
|
| SchedulePaint();
|
| OnTextInputTypeChanged();
|
| @@ -552,9 +553,9 @@ bool NativeTextfieldViews::IsCommandIdEnabled(int command_id) const {
|
| string16 result;
|
| switch (command_id) {
|
| case IDS_APP_CUT:
|
| - return editable && model_->HasSelection();
|
| + return editable && model_->HasSelection() && !textfield_->IsObscured();
|
| case IDS_APP_COPY:
|
| - return model_->HasSelection();
|
| + return model_->HasSelection() && !textfield_->IsObscured();
|
| case IDS_APP_PASTE:
|
| ViewsDelegate::views_delegate->GetClipboard()
|
| ->ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
|
| @@ -575,30 +576,28 @@ bool NativeTextfieldViews::GetAcceleratorForCommandId(int command_id,
|
|
|
| void NativeTextfieldViews::ExecuteCommand(int command_id) {
|
| bool text_changed = false;
|
| - bool editable = !textfield_->read_only();
|
| OnBeforeUserAction();
|
| - switch (command_id) {
|
| - case IDS_APP_CUT:
|
| - if (editable)
|
| + if (IsCommandIdEnabled(command_id)) {
|
| + switch (command_id) {
|
| + case IDS_APP_CUT:
|
| text_changed = Cut();
|
| - break;
|
| - case IDS_APP_COPY:
|
| - Copy();
|
| - break;
|
| - case IDS_APP_PASTE:
|
| - if (editable)
|
| + break;
|
| + case IDS_APP_COPY:
|
| + Copy();
|
| + break;
|
| + case IDS_APP_PASTE:
|
| text_changed = Paste();
|
| - break;
|
| - case IDS_APP_DELETE:
|
| - if (editable)
|
| + break;
|
| + case IDS_APP_DELETE:
|
| text_changed = model_->Delete();
|
| - break;
|
| - case IDS_APP_SELECT_ALL:
|
| - SelectAll();
|
| - break;
|
| - default:
|
| - textfield_->GetController()->ExecuteCommand(command_id);
|
| - break;
|
| + break;
|
| + case IDS_APP_SELECT_ALL:
|
| + SelectAll();
|
| + break;
|
| + default:
|
| + textfield_->GetController()->ExecuteCommand(command_id);
|
| + break;
|
| + }
|
| }
|
|
|
| // The cursor must have changed if text changed during cut/paste/delete.
|
| @@ -838,6 +837,7 @@ bool NativeTextfieldViews::HandleKeyEvent(const KeyEvent& key_event) {
|
|
|
| OnBeforeUserAction();
|
| bool editable = !textfield_->read_only();
|
| + bool readable = !textfield_->IsObscured();
|
| bool selection = key_event.IsShiftDown();
|
| bool control = key_event.IsControlDown();
|
| bool text_changed = false;
|
| @@ -858,11 +858,11 @@ bool NativeTextfieldViews::HandleKeyEvent(const KeyEvent& key_event) {
|
| }
|
| break;
|
| case ui::VKEY_X:
|
| - if (control && editable)
|
| + if (control && editable && readable)
|
| cursor_changed = text_changed = Cut();
|
| break;
|
| case ui::VKEY_C:
|
| - if (control)
|
| + if (control && readable)
|
| Copy();
|
| break;
|
| case ui::VKEY_V:
|
|
|