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

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

Issue 9419043: Revert 122412 - Enabled pressing TAB to traverse through the Omnibox results (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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 if (model_->popup_model()->IsOpen()) 248 if (model_->popup_model()->IsOpen())
249 model_->popup_model()->TryDeletingCurrentItem(); 249 model_->popup_model()->TryDeletingCurrentItem();
250 } else if (!handled && event.key_code() == ui::VKEY_UP) { 250 } else if (!handled && event.key_code() == ui::VKEY_UP) {
251 model_->OnUpOrDownKeyPressed(-1); 251 model_->OnUpOrDownKeyPressed(-1);
252 handled = true; 252 handled = true;
253 } else if (!handled && event.key_code() == ui::VKEY_DOWN) { 253 } else if (!handled && event.key_code() == ui::VKEY_DOWN) {
254 model_->OnUpOrDownKeyPressed(1); 254 model_->OnUpOrDownKeyPressed(1);
255 handled = true; 255 handled = true;
256 } else if (!handled && 256 } else if (!handled &&
257 event.key_code() == ui::VKEY_TAB && 257 event.key_code() == ui::VKEY_TAB &&
258 !event.IsShiftDown() &&
258 !event.IsControlDown()) { 259 !event.IsControlDown()) {
259 if (model_->is_keyword_hint() && !event.IsShiftDown()) { 260 if (model_->is_keyword_hint()) {
260 handled = model_->AcceptKeyword(); 261 handled = model_->AcceptKeyword();
261 } else if (model_->popup_model()->IsOpen()) {
262 if (event.IsShiftDown() &&
263 model_->popup_model()->selected_line_state() ==
264 AutocompletePopupModel::KEYWORD) {
265 model_->ClearKeyword(GetText());
266 } else {
267 model_->OnUpOrDownKeyPressed(event.IsShiftDown() ? -1 : 1);
268 }
269 handled = true;
270 } else { 262 } else {
271 string16::size_type start = 0; 263 string16::size_type start = 0;
272 string16::size_type end = 0; 264 string16::size_type end = 0;
273 size_t length = GetTextLength(); 265 size_t length = GetTextLength();
274 GetSelectionBounds(&start, &end); 266 GetSelectionBounds(&start, &end);
275 if (start != end || start < length) { 267 if (start != end || start < length) {
276 OnBeforePossibleChange(); 268 OnBeforePossibleChange();
277 textfield_->SelectRange(ui::Range(length, length)); 269 textfield_->SelectRange(ui::Range(length, length));
278 OnAfterPossibleChange(); 270 OnAfterPossibleChange();
279 handled = true; 271 handled = true;
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 } 442 }
451 443
452 void OmniboxViewViews::SetUserText(const string16& text) { 444 void OmniboxViewViews::SetUserText(const string16& text) {
453 SetUserText(text, text, true); 445 SetUserText(text, text, true);
454 } 446 }
455 447
456 void OmniboxViewViews::SetUserText(const string16& text, 448 void OmniboxViewViews::SetUserText(const string16& text,
457 const string16& display_text, 449 const string16& display_text,
458 bool update_popup) { 450 bool update_popup) {
459 model_->SetUserText(text); 451 model_->SetUserText(text);
460 SetWindowTextAndCaretPos(display_text, display_text.length(), update_popup, 452 SetWindowTextAndCaretPos(display_text, display_text.length());
461 true); 453 if (update_popup)
454 UpdatePopup();
455 TextChanged();
462 } 456 }
463 457
464 void OmniboxViewViews::SetWindowTextAndCaretPos(const string16& text, 458 void OmniboxViewViews::SetWindowTextAndCaretPos(const string16& text,
465 size_t caret_pos, 459 size_t caret_pos) {
466 bool update_popup,
467 bool notify_text_changed) {
468 const ui::Range range(caret_pos, caret_pos); 460 const ui::Range range(caret_pos, caret_pos);
469 SetTextAndSelectedRange(text, range); 461 SetTextAndSelectedRange(text, range);
470 } 462 }
471 463
472 void OmniboxViewViews::SetForcedQuery() { 464 void OmniboxViewViews::SetForcedQuery() {
473 const string16 current_text(GetText()); 465 const string16 current_text(GetText());
474 const size_t start = current_text.find_first_not_of(kWhitespaceUTF16); 466 const size_t start = current_text.find_first_not_of(kWhitespaceUTF16);
475 if (start == string16::npos || (current_text[start] != '?')) 467 if (start == string16::npos || (current_text[start] != '?'))
476 SetUserText(ASCIIToUTF16("?")); 468 SetUserText(ASCIIToUTF16("?"));
477 else 469 else
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 // In views-implementation, the focus is on textfield rather than OmniboxView. 525 // In views-implementation, the focus is on textfield rather than OmniboxView.
534 textfield_->RequestFocus(); 526 textfield_->RequestFocus();
535 } 527 }
536 528
537 void OmniboxViewViews::OnTemporaryTextMaybeChanged( 529 void OmniboxViewViews::OnTemporaryTextMaybeChanged(
538 const string16& display_text, 530 const string16& display_text,
539 bool save_original_selection) { 531 bool save_original_selection) {
540 if (save_original_selection) 532 if (save_original_selection)
541 textfield_->GetSelectedRange(&saved_temporary_selection_); 533 textfield_->GetSelectedRange(&saved_temporary_selection_);
542 534
543 SetWindowTextAndCaretPos(display_text, display_text.length(), false, true); 535 SetWindowTextAndCaretPos(display_text, display_text.length());
536 TextChanged();
544 } 537 }
545 538
546 bool OmniboxViewViews::OnInlineAutocompleteTextMaybeChanged( 539 bool OmniboxViewViews::OnInlineAutocompleteTextMaybeChanged(
547 const string16& display_text, 540 const string16& display_text,
548 size_t user_text_length) { 541 size_t user_text_length) {
549 if (display_text == GetText()) 542 if (display_text == GetText())
550 return false; 543 return false;
551 ui::Range range(display_text.size(), user_text_length); 544 ui::Range range(display_text.size(), user_text_length);
552 SetTextAndSelectedRange(display_text, range); 545 SetTextAndSelectedRange(display_text, range);
553 TextChanged(); 546 TextChanged();
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 OmniboxViewViews* omnibox_view = new OmniboxViewViews(controller, 831 OmniboxViewViews* omnibox_view = new OmniboxViewViews(controller,
839 toolbar_model, 832 toolbar_model,
840 profile, 833 profile,
841 command_updater, 834 command_updater,
842 popup_window_mode, 835 popup_window_mode,
843 location_bar); 836 location_bar);
844 omnibox_view->Init(); 837 omnibox_view->Init();
845 return omnibox_view; 838 return omnibox_view;
846 } 839 }
847 #endif 840 #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