| 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 <map> | 6 #include <map> |
| 6 #include <set> | 7 #include <set> |
| 7 #include <vector> | 8 #include <vector> |
| 8 | 9 |
| 9 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 10 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 14 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 232 |
| 232 bool ShouldAlwaysInstall(const Extension& extension) { | 233 bool ShouldAlwaysInstall(const Extension& extension) { |
| 233 return true; | 234 return true; |
| 234 } | 235 } |
| 235 | 236 |
| 236 // Loads some pending extension records into a pending extension manager. | 237 // Loads some pending extension records into a pending extension manager. |
| 237 void SetupPendingExtensionManagerForTest( | 238 void SetupPendingExtensionManagerForTest( |
| 238 int count, | 239 int count, |
| 239 const GURL& update_url, | 240 const GURL& update_url, |
| 240 PendingExtensionManager* pending_extension_manager) { | 241 PendingExtensionManager* pending_extension_manager) { |
| 241 for (int i = 1; i <= count; i++) { | 242 for (int i = 1; i <= count; ++i) { |
| 242 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install = | 243 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install = |
| 243 (i % 2 == 0) ? &ShouldInstallThemesOnly : &ShouldInstallExtensionsOnly; | 244 (i % 2 == 0) ? &ShouldInstallThemesOnly : &ShouldInstallExtensionsOnly; |
| 244 const bool kIsFromSync = true; | 245 const bool kIsFromSync = true; |
| 245 const bool kInstallSilently = true; | 246 const bool kInstallSilently = true; |
| 246 std::string id = GenerateId(base::StringPrintf("extension%i", i)); | 247 std::string id = GenerateId(base::StringPrintf("extension%i", i)); |
| 247 | 248 |
| 248 pending_extension_manager->AddForTesting( | 249 pending_extension_manager->AddForTesting( |
| 249 id, | 250 PendingExtensionInfo(id, |
| 250 PendingExtensionInfo(update_url, | 251 update_url, |
| 251 Version(), | 252 Version(), |
| 252 should_allow_install, | 253 should_allow_install, |
| 253 kIsFromSync, | 254 kIsFromSync, |
| 254 kInstallSilently, | 255 kInstallSilently, |
| 255 Extension::INTERNAL)); | 256 Extension::INTERNAL)); |
| 256 } | 257 } |
| 257 } | 258 } |
| 258 | 259 |
| 259 class ServiceForManifestTests : public MockService { | 260 class ServiceForManifestTests : public MockService { |
| 260 public: | 261 public: |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 SetupPendingExtensionManagerForTest(3, GURL(), pending_extension_manager); | 695 SetupPendingExtensionManagerForTest(3, GURL(), pending_extension_manager); |
| 695 | 696 |
| 696 TestingProfile profile; | 697 TestingProfile profile; |
| 697 profile.CreateRequestContext(); | 698 profile.CreateRequestContext(); |
| 698 MockExtensionDownloaderDelegate delegate; | 699 MockExtensionDownloaderDelegate delegate; |
| 699 ExtensionDownloader downloader(&delegate, profile.GetRequestContext()); | 700 ExtensionDownloader downloader(&delegate, profile.GetRequestContext()); |
| 700 | 701 |
| 701 ManifestFetchData fetch_data(GURL("http://localhost/foo")); | 702 ManifestFetchData fetch_data(GURL("http://localhost/foo")); |
| 702 UpdateManifest::Results updates; | 703 UpdateManifest::Results updates; |
| 703 | 704 |
| 704 std::set<std::string> ids_for_update_check; | 705 std::list<std::string> ids_for_update_check; |
| 705 pending_extension_manager->GetPendingIdsForUpdateCheck( | 706 pending_extension_manager->GetPendingIdsForUpdateCheck( |
| 706 &ids_for_update_check); | 707 &ids_for_update_check); |
| 707 | 708 |
| 708 std::set<std::string>::const_iterator it; | 709 std::list<std::string>::const_iterator it; |
| 709 for (it = ids_for_update_check.begin(); | 710 for (it = ids_for_update_check.begin(); |
| 710 it != ids_for_update_check.end(); ++it) { | 711 it != ids_for_update_check.end(); ++it) { |
| 711 fetch_data.AddExtension(*it, "1.0.0.0", | 712 fetch_data.AddExtension(*it, "1.0.0.0", |
| 712 &kNeverPingedData, kEmptyUpdateUrlData, ""); | 713 &kNeverPingedData, kEmptyUpdateUrlData, ""); |
| 713 AddParseResult(*it, "1.1", "http://localhost/e1_1.1.crx", &updates); | 714 AddParseResult(*it, "1.1", "http://localhost/e1_1.1.crx", &updates); |
| 714 } | 715 } |
| 715 | 716 |
| 716 // The delegate will tell the downloader that all the extensions are | 717 // The delegate will tell the downloader that all the extensions are |
| 717 // pending. | 718 // pending. |
| 718 EXPECT_CALL(delegate, IsExtensionPending(_)).WillRepeatedly(Return(true)); | 719 EXPECT_CALL(delegate, IsExtensionPending(_)).WillRepeatedly(Return(true)); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 ASSERT_TRUE(version.get()); | 861 ASSERT_TRUE(version.get()); |
| 861 updater.downloader_->FetchUpdatedExtension( | 862 updater.downloader_->FetchUpdatedExtension( |
| 862 id, test_url, hash, version->GetString()); | 863 id, test_url, hash, version->GetString()); |
| 863 | 864 |
| 864 if (pending) { | 865 if (pending) { |
| 865 const bool kIsFromSync = true; | 866 const bool kIsFromSync = true; |
| 866 const bool kInstallSilently = true; | 867 const bool kInstallSilently = true; |
| 867 PendingExtensionManager* pending_extension_manager = | 868 PendingExtensionManager* pending_extension_manager = |
| 868 service->pending_extension_manager(); | 869 service->pending_extension_manager(); |
| 869 pending_extension_manager->AddForTesting( | 870 pending_extension_manager->AddForTesting( |
| 870 id, | 871 PendingExtensionInfo(id, test_url, *version, |
| 871 PendingExtensionInfo(test_url, *version, | |
| 872 &ShouldAlwaysInstall, kIsFromSync, | 872 &ShouldAlwaysInstall, kIsFromSync, |
| 873 kInstallSilently, | 873 kInstallSilently, |
| 874 Extension::INTERNAL)); | 874 Extension::INTERNAL)); |
| 875 } | 875 } |
| 876 | 876 |
| 877 // Call back the ExtensionUpdater with a 200 response and some test data | 877 // Call back the ExtensionUpdater with a 200 response and some test data |
| 878 FilePath extension_file_path(FILE_PATH_LITERAL("/whatever")); | 878 FilePath extension_file_path(FILE_PATH_LITERAL("/whatever")); |
| 879 fetcher = factory.GetFetcherByID(ExtensionDownloader::kExtensionFetcherId); | 879 fetcher = factory.GetFetcherByID(ExtensionDownloader::kExtensionFetcherId); |
| 880 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL); | 880 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL); |
| 881 EXPECT_TRUE(fetcher->GetLoadFlags() == kExpectedLoadFlags); | 881 EXPECT_TRUE(fetcher->GetLoadFlags() == kExpectedLoadFlags); |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 // -prodversionmin (shouldn't update if browser version too old) | 1507 // -prodversionmin (shouldn't update if browser version too old) |
| 1508 // -manifests & updates arriving out of order / interleaved | 1508 // -manifests & updates arriving out of order / interleaved |
| 1509 // -malformed update url (empty, file://, has query, has a # fragment, etc.) | 1509 // -malformed update url (empty, file://, has query, has a # fragment, etc.) |
| 1510 // -An extension gets uninstalled while updates are in progress (so it doesn't | 1510 // -An extension gets uninstalled while updates are in progress (so it doesn't |
| 1511 // "come back from the dead") | 1511 // "come back from the dead") |
| 1512 // -An extension gets manually updated to v3 while we're downloading v2 (ie | 1512 // -An extension gets manually updated to v3 while we're downloading v2 (ie |
| 1513 // you don't get downgraded accidentally) | 1513 // you don't get downgraded accidentally) |
| 1514 // -An update manifest mentions multiple updates | 1514 // -An update manifest mentions multiple updates |
| 1515 | 1515 |
| 1516 } // namespace extensions | 1516 } // namespace extensions |
| OLD | NEW |