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

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

Issue 11293252: Change Interceptors into URLRequestJobFactory::ProtocolHandlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync 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
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"
9 #include "chrome/browser/extensions/extension_browsertest.h" 8 #include "chrome/browser/extensions/extension_browsertest.h"
10 #include "chrome/browser/extensions/extension_prefs.h" 9 #include "chrome/browser/extensions/extension_prefs.h"
11 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/updater/extension_updater.h" 11 #include "chrome/browser/extensions/updater/extension_updater.h"
13 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/global_error/global_error.h" 14 #include "chrome/browser/ui/global_error/global_error.h"
16 #include "chrome/browser/ui/global_error/global_error_service.h" 15 #include "chrome/browser/ui/global_error/global_error_service.h"
17 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 16 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
18 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/extensions/extension.h" 18 #include "chrome/common/extensions/extension.h"
19 #include "content/test/net/url_request_prepackaged_interceptor.h"
20 #include "net/url_request/url_fetcher.h" 20 #include "net/url_request/url_fetcher.h"
21 21
22 using extensions::Extension; 22 using extensions::Extension;
23 23
24 class ExtensionDisabledGlobalErrorTest : public ExtensionBrowserTest { 24 class ExtensionDisabledGlobalErrorTest : public ExtensionBrowserTest {
25 protected: 25 protected:
26 void SetUpCommandLine(CommandLine* command_line) { 26 void SetUpCommandLine(CommandLine* command_line) {
27 ExtensionBrowserTest::SetUpCommandLine(command_line); 27 ExtensionBrowserTest::SetUpCommandLine(command_line);
28 command_line->AppendSwitchASCII(switches::kAppsGalleryUpdateURL, 28 command_line->AppendSwitchASCII(switches::kAppsGalleryUpdateURL,
29 "http://localhost/autoupdate/updates.xml"); 29 "http://localhost/autoupdate/updates.xml");
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 // service_->GrantPermissionsAndEnableExtension(extension, false); 182 // service_->GrantPermissionsAndEnableExtension(extension, false);
183 extensions::ExtensionSyncData sync_data = 183 extensions::ExtensionSyncData sync_data =
184 service_->GetExtensionSyncData(*extension); 184 service_->GetExtensionSyncData(*extension);
185 UninstallExtension(extension_id); 185 UninstallExtension(extension_id);
186 extension = NULL; 186 extension = NULL;
187 187
188 // Install extension v1. 188 // Install extension v1.
189 InstallIncreasingPermissionExtensionV1(); 189 InstallIncreasingPermissionExtensionV1();
190 190
191 // Note: This interceptor gets requests on the IO thread. 191 // Note: This interceptor gets requests on the IO thread.
192 scoped_refptr<extensions::AutoUpdateInterceptor> interceptor( 192 content::URLRequestPrepackagedInterceptor interceptor;
193 new extensions::AutoUpdateInterceptor());
194 net::URLFetcher::SetEnableInterceptionForTests(true); 193 net::URLFetcher::SetEnableInterceptionForTests(true);
195 interceptor->SetResponseOnIOThread( 194 interceptor.SetResponseIgnoreQuery(
196 "http://localhost/autoupdate/updates.xml", 195 GURL("http://localhost/autoupdate/updates.xml"),
197 test_data_dir_.AppendASCII("permissions_increase") 196 test_data_dir_.AppendASCII("permissions_increase")
198 .AppendASCII("updates.xml")); 197 .AppendASCII("updates.xml"));
199 interceptor->SetResponseOnIOThread( 198 interceptor.SetResponseIgnoreQuery(
200 "http://localhost/autoupdate/v2.crx", 199 GURL("http://localhost/autoupdate/v2.crx"),
201 scoped_temp_dir_.path().AppendASCII("permissions2.crx")); 200 scoped_temp_dir_.path().AppendASCII("permissions2.crx"));
202 201
203 extensions::ExtensionUpdater::CheckParams params; 202 extensions::ExtensionUpdater::CheckParams params;
204 params.check_blacklist = false; 203 params.check_blacklist = false;
205 service_->updater()->set_default_check_params(params); 204 service_->updater()->set_default_check_params(params);
206 205
207 // Sync is replacing an older version, so it pends. 206 // Sync is replacing an older version, so it pends.
208 EXPECT_FALSE(service_->ProcessExtensionSyncData(sync_data)); 207 EXPECT_FALSE(service_->ProcessExtensionSyncData(sync_data));
209 208
210 WaitForExtensionInstall(); 209 WaitForExtensionInstall();
211 210
212 extension = service_->GetExtensionById(extension_id, true); 211 extension = service_->GetExtensionById(extension_id, true);
213 ASSERT_TRUE(extension); 212 ASSERT_TRUE(extension);
214 EXPECT_EQ("2", extension->VersionString()); 213 EXPECT_EQ("2", extension->VersionString());
215 EXPECT_EQ(1u, service_->disabled_extensions()->size()); 214 EXPECT_EQ(1u, service_->disabled_extensions()->size());
216 EXPECT_EQ(Extension::DISABLE_PERMISSIONS_INCREASE, 215 EXPECT_EQ(Extension::DISABLE_PERMISSIONS_INCREASE,
217 service_->extension_prefs()->GetDisableReasons(extension_id)); 216 service_->extension_prefs()->GetDisableReasons(extension_id));
218 EXPECT_TRUE(GetExtensionDisabledGlobalError()); 217 EXPECT_TRUE(GetExtensionDisabledGlobalError());
219 } 218 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/autoupdate_interceptor.cc ('k') | chrome/browser/extensions/user_script_listener_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698