OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/utility/shell_handler_win.h" | 5 #include "chrome/utility/shell_handler_win.h" |
6 | 6 |
7 #include <commdlg.h> | 7 #include <commdlg.h> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 content::UtilityThread::Get()->Send( | 57 content::UtilityThread::Get()->Send( |
58 new ChromeUtilityHostMsg_GetOpenFileName_Failed()); | 58 new ChromeUtilityHostMsg_GetOpenFileName_Failed()); |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 void ShellHandler::OnGetSaveFileName( | 62 void ShellHandler::OnGetSaveFileName( |
63 const ChromeUtilityMsg_GetSaveFileName_Params& params) { | 63 const ChromeUtilityMsg_GetSaveFileName_Params& params) { |
64 ui::win::OpenFileName open_file_name(params.owner, params.flags); | 64 ui::win::OpenFileName open_file_name(params.owner, params.flags); |
65 open_file_name.SetInitialSelection(params.initial_directory, | 65 open_file_name.SetInitialSelection(params.initial_directory, |
66 params.suggested_filename); | 66 params.suggested_filename); |
| 67 open_file_name.SetFilters(params.filters); |
67 open_file_name.GetOPENFILENAME()->nFilterIndex = | 68 open_file_name.GetOPENFILENAME()->nFilterIndex = |
68 params.one_based_filter_index; | 69 params.one_based_filter_index; |
69 open_file_name.GetOPENFILENAME()->lpstrDefExt = | 70 open_file_name.GetOPENFILENAME()->lpstrDefExt = |
70 params.default_extension.c_str(); | 71 params.default_extension.c_str(); |
71 | 72 |
72 open_file_name.MaybeInstallWindowPositionHookForSaveAsOnXP(); | 73 open_file_name.MaybeInstallWindowPositionHookForSaveAsOnXP(); |
73 | 74 |
74 if (::GetSaveFileName(open_file_name.GetOPENFILENAME())) { | 75 if (::GetSaveFileName(open_file_name.GetOPENFILENAME())) { |
75 content::UtilityThread::Get()->Send( | 76 content::UtilityThread::Get()->Send( |
76 new ChromeUtilityHostMsg_GetSaveFileName_Result( | 77 new ChromeUtilityHostMsg_GetSaveFileName_Result( |
77 base::FilePath(open_file_name.GetOPENFILENAME()->lpstrFile), | 78 base::FilePath(open_file_name.GetOPENFILENAME()->lpstrFile), |
78 open_file_name.GetOPENFILENAME()->nFilterIndex)); | 79 open_file_name.GetOPENFILENAME()->nFilterIndex)); |
79 return; | 80 return; |
80 } | 81 } |
81 | 82 |
82 // Zero means the dialog was closed, otherwise we had an error. | 83 // Zero means the dialog was closed, otherwise we had an error. |
83 DWORD error_code = ::CommDlgExtendedError(); | 84 DWORD error_code = ::CommDlgExtendedError(); |
84 if (error_code != 0) | 85 if (error_code != 0) |
85 NOTREACHED() << "GetSaveFileName failed with code: " << error_code; | 86 NOTREACHED() << "GetSaveFileName failed with code: " << error_code; |
86 | 87 |
87 content::UtilityThread::Get()->Send( | 88 content::UtilityThread::Get()->Send( |
88 new ChromeUtilityHostMsg_GetSaveFileName_Failed()); | 89 new ChromeUtilityHostMsg_GetSaveFileName_Failed()); |
89 } | 90 } |
OLD | NEW |