| 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 | 12 |
| 12 // Per-tab download controller. Handles dealing with various per-tab download | 13 // Per-tab download controller. Handles dealing with various per-tab download |
| 13 // duties. | 14 // duties. |
| 14 class DownloadTabHelper { | 15 class DownloadTabHelper : public TabContentsObserver { |
| 15 public: | 16 public: |
| 16 explicit DownloadTabHelper(TabContents* tab_contents); | 17 explicit DownloadTabHelper(TabContents* tab_contents); |
| 17 virtual ~DownloadTabHelper(); | 18 virtual ~DownloadTabHelper(); |
| 18 | 19 |
| 19 // Prepare for saving the current web page to disk. | 20 // Prepare for saving the current web page to disk. |
| 20 void OnSavePage(); | 21 void OnSavePage(); |
| 21 | 22 |
| 22 // Save page with the main HTML file path, the directory for saving resources, | 23 // Save page with the main HTML file path, the directory for saving resources, |
| 23 // and the save type: HTML only or complete web page. Returns true if the | 24 // and the save type: HTML only or complete web page. Returns true if the |
| 24 // saving process has been initiated successfully. | 25 // saving process has been initiated successfully. |
| 25 bool SavePage(const FilePath& main_file, const FilePath& dir_path, | 26 bool SavePage(const FilePath& main_file, const FilePath& dir_path, |
| 26 SavePackage::SavePackageType save_type); | 27 SavePackage::SavePackageType save_type); |
| 27 | 28 |
| 28 // Returns the SavePackage which manages the page saving job. May be NULL. | 29 // Returns the SavePackage which manages the page saving job. May be NULL. |
| 29 SavePackage* save_package() const { return save_package_.get(); } | 30 SavePackage* save_package() const { return save_package_.get(); } |
| 30 | 31 |
| 31 private: | 32 private: |
| 32 TabContents* tab_contents_; | 33 // TabContentsObserver overrides. |
| 34 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 33 | 35 |
| 34 // SavePackage, lazily created. | 36 // SavePackage, lazily created. |
| 35 scoped_refptr<SavePackage> save_package_; | 37 scoped_refptr<SavePackage> save_package_; |
| 36 | 38 |
| 37 DISALLOW_COPY_AND_ASSIGN(DownloadTabHelper); | 39 DISALLOW_COPY_AND_ASSIGN(DownloadTabHelper); |
| 38 }; | 40 }; |
| 39 | 41 |
| 40 #endif // CHROME_BROWSER_UI_DOWNLOAD_DOWNLOAD_TAB_HELPER_H_ | 42 #endif // CHROME_BROWSER_UI_DOWNLOAD_DOWNLOAD_TAB_HELPER_H_ |
| OLD | NEW |