Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4237)

Unified Diff: chrome/browser/chromeos/arc/fileapi/arc_content_file_system_url_util.cc

Issue 2437693002: arc: Add URL converter functions (Closed)
Patch Set: Anonymous namespace Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698