| 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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 case FileChooserParams::OpenFolder: | 384 case FileChooserParams::OpenFolder: |
| 385 dialog_type_ = SelectFileDialog::SELECT_FOLDER; | 385 dialog_type_ = SelectFileDialog::SELECT_FOLDER; |
| 386 break; | 386 break; |
| 387 case FileChooserParams::Save: | 387 case FileChooserParams::Save: |
| 388 dialog_type_ = SelectFileDialog::SELECT_SAVEAS_FILE; | 388 dialog_type_ = SelectFileDialog::SELECT_SAVEAS_FILE; |
| 389 break; | 389 break; |
| 390 default: | 390 default: |
| 391 dialog_type_ = SelectFileDialog::SELECT_OPEN_FILE; // Prevent warning. | 391 dialog_type_ = SelectFileDialog::SELECT_OPEN_FILE; // Prevent warning. |
| 392 NOTREACHED(); | 392 NOTREACHED(); |
| 393 } | 393 } |
| 394 FilePath default_file_name = params.default_file_name; | 394 |
| 395 if (default_file_name.empty()) | 395 FilePath default_file_name = params.default_file_name.IsAbsolute() ? |
| 396 default_file_name = profile_->last_selected_directory(); | 396 params.default_file_name : |
| 397 profile_->last_selected_directory().Append(params.default_file_name); |
| 397 | 398 |
| 398 gfx::NativeWindow owning_window = | 399 gfx::NativeWindow owning_window = |
| 399 platform_util::GetTopLevel(render_view_host_->GetView()->GetNativeView()); | 400 platform_util::GetTopLevel(render_view_host_->GetView()->GetNativeView()); |
| 400 | 401 |
| 401 select_file_dialog_->SelectFile( | 402 select_file_dialog_->SelectFile( |
| 402 dialog_type_, | 403 dialog_type_, |
| 403 params.title, | 404 params.title, |
| 404 default_file_name, | 405 default_file_name, |
| 405 select_file_types_.get(), | 406 select_file_types_.get(), |
| 406 select_file_types_.get() ? 1 : 0, // 1-based index. | 407 select_file_types_.get() ? 1 : 0, // 1-based index. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 // A 1 character accept type will always be invalid (either a "." in the case | 474 // A 1 character accept type will always be invalid (either a "." in the case |
| 474 // of an extension or a "/" in the case of a MIME type). | 475 // of an extension or a "/" in the case of a MIME type). |
| 475 std::string unused; | 476 std::string unused; |
| 476 if (accept_type.length() <= 1 || | 477 if (accept_type.length() <= 1 || |
| 477 StringToLowerASCII(accept_type) != accept_type || | 478 StringToLowerASCII(accept_type) != accept_type || |
| 478 TrimWhitespaceASCII(accept_type, TRIM_ALL, &unused) != TRIM_NONE) { | 479 TrimWhitespaceASCII(accept_type, TRIM_ALL, &unused) != TRIM_NONE) { |
| 479 return false; | 480 return false; |
| 480 } | 481 } |
| 481 return true; | 482 return true; |
| 482 } | 483 } |
| OLD | NEW |