| OLD | NEW |
| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // returned: "Text Document\0*.txt\0HTML Document\0*.htm;*.html\0" | 97 // returned: "Text Document\0*.txt\0HTML Document\0*.htm;*.html\0" |
| 98 // "All Files\0*.*\0\0" (in one big string) | 98 // "All Files\0*.*\0\0" (in one big string) |
| 99 // If a description is not provided for a file extension, it will be retrieved | 99 // If a description is not provided for a file extension, it will be retrieved |
| 100 // from the registry. If the file extension does not exist in the registry, it | 100 // from the registry. If the file extension does not exist in the registry, it |
| 101 // will be omitted from the filter, as it is likely a bogus extension. | 101 // will be omitted from the filter, as it is likely a bogus extension. |
| 102 std::wstring FormatFilterForExtensions( | 102 std::wstring FormatFilterForExtensions( |
| 103 const std::vector<std::wstring>& file_ext, | 103 const std::vector<std::wstring>& file_ext, |
| 104 const std::vector<std::wstring>& ext_desc, | 104 const std::vector<std::wstring>& ext_desc, |
| 105 bool include_all_files) { | 105 bool include_all_files) { |
| 106 const std::wstring all_ext = L"*.*"; | 106 const std::wstring all_ext = L"*.*"; |
| 107 const std::wstring all_desc = l10n_util::GetString(IDS_APP_SAVEAS_ALL_FILES); | 107 const std::wstring all_desc = |
| 108 l10n_util::GetStringUTF16(IDS_APP_SAVEAS_ALL_FILES); |
| 108 | 109 |
| 109 DCHECK(file_ext.size() >= ext_desc.size()); | 110 DCHECK(file_ext.size() >= ext_desc.size()); |
| 110 | 111 |
| 111 std::wstring result; | 112 std::wstring result; |
| 112 | 113 |
| 113 for (size_t i = 0; i < file_ext.size(); ++i) { | 114 for (size_t i = 0; i < file_ext.size(); ++i) { |
| 114 std::wstring ext = file_ext[i]; | 115 std::wstring ext = file_ext[i]; |
| 115 std::wstring desc; | 116 std::wstring desc; |
| 116 if (i < ext_desc.size()) | 117 if (i < ext_desc.size()) |
| 117 desc = ext_desc[i]; | 118 desc = ext_desc[i]; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 134 std::wstring ext_name = first_extension; | 135 std::wstring ext_name = first_extension; |
| 135 size_t ext_index = ext_name.find_first_not_of(L'.'); | 136 size_t ext_index = ext_name.find_first_not_of(L'.'); |
| 136 if (ext_index != std::wstring::npos) | 137 if (ext_index != std::wstring::npos) |
| 137 ext_name = ext_name.substr(ext_index); | 138 ext_name = ext_name.substr(ext_index); |
| 138 | 139 |
| 139 if (!GetRegistryDescriptionFromExtension(first_extension, &desc)) { | 140 if (!GetRegistryDescriptionFromExtension(first_extension, &desc)) { |
| 140 // The extension doesn't exist in the registry. Create a description | 141 // The extension doesn't exist in the registry. Create a description |
| 141 // based on the unknown extension type (i.e. if the extension is .qqq, | 142 // based on the unknown extension type (i.e. if the extension is .qqq, |
| 142 // the we create a description "QQQ File (.qqq)"). | 143 // the we create a description "QQQ File (.qqq)"). |
| 143 include_all_files = true; | 144 include_all_files = true; |
| 144 desc = l10n_util::GetStringF(IDS_APP_SAVEAS_EXTENSION_FORMAT, | 145 desc = l10n_util::GetStringFUTF16(IDS_APP_SAVEAS_EXTENSION_FORMAT, |
| 145 l10n_util::ToUpper(ext_name), | 146 l10n_util::ToUpper(ext_name), |
| 146 ext_name); | 147 ext_name); |
| 147 } | 148 } |
| 148 if (desc.empty()) | 149 if (desc.empty()) |
| 149 desc = L"*." + ext_name; | 150 desc = L"*." + ext_name; |
| 150 } | 151 } |
| 151 | 152 |
| 152 result.append(desc.c_str(), desc.size() + 1); // Append NULL too. | 153 result.append(desc.c_str(), desc.size() + 1); // Append NULL too. |
| 153 result.append(ext.c_str(), ext.size() + 1); | 154 result.append(ext.c_str(), ext.size() + 1); |
| 154 } | 155 } |
| 155 | 156 |
| 156 if (include_all_files) { | 157 if (include_all_files) { |
| (...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 void SelectFontDialogImpl::FontNotSelected(void* params, RunState run_state) { | 1122 void SelectFontDialogImpl::FontNotSelected(void* params, RunState run_state) { |
| 1122 if (listener_) | 1123 if (listener_) |
| 1123 listener_->FontSelectionCanceled(params); | 1124 listener_->FontSelectionCanceled(params); |
| 1124 EndRun(run_state); | 1125 EndRun(run_state); |
| 1125 } | 1126 } |
| 1126 | 1127 |
| 1127 // static | 1128 // static |
| 1128 SelectFontDialog* SelectFontDialog::Create(Listener* listener) { | 1129 SelectFontDialog* SelectFontDialog::Create(Listener* listener) { |
| 1129 return new SelectFontDialogImpl(listener); | 1130 return new SelectFontDialogImpl(listener); |
| 1130 } | 1131 } |
| OLD | NEW |