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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_view_views.cc

Issue 2341633006: MacViews/a11y: Allow accessibility clients to update the selected text. (Closed)
Patch Set: Review comments. Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.h ('k') | ui/accessibility/ax_view_state.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 model()->SetInputInProgress(true);
423 if (saved_selection_for_focus_change_.IsValid()) {
424 SelectRange(saved_selection_for_focus_change_);
425 saved_selection_for_focus_change_ = gfx::Range::InvalidRange();
426 }
427 InsertOrReplaceText(new_value);
428 TextChanged();
429 }
417 } 430 }
418 431
419 void OmniboxViewViews::UpdateSecurityLevel() { 432 void OmniboxViewViews::UpdateSecurityLevel() {
420 security_level_ = controller()->GetToolbarModel()->GetSecurityLevel(false); 433 security_level_ = controller()->GetToolbarModel()->GetSecurityLevel(false);
421 } 434 }
422 435
423 void OmniboxViewViews::SetWindowTextAndCaretPos(const base::string16& text, 436 void OmniboxViewViews::SetWindowTextAndCaretPos(const base::string16& text,
424 size_t caret_pos, 437 size_t caret_pos,
425 bool update_popup, 438 bool update_popup,
426 bool notify_text_changed) { 439 bool notify_text_changed) {
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 return Textfield::SkipDefaultKeyEventProcessing(event); 743 return Textfield::SkipDefaultKeyEventProcessing(event);
731 } 744 }
732 745
733 void OmniboxViewViews::GetAccessibleState(ui::AXViewState* state) { 746 void OmniboxViewViews::GetAccessibleState(ui::AXViewState* state) {
734 state->role = ui::AX_ROLE_TEXT_FIELD; 747 state->role = ui::AX_ROLE_TEXT_FIELD;
735 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_LOCATION); 748 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_LOCATION);
736 state->value = GetText(); 749 state->value = GetText();
737 750
738 base::string16::size_type entry_start; 751 base::string16::size_type entry_start;
739 base::string16::size_type entry_end; 752 base::string16::size_type entry_end;
740 GetSelectionBounds(&entry_start, &entry_end); 753 // Selection information is saved separately when focus is moved off the
754 // current window - use that when there is no focus and it's valid.
755 if (saved_selection_for_focus_change_.IsValid()) {
756 entry_start = saved_selection_for_focus_change_.start();
757 entry_end = saved_selection_for_focus_change_.end();
758 } else {
759 GetSelectionBounds(&entry_start, &entry_end);
760 }
741 state->selection_start = entry_start; 761 state->selection_start = entry_start;
742 state->selection_end = entry_end; 762 state->selection_end = entry_end;
743 763
744 if (popup_window_mode_) { 764 if (popup_window_mode_) {
745 state->AddStateFlag(ui::AX_STATE_READ_ONLY); 765 state->AddStateFlag(ui::AX_STATE_READ_ONLY);
746 } else { 766 } else {
747 state->AddStateFlag(ui::AX_STATE_EDITABLE); 767 state->AddStateFlag(ui::AX_STATE_EDITABLE);
748 state->set_value_callback = 768 state->set_value_callback =
749 base::Bind(&OmniboxViewViews::AccessibilitySetValue, 769 base::Bind(&OmniboxViewViews::AccessibilitySetValue,
750 weak_ptr_factory_.GetWeakPtr()); 770 weak_ptr_factory_.GetWeakPtr());
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); 1092 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO);
1073 1093
1074 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); 1094 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR);
1075 1095
1076 // Minor note: We use IDC_ for command id here while the underlying textfield 1096 // 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 1097 // is using IDS_ for all its command ids. This is because views cannot depend
1078 // on IDC_ for now. 1098 // on IDC_ for now.
1079 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, 1099 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES,
1080 IDS_EDIT_SEARCH_ENGINES); 1100 IDS_EDIT_SEARCH_ENGINES);
1081 } 1101 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.h ('k') | ui/accessibility/ax_view_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698