summaryrefslogtreecommitdiffstats
path: root/webkit/glue/plugins/plugin_instance.cc
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-23 00:34:27 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-23 00:34:27 +0000
commit65e82a56b3f1ca882db8c53f07781ecdc6cb7ece (patch)
treee224abcb3aa50320f55bf7a35bbf2e72ee0e0270 /webkit/glue/plugins/plugin_instance.cc
parent52426e4c3b775666fa9fd52e1c52f8dbbbaadd49 (diff)
downloadchromium_src-65e82a56b3f1ca882db8c53f07781ecdc6cb7ece.zip
chromium_src-65e82a56b3f1ca882db8c53f07781ecdc6cb7ece.tar.gz
chromium_src-65e82a56b3f1ca882db8c53f07781ecdc6cb7ece.tar.bz2
Implement NPAPI HTTP Redirect handling. This basically supports the NPAPI URL redirect
notifications which are sent out from the browser while processing URL requests issued by the plugin via the NPN_GetURLNotify and NPN_PostURLNotify APIs. For more info please see https://wiki.mozilla.org/NPAPI:HTTPRedirectHandling As part of this CL we also block cross origin 307 POST url redirects. Test=Covered by NPAPI UI test GetURLRedirectNotification Bug=63030,63698 Review URL: http://codereview.chromium.org/5228007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67029 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/plugins/plugin_instance.cc')
-rw-r--r--webkit/glue/plugins/plugin_instance.cc39
1 files changed, 37 insertions, 2 deletions
diff --git a/webkit/glue/plugins/plugin_instance.cc b/webkit/glue/plugins/plugin_instance.cc
index 65ae0b6..4ccbadf 100644
--- a/webkit/glue/plugins/plugin_instance.cc
+++ b/webkit/glue/plugins/plugin_instance.cc
@@ -54,7 +54,8 @@ PluginInstance::PluginInstance(PluginLib *plugin, const std::string &mime_type)
in_close_streams_(false),
next_timer_id_(1),
next_notify_id_(0),
- next_range_request_id_(0) {
+ next_range_request_id_(0),
+ handles_url_redirects_(false) {
npp_ = new NPP_t();
npp_->ndata = 0;
npp_->pdata = 0;
@@ -153,6 +154,12 @@ bool PluginInstance::Start(const GURL& url,
NPError err = NPP_New(mode, param_count,
const_cast<char **>(param_names), const_cast<char **>(param_values));
+
+ if (err == NPERR_NO_ERROR) {
+ handles_url_redirects_ =
+ ((npp_functions_->version >= NPVERS_HAS_URL_REDIRECT_HANDLING) &&
+ (npp_functions_->urlredirectnotify));
+ }
return err == NPERR_NO_ERROR;
}
@@ -350,6 +357,14 @@ NPError PluginInstance::NPP_ClearSiteData(uint64 flags,
return NPERR_NO_ERROR;
}
+void PluginInstance::NPP_URLRedirectNotify(const char* url, int32_t status,
+ void* notify_data) {
+ DCHECK(npp_functions_ != 0);
+ if (npp_functions_->urlredirectnotify != 0) {
+ npp_functions_->urlredirectnotify(npp_, url, status, notify_data);
+ }
+}
+
void PluginInstance::SendJavaScriptStream(const GURL& url,
const std::string& result,
bool success,
@@ -556,7 +571,8 @@ void PluginInstance::RequestURL(const char* url,
}
webplugin_->HandleURLRequest(
- url, method, target, buf, len, notify_id, popups_allowed());
+ url, method, target, buf, len, notify_id, popups_allowed(),
+ notify ? handles_url_redirects_ : false);
}
bool PluginInstance::ConvertPoint(double source_x, double source_y,
@@ -642,4 +658,23 @@ void PluginInstance::GetNotifyData(
}
}
+void PluginInstance::URLRedirectResponse(bool allow, void* notify_data) {
+ // The notify_data passed in allows us to identify the matching stream.
+ std::vector<scoped_refptr<PluginStream> >::iterator stream_index;
+ for (stream_index = open_streams_.begin();
+ stream_index != open_streams_.end(); ++stream_index) {
+ PluginStream* plugin_stream = *stream_index;
+ if (plugin_stream->notify_data() == notify_data) {
+ webkit_glue::WebPluginResourceClient* resource_client =
+ plugin_stream->AsResourceClient();
+ webplugin_->URLRedirectResponse(allow, resource_client->ResourceId());
+ if (allow) {
+ plugin_stream->UpdateUrl(
+ plugin_stream->pending_redirect_url().c_str());
+ }
+ break;
+ }
+ }
+}
+
} // namespace NPAPI