OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/renderer_host/pepper/pepper_platform_verification_messa
ge_filter.h" | 5 #include "chrome/browser/renderer_host/pepper/pepper_platform_verification_messa
ge_filter.h" |
6 | 6 |
7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "content/public/browser/browser_ppapi_host.h" | 8 #include "content/public/browser/browser_ppapi_host.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 #include "content/public/browser/render_frame_host.h" | 10 #include "content/public/browser/render_frame_host.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 scoped_refptr<base::TaskRunner> | 33 scoped_refptr<base::TaskRunner> |
34 PepperPlatformVerificationMessageFilter::OverrideTaskRunnerForMessage( | 34 PepperPlatformVerificationMessageFilter::OverrideTaskRunnerForMessage( |
35 const IPC::Message& msg) { | 35 const IPC::Message& msg) { |
36 return content::BrowserThread::GetMessageLoopProxyForThread( | 36 return content::BrowserThread::GetMessageLoopProxyForThread( |
37 content::BrowserThread::UI); | 37 content::BrowserThread::UI); |
38 } | 38 } |
39 | 39 |
40 int32_t PepperPlatformVerificationMessageFilter::OnResourceMessageReceived( | 40 int32_t PepperPlatformVerificationMessageFilter::OnResourceMessageReceived( |
41 const IPC::Message& msg, | 41 const IPC::Message& msg, |
42 ppapi::host::HostMessageContext* context) { | 42 ppapi::host::HostMessageContext* context) { |
43 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 43 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
44 | 44 |
45 PPAPI_BEGIN_MESSAGE_MAP(PepperPlatformVerificationMessageFilter, msg) | 45 PPAPI_BEGIN_MESSAGE_MAP(PepperPlatformVerificationMessageFilter, msg) |
46 PPAPI_DISPATCH_HOST_RESOURCE_CALL( | 46 PPAPI_DISPATCH_HOST_RESOURCE_CALL( |
47 PpapiHostMsg_PlatformVerification_ChallengePlatform, | 47 PpapiHostMsg_PlatformVerification_ChallengePlatform, |
48 OnChallengePlatform) | 48 OnChallengePlatform) |
49 PPAPI_END_MESSAGE_MAP() | 49 PPAPI_END_MESSAGE_MAP() |
50 | 50 |
51 return PP_ERROR_FAILED; | 51 return PP_ERROR_FAILED; |
52 } | 52 } |
53 | 53 |
54 int32_t PepperPlatformVerificationMessageFilter::OnChallengePlatform( | 54 int32_t PepperPlatformVerificationMessageFilter::OnChallengePlatform( |
55 ppapi::host::HostMessageContext* context, | 55 ppapi::host::HostMessageContext* context, |
56 const std::string& service_id, | 56 const std::string& service_id, |
57 const std::vector<uint8_t>& challenge) { | 57 const std::vector<uint8_t>& challenge) { |
58 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 58 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
59 | 59 |
60 // Ensure the RenderFrameHost is still alive. | 60 // Ensure the RenderFrameHost is still alive. |
61 content::RenderFrameHost* rfh = | 61 content::RenderFrameHost* rfh = |
62 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); | 62 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); |
63 if (!rfh) { | 63 if (!rfh) { |
64 ppapi::host::ReplyMessageContext reply_context = | 64 ppapi::host::ReplyMessageContext reply_context = |
65 context->MakeReplyMessageContext(); | 65 context->MakeReplyMessageContext(); |
66 reply_context.params.set_result(PP_ERROR_FAILED); | 66 reply_context.params.set_result(PP_ERROR_FAILED); |
67 SendReply( | 67 SendReply( |
68 reply_context, | 68 reply_context, |
(...skipping 16 matching lines...) Expand all Loading... |
85 | 85 |
86 return PP_OK_COMPLETIONPENDING; | 86 return PP_OK_COMPLETIONPENDING; |
87 } | 87 } |
88 | 88 |
89 void PepperPlatformVerificationMessageFilter::ChallengePlatformCallback( | 89 void PepperPlatformVerificationMessageFilter::ChallengePlatformCallback( |
90 ppapi::host::ReplyMessageContext reply_context, | 90 ppapi::host::ReplyMessageContext reply_context, |
91 chromeos::attestation::PlatformVerificationFlow::Result challenge_result, | 91 chromeos::attestation::PlatformVerificationFlow::Result challenge_result, |
92 const std::string& signed_data, | 92 const std::string& signed_data, |
93 const std::string& signature, | 93 const std::string& signature, |
94 const std::string& platform_key_certificate) { | 94 const std::string& platform_key_certificate) { |
95 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 95 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
96 | 96 |
97 if (challenge_result == PlatformVerificationFlow::SUCCESS) { | 97 if (challenge_result == PlatformVerificationFlow::SUCCESS) { |
98 reply_context.params.set_result(PP_OK); | 98 reply_context.params.set_result(PP_OK); |
99 } else { | 99 } else { |
100 reply_context.params.set_result(PP_ERROR_FAILED); | 100 reply_context.params.set_result(PP_ERROR_FAILED); |
101 DCHECK_EQ(signed_data.size(), 0u); | 101 DCHECK_EQ(signed_data.size(), 0u); |
102 DCHECK_EQ(signature.size(), 0u); | 102 DCHECK_EQ(signature.size(), 0u); |
103 DCHECK_EQ(platform_key_certificate.size(), 0u); | 103 DCHECK_EQ(platform_key_certificate.size(), 0u); |
104 } | 104 } |
105 | 105 |
106 SendReply(reply_context, | 106 SendReply(reply_context, |
107 PpapiHostMsg_PlatformVerification_ChallengePlatformReply( | 107 PpapiHostMsg_PlatformVerification_ChallengePlatformReply( |
108 std::vector<uint8_t>(signed_data.begin(), signed_data.end()), | 108 std::vector<uint8_t>(signed_data.begin(), signed_data.end()), |
109 std::vector<uint8_t>(signature.begin(), signature.end()), | 109 std::vector<uint8_t>(signature.begin(), signature.end()), |
110 platform_key_certificate)); | 110 platform_key_certificate)); |
111 } | 111 } |
112 | 112 |
113 } // namespace chrome | 113 } // namespace chrome |
OLD | NEW |