| 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 <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
| 13 #include "base/string_split.h" | 13 #include "base/string_split.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
| 16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
| 17 #include "base/version.h" | 17 #include "base/version.h" |
| 18 #include "chrome/browser/extensions/crx_installer.h" | 18 #include "chrome/browser/extensions/crx_installer.h" |
| 19 #include "chrome/browser/extensions/extension_error_reporter.h" | 19 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 20 #include "chrome/browser/extensions/extension_sync_data.h" | 20 #include "chrome/browser/extensions/extension_sync_data.h" |
| 21 #include "chrome/browser/extensions/extension_system.h" |
| 22 #include "chrome/browser/extensions/extension_system_factory.h" |
| 21 #include "chrome/browser/extensions/extension_updater.h" | 23 #include "chrome/browser/extensions/extension_updater.h" |
| 22 #include "chrome/browser/extensions/test_extension_prefs.h" | 24 #include "chrome/browser/extensions/test_extension_prefs.h" |
| 23 #include "chrome/browser/extensions/test_extension_service.h" | 25 #include "chrome/browser/extensions/test_extension_service.h" |
| 26 #include "chrome/browser/extensions/test_extension_system.h" |
| 24 #include "chrome/browser/google/google_util.h" | 27 #include "chrome/browser/google/google_util.h" |
| 25 #include "chrome/browser/prefs/pref_service.h" | 28 #include "chrome/browser/prefs/pref_service.h" |
| 26 #include "chrome/common/extensions/extension.h" | 29 #include "chrome/common/extensions/extension.h" |
| 27 #include "chrome/common/extensions/extension_constants.h" | 30 #include "chrome/common/extensions/extension_constants.h" |
| 28 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/test/base/testing_profile.h" | 32 #include "chrome/test/base/testing_profile.h" |
| 30 #include "content/test/test_browser_thread.h" | 33 #include "content/test/test_browser_thread.h" |
| 31 #include "content/test/test_url_fetcher_factory.h" | 34 #include "content/test/test_url_fetcher_factory.h" |
| 32 #include "libxml/globals.h" | 35 #include "libxml/globals.h" |
| 33 #include "net/base/escape.h" | 36 #include "net/base/escape.h" |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 fetcher = factory.GetFetcherByID(ExtensionUpdater::kExtensionFetcherId); | 808 fetcher = factory.GetFetcherByID(ExtensionUpdater::kExtensionFetcherId); |
| 806 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL); | 809 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL); |
| 807 EXPECT_TRUE(fetcher->GetLoadFlags() == expected_load_flags); | 810 EXPECT_TRUE(fetcher->GetLoadFlags() == expected_load_flags); |
| 808 | 811 |
| 809 // We need some CrxInstallers, and CrxInstallers require a real | 812 // We need some CrxInstallers, and CrxInstallers require a real |
| 810 // ExtensionService. Create one on the testing profile. Any action | 813 // ExtensionService. Create one on the testing profile. Any action |
| 811 // the CrxInstallers take is on the testing profile's extension | 814 // the CrxInstallers take is on the testing profile's extension |
| 812 // service, not on our mock |service|. This allows us to fake | 815 // service, not on our mock |service|. This allows us to fake |
| 813 // the CrxInstaller actions we want. | 816 // the CrxInstaller actions we want. |
| 814 TestingProfile profile; | 817 TestingProfile profile; |
| 815 profile.CreateExtensionService( | 818 static_cast<TestExtensionSystem*>( |
| 816 CommandLine::ForCurrentProcess(), | 819 ExtensionSystemFactory::GetForProfile(&profile))-> |
| 817 FilePath(), | 820 CreateExtensionService( |
| 818 false); | 821 CommandLine::ForCurrentProcess(), |
| 819 profile.GetExtensionService()->set_extensions_enabled(true); | 822 FilePath(), |
| 820 profile.GetExtensionService()->set_show_extensions_prompts(false); | 823 false); |
| 824 ExtensionService* extension_service = |
| 825 ExtensionSystemFactory::GetForProfile(&profile)->extension_service(); |
| 826 extension_service->set_extensions_enabled(true); |
| 827 extension_service->set_show_extensions_prompts(false); |
| 821 | 828 |
| 822 scoped_refptr<CrxInstaller> fake_crx1( | 829 scoped_refptr<CrxInstaller> fake_crx1( |
| 823 CrxInstaller::Create(profile.GetExtensionService(), NULL)); | 830 CrxInstaller::Create(extension_service, NULL)); |
| 824 scoped_refptr<CrxInstaller> fake_crx2( | 831 scoped_refptr<CrxInstaller> fake_crx2( |
| 825 CrxInstaller::Create(profile.GetExtensionService(), NULL)); | 832 CrxInstaller::Create(extension_service, NULL)); |
| 826 | 833 |
| 827 if (updates_start_running) { | 834 if (updates_start_running) { |
| 828 // Add fake CrxInstaller to be returned by service.UpdateExtension(). | 835 // Add fake CrxInstaller to be returned by service.UpdateExtension(). |
| 829 service.AddFakeCrxInstaller(id1, fake_crx1.get()); | 836 service.AddFakeCrxInstaller(id1, fake_crx1.get()); |
| 830 service.AddFakeCrxInstaller(id2, fake_crx2.get()); | 837 service.AddFakeCrxInstaller(id2, fake_crx2.get()); |
| 831 } else { | 838 } else { |
| 832 // If we don't add fake CRX installers, the mock service fakes a failure | 839 // If we don't add fake CRX installers, the mock service fakes a failure |
| 833 // starting the install. | 840 // starting the install. |
| 834 } | 841 } |
| 835 | 842 |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 | 1268 |
| 1262 // TODO(asargent) - (http://crbug.com/12780) add tests for: | 1269 // TODO(asargent) - (http://crbug.com/12780) add tests for: |
| 1263 // -prodversionmin (shouldn't update if browser version too old) | 1270 // -prodversionmin (shouldn't update if browser version too old) |
| 1264 // -manifests & updates arriving out of order / interleaved | 1271 // -manifests & updates arriving out of order / interleaved |
| 1265 // -malformed update url (empty, file://, has query, has a # fragment, etc.) | 1272 // -malformed update url (empty, file://, has query, has a # fragment, etc.) |
| 1266 // -An extension gets uninstalled while updates are in progress (so it doesn't | 1273 // -An extension gets uninstalled while updates are in progress (so it doesn't |
| 1267 // "come back from the dead") | 1274 // "come back from the dead") |
| 1268 // -An extension gets manually updated to v3 while we're downloading v2 (ie | 1275 // -An extension gets manually updated to v3 while we're downloading v2 (ie |
| 1269 // you don't get downgraded accidentally) | 1276 // you don't get downgraded accidentally) |
| 1270 // -An update manifest mentions multiple updates | 1277 // -An update manifest mentions multiple updates |
| OLD | NEW |