| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/drive/file_system_util.h" | 5 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 std::string url(base::StringPrintf("%s:%s", | 205 std::string url(base::StringPrintf("%s:%s", |
| 206 chrome::kDriveScheme, | 206 chrome::kDriveScheme, |
| 207 path.AsUTF8Unsafe().c_str())); | 207 path.AsUTF8Unsafe().c_str())); |
| 208 return GURL(url); | 208 return GURL(url); |
| 209 } | 209 } |
| 210 | 210 |
| 211 base::FilePath DriveURLToFilePath(const GURL& url) { | 211 base::FilePath DriveURLToFilePath(const GURL& url) { |
| 212 if (!url.is_valid() || url.scheme() != chrome::kDriveScheme) | 212 if (!url.is_valid() || url.scheme() != chrome::kDriveScheme) |
| 213 return base::FilePath(); | 213 return base::FilePath(); |
| 214 std::string path_string = net::UnescapeURLComponent( | 214 std::string path_string = net::UnescapeURLComponent( |
| 215 url.path(), net::UnescapeRule::NORMAL); | 215 url.Content(), net::UnescapeRule::NORMAL); |
| 216 return base::FilePath::FromUTF8Unsafe(path_string); | 216 return base::FilePath::FromUTF8Unsafe(path_string); |
| 217 } | 217 } |
| 218 | 218 |
| 219 void MaybeSetDriveURL(Profile* profile, const base::FilePath& path, GURL* url) { | 219 void MaybeSetDriveURL(Profile* profile, const base::FilePath& path, GURL* url) { |
| 220 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 220 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 221 | 221 |
| 222 if (!IsUnderDriveMountPoint(path)) | 222 if (!IsUnderDriveMountPoint(path)) |
| 223 return; | 223 return; |
| 224 | 224 |
| 225 FileSystemInterface* file_system = GetFileSystemByProfile(profile); | 225 FileSystemInterface* file_system = GetFileSystemByProfile(profile); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 267 |
| 268 base::FilePath drive_path = GetDriveGrandRootPath(); | 268 base::FilePath drive_path = GetDriveGrandRootPath(); |
| 269 GetDriveMountPointPath().AppendRelativePath(path, &drive_path); | 269 GetDriveMountPointPath().AppendRelativePath(path, &drive_path); |
| 270 return drive_path; | 270 return drive_path; |
| 271 } | 271 } |
| 272 | 272 |
| 273 base::FilePath ExtractDrivePathFromFileSystemUrl( | 273 base::FilePath ExtractDrivePathFromFileSystemUrl( |
| 274 const fileapi::FileSystemURL& url) { | 274 const fileapi::FileSystemURL& url) { |
| 275 if (!url.is_valid() || url.type() != fileapi::kFileSystemTypeDrive) | 275 if (!url.is_valid() || url.type() != fileapi::kFileSystemTypeDrive) |
| 276 return base::FilePath(); | 276 return base::FilePath(); |
| 277 return ExtractDrivePath(url.path()); | 277 return ExtractDrivePath(url.Content()); |
| 278 } | 278 } |
| 279 | 279 |
| 280 base::FilePath GetCacheRootPath(Profile* profile) { | 280 base::FilePath GetCacheRootPath(Profile* profile) { |
| 281 base::FilePath cache_base_path; | 281 base::FilePath cache_base_path; |
| 282 chrome::GetUserCacheDirectory(profile->GetPath(), &cache_base_path); | 282 chrome::GetUserCacheDirectory(profile->GetPath(), &cache_base_path); |
| 283 base::FilePath cache_root_path = | 283 base::FilePath cache_root_path = |
| 284 cache_base_path.Append(chromeos::kDriveCacheDirname); | 284 cache_base_path.Append(chromeos::kDriveCacheDirname); |
| 285 return cache_root_path.Append(kFileCacheVersionDir); | 285 return cache_root_path.Append(kFileCacheVersionDir); |
| 286 } | 286 } |
| 287 | 287 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 // Disable Drive if preference is set. This can happen with commandline flag | 454 // Disable Drive if preference is set. This can happen with commandline flag |
| 455 // --disable-drive or enterprise policy, or with user settings. | 455 // --disable-drive or enterprise policy, or with user settings. |
| 456 if (profile->GetPrefs()->GetBoolean(prefs::kDisableDrive)) | 456 if (profile->GetPrefs()->GetBoolean(prefs::kDisableDrive)) |
| 457 return false; | 457 return false; |
| 458 | 458 |
| 459 return true; | 459 return true; |
| 460 } | 460 } |
| 461 | 461 |
| 462 } // namespace util | 462 } // namespace util |
| 463 } // namespace drive | 463 } // namespace drive |
| OLD | NEW |