OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/extensions/extension_service_unittest.h" | 5 #include "chrome/browser/extensions/extension_service_unittest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 EXPECT_STREQ(version->GetString().c_str(), v2->GetString().c_str()); | 400 EXPECT_STREQ(version->GetString().c_str(), v2->GetString().c_str()); |
401 EXPECT_EQ(Manifest::EXTERNAL_PREF, location); | 401 EXPECT_EQ(Manifest::EXTERNAL_PREF, location); |
402 | 402 |
403 // Remove it so we won't count it ever again. | 403 // Remove it so we won't count it ever again. |
404 prefs_->Remove(id, NULL); | 404 prefs_->Remove(id, NULL); |
405 } | 405 } |
406 return true; | 406 return true; |
407 } | 407 } |
408 | 408 |
409 virtual bool OnExternalExtensionUpdateUrlFound( | 409 virtual bool OnExternalExtensionUpdateUrlFound( |
410 const std::string& id, const GURL& update_url, | 410 const std::string& id, |
| 411 const std::string& install_parameter, |
| 412 const GURL& update_url, |
411 Manifest::Location location, | 413 Manifest::Location location, |
412 int creation_flags, | 414 int creation_flags, |
413 bool mark_acknowledged) OVERRIDE { | 415 bool mark_acknowledged) OVERRIDE { |
414 ++ids_found_; | 416 ++ids_found_; |
415 base::DictionaryValue* pref; | 417 base::DictionaryValue* pref; |
416 // This tests is to make sure that the provider only notifies us of the | 418 // This tests is to make sure that the provider only notifies us of the |
417 // values we gave it. So if the id we doesn't exist in our internal | 419 // values we gave it. So if the id we doesn't exist in our internal |
418 // dictionary then something is wrong. | 420 // dictionary then something is wrong. |
419 EXPECT_TRUE(prefs_->GetDictionary(id, &pref)) | 421 EXPECT_TRUE(prefs_->GetDictionary(id, &pref)) |
420 << L"Got back ID (" << id.c_str() << ") we weren't expecting"; | 422 << L"Got back ID (" << id.c_str() << ") we weren't expecting"; |
421 EXPECT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD, location); | 423 EXPECT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD, location); |
422 | 424 |
423 if (pref) { | 425 if (pref) { |
424 EXPECT_TRUE(provider_->HasExtension(id)); | 426 EXPECT_TRUE(provider_->HasExtension(id)); |
425 | 427 |
426 // External extensions with update URLs do not have versions. | 428 // External extensions with update URLs do not have versions. |
427 scoped_ptr<Version> v1; | 429 scoped_ptr<Version> v1; |
428 Manifest::Location location1 = Manifest::INVALID_LOCATION; | 430 Manifest::Location location1 = Manifest::INVALID_LOCATION; |
429 EXPECT_TRUE(provider_->GetExtensionDetails(id, &location1, &v1)); | 431 EXPECT_TRUE(provider_->GetExtensionDetails(id, &location1, &v1)); |
430 EXPECT_FALSE(v1.get()); | 432 EXPECT_FALSE(v1.get()); |
431 EXPECT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD, location1); | 433 EXPECT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD, location1); |
432 | 434 |
| 435 std::string parsed_install_parameter; |
| 436 pref->GetString("install_parameter", &parsed_install_parameter); |
| 437 EXPECT_EQ(parsed_install_parameter, install_parameter); |
| 438 |
433 // Remove it so we won't count it again. | 439 // Remove it so we won't count it again. |
434 prefs_->Remove(id, NULL); | 440 prefs_->Remove(id, NULL); |
435 } | 441 } |
436 return true; | 442 return true; |
437 } | 443 } |
438 | 444 |
439 virtual void OnExternalProviderReady( | 445 virtual void OnExternalProviderReady( |
440 const extensions::ExternalProviderInterface* provider) OVERRIDE { | 446 const extensions::ExternalProviderInterface* provider) OVERRIDE { |
441 EXPECT_EQ(provider, provider_.get()); | 447 EXPECT_EQ(provider, provider_.get()); |
442 EXPECT_TRUE(provider->IsReady()); | 448 EXPECT_TRUE(provider->IsReady()); |
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1816 path, Manifest::EXTERNAL_PREF, | 1822 path, Manifest::EXTERNAL_PREF, |
1817 Extension::NO_FLAGS, false); | 1823 Extension::NO_FLAGS, false); |
1818 base::RunLoop().RunUntilIdle(); | 1824 base::RunLoop().RunUntilIdle(); |
1819 ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false)); | 1825 ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false)); |
1820 ValidateIntegerPref(good_crx, "location", | 1826 ValidateIntegerPref(good_crx, "location", |
1821 Extension::EXTERNAL_EXTENSION_UNINSTALLED); | 1827 Extension::EXTERNAL_EXTENSION_UNINSTALLED); |
1822 | 1828 |
1823 // Try adding the same extension from an external update URL. | 1829 // Try adding the same extension from an external update URL. |
1824 ASSERT_FALSE(service_->pending_extension_manager()->AddFromExternalUpdateUrl( | 1830 ASSERT_FALSE(service_->pending_extension_manager()->AddFromExternalUpdateUrl( |
1825 good_crx, | 1831 good_crx, |
| 1832 std::string(), |
1826 GURL("http:://fake.update/url"), | 1833 GURL("http:://fake.update/url"), |
1827 Manifest::EXTERNAL_PREF_DOWNLOAD, | 1834 Manifest::EXTERNAL_PREF_DOWNLOAD, |
1828 Extension::NO_FLAGS, | 1835 Extension::NO_FLAGS, |
1829 false)); | 1836 false)); |
1830 | 1837 |
1831 ASSERT_FALSE(service_->pending_extension_manager()->IsIdPending(good_crx)); | 1838 ASSERT_FALSE(service_->pending_extension_manager()->IsIdPending(good_crx)); |
1832 } | 1839 } |
1833 | 1840 |
1834 // Test that uninstalling an external extension does not crash when | 1841 // Test that uninstalling an external extension does not crash when |
1835 // the extension could not be loaded. | 1842 // the extension could not be loaded. |
(...skipping 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3190 #define MAYBE_UpdatePendingExternalCrx DISABLED_UpdatePendingExternalCrx | 3197 #define MAYBE_UpdatePendingExternalCrx DISABLED_UpdatePendingExternalCrx |
3191 #else | 3198 #else |
3192 #define MAYBE_UpdatePendingExternalCrx UpdatePendingExternalCrx | 3199 #define MAYBE_UpdatePendingExternalCrx UpdatePendingExternalCrx |
3193 #endif | 3200 #endif |
3194 // Test updating a pending CRX as if the source is an external extension | 3201 // Test updating a pending CRX as if the source is an external extension |
3195 // with an update URL. In this case we don't know if the CRX is a theme | 3202 // with an update URL. In this case we don't know if the CRX is a theme |
3196 // or not. | 3203 // or not. |
3197 TEST_F(ExtensionServiceTest, MAYBE_UpdatePendingExternalCrx) { | 3204 TEST_F(ExtensionServiceTest, MAYBE_UpdatePendingExternalCrx) { |
3198 InitializeEmptyExtensionService(); | 3205 InitializeEmptyExtensionService(); |
3199 EXPECT_TRUE(service_->pending_extension_manager()->AddFromExternalUpdateUrl( | 3206 EXPECT_TRUE(service_->pending_extension_manager()->AddFromExternalUpdateUrl( |
3200 theme_crx, GURL(), Manifest::EXTERNAL_PREF_DOWNLOAD, Extension::NO_FLAGS, | 3207 theme_crx, |
| 3208 std::string(), |
| 3209 GURL(), |
| 3210 Manifest::EXTERNAL_PREF_DOWNLOAD, |
| 3211 Extension::NO_FLAGS, |
3201 false)); | 3212 false)); |
3202 | 3213 |
3203 EXPECT_TRUE(service_->pending_extension_manager()->IsIdPending(theme_crx)); | 3214 EXPECT_TRUE(service_->pending_extension_manager()->IsIdPending(theme_crx)); |
3204 | 3215 |
3205 base::FilePath path = data_dir_.AppendASCII("theme.crx"); | 3216 base::FilePath path = data_dir_.AppendASCII("theme.crx"); |
3206 UpdateExtension(theme_crx, path, ENABLED); | 3217 UpdateExtension(theme_crx, path, ENABLED); |
3207 | 3218 |
3208 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(theme_crx)); | 3219 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(theme_crx)); |
3209 | 3220 |
3210 const Extension* extension = service_->GetExtensionById(theme_crx, true); | 3221 const Extension* extension = service_->GetExtensionById(theme_crx, true); |
(...skipping 18 matching lines...) Expand all Loading... |
3229 kGoodInstallSilently)); | 3240 kGoodInstallSilently)); |
3230 | 3241 |
3231 // Check that there is a pending crx, with is_from_sync set to true. | 3242 // Check that there is a pending crx, with is_from_sync set to true. |
3232 const extensions::PendingExtensionInfo* pending_extension_info; | 3243 const extensions::PendingExtensionInfo* pending_extension_info; |
3233 ASSERT_TRUE((pending_extension_info = service_->pending_extension_manager()-> | 3244 ASSERT_TRUE((pending_extension_info = service_->pending_extension_manager()-> |
3234 GetById(kGoodId))); | 3245 GetById(kGoodId))); |
3235 EXPECT_TRUE(pending_extension_info->is_from_sync()); | 3246 EXPECT_TRUE(pending_extension_info->is_from_sync()); |
3236 | 3247 |
3237 // Add a crx to be updated, with the same ID, from a non-sync source. | 3248 // Add a crx to be updated, with the same ID, from a non-sync source. |
3238 EXPECT_TRUE(service_->pending_extension_manager()->AddFromExternalUpdateUrl( | 3249 EXPECT_TRUE(service_->pending_extension_manager()->AddFromExternalUpdateUrl( |
3239 kGoodId, GURL(kGoodUpdateURL), Manifest::EXTERNAL_PREF_DOWNLOAD, | 3250 kGoodId, |
3240 Extension::NO_FLAGS, false)); | 3251 std::string(), |
| 3252 GURL(kGoodUpdateURL), |
| 3253 Manifest::EXTERNAL_PREF_DOWNLOAD, |
| 3254 Extension::NO_FLAGS, |
| 3255 false)); |
3241 | 3256 |
3242 // Check that there is a pending crx, with is_from_sync set to false. | 3257 // Check that there is a pending crx, with is_from_sync set to false. |
3243 ASSERT_TRUE((pending_extension_info = service_->pending_extension_manager()-> | 3258 ASSERT_TRUE((pending_extension_info = service_->pending_extension_manager()-> |
3244 GetById(kGoodId))); | 3259 GetById(kGoodId))); |
3245 EXPECT_FALSE(pending_extension_info->is_from_sync()); | 3260 EXPECT_FALSE(pending_extension_info->is_from_sync()); |
3246 EXPECT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD, | 3261 EXPECT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD, |
3247 pending_extension_info->install_source()); | 3262 pending_extension_info->install_source()); |
3248 | 3263 |
3249 // Add a crx to be installed from the update mechanism. | 3264 // Add a crx to be installed from the update mechanism. |
3250 EXPECT_FALSE(service_->pending_extension_manager()->AddFromSync( | 3265 EXPECT_FALSE(service_->pending_extension_manager()->AddFromSync( |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3317 InitializeEmptyExtensionService(); | 3332 InitializeEmptyExtensionService(); |
3318 | 3333 |
3319 base::FilePath path = data_dir_.AppendASCII("good.crx"); | 3334 base::FilePath path = data_dir_.AppendASCII("good.crx"); |
3320 const Extension* good = InstallCRX(path, INSTALL_NEW); | 3335 const Extension* good = InstallCRX(path, INSTALL_NEW); |
3321 ASSERT_EQ(1u, registry_->enabled_extensions().size()); | 3336 ASSERT_EQ(1u, registry_->enabled_extensions().size()); |
3322 | 3337 |
3323 EXPECT_FALSE(good->is_theme()); | 3338 EXPECT_FALSE(good->is_theme()); |
3324 | 3339 |
3325 // Use AddExtensionImpl() as AddFrom*() would balk. | 3340 // Use AddExtensionImpl() as AddFrom*() would balk. |
3326 service_->pending_extension_manager()->AddExtensionImpl( | 3341 service_->pending_extension_manager()->AddExtensionImpl( |
3327 good->id(), extensions::ManifestURL::GetUpdateURL(good), | 3342 good->id(), |
3328 Version(), &IsExtension, kGoodIsFromSync, | 3343 std::string(), |
3329 kGoodInstallSilently, Manifest::INTERNAL, | 3344 extensions::ManifestURL::GetUpdateURL(good), |
3330 Extension::NO_FLAGS, false); | 3345 Version(), |
| 3346 &IsExtension, |
| 3347 kGoodIsFromSync, |
| 3348 kGoodInstallSilently, |
| 3349 Manifest::INTERNAL, |
| 3350 Extension::NO_FLAGS, |
| 3351 false); |
3331 UpdateExtension(good->id(), path, ENABLED); | 3352 UpdateExtension(good->id(), path, ENABLED); |
3332 | 3353 |
3333 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(kGoodId)); | 3354 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(kGoodId)); |
3334 } | 3355 } |
3335 | 3356 |
3336 #if defined(ENABLE_BLACKLIST_TESTS) | 3357 #if defined(ENABLE_BLACKLIST_TESTS) |
3337 // Tests blacklisting then unblacklisting extensions after the service has been | 3358 // Tests blacklisting then unblacklisting extensions after the service has been |
3338 // initialized. | 3359 // initialized. |
3339 TEST_F(ExtensionServiceTest, SetUnsetBlacklistInPrefs) { | 3360 TEST_F(ExtensionServiceTest, SetUnsetBlacklistInPrefs) { |
3340 extensions::TestBlacklist test_blacklist; | 3361 extensions::TestBlacklist test_blacklist; |
(...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5021 "{" | 5042 "{" |
5022 " \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\": {" | 5043 " \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\": {" |
5023 " \"external_crx\": \"RandomExtension.crx\"," | 5044 " \"external_crx\": \"RandomExtension.crx\"," |
5024 " \"external_version\": \"1.0\"" | 5045 " \"external_version\": \"1.0\"" |
5025 " }," | 5046 " }," |
5026 " \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\": {" | 5047 " \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\": {" |
5027 " \"external_crx\": \"RandomExtension2.crx\"," | 5048 " \"external_crx\": \"RandomExtension2.crx\"," |
5028 " \"external_version\": \"2.0\"" | 5049 " \"external_version\": \"2.0\"" |
5029 " }," | 5050 " }," |
5030 " \"cccccccccccccccccccccccccccccccc\": {" | 5051 " \"cccccccccccccccccccccccccccccccc\": {" |
5031 " \"external_update_url\": \"http:\\\\foo.com/update\"" | 5052 " \"external_update_url\": \"http:\\\\foo.com/update\"," |
| 5053 " \"install_parameter\": \"id\"" |
5032 " }" | 5054 " }" |
5033 "}"; | 5055 "}"; |
5034 EXPECT_EQ(3, visitor.Visit(json_data)); | 5056 EXPECT_EQ(3, visitor.Visit(json_data)); |
5035 | 5057 |
5036 // Simulate an external_extensions.json file that contains seven invalid | 5058 // Simulate an external_extensions.json file that contains seven invalid |
5037 // records: | 5059 // records: |
5038 // - One that is missing the 'external_crx' key. | 5060 // - One that is missing the 'external_crx' key. |
5039 // - One that is missing the 'external_version' key. | 5061 // - One that is missing the 'external_version' key. |
5040 // - One that is specifying .. in the path. | 5062 // - One that is specifying .. in the path. |
5041 // - One that specifies both a file and update URL. | 5063 // - One that specifies both a file and update URL. |
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6204 InstallCRX(path, INSTALL_NEW); | 6226 InstallCRX(path, INSTALL_NEW); |
6205 ValidatePrefKeyCount(1u); | 6227 ValidatePrefKeyCount(1u); |
6206 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); | 6228 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); |
6207 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL); | 6229 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL); |
6208 | 6230 |
6209 extensions::PendingExtensionManager* pending = | 6231 extensions::PendingExtensionManager* pending = |
6210 service_->pending_extension_manager(); | 6232 service_->pending_extension_manager(); |
6211 EXPECT_FALSE(pending->IsIdPending(kGoodId)); | 6233 EXPECT_FALSE(pending->IsIdPending(kGoodId)); |
6212 | 6234 |
6213 // Skip install when the location is the same. | 6235 // Skip install when the location is the same. |
6214 EXPECT_FALSE( | 6236 EXPECT_FALSE(service_->OnExternalExtensionUpdateUrlFound(kGoodId, |
6215 service_->OnExternalExtensionUpdateUrlFound( | 6237 std::string(), |
6216 kGoodId, GURL(kGoodUpdateURL), Manifest::INTERNAL, | 6238 GURL(kGoodUpdateURL), |
6217 Extension::NO_FLAGS, false)); | 6239 Manifest::INTERNAL, |
| 6240 Extension::NO_FLAGS, |
| 6241 false)); |
6218 EXPECT_FALSE(pending->IsIdPending(kGoodId)); | 6242 EXPECT_FALSE(pending->IsIdPending(kGoodId)); |
6219 | 6243 |
6220 // Install when the location has higher priority. | 6244 // Install when the location has higher priority. |
6221 EXPECT_TRUE( | 6245 EXPECT_TRUE(service_->OnExternalExtensionUpdateUrlFound( |
6222 service_->OnExternalExtensionUpdateUrlFound( | 6246 kGoodId, |
6223 kGoodId, GURL(kGoodUpdateURL), Manifest::EXTERNAL_POLICY_DOWNLOAD, | 6247 std::string(), |
6224 Extension::NO_FLAGS, false)); | 6248 GURL(kGoodUpdateURL), |
| 6249 Manifest::EXTERNAL_POLICY_DOWNLOAD, |
| 6250 Extension::NO_FLAGS, |
| 6251 false)); |
6225 EXPECT_TRUE(pending->IsIdPending(kGoodId)); | 6252 EXPECT_TRUE(pending->IsIdPending(kGoodId)); |
6226 | 6253 |
6227 // Try the low priority again. Should be rejected. | 6254 // Try the low priority again. Should be rejected. |
6228 EXPECT_FALSE( | 6255 EXPECT_FALSE(service_->OnExternalExtensionUpdateUrlFound( |
6229 service_->OnExternalExtensionUpdateUrlFound( | 6256 kGoodId, |
6230 kGoodId, GURL(kGoodUpdateURL), Manifest::EXTERNAL_PREF_DOWNLOAD, | 6257 std::string(), |
6231 Extension::NO_FLAGS, false)); | 6258 GURL(kGoodUpdateURL), |
| 6259 Manifest::EXTERNAL_PREF_DOWNLOAD, |
| 6260 Extension::NO_FLAGS, |
| 6261 false)); |
6232 // The existing record should still be present in the pending extension | 6262 // The existing record should still be present in the pending extension |
6233 // manager. | 6263 // manager. |
6234 EXPECT_TRUE(pending->IsIdPending(kGoodId)); | 6264 EXPECT_TRUE(pending->IsIdPending(kGoodId)); |
6235 | 6265 |
6236 pending->Remove(kGoodId); | 6266 pending->Remove(kGoodId); |
6237 | 6267 |
6238 // Skip install when the location has the same priority as the installed | 6268 // Skip install when the location has the same priority as the installed |
6239 // location. | 6269 // location. |
6240 EXPECT_FALSE(service_->OnExternalExtensionUpdateUrlFound( | 6270 EXPECT_FALSE(service_->OnExternalExtensionUpdateUrlFound(kGoodId, |
6241 kGoodId, GURL(kGoodUpdateURL), Manifest::INTERNAL, | 6271 std::string(), |
6242 Extension::NO_FLAGS, false)); | 6272 GURL(kGoodUpdateURL), |
| 6273 Manifest::INTERNAL, |
| 6274 Extension::NO_FLAGS, |
| 6275 false)); |
6243 | 6276 |
6244 EXPECT_FALSE(pending->IsIdPending(kGoodId)); | 6277 EXPECT_FALSE(pending->IsIdPending(kGoodId)); |
6245 } | 6278 } |
6246 | 6279 |
6247 TEST_F(ExtensionServiceTest, InstallPriorityExternalLocalFile) { | 6280 TEST_F(ExtensionServiceTest, InstallPriorityExternalLocalFile) { |
6248 Version older_version("0.1.0.0"); | 6281 Version older_version("0.1.0.0"); |
6249 Version newer_version("2.0.0.0"); | 6282 Version newer_version("2.0.0.0"); |
6250 | 6283 |
6251 // We don't want the extension to be installed. A path that doesn't | 6284 // We don't want the extension to be installed. A path that doesn't |
6252 // point to a valid CRX ensures this. | 6285 // point to a valid CRX ensures this. |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6470 EXPECT_FALSE( | 6503 EXPECT_FALSE( |
6471 service_->OnExternalExtensionFileFound( | 6504 service_->OnExternalExtensionFileFound( |
6472 kGoodId, &kVersion123, kInvalidPathToCrx, | 6505 kGoodId, &kVersion123, kInvalidPathToCrx, |
6473 Manifest::EXTERNAL_REGISTRY, kCreationFlags, kDontMarkAcknowledged)); | 6506 Manifest::EXTERNAL_REGISTRY, kCreationFlags, kDontMarkAcknowledged)); |
6474 EXPECT_TRUE((info = pending->GetById(kGoodId))); | 6507 EXPECT_TRUE((info = pending->GetById(kGoodId))); |
6475 EXPECT_TRUE(info->version().IsValid()); | 6508 EXPECT_TRUE(info->version().IsValid()); |
6476 EXPECT_TRUE(info->version().Equals(kVersion124)); | 6509 EXPECT_TRUE(info->version().Equals(kVersion124)); |
6477 | 6510 |
6478 // Adding the latest version from the webstore overrides a specific version. | 6511 // Adding the latest version from the webstore overrides a specific version. |
6479 GURL kUpdateUrl("http://example.com/update"); | 6512 GURL kUpdateUrl("http://example.com/update"); |
6480 EXPECT_TRUE( | 6513 EXPECT_TRUE(service_->OnExternalExtensionUpdateUrlFound( |
6481 service_->OnExternalExtensionUpdateUrlFound( | 6514 kGoodId, |
6482 kGoodId, kUpdateUrl, Manifest::EXTERNAL_POLICY_DOWNLOAD, | 6515 std::string(), |
6483 Extension::NO_FLAGS, false)); | 6516 kUpdateUrl, |
| 6517 Manifest::EXTERNAL_POLICY_DOWNLOAD, |
| 6518 Extension::NO_FLAGS, |
| 6519 false)); |
6484 EXPECT_TRUE((info = pending->GetById(kGoodId))); | 6520 EXPECT_TRUE((info = pending->GetById(kGoodId))); |
6485 EXPECT_FALSE(info->version().IsValid()); | 6521 EXPECT_FALSE(info->version().IsValid()); |
6486 } | 6522 } |
6487 | 6523 |
6488 // This makes sure we can package and install CRX files that use whitelisted | 6524 // This makes sure we can package and install CRX files that use whitelisted |
6489 // permissions. | 6525 // permissions. |
6490 TEST_F(ExtensionServiceTest, InstallWhitelistedExtension) { | 6526 TEST_F(ExtensionServiceTest, InstallWhitelistedExtension) { |
6491 std::string test_id = "hdkklepkcpckhnpgjnmbdfhehckloojk"; | 6527 std::string test_id = "hdkklepkcpckhnpgjnmbdfhehckloojk"; |
6492 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 6528 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
6493 switches::kWhitelistedExtensionID, test_id); | 6529 switches::kWhitelistedExtensionID, test_id); |
(...skipping 23 matching lines...) Expand all Loading... |
6517 | 6553 |
6518 // All tests use a single extension. Put the id and path in member vars | 6554 // All tests use a single extension. Put the id and path in member vars |
6519 // that all methods can read. | 6555 // that all methods can read. |
6520 crx_id_ = kGoodId; | 6556 crx_id_ = kGoodId; |
6521 crx_path_ = data_dir_.AppendASCII("good.crx"); | 6557 crx_path_ = data_dir_.AppendASCII("good.crx"); |
6522 } | 6558 } |
6523 | 6559 |
6524 // Fake an external source adding a URL to fetch an extension from. | 6560 // Fake an external source adding a URL to fetch an extension from. |
6525 bool AddPendingExternalPrefUrl() { | 6561 bool AddPendingExternalPrefUrl() { |
6526 return service_->pending_extension_manager()->AddFromExternalUpdateUrl( | 6562 return service_->pending_extension_manager()->AddFromExternalUpdateUrl( |
6527 crx_id_, GURL(), Manifest::EXTERNAL_PREF_DOWNLOAD, | 6563 crx_id_, |
6528 Extension::NO_FLAGS, false); | 6564 std::string(), |
| 6565 GURL(), |
| 6566 Manifest::EXTERNAL_PREF_DOWNLOAD, |
| 6567 Extension::NO_FLAGS, |
| 6568 false); |
6529 } | 6569 } |
6530 | 6570 |
6531 // Fake an external file from external_extensions.json. | 6571 // Fake an external file from external_extensions.json. |
6532 bool AddPendingExternalPrefFileInstall() { | 6572 bool AddPendingExternalPrefFileInstall() { |
6533 Version version("1.0.0.0"); | 6573 Version version("1.0.0.0"); |
6534 | 6574 |
6535 return service_->OnExternalExtensionFileFound( | 6575 return service_->OnExternalExtensionFileFound( |
6536 crx_id_, &version, crx_path_, Manifest::EXTERNAL_PREF, | 6576 crx_id_, &version, crx_path_, Manifest::EXTERNAL_PREF, |
6537 Extension::NO_FLAGS, false); | 6577 Extension::NO_FLAGS, false); |
6538 } | 6578 } |
6539 | 6579 |
6540 // Fake a request from sync to install an extension. | 6580 // Fake a request from sync to install an extension. |
6541 bool AddPendingSyncInstall() { | 6581 bool AddPendingSyncInstall() { |
6542 return service_->pending_extension_manager()->AddFromSync( | 6582 return service_->pending_extension_manager()->AddFromSync( |
6543 crx_id_, GURL(kGoodUpdateURL), &IsExtension, kGoodInstallSilently); | 6583 crx_id_, GURL(kGoodUpdateURL), &IsExtension, kGoodInstallSilently); |
6544 } | 6584 } |
6545 | 6585 |
6546 // Fake a policy install. | 6586 // Fake a policy install. |
6547 bool AddPendingPolicyInstall() { | 6587 bool AddPendingPolicyInstall() { |
6548 // Get path to the CRX with id |kGoodId|. | 6588 // Get path to the CRX with id |kGoodId|. |
6549 return service_->OnExternalExtensionUpdateUrlFound( | 6589 return service_->OnExternalExtensionUpdateUrlFound( |
6550 crx_id_, GURL(), Manifest::EXTERNAL_POLICY_DOWNLOAD, | 6590 crx_id_, |
6551 Extension::NO_FLAGS, false); | 6591 std::string(), |
| 6592 GURL(), |
| 6593 Manifest::EXTERNAL_POLICY_DOWNLOAD, |
| 6594 Extension::NO_FLAGS, |
| 6595 false); |
6552 } | 6596 } |
6553 | 6597 |
6554 // Get the install source of a pending extension. | 6598 // Get the install source of a pending extension. |
6555 Manifest::Location GetPendingLocation() { | 6599 Manifest::Location GetPendingLocation() { |
6556 const extensions::PendingExtensionInfo* info; | 6600 const extensions::PendingExtensionInfo* info; |
6557 EXPECT_TRUE((info = service_->pending_extension_manager()-> | 6601 EXPECT_TRUE((info = service_->pending_extension_manager()-> |
6558 GetById(crx_id_))); | 6602 GetById(crx_id_))); |
6559 return info->install_source(); | 6603 return info->install_source(); |
6560 } | 6604 } |
6561 | 6605 |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6948 // ReconcileKnownDisabled(). | 6992 // ReconcileKnownDisabled(). |
6949 service_->EnableExtension(good2); | 6993 service_->EnableExtension(good2); |
6950 service_->ReconcileKnownDisabled(); | 6994 service_->ReconcileKnownDisabled(); |
6951 expected_extensions.insert(good2); | 6995 expected_extensions.insert(good2); |
6952 expected_disabled_extensions.erase(good2); | 6996 expected_disabled_extensions.erase(good2); |
6953 | 6997 |
6954 EXPECT_EQ(expected_extensions, registry_->enabled_extensions().GetIDs()); | 6998 EXPECT_EQ(expected_extensions, registry_->enabled_extensions().GetIDs()); |
6955 EXPECT_EQ(expected_disabled_extensions, | 6999 EXPECT_EQ(expected_disabled_extensions, |
6956 registry_->disabled_extensions().GetIDs()); | 7000 registry_->disabled_extensions().GetIDs()); |
6957 } | 7001 } |
OLD | NEW |