Chromium Code Reviews| 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 ->GetMostSpecificRulesetFlavor(); |
| 118 | |
| 118 if (ruleset_flavor.empty()) | 119 if (ruleset_flavor.empty()) |
| 119 return ruleset_flavor; | 120 return ruleset_flavor; |
| 120 | 121 |
| 121 // We allow 4 ruleset flavor identifiers: a, b, c, d | 122 // In addition to "", we allow 4 ruleset flavor identifiers: a, b, c, d. |
|
Charlie Harrison
2017/05/03 14:52:17
Move this comment above the empty() check.
engedy
2017/05/05 12:25:41
Done.
| |
| 122 if (ruleset_flavor.size() == 1 && ruleset_flavor.at(0) >= 'a' && | 123 if (ruleset_flavor.size() == 1 && ruleset_flavor.at(0) >= 'a' && |
| 123 ruleset_flavor.at(0) <= 'd') { | 124 ruleset_flavor.at(0) <= 'd') { |
| 124 return ruleset_flavor; | 125 return ruleset_flavor; |
| 125 } | 126 } |
| 126 | 127 |
| 127 // Return 'invalid' for any cases where we encounter an invalid installer | 128 // Return 'invalid' for any cases where we encounter an invalid installer |
| 128 // tag. This allows us to verify that no clients are encountering invalid | 129 // tag. This allows us to verify that no clients are encountering invalid |
| 129 // installer tags in the field. | 130 // installer tags in the field. |
| 130 return "invalid"; | 131 return "invalid"; |
| 131 } | 132 } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 151 } | 152 } |
| 152 std::unique_ptr<ComponentInstallerTraits> traits( | 153 std::unique_ptr<ComponentInstallerTraits> traits( |
| 153 new SubresourceFilterComponentInstallerTraits()); | 154 new SubresourceFilterComponentInstallerTraits()); |
| 154 // |cus| will take ownership of |installer| during installer->Register(cus). | 155 // |cus| will take ownership of |installer| during installer->Register(cus). |
| 155 DefaultComponentInstaller* installer = | 156 DefaultComponentInstaller* installer = |
| 156 new DefaultComponentInstaller(std::move(traits)); | 157 new DefaultComponentInstaller(std::move(traits)); |
| 157 installer->Register(cus, base::Closure()); | 158 installer->Register(cus, base::Closure()); |
| 158 } | 159 } |
| 159 | 160 |
| 160 } // namespace component_updater | 161 } // namespace component_updater |
| OLD | NEW |