Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: chrome/browser/views/shell_dialogs_win.cc

Issue 3069018: Win: Don't give some downloads duplicate extensions like .arj.arj... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/views/shell_dialogs_win_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/shell_dialogs.h" 5 #include "chrome/browser/shell_dialogs.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <commdlg.h> 8 #include <commdlg.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 10
(...skipping 23 matching lines...) Expand all
34 // SaveAs dialog box and may include the path, |filter_selected| should be 34 // SaveAs dialog box and may include the path, |filter_selected| should be
35 // '*.something', for example '*.*' or it can be blank (which is treated as 35 // '*.something', for example '*.*' or it can be blank (which is treated as
36 // *.*). |suggested_ext| should contain the extension without the dot (.) in 36 // *.*). |suggested_ext| should contain the extension without the dot (.) in
37 // front, for example 'jpg'. 37 // front, for example 'jpg'.
38 std::wstring AppendExtensionIfNeeded(const std::wstring& filename, 38 std::wstring AppendExtensionIfNeeded(const std::wstring& filename,
39 const std::wstring& filter_selected, 39 const std::wstring& filter_selected,
40 const std::wstring& suggested_ext) { 40 const std::wstring& suggested_ext) {
41 DCHECK(!filename.empty()); 41 DCHECK(!filename.empty());
42 std::wstring return_value = filename; 42 std::wstring return_value = filename;
43 43
44 // If the user didn't give us a known extension, and we wanted one, add it. 44 // If we wanted a specific extension, but the user's filename deleted it or
45 // changed it to something that the system doesn't understand, re-append.
45 std::string selected_mime_type; 46 std::string selected_mime_type;
47 std::wstring file_extension = file_util::GetFileExtensionFromPath(filename);
46 if (!(filter_selected.empty() || filter_selected == L"*.*") && 48 if (!(filter_selected.empty() || filter_selected == L"*.*") &&
47 !net::GetMimeTypeFromExtension( 49 !net::GetMimeTypeFromExtension(
48 file_util::GetFileExtensionFromPath(filename), &selected_mime_type)) { 50 file_extension, &selected_mime_type) &&
51 file_extension != suggested_ext) {
49 if (return_value[return_value.length() - 1] != L'.') 52 if (return_value[return_value.length() - 1] != L'.')
50 return_value.append(L"."); 53 return_value.append(L".");
51 return_value.append(suggested_ext); 54 return_value.append(suggested_ext);
52 } 55 }
53 56
54 // Strip any trailing dots, which Windows doesn't allow. 57 // Strip any trailing dots, which Windows doesn't allow.
55 size_t index = return_value.find_last_not_of(L'.'); 58 size_t index = return_value.find_last_not_of(L'.');
56 if (index < return_value.size() - 1) 59 if (index < return_value.size() - 1)
57 return_value.resize(index + 1); 60 return_value.resize(index + 1);
58 61
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 void SelectFontDialogImpl::FontNotSelected(void* params, RunState run_state) { 1118 void SelectFontDialogImpl::FontNotSelected(void* params, RunState run_state) {
1116 if (listener_) 1119 if (listener_)
1117 listener_->FontSelectionCanceled(params); 1120 listener_->FontSelectionCanceled(params);
1118 EndRun(run_state); 1121 EndRun(run_state);
1119 } 1122 }
1120 1123
1121 // static 1124 // static
1122 SelectFontDialog* SelectFontDialog::Create(Listener* listener) { 1125 SelectFontDialog* SelectFontDialog::Create(Listener* listener) {
1123 return new SelectFontDialogImpl(listener); 1126 return new SelectFontDialogImpl(listener);
1124 } 1127 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/views/shell_dialogs_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698