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_mac.h" | 5 #include "ui/shell_dialogs/select_file_dialog_mac.h" |
6 | 6 |
7 #include <CoreServices/CoreServices.h> | 7 #include <CoreServices/CoreServices.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 [popup addItemWithTitle:type_description]; | 304 [popup addItemWithTitle:type_description]; |
305 | 305 |
306 // Populate file_type_lists. | 306 // Populate file_type_lists. |
307 // Set to store different extensions in the current extension group. | 307 // Set to store different extensions in the current extension group. |
308 NSMutableSet* file_type_set = [NSMutableSet set]; | 308 NSMutableSet* file_type_set = [NSMutableSet set]; |
309 for (const base::FilePath::StringType& ext : ext_list) { | 309 for (const base::FilePath::StringType& ext : ext_list) { |
310 if (ext == default_extension) | 310 if (ext == default_extension) |
311 default_extension_index = i; | 311 default_extension_index = i; |
312 | 312 |
313 // Crash reports suggest that CreateUTIFromExtension may return nil. Hence | 313 // Crash reports suggest that CreateUTIFromExtension may return nil. Hence |
314 // we nil check before adding to |file_type_set|. See crbug.com/630101. | 314 // we nil check before adding to |file_type_set|. See crbug.com/630101 and |
| 315 // rdar://27490414. |
315 base::ScopedCFTypeRef<CFStringRef> uti(CreateUTIFromExtension(ext)); | 316 base::ScopedCFTypeRef<CFStringRef> uti(CreateUTIFromExtension(ext)); |
316 if (uti) | 317 if (uti) |
317 [file_type_set addObject:base::mac::CFToNSCast(uti.get())]; | 318 [file_type_set addObject:base::mac::CFToNSCast(uti.get())]; |
318 | 319 |
319 // Always allow the extension itself, in case the UTI doesn't map | 320 // Always allow the extension itself, in case the UTI doesn't map |
320 // back to the original extension correctly. This occurs with dynamic | 321 // back to the original extension correctly. This occurs with dynamic |
321 // UTIs on 10.7 and 10.8. | 322 // UTIs on 10.7 and 10.8. |
322 // See http://crbug.com/148840, http://openradar.me/12316273 | 323 // See http://crbug.com/148840, http://openradar.me/12316273 |
323 base::ScopedCFTypeRef<CFStringRef> ext_cf( | 324 base::ScopedCFTypeRef<CFStringRef> ext_cf( |
324 base::SysUTF8ToCFStringRef(ext)); | 325 base::SysUTF8ToCFStringRef(ext)); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 // For save dialogs, this causes the first item in the allowedFileTypes | 446 // For save dialogs, this causes the first item in the allowedFileTypes |
446 // array to be used as the extension for the save panel. | 447 // array to be used as the extension for the save panel. |
447 [dialog_ setAllowedFileTypes:[fileTypeLists_ objectAtIndex:index]]; | 448 [dialog_ setAllowedFileTypes:[fileTypeLists_ objectAtIndex:index]]; |
448 } else { | 449 } else { |
449 // The user selected "All files" option. | 450 // The user selected "All files" option. |
450 [dialog_ setAllowedFileTypes:nil]; | 451 [dialog_ setAllowedFileTypes:nil]; |
451 } | 452 } |
452 } | 453 } |
453 | 454 |
454 @end | 455 @end |
OLD | NEW |