Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: ui/shell_dialogs/select_file_dialog_win.cc

Issue 15704005: ui/shell_dialogs: Use base::string16 now that string16 was moved into base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/shell_dialogs/select_file_dialog_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 ui::SelectFilePolicy* policy); 414 ui::SelectFilePolicy* policy);
415 415
416 // BaseShellDialog implementation: 416 // BaseShellDialog implementation:
417 virtual bool IsRunning(gfx::NativeWindow owning_hwnd) const OVERRIDE; 417 virtual bool IsRunning(gfx::NativeWindow owning_hwnd) const OVERRIDE;
418 virtual void ListenerDestroyed() OVERRIDE; 418 virtual void ListenerDestroyed() OVERRIDE;
419 419
420 protected: 420 protected:
421 // SelectFileDialog implementation: 421 // SelectFileDialog implementation:
422 virtual void SelectFileImpl( 422 virtual void SelectFileImpl(
423 Type type, 423 Type type,
424 const string16& title, 424 const base::string16& title,
425 const base::FilePath& default_path, 425 const base::FilePath& default_path,
426 const FileTypeInfo* file_types, 426 const FileTypeInfo* file_types,
427 int file_type_index, 427 int file_type_index,
428 const base::FilePath::StringType& default_extension, 428 const base::FilePath::StringType& default_extension,
429 gfx::NativeWindow owning_window, 429 gfx::NativeWindow owning_window,
430 void* params) OVERRIDE; 430 void* params) OVERRIDE;
431 431
432 private: 432 private:
433 virtual ~SelectFileDialogImpl(); 433 virtual ~SelectFileDialogImpl();
434 434
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 509
510 // The callback function for when the select folder dialog is opened. 510 // The callback function for when the select folder dialog is opened.
511 static int CALLBACK BrowseCallbackProc(HWND window, UINT message, 511 static int CALLBACK BrowseCallbackProc(HWND window, UINT message,
512 LPARAM parameter, 512 LPARAM parameter,
513 LPARAM data); 513 LPARAM data);
514 514
515 virtual bool HasMultipleFileTypeChoicesImpl() OVERRIDE; 515 virtual bool HasMultipleFileTypeChoicesImpl() OVERRIDE;
516 516
517 // Returns the filter to be used while displaying the open/save file dialog. 517 // Returns the filter to be used while displaying the open/save file dialog.
518 // This is computed from the extensions for the file types being opened. 518 // This is computed from the extensions for the file types being opened.
519 string16 GetFilterForFileTypes(const FileTypeInfo& file_types); 519 base::string16 GetFilterForFileTypes(const FileTypeInfo& file_types);
520 520
521 bool has_multiple_file_type_choices_; 521 bool has_multiple_file_type_choices_;
522 522
523 DISALLOW_COPY_AND_ASSIGN(SelectFileDialogImpl); 523 DISALLOW_COPY_AND_ASSIGN(SelectFileDialogImpl);
524 }; 524 };
525 525
526 SelectFileDialogImpl::SelectFileDialogImpl(Listener* listener, 526 SelectFileDialogImpl::SelectFileDialogImpl(Listener* listener,
527 ui::SelectFilePolicy* policy) 527 ui::SelectFilePolicy* policy)
528 : SelectFileDialog(listener, policy), 528 : SelectFileDialog(listener, policy),
529 BaseShellDialogImpl(), 529 BaseShellDialogImpl(),
530 has_multiple_file_type_choices_(false) { 530 has_multiple_file_type_choices_(false) {
531 } 531 }
532 532
533 SelectFileDialogImpl::~SelectFileDialogImpl() { 533 SelectFileDialogImpl::~SelectFileDialogImpl() {
534 } 534 }
535 535
536 void SelectFileDialogImpl::SelectFileImpl( 536 void SelectFileDialogImpl::SelectFileImpl(
537 Type type, 537 Type type,
538 const string16& title, 538 const base::string16& title,
539 const base::FilePath& default_path, 539 const base::FilePath& default_path,
540 const FileTypeInfo* file_types, 540 const FileTypeInfo* file_types,
541 int file_type_index, 541 int file_type_index,
542 const base::FilePath::StringType& default_extension, 542 const base::FilePath::StringType& default_extension,
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 defined(USE_AURA) 547 #if defined(USE_AURA)
548 // If the owning_window passed in is in metro then we need to forward the 548 // If the owning_window passed in is in metro then we need to forward the
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 } 612 }
613 613
614 void SelectFileDialogImpl::ListenerDestroyed() { 614 void SelectFileDialogImpl::ListenerDestroyed() {
615 // Our associated listener has gone away, so we shouldn't call back to it if 615 // Our associated listener has gone away, so we shouldn't call back to it if
616 // our worker thread returns after the listener is dead. 616 // our worker thread returns after the listener is dead.
617 listener_ = NULL; 617 listener_ = NULL;
618 } 618 }
619 619
620 void SelectFileDialogImpl::ExecuteSelectFile( 620 void SelectFileDialogImpl::ExecuteSelectFile(
621 const ExecuteSelectParams& params) { 621 const ExecuteSelectParams& params) {
622 string16 filter = GetFilterForFileTypes(params.file_types); 622 base::string16 filter = GetFilterForFileTypes(params.file_types);
623 623
624 base::FilePath path = params.default_path; 624 base::FilePath path = params.default_path;
625 bool success = false; 625 bool success = false;
626 unsigned filter_index = params.file_type_index; 626 unsigned filter_index = params.file_type_index;
627 if (params.type == SELECT_FOLDER) { 627 if (params.type == SELECT_FOLDER) {
628 success = RunSelectFolderDialog(params.title, 628 success = RunSelectFolderDialog(params.title,
629 params.run_state.owner, 629 params.run_state.owner,
630 &path); 630 &path);
631 } else if (params.type == SELECT_SAVEAS_FILE) { 631 } else if (params.type == SELECT_SAVEAS_FILE) {
632 std::wstring path_as_wstring = path.value(); 632 std::wstring path_as_wstring = path.value();
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 std::vector<base::FilePath>::iterator path = files.begin(); 848 std::vector<base::FilePath>::iterator path = files.begin();
849 for (std::vector<base::FilePath>::iterator file = path + 1; 849 for (std::vector<base::FilePath>::iterator file = path + 1;
850 file != files.end(); ++file) { 850 file != files.end(); ++file) {
851 paths->push_back(path->Append(*file)); 851 paths->push_back(path->Append(*file));
852 } 852 }
853 } 853 }
854 } 854 }
855 return success; 855 return success;
856 } 856 }
857 857
858 string16 SelectFileDialogImpl::GetFilterForFileTypes( 858 base::string16 SelectFileDialogImpl::GetFilterForFileTypes(
859 const FileTypeInfo& file_types) { 859 const FileTypeInfo& file_types) {
860 std::vector<string16> exts; 860 std::vector<base::string16> exts;
861 for (size_t i = 0; i < file_types.extensions.size(); ++i) { 861 for (size_t i = 0; i < file_types.extensions.size(); ++i) {
862 const std::vector<string16>& inner_exts = file_types.extensions[i]; 862 const std::vector<base::string16>& inner_exts = file_types.extensions[i];
863 string16 ext_string; 863 base::string16 ext_string;
864 for (size_t j = 0; j < inner_exts.size(); ++j) { 864 for (size_t j = 0; j < inner_exts.size(); ++j) {
865 if (!ext_string.empty()) 865 if (!ext_string.empty())
866 ext_string.push_back(L';'); 866 ext_string.push_back(L';');
867 ext_string.append(L"*."); 867 ext_string.append(L"*.");
868 ext_string.append(inner_exts[j]); 868 ext_string.append(inner_exts[j]);
869 } 869 }
870 exts.push_back(ext_string); 870 exts.push_back(ext_string);
871 } 871 }
872 return FormatFilterForExtensions( 872 return FormatFilterForExtensions(
873 exts, 873 exts,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 return return_value; 920 return return_value;
921 } 921 }
922 922
923 SelectFileDialog* CreateWinSelectFileDialog( 923 SelectFileDialog* CreateWinSelectFileDialog(
924 SelectFileDialog::Listener* listener, 924 SelectFileDialog::Listener* listener,
925 SelectFilePolicy* policy) { 925 SelectFilePolicy* policy) {
926 return new SelectFileDialogImpl(listener, policy); 926 return new SelectFileDialogImpl(listener, policy);
927 } 927 }
928 928
929 } // namespace ui 929 } // namespace ui
OLDNEW
« no previous file with comments | « ui/shell_dialogs/select_file_dialog_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698