OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_manager_dialog.h" | 5 #include "chrome/browser/ui/views/file_manager_dialog.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "chrome/browser/extensions/extension_file_browser_private_api.h" | 9 #include "chrome/browser/extensions/extension_file_browser_private_api.h" |
10 #include "chrome/browser/extensions/extension_host.h" | 10 #include "chrome/browser/extensions/extension_host.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 LOG(WARNING) << "Pending dialog not found " << tab_id; | 66 LOG(WARNING) << "Pending dialog not found " << tab_id; |
67 return NULL; | 67 return NULL; |
68 } | 68 } |
69 return it->second.dialog_.get(); | 69 return it->second.dialog_.get(); |
70 } | 70 } |
71 | 71 |
72 } // namespace | 72 } // namespace |
73 | 73 |
74 // Linking this implementation of SelectFileDialog::Create into the target | 74 // Linking this implementation of SelectFileDialog::Create into the target |
75 // selects FileManagerDialog as the dialog of choice. | 75 // selects FileManagerDialog as the dialog of choice. |
76 // TODO(jamescook): Move this into a new file shell_dialogs_chromeos.cc | |
77 // static | 76 // static |
78 SelectFileDialog* SelectFileDialog::Create(Listener* listener) { | 77 SelectFileDialog* SelectFileDialog::Create(Listener* listener) { |
79 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 78 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
80 return new FileManagerDialog(listener); | 79 return new FileManagerDialog(listener); |
81 } | 80 } |
82 | 81 |
83 ///////////////////////////////////////////////////////////////////////////// | 82 ///////////////////////////////////////////////////////////////////////////// |
84 | 83 |
85 FileManagerDialog::FileManagerDialog(Listener* listener) | 84 FileManagerDialog::FileManagerDialog(Listener* listener) |
86 : SelectFileDialog(listener), | 85 : SelectFileDialog(listener), |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 NOTREACHED() << "Can't find owning browser"; | 175 NOTREACHED() << "Can't find owning browser"; |
177 return; | 176 return; |
178 } | 177 } |
179 | 178 |
180 FilePath virtual_path; | 179 FilePath virtual_path; |
181 if (!FileManagerUtil::ConvertFileToRelativeFileSystemPath( | 180 if (!FileManagerUtil::ConvertFileToRelativeFileSystemPath( |
182 owner_browser->profile(), default_path, &virtual_path)) { | 181 owner_browser->profile(), default_path, &virtual_path)) { |
183 virtual_path = FilePath(); | 182 virtual_path = FilePath(); |
184 } | 183 } |
185 | 184 |
| 185 // Connect our listener to FileDialogFunction's per-tab callbacks. |
| 186 TabContentsWrapper* tab = owner_browser->GetSelectedTabContentsWrapper(); |
| 187 int32 tab_id = (tab ? tab->restore_tab_helper()->session_id().id() : 0); |
| 188 PendingDialog::Add(tab_id, this); |
| 189 |
186 GURL file_browser_url = FileManagerUtil::GetFileBrowserUrlWithParams( | 190 GURL file_browser_url = FileManagerUtil::GetFileBrowserUrlWithParams( |
187 type, title, virtual_path, file_types, file_type_index, | 191 type, title, virtual_path, file_types, file_type_index, |
188 default_extension); | 192 default_extension); |
189 TabContentsWrapper* tab = owner_browser->GetSelectedTabContentsWrapper(); | 193 extension_dialog_ = ExtensionDialog::Show(file_browser_url, |
190 ExtensionDialog* dialog = ExtensionDialog::Show(file_browser_url, | |
191 owner_browser, tab->tab_contents(), | 194 owner_browser, tab->tab_contents(), |
192 kFileManagerWidth, kFileManagerHeight, | 195 kFileManagerWidth, kFileManagerHeight, |
193 this /* ExtensionDialog::Observer */); | 196 this /* ExtensionDialog::Observer */); |
194 if (!dialog) { | |
195 LOG(ERROR) << "Unable to create extension dialog"; | |
196 return; | |
197 } | |
198 | 197 |
199 // Connect our listener to FileDialogFunction's per-tab callbacks. | |
200 int32 tab_id = (tab ? tab->restore_tab_helper()->session_id().id() : 0); | |
201 PendingDialog::Add(tab_id, this); | |
202 | |
203 extension_dialog_ = dialog; | |
204 params_ = params; | 198 params_ = params; |
205 tab_id_ = tab_id; | 199 tab_id_ = tab_id; |
206 owner_window_ = owner_window; | 200 owner_window_ = owner_window; |
207 } | 201 } |
OLD | NEW |