| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 local_state->GetString(prefs::kApplicationLocale) != owner_locale && | 305 local_state->GetString(prefs::kApplicationLocale) != owner_locale && |
| 305 !local_state->IsManagedPreference(prefs::kApplicationLocale)) { | 306 !local_state->IsManagedPreference(prefs::kApplicationLocale)) { |
| 306 local_state->SetString(prefs::kApplicationLocale, owner_locale); | 307 local_state->SetString(prefs::kApplicationLocale, owner_locale); |
| 307 } | 308 } |
| 308 } | 309 } |
| 309 #endif | 310 #endif |
| 310 | 311 |
| 311 return local_state; | 312 return local_state; |
| 312 } | 313 } |
| 313 | 314 |
| 315 FilePath GetStartupProfilePath(const FilePath& user_data_dir, |
| 316 const CommandLine& command_line) { |
| 317 #if defined(OS_CHROMEOS) |
| 318 // TODO(ivankr): http://crbug.com/83792 |
| 319 return g_browser_process->profile_manager()->GetDefaultProfileDir( |
| 320 user_data_dir); |
| 321 #endif |
| 322 |
| 323 if (command_line.HasSwitch(switches::kProfileDirectory)) { |
| 324 return user_data_dir.Append( |
| 325 command_line.GetSwitchValuePath(switches::kProfileDirectory)); |
| 326 } |
| 327 |
| 328 if (command_line.HasSwitch(switches::kShowAppList)) |
| 329 return chrome::GetAppListProfilePath(user_data_dir); |
| 330 |
| 331 return g_browser_process->profile_manager()->GetLastUsedProfilePath( |
| 332 user_data_dir); |
| 333 } |
| 334 |
| 314 // Initializes the profile, possibly doing some user prompting to pick a | 335 // Initializes the profile, possibly doing some user prompting to pick a |
| 315 // fallback profile. Returns the newly created profile, or NULL if startup | 336 // fallback profile. Returns the newly created profile, or NULL if startup |
| 316 // should not continue. | 337 // should not continue. |
| 317 Profile* CreateProfile(const content::MainFunctionParams& parameters, | 338 Profile* CreateProfile(const content::MainFunctionParams& parameters, |
| 318 const FilePath& user_data_dir, | 339 const FilePath& user_data_dir, |
| 319 const CommandLine& parsed_command_line) { | 340 const CommandLine& parsed_command_line) { |
| 320 Profile* profile; | |
| 321 if (ProfileManager::IsMultipleProfilesEnabled() && | 341 if (ProfileManager::IsMultipleProfilesEnabled() && |
| 322 parsed_command_line.HasSwitch(switches::kProfileDirectory)) { | 342 parsed_command_line.HasSwitch(switches::kProfileDirectory)) { |
| 323 g_browser_process->local_state()->SetString(prefs::kProfileLastUsed, | 343 g_browser_process->local_state()->SetString(prefs::kProfileLastUsed, |
| 324 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); | 344 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); |
| 325 // Clear kProfilesLastActive since the user only wants to launch a specific | 345 // Clear kProfilesLastActive since the user only wants to launch a specific |
| 326 // profile. | 346 // profile. |
| 327 ListPrefUpdate update(g_browser_process->local_state(), | 347 ListPrefUpdate update(g_browser_process->local_state(), |
| 328 prefs::kProfilesLastActive); | 348 prefs::kProfilesLastActive); |
| 329 ListValue* profile_list = update.Get(); | 349 ListValue* profile_list = update.Get(); |
| 330 profile_list->Clear(); | 350 profile_list->Clear(); |
| 331 } | 351 } |
| 332 #if defined(OS_CHROMEOS) | 352 |
| 333 // TODO(ivankr): http://crbug.com/83792 | 353 FilePath profile_path = |
| 334 profile = g_browser_process->profile_manager()->GetDefaultProfile( | 354 GetStartupProfilePath(user_data_dir, parsed_command_line); |
| 335 user_data_dir); | 355 Profile* profile = g_browser_process->profile_manager()->GetProfile( |
| 336 #else | 356 profile_path); |
| 337 profile = g_browser_process->profile_manager()->GetLastUsedProfile( | |
| 338 user_data_dir); | |
| 339 #endif | |
| 340 if (profile) | 357 if (profile) |
| 341 return profile; | 358 return profile; |
| 342 | 359 |
| 343 #if defined(OS_WIN) | 360 #if defined(OS_WIN) |
| 344 #if defined(USE_AURA) | 361 #if defined(USE_AURA) |
| 345 // TODO(beng): | 362 // TODO(beng): |
| 346 NOTIMPLEMENTED(); | 363 NOTIMPLEMENTED(); |
| 347 #else | 364 #else |
| 348 // Ideally, we should be able to run w/o access to disk. For now, we | 365 // Ideally, we should be able to run w/o access to disk. For now, we |
| 349 // prompt the user to pick a different user-data-dir and restart chrome | 366 // 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... |
| 423 // We should never be called before the profile has been created. | 440 // We should never be called before the profile has been created. |
| 424 NOTREACHED(); | 441 NOTREACHED(); |
| 425 return true; | 442 return true; |
| 426 } | 443 } |
| 427 | 444 |
| 428 extensions::StartupHelper extension_startup_helper; | 445 extensions::StartupHelper extension_startup_helper; |
| 429 extension_startup_helper.UninstallExtension(command_line, profile); | 446 extension_startup_helper.UninstallExtension(command_line, profile); |
| 430 return true; | 447 return true; |
| 431 } | 448 } |
| 432 | 449 |
| 450 FilePath user_data_dir = |
| 451 g_browser_process->profile_manager()->user_data_dir(); |
| 452 FilePath startup_profile_dir = |
| 453 GetStartupProfilePath(user_data_dir, command_line); |
| 454 |
| 433 StartupBrowserCreator::ProcessCommandLineAlreadyRunning( | 455 StartupBrowserCreator::ProcessCommandLineAlreadyRunning( |
| 434 command_line, current_directory); | 456 command_line, current_directory, startup_profile_dir); |
| 435 return true; | 457 return true; |
| 436 } | 458 } |
| 437 | 459 |
| 438 void LaunchDevToolsHandlerIfNeeded(Profile* profile, | 460 void LaunchDevToolsHandlerIfNeeded(Profile* profile, |
| 439 const CommandLine& command_line) { | 461 const CommandLine& command_line) { |
| 440 if (command_line.HasSwitch(::switches::kRemoteDebuggingPort)) { | 462 if (command_line.HasSwitch(::switches::kRemoteDebuggingPort)) { |
| 441 std::string port_str = | 463 std::string port_str = |
| 442 command_line.GetSwitchValueASCII(::switches::kRemoteDebuggingPort); | 464 command_line.GetSwitchValueASCII(::switches::kRemoteDebuggingPort); |
| 443 int port; | 465 int port; |
| 444 if (base::StringToInt(port_str, &port) && port > 0 && port < 65535) { | 466 if (base::StringToInt(port_str, &port) && port > 0 && port < 65535) { |
| (...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1665 if (base::win::GetVersion() <= base::win::VERSION_XP) | 1687 if (base::win::GetVersion() <= base::win::VERSION_XP) |
| 1666 uma_name += "_XP"; | 1688 uma_name += "_XP"; |
| 1667 | 1689 |
| 1668 uma_name += "_PreRead_"; | 1690 uma_name += "_PreRead_"; |
| 1669 uma_name += pre_read_percentage; | 1691 uma_name += pre_read_percentage; |
| 1670 AddPreReadHistogramTime(uma_name.c_str(), time); | 1692 AddPreReadHistogramTime(uma_name.c_str(), time); |
| 1671 } | 1693 } |
| 1672 #endif | 1694 #endif |
| 1673 #endif | 1695 #endif |
| 1674 } | 1696 } |
| OLD | NEW |