summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/download/save_package.cc4
-rw-r--r--chrome/browser/views/shell_dialogs.cc2
-rw-r--r--chrome/common/win_util.cc11
-rw-r--r--chrome/common/win_util.h7
4 files changed, 19 insertions, 5 deletions
diff --git a/chrome/browser/download/save_package.cc b/chrome/browser/download/save_package.cc
index ac3844e..1127017 100644
--- a/chrome/browser/download/save_package.cc
+++ b/chrome/browser/download/save_package.cc
@@ -947,10 +947,14 @@ bool SavePackage::GetSaveInfo(const std::wstring& suggest_name,
filter[filter.size() - 2] = L'\0';
if (g_should_prompt_for_filename) {
+ // Since we take the suggested name from the web page's title, we want to
+ // ignore the file extension generated by SaveFileAsWithFilter, since it
+ // will always be ".htm".
if (!win_util::SaveFileAsWithFilter(container_hwnd,
suggest_name,
filter,
L"htm",
+ true,
&index,
&param->saved_main_file_path))
return false;
diff --git a/chrome/browser/views/shell_dialogs.cc b/chrome/browser/views/shell_dialogs.cc
index ab85d0a..be3da01 100644
--- a/chrome/browser/views/shell_dialogs.cc
+++ b/chrome/browser/views/shell_dialogs.cc
@@ -304,7 +304,7 @@ void SelectFileDialogImpl::ExecuteSelectFile(
} else if (type == SELECT_SAVEAS_FILE) {
unsigned index = 0;
success = win_util::SaveFileAsWithFilter(run_state.owner, default_path,
- filter, default_extension, &index, &path);
+ filter, default_extension, false, &index, &path);
DisableOwner(run_state.owner);
} else if (type == SELECT_OPEN_FILE) {
success = RunOpenFileDialog(title, filter, run_state.owner, &path);
diff --git a/chrome/common/win_util.cc b/chrome/common/win_util.cc
index 1c552a2..8442bb0 100644
--- a/chrome/common/win_util.cc
+++ b/chrome/common/win_util.cc
@@ -387,6 +387,7 @@ bool SaveFileAs(HWND owner,
suggested_name,
filter,
L"",
+ false,
&index,
final_name);
}
@@ -395,6 +396,7 @@ bool SaveFileAsWithFilter(HWND owner,
const std::wstring& suggested_name,
const std::wstring& filter,
const std::wstring& def_ext,
+ bool ignore_suggested_ext,
unsigned* index,
std::wstring* final_name) {
DCHECK(final_name);
@@ -472,9 +474,12 @@ bool SaveFileAsWithFilter(HWND owner,
filter_selected = filters[(2 * (save_as.nFilterIndex - 1)) + 1];
// Get the extension that was suggested to the user (when the Save As dialog
- // was opened).
- std::wstring suggested_ext =
- file_util::GetFileExtensionFromPath(suggested_name);
+ // was opened). For saving web pages, we skip this step since there may be
+ // 'extension characters' in the title of the web page.
+ std::wstring suggested_ext;
+ if (!ignore_suggested_ext)
+ suggested_ext = file_util::GetFileExtensionFromPath(suggested_name);
+
// If we can't get the extension from the suggested_name, we use the default
// extension passed in. This is to cover cases like when saving a web page,
// where we get passed in a name without an extension and a default extension
diff --git a/chrome/common/win_util.h b/chrome/common/win_util.h
index 5de3329..c93b098 100644
--- a/chrome/common/win_util.h
+++ b/chrome/common/win_util.h
@@ -174,11 +174,16 @@ bool SaveFileAs(HWND owner,
// |final_name| returns the file name which contains the drive designator,
// path, file name, and extension of the user selected file name. |def_ext| is
// the default extension to give to the file if the user did not enter an
-// extension.
+// extension. If |ignore_suggested_ext| is true, any file extension contained in
+// |suggested_name| will not be used to generate the file name. This is useful
+// in the case of saving web pages, where we know the extension type already and
+// where |suggested_name| may contain a '.' character as a valid part of the
+// name, thus confusing our extension detection code.
bool SaveFileAsWithFilter(HWND owner,
const std::wstring& suggested_name,
const std::wstring& filter,
const std::wstring& def_ext,
+ bool ignore_suggested_ext,
unsigned* index,
std::wstring* final_name);