| OLD | NEW |
| 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 Loading... |
| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 // |local_state_task_runner| must be a shutdown-blocking task runner. | 226 // |local_state_task_runner| must be a shutdown-blocking task runner. |
| 226 PrefService* InitializeLocalState( | 227 PrefService* InitializeLocalState( |
| 227 base::SequencedTaskRunner* local_state_task_runner, | 228 base::SequencedTaskRunner* local_state_task_runner, |
| 228 const CommandLine& parsed_command_line, | 229 const CommandLine& parsed_command_line, |
| 229 bool is_first_run) { | 230 bool is_first_run) { |
| 230 FilePath local_state_path; | 231 FilePath local_state_path; |
| 231 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); | 232 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); |
| 232 bool local_state_file_exists = file_util::PathExists(local_state_path); | 233 bool local_state_file_exists = file_util::PathExists(local_state_path); |
| 233 | 234 |
| 234 // Load local state. This includes the application locale so we know which | 235 // Load local state. This includes the application locale so we know which |
| 235 // locale dll to load. | 236 // locale dll to load. This also causes local state prefs to be registered. |
| 236 PrefServiceSimple* local_state = g_browser_process->local_state(); | 237 PrefService* local_state = g_browser_process->local_state(); |
| 237 DCHECK(local_state); | 238 DCHECK(local_state); |
| 238 | 239 |
| 239 // TODO(brettw,*): this comment about ResourceBundle was here since | |
| 240 // initial commit. This comment seems unrelated, bit-rotten and | |
| 241 // a candidate for removal. | |
| 242 // Initialize ResourceBundle which handles files loaded from external | |
| 243 // sources. This has to be done before uninstall code path and before prefs | |
| 244 // are registered. | |
| 245 local_state->RegisterStringPref(prefs::kApplicationLocale, std::string()); | |
| 246 #if defined(OS_CHROMEOS) | |
| 247 local_state->RegisterStringPref(prefs::kOwnerLocale, std::string()); | |
| 248 local_state->RegisterStringPref(prefs::kHardwareKeyboardLayout, | |
| 249 std::string()); | |
| 250 #endif // defined(OS_CHROMEOS) | |
| 251 #if !defined(OS_CHROMEOS) | |
| 252 local_state->RegisterBooleanPref(prefs::kMetricsReportingEnabled, | |
| 253 GoogleUpdateSettings::GetCollectStatsConsent()); | |
| 254 #endif // !defined(OS_CHROMEOS) | |
| 255 | |
| 256 if (is_first_run) { | 240 if (is_first_run) { |
| 257 #if defined(OS_WIN) | 241 #if defined(OS_WIN) |
| 258 // During first run we read the google_update registry key to find what | 242 // During first run we read the google_update registry key to find what |
| 259 // language the user selected when downloading the installer. This | 243 // language the user selected when downloading the installer. This |
| 260 // becomes our default language in the prefs. | 244 // becomes our default language in the prefs. |
| 261 // Other platforms obey the system locale. | 245 // Other platforms obey the system locale. |
| 262 std::wstring install_lang; | 246 std::wstring install_lang; |
| 263 if (GoogleUpdateSettings::GetLanguage(&install_lang)) { | 247 if (GoogleUpdateSettings::GetLanguage(&install_lang)) { |
| 264 local_state->SetString(prefs::kApplicationLocale, | 248 local_state->SetString(prefs::kApplicationLocale, |
| 265 WideToASCII(install_lang)); | 249 WideToASCII(install_lang)); |
| 266 } | 250 } |
| 267 #endif // defined(OS_WIN) | 251 #endif // defined(OS_WIN) |
| 268 } | 252 } |
| 269 | 253 |
| 270 // If the local state file for the current profile doesn't exist and the | 254 // If the local state file for the current profile doesn't exist and the |
| 271 // parent profile command line flag is present, then we should inherit some | 255 // parent profile command line flag is present, then we should inherit some |
| 272 // local state from the parent profile. | 256 // local state from the parent profile. |
| 273 // Checking that the local state file for the current profile doesn't exist | 257 // Checking that the local state file for the current profile doesn't exist |
| 274 // is the most robust way to determine whether we need to inherit or not | 258 // is the most robust way to determine whether we need to inherit or not |
| 275 // since the parent profile command line flag can be present even when the | 259 // since the parent profile command line flag can be present even when the |
| 276 // current profile is not a new one, and in that case we do not want to | 260 // current profile is not a new one, and in that case we do not want to |
| 277 // inherit and reset the user's setting. | 261 // inherit and reset the user's setting. |
| 278 // | 262 // |
| 279 // TODO(mnissler): We should probably just instantiate a | 263 // TODO(mnissler): We should probably just instantiate a |
| 280 // JSONPrefStore here instead of an entire PrefService. | 264 // JSONPrefStore here instead of an entire PrefService. Once this is |
| 265 // addressed, the call to browser_prefs::RegisterLocalState can move |
| 266 // to chrome_prefs::CreateLocalState. |
| 281 if (!local_state_file_exists && | 267 if (!local_state_file_exists && |
| 282 parsed_command_line.HasSwitch(switches::kParentProfile)) { | 268 parsed_command_line.HasSwitch(switches::kParentProfile)) { |
| 283 FilePath parent_profile = | 269 FilePath parent_profile = |
| 284 parsed_command_line.GetSwitchValuePath(switches::kParentProfile); | 270 parsed_command_line.GetSwitchValuePath(switches::kParentProfile); |
| 285 scoped_ptr<PrefServiceSimple> parent_local_state( | 271 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple(); |
| 272 scoped_ptr<PrefService> parent_local_state( |
| 286 chrome_prefs::CreateLocalState( | 273 chrome_prefs::CreateLocalState( |
| 287 parent_profile, | 274 parent_profile, |
| 288 local_state_task_runner, | 275 local_state_task_runner, |
| 289 g_browser_process->policy_service(), | 276 g_browser_process->policy_service(), |
| 290 NULL, false)); | 277 NULL, |
| 291 parent_local_state->RegisterStringPref(prefs::kApplicationLocale, | 278 registry, |
| 292 std::string()); | 279 false)); |
| 280 registry->RegisterStringPref(prefs::kApplicationLocale, std::string()); |
| 293 // Right now, we only inherit the locale setting from the parent profile. | 281 // Right now, we only inherit the locale setting from the parent profile. |
| 294 local_state->SetString( | 282 local_state->SetString( |
| 295 prefs::kApplicationLocale, | 283 prefs::kApplicationLocale, |
| 296 parent_local_state->GetString(prefs::kApplicationLocale)); | 284 parent_local_state->GetString(prefs::kApplicationLocale)); |
| 297 } | 285 } |
| 298 | 286 |
| 299 #if defined(OS_CHROMEOS) | 287 #if defined(OS_CHROMEOS) |
| 300 if (parsed_command_line.HasSwitch(switches::kLoginManager)) { | 288 if (parsed_command_line.HasSwitch(switches::kLoginManager)) { |
| 301 std::string owner_locale = local_state->GetString(prefs::kOwnerLocale); | 289 std::string owner_locale = local_state->GetString(prefs::kOwnerLocale); |
| 302 // Ensure that we start with owner's locale. | 290 // Ensure that we start with owner's locale. |
| (...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1654 if (base::win::GetVersion() <= base::win::VERSION_XP) | 1642 if (base::win::GetVersion() <= base::win::VERSION_XP) |
| 1655 uma_name += "_XP"; | 1643 uma_name += "_XP"; |
| 1656 | 1644 |
| 1657 uma_name += "_PreRead_"; | 1645 uma_name += "_PreRead_"; |
| 1658 uma_name += pre_read_percentage; | 1646 uma_name += pre_read_percentage; |
| 1659 AddPreReadHistogramTime(uma_name.c_str(), time); | 1647 AddPreReadHistogramTime(uma_name.c_str(), time); |
| 1660 } | 1648 } |
| 1661 #endif | 1649 #endif |
| 1662 #endif | 1650 #endif |
| 1663 } | 1651 } |
| OLD | NEW |