| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/supervised_user_whitelist_installer.h
" | 5 #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h
" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "chrome/common/chrome_paths.h" | 33 #include "chrome/common/chrome_paths.h" |
| 34 #include "chrome/common/pref_names.h" | 34 #include "chrome/common/pref_names.h" |
| 35 #include "components/component_updater/component_updater_paths.h" | 35 #include "components/component_updater/component_updater_paths.h" |
| 36 #include "components/component_updater/component_updater_service.h" | 36 #include "components/component_updater/component_updater_service.h" |
| 37 #include "components/component_updater/default_component_installer.h" | 37 #include "components/component_updater/default_component_installer.h" |
| 38 #include "components/crx_file/id_util.h" | 38 #include "components/crx_file/id_util.h" |
| 39 #include "components/prefs/pref_registry_simple.h" | 39 #include "components/prefs/pref_registry_simple.h" |
| 40 #include "components/prefs/pref_service.h" | 40 #include "components/prefs/pref_service.h" |
| 41 #include "components/prefs/scoped_user_pref_update.h" | 41 #include "components/prefs/scoped_user_pref_update.h" |
| 42 #include "components/safe_json/json_sanitizer.h" | 42 #include "components/safe_json/json_sanitizer.h" |
| 43 #include "components/update_client/update_client_errors.h" |
| 43 #include "content/public/browser/browser_thread.h" | 44 #include "content/public/browser/browser_thread.h" |
| 44 | 45 |
| 45 namespace component_updater { | 46 namespace component_updater { |
| 46 | 47 |
| 47 namespace { | 48 namespace { |
| 48 | 49 |
| 49 const char kSanitizedWhitelistExtension[] = ".json"; | 50 const char kSanitizedWhitelistExtension[] = ".json"; |
| 50 | 51 |
| 51 const char kWhitelistedContent[] = "whitelisted_content"; | 52 const char kWhitelistedContent[] = "whitelisted_content"; |
| 52 const char kSites[] = "sites"; | 53 const char kSites[] = "sites"; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 const RawWhitelistReadyCallback& callback) | 246 const RawWhitelistReadyCallback& callback) |
| 246 : crx_id_(crx_id), name_(name), callback_(callback) {} | 247 : crx_id_(crx_id), name_(name), callback_(callback) {} |
| 247 ~SupervisedUserWhitelistComponentInstallerTraits() override {} | 248 ~SupervisedUserWhitelistComponentInstallerTraits() override {} |
| 248 | 249 |
| 249 private: | 250 private: |
| 250 // ComponentInstallerTraits overrides: | 251 // ComponentInstallerTraits overrides: |
| 251 bool VerifyInstallation(const base::DictionaryValue& manifest, | 252 bool VerifyInstallation(const base::DictionaryValue& manifest, |
| 252 const base::FilePath& install_dir) const override; | 253 const base::FilePath& install_dir) const override; |
| 253 bool SupportsGroupPolicyEnabledComponentUpdates() const override; | 254 bool SupportsGroupPolicyEnabledComponentUpdates() const override; |
| 254 bool RequiresNetworkEncryption() const override; | 255 bool RequiresNetworkEncryption() const override; |
| 255 bool OnCustomInstall(const base::DictionaryValue& manifest, | 256 update_client::CrxInstaller::Result OnCustomInstall( |
| 256 const base::FilePath& install_dir) override; | 257 const base::DictionaryValue& manifest, |
| 258 const base::FilePath& install_dir) override; |
| 257 void ComponentReady(const base::Version& version, | 259 void ComponentReady(const base::Version& version, |
| 258 const base::FilePath& install_dir, | 260 const base::FilePath& install_dir, |
| 259 std::unique_ptr<base::DictionaryValue> manifest) override; | 261 std::unique_ptr<base::DictionaryValue> manifest) override; |
| 260 base::FilePath GetRelativeInstallDir() const override; | 262 base::FilePath GetRelativeInstallDir() const override; |
| 261 void GetHash(std::vector<uint8_t>* hash) const override; | 263 void GetHash(std::vector<uint8_t>* hash) const override; |
| 262 std::string GetName() const override; | 264 std::string GetName() const override; |
| 263 update_client::InstallerAttributes GetInstallerAttributes() const override; | 265 update_client::InstallerAttributes GetInstallerAttributes() const override; |
| 264 std::vector<std::string> GetMimeTypes() const override; | 266 std::vector<std::string> GetMimeTypes() const override; |
| 265 | 267 |
| 266 std::string crx_id_; | 268 std::string crx_id_; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 281 bool SupervisedUserWhitelistComponentInstallerTraits:: | 283 bool SupervisedUserWhitelistComponentInstallerTraits:: |
| 282 SupportsGroupPolicyEnabledComponentUpdates() const { | 284 SupportsGroupPolicyEnabledComponentUpdates() const { |
| 283 return false; | 285 return false; |
| 284 } | 286 } |
| 285 | 287 |
| 286 bool SupervisedUserWhitelistComponentInstallerTraits:: | 288 bool SupervisedUserWhitelistComponentInstallerTraits:: |
| 287 RequiresNetworkEncryption() const { | 289 RequiresNetworkEncryption() const { |
| 288 return true; | 290 return true; |
| 289 } | 291 } |
| 290 | 292 |
| 291 bool SupervisedUserWhitelistComponentInstallerTraits::OnCustomInstall( | 293 update_client::CrxInstaller::Result |
| 294 SupervisedUserWhitelistComponentInstallerTraits::OnCustomInstall( |
| 292 const base::DictionaryValue& manifest, | 295 const base::DictionaryValue& manifest, |
| 293 const base::FilePath& install_dir) { | 296 const base::FilePath& install_dir) { |
| 294 // Delete the existing sanitized whitelist. | 297 // Delete the existing sanitized whitelist. |
| 295 return base::DeleteFile(GetSanitizedWhitelistPath(crx_id_), false); | 298 const bool success = |
| 299 base::DeleteFile(GetSanitizedWhitelistPath(crx_id_), false); |
| 300 return update_client::CrxInstaller::Result( |
| 301 success ? update_client::InstallError::NONE |
| 302 : update_client::InstallError::GENERIC_ERROR); |
| 296 } | 303 } |
| 297 | 304 |
| 298 void SupervisedUserWhitelistComponentInstallerTraits::ComponentReady( | 305 void SupervisedUserWhitelistComponentInstallerTraits::ComponentReady( |
| 299 const base::Version& version, | 306 const base::Version& version, |
| 300 const base::FilePath& install_dir, | 307 const base::FilePath& install_dir, |
| 301 std::unique_ptr<base::DictionaryValue> manifest) { | 308 std::unique_ptr<base::DictionaryValue> manifest) { |
| 302 // TODO(treib): Before getting the title, we should localize the manifest | 309 // TODO(treib): Before getting the title, we should localize the manifest |
| 303 // using extension_l10n_util::LocalizeExtension, but that doesn't exist on | 310 // using extension_l10n_util::LocalizeExtension, but that doesn't exist on |
| 304 // Android. crbug.com/558387 | 311 // Android. crbug.com/558387 |
| 305 callback_.Run(GetWhitelistTitle(*manifest), | 312 callback_.Run(GetWhitelistTitle(*manifest), |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 | 647 |
| 641 // static | 648 // static |
| 642 void SupervisedUserWhitelistInstaller::TriggerComponentUpdate( | 649 void SupervisedUserWhitelistInstaller::TriggerComponentUpdate( |
| 643 OnDemandUpdater* updater, | 650 OnDemandUpdater* updater, |
| 644 const std::string& crx_id) { | 651 const std::string& crx_id) { |
| 645 // TODO(sorin): use a callback to check the result (crbug.com/639189). | 652 // TODO(sorin): use a callback to check the result (crbug.com/639189). |
| 646 updater->OnDemandUpdate(crx_id, component_updater::Callback()); | 653 updater->OnDemandUpdate(crx_id, component_updater::Callback()); |
| 647 } | 654 } |
| 648 | 655 |
| 649 } // namespace component_updater | 656 } // namespace component_updater |
| OLD | NEW |