| Index: chrome/browser/extensions/crx_installer_browsertest.cc
|
| diff --git a/chrome/browser/extensions/crx_installer_browsertest.cc b/chrome/browser/extensions/crx_installer_browsertest.cc
|
| index b38c6b07e3463e88372fdfeca518da7943f48c83..b2517197fe5b236e9a5a6c1b9ed1e549e7f09fcc 100644
|
| --- a/chrome/browser/extensions/crx_installer_browsertest.cc
|
| +++ b/chrome/browser/extensions/crx_installer_browsertest.cc
|
| @@ -14,6 +14,7 @@
|
| #include "chrome/browser/extensions/extension_service.h"
|
| #include "chrome/browser/extensions/extension_util.h"
|
| #include "chrome/browser/extensions/fake_safe_browsing_database_manager.h"
|
| +#include "chrome/browser/extensions/test_extension_dir.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/ui/browser.h"
|
| #include "chrome/browser/ui/browser_window.h"
|
| @@ -27,6 +28,7 @@
|
| #include "content/public/test/download_test_observer.h"
|
| #include "content/public/test/test_utils.h"
|
| #include "extensions/browser/extension_prefs.h"
|
| +#include "extensions/browser/extension_registry.h"
|
| #include "extensions/browser/extension_system.h"
|
| #include "extensions/browser/management_policy.h"
|
| #include "extensions/browser/notification_types.h"
|
| @@ -238,15 +240,15 @@ class ExtensionCrxInstallerTest : public ExtensionBrowserTest {
|
| #if !defined(OS_CHROMEOS)
|
| IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, Whitelisting) {
|
| std::string id = "hdgllgikmikobbofgnabhfimcfoopgnd";
|
| - ExtensionService* service = extensions::ExtensionSystem::Get(
|
| - browser()->profile())->extension_service();
|
| + ExtensionRegistry* registry = ExtensionRegistry::Get(
|
| + browser()->profile());
|
|
|
| // Even whitelisted extensions with NPAPI should not prompt.
|
| scoped_refptr<MockPromptProxy> mock_prompt =
|
| CreateMockPromptProxyForBrowser(browser());
|
| InstallWithPrompt("uitest/plugins", id, mock_prompt);
|
| EXPECT_FALSE(mock_prompt->confirmation_requested());
|
| - EXPECT_TRUE(service->GetExtensionById(id, false));
|
| + EXPECT_TRUE(registry->enabled_extensions().GetByID(id));
|
| }
|
| #endif
|
|
|
| @@ -373,16 +375,15 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, HiDpiThemeTest) {
|
| ASSERT_TRUE(InstallExtension(crx_path, 1));
|
|
|
| const std::string extension_id("gllekhaobjnhgeagipipnkpmmmpchacm");
|
| - ExtensionService* service = extensions::ExtensionSystem::Get(
|
| - browser()->profile())->extension_service();
|
| - ASSERT_TRUE(service);
|
| + ExtensionRegistry* registry = ExtensionRegistry::Get(
|
| + browser()->profile());
|
| const extensions::Extension* extension =
|
| - service->GetExtensionById(extension_id, false);
|
| + registry->enabled_extensions().GetByID(extension_id);
|
| ASSERT_TRUE(extension);
|
| EXPECT_EQ(extension_id, extension->id());
|
|
|
| UninstallExtension(extension_id);
|
| - EXPECT_FALSE(service->GetExtensionById(extension_id, false));
|
| + EXPECT_FALSE(registry->enabled_extensions().GetByID(extension_id));
|
| }
|
|
|
| // See http://crbug.com/315299.
|
| @@ -400,12 +401,15 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest,
|
| browser()->profile());
|
| ExtensionService* service = extension_system->extension_service();
|
| ASSERT_TRUE(service);
|
| + ExtensionRegistry* registry = ExtensionRegistry::Get(
|
| + browser()->profile());
|
| + ASSERT_TRUE(registry);
|
|
|
| // Install version 1 of the test extension. This extension does not have
|
| // a background page but does have a browser action.
|
| ASSERT_TRUE(InstallExtension(crx_path.AppendASCII("v1.crx"), 1));
|
| const extensions::Extension* extension =
|
| - service->GetExtensionById(extension_id, false);
|
| + registry->enabled_extensions().GetByID(extension_id);
|
| ASSERT_TRUE(extension);
|
| ASSERT_EQ(extension_id, extension->id());
|
| ASSERT_EQ("1.0", extension->version()->GetString());
|
| @@ -428,7 +432,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest,
|
| extension_id, crx_path.AppendASCII("v2.crx"), 0));
|
|
|
| ASSERT_EQ(1u, service->delayed_installs()->size());
|
| - extension = service->GetExtensionById(extension_id, false);
|
| + extension = registry->enabled_extensions().GetByID(extension_id);
|
| ASSERT_EQ("1.0", extension->version()->GetString());
|
|
|
| // Make the extension idle again by closing the popup. This should not trigger
|
| @@ -444,14 +448,14 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest,
|
| // this install should succeed.
|
| ASSERT_TRUE(UpdateExtensionWaitForIdle(
|
| extension_id, crx_path.AppendASCII("v3.crx"), 0));
|
| - extension = service->GetExtensionById(extension_id, false);
|
| + extension = registry->enabled_extensions().GetByID(extension_id);
|
| ASSERT_EQ("3.0", extension->version()->GetString());
|
|
|
| // The version 2 delayed install should be cleaned up, and finishing
|
| // delayed extension installation shouldn't break anything.
|
| ASSERT_EQ(0u, service->delayed_installs()->size());
|
| service->MaybeFinishDelayedInstallations();
|
| - extension = service->GetExtensionById(extension_id, false);
|
| + extension = registry->enabled_extensions().GetByID(extension_id);
|
| ASSERT_EQ("3.0", extension->version()->GetString());
|
| }
|
|
|
| @@ -522,9 +526,9 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, InstallToSharedLocation) {
|
|
|
| std::string extension_id = extension->id();
|
| UninstallExtension(extension_id);
|
| - ExtensionService* service = extensions::ExtensionSystem::Get(
|
| - browser()->profile())->extension_service();
|
| - EXPECT_FALSE(service->GetExtensionById(extension_id, false));
|
| + ExtensionRegistry* registry = ExtensionRegistry::Get(
|
| + browser()->profile());
|
| + EXPECT_FALSE(registry->enabled_extensions().GetByID(extension_id));
|
|
|
| content::RunAllBlockingPoolTasksUntilIdle();
|
|
|
| @@ -559,4 +563,42 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, ManagementPolicy) {
|
| EXPECT_FALSE(InstallExtension(crx_path, 0));
|
| }
|
|
|
| +IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, WithheldElevationCheck) {
|
| + // Enable consent flag and install extension. The <all_hosts> permission will
|
| + // be withheld.
|
| + scoped_ptr<FeatureSwitch::ScopedOverride> enable_scripts_switch(
|
| + new FeatureSwitch::ScopedOverride(
|
| + FeatureSwitch::scripts_require_action(), true));
|
| +
|
| + const char kManifest[] =
|
| + "{"
|
| + " \"name\": \"Withheld test\","
|
| + " \"version\": \"1.0\","
|
| + " \"permissions\": ["
|
| + " \"http://*/*\""
|
| + " ],"
|
| + " \"manifest_version\": 2"
|
| + "}";
|
| + TestExtensionDir dir;
|
| + dir.WriteManifest(kManifest);
|
| + base::FilePath crx_path = dir.Pack();
|
| + EXPECT_FALSE(crx_path.empty());
|
| + const Extension* extension = InstallExtension(crx_path, 1);
|
| + EXPECT_TRUE(base::PathExists(extension->path()));
|
| +
|
| + std::string extension_id = extension->id();
|
| + ExtensionRegistry* registry = ExtensionRegistry::Get(
|
| + browser()->profile());
|
| + EXPECT_TRUE(registry->enabled_extensions().GetByID(extension_id));
|
| +
|
| + // Disable consent flag and reinstall extension. It should now be disabled
|
| + // because previously withheld permissions are now being requested.
|
| + enable_scripts_switch.reset();
|
| + extension = InstallExtension(crx_path, -1);
|
| + EXPECT_FALSE(registry->enabled_extensions().GetByID(extension_id));
|
| + EXPECT_TRUE(registry->disabled_extensions().GetByID(extension_id));
|
| + EXPECT_TRUE(ExtensionPrefs::Get(browser()->profile())->GetDisableReasons(
|
| + extension_id) & Extension::DISABLE_PERMISSIONS_INCREASE);
|
| +}
|
| +
|
| } // namespace extensions
|
|
|