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 (EndsWith(group_name, kDisablingSuffix, true)) | 93 if (base::EndsWith(group_name, kDisablingSuffix, true)) |
94 return false; | 94 return false; |
95 | 95 |
96 // 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. |
97 std::string group_prefix(group_name); | 97 std::string group_prefix(group_name); |
98 size_t first_space = group_name.find(" "); | 98 size_t first_space = group_name.find(" "); |
99 if (first_space != std::string::npos) { | 99 if (first_space != std::string::npos) { |
100 // 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. |
101 group_prefix = group_name.substr(0, first_space); | 101 group_prefix = group_name.substr(0, first_space); |
102 if (!base::SplitStringIntoKeyValuePairs(group_name.substr(first_space), | 102 if (!base::SplitStringIntoKeyValuePairs(group_name.substr(first_space), |
103 ':', ' ', flags)) { | 103 ':', ' ', flags)) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 137 |
138 // Given a FieldTrialFlags object, returns the boolean value of the provided | 138 // Given a FieldTrialFlags object, returns the boolean value of the provided |
139 // flag. | 139 // flag. |
140 bool GetBoolValueForFlagWithDefault(const std::string& flag, | 140 bool GetBoolValueForFlagWithDefault(const std::string& flag, |
141 bool default_value, | 141 bool default_value, |
142 const FieldTrialFlags& flags) { | 142 const FieldTrialFlags& flags) { |
143 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); | 143 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); |
144 } | 144 } |
145 | 145 |
146 } // namespace chrome | 146 } // namespace chrome |
OLD | NEW |