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 "chrome/browser/extensions/crx_installer.h" | 5 #include "chrome/browser/extensions/crx_installer.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, ManagementPolicy) { | 591 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, ManagementPolicy) { |
592 ManagementPolicyMock policy; | 592 ManagementPolicyMock policy; |
593 extensions::ExtensionSystem::Get(profile()) | 593 extensions::ExtensionSystem::Get(profile()) |
594 ->management_policy() | 594 ->management_policy() |
595 ->RegisterProvider(&policy); | 595 ->RegisterProvider(&policy); |
596 | 596 |
597 base::FilePath crx_path = test_data_dir_.AppendASCII("crx_installer/v1.crx"); | 597 base::FilePath crx_path = test_data_dir_.AppendASCII("crx_installer/v1.crx"); |
598 EXPECT_FALSE(InstallExtension(crx_path, 0)); | 598 EXPECT_FALSE(InstallExtension(crx_path, 0)); |
599 } | 599 } |
600 | 600 |
601 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, WithheldElevationCheck) { | |
602 // Enable consent flag and install extension. The <all_hosts> permission will | |
603 // be withheld. | |
604 scoped_ptr<FeatureSwitch::ScopedOverride> enable_scripts_switch( | |
605 new FeatureSwitch::ScopedOverride( | |
606 FeatureSwitch::scripts_require_action(), true)); | |
607 | |
608 const char kManifest[] = | |
609 "{" | |
610 " \"name\": \"Withheld test\"," | |
611 " \"version\": \"1.0\"," | |
612 " \"permissions\": [" | |
613 " \"http://*/*\"" | |
614 " ]," | |
615 " \"manifest_version\": 2" | |
616 "}"; | |
617 TestExtensionDir dir; | |
618 dir.WriteManifest(kManifest); | |
619 base::FilePath crx_path = dir.Pack(); | |
620 EXPECT_FALSE(crx_path.empty()); | |
621 const Extension* extension = InstallExtension(crx_path, 1); | |
622 EXPECT_TRUE(base::PathExists(extension->path())); | |
623 | |
624 std::string extension_id = extension->id(); | |
625 ExtensionRegistry* registry = ExtensionRegistry::Get( | |
626 browser()->profile()); | |
627 EXPECT_TRUE(registry->enabled_extensions().GetByID(extension_id)); | |
628 | |
629 // Disable consent flag and reinstall extension. It should now be disabled | |
630 // because previously withheld permissions are now being requested. | |
631 enable_scripts_switch.reset(); | |
632 extension = InstallExtension(crx_path, -1); | |
633 EXPECT_FALSE(registry->enabled_extensions().GetByID(extension_id)); | |
634 EXPECT_TRUE(registry->disabled_extensions().GetByID(extension_id)); | |
635 EXPECT_TRUE(ExtensionPrefs::Get(browser()->profile())->GetDisableReasons( | |
636 extension_id) & Extension::DISABLE_PERMISSIONS_INCREASE); | |
637 } | |
638 | |
639 } // namespace extensions | 601 } // namespace extensions |
OLD | NEW |