| 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 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 16 #include "base/hash_tables.h" | 16 #include "base/hash_tables.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/task.h" | 19 #include "base/task.h" |
| 20 #include "content/browser/download/download_manager.h" | 20 #include "content/browser/download/download_manager.h" |
| 21 #include "content/browser/tab_contents/tab_contents_observer.h" | 21 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 22 #include "content/common/content_export.h" |
| 22 #include "googleurl/src/gurl.h" | 23 #include "googleurl/src/gurl.h" |
| 23 | 24 |
| 24 class GURL; | 25 class GURL; |
| 25 class MessageLoop; | 26 class MessageLoop; |
| 26 class PrefService; | 27 class PrefService; |
| 27 class SaveFileManager; | 28 class SaveFileManager; |
| 28 class SaveItem; | 29 class SaveItem; |
| 29 class SavePackage; | 30 class SavePackage; |
| 30 class TabContents; | 31 class TabContents; |
| 31 struct SaveFileCreateInfo; | 32 struct SaveFileCreateInfo; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 42 // Saving page as only-html means means that we save web page to a single HTML | 43 // Saving page as only-html means means that we save web page to a single HTML |
| 43 // file regardless internal sub resources and sub frames. | 44 // file regardless internal sub resources and sub frames. |
| 44 // Saving page as complete-html page means we save not only the main html file | 45 // Saving page as complete-html page means we save not only the main html file |
| 45 // the user told it to save but also a directory for the auxiliary files such | 46 // the user told it to save but also a directory for the auxiliary files such |
| 46 // as all sub-frame html files, image files, css files and js files. | 47 // as all sub-frame html files, image files, css files and js files. |
| 47 // | 48 // |
| 48 // Each page saving job may include one or multiple files which need to be | 49 // Each page saving job may include one or multiple files which need to be |
| 49 // saved. Each file is represented by a SaveItem, and all SaveItems are owned | 50 // saved. Each file is represented by a SaveItem, and all SaveItems are owned |
| 50 // by the SavePackage. SaveItems are created when a user initiates a page | 51 // by the SavePackage. SaveItems are created when a user initiates a page |
| 51 // saving job, and exist for the duration of one tab's life time. | 52 // saving job, and exist for the duration of one tab's life time. |
| 52 class SavePackage : public base::RefCountedThreadSafe<SavePackage>, | 53 class CONTENT_EXPORT SavePackage |
| 53 public TabContentsObserver, | 54 : public base::RefCountedThreadSafe<SavePackage>, |
| 54 public DownloadItem::Observer, | 55 public TabContentsObserver, |
| 55 public base::SupportsWeakPtr<SavePackage> { | 56 public DownloadItem::Observer, |
| 57 public base::SupportsWeakPtr<SavePackage> { |
| 56 public: | 58 public: |
| 57 enum SavePackageType { | 59 enum SavePackageType { |
| 58 // The value of the save type before its set by the user. | 60 // The value of the save type before its set by the user. |
| 59 SAVE_TYPE_UNKNOWN = -1, | 61 SAVE_TYPE_UNKNOWN = -1, |
| 60 // User chose to save only the HTML of the page. | 62 // User chose to save only the HTML of the page. |
| 61 SAVE_AS_ONLY_HTML = 0, | 63 SAVE_AS_ONLY_HTML = 0, |
| 62 // User chose to save complete-html page. | 64 // User chose to save complete-html page. |
| 63 SAVE_AS_COMPLETE_HTML = 1 | 65 SAVE_AS_COMPLETE_HTML = 1 |
| 64 }; | 66 }; |
| 65 | 67 |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 friend class SavePackageTest; | 321 friend class SavePackageTest; |
| 320 FRIEND_TEST_ALL_PREFIXES(SavePackageTest, TestSuggestedSaveNames); | 322 FRIEND_TEST_ALL_PREFIXES(SavePackageTest, TestSuggestedSaveNames); |
| 321 FRIEND_TEST_ALL_PREFIXES(SavePackageTest, TestLongSafePureFilename); | 323 FRIEND_TEST_ALL_PREFIXES(SavePackageTest, TestLongSafePureFilename); |
| 322 | 324 |
| 323 ScopedRunnableMethodFactory<SavePackage> method_factory_; | 325 ScopedRunnableMethodFactory<SavePackage> method_factory_; |
| 324 | 326 |
| 325 DISALLOW_COPY_AND_ASSIGN(SavePackage); | 327 DISALLOW_COPY_AND_ASSIGN(SavePackage); |
| 326 }; | 328 }; |
| 327 | 329 |
| 328 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_ | 330 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_ |
| OLD | NEW |