summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-25 23:23:24 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-25 23:23:24 +0000
commitb67151d6ca088f7b0390d29c33467a8cdba07616 (patch)
tree87204c79977dda9741e35b3ac3b1d0599c4120ee /content
parent3bc2ea1567b5806f4477406780cd07d34dc9a06a (diff)
downloadchromium_src-b67151d6ca088f7b0390d29c33467a8cdba07616.zip
chromium_src-b67151d6ca088f7b0390d29c33467a8cdba07616.tar.gz
chromium_src-b67151d6ca088f7b0390d29c33467a8cdba07616.tar.bz2
Plumb referrer policy along with drag data information
This allows for using the correct referrer policy when dragging a link out of a web view results in a download BUG=124750 TEST=none Review URL: https://chromiumcodereview.appspot.com/10451024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139147 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/download/drag_download_file.cc4
-rw-r--r--content/browser/download/drag_download_file.h5
-rw-r--r--content/browser/web_contents/web_contents_drag_win.cc13
-rw-r--r--content/browser/web_contents/web_drag_source_gtk.cc14
-rw-r--r--content/browser/web_contents/web_drag_source_mac.mm2
-rw-r--r--content/common/drag_messages.h2
-rw-r--r--content/renderer/render_view_impl.cc4
7 files changed, 26 insertions, 18 deletions
diff --git a/content/browser/download/drag_download_file.cc b/content/browser/download/drag_download_file.cc
index fe9281e..077bb78 100644
--- a/content/browser/download/drag_download_file.cc
+++ b/content/browser/download/drag_download_file.cc
@@ -26,7 +26,7 @@ DragDownloadFile::DragDownloadFile(
const FilePath& file_name_or_path,
linked_ptr<net::FileStream> file_stream,
const GURL& url,
- const GURL& referrer,
+ const content::Referrer& referrer,
const std::string& referrer_encoding,
WebContents* web_contents)
: file_stream_(file_stream),
@@ -139,7 +139,7 @@ void DragDownloadFile::InitiateDownload() {
download_stats::INITIATED_BY_DRAG_N_DROP);
scoped_ptr<DownloadUrlParameters> params(
DownloadUrlParameters::FromWebContents(web_contents_, url_, save_info));
- params->set_referrer(referrer_);
+ params->set_referrer(referrer_.url);
params->set_referrer_encoding(referrer_encoding_);
download_manager_->DownloadUrl(params.Pass());
}
diff --git a/content/browser/download/drag_download_file.h b/content/browser/download/drag_download_file.h
index 3360994..ff01a22 100644
--- a/content/browser/download/drag_download_file.h
+++ b/content/browser/download/drag_download_file.h
@@ -12,6 +12,7 @@
#include "content/browser/download/download_file.h"
#include "content/public/browser/download_item.h"
#include "content/public/browser/download_manager.h"
+#include "content/public/common/referrer.h"
#include "googleurl/src/gurl.h"
#include "net/base/file_stream.h"
#include "ui/base/dragdrop/download_file_interface.h"
@@ -43,7 +44,7 @@ class DragDownloadFile
DragDownloadFile(const FilePath& file_name_or_path,
linked_ptr<net::FileStream> file_stream,
const GURL& url,
- const GURL& referrer,
+ const content::Referrer& referrer,
const std::string& referrer_encoding,
content::WebContents* web_contents);
@@ -94,7 +95,7 @@ class DragDownloadFile
FilePath file_name_;
linked_ptr<net::FileStream> file_stream_;
GURL url_;
- GURL referrer_;
+ content::Referrer referrer_;
std::string referrer_encoding_;
content::WebContents* web_contents_;
MessageLoop* drag_message_loop_;
diff --git a/content/browser/web_contents/web_contents_drag_win.cc b/content/browser/web_contents/web_contents_drag_win.cc
index 5ef13e5..a07c61f 100644
--- a/content/browser/web_contents/web_contents_drag_win.cc
+++ b/content/browser/web_contents/web_contents_drag_win.cc
@@ -215,12 +215,13 @@ void WebContentsDragWin::PrepareDragForDownload(
// Zone.Identifier ADS (Alternate Data Stream) attached will be created.
linked_ptr<net::FileStream> empty_file_stream;
scoped_refptr<DragDownloadFile> download_file =
- new DragDownloadFile(generated_download_file_name,
- empty_file_stream,
- download_url,
- page_url,
- page_encoding,
- web_contents_);
+ new DragDownloadFile(
+ generated_download_file_name,
+ empty_file_stream,
+ download_url,
+ content::Referrer(page_url, drop_data.referrer_policy),
+ page_encoding,
+ web_contents_);
ui::OSExchangeData::DownloadFileInfo file_download(FilePath(),
download_file.get());
data->SetDownloadFileInfo(file_download);
diff --git a/content/browser/web_contents/web_drag_source_gtk.cc b/content/browser/web_contents/web_drag_source_gtk.cc
index 9a515e3..4e8518b 100644
--- a/content/browser/web_contents/web_drag_source_gtk.cc
+++ b/content/browser/web_contents/web_drag_source_gtk.cc
@@ -251,12 +251,14 @@ void WebDragSourceGtk::OnDragDataGet(GtkWidget* sender,
if (file_stream) {
// Start downloading the file to the stream.
scoped_refptr<DragDownloadFile> drag_file_downloader =
- new DragDownloadFile(file_path,
- linked_ptr<net::FileStream>(file_stream),
- download_url_,
- web_contents_->GetURL(),
- web_contents_->GetEncoding(),
- web_contents_);
+ new DragDownloadFile(
+ file_path,
+ linked_ptr<net::FileStream>(file_stream),
+ download_url_,
+ content::Referrer(web_contents_->GetURL(),
+ drop_data_->referrer_policy),
+ web_contents_->GetEncoding(),
+ web_contents_);
drag_file_downloader->Start(
new drag_download_util::PromiseFileFinalizer(
drag_file_downloader));
diff --git a/content/browser/web_contents/web_drag_source_mac.mm b/content/browser/web_contents/web_drag_source_mac.mm
index a899330..98a2120 100644
--- a/content/browser/web_contents/web_drag_source_mac.mm
+++ b/content/browser/web_contents/web_drag_source_mac.mm
@@ -336,7 +336,7 @@ void PromiseWriterHelper(const WebDropData& drop_data,
filePath,
linked_ptr<net::FileStream>(fileStream),
downloadURL_,
- contents_->GetURL(),
+ content::Referrer(contents_->GetURL(), dropData_->referrer_policy),
contents_->GetEncoding(),
contents_));
diff --git a/content/common/drag_messages.h b/content/common/drag_messages.h
index 29aaea8..59ee6b3 100644
--- a/content/common/drag_messages.h
+++ b/content/common/drag_messages.h
@@ -15,6 +15,7 @@
#define IPC_MESSAGE_START DragMsgStart
IPC_ENUM_TRAITS(WebKit::WebDragOperation)
+IPC_ENUM_TRAITS(WebKit::WebReferrerPolicy)
IPC_STRUCT_TRAITS_BEGIN(WebDropData::FileInfo)
IPC_STRUCT_TRAITS_MEMBER(path)
@@ -25,6 +26,7 @@ IPC_STRUCT_TRAITS_BEGIN(WebDropData)
IPC_STRUCT_TRAITS_MEMBER(url)
IPC_STRUCT_TRAITS_MEMBER(url_title)
IPC_STRUCT_TRAITS_MEMBER(download_metadata)
+ IPC_STRUCT_TRAITS_MEMBER(referrer_policy)
IPC_STRUCT_TRAITS_MEMBER(filenames)
IPC_STRUCT_TRAITS_MEMBER(filesystem_id)
IPC_STRUCT_TRAITS_MEMBER(plain_text)
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 7cc7ebe..cbd6617 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -2055,8 +2055,10 @@ void RenderViewImpl::startDragging(WebFrame* frame,
WebDragOperationsMask mask,
const WebImage& image,
const WebPoint& imageOffset) {
+ WebDropData drop_data(data);
+ drop_data.referrer_policy = frame->document().referrerPolicy();
Send(new DragHostMsg_StartDragging(routing_id_,
- WebDropData(data),
+ drop_data,
mask,
image.getSkBitmap(),
imageOffset));