OLD | NEW |
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 "chrome/browser/download/save_package.h" | 10 #include "chrome/browser/download/save_package.h" |
11 #include "content/browser/tab_contents/tab_contents_observer.h" | 11 #include "content/browser/tab_contents/tab_contents_observer.h" |
12 | 12 |
| 13 class DownloadItem; |
| 14 class DownloadTabHelperDelegate; |
13 class TabContentsWrapper; | 15 class TabContentsWrapper; |
14 | 16 |
15 // Per-tab download controller. Handles dealing with various per-tab download | 17 // Per-tab download controller. Handles dealing with various per-tab download |
16 // duties. | 18 // duties. |
17 class DownloadTabHelper : public TabContentsObserver { | 19 class DownloadTabHelper : public TabContentsObserver { |
18 public: | 20 public: |
19 explicit DownloadTabHelper(TabContentsWrapper* tab_contents); | 21 explicit DownloadTabHelper(TabContentsWrapper* tab_contents); |
20 virtual ~DownloadTabHelper(); | 22 virtual ~DownloadTabHelper(); |
21 | 23 |
| 24 DownloadTabHelperDelegate* delegate() const { return delegate_; } |
| 25 void set_delegate(DownloadTabHelperDelegate* d) { delegate_ = d; } |
| 26 |
22 // Prepare for saving the current web page to disk. | 27 // Prepare for saving the current web page to disk. |
23 void OnSavePage(); | 28 void OnSavePage(); |
24 | 29 |
25 // Prepare for saving the URL to disk. | 30 // Prepare for saving the URL to disk. |
26 // URL may refer to the iframe on the page. | 31 // URL may refer to the iframe on the page. |
27 void OnSaveURL(const GURL& url); | 32 void OnSaveURL(const GURL& url); |
28 | 33 |
29 // 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, |
30 // 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 |
31 // saving process has been initiated successfully. | 36 // saving process has been initiated successfully. |
32 bool SavePage(const FilePath& main_file, const FilePath& dir_path, | 37 bool SavePage(const FilePath& main_file, const FilePath& dir_path, |
33 SavePackage::SavePackageType save_type); | 38 SavePackage::SavePackageType save_type); |
34 | 39 |
35 // 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. |
36 SavePackage* save_package() const { return save_package_.get(); } | 41 SavePackage* save_package() const { return save_package_.get(); } |
37 | 42 |
| 43 // 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 bool CanDownload(int request_id); |
| 46 |
| 47 // Notifies the delegate that a download started. |
| 48 void OnStartDownload(DownloadItem* download); |
| 49 |
38 private: | 50 private: |
39 // TabContentsObserver overrides. | 51 // TabContentsObserver overrides. |
40 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 52 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 53 virtual void DidGetUserGesture() OVERRIDE; |
41 | 54 |
42 // SavePackage, lazily created. | 55 // SavePackage, lazily created. |
43 scoped_refptr<SavePackage> save_package_; | 56 scoped_refptr<SavePackage> save_package_; |
44 | 57 |
45 // Owning TabContentsWrapper. | 58 // Owning TabContentsWrapper. |
46 TabContentsWrapper* tab_contents_wrapper_; | 59 TabContentsWrapper* tab_contents_wrapper_; |
47 | 60 |
| 61 // Delegate for notifying our owner (usually Browser) about stuff. Not owned |
| 62 // by us. |
| 63 DownloadTabHelperDelegate* delegate_; |
| 64 |
48 DISALLOW_COPY_AND_ASSIGN(DownloadTabHelper); | 65 DISALLOW_COPY_AND_ASSIGN(DownloadTabHelper); |
49 }; | 66 }; |
50 | 67 |
51 #endif // CHROME_BROWSER_UI_DOWNLOAD_DOWNLOAD_TAB_HELPER_H_ | 68 #endif // CHROME_BROWSER_UI_DOWNLOAD_DOWNLOAD_TAB_HELPER_H_ |
OLD | NEW |