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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 // Get the file type description from the registry. This will be "Text Document" | 69 // Get the file type description from the registry. This will be "Text Document" |
70 // for .txt files, "JPEG Image" for .jpg files, etc. If the registry doesn't | 70 // for .txt files, "JPEG Image" for .jpg files, etc. If the registry doesn't |
71 // have an entry for the file type, we return false, true if the description was | 71 // have an entry for the file type, we return false, true if the description was |
72 // found. 'file_ext' must be in form ".txt". | 72 // found. 'file_ext' must be in form ".txt". |
73 static bool GetRegistryDescriptionFromExtension(const std::wstring& file_ext, | 73 static bool GetRegistryDescriptionFromExtension(const std::wstring& file_ext, |
74 std::wstring* reg_description) { | 74 std::wstring* reg_description) { |
75 DCHECK(reg_description); | 75 DCHECK(reg_description); |
76 base::win::RegKey reg_ext(HKEY_CLASSES_ROOT, file_ext.c_str(), KEY_READ); | 76 base::win::RegKey reg_ext(HKEY_CLASSES_ROOT, file_ext.c_str(), KEY_READ); |
77 std::wstring reg_app; | 77 std::wstring reg_app; |
78 if (reg_ext.ReadValue(NULL, ®_app) && !reg_app.empty()) { | 78 if (reg_ext.ReadValue(NULL, ®_app) == ERROR_SUCCESS && !reg_app.empty()) { |
79 base::win::RegKey reg_link(HKEY_CLASSES_ROOT, reg_app.c_str(), KEY_READ); | 79 base::win::RegKey reg_link(HKEY_CLASSES_ROOT, reg_app.c_str(), KEY_READ); |
80 if (reg_link.ReadValue(NULL, reg_description)) | 80 if (reg_link.ReadValue(NULL, reg_description) == ERROR_SUCCESS) |
81 return true; | 81 return true; |
82 } | 82 } |
83 return false; | 83 return false; |
84 } | 84 } |
85 | 85 |
86 // Set up a filter for a Save/Open dialog, which will consist of |file_ext| file | 86 // Set up a filter for a Save/Open dialog, which will consist of |file_ext| file |
87 // extensions (internally separated by semicolons), |ext_desc| as the text | 87 // extensions (internally separated by semicolons), |ext_desc| as the text |
88 // descriptions of the |file_ext| types (optional), and (optionally) the default | 88 // descriptions of the |file_ext| types (optional), and (optionally) the default |
89 // 'All Files' view. The purpose of the filter is to show only files of a | 89 // 'All Files' view. The purpose of the filter is to show only files of a |
90 // particular type in a Windows Save/Open dialog box. The resulting filter is | 90 // particular type in a Windows Save/Open dialog box. The resulting filter is |
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 void SelectFontDialogImpl::FontNotSelected(void* params, RunState run_state) { | 1122 void SelectFontDialogImpl::FontNotSelected(void* params, RunState run_state) { |
1123 if (listener_) | 1123 if (listener_) |
1124 listener_->FontSelectionCanceled(params); | 1124 listener_->FontSelectionCanceled(params); |
1125 EndRun(run_state); | 1125 EndRun(run_state); |
1126 } | 1126 } |
1127 | 1127 |
1128 // static | 1128 // static |
1129 SelectFontDialog* SelectFontDialog::Create(Listener* listener) { | 1129 SelectFontDialog* SelectFontDialog::Create(Listener* listener) { |
1130 return new SelectFontDialogImpl(listener); | 1130 return new SelectFontDialogImpl(listener); |
1131 } | 1131 } |
OLD | NEW |