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/signin/merge_session_throttle.h" | 5 #include "chrome/browser/chromeos/login/signin/merge_session_throttle.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 } | 157 } |
158 | 158 |
159 // static | 159 // static |
160 bool MergeSessionThrottle::ShouldDelayRequest( | 160 bool MergeSessionThrottle::ShouldDelayRequest( |
161 int render_process_id, | 161 int render_process_id, |
162 int render_view_id) { | 162 int render_view_id) { |
163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
164 | 164 |
165 if (!user_manager::UserManager::Get()->IsUserLoggedIn()) { | 165 if (!user_manager::UserManager::Get()->IsUserLoggedIn()) { |
166 return false; | 166 return false; |
167 } else if (!user_manager::UserManager::Get()->IsLoggedInAsRegularUser()) { | 167 } else if (!user_manager::UserManager::Get()-> |
168 IsLoggedInAsUserWithGaiaAccount()) { | |
168 // This is not a regular user session, let's remove the throttle | 169 // This is not a regular user session, let's remove the throttle |
bartfab (slow)
2014/11/27 12:51:50
Nit: s/regular/gaia/
| |
169 // permanently. | 170 // permanently. |
170 if (!AreAllSessionMergedAlready()) | 171 if (!AreAllSessionMergedAlready()) |
171 base::AtomicRefCountInc(&all_profiles_restored_); | 172 base::AtomicRefCountInc(&all_profiles_restored_); |
172 | 173 |
173 return false; | 174 return false; |
174 } | 175 } |
175 | 176 |
176 RenderViewHost* render_view_host = | 177 RenderViewHost* render_view_host = |
177 RenderViewHost::FromID(render_process_id, render_view_id); | 178 RenderViewHost::FromID(render_process_id, render_view_id); |
178 if (!render_view_host) | 179 if (!render_view_host) |
(...skipping 19 matching lines...) Expand all Loading... | |
198 if (!login_manager) | 199 if (!login_manager) |
199 return false; | 200 return false; |
200 | 201 |
201 switch (login_manager->state()) { | 202 switch (login_manager->state()) { |
202 case chromeos::OAuth2LoginManager::SESSION_RESTORE_NOT_STARTED: | 203 case chromeos::OAuth2LoginManager::SESSION_RESTORE_NOT_STARTED: |
203 // The session restore for this profile hasn't even started yet. Don't | 204 // The session restore for this profile hasn't even started yet. Don't |
204 // block for now. | 205 // block for now. |
205 // In theory this should not happen since we should | 206 // In theory this should not happen since we should |
206 // kick off the session restore process for the newly added profile | 207 // kick off the session restore process for the newly added profile |
207 // before we attempt loading any page. | 208 // before we attempt loading any page. |
208 if (user_manager::UserManager::Get()->IsLoggedInAsRegularUser() && | 209 if (user_manager::UserManager::Get()->IsLoggedInAsUserWithGaiaAccount() && |
209 !user_manager::UserManager::Get()->IsLoggedInAsStub()) { | 210 !user_manager::UserManager::Get()->IsLoggedInAsStub()) { |
210 LOG(WARNING) << "Loading content for a profile without " | 211 LOG(WARNING) << "Loading content for a profile without " |
211 << "session restore?"; | 212 << "session restore?"; |
212 } | 213 } |
213 return false; | 214 return false; |
214 case chromeos::OAuth2LoginManager::SESSION_RESTORE_PREPARING: | 215 case chromeos::OAuth2LoginManager::SESSION_RESTORE_PREPARING: |
215 case chromeos::OAuth2LoginManager::SESSION_RESTORE_IN_PROGRESS: { | 216 case chromeos::OAuth2LoginManager::SESSION_RESTORE_IN_PROGRESS: { |
216 // Check if the session restore has been going on for a while already. | 217 // Check if the session restore has been going on for a while already. |
217 // If so, don't attempt to block page loading. | 218 // If so, don't attempt to block page loading. |
218 if ((base::Time::Now() - | 219 if ((base::Time::Now() - |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 Profile* profile = Profile::FromBrowserContext( | 266 Profile* profile = Profile::FromBrowserContext( |
266 web_contents->GetBrowserContext()); | 267 web_contents->GetBrowserContext()); |
267 (new chromeos::MergeSessionXHRRequestWaiter(profile, | 268 (new chromeos::MergeSessionXHRRequestWaiter(profile, |
268 callback))->StartWaiting(); | 269 callback))->StartWaiting(); |
269 } | 270 } |
270 } else { | 271 } else { |
271 BrowserThread::PostTask( | 272 BrowserThread::PostTask( |
272 BrowserThread::IO, FROM_HERE, callback); | 273 BrowserThread::IO, FROM_HERE, callback); |
273 } | 274 } |
274 } | 275 } |
OLD | NEW |