| 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/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| 11 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 11 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 12 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 12 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 13 #include "chrome/browser/chromeos/login/user_flow.h" | 13 #include "chrome/browser/chromeos/login/user_flow.h" |
| 14 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 14 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
| 15 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 15 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
| 16 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 16 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 17 #include "chrome/browser/first_run/first_run.h" | 17 #include "chrome/browser/first_run/first_run.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/signin/signin_manager_factory.h" |
| 19 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 20 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 20 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 21 #include "chrome/test/base/testing_profile.h" | 22 #include "chrome/test/base/testing_profile.h" |
| 22 #include "chromeos/login/auth/mock_authenticator.h" | 23 #include "chromeos/login/auth/mock_authenticator.h" |
| 23 #include "chromeos/login/auth/user_context.h" | 24 #include "chromeos/login/auth/user_context.h" |
| 25 #include "components/signin/core/browser/signin_manager.h" |
| 24 #include "components/user_manager/user.h" | 26 #include "components/user_manager/user.h" |
| 25 #include "components/user_manager/user_manager.h" | 27 #include "components/user_manager/user_manager.h" |
| 26 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 28 | 30 |
| 29 namespace chromeos { | 31 namespace chromeos { |
| 30 | 32 |
| 31 FakeLoginUtils::FakeLoginUtils() : should_launch_browser_(false) {} | 33 FakeLoginUtils::FakeLoginUtils() : should_launch_browser_(false) {} |
| 32 | 34 |
| 33 FakeLoginUtils::~FakeLoginUtils() {} | 35 FakeLoginUtils::~FakeLoginUtils() {} |
| (...skipping 30 matching lines...) Expand all Loading... |
| 64 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 66 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 65 user_manager->UserLoggedIn( | 67 user_manager->UserLoggedIn( |
| 66 user_context.GetUserID(), user_context.GetUserIDHash(), false); | 68 user_context.GetUserID(), user_context.GetUserIDHash(), false); |
| 67 user_manager::User* user = | 69 user_manager::User* user = |
| 68 user_manager->FindUserAndModify(user_context.GetUserID()); | 70 user_manager->FindUserAndModify(user_context.GetUserID()); |
| 69 DCHECK(user); | 71 DCHECK(user); |
| 70 | 72 |
| 71 // Make sure that we get the real Profile instead of the login Profile. | 73 // Make sure that we get the real Profile instead of the login Profile. |
| 72 user->set_profile_is_created(); | 74 user->set_profile_is_created(); |
| 73 Profile* profile = ProfileHelper::Get()->GetProfileByUserUnsafe(user); | 75 Profile* profile = ProfileHelper::Get()->GetProfileByUserUnsafe(user); |
| 74 profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername, | 76 SigninManagerFactory::GetForProfile(profile)->SetAuthenticatedUsername( |
| 75 user_context.GetUserID()); | 77 user_context.GetUserID()); |
| 76 | 78 |
| 77 if (user_manager->IsLoggedInAsSupervisedUser()) { | 79 if (user_manager->IsLoggedInAsSupervisedUser()) { |
| 78 user_manager::User* active_user = user_manager->GetActiveUser(); | 80 user_manager::User* active_user = user_manager->GetActiveUser(); |
| 79 std::string supervised_user_sync_id = | 81 std::string supervised_user_sync_id = |
| 80 ChromeUserManager::Get()->GetSupervisedUserManager()->GetUserSyncId( | 82 ChromeUserManager::Get()->GetSupervisedUserManager()->GetUserSyncId( |
| 81 active_user->email()); | 83 active_user->email()); |
| 82 if (supervised_user_sync_id.empty()) | 84 if (supervised_user_sync_id.empty()) |
| 83 supervised_user_sync_id = "DUMMY ID"; | 85 supervised_user_sync_id = "DUMMY ID"; |
| 84 profile->GetPrefs()->SetString(prefs::kSupervisedUserId, | 86 profile->GetPrefs()->SetString(prefs::kSupervisedUserId, |
| 85 supervised_user_sync_id); | 87 supervised_user_sync_id); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 121 |
| 120 void FakeLoginUtils::SetExpectedCredentials(const UserContext& user_context) { | 122 void FakeLoginUtils::SetExpectedCredentials(const UserContext& user_context) { |
| 121 expected_user_context_ = user_context; | 123 expected_user_context_ = user_context; |
| 122 if (authenticator_.get()) { | 124 if (authenticator_.get()) { |
| 123 static_cast<MockAuthenticator*>(authenticator_.get())-> | 125 static_cast<MockAuthenticator*>(authenticator_.get())-> |
| 124 SetExpectedCredentials(user_context); | 126 SetExpectedCredentials(user_context); |
| 125 } | 127 } |
| 126 } | 128 } |
| 127 | 129 |
| 128 } // namespace chromeos | 130 } // namespace chromeos |
| OLD | NEW |