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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 for (size_t i = 0; i < vector.size(); ++i) | 297 for (size_t i = 0; i < vector.size(); ++i) |
295 array[i] = vector[i].c_str(); | 298 array[i] = vector[i].c_str(); |
296 return array.Pass(); | 299 return array.Pass(); |
297 } | 300 } |
298 | 301 |
299 // Creates a PP_Resource containing a PPB_Buffer_Impl, copies |data| into the | 302 // Creates a PP_Resource containing a PPB_Buffer_Impl, copies |data| into the |
300 // buffer resource, and returns it. Returns a an invalid PP_Resource with an ID | 303 // buffer resource, and returns it. Returns a an invalid PP_Resource with an ID |
301 // of 0 on failure. Upon success, the returned Buffer resource has a reference | 304 // of 0 on failure. Upon success, the returned Buffer resource has a reference |
302 // count of 1. | 305 // count of 1. |
303 PP_Resource MakeBufferResource(PP_Instance instance, | 306 PP_Resource MakeBufferResource(PP_Instance instance, |
304 const base::StringPiece& data) { | 307 const uint8* data, int size) { |
305 if (data.empty()) | 308 if (!data || !size) |
306 return 0; | 309 return 0; |
307 | 310 |
308 ScopedPPResource resource(PPB_Buffer_Impl::Create(instance, data.size())); | 311 ScopedPPResource resource(PPB_Buffer_Impl::Create(instance, size)); |
309 if (!resource.get()) | 312 if (!resource.get()) |
310 return 0; | 313 return 0; |
311 | 314 |
312 EnterResourceNoLock<PPB_Buffer_API> enter(resource, true); | 315 EnterResourceNoLock<PPB_Buffer_API> enter(resource, true); |
313 if (enter.failed()) | 316 if (enter.failed()) |
314 return 0; | 317 return 0; |
315 | 318 |
316 BufferAutoMapper mapper(enter.object()); | 319 BufferAutoMapper mapper(enter.object()); |
317 memcpy(mapper.data(), data.data(), data.size()); | 320 if (!mapper.data() || mapper.size() < static_cast<size_t>(size)) |
| 321 return 0; |
318 | 322 |
| 323 memcpy(mapper.data(), data, size); |
319 return resource.get(); | 324 return resource.get(); |
320 } | 325 } |
321 | 326 |
| 327 // Copies the content of |str| into |array|. |
| 328 // Returns true if copy succeeded. Returns false if copy failed, e.g. if the |
| 329 // |array_size| is smaller than the |str| length. |
| 330 template <uint32_t array_size> |
| 331 bool CopyStringToArray(const std::string& str, uint8 (&array)[array_size]) { |
| 332 if (array_size < str.size()) |
| 333 return false; |
| 334 |
| 335 memcpy(array, str.data(), str.size()); |
| 336 return true; |
| 337 } |
| 338 |
| 339 // Fills the |block_info| with information from |decrypt_config|, |timestamp| |
| 340 // and |request_id|. |
| 341 // Returns true if |block_info| is successfully filled. Returns false otherwise. |
| 342 bool MakeEncryptedBlockInfo( |
| 343 const media::DecryptConfig& decrypt_config, |
| 344 int64_t timestamp, |
| 345 uint32_t request_id, |
| 346 PP_EncryptedBlockInfo* block_info) { |
| 347 DCHECK(block_info); |
| 348 |
| 349 // TODO(xhwang): Fix initialization of PP_EncryptedBlockInfo here and |
| 350 // anywhere else. |
| 351 memset(&block_info, 0, sizeof(block_info)); |
| 352 |
| 353 block_info->tracking_info.request_id = request_id; |
| 354 block_info->tracking_info.timestamp = timestamp; |
| 355 block_info->data_offset = decrypt_config.data_offset(); |
| 356 |
| 357 if (!CopyStringToArray(decrypt_config.key_id(), block_info->key_id) || |
| 358 !CopyStringToArray(decrypt_config.iv(), block_info->iv) || |
| 359 !CopyStringToArray(decrypt_config.checksum(), block_info->checksum)) |
| 360 return false; |
| 361 |
| 362 block_info->key_id_size = decrypt_config.key_id().size(); |
| 363 block_info->iv_size = decrypt_config.iv().size(); |
| 364 block_info->checksum_size = decrypt_config.checksum().size(); |
| 365 |
| 366 if (decrypt_config.subsamples().size() > arraysize(block_info->subsamples)) |
| 367 return false; |
| 368 |
| 369 block_info->num_subsamples = decrypt_config.subsamples().size(); |
| 370 for (uint32_t i = 0; i < block_info->num_subsamples; ++i) { |
| 371 block_info->subsamples[i].clear_bytes = |
| 372 decrypt_config.subsamples()[i].clear_bytes; |
| 373 block_info->subsamples[i].cipher_bytes = |
| 374 decrypt_config.subsamples()[i].cypher_bytes; |
| 375 } |
| 376 |
| 377 return true; |
| 378 } |
| 379 |
322 } // namespace | 380 } // namespace |
323 | 381 |
324 // static | 382 // static |
325 PluginInstance* PluginInstance::Create(PluginDelegate* delegate, | 383 PluginInstance* PluginInstance::Create(PluginDelegate* delegate, |
326 PluginModule* module) { | 384 PluginModule* module) { |
327 base::Callback<const void*(const char*)> get_plugin_interface_func = | 385 base::Callback<const void*(const char*)> get_plugin_interface_func = |
328 base::Bind(&PluginModule::GetPluginInterface, module); | 386 base::Bind(&PluginModule::GetPluginInterface, module); |
329 PPP_Instance_Combined* ppp_instance_combined = | 387 PPP_Instance_Combined* ppp_instance_combined = |
330 PPP_Instance_Combined::Create(get_plugin_interface_func); | 388 PPP_Instance_Combined::Create(get_plugin_interface_func); |
331 if (!ppp_instance_combined) | 389 if (!ppp_instance_combined) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 sad_plugin_(NULL), | 428 sad_plugin_(NULL), |
371 input_event_mask_(0), | 429 input_event_mask_(0), |
372 filtered_input_event_mask_(0), | 430 filtered_input_event_mask_(0), |
373 text_input_type_(kPluginDefaultTextInputType), | 431 text_input_type_(kPluginDefaultTextInputType), |
374 text_input_caret_(0, 0, 0, 0), | 432 text_input_caret_(0, 0, 0, 0), |
375 text_input_caret_bounds_(0, 0, 0, 0), | 433 text_input_caret_bounds_(0, 0, 0, 0), |
376 text_input_caret_set_(false), | 434 text_input_caret_set_(false), |
377 selection_caret_(0), | 435 selection_caret_(0), |
378 selection_anchor_(0), | 436 selection_anchor_(0), |
379 pending_user_gesture_(0.0), | 437 pending_user_gesture_(0.0), |
380 flash_impl_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 438 flash_impl_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 439 decryptor_client_(NULL), |
| 440 next_decryption_request_id_(1) { |
381 pp_instance_ = HostGlobals::Get()->AddInstance(this); | 441 pp_instance_ = HostGlobals::Get()->AddInstance(this); |
382 | 442 |
383 memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); | 443 memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); |
384 DCHECK(delegate); | 444 DCHECK(delegate); |
385 module_->InstanceCreated(this); | 445 module_->InstanceCreated(this); |
386 delegate_->InstanceCreated(this); | 446 delegate_->InstanceCreated(this); |
387 message_channel_.reset(new MessageChannel(this)); | 447 message_channel_.reset(new MessageChannel(this)); |
388 | 448 |
389 view_data_.is_page_visible = delegate->IsPageVisible(); | 449 view_data_.is_page_visible = delegate->IsPageVisible(); |
390 | 450 |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 if (!LoadPdfInterface()) | 1371 if (!LoadPdfInterface()) |
1312 return; | 1372 return; |
1313 PP_PrivatePageTransformType transform_type = | 1373 PP_PrivatePageTransformType transform_type = |
1314 type == WebPlugin::RotationType90Clockwise ? | 1374 type == WebPlugin::RotationType90Clockwise ? |
1315 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW : | 1375 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW : |
1316 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW; | 1376 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW; |
1317 plugin_pdf_interface_->Transform(pp_instance(), transform_type); | 1377 plugin_pdf_interface_->Transform(pp_instance(), transform_type); |
1318 // NOTE: plugin instance may have been deleted. | 1378 // NOTE: plugin instance may have been deleted. |
1319 } | 1379 } |
1320 | 1380 |
| 1381 void PluginInstance::set_decrypt_client( |
| 1382 media::DecryptorClient* decryptor_client) { |
| 1383 DCHECK(decryptor_client); |
| 1384 decryptor_client_ = decryptor_client; |
| 1385 } |
| 1386 |
1321 bool PluginInstance::GenerateKeyRequest(const std::string& key_system, | 1387 bool PluginInstance::GenerateKeyRequest(const std::string& key_system, |
1322 const std::string& init_data) { | 1388 const std::string& init_data) { |
1323 if (!LoadContentDecryptorInterface()) | 1389 if (!LoadContentDecryptorInterface()) |
1324 return false; | 1390 return false; |
1325 if (key_system.empty()) | 1391 if (key_system.empty()) |
1326 return false; | 1392 return false; |
| 1393 |
1327 PP_Var init_data_array = | 1394 PP_Var init_data_array = |
1328 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( | 1395 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( |
1329 init_data.size(), init_data.data()); | 1396 init_data.size(), init_data.data()); |
1330 | 1397 |
1331 return PP_ToBool(plugin_decryption_interface_->GenerateKeyRequest( | 1398 return PP_ToBool(plugin_decryption_interface_->GenerateKeyRequest( |
1332 pp_instance(), | 1399 pp_instance(), |
1333 StringVar::StringToPPVar(key_system), | 1400 StringVar::StringToPPVar(key_system), |
1334 init_data_array)); | 1401 init_data_array)); |
1335 } | 1402 } |
1336 | 1403 |
(...skipping 19 matching lines...) Expand all Loading... |
1356 | 1423 |
1357 bool PluginInstance::CancelKeyRequest(const std::string& session_id) { | 1424 bool PluginInstance::CancelKeyRequest(const std::string& session_id) { |
1358 if (!LoadContentDecryptorInterface()) | 1425 if (!LoadContentDecryptorInterface()) |
1359 return false; | 1426 return false; |
1360 | 1427 |
1361 return PP_ToBool(plugin_decryption_interface_->CancelKeyRequest( | 1428 return PP_ToBool(plugin_decryption_interface_->CancelKeyRequest( |
1362 pp_instance(), | 1429 pp_instance(), |
1363 StringVar::StringToPPVar(session_id))); | 1430 StringVar::StringToPPVar(session_id))); |
1364 } | 1431 } |
1365 | 1432 |
1366 bool PluginInstance::Decrypt(const base::StringPiece& encrypted_block, | 1433 bool PluginInstance::Decrypt( |
1367 const DecryptedDataCB& callback) { | 1434 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, |
| 1435 const media::Decryptor::DecryptCB& decrypt_cb) { |
1368 if (!LoadContentDecryptorInterface()) | 1436 if (!LoadContentDecryptorInterface()) |
1369 return false; | 1437 return false; |
1370 ScopedPPResource encrypted_resource(MakeBufferResource(pp_instance(), | 1438 |
1371 encrypted_block)); | 1439 ScopedPPResource encrypted_resource( |
| 1440 MakeBufferResource(pp_instance(), |
| 1441 encrypted_buffer->GetData(), |
| 1442 encrypted_buffer->GetDataSize())); |
| 1443 if (!encrypted_resource.get()) |
| 1444 return false; |
| 1445 |
| 1446 uint32_t request_id = next_decryption_request_id_++; |
| 1447 |
| 1448 PP_EncryptedBlockInfo block_info; |
| 1449 DCHECK(encrypted_buffer->GetDecryptConfig()); |
| 1450 if (!MakeEncryptedBlockInfo(*encrypted_buffer->GetDecryptConfig(), |
| 1451 encrypted_buffer->GetTimestamp().InMicroseconds(), |
| 1452 request_id, |
| 1453 &block_info)) { |
| 1454 return false; |
| 1455 } |
| 1456 |
| 1457 DCHECK(!ContainsKey(pending_decryption_cbs_, request_id)); |
| 1458 pending_decryption_cbs_.insert(std::make_pair(request_id, decrypt_cb)); |
| 1459 |
| 1460 return PP_ToBool(plugin_decryption_interface_->Decrypt(pp_instance(), |
| 1461 encrypted_resource, |
| 1462 &block_info)); |
| 1463 } |
| 1464 |
| 1465 bool PluginInstance::DecryptAndDecode( |
| 1466 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, |
| 1467 const media::Decryptor::DecryptCB& decrypt_cb) { |
| 1468 if (!LoadContentDecryptorInterface()) |
| 1469 return false; |
| 1470 |
| 1471 ScopedPPResource encrypted_resource(MakeBufferResource( |
| 1472 pp_instance(), |
| 1473 encrypted_buffer->GetData(), |
| 1474 encrypted_buffer->GetDataSize())); |
1372 if (!encrypted_resource.get()) | 1475 if (!encrypted_resource.get()) |
1373 return false; | 1476 return false; |
1374 | 1477 |
1375 PP_EncryptedBlockInfo block_info; | 1478 PP_EncryptedBlockInfo block_info; |
1376 | 1479 |
1377 // TODO(tomfinegan): Store callback and ID in a map, and pass ID to decryptor. | 1480 // TODO(tomfinegan): Store callback and ID in a map, and pass ID to decryptor. |
1378 return PP_ToBool(plugin_decryption_interface_->Decrypt(pp_instance(), | 1481 return PP_ToBool( |
1379 encrypted_resource, | 1482 plugin_decryption_interface_->DecryptAndDecode(pp_instance(), |
1380 &block_info)); | 1483 encrypted_resource, |
1381 } | 1484 &block_info)); |
1382 | |
1383 bool PluginInstance::DecryptAndDecode(const base::StringPiece& encrypted_block, | |
1384 const DecryptedDataCB& callback) { | |
1385 if (!LoadContentDecryptorInterface()) | |
1386 return false; | |
1387 ScopedPPResource encrypted_resource(MakeBufferResource(pp_instance(), | |
1388 encrypted_block)); | |
1389 if (!encrypted_resource.get()) | |
1390 return false; | |
1391 | |
1392 PP_EncryptedBlockInfo block_info; | |
1393 | |
1394 // TODO(tomfinegan): Store callback and ID in a map, and pass ID to decryptor. | |
1395 return PP_ToBool(plugin_decryption_interface_->DecryptAndDecode( | |
1396 pp_instance(), | |
1397 encrypted_resource, | |
1398 &block_info)); | |
1399 } | 1485 } |
1400 | 1486 |
1401 bool PluginInstance::FlashIsFullscreenOrPending() { | 1487 bool PluginInstance::FlashIsFullscreenOrPending() { |
1402 return fullscreen_container_ != NULL; | 1488 return fullscreen_container_ != NULL; |
1403 } | 1489 } |
1404 | 1490 |
1405 bool PluginInstance::IsFullscreenOrPending() { | 1491 bool PluginInstance::IsFullscreenOrPending() { |
1406 return desired_fullscreen_state_; | 1492 return desired_fullscreen_state_; |
1407 } | 1493 } |
1408 | 1494 |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2009 void PluginInstance::NeedKey(PP_Instance instance, | 2095 void PluginInstance::NeedKey(PP_Instance instance, |
2010 PP_Var key_system_var, | 2096 PP_Var key_system_var, |
2011 PP_Var session_id_var, | 2097 PP_Var session_id_var, |
2012 PP_Var init_data_var) { | 2098 PP_Var init_data_var) { |
2013 // TODO(tomfinegan): send the data to media stack. | 2099 // TODO(tomfinegan): send the data to media stack. |
2014 } | 2100 } |
2015 | 2101 |
2016 void PluginInstance::KeyAdded(PP_Instance instance, | 2102 void PluginInstance::KeyAdded(PP_Instance instance, |
2017 PP_Var key_system_var, | 2103 PP_Var key_system_var, |
2018 PP_Var session_id_var) { | 2104 PP_Var session_id_var) { |
2019 // TODO(tomfinegan): send the data to media stack. | 2105 StringVar* key_system_string = StringVar::FromPPVar(key_system_var); |
| 2106 StringVar* session_id_string = StringVar::FromPPVar(session_id_var); |
| 2107 if (!key_system_string || !session_id_string) { |
| 2108 decryptor_client_->KeyError("", "", media::Decryptor::kUnknownError, 0); |
| 2109 return; |
| 2110 } |
| 2111 |
| 2112 DCHECK(decryptor_client_); |
| 2113 decryptor_client_->KeyAdded(key_system_string->value(), |
| 2114 session_id_string->value()); |
2020 } | 2115 } |
2021 | 2116 |
2022 void PluginInstance::KeyMessage(PP_Instance instance, | 2117 void PluginInstance::KeyMessage(PP_Instance instance, |
2023 PP_Var key_system_var, | 2118 PP_Var key_system_var, |
2024 PP_Var session_id_var, | 2119 PP_Var session_id_var, |
2025 PP_Resource message_resource, | 2120 PP_Resource message_resource, |
2026 PP_Var default_url_var) { | 2121 PP_Var default_url_var) { |
2027 // TODO(tomfinegan): send the data to media stack. | 2122 StringVar* key_system_string = StringVar::FromPPVar(key_system_var); |
| 2123 StringVar* session_id_string = StringVar::FromPPVar(session_id_var); |
| 2124 StringVar* default_url_string = StringVar::FromPPVar(default_url_var); |
| 2125 |
| 2126 if (!key_system_string || !session_id_string || !default_url_string) { |
| 2127 decryptor_client_->KeyError("", "", media::Decryptor::kUnknownError, 0); |
| 2128 return; |
| 2129 } |
| 2130 |
| 2131 EnterResourceNoLock<PPB_Buffer_API> enter(message_resource, true); |
| 2132 if (!enter.succeeded()) { |
| 2133 decryptor_client_->KeyError(key_system_string->value(), |
| 2134 session_id_string->value(), |
| 2135 media::Decryptor::kUnknownError, |
| 2136 0); |
| 2137 return; |
| 2138 } |
| 2139 |
| 2140 BufferAutoMapper mapper(enter.object()); |
| 2141 scoped_array<uint8> message_array(new uint8[mapper.size()]); |
| 2142 if (mapper.data() && mapper.size()) |
| 2143 memcpy(message_array.get(), mapper.data(), mapper.size()); |
| 2144 |
| 2145 DCHECK(decryptor_client_); |
| 2146 decryptor_client_->KeyMessage(key_system_string->value(), |
| 2147 session_id_string->value(), |
| 2148 message_array.Pass(), |
| 2149 mapper.size(), |
| 2150 default_url_string->value()); |
2028 } | 2151 } |
2029 | 2152 |
2030 void PluginInstance::KeyError(PP_Instance instance, | 2153 void PluginInstance::KeyError(PP_Instance instance, |
2031 PP_Var key_system_var, | 2154 PP_Var key_system_var, |
2032 PP_Var session_id_var, | 2155 PP_Var session_id_var, |
2033 int32_t media_error, | 2156 int32_t media_error, |
2034 int32_t system_code) { | 2157 int32_t system_code) { |
2035 // TODO(tomfinegan): send the data to media stack. | 2158 StringVar* key_system_string = StringVar::FromPPVar(key_system_var); |
| 2159 StringVar* session_id_string = StringVar::FromPPVar(session_id_var); |
| 2160 if (!key_system_string || !session_id_string) { |
| 2161 decryptor_client_->KeyError("", "", media::Decryptor::kUnknownError, 0); |
| 2162 return; |
| 2163 } |
| 2164 |
| 2165 DCHECK(decryptor_client_); |
| 2166 decryptor_client_->KeyError( |
| 2167 key_system_string->value(), |
| 2168 session_id_string->value(), |
| 2169 static_cast<media::Decryptor::KeyError>(media_error), |
| 2170 system_code); |
2036 } | 2171 } |
2037 | 2172 |
2038 void PluginInstance::DeliverBlock(PP_Instance instance, | 2173 void PluginInstance::DeliverBlock(PP_Instance instance, |
2039 PP_Resource decrypted_block, | 2174 PP_Resource decrypted_block, |
2040 const PP_DecryptedBlockInfo* block_info) { | 2175 const PP_DecryptedBlockInfo* block_info) { |
2041 // TODO(xhwang): Pass the decrypted block back to media stack. | 2176 DCHECK(block_info); |
| 2177 |
| 2178 DecryptionCBMap::iterator found = pending_decryption_cbs_.find( |
| 2179 block_info->tracking_info.request_id); |
| 2180 |
| 2181 if (found == pending_decryption_cbs_.end()) |
| 2182 return; |
| 2183 media::Decryptor::DecryptCB decrypt_cb = found->second; |
| 2184 pending_decryption_cbs_.erase(found); |
| 2185 |
| 2186 if (block_info->result == PP_DECRYPTRESULT_DECRYPT_NOKEY) { |
| 2187 decrypt_cb.Run(media::Decryptor::kNoKey, NULL); |
| 2188 return; |
| 2189 } |
| 2190 if (block_info->result != PP_DECRYPTRESULT_SUCCESS) { |
| 2191 decrypt_cb.Run(media::Decryptor::kError, NULL); |
| 2192 return; |
| 2193 } |
| 2194 EnterResourceNoLock<PPB_Buffer_API> enter(decrypted_block, true); |
| 2195 |
| 2196 if (!enter.succeeded()) { |
| 2197 decrypt_cb.Run(media::Decryptor::kError, NULL); |
| 2198 return; |
| 2199 } |
| 2200 BufferAutoMapper mapper(enter.object()); |
| 2201 if (!mapper.data() || !mapper.size()) { |
| 2202 decrypt_cb.Run(media::Decryptor::kError, NULL); |
| 2203 return; |
| 2204 } |
| 2205 |
| 2206 scoped_refptr<media::DecoderBuffer> decrypted_buffer( |
| 2207 media::DecoderBuffer::CopyFrom( |
| 2208 reinterpret_cast<const uint8*>(mapper.data()), mapper.size())); |
| 2209 decrypted_buffer->SetTimestamp(base::TimeDelta::FromMicroseconds( |
| 2210 block_info->tracking_info.timestamp)); |
| 2211 decrypt_cb.Run(media::Decryptor::kSuccess, decrypted_buffer); |
2042 } | 2212 } |
2043 | 2213 |
2044 void PluginInstance::DeliverFrame(PP_Instance instance, | 2214 void PluginInstance::DeliverFrame(PP_Instance instance, |
2045 PP_Resource decrypted_frame, | 2215 PP_Resource decrypted_frame, |
2046 const PP_DecryptedBlockInfo* block_info) { | 2216 const PP_DecryptedBlockInfo* block_info) { |
2047 // TODO(tomfinegan): To be implemented after completion of v0.1 of the | 2217 // TODO(tomfinegan): To be implemented after completion of v0.1 of the |
2048 // EME/CDM work. | 2218 // EME/CDM work. |
2049 } | 2219 } |
2050 | 2220 |
2051 void PluginInstance::DeliverSamples(PP_Instance instance, | 2221 void PluginInstance::DeliverSamples(PP_Instance instance, |
2052 PP_Resource decrypted_samples, | 2222 PP_Resource decrypted_samples, |
2053 const PP_DecryptedBlockInfo* block_info) { | 2223 const PP_DecryptedBlockInfo* block_info) { |
2054 // TODO(tomfinegan): To be implemented after completion of v0.1 of the | 2224 // TODO(tomfinegan): To be implemented after completion of v0.1 of the |
2055 // EME/CDM work. | 2225 // EME/CDM work. |
2056 } | 2226 } |
2057 | 2227 |
2058 | |
2059 void PluginInstance::NumberOfFindResultsChanged(PP_Instance instance, | 2228 void PluginInstance::NumberOfFindResultsChanged(PP_Instance instance, |
2060 int32_t total, | 2229 int32_t total, |
2061 PP_Bool final_result) { | 2230 PP_Bool final_result) { |
2062 DCHECK_NE(find_identifier_, -1); | 2231 DCHECK_NE(find_identifier_, -1); |
2063 delegate_->NumberOfFindResultsChanged(find_identifier_, total, | 2232 delegate_->NumberOfFindResultsChanged(find_identifier_, total, |
2064 PP_ToBool(final_result)); | 2233 PP_ToBool(final_result)); |
2065 } | 2234 } |
2066 | 2235 |
2067 void PluginInstance::SelectedFindResultChanged(PP_Instance instance, | 2236 void PluginInstance::SelectedFindResultChanged(PP_Instance instance, |
2068 int32_t index) { | 2237 int32_t index) { |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2424 screen_size_for_fullscreen_ = gfx::Size(); | 2593 screen_size_for_fullscreen_ = gfx::Size(); |
2425 WebElement element = container_->element(); | 2594 WebElement element = container_->element(); |
2426 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2595 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
2427 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2596 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
2428 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2597 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
2429 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2598 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
2430 } | 2599 } |
2431 | 2600 |
2432 } // namespace ppapi | 2601 } // namespace ppapi |
2433 } // namespace webkit | 2602 } // namespace webkit |
OLD | NEW |