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

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

Issue 9718008: Replace extension disabled infobar with a global error. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 2 Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/extension_disabled_ui.cc ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/app/chrome_command_ids.h"
6 #include "chrome/browser/extensions/extension_browsertest.h"
7 #include "chrome/browser/extensions/extension_disabled_ui.h"
8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/global_error_service.h"
12 #include "chrome/browser/ui/global_error_service_factory.h"
13 #include "chrome/common/extensions/extension.h"
14
15 // Test structure:
16 // Load test extension
17
18 class ExtensionDisabledGlobalErrorTest : public ExtensionBrowserTest {
19 protected:
20 void SetUpOnMainThread() {
21 service_ = browser()->profile()->GetExtensionService();
22 }
23
24 // Returns the ExtensionDisabledGlobalError, if present.
25 // Caution: currently only supports one error at a time.
26 GlobalError* GetExtensionDisabledGlobalError() {
27 return GlobalErrorServiceFactory::GetForProfile(browser()->profile())->
28 GetGlobalErrorByMenuItemCommandID(IDC_EXTENSION_DISABLED_FIRST);
29 }
30
31 // Helper function to install an extension and upgrade it to a version
32 // requiring additional permissions. Returns the new disabled Extension.
33 const Extension* InstallAndUpdateIncreasingPermissionsExtension() {
34 ExtensionService* service = browser()->profile()->GetExtensionService();
Matt Perry 2012/03/20 17:05:04 nit: this is just service_
Yoyo Zhou 2012/03/20 17:45:03 Done.
35 size_t size_before = service->extensions()->size();
36
37 // Install the initial version, which should happen just fine.
38 const Extension* extension = InstallExtension(
39 test_data_dir_.AppendASCII("permissions-low-v1.crx"), 1);
40 if (!extension)
41 return NULL;
42 if (service->extensions()->size() != size_before + 1)
43 return NULL;
44
45 // Upgrade to a version that wants more permissions. We should disable the
46 // extension and prompt the user to reenable.
47 if (UpdateExtension(
48 extension->id(),
49 test_data_dir_.AppendASCII("permissions-high-v2.crx"), -1))
50 return NULL;
51 EXPECT_EQ(size_before, service->extensions()->size());
52 if (service->disabled_extensions()->size() != 1u)
53 return NULL;
54
55 return *service->disabled_extensions()->begin();
56 }
57
58 ExtensionService* service_;
59 };
60
61 IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, AcceptPermissions) {
62 const Extension* extension = InstallAndUpdateIncreasingPermissionsExtension();
63 ASSERT_TRUE(extension);
64 ASSERT_TRUE(GetExtensionDisabledGlobalError());
65 service_->GrantPermissionsAndEnableExtension(extension);
66 ASSERT_FALSE(GetExtensionDisabledGlobalError());
67 }
68
69 IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, Uninstall) {
70 const Extension* extension = InstallAndUpdateIncreasingPermissionsExtension();
71 ASSERT_TRUE(extension);
72 ASSERT_TRUE(GetExtensionDisabledGlobalError());
73 UninstallExtension(extension->id());
74 ASSERT_FALSE(GetExtensionDisabledGlobalError());
75 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_disabled_ui.cc ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698