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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit_view_views.cc

Issue 5966006: Hitting Tab should always move cursor to end of omnibox text. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix AutocompleteEditViewViews. Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/autocomplete/autocomplete_edit_view_views.h" 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_views.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } else if (!handled && event.GetKeyCode() == ui::VKEY_UP) { 190 } else if (!handled && event.GetKeyCode() == ui::VKEY_UP) {
191 model_->OnUpOrDownKeyPressed(-1); 191 model_->OnUpOrDownKeyPressed(-1);
192 handled = true; 192 handled = true;
193 } else if (!handled && event.GetKeyCode() == ui::VKEY_DOWN) { 193 } else if (!handled && event.GetKeyCode() == ui::VKEY_DOWN) {
194 model_->OnUpOrDownKeyPressed(1); 194 model_->OnUpOrDownKeyPressed(1);
195 handled = true; 195 handled = true;
196 } else if (!handled && 196 } else if (!handled &&
197 event.GetKeyCode() == ui::VKEY_TAB && 197 event.GetKeyCode() == ui::VKEY_TAB &&
198 !event.IsShiftDown() && 198 !event.IsShiftDown() &&
199 !event.IsControlDown()) { 199 !event.IsControlDown()) {
200 if (model_->is_keyword_hint() && !model_->keyword().empty()) { 200 if (model_->is_keyword_hint()) {
201 model_->AcceptKeyword(); 201 handled = model_->AcceptKeyword();
202 handled = true;
203 } else { 202 } else {
203 string16::size_type start = 0;
204 string16::size_type end = 0;
205 size_t length = GetTextLength();
206 GetSelectionBounds(&start, &end);
207 if (start != end || start < length) {
208 OnBeforePossibleChange();
sky 2011/01/27 19:55:31 Same question about the need for OnBefore/after he
209 SelectRange(length, length);
210 OnAfterPossibleChange();
211 handled = true;
212 }
oshima 2011/01/27 21:17:44 instant is not working on views impl and i'd rathe
James Su 2011/01/27 21:55:53 Above code is nothing to do with instant support.
213
204 // TODO(Oshima): handle instant 214 // TODO(Oshima): handle instant
205 } 215 }
206 } 216 }
207 // TODO(oshima): page up & down 217 // TODO(oshima): page up & down
208 218
209 return handled; 219 return handled;
210 } 220 }
211 221
212 bool AutocompleteEditViewViews::HandleKeyReleaseEvent( 222 bool AutocompleteEditViewViews::HandleKeyReleaseEvent(
213 const views::KeyEvent& event) { 223 const views::KeyEvent& event) {
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 } 530 }
521 531
522 gfx::NativeView AutocompleteEditViewViews::GetNativeView() const { 532 gfx::NativeView AutocompleteEditViewViews::GetNativeView() const {
523 return GetWidget()->GetNativeView(); 533 return GetWidget()->GetNativeView();
524 } 534 }
525 535
526 CommandUpdater* AutocompleteEditViewViews::GetCommandUpdater() { 536 CommandUpdater* AutocompleteEditViewViews::GetCommandUpdater() {
527 return command_updater_; 537 return command_updater_;
528 } 538 }
529 539
530 views::View* AutocompleteEditViewViews::AddToView(views::View* parent) { 540 void AutocompleteEditViewViews::SetInstantSuggestion(const string16& input) {
531 parent->AddChildView(this); 541 NOTIMPLEMENTED();
532 AddChildView(textfield_); 542 }
533 return this; 543
544 string16 AutocompleteEditViewViews::GetInstantSuggestion() const {
545 NOTIMPLEMENTED();
546 return string16();
534 } 547 }
535 548
536 int AutocompleteEditViewViews::TextWidth() const { 549 int AutocompleteEditViewViews::TextWidth() const {
537 // TODO(oshima): add horizontal margin. 550 // TODO(oshima): add horizontal margin.
538 return textfield_->font().GetStringWidth(textfield_->text()); 551 return textfield_->font().GetStringWidth(textfield_->text());
539 } 552 }
540 553
541 bool AutocompleteEditViewViews::IsImeComposing() const { 554 bool AutocompleteEditViewViews::IsImeComposing() const {
542 return false; 555 return false;
543 } 556 }
544 557
545 bool AutocompleteEditViewViews::CommitInstantSuggestion( 558 views::View* AutocompleteEditViewViews::AddToView(views::View* parent) {
546 const string16& typed_text, 559 parent->AddChildView(this);
547 const string16& suggested_text) { 560 AddChildView(textfield_);
548 model_->FinalizeInstantQuery(typed_text, suggested_text); 561 return this;
549 return true;
550 }
551
552 void AutocompleteEditViewViews::SetInstantSuggestion(const string16& input) {
553 NOTIMPLEMENTED();
554 } 562 }
555 563
556 //////////////////////////////////////////////////////////////////////////////// 564 ////////////////////////////////////////////////////////////////////////////////
557 // AutocompleteEditViewViews, NotificationObserver implementation: 565 // AutocompleteEditViewViews, NotificationObserver implementation:
558 566
559 void AutocompleteEditViewViews::Observe(NotificationType type, 567 void AutocompleteEditViewViews::Observe(NotificationType type,
560 const NotificationSource& source, 568 const NotificationSource& source,
561 const NotificationDetails& details) { 569 const NotificationDetails& details) {
562 DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); 570 DCHECK(type == NotificationType::BROWSER_THEME_CHANGED);
563 SetBaseColor(); 571 SetBaseColor();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 636
629 string16 AutocompleteEditViewViews::GetSelectedText() const { 637 string16 AutocompleteEditViewViews::GetSelectedText() const {
630 // TODO(oshima): Support instant, IME. 638 // TODO(oshima): Support instant, IME.
631 return textfield_->GetSelectedText(); 639 return textfield_->GetSelectedText();
632 } 640 }
633 641
634 void AutocompleteEditViewViews::SelectRange(size_t caret, size_t end) { 642 void AutocompleteEditViewViews::SelectRange(size_t caret, size_t end) {
635 const views::TextRange range(caret, end); 643 const views::TextRange range(caret, end);
636 textfield_->SelectRange(range); 644 textfield_->SelectRange(range);
637 } 645 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698