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

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

Issue 330123003: Set up a field trial flag to prerender Instant search base url on omnibox focus event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added check for prefetch-search-results 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
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 const uint64 kEmbeddedPageVersionDefault = 1; 59 const uint64 kEmbeddedPageVersionDefault = 1;
60 // Use this variant to enable EmbeddedSearch SearchBox API in the results page. 60 // Use this variant to enable EmbeddedSearch SearchBox API in the results page.
61 const uint64 kEmbeddedSearchEnabledVersion = 2; 61 const uint64 kEmbeddedSearchEnabledVersion = 2;
62 #else 62 #else
63 const uint64 kEmbeddedPageVersionDefault = 2; 63 const uint64 kEmbeddedPageVersionDefault = 2;
64 #endif 64 #endif
65 65
66 const char kHideVerbatimFlagName[] = "hide_verbatim"; 66 const char kHideVerbatimFlagName[] = "hide_verbatim";
67 const char kPrefetchSearchResultsFlagName[] = "prefetch_results"; 67 const char kPrefetchSearchResultsFlagName[] = "prefetch_results";
68 const char kPrefetchSearchResultsOnSRP[] = "prefetch_results_srp"; 68 const char kPrefetchSearchResultsOnSRP[] = "prefetch_results_srp";
69 const char kPrerenderInstantUrlOnOmniboxFocus[] =
70 "prerender_instant_url_on_omnibox_focus";
69 71
70 // Controls whether to reuse prerendered Instant Search base page to commit any 72 // Controls whether to reuse prerendered Instant Search base page to commit any
71 // search query. 73 // search query.
72 const char kReuseInstantSearchBasePage[] = "reuse_instant_search_base_page"; 74 const char kReuseInstantSearchBasePage[] = "reuse_instant_search_base_page";
73 75
74 const char kDisplaySearchButtonFlagName[] = "display_search_button"; 76 const char kDisplaySearchButtonFlagName[] = "display_search_button";
75 const char kOriginChipFlagName[] = "origin_chip"; 77 const char kOriginChipFlagName[] = "origin_chip";
76 #if !defined(OS_IOS) && !defined(OS_ANDROID) 78 #if !defined(OS_IOS) && !defined(OS_ANDROID)
77 const char kEnableQueryExtractionFlagName[] = "query_extraction"; 79 const char kEnableQueryExtractionFlagName[] = "query_extraction";
78 #endif 80 #endif
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 if (CommandLine::ForCurrentProcess()->HasSwitch( 571 if (CommandLine::ForCurrentProcess()->HasSwitch(
570 switches::kPrefetchSearchResults)) { 572 switches::kPrefetchSearchResults)) {
571 return true; 573 return true;
572 } 574 }
573 575
574 FieldTrialFlags flags; 576 FieldTrialFlags flags;
575 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( 577 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault(
576 kPrefetchSearchResultsFlagName, false, flags); 578 kPrefetchSearchResultsFlagName, false, flags);
577 } 579 }
578 580
581 bool ShouldPrerenderInstantUrlOnOmniboxFocus() {
582 if (!ShouldPrefetchSearchResults())
583 return false;
584
585 FieldTrialFlags flags;
586 return GetFieldTrialInfo(&flags) &&
587 GetBoolValueForFlagWithDefault(
kmadhusu 2014/06/12 23:59:15 nit: This can go the previous line as follows: re
sidharthms 2014/06/13 00:17:55 Done.
588 kPrerenderInstantUrlOnOmniboxFocus, false, flags);
589 }
590
579 bool ShouldReuseInstantSearchBasePage() { 591 bool ShouldReuseInstantSearchBasePage() {
580 if (CommandLine::ForCurrentProcess()->HasSwitch( 592 if (CommandLine::ForCurrentProcess()->HasSwitch(
581 switches::kPrefetchSearchResults)) { 593 switches::kPrefetchSearchResults)) {
582 return true; 594 return true;
583 } 595 }
584 596
585 if (!ShouldPrefetchSearchResults()) 597 if (!ShouldPrefetchSearchResults())
586 return false; 598 return false;
587 599
588 FieldTrialFlags flags; 600 FieldTrialFlags flags;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 822
811 // Given a FieldTrialFlags object, returns the boolean value of the provided 823 // Given a FieldTrialFlags object, returns the boolean value of the provided
812 // flag. 824 // flag.
813 bool GetBoolValueForFlagWithDefault(const std::string& flag, 825 bool GetBoolValueForFlagWithDefault(const std::string& flag,
814 bool default_value, 826 bool default_value,
815 const FieldTrialFlags& flags) { 827 const FieldTrialFlags& flags) {
816 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); 828 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags);
817 } 829 }
818 830
819 } // namespace chrome 831 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698