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

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

Issue 6380012: Fix a CHECK failure in AutocompletePopupModel::InfoForCurrentSelection(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Correct solution. Created 9 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) 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.h" 5 #include "chrome/browser/autocomplete/autocomplete_edit.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 NotificationService::current()->Notify( 472 NotificationService::current()->Notify(
473 NotificationType::AUTOCOMPLETE_EDIT_FOCUSED, 473 NotificationType::AUTOCOMPLETE_EDIT_FOCUSED,
474 Source<AutocompleteEditModel>(this), 474 Source<AutocompleteEditModel>(this),
475 NotificationService::NoDetails()); 475 NotificationService::NoDetails());
476 } 476 }
477 477
478 void AutocompleteEditModel::OnKillFocus() { 478 void AutocompleteEditModel::OnKillFocus() {
479 has_focus_ = false; 479 has_focus_ = false;
480 control_key_state_ = UP; 480 control_key_state_ = UP;
481 paste_state_ = NONE; 481 paste_state_ = NONE;
482
483 // Like typing, killing focus "accepts" the temporary text as the user
484 // text, because it makes little sense to have temporary text when the
485 // popup is closed.
486 InternalSetUserText(UserTextFromDisplayText(view_->GetText()));
487 has_temporary_text_ = false;
488 } 482 }
489 483
490 bool AutocompleteEditModel::OnEscapeKeyPressed() { 484 bool AutocompleteEditModel::OnEscapeKeyPressed() {
491 if (has_temporary_text_) { 485 if (has_temporary_text_) {
492 AutocompleteMatch match; 486 AutocompleteMatch match;
493 popup_->InfoForCurrentSelection(&match, NULL); 487 popup_->InfoForCurrentSelection(&match, NULL);
494 if (match.destination_url != original_url_) { 488 if (match.destination_url != original_url_) {
495 // The user typed something, then selected a different item. Restore the 489 // The user typed something, then selected a different item. Restore the
496 // text they typed and change back to the default item. 490 // text they typed and change back to the default item.
497 // NOTE: This purposefully does not reset paste_state_. 491 // NOTE: This purposefully does not reset paste_state_.
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 } 667 }
674 668
675 view_->UpdatePopup(); 669 view_->UpdatePopup();
676 return true; 670 return true;
677 } 671 }
678 672
679 void AutocompleteEditModel::PopupBoundsChangedTo(const gfx::Rect& bounds) { 673 void AutocompleteEditModel::PopupBoundsChangedTo(const gfx::Rect& bounds) {
680 controller_->OnPopupBoundsChanged(bounds); 674 controller_->OnPopupBoundsChanged(bounds);
681 } 675 }
682 676
677 void AutocompleteEditModel::OnPopupClosed() {
678 // Accepts the temporary text as the user text, because it makes little
679 // sense to have temporary text when the popup is closed.
680 InternalSetUserText(UserTextFromDisplayText(view_->GetText()));
681 has_temporary_text_ = false;
682 }
683
683 // Return true if the suggestion type warrants a TCP/IP preconnection. 684 // Return true if the suggestion type warrants a TCP/IP preconnection.
684 // i.e., it is now highly likely that the user will select the related domain. 685 // i.e., it is now highly likely that the user will select the related domain.
685 static bool IsPreconnectable(AutocompleteMatch::Type type) { 686 static bool IsPreconnectable(AutocompleteMatch::Type type) {
686 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", type, 687 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", type,
687 AutocompleteMatch::NUM_TYPES); 688 AutocompleteMatch::NUM_TYPES);
688 switch (type) { 689 switch (type) {
689 // Matches using the user's default search engine. 690 // Matches using the user's default search engine.
690 case AutocompleteMatch::SEARCH_WHAT_YOU_TYPED: 691 case AutocompleteMatch::SEARCH_WHAT_YOU_TYPED:
691 case AutocompleteMatch::SEARCH_HISTORY: 692 case AutocompleteMatch::SEARCH_HISTORY:
692 case AutocompleteMatch::SEARCH_SUGGEST: 693 case AutocompleteMatch::SEARCH_SUGGEST:
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 // static 794 // static
794 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { 795 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) {
795 switch (c) { 796 switch (c) {
796 case 0x0020: // Space 797 case 0x0020: // Space
797 case 0x3000: // Ideographic Space 798 case 0x3000: // Ideographic Space
798 return true; 799 return true;
799 default: 800 default:
800 return false; 801 return false;
801 } 802 }
802 } 803 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698