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" |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 const PrefService* pref_service = profile_->GetPrefs(); | 314 const PrefService* pref_service = profile_->GetPrefs(); |
315 | 315 |
316 if (default_path.empty() && pref_service) { | 316 if (default_path.empty() && pref_service) { |
317 default_dialog_path = | 317 default_dialog_path = |
318 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory); | 318 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory); |
319 } else { | 319 } else { |
320 default_dialog_path = default_path; | 320 default_dialog_path = default_path; |
321 } | 321 } |
322 | 322 |
323 base::FilePath virtual_path; | 323 base::FilePath virtual_path; |
324 if (file_manager_util::ConvertFileToRelativeFileSystemPath( | 324 // If an absolute path is specified as the default path, convert it to the |
325 profile_, kFileBrowserDomain, default_dialog_path, &virtual_path)) { | 325 // virtual path in the file browser extension. Due to the current design, |
| 326 // an invalid temporal cache file path may passed as |default_dialog_path| |
| 327 // (crbug.com/178013 #9-#11). In such a case, we use the last selected |
| 328 // directory as a workaround. Real fix is tracked at crbug.com/110119. |
| 329 if (default_dialog_path.IsAbsolute() && |
| 330 (file_manager_util::ConvertFileToRelativeFileSystemPath( |
| 331 profile_, kFileBrowserDomain, default_dialog_path, &virtual_path) || |
| 332 file_manager_util::ConvertFileToRelativeFileSystemPath( |
| 333 profile_, kFileBrowserDomain, profile_->last_selected_directory(), |
| 334 &virtual_path))) { |
326 virtual_path = base::FilePath("/").Append(virtual_path); | 335 virtual_path = base::FilePath("/").Append(virtual_path); |
327 } else { | 336 } else { |
| 337 // If the path was relative, or failed to convert, just use the base name, |
328 virtual_path = default_dialog_path.BaseName(); | 338 virtual_path = default_dialog_path.BaseName(); |
329 } | 339 } |
330 | 340 |
331 has_multiple_file_type_choices_ = | 341 has_multiple_file_type_choices_ = |
332 file_types ? file_types->extensions.size() > 1 : true; | 342 file_types ? file_types->extensions.size() > 1 : true; |
333 | 343 |
334 GURL file_browser_url = file_manager_util::GetFileBrowserUrlWithParams( | 344 GURL file_browser_url = file_manager_util::GetFileBrowserUrlWithParams( |
335 type, title, virtual_path, file_types, file_type_index, | 345 type, title, virtual_path, file_types, file_type_index, |
336 default_extension); | 346 default_extension); |
337 | 347 |
(...skipping 16 matching lines...) Expand all Loading... |
354 kFileManagerMinimumHeight); | 364 kFileManagerMinimumHeight); |
355 | 365 |
356 // Connect our listener to FileDialogFunction's per-tab callbacks. | 366 // Connect our listener to FileDialogFunction's per-tab callbacks. |
357 AddPending(tab_id); | 367 AddPending(tab_id); |
358 | 368 |
359 extension_dialog_ = dialog; | 369 extension_dialog_ = dialog; |
360 params_ = params; | 370 params_ = params; |
361 tab_id_ = tab_id; | 371 tab_id_ = tab_id; |
362 owner_window_ = owner_window; | 372 owner_window_ = owner_window; |
363 } | 373 } |
OLD | NEW |