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

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 gyp file and bad merge Created 5 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
« 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 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 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 FieldTrialFlags flags; 595 FieldTrialFlags flags;
597 if (!GetFieldTrialInfo(&flags)) 596 if (!GetFieldTrialInfo(&flags))
598 return DISPLAY_SEARCH_BUTTON_NEVER; 597 return DISPLAY_SEARCH_BUTTON_NEVER;
599 uint64 value = 598 uint64 value =
600 GetUInt64ValueForFlagWithDefault(kDisplaySearchButtonFlagName, 0, flags); 599 GetUInt64ValueForFlagWithDefault(kDisplaySearchButtonFlagName, 0, flags);
601 return (value < DISPLAY_SEARCH_BUTTON_NUM_VALUES) ? 600 return (value < DISPLAY_SEARCH_BUTTON_NUM_VALUES) ?
602 static_cast<DisplaySearchButtonConditions>(value) : 601 static_cast<DisplaySearchButtonConditions>(value) :
603 DISPLAY_SEARCH_BUTTON_NEVER; 602 DISPLAY_SEARCH_BUTTON_NEVER;
604 } 603 }
605 604
606 bool ShouldDisplayOriginChip() {
607 return GetOriginChipCondition() != ORIGIN_CHIP_DISABLED;
608 }
609
610 OriginChipCondition GetOriginChipCondition() {
611 const base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
612 if (cl->HasSwitch(switches::kDisableOriginChip))
613 return ORIGIN_CHIP_DISABLED;
614 if (cl->HasSwitch(switches::kEnableOriginChipAlways))
615 return ORIGIN_CHIP_ALWAYS;
616 if (cl->HasSwitch(switches::kEnableOriginChipOnSrp))
617 return ORIGIN_CHIP_ON_SRP;
618
619 FieldTrialFlags flags;
620 if (!GetFieldTrialInfo(&flags))
621 return ORIGIN_CHIP_DISABLED;
622 uint64 value =
623 GetUInt64ValueForFlagWithDefault(kOriginChipFlagName, 0, flags);
624 return (value < ORIGIN_CHIP_NUM_VALUES) ?
625 static_cast<OriginChipCondition>(value) : ORIGIN_CHIP_DISABLED;
626 }
627
628 bool ShouldShowGoogleLocalNTP() { 605 bool ShouldShowGoogleLocalNTP() {
629 FieldTrialFlags flags; 606 FieldTrialFlags flags;
630 return !GetFieldTrialInfo(&flags) || GetBoolValueForFlagWithDefault( 607 return !GetFieldTrialInfo(&flags) || GetBoolValueForFlagWithDefault(
631 kShouldShowGoogleLocalNTPFlagName, true, flags); 608 kShouldShowGoogleLocalNTPFlagName, true, flags);
632 } 609 }
633 610
634 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) { 611 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) {
635 CHECK(ShouldAssignURLToInstantRenderer(url, profile)) 612 CHECK(ShouldAssignURLToInstantRenderer(url, profile))
636 << "Error granting Instant access."; 613 << "Error granting Instant access.";
637 614
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 kUseAltInstantURL, false, flags); 718 kUseAltInstantURL, false, flags);
742 } 719 }
743 720
744 bool ShouldUseSearchPathForInstant() { 721 bool ShouldUseSearchPathForInstant() {
745 FieldTrialFlags flags; 722 FieldTrialFlags flags;
746 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( 723 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault(
747 kUseSearchPathForInstant, false, flags); 724 kUseSearchPathForInstant, false, flags);
748 } 725 }
749 726
750 } // namespace chrome 727 } // 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