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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.cc
diff --git a/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.cc b/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ce9f326d4216df5c4a01a46b7612816fae77b205
--- /dev/null
+++ b/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.cc
@@ -0,0 +1,51 @@
+// 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_documents_provider_util.h"
+
+#include <vector>
+
+#include "base/strings/string_util.h"
+#include "storage/browser/fileapi/file_system_url.h"
+
+namespace arc {
+
+namespace {
+
+static const base::FilePath::CharType kSpecialDirectory[] =
+ FILE_PATH_LITERAL("special");
+
+} // namespace
+
+const char kDocumentsProviderMountPointName[] = "arc-documents-provider";
+const base::FilePath::CharType kDocumentsProviderMountPointPath[] =
+ "/special/arc-documents-provider";
+
+bool ParseDocumentsProviderUrl(const storage::FileSystemURL& url,
+ std::string* authority,
+ std::string* root_document_id,
+ base::FilePath* path) {
+ if (url.type() != storage::kFileSystemTypeArcDocumentsProvider)
+ return false;
+
+ // Filesystem URL format for documents provider is:
+ // /special/arc-documents-provider/<authority>/<root_doc_id>/<relative_path>
+ using Components = std::vector<base::FilePath::StringType>;
+ Components components;
+ url.path().GetComponents(&components);
+ if (components.size() < 5 || components[0] != FILE_PATH_LITERAL("/") ||
+ components[1] != kSpecialDirectory ||
+ components[2] != kDocumentsProviderMountPointName) {
+ return false;
+ }
+
+ *authority = components[3];
+ *root_document_id = components[4];
+ *path = base::FilePath::FromUTF8Unsafe(base::JoinString(
+ 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.
+ DCHECK(!path->IsAbsolute());
+ return true;
+}
+
+} // namespace arc

Powered by Google App Engine
This is Rietveld 408576698