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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_DOWNLOAD_DOWNLOAD_TAB_HELPER_H_ 6 #define CHROME_BROWSER_UI_DOWNLOAD_DOWNLOAD_TAB_HELPER_H_ 7 #pragma once 8 9 #include "base/basictypes.h" 10 #include "chrome/browser/download/save_package.h" 11 #include "content/browser/tab_contents/tab_contents_observer.h" 12 13 // Per-tab download controller. Handles dealing with various per-tab download 14 // duties. 15 class DownloadTabHelper : public TabContentsObserver { 16 public: 17 explicit DownloadTabHelper(TabContents* tab_contents); 18 virtual ~DownloadTabHelper(); 19 20 // Prepare for saving the current web page to disk. 21 void OnSavePage(); 22 23 // Prepare for saving the URL to disk. 24 // URL may refer to the iframe on the page. 25 void OnSaveURL(const GURL& url); 26 27 // Save page with the main HTML file path, the directory for saving resources, 28 // and the save type: HTML only or complete web page. Returns true if the 29 // saving process has been initiated successfully. 30 bool SavePage(const FilePath& main_file, const FilePath& dir_path, 31 SavePackage::SavePackageType save_type); 32 33 // Returns the SavePackage which manages the page saving job. May be NULL. save_package()34 SavePackage* save_package() const { return save_package_.get(); } 35 36 private: 37 // TabContentsObserver overrides. 38 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 39 40 // SavePackage, lazily created. 41 scoped_refptr<SavePackage> save_package_; 42 43 DISALLOW_COPY_AND_ASSIGN(DownloadTabHelper); 44 }; 45 46 #endif // CHROME_BROWSER_UI_DOWNLOAD_DOWNLOAD_TAB_HELPER_H_ 47