| 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 #include "components/omnibox/browser/history_url_provider.h" | 5 #include "components/omnibox/browser/history_url_provider.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 // UIThreadSearchTermsData but is subsequently safe to use on any thread. | 270 // UIThreadSearchTermsData but is subsequently safe to use on any thread. |
| 271 class SearchTermsDataSnapshot : public SearchTermsData { | 271 class SearchTermsDataSnapshot : public SearchTermsData { |
| 272 public: | 272 public: |
| 273 explicit SearchTermsDataSnapshot(const SearchTermsData& search_terms_data); | 273 explicit SearchTermsDataSnapshot(const SearchTermsData& search_terms_data); |
| 274 ~SearchTermsDataSnapshot() override; | 274 ~SearchTermsDataSnapshot() override; |
| 275 | 275 |
| 276 std::string GoogleBaseURLValue() const override; | 276 std::string GoogleBaseURLValue() const override; |
| 277 std::string GetApplicationLocale() const override; | 277 std::string GetApplicationLocale() const override; |
| 278 base::string16 GetRlzParameterValue(bool from_app_list) const override; | 278 base::string16 GetRlzParameterValue(bool from_app_list) const override; |
| 279 std::string GetSearchClient() const override; | 279 std::string GetSearchClient() const override; |
| 280 bool IsShowingSearchTermsOnSearchResultsPages() const override; | |
| 281 std::string InstantExtendedEnabledParam(bool for_search) const override; | 280 std::string InstantExtendedEnabledParam(bool for_search) const override; |
| 282 std::string ForceInstantResultsParam(bool for_prerender) const override; | 281 std::string ForceInstantResultsParam(bool for_prerender) const override; |
| 283 std::string NTPIsThemedParam() const override; | |
| 284 std::string GoogleImageSearchSource() const override; | 282 std::string GoogleImageSearchSource() const override; |
| 285 | 283 |
| 286 private: | 284 private: |
| 287 std::string google_base_url_value_; | 285 std::string google_base_url_value_; |
| 288 std::string application_locale_; | 286 std::string application_locale_; |
| 289 base::string16 rlz_parameter_value_; | 287 base::string16 rlz_parameter_value_; |
| 290 std::string search_client_; | 288 std::string search_client_; |
| 291 bool is_showing_search_terms_on_search_results_pages_; | |
| 292 std::string instant_extended_enabled_param_; | 289 std::string instant_extended_enabled_param_; |
| 293 std::string instant_extended_enabled_param_for_search_; | 290 std::string instant_extended_enabled_param_for_search_; |
| 294 std::string force_instant_results_param_; | 291 std::string force_instant_results_param_; |
| 295 std::string force_instant_results_param_for_prerender_; | 292 std::string force_instant_results_param_for_prerender_; |
| 296 std::string ntp_is_themed_param_; | |
| 297 std::string google_image_search_source_; | 293 std::string google_image_search_source_; |
| 298 | 294 |
| 299 DISALLOW_COPY_AND_ASSIGN(SearchTermsDataSnapshot); | 295 DISALLOW_COPY_AND_ASSIGN(SearchTermsDataSnapshot); |
| 300 }; | 296 }; |
| 301 | 297 |
| 302 SearchTermsDataSnapshot::SearchTermsDataSnapshot( | 298 SearchTermsDataSnapshot::SearchTermsDataSnapshot( |
| 303 const SearchTermsData& search_terms_data) | 299 const SearchTermsData& search_terms_data) |
| 304 : google_base_url_value_(search_terms_data.GoogleBaseURLValue()), | 300 : google_base_url_value_(search_terms_data.GoogleBaseURLValue()), |
| 305 application_locale_(search_terms_data.GetApplicationLocale()), | 301 application_locale_(search_terms_data.GetApplicationLocale()), |
| 306 rlz_parameter_value_(search_terms_data.GetRlzParameterValue(false)), | 302 rlz_parameter_value_(search_terms_data.GetRlzParameterValue(false)), |
| 307 search_client_(search_terms_data.GetSearchClient()), | 303 search_client_(search_terms_data.GetSearchClient()), |
| 308 is_showing_search_terms_on_search_results_pages_( | |
| 309 search_terms_data.IsShowingSearchTermsOnSearchResultsPages()), | |
| 310 instant_extended_enabled_param_( | 304 instant_extended_enabled_param_( |
| 311 search_terms_data.InstantExtendedEnabledParam(false)), | 305 search_terms_data.InstantExtendedEnabledParam(false)), |
| 312 instant_extended_enabled_param_for_search_( | 306 instant_extended_enabled_param_for_search_( |
| 313 search_terms_data.InstantExtendedEnabledParam(true)), | 307 search_terms_data.InstantExtendedEnabledParam(true)), |
| 314 force_instant_results_param_( | 308 force_instant_results_param_( |
| 315 search_terms_data.ForceInstantResultsParam(false)), | 309 search_terms_data.ForceInstantResultsParam(false)), |
| 316 force_instant_results_param_for_prerender_( | 310 force_instant_results_param_for_prerender_( |
| 317 search_terms_data.ForceInstantResultsParam(true)), | 311 search_terms_data.ForceInstantResultsParam(true)), |
| 318 ntp_is_themed_param_(search_terms_data.NTPIsThemedParam()), | |
| 319 google_image_search_source_(search_terms_data.GoogleImageSearchSource()) { | 312 google_image_search_source_(search_terms_data.GoogleImageSearchSource()) { |
| 320 } | 313 } |
| 321 | 314 |
| 322 SearchTermsDataSnapshot::~SearchTermsDataSnapshot() { | 315 SearchTermsDataSnapshot::~SearchTermsDataSnapshot() { |
| 323 } | 316 } |
| 324 | 317 |
| 325 std::string SearchTermsDataSnapshot::GoogleBaseURLValue() const { | 318 std::string SearchTermsDataSnapshot::GoogleBaseURLValue() const { |
| 326 return google_base_url_value_; | 319 return google_base_url_value_; |
| 327 } | 320 } |
| 328 | 321 |
| 329 std::string SearchTermsDataSnapshot::GetApplicationLocale() const { | 322 std::string SearchTermsDataSnapshot::GetApplicationLocale() const { |
| 330 return application_locale_; | 323 return application_locale_; |
| 331 } | 324 } |
| 332 | 325 |
| 333 base::string16 SearchTermsDataSnapshot::GetRlzParameterValue( | 326 base::string16 SearchTermsDataSnapshot::GetRlzParameterValue( |
| 334 bool from_app_list) const { | 327 bool from_app_list) const { |
| 335 return rlz_parameter_value_; | 328 return rlz_parameter_value_; |
| 336 } | 329 } |
| 337 | 330 |
| 338 std::string SearchTermsDataSnapshot::GetSearchClient() const { | 331 std::string SearchTermsDataSnapshot::GetSearchClient() const { |
| 339 return search_client_; | 332 return search_client_; |
| 340 } | 333 } |
| 341 | 334 |
| 342 bool SearchTermsDataSnapshot::IsShowingSearchTermsOnSearchResultsPages() const { | |
| 343 return is_showing_search_terms_on_search_results_pages_; | |
| 344 } | |
| 345 | |
| 346 std::string SearchTermsDataSnapshot::InstantExtendedEnabledParam( | 335 std::string SearchTermsDataSnapshot::InstantExtendedEnabledParam( |
| 347 bool for_search) const { | 336 bool for_search) const { |
| 348 return for_search ? instant_extended_enabled_param_ : | 337 return for_search ? instant_extended_enabled_param_ : |
| 349 instant_extended_enabled_param_for_search_; | 338 instant_extended_enabled_param_for_search_; |
| 350 } | 339 } |
| 351 | 340 |
| 352 std::string SearchTermsDataSnapshot::ForceInstantResultsParam( | 341 std::string SearchTermsDataSnapshot::ForceInstantResultsParam( |
| 353 bool for_prerender) const { | 342 bool for_prerender) const { |
| 354 return for_prerender ? force_instant_results_param_ : | 343 return for_prerender ? force_instant_results_param_ : |
| 355 force_instant_results_param_for_prerender_; | 344 force_instant_results_param_for_prerender_; |
| 356 } | 345 } |
| 357 | 346 |
| 358 std::string SearchTermsDataSnapshot::NTPIsThemedParam() const { | |
| 359 return ntp_is_themed_param_; | |
| 360 } | |
| 361 | |
| 362 std::string SearchTermsDataSnapshot::GoogleImageSearchSource() const { | 347 std::string SearchTermsDataSnapshot::GoogleImageSearchSource() const { |
| 363 return google_image_search_source_; | 348 return google_image_search_source_; |
| 364 } | 349 } |
| 365 | 350 |
| 366 // ----------------------------------------------------------------- | 351 // ----------------------------------------------------------------- |
| 367 // HistoryURLProvider | 352 // HistoryURLProvider |
| 368 | 353 |
| 369 // These ugly magic numbers will go away once we switch all scoring | 354 // These ugly magic numbers will go away once we switch all scoring |
| 370 // behavior (including URL-what-you-typed) to HistoryQuick provider. | 355 // behavior (including URL-what-you-typed) to HistoryQuick provider. |
| 371 const int HistoryURLProvider::kScoreForBestInlineableResult = 1413; | 356 const int HistoryURLProvider::kScoreForBestInlineableResult = 1413; |
| (...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, | 1195 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, |
| 1211 match.contents.length(), ACMatchClassification::URL, | 1196 match.contents.length(), ACMatchClassification::URL, |
| 1212 &match.contents_class); | 1197 &match.contents_class); |
| 1213 } | 1198 } |
| 1214 match.description = info.title(); | 1199 match.description = info.title(); |
| 1215 match.description_class = | 1200 match.description_class = |
| 1216 ClassifyDescription(params.input.text(), match.description); | 1201 ClassifyDescription(params.input.text(), match.description); |
| 1217 RecordAdditionalInfoFromUrlRow(info, &match); | 1202 RecordAdditionalInfoFromUrlRow(info, &match); |
| 1218 return match; | 1203 return match; |
| 1219 } | 1204 } |
| OLD | NEW |