Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(611)

Side by Side Diff: chrome/browser/search/search.cc

Issue 151813002: Adds InstantExtendedEnabledParam to the search request URL iff the query extraction flag is enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed toolbar_model_android code Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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) {
samarth 2014/02/05 21:16:16 So SearchTermsData checked that EmbeddedSearchPage
kmadhusu 2014/02/05 21:59:40 Good catch. Fixed. Added test.
366 if (for_search && !chrome::IsQueryExtractionEnabled())
367 return std::string();
368
369 return std::string(google_util::kInstantExtendedAPIParam) + "=" +
370 base::Uint64ToString(EmbeddedSearchPageVersion()) + "&";
371 }
372
365 bool IsQueryExtractionEnabled() { 373 bool IsQueryExtractionEnabled() {
366 #if defined(OS_IOS) || defined(OS_ANDROID) 374 #if defined(OS_IOS) || defined(OS_ANDROID)
367 return true; 375 return true;
368 #else 376 #else
369 if (!IsInstantExtendedAPIEnabled()) 377 if (!IsInstantExtendedAPIEnabled())
370 return false; 378 return false;
371 379
372 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 380 const CommandLine* command_line = CommandLine::ForCurrentProcess();
373 if (command_line->HasSwitch(switches::kEnableQueryExtraction)) 381 if (command_line->HasSwitch(switches::kEnableQueryExtraction))
374 return true; 382 return true;
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 784
777 // Given a FieldTrialFlags object, returns the boolean value of the provided 785 // Given a FieldTrialFlags object, returns the boolean value of the provided
778 // flag. 786 // flag.
779 bool GetBoolValueForFlagWithDefault(const std::string& flag, 787 bool GetBoolValueForFlagWithDefault(const std::string& flag,
780 bool default_value, 788 bool default_value,
781 const FieldTrialFlags& flags) { 789 const FieldTrialFlags& flags) {
782 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); 790 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags);
783 } 791 }
784 792
785 } // namespace chrome 793 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698