| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 bool finished_; | 215 bool finished_; |
| 216 | 216 |
| 217 // The set of extension id's we've seen via EXTENSION_UPDATE_FOUND. | 217 // The set of extension id's we've seen via EXTENSION_UPDATE_FOUND. |
| 218 std::set<std::string> updates_; | 218 std::set<std::string> updates_; |
| 219 }; | 219 }; |
| 220 | 220 |
| 221 #if defined(OS_WIN) | 221 #if defined(OS_WIN) |
| 222 // Fails consistently on Windows XP, see: http://crbug.com/120640. | 222 // Fails consistently on Windows XP, see: http://crbug.com/120640. |
| 223 #define MAYBE_AutoUpdate DISABLED_AutoUpdate | 223 #define MAYBE_AutoUpdate DISABLED_AutoUpdate |
| 224 #else | 224 #else |
| 225 // See http://crbug.com/103371 and http://crbug.com/120640. |
| 225 #if defined(ADDRESS_SANITIZER) | 226 #if defined(ADDRESS_SANITIZER) |
| 226 #define MAYBE_AutoUpdate DISABLED_AutoUpdate | 227 #define MAYBE_AutoUpdate DISABLED_AutoUpdate |
| 227 #else | 228 #else |
| 228 #define MAYBE_AutoUpdate AutoUpdate | 229 #define MAYBE_AutoUpdate AutoUpdate |
| 229 #endif | 230 #endif |
| 230 #endif | 231 #endif |
| 231 | 232 |
| 232 // Tests extension autoupdate. | 233 // Tests extension autoupdate. |
| 233 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, MAYBE_AutoUpdate) { | 234 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, MAYBE_AutoUpdate) { |
| 234 NotificationListener notification_listener; | 235 NotificationListener notification_listener; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 extension = service->GetExtensionById( | 294 extension = service->GetExtensionById( |
| 294 "ogjcoiohnmldgjemafoockdghcjciccf", false); | 295 "ogjcoiohnmldgjemafoockdghcjciccf", false); |
| 295 ASSERT_TRUE(extension); | 296 ASSERT_TRUE(extension); |
| 296 ASSERT_EQ("2.0", extension->VersionString()); | 297 ASSERT_EQ("2.0", extension->VersionString()); |
| 297 } | 298 } |
| 298 | 299 |
| 299 #if defined(OS_WIN) | 300 #if defined(OS_WIN) |
| 300 // Fails consistently on Windows XP, see: http://crbug.com/120640. | 301 // Fails consistently on Windows XP, see: http://crbug.com/120640. |
| 301 #define MAYBE_AutoUpdateDisabledExtensions DISABLED_AutoUpdateDisabledExtensions | 302 #define MAYBE_AutoUpdateDisabledExtensions DISABLED_AutoUpdateDisabledExtensions |
| 302 #else | 303 #else |
| 304 #if defined(ADDRESS_SANITIZER) |
| 305 #define MAYBE_AutoUpdateDisabledExtensions DISABLED_AutoUpdateDisabledExtensions |
| 306 #else |
| 303 #define MAYBE_AutoUpdateDisabledExtensions AutoUpdateDisabledExtensions | 307 #define MAYBE_AutoUpdateDisabledExtensions AutoUpdateDisabledExtensions |
| 304 #endif | 308 #endif |
| 309 #endif |
| 305 | 310 |
| 306 // Tests extension autoupdate. | 311 // Tests extension autoupdate. |
| 307 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, | 312 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, |
| 308 MAYBE_AutoUpdateDisabledExtensions) { | 313 MAYBE_AutoUpdateDisabledExtensions) { |
| 309 NotificationListener notification_listener; | 314 NotificationListener notification_listener; |
| 310 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); | 315 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); |
| 311 // Note: This interceptor gets requests on the IO thread. | 316 // Note: This interceptor gets requests on the IO thread. |
| 312 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor()); | 317 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor()); |
| 313 content::URLFetcher::SetEnableInterceptionForTests(true); | 318 content::URLFetcher::SetEnableInterceptionForTests(true); |
| 314 | 319 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 EXPECT_EQ(0u, service->disabled_extensions()->size()); | 509 EXPECT_EQ(0u, service->disabled_extensions()->size()); |
| 505 | 510 |
| 506 // Check that emptying the list triggers uninstall. | 511 // Check that emptying the list triggers uninstall. |
| 507 { | 512 { |
| 508 prefs->ClearPref(prefs::kExtensionInstallForceList); | 513 prefs->ClearPref(prefs::kExtensionInstallForceList); |
| 509 } | 514 } |
| 510 EXPECT_EQ(size_before + 1, service->extensions()->size()); | 515 EXPECT_EQ(size_before + 1, service->extensions()->size()); |
| 511 EXPECT_FALSE(service->GetExtensionById(kExtensionId, true)); | 516 EXPECT_FALSE(service->GetExtensionById(kExtensionId, true)); |
| 512 } | 517 } |
| 513 | 518 |
| 514 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, PolicyOverridesUserInstall) { | 519 // See http://crbug.com/103371 and http://crbug.com/120640. |
| 520 #if defined(ADDRESS_SANITIZER) |
| 521 #define MAYBE_PolicyOverridesUserInstall DISABLED_PolicyOverridesUserInstall |
| 522 #else |
| 523 #define MAYBE_PolicyOverridesUserInstall PolicyOverridesUserInstall |
| 524 #endif |
| 525 |
| 526 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, |
| 527 MAYBE_PolicyOverridesUserInstall) { |
| 515 ExtensionService* service = browser()->profile()->GetExtensionService(); | 528 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 516 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; | 529 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; |
| 517 service->updater()->set_blacklist_checks_enabled(false); | 530 service->updater()->set_blacklist_checks_enabled(false); |
| 518 const size_t size_before = service->extensions()->size(); | 531 const size_t size_before = service->extensions()->size(); |
| 519 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); | 532 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); |
| 520 ASSERT_TRUE(service->disabled_extensions()->is_empty()); | 533 ASSERT_TRUE(service->disabled_extensions()->is_empty()); |
| 521 | 534 |
| 522 // Note: This interceptor gets requests on the IO thread. | 535 // Note: This interceptor gets requests on the IO thread. |
| 523 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor()); | 536 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor()); |
| 524 content::URLFetcher::SetEnableInterceptionForTests(true); | 537 content::URLFetcher::SetEnableInterceptionForTests(true); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 std::string(kExtensionId) + ";http://localhost/autoupdate/manifest")); | 609 std::string(kExtensionId) + ";http://localhost/autoupdate/manifest")); |
| 597 } | 610 } |
| 598 ASSERT_TRUE(WaitForExtensionInstall()); | 611 ASSERT_TRUE(WaitForExtensionInstall()); |
| 599 ASSERT_EQ(size_before + 1, service->extensions()->size()); | 612 ASSERT_EQ(size_before + 1, service->extensions()->size()); |
| 600 extension = service->GetExtensionById(kExtensionId, false); | 613 extension = service->GetExtensionById(kExtensionId, false); |
| 601 ASSERT_TRUE(extension); | 614 ASSERT_TRUE(extension); |
| 602 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, extension->location()); | 615 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, extension->location()); |
| 603 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); | 616 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); |
| 604 EXPECT_TRUE(service->disabled_extensions()->is_empty()); | 617 EXPECT_TRUE(service->disabled_extensions()->is_empty()); |
| 605 } | 618 } |
| OLD | NEW |