Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(542)

Side by Side Diff: chrome/browser/safe_browsing/chrome_cleaner/srt_chrome_prompt_impl.cc

Issue 2932703006: Chrome Cleaner: Remove indirect base::FilePath mojo dependency. (Closed)
Patch Set: Address review comments, make tests pass Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 UInt16VectorToFilePath(const std::vector<uint16_t>& string) {
20 return base::FilePath(base::string16(string.begin(), string.end()));
Fabio Tirelo 2017/06/12 18:20:46 It may be worth static asserting that size_of(u
proberge 2017/06/12 19:02:53 Done.
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) {
39 if (on_prompt_user_) { 47 if (on_prompt_user_) {
48 std::set<base::FilePath> file_paths;
49 for (const chrome_cleaner::mojom::FilePathPtr& file_path_ptr :
50 files_to_delete) {
51 file_paths.insert(UInt16VectorToFilePath(file_path_ptr.get()->value));
52 }
53
40 std::move(on_prompt_user_) 54 std::move(on_prompt_user_)
41 .Run(base::MakeUnique<std::set<base::FilePath>>(files_to_delete.begin(), 55 .Run(base::MakeUnique<std::set<base::FilePath>>(std::move(file_paths)),
42 files_to_delete.end()),
43 std::move(callback)); 56 std::move(callback));
44 } 57 }
45 } 58 }
46 59
47 } // namespace safe_browsing 60 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698