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

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

Issue 731423002: Remove OriginChip code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad merge Created 5 years, 11 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 #endif 59 #endif
60 60
61 // Controls whether to use the alternate Instant search base URL. This allows 61 // Controls whether to use the alternate Instant search base URL. This allows
62 // experimentation of Instant search. 62 // experimentation of Instant search.
63 const char kUseAltInstantURL[] = "use_alternate_instant_url"; 63 const char kUseAltInstantURL[] = "use_alternate_instant_url";
64 const char kUseSearchPathForInstant[] = "use_search_path_for_instant"; 64 const char kUseSearchPathForInstant[] = "use_search_path_for_instant";
65 const char kAltInstantURLPath[] = "search"; 65 const char kAltInstantURLPath[] = "search";
66 const char kAltInstantURLQueryParams[] = "&qbp=1"; 66 const char kAltInstantURLQueryParams[] = "&qbp=1";
67 67
68 const char kDisplaySearchButtonFlagName[] = "display_search_button"; 68 const char kDisplaySearchButtonFlagName[] = "display_search_button";
69 const char kOriginChipFlagName[] = "origin_chip";
70 #if !defined(OS_IOS) && !defined(OS_ANDROID) 69 #if !defined(OS_IOS) && !defined(OS_ANDROID)
71 const char kEnableQueryExtractionFlagName[] = "query_extraction"; 70 const char kEnableQueryExtractionFlagName[] = "query_extraction";
72 #endif 71 #endif
73 const char kShouldShowGoogleLocalNTPFlagName[] = "google_local_ntp"; 72 const char kShouldShowGoogleLocalNTPFlagName[] = "google_local_ntp";
74 73
75 // Status of the New Tab URL for the default Search provider. NOTE: Used in a 74 // Status of the New Tab URL for the default Search provider. NOTE: Used in a
76 // UMA histogram so values should only be added at the end and not reordered. 75 // UMA histogram so values should only be added at the end and not reordered.
77 enum NewTabURLState { 76 enum NewTabURLState {
78 // Valid URL that should be used. 77 // Valid URL that should be used.
79 NEW_TAB_URL_VALID = 0, 78 NEW_TAB_URL_VALID = 0,
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 FieldTrialFlags flags; 596 FieldTrialFlags flags;
598 if (!GetFieldTrialInfo(&flags)) 597 if (!GetFieldTrialInfo(&flags))
599 return DISPLAY_SEARCH_BUTTON_NEVER; 598 return DISPLAY_SEARCH_BUTTON_NEVER;
600 uint64 value = 599 uint64 value =
601 GetUInt64ValueForFlagWithDefault(kDisplaySearchButtonFlagName, 0, flags); 600 GetUInt64ValueForFlagWithDefault(kDisplaySearchButtonFlagName, 0, flags);
602 return (value < DISPLAY_SEARCH_BUTTON_NUM_VALUES) ? 601 return (value < DISPLAY_SEARCH_BUTTON_NUM_VALUES) ?
603 static_cast<DisplaySearchButtonConditions>(value) : 602 static_cast<DisplaySearchButtonConditions>(value) :
604 DISPLAY_SEARCH_BUTTON_NEVER; 603 DISPLAY_SEARCH_BUTTON_NEVER;
605 } 604 }
606 605
607 bool ShouldDisplayOriginChip() {
608 return GetOriginChipCondition() != ORIGIN_CHIP_DISABLED;
609 }
610
611 OriginChipCondition GetOriginChipCondition() {
612 const base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
613 if (cl->HasSwitch(switches::kDisableOriginChip))
614 return ORIGIN_CHIP_DISABLED;
615 if (cl->HasSwitch(switches::kEnableOriginChipAlways))
616 return ORIGIN_CHIP_ALWAYS;
617 if (cl->HasSwitch(switches::kEnableOriginChipOnSrp))
618 return ORIGIN_CHIP_ON_SRP;
619
620 FieldTrialFlags flags;
621 if (!GetFieldTrialInfo(&flags))
622 return ORIGIN_CHIP_DISABLED;
623 uint64 value =
624 GetUInt64ValueForFlagWithDefault(kOriginChipFlagName, 0, flags);
625 return (value < ORIGIN_CHIP_NUM_VALUES) ?
626 static_cast<OriginChipCondition>(value) : ORIGIN_CHIP_DISABLED;
627 }
628
629 bool ShouldShowGoogleLocalNTP() { 606 bool ShouldShowGoogleLocalNTP() {
630 FieldTrialFlags flags; 607 FieldTrialFlags flags;
631 return !GetFieldTrialInfo(&flags) || GetBoolValueForFlagWithDefault( 608 return !GetFieldTrialInfo(&flags) || GetBoolValueForFlagWithDefault(
632 kShouldShowGoogleLocalNTPFlagName, true, flags); 609 kShouldShowGoogleLocalNTPFlagName, true, flags);
633 } 610 }
634 611
635 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) { 612 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) {
636 CHECK(ShouldAssignURLToInstantRenderer(url, profile)) 613 CHECK(ShouldAssignURLToInstantRenderer(url, profile))
637 << "Error granting Instant access."; 614 << "Error granting Instant access.";
638 615
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 kUseAltInstantURL, false, flags); 719 kUseAltInstantURL, false, flags);
743 } 720 }
744 721
745 bool ShouldUseSearchPathForInstant() { 722 bool ShouldUseSearchPathForInstant() {
746 FieldTrialFlags flags; 723 FieldTrialFlags flags;
747 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( 724 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault(
748 kUseSearchPathForInstant, false, flags); 725 kUseSearchPathForInstant, false, flags);
749 } 726 }
750 727
751 } // namespace chrome 728 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698