OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/search/search.h" | 5 #include "components/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/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 bool GetFieldTrialInfo(FieldTrialFlags* flags) { | 83 bool GetFieldTrialInfo(FieldTrialFlags* flags) { |
84 // Get the group name. If the EmbeddedSearch trial doesn't exist, look for | 84 // Get the group name. If the EmbeddedSearch trial doesn't exist, look for |
85 // the older InstantExtended name. | 85 // the older InstantExtended name. |
86 std::string group_name = base::FieldTrialList::FindFullName( | 86 std::string group_name = base::FieldTrialList::FindFullName( |
87 kEmbeddedSearchFieldTrialName); | 87 kEmbeddedSearchFieldTrialName); |
88 if (group_name.empty()) { | 88 if (group_name.empty()) { |
89 group_name = base::FieldTrialList::FindFullName( | 89 group_name = base::FieldTrialList::FindFullName( |
90 kInstantExtendedFieldTrialName); | 90 kInstantExtendedFieldTrialName); |
91 } | 91 } |
92 | 92 |
93 if (base::EndsWith(group_name, kDisablingSuffix, | 93 if (base::EndsWith(group_name, kDisablingSuffix, true)) |
94 base::CompareCase::SENSITIVE)) | |
95 return false; | 94 return false; |
96 | 95 |
97 // We have a valid trial that isn't disabled. Extract the flags. | 96 // We have a valid trial that isn't disabled. Extract the flags. |
98 std::string group_prefix(group_name); | 97 std::string group_prefix(group_name); |
99 size_t first_space = group_name.find(" "); | 98 size_t first_space = group_name.find(" "); |
100 if (first_space != std::string::npos) { | 99 if (first_space != std::string::npos) { |
101 // There is a flags section of the group name. Split that out and parse it. | 100 // There is a flags section of the group name. Split that out and parse it. |
102 group_prefix = group_name.substr(0, first_space); | 101 group_prefix = group_name.substr(0, first_space); |
103 if (!base::SplitStringIntoKeyValuePairs(group_name.substr(first_space), | 102 if (!base::SplitStringIntoKeyValuePairs(group_name.substr(first_space), |
104 ':', ' ', flags)) { | 103 ':', ' ', flags)) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 137 |
139 // Given a FieldTrialFlags object, returns the boolean value of the provided | 138 // Given a FieldTrialFlags object, returns the boolean value of the provided |
140 // flag. | 139 // flag. |
141 bool GetBoolValueForFlagWithDefault(const std::string& flag, | 140 bool GetBoolValueForFlagWithDefault(const std::string& flag, |
142 bool default_value, | 141 bool default_value, |
143 const FieldTrialFlags& flags) { | 142 const FieldTrialFlags& flags) { |
144 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); | 143 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); |
145 } | 144 } |
146 | 145 |
147 } // namespace chrome | 146 } // namespace chrome |
OLD | NEW |