aw_component_installer_policy_shim.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ANDROID_WEBVIEW_NONEMBEDDED_COMPONENT_UPDATER_AW_COMPONENT_INSTALLER_POLICY_SHIM_H_
  5. #define ANDROID_WEBVIEW_NONEMBEDDED_COMPONENT_UPDATER_AW_COMPONENT_INSTALLER_POLICY_SHIM_H_
  6. #include <cstdint>
  7. #include <memory>
  8. #include <string>
  9. #include <vector>
  10. #include "android_webview/nonembedded/component_updater/aw_component_installer_policy.h"
  11. namespace base {
  12. class Value;
  13. class FilePath;
  14. } // namespace base
  15. namespace component_updater {
  16. class ComponentInstallerPolicy;
  17. } // namespace component_updater
  18. namespace android_webview {
  19. // A shim class that transparently redirects all calls to the passed
  20. // installer policy object except for the calls that require custom WebView
  21. // implementation, namely `ComponentReady` and `OnCustomUninstall`.
  22. //
  23. // This class is handy for installer policies shared between chrome and WebView,
  24. // it can be used to wrap installer policies written for chrome to modify their
  25. // behaviour to match the expected WebView behaviour.
  26. class AwComponentInstallerPolicyShim : public AwComponentInstallerPolicy {
  27. public:
  28. explicit AwComponentInstallerPolicyShim(
  29. std::unique_ptr<component_updater::ComponentInstallerPolicy> policy);
  30. ~AwComponentInstallerPolicyShim() override;
  31. AwComponentInstallerPolicyShim(const AwComponentInstallerPolicyShim&) =
  32. delete;
  33. AwComponentInstallerPolicyShim& operator=(
  34. const AwComponentInstallerPolicyShim&) = delete;
  35. // The following methods override ComponentInstallerPolicy.
  36. bool SupportsGroupPolicyEnabledComponentUpdates() const override;
  37. bool RequiresNetworkEncryption() const override;
  38. update_client::CrxInstaller::Result OnCustomInstall(
  39. const base::Value& manifest,
  40. const base::FilePath& install_dir) override;
  41. bool VerifyInstallation(const base::Value& manifest,
  42. const base::FilePath& install_dir) const override;
  43. base::FilePath GetRelativeInstallDir() const override;
  44. std::string GetName() const override;
  45. update_client::InstallerAttributes GetInstallerAttributes() const override;
  46. void GetHash(std::vector<uint8_t>* hash) const override;
  47. private:
  48. std::unique_ptr<component_updater::ComponentInstallerPolicy> policy_;
  49. };
  50. } // namespace android_webview
  51. #endif // ANDROID_WEBVIEW_NONEMBEDDED_COMPONENT_UPDATER_AW_COMPONENT_INSTALLER_POLICY_SHIM_H_