| 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/profile.h" | 14 #include "chrome/browser/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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 URLFetcher::enable_interception_for_tests(true); | 329 URLFetcher::enable_interception_for_tests(true); |
| 330 | 330 |
| 331 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", | 331 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", |
| 332 basedir.AppendASCII("manifest_v2.xml")); | 332 basedir.AppendASCII("manifest_v2.xml")); |
| 333 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", | 333 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", |
| 334 basedir.AppendASCII("v2.crx")); | 334 basedir.AppendASCII("v2.crx")); |
| 335 | 335 |
| 336 const size_t size_before = service->extensions()->size(); | 336 const size_t size_before = service->extensions()->size(); |
| 337 ASSERT_TRUE(service->disabled_extensions()->empty()); | 337 ASSERT_TRUE(service->disabled_extensions()->empty()); |
| 338 | 338 |
| 339 // Set the policy as a user preference and fire notification observers. | |
| 340 PrefService* prefs = browser()->profile()->GetPrefs(); | 339 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 341 ListValue* forcelist = | 340 { |
| 342 prefs->GetMutableList(prefs::kExtensionInstallForceList); | 341 // Set the policy as a user preference and fire notification observers. |
| 343 ASSERT_TRUE(forcelist->empty()); | 342 ScopedPrefUpdate pref_update(prefs, prefs::kExtensionInstallForceList); |
| 344 forcelist->Append(Value::CreateStringValue( | 343 ListValue* forcelist = |
| 345 "ogjcoiohnmldgjemafoockdghcjciccf;" | 344 prefs->GetMutableList(prefs::kExtensionInstallForceList); |
| 346 "http://localhost/autoupdate/manifest")); | 345 ASSERT_TRUE(forcelist->empty()); |
| 347 prefs->pref_notifier()->FireObservers(prefs::kExtensionInstallForceList); | 346 forcelist->Append(Value::CreateStringValue( |
| 347 "ogjcoiohnmldgjemafoockdghcjciccf;" |
| 348 "http://localhost/autoupdate/manifest")); |
| 349 } |
| 348 | 350 |
| 349 // Check if the extension got installed. | 351 // Check if the extension got installed. |
| 350 ASSERT_TRUE(WaitForExtensionInstall()); | 352 ASSERT_TRUE(WaitForExtensionInstall()); |
| 351 const ExtensionList* extensions = service->extensions(); | 353 const ExtensionList* extensions = service->extensions(); |
| 352 ASSERT_EQ(size_before + 1, extensions->size()); | 354 ASSERT_EQ(size_before + 1, extensions->size()); |
| 353 ASSERT_EQ(kExtensionId, extensions->at(size_before)->id()); | 355 ASSERT_EQ(kExtensionId, extensions->at(size_before)->id()); |
| 354 EXPECT_EQ("2.0", extensions->at(size_before)->VersionString()); | 356 EXPECT_EQ("2.0", extensions->at(size_before)->VersionString()); |
| 355 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, | 357 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, |
| 356 extensions->at(size_before)->location()); | 358 extensions->at(size_before)->location()); |
| 357 | 359 |
| 358 // Check that emptying the list doesn't cause any trouble. | 360 // Check that emptying the list doesn't cause any trouble. |
| 359 prefs->ClearPref(prefs::kExtensionInstallForceList); | 361 prefs->ClearPref(prefs::kExtensionInstallForceList); |
| 360 prefs->pref_notifier()->FireObservers(prefs::kExtensionInstallForceList); | |
| 361 } | 362 } |
| OLD | NEW |