| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 11 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
| 12 #include "chrome/browser/chromeos/file_manager/drive_test_util.h" | 12 #include "chrome/browser/chromeos/file_manager/drive_test_util.h" |
| 13 #include "chrome/browser/chromeos/file_manager/volume_manager.h" | 13 #include "chrome/browser/chromeos/file_manager/volume_manager.h" |
| 14 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 14 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 15 #include "chrome/browser/drive/fake_drive_service.h" | 15 #include "chrome/browser/drive/fake_drive_service.h" |
| 16 #include "chrome/browser/extensions/extension_apitest.h" | 16 #include "chrome/browser/extensions/extension_apitest.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
| 19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/common/chrome_constants.h" | 20 #include "chrome/common/chrome_constants.h" |
| 21 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
| 22 #include "components/user_manager/user_manager.h" | 22 #include "components/user_manager/user_manager.h" |
| 23 #include "content/public/browser/browser_context.h" | 23 #include "content/public/browser/browser_context.h" |
| 24 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/test/test_utils.h" | 25 #include "content/public/test/test_utils.h" |
| 26 #include "extensions/browser/notification_types.h" | 26 #include "extensions/browser/notification_types.h" |
| 27 #include "google_apis/drive/drive_api_parser.h" | 27 #include "google_apis/drive/drive_api_parser.h" |
| 28 #include "google_apis/drive/test_util.h" | 28 #include "google_apis/drive/test_util.h" |
| 29 #include "google_apis/drive/time_util.h" | 29 #include "google_apis/drive/time_util.h" |
| 30 #include "webkit/browser/fileapi/external_mount_points.h" | 30 #include "storage/browser/fileapi/external_mount_points.h" |
| 31 | 31 |
| 32 // Tests for access to external file systems (as defined in | 32 // Tests for access to external file systems (as defined in |
| 33 // webkit/common/fileapi/file_system_types.h) from extensions with | 33 // storage/common/fileapi/file_system_types.h) from extensions with |
| 34 // fileBrowserPrivate and fileBrowserHandler extension permissions. | 34 // fileBrowserPrivate and fileBrowserHandler extension permissions. |
| 35 // The tests cover following external file system types: | 35 // The tests cover following external file system types: |
| 36 // - local (kFileSystemTypeLocalNative): a local file system on which files are | 36 // - local (kFileSystemTypeLocalNative): a local file system on which files are |
| 37 // accessed using native local path. | 37 // accessed using native local path. |
| 38 // - restricted (kFileSystemTypeRestrictedLocalNative): a *read-only* local file | 38 // - restricted (kFileSystemTypeRestrictedLocalNative): a *read-only* local file |
| 39 // system which can only be accessed by extensions that have full access to | 39 // system which can only be accessed by extensions that have full access to |
| 40 // external file systems (i.e. extensions with fileBrowserPrivate permission). | 40 // external file systems (i.e. extensions with fileBrowserPrivate permission). |
| 41 // - drive (kFileSystemTypeDrive): a file system that provides access to Google | 41 // - drive (kFileSystemTypeDrive): a file system that provides access to Google |
| 42 // Drive. | 42 // Drive. |
| 43 // | 43 // |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 | 401 |
| 402 // FileSystemExtensionApiTestBase OVERRIDE. | 402 // FileSystemExtensionApiTestBase OVERRIDE. |
| 403 virtual void InitTestFileSystem() OVERRIDE { | 403 virtual void InitTestFileSystem() OVERRIDE { |
| 404 ASSERT_TRUE(InitializeLocalFileSystem( | 404 ASSERT_TRUE(InitializeLocalFileSystem( |
| 405 kLocalMountPointName, &tmp_dir_, &mount_point_dir_)) | 405 kLocalMountPointName, &tmp_dir_, &mount_point_dir_)) |
| 406 << "Failed to initialize file system."; | 406 << "Failed to initialize file system."; |
| 407 } | 407 } |
| 408 | 408 |
| 409 // FileSystemExtensionApiTestBase OVERRIDE. | 409 // FileSystemExtensionApiTestBase OVERRIDE. |
| 410 virtual void AddTestMountPoint() OVERRIDE { | 410 virtual void AddTestMountPoint() OVERRIDE { |
| 411 EXPECT_TRUE(content::BrowserContext::GetMountPoints(browser()->profile())-> | 411 EXPECT_TRUE(content::BrowserContext::GetMountPoints(browser()->profile()) |
| 412 RegisterFileSystem(kLocalMountPointName, | 412 ->RegisterFileSystem(kLocalMountPointName, |
| 413 fileapi::kFileSystemTypeNativeLocal, | 413 storage::kFileSystemTypeNativeLocal, |
| 414 fileapi::FileSystemMountOption(), | 414 storage::FileSystemMountOption(), |
| 415 mount_point_dir_)); | 415 mount_point_dir_)); |
| 416 VolumeManager::Get(browser()->profile())->AddVolumeInfoForTesting( | 416 VolumeManager::Get(browser()->profile())->AddVolumeInfoForTesting( |
| 417 mount_point_dir_, VOLUME_TYPE_TESTING, chromeos::DEVICE_TYPE_UNKNOWN); | 417 mount_point_dir_, VOLUME_TYPE_TESTING, chromeos::DEVICE_TYPE_UNKNOWN); |
| 418 } | 418 } |
| 419 | 419 |
| 420 private: | 420 private: |
| 421 base::ScopedTempDir tmp_dir_; | 421 base::ScopedTempDir tmp_dir_; |
| 422 base::FilePath mount_point_dir_; | 422 base::FilePath mount_point_dir_; |
| 423 }; | 423 }; |
| 424 | 424 |
| 425 // Tests for restricted native local file systems. | 425 // Tests for restricted native local file systems. |
| 426 class RestrictedFileSystemExtensionApiTest | 426 class RestrictedFileSystemExtensionApiTest |
| 427 : public FileSystemExtensionApiTestBase { | 427 : public FileSystemExtensionApiTestBase { |
| 428 public: | 428 public: |
| 429 RestrictedFileSystemExtensionApiTest() {} | 429 RestrictedFileSystemExtensionApiTest() {} |
| 430 virtual ~RestrictedFileSystemExtensionApiTest() {} | 430 virtual ~RestrictedFileSystemExtensionApiTest() {} |
| 431 | 431 |
| 432 // FileSystemExtensionApiTestBase OVERRIDE. | 432 // FileSystemExtensionApiTestBase OVERRIDE. |
| 433 virtual void InitTestFileSystem() OVERRIDE { | 433 virtual void InitTestFileSystem() OVERRIDE { |
| 434 ASSERT_TRUE(InitializeLocalFileSystem( | 434 ASSERT_TRUE(InitializeLocalFileSystem( |
| 435 kRestrictedMountPointName, &tmp_dir_, &mount_point_dir_)) | 435 kRestrictedMountPointName, &tmp_dir_, &mount_point_dir_)) |
| 436 << "Failed to initialize file system."; | 436 << "Failed to initialize file system."; |
| 437 } | 437 } |
| 438 | 438 |
| 439 // FileSystemExtensionApiTestBase OVERRIDE. | 439 // FileSystemExtensionApiTestBase OVERRIDE. |
| 440 virtual void AddTestMountPoint() OVERRIDE { | 440 virtual void AddTestMountPoint() OVERRIDE { |
| 441 EXPECT_TRUE(content::BrowserContext::GetMountPoints(browser()->profile())-> | 441 EXPECT_TRUE( |
| 442 RegisterFileSystem(kRestrictedMountPointName, | 442 content::BrowserContext::GetMountPoints(browser()->profile()) |
| 443 fileapi::kFileSystemTypeRestrictedNativeLocal, | 443 ->RegisterFileSystem(kRestrictedMountPointName, |
| 444 fileapi::FileSystemMountOption(), | 444 storage::kFileSystemTypeRestrictedNativeLocal, |
| 445 mount_point_dir_)); | 445 storage::FileSystemMountOption(), |
| 446 mount_point_dir_)); |
| 446 VolumeManager::Get(browser()->profile())->AddVolumeInfoForTesting( | 447 VolumeManager::Get(browser()->profile())->AddVolumeInfoForTesting( |
| 447 mount_point_dir_, VOLUME_TYPE_TESTING, chromeos::DEVICE_TYPE_UNKNOWN); | 448 mount_point_dir_, VOLUME_TYPE_TESTING, chromeos::DEVICE_TYPE_UNKNOWN); |
| 448 } | 449 } |
| 449 | 450 |
| 450 private: | 451 private: |
| 451 base::ScopedTempDir tmp_dir_; | 452 base::ScopedTempDir tmp_dir_; |
| 452 base::FilePath mount_point_dir_; | 453 base::FilePath mount_point_dir_; |
| 453 }; | 454 }; |
| 454 | 455 |
| 455 // Tests for a drive file system. | 456 // Tests for a drive file system. |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 base::Unretained(this)); | 621 base::Unretained(this)); |
| 621 service_factory_for_test_.reset( | 622 service_factory_for_test_.reset( |
| 622 new DriveIntegrationServiceFactory::ScopedFactoryForTest( | 623 new DriveIntegrationServiceFactory::ScopedFactoryForTest( |
| 623 &create_drive_integration_service_)); | 624 &create_drive_integration_service_)); |
| 624 } | 625 } |
| 625 | 626 |
| 626 // FileSystemExtensionApiTestBase OVERRIDE. | 627 // FileSystemExtensionApiTestBase OVERRIDE. |
| 627 virtual void AddTestMountPoint() OVERRIDE { | 628 virtual void AddTestMountPoint() OVERRIDE { |
| 628 EXPECT_TRUE(content::BrowserContext::GetMountPoints(browser()->profile()) | 629 EXPECT_TRUE(content::BrowserContext::GetMountPoints(browser()->profile()) |
| 629 ->RegisterFileSystem(kLocalMountPointName, | 630 ->RegisterFileSystem(kLocalMountPointName, |
| 630 fileapi::kFileSystemTypeNativeLocal, | 631 storage::kFileSystemTypeNativeLocal, |
| 631 fileapi::FileSystemMountOption(), | 632 storage::FileSystemMountOption(), |
| 632 local_mount_point_dir_)); | 633 local_mount_point_dir_)); |
| 633 VolumeManager::Get(browser()->profile()) | 634 VolumeManager::Get(browser()->profile()) |
| 634 ->AddVolumeInfoForTesting(local_mount_point_dir_, | 635 ->AddVolumeInfoForTesting(local_mount_point_dir_, |
| 635 VOLUME_TYPE_TESTING, | 636 VOLUME_TYPE_TESTING, |
| 636 chromeos::DEVICE_TYPE_UNKNOWN); | 637 chromeos::DEVICE_TYPE_UNKNOWN); |
| 637 test_util::WaitUntilDriveMountPointIsAdded(browser()->profile()); | 638 test_util::WaitUntilDriveMountPointIsAdded(browser()->profile()); |
| 638 } | 639 } |
| 639 | 640 |
| 640 protected: | 641 protected: |
| 641 // DriveIntegrationService factory function for this test. | 642 // DriveIntegrationService factory function for this test. |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 AppFileHandlerMulti) { | 790 AppFileHandlerMulti) { |
| 790 EXPECT_TRUE( | 791 EXPECT_TRUE( |
| 791 RunFileSystemExtensionApiTest("file_browser/app_file_handler_multi", | 792 RunFileSystemExtensionApiTest("file_browser/app_file_handler_multi", |
| 792 FILE_PATH_LITERAL("manifest.json"), | 793 FILE_PATH_LITERAL("manifest.json"), |
| 793 "", | 794 "", |
| 794 FLAGS_NONE)) | 795 FLAGS_NONE)) |
| 795 << message_; | 796 << message_; |
| 796 } | 797 } |
| 797 } // namespace | 798 } // namespace |
| 798 } // namespace file_manager | 799 } // namespace file_manager |
| OLD | NEW |