| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ppapi/proxy/ppb_instance_proxy.h" | 5 #include "ppapi/proxy/ppb_instance_proxy.h" |
| 6 | 6 |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
| 10 #include "ppapi/c/pp_time.h" | 10 #include "ppapi/c/pp_time.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ResolveRelativeToDocument, | 164 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ResolveRelativeToDocument, |
| 165 OnHostMsgResolveRelativeToDocument) | 165 OnHostMsgResolveRelativeToDocument) |
| 166 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanRequest, | 166 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanRequest, |
| 167 OnHostMsgDocumentCanRequest) | 167 OnHostMsgDocumentCanRequest) |
| 168 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanAccessDocument, | 168 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanAccessDocument, |
| 169 OnHostMsgDocumentCanAccessDocument) | 169 OnHostMsgDocumentCanAccessDocument) |
| 170 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginInstanceURL, | 170 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginInstanceURL, |
| 171 OnHostMsgGetPluginInstanceURL) | 171 OnHostMsgGetPluginInstanceURL) |
| 172 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginReferrerURL, | 172 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginReferrerURL, |
| 173 OnHostMsgGetPluginReferrerURL) | 173 OnHostMsgGetPluginReferrerURL) |
| 174 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionCreated, | 174 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PromiseResolved, |
| 175 OnHostMsgSessionCreated) | 175 OnHostMsgPromiseResolved) |
| 176 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PromiseResolvedWithSession, |
| 177 OnHostMsgPromiseResolvedWithSession) |
| 178 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PromiseRejected, |
| 179 OnHostMsgPromiseRejected) |
| 176 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionMessage, | 180 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionMessage, |
| 177 OnHostMsgSessionMessage) | 181 OnHostMsgSessionMessage) |
| 178 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionReady, | 182 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionReady, |
| 179 OnHostMsgSessionReady) | 183 OnHostMsgSessionReady) |
| 180 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionClosed, | 184 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionClosed, |
| 181 OnHostMsgSessionClosed) | 185 OnHostMsgSessionClosed) |
| 182 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionError, | 186 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionError, |
| 183 OnHostMsgSessionError) | 187 OnHostMsgSessionError) |
| 184 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DeliverBlock, | 188 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DeliverBlock, |
| 185 OnHostMsgDeliverBlock) | 189 OnHostMsgDeliverBlock) |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 PP_Instance instance, | 556 PP_Instance instance, |
| 553 PP_URLComponents_Dev* components) { | 557 PP_URLComponents_Dev* components) { |
| 554 ReceiveSerializedVarReturnValue result; | 558 ReceiveSerializedVarReturnValue result; |
| 555 dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetPluginReferrerURL( | 559 dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetPluginReferrerURL( |
| 556 API_ID_PPB_INSTANCE, instance, &result)); | 560 API_ID_PPB_INSTANCE, instance, &result)); |
| 557 return PPB_URLUtil_Shared::ConvertComponentsAndReturnURL( | 561 return PPB_URLUtil_Shared::ConvertComponentsAndReturnURL( |
| 558 result.Return(dispatcher()), | 562 result.Return(dispatcher()), |
| 559 components); | 563 components); |
| 560 } | 564 } |
| 561 | 565 |
| 562 void PPB_Instance_Proxy::SessionCreated(PP_Instance instance, | 566 void PPB_Instance_Proxy::PromiseResolved(PP_Instance instance, |
| 563 uint32_t session_id, | 567 uint32 promise_id) { |
| 564 PP_Var web_session_id) { | 568 dispatcher()->Send(new PpapiHostMsg_PPBInstance_PromiseResolved( |
| 565 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionCreated( | 569 API_ID_PPB_INSTANCE, instance, promise_id)); |
| 570 } |
| 571 |
| 572 void PPB_Instance_Proxy::PromiseResolvedWithSession(PP_Instance instance, |
| 573 uint32 promise_id, |
| 574 PP_Var web_session_id_var) { |
| 575 dispatcher()->Send(new PpapiHostMsg_PPBInstance_PromiseResolvedWithSession( |
| 566 API_ID_PPB_INSTANCE, | 576 API_ID_PPB_INSTANCE, |
| 567 instance, | 577 instance, |
| 568 session_id, | 578 promise_id, |
| 569 SerializedVarSendInput(dispatcher(), web_session_id))); | 579 SerializedVarSendInput(dispatcher(), web_session_id_var))); |
| 580 } |
| 581 |
| 582 void PPB_Instance_Proxy::PromiseRejected(PP_Instance instance, |
| 583 uint32 promise_id, |
| 584 PP_ExceptionCode exception_code, |
| 585 uint32 system_code, |
| 586 PP_Var error_description_var) { |
| 587 dispatcher()->Send(new PpapiHostMsg_PPBInstance_PromiseRejected( |
| 588 API_ID_PPB_INSTANCE, |
| 589 instance, |
| 590 promise_id, |
| 591 exception_code, |
| 592 system_code, |
| 593 SerializedVarSendInput(dispatcher(), error_description_var))); |
| 570 } | 594 } |
| 571 | 595 |
| 572 void PPB_Instance_Proxy::SessionMessage(PP_Instance instance, | 596 void PPB_Instance_Proxy::SessionMessage(PP_Instance instance, |
| 573 uint32_t session_id, | 597 PP_Var web_session_id_var, |
| 574 PP_Var message, | 598 PP_Var message_var, |
| 575 PP_Var destination_url) { | 599 PP_Var destination_url_var) { |
| 576 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionMessage( | 600 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionMessage( |
| 577 API_ID_PPB_INSTANCE, | 601 API_ID_PPB_INSTANCE, |
| 578 instance, | 602 instance, |
| 579 session_id, | 603 SerializedVarSendInput(dispatcher(), web_session_id_var), |
| 580 SerializedVarSendInput(dispatcher(), message), | 604 SerializedVarSendInput(dispatcher(), message_var), |
| 581 SerializedVarSendInput(dispatcher(), destination_url))); | 605 SerializedVarSendInput(dispatcher(), destination_url_var))); |
| 582 } | 606 } |
| 583 | 607 |
| 584 void PPB_Instance_Proxy::SessionReady(PP_Instance instance, | 608 void PPB_Instance_Proxy::SessionReady(PP_Instance instance, |
| 585 uint32_t session_id) { | 609 PP_Var web_session_id_var) { |
| 586 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionReady( | 610 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionReady( |
| 587 API_ID_PPB_INSTANCE, instance, session_id)); | 611 API_ID_PPB_INSTANCE, |
| 612 instance, |
| 613 SerializedVarSendInput(dispatcher(), web_session_id_var))); |
| 588 } | 614 } |
| 589 | 615 |
| 590 void PPB_Instance_Proxy::SessionClosed(PP_Instance instance, | 616 void PPB_Instance_Proxy::SessionClosed(PP_Instance instance, |
| 591 uint32_t session_id) { | 617 PP_Var web_session_id_var) { |
| 592 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionClosed( | 618 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionClosed( |
| 593 API_ID_PPB_INSTANCE, instance, session_id)); | 619 API_ID_PPB_INSTANCE, |
| 620 instance, |
| 621 SerializedVarSendInput(dispatcher(), web_session_id_var))); |
| 594 } | 622 } |
| 595 | 623 |
| 596 void PPB_Instance_Proxy::SessionError(PP_Instance instance, | 624 void PPB_Instance_Proxy::SessionError(PP_Instance instance, |
| 597 uint32_t session_id, | 625 PP_Var web_session_id_var, |
| 598 int32_t media_error, | 626 PP_ExceptionCode exception_code, |
| 599 uint32_t system_code) { | 627 uint32 system_code, |
| 628 PP_Var error_description_var) { |
| 600 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionError( | 629 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionError( |
| 601 API_ID_PPB_INSTANCE, instance, session_id, media_error, system_code)); | 630 API_ID_PPB_INSTANCE, |
| 631 instance, |
| 632 SerializedVarSendInput(dispatcher(), web_session_id_var), |
| 633 exception_code, |
| 634 system_code, |
| 635 SerializedVarSendInput(dispatcher(), error_description_var))); |
| 602 } | 636 } |
| 603 | 637 |
| 604 void PPB_Instance_Proxy::DeliverBlock(PP_Instance instance, | 638 void PPB_Instance_Proxy::DeliverBlock(PP_Instance instance, |
| 605 PP_Resource decrypted_block, | 639 PP_Resource decrypted_block, |
| 606 const PP_DecryptedBlockInfo* block_info) { | 640 const PP_DecryptedBlockInfo* block_info) { |
| 607 PP_Resource decrypted_block_host_resource = 0; | 641 PP_Resource decrypted_block_host_resource = 0; |
| 608 | 642 |
| 609 if (decrypted_block) { | 643 if (decrypted_block) { |
| 610 Resource* object = | 644 Resource* object = |
| 611 PpapiGlobals::Get()->GetResourceTracker()->GetResource(decrypted_block); | 645 PpapiGlobals::Get()->GetResourceTracker()->GetResource(decrypted_block); |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 SerializedVarReturnValue result) { | 1138 SerializedVarReturnValue result) { |
| 1105 if (!dispatcher()->permissions().HasPermission(PERMISSION_DEV)) | 1139 if (!dispatcher()->permissions().HasPermission(PERMISSION_DEV)) |
| 1106 return; | 1140 return; |
| 1107 EnterInstanceNoLock enter(instance); | 1141 EnterInstanceNoLock enter(instance); |
| 1108 if (enter.succeeded()) { | 1142 if (enter.succeeded()) { |
| 1109 result.Return(dispatcher(), | 1143 result.Return(dispatcher(), |
| 1110 enter.functions()->GetPluginReferrerURL(instance, NULL)); | 1144 enter.functions()->GetPluginReferrerURL(instance, NULL)); |
| 1111 } | 1145 } |
| 1112 } | 1146 } |
| 1113 | 1147 |
| 1114 void PPB_Instance_Proxy::OnHostMsgSessionCreated( | 1148 void PPB_Instance_Proxy::OnHostMsgPromiseResolved(PP_Instance instance, |
| 1149 uint32_t promise_id) { |
| 1150 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) |
| 1151 return; |
| 1152 EnterInstanceNoLock enter(instance); |
| 1153 if (enter.succeeded()) { |
| 1154 enter.functions()->PromiseResolved(instance, promise_id); |
| 1155 } |
| 1156 } |
| 1157 |
| 1158 void PPB_Instance_Proxy::OnHostMsgPromiseResolvedWithSession( |
| 1115 PP_Instance instance, | 1159 PP_Instance instance, |
| 1116 uint32_t session_id, | 1160 uint32_t promise_id, |
| 1117 SerializedVarReceiveInput web_session_id) { | 1161 SerializedVarReceiveInput web_session_id) { |
| 1118 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) | 1162 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) |
| 1119 return; | 1163 return; |
| 1120 EnterInstanceNoLock enter(instance); | 1164 EnterInstanceNoLock enter(instance); |
| 1121 if (enter.succeeded()) { | 1165 if (enter.succeeded()) { |
| 1122 enter.functions()->SessionCreated( | 1166 enter.functions()->PromiseResolvedWithSession( |
| 1123 instance, session_id, web_session_id.Get(dispatcher())); | 1167 instance, promise_id, web_session_id.Get(dispatcher())); |
| 1168 } |
| 1169 } |
| 1170 |
| 1171 void PPB_Instance_Proxy::OnHostMsgPromiseRejected( |
| 1172 PP_Instance instance, |
| 1173 uint32_t promise_id, |
| 1174 PP_ExceptionCode exception_code, |
| 1175 uint32_t system_code, |
| 1176 SerializedVarReceiveInput error_description) { |
| 1177 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) |
| 1178 return; |
| 1179 EnterInstanceNoLock enter(instance); |
| 1180 if (enter.succeeded()) { |
| 1181 enter.functions()->PromiseRejected(instance, |
| 1182 promise_id, |
| 1183 exception_code, |
| 1184 system_code, |
| 1185 error_description.Get(dispatcher())); |
| 1124 } | 1186 } |
| 1125 } | 1187 } |
| 1126 | 1188 |
| 1127 void PPB_Instance_Proxy::OnHostMsgSessionMessage( | 1189 void PPB_Instance_Proxy::OnHostMsgSessionMessage( |
| 1128 PP_Instance instance, | 1190 PP_Instance instance, |
| 1129 uint32_t session_id, | 1191 SerializedVarReceiveInput web_session_id, |
| 1130 SerializedVarReceiveInput message, | 1192 SerializedVarReceiveInput message, |
| 1131 SerializedVarReceiveInput destination_url) { | 1193 SerializedVarReceiveInput destination_url) { |
| 1132 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) | 1194 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) |
| 1133 return; | 1195 return; |
| 1134 EnterInstanceNoLock enter(instance); | 1196 EnterInstanceNoLock enter(instance); |
| 1135 if (enter.succeeded()) { | 1197 if (enter.succeeded()) { |
| 1136 enter.functions()->SessionMessage(instance, | 1198 enter.functions()->SessionMessage(instance, |
| 1137 session_id, | 1199 web_session_id.Get(dispatcher()), |
| 1138 message.Get(dispatcher()), | 1200 message.Get(dispatcher()), |
| 1139 destination_url.Get(dispatcher())); | 1201 destination_url.Get(dispatcher())); |
| 1140 } | 1202 } |
| 1141 } | 1203 } |
| 1142 | 1204 |
| 1143 void PPB_Instance_Proxy::OnHostMsgSessionReady(PP_Instance instance, | 1205 void PPB_Instance_Proxy::OnHostMsgSessionReady( |
| 1144 uint32_t session_id) { | 1206 PP_Instance instance, |
| 1207 SerializedVarReceiveInput web_session_id) { |
| 1145 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) | 1208 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) |
| 1146 return; | 1209 return; |
| 1147 EnterInstanceNoLock enter(instance); | 1210 EnterInstanceNoLock enter(instance); |
| 1148 if (enter.succeeded()) { | 1211 if (enter.succeeded()) { |
| 1149 enter.functions()->SessionReady(instance, session_id); | 1212 enter.functions()->SessionReady(instance, web_session_id.Get(dispatcher())); |
| 1150 } | 1213 } |
| 1151 } | 1214 } |
| 1152 | 1215 |
| 1153 void PPB_Instance_Proxy::OnHostMsgSessionClosed(PP_Instance instance, | 1216 void PPB_Instance_Proxy::OnHostMsgSessionClosed( |
| 1154 uint32_t session_id) { | 1217 PP_Instance instance, |
| 1218 SerializedVarReceiveInput web_session_id) { |
| 1155 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) | 1219 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) |
| 1156 return; | 1220 return; |
| 1157 EnterInstanceNoLock enter(instance); | 1221 EnterInstanceNoLock enter(instance); |
| 1158 if (enter.succeeded()) { | 1222 if (enter.succeeded()) { |
| 1159 enter.functions()->SessionClosed(instance, session_id); | 1223 enter.functions()->SessionClosed(instance, |
| 1224 web_session_id.Get(dispatcher())); |
| 1160 } | 1225 } |
| 1161 } | 1226 } |
| 1162 | 1227 |
| 1163 void PPB_Instance_Proxy::OnHostMsgSessionError(PP_Instance instance, | 1228 void PPB_Instance_Proxy::OnHostMsgSessionError( |
| 1164 uint32_t session_id, | 1229 PP_Instance instance, |
| 1165 int32_t media_error, | 1230 SerializedVarReceiveInput web_session_id, |
| 1166 uint32_t system_code) { | 1231 PP_ExceptionCode exception_code, |
| 1232 uint32_t system_code, |
| 1233 SerializedVarReceiveInput error_description) { |
| 1167 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) | 1234 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) |
| 1168 return; | 1235 return; |
| 1169 EnterInstanceNoLock enter(instance); | 1236 EnterInstanceNoLock enter(instance); |
| 1170 if (enter.succeeded()) { | 1237 if (enter.succeeded()) { |
| 1171 enter.functions()->SessionError( | 1238 enter.functions()->SessionError(instance, |
| 1172 instance, session_id, media_error, system_code); | 1239 web_session_id.Get(dispatcher()), |
| 1240 exception_code, |
| 1241 system_code, |
| 1242 error_description.Get(dispatcher())); |
| 1173 } | 1243 } |
| 1174 } | 1244 } |
| 1175 | 1245 |
| 1176 void PPB_Instance_Proxy::OnHostMsgDeliverBlock( | 1246 void PPB_Instance_Proxy::OnHostMsgDeliverBlock( |
| 1177 PP_Instance instance, | 1247 PP_Instance instance, |
| 1178 PP_Resource decrypted_block, | 1248 PP_Resource decrypted_block, |
| 1179 const std::string& serialized_block_info) { | 1249 const std::string& serialized_block_info) { |
| 1180 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) | 1250 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) |
| 1181 return; | 1251 return; |
| 1182 PP_DecryptedBlockInfo block_info; | 1252 PP_DecryptedBlockInfo block_info; |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 PP_Instance instance) { | 1406 PP_Instance instance) { |
| 1337 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> | 1407 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> |
| 1338 GetInstanceData(instance); | 1408 GetInstanceData(instance); |
| 1339 if (!data) | 1409 if (!data) |
| 1340 return; // Instance was probably deleted. | 1410 return; // Instance was probably deleted. |
| 1341 data->should_do_request_surrounding_text = false; | 1411 data->should_do_request_surrounding_text = false; |
| 1342 } | 1412 } |
| 1343 | 1413 |
| 1344 } // namespace proxy | 1414 } // namespace proxy |
| 1345 } // namespace ppapi | 1415 } // namespace ppapi |
| OLD | NEW |