| 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" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/version.h" | 12 #include "base/version.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "components/component_updater/component_updater_paths.h" | 14 #include "components/component_updater/component_updater_paths.h" |
| 15 #include "components/subresource_filter/content/browser/content_ruleset_service.
h" |
| 15 #include "components/subresource_filter/core/browser/ruleset_service.h" | 16 #include "components/subresource_filter/core/browser/ruleset_service.h" |
| 16 #include "components/subresource_filter/core/browser/subresource_filter_constant
s.h" | 17 #include "components/subresource_filter/core/browser/subresource_filter_constant
s.h" |
| 17 #include "components/subresource_filter/core/browser/subresource_filter_features
.h" | 18 #include "components/subresource_filter/core/browser/subresource_filter_features
.h" |
| 18 | 19 |
| 19 using component_updater::ComponentUpdateService; | 20 using component_updater::ComponentUpdateService; |
| 20 | 21 |
| 21 namespace component_updater { | 22 namespace component_updater { |
| 22 | 23 |
| 23 // The extension id is: gcmjkmgdlgnkkcocmoeiminaijmmjnii | 24 // The extension id is: gcmjkmgdlgnkkcocmoeiminaijmmjnii |
| 24 const uint8_t kPublicKeySHA256[32] = { | 25 const uint8_t kPublicKeySHA256[32] = { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 ruleset_format != kCurrentRulesetFormat) { | 73 ruleset_format != kCurrentRulesetFormat) { |
| 73 DVLOG(1) << "Bailing out. Future ruleset version: " << ruleset_format; | 74 DVLOG(1) << "Bailing out. Future ruleset version: " << ruleset_format; |
| 74 return; | 75 return; |
| 75 } | 76 } |
| 76 subresource_filter::UnindexedRulesetInfo ruleset_info; | 77 subresource_filter::UnindexedRulesetInfo ruleset_info; |
| 77 ruleset_info.content_version = version.GetString(); | 78 ruleset_info.content_version = version.GetString(); |
| 78 ruleset_info.ruleset_path = | 79 ruleset_info.ruleset_path = |
| 79 install_dir.Append(subresource_filter::kUnindexedRulesetDataFileName); | 80 install_dir.Append(subresource_filter::kUnindexedRulesetDataFileName); |
| 80 ruleset_info.license_path = | 81 ruleset_info.license_path = |
| 81 install_dir.Append(subresource_filter::kUnindexedRulesetLicenseFileName); | 82 install_dir.Append(subresource_filter::kUnindexedRulesetLicenseFileName); |
| 82 subresource_filter::RulesetService* ruleset_service = | 83 subresource_filter::ContentRulesetService* content_ruleset_service = |
| 83 g_browser_process->subresource_filter_ruleset_service(); | 84 g_browser_process->subresource_filter_ruleset_service(); |
| 84 if (ruleset_service) | 85 if (content_ruleset_service) { |
| 85 ruleset_service->IndexAndStoreAndPublishRulesetIfNeeded(ruleset_info); | 86 content_ruleset_service->IndexAndStoreAndPublishRulesetIfNeeded( |
| 87 ruleset_info); |
| 88 } |
| 86 } | 89 } |
| 87 | 90 |
| 88 // Called during startup and installation before ComponentReady(). | 91 // Called during startup and installation before ComponentReady(). |
| 89 bool SubresourceFilterComponentInstallerTraits::VerifyInstallation( | 92 bool SubresourceFilterComponentInstallerTraits::VerifyInstallation( |
| 90 const base::DictionaryValue& manifest, | 93 const base::DictionaryValue& manifest, |
| 91 const base::FilePath& install_dir) const { | 94 const base::FilePath& install_dir) const { |
| 92 return base::PathExists(install_dir); | 95 return base::PathExists(install_dir); |
| 93 } | 96 } |
| 94 | 97 |
| 95 base::FilePath | 98 base::FilePath |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 return; | 147 return; |
| 145 std::unique_ptr<ComponentInstallerTraits> traits( | 148 std::unique_ptr<ComponentInstallerTraits> traits( |
| 146 new SubresourceFilterComponentInstallerTraits()); | 149 new SubresourceFilterComponentInstallerTraits()); |
| 147 // |cus| will take ownership of |installer| during installer->Register(cus). | 150 // |cus| will take ownership of |installer| during installer->Register(cus). |
| 148 DefaultComponentInstaller* installer = | 151 DefaultComponentInstaller* installer = |
| 149 new DefaultComponentInstaller(std::move(traits)); | 152 new DefaultComponentInstaller(std::move(traits)); |
| 150 installer->Register(cus, base::Closure()); | 153 installer->Register(cus, base::Closure()); |
| 151 } | 154 } |
| 152 | 155 |
| 153 } // namespace component_updater | 156 } // namespace component_updater |
| OLD | NEW |