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

Side by Side Diff: chrome/browser/prefs/browser_prefs.cc

Issue 11741003: Remove PrefServiceSimple, replacing it with PrefService and PrefRegistrySimple. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to review comments. Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
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
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 NO_PREFS = 0, 141 NO_PREFS = 0,
140 DNS_PREFS = 1 << 0, 142 DNS_PREFS = 1 << 0,
141 WINDOWS_PREFS = 1 << 1, 143 WINDOWS_PREFS = 1 << 1,
142 GOOGLE_URL_TRACKER_PREFS = 1 << 2, 144 GOOGLE_URL_TRACKER_PREFS = 1 << 2,
143 }; 145 };
144 146
145 } // namespace 147 } // namespace
146 148
147 namespace chrome { 149 namespace chrome {
148 150
149 void RegisterLocalState(PrefServiceSimple* local_state) { 151 void RegisterLocalState(PrefRegistrySimple* registry,
152 PrefService* local_state) {
Mattias Nissler (ping if slow) 2013/01/31 13:06:25 TODO here saying to remove the local_state paramet
Jói 2013/01/31 13:43:42 Done.
150 // Prefs in Local State. 153 // Prefs in Local State.
151 local_state->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0); 154 registry->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0);
152 155
153 // Please keep this list alphabetized. 156 // Please keep this list alphabetized.
154 browser_shutdown::RegisterPrefs(local_state); 157 browser_shutdown::RegisterPrefs(registry);
155 chrome::RegisterScreenshotPrefs(local_state); 158 chrome::RegisterScreenshotPrefs(registry);
156 extensions::app_launcher::RegisterPrefs(local_state); 159 extensions::app_launcher::RegisterPrefs(registry);
157 ExternalProtocolHandler::RegisterPrefs(local_state); 160 ExternalProtocolHandler::RegisterPrefs(registry);
158 FlagsUI::RegisterPrefs(local_state); 161 FlagsUI::RegisterPrefs(registry);
159 geolocation::RegisterPrefs(local_state); 162 geolocation::RegisterPrefs(registry);
160 IntranetRedirectDetector::RegisterPrefs(local_state); 163 IntranetRedirectDetector::RegisterPrefs(registry);
161 KeywordEditorController::RegisterPrefs(local_state); 164 KeywordEditorController::RegisterPrefs(registry);
162 MetricsLog::RegisterPrefs(local_state); 165 MetricsLog::RegisterPrefs(registry);
163 MetricsService::RegisterPrefs(local_state); 166 MetricsService::RegisterPrefs(registry);
164 PrefProxyConfigTrackerImpl::RegisterPrefs(local_state); 167 PrefProxyConfigTrackerImpl::RegisterPrefs(registry);
165 ProfileInfoCache::RegisterPrefs(local_state); 168 ProfileInfoCache::RegisterPrefs(registry);
166 ProfileManager::RegisterPrefs(local_state); 169 ProfileManager::RegisterPrefs(registry);
167 PromoResourceService::RegisterPrefs(local_state); 170 PromoResourceService::RegisterPrefs(registry);
168 SigninManagerFactory::RegisterPrefs(local_state); 171 SigninManagerFactory::RegisterPrefs(registry);
169 SSLConfigServiceManager::RegisterPrefs(local_state); 172 SSLConfigServiceManager::RegisterPrefs(registry);
170 UpgradeDetector::RegisterPrefs(local_state); 173 UpgradeDetector::RegisterPrefs(registry);
171 WebCacheManager::RegisterPrefs(local_state); 174 WebCacheManager::RegisterPrefs(registry);
172 175
173 #if defined(ENABLE_PLUGINS) 176 #if defined(ENABLE_PLUGINS)
174 PluginFinder::RegisterPrefs(local_state); 177 PluginFinder::RegisterPrefs(registry);
175 #endif 178 #endif
176 179
177 #if defined(ENABLE_PLUGIN_INSTALLATION) 180 #if defined(ENABLE_PLUGIN_INSTALLATION)
178 PluginsResourceService::RegisterPrefs(local_state); 181 PluginsResourceService::RegisterPrefs(registry);
179 #endif 182 #endif
180 183
181 #if defined(ENABLE_CONFIGURATION_POLICY) 184 #if defined(ENABLE_CONFIGURATION_POLICY)
182 policy::BrowserPolicyConnector::RegisterPrefs(local_state); 185 policy::BrowserPolicyConnector::RegisterPrefs(registry);
183 policy::PolicyStatisticsCollector::RegisterPrefs(local_state); 186 policy::PolicyStatisticsCollector::RegisterPrefs(registry);
184 #endif 187 #endif
185 188
186 #if defined(ENABLE_NOTIFICATIONS) 189 #if defined(ENABLE_NOTIFICATIONS)
187 NotificationPrefsManager::RegisterPrefs(local_state); 190 NotificationPrefsManager::RegisterPrefs(local_state, registry);
188 #endif 191 #endif
189 192
190 #if defined(ENABLE_TASK_MANAGER) 193 #if defined(ENABLE_TASK_MANAGER)
191 TaskManager::RegisterPrefs(local_state); 194 TaskManager::RegisterPrefs(registry);
192 #endif // defined(ENABLE_TASK_MANAGER) 195 #endif // defined(ENABLE_TASK_MANAGER)
193 196
194 #if defined(TOOLKIT_VIEWS) 197 #if defined(TOOLKIT_VIEWS)
195 RegisterBrowserViewPrefs(local_state); 198 RegisterBrowserViewPrefs(registry);
196 RegisterTabStripLayoutTypePrefs(local_state); 199 RegisterTabStripLayoutTypePrefs(registry);
197 #endif 200 #endif
198 201
199 #if !defined(OS_ANDROID) 202 #if !defined(OS_ANDROID)
200 BackgroundModeManager::RegisterPrefs(local_state); 203 BackgroundModeManager::RegisterPrefs(registry);
201 chrome_variations::VariationsService::RegisterPrefs(local_state); 204 chrome_variations::VariationsService::RegisterPrefs(registry);
202 RegisterBrowserPrefs(local_state); 205 RegisterBrowserPrefs(registry);
203 ManagedMode::RegisterPrefs(local_state); 206 ManagedMode::RegisterPrefs(registry);
204 #endif 207 #endif
205 208
206 #if defined(OS_CHROMEOS) 209 #if defined(OS_CHROMEOS)
207 chromeos::AudioHandler::RegisterPrefs(local_state); 210 chromeos::AudioHandler::RegisterPrefs(registry);
208 chromeos::DataPromoNotification::RegisterPrefs(local_state); 211 chromeos::DataPromoNotification::RegisterPrefs(registry);
209 chromeos::device_settings_cache::RegisterPrefs(local_state); 212 chromeos::device_settings_cache::RegisterPrefs(registry);
210 chromeos::language_prefs::RegisterPrefs(local_state); 213 chromeos::language_prefs::RegisterPrefs(registry);
211 chromeos::ProxyConfigServiceImpl::RegisterPrefs(local_state); 214 chromeos::ProxyConfigServiceImpl::RegisterPrefs(registry);
212 chromeos::RegisterDisplayLocalStatePrefs(local_state); 215 chromeos::RegisterDisplayLocalStatePrefs(registry);
213 chromeos::ServicesCustomizationDocument::RegisterPrefs(local_state); 216 chromeos::ServicesCustomizationDocument::RegisterPrefs(registry);
214 chromeos::UserImageManager::RegisterPrefs(local_state); 217 chromeos::UserImageManager::RegisterPrefs(registry);
215 chromeos::UserManager::RegisterPrefs(local_state); 218 chromeos::UserManager::RegisterPrefs(registry);
216 chromeos::WallpaperManager::RegisterPrefs(local_state); 219 chromeos::WallpaperManager::RegisterPrefs(registry);
217 chromeos::WizardController::RegisterPrefs(local_state); 220 chromeos::WizardController::RegisterPrefs(registry);
218 policy::AutoEnrollmentClient::RegisterPrefs(local_state); 221 policy::AutoEnrollmentClient::RegisterPrefs(registry);
219 policy::DeviceStatusCollector::RegisterPrefs(local_state); 222 policy::DeviceStatusCollector::RegisterPrefs(registry);
220 #endif 223 #endif
221 224
222 #if defined(OS_MACOSX) 225 #if defined(OS_MACOSX)
223 confirm_quit::RegisterLocalState(local_state); 226 confirm_quit::RegisterLocalState(registry);
224 #endif 227 #endif
225 } 228 }
226 229
227 void RegisterUserPrefs(PrefServiceSyncable* user_prefs) { 230 void RegisterUserPrefs(PrefServiceSyncable* user_prefs) {
228 // User prefs. Please keep this list alphabetized. 231 // User prefs. Please keep this list alphabetized.
229 AlternateErrorPageTabObserver::RegisterUserPrefs(user_prefs); 232 AlternateErrorPageTabObserver::RegisterUserPrefs(user_prefs);
230 AutofillManager::RegisterUserPrefs(user_prefs); 233 AutofillManager::RegisterUserPrefs(user_prefs);
231 BookmarkPromptPrefs::RegisterUserPrefs(user_prefs); 234 BookmarkPromptPrefs::RegisterUserPrefs(user_prefs);
232 bookmark_utils::RegisterUserPrefs(user_prefs); 235 bookmark_utils::RegisterUserPrefs(user_prefs);
233 BrowserInstantController::RegisterUserPrefs(user_prefs); 236 BrowserInstantController::RegisterUserPrefs(user_prefs);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 void MigrateUserPrefs(Profile* profile) { 320 void MigrateUserPrefs(Profile* profile) {
318 // Cleanup old prefs. 321 // Cleanup old prefs.
319 static const char kBackupPref[] = "backup"; 322 static const char kBackupPref[] = "backup";
320 PrefServiceSyncable* prefs = profile->GetPrefs(); 323 PrefServiceSyncable* prefs = profile->GetPrefs();
321 prefs->RegisterDictionaryPref(kBackupPref, new DictionaryValue(), 324 prefs->RegisterDictionaryPref(kBackupPref, new DictionaryValue(),
322 PrefServiceSyncable::UNSYNCABLE_PREF); 325 PrefServiceSyncable::UNSYNCABLE_PREF);
323 prefs->ClearPref(kBackupPref); 326 prefs->ClearPref(kBackupPref);
324 prefs->UnregisterPreference(kBackupPref); 327 prefs->UnregisterPreference(kBackupPref);
325 } 328 }
326 329
327 void MigrateBrowserPrefs(Profile* profile, PrefServiceSimple* local_state) { 330 void MigrateBrowserPrefs(Profile* profile, PrefService* local_state) {
328 // Copy pref values which have been migrated to user_prefs from local_state, 331 // Copy pref values which have been migrated to user_prefs from local_state,
329 // or remove them from local_state outright, if copying is not required. 332 // or remove them from local_state outright, if copying is not required.
330 int current_version = 333 int current_version =
331 local_state->GetInteger(prefs::kMultipleProfilePrefMigration); 334 local_state->GetInteger(prefs::kMultipleProfilePrefMigration);
335 PrefRegistrySimple* registry = static_cast<PrefRegistrySimple*>(
Mattias Nissler (ping if slow) 2013/01/31 13:06:25 TODO here saying the registrations should happen e
336 local_state->DeprecatedGetPrefRegistry());
332 337
333 if (!(current_version & DNS_PREFS)) { 338 if (!(current_version & DNS_PREFS)) {
334 local_state->RegisterListPref(prefs::kDnsStartupPrefetchList); 339 registry->RegisterListPref(prefs::kDnsStartupPrefetchList);
335 local_state->ClearPref(prefs::kDnsStartupPrefetchList); 340 local_state->ClearPref(prefs::kDnsStartupPrefetchList);
336 341
337 local_state->RegisterListPref(prefs::kDnsHostReferralList); 342 registry->RegisterListPref(prefs::kDnsHostReferralList);
338 local_state->ClearPref(prefs::kDnsHostReferralList); 343 local_state->ClearPref(prefs::kDnsHostReferralList);
339 344
340 current_version |= DNS_PREFS; 345 current_version |= DNS_PREFS;
341 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, 346 local_state->SetInteger(prefs::kMultipleProfilePrefMigration,
342 current_version); 347 current_version);
343 } 348 }
344 349
345 PrefServiceSyncable* user_prefs = profile->GetPrefs(); 350 PrefServiceSyncable* user_prefs = profile->GetPrefs();
346 if (!(current_version & WINDOWS_PREFS)) { 351 if (!(current_version & WINDOWS_PREFS)) {
347 local_state->RegisterIntegerPref(prefs::kDevToolsHSplitLocation, -1); 352 registry->RegisterIntegerPref(prefs::kDevToolsHSplitLocation, -1);
348 if (local_state->HasPrefPath(prefs::kDevToolsHSplitLocation)) { 353 if (local_state->HasPrefPath(prefs::kDevToolsHSplitLocation)) {
349 user_prefs->SetInteger( 354 user_prefs->SetInteger(
350 prefs::kDevToolsHSplitLocation, 355 prefs::kDevToolsHSplitLocation,
351 local_state->GetInteger(prefs::kDevToolsHSplitLocation)); 356 local_state->GetInteger(prefs::kDevToolsHSplitLocation));
352 } 357 }
353 local_state->ClearPref(prefs::kDevToolsHSplitLocation); 358 local_state->ClearPref(prefs::kDevToolsHSplitLocation);
354 359
355 local_state->RegisterDictionaryPref(prefs::kBrowserWindowPlacement); 360 registry->RegisterDictionaryPref(prefs::kBrowserWindowPlacement);
356 if (local_state->HasPrefPath(prefs::kBrowserWindowPlacement)) { 361 if (local_state->HasPrefPath(prefs::kBrowserWindowPlacement)) {
357 const PrefService::Preference* pref = 362 const PrefService::Preference* pref =
358 local_state->FindPreference(prefs::kBrowserWindowPlacement); 363 local_state->FindPreference(prefs::kBrowserWindowPlacement);
359 DCHECK(pref); 364 DCHECK(pref);
360 user_prefs->Set(prefs::kBrowserWindowPlacement, 365 user_prefs->Set(prefs::kBrowserWindowPlacement,
361 *(pref->GetValue())); 366 *(pref->GetValue()));
362 } 367 }
363 local_state->ClearPref(prefs::kBrowserWindowPlacement); 368 local_state->ClearPref(prefs::kBrowserWindowPlacement);
364 369
365 current_version |= WINDOWS_PREFS; 370 current_version |= WINDOWS_PREFS;
366 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, 371 local_state->SetInteger(prefs::kMultipleProfilePrefMigration,
367 current_version); 372 current_version);
368 } 373 }
369 374
370 if (!(current_version & GOOGLE_URL_TRACKER_PREFS)) { 375 if (!(current_version & GOOGLE_URL_TRACKER_PREFS)) {
371 GoogleURLTrackerFactory::GetInstance()->RegisterUserPrefsOnProfile(profile); 376 GoogleURLTrackerFactory::GetInstance()->RegisterUserPrefsOnProfile(profile);
372 local_state->RegisterStringPref(prefs::kLastKnownGoogleURL, 377 registry->RegisterStringPref(prefs::kLastKnownGoogleURL,
373 GoogleURLTracker::kDefaultGoogleHomepage); 378 GoogleURLTracker::kDefaultGoogleHomepage);
374 if (local_state->HasPrefPath(prefs::kLastKnownGoogleURL)) { 379 if (local_state->HasPrefPath(prefs::kLastKnownGoogleURL)) {
375 user_prefs->SetString(prefs::kLastKnownGoogleURL, 380 user_prefs->SetString(prefs::kLastKnownGoogleURL,
376 local_state->GetString(prefs::kLastKnownGoogleURL)); 381 local_state->GetString(prefs::kLastKnownGoogleURL));
377 } 382 }
378 local_state->ClearPref(prefs::kLastKnownGoogleURL); 383 local_state->ClearPref(prefs::kLastKnownGoogleURL);
379 384
380 local_state->RegisterStringPref(prefs::kLastPromptedGoogleURL, 385 registry->RegisterStringPref(prefs::kLastPromptedGoogleURL,
381 std::string()); 386 std::string());
382 if (local_state->HasPrefPath(prefs::kLastPromptedGoogleURL)) { 387 if (local_state->HasPrefPath(prefs::kLastPromptedGoogleURL)) {
383 user_prefs->SetString( 388 user_prefs->SetString(
384 prefs::kLastPromptedGoogleURL, 389 prefs::kLastPromptedGoogleURL,
385 local_state->GetString(prefs::kLastPromptedGoogleURL)); 390 local_state->GetString(prefs::kLastPromptedGoogleURL));
386 } 391 }
387 local_state->ClearPref(prefs::kLastPromptedGoogleURL); 392 local_state->ClearPref(prefs::kLastPromptedGoogleURL);
388 393
389 current_version |= GOOGLE_URL_TRACKER_PREFS; 394 current_version |= GOOGLE_URL_TRACKER_PREFS;
390 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, 395 local_state->SetInteger(prefs::kMultipleProfilePrefMigration,
391 current_version); 396 current_version);
392 } 397 }
393 } 398 }
394 399
395 } // namespace chrome 400 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698