OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 // The set of extension id's we've seen via EXTENSION_UPDATE_FOUND. | 295 // The set of extension id's we've seen via EXTENSION_UPDATE_FOUND. |
296 std::set<std::string> updates_; | 296 std::set<std::string> updates_; |
297 }; | 297 }; |
298 | 298 |
299 // Tests extension autoupdate. | 299 // Tests extension autoupdate. |
300 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, AutoUpdate) { | 300 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, AutoUpdate) { |
301 NotificationListener notification_listener; | 301 NotificationListener notification_listener; |
302 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); | 302 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); |
303 // Note: This interceptor gets requests on the IO thread. | 303 // Note: This interceptor gets requests on the IO thread. |
304 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor()); | 304 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor()); |
305 URLFetcher::enable_interception_for_tests(true); | 305 content::URLFetcher::SetEnableInterceptionForTests(true); |
306 | 306 |
307 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", | 307 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", |
308 basedir.AppendASCII("manifest_v2.xml")); | 308 basedir.AppendASCII("manifest_v2.xml")); |
309 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", | 309 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", |
310 basedir.AppendASCII("v2.crx")); | 310 basedir.AppendASCII("v2.crx")); |
311 | 311 |
312 // Install version 1 of the extension. | 312 // Install version 1 of the extension. |
313 ExtensionTestMessageListener listener1("v1 installed", false); | 313 ExtensionTestMessageListener listener1("v1 installed", false); |
314 ExtensionService* service = browser()->profile()->GetExtensionService(); | 314 ExtensionService* service = browser()->profile()->GetExtensionService(); |
315 const size_t size_before = service->extensions()->size(); | 315 const size_t size_before = service->extensions()->size(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalUrlUpdate) { | 366 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalUrlUpdate) { |
367 ExtensionService* service = browser()->profile()->GetExtensionService(); | 367 ExtensionService* service = browser()->profile()->GetExtensionService(); |
368 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; | 368 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; |
369 // We don't want autoupdate blacklist checks. | 369 // We don't want autoupdate blacklist checks. |
370 service->updater()->set_blacklist_checks_enabled(false); | 370 service->updater()->set_blacklist_checks_enabled(false); |
371 | 371 |
372 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); | 372 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); |
373 | 373 |
374 // Note: This interceptor gets requests on the IO thread. | 374 // Note: This interceptor gets requests on the IO thread. |
375 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor()); | 375 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor()); |
376 URLFetcher::enable_interception_for_tests(true); | 376 content::URLFetcher::SetEnableInterceptionForTests(true); |
377 | 377 |
378 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", | 378 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", |
379 basedir.AppendASCII("manifest_v2.xml")); | 379 basedir.AppendASCII("manifest_v2.xml")); |
380 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", | 380 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", |
381 basedir.AppendASCII("v2.crx")); | 381 basedir.AppendASCII("v2.crx")); |
382 | 382 |
383 const size_t size_before = service->extensions()->size(); | 383 const size_t size_before = service->extensions()->size(); |
384 ASSERT_TRUE(service->disabled_extensions()->empty()); | 384 ASSERT_TRUE(service->disabled_extensions()->empty()); |
385 | 385 |
386 PendingExtensionManager* pending_extension_manager = | 386 PendingExtensionManager* pending_extension_manager = |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalPolicyRefresh) { | 449 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalPolicyRefresh) { |
450 ExtensionService* service = browser()->profile()->GetExtensionService(); | 450 ExtensionService* service = browser()->profile()->GetExtensionService(); |
451 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; | 451 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; |
452 // We don't want autoupdate blacklist checks. | 452 // We don't want autoupdate blacklist checks. |
453 service->updater()->set_blacklist_checks_enabled(false); | 453 service->updater()->set_blacklist_checks_enabled(false); |
454 | 454 |
455 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); | 455 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); |
456 | 456 |
457 // Note: This interceptor gets requests on the IO thread. | 457 // Note: This interceptor gets requests on the IO thread. |
458 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor()); | 458 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor()); |
459 URLFetcher::enable_interception_for_tests(true); | 459 content::URLFetcher::SetEnableInterceptionForTests(true); |
460 | 460 |
461 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", | 461 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", |
462 basedir.AppendASCII("manifest_v2.xml")); | 462 basedir.AppendASCII("manifest_v2.xml")); |
463 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", | 463 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", |
464 basedir.AppendASCII("v2.crx")); | 464 basedir.AppendASCII("v2.crx")); |
465 | 465 |
466 const size_t size_before = service->extensions()->size(); | 466 const size_t size_before = service->extensions()->size(); |
467 ASSERT_TRUE(service->disabled_extensions()->empty()); | 467 ASSERT_TRUE(service->disabled_extensions()->empty()); |
468 | 468 |
469 PrefService* prefs = browser()->profile()->GetPrefs(); | 469 PrefService* prefs = browser()->profile()->GetPrefs(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, PolicyOverridesUserInstall) { | 519 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, PolicyOverridesUserInstall) { |
520 ExtensionService* service = browser()->profile()->GetExtensionService(); | 520 ExtensionService* service = browser()->profile()->GetExtensionService(); |
521 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; | 521 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; |
522 service->updater()->set_blacklist_checks_enabled(false); | 522 service->updater()->set_blacklist_checks_enabled(false); |
523 const size_t size_before = service->extensions()->size(); | 523 const size_t size_before = service->extensions()->size(); |
524 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); | 524 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); |
525 ASSERT_TRUE(service->disabled_extensions()->empty()); | 525 ASSERT_TRUE(service->disabled_extensions()->empty()); |
526 | 526 |
527 // Note: This interceptor gets requests on the IO thread. | 527 // Note: This interceptor gets requests on the IO thread. |
528 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor()); | 528 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor()); |
529 URLFetcher::enable_interception_for_tests(true); | 529 content::URLFetcher::SetEnableInterceptionForTests(true); |
530 | 530 |
531 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", | 531 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", |
532 basedir.AppendASCII("manifest_v2.xml")); | 532 basedir.AppendASCII("manifest_v2.xml")); |
533 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", | 533 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", |
534 basedir.AppendASCII("v2.crx")); | 534 basedir.AppendASCII("v2.crx")); |
535 | 535 |
536 // Check that the policy is initially empty. | 536 // Check that the policy is initially empty. |
537 PrefService* prefs = browser()->profile()->GetPrefs(); | 537 PrefService* prefs = browser()->profile()->GetPrefs(); |
538 const ListValue* forcelist = | 538 const ListValue* forcelist = |
539 prefs->GetList(prefs::kExtensionInstallForceList); | 539 prefs->GetList(prefs::kExtensionInstallForceList); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 } | 605 } |
606 ASSERT_TRUE(WaitForExtensionInstall()); | 606 ASSERT_TRUE(WaitForExtensionInstall()); |
607 extensions = service->extensions(); | 607 extensions = service->extensions(); |
608 ASSERT_EQ(size_before + 1, extensions->size()); | 608 ASSERT_EQ(size_before + 1, extensions->size()); |
609 extension = extensions->at(size_before); | 609 extension = extensions->at(size_before); |
610 ASSERT_EQ(kExtensionId, extension->id()); | 610 ASSERT_EQ(kExtensionId, extension->id()); |
611 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, extension->location()); | 611 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, extension->location()); |
612 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); | 612 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); |
613 EXPECT_TRUE(service->disabled_extensions()->empty()); | 613 EXPECT_TRUE(service->disabled_extensions()->empty()); |
614 } | 614 } |
OLD | NEW |