1 // Copyright (c) 2014 Intel Corporation. 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 "xwalk/experimental/native_file_system/virtual_root_provider.h"
10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h"
13 bool VirtualRootProvider::testing_enabled_ = false;
15 VirtualRootProvider::VirtualRootProvider() {
16 if (!virtual_root_map_.empty())
19 if (testing_enabled_) {
20 base::GetTempDir(&home_path_);
22 home_path_ = base::GetHomeDir();
25 // TODO(shawngao5): Hard code virtual root mapping for linux here.
26 // In future, it should be removed by parsing xdg configure file for
28 virtual_root_map_["DESKTOP"] = home_path_.Append("Desktop");
29 virtual_root_map_["DOWNLOADS"] = home_path_.Append("Downloads");
30 virtual_root_map_["DOCUMENTS"] = home_path_.Append("Documents");
31 virtual_root_map_["MUSIC"] = home_path_.Append("Music");
32 virtual_root_map_["PICTURES"] = home_path_.Append("Pictures");
33 virtual_root_map_["VIDEOS"] = home_path_.Append("Videos");
36 void VirtualRootProvider::SetTesting(bool testing_enabled) {
37 testing_enabled_ = testing_enabled;
38 base::FilePath tmp_path;
39 base::GetTempDir(&tmp_path);
40 base::FilePath doc_path = tmp_path.Append("Documents");
41 if (!DirectoryExists(doc_path)) {
42 CreateDirectory(doc_path);