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

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: Remove PathServiceWrapper and add DefaultDownloadDirectory Created 9 years, 6 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..9c9250988c49c59d51e6541ee97689585486557d 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"
@@ -34,6 +35,9 @@ class DownloadTabHelper : public TabContentsObserver {
// Save page with the main HTML file path, the directory for saving resources,
// and the save type: HTML only or complete web page. Returns true if the
// saving process has been initiated successfully.
+ // This method is 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 SavePage(const FilePath& main_file, const FilePath& dir_path,
SavePackage::SavePackageType save_type);
@@ -48,6 +52,21 @@ class DownloadTabHelper : public TabContentsObserver {
void OnStartDownload(DownloadItem* download);
private:
+ FRIEND_TEST_ALL_PREFIXES(SavePageBrowserTest, SavedFolder1);
+ FRIEND_TEST_ALL_PREFIXES(SavePageBrowserTest, SavedFolder2);
+ FRIEND_TEST_ALL_PREFIXES(SavePageBrowserTest, SavedFolder3);
+ FRIEND_TEST_ALL_PREFIXES(SavePageBrowserTest, SavedFolder4);
+
+ // Used in automated testing to bypass prompting the user for file names.
+ // The difference between SavePageBasedOnDefaultPrefs() and SavePage()
+ // is whether the default folder prefs are used. In case of SavePage(),
+ // we need to give it the file path to which the file is saved.
+ // On the other hand, in case of SavePageBasedOnDefaultPrefs(),
+ // we need not to give the file path since the file path is determined
+ // based on the default folder prefs. This method returns the title
+ // of the current tab.
+ string16 SavePageBasedOnDefaultPrefs();
+
// TabContentsObserver overrides.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
virtual void DidGetUserGesture() OVERRIDE;

Powered by Google App Engine
This is Rietveld 408576698