| 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 "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 Loading... |
| 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); | |
| 66 | 65 |
| 67 // BaseShellDialog implementation. | 66 // BaseShellDialog implementation. |
| 68 virtual bool IsRunning(gfx::NativeWindow parent_window) const; | 67 virtual bool IsRunning(gfx::NativeWindow parent_window) const; |
| 69 virtual void ListenerDestroyed(); | 68 virtual void ListenerDestroyed(); |
| 70 | 69 |
| 71 // Callback from ObjC bridge. | 70 // Callback from ObjC bridge. |
| 72 void FileWasSelected(NSSavePanel* dialog, | 71 void FileWasSelected(NSSavePanel* dialog, |
| 73 NSWindow* parent_window, | 72 NSWindow* parent_window, |
| 74 bool was_cancelled, | 73 bool was_cancelled, |
| 75 bool is_multi, | 74 bool is_multi, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 114 |
| 116 // A map from file dialogs to their types. | 115 // A map from file dialogs to their types. |
| 117 std::map<NSSavePanel*, Type> type_map_; | 116 std::map<NSSavePanel*, Type> type_map_; |
| 118 | 117 |
| 119 bool hasMultipleFileTypeChoices_; | 118 bool hasMultipleFileTypeChoices_; |
| 120 | 119 |
| 121 DISALLOW_COPY_AND_ASSIGN(SelectFileDialogImpl); | 120 DISALLOW_COPY_AND_ASSIGN(SelectFileDialogImpl); |
| 122 }; | 121 }; |
| 123 | 122 |
| 124 // static | 123 // static |
| 125 SelectFileDialog* SelectFileDialog::Create(Listener* listener, | 124 SelectFileDialog* SelectFileDialog::Create(Listener* listener) { |
| 126 ui::SelectFilePolicy* policy) { | 125 return new SelectFileDialogImpl(listener); |
| 127 return new SelectFileDialogImpl(listener, policy); | |
| 128 } | 126 } |
| 129 | 127 |
| 130 SelectFileDialogImpl::SelectFileDialogImpl(Listener* listener, | 128 SelectFileDialogImpl::SelectFileDialogImpl(Listener* listener) |
| 131 ui::SelectFilePolicy* policy) | 129 : SelectFileDialog(listener), |
| 132 : SelectFileDialog(listener, policy), | |
| 133 bridge_([[SelectFileDialogBridge alloc] | 130 bridge_([[SelectFileDialogBridge alloc] |
| 134 initWithSelectFileDialogImpl:this]) { | 131 initWithSelectFileDialogImpl:this]) { |
| 135 } | 132 } |
| 136 | 133 |
| 137 bool SelectFileDialogImpl::IsRunning(gfx::NativeWindow parent_window) const { | 134 bool SelectFileDialogImpl::IsRunning(gfx::NativeWindow parent_window) const { |
| 138 return parents_.find(parent_window) != parents_.end(); | 135 return parents_.find(parent_window) != parents_.end(); |
| 139 } | 136 } |
| 140 | 137 |
| 141 void SelectFileDialogImpl::ListenerDestroyed() { | 138 void SelectFileDialogImpl::ListenerDestroyed() { |
| 142 listener_ = NULL; | 139 listener_ = NULL; |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 paths, | 426 paths, |
| 430 index); | 427 index); |
| 431 [panel release]; | 428 [panel release]; |
| 432 } | 429 } |
| 433 | 430 |
| 434 - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename { | 431 - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename { |
| 435 return selectFileDialogImpl_->ShouldEnableFilename(sender, filename); | 432 return selectFileDialogImpl_->ShouldEnableFilename(sender, filename); |
| 436 } | 433 } |
| 437 | 434 |
| 438 @end | 435 @end |
| OLD | NEW |