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" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 NO_PREFS = 0, | 137 NO_PREFS = 0, |
138 DNS_PREFS = 1 << 0, | 138 DNS_PREFS = 1 << 0, |
139 WINDOWS_PREFS = 1 << 1, | 139 WINDOWS_PREFS = 1 << 1, |
140 GOOGLE_URL_TRACKER_PREFS = 1 << 2, | 140 GOOGLE_URL_TRACKER_PREFS = 1 << 2, |
141 }; | 141 }; |
142 | 142 |
143 } // namespace | 143 } // namespace |
144 | 144 |
145 namespace chrome { | 145 namespace chrome { |
146 | 146 |
147 void RegisterLocalState(PrefService* local_state) { | 147 void RegisterLocalState(PrefServiceSimple* local_state) { |
148 // Prefs in Local State. | 148 // Prefs in Local State. |
149 local_state->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0); | 149 local_state->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0); |
150 | 150 |
151 // Please keep this list alphabetized. | 151 // Please keep this list alphabetized. |
152 browser_shutdown::RegisterPrefs(local_state); | 152 browser_shutdown::RegisterPrefs(local_state); |
153 chrome::RegisterScreenshotPrefs(local_state); | 153 chrome::RegisterScreenshotPrefs(local_state); |
154 ExternalProtocolHandler::RegisterPrefs(local_state); | 154 ExternalProtocolHandler::RegisterPrefs(local_state); |
155 geolocation::RegisterPrefs(local_state); | 155 geolocation::RegisterPrefs(local_state); |
156 IntranetRedirectDetector::RegisterPrefs(local_state); | 156 IntranetRedirectDetector::RegisterPrefs(local_state); |
157 KeywordEditorController::RegisterPrefs(local_state); | 157 KeywordEditorController::RegisterPrefs(local_state); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 chromeos::WizardController::RegisterPrefs(local_state); | 211 chromeos::WizardController::RegisterPrefs(local_state); |
212 policy::AutoEnrollmentClient::RegisterPrefs(local_state); | 212 policy::AutoEnrollmentClient::RegisterPrefs(local_state); |
213 policy::DeviceStatusCollector::RegisterPrefs(local_state); | 213 policy::DeviceStatusCollector::RegisterPrefs(local_state); |
214 #endif | 214 #endif |
215 | 215 |
216 #if defined(OS_MACOSX) | 216 #if defined(OS_MACOSX) |
217 confirm_quit::RegisterLocalState(local_state); | 217 confirm_quit::RegisterLocalState(local_state); |
218 #endif | 218 #endif |
219 } | 219 } |
220 | 220 |
221 void RegisterUserPrefs(PrefService* user_prefs) { | 221 void RegisterUserPrefs(PrefServiceSyncable* user_prefs) { |
222 // User prefs. Please keep this list alphabetized. | 222 // User prefs. Please keep this list alphabetized. |
223 AlternateErrorPageTabObserver::RegisterUserPrefs(user_prefs); | 223 AlternateErrorPageTabObserver::RegisterUserPrefs(user_prefs); |
224 AutofillManager::RegisterUserPrefs(user_prefs); | 224 AutofillManager::RegisterUserPrefs(user_prefs); |
225 BookmarkPromptPrefs::RegisterUserPrefs(user_prefs); | 225 BookmarkPromptPrefs::RegisterUserPrefs(user_prefs); |
226 bookmark_utils::RegisterUserPrefs(user_prefs); | 226 bookmark_utils::RegisterUserPrefs(user_prefs); |
227 BrowserInstantController::RegisterUserPrefs(user_prefs); | 227 BrowserInstantController::RegisterUserPrefs(user_prefs); |
228 ChromeContentBrowserClient::RegisterUserPrefs(user_prefs); | 228 ChromeContentBrowserClient::RegisterUserPrefs(user_prefs); |
229 ChromeVersionService::RegisterUserPrefs(user_prefs); | 229 ChromeVersionService::RegisterUserPrefs(user_prefs); |
230 chrome_browser_net::HttpServerPropertiesManager::RegisterPrefs(user_prefs); | 230 chrome_browser_net::HttpServerPropertiesManager::RegisterUserPrefs( |
| 231 user_prefs); |
231 chrome_browser_net::Predictor::RegisterUserPrefs(user_prefs); | 232 chrome_browser_net::Predictor::RegisterUserPrefs(user_prefs); |
232 DownloadPrefs::RegisterUserPrefs(user_prefs); | 233 DownloadPrefs::RegisterUserPrefs(user_prefs); |
233 extensions::ComponentLoader::RegisterUserPrefs(user_prefs); | 234 extensions::ComponentLoader::RegisterUserPrefs(user_prefs); |
234 extensions::ExtensionPrefs::RegisterUserPrefs(user_prefs); | 235 extensions::ExtensionPrefs::RegisterUserPrefs(user_prefs); |
235 ExtensionWebUI::RegisterUserPrefs(user_prefs); | 236 ExtensionWebUI::RegisterUserPrefs(user_prefs); |
236 first_run::RegisterUserPrefs(user_prefs); | 237 first_run::RegisterUserPrefs(user_prefs); |
237 GAIAInfoUpdateService::RegisterUserPrefs(user_prefs); | 238 GAIAInfoUpdateService::RegisterUserPrefs(user_prefs); |
238 HostContentSettingsMap::RegisterUserPrefs(user_prefs); | 239 HostContentSettingsMap::RegisterUserPrefs(user_prefs); |
239 IncognitoModePrefs::RegisterUserPrefs(user_prefs); | 240 IncognitoModePrefs::RegisterUserPrefs(user_prefs); |
240 InstantUI::RegisterUserPrefs(user_prefs); | 241 InstantUI::RegisterUserPrefs(user_prefs); |
241 MediaCaptureDevicesDispatcher::RegisterUserPrefs(user_prefs); | 242 MediaCaptureDevicesDispatcher::RegisterUserPrefs(user_prefs); |
242 MediaStreamDevicesController::RegisterUserPrefs(user_prefs); | 243 MediaStreamDevicesController::RegisterUserPrefs(user_prefs); |
243 NetPrefObserver::RegisterPrefs(user_prefs); | 244 NetPrefObserver::RegisterUserPrefs(user_prefs); |
244 NewTabUI::RegisterUserPrefs(user_prefs); | 245 NewTabUI::RegisterUserPrefs(user_prefs); |
245 PasswordManager::RegisterUserPrefs(user_prefs); | 246 PasswordManager::RegisterUserPrefs(user_prefs); |
246 PrefProxyConfigTrackerImpl::RegisterPrefs(user_prefs); | 247 PrefProxyConfigTrackerImpl::RegisterUserPrefs(user_prefs); |
247 PrefsTabHelper::RegisterUserPrefs(user_prefs); | 248 PrefsTabHelper::RegisterUserPrefs(user_prefs); |
248 ProfileImpl::RegisterUserPrefs(user_prefs); | 249 ProfileImpl::RegisterUserPrefs(user_prefs); |
249 PromoResourceService::RegisterUserPrefs(user_prefs); | 250 PromoResourceService::RegisterUserPrefs(user_prefs); |
250 ProtocolHandlerRegistry::RegisterPrefs(user_prefs); | 251 ProtocolHandlerRegistry::RegisterUserPrefs(user_prefs); |
251 RegisterBrowserUserPrefs(user_prefs); | 252 RegisterBrowserUserPrefs(user_prefs); |
252 SessionStartupPref::RegisterUserPrefs(user_prefs); | 253 SessionStartupPref::RegisterUserPrefs(user_prefs); |
253 TemplateURLPrepopulateData::RegisterUserPrefs(user_prefs); | 254 TemplateURLPrepopulateData::RegisterUserPrefs(user_prefs); |
254 TranslatePrefs::RegisterUserPrefs(user_prefs); | 255 TranslatePrefs::RegisterUserPrefs(user_prefs); |
255 | 256 |
256 #if defined(ENABLE_CONFIGURATION_POLICY) | 257 #if defined(ENABLE_CONFIGURATION_POLICY) |
257 policy::URLBlacklistManager::RegisterPrefs(user_prefs); | 258 policy::URLBlacklistManager::RegisterUserPrefs(user_prefs); |
258 #endif | 259 #endif |
259 | 260 |
260 #if defined(ENABLE_WEB_INTENTS) | 261 #if defined(ENABLE_WEB_INTENTS) |
261 web_intents::RegisterUserPrefs(user_prefs); | 262 web_intents::RegisterUserPrefs(user_prefs); |
262 #endif | 263 #endif |
263 | 264 |
264 #if defined(TOOLKIT_VIEWS) | 265 #if defined(TOOLKIT_VIEWS) |
265 RegisterInvertBubbleUserPrefs(user_prefs); | 266 RegisterInvertBubbleUserPrefs(user_prefs); |
266 #elif defined(TOOLKIT_GTK) | 267 #elif defined(TOOLKIT_GTK) |
267 BrowserWindowGtk::RegisterUserPrefs(user_prefs); | 268 BrowserWindowGtk::RegisterUserPrefs(user_prefs); |
(...skipping 12 matching lines...) Expand all Loading... |
280 CaptureVisibleTabFunction::RegisterUserPrefs(user_prefs); | 281 CaptureVisibleTabFunction::RegisterUserPrefs(user_prefs); |
281 ChromeToMobileService::RegisterUserPrefs(user_prefs); | 282 ChromeToMobileService::RegisterUserPrefs(user_prefs); |
282 DevToolsWindow::RegisterUserPrefs(user_prefs); | 283 DevToolsWindow::RegisterUserPrefs(user_prefs); |
283 extensions::CommandService::RegisterUserPrefs(user_prefs); | 284 extensions::CommandService::RegisterUserPrefs(user_prefs); |
284 ExtensionSettingsHandler::RegisterUserPrefs(user_prefs); | 285 ExtensionSettingsHandler::RegisterUserPrefs(user_prefs); |
285 ManagedMode::RegisterUserPrefs(user_prefs); | 286 ManagedMode::RegisterUserPrefs(user_prefs); |
286 PepperFlashSettingsManager::RegisterUserPrefs(user_prefs); | 287 PepperFlashSettingsManager::RegisterUserPrefs(user_prefs); |
287 PinnedTabCodec::RegisterUserPrefs(user_prefs); | 288 PinnedTabCodec::RegisterUserPrefs(user_prefs); |
288 PluginsUI::RegisterUserPrefs(user_prefs); | 289 PluginsUI::RegisterUserPrefs(user_prefs); |
289 printing::StickySettings::RegisterUserPrefs(user_prefs); | 290 printing::StickySettings::RegisterUserPrefs(user_prefs); |
290 RegisterAutolaunchPrefs(user_prefs); | 291 RegisterAutolaunchUserPrefs(user_prefs); |
291 SyncPromoUI::RegisterUserPrefs(user_prefs); | 292 SyncPromoUI::RegisterUserPrefs(user_prefs); |
292 #endif | 293 #endif |
293 | 294 |
294 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) | 295 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) |
295 default_apps::RegisterUserPrefs(user_prefs); | 296 default_apps::RegisterUserPrefs(user_prefs); |
296 #endif | 297 #endif |
297 | 298 |
298 #if defined(OS_CHROMEOS) | 299 #if defined(OS_CHROMEOS) |
299 chromeos::Preferences::RegisterUserPrefs(user_prefs); | 300 chromeos::Preferences::RegisterUserPrefs(user_prefs); |
300 chromeos::ProxyConfigServiceImpl::RegisterPrefs(user_prefs); | 301 chromeos::ProxyConfigServiceImpl::RegisterUserPrefs(user_prefs); |
301 #endif | 302 #endif |
302 | 303 |
303 #if defined(OS_WIN) | 304 #if defined(OS_WIN) |
304 NetworkProfileBubble::RegisterPrefs(user_prefs); | 305 NetworkProfileBubble::RegisterUserPrefs(user_prefs); |
305 #endif | 306 #endif |
306 } | 307 } |
307 | 308 |
308 void MigrateUserPrefs(Profile* profile) { | 309 void MigrateUserPrefs(Profile* profile) { |
309 // Cleanup old prefs. | 310 // Cleanup old prefs. |
310 static const char kBackupPref[] = "backup"; | 311 static const char kBackupPref[] = "backup"; |
311 PrefService* prefs = profile->GetPrefs(); | 312 PrefServiceSyncable* prefs = profile->GetPrefs(); |
312 prefs->RegisterDictionaryPref(kBackupPref, new DictionaryValue(), | 313 prefs->RegisterDictionaryPref(kBackupPref, new DictionaryValue(), |
313 PrefService::UNSYNCABLE_PREF); | 314 PrefServiceSyncable::UNSYNCABLE_PREF); |
314 prefs->ClearPref(kBackupPref); | 315 prefs->ClearPref(kBackupPref); |
315 prefs->UnregisterPreference(kBackupPref); | 316 prefs->UnregisterPreference(kBackupPref); |
316 } | 317 } |
317 | 318 |
318 void MigrateBrowserPrefs(Profile* profile, PrefService* local_state) { | 319 void MigrateBrowserPrefs(Profile* profile, PrefServiceSimple* local_state) { |
319 // Copy pref values which have been migrated to user_prefs from local_state, | 320 // Copy pref values which have been migrated to user_prefs from local_state, |
320 // or remove them from local_state outright, if copying is not required. | 321 // or remove them from local_state outright, if copying is not required. |
321 int current_version = | 322 int current_version = |
322 local_state->GetInteger(prefs::kMultipleProfilePrefMigration); | 323 local_state->GetInteger(prefs::kMultipleProfilePrefMigration); |
323 | 324 |
324 if (!(current_version & DNS_PREFS)) { | 325 if (!(current_version & DNS_PREFS)) { |
325 local_state->RegisterListPref(prefs::kDnsStartupPrefetchList, | 326 local_state->RegisterListPref(prefs::kDnsStartupPrefetchList); |
326 PrefService::UNSYNCABLE_PREF); | |
327 local_state->ClearPref(prefs::kDnsStartupPrefetchList); | 327 local_state->ClearPref(prefs::kDnsStartupPrefetchList); |
328 | 328 |
329 local_state->RegisterListPref(prefs::kDnsHostReferralList, | 329 local_state->RegisterListPref(prefs::kDnsHostReferralList); |
330 PrefService::UNSYNCABLE_PREF); | |
331 local_state->ClearPref(prefs::kDnsHostReferralList); | 330 local_state->ClearPref(prefs::kDnsHostReferralList); |
332 | 331 |
333 current_version |= DNS_PREFS; | 332 current_version |= DNS_PREFS; |
334 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, | 333 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, |
335 current_version); | 334 current_version); |
336 } | 335 } |
337 | 336 |
338 PrefService* user_prefs = profile->GetPrefs(); | 337 PrefServiceSyncable* user_prefs = profile->GetPrefs(); |
339 if (!(current_version & WINDOWS_PREFS)) { | 338 if (!(current_version & WINDOWS_PREFS)) { |
340 local_state->RegisterIntegerPref(prefs::kDevToolsHSplitLocation, -1); | 339 local_state->RegisterIntegerPref(prefs::kDevToolsHSplitLocation, -1); |
341 if (local_state->HasPrefPath(prefs::kDevToolsHSplitLocation)) { | 340 if (local_state->HasPrefPath(prefs::kDevToolsHSplitLocation)) { |
342 user_prefs->SetInteger(prefs::kDevToolsHSplitLocation, | 341 user_prefs->SetInteger( |
| 342 prefs::kDevToolsHSplitLocation, |
343 local_state->GetInteger(prefs::kDevToolsHSplitLocation)); | 343 local_state->GetInteger(prefs::kDevToolsHSplitLocation)); |
344 } | 344 } |
345 local_state->ClearPref(prefs::kDevToolsHSplitLocation); | 345 local_state->ClearPref(prefs::kDevToolsHSplitLocation); |
346 | 346 |
347 local_state->RegisterDictionaryPref(prefs::kBrowserWindowPlacement); | 347 local_state->RegisterDictionaryPref(prefs::kBrowserWindowPlacement); |
348 if (local_state->HasPrefPath(prefs::kBrowserWindowPlacement)) { | 348 if (local_state->HasPrefPath(prefs::kBrowserWindowPlacement)) { |
349 const PrefService::Preference* pref = | 349 const PrefService::Preference* pref = |
350 local_state->FindPreference(prefs::kBrowserWindowPlacement); | 350 local_state->FindPreference(prefs::kBrowserWindowPlacement); |
351 DCHECK(pref); | 351 DCHECK(pref); |
352 user_prefs->Set(prefs::kBrowserWindowPlacement, *(pref->GetValue())); | 352 user_prefs->Set(prefs::kBrowserWindowPlacement, |
| 353 *(pref->GetValue())); |
353 } | 354 } |
354 local_state->ClearPref(prefs::kBrowserWindowPlacement); | 355 local_state->ClearPref(prefs::kBrowserWindowPlacement); |
355 | 356 |
356 current_version |= WINDOWS_PREFS; | 357 current_version |= WINDOWS_PREFS; |
357 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, | 358 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, |
358 current_version); | 359 current_version); |
359 } | 360 } |
360 | 361 |
361 if (!(current_version & GOOGLE_URL_TRACKER_PREFS)) { | 362 if (!(current_version & GOOGLE_URL_TRACKER_PREFS)) { |
362 GoogleURLTrackerFactory::GetInstance()->RegisterUserPrefsOnProfile(profile); | 363 GoogleURLTrackerFactory::GetInstance()->RegisterUserPrefsOnProfile(profile); |
363 local_state->RegisterStringPref(prefs::kLastKnownGoogleURL, | 364 local_state->RegisterStringPref(prefs::kLastKnownGoogleURL, |
364 GoogleURLTracker::kDefaultGoogleHomepage); | 365 GoogleURLTracker::kDefaultGoogleHomepage); |
365 if (local_state->HasPrefPath(prefs::kLastKnownGoogleURL)) { | 366 if (local_state->HasPrefPath(prefs::kLastKnownGoogleURL)) { |
366 user_prefs->SetString(prefs::kLastKnownGoogleURL, | 367 user_prefs->SetString(prefs::kLastKnownGoogleURL, |
367 local_state->GetString(prefs::kLastKnownGoogleURL)); | 368 local_state->GetString(prefs::kLastKnownGoogleURL)); |
368 } | 369 } |
369 local_state->ClearPref(prefs::kLastKnownGoogleURL); | 370 local_state->ClearPref(prefs::kLastKnownGoogleURL); |
370 | 371 |
371 local_state->RegisterStringPref(prefs::kLastPromptedGoogleURL, | 372 local_state->RegisterStringPref(prefs::kLastPromptedGoogleURL, |
372 std::string()); | 373 std::string()); |
373 if (local_state->HasPrefPath(prefs::kLastPromptedGoogleURL)) { | 374 if (local_state->HasPrefPath(prefs::kLastPromptedGoogleURL)) { |
374 user_prefs->SetString(prefs::kLastPromptedGoogleURL, | 375 user_prefs->SetString( |
| 376 prefs::kLastPromptedGoogleURL, |
375 local_state->GetString(prefs::kLastPromptedGoogleURL)); | 377 local_state->GetString(prefs::kLastPromptedGoogleURL)); |
376 } | 378 } |
377 local_state->ClearPref(prefs::kLastPromptedGoogleURL); | 379 local_state->ClearPref(prefs::kLastPromptedGoogleURL); |
378 | 380 |
379 current_version |= GOOGLE_URL_TRACKER_PREFS; | 381 current_version |= GOOGLE_URL_TRACKER_PREFS; |
380 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, | 382 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, |
381 current_version); | 383 current_version); |
382 } | 384 } |
383 } | 385 } |
384 | 386 |
385 } // namespace chrome | 387 } // namespace chrome |
OLD | NEW |