| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/chromeos/chrome_browser_main_chromeos.h" | 5 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 } | 185 } |
| 186 | 186 |
| 187 scoped_refptr<Authenticator> authenticator_; | 187 scoped_refptr<Authenticator> authenticator_; |
| 188 bool pending_requests_; | 188 bool pending_requests_; |
| 189 bool profile_prepared_; | 189 bool profile_prepared_; |
| 190 }; | 190 }; |
| 191 | 191 |
| 192 bool ShouldAutoLaunchKioskApp(const CommandLine& command_line) { | 192 bool ShouldAutoLaunchKioskApp(const CommandLine& command_line) { |
| 193 KioskAppManager* app_manager = KioskAppManager::Get(); | 193 KioskAppManager* app_manager = KioskAppManager::Get(); |
| 194 return !command_line.HasSwitch(::switches::kDisableAppMode) && | 194 return !command_line.HasSwitch(::switches::kDisableAppMode) && |
| 195 command_line.HasSwitch(switches::kLoginManager) && | 195 command_line.HasSwitch(::switches::kLoginManager) && |
| 196 !command_line.HasSwitch(switches::kForceLoginManagerInTests) && | 196 !command_line.HasSwitch(::switches::kForceLoginManagerInTests) && |
| 197 !app_manager->GetAutoLaunchApp().empty() && | 197 !app_manager->GetAutoLaunchApp().empty() && |
| 198 KioskAppLaunchError::Get() == KioskAppLaunchError::NONE; | 198 KioskAppLaunchError::Get() == KioskAppLaunchError::NONE; |
| 199 } | 199 } |
| 200 | 200 |
| 201 void OptionallyRunChromeOSLoginManager(const CommandLine& parsed_command_line, | 201 void OptionallyRunChromeOSLoginManager(const CommandLine& parsed_command_line, |
| 202 Profile* profile) { | 202 Profile* profile) { |
| 203 if (parsed_command_line.HasSwitch(switches::kLoginManager)) { | 203 if (parsed_command_line.HasSwitch(::switches::kLoginManager)) { |
| 204 std::string first_screen = | 204 std::string first_screen = |
| 205 parsed_command_line.GetSwitchValueASCII(switches::kLoginScreen); | 205 parsed_command_line.GetSwitchValueASCII(::switches::kLoginScreen); |
| 206 std::string size_arg = | 206 std::string size_arg = |
| 207 parsed_command_line.GetSwitchValueASCII(switches::kLoginScreenSize); | 207 parsed_command_line.GetSwitchValueASCII( |
| 208 ::switches::kLoginScreenSize); |
| 208 gfx::Size size(0, 0); | 209 gfx::Size size(0, 0); |
| 209 // Allow the size of the login window to be set explicitly. If not set, | 210 // Allow the size of the login window to be set explicitly. If not set, |
| 210 // default to the entire screen. This is mostly useful for testing. | 211 // default to the entire screen. This is mostly useful for testing. |
| 211 if (size_arg.size()) { | 212 if (size_arg.size()) { |
| 212 std::vector<std::string> dimensions; | 213 std::vector<std::string> dimensions; |
| 213 base::SplitString(size_arg, ',', &dimensions); | 214 base::SplitString(size_arg, ',', &dimensions); |
| 214 if (dimensions.size() == 2) { | 215 if (dimensions.size() == 2) { |
| 215 int width, height; | 216 int width, height; |
| 216 if (base::StringToInt(dimensions[0], &width) && | 217 if (base::StringToInt(dimensions[0], &width) && |
| 217 base::StringToInt(dimensions[1], &height)) | 218 base::StringToInt(dimensions[1], &height)) |
| 218 size.SetSize(width, height); | 219 size.SetSize(width, height); |
| 219 } | 220 } |
| 220 } | 221 } |
| 221 | 222 |
| 222 ShowLoginWizard(first_screen, size); | 223 ShowLoginWizard(first_screen, size); |
| 223 | 224 |
| 224 if (KioskModeSettings::Get()->IsKioskModeEnabled()) | 225 if (KioskModeSettings::Get()->IsKioskModeEnabled()) |
| 225 InitializeKioskModeScreensaver(); | 226 InitializeKioskModeScreensaver(); |
| 226 | 227 |
| 227 // If app mode is enabled, reset reboot after update flag when login | 228 // If app mode is enabled, reset reboot after update flag when login |
| 228 // screen is shown. | 229 // screen is shown. |
| 229 if (!parsed_command_line.HasSwitch(::switches::kDisableAppMode)) { | 230 if (!parsed_command_line.HasSwitch(::switches::kDisableAppMode)) { |
| 230 if (!g_browser_process->browser_policy_connector()-> | 231 if (!g_browser_process->browser_policy_connector()-> |
| 231 IsEnterpriseManaged()) { | 232 IsEnterpriseManaged()) { |
| 232 PrefService* local_state = g_browser_process->local_state(); | 233 PrefService* local_state = g_browser_process->local_state(); |
| 233 local_state->ClearPref(prefs::kRebootAfterUpdate); | 234 local_state->ClearPref(prefs::kRebootAfterUpdate); |
| 234 } | 235 } |
| 235 } | 236 } |
| 236 } else if (parsed_command_line.HasSwitch(switches::kLoginUser) && | 237 } else if (parsed_command_line.HasSwitch(::switches::kLoginUser) && |
| 237 parsed_command_line.HasSwitch(switches::kLoginPassword)) { | 238 parsed_command_line.HasSwitch(::switches::kLoginPassword)) { |
| 238 BootTimesLoader::Get()->RecordLoginAttempted(); | 239 BootTimesLoader::Get()->RecordLoginAttempted(); |
| 239 new StubLogin( | 240 new StubLogin( |
| 240 parsed_command_line.GetSwitchValueASCII(switches::kLoginUser), | 241 parsed_command_line.GetSwitchValueASCII(::switches::kLoginUser), |
| 241 parsed_command_line.GetSwitchValueASCII(switches::kLoginPassword)); | 242 parsed_command_line.GetSwitchValueASCII(::switches::kLoginPassword)); |
| 242 } else { | 243 } else { |
| 243 if (!parsed_command_line.HasSwitch(::switches::kTestName)) { | 244 if (!parsed_command_line.HasSwitch(::switches::kTestName)) { |
| 244 // We did not log in (we crashed or are debugging), so we need to | 245 // We did not log in (we crashed or are debugging), so we need to |
| 245 // restore Sync. | 246 // restore Sync. |
| 246 LoginUtils::Get()->RestoreAuthenticationSession(profile); | 247 LoginUtils::Get()->RestoreAuthenticationSession(profile); |
| 247 } | 248 } |
| 248 } | 249 } |
| 249 } | 250 } |
| 250 | 251 |
| 251 void RunAutoLaunchKioskApp() { | 252 void RunAutoLaunchKioskApp() { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 // remaining work is negligible, hence we say LogoutDone here. | 380 // remaining work is negligible, hence we say LogoutDone here. |
| 380 BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", false); | 381 BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", false); |
| 381 BootTimesLoader::Get()->WriteLogoutTimes(); | 382 BootTimesLoader::Get()->WriteLogoutTimes(); |
| 382 } | 383 } |
| 383 | 384 |
| 384 // content::BrowserMainParts and ChromeBrowserMainExtraParts overrides --------- | 385 // content::BrowserMainParts and ChromeBrowserMainExtraParts overrides --------- |
| 385 | 386 |
| 386 void ChromeBrowserMainPartsChromeos::PreEarlyInitialization() { | 387 void ChromeBrowserMainPartsChromeos::PreEarlyInitialization() { |
| 387 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); | 388 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); |
| 388 | 389 |
| 389 if (parsed_command_line().HasSwitch(switches::kGuestSession)) { | 390 if (parsed_command_line().HasSwitch(::switches::kGuestSession)) { |
| 390 // Disable sync and extensions if we're in "browse without sign-in" mode. | 391 // Disable sync and extensions if we're in "browse without sign-in" mode. |
| 391 singleton_command_line->AppendSwitch(::switches::kDisableSync); | 392 singleton_command_line->AppendSwitch(::switches::kDisableSync); |
| 392 singleton_command_line->AppendSwitch(::switches::kDisableExtensions); | 393 singleton_command_line->AppendSwitch(::switches::kDisableExtensions); |
| 393 browser_defaults::bookmarks_enabled = false; | 394 browser_defaults::bookmarks_enabled = false; |
| 394 } | 395 } |
| 395 | 396 |
| 396 // If we're not running on real ChromeOS hardware (or under VM), and are not | 397 // If we're not running on real ChromeOS hardware (or under VM), and are not |
| 397 // showing the login manager or attempting a command line login, login with a | 398 // showing the login manager or attempting a command line login, login with a |
| 398 // stub user. | 399 // stub user. |
| 399 if (!base::chromeos::IsRunningOnChromeOS() && | 400 if (!base::chromeos::IsRunningOnChromeOS() && |
| 400 !parsed_command_line().HasSwitch(switches::kLoginManager) && | 401 !parsed_command_line().HasSwitch(::switches::kLoginManager) && |
| 401 !parsed_command_line().HasSwitch(switches::kLoginUser) && | 402 !parsed_command_line().HasSwitch(::switches::kLoginUser) && |
| 402 !parsed_command_line().HasSwitch(switches::kGuestSession)) { | 403 !parsed_command_line().HasSwitch(::switches::kGuestSession)) { |
| 403 singleton_command_line->AppendSwitchASCII( | 404 singleton_command_line->AppendSwitchASCII( |
| 404 switches::kLoginUser, UserManager::kStubUser); | 405 ::switches::kLoginUser, UserManager::kStubUser); |
| 405 if (!parsed_command_line().HasSwitch(switches::kLoginProfile)) { | 406 if (!parsed_command_line().HasSwitch(::switches::kLoginProfile)) { |
| 406 // This must be kept in sync with TestingProfile::kTestUserProfileDir. | 407 // This must be kept in sync with TestingProfile::kTestUserProfileDir. |
| 407 singleton_command_line->AppendSwitchASCII( | 408 singleton_command_line->AppendSwitchASCII( |
| 408 switches::kLoginProfile, "test-user"); | 409 ::switches::kLoginProfile, "test-user"); |
| 409 } | 410 } |
| 410 LOG(INFO) << "Running as stub user with profile dir: " | 411 LOG(INFO) << "Running as stub user with profile dir: " |
| 411 << singleton_command_line->GetSwitchValuePath( | 412 << singleton_command_line->GetSwitchValuePath( |
| 412 switches::kLoginProfile).value(); | 413 ::switches::kLoginProfile).value(); |
| 413 } | 414 } |
| 414 | 415 |
| 415 // Initialize the statistics provider, which will ensure that the Chrome | 416 // Initialize the statistics provider, which will ensure that the Chrome |
| 416 // channel info is read and made available early. | 417 // channel info is read and made available early. |
| 417 system::StatisticsProvider::GetInstance()->Init(); | 418 system::StatisticsProvider::GetInstance()->Init(); |
| 418 | 419 |
| 419 ChromeBrowserMainPartsLinux::PreEarlyInitialization(); | 420 ChromeBrowserMainPartsLinux::PreEarlyInitialization(); |
| 420 } | 421 } |
| 421 | 422 |
| 422 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { | 423 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 if (parsed_command_line().HasSwitch(::switches::kEnableContacts)) { | 499 if (parsed_command_line().HasSwitch(::switches::kEnableContacts)) { |
| 499 contact_manager_.reset(new contacts::ContactManager()); | 500 contact_manager_.reset(new contacts::ContactManager()); |
| 500 contact_manager_->Init(); | 501 contact_manager_->Init(); |
| 501 } | 502 } |
| 502 | 503 |
| 503 // There are two use cases for kLoginUser: | 504 // There are two use cases for kLoginUser: |
| 504 // 1) if passed in tandem with kLoginPassword, to drive a "StubLogin" | 505 // 1) if passed in tandem with kLoginPassword, to drive a "StubLogin" |
| 505 // 2) if passed alone, to signal that the indicated user has already | 506 // 2) if passed alone, to signal that the indicated user has already |
| 506 // logged in and we should behave accordingly. | 507 // logged in and we should behave accordingly. |
| 507 // This handles case 2. | 508 // This handles case 2. |
| 508 if (parsed_command_line().HasSwitch(switches::kLoginUser) && | 509 if (parsed_command_line().HasSwitch(::switches::kLoginUser) && |
| 509 !parsed_command_line().HasSwitch(switches::kLoginPassword)) { | 510 !parsed_command_line().HasSwitch(::switches::kLoginPassword)) { |
| 510 std::string username = | 511 std::string username = |
| 511 parsed_command_line().GetSwitchValueASCII(switches::kLoginUser); | 512 parsed_command_line().GetSwitchValueASCII(::switches::kLoginUser); |
| 512 VLOG(1) << "Relaunching browser for user: " << username; | 513 VLOG(1) << "Relaunching browser for user: " << username; |
| 513 UserManager* user_manager = UserManager::Get(); | 514 UserManager* user_manager = UserManager::Get(); |
| 514 // TODO(nkostylev): Get user username_hash (cryptohome mount point) | 515 // TODO(nkostylev): Get user username_hash (cryptohome mount point) |
| 515 // from a separate cmd line switch. | 516 // from a separate cmd line switch. |
| 516 std::string username_hash = | 517 std::string username_hash = |
| 517 parsed_command_line().GetSwitchValueASCII(switches::kLoginProfile); | 518 parsed_command_line().GetSwitchValueASCII(::switches::kLoginProfile); |
| 518 user_manager->UserLoggedIn(username, username_hash, true); | 519 user_manager->UserLoggedIn(username, username_hash, true); |
| 519 | 520 |
| 520 // Redirects Chrome logging to the user data dir. | 521 // Redirects Chrome logging to the user data dir. |
| 521 logging::RedirectChromeLogging(parsed_command_line()); | 522 logging::RedirectChromeLogging(parsed_command_line()); |
| 522 | 523 |
| 523 // Initialize user policy before creating the profile so the profile | 524 // Initialize user policy before creating the profile so the profile |
| 524 // initialization code sees policy settings. | 525 // initialization code sees policy settings. |
| 525 // Guest accounts are not subject to user policy. | 526 // Guest accounts are not subject to user policy. |
| 526 if (!user_manager->IsLoggedInAsGuest()) { | 527 if (!user_manager->IsLoggedInAsGuest()) { |
| 527 g_browser_process->browser_policy_connector()->InitializeUserPolicy( | 528 g_browser_process->browser_policy_connector()->InitializeUserPolicy( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 storage_monitor_ = new StorageMonitorCros(); | 565 storage_monitor_ = new StorageMonitorCros(); |
| 565 | 566 |
| 566 // In Aura builds this will initialize ash::Shell. | 567 // In Aura builds this will initialize ash::Shell. |
| 567 ChromeBrowserMainPartsLinux::PreProfileInit(); | 568 ChromeBrowserMainPartsLinux::PreProfileInit(); |
| 568 } | 569 } |
| 569 | 570 |
| 570 void ChromeBrowserMainPartsChromeos::PostProfileInit() { | 571 void ChromeBrowserMainPartsChromeos::PostProfileInit() { |
| 571 // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun() | 572 // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun() |
| 572 // -- just after CreateProfile(). | 573 // -- just after CreateProfile(). |
| 573 | 574 |
| 574 if (parsed_command_line().HasSwitch(switches::kLoginUser) && | 575 if (parsed_command_line().HasSwitch(::switches::kLoginUser) && |
| 575 !parsed_command_line().HasSwitch(switches::kLoginPassword)) { | 576 !parsed_command_line().HasSwitch(::switches::kLoginPassword)) { |
| 576 // Make sure we flip every profile to not share proxies if the user hasn't | 577 // Make sure we flip every profile to not share proxies if the user hasn't |
| 577 // specified so explicitly. | 578 // specified so explicitly. |
| 578 const PrefService::Preference* use_shared_proxies_pref = | 579 const PrefService::Preference* use_shared_proxies_pref = |
| 579 profile()->GetPrefs()->FindPreference(prefs::kUseSharedProxies); | 580 profile()->GetPrefs()->FindPreference(prefs::kUseSharedProxies); |
| 580 if (use_shared_proxies_pref->IsDefaultValue()) | 581 if (use_shared_proxies_pref->IsDefaultValue()) |
| 581 profile()->GetPrefs()->SetBoolean(prefs::kUseSharedProxies, false); | 582 profile()->GetPrefs()->SetBoolean(prefs::kUseSharedProxies, false); |
| 582 | 583 |
| 583 // This is done in LoginUtils::OnProfileCreated during normal login. | 584 // This is done in LoginUtils::OnProfileCreated during normal login. |
| 584 LoginUtils::Get()->InitRlzDelayed(profile()); | 585 LoginUtils::Get()->InitRlzDelayed(profile()); |
| 585 } | 586 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 599 // Start loading the machine statistics. Note: if we start loading machine | 600 // Start loading the machine statistics. Note: if we start loading machine |
| 600 // statistics early in PreEarlyInitialization() then the crossystem tool | 601 // statistics early in PreEarlyInitialization() then the crossystem tool |
| 601 // sometimes hangs for unknown reasons, see http://crbug.com/167671. | 602 // sometimes hangs for unknown reasons, see http://crbug.com/167671. |
| 602 // Also we must start loading no later than this point, because login manager | 603 // Also we must start loading no later than this point, because login manager |
| 603 // may call GetMachineStatistic() during startup, see crbug.com/170635. | 604 // may call GetMachineStatistic() during startup, see crbug.com/170635. |
| 604 system::StatisticsProvider::GetInstance()->StartLoadingMachineStatistics(); | 605 system::StatisticsProvider::GetInstance()->StartLoadingMachineStatistics(); |
| 605 | 606 |
| 606 // Tests should be able to tune login manager before showing it. | 607 // Tests should be able to tune login manager before showing it. |
| 607 // Thus only show login manager in normal (non-testing) mode. | 608 // Thus only show login manager in normal (non-testing) mode. |
| 608 if (!parameters().ui_task || | 609 if (!parameters().ui_task || |
| 609 parsed_command_line().HasSwitch(switches::kForceLoginManagerInTests)) { | 610 parsed_command_line().HasSwitch(::switches::kForceLoginManagerInTests)) { |
| 610 if (ShouldAutoLaunchKioskApp(parsed_command_line())) { | 611 if (ShouldAutoLaunchKioskApp(parsed_command_line())) { |
| 611 RunAutoLaunchKioskApp(); | 612 RunAutoLaunchKioskApp(); |
| 612 } else { | 613 } else { |
| 613 OptionallyRunChromeOSLoginManager(parsed_command_line(), profile()); | 614 OptionallyRunChromeOSLoginManager(parsed_command_line(), profile()); |
| 614 } | 615 } |
| 615 } | 616 } |
| 616 | 617 |
| 617 // These observers must be initialized after the profile because | 618 // These observers must be initialized after the profile because |
| 618 // they use the profile to dispatch extension events. | 619 // they use the profile to dispatch extension events. |
| 619 // | 620 // |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 trial->AppendGroup("4GB_RAM_4GB_swap", zram_group == '4' ? 1 : 0); | 874 trial->AppendGroup("4GB_RAM_4GB_swap", zram_group == '4' ? 1 : 0); |
| 874 trial->AppendGroup("4GB_RAM_6GB_swap", zram_group == '5' ? 1 : 0); | 875 trial->AppendGroup("4GB_RAM_6GB_swap", zram_group == '5' ? 1 : 0); |
| 875 trial->AppendGroup("snow_no_swap", zram_group == '6' ? 1 : 0); | 876 trial->AppendGroup("snow_no_swap", zram_group == '6' ? 1 : 0); |
| 876 trial->AppendGroup("snow_1GB_swap", zram_group == '7' ? 1 : 0); | 877 trial->AppendGroup("snow_1GB_swap", zram_group == '7' ? 1 : 0); |
| 877 trial->AppendGroup("snow_2GB_swap", zram_group == '8' ? 1 : 0); | 878 trial->AppendGroup("snow_2GB_swap", zram_group == '8' ? 1 : 0); |
| 878 // This is necessary to start the experiment as a side effect. | 879 // This is necessary to start the experiment as a side effect. |
| 879 trial->group(); | 880 trial->group(); |
| 880 } | 881 } |
| 881 | 882 |
| 882 } // namespace chromeos | 883 } // namespace chromeos |
| OLD | NEW |