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 "chrome/browser/ui/views/select_file_dialog_extension.h" | 5 #include "chrome/browser/ui/views/select_file_dialog_extension.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" | 13 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" |
14 #include "chrome/browser/chromeos/extensions/file_manager_util.h" | 14 #include "chrome/browser/chromeos/extensions/file_manager_util.h" |
15 #include "chrome/browser/extensions/extension_host.h" | 15 #include "chrome/browser/extensions/extension_host.h" |
16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
17 #include "chrome/browser/sessions/restore_tab_helper.h" | 17 #include "chrome/browser/sessions/restore_tab_helper.h" |
18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/browser/ui/browser_finder.h" | 19 #include "chrome/browser/ui/browser_finder.h" |
20 #include "chrome/browser/ui/browser_list.h" | 20 #include "chrome/browser/ui/browser_list.h" |
21 #include "chrome/browser/ui/browser_window.h" | 21 #include "chrome/browser/ui/browser_window.h" |
22 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 22 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
23 #include "chrome/browser/ui/views/extensions/extension_dialog.h" | 23 #include "chrome/browser/ui/views/extensions/extension_dialog.h" |
24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
25 #include "content/public/common/selected_file_info.h" | 25 #include "ui/base/dialogs/selected_file_info.h" |
26 | 26 |
27 using content::BrowserThread; | 27 using content::BrowserThread; |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 const int kFileManagerWidth = 954; // pixels | 31 const int kFileManagerWidth = 954; // pixels |
32 const int kFileManagerHeight = 640; // pixels | 32 const int kFileManagerHeight = 640; // pixels |
33 | 33 |
34 // Holds references to file manager dialogs that have callbacks pending | 34 // Holds references to file manager dialogs that have callbacks pending |
35 // to their listeners. | 35 // to their listeners. |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 base::Unretained(owner_browser_->profile()->GetExtensionService()), | 150 base::Unretained(owner_browser_->profile()->GetExtensionService()), |
151 extension_id)); | 151 extension_id)); |
152 } | 152 } |
153 | 153 |
154 dialog->Close(); | 154 dialog->Close(); |
155 } | 155 } |
156 | 156 |
157 // static | 157 // static |
158 void SelectFileDialogExtension::OnFileSelected( | 158 void SelectFileDialogExtension::OnFileSelected( |
159 int32 tab_id, | 159 int32 tab_id, |
160 const content::SelectedFileInfo& file, | 160 const ui::SelectedFileInfo& file, |
161 int index) { | 161 int index) { |
162 scoped_refptr<SelectFileDialogExtension> dialog = | 162 scoped_refptr<SelectFileDialogExtension> dialog = |
163 PendingDialog::GetInstance()->Find(tab_id); | 163 PendingDialog::GetInstance()->Find(tab_id); |
164 if (!dialog) | 164 if (!dialog) |
165 return; | 165 return; |
166 dialog->selection_type_ = SINGLE_FILE; | 166 dialog->selection_type_ = SINGLE_FILE; |
167 dialog->selection_files_.clear(); | 167 dialog->selection_files_.clear(); |
168 dialog->selection_files_.push_back(file); | 168 dialog->selection_files_.push_back(file); |
169 dialog->selection_index_ = index; | 169 dialog->selection_index_ = index; |
170 } | 170 } |
171 | 171 |
172 // static | 172 // static |
173 void SelectFileDialogExtension::OnMultiFilesSelected( | 173 void SelectFileDialogExtension::OnMultiFilesSelected( |
174 int32 tab_id, | 174 int32 tab_id, |
175 const std::vector<content::SelectedFileInfo>& files) { | 175 const std::vector<ui::SelectedFileInfo>& files) { |
176 scoped_refptr<SelectFileDialogExtension> dialog = | 176 scoped_refptr<SelectFileDialogExtension> dialog = |
177 PendingDialog::GetInstance()->Find(tab_id); | 177 PendingDialog::GetInstance()->Find(tab_id); |
178 if (!dialog) | 178 if (!dialog) |
179 return; | 179 return; |
180 dialog->selection_type_ = MULTIPLE_FILES; | 180 dialog->selection_type_ = MULTIPLE_FILES; |
181 dialog->selection_files_ = files; | 181 dialog->selection_files_ = files; |
182 dialog->selection_index_ = 0; | 182 dialog->selection_index_ = 0; |
183 } | 183 } |
184 | 184 |
185 // static | 185 // static |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 } | 294 } |
295 | 295 |
296 // Connect our listener to FileDialogFunction's per-tab callbacks. | 296 // Connect our listener to FileDialogFunction's per-tab callbacks. |
297 AddPending(tab_id); | 297 AddPending(tab_id); |
298 | 298 |
299 extension_dialog_ = dialog; | 299 extension_dialog_ = dialog; |
300 params_ = params; | 300 params_ = params; |
301 tab_id_ = tab_id; | 301 tab_id_ = tab_id; |
302 owner_window_ = owner_window; | 302 owner_window_ = owner_window; |
303 } | 303 } |
OLD | NEW |