forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AW][Trust Tokens] Register trust tokens component
Register trust tokens component for installation in ComponentUpdateService in WebView. Note that this only means downloading the files on disk. Trust tokens config is still needed to be fetched and loaded inside embedded WebView instances via ComponentProviderService, this will be in following CLs. See supporting component updater in WebView design doc for more details: http://go/wv-component-updater Bug: 1171762 Test: Manully launch AwComponentUpdateService and notice debug logs Change-Id: Iad716b0b9ce79296fb818a4072b661225ab62cb5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2697148 Reviewed-by: Sorin Jianu <sorin@chromium.org> Reviewed-by: Joshua Pawlicki <waffles@chromium.org> Reviewed-by: Mugdha Lakhani <nator@chromium.org> Commit-Queue: Hazem Ashmawy <hazems@chromium.org> Cr-Commit-Position: refs/heads/master@{#855947}
- Loading branch information
1 parent
53883a6
commit a711c86
Showing
6 changed files
with
128 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...t_updater/installer_policies/aw_trust_token_key_commitments_component_installer_policy.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2021 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "android_webview/nonembedded/component_updater/installer_policies/aw_trust_token_key_commitments_component_installer_policy.h" | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <utility> | ||
#include <vector> | ||
|
||
#include "android_webview/nonembedded/component_updater/aw_component_installer_policy_delegate.h" | ||
#include "base/callback.h" | ||
#include "base/notreached.h" | ||
#include "components/component_updater/component_installer.h" | ||
#include "components/component_updater/installer_policies/trust_token_key_commitments_component_installer_policy.h" | ||
|
||
namespace android_webview { | ||
|
||
AwTrustTokenKeyCommitmentsComponentInstallerPolicy:: | ||
AwTrustTokenKeyCommitmentsComponentInstallerPolicy( | ||
std::unique_ptr<AwComponentInstallerPolicyDelegate> delegate) | ||
: component_updater::TrustTokenKeyCommitmentsComponentInstallerPolicy( | ||
/* on_commitments_ready= */ base::BindRepeating( | ||
[](const std::string& raw_commitments) { | ||
// The inherited ComponentReady shouldn't be called because it | ||
// assumes it runs in a browser context. | ||
NOTREACHED(); | ||
})), | ||
delegate_(std::move(delegate)) {} | ||
|
||
AwTrustTokenKeyCommitmentsComponentInstallerPolicy:: | ||
~AwTrustTokenKeyCommitmentsComponentInstallerPolicy() = default; | ||
|
||
update_client::CrxInstaller::Result | ||
AwTrustTokenKeyCommitmentsComponentInstallerPolicy::OnCustomInstall( | ||
const base::DictionaryValue& manifest, | ||
const base::FilePath& install_dir) { | ||
std::vector<uint8_t> hash; | ||
GetHash(&hash); | ||
return delegate_->OnCustomInstall(manifest, install_dir, hash); | ||
} | ||
void AwTrustTokenKeyCommitmentsComponentInstallerPolicy::OnCustomUninstall() { | ||
delegate_->OnCustomUninstall(); | ||
} | ||
void AwTrustTokenKeyCommitmentsComponentInstallerPolicy::ComponentReady( | ||
const base::Version& version, | ||
const base::FilePath& install_dir, | ||
std::unique_ptr<base::DictionaryValue> manifest) { | ||
delegate_->ComponentReady(version, install_dir, std::move(manifest)); | ||
} | ||
|
||
} // namespace android_webview |
55 changes: 55 additions & 0 deletions
55
...nt_updater/installer_policies/aw_trust_token_key_commitments_component_installer_policy.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright 2021 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef ANDROID_WEBVIEW_NONEMBEDDED_COMPONENT_UPDATER_INSTALLER_POLICIES_AW_TRUST_TOKEN_KEY_COMMITMENTS_COMPONENT_INSTALLER_POLICY_H_ | ||
#define ANDROID_WEBVIEW_NONEMBEDDED_COMPONENT_UPDATER_INSTALLER_POLICIES_AW_TRUST_TOKEN_KEY_COMMITMENTS_COMPONENT_INSTALLER_POLICY_H_ | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "components/component_updater/installer_policies/trust_token_key_commitments_component_installer_policy.h" | ||
|
||
namespace base { | ||
class DictionaryValue; | ||
class FilePath; | ||
class Version; | ||
} // namespace base | ||
|
||
namespace android_webview { | ||
|
||
class AwComponentInstallerPolicyDelegate; | ||
|
||
// Provides an implementation for the policy methods that need custom | ||
// implementation for WebView. These methods should always be delegated to the | ||
// custom delegate object, inherited methods shouldn't be called if they need | ||
// a browser context for execution. | ||
class AwTrustTokenKeyCommitmentsComponentInstallerPolicy | ||
: public component_updater:: | ||
TrustTokenKeyCommitmentsComponentInstallerPolicy { | ||
public: | ||
explicit AwTrustTokenKeyCommitmentsComponentInstallerPolicy( | ||
std::unique_ptr<AwComponentInstallerPolicyDelegate> delegate); | ||
~AwTrustTokenKeyCommitmentsComponentInstallerPolicy() override; | ||
|
||
AwTrustTokenKeyCommitmentsComponentInstallerPolicy( | ||
const AwTrustTokenKeyCommitmentsComponentInstallerPolicy&) = delete; | ||
AwTrustTokenKeyCommitmentsComponentInstallerPolicy& operator=( | ||
const AwTrustTokenKeyCommitmentsComponentInstallerPolicy&) = delete; | ||
|
||
update_client::CrxInstaller::Result OnCustomInstall( | ||
const base::DictionaryValue& manifest, | ||
const base::FilePath& install_dir) override; | ||
void OnCustomUninstall() override; | ||
void ComponentReady(const base::Version& version, | ||
const base::FilePath& install_dir, | ||
std::unique_ptr<base::DictionaryValue> manifest) override; | ||
|
||
private: | ||
std::unique_ptr<AwComponentInstallerPolicyDelegate> delegate_; | ||
}; | ||
|
||
} // namespace android_webview | ||
|
||
#endif // ANDROID_WEBVIEW_NONEMBEDDED_COMPONENT_UPDATER_INSTALLER_POLICIES_AW_TRUST_TOKEN_KEY_COMMITMENTS_COMPONENT_INSTALLER_POLICY_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters