Chromium Code Reviews| 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" |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 WebKit::WebSecurityOrigin* security_origin) { | 274 WebKit::WebSecurityOrigin* security_origin) { |
| 275 PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id); | 275 PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id); |
| 276 if (!instance) | 276 if (!instance) |
| 277 return false; | 277 return false; |
| 278 | 278 |
| 279 WebElement plugin_element = instance->container()->element(); | 279 WebElement plugin_element = instance->container()->element(); |
| 280 *security_origin = plugin_element.document().securityOrigin(); | 280 *security_origin = plugin_element.document().securityOrigin(); |
| 281 return true; | 281 return true; |
| 282 } | 282 } |
| 283 | 283 |
| 284 // Creates a PP_Resource containing a PPB_Buffer_Impl, copies |data| into the | |
| 285 // buffer resource, and returns it. Returns a PP_Resource equal to 0 on | |
| 286 // failure. | |
| 287 PP_Resource MakeBufferResource(PP_Instance instance, | |
| 288 const std::string& data) { | |
| 289 if (!data.size()) | |
| 290 return 0; | |
| 291 | |
| 292 ScopedPPResource resource(PPB_Buffer_Impl::Create(instance, data.size())); | |
| 293 if (!resource.get()) | |
| 294 return 0; | |
| 295 | |
| 296 EnterResourceNoLock<PPB_Buffer_API> enter(resource, true); | |
| 297 if (enter.failed()) | |
| 298 return 0; | |
| 299 | |
| 300 BufferAutoMapper mapper(enter.object()); | |
| 301 if (!mapper.data() || mapper.size() < data.size()) | |
| 302 return 0; | |
| 303 memcpy(mapper.data(), data.c_str(), data.size()); | |
|
xhwang
2012/06/18 20:20:41
Not a big difference here, but I feel data.data()
Tom Finegan
2012/06/18 20:36:58
Done.
| |
| 304 | |
| 305 return resource.Release(); | |
| 306 } | |
| 307 | |
| 284 } // namespace | 308 } // namespace |
| 285 | 309 |
| 286 // static | 310 // static |
| 287 PluginInstance* PluginInstance::Create1_0(PluginDelegate* delegate, | 311 PluginInstance* PluginInstance::Create1_0(PluginDelegate* delegate, |
| 288 PluginModule* module, | 312 PluginModule* module, |
| 289 const void* ppp_instance_if_1_0) { | 313 const void* ppp_instance_if_1_0) { |
| 290 const PPP_Instance_1_0* instance = | 314 const PPP_Instance_1_0* instance = |
| 291 static_cast<const PPP_Instance_1_0*>(ppp_instance_if_1_0); | 315 static_cast<const PPP_Instance_1_0*>(ppp_instance_if_1_0); |
| 292 return new PluginInstance( | 316 return new PluginInstance( |
| 293 delegate, | 317 delegate, |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 316 instance_interface_(instance_interface), | 340 instance_interface_(instance_interface), |
| 317 pp_instance_(0), | 341 pp_instance_(0), |
| 318 container_(NULL), | 342 container_(NULL), |
| 319 full_frame_(false), | 343 full_frame_(false), |
| 320 sent_initial_did_change_view_(false), | 344 sent_initial_did_change_view_(false), |
| 321 suppress_did_change_view_(false), | 345 suppress_did_change_view_(false), |
| 322 has_webkit_focus_(false), | 346 has_webkit_focus_(false), |
| 323 has_content_area_focus_(false), | 347 has_content_area_focus_(false), |
| 324 find_identifier_(-1), | 348 find_identifier_(-1), |
| 325 resource_creation_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 349 resource_creation_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 350 plugin_decryption_interface_(NULL), | |
| 326 plugin_find_interface_(NULL), | 351 plugin_find_interface_(NULL), |
| 327 plugin_messaging_interface_(NULL), | 352 plugin_messaging_interface_(NULL), |
| 328 plugin_mouse_lock_interface_(NULL), | 353 plugin_mouse_lock_interface_(NULL), |
| 329 plugin_input_event_interface_(NULL), | 354 plugin_input_event_interface_(NULL), |
| 330 plugin_private_interface_(NULL), | 355 plugin_private_interface_(NULL), |
| 331 plugin_pdf_interface_(NULL), | 356 plugin_pdf_interface_(NULL), |
| 332 plugin_selection_interface_(NULL), | 357 plugin_selection_interface_(NULL), |
| 333 plugin_textinput_interface_(NULL), | 358 plugin_textinput_interface_(NULL), |
| 334 plugin_zoom_interface_(NULL), | 359 plugin_zoom_interface_(NULL), |
| 335 checked_for_plugin_input_event_interface_(false), | 360 checked_for_plugin_input_event_interface_(false), |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 947 | 972 |
| 948 void PluginInstance::StopFind() { | 973 void PluginInstance::StopFind() { |
| 949 // Keep a reference on the stack. See NOTE above. | 974 // Keep a reference on the stack. See NOTE above. |
| 950 scoped_refptr<PluginInstance> ref(this); | 975 scoped_refptr<PluginInstance> ref(this); |
| 951 if (!LoadFindInterface()) | 976 if (!LoadFindInterface()) |
| 952 return; | 977 return; |
| 953 find_identifier_ = -1; | 978 find_identifier_ = -1; |
| 954 plugin_find_interface_->StopFind(pp_instance()); | 979 plugin_find_interface_->StopFind(pp_instance()); |
| 955 } | 980 } |
| 956 | 981 |
| 982 bool PluginInstance::LoadContentDecryptionModuleInterface() { | |
| 983 if (!plugin_decryption_interface_) { | |
| 984 plugin_decryption_interface_ = | |
| 985 static_cast<const PPP_ContentDecryptionModule_Dev*>( | |
| 986 module_->GetPluginInterface( | |
| 987 PPP_CONTENTDECRYPTIONMODULE_DEV_INTERFACE)); | |
| 988 } | |
| 989 return !!plugin_decryption_interface_; | |
| 990 } | |
| 991 | |
| 957 bool PluginInstance::LoadFindInterface() { | 992 bool PluginInstance::LoadFindInterface() { |
| 958 if (!plugin_find_interface_) { | 993 if (!plugin_find_interface_) { |
| 959 plugin_find_interface_ = | 994 plugin_find_interface_ = |
| 960 static_cast<const PPP_Find_Dev*>(module_->GetPluginInterface( | 995 static_cast<const PPP_Find_Dev*>(module_->GetPluginInterface( |
| 961 PPP_FIND_DEV_INTERFACE)); | 996 PPP_FIND_DEV_INTERFACE)); |
| 962 } | 997 } |
| 963 | 998 |
| 964 return !!plugin_find_interface_; | 999 return !!plugin_find_interface_; |
| 965 } | 1000 } |
| 966 | 1001 |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1249 if (!LoadPdfInterface()) | 1284 if (!LoadPdfInterface()) |
| 1250 return; | 1285 return; |
| 1251 PP_PrivatePageTransformType transform_type = | 1286 PP_PrivatePageTransformType transform_type = |
| 1252 type == WebPlugin::RotationType90Clockwise ? | 1287 type == WebPlugin::RotationType90Clockwise ? |
| 1253 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW : | 1288 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW : |
| 1254 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW; | 1289 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW; |
| 1255 plugin_pdf_interface_->Transform(pp_instance(), transform_type); | 1290 plugin_pdf_interface_->Transform(pp_instance(), transform_type); |
| 1256 // NOTE: plugin instance may have been deleted. | 1291 // NOTE: plugin instance may have been deleted. |
| 1257 } | 1292 } |
| 1258 | 1293 |
| 1294 bool PluginInstance::GenerateKeyRequest(const std::string& key_system, | |
| 1295 const std::string& init_data) { | |
| 1296 if (!LoadContentDecryptionModuleInterface()) | |
| 1297 return false; | |
| 1298 | |
| 1299 StringVar key_system_var(key_system); | |
| 1300 if (key_system_var.value().size() < key_system.size()) | |
| 1301 return false; | |
| 1302 | |
| 1303 PP_Resource init_resource = 0; | |
| 1304 if (init_data.size()) { | |
| 1305 ScopedPPResource init_data_resource(ScopedPPResource::PassRef(), | |
| 1306 MakeBufferResource(pp_instance(), | |
| 1307 init_data)); | |
| 1308 | |
| 1309 if (!init_data_resource.get()) | |
| 1310 return false; | |
| 1311 init_resource = init_data_resource.Release(); | |
| 1312 } | |
| 1313 | |
| 1314 return PP_ToBool(plugin_decryption_interface_->GenerateKeyRequest( | |
| 1315 pp_instance(), | |
| 1316 key_system_var.GetPPVar(), | |
| 1317 init_resource)); | |
| 1318 } | |
| 1319 | |
| 1320 bool PluginInstance::AddKey(const std::string& session_id, | |
| 1321 const std::string& key) { | |
| 1322 if (!LoadContentDecryptionModuleInterface()) | |
| 1323 return false; | |
| 1324 | |
| 1325 StringVar session_id_var(session_id); | |
| 1326 if (session_id_var.value().size() < session_id.size()) | |
| 1327 return false; | |
| 1328 | |
| 1329 ScopedPPResource key_resource(ScopedPPResource::PassRef(), | |
| 1330 MakeBufferResource(pp_instance(), key)); | |
| 1331 if (!key_resource.get()) | |
| 1332 return false; | |
| 1333 | |
| 1334 return PP_ToBool(plugin_decryption_interface_->AddKey( | |
| 1335 pp_instance(), | |
| 1336 session_id_var.GetPPVar(), | |
| 1337 key_resource)); | |
| 1338 } | |
| 1339 | |
| 1340 bool PluginInstance::CancelKeyRequest(const std::string& session_id) { | |
| 1341 if (!LoadContentDecryptionModuleInterface()) | |
| 1342 return false; | |
| 1343 StringVar session_id_var(session_id); | |
| 1344 if (session_id_var.value().size() < session_id.size()) | |
| 1345 return false; | |
| 1346 return PP_ToBool(plugin_decryption_interface_->CancelKeyRequest( | |
| 1347 pp_instance(), | |
| 1348 session_id_var.GetPPVar())); | |
| 1349 } | |
| 1350 | |
| 1351 bool PluginInstance::Decrypt(const std::string& encrypted_block, | |
| 1352 const CDMStatusCB& callback) { | |
| 1353 if (!LoadContentDecryptionModuleInterface()) | |
| 1354 return false; | |
| 1355 ScopedPPResource encrypted_resource(ScopedPPResource::PassRef(), | |
| 1356 MakeBufferResource(pp_instance(), | |
| 1357 encrypted_block)); | |
| 1358 if (!encrypted_resource.get()) | |
| 1359 return false; | |
| 1360 // TODO(tomfinegan): wrap callback in PP_CompletionCallback and pass it to | |
| 1361 // the plugin. | |
| 1362 PP_CompletionCallback pp_callback = {NULL, NULL, 0}; | |
| 1363 return PP_ToBool(plugin_decryption_interface_->Decrypt(pp_instance(), | |
| 1364 encrypted_resource, | |
| 1365 pp_callback)); | |
| 1366 } | |
| 1367 | |
| 1368 bool PluginInstance::DecryptAndDecode(const std::string& encrypted_block, | |
| 1369 const CDMStatusCB& callback) { | |
| 1370 if (!LoadContentDecryptionModuleInterface()) | |
| 1371 return false; | |
| 1372 ScopedPPResource encrypted_resource(ScopedPPResource::PassRef(), | |
| 1373 MakeBufferResource(pp_instance(), | |
| 1374 encrypted_block)); | |
| 1375 if (!encrypted_resource.get()) | |
| 1376 return false; | |
| 1377 // TODO(tomfinegan): wrap callback in PP_CompletionCallback and pass it to | |
| 1378 // the plugin. | |
| 1379 PP_CompletionCallback pp_callback = {NULL, NULL, 0}; | |
| 1380 return PP_ToBool(plugin_decryption_interface_->DecryptAndDecode( | |
| 1381 pp_instance(), | |
| 1382 encrypted_resource, | |
| 1383 pp_callback)); | |
| 1384 } | |
| 1385 | |
| 1259 bool PluginInstance::FlashIsFullscreenOrPending() { | 1386 bool PluginInstance::FlashIsFullscreenOrPending() { |
| 1260 return fullscreen_container_ != NULL; | 1387 return fullscreen_container_ != NULL; |
| 1261 } | 1388 } |
| 1262 | 1389 |
| 1263 bool PluginInstance::IsFullscreenOrPending() { | 1390 bool PluginInstance::IsFullscreenOrPending() { |
| 1264 return desired_fullscreen_state_; | 1391 return desired_fullscreen_state_; |
| 1265 } | 1392 } |
| 1266 | 1393 |
| 1267 bool PluginInstance::SetFullscreen(bool fullscreen) { | 1394 bool PluginInstance::SetFullscreen(bool fullscreen) { |
| 1268 // Keep a reference on the stack. See NOTE above. | 1395 // Keep a reference on the stack. See NOTE above. |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1833 PP_Var PluginInstance::GetDefaultCharSet(PP_Instance instance) { | 1960 PP_Var PluginInstance::GetDefaultCharSet(PP_Instance instance) { |
| 1834 std::string encoding = delegate()->GetDefaultEncoding(); | 1961 std::string encoding = delegate()->GetDefaultEncoding(); |
| 1835 return StringVar::StringToPPVar(encoding); | 1962 return StringVar::StringToPPVar(encoding); |
| 1836 } | 1963 } |
| 1837 | 1964 |
| 1838 PP_Var PluginInstance::GetFontFamilies(PP_Instance instance) { | 1965 PP_Var PluginInstance::GetFontFamilies(PP_Instance instance) { |
| 1839 // No in-process implementation. | 1966 // No in-process implementation. |
| 1840 return PP_MakeUndefined(); | 1967 return PP_MakeUndefined(); |
| 1841 } | 1968 } |
| 1842 | 1969 |
| 1970 void PluginInstance::NeedKey(PP_Instance instance, | |
| 1971 PP_Var key_system, | |
| 1972 PP_Var session_id, | |
| 1973 PP_Resource init_data) { | |
| 1974 } | |
| 1975 | |
| 1976 void PluginInstance::KeyAdded(PP_Instance instance, | |
| 1977 PP_Var key_system, | |
| 1978 PP_Var session_id) { | |
| 1979 } | |
| 1980 | |
| 1981 void PluginInstance::KeyMessage(PP_Instance instance, | |
| 1982 PP_Var key_system, | |
| 1983 PP_Var session_id, | |
| 1984 PP_Resource message, | |
| 1985 PP_Var default_url) { | |
| 1986 } | |
| 1987 | |
| 1988 void PluginInstance::KeyError(PP_Instance instance, | |
| 1989 PP_Var key_system, | |
| 1990 PP_Var session_id, | |
| 1991 uint16_t media_error, | |
| 1992 uint16_t system_error) { | |
| 1993 } | |
| 1994 | |
| 1995 void PluginInstance::DeliverBlock(PP_Instance instance, | |
| 1996 PP_Resource decrypted_block, | |
| 1997 PP_CompletionCallback callback) { | |
| 1998 } | |
| 1999 | |
| 2000 void PluginInstance::DeliverFrame(PP_Instance instance, | |
| 2001 PP_Resource decrypted_frame, | |
| 2002 PP_CompletionCallback callback) { | |
| 2003 } | |
| 2004 | |
| 2005 void PluginInstance::DeliverSamples(PP_Instance instance, | |
| 2006 PP_Resource decrypted_samples, | |
| 2007 PP_CompletionCallback callback) { | |
| 2008 } | |
| 2009 | |
| 2010 | |
| 1843 void PluginInstance::NumberOfFindResultsChanged(PP_Instance instance, | 2011 void PluginInstance::NumberOfFindResultsChanged(PP_Instance instance, |
| 1844 int32_t total, | 2012 int32_t total, |
| 1845 PP_Bool final_result) { | 2013 PP_Bool final_result) { |
| 1846 DCHECK_NE(find_identifier_, -1); | 2014 DCHECK_NE(find_identifier_, -1); |
| 1847 delegate_->NumberOfFindResultsChanged(find_identifier_, total, | 2015 delegate_->NumberOfFindResultsChanged(find_identifier_, total, |
| 1848 PP_ToBool(final_result)); | 2016 PP_ToBool(final_result)); |
| 1849 } | 2017 } |
| 1850 | 2018 |
| 1851 void PluginInstance::SelectedFindResultChanged(PP_Instance instance, | 2019 void PluginInstance::SelectedFindResultChanged(PP_Instance instance, |
| 1852 int32_t index) { | 2020 int32_t index) { |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2152 screen_size_for_fullscreen_ = gfx::Size(); | 2320 screen_size_for_fullscreen_ = gfx::Size(); |
| 2153 WebElement element = container_->element(); | 2321 WebElement element = container_->element(); |
| 2154 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2322 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
| 2155 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2323 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
| 2156 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2324 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
| 2157 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2325 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
| 2158 } | 2326 } |
| 2159 | 2327 |
| 2160 } // namespace ppapi | 2328 } // namespace ppapi |
| 2161 } // namespace webkit | 2329 } // namespace webkit |
| OLD | NEW |