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

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: '' 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/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 uint64 EmbeddedSearchPageVersion() { 277 uint64 EmbeddedSearchPageVersion() {
278 FieldTrialFlags flags; 278 FieldTrialFlags flags;
279 if (GetFieldTrialInfo(&flags)) { 279 if (GetFieldTrialInfo(&flags)) {
280 return GetUInt64ValueForFlagWithDefault(kEmbeddedPageVersionFlagName, 280 return GetUInt64ValueForFlagWithDefault(kEmbeddedPageVersionFlagName,
281 kEmbeddedPageVersionDefault, 281 kEmbeddedPageVersionDefault,
282 flags); 282 flags);
283 } 283 }
284 return kEmbeddedPageVersionDefault; 284 return kEmbeddedPageVersionDefault;
285 } 285 }
286 286
287 std::string InstantExtendedEnabledParam(bool for_search) {
288 #if !defined(OS_IOS) && !defined(OS_ANDROID)
289 // On mobile, query extraction is always enabled.
290 if (for_search && !chrome::IsQueryExtractionEnabled())
291 return std::string();
292 #endif
293
294 return std::string(google_util::kInstantExtendedAPIParam) + "=" +
295 base::Uint64ToString(EmbeddedSearchPageVersion()) + "&";
296 }
297
287 bool IsQueryExtractionEnabled() { 298 bool IsQueryExtractionEnabled() {
288 #if defined(OS_IOS) || defined(OS_ANDROID) 299 #if defined(OS_IOS) || defined(OS_ANDROID)
289 return true; 300 return true;
290 #else 301 #else
291 if (!IsInstantExtendedAPIEnabled()) 302 if (!IsInstantExtendedAPIEnabled())
292 return false; 303 return false;
293 304
294 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 305 const CommandLine* command_line = CommandLine::ForCurrentProcess();
295 if (command_line->HasSwitch(switches::kEnableQueryExtraction)) 306 if (command_line->HasSwitch(switches::kEnableQueryExtraction))
296 return true; 307 return true;
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 714
704 // Given a FieldTrialFlags object, returns the boolean value of the provided 715 // Given a FieldTrialFlags object, returns the boolean value of the provided
705 // flag. 716 // flag.
706 bool GetBoolValueForFlagWithDefault(const std::string& flag, 717 bool GetBoolValueForFlagWithDefault(const std::string& flag,
707 bool default_value, 718 bool default_value,
708 const FieldTrialFlags& flags) { 719 const FieldTrialFlags& flags) {
709 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); 720 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags);
710 } 721 }
711 722
712 } // namespace chrome 723 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698