| 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_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/strings/utf_offset_string_conversions.h" | 15 #include "base/strings/utf_offset_string_conversions.h" |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 PP_PRINTSCALINGOPTION_FIT_TO_PRINTABLE_AREA); | 286 PP_PRINTSCALINGOPTION_FIT_TO_PRINTABLE_AREA); |
| 287 COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM( | 287 COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM( |
| 288 WebKit::WebPrintScalingOptionSourceSize, PP_PRINTSCALINGOPTION_SOURCE_SIZE); | 288 WebKit::WebPrintScalingOptionSourceSize, PP_PRINTSCALINGOPTION_SOURCE_SIZE); |
| 289 | 289 |
| 290 // Sets |*security_origin| to be the WebKit security origin associated with the | 290 // Sets |*security_origin| to be the WebKit security origin associated with the |
| 291 // document containing the given plugin instance. On success, returns true. If | 291 // document containing the given plugin instance. On success, returns true. If |
| 292 // the instance is invalid, returns false and |*security_origin| will be | 292 // the instance is invalid, returns false and |*security_origin| will be |
| 293 // unchanged. | 293 // unchanged. |
| 294 bool SecurityOriginForInstance(PP_Instance instance_id, | 294 bool SecurityOriginForInstance(PP_Instance instance_id, |
| 295 WebKit::WebSecurityOrigin* security_origin) { | 295 WebKit::WebSecurityOrigin* security_origin) { |
| 296 PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id); | 296 PluginInstanceImpl* instance = HostGlobals::Get()->GetInstance(instance_id); |
| 297 if (!instance) | 297 if (!instance) |
| 298 return false; | 298 return false; |
| 299 | 299 |
| 300 WebElement plugin_element = instance->container()->element(); | 300 WebElement plugin_element = instance->container()->element(); |
| 301 *security_origin = plugin_element.document().securityOrigin(); | 301 *security_origin = plugin_element.document().securityOrigin(); |
| 302 return true; | 302 return true; |
| 303 } | 303 } |
| 304 | 304 |
| 305 // Convert the given vector to an array of C-strings. The strings in the | 305 // Convert the given vector to an array of C-strings. The strings in the |
| 306 // returned vector are only guaranteed valid so long as the vector of strings | 306 // returned vector are only guaranteed valid so long as the vector of strings |
| 307 // is not modified. | 307 // is not modified. |
| 308 scoped_ptr<const char*[]> StringVectorToArgArray( | 308 scoped_ptr<const char*[]> StringVectorToArgArray( |
| 309 const std::vector<std::string>& vector) { | 309 const std::vector<std::string>& vector) { |
| 310 scoped_ptr<const char*[]> array(new const char*[vector.size()]); | 310 scoped_ptr<const char*[]> array(new const char*[vector.size()]); |
| 311 for (size_t i = 0; i < vector.size(); ++i) | 311 for (size_t i = 0; i < vector.size(); ++i) |
| 312 array[i] = vector[i].c_str(); | 312 array[i] = vector[i].c_str(); |
| 313 return array.Pass(); | 313 return array.Pass(); |
| 314 } | 314 } |
| 315 | 315 |
| 316 } // namespace | 316 } // namespace |
| 317 | 317 |
| 318 // static | 318 // static |
| 319 PluginInstance* PluginInstance::Create(PluginDelegate* delegate, | 319 PluginInstanceImpl* PluginInstanceImpl::Create(PluginDelegate* delegate, |
| 320 content::RenderView* render_view, | 320 content::RenderView* render_view, |
| 321 PluginModule* module, | 321 PluginModule* module, |
| 322 WebPluginContainer* container, | 322 WebPluginContainer* container, |
| 323 const GURL& plugin_url) { | 323 const GURL& plugin_url) { |
| 324 base::Callback<const void*(const char*)> get_plugin_interface_func = | 324 base::Callback<const void*(const char*)> get_plugin_interface_func = |
| 325 base::Bind(&PluginModule::GetPluginInterface, module); | 325 base::Bind(&PluginModule::GetPluginInterface, module); |
| 326 PPP_Instance_Combined* ppp_instance_combined = | 326 PPP_Instance_Combined* ppp_instance_combined = |
| 327 PPP_Instance_Combined::Create(get_plugin_interface_func); | 327 PPP_Instance_Combined::Create(get_plugin_interface_func); |
| 328 if (!ppp_instance_combined) | 328 if (!ppp_instance_combined) |
| 329 return NULL; | 329 return NULL; |
| 330 return new PluginInstance(delegate, render_view, module, | 330 return new PluginInstanceImpl(delegate, render_view, module, |
| 331 ppp_instance_combined, container, plugin_url); | 331 ppp_instance_combined, container, plugin_url); |
| 332 } | 332 } |
| 333 | 333 |
| 334 PluginInstance::NaClDocumentLoader::NaClDocumentLoader() | 334 PluginInstanceImpl::NaClDocumentLoader::NaClDocumentLoader() |
| 335 : finished_loading_(false) { | 335 : finished_loading_(false) { |
| 336 } | 336 } |
| 337 | 337 |
| 338 PluginInstance::NaClDocumentLoader::~NaClDocumentLoader(){ | 338 PluginInstanceImpl::NaClDocumentLoader::~NaClDocumentLoader(){ |
| 339 } | 339 } |
| 340 | 340 |
| 341 void PluginInstance::NaClDocumentLoader::ReplayReceivedData( | 341 void PluginInstanceImpl::NaClDocumentLoader::ReplayReceivedData( |
| 342 WebURLLoaderClient* document_loader) { | 342 WebURLLoaderClient* document_loader) { |
| 343 for (std::list<std::string>::iterator it = data_.begin(); | 343 for (std::list<std::string>::iterator it = data_.begin(); |
| 344 it != data_.end(); ++it) { | 344 it != data_.end(); ++it) { |
| 345 document_loader->didReceiveData(NULL, it->c_str(), it->length(), | 345 document_loader->didReceiveData(NULL, it->c_str(), it->length(), |
| 346 0 /* encoded_data_length */); | 346 0 /* encoded_data_length */); |
| 347 } | 347 } |
| 348 if (finished_loading_) { | 348 if (finished_loading_) { |
| 349 document_loader->didFinishLoading(NULL, | 349 document_loader->didFinishLoading(NULL, |
| 350 0 /* finish_time */); | 350 0 /* finish_time */); |
| 351 } | 351 } |
| 352 if (error_.get()) { | 352 if (error_.get()) { |
| 353 document_loader->didFail(NULL, *error_); | 353 document_loader->didFail(NULL, *error_); |
| 354 } | 354 } |
| 355 } | 355 } |
| 356 | 356 |
| 357 void PluginInstance::NaClDocumentLoader::didReceiveData( | 357 void PluginInstanceImpl::NaClDocumentLoader::didReceiveData( |
| 358 WebURLLoader* loader, | 358 WebURLLoader* loader, |
| 359 const char* data, | 359 const char* data, |
| 360 int data_length, | 360 int data_length, |
| 361 int encoded_data_length) { | 361 int encoded_data_length) { |
| 362 data_.push_back(std::string(data, data_length)); | 362 data_.push_back(std::string(data, data_length)); |
| 363 } | 363 } |
| 364 | 364 |
| 365 void PluginInstance::NaClDocumentLoader::didFinishLoading( | 365 void PluginInstanceImpl::NaClDocumentLoader::didFinishLoading( |
| 366 WebURLLoader* loader, | 366 WebURLLoader* loader, |
| 367 double finish_time) { | 367 double finish_time) { |
| 368 DCHECK(!finished_loading_); | 368 DCHECK(!finished_loading_); |
| 369 finished_loading_ = true; | 369 finished_loading_ = true; |
| 370 } | 370 } |
| 371 | 371 |
| 372 void PluginInstance::NaClDocumentLoader::didFail( | 372 void PluginInstanceImpl::NaClDocumentLoader::didFail( |
| 373 WebURLLoader* loader, | 373 WebURLLoader* loader, |
| 374 const WebURLError& error) { | 374 const WebURLError& error) { |
| 375 DCHECK(!error_.get()); | 375 DCHECK(!error_.get()); |
| 376 error_.reset(new WebURLError(error)); | 376 error_.reset(new WebURLError(error)); |
| 377 } | 377 } |
| 378 | 378 |
| 379 PluginInstance::GamepadImpl::GamepadImpl(PluginDelegate* delegate) | 379 PluginInstanceImpl::GamepadImpl::GamepadImpl(PluginDelegate* delegate) |
| 380 : Resource(::ppapi::Resource::Untracked()), | 380 : Resource(::ppapi::Resource::Untracked()), |
| 381 delegate_(delegate) { | 381 delegate_(delegate) { |
| 382 } | 382 } |
| 383 | 383 |
| 384 PPB_Gamepad_API* PluginInstance::GamepadImpl::AsPPB_Gamepad_API() { | 384 PPB_Gamepad_API* PluginInstanceImpl::GamepadImpl::AsPPB_Gamepad_API() { |
| 385 return this; | 385 return this; |
| 386 } | 386 } |
| 387 | 387 |
| 388 void PluginInstance::GamepadImpl::Sample(PP_Instance /* instance */, | 388 void PluginInstanceImpl::GamepadImpl::Sample(PP_Instance instance, |
| 389 PP_GamepadsSampleData* data) { | 389 PP_GamepadsSampleData* data) { |
| 390 WebKit::WebGamepads webkit_data; | 390 WebKit::WebGamepads webkit_data; |
| 391 delegate_->SampleGamepads(&webkit_data); | 391 delegate_->SampleGamepads(&webkit_data); |
| 392 ConvertWebKitGamepadData( | 392 ConvertWebKitGamepadData( |
| 393 *reinterpret_cast<const ::ppapi::WebKitGamepads*>(&webkit_data), data); | 393 *reinterpret_cast<const ::ppapi::WebKitGamepads*>(&webkit_data), data); |
| 394 } | 394 } |
| 395 | 395 |
| 396 PluginInstance::PluginInstance( | 396 PluginInstanceImpl::PluginInstanceImpl( |
| 397 PluginDelegate* delegate, | 397 PluginDelegate* delegate, |
| 398 content::RenderView* render_view, | 398 content::RenderView* render_view, |
| 399 PluginModule* module, | 399 PluginModule* module, |
| 400 ::ppapi::PPP_Instance_Combined* instance_interface, | 400 ::ppapi::PPP_Instance_Combined* instance_interface, |
| 401 WebPluginContainer* container, | 401 WebPluginContainer* container, |
| 402 const GURL& plugin_url) | 402 const GURL& plugin_url) |
| 403 : delegate_(delegate), | 403 : delegate_(delegate), |
| 404 render_view_(render_view), | 404 render_view_(render_view), |
| 405 module_(module), | 405 module_(module), |
| 406 instance_interface_(instance_interface), | 406 instance_interface_(instance_interface), |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 view_data_.is_page_visible = delegate->IsPageVisible(); | 458 view_data_.is_page_visible = delegate->IsPageVisible(); |
| 459 resource_creation_ = delegate_->CreateResourceCreationAPI(this); | 459 resource_creation_ = delegate_->CreateResourceCreationAPI(this); |
| 460 | 460 |
| 461 // TODO(bbudge) remove this when the trusted NaCl plugin has been removed. | 461 // TODO(bbudge) remove this when the trusted NaCl plugin has been removed. |
| 462 // We must defer certain plugin events for NaCl instances since we switch | 462 // We must defer certain plugin events for NaCl instances since we switch |
| 463 // from the in-process to the out-of-process proxy after instantiating them. | 463 // from the in-process to the out-of-process proxy after instantiating them. |
| 464 if (module->name() == "Native Client") | 464 if (module->name() == "Native Client") |
| 465 nacl_document_load_ = true; | 465 nacl_document_load_ = true; |
| 466 } | 466 } |
| 467 | 467 |
| 468 PluginInstance::~PluginInstance() { | 468 PluginInstanceImpl::~PluginInstanceImpl() { |
| 469 DCHECK(!fullscreen_container_); | 469 DCHECK(!fullscreen_container_); |
| 470 | 470 |
| 471 // Force-unbind any Graphics. In the case of Graphics2D, if the plugin | 471 // Force-unbind any Graphics. In the case of Graphics2D, if the plugin |
| 472 // leaks the graphics 2D, it may actually get cleaned up after our | 472 // leaks the graphics 2D, it may actually get cleaned up after our |
| 473 // destruction, so we need its pointers to be up-to-date. | 473 // destruction, so we need its pointers to be up-to-date. |
| 474 BindGraphics(pp_instance(), 0); | 474 BindGraphics(pp_instance(), 0); |
| 475 | 475 |
| 476 // Free all the plugin objects. This will automatically clear the back- | 476 // Free all the plugin objects. This will automatically clear the back- |
| 477 // pointer from the NPObject so WebKit can't call into the plugin any more. | 477 // pointer from the NPObject so WebKit can't call into the plugin any more. |
| 478 // | 478 // |
| (...skipping 18 matching lines...) Expand all Loading... |
| 497 // want to look up in the global map to get info off of our object. | 497 // want to look up in the global map to get info off of our object. |
| 498 HostGlobals::Get()->InstanceDeleted(pp_instance_); | 498 HostGlobals::Get()->InstanceDeleted(pp_instance_); |
| 499 } | 499 } |
| 500 | 500 |
| 501 // NOTE: Any of these methods that calls into the plugin needs to take into | 501 // NOTE: Any of these methods that calls into the plugin needs to take into |
| 502 // account that the plugin may use Var to remove the <embed> from the DOM, which | 502 // account that the plugin may use Var to remove the <embed> from the DOM, which |
| 503 // will make the WebPluginImpl drop its reference, usually the last one. If a | 503 // will make the WebPluginImpl drop its reference, usually the last one. If a |
| 504 // method needs to access a member of the instance after the call has returned, | 504 // method needs to access a member of the instance after the call has returned, |
| 505 // then it needs to keep its own reference on the stack. | 505 // then it needs to keep its own reference on the stack. |
| 506 | 506 |
| 507 void PluginInstance::Delete() { | 507 void PluginInstanceImpl::Delete() { |
| 508 // Keep a reference on the stack. See NOTE above. | 508 // Keep a reference on the stack. See NOTE above. |
| 509 scoped_refptr<PluginInstance> ref(this); | 509 scoped_refptr<PluginInstanceImpl> ref(this); |
| 510 // Force the MessageChannel to release its "passthrough object" which should | 510 // Force the MessageChannel to release its "passthrough object" which should |
| 511 // release our last reference to the "InstanceObject" and will probably | 511 // release our last reference to the "InstanceObject" and will probably |
| 512 // destroy it. We want to do this prior to calling DidDestroy in case the | 512 // destroy it. We want to do this prior to calling DidDestroy in case the |
| 513 // destructor of the instance object tries to use the instance. | 513 // destructor of the instance object tries to use the instance. |
| 514 message_channel_->SetPassthroughObject(NULL); | 514 message_channel_->SetPassthroughObject(NULL); |
| 515 // If this is a NaCl plugin instance, shut down the NaCl plugin by calling | 515 // If this is a NaCl plugin instance, shut down the NaCl plugin by calling |
| 516 // its DidDestroy. Don't call DidDestroy on the untrusted plugin instance, | 516 // its DidDestroy. Don't call DidDestroy on the untrusted plugin instance, |
| 517 // since there is little that it can do at this point. | 517 // since there is little that it can do at this point. |
| 518 if (original_instance_interface_) | 518 if (original_instance_interface_) |
| 519 original_instance_interface_->DidDestroy(pp_instance()); | 519 original_instance_interface_->DidDestroy(pp_instance()); |
| 520 else | 520 else |
| 521 instance_interface_->DidDestroy(pp_instance()); | 521 instance_interface_->DidDestroy(pp_instance()); |
| 522 // Ensure we don't attempt to call functions on the destroyed instance. | 522 // Ensure we don't attempt to call functions on the destroyed instance. |
| 523 original_instance_interface_.reset(); | 523 original_instance_interface_.reset(); |
| 524 instance_interface_.reset(); | 524 instance_interface_.reset(); |
| 525 | 525 |
| 526 if (fullscreen_container_) { | 526 if (fullscreen_container_) { |
| 527 fullscreen_container_->Destroy(); | 527 fullscreen_container_->Destroy(); |
| 528 fullscreen_container_ = NULL; | 528 fullscreen_container_ = NULL; |
| 529 } | 529 } |
| 530 bound_graphics_3d_ = NULL; | 530 bound_graphics_3d_ = NULL; |
| 531 UpdateLayer(); | 531 UpdateLayer(); |
| 532 container_ = NULL; | 532 container_ = NULL; |
| 533 } | 533 } |
| 534 | 534 |
| 535 void PluginInstance::Paint(WebCanvas* canvas, | 535 void PluginInstanceImpl::Paint(WebCanvas* canvas, |
| 536 const gfx::Rect& plugin_rect, | 536 const gfx::Rect& plugin_rect, |
| 537 const gfx::Rect& paint_rect) { | 537 const gfx::Rect& paint_rect) { |
| 538 TRACE_EVENT0("ppapi", "PluginInstance::Paint"); | 538 TRACE_EVENT0("ppapi", "PluginInstance::Paint"); |
| 539 if (module()->is_crashed()) { | 539 if (module()->is_crashed()) { |
| 540 // Crashed plugin painting. | 540 // Crashed plugin painting. |
| 541 if (!sad_plugin_) // Lazily initialize bitmap. | 541 if (!sad_plugin_) // Lazily initialize bitmap. |
| 542 sad_plugin_ = delegate_->GetSadPluginBitmap(); | 542 sad_plugin_ = delegate_->GetSadPluginBitmap(); |
| 543 if (sad_plugin_) | 543 if (sad_plugin_) |
| 544 webkit::PaintSadPlugin(canvas, plugin_rect, *sad_plugin_); | 544 webkit::PaintSadPlugin(canvas, plugin_rect, *sad_plugin_); |
| 545 return; | 545 return; |
| 546 } | 546 } |
| 547 | 547 |
| 548 PluginDelegate::PlatformGraphics2D* bound_graphics_2d = GetBoundGraphics2D(); | 548 PluginDelegate::PlatformGraphics2D* bound_graphics_2d = GetBoundGraphics2D(); |
| 549 if (bound_graphics_2d) | 549 if (bound_graphics_2d) |
| 550 bound_graphics_2d->Paint(canvas, plugin_rect, paint_rect); | 550 bound_graphics_2d->Paint(canvas, plugin_rect, paint_rect); |
| 551 } | 551 } |
| 552 | 552 |
| 553 void PluginInstance::InvalidateRect(const gfx::Rect& rect) { | 553 void PluginInstanceImpl::InvalidateRect(const gfx::Rect& rect) { |
| 554 if (fullscreen_container_) { | 554 if (fullscreen_container_) { |
| 555 if (rect.IsEmpty()) | 555 if (rect.IsEmpty()) |
| 556 fullscreen_container_->Invalidate(); | 556 fullscreen_container_->Invalidate(); |
| 557 else | 557 else |
| 558 fullscreen_container_->InvalidateRect(rect); | 558 fullscreen_container_->InvalidateRect(rect); |
| 559 } else { | 559 } else { |
| 560 if (!container_ || | 560 if (!container_ || |
| 561 view_data_.rect.size.width == 0 || view_data_.rect.size.height == 0) | 561 view_data_.rect.size.width == 0 || view_data_.rect.size.height == 0) |
| 562 return; // Nothing to do. | 562 return; // Nothing to do. |
| 563 if (rect.IsEmpty()) | 563 if (rect.IsEmpty()) |
| 564 container_->invalidate(); | 564 container_->invalidate(); |
| 565 else | 565 else |
| 566 container_->invalidateRect(rect); | 566 container_->invalidateRect(rect); |
| 567 } | 567 } |
| 568 } | 568 } |
| 569 | 569 |
| 570 void PluginInstance::ScrollRect(int dx, int dy, const gfx::Rect& rect) { | 570 void PluginInstanceImpl::ScrollRect(int dx, int dy, const gfx::Rect& rect) { |
| 571 if (fullscreen_container_) { | 571 if (fullscreen_container_) { |
| 572 fullscreen_container_->ScrollRect(dx, dy, rect); | 572 fullscreen_container_->ScrollRect(dx, dy, rect); |
| 573 } else { | 573 } else { |
| 574 if (full_frame_ && !IsViewAccelerated()) { | 574 if (full_frame_ && !IsViewAccelerated()) { |
| 575 container_->scrollRect(dx, dy, rect); | 575 container_->scrollRect(dx, dy, rect); |
| 576 } else { | 576 } else { |
| 577 // Can't do optimized scrolling since there could be other elements on top | 577 // Can't do optimized scrolling since there could be other elements on top |
| 578 // of us or the view renders via the accelerated compositor which is | 578 // of us or the view renders via the accelerated compositor which is |
| 579 // incompatible with the move and backfill scrolling model. | 579 // incompatible with the move and backfill scrolling model. |
| 580 InvalidateRect(rect); | 580 InvalidateRect(rect); |
| 581 } | 581 } |
| 582 } | 582 } |
| 583 } | 583 } |
| 584 | 584 |
| 585 void PluginInstance::CommitBackingTexture() { | 585 void PluginInstanceImpl::CommitBackingTexture() { |
| 586 if (texture_layer_.get()) | 586 if (texture_layer_.get()) |
| 587 texture_layer_->SetNeedsDisplay(); | 587 texture_layer_->SetNeedsDisplay(); |
| 588 } | 588 } |
| 589 | 589 |
| 590 void PluginInstance::InstanceCrashed() { | 590 void PluginInstanceImpl::InstanceCrashed() { |
| 591 // Force free all resources and vars. | 591 // Force free all resources and vars. |
| 592 HostGlobals::Get()->InstanceCrashed(pp_instance()); | 592 HostGlobals::Get()->InstanceCrashed(pp_instance()); |
| 593 | 593 |
| 594 // Free any associated graphics. | 594 // Free any associated graphics. |
| 595 SetFullscreen(false); | 595 SetFullscreen(false); |
| 596 FlashSetFullscreen(false, false); | 596 FlashSetFullscreen(false, false); |
| 597 // Unbind current 2D or 3D graphics context. | 597 // Unbind current 2D or 3D graphics context. |
| 598 BindGraphics(pp_instance(), 0); | 598 BindGraphics(pp_instance(), 0); |
| 599 InvalidateRect(gfx::Rect()); | 599 InvalidateRect(gfx::Rect()); |
| 600 | 600 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 625 // 3 : 3D content and GPU is not blacklisted | 625 // 3 : 3D content and GPU is not blacklisted |
| 626 // 4 : No 3D content and GPU is blacklisted on XP | 626 // 4 : No 3D content and GPU is blacklisted on XP |
| 627 // 5 : No 3D content and GPU is not blacklisted on XP | 627 // 5 : No 3D content and GPU is not blacklisted on XP |
| 628 // 6 : 3D content but GPU is blacklisted on XP | 628 // 6 : 3D content but GPU is blacklisted on XP |
| 629 // 7 : 3D content and GPU is not blacklisted on XP | 629 // 7 : 3D content and GPU is not blacklisted on XP |
| 630 UMA_HISTOGRAM_ENUMERATION("Flash.UsesGPU", | 630 UMA_HISTOGRAM_ENUMERATION("Flash.UsesGPU", |
| 631 is_xp * 4 + needs_gpu * 2 + prefs.is_webgl_supported, 8); | 631 is_xp * 4 + needs_gpu * 2 + prefs.is_webgl_supported, 8); |
| 632 #endif | 632 #endif |
| 633 } | 633 } |
| 634 | 634 |
| 635 bool PluginInstance::Initialize(const std::vector<std::string>& arg_names, | 635 bool PluginInstanceImpl::Initialize(const std::vector<std::string>& arg_names, |
| 636 const std::vector<std::string>& arg_values, | 636 const std::vector<std::string>& arg_values, |
| 637 bool full_frame) { | 637 bool full_frame) { |
| 638 message_channel_.reset(new MessageChannel(this)); | 638 message_channel_.reset(new MessageChannel(this)); |
| 639 | 639 |
| 640 full_frame_ = full_frame; | 640 full_frame_ = full_frame; |
| 641 | 641 |
| 642 UpdateTouchEventRequest(); | 642 UpdateTouchEventRequest(); |
| 643 container_->setWantsWheelEvents(IsAcceptingWheelEvents()); | 643 container_->setWantsWheelEvents(IsAcceptingWheelEvents()); |
| 644 | 644 |
| 645 SetGPUHistogram(delegate_->GetPreferences(), arg_names, arg_values); | 645 SetGPUHistogram(delegate_->GetPreferences(), arg_names, arg_values); |
| 646 | 646 |
| 647 argn_ = arg_names; | 647 argn_ = arg_names; |
| 648 argv_ = arg_values; | 648 argv_ = arg_values; |
| 649 scoped_ptr<const char*[]> argn_array(StringVectorToArgArray(argn_)); | 649 scoped_ptr<const char*[]> argn_array(StringVectorToArgArray(argn_)); |
| 650 scoped_ptr<const char*[]> argv_array(StringVectorToArgArray(argv_)); | 650 scoped_ptr<const char*[]> argv_array(StringVectorToArgArray(argv_)); |
| 651 bool success = PP_ToBool(instance_interface_->DidCreate(pp_instance(), | 651 bool success = PP_ToBool(instance_interface_->DidCreate(pp_instance(), |
| 652 argn_.size(), | 652 argn_.size(), |
| 653 argn_array.get(), | 653 argn_array.get(), |
| 654 argv_array.get())); | 654 argv_array.get())); |
| 655 if (success) | 655 if (success) |
| 656 message_channel_->StopQueueingJavaScriptMessages(); | 656 message_channel_->StopQueueingJavaScriptMessages(); |
| 657 return success; | 657 return success; |
| 658 } | 658 } |
| 659 | 659 |
| 660 bool PluginInstance::HandleDocumentLoad( | 660 bool PluginInstanceImpl::HandleDocumentLoad( |
| 661 const WebKit::WebURLResponse& response) { | 661 const WebKit::WebURLResponse& response) { |
| 662 DCHECK(!document_loader_); | 662 DCHECK(!document_loader_); |
| 663 if (!nacl_document_load_) { | 663 if (!nacl_document_load_) { |
| 664 if (module()->is_crashed()) { | 664 if (module()->is_crashed()) { |
| 665 // Don't create a resource for a crashed plugin. | 665 // Don't create a resource for a crashed plugin. |
| 666 container()->element().document().frame()->stopLoading(); | 666 container()->element().document().frame()->stopLoading(); |
| 667 return false; | 667 return false; |
| 668 } | 668 } |
| 669 delegate()->HandleDocumentLoad(this, response); | 669 delegate()->HandleDocumentLoad(this, response); |
| 670 // If the load was not abandoned, document_loader_ will now be set. It's | 670 // If the load was not abandoned, document_loader_ will now be set. It's |
| 671 // possible that the load was canceled by now and document_loader_ was | 671 // possible that the load was canceled by now and document_loader_ was |
| 672 // already nulled out. | 672 // already nulled out. |
| 673 } else { | 673 } else { |
| 674 // The NaCl proxy isn't available, so save the response and record document | 674 // The NaCl proxy isn't available, so save the response and record document |
| 675 // load notifications for later replay. | 675 // load notifications for later replay. |
| 676 nacl_document_response_ = response; | 676 nacl_document_response_ = response; |
| 677 nacl_document_loader_.reset(new NaClDocumentLoader()); | 677 nacl_document_loader_.reset(new NaClDocumentLoader()); |
| 678 document_loader_ = nacl_document_loader_.get(); | 678 document_loader_ = nacl_document_loader_.get(); |
| 679 } | 679 } |
| 680 return true; | 680 return true; |
| 681 } | 681 } |
| 682 | 682 |
| 683 bool PluginInstance::SendCompositionEventToPlugin(PP_InputEvent_Type type, | 683 bool PluginInstanceImpl::SendCompositionEventToPlugin( |
| 684 const base::string16& text) { | 684 PP_InputEvent_Type type, const base::string16& text) { |
| 685 std::vector<WebKit::WebCompositionUnderline> empty; | 685 std::vector<WebKit::WebCompositionUnderline> empty; |
| 686 return SendCompositionEventWithUnderlineInformationToPlugin( | 686 return SendCompositionEventWithUnderlineInformationToPlugin( |
| 687 type, text, empty, static_cast<int>(text.size()), | 687 type, text, empty, static_cast<int>(text.size()), |
| 688 static_cast<int>(text.size())); | 688 static_cast<int>(text.size())); |
| 689 } | 689 } |
| 690 | 690 |
| 691 bool PluginInstance::SendCompositionEventWithUnderlineInformationToPlugin( | 691 bool PluginInstanceImpl::SendCompositionEventWithUnderlineInformationToPlugin( |
| 692 PP_InputEvent_Type type, | 692 PP_InputEvent_Type type, |
| 693 const base::string16& text, | 693 const base::string16& text, |
| 694 const std::vector<WebKit::WebCompositionUnderline>& underlines, | 694 const std::vector<WebKit::WebCompositionUnderline>& underlines, |
| 695 int selection_start, | 695 int selection_start, |
| 696 int selection_end) { | 696 int selection_end) { |
| 697 // Keep a reference on the stack. See NOTE above. | 697 // Keep a reference on the stack. See NOTE above. |
| 698 scoped_refptr<PluginInstance> ref(this); | 698 scoped_refptr<PluginInstanceImpl> ref(this); |
| 699 | 699 |
| 700 if (!LoadInputEventInterface()) | 700 if (!LoadInputEventInterface()) |
| 701 return false; | 701 return false; |
| 702 | 702 |
| 703 PP_InputEvent_Class event_class = PP_INPUTEVENT_CLASS_IME; | 703 PP_InputEvent_Class event_class = PP_INPUTEVENT_CLASS_IME; |
| 704 if (!(filtered_input_event_mask_ & event_class) && | 704 if (!(filtered_input_event_mask_ & event_class) && |
| 705 !(input_event_mask_ & event_class)) | 705 !(input_event_mask_ & event_class)) |
| 706 return false; | 706 return false; |
| 707 | 707 |
| 708 ::ppapi::InputEventData event; | 708 ::ppapi::InputEventData event; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 event.is_filtered = true; | 757 event.is_filtered = true; |
| 758 else | 758 else |
| 759 handled = true; // Unfiltered events are assumed to be handled. | 759 handled = true; // Unfiltered events are assumed to be handled. |
| 760 scoped_refptr<PPB_InputEvent_Shared> event_resource( | 760 scoped_refptr<PPB_InputEvent_Shared> event_resource( |
| 761 new PPB_InputEvent_Shared(::ppapi::OBJECT_IS_IMPL, pp_instance(), event)); | 761 new PPB_InputEvent_Shared(::ppapi::OBJECT_IS_IMPL, pp_instance(), event)); |
| 762 handled |= PP_ToBool(plugin_input_event_interface_->HandleInputEvent( | 762 handled |= PP_ToBool(plugin_input_event_interface_->HandleInputEvent( |
| 763 pp_instance(), event_resource->pp_resource())); | 763 pp_instance(), event_resource->pp_resource())); |
| 764 return handled; | 764 return handled; |
| 765 } | 765 } |
| 766 | 766 |
| 767 void PluginInstance::RequestInputEventsHelper(uint32_t event_classes) { | 767 void PluginInstanceImpl::RequestInputEventsHelper(uint32_t event_classes) { |
| 768 if (event_classes & PP_INPUTEVENT_CLASS_TOUCH) | 768 if (event_classes & PP_INPUTEVENT_CLASS_TOUCH) |
| 769 UpdateTouchEventRequest(); | 769 UpdateTouchEventRequest(); |
| 770 if (event_classes & PP_INPUTEVENT_CLASS_WHEEL) | 770 if (event_classes & PP_INPUTEVENT_CLASS_WHEEL) |
| 771 container_->setWantsWheelEvents(IsAcceptingWheelEvents()); | 771 container_->setWantsWheelEvents(IsAcceptingWheelEvents()); |
| 772 } | 772 } |
| 773 | 773 |
| 774 bool PluginInstance::HandleCompositionStart(const base::string16& text) { | 774 bool PluginInstanceImpl::HandleCompositionStart(const base::string16& text) { |
| 775 return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_COMPOSITION_START, | 775 return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_COMPOSITION_START, |
| 776 text); | 776 text); |
| 777 } | 777 } |
| 778 | 778 |
| 779 bool PluginInstance::HandleCompositionUpdate( | 779 bool PluginInstanceImpl::HandleCompositionUpdate( |
| 780 const base::string16& text, | 780 const base::string16& text, |
| 781 const std::vector<WebKit::WebCompositionUnderline>& underlines, | 781 const std::vector<WebKit::WebCompositionUnderline>& underlines, |
| 782 int selection_start, | 782 int selection_start, |
| 783 int selection_end) { | 783 int selection_end) { |
| 784 return SendCompositionEventWithUnderlineInformationToPlugin( | 784 return SendCompositionEventWithUnderlineInformationToPlugin( |
| 785 PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE, | 785 PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE, |
| 786 text, underlines, selection_start, selection_end); | 786 text, underlines, selection_start, selection_end); |
| 787 } | 787 } |
| 788 | 788 |
| 789 bool PluginInstance::HandleCompositionEnd(const base::string16& text) { | 789 bool PluginInstanceImpl::HandleCompositionEnd(const base::string16& text) { |
| 790 return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_COMPOSITION_END, | 790 return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_COMPOSITION_END, |
| 791 text); | 791 text); |
| 792 } | 792 } |
| 793 | 793 |
| 794 bool PluginInstance::HandleTextInput(const base::string16& text) { | 794 bool PluginInstanceImpl::HandleTextInput(const base::string16& text) { |
| 795 return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_TEXT, | 795 return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_TEXT, |
| 796 text); | 796 text); |
| 797 } | 797 } |
| 798 | 798 |
| 799 void PluginInstance::GetSurroundingText(base::string16* text, | 799 void PluginInstanceImpl::GetSurroundingText(base::string16* text, |
| 800 ui::Range* range) const { | 800 ui::Range* range) const { |
| 801 std::vector<size_t> offsets; | 801 std::vector<size_t> offsets; |
| 802 offsets.push_back(selection_anchor_); | 802 offsets.push_back(selection_anchor_); |
| 803 offsets.push_back(selection_caret_); | 803 offsets.push_back(selection_caret_); |
| 804 *text = base::UTF8ToUTF16AndAdjustOffsets(surrounding_text_, &offsets); | 804 *text = base::UTF8ToUTF16AndAdjustOffsets(surrounding_text_, &offsets); |
| 805 range->set_start(offsets[0] == base::string16::npos ? text->size() | 805 range->set_start(offsets[0] == base::string16::npos ? text->size() |
| 806 : offsets[0]); | 806 : offsets[0]); |
| 807 range->set_end(offsets[1] == base::string16::npos ? text->size() | 807 range->set_end(offsets[1] == base::string16::npos ? text->size() |
| 808 : offsets[1]); | 808 : offsets[1]); |
| 809 } | 809 } |
| 810 | 810 |
| 811 bool PluginInstance::IsPluginAcceptingCompositionEvents() const { | 811 bool PluginInstanceImpl::IsPluginAcceptingCompositionEvents() const { |
| 812 return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_IME) || | 812 return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_IME) || |
| 813 (input_event_mask_ & PP_INPUTEVENT_CLASS_IME); | 813 (input_event_mask_ & PP_INPUTEVENT_CLASS_IME); |
| 814 } | 814 } |
| 815 | 815 |
| 816 gfx::Rect PluginInstance::GetCaretBounds() const { | 816 gfx::Rect PluginInstanceImpl::GetCaretBounds() const { |
| 817 if (!text_input_caret_set_) { | 817 if (!text_input_caret_set_) { |
| 818 // If it is never set by the plugin, use the bottom left corner. | 818 // If it is never set by the plugin, use the bottom left corner. |
| 819 return gfx::Rect(view_data_.rect.point.x, | 819 return gfx::Rect(view_data_.rect.point.x, |
| 820 view_data_.rect.point.y + view_data_.rect.size.height, | 820 view_data_.rect.point.y + view_data_.rect.size.height, |
| 821 0, 0); | 821 0, 0); |
| 822 } | 822 } |
| 823 | 823 |
| 824 // TODO(kinaba) Take CSS transformation into accont. | 824 // TODO(kinaba) Take CSS transformation into accont. |
| 825 // TODO(kinaba) Take bounding_box into account. On some platforms, an | 825 // TODO(kinaba) Take bounding_box into account. On some platforms, an |
| 826 // "exclude rectangle" where candidate window must avoid the region can be | 826 // "exclude rectangle" where candidate window must avoid the region can be |
| 827 // passed to IME. Currently, we pass only the caret rectangle because | 827 // passed to IME. Currently, we pass only the caret rectangle because |
| 828 // it is the only information supported uniformly in Chromium. | 828 // it is the only information supported uniformly in Chromium. |
| 829 gfx::Rect caret(text_input_caret_); | 829 gfx::Rect caret(text_input_caret_); |
| 830 caret.Offset(view_data_.rect.point.x, view_data_.rect.point.y); | 830 caret.Offset(view_data_.rect.point.x, view_data_.rect.point.y); |
| 831 return caret; | 831 return caret; |
| 832 } | 832 } |
| 833 | 833 |
| 834 bool PluginInstance::HandleInputEvent(const WebKit::WebInputEvent& event, | 834 bool PluginInstanceImpl::HandleInputEvent(const WebKit::WebInputEvent& event, |
| 835 WebCursorInfo* cursor_info) { | 835 WebCursorInfo* cursor_info) { |
| 836 TRACE_EVENT0("ppapi", "PluginInstance::HandleInputEvent"); | 836 TRACE_EVENT0("ppapi", "PluginInstanceImpl::HandleInputEvent"); |
| 837 | 837 |
| 838 if (WebInputEvent::isMouseEventType(event.type)) | 838 if (WebInputEvent::isMouseEventType(event.type)) |
| 839 delegate()->DidReceiveMouseEvent(this); | 839 delegate()->DidReceiveMouseEvent(this); |
| 840 | 840 |
| 841 // Don't dispatch input events to crashed plugins. | 841 // Don't dispatch input events to crashed plugins. |
| 842 if (module()->is_crashed()) | 842 if (module()->is_crashed()) |
| 843 return false; | 843 return false; |
| 844 | 844 |
| 845 // Keep a reference on the stack. See NOTE above. | 845 // Keep a reference on the stack. See NOTE above. |
| 846 scoped_refptr<PluginInstance> ref(this); | 846 scoped_refptr<PluginInstanceImpl> ref(this); |
| 847 | 847 |
| 848 bool rv = false; | 848 bool rv = false; |
| 849 if (LoadInputEventInterface()) { | 849 if (LoadInputEventInterface()) { |
| 850 PP_InputEvent_Class event_class = ClassifyInputEvent(event.type); | 850 PP_InputEvent_Class event_class = ClassifyInputEvent(event.type); |
| 851 if (!event_class) | 851 if (!event_class) |
| 852 return false; | 852 return false; |
| 853 | 853 |
| 854 if ((filtered_input_event_mask_ & event_class) || | 854 if ((filtered_input_event_mask_ & event_class) || |
| 855 (input_event_mask_ & event_class)) { | 855 (input_event_mask_ & event_class)) { |
| 856 // Actually send the event. | 856 // Actually send the event. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 882 pp_instance(), event_resource->pp_resource())); | 882 pp_instance(), event_resource->pp_resource())); |
| 883 } | 883 } |
| 884 } | 884 } |
| 885 } | 885 } |
| 886 | 886 |
| 887 if (cursor_) | 887 if (cursor_) |
| 888 *cursor_info = *cursor_; | 888 *cursor_info = *cursor_; |
| 889 return rv; | 889 return rv; |
| 890 } | 890 } |
| 891 | 891 |
| 892 void PluginInstance::HandleMessage(PP_Var message) { | 892 void PluginInstanceImpl::HandleMessage(PP_Var message) { |
| 893 TRACE_EVENT0("ppapi", "PluginInstance::HandleMessage"); | 893 TRACE_EVENT0("ppapi", "PluginInstanceImpl::HandleMessage"); |
| 894 // Keep a reference on the stack. See NOTE above. | 894 // Keep a reference on the stack. See NOTE above. |
| 895 scoped_refptr<PluginInstance> ref(this); | 895 scoped_refptr<PluginInstanceImpl> ref(this); |
| 896 if (!LoadMessagingInterface()) | 896 if (!LoadMessagingInterface()) |
| 897 return; | 897 return; |
| 898 plugin_messaging_interface_->HandleMessage(pp_instance(), message); | 898 plugin_messaging_interface_->HandleMessage(pp_instance(), message); |
| 899 } | 899 } |
| 900 | 900 |
| 901 PP_Var PluginInstance::GetInstanceObject() { | 901 PP_Var PluginInstanceImpl::GetInstanceObject() { |
| 902 // Keep a reference on the stack. See NOTE above. | 902 // Keep a reference on the stack. See NOTE above. |
| 903 scoped_refptr<PluginInstance> ref(this); | 903 scoped_refptr<PluginInstanceImpl> ref(this); |
| 904 | 904 |
| 905 // If the plugin supports the private instance interface, try to retrieve its | 905 // If the plugin supports the private instance interface, try to retrieve its |
| 906 // instance object. | 906 // instance object. |
| 907 if (LoadPrivateInterface()) | 907 if (LoadPrivateInterface()) |
| 908 return plugin_private_interface_->GetInstanceObject(pp_instance()); | 908 return plugin_private_interface_->GetInstanceObject(pp_instance()); |
| 909 return PP_MakeUndefined(); | 909 return PP_MakeUndefined(); |
| 910 } | 910 } |
| 911 | 911 |
| 912 void PluginInstance::ViewChanged(const gfx::Rect& position, | 912 void PluginInstanceImpl::ViewChanged( |
| 913 const gfx::Rect& clip, | 913 const gfx::Rect& position, |
| 914 const std::vector<gfx::Rect>& cut_outs_rects) { | 914 const gfx::Rect& clip, |
| 915 const std::vector<gfx::Rect>& cut_outs_rects) { |
| 915 // WebKit can give weird (x,y) positions for empty clip rects (since the | 916 // WebKit can give weird (x,y) positions for empty clip rects (since the |
| 916 // position technically doesn't matter). But we want to make these | 917 // position technically doesn't matter). But we want to make these |
| 917 // consistent since this is given to the plugin, so force everything to 0 | 918 // consistent since this is given to the plugin, so force everything to 0 |
| 918 // in the "everything is clipped" case. | 919 // in the "everything is clipped" case. |
| 919 gfx::Rect new_clip; | 920 gfx::Rect new_clip; |
| 920 if (!clip.IsEmpty()) | 921 if (!clip.IsEmpty()) |
| 921 new_clip = clip; | 922 new_clip = clip; |
| 922 | 923 |
| 923 cut_outs_rects_ = cut_outs_rects; | 924 cut_outs_rects_ = cut_outs_rects; |
| 924 | 925 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 954 ResetSizeAttributesAfterFullscreen(); | 955 ResetSizeAttributesAfterFullscreen(); |
| 955 return; | 956 return; |
| 956 } | 957 } |
| 957 } | 958 } |
| 958 | 959 |
| 959 UpdateFlashFullscreenState(fullscreen_container_ != NULL); | 960 UpdateFlashFullscreenState(fullscreen_container_ != NULL); |
| 960 | 961 |
| 961 SendDidChangeView(); | 962 SendDidChangeView(); |
| 962 } | 963 } |
| 963 | 964 |
| 964 void PluginInstance::SetWebKitFocus(bool has_focus) { | 965 void PluginInstanceImpl::SetWebKitFocus(bool has_focus) { |
| 965 if (has_webkit_focus_ == has_focus) | 966 if (has_webkit_focus_ == has_focus) |
| 966 return; | 967 return; |
| 967 | 968 |
| 968 bool old_plugin_focus = PluginHasFocus(); | 969 bool old_plugin_focus = PluginHasFocus(); |
| 969 has_webkit_focus_ = has_focus; | 970 has_webkit_focus_ = has_focus; |
| 970 if (PluginHasFocus() != old_plugin_focus) | 971 if (PluginHasFocus() != old_plugin_focus) |
| 971 SendFocusChangeNotification(); | 972 SendFocusChangeNotification(); |
| 972 } | 973 } |
| 973 | 974 |
| 974 void PluginInstance::SetContentAreaFocus(bool has_focus) { | 975 void PluginInstanceImpl::SetContentAreaFocus(bool has_focus) { |
| 975 if (has_content_area_focus_ == has_focus) | 976 if (has_content_area_focus_ == has_focus) |
| 976 return; | 977 return; |
| 977 | 978 |
| 978 bool old_plugin_focus = PluginHasFocus(); | 979 bool old_plugin_focus = PluginHasFocus(); |
| 979 has_content_area_focus_ = has_focus; | 980 has_content_area_focus_ = has_focus; |
| 980 if (PluginHasFocus() != old_plugin_focus) | 981 if (PluginHasFocus() != old_plugin_focus) |
| 981 SendFocusChangeNotification(); | 982 SendFocusChangeNotification(); |
| 982 } | 983 } |
| 983 | 984 |
| 984 void PluginInstance::PageVisibilityChanged(bool is_visible) { | 985 void PluginInstanceImpl::PageVisibilityChanged(bool is_visible) { |
| 985 if (is_visible == view_data_.is_page_visible) | 986 if (is_visible == view_data_.is_page_visible) |
| 986 return; // Nothing to do. | 987 return; // Nothing to do. |
| 987 view_data_.is_page_visible = is_visible; | 988 view_data_.is_page_visible = is_visible; |
| 988 | 989 |
| 989 // If the initial DidChangeView notification hasn't been sent to the plugin, | 990 // If the initial DidChangeView notification hasn't been sent to the plugin, |
| 990 // let it pass the visibility state for us, instead of sending a notification | 991 // let it pass the visibility state for us, instead of sending a notification |
| 991 // immediately. It is possible that PluginInstance::ViewChanged() hasn't been | 992 // immediately. It is possible that PluginInstanceImpl::ViewChanged() hasn't |
| 992 // called for the first time. In that case, most of the fields in |view_data_| | 993 // been called for the first time. In that case, most of the fields in |
| 993 // haven't been properly initialized. | 994 // |view_data_| haven't been properly initialized. |
| 994 if (sent_initial_did_change_view_) | 995 if (sent_initial_did_change_view_) |
| 995 SendDidChangeView(); | 996 SendDidChangeView(); |
| 996 } | 997 } |
| 997 | 998 |
| 998 void PluginInstance::ViewWillInitiatePaint() { | 999 void PluginInstanceImpl::ViewWillInitiatePaint() { |
| 999 if (GetBoundGraphics2D()) | 1000 if (GetBoundGraphics2D()) |
| 1000 GetBoundGraphics2D()->ViewWillInitiatePaint(); | 1001 GetBoundGraphics2D()->ViewWillInitiatePaint(); |
| 1001 else if (bound_graphics_3d_.get()) | 1002 else if (bound_graphics_3d_.get()) |
| 1002 bound_graphics_3d_->ViewWillInitiatePaint(); | 1003 bound_graphics_3d_->ViewWillInitiatePaint(); |
| 1003 } | 1004 } |
| 1004 | 1005 |
| 1005 void PluginInstance::ViewInitiatedPaint() { | 1006 void PluginInstanceImpl::ViewInitiatedPaint() { |
| 1006 if (GetBoundGraphics2D()) | 1007 if (GetBoundGraphics2D()) |
| 1007 GetBoundGraphics2D()->ViewInitiatedPaint(); | 1008 GetBoundGraphics2D()->ViewInitiatedPaint(); |
| 1008 else if (bound_graphics_3d_.get()) | 1009 else if (bound_graphics_3d_.get()) |
| 1009 bound_graphics_3d_->ViewInitiatedPaint(); | 1010 bound_graphics_3d_->ViewInitiatedPaint(); |
| 1010 } | 1011 } |
| 1011 | 1012 |
| 1012 void PluginInstance::ViewFlushedPaint() { | 1013 void PluginInstanceImpl::ViewFlushedPaint() { |
| 1013 // Keep a reference on the stack. See NOTE above. | 1014 // Keep a reference on the stack. See NOTE above. |
| 1014 scoped_refptr<PluginInstance> ref(this); | 1015 scoped_refptr<PluginInstanceImpl> ref(this); |
| 1015 if (GetBoundGraphics2D()) | 1016 if (GetBoundGraphics2D()) |
| 1016 GetBoundGraphics2D()->ViewFlushedPaint(); | 1017 GetBoundGraphics2D()->ViewFlushedPaint(); |
| 1017 else if (bound_graphics_3d_.get()) | 1018 else if (bound_graphics_3d_.get()) |
| 1018 bound_graphics_3d_->ViewFlushedPaint(); | 1019 bound_graphics_3d_->ViewFlushedPaint(); |
| 1019 } | 1020 } |
| 1020 | 1021 |
| 1021 bool PluginInstance::GetBitmapForOptimizedPluginPaint( | 1022 bool PluginInstanceImpl::GetBitmapForOptimizedPluginPaint( |
| 1022 const gfx::Rect& paint_bounds, | 1023 const gfx::Rect& paint_bounds, |
| 1023 TransportDIB** dib, | 1024 TransportDIB** dib, |
| 1024 gfx::Rect* location, | 1025 gfx::Rect* location, |
| 1025 gfx::Rect* clip, | 1026 gfx::Rect* clip, |
| 1026 float* scale_factor) { | 1027 float* scale_factor) { |
| 1027 if (!always_on_top_) | 1028 if (!always_on_top_) |
| 1028 return false; | 1029 return false; |
| 1029 if (!GetBoundGraphics2D() || !GetBoundGraphics2D()->IsAlwaysOpaque()) | 1030 if (!GetBoundGraphics2D() || !GetBoundGraphics2D()->IsAlwaysOpaque()) |
| 1030 return false; | 1031 return false; |
| 1031 | 1032 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1068 plugin_backing_store_rect.Offset(plugin_offset); | 1069 plugin_backing_store_rect.Offset(plugin_offset); |
| 1069 *location = plugin_backing_store_rect; | 1070 *location = plugin_backing_store_rect; |
| 1070 clip_page.Offset(plugin_offset); | 1071 clip_page.Offset(plugin_offset); |
| 1071 *clip = clip_page; | 1072 *clip = clip_page; |
| 1072 // The plugin scale factor is inverted, e.g. for a device scale factor of 2x | 1073 // The plugin scale factor is inverted, e.g. for a device scale factor of 2x |
| 1073 // the plugin scale factor is 0.5. | 1074 // the plugin scale factor is 0.5. |
| 1074 *scale_factor = 1.0 / scale; | 1075 *scale_factor = 1.0 / scale; |
| 1075 return true; | 1076 return true; |
| 1076 } | 1077 } |
| 1077 | 1078 |
| 1078 base::string16 PluginInstance::GetSelectedText(bool html) { | 1079 base::string16 PluginInstanceImpl::GetSelectedText(bool html) { |
| 1079 // Keep a reference on the stack. See NOTE above. | 1080 // Keep a reference on the stack. See NOTE above. |
| 1080 scoped_refptr<PluginInstance> ref(this); | 1081 scoped_refptr<PluginInstanceImpl> ref(this); |
| 1081 if (!LoadSelectionInterface()) | 1082 if (!LoadSelectionInterface()) |
| 1082 return base::string16(); | 1083 return base::string16(); |
| 1083 | 1084 |
| 1084 PP_Var rv = plugin_selection_interface_->GetSelectedText(pp_instance(), | 1085 PP_Var rv = plugin_selection_interface_->GetSelectedText(pp_instance(), |
| 1085 PP_FromBool(html)); | 1086 PP_FromBool(html)); |
| 1086 StringVar* string = StringVar::FromPPVar(rv); | 1087 StringVar* string = StringVar::FromPPVar(rv); |
| 1087 base::string16 selection; | 1088 base::string16 selection; |
| 1088 if (string) | 1089 if (string) |
| 1089 selection = UTF8ToUTF16(string->value()); | 1090 selection = UTF8ToUTF16(string->value()); |
| 1090 // Release the ref the plugin transfered to us. | 1091 // Release the ref the plugin transfered to us. |
| 1091 HostGlobals::Get()->GetVarTracker()->ReleaseVar(rv); | 1092 HostGlobals::Get()->GetVarTracker()->ReleaseVar(rv); |
| 1092 return selection; | 1093 return selection; |
| 1093 } | 1094 } |
| 1094 | 1095 |
| 1095 base::string16 PluginInstance::GetLinkAtPosition(const gfx::Point& point) { | 1096 base::string16 PluginInstanceImpl::GetLinkAtPosition(const gfx::Point& point) { |
| 1096 // Keep a reference on the stack. See NOTE above. | 1097 // Keep a reference on the stack. See NOTE above. |
| 1097 scoped_refptr<PluginInstance> ref(this); | 1098 scoped_refptr<PluginInstanceImpl> ref(this); |
| 1098 if (!LoadPdfInterface()) | 1099 if (!LoadPdfInterface()) |
| 1099 return base::string16(); | 1100 return base::string16(); |
| 1100 | 1101 |
| 1101 PP_Point p; | 1102 PP_Point p; |
| 1102 p.x = point.x(); | 1103 p.x = point.x(); |
| 1103 p.y = point.y(); | 1104 p.y = point.y(); |
| 1104 PP_Var rv = plugin_pdf_interface_->GetLinkAtPosition(pp_instance(), p); | 1105 PP_Var rv = plugin_pdf_interface_->GetLinkAtPosition(pp_instance(), p); |
| 1105 StringVar* string = StringVar::FromPPVar(rv); | 1106 StringVar* string = StringVar::FromPPVar(rv); |
| 1106 base::string16 link; | 1107 base::string16 link; |
| 1107 if (string) | 1108 if (string) |
| 1108 link = UTF8ToUTF16(string->value()); | 1109 link = UTF8ToUTF16(string->value()); |
| 1109 // Release the ref the plugin transfered to us. | 1110 // Release the ref the plugin transfered to us. |
| 1110 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(rv); | 1111 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(rv); |
| 1111 return link; | 1112 return link; |
| 1112 } | 1113 } |
| 1113 | 1114 |
| 1114 void PluginInstance::RequestSurroundingText( | 1115 void PluginInstanceImpl::RequestSurroundingText( |
| 1115 size_t desired_number_of_characters) { | 1116 size_t desired_number_of_characters) { |
| 1116 // Keep a reference on the stack. See NOTE above. | 1117 // Keep a reference on the stack. See NOTE above. |
| 1117 scoped_refptr<PluginInstance> ref(this); | 1118 scoped_refptr<PluginInstanceImpl> ref(this); |
| 1118 if (!LoadTextInputInterface()) | 1119 if (!LoadTextInputInterface()) |
| 1119 return; | 1120 return; |
| 1120 plugin_textinput_interface_->RequestSurroundingText( | 1121 plugin_textinput_interface_->RequestSurroundingText( |
| 1121 pp_instance(), desired_number_of_characters); | 1122 pp_instance(), desired_number_of_characters); |
| 1122 } | 1123 } |
| 1123 | 1124 |
| 1124 void PluginInstance::Zoom(double factor, bool text_only) { | 1125 void PluginInstanceImpl::Zoom(double factor, bool text_only) { |
| 1125 // Keep a reference on the stack. See NOTE above. | 1126 // Keep a reference on the stack. See NOTE above. |
| 1126 scoped_refptr<PluginInstance> ref(this); | 1127 scoped_refptr<PluginInstanceImpl> ref(this); |
| 1127 if (!LoadZoomInterface()) | 1128 if (!LoadZoomInterface()) |
| 1128 return; | 1129 return; |
| 1129 plugin_zoom_interface_->Zoom(pp_instance(), factor, PP_FromBool(text_only)); | 1130 plugin_zoom_interface_->Zoom(pp_instance(), factor, PP_FromBool(text_only)); |
| 1130 } | 1131 } |
| 1131 | 1132 |
| 1132 bool PluginInstance::StartFind(const base::string16& search_text, | 1133 bool PluginInstanceImpl::StartFind(const base::string16& search_text, |
| 1133 bool case_sensitive, | 1134 bool case_sensitive, |
| 1134 int identifier) { | 1135 int identifier) { |
| 1135 // Keep a reference on the stack. See NOTE above. | 1136 // Keep a reference on the stack. See NOTE above. |
| 1136 scoped_refptr<PluginInstance> ref(this); | 1137 scoped_refptr<PluginInstanceImpl> ref(this); |
| 1137 if (!LoadFindInterface()) | 1138 if (!LoadFindInterface()) |
| 1138 return false; | 1139 return false; |
| 1139 find_identifier_ = identifier; | 1140 find_identifier_ = identifier; |
| 1140 return PP_ToBool( | 1141 return PP_ToBool( |
| 1141 plugin_find_interface_->StartFind( | 1142 plugin_find_interface_->StartFind( |
| 1142 pp_instance(), | 1143 pp_instance(), |
| 1143 UTF16ToUTF8(search_text.c_str()).c_str(), | 1144 UTF16ToUTF8(search_text.c_str()).c_str(), |
| 1144 PP_FromBool(case_sensitive))); | 1145 PP_FromBool(case_sensitive))); |
| 1145 } | 1146 } |
| 1146 | 1147 |
| 1147 void PluginInstance::SelectFindResult(bool forward) { | 1148 void PluginInstanceImpl::SelectFindResult(bool forward) { |
| 1148 // Keep a reference on the stack. See NOTE above. | 1149 // Keep a reference on the stack. See NOTE above. |
| 1149 scoped_refptr<PluginInstance> ref(this); | 1150 scoped_refptr<PluginInstanceImpl> ref(this); |
| 1150 if (LoadFindInterface()) | 1151 if (LoadFindInterface()) |
| 1151 plugin_find_interface_->SelectFindResult(pp_instance(), | 1152 plugin_find_interface_->SelectFindResult(pp_instance(), |
| 1152 PP_FromBool(forward)); | 1153 PP_FromBool(forward)); |
| 1153 } | 1154 } |
| 1154 | 1155 |
| 1155 void PluginInstance::StopFind() { | 1156 void PluginInstanceImpl::StopFind() { |
| 1156 // Keep a reference on the stack. See NOTE above. | 1157 // Keep a reference on the stack. See NOTE above. |
| 1157 scoped_refptr<PluginInstance> ref(this); | 1158 scoped_refptr<PluginInstanceImpl> ref(this); |
| 1158 if (!LoadFindInterface()) | 1159 if (!LoadFindInterface()) |
| 1159 return; | 1160 return; |
| 1160 find_identifier_ = -1; | 1161 find_identifier_ = -1; |
| 1161 plugin_find_interface_->StopFind(pp_instance()); | 1162 plugin_find_interface_->StopFind(pp_instance()); |
| 1162 } | 1163 } |
| 1163 | 1164 |
| 1164 bool PluginInstance::LoadFindInterface() { | 1165 bool PluginInstanceImpl::LoadFindInterface() { |
| 1165 if (!plugin_find_interface_) { | 1166 if (!plugin_find_interface_) { |
| 1166 plugin_find_interface_ = | 1167 plugin_find_interface_ = |
| 1167 static_cast<const PPP_Find_Dev*>(module_->GetPluginInterface( | 1168 static_cast<const PPP_Find_Dev*>(module_->GetPluginInterface( |
| 1168 PPP_FIND_DEV_INTERFACE)); | 1169 PPP_FIND_DEV_INTERFACE)); |
| 1169 } | 1170 } |
| 1170 | 1171 |
| 1171 return !!plugin_find_interface_; | 1172 return !!plugin_find_interface_; |
| 1172 } | 1173 } |
| 1173 | 1174 |
| 1174 bool PluginInstance::LoadInputEventInterface() { | 1175 bool PluginInstanceImpl::LoadInputEventInterface() { |
| 1175 if (!checked_for_plugin_input_event_interface_) { | 1176 if (!checked_for_plugin_input_event_interface_) { |
| 1176 checked_for_plugin_input_event_interface_ = true; | 1177 checked_for_plugin_input_event_interface_ = true; |
| 1177 plugin_input_event_interface_ = | 1178 plugin_input_event_interface_ = |
| 1178 static_cast<const PPP_InputEvent*>(module_->GetPluginInterface( | 1179 static_cast<const PPP_InputEvent*>(module_->GetPluginInterface( |
| 1179 PPP_INPUT_EVENT_INTERFACE)); | 1180 PPP_INPUT_EVENT_INTERFACE)); |
| 1180 } | 1181 } |
| 1181 return !!plugin_input_event_interface_; | 1182 return !!plugin_input_event_interface_; |
| 1182 } | 1183 } |
| 1183 | 1184 |
| 1184 bool PluginInstance::LoadMessagingInterface() { | 1185 bool PluginInstanceImpl::LoadMessagingInterface() { |
| 1185 if (!checked_for_plugin_messaging_interface_) { | 1186 if (!checked_for_plugin_messaging_interface_) { |
| 1186 checked_for_plugin_messaging_interface_ = true; | 1187 checked_for_plugin_messaging_interface_ = true; |
| 1187 plugin_messaging_interface_ = | 1188 plugin_messaging_interface_ = |
| 1188 static_cast<const PPP_Messaging*>(module_->GetPluginInterface( | 1189 static_cast<const PPP_Messaging*>(module_->GetPluginInterface( |
| 1189 PPP_MESSAGING_INTERFACE)); | 1190 PPP_MESSAGING_INTERFACE)); |
| 1190 } | 1191 } |
| 1191 return !!plugin_messaging_interface_; | 1192 return !!plugin_messaging_interface_; |
| 1192 } | 1193 } |
| 1193 | 1194 |
| 1194 bool PluginInstance::LoadMouseLockInterface() { | 1195 bool PluginInstanceImpl::LoadMouseLockInterface() { |
| 1195 if (!plugin_mouse_lock_interface_) { | 1196 if (!plugin_mouse_lock_interface_) { |
| 1196 plugin_mouse_lock_interface_ = | 1197 plugin_mouse_lock_interface_ = |
| 1197 static_cast<const PPP_MouseLock*>(module_->GetPluginInterface( | 1198 static_cast<const PPP_MouseLock*>(module_->GetPluginInterface( |
| 1198 PPP_MOUSELOCK_INTERFACE)); | 1199 PPP_MOUSELOCK_INTERFACE)); |
| 1199 } | 1200 } |
| 1200 | 1201 |
| 1201 return !!plugin_mouse_lock_interface_; | 1202 return !!plugin_mouse_lock_interface_; |
| 1202 } | 1203 } |
| 1203 | 1204 |
| 1204 bool PluginInstance::LoadPdfInterface() { | 1205 bool PluginInstanceImpl::LoadPdfInterface() { |
| 1205 if (!checked_for_plugin_pdf_interface_) { | 1206 if (!checked_for_plugin_pdf_interface_) { |
| 1206 checked_for_plugin_pdf_interface_ = true; | 1207 checked_for_plugin_pdf_interface_ = true; |
| 1207 plugin_pdf_interface_ = | 1208 plugin_pdf_interface_ = |
| 1208 static_cast<const PPP_Pdf_1*>(module_->GetPluginInterface( | 1209 static_cast<const PPP_Pdf_1*>(module_->GetPluginInterface( |
| 1209 PPP_PDF_INTERFACE_1)); | 1210 PPP_PDF_INTERFACE_1)); |
| 1210 } | 1211 } |
| 1211 | 1212 |
| 1212 return !!plugin_pdf_interface_; | 1213 return !!plugin_pdf_interface_; |
| 1213 } | 1214 } |
| 1214 | 1215 |
| 1215 bool PluginInstance::LoadPrintInterface() { | 1216 bool PluginInstanceImpl::LoadPrintInterface() { |
| 1216 // Only check for the interface if the plugin has dev permission. | 1217 // Only check for the interface if the plugin has dev permission. |
| 1217 if (!module_->permissions().HasPermission(::ppapi::PERMISSION_DEV)) | 1218 if (!module_->permissions().HasPermission(::ppapi::PERMISSION_DEV)) |
| 1218 return false; | 1219 return false; |
| 1219 if (!plugin_print_interface_) { | 1220 if (!plugin_print_interface_) { |
| 1220 plugin_print_interface_ = static_cast<const PPP_Printing_Dev*>( | 1221 plugin_print_interface_ = static_cast<const PPP_Printing_Dev*>( |
| 1221 module_->GetPluginInterface(PPP_PRINTING_DEV_INTERFACE)); | 1222 module_->GetPluginInterface(PPP_PRINTING_DEV_INTERFACE)); |
| 1222 } | 1223 } |
| 1223 return !!plugin_print_interface_; | 1224 return !!plugin_print_interface_; |
| 1224 } | 1225 } |
| 1225 | 1226 |
| 1226 bool PluginInstance::LoadPrivateInterface() { | 1227 bool PluginInstanceImpl::LoadPrivateInterface() { |
| 1227 // Only check for the interface if the plugin has private permission. | 1228 // Only check for the interface if the plugin has private permission. |
| 1228 if (!module_->permissions().HasPermission(::ppapi::PERMISSION_PRIVATE)) | 1229 if (!module_->permissions().HasPermission(::ppapi::PERMISSION_PRIVATE)) |
| 1229 return false; | 1230 return false; |
| 1230 if (!plugin_private_interface_) { | 1231 if (!plugin_private_interface_) { |
| 1231 plugin_private_interface_ = static_cast<const PPP_Instance_Private*>( | 1232 plugin_private_interface_ = static_cast<const PPP_Instance_Private*>( |
| 1232 module_->GetPluginInterface(PPP_INSTANCE_PRIVATE_INTERFACE)); | 1233 module_->GetPluginInterface(PPP_INSTANCE_PRIVATE_INTERFACE)); |
| 1233 } | 1234 } |
| 1234 | 1235 |
| 1235 return !!plugin_private_interface_; | 1236 return !!plugin_private_interface_; |
| 1236 } | 1237 } |
| 1237 | 1238 |
| 1238 bool PluginInstance::LoadSelectionInterface() { | 1239 bool PluginInstanceImpl::LoadSelectionInterface() { |
| 1239 if (!plugin_selection_interface_) { | 1240 if (!plugin_selection_interface_) { |
| 1240 plugin_selection_interface_ = | 1241 plugin_selection_interface_ = |
| 1241 static_cast<const PPP_Selection_Dev*>(module_->GetPluginInterface( | 1242 static_cast<const PPP_Selection_Dev*>(module_->GetPluginInterface( |
| 1242 PPP_SELECTION_DEV_INTERFACE)); | 1243 PPP_SELECTION_DEV_INTERFACE)); |
| 1243 } | 1244 } |
| 1244 return !!plugin_selection_interface_; | 1245 return !!plugin_selection_interface_; |
| 1245 } | 1246 } |
| 1246 | 1247 |
| 1247 bool PluginInstance::LoadTextInputInterface() { | 1248 bool PluginInstanceImpl::LoadTextInputInterface() { |
| 1248 if (!plugin_textinput_interface_) { | 1249 if (!plugin_textinput_interface_) { |
| 1249 plugin_textinput_interface_ = | 1250 plugin_textinput_interface_ = |
| 1250 static_cast<const PPP_TextInput_Dev*>(module_->GetPluginInterface( | 1251 static_cast<const PPP_TextInput_Dev*>(module_->GetPluginInterface( |
| 1251 PPP_TEXTINPUT_DEV_INTERFACE)); | 1252 PPP_TEXTINPUT_DEV_INTERFACE)); |
| 1252 } | 1253 } |
| 1253 | 1254 |
| 1254 return !!plugin_textinput_interface_; | 1255 return !!plugin_textinput_interface_; |
| 1255 } | 1256 } |
| 1256 | 1257 |
| 1257 bool PluginInstance::LoadZoomInterface() { | 1258 bool PluginInstanceImpl::LoadZoomInterface() { |
| 1258 if (!plugin_zoom_interface_) { | 1259 if (!plugin_zoom_interface_) { |
| 1259 plugin_zoom_interface_ = | 1260 plugin_zoom_interface_ = |
| 1260 static_cast<const PPP_Zoom_Dev*>(module_->GetPluginInterface( | 1261 static_cast<const PPP_Zoom_Dev*>(module_->GetPluginInterface( |
| 1261 PPP_ZOOM_DEV_INTERFACE)); | 1262 PPP_ZOOM_DEV_INTERFACE)); |
| 1262 } | 1263 } |
| 1263 | 1264 |
| 1264 return !!plugin_zoom_interface_; | 1265 return !!plugin_zoom_interface_; |
| 1265 } | 1266 } |
| 1266 | 1267 |
| 1267 bool PluginInstance::PluginHasFocus() const { | 1268 bool PluginInstanceImpl::PluginHasFocus() const { |
| 1268 return flash_fullscreen_ || (has_webkit_focus_ && has_content_area_focus_); | 1269 return flash_fullscreen_ || (has_webkit_focus_ && has_content_area_focus_); |
| 1269 } | 1270 } |
| 1270 | 1271 |
| 1271 void PluginInstance::SendFocusChangeNotification() { | 1272 void PluginInstanceImpl::SendFocusChangeNotification() { |
| 1272 // This call can happen during PluginInstance destruction, because WebKit | 1273 // This call can happen during PluginInstanceImpl destruction, because WebKit |
| 1273 // informs the plugin it's losing focus. See crbug.com/236574 | 1274 // informs the plugin it's losing focus. See crbug.com/236574 |
| 1274 if (!delegate_ || !instance_interface_) | 1275 if (!delegate_ || !instance_interface_) |
| 1275 return; | 1276 return; |
| 1276 bool has_focus = PluginHasFocus(); | 1277 bool has_focus = PluginHasFocus(); |
| 1277 delegate()->PluginFocusChanged(this, has_focus); | 1278 delegate()->PluginFocusChanged(this, has_focus); |
| 1278 instance_interface_->DidChangeFocus(pp_instance(), PP_FromBool(has_focus)); | 1279 instance_interface_->DidChangeFocus(pp_instance(), PP_FromBool(has_focus)); |
| 1279 } | 1280 } |
| 1280 | 1281 |
| 1281 void PluginInstance::UpdateTouchEventRequest() { | 1282 void PluginInstanceImpl::UpdateTouchEventRequest() { |
| 1282 bool raw_touch = (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH) || | 1283 bool raw_touch = (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH) || |
| 1283 (input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH); | 1284 (input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH); |
| 1284 container_->requestTouchEventType(raw_touch ? | 1285 container_->requestTouchEventType(raw_touch ? |
| 1285 WebKit::WebPluginContainer::TouchEventRequestTypeRaw : | 1286 WebKit::WebPluginContainer::TouchEventRequestTypeRaw : |
| 1286 WebKit::WebPluginContainer::TouchEventRequestTypeSynthesizedMouse); | 1287 WebKit::WebPluginContainer::TouchEventRequestTypeSynthesizedMouse); |
| 1287 } | 1288 } |
| 1288 | 1289 |
| 1289 bool PluginInstance::IsAcceptingWheelEvents() const { | 1290 bool PluginInstanceImpl::IsAcceptingWheelEvents() const { |
| 1290 return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL) || | 1291 return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL) || |
| 1291 (input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL); | 1292 (input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL); |
| 1292 } | 1293 } |
| 1293 | 1294 |
| 1294 void PluginInstance::ScheduleAsyncDidChangeView() { | 1295 void PluginInstanceImpl::ScheduleAsyncDidChangeView() { |
| 1295 if (view_change_weak_ptr_factory_.HasWeakPtrs()) | 1296 if (view_change_weak_ptr_factory_.HasWeakPtrs()) |
| 1296 return; // Already scheduled. | 1297 return; // Already scheduled. |
| 1297 base::MessageLoop::current()->PostTask( | 1298 base::MessageLoop::current()->PostTask( |
| 1298 FROM_HERE, | 1299 FROM_HERE, |
| 1299 base::Bind(&PluginInstance::SendAsyncDidChangeView, | 1300 base::Bind(&PluginInstanceImpl::SendAsyncDidChangeView, |
| 1300 view_change_weak_ptr_factory_.GetWeakPtr())); | 1301 view_change_weak_ptr_factory_.GetWeakPtr())); |
| 1301 } | 1302 } |
| 1302 | 1303 |
| 1303 void PluginInstance::SendAsyncDidChangeView() { | 1304 void PluginInstanceImpl::SendAsyncDidChangeView() { |
| 1304 // The bound callback that owns the weak pointer is still valid until after | 1305 // The bound callback that owns the weak pointer is still valid until after |
| 1305 // this function returns. SendDidChangeView checks HasWeakPtrs, so we need to | 1306 // this function returns. SendDidChangeView checks HasWeakPtrs, so we need to |
| 1306 // invalidate them here. | 1307 // invalidate them here. |
| 1307 // NOTE: If we ever want to have more than one pending callback, it should | 1308 // NOTE: If we ever want to have more than one pending callback, it should |
| 1308 // use a different factory, or we should have a different strategy here. | 1309 // use a different factory, or we should have a different strategy here. |
| 1309 view_change_weak_ptr_factory_.InvalidateWeakPtrs(); | 1310 view_change_weak_ptr_factory_.InvalidateWeakPtrs(); |
| 1310 SendDidChangeView(); | 1311 SendDidChangeView(); |
| 1311 } | 1312 } |
| 1312 | 1313 |
| 1313 void PluginInstance::SendDidChangeView() { | 1314 void PluginInstanceImpl::SendDidChangeView() { |
| 1314 // Don't send DidChangeView to crashed plugins. | 1315 // Don't send DidChangeView to crashed plugins. |
| 1315 if (module()->is_crashed()) | 1316 if (module()->is_crashed()) |
| 1316 return; | 1317 return; |
| 1317 | 1318 |
| 1318 if (view_change_weak_ptr_factory_.HasWeakPtrs() || | 1319 if (view_change_weak_ptr_factory_.HasWeakPtrs() || |
| 1319 (sent_initial_did_change_view_ && | 1320 (sent_initial_did_change_view_ && |
| 1320 last_sent_view_data_.Equals(view_data_))) | 1321 last_sent_view_data_.Equals(view_data_))) |
| 1321 return; // Nothing to update. | 1322 return; // Nothing to update. |
| 1322 | 1323 |
| 1323 const PP_Size& size = view_data_.rect.size; | 1324 const PP_Size& size = view_data_.rect.size; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1335 ScopedPPResource resource( | 1336 ScopedPPResource resource( |
| 1336 ScopedPPResource::PassRef(), | 1337 ScopedPPResource::PassRef(), |
| 1337 (new PPB_View_Shared(::ppapi::OBJECT_IS_IMPL, | 1338 (new PPB_View_Shared(::ppapi::OBJECT_IS_IMPL, |
| 1338 pp_instance(), view_data_))->GetReference()); | 1339 pp_instance(), view_data_))->GetReference()); |
| 1339 | 1340 |
| 1340 instance_interface_->DidChangeView(pp_instance(), resource, | 1341 instance_interface_->DidChangeView(pp_instance(), resource, |
| 1341 &view_data_.rect, | 1342 &view_data_.rect, |
| 1342 &view_data_.clip_rect); | 1343 &view_data_.clip_rect); |
| 1343 } | 1344 } |
| 1344 | 1345 |
| 1345 void PluginInstance::ReportGeometry() { | 1346 void PluginInstanceImpl::ReportGeometry() { |
| 1346 // If this call was delayed, we may have transitioned back to fullscreen in | 1347 // If this call was delayed, we may have transitioned back to fullscreen in |
| 1347 // the mean time, so only report the geometry if we are actually in normal | 1348 // the mean time, so only report the geometry if we are actually in normal |
| 1348 // mode. | 1349 // mode. |
| 1349 if (container_ && !fullscreen_container_ && !flash_fullscreen_) | 1350 if (container_ && !fullscreen_container_ && !flash_fullscreen_) |
| 1350 container_->reportGeometry(); | 1351 container_->reportGeometry(); |
| 1351 } | 1352 } |
| 1352 | 1353 |
| 1353 bool PluginInstance::GetPreferredPrintOutputFormat( | 1354 bool PluginInstanceImpl::GetPreferredPrintOutputFormat( |
| 1354 PP_PrintOutputFormat_Dev* format) { | 1355 PP_PrintOutputFormat_Dev* format) { |
| 1355 // Keep a reference on the stack. See NOTE above. | 1356 // Keep a reference on the stack. See NOTE above. |
| 1356 scoped_refptr<PluginInstance> ref(this); | 1357 scoped_refptr<PluginInstanceImpl> ref(this); |
| 1357 if (!LoadPrintInterface()) | 1358 if (!LoadPrintInterface()) |
| 1358 return false; | 1359 return false; |
| 1359 uint32_t supported_formats = | 1360 uint32_t supported_formats = |
| 1360 plugin_print_interface_->QuerySupportedFormats(pp_instance()); | 1361 plugin_print_interface_->QuerySupportedFormats(pp_instance()); |
| 1361 if (supported_formats & PP_PRINTOUTPUTFORMAT_PDF) { | 1362 if (supported_formats & PP_PRINTOUTPUTFORMAT_PDF) { |
| 1362 *format = PP_PRINTOUTPUTFORMAT_PDF; | 1363 *format = PP_PRINTOUTPUTFORMAT_PDF; |
| 1363 return true; | 1364 return true; |
| 1364 } | 1365 } |
| 1365 return false; | 1366 return false; |
| 1366 } | 1367 } |
| 1367 | 1368 |
| 1368 bool PluginInstance::SupportsPrintInterface() { | 1369 bool PluginInstanceImpl::SupportsPrintInterface() { |
| 1369 PP_PrintOutputFormat_Dev format; | 1370 PP_PrintOutputFormat_Dev format; |
| 1370 return GetPreferredPrintOutputFormat(&format); | 1371 return GetPreferredPrintOutputFormat(&format); |
| 1371 } | 1372 } |
| 1372 | 1373 |
| 1373 bool PluginInstance::IsPrintScalingDisabled() { | 1374 bool PluginInstanceImpl::IsPrintScalingDisabled() { |
| 1374 DCHECK(plugin_print_interface_); | 1375 DCHECK(plugin_print_interface_); |
| 1375 if (!plugin_print_interface_) | 1376 if (!plugin_print_interface_) |
| 1376 return false; | 1377 return false; |
| 1377 return plugin_print_interface_->IsScalingDisabled(pp_instance()) == PP_TRUE; | 1378 return plugin_print_interface_->IsScalingDisabled(pp_instance()) == PP_TRUE; |
| 1378 } | 1379 } |
| 1379 | 1380 |
| 1380 int PluginInstance::PrintBegin(const WebPrintParams& print_params) { | 1381 int PluginInstanceImpl::PrintBegin(const WebPrintParams& print_params) { |
| 1381 // Keep a reference on the stack. See NOTE above. | 1382 // Keep a reference on the stack. See NOTE above. |
| 1382 scoped_refptr<PluginInstance> ref(this); | 1383 scoped_refptr<PluginInstanceImpl> ref(this); |
| 1383 PP_PrintOutputFormat_Dev format; | 1384 PP_PrintOutputFormat_Dev format; |
| 1384 if (!GetPreferredPrintOutputFormat(&format)) { | 1385 if (!GetPreferredPrintOutputFormat(&format)) { |
| 1385 // PrintBegin should not have been called since SupportsPrintInterface | 1386 // PrintBegin should not have been called since SupportsPrintInterface |
| 1386 // would have returned false; | 1387 // would have returned false; |
| 1387 NOTREACHED(); | 1388 NOTREACHED(); |
| 1388 return 0; | 1389 return 0; |
| 1389 } | 1390 } |
| 1390 int num_pages = 0; | 1391 int num_pages = 0; |
| 1391 PP_PrintSettings_Dev print_settings; | 1392 PP_PrintSettings_Dev print_settings; |
| 1392 print_settings.printable_area = PP_FromGfxRect(print_params.printableArea); | 1393 print_settings.printable_area = PP_FromGfxRect(print_params.printableArea); |
| 1393 print_settings.content_area = PP_FromGfxRect(print_params.printContentArea); | 1394 print_settings.content_area = PP_FromGfxRect(print_params.printContentArea); |
| 1394 print_settings.paper_size = PP_FromGfxSize(print_params.paperSize); | 1395 print_settings.paper_size = PP_FromGfxSize(print_params.paperSize); |
| 1395 print_settings.dpi = print_params.printerDPI; | 1396 print_settings.dpi = print_params.printerDPI; |
| 1396 print_settings.orientation = PP_PRINTORIENTATION_NORMAL; | 1397 print_settings.orientation = PP_PRINTORIENTATION_NORMAL; |
| 1397 print_settings.grayscale = PP_FALSE; | 1398 print_settings.grayscale = PP_FALSE; |
| 1398 print_settings.print_scaling_option = static_cast<PP_PrintScalingOption_Dev>( | 1399 print_settings.print_scaling_option = static_cast<PP_PrintScalingOption_Dev>( |
| 1399 print_params.printScalingOption); | 1400 print_params.printScalingOption); |
| 1400 print_settings.format = format; | 1401 print_settings.format = format; |
| 1401 num_pages = plugin_print_interface_->Begin(pp_instance(), | 1402 num_pages = plugin_print_interface_->Begin(pp_instance(), |
| 1402 &print_settings); | 1403 &print_settings); |
| 1403 if (!num_pages) | 1404 if (!num_pages) |
| 1404 return 0; | 1405 return 0; |
| 1405 current_print_settings_ = print_settings; | 1406 current_print_settings_ = print_settings; |
| 1406 canvas_.clear(); | 1407 canvas_.clear(); |
| 1407 ranges_.clear(); | 1408 ranges_.clear(); |
| 1408 return num_pages; | 1409 return num_pages; |
| 1409 } | 1410 } |
| 1410 | 1411 |
| 1411 bool PluginInstance::PrintPage(int page_number, WebKit::WebCanvas* canvas) { | 1412 bool PluginInstanceImpl::PrintPage(int page_number, WebKit::WebCanvas* canvas) { |
| 1412 #if defined(ENABLE_PRINTING) | 1413 #if defined(ENABLE_PRINTING) |
| 1413 DCHECK(plugin_print_interface_); | 1414 DCHECK(plugin_print_interface_); |
| 1414 PP_PrintPageNumberRange_Dev page_range; | 1415 PP_PrintPageNumberRange_Dev page_range; |
| 1415 page_range.first_page_number = page_range.last_page_number = page_number; | 1416 page_range.first_page_number = page_range.last_page_number = page_number; |
| 1416 // The canvas only has a metafile on it for print preview. | 1417 // The canvas only has a metafile on it for print preview. |
| 1417 bool save_for_later = | 1418 bool save_for_later = |
| 1418 (printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas) != NULL); | 1419 (printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas) != NULL); |
| 1419 #if defined(OS_MACOSX) || defined(OS_WIN) | 1420 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 1420 save_for_later = save_for_later && skia::IsPreviewMetafile(*canvas); | 1421 save_for_later = save_for_later && skia::IsPreviewMetafile(*canvas); |
| 1421 #endif | 1422 #endif |
| 1422 if (save_for_later) { | 1423 if (save_for_later) { |
| 1423 ranges_.push_back(page_range); | 1424 ranges_.push_back(page_range); |
| 1424 canvas_ = skia::SharePtr(canvas); | 1425 canvas_ = skia::SharePtr(canvas); |
| 1425 return true; | 1426 return true; |
| 1426 } else { | 1427 } else { |
| 1427 return PrintPageHelper(&page_range, 1, canvas); | 1428 return PrintPageHelper(&page_range, 1, canvas); |
| 1428 } | 1429 } |
| 1429 #else // defined(ENABLED_PRINTING) | 1430 #else // defined(ENABLED_PRINTING) |
| 1430 return false; | 1431 return false; |
| 1431 #endif | 1432 #endif |
| 1432 } | 1433 } |
| 1433 | 1434 |
| 1434 bool PluginInstance::PrintPageHelper(PP_PrintPageNumberRange_Dev* page_ranges, | 1435 bool PluginInstanceImpl::PrintPageHelper( |
| 1435 int num_ranges, | 1436 PP_PrintPageNumberRange_Dev* page_ranges, |
| 1436 WebKit::WebCanvas* canvas) { | 1437 int num_ranges, |
| 1438 WebKit::WebCanvas* canvas) { |
| 1437 // Keep a reference on the stack. See NOTE above. | 1439 // Keep a reference on the stack. See NOTE above. |
| 1438 scoped_refptr<PluginInstance> ref(this); | 1440 scoped_refptr<PluginInstanceImpl> ref(this); |
| 1439 DCHECK(plugin_print_interface_); | 1441 DCHECK(plugin_print_interface_); |
| 1440 if (!plugin_print_interface_) | 1442 if (!plugin_print_interface_) |
| 1441 return false; | 1443 return false; |
| 1442 PP_Resource print_output = plugin_print_interface_->PrintPages( | 1444 PP_Resource print_output = plugin_print_interface_->PrintPages( |
| 1443 pp_instance(), page_ranges, num_ranges); | 1445 pp_instance(), page_ranges, num_ranges); |
| 1444 if (!print_output) | 1446 if (!print_output) |
| 1445 return false; | 1447 return false; |
| 1446 | 1448 |
| 1447 bool ret = false; | 1449 bool ret = false; |
| 1448 | 1450 |
| 1449 if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_PDF) | 1451 if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_PDF) |
| 1450 ret = PrintPDFOutput(print_output, canvas); | 1452 ret = PrintPDFOutput(print_output, canvas); |
| 1451 | 1453 |
| 1452 // Now we need to release the print output resource. | 1454 // Now we need to release the print output resource. |
| 1453 PluginModule::GetCore()->ReleaseResource(print_output); | 1455 PluginModule::GetCore()->ReleaseResource(print_output); |
| 1454 | 1456 |
| 1455 return ret; | 1457 return ret; |
| 1456 } | 1458 } |
| 1457 | 1459 |
| 1458 void PluginInstance::PrintEnd() { | 1460 void PluginInstanceImpl::PrintEnd() { |
| 1459 // Keep a reference on the stack. See NOTE above. | 1461 // Keep a reference on the stack. See NOTE above. |
| 1460 scoped_refptr<PluginInstance> ref(this); | 1462 scoped_refptr<PluginInstanceImpl> ref(this); |
| 1461 if (!ranges_.empty()) | 1463 if (!ranges_.empty()) |
| 1462 PrintPageHelper(&(ranges_.front()), ranges_.size(), canvas_.get()); | 1464 PrintPageHelper(&(ranges_.front()), ranges_.size(), canvas_.get()); |
| 1463 canvas_.clear(); | 1465 canvas_.clear(); |
| 1464 ranges_.clear(); | 1466 ranges_.clear(); |
| 1465 | 1467 |
| 1466 DCHECK(plugin_print_interface_); | 1468 DCHECK(plugin_print_interface_); |
| 1467 if (plugin_print_interface_) | 1469 if (plugin_print_interface_) |
| 1468 plugin_print_interface_->End(pp_instance()); | 1470 plugin_print_interface_->End(pp_instance()); |
| 1469 | 1471 |
| 1470 memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); | 1472 memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); |
| 1471 #if defined(OS_MACOSX) | 1473 #if defined(OS_MACOSX) |
| 1472 last_printed_page_ = NULL; | 1474 last_printed_page_ = NULL; |
| 1473 #endif // defined(OS_MACOSX) | 1475 #endif // defined(OS_MACOSX) |
| 1474 } | 1476 } |
| 1475 | 1477 |
| 1476 bool PluginInstance::CanRotateView() { | 1478 bool PluginInstanceImpl::CanRotateView() { |
| 1477 if (!LoadPdfInterface()) | 1479 if (!LoadPdfInterface()) |
| 1478 return false; | 1480 return false; |
| 1479 | 1481 |
| 1480 return true; | 1482 return true; |
| 1481 } | 1483 } |
| 1482 | 1484 |
| 1483 void PluginInstance::SetBoundGraphics2DForTest( | 1485 void PluginInstanceImpl::SetBoundGraphics2DForTest( |
| 1484 PluginDelegate::PlatformGraphics2D* graphics) { | 1486 PluginDelegate::PlatformGraphics2D* graphics) { |
| 1485 BindGraphics(pp_instance(), 0); // Unbind any old stuff. | 1487 BindGraphics(pp_instance(), 0); // Unbind any old stuff. |
| 1486 if (graphics) { | 1488 if (graphics) { |
| 1487 bound_graphics_2d_platform_ = graphics; | 1489 bound_graphics_2d_platform_ = graphics; |
| 1488 bound_graphics_2d_platform_->BindToInstance(this); | 1490 bound_graphics_2d_platform_->BindToInstance(this); |
| 1489 } | 1491 } |
| 1490 } | 1492 } |
| 1491 | 1493 |
| 1492 void PluginInstance::RotateView(WebPlugin::RotationType type) { | 1494 void PluginInstanceImpl::RotateView(WebPlugin::RotationType type) { |
| 1493 if (!LoadPdfInterface()) | 1495 if (!LoadPdfInterface()) |
| 1494 return; | 1496 return; |
| 1495 PP_PrivatePageTransformType transform_type = | 1497 PP_PrivatePageTransformType transform_type = |
| 1496 type == WebPlugin::RotationType90Clockwise ? | 1498 type == WebPlugin::RotationType90Clockwise ? |
| 1497 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW : | 1499 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW : |
| 1498 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW; | 1500 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW; |
| 1499 plugin_pdf_interface_->Transform(pp_instance(), transform_type); | 1501 plugin_pdf_interface_->Transform(pp_instance(), transform_type); |
| 1500 // NOTE: plugin instance may have been deleted. | 1502 // NOTE: plugin instance may have been deleted. |
| 1501 } | 1503 } |
| 1502 | 1504 |
| 1503 bool PluginInstance::FlashIsFullscreenOrPending() { | 1505 bool PluginInstanceImpl::FlashIsFullscreenOrPending() { |
| 1504 return fullscreen_container_ != NULL; | 1506 return fullscreen_container_ != NULL; |
| 1505 } | 1507 } |
| 1506 | 1508 |
| 1507 bool PluginInstance::IsFullscreenOrPending() { | 1509 bool PluginInstanceImpl::IsFullscreenOrPending() { |
| 1508 return desired_fullscreen_state_; | 1510 return desired_fullscreen_state_; |
| 1509 } | 1511 } |
| 1510 | 1512 |
| 1511 bool PluginInstance::SetFullscreen(bool fullscreen) { | 1513 bool PluginInstanceImpl::SetFullscreen(bool fullscreen) { |
| 1512 // Keep a reference on the stack. See NOTE above. | 1514 // Keep a reference on the stack. See NOTE above. |
| 1513 scoped_refptr<PluginInstance> ref(this); | 1515 scoped_refptr<PluginInstanceImpl> ref(this); |
| 1514 | 1516 |
| 1515 // Check whether we are trying to switch to the state we're already going | 1517 // Check whether we are trying to switch to the state we're already going |
| 1516 // to (i.e. if we're already switching to fullscreen but the fullscreen | 1518 // to (i.e. if we're already switching to fullscreen but the fullscreen |
| 1517 // container isn't ready yet, don't do anything more). | 1519 // container isn't ready yet, don't do anything more). |
| 1518 if (fullscreen == IsFullscreenOrPending()) | 1520 if (fullscreen == IsFullscreenOrPending()) |
| 1519 return false; | 1521 return false; |
| 1520 | 1522 |
| 1521 // Check whether we are trying to switch while the state is in transition. | 1523 // Check whether we are trying to switch while the state is in transition. |
| 1522 // The 2nd request gets dropped while messing up the internal state, so | 1524 // The 2nd request gets dropped while messing up the internal state, so |
| 1523 // disallow this. | 1525 // disallow this. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1537 // so we will tweak plugin's attributes to support the expected behavior. | 1539 // so we will tweak plugin's attributes to support the expected behavior. |
| 1538 KeepSizeAttributesBeforeFullscreen(); | 1540 KeepSizeAttributesBeforeFullscreen(); |
| 1539 SetSizeAttributesForFullscreen(); | 1541 SetSizeAttributesForFullscreen(); |
| 1540 container_->element().requestFullScreen(); | 1542 container_->element().requestFullScreen(); |
| 1541 } else { | 1543 } else { |
| 1542 container_->element().document().cancelFullScreen(); | 1544 container_->element().document().cancelFullScreen(); |
| 1543 } | 1545 } |
| 1544 return true; | 1546 return true; |
| 1545 } | 1547 } |
| 1546 | 1548 |
| 1547 void PluginInstance::FlashSetFullscreen(bool fullscreen, bool delay_report) { | 1549 void PluginInstanceImpl::UpdateFlashFullscreenState(bool flash_fullscreen) { |
| 1548 TRACE_EVENT0("ppapi", "PluginInstance::FlashSetFullscreen"); | |
| 1549 // Keep a reference on the stack. See NOTE above. | |
| 1550 scoped_refptr<PluginInstance> ref(this); | |
| 1551 | |
| 1552 // We check whether we are trying to switch to the state we're already going | |
| 1553 // to (i.e. if we're already switching to fullscreen but the fullscreen | |
| 1554 // container isn't ready yet, don't do anything more). | |
| 1555 if (fullscreen == FlashIsFullscreenOrPending()) | |
| 1556 return; | |
| 1557 | |
| 1558 // Unbind current 2D or 3D graphics context. | |
| 1559 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); | |
| 1560 if (fullscreen) { | |
| 1561 DCHECK(!fullscreen_container_); | |
| 1562 fullscreen_container_ = delegate_->CreateFullscreenContainer(this); | |
| 1563 UpdateLayer(); | |
| 1564 } else { | |
| 1565 DCHECK(fullscreen_container_); | |
| 1566 fullscreen_container_->Destroy(); | |
| 1567 fullscreen_container_ = NULL; | |
| 1568 UpdateFlashFullscreenState(false); | |
| 1569 if (!delay_report) { | |
| 1570 ReportGeometry(); | |
| 1571 } else { | |
| 1572 base::MessageLoop::current()->PostTask( | |
| 1573 FROM_HERE, base::Bind(&PluginInstance::ReportGeometry, this)); | |
| 1574 } | |
| 1575 } | |
| 1576 } | |
| 1577 | |
| 1578 void PluginInstance::UpdateFlashFullscreenState(bool flash_fullscreen) { | |
| 1579 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_); | 1550 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_); |
| 1580 | 1551 |
| 1581 if (flash_fullscreen == flash_fullscreen_) { | 1552 if (flash_fullscreen == flash_fullscreen_) { |
| 1582 // Manually clear callback when fullscreen fails with mouselock pending. | 1553 // Manually clear callback when fullscreen fails with mouselock pending. |
| 1583 if (!flash_fullscreen && is_mouselock_pending) | 1554 if (!flash_fullscreen && is_mouselock_pending) |
| 1584 lock_mouse_callback_->Run(PP_ERROR_FAILED); | 1555 lock_mouse_callback_->Run(PP_ERROR_FAILED); |
| 1585 return; | 1556 return; |
| 1586 } | 1557 } |
| 1587 | 1558 |
| 1588 PPB_Graphics3D_Impl* graphics_3d = bound_graphics_3d_.get(); | 1559 PPB_Graphics3D_Impl* graphics_3d = bound_graphics_3d_.get(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1602 WebScopedUserGesture user_gesture(CurrentUserGestureToken()); | 1573 WebScopedUserGesture user_gesture(CurrentUserGestureToken()); |
| 1603 if (!delegate()->LockMouse(this)) | 1574 if (!delegate()->LockMouse(this)) |
| 1604 lock_mouse_callback_->Run(PP_ERROR_FAILED); | 1575 lock_mouse_callback_->Run(PP_ERROR_FAILED); |
| 1605 } | 1576 } |
| 1606 } | 1577 } |
| 1607 | 1578 |
| 1608 if (PluginHasFocus() != old_plugin_focus) | 1579 if (PluginHasFocus() != old_plugin_focus) |
| 1609 SendFocusChangeNotification(); | 1580 SendFocusChangeNotification(); |
| 1610 } | 1581 } |
| 1611 | 1582 |
| 1612 int32_t PluginInstance::Navigate(const ::ppapi::URLRequestInfoData& request, | 1583 bool PluginInstanceImpl::IsViewAccelerated() { |
| 1613 const char* target, | |
| 1614 bool from_user_action) { | |
| 1615 if (!container_) | |
| 1616 return PP_ERROR_FAILED; | |
| 1617 | |
| 1618 WebDocument document = container_->element().document(); | |
| 1619 WebFrame* frame = document.frame(); | |
| 1620 if (!frame) | |
| 1621 return PP_ERROR_FAILED; | |
| 1622 | |
| 1623 ::ppapi::URLRequestInfoData completed_request = request; | |
| 1624 | |
| 1625 WebURLRequest web_request; | |
| 1626 if (!CreateWebURLRequest(&completed_request, frame, &web_request)) | |
| 1627 return PP_ERROR_FAILED; | |
| 1628 web_request.setFirstPartyForCookies(document.firstPartyForCookies()); | |
| 1629 web_request.setHasUserGesture(from_user_action); | |
| 1630 | |
| 1631 GURL gurl(web_request.url()); | |
| 1632 if (gurl.SchemeIs("javascript")) { | |
| 1633 // In imitation of the NPAPI implementation, only |target_frame == frame| is | |
| 1634 // allowed for security reasons. | |
| 1635 WebFrame* target_frame = | |
| 1636 frame->view()->findFrameByName(WebString::fromUTF8(target), frame); | |
| 1637 if (target_frame != frame) | |
| 1638 return PP_ERROR_NOACCESS; | |
| 1639 | |
| 1640 // TODO(viettrungluu): NPAPI sends the result back to the plugin -- do we | |
| 1641 // need that? | |
| 1642 WebString result = container_->executeScriptURL(gurl, from_user_action); | |
| 1643 return result.isNull() ? PP_ERROR_FAILED : PP_OK; | |
| 1644 } | |
| 1645 | |
| 1646 // Only GETs and POSTs are supported. | |
| 1647 if (web_request.httpMethod() != "GET" && | |
| 1648 web_request.httpMethod() != "POST") | |
| 1649 return PP_ERROR_BADARGUMENT; | |
| 1650 | |
| 1651 WebString target_str = WebString::fromUTF8(target); | |
| 1652 container_->loadFrameRequest(web_request, target_str, false, NULL); | |
| 1653 return PP_OK; | |
| 1654 } | |
| 1655 | |
| 1656 bool PluginInstance::IsRectTopmost(const gfx::Rect& rect) { | |
| 1657 if (flash_fullscreen_) | |
| 1658 return true; | |
| 1659 | |
| 1660 return container_->isRectTopmost(rect); | |
| 1661 } | |
| 1662 | |
| 1663 bool PluginInstance::IsViewAccelerated() { | |
| 1664 if (!container_) | 1584 if (!container_) |
| 1665 return false; | 1585 return false; |
| 1666 | 1586 |
| 1667 WebDocument document = container_->element().document(); | 1587 WebDocument document = container_->element().document(); |
| 1668 WebFrame* frame = document.frame(); | 1588 WebFrame* frame = document.frame(); |
| 1669 if (!frame) | 1589 if (!frame) |
| 1670 return false; | 1590 return false; |
| 1671 WebView* view = frame->view(); | 1591 WebView* view = frame->view(); |
| 1672 if (!view) | 1592 if (!view) |
| 1673 return false; | 1593 return false; |
| 1674 | 1594 |
| 1675 return view->isAcceleratedCompositingActive(); | 1595 return view->isAcceleratedCompositingActive(); |
| 1676 } | 1596 } |
| 1677 | 1597 |
| 1678 PluginDelegate::PlatformContext3D* PluginInstance::CreateContext3D() { | 1598 PluginDelegate::PlatformContext3D* PluginInstanceImpl::CreateContext3D() { |
| 1679 return delegate_->CreateContext3D(); | 1599 return delegate_->CreateContext3D(); |
| 1680 } | 1600 } |
| 1681 | 1601 |
| 1682 bool PluginInstance::PrintPDFOutput(PP_Resource print_output, | 1602 bool PluginInstanceImpl::PrintPDFOutput(PP_Resource print_output, |
| 1683 WebKit::WebCanvas* canvas) { | 1603 WebKit::WebCanvas* canvas) { |
| 1684 #if defined(ENABLE_PRINTING) | 1604 #if defined(ENABLE_PRINTING) |
| 1685 ::ppapi::thunk::EnterResourceNoLock<PPB_Buffer_API> enter(print_output, true); | 1605 ::ppapi::thunk::EnterResourceNoLock<PPB_Buffer_API> enter(print_output, true); |
| 1686 if (enter.failed()) | 1606 if (enter.failed()) |
| 1687 return false; | 1607 return false; |
| 1688 | 1608 |
| 1689 BufferAutoMapper mapper(enter.object()); | 1609 BufferAutoMapper mapper(enter.object()); |
| 1690 if (!mapper.data() || !mapper.size()) { | 1610 if (!mapper.data() || !mapper.size()) { |
| 1691 NOTREACHED(); | 1611 NOTREACHED(); |
| 1692 return false; | 1612 return false; |
| 1693 } | 1613 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1764 skia::EndPlatformPaint(canvas); | 1684 skia::EndPlatformPaint(canvas); |
| 1765 } | 1685 } |
| 1766 #endif // defined(OS_WIN) | 1686 #endif // defined(OS_WIN) |
| 1767 | 1687 |
| 1768 return ret; | 1688 return ret; |
| 1769 #else // defined(ENABLE_PRINTING) | 1689 #else // defined(ENABLE_PRINTING) |
| 1770 return false; | 1690 return false; |
| 1771 #endif | 1691 #endif |
| 1772 } | 1692 } |
| 1773 | 1693 |
| 1774 PluginDelegate::PlatformGraphics2D* PluginInstance::GetBoundGraphics2D() const { | 1694 PluginDelegate::PlatformGraphics2D* |
| 1695 PluginInstanceImpl::GetBoundGraphics2D() const { |
| 1775 return bound_graphics_2d_platform_; | 1696 return bound_graphics_2d_platform_; |
| 1776 } | 1697 } |
| 1777 | 1698 |
| 1778 static void IgnoreCallback(unsigned, bool) {} | 1699 static void IgnoreCallback(unsigned, bool) {} |
| 1779 | 1700 |
| 1780 void PluginInstance::UpdateLayer() { | 1701 void PluginInstanceImpl::UpdateLayer() { |
| 1781 if (!container_) | 1702 if (!container_) |
| 1782 return; | 1703 return; |
| 1783 | 1704 |
| 1784 gpu::Mailbox mailbox; | 1705 gpu::Mailbox mailbox; |
| 1785 if (bound_graphics_3d_.get()) { | 1706 if (bound_graphics_3d_.get()) { |
| 1786 PluginDelegate::PlatformContext3D* context = | 1707 PluginDelegate::PlatformContext3D* context = |
| 1787 bound_graphics_3d_->platform_context(); | 1708 bound_graphics_3d_->platform_context(); |
| 1788 context->GetBackingMailbox(&mailbox); | 1709 context->GetBackingMailbox(&mailbox); |
| 1789 } | 1710 } |
| 1790 bool want_layer = !mailbox.IsZero(); | 1711 bool want_layer = !mailbox.IsZero(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1814 } else { | 1735 } else { |
| 1815 container_->setWebLayer(web_layer_.get()); | 1736 container_->setWebLayer(web_layer_.get()); |
| 1816 texture_layer_->SetContentsOpaque(bound_graphics_3d_->IsOpaque()); | 1737 texture_layer_->SetContentsOpaque(bound_graphics_3d_->IsOpaque()); |
| 1817 } | 1738 } |
| 1818 texture_layer_->SetTextureMailbox( | 1739 texture_layer_->SetTextureMailbox( |
| 1819 cc::TextureMailbox(mailbox, base::Bind(&IgnoreCallback), 0)); | 1740 cc::TextureMailbox(mailbox, base::Bind(&IgnoreCallback), 0)); |
| 1820 } | 1741 } |
| 1821 layer_bound_to_fullscreen_ = !!fullscreen_container_; | 1742 layer_bound_to_fullscreen_ = !!fullscreen_container_; |
| 1822 } | 1743 } |
| 1823 | 1744 |
| 1824 void PluginInstance::AddPluginObject(PluginObject* plugin_object) { | 1745 void PluginInstanceImpl::AddPluginObject(PluginObject* plugin_object) { |
| 1825 DCHECK(live_plugin_objects_.find(plugin_object) == | 1746 DCHECK(live_plugin_objects_.find(plugin_object) == |
| 1826 live_plugin_objects_.end()); | 1747 live_plugin_objects_.end()); |
| 1827 live_plugin_objects_.insert(plugin_object); | 1748 live_plugin_objects_.insert(plugin_object); |
| 1828 } | 1749 } |
| 1829 | 1750 |
| 1830 void PluginInstance::RemovePluginObject(PluginObject* plugin_object) { | 1751 void PluginInstanceImpl::RemovePluginObject(PluginObject* plugin_object) { |
| 1831 // Don't actually verify that the object is in the set since during module | 1752 // Don't actually verify that the object is in the set since during module |
| 1832 // deletion we'll be in the process of freeing them. | 1753 // deletion we'll be in the process of freeing them. |
| 1833 live_plugin_objects_.erase(plugin_object); | 1754 live_plugin_objects_.erase(plugin_object); |
| 1834 } | 1755 } |
| 1835 | 1756 |
| 1836 bool PluginInstance::IsFullPagePlugin() const { | 1757 bool PluginInstanceImpl::IsProcessingUserGesture() { |
| 1837 WebFrame* frame = container()->element().document().frame(); | |
| 1838 return frame->view()->mainFrame()->document().isPluginDocument(); | |
| 1839 } | |
| 1840 | |
| 1841 bool PluginInstance::IsProcessingUserGesture() { | |
| 1842 PP_TimeTicks now = | 1758 PP_TimeTicks now = |
| 1843 ::ppapi::TimeTicksToPPTimeTicks(base::TimeTicks::Now()); | 1759 ::ppapi::TimeTicksToPPTimeTicks(base::TimeTicks::Now()); |
| 1844 // Give a lot of slack so tests won't be flaky. | 1760 // Give a lot of slack so tests won't be flaky. |
| 1845 const PP_TimeTicks kUserGestureDurationInSeconds = 10.0; | 1761 const PP_TimeTicks kUserGestureDurationInSeconds = 10.0; |
| 1846 return pending_user_gesture_token_.hasGestures() && | 1762 return pending_user_gesture_token_.hasGestures() && |
| 1847 (now - pending_user_gesture_ < kUserGestureDurationInSeconds); | 1763 (now - pending_user_gesture_ < kUserGestureDurationInSeconds); |
| 1848 } | 1764 } |
| 1849 | 1765 |
| 1850 WebUserGestureToken PluginInstance::CurrentUserGestureToken() { | 1766 WebUserGestureToken PluginInstanceImpl::CurrentUserGestureToken() { |
| 1851 if (!IsProcessingUserGesture()) | 1767 if (!IsProcessingUserGesture()) |
| 1852 pending_user_gesture_token_ = WebUserGestureToken(); | 1768 pending_user_gesture_token_ = WebUserGestureToken(); |
| 1853 return pending_user_gesture_token_; | 1769 return pending_user_gesture_token_; |
| 1854 } | 1770 } |
| 1855 | 1771 |
| 1856 void PluginInstance::OnLockMouseACK(bool succeeded) { | 1772 void PluginInstanceImpl::OnLockMouseACK(bool succeeded) { |
| 1857 if (TrackedCallback::IsPending(lock_mouse_callback_)) | 1773 if (TrackedCallback::IsPending(lock_mouse_callback_)) |
| 1858 lock_mouse_callback_->Run(succeeded ? PP_OK : PP_ERROR_FAILED); | 1774 lock_mouse_callback_->Run(succeeded ? PP_OK : PP_ERROR_FAILED); |
| 1859 } | 1775 } |
| 1860 | 1776 |
| 1861 void PluginInstance::OnMouseLockLost() { | 1777 void PluginInstanceImpl::OnMouseLockLost() { |
| 1862 if (LoadMouseLockInterface()) | 1778 if (LoadMouseLockInterface()) |
| 1863 plugin_mouse_lock_interface_->MouseLockLost(pp_instance()); | 1779 plugin_mouse_lock_interface_->MouseLockLost(pp_instance()); |
| 1864 } | 1780 } |
| 1865 | 1781 |
| 1866 void PluginInstance::HandleMouseLockedInputEvent( | 1782 void PluginInstanceImpl::HandleMouseLockedInputEvent( |
| 1867 const WebKit::WebMouseEvent& event) { | 1783 const WebKit::WebMouseEvent& event) { |
| 1868 // |cursor_info| is ignored since it is hidden when the mouse is locked. | 1784 // |cursor_info| is ignored since it is hidden when the mouse is locked. |
| 1869 WebKit::WebCursorInfo cursor_info; | 1785 WebKit::WebCursorInfo cursor_info; |
| 1870 HandleInputEvent(event, &cursor_info); | 1786 HandleInputEvent(event, &cursor_info); |
| 1871 } | 1787 } |
| 1872 | 1788 |
| 1873 void PluginInstance::SimulateInputEvent(const InputEventData& input_event) { | 1789 void PluginInstanceImpl::SimulateInputEvent(const InputEventData& input_event) { |
| 1874 WebView* web_view = container()->element().document().frame()->view(); | 1790 WebView* web_view = container()->element().document().frame()->view(); |
| 1875 if (!web_view) { | 1791 if (!web_view) { |
| 1876 NOTREACHED(); | 1792 NOTREACHED(); |
| 1877 return; | 1793 return; |
| 1878 } | 1794 } |
| 1879 | 1795 |
| 1880 bool handled = SimulateIMEEvent(input_event); | 1796 bool handled = SimulateIMEEvent(input_event); |
| 1881 if (handled) | 1797 if (handled) |
| 1882 return; | 1798 return; |
| 1883 | 1799 |
| 1884 std::vector<linked_ptr<WebInputEvent> > events = | 1800 std::vector<linked_ptr<WebInputEvent> > events = |
| 1885 CreateSimulatedWebInputEvents( | 1801 CreateSimulatedWebInputEvents( |
| 1886 input_event, | 1802 input_event, |
| 1887 view_data_.rect.point.x + view_data_.rect.size.width / 2, | 1803 view_data_.rect.point.x + view_data_.rect.size.width / 2, |
| 1888 view_data_.rect.point.y + view_data_.rect.size.height / 2); | 1804 view_data_.rect.point.y + view_data_.rect.size.height / 2); |
| 1889 for (std::vector<linked_ptr<WebInputEvent> >::iterator it = events.begin(); | 1805 for (std::vector<linked_ptr<WebInputEvent> >::iterator it = events.begin(); |
| 1890 it != events.end(); ++it) { | 1806 it != events.end(); ++it) { |
| 1891 web_view->handleInputEvent(*it->get()); | 1807 web_view->handleInputEvent(*it->get()); |
| 1892 } | 1808 } |
| 1893 } | 1809 } |
| 1894 | 1810 |
| 1895 bool PluginInstance::SimulateIMEEvent(const InputEventData& input_event) { | 1811 bool PluginInstanceImpl::SimulateIMEEvent(const InputEventData& input_event) { |
| 1896 switch (input_event.event_type) { | 1812 switch (input_event.event_type) { |
| 1897 case PP_INPUTEVENT_TYPE_IME_COMPOSITION_START: | 1813 case PP_INPUTEVENT_TYPE_IME_COMPOSITION_START: |
| 1898 case PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE: | 1814 case PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE: |
| 1899 SimulateImeSetCompositionEvent(input_event); | 1815 SimulateImeSetCompositionEvent(input_event); |
| 1900 break; | 1816 break; |
| 1901 case PP_INPUTEVENT_TYPE_IME_COMPOSITION_END: | 1817 case PP_INPUTEVENT_TYPE_IME_COMPOSITION_END: |
| 1902 DCHECK(input_event.character_text.empty()); | 1818 DCHECK(input_event.character_text.empty()); |
| 1903 SimulateImeSetCompositionEvent(input_event); | 1819 SimulateImeSetCompositionEvent(input_event); |
| 1904 break; | 1820 break; |
| 1905 case PP_INPUTEVENT_TYPE_IME_TEXT: | 1821 case PP_INPUTEVENT_TYPE_IME_TEXT: |
| 1906 delegate()->SimulateImeConfirmComposition( | 1822 delegate()->SimulateImeConfirmComposition( |
| 1907 UTF8ToUTF16(input_event.character_text)); | 1823 UTF8ToUTF16(input_event.character_text)); |
| 1908 break; | 1824 break; |
| 1909 default: | 1825 default: |
| 1910 return false; | 1826 return false; |
| 1911 } | 1827 } |
| 1912 return true; | 1828 return true; |
| 1913 } | 1829 } |
| 1914 | 1830 |
| 1915 void PluginInstance::SimulateImeSetCompositionEvent( | 1831 void PluginInstanceImpl::SimulateImeSetCompositionEvent( |
| 1916 const InputEventData& input_event) { | 1832 const InputEventData& input_event) { |
| 1917 std::vector<size_t> offsets; | 1833 std::vector<size_t> offsets; |
| 1918 offsets.push_back(input_event.composition_selection_start); | 1834 offsets.push_back(input_event.composition_selection_start); |
| 1919 offsets.push_back(input_event.composition_selection_end); | 1835 offsets.push_back(input_event.composition_selection_end); |
| 1920 offsets.insert(offsets.end(), | 1836 offsets.insert(offsets.end(), |
| 1921 input_event.composition_segment_offsets.begin(), | 1837 input_event.composition_segment_offsets.begin(), |
| 1922 input_event.composition_segment_offsets.end()); | 1838 input_event.composition_segment_offsets.end()); |
| 1923 | 1839 |
| 1924 base::string16 utf16_text = | 1840 base::string16 utf16_text = |
| 1925 base::UTF8ToUTF16AndAdjustOffsets(input_event.character_text, &offsets); | 1841 base::UTF8ToUTF16AndAdjustOffsets(input_event.character_text, &offsets); |
| 1926 | 1842 |
| 1927 std::vector<WebKit::WebCompositionUnderline> underlines; | 1843 std::vector<WebKit::WebCompositionUnderline> underlines; |
| 1928 for (size_t i = 2; i + 1 < offsets.size(); ++i) { | 1844 for (size_t i = 2; i + 1 < offsets.size(); ++i) { |
| 1929 WebKit::WebCompositionUnderline underline; | 1845 WebKit::WebCompositionUnderline underline; |
| 1930 underline.startOffset = offsets[i]; | 1846 underline.startOffset = offsets[i]; |
| 1931 underline.endOffset = offsets[i + 1]; | 1847 underline.endOffset = offsets[i + 1]; |
| 1932 if (input_event.composition_target_segment == static_cast<int32_t>(i - 2)) | 1848 if (input_event.composition_target_segment == static_cast<int32_t>(i - 2)) |
| 1933 underline.thick = true; | 1849 underline.thick = true; |
| 1934 underlines.push_back(underline); | 1850 underlines.push_back(underline); |
| 1935 } | 1851 } |
| 1936 | 1852 |
| 1937 delegate()->SimulateImeSetComposition( | 1853 delegate()->SimulateImeSetComposition( |
| 1938 utf16_text, underlines, offsets[0], offsets[1]); | 1854 utf16_text, underlines, offsets[0], offsets[1]); |
| 1939 } | 1855 } |
| 1940 | 1856 |
| 1941 ContentDecryptorDelegate* PluginInstance::GetContentDecryptorDelegate() { | 1857 ContentDecryptorDelegate* PluginInstanceImpl::GetContentDecryptorDelegate() { |
| 1942 if (content_decryptor_delegate_) | 1858 if (content_decryptor_delegate_) |
| 1943 return content_decryptor_delegate_.get(); | 1859 return content_decryptor_delegate_.get(); |
| 1944 | 1860 |
| 1945 const PPP_ContentDecryptor_Private* plugin_decryption_interface = | 1861 const PPP_ContentDecryptor_Private* plugin_decryption_interface = |
| 1946 static_cast<const PPP_ContentDecryptor_Private*>( | 1862 static_cast<const PPP_ContentDecryptor_Private*>( |
| 1947 module_->GetPluginInterface( | 1863 module_->GetPluginInterface( |
| 1948 PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE)); | 1864 PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE)); |
| 1949 if (!plugin_decryption_interface) | 1865 if (!plugin_decryption_interface) |
| 1950 return NULL; | 1866 return NULL; |
| 1951 | 1867 |
| 1952 content_decryptor_delegate_.reset( | 1868 content_decryptor_delegate_.reset( |
| 1953 new ContentDecryptorDelegate(pp_instance_, plugin_decryption_interface)); | 1869 new ContentDecryptorDelegate(pp_instance_, plugin_decryption_interface)); |
| 1954 return content_decryptor_delegate_.get(); | 1870 return content_decryptor_delegate_.get(); |
| 1955 } | 1871 } |
| 1956 | 1872 |
| 1957 PP_Bool PluginInstance::BindGraphics(PP_Instance instance, | 1873 PP_Bool PluginInstanceImpl::BindGraphics(PP_Instance instance, |
| 1958 PP_Resource device) { | 1874 PP_Resource device) { |
| 1959 TRACE_EVENT0("ppapi", "PluginInstance::BindGraphics"); | 1875 TRACE_EVENT0("ppapi", "PluginInstanceImpl::BindGraphics"); |
| 1960 // The Graphics3D instance can't be destroyed until we call | 1876 // The Graphics3D instance can't be destroyed until we call |
| 1961 // UpdateLayer(). | 1877 // UpdateLayer(). |
| 1962 scoped_refptr< ::ppapi::Resource> old_graphics = bound_graphics_3d_.get(); | 1878 scoped_refptr< ::ppapi::Resource> old_graphics = bound_graphics_3d_.get(); |
| 1963 if (bound_graphics_3d_.get()) { | 1879 if (bound_graphics_3d_.get()) { |
| 1964 bound_graphics_3d_->BindToInstance(false); | 1880 bound_graphics_3d_->BindToInstance(false); |
| 1965 bound_graphics_3d_ = NULL; | 1881 bound_graphics_3d_ = NULL; |
| 1966 } | 1882 } |
| 1967 if (bound_graphics_2d_platform_) { | 1883 if (bound_graphics_2d_platform_) { |
| 1968 GetBoundGraphics2D()->BindToInstance(NULL); | 1884 GetBoundGraphics2D()->BindToInstance(NULL); |
| 1969 bound_graphics_2d_platform_ = NULL; | 1885 bound_graphics_2d_platform_ = NULL; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2002 bound_graphics_3d_ = graphics_3d; | 1918 bound_graphics_3d_ = graphics_3d; |
| 2003 UpdateLayer(); | 1919 UpdateLayer(); |
| 2004 return PP_TRUE; | 1920 return PP_TRUE; |
| 2005 } | 1921 } |
| 2006 } | 1922 } |
| 2007 | 1923 |
| 2008 // The instance cannot be bound or the device is not a valid resource type. | 1924 // The instance cannot be bound or the device is not a valid resource type. |
| 2009 return PP_FALSE; | 1925 return PP_FALSE; |
| 2010 } | 1926 } |
| 2011 | 1927 |
| 2012 PP_Bool PluginInstance::IsFullFrame(PP_Instance instance) { | 1928 PP_Bool PluginInstanceImpl::IsFullFrame(PP_Instance instance) { |
| 2013 return PP_FromBool(full_frame()); | 1929 return PP_FromBool(full_frame()); |
| 2014 } | 1930 } |
| 2015 | 1931 |
| 2016 const ViewData* PluginInstance::GetViewData(PP_Instance instance) { | 1932 const ViewData* PluginInstanceImpl::GetViewData(PP_Instance instance) { |
| 2017 return &view_data_; | 1933 return &view_data_; |
| 2018 } | 1934 } |
| 2019 | 1935 |
| 2020 PP_Bool PluginInstance::FlashIsFullscreen(PP_Instance instance) { | 1936 PP_Bool PluginInstanceImpl::FlashIsFullscreen(PP_Instance instance) { |
| 2021 return PP_FromBool(flash_fullscreen_); | 1937 return PP_FromBool(flash_fullscreen_); |
| 2022 } | 1938 } |
| 2023 | 1939 |
| 2024 PP_Var PluginInstance::GetWindowObject(PP_Instance instance) { | 1940 PP_Var PluginInstanceImpl::GetWindowObject(PP_Instance instance) { |
| 2025 if (!container_) | 1941 if (!container_) |
| 2026 return PP_MakeUndefined(); | 1942 return PP_MakeUndefined(); |
| 2027 | 1943 |
| 2028 WebFrame* frame = container_->element().document().frame(); | 1944 WebFrame* frame = container_->element().document().frame(); |
| 2029 if (!frame) | 1945 if (!frame) |
| 2030 return PP_MakeUndefined(); | 1946 return PP_MakeUndefined(); |
| 2031 | 1947 |
| 2032 return NPObjectToPPVar(this, frame->windowObject()); | 1948 return NPObjectToPPVar(this, frame->windowObject()); |
| 2033 } | 1949 } |
| 2034 | 1950 |
| 2035 PP_Var PluginInstance::GetOwnerElementObject(PP_Instance instance) { | 1951 PP_Var PluginInstanceImpl::GetOwnerElementObject(PP_Instance instance) { |
| 2036 if (!container_) | 1952 if (!container_) |
| 2037 return PP_MakeUndefined(); | 1953 return PP_MakeUndefined(); |
| 2038 return NPObjectToPPVar(this, container_->scriptableObjectForElement()); | 1954 return NPObjectToPPVar(this, container_->scriptableObjectForElement()); |
| 2039 } | 1955 } |
| 2040 | 1956 |
| 2041 PP_Var PluginInstance::ExecuteScript(PP_Instance instance, | 1957 PP_Var PluginInstanceImpl::ExecuteScript(PP_Instance instance, |
| 2042 PP_Var script, | 1958 PP_Var script, |
| 2043 PP_Var* exception) { | 1959 PP_Var* exception) { |
| 2044 // Executing the script may remove the plugin from the DOM, so we need to keep | 1960 // Executing the script may remove the plugin from the DOM, so we need to keep |
| 2045 // a reference to ourselves so that we can still process the result after the | 1961 // a reference to ourselves so that we can still process the result after the |
| 2046 // WebBindings::evaluate() below. | 1962 // WebBindings::evaluate() below. |
| 2047 scoped_refptr<PluginInstance> ref(this); | 1963 scoped_refptr<PluginInstanceImpl> ref(this); |
| 2048 TryCatch try_catch(exception); | 1964 TryCatch try_catch(exception); |
| 2049 if (try_catch.has_exception()) | 1965 if (try_catch.has_exception()) |
| 2050 return PP_MakeUndefined(); | 1966 return PP_MakeUndefined(); |
| 2051 | 1967 |
| 2052 // Convert the script into an inconvenient NPString object. | 1968 // Convert the script into an inconvenient NPString object. |
| 2053 StringVar* script_string = StringVar::FromPPVar(script); | 1969 StringVar* script_string = StringVar::FromPPVar(script); |
| 2054 if (!script_string) { | 1970 if (!script_string) { |
| 2055 try_catch.SetException("Script param to ExecuteScript must be a string."); | 1971 try_catch.SetException("Script param to ExecuteScript must be a string."); |
| 2056 return PP_MakeUndefined(); | 1972 return PP_MakeUndefined(); |
| 2057 } | 1973 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2082 try_catch.SetException("Exception caught"); | 1998 try_catch.SetException("Exception caught"); |
| 2083 WebBindings::releaseVariantValue(&result); | 1999 WebBindings::releaseVariantValue(&result); |
| 2084 return PP_MakeUndefined(); | 2000 return PP_MakeUndefined(); |
| 2085 } | 2001 } |
| 2086 | 2002 |
| 2087 PP_Var ret = NPVariantToPPVar(this, &result); | 2003 PP_Var ret = NPVariantToPPVar(this, &result); |
| 2088 WebBindings::releaseVariantValue(&result); | 2004 WebBindings::releaseVariantValue(&result); |
| 2089 return ret; | 2005 return ret; |
| 2090 } | 2006 } |
| 2091 | 2007 |
| 2092 uint32_t PluginInstance::GetAudioHardwareOutputSampleRate( | 2008 uint32_t PluginInstanceImpl::GetAudioHardwareOutputSampleRate( |
| 2093 PP_Instance instance) { | 2009 PP_Instance instance) { |
| 2094 return delegate()->GetAudioHardwareOutputSampleRate(); | 2010 return delegate()->GetAudioHardwareOutputSampleRate(); |
| 2095 } | 2011 } |
| 2096 | 2012 |
| 2097 uint32_t PluginInstance::GetAudioHardwareOutputBufferSize( | 2013 uint32_t PluginInstanceImpl::GetAudioHardwareOutputBufferSize( |
| 2098 PP_Instance instance) { | 2014 PP_Instance instance) { |
| 2099 return delegate()->GetAudioHardwareOutputBufferSize(); | 2015 return delegate()->GetAudioHardwareOutputBufferSize(); |
| 2100 } | 2016 } |
| 2101 | 2017 |
| 2102 PP_Var PluginInstance::GetDefaultCharSet(PP_Instance instance) { | 2018 PP_Var PluginInstanceImpl::GetDefaultCharSet(PP_Instance instance) { |
| 2103 std::string encoding = delegate()->GetDefaultEncoding(); | 2019 std::string encoding = delegate()->GetDefaultEncoding(); |
| 2104 return StringVar::StringToPPVar(encoding); | 2020 return StringVar::StringToPPVar(encoding); |
| 2105 } | 2021 } |
| 2106 | 2022 |
| 2107 // These PPB_ContentDecryptor_Private calls are responses to | 2023 // These PPB_ContentDecryptor_Private calls are responses to |
| 2108 // PPP_ContentDecryptor_Private calls made on |content_decryptor_delegate_|. | 2024 // PPP_ContentDecryptor_Private calls made on |content_decryptor_delegate_|. |
| 2109 // Therefore, |content_decryptor_delegate_| must have been initialized when | 2025 // Therefore, |content_decryptor_delegate_| must have been initialized when |
| 2110 // the following methods are called. | 2026 // the following methods are called. |
| 2111 void PluginInstance::NeedKey(PP_Instance instance, | 2027 void PluginInstanceImpl::NeedKey(PP_Instance instance, |
| 2112 PP_Var key_system_var, | 2028 PP_Var key_system_var, |
| 2113 PP_Var session_id_var, | 2029 PP_Var session_id_var, |
| 2114 PP_Var init_data_var) { | 2030 PP_Var init_data_var) { |
| 2115 content_decryptor_delegate_->NeedKey( | 2031 content_decryptor_delegate_->NeedKey( |
| 2116 key_system_var, session_id_var, init_data_var); | 2032 key_system_var, session_id_var, init_data_var); |
| 2117 } | 2033 } |
| 2118 | 2034 |
| 2119 void PluginInstance::KeyAdded(PP_Instance instance, | 2035 void PluginInstanceImpl::KeyAdded(PP_Instance instance, |
| 2120 PP_Var key_system_var, | 2036 PP_Var key_system_var, |
| 2121 PP_Var session_id_var) { | 2037 PP_Var session_id_var) { |
| 2122 content_decryptor_delegate_->KeyAdded(key_system_var, session_id_var); | 2038 content_decryptor_delegate_->KeyAdded(key_system_var, session_id_var); |
| 2123 } | 2039 } |
| 2124 | 2040 |
| 2125 void PluginInstance::KeyMessage(PP_Instance instance, | 2041 void PluginInstanceImpl::KeyMessage(PP_Instance instance, |
| 2126 PP_Var key_system_var, | 2042 PP_Var key_system_var, |
| 2127 PP_Var session_id_var, | 2043 PP_Var session_id_var, |
| 2128 PP_Var message_var, | 2044 PP_Var message_var, |
| 2129 PP_Var default_url_var) { | 2045 PP_Var default_url_var) { |
| 2130 content_decryptor_delegate_->KeyMessage( | 2046 content_decryptor_delegate_->KeyMessage( |
| 2131 key_system_var, session_id_var, message_var, default_url_var); | 2047 key_system_var, session_id_var, message_var, default_url_var); |
| 2132 } | 2048 } |
| 2133 | 2049 |
| 2134 void PluginInstance::KeyError(PP_Instance instance, | 2050 void PluginInstanceImpl::KeyError(PP_Instance instance, |
| 2135 PP_Var key_system_var, | 2051 PP_Var key_system_var, |
| 2136 PP_Var session_id_var, | 2052 PP_Var session_id_var, |
| 2137 int32_t media_error, | 2053 int32_t media_error, |
| 2138 int32_t system_code) { | 2054 int32_t system_code) { |
| 2139 content_decryptor_delegate_->KeyError( | 2055 content_decryptor_delegate_->KeyError( |
| 2140 key_system_var, session_id_var, media_error, system_code); | 2056 key_system_var, session_id_var, media_error, system_code); |
| 2141 } | 2057 } |
| 2142 | 2058 |
| 2143 void PluginInstance::DeliverBlock(PP_Instance instance, | 2059 void PluginInstanceImpl::DeliverBlock(PP_Instance instance, |
| 2144 PP_Resource decrypted_block, | 2060 PP_Resource decrypted_block, |
| 2145 const PP_DecryptedBlockInfo* block_info) { | 2061 const PP_DecryptedBlockInfo* block_info) { |
| 2146 content_decryptor_delegate_->DeliverBlock(decrypted_block, block_info); | 2062 content_decryptor_delegate_->DeliverBlock(decrypted_block, block_info); |
| 2147 } | 2063 } |
| 2148 | 2064 |
| 2149 void PluginInstance::DecoderInitializeDone(PP_Instance instance, | 2065 void PluginInstanceImpl::DecoderInitializeDone( |
| 2150 PP_DecryptorStreamType decoder_type, | 2066 PP_Instance instance, |
| 2151 uint32_t request_id, | 2067 PP_DecryptorStreamType decoder_type, |
| 2152 PP_Bool success) { | 2068 uint32_t request_id, |
| 2069 PP_Bool success) { |
| 2153 content_decryptor_delegate_->DecoderInitializeDone( | 2070 content_decryptor_delegate_->DecoderInitializeDone( |
| 2154 decoder_type, request_id, success); | 2071 decoder_type, request_id, success); |
| 2155 } | 2072 } |
| 2156 | 2073 |
| 2157 void PluginInstance::DecoderDeinitializeDone( | 2074 void PluginInstanceImpl::DecoderDeinitializeDone( |
| 2158 PP_Instance instance, | 2075 PP_Instance instance, |
| 2159 PP_DecryptorStreamType decoder_type, | 2076 PP_DecryptorStreamType decoder_type, |
| 2160 uint32_t request_id) { | 2077 uint32_t request_id) { |
| 2161 content_decryptor_delegate_->DecoderDeinitializeDone(decoder_type, | 2078 content_decryptor_delegate_->DecoderDeinitializeDone(decoder_type, |
| 2162 request_id); | 2079 request_id); |
| 2163 } | 2080 } |
| 2164 | 2081 |
| 2165 void PluginInstance::DecoderResetDone(PP_Instance instance, | 2082 void PluginInstanceImpl::DecoderResetDone(PP_Instance instance, |
| 2166 PP_DecryptorStreamType decoder_type, | 2083 PP_DecryptorStreamType decoder_type, |
| 2167 uint32_t request_id) { | 2084 uint32_t request_id) { |
| 2168 content_decryptor_delegate_->DecoderResetDone(decoder_type, request_id); | 2085 content_decryptor_delegate_->DecoderResetDone(decoder_type, request_id); |
| 2169 } | 2086 } |
| 2170 | 2087 |
| 2171 | 2088 |
| 2172 void PluginInstance::DeliverFrame(PP_Instance instance, | 2089 void PluginInstanceImpl::DeliverFrame(PP_Instance instance, |
| 2173 PP_Resource decrypted_frame, | 2090 PP_Resource decrypted_frame, |
| 2174 const PP_DecryptedFrameInfo* frame_info) { | 2091 const PP_DecryptedFrameInfo* frame_info) { |
| 2175 content_decryptor_delegate_->DeliverFrame(decrypted_frame, frame_info); | 2092 content_decryptor_delegate_->DeliverFrame(decrypted_frame, frame_info); |
| 2176 } | 2093 } |
| 2177 | 2094 |
| 2178 void PluginInstance::DeliverSamples(PP_Instance instance, | 2095 void PluginInstanceImpl::DeliverSamples( |
| 2179 PP_Resource audio_frames, | 2096 PP_Instance instance, |
| 2180 const PP_DecryptedBlockInfo* block_info) { | 2097 PP_Resource audio_frames, |
| 2098 const PP_DecryptedBlockInfo* block_info) { |
| 2181 content_decryptor_delegate_->DeliverSamples(audio_frames, block_info); | 2099 content_decryptor_delegate_->DeliverSamples(audio_frames, block_info); |
| 2182 } | 2100 } |
| 2183 | 2101 |
| 2184 void PluginInstance::NumberOfFindResultsChanged(PP_Instance instance, | 2102 void PluginInstanceImpl::NumberOfFindResultsChanged(PP_Instance instance, |
| 2185 int32_t total, | 2103 int32_t total, |
| 2186 PP_Bool final_result) { | 2104 PP_Bool final_result) { |
| 2187 DCHECK_NE(find_identifier_, -1); | 2105 DCHECK_NE(find_identifier_, -1); |
| 2188 delegate_->NumberOfFindResultsChanged(find_identifier_, total, | 2106 delegate_->NumberOfFindResultsChanged(find_identifier_, total, |
| 2189 PP_ToBool(final_result)); | 2107 PP_ToBool(final_result)); |
| 2190 } | 2108 } |
| 2191 | 2109 |
| 2192 void PluginInstance::SelectedFindResultChanged(PP_Instance instance, | 2110 void PluginInstanceImpl::SelectedFindResultChanged(PP_Instance instance, |
| 2193 int32_t index) { | 2111 int32_t index) { |
| 2194 DCHECK_NE(find_identifier_, -1); | 2112 DCHECK_NE(find_identifier_, -1); |
| 2195 delegate_->SelectedFindResultChanged(find_identifier_, index); | 2113 delegate_->SelectedFindResultChanged(find_identifier_, index); |
| 2196 } | 2114 } |
| 2197 | 2115 |
| 2198 PP_Bool PluginInstance::IsFullscreen(PP_Instance instance) { | 2116 PP_Bool PluginInstanceImpl::IsFullscreen(PP_Instance instance) { |
| 2199 return PP_FromBool(view_data_.is_fullscreen); | 2117 return PP_FromBool(view_data_.is_fullscreen); |
| 2200 } | 2118 } |
| 2201 | 2119 |
| 2202 PP_Bool PluginInstance::SetFullscreen(PP_Instance instance, | 2120 PP_Bool PluginInstanceImpl::SetFullscreen(PP_Instance instance, |
| 2203 PP_Bool fullscreen) { | 2121 PP_Bool fullscreen) { |
| 2204 return PP_FromBool(SetFullscreen(PP_ToBool(fullscreen))); | 2122 return PP_FromBool(SetFullscreen(PP_ToBool(fullscreen))); |
| 2205 } | 2123 } |
| 2206 | 2124 |
| 2207 PP_Bool PluginInstance::GetScreenSize(PP_Instance instance, PP_Size* size) { | 2125 PP_Bool PluginInstanceImpl::GetScreenSize(PP_Instance instance, PP_Size* size) { |
| 2208 gfx::Size screen_size = delegate()->GetScreenSize(); | 2126 gfx::Size screen_size = delegate()->GetScreenSize(); |
| 2209 *size = PP_MakeSize(screen_size.width(), screen_size.height()); | 2127 *size = PP_MakeSize(screen_size.width(), screen_size.height()); |
| 2210 return PP_TRUE; | 2128 return PP_TRUE; |
| 2211 } | 2129 } |
| 2212 | 2130 |
| 2213 ::ppapi::Resource* PluginInstance::GetSingletonResource( | 2131 ::ppapi::Resource* PluginInstanceImpl::GetSingletonResource( |
| 2214 PP_Instance instance, | 2132 PP_Instance instance, |
| 2215 ::ppapi::SingletonResourceID id) { | 2133 ::ppapi::SingletonResourceID id) { |
| 2216 // Flash APIs and some others aren't implemented in-process. | 2134 // Flash APIs and some others aren't implemented in-process. |
| 2217 switch (id) { | 2135 switch (id) { |
| 2218 case ::ppapi::BROKER_SINGLETON_ID: | 2136 case ::ppapi::BROKER_SINGLETON_ID: |
| 2219 case ::ppapi::BROWSER_FONT_SINGLETON_ID: | 2137 case ::ppapi::BROWSER_FONT_SINGLETON_ID: |
| 2220 case ::ppapi::CRX_FILESYSTEM_SINGLETON_ID: | 2138 case ::ppapi::CRX_FILESYSTEM_SINGLETON_ID: |
| 2221 case ::ppapi::EXTENSIONS_COMMON_SINGLETON_ID: | 2139 case ::ppapi::EXTENSIONS_COMMON_SINGLETON_ID: |
| 2222 case ::ppapi::FLASH_CLIPBOARD_SINGLETON_ID: | 2140 case ::ppapi::FLASH_CLIPBOARD_SINGLETON_ID: |
| 2223 case ::ppapi::FLASH_FILE_SINGLETON_ID: | 2141 case ::ppapi::FLASH_FILE_SINGLETON_ID: |
| 2224 case ::ppapi::FLASH_FULLSCREEN_SINGLETON_ID: | 2142 case ::ppapi::FLASH_FULLSCREEN_SINGLETON_ID: |
| 2225 case ::ppapi::FLASH_SINGLETON_ID: | 2143 case ::ppapi::FLASH_SINGLETON_ID: |
| 2226 case ::ppapi::NETWORK_PROXY_SINGLETON_ID: | 2144 case ::ppapi::NETWORK_PROXY_SINGLETON_ID: |
| 2227 case ::ppapi::PDF_SINGLETON_ID: | 2145 case ::ppapi::PDF_SINGLETON_ID: |
| 2228 case ::ppapi::TRUETYPE_FONT_SINGLETON_ID: | 2146 case ::ppapi::TRUETYPE_FONT_SINGLETON_ID: |
| 2229 NOTIMPLEMENTED(); | 2147 NOTIMPLEMENTED(); |
| 2230 return NULL; | 2148 return NULL; |
| 2231 case ::ppapi::GAMEPAD_SINGLETON_ID: | 2149 case ::ppapi::GAMEPAD_SINGLETON_ID: |
| 2232 return gamepad_impl_.get(); | 2150 return gamepad_impl_.get(); |
| 2233 } | 2151 } |
| 2234 | 2152 |
| 2235 NOTREACHED(); | 2153 NOTREACHED(); |
| 2236 return NULL; | 2154 return NULL; |
| 2237 } | 2155 } |
| 2238 | 2156 |
| 2239 int32_t PluginInstance::RequestInputEvents(PP_Instance instance, | 2157 int32_t PluginInstanceImpl::RequestInputEvents(PP_Instance instance, |
| 2240 uint32_t event_classes) { | 2158 uint32_t event_classes) { |
| 2241 input_event_mask_ |= event_classes; | 2159 input_event_mask_ |= event_classes; |
| 2242 filtered_input_event_mask_ &= ~(event_classes); | 2160 filtered_input_event_mask_ &= ~(event_classes); |
| 2243 RequestInputEventsHelper(event_classes); | 2161 RequestInputEventsHelper(event_classes); |
| 2244 return ValidateRequestInputEvents(false, event_classes); | 2162 return ValidateRequestInputEvents(false, event_classes); |
| 2245 } | 2163 } |
| 2246 | 2164 |
| 2247 int32_t PluginInstance::RequestFilteringInputEvents(PP_Instance instance, | 2165 int32_t PluginInstanceImpl::RequestFilteringInputEvents( |
| 2248 uint32_t event_classes) { | 2166 PP_Instance instance, |
| 2167 uint32_t event_classes) { |
| 2249 filtered_input_event_mask_ |= event_classes; | 2168 filtered_input_event_mask_ |= event_classes; |
| 2250 input_event_mask_ &= ~(event_classes); | 2169 input_event_mask_ &= ~(event_classes); |
| 2251 RequestInputEventsHelper(event_classes); | 2170 RequestInputEventsHelper(event_classes); |
| 2252 return ValidateRequestInputEvents(true, event_classes); | 2171 return ValidateRequestInputEvents(true, event_classes); |
| 2253 } | 2172 } |
| 2254 | 2173 |
| 2255 void PluginInstance::ClearInputEventRequest(PP_Instance instance, | 2174 void PluginInstanceImpl::ClearInputEventRequest(PP_Instance instance, |
| 2256 uint32_t event_classes) { | 2175 uint32_t event_classes) { |
| 2257 input_event_mask_ &= ~(event_classes); | 2176 input_event_mask_ &= ~(event_classes); |
| 2258 filtered_input_event_mask_ &= ~(event_classes); | 2177 filtered_input_event_mask_ &= ~(event_classes); |
| 2259 RequestInputEventsHelper(event_classes); | 2178 RequestInputEventsHelper(event_classes); |
| 2260 } | 2179 } |
| 2261 | 2180 |
| 2262 void PluginInstance::ZoomChanged(PP_Instance instance, double factor) { | 2181 void PluginInstanceImpl::ZoomChanged(PP_Instance instance, double factor) { |
| 2263 // We only want to tell the page to change its zoom if the whole page is the | 2182 // We only want to tell the page to change its zoom if the whole page is the |
| 2264 // plugin. If we're in an iframe, then don't do anything. | 2183 // plugin. If we're in an iframe, then don't do anything. |
| 2265 if (!IsFullPagePlugin()) | 2184 if (!IsFullPagePlugin()) |
| 2266 return; | 2185 return; |
| 2267 container()->zoomLevelChanged(WebView::zoomFactorToZoomLevel(factor)); | 2186 container()->zoomLevelChanged(WebView::zoomFactorToZoomLevel(factor)); |
| 2268 } | 2187 } |
| 2269 | 2188 |
| 2270 void PluginInstance::ZoomLimitsChanged(PP_Instance instance, | 2189 void PluginInstanceImpl::ZoomLimitsChanged(PP_Instance instance, |
| 2271 double minimum_factor, | 2190 double minimum_factor, |
| 2272 double maximium_factor) { | 2191 double maximium_factor) { |
| 2273 if (minimum_factor > maximium_factor) { | 2192 if (minimum_factor > maximium_factor) { |
| 2274 NOTREACHED(); | 2193 NOTREACHED(); |
| 2275 return; | 2194 return; |
| 2276 } | 2195 } |
| 2277 delegate()->ZoomLimitsChanged(minimum_factor, maximium_factor); | 2196 delegate()->ZoomLimitsChanged(minimum_factor, maximium_factor); |
| 2278 } | 2197 } |
| 2279 | 2198 |
| 2280 void PluginInstance::PostMessage(PP_Instance instance, PP_Var message) { | 2199 void PluginInstanceImpl::PostMessage(PP_Instance instance, PP_Var message) { |
| 2281 message_channel_->PostMessageToJavaScript(message); | 2200 message_channel_->PostMessageToJavaScript(message); |
| 2282 } | 2201 } |
| 2283 | 2202 |
| 2284 PP_Bool PluginInstance::SetCursor(PP_Instance instance, | 2203 PP_Bool PluginInstanceImpl::SetCursor(PP_Instance instance, |
| 2285 PP_MouseCursor_Type type, | 2204 PP_MouseCursor_Type type, |
| 2286 PP_Resource image, | 2205 PP_Resource image, |
| 2287 const PP_Point* hot_spot) { | 2206 const PP_Point* hot_spot) { |
| 2288 if (!ValidateSetCursorParams(type, image, hot_spot)) | 2207 if (!ValidateSetCursorParams(type, image, hot_spot)) |
| 2289 return PP_FALSE; | 2208 return PP_FALSE; |
| 2290 | 2209 |
| 2291 if (type != PP_MOUSECURSOR_TYPE_CUSTOM) { | 2210 if (type != PP_MOUSECURSOR_TYPE_CUSTOM) { |
| 2292 DoSetCursor(new WebCursorInfo(static_cast<WebCursorInfo::Type>(type))); | 2211 DoSetCursor(new WebCursorInfo(static_cast<WebCursorInfo::Type>(type))); |
| 2293 return PP_TRUE; | 2212 return PP_TRUE; |
| 2294 } | 2213 } |
| 2295 | 2214 |
| 2296 EnterResourceNoLock<PPB_ImageData_API> enter(image, true); | 2215 EnterResourceNoLock<PPB_ImageData_API> enter(image, true); |
| 2297 if (enter.failed()) | 2216 if (enter.failed()) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2313 // image data gets freed. | 2232 // image data gets freed. |
| 2314 if (!bitmap->copyTo(&custom_cursor->customImage.getSkBitmap(), | 2233 if (!bitmap->copyTo(&custom_cursor->customImage.getSkBitmap(), |
| 2315 bitmap->config())) { | 2234 bitmap->config())) { |
| 2316 return PP_FALSE; | 2235 return PP_FALSE; |
| 2317 } | 2236 } |
| 2318 | 2237 |
| 2319 DoSetCursor(custom_cursor.release()); | 2238 DoSetCursor(custom_cursor.release()); |
| 2320 return PP_TRUE; | 2239 return PP_TRUE; |
| 2321 } | 2240 } |
| 2322 | 2241 |
| 2323 int32_t PluginInstance::LockMouse(PP_Instance instance, | 2242 int32_t PluginInstanceImpl::LockMouse(PP_Instance instance, |
| 2324 scoped_refptr<TrackedCallback> callback) { | 2243 scoped_refptr<TrackedCallback> callback) { |
| 2325 if (TrackedCallback::IsPending(lock_mouse_callback_)) | 2244 if (TrackedCallback::IsPending(lock_mouse_callback_)) |
| 2326 return PP_ERROR_INPROGRESS; | 2245 return PP_ERROR_INPROGRESS; |
| 2327 | 2246 |
| 2328 if (delegate()->IsMouseLocked(this)) | 2247 if (delegate()->IsMouseLocked(this)) |
| 2329 return PP_OK; | 2248 return PP_OK; |
| 2330 | 2249 |
| 2331 if (!CanAccessMainFrame()) | 2250 if (!CanAccessMainFrame()) |
| 2332 return PP_ERROR_NOACCESS; | 2251 return PP_ERROR_NOACCESS; |
| 2333 | 2252 |
| 2334 if (!IsProcessingUserGesture()) | 2253 if (!IsProcessingUserGesture()) |
| 2335 return PP_ERROR_NO_USER_GESTURE; | 2254 return PP_ERROR_NO_USER_GESTURE; |
| 2336 | 2255 |
| 2337 // Attempt mouselock only if Flash isn't waiting on fullscreen, otherwise | 2256 // Attempt mouselock only if Flash isn't waiting on fullscreen, otherwise |
| 2338 // we wait and call LockMouse() in UpdateFlashFullscreenState(). | 2257 // we wait and call LockMouse() in UpdateFlashFullscreenState(). |
| 2339 if (!FlashIsFullscreenOrPending() || flash_fullscreen()) { | 2258 if (!FlashIsFullscreenOrPending() || flash_fullscreen()) { |
| 2340 // Open a user gesture here so the Webkit user gesture checks will succeed | 2259 // Open a user gesture here so the Webkit user gesture checks will succeed |
| 2341 // for out-of-process plugins. | 2260 // for out-of-process plugins. |
| 2342 WebScopedUserGesture user_gesture(CurrentUserGestureToken()); | 2261 WebScopedUserGesture user_gesture(CurrentUserGestureToken()); |
| 2343 if (!delegate()->LockMouse(this)) | 2262 if (!delegate()->LockMouse(this)) |
| 2344 return PP_ERROR_FAILED; | 2263 return PP_ERROR_FAILED; |
| 2345 } | 2264 } |
| 2346 | 2265 |
| 2347 // Either mouselock succeeded or a Flash fullscreen is pending. | 2266 // Either mouselock succeeded or a Flash fullscreen is pending. |
| 2348 lock_mouse_callback_ = callback; | 2267 lock_mouse_callback_ = callback; |
| 2349 return PP_OK_COMPLETIONPENDING; | 2268 return PP_OK_COMPLETIONPENDING; |
| 2350 } | 2269 } |
| 2351 | 2270 |
| 2352 void PluginInstance::UnlockMouse(PP_Instance instance) { | 2271 void PluginInstanceImpl::UnlockMouse(PP_Instance instance) { |
| 2353 delegate()->UnlockMouse(this); | 2272 delegate()->UnlockMouse(this); |
| 2354 } | 2273 } |
| 2355 | 2274 |
| 2356 void PluginInstance::SetTextInputType(PP_Instance instance, | 2275 void PluginInstanceImpl::SetTextInputType(PP_Instance instance, |
| 2357 PP_TextInput_Type type) { | 2276 PP_TextInput_Type type) { |
| 2358 int itype = type; | 2277 int itype = type; |
| 2359 if (itype < 0 || itype > ui::TEXT_INPUT_TYPE_URL) | 2278 if (itype < 0 || itype > ui::TEXT_INPUT_TYPE_URL) |
| 2360 itype = ui::TEXT_INPUT_TYPE_NONE; | 2279 itype = ui::TEXT_INPUT_TYPE_NONE; |
| 2361 text_input_type_ = static_cast<ui::TextInputType>(itype); | 2280 text_input_type_ = static_cast<ui::TextInputType>(itype); |
| 2362 delegate()->PluginTextInputTypeChanged(this); | 2281 delegate()->PluginTextInputTypeChanged(this); |
| 2363 } | 2282 } |
| 2364 | 2283 |
| 2365 void PluginInstance::UpdateCaretPosition(PP_Instance instance, | 2284 void PluginInstanceImpl::UpdateCaretPosition(PP_Instance instance, |
| 2366 const PP_Rect& caret, | 2285 const PP_Rect& caret, |
| 2367 const PP_Rect& bounding_box) { | 2286 const PP_Rect& bounding_box) { |
| 2368 text_input_caret_ = PP_ToGfxRect(caret); | 2287 text_input_caret_ = PP_ToGfxRect(caret); |
| 2369 text_input_caret_bounds_ = PP_ToGfxRect(bounding_box); | 2288 text_input_caret_bounds_ = PP_ToGfxRect(bounding_box); |
| 2370 text_input_caret_set_ = true; | 2289 text_input_caret_set_ = true; |
| 2371 delegate()->PluginCaretPositionChanged(this); | 2290 delegate()->PluginCaretPositionChanged(this); |
| 2372 } | 2291 } |
| 2373 | 2292 |
| 2374 void PluginInstance::CancelCompositionText(PP_Instance instance) { | 2293 void PluginInstanceImpl::CancelCompositionText(PP_Instance instance) { |
| 2375 delegate()->PluginRequestedCancelComposition(this); | 2294 delegate()->PluginRequestedCancelComposition(this); |
| 2376 } | 2295 } |
| 2377 | 2296 |
| 2378 void PluginInstance::SelectionChanged(PP_Instance instance) { | 2297 void PluginInstanceImpl::SelectionChanged(PP_Instance instance) { |
| 2379 // TODO(kinaba): currently the browser always calls RequestSurroundingText. | 2298 // TODO(kinaba): currently the browser always calls RequestSurroundingText. |
| 2380 // It can be optimized so that it won't call it back until the information | 2299 // It can be optimized so that it won't call it back until the information |
| 2381 // is really needed. | 2300 // is really needed. |
| 2382 | 2301 |
| 2383 // Avoid calling in nested context or else this will reenter the plugin. This | 2302 // Avoid calling in nested context or else this will reenter the plugin. This |
| 2384 // uses a weak pointer rather than exploiting the fact that this class is | 2303 // uses a weak pointer rather than exploiting the fact that this class is |
| 2385 // refcounted because we don't actually want this operation to affect the | 2304 // refcounted because we don't actually want this operation to affect the |
| 2386 // lifetime of the instance. | 2305 // lifetime of the instance. |
| 2387 base::MessageLoop::current()->PostTask( | 2306 base::MessageLoop::current()->PostTask( |
| 2388 FROM_HERE, | 2307 FROM_HERE, |
| 2389 base::Bind(&PluginInstance::RequestSurroundingText, | 2308 base::Bind(&PluginInstanceImpl::RequestSurroundingText, |
| 2390 AsWeakPtr(), | 2309 AsWeakPtr(), |
| 2391 static_cast<size_t>(kExtraCharsForTextInput))); | 2310 static_cast<size_t>(kExtraCharsForTextInput))); |
| 2392 } | 2311 } |
| 2393 | 2312 |
| 2394 void PluginInstance::UpdateSurroundingText(PP_Instance instance, | 2313 void PluginInstanceImpl::UpdateSurroundingText(PP_Instance instance, |
| 2395 const char* text, | 2314 const char* text, |
| 2396 uint32_t caret, | 2315 uint32_t caret, |
| 2397 uint32_t anchor) { | 2316 uint32_t anchor) { |
| 2398 surrounding_text_ = text; | 2317 surrounding_text_ = text; |
| 2399 selection_caret_ = caret; | 2318 selection_caret_ = caret; |
| 2400 selection_anchor_ = anchor; | 2319 selection_anchor_ = anchor; |
| 2401 delegate()->PluginSelectionChanged(this); | 2320 delegate()->PluginSelectionChanged(this); |
| 2402 } | 2321 } |
| 2403 | 2322 |
| 2404 PP_Var PluginInstance::ResolveRelativeToDocument( | 2323 PP_Var PluginInstanceImpl::ResolveRelativeToDocument( |
| 2405 PP_Instance instance, | 2324 PP_Instance instance, |
| 2406 PP_Var relative, | 2325 PP_Var relative, |
| 2407 PP_URLComponents_Dev* components) { | 2326 PP_URLComponents_Dev* components) { |
| 2408 StringVar* relative_string = StringVar::FromPPVar(relative); | 2327 StringVar* relative_string = StringVar::FromPPVar(relative); |
| 2409 if (!relative_string) | 2328 if (!relative_string) |
| 2410 return PP_MakeNull(); | 2329 return PP_MakeNull(); |
| 2411 | 2330 |
| 2412 WebElement plugin_element = container()->element(); | 2331 WebElement plugin_element = container()->element(); |
| 2413 GURL document_url = plugin_element.document().baseURL(); | 2332 GURL document_url = plugin_element.document().baseURL(); |
| 2414 return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn( | 2333 return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn( |
| 2415 document_url.Resolve(relative_string->value()), | 2334 document_url.Resolve(relative_string->value()), |
| 2416 components); | 2335 components); |
| 2417 } | 2336 } |
| 2418 | 2337 |
| 2419 PP_Bool PluginInstance::DocumentCanRequest(PP_Instance instance, PP_Var url) { | 2338 PP_Bool PluginInstanceImpl::DocumentCanRequest(PP_Instance instance, |
| 2339 PP_Var url) { |
| 2420 StringVar* url_string = StringVar::FromPPVar(url); | 2340 StringVar* url_string = StringVar::FromPPVar(url); |
| 2421 if (!url_string) | 2341 if (!url_string) |
| 2422 return PP_FALSE; | 2342 return PP_FALSE; |
| 2423 | 2343 |
| 2424 WebKit::WebSecurityOrigin security_origin; | 2344 WebKit::WebSecurityOrigin security_origin; |
| 2425 if (!SecurityOriginForInstance(instance, &security_origin)) | 2345 if (!SecurityOriginForInstance(instance, &security_origin)) |
| 2426 return PP_FALSE; | 2346 return PP_FALSE; |
| 2427 | 2347 |
| 2428 GURL gurl(url_string->value()); | 2348 GURL gurl(url_string->value()); |
| 2429 if (!gurl.is_valid()) | 2349 if (!gurl.is_valid()) |
| 2430 return PP_FALSE; | 2350 return PP_FALSE; |
| 2431 | 2351 |
| 2432 return BoolToPPBool(security_origin.canRequest(gurl)); | 2352 return BoolToPPBool(security_origin.canRequest(gurl)); |
| 2433 } | 2353 } |
| 2434 | 2354 |
| 2435 PP_Bool PluginInstance::DocumentCanAccessDocument(PP_Instance instance, | 2355 PP_Bool PluginInstanceImpl::DocumentCanAccessDocument(PP_Instance instance, |
| 2436 PP_Instance target) { | 2356 PP_Instance target) { |
| 2437 WebKit::WebSecurityOrigin our_origin; | 2357 WebKit::WebSecurityOrigin our_origin; |
| 2438 if (!SecurityOriginForInstance(instance, &our_origin)) | 2358 if (!SecurityOriginForInstance(instance, &our_origin)) |
| 2439 return PP_FALSE; | 2359 return PP_FALSE; |
| 2440 | 2360 |
| 2441 WebKit::WebSecurityOrigin target_origin; | 2361 WebKit::WebSecurityOrigin target_origin; |
| 2442 if (!SecurityOriginForInstance(instance, &target_origin)) | 2362 if (!SecurityOriginForInstance(instance, &target_origin)) |
| 2443 return PP_FALSE; | 2363 return PP_FALSE; |
| 2444 | 2364 |
| 2445 return BoolToPPBool(our_origin.canAccess(target_origin)); | 2365 return BoolToPPBool(our_origin.canAccess(target_origin)); |
| 2446 } | 2366 } |
| 2447 | 2367 |
| 2448 PP_Var PluginInstance::GetDocumentURL(PP_Instance instance, | 2368 PP_Var PluginInstanceImpl::GetDocumentURL(PP_Instance instance, |
| 2449 PP_URLComponents_Dev* components) { | 2369 PP_URLComponents_Dev* components) { |
| 2450 WebKit::WebDocument document = container()->element().document(); | 2370 WebKit::WebDocument document = container()->element().document(); |
| 2451 return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn(document.url(), | 2371 return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn(document.url(), |
| 2452 components); | 2372 components); |
| 2453 } | 2373 } |
| 2454 | 2374 |
| 2455 PP_Var PluginInstance::GetPluginInstanceURL( | 2375 PP_Var PluginInstanceImpl::GetPluginInstanceURL( |
| 2456 PP_Instance instance, | 2376 PP_Instance instance, |
| 2457 PP_URLComponents_Dev* components) { | 2377 PP_URLComponents_Dev* components) { |
| 2458 return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn(plugin_url_, | 2378 return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn(plugin_url_, |
| 2459 components); | 2379 components); |
| 2460 } | 2380 } |
| 2461 | 2381 |
| 2462 PP_ExternalPluginResult PluginInstance::ResetAsProxied( | 2382 PP_ExternalPluginResult PluginInstanceImpl::ResetAsProxied( |
| 2463 scoped_refptr<PluginModule> module) { | 2383 scoped_refptr<PluginModule> module) { |
| 2464 // Save the original module and switch over to the new one now that this | 2384 // Save the original module and switch over to the new one now that this |
| 2465 // plugin is using the IPC-based proxy. | 2385 // plugin is using the IPC-based proxy. |
| 2466 original_module_ = module_; | 2386 original_module_ = module_; |
| 2467 module_ = module; | 2387 module_ = module; |
| 2468 | 2388 |
| 2469 // Don't send any messages to the plugin until DidCreate() has finished. | 2389 // Don't send any messages to the plugin until DidCreate() has finished. |
| 2470 message_channel_->QueueJavaScriptMessages(); | 2390 message_channel_->QueueJavaScriptMessages(); |
| 2471 | 2391 |
| 2472 // For NaCl instances, remember the NaCl plugin instance interface, so we | 2392 // For NaCl instances, remember the NaCl plugin instance interface, so we |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2523 HandleDocumentLoad(nacl_document_response_); | 2443 HandleDocumentLoad(nacl_document_response_); |
| 2524 nacl_document_response_ = WebKit::WebURLResponse(); | 2444 nacl_document_response_ = WebKit::WebURLResponse(); |
| 2525 // Replay any document load events we've received to the real loader. | 2445 // Replay any document load events we've received to the real loader. |
| 2526 nacl_document_loader_->ReplayReceivedData(document_loader_); | 2446 nacl_document_loader_->ReplayReceivedData(document_loader_); |
| 2527 nacl_document_loader_.reset(NULL); | 2447 nacl_document_loader_.reset(NULL); |
| 2528 } | 2448 } |
| 2529 | 2449 |
| 2530 return PP_EXTERNAL_PLUGIN_OK; | 2450 return PP_EXTERNAL_PLUGIN_OK; |
| 2531 } | 2451 } |
| 2532 | 2452 |
| 2533 bool PluginInstance::IsValidInstanceOf(PluginModule* module) { | 2453 bool PluginInstanceImpl::IsValidInstanceOf(PluginModule* module) { |
| 2534 DCHECK(module); | 2454 DCHECK(module); |
| 2535 return module == module_.get() || | 2455 return module == module_.get() || |
| 2536 module == original_module_.get(); | 2456 module == original_module_.get(); |
| 2537 } | 2457 } |
| 2538 | 2458 |
| 2539 NPP PluginInstance::instanceNPP() { | 2459 NPP PluginInstanceImpl::instanceNPP() { |
| 2540 return npp_.get(); | 2460 return npp_.get(); |
| 2541 } | 2461 } |
| 2542 | 2462 |
| 2543 v8::Isolate* PluginInstance::GetIsolate() const { | 2463 v8::Isolate* PluginInstanceImpl::GetIsolate() const { |
| 2544 return isolate_; | 2464 return isolate_; |
| 2545 } | 2465 } |
| 2546 | 2466 |
| 2547 PluginInstance* PluginInstance::Get(PP_Instance instance_id) { | 2467 PluginInstance* PluginInstance::Get(PP_Instance instance_id) { |
| 2548 return HostGlobals::Get()->GetInstance(instance_id); | 2468 return HostGlobals::Get()->GetInstance(instance_id); |
| 2549 } | 2469 } |
| 2550 | 2470 |
| 2551 ::ppapi::VarTracker* PluginInstance::GetVarTracker() { | 2471 content::RenderView* PluginInstanceImpl::GetRenderView() { |
| 2472 return render_view_; |
| 2473 } |
| 2474 |
| 2475 WebKit::WebPluginContainer* PluginInstanceImpl::GetContainer() { |
| 2476 return container_; |
| 2477 } |
| 2478 |
| 2479 ::ppapi::VarTracker* PluginInstanceImpl::GetVarTracker() { |
| 2552 return HostGlobals::Get()->GetVarTracker(); | 2480 return HostGlobals::Get()->GetVarTracker(); |
| 2553 } | 2481 } |
| 2554 | 2482 |
| 2555 PP_Resource PluginInstance::CreateExternalFileReference( | 2483 const GURL& PluginInstanceImpl::GetPluginURL() { |
| 2484 return plugin_url_; |
| 2485 } |
| 2486 |
| 2487 base::FilePath PluginInstanceImpl::GetModulePath() { |
| 2488 return module_->path(); |
| 2489 } |
| 2490 |
| 2491 PP_Resource PluginInstanceImpl::CreateExternalFileReference( |
| 2556 const base::FilePath& external_file_path) { | 2492 const base::FilePath& external_file_path) { |
| 2557 webkit::ppapi::PPB_FileRef_Impl* ref = | 2493 webkit::ppapi::PPB_FileRef_Impl* ref = |
| 2558 webkit::ppapi::PPB_FileRef_Impl::CreateExternal( | 2494 webkit::ppapi::PPB_FileRef_Impl::CreateExternal( |
| 2559 pp_instance(), external_file_path, ""); | 2495 pp_instance(), external_file_path, ""); |
| 2560 return ref->GetReference(); | 2496 return ref->GetReference(); |
| 2561 } | 2497 } |
| 2562 | 2498 |
| 2563 PP_Resource PluginInstance::CreateImage(gfx::ImageSkia* source_image, | 2499 PP_Resource PluginInstanceImpl::CreateImage(gfx::ImageSkia* source_image, |
| 2564 float scale) { | 2500 float scale) { |
| 2565 ui::ScaleFactor scale_factor = ui::GetScaleFactorFromScale(scale); | 2501 ui::ScaleFactor scale_factor = ui::GetScaleFactorFromScale(scale); |
| 2566 gfx::ImageSkiaRep image_skia_rep = source_image->GetRepresentation( | 2502 gfx::ImageSkiaRep image_skia_rep = source_image->GetRepresentation( |
| 2567 scale_factor); | 2503 scale_factor); |
| 2568 | 2504 |
| 2569 if (image_skia_rep.is_null() || image_skia_rep.scale_factor() != scale_factor) | 2505 if (image_skia_rep.is_null() || image_skia_rep.scale_factor() != scale_factor) |
| 2570 return 0; | 2506 return 0; |
| 2571 | 2507 |
| 2572 scoped_refptr<webkit::ppapi::PPB_ImageData_Impl> image_data( | 2508 scoped_refptr<webkit::ppapi::PPB_ImageData_Impl> image_data( |
| 2573 new webkit::ppapi::PPB_ImageData_Impl( | 2509 new webkit::ppapi::PPB_ImageData_Impl( |
| 2574 pp_instance(), | 2510 pp_instance(), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2586 return 0; | 2522 return 0; |
| 2587 | 2523 |
| 2588 skia::PlatformCanvas* canvas = image_data->GetPlatformCanvas(); | 2524 skia::PlatformCanvas* canvas = image_data->GetPlatformCanvas(); |
| 2589 // Note: Do not SkBitmap::copyTo the canvas bitmap directly because it will | 2525 // Note: Do not SkBitmap::copyTo the canvas bitmap directly because it will |
| 2590 // ignore the allocated pixels in shared memory and re-allocate a new buffer. | 2526 // ignore the allocated pixels in shared memory and re-allocate a new buffer. |
| 2591 canvas->writePixels(image_skia_rep.sk_bitmap(), 0, 0); | 2527 canvas->writePixels(image_skia_rep.sk_bitmap(), 0, 0); |
| 2592 | 2528 |
| 2593 return image_data->GetReference(); | 2529 return image_data->GetReference(); |
| 2594 } | 2530 } |
| 2595 | 2531 |
| 2596 base::FilePath PluginInstance::GetModulePath() { | 2532 PP_ExternalPluginResult PluginInstanceImpl::SwitchToOutOfProcessProxy( |
| 2597 return module_->path(); | |
| 2598 } | |
| 2599 | |
| 2600 PP_ExternalPluginResult PluginInstance::SwitchToOutOfProcessProxy( | |
| 2601 const base::FilePath& file_path, | 2533 const base::FilePath& file_path, |
| 2602 ::ppapi::PpapiPermissions permissions, | 2534 ::ppapi::PpapiPermissions permissions, |
| 2603 const IPC::ChannelHandle& channel_handle, | 2535 const IPC::ChannelHandle& channel_handle, |
| 2604 base::ProcessId plugin_pid, | 2536 base::ProcessId plugin_pid, |
| 2605 int plugin_child_id) { | 2537 int plugin_child_id) { |
| 2606 // Create a new module for each instance of the external plugin that is using | 2538 // Create a new module for each instance of the external plugin that is using |
| 2607 // the IPC based out-of-process proxy. We can't use the existing module, | 2539 // the IPC based out-of-process proxy. We can't use the existing module, |
| 2608 // because it is configured for the in-process plugin, and we must keep it | 2540 // because it is configured for the in-process plugin, and we must keep it |
| 2609 // that way to allow the page to create other instances. | 2541 // that way to allow the page to create other instances. |
| 2610 scoped_refptr<webkit::ppapi::PluginModule> external_plugin_module( | 2542 scoped_refptr<webkit::ppapi::PluginModule> external_plugin_module( |
| 2611 module_->CreateModuleForExternalPluginInstance()); | 2543 module_->CreateModuleForExternalPluginInstance()); |
| 2612 | 2544 |
| 2613 content::RendererPpapiHost* renderer_ppapi_host = | 2545 content::RendererPpapiHost* renderer_ppapi_host = |
| 2614 delegate_->CreateExternalPluginModule( | 2546 delegate_->CreateExternalPluginModule( |
| 2615 external_plugin_module, | 2547 external_plugin_module, |
| 2616 file_path, | 2548 file_path, |
| 2617 permissions, | 2549 permissions, |
| 2618 channel_handle, | 2550 channel_handle, |
| 2619 plugin_pid, | 2551 plugin_pid, |
| 2620 plugin_child_id); | 2552 plugin_child_id); |
| 2621 if (!renderer_ppapi_host) { | 2553 if (!renderer_ppapi_host) { |
| 2622 DLOG(ERROR) << "CreateExternalPluginModule() failed"; | 2554 DLOG(ERROR) << "CreateExternalPluginModule() failed"; |
| 2623 return PP_EXTERNAL_PLUGIN_ERROR_MODULE; | 2555 return PP_EXTERNAL_PLUGIN_ERROR_MODULE; |
| 2624 } | 2556 } |
| 2625 | 2557 |
| 2626 // Finally, switch the instance to the proxy. | 2558 // Finally, switch the instance to the proxy. |
| 2627 return external_plugin_module->InitAsProxiedExternalPlugin(this); | 2559 return external_plugin_module->InitAsProxiedExternalPlugin(this); |
| 2628 } | 2560 } |
| 2629 | 2561 |
| 2630 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { | 2562 void PluginInstanceImpl::SetAlwaysOnTop(bool on_top) { |
| 2563 always_on_top_ = on_top; |
| 2564 } |
| 2565 |
| 2566 void PluginInstanceImpl::DoSetCursor(WebCursorInfo* cursor) { |
| 2631 cursor_.reset(cursor); | 2567 cursor_.reset(cursor); |
| 2632 if (fullscreen_container_) { | 2568 if (fullscreen_container_) { |
| 2633 fullscreen_container_->DidChangeCursor(*cursor); | 2569 fullscreen_container_->DidChangeCursor(*cursor); |
| 2634 } else { | 2570 } else { |
| 2635 delegate()->DidChangeCursor(this, *cursor); | 2571 delegate()->DidChangeCursor(this, *cursor); |
| 2636 } | 2572 } |
| 2637 } | 2573 } |
| 2638 | 2574 |
| 2639 bool PluginInstance::CanAccessMainFrame() const { | 2575 bool PluginInstanceImpl::IsFullPagePlugin() { |
| 2576 WebFrame* frame = container()->element().document().frame(); |
| 2577 return frame->view()->mainFrame()->document().isPluginDocument(); |
| 2578 } |
| 2579 |
| 2580 void PluginInstanceImpl::FlashSetFullscreen(bool fullscreen, |
| 2581 bool delay_report) { |
| 2582 TRACE_EVENT0("ppapi", "PluginInstanceImpl::FlashSetFullscreen"); |
| 2583 // Keep a reference on the stack. See NOTE above. |
| 2584 scoped_refptr<PluginInstanceImpl> ref(this); |
| 2585 |
| 2586 // We check whether we are trying to switch to the state we're already going |
| 2587 // to (i.e. if we're already switching to fullscreen but the fullscreen |
| 2588 // container isn't ready yet, don't do anything more). |
| 2589 if (fullscreen == FlashIsFullscreenOrPending()) |
| 2590 return; |
| 2591 |
| 2592 // Unbind current 2D or 3D graphics context. |
| 2593 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); |
| 2594 if (fullscreen) { |
| 2595 DCHECK(!fullscreen_container_); |
| 2596 fullscreen_container_ = delegate_->CreateFullscreenContainer(this); |
| 2597 UpdateLayer(); |
| 2598 } else { |
| 2599 DCHECK(fullscreen_container_); |
| 2600 fullscreen_container_->Destroy(); |
| 2601 fullscreen_container_ = NULL; |
| 2602 UpdateFlashFullscreenState(false); |
| 2603 if (!delay_report) { |
| 2604 ReportGeometry(); |
| 2605 } else { |
| 2606 base::MessageLoop::current()->PostTask( |
| 2607 FROM_HERE, base::Bind(&PluginInstanceImpl::ReportGeometry, this)); |
| 2608 } |
| 2609 } |
| 2610 } |
| 2611 |
| 2612 bool PluginInstanceImpl::IsRectTopmost(const gfx::Rect& rect) { |
| 2613 if (flash_fullscreen_) |
| 2614 return true; |
| 2615 |
| 2616 return container_->isRectTopmost(rect); |
| 2617 } |
| 2618 |
| 2619 int32_t PluginInstanceImpl::Navigate(const ::ppapi::URLRequestInfoData& request, |
| 2620 const char* target, |
| 2621 bool from_user_action) { |
| 2622 if (!container_) |
| 2623 return PP_ERROR_FAILED; |
| 2624 |
| 2625 WebDocument document = container_->element().document(); |
| 2626 WebFrame* frame = document.frame(); |
| 2627 if (!frame) |
| 2628 return PP_ERROR_FAILED; |
| 2629 |
| 2630 ::ppapi::URLRequestInfoData completed_request = request; |
| 2631 |
| 2632 WebURLRequest web_request; |
| 2633 if (!CreateWebURLRequest(&completed_request, frame, &web_request)) |
| 2634 return PP_ERROR_FAILED; |
| 2635 web_request.setFirstPartyForCookies(document.firstPartyForCookies()); |
| 2636 web_request.setHasUserGesture(from_user_action); |
| 2637 |
| 2638 GURL gurl(web_request.url()); |
| 2639 if (gurl.SchemeIs("javascript")) { |
| 2640 // In imitation of the NPAPI implementation, only |target_frame == frame| is |
| 2641 // allowed for security reasons. |
| 2642 WebFrame* target_frame = |
| 2643 frame->view()->findFrameByName(WebString::fromUTF8(target), frame); |
| 2644 if (target_frame != frame) |
| 2645 return PP_ERROR_NOACCESS; |
| 2646 |
| 2647 // TODO(viettrungluu): NPAPI sends the result back to the plugin -- do we |
| 2648 // need that? |
| 2649 WebString result = container_->executeScriptURL(gurl, from_user_action); |
| 2650 return result.isNull() ? PP_ERROR_FAILED : PP_OK; |
| 2651 } |
| 2652 |
| 2653 // Only GETs and POSTs are supported. |
| 2654 if (web_request.httpMethod() != "GET" && |
| 2655 web_request.httpMethod() != "POST") |
| 2656 return PP_ERROR_BADARGUMENT; |
| 2657 |
| 2658 WebString target_str = WebString::fromUTF8(target); |
| 2659 container_->loadFrameRequest(web_request, target_str, false, NULL); |
| 2660 return PP_OK; |
| 2661 } |
| 2662 |
| 2663 bool PluginInstanceImpl::CanAccessMainFrame() const { |
| 2640 if (!container_) | 2664 if (!container_) |
| 2641 return false; | 2665 return false; |
| 2642 WebKit::WebDocument containing_document = container_->element().document(); | 2666 WebKit::WebDocument containing_document = container_->element().document(); |
| 2643 | 2667 |
| 2644 if (!containing_document.frame() || | 2668 if (!containing_document.frame() || |
| 2645 !containing_document.frame()->view() || | 2669 !containing_document.frame()->view() || |
| 2646 !containing_document.frame()->view()->mainFrame()) { | 2670 !containing_document.frame()->view()->mainFrame()) { |
| 2647 return false; | 2671 return false; |
| 2648 } | 2672 } |
| 2649 WebKit::WebDocument main_document = | 2673 WebKit::WebDocument main_document = |
| 2650 containing_document.frame()->view()->mainFrame()->document(); | 2674 containing_document.frame()->view()->mainFrame()->document(); |
| 2651 | 2675 |
| 2652 return containing_document.securityOrigin().canAccess( | 2676 return containing_document.securityOrigin().canAccess( |
| 2653 main_document.securityOrigin()); | 2677 main_document.securityOrigin()); |
| 2654 } | 2678 } |
| 2655 | 2679 |
| 2656 void PluginInstance::KeepSizeAttributesBeforeFullscreen() { | 2680 void PluginInstanceImpl::KeepSizeAttributesBeforeFullscreen() { |
| 2657 WebElement element = container_->element(); | 2681 WebElement element = container_->element(); |
| 2658 width_before_fullscreen_ = element.getAttribute(WebString::fromUTF8(kWidth)); | 2682 width_before_fullscreen_ = element.getAttribute(WebString::fromUTF8(kWidth)); |
| 2659 height_before_fullscreen_ = | 2683 height_before_fullscreen_ = |
| 2660 element.getAttribute(WebString::fromUTF8(kHeight)); | 2684 element.getAttribute(WebString::fromUTF8(kHeight)); |
| 2661 border_before_fullscreen_ = | 2685 border_before_fullscreen_ = |
| 2662 element.getAttribute(WebString::fromUTF8(kBorder)); | 2686 element.getAttribute(WebString::fromUTF8(kBorder)); |
| 2663 style_before_fullscreen_ = element.getAttribute(WebString::fromUTF8(kStyle)); | 2687 style_before_fullscreen_ = element.getAttribute(WebString::fromUTF8(kStyle)); |
| 2664 } | 2688 } |
| 2665 | 2689 |
| 2666 void PluginInstance::SetSizeAttributesForFullscreen() { | 2690 void PluginInstanceImpl::SetSizeAttributesForFullscreen() { |
| 2667 screen_size_for_fullscreen_ = delegate()->GetScreenSize(); | 2691 screen_size_for_fullscreen_ = delegate()->GetScreenSize(); |
| 2668 std::string width = StringPrintf("%d", screen_size_for_fullscreen_.width()); | 2692 std::string width = StringPrintf("%d", screen_size_for_fullscreen_.width()); |
| 2669 std::string height = StringPrintf("%d", screen_size_for_fullscreen_.height()); | 2693 std::string height = StringPrintf("%d", screen_size_for_fullscreen_.height()); |
| 2670 | 2694 |
| 2671 WebElement element = container_->element(); | 2695 WebElement element = container_->element(); |
| 2672 element.setAttribute(WebString::fromUTF8(kWidth), WebString::fromUTF8(width)); | 2696 element.setAttribute(WebString::fromUTF8(kWidth), WebString::fromUTF8(width)); |
| 2673 element.setAttribute(WebString::fromUTF8(kHeight), | 2697 element.setAttribute(WebString::fromUTF8(kHeight), |
| 2674 WebString::fromUTF8(height)); | 2698 WebString::fromUTF8(height)); |
| 2675 element.setAttribute(WebString::fromUTF8(kBorder), WebString::fromUTF8("0")); | 2699 element.setAttribute(WebString::fromUTF8(kBorder), WebString::fromUTF8("0")); |
| 2676 | 2700 |
| 2677 // There should be no style settings that matter in fullscreen mode, | 2701 // There should be no style settings that matter in fullscreen mode, |
| 2678 // so just replace them instead of appending. | 2702 // so just replace them instead of appending. |
| 2679 // NOTE: "position: fixed" and "display: block" reset the plugin and | 2703 // NOTE: "position: fixed" and "display: block" reset the plugin and |
| 2680 // using %% settings might not work without them (e.g. if the plugin is a | 2704 // using %% settings might not work without them (e.g. if the plugin is a |
| 2681 // child of a container element). | 2705 // child of a container element). |
| 2682 std::string style; | 2706 std::string style; |
| 2683 style += StringPrintf("width: %s !important; ", width.c_str()); | 2707 style += StringPrintf("width: %s !important; ", width.c_str()); |
| 2684 style += StringPrintf("height: %s !important; ", height.c_str()); | 2708 style += StringPrintf("height: %s !important; ", height.c_str()); |
| 2685 style += "margin: 0 !important; padding: 0 !important; border: 0 !important"; | 2709 style += "margin: 0 !important; padding: 0 !important; border: 0 !important"; |
| 2686 container_->element().setAttribute(kStyle, WebString::fromUTF8(style)); | 2710 container_->element().setAttribute(kStyle, WebString::fromUTF8(style)); |
| 2687 } | 2711 } |
| 2688 | 2712 |
| 2689 void PluginInstance::ResetSizeAttributesAfterFullscreen() { | 2713 void PluginInstanceImpl::ResetSizeAttributesAfterFullscreen() { |
| 2690 screen_size_for_fullscreen_ = gfx::Size(); | 2714 screen_size_for_fullscreen_ = gfx::Size(); |
| 2691 WebElement element = container_->element(); | 2715 WebElement element = container_->element(); |
| 2692 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2716 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
| 2693 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2717 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
| 2694 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2718 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
| 2695 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2719 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
| 2696 } | 2720 } |
| 2697 | 2721 |
| 2698 } // namespace ppapi | 2722 } // namespace ppapi |
| 2699 } // namespace webkit | 2723 } // namespace webkit |
| OLD | NEW |