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

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: Switch to desired interfaces. Created 7 years, 11 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 (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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 #include "chrome/browser/net/chrome_net_log.h" 62 #include "chrome/browser/net/chrome_net_log.h"
63 #include "chrome/browser/notifications/desktop_notification_service.h" 63 #include "chrome/browser/notifications/desktop_notification_service.h"
64 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 64 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
65 #include "chrome/browser/page_cycler/page_cycler.h" 65 #include "chrome/browser/page_cycler/page_cycler.h"
66 #include "chrome/browser/performance_monitor/performance_monitor.h" 66 #include "chrome/browser/performance_monitor/performance_monitor.h"
67 #include "chrome/browser/performance_monitor/startup_timer.h" 67 #include "chrome/browser/performance_monitor/startup_timer.h"
68 #include "chrome/browser/plugins/plugin_prefs.h" 68 #include "chrome/browser/plugins/plugin_prefs.h"
69 #include "chrome/browser/policy/policy_service.h" 69 #include "chrome/browser/policy/policy_service.h"
70 #include "chrome/browser/prefs/chrome_pref_service_factory.h" 70 #include "chrome/browser/prefs/chrome_pref_service_factory.h"
71 #include "chrome/browser/prefs/command_line_pref_store.h" 71 #include "chrome/browser/prefs/command_line_pref_store.h"
72 #include "chrome/browser/prefs/pref_registry_simple.h"
72 #include "chrome/browser/prefs/pref_service.h" 73 #include "chrome/browser/prefs/pref_service.h"
73 #include "chrome/browser/prefs/pref_value_store.h" 74 #include "chrome/browser/prefs/pref_value_store.h"
74 #include "chrome/browser/prefs/scoped_user_pref_update.h" 75 #include "chrome/browser/prefs/scoped_user_pref_update.h"
75 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" 76 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
76 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h" 77 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h"
77 #include "chrome/browser/process_singleton.h" 78 #include "chrome/browser/process_singleton.h"
78 #include "chrome/browser/profiles/profile.h" 79 #include "chrome/browser/profiles/profile.h"
79 #include "chrome/browser/profiles/profile_manager.h" 80 #include "chrome/browser/profiles/profile_manager.h"
80 #include "chrome/browser/search_engines/search_engine_type.h" 81 #include "chrome/browser/search_engines/search_engine_type.h"
81 #include "chrome/browser/search_engines/template_url.h" 82 #include "chrome/browser/search_engines/template_url.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // |local_state_task_runner| must be a shutdown-blocking task runner. 225 // |local_state_task_runner| must be a shutdown-blocking task runner.
225 PrefService* InitializeLocalState( 226 PrefService* InitializeLocalState(
226 base::SequencedTaskRunner* local_state_task_runner, 227 base::SequencedTaskRunner* local_state_task_runner,
227 const CommandLine& parsed_command_line, 228 const CommandLine& parsed_command_line,
228 bool is_first_run) { 229 bool is_first_run) {
229 FilePath local_state_path; 230 FilePath local_state_path;
230 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); 231 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path);
231 bool local_state_file_exists = file_util::PathExists(local_state_path); 232 bool local_state_file_exists = file_util::PathExists(local_state_path);
232 233
233 // Load local state. This includes the application locale so we know which 234 // Load local state. This includes the application locale so we know which
234 // locale dll to load. 235 // locale dll to load. This also causes local state prefs to be registered.
235 PrefServiceSimple* local_state = g_browser_process->local_state(); 236 PrefService* local_state = g_browser_process->local_state();
236 DCHECK(local_state); 237 DCHECK(local_state);
237 238
238 // TODO(brettw,*): this comment about ResourceBundle was here since
239 // initial commit. This comment seems unrelated, bit-rotten and
240 // a candidate for removal.
241 // Initialize ResourceBundle which handles files loaded from external
242 // sources. This has to be done before uninstall code path and before prefs
243 // are registered.
244 local_state->RegisterStringPref(prefs::kApplicationLocale, std::string());
245 #if defined(OS_CHROMEOS)
246 local_state->RegisterStringPref(prefs::kOwnerLocale, std::string());
247 local_state->RegisterStringPref(prefs::kHardwareKeyboardLayout,
248 std::string());
249 #endif // defined(OS_CHROMEOS)
250 #if !defined(OS_CHROMEOS)
251 local_state->RegisterBooleanPref(prefs::kMetricsReportingEnabled,
252 GoogleUpdateSettings::GetCollectStatsConsent());
253 #endif // !defined(OS_CHROMEOS)
254
255 if (is_first_run) { 239 if (is_first_run) {
256 #if defined(OS_WIN) 240 #if defined(OS_WIN)
257 // During first run we read the google_update registry key to find what 241 // During first run we read the google_update registry key to find what
258 // language the user selected when downloading the installer. This 242 // language the user selected when downloading the installer. This
259 // becomes our default language in the prefs. 243 // becomes our default language in the prefs.
260 // Other platforms obey the system locale. 244 // Other platforms obey the system locale.
261 std::wstring install_lang; 245 std::wstring install_lang;
262 if (GoogleUpdateSettings::GetLanguage(&install_lang)) { 246 if (GoogleUpdateSettings::GetLanguage(&install_lang)) {
263 local_state->SetString(prefs::kApplicationLocale, 247 local_state->SetString(prefs::kApplicationLocale,
264 WideToASCII(install_lang)); 248 WideToASCII(install_lang));
265 } 249 }
266 #endif // defined(OS_WIN) 250 #endif // defined(OS_WIN)
267 } 251 }
268 252
269 // If the local state file for the current profile doesn't exist and the 253 // If the local state file for the current profile doesn't exist and the
270 // parent profile command line flag is present, then we should inherit some 254 // parent profile command line flag is present, then we should inherit some
271 // local state from the parent profile. 255 // local state from the parent profile.
272 // Checking that the local state file for the current profile doesn't exist 256 // Checking that the local state file for the current profile doesn't exist
273 // is the most robust way to determine whether we need to inherit or not 257 // is the most robust way to determine whether we need to inherit or not
274 // since the parent profile command line flag can be present even when the 258 // since the parent profile command line flag can be present even when the
275 // current profile is not a new one, and in that case we do not want to 259 // current profile is not a new one, and in that case we do not want to
276 // inherit and reset the user's setting. 260 // inherit and reset the user's setting.
277 // 261 //
278 // TODO(mnissler): We should probably just instantiate a 262 // TODO(mnissler): We should probably just instantiate a
279 // JSONPrefStore here instead of an entire PrefService. 263 // JSONPrefStore here instead of an entire PrefService.
280 if (!local_state_file_exists && 264 if (!local_state_file_exists &&
281 parsed_command_line.HasSwitch(switches::kParentProfile)) { 265 parsed_command_line.HasSwitch(switches::kParentProfile)) {
282 FilePath parent_profile = 266 FilePath parent_profile =
283 parsed_command_line.GetSwitchValuePath(switches::kParentProfile); 267 parsed_command_line.GetSwitchValuePath(switches::kParentProfile);
284 scoped_ptr<PrefServiceSimple> parent_local_state( 268 PrefRegistrySimple* registry = new PrefRegistrySimple();
269 scoped_ptr<PrefService> parent_local_state(
285 chrome_prefs::CreateLocalState( 270 chrome_prefs::CreateLocalState(
286 parent_profile, 271 parent_profile,
287 local_state_task_runner, 272 local_state_task_runner,
288 g_browser_process->policy_service(), 273 g_browser_process->policy_service(),
289 NULL, false)); 274 NULL,
290 parent_local_state->RegisterStringPref(prefs::kApplicationLocale, 275 scoped_ptr<PrefRegistry>(registry),
291 std::string()); 276 false));
277 registry->RegisterStringPref(prefs::kApplicationLocale, std::string());
292 // Right now, we only inherit the locale setting from the parent profile. 278 // Right now, we only inherit the locale setting from the parent profile.
293 local_state->SetString( 279 local_state->SetString(
294 prefs::kApplicationLocale, 280 prefs::kApplicationLocale,
295 parent_local_state->GetString(prefs::kApplicationLocale)); 281 parent_local_state->GetString(prefs::kApplicationLocale));
296 } 282 }
297 283
298 #if defined(OS_CHROMEOS) 284 #if defined(OS_CHROMEOS)
299 if (parsed_command_line.HasSwitch(switches::kLoginManager)) { 285 if (parsed_command_line.HasSwitch(switches::kLoginManager)) {
300 std::string owner_locale = local_state->GetString(prefs::kOwnerLocale); 286 std::string owner_locale = local_state->GetString(prefs::kOwnerLocale);
301 // Ensure that we start with owner's locale. 287 // Ensure that we start with owner's locale.
(...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 if (base::win::GetVersion() <= base::win::VERSION_XP) 1629 if (base::win::GetVersion() <= base::win::VERSION_XP)
1644 uma_name += "_XP"; 1630 uma_name += "_XP";
1645 1631
1646 uma_name += "_PreRead_"; 1632 uma_name += "_PreRead_";
1647 uma_name += pre_read_percentage; 1633 uma_name += pre_read_percentage;
1648 AddPreReadHistogramTime(uma_name.c_str(), time); 1634 AddPreReadHistogramTime(uma_name.c_str(), time);
1649 } 1635 }
1650 #endif 1636 #endif
1651 #endif 1637 #endif
1652 } 1638 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698