Chromium Code Reviews| 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 const ExtensionList* extensions = service->extensions(); | 285 const ExtensionList* extensions = service->extensions(); |
| 286 ASSERT_EQ(size_before + 1, extensions->size()); | 286 ASSERT_EQ(size_before + 1, extensions->size()); |
| 287 ASSERT_EQ(kExtensionId, extensions->at(size_before)->id()); | 287 ASSERT_EQ(kExtensionId, extensions->at(size_before)->id()); |
| 288 ASSERT_EQ("2.0", extensions->at(size_before)->VersionString()); | 288 ASSERT_EQ("2.0", extensions->at(size_before)->VersionString()); |
| 289 | 289 |
| 290 // Uninstalling the extension should set a pref that keeps the extension from | 290 // Uninstalling the extension should set a pref that keeps the extension from |
| 291 // being installed again the next time external_extensions.json is read. | 291 // being installed again the next time external_extensions.json is read. |
| 292 | 292 |
| 293 UninstallExtension(kExtensionId); | 293 UninstallExtension(kExtensionId); |
| 294 | 294 |
| 295 std::set<std::string> killed_ids; | 295 ExtensionPrefs* extension_prefs = service->extension_prefs(); |
| 296 service->extension_prefs()->GetKilledExtensionIds(&killed_ids); | 296 EXPECT_TRUE(extension_prefs->IsExtensionKilled(kExtensionId)) |
| 297 EXPECT_TRUE(killed_ids.end() != killed_ids.find(kExtensionId)) | |
| 298 << "Uninstalling should set kill bit on externaly installed extension."; | 297 << "Uninstalling should set kill bit on externaly installed extension."; |
| 299 | 298 |
| 299 // Try to install the extension again from an external source. It should fail | |
| 300 // bacuse of the killbit. | |
|
Erik does not do reviews
2010/12/03 17:15:16
typo: because
gfeher
2010/12/03 21:10:09
Done.
| |
| 301 service->AddPendingExtensionFromExternalUpdateUrl( | |
| 302 kExtensionId, GURL("http://localhost/autoupdate/manifest"), | |
| 303 Extension::EXTERNAL_PREF_DOWNLOAD); | |
| 304 | |
| 305 EXPECT_EQ(0u, service->pending_extensions_.size()) | |
| 306 << "External reinstall of a killed extension shouldn't work."; | |
| 307 EXPECT_TRUE(extension_prefs->IsExtensionKilled(kExtensionId)) | |
| 308 << "External reinstall of a killed extension should leave it killed."; | |
| 309 | |
| 300 // Installing from non-external source. | 310 // Installing from non-external source. |
| 301 ASSERT_TRUE(InstallExtension(basedir.AppendASCII("v2.crx"), 1)); | 311 ASSERT_TRUE(InstallExtension(basedir.AppendASCII("v2.crx"), 1)); |
| 302 | 312 |
| 303 killed_ids.clear(); | 313 EXPECT_FALSE(extension_prefs->IsExtensionKilled(kExtensionId)) |
| 304 service->extension_prefs()->GetKilledExtensionIds(&killed_ids); | |
| 305 EXPECT_TRUE(killed_ids.end() == killed_ids.find(kExtensionId)) | |
| 306 << "Reinstalling should clear the kill bit."; | 314 << "Reinstalling should clear the kill bit."; |
| 307 | 315 |
| 308 // Uninstalling from a non-external source should not set the kill bit. | 316 // Uninstalling from a non-external source should not set the kill bit. |
| 309 UninstallExtension(kExtensionId); | 317 UninstallExtension(kExtensionId); |
| 310 | 318 |
| 311 killed_ids.clear(); | 319 EXPECT_FALSE(extension_prefs->IsExtensionKilled(kExtensionId)) |
| 312 service->extension_prefs()->GetKilledExtensionIds(&killed_ids); | |
| 313 EXPECT_TRUE(killed_ids.end() == killed_ids.find(kExtensionId)) | |
| 314 << "Uninstalling non-external extension should not set kill bit."; | 320 << "Uninstalling non-external extension should not set kill bit."; |
| 315 } | 321 } |
| 316 | 322 |
| 317 // See http://crbug.com/57378 for flakiness details. | 323 // See http://crbug.com/57378 for flakiness details. |
| 318 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalPolicyRefresh) { | 324 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalPolicyRefresh) { |
| 319 ExtensionsService* service = browser()->profile()->GetExtensionsService(); | 325 ExtensionsService* service = browser()->profile()->GetExtensionsService(); |
| 320 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; | 326 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; |
| 321 // We don't want autoupdate blacklist checks. | 327 // We don't want autoupdate blacklist checks. |
| 322 service->updater()->set_blacklist_checks_enabled(false); | 328 service->updater()->set_blacklist_checks_enabled(false); |
| 323 | 329 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 351 ASSERT_EQ(size_before + 1, extensions->size()); | 357 ASSERT_EQ(size_before + 1, extensions->size()); |
| 352 ASSERT_EQ(kExtensionId, extensions->at(size_before)->id()); | 358 ASSERT_EQ(kExtensionId, extensions->at(size_before)->id()); |
| 353 EXPECT_EQ("2.0", extensions->at(size_before)->VersionString()); | 359 EXPECT_EQ("2.0", extensions->at(size_before)->VersionString()); |
| 354 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, | 360 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, |
| 355 extensions->at(size_before)->location()); | 361 extensions->at(size_before)->location()); |
| 356 | 362 |
| 357 // Check that emptying the list doesn't cause any trouble. | 363 // Check that emptying the list doesn't cause any trouble. |
| 358 prefs->ClearPref(prefs::kExtensionInstallForceList); | 364 prefs->ClearPref(prefs::kExtensionInstallForceList); |
| 359 prefs->pref_notifier()->FireObservers(prefs::kExtensionInstallForceList); | 365 prefs->pref_notifier()->FireObservers(prefs::kExtensionInstallForceList); |
| 360 } | 366 } |
| OLD | NEW |