From 15bc8050874dd8108a222e17e99344afcbe99a55 Mon Sep 17 00:00:00 2001 From: "avi@chromium.org" Date: Fri, 17 Apr 2009 19:57:24 +0000 Subject: Fixes saving files that don't have valid extensions. Two fixes here. First was a disturbing discovery that FilePath::Extension returns an extension starting with a period. I am of the belief that this is the wrong API to expose, but that's a different fight. Fixed. Second is a subtle behavior of the old code that wasn't preserved. In the case where the extension did not exist in the registry, the old code dropped the extension from the filter. We now also do so. BUG=10561 Review URL: http://codereview.chromium.org/79045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13960 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/download/download_manager.cc | 2 ++ chrome/browser/download/save_package.cc | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'chrome/browser/download') diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc index 4e133e9..5a5649c 100644 --- a/chrome/browser/download/download_manager.cc +++ b/chrome/browser/download/download_manager.cc @@ -641,6 +641,8 @@ void DownloadManager::OnPathExistenceAvailable(DownloadCreateInfo* info) { SelectFileDialog::FileTypeInfo file_type_info; file_type_info.extensions.resize(1); file_type_info.extensions[0].push_back(info->suggested_path.Extension()); + if (!file_type_info.extensions[0][0].empty()) + file_type_info.extensions[0][0].erase(0, 1); // drop the . file_type_info.include_all_files = true; gfx::NativeWindow owning_window = contents ? platform_util::GetTopLevel(contents->GetNativeView()) : NULL; diff --git a/chrome/browser/download/save_package.cc b/chrome/browser/download/save_package.cc index 0c40a82..3fc1738 100644 --- a/chrome/browser/download/save_package.cc +++ b/chrome/browser/download/save_package.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -1021,6 +1021,8 @@ void SavePackage::GetSaveInfo() { } else { file_type_info.extensions.resize(1); file_type_info.extensions[0].push_back(suggested_path.Extension()); + if (!file_type_info.extensions[0][0].empty()) + file_type_info.extensions[0][0].erase(0, 1); // drop the . file_type_info.include_all_files = true; file_type_index = 1; } -- cgit v1.1