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

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

Issue 768413003: TEST ONLY - DO NOT SUBMIT - FOR TRYBOTS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 const char kReuseInstantSearchBasePage[] = "reuse_instant_search_base_page"; 58 const char kReuseInstantSearchBasePage[] = "reuse_instant_search_base_page";
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";
69 const char kOriginChipFlagName[] = "origin_chip";
70 #if !defined(OS_IOS) && !defined(OS_ANDROID) 68 #if !defined(OS_IOS) && !defined(OS_ANDROID)
71 const char kEnableQueryExtractionFlagName[] = "query_extraction"; 69 const char kEnableQueryExtractionFlagName[] = "query_extraction";
72 #endif 70 #endif
73 const char kShouldShowGoogleLocalNTPFlagName[] = "google_local_ntp"; 71 const char kShouldShowGoogleLocalNTPFlagName[] = "google_local_ntp";
74 72
75 // Status of the New Tab URL for the default Search provider. NOTE: Used in a 73 // 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. 74 // UMA histogram so values should only be added at the end and not reordered.
77 enum NewTabURLState { 75 enum NewTabURLState {
78 // Valid URL that should be used. 76 // Valid URL that should be used.
79 NEW_TAB_URL_VALID = 0, 77 NEW_TAB_URL_VALID = 0,
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 kReuseInstantSearchBasePage, false, flags); 573 kReuseInstantSearchBasePage, false, flags);
576 #else 574 #else
577 return true; 575 return true;
578 #endif 576 #endif
579 } 577 }
580 578
581 GURL GetLocalInstantURL(Profile* profile) { 579 GURL GetLocalInstantURL(Profile* profile) {
582 return GURL(chrome::kChromeSearchLocalNtpUrl); 580 return GURL(chrome::kChromeSearchLocalNtpUrl);
583 } 581 }
584 582
585 DisplaySearchButtonConditions GetDisplaySearchButtonConditions() {
586 const CommandLine* cl = CommandLine::ForCurrentProcess();
587 if (cl->HasSwitch(switches::kDisableSearchButtonInOmnibox))
588 return DISPLAY_SEARCH_BUTTON_NEVER;
589 if (cl->HasSwitch(switches::kEnableSearchButtonInOmniboxForStr))
590 return DISPLAY_SEARCH_BUTTON_FOR_STR;
591 if (cl->HasSwitch(switches::kEnableSearchButtonInOmniboxForStrOrIip))
592 return DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP;
593 if (cl->HasSwitch(switches::kEnableSearchButtonInOmniboxAlways))
594 return DISPLAY_SEARCH_BUTTON_ALWAYS;
595
596 FieldTrialFlags flags;
597 if (!GetFieldTrialInfo(&flags))
598 return DISPLAY_SEARCH_BUTTON_NEVER;
599 uint64 value =
600 GetUInt64ValueForFlagWithDefault(kDisplaySearchButtonFlagName, 0, flags);
601 return (value < DISPLAY_SEARCH_BUTTON_NUM_VALUES) ?
602 static_cast<DisplaySearchButtonConditions>(value) :
603 DISPLAY_SEARCH_BUTTON_NEVER;
604 }
605
606 bool ShouldDisplayOriginChip() {
607 return GetOriginChipCondition() != ORIGIN_CHIP_DISABLED;
608 }
609
610 OriginChipCondition GetOriginChipCondition() {
611 const CommandLine* cl = 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() { 583 bool ShouldShowGoogleLocalNTP() {
629 FieldTrialFlags flags; 584 FieldTrialFlags flags;
630 return !GetFieldTrialInfo(&flags) || GetBoolValueForFlagWithDefault( 585 return !GetFieldTrialInfo(&flags) || GetBoolValueForFlagWithDefault(
631 kShouldShowGoogleLocalNTPFlagName, true, flags); 586 kShouldShowGoogleLocalNTPFlagName, true, flags);
632 } 587 }
633 588
634 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) { 589 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) {
635 CHECK(ShouldAssignURLToInstantRenderer(url, profile)) 590 CHECK(ShouldAssignURLToInstantRenderer(url, profile))
636 << "Error granting Instant access."; 591 << "Error granting Instant access.";
637 592
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 kUseAltInstantURL, false, flags); 696 kUseAltInstantURL, false, flags);
742 } 697 }
743 698
744 bool ShouldUseSearchPathForInstant() { 699 bool ShouldUseSearchPathForInstant() {
745 FieldTrialFlags flags; 700 FieldTrialFlags flags;
746 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( 701 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault(
747 kUseSearchPathForInstant, false, flags); 702 kUseSearchPathForInstant, false, flags);
748 } 703 }
749 704
750 } // namespace chrome 705 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698