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/file_select_helper.h" | 5 #include "chrome/browser/file_select_helper.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 dialog_type_ = ui::SelectFileDialog::SELECT_FOLDER; | 394 dialog_type_ = ui::SelectFileDialog::SELECT_FOLDER; |
395 break; | 395 break; |
396 case FileChooserParams::Save: | 396 case FileChooserParams::Save: |
397 dialog_type_ = ui::SelectFileDialog::SELECT_SAVEAS_FILE; | 397 dialog_type_ = ui::SelectFileDialog::SELECT_SAVEAS_FILE; |
398 break; | 398 break; |
399 default: | 399 default: |
400 // Prevent warning. | 400 // Prevent warning. |
401 dialog_type_ = ui::SelectFileDialog::SELECT_OPEN_FILE; | 401 dialog_type_ = ui::SelectFileDialog::SELECT_OPEN_FILE; |
402 NOTREACHED(); | 402 NOTREACHED(); |
403 } | 403 } |
404 FilePath default_file_name = params.default_file_name; | 404 |
405 if (default_file_name.empty()) | 405 FilePath default_file_name = params.default_file_name.IsAbsolute() ? |
406 default_file_name = profile_->last_selected_directory(); | 406 params.default_file_name : |
| 407 profile_->last_selected_directory().Append(params.default_file_name); |
407 | 408 |
408 gfx::NativeWindow owning_window = | 409 gfx::NativeWindow owning_window = |
409 platform_util::GetTopLevel(render_view_host_->GetView()->GetNativeView()); | 410 platform_util::GetTopLevel(render_view_host_->GetView()->GetNativeView()); |
410 | 411 |
411 select_file_dialog_->SelectFile( | 412 select_file_dialog_->SelectFile( |
412 dialog_type_, | 413 dialog_type_, |
413 params.title, | 414 params.title, |
414 default_file_name, | 415 default_file_name, |
415 select_file_types_.get(), | 416 select_file_types_.get(), |
416 select_file_types_.get() ? 1 : 0, // 1-based index. | 417 select_file_types_.get() ? 1 : 0, // 1-based index. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 // A 1 character accept type will always be invalid (either a "." in the case | 483 // A 1 character accept type will always be invalid (either a "." in the case |
483 // of an extension or a "/" in the case of a MIME type). | 484 // of an extension or a "/" in the case of a MIME type). |
484 std::string unused; | 485 std::string unused; |
485 if (accept_type.length() <= 1 || | 486 if (accept_type.length() <= 1 || |
486 StringToLowerASCII(accept_type) != accept_type || | 487 StringToLowerASCII(accept_type) != accept_type || |
487 TrimWhitespaceASCII(accept_type, TRIM_ALL, &unused) != TRIM_NONE) { | 488 TrimWhitespaceASCII(accept_type, TRIM_ALL, &unused) != TRIM_NONE) { |
488 return false; | 489 return false; |
489 } | 490 } |
490 return true; | 491 return true; |
491 } | 492 } |
OLD | NEW |