Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / content / child / webfileutilities_impl.cc
blob72ddc73d9d6d7ae808dc1b7bb530f3c3fb00483e
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.
5 #include "content/child/webfileutilities_impl.h"
7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h"
9 #include "base/logging.h"
10 #include "content/child/file_info_util.h"
11 #include "net/base/file_stream.h"
12 #include "net/base/filename_util.h"
13 #include "third_party/WebKit/public/platform/WebFileInfo.h"
14 #include "third_party/WebKit/public/platform/WebString.h"
15 #include "third_party/WebKit/public/platform/WebURL.h"
17 using blink::WebString;
19 namespace content {
21 WebFileUtilitiesImpl::WebFileUtilitiesImpl()
22 : sandbox_enabled_(true) {
25 WebFileUtilitiesImpl::~WebFileUtilitiesImpl() {
28 bool WebFileUtilitiesImpl::getFileInfo(const WebString& path,
29 blink::WebFileInfo& web_file_info) {
30 if (sandbox_enabled_) {
31 NOTREACHED();
32 return false;
34 base::File::Info file_info;
35 if (!base::GetFileInfo(base::FilePath::FromUTF16Unsafe(path),
36 reinterpret_cast<base::File::Info*>(&file_info)))
37 return false;
39 FileInfoToWebFileInfo(file_info, &web_file_info);
40 web_file_info.platformPath = path;
41 return true;
44 WebString WebFileUtilitiesImpl::directoryName(const WebString& path) {
45 return base::FilePath::FromUTF16Unsafe(path).DirName().AsUTF16Unsafe();
48 WebString WebFileUtilitiesImpl::baseName(const WebString& path) {
49 return base::FilePath::FromUTF16Unsafe(path).BaseName().AsUTF16Unsafe();
52 blink::WebURL WebFileUtilitiesImpl::filePathToURL(const WebString& path) {
53 return net::FilePathToFileURL(base::FilePath::FromUTF16Unsafe(path));
56 } // namespace content