Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_H_ |
| 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "chrome/browser/autocomplete/autocomplete_match.h" | 13 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 15 | 15 |
| 16 class AutocompleteInput; | 16 class AutocompleteInput; |
| 17 class AutocompleteProvider; | 17 class AutocompleteProvider; |
| 18 class Profile; | |
| 18 | 19 |
| 19 // All matches from all providers for a particular query. This also tracks | 20 // All matches from all providers for a particular query. This also tracks |
| 20 // what the default match should be if the user doesn't manually select another | 21 // what the default match should be if the user doesn't manually select another |
| 21 // match. | 22 // match. |
| 22 class AutocompleteResult { | 23 class AutocompleteResult { |
| 23 public: | 24 public: |
| 24 typedef ACMatches::const_iterator const_iterator; | 25 typedef ACMatches::const_iterator const_iterator; |
| 25 typedef ACMatches::iterator iterator; | 26 typedef ACMatches::iterator iterator; |
| 26 | 27 |
| 27 // The "Selection" struct is the information we need to select the same match | 28 // The "Selection" struct is the information we need to select the same match |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 | 65 |
| 65 AutocompleteResult(); | 66 AutocompleteResult(); |
| 66 ~AutocompleteResult(); | 67 ~AutocompleteResult(); |
| 67 | 68 |
| 68 // operator=() by another name. | 69 // operator=() by another name. |
| 69 void CopyFrom(const AutocompleteResult& rhs); | 70 void CopyFrom(const AutocompleteResult& rhs); |
| 70 | 71 |
| 71 // Copies matches from |old_matches| to provide a consistant result set. See | 72 // Copies matches from |old_matches| to provide a consistant result set. See |
| 72 // comments in code for specifics. | 73 // comments in code for specifics. |
| 73 void CopyOldMatches(const AutocompleteInput& input, | 74 void CopyOldMatches(const AutocompleteInput& input, |
| 74 const AutocompleteResult& old_matches); | 75 const AutocompleteResult& old_matches, |
| 76 Profile* profile); | |
|
Peter Kasting
2012/10/19 22:49:33
It doesn't really make sense to use a single Autoc
| |
| 75 | 77 |
| 76 // Adds a single match. The match is inserted at the appropriate position | 78 // Adds a single match. The match is inserted at the appropriate position |
| 77 // based on relevancy and display order. This is ONLY for use after | 79 // based on relevancy and display order. This is ONLY for use after |
| 78 // SortAndCull() has been invoked, and preserves default_match_. | 80 // SortAndCull() has been invoked, and preserves default_match_. |
| 79 void AddMatch(const AutocompleteMatch& match); | 81 void AddMatch(const AutocompleteMatch& match); |
| 80 | 82 |
| 81 // Adds a new set of matches to the result set. Does not re-sort. | 83 // Adds a new set of matches to the result set. Does not re-sort. |
| 82 void AppendMatches(const ACMatches& matches); | 84 void AppendMatches(const ACMatches& matches); |
| 83 | 85 |
| 84 // Removes duplicates, puts the list in sorted order and culls to leave only | 86 // Removes duplicates, puts the list in sorted order and culls to leave only |
| 85 // the best kMaxMatches matches. Sets the default match to the best match | 87 // the best kMaxMatches matches. Sets the default match to the best match |
| 86 // and updates the alternate nav URL. | 88 // and updates the alternate nav URL. |
| 87 void SortAndCull(const AutocompleteInput& input); | 89 void SortAndCull(const AutocompleteInput& input, Profile* profile); |
| 88 | 90 |
| 89 // Returns true if at least one match was copied from the last result. | 91 // Returns true if at least one match was copied from the last result. |
| 90 bool HasCopiedMatches() const; | 92 bool HasCopiedMatches() const; |
| 91 | 93 |
| 92 // Vector-style accessors/operators. | 94 // Vector-style accessors/operators. |
| 93 size_t size() const; | 95 size_t size() const; |
| 94 bool empty() const; | 96 bool empty() const; |
| 95 const_iterator begin() const; | 97 const_iterator begin() const; |
| 96 iterator begin(); | 98 iterator begin(); |
| 97 const_iterator end() const; | 99 const_iterator end() const; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 // user's local intranet contains site "foo", and the user types "foo", we | 153 // user's local intranet contains site "foo", and the user types "foo", we |
| 152 // default to searching for "foo" when the user may have meant to navigate | 154 // default to searching for "foo" when the user may have meant to navigate |
| 153 // there. In cases like this, the default match will point to the "search for | 155 // there. In cases like this, the default match will point to the "search for |
| 154 // 'foo'" result, and this will contain "http://foo/". | 156 // 'foo'" result, and this will contain "http://foo/". |
| 155 GURL alternate_nav_url_; | 157 GURL alternate_nav_url_; |
| 156 | 158 |
| 157 DISALLOW_COPY_AND_ASSIGN(AutocompleteResult); | 159 DISALLOW_COPY_AND_ASSIGN(AutocompleteResult); |
| 158 }; | 160 }; |
| 159 | 161 |
| 160 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_H_ | 162 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_H_ |
| OLD | NEW |