Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(463)

Side by Side Diff: ui/base/dialogs/select_file_dialog.cc

Issue 10698168: Part 3 of Move SelectFileDialog implementation to ui/base/dialogs/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More namespace to force rebuild. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/dialogs/select_file_dialog.h ('k') | ui/base/dialogs/select_file_dialog_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/ui/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 "chrome/browser/browser_process.h"
11 #include "chrome/browser/infobars/infobar_tab_helper.h"
12 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h"
14 #include "chrome/browser/ui/tab_contents/tab_contents.h"
15 #include "chrome/common/pref_names.h"
16 #include "grit/generated_resources.h"
17 #include "ui/base/dialogs/selected_file_info.h" 10 #include "ui/base/dialogs/selected_file_info.h"
11 #include "ui/base/dialogs/select_file_dialog_factory.h"
18 #include "ui/base/dialogs/select_file_policy.h" 12 #include "ui/base/dialogs/select_file_policy.h"
19 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
20 14
21 using content::WebContents; 15 #if defined(OS_WIN)
16 #include "ui/base/dialogs/select_file_dialog_win.h"
17 #endif
18
19 namespace {
20
21 // Optional dialog factory. Leaked.
22 ui::SelectFileDialogFactory* dialog_factory_ = NULL;
23
24 } // namespace
25
26 namespace ui {
22 27
23 SelectFileDialog::FileTypeInfo::FileTypeInfo() : include_all_files(false) {} 28 SelectFileDialog::FileTypeInfo::FileTypeInfo() : include_all_files(false) {}
24 29
25 SelectFileDialog::FileTypeInfo::~FileTypeInfo() {} 30 SelectFileDialog::FileTypeInfo::~FileTypeInfo() {}
26 31
27 void SelectFileDialog::Listener::FileSelectedWithExtraInfo( 32 void SelectFileDialog::Listener::FileSelectedWithExtraInfo(
28 const ui::SelectedFileInfo& file, 33 const ui::SelectedFileInfo& file,
29 int index, 34 int index,
30 void* params) { 35 void* params) {
31 FileSelected(file.path, index, params); 36 FileSelected(file.path, index, params);
32 } 37 }
33 38
34 void SelectFileDialog::Listener::MultiFilesSelectedWithExtraInfo( 39 void SelectFileDialog::Listener::MultiFilesSelectedWithExtraInfo(
35 const std::vector<ui::SelectedFileInfo>& files, 40 const std::vector<ui::SelectedFileInfo>& files,
36 void* params) { 41 void* params) {
37 std::vector<FilePath> file_paths; 42 std::vector<FilePath> file_paths;
38 for (size_t i = 0; i < files.size(); ++i) 43 for (size_t i = 0; i < files.size(); ++i)
39 file_paths.push_back(files[i].path); 44 file_paths.push_back(files[i].path);
40 45
41 MultiFilesSelected(file_paths, params); 46 MultiFilesSelected(file_paths, params);
42 } 47 }
43 48
44 SelectFileDialog::SelectFileDialog(Listener* listener, 49 // static
45 ui::SelectFilePolicy* policy) 50 void SelectFileDialog::SetFactory(ui::SelectFileDialogFactory* factory) {
46 : listener_(listener), 51 delete dialog_factory_;
47 select_file_policy_(policy) { 52 dialog_factory_ = factory;
48 DCHECK(listener_);
49 } 53 }
50 54
51 SelectFileDialog::~SelectFileDialog() {} 55 // TODO(erg): As each implementation moves into ui/base/dialogs, consolidate
56 // the Create() methods into the following single method, which has to check
57 // all options.
58 #if defined(USE_AURA) || defined(OS_WIN)
59 // static
60 SelectFileDialog* SelectFileDialog::Create(Listener* listener,
61 ui::SelectFilePolicy* policy) {
62 if (dialog_factory_) {
63 SelectFileDialog* dialog = dialog_factory_->Create(listener, policy);
64 if (dialog)
65 return dialog;
66 }
67
68 // TODO(erg): Proxy to LinuxUI here.
69
70 // TODO(erg): Add other OSs one by one here.
71
72 #if defined(OS_WIN) && !defined(USE_AURA)
73 return CreateWinSelectFileDialog(listener, policy);
74 #endif
75
76 return NULL;
77 }
78 #endif
52 79
53 void SelectFileDialog::SelectFile(Type type, 80 void SelectFileDialog::SelectFile(Type type,
54 const string16& title, 81 const string16& title,
55 const FilePath& default_path, 82 const FilePath& default_path,
56 const FileTypeInfo* file_types, 83 const FileTypeInfo* file_types,
57 int file_type_index, 84 int file_type_index,
58 const FilePath::StringType& default_extension, 85 const FilePath::StringType& default_extension,
59 gfx::NativeWindow owning_window, 86 gfx::NativeWindow owning_window,
60 void* params) { 87 void* params) {
61 DCHECK(listener_); 88 DCHECK(listener_);
(...skipping 13 matching lines...) Expand all
75 102
76 // Call the platform specific implementation of the file selection dialog. 103 // Call the platform specific implementation of the file selection dialog.
77 SelectFileImpl(type, title, default_path, file_types, file_type_index, 104 SelectFileImpl(type, title, default_path, file_types, file_type_index,
78 default_extension, owning_window, params); 105 default_extension, owning_window, params);
79 } 106 }
80 107
81 bool SelectFileDialog::HasMultipleFileTypeChoices() { 108 bool SelectFileDialog::HasMultipleFileTypeChoices() {
82 return HasMultipleFileTypeChoicesImpl(); 109 return HasMultipleFileTypeChoicesImpl();
83 } 110 }
84 111
112 SelectFileDialog::SelectFileDialog(Listener* listener,
113 ui::SelectFilePolicy* policy)
114 : listener_(listener),
115 select_file_policy_(policy) {
116 DCHECK(listener_);
117 }
118
119 SelectFileDialog::~SelectFileDialog() {}
120
85 void SelectFileDialog::CancelFileSelection(void* params) { 121 void SelectFileDialog::CancelFileSelection(void* params) {
86 if (listener_) 122 if (listener_)
87 listener_->FileSelectionCanceled(params); 123 listener_->FileSelectionCanceled(params);
88 } 124 }
125
126 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/dialogs/select_file_dialog.h ('k') | ui/base/dialogs/select_file_dialog_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698