Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/views/omnibox/omnibox_view_views.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 if (event.IsShiftDown() && | 405 if (event.IsShiftDown() && |
| 406 (model()->popup_model()->selected_line_state() == | 406 (model()->popup_model()->selected_line_state() == |
| 407 OmniboxPopupModel::KEYWORD)) | 407 OmniboxPopupModel::KEYWORD)) |
| 408 model()->ClearKeyword(); | 408 model()->ClearKeyword(); |
| 409 else | 409 else |
| 410 model()->OnUpOrDownKeyPressed(event.IsShiftDown() ? -1 : 1); | 410 model()->OnUpOrDownKeyPressed(event.IsShiftDown() ? -1 : 1); |
| 411 | 411 |
| 412 return true; | 412 return true; |
| 413 } | 413 } |
| 414 | 414 |
| 415 void OmniboxViewViews::AccessibilitySetValue(const base::string16& new_value) { | 415 void OmniboxViewViews::AccessibilitySetValue(const base::string16& new_value, |
| 416 SetUserText(new_value, true); | 416 bool clear_first) { |
| 417 if (read_only()) | |
| 418 return; | |
| 419 if (clear_first) { | |
| 420 SetUserText(new_value, true); | |
| 421 } else { | |
| 422 SelectRange(saved_selection_for_focus_change_); | |
|
msw
2016/10/27 17:55:09
Should this check if saved_selection_for_focus_cha
Patti Lor
2016/10/31 00:35:05
Yes - thanks for picking that up!
| |
| 423 saved_selection_for_focus_change_ = gfx::Range::InvalidRange(); | |
| 424 InsertOrReplaceText(new_value); | |
| 425 model()->SetInputInProgress(true); | |
|
msw
2016/10/27 17:55:08
nit: call this at the top of the block, to match S
Patti Lor
2016/10/31 00:35:05
Done.
| |
| 426 TextChanged(); | |
| 427 } | |
| 417 } | 428 } |
| 418 | 429 |
| 419 void OmniboxViewViews::UpdateSecurityLevel() { | 430 void OmniboxViewViews::UpdateSecurityLevel() { |
| 420 security_level_ = controller()->GetToolbarModel()->GetSecurityLevel(false); | 431 security_level_ = controller()->GetToolbarModel()->GetSecurityLevel(false); |
| 421 } | 432 } |
| 422 | 433 |
| 423 void OmniboxViewViews::SetWindowTextAndCaretPos(const base::string16& text, | 434 void OmniboxViewViews::SetWindowTextAndCaretPos(const base::string16& text, |
| 424 size_t caret_pos, | 435 size_t caret_pos, |
| 425 bool update_popup, | 436 bool update_popup, |
| 426 bool notify_text_changed) { | 437 bool notify_text_changed) { |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 730 return Textfield::SkipDefaultKeyEventProcessing(event); | 741 return Textfield::SkipDefaultKeyEventProcessing(event); |
| 731 } | 742 } |
| 732 | 743 |
| 733 void OmniboxViewViews::GetAccessibleState(ui::AXViewState* state) { | 744 void OmniboxViewViews::GetAccessibleState(ui::AXViewState* state) { |
| 734 state->role = ui::AX_ROLE_TEXT_FIELD; | 745 state->role = ui::AX_ROLE_TEXT_FIELD; |
| 735 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_LOCATION); | 746 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_LOCATION); |
| 736 state->value = GetText(); | 747 state->value = GetText(); |
| 737 | 748 |
| 738 base::string16::size_type entry_start; | 749 base::string16::size_type entry_start; |
| 739 base::string16::size_type entry_end; | 750 base::string16::size_type entry_end; |
| 740 GetSelectionBounds(&entry_start, &entry_end); | 751 // Selection information is saved separately when focus is moved off the |
| 752 // current window - use that when there is no focus and it's valid. | |
| 753 if (saved_selection_for_focus_change_.IsValid()) { | |
| 754 entry_start = saved_selection_for_focus_change_.start(); | |
| 755 entry_end = saved_selection_for_focus_change_.end(); | |
| 756 } else { | |
| 757 GetSelectionBounds(&entry_start, &entry_end); | |
| 758 } | |
| 741 state->selection_start = entry_start; | 759 state->selection_start = entry_start; |
| 742 state->selection_end = entry_end; | 760 state->selection_end = entry_end; |
| 743 | 761 |
| 744 if (popup_window_mode_) { | 762 if (popup_window_mode_) { |
| 745 state->AddStateFlag(ui::AX_STATE_READ_ONLY); | 763 state->AddStateFlag(ui::AX_STATE_READ_ONLY); |
| 746 } else { | 764 } else { |
| 747 state->AddStateFlag(ui::AX_STATE_EDITABLE); | 765 state->AddStateFlag(ui::AX_STATE_EDITABLE); |
| 748 state->set_value_callback = | 766 state->set_value_callback = |
| 749 base::Bind(&OmniboxViewViews::AccessibilitySetValue, | 767 base::Bind(&OmniboxViewViews::AccessibilitySetValue, |
| 750 weak_ptr_factory_.GetWeakPtr()); | 768 weak_ptr_factory_.GetWeakPtr()); |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1072 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); | 1090 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); |
| 1073 | 1091 |
| 1074 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); | 1092 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); |
| 1075 | 1093 |
| 1076 // Minor note: We use IDC_ for command id here while the underlying textfield | 1094 // Minor note: We use IDC_ for command id here while the underlying textfield |
| 1077 // is using IDS_ for all its command ids. This is because views cannot depend | 1095 // is using IDS_ for all its command ids. This is because views cannot depend |
| 1078 // on IDC_ for now. | 1096 // on IDC_ for now. |
| 1079 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 1097 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
| 1080 IDS_EDIT_SEARCH_ENGINES); | 1098 IDS_EDIT_SEARCH_ENGINES); |
| 1081 } | 1099 } |
| OLD | NEW |