ExtensionSyncService: listen for relevant changes instead of being explicitly called...
[chromium-blink-merge.git] / chrome / browser / chromeos / attestation / platform_verification_impl.h
blobd30f0a2ad887bd033fb28ddb59efd3f3d6fec2af
1 // Copyright 2015 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.
5 #ifndef CHROME_BROWSER_CHROMEOS_ATTESTATION_PLATFORM_VERIFICATION_IMPL_H_
6 #define CHROME_BROWSER_CHROMEOS_ATTESTATION_PLATFORM_VERIFICATION_IMPL_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/memory/ref_counted.h"
13 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h"
14 #include "content/public/browser/render_frame_host.h"
15 #include "media/mojo/interfaces/platform_verification.mojom.h"
16 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
18 namespace chromeos {
19 namespace attestation {
21 // Implements media::interfaces::PlatformVerification on ChromeOS using
22 // PlatformVerificationFlow. Can only be used on the UI thread because
23 // PlatformVerificationFlow lives on the UI thread.
24 class PlatformVerificationImpl
25 : public media::interfaces::PlatformVerification {
26 public:
27 static void Create(
28 content::RenderFrameHost* render_frame_host,
29 mojo::InterfaceRequest<media::interfaces::PlatformVerification> request);
31 PlatformVerificationImpl(
32 content::RenderFrameHost* render_frame_host,
33 mojo::InterfaceRequest<PlatformVerification> request);
34 ~PlatformVerificationImpl() override;
36 // mojo::InterfaceImpl<PlatformVerification> implementation.
37 void ChallengePlatform(const mojo::String& service_id,
38 const mojo::String& challenge,
39 const ChallengePlatformCallback& callback) override;
41 private:
42 using Result = PlatformVerificationFlow::Result;
44 void OnPlatformChallenged(const ChallengePlatformCallback& callback,
45 Result result,
46 const std::string& signed_data,
47 const std::string& signature,
48 const std::string& platform_key_certificate);
50 mojo::StrongBinding<media::interfaces::PlatformVerification> binding_;
52 content::RenderFrameHost* const render_frame_host_;
54 scoped_refptr<PlatformVerificationFlow> platform_verification_flow_;
56 base::WeakPtrFactory<PlatformVerificationImpl> weak_factory_;
59 } // namespace attestation
60 } // namespace chromeos
62 #endif // CHROME_BROWSER_CHROMEOS_ATTESTATION_PLATFORM_VERIFICATION_IMPL_H_