| Index: chrome/browser/chromeos/arc/fileapi/arc_content_file_system_url_util.cc
|
| diff --git a/chrome/browser/chromeos/arc/fileapi/arc_content_file_system_url_util.cc b/chrome/browser/chromeos/arc/fileapi/arc_content_file_system_url_util.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e125742638c40e02e77e81c52a8977105ef7c6be
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/arc/fileapi/arc_content_file_system_url_util.cc
|
| @@ -0,0 +1,42 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_url_util.h"
|
| +
|
| +#include "base/files/file_path.h"
|
| +#include "chrome/browser/chromeos/fileapi/external_file_url_util.h"
|
| +#include "net/base/escape.h"
|
| +
|
| +namespace arc {
|
| +
|
| +namespace {
|
| +
|
| +const char kMountPointName[] = "arc-content";
|
| +
|
| +} // namespace
|
| +
|
| +GURL ArcUrlToExternalFileUrl(const GURL& arc_url) {
|
| + // Return "externalfile:arc-content/<|arc_url| escaped>".
|
| + base::FilePath virtual_path =
|
| + base::FilePath::FromUTF8Unsafe(kMountPointName)
|
| + .Append(base::FilePath::FromUTF8Unsafe(
|
| + net::EscapeQueryParamValue(arc_url.spec(), false)));
|
| + return chromeos::VirtualPathToExternalFileURL(virtual_path);
|
| +}
|
| +
|
| +GURL ExternalFileUrlToArcUrl(const GURL& external_file_url) {
|
| + base::FilePath virtual_path =
|
| + chromeos::ExternalFileURLToVirtualPath(external_file_url);
|
| + base::FilePath path_after_root;
|
| + if (!base::FilePath::FromUTF8Unsafe(kMountPointName)
|
| + .AppendRelativePath(virtual_path, &path_after_root)) {
|
| + return GURL();
|
| + }
|
| + return GURL(net::UnescapeURLComponent(
|
| + path_after_root.AsUTF8Unsafe(),
|
| + net::UnescapeRule::SPACES | net::UnescapeRule::PATH_SEPARATORS |
|
| + net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS));
|
| +}
|
| +
|
| +} // namespace arc
|
|
|