Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/search/search.h" | 5 #include "chrome/browser/search/search.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 398 | 398 |
| 399 FieldTrialFlags flags; | 399 FieldTrialFlags flags; |
| 400 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | 400 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( |
| 401 kEnableQueryExtractionFlagName, false, flags); | 401 kEnableQueryExtractionFlagName, false, flags); |
| 402 #endif // defined(OS_IOS) || defined(OS_ANDROID) | 402 #endif // defined(OS_IOS) || defined(OS_ANDROID) |
| 403 } | 403 } |
| 404 | 404 |
| 405 base::string16 ExtractSearchTermsFromURL(Profile* profile, const GURL& url) { | 405 base::string16 ExtractSearchTermsFromURL(Profile* profile, const GURL& url) { |
| 406 if (url.is_valid() && url == GetSearchResultPrefetchBaseURL(profile)) { | 406 if (url.is_valid() && url == GetSearchResultPrefetchBaseURL(profile)) { |
| 407 // InstantSearchPrerenderer has the search query for the Instant search base | 407 // InstantSearchPrerenderer has the search query for the Instant search base |
| 408 // page. | 408 // page. |
|
Peter Kasting
2014/05/01 20:21:02
Nit: Add an explanation of when this can be NULL (
| |
| 409 InstantSearchPrerenderer* prerenderer = | 409 InstantSearchPrerenderer* prerenderer = |
| 410 InstantSearchPrerenderer::GetForProfile(profile); | 410 InstantSearchPrerenderer::GetForProfile(profile); |
| 411 DCHECK(prerenderer); | 411 return prerenderer ? prerenderer->get_last_query() : base::string16(); |
| 412 return prerenderer->get_last_query(); | |
| 413 } | 412 } |
| 414 | 413 |
| 415 TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile); | 414 TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile); |
| 416 base::string16 search_terms; | 415 base::string16 search_terms; |
| 417 if (template_url) | 416 if (template_url) |
| 418 template_url->ExtractSearchTermsFromURL(url, &search_terms); | 417 template_url->ExtractSearchTermsFromURL(url, &search_terms); |
| 419 return search_terms; | 418 return search_terms; |
| 420 } | 419 } |
| 421 | 420 |
| 422 bool IsQueryExtractionAllowedForURL(Profile* profile, const GURL& url) { | 421 bool IsQueryExtractionAllowedForURL(Profile* profile, const GURL& url) { |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 839 | 838 |
| 840 // Given a FieldTrialFlags object, returns the boolean value of the provided | 839 // Given a FieldTrialFlags object, returns the boolean value of the provided |
| 841 // flag. | 840 // flag. |
| 842 bool GetBoolValueForFlagWithDefault(const std::string& flag, | 841 bool GetBoolValueForFlagWithDefault(const std::string& flag, |
| 843 bool default_value, | 842 bool default_value, |
| 844 const FieldTrialFlags& flags) { | 843 const FieldTrialFlags& flags) { |
| 845 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); | 844 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); |
| 846 } | 845 } |
| 847 | 846 |
| 848 } // namespace chrome | 847 } // namespace chrome |
| OLD | NEW |