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

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

Issue 2868101: Merge 54625 - Win: Don't give some downloads duplicate extensions like .arj.a... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/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 24 matching lines...) Expand all
35 // SaveAs dialog box and may include the path, |filter_selected| should be 35 // SaveAs dialog box and may include the path, |filter_selected| should be
36 // '*.something', for example '*.*' or it can be blank (which is treated as 36 // '*.something', for example '*.*' or it can be blank (which is treated as
37 // *.*). |suggested_ext| should contain the extension without the dot (.) in 37 // *.*). |suggested_ext| should contain the extension without the dot (.) in
38 // front, for example 'jpg'. 38 // front, for example 'jpg'.
39 std::wstring AppendExtensionIfNeeded(const std::wstring& filename, 39 std::wstring AppendExtensionIfNeeded(const std::wstring& filename,
40 const std::wstring& filter_selected, 40 const std::wstring& filter_selected,
41 const std::wstring& suggested_ext) { 41 const std::wstring& suggested_ext) {
42 DCHECK(!filename.empty()); 42 DCHECK(!filename.empty());
43 std::wstring return_value = filename; 43 std::wstring return_value = filename;
44 44
45 // If the user didn't give us a known extension, and we wanted one, add it. 45 // If we wanted a specific extension, but the user's filename deleted it or
46 // changed it to something that the system doesn't understand, re-append.
46 std::string selected_mime_type; 47 std::string selected_mime_type;
48 std::wstring file_extension = file_util::GetFileExtensionFromPath(filename);
47 if (!(filter_selected.empty() || filter_selected == L"*.*") && 49 if (!(filter_selected.empty() || filter_selected == L"*.*") &&
48 !net::GetMimeTypeFromExtension( 50 !net::GetMimeTypeFromExtension(
49 file_util::GetFileExtensionFromPath(filename), &selected_mime_type)) { 51 file_extension, &selected_mime_type) &&
52 file_extension != suggested_ext) {
50 if (return_value[return_value.length() - 1] != L'.') 53 if (return_value[return_value.length() - 1] != L'.')
51 return_value.append(L"."); 54 return_value.append(L".");
52 return_value.append(suggested_ext); 55 return_value.append(suggested_ext);
53 } 56 }
54 57
55 // Strip any trailing dots, which Windows doesn't allow. 58 // Strip any trailing dots, which Windows doesn't allow.
56 size_t index = return_value.find_last_not_of(L'.'); 59 size_t index = return_value.find_last_not_of(L'.');
57 if (index < return_value.size() - 1) 60 if (index < return_value.size() - 1)
58 return_value.resize(index + 1); 61 return_value.resize(index + 1);
59 62
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 void SelectFontDialogImpl::FontNotSelected(void* params, RunState run_state) { 1119 void SelectFontDialogImpl::FontNotSelected(void* params, RunState run_state) {
1117 if (listener_) 1120 if (listener_)
1118 listener_->FontSelectionCanceled(params); 1121 listener_->FontSelectionCanceled(params);
1119 EndRun(run_state); 1122 EndRun(run_state);
1120 } 1123 }
1121 1124
1122 // static 1125 // static
1123 SelectFontDialog* SelectFontDialog::Create(Listener* listener) { 1126 SelectFontDialog* SelectFontDialog::Create(Listener* listener) {
1124 return new SelectFontDialogImpl(listener); 1127 return new SelectFontDialogImpl(listener);
1125 } 1128 }
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