| OLD | NEW |
| 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" | |
| 23 #include "extensions/browser/extension_prefs.h" | 22 #include "extensions/browser/extension_prefs.h" |
| 24 #include "extensions/browser/extension_registry.h" | 23 #include "extensions/browser/extension_registry.h" |
| 25 #include "extensions/browser/extension_system.h" | 24 #include "extensions/browser/extension_system.h" |
| 26 #include "extensions/common/extension.h" | 25 #include "extensions/common/extension.h" |
| 26 #include "net/url_request/test_url_request_interceptor.h" |
| 27 #include "net/url_request/url_fetcher.h" | 27 #include "net/url_request/url_fetcher.h" |
| 28 #include "sync/protocol/extension_specifics.pb.h" | 28 #include "sync/protocol/extension_specifics.pb.h" |
| 29 #include "sync/protocol/sync.pb.h" | 29 #include "sync/protocol/sync.pb.h" |
| 30 | 30 |
| 31 using content::BrowserThread; |
| 31 using extensions::Extension; | 32 using extensions::Extension; |
| 32 using extensions::ExtensionRegistry; | 33 using extensions::ExtensionRegistry; |
| 33 using extensions::ExtensionPrefs; | 34 using extensions::ExtensionPrefs; |
| 34 | 35 |
| 35 class ExtensionDisabledGlobalErrorTest : public ExtensionBrowserTest { | 36 class ExtensionDisabledGlobalErrorTest : public ExtensionBrowserTest { |
| 36 protected: | 37 protected: |
| 37 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 38 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 38 ExtensionBrowserTest::SetUpCommandLine(command_line); | 39 ExtensionBrowserTest::SetUpCommandLine(command_line); |
| 39 command_line->AppendSwitchASCII(switches::kAppsGalleryUpdateURL, | 40 command_line->AppendSwitchASCII(switches::kAppsGalleryUpdateURL, |
| 40 "http://localhost/autoupdate/updates.xml"); | 41 "http://localhost/autoupdate/updates.xml"); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 browser()->profile()); | 204 browser()->profile()); |
| 204 extensions::ExtensionSyncData sync_data = | 205 extensions::ExtensionSyncData sync_data = |
| 205 sync_service->GetExtensionSyncData(*extension); | 206 sync_service->GetExtensionSyncData(*extension); |
| 206 UninstallExtension(extension_id); | 207 UninstallExtension(extension_id); |
| 207 extension = NULL; | 208 extension = NULL; |
| 208 | 209 |
| 209 // Install extension v1. | 210 // Install extension v1. |
| 210 InstallIncreasingPermissionExtensionV1(); | 211 InstallIncreasingPermissionExtensionV1(); |
| 211 | 212 |
| 212 // Note: This interceptor gets requests on the IO thread. | 213 // Note: This interceptor gets requests on the IO thread. |
| 213 content::URLLocalHostRequestPrepackagedInterceptor interceptor; | 214 net::LocalHostTestURLRequestInterceptor interceptor( |
| 215 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
| 216 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( |
| 217 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); |
| 214 net::URLFetcher::SetEnableInterceptionForTests(true); | 218 net::URLFetcher::SetEnableInterceptionForTests(true); |
| 215 interceptor.SetResponseIgnoreQuery( | 219 interceptor.SetResponseIgnoreQuery( |
| 216 GURL("http://localhost/autoupdate/updates.xml"), | 220 GURL("http://localhost/autoupdate/updates.xml"), |
| 217 test_data_dir_.AppendASCII("permissions_increase") | 221 test_data_dir_.AppendASCII("permissions_increase") |
| 218 .AppendASCII("updates.xml")); | 222 .AppendASCII("updates.xml")); |
| 219 interceptor.SetResponseIgnoreQuery( | 223 interceptor.SetResponseIgnoreQuery( |
| 220 GURL("http://localhost/autoupdate/v2.crx"), | 224 GURL("http://localhost/autoupdate/v2.crx"), |
| 221 scoped_temp_dir_.path().AppendASCII("permissions2.crx")); | 225 scoped_temp_dir_.path().AppendASCII("permissions2.crx")); |
| 222 | 226 |
| 223 extensions::ExtensionUpdater::CheckParams params; | 227 extensions::ExtensionUpdater::CheckParams params; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 240 EXPECT_TRUE(GetExtensionDisabledGlobalError()); | 244 EXPECT_TRUE(GetExtensionDisabledGlobalError()); |
| 241 } | 245 } |
| 242 | 246 |
| 243 // Test that an error appears if an extension gets installed server side. | 247 // Test that an error appears if an extension gets installed server side. |
| 244 IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, RemoteInstall) { | 248 IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, RemoteInstall) { |
| 245 static const char* extension_id = "pgdpcfcocojkjfbgpiianjngphoopgmo"; | 249 static const char* extension_id = "pgdpcfcocojkjfbgpiianjngphoopgmo"; |
| 246 ExtensionSyncService* sync_service = | 250 ExtensionSyncService* sync_service = |
| 247 ExtensionSyncService::Get(browser()->profile()); | 251 ExtensionSyncService::Get(browser()->profile()); |
| 248 | 252 |
| 249 // Note: This interceptor gets requests on the IO thread. | 253 // Note: This interceptor gets requests on the IO thread. |
| 250 content::URLLocalHostRequestPrepackagedInterceptor interceptor; | 254 net::LocalHostTestURLRequestInterceptor interceptor( |
| 255 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
| 256 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( |
| 257 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); |
| 251 net::URLFetcher::SetEnableInterceptionForTests(true); | 258 net::URLFetcher::SetEnableInterceptionForTests(true); |
| 252 interceptor.SetResponseIgnoreQuery( | 259 interceptor.SetResponseIgnoreQuery( |
| 253 GURL("http://localhost/autoupdate/updates.xml"), | 260 GURL("http://localhost/autoupdate/updates.xml"), |
| 254 test_data_dir_.AppendASCII("permissions_increase") | 261 test_data_dir_.AppendASCII("permissions_increase") |
| 255 .AppendASCII("updates.xml")); | 262 .AppendASCII("updates.xml")); |
| 256 interceptor.SetResponseIgnoreQuery( | 263 interceptor.SetResponseIgnoreQuery( |
| 257 GURL("http://localhost/autoupdate/v2.crx"), | 264 GURL("http://localhost/autoupdate/v2.crx"), |
| 258 scoped_temp_dir_.path().AppendASCII("permissions2.crx")); | 265 scoped_temp_dir_.path().AppendASCII("permissions2.crx")); |
| 259 | 266 |
| 260 extensions::ExtensionUpdater::CheckParams params; | 267 extensions::ExtensionUpdater::CheckParams params; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 283 | 290 |
| 284 const Extension* extension = service_->GetExtensionById(extension_id, true); | 291 const Extension* extension = service_->GetExtensionById(extension_id, true); |
| 285 ASSERT_TRUE(extension); | 292 ASSERT_TRUE(extension); |
| 286 EXPECT_EQ("2", extension->VersionString()); | 293 EXPECT_EQ("2", extension->VersionString()); |
| 287 EXPECT_EQ(1u, registry_->disabled_extensions().size()); | 294 EXPECT_EQ(1u, registry_->disabled_extensions().size()); |
| 288 EXPECT_EQ(Extension::DISABLE_REMOTE_INSTALL, | 295 EXPECT_EQ(Extension::DISABLE_REMOTE_INSTALL, |
| 289 ExtensionPrefs::Get(service_->profile()) | 296 ExtensionPrefs::Get(service_->profile()) |
| 290 ->GetDisableReasons(extension_id)); | 297 ->GetDisableReasons(extension_id)); |
| 291 EXPECT_TRUE(GetExtensionDisabledGlobalError()); | 298 EXPECT_TRUE(GetExtensionDisabledGlobalError()); |
| 292 } | 299 } |
| OLD | NEW |