Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: chrome/browser/extensions/api/management/management_browsertest.cc

Issue 1348903007: Revert of Add source column to chrome://policy showing the origins of policies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
23 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
25 #include "content/public/browser/render_view_host.h" 24 #include "content/public/browser/render_view_host.h"
26 #include "content/public/test/browser_test_utils.h" 25 #include "content/public/test/browser_test_utils.h"
27 #include "extensions/browser/extension_host.h" 26 #include "extensions/browser/extension_host.h"
28 #include "extensions/browser/extension_prefs.h" 27 #include "extensions/browser/extension_prefs.h"
29 #include "extensions/browser/extension_registry.h" 28 #include "extensions/browser/extension_registry.h"
30 #include "extensions/browser/extension_system.h" 29 #include "extensions/browser/extension_system.h"
31 #include "extensions/browser/notification_types.h" 30 #include "extensions/browser/notification_types.h"
32 #include "extensions/browser/updater/extension_downloader.h" 31 #include "extensions/browser/updater/extension_downloader.h"
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 ->empty()) 555 ->empty())
557 << kForceInstallNotEmptyHelp; 556 << kForceInstallNotEmptyHelp;
558 557
559 base::ListValue forcelist; 558 base::ListValue forcelist;
560 forcelist.AppendString(BuildForceInstallPolicyValue( 559 forcelist.AppendString(BuildForceInstallPolicyValue(
561 kExtensionId, "http://localhost/autoupdate/manifest")); 560 kExtensionId, "http://localhost/autoupdate/manifest"));
562 PolicyMap policies; 561 PolicyMap policies;
563 policies.Set(policy::key::kExtensionInstallForcelist, 562 policies.Set(policy::key::kExtensionInstallForcelist,
564 policy::POLICY_LEVEL_MANDATORY, 563 policy::POLICY_LEVEL_MANDATORY,
565 policy::POLICY_SCOPE_USER, 564 policy::POLICY_SCOPE_USER,
566 policy::POLICY_SOURCE_CLOUD,
567 forcelist.DeepCopy(), 565 forcelist.DeepCopy(),
568 NULL); 566 NULL);
569 UpdateProviderPolicy(policies); 567 UpdateProviderPolicy(policies);
570 568
571 // Check if the extension got installed. 569 // Check if the extension got installed.
572 ASSERT_TRUE(WaitForExtensionInstall()); 570 ASSERT_TRUE(WaitForExtensionInstall());
573 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); 571 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size());
574 const Extension* extension = service->GetExtensionById(kExtensionId, false); 572 const Extension* extension = service->GetExtensionById(kExtensionId, false);
575 ASSERT_TRUE(extension); 573 ASSERT_TRUE(extension);
576 ASSERT_EQ("2.0", extension->VersionString()); 574 ASSERT_EQ("2.0", extension->VersionString());
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); 644 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId));
647 645
648 // Setup the force install policy. It should override the location. 646 // Setup the force install policy. It should override the location.
649 base::ListValue forcelist; 647 base::ListValue forcelist;
650 forcelist.AppendString(BuildForceInstallPolicyValue( 648 forcelist.AppendString(BuildForceInstallPolicyValue(
651 kExtensionId, "http://localhost/autoupdate/manifest")); 649 kExtensionId, "http://localhost/autoupdate/manifest"));
652 PolicyMap policies; 650 PolicyMap policies;
653 policies.Set(policy::key::kExtensionInstallForcelist, 651 policies.Set(policy::key::kExtensionInstallForcelist,
654 policy::POLICY_LEVEL_MANDATORY, 652 policy::POLICY_LEVEL_MANDATORY,
655 policy::POLICY_SCOPE_USER, 653 policy::POLICY_SCOPE_USER,
656 policy::POLICY_SOURCE_CLOUD,
657 forcelist.DeepCopy(), 654 forcelist.DeepCopy(),
658 NULL); 655 NULL);
659 UpdateProviderPolicy(policies); 656 UpdateProviderPolicy(policies);
660 657
661 ASSERT_TRUE(WaitForExtensionInstall()); 658 ASSERT_TRUE(WaitForExtensionInstall());
662 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); 659 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size());
663 extension = service->GetExtensionById(kExtensionId, false); 660 extension = service->GetExtensionById(kExtensionId, false);
664 ASSERT_TRUE(extension); 661 ASSERT_TRUE(extension);
665 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); 662 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location());
666 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); 663 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId));
(...skipping 21 matching lines...) Expand all
688 EXPECT_EQ(1u, registry->disabled_extensions().size()); 685 EXPECT_EQ(1u, registry->disabled_extensions().size());
689 extension = service->GetExtensionById(kExtensionId, true); 686 extension = service->GetExtensionById(kExtensionId, true);
690 EXPECT_TRUE(extension); 687 EXPECT_TRUE(extension);
691 EXPECT_FALSE(service->IsExtensionEnabled(kExtensionId)); 688 EXPECT_FALSE(service->IsExtensionEnabled(kExtensionId));
692 689
693 // Install the policy again. It should overwrite the extension's location, 690 // Install the policy again. It should overwrite the extension's location,
694 // and force enable it too. 691 // and force enable it too.
695 policies.Set(policy::key::kExtensionInstallForcelist, 692 policies.Set(policy::key::kExtensionInstallForcelist,
696 policy::POLICY_LEVEL_MANDATORY, 693 policy::POLICY_LEVEL_MANDATORY,
697 policy::POLICY_SCOPE_USER, 694 policy::POLICY_SCOPE_USER,
698 policy::POLICY_SOURCE_CLOUD,
699 forcelist.DeepCopy(), 695 forcelist.DeepCopy(),
700 NULL); 696 NULL);
701 UpdateProviderPolicy(policies); 697 UpdateProviderPolicy(policies);
702 698
703 ASSERT_TRUE(WaitForExtensionInstall()); 699 ASSERT_TRUE(WaitForExtensionInstall());
704 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); 700 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size());
705 extension = service->GetExtensionById(kExtensionId, false); 701 extension = service->GetExtensionById(kExtensionId, false);
706 ASSERT_TRUE(extension); 702 ASSERT_TRUE(extension);
707 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); 703 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location());
708 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); 704 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId));
709 EXPECT_TRUE(registry->disabled_extensions().is_empty()); 705 EXPECT_TRUE(registry->disabled_extensions().is_empty());
710 } 706 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698