OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser_main.h" | 5 #include "chrome/browser/browser_main.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 policy->Release(); | 890 policy->Release(); |
891 } | 891 } |
892 } | 892 } |
893 #endif | 893 #endif |
894 } | 894 } |
895 | 895 |
896 // Initializes the profile, possibly doing some user prompting to pick a | 896 // Initializes the profile, possibly doing some user prompting to pick a |
897 // fallback profile. Returns the newly created profile, or NULL if startup | 897 // fallback profile. Returns the newly created profile, or NULL if startup |
898 // should not continue. | 898 // should not continue. |
899 Profile* CreateProfile(const MainFunctionParams& parameters, | 899 Profile* CreateProfile(const MainFunctionParams& parameters, |
900 const FilePath& user_data_dir) { | 900 const FilePath& user_data_dir, |
901 Profile* profile = ProfileManager::IsMultipleProfilesEnabled() ? | 901 const CommandLine& parsed_command_line) { |
902 g_browser_process->profile_manager()->GetLastUsedProfile(user_data_dir) : | 902 Profile* profile; |
903 g_browser_process->profile_manager()->GetDefaultProfile(user_data_dir); | 903 if (ProfileManager::IsMultipleProfilesEnabled()) { |
| 904 if (parsed_command_line.HasSwitch(switches::kProfileDirectory)) { |
| 905 g_browser_process->local_state()->SetString(prefs::kProfileLastUsed, |
| 906 parsed_command_line.GetSwitchValueASCII( |
| 907 switches::kProfileDirectory)); |
| 908 } |
| 909 profile = g_browser_process->profile_manager()->GetLastUsedProfile( |
| 910 user_data_dir); |
| 911 } else { |
| 912 profile = g_browser_process->profile_manager()->GetDefaultProfile( |
| 913 user_data_dir); |
| 914 } |
| 915 |
904 if (profile) | 916 if (profile) |
905 return profile; | 917 return profile; |
906 | 918 |
907 #if defined(OS_WIN) | 919 #if defined(OS_WIN) |
908 // Ideally, we should be able to run w/o access to disk. For now, we | 920 // Ideally, we should be able to run w/o access to disk. For now, we |
909 // prompt the user to pick a different user-data-dir and restart chrome | 921 // prompt the user to pick a different user-data-dir and restart chrome |
910 // with the new dir. | 922 // with the new dir. |
911 // http://code.google.com/p/chromium/issues/detail?id=11510 | 923 // http://code.google.com/p/chromium/issues/detail?id=11510 |
912 FilePath new_user_data_dir = UserDataDirDialog::RunUserDataDirDialog( | 924 FilePath new_user_data_dir = UserDataDirDialog::RunUserDataDirDialog( |
913 user_data_dir); | 925 user_data_dir); |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1649 std::string username = | 1661 std::string username = |
1650 parsed_command_line.GetSwitchValueASCII(switches::kLoginUser); | 1662 parsed_command_line.GetSwitchValueASCII(switches::kLoginUser); |
1651 VLOG(1) << "Relaunching browser for user: " << username; | 1663 VLOG(1) << "Relaunching browser for user: " << username; |
1652 chromeos::UserManager::Get()->UserLoggedIn(username); | 1664 chromeos::UserManager::Get()->UserLoggedIn(username); |
1653 | 1665 |
1654 // Redirects Chrome logging to the user data dir. | 1666 // Redirects Chrome logging to the user data dir. |
1655 logging::RedirectChromeLogging(parsed_command_line); | 1667 logging::RedirectChromeLogging(parsed_command_line); |
1656 } | 1668 } |
1657 #endif | 1669 #endif |
1658 | 1670 |
1659 Profile* profile = CreateProfile(parameters, user_data_dir); | 1671 Profile* profile = CreateProfile(parameters, user_data_dir, |
| 1672 parsed_command_line); |
1660 if (!profile) | 1673 if (!profile) |
1661 return content::RESULT_CODE_NORMAL_EXIT; | 1674 return content::RESULT_CODE_NORMAL_EXIT; |
1662 | 1675 |
1663 // Post-profile init --------------------------------------------------------- | 1676 // Post-profile init --------------------------------------------------------- |
1664 | 1677 |
1665 #if defined(OS_CHROMEOS) | 1678 #if defined(OS_CHROMEOS) |
1666 // Handling the user cloud policy initialization for case 2 mentioned above. | 1679 // Handling the user cloud policy initialization for case 2 mentioned above. |
1667 // We do this after the profile creation since we need the TokenService. | 1680 // We do this after the profile creation since we need the TokenService. |
1668 if (parsed_command_line.HasSwitch(switches::kLoginUser) && | 1681 if (parsed_command_line.HasSwitch(switches::kLoginUser) && |
1669 !parsed_command_line.HasSwitch(switches::kLoginPassword)) { | 1682 !parsed_command_line.HasSwitch(switches::kLoginPassword)) { |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2086 #if defined(OS_CHROMEOS) | 2099 #if defined(OS_CHROMEOS) |
2087 // To be precise, logout (browser shutdown) is not yet done, but the | 2100 // To be precise, logout (browser shutdown) is not yet done, but the |
2088 // remaining work is negligible, hence we say LogoutDone here. | 2101 // remaining work is negligible, hence we say LogoutDone here. |
2089 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 2102 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
2090 false); | 2103 false); |
2091 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 2104 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
2092 #endif | 2105 #endif |
2093 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); | 2106 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); |
2094 return result_code; | 2107 return result_code; |
2095 } | 2108 } |
OLD | NEW |