| 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 DVLOG(1) << "All profiles merged " << all_profiles_restored_; | 157 DVLOG(1) << "All profiles merged " << all_profiles_restored_; |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 | 160 |
| 161 // static | 161 // static |
| 162 bool MergeSessionThrottle::ShouldDelayRequest( | 162 bool MergeSessionThrottle::ShouldDelayRequest( |
| 163 int render_process_id, | 163 int render_process_id, |
| 164 int render_view_id) { | 164 int render_view_id) { |
| 165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 166 | 166 |
| 167 if (!chromeos::UserManager::Get()->IsUserLoggedIn()) { | 167 if (!chromeos::GetUserManager()->IsUserLoggedIn()) { |
| 168 return false; | 168 return false; |
| 169 } else if (!chromeos::UserManager::Get()->IsLoggedInAsRegularUser()) { | 169 } else if (!chromeos::GetUserManager()->IsLoggedInAsRegularUser()) { |
| 170 // This is not a regular user session, let's remove the throttle | 170 // This is not a regular user session, let's remove the throttle |
| 171 // permanently. | 171 // permanently. |
| 172 if (!AreAllSessionMergedAlready()) | 172 if (!AreAllSessionMergedAlready()) |
| 173 base::AtomicRefCountInc(&all_profiles_restored_); | 173 base::AtomicRefCountInc(&all_profiles_restored_); |
| 174 | 174 |
| 175 return false; | 175 return false; |
| 176 } | 176 } |
| 177 | 177 |
| 178 RenderViewHost* render_view_host = | 178 RenderViewHost* render_view_host = |
| 179 RenderViewHost::FromID(render_process_id, render_view_id); | 179 RenderViewHost::FromID(render_process_id, render_view_id); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 200 if (!login_manager) | 200 if (!login_manager) |
| 201 return false; | 201 return false; |
| 202 | 202 |
| 203 switch (login_manager->state()) { | 203 switch (login_manager->state()) { |
| 204 case chromeos::OAuth2LoginManager::SESSION_RESTORE_NOT_STARTED: | 204 case chromeos::OAuth2LoginManager::SESSION_RESTORE_NOT_STARTED: |
| 205 // The session restore for this profile hasn't even started yet. Don't | 205 // The session restore for this profile hasn't even started yet. Don't |
| 206 // block for now. | 206 // block for now. |
| 207 // In theory this should not happen since we should | 207 // In theory this should not happen since we should |
| 208 // kick off the session restore process for the newly added profile | 208 // kick off the session restore process for the newly added profile |
| 209 // before we attempt loading any page. | 209 // before we attempt loading any page. |
| 210 if (chromeos::UserManager::Get()->IsLoggedInAsRegularUser() && | 210 if (chromeos::GetUserManager()->IsLoggedInAsRegularUser() && |
| 211 !chromeos::UserManager::Get()->IsLoggedInAsStub()) { | 211 !chromeos::GetUserManager()->IsLoggedInAsStub()) { |
| 212 LOG(WARNING) << "Loading content for a profile without " | 212 LOG(WARNING) << "Loading content for a profile without " |
| 213 << "session restore?"; | 213 << "session restore?"; |
| 214 } | 214 } |
| 215 return false; | 215 return false; |
| 216 case chromeos::OAuth2LoginManager::SESSION_RESTORE_PREPARING: | 216 case chromeos::OAuth2LoginManager::SESSION_RESTORE_PREPARING: |
| 217 case chromeos::OAuth2LoginManager::SESSION_RESTORE_IN_PROGRESS: { | 217 case chromeos::OAuth2LoginManager::SESSION_RESTORE_IN_PROGRESS: { |
| 218 // Check if the session restore has been going on for a while already. | 218 // Check if the session restore has been going on for a while already. |
| 219 // If so, don't attempt to block page loading. | 219 // If so, don't attempt to block page loading. |
| 220 if ((base::Time::Now() - | 220 if ((base::Time::Now() - |
| 221 login_manager->session_restore_start()).InSeconds() > | 221 login_manager->session_restore_start()).InSeconds() > |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 Profile* profile = Profile::FromBrowserContext( | 267 Profile* profile = Profile::FromBrowserContext( |
| 268 web_contents->GetBrowserContext()); | 268 web_contents->GetBrowserContext()); |
| 269 (new chromeos::MergeSessionXHRRequestWaiter(profile, | 269 (new chromeos::MergeSessionXHRRequestWaiter(profile, |
| 270 callback))->StartWaiting(); | 270 callback))->StartWaiting(); |
| 271 } | 271 } |
| 272 } else { | 272 } else { |
| 273 BrowserThread::PostTask( | 273 BrowserThread::PostTask( |
| 274 BrowserThread::IO, FROM_HERE, callback); | 274 BrowserThread::IO, FROM_HERE, callback); |
| 275 } | 275 } |
| 276 } | 276 } |
| OLD | NEW |