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

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

Issue 8364001: Strip special characters in extension omnibox suggestions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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.h" 5 #include "chrome/browser/autocomplete/autocomplete.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 old_matches.BuildProviderToMatches(&old_matches_per_provider); 645 old_matches.BuildProviderToMatches(&old_matches_per_provider);
646 for (ProviderToMatches::const_iterator i = old_matches_per_provider.begin(); 646 for (ProviderToMatches::const_iterator i = old_matches_per_provider.begin();
647 i != old_matches_per_provider.end(); ++i) { 647 i != old_matches_per_provider.end(); ++i) {
648 MergeMatchesByProvider(i->second, matches_per_provider[i->first]); 648 MergeMatchesByProvider(i->second, matches_per_provider[i->first]);
649 } 649 }
650 650
651 SortAndCull(input); 651 SortAndCull(input);
652 } 652 }
653 653
654 void AutocompleteResult::AppendMatches(const ACMatches& matches) { 654 void AutocompleteResult::AppendMatches(const ACMatches& matches) {
655 #ifndef NDEBUG
656 for (size_t i = 0; i < matches.size(); i++) {
Peter Kasting 2011/10/25 20:37:07 Nit: This code tries to use iterators (begin() and
Alexei Svitkine (slow) 2011/10/25 21:37:16 Done.
657 DCHECK_EQ(AutocompleteMatch::SanitizeString(matches[i].contents),
Peter Kasting 2011/10/25 20:37:07 Nit: Here and below, we should also check the desc
Alexei Svitkine (slow) 2011/10/25 21:37:16 Done.
658 matches[i].contents);
659 }
660 #endif
655 std::copy(matches.begin(), matches.end(), std::back_inserter(matches_)); 661 std::copy(matches.begin(), matches.end(), std::back_inserter(matches_));
656 default_match_ = end(); 662 default_match_ = end();
657 alternate_nav_url_ = GURL(); 663 alternate_nav_url_ = GURL();
658 } 664 }
659 665
660 void AutocompleteResult::AddMatch(const AutocompleteMatch& match) { 666 void AutocompleteResult::AddMatch(const AutocompleteMatch& match) {
661 DCHECK(default_match_ != end()); 667 DCHECK(default_match_ != end());
668 // Check that there are no invalid characters in |match.contents|.
Peter Kasting 2011/10/25 20:37:07 Nit: Remove this comment, it's redundant with the
Alexei Svitkine (slow) 2011/10/25 21:37:16 Done.
669 DCHECK_EQ(AutocompleteMatch::SanitizeString(match.contents), match.contents);
662 ACMatches::iterator insertion_point = 670 ACMatches::iterator insertion_point =
663 std::upper_bound(begin(), end(), match, &AutocompleteMatch::MoreRelevant); 671 std::upper_bound(begin(), end(), match, &AutocompleteMatch::MoreRelevant);
664 ACMatches::iterator::difference_type default_offset = 672 ACMatches::iterator::difference_type default_offset =
665 default_match_ - begin(); 673 default_match_ - begin();
666 if ((insertion_point - begin()) <= default_offset) 674 if ((insertion_point - begin()) <= default_offset)
667 ++default_offset; 675 ++default_offset;
668 matches_.insert(insertion_point, match); 676 matches_.insert(insertion_point, match);
669 default_match_ = begin() + default_offset; 677 default_match_ = begin() + default_offset;
670 } 678 }
671 679
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 } 1051 }
1044 done_ = true; 1052 done_ = true;
1045 } 1053 }
1046 1054
1047 void AutocompleteController::StartExpireTimer() { 1055 void AutocompleteController::StartExpireTimer() {
1048 if (result_.HasCopiedMatches()) 1056 if (result_.HasCopiedMatches())
1049 expire_timer_.Start(FROM_HERE, 1057 expire_timer_.Start(FROM_HERE,
1050 base::TimeDelta::FromMilliseconds(kExpireTimeMS), 1058 base::TimeDelta::FromMilliseconds(kExpireTimeMS),
1051 this, &AutocompleteController::ExpireCopiedEntries); 1059 this, &AutocompleteController::ExpireCopiedEntries);
1052 } 1060 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autocomplete/autocomplete_match.h » ('j') | chrome/browser/autocomplete/autocomplete_match.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698