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 "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
7 #include "base/threading/sequenced_worker_pool.h" | 7 #include "base/threading/sequenced_worker_pool.h" |
8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
9 #include "chrome/browser/extensions/extension_browsertest.h" | 9 #include "chrome/browser/extensions/extension_browsertest.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 146 } |
147 | 147 |
148 // Tests that no error appears if the user disabled the extension. | 148 // Tests that no error appears if the user disabled the extension. |
149 IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, UserDisabled) { | 149 IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, UserDisabled) { |
150 const Extension* extension = InstallIncreasingPermissionExtensionV1(); | 150 const Extension* extension = InstallIncreasingPermissionExtensionV1(); |
151 DisableExtension(extension->id()); | 151 DisableExtension(extension->id()); |
152 extension = UpdateIncreasingPermissionExtension(extension, path_v2_, 0); | 152 extension = UpdateIncreasingPermissionExtension(extension, path_v2_, 0); |
153 ASSERT_FALSE(GetExtensionDisabledGlobalError()); | 153 ASSERT_FALSE(GetExtensionDisabledGlobalError()); |
154 } | 154 } |
155 | 155 |
156 // Test that no error appears if the disable reason is unknown | |
157 // (but probably was by the user). | |
158 IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, | |
159 UnknownReasonSamePermissions) { | |
160 const Extension* extension = InstallIncreasingPermissionExtensionV1(); | |
161 DisableExtension(extension->id()); | |
162 // Clear disable reason to simulate legacy disables. | |
163 ExtensionPrefs::Get(browser()->profile()) | |
164 ->ClearDisableReasons(extension->id()); | |
165 // Upgrade to version 2. Infer from version 1 having the same permissions | |
166 // granted by the user that it was disabled by the user. | |
167 extension = UpdateIncreasingPermissionExtension(extension, path_v2_, 0); | |
168 ASSERT_TRUE(extension); | |
169 ASSERT_FALSE(GetExtensionDisabledGlobalError()); | |
170 } | |
171 | |
172 // Test that an error appears if the disable reason is unknown | |
173 // (but probably was for increased permissions). | |
174 IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, | |
175 UnknownReasonHigherPermissions) { | |
176 const Extension* extension = InstallAndUpdateIncreasingPermissionsExtension(); | |
177 // Clear disable reason to simulate legacy disables. | |
178 ExtensionPrefs::Get(service_->profile()) | |
179 ->ClearDisableReasons(extension->id()); | |
180 // We now have version 2 but only accepted permissions for version 1. | |
181 GlobalError* error = GetExtensionDisabledGlobalError(); | |
182 ASSERT_TRUE(error); | |
183 // Also, remove the upgrade error for version 2. | |
184 GlobalErrorServiceFactory::GetForProfile(browser()->profile())-> | |
185 RemoveGlobalError(error); | |
186 delete error; | |
187 // Upgrade to version 3, with even higher permissions. Infer from | |
188 // version 2 having higher-than-granted permissions that it was disabled | |
189 // for permissions increase. | |
190 extension = UpdateIncreasingPermissionExtension(extension, path_v3_, 0); | |
191 ASSERT_TRUE(extension); | |
192 ASSERT_TRUE(GetExtensionDisabledGlobalError()); | |
193 } | |
194 | |
195 // Test that an error appears if the extension gets disabled because a | 156 // Test that an error appears if the extension gets disabled because a |
196 // version with higher permissions was installed by sync. | 157 // version with higher permissions was installed by sync. |
197 IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, | 158 IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, |
198 HigherPermissionsFromSync) { | 159 HigherPermissionsFromSync) { |
199 // Get data for extension v2 (disabled) into sync. | 160 // Get data for extension v2 (disabled) into sync. |
200 const Extension* extension = InstallAndUpdateIncreasingPermissionsExtension(); | 161 const Extension* extension = InstallAndUpdateIncreasingPermissionsExtension(); |
201 std::string extension_id = extension->id(); | 162 std::string extension_id = extension->id(); |
202 ExtensionSyncService* sync_service = ExtensionSyncService::Get( | 163 ExtensionSyncService* sync_service = ExtensionSyncService::Get( |
203 browser()->profile()); | 164 browser()->profile()); |
204 extensions::ExtensionSyncData sync_data = | 165 extensions::ExtensionSyncData sync_data = |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 | 248 |
288 const Extension* extension = service_->GetExtensionById(extension_id, true); | 249 const Extension* extension = service_->GetExtensionById(extension_id, true); |
289 ASSERT_TRUE(extension); | 250 ASSERT_TRUE(extension); |
290 EXPECT_EQ("2", extension->VersionString()); | 251 EXPECT_EQ("2", extension->VersionString()); |
291 EXPECT_EQ(1u, registry_->disabled_extensions().size()); | 252 EXPECT_EQ(1u, registry_->disabled_extensions().size()); |
292 EXPECT_EQ(Extension::DISABLE_REMOTE_INSTALL, | 253 EXPECT_EQ(Extension::DISABLE_REMOTE_INSTALL, |
293 ExtensionPrefs::Get(service_->profile()) | 254 ExtensionPrefs::Get(service_->profile()) |
294 ->GetDisableReasons(extension_id)); | 255 ->GetDisableReasons(extension_id)); |
295 EXPECT_TRUE(GetExtensionDisabledGlobalError()); | 256 EXPECT_TRUE(GetExtensionDisabledGlobalError()); |
296 } | 257 } |
OLD | NEW |