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_input.h" | 13 #include "chrome/browser/autocomplete/autocomplete_input.h" |
14 #include "chrome/browser/autocomplete/autocomplete_match.h" | 14 #include "chrome/browser/autocomplete/autocomplete_match.h" |
15 #include "components/metrics/proto/omnibox_event.pb.h" | |
15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
16 | 17 |
17 class AutocompleteInput; | 18 class AutocompleteInput; |
Mark P
2014/06/20 00:08:29
This isn't necessary if we're including autocomple
Jun Mukai
2014/06/20 00:29:51
Done.
| |
18 class AutocompleteProvider; | 19 class AutocompleteProvider; |
19 class Profile; | 20 class Profile; |
20 | 21 |
21 // All matches from all providers for a particular query. This also tracks | 22 // All matches from all providers for a particular query. This also tracks |
22 // what the default match should be if the user doesn't manually select another | 23 // what the default match should be if the user doesn't manually select another |
23 // match. | 24 // match. |
24 class AutocompleteResult { | 25 class AutocompleteResult { |
25 public: | 26 public: |
26 typedef ACMatches::const_iterator const_iterator; | 27 typedef ACMatches::const_iterator const_iterator; |
27 typedef ACMatches::iterator iterator; | 28 typedef ACMatches::iterator iterator; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 // |alternate_nav_url_|. | 144 // |alternate_nav_url_|. |
144 static GURL ComputeAlternateNavUrl(const AutocompleteInput& input, | 145 static GURL ComputeAlternateNavUrl(const AutocompleteInput& input, |
145 const AutocompleteMatch& match); | 146 const AutocompleteMatch& match); |
146 | 147 |
147 // Sort |matches| by destination, taking into account demotions based on | 148 // Sort |matches| by destination, taking into account demotions based on |
148 // |page_classification| when resolving ties about which of several | 149 // |page_classification| when resolving ties about which of several |
149 // duplicates to keep. The matches are also deduplicated. If | 150 // duplicates to keep. The matches are also deduplicated. If |
150 // |set_duplicate_matches| is true, the duplicate matches are stored in the | 151 // |set_duplicate_matches| is true, the duplicate matches are stored in the |
151 // |duplicate_matches| vector of the corresponding AutocompleteMatch. | 152 // |duplicate_matches| vector of the corresponding AutocompleteMatch. |
152 static void DedupMatchesByDestination( | 153 static void DedupMatchesByDestination( |
153 AutocompleteInput::PageClassification page_classification, | 154 metrics::OmniboxEventProto::PageClassification page_classification, |
154 bool set_duplicate_matches, | 155 bool set_duplicate_matches, |
155 ACMatches* matches); | 156 ACMatches* matches); |
156 | 157 |
157 private: | 158 private: |
158 friend class AutocompleteProviderTest; | 159 friend class AutocompleteProviderTest; |
159 | 160 |
160 typedef std::map<AutocompleteProvider*, ACMatches> ProviderToMatches; | 161 typedef std::map<AutocompleteProvider*, ACMatches> ProviderToMatches; |
161 | 162 |
162 #if defined(OS_ANDROID) | 163 #if defined(OS_ANDROID) |
163 // iterator::difference_type is not defined in the STL that we compile with on | 164 // iterator::difference_type is not defined in the STL that we compile with on |
(...skipping 10 matching lines...) Expand all Loading... | |
174 | 175 |
175 // operator=() by another name. | 176 // operator=() by another name. |
176 void CopyFrom(const AutocompleteResult& rhs); | 177 void CopyFrom(const AutocompleteResult& rhs); |
177 | 178 |
178 // Populates |provider_to_matches| from |matches_|. | 179 // Populates |provider_to_matches| from |matches_|. |
179 void BuildProviderToMatches(ProviderToMatches* provider_to_matches) const; | 180 void BuildProviderToMatches(ProviderToMatches* provider_to_matches) const; |
180 | 181 |
181 // Copies matches into this result. |old_matches| gives the matches from the | 182 // Copies matches into this result. |old_matches| gives the matches from the |
182 // last result, and |new_matches| the results from this result. | 183 // last result, and |new_matches| the results from this result. |
183 void MergeMatchesByProvider( | 184 void MergeMatchesByProvider( |
184 AutocompleteInput::PageClassification page_classification, | 185 metrics::OmniboxEventProto::PageClassification page_classification, |
185 const ACMatches& old_matches, | 186 const ACMatches& old_matches, |
186 const ACMatches& new_matches); | 187 const ACMatches& new_matches); |
187 | 188 |
188 ACMatches matches_; | 189 ACMatches matches_; |
189 | 190 |
190 const_iterator default_match_; | 191 const_iterator default_match_; |
191 | 192 |
192 // The "alternate navigation URL", if any, for this result set. This is a URL | 193 // The "alternate navigation URL", if any, for this result set. This is a URL |
193 // to try offering as a navigational option in case the user navigated to the | 194 // to try offering as a navigational option in case the user navigated to the |
194 // URL of the default match but intended something else. For example, if the | 195 // URL of the default match but intended something else. For example, if the |
195 // user's local intranet contains site "foo", and the user types "foo", we | 196 // user's local intranet contains site "foo", and the user types "foo", we |
196 // default to searching for "foo" when the user may have meant to navigate | 197 // default to searching for "foo" when the user may have meant to navigate |
197 // there. In cases like this, the default match will point to the "search for | 198 // there. In cases like this, the default match will point to the "search for |
198 // 'foo'" result, and this will contain "http://foo/". | 199 // 'foo'" result, and this will contain "http://foo/". |
199 GURL alternate_nav_url_; | 200 GURL alternate_nav_url_; |
200 | 201 |
201 DISALLOW_COPY_AND_ASSIGN(AutocompleteResult); | 202 DISALLOW_COPY_AND_ASSIGN(AutocompleteResult); |
202 }; | 203 }; |
203 | 204 |
204 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_H_ | 205 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_H_ |
OLD | NEW |