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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 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/fileapi/external_file_url_util.h"
6
7 #include <string>
8
9 #include "base/strings/stringprintf.h"
10 #include "chrome/browser/chromeos/drive/file_system_util.h"
11 #include "chrome/common/url_constants.h"
12 #include "content/public/browser/browser_thread.h"
13 #include "net/base/escape.h"
14
15 using content::BrowserThread;
16
17 namespace chromeos {
18
19 GURL FilePathToExternalFileURL(const base::FilePath& path) {
20 std::string url(base::StringPrintf(
21 "%s:%s", chrome::kExternalFileScheme, path.AsUTF8Unsafe().c_str()));
22 return GURL(url);
23 }
24
25 base::FilePath ExternalFileURLToFilePath(const GURL& url) {
26 if (!url.is_valid() || url.scheme() != chrome::kExternalFileScheme)
27 return base::FilePath();
28 std::string path_string =
29 net::UnescapeURLComponent(url.GetContent(), net::UnescapeRule::NORMAL);
30 return base::FilePath::FromUTF8Unsafe(path_string);
31 }
32
33 void MaybeSetExternalFileURL(Profile* profile,
34 const base::FilePath& path,
35 GURL* url) {
36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
37
38 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.
39 return;
40
41 drive::FileSystemInterface* file_system =
42 drive::util::GetFileSystemByProfile(profile);
43 if (!file_system)
44 return;
45
46 *url = FilePathToExternalFileURL(drive::util::ExtractDrivePath(path));
47 }
48
49 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698