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 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
452 break; | 452 break; |
453 case FileChooserParams::Save: | 453 case FileChooserParams::Save: |
454 dialog_type_ = ui::SelectFileDialog::SELECT_SAVEAS_FILE; | 454 dialog_type_ = ui::SelectFileDialog::SELECT_SAVEAS_FILE; |
455 break; | 455 break; |
456 default: | 456 default: |
457 // Prevent warning. | 457 // Prevent warning. |
458 dialog_type_ = ui::SelectFileDialog::SELECT_OPEN_FILE; | 458 dialog_type_ = ui::SelectFileDialog::SELECT_OPEN_FILE; |
459 NOTREACHED(); | 459 NOTREACHED(); |
460 } | 460 } |
461 | 461 |
462 base::FilePath default_file_name = params.default_file_name.IsAbsolute() ? | 462 // default_file_name is untrusted from renderer so only take basename. |
Lei Zhang
2014/12/20 01:08:58
nit: |default_file_name|
| |
463 params.default_file_name : | 463 base::FilePath default_file_name = profile_->last_selected_directory().Append( |
464 profile_->last_selected_directory().Append(params.default_file_name); | 464 params.default_file_name.BaseName()); |
465 | 465 |
466 gfx::NativeWindow owning_window = | 466 gfx::NativeWindow owning_window = |
467 platform_util::GetTopLevel(render_view_host_->GetView()->GetNativeView()); | 467 platform_util::GetTopLevel(render_view_host_->GetView()->GetNativeView()); |
468 | 468 |
469 #if defined(OS_ANDROID) | 469 #if defined(OS_ANDROID) |
470 // Android needs the original MIME types and an additional capture value. | 470 // Android needs the original MIME types and an additional capture value. |
471 std::pair<std::vector<base::string16>, bool> accept_types = | 471 std::pair<std::vector<base::string16>, bool> accept_types = |
472 std::make_pair(params.accept_types, params.capture); | 472 std::make_pair(params.accept_types, params.capture); |
473 #endif | 473 #endif |
474 | 474 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
566 // of an extension or a "/" in the case of a MIME type). | 566 // of an extension or a "/" in the case of a MIME type). |
567 std::string unused; | 567 std::string unused; |
568 if (accept_type.length() <= 1 || | 568 if (accept_type.length() <= 1 || |
569 base::StringToLowerASCII(accept_type) != accept_type || | 569 base::StringToLowerASCII(accept_type) != accept_type || |
570 base::TrimWhitespaceASCII(accept_type, base::TRIM_ALL, &unused) != | 570 base::TrimWhitespaceASCII(accept_type, base::TRIM_ALL, &unused) != |
571 base::TRIM_NONE) { | 571 base::TRIM_NONE) { |
572 return false; | 572 return false; |
573 } | 573 } |
574 return true; | 574 return true; |
575 } | 575 } |
OLD | NEW |