| 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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 local_state->GetString(prefs::kApplicationLocale) != owner_locale && | 293 local_state->GetString(prefs::kApplicationLocale) != owner_locale && |
| 294 !local_state->IsManagedPreference(prefs::kApplicationLocale)) { | 294 !local_state->IsManagedPreference(prefs::kApplicationLocale)) { |
| 295 local_state->SetString(prefs::kApplicationLocale, owner_locale); | 295 local_state->SetString(prefs::kApplicationLocale, owner_locale); |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 #endif | 298 #endif |
| 299 | 299 |
| 300 return local_state; | 300 return local_state; |
| 301 } | 301 } |
| 302 | 302 |
| 303 // Returns the path that contains the profile that should be loaded | |
| 304 // on process startup. | |
| 305 base::FilePath GetStartupProfilePath(const base::FilePath& user_data_dir, | |
| 306 const CommandLine& command_line) { | |
| 307 if (command_line.HasSwitch(switches::kProfileDirectory)) { | |
| 308 return user_data_dir.Append( | |
| 309 command_line.GetSwitchValuePath(switches::kProfileDirectory)); | |
| 310 } | |
| 311 | |
| 312 // If we are showing the app list then chrome isn't shown so load the app | |
| 313 // list's profile rather than chrome's. | |
| 314 if (command_line.HasSwitch(switches::kShowAppList)) { | |
| 315 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> | |
| 316 GetProfilePath(user_data_dir); | |
| 317 } | |
| 318 | |
| 319 return g_browser_process->profile_manager()->GetLastUsedProfileDir( | |
| 320 user_data_dir); | |
| 321 } | |
| 322 | |
| 323 // Initializes the primary profile, possibly doing some user prompting to pick | 303 // Initializes the primary profile, possibly doing some user prompting to pick |
| 324 // a fallback profile. Returns the newly created profile, or NULL if startup | 304 // a fallback profile. Returns the newly created profile, or NULL if startup |
| 325 // should not continue. | 305 // should not continue. |
| 326 Profile* CreatePrimaryProfile(const content::MainFunctionParams& parameters, | 306 Profile* CreatePrimaryProfile(const content::MainFunctionParams& parameters, |
| 327 const base::FilePath& user_data_dir, | 307 const base::FilePath& user_data_dir, |
| 328 const CommandLine& parsed_command_line) { | 308 const CommandLine& parsed_command_line) { |
| 329 TRACE_EVENT0("startup", "ChromeBrowserMainParts::CreateProfile") | 309 TRACE_EVENT0("startup", "ChromeBrowserMainParts::CreateProfile") |
| 330 base::Time start = base::Time::Now(); | 310 base::Time start = base::Time::Now(); |
| 331 if (profiles::IsMultipleProfilesEnabled() && | 311 if (profiles::IsMultipleProfilesEnabled() && |
| 332 parsed_command_line.HasSwitch(switches::kProfileDirectory)) { | 312 parsed_command_line.HasSwitch(switches::kProfileDirectory)) { |
| 333 g_browser_process->local_state()->SetString(prefs::kProfileLastUsed, | 313 g_browser_process->local_state()->SetString(prefs::kProfileLastUsed, |
| 334 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); | 314 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); |
| 335 // Clear kProfilesLastActive since the user only wants to launch a specific | 315 // Clear kProfilesLastActive since the user only wants to launch a specific |
| 336 // profile. | 316 // profile. |
| 337 ListPrefUpdate update(g_browser_process->local_state(), | 317 ListPrefUpdate update(g_browser_process->local_state(), |
| 338 prefs::kProfilesLastActive); | 318 prefs::kProfilesLastActive); |
| 339 base::ListValue* profile_list = update.Get(); | 319 base::ListValue* profile_list = update.Get(); |
| 340 profile_list->Clear(); | 320 profile_list->Clear(); |
| 341 } | 321 } |
| 342 | 322 |
| 343 Profile* profile = NULL; | 323 Profile* profile = NULL; |
| 344 #if defined(OS_CHROMEOS) | 324 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
| 345 // On ChromeOS the ProfileManager will use the same path as the one we got | 325 // On ChromeOS and Android the ProfileManager will use the same path as the |
| 346 // passed. GetActiveUserProfile will therefore use the correct path | 326 // one we got passed. GetActiveUserProfile will therefore use the correct path |
| 347 // automatically. | 327 // automatically. |
| 348 DCHECK_EQ(user_data_dir.value(), | 328 DCHECK_EQ(user_data_dir.value(), |
| 349 g_browser_process->profile_manager()->user_data_dir().value()); | 329 g_browser_process->profile_manager()->user_data_dir().value()); |
| 350 profile = ProfileManager::GetActiveUserProfile(); | 330 profile = ProfileManager::GetActiveUserProfile(); |
| 351 #else | 331 #else |
| 352 base::FilePath profile_path = | 332 base::FilePath profile_path = |
| 353 GetStartupProfilePath(user_data_dir, parsed_command_line); | 333 GetStartupProfilePath(user_data_dir, parsed_command_line); |
| 354 profile = g_browser_process->profile_manager()->GetProfile( | 334 profile = g_browser_process->profile_manager()->GetProfile( |
| 355 profile_path); | 335 profile_path); |
| 356 | 336 |
| (...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1675 chromeos::CrosSettings::Shutdown(); | 1655 chromeos::CrosSettings::Shutdown(); |
| 1676 #endif | 1656 #endif |
| 1677 #endif | 1657 #endif |
| 1678 } | 1658 } |
| 1679 | 1659 |
| 1680 // Public members: | 1660 // Public members: |
| 1681 | 1661 |
| 1682 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1662 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
| 1683 chrome_extra_parts_.push_back(parts); | 1663 chrome_extra_parts_.push_back(parts); |
| 1684 } | 1664 } |
| OLD | NEW |