Chromium Code Reviews| 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 FilePath GetStartupProfilePath(const FilePath& user_data_dir, | |
|
sky
2013/01/22 23:56:18
Add description.
koz (OOO until 15th September)
2013/01/23 00:07:55
Done.
| |
| 315 const CommandLine& command_line) { | |
| 316 #if defined(OS_CHROMEOS) | |
| 317 // TODO(ivankr): http://crbug.com/83792 | |
| 318 return g_browser_process->profile_manager()->GetDefaultProfileDir( | |
| 319 user_data_dir); | |
| 320 #endif | |
| 321 | |
| 322 if (command_line.HasSwitch(switches::kProfileDirectory)) { | |
| 323 return user_data_dir.Append( | |
| 324 command_line.GetSwitchValuePath(switches::kProfileDirectory)); | |
| 325 } | |
| 326 | |
| 327 if (command_line.HasSwitch(switches::kShowAppList)) | |
| 328 return chrome::GetAppListProfilePath(user_data_dir); | |
| 329 | |
| 330 return g_browser_process->profile_manager()->GetLastUsedProfilePath( | |
| 331 user_data_dir); | |
| 332 } | |
| 333 | |
| 313 // Initializes the profile, possibly doing some user prompting to pick a | 334 // Initializes the profile, possibly doing some user prompting to pick a |
| 314 // fallback profile. Returns the newly created profile, or NULL if startup | 335 // fallback profile. Returns the newly created profile, or NULL if startup |
| 315 // should not continue. | 336 // should not continue. |
| 316 Profile* CreateProfile(const content::MainFunctionParams& parameters, | 337 Profile* CreateProfile(const content::MainFunctionParams& parameters, |
| 317 const FilePath& user_data_dir, | 338 const FilePath& user_data_dir, |
| 318 const CommandLine& parsed_command_line) { | 339 const CommandLine& parsed_command_line) { |
| 319 Profile* profile; | |
| 320 if (ProfileManager::IsMultipleProfilesEnabled() && | 340 if (ProfileManager::IsMultipleProfilesEnabled() && |
| 321 parsed_command_line.HasSwitch(switches::kProfileDirectory)) { | 341 parsed_command_line.HasSwitch(switches::kProfileDirectory)) { |
| 322 g_browser_process->local_state()->SetString(prefs::kProfileLastUsed, | 342 g_browser_process->local_state()->SetString(prefs::kProfileLastUsed, |
| 323 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); | 343 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); |
| 324 // Clear kProfilesLastActive since the user only wants to launch a specific | 344 // Clear kProfilesLastActive since the user only wants to launch a specific |
| 325 // profile. | 345 // profile. |
| 326 ListPrefUpdate update(g_browser_process->local_state(), | 346 ListPrefUpdate update(g_browser_process->local_state(), |
| 327 prefs::kProfilesLastActive); | 347 prefs::kProfilesLastActive); |
| 328 ListValue* profile_list = update.Get(); | 348 ListValue* profile_list = update.Get(); |
| 329 profile_list->Clear(); | 349 profile_list->Clear(); |
| 330 } | 350 } |
| 331 #if defined(OS_CHROMEOS) | 351 |
| 332 // TODO(ivankr): http://crbug.com/83792 | 352 FilePath profile_path = |
| 333 profile = g_browser_process->profile_manager()->GetDefaultProfile( | 353 GetStartupProfilePath(user_data_dir, parsed_command_line); |
| 334 user_data_dir); | 354 Profile* profile = g_browser_process->profile_manager()->GetProfile( |
| 335 #else | 355 profile_path); |
| 336 profile = g_browser_process->profile_manager()->GetLastUsedProfile( | |
| 337 user_data_dir); | |
| 338 #endif | |
| 339 if (profile) | 356 if (profile) |
| 340 return profile; | 357 return profile; |
| 341 | 358 |
| 342 #if defined(OS_WIN) | 359 #if defined(OS_WIN) |
| 343 #if defined(USE_AURA) | 360 #if defined(USE_AURA) |
| 344 // TODO(beng): | 361 // TODO(beng): |
| 345 NOTIMPLEMENTED(); | 362 NOTIMPLEMENTED(); |
| 346 #else | 363 #else |
| 347 // Ideally, we should be able to run w/o access to disk. For now, we | 364 // 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 | 365 // 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. | 439 // We should never be called before the profile has been created. |
| 423 NOTREACHED(); | 440 NOTREACHED(); |
| 424 return true; | 441 return true; |
| 425 } | 442 } |
| 426 | 443 |
| 427 extensions::StartupHelper extension_startup_helper; | 444 extensions::StartupHelper extension_startup_helper; |
| 428 extension_startup_helper.UninstallExtension(command_line, profile); | 445 extension_startup_helper.UninstallExtension(command_line, profile); |
| 429 return true; | 446 return true; |
| 430 } | 447 } |
| 431 | 448 |
| 449 FilePath user_data_dir = | |
| 450 g_browser_process->profile_manager()->user_data_dir(); | |
| 451 FilePath startup_profile_dir = | |
| 452 GetStartupProfilePath(user_data_dir, command_line); | |
| 453 | |
| 432 StartupBrowserCreator::ProcessCommandLineAlreadyRunning( | 454 StartupBrowserCreator::ProcessCommandLineAlreadyRunning( |
| 433 command_line, current_directory); | 455 command_line, current_directory, startup_profile_dir); |
| 434 return true; | 456 return true; |
| 435 } | 457 } |
| 436 | 458 |
| 437 void LaunchDevToolsHandlerIfNeeded(Profile* profile, | 459 void LaunchDevToolsHandlerIfNeeded(Profile* profile, |
| 438 const CommandLine& command_line) { | 460 const CommandLine& command_line) { |
| 439 if (command_line.HasSwitch(::switches::kRemoteDebuggingPort)) { | 461 if (command_line.HasSwitch(::switches::kRemoteDebuggingPort)) { |
| 440 std::string port_str = | 462 std::string port_str = |
| 441 command_line.GetSwitchValueASCII(::switches::kRemoteDebuggingPort); | 463 command_line.GetSwitchValueASCII(::switches::kRemoteDebuggingPort); |
| 442 int port; | 464 int port; |
| 443 if (base::StringToInt(port_str, &port) && port > 0 && port < 65535) { | 465 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) | 1665 if (base::win::GetVersion() <= base::win::VERSION_XP) |
| 1644 uma_name += "_XP"; | 1666 uma_name += "_XP"; |
| 1645 | 1667 |
| 1646 uma_name += "_PreRead_"; | 1668 uma_name += "_PreRead_"; |
| 1647 uma_name += pre_read_percentage; | 1669 uma_name += pre_read_percentage; |
| 1648 AddPreReadHistogramTime(uma_name.c_str(), time); | 1670 AddPreReadHistogramTime(uma_name.c_str(), time); |
| 1649 } | 1671 } |
| 1650 #endif | 1672 #endif |
| 1651 #endif | 1673 #endif |
| 1652 } | 1674 } |
| OLD | NEW |