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

Side by Side Diff: chrome/browser/ui/cocoa/select_file_dialog_mac.mm

Issue 10667026: Start consolidating cross-port file selection code into ui/base/dialogs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos Created 8 years, 5 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
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 "chrome/browser/ui/select_file_dialog.h" 5 #include "chrome/browser/ui/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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 // NSSavePanel delegate method 55 // NSSavePanel delegate method
56 - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename; 56 - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename;
57 57
58 @end 58 @end
59 59
60 // Implementation of SelectFileDialog that shows Cocoa dialogs for choosing a 60 // Implementation of SelectFileDialog that shows Cocoa dialogs for choosing a
61 // file or folder. 61 // file or folder.
62 class SelectFileDialogImpl : public SelectFileDialog { 62 class SelectFileDialogImpl : public SelectFileDialog {
63 public: 63 public:
64 explicit SelectFileDialogImpl(Listener* listener); 64 explicit SelectFileDialogImpl(Listener* listener,
65 ui::SelectFilePolicy* policy);
65 66
66 // BaseShellDialog implementation. 67 // BaseShellDialog implementation.
67 virtual bool IsRunning(gfx::NativeWindow parent_window) const; 68 virtual bool IsRunning(gfx::NativeWindow parent_window) const;
68 virtual void ListenerDestroyed(); 69 virtual void ListenerDestroyed();
69 70
70 // Callback from ObjC bridge. 71 // Callback from ObjC bridge.
71 void FileWasSelected(NSSavePanel* dialog, 72 void FileWasSelected(NSSavePanel* dialog,
72 NSWindow* parent_window, 73 NSWindow* parent_window,
73 bool was_cancelled, 74 bool was_cancelled,
74 bool is_multi, 75 bool is_multi,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 115
115 // A map from file dialogs to their types. 116 // A map from file dialogs to their types.
116 std::map<NSSavePanel*, Type> type_map_; 117 std::map<NSSavePanel*, Type> type_map_;
117 118
118 bool hasMultipleFileTypeChoices_; 119 bool hasMultipleFileTypeChoices_;
119 120
120 DISALLOW_COPY_AND_ASSIGN(SelectFileDialogImpl); 121 DISALLOW_COPY_AND_ASSIGN(SelectFileDialogImpl);
121 }; 122 };
122 123
123 // static 124 // static
124 SelectFileDialog* SelectFileDialog::Create(Listener* listener) { 125 SelectFileDialog* SelectFileDialog::Create(Listener* listener,
125 return new SelectFileDialogImpl(listener); 126 ui::SelectFilePolicy* policy) {
127 return new SelectFileDialogImpl(listener, policy);
126 } 128 }
127 129
128 SelectFileDialogImpl::SelectFileDialogImpl(Listener* listener) 130 SelectFileDialogImpl::SelectFileDialogImpl(Listener* listener,
129 : SelectFileDialog(listener), 131 ui::SelectFilePolicy* policy)
132 : SelectFileDialog(listener, policy),
130 bridge_([[SelectFileDialogBridge alloc] 133 bridge_([[SelectFileDialogBridge alloc]
131 initWithSelectFileDialogImpl:this]) { 134 initWithSelectFileDialogImpl:this]) {
132 } 135 }
133 136
134 bool SelectFileDialogImpl::IsRunning(gfx::NativeWindow parent_window) const { 137 bool SelectFileDialogImpl::IsRunning(gfx::NativeWindow parent_window) const {
135 return parents_.find(parent_window) != parents_.end(); 138 return parents_.find(parent_window) != parents_.end();
136 } 139 }
137 140
138 void SelectFileDialogImpl::ListenerDestroyed() { 141 void SelectFileDialogImpl::ListenerDestroyed() {
139 listener_ = NULL; 142 listener_ = NULL;
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 paths, 429 paths,
427 index); 430 index);
428 [panel release]; 431 [panel release];
429 } 432 }
430 433
431 - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename { 434 - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename {
432 return selectFileDialogImpl_->ShouldEnableFilename(sender, filename); 435 return selectFileDialogImpl_->ShouldEnableFilename(sender, filename);
433 } 436 }
434 437
435 @end 438 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698