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 std::string ruleset_flavor = subresource_filter::GetActiveConfigurations() | 115 const auto configurations = subresource_filter::GetActiveConfigurations(); |
| 116 ->the_one_and_only() | 116 const std::string ruleset_flavor = |
|
pkalinnikov
2017/04/26 09:20:19
nit: Why not const ref? Seems all the way the same
engedy
2017/04/26 10:00:31
No reason, I just didn't realize that a reference
| |
| 117 .ruleset_flavor; | 117 configurations->the_one_and_only().ruleset_flavor; |
| 118 if (ruleset_flavor.empty()) | 118 if (ruleset_flavor.empty()) |
| 119 return ruleset_flavor; | 119 return ruleset_flavor; |
| 120 | 120 |
| 121 // We allow 4 ruleset flavor identifiers: a, b, c, d | 121 // We allow 4 ruleset flavor identifiers: a, b, c, d |
| 122 if (ruleset_flavor.size() == 1 && ruleset_flavor.at(0) >= 'a' && | 122 if (ruleset_flavor.size() == 1 && ruleset_flavor.at(0) >= 'a' && |
| 123 ruleset_flavor.at(0) <= 'd') | 123 ruleset_flavor.at(0) <= 'd') |
|
pkalinnikov
2017/04/26 09:20:19
I vaguely remember that we had a rule to put a sta
engedy
2017/04/26 10:00:31
I, too, am unable to find it, and I could not find
| |
| 124 return ruleset_flavor; | 124 return ruleset_flavor; |
| 125 | 125 |
| 126 // Return 'invalid' for any cases where we encounter an invalid installer | 126 // Return 'invalid' for any cases where we encounter an invalid installer |
| 127 // tag. This allows us to verify that no clients are encountering invalid | 127 // tag. This allows us to verify that no clients are encountering invalid |
| 128 // installer tags in the field. | 128 // installer tags in the field. |
| 129 return "invalid"; | 129 return "invalid"; |
| 130 } | 130 } |
| 131 | 131 |
| 132 update_client::InstallerAttributes | 132 update_client::InstallerAttributes |
| 133 SubresourceFilterComponentInstallerTraits::GetInstallerAttributes() const { | 133 SubresourceFilterComponentInstallerTraits::GetInstallerAttributes() const { |
| 134 update_client::InstallerAttributes attributes; | 134 update_client::InstallerAttributes attributes; |
| 135 std::string installer_tag = GetInstallerTag(); | 135 std::string installer_tag = GetInstallerTag(); |
| 136 if (!installer_tag.empty()) | 136 if (!installer_tag.empty()) |
| 137 attributes["tag"] = installer_tag; | 137 attributes["tag"] = installer_tag; |
| 138 return attributes; | 138 return attributes; |
| 139 } | 139 } |
| 140 | 140 |
| 141 std::vector<std::string> | 141 std::vector<std::string> |
| 142 SubresourceFilterComponentInstallerTraits::GetMimeTypes() const { | 142 SubresourceFilterComponentInstallerTraits::GetMimeTypes() const { |
| 143 return std::vector<std::string>(); | 143 return std::vector<std::string>(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void RegisterSubresourceFilterComponent(ComponentUpdateService* cus) { | 146 void RegisterSubresourceFilterComponent(ComponentUpdateService* cus) { |
| 147 if (!base::FeatureList::IsEnabled( | 147 if (!base::FeatureList::IsEnabled( |
| 148 subresource_filter::kSafeBrowsingSubresourceFilter)) | 148 subresource_filter::kSafeBrowsingSubresourceFilter)) |
|
pkalinnikov
2017/04/26 09:20:18
Same as above.
engedy
2017/04/26 10:00:31
Done.
| |
| 149 return; | 149 return; |
| 150 std::unique_ptr<ComponentInstallerTraits> traits( | 150 std::unique_ptr<ComponentInstallerTraits> traits( |
| 151 new SubresourceFilterComponentInstallerTraits()); | 151 new SubresourceFilterComponentInstallerTraits()); |
| 152 // |cus| will take ownership of |installer| during installer->Register(cus). | 152 // |cus| will take ownership of |installer| during installer->Register(cus). |
| 153 DefaultComponentInstaller* installer = | 153 DefaultComponentInstaller* installer = |
| 154 new DefaultComponentInstaller(std::move(traits)); | 154 new DefaultComponentInstaller(std::move(traits)); |
| 155 installer->Register(cus, base::Closure()); | 155 installer->Register(cus, base::Closure()); |
| 156 } | 156 } |
| 157 | 157 |
| 158 } // namespace component_updater | 158 } // namespace component_updater |
| OLD | NEW |