| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/app_restore_service.h" | 5 #include "apps/app_restore_service.h" |
| 6 #include "apps/app_restore_service_factory.h" | 6 #include "apps/app_restore_service_factory.h" |
| 7 #include "apps/saved_files_service.h" | 7 #include "apps/saved_files_service.h" |
| 8 #include "chrome/browser/apps/app_browsertest_util.h" | 8 #include "chrome/browser/apps/app_browsertest_util.h" |
| 9 #include "chrome/browser/extensions/api/file_system/file_system_api.h" | 9 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 110 } |
| 111 | 111 |
| 112 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, FileAccessIsSavedToPrefs) { | 112 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, FileAccessIsSavedToPrefs) { |
| 113 content::WindowedNotificationObserver extension_suspended( | 113 content::WindowedNotificationObserver extension_suspended( |
| 114 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED, | 114 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
| 115 content::NotificationService::AllSources()); | 115 content::NotificationService::AllSources()); |
| 116 | 116 |
| 117 base::ScopedTempDir temp_directory; | 117 base::ScopedTempDir temp_directory; |
| 118 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); | 118 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); |
| 119 base::FilePath temp_file; | 119 base::FilePath temp_file; |
| 120 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_directory.path(), | 120 ASSERT_TRUE( |
| 121 &temp_file)); | 121 base::CreateTemporaryFileInDir(temp_directory.GetPath(), &temp_file)); |
| 122 | 122 |
| 123 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( | 123 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( |
| 124 &temp_file); | 124 &temp_file); |
| 125 FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest( | 125 FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest( |
| 126 "temp", temp_directory.path()); | 126 "temp", temp_directory.GetPath()); |
| 127 | 127 |
| 128 const Extension* extension = LoadAndLaunchPlatformApp( | 128 const Extension* extension = LoadAndLaunchPlatformApp( |
| 129 "file_access_saved_to_prefs_test", "fileWritten"); | 129 "file_access_saved_to_prefs_test", "fileWritten"); |
| 130 ASSERT_TRUE(extension); | 130 ASSERT_TRUE(extension); |
| 131 | 131 |
| 132 SavedFilesService* saved_files_service = SavedFilesService::Get(profile()); | 132 SavedFilesService* saved_files_service = SavedFilesService::Get(profile()); |
| 133 | 133 |
| 134 std::vector<SavedFileEntry> file_entries = | 134 std::vector<SavedFileEntry> file_entries = |
| 135 saved_files_service->GetAllFileEntries(extension->id()); | 135 saved_files_service->GetAllFileEntries(extension->id()); |
| 136 // One for the read-only file entry and one for the writable file entry. | 136 // One for the read-only file entry and one for the writable file entry. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 150 #endif | 150 #endif |
| 151 | 151 |
| 152 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_FileAccessIsRestored) { | 152 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_FileAccessIsRestored) { |
| 153 content::WindowedNotificationObserver extension_suspended( | 153 content::WindowedNotificationObserver extension_suspended( |
| 154 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED, | 154 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
| 155 content::NotificationService::AllSources()); | 155 content::NotificationService::AllSources()); |
| 156 | 156 |
| 157 base::ScopedTempDir temp_directory; | 157 base::ScopedTempDir temp_directory; |
| 158 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); | 158 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); |
| 159 base::FilePath temp_file; | 159 base::FilePath temp_file; |
| 160 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_directory.path(), | 160 ASSERT_TRUE( |
| 161 &temp_file)); | 161 base::CreateTemporaryFileInDir(temp_directory.GetPath(), &temp_file)); |
| 162 | 162 |
| 163 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( | 163 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( |
| 164 &temp_file); | 164 &temp_file); |
| 165 FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest( | 165 FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest( |
| 166 "temp", temp_directory.path()); | 166 "temp", temp_directory.GetPath()); |
| 167 | 167 |
| 168 ExtensionTestMessageListener access_ok_listener( | 168 ExtensionTestMessageListener access_ok_listener( |
| 169 "restartedFileAccessOK", false); | 169 "restartedFileAccessOK", false); |
| 170 | 170 |
| 171 const Extension* extension = | 171 const Extension* extension = |
| 172 LoadAndLaunchPlatformApp("file_access_restored_test", "fileWritten"); | 172 LoadAndLaunchPlatformApp("file_access_restored_test", "fileWritten"); |
| 173 ASSERT_TRUE(extension); | 173 ASSERT_TRUE(extension); |
| 174 | 174 |
| 175 ExtensionPrefs* extension_prefs = | 175 ExtensionPrefs* extension_prefs = |
| 176 ExtensionPrefs::Get(browser()->profile()); | 176 ExtensionPrefs::Get(browser()->profile()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 188 extension->id(), it->id, it->path, it->is_directory); | 188 extension->id(), it->id, it->path, it->is_directory); |
| 189 } | 189 } |
| 190 | 190 |
| 191 apps::AppRestoreServiceFactory::GetForProfile(browser()->profile())-> | 191 apps::AppRestoreServiceFactory::GetForProfile(browser()->profile())-> |
| 192 HandleStartup(true); | 192 HandleStartup(true); |
| 193 | 193 |
| 194 access_ok_listener.WaitUntilSatisfied(); | 194 access_ok_listener.WaitUntilSatisfied(); |
| 195 } | 195 } |
| 196 | 196 |
| 197 } // namespace apps | 197 } // namespace apps |
| OLD | NEW |