| 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 "apps/saved_files_service.h" | 5 #include "apps/saved_files_service.h" |
| 6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/scoped_observer.h" | 8 #include "base/scoped_observer.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "chrome/browser/apps/app_browsertest_util.h" | 10 #include "chrome/browser/apps/app_browsertest_util.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 class AppLoadObserver : public ExtensionRegistryObserver { | 26 class AppLoadObserver : public ExtensionRegistryObserver { |
| 27 public: | 27 public: |
| 28 AppLoadObserver(content::BrowserContext* browser_context, | 28 AppLoadObserver(content::BrowserContext* browser_context, |
| 29 base::Callback<void(const Extension*)> callback) | 29 base::Callback<void(const Extension*)> callback) |
| 30 : callback_(callback), extension_registry_observer_(this) { | 30 : callback_(callback), extension_registry_observer_(this) { |
| 31 extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context)); | 31 extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context)); |
| 32 } | 32 } |
| 33 | 33 |
| 34 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, | 34 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 35 const Extension* extension) OVERRIDE { | 35 const Extension* extension) override { |
| 36 callback_.Run(extension); | 36 callback_.Run(extension); |
| 37 } | 37 } |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 base::Callback<void(const Extension*)> callback_; | 40 base::Callback<void(const Extension*)> callback_; |
| 41 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 41 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 42 extension_registry_observer_; | 42 extension_registry_observer_; |
| 43 DISALLOW_COPY_AND_ASSIGN(AppLoadObserver); | 43 DISALLOW_COPY_AND_ASSIGN(AppLoadObserver); |
| 44 }; | 44 }; |
| 45 | 45 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 57 service->RegisterFileEntry( | 57 service->RegisterFileEntry( |
| 58 extension->id(), "magic id", path_to_save, is_directory); | 58 extension->id(), "magic id", path_to_save, is_directory); |
| 59 } | 59 } |
| 60 | 60 |
| 61 const int kGraylistedPath = base::DIR_HOME; | 61 const int kGraylistedPath = base::DIR_HOME; |
| 62 | 62 |
| 63 } // namespace | 63 } // namespace |
| 64 | 64 |
| 65 class FileSystemApiTest : public PlatformAppBrowserTest { | 65 class FileSystemApiTest : public PlatformAppBrowserTest { |
| 66 public: | 66 public: |
| 67 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 67 virtual void SetUpCommandLine(CommandLine* command_line) override { |
| 68 PlatformAppBrowserTest::SetUpCommandLine(command_line); | 68 PlatformAppBrowserTest::SetUpCommandLine(command_line); |
| 69 test_root_folder_ = test_data_dir_.AppendASCII("api_test") | 69 test_root_folder_ = test_data_dir_.AppendASCII("api_test") |
| 70 .AppendASCII("file_system"); | 70 .AppendASCII("file_system"); |
| 71 FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest( | 71 FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest( |
| 72 "test_root", test_root_folder_); | 72 "test_root", test_root_folder_); |
| 73 } | 73 } |
| 74 | 74 |
| 75 virtual void SetUpOnMainThread() OVERRIDE { | 75 virtual void SetUpOnMainThread() override { |
| 76 ClearCommandLineArgs(); | 76 ClearCommandLineArgs(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 virtual void TearDown() OVERRIDE { | 79 virtual void TearDown() override { |
| 80 FileSystemChooseEntryFunction::StopSkippingPickerForTest(); | 80 FileSystemChooseEntryFunction::StopSkippingPickerForTest(); |
| 81 PlatformAppBrowserTest::TearDown(); | 81 PlatformAppBrowserTest::TearDown(); |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 protected: | 84 protected: |
| 85 base::FilePath TempFilePath(const std::string& destination_name, | 85 base::FilePath TempFilePath(const std::string& destination_name, |
| 86 bool copy_gold) { | 86 bool copy_gold) { |
| 87 if (!temp_dir_.CreateUniqueTempDir()) { | 87 if (!temp_dir_.CreateUniqueTempDir()) { |
| 88 ADD_FAILURE() << "CreateUniqueTempDir failed"; | 88 ADD_FAILURE() << "CreateUniqueTempDir failed"; |
| 89 return base::FilePath(); | 89 return base::FilePath(); |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 AppLoadObserver observer(profile(), | 628 AppLoadObserver observer(profile(), |
| 629 base::Bind(AddSavedEntry, | 629 base::Bind(AddSavedEntry, |
| 630 test_directory, | 630 test_directory, |
| 631 true, | 631 true, |
| 632 apps::SavedFilesService::Get(profile()))); | 632 apps::SavedFilesService::Get(profile()))); |
| 633 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/restore_directory")) | 633 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/restore_directory")) |
| 634 << message_; | 634 << message_; |
| 635 } | 635 } |
| 636 | 636 |
| 637 } // namespace extensions | 637 } // namespace extensions |
| OLD | NEW |