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/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
7 #include "base/run_loop.h" | |
8 #include "base/threading/sequenced_worker_pool.h" | 7 #include "base/threading/sequenced_worker_pool.h" |
9 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/browser/extensions/extension_browsertest.h" | 9 #include "chrome/browser/extensions/extension_browsertest.h" |
11 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
12 #include "chrome/browser/extensions/extension_sync_service.h" | 11 #include "chrome/browser/extensions/extension_sync_service.h" |
13 #include "chrome/browser/extensions/updater/extension_updater.h" | 12 #include "chrome/browser/extensions/updater/extension_updater.h" |
14 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/global_error/global_error.h" | 15 #include "chrome/browser/ui/global_error/global_error.h" |
17 #include "chrome/browser/ui/global_error/global_error_service.h" | 16 #include "chrome/browser/ui/global_error/global_error_service.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 84 |
86 // Upgrade to a version that wants more permissions. We should disable the | 85 // Upgrade to a version that wants more permissions. We should disable the |
87 // extension and prompt the user to reenable. | 86 // extension and prompt the user to reenable. |
88 const Extension* UpdateIncreasingPermissionExtension( | 87 const Extension* UpdateIncreasingPermissionExtension( |
89 const Extension* extension, | 88 const Extension* extension, |
90 const base::FilePath& crx_path, | 89 const base::FilePath& crx_path, |
91 int expected_change) { | 90 int expected_change) { |
92 size_t size_before = registry_->enabled_extensions().size(); | 91 size_t size_before = registry_->enabled_extensions().size(); |
93 if (UpdateExtension(extension->id(), crx_path, expected_change)) | 92 if (UpdateExtension(extension->id(), crx_path, expected_change)) |
94 return NULL; | 93 return NULL; |
95 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 94 content::RunAllBlockingPoolTasksUntilIdle(); |
96 base::RunLoop().RunUntilIdle(); | |
97 EXPECT_EQ(size_before + expected_change, | 95 EXPECT_EQ(size_before + expected_change, |
98 registry_->enabled_extensions().size()); | 96 registry_->enabled_extensions().size()); |
99 if (registry_->disabled_extensions().size() != 1u) | 97 if (registry_->disabled_extensions().size() != 1u) |
100 return NULL; | 98 return NULL; |
101 | 99 |
102 return registry_->disabled_extensions().begin()->get(); | 100 return registry_->disabled_extensions().begin()->get(); |
103 } | 101 } |
104 | 102 |
105 // Helper function to install an extension and upgrade it to a version | 103 // Helper function to install an extension and upgrade it to a version |
106 // requiring additional permissions. Returns the new disabled Extension. | 104 // requiring additional permissions. Returns the new disabled Extension. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 GURL("http://localhost/autoupdate/v2.crx"), | 218 GURL("http://localhost/autoupdate/v2.crx"), |
221 scoped_temp_dir_.path().AppendASCII("permissions2.crx")); | 219 scoped_temp_dir_.path().AppendASCII("permissions2.crx")); |
222 | 220 |
223 extensions::ExtensionUpdater::CheckParams params; | 221 extensions::ExtensionUpdater::CheckParams params; |
224 service_->updater()->set_default_check_params(params); | 222 service_->updater()->set_default_check_params(params); |
225 | 223 |
226 // Sync is replacing an older version, so it pends. | 224 // Sync is replacing an older version, so it pends. |
227 EXPECT_FALSE(sync_service->ProcessExtensionSyncData(sync_data)); | 225 EXPECT_FALSE(sync_service->ProcessExtensionSyncData(sync_data)); |
228 | 226 |
229 WaitForExtensionInstall(); | 227 WaitForExtensionInstall(); |
230 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 228 content::RunAllBlockingPoolTasksUntilIdle(); |
231 base::RunLoop().RunUntilIdle(); | |
232 | 229 |
233 extension = service_->GetExtensionById(extension_id, true); | 230 extension = service_->GetExtensionById(extension_id, true); |
234 ASSERT_TRUE(extension); | 231 ASSERT_TRUE(extension); |
235 EXPECT_EQ("2", extension->VersionString()); | 232 EXPECT_EQ("2", extension->VersionString()); |
236 EXPECT_EQ(1u, registry_->disabled_extensions().size()); | 233 EXPECT_EQ(1u, registry_->disabled_extensions().size()); |
237 EXPECT_EQ(Extension::DISABLE_PERMISSIONS_INCREASE, | 234 EXPECT_EQ(Extension::DISABLE_PERMISSIONS_INCREASE, |
238 ExtensionPrefs::Get(service_->profile()) | 235 ExtensionPrefs::Get(service_->profile()) |
239 ->GetDisableReasons(extension_id)); | 236 ->GetDisableReasons(extension_id)); |
240 EXPECT_TRUE(GetExtensionDisabledGlobalError()); | 237 EXPECT_TRUE(GetExtensionDisabledGlobalError()); |
241 } | 238 } |
(...skipping 29 matching lines...) Expand all Loading... |
271 syncer::SyncData::CreateRemoteData(1234567, | 268 syncer::SyncData::CreateRemoteData(1234567, |
272 specifics, | 269 specifics, |
273 base::Time::Now(), | 270 base::Time::Now(), |
274 syncer::AttachmentIdList(), | 271 syncer::AttachmentIdList(), |
275 syncer::AttachmentServiceProxy()); | 272 syncer::AttachmentServiceProxy()); |
276 // Sync is installing a new extension, so it pends. | 273 // Sync is installing a new extension, so it pends. |
277 EXPECT_FALSE(sync_service->ProcessExtensionSyncData( | 274 EXPECT_FALSE(sync_service->ProcessExtensionSyncData( |
278 extensions::ExtensionSyncData(sync_data))); | 275 extensions::ExtensionSyncData(sync_data))); |
279 | 276 |
280 WaitForExtensionInstall(); | 277 WaitForExtensionInstall(); |
281 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 278 content::RunAllBlockingPoolTasksUntilIdle(); |
282 base::RunLoop().RunUntilIdle(); | |
283 | 279 |
284 const Extension* extension = service_->GetExtensionById(extension_id, true); | 280 const Extension* extension = service_->GetExtensionById(extension_id, true); |
285 ASSERT_TRUE(extension); | 281 ASSERT_TRUE(extension); |
286 EXPECT_EQ("2", extension->VersionString()); | 282 EXPECT_EQ("2", extension->VersionString()); |
287 EXPECT_EQ(1u, registry_->disabled_extensions().size()); | 283 EXPECT_EQ(1u, registry_->disabled_extensions().size()); |
288 EXPECT_EQ(Extension::DISABLE_REMOTE_INSTALL, | 284 EXPECT_EQ(Extension::DISABLE_REMOTE_INSTALL, |
289 ExtensionPrefs::Get(service_->profile()) | 285 ExtensionPrefs::Get(service_->profile()) |
290 ->GetDisableReasons(extension_id)); | 286 ->GetDisableReasons(extension_id)); |
291 EXPECT_TRUE(GetExtensionDisabledGlobalError()); | 287 EXPECT_TRUE(GetExtensionDisabledGlobalError()); |
292 } | 288 } |
OLD | NEW |