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> |
| 8 |
| 9 #include "base/location.h" |
7 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ptr_util.h" |
| 12 #include "content/public/browser/browser_thread.h" |
8 | 13 |
9 namespace safe_browsing { | 14 namespace safe_browsing { |
10 | 15 |
11 using chrome_cleaner::mojom::ChromePrompt; | 16 using chrome_cleaner::mojom::ChromePrompt; |
12 using chrome_cleaner::mojom::ChromePromptRequest; | 17 using chrome_cleaner::mojom::ChromePromptRequest; |
13 using chrome_cleaner::mojom::ElevationStatus; | 18 using chrome_cleaner::mojom::ElevationStatus; |
14 using chrome_cleaner::mojom::PromptAcceptance; | 19 using chrome_cleaner::mojom::PromptAcceptance; |
15 using chrome_cleaner::mojom::UwSPtr; | 20 using chrome_cleaner::mojom::UwSPtr; |
16 | 21 |
17 ChromePromptImpl::ChromePromptImpl(ChromePromptRequest request, | 22 ChromePromptImpl::ChromePromptImpl(ChromePromptRequest request, |
18 base::Closure on_connection_closed) | 23 base::Closure on_connection_closed, |
19 : binding_(this, std::move(request)) { | 24 OnPromptUser on_prompt_user) |
| 25 : binding_(this, std::move(request)), |
| 26 on_prompt_user_(std::move(on_prompt_user)) { |
| 27 DCHECK(on_prompt_user_); |
20 binding_.set_connection_error_handler(std::move(on_connection_closed)); | 28 binding_.set_connection_error_handler(std::move(on_connection_closed)); |
21 } | 29 } |
22 | 30 |
23 ChromePromptImpl::~ChromePromptImpl() {} | 31 ChromePromptImpl::~ChromePromptImpl() {} |
24 | 32 |
25 void ChromePromptImpl::PromptUser(std::vector<UwSPtr> removable_uws_found, | 33 void ChromePromptImpl::PromptUser(std::vector<UwSPtr> removable_uws_found, |
26 ElevationStatus elevation_status, | 34 ElevationStatus elevation_status, |
27 ChromePrompt::PromptUserCallback callback) { | 35 ChromePrompt::PromptUserCallback callback) { |
28 // Placeholder. The actual implementation will show the prompt dialog to the | 36 auto files_to_delete = base::MakeUnique<std::set<base::FilePath>>(); |
29 // user and invoke this callback depending on the user's response. | 37 for (const UwSPtr& uws_ptr : removable_uws_found) { |
30 std::move(callback).Run(PromptAcceptance::DENIED); | 38 for (const base::FilePath& filepath : uws_ptr->files_to_delete) { |
| 39 files_to_delete->insert(filepath); |
| 40 } |
| 41 } |
| 42 |
| 43 if (on_prompt_user_) { |
| 44 std::move(on_prompt_user_) |
| 45 .Run(std::move(files_to_delete), std::move(callback)); |
| 46 } |
31 } | 47 } |
32 | 48 |
33 } // namespace safe_browsing | 49 } // namespace safe_browsing |
OLD | NEW |