Commit 20b433a9 authored by jochen@chromium.org's avatar jochen@chromium.org

Send the correct referrer and policy when saving a file via PPAPI

BUG=124750
TEST=none


Review URL: https://chromiumcodereview.appspot.com/10377118

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137249 0039d316-1c4b-4281-b951-d872f2087c98
parent 7a3bdee2
......@@ -1218,7 +1218,7 @@ void WebContentsImpl::OnSavePage() {
if (!IsSavable()) {
download_stats::RecordDownloadSource(
download_stats::INITIATED_BY_SAVE_PACKAGE_ON_NON_HTML);
SaveURL(GetURL(), GURL(), true);
SaveURL(GetURL(), content::Referrer(), true);
return;
}
......@@ -1748,7 +1748,8 @@ void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent,
temporary_zoom_settings_ = !remember;
}
void WebContentsImpl::OnSaveURL(const GURL& url) {
void WebContentsImpl::OnSaveURL(const GURL& url,
const content::Referrer& referrer) {
download_stats::RecordDownloadSource(
download_stats::INITIATED_BY_PEPPER_SAVE);
// Check if the URL to save matches the URL of the main frame. Since this
......@@ -1758,7 +1759,7 @@ void WebContentsImpl::OnSaveURL(const GURL& url) {
if (!main_frame_url.is_valid())
return;
bool is_main_frame = (url == main_frame_url);
SaveURL(url, main_frame_url, is_main_frame);
SaveURL(url, referrer, is_main_frame);
}
void WebContentsImpl::OnEnumerateDirectory(int request_id,
......@@ -2752,7 +2753,7 @@ void WebContentsImpl::SetEncoding(const std::string& encoding) {
}
void WebContentsImpl::SaveURL(const GURL& url,
const GURL& referrer,
const content::Referrer& referrer,
bool is_main_frame) {
DownloadManager* dlm = GetBrowserContext()->GetDownloadManager();
if (!dlm)
......@@ -2767,7 +2768,8 @@ void WebContentsImpl::SaveURL(const GURL& url,
save_info.prompt_for_save_location = true;
scoped_ptr<DownloadUrlParameters> params(
DownloadUrlParameters::FromWebContents(this, url, save_info));
params->set_referrer(referrer);
// TODO(jochen): Pass in the referrer policy as well.
params->set_referrer(referrer.url);
params->set_post_id(post_id);
params->set_prefer_cache(true);
if (post_id >= 0)
......
......@@ -455,7 +455,7 @@ class CONTENT_EXPORT WebContentsImpl
void OnUpdateZoomLimits(int minimum_percent,
int maximum_percent,
bool remember);
void OnSaveURL(const GURL& url);
void OnSaveURL(const GURL& url, const content::Referrer& referrer);
void OnEnumerateDirectory(int request_id, const FilePath& path);
void OnJSOutOfMemory();
......@@ -552,7 +552,9 @@ class CONTENT_EXPORT WebContentsImpl
void SetEncoding(const std::string& encoding);
// Save a URL to the local filesystem.
void SaveURL(const GURL& url, const GURL& referrer, bool is_main_frame);
void SaveURL(const GURL& url,
const content::Referrer& referrer,
bool is_main_frame);
content::RenderViewHostImpl* GetRenderViewHostImpl();
......
......@@ -1987,8 +1987,9 @@ IPC_MESSAGE_ROUTED1(ViewHostMsg_UpdateContentRestrictions,
int /* restrictions */)
// Brings up SaveAs... dialog to save specified URL.
IPC_MESSAGE_ROUTED1(ViewHostMsg_SaveURLAs,
GURL /* url */)
IPC_MESSAGE_ROUTED2(ViewHostMsg_SaveURLAs,
GURL /* url */,
content::Referrer /* referrer */)
// Displays a JavaScript out-of-memory message in the infobar.
IPC_MESSAGE_ROUTED0(ViewHostMsg_JSOutOfMemory)
......
......@@ -32,6 +32,7 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/context_menu_params.h"
#include "content/public/common/media_stream_request.h"
#include "content/public/common/referrer.h"
#include "content/public/renderer/content_renderer_client.h"
#include "content/renderer/gamepad_shared_memory_reader.h"
#include "content/renderer/media/audio_hardware.h"
......@@ -1256,8 +1257,11 @@ void PepperPluginDelegateImpl::SetContentRestriction(int restrictions) {
}
void PepperPluginDelegateImpl::SaveURLAs(const GURL& url) {
WebFrame* frame = render_view_->webview()->mainFrame();
content::Referrer referrer(frame->document().url(),
frame->document().referrerPolicy());
render_view_->Send(new ViewHostMsg_SaveURLAs(
render_view_->routing_id(), url));
render_view_->routing_id(), url, referrer));
}
webkit_glue::P2PTransport* PepperPluginDelegateImpl::CreateP2PTransport() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment