| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/renderer/pepper/pepper_extensions_common_host.h" | 5 #include "chrome/renderer/pepper/pepper_extensions_common_host.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/renderer/extensions/chrome_v8_context.h" | 10 #include "chrome/renderer/extensions/chrome_v8_context.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 const IPC::Message& msg, | 77 const IPC::Message& msg, |
| 78 ppapi::host::HostMessageContext* context) { | 78 ppapi::host::HostMessageContext* context) { |
| 79 IPC_BEGIN_MESSAGE_MAP(PepperExtensionsCommonHost, msg) | 79 IPC_BEGIN_MESSAGE_MAP(PepperExtensionsCommonHost, msg) |
| 80 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_ExtensionsCommon_Post, OnPost) | 80 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_ExtensionsCommon_Post, OnPost) |
| 81 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_ExtensionsCommon_Call, OnCall) | 81 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_ExtensionsCommon_Call, OnCall) |
| 82 IPC_END_MESSAGE_MAP() | 82 IPC_END_MESSAGE_MAP() |
| 83 return PP_ERROR_FAILED; | 83 return PP_ERROR_FAILED; |
| 84 } | 84 } |
| 85 | 85 |
| 86 void PepperExtensionsCommonHost::OnResponseReceived( | 86 void PepperExtensionsCommonHost::OnResponseReceived( |
| 87 scoped_ptr<ppapi::host::ReplyMessageContext> context, | 87 const ppapi::host::ReplyMessageContext& reply_context, |
| 88 bool success, | 88 bool success, |
| 89 const base::ListValue& response, | 89 const base::ListValue& response, |
| 90 const std::string& /* error */) { | 90 const std::string& /* error */) { |
| 91 context->params.set_result(success ? PP_OK : PP_ERROR_FAILED); | 91 ppapi::host::ReplyMessageContext context(reply_context); |
| 92 SendReply(*context, PpapiPluginMsg_ExtensionsCommon_CallReply(response)); | 92 context.params.set_result(success ? PP_OK : PP_ERROR_FAILED); |
| 93 SendReply(context, PpapiPluginMsg_ExtensionsCommon_CallReply(response)); |
| 93 } | 94 } |
| 94 | 95 |
| 95 int32_t PepperExtensionsCommonHost::OnPost( | 96 int32_t PepperExtensionsCommonHost::OnPost( |
| 96 ppapi::host::HostMessageContext* context, | 97 ppapi::host::HostMessageContext* context, |
| 97 const std::string& request_name, | 98 const std::string& request_name, |
| 98 const base::ListValue& args) { | 99 const base::ListValue& args) { |
| 99 std::string error; | 100 std::string error; |
| 100 bool success = pepper_request_proxy_->StartRequest( | 101 bool success = pepper_request_proxy_->StartRequest( |
| 101 base::Bind(&DoNothing), request_name, args, &error); | 102 base::Bind(&DoNothing), request_name, args, &error); |
| 102 return success ? PP_OK : PP_ERROR_FAILED; | 103 return success ? PP_OK : PP_ERROR_FAILED; |
| 103 } | 104 } |
| 104 | 105 |
| 105 int32_t PepperExtensionsCommonHost::OnCall( | 106 int32_t PepperExtensionsCommonHost::OnCall( |
| 106 ppapi::host::HostMessageContext* context, | 107 ppapi::host::HostMessageContext* context, |
| 107 const std::string& request_name, | 108 const std::string& request_name, |
| 108 const base::ListValue& args) { | 109 const base::ListValue& args) { |
| 109 std::string error; | 110 std::string error; |
| 110 scoped_ptr<ppapi::host::ReplyMessageContext> message_context( | |
| 111 new ppapi::host::ReplyMessageContext(context->MakeReplyMessageContext())); | |
| 112 bool success = pepper_request_proxy_->StartRequest( | 111 bool success = pepper_request_proxy_->StartRequest( |
| 113 base::Bind(&PepperExtensionsCommonHost::OnResponseReceived, | 112 base::Bind(&PepperExtensionsCommonHost::OnResponseReceived, |
| 114 weak_factory_.GetWeakPtr(), | 113 weak_factory_.GetWeakPtr(), |
| 115 base::Passed(&message_context)), | 114 context->MakeReplyMessageContext()), |
| 116 request_name, | 115 request_name, |
| 117 args, | 116 args, |
| 118 &error); | 117 &error); |
| 119 return success ? PP_OK_COMPLETIONPENDING : PP_ERROR_FAILED; | 118 return success ? PP_OK_COMPLETIONPENDING : PP_ERROR_FAILED; |
| 120 } | 119 } |
| OLD | NEW |