OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/shell_dialogs.h" | 5 #include "chrome/browser/shell_dialogs.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> |
11 #include <set> | 11 #include <set> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "app/l10n_util_mac.h" | 14 #include "app/l10n_util_mac.h" |
15 #import "base/cocoa_protocols_mac.h" | 15 #import "base/cocoa_protocols_mac.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/mac_util.h" | 17 #include "base/mac_util.h" |
18 #include "base/scoped_cftyperef.h" | 18 #include "base/mac/scoped_cftyperef.h" |
19 #import "base/scoped_nsobject.h" | 19 #import "base/scoped_nsobject.h" |
20 #include "base/sys_string_conversions.h" | 20 #include "base/sys_string_conversions.h" |
21 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
22 | 22 |
23 static const int kFileTypePopupTag = 1234; | 23 static const int kFileTypePopupTag = 1234; |
24 | 24 |
25 class SelectFileDialogImpl; | 25 class SelectFileDialogImpl; |
26 | 26 |
27 // A bridge class to act as the modal delegate to the save/open sheet and send | 27 // A bridge class to act as the modal delegate to the save/open sheet and send |
28 // the results to the C++ class. | 28 // the results to the C++ class. |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 for (size_t type = 0; type<type_count; ++type) { | 301 for (size_t type = 0; type<type_count; ++type) { |
302 NSString* type_description; | 302 NSString* type_description; |
303 if (type < file_types->extension_description_overrides.size()) { | 303 if (type < file_types->extension_description_overrides.size()) { |
304 type_description = base::SysUTF16ToNSString( | 304 type_description = base::SysUTF16ToNSString( |
305 file_types->extension_description_overrides[type]); | 305 file_types->extension_description_overrides[type]); |
306 } else { | 306 } else { |
307 const std::vector<FilePath::StringType>& ext_list = | 307 const std::vector<FilePath::StringType>& ext_list = |
308 file_types->extensions[type]; | 308 file_types->extensions[type]; |
309 DCHECK(!ext_list.empty()); | 309 DCHECK(!ext_list.empty()); |
310 NSString* type_extension = base::SysUTF8ToNSString(ext_list[0]); | 310 NSString* type_extension = base::SysUTF8ToNSString(ext_list[0]); |
311 scoped_cftyperef<CFStringRef> uti( | 311 base::mac::ScopedCFTypeRef<CFStringRef> uti( |
312 UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, | 312 UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, |
313 (CFStringRef)type_extension, | 313 (CFStringRef)type_extension, |
314 NULL)); | 314 NULL)); |
315 scoped_cftyperef<CFStringRef> description( | 315 base::mac::ScopedCFTypeRef<CFStringRef> description( |
316 UTTypeCopyDescription(uti.get())); | 316 UTTypeCopyDescription(uti.get())); |
317 | 317 |
318 type_description = | 318 type_description = |
319 [NSString stringWithString:(NSString*)description.get()]; | 319 [NSString stringWithString:(NSString*)description.get()]; |
320 } | 320 } |
321 [popup addItemWithTitle:type_description]; | 321 [popup addItemWithTitle:type_description]; |
322 } | 322 } |
323 | 323 |
324 [popup selectItemAtIndex:file_type_index-1]; // 1-based | 324 [popup selectItemAtIndex:file_type_index-1]; // 1-based |
325 return accessory_view; | 325 return accessory_view; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 paths, | 388 paths, |
389 index); | 389 index); |
390 [panel release]; | 390 [panel release]; |
391 } | 391 } |
392 | 392 |
393 - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename { | 393 - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename { |
394 return selectFileDialogImpl_->ShouldEnableFilename(sender, filename); | 394 return selectFileDialogImpl_->ShouldEnableFilename(sender, filename); |
395 } | 395 } |
396 | 396 |
397 @end | 397 @end |
OLD | NEW |