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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 } else if (type == SELECT_OPEN_MULTI_FILE) { | 574 } else if (type == SELECT_OPEN_MULTI_FILE) { |
575 aura::HandleOpenMultipleFiles( | 575 aura::HandleOpenMultipleFiles( |
576 UTF16ToWide(title), | 576 UTF16ToWide(title), |
577 default_path, | 577 default_path, |
578 GetFilterForFileTypes(*file_types), | 578 GetFilterForFileTypes(*file_types), |
579 base::Bind(&ui::SelectFileDialog::Listener::MultiFilesSelected, | 579 base::Bind(&ui::SelectFileDialog::Listener::MultiFilesSelected, |
580 base::Unretained(listener_)), | 580 base::Unretained(listener_)), |
581 base::Bind(&ui::SelectFileDialog::Listener::FileSelectionCanceled, | 581 base::Bind(&ui::SelectFileDialog::Listener::FileSelectionCanceled, |
582 base::Unretained(listener_))); | 582 base::Unretained(listener_))); |
583 return; | 583 return; |
584 } else if (type == SELECT_FOLDER) { | 584 } else if (type == SELECT_FOLDER || type == SELECT_UPLOAD_FOLDER) { |
| 585 base::string16 title_string = title; |
| 586 if (type == SELECT_UPLOAD_FOLDER && title_string.empty()) { |
| 587 // If it's for uploading don't use default dialog title to |
| 588 // make sure we clearly tell it's for uploading. |
| 589 title_string = l10n_util::GetStringUTF16( |
| 590 IDS_SELECT_UPLOAD_FOLDER_DIALOG_TITLE); |
| 591 } |
585 aura::HandleSelectFolder( | 592 aura::HandleSelectFolder( |
586 UTF16ToWide(title), | 593 UTF16ToWide(title_string), |
587 base::Bind(&ui::SelectFileDialog::Listener::FileSelected, | 594 base::Bind(&ui::SelectFileDialog::Listener::FileSelected, |
588 base::Unretained(listener_)), | 595 base::Unretained(listener_)), |
589 base::Bind(&ui::SelectFileDialog::Listener::FileSelectionCanceled, | 596 base::Bind(&ui::SelectFileDialog::Listener::FileSelectionCanceled, |
590 base::Unretained(listener_))); | 597 base::Unretained(listener_))); |
591 return; | 598 return; |
592 } | 599 } |
593 } | 600 } |
594 HWND owner = owning_window | 601 HWND owner = owning_window |
595 ? owning_window->GetRootWindow()->GetAcceleratedWidget() : NULL; | 602 ? owning_window->GetRootWindow()->GetAcceleratedWidget() : NULL; |
596 #else | 603 #else |
(...skipping 28 matching lines...) Expand all Loading... |
625 listener_ = NULL; | 632 listener_ = NULL; |
626 } | 633 } |
627 | 634 |
628 void SelectFileDialogImpl::ExecuteSelectFile( | 635 void SelectFileDialogImpl::ExecuteSelectFile( |
629 const ExecuteSelectParams& params) { | 636 const ExecuteSelectParams& params) { |
630 base::string16 filter = GetFilterForFileTypes(params.file_types); | 637 base::string16 filter = GetFilterForFileTypes(params.file_types); |
631 | 638 |
632 base::FilePath path = params.default_path; | 639 base::FilePath path = params.default_path; |
633 bool success = false; | 640 bool success = false; |
634 unsigned filter_index = params.file_type_index; | 641 unsigned filter_index = params.file_type_index; |
635 if (params.type == SELECT_FOLDER) { | 642 if (params.type == SELECT_FOLDER || params.type == SELECT_UPLOAD_FOLDER) { |
636 success = RunSelectFolderDialog(params.title, | 643 std::wstring title = params.title; |
| 644 if (title.empty() && params.type == SELECT_UPLOAD_FOLDER) { |
| 645 // If it's for uploading don't use default dialog title to |
| 646 // make sure we clearly tell it's for uploading. |
| 647 title = UTF16ToWide( |
| 648 l10n_util::GetStringUTF16(IDS_SELECT_UPLOAD_FOLDER_DIALOG_TITLE)); |
| 649 } |
| 650 success = RunSelectFolderDialog(title, |
637 params.run_state.owner, | 651 params.run_state.owner, |
638 &path); | 652 &path); |
639 } else if (params.type == SELECT_SAVEAS_FILE) { | 653 } else if (params.type == SELECT_SAVEAS_FILE) { |
640 std::wstring path_as_wstring = path.value(); | 654 std::wstring path_as_wstring = path.value(); |
641 success = SaveFileAsWithFilter(params.run_state.owner, | 655 success = SaveFileAsWithFilter(params.run_state.owner, |
642 params.default_path.value(), filter, | 656 params.default_path.value(), filter, |
643 params.default_extension, false, &filter_index, &path_as_wstring); | 657 params.default_extension, false, &filter_index, &path_as_wstring); |
644 if (success) | 658 if (success) |
645 path = base::FilePath(path_as_wstring); | 659 path = base::FilePath(path_as_wstring); |
646 DisableOwner(params.run_state.owner); | 660 DisableOwner(params.run_state.owner); |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 return return_value; | 942 return return_value; |
929 } | 943 } |
930 | 944 |
931 SelectFileDialog* CreateWinSelectFileDialog( | 945 SelectFileDialog* CreateWinSelectFileDialog( |
932 SelectFileDialog::Listener* listener, | 946 SelectFileDialog::Listener* listener, |
933 SelectFilePolicy* policy) { | 947 SelectFilePolicy* policy) { |
934 return new SelectFileDialogImpl(listener, policy); | 948 return new SelectFileDialogImpl(listener, policy); |
935 } | 949 } |
936 | 950 |
937 } // namespace ui | 951 } // namespace ui |
OLD | NEW |