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/scoped_user_pref_update.h" | 8 #include "base/prefs/scoped_user_pref_update.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "chrome/browser/extensions/extension_browsertest.h" | 12 #include "chrome/browser/extensions/extension_browsertest.h" |
13 #include "chrome/browser/extensions/extension_management.h" | 13 #include "chrome/browser/extensions/extension_management.h" |
14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
15 #include "chrome/browser/extensions/updater/extension_updater.h" | 15 #include "chrome/browser/extensions/updater/extension_updater.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
18 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
19 #include "components/policy/core/browser/browser_policy_connector.h" | 19 #include "components/policy/core/browser/browser_policy_connector.h" |
20 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 20 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
21 #include "components/policy/core/common/policy_map.h" | 21 #include "components/policy/core/common/policy_map.h" |
| 22 #include "components/policy/core/common/policy_types.h" |
22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
23 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
24 #include "content/public/browser/render_view_host.h" | 25 #include "content/public/browser/render_view_host.h" |
25 #include "content/public/test/browser_test_utils.h" | 26 #include "content/public/test/browser_test_utils.h" |
26 #include "extensions/browser/extension_host.h" | 27 #include "extensions/browser/extension_host.h" |
27 #include "extensions/browser/extension_prefs.h" | 28 #include "extensions/browser/extension_prefs.h" |
28 #include "extensions/browser/extension_registry.h" | 29 #include "extensions/browser/extension_registry.h" |
29 #include "extensions/browser/extension_system.h" | 30 #include "extensions/browser/extension_system.h" |
30 #include "extensions/browser/notification_types.h" | 31 #include "extensions/browser/notification_types.h" |
31 #include "extensions/browser/updater/extension_downloader.h" | 32 #include "extensions/browser/updater/extension_downloader.h" |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 ->empty()) | 556 ->empty()) |
556 << kForceInstallNotEmptyHelp; | 557 << kForceInstallNotEmptyHelp; |
557 | 558 |
558 base::ListValue forcelist; | 559 base::ListValue forcelist; |
559 forcelist.AppendString(BuildForceInstallPolicyValue( | 560 forcelist.AppendString(BuildForceInstallPolicyValue( |
560 kExtensionId, "http://localhost/autoupdate/manifest")); | 561 kExtensionId, "http://localhost/autoupdate/manifest")); |
561 PolicyMap policies; | 562 PolicyMap policies; |
562 policies.Set(policy::key::kExtensionInstallForcelist, | 563 policies.Set(policy::key::kExtensionInstallForcelist, |
563 policy::POLICY_LEVEL_MANDATORY, | 564 policy::POLICY_LEVEL_MANDATORY, |
564 policy::POLICY_SCOPE_USER, | 565 policy::POLICY_SCOPE_USER, |
| 566 policy::POLICY_SOURCE_CLOUD, |
565 forcelist.DeepCopy(), | 567 forcelist.DeepCopy(), |
566 NULL); | 568 NULL); |
567 UpdateProviderPolicy(policies); | 569 UpdateProviderPolicy(policies); |
568 | 570 |
569 // Check if the extension got installed. | 571 // Check if the extension got installed. |
570 ASSERT_TRUE(WaitForExtensionInstall()); | 572 ASSERT_TRUE(WaitForExtensionInstall()); |
571 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); | 573 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); |
572 const Extension* extension = service->GetExtensionById(kExtensionId, false); | 574 const Extension* extension = service->GetExtensionById(kExtensionId, false); |
573 ASSERT_TRUE(extension); | 575 ASSERT_TRUE(extension); |
574 ASSERT_EQ("2.0", extension->VersionString()); | 576 ASSERT_EQ("2.0", extension->VersionString()); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); | 646 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); |
645 | 647 |
646 // Setup the force install policy. It should override the location. | 648 // Setup the force install policy. It should override the location. |
647 base::ListValue forcelist; | 649 base::ListValue forcelist; |
648 forcelist.AppendString(BuildForceInstallPolicyValue( | 650 forcelist.AppendString(BuildForceInstallPolicyValue( |
649 kExtensionId, "http://localhost/autoupdate/manifest")); | 651 kExtensionId, "http://localhost/autoupdate/manifest")); |
650 PolicyMap policies; | 652 PolicyMap policies; |
651 policies.Set(policy::key::kExtensionInstallForcelist, | 653 policies.Set(policy::key::kExtensionInstallForcelist, |
652 policy::POLICY_LEVEL_MANDATORY, | 654 policy::POLICY_LEVEL_MANDATORY, |
653 policy::POLICY_SCOPE_USER, | 655 policy::POLICY_SCOPE_USER, |
| 656 policy::POLICY_SOURCE_CLOUD, |
654 forcelist.DeepCopy(), | 657 forcelist.DeepCopy(), |
655 NULL); | 658 NULL); |
656 UpdateProviderPolicy(policies); | 659 UpdateProviderPolicy(policies); |
657 | 660 |
658 ASSERT_TRUE(WaitForExtensionInstall()); | 661 ASSERT_TRUE(WaitForExtensionInstall()); |
659 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); | 662 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); |
660 extension = service->GetExtensionById(kExtensionId, false); | 663 extension = service->GetExtensionById(kExtensionId, false); |
661 ASSERT_TRUE(extension); | 664 ASSERT_TRUE(extension); |
662 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); | 665 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); |
663 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); | 666 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); |
(...skipping 21 matching lines...) Expand all Loading... |
685 EXPECT_EQ(1u, registry->disabled_extensions().size()); | 688 EXPECT_EQ(1u, registry->disabled_extensions().size()); |
686 extension = service->GetExtensionById(kExtensionId, true); | 689 extension = service->GetExtensionById(kExtensionId, true); |
687 EXPECT_TRUE(extension); | 690 EXPECT_TRUE(extension); |
688 EXPECT_FALSE(service->IsExtensionEnabled(kExtensionId)); | 691 EXPECT_FALSE(service->IsExtensionEnabled(kExtensionId)); |
689 | 692 |
690 // Install the policy again. It should overwrite the extension's location, | 693 // Install the policy again. It should overwrite the extension's location, |
691 // and force enable it too. | 694 // and force enable it too. |
692 policies.Set(policy::key::kExtensionInstallForcelist, | 695 policies.Set(policy::key::kExtensionInstallForcelist, |
693 policy::POLICY_LEVEL_MANDATORY, | 696 policy::POLICY_LEVEL_MANDATORY, |
694 policy::POLICY_SCOPE_USER, | 697 policy::POLICY_SCOPE_USER, |
| 698 policy::POLICY_SOURCE_CLOUD, |
695 forcelist.DeepCopy(), | 699 forcelist.DeepCopy(), |
696 NULL); | 700 NULL); |
697 UpdateProviderPolicy(policies); | 701 UpdateProviderPolicy(policies); |
698 | 702 |
699 ASSERT_TRUE(WaitForExtensionInstall()); | 703 ASSERT_TRUE(WaitForExtensionInstall()); |
700 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); | 704 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); |
701 extension = service->GetExtensionById(kExtensionId, false); | 705 extension = service->GetExtensionById(kExtensionId, false); |
702 ASSERT_TRUE(extension); | 706 ASSERT_TRUE(extension); |
703 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); | 707 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); |
704 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); | 708 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); |
705 EXPECT_TRUE(registry->disabled_extensions().is_empty()); | 709 EXPECT_TRUE(registry->disabled_extensions().is_empty()); |
706 } | 710 } |
OLD | NEW |