OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/saml/saml_offline_signin_limiter.h" | 5 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 now - last_gaia_signin_time; | 120 now - last_gaia_signin_time; |
121 if (time_since_last_gaia_signin >= offline_signin_time_limit) { | 121 if (time_since_last_gaia_signin >= offline_signin_time_limit) { |
122 // If the limit already expired, set the flag enforcing online login | 122 // If the limit already expired, set the flag enforcing online login |
123 // immediately and return. | 123 // immediately and return. |
124 ForceOnlineLogin(); | 124 ForceOnlineLogin(); |
125 return; | 125 return; |
126 } | 126 } |
127 | 127 |
128 // Arm |offline_signin_limit_timer_| so that it sets the flag enforcing online | 128 // Arm |offline_signin_limit_timer_| so that it sets the flag enforcing online |
129 // login when the limit expires. | 129 // login when the limit expires. |
130 offline_signin_limit_timer_.reset( | 130 offline_signin_limit_timer_.reset(new base::OneShotTimer); |
131 new base::OneShotTimer<SAMLOfflineSigninLimiter>); | |
132 offline_signin_limit_timer_->Start( | 131 offline_signin_limit_timer_->Start( |
133 FROM_HERE, | 132 FROM_HERE, |
134 offline_signin_time_limit - time_since_last_gaia_signin, | 133 offline_signin_time_limit - time_since_last_gaia_signin, |
135 this, | 134 this, |
136 &SAMLOfflineSigninLimiter::ForceOnlineLogin); | 135 &SAMLOfflineSigninLimiter::ForceOnlineLogin); |
137 } | 136 } |
138 | 137 |
139 void SAMLOfflineSigninLimiter::ForceOnlineLogin() { | 138 void SAMLOfflineSigninLimiter::ForceOnlineLogin() { |
140 const user_manager::User* user = | 139 const user_manager::User* user = |
141 ProfileHelper::Get()->GetUserByProfile(profile_); | 140 ProfileHelper::Get()->GetUserByProfile(profile_); |
142 if (!user) { | 141 if (!user) { |
143 NOTREACHED(); | 142 NOTREACHED(); |
144 return; | 143 return; |
145 } | 144 } |
146 | 145 |
147 user_manager::UserManager::Get()->SaveForceOnlineSignin(user->email(), true); | 146 user_manager::UserManager::Get()->SaveForceOnlineSignin(user->email(), true); |
148 RecordReauthReason(user->email(), ReauthReason::SAML_REAUTH_POLICY); | 147 RecordReauthReason(user->email(), ReauthReason::SAML_REAUTH_POLICY); |
149 offline_signin_limit_timer_.reset(); | 148 offline_signin_limit_timer_.reset(); |
150 } | 149 } |
151 | 150 |
152 } // namespace chromeos | 151 } // namespace chromeos |
OLD | NEW |