| 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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 NOTREACHED(); | 400 NOTREACHED(); |
| 401 } | 401 } |
| 402 | 402 |
| 403 FilePath default_file_name = params.default_file_name.IsAbsolute() ? | 403 FilePath default_file_name = params.default_file_name.IsAbsolute() ? |
| 404 params.default_file_name : | 404 params.default_file_name : |
| 405 profile_->last_selected_directory().Append(params.default_file_name); | 405 profile_->last_selected_directory().Append(params.default_file_name); |
| 406 | 406 |
| 407 gfx::NativeWindow owning_window = | 407 gfx::NativeWindow owning_window = |
| 408 platform_util::GetTopLevel(render_view_host_->GetView()->GetNativeView()); | 408 platform_util::GetTopLevel(render_view_host_->GetView()->GetNativeView()); |
| 409 | 409 |
| 410 #if defined(OS_ANDROID) |
| 411 // Android needs the original MIME types and an additional capture value. |
| 412 std::vector<string16> accept_types(params.accept_types); |
| 413 // We append the capture value to the end of the accept_types vector. This |
| 414 // allows to pass MIME types and the capture value to the SelectFile method. |
| 415 accept_types.push_back(params.capture); |
| 416 #endif |
| 417 |
| 410 select_file_dialog_->SelectFile( | 418 select_file_dialog_->SelectFile( |
| 411 dialog_type_, | 419 dialog_type_, |
| 412 params.title, | 420 params.title, |
| 413 default_file_name, | 421 default_file_name, |
| 414 select_file_types_.get(), | 422 select_file_types_.get(), |
| 415 select_file_types_.get() ? 1 : 0, // 1-based index. | 423 select_file_types_.get() ? 1 : 0, // 1-based index. |
| 416 FILE_PATH_LITERAL(""), | 424 FILE_PATH_LITERAL(""), |
| 417 owning_window, | 425 owning_window, |
| 418 #if defined(OS_ANDROID) | 426 #if defined(OS_ANDROID) |
| 419 const_cast<content::FileChooserParams*>(¶ms)); | 427 &accept_types); |
| 420 #else | 428 #else |
| 421 NULL); | 429 NULL); |
| 422 #endif | 430 #endif |
| 423 | 431 |
| 424 select_file_types_.reset(); | 432 select_file_types_.reset(); |
| 425 } | 433 } |
| 426 | 434 |
| 427 // This method is called when we receive the last callback from the file | 435 // This method is called when we receive the last callback from the file |
| 428 // chooser dialog. Perform any cleanup and release the reference we added | 436 // chooser dialog. Perform any cleanup and release the reference we added |
| 429 // in RunFileChooser(). | 437 // in RunFileChooser(). |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 // A 1 character accept type will always be invalid (either a "." in the case | 489 // A 1 character accept type will always be invalid (either a "." in the case |
| 482 // of an extension or a "/" in the case of a MIME type). | 490 // of an extension or a "/" in the case of a MIME type). |
| 483 std::string unused; | 491 std::string unused; |
| 484 if (accept_type.length() <= 1 || | 492 if (accept_type.length() <= 1 || |
| 485 StringToLowerASCII(accept_type) != accept_type || | 493 StringToLowerASCII(accept_type) != accept_type || |
| 486 TrimWhitespaceASCII(accept_type, TRIM_ALL, &unused) != TRIM_NONE) { | 494 TrimWhitespaceASCII(accept_type, TRIM_ALL, &unused) != TRIM_NONE) { |
| 487 return false; | 495 return false; |
| 488 } | 496 } |
| 489 return true; | 497 return true; |
| 490 } | 498 } |
| OLD | NEW |