Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: chrome/browser/content_settings/host_content_settings_map_factory.cc

Issue 2075103002: Change ContentSettingsType's scoping type and hookup migration code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@do_migration_after_sync
Patch Set: revise test Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
14 #include "components/syncable_prefs/pref_service_syncable.h"
13 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
14 16
15 #if defined(ENABLE_EXTENSIONS) 17 #if defined(ENABLE_EXTENSIONS)
16 #include "chrome/browser/extensions/extension_service.h" 18 #include "chrome/browser/extensions/extension_service.h"
17 #include "extensions/browser/extension_system.h" 19 #include "extensions/browser/extension_system.h"
18 #include "extensions/browser/extension_system_provider.h" 20 #include "extensions/browser/extension_system_provider.h"
19 #include "extensions/browser/extensions_browser_client.h" 21 #include "extensions/browser/extensions_browser_client.h"
20 #endif 22 #endif
21 23
22 #if defined(ENABLE_SUPERVISED_USERS) 24 #if defined(ENABLE_SUPERVISED_USERS)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // If off the record, retrieve the host content settings map of the parent 67 // If off the record, retrieve the host content settings map of the parent
66 // profile in order to ensure the preferences have been migrated. 68 // profile in order to ensure the preferences have been migrated.
67 if (profile->GetProfileType() == Profile::INCOGNITO_PROFILE) 69 if (profile->GetProfileType() == Profile::INCOGNITO_PROFILE)
68 GetForProfile(profile->GetOriginalProfile()); 70 GetForProfile(profile->GetOriginalProfile());
69 71
70 scoped_refptr<HostContentSettingsMap> settings_map(new HostContentSettingsMap( 72 scoped_refptr<HostContentSettingsMap> settings_map(new HostContentSettingsMap(
71 profile->GetPrefs(), 73 profile->GetPrefs(),
72 profile->GetProfileType() == Profile::INCOGNITO_PROFILE, 74 profile->GetProfileType() == Profile::INCOGNITO_PROFILE,
73 profile->GetProfileType() == Profile::GUEST_PROFILE)); 75 profile->GetProfileType() == Profile::GUEST_PROFILE));
74 76
77 syncable_prefs::PrefServiceSyncable* pref_service =
78 PrefServiceSyncableFromProfile(profile);
79 if (pref_service) {
80 pref_service->RegisterMergeDataFinishedCallback(
81 base::Bind(&HostContentSettingsMap::MigrateDomainScopedSettings,
82 settings_map->GetWeakPtr(), true));
raymes 2016/07/21 01:13:57 nit: we tend to document bools that we pass around
lshang 2016/07/22 02:58:38 Done.
83 }
84
75 #if defined(ENABLE_EXTENSIONS) 85 #if defined(ENABLE_EXTENSIONS)
76 ExtensionService *ext_service = 86 ExtensionService *ext_service =
77 extensions::ExtensionSystem::Get(profile)->extension_service(); 87 extensions::ExtensionSystem::Get(profile)->extension_service();
78 // This may be null in testing or when the extenion_service hasn't been 88 // This may be null in testing or when the extenion_service hasn't been
79 // initialized, in which case it will be registered then. 89 // initialized, in which case it will be registered then.
80 if (ext_service) 90 if (ext_service)
81 ext_service->RegisterContentSettings(settings_map.get()); 91 ext_service->RegisterContentSettings(settings_map.get());
82 #endif // defined(ENABLE_EXTENSIONS) 92 #endif // defined(ENABLE_EXTENSIONS)
83 #if defined(ENABLE_SUPERVISED_USERS) 93 #if defined(ENABLE_SUPERVISED_USERS)
84 SupervisedUserSettingsService* supervised_service = 94 SupervisedUserSettingsService* supervised_service =
85 SupervisedUserSettingsServiceFactory::GetForProfile(profile); 95 SupervisedUserSettingsServiceFactory::GetForProfile(profile);
86 // This may be null in testing. 96 // This may be null in testing.
87 if (supervised_service) { 97 if (supervised_service) {
88 std::unique_ptr<content_settings::SupervisedProvider> supervised_provider( 98 std::unique_ptr<content_settings::SupervisedProvider> supervised_provider(
89 new content_settings::SupervisedProvider(supervised_service)); 99 new content_settings::SupervisedProvider(supervised_service));
90 settings_map->RegisterProvider(HostContentSettingsMap::SUPERVISED_PROVIDER, 100 settings_map->RegisterProvider(HostContentSettingsMap::SUPERVISED_PROVIDER,
91 std::move(supervised_provider)); 101 std::move(supervised_provider));
92 } 102 }
93 #endif // defined(ENABLE_SUPERVISED_USERS) 103 #endif // defined(ENABLE_SUPERVISED_USERS)
94 104
95 return settings_map; 105 return settings_map;
96 } 106 }
97 107
98 content::BrowserContext* HostContentSettingsMapFactory::GetBrowserContextToUse( 108 content::BrowserContext* HostContentSettingsMapFactory::GetBrowserContextToUse(
99 content::BrowserContext* context) const { 109 content::BrowserContext* context) const {
100 return context; 110 return context;
101 } 111 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698