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/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 | 418 |
419 extensions::PendingExtensionManager* pending_extension_manager = | 419 extensions::PendingExtensionManager* pending_extension_manager = |
420 service->pending_extension_manager(); | 420 service->pending_extension_manager(); |
421 | 421 |
422 // The code that reads external_extensions.json uses this method to inform | 422 // The code that reads external_extensions.json uses this method to inform |
423 // the ExtensionService of an extension to download. Using the real code | 423 // the ExtensionService of an extension to download. Using the real code |
424 // is race-prone, because instantating the ExtensionService starts a read | 424 // is race-prone, because instantating the ExtensionService starts a read |
425 // of external_extensions.json before this test function starts. | 425 // of external_extensions.json before this test function starts. |
426 | 426 |
427 EXPECT_TRUE(pending_extension_manager->AddFromExternalUpdateUrl( | 427 EXPECT_TRUE(pending_extension_manager->AddFromExternalUpdateUrl( |
428 kExtensionId, GURL("http://localhost/autoupdate/manifest"), | 428 kExtensionId, |
429 Manifest::EXTERNAL_PREF_DOWNLOAD, Extension::NO_FLAGS, false)); | 429 std::string(), |
| 430 GURL("http://localhost/autoupdate/manifest"), |
| 431 Manifest::EXTERNAL_PREF_DOWNLOAD, |
| 432 Extension::NO_FLAGS, |
| 433 false)); |
430 | 434 |
431 // Run autoupdate and make sure version 2 of the extension was installed. | 435 // Run autoupdate and make sure version 2 of the extension was installed. |
432 service->updater()->CheckNow(params); | 436 service->updater()->CheckNow(params); |
433 ASSERT_TRUE(WaitForExtensionInstall()); | 437 ASSERT_TRUE(WaitForExtensionInstall()); |
434 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); | 438 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); |
435 const Extension* extension = service->GetExtensionById(kExtensionId, false); | 439 const Extension* extension = service->GetExtensionById(kExtensionId, false); |
436 ASSERT_TRUE(extension); | 440 ASSERT_TRUE(extension); |
437 ASSERT_EQ("2.0", extension->VersionString()); | 441 ASSERT_EQ("2.0", extension->VersionString()); |
438 | 442 |
439 // Uninstalling the extension should set a pref that keeps the extension from | 443 // Uninstalling the extension should set a pref that keeps the extension from |
440 // being installed again the next time external_extensions.json is read. | 444 // being installed again the next time external_extensions.json is read. |
441 | 445 |
442 UninstallExtension(kExtensionId); | 446 UninstallExtension(kExtensionId); |
443 | 447 |
444 extensions::ExtensionPrefs* extension_prefs = | 448 extensions::ExtensionPrefs* extension_prefs = |
445 extensions::ExtensionPrefs::Get(browser()->profile()); | 449 extensions::ExtensionPrefs::Get(browser()->profile()); |
446 EXPECT_TRUE(extension_prefs->IsExternalExtensionUninstalled(kExtensionId)) | 450 EXPECT_TRUE(extension_prefs->IsExternalExtensionUninstalled(kExtensionId)) |
447 << "Uninstalling should set kill bit on externaly installed extension."; | 451 << "Uninstalling should set kill bit on externaly installed extension."; |
448 | 452 |
449 // Try to install the extension again from an external source. It should fail | 453 // Try to install the extension again from an external source. It should fail |
450 // because of the killbit. | 454 // because of the killbit. |
451 EXPECT_FALSE(pending_extension_manager->AddFromExternalUpdateUrl( | 455 EXPECT_FALSE(pending_extension_manager->AddFromExternalUpdateUrl( |
452 kExtensionId, GURL("http://localhost/autoupdate/manifest"), | 456 kExtensionId, |
453 Manifest::EXTERNAL_PREF_DOWNLOAD, Extension::NO_FLAGS, false)); | 457 std::string(), |
| 458 GURL("http://localhost/autoupdate/manifest"), |
| 459 Manifest::EXTERNAL_PREF_DOWNLOAD, |
| 460 Extension::NO_FLAGS, |
| 461 false)); |
454 EXPECT_FALSE(pending_extension_manager->IsIdPending(kExtensionId)) | 462 EXPECT_FALSE(pending_extension_manager->IsIdPending(kExtensionId)) |
455 << "External reinstall of a killed extension shouldn't work."; | 463 << "External reinstall of a killed extension shouldn't work."; |
456 EXPECT_TRUE(extension_prefs->IsExternalExtensionUninstalled(kExtensionId)) | 464 EXPECT_TRUE(extension_prefs->IsExternalExtensionUninstalled(kExtensionId)) |
457 << "External reinstall of a killed extension should leave it killed."; | 465 << "External reinstall of a killed extension should leave it killed."; |
458 | 466 |
459 // Installing from non-external source. | 467 // Installing from non-external source. |
460 ASSERT_TRUE(InstallExtension(basedir.AppendASCII("v2.crx"), 1)); | 468 ASSERT_TRUE(InstallExtension(basedir.AppendASCII("v2.crx"), 1)); |
461 | 469 |
462 EXPECT_FALSE(extension_prefs->IsExternalExtensionUninstalled(kExtensionId)) | 470 EXPECT_FALSE(extension_prefs->IsExternalExtensionUninstalled(kExtensionId)) |
463 << "Reinstalling should clear the kill bit."; | 471 << "Reinstalling should clear the kill bit."; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 forcelist, kExtensionId, "http://localhost/autoupdate/manifest"); | 645 forcelist, kExtensionId, "http://localhost/autoupdate/manifest"); |
638 } | 646 } |
639 ASSERT_TRUE(WaitForExtensionInstall()); | 647 ASSERT_TRUE(WaitForExtensionInstall()); |
640 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); | 648 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); |
641 extension = service->GetExtensionById(kExtensionId, false); | 649 extension = service->GetExtensionById(kExtensionId, false); |
642 ASSERT_TRUE(extension); | 650 ASSERT_TRUE(extension); |
643 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); | 651 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); |
644 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); | 652 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); |
645 EXPECT_TRUE(registry->disabled_extensions().is_empty()); | 653 EXPECT_TRUE(registry->disabled_extensions().is_empty()); |
646 } | 654 } |
OLD | NEW |