Chromium Code Reviews| 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/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 | 14 |
| 15 namespace safe_browsing { | 15 namespace safe_browsing { |
| 16 | 16 |
| 17 namespace { | |
| 18 | |
| 19 base::FilePath CastUInt16ToFilePath(const uint16_t* string) { | |
| 20 return base::FilePath(reinterpret_cast<const wchar_t*>(string)); | |
| 21 } | |
| 22 | |
| 23 } // namespace | |
| 24 | |
| 17 using chrome_cleaner::mojom::ChromePrompt; | 25 using chrome_cleaner::mojom::ChromePrompt; |
| 18 using chrome_cleaner::mojom::ChromePromptRequest; | 26 using chrome_cleaner::mojom::ChromePromptRequest; |
| 19 using chrome_cleaner::mojom::PromptAcceptance; | 27 using chrome_cleaner::mojom::PromptAcceptance; |
| 20 using content::BrowserThread; | 28 using content::BrowserThread; |
| 21 | 29 |
| 22 ChromePromptImpl::ChromePromptImpl(ChromePromptRequest request, | 30 ChromePromptImpl::ChromePromptImpl(ChromePromptRequest request, |
| 23 base::Closure on_connection_closed, | 31 base::Closure on_connection_closed, |
| 24 OnPromptUser on_prompt_user) | 32 OnPromptUser on_prompt_user) |
| 25 : binding_(this, std::move(request)), | 33 : binding_(this, std::move(request)), |
| 26 on_prompt_user_(std::move(on_prompt_user)) { | 34 on_prompt_user_(std::move(on_prompt_user)) { |
| 27 DCHECK(on_prompt_user_); | 35 DCHECK(on_prompt_user_); |
| 28 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 36 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 29 binding_.set_connection_error_handler(std::move(on_connection_closed)); | 37 binding_.set_connection_error_handler(std::move(on_connection_closed)); |
| 30 } | 38 } |
| 31 | 39 |
| 32 ChromePromptImpl::~ChromePromptImpl() { | 40 ChromePromptImpl::~ChromePromptImpl() { |
| 33 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 41 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 34 } | 42 } |
| 35 | 43 |
| 36 void ChromePromptImpl::PromptUser( | 44 void ChromePromptImpl::PromptUser( |
| 37 const std::vector<base::FilePath>& files_to_delete, | 45 std::vector<chrome_cleaner::mojom::FilePathPtr> files_to_delete, |
| 38 ChromePrompt::PromptUserCallback callback) { | 46 ChromePrompt::PromptUserCallback callback) { |
| 47 std::vector<base::FilePath> file_paths; | |
|
Fabio Tirelo
2017/06/12 14:04:50
Instead of creating this vector to later copy all
proberge
2017/06/12 17:49:30
Done.
| |
| 48 for (const chrome_cleaner::mojom::FilePathPtr& file_path_ptr : | |
| 49 files_to_delete) { | |
|
Fabio Tirelo
2017/06/12 14:04:50
Please move this to inside the conditional in line
proberge
2017/06/12 17:49:30
Done.
| |
| 50 file_paths.push_back( | |
| 51 CastUInt16ToFilePath(file_path_ptr.get()->value.data())); | |
| 52 } | |
| 53 | |
| 39 if (on_prompt_user_) { | 54 if (on_prompt_user_) { |
| 40 std::move(on_prompt_user_) | 55 std::move(on_prompt_user_) |
| 41 .Run(base::MakeUnique<std::set<base::FilePath>>(files_to_delete.begin(), | 56 .Run(base::MakeUnique<std::set<base::FilePath>>(file_paths.begin(), |
| 42 files_to_delete.end()), | 57 file_paths.end()), |
| 43 std::move(callback)); | 58 std::move(callback)); |
| 44 } | 59 } |
| 45 } | 60 } |
| 46 | 61 |
| 47 } // namespace safe_browsing | 62 } // namespace safe_browsing |
| OLD | NEW |