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 "chrome/browser/component_updater/subresource_filter_component_installe
r.h" | 5 #include "chrome/browser/component_updater/subresource_filter_component_installe
r.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 std::vector<uint8_t>* hash) const { | 105 std::vector<uint8_t>* hash) const { |
106 hash->assign(std::begin(kPublicKeySHA256), std::end(kPublicKeySHA256)); | 106 hash->assign(std::begin(kPublicKeySHA256), std::end(kPublicKeySHA256)); |
107 } | 107 } |
108 | 108 |
109 std::string SubresourceFilterComponentInstallerTraits::GetName() const { | 109 std::string SubresourceFilterComponentInstallerTraits::GetName() const { |
110 return kSubresourceFilterSetFetcherManifestName; | 110 return kSubresourceFilterSetFetcherManifestName; |
111 } | 111 } |
112 | 112 |
113 // static | 113 // static |
114 std::string SubresourceFilterComponentInstallerTraits::GetInstallerTag() { | 114 std::string SubresourceFilterComponentInstallerTraits::GetInstallerTag() { |
115 const auto configurations = subresource_filter::GetActiveConfigurations(); | 115 const std::string ruleset_flavor = |
116 const std::string& ruleset_flavor = | 116 subresource_filter::GetEnabledConfigurations() |
117 configurations->the_one_and_only().ruleset_flavor; | 117 ->lexicographically_greatest_ruleset_flavor() |
| 118 .as_string(); |
| 119 |
| 120 // Allow the empty, and 4 non-empty ruleset flavor identifiers: a, b, c, d. |
118 if (ruleset_flavor.empty()) | 121 if (ruleset_flavor.empty()) |
119 return ruleset_flavor; | 122 return ruleset_flavor; |
120 | 123 |
121 // We allow 4 ruleset flavor identifiers: a, b, c, d | |
122 if (ruleset_flavor.size() == 1 && ruleset_flavor.at(0) >= 'a' && | 124 if (ruleset_flavor.size() == 1 && ruleset_flavor.at(0) >= 'a' && |
123 ruleset_flavor.at(0) <= 'd') { | 125 ruleset_flavor.at(0) <= 'd') { |
124 return ruleset_flavor; | 126 return ruleset_flavor; |
125 } | 127 } |
126 | 128 |
127 // Return 'invalid' for any cases where we encounter an invalid installer | 129 // Return 'invalid' for any cases where we encounter an invalid installer |
128 // tag. This allows us to verify that no clients are encountering invalid | 130 // tag. This allows us to verify that no clients are encountering invalid |
129 // installer tags in the field. | 131 // installer tags in the field. |
130 return "invalid"; | 132 return "invalid"; |
131 } | 133 } |
(...skipping 19 matching lines...) Expand all Loading... |
151 } | 153 } |
152 std::unique_ptr<ComponentInstallerTraits> traits( | 154 std::unique_ptr<ComponentInstallerTraits> traits( |
153 new SubresourceFilterComponentInstallerTraits()); | 155 new SubresourceFilterComponentInstallerTraits()); |
154 // |cus| will take ownership of |installer| during installer->Register(cus). | 156 // |cus| will take ownership of |installer| during installer->Register(cus). |
155 DefaultComponentInstaller* installer = | 157 DefaultComponentInstaller* installer = |
156 new DefaultComponentInstaller(std::move(traits)); | 158 new DefaultComponentInstaller(std::move(traits)); |
157 installer->Register(cus, base::Closure()); | 159 installer->Register(cus, base::Closure()); |
158 } | 160 } |
159 | 161 |
160 } // namespace component_updater | 162 } // namespace component_updater |
OLD | NEW |