OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/prefs/browser_prefs.h" | 5 #include "chrome/browser/prefs/browser_prefs.h" |
6 | 6 |
7 #include "chrome/browser/about_flags.h" | 7 #include "chrome/browser/about_flags.h" |
8 #include "chrome/browser/accessibility/invert_bubble_prefs.h" | 8 #include "chrome/browser/accessibility/invert_bubble_prefs.h" |
9 #include "chrome/browser/autofill/autofill_manager.h" | 9 #include "chrome/browser/autofill/autofill_manager.h" |
10 #include "chrome/browser/background/background_mode_manager.h" | 10 #include "chrome/browser/background/background_mode_manager.h" |
11 #include "chrome/browser/bookmarks/bookmark_prompt_prefs.h" | 11 #include "chrome/browser/bookmarks/bookmark_prompt_prefs.h" |
12 #include "chrome/browser/bookmarks/bookmark_utils.h" | 12 #include "chrome/browser/bookmarks/bookmark_utils.h" |
13 #include "chrome/browser/browser_process_impl.h" | |
13 #include "chrome/browser/browser_shutdown.h" | 14 #include "chrome/browser/browser_shutdown.h" |
14 #include "chrome/browser/chrome_content_browser_client.h" | 15 #include "chrome/browser/chrome_content_browser_client.h" |
15 #include "chrome/browser/content_settings/host_content_settings_map.h" | 16 #include "chrome/browser/content_settings/host_content_settings_map.h" |
16 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 17 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
17 #include "chrome/browser/devtools/devtools_window.h" | 18 #include "chrome/browser/devtools/devtools_window.h" |
18 #include "chrome/browser/download/download_prefs.h" | 19 #include "chrome/browser/download/download_prefs.h" |
19 #include "chrome/browser/extensions/api/commands/command_service.h" | 20 #include "chrome/browser/extensions/api/commands/command_service.h" |
20 #include "chrome/browser/extensions/api/tabs/tabs_api.h" | 21 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
21 #include "chrome/browser/extensions/component_loader.h" | 22 #include "chrome/browser/extensions/component_loader.h" |
22 #include "chrome/browser/extensions/extension_prefs.h" | 23 #include "chrome/browser/extensions/extension_prefs.h" |
(...skipping 16 matching lines...) Expand all Loading... | |
39 #include "chrome/browser/net/net_pref_observer.h" | 40 #include "chrome/browser/net/net_pref_observer.h" |
40 #include "chrome/browser/net/predictor.h" | 41 #include "chrome/browser/net/predictor.h" |
41 #include "chrome/browser/net/ssl_config_service_manager.h" | 42 #include "chrome/browser/net/ssl_config_service_manager.h" |
42 #include "chrome/browser/notifications/desktop_notification_service.h" | 43 #include "chrome/browser/notifications/desktop_notification_service.h" |
43 #include "chrome/browser/notifications/notification_prefs_manager.h" | 44 #include "chrome/browser/notifications/notification_prefs_manager.h" |
44 #include "chrome/browser/page_info_model.h" | 45 #include "chrome/browser/page_info_model.h" |
45 #include "chrome/browser/password_manager/password_manager.h" | 46 #include "chrome/browser/password_manager/password_manager.h" |
46 #include "chrome/browser/pepper_flash_settings_manager.h" | 47 #include "chrome/browser/pepper_flash_settings_manager.h" |
47 #include "chrome/browser/plugins/plugin_finder.h" | 48 #include "chrome/browser/plugins/plugin_finder.h" |
48 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 49 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
50 #include "chrome/browser/prefs/pref_registry_simple.h" | |
49 #include "chrome/browser/prefs/pref_service.h" | 51 #include "chrome/browser/prefs/pref_service.h" |
50 #include "chrome/browser/prefs/session_startup_pref.h" | 52 #include "chrome/browser/prefs/session_startup_pref.h" |
51 #include "chrome/browser/profiles/chrome_version_service.h" | 53 #include "chrome/browser/profiles/chrome_version_service.h" |
52 #include "chrome/browser/profiles/profile_impl.h" | 54 #include "chrome/browser/profiles/profile_impl.h" |
53 #include "chrome/browser/profiles/profile_info_cache.h" | 55 #include "chrome/browser/profiles/profile_info_cache.h" |
54 #include "chrome/browser/profiles/profile_manager.h" | 56 #include "chrome/browser/profiles/profile_manager.h" |
55 #include "chrome/browser/renderer_host/web_cache_manager.h" | 57 #include "chrome/browser/renderer_host/web_cache_manager.h" |
56 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 58 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
57 #include "chrome/browser/signin/signin_manager_factory.h" | 59 #include "chrome/browser/signin/signin_manager_factory.h" |
58 #include "chrome/browser/sync/sync_prefs.h" | 60 #include "chrome/browser/sync/sync_prefs.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 NO_PREFS = 0, | 140 NO_PREFS = 0, |
139 DNS_PREFS = 1 << 0, | 141 DNS_PREFS = 1 << 0, |
140 WINDOWS_PREFS = 1 << 1, | 142 WINDOWS_PREFS = 1 << 1, |
141 GOOGLE_URL_TRACKER_PREFS = 1 << 2, | 143 GOOGLE_URL_TRACKER_PREFS = 1 << 2, |
142 }; | 144 }; |
143 | 145 |
144 } // namespace | 146 } // namespace |
145 | 147 |
146 namespace chrome { | 148 namespace chrome { |
147 | 149 |
148 void RegisterLocalState(PrefServiceSimple* local_state) { | 150 void RegisterLocalState(PrefRegistrySimple* registry, |
151 PrefService* local_state) { | |
149 // Prefs in Local State. | 152 // Prefs in Local State. |
150 local_state->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0); | 153 registry->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0); |
151 | 154 |
152 // Please keep this list alphabetized. | 155 // Please keep this list alphabetized. |
153 browser_shutdown::RegisterPrefs(local_state); | 156 browser_shutdown::RegisterPrefs(registry); |
154 chrome::RegisterScreenshotPrefs(local_state); | 157 chrome::RegisterScreenshotPrefs(registry); |
155 ExternalProtocolHandler::RegisterPrefs(local_state); | 158 ExternalProtocolHandler::RegisterPrefs(registry); |
156 FlagsUI::RegisterPrefs(local_state); | 159 FlagsUI::RegisterPrefs(registry); |
157 geolocation::RegisterPrefs(local_state); | 160 geolocation::RegisterPrefs(registry); |
158 IntranetRedirectDetector::RegisterPrefs(local_state); | 161 IntranetRedirectDetector::RegisterPrefs(registry); |
159 KeywordEditorController::RegisterPrefs(local_state); | 162 KeywordEditorController::RegisterPrefs(registry); |
160 MetricsLog::RegisterPrefs(local_state); | 163 MetricsLog::RegisterPrefs(registry); |
161 MetricsService::RegisterPrefs(local_state); | 164 MetricsService::RegisterPrefs(registry); |
162 PrefProxyConfigTrackerImpl::RegisterPrefs(local_state); | 165 PrefProxyConfigTrackerImpl::RegisterPrefs(registry); |
163 ProfileInfoCache::RegisterPrefs(local_state); | 166 ProfileInfoCache::RegisterPrefs(registry); |
164 ProfileManager::RegisterPrefs(local_state); | 167 ProfileManager::RegisterPrefs(registry); |
165 PromoResourceService::RegisterPrefs(local_state); | 168 PromoResourceService::RegisterPrefs(registry); |
166 SigninManagerFactory::RegisterPrefs(local_state); | 169 SigninManagerFactory::RegisterPrefs(registry); |
167 SSLConfigServiceManager::RegisterPrefs(local_state); | 170 SSLConfigServiceManager::RegisterPrefs(registry); |
168 UpgradeDetector::RegisterPrefs(local_state); | 171 UpgradeDetector::RegisterPrefs(registry); |
169 WebCacheManager::RegisterPrefs(local_state); | 172 WebCacheManager::RegisterPrefs(registry); |
170 | 173 |
171 #if defined(ENABLE_PLUGINS) | 174 #if defined(ENABLE_PLUGINS) |
172 PluginFinder::RegisterPrefs(local_state); | 175 PluginFinder::RegisterPrefs(registry); |
173 #endif | 176 #endif |
174 | 177 |
175 #if defined(ENABLE_PLUGIN_INSTALLATION) | 178 #if defined(ENABLE_PLUGIN_INSTALLATION) |
176 PluginsResourceService::RegisterPrefs(local_state); | 179 PluginsResourceService::RegisterPrefs(registry); |
177 #endif | 180 #endif |
178 | 181 |
179 #if defined(ENABLE_CONFIGURATION_POLICY) | 182 #if defined(ENABLE_CONFIGURATION_POLICY) |
180 policy::CloudPolicySubsystem::RegisterPrefs(local_state); | 183 policy::CloudPolicySubsystem::RegisterPrefs(registry); |
181 policy::PolicyStatisticsCollector::RegisterPrefs(local_state); | 184 policy::PolicyStatisticsCollector::RegisterPrefs(registry); |
182 #endif | 185 #endif |
183 | 186 |
184 #if defined(ENABLE_NOTIFICATIONS) | 187 #if defined(ENABLE_NOTIFICATIONS) |
185 NotificationPrefsManager::RegisterPrefs(local_state); | 188 NotificationPrefsManager::RegisterPrefs(local_state, registry); |
Mattias Nissler (ping if slow)
2013/01/25 14:57:11
Ah, this is the reason. That set-to-default piece
Jói
2013/01/29 16:10:02
Mind if we take care of this in a follow-up?
| |
186 #endif | 189 #endif |
187 | 190 |
188 #if defined(ENABLE_TASK_MANAGER) | 191 #if defined(ENABLE_TASK_MANAGER) |
189 TaskManager::RegisterPrefs(local_state); | 192 TaskManager::RegisterPrefs(registry); |
190 #endif // defined(ENABLE_TASK_MANAGER) | 193 #endif // defined(ENABLE_TASK_MANAGER) |
191 | 194 |
192 #if defined(TOOLKIT_VIEWS) | 195 #if defined(TOOLKIT_VIEWS) |
193 RegisterBrowserViewPrefs(local_state); | 196 RegisterBrowserViewPrefs(registry); |
194 RegisterTabStripLayoutTypePrefs(local_state); | 197 RegisterTabStripLayoutTypePrefs(registry); |
195 #endif | 198 #endif |
196 | 199 |
197 #if !defined(OS_ANDROID) | 200 #if !defined(OS_ANDROID) |
198 BackgroundModeManager::RegisterPrefs(local_state); | 201 BackgroundModeManager::RegisterPrefs(registry); |
199 chrome_variations::VariationsService::RegisterPrefs(local_state); | 202 chrome_variations::VariationsService::RegisterPrefs(registry); |
200 RegisterBrowserPrefs(local_state); | 203 RegisterBrowserPrefs(registry); |
201 ManagedMode::RegisterPrefs(local_state); | 204 ManagedMode::RegisterPrefs(registry); |
202 #endif | 205 #endif |
203 | 206 |
204 #if defined(OS_CHROMEOS) | 207 #if defined(OS_CHROMEOS) |
205 chromeos::AudioHandler::RegisterPrefs(local_state); | 208 chromeos::AudioHandler::RegisterPrefs(registry); |
206 chromeos::DataPromoNotification::RegisterPrefs(local_state); | 209 chromeos::DataPromoNotification::RegisterPrefs(registry); |
207 chromeos::device_settings_cache::RegisterPrefs(local_state); | 210 chromeos::device_settings_cache::RegisterPrefs(registry); |
208 chromeos::language_prefs::RegisterPrefs(local_state); | 211 chromeos::language_prefs::RegisterPrefs(registry); |
209 chromeos::ProxyConfigServiceImpl::RegisterPrefs(local_state); | 212 chromeos::ProxyConfigServiceImpl::RegisterPrefs(registry); |
210 chromeos::RegisterDisplayLocalStatePrefs(local_state); | 213 chromeos::RegisterDisplayLocalStatePrefs(registry); |
211 chromeos::ServicesCustomizationDocument::RegisterPrefs(local_state); | 214 chromeos::ServicesCustomizationDocument::RegisterPrefs(registry); |
212 chromeos::UserImageManager::RegisterPrefs(local_state); | 215 chromeos::UserImageManager::RegisterPrefs(registry); |
213 chromeos::UserManager::RegisterPrefs(local_state); | 216 chromeos::UserManager::RegisterPrefs(registry); |
214 chromeos::WallpaperManager::RegisterPrefs(local_state); | 217 chromeos::WallpaperManager::RegisterPrefs(registry); |
215 chromeos::WizardController::RegisterPrefs(local_state); | 218 chromeos::WizardController::RegisterPrefs(registry); |
216 policy::AutoEnrollmentClient::RegisterPrefs(local_state); | 219 policy::AutoEnrollmentClient::RegisterPrefs(registry); |
217 policy::DeviceStatusCollector::RegisterPrefs(local_state); | 220 policy::DeviceStatusCollector::RegisterPrefs(registry); |
218 #endif | 221 #endif |
219 | 222 |
220 #if defined(OS_MACOSX) | 223 #if defined(OS_MACOSX) |
221 confirm_quit::RegisterLocalState(local_state); | 224 confirm_quit::RegisterLocalState(registry); |
222 #endif | 225 #endif |
223 } | 226 } |
224 | 227 |
225 void RegisterUserPrefs(PrefServiceSyncable* user_prefs) { | 228 void RegisterUserPrefs(PrefServiceSyncable* user_prefs) { |
226 // User prefs. Please keep this list alphabetized. | 229 // User prefs. Please keep this list alphabetized. |
227 AlternateErrorPageTabObserver::RegisterUserPrefs(user_prefs); | 230 AlternateErrorPageTabObserver::RegisterUserPrefs(user_prefs); |
228 AutofillManager::RegisterUserPrefs(user_prefs); | 231 AutofillManager::RegisterUserPrefs(user_prefs); |
229 BookmarkPromptPrefs::RegisterUserPrefs(user_prefs); | 232 BookmarkPromptPrefs::RegisterUserPrefs(user_prefs); |
230 bookmark_utils::RegisterUserPrefs(user_prefs); | 233 bookmark_utils::RegisterUserPrefs(user_prefs); |
231 BrowserInstantController::RegisterUserPrefs(user_prefs); | 234 BrowserInstantController::RegisterUserPrefs(user_prefs); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 void MigrateUserPrefs(Profile* profile) { | 318 void MigrateUserPrefs(Profile* profile) { |
316 // Cleanup old prefs. | 319 // Cleanup old prefs. |
317 static const char kBackupPref[] = "backup"; | 320 static const char kBackupPref[] = "backup"; |
318 PrefServiceSyncable* prefs = profile->GetPrefs(); | 321 PrefServiceSyncable* prefs = profile->GetPrefs(); |
319 prefs->RegisterDictionaryPref(kBackupPref, new DictionaryValue(), | 322 prefs->RegisterDictionaryPref(kBackupPref, new DictionaryValue(), |
320 PrefServiceSyncable::UNSYNCABLE_PREF); | 323 PrefServiceSyncable::UNSYNCABLE_PREF); |
321 prefs->ClearPref(kBackupPref); | 324 prefs->ClearPref(kBackupPref); |
322 prefs->UnregisterPreference(kBackupPref); | 325 prefs->UnregisterPreference(kBackupPref); |
323 } | 326 } |
324 | 327 |
325 void MigrateBrowserPrefs(Profile* profile, PrefServiceSimple* local_state) { | 328 void MigrateBrowserPrefs(Profile* profile, PrefService* local_state) { |
326 // Copy pref values which have been migrated to user_prefs from local_state, | 329 // Copy pref values which have been migrated to user_prefs from local_state, |
327 // or remove them from local_state outright, if copying is not required. | 330 // or remove them from local_state outright, if copying is not required. |
328 int current_version = | 331 int current_version = |
329 local_state->GetInteger(prefs::kMultipleProfilePrefMigration); | 332 local_state->GetInteger(prefs::kMultipleProfilePrefMigration); |
333 PrefRegistrySimple* registry = static_cast<PrefRegistrySimple*>( | |
334 local_state->DeprecatedGetPrefRegistry()); | |
330 | 335 |
331 if (!(current_version & DNS_PREFS)) { | 336 if (!(current_version & DNS_PREFS)) { |
332 local_state->RegisterListPref(prefs::kDnsStartupPrefetchList); | 337 registry->RegisterListPref(prefs::kDnsStartupPrefetchList); |
Mattias Nissler (ping if slow)
2013/01/25 14:57:11
It seems like we could register these prefs throug
Jói
2013/01/29 16:10:02
Mind if we take care of this in a follow-up?
| |
333 local_state->ClearPref(prefs::kDnsStartupPrefetchList); | 338 local_state->ClearPref(prefs::kDnsStartupPrefetchList); |
334 | 339 |
335 local_state->RegisterListPref(prefs::kDnsHostReferralList); | 340 registry->RegisterListPref(prefs::kDnsHostReferralList); |
336 local_state->ClearPref(prefs::kDnsHostReferralList); | 341 local_state->ClearPref(prefs::kDnsHostReferralList); |
337 | 342 |
338 current_version |= DNS_PREFS; | 343 current_version |= DNS_PREFS; |
339 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, | 344 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, |
340 current_version); | 345 current_version); |
341 } | 346 } |
342 | 347 |
343 PrefServiceSyncable* user_prefs = profile->GetPrefs(); | 348 PrefServiceSyncable* user_prefs = profile->GetPrefs(); |
344 if (!(current_version & WINDOWS_PREFS)) { | 349 if (!(current_version & WINDOWS_PREFS)) { |
345 local_state->RegisterIntegerPref(prefs::kDevToolsHSplitLocation, -1); | 350 registry->RegisterIntegerPref(prefs::kDevToolsHSplitLocation, -1); |
346 if (local_state->HasPrefPath(prefs::kDevToolsHSplitLocation)) { | 351 if (local_state->HasPrefPath(prefs::kDevToolsHSplitLocation)) { |
347 user_prefs->SetInteger( | 352 user_prefs->SetInteger( |
348 prefs::kDevToolsHSplitLocation, | 353 prefs::kDevToolsHSplitLocation, |
349 local_state->GetInteger(prefs::kDevToolsHSplitLocation)); | 354 local_state->GetInteger(prefs::kDevToolsHSplitLocation)); |
350 } | 355 } |
351 local_state->ClearPref(prefs::kDevToolsHSplitLocation); | 356 local_state->ClearPref(prefs::kDevToolsHSplitLocation); |
352 | 357 |
353 local_state->RegisterDictionaryPref(prefs::kBrowserWindowPlacement); | 358 registry->RegisterDictionaryPref(prefs::kBrowserWindowPlacement); |
354 if (local_state->HasPrefPath(prefs::kBrowserWindowPlacement)) { | 359 if (local_state->HasPrefPath(prefs::kBrowserWindowPlacement)) { |
355 const PrefService::Preference* pref = | 360 const PrefService::Preference* pref = |
356 local_state->FindPreference(prefs::kBrowserWindowPlacement); | 361 local_state->FindPreference(prefs::kBrowserWindowPlacement); |
357 DCHECK(pref); | 362 DCHECK(pref); |
358 user_prefs->Set(prefs::kBrowserWindowPlacement, | 363 user_prefs->Set(prefs::kBrowserWindowPlacement, |
359 *(pref->GetValue())); | 364 *(pref->GetValue())); |
360 } | 365 } |
361 local_state->ClearPref(prefs::kBrowserWindowPlacement); | 366 local_state->ClearPref(prefs::kBrowserWindowPlacement); |
362 | 367 |
363 current_version |= WINDOWS_PREFS; | 368 current_version |= WINDOWS_PREFS; |
364 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, | 369 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, |
365 current_version); | 370 current_version); |
366 } | 371 } |
367 | 372 |
368 if (!(current_version & GOOGLE_URL_TRACKER_PREFS)) { | 373 if (!(current_version & GOOGLE_URL_TRACKER_PREFS)) { |
369 GoogleURLTrackerFactory::GetInstance()->RegisterUserPrefsOnProfile(profile); | 374 GoogleURLTrackerFactory::GetInstance()->RegisterUserPrefsOnProfile(profile); |
370 local_state->RegisterStringPref(prefs::kLastKnownGoogleURL, | 375 registry->RegisterStringPref(prefs::kLastKnownGoogleURL, |
371 GoogleURLTracker::kDefaultGoogleHomepage); | 376 GoogleURLTracker::kDefaultGoogleHomepage); |
372 if (local_state->HasPrefPath(prefs::kLastKnownGoogleURL)) { | 377 if (local_state->HasPrefPath(prefs::kLastKnownGoogleURL)) { |
373 user_prefs->SetString(prefs::kLastKnownGoogleURL, | 378 user_prefs->SetString(prefs::kLastKnownGoogleURL, |
374 local_state->GetString(prefs::kLastKnownGoogleURL)); | 379 local_state->GetString(prefs::kLastKnownGoogleURL)); |
375 } | 380 } |
376 local_state->ClearPref(prefs::kLastKnownGoogleURL); | 381 local_state->ClearPref(prefs::kLastKnownGoogleURL); |
377 | 382 |
378 local_state->RegisterStringPref(prefs::kLastPromptedGoogleURL, | 383 registry->RegisterStringPref(prefs::kLastPromptedGoogleURL, |
379 std::string()); | 384 std::string()); |
380 if (local_state->HasPrefPath(prefs::kLastPromptedGoogleURL)) { | 385 if (local_state->HasPrefPath(prefs::kLastPromptedGoogleURL)) { |
381 user_prefs->SetString( | 386 user_prefs->SetString( |
382 prefs::kLastPromptedGoogleURL, | 387 prefs::kLastPromptedGoogleURL, |
383 local_state->GetString(prefs::kLastPromptedGoogleURL)); | 388 local_state->GetString(prefs::kLastPromptedGoogleURL)); |
384 } | 389 } |
385 local_state->ClearPref(prefs::kLastPromptedGoogleURL); | 390 local_state->ClearPref(prefs::kLastPromptedGoogleURL); |
386 | 391 |
387 current_version |= GOOGLE_URL_TRACKER_PREFS; | 392 current_version |= GOOGLE_URL_TRACKER_PREFS; |
388 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, | 393 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, |
389 current_version); | 394 current_version); |
390 } | 395 } |
391 } | 396 } |
392 | 397 |
393 } // namespace chrome | 398 } // namespace chrome |
OLD | NEW |