| 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 "content/renderer/pepper/pepper_plugin_delegate_impl.h" | 5 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <cstddef> | 8 #include <cstddef> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 #include "third_party/WebKit/public/web/WebDocument.h" | 89 #include "third_party/WebKit/public/web/WebDocument.h" |
| 90 #include "third_party/WebKit/public/web/WebElement.h" | 90 #include "third_party/WebKit/public/web/WebElement.h" |
| 91 #include "third_party/WebKit/public/web/WebFrame.h" | 91 #include "third_party/WebKit/public/web/WebFrame.h" |
| 92 #include "third_party/WebKit/public/web/WebInputEvent.h" | 92 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 93 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 93 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 94 #include "third_party/WebKit/public/web/WebScreenInfo.h" | 94 #include "third_party/WebKit/public/web/WebScreenInfo.h" |
| 95 #include "third_party/WebKit/public/web/WebView.h" | 95 #include "third_party/WebKit/public/web/WebView.h" |
| 96 #include "ui/gfx/size.h" | 96 #include "ui/gfx/size.h" |
| 97 #include "url/gurl.h" | 97 #include "url/gurl.h" |
| 98 #include "webkit/plugins/ppapi/plugin_module.h" | 98 #include "webkit/plugins/ppapi/plugin_module.h" |
| 99 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 99 #include "webkit/plugins/ppapi/ppapi_plugin_instance_impl.h" |
| 100 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" | 100 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" |
| 101 #include "webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.h" | 101 #include "webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.h" |
| 102 #include "webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h" | 102 #include "webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h" |
| 103 #include "webkit/plugins/ppapi/resource_helper.h" | 103 #include "webkit/plugins/ppapi/resource_helper.h" |
| 104 | 104 |
| 105 using WebKit::WebView; | 105 using WebKit::WebView; |
| 106 using WebKit::WebFrame; | 106 using WebKit::WebFrame; |
| 107 | 107 |
| 108 namespace content { | 108 namespace content { |
| 109 | 109 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 if (host) { | 175 if (host) { |
| 176 RenderView* render_view = host->GetRenderViewForInstance(instance); | 176 RenderView* render_view = host->GetRenderViewForInstance(instance); |
| 177 webkit::ppapi::PluginInstance* plugin_instance = | 177 webkit::ppapi::PluginInstance* plugin_instance = |
| 178 host->GetPluginInstance(instance); | 178 host->GetPluginInstance(instance); |
| 179 render_view->Send(new ViewHostMsg_DidCreateOutOfProcessPepperInstance( | 179 render_view->Send(new ViewHostMsg_DidCreateOutOfProcessPepperInstance( |
| 180 plugin_child_id_, | 180 plugin_child_id_, |
| 181 instance, | 181 instance, |
| 182 PepperRendererInstanceData( | 182 PepperRendererInstanceData( |
| 183 0, // The render process id will be supplied in the browser. | 183 0, // The render process id will be supplied in the browser. |
| 184 render_view->GetRoutingID(), | 184 render_view->GetRoutingID(), |
| 185 plugin_instance->container()->element().document().url(), | 185 plugin_instance->GetContainer()->element().document().url(), |
| 186 plugin_instance->plugin_url()), | 186 plugin_instance->GetPluginURL()), |
| 187 is_external_)); | 187 is_external_)); |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 virtual void RemoveInstance(PP_Instance instance) OVERRIDE { | 190 virtual void RemoveInstance(PP_Instance instance) OVERRIDE { |
| 191 ppapi::proxy::HostDispatcher::RemoveForInstance(instance); | 191 ppapi::proxy::HostDispatcher::RemoveForInstance(instance); |
| 192 | 192 |
| 193 RendererPpapiHostImpl* host = | 193 RendererPpapiHostImpl* host = |
| 194 RendererPpapiHostImpl::GetForPPInstance(instance); | 194 RendererPpapiHostImpl::GetForPPInstance(instance); |
| 195 // TODO(brettw) remove null check as described in AddInstance. | 195 // TODO(brettw) remove null check as described in AddInstance. |
| 196 if (host) { | 196 if (host) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 } | 240 } |
| 241 virtual void DidFail(quota::QuotaStatusCode error) OVERRIDE { | 241 virtual void DidFail(quota::QuotaStatusCode error) OVERRIDE { |
| 242 callback_.Run(0); | 242 callback_.Run(0); |
| 243 } | 243 } |
| 244 private: | 244 private: |
| 245 PluginCallback callback_; | 245 PluginCallback callback_; |
| 246 }; | 246 }; |
| 247 | 247 |
| 248 class PluginInstanceLockTarget : public MouseLockDispatcher::LockTarget { | 248 class PluginInstanceLockTarget : public MouseLockDispatcher::LockTarget { |
| 249 public: | 249 public: |
| 250 PluginInstanceLockTarget(webkit::ppapi::PluginInstance* plugin) | 250 PluginInstanceLockTarget(webkit::ppapi::PluginInstanceImpl* plugin) |
| 251 : plugin_(plugin) {} | 251 : plugin_(plugin) {} |
| 252 | 252 |
| 253 virtual void OnLockMouseACK(bool succeeded) OVERRIDE { | 253 virtual void OnLockMouseACK(bool succeeded) OVERRIDE { |
| 254 plugin_->OnLockMouseACK(succeeded); | 254 plugin_->OnLockMouseACK(succeeded); |
| 255 } | 255 } |
| 256 | 256 |
| 257 virtual void OnMouseLockLost() OVERRIDE { | 257 virtual void OnMouseLockLost() OVERRIDE { |
| 258 plugin_->OnMouseLockLost(); | 258 plugin_->OnMouseLockLost(); |
| 259 } | 259 } |
| 260 | 260 |
| 261 virtual bool HandleMouseLockedInputEvent( | 261 virtual bool HandleMouseLockedInputEvent( |
| 262 const WebKit::WebMouseEvent &event) OVERRIDE { | 262 const WebKit::WebMouseEvent &event) OVERRIDE { |
| 263 plugin_->HandleMouseLockedInputEvent(event); | 263 plugin_->HandleMouseLockedInputEvent(event); |
| 264 return true; | 264 return true; |
| 265 } | 265 } |
| 266 | 266 |
| 267 private: | 267 private: |
| 268 webkit::ppapi::PluginInstance* plugin_; | 268 webkit::ppapi::PluginInstanceImpl* plugin_; |
| 269 }; | 269 }; |
| 270 | 270 |
| 271 void DoNotifyCloseFile(int file_open_id, base::PlatformFileError /* unused */) { | 271 void DoNotifyCloseFile(int file_open_id, base::PlatformFileError /* unused */) { |
| 272 ChildThread::current()->file_system_dispatcher()->NotifyCloseFile( | 272 ChildThread::current()->file_system_dispatcher()->NotifyCloseFile( |
| 273 file_open_id); | 273 file_open_id); |
| 274 } | 274 } |
| 275 | 275 |
| 276 void DidOpenFileSystemURL( | 276 void DidOpenFileSystemURL( |
| 277 const webkit::ppapi::PluginDelegate::AsyncOpenFileSystemURLCallback& | 277 const webkit::ppapi::PluginDelegate::AsyncOpenFileSystemURLCallback& |
| 278 callback, | 278 callback, |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 } | 523 } |
| 524 } | 524 } |
| 525 | 525 |
| 526 return false; | 526 return false; |
| 527 } | 527 } |
| 528 | 528 |
| 529 void PepperPluginDelegateImpl::ViewWillInitiatePaint() { | 529 void PepperPluginDelegateImpl::ViewWillInitiatePaint() { |
| 530 // Notify all of our instances that we started painting. This is used for | 530 // Notify all of our instances that we started painting. This is used for |
| 531 // internal bookkeeping only, so we know that the set can not change under | 531 // internal bookkeeping only, so we know that the set can not change under |
| 532 // us. | 532 // us. |
| 533 for (std::set<webkit::ppapi::PluginInstance*>::iterator i = | 533 for (std::set<webkit::ppapi::PluginInstanceImpl*>::iterator i = |
| 534 active_instances_.begin(); | 534 active_instances_.begin(); |
| 535 i != active_instances_.end(); ++i) | 535 i != active_instances_.end(); ++i) |
| 536 (*i)->ViewWillInitiatePaint(); | 536 (*i)->ViewWillInitiatePaint(); |
| 537 } | 537 } |
| 538 | 538 |
| 539 void PepperPluginDelegateImpl::ViewInitiatedPaint() { | 539 void PepperPluginDelegateImpl::ViewInitiatedPaint() { |
| 540 // Notify all instances that we painted. The same caveats apply as for | 540 // Notify all instances that we painted. The same caveats apply as for |
| 541 // ViewFlushedPaint regarding instances closing themselves, so we take | 541 // ViewFlushedPaint regarding instances closing themselves, so we take |
| 542 // similar precautions. | 542 // similar precautions. |
| 543 std::set<webkit::ppapi::PluginInstance*> plugins = active_instances_; | 543 std::set<webkit::ppapi::PluginInstanceImpl*> plugins = active_instances_; |
| 544 for (std::set<webkit::ppapi::PluginInstance*>::iterator i = plugins.begin(); | 544 for (std::set<webkit::ppapi::PluginInstanceImpl*>::iterator i = |
| 545 plugins.begin(); |
| 545 i != plugins.end(); ++i) { | 546 i != plugins.end(); ++i) { |
| 546 if (active_instances_.find(*i) != active_instances_.end()) | 547 if (active_instances_.find(*i) != active_instances_.end()) |
| 547 (*i)->ViewInitiatedPaint(); | 548 (*i)->ViewInitiatedPaint(); |
| 548 } | 549 } |
| 549 } | 550 } |
| 550 | 551 |
| 551 void PepperPluginDelegateImpl::ViewFlushedPaint() { | 552 void PepperPluginDelegateImpl::ViewFlushedPaint() { |
| 552 // Notify all instances that we flushed. This will call into the plugin, and | 553 // Notify all instances that we flushed. This will call into the plugin, and |
| 553 // we it may ask to close itself as a result. This will, in turn, modify our | 554 // we it may ask to close itself as a result. This will, in turn, modify our |
| 554 // set, possibly invalidating the iterator. So we iterate on a copy that | 555 // set, possibly invalidating the iterator. So we iterate on a copy that |
| 555 // won't change out from under us. | 556 // won't change out from under us. |
| 556 std::set<webkit::ppapi::PluginInstance*> plugins = active_instances_; | 557 std::set<webkit::ppapi::PluginInstanceImpl*> plugins = active_instances_; |
| 557 for (std::set<webkit::ppapi::PluginInstance*>::iterator i = plugins.begin(); | 558 for (std::set<webkit::ppapi::PluginInstanceImpl*>::iterator i = |
| 559 plugins.begin(); |
| 558 i != plugins.end(); ++i) { | 560 i != plugins.end(); ++i) { |
| 559 // The copy above makes sure our iterator is never invalid if some plugins | 561 // The copy above makes sure our iterator is never invalid if some plugins |
| 560 // are destroyed. But some plugin may decide to close all of its views in | 562 // are destroyed. But some plugin may decide to close all of its views in |
| 561 // response to a paint in one of them, so we need to make sure each one is | 563 // response to a paint in one of them, so we need to make sure each one is |
| 562 // still "current" before using it. | 564 // still "current" before using it. |
| 563 // | 565 // |
| 564 // It's possible that a plugin was destroyed, but another one was created | 566 // It's possible that a plugin was destroyed, but another one was created |
| 565 // with the same address. In this case, we'll call ViewFlushedPaint on that | 567 // with the same address. In this case, we'll call ViewFlushedPaint on that |
| 566 // new plugin. But that's OK for this particular case since we're just | 568 // new plugin. But that's OK for this particular case since we're just |
| 567 // notifying all of our instances that the view flushed, and the new one is | 569 // notifying all of our instances that the view flushed, and the new one is |
| 568 // one of our instances. | 570 // one of our instances. |
| 569 // | 571 // |
| 570 // What about the case where a new one is created in a callback at a new | 572 // What about the case where a new one is created in a callback at a new |
| 571 // address and we don't issue the callback? We're still OK since this | 573 // address and we don't issue the callback? We're still OK since this |
| 572 // callback is used for flush callbacks and we could not have possibly | 574 // callback is used for flush callbacks and we could not have possibly |
| 573 // started a new paint (ViewWillInitiatePaint) for the new plugin while | 575 // started a new paint (ViewWillInitiatePaint) for the new plugin while |
| 574 // processing a previous paint for an existing one. | 576 // processing a previous paint for an existing one. |
| 575 if (active_instances_.find(*i) != active_instances_.end()) | 577 if (active_instances_.find(*i) != active_instances_.end()) |
| 576 (*i)->ViewFlushedPaint(); | 578 (*i)->ViewFlushedPaint(); |
| 577 } | 579 } |
| 578 } | 580 } |
| 579 | 581 |
| 580 webkit::ppapi::PluginInstance* | 582 webkit::ppapi::PluginInstanceImpl* |
| 581 PepperPluginDelegateImpl::GetBitmapForOptimizedPluginPaint( | 583 PepperPluginDelegateImpl::GetBitmapForOptimizedPluginPaint( |
| 582 const gfx::Rect& paint_bounds, | 584 const gfx::Rect& paint_bounds, |
| 583 TransportDIB** dib, | 585 TransportDIB** dib, |
| 584 gfx::Rect* location, | 586 gfx::Rect* location, |
| 585 gfx::Rect* clip, | 587 gfx::Rect* clip, |
| 586 float* scale_factor) { | 588 float* scale_factor) { |
| 587 for (std::set<webkit::ppapi::PluginInstance*>::iterator i = | 589 for (std::set<webkit::ppapi::PluginInstanceImpl*>::iterator i = |
| 588 active_instances_.begin(); | 590 active_instances_.begin(); |
| 589 i != active_instances_.end(); ++i) { | 591 i != active_instances_.end(); ++i) { |
| 590 webkit::ppapi::PluginInstance* instance = *i; | 592 webkit::ppapi::PluginInstanceImpl* instance = *i; |
| 591 // In Flash fullscreen , the plugin contents should be painted onto the | 593 // In Flash fullscreen , the plugin contents should be painted onto the |
| 592 // fullscreen widget instead of the web page. | 594 // fullscreen widget instead of the web page. |
| 593 if (!instance->FlashIsFullscreenOrPending() && | 595 if (!instance->FlashIsFullscreenOrPending() && |
| 594 instance->GetBitmapForOptimizedPluginPaint(paint_bounds, dib, location, | 596 instance->GetBitmapForOptimizedPluginPaint(paint_bounds, dib, location, |
| 595 clip, scale_factor)) | 597 clip, scale_factor)) |
| 596 return *i; | 598 return *i; |
| 597 } | 599 } |
| 598 return NULL; | 600 return NULL; |
| 599 } | 601 } |
| 600 | 602 |
| 601 void PepperPluginDelegateImpl::PluginFocusChanged( | 603 void PepperPluginDelegateImpl::PluginFocusChanged( |
| 602 webkit::ppapi::PluginInstance* instance, | 604 webkit::ppapi::PluginInstanceImpl* instance, |
| 603 bool focused) { | 605 bool focused) { |
| 604 if (focused) | 606 if (focused) |
| 605 focused_plugin_ = instance; | 607 focused_plugin_ = instance; |
| 606 else if (focused_plugin_ == instance) | 608 else if (focused_plugin_ == instance) |
| 607 focused_plugin_ = NULL; | 609 focused_plugin_ = NULL; |
| 608 if (render_view_) | 610 if (render_view_) |
| 609 render_view_->PpapiPluginFocusChanged(); | 611 render_view_->PpapiPluginFocusChanged(); |
| 610 } | 612 } |
| 611 | 613 |
| 612 void PepperPluginDelegateImpl::PluginTextInputTypeChanged( | 614 void PepperPluginDelegateImpl::PluginTextInputTypeChanged( |
| 613 webkit::ppapi::PluginInstance* instance) { | 615 webkit::ppapi::PluginInstanceImpl* instance) { |
| 614 if (focused_plugin_ == instance && render_view_) | 616 if (focused_plugin_ == instance && render_view_) |
| 615 render_view_->PpapiPluginTextInputTypeChanged(); | 617 render_view_->PpapiPluginTextInputTypeChanged(); |
| 616 } | 618 } |
| 617 | 619 |
| 618 void PepperPluginDelegateImpl::PluginCaretPositionChanged( | 620 void PepperPluginDelegateImpl::PluginCaretPositionChanged( |
| 619 webkit::ppapi::PluginInstance* instance) { | 621 webkit::ppapi::PluginInstanceImpl* instance) { |
| 620 if (focused_plugin_ == instance && render_view_) | 622 if (focused_plugin_ == instance && render_view_) |
| 621 render_view_->PpapiPluginCaretPositionChanged(); | 623 render_view_->PpapiPluginCaretPositionChanged(); |
| 622 } | 624 } |
| 623 | 625 |
| 624 void PepperPluginDelegateImpl::PluginRequestedCancelComposition( | 626 void PepperPluginDelegateImpl::PluginRequestedCancelComposition( |
| 625 webkit::ppapi::PluginInstance* instance) { | 627 webkit::ppapi::PluginInstanceImpl* instance) { |
| 626 if (focused_plugin_ == instance && render_view_) | 628 if (focused_plugin_ == instance && render_view_) |
| 627 render_view_->PpapiPluginCancelComposition(); | 629 render_view_->PpapiPluginCancelComposition(); |
| 628 } | 630 } |
| 629 | 631 |
| 630 void PepperPluginDelegateImpl::PluginSelectionChanged( | 632 void PepperPluginDelegateImpl::PluginSelectionChanged( |
| 631 webkit::ppapi::PluginInstance* instance) { | 633 webkit::ppapi::PluginInstanceImpl* instance) { |
| 632 if (focused_plugin_ == instance && render_view_) | 634 if (focused_plugin_ == instance && render_view_) |
| 633 render_view_->PpapiPluginSelectionChanged(); | 635 render_view_->PpapiPluginSelectionChanged(); |
| 634 } | 636 } |
| 635 | 637 |
| 636 void PepperPluginDelegateImpl::SimulateImeSetComposition( | 638 void PepperPluginDelegateImpl::SimulateImeSetComposition( |
| 637 const string16& text, | 639 const string16& text, |
| 638 const std::vector<WebKit::WebCompositionUnderline>& underlines, | 640 const std::vector<WebKit::WebCompositionUnderline>& underlines, |
| 639 int selection_start, | 641 int selection_start, |
| 640 int selection_end) { | 642 int selection_end) { |
| 641 if (render_view_) { | 643 if (render_view_) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 if (!focused_plugin_) | 734 if (!focused_plugin_) |
| 733 return false; | 735 return false; |
| 734 return focused_plugin_->IsPluginAcceptingCompositionEvents(); | 736 return focused_plugin_->IsPluginAcceptingCompositionEvents(); |
| 735 } | 737 } |
| 736 | 738 |
| 737 bool PepperPluginDelegateImpl::CanComposeInline() const { | 739 bool PepperPluginDelegateImpl::CanComposeInline() const { |
| 738 return IsPluginAcceptingCompositionEvents(); | 740 return IsPluginAcceptingCompositionEvents(); |
| 739 } | 741 } |
| 740 | 742 |
| 741 void PepperPluginDelegateImpl::PluginCrashed( | 743 void PepperPluginDelegateImpl::PluginCrashed( |
| 742 webkit::ppapi::PluginInstance* instance) { | 744 webkit::ppapi::PluginInstanceImpl* instance) { |
| 743 render_view_->PluginCrashed(instance->module()->path(), | 745 render_view_->PluginCrashed(instance->module()->path(), |
| 744 instance->module()->GetPeerProcessId()); | 746 instance->module()->GetPeerProcessId()); |
| 745 UnSetAndDeleteLockTargetAdapter(instance); | 747 UnSetAndDeleteLockTargetAdapter(instance); |
| 746 } | 748 } |
| 747 | 749 |
| 748 void PepperPluginDelegateImpl::InstanceCreated( | 750 void PepperPluginDelegateImpl::InstanceCreated( |
| 749 webkit::ppapi::PluginInstance* instance) { | 751 webkit::ppapi::PluginInstanceImpl* instance) { |
| 750 active_instances_.insert(instance); | 752 active_instances_.insert(instance); |
| 751 | 753 |
| 752 // Set the initial focus. | 754 // Set the initial focus. |
| 753 instance->SetContentAreaFocus(render_view_->has_focus()); | 755 instance->SetContentAreaFocus(render_view_->has_focus()); |
| 754 } | 756 } |
| 755 | 757 |
| 756 void PepperPluginDelegateImpl::InstanceDeleted( | 758 void PepperPluginDelegateImpl::InstanceDeleted( |
| 757 webkit::ppapi::PluginInstance* instance) { | 759 webkit::ppapi::PluginInstanceImpl* instance) { |
| 758 active_instances_.erase(instance); | 760 active_instances_.erase(instance); |
| 759 UnSetAndDeleteLockTargetAdapter(instance); | 761 UnSetAndDeleteLockTargetAdapter(instance); |
| 760 | 762 |
| 761 if (last_mouse_event_target_ == instance) | 763 if (last_mouse_event_target_ == instance) |
| 762 last_mouse_event_target_ = NULL; | 764 last_mouse_event_target_ = NULL; |
| 763 if (focused_plugin_ == instance) | 765 if (focused_plugin_ == instance) |
| 764 PluginFocusChanged(instance, false); | 766 PluginFocusChanged(instance, false); |
| 765 } | 767 } |
| 766 | 768 |
| 767 scoped_ptr< ::ppapi::thunk::ResourceCreationAPI> | 769 scoped_ptr< ::ppapi::thunk::ResourceCreationAPI> |
| 768 PepperPluginDelegateImpl::CreateResourceCreationAPI( | 770 PepperPluginDelegateImpl::CreateResourceCreationAPI( |
| 769 webkit::ppapi::PluginInstance* instance) { | 771 webkit::ppapi::PluginInstanceImpl* instance) { |
| 770 RendererPpapiHostImpl* host_impl = static_cast<RendererPpapiHostImpl*>( | 772 RendererPpapiHostImpl* host_impl = static_cast<RendererPpapiHostImpl*>( |
| 771 instance->module()->GetEmbedderState()); | 773 instance->module()->GetEmbedderState()); |
| 772 return host_impl->CreateInProcessResourceCreationAPI(instance); | 774 return host_impl->CreateInProcessResourceCreationAPI(instance); |
| 773 } | 775 } |
| 774 | 776 |
| 775 SkBitmap* PepperPluginDelegateImpl::GetSadPluginBitmap() { | 777 SkBitmap* PepperPluginDelegateImpl::GetSadPluginBitmap() { |
| 776 return GetContentClient()->renderer()->GetSadPluginBitmap(); | 778 return GetContentClient()->renderer()->GetSadPluginBitmap(); |
| 777 } | 779 } |
| 778 | 780 |
| 779 WebKit::WebPlugin* PepperPluginDelegateImpl::CreatePluginReplacement( | 781 WebKit::WebPlugin* PepperPluginDelegateImpl::CreatePluginReplacement( |
| 780 const base::FilePath& file_path) { | 782 const base::FilePath& file_path) { |
| 781 return GetContentClient()->renderer()->CreatePluginReplacement( | 783 return GetContentClient()->renderer()->CreatePluginReplacement( |
| 782 render_view_, file_path); | 784 render_view_, file_path); |
| 783 } | 785 } |
| 784 | 786 |
| 785 webkit::ppapi::PluginDelegate::PlatformImage2D* | 787 webkit::ppapi::PluginDelegate::PlatformImage2D* |
| 786 PepperPluginDelegateImpl::CreateImage2D(int width, int height) { | 788 PepperPluginDelegateImpl::CreateImage2D(int width, int height) { |
| 787 return PepperPlatformImage2DImpl::Create(width, height); | 789 return PepperPlatformImage2DImpl::Create(width, height); |
| 788 } | 790 } |
| 789 | 791 |
| 790 webkit::ppapi::PluginDelegate::PlatformGraphics2D* | 792 webkit::ppapi::PluginDelegate::PlatformGraphics2D* |
| 791 PepperPluginDelegateImpl::GetGraphics2D( | 793 PepperPluginDelegateImpl::GetGraphics2D( |
| 792 webkit::ppapi::PluginInstance* instance, | 794 webkit::ppapi::PluginInstanceImpl* instance, |
| 793 PP_Resource resource) { | 795 PP_Resource resource) { |
| 794 ppapi::host::ResourceHost* host = | 796 ppapi::host::ResourceHost* host = |
| 795 GetRendererResourceHost(instance->pp_instance(), resource); | 797 GetRendererResourceHost(instance->pp_instance(), resource); |
| 796 if (!host) | 798 if (!host) |
| 797 return NULL; | 799 return NULL; |
| 798 PepperGraphics2DHost* result = host->AsPepperGraphics2DHost(); | 800 PepperGraphics2DHost* result = host->AsPepperGraphics2DHost(); |
| 799 DLOG_IF(ERROR, !result) << "Resource is not PepperGraphics2DHost."; | 801 DLOG_IF(ERROR, !result) << "Resource is not PepperGraphics2DHost."; |
| 800 return result; | 802 return result; |
| 801 } | 803 } |
| 802 | 804 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 callback->Run(error_code, base::PassPlatformFile(&file)); | 953 callback->Run(error_code, base::PassPlatformFile(&file)); |
| 952 // Make sure we won't leak file handle if the requester has died. | 954 // Make sure we won't leak file handle if the requester has died. |
| 953 if (file != base::kInvalidPlatformFileValue) | 955 if (file != base::kInvalidPlatformFileValue) |
| 954 base::FileUtilProxy::Close(GetFileThreadMessageLoopProxy().get(), | 956 base::FileUtilProxy::Close(GetFileThreadMessageLoopProxy().get(), |
| 955 file, | 957 file, |
| 956 base::FileUtilProxy::StatusCallback()); | 958 base::FileUtilProxy::StatusCallback()); |
| 957 delete callback; | 959 delete callback; |
| 958 } | 960 } |
| 959 | 961 |
| 960 void PepperPluginDelegateImpl::OnSetFocus(bool has_focus) { | 962 void PepperPluginDelegateImpl::OnSetFocus(bool has_focus) { |
| 961 for (std::set<webkit::ppapi::PluginInstance*>::iterator i = | 963 for (std::set<webkit::ppapi::PluginInstanceImpl*>::iterator i = |
| 962 active_instances_.begin(); | 964 active_instances_.begin(); |
| 963 i != active_instances_.end(); ++i) | 965 i != active_instances_.end(); ++i) |
| 964 (*i)->SetContentAreaFocus(has_focus); | 966 (*i)->SetContentAreaFocus(has_focus); |
| 965 } | 967 } |
| 966 | 968 |
| 967 void PepperPluginDelegateImpl::PageVisibilityChanged(bool is_visible) { | 969 void PepperPluginDelegateImpl::PageVisibilityChanged(bool is_visible) { |
| 968 for (std::set<webkit::ppapi::PluginInstance*>::iterator i = | 970 for (std::set<webkit::ppapi::PluginInstanceImpl*>::iterator i = |
| 969 active_instances_.begin(); | 971 active_instances_.begin(); |
| 970 i != active_instances_.end(); ++i) | 972 i != active_instances_.end(); ++i) |
| 971 (*i)->PageVisibilityChanged(is_visible); | 973 (*i)->PageVisibilityChanged(is_visible); |
| 972 } | 974 } |
| 973 | 975 |
| 974 bool PepperPluginDelegateImpl::IsPluginFocused() const { | 976 bool PepperPluginDelegateImpl::IsPluginFocused() const { |
| 975 return focused_plugin_ != NULL; | 977 return focused_plugin_ != NULL; |
| 976 } | 978 } |
| 977 | 979 |
| 978 void PepperPluginDelegateImpl::WillHandleMouseEvent() { | 980 void PepperPluginDelegateImpl::WillHandleMouseEvent() { |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1259 const std::vector<char>& der, | 1261 const std::vector<char>& der, |
| 1260 ppapi::PPB_X509Certificate_Fields* fields) { | 1262 ppapi::PPB_X509Certificate_Fields* fields) { |
| 1261 bool succeeded = false; | 1263 bool succeeded = false; |
| 1262 render_view_->Send( | 1264 render_view_->Send( |
| 1263 new PpapiHostMsg_PPBX509Certificate_ParseDER(der, &succeeded, fields)); | 1265 new PpapiHostMsg_PPBX509Certificate_ParseDER(der, &succeeded, fields)); |
| 1264 return succeeded; | 1266 return succeeded; |
| 1265 } | 1267 } |
| 1266 | 1268 |
| 1267 webkit::ppapi::FullscreenContainer* | 1269 webkit::ppapi::FullscreenContainer* |
| 1268 PepperPluginDelegateImpl::CreateFullscreenContainer( | 1270 PepperPluginDelegateImpl::CreateFullscreenContainer( |
| 1269 webkit::ppapi::PluginInstance* instance) { | 1271 webkit::ppapi::PluginInstanceImpl* instance) { |
| 1270 return render_view_->CreatePepperFullscreenContainer(instance); | 1272 return render_view_->CreatePepperFullscreenContainer(instance); |
| 1271 } | 1273 } |
| 1272 | 1274 |
| 1273 gfx::Size PepperPluginDelegateImpl::GetScreenSize() { | 1275 gfx::Size PepperPluginDelegateImpl::GetScreenSize() { |
| 1274 WebKit::WebScreenInfo info = render_view_->screenInfo(); | 1276 WebKit::WebScreenInfo info = render_view_->screenInfo(); |
| 1275 return gfx::Size(info.rect.width, info.rect.height); | 1277 return gfx::Size(info.rect.width, info.rect.height); |
| 1276 } | 1278 } |
| 1277 | 1279 |
| 1278 std::string PepperPluginDelegateImpl::GetDefaultEncoding() { | 1280 std::string PepperPluginDelegateImpl::GetDefaultEncoding() { |
| 1279 return render_view_->webkit_preferences().default_encoding; | 1281 return render_view_->webkit_preferences().default_encoding; |
| 1280 } | 1282 } |
| 1281 | 1283 |
| 1282 void PepperPluginDelegateImpl::ZoomLimitsChanged(double minimum_factor, | 1284 void PepperPluginDelegateImpl::ZoomLimitsChanged(double minimum_factor, |
| 1283 double maximum_factor) { | 1285 double maximum_factor) { |
| 1284 double minimum_level = WebView::zoomFactorToZoomLevel(minimum_factor); | 1286 double minimum_level = WebView::zoomFactorToZoomLevel(minimum_factor); |
| 1285 double maximum_level = WebView::zoomFactorToZoomLevel(maximum_factor); | 1287 double maximum_level = WebView::zoomFactorToZoomLevel(maximum_factor); |
| 1286 render_view_->webview()->zoomLimitsChanged(minimum_level, maximum_level); | 1288 render_view_->webview()->zoomLimitsChanged(minimum_level, maximum_level); |
| 1287 } | 1289 } |
| 1288 | 1290 |
| 1289 void PepperPluginDelegateImpl::HandleDocumentLoad( | 1291 void PepperPluginDelegateImpl::HandleDocumentLoad( |
| 1290 webkit::ppapi::PluginInstance* instance, | 1292 webkit::ppapi::PluginInstanceImpl* instance, |
| 1291 const WebKit::WebURLResponse& response) { | 1293 const WebKit::WebURLResponse& response) { |
| 1292 DCHECK(!instance->document_loader()); | 1294 DCHECK(!instance->document_loader()); |
| 1293 | 1295 |
| 1294 PP_Instance pp_instance = instance->pp_instance(); | 1296 PP_Instance pp_instance = instance->pp_instance(); |
| 1295 RendererPpapiHostImpl* host_impl = static_cast<RendererPpapiHostImpl*>( | 1297 RendererPpapiHostImpl* host_impl = static_cast<RendererPpapiHostImpl*>( |
| 1296 instance->module()->GetEmbedderState()); | 1298 instance->module()->GetEmbedderState()); |
| 1297 | 1299 |
| 1298 // Create a loader resource host for this load. Note that we have to set | 1300 // Create a loader resource host for this load. Note that we have to set |
| 1299 // the document_loader before issuing the in-process | 1301 // the document_loader before issuing the in-process |
| 1300 // PPP_Instance.HandleDocumentLoad call below, since this may reentrantly | 1302 // PPP_Instance.HandleDocumentLoad call below, since this may reentrantly |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1365 base::SharedMemory* PepperPluginDelegateImpl::CreateAnonymousSharedMemory( | 1367 base::SharedMemory* PepperPluginDelegateImpl::CreateAnonymousSharedMemory( |
| 1366 size_t size) { | 1368 size_t size) { |
| 1367 return RenderThread::Get()->HostAllocateSharedMemoryBuffer(size).release(); | 1369 return RenderThread::Get()->HostAllocateSharedMemoryBuffer(size).release(); |
| 1368 } | 1370 } |
| 1369 | 1371 |
| 1370 ppapi::Preferences PepperPluginDelegateImpl::GetPreferences() { | 1372 ppapi::Preferences PepperPluginDelegateImpl::GetPreferences() { |
| 1371 return ppapi::Preferences(render_view_->webkit_preferences()); | 1373 return ppapi::Preferences(render_view_->webkit_preferences()); |
| 1372 } | 1374 } |
| 1373 | 1375 |
| 1374 bool PepperPluginDelegateImpl::LockMouse( | 1376 bool PepperPluginDelegateImpl::LockMouse( |
| 1375 webkit::ppapi::PluginInstance* instance) { | 1377 webkit::ppapi::PluginInstanceImpl* instance) { |
| 1376 return GetMouseLockDispatcher(instance)->LockMouse( | 1378 return GetMouseLockDispatcher(instance)->LockMouse( |
| 1377 GetOrCreateLockTargetAdapter(instance)); | 1379 GetOrCreateLockTargetAdapter(instance)); |
| 1378 } | 1380 } |
| 1379 | 1381 |
| 1380 void PepperPluginDelegateImpl::UnlockMouse( | 1382 void PepperPluginDelegateImpl::UnlockMouse( |
| 1381 webkit::ppapi::PluginInstance* instance) { | 1383 webkit::ppapi::PluginInstanceImpl* instance) { |
| 1382 GetMouseLockDispatcher(instance)->UnlockMouse( | 1384 GetMouseLockDispatcher(instance)->UnlockMouse( |
| 1383 GetOrCreateLockTargetAdapter(instance)); | 1385 GetOrCreateLockTargetAdapter(instance)); |
| 1384 } | 1386 } |
| 1385 | 1387 |
| 1386 bool PepperPluginDelegateImpl::IsMouseLocked( | 1388 bool PepperPluginDelegateImpl::IsMouseLocked( |
| 1387 webkit::ppapi::PluginInstance* instance) { | 1389 webkit::ppapi::PluginInstanceImpl* instance) { |
| 1388 return GetMouseLockDispatcher(instance)->IsMouseLockedTo( | 1390 return GetMouseLockDispatcher(instance)->IsMouseLockedTo( |
| 1389 GetOrCreateLockTargetAdapter(instance)); | 1391 GetOrCreateLockTargetAdapter(instance)); |
| 1390 } | 1392 } |
| 1391 | 1393 |
| 1392 void PepperPluginDelegateImpl::DidChangeCursor( | 1394 void PepperPluginDelegateImpl::DidChangeCursor( |
| 1393 webkit::ppapi::PluginInstance* instance, | 1395 webkit::ppapi::PluginInstanceImpl* instance, |
| 1394 const WebKit::WebCursorInfo& cursor) { | 1396 const WebKit::WebCursorInfo& cursor) { |
| 1395 // Update the cursor appearance immediately if the requesting plugin is the | 1397 // Update the cursor appearance immediately if the requesting plugin is the |
| 1396 // one which receives the last mouse event. Otherwise, the new cursor won't be | 1398 // one which receives the last mouse event. Otherwise, the new cursor won't be |
| 1397 // picked up until the plugin gets the next input event. That is bad if, e.g., | 1399 // picked up until the plugin gets the next input event. That is bad if, e.g., |
| 1398 // the plugin would like to set an invisible cursor when there isn't any user | 1400 // the plugin would like to set an invisible cursor when there isn't any user |
| 1399 // input for a while. | 1401 // input for a while. |
| 1400 if (instance == last_mouse_event_target_) | 1402 if (instance == last_mouse_event_target_) |
| 1401 render_view_->didChangeCursor(cursor); | 1403 render_view_->didChangeCursor(cursor); |
| 1402 } | 1404 } |
| 1403 | 1405 |
| 1404 void PepperPluginDelegateImpl::DidReceiveMouseEvent( | 1406 void PepperPluginDelegateImpl::DidReceiveMouseEvent( |
| 1405 webkit::ppapi::PluginInstance* instance) { | 1407 webkit::ppapi::PluginInstanceImpl* instance) { |
| 1406 last_mouse_event_target_ = instance; | 1408 last_mouse_event_target_ = instance; |
| 1407 } | 1409 } |
| 1408 | 1410 |
| 1409 bool PepperPluginDelegateImpl::IsInFullscreenMode() { | 1411 bool PepperPluginDelegateImpl::IsInFullscreenMode() { |
| 1410 return render_view_->is_fullscreen(); | 1412 return render_view_->is_fullscreen(); |
| 1411 } | 1413 } |
| 1412 | 1414 |
| 1413 void PepperPluginDelegateImpl::SampleGamepads(WebKit::WebGamepads* data) { | 1415 void PepperPluginDelegateImpl::SampleGamepads(WebKit::WebGamepads* data) { |
| 1414 if (!gamepad_shared_memory_reader_) | 1416 if (!gamepad_shared_memory_reader_) |
| 1415 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); | 1417 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1641 NOTREACHED(); | 1643 NOTREACHED(); |
| 1642 return 0; | 1644 return 0; |
| 1643 } | 1645 } |
| 1644 #else | 1646 #else |
| 1645 return 0; | 1647 return 0; |
| 1646 #endif | 1648 #endif |
| 1647 } | 1649 } |
| 1648 | 1650 |
| 1649 MouseLockDispatcher::LockTarget* | 1651 MouseLockDispatcher::LockTarget* |
| 1650 PepperPluginDelegateImpl::GetOrCreateLockTargetAdapter( | 1652 PepperPluginDelegateImpl::GetOrCreateLockTargetAdapter( |
| 1651 webkit::ppapi::PluginInstance* instance) { | 1653 webkit::ppapi::PluginInstanceImpl* instance) { |
| 1652 MouseLockDispatcher::LockTarget* target = mouse_lock_instances_[instance]; | 1654 MouseLockDispatcher::LockTarget* target = mouse_lock_instances_[instance]; |
| 1653 if (target) | 1655 if (target) |
| 1654 return target; | 1656 return target; |
| 1655 | 1657 |
| 1656 return mouse_lock_instances_[instance] = | 1658 return mouse_lock_instances_[instance] = |
| 1657 new PluginInstanceLockTarget(instance); | 1659 new PluginInstanceLockTarget(instance); |
| 1658 } | 1660 } |
| 1659 | 1661 |
| 1660 void PepperPluginDelegateImpl::UnSetAndDeleteLockTargetAdapter( | 1662 void PepperPluginDelegateImpl::UnSetAndDeleteLockTargetAdapter( |
| 1661 webkit::ppapi::PluginInstance* instance) { | 1663 webkit::ppapi::PluginInstanceImpl* instance) { |
| 1662 LockTargetMap::iterator it = mouse_lock_instances_.find(instance); | 1664 LockTargetMap::iterator it = mouse_lock_instances_.find(instance); |
| 1663 if (it != mouse_lock_instances_.end()) { | 1665 if (it != mouse_lock_instances_.end()) { |
| 1664 MouseLockDispatcher::LockTarget* target = it->second; | 1666 MouseLockDispatcher::LockTarget* target = it->second; |
| 1665 GetMouseLockDispatcher(instance)->OnLockTargetDestroyed(target); | 1667 GetMouseLockDispatcher(instance)->OnLockTargetDestroyed(target); |
| 1666 delete target; | 1668 delete target; |
| 1667 mouse_lock_instances_.erase(it); | 1669 mouse_lock_instances_.erase(it); |
| 1668 } | 1670 } |
| 1669 } | 1671 } |
| 1670 | 1672 |
| 1671 MouseLockDispatcher* PepperPluginDelegateImpl::GetMouseLockDispatcher( | 1673 MouseLockDispatcher* PepperPluginDelegateImpl::GetMouseLockDispatcher( |
| 1672 webkit::ppapi::PluginInstance* instance) { | 1674 webkit::ppapi::PluginInstanceImpl* instance) { |
| 1673 if (instance->flash_fullscreen()) { | 1675 if (instance->flash_fullscreen()) { |
| 1674 RenderWidgetFullscreenPepper* container = | 1676 RenderWidgetFullscreenPepper* container = |
| 1675 static_cast<RenderWidgetFullscreenPepper*>( | 1677 static_cast<RenderWidgetFullscreenPepper*>( |
| 1676 instance->fullscreen_container()); | 1678 instance->fullscreen_container()); |
| 1677 return container->mouse_lock_dispatcher(); | 1679 return container->mouse_lock_dispatcher(); |
| 1678 } else { | 1680 } else { |
| 1679 return render_view_->mouse_lock_dispatcher(); | 1681 return render_view_->mouse_lock_dispatcher(); |
| 1680 } | 1682 } |
| 1681 } | 1683 } |
| 1682 | 1684 |
| 1683 IPC::PlatformFileForTransit PepperPluginDelegateImpl::ShareHandleWithRemote( | 1685 IPC::PlatformFileForTransit PepperPluginDelegateImpl::ShareHandleWithRemote( |
| 1684 base::PlatformFile handle, | 1686 base::PlatformFile handle, |
| 1685 base::ProcessId target_process_id, | 1687 base::ProcessId target_process_id, |
| 1686 bool should_close_source) const { | 1688 bool should_close_source) const { |
| 1687 return BrokerGetFileHandleForProcess( | 1689 return BrokerGetFileHandleForProcess( |
| 1688 handle, | 1690 handle, |
| 1689 target_process_id, | 1691 target_process_id, |
| 1690 should_close_source); | 1692 should_close_source); |
| 1691 } | 1693 } |
| 1692 | 1694 |
| 1693 bool PepperPluginDelegateImpl::IsRunningInProcess(PP_Instance instance) const { | 1695 bool PepperPluginDelegateImpl::IsRunningInProcess(PP_Instance instance) const { |
| 1694 RendererPpapiHostImpl* host = | 1696 RendererPpapiHostImpl* host = |
| 1695 RendererPpapiHostImpl::GetForPPInstance(instance); | 1697 RendererPpapiHostImpl::GetForPPInstance(instance); |
| 1696 return host && host->IsRunningInProcess(); | 1698 return host && host->IsRunningInProcess(); |
| 1697 } | 1699 } |
| 1698 | 1700 |
| 1699 } // namespace content | 1701 } // namespace content |
| OLD | NEW |