| 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 "base/feature_list.h" | 9 #include "base/feature_list.h" |
| 10 #include "chrome/browser/prefs/pref_service_syncable_util.h" | 10 #include "chrome/browser/prefs/pref_service_syncable_util.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 sync_preferences::PrefServiceSyncable* pref_service = | 87 sync_preferences::PrefServiceSyncable* pref_service = |
| 88 PrefServiceSyncableFromProfile(profile); | 88 PrefServiceSyncableFromProfile(profile); |
| 89 if (pref_service) { | 89 if (pref_service) { |
| 90 pref_service->RegisterMergeDataFinishedCallback( | 90 pref_service->RegisterMergeDataFinishedCallback( |
| 91 base::Bind(&HostContentSettingsMap::MigrateDomainScopedSettings, | 91 base::Bind(&HostContentSettingsMap::MigrateDomainScopedSettings, |
| 92 settings_map->GetWeakPtr(), true /* after_sync */)); | 92 settings_map->GetWeakPtr(), true /* after_sync */)); |
| 93 } | 93 } |
| 94 | 94 |
| 95 #if BUILDFLAG(ENABLE_EXTENSIONS) | 95 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 96 ExtensionService *ext_service = | 96 // These must be registered before before the HostSettings are passed over to |
| 97 extensions::ExtensionSystem::Get(profile)->extension_service(); | 97 // the IOThread. Simplest to do this on construction. |
| 98 // This may be null in testing or when the extenion_service hasn't been | 98 ExtensionService::RegisterContentSettings(settings_map.get(), profile); |
| 99 // initialized, in which case it will be registered then. | |
| 100 if (ext_service) | |
| 101 ext_service->RegisterContentSettings(settings_map.get()); | |
| 102 #endif // BUILDFLAG(ENABLE_EXTENSIONS) | 99 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
| 103 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) | 100 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
| 104 SupervisedUserSettingsService* supervised_service = | 101 SupervisedUserSettingsService* supervised_service = |
| 105 SupervisedUserSettingsServiceFactory::GetForProfile(profile); | 102 SupervisedUserSettingsServiceFactory::GetForProfile(profile); |
| 106 // This may be null in testing. | 103 // This may be null in testing. |
| 107 if (supervised_service) { | 104 if (supervised_service) { |
| 108 std::unique_ptr<content_settings::SupervisedProvider> supervised_provider( | 105 std::unique_ptr<content_settings::SupervisedProvider> supervised_provider( |
| 109 new content_settings::SupervisedProvider(supervised_service)); | 106 new content_settings::SupervisedProvider(supervised_service)); |
| 110 settings_map->RegisterProvider(HostContentSettingsMap::SUPERVISED_PROVIDER, | 107 settings_map->RegisterProvider(HostContentSettingsMap::SUPERVISED_PROVIDER, |
| 111 std::move(supervised_provider)); | 108 std::move(supervised_provider)); |
| 112 } | 109 } |
| 113 #endif // BUILDFLAG(ENABLE_SUPERVISED_USERS) | 110 #endif // BUILDFLAG(ENABLE_SUPERVISED_USERS) |
| 114 | 111 |
| 115 return settings_map; | 112 return settings_map; |
| 116 } | 113 } |
| 117 | 114 |
| 118 content::BrowserContext* HostContentSettingsMapFactory::GetBrowserContextToUse( | 115 content::BrowserContext* HostContentSettingsMapFactory::GetBrowserContextToUse( |
| 119 content::BrowserContext* context) const { | 116 content::BrowserContext* context) const { |
| 120 return context; | 117 return context; |
| 121 } | 118 } |
| OLD | NEW |