diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-01 01:48:52 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-01 01:48:52 +0000 |
commit | 829c2841a0e30b9f08453566ffc52d2c386a9045 (patch) | |
tree | b916ff2699e97a13f027d3e2cb60be781c0e18c8 /webkit | |
parent | 5c0b8e45fa1260f311d71073c8a9b89db199d992 (diff) | |
download | chromium_src-829c2841a0e30b9f08453566ffc52d2c386a9045.zip chromium_src-829c2841a0e30b9f08453566ffc52d2c386a9045.tar.gz chromium_src-829c2841a0e30b9f08453566ffc52d2c386a9045.tar.bz2 |
Port plugin messages.
Review URL: http://codereview.chromium.org/49050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12928 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/plugins/plugin_host.cc | 27 | ||||
-rw-r--r-- | webkit/glue/plugins/plugin_instance.cc | 11 | ||||
-rw-r--r-- | webkit/glue/plugins/plugin_instance.h | 7 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl.cc | 29 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl.h | 8 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl_gtk.cc | 16 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl_mac.cc | 16 | ||||
-rw-r--r-- | webkit/glue/webplugin.h | 18 | ||||
-rw-r--r-- | webkit/glue/webplugin_delegate.h | 8 | ||||
-rw-r--r-- | webkit/glue/webplugin_impl.cc | 20 | ||||
-rw-r--r-- | webkit/glue/webplugin_impl.h | 15 |
11 files changed, 82 insertions, 93 deletions
diff --git a/webkit/glue/plugins/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc index b0c199a..b87160a 100644 --- a/webkit/glue/plugins/plugin_host.cc +++ b/webkit/glue/plugins/plugin_host.cc @@ -340,16 +340,10 @@ static NPError GetURLNotify(NPP id, scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); if (plugin.get()) { - plugin->webplugin()->HandleURLRequest("GET", - is_javascript_url, - target, - 0, - 0, - false, - notify, - url, - notify_data, - plugin->popups_allowed()); + plugin->webplugin()->HandleURLRequest( + "GET", is_javascript_url, target, 0, 0, false, + notify, url, reinterpret_cast<intptr_t>(notify_data), + plugin->popups_allowed()); } else { NOTREACHED(); return NPERR_GENERIC_ERROR; @@ -485,16 +479,9 @@ static NPError PostURLNotify(NPP id, // Unfortunately, our stream needs these broken apart, // so we need to parse the data and set headers and data // separately. - plugin->webplugin()->HandleURLRequest("POST", - is_javascript_url, - target, - len, - buf, - false, - notify, - url, - notify_data, - plugin->popups_allowed()); + plugin->webplugin()->HandleURLRequest( + "POST", is_javascript_url, target, len, buf, false, notify, url, + reinterpret_cast<intptr_t>(notify_data), plugin->popups_allowed()); return NPERR_NO_ERROR; } diff --git a/webkit/glue/plugins/plugin_instance.cc b/webkit/glue/plugins/plugin_instance.cc index 6738435..f8c1814 100644 --- a/webkit/glue/plugins/plugin_instance.cc +++ b/webkit/glue/plugins/plugin_instance.cc @@ -167,7 +167,7 @@ NPObject *PluginInstance::GetPluginScriptableObject() { } void PluginInstance::SetURLLoadData(const GURL& url, - void* notify_data) { + intptr_t notify_data) { get_url_ = url; get_notify_data_ = notify_data; } @@ -175,7 +175,8 @@ void PluginInstance::SetURLLoadData(const GURL& url, // WebPluginLoadDelegate methods void PluginInstance::DidFinishLoadWithReason(NPReason reason) { if (!get_url_.is_empty()) { - NPP_URLNotify(get_url_.spec().c_str(), reason, get_notify_data_); + NPP_URLNotify(get_url_.spec().c_str(), reason, + reinterpret_cast<void*>(get_notify_data_)); } get_url_ = GURL(); @@ -351,7 +352,7 @@ void PluginInstance::SendJavaScriptStream(const std::string& url, const std::wstring& result, bool success, bool notify_needed, - int notify_data) { + intptr_t notify_data) { if (success) { PluginStringStream *stream = new PluginStringStream(this, url, notify_needed, @@ -505,9 +506,9 @@ void PluginInstance::RequestRead(NPStream* stream, NPByteRange* range_list) { webplugin_->InitiateHTTPRangeRequest( stream->url, range_info.c_str(), - plugin_stream, + reinterpret_cast<intptr_t>(plugin_stream), plugin_stream->notify_needed(), - plugin_stream->notify_data()); + reinterpret_cast<intptr_t>(plugin_stream->notify_data())); break; } } diff --git a/webkit/glue/plugins/plugin_instance.h b/webkit/glue/plugins/plugin_instance.h index e973717..2c3bb49 100644 --- a/webkit/glue/plugins/plugin_instance.h +++ b/webkit/glue/plugins/plugin_instance.h @@ -138,7 +138,7 @@ class PluginInstance : public base::RefCountedThreadSafe<PluginInstance> { // Helper method to set some persistent data for getURLNotify since // resource fetches happen async. - void SetURLLoadData(const GURL& url, void* notify_data); + void SetURLLoadData(const GURL& url, intptr_t notify_data); // If true, send the Mozilla user agent instead of Chrome's to the plugin. bool use_mozilla_user_agent() { return use_mozilla_user_agent_; } @@ -166,7 +166,8 @@ class PluginInstance : public base::RefCountedThreadSafe<PluginInstance> { bool NPP_Print(NPPrint* platform_print); void SendJavaScriptStream(const std::string& url, const std::wstring& result, - bool success, bool notify_needed, int notify_data); + bool success, bool notify_needed, + intptr_t notify_data); void DidReceiveManualResponse(const std::string& url, const std::string& mime_type, @@ -231,7 +232,7 @@ class PluginInstance : public base::RefCountedThreadSafe<PluginInstance> { WebPlugin* webplugin_; std::string mime_type_; GURL get_url_; - void* get_notify_data_; + intptr_t get_notify_data_; bool use_mozilla_user_agent_; #if defined(OS_WIN) scoped_refptr<MozillaExtensionApi> mozilla_extenstions_; diff --git a/webkit/glue/plugins/webplugin_delegate_impl.cc b/webkit/glue/plugins/webplugin_delegate_impl.cc index 3d18525..87d02cb 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.cc +++ b/webkit/glue/plugins/webplugin_delegate_impl.cc @@ -253,6 +253,13 @@ bool WebPluginDelegateImpl::Initialize(const GURL& url, return false; windowless_ = instance_->windowless(); + if (!windowless_) { + if (!WindowedCreatePlugin()) + return false; + } + + windowed_manage_position_ = plugin->SetWindow(windowed_handle_); +#if defined(OS_WIN) if (windowless_) { // For windowless plugins we should set the containing window handle // as the instance window handle. This is what Safari does. Not having @@ -262,13 +269,9 @@ bool WebPluginDelegateImpl::Initialize(const GURL& url, instance_->set_window_handle(parent_); CreateDummyWindowForActivation(); handle_event_pump_messages_event_ = CreateEvent(NULL, TRUE, FALSE, NULL); - } else { - if (!WindowedCreatePlugin()) - return false; + plugin->SetWindowlessPumpEvent(handle_event_pump_messages_event_); } - - windowed_manage_position_ = - plugin->SetWindow(windowed_handle_, handle_event_pump_messages_event_); +#endif plugin_url_ = url.spec(); // The windowless version of the Silverlight plugin calls the @@ -382,7 +385,7 @@ void WebPluginDelegateImpl::SendJavaScriptStream(const std::string& url, const std::wstring& result, bool success, bool notify_needed, - int notify_data) { + intptr_t notify_data) { instance()->SendJavaScriptStream(url, result, success, notify_needed, notify_data); } @@ -1090,7 +1093,7 @@ bool WebPluginDelegateImpl::HandleEvent(NPEvent* event, WebPluginResourceClient* WebPluginDelegateImpl::CreateResourceClient( int resource_id, const std::string &url, bool notify_needed, - void *notify_data, void* existing_stream) { + intptr_t notify_data, intptr_t existing_stream) { // Stream already exists. This typically happens for range requests // initiated via NPN_RequestRead. if (existing_stream) { @@ -1106,17 +1109,15 @@ WebPluginResourceClient* WebPluginDelegateImpl::CreateResourceClient( instance()->SetURLLoadData(GURL(url.c_str()), notify_data); } std::string mime_type; - NPAPI::PluginStreamUrl *stream = instance()->CreateStream(resource_id, - url, - mime_type, - notify_needed, - notify_data); + NPAPI::PluginStreamUrl *stream = instance()->CreateStream( + resource_id, url, mime_type, notify_needed, + reinterpret_cast<void*>(notify_data)); return stream; } void WebPluginDelegateImpl::URLRequestRouted(const std::string&url, bool notify_needed, - void* notify_data) { + intptr_t notify_data) { if (notify_needed) { instance()->SetURLLoadData(GURL(url.c_str()), notify_data); } diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h index 74b0e13..a429e63 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.h +++ b/webkit/glue/plugins/webplugin_delegate_impl.h @@ -65,7 +65,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate { virtual void SendJavaScriptStream(const std::string& url, const std::wstring& result, bool success, bool notify_needed, - int notify_data); + intptr_t notify_data); virtual void DidReceiveManualResponse(const std::string& url, const std::string& mime_type, const std::string& headers, @@ -79,11 +79,11 @@ class WebPluginDelegateImpl : public WebPluginDelegate { virtual WebPluginResourceClient* CreateResourceClient(int resource_id, const std::string &url, bool notify_needed, - void *notify_data, - void* stream); + intptr_t notify_data, + intptr_t stream); virtual void URLRequestRouted(const std::string&url, bool notify_needed, - void* notify_data); + intptr_t notify_data); virtual bool IsWindowless() const { return windowless_ ; } virtual const gfx::Rect& GetRect() const { return window_rect_; } virtual const gfx::Rect& GetClipRect() const { return clip_rect_; } diff --git a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc index c77b61b..8d20186 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc +++ b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc @@ -128,7 +128,7 @@ bool WebPluginDelegateImpl::Initialize(const GURL& url, return false; } - plugin->SetWindow(windowed_handle_, /* unused event param */ NULL); + plugin->SetWindow(windowed_handle_); plugin_url_ = url.spec(); return true; @@ -197,7 +197,7 @@ void WebPluginDelegateImpl::SendJavaScriptStream(const std::string& url, const std::wstring& result, bool success, bool notify_needed, - int notify_data) { + intptr_t notify_data) { instance()->SendJavaScriptStream(url, result, success, notify_needed, notify_data); } @@ -653,7 +653,7 @@ bool WebPluginDelegateImpl::HandleEvent(NPEvent* event, WebPluginResourceClient* WebPluginDelegateImpl::CreateResourceClient( int resource_id, const std::string &url, bool notify_needed, - void *notify_data, void* existing_stream) { + intptr_t notify_data, intptr_t existing_stream) { // Stream already exists. This typically happens for range requests // initiated via NPN_RequestRead. if (existing_stream) { @@ -669,17 +669,15 @@ WebPluginResourceClient* WebPluginDelegateImpl::CreateResourceClient( instance()->SetURLLoadData(GURL(url.c_str()), notify_data); } std::string mime_type; - NPAPI::PluginStreamUrl *stream = instance()->CreateStream(resource_id, - url, - mime_type, - notify_needed, - notify_data); + NPAPI::PluginStreamUrl *stream = instance()->CreateStream( + resource_id, url, mime_type, notify_needed, + reinterpret_cast<void*>(notify_data)); return stream; } void WebPluginDelegateImpl::URLRequestRouted(const std::string&url, bool notify_needed, - void* notify_data) { + intptr_t notify_data) { if (notify_needed) { instance()->SetURLLoadData(GURL(url.c_str()), notify_data); } diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.cc b/webkit/glue/plugins/webplugin_delegate_impl_mac.cc index 7c806dc..f758ce0 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_mac.cc +++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.cc @@ -154,7 +154,7 @@ bool WebPluginDelegateImpl::Initialize(const GURL& url, return false; } - // plugin->SetWindow(windowed_handle_, handle_event_pump_messages_event_); + // plugin->SetWindow(windowed_handle_); plugin_url_ = url.spec(); return true; @@ -223,7 +223,7 @@ void WebPluginDelegateImpl::SendJavaScriptStream(const std::string& url, const std::wstring& result, bool success, bool notify_needed, - int notify_data) { + intptr_t notify_data) { instance()->SendJavaScriptStream(url, result, success, notify_needed, notify_data); } @@ -423,7 +423,7 @@ bool WebPluginDelegateImpl::HandleEvent(NPEvent* event, WebPluginResourceClient* WebPluginDelegateImpl::CreateResourceClient( int resource_id, const std::string &url, bool notify_needed, - void *notify_data, void* existing_stream) { + intptr_t notify_data, intptr_t existing_stream) { // Stream already exists. This typically happens for range requests // initiated via NPN_RequestRead. if (existing_stream) { @@ -439,17 +439,15 @@ WebPluginResourceClient* WebPluginDelegateImpl::CreateResourceClient( instance()->SetURLLoadData(GURL(url.c_str()), notify_data); } std::string mime_type; - NPAPI::PluginStreamUrl *stream = instance()->CreateStream(resource_id, - url, - mime_type, - notify_needed, - notify_data); + NPAPI::PluginStreamUrl *stream = instance()->CreateStream( + resource_id, url, mime_type, notify_needed, + reinterpret_cast<void*>(notify_data)); return stream; } void WebPluginDelegateImpl::URLRequestRouted(const std::string&url, bool notify_needed, - void* notify_data) { + intptr_t notify_data) { if (notify_needed) { instance()->SetURLLoadData(GURL(url.c_str()), notify_data); } diff --git a/webkit/glue/webplugin.h b/webkit/glue/webplugin.h index f78deaa..8c56100 100644 --- a/webkit/glue/webplugin.h +++ b/webkit/glue/webplugin.h @@ -86,15 +86,17 @@ class WebPlugin { // windowed (i.e. handle is not NULL) or windowless (handle is NULL). This // tells the WebPlugin to send mouse/keyboard events to the plugin delegate, // as well as the information about the HDC for paint operations. - // The pump_messages_event is a event handle which is valid only for - // windowless plugins and is used in NPP_HandleEvent calls to pump messages - // if the plugin enters a modal loop. // The return value is only valid for windowed plugins. If true, it means // that the the HWND position should be managed by the delegate. If false, // the plugin should be kept at the origin and it'll get moved elsewhere. - virtual bool SetWindow(gfx::NativeView window, - HANDLE pump_messages_event) = 0; + virtual bool SetWindow(gfx::NativeView window) = 0; +#if defined(OS_WIN) + // The pump_messages_event is a event handle which is valid only for + // windowless plugins and is used in NPP_HandleEvent calls to pump messages + // if the plugin enters a modal loop. // Cancels a pending request. + virtual void SetWindowlessPumpEvent(HANDLE pump_messages_event) = 0; +#endif virtual void CancelResource(int id) = 0; virtual void Invalidate() = 0; virtual void InvalidateRect(const gfx::Rect& rect) = 0; @@ -132,7 +134,7 @@ class WebPlugin { const char* target, unsigned int len, const char* buf, bool is_file_data, bool notify, const char* url, - void* notify_data, bool popups_allowed) = 0; + intptr_t notify_data, bool popups_allowed) = 0; // Cancels document load. virtual void CancelDocumentLoad() = 0; @@ -140,9 +142,9 @@ class WebPlugin { // Initiates a HTTP range request. virtual void InitiateHTTPRangeRequest(const char* url, const char* range_info, - void* existing_stream, + intptr_t existing_stream, bool notify_needed, - HANDLE notify_data) = 0; + intptr_t notify_data) = 0; // Returns true iff in off the record (Incognito) mode. virtual bool IsOffTheRecord() = 0; diff --git a/webkit/glue/webplugin_delegate.h b/webkit/glue/webplugin_delegate.h index 7f0f424..a6e711bd 100644 --- a/webkit/glue/webplugin_delegate.h +++ b/webkit/glue/webplugin_delegate.h @@ -105,7 +105,7 @@ class WebPluginDelegate { virtual void SendJavaScriptStream(const std::string& url, const std::wstring& result, bool success, bool notify_needed, - int notify_data) = 0; + intptr_t notify_data) = 0; // Receives notification about data being available. virtual void DidReceiveManualResponse(const std::string& url, @@ -133,12 +133,12 @@ class WebPluginDelegate { virtual WebPluginResourceClient* CreateResourceClient(int resource_id, const std::string &url, bool notify_needed, - void *notify_data, - void* stream) = 0; + intptr_t notify_data, + intptr_t stream) = 0; // Notifies the delegate about a Get/Post URL request getting routed. virtual void URLRequestRouted(const std::string&url, bool notify_needed, - void* notify_data) = 0; + intptr_t notify_data) = 0; virtual bool IsWindowless() const; diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc index e822cfc..f61bb16 100644 --- a/webkit/glue/webplugin_impl.cc +++ b/webkit/glue/webplugin_impl.cc @@ -336,8 +336,7 @@ WebPluginImpl::WebPluginImpl(WebCore::HTMLPlugInElement* element, WebPluginImpl::~WebPluginImpl() { } -bool WebPluginImpl::SetWindow(gfx::NativeView window, - HANDLE pump_messages_event) { +bool WebPluginImpl::SetWindow(gfx::NativeView window) { if (window) { DCHECK(!windowless_); // Make sure not called twice. window_ = window; @@ -366,7 +365,7 @@ bool WebPluginImpl::CompleteURL(const std::string& url_in, bool WebPluginImpl::ExecuteScript(const std::string& url, const std::wstring& script, bool notify_needed, - int notify_data, + intptr_t notify_data, bool popups_allowed) { // This could happen if the WebPluginContainer was already deleted. if (!frame()) @@ -1006,7 +1005,7 @@ void WebPluginImpl::didReceiveResponse(WebCore::ResourceHandle* handle, WebPluginResourceClient* resource_client = delegate_->CreateResourceClient(clients_[i].id, plugin_url_.spec().c_str(), - NULL, false, NULL); + false, 0, NULL); clients_[i].client = resource_client; client = resource_client; break; @@ -1151,7 +1150,7 @@ void WebPluginImpl::HandleURLRequest(const char *method, const char* target, unsigned int len, const char* buf, bool is_file_data, bool notify, const char* url, - void* notify_data, bool popups_allowed) { + intptr_t notify_data, bool popups_allowed) { HandleURLRequestInternal(method, is_javascript_url, target, len, buf, is_file_data, notify, url, notify_data, popups_allowed, true); @@ -1160,7 +1159,7 @@ void WebPluginImpl::HandleURLRequest(const char *method, void WebPluginImpl::HandleURLRequestInternal( const char *method, bool is_javascript_url, const char* target, unsigned int len, const char* buf, bool is_file_data, bool notify, - const char* url, void* notify_data, bool popups_allowed, + const char* url, intptr_t notify_data, bool popups_allowed, bool use_plugin_src_as_referrer) { // For this request, we either route the output to a frame // because a target has been specified, or we handle the request @@ -1190,9 +1189,8 @@ void WebPluginImpl::HandleURLRequestInternal( WebCore::String(escaped_script.data(), static_cast<int>(escaped_script.length()))); - ExecuteScript(original_url, - webkit_glue::StringToStdWString(script), notify, - reinterpret_cast<int>(notify_data), popups_allowed); + ExecuteScript(original_url, webkit_glue::StringToStdWString(script), notify, + notify_data, popups_allowed); } else { std::string complete_url_string; CompleteURL(url, &complete_url_string); @@ -1288,9 +1286,9 @@ void WebPluginImpl::CancelDocumentLoad() { void WebPluginImpl::InitiateHTTPRangeRequest(const char* url, const char* range_info, - HANDLE existing_stream, + intptr_t existing_stream, bool notify_needed, - HANDLE notify_data) { + int notify_data) { int resource_id = GetNextResourceId(); std::string complete_url_string; CompleteURL(url, &complete_url_string); diff --git a/webkit/glue/webplugin_impl.h b/webkit/glue/webplugin_impl.h index 8e0b6d2..a93b299 100644 --- a/webkit/glue/webplugin_impl.h +++ b/webkit/glue/webplugin_impl.h @@ -147,7 +147,10 @@ class WebPluginImpl : public WebPlugin, int arg_count, char** arg_names, char** arg_values); // WebPlugin implementation: - bool SetWindow(gfx::NativeView window, HANDLE pump_messages_event); + bool SetWindow(gfx::NativeView window); +#if defined(OS_WIN) + void SetWindowlessPumpEvent(HANDLE pump_messages_event) { } +#endif // Given a (maybe partial) url, completes using the base url. bool CompleteURL(const std::string& url_in, std::string* url_out); @@ -158,7 +161,7 @@ class WebPluginImpl : public WebPlugin, // plugin as is. This avoids having to track the notification arguments // in the plugin process. bool ExecuteScript(const std::string& url, const std::wstring& script, - bool notify_needed, int notify_data, bool popups_allowed); + bool notify_needed, intptr_t notify_data, bool popups_allowed); // Given a download request, check if we need to route the output // to a frame. Returns ROUTED if the load is done and routed to @@ -289,13 +292,13 @@ class WebPluginImpl : public WebPlugin, const char* target, unsigned int len, const char* buf, bool is_file_data, bool notify, const char* url, - void* notify_data, bool popups_allowed); + intptr_t notify_data, bool popups_allowed); void CancelDocumentLoad(); void InitiateHTTPRangeRequest(const char* url, const char* range_info, - HANDLE existing_stream, bool notify_needed, - HANDLE notify_data); + intptr_t existing_stream, bool notify_needed, + intptr_t notify_data); // Ignore in-process plugins mode for this flag. bool IsOffTheRecord() { return false; } @@ -309,7 +312,7 @@ class WebPluginImpl : public WebPlugin, const char* target, unsigned int len, const char* buf, bool is_file_data, bool notify, const char* url, - void* notify_data, bool popups_allowed, + intptr_t notify_data, bool popups_allowed, bool use_plugin_src_as_referrer); // Tears down the existing plugin instance and creates a new plugin instance |