Chromium Code Reviews| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 #include "chrome/browser/background/background_contents_service.h" | 31 #include "chrome/browser/background/background_contents_service.h" |
| 32 #include "chrome/browser/browser_process.h" | 32 #include "chrome/browser/browser_process.h" |
| 33 #include "chrome/browser/chrome_notification_types.h" | 33 #include "chrome/browser/chrome_notification_types.h" |
| 34 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 34 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 35 #include "chrome/browser/devtools/devtools_window_testing.h" | 35 #include "chrome/browser/devtools/devtools_window_testing.h" |
| 36 #include "chrome/browser/download/download_prefs.h" | 36 #include "chrome/browser/download/download_prefs.h" |
| 37 #include "chrome/browser/extensions/api/messaging/message_service.h" | 37 #include "chrome/browser/extensions/api/messaging/message_service.h" |
| 38 #include "chrome/browser/extensions/crx_installer.h" | 38 #include "chrome/browser/extensions/crx_installer.h" |
| 39 #include "chrome/browser/extensions/extension_management_constants.h" | 39 #include "chrome/browser/extensions/extension_management_constants.h" |
| 40 #include "chrome/browser/extensions/extension_service.h" | 40 #include "chrome/browser/extensions/extension_service.h" |
| 41 #include "chrome/browser/extensions/shared_module_service.h" | |
| 41 #include "chrome/browser/extensions/unpacked_installer.h" | 42 #include "chrome/browser/extensions/unpacked_installer.h" |
| 42 #include "chrome/browser/extensions/updater/extension_cache_fake.h" | 43 #include "chrome/browser/extensions/updater/extension_cache_fake.h" |
| 43 #include "chrome/browser/extensions/updater/extension_updater.h" | 44 #include "chrome/browser/extensions/updater/extension_updater.h" |
| 44 #include "chrome/browser/infobars/infobar_service.h" | 45 #include "chrome/browser/infobars/infobar_service.h" |
| 45 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 46 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| 46 #include "chrome/browser/media/media_stream_devices_controller.h" | 47 #include "chrome/browser/media/media_stream_devices_controller.h" |
| 47 #include "chrome/browser/metrics/variations/variations_service.h" | 48 #include "chrome/browser/metrics/variations/variations_service.h" |
| 48 #include "chrome/browser/net/prediction_options.h" | 49 #include "chrome/browser/net/prediction_options.h" |
| 49 #include "chrome/browser/net/ssl_config_service_manager.h" | 50 #include "chrome/browser/net/ssl_config_service_manager.h" |
| 50 #include "chrome/browser/net/url_request_mock_util.h" | 51 #include "chrome/browser/net/url_request_mock_util.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 #include "content/public/common/process_type.h" | 118 #include "content/public/common/process_type.h" |
| 118 #include "content/public/common/result_codes.h" | 119 #include "content/public/common/result_codes.h" |
| 119 #include "content/public/common/url_constants.h" | 120 #include "content/public/common/url_constants.h" |
| 120 #include "content/public/common/webplugininfo.h" | 121 #include "content/public/common/webplugininfo.h" |
| 121 #include "content/public/test/browser_test_utils.h" | 122 #include "content/public/test/browser_test_utils.h" |
| 122 #include "content/public/test/download_test_observer.h" | 123 #include "content/public/test/download_test_observer.h" |
| 123 #include "content/public/test/mock_notification_observer.h" | 124 #include "content/public/test/mock_notification_observer.h" |
| 124 #include "content/public/test/test_navigation_observer.h" | 125 #include "content/public/test/test_navigation_observer.h" |
| 125 #include "content/public/test/test_utils.h" | 126 #include "content/public/test/test_utils.h" |
| 126 #include "extensions/browser/extension_host.h" | 127 #include "extensions/browser/extension_host.h" |
| 128 #include "extensions/browser/extension_registry.h" | |
| 127 #include "extensions/browser/extension_system.h" | 129 #include "extensions/browser/extension_system.h" |
| 128 #include "extensions/browser/process_manager.h" | 130 #include "extensions/browser/process_manager.h" |
| 131 #include "extensions/browser/test_extension_registry_observer.h" | |
| 129 #include "extensions/browser/uninstall_reason.h" | 132 #include "extensions/browser/uninstall_reason.h" |
| 130 #include "extensions/common/constants.h" | 133 #include "extensions/common/constants.h" |
| 131 #include "extensions/common/extension.h" | 134 #include "extensions/common/extension.h" |
| 132 #include "extensions/common/extension_set.h" | 135 #include "extensions/common/extension_set.h" |
| 136 #include "extensions/common/manifest_handlers/shared_module_info.h" | |
| 133 #include "net/base/net_errors.h" | 137 #include "net/base/net_errors.h" |
| 134 #include "net/base/net_util.h" | 138 #include "net/base/net_util.h" |
| 135 #include "net/base/url_util.h" | 139 #include "net/base/url_util.h" |
| 136 #include "net/http/http_stream_factory.h" | 140 #include "net/http/http_stream_factory.h" |
| 137 #include "net/ssl/ssl_config.h" | 141 #include "net/ssl/ssl_config.h" |
| 138 #include "net/ssl/ssl_config_service.h" | 142 #include "net/ssl/ssl_config_service.h" |
| 139 #include "net/test/url_request/url_request_failed_job.h" | 143 #include "net/test/url_request/url_request_failed_job.h" |
| 140 #include "net/test/url_request/url_request_mock_http_job.h" | 144 #include "net/test/url_request/url_request_mock_http_job.h" |
| 141 #include "net/url_request/url_request.h" | 145 #include "net/url_request/url_request.h" |
| 142 #include "net/url_request/url_request_filter.h" | 146 #include "net/url_request/url_request_filter.h" |
| (...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1597 // AdBlock was automatically removed. | 1601 // AdBlock was automatically removed. |
| 1598 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); | 1602 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); |
| 1599 | 1603 |
| 1600 // And can't be installed again, nor can good.crx. | 1604 // And can't be installed again, nor can good.crx. |
| 1601 EXPECT_FALSE(InstallExtension(kAdBlockCrxName)); | 1605 EXPECT_FALSE(InstallExtension(kAdBlockCrxName)); |
| 1602 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); | 1606 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); |
| 1603 EXPECT_FALSE(InstallExtension(kGoodCrxName)); | 1607 EXPECT_FALSE(InstallExtension(kGoodCrxName)); |
| 1604 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1608 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
| 1605 } | 1609 } |
| 1606 | 1610 |
| 1611 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallBlacklistSharedModules) { | |
| 1612 // Verifies that shared_modules are not affected by the blacklist. | |
| 1613 | |
| 1614 const char kImporterId[] = "pchakhniekfaeoddkifplhnfbffomabh"; | |
| 1615 const char kSharedModuleId[] = "nfgclafboonjbiafbllihiailjlhelpm"; | |
|
elijahtaylor1
2014/10/22 16:40:01
be careful if you are using a new ID that is not w
Joao da Silva
2014/10/22 18:31:05
Thanks for the tip. I'll fake the channel.
| |
| 1616 | |
| 1617 // Verify that the extensions are not installed initially. | |
| 1618 ExtensionService* service = extension_service(); | |
| 1619 ASSERT_FALSE(service->GetExtensionById(kImporterId, true)); | |
| 1620 ASSERT_FALSE(service->GetExtensionById(kSharedModuleId, true)); | |
| 1621 | |
| 1622 // Mock the webstore update URL. This is where the shared module extension | |
| 1623 // will be installed from. | |
| 1624 base::FilePath update_xml_path = base::FilePath(kTestExtensionsDir) | |
| 1625 .Append("policy_shared_module") | |
| 1626 .Append("update.xml"); | |
| 1627 GURL update_xml_url(URLRequestMockHTTPJob::GetMockUrl(update_xml_path)); | |
| 1628 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
| 1629 switches::kAppsGalleryUpdateURL, update_xml_url.spec()); | |
| 1630 ui_test_utils::NavigateToURL(browser(), update_xml_url); | |
| 1631 | |
| 1632 // Blacklist "*" but force-install the importer extension. The shared module | |
| 1633 // should be automatically installed too. | |
| 1634 base::ListValue blacklist; | |
| 1635 blacklist.AppendString("*"); | |
| 1636 base::ListValue forcelist; | |
| 1637 forcelist.AppendString( | |
| 1638 base::StringPrintf("%s;%s", kImporterId, update_xml_url.spec().c_str())); | |
| 1639 PolicyMap policies; | |
| 1640 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, | |
| 1641 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | |
| 1642 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY, | |
| 1643 POLICY_SCOPE_USER, forcelist.DeepCopy(), NULL); | |
| 1644 | |
| 1645 extensions::ExtensionRegistry* registry = | |
| 1646 extensions::ExtensionRegistry::Get(browser()->profile()); | |
| 1647 extensions::TestExtensionRegistryObserver observe_importer( | |
| 1648 registry, kImporterId); | |
| 1649 extensions::TestExtensionRegistryObserver observe_shared_module( | |
| 1650 registry, kSharedModuleId); | |
| 1651 UpdateProviderPolicy(policies); | |
| 1652 observe_importer.WaitForExtensionLoaded(); | |
| 1653 observe_shared_module.WaitForExtensionLoaded(); | |
| 1654 | |
| 1655 // Verify that both extensions got installed. | |
| 1656 const extensions::Extension* importer = | |
| 1657 service->GetExtensionById(kImporterId, true); | |
| 1658 ASSERT_TRUE(importer); | |
| 1659 EXPECT_EQ(kImporterId, importer->id()); | |
| 1660 const extensions::Extension* shared_module = | |
| 1661 service->GetExtensionById(kSharedModuleId, true); | |
| 1662 ASSERT_TRUE(shared_module); | |
| 1663 EXPECT_EQ(kSharedModuleId, shared_module->id()); | |
| 1664 EXPECT_TRUE(shared_module->is_shared_module()); | |
| 1665 | |
| 1666 // Verify the dependency. | |
| 1667 scoped_ptr<extensions::ExtensionSet> set = | |
| 1668 service->shared_module_service()->GetDependentExtensions(shared_module); | |
| 1669 ASSERT_TRUE(set); | |
| 1670 EXPECT_EQ(1u, set->size()); | |
| 1671 EXPECT_TRUE(set->Contains(importer->id())); | |
| 1672 | |
| 1673 std::vector<extensions::SharedModuleInfo::ImportInfo> imports = | |
| 1674 extensions::SharedModuleInfo::GetImports(importer); | |
| 1675 ASSERT_EQ(1u, imports.size()); | |
| 1676 EXPECT_EQ(kSharedModuleId, imports[0].extension_id); | |
| 1677 } | |
| 1678 | |
| 1607 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallWhitelist) { | 1679 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallWhitelist) { |
| 1608 // Verifies that the whitelist can open exceptions to the blacklist. | 1680 // Verifies that the whitelist can open exceptions to the blacklist. |
| 1609 ExtensionService* service = extension_service(); | 1681 ExtensionService* service = extension_service(); |
| 1610 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1682 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
| 1611 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); | 1683 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); |
| 1612 base::ListValue blacklist; | 1684 base::ListValue blacklist; |
| 1613 blacklist.Append(new base::StringValue("*")); | 1685 blacklist.Append(new base::StringValue("*")); |
| 1614 base::ListValue whitelist; | 1686 base::ListValue whitelist; |
| 1615 whitelist.Append(new base::StringValue(kGoodCrxId)); | 1687 whitelist.Append(new base::StringValue(kGoodCrxId)); |
| 1616 PolicyMap policies; | 1688 PolicyMap policies; |
| (...skipping 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3349 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 3421 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 3350 browser2->tab_strip_model()->GetActiveWebContents(), | 3422 browser2->tab_strip_model()->GetActiveWebContents(), |
| 3351 "domAutomationController.send(window.showModalDialog !== undefined);", | 3423 "domAutomationController.send(window.showModalDialog !== undefined);", |
| 3352 &result)); | 3424 &result)); |
| 3353 EXPECT_TRUE(result); | 3425 EXPECT_TRUE(result); |
| 3354 } | 3426 } |
| 3355 | 3427 |
| 3356 #endif // !defined(CHROME_OS) | 3428 #endif // !defined(CHROME_OS) |
| 3357 | 3429 |
| 3358 } // namespace policy | 3430 } // namespace policy |
| OLD | NEW |