| 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 uint64 EmbeddedSearchPageVersion() { | 357 uint64 EmbeddedSearchPageVersion() { |
| 358 FieldTrialFlags flags; | 358 FieldTrialFlags flags; |
| 359 if (GetFieldTrialInfo(&flags)) { | 359 if (GetFieldTrialInfo(&flags)) { |
| 360 return GetUInt64ValueForFlagWithDefault(kEmbeddedPageVersionFlagName, | 360 return GetUInt64ValueForFlagWithDefault(kEmbeddedPageVersionFlagName, |
| 361 kEmbeddedPageVersionDefault, | 361 kEmbeddedPageVersionDefault, |
| 362 flags); | 362 flags); |
| 363 } | 363 } |
| 364 return kEmbeddedPageVersionDefault; | 364 return kEmbeddedPageVersionDefault; |
| 365 } | 365 } |
| 366 | 366 |
| 367 std::string InstantExtendedEnabledParam(bool for_search) { |
| 368 if (for_search && !chrome::IsQueryExtractionEnabled()) |
| 369 return std::string(); |
| 370 return std::string(google_util::kInstantExtendedAPIParam) + "=" + |
| 371 base::Uint64ToString(EmbeddedSearchPageVersion()) + "&"; |
| 372 } |
| 373 |
| 367 bool IsQueryExtractionEnabled() { | 374 bool IsQueryExtractionEnabled() { |
| 368 #if defined(OS_IOS) || defined(OS_ANDROID) | 375 #if defined(OS_IOS) || defined(OS_ANDROID) |
| 369 return true; | 376 return true; |
| 370 #else | 377 #else |
| 371 if (!IsInstantExtendedAPIEnabled()) | 378 if (!IsInstantExtendedAPIEnabled()) |
| 372 return false; | 379 return false; |
| 373 | 380 |
| 374 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 381 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 375 if (command_line->HasSwitch(switches::kEnableQueryExtraction)) | 382 if (command_line->HasSwitch(switches::kEnableQueryExtraction)) |
| 376 return true; | 383 return true; |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 | 825 |
| 819 // Given a FieldTrialFlags object, returns the boolean value of the provided | 826 // Given a FieldTrialFlags object, returns the boolean value of the provided |
| 820 // flag. | 827 // flag. |
| 821 bool GetBoolValueForFlagWithDefault(const std::string& flag, | 828 bool GetBoolValueForFlagWithDefault(const std::string& flag, |
| 822 bool default_value, | 829 bool default_value, |
| 823 const FieldTrialFlags& flags) { | 830 const FieldTrialFlags& flags) { |
| 824 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); | 831 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); |
| 825 } | 832 } |
| 826 | 833 |
| 827 } // namespace chrome | 834 } // namespace chrome |
| OLD | NEW |