pepper_platform_verification_message_filter.h revision d0247b1b59f9c528cb6df88b4f2b9afaf80d181e
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 12namespace content { 13class BrowserPpapiHost; 14} // namespace content 15 16namespace ppapi { 17namespace host { 18struct HostMessageContext; 19} // namespace host 20} // namespace ppapi 21 22namespace chrome { 23 24// This filter handles messages for platform verification on the UI thread. 25class 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 OnCanChallengePlatform(ppapi::host::HostMessageContext* context); 42 int32_t OnChallengePlatform(ppapi::host::HostMessageContext* context, 43 const std::string& service_id, 44 const std::vector<uint8_t>& challenge); 45 46 // PlatformVerificationFlow callbacks. 47 void CanChallengePlatformCallback( 48 ppapi::host::ReplyMessageContext reply_context, 49 bool can_challenge_platform); 50 void ChallengePlatformCallback( 51 ppapi::host::ReplyMessageContext reply_context, 52 chromeos::attestation::PlatformVerificationFlow::Result challenge_result, 53 const std::string& signed_data, 54 const std::string& signature, 55 const std::string& platform_key_certificate); 56 57 // Used to lookup the WebContents associated with this PP_Instance. 58 int render_process_id_; 59 int render_view_id_; 60 61 // Must only be accessed on the UI thread. 62 scoped_ptr<chromeos::attestation::PlatformVerificationFlow> pv_; 63 64 DISALLOW_COPY_AND_ASSIGN(PepperPlatformVerificationMessageFilter); 65}; 66 67} // namespace chrome 68 69#endif // CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_PLATFORM_VERIFICATION_MESSAGE_FILTER_H_ 70