| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/content_settings/host_content_settings_map_factory.h" | 5 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "chrome/browser/prefs/pref_service_syncable_util.h" | 9 #include "chrome/browser/prefs/pref_service_syncable_util.h" |
| 10 #include "chrome/browser/profiles/off_the_record_profile_impl.h" | 10 #include "chrome/browser/profiles/off_the_record_profile_impl.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "components/content_settings/core/browser/host_content_settings_map.h" | 12 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 13 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 13 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 14 #include "components/sync_preferences/pref_service_syncable.h" | 14 #include "components/sync_preferences/pref_service_syncable.h" |
| 15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 #include "extensions/features/features.h" |
| 16 | 17 |
| 17 #if defined(ENABLE_EXTENSIONS) | 18 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 18 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "extensions/browser/extension_system.h" | 20 #include "extensions/browser/extension_system.h" |
| 20 #include "extensions/browser/extension_system_provider.h" | 21 #include "extensions/browser/extension_system_provider.h" |
| 21 #include "extensions/browser/extensions_browser_client.h" | 22 #include "extensions/browser/extensions_browser_client.h" |
| 22 #endif | 23 #endif |
| 23 | 24 |
| 24 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) | 25 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
| 25 #include "chrome/browser/content_settings/content_settings_supervised_provider.h
" | 26 #include "chrome/browser/content_settings/content_settings_supervised_provider.h
" |
| 26 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" | 27 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" |
| 27 #include "chrome/browser/supervised_user/supervised_user_settings_service_factor
y.h" | 28 #include "chrome/browser/supervised_user/supervised_user_settings_service_factor
y.h" |
| 28 #endif | 29 #endif |
| 29 | 30 |
| 30 HostContentSettingsMapFactory::HostContentSettingsMapFactory() | 31 HostContentSettingsMapFactory::HostContentSettingsMapFactory() |
| 31 : RefcountedBrowserContextKeyedServiceFactory( | 32 : RefcountedBrowserContextKeyedServiceFactory( |
| 32 "HostContentSettingsMap", | 33 "HostContentSettingsMap", |
| 33 BrowserContextDependencyManager::GetInstance()) { | 34 BrowserContextDependencyManager::GetInstance()) { |
| 34 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) | 35 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
| 35 DependsOn(SupervisedUserSettingsServiceFactory::GetInstance()); | 36 DependsOn(SupervisedUserSettingsServiceFactory::GetInstance()); |
| 36 #endif | 37 #endif |
| 37 #if defined(ENABLE_EXTENSIONS) | 38 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 38 DependsOn( | 39 DependsOn( |
| 39 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | 40 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
| 40 #endif | 41 #endif |
| 41 } | 42 } |
| 42 | 43 |
| 43 HostContentSettingsMapFactory::~HostContentSettingsMapFactory() { | 44 HostContentSettingsMapFactory::~HostContentSettingsMapFactory() { |
| 44 } | 45 } |
| 45 | 46 |
| 46 // static | 47 // static |
| 47 HostContentSettingsMap* HostContentSettingsMapFactory::GetForProfile( | 48 HostContentSettingsMap* HostContentSettingsMapFactory::GetForProfile( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 profile->GetProfileType() == Profile::GUEST_PROFILE)); | 80 profile->GetProfileType() == Profile::GUEST_PROFILE)); |
| 80 | 81 |
| 81 sync_preferences::PrefServiceSyncable* pref_service = | 82 sync_preferences::PrefServiceSyncable* pref_service = |
| 82 PrefServiceSyncableFromProfile(profile); | 83 PrefServiceSyncableFromProfile(profile); |
| 83 if (pref_service) { | 84 if (pref_service) { |
| 84 pref_service->RegisterMergeDataFinishedCallback( | 85 pref_service->RegisterMergeDataFinishedCallback( |
| 85 base::Bind(&HostContentSettingsMap::MigrateDomainScopedSettings, | 86 base::Bind(&HostContentSettingsMap::MigrateDomainScopedSettings, |
| 86 settings_map->GetWeakPtr(), true /* after_sync */)); | 87 settings_map->GetWeakPtr(), true /* after_sync */)); |
| 87 } | 88 } |
| 88 | 89 |
| 89 #if defined(ENABLE_EXTENSIONS) | 90 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 90 ExtensionService *ext_service = | 91 ExtensionService *ext_service = |
| 91 extensions::ExtensionSystem::Get(profile)->extension_service(); | 92 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 92 // This may be null in testing or when the extenion_service hasn't been | 93 // This may be null in testing or when the extenion_service hasn't been |
| 93 // initialized, in which case it will be registered then. | 94 // initialized, in which case it will be registered then. |
| 94 if (ext_service) | 95 if (ext_service) |
| 95 ext_service->RegisterContentSettings(settings_map.get()); | 96 ext_service->RegisterContentSettings(settings_map.get()); |
| 96 #endif // defined(ENABLE_EXTENSIONS) | 97 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
| 97 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) | 98 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
| 98 SupervisedUserSettingsService* supervised_service = | 99 SupervisedUserSettingsService* supervised_service = |
| 99 SupervisedUserSettingsServiceFactory::GetForProfile(profile); | 100 SupervisedUserSettingsServiceFactory::GetForProfile(profile); |
| 100 // This may be null in testing. | 101 // This may be null in testing. |
| 101 if (supervised_service) { | 102 if (supervised_service) { |
| 102 std::unique_ptr<content_settings::SupervisedProvider> supervised_provider( | 103 std::unique_ptr<content_settings::SupervisedProvider> supervised_provider( |
| 103 new content_settings::SupervisedProvider(supervised_service)); | 104 new content_settings::SupervisedProvider(supervised_service)); |
| 104 settings_map->RegisterProvider(HostContentSettingsMap::SUPERVISED_PROVIDER, | 105 settings_map->RegisterProvider(HostContentSettingsMap::SUPERVISED_PROVIDER, |
| 105 std::move(supervised_provider)); | 106 std::move(supervised_provider)); |
| 106 } | 107 } |
| 107 #endif // BUILDFLAG(ENABLE_SUPERVISED_USERS) | 108 #endif // BUILDFLAG(ENABLE_SUPERVISED_USERS) |
| 108 | 109 |
| 109 return settings_map; | 110 return settings_map; |
| 110 } | 111 } |
| 111 | 112 |
| 112 content::BrowserContext* HostContentSettingsMapFactory::GetBrowserContextToUse( | 113 content::BrowserContext* HostContentSettingsMapFactory::GetBrowserContextToUse( |
| 113 content::BrowserContext* context) const { | 114 content::BrowserContext* context) const { |
| 114 return context; | 115 return context; |
| 115 } | 116 } |
| OLD | NEW |