| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 browser()->profile()) | 565 browser()->profile()) |
| 566 ->GetForceInstallList() | 566 ->GetForceInstallList() |
| 567 ->empty()) | 567 ->empty()) |
| 568 << kForceInstallNotEmptyHelp; | 568 << kForceInstallNotEmptyHelp; |
| 569 | 569 |
| 570 base::ListValue forcelist; | 570 base::ListValue forcelist; |
| 571 forcelist.AppendString(BuildForceInstallPolicyValue( | 571 forcelist.AppendString(BuildForceInstallPolicyValue( |
| 572 kExtensionId, "http://localhost/autoupdate/manifest")); | 572 kExtensionId, "http://localhost/autoupdate/manifest")); |
| 573 PolicyMap policies; | 573 PolicyMap policies; |
| 574 policies.Set(policy::key::kExtensionInstallForcelist, | 574 policies.Set(policy::key::kExtensionInstallForcelist, |
| 575 policy::POLICY_LEVEL_MANDATORY, | 575 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER, |
| 576 policy::POLICY_SCOPE_USER, | 576 policy::POLICY_SOURCE_CLOUD, forcelist.CreateDeepCopy(), |
| 577 policy::POLICY_SOURCE_CLOUD, | 577 nullptr); |
| 578 forcelist.DeepCopy(), | |
| 579 NULL); | |
| 580 extensions::TestExtensionRegistryObserver install_observer(registry); | 578 extensions::TestExtensionRegistryObserver install_observer(registry); |
| 581 UpdateProviderPolicy(policies); | 579 UpdateProviderPolicy(policies); |
| 582 install_observer.WaitForExtensionWillBeInstalled(); | 580 install_observer.WaitForExtensionWillBeInstalled(); |
| 583 | 581 |
| 584 // Check if the extension got installed. | 582 // Check if the extension got installed. |
| 585 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); | 583 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); |
| 586 const Extension* extension = service->GetExtensionById(kExtensionId, false); | 584 const Extension* extension = service->GetExtensionById(kExtensionId, false); |
| 587 ASSERT_TRUE(extension); | 585 ASSERT_TRUE(extension); |
| 588 ASSERT_EQ("2.0", extension->VersionString()); | 586 ASSERT_EQ("2.0", extension->VersionString()); |
| 589 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); | 587 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 ASSERT_TRUE(extension); | 652 ASSERT_TRUE(extension); |
| 655 EXPECT_EQ(Manifest::INTERNAL, extension->location()); | 653 EXPECT_EQ(Manifest::INTERNAL, extension->location()); |
| 656 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); | 654 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); |
| 657 | 655 |
| 658 // Setup the force install policy. It should override the location. | 656 // Setup the force install policy. It should override the location. |
| 659 base::ListValue forcelist; | 657 base::ListValue forcelist; |
| 660 forcelist.AppendString(BuildForceInstallPolicyValue( | 658 forcelist.AppendString(BuildForceInstallPolicyValue( |
| 661 kExtensionId, "http://localhost/autoupdate/manifest")); | 659 kExtensionId, "http://localhost/autoupdate/manifest")); |
| 662 PolicyMap policies; | 660 PolicyMap policies; |
| 663 policies.Set(policy::key::kExtensionInstallForcelist, | 661 policies.Set(policy::key::kExtensionInstallForcelist, |
| 664 policy::POLICY_LEVEL_MANDATORY, | 662 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER, |
| 665 policy::POLICY_SCOPE_USER, | 663 policy::POLICY_SOURCE_CLOUD, forcelist.CreateDeepCopy(), |
| 666 policy::POLICY_SOURCE_CLOUD, | 664 nullptr); |
| 667 forcelist.DeepCopy(), | |
| 668 NULL); | |
| 669 extensions::TestExtensionRegistryObserver install_observer(registry); | 665 extensions::TestExtensionRegistryObserver install_observer(registry); |
| 670 UpdateProviderPolicy(policies); | 666 UpdateProviderPolicy(policies); |
| 671 install_observer.WaitForExtensionWillBeInstalled(); | 667 install_observer.WaitForExtensionWillBeInstalled(); |
| 672 | 668 |
| 673 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); | 669 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); |
| 674 extension = service->GetExtensionById(kExtensionId, false); | 670 extension = service->GetExtensionById(kExtensionId, false); |
| 675 ASSERT_TRUE(extension); | 671 ASSERT_TRUE(extension); |
| 676 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); | 672 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); |
| 677 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); | 673 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); |
| 678 | 674 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 697 | 693 |
| 698 DisableExtension(kExtensionId); | 694 DisableExtension(kExtensionId); |
| 699 EXPECT_EQ(1u, registry->disabled_extensions().size()); | 695 EXPECT_EQ(1u, registry->disabled_extensions().size()); |
| 700 extension = service->GetExtensionById(kExtensionId, true); | 696 extension = service->GetExtensionById(kExtensionId, true); |
| 701 EXPECT_TRUE(extension); | 697 EXPECT_TRUE(extension); |
| 702 EXPECT_FALSE(service->IsExtensionEnabled(kExtensionId)); | 698 EXPECT_FALSE(service->IsExtensionEnabled(kExtensionId)); |
| 703 | 699 |
| 704 // Install the policy again. It should overwrite the extension's location, | 700 // Install the policy again. It should overwrite the extension's location, |
| 705 // and force enable it too. | 701 // and force enable it too. |
| 706 policies.Set(policy::key::kExtensionInstallForcelist, | 702 policies.Set(policy::key::kExtensionInstallForcelist, |
| 707 policy::POLICY_LEVEL_MANDATORY, | 703 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER, |
| 708 policy::POLICY_SCOPE_USER, | 704 policy::POLICY_SOURCE_CLOUD, forcelist.CreateDeepCopy(), |
| 709 policy::POLICY_SOURCE_CLOUD, | 705 nullptr); |
| 710 forcelist.DeepCopy(), | |
| 711 NULL); | |
| 712 | 706 |
| 713 extensions::TestExtensionRegistryObserver extension_observer(registry); | 707 extensions::TestExtensionRegistryObserver extension_observer(registry); |
| 714 UpdateProviderPolicy(policies); | 708 UpdateProviderPolicy(policies); |
| 715 extension_observer.WaitForExtensionWillBeInstalled(); | 709 extension_observer.WaitForExtensionWillBeInstalled(); |
| 716 | 710 |
| 717 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); | 711 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); |
| 718 extension = service->GetExtensionById(kExtensionId, false); | 712 extension = service->GetExtensionById(kExtensionId, false); |
| 719 ASSERT_TRUE(extension); | 713 ASSERT_TRUE(extension); |
| 720 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); | 714 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); |
| 721 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); | 715 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); |
| 722 EXPECT_TRUE(registry->disabled_extensions().is_empty()); | 716 EXPECT_TRUE(registry->disabled_extensions().is_empty()); |
| 723 } | 717 } |
| OLD | NEW |