Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: chrome/browser/chromeos/chrome_browser_main_chromeos.cc

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

Powered by Google App Engine
This is Rietveld 408576698