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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 const char kPrefetchSearchResultsFlagName[] = "prefetch_results"; | 54 const char kPrefetchSearchResultsFlagName[] = "prefetch_results"; |
55 | 55 |
56 // Controls whether to reuse prerendered Instant Search base page to commit any | 56 // Controls whether to reuse prerendered Instant Search base page to commit any |
57 // search query. | 57 // search query. |
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 kAltInstantURLPath[] = "search"; | |
65 const char kAltInstantURLQueryParams[] = "&qbp=1"; | 64 const char kAltInstantURLQueryParams[] = "&qbp=1"; |
66 | 65 |
67 const char kDisplaySearchButtonFlagName[] = "display_search_button"; | 66 const char kDisplaySearchButtonFlagName[] = "display_search_button"; |
68 const char kOriginChipFlagName[] = "origin_chip"; | 67 const char kOriginChipFlagName[] = "origin_chip"; |
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 |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 const std::string secure_scheme(url::kHttpsScheme); | 486 const std::string secure_scheme(url::kHttpsScheme); |
488 replacements.SetSchemeStr(secure_scheme); | 487 replacements.SetSchemeStr(secure_scheme); |
489 instant_url = instant_url.ReplaceComponents(replacements); | 488 instant_url = instant_url.ReplaceComponents(replacements); |
490 } | 489 } |
491 | 490 |
492 if (!IsURLAllowedForSupervisedUser(instant_url, profile)) | 491 if (!IsURLAllowedForSupervisedUser(instant_url, profile)) |
493 return GURL(); | 492 return GURL(); |
494 | 493 |
495 if (ShouldUseAltInstantURL()) { | 494 if (ShouldUseAltInstantURL()) { |
496 GURL::Replacements replacements; | 495 GURL::Replacements replacements; |
497 const std::string path(kAltInstantURLPath); | |
498 replacements.SetPathStr(path); | |
499 const std::string query( | 496 const std::string query( |
500 instant_url.query() + std::string(kAltInstantURLQueryParams)); | 497 instant_url.query() + std::string(kAltInstantURLQueryParams)); |
501 replacements.SetQueryStr(query); | 498 replacements.SetQueryStr(query); |
502 instant_url = instant_url.ReplaceComponents(replacements); | 499 instant_url = instant_url.ReplaceComponents(replacements); |
503 } | 500 } |
504 return instant_url; | 501 return instant_url; |
505 } | 502 } |
506 | 503 |
507 // Returns URLs associated with the default search engine for |profile|. | 504 // Returns URLs associated with the default search engine for |profile|. |
508 std::vector<GURL> GetSearchURLs(Profile* profile) { | 505 std::vector<GURL> GetSearchURLs(Profile* profile) { |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 cl->AppendSwitch(switches::kEnableQueryExtraction); | 729 cl->AppendSwitch(switches::kEnableQueryExtraction); |
733 } | 730 } |
734 | 731 |
735 bool ShouldUseAltInstantURL() { | 732 bool ShouldUseAltInstantURL() { |
736 FieldTrialFlags flags; | 733 FieldTrialFlags flags; |
737 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | 734 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( |
738 kUseAltInstantURL, false, flags); | 735 kUseAltInstantURL, false, flags); |
739 } | 736 } |
740 | 737 |
741 } // namespace chrome | 738 } // namespace chrome |
OLD | NEW |