| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/shell_dialogs.h" | 5 #include "chrome/browser/ui/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 |
| 11 #include <algorithm> | 11 #include <algorithm> |
| 12 #include <set> | 12 #include <set> |
| 13 | 13 |
| 14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
| 17 #include "base/scoped_comptr_win.h" | |
| 18 #include "base/string_split.h" | 17 #include "base/string_split.h" |
| 19 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
| 20 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 21 #include "base/win/registry.h" | 20 #include "base/win/registry.h" |
| 21 #include "base/win/scoped_comptr.h" |
| 22 #include "base/win/windows_version.h" | 22 #include "base/win/windows_version.h" |
| 23 #include "content/browser/browser_thread.h" | 23 #include "content/browser/browser_thread.h" |
| 24 #include "grit/app_strings.h" | 24 #include "grit/app_strings.h" |
| 25 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| 27 | 27 |
| 28 // This function takes the output of a SaveAs dialog: a filename, a filter and | 28 // This function takes the output of a SaveAs dialog: a filename, a filter and |
| 29 // the extension originally suggested to the user (shown in the dialog box) and | 29 // the extension originally suggested to the user (shown in the dialog box) and |
| 30 // returns back the filename with the appropriate extension tacked on. If the | 30 // returns back the filename with the appropriate extension tacked on. If the |
| 31 // user requests an unknown extension and is not using the 'All files' filter, | 31 // user requests an unknown extension and is not using the 'All files' filter, |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 browse_info.lParam = (LPARAM)path->value().c_str(); | 793 browse_info.lParam = (LPARAM)path->value().c_str(); |
| 794 browse_info.lpfn = &BrowseCallbackProc; | 794 browse_info.lpfn = &BrowseCallbackProc; |
| 795 } | 795 } |
| 796 | 796 |
| 797 LPITEMIDLIST list = SHBrowseForFolder(&browse_info); | 797 LPITEMIDLIST list = SHBrowseForFolder(&browse_info); |
| 798 DisableOwner(owner); | 798 DisableOwner(owner); |
| 799 if (list) { | 799 if (list) { |
| 800 STRRET out_dir_buffer; | 800 STRRET out_dir_buffer; |
| 801 ZeroMemory(&out_dir_buffer, sizeof(out_dir_buffer)); | 801 ZeroMemory(&out_dir_buffer, sizeof(out_dir_buffer)); |
| 802 out_dir_buffer.uType = STRRET_WSTR; | 802 out_dir_buffer.uType = STRRET_WSTR; |
| 803 ScopedComPtr<IShellFolder> shell_folder; | 803 base::win::ScopedComPtr<IShellFolder> shell_folder; |
| 804 if (SHGetDesktopFolder(shell_folder.Receive()) == NOERROR) { | 804 if (SHGetDesktopFolder(shell_folder.Receive()) == NOERROR) { |
| 805 HRESULT hr = shell_folder->GetDisplayNameOf(list, SHGDN_FORPARSING, | 805 HRESULT hr = shell_folder->GetDisplayNameOf(list, SHGDN_FORPARSING, |
| 806 &out_dir_buffer); | 806 &out_dir_buffer); |
| 807 if (SUCCEEDED(hr) && out_dir_buffer.uType == STRRET_WSTR) { | 807 if (SUCCEEDED(hr) && out_dir_buffer.uType == STRRET_WSTR) { |
| 808 *path = FilePath(out_dir_buffer.pOleStr); | 808 *path = FilePath(out_dir_buffer.pOleStr); |
| 809 CoTaskMemFree(out_dir_buffer.pOleStr); | 809 CoTaskMemFree(out_dir_buffer.pOleStr); |
| 810 result = true; | 810 result = true; |
| 811 } else { | 811 } else { |
| 812 // Use old way if we don't get what we want. | 812 // Use old way if we don't get what we want. |
| 813 wchar_t old_out_dir_buffer[MAX_PATH + 1]; | 813 wchar_t old_out_dir_buffer[MAX_PATH + 1]; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 } | 931 } |
| 932 } | 932 } |
| 933 } | 933 } |
| 934 return success; | 934 return success; |
| 935 } | 935 } |
| 936 | 936 |
| 937 // static | 937 // static |
| 938 SelectFileDialog* SelectFileDialog::Create(Listener* listener) { | 938 SelectFileDialog* SelectFileDialog::Create(Listener* listener) { |
| 939 return new SelectFileDialogImpl(listener); | 939 return new SelectFileDialogImpl(listener); |
| 940 } | 940 } |
| OLD | NEW |