| 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" |
| 11 #include "chrome/browser/extensions/extension_updater.h" | 11 #include "chrome/browser/extensions/extension_updater.h" |
| 12 #include "chrome/browser/prefs/pref_notifier.h" | |
| 13 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
| 13 #include "chrome/browser/prefs/scoped_pref_update.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/renderer_host/render_view_host.h" | 15 #include "chrome/browser/renderer_host/render_view_host.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 18 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 19 #include "chrome/test/ui_test_utils.h" | 19 #include "chrome/test/ui_test_utils.h" |
| 20 | 20 |
| 21 class ExtensionManagementTest : public ExtensionBrowserTest { | 21 class ExtensionManagementTest : public ExtensionBrowserTest { |
| 22 protected: | 22 protected: |
| 23 // Helper method that returns whether the extension is at the given version. | 23 // Helper method that returns whether the extension is at the given version. |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 URLFetcher::enable_interception_for_tests(true); | 337 URLFetcher::enable_interception_for_tests(true); |
| 338 | 338 |
| 339 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", | 339 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", |
| 340 basedir.AppendASCII("manifest_v2.xml")); | 340 basedir.AppendASCII("manifest_v2.xml")); |
| 341 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", | 341 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", |
| 342 basedir.AppendASCII("v2.crx")); | 342 basedir.AppendASCII("v2.crx")); |
| 343 | 343 |
| 344 const size_t size_before = service->extensions()->size(); | 344 const size_t size_before = service->extensions()->size(); |
| 345 ASSERT_TRUE(service->disabled_extensions()->empty()); | 345 ASSERT_TRUE(service->disabled_extensions()->empty()); |
| 346 | 346 |
| 347 // Set the policy as a user preference and fire notification observers. | |
| 348 PrefService* prefs = browser()->profile()->GetPrefs(); | 347 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 349 ListValue* forcelist = | 348 { |
| 350 prefs->GetMutableList(prefs::kExtensionInstallForceList); | 349 // Set the policy as a user preference and fire notification observers. |
| 351 ASSERT_TRUE(forcelist->empty()); | 350 ScopedPrefUpdate pref_update(prefs, prefs::kExtensionInstallForceList); |
| 352 forcelist->Append(Value::CreateStringValue( | 351 ListValue* forcelist = |
| 353 "ogjcoiohnmldgjemafoockdghcjciccf;" | 352 prefs->GetMutableList(prefs::kExtensionInstallForceList); |
| 354 "http://localhost/autoupdate/manifest")); | 353 ASSERT_TRUE(forcelist->empty()); |
| 355 prefs->pref_notifier()->FireObservers(prefs::kExtensionInstallForceList); | 354 forcelist->Append(Value::CreateStringValue( |
| 355 "ogjcoiohnmldgjemafoockdghcjciccf;" |
| 356 "http://localhost/autoupdate/manifest")); |
| 357 } |
| 356 | 358 |
| 357 // Check if the extension got installed. | 359 // Check if the extension got installed. |
| 358 ASSERT_TRUE(WaitForExtensionInstall()); | 360 ASSERT_TRUE(WaitForExtensionInstall()); |
| 359 const ExtensionList* extensions = service->extensions(); | 361 const ExtensionList* extensions = service->extensions(); |
| 360 ASSERT_EQ(size_before + 1, extensions->size()); | 362 ASSERT_EQ(size_before + 1, extensions->size()); |
| 361 ASSERT_EQ(kExtensionId, extensions->at(size_before)->id()); | 363 ASSERT_EQ(kExtensionId, extensions->at(size_before)->id()); |
| 362 EXPECT_EQ("2.0", extensions->at(size_before)->VersionString()); | 364 EXPECT_EQ("2.0", extensions->at(size_before)->VersionString()); |
| 363 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, | 365 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, |
| 364 extensions->at(size_before)->location()); | 366 extensions->at(size_before)->location()); |
| 365 | 367 |
| 366 // Check that emptying the list doesn't cause any trouble. | 368 // Check that emptying the list doesn't cause any trouble. |
| 367 prefs->ClearPref(prefs::kExtensionInstallForceList); | 369 prefs->ClearPref(prefs::kExtensionInstallForceList); |
| 368 prefs->pref_notifier()->FireObservers(prefs::kExtensionInstallForceList); | |
| 369 } | 370 } |
| OLD | NEW |