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> |
11 #include <set> | 11 #include <set> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/mac/bundle_locations.h" | 16 #include "base/mac/bundle_locations.h" |
17 #include "base/mac/foundation_util.h" | 17 #include "base/mac/foundation_util.h" |
18 #include "base/mac/scoped_cftyperef.h" | 18 #include "base/mac/scoped_cftyperef.h" |
19 #import "base/mac/scoped_nsobject.h" | 19 #import "base/mac/scoped_nsobject.h" |
20 #include "base/strings/sys_string_conversions.h" | 20 #include "base/strings/sys_string_conversions.h" |
21 #include "base/threading/thread_restrictions.h" | 21 #include "base/threading/thread_restrictions.h" |
22 #import "ui/base/cocoa/nib_loading.h" | 22 #import "ui/base/cocoa/nib_loading.h" |
23 #include "ui/base/l10n/l10n_util_mac.h" | 23 #include "ui/base/l10n/l10n_util_mac.h" |
24 #include "ui/shell_dialogs/selected_file_info.h" | |
24 #include "ui/strings/grit/ui_strings.h" | 25 #include "ui/strings/grit/ui_strings.h" |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 const int kFileTypePopupTag = 1234; | 29 const int kFileTypePopupTag = 1234; |
29 | 30 |
30 CFStringRef CreateUTIFromExtension(const base::FilePath::StringType& ext) { | 31 CFStringRef CreateUTIFromExtension(const base::FilePath::StringType& ext) { |
31 base::ScopedCFTypeRef<CFStringRef> ext_cf(base::SysUTF8ToCFStringRef(ext)); | 32 base::ScopedCFTypeRef<CFStringRef> ext_cf(base::SysUTF8ToCFStringRef(ext)); |
32 return UTTypeCreatePreferredIdentifierForTag( | 33 return UTTypeCreatePreferredIdentifierForTag( |
33 kUTTagClassFilenameExtension, ext_cf.get(), NULL); | 34 kUTTagClassFilenameExtension, ext_cf.get(), NULL); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 | 144 |
144 if (!listener_) | 145 if (!listener_) |
145 return; | 146 return; |
146 | 147 |
147 if (was_cancelled || files.empty()) { | 148 if (was_cancelled || files.empty()) { |
148 listener_->FileSelectionCanceled(params); | 149 listener_->FileSelectionCanceled(params); |
149 } else { | 150 } else { |
150 if (is_multi) { | 151 if (is_multi) { |
151 listener_->MultiFilesSelected(files, params); | 152 listener_->MultiFilesSelected(files, params); |
152 } else { | 153 } else { |
153 listener_->FileSelected(files[0], index, params); | 154 ui::SelectedFileInfo file(files[0], base::FilePath()); |
155 if ([dialog isExtensionHidden]) { | |
asanka
2015/12/16 02:54:26
Doesn't this mean that the user has chosen to expo
shrike
2015/12/16 19:04:12
The "Hide Extension" checkbox does not hide extens
| |
156 file.SetHideFileExtension(true); | |
157 } | |
158 listener_->FileSelectedWithExtraInfo(file, index, params); | |
154 } | 159 } |
155 } | 160 } |
156 } | 161 } |
157 | 162 |
158 void SelectFileDialogImpl::SelectFileImpl( | 163 void SelectFileDialogImpl::SelectFileImpl( |
159 Type type, | 164 Type type, |
160 const base::string16& title, | 165 const base::string16& title, |
161 const base::FilePath& default_path, | 166 const base::FilePath& default_path, |
162 const FileTypeInfo* file_types, | 167 const FileTypeInfo* file_types, |
163 int file_type_index, | 168 int file_type_index, |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 | 425 |
421 namespace ui { | 426 namespace ui { |
422 | 427 |
423 SelectFileDialog* CreateMacSelectFileDialog( | 428 SelectFileDialog* CreateMacSelectFileDialog( |
424 SelectFileDialog::Listener* listener, | 429 SelectFileDialog::Listener* listener, |
425 SelectFilePolicy* policy) { | 430 SelectFilePolicy* policy) { |
426 return new SelectFileDialogImpl(listener, policy); | 431 return new SelectFileDialogImpl(listener, policy); |
427 } | 432 } |
428 | 433 |
429 } // namespace ui | 434 } // namespace ui |
OLD | NEW |