Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_ |
| 6 #define CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 class SaveItem; | 28 class SaveItem; |
| 29 class SavePackage; | 29 class SavePackage; |
| 30 struct SaveFileCreateInfo; | 30 struct SaveFileCreateInfo; |
| 31 | 31 |
| 32 namespace content { | 32 namespace content { |
| 33 class DownloadManager; | 33 class DownloadManager; |
| 34 class WebContents; | 34 class WebContents; |
| 35 } | 35 } |
| 36 | 36 |
| 37 // The SavePackage object manages the process of saving a page as only-html or | 37 // The SavePackage object manages the process of saving a page as only-html or |
| 38 // complete-html and providing the information for displaying saving status. | 38 // complete-html or MHTML and providing the information for displaying saving |
| 39 // Saving page as only-html means means that we save web page to a single HTML | 39 // status. Saving page as only-html means means that we save web page to a |
| 40 // file regardless internal sub resources and sub frames. | 40 // single HTML file regardless internal sub resources and sub frames. Saving |
| 41 // Saving page as complete-html page means we save not only the main html file | 41 // page as complete-html page means we save not only the main html file the user |
| 42 // the user told it to save but also a directory for the auxiliary files such | 42 // told it to save but also a directory for the auxiliary files such as all |
| 43 // as all sub-frame html files, image files, css files and js files. | 43 // sub-frame html files, image files, css files and js files. Saving page as |
| 44 // MHTML means the same thing as complete-html, but it uses the MHTML format to | |
| 45 // contain the html and all auxiliary files in a single text file. | |
| 44 // | 46 // |
| 45 // Each page saving job may include one or multiple files which need to be | 47 // Each page saving job may include one or multiple files which need to be |
| 46 // saved. Each file is represented by a SaveItem, and all SaveItems are owned | 48 // saved. Each file is represented by a SaveItem, and all SaveItems are owned |
| 47 // by the SavePackage. SaveItems are created when a user initiates a page | 49 // by the SavePackage. SaveItems are created when a user initiates a page |
| 48 // saving job, and exist for the duration of one contents's life time. | 50 // saving job, and exist for the duration of one contents's life time. |
| 49 class CONTENT_EXPORT SavePackage | 51 class CONTENT_EXPORT SavePackage |
| 50 : public base::RefCountedThreadSafe<SavePackage>, | 52 : public base::RefCountedThreadSafe<SavePackage>, |
| 51 public content::WebContentsObserver, | 53 public content::WebContentsObserver, |
| 52 public content::DownloadItem::Observer, | 54 public content::DownloadItem::Observer, |
| 53 public base::SupportsWeakPtr<SavePackage> { | 55 public base::SupportsWeakPtr<SavePackage> { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 content::SavePageType save_type() const { return save_type_; } | 113 content::SavePageType save_type() const { return save_type_; } |
| 112 int contents_id() const { return contents_id_; } | 114 int contents_id() const { return contents_id_; } |
| 113 int id() const { return unique_id_; } | 115 int id() const { return unique_id_; } |
| 114 content::WebContents* web_contents() const; | 116 content::WebContents* web_contents() const; |
| 115 | 117 |
| 116 void GetSaveInfo(); | 118 void GetSaveInfo(); |
| 117 | 119 |
| 118 private: | 120 private: |
| 119 friend class base::RefCountedThreadSafe<SavePackage>; | 121 friend class base::RefCountedThreadSafe<SavePackage>; |
| 120 | 122 |
| 123 // Callback for content::WebContents::GenerateMHTML(). | |
| 124 void MHTMLGenerated(const FilePath& path, int64 size); | |
|
cbentzel
2012/04/17 14:45:34
Perhaps prefix with On to make it clear that this
benjhayden
2012/04/17 17:14:36
Done.
| |
| 125 | |
| 121 // For testing only. | 126 // For testing only. |
| 122 SavePackage(content::WebContents* web_contents, | 127 SavePackage(content::WebContents* web_contents, |
| 123 const FilePath& file_full_path, | 128 const FilePath& file_full_path, |
| 124 const FilePath& directory_full_path); | 129 const FilePath& directory_full_path); |
| 125 | 130 |
| 126 virtual ~SavePackage(); | 131 virtual ~SavePackage(); |
| 127 | 132 |
| 128 // Notes from Init() above applies here as well. | 133 // Notes from Init() above applies here as well. |
| 129 void InternalInit(); | 134 void InternalInit(); |
| 130 | 135 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 bool wrote_to_failed_file_; | 312 bool wrote_to_failed_file_; |
| 308 | 313 |
| 309 friend class SavePackageTest; | 314 friend class SavePackageTest; |
| 310 FRIEND_TEST_ALL_PREFIXES(SavePackageTest, TestSuggestedSaveNames); | 315 FRIEND_TEST_ALL_PREFIXES(SavePackageTest, TestSuggestedSaveNames); |
| 311 FRIEND_TEST_ALL_PREFIXES(SavePackageTest, TestLongSafePureFilename); | 316 FRIEND_TEST_ALL_PREFIXES(SavePackageTest, TestLongSafePureFilename); |
| 312 | 317 |
| 313 DISALLOW_COPY_AND_ASSIGN(SavePackage); | 318 DISALLOW_COPY_AND_ASSIGN(SavePackage); |
| 314 }; | 319 }; |
| 315 | 320 |
| 316 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_ | 321 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_ |
| OLD | NEW |