| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 #include "chrome/browser/profiles/profile.h" | 78 #include "chrome/browser/profiles/profile.h" |
| 79 #include "chrome/browser/profiles/profile_manager.h" | 79 #include "chrome/browser/profiles/profile_manager.h" |
| 80 #include "chrome/browser/search_engines/search_engine_type.h" | 80 #include "chrome/browser/search_engines/search_engine_type.h" |
| 81 #include "chrome/browser/search_engines/template_url.h" | 81 #include "chrome/browser/search_engines/template_url.h" |
| 82 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 82 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
| 83 #include "chrome/browser/search_engines/template_url_service.h" | 83 #include "chrome/browser/search_engines/template_url_service.h" |
| 84 #include "chrome/browser/search_engines/template_url_service_factory.h" | 84 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 85 #include "chrome/browser/service/service_process_control.h" | 85 #include "chrome/browser/service/service_process_control.h" |
| 86 #include "chrome/browser/shell_integration.h" | 86 #include "chrome/browser/shell_integration.h" |
| 87 #include "chrome/browser/translate/translate_manager.h" | 87 #include "chrome/browser/translate/translate_manager.h" |
| 88 #include "chrome/browser/ui/app_list/app_list_util.h" |
| 88 #include "chrome/browser/ui/browser.h" | 89 #include "chrome/browser/ui/browser.h" |
| 89 #include "chrome/browser/ui/browser_finder.h" | 90 #include "chrome/browser/ui/browser_finder.h" |
| 90 #include "chrome/browser/ui/startup/default_browser_prompt.h" | 91 #include "chrome/browser/ui/startup/default_browser_prompt.h" |
| 91 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 92 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 92 #include "chrome/browser/ui/uma_browsing_activity_observer.h" | 93 #include "chrome/browser/ui/uma_browsing_activity_observer.h" |
| 93 #include "chrome/browser/ui/user_data_dir_dialog.h" | 94 #include "chrome/browser/ui/user_data_dir_dialog.h" |
| 94 #include "chrome/common/child_process_logging.h" | 95 #include "chrome/common/child_process_logging.h" |
| 95 #include "chrome/common/chrome_constants.h" | 96 #include "chrome/common/chrome_constants.h" |
| 96 #include "chrome/common/chrome_paths.h" | 97 #include "chrome/common/chrome_paths.h" |
| 97 #include "chrome/common/chrome_result_codes.h" | 98 #include "chrome/common/chrome_result_codes.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 local_state->GetString(prefs::kApplicationLocale) != owner_locale && | 304 local_state->GetString(prefs::kApplicationLocale) != owner_locale && |
| 304 !local_state->IsManagedPreference(prefs::kApplicationLocale)) { | 305 !local_state->IsManagedPreference(prefs::kApplicationLocale)) { |
| 305 local_state->SetString(prefs::kApplicationLocale, owner_locale); | 306 local_state->SetString(prefs::kApplicationLocale, owner_locale); |
| 306 } | 307 } |
| 307 } | 308 } |
| 308 #endif | 309 #endif |
| 309 | 310 |
| 310 return local_state; | 311 return local_state; |
| 311 } | 312 } |
| 312 | 313 |
| 314 // Returns the path that contains the profile that should be loaded |
| 315 // on process startup. |
| 316 FilePath GetStartupProfilePath(const FilePath& user_data_dir, |
| 317 const CommandLine& command_line) { |
| 318 #if defined(OS_CHROMEOS) |
| 319 // TODO(ivankr): http://crbug.com/83792 |
| 320 return g_browser_process->profile_manager()->GetDefaultProfileDir( |
| 321 user_data_dir); |
| 322 #endif |
| 323 |
| 324 if (command_line.HasSwitch(switches::kProfileDirectory)) { |
| 325 return user_data_dir.Append( |
| 326 command_line.GetSwitchValuePath(switches::kProfileDirectory)); |
| 327 } |
| 328 |
| 329 // If we are showing the app list then chrome isn't shown so load the app |
| 330 // list's profile rather than chrome's. |
| 331 if (command_line.HasSwitch(switches::kShowAppList)) |
| 332 return chrome::GetAppListProfilePath(user_data_dir); |
| 333 |
| 334 return g_browser_process->profile_manager()->GetLastUsedProfileDir( |
| 335 user_data_dir); |
| 336 } |
| 337 |
| 313 // Initializes the profile, possibly doing some user prompting to pick a | 338 // Initializes the profile, possibly doing some user prompting to pick a |
| 314 // fallback profile. Returns the newly created profile, or NULL if startup | 339 // fallback profile. Returns the newly created profile, or NULL if startup |
| 315 // should not continue. | 340 // should not continue. |
| 316 Profile* CreateProfile(const content::MainFunctionParams& parameters, | 341 Profile* CreateProfile(const content::MainFunctionParams& parameters, |
| 317 const FilePath& user_data_dir, | 342 const FilePath& user_data_dir, |
| 318 const CommandLine& parsed_command_line) { | 343 const CommandLine& parsed_command_line) { |
| 319 Profile* profile; | |
| 320 if (ProfileManager::IsMultipleProfilesEnabled() && | 344 if (ProfileManager::IsMultipleProfilesEnabled() && |
| 321 parsed_command_line.HasSwitch(switches::kProfileDirectory)) { | 345 parsed_command_line.HasSwitch(switches::kProfileDirectory)) { |
| 322 g_browser_process->local_state()->SetString(prefs::kProfileLastUsed, | 346 g_browser_process->local_state()->SetString(prefs::kProfileLastUsed, |
| 323 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); | 347 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); |
| 324 // Clear kProfilesLastActive since the user only wants to launch a specific | 348 // Clear kProfilesLastActive since the user only wants to launch a specific |
| 325 // profile. | 349 // profile. |
| 326 ListPrefUpdate update(g_browser_process->local_state(), | 350 ListPrefUpdate update(g_browser_process->local_state(), |
| 327 prefs::kProfilesLastActive); | 351 prefs::kProfilesLastActive); |
| 328 ListValue* profile_list = update.Get(); | 352 ListValue* profile_list = update.Get(); |
| 329 profile_list->Clear(); | 353 profile_list->Clear(); |
| 330 } | 354 } |
| 331 #if defined(OS_CHROMEOS) | 355 |
| 332 // TODO(ivankr): http://crbug.com/83792 | 356 FilePath profile_path = |
| 333 profile = g_browser_process->profile_manager()->GetDefaultProfile( | 357 GetStartupProfilePath(user_data_dir, parsed_command_line); |
| 334 user_data_dir); | 358 Profile* profile = g_browser_process->profile_manager()->GetProfile( |
| 335 #else | 359 profile_path); |
| 336 profile = g_browser_process->profile_manager()->GetLastUsedProfile( | |
| 337 user_data_dir); | |
| 338 #endif | |
| 339 if (profile) | 360 if (profile) |
| 340 return profile; | 361 return profile; |
| 341 | 362 |
| 342 #if defined(OS_WIN) | 363 #if defined(OS_WIN) |
| 343 #if defined(USE_AURA) | 364 #if defined(USE_AURA) |
| 344 // TODO(beng): | 365 // TODO(beng): |
| 345 NOTIMPLEMENTED(); | 366 NOTIMPLEMENTED(); |
| 346 #else | 367 #else |
| 347 // Ideally, we should be able to run w/o access to disk. For now, we | 368 // Ideally, we should be able to run w/o access to disk. For now, we |
| 348 // prompt the user to pick a different user-data-dir and restart chrome | 369 // prompt the user to pick a different user-data-dir and restart chrome |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 // We should never be called before the profile has been created. | 443 // We should never be called before the profile has been created. |
| 423 NOTREACHED(); | 444 NOTREACHED(); |
| 424 return true; | 445 return true; |
| 425 } | 446 } |
| 426 | 447 |
| 427 extensions::StartupHelper extension_startup_helper; | 448 extensions::StartupHelper extension_startup_helper; |
| 428 extension_startup_helper.UninstallExtension(command_line, profile); | 449 extension_startup_helper.UninstallExtension(command_line, profile); |
| 429 return true; | 450 return true; |
| 430 } | 451 } |
| 431 | 452 |
| 453 FilePath user_data_dir = |
| 454 g_browser_process->profile_manager()->user_data_dir(); |
| 455 FilePath startup_profile_dir = |
| 456 GetStartupProfilePath(user_data_dir, command_line); |
| 457 |
| 432 StartupBrowserCreator::ProcessCommandLineAlreadyRunning( | 458 StartupBrowserCreator::ProcessCommandLineAlreadyRunning( |
| 433 command_line, current_directory); | 459 command_line, current_directory, startup_profile_dir); |
| 434 return true; | 460 return true; |
| 435 } | 461 } |
| 436 | 462 |
| 437 void LaunchDevToolsHandlerIfNeeded(Profile* profile, | 463 void LaunchDevToolsHandlerIfNeeded(Profile* profile, |
| 438 const CommandLine& command_line) { | 464 const CommandLine& command_line) { |
| 439 if (command_line.HasSwitch(::switches::kRemoteDebuggingPort)) { | 465 if (command_line.HasSwitch(::switches::kRemoteDebuggingPort)) { |
| 440 std::string port_str = | 466 std::string port_str = |
| 441 command_line.GetSwitchValueASCII(::switches::kRemoteDebuggingPort); | 467 command_line.GetSwitchValueASCII(::switches::kRemoteDebuggingPort); |
| 442 int port; | 468 int port; |
| 443 if (base::StringToInt(port_str, &port) && port > 0 && port < 65535) { | 469 if (base::StringToInt(port_str, &port) && port > 0 && port < 65535) { |
| (...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1643 if (base::win::GetVersion() <= base::win::VERSION_XP) | 1669 if (base::win::GetVersion() <= base::win::VERSION_XP) |
| 1644 uma_name += "_XP"; | 1670 uma_name += "_XP"; |
| 1645 | 1671 |
| 1646 uma_name += "_PreRead_"; | 1672 uma_name += "_PreRead_"; |
| 1647 uma_name += pre_read_percentage; | 1673 uma_name += pre_read_percentage; |
| 1648 AddPreReadHistogramTime(uma_name.c_str(), time); | 1674 AddPreReadHistogramTime(uma_name.c_str(), time); |
| 1649 } | 1675 } |
| 1650 #endif | 1676 #endif |
| 1651 #endif | 1677 #endif |
| 1652 } | 1678 } |
| OLD | NEW |