| 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 30 matching lines...) Expand all Loading... |
| 41 std::wstring return_value = filename; | 41 std::wstring return_value = filename; |
| 42 | 42 |
| 43 // If we wanted a specific extension, but the user's filename deleted it or | 43 // If we wanted a specific extension, but the user's filename deleted it or |
| 44 // changed it to something that the system doesn't understand, re-append. | 44 // changed it to something that the system doesn't understand, re-append. |
| 45 // Careful: Checking net::GetMimeTypeFromExtension() will only find | 45 // Careful: Checking net::GetMimeTypeFromExtension() will only find |
| 46 // extensions with a known MIME type, which many "known" extensions on Windows | 46 // extensions with a known MIME type, which many "known" extensions on Windows |
| 47 // don't have. So we check directly for the "known extension" registry key. | 47 // don't have. So we check directly for the "known extension" registry key. |
| 48 std::wstring file_extension(file_util::GetFileExtensionFromPath(filename)); | 48 std::wstring file_extension(file_util::GetFileExtensionFromPath(filename)); |
| 49 std::wstring key(L"." + file_extension); | 49 std::wstring key(L"." + file_extension); |
| 50 if (!(filter_selected.empty() || filter_selected == L"*.*") && | 50 if (!(filter_selected.empty() || filter_selected == L"*.*") && |
| 51 !RegKey(HKEY_CLASSES_ROOT, key.c_str()).Valid() && | 51 !RegKey(HKEY_CLASSES_ROOT, key.c_str(), KEY_READ).Valid() && |
| 52 file_extension != suggested_ext) { | 52 file_extension != suggested_ext) { |
| 53 if (return_value[return_value.length() - 1] != L'.') | 53 if (return_value[return_value.length() - 1] != L'.') |
| 54 return_value.append(L"."); | 54 return_value.append(L"."); |
| 55 return_value.append(suggested_ext); | 55 return_value.append(suggested_ext); |
| 56 } | 56 } |
| 57 | 57 |
| 58 // Strip any trailing dots, which Windows doesn't allow. | 58 // Strip any trailing dots, which Windows doesn't allow. |
| 59 size_t index = return_value.find_last_not_of(L'.'); | 59 size_t index = return_value.find_last_not_of(L'.'); |
| 60 if (index < return_value.size() - 1) | 60 if (index < return_value.size() - 1) |
| 61 return_value.resize(index + 1); | 61 return_value.resize(index + 1); |
| (...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 void SelectFontDialogImpl::FontNotSelected(void* params, RunState run_state) { | 1119 void SelectFontDialogImpl::FontNotSelected(void* params, RunState run_state) { |
| 1120 if (listener_) | 1120 if (listener_) |
| 1121 listener_->FontSelectionCanceled(params); | 1121 listener_->FontSelectionCanceled(params); |
| 1122 EndRun(run_state); | 1122 EndRun(run_state); |
| 1123 } | 1123 } |
| 1124 | 1124 |
| 1125 // static | 1125 // static |
| 1126 SelectFontDialog* SelectFontDialog::Create(Listener* listener) { | 1126 SelectFontDialog* SelectFontDialog::Create(Listener* listener) { |
| 1127 return new SelectFontDialogImpl(listener); | 1127 return new SelectFontDialogImpl(listener); |
| 1128 } | 1128 } |
| OLD | NEW |