OLD | NEW |
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 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 // A match that uses a non-default search engine (e.g. for tab-to-search). | 710 // A match that uses a non-default search engine (e.g. for tab-to-search). |
711 case AutocompleteMatch::SEARCH_OTHER_ENGINE: | 711 case AutocompleteMatch::SEARCH_OTHER_ENGINE: |
712 return true; | 712 return true; |
713 | 713 |
714 default: | 714 default: |
715 return false; | 715 return false; |
716 } | 716 } |
717 } | 717 } |
718 | 718 |
719 void AutocompleteEditModel::OnResultChanged(bool default_match_changed) { | 719 void AutocompleteEditModel::OnResultChanged(bool default_match_changed) { |
720 const bool was_open = popup_->view()->IsOpen(); | 720 const bool was_open = popup_->IsOpen(); |
721 if (default_match_changed) { | 721 if (default_match_changed) { |
722 string16 inline_autocomplete_text; | 722 string16 inline_autocomplete_text; |
723 string16 keyword; | 723 string16 keyword; |
724 bool is_keyword_hint = false; | 724 bool is_keyword_hint = false; |
725 const AutocompleteResult& result = this->result(); | 725 const AutocompleteResult& result = this->result(); |
726 const AutocompleteResult::const_iterator match(result.default_match()); | 726 const AutocompleteResult::const_iterator match(result.default_match()); |
727 if (match != result.end()) { | 727 if (match != result.end()) { |
728 if ((match->inline_autocomplete_offset != string16::npos) && | 728 if ((match->inline_autocomplete_offset != string16::npos) && |
729 (match->inline_autocomplete_offset < | 729 (match->inline_autocomplete_offset < |
730 match->fill_into_edit.length())) { | 730 match->fill_into_edit.length())) { |
(...skipping 13 matching lines...) Expand all Loading... |
744 | 744 |
745 is_keyword_hint = popup_->GetKeywordForMatch(*match, &keyword); | 745 is_keyword_hint = popup_->GetKeywordForMatch(*match, &keyword); |
746 } | 746 } |
747 popup_->OnResultChanged(); | 747 popup_->OnResultChanged(); |
748 OnPopupDataChanged(inline_autocomplete_text, NULL, keyword, | 748 OnPopupDataChanged(inline_autocomplete_text, NULL, keyword, |
749 is_keyword_hint); | 749 is_keyword_hint); |
750 } else { | 750 } else { |
751 popup_->OnResultChanged(); | 751 popup_->OnResultChanged(); |
752 } | 752 } |
753 | 753 |
754 if (popup_->view()->IsOpen()) { | 754 if (popup_->IsOpen()) { |
755 PopupBoundsChangedTo(popup_->view()->GetTargetBounds()); | 755 PopupBoundsChangedTo(popup_->view()->GetTargetBounds()); |
756 } else if (was_open) { | 756 } else if (was_open) { |
757 // Accepts the temporary text as the user text, because it makes little | 757 // Accepts the temporary text as the user text, because it makes little |
758 // sense to have temporary text when the popup is closed. | 758 // sense to have temporary text when the popup is closed. |
759 InternalSetUserText(UserTextFromDisplayText(view_->GetText())); | 759 InternalSetUserText(UserTextFromDisplayText(view_->GetText())); |
760 has_temporary_text_ = false; | 760 has_temporary_text_ = false; |
761 PopupBoundsChangedTo(gfx::Rect()); | 761 PopupBoundsChangedTo(gfx::Rect()); |
762 } | 762 } |
763 } | 763 } |
764 | 764 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 // static | 865 // static |
866 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { | 866 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { |
867 switch (c) { | 867 switch (c) { |
868 case 0x0020: // Space | 868 case 0x0020: // Space |
869 case 0x3000: // Ideographic Space | 869 case 0x3000: // Ideographic Space |
870 return true; | 870 return true; |
871 default: | 871 default: |
872 return false; | 872 return false; |
873 } | 873 } |
874 } | 874 } |
OLD | NEW |