Chromium Code Reviews| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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)); |
| 74 | 75 |
| 76 // TODO(lshang): Make this not a comment when we change scoping type and hook up | |
|
Bernhard Bauer
2016/07/07 08:50:08
The comment should be indented at the same level a
lshang
2016/07/13 06:27:28
I moved this code block to the following CL, so th
| |
| 77 // the migration code. | |
| 78 /* syncable_prefs::PrefServiceSyncable* pref_service = | |
|
Bernhard Bauer
2016/07/07 08:50:08
And this comment should use the regular double-sla
lshang
2016/07/13 06:27:28
Also with this comment sign.
| |
| 79 PrefServiceSyncableFromProfile(profile); | |
| 80 if (pref_service) | |
|
Bernhard Bauer
2016/07/07 08:50:08
Add braces, as the body spans more than a single l
lshang
2016/07/13 06:27:28
Done in the following CL.
| |
| 81 pref_service->RegisterMergeDataFinishedCallback(base::Bind( | |
| 82 &HostContentSettingsMap::MigrateDomainScopedSettings, settings_map));*/ | |
|
Bernhard Bauer
2016/07/07 08:50:08
You are going to have to figure out the lifetime s
raymes
2016/07/13 03:20:20
I don't think we can make that guarantee (that I k
lshang
2016/07/13 06:27:28
Done.
| |
| 83 | |
| 75 #if defined(ENABLE_EXTENSIONS) | 84 #if defined(ENABLE_EXTENSIONS) |
| 76 ExtensionService *ext_service = | 85 ExtensionService *ext_service = |
| 77 extensions::ExtensionSystem::Get(profile)->extension_service(); | 86 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 78 // This may be null in testing or when the extenion_service hasn't been | 87 // This may be null in testing or when the extenion_service hasn't been |
| 79 // initialized, in which case it will be registered then. | 88 // initialized, in which case it will be registered then. |
| 80 if (ext_service) | 89 if (ext_service) |
| 81 ext_service->RegisterContentSettings(settings_map.get()); | 90 ext_service->RegisterContentSettings(settings_map.get()); |
| 82 #endif // defined(ENABLE_EXTENSIONS) | 91 #endif // defined(ENABLE_EXTENSIONS) |
| 83 #if defined(ENABLE_SUPERVISED_USERS) | 92 #if defined(ENABLE_SUPERVISED_USERS) |
| 84 SupervisedUserSettingsService* supervised_service = | 93 SupervisedUserSettingsService* supervised_service = |
| 85 SupervisedUserSettingsServiceFactory::GetForProfile(profile); | 94 SupervisedUserSettingsServiceFactory::GetForProfile(profile); |
| 86 // This may be null in testing. | 95 // This may be null in testing. |
| 87 if (supervised_service) { | 96 if (supervised_service) { |
| 88 std::unique_ptr<content_settings::SupervisedProvider> supervised_provider( | 97 std::unique_ptr<content_settings::SupervisedProvider> supervised_provider( |
| 89 new content_settings::SupervisedProvider(supervised_service)); | 98 new content_settings::SupervisedProvider(supervised_service)); |
| 90 settings_map->RegisterProvider(HostContentSettingsMap::SUPERVISED_PROVIDER, | 99 settings_map->RegisterProvider(HostContentSettingsMap::SUPERVISED_PROVIDER, |
| 91 std::move(supervised_provider)); | 100 std::move(supervised_provider)); |
| 92 } | 101 } |
| 93 #endif // defined(ENABLE_SUPERVISED_USERS) | 102 #endif // defined(ENABLE_SUPERVISED_USERS) |
| 94 | 103 |
| 95 return settings_map; | 104 return settings_map; |
| 96 } | 105 } |
| 97 | 106 |
| 98 content::BrowserContext* HostContentSettingsMapFactory::GetBrowserContextToUse( | 107 content::BrowserContext* HostContentSettingsMapFactory::GetBrowserContextToUse( |
| 99 content::BrowserContext* context) const { | 108 content::BrowserContext* context) const { |
| 100 return context; | 109 return context; |
| 101 } | 110 } |
| OLD | NEW |