| 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 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 11 #include "base/files/file_enumerator.h" | 12 #include "base/files/file_enumerator.h" |
| 12 #include "base/platform_file.h" | 13 #include "base/platform_file.h" |
| 13 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
| 14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 16 #include "chrome/browser/platform_util.h" | 17 #include "chrome/browser/platform_util.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 | 409 |
| 409 base::FilePath default_file_name = params.default_file_name.IsAbsolute() ? | 410 base::FilePath default_file_name = params.default_file_name.IsAbsolute() ? |
| 410 params.default_file_name : | 411 params.default_file_name : |
| 411 profile_->last_selected_directory().Append(params.default_file_name); | 412 profile_->last_selected_directory().Append(params.default_file_name); |
| 412 | 413 |
| 413 gfx::NativeWindow owning_window = | 414 gfx::NativeWindow owning_window = |
| 414 platform_util::GetTopLevel(render_view_host_->GetView()->GetNativeView()); | 415 platform_util::GetTopLevel(render_view_host_->GetView()->GetNativeView()); |
| 415 | 416 |
| 416 #if defined(OS_ANDROID) | 417 #if defined(OS_ANDROID) |
| 417 // Android needs the original MIME types and an additional capture value. | 418 // Android needs the original MIME types and an additional capture value. |
| 418 std::vector<string16> accept_types(params.accept_types); | 419 std::pair<std::vector<string16>, bool> accept_types = |
| 419 accept_types.push_back(params.capture); | 420 std::make_pair(params.accept_types, params.capture); |
| 420 #endif | 421 #endif |
| 421 | 422 |
| 422 select_file_dialog_->SelectFile( | 423 select_file_dialog_->SelectFile( |
| 423 dialog_type_, | 424 dialog_type_, |
| 424 params.title, | 425 params.title, |
| 425 default_file_name, | 426 default_file_name, |
| 426 select_file_types_.get(), | 427 select_file_types_.get(), |
| 427 select_file_types_.get() && !select_file_types_->extensions.empty() | 428 select_file_types_.get() && !select_file_types_->extensions.empty() |
| 428 ? 1 | 429 ? 1 |
| 429 : 0, // 1-based index of default extension to show. | 430 : 0, // 1-based index of default extension to show. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 // A 1 character accept type will always be invalid (either a "." in the case | 496 // A 1 character accept type will always be invalid (either a "." in the case |
| 496 // of an extension or a "/" in the case of a MIME type). | 497 // of an extension or a "/" in the case of a MIME type). |
| 497 std::string unused; | 498 std::string unused; |
| 498 if (accept_type.length() <= 1 || | 499 if (accept_type.length() <= 1 || |
| 499 StringToLowerASCII(accept_type) != accept_type || | 500 StringToLowerASCII(accept_type) != accept_type || |
| 500 TrimWhitespaceASCII(accept_type, TRIM_ALL, &unused) != TRIM_NONE) { | 501 TrimWhitespaceASCII(accept_type, TRIM_ALL, &unused) != TRIM_NONE) { |
| 501 return false; | 502 return false; |
| 502 } | 503 } |
| 503 return true; | 504 return true; |
| 504 } | 505 } |
| OLD | NEW |