1 // Copyright 2013 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 5 #ifndef CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_PLATFORM_VERIFICATION_MESSAGE_FILTER_H_ 6 #define CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_PLATFORM_VERIFICATION_MESSAGE_FILTER_H_ 7 8 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h" 9 #include "ppapi/c/pp_instance.h" 10 #include "ppapi/host/resource_message_filter.h" 11 12 namespace content { 13 class BrowserPpapiHost; 14 } // namespace content 15 16 namespace ppapi { 17 namespace host { 18 struct HostMessageContext; 19 } // namespace host 20 } // namespace ppapi 21 22 namespace chrome { 23 24 // This filter handles messages for platform verification on the UI thread. 25 class PepperPlatformVerificationMessageFilter 26 : public ppapi::host::ResourceMessageFilter { 27 public: 28 PepperPlatformVerificationMessageFilter(content::BrowserPpapiHost* host, 29 PP_Instance instance); 30 31 private: 32 virtual ~PepperPlatformVerificationMessageFilter(); 33 34 // ppapi::host::ResourceMessageFilter overrides. 35 virtual scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage( 36 const IPC::Message& message) OVERRIDE; 37 virtual int32_t OnResourceMessageReceived( 38 const IPC::Message& msg, 39 ppapi::host::HostMessageContext* context) OVERRIDE; 40 41 int32_t OnChallengePlatform(ppapi::host::HostMessageContext* context, 42 const std::string& service_id, 43 const std::vector<uint8_t>& challenge); 44 45 // PlatformVerificationFlow callbacks. 46 void ChallengePlatformCallback( 47 ppapi::host::ReplyMessageContext reply_context, 48 chromeos::attestation::PlatformVerificationFlow::Result challenge_result, 49 const std::string& signed_data, 50 const std::string& signature, 51 const std::string& platform_key_certificate); 52 53 // Used to lookup the WebContents associated with this PP_Instance. 54 int render_process_id_; 55 int render_view_id_; 56 57 // Must only be accessed on the UI thread. 58 scoped_refptr<chromeos::attestation::PlatformVerificationFlow> pv_; 59 60 DISALLOW_COPY_AND_ASSIGN(PepperPlatformVerificationMessageFilter); 61 }; 62 63 } // namespace chrome 64 65 #endif // CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_PLATFORM_VERIFICATION_MESSAGE_FILTER_H_ 66