| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/chrome_cleaner/srt_chrome_prompt_impl.h" | 5 #include "chrome/browser/safe_browsing/chrome_cleaner/srt_chrome_prompt_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 | 13 |
| 14 using content::BrowserThread; |
| 15 |
| 14 namespace safe_browsing { | 16 namespace safe_browsing { |
| 15 | 17 |
| 16 using chrome_cleaner::mojom::ChromePrompt; | 18 using chrome_cleaner::mojom::ChromePrompt; |
| 17 using chrome_cleaner::mojom::ChromePromptRequest; | 19 using chrome_cleaner::mojom::ChromePromptRequest; |
| 18 using chrome_cleaner::mojom::ElevationStatus; | 20 using chrome_cleaner::mojom::ElevationStatus; |
| 19 using chrome_cleaner::mojom::PromptAcceptance; | 21 using chrome_cleaner::mojom::PromptAcceptance; |
| 20 using chrome_cleaner::mojom::UwSPtr; | 22 using chrome_cleaner::mojom::UwSPtr; |
| 21 | 23 |
| 22 ChromePromptImpl::ChromePromptImpl(ChromePromptRequest request, | 24 ChromePromptImpl::ChromePromptImpl(ChromePromptRequest request, |
| 23 base::Closure on_connection_closed, | 25 base::Closure on_connection_closed, |
| 24 OnPromptUser on_prompt_user) | 26 OnPromptUser on_prompt_user) |
| 25 : binding_(this, std::move(request)), | 27 : binding_(this, std::move(request)), |
| 26 on_prompt_user_(std::move(on_prompt_user)) { | 28 on_prompt_user_(std::move(on_prompt_user)) { |
| 27 DCHECK(on_prompt_user_); | 29 DCHECK(on_prompt_user_); |
| 30 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 28 binding_.set_connection_error_handler(std::move(on_connection_closed)); | 31 binding_.set_connection_error_handler(std::move(on_connection_closed)); |
| 29 } | 32 } |
| 30 | 33 |
| 31 ChromePromptImpl::~ChromePromptImpl() {} | 34 ChromePromptImpl::~ChromePromptImpl() { |
| 35 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 36 } |
| 32 | 37 |
| 33 void ChromePromptImpl::PromptUser(std::vector<UwSPtr> removable_uws_found, | 38 void ChromePromptImpl::PromptUser(std::vector<UwSPtr> removable_uws_found, |
| 34 ElevationStatus elevation_status, | 39 ElevationStatus elevation_status, |
| 35 ChromePrompt::PromptUserCallback callback) { | 40 ChromePrompt::PromptUserCallback callback) { |
| 36 auto files_to_delete = base::MakeUnique<std::set<base::FilePath>>(); | 41 auto files_to_delete = base::MakeUnique<std::set<base::FilePath>>(); |
| 37 for (const UwSPtr& uws_ptr : removable_uws_found) { | 42 for (const UwSPtr& uws_ptr : removable_uws_found) { |
| 38 files_to_delete->insert(uws_ptr->files_to_delete.begin(), | 43 files_to_delete->insert(uws_ptr->files_to_delete.begin(), |
| 39 uws_ptr->files_to_delete.end()); | 44 uws_ptr->files_to_delete.end()); |
| 40 } | 45 } |
| 41 | 46 |
| 42 if (on_prompt_user_) { | 47 if (on_prompt_user_) { |
| 43 std::move(on_prompt_user_) | 48 std::move(on_prompt_user_) |
| 44 .Run(std::move(files_to_delete), std::move(callback)); | 49 .Run(std::move(files_to_delete), std::move(callback)); |
| 45 } | 50 } |
| 46 } | 51 } |
| 47 | 52 |
| 48 } // namespace safe_browsing | 53 } // namespace safe_browsing |
| OLD | NEW |