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 <algorithm> | 5 #include <algorithm> |
6 #include <set> | 6 #include <set> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 6066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6077 const extensions::PendingExtensionInfo* info; | 6077 const extensions::PendingExtensionInfo* info; |
6078 EXPECT_TRUE( | 6078 EXPECT_TRUE( |
6079 (info = service()->pending_extension_manager()->GetById(good_crx))); | 6079 (info = service()->pending_extension_manager()->GetById(good_crx))); |
6080 EXPECT_EQ(ext_specifics->update_url(), info->update_url().spec()); | 6080 EXPECT_EQ(ext_specifics->update_url(), info->update_url().spec()); |
6081 EXPECT_TRUE(info->is_from_sync()); | 6081 EXPECT_TRUE(info->is_from_sync()); |
6082 EXPECT_TRUE(info->install_silently()); | 6082 EXPECT_TRUE(info->install_silently()); |
6083 EXPECT_EQ(Manifest::INTERNAL, info->install_source()); | 6083 EXPECT_EQ(Manifest::INTERNAL, info->install_source()); |
6084 // TODO(akalin): Figure out a way to test |info.ShouldAllowInstall()|. | 6084 // TODO(akalin): Figure out a way to test |info.ShouldAllowInstall()|. |
6085 } | 6085 } |
6086 | 6086 |
| 6087 TEST_F(ExtensionServiceTest, SyncUninstallForSupervisedUser) { |
| 6088 InitializeEmptyExtensionService(); |
| 6089 InitializeExtensionSyncService(); |
| 6090 extension_sync_service()->MergeDataAndStartSyncing( |
| 6091 syncer::EXTENSIONS, |
| 6092 syncer::SyncDataList(), |
| 6093 scoped_ptr<syncer::SyncChangeProcessor>( |
| 6094 new syncer::FakeSyncChangeProcessor), |
| 6095 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())); |
| 6096 |
| 6097 // Install two extensions. |
| 6098 base::FilePath path1 = data_dir().AppendASCII("good.crx"); |
| 6099 base::FilePath path2 = data_dir().AppendASCII("good2048.crx"); |
| 6100 const Extension* extensions[2] = { |
| 6101 InstallCRX(path1, INSTALL_NEW), |
| 6102 InstallCRX(path2, INSTALL_NEW, Extension::WAS_INSTALLED_BY_CUSTODIAN) |
| 6103 }; |
| 6104 |
| 6105 // Add a policy provider that will disallow any changes. |
| 6106 extensions::TestManagementPolicyProvider provider( |
| 6107 extensions::TestManagementPolicyProvider::PROHIBIT_MODIFY_STATUS); |
| 6108 GetManagementPolicy()->RegisterProvider(&provider); |
| 6109 |
| 6110 // Create a sync deletion for each extension. |
| 6111 syncer::SyncChangeList change_list; |
| 6112 for (int i = 0; i < 2; i++) { |
| 6113 const std::string& id = extensions[i]->id(); |
| 6114 sync_pb::EntitySpecifics specifics; |
| 6115 sync_pb::ExtensionSpecifics* ext_specifics = specifics.mutable_extension(); |
| 6116 ext_specifics->set_id(id); |
| 6117 ext_specifics->set_version("1.0"); |
| 6118 ext_specifics->set_installed_by_custodian( |
| 6119 extensions[i]->was_installed_by_custodian()); |
| 6120 syncer::SyncData sync_data = |
| 6121 syncer::SyncData::CreateLocalData(id, "Name", specifics); |
| 6122 change_list.push_back(syncer::SyncChange(FROM_HERE, |
| 6123 syncer::SyncChange::ACTION_DELETE, |
| 6124 sync_data)); |
| 6125 } |
| 6126 |
| 6127 // Save the extension ids, as uninstalling destroys the Extension instance. |
| 6128 std::string extension_ids[2] = { |
| 6129 extensions[0]->id(), |
| 6130 extensions[1]->id() |
| 6131 }; |
| 6132 |
| 6133 // Now apply the uninstallations. |
| 6134 extension_sync_service()->ProcessSyncChanges(FROM_HERE, change_list); |
| 6135 |
| 6136 // Uninstalling the extension without installed_by_custodian should have been |
| 6137 // blocked by policy. |
| 6138 EXPECT_TRUE(service()->GetExtensionById(extension_ids[0], true)); |
| 6139 |
| 6140 // But installed_by_custodian should result in bypassing the policy check. |
| 6141 EXPECT_FALSE(service()->GetExtensionById(extension_ids[1], true)); |
| 6142 } |
| 6143 |
6087 TEST_F(ExtensionServiceTest, InstallPriorityExternalUpdateUrl) { | 6144 TEST_F(ExtensionServiceTest, InstallPriorityExternalUpdateUrl) { |
6088 InitializeEmptyExtensionService(); | 6145 InitializeEmptyExtensionService(); |
6089 | 6146 |
6090 base::FilePath path = data_dir().AppendASCII("good.crx"); | 6147 base::FilePath path = data_dir().AppendASCII("good.crx"); |
6091 InstallCRX(path, INSTALL_NEW); | 6148 InstallCRX(path, INSTALL_NEW); |
6092 ValidatePrefKeyCount(1u); | 6149 ValidatePrefKeyCount(1u); |
6093 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); | 6150 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); |
6094 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL); | 6151 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL); |
6095 | 6152 |
6096 extensions::PendingExtensionManager* pending = | 6153 extensions::PendingExtensionManager* pending = |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6962 | 7019 |
6963 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, | 7020 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, |
6964 content::Source<Profile>(profile()), | 7021 content::Source<Profile>(profile()), |
6965 content::NotificationService::NoDetails()); | 7022 content::NotificationService::NoDetails()); |
6966 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); | 7023 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); |
6967 EXPECT_EQ(0u, registry()->enabled_extensions().size()); | 7024 EXPECT_EQ(0u, registry()->enabled_extensions().size()); |
6968 EXPECT_EQ(0u, registry()->disabled_extensions().size()); | 7025 EXPECT_EQ(0u, registry()->disabled_extensions().size()); |
6969 EXPECT_EQ(0u, registry()->terminated_extensions().size()); | 7026 EXPECT_EQ(0u, registry()->terminated_extensions().size()); |
6970 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); | 7027 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); |
6971 } | 7028 } |
OLD | NEW |