| 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/base/dialogs/select_file_dialog.h" | 5 #include "ui/base/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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 // will be part of one list. To be safe, allow the types of all the | 220 // will be part of one list. To be safe, allow the types of all the |
| 221 // specified extensions. | 221 // specified extensions. |
| 222 NSMutableSet* file_type_set = [NSMutableSet set]; | 222 NSMutableSet* file_type_set = [NSMutableSet set]; |
| 223 for (size_t i = 0; i < file_types->extensions.size(); ++i) { | 223 for (size_t i = 0; i < file_types->extensions.size(); ++i) { |
| 224 const std::vector<FilePath::StringType>& ext_list = | 224 const std::vector<FilePath::StringType>& ext_list = |
| 225 file_types->extensions[i]; | 225 file_types->extensions[i]; |
| 226 for (size_t j = 0; j < ext_list.size(); ++j) { | 226 for (size_t j = 0; j < ext_list.size(); ++j) { |
| 227 base::mac::ScopedCFTypeRef<CFStringRef> uti( | 227 base::mac::ScopedCFTypeRef<CFStringRef> uti( |
| 228 CreateUTIFromExtension(ext_list[j])); | 228 CreateUTIFromExtension(ext_list[j])); |
| 229 [file_type_set addObject:base::mac::CFToNSCast(uti.get())]; | 229 [file_type_set addObject:base::mac::CFToNSCast(uti.get())]; |
| 230 |
| 231 // Always allow the extension itself, in case the UTI doesn't map |
| 232 // back to the original extension correctly. This occurs with dynamic |
| 233 // UTIs on 10.7 and 10.8. |
| 234 // See http://crbug.com/148840, http://openradar.me/12316273 |
| 235 base::mac::ScopedCFTypeRef<CFStringRef> ext_cf( |
| 236 base::SysUTF8ToCFStringRef(ext_list[j])); |
| 237 [file_type_set addObject:base::mac::CFToNSCast(ext_cf.get())]; |
| 230 } | 238 } |
| 231 } | 239 } |
| 232 allowed_file_types = [file_type_set allObjects]; | 240 allowed_file_types = [file_type_set allObjects]; |
| 233 } | 241 } |
| 234 if (type == SELECT_SAVEAS_FILE) | 242 if (type == SELECT_SAVEAS_FILE) |
| 235 [dialog setAllowedFileTypes:allowed_file_types]; | 243 [dialog setAllowedFileTypes:allowed_file_types]; |
| 236 // else we'll pass it in when we run the open panel | 244 // else we'll pass it in when we run the open panel |
| 237 | 245 |
| 238 if (file_types->include_all_files || file_types->extensions.empty()) | 246 if (file_types->include_all_files || file_types->extensions.empty()) |
| 239 [dialog setAllowsOtherFileTypes:YES]; | 247 [dialog setAllowsOtherFileTypes:YES]; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 | 415 |
| 408 namespace ui { | 416 namespace ui { |
| 409 | 417 |
| 410 SelectFileDialog* CreateMacSelectFileDialog( | 418 SelectFileDialog* CreateMacSelectFileDialog( |
| 411 SelectFileDialog::Listener* listener, | 419 SelectFileDialog::Listener* listener, |
| 412 SelectFilePolicy* policy) { | 420 SelectFilePolicy* policy) { |
| 413 return new SelectFileDialogImpl(listener, policy); | 421 return new SelectFileDialogImpl(listener, policy); |
| 414 } | 422 } |
| 415 | 423 |
| 416 } // namespace ui | 424 } // namespace ui |
| OLD | NEW |