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

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

Issue 6973052: When the download folder does not exist, change the download folder to a user's "Downloads" (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Redirect "http://mock.testfile.http/<random path>" to "chrome/test/data/a.htm" Created 9 years, 4 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 d25617547e48687cb67ba6ff81e4bf13d482e9f0..37d6938d76d9e04005eb4fa8fff1d31eb54a21b6 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/download/download_request_limiter.h"
#include "chrome/browser/download/download_util.h"
#include "content/browser/browser_context.h"
+#include "chrome/browser/download/save_package_file_picker.h"
#include "content/browser/child_process_security_policy.h"
#include "content/browser/content_browser_client.h"
#include "content/browser/debugger/devtools_manager.h"
@@ -752,18 +753,29 @@ void TabContents::OnSavePage() {
save_package_->GetSaveInfo();
}
-// Used in automated testing to bypass prompting the user for file names.
-// Instead, the names and paths are hard coded rather than running them through
-// file name sanitation and extension / mime checking.
bool TabContents::SavePage(const FilePath& main_file, const FilePath& dir_path,
SavePackage::SavePackageType save_type) {
// Stop the page from navigating.
Stop();
save_package_ = new SavePackage(this, save_type, main_file, dir_path);
+ // Skips GetSaveInfo() and directly calls Init().
+ // We do not have to explicitly disable the select file dialog
+ // since we skip the process that can show the dialog.
return save_package_->Init();
}
+string16 TabContents::SavePageBasedOnDefaultPrefs() {
+ Stop();
+
+ save_package_ = new SavePackage(this);
+ // Disables the select file dialog.
+ SavePackageFilePicker::SetShouldPromptUser(false);
+ // This GetSaveInfo() calls save_package_->Init() in the background.
+ save_package_->GetSaveInfo();
+ return GetTitle();
+}
+
void TabContents::OnSaveURL(const GURL& url) {
DownloadManager* dlm = browser_context()->GetDownloadManager();
dlm->DownloadUrl(url, GetURL(), "", this);

Powered by Google App Engine
This is Rietveld 408576698