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

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

Issue 156843004: Remove ExtensionService::extension_prefs() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix UserScriptListenerTests.MultiProfile Created 6 years, 10 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
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/files/file_path.h" 5 #include "base/files/file_path.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/threading/sequenced_worker_pool.h" 8 #include "base/threading/sequenced_worker_pool.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/extensions/extension_browsertest.h" 10 #include "chrome/browser/extensions/extension_browsertest.h"
11 #include "chrome/browser/extensions/extension_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/extension_sync_service.h" 12 #include "chrome/browser/extensions/extension_sync_service.h"
13 #include "chrome/browser/extensions/updater/extension_updater.h" 13 #include "chrome/browser/extensions/updater/extension_updater.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/global_error/global_error.h" 16 #include "chrome/browser/ui/global_error/global_error.h"
17 #include "chrome/browser/ui/global_error/global_error_service.h" 17 #include "chrome/browser/ui/global_error/global_error_service.h"
18 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 18 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
21 #include "content/public/test/test_utils.h" 21 #include "content/public/test/test_utils.h"
22 #include "content/test/net/url_request_prepackaged_interceptor.h" 22 #include "content/test/net/url_request_prepackaged_interceptor.h"
23 #include "extensions/browser/extension_prefs.h" 23 #include "extensions/browser/extension_prefs.h"
24 #include "extensions/browser/extension_registry.h" 24 #include "extensions/browser/extension_registry.h"
25 #include "extensions/common/extension.h" 25 #include "extensions/common/extension.h"
26 #include "net/url_request/url_fetcher.h" 26 #include "net/url_request/url_fetcher.h"
27 27
28 using extensions::Extension; 28 using extensions::Extension;
29 using extensions::ExtensionRegistry; 29 using extensions::ExtensionRegistry;
30 using extensions::ExtensionPrefs;
30 31
31 class ExtensionDisabledGlobalErrorTest : public ExtensionBrowserTest { 32 class ExtensionDisabledGlobalErrorTest : public ExtensionBrowserTest {
32 protected: 33 protected:
33 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 34 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
34 ExtensionBrowserTest::SetUpCommandLine(command_line); 35 ExtensionBrowserTest::SetUpCommandLine(command_line);
35 command_line->AppendSwitchASCII(switches::kAppsGalleryUpdateURL, 36 command_line->AppendSwitchASCII(switches::kAppsGalleryUpdateURL,
36 "http://localhost/autoupdate/updates.xml"); 37 "http://localhost/autoupdate/updates.xml");
37 } 38 }
38 39
39 virtual void SetUpOnMainThread() OVERRIDE { 40 virtual void SetUpOnMainThread() OVERRIDE {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 ASSERT_FALSE(GetExtensionDisabledGlobalError()); 148 ASSERT_FALSE(GetExtensionDisabledGlobalError());
148 } 149 }
149 150
150 // Test that no error appears if the disable reason is unknown 151 // Test that no error appears if the disable reason is unknown
151 // (but probably was by the user). 152 // (but probably was by the user).
152 IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, 153 IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest,
153 UnknownReasonSamePermissions) { 154 UnknownReasonSamePermissions) {
154 const Extension* extension = InstallIncreasingPermissionExtensionV1(); 155 const Extension* extension = InstallIncreasingPermissionExtensionV1();
155 DisableExtension(extension->id()); 156 DisableExtension(extension->id());
156 // Clear disable reason to simulate legacy disables. 157 // Clear disable reason to simulate legacy disables.
157 service_->extension_prefs()->ClearDisableReasons(extension->id()); 158 ExtensionPrefs::Get(browser()->profile())
159 ->ClearDisableReasons(extension->id());
158 // Upgrade to version 2. Infer from version 1 having the same permissions 160 // Upgrade to version 2. Infer from version 1 having the same permissions
159 // granted by the user that it was disabled by the user. 161 // granted by the user that it was disabled by the user.
160 extension = UpdateIncreasingPermissionExtension(extension, path_v2_, 0); 162 extension = UpdateIncreasingPermissionExtension(extension, path_v2_, 0);
161 ASSERT_TRUE(extension); 163 ASSERT_TRUE(extension);
162 ASSERT_FALSE(GetExtensionDisabledGlobalError()); 164 ASSERT_FALSE(GetExtensionDisabledGlobalError());
163 } 165 }
164 166
165 // Test that an error appears if the disable reason is unknown 167 // Test that an error appears if the disable reason is unknown
166 // (but probably was for increased permissions). 168 // (but probably was for increased permissions).
167 IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, 169 IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest,
168 UnknownReasonHigherPermissions) { 170 UnknownReasonHigherPermissions) {
169 const Extension* extension = InstallAndUpdateIncreasingPermissionsExtension(); 171 const Extension* extension = InstallAndUpdateIncreasingPermissionsExtension();
170 // Clear disable reason to simulate legacy disables. 172 // Clear disable reason to simulate legacy disables.
171 service_->extension_prefs()->ClearDisableReasons(extension->id()); 173 ExtensionPrefs::Get(service_->profile())
174 ->ClearDisableReasons(extension->id());
172 // We now have version 2 but only accepted permissions for version 1. 175 // We now have version 2 but only accepted permissions for version 1.
173 GlobalError* error = GetExtensionDisabledGlobalError(); 176 GlobalError* error = GetExtensionDisabledGlobalError();
174 ASSERT_TRUE(error); 177 ASSERT_TRUE(error);
175 // Also, remove the upgrade error for version 2. 178 // Also, remove the upgrade error for version 2.
176 GlobalErrorServiceFactory::GetForProfile(browser()->profile())-> 179 GlobalErrorServiceFactory::GetForProfile(browser()->profile())->
177 RemoveGlobalError(error); 180 RemoveGlobalError(error);
178 delete error; 181 delete error;
179 // Upgrade to version 3, with even higher permissions. Infer from 182 // Upgrade to version 3, with even higher permissions. Infer from
180 // version 2 having higher-than-granted permissions that it was disabled 183 // version 2 having higher-than-granted permissions that it was disabled
181 // for permissions increase. 184 // for permissions increase.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 223
221 WaitForExtensionInstall(); 224 WaitForExtensionInstall();
222 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 225 content::BrowserThread::GetBlockingPool()->FlushForTesting();
223 base::RunLoop().RunUntilIdle(); 226 base::RunLoop().RunUntilIdle();
224 227
225 extension = service_->GetExtensionById(extension_id, true); 228 extension = service_->GetExtensionById(extension_id, true);
226 ASSERT_TRUE(extension); 229 ASSERT_TRUE(extension);
227 EXPECT_EQ("2", extension->VersionString()); 230 EXPECT_EQ("2", extension->VersionString());
228 EXPECT_EQ(1u, registry_->disabled_extensions().size()); 231 EXPECT_EQ(1u, registry_->disabled_extensions().size());
229 EXPECT_EQ(Extension::DISABLE_PERMISSIONS_INCREASE, 232 EXPECT_EQ(Extension::DISABLE_PERMISSIONS_INCREASE,
230 service_->extension_prefs()->GetDisableReasons(extension_id)); 233 ExtensionPrefs::Get(service_->profile())
234 ->GetDisableReasons(extension_id));
231 EXPECT_TRUE(GetExtensionDisabledGlobalError()); 235 EXPECT_TRUE(GetExtensionDisabledGlobalError());
232 } 236 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698