| 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 void SelectFileDialogImpl::SelectFileImpl( | 171 void SelectFileDialogImpl::SelectFileImpl( |
| 172 Type type, | 172 Type type, |
| 173 const base::string16& title, | 173 const base::string16& title, |
| 174 const base::FilePath& default_path, | 174 const base::FilePath& default_path, |
| 175 const FileTypeInfo* file_types, | 175 const FileTypeInfo* file_types, |
| 176 int file_type_index, | 176 int file_type_index, |
| 177 const base::FilePath::StringType& default_extension, | 177 const base::FilePath::StringType& default_extension, |
| 178 gfx::NativeWindow owning_window, | 178 gfx::NativeWindow owning_window, |
| 179 void* params) { | 179 void* params) { |
| 180 DCHECK(type == SELECT_FOLDER || | 180 DCHECK(type == SELECT_FOLDER || |
| 181 type == SELECT_UPLOAD_FOLDER || |
| 181 type == SELECT_OPEN_FILE || | 182 type == SELECT_OPEN_FILE || |
| 182 type == SELECT_OPEN_MULTI_FILE || | 183 type == SELECT_OPEN_MULTI_FILE || |
| 183 type == SELECT_SAVEAS_FILE); | 184 type == SELECT_SAVEAS_FILE); |
| 184 parents_.insert(owning_window); | 185 parents_.insert(owning_window); |
| 185 | 186 |
| 186 // Note: we need to retain the dialog as owning_window can be null. | 187 // Note: we need to retain the dialog as owning_window can be null. |
| 187 // (See http://crbug.com/29213 .) | 188 // (See http://crbug.com/29213 .) |
| 188 NSSavePanel* dialog; | 189 NSSavePanel* dialog; |
| 189 if (type == SELECT_SAVEAS_FILE) | 190 if (type == SELECT_SAVEAS_FILE) |
| 190 dialog = [[NSSavePanel savePanel] retain]; | 191 dialog = [[NSSavePanel savePanel] retain]; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 if (type == SELECT_SAVEAS_FILE) { | 268 if (type == SELECT_SAVEAS_FILE) { |
| 268 [dialog setCanSelectHiddenExtension:YES]; | 269 [dialog setCanSelectHiddenExtension:YES]; |
| 269 } else { | 270 } else { |
| 270 NSOpenPanel* open_dialog = (NSOpenPanel*)dialog; | 271 NSOpenPanel* open_dialog = (NSOpenPanel*)dialog; |
| 271 | 272 |
| 272 if (type == SELECT_OPEN_MULTI_FILE) | 273 if (type == SELECT_OPEN_MULTI_FILE) |
| 273 [open_dialog setAllowsMultipleSelection:YES]; | 274 [open_dialog setAllowsMultipleSelection:YES]; |
| 274 else | 275 else |
| 275 [open_dialog setAllowsMultipleSelection:NO]; | 276 [open_dialog setAllowsMultipleSelection:NO]; |
| 276 | 277 |
| 277 if (type == SELECT_FOLDER) { | 278 if (type == SELECT_FOLDER || type == SELECT_UPLOAD_FOLDER) { |
| 278 [open_dialog setCanChooseFiles:NO]; | 279 [open_dialog setCanChooseFiles:NO]; |
| 279 [open_dialog setCanChooseDirectories:YES]; | 280 [open_dialog setCanChooseDirectories:YES]; |
| 280 [open_dialog setCanCreateDirectories:YES]; | 281 [open_dialog setCanCreateDirectories:YES]; |
| 281 NSString *prompt = l10n_util::GetNSString(IDS_SELECT_FOLDER_BUTTON_TITLE); | 282 NSString *prompt = (type == SELECT_UPLOAD_FOLDER) |
| 283 ? l10n_util::GetNSString(IDS_SELECT_UPLOAD_FOLDER_BUTTON_TITLE) |
| 284 : l10n_util::GetNSString(IDS_SELECT_FOLDER_BUTTON_TITLE); |
| 282 [open_dialog setPrompt:prompt]; | 285 [open_dialog setPrompt:prompt]; |
| 283 } else { | 286 } else { |
| 284 [open_dialog setCanChooseFiles:YES]; | 287 [open_dialog setCanChooseFiles:YES]; |
| 285 [open_dialog setCanChooseDirectories:NO]; | 288 [open_dialog setCanChooseDirectories:NO]; |
| 286 } | 289 } |
| 287 | 290 |
| 288 [open_dialog setDelegate:bridge_.get()]; | 291 [open_dialog setDelegate:bridge_.get()]; |
| 289 [open_dialog setAllowedFileTypes:allowed_file_types]; | 292 [open_dialog setAllowedFileTypes:allowed_file_types]; |
| 290 } | 293 } |
| 291 if (default_dir) | 294 if (default_dir) |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 | 420 |
| 418 namespace ui { | 421 namespace ui { |
| 419 | 422 |
| 420 SelectFileDialog* CreateMacSelectFileDialog( | 423 SelectFileDialog* CreateMacSelectFileDialog( |
| 421 SelectFileDialog::Listener* listener, | 424 SelectFileDialog::Listener* listener, |
| 422 SelectFilePolicy* policy) { | 425 SelectFilePolicy* policy) { |
| 423 return new SelectFileDialogImpl(listener, policy); | 426 return new SelectFileDialogImpl(listener, policy); |
| 424 } | 427 } |
| 425 | 428 |
| 426 } // namespace ui | 429 } // namespace ui |
| OLD | NEW |