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_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.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/public/platform/WebFileInfo.h" | 12 #include "third_party/WebKit/public/platform/WebFileInfo.h" |
13 #include "third_party/WebKit/public/platform/WebString.h" | 13 #include "third_party/WebKit/public/platform/WebString.h" |
14 #include "third_party/WebKit/public/platform/WebURL.h" | 14 #include "third_party/WebKit/public/platform/WebURL.h" |
15 #include "webkit/glue/webkit_glue.h" | 15 #include "webkit/glue/webkit_glue.h" |
16 | 16 |
17 using WebKit::WebString; | 17 using blink::WebString; |
18 | 18 |
19 namespace webkit_glue { | 19 namespace webkit_glue { |
20 | 20 |
21 WebFileUtilitiesImpl::WebFileUtilitiesImpl() | 21 WebFileUtilitiesImpl::WebFileUtilitiesImpl() |
22 : sandbox_enabled_(true) { | 22 : sandbox_enabled_(true) { |
23 } | 23 } |
24 | 24 |
25 WebFileUtilitiesImpl::~WebFileUtilitiesImpl() { | 25 WebFileUtilitiesImpl::~WebFileUtilitiesImpl() { |
26 } | 26 } |
27 | 27 |
28 bool WebFileUtilitiesImpl::getFileInfo(const WebString& path, | 28 bool WebFileUtilitiesImpl::getFileInfo(const WebString& path, |
29 WebKit::WebFileInfo& web_file_info) { | 29 blink::WebFileInfo& web_file_info) { |
30 if (sandbox_enabled_) { | 30 if (sandbox_enabled_) { |
31 NOTREACHED(); | 31 NOTREACHED(); |
32 return false; | 32 return false; |
33 } | 33 } |
34 base::PlatformFileInfo file_info; | 34 base::PlatformFileInfo file_info; |
35 if (!file_util::GetFileInfo(base::FilePath::FromUTF16Unsafe(path), | 35 if (!file_util::GetFileInfo(base::FilePath::FromUTF16Unsafe(path), |
36 &file_info)) | 36 &file_info)) |
37 return false; | 37 return false; |
38 | 38 |
39 webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info); | 39 webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info); |
40 web_file_info.platformPath = path; | 40 web_file_info.platformPath = path; |
41 return true; | 41 return true; |
42 } | 42 } |
43 | 43 |
44 WebString WebFileUtilitiesImpl::directoryName(const WebString& path) { | 44 WebString WebFileUtilitiesImpl::directoryName(const WebString& path) { |
45 return base::FilePath::FromUTF16Unsafe(path).DirName().AsUTF16Unsafe(); | 45 return base::FilePath::FromUTF16Unsafe(path).DirName().AsUTF16Unsafe(); |
46 } | 46 } |
47 | 47 |
48 WebString WebFileUtilitiesImpl::baseName(const WebString& path) { | 48 WebString WebFileUtilitiesImpl::baseName(const WebString& path) { |
49 return base::FilePath::FromUTF16Unsafe(path).BaseName().AsUTF16Unsafe(); | 49 return base::FilePath::FromUTF16Unsafe(path).BaseName().AsUTF16Unsafe(); |
50 } | 50 } |
51 | 51 |
52 WebKit::WebURL WebFileUtilitiesImpl::filePathToURL(const WebString& path) { | 52 blink::WebURL WebFileUtilitiesImpl::filePathToURL(const WebString& path) { |
53 return net::FilePathToFileURL(base::FilePath::FromUTF16Unsafe(path)); | 53 return net::FilePathToFileURL(base::FilePath::FromUTF16Unsafe(path)); |
54 } | 54 } |
55 | 55 |
56 base::PlatformFile WebFileUtilitiesImpl::openFile(const WebString& path, | 56 base::PlatformFile WebFileUtilitiesImpl::openFile(const WebString& path, |
57 int mode) { | 57 int mode) { |
58 if (sandbox_enabled_) { | 58 if (sandbox_enabled_) { |
59 NOTREACHED(); | 59 NOTREACHED(); |
60 return base::kInvalidPlatformFileValue; | 60 return base::kInvalidPlatformFileValue; |
61 } | 61 } |
62 // mode==0 (read-only) is the only supported mode. | 62 // mode==0 (read-only) is the only supported mode. |
(...skipping 14 matching lines...) Expand all Loading... |
77 | 77 |
78 int WebFileUtilitiesImpl::readFromFile(base::PlatformFile handle, | 78 int WebFileUtilitiesImpl::readFromFile(base::PlatformFile handle, |
79 char* data, | 79 char* data, |
80 int length) { | 80 int length) { |
81 if (handle == base::kInvalidPlatformFileValue || !data || length <= 0) | 81 if (handle == base::kInvalidPlatformFileValue || !data || length <= 0) |
82 return -1; | 82 return -1; |
83 return base::ReadPlatformFileCurPosNoBestEffort(handle, data, length); | 83 return base::ReadPlatformFileCurPosNoBestEffort(handle, data, length); |
84 } | 84 } |
85 | 85 |
86 } // namespace webkit_glue | 86 } // namespace webkit_glue |
OLD | NEW |