| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/login/login_utils.h" | 5 #include "chrome/browser/chromeos/login/login_utils.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 virtual void FetchTokens( | 146 virtual void FetchTokens( |
| 147 Profile* profile, | 147 Profile* profile, |
| 148 const GaiaAuthConsumer::ClientLoginResult& credentials); | 148 const GaiaAuthConsumer::ClientLoginResult& credentials); |
| 149 | 149 |
| 150 // Sets the current background view. | 150 // Sets the current background view. |
| 151 virtual void SetBackgroundView(chromeos::BackgroundView* background_view); | 151 virtual void SetBackgroundView(chromeos::BackgroundView* background_view); |
| 152 | 152 |
| 153 // Gets the current background view. | 153 // Gets the current background view. |
| 154 virtual chromeos::BackgroundView* GetBackgroundView(); | 154 virtual chromeos::BackgroundView* GetBackgroundView(); |
| 155 | 155 |
| 156 protected: |
| 157 virtual std::string GetOffTheRecordCommandLine( |
| 158 const GURL& start_url, |
| 159 const CommandLine& base_command_line, |
| 160 CommandLine *command_line); |
| 161 |
| 156 private: | 162 private: |
| 157 // Check user's profile for kApplicationLocale setting. | 163 // Check user's profile for kApplicationLocale setting. |
| 158 void RespectLocalePreference(Profile* pref); | 164 void RespectLocalePreference(Profile* pref); |
| 159 | 165 |
| 160 // Indicates if DoBrowserLaunch will actually launch the browser or not. | 166 // Indicates if DoBrowserLaunch will actually launch the browser or not. |
| 161 bool browser_launch_enabled_; | 167 bool browser_launch_enabled_; |
| 162 | 168 |
| 163 // The current background view. | 169 // The current background view. |
| 164 chromeos::BackgroundView* background_view_; | 170 chromeos::BackgroundView* background_view_; |
| 165 | 171 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 } | 378 } |
| 373 | 379 |
| 374 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) { | 380 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) { |
| 375 VLOG(1) << "Completing off the record login"; | 381 VLOG(1) << "Completing off the record login"; |
| 376 | 382 |
| 377 UserManager::Get()->OffTheRecordUserLoggedIn(); | 383 UserManager::Get()->OffTheRecordUserLoggedIn(); |
| 378 | 384 |
| 379 if (CrosLibrary::Get()->EnsureLoaded()) { | 385 if (CrosLibrary::Get()->EnsureLoaded()) { |
| 380 // For guest session we ask session manager to restart Chrome with --bwsi | 386 // For guest session we ask session manager to restart Chrome with --bwsi |
| 381 // flag. We keep only some of the arguments of this process. | 387 // flag. We keep only some of the arguments of this process. |
| 382 static const char* kForwardSwitches[] = { | 388 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| 383 switches::kEnableLogging, | |
| 384 switches::kUserDataDir, | |
| 385 switches::kScrollPixels, | |
| 386 switches::kEnableGView, | |
| 387 switches::kNoFirstRun, | |
| 388 switches::kLoginProfile, | |
| 389 switches::kCompressSystemFeedback, | |
| 390 switches::kDisableSeccompSandbox, | |
| 391 #if defined(HAVE_XINPUT2) | |
| 392 switches::kTouchDevices, | |
| 393 #endif | |
| 394 }; | |
| 395 const CommandLine& browser_command_line = | |
| 396 *CommandLine::ForCurrentProcess(); | |
| 397 CommandLine command_line(browser_command_line.GetProgram()); | 389 CommandLine command_line(browser_command_line.GetProgram()); |
| 398 command_line.CopySwitchesFrom(browser_command_line, | 390 std::string cmd_line_str = |
| 399 kForwardSwitches, | 391 GetOffTheRecordCommandLine(start_url, |
| 400 arraysize(kForwardSwitches)); | 392 browser_command_line, |
| 401 command_line.AppendSwitch(switches::kGuestSession); | 393 &command_line); |
| 402 command_line.AppendSwitch(switches::kIncognito); | |
| 403 command_line.AppendSwitchASCII(switches::kLoggingLevel, | |
| 404 kGuestModeLoggingLevel); | |
| 405 command_line.AppendSwitchASCII( | |
| 406 switches::kLoginUser, | |
| 407 UserManager::Get()->logged_in_user().email()); | |
| 408 | |
| 409 if (start_url.is_valid()) | |
| 410 command_line.AppendArg(start_url.spec()); | |
| 411 | |
| 412 // Override the value of the homepage that is set in first run mode. | |
| 413 // TODO(altimofeev): extend action of the |kNoFirstRun| to cover this case. | |
| 414 command_line.AppendSwitchASCII( | |
| 415 switches::kHomePage, | |
| 416 GURL(chrome::kChromeUINewTabURL).spec()); | |
| 417 | |
| 418 std::string cmd_line_str = command_line.command_line_string(); | |
| 419 // Special workaround for the arguments that should be quoted. | |
| 420 // Copying switches won't be needed when Guest mode won't need restart | |
| 421 // http://crosbug.com/6924 | |
| 422 if (browser_command_line.HasSwitch(switches::kRegisterPepperPlugins)) { | |
| 423 cmd_line_str += base::StringPrintf( | |
| 424 kSwitchFormatString, | |
| 425 switches::kRegisterPepperPlugins, | |
| 426 browser_command_line.GetSwitchValueNative( | |
| 427 switches::kRegisterPepperPlugins).c_str()); | |
| 428 } | |
| 429 | |
| 430 CrosLibrary::Get()->GetLoginLibrary()->RestartJob(getpid(), cmd_line_str); | 394 CrosLibrary::Get()->GetLoginLibrary()->RestartJob(getpid(), cmd_line_str); |
| 431 } | 395 } |
| 432 } | 396 } |
| 433 | 397 |
| 398 std::string LoginUtilsImpl::GetOffTheRecordCommandLine( |
| 399 const GURL& start_url, |
| 400 const CommandLine& base_command_line, |
| 401 CommandLine* command_line) { |
| 402 static const char* kForwardSwitches[] = { |
| 403 switches::kEnableLogging, |
| 404 switches::kUserDataDir, |
| 405 switches::kScrollPixels, |
| 406 switches::kEnableGView, |
| 407 switches::kNoFirstRun, |
| 408 switches::kLoginProfile, |
| 409 switches::kCompressSystemFeedback, |
| 410 switches::kDisableSeccompSandbox, |
| 411 #if defined(HAVE_XINPUT2) |
| 412 switches::kTouchDevices, |
| 413 #endif |
| 414 }; |
| 415 command_line->CopySwitchesFrom(base_command_line, |
| 416 kForwardSwitches, |
| 417 arraysize(kForwardSwitches)); |
| 418 command_line->AppendSwitch(switches::kGuestSession); |
| 419 command_line->AppendSwitch(switches::kIncognito); |
| 420 command_line->AppendSwitchASCII(switches::kLoggingLevel, |
| 421 kGuestModeLoggingLevel); |
| 422 |
| 423 if (start_url.is_valid()) |
| 424 command_line->AppendArg(start_url.spec()); |
| 425 |
| 426 // Override the value of the homepage that is set in first run mode. |
| 427 // TODO(altimofeev): extend action of the |kNoFirstRun| to cover this case. |
| 428 command_line->AppendSwitchASCII( |
| 429 switches::kHomePage, |
| 430 GURL(chrome::kChromeUINewTabURL).spec()); |
| 431 |
| 432 std::string cmd_line_str = command_line->command_line_string(); |
| 433 // Special workaround for the arguments that should be quoted. |
| 434 // Copying switches won't be needed when Guest mode won't need restart |
| 435 // http://crosbug.com/6924 |
| 436 if (base_command_line.HasSwitch(switches::kRegisterPepperPlugins)) { |
| 437 cmd_line_str += base::StringPrintf( |
| 438 kSwitchFormatString, |
| 439 switches::kRegisterPepperPlugins, |
| 440 base_command_line.GetSwitchValueNative( |
| 441 switches::kRegisterPepperPlugins).c_str()); |
| 442 } |
| 443 |
| 444 return cmd_line_str; |
| 445 } |
| 446 |
| 434 void LoginUtilsImpl::SetFirstLoginPrefs(PrefService* prefs) { | 447 void LoginUtilsImpl::SetFirstLoginPrefs(PrefService* prefs) { |
| 435 VLOG(1) << "Setting first login prefs"; | 448 VLOG(1) << "Setting first login prefs"; |
| 436 BootTimesLoader* btl = BootTimesLoader::Get(); | 449 BootTimesLoader* btl = BootTimesLoader::Get(); |
| 437 | 450 |
| 438 static const char kFallbackInputMethodLocale[] = "en-US"; | 451 static const char kFallbackInputMethodLocale[] = "en-US"; |
| 439 std::string locale(g_browser_process->GetApplicationLocale()); | 452 std::string locale(g_browser_process->GetApplicationLocale()); |
| 440 // Add input methods based on the application locale when the user first | 453 // Add input methods based on the application locale when the user first |
| 441 // logs in. For instance, if the user chooses Japanese as the UI | 454 // logs in. For instance, if the user chooses Japanese as the UI |
| 442 // language at the first login, we'll add input methods associated with | 455 // language at the first login, we'll add input methods associated with |
| 443 // Japanese, such as mozc. | 456 // Japanese, such as mozc. |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 BrowserInit browser_init; | 567 BrowserInit browser_init; |
| 555 int return_code; | 568 int return_code; |
| 556 browser_init.LaunchBrowser(*CommandLine::ForCurrentProcess(), | 569 browser_init.LaunchBrowser(*CommandLine::ForCurrentProcess(), |
| 557 profile, | 570 profile, |
| 558 FilePath(), | 571 FilePath(), |
| 559 true, | 572 true, |
| 560 &return_code); | 573 &return_code); |
| 561 } | 574 } |
| 562 | 575 |
| 563 } // namespace chromeos | 576 } // namespace chromeos |
| OLD | NEW |