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

Unified Diff: chrome/browser/ui/download/download_tab_helper.h

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: Correct typo Created 9 years, 7 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: chrome/browser/ui/download/download_tab_helper.h
diff --git a/chrome/browser/ui/download/download_tab_helper.h b/chrome/browser/ui/download/download_tab_helper.h
index ac559136eb7b74d2056acbd2bdd50d8c95cb87db..685444440d0ad5ab65e0551e06cea96b149ea40a 100644
--- a/chrome/browser/ui/download/download_tab_helper.h
+++ b/chrome/browser/ui/download/download_tab_helper.h
@@ -7,6 +7,7 @@
#pragma once
#include "base/basictypes.h"
+#include "base/gtest_prod_util.h"
#include "chrome/browser/download/save_package.h"
#include "content/browser/tab_contents/tab_contents_observer.h"
@@ -47,6 +48,29 @@ class DownloadTabHelper : public TabContentsObserver {
// Notifies the delegate that a download started.
void OnStartDownload(DownloadItem* download);
+ // Used in automated testing to bypass prompting the user for file names.
+ // If we want to change the default folder prefs used for tests,
+ // call ChangeSaveDirectoryPrefs() before this method
+ // and call RestoreSaveDirectoryPrefs() after this method.
+ // Returns the title of the current tab.
+ string16 SavePageWithoutDialog();
Randy Smith (Not in Mondays) 2011/06/02 19:13:57 I still don't see a comment describing the differe
haraken1 2011/06/03 06:50:27 I wrote the difference here and download_tab_helpe
+
+ // Changes the default folder prefs. This method saves the current folder
+ // for saving HTML, the current folder for saving downloaded files,
+ // the current user's "Downloads" folder and a save type (HTML only or
+ // complete HTML files), and then changes them to |website_save_dir|,
+ // |download_save_dir|, |default_downloads_dir| and |save_type|, respectively.
+ // If we call this method, we must call RestoreSaveDirectoryPrefs()
+ // after the test to restore the default folder prefs.
+ void ChangeSaveDirectoryPrefs(
+ const FilePath& website_save_dir,
+ const FilePath& download_save_dir,
+ const FilePath& default_downloads_dir,
+ const SavePackage::SavePackageType save_type);
+
+ // Restores the default folder prefs.
+ void RestoreSaveDirectoryPrefs();
+
private:
// TabContentsObserver overrides.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
@@ -62,6 +86,12 @@ class DownloadTabHelper : public TabContentsObserver {
// by us.
DownloadTabHelperDelegate* delegate_;
+ // Temporarily stores the default folder prefs.
+ FilePath prev_website_save_dir_;
+ FilePath prev_download_save_dir_;
+ FilePath prev_default_downloads_dir_;
+ SavePackage::SavePackageType prev_save_type_;
+
DISALLOW_COPY_AND_ASSIGN(DownloadTabHelper);
};

Powered by Google App Engine
This is Rietveld 408576698