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 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "build/build_config.h" |
10 #include "ui/base/dialogs/selected_file_info.h" | 11 #include "ui/base/dialogs/selected_file_info.h" |
11 #include "ui/base/dialogs/select_file_dialog_factory.h" | 12 #include "ui/base/dialogs/select_file_dialog_factory.h" |
12 #include "ui/base/dialogs/select_file_policy.h" | 13 #include "ui/base/dialogs/select_file_policy.h" |
13 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
14 | 15 |
15 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
16 #include "ui/base/dialogs/select_file_dialog_win.h" | 17 #include "ui/base/dialogs/select_file_dialog_win.h" |
17 #elif defined(OS_MACOSX) | 18 #elif defined(OS_MACOSX) |
18 #include "ui/base/dialogs/select_file_dialog_mac.h" | 19 #include "ui/base/dialogs/select_file_dialog_mac.h" |
| 20 #elif defined(TOOLKIT_GTK) |
| 21 #include "ui/base/dialogs/gtk/select_file_dialog_impl.h" |
19 #endif | 22 #endif |
20 | 23 |
21 namespace { | 24 namespace { |
22 | 25 |
23 // Optional dialog factory. Leaked. | 26 // Optional dialog factory. Leaked. |
24 ui::SelectFileDialogFactory* dialog_factory_ = NULL; | 27 ui::SelectFileDialogFactory* dialog_factory_ = NULL; |
25 | 28 |
26 } // namespace | 29 } // namespace |
27 | 30 |
28 namespace ui { | 31 namespace ui { |
(...skipping 18 matching lines...) Expand all Loading... |
47 | 50 |
48 MultiFilesSelected(file_paths, params); | 51 MultiFilesSelected(file_paths, params); |
49 } | 52 } |
50 | 53 |
51 // static | 54 // static |
52 void SelectFileDialog::SetFactory(ui::SelectFileDialogFactory* factory) { | 55 void SelectFileDialog::SetFactory(ui::SelectFileDialogFactory* factory) { |
53 delete dialog_factory_; | 56 delete dialog_factory_; |
54 dialog_factory_ = factory; | 57 dialog_factory_ = factory; |
55 } | 58 } |
56 | 59 |
57 #if !defined(TOOLKIT_GTK) | |
58 // static | 60 // static |
59 SelectFileDialog* SelectFileDialog::Create(Listener* listener, | 61 SelectFileDialog* SelectFileDialog::Create(Listener* listener, |
60 ui::SelectFilePolicy* policy) { | 62 ui::SelectFilePolicy* policy) { |
61 if (dialog_factory_) { | 63 if (dialog_factory_) { |
62 SelectFileDialog* dialog = dialog_factory_->Create(listener, policy); | 64 SelectFileDialog* dialog = dialog_factory_->Create(listener, policy); |
63 if (dialog) | 65 if (dialog) |
64 return dialog; | 66 return dialog; |
65 } | 67 } |
66 | 68 |
67 // TODO(erg): Proxy to LinuxUI here. | 69 // TODO(erg): Proxy to LinuxUI here. |
68 | 70 |
69 // TODO(erg): Add other OSs one by one here. | 71 // TODO(erg): Add other OSs one by one here. |
70 | |
71 #if defined(OS_WIN) && !defined(USE_AURA) | 72 #if defined(OS_WIN) && !defined(USE_AURA) |
72 // TODO(port): The windows people need this to work in aura, too. | 73 // TODO(port): The windows people need this to work in aura, too. |
73 return CreateWinSelectFileDialog(listener, policy); | 74 return CreateWinSelectFileDialog(listener, policy); |
74 #elif defined(OS_MACOSX) && !defined(USE_AURA) | 75 #elif defined(OS_MACOSX) && !defined(USE_AURA) |
75 return CreateMacSelectFileDialog(listener, policy); | 76 return CreateMacSelectFileDialog(listener, policy); |
| 77 #elif defined(TOOLKIT_GTK) |
| 78 return CreateLinuxSelectFileDialog(listener, policy); |
76 #elif defined(OS_ANDROID) | 79 #elif defined(OS_ANDROID) |
77 // see crbug.com/116131 to track implemenation of SelectFileDialog | 80 // see crbug.com/116131 to track implemenation of SelectFileDialog |
78 NOTIMPLEMENTED(); | 81 NOTIMPLEMENTED(); |
79 #endif | 82 #endif |
80 | 83 |
81 return NULL; | 84 return NULL; |
82 } | 85 } |
83 #endif | |
84 | 86 |
85 void SelectFileDialog::SelectFile(Type type, | 87 void SelectFileDialog::SelectFile(Type type, |
86 const string16& title, | 88 const string16& title, |
87 const FilePath& default_path, | 89 const FilePath& default_path, |
88 const FileTypeInfo* file_types, | 90 const FileTypeInfo* file_types, |
89 int file_type_index, | 91 int file_type_index, |
90 const FilePath::StringType& default_extension, | 92 const FilePath::StringType& default_extension, |
91 gfx::NativeWindow owning_window, | 93 gfx::NativeWindow owning_window, |
92 void* params) { | 94 void* params) { |
93 DCHECK(listener_); | 95 DCHECK(listener_); |
(...skipping 28 matching lines...) Expand all Loading... |
122 } | 124 } |
123 | 125 |
124 SelectFileDialog::~SelectFileDialog() {} | 126 SelectFileDialog::~SelectFileDialog() {} |
125 | 127 |
126 void SelectFileDialog::CancelFileSelection(void* params) { | 128 void SelectFileDialog::CancelFileSelection(void* params) { |
127 if (listener_) | 129 if (listener_) |
128 listener_->FileSelectionCanceled(params); | 130 listener_->FileSelectionCanceled(params); |
129 } | 131 } |
130 | 132 |
131 } // namespace ui | 133 } // namespace ui |
OLD | NEW |