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

Side by Side Diff: chrome/browser/chromeos/arc/fileapi/arc_content_file_system_url_util.cc

Issue 2589643002: mediaview: Register ARC documents provider file system. (Closed)
Patch Set: . Created 4 years 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_url_util.h " 5 #include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_url_util.h "
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "chrome/browser/chromeos/fileapi/external_file_url_util.h" 8 #include "chrome/browser/chromeos/fileapi/external_file_url_util.h"
9 #include "net/base/escape.h" 9 #include "net/base/escape.h"
10 #include "storage/browser/fileapi/file_system_url.h" 10 #include "storage/browser/fileapi/file_system_url.h"
11 11
12 namespace arc { 12 namespace arc {
13 13
14 const char kMountPointName[] = "arc-content"; 14 const char kContentFileSystemMountPointName[] = "arc-content";
15 15
16 const base::FilePath::CharType kMountPointPath[] = 16 const base::FilePath::CharType kContentFileSystemMountPointPath[] =
17 FILE_PATH_LITERAL("/special/arc-content"); 17 FILE_PATH_LITERAL("/special/arc-content");
18 18
19 std::string EscapeArcUrl(const GURL& arc_url) { 19 std::string EscapeArcUrl(const GURL& arc_url) {
20 return net::EscapeQueryParamValue(arc_url.spec(), false); 20 return net::EscapeQueryParamValue(arc_url.spec(), false);
21 } 21 }
22 22
23 GURL UnescapeArcUrl(const std::string& escaped_arc_url) { 23 GURL UnescapeArcUrl(const std::string& escaped_arc_url) {
24 return GURL(net::UnescapeURLComponent( 24 return GURL(net::UnescapeURLComponent(
25 escaped_arc_url, 25 escaped_arc_url,
26 net::UnescapeRule::SPACES | net::UnescapeRule::PATH_SEPARATORS | 26 net::UnescapeRule::SPACES | net::UnescapeRule::PATH_SEPARATORS |
27 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS)); 27 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS));
28 } 28 }
29 29
30 GURL ArcUrlToExternalFileUrl(const GURL& arc_url) { 30 GURL ArcUrlToExternalFileUrl(const GURL& arc_url) {
31 // Return "externalfile:arc-content/<|arc_url| escaped>". 31 // Return "externalfile:arc-content/<|arc_url| escaped>".
32 base::FilePath virtual_path = 32 base::FilePath virtual_path =
33 base::FilePath::FromUTF8Unsafe(kMountPointName) 33 base::FilePath::FromUTF8Unsafe(kContentFileSystemMountPointName)
34 .Append(base::FilePath::FromUTF8Unsafe(EscapeArcUrl(arc_url))); 34 .Append(base::FilePath::FromUTF8Unsafe(EscapeArcUrl(arc_url)));
35 return chromeos::VirtualPathToExternalFileURL(virtual_path); 35 return chromeos::VirtualPathToExternalFileURL(virtual_path);
36 } 36 }
37 37
38 GURL ExternalFileUrlToArcUrl(const GURL& external_file_url) { 38 GURL ExternalFileUrlToArcUrl(const GURL& external_file_url) {
39 base::FilePath virtual_path = 39 base::FilePath virtual_path =
40 chromeos::ExternalFileURLToVirtualPath(external_file_url); 40 chromeos::ExternalFileURLToVirtualPath(external_file_url);
41 base::FilePath path_after_root; 41 base::FilePath path_after_root;
42 if (!base::FilePath::FromUTF8Unsafe(kMountPointName) 42 if (!base::FilePath::FromUTF8Unsafe(kContentFileSystemMountPointName)
43 .AppendRelativePath(virtual_path, &path_after_root)) { 43 .AppendRelativePath(virtual_path, &path_after_root)) {
44 return GURL(); 44 return GURL();
45 } 45 }
46 return UnescapeArcUrl(path_after_root.AsUTF8Unsafe()); 46 return UnescapeArcUrl(path_after_root.AsUTF8Unsafe());
47 } 47 }
48 48
49 GURL FileSystemUrlToArcUrl(const storage::FileSystemURL& url) { 49 GURL FileSystemUrlToArcUrl(const storage::FileSystemURL& url) {
50 base::FilePath path_after_mount_point; 50 base::FilePath path_after_mount_point;
51 if (!base::FilePath(kMountPointPath) 51 if (!base::FilePath(kContentFileSystemMountPointPath)
52 .AppendRelativePath(url.path(), &path_after_mount_point)) { 52 .AppendRelativePath(url.path(), &path_after_mount_point)) {
53 return GURL(); 53 return GURL();
54 } 54 }
55 return UnescapeArcUrl(path_after_mount_point.AsUTF8Unsafe()); 55 return UnescapeArcUrl(path_after_mount_point.AsUTF8Unsafe());
56 } 56 }
57 57
58 } // namespace arc 58 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698