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

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

Issue 287543002: Remove origin chip v1 and "hide on input" v2 behavior. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 69
70 // Controls whether to reuse prerendered Instant Search base page to commit any 70 // Controls whether to reuse prerendered Instant Search base page to commit any
71 // search query. 71 // search query.
72 const char kReuseInstantSearchBasePage[] = "reuse_instant_search_base_page"; 72 const char kReuseInstantSearchBasePage[] = "reuse_instant_search_base_page";
73 73
74 const char kDisplaySearchButtonFlagName[] = "display_search_button"; 74 const char kDisplaySearchButtonFlagName[] = "display_search_button";
75 const char kOriginChipFlagName[] = "origin_chip"; 75 const char kOriginChipFlagName[] = "origin_chip";
76 const char kOriginChipV2FlagName[] = "origin_chip_v2";
77 #if !defined(OS_IOS) && !defined(OS_ANDROID) 76 #if !defined(OS_IOS) && !defined(OS_ANDROID)
78 const char kEnableQueryExtractionFlagName[] = "query_extraction"; 77 const char kEnableQueryExtractionFlagName[] = "query_extraction";
79 #endif 78 #endif
80 const char kShouldShowGoogleLocalNTPFlagName[] = "google_local_ntp"; 79 const char kShouldShowGoogleLocalNTPFlagName[] = "google_local_ntp";
81 80
82 // Constants for the field trial name and group prefix. 81 // Constants for the field trial name and group prefix.
83 // Note in M30 and below this field trial was named "InstantExtended" and in 82 // Note in M30 and below this field trial was named "InstantExtended" and in
84 // M31 was renamed to EmbeddedSearch for clarity and cleanliness. Since we 83 // M31 was renamed to EmbeddedSearch for clarity and cleanliness. Since we
85 // can't easilly sync up Finch configs with the pushing of this change to 84 // can't easilly sync up Finch configs with the pushing of this change to
86 // Dev & Canary, for now the code accepts both names. 85 // Dev & Canary, for now the code accepts both names.
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 if (!GetFieldTrialInfo(&flags)) 615 if (!GetFieldTrialInfo(&flags))
617 return DISPLAY_SEARCH_BUTTON_NEVER; 616 return DISPLAY_SEARCH_BUTTON_NEVER;
618 uint64 value = 617 uint64 value =
619 GetUInt64ValueForFlagWithDefault(kDisplaySearchButtonFlagName, 0, flags); 618 GetUInt64ValueForFlagWithDefault(kDisplaySearchButtonFlagName, 0, flags);
620 return (value < DISPLAY_SEARCH_BUTTON_NUM_VALUES) ? 619 return (value < DISPLAY_SEARCH_BUTTON_NUM_VALUES) ?
621 static_cast<DisplaySearchButtonConditions>(value) : 620 static_cast<DisplaySearchButtonConditions>(value) :
622 DISPLAY_SEARCH_BUTTON_NEVER; 621 DISPLAY_SEARCH_BUTTON_NEVER;
623 } 622 }
624 623
625 bool ShouldDisplayOriginChip() { 624 bool ShouldDisplayOriginChip() {
626 return GetOriginChipPosition() != ORIGIN_CHIP_DISABLED; 625 return GetOriginChipCondition() != ORIGIN_CHIP_DISABLED;
627 } 626 }
628 627
629 OriginChipPosition GetOriginChipPosition() { 628 OriginChipCondition GetOriginChipCondition() {
630 if (ShouldDisplayOriginChipV2())
631 return ORIGIN_CHIP_DISABLED;
632
633 const CommandLine* cl = CommandLine::ForCurrentProcess(); 629 const CommandLine* cl = CommandLine::ForCurrentProcess();
634 if (cl->HasSwitch(switches::kDisableOriginChip)) 630 if (cl->HasSwitch(switches::kDisableOriginChip))
635 return ORIGIN_CHIP_DISABLED; 631 return ORIGIN_CHIP_DISABLED;
636 if (cl->HasSwitch(switches::kEnableOriginChipLeadingLocationBar)) 632 if (cl->HasSwitch(switches::kEnableOriginChipAlways))
637 return ORIGIN_CHIP_LEADING_LOCATION_BAR; 633 return ORIGIN_CHIP_ALWAYS;
638 if (cl->HasSwitch(switches::kEnableOriginChip) || 634 if (cl->HasSwitch(switches::kEnableOriginChipOnSrp))
639 cl->HasSwitch(switches::kEnableOriginChipTrailingLocationBar)) 635 return ORIGIN_CHIP_ON_SRP;
640 return ORIGIN_CHIP_TRAILING_LOCATION_BAR;
641 if (cl->HasSwitch(switches::kEnableOriginChipLeadingMenuButton))
642 return ORIGIN_CHIP_LEADING_MENU_BUTTON;
643 636
644 FieldTrialFlags flags; 637 FieldTrialFlags flags;
645 if (!GetFieldTrialInfo(&flags)) 638 if (!GetFieldTrialInfo(&flags))
646 return ORIGIN_CHIP_DISABLED; 639 return ORIGIN_CHIP_DISABLED;
647 uint64 value = 640 uint64 value =
648 GetUInt64ValueForFlagWithDefault(kOriginChipFlagName, 0, flags); 641 GetUInt64ValueForFlagWithDefault(kOriginChipFlagName, 0, flags);
649 return (value < ORIGIN_CHIP_NUM_VALUES) ? 642 return (value < ORIGIN_CHIP_NUM_VALUES) ?
650 static_cast<OriginChipPosition>(value) : 643 static_cast<OriginChipCondition>(value) : ORIGIN_CHIP_DISABLED;
651 ORIGIN_CHIP_DISABLED;
652 }
653
654 bool ShouldDisplayOriginChipV2() {
655 return GetOriginChipV2Condition() != ORIGIN_CHIP_V2_DISABLED;
656 }
657
658 OriginChipV2Condition GetOriginChipV2Condition() {
659 const CommandLine* cl = CommandLine::ForCurrentProcess();
660 if (cl->HasSwitch(switches::kDisableOriginChipV2))
661 return ORIGIN_CHIP_V2_DISABLED;
662 if (cl->HasSwitch(switches::kEnableOriginChipV2HideOnMouseRelease))
663 return ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE;
664 if (cl->HasSwitch(switches::kEnableOriginChipV2HideOnUserInput))
665 return ORIGIN_CHIP_V2_HIDE_ON_USER_INPUT;
666 if (cl->HasSwitch(switches::kEnableOriginChipV2OnSrp))
667 return ORIGIN_CHIP_V2_ON_SRP;
668
669 FieldTrialFlags flags;
670 if (!GetFieldTrialInfo(&flags))
671 return ORIGIN_CHIP_V2_DISABLED;
672 uint64 value =
673 GetUInt64ValueForFlagWithDefault(kOriginChipV2FlagName, 0, flags);
674 return (value < ORIGIN_CHIP_V2_NUM_VALUES) ?
675 static_cast<OriginChipV2Condition>(value) :
676 ORIGIN_CHIP_V2_DISABLED;
677 } 644 }
678 645
679 bool ShouldShowGoogleLocalNTP() { 646 bool ShouldShowGoogleLocalNTP() {
680 FieldTrialFlags flags; 647 FieldTrialFlags flags;
681 return !GetFieldTrialInfo(&flags) || GetBoolValueForFlagWithDefault( 648 return !GetFieldTrialInfo(&flags) || GetBoolValueForFlagWithDefault(
682 kShouldShowGoogleLocalNTPFlagName, true, flags); 649 kShouldShowGoogleLocalNTPFlagName, true, flags);
683 } 650 }
684 651
685 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) { 652 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) {
686 CHECK(ShouldAssignURLToInstantRenderer(url, profile)) 653 CHECK(ShouldAssignURLToInstantRenderer(url, profile))
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 810
844 // Given a FieldTrialFlags object, returns the boolean value of the provided 811 // Given a FieldTrialFlags object, returns the boolean value of the provided
845 // flag. 812 // flag.
846 bool GetBoolValueForFlagWithDefault(const std::string& flag, 813 bool GetBoolValueForFlagWithDefault(const std::string& flag,
847 bool default_value, 814 bool default_value,
848 const FieldTrialFlags& flags) { 815 const FieldTrialFlags& flags) {
849 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); 816 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags);
850 } 817 }
851 818
852 } // namespace chrome 819 } // 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