Commit ecc9cfd6 authored by haruki@chromium.org's avatar haruki@chromium.org

drive: Enable a hook to update the default download directory.

This enables the update logic for /drive/root namespace.

BUG=174233
TESTS=unittests


Review URL: https://chromiumcodereview.appspot.com/13586012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192570 0039d316-1c4b-4281-b951-d872f2087c98
parent ac3851fe
...@@ -236,19 +236,21 @@ bool IsUnderDriveMountPoint(const base::FilePath& path) { ...@@ -236,19 +236,21 @@ bool IsUnderDriveMountPoint(const base::FilePath& path) {
} }
bool NeedsNamespaceMigration(const base::FilePath& path) { bool NeedsNamespaceMigration(const base::FilePath& path) {
return false; // Before migration, "My Drive" which was represented as "drive.
// TODO(haruki): Update this along with http://crbug.com/174233. // The user might use some path pointing a directory in "My Drive".
// return IsUnderDriveMountPoint(path) && // e.g. "drive/downloads_dir"
// !(GetDriveMyDriveMountPointPath() == path || // We changed the path for the "My Drive" to "drive/root", hence the user pref
// GetDriveMyDriveMountPointPath().IsParent(path)); // pointing to the old path needs update to the new path.
// e.g. "drive/root/downloads_dir"
// If |path| already points to some directory in "drive/root", there's no need
// to update it.
return IsUnderDriveMountPoint(path) &&
!(GetDriveMyDriveMountPointPath() == path ||
GetDriveMyDriveMountPointPath().IsParent(path));
} }
base::FilePath ConvertToMyDriveNamespace(const base::FilePath& path) { base::FilePath ConvertToMyDriveNamespace(const base::FilePath& path) {
// Double check the path. DCHECK(NeedsNamespaceMigration(path));
// TODO(haruki): Update this with DCHECK(NeedsNamespaceMigration(path)).
DCHECK(IsUnderDriveMountPoint(path) &&
!(GetDriveMyDriveMountPointPath() == path ||
GetDriveMyDriveMountPointPath().IsParent(path)));
// Need to migrate "/special/drive(.*)" to "/special/drive/root(.*)". // Need to migrate "/special/drive(.*)" to "/special/drive/root(.*)".
// Append the relative path from "/special/drive". // Append the relative path from "/special/drive".
......
...@@ -151,13 +151,12 @@ TEST(DriveFileSystemUtilTest, NeedsNamespaceMigration) { ...@@ -151,13 +151,12 @@ TEST(DriveFileSystemUtilTest, NeedsNamespaceMigration) {
EXPECT_FALSE(NeedsNamespaceMigration( EXPECT_FALSE(NeedsNamespaceMigration(
base::FilePath::FromUTF8Unsafe("special/drivex/foo.txt"))); base::FilePath::FromUTF8Unsafe("special/drivex/foo.txt")));
// Before migration. TODO(haruki): These cases should be EXPECT_TRUE. // Before migration.
// Update this along with http://crbug.com/174233. EXPECT_TRUE(NeedsNamespaceMigration(
EXPECT_FALSE(NeedsNamespaceMigration(
base::FilePath::FromUTF8Unsafe("/special/drive"))); base::FilePath::FromUTF8Unsafe("/special/drive")));
EXPECT_FALSE(NeedsNamespaceMigration( EXPECT_TRUE(NeedsNamespaceMigration(
base::FilePath::FromUTF8Unsafe("/special/drive/foo.txt"))); base::FilePath::FromUTF8Unsafe("/special/drive/foo.txt")));
EXPECT_FALSE(NeedsNamespaceMigration( EXPECT_TRUE(NeedsNamespaceMigration(
base::FilePath::FromUTF8Unsafe("/special/drive/subdir/foo.txt"))); base::FilePath::FromUTF8Unsafe("/special/drive/subdir/foo.txt")));
// Already migrated. // Already migrated.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment