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 uint64_t request_id, | |
346 PP_EncryptedBlockInfo* block_info) { | |
347 DCHECK(block_info); | |
348 | |
349 block_info->tracking_info.request_id = request_id; | |
350 block_info->tracking_info.timestamp = timestamp; | |
351 block_info->data_offset = decrypt_config.data_offset(); | |
352 | |
353 if (!CopyStringToArray(decrypt_config.key_id(), block_info->key_id) || | |
354 !CopyStringToArray(decrypt_config.iv(), block_info->iv) || | |
355 !CopyStringToArray(decrypt_config.checksum(), block_info->checksum)) | |
356 return false; | |
357 | |
358 block_info->key_id_size = decrypt_config.key_id().size(); | |
359 block_info->iv_size = decrypt_config.iv().size(); | |
360 block_info->checksum_size = decrypt_config.checksum().size(); | |
361 | |
362 if (decrypt_config.subsamples().size() > arraysize(block_info->subsamples)) | |
363 return false; | |
364 | |
365 block_info->num_subsamples = decrypt_config.subsamples().size(); | |
366 for (uint32_t i = 0; i < block_info->num_subsamples; ++i) { | |
367 block_info->subsamples[i].clear_bytes = | |
368 decrypt_config.subsamples()[i].clear_bytes; | |
369 block_info->subsamples[i].cipher_bytes = | |
370 decrypt_config.subsamples()[i].cypher_bytes; | |
371 } | |
372 | |
373 return true; | |
374 } | |
375 | |
322 } // namespace | 376 } // namespace |
323 | 377 |
324 // static | 378 // static |
325 PluginInstance* PluginInstance::Create(PluginDelegate* delegate, | 379 PluginInstance* PluginInstance::Create(PluginDelegate* delegate, |
326 PluginModule* module) { | 380 PluginModule* module) { |
327 base::Callback<const void*(const char*)> get_plugin_interface_func = | 381 base::Callback<const void*(const char*)> get_plugin_interface_func = |
328 base::Bind(&PluginModule::GetPluginInterface, module); | 382 base::Bind(&PluginModule::GetPluginInterface, module); |
329 PPP_Instance_Combined* ppp_instance_combined = | 383 PPP_Instance_Combined* ppp_instance_combined = |
330 PPP_Instance_Combined::Create(get_plugin_interface_func); | 384 PPP_Instance_Combined::Create(get_plugin_interface_func); |
331 if (!ppp_instance_combined) | 385 if (!ppp_instance_combined) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
370 sad_plugin_(NULL), | 424 sad_plugin_(NULL), |
371 input_event_mask_(0), | 425 input_event_mask_(0), |
372 filtered_input_event_mask_(0), | 426 filtered_input_event_mask_(0), |
373 text_input_type_(kPluginDefaultTextInputType), | 427 text_input_type_(kPluginDefaultTextInputType), |
374 text_input_caret_(0, 0, 0, 0), | 428 text_input_caret_(0, 0, 0, 0), |
375 text_input_caret_bounds_(0, 0, 0, 0), | 429 text_input_caret_bounds_(0, 0, 0, 0), |
376 text_input_caret_set_(false), | 430 text_input_caret_set_(false), |
377 selection_caret_(0), | 431 selection_caret_(0), |
378 selection_anchor_(0), | 432 selection_anchor_(0), |
379 pending_user_gesture_(0.0), | 433 pending_user_gesture_(0.0), |
380 flash_impl_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 434 flash_impl_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
435 decryptor_client_(NULL), | |
436 next_decryption_request_id_(1) { | |
381 pp_instance_ = HostGlobals::Get()->AddInstance(this); | 437 pp_instance_ = HostGlobals::Get()->AddInstance(this); |
382 | 438 |
383 memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); | 439 memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); |
384 DCHECK(delegate); | 440 DCHECK(delegate); |
385 module_->InstanceCreated(this); | 441 module_->InstanceCreated(this); |
386 delegate_->InstanceCreated(this); | 442 delegate_->InstanceCreated(this); |
387 message_channel_.reset(new MessageChannel(this)); | 443 message_channel_.reset(new MessageChannel(this)); |
388 | 444 |
389 view_data_.is_page_visible = delegate->IsPageVisible(); | 445 view_data_.is_page_visible = delegate->IsPageVisible(); |
390 | 446 |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1311 if (!LoadPdfInterface()) | 1367 if (!LoadPdfInterface()) |
1312 return; | 1368 return; |
1313 PP_PrivatePageTransformType transform_type = | 1369 PP_PrivatePageTransformType transform_type = |
1314 type == WebPlugin::RotationType90Clockwise ? | 1370 type == WebPlugin::RotationType90Clockwise ? |
1315 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW : | 1371 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW : |
1316 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW; | 1372 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW; |
1317 plugin_pdf_interface_->Transform(pp_instance(), transform_type); | 1373 plugin_pdf_interface_->Transform(pp_instance(), transform_type); |
1318 // NOTE: plugin instance may have been deleted. | 1374 // NOTE: plugin instance may have been deleted. |
1319 } | 1375 } |
1320 | 1376 |
1377 void PluginInstance::set_decrypt_client( | |
1378 media::DecryptorClient* decryptor_client) { | |
1379 DCHECK(decryptor_client); | |
1380 decryptor_client_ = decryptor_client; | |
1381 } | |
1382 | |
1321 bool PluginInstance::GenerateKeyRequest(const std::string& key_system, | 1383 bool PluginInstance::GenerateKeyRequest(const std::string& key_system, |
1322 const std::string& init_data) { | 1384 const std::string& init_data) { |
1323 if (!LoadContentDecryptorInterface()) | 1385 if (!LoadContentDecryptorInterface()) |
1324 return false; | 1386 return false; |
1325 if (key_system.empty()) | 1387 if (key_system.empty()) |
1326 return false; | 1388 return false; |
1389 | |
1327 PP_Var init_data_array = | 1390 PP_Var init_data_array = |
1328 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( | 1391 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( |
1329 init_data.size(), init_data.data()); | 1392 init_data.size(), init_data.data()); |
1330 | 1393 |
1331 return PP_ToBool(plugin_decryption_interface_->GenerateKeyRequest( | 1394 return PP_ToBool(plugin_decryption_interface_->GenerateKeyRequest( |
1332 pp_instance(), | 1395 pp_instance(), |
1333 StringVar::StringToPPVar(key_system), | 1396 StringVar::StringToPPVar(key_system), |
1334 init_data_array)); | 1397 init_data_array)); |
1335 } | 1398 } |
1336 | 1399 |
(...skipping 19 matching lines...) Expand all Loading... | |
1356 | 1419 |
1357 bool PluginInstance::CancelKeyRequest(const std::string& session_id) { | 1420 bool PluginInstance::CancelKeyRequest(const std::string& session_id) { |
1358 if (!LoadContentDecryptorInterface()) | 1421 if (!LoadContentDecryptorInterface()) |
1359 return false; | 1422 return false; |
1360 | 1423 |
1361 return PP_ToBool(plugin_decryption_interface_->CancelKeyRequest( | 1424 return PP_ToBool(plugin_decryption_interface_->CancelKeyRequest( |
1362 pp_instance(), | 1425 pp_instance(), |
1363 StringVar::StringToPPVar(session_id))); | 1426 StringVar::StringToPPVar(session_id))); |
1364 } | 1427 } |
1365 | 1428 |
1366 bool PluginInstance::Decrypt(const base::StringPiece& encrypted_block, | 1429 bool PluginInstance::Decrypt( |
1367 const DecryptedDataCB& callback) { | 1430 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, |
1431 const media::Decryptor::DecryptCB& decrypt_cb) { | |
1368 if (!LoadContentDecryptorInterface()) | 1432 if (!LoadContentDecryptorInterface()) |
1369 return false; | 1433 return false; |
1370 ScopedPPResource encrypted_resource(MakeBufferResource(pp_instance(), | 1434 |
1371 encrypted_block)); | 1435 ScopedPPResource encrypted_resource( |
1436 MakeBufferResource(pp_instance(), | |
1437 encrypted_buffer->GetData(), | |
1438 encrypted_buffer->GetDataSize())); | |
1439 if (!encrypted_resource.get()) | |
1440 return false; | |
1441 | |
1442 uint64_t request_id = next_decryption_request_id_++; | |
1443 | |
1444 // TODO(xhwang): Fix initialization of PP_EncryptedBlockInfo here and | |
1445 // anywhere else. | |
1446 PP_EncryptedBlockInfo block_info; | |
1447 memset(&block_info, 0, sizeof(block_info)); | |
1448 | |
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 | |
2110 DCHECK(decryptor_client_); | |
2111 decryptor_client_->KeyAdded(key_system_string->value(), | |
2112 session_id_string->value()); | |
2020 } | 2113 } |
2021 | 2114 |
2022 void PluginInstance::KeyMessage(PP_Instance instance, | 2115 void PluginInstance::KeyMessage(PP_Instance instance, |
2023 PP_Var key_system_var, | 2116 PP_Var key_system_var, |
2024 PP_Var session_id_var, | 2117 PP_Var session_id_var, |
2025 PP_Resource message_resource, | 2118 PP_Resource message_resource, |
2026 PP_Var default_url_var) { | 2119 PP_Var default_url_var) { |
2027 // TODO(tomfinegan): send the data to media stack. | 2120 StringVar* key_system_string = StringVar::FromPPVar(key_system_var); |
2121 StringVar* session_id_string = StringVar::FromPPVar(session_id_var); | |
2122 StringVar* default_url_string = StringVar::FromPPVar(default_url_var); | |
2123 | |
2124 if (!key_system_string || !session_id_string || !default_url_string) | |
2125 decryptor_client_->KeyError("", "", media::Decryptor::kUnknownError, 0); | |
2126 | |
2127 EnterResourceNoLock<PPB_Buffer_API> enter(message_resource, true); | |
2128 if (!enter.succeeded()) { | |
2129 decryptor_client_->KeyError(key_system_string->value(), | |
2130 session_id_string->value(), | |
2131 media::Decryptor::kUnknownError, | |
2132 0); | |
2133 } | |
2134 | |
2135 BufferAutoMapper mapper(enter.object()); | |
2136 scoped_array<uint8> message_array(new uint8[mapper.size()]); | |
2137 if (mapper.data() && mapper.size()) | |
2138 memcpy(message_array.get(), mapper.data(), mapper.size()); | |
2139 | |
2140 DCHECK(decryptor_client_); | |
2141 decryptor_client_->KeyMessage(key_system_string->value(), | |
2142 session_id_string->value(), | |
2143 message_array.Pass(), | |
2144 mapper.size(), | |
2145 default_url_string->value()); | |
2028 } | 2146 } |
2029 | 2147 |
2030 void PluginInstance::KeyError(PP_Instance instance, | 2148 void PluginInstance::KeyError(PP_Instance instance, |
2031 PP_Var key_system_var, | 2149 PP_Var key_system_var, |
2032 PP_Var session_id_var, | 2150 PP_Var session_id_var, |
2033 int32_t media_error, | 2151 int32_t media_error, |
2034 int32_t system_code) { | 2152 int32_t system_code) { |
2035 // TODO(tomfinegan): send the data to media stack. | 2153 StringVar* key_system_string = StringVar::FromPPVar(key_system_var); |
2154 StringVar* session_id_string = StringVar::FromPPVar(session_id_var); | |
2155 if (!key_system_string || !session_id_string) | |
2156 decryptor_client_->KeyError("", "", media::Decryptor::kUnknownError, 0); | |
2157 | |
2158 DCHECK(decryptor_client_); | |
2159 decryptor_client_->KeyError( | |
2160 key_system_string->value(), | |
2161 session_id_string->value(), | |
2162 static_cast<media::Decryptor::KeyError>(media_error), | |
2163 system_code); | |
2036 } | 2164 } |
2037 | 2165 |
2038 void PluginInstance::DeliverBlock(PP_Instance instance, | 2166 void PluginInstance::DeliverBlock(PP_Instance instance, |
2039 PP_Resource decrypted_block, | 2167 PP_Resource decrypted_block, |
2040 const PP_DecryptedBlockInfo* block_info) { | 2168 const PP_DecryptedBlockInfo* block_info) { |
2041 // TODO(xhwang): Pass the decrypted block back to media stack. | 2169 DCHECK(block_info); |
2170 | |
2171 DecryptionCBMap::iterator found = pending_decryption_cbs_.find( | |
2172 block_info->tracking_info.request_id); | |
2173 | |
2174 if (found == pending_decryption_cbs_.end()) | |
2175 return; | |
2176 media::Decryptor::DecryptCB decrypt_cb = found->second; | |
2177 pending_decryption_cbs_.erase(found); | |
2178 | |
2179 if (block_info->result == PP_DECRYPTRESULT_DECRYPT_NOKEY) { | |
2180 decrypt_cb.Run(media::Decryptor::kNoKey, NULL); | |
2181 return; | |
2182 } | |
2183 if (block_info->result != PP_DECRYPTRESULT_SUCCESS) { | |
2184 decrypt_cb.Run(media::Decryptor::kError, NULL); | |
2185 return; | |
2186 } | |
2187 EnterResourceNoLock<PPB_Buffer_API> enter(decrypted_block, true); | |
ddorwin
2012/08/24 05:54:43
add empty line - error handling is complete, and t
xhwang
2012/08/24 16:57:46
Done.
| |
2188 if (!enter.succeeded()) { | |
2189 decrypt_cb.Run(media::Decryptor::kError, NULL); | |
2190 return; | |
2191 } | |
2192 BufferAutoMapper mapper(enter.object()); | |
2193 if (!mapper.data() || !mapper.size()) { | |
2194 decrypt_cb.Run(media::Decryptor::kError, NULL); | |
2195 return; | |
2196 } | |
2197 | |
2198 scoped_refptr<media::DecoderBuffer> decrypted_buffer( | |
2199 media::DecoderBuffer::CopyFrom( | |
2200 reinterpret_cast<const uint8*>(mapper.data()), mapper.size())); | |
2201 decrypted_buffer->SetTimestamp(base::TimeDelta::FromMicroseconds( | |
2202 block_info->tracking_info.timestamp)); | |
2203 decrypt_cb.Run(media::Decryptor::kSuccess, decrypted_buffer); | |
2042 } | 2204 } |
2043 | 2205 |
2044 void PluginInstance::DeliverFrame(PP_Instance instance, | 2206 void PluginInstance::DeliverFrame(PP_Instance instance, |
2045 PP_Resource decrypted_frame, | 2207 PP_Resource decrypted_frame, |
2046 const PP_DecryptedBlockInfo* block_info) { | 2208 const PP_DecryptedBlockInfo* block_info) { |
2047 // TODO(tomfinegan): To be implemented after completion of v0.1 of the | 2209 // TODO(tomfinegan): To be implemented after completion of v0.1 of the |
2048 // EME/CDM work. | 2210 // EME/CDM work. |
2049 } | 2211 } |
2050 | 2212 |
2051 void PluginInstance::DeliverSamples(PP_Instance instance, | 2213 void PluginInstance::DeliverSamples(PP_Instance instance, |
2052 PP_Resource decrypted_samples, | 2214 PP_Resource decrypted_samples, |
2053 const PP_DecryptedBlockInfo* block_info) { | 2215 const PP_DecryptedBlockInfo* block_info) { |
2054 // TODO(tomfinegan): To be implemented after completion of v0.1 of the | 2216 // TODO(tomfinegan): To be implemented after completion of v0.1 of the |
2055 // EME/CDM work. | 2217 // EME/CDM work. |
2056 } | 2218 } |
2057 | 2219 |
2058 | |
2059 void PluginInstance::NumberOfFindResultsChanged(PP_Instance instance, | 2220 void PluginInstance::NumberOfFindResultsChanged(PP_Instance instance, |
2060 int32_t total, | 2221 int32_t total, |
2061 PP_Bool final_result) { | 2222 PP_Bool final_result) { |
2062 DCHECK_NE(find_identifier_, -1); | 2223 DCHECK_NE(find_identifier_, -1); |
2063 delegate_->NumberOfFindResultsChanged(find_identifier_, total, | 2224 delegate_->NumberOfFindResultsChanged(find_identifier_, total, |
2064 PP_ToBool(final_result)); | 2225 PP_ToBool(final_result)); |
2065 } | 2226 } |
2066 | 2227 |
2067 void PluginInstance::SelectedFindResultChanged(PP_Instance instance, | 2228 void PluginInstance::SelectedFindResultChanged(PP_Instance instance, |
2068 int32_t index) { | 2229 int32_t index) { |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2424 screen_size_for_fullscreen_ = gfx::Size(); | 2585 screen_size_for_fullscreen_ = gfx::Size(); |
2425 WebElement element = container_->element(); | 2586 WebElement element = container_->element(); |
2426 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2587 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
2427 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2588 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
2428 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2589 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
2429 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2590 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
2430 } | 2591 } |
2431 | 2592 |
2432 } // namespace ppapi | 2593 } // namespace ppapi |
2433 } // namespace webkit | 2594 } // namespace webkit |
OLD | NEW |