| 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 } | 330 } |
| 331 #endif // defined(OS_CHROMEOS) | 331 #endif // defined(OS_CHROMEOS) |
| 332 | 332 |
| 333 return local_state; | 333 return local_state; |
| 334 } | 334 } |
| 335 | 335 |
| 336 // Initializes the primary profile, possibly doing some user prompting to pick | 336 // Initializes the primary profile, possibly doing some user prompting to pick |
| 337 // a fallback profile. Returns the newly created profile, or NULL if startup | 337 // a fallback profile. Returns the newly created profile, or NULL if startup |
| 338 // should not continue. | 338 // should not continue. |
| 339 Profile* CreatePrimaryProfile(const content::MainFunctionParams& parameters, | 339 Profile* CreatePrimaryProfile(const content::MainFunctionParams& parameters, |
| 340 const base::FilePath& user_data_dir, | |
| 341 const base::CommandLine& parsed_command_line) { | 340 const base::CommandLine& parsed_command_line) { |
| 342 TRACE_EVENT0("startup", "ChromeBrowserMainParts::CreateProfile") | 341 TRACE_EVENT0("startup", "ChromeBrowserMainParts::CreateProfile") |
| 343 TRACK_SCOPED_REGION( | 342 TRACK_SCOPED_REGION( |
| 344 "Startup", "ChromeBrowserMainParts::CreatePrimaryProfile"); | 343 "Startup", "ChromeBrowserMainParts::CreatePrimaryProfile"); |
| 345 | 344 |
| 346 base::Time start = base::Time::Now(); | 345 base::Time start = base::Time::Now(); |
| 347 if (profiles::IsMultipleProfilesEnabled() && | 346 if (profiles::IsMultipleProfilesEnabled() && |
| 348 parsed_command_line.HasSwitch(switches::kProfileDirectory)) { | 347 parsed_command_line.HasSwitch(switches::kProfileDirectory)) { |
| 349 g_browser_process->local_state()->SetString(prefs::kProfileLastUsed, | 348 g_browser_process->local_state()->SetString(prefs::kProfileLastUsed, |
| 350 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); | 349 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); |
| 351 // Clear kProfilesLastActive since the user only wants to launch a specific | 350 // Clear kProfilesLastActive since the user only wants to launch a specific |
| 352 // profile. | 351 // profile. |
| 353 ListPrefUpdate update(g_browser_process->local_state(), | 352 ListPrefUpdate update(g_browser_process->local_state(), |
| 354 prefs::kProfilesLastActive); | 353 prefs::kProfilesLastActive); |
| 355 base::ListValue* profile_list = update.Get(); | 354 base::ListValue* profile_list = update.Get(); |
| 356 profile_list->Clear(); | 355 profile_list->Clear(); |
| 357 } | 356 } |
| 358 | 357 |
| 359 Profile* profile = NULL; | 358 Profile* profile = NULL; |
| 360 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 359 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
| 361 // On ChromeOS and Android the ProfileManager will use the same path as the | 360 // On ChromeOS and Android the ProfileManager will use the same path as the |
| 362 // one we got passed. GetActiveUserProfile will therefore use the correct path | 361 // one we got passed. GetActiveUserProfile will therefore use the correct path |
| 363 // automatically. | 362 // automatically. |
| 364 DCHECK_EQ(user_data_dir.value(), | |
| 365 g_browser_process->profile_manager()->user_data_dir().value()); | |
| 366 profile = ProfileManager::GetActiveUserProfile(); | 363 profile = ProfileManager::GetActiveUserProfile(); |
| 367 #else | 364 #else |
| 368 base::FilePath profile_path = | 365 base::FilePath profile_path = GetStartupProfilePath(parsed_command_line); |
| 369 GetStartupProfilePath(user_data_dir, parsed_command_line); | |
| 370 | 366 |
| 371 // Without NewAvatarMenu, replace guest with any existing profile. | 367 // Without NewAvatarMenu, replace guest with any existing profile. |
| 372 if (!switches::IsNewAvatarMenu() && | 368 if (!switches::IsNewAvatarMenu() && |
| 373 profile_path == ProfileManager::GetGuestProfilePath()) { | 369 profile_path == ProfileManager::GetGuestProfilePath()) { |
| 374 profile_path = g_browser_process->profile_manager()->GetProfileInfoCache(). | 370 profile_path = g_browser_process->profile_manager()->GetProfileInfoCache(). |
| 375 GetPathOfProfileAtIndex(0); | 371 GetPathOfProfileAtIndex(0); |
| 376 } | 372 } |
| 377 profile = g_browser_process->profile_manager()->GetProfile( | 373 profile = g_browser_process->profile_manager()->GetProfile(profile_path); |
| 378 profile_path); | |
| 379 | 374 |
| 380 // 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 |
| 381 // 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 |
| 382 // the active profile to the guest profile we ensure that no | 377 // the active profile to the guest profile we ensure that no |
| 383 // browser windows will be opened for the guest profile. | 378 // browser windows will be opened for the guest profile. |
| 384 if (switches::IsNewProfileManagement() && | 379 if (switches::IsNewProfileManagement() && |
| 385 profile && | 380 profile && |
| 386 !profile->IsGuestSession()) { | 381 !profile->IsGuestSession()) { |
| 387 ProfileInfoCache& cache = | 382 ProfileInfoCache& cache = |
| 388 g_browser_process->profile_manager()->GetProfileInfoCache(); | 383 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 } else { | 497 } else { |
| 503 UMA_HISTOGRAM_LONG_TIMES( | 498 UMA_HISTOGRAM_LONG_TIMES( |
| 504 "Startup.WarmStartTimeFromRemoteProcessStart", elapsed); | 499 "Startup.WarmStartTimeFromRemoteProcessStart", elapsed); |
| 505 } | 500 } |
| 506 } | 501 } |
| 507 } | 502 } |
| 508 | 503 |
| 509 g_browser_process->platform_part()->PlatformSpecificCommandLineProcessing( | 504 g_browser_process->platform_part()->PlatformSpecificCommandLineProcessing( |
| 510 command_line); | 505 command_line); |
| 511 | 506 |
| 512 base::FilePath user_data_dir = | 507 base::FilePath startup_profile_dir = GetStartupProfilePath(command_line); |
| 513 g_browser_process->profile_manager()->user_data_dir(); | |
| 514 base::FilePath startup_profile_dir = | |
| 515 GetStartupProfilePath(user_data_dir, command_line); | |
| 516 | 508 |
| 517 StartupBrowserCreator::ProcessCommandLineAlreadyRunning( | 509 StartupBrowserCreator::ProcessCommandLineAlreadyRunning( |
| 518 command_line, current_directory, startup_profile_dir); | 510 command_line, current_directory, startup_profile_dir); |
| 519 return true; | 511 return true; |
| 520 } | 512 } |
| 521 #endif // !defined(OS_ANDROID) | 513 #endif // !defined(OS_ANDROID) |
| 522 | 514 |
| 523 void LaunchDevToolsHandlerIfNeeded(const base::CommandLine& command_line) { | 515 void LaunchDevToolsHandlerIfNeeded(const base::CommandLine& command_line) { |
| 524 if (command_line.HasSwitch(::switches::kRemoteDebuggingPort)) { | 516 if (command_line.HasSwitch(::switches::kRemoteDebuggingPort)) { |
| 525 std::string port_str = | 517 std::string port_str = |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1343 metrics::MetricsService::SetExecutionPhase( | 1335 metrics::MetricsService::SetExecutionPhase( |
| 1344 metrics::MetricsService::CREATE_PROFILE, | 1336 metrics::MetricsService::CREATE_PROFILE, |
| 1345 g_browser_process->local_state()); | 1337 g_browser_process->local_state()); |
| 1346 | 1338 |
| 1347 UMA_HISTOGRAM_TIMES("Startup.PreMainMessageLoopRunImplStep1Time", | 1339 UMA_HISTOGRAM_TIMES("Startup.PreMainMessageLoopRunImplStep1Time", |
| 1348 base::TimeTicks::Now() - start_time_step1); | 1340 base::TimeTicks::Now() - start_time_step1); |
| 1349 | 1341 |
| 1350 // This step is costly and is already measured in Startup.CreateFirstProfile | 1342 // This step is costly and is already measured in Startup.CreateFirstProfile |
| 1351 // and more directly Profile.CreateAndInitializeProfile. | 1343 // and more directly Profile.CreateAndInitializeProfile. |
| 1352 profile_ = CreatePrimaryProfile(parameters(), | 1344 profile_ = CreatePrimaryProfile(parameters(), |
| 1353 user_data_dir_, | |
| 1354 parsed_command_line()); | 1345 parsed_command_line()); |
| 1355 if (!profile_) | 1346 if (!profile_) |
| 1356 return content::RESULT_CODE_NORMAL_EXIT; | 1347 return content::RESULT_CODE_NORMAL_EXIT; |
| 1357 | 1348 |
| 1358 #if !defined(OS_ANDROID) | 1349 #if !defined(OS_ANDROID) |
| 1359 const base::TimeTicks start_time_step2 = base::TimeTicks::Now(); | 1350 const base::TimeTicks start_time_step2 = base::TimeTicks::Now(); |
| 1360 // The first run sentinel must be created after the process singleton was | 1351 // The first run sentinel must be created after the process singleton was |
| 1361 // grabbed and no early return paths were otherwise hit above. | 1352 // grabbed and no early return paths were otherwise hit above. |
| 1362 first_run::CreateSentinelIfNeeded(); | 1353 first_run::CreateSentinelIfNeeded(); |
| 1363 #endif // !defined(OS_ANDROID) | 1354 #endif // !defined(OS_ANDROID) |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1782 chromeos::CrosSettings::Shutdown(); | 1773 chromeos::CrosSettings::Shutdown(); |
| 1783 #endif // defined(OS_CHROMEOS) | 1774 #endif // defined(OS_CHROMEOS) |
| 1784 #endif // defined(OS_ANDROID) | 1775 #endif // defined(OS_ANDROID) |
| 1785 } | 1776 } |
| 1786 | 1777 |
| 1787 // Public members: | 1778 // Public members: |
| 1788 | 1779 |
| 1789 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1780 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
| 1790 chrome_extra_parts_.push_back(parts); | 1781 chrome_extra_parts_.push_back(parts); |
| 1791 } | 1782 } |
| OLD | NEW |