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

Side by Side 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 unified diff | Download patch
OLDNEW
(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 namespace {
14
15 const char kMountPointName[] = "arc-content";
16
17 } // namespace
18
19 GURL ArcUrlToExternalFileUrl(const GURL& arc_url) {
20 // Return "externalfile:arc-content/<|arc_url| escaped>".
21 base::FilePath virtual_path =
22 base::FilePath::FromUTF8Unsafe(kMountPointName)
23 .Append(base::FilePath::FromUTF8Unsafe(
24 net::EscapeQueryParamValue(arc_url.spec(), false)));
25 return chromeos::VirtualPathToExternalFileURL(virtual_path);
26 }
27
28 GURL ExternalFileUrlToArcUrl(const GURL& external_file_url) {
29 base::FilePath virtual_path =
30 chromeos::ExternalFileURLToVirtualPath(external_file_url);
31 base::FilePath path_after_root;
32 if (!base::FilePath::FromUTF8Unsafe(kMountPointName)
33 .AppendRelativePath(virtual_path, &path_after_root)) {
34 return GURL();
35 }
36 return GURL(net::UnescapeURLComponent(
37 path_after_root.AsUTF8Unsafe(),
38 net::UnescapeRule::SPACES | net::UnescapeRule::PATH_SEPARATORS |
39 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS));
40 }
41
42 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698