Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(878)

Unified Diff: content/browser/tab_contents/tab_contents.cc

Issue 9314037: Save As for content retrieved via POST works in most circumstances. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/tab_contents/tab_contents.h ('k') | content/public/browser/download_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/tab_contents/tab_contents.cc
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index 1fc4bfafe34850528a930836d3c77b2f160f64f0..fa0e657326ed16635e6b24493402f8db61357315 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -934,21 +934,10 @@ bool TabContents::IsSavable() {
void TabContents::OnSavePage() {
// If we can not save the page, try to download it.
if (!IsSavable()) {
- DownloadManager* dlm = GetBrowserContext()->GetDownloadManager();
- const GURL& current_page_url = GetURL();
- if (dlm && current_page_url.is_valid()) {
- DownloadSaveInfo save_info;
- save_info.prompt_for_save_location = true;
- dlm->DownloadUrl(current_page_url,
- GURL(),
- "",
- true, // prefer_cache
- save_info,
- this);
- download_stats::RecordDownloadCount(
- download_stats::INITIATED_BY_SAVE_PACKAGE_FAILURE_COUNT);
- return;
- }
+ SaveURL(GetURL(), GURL());
+ download_stats::RecordDownloadCount(
+ download_stats::INITIATED_BY_SAVE_PACKAGE_FAILURE_COUNT);
+ return;
}
Stop();
@@ -1425,10 +1414,7 @@ void TabContents::OnUpdateZoomLimits(int minimum_percent,
}
void TabContents::OnSaveURL(const GURL& url) {
- DownloadManager* dlm = GetBrowserContext()->GetDownloadManager();
- DownloadSaveInfo save_info;
- save_info.prompt_for_save_location = true;
- dlm->DownloadUrl(url, GetURL(), "", true, save_info, this);
+ SaveURL(url, GetURL());
}
void TabContents::OnEnumerateDirectory(int request_id,
@@ -2288,6 +2274,30 @@ void TabContents::SetEncoding(const std::string& encoding) {
GetCanonicalEncodingNameByAliasName(encoding);
}
+void TabContents::SaveURL(const GURL& url, const GURL& referrer) {
+ DownloadManager* dlm = GetBrowserContext()->GetDownloadManager();
+ if (!dlm)
+ return;
+ int64 post_id = -1;
+ // Check if the URL to save matches the URL of the page itself. One
+ // circumstance where this may not happen is when a Pepper plugin initiates
+ // a save.
+ if (url == GetURL()) {
+ const NavigationEntry* entry = controller_.GetActiveEntry();
+ if (entry)
+ post_id = entry->GetPostID();
+ }
+ DownloadSaveInfo save_info;
+ save_info.prompt_for_save_location = true;
+ dlm->DownloadUrl(url,
+ referrer,
+ "",
+ true, // prefer_cache
+ post_id,
+ save_info,
+ this);
+}
+
void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) {
RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh);
// Can be NULL during tests.
« no previous file with comments | « content/browser/tab_contents/tab_contents.h ('k') | content/public/browser/download_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698