diff options
Diffstat (limited to 'chrome')
19 files changed, 240 insertions, 196 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host_view.h b/chrome/browser/renderer_host/render_widget_host_view.h index b022f7e..508be27 100644 --- a/chrome/browser/renderer_host/render_widget_host_view.h +++ b/chrome/browser/renderer_host/render_widget_host_view.h @@ -70,7 +70,7 @@ class RenderWidgetHostView { // Moves all plugin windows as described in the given list. virtual void MovePluginWindows( - const std::vector<WebPluginGeometry>& plugin_window_moves) = 0; + const std::vector<webkit_glue::WebPluginGeometry>& moves) = 0; // Actually set/take focus to/from the associated View component. virtual void Focus() = 0; diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc index 159e1cd..ec6be0f 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc @@ -403,9 +403,9 @@ gfx::NativeView RenderWidgetHostViewGtk::GetNativeView() { } void RenderWidgetHostViewGtk::MovePluginWindows( - const std::vector<WebPluginGeometry>& plugin_window_moves) { - for (size_t i = 0; i < plugin_window_moves.size(); ++i) { - plugin_container_manager_.MovePluginContainer(plugin_window_moves[i]); + const std::vector<webkit_glue::WebPluginGeometry>& moves) { + for (size_t i = 0; i < moves.size(); ++i) { + plugin_container_manager_.MovePluginContainer(moves[i]); } } diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.h b/chrome/browser/renderer_host/render_widget_host_view_gtk.h index 95b8c2d..9f5c76d 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.h +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.h @@ -45,7 +45,7 @@ class RenderWidgetHostViewGtk : public RenderWidgetHostView { virtual void SetSize(const gfx::Size& size); virtual gfx::NativeView GetNativeView(); virtual void MovePluginWindows( - const std::vector<WebPluginGeometry>& plugin_window_moves); + const std::vector<webkit_glue::WebPluginGeometry>& moves); virtual void Focus(); virtual void Blur(); virtual bool HasFocus(); diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.h b/chrome/browser/renderer_host/render_widget_host_view_mac.h index 7c6ece5..1633a52 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.h +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.h @@ -84,7 +84,7 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { virtual void SetSize(const gfx::Size& size); virtual gfx::NativeView GetNativeView(); virtual void MovePluginWindows( - const std::vector<WebPluginGeometry>& plugin_window_moves); + const std::vector<webkit_glue::WebPluginGeometry>& moves); virtual void Focus(); virtual void Blur(); virtual bool HasFocus(); diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm index 1010475..fef480b 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm @@ -149,7 +149,7 @@ gfx::NativeView RenderWidgetHostViewMac::GetNativeView() { } void RenderWidgetHostViewMac::MovePluginWindows( - const std::vector<WebPluginGeometry>& plugin_window_moves) { + const std::vector<webkit_glue::WebPluginGeometry>& moves) { // All plugin stuff is TBD. TODO(avi,awalker): fill in // http://crbug.com/8192 } diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc index 8409006..6838e08 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc @@ -40,11 +40,11 @@ using base::TimeDelta; using base::TimeTicks; - using WebKit::WebInputEvent; using WebKit::WebInputEventFactory; using WebKit::WebMouseEvent; using WebKit::WebTextDirection; +using webkit_glue::WebPluginGeometry; namespace { diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.h b/chrome/browser/renderer_host/render_widget_host_view_win.h index 751dbb2..5bfbd86 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.h +++ b/chrome/browser/renderer_host/render_widget_host_view_win.h @@ -114,7 +114,7 @@ class RenderWidgetHostViewWin : virtual void SetSize(const gfx::Size& size); virtual gfx::NativeView GetNativeView(); virtual void MovePluginWindows( - const std::vector<WebPluginGeometry>& plugin_window_moves); + const std::vector<webkit_glue::WebPluginGeometry>& moves); virtual void Focus(); virtual void Blur(); virtual bool HasFocus(); diff --git a/chrome/browser/renderer_host/test/test_render_view_host.h b/chrome/browser/renderer_host/test/test_render_view_host.h index 537c149..18a6db7 100644 --- a/chrome/browser/renderer_host/test/test_render_view_host.h +++ b/chrome/browser/renderer_host/test/test_render_view_host.h @@ -48,7 +48,7 @@ class TestRenderWidgetHostView : public RenderWidgetHostView { virtual void SetSize(const gfx::Size& size) {} virtual gfx::NativeView GetNativeView() { return NULL; } virtual void MovePluginWindows( - const std::vector<WebPluginGeometry>& plugin_window_moves) {} + const std::vector<webkit_glue::WebPluginGeometry>& moves) {} #if defined(OS_WIN) virtual void ForwardMouseEventToRenderer(UINT message, WPARAM wparam, diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index b1b21ec..16a2037 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -197,7 +197,7 @@ struct ViewHostMsg_PaintRect_Params { gfx::Size view_size; // New window locations for plugin child windows. - std::vector<WebPluginGeometry> plugin_window_moves; + std::vector<webkit_glue::WebPluginGeometry> plugin_window_moves; // The following describes the various bits that may be set in flags: // @@ -234,7 +234,7 @@ struct ViewHostMsg_ScrollRect_Params { gfx::Size view_size; // New window locations for plugin child windows. - std::vector<WebPluginGeometry> plugin_window_moves; + std::vector<webkit_glue::WebPluginGeometry> plugin_window_moves; }; // Parameters structure for ViewMsg_UploadFile. @@ -1060,8 +1060,8 @@ struct ParamTraits<ViewHostMsg_ScrollRect_Params> { }; template <> -struct ParamTraits<WebPluginGeometry> { - typedef WebPluginGeometry param_type; +struct ParamTraits<webkit_glue::WebPluginGeometry> { + typedef webkit_glue::WebPluginGeometry param_type; static void Write(Message* m, const param_type& p) { WriteParam(m, p.window); WriteParam(m, p.window_rect); diff --git a/chrome/plugin/webplugin_delegate_stub.cc b/chrome/plugin/webplugin_delegate_stub.cc index fda6909..65bdfdc 100644 --- a/chrome/plugin/webplugin_delegate_stub.cc +++ b/chrome/plugin/webplugin_delegate_stub.cc @@ -25,6 +25,9 @@ using WebKit::WebBindings; using WebKit::WebCursorInfo; +using webkit_glue::WebPlugin; +using webkit_glue::WebPluginDelegate; +using webkit_glue::WebPluginResourceClient; class FinishDestructionTask : public Task { public: @@ -152,15 +155,16 @@ void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params, // PluginThread::current()->Send(new PluginProcessHostMsg_MapNativeViewId( // params.containing_window, &parent)); #endif - delegate_ = WebPluginDelegate::Create(path, mime_type_, parent); - if (delegate_) { - webplugin_ = new WebPluginProxy( - channel_, instance_id_, delegate_, page_url_); + webplugin_ = new WebPluginProxy(channel_, instance_id_, page_url_); #if defined(OS_WIN) - if (!webplugin_->SetModalDialogEvent(params.modal_dialog_event)) - return; + if (!webplugin_->SetModalDialogEvent(params.modal_dialog_event)) + return; #endif + + delegate_ = WebPluginDelegate::Create(path, mime_type_, parent); + if (delegate_) { + webplugin_->set_delegate(delegate_); *result = delegate_->Initialize( params.url, argn, argv, argc, webplugin_, params.load_manually); } diff --git a/chrome/plugin/webplugin_delegate_stub.h b/chrome/plugin/webplugin_delegate_stub.h index d0c6542..34cde08 100644 --- a/chrome/plugin/webplugin_delegate_stub.h +++ b/chrome/plugin/webplugin_delegate_stub.h @@ -18,7 +18,6 @@ class PluginChannel; class WebPluginProxy; -class WebPluginDelegate; struct PluginMsg_Init_Params; struct PluginMsg_DidReceiveResponseParams; struct PluginMsg_URLRequestReply_Params; @@ -28,6 +27,10 @@ namespace WebKit { class WebInputEvent; } +namespace webkit_glue { +class WebPluginDelegate; +} + // Converts the IPC messages from WebPluginDelegateProxy into calls to the // actual WebPluginDelegate object. class WebPluginDelegateStub : public IPC::Channel::Listener, @@ -99,7 +102,7 @@ class WebPluginDelegateStub : public IPC::Channel::Listener, scoped_refptr<PluginChannel> channel_; - WebPluginDelegate* delegate_; + webkit_glue::WebPluginDelegate* delegate_; WebPluginProxy* webplugin_; // The url of the main frame hosting the plugin. diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc index 1684785..739fc74 100644 --- a/chrome/plugin/webplugin_proxy.cc +++ b/chrome/plugin/webplugin_proxy.cc @@ -34,6 +34,8 @@ #endif using WebKit::WebBindings; +using webkit_glue::WebPluginDelegate; +using webkit_glue::WebPluginResourceClient; typedef std::map<CPBrowsingContext, WebPluginProxy*> ContextMap; static ContextMap& GetContextMap() { @@ -43,14 +45,13 @@ static ContextMap& GetContextMap() { WebPluginProxy::WebPluginProxy( PluginChannel* channel, int route_id, - WebPluginDelegate* delegate, const GURL& page_url) : channel_(channel), route_id_(route_id), cp_browsing_context_(0), window_npobject_(NULL), plugin_element_(NULL), - delegate_(delegate), + delegate_(NULL), waiting_for_paint_(false), page_url_(page_url), ALLOW_THIS_IN_INITIALIZER_LIST(runnable_method_factory_(this)) diff --git a/chrome/plugin/webplugin_proxy.h b/chrome/plugin/webplugin_proxy.h index 8e13638..6297f24 100644 --- a/chrome/plugin/webplugin_proxy.h +++ b/chrome/plugin/webplugin_proxy.h @@ -22,25 +22,29 @@ #include "ipc/ipc_message.h" #include "webkit/glue/webplugin.h" +class PluginChannel; + namespace base { class WaitableEvent; } -class PluginChannel; +namespace webkit_glue { class WebPluginDelegate; +} // This is an implementation of WebPlugin that proxies all calls to the // renderer. -class WebPluginProxy : public WebPlugin { +class WebPluginProxy : public webkit_glue::WebPlugin { public: // Creates a new proxy for WebPlugin, using the given sender to send the // marshalled WebPlugin calls. WebPluginProxy(PluginChannel* channel, int route_id, - WebPluginDelegate* delegate, const GURL& page_url); ~WebPluginProxy(); + void set_delegate(webkit_glue::WebPluginDelegate* d) { delegate_ = d; } + // WebPlugin overrides void SetWindow(gfx::PluginWindowHandle window); void WillDestroyWindow(gfx::PluginWindowHandle window); @@ -83,7 +87,7 @@ class WebPluginProxy : public WebPlugin { // Returns a WebPluginResourceClient object given its id, or NULL if no // object with that id exists. - WebPluginResourceClient* GetResourceClient(int id); + webkit_glue::WebPluginResourceClient* GetResourceClient(int id); // Returns the process id of the renderer that contains this plugin. int GetRendererProcessId(); @@ -122,7 +126,8 @@ class WebPluginProxy : public WebPlugin { bool IsOffTheRecord(); - void ResourceClientDeleted(WebPluginResourceClient* resource_client); + void ResourceClientDeleted( + webkit_glue::WebPluginResourceClient* resource_client); base::WaitableEvent* modal_dialog_event() { return modal_dialog_event_.get(); @@ -151,7 +156,8 @@ class WebPluginProxy : public WebPlugin { // transform of the local HDC. void UpdateTransform(); - typedef base::hash_map<int, WebPluginResourceClient*> ResourceClientMap; + typedef base::hash_map<int, webkit_glue::WebPluginResourceClient*> + ResourceClientMap; ResourceClientMap resource_clients_; scoped_refptr<PluginChannel> channel_; @@ -159,7 +165,7 @@ class WebPluginProxy : public WebPlugin { uint32 cp_browsing_context_; NPObject* window_npobject_; NPObject* plugin_element_; - WebPluginDelegate* delegate_; + webkit_glue::WebPluginDelegate* delegate_; gfx::Rect damaged_rect_; bool waiting_for_paint_; scoped_ptr<base::WaitableEvent> modal_dialog_event_; diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index c76c31a..e0015e8 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -88,6 +88,7 @@ #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webmediaplayer_impl.h" #include "webkit/glue/webplugin_delegate.h" +#include "webkit/glue/webplugin_impl.h" #include "webkit/glue/webview.h" #if defined(OS_WIN) @@ -191,7 +192,6 @@ RenderView::RenderView(RenderThreadBase* render_thread, last_indexed_page_id_(-1), opened_by_user_gesture_(true), ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), - first_default_plugin_(NULL), devtools_agent_(NULL), devtools_client_(NULL), history_back_list_count_(0), @@ -216,13 +216,6 @@ RenderView::~RenderView() { if (decrement_shared_popup_at_destruction_) shared_popup_counter_->data--; - // Clear any back-pointers that might still be held by plugins. - PluginDelegateList::iterator it = plugin_delegates_.begin(); - while (it != plugin_delegates_.end()) { - (*it)->DropRenderView(); - it = plugin_delegates_.erase(it); - } - render_thread_->RemoveFilter(audio_message_filter_); } @@ -256,25 +249,11 @@ void RenderView::SetNextPageID(int32 next_page_id) { next_page_id_ = next_page_id; } -void RenderView::PluginDestroyed(WebPluginDelegateProxy* proxy) { - PluginDelegateList::iterator it = - std::find(plugin_delegates_.begin(), plugin_delegates_.end(), proxy); - DCHECK(it != plugin_delegates_.end()); - plugin_delegates_.erase(it); - // If the plugin is deleted, we need to clear our reference in case user - // clicks the info bar to install. Unfortunately we are getting - // PluginDestroyed in single process mode. However, that is not a huge - // concern. - if (proxy == first_default_plugin_) - first_default_plugin_ = NULL; -} - void RenderView::PluginCrashed(base::ProcessId pid, const FilePath& plugin_path) { Send(new ViewHostMsg_CrashedPlugin(routing_id_, pid, plugin_path)); } - void RenderView::JSOutOfMemory() { Send(new ViewHostMsg_JSOutOfMemory(routing_id_)); } @@ -1070,7 +1049,7 @@ void RenderView::DidStartLoading(WebView* webview) { is_loading_ = true; // Clear the pointer so that we can assign it only when there is an unknown // plugin on a page. - first_default_plugin_ = NULL; + first_default_plugin_.reset(); Send(new ViewHostMsg_DidStartLoading(routing_id_)); } @@ -1784,16 +1763,6 @@ void RenderView::OnPopupNotificationVisibilityChanged(bool visible) { popup_notification_visible_ = visible; } -void RenderView::ShowModalHTMLDialog(const GURL& url, int width, int height, - const std::string& json_arguments, - std::string* json_retval) { - IPC::SyncMessage* msg = new ViewHostMsg_ShowModalHTMLDialog( - routing_id_, url, width, height, json_arguments, json_retval); - - msg->set_pump_messages_event(modal_dialog_event_.get()); - Send(msg); -} - uint32 RenderView::GetCPBrowsingContext() { uint32 context = 0; Send(new ViewHostMsg_GetCPBrowsingContext(&context)); @@ -1911,51 +1880,9 @@ WebWidget* RenderView::CreatePopupWidgetWithInfo(WebView* webview, return widget->webwidget(); } -WebPluginDelegate* RenderView::CreatePluginDelegate( - WebView* webview, - const GURL& url, - const std::string& mime_type, - const std::string& clsid, - std::string* actual_mime_type) { - if (!PluginChannelHost::IsListening()) - return NULL; - - GURL policy_url; - if (webview->GetMainFrame()) - policy_url = webview->GetMainFrame()->url(); - - FilePath path; - render_thread_->Send( - new ViewHostMsg_GetPluginPath(url, policy_url, mime_type, clsid, &path, - actual_mime_type)); - if (path.value().empty()) - return NULL; - - std::string mime_type_to_use; - if (!actual_mime_type->empty()) - mime_type_to_use = *actual_mime_type; - else - mime_type_to_use = mime_type; - - if (RenderProcess::current()->in_process_plugins()) { -#if defined(OS_WIN) // In-proc plugins aren't supported on Linux or Mac. - return WebPluginDelegate::Create(path, - mime_type_to_use, - gfx::NativeViewFromId(host_window_)); -#else - NOTIMPLEMENTED(); - return NULL; -#endif - } - - WebPluginDelegateProxy* proxy = - WebPluginDelegateProxy::Create(url, mime_type_to_use, clsid, this); - if (!proxy) - return NULL; - - plugin_delegates_.push_back(proxy); - - return proxy; +WebKit::WebPlugin* RenderView::CreatePlugin( + WebFrame* frame, const WebKit::WebPluginParams& params) { + return new webkit_glue::WebPluginImpl(frame, params, AsWeakPtr()); } WebKit::WebMediaPlayer* RenderView::CreateWebMediaPlayer( @@ -1993,13 +1920,14 @@ WebKit::WebMediaPlayer* RenderView::CreateWebMediaPlayer( return new webkit_glue::WebMediaPlayerImpl(client, factory); } -void RenderView::OnMissingPluginStatus(WebPluginDelegate* delegate, - int status) { +void RenderView::OnMissingPluginStatus( + WebPluginDelegateProxy* delegate, + int status) { #if defined(OS_WIN) - if (first_default_plugin_ == NULL) { + if (!first_default_plugin_) { // Show the InfoBar for the first available plugin. if (status == default_plugin::MISSING_PLUGIN_AVAILABLE) { - first_default_plugin_ = delegate; + first_default_plugin_ = delegate->AsWeakPtr(); Send(new ViewHostMsg_MissingPluginStatus(routing_id_, status)); } } else { @@ -2087,6 +2015,88 @@ void RenderView::runModal() { Send(msg); } +webkit_glue::WebPluginDelegate* RenderView::CreatePluginDelegate( + const GURL& url, + const std::string& mime_type, + const std::string& clsid, + std::string* actual_mime_type) { + if (!PluginChannelHost::IsListening()) + return NULL; + + GURL policy_url; + WebFrame* main_frame = webview()->GetMainFrame(); + if (main_frame) + policy_url = main_frame->url(); + + FilePath path; + render_thread_->Send( + new ViewHostMsg_GetPluginPath(url, policy_url, mime_type, clsid, &path, + actual_mime_type)); + if (path.value().empty()) + return NULL; + + const std::string* mime_type_to_use; + if (!actual_mime_type->empty()) + mime_type_to_use = actual_mime_type; + else + mime_type_to_use = &mime_type; + + if (RenderProcess::current()->in_process_plugins()) { +#if defined(OS_WIN) // In-proc plugins aren't supported on Linux or Mac. + return webkit_glue::WebPluginDelegate::Create( + path, *mime_type_to_use, gfx::NativeViewFromId(host_window_)); +#else + NOTIMPLEMENTED(); + return NULL; +#endif + } + + return WebPluginDelegateProxy::Create( + url, *mime_type_to_use, clsid, AsWeakPtr()); +} + +void RenderView::CreatedPluginWindow(gfx::PluginWindowHandle window) { +#if defined(OS_LINUX) + RenderThread::current()->Send(new ViewHostMsg_CreatePluginContainer( + routing_id(), window)); +#endif +} + +void RenderView::WillDestroyPluginWindow(gfx::PluginWindowHandle window) { +#if defined(OS_LINUX) + RenderThread::current()->Send(new ViewHostMsg_DestroyPluginContainer( + routing_id(), window)); +#endif + CleanupWindowInPluginMoves(window); +} + +void RenderView::DidMovePlugin(const webkit_glue::WebPluginGeometry& move) { + SchedulePluginMove(move); +} + +void RenderView::DidStartLoadingForPlugin() { + // TODO(darin): Make is_loading_ be a counter! + DidStartLoading(webview()); +} + +void RenderView::DidStopLoadingForPlugin() { + // TODO(darin): Make is_loading_ be a counter! + DidStopLoading(webview()); +} + +void RenderView::ShowModalHTMLDialogForPlugin( + const GURL& url, + const gfx::Size& size, + const std::string& json_arguments, + std::string* json_retval) { + IPC::SyncMessage* msg = new ViewHostMsg_ShowModalHTMLDialog( + routing_id_, url, size.width(), size.height(), json_arguments, + json_retval); + + msg->set_pump_messages_event(modal_dialog_event_.get()); + Send(msg); +} + void RenderView::SyncNavigationState() { if (!webview()) return; @@ -2742,9 +2752,8 @@ void RenderView::OnSetAltErrorPageURL(const GURL& url) { void RenderView::OnInstallMissingPlugin() { // This could happen when the first default plugin is deleted. - if (first_default_plugin_ == NULL) - return; - first_default_plugin_->InstallMissingPlugin(); + if (first_default_plugin_) + first_default_plugin_->InstallMissingPlugin(); } void RenderView::OnFileChooserResponse( @@ -3297,25 +3306,6 @@ void RenderView::FocusAccessibilityObject( #endif } -void RenderView::DidMovePlugin(const WebPluginGeometry& move) { - SchedulePluginMove(move); -} - -void RenderView::CreatedPluginWindow(gfx::PluginWindowHandle window) { -#if defined(OS_LINUX) - RenderThread::current()->Send(new ViewHostMsg_CreatePluginContainer( - routing_id(), window)); -#endif -} - -void RenderView::WillDestroyPluginWindow(gfx::PluginWindowHandle window) { -#if defined(OS_LINUX) - RenderThread::current()->Send(new ViewHostMsg_DestroyPluginContainer( - routing_id(), window)); -#endif - CleanupWindowInPluginMoves(window); -} - void RenderView::SendPasswordForms(WebFrame* frame) { WebVector<WebForm> forms; frame->forms(forms); diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 7317385..83518cd 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -17,6 +17,7 @@ #include "base/shared_memory.h" #include "base/timer.h" #include "base/values.h" +#include "base/weak_ptr.h" #include "build/build_config.h" #include "chrome/common/renderer_preferences.h" #include "chrome/common/view_types.h" @@ -33,6 +34,7 @@ #include "webkit/glue/form_data.h" #include "webkit/glue/password_form_dom_manager.h" #include "webkit/glue/webaccessibilitymanager.h" +#include "webkit/glue/webplugin_page_delegate.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webview_delegate.h" #include "webkit/glue/webview.h" @@ -53,7 +55,6 @@ class GURL; class ListValue; class NavigationState; class PrintWebViewHelper; -class WebPluginDelegate; class WebPluginDelegateProxy; class WebDevToolsAgentDelegate; struct ContextMenuMediaParams; @@ -98,11 +99,14 @@ typedef base::RefCountedData<int> SharedRenderViewCounter; // class RenderView : public RenderWidget, public WebViewDelegate, - public webkit_glue::DomSerializerDelegate { + public webkit_glue::WebPluginPageDelegate, + public webkit_glue::DomSerializerDelegate, + public base::SupportsWeakPtr<RenderView> { public: struct RenderViewSet { - std::set<RenderView* > render_view_set_; + std::set<RenderView*> render_view_set_; }; + // Creates a new RenderView. The parent_hwnd specifies a HWND to use as the // parent of the WebView HWND that will be created. The modal_dialog_event // is set by the RenderView whenever a modal dialog alert is shown, so that @@ -150,9 +154,6 @@ class RenderView : public RenderWidget, // WebViewDelegate virtual bool CanAcceptLoadDrops() const; - virtual void ShowModalHTMLDialog(const GURL& url, int width, int height, - const std::string& json_arguments, - std::string* json_retval); virtual void RunJavaScriptAlert(WebKit::WebFrame* webframe, const std::wstring& message); virtual bool RunJavaScriptConfirm(WebKit::WebFrame* webframe, @@ -263,16 +264,15 @@ class RenderView : public RenderWidget, virtual WebKit::WebWidget* CreatePopupWidgetWithInfo( WebView* webview, const WebKit::WebPopupMenuInfo& info); - virtual WebPluginDelegate* CreatePluginDelegate( - WebView* webview, - const GURL& url, - const std::string& mime_type, - const std::string& clsid, - std::string* actual_mime_type); + virtual WebKit::WebPlugin* CreatePlugin( + WebKit::WebFrame* frame, + const WebKit::WebPluginParams& params); virtual WebKit::WebWorker* CreateWebWorker(WebKit::WebWorkerClient* client); virtual WebKit::WebMediaPlayer* CreateWebMediaPlayer( WebKit::WebMediaPlayerClient* client); - virtual void OnMissingPluginStatus(WebPluginDelegate* delegate, int status); + virtual void OnMissingPluginStatus( + WebPluginDelegateProxy* delegate, + int status); virtual void OpenURL(WebView* webview, const GURL& url, const GURL& referrer, WebKit::WebNavigationPolicy policy); @@ -327,9 +327,6 @@ class RenderView : public RenderWidget, const WebKit::WebRect& selection); virtual bool WasOpenedByUserGesture() const; virtual void FocusAccessibilityObject(WebCore::AccessibilityObject* acc_obj); - virtual void DidMovePlugin(const WebPluginGeometry& move); - virtual void CreatedPluginWindow(gfx::PluginWindowHandle handle); - virtual void WillDestroyPluginWindow(gfx::PluginWindowHandle handle); virtual void SpellCheck(const std::wstring& word, int* misspell_location, int* misspell_length); virtual std::wstring GetAutoCorrectWord(const std::wstring& word); @@ -338,22 +335,36 @@ class RenderView : public RenderWidget, virtual void UserMetricsRecordAction(const std::wstring& action); virtual void DnsPrefetch(const std::vector<std::string>& host_names); - // DomSerializerDelegate - virtual void DidSerializeDataForFrame(const GURL& frame_url, - const std::string& data, PageSavingSerializationStatus status); - // WebKit::WebWidgetClient // Most methods are handled by RenderWidget. virtual void show(WebKit::WebNavigationPolicy policy); virtual void closeWidgetSoon(); virtual void runModal(); + // WebPluginPageDelegate: + virtual webkit_glue::WebPluginDelegate* CreatePluginDelegate( + const GURL& url, + const std::string& mime_type, + const std::string& clsid, + std::string* actual_mime_type); + virtual void CreatedPluginWindow(gfx::PluginWindowHandle handle); + virtual void WillDestroyPluginWindow(gfx::PluginWindowHandle handle); + virtual void DidMovePlugin(const webkit_glue::WebPluginGeometry& move); + virtual void DidStartLoadingForPlugin(); + virtual void DidStopLoadingForPlugin(); + virtual void ShowModalHTMLDialogForPlugin( + const GURL& url, + const gfx::Size& size, + const std::string& json_arguments, + std::string* json_retval); + + // DomSerializerDelegate + virtual void DidSerializeDataForFrame(const GURL& frame_url, + const std::string& data, PageSavingSerializationStatus status); + // Do not delete directly. This class is reference counted. virtual ~RenderView(); - // Called when a plugin is destroyed. - void PluginDestroyed(WebPluginDelegateProxy* proxy); - // Called when a plugin has crashed. void PluginCrashed(base::ProcessId pid, const FilePath& plugin_path); @@ -754,12 +765,9 @@ class RenderView : public RenderWidget, // Timer used to delay the updating of nav state (see SyncNavigationState). base::OneShotTimer<RenderView> nav_state_sync_timer_; - typedef std::vector<WebPluginDelegateProxy*> PluginDelegateList; - PluginDelegateList plugin_delegates_; - // Remember the first uninstalled plugin, so that we can ask the plugin // to install itself when user clicks on the info bar. - WebPluginDelegate* first_default_plugin_; + base::WeakPtr<webkit_glue::WebPluginDelegate> first_default_plugin_; // If the browser hasn't sent us an ACK for the last FindReply we sent // to it, then we need to queue up the message (keeping only the most diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc index fa97dda..f668896 100644 --- a/chrome/renderer/render_widget.cc +++ b/chrome/renderer/render_widget.cc @@ -879,7 +879,8 @@ WebScreenInfo RenderWidget::screenInfo() { return results; } -void RenderWidget::SchedulePluginMove(const WebPluginGeometry& move) { +void RenderWidget::SchedulePluginMove( + const webkit_glue::WebPluginGeometry& move) { size_t i = 0; for (; i < plugin_window_moves_.size(); ++i) { if (plugin_window_moves_[i].window == move.window) { diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h index f8580ce..38dfad8 100644 --- a/chrome/renderer/render_widget.h +++ b/chrome/renderer/render_widget.h @@ -25,12 +25,15 @@ class RenderThreadBase; struct ViewHostMsg_ShowPopup_Params; -struct WebPluginGeometry; namespace WebKit { struct WebPopupMenuInfo; } +namespace webkit_glue { +struct WebPluginGeometry; +} + // RenderWidget provides a communication bridge between a WebWidget and // a RenderWidgetHost, the latter of which lives in a different process. class RenderWidget : public IPC::Channel::Listener, @@ -84,7 +87,7 @@ class RenderWidget : public IPC::Channel::Listener, // Called when a plugin is moved. These events are queued up and sent with // the next paint or scroll message to the host. - void SchedulePluginMove(const WebPluginGeometry& move); + void SchedulePluginMove(const webkit_glue::WebPluginGeometry& move); // Called when a plugin window has been destroyed, to make sure the currently // pending moves don't try to reference it. @@ -297,7 +300,7 @@ class RenderWidget : public IPC::Channel::Listener, bool activatable_; // Holds all the needed plugin window moves for a scroll. - typedef std::vector<WebPluginGeometry> WebPluginGeometryVector; + typedef std::vector<webkit_glue::WebPluginGeometry> WebPluginGeometryVector; WebPluginGeometryVector plugin_window_moves_; // A custom background for the widget. diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index 2068a50..66cf1c6 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -59,7 +59,7 @@ using WebKit::WebString; // Proxy for WebPluginResourceClient. The object owns itself after creation, // deleting itself after its callback has been called. -class ResourceClientProxy : public WebPluginResourceClient { +class ResourceClientProxy : public webkit_glue::WebPluginResourceClient { public: ResourceClientProxy(PluginChannelHost* channel, int instance_id) : channel_(channel), instance_id_(instance_id), resource_id_(0), @@ -162,13 +162,14 @@ WebPluginDelegateProxy* WebPluginDelegateProxy::Create( const GURL& url, const std::string& mime_type, const std::string& clsid, - RenderView* render_view) { + const base::WeakPtr<RenderView>& render_view) { return new WebPluginDelegateProxy(mime_type, clsid, render_view); } -WebPluginDelegateProxy::WebPluginDelegateProxy(const std::string& mime_type, - const std::string& clsid, - RenderView* render_view) +WebPluginDelegateProxy::WebPluginDelegateProxy( + const std::string& mime_type, + const std::string& clsid, + const base::WeakPtr<RenderView>& render_view) : render_view_(render_view), plugin_(NULL), windowless_(false), @@ -221,13 +222,12 @@ void WebPluginDelegateProxy::PluginDestroyed() { channel_host_ = NULL; } - render_view_->PluginDestroyed(this); MessageLoop::current()->DeleteSoon(FROM_HERE, this); } bool WebPluginDelegateProxy::Initialize(const GURL& url, char** argn, char** argv, int argc, - WebPlugin* plugin, + webkit_glue::WebPlugin* plugin, bool load_manually) { IPC::ChannelHandle channel_handle; FilePath plugin_path; @@ -881,9 +881,10 @@ void WebPluginDelegateProxy::OnShowModalHTMLDialog( const GURL& url, int width, int height, const std::string& json_arguments, std::string* json_retval) { DCHECK(json_retval); - if (render_view_) - render_view_->ShowModalHTMLDialog(url, width, height, json_arguments, - json_retval); + if (render_view_) { + render_view_->ShowModalHTMLDialogForPlugin( + url, gfx::Size(width, height), json_arguments, json_retval); + } } static void EncodeDragData(const WebDragData& data, bool add_data, @@ -1048,7 +1049,8 @@ void WebPluginDelegateProxy::OnHandleURLRequest( params.popups_allowed); } -WebPluginResourceClient* WebPluginDelegateProxy::CreateResourceClient( +webkit_glue::WebPluginResourceClient* +WebPluginDelegateProxy::CreateResourceClient( int resource_id, const GURL& url, bool notify_needed, intptr_t notify_data, intptr_t npstream) { ResourceClientProxy* proxy = new ResourceClientProxy(channel_host_, @@ -1057,6 +1059,26 @@ WebPluginResourceClient* WebPluginDelegateProxy::CreateResourceClient( return proxy; } +bool WebPluginDelegateProxy::IsWindowless() const { + NOTREACHED(); + return false; +} + +gfx::Rect WebPluginDelegateProxy::GetRect() const { + NOTREACHED(); + return gfx::Rect(); +} + +gfx::Rect WebPluginDelegateProxy::GetClipRect() const { + NOTREACHED(); + return gfx::Rect(); +} + +int WebPluginDelegateProxy::GetQuirks() const { + NOTREACHED(); + return 0; +} + void WebPluginDelegateProxy::OnCancelDocumentLoad() { plugin_->CancelDocumentLoad(); } diff --git a/chrome/renderer/webplugin_delegate_proxy.h b/chrome/renderer/webplugin_delegate_proxy.h index 61dfa8b..45ffb8d 100644 --- a/chrome/renderer/webplugin_delegate_proxy.h +++ b/chrome/renderer/webplugin_delegate_proxy.h @@ -12,6 +12,7 @@ #include "base/gfx/rect.h" #include "base/gfx/native_widget_types.h" #include "base/ref_counted.h" +#include "base/weak_ptr.h" #include "chrome/common/transport_dib.h" #include "chrome/renderer/plugin_channel_host.h" #include "googleurl/src/gurl.h" @@ -34,17 +35,17 @@ class WaitableEvent; // An implementation of WebPluginDelegate that proxies all calls to // the plugin process. -class WebPluginDelegateProxy : public WebPluginDelegate, - public IPC::Channel::Listener, - public IPC::Message::Sender { +class WebPluginDelegateProxy : + public webkit_glue::WebPluginDelegate, + public IPC::Channel::Listener, + public IPC::Message::Sender, + public base::SupportsWeakPtr<WebPluginDelegateProxy> { public: - static WebPluginDelegateProxy* Create(const GURL& url, - const std::string& mime_type, - const std::string& clsid, - RenderView* render_view); - - // Called to drop our back-pointer to the containing RenderView. - void DropRenderView() { render_view_ = NULL; } + static WebPluginDelegateProxy* Create( + const GURL& url, + const std::string& mime_type, + const std::string& clsid, + const base::WeakPtr<RenderView>& render_view); // Called to drop our pointer to the window script object. void DropWindowScriptObject() { window_script_object_ = NULL; } @@ -52,7 +53,7 @@ class WebPluginDelegateProxy : public WebPluginDelegate, // WebPluginDelegate implementation: virtual void PluginDestroyed(); virtual bool Initialize(const GURL& url, char** argn, char** argv, int argc, - WebPlugin* plugin, bool load_manually); + webkit_glue::WebPlugin* plugin, bool load_manually); virtual void UpdateGeometry(const gfx::Rect& window_rect, const gfx::Rect& clip_rect); virtual void Paint(gfx::NativeDrawingContext context, const gfx::Rect& rect); @@ -87,11 +88,16 @@ class WebPluginDelegateProxy : public WebPluginDelegate, virtual void DidManualLoadFail(); virtual FilePath GetPluginPath(); virtual void InstallMissingPlugin(); - virtual WebPluginResourceClient* CreateResourceClient(int resource_id, - const GURL& url, - bool notify_needed, - intptr_t notify_data, - intptr_t existing_stream); + virtual webkit_glue::WebPluginResourceClient* CreateResourceClient( + int resource_id, + const GURL& url, + bool notify_needed, + intptr_t notify_data, + intptr_t existing_stream); + virtual bool IsWindowless() const; + virtual gfx::Rect GetRect() const; + virtual gfx::Rect GetClipRect() const; + virtual int GetQuirks() const; protected: template<class WebPluginDelegateProxy> friend class DeleteTask; @@ -100,7 +106,7 @@ class WebPluginDelegateProxy : public WebPluginDelegate, private: WebPluginDelegateProxy(const std::string& mime_type, const std::string& clsid, - RenderView* render_view); + const base::WeakPtr<RenderView>& render_view); // Message handlers for messages that proxy WebPlugin methods, which // we translate into calls to the real WebPlugin. @@ -161,8 +167,8 @@ class WebPluginDelegateProxy : public WebPluginDelegate, // point the window has already been destroyed). void WillDestroyWindow(); - RenderView* render_view_; - WebPlugin* plugin_; + base::WeakPtr<RenderView> render_view_; + webkit_glue::WebPlugin* plugin_; bool windowless_; gfx::PluginWindowHandle window_; scoped_refptr<PluginChannelHost> channel_host_; |