| 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/profiles/off_the_record_profile_impl.h" | 9 #include "chrome/browser/profiles/off_the_record_profile_impl.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 HostContentSettingsMapFactory* HostContentSettingsMapFactory::GetInstance() { | 54 HostContentSettingsMapFactory* HostContentSettingsMapFactory::GetInstance() { |
| 55 return base::Singleton<HostContentSettingsMapFactory>::get(); | 55 return base::Singleton<HostContentSettingsMapFactory>::get(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 scoped_refptr<RefcountedKeyedService> | 58 scoped_refptr<RefcountedKeyedService> |
| 59 HostContentSettingsMapFactory::BuildServiceInstanceFor( | 59 HostContentSettingsMapFactory::BuildServiceInstanceFor( |
| 60 content::BrowserContext* context) const { | 60 content::BrowserContext* context) const { |
| 61 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 61 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 62 | 62 |
| 63 Profile* profile = static_cast<Profile*>(context); | 63 Profile* profile = static_cast<Profile*>(context); |
| 64 bool off_the_record = profile->GetProfileType() == Profile::INCOGNITO_PROFILE; | |
| 65 | 64 |
| 66 // If off the record, retrieve the host content settings map of the parent | 65 // If off the record, retrieve the host content settings map of the parent |
| 67 // profile in order to ensure the preferences have been migrated. | 66 // profile in order to ensure the preferences have been migrated. |
| 68 if (off_the_record) | 67 if (profile->GetProfileType() == Profile::INCOGNITO_PROFILE) |
| 69 GetForProfile(profile->GetOriginalProfile()); | 68 GetForProfile(profile->GetOriginalProfile()); |
| 70 | 69 |
| 71 scoped_refptr<HostContentSettingsMap> settings_map( | 70 scoped_refptr<HostContentSettingsMap> settings_map(new HostContentSettingsMap( |
| 72 new HostContentSettingsMap(profile->GetPrefs(), off_the_record)); | 71 profile->GetPrefs(), |
| 72 profile->GetProfileType() == Profile::INCOGNITO_PROFILE, |
| 73 profile->GetProfileType() == Profile::GUEST_PROFILE)); |
| 73 | 74 |
| 74 #if defined(ENABLE_EXTENSIONS) | 75 #if defined(ENABLE_EXTENSIONS) |
| 75 ExtensionService *ext_service = | 76 ExtensionService *ext_service = |
| 76 extensions::ExtensionSystem::Get(profile)->extension_service(); | 77 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 77 // This may be null in testing or when the extenion_service hasn't been | 78 // This may be null in testing or when the extenion_service hasn't been |
| 78 // initialized, in which case it will be registered then. | 79 // initialized, in which case it will be registered then. |
| 79 if (ext_service) | 80 if (ext_service) |
| 80 ext_service->RegisterContentSettings(settings_map.get()); | 81 ext_service->RegisterContentSettings(settings_map.get()); |
| 81 #endif // defined(ENABLE_EXTENSIONS) | 82 #endif // defined(ENABLE_EXTENSIONS) |
| 82 #if defined(ENABLE_SUPERVISED_USERS) | 83 #if defined(ENABLE_SUPERVISED_USERS) |
| 83 SupervisedUserSettingsService* supervised_service = | 84 SupervisedUserSettingsService* supervised_service = |
| 84 SupervisedUserSettingsServiceFactory::GetForProfile(profile); | 85 SupervisedUserSettingsServiceFactory::GetForProfile(profile); |
| 85 // This may be null in testing. | 86 // This may be null in testing. |
| 86 if (supervised_service) { | 87 if (supervised_service) { |
| 87 scoped_ptr<content_settings::SupervisedProvider> supervised_provider( | 88 scoped_ptr<content_settings::SupervisedProvider> supervised_provider( |
| 88 new content_settings::SupervisedProvider(supervised_service)); | 89 new content_settings::SupervisedProvider(supervised_service)); |
| 89 settings_map->RegisterProvider(HostContentSettingsMap::SUPERVISED_PROVIDER, | 90 settings_map->RegisterProvider(HostContentSettingsMap::SUPERVISED_PROVIDER, |
| 90 std::move(supervised_provider)); | 91 std::move(supervised_provider)); |
| 91 } | 92 } |
| 92 #endif // defined(ENABLE_SUPERVISED_USERS) | 93 #endif // defined(ENABLE_SUPERVISED_USERS) |
| 93 | 94 |
| 94 return settings_map; | 95 return settings_map; |
| 95 } | 96 } |
| 96 | 97 |
| 97 content::BrowserContext* HostContentSettingsMapFactory::GetBrowserContextToUse( | 98 content::BrowserContext* HostContentSettingsMapFactory::GetBrowserContextToUse( |
| 98 content::BrowserContext* context) const { | 99 content::BrowserContext* context) const { |
| 99 return context; | 100 return context; |
| 100 } | 101 } |
| OLD | NEW |