diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/common/plugin_messages.cc | 9 | ||||
-rw-r--r-- | chrome/common/plugin_messages.h | 1 | ||||
-rw-r--r-- | chrome/common/plugin_messages_internal.h | 9 | ||||
-rw-r--r-- | chrome/plugin/webplugin_delegate_stub.cc | 5 | ||||
-rw-r--r-- | chrome/plugin/webplugin_delegate_stub.h | 2 | ||||
-rw-r--r-- | chrome/plugin/webplugin_proxy.cc | 9 | ||||
-rw-r--r-- | chrome/plugin/webplugin_proxy.h | 5 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_proxy.cc | 21 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_proxy.h | 2 | ||||
-rw-r--r-- | chrome/test/data/npapi/geturl_redirect_notify.html | 26 | ||||
-rw-r--r-- | chrome/test/data/npapi/plugin_read_page_redirect_src.html | 4 | ||||
-rw-r--r-- | chrome/test/data/npapi/plugin_read_page_redirect_src.html.mock-http-headers | 3 | ||||
-rw-r--r-- | chrome/test/ui/npapi_uitest.cc | 8 |
13 files changed, 92 insertions, 12 deletions
diff --git a/chrome/common/plugin_messages.cc b/chrome/common/plugin_messages.cc index e152728..0434197 100644 --- a/chrome/common/plugin_messages.cc +++ b/chrome/common/plugin_messages.cc @@ -22,7 +22,8 @@ PluginMsg_Init_Params::~PluginMsg_Init_Params() { PluginHostMsg_URLRequest_Params::PluginHostMsg_URLRequest_Params() : notify_id(-1), - popups_allowed(false) { + popups_allowed(false), + notify_redirects(false) { } PluginHostMsg_URLRequest_Params::~PluginHostMsg_URLRequest_Params() { @@ -123,6 +124,7 @@ void ParamTraits<PluginHostMsg_URLRequest_Params>::Write(Message* m, WriteParam(m, p.buffer); WriteParam(m, p.notify_id); WriteParam(m, p.popups_allowed); + WriteParam(m, p.notify_redirects); } bool ParamTraits<PluginHostMsg_URLRequest_Params>::Read(const Message* m, @@ -134,7 +136,8 @@ bool ParamTraits<PluginHostMsg_URLRequest_Params>::Read(const Message* m, ReadParam(m, iter, &p->target) && ReadParam(m, iter, &p->buffer) && ReadParam(m, iter, &p->notify_id) && - ReadParam(m, iter, &p->popups_allowed); + ReadParam(m, iter, &p->popups_allowed) && + ReadParam(m, iter, &p->notify_redirects); } void ParamTraits<PluginHostMsg_URLRequest_Params>::Log(const param_type& p, @@ -151,6 +154,8 @@ void ParamTraits<PluginHostMsg_URLRequest_Params>::Log(const param_type& p, LogParam(p.notify_id, l); l->append(", "); LogParam(p.popups_allowed, l); + l->append(", "); + LogParam(p.notify_redirects, l); l->append(")"); } diff --git a/chrome/common/plugin_messages.h b/chrome/common/plugin_messages.h index 86df200..3935fa8 100644 --- a/chrome/common/plugin_messages.h +++ b/chrome/common/plugin_messages.h @@ -56,6 +56,7 @@ struct PluginHostMsg_URLRequest_Params { std::vector<char> buffer; int notify_id; bool popups_allowed; + bool notify_redirects; }; struct PluginMsg_DidReceiveResponseParams { diff --git a/chrome/common/plugin_messages_internal.h b/chrome/common/plugin_messages_internal.h index 791f05a..7ebfd58 100644 --- a/chrome/common/plugin_messages_internal.h +++ b/chrome/common/plugin_messages_internal.h @@ -243,9 +243,10 @@ IPC_BEGIN_MESSAGES(Plugin) string16 /* text */) #endif - IPC_SYNC_MESSAGE_ROUTED2_0(PluginMsg_WillSendRequest, + IPC_SYNC_MESSAGE_ROUTED3_0(PluginMsg_WillSendRequest, unsigned long /* id */, - GURL /* url */) + GURL /* url */, + int /* http_status_code */) IPC_MESSAGE_ROUTED1(PluginMsg_DidReceiveResponse, PluginMsg_DidReceiveResponseParams) @@ -471,6 +472,10 @@ IPC_BEGIN_MESSAGES(PluginHost) IPC_MESSAGE_CONTROL1(PluginHostMsg_ClearSiteDataResult, bool /* success */) + IPC_MESSAGE_ROUTED2(PluginHostMsg_URLRedirectResponse, + bool /* allow */, + int /* resource_id */) + IPC_END_MESSAGES(PluginHost) //----------------------------------------------------------------------------- diff --git a/chrome/plugin/webplugin_delegate_stub.cc b/chrome/plugin/webplugin_delegate_stub.cc index 5af56dd..ff0652d 100644 --- a/chrome/plugin/webplugin_delegate_stub.cc +++ b/chrome/plugin/webplugin_delegate_stub.cc @@ -196,12 +196,13 @@ void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params, } } -void WebPluginDelegateStub::OnWillSendRequest(int id, const GURL& url) { +void WebPluginDelegateStub::OnWillSendRequest(int id, const GURL& url, + int http_status_code) { WebPluginResourceClient* client = webplugin_->GetResourceClient(id); if (!client) return; - client->WillSendRequest(url); + client->WillSendRequest(url, http_status_code); } void WebPluginDelegateStub::OnDidReceiveResponse( diff --git a/chrome/plugin/webplugin_delegate_stub.h b/chrome/plugin/webplugin_delegate_stub.h index 5bc2887..cbd2c97 100644 --- a/chrome/plugin/webplugin_delegate_stub.h +++ b/chrome/plugin/webplugin_delegate_stub.h @@ -57,7 +57,7 @@ class WebPluginDelegateStub : public IPC::Channel::Listener, // Message handlers for the WebPluginDelegate calls that are proxied from the // renderer over the IPC channel. void OnInit(const PluginMsg_Init_Params& params, bool* result); - void OnWillSendRequest(int id, const GURL& url); + void OnWillSendRequest(int id, const GURL& url, int http_status_code); void OnDidReceiveResponse(const PluginMsg_DidReceiveResponseParams& params); void OnDidReceiveData(int id, const std::vector<char>& buffer, int data_offset); diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc index f099963..0b04a94 100644 --- a/chrome/plugin/webplugin_proxy.cc +++ b/chrome/plugin/webplugin_proxy.cc @@ -315,7 +315,8 @@ void WebPluginProxy::HandleURLRequest(const char* url, const char* buf, unsigned int len, int notify_id, - bool popups_allowed) { + bool popups_allowed, + bool notify_redirects) { if (!target && (0 == base::strcasecmp(method, "GET"))) { // Please refer to https://bugzilla.mozilla.org/show_bug.cgi?id=366082 // for more details on this. @@ -343,6 +344,7 @@ void WebPluginProxy::HandleURLRequest(const char* url, params.notify_id = notify_id; params.popups_allowed = popups_allowed; + params.notify_redirects = notify_redirects; Send(new PluginHostMsg_URLRequest(route_id_, params)); } @@ -725,3 +727,8 @@ void WebPluginProxy::ResourceClientDeleted( } } } + +void WebPluginProxy::URLRedirectResponse(bool allow, int resource_id) { + Send(new PluginHostMsg_URLRedirectResponse(route_id_, allow, resource_id)); +} + diff --git a/chrome/plugin/webplugin_proxy.h b/chrome/plugin/webplugin_proxy.h index 5a24e2bf..d9a4c67 100644 --- a/chrome/plugin/webplugin_proxy.h +++ b/chrome/plugin/webplugin_proxy.h @@ -120,7 +120,8 @@ class WebPluginProxy : public webkit_glue::WebPlugin { const char* buf, unsigned int len, int notify_id, - bool popups_allowed); + bool popups_allowed, + bool notify_redirects); void UpdateGeometry(const gfx::Rect& window_rect, const gfx::Rect& clip_rect, const TransportDIB::Handle& windowless_buffer, @@ -176,6 +177,8 @@ class WebPluginProxy : public webkit_glue::WebPlugin { virtual void FreeSurfaceDIB(TransportDIB::Id dib_id); #endif + virtual void URLRedirectResponse(bool allow, int resource_id); + private: bool Send(IPC::Message* msg); diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index eff2d29..0aaa742 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -90,10 +90,10 @@ class ResourceClientProxy : public webkit_glue::WebPluginResourceClient { } // PluginResourceClient implementation: - void WillSendRequest(const GURL& url) { + void WillSendRequest(const GURL& url, int http_status_code) { DCHECK(channel_ != NULL); channel_->Send(new PluginMsg_WillSendRequest(instance_id_, resource_id_, - url)); + url, http_status_code)); } void DidReceiveResponse(const std::string& mime_type, @@ -146,6 +146,10 @@ class ResourceClientProxy : public webkit_glue::WebPluginResourceClient { return multibyte_response_expected_; } + int ResourceId() { + return resource_id_; + } + private: scoped_refptr<PluginChannelHost> channel_; int instance_id_; @@ -477,6 +481,8 @@ void WebPluginDelegateProxy::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(PluginHostMsg_AcceleratedSurfaceBuffersSwapped, OnAcceleratedSurfaceBuffersSwapped) #endif + IPC_MESSAGE_HANDLER(PluginHostMsg_URLRedirectResponse, + OnURLRedirectResponse) IPC_MESSAGE_UNHANDLED_ERROR() IPC_END_MESSAGE_MAP() @@ -1346,7 +1352,7 @@ void WebPluginDelegateProxy::OnHandleURLRequest( plugin_->HandleURLRequest( params.url.c_str(), params.method.c_str(), target, data, static_cast<unsigned int>(params.buffer.size()), params.notify_id, - params.popups_allowed); + params.popups_allowed, params.notify_redirects); } webkit_glue::WebPluginResourceClient* @@ -1556,3 +1562,12 @@ bool WebPluginDelegateProxy::UseSynchronousGeometryUpdates() { return false; } #endif + +void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, + int resource_id) { + if (!plugin_) + return; + + plugin_->URLRedirectResponse(allow, resource_id); +} + diff --git a/chrome/renderer/webplugin_delegate_proxy.h b/chrome/renderer/webplugin_delegate_proxy.h index 64f1b30..4dea6c7 100644 --- a/chrome/renderer/webplugin_delegate_proxy.h +++ b/chrome/renderer/webplugin_delegate_proxy.h @@ -180,6 +180,8 @@ class WebPluginDelegateProxy uint64 surface_id); #endif + void OnURLRedirectResponse(bool allow, int resource_id); + // Draw a graphic indicating a crashed plugin. void PaintSadPlugin(WebKit::WebCanvas* canvas, const gfx::Rect& rect); diff --git a/chrome/test/data/npapi/geturl_redirect_notify.html b/chrome/test/data/npapi/geturl_redirect_notify.html new file mode 100644 index 0000000..568834d --- /dev/null +++ b/chrome/test/data/npapi/geturl_redirect_notify.html @@ -0,0 +1,26 @@ +<html> + +<head> +<script src="npapi.js"></script> +</head> + + +<body> +<div id="statusPanel" style="border: 1px solid red; width: 100%"> +Test running.... +</div> + + +GetURL Test<p> +This test fetches a URL via the plugin and validates that the plugin does +receive notification about the redirect which is then denied. + +<embed type="application/vnd.npapi-test" + src="foo" + name="geturlredirectnotify" + id="1" + mode="np_embed" +> + +</body> +</html> diff --git a/chrome/test/data/npapi/plugin_read_page_redirect_src.html b/chrome/test/data/npapi/plugin_read_page_redirect_src.html new file mode 100644 index 0000000..d359a54 --- /dev/null +++ b/chrome/test/data/npapi/plugin_read_page_redirect_src.html @@ -0,0 +1,4 @@ +<html> +<head><title>Test redirect page</title></head> +<body>Redirect page. This page redirects to another page.</body> +</html> diff --git a/chrome/test/data/npapi/plugin_read_page_redirect_src.html.mock-http-headers b/chrome/test/data/npapi/plugin_read_page_redirect_src.html.mock-http-headers new file mode 100644 index 0000000..0818be1 --- /dev/null +++ b/chrome/test/data/npapi/plugin_read_page_redirect_src.html.mock-http-headers @@ -0,0 +1,3 @@ +HTTP/1.1 301 Moved Permanently +Location: http://mock.http/npapi/plugin_read_page.html +Content-type: text/html diff --git a/chrome/test/ui/npapi_uitest.cc b/chrome/test/ui/npapi_uitest.cc index d20179a..77a80b2 100644 --- a/chrome/test/ui/npapi_uitest.cc +++ b/chrome/test/ui/npapi_uitest.cc @@ -88,6 +88,14 @@ TEST_F(NPAPITesterBase, GetJavaScriptURL2) { kTestCompleteSuccess, action_max_timeout_ms()); } +TEST_F(NPAPITesterBase, GetURLRedirectNotification) { + const FilePath test_case(FILE_PATH_LITERAL("geturl_redirect_notify.html")); + GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), test_case); + ASSERT_NO_FATAL_FAILURE(NavigateToURL(url)); + WaitForFinish("geturlredirectnotify", "1", url, kTestCompleteCookie, + kTestCompleteSuccess, action_max_timeout_ms()); +} + // Tests that if an NPObject is proxies back to its original process, the // original pointer is returned and not a proxy. If this fails the plugin // will crash. |