Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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. | |
| 4 | |
| 5 #include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_url_util.h " | |
| 6 | |
| 7 #include "base/files/file_path.h" | |
| 8 #include "chrome/browser/chromeos/fileapi/external_file_url_util.h" | |
| 9 #include "net/base/escape.h" | |
| 10 | |
| 11 namespace arc { | |
| 12 | |
| 13 const char kMountPointName[] = "arc-content"; | |
|
mtomasz
2016/10/20 08:55:05
nit: Can this be constexpr and/or anonymous namesp
hashimoto
2016/10/20 09:26:45
Later this will be used to add a mount to chromeos
| |
| 14 | |
| 15 GURL ArcUrlToExternalFileUrl(const GURL& arc_url) { | |
| 16 // Return "externalfile:arc-content/<|arc_url| escaped>". | |
| 17 base::FilePath virtual_path = | |
| 18 base::FilePath::FromUTF8Unsafe(kMountPointName) | |
| 19 .Append(base::FilePath::FromUTF8Unsafe( | |
| 20 net::EscapeQueryParamValue(arc_url.spec(), false))); | |
| 21 return chromeos::VirtualPathToExternalFileURL(virtual_path); | |
| 22 } | |
| 23 | |
| 24 GURL ExternalFileUrlToArcUrl(const GURL& external_file_url) { | |
| 25 base::FilePath virtual_path = | |
| 26 chromeos::ExternalFileURLToVirtualPath(external_file_url); | |
| 27 base::FilePath path_after_root; | |
| 28 if (!base::FilePath::FromUTF8Unsafe(kMountPointName) | |
| 29 .AppendRelativePath(virtual_path, &path_after_root)) { | |
| 30 return GURL(); | |
| 31 } | |
| 32 return GURL(net::UnescapeURLComponent( | |
| 33 path_after_root.AsUTF8Unsafe(), | |
| 34 net::UnescapeRule::SPACES | net::UnescapeRule::PATH_SEPARATORS | | |
| 35 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS)); | |
| 36 } | |
| 37 | |
| 38 } // namespace arc | |
| OLD | NEW |