| 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/profiles/off_the_record_profile_impl.h" | 10 #include "chrome/browser/profiles/off_the_record_profile_impl.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 11 #include "components/content_settings/core/browser/host_content_settings_map.h" | 12 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 13 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 14 | 15 |
| 15 #if defined(ENABLE_EXTENSIONS) | 16 #if defined(ENABLE_EXTENSIONS) |
| 16 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "extensions/browser/extension_system.h" | 18 #include "extensions/browser/extension_system.h" |
| 18 #include "extensions/browser/extension_system_provider.h" | 19 #include "extensions/browser/extension_system_provider.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 Profile* profile = static_cast<Profile*>(context); | 64 Profile* profile = static_cast<Profile*>(context); |
| 64 | 65 |
| 65 // If off the record, retrieve the host content settings map of the parent | 66 // If off the record, retrieve the host content settings map of the parent |
| 66 // profile in order to ensure the preferences have been migrated. | 67 // profile in order to ensure the preferences have been migrated. |
| 67 if (profile->GetProfileType() == Profile::INCOGNITO_PROFILE) | 68 if (profile->GetProfileType() == Profile::INCOGNITO_PROFILE) |
| 68 GetForProfile(profile->GetOriginalProfile()); | 69 GetForProfile(profile->GetOriginalProfile()); |
| 69 | 70 |
| 70 scoped_refptr<HostContentSettingsMap> settings_map(new HostContentSettingsMap( | 71 scoped_refptr<HostContentSettingsMap> settings_map(new HostContentSettingsMap( |
| 71 profile->GetPrefs(), | 72 profile->GetPrefs(), |
| 72 profile->GetProfileType() == Profile::INCOGNITO_PROFILE, | 73 profile->GetProfileType() == Profile::INCOGNITO_PROFILE, |
| 73 profile->GetProfileType() == Profile::GUEST_PROFILE)); | 74 profile->GetProfileType() == Profile::GUEST_PROFILE, |
| 75 PrefServiceSyncableFromProfile(profile))); |
| 74 | 76 |
| 75 #if defined(ENABLE_EXTENSIONS) | 77 #if defined(ENABLE_EXTENSIONS) |
| 76 ExtensionService *ext_service = | 78 ExtensionService *ext_service = |
| 77 extensions::ExtensionSystem::Get(profile)->extension_service(); | 79 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 78 // This may be null in testing or when the extenion_service hasn't been | 80 // This may be null in testing or when the extenion_service hasn't been |
| 79 // initialized, in which case it will be registered then. | 81 // initialized, in which case it will be registered then. |
| 80 if (ext_service) | 82 if (ext_service) |
| 81 ext_service->RegisterContentSettings(settings_map.get()); | 83 ext_service->RegisterContentSettings(settings_map.get()); |
| 82 #endif // defined(ENABLE_EXTENSIONS) | 84 #endif // defined(ENABLE_EXTENSIONS) |
| 83 #if defined(ENABLE_SUPERVISED_USERS) | 85 #if defined(ENABLE_SUPERVISED_USERS) |
| 84 SupervisedUserSettingsService* supervised_service = | 86 SupervisedUserSettingsService* supervised_service = |
| 85 SupervisedUserSettingsServiceFactory::GetForProfile(profile); | 87 SupervisedUserSettingsServiceFactory::GetForProfile(profile); |
| 86 // This may be null in testing. | 88 // This may be null in testing. |
| 87 if (supervised_service) { | 89 if (supervised_service) { |
| 88 std::unique_ptr<content_settings::SupervisedProvider> supervised_provider( | 90 std::unique_ptr<content_settings::SupervisedProvider> supervised_provider( |
| 89 new content_settings::SupervisedProvider(supervised_service)); | 91 new content_settings::SupervisedProvider(supervised_service)); |
| 90 settings_map->RegisterProvider(HostContentSettingsMap::SUPERVISED_PROVIDER, | 92 settings_map->RegisterProvider(HostContentSettingsMap::SUPERVISED_PROVIDER, |
| 91 std::move(supervised_provider)); | 93 std::move(supervised_provider)); |
| 92 } | 94 } |
| 93 #endif // defined(ENABLE_SUPERVISED_USERS) | 95 #endif // defined(ENABLE_SUPERVISED_USERS) |
| 94 | 96 |
| 95 return settings_map; | 97 return settings_map; |
| 96 } | 98 } |
| 97 | 99 |
| 98 content::BrowserContext* HostContentSettingsMapFactory::GetBrowserContextToUse( | 100 content::BrowserContext* HostContentSettingsMapFactory::GetBrowserContextToUse( |
| 99 content::BrowserContext* context) const { | 101 content::BrowserContext* context) const { |
| 100 return context; | 102 return context; |
| 101 } | 103 } |
| OLD | NEW |