| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 // static | 423 // static |
| 424 void FileSelectHelper::RunFileChooser( | 424 void FileSelectHelper::RunFileChooser( |
| 425 content::RenderFrameHost* render_frame_host, | 425 content::RenderFrameHost* render_frame_host, |
| 426 const FileChooserParams& params) { | 426 const FileChooserParams& params) { |
| 427 Profile* profile = Profile::FromBrowserContext( | 427 Profile* profile = Profile::FromBrowserContext( |
| 428 render_frame_host->GetProcess()->GetBrowserContext()); | 428 render_frame_host->GetProcess()->GetBrowserContext()); |
| 429 // FileSelectHelper will keep itself alive until it sends the result message. | 429 // FileSelectHelper will keep itself alive until it sends the result message. |
| 430 scoped_refptr<FileSelectHelper> file_select_helper( | 430 scoped_refptr<FileSelectHelper> file_select_helper( |
| 431 new FileSelectHelper(profile)); | 431 new FileSelectHelper(profile)); |
| 432 file_select_helper->RunFileChooser( | 432 file_select_helper->RunFileChooser( |
| 433 render_frame_host, | 433 render_frame_host, base::MakeUnique<content::FileChooserParams>(params)); |
| 434 base::WrapUnique(new content::FileChooserParams(params))); | |
| 435 } | 434 } |
| 436 | 435 |
| 437 // static | 436 // static |
| 438 void FileSelectHelper::EnumerateDirectory(content::WebContents* tab, | 437 void FileSelectHelper::EnumerateDirectory(content::WebContents* tab, |
| 439 int request_id, | 438 int request_id, |
| 440 const base::FilePath& path) { | 439 const base::FilePath& path) { |
| 441 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); | 440 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); |
| 442 // FileSelectHelper will keep itself alive until it sends the result message. | 441 // FileSelectHelper will keep itself alive until it sends the result message. |
| 443 scoped_refptr<FileSelectHelper> file_select_helper( | 442 scoped_refptr<FileSelectHelper> file_select_helper( |
| 444 new FileSelectHelper(profile)); | 443 new FileSelectHelper(profile)); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 | 687 |
| 689 // static | 688 // static |
| 690 base::FilePath FileSelectHelper::GetSanitizedFileName( | 689 base::FilePath FileSelectHelper::GetSanitizedFileName( |
| 691 const base::FilePath& suggested_filename) { | 690 const base::FilePath& suggested_filename) { |
| 692 if (suggested_filename.empty()) | 691 if (suggested_filename.empty()) |
| 693 return base::FilePath(); | 692 return base::FilePath(); |
| 694 return net::GenerateFileName( | 693 return net::GenerateFileName( |
| 695 GURL(), std::string(), std::string(), suggested_filename.AsUTF8Unsafe(), | 694 GURL(), std::string(), std::string(), suggested_filename.AsUTF8Unsafe(), |
| 696 std::string(), l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME)); | 695 std::string(), l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME)); |
| 697 } | 696 } |
| OLD | NEW |