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

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

Issue 2158743002: Register a pref to control migration status (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@change_scoping_type
Patch Set: add some comments 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/prefs/pref_service_syncable_util.h"
10 #include "chrome/browser/profiles/off_the_record_profile_impl.h" 10 #include "chrome/browser/profiles/off_the_record_profile_impl.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "components/content_settings/core/browser/host_content_settings_map.h" 12 #include "components/content_settings/core/browser/host_content_settings_map.h"
13 #include "components/content_settings/core/common/pref_names.h"
13 #include "components/keyed_service/content/browser_context_dependency_manager.h" 14 #include "components/keyed_service/content/browser_context_dependency_manager.h"
14 #include "components/syncable_prefs/pref_service_syncable.h" 15 #include "components/syncable_prefs/pref_service_syncable.h"
15 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
16 17
17 #if defined(ENABLE_EXTENSIONS) 18 #if defined(ENABLE_EXTENSIONS)
18 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
19 #include "extensions/browser/extension_system.h" 20 #include "extensions/browser/extension_system.h"
20 #include "extensions/browser/extension_system_provider.h" 21 #include "extensions/browser/extension_system_provider.h"
21 #include "extensions/browser/extensions_browser_client.h" 22 #include "extensions/browser/extensions_browser_client.h"
22 #endif 23 #endif
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // If off the record, retrieve the host content settings map of the parent 68 // If off the record, retrieve the host content settings map of the parent
68 // profile in order to ensure the preferences have been migrated. 69 // profile in order to ensure the preferences have been migrated.
69 if (profile->GetProfileType() == Profile::INCOGNITO_PROFILE) 70 if (profile->GetProfileType() == Profile::INCOGNITO_PROFILE)
70 GetForProfile(profile->GetOriginalProfile()); 71 GetForProfile(profile->GetOriginalProfile());
71 72
72 scoped_refptr<HostContentSettingsMap> settings_map(new HostContentSettingsMap( 73 scoped_refptr<HostContentSettingsMap> settings_map(new HostContentSettingsMap(
73 profile->GetPrefs(), 74 profile->GetPrefs(),
74 profile->GetProfileType() == Profile::INCOGNITO_PROFILE, 75 profile->GetProfileType() == Profile::INCOGNITO_PROFILE,
75 profile->GetProfileType() == Profile::GUEST_PROFILE)); 76 profile->GetProfileType() == Profile::GUEST_PROFILE));
76 77
77 syncable_prefs::PrefServiceSyncable* pref_service = 78 if (profile->GetPrefs()->GetInteger(prefs::kContentSettingsMigrationStatus) ==
78 PrefServiceSyncableFromProfile(profile); 79 content_settings::DONE_IN_HCSM) {
79 if (pref_service) { 80 syncable_prefs::PrefServiceSyncable* pref_service =
80 pref_service->RegisterMergeDataFinishedCallback( 81 PrefServiceSyncableFromProfile(profile);
81 base::Bind(&HostContentSettingsMap::MigrateDomainScopedSettings, 82 if (pref_service) {
82 settings_map->GetWeakPtr())); 83 pref_service->RegisterMergeDataFinishedCallback(
84 base::Bind(&HostContentSettingsMap::MigrateDomainScopedSettings,
85 settings_map->GetWeakPtr()));
86 profile->GetPrefs()->SetInteger(prefs::kContentSettingsMigrationStatus,
87 content_settings::DONE_IN_HCSM_AND_SYNC);
raymes 2016/07/19 01:48:15 Instead of checking/modifying the pref here, I thi
lshang 2016/07/19 07:45:56 We all need to run the migration code either befor
lshang 2016/07/20 06:16:20 Done.
88 }
83 } 89 }
84 90
85 #if defined(ENABLE_EXTENSIONS) 91 #if defined(ENABLE_EXTENSIONS)
86 ExtensionService *ext_service = 92 ExtensionService *ext_service =
87 extensions::ExtensionSystem::Get(profile)->extension_service(); 93 extensions::ExtensionSystem::Get(profile)->extension_service();
88 // This may be null in testing or when the extenion_service hasn't been 94 // This may be null in testing or when the extenion_service hasn't been
89 // initialized, in which case it will be registered then. 95 // initialized, in which case it will be registered then.
90 if (ext_service) 96 if (ext_service)
91 ext_service->RegisterContentSettings(settings_map.get()); 97 ext_service->RegisterContentSettings(settings_map.get());
92 #endif // defined(ENABLE_EXTENSIONS) 98 #endif // defined(ENABLE_EXTENSIONS)
93 #if defined(ENABLE_SUPERVISED_USERS) 99 #if defined(ENABLE_SUPERVISED_USERS)
94 SupervisedUserSettingsService* supervised_service = 100 SupervisedUserSettingsService* supervised_service =
95 SupervisedUserSettingsServiceFactory::GetForProfile(profile); 101 SupervisedUserSettingsServiceFactory::GetForProfile(profile);
96 // This may be null in testing. 102 // This may be null in testing.
97 if (supervised_service) { 103 if (supervised_service) {
98 std::unique_ptr<content_settings::SupervisedProvider> supervised_provider( 104 std::unique_ptr<content_settings::SupervisedProvider> supervised_provider(
99 new content_settings::SupervisedProvider(supervised_service)); 105 new content_settings::SupervisedProvider(supervised_service));
100 settings_map->RegisterProvider(HostContentSettingsMap::SUPERVISED_PROVIDER, 106 settings_map->RegisterProvider(HostContentSettingsMap::SUPERVISED_PROVIDER,
101 std::move(supervised_provider)); 107 std::move(supervised_provider));
102 } 108 }
103 #endif // defined(ENABLE_SUPERVISED_USERS) 109 #endif // defined(ENABLE_SUPERVISED_USERS)
104 110
105 return settings_map; 111 return settings_map;
106 } 112 }
107 113
108 content::BrowserContext* HostContentSettingsMapFactory::GetBrowserContextToUse( 114 content::BrowserContext* HostContentSettingsMapFactory::GetBrowserContextToUse(
109 content::BrowserContext* context) const { 115 content::BrowserContext* context) const {
110 return context; 116 return context;
111 } 117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698