OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/glue/webfileutilities_impl.h" | 5 #include "webkit/glue/webfileutilities_impl.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "net/base/file_stream.h" | 10 #include "net/base/file_stream.h" |
11 #include "net/base/net_util.h" | 11 #include "net/base/net_util.h" |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileInfo.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
14 #include "webkit/glue/webkit_glue.h" | 15 #include "webkit/glue/webkit_glue.h" |
15 | 16 |
16 using WebKit::WebString; | 17 using WebKit::WebString; |
17 | 18 |
18 namespace webkit_glue { | 19 namespace webkit_glue { |
19 | 20 |
20 WebFileUtilitiesImpl::WebFileUtilitiesImpl() | 21 WebFileUtilitiesImpl::WebFileUtilitiesImpl() |
21 : sandbox_enabled_(true) { | 22 : sandbox_enabled_(true) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 NOTREACHED(); | 56 NOTREACHED(); |
56 return false; | 57 return false; |
57 } | 58 } |
58 base::PlatformFileInfo info; | 59 base::PlatformFileInfo info; |
59 if (!file_util::GetFileInfo(WebStringToFilePath(path), &info)) | 60 if (!file_util::GetFileInfo(WebStringToFilePath(path), &info)) |
60 return false; | 61 return false; |
61 result = info.last_modified.ToDoubleT(); | 62 result = info.last_modified.ToDoubleT(); |
62 return true; | 63 return true; |
63 } | 64 } |
64 | 65 |
| 66 bool WebFileUtilitiesImpl::getFileInfo(const WebString& path, |
| 67 WebKit::WebFileInfo& web_file_info) { |
| 68 if (sandbox_enabled_) { |
| 69 NOTREACHED(); |
| 70 return false; |
| 71 } |
| 72 base::PlatformFileInfo file_info; |
| 73 if (!file_util::GetFileInfo(WebStringToFilePath(path), &file_info)) |
| 74 return false; |
| 75 |
| 76 webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info); |
| 77 web_file_info.platformPath = path; |
| 78 return true; |
| 79 } |
| 80 |
65 WebString WebFileUtilitiesImpl::directoryName(const WebString& path) { | 81 WebString WebFileUtilitiesImpl::directoryName(const WebString& path) { |
66 FilePath file_path(WebStringToFilePathString(path)); | 82 FilePath file_path(WebStringToFilePathString(path)); |
67 return FilePathToWebString(file_path.DirName()); | 83 return FilePathToWebString(file_path.DirName()); |
68 } | 84 } |
69 | 85 |
70 WebString WebFileUtilitiesImpl::pathByAppendingComponent( | 86 WebString WebFileUtilitiesImpl::pathByAppendingComponent( |
71 const WebString& webkit_path, | 87 const WebString& webkit_path, |
72 const WebString& webkit_component) { | 88 const WebString& webkit_component) { |
73 FilePath path(WebStringToFilePathString(webkit_path)); | 89 FilePath path(WebStringToFilePathString(webkit_path)); |
74 FilePath component(WebStringToFilePathString(webkit_component)); | 90 FilePath component(WebStringToFilePathString(webkit_component)); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 int WebFileUtilitiesImpl::writeToFile(base::PlatformFile handle, | 165 int WebFileUtilitiesImpl::writeToFile(base::PlatformFile handle, |
150 const char* data, | 166 const char* data, |
151 int length) { | 167 int length) { |
152 if (handle == base::kInvalidPlatformFileValue || !data || length <= 0) | 168 if (handle == base::kInvalidPlatformFileValue || !data || length <= 0) |
153 return -1; | 169 return -1; |
154 net::FileStream file_stream(handle, base::PLATFORM_FILE_WRITE, NULL); | 170 net::FileStream file_stream(handle, base::PLATFORM_FILE_WRITE, NULL); |
155 return file_stream.WriteSync(data, length); | 171 return file_stream.WriteSync(data, length); |
156 } | 172 } |
157 | 173 |
158 } // namespace webkit_glue | 174 } // namespace webkit_glue |
OLD | NEW |