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

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: piman's nit 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
« no previous file with comments | « chrome/browser/android/tab_android.h ('k') | chrome/browser/platform_util_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.
Nico 2012/09/15 13:11:49 useless comment, remove
aurimas (slooooooooow) 2012/09/17 16:56:45 Done.
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*>(&params)); 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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/android/tab_android.h ('k') | chrome/browser/platform_util_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698