Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Unified Diff: content/browser/download/save_package.h

Issue 10069014: Save Page As MHTML (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/download/download_manager_impl.cc ('k') | content/browser/download/save_package.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/save_package.h
diff --git a/content/browser/download/save_package.h b/content/browser/download/save_package.h
index 8fefebd7ed5ae2d1a06ea037644100afc972c56e..6edd59c3f9620a23abd23da9e94961ced9ada526 100644
--- a/content/browser/download/save_package.h
+++ b/content/browser/download/save_package.h
@@ -19,6 +19,7 @@
#include "base/time.h"
#include "content/common/content_export.h"
#include "content/public/browser/download_item.h"
+#include "content/public/browser/download_manager_delegate.h"
#include "content/public/browser/save_page_type.h"
#include "content/public/browser/web_contents_observer.h"
#include "googleurl/src/gurl.h"
@@ -35,12 +36,14 @@ class WebContents;
}
// The SavePackage object manages the process of saving a page as only-html or
-// complete-html and providing the information for displaying saving status.
-// Saving page as only-html means means that we save web page to a single HTML
-// file regardless internal sub resources and sub frames.
-// Saving page as complete-html page means we save not only the main html file
-// the user told it to save but also a directory for the auxiliary files such
-// as all sub-frame html files, image files, css files and js files.
+// complete-html or MHTML and providing the information for displaying saving
+// status. Saving page as only-html means means that we save web page to a
+// single HTML file regardless internal sub resources and sub frames. Saving
+// page as complete-html page means we save not only the main html file the user
+// told it to save but also a directory for the auxiliary files such as all
+// sub-frame html files, image files, css files and js files. Saving page as
+// MHTML means the same thing as complete-html, but it uses the MHTML format to
+// contain the html and all auxiliary files in a single text file.
//
// Each page saving job may include one or multiple files which need to be
// saved. Each file is represented by a SaveItem, and all SaveItems are owned
@@ -84,11 +87,12 @@ class CONTENT_EXPORT SavePackage
const FilePath& file_full_path,
const FilePath& directory_full_path);
- // Initialize the SavePackage. Returns true if it initializes properly.
- // Need to make sure that this method must be called in the UI thread because
- // using g_browser_process on a non-UI thread can cause crashes during
- // shutdown.
- bool Init();
+ // Initialize the SavePackage. Returns true if it initializes properly. Need
+ // to make sure that this method must be called in the UI thread because using
+ // g_browser_process on a non-UI thread can cause crashes during shutdown.
+ // |cb| will be called when the DownloadItem is created, before data is
+ // written to disk.
+ bool Init(const content::SavePackageDownloadCreatedCallback& cb);
// Cancel all in progress request, might be called by user or internal error.
void Cancel(bool user_action);
@@ -118,6 +122,9 @@ class CONTENT_EXPORT SavePackage
private:
friend class base::RefCountedThreadSafe<SavePackage>;
+ // Callback for content::WebContents::GenerateMHTML().
+ void OnMHTMLGenerated(const FilePath& path, int64 size);
+
// For testing only.
SavePackage(content::WebContents* web_contents,
const FilePath& file_full_path,
@@ -185,7 +192,10 @@ class CONTENT_EXPORT SavePackage
const std::string& accept_langs);
void ContinueGetSaveInfo(const FilePath& suggested_path,
bool can_save_as_complete);
- void OnPathPicked(const FilePath& final_name, content::SavePageType type);
+ void OnPathPicked(
+ const FilePath& final_name,
+ content::SavePageType type,
+ const content::SavePackageDownloadCreatedCallback& cb);
void OnReceivedSavableResourceLinksForCurrentPage(
const std::vector<GURL>& resources_list,
const std::vector<GURL>& referrers_list,
@@ -270,6 +280,9 @@ class CONTENT_EXPORT SavePackage
// Indicates whether the actual saving job is finishing or not.
bool finished_;
+ // Indicates whether a call to Finish() has been scheduled.
+ bool mhtml_finishing_;
+
// Indicates whether user canceled the saving job.
bool user_canceled_;
« no previous file with comments | « content/browser/download/download_manager_impl.cc ('k') | content/browser/download/save_package.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698