| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/login/fake_login_utils.h" | 5 #include "chrome/browser/chromeos/login/fake_login_utils.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/chromeos/login/login_display_host.h" | 10 #include "chrome/browser/chromeos/login/login_display_host.h" |
| 11 #include "chrome/browser/chromeos/login/mock_authenticator.h" | 11 #include "chrome/browser/chromeos/login/mock_authenticator.h" |
| 12 #include "chrome/browser/first_run/first_run.h" | 12 #include "chrome/browser/first_run/first_run.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 14 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 15 #include "chrome/common/chrome_constants.h" | 15 #include "chrome/common/chrome_constants.h" |
| 16 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
| 17 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| 20 namespace chromeos { | 20 namespace chromeos { |
| 21 | 21 |
| 22 FakeLoginUtils::FakeLoginUtils() : should_launch_browser_(false) {} | 22 FakeLoginUtils::FakeLoginUtils() : should_launch_browser_(false) {} |
| 23 | 23 |
| 24 FakeLoginUtils::~FakeLoginUtils() {} | 24 FakeLoginUtils::~FakeLoginUtils() {} |
| 25 | 25 |
| 26 void FakeLoginUtils::DoBrowserLaunch(Profile* profile, | 26 void FakeLoginUtils::DoBrowserLaunch(Profile* profile, |
| 27 LoginDisplayHost* login_host) { | 27 LoginDisplayHost* login_host) { |
| 28 login_host->BeforeSessionStart(); |
| 28 if (should_launch_browser_) { | 29 if (should_launch_browser_) { |
| 29 StartupBrowserCreator browser_creator; | 30 StartupBrowserCreator browser_creator; |
| 30 chrome::startup::IsFirstRun first_run = | 31 chrome::startup::IsFirstRun first_run = |
| 31 first_run::IsChromeFirstRun() ? chrome::startup::IS_FIRST_RUN | 32 first_run::IsChromeFirstRun() ? chrome::startup::IS_FIRST_RUN |
| 32 : chrome::startup::IS_NOT_FIRST_RUN; | 33 : chrome::startup::IS_NOT_FIRST_RUN; |
| 33 ASSERT_TRUE( | 34 ASSERT_TRUE( |
| 34 browser_creator.LaunchBrowser(*CommandLine::ForCurrentProcess(), | 35 browser_creator.LaunchBrowser(*CommandLine::ForCurrentProcess(), |
| 35 profile, | 36 profile, |
| 36 base::FilePath(), | 37 base::FilePath(), |
| 37 chrome::startup::IS_PROCESS_STARTUP, | 38 chrome::startup::IS_PROCESS_STARTUP, |
| 38 first_run, | 39 first_run, |
| 39 NULL)); | 40 NULL)); |
| 40 } | 41 } |
| 41 if (login_host) | 42 if (login_host) |
| 42 login_host->Finalize(); | 43 login_host->Finalize(); |
| 44 UserManager::Get()->SessionStarted(); |
| 43 } | 45 } |
| 44 | 46 |
| 45 void FakeLoginUtils::PrepareProfile(const UserContext& user_context, | 47 void FakeLoginUtils::PrepareProfile(const UserContext& user_context, |
| 46 const std::string& display_email, | 48 const std::string& display_email, |
| 47 bool using_oauth, | 49 bool using_oauth, |
| 48 bool has_cookies, | 50 bool has_cookies, |
| 49 bool has_active_session, | 51 bool has_active_session, |
| 50 LoginUtils::Delegate* delegate) { | 52 LoginUtils::Delegate* delegate) { |
| 51 UserManager::Get()->UserLoggedIn( | 53 UserManager::Get()->UserLoggedIn( |
| 52 user_context.username, user_context.username_hash, false); | 54 user_context.username, user_context.username_hash, false); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 const std::string& password) { | 107 const std::string& password) { |
| 106 expected_username_ = username; | 108 expected_username_ = username; |
| 107 expected_password_ = password; | 109 expected_password_ = password; |
| 108 if (authenticator_.get()) { | 110 if (authenticator_.get()) { |
| 109 static_cast<MockAuthenticator*>(authenticator_.get())-> | 111 static_cast<MockAuthenticator*>(authenticator_.get())-> |
| 110 SetExpectedCredentials(username, password); | 112 SetExpectedCredentials(username, password); |
| 111 } | 113 } |
| 112 } | 114 } |
| 113 | 115 |
| 114 } // namespace chromeos | 116 } // namespace chromeos |
| OLD | NEW |