summaryrefslogtreecommitdiffstats
path: root/chrome/browser/download/save_package.cc
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-12 20:03:08 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-12 20:03:08 +0000
commitb949f1110dea9e220706cbe72ede4118d78308f0 (patch)
tree16627db33014921df4287548a54caac852dd76eb /chrome/browser/download/save_package.cc
parent3e1302168c2b16d744486172b55dc48114baac7e (diff)
downloadchromium_src-b949f1110dea9e220706cbe72ede4118d78308f0.zip
chromium_src-b949f1110dea9e220706cbe72ede4118d78308f0.tar.gz
chromium_src-b949f1110dea9e220706cbe72ede4118d78308f0.tar.bz2
Refactoring; switch the |filter| parameter into something that is more amenable to cross-platform implementation.
BUG=9852 Review URL: http://codereview.chromium.org/63093 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13573 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download/save_package.cc')
-rw-r--r--chrome/browser/download/save_package.cc34
1 files changed, 17 insertions, 17 deletions
diff --git a/chrome/browser/download/save_package.cc b/chrome/browser/download/save_package.cc
index 23bb704..01a1b26 100644
--- a/chrome/browser/download/save_package.cc
+++ b/chrome/browser/download/save_package.cc
@@ -995,8 +995,8 @@ FilePath SavePackage::GetSuggestNameForSaveAs(PrefService* prefs,
void SavePackage::GetSaveInfo() {
// Use "Web Page, Complete" option as default choice of saving page.
- int filter_index = 2;
- std::wstring filter;
+ int file_type_index = 2;
+ SelectFileDialog::FileTypeInfo file_type_info;
FilePath::StringType default_extension;
FilePath title =
FilePath::FromWStringHack(UTF16ToWideHack(web_contents_->GetTitle()));
@@ -1009,22 +1009,22 @@ void SavePackage::GetSaveInfo() {
// If the contents can not be saved as complete-HTML, do not show the
// file filters.
if (CanSaveAsComplete(save_params->current_tab_mime_type)) {
- filter = l10n_util::GetString(IDS_SAVE_PAGE_FILTER);
- filter.resize(filter.size() + 2);
- filter[filter.size() - 1] = L'\0';
- filter[filter.size() - 2] = L'\0';
+ file_type_info.extensions.resize(2);
+ file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("htm"));
+ file_type_info.extension_description_overrides.push_back(
+ WideToUTF16(l10n_util::GetString(IDS_SAVE_PAGE_DESC_HTML_ONLY)));
+ file_type_info.extensions[1].push_back(FILE_PATH_LITERAL("htm"));
+ file_type_info.extension_description_overrides.push_back(
+ WideToUTF16(l10n_util::GetString(IDS_SAVE_PAGE_DESC_COMPLETE)));
+ file_type_info.include_all_files = false;
default_extension = FILE_PATH_LITERAL("htm");
} else {
-#if defined(OS_WIN)
- filter = win_util::GetFileFilterFromPath(suggested_path.ToWStringHack());
-#else
- // TODO(port): implement this.
- NOTIMPLEMENTED();
-#endif
- filter_index = 1;
+ file_type_info.extensions.resize(1);
+ file_type_info.extensions[0].push_back(suggested_path.Extension());
+ file_type_info.include_all_files = true;
+ file_type_index = 1;
}
-
#if defined(OS_LINUX) || defined(OS_WIN)
if (g_should_prompt_for_filename) {
if (!select_file_dialog_.get())
@@ -1032,8 +1032,8 @@ void SavePackage::GetSaveInfo() {
select_file_dialog_->SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE,
string16(),
suggested_path,
- filter,
- filter_index,
+ &file_type_info,
+ file_type_index,
default_extension,
platform_util::GetTopLevel(
web_contents_->GetNativeView()),
@@ -1042,7 +1042,7 @@ void SavePackage::GetSaveInfo() {
#endif // defined(OS_LINUX) || defined(OS_WIN)
{
// Just use 'suggested_path' instead of opening the dialog prompt.
- ContinueSave(save_params, suggested_path, filter_index);
+ ContinueSave(save_params, suggested_path, file_type_index);
delete save_params;
}
}