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

Side by Side 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, 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_DOWNLOAD_DOWNLOAD_TAB_HELPER_H_ 5 #ifndef CHROME_BROWSER_UI_DOWNLOAD_DOWNLOAD_TAB_HELPER_H_
6 #define CHROME_BROWSER_UI_DOWNLOAD_DOWNLOAD_TAB_HELPER_H_ 6 #define CHROME_BROWSER_UI_DOWNLOAD_DOWNLOAD_TAB_HELPER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/gtest_prod_util.h"
10 #include "chrome/browser/download/save_package.h" 11 #include "chrome/browser/download/save_package.h"
11 #include "content/browser/tab_contents/tab_contents_observer.h" 12 #include "content/browser/tab_contents/tab_contents_observer.h"
12 13
13 class DownloadItem; 14 class DownloadItem;
14 class DownloadTabHelperDelegate; 15 class DownloadTabHelperDelegate;
15 class TabContentsWrapper; 16 class TabContentsWrapper;
16 17
17 // Per-tab download controller. Handles dealing with various per-tab download 18 // Per-tab download controller. Handles dealing with various per-tab download
18 // duties. 19 // duties.
19 class DownloadTabHelper : public TabContentsObserver { 20 class DownloadTabHelper : public TabContentsObserver {
(...skipping 20 matching lines...) Expand all
40 // Returns the SavePackage which manages the page saving job. May be NULL. 41 // Returns the SavePackage which manages the page saving job. May be NULL.
41 SavePackage* save_package() const { return save_package_.get(); } 42 SavePackage* save_package() const { return save_package_.get(); }
42 43
43 // Notifies the delegate that a download is about to be started. 44 // Notifies the delegate that a download is about to be started.
44 // This notification is fired before a local temporary file has been created. 45 // This notification is fired before a local temporary file has been created.
45 bool CanDownload(int request_id); 46 bool CanDownload(int request_id);
46 47
47 // Notifies the delegate that a download started. 48 // Notifies the delegate that a download started.
48 void OnStartDownload(DownloadItem* download); 49 void OnStartDownload(DownloadItem* download);
49 50
51 // Used in automated testing to bypass prompting the user for file names.
52 // If we want to change the default folder prefs used for tests,
53 // call ChangeSaveDirectoryPrefs() before this method
54 // and call RestoreSaveDirectoryPrefs() after this method.
55 // Returns the title of the current tab.
56 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
57
58 // Changes the default folder prefs. This method saves the current folder
59 // for saving HTML, the current folder for saving downloaded files,
60 // the current user's "Downloads" folder and a save type (HTML only or
61 // complete HTML files), and then changes them to |website_save_dir|,
62 // |download_save_dir|, |default_downloads_dir| and |save_type|, respectively.
63 // If we call this method, we must call RestoreSaveDirectoryPrefs()
64 // after the test to restore the default folder prefs.
65 void ChangeSaveDirectoryPrefs(
66 const FilePath& website_save_dir,
67 const FilePath& download_save_dir,
68 const FilePath& default_downloads_dir,
69 const SavePackage::SavePackageType save_type);
70
71 // Restores the default folder prefs.
72 void RestoreSaveDirectoryPrefs();
73
50 private: 74 private:
51 // TabContentsObserver overrides. 75 // TabContentsObserver overrides.
52 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 76 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
53 virtual void DidGetUserGesture() OVERRIDE; 77 virtual void DidGetUserGesture() OVERRIDE;
54 78
55 // SavePackage, lazily created. 79 // SavePackage, lazily created.
56 scoped_refptr<SavePackage> save_package_; 80 scoped_refptr<SavePackage> save_package_;
57 81
58 // Owning TabContentsWrapper. 82 // Owning TabContentsWrapper.
59 TabContentsWrapper* tab_contents_wrapper_; 83 TabContentsWrapper* tab_contents_wrapper_;
60 84
61 // Delegate for notifying our owner (usually Browser) about stuff. Not owned 85 // Delegate for notifying our owner (usually Browser) about stuff. Not owned
62 // by us. 86 // by us.
63 DownloadTabHelperDelegate* delegate_; 87 DownloadTabHelperDelegate* delegate_;
64 88
89 // Temporarily stores the default folder prefs.
90 FilePath prev_website_save_dir_;
91 FilePath prev_download_save_dir_;
92 FilePath prev_default_downloads_dir_;
93 SavePackage::SavePackageType prev_save_type_;
94
65 DISALLOW_COPY_AND_ASSIGN(DownloadTabHelper); 95 DISALLOW_COPY_AND_ASSIGN(DownloadTabHelper);
66 }; 96 };
67 97
68 #endif // CHROME_BROWSER_UI_DOWNLOAD_DOWNLOAD_TAB_HELPER_H_ 98 #endif // CHROME_BROWSER_UI_DOWNLOAD_DOWNLOAD_TAB_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698