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/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/chromeos/login/auth/mock_authenticator.h" | 10 #include "chrome/browser/chromeos/login/auth/mock_authenticator.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/user_flow.h" | 12 #include "chrome/browser/chromeos/login/user_flow.h" |
13 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 13 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
14 #include "chrome/browser/chromeos/login/users/user.h" | |
15 #include "chrome/browser/chromeos/login/users/user_manager.h" | 14 #include "chrome/browser/chromeos/login/users/user_manager.h" |
16 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 15 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
17 #include "chrome/browser/first_run/first_run.h" | 16 #include "chrome/browser/first_run/first_run.h" |
18 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 18 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
20 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
21 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
22 #include "chromeos/login/auth/user_context.h" | 21 #include "chromeos/login/auth/user_context.h" |
| 22 #include "components/user_manager/user.h" |
23 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
25 | 25 |
26 namespace chromeos { | 26 namespace chromeos { |
27 | 27 |
28 FakeLoginUtils::FakeLoginUtils() : should_launch_browser_(false) {} | 28 FakeLoginUtils::FakeLoginUtils() : should_launch_browser_(false) {} |
29 | 29 |
30 FakeLoginUtils::~FakeLoginUtils() {} | 30 FakeLoginUtils::~FakeLoginUtils() {} |
31 | 31 |
32 void FakeLoginUtils::DoBrowserLaunch(Profile* profile, | 32 void FakeLoginUtils::DoBrowserLaunch(Profile* profile, |
(...skipping 21 matching lines...) Expand all Loading... |
54 login_host->Finalize(); | 54 login_host->Finalize(); |
55 UserManager::Get()->SessionStarted(); | 55 UserManager::Get()->SessionStarted(); |
56 } | 56 } |
57 | 57 |
58 void FakeLoginUtils::PrepareProfile(const UserContext& user_context, | 58 void FakeLoginUtils::PrepareProfile(const UserContext& user_context, |
59 bool has_cookies, | 59 bool has_cookies, |
60 bool has_active_session, | 60 bool has_active_session, |
61 LoginUtils::Delegate* delegate) { | 61 LoginUtils::Delegate* delegate) { |
62 UserManager::Get()->UserLoggedIn( | 62 UserManager::Get()->UserLoggedIn( |
63 user_context.GetUserID(), user_context.GetUserIDHash(), false); | 63 user_context.GetUserID(), user_context.GetUserIDHash(), false); |
64 User* user = UserManager::Get()->FindUserAndModify(user_context.GetUserID()); | 64 user_manager::User* user = |
| 65 UserManager::Get()->FindUserAndModify(user_context.GetUserID()); |
65 DCHECK(user); | 66 DCHECK(user); |
66 | 67 |
67 // Make sure that we get the real Profile instead of the login Profile. | 68 // Make sure that we get the real Profile instead of the login Profile. |
68 user->set_profile_is_created(); | 69 user->set_profile_is_created(); |
69 Profile* profile = ProfileHelper::Get()->GetProfileByUser(user); | 70 Profile* profile = ProfileHelper::Get()->GetProfileByUser(user); |
70 profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername, | 71 profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername, |
71 user_context.GetUserID()); | 72 user_context.GetUserID()); |
72 | 73 |
73 if (UserManager::Get()->IsLoggedInAsSupervisedUser()) { | 74 if (UserManager::Get()->IsLoggedInAsSupervisedUser()) { |
74 User* active_user = UserManager::Get()->GetActiveUser(); | 75 user_manager::User* active_user = UserManager::Get()->GetActiveUser(); |
75 std::string supervised_user_sync_id = | 76 std::string supervised_user_sync_id = |
76 UserManager::Get()->GetSupervisedUserManager()-> | 77 UserManager::Get()->GetSupervisedUserManager()-> |
77 GetUserSyncId(active_user->email()); | 78 GetUserSyncId(active_user->email()); |
78 if (supervised_user_sync_id.empty()) | 79 if (supervised_user_sync_id.empty()) |
79 supervised_user_sync_id = "DUMMY ID"; | 80 supervised_user_sync_id = "DUMMY ID"; |
80 profile->GetPrefs()->SetString(prefs::kSupervisedUserId, | 81 profile->GetPrefs()->SetString(prefs::kSupervisedUserId, |
81 supervised_user_sync_id); | 82 supervised_user_sync_id); |
82 } | 83 } |
83 | 84 |
84 content::NotificationService::current()->Notify( | 85 content::NotificationService::current()->Notify( |
(...skipping 26 matching lines...) Expand all Loading... |
111 | 112 |
112 void FakeLoginUtils::SetExpectedCredentials(const UserContext& user_context) { | 113 void FakeLoginUtils::SetExpectedCredentials(const UserContext& user_context) { |
113 expected_user_context_ = user_context; | 114 expected_user_context_ = user_context; |
114 if (authenticator_) { | 115 if (authenticator_) { |
115 static_cast<MockAuthenticator*>(authenticator_.get())-> | 116 static_cast<MockAuthenticator*>(authenticator_.get())-> |
116 SetExpectedCredentials(user_context); | 117 SetExpectedCredentials(user_context); |
117 } | 118 } |
118 } | 119 } |
119 | 120 |
120 } // namespace chromeos | 121 } // namespace chromeos |
OLD | NEW |