| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/shell_dialogs/select_file_dialog_win.h" | 5 #include "ui/shell_dialogs/select_file_dialog_win.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 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 base::Unretained(listener_))); | 568 base::Unretained(listener_))); |
| 569 return; | 569 return; |
| 570 } else if (type == SELECT_OPEN_MULTI_FILE) { | 570 } else if (type == SELECT_OPEN_MULTI_FILE) { |
| 571 aura::HandleOpenMultipleFiles( | 571 aura::HandleOpenMultipleFiles( |
| 572 UTF16ToWide(title), | 572 UTF16ToWide(title), |
| 573 default_path, | 573 default_path, |
| 574 GetFilterForFileTypes(*file_types), | 574 GetFilterForFileTypes(*file_types), |
| 575 base::Bind(&ui::SelectFileDialog::Listener::MultiFilesSelected, | 575 base::Bind(&ui::SelectFileDialog::Listener::MultiFilesSelected, |
| 576 base::Unretained(listener_))); | 576 base::Unretained(listener_))); |
| 577 return; | 577 return; |
| 578 } else if (type == SELECT_FOLDER) { | 578 } else if (type == SELECT_FOLDER || type == SELECT_UPLOAD_FOLDER) { |
| 579 std::string16 title_string = title; |
| 580 if (type == SELECT_UPLOAD_FOLDER && title_string.empty()) { |
| 581 // If it's for uploading don't use default dialog title to |
| 582 // make sure we clearly tell it's for uploading. |
| 583 title_string = l10n_util::GetStringUTF16( |
| 584 IDS_SELECT_UPLOAD_FOLDER_DIALOG_TITLE); |
| 585 } |
| 579 aura::HandleSelectFolder( | 586 aura::HandleSelectFolder( |
| 580 UTF16ToWide(title), | 587 UTF16ToWide(title_string), |
| 581 base::Bind(&ui::SelectFileDialog::Listener::FileSelected, | 588 base::Bind(&ui::SelectFileDialog::Listener::FileSelected, |
| 582 base::Unretained(listener_))); | 589 base::Unretained(listener_))); |
| 583 return; | 590 return; |
| 584 } | 591 } |
| 585 } | 592 } |
| 586 HWND owner = owning_window | 593 HWND owner = owning_window |
| 587 ? owning_window->GetRootWindow()->GetAcceleratedWidget() : NULL; | 594 ? owning_window->GetRootWindow()->GetAcceleratedWidget() : NULL; |
| 588 #else | 595 #else |
| 589 HWND owner = owning_window; | 596 HWND owner = owning_window; |
| 590 #endif | 597 #endif |
| (...skipping 26 matching lines...) Expand all Loading... |
| 617 listener_ = NULL; | 624 listener_ = NULL; |
| 618 } | 625 } |
| 619 | 626 |
| 620 void SelectFileDialogImpl::ExecuteSelectFile( | 627 void SelectFileDialogImpl::ExecuteSelectFile( |
| 621 const ExecuteSelectParams& params) { | 628 const ExecuteSelectParams& params) { |
| 622 base::string16 filter = GetFilterForFileTypes(params.file_types); | 629 base::string16 filter = GetFilterForFileTypes(params.file_types); |
| 623 | 630 |
| 624 base::FilePath path = params.default_path; | 631 base::FilePath path = params.default_path; |
| 625 bool success = false; | 632 bool success = false; |
| 626 unsigned filter_index = params.file_type_index; | 633 unsigned filter_index = params.file_type_index; |
| 627 if (params.type == SELECT_FOLDER) { | 634 if (params.type == SELECT_FOLDER || params.type == SELECT_UPLOAD_FOLDER) { |
| 628 success = RunSelectFolderDialog(params.title, | 635 std::wstring title = params.title; |
| 636 if (title.empty() && params.type == SELECT_UPLOAD_FOLDER) { |
| 637 // If it's for uploading don't use default dialog title to |
| 638 // make sure we clearly tell it's for uploading. |
| 639 title = UTF16ToWide( |
| 640 l10n_util::GetStringUTF16(IDS_SELECT_UPLOAD_FOLDER_DIALOG_TITLE)); |
| 641 } |
| 642 success = RunSelectFolderDialog(title, |
| 629 params.run_state.owner, | 643 params.run_state.owner, |
| 630 &path); | 644 &path); |
| 631 } else if (params.type == SELECT_SAVEAS_FILE) { | 645 } else if (params.type == SELECT_SAVEAS_FILE) { |
| 632 std::wstring path_as_wstring = path.value(); | 646 std::wstring path_as_wstring = path.value(); |
| 633 success = SaveFileAsWithFilter(params.run_state.owner, | 647 success = SaveFileAsWithFilter(params.run_state.owner, |
| 634 params.default_path.value(), filter, | 648 params.default_path.value(), filter, |
| 635 params.default_extension, false, &filter_index, &path_as_wstring); | 649 params.default_extension, false, &filter_index, &path_as_wstring); |
| 636 if (success) | 650 if (success) |
| 637 path = base::FilePath(path_as_wstring); | 651 path = base::FilePath(path_as_wstring); |
| 638 DisableOwner(params.run_state.owner); | 652 DisableOwner(params.run_state.owner); |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 return return_value; | 934 return return_value; |
| 921 } | 935 } |
| 922 | 936 |
| 923 SelectFileDialog* CreateWinSelectFileDialog( | 937 SelectFileDialog* CreateWinSelectFileDialog( |
| 924 SelectFileDialog::Listener* listener, | 938 SelectFileDialog::Listener* listener, |
| 925 SelectFilePolicy* policy) { | 939 SelectFilePolicy* policy) { |
| 926 return new SelectFileDialogImpl(listener, policy); | 940 return new SelectFileDialogImpl(listener, policy); |
| 927 } | 941 } |
| 928 | 942 |
| 929 } // namespace ui | 943 } // namespace ui |
| OLD | NEW |