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

Unified Diff: chrome/browser/chromeos/drive/drive_file_system_util.cc

Issue 13401003: chromeos: Replace resource ID in drive URL with path (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unneeded include Created 7 years, 8 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/drive/drive_file_system_util.cc
diff --git a/chrome/browser/chromeos/drive/drive_file_system_util.cc b/chrome/browser/chromeos/drive/drive_file_system_util.cc
index 107525bf7665863f7d3ffbc311d7c89b19a1ad9a..3cb24d4c19dba396f1bb93162e2abf42eed84d71 100644
--- a/chrome/browser/chromeos/drive/drive_file_system_util.cc
+++ b/chrome/browser/chromeos/drive/drive_file_system_util.cc
@@ -115,18 +115,16 @@ void OpenEditURLUIThread(Profile* profile, const GURL& edit_url) {
void OnGetEntryInfoByResourceId(Profile* profile,
const std::string& resource_id,
DriveFileError error,
- const base::FilePath& /* drive_file_path */,
+ const base::FilePath& drive_file_path,
scoped_ptr<DriveEntryProto> entry_proto) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (error != DRIVE_FILE_OK)
return;
- DCHECK(entry_proto.get());
- const std::string& base_name = entry_proto->base_name();
- const GURL edit_url = GetFileResourceUrl(resource_id, base_name);
+ const GURL edit_url = FilePathToDriveURL(drive_file_path);
OpenEditURLUIThread(profile, edit_url);
- DVLOG(1) << "OnFindEntryByResourceId " << edit_url;
+ DVLOG(1) << "OnGetEntryInfoByResourceId " << edit_url;
}
} // namespace
@@ -179,15 +177,21 @@ const base::FilePath& GetDriveMyDriveMountPointPath() {
return drive_mydrive_mount_path;
}
-GURL GetFileResourceUrl(const std::string& resource_id,
- const std::string& file_name) {
- std::string url(base::StringPrintf(
- "%s:%s",
- chrome::kDriveScheme,
- net::EscapePath(resource_id).c_str()));
+GURL FilePathToDriveURL(const base::FilePath& path) {
+ std::string url(base::StringPrintf("%s:%s",
+ chrome::kDriveScheme,
+ path.AsUTF8Unsafe().c_str()));
return GURL(url);
}
+base::FilePath DriveURLToFilePath(const GURL& url) {
+ if (!url.is_valid() || url.scheme() != chrome::kDriveScheme)
+ return base::FilePath();
+ std::string path_string = net::UnescapeURLComponent(
+ url.path(), net::UnescapeRule::NORMAL);
+ return base::FilePath::FromUTF8Unsafe(path_string);
+}
+
void ModifyDriveFileResourceUrl(Profile* profile,
const base::FilePath& drive_cache_path,
GURL* url) {

Powered by Google App Engine
This is Rietveld 408576698