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

Side by Side Diff: chrome/browser/chrome_browser_main.cc

Issue 11741003: Remove PrefServiceSimple, replacing it with PrefService and PrefRegistrySimple. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix double registration in Chrome Frame test. 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
« no previous file with comments | « chrome/browser/browser_shutdown.cc ('k') | chrome/browser/chromeos/audio/audio_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/chrome_browser_main.h" 5 #include "chrome/browser/chrome_browser_main.h"
6 6
7 #if defined(TOOLKIT_GTK) 7 #if defined(TOOLKIT_GTK)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 #include "chrome/browser/net/crl_set_fetcher.h" 69 #include "chrome/browser/net/crl_set_fetcher.h"
70 #include "chrome/browser/notifications/desktop_notification_service.h" 70 #include "chrome/browser/notifications/desktop_notification_service.h"
71 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 71 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
72 #include "chrome/browser/page_cycler/page_cycler.h" 72 #include "chrome/browser/page_cycler/page_cycler.h"
73 #include "chrome/browser/performance_monitor/performance_monitor.h" 73 #include "chrome/browser/performance_monitor/performance_monitor.h"
74 #include "chrome/browser/performance_monitor/startup_timer.h" 74 #include "chrome/browser/performance_monitor/startup_timer.h"
75 #include "chrome/browser/plugins/plugin_prefs.h" 75 #include "chrome/browser/plugins/plugin_prefs.h"
76 #include "chrome/browser/policy/policy_service.h" 76 #include "chrome/browser/policy/policy_service.h"
77 #include "chrome/browser/prefs/chrome_pref_service_factory.h" 77 #include "chrome/browser/prefs/chrome_pref_service_factory.h"
78 #include "chrome/browser/prefs/command_line_pref_store.h" 78 #include "chrome/browser/prefs/command_line_pref_store.h"
79 #include "chrome/browser/prefs/pref_registry_simple.h"
79 #include "chrome/browser/prefs/pref_service.h" 80 #include "chrome/browser/prefs/pref_service.h"
80 #include "chrome/browser/prefs/pref_value_store.h" 81 #include "chrome/browser/prefs/pref_value_store.h"
81 #include "chrome/browser/prefs/scoped_user_pref_update.h" 82 #include "chrome/browser/prefs/scoped_user_pref_update.h"
82 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" 83 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
83 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h" 84 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h"
84 #include "chrome/browser/process_singleton.h" 85 #include "chrome/browser/process_singleton.h"
85 #include "chrome/browser/profiles/profile.h" 86 #include "chrome/browser/profiles/profile.h"
86 #include "chrome/browser/profiles/profile_manager.h" 87 #include "chrome/browser/profiles/profile_manager.h"
87 #include "chrome/browser/search_engines/search_engine_type.h" 88 #include "chrome/browser/search_engines/search_engine_type.h"
88 #include "chrome/browser/search_engines/template_url.h" 89 #include "chrome/browser/search_engines/template_url.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // |local_state_task_runner| must be a shutdown-blocking task runner. 245 // |local_state_task_runner| must be a shutdown-blocking task runner.
245 PrefService* InitializeLocalState( 246 PrefService* InitializeLocalState(
246 base::SequencedTaskRunner* local_state_task_runner, 247 base::SequencedTaskRunner* local_state_task_runner,
247 const CommandLine& parsed_command_line, 248 const CommandLine& parsed_command_line,
248 bool is_first_run) { 249 bool is_first_run) {
249 FilePath local_state_path; 250 FilePath local_state_path;
250 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); 251 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path);
251 bool local_state_file_exists = file_util::PathExists(local_state_path); 252 bool local_state_file_exists = file_util::PathExists(local_state_path);
252 253
253 // Load local state. This includes the application locale so we know which 254 // Load local state. This includes the application locale so we know which
254 // locale dll to load. 255 // locale dll to load. This also causes local state prefs to be registered.
255 PrefServiceSimple* local_state = g_browser_process->local_state(); 256 PrefService* local_state = g_browser_process->local_state();
256 DCHECK(local_state); 257 DCHECK(local_state);
257 258
258 // TODO(brettw,*): this comment about ResourceBundle was here since
259 // initial commit. This comment seems unrelated, bit-rotten and
260 // a candidate for removal.
261 // Initialize ResourceBundle which handles files loaded from external
262 // sources. This has to be done before uninstall code path and before prefs
263 // are registered.
264 local_state->RegisterStringPref(prefs::kApplicationLocale, std::string());
265 #if defined(OS_CHROMEOS)
266 local_state->RegisterStringPref(prefs::kOwnerLocale, std::string());
267 local_state->RegisterStringPref(prefs::kHardwareKeyboardLayout,
268 std::string());
269 #endif // defined(OS_CHROMEOS)
270 #if !defined(OS_CHROMEOS)
271 local_state->RegisterBooleanPref(prefs::kMetricsReportingEnabled,
272 GoogleUpdateSettings::GetCollectStatsConsent());
273 #endif // !defined(OS_CHROMEOS)
274
275 if (is_first_run) { 259 if (is_first_run) {
276 #if defined(OS_WIN) 260 #if defined(OS_WIN)
277 // During first run we read the google_update registry key to find what 261 // During first run we read the google_update registry key to find what
278 // language the user selected when downloading the installer. This 262 // language the user selected when downloading the installer. This
279 // becomes our default language in the prefs. 263 // becomes our default language in the prefs.
280 // Other platforms obey the system locale. 264 // Other platforms obey the system locale.
281 std::wstring install_lang; 265 std::wstring install_lang;
282 if (GoogleUpdateSettings::GetLanguage(&install_lang)) { 266 if (GoogleUpdateSettings::GetLanguage(&install_lang)) {
283 local_state->SetString(prefs::kApplicationLocale, 267 local_state->SetString(prefs::kApplicationLocale,
284 WideToASCII(install_lang)); 268 WideToASCII(install_lang));
285 } 269 }
286 #endif // defined(OS_WIN) 270 #endif // defined(OS_WIN)
287 } 271 }
288 272
289 // If the local state file for the current profile doesn't exist and the 273 // If the local state file for the current profile doesn't exist and the
290 // parent profile command line flag is present, then we should inherit some 274 // parent profile command line flag is present, then we should inherit some
291 // local state from the parent profile. 275 // local state from the parent profile.
292 // Checking that the local state file for the current profile doesn't exist 276 // Checking that the local state file for the current profile doesn't exist
293 // is the most robust way to determine whether we need to inherit or not 277 // is the most robust way to determine whether we need to inherit or not
294 // since the parent profile command line flag can be present even when the 278 // since the parent profile command line flag can be present even when the
295 // current profile is not a new one, and in that case we do not want to 279 // current profile is not a new one, and in that case we do not want to
296 // inherit and reset the user's setting. 280 // inherit and reset the user's setting.
297 // 281 //
298 // TODO(mnissler): We should probably just instantiate a 282 // TODO(mnissler): We should probably just instantiate a
299 // JSONPrefStore here instead of an entire PrefService. 283 // JSONPrefStore here instead of an entire PrefService. Once this is
284 // addressed, the call to browser_prefs::RegisterLocalState can move
285 // to chrome_prefs::CreateLocalState.
300 if (!local_state_file_exists && 286 if (!local_state_file_exists &&
301 parsed_command_line.HasSwitch(switches::kParentProfile)) { 287 parsed_command_line.HasSwitch(switches::kParentProfile)) {
302 FilePath parent_profile = 288 FilePath parent_profile =
303 parsed_command_line.GetSwitchValuePath(switches::kParentProfile); 289 parsed_command_line.GetSwitchValuePath(switches::kParentProfile);
304 scoped_ptr<PrefServiceSimple> parent_local_state( 290 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple();
291 scoped_ptr<PrefService> parent_local_state(
305 chrome_prefs::CreateLocalState( 292 chrome_prefs::CreateLocalState(
306 parent_profile, 293 parent_profile,
307 local_state_task_runner, 294 local_state_task_runner,
308 g_browser_process->policy_service(), 295 g_browser_process->policy_service(),
309 NULL, false)); 296 NULL,
310 parent_local_state->RegisterStringPref(prefs::kApplicationLocale, 297 registry,
311 std::string()); 298 false));
299 registry->RegisterStringPref(prefs::kApplicationLocale, std::string());
312 // Right now, we only inherit the locale setting from the parent profile. 300 // Right now, we only inherit the locale setting from the parent profile.
313 local_state->SetString( 301 local_state->SetString(
314 prefs::kApplicationLocale, 302 prefs::kApplicationLocale,
315 parent_local_state->GetString(prefs::kApplicationLocale)); 303 parent_local_state->GetString(prefs::kApplicationLocale));
316 } 304 }
317 305
318 #if defined(OS_CHROMEOS) 306 #if defined(OS_CHROMEOS)
319 if (parsed_command_line.HasSwitch(switches::kLoginManager)) { 307 if (parsed_command_line.HasSwitch(switches::kLoginManager)) {
320 std::string owner_locale = local_state->GetString(prefs::kOwnerLocale); 308 std::string owner_locale = local_state->GetString(prefs::kOwnerLocale);
321 // Ensure that we start with owner's locale. 309 // Ensure that we start with owner's locale.
(...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 if (base::win::GetVersion() <= base::win::VERSION_XP) 1746 if (base::win::GetVersion() <= base::win::VERSION_XP)
1759 uma_name += "_XP"; 1747 uma_name += "_XP";
1760 1748
1761 uma_name += "_PreRead_"; 1749 uma_name += "_PreRead_";
1762 uma_name += pre_read_percentage; 1750 uma_name += pre_read_percentage;
1763 AddPreReadHistogramTime(uma_name.c_str(), time); 1751 AddPreReadHistogramTime(uma_name.c_str(), time);
1764 } 1752 }
1765 #endif 1753 #endif
1766 #endif 1754 #endif
1767 } 1755 }
OLDNEW
« no previous file with comments | « chrome/browser/browser_shutdown.cc ('k') | chrome/browser/chromeos/audio/audio_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698