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 COMPONENTS_OMNIBOX_BROWSER_HISTORY_URL_PROVIDER_H_ | 5 #ifndef COMPONENTS_OMNIBOX_BROWSER_HISTORY_URL_PROVIDER_H_ |
6 #define COMPONENTS_OMNIBOX_BROWSER_HISTORY_URL_PROVIDER_H_ | 6 #define COMPONENTS_OMNIBOX_BROWSER_HISTORY_URL_PROVIDER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // See comments on |promote_type| below. | 96 // See comments on |promote_type| below. |
97 enum PromoteType { | 97 enum PromoteType { |
98 WHAT_YOU_TYPED_MATCH, | 98 WHAT_YOU_TYPED_MATCH, |
99 FRONT_HISTORY_MATCH, | 99 FRONT_HISTORY_MATCH, |
100 NEITHER, | 100 NEITHER, |
101 }; | 101 }; |
102 | 102 |
103 HistoryURLProviderParams(const AutocompleteInput& input, | 103 HistoryURLProviderParams(const AutocompleteInput& input, |
104 bool trim_http, | 104 bool trim_http, |
105 const AutocompleteMatch& what_you_typed_match, | 105 const AutocompleteMatch& what_you_typed_match, |
106 const std::string& languages, | |
107 TemplateURL* default_search_provider, | 106 TemplateURL* default_search_provider, |
108 const SearchTermsData& search_terms_data); | 107 const SearchTermsData& search_terms_data); |
109 ~HistoryURLProviderParams(); | 108 ~HistoryURLProviderParams(); |
110 | 109 |
111 base::MessageLoop* message_loop; | 110 base::MessageLoop* message_loop; |
112 | 111 |
113 // A copy of the autocomplete input. We need the copy since this object will | 112 // A copy of the autocomplete input. We need the copy since this object will |
114 // live beyond the original query while it runs on the history thread. | 113 // live beyond the original query while it runs on the history thread. |
115 AutocompleteInput input; | 114 AutocompleteInput input; |
116 | 115 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // | 158 // |
160 // NOTE: The second pass of DoAutocomplete() checks what the first pass set | 159 // NOTE: The second pass of DoAutocomplete() checks what the first pass set |
161 // this to. See comments in DoAutocomplete(). | 160 // this to. See comments in DoAutocomplete(). |
162 PromoteType promote_type; | 161 PromoteType promote_type; |
163 | 162 |
164 // True if |what_you_typed_match| is eligible for display. If this is true, | 163 // True if |what_you_typed_match| is eligible for display. If this is true, |
165 // PromoteMatchesIfNecessary() may choose to place |what_you_typed_match| on | 164 // PromoteMatchesIfNecessary() may choose to place |what_you_typed_match| on |
166 // |matches_| even when |promote_type| is not WHAT_YOU_TYPED_MATCH. | 165 // |matches_| even when |promote_type| is not WHAT_YOU_TYPED_MATCH. |
167 bool have_what_you_typed_match; | 166 bool have_what_you_typed_match; |
168 | 167 |
169 // Languages we should pass to gfx::GetCleanStringFromUrl. | |
170 std::string languages; | |
171 | |
172 // The default search provider and search terms data necessary to cull results | 168 // The default search provider and search terms data necessary to cull results |
173 // that correspond to searches (on the default engine). These can only be | 169 // that correspond to searches (on the default engine). These can only be |
174 // obtained on the UI thread, so we have to copy them into here to pass them | 170 // obtained on the UI thread, so we have to copy them into here to pass them |
175 // to the history thread. We use a scoped_ptr<TemplateURL> for the DSP since | 171 // to the history thread. We use a scoped_ptr<TemplateURL> for the DSP since |
176 // TemplateURLs can't be copied by value. We use a scoped_ptr<SearchTermsData> | 172 // TemplateURLs can't be copied by value. We use a scoped_ptr<SearchTermsData> |
177 // so that we can store a snapshot of the SearchTermsData accessible from the | 173 // so that we can store a snapshot of the SearchTermsData accessible from the |
178 // history thread. | 174 // history thread. |
179 scoped_ptr<TemplateURL> default_search_provider; | 175 scoped_ptr<TemplateURL> default_search_provider; |
180 scoped_ptr<SearchTermsData> search_terms_data; | 176 scoped_ptr<SearchTermsData> search_terms_data; |
181 | 177 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 size_t source_index, | 314 size_t source_index, |
319 const std::vector<GURL>& remove) const; | 315 const std::vector<GURL>& remove) const; |
320 | 316 |
321 // Converts a specified |match_number| from params.matches into an | 317 // Converts a specified |match_number| from params.matches into an |
322 // autocomplete match for display. If experimental scoring is enabled, the | 318 // autocomplete match for display. If experimental scoring is enabled, the |
323 // final relevance score might be different from the given |relevance|. | 319 // final relevance score might be different from the given |relevance|. |
324 // NOTE: This function should only be called on the UI thread. | 320 // NOTE: This function should only be called on the UI thread. |
325 AutocompleteMatch HistoryMatchToACMatch( | 321 AutocompleteMatch HistoryMatchToACMatch( |
326 const HistoryURLProviderParams& params, | 322 const HistoryURLProviderParams& params, |
327 size_t match_number, | 323 size_t match_number, |
328 MatchType match_type, | |
329 int relevance); | 324 int relevance); |
330 | 325 |
331 AutocompleteProviderListener* listener_; | 326 AutocompleteProviderListener* listener_; |
332 | 327 |
333 // Params for the current query. The provider should not free this directly; | 328 // Params for the current query. The provider should not free this directly; |
334 // instead, it is passed as a parameter through the history backend, and the | 329 // instead, it is passed as a parameter through the history backend, and the |
335 // parameter itself is freed once it's no longer needed. The only reason we | 330 // parameter itself is freed once it's no longer needed. The only reason we |
336 // keep this member is so we can set the cancel bit on it. | 331 // keep this member is so we can set the cancel bit on it. |
337 HistoryURLProviderParams* params_; | 332 HistoryURLProviderParams* params_; |
338 | 333 |
339 // Whether to query the history URL database to match. Even if false, we | 334 // Whether to query the history URL database to match. Even if false, we |
340 // still use the URL database to decide if the URL-what-you-typed was visited | 335 // still use the URL database to decide if the URL-what-you-typed was visited |
341 // before or not. If false, the only possible result that HistoryURL provider | 336 // before or not. If false, the only possible result that HistoryURL provider |
342 // can return is URL-what-you-typed. This variable is not part of params_ | 337 // can return is URL-what-you-typed. This variable is not part of params_ |
343 // because it never changes after the HistoryURLProvider is initialized. | 338 // because it never changes after the HistoryURLProvider is initialized. |
344 // It's used to aid the possible transition to get all URLs from history to | 339 // It's used to aid the possible transition to get all URLs from history to |
345 // be scored in the HistoryQuick provider only. | 340 // be scored in the HistoryQuick provider only. |
346 bool search_url_database_; | 341 bool search_url_database_; |
347 | 342 |
348 // Params controlling experimental behavior of this provider. | 343 // Params controlling experimental behavior of this provider. |
349 HUPScoringParams scoring_params_; | 344 HUPScoringParams scoring_params_; |
350 | 345 |
351 base::ThreadChecker thread_checker_; | 346 base::ThreadChecker thread_checker_; |
352 | 347 |
353 DISALLOW_COPY_AND_ASSIGN(HistoryURLProvider); | 348 DISALLOW_COPY_AND_ASSIGN(HistoryURLProvider); |
354 }; | 349 }; |
355 | 350 |
356 #endif // COMPONENTS_OMNIBOX_BROWSER_HISTORY_URL_PROVIDER_H_ | 351 #endif // COMPONENTS_OMNIBOX_BROWSER_HISTORY_URL_PROVIDER_H_ |
OLD | NEW |