| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/safe_browsing/sandboxed_dmg_analyzer_mac.h" | 5 #include "chrome/browser/safe_browsing/sandboxed_dmg_analyzer_mac.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/task_scheduler/post_task.h" | 10 #include "base/task_scheduler/post_task.h" |
| 11 #include "chrome/common/safe_browsing/zip_analyzer_results.h" | 11 #include "chrome/common/safe_browsing/archive_analyzer_results.h" |
| 12 #include "chrome/grit/generated_resources.h" | 12 #include "chrome/grit/generated_resources.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 15 | 15 |
| 16 namespace safe_browsing { | 16 namespace safe_browsing { |
| 17 | 17 |
| 18 SandboxedDMGAnalyzer::SandboxedDMGAnalyzer(const base::FilePath& dmg_file, | 18 SandboxedDMGAnalyzer::SandboxedDMGAnalyzer(const base::FilePath& dmg_file, |
| 19 const ResultCallback& callback) | 19 const ResultCallback& callback) |
| 20 : file_path_(dmg_file), callback_(callback) { | 20 : file_path_(dmg_file), callback_(callback) { |
| 21 DCHECK(callback); | 21 DCHECK(callback); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 44 | 44 |
| 45 content::BrowserThread::PostTask( | 45 content::BrowserThread::PostTask( |
| 46 content::BrowserThread::UI, FROM_HERE, | 46 content::BrowserThread::UI, FROM_HERE, |
| 47 base::Bind(&SandboxedDMGAnalyzer::AnalyzeFile, this, | 47 base::Bind(&SandboxedDMGAnalyzer::AnalyzeFile, this, |
| 48 base::Passed(&file))); | 48 base::Passed(&file))); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void SandboxedDMGAnalyzer::ReportFileFailure() { | 51 void SandboxedDMGAnalyzer::ReportFileFailure() { |
| 52 DCHECK(!utility_process_mojo_client_); | 52 DCHECK(!utility_process_mojo_client_); |
| 53 | 53 |
| 54 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 54 content::BrowserThread::PostTask( |
| 55 base::Bind(callback_, Results())); | 55 content::BrowserThread::UI, FROM_HERE, |
| 56 base::Bind(callback_, ArchiveAnalyzerResults())); |
| 56 } | 57 } |
| 57 | 58 |
| 58 void SandboxedDMGAnalyzer::AnalyzeFile(base::File file) { | 59 void SandboxedDMGAnalyzer::AnalyzeFile(base::File file) { |
| 59 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 60 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 60 DCHECK(!utility_process_mojo_client_); | 61 DCHECK(!utility_process_mojo_client_); |
| 61 | 62 |
| 62 utility_process_mojo_client_ = base::MakeUnique< | 63 utility_process_mojo_client_ = base::MakeUnique< |
| 63 content::UtilityProcessMojoClient<chrome::mojom::SafeArchiveAnalyzer>>( | 64 content::UtilityProcessMojoClient<chrome::mojom::SafeArchiveAnalyzer>>( |
| 64 l10n_util::GetStringUTF16( | 65 l10n_util::GetStringUTF16( |
| 65 IDS_UTILITY_PROCESS_SAFE_BROWSING_ZIP_FILE_ANALYZER_NAME)); | 66 IDS_UTILITY_PROCESS_SAFE_BROWSING_ZIP_FILE_ANALYZER_NAME)); |
| 66 utility_process_mojo_client_->set_error_callback( | 67 utility_process_mojo_client_->set_error_callback(base::Bind( |
| 67 base::Bind(&SandboxedDMGAnalyzer::AnalyzeFileDone, this, Results())); | 68 &SandboxedDMGAnalyzer::AnalyzeFileDone, this, ArchiveAnalyzerResults())); |
| 68 | 69 |
| 69 utility_process_mojo_client_->Start(); | 70 utility_process_mojo_client_->Start(); |
| 70 | 71 |
| 71 utility_process_mojo_client_->service()->AnalyzeDmgFile( | 72 utility_process_mojo_client_->service()->AnalyzeDmgFile( |
| 72 std::move(file), | 73 std::move(file), |
| 73 base::Bind(&SandboxedDMGAnalyzer::AnalyzeFileDone, this)); | 74 base::Bind(&SandboxedDMGAnalyzer::AnalyzeFileDone, this)); |
| 74 } | 75 } |
| 75 | 76 |
| 76 void SandboxedDMGAnalyzer::AnalyzeFileDone(const Results& results) { | 77 void SandboxedDMGAnalyzer::AnalyzeFileDone( |
| 78 const ArchiveAnalyzerResults& results) { |
| 77 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 79 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 78 | 80 |
| 79 utility_process_mojo_client_.reset(); | 81 utility_process_mojo_client_.reset(); |
| 80 callback_.Run(results); | 82 callback_.Run(results); |
| 81 } | 83 } |
| 82 | 84 |
| 83 } // namespace safe_browsing | 85 } // namespace safe_browsing |
| OLD | NEW |