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 AutocompleteProvider; | 18 class AutocompleteProvider; |
19 class Profile; | 19 class Profile; |
20 | 20 |
21 // All matches from all providers for a particular query. This also tracks | 21 // 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 | 22 // what the default match should be if the user doesn't manually select another |
23 // match. | 23 // match. |
24 class AutocompleteResult { | 24 class AutocompleteResult { |
25 public: | 25 public: |
26 typedef ACMatches::const_iterator const_iterator; | 26 typedef ACMatches::const_iterator const_iterator; |
27 typedef ACMatches::iterator iterator; | 27 typedef ACMatches::iterator iterator; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // |alternate_nav_url_|. | 143 // |alternate_nav_url_|. |
144 static GURL ComputeAlternateNavUrl(const AutocompleteInput& input, | 144 static GURL ComputeAlternateNavUrl(const AutocompleteInput& input, |
145 const AutocompleteMatch& match); | 145 const AutocompleteMatch& match); |
146 | 146 |
147 // Sort |matches| by destination, taking into account demotions based on | 147 // Sort |matches| by destination, taking into account demotions based on |
148 // |page_classification| when resolving ties about which of several | 148 // |page_classification| when resolving ties about which of several |
149 // duplicates to keep. The matches are also deduplicated. If | 149 // duplicates to keep. The matches are also deduplicated. If |
150 // |set_duplicate_matches| is true, the duplicate matches are stored in the | 150 // |set_duplicate_matches| is true, the duplicate matches are stored in the |
151 // |duplicate_matches| vector of the corresponding AutocompleteMatch. | 151 // |duplicate_matches| vector of the corresponding AutocompleteMatch. |
152 static void DedupMatchesByDestination( | 152 static void DedupMatchesByDestination( |
153 AutocompleteInput::PageClassification page_classification, | 153 metrics::OmniboxEventProto::PageClassification page_classification, |
154 bool set_duplicate_matches, | 154 bool set_duplicate_matches, |
155 ACMatches* matches); | 155 ACMatches* matches); |
156 | 156 |
157 private: | 157 private: |
158 friend class AutocompleteProviderTest; | 158 friend class AutocompleteProviderTest; |
159 | 159 |
160 typedef std::map<AutocompleteProvider*, ACMatches> ProviderToMatches; | 160 typedef std::map<AutocompleteProvider*, ACMatches> ProviderToMatches; |
161 | 161 |
162 #if defined(OS_ANDROID) | 162 #if defined(OS_ANDROID) |
163 // iterator::difference_type is not defined in the STL that we compile with on | 163 // iterator::difference_type is not defined in the STL that we compile with on |
(...skipping 10 matching lines...) Expand all Loading... |
174 | 174 |
175 // operator=() by another name. | 175 // operator=() by another name. |
176 void CopyFrom(const AutocompleteResult& rhs); | 176 void CopyFrom(const AutocompleteResult& rhs); |
177 | 177 |
178 // Populates |provider_to_matches| from |matches_|. | 178 // Populates |provider_to_matches| from |matches_|. |
179 void BuildProviderToMatches(ProviderToMatches* provider_to_matches) const; | 179 void BuildProviderToMatches(ProviderToMatches* provider_to_matches) const; |
180 | 180 |
181 // Copies matches into this result. |old_matches| gives the matches from the | 181 // Copies matches into this result. |old_matches| gives the matches from the |
182 // last result, and |new_matches| the results from this result. | 182 // last result, and |new_matches| the results from this result. |
183 void MergeMatchesByProvider( | 183 void MergeMatchesByProvider( |
184 AutocompleteInput::PageClassification page_classification, | 184 metrics::OmniboxEventProto::PageClassification page_classification, |
185 const ACMatches& old_matches, | 185 const ACMatches& old_matches, |
186 const ACMatches& new_matches); | 186 const ACMatches& new_matches); |
187 | 187 |
188 ACMatches matches_; | 188 ACMatches matches_; |
189 | 189 |
190 const_iterator default_match_; | 190 const_iterator default_match_; |
191 | 191 |
192 // The "alternate navigation URL", if any, for this result set. This is a URL | 192 // 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 | 193 // 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 | 194 // 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 | 195 // 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 | 196 // 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 | 197 // there. In cases like this, the default match will point to the "search for |
198 // 'foo'" result, and this will contain "http://foo/". | 198 // 'foo'" result, and this will contain "http://foo/". |
199 GURL alternate_nav_url_; | 199 GURL alternate_nav_url_; |
200 | 200 |
201 DISALLOW_COPY_AND_ASSIGN(AutocompleteResult); | 201 DISALLOW_COPY_AND_ASSIGN(AutocompleteResult); |
202 }; | 202 }; |
203 | 203 |
204 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_H_ | 204 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_H_ |
OLD | NEW |