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

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

Issue 9310017: Revert 120005 - Enabled pressing TAB to traverse through the Omnibox results, removed moving the ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 if (model_->popup_model()->IsOpen()) 257 if (model_->popup_model()->IsOpen())
258 model_->popup_model()->TryDeletingCurrentItem(); 258 model_->popup_model()->TryDeletingCurrentItem();
259 } else if (!handled && event.key_code() == ui::VKEY_UP) { 259 } else if (!handled && event.key_code() == ui::VKEY_UP) {
260 model_->OnUpOrDownKeyPressed(-1); 260 model_->OnUpOrDownKeyPressed(-1);
261 handled = true; 261 handled = true;
262 } else if (!handled && event.key_code() == ui::VKEY_DOWN) { 262 } else if (!handled && event.key_code() == ui::VKEY_DOWN) {
263 model_->OnUpOrDownKeyPressed(1); 263 model_->OnUpOrDownKeyPressed(1);
264 handled = true; 264 handled = true;
265 } else if (!handled && 265 } else if (!handled &&
266 event.key_code() == ui::VKEY_TAB && 266 event.key_code() == ui::VKEY_TAB &&
267 !event.IsShiftDown() &&
267 !event.IsControlDown()) { 268 !event.IsControlDown()) {
268 if (model_->is_keyword_hint() && !event.IsShiftDown()) { 269 if (model_->is_keyword_hint()) {
269 handled = model_->AcceptKeyword(); 270 handled = model_->AcceptKeyword();
270 } else if (model_->popup_model()->IsOpen()) {
271 if (event.IsShiftDown() &&
272 model_->popup_model()->selected_line_state() ==
273 AutocompletePopupModel::KEYWORD) {
274 model_->ClearKeyword(GetText());
275 } else {
276 model_->OnUpOrDownKeyPressed(event.IsShiftDown() ? -1 : 1);
277 }
278 handled = true;
279 } else { 271 } else {
280 string16::size_type start = 0; 272 string16::size_type start = 0;
281 string16::size_type end = 0; 273 string16::size_type end = 0;
282 size_t length = GetTextLength(); 274 size_t length = GetTextLength();
283 GetSelectionBounds(&start, &end); 275 GetSelectionBounds(&start, &end);
284 if (start != end || start < length) { 276 if (start != end || start < length) {
285 OnBeforePossibleChange(); 277 OnBeforePossibleChange();
286 textfield_->SelectRange(ui::Range(length, length)); 278 textfield_->SelectRange(ui::Range(length, length));
287 OnAfterPossibleChange(); 279 OnAfterPossibleChange();
288 handled = true; 280 handled = true;
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 } 454 }
463 455
464 void OmniboxViewViews::SetUserText(const string16& text) { 456 void OmniboxViewViews::SetUserText(const string16& text) {
465 SetUserText(text, text, true); 457 SetUserText(text, text, true);
466 } 458 }
467 459
468 void OmniboxViewViews::SetUserText(const string16& text, 460 void OmniboxViewViews::SetUserText(const string16& text,
469 const string16& display_text, 461 const string16& display_text,
470 bool update_popup) { 462 bool update_popup) {
471 model_->SetUserText(text); 463 model_->SetUserText(text);
472 SetWindowTextAndCaretPos(display_text, display_text.length(), update_popup, 464 SetWindowTextAndCaretPos(display_text, display_text.length());
473 true); 465 if (update_popup)
466 UpdatePopup();
467 TextChanged();
474 } 468 }
475 469
476 void OmniboxViewViews::SetWindowTextAndCaretPos(const string16& text, 470 void OmniboxViewViews::SetWindowTextAndCaretPos(const string16& text,
477 size_t caret_pos, 471 size_t caret_pos) {
478 bool update_popup,
479 bool notify_text_changed) {
480 const ui::Range range(caret_pos, caret_pos); 472 const ui::Range range(caret_pos, caret_pos);
481 SetTextAndSelectedRange(text, range); 473 SetTextAndSelectedRange(text, range);
482 } 474 }
483 475
484 void OmniboxViewViews::SetForcedQuery() { 476 void OmniboxViewViews::SetForcedQuery() {
485 const string16 current_text(GetText()); 477 const string16 current_text(GetText());
486 const size_t start = current_text.find_first_not_of(kWhitespaceUTF16); 478 const size_t start = current_text.find_first_not_of(kWhitespaceUTF16);
487 if (start == string16::npos || (current_text[start] != '?')) 479 if (start == string16::npos || (current_text[start] != '?'))
488 SetUserText(ASCIIToUTF16("?")); 480 SetUserText(ASCIIToUTF16("?"));
489 else 481 else
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 // In views-implementation, the focus is on textfield rather than OmniboxView. 537 // In views-implementation, the focus is on textfield rather than OmniboxView.
546 textfield_->RequestFocus(); 538 textfield_->RequestFocus();
547 } 539 }
548 540
549 void OmniboxViewViews::OnTemporaryTextMaybeChanged( 541 void OmniboxViewViews::OnTemporaryTextMaybeChanged(
550 const string16& display_text, 542 const string16& display_text,
551 bool save_original_selection) { 543 bool save_original_selection) {
552 if (save_original_selection) 544 if (save_original_selection)
553 textfield_->GetSelectedRange(&saved_temporary_selection_); 545 textfield_->GetSelectedRange(&saved_temporary_selection_);
554 546
555 SetWindowTextAndCaretPos(display_text, display_text.length(), false, true); 547 SetWindowTextAndCaretPos(display_text, display_text.length());
548 TextChanged();
556 } 549 }
557 550
558 bool OmniboxViewViews::OnInlineAutocompleteTextMaybeChanged( 551 bool OmniboxViewViews::OnInlineAutocompleteTextMaybeChanged(
559 const string16& display_text, 552 const string16& display_text,
560 size_t user_text_length) { 553 size_t user_text_length) {
561 if (display_text == GetText()) 554 if (display_text == GetText())
562 return false; 555 return false;
563 ui::Range range(display_text.size(), user_text_length); 556 ui::Range range(display_text.size(), user_text_length);
564 SetTextAndSelectedRange(display_text, range); 557 SetTextAndSelectedRange(display_text, range);
565 TextChanged(); 558 TextChanged();
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 OmniboxViewViews* omnibox_view = new OmniboxViewViews(controller, 853 OmniboxViewViews* omnibox_view = new OmniboxViewViews(controller,
861 toolbar_model, 854 toolbar_model,
862 profile, 855 profile,
863 command_updater, 856 command_updater,
864 popup_window_mode, 857 popup_window_mode,
865 location_bar); 858 location_bar);
866 omnibox_view->Init(); 859 omnibox_view->Init();
867 return omnibox_view; 860 return omnibox_view;
868 } 861 }
869 #endif 862 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.h ('k') | chrome/browser/ui/views/omnibox/omnibox_view_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698