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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 void SetupPendingExtensionManagerForTest( | 345 void SetupPendingExtensionManagerForTest( |
346 int count, | 346 int count, |
347 const GURL& update_url, | 347 const GURL& update_url, |
348 PendingExtensionManager* pending_extension_manager) { | 348 PendingExtensionManager* pending_extension_manager) { |
349 for (int i = 1; i <= count; ++i) { | 349 for (int i = 1; i <= count; ++i) { |
350 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install = | 350 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install = |
351 (i % 2 == 0) ? &ShouldInstallThemesOnly : &ShouldInstallExtensionsOnly; | 351 (i % 2 == 0) ? &ShouldInstallThemesOnly : &ShouldInstallExtensionsOnly; |
352 const bool kIsFromSync = true; | 352 const bool kIsFromSync = true; |
353 const bool kInstallSilently = true; | 353 const bool kInstallSilently = true; |
354 const bool kMarkAcknowledged = false; | 354 const bool kMarkAcknowledged = false; |
| 355 const bool kRemoteInstall = false; |
355 std::string id = id_util::GenerateId(base::StringPrintf("extension%i", i)); | 356 std::string id = id_util::GenerateId(base::StringPrintf("extension%i", i)); |
356 | 357 |
357 pending_extension_manager->AddForTesting( | 358 pending_extension_manager->AddForTesting( |
358 PendingExtensionInfo(id, | 359 PendingExtensionInfo(id, |
359 std::string(), | 360 std::string(), |
360 update_url, | 361 update_url, |
361 Version(), | 362 Version(), |
362 should_allow_install, | 363 should_allow_install, |
363 kIsFromSync, | 364 kIsFromSync, |
364 kInstallSilently, | 365 kInstallSilently, |
365 Manifest::INTERNAL, | 366 Manifest::INTERNAL, |
366 Extension::NO_FLAGS, | 367 Extension::NO_FLAGS, |
367 kMarkAcknowledged)); | 368 kMarkAcknowledged, |
| 369 kRemoteInstall)); |
368 } | 370 } |
369 } | 371 } |
370 | 372 |
371 class ServiceForManifestTests : public MockService { | 373 class ServiceForManifestTests : public MockService { |
372 public: | 374 public: |
373 explicit ServiceForManifestTests(TestExtensionPrefs* prefs) | 375 explicit ServiceForManifestTests(TestExtensionPrefs* prefs) |
374 : MockService(prefs), registry_(ExtensionRegistry::Get(profile())) {} | 376 : MockService(prefs), registry_(ExtensionRegistry::Get(profile())) {} |
375 | 377 |
376 virtual ~ServiceForManifestTests() {} | 378 virtual ~ServiceForManifestTests() {} |
377 | 379 |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 requests.insert(0); | 1051 requests.insert(0); |
1050 scoped_ptr<ExtensionDownloader::ExtensionFetch> fetch( | 1052 scoped_ptr<ExtensionDownloader::ExtensionFetch> fetch( |
1051 new ExtensionDownloader::ExtensionFetch( | 1053 new ExtensionDownloader::ExtensionFetch( |
1052 id, test_url, hash, version.GetString(), requests)); | 1054 id, test_url, hash, version.GetString(), requests)); |
1053 updater.downloader_->FetchUpdatedExtension(fetch.Pass()); | 1055 updater.downloader_->FetchUpdatedExtension(fetch.Pass()); |
1054 | 1056 |
1055 if (pending) { | 1057 if (pending) { |
1056 const bool kIsFromSync = true; | 1058 const bool kIsFromSync = true; |
1057 const bool kInstallSilently = true; | 1059 const bool kInstallSilently = true; |
1058 const bool kMarkAcknowledged = false; | 1060 const bool kMarkAcknowledged = false; |
| 1061 const bool kRemoteInstall = false; |
1059 PendingExtensionManager* pending_extension_manager = | 1062 PendingExtensionManager* pending_extension_manager = |
1060 service->pending_extension_manager(); | 1063 service->pending_extension_manager(); |
1061 pending_extension_manager->AddForTesting( | 1064 pending_extension_manager->AddForTesting( |
1062 PendingExtensionInfo(id, | 1065 PendingExtensionInfo(id, |
1063 std::string(), | 1066 std::string(), |
1064 test_url, | 1067 test_url, |
1065 version, | 1068 version, |
1066 &ShouldAlwaysInstall, | 1069 &ShouldAlwaysInstall, |
1067 kIsFromSync, | 1070 kIsFromSync, |
1068 kInstallSilently, | 1071 kInstallSilently, |
1069 Manifest::INTERNAL, | 1072 Manifest::INTERNAL, |
1070 Extension::NO_FLAGS, | 1073 Extension::NO_FLAGS, |
1071 kMarkAcknowledged)); | 1074 kMarkAcknowledged, |
| 1075 kRemoteInstall)); |
1072 } | 1076 } |
1073 | 1077 |
1074 // Call back the ExtensionUpdater with a 200 response and some test data | 1078 // Call back the ExtensionUpdater with a 200 response and some test data |
1075 base::FilePath extension_file_path(FILE_PATH_LITERAL("/whatever")); | 1079 base::FilePath extension_file_path(FILE_PATH_LITERAL("/whatever")); |
1076 fetcher = factory.GetFetcherByID(ExtensionDownloader::kExtensionFetcherId); | 1080 fetcher = factory.GetFetcherByID(ExtensionDownloader::kExtensionFetcherId); |
1077 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL); | 1081 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL); |
1078 EXPECT_TRUE(fetcher->GetLoadFlags() == kExpectedLoadFlags); | 1082 EXPECT_TRUE(fetcher->GetLoadFlags() == kExpectedLoadFlags); |
1079 | 1083 |
1080 if (retry) { | 1084 if (retry) { |
1081 // Reply with response code 500 to cause ExtensionDownloader to retry | 1085 // Reply with response code 500 to cause ExtensionDownloader to retry |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1862 // -prodversionmin (shouldn't update if browser version too old) | 1866 // -prodversionmin (shouldn't update if browser version too old) |
1863 // -manifests & updates arriving out of order / interleaved | 1867 // -manifests & updates arriving out of order / interleaved |
1864 // -malformed update url (empty, file://, has query, has a # fragment, etc.) | 1868 // -malformed update url (empty, file://, has query, has a # fragment, etc.) |
1865 // -An extension gets uninstalled while updates are in progress (so it doesn't | 1869 // -An extension gets uninstalled while updates are in progress (so it doesn't |
1866 // "come back from the dead") | 1870 // "come back from the dead") |
1867 // -An extension gets manually updated to v3 while we're downloading v2 (ie | 1871 // -An extension gets manually updated to v3 while we're downloading v2 (ie |
1868 // you don't get downgraded accidentally) | 1872 // you don't get downgraded accidentally) |
1869 // -An update manifest mentions multiple updates | 1873 // -An update manifest mentions multiple updates |
1870 | 1874 |
1871 } // namespace extensions | 1875 } // namespace extensions |
OLD | NEW |