| 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/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
| 6 #include "base/stl_util.h" | 6 #include "base/stl_util.h" |
| 7 #include "chrome/browser/extensions/autoupdate_interceptor.h" | 7 #include "chrome/browser/extensions/autoupdate_interceptor.h" |
| 8 #include "chrome/browser/extensions/extension_browsertest.h" | 8 #include "chrome/browser/extensions/extension_browsertest.h" |
| 9 #include "chrome/browser/extensions/extension_host.h" | 9 #include "chrome/browser/extensions/extension_host.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 #else | 237 #else |
| 238 #define MAYBE_AutoUpdate AutoUpdate | 238 #define MAYBE_AutoUpdate AutoUpdate |
| 239 #endif | 239 #endif |
| 240 #endif | 240 #endif |
| 241 | 241 |
| 242 // Tests extension autoupdate. | 242 // Tests extension autoupdate. |
| 243 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, MAYBE_AutoUpdate) { | 243 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, MAYBE_AutoUpdate) { |
| 244 NotificationListener notification_listener; | 244 NotificationListener notification_listener; |
| 245 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); | 245 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); |
| 246 // Note: This interceptor gets requests on the IO thread. | 246 // Note: This interceptor gets requests on the IO thread. |
| 247 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor()); | 247 scoped_refptr<extensions::AutoUpdateInterceptor> interceptor( |
| 248 new extensions::AutoUpdateInterceptor()); |
| 248 net::URLFetcher::SetEnableInterceptionForTests(true); | 249 net::URLFetcher::SetEnableInterceptionForTests(true); |
| 249 | 250 |
| 250 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", | 251 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", |
| 251 basedir.AppendASCII("manifest_v2.xml")); | 252 basedir.AppendASCII("manifest_v2.xml")); |
| 252 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", | 253 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", |
| 253 basedir.AppendASCII("v2.crx")); | 254 basedir.AppendASCII("v2.crx")); |
| 254 | 255 |
| 255 // Install version 1 of the extension. | 256 // Install version 1 of the extension. |
| 256 ExtensionTestMessageListener listener1("v1 installed", false); | 257 ExtensionTestMessageListener listener1("v1 installed", false); |
| 257 ExtensionService* service = browser()->profile()->GetExtensionService(); | 258 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 #define MAYBE_AutoUpdateDisabledExtensions AutoUpdateDisabledExtensions | 317 #define MAYBE_AutoUpdateDisabledExtensions AutoUpdateDisabledExtensions |
| 317 #endif | 318 #endif |
| 318 #endif | 319 #endif |
| 319 | 320 |
| 320 // Tests extension autoupdate. | 321 // Tests extension autoupdate. |
| 321 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, | 322 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, |
| 322 MAYBE_AutoUpdateDisabledExtensions) { | 323 MAYBE_AutoUpdateDisabledExtensions) { |
| 323 NotificationListener notification_listener; | 324 NotificationListener notification_listener; |
| 324 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); | 325 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); |
| 325 // Note: This interceptor gets requests on the IO thread. | 326 // Note: This interceptor gets requests on the IO thread. |
| 326 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor()); | 327 scoped_refptr<extensions::AutoUpdateInterceptor> interceptor( |
| 328 new extensions::AutoUpdateInterceptor()); |
| 327 net::URLFetcher::SetEnableInterceptionForTests(true); | 329 net::URLFetcher::SetEnableInterceptionForTests(true); |
| 328 | 330 |
| 329 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", | 331 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", |
| 330 basedir.AppendASCII("manifest_v2.xml")); | 332 basedir.AppendASCII("manifest_v2.xml")); |
| 331 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", | 333 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", |
| 332 basedir.AppendASCII("v2.crx")); | 334 basedir.AppendASCII("v2.crx")); |
| 333 | 335 |
| 334 // Install version 1 of the extension. | 336 // Install version 1 of the extension. |
| 335 ExtensionTestMessageListener listener1("v1 installed", false); | 337 ExtensionTestMessageListener listener1("v1 installed", false); |
| 336 ExtensionService* service = browser()->profile()->GetExtensionService(); | 338 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 | 379 |
| 378 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalUrlUpdate) { | 380 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalUrlUpdate) { |
| 379 ExtensionService* service = browser()->profile()->GetExtensionService(); | 381 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 380 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; | 382 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; |
| 381 // We don't want autoupdate blacklist checks. | 383 // We don't want autoupdate blacklist checks. |
| 382 service->updater()->set_blacklist_checks_enabled(false); | 384 service->updater()->set_blacklist_checks_enabled(false); |
| 383 | 385 |
| 384 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); | 386 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); |
| 385 | 387 |
| 386 // Note: This interceptor gets requests on the IO thread. | 388 // Note: This interceptor gets requests on the IO thread. |
| 387 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor()); | 389 scoped_refptr<extensions::AutoUpdateInterceptor> interceptor( |
| 390 new extensions::AutoUpdateInterceptor()); |
| 388 net::URLFetcher::SetEnableInterceptionForTests(true); | 391 net::URLFetcher::SetEnableInterceptionForTests(true); |
| 389 | 392 |
| 390 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", | 393 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", |
| 391 basedir.AppendASCII("manifest_v2.xml")); | 394 basedir.AppendASCII("manifest_v2.xml")); |
| 392 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", | 395 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", |
| 393 basedir.AppendASCII("v2.crx")); | 396 basedir.AppendASCII("v2.crx")); |
| 394 | 397 |
| 395 const size_t size_before = service->extensions()->size(); | 398 const size_t size_before = service->extensions()->size(); |
| 396 ASSERT_TRUE(service->disabled_extensions()->is_empty()); | 399 ASSERT_TRUE(service->disabled_extensions()->is_empty()); |
| 397 | 400 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 // See http://crbug.com/57378 for flakiness details. | 463 // See http://crbug.com/57378 for flakiness details. |
| 461 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalPolicyRefresh) { | 464 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalPolicyRefresh) { |
| 462 ExtensionService* service = browser()->profile()->GetExtensionService(); | 465 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 463 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; | 466 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; |
| 464 // We don't want autoupdate blacklist checks. | 467 // We don't want autoupdate blacklist checks. |
| 465 service->updater()->set_blacklist_checks_enabled(false); | 468 service->updater()->set_blacklist_checks_enabled(false); |
| 466 | 469 |
| 467 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); | 470 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); |
| 468 | 471 |
| 469 // Note: This interceptor gets requests on the IO thread. | 472 // Note: This interceptor gets requests on the IO thread. |
| 470 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor()); | 473 scoped_refptr<extensions::AutoUpdateInterceptor> interceptor( |
| 474 new extensions::AutoUpdateInterceptor()); |
| 471 net::URLFetcher::SetEnableInterceptionForTests(true); | 475 net::URLFetcher::SetEnableInterceptionForTests(true); |
| 472 | 476 |
| 473 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", | 477 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", |
| 474 basedir.AppendASCII("manifest_v2.xml")); | 478 basedir.AppendASCII("manifest_v2.xml")); |
| 475 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", | 479 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", |
| 476 basedir.AppendASCII("v2.crx")); | 480 basedir.AppendASCII("v2.crx")); |
| 477 | 481 |
| 478 const size_t size_before = service->extensions()->size(); | 482 const size_t size_before = service->extensions()->size(); |
| 479 ASSERT_TRUE(service->disabled_extensions()->is_empty()); | 483 ASSERT_TRUE(service->disabled_extensions()->is_empty()); |
| 480 | 484 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, | 539 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, |
| 536 MAYBE_PolicyOverridesUserInstall) { | 540 MAYBE_PolicyOverridesUserInstall) { |
| 537 ExtensionService* service = browser()->profile()->GetExtensionService(); | 541 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 538 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; | 542 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; |
| 539 service->updater()->set_blacklist_checks_enabled(false); | 543 service->updater()->set_blacklist_checks_enabled(false); |
| 540 const size_t size_before = service->extensions()->size(); | 544 const size_t size_before = service->extensions()->size(); |
| 541 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); | 545 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); |
| 542 ASSERT_TRUE(service->disabled_extensions()->is_empty()); | 546 ASSERT_TRUE(service->disabled_extensions()->is_empty()); |
| 543 | 547 |
| 544 // Note: This interceptor gets requests on the IO thread. | 548 // Note: This interceptor gets requests on the IO thread. |
| 545 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor()); | 549 scoped_refptr<extensions::AutoUpdateInterceptor> interceptor( |
| 550 new extensions::AutoUpdateInterceptor()); |
| 546 net::URLFetcher::SetEnableInterceptionForTests(true); | 551 net::URLFetcher::SetEnableInterceptionForTests(true); |
| 547 | 552 |
| 548 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", | 553 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", |
| 549 basedir.AppendASCII("manifest_v2.xml")); | 554 basedir.AppendASCII("manifest_v2.xml")); |
| 550 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", | 555 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", |
| 551 basedir.AppendASCII("v2.crx")); | 556 basedir.AppendASCII("v2.crx")); |
| 552 | 557 |
| 553 // Check that the policy is initially empty. | 558 // Check that the policy is initially empty. |
| 554 PrefService* prefs = browser()->profile()->GetPrefs(); | 559 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 555 const ListValue* forcelist = | 560 const ListValue* forcelist = |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 std::string(kExtensionId) + ";http://localhost/autoupdate/manifest")); | 623 std::string(kExtensionId) + ";http://localhost/autoupdate/manifest")); |
| 619 } | 624 } |
| 620 ASSERT_TRUE(WaitForExtensionInstall()); | 625 ASSERT_TRUE(WaitForExtensionInstall()); |
| 621 ASSERT_EQ(size_before + 1, service->extensions()->size()); | 626 ASSERT_EQ(size_before + 1, service->extensions()->size()); |
| 622 extension = service->GetExtensionById(kExtensionId, false); | 627 extension = service->GetExtensionById(kExtensionId, false); |
| 623 ASSERT_TRUE(extension); | 628 ASSERT_TRUE(extension); |
| 624 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, extension->location()); | 629 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, extension->location()); |
| 625 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); | 630 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); |
| 626 EXPECT_TRUE(service->disabled_extensions()->is_empty()); | 631 EXPECT_TRUE(service->disabled_extensions()->is_empty()); |
| 627 } | 632 } |
| OLD | NEW |