| 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 "chrome/browser/autocomplete/history_url_provider.h" | 5 #include "chrome/browser/autocomplete/history_url_provider.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 // UIThreadSearchTermsData but is subsequently safe to use on any thread. | 232 // UIThreadSearchTermsData but is subsequently safe to use on any thread. |
| 233 class SearchTermsDataSnapshot : public SearchTermsData { | 233 class SearchTermsDataSnapshot : public SearchTermsData { |
| 234 public: | 234 public: |
| 235 explicit SearchTermsDataSnapshot(const SearchTermsData& search_terms_data); | 235 explicit SearchTermsDataSnapshot(const SearchTermsData& search_terms_data); |
| 236 virtual ~SearchTermsDataSnapshot(); | 236 virtual ~SearchTermsDataSnapshot(); |
| 237 | 237 |
| 238 virtual std::string GoogleBaseURLValue() const OVERRIDE; | 238 virtual std::string GoogleBaseURLValue() const OVERRIDE; |
| 239 virtual std::string GetApplicationLocale() const OVERRIDE; | 239 virtual std::string GetApplicationLocale() const OVERRIDE; |
| 240 virtual base::string16 GetRlzParameterValue() const OVERRIDE; | 240 virtual base::string16 GetRlzParameterValue() const OVERRIDE; |
| 241 virtual std::string GetSearchClient() const OVERRIDE; | 241 virtual std::string GetSearchClient() const OVERRIDE; |
| 242 virtual std::string ForceInstantResultsParam( | |
| 243 bool for_prerender) const OVERRIDE; | |
| 244 virtual std::string NTPIsThemedParam() const OVERRIDE; | 242 virtual std::string NTPIsThemedParam() const OVERRIDE; |
| 245 | 243 |
| 246 private: | 244 private: |
| 247 std::string google_base_url_value_; | 245 std::string google_base_url_value_; |
| 248 std::string application_locale_; | 246 std::string application_locale_; |
| 249 base::string16 rlz_parameter_value_; | 247 base::string16 rlz_parameter_value_; |
| 250 std::string search_client_; | 248 std::string search_client_; |
| 251 std::string force_instant_results_param_; | |
| 252 std::string ntp_is_themed_param_; | 249 std::string ntp_is_themed_param_; |
| 253 | 250 |
| 254 DISALLOW_COPY_AND_ASSIGN(SearchTermsDataSnapshot); | 251 DISALLOW_COPY_AND_ASSIGN(SearchTermsDataSnapshot); |
| 255 }; | 252 }; |
| 256 | 253 |
| 257 SearchTermsDataSnapshot::SearchTermsDataSnapshot( | 254 SearchTermsDataSnapshot::SearchTermsDataSnapshot( |
| 258 const SearchTermsData& search_terms_data) | 255 const SearchTermsData& search_terms_data) |
| 259 : google_base_url_value_(search_terms_data.GoogleBaseURLValue()), | 256 : google_base_url_value_(search_terms_data.GoogleBaseURLValue()), |
| 260 application_locale_(search_terms_data.GetApplicationLocale()), | 257 application_locale_(search_terms_data.GetApplicationLocale()), |
| 261 rlz_parameter_value_(search_terms_data.GetRlzParameterValue()), | 258 rlz_parameter_value_(search_terms_data.GetRlzParameterValue()), |
| 262 search_client_(search_terms_data.GetSearchClient()), | 259 search_client_(search_terms_data.GetSearchClient()), |
| 263 force_instant_results_param_( | |
| 264 search_terms_data.ForceInstantResultsParam(false)), | |
| 265 ntp_is_themed_param_(search_terms_data.NTPIsThemedParam()) {} | 260 ntp_is_themed_param_(search_terms_data.NTPIsThemedParam()) {} |
| 266 | 261 |
| 267 SearchTermsDataSnapshot::~SearchTermsDataSnapshot() { | 262 SearchTermsDataSnapshot::~SearchTermsDataSnapshot() { |
| 268 } | 263 } |
| 269 | 264 |
| 270 std::string SearchTermsDataSnapshot::GoogleBaseURLValue() const { | 265 std::string SearchTermsDataSnapshot::GoogleBaseURLValue() const { |
| 271 return google_base_url_value_; | 266 return google_base_url_value_; |
| 272 } | 267 } |
| 273 | 268 |
| 274 std::string SearchTermsDataSnapshot::GetApplicationLocale() const { | 269 std::string SearchTermsDataSnapshot::GetApplicationLocale() const { |
| 275 return application_locale_; | 270 return application_locale_; |
| 276 } | 271 } |
| 277 | 272 |
| 278 base::string16 SearchTermsDataSnapshot::GetRlzParameterValue() const { | 273 base::string16 SearchTermsDataSnapshot::GetRlzParameterValue() const { |
| 279 return rlz_parameter_value_; | 274 return rlz_parameter_value_; |
| 280 } | 275 } |
| 281 | 276 |
| 282 std::string SearchTermsDataSnapshot::GetSearchClient() const { | 277 std::string SearchTermsDataSnapshot::GetSearchClient() const { |
| 283 return search_client_; | 278 return search_client_; |
| 284 } | 279 } |
| 285 | 280 |
| 286 std::string SearchTermsDataSnapshot::ForceInstantResultsParam( | |
| 287 bool for_prerender) const { | |
| 288 return force_instant_results_param_; | |
| 289 } | |
| 290 | |
| 291 std::string SearchTermsDataSnapshot::NTPIsThemedParam() const { | 281 std::string SearchTermsDataSnapshot::NTPIsThemedParam() const { |
| 292 return ntp_is_themed_param_; | 282 return ntp_is_themed_param_; |
| 293 } | 283 } |
| 294 | 284 |
| 295 // ----------------------------------------------------------------- | 285 // ----------------------------------------------------------------- |
| 296 // HistoryURLProvider | 286 // HistoryURLProvider |
| 297 | 287 |
| 298 // These ugly magic numbers will go away once we switch all scoring | 288 // These ugly magic numbers will go away once we switch all scoring |
| 299 // behavior (including URL-what-you-typed) to HistoryQuick provider. | 289 // behavior (including URL-what-you-typed) to HistoryQuick provider. |
| 300 const int HistoryURLProvider::kScoreForBestInlineableResult = 1413; | 290 const int HistoryURLProvider::kScoreForBestInlineableResult = 1413; |
| (...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1164 history::MatchTermInString(input_text, clean_description, 0))); | 1154 history::MatchTermInString(input_text, clean_description, 0))); |
| 1165 history::WordStarts description_word_starts; | 1155 history::WordStarts description_word_starts; |
| 1166 history::String16VectorFromString16( | 1156 history::String16VectorFromString16( |
| 1167 clean_description, false, &description_word_starts); | 1157 clean_description, false, &description_word_starts); |
| 1168 description_matches = | 1158 description_matches = |
| 1169 history::ScoredHistoryMatch::FilterTermMatchesByWordStarts( | 1159 history::ScoredHistoryMatch::FilterTermMatchesByWordStarts( |
| 1170 description_matches, description_word_starts, 0, std::string::npos); | 1160 description_matches, description_word_starts, 0, std::string::npos); |
| 1171 return SpansFromTermMatch( | 1161 return SpansFromTermMatch( |
| 1172 description_matches, clean_description.length(), false); | 1162 description_matches, clean_description.length(), false); |
| 1173 } | 1163 } |
| OLD | NEW |