| 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "chrome/browser/extensions/extension_browsertest.h" | 10 #include "chrome/browser/extensions/extension_browsertest.h" |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 #else | 243 #else |
| 244 #define MAYBE_AutoUpdate AutoUpdate | 244 #define MAYBE_AutoUpdate AutoUpdate |
| 245 #endif | 245 #endif |
| 246 #endif | 246 #endif |
| 247 | 247 |
| 248 // Tests extension autoupdate. | 248 // Tests extension autoupdate. |
| 249 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, MAYBE_AutoUpdate) { | 249 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, MAYBE_AutoUpdate) { |
| 250 NotificationListener notification_listener; | 250 NotificationListener notification_listener; |
| 251 base::FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); | 251 base::FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); |
| 252 // Note: This interceptor gets requests on the IO thread. | 252 // Note: This interceptor gets requests on the IO thread. |
| 253 content::URLRequestPrepackagedInterceptor interceptor; | 253 content::URLLocalHostRequestPrepackagedInterceptor interceptor; |
| 254 net::URLFetcher::SetEnableInterceptionForTests(true); | 254 net::URLFetcher::SetEnableInterceptionForTests(true); |
| 255 | 255 |
| 256 interceptor.SetResponseIgnoreQuery( | 256 interceptor.SetResponseIgnoreQuery( |
| 257 GURL("http://localhost/autoupdate/manifest"), | 257 GURL("http://localhost/autoupdate/manifest"), |
| 258 basedir.AppendASCII("manifest_v2.xml")); | 258 basedir.AppendASCII("manifest_v2.xml")); |
| 259 interceptor.SetResponseIgnoreQuery(GURL("http://localhost/autoupdate/v2.crx"), | 259 interceptor.SetResponseIgnoreQuery(GURL("http://localhost/autoupdate/v2.crx"), |
| 260 basedir.AppendASCII("v2.crx")); | 260 basedir.AppendASCII("v2.crx")); |
| 261 | 261 |
| 262 // Install version 1 of the extension. | 262 // Install version 1 of the extension. |
| 263 ExtensionTestMessageListener listener1("v1 installed", false); | 263 ExtensionTestMessageListener listener1("v1 installed", false); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 #define MAYBE_AutoUpdateDisabledExtensions AutoUpdateDisabledExtensions | 329 #define MAYBE_AutoUpdateDisabledExtensions AutoUpdateDisabledExtensions |
| 330 #endif | 330 #endif |
| 331 #endif | 331 #endif |
| 332 | 332 |
| 333 // Tests extension autoupdate. | 333 // Tests extension autoupdate. |
| 334 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, | 334 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, |
| 335 MAYBE_AutoUpdateDisabledExtensions) { | 335 MAYBE_AutoUpdateDisabledExtensions) { |
| 336 NotificationListener notification_listener; | 336 NotificationListener notification_listener; |
| 337 base::FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); | 337 base::FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); |
| 338 // Note: This interceptor gets requests on the IO thread. | 338 // Note: This interceptor gets requests on the IO thread. |
| 339 content::URLRequestPrepackagedInterceptor interceptor; | 339 content::URLLocalHostRequestPrepackagedInterceptor interceptor; |
| 340 net::URLFetcher::SetEnableInterceptionForTests(true); | 340 net::URLFetcher::SetEnableInterceptionForTests(true); |
| 341 | 341 |
| 342 interceptor.SetResponseIgnoreQuery( | 342 interceptor.SetResponseIgnoreQuery( |
| 343 GURL("http://localhost/autoupdate/manifest"), | 343 GURL("http://localhost/autoupdate/manifest"), |
| 344 basedir.AppendASCII("manifest_v2.xml")); | 344 basedir.AppendASCII("manifest_v2.xml")); |
| 345 interceptor.SetResponseIgnoreQuery(GURL("http://localhost/autoupdate/v2.crx"), | 345 interceptor.SetResponseIgnoreQuery(GURL("http://localhost/autoupdate/v2.crx"), |
| 346 basedir.AppendASCII("v2.crx")); | 346 basedir.AppendASCII("v2.crx")); |
| 347 | 347 |
| 348 // Install version 1 of the extension. | 348 // Install version 1 of the extension. |
| 349 ExtensionTestMessageListener listener1("v1 installed", false); | 349 ExtensionTestMessageListener listener1("v1 installed", false); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 ExtensionService* service = extensions::ExtensionSystem::Get( | 405 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 406 browser()->profile())->extension_service(); | 406 browser()->profile())->extension_service(); |
| 407 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; | 407 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; |
| 408 // We don't want autoupdate blacklist checks. | 408 // We don't want autoupdate blacklist checks. |
| 409 extensions::ExtensionUpdater::CheckParams params; | 409 extensions::ExtensionUpdater::CheckParams params; |
| 410 params.check_blacklist = false; | 410 params.check_blacklist = false; |
| 411 | 411 |
| 412 base::FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); | 412 base::FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); |
| 413 | 413 |
| 414 // Note: This interceptor gets requests on the IO thread. | 414 // Note: This interceptor gets requests on the IO thread. |
| 415 content::URLRequestPrepackagedInterceptor interceptor; | 415 content::URLLocalHostRequestPrepackagedInterceptor interceptor; |
| 416 net::URLFetcher::SetEnableInterceptionForTests(true); | 416 net::URLFetcher::SetEnableInterceptionForTests(true); |
| 417 | 417 |
| 418 interceptor.SetResponseIgnoreQuery( | 418 interceptor.SetResponseIgnoreQuery( |
| 419 GURL("http://localhost/autoupdate/manifest"), | 419 GURL("http://localhost/autoupdate/manifest"), |
| 420 basedir.AppendASCII("manifest_v2.xml")); | 420 basedir.AppendASCII("manifest_v2.xml")); |
| 421 interceptor.SetResponseIgnoreQuery(GURL("http://localhost/autoupdate/v2.crx"), | 421 interceptor.SetResponseIgnoreQuery(GURL("http://localhost/autoupdate/v2.crx"), |
| 422 basedir.AppendASCII("v2.crx")); | 422 basedir.AppendASCII("v2.crx")); |
| 423 | 423 |
| 424 const size_t size_before = service->extensions()->size(); | 424 const size_t size_before = service->extensions()->size(); |
| 425 ASSERT_TRUE(service->disabled_extensions()->is_empty()); | 425 ASSERT_TRUE(service->disabled_extensions()->is_empty()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 ExtensionService* service = extensions::ExtensionSystem::Get( | 491 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 492 browser()->profile())->extension_service(); | 492 browser()->profile())->extension_service(); |
| 493 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; | 493 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; |
| 494 // We don't want autoupdate blacklist checks. | 494 // We don't want autoupdate blacklist checks. |
| 495 extensions::ExtensionUpdater::CheckParams params; | 495 extensions::ExtensionUpdater::CheckParams params; |
| 496 params.check_blacklist = false; | 496 params.check_blacklist = false; |
| 497 | 497 |
| 498 base::FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); | 498 base::FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); |
| 499 | 499 |
| 500 // Note: This interceptor gets requests on the IO thread. | 500 // Note: This interceptor gets requests on the IO thread. |
| 501 content::URLRequestPrepackagedInterceptor interceptor; | 501 content::URLLocalHostRequestPrepackagedInterceptor interceptor; |
| 502 net::URLFetcher::SetEnableInterceptionForTests(true); | 502 net::URLFetcher::SetEnableInterceptionForTests(true); |
| 503 | 503 |
| 504 interceptor.SetResponseIgnoreQuery( | 504 interceptor.SetResponseIgnoreQuery( |
| 505 GURL("http://localhost/autoupdate/manifest"), | 505 GURL("http://localhost/autoupdate/manifest"), |
| 506 basedir.AppendASCII("manifest_v2.xml")); | 506 basedir.AppendASCII("manifest_v2.xml")); |
| 507 interceptor.SetResponseIgnoreQuery(GURL("http://localhost/autoupdate/v2.crx"), | 507 interceptor.SetResponseIgnoreQuery(GURL("http://localhost/autoupdate/v2.crx"), |
| 508 basedir.AppendASCII("v2.crx")); | 508 basedir.AppendASCII("v2.crx")); |
| 509 | 509 |
| 510 const size_t size_before = service->extensions()->size(); | 510 const size_t size_before = service->extensions()->size(); |
| 511 ASSERT_TRUE(service->disabled_extensions()->is_empty()); | 511 ASSERT_TRUE(service->disabled_extensions()->is_empty()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 browser()->profile())->extension_service(); | 566 browser()->profile())->extension_service(); |
| 567 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; | 567 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; |
| 568 extensions::ExtensionUpdater::CheckParams params; | 568 extensions::ExtensionUpdater::CheckParams params; |
| 569 params.check_blacklist = false; | 569 params.check_blacklist = false; |
| 570 service->updater()->set_default_check_params(params); | 570 service->updater()->set_default_check_params(params); |
| 571 const size_t size_before = service->extensions()->size(); | 571 const size_t size_before = service->extensions()->size(); |
| 572 base::FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); | 572 base::FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); |
| 573 ASSERT_TRUE(service->disabled_extensions()->is_empty()); | 573 ASSERT_TRUE(service->disabled_extensions()->is_empty()); |
| 574 | 574 |
| 575 // Note: This interceptor gets requests on the IO thread. | 575 // Note: This interceptor gets requests on the IO thread. |
| 576 content::URLRequestPrepackagedInterceptor interceptor; | 576 content::URLLocalHostRequestPrepackagedInterceptor interceptor; |
| 577 net::URLFetcher::SetEnableInterceptionForTests(true); | 577 net::URLFetcher::SetEnableInterceptionForTests(true); |
| 578 | 578 |
| 579 interceptor.SetResponseIgnoreQuery( | 579 interceptor.SetResponseIgnoreQuery( |
| 580 GURL("http://localhost/autoupdate/manifest"), | 580 GURL("http://localhost/autoupdate/manifest"), |
| 581 basedir.AppendASCII("manifest_v2.xml")); | 581 basedir.AppendASCII("manifest_v2.xml")); |
| 582 interceptor.SetResponseIgnoreQuery(GURL("http://localhost/autoupdate/v2.crx"), | 582 interceptor.SetResponseIgnoreQuery(GURL("http://localhost/autoupdate/v2.crx"), |
| 583 basedir.AppendASCII("v2.crx")); | 583 basedir.AppendASCII("v2.crx")); |
| 584 | 584 |
| 585 // Check that the policy is initially empty. | 585 // Check that the policy is initially empty. |
| 586 PrefService* prefs = browser()->profile()->GetPrefs(); | 586 PrefService* prefs = browser()->profile()->GetPrefs(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 forcelist, kExtensionId, "http://localhost/autoupdate/manifest"); | 643 forcelist, kExtensionId, "http://localhost/autoupdate/manifest"); |
| 644 } | 644 } |
| 645 ASSERT_TRUE(WaitForExtensionInstall()); | 645 ASSERT_TRUE(WaitForExtensionInstall()); |
| 646 ASSERT_EQ(size_before + 1, service->extensions()->size()); | 646 ASSERT_EQ(size_before + 1, service->extensions()->size()); |
| 647 extension = service->GetExtensionById(kExtensionId, false); | 647 extension = service->GetExtensionById(kExtensionId, false); |
| 648 ASSERT_TRUE(extension); | 648 ASSERT_TRUE(extension); |
| 649 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); | 649 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); |
| 650 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); | 650 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); |
| 651 EXPECT_TRUE(service->disabled_extensions()->is_empty()); | 651 EXPECT_TRUE(service->disabled_extensions()->is_empty()); |
| 652 } | 652 } |
| OLD | NEW |