| 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 // list's profile rather than chrome's. | 313 // list's profile rather than chrome's. |
| 314 if (command_line.HasSwitch(switches::kShowAppList)) { | 314 if (command_line.HasSwitch(switches::kShowAppList)) { |
| 315 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> | 315 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> |
| 316 GetProfilePath(user_data_dir); | 316 GetProfilePath(user_data_dir); |
| 317 } | 317 } |
| 318 | 318 |
| 319 return g_browser_process->profile_manager()->GetLastUsedProfileDir( | 319 return g_browser_process->profile_manager()->GetLastUsedProfileDir( |
| 320 user_data_dir); | 320 user_data_dir); |
| 321 } | 321 } |
| 322 | 322 |
| 323 // Initializes the profile, possibly doing some user prompting to pick a | 323 // Initializes the primary profile, possibly doing some user prompting to pick |
| 324 // fallback profile. Returns the newly created profile, or NULL if startup | 324 // a fallback profile. Returns the newly created profile, or NULL if startup |
| 325 // should not continue. | 325 // should not continue. |
| 326 Profile* CreateProfile(const content::MainFunctionParams& parameters, | 326 Profile* CreatePrimaryProfile(const content::MainFunctionParams& parameters, |
| 327 const base::FilePath& user_data_dir, | 327 const base::FilePath& user_data_dir, |
| 328 const CommandLine& parsed_command_line) { | 328 const CommandLine& parsed_command_line) { |
| 329 TRACE_EVENT0("startup", "ChromeBrowserMainParts::CreateProfile") | 329 TRACE_EVENT0("startup", "ChromeBrowserMainParts::CreateProfile") |
| 330 base::Time start = base::Time::Now(); | 330 base::Time start = base::Time::Now(); |
| 331 if (profiles::IsMultipleProfilesEnabled() && | 331 if (profiles::IsMultipleProfilesEnabled() && |
| 332 parsed_command_line.HasSwitch(switches::kProfileDirectory)) { | 332 parsed_command_line.HasSwitch(switches::kProfileDirectory)) { |
| 333 g_browser_process->local_state()->SetString(prefs::kProfileLastUsed, | 333 g_browser_process->local_state()->SetString(prefs::kProfileLastUsed, |
| 334 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); | 334 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); |
| 335 // Clear kProfilesLastActive since the user only wants to launch a specific | 335 // Clear kProfilesLastActive since the user only wants to launch a specific |
| 336 // profile. | 336 // profile. |
| 337 ListPrefUpdate update(g_browser_process->local_state(), | 337 ListPrefUpdate update(g_browser_process->local_state(), |
| 338 prefs::kProfilesLastActive); | 338 prefs::kProfilesLastActive); |
| 339 base::ListValue* profile_list = update.Get(); | 339 base::ListValue* profile_list = update.Get(); |
| 340 profile_list->Clear(); | 340 profile_list->Clear(); |
| 341 } | 341 } |
| 342 | 342 |
| 343 Profile* profile = NULL; | 343 Profile* profile = NULL; |
| 344 #if defined(OS_CHROMEOS) | 344 #if defined(OS_CHROMEOS) |
| 345 // TODO(ivankr): http://crbug.com/83792 | 345 // On ChromeOS the ProfileManager will use the same path as the one we got |
| 346 profile = g_browser_process->profile_manager()->GetDefaultProfile( | 346 // passed. GetActiveUserProfile will therefore use the correct path |
| 347 user_data_dir); | 347 // automatically. |
| 348 DCHECK_EQ(user_data_dir.value(), |
| 349 g_browser_process->profile_manager()->user_data_dir().value()); |
| 350 profile = ProfileManager::GetActiveUserProfile(); |
| 348 #else | 351 #else |
| 349 base::FilePath profile_path = | 352 base::FilePath profile_path = |
| 350 GetStartupProfilePath(user_data_dir, parsed_command_line); | 353 GetStartupProfilePath(user_data_dir, parsed_command_line); |
| 351 profile = g_browser_process->profile_manager()->GetProfile( | 354 profile = g_browser_process->profile_manager()->GetProfile( |
| 352 profile_path); | 355 profile_path); |
| 353 | 356 |
| 354 // If we're using the --new-profile-management flag and this profile is | 357 // If we're using the --new-profile-management flag and this profile is |
| 355 // signed out, then we should show the user manager instead. By switching | 358 // signed out, then we should show the user manager instead. By switching |
| 356 // the active profile to the guest profile we ensure that no | 359 // the active profile to the guest profile we ensure that no |
| 357 // browser windows will be opened for the guest profile. | 360 // browser windows will be opened for the guest profile. |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 } | 1245 } |
| 1243 #else | 1246 #else |
| 1244 // We don't support retention experiments on Mac or Linux. | 1247 // We don't support retention experiments on Mac or Linux. |
| 1245 return content::RESULT_CODE_NORMAL_EXIT; | 1248 return content::RESULT_CODE_NORMAL_EXIT; |
| 1246 #endif // defined(OS_WIN) | 1249 #endif // defined(OS_WIN) |
| 1247 } | 1250 } |
| 1248 | 1251 |
| 1249 // Profile creation ---------------------------------------------------------- | 1252 // Profile creation ---------------------------------------------------------- |
| 1250 | 1253 |
| 1251 MetricsService::SetExecutionPhase(MetricsService::CREATE_PROFILE); | 1254 MetricsService::SetExecutionPhase(MetricsService::CREATE_PROFILE); |
| 1252 profile_ = CreateProfile(parameters(), user_data_dir_, parsed_command_line()); | 1255 profile_ = CreatePrimaryProfile(parameters(), |
| 1256 user_data_dir_, |
| 1257 parsed_command_line()); |
| 1253 if (!profile_) | 1258 if (!profile_) |
| 1254 return content::RESULT_CODE_NORMAL_EXIT; | 1259 return content::RESULT_CODE_NORMAL_EXIT; |
| 1255 | 1260 |
| 1256 #if defined(ENABLE_BACKGROUND) | 1261 #if defined(ENABLE_BACKGROUND) |
| 1257 // Autoload any profiles which are running background apps. | 1262 // Autoload any profiles which are running background apps. |
| 1258 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075. | 1263 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075. |
| 1259 browser_process_->profile_manager()->AutoloadProfiles(); | 1264 browser_process_->profile_manager()->AutoloadProfiles(); |
| 1260 #endif | 1265 #endif |
| 1261 // Post-profile init --------------------------------------------------------- | 1266 // Post-profile init --------------------------------------------------------- |
| 1262 | 1267 |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1689 chromeos::CrosSettings::Shutdown(); | 1694 chromeos::CrosSettings::Shutdown(); |
| 1690 #endif | 1695 #endif |
| 1691 #endif | 1696 #endif |
| 1692 } | 1697 } |
| 1693 | 1698 |
| 1694 // Public members: | 1699 // Public members: |
| 1695 | 1700 |
| 1696 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1701 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
| 1697 chrome_extra_parts_.push_back(parts); | 1702 chrome_extra_parts_.push_back(parts); |
| 1698 } | 1703 } |
| OLD | NEW |