trust_token_key_commitments_component_loader.cc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #include "android_webview/browser/component_updater/trust_token_key_commitments_component_loader.h"
  5. #include <memory>
  6. #include <string>
  7. #include <vector>
  8. #include "base/bind.h"
  9. #include "base/feature_list.h"
  10. #include "base/logging.h"
  11. #include "components/component_updater/android/loader_policies/trust_token_key_commitments_component_loader_policy.h"
  12. #include "content/public/browser/network_service_instance.h"
  13. #include "services/network/public/cpp/features.h"
  14. #include "services/network/public/mojom/network_service.mojom.h"
  15. namespace android_webview {
  16. // Add trust tokens ComponentLoaderPolicy to the given policies vector, if Trust
  17. // Tokens is enabled.
  18. void LoadTrustTokenKeyCommitmentsComponent(
  19. ComponentLoaderPolicyVector& policies) {
  20. if (!base::FeatureList::IsEnabled(network::features::kTrustTokens))
  21. return;
  22. DVLOG(1)
  23. << "Registering Trust Token Key Commitments component for loading in "
  24. "embedded WebView.";
  25. policies.push_back(
  26. std::make_unique<
  27. component_updater::TrustTokenKeyCommitmentsComponentLoaderPolicy>(
  28. /* on_commitments_ready = */ base::BindRepeating(
  29. [](const std::string& raw_commitments) {
  30. content::GetNetworkService()->SetTrustTokenKeyCommitments(
  31. raw_commitments, /* done_callback = */ base::DoNothing());
  32. })));
  33. }
  34. } // namespace android_webview