| 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/browser/ui/webui/chrome_web_ui_controller_factory.h" | 95 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
| 95 #include "chrome/common/child_process_logging.h" | 96 #include "chrome/common/child_process_logging.h" |
| 96 #include "chrome/common/chrome_constants.h" | 97 #include "chrome/common/chrome_constants.h" |
| 97 #include "chrome/common/chrome_paths.h" | 98 #include "chrome/common/chrome_paths.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 // Returns the path that contains the profile that should be loaded |
| 316 // on process startup. |
| 317 FilePath GetStartupProfilePath(const FilePath& user_data_dir, |
| 318 const CommandLine& command_line) { |
| 319 #if defined(OS_CHROMEOS) |
| 320 // TODO(ivankr): http://crbug.com/83792 |
| 321 return g_browser_process->profile_manager()->GetDefaultProfileDir( |
| 322 user_data_dir); |
| 323 #endif |
| 324 |
| 325 if (command_line.HasSwitch(switches::kProfileDirectory)) { |
| 326 return user_data_dir.Append( |
| 327 command_line.GetSwitchValuePath(switches::kProfileDirectory)); |
| 328 } |
| 329 |
| 330 // If we are showing the app list then chrome isn't shown so load the app |
| 331 // list's profile rather than chrome's. |
| 332 if (command_line.HasSwitch(switches::kShowAppList)) |
| 333 return chrome::GetAppListProfilePath(user_data_dir); |
| 334 |
| 335 return g_browser_process->profile_manager()->GetLastUsedProfileDir( |
| 336 user_data_dir); |
| 337 } |
| 338 |
| 314 // Initializes the profile, possibly doing some user prompting to pick a | 339 // Initializes the profile, possibly doing some user prompting to pick a |
| 315 // fallback profile. Returns the newly created profile, or NULL if startup | 340 // fallback profile. Returns the newly created profile, or NULL if startup |
| 316 // should not continue. | 341 // should not continue. |
| 317 Profile* CreateProfile(const content::MainFunctionParams& parameters, | 342 Profile* CreateProfile(const content::MainFunctionParams& parameters, |
| 318 const FilePath& user_data_dir, | 343 const FilePath& user_data_dir, |
| 319 const CommandLine& parsed_command_line) { | 344 const CommandLine& parsed_command_line) { |
| 320 Profile* profile; | |
| 321 if (ProfileManager::IsMultipleProfilesEnabled() && | 345 if (ProfileManager::IsMultipleProfilesEnabled() && |
| 322 parsed_command_line.HasSwitch(switches::kProfileDirectory)) { | 346 parsed_command_line.HasSwitch(switches::kProfileDirectory)) { |
| 323 g_browser_process->local_state()->SetString(prefs::kProfileLastUsed, | 347 g_browser_process->local_state()->SetString(prefs::kProfileLastUsed, |
| 324 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); | 348 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); |
| 325 // Clear kProfilesLastActive since the user only wants to launch a specific | 349 // Clear kProfilesLastActive since the user only wants to launch a specific |
| 326 // profile. | 350 // profile. |
| 327 ListPrefUpdate update(g_browser_process->local_state(), | 351 ListPrefUpdate update(g_browser_process->local_state(), |
| 328 prefs::kProfilesLastActive); | 352 prefs::kProfilesLastActive); |
| 329 ListValue* profile_list = update.Get(); | 353 ListValue* profile_list = update.Get(); |
| 330 profile_list->Clear(); | 354 profile_list->Clear(); |
| 331 } | 355 } |
| 332 #if defined(OS_CHROMEOS) | 356 |
| 333 // TODO(ivankr): http://crbug.com/83792 | 357 FilePath profile_path = |
| 334 profile = g_browser_process->profile_manager()->GetDefaultProfile( | 358 GetStartupProfilePath(user_data_dir, parsed_command_line); |
| 335 user_data_dir); | 359 Profile* profile = g_browser_process->profile_manager()->GetProfile( |
| 336 #else | 360 profile_path); |
| 337 profile = g_browser_process->profile_manager()->GetLastUsedProfile( | |
| 338 user_data_dir); | |
| 339 #endif | |
| 340 if (profile) | 361 if (profile) |
| 341 return profile; | 362 return profile; |
| 342 | 363 |
| 343 #if defined(OS_WIN) | 364 #if defined(OS_WIN) |
| 344 #if defined(USE_AURA) | 365 #if defined(USE_AURA) |
| 345 // TODO(beng): | 366 // TODO(beng): |
| 346 NOTIMPLEMENTED(); | 367 NOTIMPLEMENTED(); |
| 347 #else | 368 #else |
| 348 // Ideally, we should be able to run w/o access to disk. For now, we | 369 // 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 | 370 // 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. | 444 // We should never be called before the profile has been created. |
| 424 NOTREACHED(); | 445 NOTREACHED(); |
| 425 return true; | 446 return true; |
| 426 } | 447 } |
| 427 | 448 |
| 428 extensions::StartupHelper extension_startup_helper; | 449 extensions::StartupHelper extension_startup_helper; |
| 429 extension_startup_helper.UninstallExtension(command_line, profile); | 450 extension_startup_helper.UninstallExtension(command_line, profile); |
| 430 return true; | 451 return true; |
| 431 } | 452 } |
| 432 | 453 |
| 454 FilePath user_data_dir = |
| 455 g_browser_process->profile_manager()->user_data_dir(); |
| 456 FilePath startup_profile_dir = |
| 457 GetStartupProfilePath(user_data_dir, command_line); |
| 458 |
| 433 StartupBrowserCreator::ProcessCommandLineAlreadyRunning( | 459 StartupBrowserCreator::ProcessCommandLineAlreadyRunning( |
| 434 command_line, current_directory); | 460 command_line, current_directory, startup_profile_dir); |
| 435 return true; | 461 return true; |
| 436 } | 462 } |
| 437 | 463 |
| 438 void LaunchDevToolsHandlerIfNeeded(Profile* profile, | 464 void LaunchDevToolsHandlerIfNeeded(Profile* profile, |
| 439 const CommandLine& command_line) { | 465 const CommandLine& command_line) { |
| 440 if (command_line.HasSwitch(::switches::kRemoteDebuggingPort)) { | 466 if (command_line.HasSwitch(::switches::kRemoteDebuggingPort)) { |
| 441 std::string port_str = | 467 std::string port_str = |
| 442 command_line.GetSwitchValueASCII(::switches::kRemoteDebuggingPort); | 468 command_line.GetSwitchValueASCII(::switches::kRemoteDebuggingPort); |
| 443 int port; | 469 int port; |
| 444 if (base::StringToInt(port_str, &port) && port > 0 && port < 65535) { | 470 if (base::StringToInt(port_str, &port) && port > 0 && port < 65535) { |
| (...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 if (base::win::GetVersion() <= base::win::VERSION_XP) | 1675 if (base::win::GetVersion() <= base::win::VERSION_XP) |
| 1650 uma_name += "_XP"; | 1676 uma_name += "_XP"; |
| 1651 | 1677 |
| 1652 uma_name += "_PreRead_"; | 1678 uma_name += "_PreRead_"; |
| 1653 uma_name += pre_read_percentage; | 1679 uma_name += pre_read_percentage; |
| 1654 AddPreReadHistogramTime(uma_name.c_str(), time); | 1680 AddPreReadHistogramTime(uma_name.c_str(), time); |
| 1655 } | 1681 } |
| 1656 #endif | 1682 #endif |
| 1657 #endif | 1683 #endif |
| 1658 } | 1684 } |
| OLD | NEW |