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

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

Issue 266263002: [OriginChip] Add an option to display only on search result pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to comments Created 6 years, 7 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 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 if (!GetFieldTrialInfo(&flags)) 645 if (!GetFieldTrialInfo(&flags))
646 return ORIGIN_CHIP_DISABLED; 646 return ORIGIN_CHIP_DISABLED;
647 uint64 value = 647 uint64 value =
648 GetUInt64ValueForFlagWithDefault(kOriginChipFlagName, 0, flags); 648 GetUInt64ValueForFlagWithDefault(kOriginChipFlagName, 0, flags);
649 return (value < ORIGIN_CHIP_NUM_VALUES) ? 649 return (value < ORIGIN_CHIP_NUM_VALUES) ?
650 static_cast<OriginChipPosition>(value) : 650 static_cast<OriginChipPosition>(value) :
651 ORIGIN_CHIP_DISABLED; 651 ORIGIN_CHIP_DISABLED;
652 } 652 }
653 653
654 bool ShouldDisplayOriginChipV2() { 654 bool ShouldDisplayOriginChipV2() {
655 return GetOriginChipV2HideTrigger() != ORIGIN_CHIP_V2_DISABLED; 655 return GetOriginChipV2Condition() != ORIGIN_CHIP_V2_DISABLED;
656 } 656 }
657 657
658 OriginChipV2HideTrigger GetOriginChipV2HideTrigger() { 658 OriginChipV2Condition GetOriginChipV2Condition() {
659 const CommandLine* cl = CommandLine::ForCurrentProcess(); 659 const CommandLine* cl = CommandLine::ForCurrentProcess();
660 if (cl->HasSwitch(switches::kDisableOriginChipV2)) 660 if (cl->HasSwitch(switches::kDisableOriginChipV2))
661 return ORIGIN_CHIP_V2_DISABLED; 661 return ORIGIN_CHIP_V2_DISABLED;
662 if (cl->HasSwitch(switches::kEnableOriginChipV2HideOnMouseRelease)) 662 if (cl->HasSwitch(switches::kEnableOriginChipV2HideOnMouseRelease))
663 return ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE; 663 return ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE;
664 if (cl->HasSwitch(switches::kEnableOriginChipV2HideOnUserInput)) 664 if (cl->HasSwitch(switches::kEnableOriginChipV2HideOnUserInput))
665 return ORIGIN_CHIP_V2_HIDE_ON_USER_INPUT; 665 return ORIGIN_CHIP_V2_HIDE_ON_USER_INPUT;
666 if (cl->HasSwitch(switches::kEnableOriginChipV2OnSrp))
667 return ORIGIN_CHIP_V2_ON_SRP;
666 668
667 FieldTrialFlags flags; 669 FieldTrialFlags flags;
668 if (!GetFieldTrialInfo(&flags)) 670 if (!GetFieldTrialInfo(&flags))
669 return ORIGIN_CHIP_V2_DISABLED; 671 return ORIGIN_CHIP_V2_DISABLED;
670 uint64 value = 672 uint64 value =
671 GetUInt64ValueForFlagWithDefault(kOriginChipV2FlagName, 0, flags); 673 GetUInt64ValueForFlagWithDefault(kOriginChipV2FlagName, 0, flags);
672 return (value < ORIGIN_CHIP_V2_NUM_VALUES) ? 674 return (value < ORIGIN_CHIP_V2_NUM_VALUES) ?
673 static_cast<OriginChipV2HideTrigger>(value) : 675 static_cast<OriginChipV2Condition>(value) :
674 ORIGIN_CHIP_V2_DISABLED; 676 ORIGIN_CHIP_V2_DISABLED;
675 } 677 }
676 678
677 bool ShouldShowGoogleLocalNTP() { 679 bool ShouldShowGoogleLocalNTP() {
678 FieldTrialFlags flags; 680 FieldTrialFlags flags;
679 return !GetFieldTrialInfo(&flags) || GetBoolValueForFlagWithDefault( 681 return !GetFieldTrialInfo(&flags) || GetBoolValueForFlagWithDefault(
680 kShouldShowGoogleLocalNTPFlagName, true, flags); 682 kShouldShowGoogleLocalNTPFlagName, true, flags);
681 } 683 }
682 684
683 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) { 685 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 843
842 // Given a FieldTrialFlags object, returns the boolean value of the provided 844 // Given a FieldTrialFlags object, returns the boolean value of the provided
843 // flag. 845 // flag.
844 bool GetBoolValueForFlagWithDefault(const std::string& flag, 846 bool GetBoolValueForFlagWithDefault(const std::string& flag,
845 bool default_value, 847 bool default_value,
846 const FieldTrialFlags& flags) { 848 const FieldTrialFlags& flags) {
847 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); 849 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags);
848 } 850 }
849 851
850 } // namespace chrome 852 } // 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