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/drive_file_system_util.h" | 5 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 *url = GURL(); | 225 *url = GURL(); |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 bool IsUnderDriveMountPoint(const base::FilePath& path) { | 229 bool IsUnderDriveMountPoint(const base::FilePath& path) { |
230 return GetDriveMountPointPath() == path || | 230 return GetDriveMountPointPath() == path || |
231 GetDriveMountPointPath().IsParent(path); | 231 GetDriveMountPointPath().IsParent(path); |
232 } | 232 } |
233 | 233 |
234 bool NeedsNamespaceMigration(const base::FilePath& path) { | 234 bool NeedsNamespaceMigration(const base::FilePath& path) { |
235 return false; | 235 // Before migration, "My Drive" which was represented as "drive. |
236 // TODO(haruki): Update this along with http://crbug.com/174233. | 236 // The user might use some path pointing a directory in "My Drive". |
237 // return IsUnderDriveMountPoint(path) && | 237 // e.g. "drive/downloads_dir" |
238 // !(GetDriveMyDriveMountPointPath() == path || | 238 // We changed the path for the "My Drive" to "drive/root", hence the user pref |
239 // GetDriveMyDriveMountPointPath().IsParent(path)); | 239 // pointing to the old path needs update to the new path. |
| 240 // e.g. "drive/root/downloads_dir" |
| 241 // If |path| already points to some directory in "drive/root", there's no need |
| 242 // to update it. |
| 243 return IsUnderDriveMountPoint(path) && |
| 244 !(GetDriveMyDriveMountPointPath() == path || |
| 245 GetDriveMyDriveMountPointPath().IsParent(path)); |
240 } | 246 } |
241 | 247 |
242 base::FilePath ConvertToMyDriveNamespace(const base::FilePath& path) { | 248 base::FilePath ConvertToMyDriveNamespace(const base::FilePath& path) { |
243 // Double check the path. | 249 DCHECK(NeedsNamespaceMigration(path)); |
244 // TODO(haruki): Update this with DCHECK(NeedsNamespaceMigration(path)). | |
245 DCHECK(IsUnderDriveMountPoint(path) && | |
246 !(GetDriveMyDriveMountPointPath() == path || | |
247 GetDriveMyDriveMountPointPath().IsParent(path))); | |
248 | 250 |
249 // Need to migrate "/special/drive(.*)" to "/special/drive/root(.*)". | 251 // Need to migrate "/special/drive(.*)" to "/special/drive/root(.*)". |
250 // Append the relative path from "/special/drive". | 252 // Append the relative path from "/special/drive". |
251 base::FilePath new_path(GetDriveMyDriveMountPointPath()); | 253 base::FilePath new_path(GetDriveMyDriveMountPointPath()); |
252 GetDriveMountPointPath().AppendRelativePath(path, &new_path); | 254 GetDriveMountPointPath().AppendRelativePath(path, &new_path); |
253 DVLOG(1) << "Migrate download.default_directory setting from " | 255 DVLOG(1) << "Migrate download.default_directory setting from " |
254 << path.AsUTF8Unsafe() << " to " << new_path.AsUTF8Unsafe(); | 256 << path.AsUTF8Unsafe() << " to " << new_path.AsUTF8Unsafe(); |
255 DCHECK(!NeedsNamespaceMigration(new_path)); | 257 DCHECK(!NeedsNamespaceMigration(new_path)); |
256 return new_path; | 258 return new_path; |
257 } | 259 } |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 proto->set_last_modified(file_info.last_modified.ToInternalValue()); | 432 proto->set_last_modified(file_info.last_modified.ToInternalValue()); |
431 proto->set_last_accessed(file_info.last_accessed.ToInternalValue()); | 433 proto->set_last_accessed(file_info.last_accessed.ToInternalValue()); |
432 proto->set_creation_time(file_info.creation_time.ToInternalValue()); | 434 proto->set_creation_time(file_info.creation_time.ToInternalValue()); |
433 } | 435 } |
434 | 436 |
435 void EmptyFileOperationCallback(DriveFileError error) { | 437 void EmptyFileOperationCallback(DriveFileError error) { |
436 } | 438 } |
437 | 439 |
438 } // namespace util | 440 } // namespace util |
439 } // namespace drive | 441 } // namespace drive |
OLD | NEW |