Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: chrome/browser/extensions/crx_installer_browsertest.cc

Issue 381553002: Update the CrxInstaller and UnpackedInstaller to use the ExtensionInstallChecker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/download/download_crx_util.h" 8 #include "chrome/browser/download/download_crx_util.h"
8 #include "chrome/browser/extensions/browser_action_test_util.h" 9 #include "chrome/browser/extensions/browser_action_test_util.h"
9 #include "chrome/browser/extensions/crx_installer.h" 10 #include "chrome/browser/extensions/crx_installer.h"
10 #include "chrome/browser/extensions/extension_browsertest.h" 11 #include "chrome/browser/extensions/extension_browsertest.h"
11 #include "chrome/browser/extensions/extension_install_prompt.h" 12 #include "chrome/browser/extensions/extension_install_prompt.h"
12 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/extension_util.h" 14 #include "chrome/browser/extensions/extension_util.h"
14 #include "chrome/browser/extensions/fake_safe_browsing_database_manager.h" 15 #include "chrome/browser/extensions/fake_safe_browsing_database_manager.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 return prompt.PassAs<ExtensionInstallPrompt>(); 131 return prompt.PassAs<ExtensionInstallPrompt>();
131 } 132 }
132 133
133 134
134 scoped_refptr<MockPromptProxy> CreateMockPromptProxyForBrowser( 135 scoped_refptr<MockPromptProxy> CreateMockPromptProxyForBrowser(
135 Browser* browser) { 136 Browser* browser) {
136 return new MockPromptProxy( 137 return new MockPromptProxy(
137 browser->tab_strip_model()->GetActiveWebContents()); 138 browser->tab_strip_model()->GetActiveWebContents());
138 } 139 }
139 140
141 class ManagementPolicyMock : public extensions::ManagementPolicy::Provider {
142 public:
143 ManagementPolicyMock() {}
144
145 virtual std::string GetDebugPolicyProviderName() const OVERRIDE {
146 return "ManagementPolicyMock";
147 }
148
149 virtual bool UserMayLoad(const Extension* extension,
150 base::string16* error) const OVERRIDE {
151 *error = base::UTF8ToUTF16("Dummy error message");
152 return false;
153 }
154 };
155
140 } // namespace 156 } // namespace
141 157
142 class ExtensionCrxInstallerTest : public ExtensionBrowserTest { 158 class ExtensionCrxInstallerTest : public ExtensionBrowserTest {
143 public: 159 public:
144 scoped_ptr<WebstoreInstaller::Approval> GetApproval( 160 scoped_ptr<WebstoreInstaller::Approval> GetApproval(
145 const char* manifest_dir, 161 const char* manifest_dir,
146 const std::string& id, 162 const std::string& id,
147 bool strict_manifest_checks) { 163 bool strict_manifest_checks) {
148 scoped_ptr<WebstoreInstaller::Approval> result; 164 scoped_ptr<WebstoreInstaller::Approval> result;
149 165
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 EXPECT_TRUE(WaitForCrxInstallerDone()); 559 EXPECT_TRUE(WaitForCrxInstallerDone());
544 ASSERT_TRUE(crx_installer->extension()); 560 ASSERT_TRUE(crx_installer->extension());
545 561
546 const ExtensionPrefs* extension_prefs = 562 const ExtensionPrefs* extension_prefs =
547 ExtensionPrefs::Get(browser()->profile()); 563 ExtensionPrefs::Get(browser()->profile());
548 EXPECT_TRUE(extension_prefs->DoNotSync(crx_installer->extension()->id())); 564 EXPECT_TRUE(extension_prefs->DoNotSync(crx_installer->extension()->id()));
549 EXPECT_FALSE(extensions::util::ShouldSyncApp(crx_installer->extension(), 565 EXPECT_FALSE(extensions::util::ShouldSyncApp(crx_installer->extension(),
550 browser()->profile())); 566 browser()->profile()));
551 } 567 }
552 568
569 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, ManagementPolicy) {
570 ManagementPolicyMock policy;
571 extensions::ExtensionSystem::Get(profile())
572 ->management_policy()
573 ->RegisterProvider(&policy);
574
575 base::FilePath crx_path = test_data_dir_.AppendASCII("crx_installer/v1.crx");
576 EXPECT_FALSE(InstallExtension(crx_path, 0));
577 }
578
553 } // namespace extensions 579 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698