| 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.h" | 5 #include "ui/shell_dialogs/select_file_dialog.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 #include <CoreServices/CoreServices.h> | 8 #include <CoreServices/CoreServices.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 @end | 57 @end |
| 58 | 58 |
| 59 // Implementation of SelectFileDialog that shows Cocoa dialogs for choosing a | 59 // Implementation of SelectFileDialog that shows Cocoa dialogs for choosing a |
| 60 // file or folder. | 60 // file or folder. |
| 61 class SelectFileDialogImpl : public ui::SelectFileDialog { | 61 class SelectFileDialogImpl : public ui::SelectFileDialog { |
| 62 public: | 62 public: |
| 63 explicit SelectFileDialogImpl(Listener* listener, | 63 explicit SelectFileDialogImpl(Listener* listener, |
| 64 ui::SelectFilePolicy* policy); | 64 ui::SelectFilePolicy* policy); |
| 65 | 65 |
| 66 // BaseShellDialog implementation. | 66 // BaseShellDialog implementation. |
| 67 virtual bool IsRunning(gfx::NativeWindow parent_window) const override; | 67 bool IsRunning(gfx::NativeWindow parent_window) const override; |
| 68 virtual void ListenerDestroyed() override; | 68 void ListenerDestroyed() override; |
| 69 | 69 |
| 70 // Callback from ObjC bridge. | 70 // Callback from ObjC bridge. |
| 71 void FileWasSelected(NSSavePanel* dialog, | 71 void FileWasSelected(NSSavePanel* dialog, |
| 72 NSWindow* parent_window, | 72 NSWindow* parent_window, |
| 73 bool was_cancelled, | 73 bool was_cancelled, |
| 74 bool is_multi, | 74 bool is_multi, |
| 75 const std::vector<base::FilePath>& files, | 75 const std::vector<base::FilePath>& files, |
| 76 int index); | 76 int index); |
| 77 | 77 |
| 78 protected: | 78 protected: |
| 79 // SelectFileDialog implementation. | 79 // SelectFileDialog implementation. |
| 80 // |params| is user data we pass back via the Listener interface. | 80 // |params| is user data we pass back via the Listener interface. |
| 81 virtual void SelectFileImpl( | 81 void SelectFileImpl(Type type, |
| 82 Type type, | 82 const base::string16& title, |
| 83 const base::string16& title, | 83 const base::FilePath& default_path, |
| 84 const base::FilePath& default_path, | 84 const FileTypeInfo* file_types, |
| 85 const FileTypeInfo* file_types, | 85 int file_type_index, |
| 86 int file_type_index, | 86 const base::FilePath::StringType& default_extension, |
| 87 const base::FilePath::StringType& default_extension, | 87 gfx::NativeWindow owning_window, |
| 88 gfx::NativeWindow owning_window, | 88 void* params) override; |
| 89 void* params) override; | |
| 90 | 89 |
| 91 private: | 90 private: |
| 92 virtual ~SelectFileDialogImpl(); | 91 ~SelectFileDialogImpl() override; |
| 93 | 92 |
| 94 // Gets the accessory view for the save dialog. | 93 // Gets the accessory view for the save dialog. |
| 95 NSView* GetAccessoryView(const FileTypeInfo* file_types, | 94 NSView* GetAccessoryView(const FileTypeInfo* file_types, |
| 96 int file_type_index); | 95 int file_type_index); |
| 97 | 96 |
| 98 virtual bool HasMultipleFileTypeChoicesImpl() override; | 97 bool HasMultipleFileTypeChoicesImpl() override; |
| 99 | 98 |
| 100 // The bridge for results from Cocoa to return to us. | 99 // The bridge for results from Cocoa to return to us. |
| 101 base::scoped_nsobject<SelectFileDialogBridge> bridge_; | 100 base::scoped_nsobject<SelectFileDialogBridge> bridge_; |
| 102 | 101 |
| 103 // A map from file dialogs to the |params| user data associated with them. | 102 // A map from file dialogs to the |params| user data associated with them. |
| 104 std::map<NSSavePanel*, void*> params_map_; | 103 std::map<NSSavePanel*, void*> params_map_; |
| 105 | 104 |
| 106 // The set of all parent windows for which we are currently running dialogs. | 105 // The set of all parent windows for which we are currently running dialogs. |
| 107 std::set<NSWindow*> parents_; | 106 std::set<NSWindow*> parents_; |
| 108 | 107 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 | 421 |
| 423 namespace ui { | 422 namespace ui { |
| 424 | 423 |
| 425 SelectFileDialog* CreateMacSelectFileDialog( | 424 SelectFileDialog* CreateMacSelectFileDialog( |
| 426 SelectFileDialog::Listener* listener, | 425 SelectFileDialog::Listener* listener, |
| 427 SelectFilePolicy* policy) { | 426 SelectFilePolicy* policy) { |
| 428 return new SelectFileDialogImpl(listener, policy); | 427 return new SelectFileDialogImpl(listener, policy); |
| 429 } | 428 } |
| 430 | 429 |
| 431 } // namespace ui | 430 } // namespace ui |
| OLD | NEW |