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 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 346 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
| 347 // On ChromeOS and Android the ProfileManager will use the same path as the | 347 // On ChromeOS and Android the ProfileManager will use the same path as the |
| 348 // one we got passed. GetActiveUserProfile will therefore use the correct path | 348 // one we got passed. GetActiveUserProfile will therefore use the correct path |
| 349 // automatically. | 349 // automatically. |
| 350 DCHECK_EQ(user_data_dir.value(), | 350 DCHECK_EQ(user_data_dir.value(), |
| 351 g_browser_process->profile_manager()->user_data_dir().value()); | 351 g_browser_process->profile_manager()->user_data_dir().value()); |
| 352 profile = ProfileManager::GetActiveUserProfile(); | 352 profile = ProfileManager::GetActiveUserProfile(); |
| 353 #else | 353 #else |
| 354 base::FilePath profile_path = | 354 base::FilePath profile_path = |
| 355 GetStartupProfilePath(user_data_dir, parsed_command_line); | 355 GetStartupProfilePath(user_data_dir, parsed_command_line); |
| 356 ProfileInfoCache& cache = | |
|
Mike Lerman
2015/03/31 20:48:30
nit: Can this be a const ProfileInfoCache&?
noms (inactive)
2015/03/31 21:01:33
Done.
| |
| 357 g_browser_process->profile_manager()->GetProfileInfoCache(); | |
| 356 | 358 |
| 357 // Without NewAvatarMenu, replace guest with any existing profile. | 359 // Without NewAvatarMenu, replace guest with any existing profile. |
| 358 if (!switches::IsNewAvatarMenu() && | 360 if (!switches::IsNewAvatarMenu() && |
| 359 profile_path == ProfileManager::GetGuestProfilePath()) { | 361 profile_path == ProfileManager::GetGuestProfilePath()) { |
| 360 profile_path = g_browser_process->profile_manager()->GetProfileInfoCache(). | 362 profile_path = cache.GetPathOfProfileAtIndex(0); |
| 361 GetPathOfProfileAtIndex(0); | |
| 362 } | 363 } |
| 364 | |
| 365 // If we are trying to load a profile that has been deleted (for example from | |
| 366 // an old shortcut, or using an incorrect kProfileDirectory argument), set | |
| 367 // the active profile to Guest to force showing the User Manager. | |
| 368 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_path); | |
| 369 if (profile_index == std::string::npos) | |
|
Mike Lerman
2015/03/31 20:48:30
We need to make sure that those folks who have dis
noms (inactive)
2015/03/31 21:01:33
Ughhhhh that's a weird result now, though (but you
| |
| 370 profile_path = ProfileManager::GetGuestProfilePath(); | |
| 371 | |
| 363 profile = g_browser_process->profile_manager()->GetProfile( | 372 profile = g_browser_process->profile_manager()->GetProfile( |
| 364 profile_path); | 373 profile_path); |
| 365 | 374 |
| 366 // If we're using the --new-profile-management flag and this profile is | 375 // If we're using the --new-profile-management flag and this profile is |
| 367 // signed out, then we should show the user manager instead. By switching | 376 // signed out, then we should show the user manager instead. By switching |
| 368 // the active profile to the guest profile we ensure that no | 377 // the active profile to the guest profile we ensure that no |
| 369 // browser windows will be opened for the guest profile. | 378 // browser windows will be opened for the guest profile. |
| 370 if (switches::IsNewProfileManagement() && | 379 if (switches::IsNewProfileManagement() && |
| 371 profile && | 380 profile && |
| 372 !profile->IsGuestSession()) { | 381 !profile->IsGuestSession()) { |
| 373 ProfileInfoCache& cache = | |
| 374 g_browser_process->profile_manager()->GetProfileInfoCache(); | |
| 375 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_path); | |
| 376 | |
| 377 if (profile_index != std::string::npos && | 382 if (profile_index != std::string::npos && |
|
Mike Lerman
2015/03/31 20:48:30
We can remove the profile_index != std::string::np
noms (inactive)
2015/03/31 21:01:33
Done.
| |
| 378 cache.ProfileIsSigninRequiredAtIndex(profile_index)) { | 383 cache.ProfileIsSigninRequiredAtIndex(profile_index)) { |
| 379 profile = g_browser_process->profile_manager()->GetProfile( | 384 profile = g_browser_process->profile_manager()->GetProfile( |
| 380 ProfileManager::GetGuestProfilePath()); | 385 ProfileManager::GetGuestProfilePath()); |
| 381 } | 386 } |
| 382 } | 387 } |
| 383 #endif // defined(OS_CHROMEOS) || defined(OS_ANDROID) | 388 #endif // defined(OS_CHROMEOS) || defined(OS_ANDROID) |
| 384 if (profile) { | 389 if (profile) { |
| 385 UMA_HISTOGRAM_LONG_TIMES( | 390 UMA_HISTOGRAM_LONG_TIMES( |
| 386 "Startup.CreateFirstProfile", base::Time::Now() - start); | 391 "Startup.CreateFirstProfile", base::Time::Now() - start); |
| 387 return profile; | 392 return profile; |
| (...skipping 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1730 chromeos::CrosSettings::Shutdown(); | 1735 chromeos::CrosSettings::Shutdown(); |
| 1731 #endif // defined(OS_CHROMEOS) | 1736 #endif // defined(OS_CHROMEOS) |
| 1732 #endif // defined(OS_ANDROID) | 1737 #endif // defined(OS_ANDROID) |
| 1733 } | 1738 } |
| 1734 | 1739 |
| 1735 // Public members: | 1740 // Public members: |
| 1736 | 1741 |
| 1737 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1742 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
| 1738 chrome_extra_parts_.push_back(parts); | 1743 chrome_extra_parts_.push_back(parts); |
| 1739 } | 1744 } |
| OLD | NEW |