Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: chrome/browser/chromeos/login/fake_login_utils.cc

Issue 375413002: Replace chromeos::UserManager::Get() with chromeos::GetUserManager(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 13 matching lines...) Expand all
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,
33 LoginDisplayHost* login_host) { 33 LoginDisplayHost* login_host) {
34 34 if (!GetUserManager()->GetCurrentUserFlow()->ShouldLaunchBrowser()) {
35 if (!UserManager::Get()->GetCurrentUserFlow()->ShouldLaunchBrowser()) { 35 GetUserManager()->GetCurrentUserFlow()->LaunchExtraSteps(profile);
36 UserManager::Get()->GetCurrentUserFlow()->LaunchExtraSteps(profile);
37 return; 36 return;
38 } 37 }
39 login_host->BeforeSessionStart(); 38 login_host->BeforeSessionStart();
40 if (should_launch_browser_) { 39 if (should_launch_browser_) {
41 StartupBrowserCreator browser_creator; 40 StartupBrowserCreator browser_creator;
42 chrome::startup::IsFirstRun first_run = 41 chrome::startup::IsFirstRun first_run =
43 first_run::IsChromeFirstRun() ? chrome::startup::IS_FIRST_RUN 42 first_run::IsChromeFirstRun() ? chrome::startup::IS_FIRST_RUN
44 : chrome::startup::IS_NOT_FIRST_RUN; 43 : chrome::startup::IS_NOT_FIRST_RUN;
45 ASSERT_TRUE( 44 ASSERT_TRUE(
46 browser_creator.LaunchBrowser(*CommandLine::ForCurrentProcess(), 45 browser_creator.LaunchBrowser(*CommandLine::ForCurrentProcess(),
47 profile, 46 profile,
48 base::FilePath(), 47 base::FilePath(),
49 chrome::startup::IS_PROCESS_STARTUP, 48 chrome::startup::IS_PROCESS_STARTUP,
50 first_run, 49 first_run,
51 NULL)); 50 NULL));
52 } 51 }
53 if (login_host) 52 if (login_host)
54 login_host->Finalize(); 53 login_host->Finalize();
55 UserManager::Get()->SessionStarted(); 54 GetUserManager()->SessionStarted();
56 } 55 }
57 56
58 void FakeLoginUtils::PrepareProfile(const UserContext& user_context, 57 void FakeLoginUtils::PrepareProfile(const UserContext& user_context,
59 bool has_cookies, 58 bool has_cookies,
60 bool has_active_session, 59 bool has_active_session,
61 LoginUtils::Delegate* delegate) { 60 LoginUtils::Delegate* delegate) {
62 UserManager::Get()->UserLoggedIn( 61 GetUserManager()->UserLoggedIn(
63 user_context.GetUserID(), user_context.GetUserIDHash(), false); 62 user_context.GetUserID(), user_context.GetUserIDHash(), false);
64 User* user = UserManager::Get()->FindUserAndModify(user_context.GetUserID()); 63 User* user = GetUserManager()->FindUserAndModify(user_context.GetUserID());
65 DCHECK(user); 64 DCHECK(user);
66 65
67 // Make sure that we get the real Profile instead of the login Profile. 66 // Make sure that we get the real Profile instead of the login Profile.
68 user->set_profile_is_created(); 67 user->set_profile_is_created();
69 Profile* profile = ProfileHelper::Get()->GetProfileByUser(user); 68 Profile* profile = ProfileHelper::Get()->GetProfileByUser(user);
70 profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername, 69 profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername,
71 user_context.GetUserID()); 70 user_context.GetUserID());
72 71
73 if (UserManager::Get()->IsLoggedInAsLocallyManagedUser()) { 72 if (GetUserManager()->IsLoggedInAsLocallyManagedUser()) {
74 User* active_user = UserManager::Get()->GetActiveUser(); 73 User* active_user = GetUserManager()->GetActiveUser();
75 std::string supervised_user_sync_id = 74 std::string supervised_user_sync_id =
76 UserManager::Get()->GetSupervisedUserManager()-> 75 GetUserManager()->GetSupervisedUserManager()->GetUserSyncId(
77 GetUserSyncId(active_user->email()); 76 active_user->email());
78 if (supervised_user_sync_id.empty()) 77 if (supervised_user_sync_id.empty())
79 supervised_user_sync_id = "DUMMY ID"; 78 supervised_user_sync_id = "DUMMY ID";
80 profile->GetPrefs()->SetString(prefs::kSupervisedUserId, 79 profile->GetPrefs()->SetString(prefs::kSupervisedUserId,
81 supervised_user_sync_id); 80 supervised_user_sync_id);
82 } 81 }
83 82
84 content::NotificationService::current()->Notify( 83 content::NotificationService::current()->Notify(
85 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, 84 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
86 content::NotificationService::AllSources(), 85 content::NotificationService::AllSources(),
87 content::Details<Profile>(profile)); 86 content::Details<Profile>(profile));
(...skipping 23 matching lines...) Expand all
111 110
112 void FakeLoginUtils::SetExpectedCredentials(const UserContext& user_context) { 111 void FakeLoginUtils::SetExpectedCredentials(const UserContext& user_context) {
113 expected_user_context_ = user_context; 112 expected_user_context_ = user_context;
114 if (authenticator_) { 113 if (authenticator_) {
115 static_cast<MockAuthenticator*>(authenticator_.get())-> 114 static_cast<MockAuthenticator*>(authenticator_.get())->
116 SetExpectedCredentials(user_context); 115 SetExpectedCredentials(user_context);
117 } 116 }
118 } 117 }
119 118
120 } // namespace chromeos 119 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698