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

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

Issue 11412239: Delay determination of why a synced disabled extension was disabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: missing file Created 8 years 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 | « no previous file | chrome/browser/extensions/extension_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/file_path.h" 5 #include "base/file_path.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "chrome/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/extensions/autoupdate_interceptor.h"
8 #include "chrome/browser/extensions/extension_browsertest.h" 9 #include "chrome/browser/extensions/extension_browsertest.h"
9 #include "chrome/browser/extensions/extension_prefs.h" 10 #include "chrome/browser/extensions/extension_prefs.h"
10 #include "chrome/browser/extensions/extension_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/updater/extension_updater.h"
11 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/global_error/global_error.h" 15 #include "chrome/browser/ui/global_error/global_error.h"
14 #include "chrome/browser/ui/global_error/global_error_service.h" 16 #include "chrome/browser/ui/global_error/global_error_service.h"
15 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 17 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
18 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/extensions/extension.h" 19 #include "chrome/common/extensions/extension.h"
20 #include "net/url_request/url_fetcher.h"
17 21
18 using extensions::Extension; 22 using extensions::Extension;
19 23
20 class ExtensionDisabledGlobalErrorTest : public ExtensionBrowserTest { 24 class ExtensionDisabledGlobalErrorTest : public ExtensionBrowserTest {
21 protected: 25 protected:
26 void SetUpCommandLine(CommandLine* command_line) {
27 ExtensionBrowserTest::SetUpCommandLine(command_line);
28 command_line->AppendSwitchASCII(switches::kAppsGalleryUpdateURL,
29 "http://localhost/autoupdate/updates.xml");
30 }
31
22 void SetUpOnMainThread() { 32 void SetUpOnMainThread() {
23 EXPECT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); 33 EXPECT_TRUE(scoped_temp_dir_.CreateUniqueTempDir());
24 service_ = browser()->profile()->GetExtensionService(); 34 service_ = browser()->profile()->GetExtensionService();
25 FilePath pem_path = test_data_dir_. 35 FilePath pem_path = test_data_dir_.
26 AppendASCII("permissions_increase").AppendASCII("permissions.pem"); 36 AppendASCII("permissions_increase").AppendASCII("permissions.pem");
27 path_v1_ = PackExtensionWithOptions( 37 path_v1_ = PackExtensionWithOptions(
28 test_data_dir_.AppendASCII("permissions_increase").AppendASCII("v1"), 38 test_data_dir_.AppendASCII("permissions_increase").AppendASCII("v1"),
29 scoped_temp_dir_.path().AppendASCII("permissions1.crx"), 39 scoped_temp_dir_.path().AppendASCII("permissions1.crx"),
30 pem_path, 40 pem_path,
31 FilePath()); 41 FilePath());
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 GlobalErrorServiceFactory::GetForProfile(browser()->profile())-> 164 GlobalErrorServiceFactory::GetForProfile(browser()->profile())->
155 RemoveGlobalError(error); 165 RemoveGlobalError(error);
156 delete error; 166 delete error;
157 // Upgrade to version 3, with even higher permissions. Infer from 167 // Upgrade to version 3, with even higher permissions. Infer from
158 // version 2 having higher-than-granted permissions that it was disabled 168 // version 2 having higher-than-granted permissions that it was disabled
159 // for permissions increase. 169 // for permissions increase.
160 extension = UpdateIncreasingPermissionExtension(extension, path_v3_, 0); 170 extension = UpdateIncreasingPermissionExtension(extension, path_v3_, 0);
161 ASSERT_TRUE(extension); 171 ASSERT_TRUE(extension);
162 ASSERT_TRUE(GetExtensionDisabledGlobalError()); 172 ASSERT_TRUE(GetExtensionDisabledGlobalError());
163 } 173 }
174
175 // Test that an error appears if the extension gets disabled because a
176 // version with higher permissions was installed by sync.
177 IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest,
178 HigherPermissionsFromSync) {
179 // Get data for extension v2 (disabled) into sync.
180 const Extension* extension = InstallAndUpdateIncreasingPermissionsExtension();
181 std::string extension_id = extension->id();
182 // service_->GrantPermissionsAndEnableExtension(extension, false);
183 extensions::ExtensionSyncData sync_data =
184 service_->GetExtensionSyncData(*extension);
185 UninstallExtension(extension_id);
186 extension = NULL;
187
188 // Install extension v1.
189 InstallIncreasingPermissionExtensionV1();
190
191 // Note: This interceptor gets requests on the IO thread.
192 scoped_refptr<extensions::AutoUpdateInterceptor> interceptor(
193 new extensions::AutoUpdateInterceptor());
194 net::URLFetcher::SetEnableInterceptionForTests(true);
195 interceptor->SetResponseOnIOThread(
196 "http://localhost/autoupdate/updates.xml",
197 test_data_dir_.AppendASCII("permissions_increase")
198 .AppendASCII("updates.xml"));
199 interceptor->SetResponseOnIOThread(
200 "http://localhost/autoupdate/v2.crx",
201 scoped_temp_dir_.path().AppendASCII("permissions2.crx"));
202
203 extensions::ExtensionUpdater::CheckParams params;
204 params.check_blacklist = false;
205 service_->updater()->set_default_check_params(params);
206
207 // Sync is replacing an older version, so it pends.
208 EXPECT_FALSE(service_->ProcessExtensionSyncData(sync_data));
209
210 WaitForExtensionInstall();
211
212 extension = service_->GetExtensionById(extension_id, true);
213 ASSERT_TRUE(extension);
214 EXPECT_EQ("2", extension->VersionString());
215 EXPECT_EQ(1u, service_->disabled_extensions()->size());
216 EXPECT_EQ(Extension::DISABLE_PERMISSIONS_INCREASE,
217 service_->extension_prefs()->GetDisableReasons(extension_id));
218 EXPECT_TRUE(GetExtensionDisabledGlobalError());
219 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698