| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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( | 242 virtual std::string ForceInstantResultsParam( |
| 243 bool for_prerender) const OVERRIDE; | 243 bool for_prerender) const OVERRIDE; |
| 244 virtual std::string InstantExtendedEnabledParam() const OVERRIDE; | |
| 245 virtual std::string NTPIsThemedParam() const OVERRIDE; | 244 virtual std::string NTPIsThemedParam() const OVERRIDE; |
| 246 | 245 |
| 247 private: | 246 private: |
| 248 std::string google_base_url_value_; | 247 std::string google_base_url_value_; |
| 249 std::string application_locale_; | 248 std::string application_locale_; |
| 250 base::string16 rlz_parameter_value_; | 249 base::string16 rlz_parameter_value_; |
| 251 std::string search_client_; | 250 std::string search_client_; |
| 252 std::string force_instant_results_param_; | 251 std::string force_instant_results_param_; |
| 253 std::string instant_extended_enabled_param_; | |
| 254 std::string ntp_is_themed_param_; | 252 std::string ntp_is_themed_param_; |
| 255 | 253 |
| 256 DISALLOW_COPY_AND_ASSIGN(SearchTermsDataSnapshot); | 254 DISALLOW_COPY_AND_ASSIGN(SearchTermsDataSnapshot); |
| 257 }; | 255 }; |
| 258 | 256 |
| 259 SearchTermsDataSnapshot::SearchTermsDataSnapshot( | 257 SearchTermsDataSnapshot::SearchTermsDataSnapshot( |
| 260 const SearchTermsData& search_terms_data) | 258 const SearchTermsData& search_terms_data) |
| 261 : google_base_url_value_(search_terms_data.GoogleBaseURLValue()), | 259 : google_base_url_value_(search_terms_data.GoogleBaseURLValue()), |
| 262 application_locale_(search_terms_data.GetApplicationLocale()), | 260 application_locale_(search_terms_data.GetApplicationLocale()), |
| 263 rlz_parameter_value_(search_terms_data.GetRlzParameterValue()), | 261 rlz_parameter_value_(search_terms_data.GetRlzParameterValue()), |
| 264 search_client_(search_terms_data.GetSearchClient()), | 262 search_client_(search_terms_data.GetSearchClient()), |
| 265 force_instant_results_param_( | 263 force_instant_results_param_( |
| 266 search_terms_data.ForceInstantResultsParam(false)), | 264 search_terms_data.ForceInstantResultsParam(false)), |
| 267 instant_extended_enabled_param_( | |
| 268 search_terms_data.InstantExtendedEnabledParam()), | |
| 269 ntp_is_themed_param_(search_terms_data.NTPIsThemedParam()) {} | 265 ntp_is_themed_param_(search_terms_data.NTPIsThemedParam()) {} |
| 270 | 266 |
| 271 SearchTermsDataSnapshot::~SearchTermsDataSnapshot() { | 267 SearchTermsDataSnapshot::~SearchTermsDataSnapshot() { |
| 272 } | 268 } |
| 273 | 269 |
| 274 std::string SearchTermsDataSnapshot::GoogleBaseURLValue() const { | 270 std::string SearchTermsDataSnapshot::GoogleBaseURLValue() const { |
| 275 return google_base_url_value_; | 271 return google_base_url_value_; |
| 276 } | 272 } |
| 277 | 273 |
| 278 std::string SearchTermsDataSnapshot::GetApplicationLocale() const { | 274 std::string SearchTermsDataSnapshot::GetApplicationLocale() const { |
| 279 return application_locale_; | 275 return application_locale_; |
| 280 } | 276 } |
| 281 | 277 |
| 282 base::string16 SearchTermsDataSnapshot::GetRlzParameterValue() const { | 278 base::string16 SearchTermsDataSnapshot::GetRlzParameterValue() const { |
| 283 return rlz_parameter_value_; | 279 return rlz_parameter_value_; |
| 284 } | 280 } |
| 285 | 281 |
| 286 std::string SearchTermsDataSnapshot::GetSearchClient() const { | 282 std::string SearchTermsDataSnapshot::GetSearchClient() const { |
| 287 return search_client_; | 283 return search_client_; |
| 288 } | 284 } |
| 289 | 285 |
| 290 std::string SearchTermsDataSnapshot::ForceInstantResultsParam( | 286 std::string SearchTermsDataSnapshot::ForceInstantResultsParam( |
| 291 bool for_prerender) const { | 287 bool for_prerender) const { |
| 292 return force_instant_results_param_; | 288 return force_instant_results_param_; |
| 293 } | 289 } |
| 294 | 290 |
| 295 std::string SearchTermsDataSnapshot::InstantExtendedEnabledParam() const { | |
| 296 return instant_extended_enabled_param_; | |
| 297 } | |
| 298 | |
| 299 std::string SearchTermsDataSnapshot::NTPIsThemedParam() const { | 291 std::string SearchTermsDataSnapshot::NTPIsThemedParam() const { |
| 300 return ntp_is_themed_param_; | 292 return ntp_is_themed_param_; |
| 301 } | 293 } |
| 302 | 294 |
| 303 // ----------------------------------------------------------------- | 295 // ----------------------------------------------------------------- |
| 304 // HistoryURLProvider | 296 // HistoryURLProvider |
| 305 | 297 |
| 306 // These ugly magic numbers will go away once we switch all scoring | 298 // These ugly magic numbers will go away once we switch all scoring |
| 307 // behavior (including URL-what-you-typed) to HistoryQuick provider. | 299 // behavior (including URL-what-you-typed) to HistoryQuick provider. |
| 308 const int HistoryURLProvider::kScoreForBestInlineableResult = 1413; | 300 const int HistoryURLProvider::kScoreForBestInlineableResult = 1413; |
| (...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1172 history::MatchTermInString(input_text, clean_description, 0))); | 1164 history::MatchTermInString(input_text, clean_description, 0))); |
| 1173 history::WordStarts description_word_starts; | 1165 history::WordStarts description_word_starts; |
| 1174 history::String16VectorFromString16( | 1166 history::String16VectorFromString16( |
| 1175 clean_description, false, &description_word_starts); | 1167 clean_description, false, &description_word_starts); |
| 1176 description_matches = | 1168 description_matches = |
| 1177 history::ScoredHistoryMatch::FilterTermMatchesByWordStarts( | 1169 history::ScoredHistoryMatch::FilterTermMatchesByWordStarts( |
| 1178 description_matches, description_word_starts, 0, std::string::npos); | 1170 description_matches, description_word_starts, 0, std::string::npos); |
| 1179 return SpansFromTermMatch( | 1171 return SpansFromTermMatch( |
| 1180 description_matches, clean_description.length(), false); | 1172 description_matches, clean_description.length(), false); |
| 1181 } | 1173 } |
| OLD | NEW |