diff options
author | paulg@google.com <paulg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-30 20:02:36 +0000 |
---|---|---|
committer | paulg@google.com <paulg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-30 20:02:36 +0000 |
commit | 23b357b59e5eb192d6c747c9ff19c3d91e1556e1 (patch) | |
tree | 7c4673aee2b8fe7748e409cd7a2aa71dae67a951 /chrome/browser/tab_contents | |
parent | 808f640d6ef38a1d879ecfeff30a1c0aae6f9427 (diff) | |
download | chromium_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/tab_contents')
-rw-r--r-- | chrome/browser/tab_contents/web_contents.cc | 33 | ||||
-rw-r--r-- | chrome/browser/tab_contents/web_contents.h | 7 |
2 files changed, 17 insertions, 23 deletions
diff --git a/chrome/browser/tab_contents/web_contents.cc b/chrome/browser/tab_contents/web_contents.cc index 7ba7c1a..5e1d3bb 100644 --- a/chrome/browser/tab_contents/web_contents.cc +++ b/chrome/browser/tab_contents/web_contents.cc @@ -653,26 +653,18 @@ void WebContents::OnSavePage() { return; } - // Get our user preference state. - PrefService* prefs = profile()->GetPrefs(); - DCHECK(prefs); - - FilePath suggest_name = SavePackage::GetSuggestNameForSaveAs(prefs, - FilePath::FromWStringHack(UTF16ToWideHack(GetTitle()))); - - SavePackage::SavePackageParam param(contents_mime_type()); - param.prefs = prefs; + Stop(); - // TODO(rocking): Use new asynchronous dialog boxes to prevent the SaveAs - // dialog blocking the UI thread. See bug: http://b/issue?id=1129694. - if (SavePackage::GetSaveInfo(suggest_name, view_->GetNativeView(), - ¶m, profile()->GetDownloadManager())) { - SavePage(param.saved_main_file_path.ToWStringHack(), - param.dir.ToWStringHack(), - param.save_type); - } + // Create the save package and possibly prompt the user for the name to save + // the page as. The user prompt is an asynchronous operation that runs on + // another thread. + save_package_ = new SavePackage(this); + save_package_->GetSaveInfo(); } +// Used in automated testing to bypass prompting the user for file names. +// Instead, the names and paths are hard coded rather than running them through +// file name sanitation and extension / mime checking. void WebContents::SavePage(const std::wstring& main_file, const std::wstring& dir_path, SavePackage::SavePackageType save_type) { @@ -1157,8 +1149,8 @@ void WebContents::RunFileChooser(bool multiple_files, SelectFileDialog::Type dialog_type = multiple_files ? SelectFileDialog::SELECT_OPEN_MULTI_FILE : SelectFileDialog::SELECT_OPEN_FILE; - select_file_dialog_->SelectFile(dialog_type, title, default_file, filter, - std::wstring(), + select_file_dialog_->SelectFile(dialog_type, title, default_file, + filter, 0, std::wstring(), view_->GetTopLevelNativeWindow(), NULL); } @@ -1573,7 +1565,8 @@ bool WebContents::CanTerminate() const { return !delegate()->IsExternalTabContainer(); } -void WebContents::FileSelected(const std::wstring& path, void* params) { +void WebContents::FileSelected(const std::wstring& path, + int index, void* params) { render_view_host()->FileSelected(path); } diff --git a/chrome/browser/tab_contents/web_contents.h b/chrome/browser/tab_contents/web_contents.h index 3407a93..5aa1093 100644 --- a/chrome/browser/tab_contents/web_contents.h +++ b/chrome/browser/tab_contents/web_contents.h @@ -239,12 +239,13 @@ class WebContents : public TabContents, bool success, const std::wstring& prompt); - // Prepare for saving page. + // Prepare for saving the current web page to disk. void OnSavePage(); // Save page with the main HTML file path, the directory for saving resources, // and the save type: HTML only or complete web page. - void SavePage(const std::wstring& main_file, const std::wstring& dir_path, + void SavePage(const std::wstring& main_file, + const std::wstring& dir_path, SavePackage::SavePackageType save_type); // Displays asynchronously a print preview (generated by the renderer) if not @@ -429,7 +430,7 @@ class WebContents : public TabContents, // SelectFileDialog::Listener ------------------------------------------------ - virtual void FileSelected(const std::wstring& path, void* params); + virtual void FileSelected(const std::wstring& path, int index, void* params); virtual void MultiFilesSelected(const std::vector<std::wstring>& files, void* params); virtual void FileSelectionCanceled(void* params); |