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

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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 if (model_->popup_model()->IsOpen()) 232 if (model_->popup_model()->IsOpen())
233 model_->popup_model()->TryDeletingCurrentItem(); 233 model_->popup_model()->TryDeletingCurrentItem();
234 } else if (!handled && event.key_code() == ui::VKEY_UP) { 234 } else if (!handled && event.key_code() == ui::VKEY_UP) {
235 model_->OnUpOrDownKeyPressed(-1); 235 model_->OnUpOrDownKeyPressed(-1);
236 handled = true; 236 handled = true;
237 } else if (!handled && event.key_code() == ui::VKEY_DOWN) { 237 } else if (!handled && event.key_code() == ui::VKEY_DOWN) {
238 model_->OnUpOrDownKeyPressed(1); 238 model_->OnUpOrDownKeyPressed(1);
239 handled = true; 239 handled = true;
240 } else if (!handled && 240 } else if (!handled &&
241 event.key_code() == ui::VKEY_TAB && 241 event.key_code() == ui::VKEY_TAB &&
242 !event.IsShiftDown() &&
243 !event.IsControlDown()) { 242 !event.IsControlDown()) {
244 if (model_->is_keyword_hint()) { 243 if (model_->is_keyword_hint() && !event.IsShiftDown()) {
245 handled = model_->AcceptKeyword(); 244 handled = model_->AcceptKeyword();
245 } else if (model_->popup_model()->IsOpen()) {
246 if (event.IsShiftDown() &&
247 model_->popup_model()->selected_line_state() ==
248 AutocompletePopupModel::KEYWORD) {
249 model_->ClearKeyword(GetText());
250 } else {
251 model_->OnUpOrDownKeyPressed(event.IsShiftDown() ? -1 : 1);
252 }
253 handled = true;
246 } else { 254 } else {
247 string16::size_type start = 0; 255 string16::size_type start = 0;
248 string16::size_type end = 0; 256 string16::size_type end = 0;
249 size_t length = GetTextLength(); 257 size_t length = GetTextLength();
250 GetSelectionBounds(&start, &end); 258 GetSelectionBounds(&start, &end);
251 if (start != end || start < length) { 259 if (start != end || start < length) {
252 OnBeforePossibleChange(); 260 OnBeforePossibleChange();
253 textfield_->SelectRange(ui::Range(length, length)); 261 textfield_->SelectRange(ui::Range(length, length));
254 OnAfterPossibleChange(); 262 OnAfterPossibleChange();
255 handled = true; 263 handled = true;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 } 426 }
419 427
420 void OmniboxViewViews::SetUserText(const string16& text) { 428 void OmniboxViewViews::SetUserText(const string16& text) {
421 SetUserText(text, text, true); 429 SetUserText(text, text, true);
422 } 430 }
423 431
424 void OmniboxViewViews::SetUserText(const string16& text, 432 void OmniboxViewViews::SetUserText(const string16& text,
425 const string16& display_text, 433 const string16& display_text,
426 bool update_popup) { 434 bool update_popup) {
427 model_->SetUserText(text); 435 model_->SetUserText(text);
428 SetWindowTextAndCaretPos(display_text, display_text.length()); 436 SetWindowTextAndCaretPos(display_text, display_text.length(), update_popup,
429 if (update_popup) 437 true);
430 UpdatePopup();
431 TextChanged();
432 } 438 }
433 439
434 void OmniboxViewViews::SetWindowTextAndCaretPos(const string16& text, 440 void OmniboxViewViews::SetWindowTextAndCaretPos(const string16& text,
435 size_t caret_pos) { 441 size_t caret_pos,
442 bool update_popup,
443 bool notify_text_changed) {
436 const ui::Range range(caret_pos, caret_pos); 444 const ui::Range range(caret_pos, caret_pos);
437 SetTextAndSelectedRange(text, range); 445 SetTextAndSelectedRange(text, range);
438 } 446 }
439 447
440 void OmniboxViewViews::SetForcedQuery() { 448 void OmniboxViewViews::SetForcedQuery() {
441 const string16 current_text(GetText()); 449 const string16 current_text(GetText());
442 const size_t start = current_text.find_first_not_of(kWhitespaceUTF16); 450 const size_t start = current_text.find_first_not_of(kWhitespaceUTF16);
443 if (start == string16::npos || (current_text[start] != '?')) 451 if (start == string16::npos || (current_text[start] != '?'))
444 SetUserText(ASCIIToUTF16("?")); 452 SetUserText(ASCIIToUTF16("?"));
445 else 453 else
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 // In views-implementation, the focus is on textfield rather than OmniboxView. 509 // In views-implementation, the focus is on textfield rather than OmniboxView.
502 textfield_->RequestFocus(); 510 textfield_->RequestFocus();
503 } 511 }
504 512
505 void OmniboxViewViews::OnTemporaryTextMaybeChanged( 513 void OmniboxViewViews::OnTemporaryTextMaybeChanged(
506 const string16& display_text, 514 const string16& display_text,
507 bool save_original_selection) { 515 bool save_original_selection) {
508 if (save_original_selection) 516 if (save_original_selection)
509 textfield_->GetSelectedRange(&saved_temporary_selection_); 517 textfield_->GetSelectedRange(&saved_temporary_selection_);
510 518
511 SetWindowTextAndCaretPos(display_text, display_text.length()); 519 SetWindowTextAndCaretPos(display_text, display_text.length(), false, true);
512 TextChanged();
513 } 520 }
514 521
515 bool OmniboxViewViews::OnInlineAutocompleteTextMaybeChanged( 522 bool OmniboxViewViews::OnInlineAutocompleteTextMaybeChanged(
516 const string16& display_text, 523 const string16& display_text,
517 size_t user_text_length) { 524 size_t user_text_length) {
518 if (display_text == GetText()) 525 if (display_text == GetText())
519 return false; 526 return false;
520 ui::Range range(display_text.size(), user_text_length); 527 ui::Range range(display_text.size(), user_text_length);
521 SetTextAndSelectedRange(display_text, range); 528 SetTextAndSelectedRange(display_text, range);
522 TextChanged(); 529 TextChanged();
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 OmniboxViewViews* omnibox_view = new OmniboxViewViews(controller, 817 OmniboxViewViews* omnibox_view = new OmniboxViewViews(controller,
811 toolbar_model, 818 toolbar_model,
812 profile, 819 profile,
813 command_updater, 820 command_updater,
814 popup_window_mode, 821 popup_window_mode,
815 location_bar); 822 location_bar);
816 omnibox_view->Init(); 823 omnibox_view->Init();
817 return omnibox_view; 824 return omnibox_view;
818 } 825 }
819 #endif 826 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698