Chromium Code Reviews| 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 does not exist. | |
| 232 base::mac::ScopedCFTypeRef<CFStringRef> ext_cf( | |
| 233 base::SysUTF8ToCFStringRef(ext_list[j])); | |
| 234 [file_type_set addObject:base::mac::CFToNSCast(ext_cf.get())]; | |
|
Avi (use Gerrit)
2012/09/13 05:52:39
UTIs always exist. Dynamic UTIs exist to round-tri
thorogood
2012/09/16 23:50:49
Done, I've attached it to the bug (which I've CC'e
Avi (use Gerrit)
2012/09/17 02:41:45
What The F. Can you link the bug in the comment?
thorogood
2012/09/17 03:19:06
Done, linked to the issue 148840.
| |
| 230 } | 235 } |
| 231 } | 236 } |
| 232 allowed_file_types = [file_type_set allObjects]; | 237 allowed_file_types = [file_type_set allObjects]; |
| 233 } | 238 } |
| 234 if (type == SELECT_SAVEAS_FILE) | 239 if (type == SELECT_SAVEAS_FILE) |
| 235 [dialog setAllowedFileTypes:allowed_file_types]; | 240 [dialog setAllowedFileTypes:allowed_file_types]; |
| 236 // else we'll pass it in when we run the open panel | 241 // else we'll pass it in when we run the open panel |
| 237 | 242 |
| 238 if (file_types->include_all_files) | 243 if (file_types->include_all_files) |
| 239 [dialog setAllowsOtherFileTypes:YES]; | 244 [dialog setAllowsOtherFileTypes:YES]; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 | 412 |
| 408 namespace ui { | 413 namespace ui { |
| 409 | 414 |
| 410 SelectFileDialog* CreateMacSelectFileDialog( | 415 SelectFileDialog* CreateMacSelectFileDialog( |
| 411 SelectFileDialog::Listener* listener, | 416 SelectFileDialog::Listener* listener, |
| 412 SelectFilePolicy* policy) { | 417 SelectFilePolicy* policy) { |
| 413 return new SelectFileDialogImpl(listener, policy); | 418 return new SelectFileDialogImpl(listener, policy); |
| 414 } | 419 } |
| 415 | 420 |
| 416 } // namespace ui | 421 } // namespace ui |
| OLD | NEW |