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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/stl_util.h" |
12 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
13 #include "base/time.h" | 14 #include "base/time.h" |
14 #include "base/utf_offset_string_conversions.h" | 15 #include "base/utf_offset_string_conversions.h" |
15 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 17 #include "media/base/decoder_buffer.h" |
| 18 #include "media/base/decryptor_client.h" |
16 #include "ppapi/c/dev/ppb_find_dev.h" | 19 #include "ppapi/c/dev/ppb_find_dev.h" |
17 #include "ppapi/c/dev/ppb_zoom_dev.h" | 20 #include "ppapi/c/dev/ppb_zoom_dev.h" |
18 #include "ppapi/c/dev/ppp_find_dev.h" | 21 #include "ppapi/c/dev/ppp_find_dev.h" |
19 #include "ppapi/c/dev/ppp_selection_dev.h" | 22 #include "ppapi/c/dev/ppp_selection_dev.h" |
20 #include "ppapi/c/dev/ppp_text_input_dev.h" | 23 #include "ppapi/c/dev/ppp_text_input_dev.h" |
21 #include "ppapi/c/dev/ppp_zoom_dev.h" | 24 #include "ppapi/c/dev/ppp_zoom_dev.h" |
22 #include "ppapi/c/pp_rect.h" | 25 #include "ppapi/c/pp_rect.h" |
23 #include "ppapi/c/ppb_audio_config.h" | 26 #include "ppapi/c/ppb_audio_config.h" |
24 #include "ppapi/c/ppb_core.h" | 27 #include "ppapi/c/ppb_core.h" |
25 #include "ppapi/c/ppb_gamepad.h" | 28 #include "ppapi/c/ppb_gamepad.h" |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 for (size_t i = 0; i < vector.size(); ++i) | 298 for (size_t i = 0; i < vector.size(); ++i) |
296 array[i] = vector[i].c_str(); | 299 array[i] = vector[i].c_str(); |
297 return array.Pass(); | 300 return array.Pass(); |
298 } | 301 } |
299 | 302 |
300 // Creates a PP_Resource containing a PPB_Buffer_Impl, copies |data| into the | 303 // Creates a PP_Resource containing a PPB_Buffer_Impl, copies |data| into the |
301 // buffer resource, and returns it. Returns a an invalid PP_Resource with an ID | 304 // buffer resource, and returns it. Returns a an invalid PP_Resource with an ID |
302 // of 0 on failure. Upon success, the returned Buffer resource has a reference | 305 // of 0 on failure. Upon success, the returned Buffer resource has a reference |
303 // count of 1. | 306 // count of 1. |
304 PP_Resource MakeBufferResource(PP_Instance instance, | 307 PP_Resource MakeBufferResource(PP_Instance instance, |
305 const base::StringPiece& data) { | 308 const uint8* data, int size) { |
306 if (data.empty()) | 309 if (!data || !size) |
307 return 0; | 310 return 0; |
308 | 311 |
309 ScopedPPResource resource(PPB_Buffer_Impl::Create(instance, data.size())); | 312 ScopedPPResource resource(PPB_Buffer_Impl::Create(instance, size)); |
310 if (!resource.get()) | 313 if (!resource.get()) |
311 return 0; | 314 return 0; |
312 | 315 |
313 EnterResourceNoLock<PPB_Buffer_API> enter(resource, true); | 316 EnterResourceNoLock<PPB_Buffer_API> enter(resource, true); |
314 if (enter.failed()) | 317 if (enter.failed()) |
315 return 0; | 318 return 0; |
316 | 319 |
317 BufferAutoMapper mapper(enter.object()); | 320 BufferAutoMapper mapper(enter.object()); |
318 memcpy(mapper.data(), data.data(), data.size()); | 321 if (!mapper.data() || mapper.size() < static_cast<size_t>(size)) |
| 322 return 0; |
319 | 323 |
| 324 memcpy(mapper.data(), data, size); |
320 return resource.get(); | 325 return resource.get(); |
321 } | 326 } |
322 | 327 |
| 328 // Copies the content of |str| into |array|. |
| 329 // Returns true if copy succeeded. Returns false if copy failed, e.g. if the |
| 330 // |array_size| is smaller than the |str| length. |
| 331 template <uint32_t array_size> |
| 332 bool CopyStringToArray(const std::string& str, uint8 (&array)[array_size]) { |
| 333 if (array_size < str.size()) |
| 334 return false; |
| 335 |
| 336 memcpy(array, str.data(), str.size()); |
| 337 return true; |
| 338 } |
| 339 |
| 340 // Fills the |block_info| with information from |decrypt_config|, |timestamp| |
| 341 // and |request_id|. |
| 342 // Returns true if |block_info| is successfully filled. Returns false otherwise. |
| 343 bool MakeEncryptedBlockInfo( |
| 344 const media::DecryptConfig& decrypt_config, |
| 345 int64_t timestamp, |
| 346 uint32_t request_id, |
| 347 PP_EncryptedBlockInfo* block_info) { |
| 348 DCHECK(block_info); |
| 349 |
| 350 // TODO(xhwang): Fix initialization of PP_EncryptedBlockInfo here and |
| 351 // anywhere else. |
| 352 memset(block_info, 0, sizeof(*block_info)); |
| 353 |
| 354 block_info->tracking_info.request_id = request_id; |
| 355 block_info->tracking_info.timestamp = timestamp; |
| 356 block_info->data_offset = decrypt_config.data_offset(); |
| 357 |
| 358 if (!CopyStringToArray(decrypt_config.key_id(), block_info->key_id) || |
| 359 !CopyStringToArray(decrypt_config.iv(), block_info->iv) || |
| 360 !CopyStringToArray(decrypt_config.checksum(), block_info->checksum)) |
| 361 return false; |
| 362 |
| 363 block_info->key_id_size = decrypt_config.key_id().size(); |
| 364 block_info->iv_size = decrypt_config.iv().size(); |
| 365 block_info->checksum_size = decrypt_config.checksum().size(); |
| 366 |
| 367 if (decrypt_config.subsamples().size() > arraysize(block_info->subsamples)) |
| 368 return false; |
| 369 |
| 370 block_info->num_subsamples = decrypt_config.subsamples().size(); |
| 371 for (uint32_t i = 0; i < block_info->num_subsamples; ++i) { |
| 372 block_info->subsamples[i].clear_bytes = |
| 373 decrypt_config.subsamples()[i].clear_bytes; |
| 374 block_info->subsamples[i].cipher_bytes = |
| 375 decrypt_config.subsamples()[i].cypher_bytes; |
| 376 } |
| 377 |
| 378 return true; |
| 379 } |
| 380 |
323 } // namespace | 381 } // namespace |
324 | 382 |
325 // static | 383 // static |
326 PluginInstance* PluginInstance::Create(PluginDelegate* delegate, | 384 PluginInstance* PluginInstance::Create(PluginDelegate* delegate, |
327 PluginModule* module) { | 385 PluginModule* module) { |
328 base::Callback<const void*(const char*)> get_plugin_interface_func = | 386 base::Callback<const void*(const char*)> get_plugin_interface_func = |
329 base::Bind(&PluginModule::GetPluginInterface, module); | 387 base::Bind(&PluginModule::GetPluginInterface, module); |
330 PPP_Instance_Combined* ppp_instance_combined = | 388 PPP_Instance_Combined* ppp_instance_combined = |
331 PPP_Instance_Combined::Create(get_plugin_interface_func); | 389 PPP_Instance_Combined::Create(get_plugin_interface_func); |
332 if (!ppp_instance_combined) | 390 if (!ppp_instance_combined) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 sad_plugin_(NULL), | 440 sad_plugin_(NULL), |
383 input_event_mask_(0), | 441 input_event_mask_(0), |
384 filtered_input_event_mask_(0), | 442 filtered_input_event_mask_(0), |
385 text_input_type_(kPluginDefaultTextInputType), | 443 text_input_type_(kPluginDefaultTextInputType), |
386 text_input_caret_(0, 0, 0, 0), | 444 text_input_caret_(0, 0, 0, 0), |
387 text_input_caret_bounds_(0, 0, 0, 0), | 445 text_input_caret_bounds_(0, 0, 0, 0), |
388 text_input_caret_set_(false), | 446 text_input_caret_set_(false), |
389 selection_caret_(0), | 447 selection_caret_(0), |
390 selection_anchor_(0), | 448 selection_anchor_(0), |
391 pending_user_gesture_(0.0), | 449 pending_user_gesture_(0.0), |
392 flash_impl_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 450 flash_impl_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 451 decryptor_client_(NULL), |
| 452 next_decryption_request_id_(1) { |
393 pp_instance_ = HostGlobals::Get()->AddInstance(this); | 453 pp_instance_ = HostGlobals::Get()->AddInstance(this); |
394 | 454 |
395 memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); | 455 memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); |
396 DCHECK(delegate); | 456 DCHECK(delegate); |
397 module_->InstanceCreated(this); | 457 module_->InstanceCreated(this); |
398 delegate_->InstanceCreated(this); | 458 delegate_->InstanceCreated(this); |
399 message_channel_.reset(new MessageChannel(this)); | 459 message_channel_.reset(new MessageChannel(this)); |
400 | 460 |
401 view_data_.is_page_visible = delegate->IsPageVisible(); | 461 view_data_.is_page_visible = delegate->IsPageVisible(); |
402 | 462 |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1323 if (!LoadPdfInterface()) | 1383 if (!LoadPdfInterface()) |
1324 return; | 1384 return; |
1325 PP_PrivatePageTransformType transform_type = | 1385 PP_PrivatePageTransformType transform_type = |
1326 type == WebPlugin::RotationType90Clockwise ? | 1386 type == WebPlugin::RotationType90Clockwise ? |
1327 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW : | 1387 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW : |
1328 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW; | 1388 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW; |
1329 plugin_pdf_interface_->Transform(pp_instance(), transform_type); | 1389 plugin_pdf_interface_->Transform(pp_instance(), transform_type); |
1330 // NOTE: plugin instance may have been deleted. | 1390 // NOTE: plugin instance may have been deleted. |
1331 } | 1391 } |
1332 | 1392 |
| 1393 void PluginInstance::set_decrypt_client( |
| 1394 media::DecryptorClient* decryptor_client) { |
| 1395 DCHECK(decryptor_client); |
| 1396 decryptor_client_ = decryptor_client; |
| 1397 } |
| 1398 |
1333 bool PluginInstance::GenerateKeyRequest(const std::string& key_system, | 1399 bool PluginInstance::GenerateKeyRequest(const std::string& key_system, |
1334 const std::string& init_data) { | 1400 const std::string& init_data) { |
1335 if (!LoadContentDecryptorInterface()) | 1401 if (!LoadContentDecryptorInterface()) |
1336 return false; | 1402 return false; |
1337 if (key_system.empty()) | 1403 if (key_system.empty()) |
1338 return false; | 1404 return false; |
| 1405 |
1339 PP_Var init_data_array = | 1406 PP_Var init_data_array = |
1340 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( | 1407 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( |
1341 init_data.size(), init_data.data()); | 1408 init_data.size(), init_data.data()); |
1342 | 1409 |
1343 return PP_ToBool(plugin_decryption_interface_->GenerateKeyRequest( | 1410 return PP_ToBool(plugin_decryption_interface_->GenerateKeyRequest( |
1344 pp_instance(), | 1411 pp_instance(), |
1345 StringVar::StringToPPVar(key_system), | 1412 StringVar::StringToPPVar(key_system), |
1346 init_data_array)); | 1413 init_data_array)); |
1347 } | 1414 } |
1348 | 1415 |
(...skipping 19 matching lines...) Expand all Loading... |
1368 | 1435 |
1369 bool PluginInstance::CancelKeyRequest(const std::string& session_id) { | 1436 bool PluginInstance::CancelKeyRequest(const std::string& session_id) { |
1370 if (!LoadContentDecryptorInterface()) | 1437 if (!LoadContentDecryptorInterface()) |
1371 return false; | 1438 return false; |
1372 | 1439 |
1373 return PP_ToBool(plugin_decryption_interface_->CancelKeyRequest( | 1440 return PP_ToBool(plugin_decryption_interface_->CancelKeyRequest( |
1374 pp_instance(), | 1441 pp_instance(), |
1375 StringVar::StringToPPVar(session_id))); | 1442 StringVar::StringToPPVar(session_id))); |
1376 } | 1443 } |
1377 | 1444 |
1378 bool PluginInstance::Decrypt(const base::StringPiece& encrypted_block, | 1445 bool PluginInstance::Decrypt( |
1379 const DecryptedDataCB& callback) { | 1446 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, |
| 1447 const media::Decryptor::DecryptCB& decrypt_cb) { |
1380 if (!LoadContentDecryptorInterface()) | 1448 if (!LoadContentDecryptorInterface()) |
1381 return false; | 1449 return false; |
1382 ScopedPPResource encrypted_resource(MakeBufferResource(pp_instance(), | 1450 |
1383 encrypted_block)); | 1451 ScopedPPResource encrypted_resource( |
| 1452 MakeBufferResource(pp_instance(), |
| 1453 encrypted_buffer->GetData(), |
| 1454 encrypted_buffer->GetDataSize())); |
| 1455 if (!encrypted_resource.get()) |
| 1456 return false; |
| 1457 |
| 1458 uint32_t request_id = next_decryption_request_id_++; |
| 1459 |
| 1460 PP_EncryptedBlockInfo block_info; |
| 1461 DCHECK(encrypted_buffer->GetDecryptConfig()); |
| 1462 if (!MakeEncryptedBlockInfo(*encrypted_buffer->GetDecryptConfig(), |
| 1463 encrypted_buffer->GetTimestamp().InMicroseconds(), |
| 1464 request_id, |
| 1465 &block_info)) { |
| 1466 return false; |
| 1467 } |
| 1468 |
| 1469 DCHECK(!ContainsKey(pending_decryption_cbs_, request_id)); |
| 1470 pending_decryption_cbs_.insert(std::make_pair(request_id, decrypt_cb)); |
| 1471 |
| 1472 return PP_ToBool(plugin_decryption_interface_->Decrypt(pp_instance(), |
| 1473 encrypted_resource, |
| 1474 &block_info)); |
| 1475 } |
| 1476 |
| 1477 bool PluginInstance::DecryptAndDecode( |
| 1478 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, |
| 1479 const media::Decryptor::DecryptCB& decrypt_cb) { |
| 1480 if (!LoadContentDecryptorInterface()) |
| 1481 return false; |
| 1482 |
| 1483 ScopedPPResource encrypted_resource(MakeBufferResource( |
| 1484 pp_instance(), |
| 1485 encrypted_buffer->GetData(), |
| 1486 encrypted_buffer->GetDataSize())); |
1384 if (!encrypted_resource.get()) | 1487 if (!encrypted_resource.get()) |
1385 return false; | 1488 return false; |
1386 | 1489 |
1387 PP_EncryptedBlockInfo block_info; | 1490 PP_EncryptedBlockInfo block_info; |
1388 | 1491 |
1389 // TODO(tomfinegan): Store callback and ID in a map, and pass ID to decryptor. | 1492 // TODO(tomfinegan): Store callback and ID in a map, and pass ID to decryptor. |
1390 return PP_ToBool(plugin_decryption_interface_->Decrypt(pp_instance(), | 1493 return PP_ToBool( |
1391 encrypted_resource, | 1494 plugin_decryption_interface_->DecryptAndDecode(pp_instance(), |
1392 &block_info)); | 1495 encrypted_resource, |
1393 } | 1496 &block_info)); |
1394 | |
1395 bool PluginInstance::DecryptAndDecode(const base::StringPiece& encrypted_block, | |
1396 const DecryptedDataCB& callback) { | |
1397 if (!LoadContentDecryptorInterface()) | |
1398 return false; | |
1399 ScopedPPResource encrypted_resource(MakeBufferResource(pp_instance(), | |
1400 encrypted_block)); | |
1401 if (!encrypted_resource.get()) | |
1402 return false; | |
1403 | |
1404 PP_EncryptedBlockInfo block_info; | |
1405 | |
1406 // TODO(tomfinegan): Store callback and ID in a map, and pass ID to decryptor. | |
1407 return PP_ToBool(plugin_decryption_interface_->DecryptAndDecode( | |
1408 pp_instance(), | |
1409 encrypted_resource, | |
1410 &block_info)); | |
1411 } | 1497 } |
1412 | 1498 |
1413 bool PluginInstance::FlashIsFullscreenOrPending() { | 1499 bool PluginInstance::FlashIsFullscreenOrPending() { |
1414 return fullscreen_container_ != NULL; | 1500 return fullscreen_container_ != NULL; |
1415 } | 1501 } |
1416 | 1502 |
1417 bool PluginInstance::IsFullscreenOrPending() { | 1503 bool PluginInstance::IsFullscreenOrPending() { |
1418 return desired_fullscreen_state_; | 1504 return desired_fullscreen_state_; |
1419 } | 1505 } |
1420 | 1506 |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2013 void PluginInstance::NeedKey(PP_Instance instance, | 2099 void PluginInstance::NeedKey(PP_Instance instance, |
2014 PP_Var key_system_var, | 2100 PP_Var key_system_var, |
2015 PP_Var session_id_var, | 2101 PP_Var session_id_var, |
2016 PP_Var init_data_var) { | 2102 PP_Var init_data_var) { |
2017 // TODO(tomfinegan): send the data to media stack. | 2103 // TODO(tomfinegan): send the data to media stack. |
2018 } | 2104 } |
2019 | 2105 |
2020 void PluginInstance::KeyAdded(PP_Instance instance, | 2106 void PluginInstance::KeyAdded(PP_Instance instance, |
2021 PP_Var key_system_var, | 2107 PP_Var key_system_var, |
2022 PP_Var session_id_var) { | 2108 PP_Var session_id_var) { |
2023 // TODO(tomfinegan): send the data to media stack. | 2109 StringVar* key_system_string = StringVar::FromPPVar(key_system_var); |
| 2110 StringVar* session_id_string = StringVar::FromPPVar(session_id_var); |
| 2111 if (!key_system_string || !session_id_string) { |
| 2112 decryptor_client_->KeyError("", "", media::Decryptor::kUnknownError, 0); |
| 2113 return; |
| 2114 } |
| 2115 |
| 2116 DCHECK(decryptor_client_); |
| 2117 decryptor_client_->KeyAdded(key_system_string->value(), |
| 2118 session_id_string->value()); |
2024 } | 2119 } |
2025 | 2120 |
2026 void PluginInstance::KeyMessage(PP_Instance instance, | 2121 void PluginInstance::KeyMessage(PP_Instance instance, |
2027 PP_Var key_system_var, | 2122 PP_Var key_system_var, |
2028 PP_Var session_id_var, | 2123 PP_Var session_id_var, |
2029 PP_Resource message_resource, | 2124 PP_Resource message_resource, |
2030 PP_Var default_url_var) { | 2125 PP_Var default_url_var) { |
2031 // TODO(tomfinegan): send the data to media stack. | 2126 StringVar* key_system_string = StringVar::FromPPVar(key_system_var); |
| 2127 StringVar* session_id_string = StringVar::FromPPVar(session_id_var); |
| 2128 StringVar* default_url_string = StringVar::FromPPVar(default_url_var); |
| 2129 |
| 2130 if (!key_system_string || !session_id_string || !default_url_string) { |
| 2131 decryptor_client_->KeyError("", "", media::Decryptor::kUnknownError, 0); |
| 2132 return; |
| 2133 } |
| 2134 |
| 2135 EnterResourceNoLock<PPB_Buffer_API> enter(message_resource, true); |
| 2136 if (!enter.succeeded()) { |
| 2137 decryptor_client_->KeyError(key_system_string->value(), |
| 2138 session_id_string->value(), |
| 2139 media::Decryptor::kUnknownError, |
| 2140 0); |
| 2141 return; |
| 2142 } |
| 2143 |
| 2144 BufferAutoMapper mapper(enter.object()); |
| 2145 scoped_array<uint8> message_array(new uint8[mapper.size()]); |
| 2146 if (mapper.data() && mapper.size()) |
| 2147 memcpy(message_array.get(), mapper.data(), mapper.size()); |
| 2148 |
| 2149 DCHECK(decryptor_client_); |
| 2150 decryptor_client_->KeyMessage(key_system_string->value(), |
| 2151 session_id_string->value(), |
| 2152 message_array.Pass(), |
| 2153 mapper.size(), |
| 2154 default_url_string->value()); |
2032 } | 2155 } |
2033 | 2156 |
2034 void PluginInstance::KeyError(PP_Instance instance, | 2157 void PluginInstance::KeyError(PP_Instance instance, |
2035 PP_Var key_system_var, | 2158 PP_Var key_system_var, |
2036 PP_Var session_id_var, | 2159 PP_Var session_id_var, |
2037 int32_t media_error, | 2160 int32_t media_error, |
2038 int32_t system_code) { | 2161 int32_t system_code) { |
2039 // TODO(tomfinegan): send the data to media stack. | 2162 StringVar* key_system_string = StringVar::FromPPVar(key_system_var); |
| 2163 StringVar* session_id_string = StringVar::FromPPVar(session_id_var); |
| 2164 if (!key_system_string || !session_id_string) { |
| 2165 decryptor_client_->KeyError("", "", media::Decryptor::kUnknownError, 0); |
| 2166 return; |
| 2167 } |
| 2168 |
| 2169 DCHECK(decryptor_client_); |
| 2170 decryptor_client_->KeyError( |
| 2171 key_system_string->value(), |
| 2172 session_id_string->value(), |
| 2173 static_cast<media::Decryptor::KeyError>(media_error), |
| 2174 system_code); |
2040 } | 2175 } |
2041 | 2176 |
2042 void PluginInstance::DeliverBlock(PP_Instance instance, | 2177 void PluginInstance::DeliverBlock(PP_Instance instance, |
2043 PP_Resource decrypted_block, | 2178 PP_Resource decrypted_block, |
2044 const PP_DecryptedBlockInfo* block_info) { | 2179 const PP_DecryptedBlockInfo* block_info) { |
2045 // TODO(xhwang): Pass the decrypted block back to media stack. | 2180 DCHECK(block_info); |
| 2181 |
| 2182 DecryptionCBMap::iterator found = pending_decryption_cbs_.find( |
| 2183 block_info->tracking_info.request_id); |
| 2184 |
| 2185 if (found == pending_decryption_cbs_.end()) |
| 2186 return; |
| 2187 media::Decryptor::DecryptCB decrypt_cb = found->second; |
| 2188 pending_decryption_cbs_.erase(found); |
| 2189 |
| 2190 if (block_info->result == PP_DECRYPTRESULT_DECRYPT_NOKEY) { |
| 2191 decrypt_cb.Run(media::Decryptor::kNoKey, NULL); |
| 2192 return; |
| 2193 } |
| 2194 if (block_info->result != PP_DECRYPTRESULT_SUCCESS) { |
| 2195 decrypt_cb.Run(media::Decryptor::kError, NULL); |
| 2196 return; |
| 2197 } |
| 2198 EnterResourceNoLock<PPB_Buffer_API> enter(decrypted_block, true); |
| 2199 |
| 2200 if (!enter.succeeded()) { |
| 2201 decrypt_cb.Run(media::Decryptor::kError, NULL); |
| 2202 return; |
| 2203 } |
| 2204 BufferAutoMapper mapper(enter.object()); |
| 2205 if (!mapper.data() || !mapper.size()) { |
| 2206 decrypt_cb.Run(media::Decryptor::kError, NULL); |
| 2207 return; |
| 2208 } |
| 2209 |
| 2210 scoped_refptr<media::DecoderBuffer> decrypted_buffer( |
| 2211 media::DecoderBuffer::CopyFrom( |
| 2212 reinterpret_cast<const uint8*>(mapper.data()), mapper.size())); |
| 2213 decrypted_buffer->SetTimestamp(base::TimeDelta::FromMicroseconds( |
| 2214 block_info->tracking_info.timestamp)); |
| 2215 decrypt_cb.Run(media::Decryptor::kSuccess, decrypted_buffer); |
2046 } | 2216 } |
2047 | 2217 |
2048 void PluginInstance::DeliverFrame(PP_Instance instance, | 2218 void PluginInstance::DeliverFrame(PP_Instance instance, |
2049 PP_Resource decrypted_frame, | 2219 PP_Resource decrypted_frame, |
2050 const PP_DecryptedBlockInfo* block_info) { | 2220 const PP_DecryptedBlockInfo* block_info) { |
2051 // TODO(tomfinegan): To be implemented after completion of v0.1 of the | 2221 // TODO(tomfinegan): To be implemented after completion of v0.1 of the |
2052 // EME/CDM work. | 2222 // EME/CDM work. |
2053 } | 2223 } |
2054 | 2224 |
2055 void PluginInstance::DeliverSamples(PP_Instance instance, | 2225 void PluginInstance::DeliverSamples(PP_Instance instance, |
2056 PP_Resource decrypted_samples, | 2226 PP_Resource decrypted_samples, |
2057 const PP_DecryptedBlockInfo* block_info) { | 2227 const PP_DecryptedBlockInfo* block_info) { |
2058 // TODO(tomfinegan): To be implemented after completion of v0.1 of the | 2228 // TODO(tomfinegan): To be implemented after completion of v0.1 of the |
2059 // EME/CDM work. | 2229 // EME/CDM work. |
2060 } | 2230 } |
2061 | 2231 |
2062 | |
2063 void PluginInstance::NumberOfFindResultsChanged(PP_Instance instance, | 2232 void PluginInstance::NumberOfFindResultsChanged(PP_Instance instance, |
2064 int32_t total, | 2233 int32_t total, |
2065 PP_Bool final_result) { | 2234 PP_Bool final_result) { |
2066 DCHECK_NE(find_identifier_, -1); | 2235 DCHECK_NE(find_identifier_, -1); |
2067 delegate_->NumberOfFindResultsChanged(find_identifier_, total, | 2236 delegate_->NumberOfFindResultsChanged(find_identifier_, total, |
2068 PP_ToBool(final_result)); | 2237 PP_ToBool(final_result)); |
2069 } | 2238 } |
2070 | 2239 |
2071 void PluginInstance::SelectedFindResultChanged(PP_Instance instance, | 2240 void PluginInstance::SelectedFindResultChanged(PP_Instance instance, |
2072 int32_t index) { | 2241 int32_t index) { |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2433 screen_size_for_fullscreen_ = gfx::Size(); | 2602 screen_size_for_fullscreen_ = gfx::Size(); |
2434 WebElement element = container_->element(); | 2603 WebElement element = container_->element(); |
2435 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2604 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
2436 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2605 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
2437 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2606 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
2438 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2607 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
2439 } | 2608 } |
2440 | 2609 |
2441 } // namespace ppapi | 2610 } // namespace ppapi |
2442 } // namespace webkit | 2611 } // namespace webkit |
OLD | NEW |