| 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 <list> | 5 #include <list> |
| 6 #include <map> | 6 #include <map> |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 void SetupPendingExtensionManagerForTest( | 323 void SetupPendingExtensionManagerForTest( |
| 324 int count, | 324 int count, |
| 325 const GURL& update_url, | 325 const GURL& update_url, |
| 326 PendingExtensionManager* pending_extension_manager) { | 326 PendingExtensionManager* pending_extension_manager) { |
| 327 for (int i = 1; i <= count; ++i) { | 327 for (int i = 1; i <= count; ++i) { |
| 328 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install = | 328 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install = |
| 329 (i % 2 == 0) ? &ShouldInstallThemesOnly : &ShouldInstallExtensionsOnly; | 329 (i % 2 == 0) ? &ShouldInstallThemesOnly : &ShouldInstallExtensionsOnly; |
| 330 const bool kIsFromSync = true; | 330 const bool kIsFromSync = true; |
| 331 const bool kInstallSilently = true; | 331 const bool kInstallSilently = true; |
| 332 const bool kMarkAcknowledged = false; | 332 const bool kMarkAcknowledged = false; |
| 333 const bool kRemoteInstall = false; |
| 333 std::string id = id_util::GenerateId(base::StringPrintf("extension%i", i)); | 334 std::string id = id_util::GenerateId(base::StringPrintf("extension%i", i)); |
| 334 | 335 |
| 335 pending_extension_manager->AddForTesting( | 336 pending_extension_manager->AddForTesting( |
| 336 PendingExtensionInfo(id, | 337 PendingExtensionInfo(id, |
| 337 std::string(), | 338 std::string(), |
| 338 update_url, | 339 update_url, |
| 339 Version(), | 340 Version(), |
| 340 should_allow_install, | 341 should_allow_install, |
| 341 kIsFromSync, | 342 kIsFromSync, |
| 342 kInstallSilently, | 343 kInstallSilently, |
| 343 Manifest::INTERNAL, | 344 Manifest::INTERNAL, |
| 344 Extension::NO_FLAGS, | 345 Extension::NO_FLAGS, |
| 345 kMarkAcknowledged)); | 346 kMarkAcknowledged, |
| 347 kRemoteInstall)); |
| 346 } | 348 } |
| 347 } | 349 } |
| 348 | 350 |
| 349 class ServiceForManifestTests : public MockService { | 351 class ServiceForManifestTests : public MockService { |
| 350 public: | 352 public: |
| 351 explicit ServiceForManifestTests(TestExtensionPrefs* prefs) | 353 explicit ServiceForManifestTests(TestExtensionPrefs* prefs) |
| 352 : MockService(prefs), registry_(ExtensionRegistry::Get(profile())) {} | 354 : MockService(prefs), registry_(ExtensionRegistry::Get(profile())) {} |
| 353 | 355 |
| 354 virtual ~ServiceForManifestTests() {} | 356 virtual ~ServiceForManifestTests() {} |
| 355 | 357 |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 requests.insert(0); | 1011 requests.insert(0); |
| 1010 scoped_ptr<ExtensionDownloader::ExtensionFetch> fetch( | 1012 scoped_ptr<ExtensionDownloader::ExtensionFetch> fetch( |
| 1011 new ExtensionDownloader::ExtensionFetch( | 1013 new ExtensionDownloader::ExtensionFetch( |
| 1012 id, test_url, hash, version.GetString(), requests)); | 1014 id, test_url, hash, version.GetString(), requests)); |
| 1013 updater.downloader_->FetchUpdatedExtension(fetch.Pass()); | 1015 updater.downloader_->FetchUpdatedExtension(fetch.Pass()); |
| 1014 | 1016 |
| 1015 if (pending) { | 1017 if (pending) { |
| 1016 const bool kIsFromSync = true; | 1018 const bool kIsFromSync = true; |
| 1017 const bool kInstallSilently = true; | 1019 const bool kInstallSilently = true; |
| 1018 const bool kMarkAcknowledged = false; | 1020 const bool kMarkAcknowledged = false; |
| 1021 const bool kRemoteInstall = false; |
| 1019 PendingExtensionManager* pending_extension_manager = | 1022 PendingExtensionManager* pending_extension_manager = |
| 1020 service->pending_extension_manager(); | 1023 service->pending_extension_manager(); |
| 1021 pending_extension_manager->AddForTesting( | 1024 pending_extension_manager->AddForTesting( |
| 1022 PendingExtensionInfo(id, | 1025 PendingExtensionInfo(id, |
| 1023 std::string(), | 1026 std::string(), |
| 1024 test_url, | 1027 test_url, |
| 1025 version, | 1028 version, |
| 1026 &ShouldAlwaysInstall, | 1029 &ShouldAlwaysInstall, |
| 1027 kIsFromSync, | 1030 kIsFromSync, |
| 1028 kInstallSilently, | 1031 kInstallSilently, |
| 1029 Manifest::INTERNAL, | 1032 Manifest::INTERNAL, |
| 1030 Extension::NO_FLAGS, | 1033 Extension::NO_FLAGS, |
| 1031 kMarkAcknowledged)); | 1034 kMarkAcknowledged, |
| 1035 kRemoteInstall)); |
| 1032 } | 1036 } |
| 1033 | 1037 |
| 1034 // Call back the ExtensionUpdater with a 200 response and some test data | 1038 // Call back the ExtensionUpdater with a 200 response and some test data |
| 1035 base::FilePath extension_file_path(FILE_PATH_LITERAL("/whatever")); | 1039 base::FilePath extension_file_path(FILE_PATH_LITERAL("/whatever")); |
| 1036 fetcher = factory.GetFetcherByID(ExtensionDownloader::kExtensionFetcherId); | 1040 fetcher = factory.GetFetcherByID(ExtensionDownloader::kExtensionFetcherId); |
| 1037 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL); | 1041 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL); |
| 1038 EXPECT_TRUE(fetcher->GetLoadFlags() == kExpectedLoadFlags); | 1042 EXPECT_TRUE(fetcher->GetLoadFlags() == kExpectedLoadFlags); |
| 1039 | 1043 |
| 1040 if (retry) { | 1044 if (retry) { |
| 1041 // Reply with response code 500 to cause ExtensionDownloader to retry | 1045 // Reply with response code 500 to cause ExtensionDownloader to retry |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1782 // -prodversionmin (shouldn't update if browser version too old) | 1786 // -prodversionmin (shouldn't update if browser version too old) |
| 1783 // -manifests & updates arriving out of order / interleaved | 1787 // -manifests & updates arriving out of order / interleaved |
| 1784 // -malformed update url (empty, file://, has query, has a # fragment, etc.) | 1788 // -malformed update url (empty, file://, has query, has a # fragment, etc.) |
| 1785 // -An extension gets uninstalled while updates are in progress (so it doesn't | 1789 // -An extension gets uninstalled while updates are in progress (so it doesn't |
| 1786 // "come back from the dead") | 1790 // "come back from the dead") |
| 1787 // -An extension gets manually updated to v3 while we're downloading v2 (ie | 1791 // -An extension gets manually updated to v3 while we're downloading v2 (ie |
| 1788 // you don't get downgraded accidentally) | 1792 // you don't get downgraded accidentally) |
| 1789 // -An update manifest mentions multiple updates | 1793 // -An update manifest mentions multiple updates |
| 1790 | 1794 |
| 1791 } // namespace extensions | 1795 } // namespace extensions |
| OLD | NEW |