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

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

Powered by Google App Engine
This is Rietveld 408576698