OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/ref_counted.h" | 5 #include "base/ref_counted.h" |
6 #include "chrome/browser/extensions/autoupdate_interceptor.h" | 6 #include "chrome/browser/extensions/autoupdate_interceptor.h" |
7 #include "chrome/browser/extensions/extension_browsertest.h" | 7 #include "chrome/browser/extensions/extension_browsertest.h" |
8 #include "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
9 #include "chrome/browser/extensions/extensions_service.h" | 9 #include "chrome/browser/extensions/extensions_service.h" |
10 #include "chrome/browser/extensions/extension_test_message_listener.h" | 10 #include "chrome/browser/extensions/extension_test_message_listener.h" |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 const ExtensionList* extensions = service->extensions(); | 286 const ExtensionList* extensions = service->extensions(); |
287 ASSERT_EQ(size_before + 1, extensions->size()); | 287 ASSERT_EQ(size_before + 1, extensions->size()); |
288 ASSERT_EQ(kExtensionId, extensions->at(size_before)->id()); | 288 ASSERT_EQ(kExtensionId, extensions->at(size_before)->id()); |
289 ASSERT_EQ("2.0", extensions->at(size_before)->VersionString()); | 289 ASSERT_EQ("2.0", extensions->at(size_before)->VersionString()); |
290 | 290 |
291 // Uninstalling the extension should set a pref that keeps the extension from | 291 // Uninstalling the extension should set a pref that keeps the extension from |
292 // being installed again the next time external_extensions.json is read. | 292 // being installed again the next time external_extensions.json is read. |
293 | 293 |
294 UninstallExtension(kExtensionId); | 294 UninstallExtension(kExtensionId); |
295 | 295 |
296 std::set<std::string> killed_ids; | 296 ExtensionPrefs* extension_prefs = service->extension_prefs(); |
297 service->extension_prefs()->GetKilledExtensionIds(&killed_ids); | 297 EXPECT_TRUE(extension_prefs->IsExtensionKilled(kExtensionId)) |
298 EXPECT_TRUE(killed_ids.end() != killed_ids.find(kExtensionId)) | |
299 << "Uninstalling should set kill bit on externaly installed extension."; | 298 << "Uninstalling should set kill bit on externaly installed extension."; |
300 | 299 |
| 300 // Try to install the extension again from an external source. It should fail |
| 301 // because of the killbit. |
| 302 service->AddPendingExtensionFromExternalUpdateUrl( |
| 303 kExtensionId, GURL("http://localhost/autoupdate/manifest"), |
| 304 Extension::EXTERNAL_PREF_DOWNLOAD); |
| 305 const PendingExtensionMap& pending_extensions = |
| 306 service->pending_extensions(); |
| 307 EXPECT_TRUE( |
| 308 pending_extensions.find(kExtensionId) == pending_extensions.end()) |
| 309 << "External reinstall of a killed extension shouldn't work."; |
| 310 EXPECT_TRUE(extension_prefs->IsExtensionKilled(kExtensionId)) |
| 311 << "External reinstall of a killed extension should leave it killed."; |
| 312 |
301 // Installing from non-external source. | 313 // Installing from non-external source. |
302 ASSERT_TRUE(InstallExtension(basedir.AppendASCII("v2.crx"), 1)); | 314 ASSERT_TRUE(InstallExtension(basedir.AppendASCII("v2.crx"), 1)); |
303 | 315 |
304 killed_ids.clear(); | 316 EXPECT_FALSE(extension_prefs->IsExtensionKilled(kExtensionId)) |
305 service->extension_prefs()->GetKilledExtensionIds(&killed_ids); | |
306 EXPECT_TRUE(killed_ids.end() == killed_ids.find(kExtensionId)) | |
307 << "Reinstalling should clear the kill bit."; | 317 << "Reinstalling should clear the kill bit."; |
308 | 318 |
309 // Uninstalling from a non-external source should not set the kill bit. | 319 // Uninstalling from a non-external source should not set the kill bit. |
310 UninstallExtension(kExtensionId); | 320 UninstallExtension(kExtensionId); |
311 | 321 |
312 killed_ids.clear(); | 322 EXPECT_FALSE(extension_prefs->IsExtensionKilled(kExtensionId)) |
313 service->extension_prefs()->GetKilledExtensionIds(&killed_ids); | |
314 EXPECT_TRUE(killed_ids.end() == killed_ids.find(kExtensionId)) | |
315 << "Uninstalling non-external extension should not set kill bit."; | 323 << "Uninstalling non-external extension should not set kill bit."; |
316 } | 324 } |
317 | 325 |
318 // See http://crbug.com/57378 for flakiness details. | 326 // See http://crbug.com/57378 for flakiness details. |
319 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalPolicyRefresh) { | 327 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalPolicyRefresh) { |
320 ExtensionsService* service = browser()->profile()->GetExtensionsService(); | 328 ExtensionsService* service = browser()->profile()->GetExtensionsService(); |
321 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; | 329 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; |
322 // We don't want autoupdate blacklist checks. | 330 // We don't want autoupdate blacklist checks. |
323 service->updater()->set_blacklist_checks_enabled(false); | 331 service->updater()->set_blacklist_checks_enabled(false); |
324 | 332 |
(...skipping 27 matching lines...) Expand all Loading... |
352 ASSERT_EQ(size_before + 1, extensions->size()); | 360 ASSERT_EQ(size_before + 1, extensions->size()); |
353 ASSERT_EQ(kExtensionId, extensions->at(size_before)->id()); | 361 ASSERT_EQ(kExtensionId, extensions->at(size_before)->id()); |
354 EXPECT_EQ("2.0", extensions->at(size_before)->VersionString()); | 362 EXPECT_EQ("2.0", extensions->at(size_before)->VersionString()); |
355 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, | 363 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, |
356 extensions->at(size_before)->location()); | 364 extensions->at(size_before)->location()); |
357 | 365 |
358 // Check that emptying the list doesn't cause any trouble. | 366 // Check that emptying the list doesn't cause any trouble. |
359 prefs->ClearPref(prefs::kExtensionInstallForceList); | 367 prefs->ClearPref(prefs::kExtensionInstallForceList); |
360 prefs->pref_notifier()->FireObservers(prefs::kExtensionInstallForceList); | 368 prefs->pref_notifier()->FireObservers(prefs::kExtensionInstallForceList); |
361 } | 369 } |
OLD | NEW |