| 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 "chrome/browser/extensions/extension_prefs_unittest.h" | 5 #include "chrome/browser/extensions/extension_prefs_unittest.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/prefs/mock_pref_change_callback.h" | 10 #include "base/prefs/mock_pref_change_callback.h" |
| 11 #include "base/prefs/pref_change_registrar.h" | 11 #include "base/prefs/pref_change_registrar.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/extensions/extension_pref_value_map.h" | 16 #include "chrome/browser/extensions/extension_pref_value_map.h" |
| 17 #include "chrome/browser/extensions/extension_prefs.h" | 17 #include "chrome/browser/extensions/extension_prefs.h" |
| 18 #include "chrome/browser/prefs/pref_service_syncable.h" | 18 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 19 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 19 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 20 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
| 21 #include "chrome/common/extensions/extension_manifest_constants.h" | |
| 22 #include "chrome/common/extensions/permissions/permission_set.h" | 21 #include "chrome/common/extensions/permissions/permission_set.h" |
| 23 #include "chrome/common/extensions/permissions/permissions_info.h" | 22 #include "chrome/common/extensions/permissions/permissions_info.h" |
| 24 #include "components/user_prefs/pref_registry_syncable.h" | 23 #include "components/user_prefs/pref_registry_syncable.h" |
| 25 #include "content/public/browser/notification_details.h" | 24 #include "content/public/browser/notification_details.h" |
| 26 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
| 27 #include "content/public/test/mock_notification_observer.h" | 26 #include "content/public/test/mock_notification_observer.h" |
| 27 #include "extensions/common/manifest_constants.h" |
| 28 #include "sync/api/string_ordinal.h" | 28 #include "sync/api/string_ordinal.h" |
| 29 | 29 |
| 30 using base::Time; | 30 using base::Time; |
| 31 using base::TimeDelta; | 31 using base::TimeDelta; |
| 32 using content::BrowserThread; | 32 using content::BrowserThread; |
| 33 | 33 |
| 34 namespace extensions { | 34 namespace extensions { |
| 35 | 35 |
| 36 static void AddPattern(URLPatternSet* extent, const std::string& pattern) { | 36 static void AddPattern(URLPatternSet* extent, const std::string& pattern) { |
| 37 int schemes = URLPattern::SCHEME_ALL; | 37 int schemes = URLPattern::SCHEME_ALL; |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 std::string blacklisted_id_; | 434 std::string blacklisted_id_; |
| 435 }; | 435 }; |
| 436 TEST_F(ExtensionPrefsAcknowledgment, Acknowledgment) {} | 436 TEST_F(ExtensionPrefsAcknowledgment, Acknowledgment) {} |
| 437 | 437 |
| 438 // Tests the idle install information functions. | 438 // Tests the idle install information functions. |
| 439 class ExtensionPrefsDelayedInstallInfo : public ExtensionPrefsTest { | 439 class ExtensionPrefsDelayedInstallInfo : public ExtensionPrefsTest { |
| 440 public: | 440 public: |
| 441 // Sets idle install information for one test extension. | 441 // Sets idle install information for one test extension. |
| 442 void SetIdleInfo(std::string id, int num) { | 442 void SetIdleInfo(std::string id, int num) { |
| 443 DictionaryValue manifest; | 443 DictionaryValue manifest; |
| 444 manifest.SetString(extension_manifest_keys::kName, "test"); | 444 manifest.SetString(manifest_keys::kName, "test"); |
| 445 manifest.SetString(extension_manifest_keys::kVersion, | 445 manifest.SetString(manifest_keys::kVersion, "1." + base::IntToString(num)); |
| 446 "1." + base::IntToString(num)); | |
| 447 base::FilePath path = | 446 base::FilePath path = |
| 448 prefs_.extensions_dir().AppendASCII(base::IntToString(num)); | 447 prefs_.extensions_dir().AppendASCII(base::IntToString(num)); |
| 449 std::string errors; | 448 std::string errors; |
| 450 scoped_refptr<Extension> extension = Extension::Create( | 449 scoped_refptr<Extension> extension = Extension::Create( |
| 451 path, Manifest::INTERNAL, manifest, Extension::NO_FLAGS, id, &errors); | 450 path, Manifest::INTERNAL, manifest, Extension::NO_FLAGS, id, &errors); |
| 452 ASSERT_TRUE(extension.get()) << errors; | 451 ASSERT_TRUE(extension.get()) << errors; |
| 453 ASSERT_EQ(id, extension->id()); | 452 ASSERT_EQ(id, extension->id()); |
| 454 prefs()->SetDelayedInstallInfo(extension.get(), | 453 prefs()->SetDelayedInstallInfo(extension.get(), |
| 455 Extension::ENABLED, | 454 Extension::ENABLED, |
| 456 Blacklist::NOT_BLACKLISTED, | 455 Blacklist::NOT_BLACKLISTED, |
| 457 ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE, | 456 ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE, |
| 458 syncer::StringOrdinal()); | 457 syncer::StringOrdinal()); |
| 459 } | 458 } |
| 460 | 459 |
| 461 // Verifies that we get back expected idle install information previously | 460 // Verifies that we get back expected idle install information previously |
| 462 // set by SetIdleInfo. | 461 // set by SetIdleInfo. |
| 463 void VerifyIdleInfo(std::string id, int num) { | 462 void VerifyIdleInfo(std::string id, int num) { |
| 464 scoped_ptr<ExtensionInfo> info(prefs()->GetDelayedInstallInfo(id)); | 463 scoped_ptr<ExtensionInfo> info(prefs()->GetDelayedInstallInfo(id)); |
| 465 ASSERT_TRUE(info); | 464 ASSERT_TRUE(info); |
| 466 std::string version; | 465 std::string version; |
| 467 ASSERT_TRUE(info->extension_manifest->GetString("version", &version)); | 466 ASSERT_TRUE(info->extension_manifest->GetString("version", &version)); |
| 468 ASSERT_EQ("1." + base::IntToString(num), version); | 467 ASSERT_EQ("1." + base::IntToString(num), version); |
| 469 ASSERT_EQ(base::IntToString(num), | 468 ASSERT_EQ(base::IntToString(num), |
| 470 info->extension_path.BaseName().MaybeAsASCII()); | 469 info->extension_path.BaseName().MaybeAsASCII()); |
| 471 } | 470 } |
| 472 | 471 |
| 473 bool HasInfoForId(extensions::ExtensionPrefs::ExtensionsInfo* info, | 472 bool HasInfoForId(ExtensionPrefs::ExtensionsInfo* info, |
| 474 const std::string& id) { | 473 const std::string& id) { |
| 475 for (size_t i = 0; i < info->size(); ++i) { | 474 for (size_t i = 0; i < info->size(); ++i) { |
| 476 if (info->at(i)->extension_id == id) | 475 if (info->at(i)->extension_id == id) |
| 477 return true; | 476 return true; |
| 478 } | 477 } |
| 479 return false; | 478 return false; |
| 480 } | 479 } |
| 481 | 480 |
| 482 virtual void Initialize() OVERRIDE { | 481 virtual void Initialize() OVERRIDE { |
| 483 PathService::Get(chrome::DIR_TEST_DATA, &basedir_); | 482 PathService::Get(chrome::DIR_TEST_DATA, &basedir_); |
| 484 now_ = Time::Now(); | 483 now_ = Time::Now(); |
| 485 id1_ = prefs_.AddExtensionAndReturnId("1"); | 484 id1_ = prefs_.AddExtensionAndReturnId("1"); |
| 486 id2_ = prefs_.AddExtensionAndReturnId("2"); | 485 id2_ = prefs_.AddExtensionAndReturnId("2"); |
| 487 id3_ = prefs_.AddExtensionAndReturnId("3"); | 486 id3_ = prefs_.AddExtensionAndReturnId("3"); |
| 488 id4_ = prefs_.AddExtensionAndReturnId("4"); | 487 id4_ = prefs_.AddExtensionAndReturnId("4"); |
| 489 | 488 |
| 490 // Set info for two extensions, then remove it. | 489 // Set info for two extensions, then remove it. |
| 491 SetIdleInfo(id1_, 1); | 490 SetIdleInfo(id1_, 1); |
| 492 SetIdleInfo(id2_, 2); | 491 SetIdleInfo(id2_, 2); |
| 493 VerifyIdleInfo(id1_, 1); | 492 VerifyIdleInfo(id1_, 1); |
| 494 VerifyIdleInfo(id2_, 2); | 493 VerifyIdleInfo(id2_, 2); |
| 495 scoped_ptr<extensions::ExtensionPrefs::ExtensionsInfo> info( | 494 scoped_ptr<ExtensionPrefs::ExtensionsInfo> info( |
| 496 prefs()->GetAllDelayedInstallInfo()); | 495 prefs()->GetAllDelayedInstallInfo()); |
| 497 EXPECT_EQ(2u, info->size()); | 496 EXPECT_EQ(2u, info->size()); |
| 498 EXPECT_TRUE(HasInfoForId(info.get(), id1_)); | 497 EXPECT_TRUE(HasInfoForId(info.get(), id1_)); |
| 499 EXPECT_TRUE(HasInfoForId(info.get(), id2_)); | 498 EXPECT_TRUE(HasInfoForId(info.get(), id2_)); |
| 500 prefs()->RemoveDelayedInstallInfo(id1_); | 499 prefs()->RemoveDelayedInstallInfo(id1_); |
| 501 prefs()->RemoveDelayedInstallInfo(id2_); | 500 prefs()->RemoveDelayedInstallInfo(id2_); |
| 502 info = prefs()->GetAllDelayedInstallInfo(); | 501 info = prefs()->GetAllDelayedInstallInfo(); |
| 503 EXPECT_TRUE(info->empty()); | 502 EXPECT_TRUE(info->empty()); |
| 504 | 503 |
| 505 // Try getting/removing info for an id that used to have info set. | 504 // Try getting/removing info for an id that used to have info set. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 517 SetIdleInfo(id4_, 4); | 516 SetIdleInfo(id4_, 4); |
| 518 VerifyIdleInfo(id1_, 1); | 517 VerifyIdleInfo(id1_, 1); |
| 519 VerifyIdleInfo(id2_, 2); | 518 VerifyIdleInfo(id2_, 2); |
| 520 VerifyIdleInfo(id3_, 3); | 519 VerifyIdleInfo(id3_, 3); |
| 521 VerifyIdleInfo(id4_, 4); | 520 VerifyIdleInfo(id4_, 4); |
| 522 prefs()->RemoveDelayedInstallInfo(id3_); | 521 prefs()->RemoveDelayedInstallInfo(id3_); |
| 523 } | 522 } |
| 524 | 523 |
| 525 virtual void Verify() OVERRIDE { | 524 virtual void Verify() OVERRIDE { |
| 526 // Make sure the info for the 3 extensions we expect is present. | 525 // Make sure the info for the 3 extensions we expect is present. |
| 527 scoped_ptr<extensions::ExtensionPrefs::ExtensionsInfo> info( | 526 scoped_ptr<ExtensionPrefs::ExtensionsInfo> info( |
| 528 prefs()->GetAllDelayedInstallInfo()); | 527 prefs()->GetAllDelayedInstallInfo()); |
| 529 EXPECT_EQ(3u, info->size()); | 528 EXPECT_EQ(3u, info->size()); |
| 530 EXPECT_TRUE(HasInfoForId(info.get(), id1_)); | 529 EXPECT_TRUE(HasInfoForId(info.get(), id1_)); |
| 531 EXPECT_TRUE(HasInfoForId(info.get(), id2_)); | 530 EXPECT_TRUE(HasInfoForId(info.get(), id2_)); |
| 532 EXPECT_TRUE(HasInfoForId(info.get(), id4_)); | 531 EXPECT_TRUE(HasInfoForId(info.get(), id4_)); |
| 533 VerifyIdleInfo(id1_, 1); | 532 VerifyIdleInfo(id1_, 1); |
| 534 VerifyIdleInfo(id2_, 2); | 533 VerifyIdleInfo(id2_, 2); |
| 535 VerifyIdleInfo(id4_, 4); | 534 VerifyIdleInfo(id4_, 4); |
| 536 | 535 |
| 537 // Make sure there isn't info the for the one extension id we removed. | 536 // Make sure there isn't info the for the one extension id we removed. |
| 538 EXPECT_FALSE(prefs()->GetDelayedInstallInfo(id3_)); | 537 EXPECT_FALSE(prefs()->GetDelayedInstallInfo(id3_)); |
| 539 } | 538 } |
| 540 | 539 |
| 541 protected: | 540 protected: |
| 542 Time now_; | 541 Time now_; |
| 543 base::FilePath basedir_; | 542 base::FilePath basedir_; |
| 544 std::string id1_; | 543 std::string id1_; |
| 545 std::string id2_; | 544 std::string id2_; |
| 546 std::string id3_; | 545 std::string id3_; |
| 547 std::string id4_; | 546 std::string id4_; |
| 548 }; | 547 }; |
| 549 TEST_F(ExtensionPrefsDelayedInstallInfo, DelayedInstallInfo) {} | 548 TEST_F(ExtensionPrefsDelayedInstallInfo, DelayedInstallInfo) {} |
| 550 | 549 |
| 551 // Tests the FinishDelayedInstallInfo function. | 550 // Tests the FinishDelayedInstallInfo function. |
| 552 class ExtensionPrefsFinishDelayedInstallInfo : public ExtensionPrefsTest { | 551 class ExtensionPrefsFinishDelayedInstallInfo : public ExtensionPrefsTest { |
| 553 public: | 552 public: |
| 554 virtual void Initialize() OVERRIDE { | 553 virtual void Initialize() OVERRIDE { |
| 555 DictionaryValue dictionary; | 554 DictionaryValue dictionary; |
| 556 dictionary.SetString(extension_manifest_keys::kName, "test"); | 555 dictionary.SetString(manifest_keys::kName, "test"); |
| 557 dictionary.SetString(extension_manifest_keys::kVersion, "0.1"); | 556 dictionary.SetString(manifest_keys::kVersion, "0.1"); |
| 558 dictionary.SetString(extension_manifest_keys::kBackgroundPage, | 557 dictionary.SetString(manifest_keys::kBackgroundPage, "background.html"); |
| 559 "background.html"); | |
| 560 scoped_refptr<Extension> extension = | 558 scoped_refptr<Extension> extension = |
| 561 prefs_.AddExtensionWithManifest(dictionary, Manifest::INTERNAL); | 559 prefs_.AddExtensionWithManifest(dictionary, Manifest::INTERNAL); |
| 562 id_ = extension->id(); | 560 id_ = extension->id(); |
| 563 | 561 |
| 564 | 562 |
| 565 // Set idle info | 563 // Set idle info |
| 566 DictionaryValue manifest; | 564 DictionaryValue manifest; |
| 567 manifest.SetString(extension_manifest_keys::kName, "test"); | 565 manifest.SetString(manifest_keys::kName, "test"); |
| 568 manifest.SetString(extension_manifest_keys::kVersion, "0.2"); | 566 manifest.SetString(manifest_keys::kVersion, "0.2"); |
| 569 scoped_ptr<ListValue> scripts(new ListValue); | 567 scoped_ptr<ListValue> scripts(new ListValue); |
| 570 scripts->AppendString("test.js"); | 568 scripts->AppendString("test.js"); |
| 571 manifest.Set(extension_manifest_keys::kBackgroundScripts, | 569 manifest.Set(manifest_keys::kBackgroundScripts, scripts.release()); |
| 572 scripts.release()); | |
| 573 base::FilePath path = | 570 base::FilePath path = |
| 574 prefs_.extensions_dir().AppendASCII("test_0.2"); | 571 prefs_.extensions_dir().AppendASCII("test_0.2"); |
| 575 std::string errors; | 572 std::string errors; |
| 576 scoped_refptr<Extension> new_extension = Extension::Create( | 573 scoped_refptr<Extension> new_extension = Extension::Create( |
| 577 path, Manifest::INTERNAL, manifest, Extension::NO_FLAGS, id_, &errors); | 574 path, Manifest::INTERNAL, manifest, Extension::NO_FLAGS, id_, &errors); |
| 578 ASSERT_TRUE(new_extension.get()) << errors; | 575 ASSERT_TRUE(new_extension.get()) << errors; |
| 579 ASSERT_EQ(id_, new_extension->id()); | 576 ASSERT_EQ(id_, new_extension->id()); |
| 580 prefs()->SetDelayedInstallInfo(new_extension.get(), | 577 prefs()->SetDelayedInstallInfo(new_extension.get(), |
| 581 Extension::ENABLED, | 578 Extension::ENABLED, |
| 582 Blacklist::NOT_BLACKLISTED, | 579 Blacklist::NOT_BLACKLISTED, |
| 583 ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE, | 580 ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE, |
| 584 syncer::StringOrdinal()); | 581 syncer::StringOrdinal()); |
| 585 | 582 |
| 586 // Finish idle installation | 583 // Finish idle installation |
| 587 ASSERT_TRUE(prefs()->FinishDelayedInstallInfo(id_)); | 584 ASSERT_TRUE(prefs()->FinishDelayedInstallInfo(id_)); |
| 588 } | 585 } |
| 589 | 586 |
| 590 virtual void Verify() OVERRIDE { | 587 virtual void Verify() OVERRIDE { |
| 591 EXPECT_FALSE(prefs()->GetDelayedInstallInfo(id_)); | 588 EXPECT_FALSE(prefs()->GetDelayedInstallInfo(id_)); |
| 592 | 589 |
| 593 const DictionaryValue* manifest; | 590 const DictionaryValue* manifest; |
| 594 ASSERT_TRUE(prefs()->ReadPrefAsDictionary(id_, "manifest", &manifest)); | 591 ASSERT_TRUE(prefs()->ReadPrefAsDictionary(id_, "manifest", &manifest)); |
| 595 ASSERT_TRUE(manifest); | 592 ASSERT_TRUE(manifest); |
| 596 std::string value; | 593 std::string value; |
| 597 EXPECT_TRUE(manifest->GetString(extension_manifest_keys::kName, &value)); | 594 EXPECT_TRUE(manifest->GetString(manifest_keys::kName, &value)); |
| 598 EXPECT_EQ("test", value); | 595 EXPECT_EQ("test", value); |
| 599 EXPECT_TRUE(manifest->GetString(extension_manifest_keys::kVersion, &value)); | 596 EXPECT_TRUE(manifest->GetString(manifest_keys::kVersion, &value)); |
| 600 EXPECT_EQ("0.2", value); | 597 EXPECT_EQ("0.2", value); |
| 601 EXPECT_FALSE(manifest->GetString(extension_manifest_keys::kBackgroundPage, | 598 EXPECT_FALSE(manifest->GetString(manifest_keys::kBackgroundPage, &value)); |
| 602 &value)); | |
| 603 const ListValue* scripts; | 599 const ListValue* scripts; |
| 604 ASSERT_TRUE(manifest->GetList(extension_manifest_keys::kBackgroundScripts, | 600 ASSERT_TRUE(manifest->GetList(manifest_keys::kBackgroundScripts, &scripts)); |
| 605 &scripts)); | |
| 606 EXPECT_EQ(1u, scripts->GetSize()); | 601 EXPECT_EQ(1u, scripts->GetSize()); |
| 607 } | 602 } |
| 608 | 603 |
| 609 protected: | 604 protected: |
| 610 std::string id_; | 605 std::string id_; |
| 611 }; | 606 }; |
| 612 TEST_F(ExtensionPrefsFinishDelayedInstallInfo, FinishDelayedInstallInfo) {} | 607 TEST_F(ExtensionPrefsFinishDelayedInstallInfo, FinishDelayedInstallInfo) {} |
| 613 | 608 |
| 614 class ExtensionPrefsOnExtensionInstalled : public ExtensionPrefsTest { | 609 class ExtensionPrefsOnExtensionInstalled : public ExtensionPrefsTest { |
| 615 public: | 610 public: |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 private: | 651 private: |
| 657 scoped_refptr<Extension> extension_; | 652 scoped_refptr<Extension> extension_; |
| 658 }; | 653 }; |
| 659 TEST_F(ExtensionPrefsAppDraggedByUser, ExtensionPrefsAppDraggedByUser) {} | 654 TEST_F(ExtensionPrefsAppDraggedByUser, ExtensionPrefsAppDraggedByUser) {} |
| 660 | 655 |
| 661 class ExtensionPrefsFlags : public ExtensionPrefsTest { | 656 class ExtensionPrefsFlags : public ExtensionPrefsTest { |
| 662 public: | 657 public: |
| 663 virtual void Initialize() OVERRIDE { | 658 virtual void Initialize() OVERRIDE { |
| 664 { | 659 { |
| 665 base::DictionaryValue dictionary; | 660 base::DictionaryValue dictionary; |
| 666 dictionary.SetString(extension_manifest_keys::kName, "from_webstore"); | 661 dictionary.SetString(manifest_keys::kName, "from_webstore"); |
| 667 dictionary.SetString(extension_manifest_keys::kVersion, "0.1"); | 662 dictionary.SetString(manifest_keys::kVersion, "0.1"); |
| 668 webstore_extension_ = prefs_.AddExtensionWithManifestAndFlags( | 663 webstore_extension_ = prefs_.AddExtensionWithManifestAndFlags( |
| 669 dictionary, Manifest::INTERNAL, Extension::FROM_WEBSTORE); | 664 dictionary, Manifest::INTERNAL, Extension::FROM_WEBSTORE); |
| 670 } | 665 } |
| 671 | 666 |
| 672 { | 667 { |
| 673 base::DictionaryValue dictionary; | 668 base::DictionaryValue dictionary; |
| 674 dictionary.SetString(extension_manifest_keys::kName, "from_bookmark"); | 669 dictionary.SetString(manifest_keys::kName, "from_bookmark"); |
| 675 dictionary.SetString(extension_manifest_keys::kVersion, "0.1"); | 670 dictionary.SetString(manifest_keys::kVersion, "0.1"); |
| 676 bookmark_extension_ = prefs_.AddExtensionWithManifestAndFlags( | 671 bookmark_extension_ = prefs_.AddExtensionWithManifestAndFlags( |
| 677 dictionary, Manifest::INTERNAL, Extension::FROM_BOOKMARK); | 672 dictionary, Manifest::INTERNAL, Extension::FROM_BOOKMARK); |
| 678 } | 673 } |
| 679 | 674 |
| 680 { | 675 { |
| 681 base::DictionaryValue dictionary; | 676 base::DictionaryValue dictionary; |
| 682 dictionary.SetString(extension_manifest_keys::kName, | 677 dictionary.SetString(manifest_keys::kName, "was_installed_by_default"); |
| 683 "was_installed_by_default"); | 678 dictionary.SetString(manifest_keys::kVersion, "0.1"); |
| 684 dictionary.SetString(extension_manifest_keys::kVersion, "0.1"); | |
| 685 default_extension_ = prefs_.AddExtensionWithManifestAndFlags( | 679 default_extension_ = prefs_.AddExtensionWithManifestAndFlags( |
| 686 dictionary, | 680 dictionary, |
| 687 Manifest::INTERNAL, | 681 Manifest::INTERNAL, |
| 688 Extension::WAS_INSTALLED_BY_DEFAULT); | 682 Extension::WAS_INSTALLED_BY_DEFAULT); |
| 689 } | 683 } |
| 690 } | 684 } |
| 691 | 685 |
| 692 virtual void Verify() OVERRIDE { | 686 virtual void Verify() OVERRIDE { |
| 693 EXPECT_TRUE(prefs()->IsFromWebStore(webstore_extension_->id())); | 687 EXPECT_TRUE(prefs()->IsFromWebStore(webstore_extension_->id())); |
| 694 EXPECT_FALSE(prefs()->IsFromBookmark(webstore_extension_->id())); | 688 EXPECT_FALSE(prefs()->IsFromBookmark(webstore_extension_->id())); |
| 695 | 689 |
| 696 EXPECT_TRUE(prefs()->IsFromBookmark(bookmark_extension_->id())); | 690 EXPECT_TRUE(prefs()->IsFromBookmark(bookmark_extension_->id())); |
| 697 EXPECT_FALSE(prefs()->IsFromWebStore(bookmark_extension_->id())); | 691 EXPECT_FALSE(prefs()->IsFromWebStore(bookmark_extension_->id())); |
| 698 | 692 |
| 699 EXPECT_TRUE(prefs()->WasInstalledByDefault(default_extension_->id())); | 693 EXPECT_TRUE(prefs()->WasInstalledByDefault(default_extension_->id())); |
| 700 } | 694 } |
| 701 | 695 |
| 702 private: | 696 private: |
| 703 scoped_refptr<Extension> webstore_extension_; | 697 scoped_refptr<Extension> webstore_extension_; |
| 704 scoped_refptr<Extension> bookmark_extension_; | 698 scoped_refptr<Extension> bookmark_extension_; |
| 705 scoped_refptr<Extension> default_extension_; | 699 scoped_refptr<Extension> default_extension_; |
| 706 }; | 700 }; |
| 707 TEST_F(ExtensionPrefsFlags, ExtensionPrefsFlags) {} | 701 TEST_F(ExtensionPrefsFlags, ExtensionPrefsFlags) {} |
| 708 | 702 |
| 709 PrefsPrepopulatedTestBase::PrefsPrepopulatedTestBase() | 703 PrefsPrepopulatedTestBase::PrefsPrepopulatedTestBase() |
| 710 : ExtensionPrefsTest() { | 704 : ExtensionPrefsTest() { |
| 711 DictionaryValue simple_dict; | 705 DictionaryValue simple_dict; |
| 712 std::string error; | 706 std::string error; |
| 713 | 707 |
| 714 simple_dict.SetString(extension_manifest_keys::kVersion, "1.0.0.0"); | 708 simple_dict.SetString(manifest_keys::kVersion, "1.0.0.0"); |
| 715 simple_dict.SetString(extension_manifest_keys::kName, "unused"); | 709 simple_dict.SetString(manifest_keys::kName, "unused"); |
| 716 | 710 |
| 717 extension1_ = Extension::Create( | 711 extension1_ = Extension::Create( |
| 718 prefs_.temp_dir().AppendASCII("ext1_"), | 712 prefs_.temp_dir().AppendASCII("ext1_"), |
| 719 Manifest::EXTERNAL_PREF, | 713 Manifest::EXTERNAL_PREF, |
| 720 simple_dict, | 714 simple_dict, |
| 721 Extension::NO_FLAGS, | 715 Extension::NO_FLAGS, |
| 722 &error); | 716 &error); |
| 723 extension2_ = Extension::Create( | 717 extension2_ = Extension::Create( |
| 724 prefs_.temp_dir().AppendASCII("ext2_"), | 718 prefs_.temp_dir().AppendASCII("ext2_"), |
| 725 Manifest::EXTERNAL_PREF, | 719 Manifest::EXTERNAL_PREF, |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 | 813 |
| 820 private: | 814 private: |
| 821 scoped_refptr<const Extension> extension_a_; | 815 scoped_refptr<const Extension> extension_a_; |
| 822 scoped_refptr<const Extension> extension_b_; | 816 scoped_refptr<const Extension> extension_b_; |
| 823 scoped_refptr<const Extension> extension_c_; | 817 scoped_refptr<const Extension> extension_c_; |
| 824 }; | 818 }; |
| 825 TEST_F(ExtensionPrefsBlacklistedExtensions, | 819 TEST_F(ExtensionPrefsBlacklistedExtensions, |
| 826 ExtensionPrefsBlacklistedExtensions) {} | 820 ExtensionPrefsBlacklistedExtensions) {} |
| 827 | 821 |
| 828 } // namespace extensions | 822 } // namespace extensions |
| OLD | NEW |