OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/common/win_util.h" | 5 #include "chrome/common/win_util.h" |
6 | 6 |
7 #include <atlbase.h> | 7 #include <atlbase.h> |
8 #include <atlapp.h> | 8 #include <atlapp.h> |
9 #include <commdlg.h> | 9 #include <commdlg.h> |
10 #include <dwmapi.h> | 10 #include <dwmapi.h> |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 int buffer_size = GetDateFormat(LOCALE_USER_DEFAULT, NULL, &date, format_ptr, | 111 int buffer_size = GetDateFormat(LOCALE_USER_DEFAULT, NULL, &date, format_ptr, |
112 NULL, 0); | 112 NULL, 0); |
113 | 113 |
114 std::wstring output; | 114 std::wstring output; |
115 GetDateFormat(LOCALE_USER_DEFAULT, NULL, &date, format_ptr, | 115 GetDateFormat(LOCALE_USER_DEFAULT, NULL, &date, format_ptr, |
116 WriteInto(&output, buffer_size), buffer_size); | 116 WriteInto(&output, buffer_size), buffer_size); |
117 | 117 |
118 return output; | 118 return output; |
119 } | 119 } |
120 | 120 |
121 bool ConvertToLongPath(const std::wstring& short_path, std::wstring* long_path)
{ | 121 bool ConvertToLongPath(const std::wstring& short_path, |
| 122 std::wstring* long_path) { |
122 wchar_t long_path_buf[MAX_PATH]; | 123 wchar_t long_path_buf[MAX_PATH]; |
123 DWORD return_value = GetLongPathName(short_path.c_str(), long_path_buf, | 124 DWORD return_value = GetLongPathName(short_path.c_str(), long_path_buf, |
124 MAX_PATH); | 125 MAX_PATH); |
125 if (return_value != 0 && return_value < MAX_PATH) { | 126 if (return_value != 0 && return_value < MAX_PATH) { |
126 *long_path = long_path_buf; | 127 *long_path = long_path_buf; |
127 return true; | 128 return true; |
128 } | 129 } |
129 | 130 |
130 return false; | 131 return false; |
131 } | 132 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 FilePath dir_path(dir); | 168 FilePath dir_path(dir); |
168 file_util::EnsureEndsWithSeparator(&dir_path); | 169 file_util::EnsureEndsWithSeparator(&dir_path); |
169 dir = dir_path.value(); | 170 dir = dir_path.value(); |
170 | 171 |
171 typedef HRESULT (WINAPI *SHOpenFolderAndSelectItemsFuncPtr)( | 172 typedef HRESULT (WINAPI *SHOpenFolderAndSelectItemsFuncPtr)( |
172 PCIDLIST_ABSOLUTE pidl_Folder, | 173 PCIDLIST_ABSOLUTE pidl_Folder, |
173 UINT cidl, | 174 UINT cidl, |
174 PCUITEMID_CHILD_ARRAY pidls, | 175 PCUITEMID_CHILD_ARRAY pidls, |
175 DWORD flags); | 176 DWORD flags); |
176 | 177 |
177 static SHOpenFolderAndSelectItemsFuncPtr open_folder_and_select_itemsPtr = NUL
L; | 178 static SHOpenFolderAndSelectItemsFuncPtr open_folder_and_select_itemsPtr = |
| 179 NULL; |
178 static bool initialize_open_folder_proc = true; | 180 static bool initialize_open_folder_proc = true; |
179 if (initialize_open_folder_proc) { | 181 if (initialize_open_folder_proc) { |
180 initialize_open_folder_proc = false; | 182 initialize_open_folder_proc = false; |
181 // The SHOpenFolderAndSelectItems API is exposed by shell32 version 6 | 183 // The SHOpenFolderAndSelectItems API is exposed by shell32 version 6 |
182 // and does not exist in Win2K. We attempt to retrieve this function export | 184 // and does not exist in Win2K. We attempt to retrieve this function export |
183 // from shell32 and if it does not exist, we just invoke ShellExecute to | 185 // from shell32 and if it does not exist, we just invoke ShellExecute to |
184 // open the folder thus losing the functionality to select the item in | 186 // open the folder thus losing the functionality to select the item in |
185 // the process. | 187 // the process. |
186 HMODULE shell32_base = GetModuleHandle(L"shell32.dll"); | 188 HMODULE shell32_base = GetModuleHandle(L"shell32.dll"); |
187 if (!shell32_base) { | 189 if (!shell32_base) { |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 } | 911 } |
910 | 912 |
911 ChromeFont GetWindowTitleFont() { | 913 ChromeFont GetWindowTitleFont() { |
912 NONCLIENTMETRICS ncm; | 914 NONCLIENTMETRICS ncm; |
913 win_util::GetNonClientMetrics(&ncm); | 915 win_util::GetNonClientMetrics(&ncm); |
914 ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); | 916 ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); |
915 return ChromeFont::CreateFont(caption_font); | 917 return ChromeFont::CreateFont(caption_font); |
916 } | 918 } |
917 | 919 |
918 } // namespace win_util | 920 } // namespace win_util |
OLD | NEW |