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

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

Issue 2825003002: Rewrite base::Bind to base::BindOnce with base_bind_rewriters in //chrome/browser/{a,b,c,d,e,f,g}* (Closed)
Patch Set: split rest of changes to 3 CLs Created 3 years, 8 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 void FileSelectHelper::NotifyRenderFrameHostAndEndAfterConversion( 332 void FileSelectHelper::NotifyRenderFrameHostAndEndAfterConversion(
333 const std::vector<content::FileChooserFileInfo>& list) { 333 const std::vector<content::FileChooserFileInfo>& list) {
334 if (render_frame_host_) 334 if (render_frame_host_)
335 render_frame_host_->FilesSelectedInChooser(list, dialog_mode_); 335 render_frame_host_->FilesSelectedInChooser(list, dialog_mode_);
336 336
337 // No members should be accessed from here on. 337 // No members should be accessed from here on.
338 RunFileChooserEnd(); 338 RunFileChooserEnd();
339 } 339 }
340 340
341 void FileSelectHelper::DeleteTemporaryFiles() { 341 void FileSelectHelper::DeleteTemporaryFiles() {
342 BrowserThread::PostTask(BrowserThread::FILE, 342 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
343 FROM_HERE, 343 base::BindOnce(&DeleteFiles, temporary_files_));
344 base::Bind(&DeleteFiles, temporary_files_));
345 temporary_files_.clear(); 344 temporary_files_.clear();
346 } 345 }
347 346
348 void FileSelectHelper::CleanUp() { 347 void FileSelectHelper::CleanUp() {
349 if (!temporary_files_.empty()) { 348 if (!temporary_files_.empty()) {
350 DeleteTemporaryFiles(); 349 DeleteTemporaryFiles();
351 350
352 // Now that the temporary files have been scheduled for deletion, there 351 // Now that the temporary files have been scheduled for deletion, there
353 // is no longer any reason to keep this instance around. 352 // is no longer any reason to keep this instance around.
354 Release(); 353 Release();
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 web_contents_ = WebContents::FromRenderFrameHost(render_frame_host); 463 web_contents_ = WebContents::FromRenderFrameHost(render_frame_host);
465 notification_registrar_.RemoveAll(); 464 notification_registrar_.RemoveAll();
466 content::WebContentsObserver::Observe(web_contents_); 465 content::WebContentsObserver::Observe(web_contents_);
467 notification_registrar_.Add( 466 notification_registrar_.Add(
468 this, content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, 467 this, content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
469 content::Source<RenderWidgetHost>( 468 content::Source<RenderWidgetHost>(
470 render_frame_host_->GetRenderViewHost()->GetWidget())); 469 render_frame_host_->GetRenderViewHost()->GetWidget()));
471 470
472 BrowserThread::PostTask( 471 BrowserThread::PostTask(
473 BrowserThread::FILE, FROM_HERE, 472 BrowserThread::FILE, FROM_HERE,
474 base::Bind(&FileSelectHelper::GetFileTypesOnFileThread, this, 473 base::BindOnce(&FileSelectHelper::GetFileTypesOnFileThread, this,
475 base::Passed(&params))); 474 base::Passed(&params)));
476 475
477 // Because this class returns notifications to the RenderViewHost, it is 476 // Because this class returns notifications to the RenderViewHost, it is
478 // difficult for callers to know how long to keep a reference to this 477 // difficult for callers to know how long to keep a reference to this
479 // instance. We AddRef() here to keep the instance alive after we return 478 // instance. We AddRef() here to keep the instance alive after we return
480 // to the caller, until the last callback is received from the file dialog. 479 // to the caller, until the last callback is received from the file dialog.
481 // At that point, we must call RunFileChooserEnd(). 480 // At that point, we must call RunFileChooserEnd().
482 AddRef(); 481 AddRef();
483 } 482 }
484 483
485 void FileSelectHelper::GetFileTypesOnFileThread( 484 void FileSelectHelper::GetFileTypesOnFileThread(
486 std::unique_ptr<FileChooserParams> params) { 485 std::unique_ptr<FileChooserParams> params) {
487 select_file_types_ = GetFileTypesFromAcceptType(params->accept_types); 486 select_file_types_ = GetFileTypesFromAcceptType(params->accept_types);
488 select_file_types_->allowed_paths = 487 select_file_types_->allowed_paths =
489 params->need_local_path ? ui::SelectFileDialog::FileTypeInfo::NATIVE_PATH 488 params->need_local_path ? ui::SelectFileDialog::FileTypeInfo::NATIVE_PATH
490 : ui::SelectFileDialog::FileTypeInfo::ANY_PATH; 489 : ui::SelectFileDialog::FileTypeInfo::ANY_PATH;
491 490
492 BrowserThread::PostTask( 491 BrowserThread::PostTask(
493 BrowserThread::UI, FROM_HERE, 492 BrowserThread::UI, FROM_HERE,
494 base::Bind(&FileSelectHelper::GetSanitizedFilenameOnUIThread, this, 493 base::BindOnce(&FileSelectHelper::GetSanitizedFilenameOnUIThread, this,
495 base::Passed(&params))); 494 base::Passed(&params)));
496 } 495 }
497 496
498 void FileSelectHelper::GetSanitizedFilenameOnUIThread( 497 void FileSelectHelper::GetSanitizedFilenameOnUIThread(
499 std::unique_ptr<FileChooserParams> params) { 498 std::unique_ptr<FileChooserParams> params) {
500 base::FilePath default_file_path = profile_->last_selected_directory().Append( 499 base::FilePath default_file_path = profile_->last_selected_directory().Append(
501 GetSanitizedFileName(params->default_file_name)); 500 GetSanitizedFileName(params->default_file_name));
502 #if defined(FULL_SAFE_BROWSING) 501 #if defined(FULL_SAFE_BROWSING)
503 CheckDownloadRequestWithSafeBrowsing(default_file_path, std::move(params)); 502 CheckDownloadRequestWithSafeBrowsing(default_file_path, std::move(params));
504 #else 503 #else
505 RunFileChooserOnUIThread(default_file_path, std::move(params)); 504 RunFileChooserOnUIThread(default_file_path, std::move(params));
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 692
694 // static 693 // static
695 base::FilePath FileSelectHelper::GetSanitizedFileName( 694 base::FilePath FileSelectHelper::GetSanitizedFileName(
696 const base::FilePath& suggested_filename) { 695 const base::FilePath& suggested_filename) {
697 if (suggested_filename.empty()) 696 if (suggested_filename.empty())
698 return base::FilePath(); 697 return base::FilePath();
699 return net::GenerateFileName( 698 return net::GenerateFileName(
700 GURL(), std::string(), std::string(), suggested_filename.AsUTF8Unsafe(), 699 GURL(), std::string(), std::string(), suggested_filename.AsUTF8Unsafe(),
701 std::string(), l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME)); 700 std::string(), l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME));
702 } 701 }
OLDNEW
« no previous file with comments | « chrome/browser/feedback/feedback_profile_observer.cc ('k') | chrome/browser/gcm/fake_gcm_profile_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698