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

Unified Diff: chrome/browser/chromeos/fileapi/external_file_url_util.cc

Issue 580023003: Rename the drive: scheme with the externalfile: scheme. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/fileapi/external_file_url_util.cc
diff --git a/chrome/browser/chromeos/fileapi/external_file_url_util.cc b/chrome/browser/chromeos/fileapi/external_file_url_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9ec10794c8add0f070f7eff12fb3aab631142d29
--- /dev/null
+++ b/chrome/browser/chromeos/fileapi/external_file_url_util.cc
@@ -0,0 +1,49 @@
+// Copyright 2014 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/fileapi/external_file_url_util.h"
+
+#include <string>
+
+#include "base/strings/stringprintf.h"
+#include "chrome/browser/chromeos/drive/file_system_util.h"
+#include "chrome/common/url_constants.h"
+#include "content/public/browser/browser_thread.h"
+#include "net/base/escape.h"
+
+using content::BrowserThread;
+
+namespace chromeos {
+
+GURL FilePathToExternalFileURL(const base::FilePath& path) {
+ std::string url(base::StringPrintf(
+ "%s:%s", chrome::kExternalFileScheme, path.AsUTF8Unsafe().c_str()));
+ return GURL(url);
+}
+
+base::FilePath ExternalFileURLToFilePath(const GURL& url) {
+ if (!url.is_valid() || url.scheme() != chrome::kExternalFileScheme)
+ return base::FilePath();
+ std::string path_string =
+ net::UnescapeURLComponent(url.GetContent(), net::UnescapeRule::NORMAL);
+ return base::FilePath::FromUTF8Unsafe(path_string);
+}
+
+void MaybeSetExternalFileURL(Profile* profile,
+ const base::FilePath& path,
+ GURL* url) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (!drive::util::IsUnderDriveMountPoint(path))
mtomasz 2014/09/22 01:58:48 I'm wondering if we should have a dependency to dr
hirono 2014/09/22 03:32:19 I'll update the function at the next patch, but I'
mtomasz 2014/09/22 05:03:31 Got it.
+ return;
+
+ drive::FileSystemInterface* file_system =
+ drive::util::GetFileSystemByProfile(profile);
+ if (!file_system)
+ return;
+
+ *url = FilePathToExternalFileURL(drive::util::ExtractDrivePath(path));
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698