Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1295)

Side by Side Diff: chrome/browser/file_select_helper.cc

Issue 10916160: Upstreaming SelectFileDialog for Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 NOTREACHED(); 402 NOTREACHED();
403 } 403 }
404 404
405 FilePath default_file_name = params.default_file_name.IsAbsolute() ? 405 FilePath default_file_name = params.default_file_name.IsAbsolute() ?
406 params.default_file_name : 406 params.default_file_name :
407 profile_->last_selected_directory().Append(params.default_file_name); 407 profile_->last_selected_directory().Append(params.default_file_name);
408 408
409 gfx::NativeWindow owning_window = 409 gfx::NativeWindow owning_window =
410 platform_util::GetTopLevel(render_view_host_->GetView()->GetNativeView()); 410 platform_util::GetTopLevel(render_view_host_->GetView()->GetNativeView());
411 411
412 #if defined(OS_ANDROID)
413 // Android needs the original MIME types and an additional capture value.
414 std::vector<string16> accept_types(params.accept_types);
415 // We append the capture value to the end of the accept_types vector. This
416 // allows to pass MIME types and the capture value to the SelectFile method.
417 accept_types.push_back(params.capture);
418 #endif
419
412 select_file_dialog_->SelectFile( 420 select_file_dialog_->SelectFile(
413 dialog_type_, 421 dialog_type_,
414 params.title, 422 params.title,
415 default_file_name, 423 default_file_name,
416 select_file_types_.get(), 424 select_file_types_.get(),
417 select_file_types_.get() ? 1 : 0, // 1-based index. 425 select_file_types_.get() ? 1 : 0, // 1-based index.
418 FILE_PATH_LITERAL(""), 426 FILE_PATH_LITERAL(""),
419 owning_window, 427 owning_window,
420 #if defined(OS_ANDROID) 428 #if defined(OS_ANDROID)
421 const_cast<content::FileChooserParams*>(&params)); 429 &accept_types);
422 #else 430 #else
423 NULL); 431 NULL);
424 #endif 432 #endif
425 433
426 select_file_types_.reset(); 434 select_file_types_.reset();
427 } 435 }
428 436
429 // This method is called when we receive the last callback from the file 437 // This method is called when we receive the last callback from the file
430 // chooser dialog. Perform any cleanup and release the reference we added 438 // chooser dialog. Perform any cleanup and release the reference we added
431 // in RunFileChooser(). 439 // in RunFileChooser().
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 // A 1 character accept type will always be invalid (either a "." in the case 491 // A 1 character accept type will always be invalid (either a "." in the case
484 // of an extension or a "/" in the case of a MIME type). 492 // of an extension or a "/" in the case of a MIME type).
485 std::string unused; 493 std::string unused;
486 if (accept_type.length() <= 1 || 494 if (accept_type.length() <= 1 ||
487 StringToLowerASCII(accept_type) != accept_type || 495 StringToLowerASCII(accept_type) != accept_type ||
488 TrimWhitespaceASCII(accept_type, TRIM_ALL, &unused) != TRIM_NONE) { 496 TrimWhitespaceASCII(accept_type, TRIM_ALL, &unused) != TRIM_NONE) {
489 return false; 497 return false;
490 } 498 }
491 return true; 499 return true;
492 } 500 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698