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

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

Issue 330653004: Adds a field trial flag to control whether to use an alternate Instant search base page URL for pre… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
« no previous file with comments | « chrome/browser/search/search.h ('k') | chrome/browser/search/search_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 const char kHideVerbatimFlagName[] = "hide_verbatim"; 67 const char kHideVerbatimFlagName[] = "hide_verbatim";
68 const char kPrefetchSearchResultsFlagName[] = "prefetch_results"; 68 const char kPrefetchSearchResultsFlagName[] = "prefetch_results";
69 const char kPrefetchSearchResultsOnSRP[] = "prefetch_results_srp"; 69 const char kPrefetchSearchResultsOnSRP[] = "prefetch_results_srp";
70 const char kPrerenderInstantUrlOnOmniboxFocus[] = 70 const char kPrerenderInstantUrlOnOmniboxFocus[] =
71 "prerender_instant_url_on_omnibox_focus"; 71 "prerender_instant_url_on_omnibox_focus";
72 72
73 // Controls whether to reuse prerendered Instant Search base page to commit any 73 // Controls whether to reuse prerendered Instant Search base page to commit any
74 // search query. 74 // search query.
75 const char kReuseInstantSearchBasePage[] = "reuse_instant_search_base_page"; 75 const char kReuseInstantSearchBasePage[] = "reuse_instant_search_base_page";
76 76
77 // Controls whether to use the alternate Instant search base URL. This allows
78 // experimentation of Instant search.
79 const char kUseAltInstantURL[] = "use_alternate_instant_url";
80 const char kAltInstantURLPath[] = "search";
81 const char kAltInstantURLQueryParams[] = "&qbp=1";
82
77 const char kDisplaySearchButtonFlagName[] = "display_search_button"; 83 const char kDisplaySearchButtonFlagName[] = "display_search_button";
78 const char kOriginChipFlagName[] = "origin_chip"; 84 const char kOriginChipFlagName[] = "origin_chip";
79 #if !defined(OS_IOS) && !defined(OS_ANDROID) 85 #if !defined(OS_IOS) && !defined(OS_ANDROID)
80 const char kEnableQueryExtractionFlagName[] = "query_extraction"; 86 const char kEnableQueryExtractionFlagName[] = "query_extraction";
81 #endif 87 #endif
82 const char kShouldShowGoogleLocalNTPFlagName[] = "google_local_ntp"; 88 const char kShouldShowGoogleLocalNTPFlagName[] = "google_local_ntp";
83 89
84 // Constants for the field trial name and group prefix. 90 // Constants for the field trial name and group prefix.
85 // Note in M30 and below this field trial was named "InstantExtended" and in 91 // Note in M30 and below this field trial was named "InstantExtended" and in
86 // M31 was renamed to EmbeddedSearch for clarity and cleanliness. Since we 92 // M31 was renamed to EmbeddedSearch for clarity and cleanliness. Since we
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 !google_util::StartsWithCommandLineGoogleBaseURL(instant_url)) { 549 !google_util::StartsWithCommandLineGoogleBaseURL(instant_url)) {
544 GURL::Replacements replacements; 550 GURL::Replacements replacements;
545 const std::string secure_scheme(url::kHttpsScheme); 551 const std::string secure_scheme(url::kHttpsScheme);
546 replacements.SetSchemeStr(secure_scheme); 552 replacements.SetSchemeStr(secure_scheme);
547 instant_url = instant_url.ReplaceComponents(replacements); 553 instant_url = instant_url.ReplaceComponents(replacements);
548 } 554 }
549 555
550 if (!IsURLAllowedForSupervisedUser(instant_url, profile)) 556 if (!IsURLAllowedForSupervisedUser(instant_url, profile))
551 return GURL(); 557 return GURL();
552 558
559 if (ShouldUseAltInstantURL()) {
560 GURL::Replacements replacements;
561 const std::string path(kAltInstantURLPath);
562 replacements.SetPathStr(path);
563 const std::string query(
564 instant_url.query() + std::string(kAltInstantURLQueryParams));
565 replacements.SetQueryStr(query);
566 instant_url = instant_url.ReplaceComponents(replacements);
567 }
553 return instant_url; 568 return instant_url;
554 } 569 }
555 570
556 // Returns URLs associated with the default search engine for |profile|. 571 // Returns URLs associated with the default search engine for |profile|.
557 std::vector<GURL> GetSearchURLs(Profile* profile) { 572 std::vector<GURL> GetSearchURLs(Profile* profile) {
558 std::vector<GURL> result; 573 std::vector<GURL> result;
559 TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile); 574 TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile);
560 if (!template_url) 575 if (!template_url)
561 return result; 576 return result;
562 for (size_t i = 0; i < template_url->URLCount(); ++i) { 577 for (size_t i = 0; i < template_url->URLCount(); ++i) {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 } 842 }
828 843
829 // Given a FieldTrialFlags object, returns the boolean value of the provided 844 // Given a FieldTrialFlags object, returns the boolean value of the provided
830 // flag. 845 // flag.
831 bool GetBoolValueForFlagWithDefault(const std::string& flag, 846 bool GetBoolValueForFlagWithDefault(const std::string& flag,
832 bool default_value, 847 bool default_value,
833 const FieldTrialFlags& flags) { 848 const FieldTrialFlags& flags) {
834 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); 849 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags);
835 } 850 }
836 851
852 bool ShouldUseAltInstantURL() {
samarth 2014/06/20 04:43:23 Put this in an anonymous namespace?
kmadhusu 2014/06/20 16:01:53 If I put this in anonymous namespace, I will not b
853 FieldTrialFlags flags;
854 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault(
855 kUseAltInstantURL, false, flags);
856 }
857
837 } // namespace chrome 858 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/search/search.h ('k') | chrome/browser/search/search_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698