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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 uint64 EmbeddedSearchPageVersion() { | 355 uint64 EmbeddedSearchPageVersion() { |
| 356 FieldTrialFlags flags; | 356 FieldTrialFlags flags; |
| 357 if (GetFieldTrialInfo(&flags)) { | 357 if (GetFieldTrialInfo(&flags)) { |
| 358 return GetUInt64ValueForFlagWithDefault(kEmbeddedPageVersionFlagName, | 358 return GetUInt64ValueForFlagWithDefault(kEmbeddedPageVersionFlagName, |
| 359 kEmbeddedPageVersionDefault, | 359 kEmbeddedPageVersionDefault, |
| 360 flags); | 360 flags); |
| 361 } | 361 } |
| 362 return kEmbeddedPageVersionDefault; | 362 return kEmbeddedPageVersionDefault; |
| 363 } | 363 } |
| 364 | 364 |
| 365 std::string InstantExtendedEnabledParam(bool for_search) { | |
| 366 #if !defined(OS_IOS) && !defined(OS_ANDROID) | |
|
samarth
2014/02/04 17:17:05
Why are these ifdefs necessary? IsQueryExtraction
kmadhusu
2014/02/04 17:49:59
ifdefs are not required here. Since I passed "fals
kmadhusu
2014/02/04 19:39:54
Removed.
| |
| 367 // On mobile, query extraction is always enabled. | |
| 368 if (for_search && !chrome::IsQueryExtractionEnabled()) | |
| 369 return std::string(); | |
| 370 #endif | |
| 371 | |
| 372 return std::string(google_util::kInstantExtendedAPIParam) + "=" + | |
| 373 base::Uint64ToString(EmbeddedSearchPageVersion()) + "&"; | |
| 374 } | |
| 375 | |
| 365 bool IsQueryExtractionEnabled() { | 376 bool IsQueryExtractionEnabled() { |
| 366 #if defined(OS_IOS) || defined(OS_ANDROID) | 377 #if defined(OS_IOS) || defined(OS_ANDROID) |
| 367 return true; | 378 return true; |
| 368 #else | 379 #else |
| 369 if (!IsInstantExtendedAPIEnabled()) | 380 if (!IsInstantExtendedAPIEnabled()) |
| 370 return false; | 381 return false; |
| 371 | 382 |
| 372 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 383 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 373 if (command_line->HasSwitch(switches::kEnableQueryExtraction)) | 384 if (command_line->HasSwitch(switches::kEnableQueryExtraction)) |
| 374 return true; | 385 return true; |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 776 | 787 |
| 777 // Given a FieldTrialFlags object, returns the boolean value of the provided | 788 // Given a FieldTrialFlags object, returns the boolean value of the provided |
| 778 // flag. | 789 // flag. |
| 779 bool GetBoolValueForFlagWithDefault(const std::string& flag, | 790 bool GetBoolValueForFlagWithDefault(const std::string& flag, |
| 780 bool default_value, | 791 bool default_value, |
| 781 const FieldTrialFlags& flags) { | 792 const FieldTrialFlags& flags) { |
| 782 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); | 793 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); |
| 783 } | 794 } |
| 784 | 795 |
| 785 } // namespace chrome | 796 } // namespace chrome |
| OLD | NEW |