diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-23 21:25:34 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-23 21:25:34 +0000 |
commit | 3bc58e70973f637a55e3e10563b5c274b90f020f (patch) | |
tree | 0cd130ef13004f9b16dc626df46c2554ca18d3e5 /webkit | |
parent | 68c73b083028bb08744fbb87faba45a9e2ab6614 (diff) | |
download | chromium_src-3bc58e70973f637a55e3e10563b5c274b90f020f.zip chromium_src-3bc58e70973f637a55e3e10563b5c274b90f020f.tar.gz chromium_src-3bc58e70973f637a55e3e10563b5c274b90f020f.tar.bz2 |
This fixes http://code.google.com/p/chromium/issues/detail?id=3585, which is an issue with videos on sites like thedailyshow.com not showing up in Chrome. We recently made a change to send out the plugin SRC as the referrer in requests initiated by plugins.We also use the GetURLNotify codepath for requests which are initiated by us when the plugin is instantiated. It looks like the other browsers don't do the same, and only use the SRC as the referer for explicit plugin requests.Based on a reply on the PluginFutures list we emulate this behavior, which is to default to the containing frame URL as the referer for requests not initiated by plugins.
R=jam
Review URL: http://codereview.chromium.org/7871
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3862 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/plugins/plugin_instance.cc | 11 | ||||
-rw-r--r-- | webkit/glue/plugins/plugin_instance.h | 4 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl.cc | 15 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl.h | 6 | ||||
-rw-r--r-- | webkit/glue/webplugin_impl.cc | 50 | ||||
-rw-r--r-- | webkit/glue/webplugin_impl.h | 20 |
6 files changed, 57 insertions, 49 deletions
diff --git a/webkit/glue/plugins/plugin_instance.cc b/webkit/glue/plugins/plugin_instance.cc index ca34639..893b6ec 100644 --- a/webkit/glue/plugins/plugin_instance.cc +++ b/webkit/glue/plugins/plugin_instance.cc @@ -74,17 +74,6 @@ PluginStreamUrl *PluginInstance::CreateStream(int resource_id, return stream; } -void PluginInstance::SendStream(const std::string &url, - bool notify_needed, - void *notify_data) { - if (notify_needed) { - host_->host_functions()->geturlnotify(npp(), url.c_str(), NULL, - notify_data); - } else { - host_->host_functions()->geturl(npp(), url.c_str(), NULL); - } -} - void PluginInstance::AddStream(PluginStream* stream) { open_streams_.push_back(stream); } diff --git a/webkit/glue/plugins/plugin_instance.h b/webkit/glue/plugins/plugin_instance.h index 824c557..6d0d610 100644 --- a/webkit/glue/plugins/plugin_instance.h +++ b/webkit/glue/plugins/plugin_instance.h @@ -113,10 +113,6 @@ class PluginInstance : public base::RefCounted<PluginInstance> { bool notify_needed, void *notify_data); - // Convenience function for sending a stream from a URL to this instance. - // URL can be a relative or a fully qualified url. - void SendStream(const std::string& url, bool notify_needed, - void* notify_data); // For each instance, we track all streams. When the // instance closes, all remaining streams are also // closed. All streams associated with this instance diff --git a/webkit/glue/plugins/webplugin_delegate_impl.cc b/webkit/glue/plugins/webplugin_delegate_impl.cc index fd97706..38fdde7 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.cc +++ b/webkit/glue/plugins/webplugin_delegate_impl.cc @@ -137,9 +137,7 @@ WebPluginDelegateImpl::WebPluginDelegateImpl( handle_event_depth_(0), user_gesture_message_posted_(false), #pragma warning(suppress: 4355) // can use this - user_gesture_msg_factory_(this), - load_manually_(false), - first_geometry_update_(true) { + user_gesture_msg_factory_(this) { memset(&window_, 0, sizeof(window_)); const WebPluginInfo& plugin_info = instance_->plugin_lib()->plugin_info(); @@ -243,7 +241,6 @@ bool WebPluginDelegateImpl::Initialize(const GURL& url, plugin->SetWindow(windowed_handle_, handle_event_pump_messages_event_); - load_manually_ = load_manually; plugin_url_ = url.spec(); return true; } @@ -279,16 +276,6 @@ void WebPluginDelegateImpl::UpdateGeometry( } else { WindowedUpdateGeometry(window_rect, clip_rect, cutout_rects, visible); } - - // Initiate a download on the plugin url. This should be done for the - // first update geometry sequence. - if (first_geometry_update_) { - first_geometry_update_ = false; - // An empty url corresponds to an EMBED tag with no src attribute. - if (!load_manually_ && !plugin_url_.empty()) { - instance_->SendStream(plugin_url_.c_str(), false, NULL); - } - } } void WebPluginDelegateImpl::Paint(HDC hdc, const gfx::Rect& rect) { diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h index 6240934..6d67dc7 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.h +++ b/webkit/glue/plugins/webplugin_delegate_impl.h @@ -261,12 +261,6 @@ class WebPluginDelegateImpl : public WebPluginDelegate { // The url with which the plugin was instantiated. std::string plugin_url_; - // Indicates if the download would be initiated by the plugin or us. - bool load_manually_; - - // Indicates whether a geometry update sequence is the first. - bool first_geometry_update_; - DISALLOW_EVIL_CONSTRUCTORS(WebPluginDelegateImpl); }; diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc index 3b8f9eb..2429c0b 100644 --- a/webkit/glue/webplugin_impl.cc +++ b/webkit/glue/webplugin_impl.cc @@ -258,7 +258,8 @@ WebCore::Widget* WebPluginImpl::Create(const GURL& url, WebFrameImpl *frame, WebPluginDelegate* delegate, bool load_manually) { - WebPluginImpl* webplugin = new WebPluginImpl(element, frame, delegate, url); + WebPluginImpl* webplugin = new WebPluginImpl(element, frame, delegate, url, + load_manually); if (!delegate->Initialize(url, argn, argv, argc, webplugin, load_manually)) { delegate->PluginDestroyed(); @@ -275,7 +276,8 @@ WebCore::Widget* WebPluginImpl::Create(const GURL& url, WebPluginImpl::WebPluginImpl(WebCore::Element* element, WebFrameImpl* webframe, WebPluginDelegate* delegate, - const GURL& plugin_url) + const GURL& plugin_url, + bool load_manually) : windowless_(false), window_(NULL), element_(element), @@ -285,7 +287,9 @@ WebPluginImpl::WebPluginImpl(WebCore::Element* element, visible_(false), received_first_paint_notification_(false), widget_(NULL), - plugin_url_(plugin_url) { + plugin_url_(plugin_url), + load_manually_(load_manually), + first_geometry_update_(true) { } WebPluginImpl::~WebPluginImpl() { @@ -645,6 +649,18 @@ void WebPluginImpl::setFrameGeometry(const WebCore::IntRect& rect) { force_geometry_update_ = false; delegate_->FlushGeometryUpdates(); } + + // Initiate a download on the plugin url. This should be done for the + // first update geometry sequence. + if (first_geometry_update_) { + first_geometry_update_ = false; + // An empty url corresponds to an EMBED tag with no src attribute. + if (!load_manually_ && plugin_url_.is_valid()) { + HandleURLRequestInternal("GET", false, NULL, 0, NULL, false, false, + plugin_url_.spec().c_str(), NULL, false, + false); + } + } } void WebPluginImpl::paint(WebCore::GraphicsContext* gc, @@ -1104,6 +1120,16 @@ void WebPluginImpl::HandleURLRequest(const char *method, const char* buf, bool is_file_data, bool notify, const char* url, void* notify_data, bool popups_allowed) { + HandleURLRequestInternal(method, is_javascript_url, target, len, buf, + is_file_data, notify, url, notify_data, + popups_allowed, true); +} + +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, + 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 // here, i.e. by executing the script if it is a javascript url @@ -1153,7 +1179,8 @@ void WebPluginImpl::HandleURLRequest(const char *method, } InitiateHTTPRequest(resource_id, resource_client, method, buf, len, - GURL(complete_url_string), NULL); + GURL(complete_url_string), NULL, + use_plugin_src_as_referrer); } } @@ -1167,7 +1194,8 @@ bool WebPluginImpl::InitiateHTTPRequest(int resource_id, const char* method, const char* buf, int buf_len, const GURL& url, - const char* range_info) { + const char* range_info, + bool use_plugin_src_as_referrer) { if (!client) { NOTREACHED(); return false; @@ -1188,12 +1216,12 @@ bool WebPluginImpl::InitiateHTTPRequest(int resource_id, info.request.addHTTPHeaderField("Range", range_info); WebCore::String referrer; - // If the plugin is instantiated without a SRC URL, then use the - // containing frame URL as the referrer. - if (plugin_url_.spec().empty()) { - referrer = frame()->loader()->outgoingReferrer(); - } else { + // GetURL/PostURL requests initiated explicitly by plugins should specify the + // plugin SRC url as the referrer if it is available. + if (use_plugin_src_as_referrer && !plugin_url_.spec().empty()) { referrer = webkit_glue::StdStringToString(plugin_url_.spec()); + } else { + referrer = frame()->loader()->outgoingReferrer(); } if (!WebCore::FrameLoader::shouldHideReferrer(kurl, referrer)) @@ -1233,7 +1261,7 @@ void WebPluginImpl::InitiateHTTPRangeRequest(const char* url, notify_needed, notify_data, existing_stream); InitiateHTTPRequest(resource_id, resource_client, "GET", NULL, 0, - GURL(complete_url_string), range_info); + GURL(complete_url_string), range_info, true); } void WebPluginImpl::HandleHttpMultipartResponse( diff --git a/webkit/glue/webplugin_impl.h b/webkit/glue/webplugin_impl.h index 70d4b89..b5473c5 100644 --- a/webkit/glue/webplugin_impl.h +++ b/webkit/glue/webplugin_impl.h @@ -131,7 +131,8 @@ class WebPluginImpl : public WebPlugin, friend class WebPluginContainer; WebPluginImpl(WebCore::Element *element, WebFrameImpl *frame, - WebPluginDelegate* delegate, const GURL& plugin_url); + WebPluginDelegate* delegate, const GURL& plugin_url, + bool load_manually); // WebPlugin implementation: void SetWindow(HWND window, HANDLE pump_messages_event); @@ -165,8 +166,8 @@ class WebPluginImpl : public WebPlugin, // Returns true on success. bool InitiateHTTPRequest(int resource_id, WebPluginResourceClient* client, const char* method, const char* buf, int buf_len, - const GURL& url, - const char* range_info); + const GURL& url, const char* range_info, + bool use_plugin_src_as_referer); gfx::Rect GetWindowClipRect(const gfx::Rect& rect); @@ -280,6 +281,13 @@ class WebPluginImpl : public WebPlugin, void HandleHttpMultipartResponse(const WebCore::ResourceResponse& response, WebPluginResourceClient* client); + void 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, + bool use_plugin_src_as_referrer); + struct ClientInfo { int id; WebPluginResourceClient* client; @@ -311,6 +319,12 @@ class WebPluginImpl : public WebPlugin, // The plugin source URL. GURL plugin_url_; + // Indicates if the download would be initiated by the plugin or us. + bool load_manually_; + + // Indicates if this is the first geometry update received by the plugin. + bool first_geometry_update_; + DISALLOW_COPY_AND_ASSIGN(WebPluginImpl); }; |