| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 service->updater()->CheckNow(params); | 329 service->updater()->CheckNow(params); |
| 330 install_observer.WaitForExtensionWillBeInstalled(); | 330 install_observer.WaitForExtensionWillBeInstalled(); |
| 331 listener2.WaitUntilSatisfied(); | 331 listener2.WaitUntilSatisfied(); |
| 332 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); | 332 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); |
| 333 extension = service->GetExtensionById( | 333 extension = service->GetExtensionById( |
| 334 "ogjcoiohnmldgjemafoockdghcjciccf", false); | 334 "ogjcoiohnmldgjemafoockdghcjciccf", false); |
| 335 ASSERT_TRUE(extension); | 335 ASSERT_TRUE(extension); |
| 336 ASSERT_EQ("2.0", extension->VersionString()); | 336 ASSERT_EQ("2.0", extension->VersionString()); |
| 337 ASSERT_TRUE(notification_listener.started()); | 337 ASSERT_TRUE(notification_listener.started()); |
| 338 ASSERT_TRUE(notification_listener.finished()); | 338 ASSERT_TRUE(notification_listener.finished()); |
| 339 ASSERT_TRUE(ContainsKey(notification_listener.updates(), | 339 ASSERT_TRUE(base::ContainsKey(notification_listener.updates(), |
| 340 "ogjcoiohnmldgjemafoockdghcjciccf")); | 340 "ogjcoiohnmldgjemafoockdghcjciccf")); |
| 341 notification_listener.Reset(); | 341 notification_listener.Reset(); |
| 342 | 342 |
| 343 // Now try doing an update to version 3, which has been incorrectly | 343 // Now try doing an update to version 3, which has been incorrectly |
| 344 // signed. This should fail. | 344 // signed. This should fail. |
| 345 interceptor.SetResponseIgnoreQuery( | 345 interceptor.SetResponseIgnoreQuery( |
| 346 GURL("http://localhost/autoupdate/manifest"), | 346 GURL("http://localhost/autoupdate/manifest"), |
| 347 basedir.AppendASCII("manifest_v3.xml")); | 347 basedir.AppendASCII("manifest_v3.xml")); |
| 348 interceptor.SetResponseIgnoreQuery(GURL("http://localhost/autoupdate/v3.crx"), | 348 interceptor.SetResponseIgnoreQuery(GURL("http://localhost/autoupdate/v3.crx"), |
| 349 basedir.AppendASCII("v3.crx")); | 349 basedir.AppendASCII("v3.crx")); |
| 350 | 350 |
| 351 service->updater()->CheckNow(params); | 351 service->updater()->CheckNow(params); |
| 352 ASSERT_TRUE(WaitForExtensionInstallError()); | 352 ASSERT_TRUE(WaitForExtensionInstallError()); |
| 353 ASSERT_TRUE(notification_listener.started()); | 353 ASSERT_TRUE(notification_listener.started()); |
| 354 ASSERT_TRUE(notification_listener.finished()); | 354 ASSERT_TRUE(notification_listener.finished()); |
| 355 ASSERT_TRUE(ContainsKey(notification_listener.updates(), | 355 ASSERT_TRUE(base::ContainsKey(notification_listener.updates(), |
| 356 "ogjcoiohnmldgjemafoockdghcjciccf")); | 356 "ogjcoiohnmldgjemafoockdghcjciccf")); |
| 357 | 357 |
| 358 // Make sure the extension state is the same as before. | 358 // Make sure the extension state is the same as before. |
| 359 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); | 359 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); |
| 360 extension = service->GetExtensionById( | 360 extension = service->GetExtensionById( |
| 361 "ogjcoiohnmldgjemafoockdghcjciccf", false); | 361 "ogjcoiohnmldgjemafoockdghcjciccf", false); |
| 362 ASSERT_TRUE(extension); | 362 ASSERT_TRUE(extension); |
| 363 ASSERT_EQ("2.0", extension->VersionString()); | 363 ASSERT_EQ("2.0", extension->VersionString()); |
| 364 } | 364 } |
| 365 | 365 |
| 366 #if defined(OS_WIN) | 366 #if defined(OS_WIN) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 "ogjcoiohnmldgjemafoockdghcjciccf", false)); | 429 "ogjcoiohnmldgjemafoockdghcjciccf", false)); |
| 430 ASSERT_EQ("2.0", extension->VersionString()); | 430 ASSERT_EQ("2.0", extension->VersionString()); |
| 431 | 431 |
| 432 // The extension should have not made the callback because it is disabled. | 432 // The extension should have not made the callback because it is disabled. |
| 433 // When we enabled it, it should then make the callback. | 433 // When we enabled it, it should then make the callback. |
| 434 ASSERT_FALSE(listener2.was_satisfied()); | 434 ASSERT_FALSE(listener2.was_satisfied()); |
| 435 EnableExtension(extension->id()); | 435 EnableExtension(extension->id()); |
| 436 listener2.WaitUntilSatisfied(); | 436 listener2.WaitUntilSatisfied(); |
| 437 ASSERT_TRUE(notification_listener.started()); | 437 ASSERT_TRUE(notification_listener.started()); |
| 438 ASSERT_TRUE(notification_listener.finished()); | 438 ASSERT_TRUE(notification_listener.finished()); |
| 439 ASSERT_TRUE(ContainsKey(notification_listener.updates(), | 439 ASSERT_TRUE(base::ContainsKey(notification_listener.updates(), |
| 440 "ogjcoiohnmldgjemafoockdghcjciccf")); | 440 "ogjcoiohnmldgjemafoockdghcjciccf")); |
| 441 notification_listener.Reset(); | 441 notification_listener.Reset(); |
| 442 } | 442 } |
| 443 | 443 |
| 444 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalUrlUpdate) { | 444 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalUrlUpdate) { |
| 445 ExtensionService* service = extensions::ExtensionSystem::Get( | 445 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 446 browser()->profile())->extension_service(); | 446 browser()->profile())->extension_service(); |
| 447 const char kExtensionId[] = "ogjcoiohnmldgjemafoockdghcjciccf"; | 447 const char kExtensionId[] = "ogjcoiohnmldgjemafoockdghcjciccf"; |
| 448 extensions::ExtensionUpdater::CheckParams params; | 448 extensions::ExtensionUpdater::CheckParams params; |
| 449 | 449 |
| 450 base::FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); | 450 base::FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 UpdateProviderPolicy(policies); | 708 UpdateProviderPolicy(policies); |
| 709 extension_observer.WaitForExtensionWillBeInstalled(); | 709 extension_observer.WaitForExtensionWillBeInstalled(); |
| 710 | 710 |
| 711 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); | 711 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); |
| 712 extension = service->GetExtensionById(kExtensionId, false); | 712 extension = service->GetExtensionById(kExtensionId, false); |
| 713 ASSERT_TRUE(extension); | 713 ASSERT_TRUE(extension); |
| 714 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); | 714 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); |
| 715 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); | 715 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); |
| 716 EXPECT_TRUE(registry->disabled_extensions().is_empty()); | 716 EXPECT_TRUE(registry->disabled_extensions().is_empty()); |
| 717 } | 717 } |
| OLD | NEW |