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

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

Issue 324273004: Allow non default prefetch suggestions to be prefetched (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
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 kAllowPrefetchNonDefaultMatch[] = "allow_prefetch_non_default_match";
69 const char kPrerenderInstantUrlOnOmniboxFocus[] = 70 const char kPrerenderInstantUrlOnOmniboxFocus[] =
70 "prerender_instant_url_on_omnibox_focus"; 71 "prerender_instant_url_on_omnibox_focus";
71 72
72 // 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
73 // search query. 74 // search query.
74 const char kReuseInstantSearchBasePage[] = "reuse_instant_search_base_page"; 75 const char kReuseInstantSearchBasePage[] = "reuse_instant_search_base_page";
75 76
76 const char kDisplaySearchButtonFlagName[] = "display_search_button"; 77 const char kDisplaySearchButtonFlagName[] = "display_search_button";
77 const char kOriginChipFlagName[] = "origin_chip"; 78 const char kOriginChipFlagName[] = "origin_chip";
78 #if !defined(OS_IOS) && !defined(OS_ANDROID) 79 #if !defined(OS_IOS) && !defined(OS_ANDROID)
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 if (CommandLine::ForCurrentProcess()->HasSwitch( 575 if (CommandLine::ForCurrentProcess()->HasSwitch(
575 switches::kPrefetchSearchResults)) { 576 switches::kPrefetchSearchResults)) {
576 return true; 577 return true;
577 } 578 }
578 579
579 FieldTrialFlags flags; 580 FieldTrialFlags flags;
580 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( 581 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault(
581 kPrefetchSearchResultsFlagName, false, flags); 582 kPrefetchSearchResultsFlagName, false, flags);
582 } 583 }
583 584
585 bool ShouldAllowPrefetchNonDefaultMatch() {
586 if (!ShouldPrefetchSearchResults())
587 return false;
588
589 FieldTrialFlags flags;
590 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault(
591 kAllowPrefetchNonDefaultMatch, false, flags);
592 }
593
584 bool ShouldPrerenderInstantUrlOnOmniboxFocus() { 594 bool ShouldPrerenderInstantUrlOnOmniboxFocus() {
585 if (!ShouldPrefetchSearchResults()) 595 if (!ShouldPrefetchSearchResults())
586 return false; 596 return false;
587 597
588 FieldTrialFlags flags; 598 FieldTrialFlags flags;
589 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( 599 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault(
590 kPrerenderInstantUrlOnOmniboxFocus, false, flags); 600 kPrerenderInstantUrlOnOmniboxFocus, false, flags);
591 } 601 }
592 602
593 bool ShouldReuseInstantSearchBasePage() { 603 bool ShouldReuseInstantSearchBasePage() {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 829
820 // Given a FieldTrialFlags object, returns the boolean value of the provided 830 // Given a FieldTrialFlags object, returns the boolean value of the provided
821 // flag. 831 // flag.
822 bool GetBoolValueForFlagWithDefault(const std::string& flag, 832 bool GetBoolValueForFlagWithDefault(const std::string& flag,
823 bool default_value, 833 bool default_value,
824 const FieldTrialFlags& flags) { 834 const FieldTrialFlags& flags) {
825 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); 835 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags);
826 } 836 }
827 837
828 } // namespace chrome 838 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698