| 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" |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 basedir.AppendASCII("manifest_v2.xml")); | 552 basedir.AppendASCII("manifest_v2.xml")); |
| 553 interceptor.SetResponseIgnoreQuery(GURL("http://localhost/autoupdate/v2.crx"), | 553 interceptor.SetResponseIgnoreQuery(GURL("http://localhost/autoupdate/v2.crx"), |
| 554 basedir.AppendASCII("v2.crx")); | 554 basedir.AppendASCII("v2.crx")); |
| 555 | 555 |
| 556 ExtensionRegistry* registry = ExtensionRegistry::Get(browser()->profile()); | 556 ExtensionRegistry* registry = ExtensionRegistry::Get(browser()->profile()); |
| 557 const size_t size_before = registry->enabled_extensions().size(); | 557 const size_t size_before = registry->enabled_extensions().size(); |
| 558 ASSERT_TRUE(registry->disabled_extensions().is_empty()); | 558 ASSERT_TRUE(registry->disabled_extensions().is_empty()); |
| 559 | 559 |
| 560 ASSERT_TRUE(extensions::ExtensionManagementFactory::GetForBrowserContext( | 560 ASSERT_TRUE(extensions::ExtensionManagementFactory::GetForBrowserContext( |
| 561 browser()->profile()) | 561 browser()->profile()) |
| 562 ->GetForceInstallList() | 562 ->GetAutoInstallList(true) |
| 563 ->empty()) | 563 ->empty()) |
| 564 << kForceInstallNotEmptyHelp; | 564 << kForceInstallNotEmptyHelp; |
| 565 | 565 |
| 566 base::ListValue forcelist; | 566 base::ListValue forcelist; |
| 567 forcelist.AppendString(BuildForceInstallPolicyValue( | 567 forcelist.AppendString(BuildForceInstallPolicyValue( |
| 568 kExtensionId, "http://localhost/autoupdate/manifest")); | 568 kExtensionId, "http://localhost/autoupdate/manifest")); |
| 569 PolicyMap policies; | 569 PolicyMap policies; |
| 570 policies.Set(policy::key::kExtensionInstallForcelist, | 570 policies.Set(policy::key::kExtensionInstallForcelist, |
| 571 policy::POLICY_LEVEL_MANDATORY, | 571 policy::POLICY_LEVEL_MANDATORY, |
| 572 policy::POLICY_SCOPE_USER, | 572 policy::POLICY_SCOPE_USER, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 | 633 |
| 634 interceptor.SetResponseIgnoreQuery( | 634 interceptor.SetResponseIgnoreQuery( |
| 635 GURL("http://localhost/autoupdate/manifest"), | 635 GURL("http://localhost/autoupdate/manifest"), |
| 636 basedir.AppendASCII("manifest_v2.xml")); | 636 basedir.AppendASCII("manifest_v2.xml")); |
| 637 interceptor.SetResponseIgnoreQuery(GURL("http://localhost/autoupdate/v2.crx"), | 637 interceptor.SetResponseIgnoreQuery(GURL("http://localhost/autoupdate/v2.crx"), |
| 638 basedir.AppendASCII("v2.crx")); | 638 basedir.AppendASCII("v2.crx")); |
| 639 | 639 |
| 640 // Check that the policy is initially empty. | 640 // Check that the policy is initially empty. |
| 641 ASSERT_TRUE(extensions::ExtensionManagementFactory::GetForBrowserContext( | 641 ASSERT_TRUE(extensions::ExtensionManagementFactory::GetForBrowserContext( |
| 642 browser()->profile()) | 642 browser()->profile()) |
| 643 ->GetForceInstallList() | 643 ->GetAutoInstallList(true) |
| 644 ->empty()) | 644 ->empty()) |
| 645 << kForceInstallNotEmptyHelp; | 645 << kForceInstallNotEmptyHelp; |
| 646 | 646 |
| 647 // User install of the extension. | 647 // User install of the extension. |
| 648 ASSERT_TRUE(InstallExtension(basedir.AppendASCII("v2.crx"), 1)); | 648 ASSERT_TRUE(InstallExtension(basedir.AppendASCII("v2.crx"), 1)); |
| 649 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); | 649 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); |
| 650 const Extension* extension = service->GetExtensionById(kExtensionId, false); | 650 const Extension* extension = service->GetExtensionById(kExtensionId, false); |
| 651 ASSERT_TRUE(extension); | 651 ASSERT_TRUE(extension); |
| 652 EXPECT_EQ(Manifest::INTERNAL, extension->location()); | 652 EXPECT_EQ(Manifest::INTERNAL, extension->location()); |
| 653 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); | 653 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 UpdateProviderPolicy(policies); | 706 UpdateProviderPolicy(policies); |
| 707 | 707 |
| 708 ASSERT_TRUE(WaitForExtensionInstall()); | 708 ASSERT_TRUE(WaitForExtensionInstall()); |
| 709 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); | 709 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); |
| 710 extension = service->GetExtensionById(kExtensionId, false); | 710 extension = service->GetExtensionById(kExtensionId, false); |
| 711 ASSERT_TRUE(extension); | 711 ASSERT_TRUE(extension); |
| 712 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); | 712 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); |
| 713 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); | 713 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); |
| 714 EXPECT_TRUE(registry->disabled_extensions().is_empty()); | 714 EXPECT_TRUE(registry->disabled_extensions().is_empty()); |
| 715 } | 715 } |
| OLD | NEW |