Chromium Code Reviews| 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 "chrome/browser/extensions/extension_service_unittest.h" | 5 #include "chrome/browser/extensions/extension_service_unittest.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 #include "base/stl_util.h" | 23 #include "base/stl_util.h" |
| 24 #include "base/string16.h" | 24 #include "base/string16.h" |
| 25 #include "base/string_number_conversions.h" | 25 #include "base/string_number_conversions.h" |
| 26 #include "base/string_util.h" | 26 #include "base/string_util.h" |
| 27 #include "base/utf_string_conversions.h" | 27 #include "base/utf_string_conversions.h" |
| 28 #include "base/version.h" | 28 #include "base/version.h" |
| 29 #include "chrome/browser/browser_process.h" | 29 #include "chrome/browser/browser_process.h" |
| 30 #include "chrome/browser/extensions/app_sync_data.h" | 30 #include "chrome/browser/extensions/app_sync_data.h" |
| 31 #include "chrome/browser/extensions/component_loader.h" | 31 #include "chrome/browser/extensions/component_loader.h" |
| 32 #include "chrome/browser/extensions/crx_installer.h" | 32 #include "chrome/browser/extensions/crx_installer.h" |
| 33 #include "chrome/browser/extensions/default_apps.h" | |
| 33 #include "chrome/browser/extensions/extension_creator.h" | 34 #include "chrome/browser/extensions/extension_creator.h" |
| 34 #include "chrome/browser/extensions/extension_error_reporter.h" | 35 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 35 #include "chrome/browser/extensions/extension_error_ui.h" | 36 #include "chrome/browser/extensions/extension_error_ui.h" |
| 36 #include "chrome/browser/extensions/extension_service.h" | 37 #include "chrome/browser/extensions/extension_service.h" |
| 37 #include "chrome/browser/extensions/extension_sorting.h" | 38 #include "chrome/browser/extensions/extension_sorting.h" |
| 38 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 39 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 39 #include "chrome/browser/extensions/extension_sync_data.h" | 40 #include "chrome/browser/extensions/extension_sync_data.h" |
| 40 #include "chrome/browser/extensions/extension_system.h" | 41 #include "chrome/browser/extensions/extension_system.h" |
| 41 #include "chrome/browser/extensions/external_pref_loader.h" | 42 #include "chrome/browser/extensions/external_pref_loader.h" |
| 42 #include "chrome/browser/extensions/external_provider_impl.h" | 43 #include "chrome/browser/extensions/external_provider_impl.h" |
| (...skipping 3777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3820 InitializeEmptyExtensionService(); | 3821 InitializeEmptyExtensionService(); |
| 3821 | 3822 |
| 3822 // Now add providers. Extension system takes ownership of the objects. | 3823 // Now add providers. Extension system takes ownership of the objects. |
| 3823 MockExtensionProvider* pref_provider = | 3824 MockExtensionProvider* pref_provider = |
| 3824 new MockExtensionProvider(service_, Extension::EXTERNAL_PREF); | 3825 new MockExtensionProvider(service_, Extension::EXTERNAL_PREF); |
| 3825 | 3826 |
| 3826 AddMockExternalProvider(pref_provider); | 3827 AddMockExternalProvider(pref_provider); |
| 3827 TestExternalProvider(pref_provider, Extension::EXTERNAL_PREF); | 3828 TestExternalProvider(pref_provider, Extension::EXTERNAL_PREF); |
| 3828 } | 3829 } |
| 3829 | 3830 |
| 3831 #if !defined(OS_CHROMEOS) | |
|
Mihai Parparita -not on Chrome
2012/08/23 23:14:22
Just realized that this might make sense in a sepa
| |
| 3832 // Chrome OS has different way of installing default apps. | |
| 3833 TEST_F(ExtensionServiceTest, DefaultAppsInstall) { | |
| 3834 scoped_ptr<TestingProfile> profile(new TestingProfile()); | |
| 3835 | |
| 3836 // The default apps should be installed if kDefaultAppsInstallState | |
| 3837 // is unknown. | |
| 3838 EXPECT_TRUE(default_apps::ShouldInstallInProfile(profile.get())); | |
| 3839 int state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState); | |
| 3840 EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps); | |
| 3841 | |
| 3842 // The default apps should only be installed once. | |
| 3843 EXPECT_FALSE(default_apps::ShouldInstallInProfile(profile.get())); | |
| 3844 state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState); | |
| 3845 EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps); | |
| 3846 | |
| 3847 // The default apps should not be installed if the state is | |
| 3848 // kNeverProvideDefaultApps | |
| 3849 profile->GetPrefs()->SetInteger(prefs::kDefaultAppsInstallState, | |
| 3850 default_apps::kNeverInstallDefaultApps); | |
| 3851 EXPECT_FALSE(default_apps::ShouldInstallInProfile(profile.get())); | |
| 3852 state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState); | |
| 3853 EXPECT_TRUE(state == default_apps::kNeverInstallDefaultApps); | |
| 3854 | |
| 3855 // The old default apps with kAlwaysInstallDefaultAppss should be migrated. | |
| 3856 profile->GetPrefs()->SetInteger(prefs::kDefaultAppsInstallState, | |
| 3857 default_apps::kProvideLegacyDefaultApps); | |
| 3858 EXPECT_TRUE(default_apps::ShouldInstallInProfile(profile.get())); | |
| 3859 state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState); | |
| 3860 EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps); | |
| 3861 | |
| 3862 class DefaultTestingProfile : public TestingProfile { | |
| 3863 virtual bool WasCreatedByVersionOrLater( | |
| 3864 const std::string& version) OVERRIDE { | |
| 3865 return false; | |
| 3866 } | |
| 3867 }; | |
| 3868 profile.reset(new DefaultTestingProfile); | |
| 3869 // The old default apps with kProvideLegacyDefaultApps should be migrated | |
| 3870 // even if the profile version is older than Chrome version. | |
| 3871 profile->GetPrefs()->SetInteger(prefs::kDefaultAppsInstallState, | |
| 3872 default_apps::kProvideLegacyDefaultApps); | |
| 3873 EXPECT_TRUE(default_apps::ShouldInstallInProfile(profile.get())); | |
| 3874 state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState); | |
| 3875 EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps); | |
| 3876 } | |
| 3877 #endif | |
| 3878 | |
| 3830 TEST_F(ExtensionServiceTest, ExternalInstallPrefUpdateUrl) { | 3879 TEST_F(ExtensionServiceTest, ExternalInstallPrefUpdateUrl) { |
| 3831 // This should all work, even when normal extension installation is disabled. | 3880 // This should all work, even when normal extension installation is disabled. |
| 3832 InitializeEmptyExtensionService(); | 3881 InitializeEmptyExtensionService(); |
| 3833 set_extensions_enabled(false); | 3882 set_extensions_enabled(false); |
| 3834 | 3883 |
| 3835 // TODO(skerner): The mock provider is not a good model of a provider | 3884 // TODO(skerner): The mock provider is not a good model of a provider |
| 3836 // that works with update URLs, because it adds file and version info. | 3885 // that works with update URLs, because it adds file and version info. |
| 3837 // Extend the mock to work with update URLs. This test checks the | 3886 // Extend the mock to work with update URLs. This test checks the |
| 3838 // behavior that is common to all external extension visitors. The | 3887 // behavior that is common to all external extension visitors. The |
| 3839 // browser test ExtensionManagementTest.ExternalUrlUpdate tests that | 3888 // browser test ExtensionManagementTest.ExternalUrlUpdate tests that |
| (...skipping 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5352 // This should NOT trigger an alert. | 5401 // This should NOT trigger an alert. |
| 5353 provider->UpdateOrAddExtension(hosted_app, "1.0.0.0", | 5402 provider->UpdateOrAddExtension(hosted_app, "1.0.0.0", |
| 5354 data_dir_.AppendASCII("hosted_app.crx")); | 5403 data_dir_.AppendASCII("hosted_app.crx")); |
| 5355 | 5404 |
| 5356 service_->CheckForExternalUpdates(); | 5405 service_->CheckForExternalUpdates(); |
| 5357 loop_.RunAllPending(); | 5406 loop_.RunAllPending(); |
| 5358 | 5407 |
| 5359 ASSERT_TRUE(service_->PopulateExtensionErrorUI(extension_error_ui.get())); | 5408 ASSERT_TRUE(service_->PopulateExtensionErrorUI(extension_error_ui.get())); |
| 5360 ASSERT_EQ(1u, extension_error_ui->get_external_extension_ids()->size()); | 5409 ASSERT_EQ(1u, extension_error_ui->get_external_extension_ids()->size()); |
| 5361 } | 5410 } |
| OLD | NEW |