| 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 #include <map> |
| 8 #include <utility> | 9 #include <utility> |
| 9 | 10 |
| 10 #include "base/bind.h" | 11 #include "base/bind.h" |
| 11 #include "base/callback.h" | 12 #include "base/callback.h" |
| 12 #include "base/files/file_enumerator.h" | 13 #include "base/files/file_enumerator.h" |
| 13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 14 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
| 15 #include "base/files/important_file_writer.h" | 16 #include "base/files/important_file_writer.h" |
| 16 #include "base/location.h" | 17 #include "base/location.h" |
| 17 #include "base/macros.h" | 18 #include "base/macros.h" |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 const std::string& name, | 242 const std::string& name, |
| 242 const RawWhitelistReadyCallback& callback) | 243 const RawWhitelistReadyCallback& callback) |
| 243 : crx_id_(crx_id), name_(name), callback_(callback) {} | 244 : crx_id_(crx_id), name_(name), callback_(callback) {} |
| 244 ~SupervisedUserWhitelistComponentInstallerTraits() override {} | 245 ~SupervisedUserWhitelistComponentInstallerTraits() override {} |
| 245 | 246 |
| 246 private: | 247 private: |
| 247 // ComponentInstallerTraits overrides: | 248 // ComponentInstallerTraits overrides: |
| 248 bool VerifyInstallation(const base::DictionaryValue& manifest, | 249 bool VerifyInstallation(const base::DictionaryValue& manifest, |
| 249 const base::FilePath& install_dir) const override; | 250 const base::FilePath& install_dir) const override; |
| 250 bool CanAutoUpdate() const override; | 251 bool CanAutoUpdate() const override; |
| 252 bool RequiresNetworkEncryption() const override; |
| 251 bool OnCustomInstall(const base::DictionaryValue& manifest, | 253 bool OnCustomInstall(const base::DictionaryValue& manifest, |
| 252 const base::FilePath& install_dir) override; | 254 const base::FilePath& install_dir) override; |
| 253 void ComponentReady(const base::Version& version, | 255 void ComponentReady(const base::Version& version, |
| 254 const base::FilePath& install_dir, | 256 const base::FilePath& install_dir, |
| 255 scoped_ptr<base::DictionaryValue> manifest) override; | 257 scoped_ptr<base::DictionaryValue> manifest) override; |
| 256 base::FilePath GetBaseDirectory() const override; | 258 base::FilePath GetBaseDirectory() const override; |
| 257 void GetHash(std::vector<uint8_t>* hash) const override; | 259 void GetHash(std::vector<uint8_t>* hash) const override; |
| 258 std::string GetName() const override; | 260 std::string GetName() const override; |
| 259 | 261 |
| 260 std::string crx_id_; | 262 std::string crx_id_; |
| 261 std::string name_; | 263 std::string name_; |
| 262 RawWhitelistReadyCallback callback_; | 264 RawWhitelistReadyCallback callback_; |
| 263 | 265 |
| 264 DISALLOW_COPY_AND_ASSIGN(SupervisedUserWhitelistComponentInstallerTraits); | 266 DISALLOW_COPY_AND_ASSIGN(SupervisedUserWhitelistComponentInstallerTraits); |
| 265 }; | 267 }; |
| 266 | 268 |
| 267 bool SupervisedUserWhitelistComponentInstallerTraits::VerifyInstallation( | 269 bool SupervisedUserWhitelistComponentInstallerTraits::VerifyInstallation( |
| 268 const base::DictionaryValue& manifest, | 270 const base::DictionaryValue& manifest, |
| 269 const base::FilePath& install_dir) const { | 271 const base::FilePath& install_dir) const { |
| 270 // Check whether the whitelist exists at the path specified by the manifest. | 272 // Check whether the whitelist exists at the path specified by the manifest. |
| 271 // This does not check whether the whitelist is wellformed. | 273 // This does not check whether the whitelist is wellformed. |
| 272 return base::PathExists(GetRawWhitelistPath(manifest, install_dir)); | 274 return base::PathExists(GetRawWhitelistPath(manifest, install_dir)); |
| 273 } | 275 } |
| 274 | 276 |
| 275 bool SupervisedUserWhitelistComponentInstallerTraits::CanAutoUpdate() const { | 277 bool SupervisedUserWhitelistComponentInstallerTraits::CanAutoUpdate() const { |
| 276 return true; | 278 return true; |
| 277 } | 279 } |
| 278 | 280 |
| 281 bool SupervisedUserWhitelistComponentInstallerTraits:: |
| 282 RequiresNetworkEncryption() const { |
| 283 return true; |
| 284 } |
| 285 |
| 279 bool SupervisedUserWhitelistComponentInstallerTraits::OnCustomInstall( | 286 bool SupervisedUserWhitelistComponentInstallerTraits::OnCustomInstall( |
| 280 const base::DictionaryValue& manifest, | 287 const base::DictionaryValue& manifest, |
| 281 const base::FilePath& install_dir) { | 288 const base::FilePath& install_dir) { |
| 282 // Delete the existing sanitized whitelist. | 289 // Delete the existing sanitized whitelist. |
| 283 return base::DeleteFile(GetSanitizedWhitelistPath(crx_id_), false); | 290 return base::DeleteFile(GetSanitizedWhitelistPath(crx_id_), false); |
| 284 } | 291 } |
| 285 | 292 |
| 286 void SupervisedUserWhitelistComponentInstallerTraits::ComponentReady( | 293 void SupervisedUserWhitelistComponentInstallerTraits::ComponentReady( |
| 287 const base::Version& version, | 294 const base::Version& version, |
| 288 const base::FilePath& install_dir, | 295 const base::FilePath& install_dir, |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 | 625 |
| 619 // static | 626 // static |
| 620 void SupervisedUserWhitelistInstaller::TriggerComponentUpdate( | 627 void SupervisedUserWhitelistInstaller::TriggerComponentUpdate( |
| 621 OnDemandUpdater* updater, | 628 OnDemandUpdater* updater, |
| 622 const std::string& crx_id) { | 629 const std::string& crx_id) { |
| 623 const bool result = updater->OnDemandUpdate(crx_id); | 630 const bool result = updater->OnDemandUpdate(crx_id); |
| 624 DCHECK(result); | 631 DCHECK(result); |
| 625 } | 632 } |
| 626 | 633 |
| 627 } // namespace component_updater | 634 } // namespace component_updater |
| OLD | NEW |