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

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

Issue 2572683004: mediaview: Introduce ArcDocumentsProviderRoot. (Closed)
Patch Set: Addressed lhchavez's comments. 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 static const base::FilePath::CharType kSpecialDirectory[] =
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 using Components = std::vector<base::FilePath::StringType>;
35 Components components;
36 url.path().GetComponents(&components);
37 if (components.size() < 5 || components[0] != FILE_PATH_LITERAL("/") ||
38 components[1] != kSpecialDirectory ||
39 components[2] != kDocumentsProviderMountPointName) {
40 return false;
41 }
42
43 *authority = components[3];
44 *root_document_id = components[4];
45 *path = base::FilePath::FromUTF8Unsafe(base::JoinString(
46 Components(components.begin() + 5, components.end()), "/"));
hashimoto 2016/12/15 03:53:22 How about using FilePath::AppendRelativePath?
Shuhei Takahashi 2016/12/15 05:21:53 Thanks, that's what I wanted.
47 DCHECK(!path->IsAbsolute());
48 return true;
49 }
50
51 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698