Chromium Code Reviews| 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 2163dbded451db87a95c4695aca638cc52c1ffb1..930ca5e4d4d255f39e204aec5feb2211d81426ab 100644 |
| --- a/ui/views/controls/textfield/native_textfield_views.cc |
| +++ b/ui/views/controls/textfield/native_textfield_views.cc |
| @@ -299,7 +299,8 @@ void NativeTextfieldViews::WriteDragDataForView(views::View* sender, |
| int NativeTextfieldViews::GetDragOperationsForView(views::View* sender, |
| const gfx::Point& p) { |
| - if (!textfield_->IsEnabled() || !GetRenderText()->IsPointInSelection(p)) |
| + if (!textfield_->IsEnabled() || textfield_->IsPassword() |
| + || !GetRenderText()->IsPointInSelection(p)) |
| return ui::DragDropTypes::DRAG_NONE; |
| if (sender == this && !textfield_->read_only()) |
| return ui::DragDropTypes::DRAG_MOVE | ui::DragDropTypes::DRAG_COPY; |
| @@ -398,7 +399,7 @@ void NativeTextfieldViews::UpdateFont() { |
| } |
| void NativeTextfieldViews::UpdateIsPassword() { |
| - model_->set_is_password(textfield_->IsPassword()); |
| + GetRenderText()->SetIsObscured(textfield_->IsPassword()); |
| OnCaretBoundsChanged(); |
| SchedulePaint(); |
| OnTextInputTypeChanged(); |
| @@ -533,9 +534,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_->IsPassword(); |
|
oshima
2011/12/06 23:57:18
I assume you'll change IsPassword in another CL?
benrg
2011/12/08 21:40:55
It's changed in 8748001, which should land someday
|
| case IDS_APP_COPY: |
| - return model_->HasSelection(); |
| + return model_->HasSelection() && !textfield_->IsPassword(); |
| case IDS_APP_PASTE: |
| ViewsDelegate::views_delegate->GetClipboard() |
| ->ReadText(ui::Clipboard::BUFFER_STANDARD, &result); |
| @@ -557,23 +558,20 @@ bool NativeTextfieldViews::GetAcceleratorForCommandId(int command_id, |
| void NativeTextfieldViews::ExecuteCommand(int command_id) { |
| bool text_changed = false; |
| - bool editable = !textfield_->read_only(); |
|
oshima
2011/12/06 23:57:18
won't this break read_only behavior?
benrg
2011/12/08 21:40:55
I thought ExecuteCommand is only called when a men
|
| + DCHECK(IsCommandIdEnabled(command_id)); |
| OnBeforeUserAction(); |
| switch (command_id) { |
| case IDS_APP_CUT: |
| - if (editable) |
| - text_changed = model_->Cut(); |
| + text_changed = model_->Cut(); |
| break; |
| case IDS_APP_COPY: |
| model_->Copy(); |
| break; |
| case IDS_APP_PASTE: |
| - if (editable) |
| - text_changed = Paste(); |
| + text_changed = Paste(); |
| break; |
| case IDS_APP_DELETE: |
| - if (editable) |
| - text_changed = model_->Delete(); |
| + text_changed = model_->Delete(); |
| break; |
| case IDS_APP_SELECT_ALL: |
| SelectAll(); |