| 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/chrome_browser_main.h" | 5 #include "chrome/browser/chrome_browser_main.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 return NULL; | 471 return NULL; |
| 472 } | 472 } |
| 473 | 473 |
| 474 #if defined(OS_CHROMEOS) | 474 #if defined(OS_CHROMEOS) |
| 475 | 475 |
| 476 // Class is used to login using passed username and password. | 476 // Class is used to login using passed username and password. |
| 477 // The instance will be deleted upon success or failure. | 477 // The instance will be deleted upon success or failure. |
| 478 class StubLogin : public chromeos::LoginStatusConsumer, | 478 class StubLogin : public chromeos::LoginStatusConsumer, |
| 479 public chromeos::LoginUtils::Delegate { | 479 public chromeos::LoginUtils::Delegate { |
| 480 public: | 480 public: |
| 481 StubLogin(std::string username, std::string password) { | 481 StubLogin(std::string username, std::string password) |
| 482 : pending_requests_(false), |
| 483 profile_prepared_(false) { |
| 482 authenticator_ = chromeos::LoginUtils::Get()->CreateAuthenticator(this); | 484 authenticator_ = chromeos::LoginUtils::Get()->CreateAuthenticator(this); |
| 483 authenticator_.get()->AuthenticateToLogin( | 485 authenticator_.get()->AuthenticateToLogin( |
| 484 g_browser_process->profile_manager()->GetDefaultProfile(), | 486 g_browser_process->profile_manager()->GetDefaultProfile(), |
| 485 username, | 487 username, |
| 486 password, | 488 password, |
| 487 std::string(), | 489 std::string(), |
| 488 std::string()); | 490 std::string()); |
| 489 } | 491 } |
| 490 | 492 |
| 491 ~StubLogin() { | 493 ~StubLogin() { |
| 492 chromeos::LoginUtils::Get()->DelegateDeleted(this); | 494 chromeos::LoginUtils::Get()->DelegateDeleted(this); |
| 493 } | 495 } |
| 494 | 496 |
| 495 void OnLoginFailure(const chromeos::LoginFailure& error) { | 497 void OnLoginFailure(const chromeos::LoginFailure& error) { |
| 496 LOG(ERROR) << "Login Failure: " << error.GetErrorString(); | 498 LOG(ERROR) << "Login Failure: " << error.GetErrorString(); |
| 497 delete this; | 499 delete this; |
| 498 } | 500 } |
| 499 | 501 |
| 500 void OnLoginSuccess(const std::string& username, | 502 void OnLoginSuccess(const std::string& username, |
| 501 const std::string& password, | 503 const std::string& password, |
| 502 const GaiaAuthConsumer::ClientLoginResult& credentials, | 504 const GaiaAuthConsumer::ClientLoginResult& credentials, |
| 503 bool pending_requests, | 505 bool pending_requests, |
| 504 bool using_oauth) { | 506 bool using_oauth) { |
| 505 // Will call OnProfilePrepared in the end. | 507 pending_requests_ = pending_requests; |
| 506 chromeos::LoginUtils::Get()->PrepareProfile(username, | 508 if (!profile_prepared_) { |
| 507 password, | 509 // Will call OnProfilePrepared in the end. |
| 508 credentials, | 510 chromeos::LoginUtils::Get()->PrepareProfile(username, |
| 509 pending_requests, | 511 password, |
| 510 using_oauth, | 512 credentials, |
| 511 false, | 513 pending_requests, |
| 512 this); | 514 using_oauth, |
| 515 false, |
| 516 this); |
| 517 } else if (!pending_requests) { |
| 518 delete this; |
| 519 } |
| 513 } | 520 } |
| 514 | 521 |
| 515 // LoginUtils::Delegate implementation: | 522 // LoginUtils::Delegate implementation: |
| 516 virtual void OnProfilePrepared(Profile* profile) { | 523 virtual void OnProfilePrepared(Profile* profile) { |
| 524 profile_prepared_ = true; |
| 517 chromeos::LoginUtils::DoBrowserLaunch(profile, NULL); | 525 chromeos::LoginUtils::DoBrowserLaunch(profile, NULL); |
| 518 delete this; | 526 if (!pending_requests_) |
| 527 delete this; |
| 519 } | 528 } |
| 520 | 529 |
| 521 scoped_refptr<chromeos::Authenticator> authenticator_; | 530 scoped_refptr<chromeos::Authenticator> authenticator_; |
| 531 bool pending_requests_; |
| 532 bool profile_prepared_; |
| 522 }; | 533 }; |
| 523 | 534 |
| 524 void OptionallyRunChromeOSLoginManager(const CommandLine& parsed_command_line, | 535 void OptionallyRunChromeOSLoginManager(const CommandLine& parsed_command_line, |
| 525 Profile* profile) { | 536 Profile* profile) { |
| 526 if (parsed_command_line.HasSwitch(switches::kLoginManager)) { | 537 if (parsed_command_line.HasSwitch(switches::kLoginManager)) { |
| 527 std::string first_screen = | 538 std::string first_screen = |
| 528 parsed_command_line.GetSwitchValueASCII(switches::kLoginScreen); | 539 parsed_command_line.GetSwitchValueASCII(switches::kLoginScreen); |
| 529 std::string size_arg = | 540 std::string size_arg = |
| 530 parsed_command_line.GetSwitchValueASCII( | 541 parsed_command_line.GetSwitchValueASCII( |
| 531 switches::kLoginScreenSize); | 542 switches::kLoginScreenSize); |
| (...skipping 1569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2101 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && | 2112 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && |
| 2102 (pre_read == "0" || pre_read == "1")) { | 2113 (pre_read == "0" || pre_read == "1")) { |
| 2103 std::string uma_name(name); | 2114 std::string uma_name(name); |
| 2104 uma_name += "_PreRead"; | 2115 uma_name += "_PreRead"; |
| 2105 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; | 2116 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; |
| 2106 AddPreReadHistogramTime(uma_name.c_str(), time); | 2117 AddPreReadHistogramTime(uma_name.c_str(), time); |
| 2107 } | 2118 } |
| 2108 #endif | 2119 #endif |
| 2109 #endif | 2120 #endif |
| 2110 } | 2121 } |
| OLD | NEW |