OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ntp_snippets/features.h" | 5 #include "components/ntp_snippets/features.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "components/variations/variations_associated_data.h" | 8 #include "components/variations/variations_associated_data.h" |
9 | 9 |
10 namespace ntp_snippets { | 10 namespace ntp_snippets { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } | 60 } |
61 return value_as_int; | 61 return value_as_int; |
62 } | 62 } |
63 | 63 |
64 | 64 |
65 bool GetParamAsBool(const base::Feature& feature, | 65 bool GetParamAsBool(const base::Feature& feature, |
66 const std::string& param_name, | 66 const std::string& param_name, |
67 bool default_value) { | 67 bool default_value) { |
68 std::string value_as_string = | 68 std::string value_as_string = |
69 variations::GetVariationParamValueByFeature(feature, param_name); | 69 variations::GetVariationParamValueByFeature(feature, param_name); |
70 if (value_as_string == "true") | 70 if (value_as_string == "true") { |
71 return true; | 71 return true; |
72 if (value_as_string == "false") | 72 } |
| 73 if (value_as_string == "false") { |
73 return false; | 74 return false; |
| 75 } |
74 | 76 |
75 if (!value_as_string.empty()) { | 77 if (!value_as_string.empty()) { |
76 LOG(WARNING) << "Failed to parse variation param " << param_name | 78 LOG(WARNING) << "Failed to parse variation param " << param_name |
77 << " with string value " << value_as_string | 79 << " with string value " << value_as_string |
78 << " under feature " << feature.name | 80 << " under feature " << feature.name |
79 << " into a bool. Falling back to default value of " | 81 << " into a bool. Falling back to default value of " |
80 << default_value; | 82 << default_value; |
81 } | 83 } |
82 return default_value; | 84 return default_value; |
83 } | 85 } |
84 | 86 |
85 } // namespace ntp_snippets | 87 } // namespace ntp_snippets |
OLD | NEW |