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