OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <algorithm> | 5 #include <algorithm> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/json/json_parser.h" | 8 #include "base/json/json_parser.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 } | 416 } |
417 | 417 |
418 // Tests functionality of new preference as to deprecate legacy | 418 // Tests functionality of new preference as to deprecate legacy |
419 // ExtensionInstallBlacklist policy. | 419 // ExtensionInstallBlacklist policy. |
420 TEST_F(ExtensionManagementServiceTest, NewInstallBlacklist) { | 420 TEST_F(ExtensionManagementServiceTest, NewInstallBlacklist) { |
421 // Set the new dictionary preference. | 421 // Set the new dictionary preference. |
422 { | 422 { |
423 PrefUpdater updater(pref_service_.get()); | 423 PrefUpdater updater(pref_service_.get()); |
424 updater.SetBlacklistedByDefault(false); // Allowed by default. | 424 updater.SetBlacklistedByDefault(false); // Allowed by default. |
425 updater.SetIndividualExtensionInstallationAllowed(kTargetExtension, false); | 425 updater.SetIndividualExtensionInstallationAllowed(kTargetExtension, false); |
| 426 updater.ClearPerExtensionSettings(kTargetExtension2); |
| 427 updater.ClearPerExtensionSettings(kOtherExtension); |
426 } | 428 } |
427 EXPECT_FALSE(extension_management_->BlacklistedByDefault()); | 429 EXPECT_FALSE(extension_management_->BlacklistedByDefault()); |
428 EXPECT_EQ(extension_management_->ReadById(kTargetExtension).installation_mode, | 430 EXPECT_EQ(extension_management_->ReadById(kTargetExtension).installation_mode, |
429 ExtensionManagement::INSTALLATION_BLOCKED); | 431 ExtensionManagement::INSTALLATION_BLOCKED); |
430 EXPECT_EQ(extension_management_->ReadById(kOtherExtension).installation_mode, | 432 EXPECT_EQ(extension_management_->ReadById(kOtherExtension).installation_mode, |
431 ExtensionManagement::INSTALLATION_ALLOWED); | 433 ExtensionManagement::INSTALLATION_ALLOWED); |
432 | 434 |
433 // Set legacy preference. | 435 // Set legacy preference. |
434 base::ListValue denied_list_pref; | 436 base::ListValue denied_list_pref; |
435 denied_list_pref.AppendString("*"); | 437 denied_list_pref.AppendString("*"); |
(...skipping 16 matching lines...) Expand all Loading... |
452 } | 454 } |
453 | 455 |
454 // Tests functionality of new preference as to deprecate legacy | 456 // Tests functionality of new preference as to deprecate legacy |
455 // ExtensionInstallWhitelist policy. | 457 // ExtensionInstallWhitelist policy. |
456 TEST_F(ExtensionManagementServiceTest, NewInstallWhitelist) { | 458 TEST_F(ExtensionManagementServiceTest, NewInstallWhitelist) { |
457 // Set the new dictionary preference. | 459 // Set the new dictionary preference. |
458 { | 460 { |
459 PrefUpdater updater(pref_service_.get()); | 461 PrefUpdater updater(pref_service_.get()); |
460 updater.SetBlacklistedByDefault(true); // Disallowed by default. | 462 updater.SetBlacklistedByDefault(true); // Disallowed by default. |
461 updater.SetIndividualExtensionInstallationAllowed(kTargetExtension, true); | 463 updater.SetIndividualExtensionInstallationAllowed(kTargetExtension, true); |
| 464 updater.ClearPerExtensionSettings(kTargetExtension2); |
| 465 updater.ClearPerExtensionSettings(kOtherExtension); |
462 } | 466 } |
463 EXPECT_TRUE(extension_management_->BlacklistedByDefault()); | 467 EXPECT_TRUE(extension_management_->BlacklistedByDefault()); |
464 EXPECT_EQ(extension_management_->ReadById(kTargetExtension).installation_mode, | 468 EXPECT_EQ(extension_management_->ReadById(kTargetExtension).installation_mode, |
465 ExtensionManagement::INSTALLATION_ALLOWED); | 469 ExtensionManagement::INSTALLATION_ALLOWED); |
466 EXPECT_EQ(extension_management_->ReadById(kOtherExtension).installation_mode, | 470 EXPECT_EQ(extension_management_->ReadById(kOtherExtension).installation_mode, |
467 ExtensionManagement::INSTALLATION_BLOCKED); | 471 ExtensionManagement::INSTALLATION_BLOCKED); |
468 | 472 |
469 // Set legacy preference. | 473 // Set legacy preference. |
470 base::ListValue denied_list_pref; | 474 base::ListValue denied_list_pref; |
471 denied_list_pref.AppendString(kTargetExtension); | 475 denied_list_pref.AppendString(kTargetExtension); |
(...skipping 21 matching lines...) Expand all Loading... |
493 // legacy ones. | 497 // legacy ones. |
494 base::ListValue denied_list_pref; | 498 base::ListValue denied_list_pref; |
495 denied_list_pref.AppendString(kTargetExtension); | 499 denied_list_pref.AppendString(kTargetExtension); |
496 SetPref(true, pref_names::kInstallDenyList, denied_list_pref.DeepCopy()); | 500 SetPref(true, pref_names::kInstallDenyList, denied_list_pref.DeepCopy()); |
497 | 501 |
498 // Set the new dictionary preference. | 502 // Set the new dictionary preference. |
499 { | 503 { |
500 PrefUpdater updater(pref_service_.get()); | 504 PrefUpdater updater(pref_service_.get()); |
501 updater.SetIndividualExtensionAutoInstalled( | 505 updater.SetIndividualExtensionAutoInstalled( |
502 kTargetExtension, kExampleUpdateUrl, true); | 506 kTargetExtension, kExampleUpdateUrl, true); |
| 507 updater.ClearPerExtensionSettings(kOtherExtension); |
503 } | 508 } |
504 EXPECT_EQ(extension_management_->ReadById(kTargetExtension).installation_mode, | 509 EXPECT_EQ(extension_management_->ReadById(kTargetExtension).installation_mode, |
505 ExtensionManagement::INSTALLATION_FORCED); | 510 ExtensionManagement::INSTALLATION_FORCED); |
506 EXPECT_EQ(extension_management_->ReadById(kTargetExtension).update_url, | 511 EXPECT_EQ(extension_management_->ReadById(kTargetExtension).update_url, |
507 kExampleUpdateUrl); | 512 kExampleUpdateUrl); |
508 EXPECT_EQ(extension_management_->ReadById(kOtherExtension).installation_mode, | 513 EXPECT_EQ(extension_management_->ReadById(kOtherExtension).installation_mode, |
509 ExtensionManagement::INSTALLATION_ALLOWED); | 514 ExtensionManagement::INSTALLATION_ALLOWED); |
510 } | 515 } |
511 | 516 |
512 // Tests the flag value indicating that extensions are blacklisted by default. | 517 // Tests the flag value indicating that extensions are blacklisted by default. |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 EXPECT_FALSE(error.empty()); | 656 EXPECT_FALSE(error.empty()); |
652 | 657 |
653 CreateExtension(Manifest::INTERNAL); | 658 CreateExtension(Manifest::INTERNAL); |
654 error.clear(); | 659 error.clear(); |
655 EXPECT_FALSE(MustRemainEnabled(extension_.get(), NULL)); | 660 EXPECT_FALSE(MustRemainEnabled(extension_.get(), NULL)); |
656 EXPECT_FALSE(MustRemainEnabled(extension_.get(), &error)); | 661 EXPECT_FALSE(MustRemainEnabled(extension_.get(), &error)); |
657 EXPECT_TRUE(error.empty()); | 662 EXPECT_TRUE(error.empty()); |
658 } | 663 } |
659 | 664 |
660 } // namespace extensions | 665 } // namespace extensions |
OLD | NEW |