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