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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 gfx::NativeWindow owning_window, | 543 gfx::NativeWindow owning_window, |
544 void* params) { | 544 void* params) { |
545 has_multiple_file_type_choices_ = | 545 has_multiple_file_type_choices_ = |
546 file_types ? file_types->extensions.size() > 1 : true; | 546 file_types ? file_types->extensions.size() > 1 : true; |
547 // If the owning_window passed in is in metro then we need to forward the | 547 // If the owning_window passed in is in metro then we need to forward the |
548 // file open/save operations to metro. | 548 // file open/save operations to metro. |
549 if (GetShellDialogsDelegate() && | 549 if (GetShellDialogsDelegate() && |
550 GetShellDialogsDelegate()->IsWindowInMetro(owning_window)) { | 550 GetShellDialogsDelegate()->IsWindowInMetro(owning_window)) { |
551 if (type == SELECT_SAVEAS_FILE) { | 551 if (type == SELECT_SAVEAS_FILE) { |
552 win8::MetroViewerProcessHost::HandleSaveFile( | 552 win8::MetroViewerProcessHost::HandleSaveFile( |
553 base::UTF16ToWide(title), | 553 title, |
554 default_path, | 554 default_path, |
555 GetFilterForFileTypes(file_types), | 555 GetFilterForFileTypes(file_types), |
556 file_type_index, | 556 file_type_index, |
557 default_extension, | 557 default_extension, |
558 base::Bind(&ui::SelectFileDialog::Listener::FileSelected, | 558 base::Bind(&ui::SelectFileDialog::Listener::FileSelected, |
559 base::Unretained(listener_)), | 559 base::Unretained(listener_)), |
560 base::Bind(&ui::SelectFileDialog::Listener::FileSelectionCanceled, | 560 base::Bind(&ui::SelectFileDialog::Listener::FileSelectionCanceled, |
561 base::Unretained(listener_))); | 561 base::Unretained(listener_))); |
562 return; | 562 return; |
563 } else if (type == SELECT_OPEN_FILE) { | 563 } else if (type == SELECT_OPEN_FILE) { |
564 win8::MetroViewerProcessHost::HandleOpenFile( | 564 win8::MetroViewerProcessHost::HandleOpenFile( |
565 base::UTF16ToWide(title), | 565 title, |
566 default_path, | 566 default_path, |
567 GetFilterForFileTypes(file_types), | 567 GetFilterForFileTypes(file_types), |
568 base::Bind(&ui::SelectFileDialog::Listener::FileSelected, | 568 base::Bind(&ui::SelectFileDialog::Listener::FileSelected, |
569 base::Unretained(listener_)), | 569 base::Unretained(listener_)), |
570 base::Bind(&ui::SelectFileDialog::Listener::FileSelectionCanceled, | 570 base::Bind(&ui::SelectFileDialog::Listener::FileSelectionCanceled, |
571 base::Unretained(listener_))); | 571 base::Unretained(listener_))); |
572 return; | 572 return; |
573 } else if (type == SELECT_OPEN_MULTI_FILE) { | 573 } else if (type == SELECT_OPEN_MULTI_FILE) { |
574 win8::MetroViewerProcessHost::HandleOpenMultipleFiles( | 574 win8::MetroViewerProcessHost::HandleOpenMultipleFiles( |
575 base::UTF16ToWide(title), | 575 title, |
576 default_path, | 576 default_path, |
577 GetFilterForFileTypes(file_types), | 577 GetFilterForFileTypes(file_types), |
578 base::Bind(&ui::SelectFileDialog::Listener::MultiFilesSelected, | 578 base::Bind(&ui::SelectFileDialog::Listener::MultiFilesSelected, |
579 base::Unretained(listener_)), | 579 base::Unretained(listener_)), |
580 base::Bind(&ui::SelectFileDialog::Listener::FileSelectionCanceled, | 580 base::Bind(&ui::SelectFileDialog::Listener::FileSelectionCanceled, |
581 base::Unretained(listener_))); | 581 base::Unretained(listener_))); |
582 return; | 582 return; |
583 } else if (type == SELECT_FOLDER || type == SELECT_UPLOAD_FOLDER) { | 583 } else if (type == SELECT_FOLDER || type == SELECT_UPLOAD_FOLDER) { |
584 base::string16 title_string = title; | 584 base::string16 title_string = title; |
585 if (type == SELECT_UPLOAD_FOLDER && title_string.empty()) { | 585 if (type == SELECT_UPLOAD_FOLDER && title_string.empty()) { |
586 // If it's for uploading don't use default dialog title to | 586 // If it's for uploading don't use default dialog title to |
587 // make sure we clearly tell it's for uploading. | 587 // make sure we clearly tell it's for uploading. |
588 title_string = l10n_util::GetStringUTF16( | 588 title_string = l10n_util::GetStringUTF16( |
589 IDS_SELECT_UPLOAD_FOLDER_DIALOG_TITLE); | 589 IDS_SELECT_UPLOAD_FOLDER_DIALOG_TITLE); |
590 } | 590 } |
591 win8::MetroViewerProcessHost::HandleSelectFolder( | 591 win8::MetroViewerProcessHost::HandleSelectFolder( |
592 base::UTF16ToWide(title_string), | 592 title_string, |
593 base::Bind(&ui::SelectFileDialog::Listener::FileSelected, | 593 base::Bind(&ui::SelectFileDialog::Listener::FileSelected, |
594 base::Unretained(listener_)), | 594 base::Unretained(listener_)), |
595 base::Bind(&ui::SelectFileDialog::Listener::FileSelectionCanceled, | 595 base::Bind(&ui::SelectFileDialog::Listener::FileSelectionCanceled, |
596 base::Unretained(listener_))); | 596 base::Unretained(listener_))); |
597 return; | 597 return; |
598 } | 598 } |
599 } | 599 } |
600 HWND owner = owning_window && owning_window->GetRootWindow() | 600 HWND owner = owning_window && owning_window->GetRootWindow() |
601 ? owning_window->GetHost()->GetAcceleratedWidget() : NULL; | 601 ? owning_window->GetHost()->GetAcceleratedWidget() : NULL; |
602 | 602 |
603 ExecuteSelectParams execute_params(type, base::UTF16ToWide(title), | 603 ExecuteSelectParams execute_params(type, title, |
604 default_path, file_types, file_type_index, | 604 default_path, file_types, file_type_index, |
605 default_extension, BeginRun(owner), | 605 default_extension, BeginRun(owner), |
606 owner, params); | 606 owner, params); |
607 execute_params.run_state.dialog_thread->message_loop()->PostTask( | 607 execute_params.run_state.dialog_thread->message_loop()->PostTask( |
608 FROM_HERE, | 608 FROM_HERE, |
609 base::Bind(&SelectFileDialogImpl::ExecuteSelectFile, this, | 609 base::Bind(&SelectFileDialogImpl::ExecuteSelectFile, this, |
610 execute_params)); | 610 execute_params)); |
611 } | 611 } |
612 | 612 |
613 bool SelectFileDialogImpl::HasMultipleFileTypeChoicesImpl() { | 613 bool SelectFileDialogImpl::HasMultipleFileTypeChoicesImpl() { |
(...skipping 18 matching lines...) Expand all Loading... |
632 base::string16 filter = GetFilterForFileTypes(¶ms.file_types); | 632 base::string16 filter = GetFilterForFileTypes(¶ms.file_types); |
633 | 633 |
634 base::FilePath path = params.default_path; | 634 base::FilePath path = params.default_path; |
635 bool success = false; | 635 bool success = false; |
636 unsigned filter_index = params.file_type_index; | 636 unsigned filter_index = params.file_type_index; |
637 if (params.type == SELECT_FOLDER || params.type == SELECT_UPLOAD_FOLDER) { | 637 if (params.type == SELECT_FOLDER || params.type == SELECT_UPLOAD_FOLDER) { |
638 std::wstring title = params.title; | 638 std::wstring title = params.title; |
639 if (title.empty() && params.type == SELECT_UPLOAD_FOLDER) { | 639 if (title.empty() && params.type == SELECT_UPLOAD_FOLDER) { |
640 // If it's for uploading don't use default dialog title to | 640 // If it's for uploading don't use default dialog title to |
641 // make sure we clearly tell it's for uploading. | 641 // make sure we clearly tell it's for uploading. |
642 title = base::UTF16ToWide( | 642 title = l10n_util::GetStringUTF16(IDS_SELECT_UPLOAD_FOLDER_DIALOG_TITLE); |
643 l10n_util::GetStringUTF16(IDS_SELECT_UPLOAD_FOLDER_DIALOG_TITLE)); | |
644 } | 643 } |
645 success = RunSelectFolderDialog(title, | 644 success = RunSelectFolderDialog(title, |
646 params.run_state.owner, | 645 params.run_state.owner, |
647 &path); | 646 &path); |
648 } else if (params.type == SELECT_SAVEAS_FILE) { | 647 } else if (params.type == SELECT_SAVEAS_FILE) { |
649 std::wstring path_as_wstring = path.value(); | 648 std::wstring path_as_wstring = path.value(); |
650 success = SaveFileAsWithFilter(params.run_state.owner, | 649 success = SaveFileAsWithFilter(params.run_state.owner, |
651 params.default_path.value(), filter, | 650 params.default_path.value(), filter, |
652 params.default_extension, false, &filter_index, &path_as_wstring); | 651 params.default_extension, false, &filter_index, &path_as_wstring); |
653 if (success) | 652 if (success) |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 return return_value; | 939 return return_value; |
941 } | 940 } |
942 | 941 |
943 SelectFileDialog* CreateWinSelectFileDialog( | 942 SelectFileDialog* CreateWinSelectFileDialog( |
944 SelectFileDialog::Listener* listener, | 943 SelectFileDialog::Listener* listener, |
945 SelectFilePolicy* policy) { | 944 SelectFilePolicy* policy) { |
946 return new SelectFileDialogImpl(listener, policy); | 945 return new SelectFileDialogImpl(listener, policy); |
947 } | 946 } |
948 | 947 |
949 } // namespace ui | 948 } // namespace ui |
OLD | NEW |