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

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: Add test page 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
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 78b80246afc2526d741901f8cbcf3104e4b931d5..bb64ed06f08cecf0fa748f81c1c94d29ec594b85 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) {
Randy Smith (Not in Mondays) 2012/02/02 19:46:10 When does this get called? I ask because we shoul
cbentzel 2012/02/03 15:54:47 This is currently called when the save button icon
- 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,27 @@ 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;
+ if (url == GetURL()) {
Randy Smith (Not in Mondays) 2012/02/02 19:46:10 Could you comment on the purpose of this test? (E
cbentzel 2012/02/03 15:54:47 Added a comment.
+ 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.

Powered by Google App Engine
This is Rietveld 408576698