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 virtual bool IsRunning(gfx::NativeWindow parent_window) const override; |
68 virtual void ListenerDestroyed() OVERRIDE; | 68 virtual 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 bool ShouldEnableFilename(NSSavePanel* dialog, NSString* filename); | 78 bool ShouldEnableFilename(NSSavePanel* dialog, NSString* filename); |
79 | 79 |
80 protected: | 80 protected: |
81 // SelectFileDialog implementation. | 81 // SelectFileDialog implementation. |
82 // |params| is user data we pass back via the Listener interface. | 82 // |params| is user data we pass back via the Listener interface. |
83 virtual void SelectFileImpl( | 83 virtual void SelectFileImpl( |
84 Type type, | 84 Type type, |
85 const base::string16& title, | 85 const base::string16& title, |
86 const base::FilePath& default_path, | 86 const base::FilePath& default_path, |
87 const FileTypeInfo* file_types, | 87 const FileTypeInfo* file_types, |
88 int file_type_index, | 88 int file_type_index, |
89 const base::FilePath::StringType& default_extension, | 89 const base::FilePath::StringType& default_extension, |
90 gfx::NativeWindow owning_window, | 90 gfx::NativeWindow owning_window, |
91 void* params) OVERRIDE; | 91 void* params) override; |
92 | 92 |
93 private: | 93 private: |
94 virtual ~SelectFileDialogImpl(); | 94 virtual ~SelectFileDialogImpl(); |
95 | 95 |
96 // Gets the accessory view for the save dialog. | 96 // Gets the accessory view for the save dialog. |
97 NSView* GetAccessoryView(const FileTypeInfo* file_types, | 97 NSView* GetAccessoryView(const FileTypeInfo* file_types, |
98 int file_type_index); | 98 int file_type_index); |
99 | 99 |
100 virtual bool HasMultipleFileTypeChoicesImpl() OVERRIDE; | 100 virtual bool HasMultipleFileTypeChoicesImpl() override; |
101 | 101 |
102 // The bridge for results from Cocoa to return to us. | 102 // The bridge for results from Cocoa to return to us. |
103 base::scoped_nsobject<SelectFileDialogBridge> bridge_; | 103 base::scoped_nsobject<SelectFileDialogBridge> bridge_; |
104 | 104 |
105 // A map from file dialogs to the |params| user data associated with them. | 105 // A map from file dialogs to the |params| user data associated with them. |
106 std::map<NSSavePanel*, void*> params_map_; | 106 std::map<NSSavePanel*, void*> params_map_; |
107 | 107 |
108 // The set of all parent windows for which we are currently running dialogs. | 108 // The set of all parent windows for which we are currently running dialogs. |
109 std::set<NSWindow*> parents_; | 109 std::set<NSWindow*> parents_; |
110 | 110 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 | 436 |
437 namespace ui { | 437 namespace ui { |
438 | 438 |
439 SelectFileDialog* CreateMacSelectFileDialog( | 439 SelectFileDialog* CreateMacSelectFileDialog( |
440 SelectFileDialog::Listener* listener, | 440 SelectFileDialog::Listener* listener, |
441 SelectFilePolicy* policy) { | 441 SelectFilePolicy* policy) { |
442 return new SelectFileDialogImpl(listener, policy); | 442 return new SelectFileDialogImpl(listener, policy); |
443 } | 443 } |
444 | 444 |
445 } // namespace ui | 445 } // namespace ui |
OLD | NEW |