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

Side by Side Diff: chrome/browser/ui/download/download_tab_helper.h

Issue 7324031: Revert 91861 - When the download folder does not exist, change the download folder to a user's "D... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 5 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"
11 #include "chrome/browser/download/save_package.h" 10 #include "chrome/browser/download/save_package.h"
12 #include "content/browser/tab_contents/tab_contents_observer.h" 11 #include "content/browser/tab_contents/tab_contents_observer.h"
13 12
14 class DownloadItem; 13 class DownloadItem;
15 class DownloadTabHelperDelegate; 14 class DownloadTabHelperDelegate;
16 class TabContentsWrapper; 15 class TabContentsWrapper;
17 16
18 // Per-tab download controller. Handles dealing with various per-tab download 17 // Per-tab download controller. Handles dealing with various per-tab download
19 // duties. 18 // duties.
20 class DownloadTabHelper : public TabContentsObserver { 19 class DownloadTabHelper : public TabContentsObserver {
21 public: 20 public:
22 explicit DownloadTabHelper(TabContentsWrapper* tab_contents); 21 explicit DownloadTabHelper(TabContentsWrapper* tab_contents);
23 virtual ~DownloadTabHelper(); 22 virtual ~DownloadTabHelper();
24 23
25 DownloadTabHelperDelegate* delegate() const { return delegate_; } 24 DownloadTabHelperDelegate* delegate() const { return delegate_; }
26 void set_delegate(DownloadTabHelperDelegate* d) { delegate_ = d; } 25 void set_delegate(DownloadTabHelperDelegate* d) { delegate_ = d; }
27 26
28 // Prepare for saving the current web page to disk. 27 // Prepare for saving the current web page to disk.
29 void OnSavePage(); 28 void OnSavePage();
30 29
31 // Prepare for saving the URL to disk. 30 // Prepare for saving the URL to disk.
32 // URL may refer to the iframe on the page. 31 // URL may refer to the iframe on the page.
33 void OnSaveURL(const GURL& url); 32 void OnSaveURL(const GURL& url);
34 33
35 // Save page with the main HTML file path, the directory for saving resources, 34 // Save page with the main HTML file path, the directory for saving resources,
36 // and the save type: HTML only or complete web page. Returns true if the 35 // and the save type: HTML only or complete web page. Returns true if the
37 // saving process has been initiated successfully. 36 // saving process has been initiated successfully.
38 // This method is used in automated testing to bypass prompting the user for
39 // file names. Instead, the names and paths are hard coded rather than
40 // running them through file name sanitation and extension / mime checking.
41 bool SavePage(const FilePath& main_file, const FilePath& dir_path, 37 bool SavePage(const FilePath& main_file, const FilePath& dir_path,
42 SavePackage::SavePackageType save_type); 38 SavePackage::SavePackageType save_type);
43 39
44 // Returns the SavePackage which manages the page saving job. May be NULL. 40 // Returns the SavePackage which manages the page saving job. May be NULL.
45 SavePackage* save_package() const { return save_package_.get(); } 41 SavePackage* save_package() const { return save_package_.get(); }
46 42
47 // Notifies the delegate that a download is about to be started. 43 // Notifies the delegate that a download is about to be started.
48 // This notification is fired before a local temporary file has been created. 44 // This notification is fired before a local temporary file has been created.
49 bool CanDownload(int request_id); 45 bool CanDownload(int request_id);
50 46
51 // Notifies the delegate that a download started. 47 // Notifies the delegate that a download started.
52 void OnStartDownload(DownloadItem* download); 48 void OnStartDownload(DownloadItem* download);
53 49
54 private: 50 private:
55 FRIEND_TEST_ALL_PREFIXES(SavePageBrowserTest, SaveFolder1);
56 FRIEND_TEST_ALL_PREFIXES(SavePageBrowserTest, SaveFolder2);
57 FRIEND_TEST_ALL_PREFIXES(SavePageBrowserTest, SaveFolder3);
58
59 // Used in automated testing to bypass prompting the user for file names.
60 // The difference between SavePageBasedOnDefaultPrefs() and SavePage()
61 // is whether the default folder prefs are used. In case of SavePage(),
62 // we need to give it the file path to which the file is saved.
63 // On the other hand, in case of SavePageBasedOnDefaultPrefs(),
64 // we need not to give the file path since the file path is determined
65 // based on the default folder prefs. This method returns the title
66 // of the current tab.
67 string16 SavePageBasedOnDefaultPrefs();
68
69 // TabContentsObserver overrides. 51 // TabContentsObserver overrides.
70 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 52 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
71 virtual void DidGetUserGesture() OVERRIDE; 53 virtual void DidGetUserGesture() OVERRIDE;
72 54
73 // SavePackage, lazily created. 55 // SavePackage, lazily created.
74 scoped_refptr<SavePackage> save_package_; 56 scoped_refptr<SavePackage> save_package_;
75 57
76 // Owning TabContentsWrapper. 58 // Owning TabContentsWrapper.
77 TabContentsWrapper* tab_contents_wrapper_; 59 TabContentsWrapper* tab_contents_wrapper_;
78 60
79 // Delegate for notifying our owner (usually Browser) about stuff. Not owned 61 // Delegate for notifying our owner (usually Browser) about stuff. Not owned
80 // by us. 62 // by us.
81 DownloadTabHelperDelegate* delegate_; 63 DownloadTabHelperDelegate* delegate_;
82 64
83 DISALLOW_COPY_AND_ASSIGN(DownloadTabHelper); 65 DISALLOW_COPY_AND_ASSIGN(DownloadTabHelper);
84 }; 66 };
85 67
86 #endif // CHROME_BROWSER_UI_DOWNLOAD_DOWNLOAD_TAB_HELPER_H_ 68 #endif // CHROME_BROWSER_UI_DOWNLOAD_DOWNLOAD_TAB_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/download/save_page_browsertest.cc ('k') | chrome/browser/ui/download/download_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698