summaryrefslogtreecommitdiffstats
path: root/chrome/browser/download/save_package.h
diff options
context:
space:
mode:
authorpaulg@google.com <paulg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-30 20:02:36 +0000
committerpaulg@google.com <paulg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-30 20:02:36 +0000
commit23b357b59e5eb192d6c747c9ff19c3d91e1556e1 (patch)
tree7c4673aee2b8fe7748e409cd7a2aa71dae67a951 /chrome/browser/download/save_package.h
parent808f640d6ef38a1d879ecfeff30a1c0aae6f9427 (diff)
downloadchromium_src-23b357b59e5eb192d6c747c9ff19c3d91e1556e1.zip
chromium_src-23b357b59e5eb192d6c747c9ff19c3d91e1556e1.tar.gz
chromium_src-23b357b59e5eb192d6c747c9ff19c3d91e1556e1.tar.bz2
Remove Windows "Save As" dialogs from Save Page code.In this change:- convert SavePackage to use async SelectFileDialog- return the chosen filter index in the FileSelected callback- some clean up of save_package.ccBUG=8691 (http://crbug.com/8691)
Review URL: http://codereview.chromium.org/45048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12799 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download/save_package.h')
-rw-r--r--chrome/browser/download/save_package.h54
1 files changed, 31 insertions, 23 deletions
diff --git a/chrome/browser/download/save_package.h b/chrome/browser/download/save_package.h
index 447ab67..5f86a98 100644
--- a/chrome/browser/download/save_package.h
+++ b/chrome/browser/download/save_package.h
@@ -32,11 +32,20 @@ class WebContents;
class URLRequestContext;
class WebContents;
+#if defined(OS_WIN) || defined(OS_LINUX)
+// TODO(port): port this header.
+#include "chrome/browser/shell_dialogs.h"
+#elif defined(OS_MACOSX)
+#include "chrome/common/temp_scaffolding_stubs.h"
+#endif
+
namespace base {
class Thread;
class Time;
}
+struct SavePackageParam;
+
// 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
@@ -50,7 +59,8 @@ class Time;
// by the SavePackage. SaveItems are created when a user initiates a page
// saving job, and exist for the duration of one tab's life time.
class SavePackage : public base::RefCountedThreadSafe<SavePackage>,
- public RenderViewHostDelegate::Save {
+ public RenderViewHostDelegate::Save,
+ public SelectFileDialog::Listener {
public:
enum SavePackageType {
// User chose to save only the HTML of the page.
@@ -76,6 +86,14 @@ class SavePackage : public base::RefCountedThreadSafe<SavePackage>,
FAILED
};
+ // Constructor for user initiated page saving. This constructor results in a
+ // SavePackage that will generate and sanitize a suggested name for the user
+ // in the "Save As" dialog box.
+ SavePackage(WebContents* web_content);
+
+ // This contructor is used only for testing. We can bypass the file and
+ // directory name generation / sanitization by providing well known paths
+ // better suited for tests.
SavePackage(WebContents* web_content,
SavePackageType save_type,
const FilePath& file_full_path,
@@ -117,6 +135,11 @@ class SavePackage : public base::RefCountedThreadSafe<SavePackage>,
// Now we actually use render_process_id as tab's unique id.
int tab_id() const { return tab_id_; }
+ void GetSaveInfo();
+ void ContinueSave(SavePackageParam* param,
+ const std::wstring& final_name,
+ int index);
+
// RenderViewHostDelegate::Save ----------------------------------------------
// Process all of the current page's savable links of subresources, resources
@@ -145,28 +168,6 @@ class SavePackage : public base::RefCountedThreadSafe<SavePackage>,
static FilePath GetSuggestNameForSaveAs(PrefService* prefs,
const FilePath& name);
- // This structure is for storing parameters which we will use to create
- // a SavePackage object later.
- struct SavePackageParam {
- // MIME type of current tab contents.
- const std::string& current_tab_mime_type;
- // Pointer to preference service.
- PrefService* prefs;
- // Type about saving page as only-html or complete-html.
- SavePackageType save_type;
- // File path for main html file.
- FilePath saved_main_file_path;
- // Directory path for saving sub resources and sub html frames.
- FilePath dir;
-
- SavePackageParam(const std::string& mime_type)
- : current_tab_mime_type(mime_type) { }
- };
- static bool GetSaveInfo(const FilePath& suggest_name,
- gfx::NativeView container_window,
- SavePackageParam* param,
- DownloadManager* download_manager);
-
// Check whether we can do the saving page operation for the specified URL.
static bool IsSavableURL(const GURL& url);
@@ -201,6 +202,10 @@ class SavePackage : public base::RefCountedThreadSafe<SavePackage>,
uint32 max_file_path_len,
FilePath::StringType* pure_file_name);
+ // SelectFileDialog::Listener interface.
+ virtual void FileSelected(const std::wstring& path, int index, void* params);
+ virtual void FileSelectionCanceled(void* params);
+
private:
// For testing only.
SavePackage(const FilePath& file_full_path,
@@ -301,6 +306,9 @@ class SavePackage : public base::RefCountedThreadSafe<SavePackage>,
// Unique id for this SavePackage.
const int tab_id_;
+ // For managing select file dialogs.
+ scoped_refptr<SelectFileDialog> select_file_dialog_;
+
friend class SavePackageTest;
DISALLOW_COPY_AND_ASSIGN(SavePackage);
};