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

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

Issue 2572683004: mediaview: Introduce ArcDocumentsProviderRoot. (Closed)
Patch Set: Fix failing unit tests. 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
(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_documents_provider_util.h"
6
7 #include <vector>
8
9 #include "base/strings/string_util.h"
10 #include "storage/browser/fileapi/file_system_url.h"
11
12 namespace arc {
13
14 namespace {
15
16 const base::FilePath::CharType kSpecialDirectory[] =
Luis Héctor Chávez 2016/12/15 21:26:10 nit: can this be constexpr?
Shuhei Takahashi 2016/12/16 03:21:12 Of course.
17 FILE_PATH_LITERAL("special");
18
19 } // namespace
20
21 const char kDocumentsProviderMountPointName[] = "arc-documents-provider";
22 const base::FilePath::CharType kDocumentsProviderMountPointPath[] =
23 "/special/arc-documents-provider";
24
25 bool ParseDocumentsProviderUrl(const storage::FileSystemURL& url,
26 std::string* authority,
27 std::string* root_document_id,
28 base::FilePath* path) {
29 if (url.type() != storage::kFileSystemTypeArcDocumentsProvider)
30 return false;
31
32 // Filesystem URL format for documents provider is:
33 // /special/arc-documents-provider/<authority>/<root_doc_id>/<relative_path>
34 std::vector<base::FilePath::StringType> components;
35 url.path().GetComponents(&components);
36 if (components.size() < 5 || components[0] != FILE_PATH_LITERAL("/") ||
37 components[1] != kSpecialDirectory ||
38 components[2] != kDocumentsProviderMountPointName) {
39 return false;
40 }
41
42 *authority = components[3];
43 *root_document_id = components[4];
44
45 base::FilePath url_path_stripped = url.path().StripTrailingSeparators();
46 base::FilePath root_path = base::FilePath(kDocumentsProviderMountPointPath)
47 .Append(*authority)
48 .Append(*root_document_id);
49 // Special case: AppendRelativePath() fails for identical paths.
50 if (url_path_stripped == root_path) {
51 path->clear();
52 } else {
53 bool success = root_path.AppendRelativePath(url_path_stripped, path);
54 DCHECK(success);
55 }
56 return true;
57 }
58
59 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698