OLD | NEW |
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 Loading... |
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 #if !defined(OS_IOS) && !defined(OS_ANDROID) | 68 #if !defined(OS_IOS) && !defined(OS_ANDROID) |
70 const char kEnableQueryExtractionFlagName[] = "query_extraction"; | 69 const char kEnableQueryExtractionFlagName[] = "query_extraction"; |
71 #endif | 70 #endif |
72 const char kShouldShowGoogleLocalNTPFlagName[] = "google_local_ntp"; | 71 const char kShouldShowGoogleLocalNTPFlagName[] = "google_local_ntp"; |
73 | 72 |
74 // 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 |
75 // 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. |
76 enum NewTabURLState { | 75 enum NewTabURLState { |
77 // Valid URL that should be used. | 76 // Valid URL that should be used. |
78 NEW_TAB_URL_VALID = 0, | 77 NEW_TAB_URL_VALID = 0, |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 kReuseInstantSearchBasePage, false, flags); | 573 kReuseInstantSearchBasePage, false, flags); |
575 #else | 574 #else |
576 return true; | 575 return true; |
577 #endif | 576 #endif |
578 } | 577 } |
579 | 578 |
580 GURL GetLocalInstantURL(Profile* profile) { | 579 GURL GetLocalInstantURL(Profile* profile) { |
581 return GURL(chrome::kChromeSearchLocalNtpUrl); | 580 return GURL(chrome::kChromeSearchLocalNtpUrl); |
582 } | 581 } |
583 | 582 |
584 DisplaySearchButtonConditions GetDisplaySearchButtonConditions() { | |
585 const base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); | |
586 if (cl->HasSwitch(switches::kDisableSearchButtonInOmnibox)) | |
587 return DISPLAY_SEARCH_BUTTON_NEVER; | |
588 if (cl->HasSwitch(switches::kEnableSearchButtonInOmniboxForStr)) | |
589 return DISPLAY_SEARCH_BUTTON_FOR_STR; | |
590 if (cl->HasSwitch(switches::kEnableSearchButtonInOmniboxForStrOrIip)) | |
591 return DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP; | |
592 if (cl->HasSwitch(switches::kEnableSearchButtonInOmniboxAlways)) | |
593 return DISPLAY_SEARCH_BUTTON_ALWAYS; | |
594 | |
595 FieldTrialFlags flags; | |
596 if (!GetFieldTrialInfo(&flags)) | |
597 return DISPLAY_SEARCH_BUTTON_NEVER; | |
598 uint64 value = | |
599 GetUInt64ValueForFlagWithDefault(kDisplaySearchButtonFlagName, 0, flags); | |
600 return (value < DISPLAY_SEARCH_BUTTON_NUM_VALUES) ? | |
601 static_cast<DisplaySearchButtonConditions>(value) : | |
602 DISPLAY_SEARCH_BUTTON_NEVER; | |
603 } | |
604 | |
605 bool ShouldShowGoogleLocalNTP() { | 583 bool ShouldShowGoogleLocalNTP() { |
606 FieldTrialFlags flags; | 584 FieldTrialFlags flags; |
607 return !GetFieldTrialInfo(&flags) || GetBoolValueForFlagWithDefault( | 585 return !GetFieldTrialInfo(&flags) || GetBoolValueForFlagWithDefault( |
608 kShouldShowGoogleLocalNTPFlagName, true, flags); | 586 kShouldShowGoogleLocalNTPFlagName, true, flags); |
609 } | 587 } |
610 | 588 |
611 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) { | 589 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) { |
612 CHECK(ShouldAssignURLToInstantRenderer(url, profile)) | 590 CHECK(ShouldAssignURLToInstantRenderer(url, profile)) |
613 << "Error granting Instant access."; | 591 << "Error granting Instant access."; |
614 | 592 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 kUseAltInstantURL, false, flags); | 696 kUseAltInstantURL, false, flags); |
719 } | 697 } |
720 | 698 |
721 bool ShouldUseSearchPathForInstant() { | 699 bool ShouldUseSearchPathForInstant() { |
722 FieldTrialFlags flags; | 700 FieldTrialFlags flags; |
723 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | 701 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( |
724 kUseSearchPathForInstant, false, flags); | 702 kUseSearchPathForInstant, false, flags); |
725 } | 703 } |
726 | 704 |
727 } // namespace chrome | 705 } // namespace chrome |
OLD | NEW |