| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "app/win_util.h" | 5 #include "app/win_util.h" |
| 6 | 6 |
| 7 #include <commdlg.h> | 7 #include <commdlg.h> |
| 8 #include <dwmapi.h> | 8 #include <dwmapi.h> |
| 9 #include <propvarutil.h> | 9 #include <propvarutil.h> |
| 10 #include <shellapi.h> | 10 #include <shellapi.h> |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 include_all_files = true; | 260 include_all_files = true; |
| 261 continue; | 261 continue; |
| 262 } | 262 } |
| 263 | 263 |
| 264 if (desc.empty()) { | 264 if (desc.empty()) { |
| 265 DCHECK(ext.find(L'.') != std::wstring::npos); | 265 DCHECK(ext.find(L'.') != std::wstring::npos); |
| 266 std::wstring first_extension = ext.substr(ext.find(L'.')); | 266 std::wstring first_extension = ext.substr(ext.find(L'.')); |
| 267 size_t first_separator_index = first_extension.find(L';'); | 267 size_t first_separator_index = first_extension.find(L';'); |
| 268 if (first_separator_index != std::wstring::npos) | 268 if (first_separator_index != std::wstring::npos) |
| 269 first_extension = first_extension.substr(0, first_separator_index); | 269 first_extension = first_extension.substr(0, first_separator_index); |
| 270 |
| 271 // Find the extension name without the preceeding '.' character. |
| 272 std::wstring ext_name = first_extension; |
| 273 size_t ext_index = ext_name.find_first_not_of(L'.'); |
| 274 if (ext_index != std::wstring::npos) |
| 275 ext_name = ext_name.substr(ext_index); |
| 276 |
| 270 if (!GetRegistryDescriptionFromExtension(first_extension, &desc)) { | 277 if (!GetRegistryDescriptionFromExtension(first_extension, &desc)) { |
| 271 // The extension doesn't exist in the registry. It's likely bogus, so | 278 // The extension doesn't exist in the registry. Create a description |
| 272 // just drop it. | 279 // based on the unknown extension type (i.e. if the extension is .qqq, |
| 280 // the we create a description "QQQ File (.qqq)"). |
| 273 include_all_files = true; | 281 include_all_files = true; |
| 274 continue; | 282 desc = l10n_util::GetStringF(IDS_APP_SAVEAS_EXTENSION_FORMAT, |
| 283 l10n_util::ToUpper(ext_name), |
| 284 ext_name); |
| 275 } | 285 } |
| 276 if (desc.empty()) | 286 if (desc.empty()) |
| 277 desc = L"*." + first_extension; | 287 desc = L"*." + ext_name; |
| 278 } | 288 } |
| 279 | 289 |
| 280 result.append(desc.c_str(), desc.size()+1); // Append NULL too. | 290 result.append(desc.c_str(), desc.size() + 1); // Append NULL too. |
| 281 result.append(ext.c_str(), ext.size()+1); | 291 result.append(ext.c_str(), ext.size() + 1); |
| 282 } | 292 } |
| 283 | 293 |
| 284 if (include_all_files) { | 294 if (include_all_files) { |
| 285 result.append(all_desc.c_str(), all_desc.size()+1); | 295 result.append(all_desc.c_str(), all_desc.size() + 1); |
| 286 result.append(all_ext.c_str(), all_ext.size()+1); | 296 result.append(all_ext.c_str(), all_ext.size() + 1); |
| 287 } | 297 } |
| 288 | 298 |
| 289 result.append(1, '\0'); // Double NULL required. | 299 result.append(1, '\0'); // Double NULL required. |
| 290 return result; | 300 return result; |
| 291 } | 301 } |
| 292 | 302 |
| 293 bool SaveFileAs(HWND owner, | 303 bool SaveFileAs(HWND owner, |
| 294 const std::wstring& suggested_name, | 304 const std::wstring& suggested_name, |
| 295 std::wstring* final_name) { | 305 std::wstring* final_name) { |
| 296 std::wstring file_ext = file_util::GetFileExtensionFromPath(suggested_name); | 306 std::wstring file_ext = file_util::GetFileExtensionFromPath(suggested_name); |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 if (S_OK == pps->SetValue(PKEY_AppUserModel_ID, pv)) | 890 if (S_OK == pps->SetValue(PKEY_AppUserModel_ID, pv)) |
| 881 pps->Commit(); | 891 pps->Commit(); |
| 882 } | 892 } |
| 883 | 893 |
| 884 // Cleanup. | 894 // Cleanup. |
| 885 PropVariantClear(&pv); | 895 PropVariantClear(&pv); |
| 886 base::UnloadNativeLibrary(shell32_library); | 896 base::UnloadNativeLibrary(shell32_library); |
| 887 } | 897 } |
| 888 | 898 |
| 889 } // namespace win_util | 899 } // namespace win_util |
| OLD | NEW |