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/app_launcher.h" | 22 #include "chrome/browser/extensions/app_launcher.h" |
22 #include "chrome/browser/extensions/component_loader.h" | 23 #include "chrome/browser/extensions/component_loader.h" |
(...skipping 16 matching lines...) Expand all Loading... |
39 #include "chrome/browser/net/http_server_properties_manager.h" | 40 #include "chrome/browser/net/http_server_properties_manager.h" |
40 #include "chrome/browser/net/net_pref_observer.h" | 41 #include "chrome/browser/net/net_pref_observer.h" |
41 #include "chrome/browser/net/predictor.h" | 42 #include "chrome/browser/net/predictor.h" |
42 #include "chrome/browser/net/ssl_config_service_manager.h" | 43 #include "chrome/browser/net/ssl_config_service_manager.h" |
43 #include "chrome/browser/notifications/desktop_notification_service.h" | 44 #include "chrome/browser/notifications/desktop_notification_service.h" |
44 #include "chrome/browser/notifications/notification_prefs_manager.h" | 45 #include "chrome/browser/notifications/notification_prefs_manager.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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 NO_PREFS = 0, | 142 NO_PREFS = 0, |
141 DNS_PREFS = 1 << 0, | 143 DNS_PREFS = 1 << 0, |
142 WINDOWS_PREFS = 1 << 1, | 144 WINDOWS_PREFS = 1 << 1, |
143 GOOGLE_URL_TRACKER_PREFS = 1 << 2, | 145 GOOGLE_URL_TRACKER_PREFS = 1 << 2, |
144 }; | 146 }; |
145 | 147 |
146 } // namespace | 148 } // namespace |
147 | 149 |
148 namespace chrome { | 150 namespace chrome { |
149 | 151 |
150 void RegisterLocalState(PrefServiceSimple* local_state) { | 152 // TODO(joi): Do the work needed to remove the PrefService parameter, |
| 153 // i.e. to do all registration up front before a PrefService is even |
| 154 // created. |
| 155 void RegisterLocalState(PrefRegistrySimple* registry, |
| 156 PrefService* local_state) { |
151 // Prefs in Local State. | 157 // Prefs in Local State. |
152 local_state->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0); | 158 registry->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0); |
153 | 159 |
154 // Please keep this list alphabetized. | 160 // Please keep this list alphabetized. |
155 browser_shutdown::RegisterPrefs(local_state); | 161 browser_shutdown::RegisterPrefs(registry); |
156 chrome::RegisterScreenshotPrefs(local_state); | 162 BrowserProcessImpl::RegisterPrefs(registry); |
157 extensions::app_launcher::RegisterPrefs(local_state); | 163 chrome::RegisterScreenshotPrefs(registry); |
158 ExternalProtocolHandler::RegisterPrefs(local_state); | 164 extensions::app_launcher::RegisterPrefs(registry); |
159 FlagsUI::RegisterPrefs(local_state); | 165 ExternalProtocolHandler::RegisterPrefs(registry); |
160 geolocation::RegisterPrefs(local_state); | 166 FlagsUI::RegisterPrefs(registry); |
161 IntranetRedirectDetector::RegisterPrefs(local_state); | 167 geolocation::RegisterPrefs(registry); |
162 KeywordEditorController::RegisterPrefs(local_state); | 168 IntranetRedirectDetector::RegisterPrefs(registry); |
163 MetricsLog::RegisterPrefs(local_state); | 169 KeywordEditorController::RegisterPrefs(registry); |
164 MetricsService::RegisterPrefs(local_state); | 170 MetricsLog::RegisterPrefs(registry); |
165 PrefProxyConfigTrackerImpl::RegisterPrefs(local_state); | 171 MetricsService::RegisterPrefs(registry); |
166 ProfileInfoCache::RegisterPrefs(local_state); | 172 PrefProxyConfigTrackerImpl::RegisterPrefs(registry); |
167 ProfileManager::RegisterPrefs(local_state); | 173 ProfileInfoCache::RegisterPrefs(registry); |
168 PromoResourceService::RegisterPrefs(local_state); | 174 ProfileManager::RegisterPrefs(registry); |
169 SigninManagerFactory::RegisterPrefs(local_state); | 175 PromoResourceService::RegisterPrefs(registry); |
170 SSLConfigServiceManager::RegisterPrefs(local_state); | 176 SigninManagerFactory::RegisterPrefs(registry); |
171 UpgradeDetector::RegisterPrefs(local_state); | 177 SSLConfigServiceManager::RegisterPrefs(registry); |
172 WebCacheManager::RegisterPrefs(local_state); | 178 UpgradeDetector::RegisterPrefs(registry); |
| 179 WebCacheManager::RegisterPrefs(registry); |
173 | 180 |
174 #if defined(ENABLE_PLUGINS) | 181 #if defined(ENABLE_PLUGINS) |
175 PluginFinder::RegisterPrefs(local_state); | 182 PluginFinder::RegisterPrefs(registry); |
176 #endif | 183 #endif |
177 | 184 |
178 #if defined(ENABLE_PLUGIN_INSTALLATION) | 185 #if defined(ENABLE_PLUGIN_INSTALLATION) |
179 PluginsResourceService::RegisterPrefs(local_state); | 186 PluginsResourceService::RegisterPrefs(registry); |
180 #endif | 187 #endif |
181 | 188 |
182 #if defined(ENABLE_CONFIGURATION_POLICY) | 189 #if defined(ENABLE_CONFIGURATION_POLICY) |
183 policy::BrowserPolicyConnector::RegisterPrefs(local_state); | 190 policy::BrowserPolicyConnector::RegisterPrefs(registry); |
184 policy::PolicyStatisticsCollector::RegisterPrefs(local_state); | 191 policy::PolicyStatisticsCollector::RegisterPrefs(registry); |
185 #endif | 192 #endif |
186 | 193 |
187 #if defined(ENABLE_NOTIFICATIONS) | 194 #if defined(ENABLE_NOTIFICATIONS) |
188 NotificationPrefsManager::RegisterPrefs(local_state); | 195 NotificationPrefsManager::RegisterPrefs(local_state, registry); |
189 #endif | 196 #endif |
190 | 197 |
191 #if defined(ENABLE_TASK_MANAGER) | 198 #if defined(ENABLE_TASK_MANAGER) |
192 TaskManager::RegisterPrefs(local_state); | 199 TaskManager::RegisterPrefs(registry); |
193 #endif // defined(ENABLE_TASK_MANAGER) | 200 #endif // defined(ENABLE_TASK_MANAGER) |
194 | 201 |
195 #if defined(TOOLKIT_VIEWS) | 202 #if defined(TOOLKIT_VIEWS) |
196 RegisterBrowserViewPrefs(local_state); | 203 RegisterBrowserViewPrefs(registry); |
197 RegisterTabStripLayoutTypePrefs(local_state); | 204 RegisterTabStripLayoutTypePrefs(registry); |
198 #endif | 205 #endif |
199 | 206 |
200 #if !defined(OS_ANDROID) | 207 #if !defined(OS_ANDROID) |
201 BackgroundModeManager::RegisterPrefs(local_state); | 208 BackgroundModeManager::RegisterPrefs(registry); |
202 chrome_variations::VariationsService::RegisterPrefs(local_state); | 209 chrome_variations::VariationsService::RegisterPrefs(registry); |
203 RegisterBrowserPrefs(local_state); | 210 RegisterBrowserPrefs(registry); |
204 ManagedMode::RegisterPrefs(local_state); | 211 ManagedMode::RegisterPrefs(registry); |
205 #endif | 212 #endif |
206 | 213 |
207 #if defined(OS_CHROMEOS) | 214 #if defined(OS_CHROMEOS) |
208 chromeos::AudioHandler::RegisterPrefs(local_state); | 215 chromeos::AudioHandler::RegisterPrefs(registry); |
209 chromeos::DataPromoNotification::RegisterPrefs(local_state); | 216 chromeos::DataPromoNotification::RegisterPrefs(registry); |
210 chromeos::device_settings_cache::RegisterPrefs(local_state); | 217 chromeos::device_settings_cache::RegisterPrefs(registry); |
211 chromeos::language_prefs::RegisterPrefs(local_state); | 218 chromeos::language_prefs::RegisterPrefs(registry); |
212 chromeos::ProxyConfigServiceImpl::RegisterPrefs(local_state); | 219 chromeos::ProxyConfigServiceImpl::RegisterPrefs(registry); |
213 chromeos::RegisterDisplayLocalStatePrefs(local_state); | 220 chromeos::RegisterDisplayLocalStatePrefs(registry); |
214 chromeos::ServicesCustomizationDocument::RegisterPrefs(local_state); | 221 chromeos::ServicesCustomizationDocument::RegisterPrefs(registry); |
215 chromeos::UserImageManager::RegisterPrefs(local_state); | 222 chromeos::UserImageManager::RegisterPrefs(registry); |
216 chromeos::UserManager::RegisterPrefs(local_state); | 223 chromeos::UserManager::RegisterPrefs(registry); |
217 chromeos::WallpaperManager::RegisterPrefs(local_state); | 224 chromeos::WallpaperManager::RegisterPrefs(registry); |
218 chromeos::WizardController::RegisterPrefs(local_state); | 225 chromeos::WizardController::RegisterPrefs(registry); |
219 policy::AutoEnrollmentClient::RegisterPrefs(local_state); | 226 policy::AutoEnrollmentClient::RegisterPrefs(registry); |
220 policy::DeviceStatusCollector::RegisterPrefs(local_state); | 227 policy::DeviceStatusCollector::RegisterPrefs(registry); |
221 #endif | 228 #endif |
222 | 229 |
223 #if defined(OS_MACOSX) | 230 #if defined(OS_MACOSX) |
224 confirm_quit::RegisterLocalState(local_state); | 231 confirm_quit::RegisterLocalState(registry); |
225 #endif | 232 #endif |
226 | 233 |
227 #if defined(ENABLE_SETTINGS_APP) | 234 #if defined(ENABLE_SETTINGS_APP) |
228 chrome::RegisterAppListPrefs(local_state); | 235 chrome::RegisterAppListPrefs(registry); |
229 #endif | 236 #endif |
230 } | 237 } |
231 | 238 |
232 void RegisterUserPrefs(PrefServiceSyncable* user_prefs) { | 239 void RegisterUserPrefs(PrefServiceSyncable* user_prefs) { |
233 // User prefs. Please keep this list alphabetized. | 240 // User prefs. Please keep this list alphabetized. |
234 AlternateErrorPageTabObserver::RegisterUserPrefs(user_prefs); | 241 AlternateErrorPageTabObserver::RegisterUserPrefs(user_prefs); |
235 AutofillManager::RegisterUserPrefs(user_prefs); | 242 AutofillManager::RegisterUserPrefs(user_prefs); |
236 BookmarkPromptPrefs::RegisterUserPrefs(user_prefs); | 243 BookmarkPromptPrefs::RegisterUserPrefs(user_prefs); |
237 bookmark_utils::RegisterUserPrefs(user_prefs); | 244 bookmark_utils::RegisterUserPrefs(user_prefs); |
238 BrowserInstantController::RegisterUserPrefs(user_prefs); | 245 BrowserInstantController::RegisterUserPrefs(user_prefs); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 void MigrateUserPrefs(Profile* profile) { | 329 void MigrateUserPrefs(Profile* profile) { |
323 // Cleanup old prefs. | 330 // Cleanup old prefs. |
324 static const char kBackupPref[] = "backup"; | 331 static const char kBackupPref[] = "backup"; |
325 PrefServiceSyncable* prefs = profile->GetPrefs(); | 332 PrefServiceSyncable* prefs = profile->GetPrefs(); |
326 prefs->RegisterDictionaryPref(kBackupPref, new DictionaryValue(), | 333 prefs->RegisterDictionaryPref(kBackupPref, new DictionaryValue(), |
327 PrefServiceSyncable::UNSYNCABLE_PREF); | 334 PrefServiceSyncable::UNSYNCABLE_PREF); |
328 prefs->ClearPref(kBackupPref); | 335 prefs->ClearPref(kBackupPref); |
329 prefs->UnregisterPreference(kBackupPref); | 336 prefs->UnregisterPreference(kBackupPref); |
330 } | 337 } |
331 | 338 |
332 void MigrateBrowserPrefs(Profile* profile, PrefServiceSimple* local_state) { | 339 void MigrateBrowserPrefs(Profile* profile, PrefService* local_state) { |
333 // Copy pref values which have been migrated to user_prefs from local_state, | 340 // Copy pref values which have been migrated to user_prefs from local_state, |
334 // or remove them from local_state outright, if copying is not required. | 341 // or remove them from local_state outright, if copying is not required. |
335 int current_version = | 342 int current_version = |
336 local_state->GetInteger(prefs::kMultipleProfilePrefMigration); | 343 local_state->GetInteger(prefs::kMultipleProfilePrefMigration); |
| 344 PrefRegistrySimple* registry = static_cast<PrefRegistrySimple*>( |
| 345 local_state->DeprecatedGetPrefRegistry()); |
337 | 346 |
338 if (!(current_version & DNS_PREFS)) { | 347 if (!(current_version & DNS_PREFS)) { |
339 local_state->RegisterListPref(prefs::kDnsStartupPrefetchList); | 348 registry->RegisterListPref(prefs::kDnsStartupPrefetchList); |
340 local_state->ClearPref(prefs::kDnsStartupPrefetchList); | 349 local_state->ClearPref(prefs::kDnsStartupPrefetchList); |
341 | 350 |
342 local_state->RegisterListPref(prefs::kDnsHostReferralList); | 351 registry->RegisterListPref(prefs::kDnsHostReferralList); |
343 local_state->ClearPref(prefs::kDnsHostReferralList); | 352 local_state->ClearPref(prefs::kDnsHostReferralList); |
344 | 353 |
345 current_version |= DNS_PREFS; | 354 current_version |= DNS_PREFS; |
346 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, | 355 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, |
347 current_version); | 356 current_version); |
348 } | 357 } |
349 | 358 |
350 PrefServiceSyncable* user_prefs = profile->GetPrefs(); | 359 PrefServiceSyncable* user_prefs = profile->GetPrefs(); |
351 if (!(current_version & WINDOWS_PREFS)) { | 360 if (!(current_version & WINDOWS_PREFS)) { |
352 local_state->RegisterIntegerPref(prefs::kDevToolsHSplitLocation, -1); | 361 registry->RegisterIntegerPref(prefs::kDevToolsHSplitLocation, -1); |
353 if (local_state->HasPrefPath(prefs::kDevToolsHSplitLocation)) { | 362 if (local_state->HasPrefPath(prefs::kDevToolsHSplitLocation)) { |
354 user_prefs->SetInteger( | 363 user_prefs->SetInteger( |
355 prefs::kDevToolsHSplitLocation, | 364 prefs::kDevToolsHSplitLocation, |
356 local_state->GetInteger(prefs::kDevToolsHSplitLocation)); | 365 local_state->GetInteger(prefs::kDevToolsHSplitLocation)); |
357 } | 366 } |
358 local_state->ClearPref(prefs::kDevToolsHSplitLocation); | 367 local_state->ClearPref(prefs::kDevToolsHSplitLocation); |
359 | 368 |
360 local_state->RegisterDictionaryPref(prefs::kBrowserWindowPlacement); | 369 registry->RegisterDictionaryPref(prefs::kBrowserWindowPlacement); |
361 if (local_state->HasPrefPath(prefs::kBrowserWindowPlacement)) { | 370 if (local_state->HasPrefPath(prefs::kBrowserWindowPlacement)) { |
362 const PrefService::Preference* pref = | 371 const PrefService::Preference* pref = |
363 local_state->FindPreference(prefs::kBrowserWindowPlacement); | 372 local_state->FindPreference(prefs::kBrowserWindowPlacement); |
364 DCHECK(pref); | 373 DCHECK(pref); |
365 user_prefs->Set(prefs::kBrowserWindowPlacement, | 374 user_prefs->Set(prefs::kBrowserWindowPlacement, |
366 *(pref->GetValue())); | 375 *(pref->GetValue())); |
367 } | 376 } |
368 local_state->ClearPref(prefs::kBrowserWindowPlacement); | 377 local_state->ClearPref(prefs::kBrowserWindowPlacement); |
369 | 378 |
370 current_version |= WINDOWS_PREFS; | 379 current_version |= WINDOWS_PREFS; |
371 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, | 380 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, |
372 current_version); | 381 current_version); |
373 } | 382 } |
374 | 383 |
375 if (!(current_version & GOOGLE_URL_TRACKER_PREFS)) { | 384 if (!(current_version & GOOGLE_URL_TRACKER_PREFS)) { |
376 GoogleURLTrackerFactory::GetInstance()->RegisterUserPrefsOnProfile(profile); | 385 GoogleURLTrackerFactory::GetInstance()->RegisterUserPrefsOnProfile(profile); |
377 local_state->RegisterStringPref(prefs::kLastKnownGoogleURL, | 386 registry->RegisterStringPref(prefs::kLastKnownGoogleURL, |
378 GoogleURLTracker::kDefaultGoogleHomepage); | 387 GoogleURLTracker::kDefaultGoogleHomepage); |
379 if (local_state->HasPrefPath(prefs::kLastKnownGoogleURL)) { | 388 if (local_state->HasPrefPath(prefs::kLastKnownGoogleURL)) { |
380 user_prefs->SetString(prefs::kLastKnownGoogleURL, | 389 user_prefs->SetString(prefs::kLastKnownGoogleURL, |
381 local_state->GetString(prefs::kLastKnownGoogleURL)); | 390 local_state->GetString(prefs::kLastKnownGoogleURL)); |
382 } | 391 } |
383 local_state->ClearPref(prefs::kLastKnownGoogleURL); | 392 local_state->ClearPref(prefs::kLastKnownGoogleURL); |
384 | 393 |
385 local_state->RegisterStringPref(prefs::kLastPromptedGoogleURL, | 394 registry->RegisterStringPref(prefs::kLastPromptedGoogleURL, |
386 std::string()); | 395 std::string()); |
387 if (local_state->HasPrefPath(prefs::kLastPromptedGoogleURL)) { | 396 if (local_state->HasPrefPath(prefs::kLastPromptedGoogleURL)) { |
388 user_prefs->SetString( | 397 user_prefs->SetString( |
389 prefs::kLastPromptedGoogleURL, | 398 prefs::kLastPromptedGoogleURL, |
390 local_state->GetString(prefs::kLastPromptedGoogleURL)); | 399 local_state->GetString(prefs::kLastPromptedGoogleURL)); |
391 } | 400 } |
392 local_state->ClearPref(prefs::kLastPromptedGoogleURL); | 401 local_state->ClearPref(prefs::kLastPromptedGoogleURL); |
393 | 402 |
394 current_version |= GOOGLE_URL_TRACKER_PREFS; | 403 current_version |= GOOGLE_URL_TRACKER_PREFS; |
395 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, | 404 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, |
396 current_version); | 405 current_version); |
397 } | 406 } |
398 } | 407 } |
399 | 408 |
400 } // namespace chrome | 409 } // namespace chrome |
OLD | NEW |