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

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

Issue 6731036: Enabled pressing TAB to cycle through the Omnibox results. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 8 years, 11 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) 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 "base/property_bag.h" 7 #include "base/property_bag.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 if (model_->popup_model()->IsOpen()) 258 if (model_->popup_model()->IsOpen())
259 model_->popup_model()->TryDeletingCurrentItem(); 259 model_->popup_model()->TryDeletingCurrentItem();
260 } else if (!handled && event.key_code() == ui::VKEY_UP) { 260 } else if (!handled && event.key_code() == ui::VKEY_UP) {
261 model_->OnUpOrDownKeyPressed(-1); 261 model_->OnUpOrDownKeyPressed(-1);
262 handled = true; 262 handled = true;
263 } else if (!handled && event.key_code() == ui::VKEY_DOWN) { 263 } else if (!handled && event.key_code() == ui::VKEY_DOWN) {
264 model_->OnUpOrDownKeyPressed(1); 264 model_->OnUpOrDownKeyPressed(1);
265 handled = true; 265 handled = true;
266 } else if (!handled && 266 } else if (!handled &&
267 event.key_code() == ui::VKEY_TAB && 267 event.key_code() == ui::VKEY_TAB &&
268 !event.IsShiftDown() &&
269 !event.IsControlDown()) { 268 !event.IsControlDown()) {
270 if (model_->is_keyword_hint()) { 269 if (model_->is_keyword_hint() && !event.IsShiftDown()) {
271 handled = model_->AcceptKeyword(); 270 handled = model_->AcceptKeyword();
271 } else if (model_->popup_model()->IsOpen()) {
272 if (event.IsShiftDown() &&
273 model_->popup_model()->selected_line_state() ==
274 AutocompletePopupModel::KEYWORD) {
275 model_->ClearKeyword(GetText());
276 } else {
277 model_->OnUpOrDownKeyPressed(event.IsShiftDown() ? -1 : 1);
278 }
279 handled = true;
272 } else { 280 } else {
273 string16::size_type start = 0; 281 string16::size_type start = 0;
274 string16::size_type end = 0; 282 string16::size_type end = 0;
275 size_t length = GetTextLength(); 283 size_t length = GetTextLength();
276 GetSelectionBounds(&start, &end); 284 GetSelectionBounds(&start, &end);
277 if (start != end || start < length) { 285 if (start != end || start < length) {
278 OnBeforePossibleChange(); 286 OnBeforePossibleChange();
279 textfield_->SelectRange(ui::Range(length, length)); 287 textfield_->SelectRange(ui::Range(length, length));
280 OnAfterPossibleChange(); 288 OnAfterPossibleChange();
281 handled = true; 289 handled = true;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 } 452 }
445 453
446 void OmniboxViewViews::SetUserText(const string16& text) { 454 void OmniboxViewViews::SetUserText(const string16& text) {
447 SetUserText(text, text, true); 455 SetUserText(text, text, true);
448 } 456 }
449 457
450 void OmniboxViewViews::SetUserText(const string16& text, 458 void OmniboxViewViews::SetUserText(const string16& text,
451 const string16& display_text, 459 const string16& display_text,
452 bool update_popup) { 460 bool update_popup) {
453 model_->SetUserText(text); 461 model_->SetUserText(text);
454 SetWindowTextAndCaretPos(display_text, display_text.length()); 462 SetWindowTextAndCaretPos(display_text, display_text.length(), update_popup,
455 if (update_popup) 463 true);
456 UpdatePopup();
457 TextChanged();
458 } 464 }
459 465
460 void OmniboxViewViews::SetWindowTextAndCaretPos(const string16& text, 466 void OmniboxViewViews::SetWindowTextAndCaretPos(const string16& text,
461 size_t caret_pos) { 467 size_t caret_pos,
468 bool update_popup,
469 bool notify_text_changed) {
462 const ui::Range range(caret_pos, caret_pos); 470 const ui::Range range(caret_pos, caret_pos);
463 SetTextAndSelectedRange(text, range); 471 SetTextAndSelectedRange(text, range);
464 } 472 }
465 473
466 void OmniboxViewViews::SetForcedQuery() { 474 void OmniboxViewViews::SetForcedQuery() {
467 const string16 current_text(GetText()); 475 const string16 current_text(GetText());
468 const size_t start = current_text.find_first_not_of(kWhitespaceUTF16); 476 const size_t start = current_text.find_first_not_of(kWhitespaceUTF16);
469 if (start == string16::npos || (current_text[start] != '?')) 477 if (start == string16::npos || (current_text[start] != '?'))
470 SetUserText(ASCIIToUTF16("?")); 478 SetUserText(ASCIIToUTF16("?"));
471 else 479 else
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 // In views-implementation, the focus is on textfield rather than OmniboxView. 535 // In views-implementation, the focus is on textfield rather than OmniboxView.
528 textfield_->RequestFocus(); 536 textfield_->RequestFocus();
529 } 537 }
530 538
531 void OmniboxViewViews::OnTemporaryTextMaybeChanged( 539 void OmniboxViewViews::OnTemporaryTextMaybeChanged(
532 const string16& display_text, 540 const string16& display_text,
533 bool save_original_selection) { 541 bool save_original_selection) {
534 if (save_original_selection) 542 if (save_original_selection)
535 textfield_->GetSelectedRange(&saved_temporary_selection_); 543 textfield_->GetSelectedRange(&saved_temporary_selection_);
536 544
537 SetWindowTextAndCaretPos(display_text, display_text.length()); 545 SetWindowTextAndCaretPos(display_text, display_text.length(), false, true);
538 TextChanged();
539 } 546 }
540 547
541 bool OmniboxViewViews::OnInlineAutocompleteTextMaybeChanged( 548 bool OmniboxViewViews::OnInlineAutocompleteTextMaybeChanged(
542 const string16& display_text, 549 const string16& display_text,
543 size_t user_text_length) { 550 size_t user_text_length) {
544 if (display_text == GetText()) 551 if (display_text == GetText())
545 return false; 552 return false;
546 ui::Range range(display_text.size(), user_text_length); 553 ui::Range range(display_text.size(), user_text_length);
547 SetTextAndSelectedRange(display_text, range); 554 SetTextAndSelectedRange(display_text, range);
548 TextChanged(); 555 TextChanged();
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 OmniboxViewViews* omnibox_view = new OmniboxViewViews(controller, 852 OmniboxViewViews* omnibox_view = new OmniboxViewViews(controller,
846 toolbar_model, 853 toolbar_model,
847 profile, 854 profile,
848 command_updater, 855 command_updater,
849 popup_window_mode, 856 popup_window_mode,
850 location_bar); 857 location_bar);
851 omnibox_view->Init(); 858 omnibox_view->Init();
852 return omnibox_view; 859 return omnibox_view;
853 } 860 }
854 #endif 861 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698