OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/safe_browsing/path_sanitizer.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "base/path_service.h" | |
9 | |
10 namespace safe_browsing { | |
11 | |
12 PathSanitizer::PathSanitizer() { | |
13 // Get the home directory path. | |
14 if (!PathService::Get(base::DIR_HOME, &home_path_)) | |
15 NOTREACHED(); | |
16 } | |
17 | |
18 const base::FilePath& PathSanitizer::GetHomeDirectory() const { | |
19 return home_path_; | |
20 } | |
21 | |
22 void PathSanitizer::StripHomeDirectory(base::FilePath* file_path) const { | |
23 base::FilePath sanitized_path(FILE_PATH_LITERAL("~\\")); | |
24 | |
25 // The |file_path| is overwritten only if a relative path is found. | |
26 if (home_path_.AppendRelativePath(*file_path, &sanitized_path)) | |
27 *file_path = sanitized_path; | |
28 } | |
29 | |
30 void PathSanitizer::StripHomeDirectoryFromString( | |
31 base::string16* file_path_str) const { | |
32 base::FilePath file_path(*file_path_str); | |
grt (UTC plus 2)
2014/06/16 20:30:38
looks like you'll either need to make PathSanitize
pmonette_google.com
2014/06/17 17:48:22
Done.
| |
33 | |
34 StripHomeDirectory(&file_path); | |
35 | |
36 *file_path_str = file_path.value(); | |
37 } | |
38 | |
39 } // namespace safe_browsing | |
OLD | NEW |