| 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/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 const char kDisablingSuffix[] = "DISABLED"; | 89 const char kDisablingSuffix[] = "DISABLED"; |
| 90 | 90 |
| 91 // Used to set the Instant support state of the Navigation entry. | 91 // Used to set the Instant support state of the Navigation entry. |
| 92 const char kInstantSupportStateKey[] = "instant_support_state"; | 92 const char kInstantSupportStateKey[] = "instant_support_state"; |
| 93 | 93 |
| 94 const char kInstantSupportEnabled[] = "Instant support enabled"; | 94 const char kInstantSupportEnabled[] = "Instant support enabled"; |
| 95 const char kInstantSupportDisabled[] = "Instant support disabled"; | 95 const char kInstantSupportDisabled[] = "Instant support disabled"; |
| 96 const char kInstantSupportUnknown[] = "Instant support unknown"; | 96 const char kInstantSupportUnknown[] = "Instant support unknown"; |
| 97 | 97 |
| 98 InstantSupportState StringToInstantSupportState(const base::string16& value) { | 98 InstantSupportState StringToInstantSupportState(const base::string16& value) { |
| 99 if (value == ASCIIToUTF16(kInstantSupportEnabled)) | 99 if (value == base::ASCIIToUTF16(kInstantSupportEnabled)) |
| 100 return INSTANT_SUPPORT_YES; | 100 return INSTANT_SUPPORT_YES; |
| 101 else if (value == ASCIIToUTF16(kInstantSupportDisabled)) | 101 else if (value == base::ASCIIToUTF16(kInstantSupportDisabled)) |
| 102 return INSTANT_SUPPORT_NO; | 102 return INSTANT_SUPPORT_NO; |
| 103 else | 103 else |
| 104 return INSTANT_SUPPORT_UNKNOWN; | 104 return INSTANT_SUPPORT_UNKNOWN; |
| 105 } | 105 } |
| 106 | 106 |
| 107 base::string16 InstantSupportStateToString(InstantSupportState state) { | 107 base::string16 InstantSupportStateToString(InstantSupportState state) { |
| 108 switch (state) { | 108 switch (state) { |
| 109 case INSTANT_SUPPORT_NO: | 109 case INSTANT_SUPPORT_NO: |
| 110 return ASCIIToUTF16(kInstantSupportDisabled); | 110 return base::ASCIIToUTF16(kInstantSupportDisabled); |
| 111 case INSTANT_SUPPORT_YES: | 111 case INSTANT_SUPPORT_YES: |
| 112 return ASCIIToUTF16(kInstantSupportEnabled); | 112 return base::ASCIIToUTF16(kInstantSupportEnabled); |
| 113 case INSTANT_SUPPORT_UNKNOWN: | 113 case INSTANT_SUPPORT_UNKNOWN: |
| 114 return ASCIIToUTF16(kInstantSupportUnknown); | 114 return base::ASCIIToUTF16(kInstantSupportUnknown); |
| 115 } | 115 } |
| 116 return ASCIIToUTF16(kInstantSupportUnknown); | 116 return base::ASCIIToUTF16(kInstantSupportUnknown); |
| 117 } | 117 } |
| 118 | 118 |
| 119 TemplateURL* GetDefaultSearchProviderTemplateURL(Profile* profile) { | 119 TemplateURL* GetDefaultSearchProviderTemplateURL(Profile* profile) { |
| 120 TemplateURLService* template_url_service = | 120 TemplateURLService* template_url_service = |
| 121 TemplateURLServiceFactory::GetForProfile(profile); | 121 TemplateURLServiceFactory::GetForProfile(profile); |
| 122 if (template_url_service) | 122 if (template_url_service) |
| 123 return template_url_service->GetDefaultSearchProvider(); | 123 return template_url_service->GetDefaultSearchProvider(); |
| 124 return NULL; | 124 return NULL; |
| 125 } | 125 } |
| 126 | 126 |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 | 747 |
| 748 // Given a FieldTrialFlags object, returns the boolean value of the provided | 748 // Given a FieldTrialFlags object, returns the boolean value of the provided |
| 749 // flag. | 749 // flag. |
| 750 bool GetBoolValueForFlagWithDefault(const std::string& flag, | 750 bool GetBoolValueForFlagWithDefault(const std::string& flag, |
| 751 bool default_value, | 751 bool default_value, |
| 752 const FieldTrialFlags& flags) { | 752 const FieldTrialFlags& flags) { |
| 753 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); | 753 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); |
| 754 } | 754 } |
| 755 | 755 |
| 756 } // namespace chrome | 756 } // namespace chrome |
| OLD | NEW |