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

Side by Side Diff: content/child/webfileutilities_impl.cc

Issue 1686263008: Add utility method for WebString to base::FilePath conversion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase! Created 4 years, 10 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
« no previous file with comments | « content/child/webblobregistry_impl.cc ('k') | content/renderer/drop_data_builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 "content/child/webfileutilities_impl.h" 5 #include "content/child/webfileutilities_impl.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/child/file_info_util.h" 10 #include "content/child/file_info_util.h"
11 #include "net/base/file_stream.h" 11 #include "net/base/file_stream.h"
12 #include "net/base/filename_util.h" 12 #include "net/base/filename_util.h"
13 #include "third_party/WebKit/public/platform/FilePathConversion.h"
13 #include "third_party/WebKit/public/platform/WebFileInfo.h" 14 #include "third_party/WebKit/public/platform/WebFileInfo.h"
14 #include "third_party/WebKit/public/platform/WebString.h" 15 #include "third_party/WebKit/public/platform/WebString.h"
15 #include "third_party/WebKit/public/platform/WebURL.h" 16 #include "third_party/WebKit/public/platform/WebURL.h"
16 17
17 using blink::WebString; 18 using blink::WebString;
18 19
19 namespace content { 20 namespace content {
20 21
21 WebFileUtilitiesImpl::WebFileUtilitiesImpl() 22 WebFileUtilitiesImpl::WebFileUtilitiesImpl()
22 : sandbox_enabled_(true) { 23 : sandbox_enabled_(true) {
23 } 24 }
24 25
25 WebFileUtilitiesImpl::~WebFileUtilitiesImpl() { 26 WebFileUtilitiesImpl::~WebFileUtilitiesImpl() {
26 } 27 }
27 28
28 bool WebFileUtilitiesImpl::getFileInfo(const WebString& path, 29 bool WebFileUtilitiesImpl::getFileInfo(const WebString& path,
29 blink::WebFileInfo& web_file_info) { 30 blink::WebFileInfo& web_file_info) {
30 if (sandbox_enabled_) { 31 if (sandbox_enabled_) {
31 NOTREACHED(); 32 NOTREACHED();
32 return false; 33 return false;
33 } 34 }
34 base::File::Info file_info; 35 base::File::Info file_info;
35 if (!base::GetFileInfo(base::FilePath::FromUTF16Unsafe(path), 36 if (!base::GetFileInfo(blink::WebStringToFilePath(path),
36 reinterpret_cast<base::File::Info*>(&file_info))) 37 reinterpret_cast<base::File::Info*>(&file_info)))
37 return false; 38 return false;
38 39
39 FileInfoToWebFileInfo(file_info, &web_file_info); 40 FileInfoToWebFileInfo(file_info, &web_file_info);
40 web_file_info.platformPath = path; 41 web_file_info.platformPath = path;
41 return true; 42 return true;
42 } 43 }
43 44
44 WebString WebFileUtilitiesImpl::directoryName(const WebString& path) { 45 WebString WebFileUtilitiesImpl::directoryName(const WebString& path) {
45 return base::FilePath::FromUTF16Unsafe(path).DirName().AsUTF16Unsafe(); 46 return blink::WebStringToFilePath(path).DirName().AsUTF16Unsafe();
46 } 47 }
47 48
48 WebString WebFileUtilitiesImpl::baseName(const WebString& path) { 49 WebString WebFileUtilitiesImpl::baseName(const WebString& path) {
49 return base::FilePath::FromUTF16Unsafe(path).BaseName().AsUTF16Unsafe(); 50 return blink::WebStringToFilePath(path).BaseName().AsUTF16Unsafe();
50 } 51 }
51 52
52 blink::WebURL WebFileUtilitiesImpl::filePathToURL(const WebString& path) { 53 blink::WebURL WebFileUtilitiesImpl::filePathToURL(const WebString& path) {
53 return net::FilePathToFileURL(base::FilePath::FromUTF16Unsafe(path)); 54 return net::FilePathToFileURL(blink::WebStringToFilePath(path));
54 } 55 }
55 56
56 } // namespace content 57 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webblobregistry_impl.cc ('k') | content/renderer/drop_data_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698