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 17 matching lines...) Expand all Loading... |
68 #include "chrome/browser/ui/browser_tabstrip.h" | 69 #include "chrome/browser/ui/browser_tabstrip.h" |
69 #include "chrome/browser/ui/browser_window.h" | 70 #include "chrome/browser/ui/browser_window.h" |
70 #include "chrome/browser/ui/host_desktop.h" | 71 #include "chrome/browser/ui/host_desktop.h" |
71 #include "chrome/browser/ui/location_bar/location_bar.h" | 72 #include "chrome/browser/ui/location_bar/location_bar.h" |
72 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 73 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
73 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 74 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
74 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 75 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
75 #include "chrome/common/chrome_paths.h" | 76 #include "chrome/common/chrome_paths.h" |
76 #include "chrome/common/chrome_switches.h" | 77 #include "chrome/common/chrome_switches.h" |
77 #include "chrome/common/extensions/extension_constants.h" | 78 #include "chrome/common/extensions/extension_constants.h" |
| 79 #include "chrome/common/extensions/features/feature_channel.h" |
78 #include "chrome/common/pref_names.h" | 80 #include "chrome/common/pref_names.h" |
79 #include "chrome/common/url_constants.h" | 81 #include "chrome/common/url_constants.h" |
80 #include "chrome/grit/generated_resources.h" | 82 #include "chrome/grit/generated_resources.h" |
81 #include "chrome/test/base/in_process_browser_test.h" | 83 #include "chrome/test/base/in_process_browser_test.h" |
82 #include "chrome/test/base/test_switches.h" | 84 #include "chrome/test/base/test_switches.h" |
83 #include "chrome/test/base/ui_test_utils.h" | 85 #include "chrome/test/base/ui_test_utils.h" |
84 #include "components/content_settings/core/common/content_settings.h" | 86 #include "components/content_settings/core/common/content_settings.h" |
85 #include "components/content_settings/core/common/content_settings_pattern.h" | 87 #include "components/content_settings/core/common/content_settings_pattern.h" |
86 #include "components/infobars/core/infobar.h" | 88 #include "components/infobars/core/infobar.h" |
87 #include "components/policy/core/browser/browser_policy_connector.h" | 89 #include "components/policy/core/browser/browser_policy_connector.h" |
(...skipping 29 matching lines...) Expand all Loading... |
117 #include "content/public/common/process_type.h" | 119 #include "content/public/common/process_type.h" |
118 #include "content/public/common/result_codes.h" | 120 #include "content/public/common/result_codes.h" |
119 #include "content/public/common/url_constants.h" | 121 #include "content/public/common/url_constants.h" |
120 #include "content/public/common/webplugininfo.h" | 122 #include "content/public/common/webplugininfo.h" |
121 #include "content/public/test/browser_test_utils.h" | 123 #include "content/public/test/browser_test_utils.h" |
122 #include "content/public/test/download_test_observer.h" | 124 #include "content/public/test/download_test_observer.h" |
123 #include "content/public/test/mock_notification_observer.h" | 125 #include "content/public/test/mock_notification_observer.h" |
124 #include "content/public/test/test_navigation_observer.h" | 126 #include "content/public/test/test_navigation_observer.h" |
125 #include "content/public/test/test_utils.h" | 127 #include "content/public/test/test_utils.h" |
126 #include "extensions/browser/extension_host.h" | 128 #include "extensions/browser/extension_host.h" |
| 129 #include "extensions/browser/extension_registry.h" |
127 #include "extensions/browser/extension_system.h" | 130 #include "extensions/browser/extension_system.h" |
128 #include "extensions/browser/process_manager.h" | 131 #include "extensions/browser/process_manager.h" |
| 132 #include "extensions/browser/test_extension_registry_observer.h" |
129 #include "extensions/browser/uninstall_reason.h" | 133 #include "extensions/browser/uninstall_reason.h" |
130 #include "extensions/common/constants.h" | 134 #include "extensions/common/constants.h" |
131 #include "extensions/common/extension.h" | 135 #include "extensions/common/extension.h" |
132 #include "extensions/common/extension_set.h" | 136 #include "extensions/common/extension_set.h" |
| 137 #include "extensions/common/manifest_handlers/shared_module_info.h" |
133 #include "net/base/net_errors.h" | 138 #include "net/base/net_errors.h" |
134 #include "net/base/net_util.h" | 139 #include "net/base/net_util.h" |
135 #include "net/base/url_util.h" | 140 #include "net/base/url_util.h" |
136 #include "net/http/http_stream_factory.h" | 141 #include "net/http/http_stream_factory.h" |
137 #include "net/ssl/ssl_config.h" | 142 #include "net/ssl/ssl_config.h" |
138 #include "net/ssl/ssl_config_service.h" | 143 #include "net/ssl/ssl_config_service.h" |
139 #include "net/test/url_request/url_request_failed_job.h" | 144 #include "net/test/url_request/url_request_failed_job.h" |
140 #include "net/test/url_request/url_request_mock_http_job.h" | 145 #include "net/test/url_request/url_request_mock_http_job.h" |
141 #include "net/url_request/url_request.h" | 146 #include "net/url_request/url_request.h" |
142 #include "net/url_request/url_request_filter.h" | 147 #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. | 1602 // AdBlock was automatically removed. |
1598 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); | 1603 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); |
1599 | 1604 |
1600 // And can't be installed again, nor can good.crx. | 1605 // And can't be installed again, nor can good.crx. |
1601 EXPECT_FALSE(InstallExtension(kAdBlockCrxName)); | 1606 EXPECT_FALSE(InstallExtension(kAdBlockCrxName)); |
1602 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); | 1607 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); |
1603 EXPECT_FALSE(InstallExtension(kGoodCrxName)); | 1608 EXPECT_FALSE(InstallExtension(kGoodCrxName)); |
1604 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1609 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
1605 } | 1610 } |
1606 | 1611 |
| 1612 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallBlacklistSharedModules) { |
| 1613 // Verifies that shared_modules are not affected by the blacklist. |
| 1614 |
| 1615 const char kImporterId[] = "pchakhniekfaeoddkifplhnfbffomabh"; |
| 1616 const char kSharedModuleId[] = "nfgclafboonjbiafbllihiailjlhelpm"; |
| 1617 |
| 1618 // Make sure that "import" and "export" are available to these extension IDs |
| 1619 // by mocking the release channel. |
| 1620 extensions::ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV); |
| 1621 |
| 1622 // Verify that the extensions are not installed initially. |
| 1623 ExtensionService* service = extension_service(); |
| 1624 ASSERT_FALSE(service->GetExtensionById(kImporterId, true)); |
| 1625 ASSERT_FALSE(service->GetExtensionById(kSharedModuleId, true)); |
| 1626 |
| 1627 // Mock the webstore update URL. This is where the shared module extension |
| 1628 // will be installed from. |
| 1629 base::FilePath update_xml_path = base::FilePath(kTestExtensionsDir) |
| 1630 .AppendASCII("policy_shared_module") |
| 1631 .AppendASCII("update.xml"); |
| 1632 GURL update_xml_url(URLRequestMockHTTPJob::GetMockUrl(update_xml_path)); |
| 1633 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 1634 switches::kAppsGalleryUpdateURL, update_xml_url.spec()); |
| 1635 ui_test_utils::NavigateToURL(browser(), update_xml_url); |
| 1636 |
| 1637 // Blacklist "*" but force-install the importer extension. The shared module |
| 1638 // should be automatically installed too. |
| 1639 base::ListValue blacklist; |
| 1640 blacklist.AppendString("*"); |
| 1641 base::ListValue forcelist; |
| 1642 forcelist.AppendString( |
| 1643 base::StringPrintf("%s;%s", kImporterId, update_xml_url.spec().c_str())); |
| 1644 PolicyMap policies; |
| 1645 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, |
| 1646 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); |
| 1647 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY, |
| 1648 POLICY_SCOPE_USER, forcelist.DeepCopy(), NULL); |
| 1649 |
| 1650 extensions::ExtensionRegistry* registry = |
| 1651 extensions::ExtensionRegistry::Get(browser()->profile()); |
| 1652 extensions::TestExtensionRegistryObserver observe_importer( |
| 1653 registry, kImporterId); |
| 1654 extensions::TestExtensionRegistryObserver observe_shared_module( |
| 1655 registry, kSharedModuleId); |
| 1656 UpdateProviderPolicy(policies); |
| 1657 observe_importer.WaitForExtensionLoaded(); |
| 1658 observe_shared_module.WaitForExtensionLoaded(); |
| 1659 |
| 1660 // Verify that both extensions got installed. |
| 1661 const extensions::Extension* importer = |
| 1662 service->GetExtensionById(kImporterId, true); |
| 1663 ASSERT_TRUE(importer); |
| 1664 EXPECT_EQ(kImporterId, importer->id()); |
| 1665 const extensions::Extension* shared_module = |
| 1666 service->GetExtensionById(kSharedModuleId, true); |
| 1667 ASSERT_TRUE(shared_module); |
| 1668 EXPECT_EQ(kSharedModuleId, shared_module->id()); |
| 1669 EXPECT_TRUE(shared_module->is_shared_module()); |
| 1670 |
| 1671 // Verify the dependency. |
| 1672 scoped_ptr<extensions::ExtensionSet> set = |
| 1673 service->shared_module_service()->GetDependentExtensions(shared_module); |
| 1674 ASSERT_TRUE(set); |
| 1675 EXPECT_EQ(1u, set->size()); |
| 1676 EXPECT_TRUE(set->Contains(importer->id())); |
| 1677 |
| 1678 std::vector<extensions::SharedModuleInfo::ImportInfo> imports = |
| 1679 extensions::SharedModuleInfo::GetImports(importer); |
| 1680 ASSERT_EQ(1u, imports.size()); |
| 1681 EXPECT_EQ(kSharedModuleId, imports[0].extension_id); |
| 1682 } |
| 1683 |
1607 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallWhitelist) { | 1684 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallWhitelist) { |
1608 // Verifies that the whitelist can open exceptions to the blacklist. | 1685 // Verifies that the whitelist can open exceptions to the blacklist. |
1609 ExtensionService* service = extension_service(); | 1686 ExtensionService* service = extension_service(); |
1610 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1687 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
1611 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); | 1688 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); |
1612 base::ListValue blacklist; | 1689 base::ListValue blacklist; |
1613 blacklist.Append(new base::StringValue("*")); | 1690 blacklist.Append(new base::StringValue("*")); |
1614 base::ListValue whitelist; | 1691 base::ListValue whitelist; |
1615 whitelist.Append(new base::StringValue(kGoodCrxId)); | 1692 whitelist.Append(new base::StringValue(kGoodCrxId)); |
1616 PolicyMap policies; | 1693 PolicyMap policies; |
(...skipping 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3349 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 3426 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
3350 browser2->tab_strip_model()->GetActiveWebContents(), | 3427 browser2->tab_strip_model()->GetActiveWebContents(), |
3351 "domAutomationController.send(window.showModalDialog !== undefined);", | 3428 "domAutomationController.send(window.showModalDialog !== undefined);", |
3352 &result)); | 3429 &result)); |
3353 EXPECT_TRUE(result); | 3430 EXPECT_TRUE(result); |
3354 } | 3431 } |
3355 | 3432 |
3356 #endif // !defined(CHROME_OS) | 3433 #endif // !defined(CHROME_OS) |
3357 | 3434 |
3358 } // namespace policy | 3435 } // namespace policy |
OLD | NEW |