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::RegisterPrefs(user_prefs); |
231 chrome_browser_net::Predictor::RegisterUserPrefs(user_prefs); | 231 chrome_browser_net::Predictor::RegisterUserPrefs(user_prefs); |
232 DownloadPrefs::RegisterUserPrefs(user_prefs); | 232 DownloadPrefs::RegisterUserPrefs(user_prefs); |
233 extensions::ComponentLoader::RegisterUserPrefs(user_prefs); | 233 extensions::ComponentLoader::RegisterUserPrefs(user_prefs); |
234 extensions::ExtensionPrefs::RegisterUserPrefs(user_prefs); | 234 extensions::ExtensionPrefs::RegisterUserPrefs(user_prefs); |
235 ExtensionWebUI::RegisterUserPrefs(user_prefs); | 235 ExtensionWebUI::RegisterUserPrefs(user_prefs); |
236 first_run::RegisterUserPrefs(user_prefs); | 236 first_run::RegisterUserPrefs(user_prefs); |
237 GAIAInfoUpdateService::RegisterUserPrefs(user_prefs); | 237 GAIAInfoUpdateService::RegisterUserPrefs(user_prefs); |
238 HostContentSettingsMap::RegisterUserPrefs(user_prefs); | 238 HostContentSettingsMap::RegisterUserPrefs(user_prefs); |
239 IncognitoModePrefs::RegisterUserPrefs(user_prefs); | 239 IncognitoModePrefs::RegisterUserPrefs(user_prefs); |
240 InstantUI::RegisterUserPrefs(user_prefs); | 240 InstantUI::RegisterUserPrefs(user_prefs); |
241 MediaCaptureDevicesDispatcher::RegisterUserPrefs(user_prefs); | 241 MediaCaptureDevicesDispatcher::RegisterUserPrefs(user_prefs); |
242 MediaStreamDevicesController::RegisterUserPrefs(user_prefs); | 242 MediaStreamDevicesController::RegisterUserPrefs(user_prefs); |
243 NetPrefObserver::RegisterPrefs(user_prefs); | 243 NetPrefObserver::RegisterPrefs(user_prefs); |
244 NewTabUI::RegisterUserPrefs(user_prefs); | 244 NewTabUI::RegisterUserPrefs(user_prefs); |
245 PasswordManager::RegisterUserPrefs(user_prefs); | 245 PasswordManager::RegisterUserPrefs(user_prefs); |
246 PrefProxyConfigTrackerImpl::RegisterPrefs(user_prefs); | 246 PrefProxyConfigTrackerImpl::RegisterUserPrefs(user_prefs); |
247 PrefsTabHelper::RegisterUserPrefs(user_prefs); | 247 PrefsTabHelper::RegisterUserPrefs(user_prefs); |
248 ProfileImpl::RegisterUserPrefs(user_prefs); | 248 ProfileImpl::RegisterUserPrefs(user_prefs); |
249 PromoResourceService::RegisterUserPrefs(user_prefs); | 249 PromoResourceService::RegisterUserPrefs(user_prefs); |
250 ProtocolHandlerRegistry::RegisterPrefs(user_prefs); | 250 ProtocolHandlerRegistry::RegisterUserPrefs(user_prefs); |
Mattias Nissler (ping if slow)
2012/12/19 19:50:22
I don't see why you renamed this.
Jói
2012/12/20 16:30:31
Because the convention is that RegisterPrefs takes
Mattias Nissler (ping if slow)
2012/12/21 13:09:31
I see, makes sense. Then please also change lines
Jói
2012/12/21 14:34:13
Done. chrome::RegisterAutolaunchPrefs -> chrome::R
| |
251 RegisterBrowserUserPrefs(user_prefs); | 251 RegisterBrowserUserPrefs(user_prefs); |
252 SessionStartupPref::RegisterUserPrefs(user_prefs); | 252 SessionStartupPref::RegisterUserPrefs(user_prefs); |
253 TemplateURLPrepopulateData::RegisterUserPrefs(user_prefs); | 253 TemplateURLPrepopulateData::RegisterUserPrefs(user_prefs); |
254 TranslatePrefs::RegisterUserPrefs(user_prefs); | 254 TranslatePrefs::RegisterUserPrefs(user_prefs); |
255 | 255 |
256 #if defined(ENABLE_CONFIGURATION_POLICY) | 256 #if defined(ENABLE_CONFIGURATION_POLICY) |
257 policy::URLBlacklistManager::RegisterPrefs(user_prefs); | 257 policy::URLBlacklistManager::RegisterPrefs(user_prefs); |
258 #endif | 258 #endif |
259 | 259 |
260 #if defined(ENABLE_WEB_INTENTS) | 260 #if defined(ENABLE_WEB_INTENTS) |
(...skipping 29 matching lines...) Expand all Loading... | |
290 RegisterAutolaunchPrefs(user_prefs); | 290 RegisterAutolaunchPrefs(user_prefs); |
291 SyncPromoUI::RegisterUserPrefs(user_prefs); | 291 SyncPromoUI::RegisterUserPrefs(user_prefs); |
292 #endif | 292 #endif |
293 | 293 |
294 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) | 294 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) |
295 default_apps::RegisterUserPrefs(user_prefs); | 295 default_apps::RegisterUserPrefs(user_prefs); |
296 #endif | 296 #endif |
297 | 297 |
298 #if defined(OS_CHROMEOS) | 298 #if defined(OS_CHROMEOS) |
299 chromeos::Preferences::RegisterUserPrefs(user_prefs); | 299 chromeos::Preferences::RegisterUserPrefs(user_prefs); |
300 chromeos::ProxyConfigServiceImpl::RegisterPrefs(user_prefs); | 300 chromeos::ProxyConfigServiceImpl::RegisterUserPrefs(user_prefs); |
301 #endif | 301 #endif |
302 | 302 |
303 #if defined(OS_WIN) | 303 #if defined(OS_WIN) |
304 NetworkProfileBubble::RegisterPrefs(user_prefs); | 304 NetworkProfileBubble::RegisterUserPrefs(user_prefs); |
Mattias Nissler (ping if slow)
2012/12/19 19:50:22
why rename?
Jói
2012/12/20 16:30:31
As above.
| |
305 #endif | 305 #endif |
306 } | 306 } |
307 | 307 |
308 void MigrateUserPrefs(Profile* profile) { | 308 void MigrateUserPrefs(Profile* profile) { |
309 // Cleanup old prefs. | 309 // Cleanup old prefs. |
310 static const char kBackupPref[] = "backup"; | 310 static const char kBackupPref[] = "backup"; |
311 PrefService* prefs = profile->GetPrefs(); | 311 PrefServiceSyncable* prefs = profile->GetPrefs(); |
312 prefs->RegisterDictionaryPref(kBackupPref, new DictionaryValue(), | 312 prefs->RegisterDictionaryPref(kBackupPref, new DictionaryValue(), |
313 PrefService::UNSYNCABLE_PREF); | 313 PrefServiceSyncable::UNSYNCABLE_PREF); |
314 prefs->ClearPref(kBackupPref); | 314 prefs->ClearPref(kBackupPref); |
315 prefs->UnregisterPreference(kBackupPref); | 315 prefs->UnregisterPreference(kBackupPref); |
316 } | 316 } |
317 | 317 |
318 void MigrateBrowserPrefs(Profile* profile, PrefService* local_state) { | 318 void MigrateBrowserPrefs(Profile* profile, PrefServiceSimple* local_state) { |
319 // Copy pref values which have been migrated to user_prefs from local_state, | 319 // 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. | 320 // or remove them from local_state outright, if copying is not required. |
321 int current_version = | 321 int current_version = |
322 local_state->GetInteger(prefs::kMultipleProfilePrefMigration); | 322 local_state->GetInteger(prefs::kMultipleProfilePrefMigration); |
323 | 323 |
324 if (!(current_version & DNS_PREFS)) { | 324 if (!(current_version & DNS_PREFS)) { |
325 local_state->RegisterListPref(prefs::kDnsStartupPrefetchList, | 325 local_state->RegisterListPref(prefs::kDnsStartupPrefetchList); |
326 PrefService::UNSYNCABLE_PREF); | |
327 local_state->ClearPref(prefs::kDnsStartupPrefetchList); | 326 local_state->ClearPref(prefs::kDnsStartupPrefetchList); |
328 | 327 |
329 local_state->RegisterListPref(prefs::kDnsHostReferralList, | 328 local_state->RegisterListPref(prefs::kDnsHostReferralList); |
330 PrefService::UNSYNCABLE_PREF); | |
331 local_state->ClearPref(prefs::kDnsHostReferralList); | 329 local_state->ClearPref(prefs::kDnsHostReferralList); |
332 | 330 |
333 current_version |= DNS_PREFS; | 331 current_version |= DNS_PREFS; |
334 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, | 332 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, |
335 current_version); | 333 current_version); |
336 } | 334 } |
337 | 335 |
338 PrefService* user_prefs = profile->GetPrefs(); | 336 PrefServiceSyncable* user_prefs = profile->GetPrefs(); |
339 if (!(current_version & WINDOWS_PREFS)) { | 337 if (!(current_version & WINDOWS_PREFS)) { |
340 local_state->RegisterIntegerPref(prefs::kDevToolsHSplitLocation, -1); | 338 local_state->RegisterIntegerPref(prefs::kDevToolsHSplitLocation, -1); |
341 if (local_state->HasPrefPath(prefs::kDevToolsHSplitLocation)) { | 339 if (local_state->HasPrefPath(prefs::kDevToolsHSplitLocation)) { |
342 user_prefs->SetInteger(prefs::kDevToolsHSplitLocation, | 340 user_prefs->SetInteger( |
341 prefs::kDevToolsHSplitLocation, | |
343 local_state->GetInteger(prefs::kDevToolsHSplitLocation)); | 342 local_state->GetInteger(prefs::kDevToolsHSplitLocation)); |
344 } | 343 } |
345 local_state->ClearPref(prefs::kDevToolsHSplitLocation); | 344 local_state->ClearPref(prefs::kDevToolsHSplitLocation); |
346 | 345 |
347 local_state->RegisterDictionaryPref(prefs::kBrowserWindowPlacement); | 346 local_state->RegisterDictionaryPref(prefs::kBrowserWindowPlacement); |
348 if (local_state->HasPrefPath(prefs::kBrowserWindowPlacement)) { | 347 if (local_state->HasPrefPath(prefs::kBrowserWindowPlacement)) { |
349 const PrefService::Preference* pref = | 348 const PrefService::Preference* pref = |
350 local_state->FindPreference(prefs::kBrowserWindowPlacement); | 349 local_state->FindPreference(prefs::kBrowserWindowPlacement); |
351 DCHECK(pref); | 350 DCHECK(pref); |
352 user_prefs->Set(prefs::kBrowserWindowPlacement, *(pref->GetValue())); | 351 user_prefs->Set(prefs::kBrowserWindowPlacement, |
352 *(pref->GetValue())); | |
353 } | 353 } |
354 local_state->ClearPref(prefs::kBrowserWindowPlacement); | 354 local_state->ClearPref(prefs::kBrowserWindowPlacement); |
355 | 355 |
356 current_version |= WINDOWS_PREFS; | 356 current_version |= WINDOWS_PREFS; |
357 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, | 357 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, |
358 current_version); | 358 current_version); |
359 } | 359 } |
360 | 360 |
361 if (!(current_version & GOOGLE_URL_TRACKER_PREFS)) { | 361 if (!(current_version & GOOGLE_URL_TRACKER_PREFS)) { |
362 GoogleURLTrackerFactory::GetInstance()->RegisterUserPrefsOnProfile(profile); | 362 GoogleURLTrackerFactory::GetInstance()->RegisterUserPrefsOnProfile(profile); |
363 local_state->RegisterStringPref(prefs::kLastKnownGoogleURL, | 363 local_state->RegisterStringPref(prefs::kLastKnownGoogleURL, |
364 GoogleURLTracker::kDefaultGoogleHomepage); | 364 GoogleURLTracker::kDefaultGoogleHomepage); |
365 if (local_state->HasPrefPath(prefs::kLastKnownGoogleURL)) { | 365 if (local_state->HasPrefPath(prefs::kLastKnownGoogleURL)) { |
366 user_prefs->SetString(prefs::kLastKnownGoogleURL, | 366 user_prefs->SetString(prefs::kLastKnownGoogleURL, |
367 local_state->GetString(prefs::kLastKnownGoogleURL)); | 367 local_state->GetString(prefs::kLastKnownGoogleURL)); |
368 } | 368 } |
369 local_state->ClearPref(prefs::kLastKnownGoogleURL); | 369 local_state->ClearPref(prefs::kLastKnownGoogleURL); |
370 | 370 |
371 local_state->RegisterStringPref(prefs::kLastPromptedGoogleURL, | 371 local_state->RegisterStringPref(prefs::kLastPromptedGoogleURL, |
372 std::string()); | 372 std::string()); |
373 if (local_state->HasPrefPath(prefs::kLastPromptedGoogleURL)) { | 373 if (local_state->HasPrefPath(prefs::kLastPromptedGoogleURL)) { |
374 user_prefs->SetString(prefs::kLastPromptedGoogleURL, | 374 user_prefs->SetString( |
375 prefs::kLastPromptedGoogleURL, | |
375 local_state->GetString(prefs::kLastPromptedGoogleURL)); | 376 local_state->GetString(prefs::kLastPromptedGoogleURL)); |
376 } | 377 } |
377 local_state->ClearPref(prefs::kLastPromptedGoogleURL); | 378 local_state->ClearPref(prefs::kLastPromptedGoogleURL); |
378 | 379 |
379 current_version |= GOOGLE_URL_TRACKER_PREFS; | 380 current_version |= GOOGLE_URL_TRACKER_PREFS; |
380 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, | 381 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, |
381 current_version); | 382 current_version); |
382 } | 383 } |
383 } | 384 } |
384 | 385 |
385 } // namespace chrome | 386 } // namespace chrome |
OLD | NEW |