| 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 "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "chrome/browser/extensions/extension_file_browser_private_api.h" | 10 #include "chrome/browser/extensions/extension_file_browser_private_api.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 BrowserList::FindBrowserWithWindow(owner_window) : | 192 BrowserList::FindBrowserWithWindow(owner_window) : |
| 193 BrowserList::GetLastActive()); | 193 BrowserList::GetLastActive()); |
| 194 if (!owner_browser) { | 194 if (!owner_browser) { |
| 195 NOTREACHED() << "Can't find owning browser"; | 195 NOTREACHED() << "Can't find owning browser"; |
| 196 return; | 196 return; |
| 197 } | 197 } |
| 198 | 198 |
| 199 FilePath virtual_path; | 199 FilePath virtual_path; |
| 200 if (!FileManagerUtil::ConvertFileToRelativeFileSystemPath( | 200 if (!FileManagerUtil::ConvertFileToRelativeFileSystemPath( |
| 201 owner_browser->profile(), default_path, &virtual_path)) { | 201 owner_browser->profile(), default_path, &virtual_path)) { |
| 202 virtual_path = FilePath(); | 202 virtual_path = default_path.BaseName(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 hasMultipleFileTypeChoices_ = | 205 hasMultipleFileTypeChoices_ = |
| 206 file_types ? file_types->extensions.size() > 1 : true; | 206 file_types ? file_types->extensions.size() > 1 : true; |
| 207 | 207 |
| 208 GURL file_browser_url = FileManagerUtil::GetFileBrowserUrlWithParams( | 208 GURL file_browser_url = FileManagerUtil::GetFileBrowserUrlWithParams( |
| 209 type, title, virtual_path, file_types, file_type_index, | 209 type, title, virtual_path, file_types, file_type_index, |
| 210 default_extension); | 210 default_extension); |
| 211 TabContentsWrapper* tab = owner_browser->GetSelectedTabContentsWrapper(); | 211 TabContentsWrapper* tab = owner_browser->GetSelectedTabContentsWrapper(); |
| 212 ExtensionDialog* dialog = ExtensionDialog::Show(file_browser_url, | 212 ExtensionDialog* dialog = ExtensionDialog::Show(file_browser_url, |
| 213 owner_browser, tab->tab_contents(), | 213 owner_browser, tab->tab_contents(), |
| 214 kFileManagerWidth, kFileManagerHeight, | 214 kFileManagerWidth, kFileManagerHeight, |
| 215 this /* ExtensionDialog::Observer */); | 215 this /* ExtensionDialog::Observer */); |
| 216 if (!dialog) { | 216 if (!dialog) { |
| 217 LOG(ERROR) << "Unable to create extension dialog"; | 217 LOG(ERROR) << "Unable to create extension dialog"; |
| 218 return; | 218 return; |
| 219 } | 219 } |
| 220 | 220 |
| 221 // Connect our listener to FileDialogFunction's per-tab callbacks. | 221 // Connect our listener to FileDialogFunction's per-tab callbacks. |
| 222 int32 tab_id = (tab ? tab->restore_tab_helper()->session_id().id() : 0); | 222 int32 tab_id = (tab ? tab->restore_tab_helper()->session_id().id() : 0); |
| 223 AddPending(tab_id); | 223 AddPending(tab_id); |
| 224 | 224 |
| 225 extension_dialog_ = dialog; | 225 extension_dialog_ = dialog; |
| 226 params_ = params; | 226 params_ = params; |
| 227 tab_id_ = tab_id; | 227 tab_id_ = tab_id; |
| 228 owner_window_ = owner_window; | 228 owner_window_ = owner_window; |
| 229 } | 229 } |
| OLD | NEW |