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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 85 |
87 // Upgrade to a version that wants more permissions. We should disable the | 86 // Upgrade to a version that wants more permissions. We should disable the |
88 // extension and prompt the user to reenable. | 87 // extension and prompt the user to reenable. |
89 const Extension* UpdateIncreasingPermissionExtension( | 88 const Extension* UpdateIncreasingPermissionExtension( |
90 const Extension* extension, | 89 const Extension* extension, |
91 const base::FilePath& crx_path, | 90 const base::FilePath& crx_path, |
92 int expected_change) { | 91 int expected_change) { |
93 size_t size_before = registry_->enabled_extensions().size(); | 92 size_t size_before = registry_->enabled_extensions().size(); |
94 if (UpdateExtension(extension->id(), crx_path, expected_change)) | 93 if (UpdateExtension(extension->id(), crx_path, expected_change)) |
95 return NULL; | 94 return NULL; |
96 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 95 content::RunAllBlockingPoolTasksUntilIdle(); |
97 base::RunLoop().RunUntilIdle(); | |
98 EXPECT_EQ(size_before + expected_change, | 96 EXPECT_EQ(size_before + expected_change, |
99 registry_->enabled_extensions().size()); | 97 registry_->enabled_extensions().size()); |
100 if (registry_->disabled_extensions().size() != 1u) | 98 if (registry_->disabled_extensions().size() != 1u) |
101 return NULL; | 99 return NULL; |
102 | 100 |
103 return registry_->disabled_extensions().begin()->get(); | 101 return registry_->disabled_extensions().begin()->get(); |
104 } | 102 } |
105 | 103 |
106 // Helper function to install an extension and upgrade it to a version | 104 // Helper function to install an extension and upgrade it to a version |
107 // requiring additional permissions. Returns the new disabled Extension. | 105 // requiring additional permissions. Returns the new disabled Extension. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 GURL("http://localhost/autoupdate/v2.crx"), | 222 GURL("http://localhost/autoupdate/v2.crx"), |
225 scoped_temp_dir_.path().AppendASCII("permissions2.crx")); | 223 scoped_temp_dir_.path().AppendASCII("permissions2.crx")); |
226 | 224 |
227 extensions::ExtensionUpdater::CheckParams params; | 225 extensions::ExtensionUpdater::CheckParams params; |
228 service_->updater()->set_default_check_params(params); | 226 service_->updater()->set_default_check_params(params); |
229 | 227 |
230 // Sync is replacing an older version, so it pends. | 228 // Sync is replacing an older version, so it pends. |
231 EXPECT_FALSE(sync_service->ProcessExtensionSyncData(sync_data)); | 229 EXPECT_FALSE(sync_service->ProcessExtensionSyncData(sync_data)); |
232 | 230 |
233 WaitForExtensionInstall(); | 231 WaitForExtensionInstall(); |
234 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 232 content::RunAllBlockingPoolTasksUntilIdle(); |
235 base::RunLoop().RunUntilIdle(); | |
236 | 233 |
237 extension = service_->GetExtensionById(extension_id, true); | 234 extension = service_->GetExtensionById(extension_id, true); |
238 ASSERT_TRUE(extension); | 235 ASSERT_TRUE(extension); |
239 EXPECT_EQ("2", extension->VersionString()); | 236 EXPECT_EQ("2", extension->VersionString()); |
240 EXPECT_EQ(1u, registry_->disabled_extensions().size()); | 237 EXPECT_EQ(1u, registry_->disabled_extensions().size()); |
241 EXPECT_EQ(Extension::DISABLE_PERMISSIONS_INCREASE, | 238 EXPECT_EQ(Extension::DISABLE_PERMISSIONS_INCREASE, |
242 ExtensionPrefs::Get(service_->profile()) | 239 ExtensionPrefs::Get(service_->profile()) |
243 ->GetDisableReasons(extension_id)); | 240 ->GetDisableReasons(extension_id)); |
244 EXPECT_TRUE(GetExtensionDisabledGlobalError()); | 241 EXPECT_TRUE(GetExtensionDisabledGlobalError()); |
245 } | 242 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 syncer::SyncData::CreateRemoteData(1234567, | 275 syncer::SyncData::CreateRemoteData(1234567, |
279 specifics, | 276 specifics, |
280 base::Time::Now(), | 277 base::Time::Now(), |
281 syncer::AttachmentIdList(), | 278 syncer::AttachmentIdList(), |
282 syncer::AttachmentServiceProxy()); | 279 syncer::AttachmentServiceProxy()); |
283 // Sync is installing a new extension, so it pends. | 280 // Sync is installing a new extension, so it pends. |
284 EXPECT_FALSE(sync_service->ProcessExtensionSyncData( | 281 EXPECT_FALSE(sync_service->ProcessExtensionSyncData( |
285 extensions::ExtensionSyncData(sync_data))); | 282 extensions::ExtensionSyncData(sync_data))); |
286 | 283 |
287 WaitForExtensionInstall(); | 284 WaitForExtensionInstall(); |
288 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 285 content::RunAllBlockingPoolTasksUntilIdle(); |
289 base::RunLoop().RunUntilIdle(); | |
290 | 286 |
291 const Extension* extension = service_->GetExtensionById(extension_id, true); | 287 const Extension* extension = service_->GetExtensionById(extension_id, true); |
292 ASSERT_TRUE(extension); | 288 ASSERT_TRUE(extension); |
293 EXPECT_EQ("2", extension->VersionString()); | 289 EXPECT_EQ("2", extension->VersionString()); |
294 EXPECT_EQ(1u, registry_->disabled_extensions().size()); | 290 EXPECT_EQ(1u, registry_->disabled_extensions().size()); |
295 EXPECT_EQ(Extension::DISABLE_REMOTE_INSTALL, | 291 EXPECT_EQ(Extension::DISABLE_REMOTE_INSTALL, |
296 ExtensionPrefs::Get(service_->profile()) | 292 ExtensionPrefs::Get(service_->profile()) |
297 ->GetDisableReasons(extension_id)); | 293 ->GetDisableReasons(extension_id)); |
298 EXPECT_TRUE(GetExtensionDisabledGlobalError()); | 294 EXPECT_TRUE(GetExtensionDisabledGlobalError()); |
299 } | 295 } |
OLD | NEW |