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

Unified Diff: chrome/browser/tab_contents/render_view_context_menu.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 | « chrome/browser/extensions/webstore_installer.cc ('k') | chrome/test/data/downloads/form_page_to_post.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tab_contents/render_view_context_menu.cc
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index e24f65e242729009b70710cbc26008720c68800f..af8283174f12fa6fc86706aad19e5ce7fd4e9715 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -1484,27 +1484,51 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) {
content::PAGE_TRANSITION_LINK);
break;
- case IDC_CONTENT_CONTEXT_SAVEAVAS:
- case IDC_CONTENT_CONTEXT_SAVEIMAGEAS:
case IDC_CONTENT_CONTEXT_SAVELINKAS: {
download_util::RecordDownloadCount(
download_util::INITIATED_BY_CONTEXT_MENU_COUNT);
const GURL& referrer =
params_.frame_url.is_empty() ? params_.page_url : params_.frame_url;
- const GURL& url =
- (id == IDC_CONTENT_CONTEXT_SAVELINKAS ? params_.link_url :
- params_.src_url);
+ const GURL& url = params_.link_url;
+ DownloadSaveInfo save_info;
+ save_info.prompt_for_save_location = true;
DownloadManager* dlm =
DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager();
- // For images and AV "Save As" context menu commands, save the cached
- // data even if it is no longer valid. This helps ensure that the content
- // that is visible on the page is what is saved. For links, this behavior
- // is not desired since the content being linked to is not visible.
- bool prefer_cache = (id != IDC_CONTENT_CONTEXT_SAVELINKAS);
+ dlm->DownloadUrl(url,
+ referrer,
+ params_.frame_charset,
+ false, // Don't prefer_cache
+ -1, // No POST id
+ save_info,
+ source_web_contents_);
+ break;
+ }
+
+ case IDC_CONTENT_CONTEXT_SAVEAVAS:
+ case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: {
+ download_util::RecordDownloadCount(
+ download_util::INITIATED_BY_CONTEXT_MENU_COUNT);
+ const GURL& referrer =
+ params_.frame_url.is_empty() ? params_.page_url : params_.frame_url;
+ const GURL& url = params_.src_url;
DownloadSaveInfo save_info;
save_info.prompt_for_save_location = true;
- dlm->DownloadUrl(url, referrer, params_.frame_charset,
- prefer_cache, save_info, source_web_contents_);
+ int64 post_id = -1;
+ if (url == source_web_contents_->GetURL()) {
+ const NavigationEntry* entry =
+ source_web_contents_->GetController().GetActiveEntry();
+ if (entry)
+ post_id = entry->GetPostID();
+ }
+ DownloadManager* dlm =
+ DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager();
+ dlm->DownloadUrl(url,
+ referrer,
+ "",
+ true, // prefer_cache
+ post_id,
+ save_info,
+ source_web_contents_);
break;
}
« no previous file with comments | « chrome/browser/extensions/webstore_installer.cc ('k') | chrome/test/data/downloads/form_page_to_post.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698