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

Side by Side Diff: chrome/browser/chromeos/login/signin/merge_session_throttle.cc

Issue 444903002: [cros] user_manager component - move UserManagerBase and UserManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: similarity Created 6 years, 4 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 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"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/threading/non_thread_safe.h" 13 #include "base/threading/non_thread_safe.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "chrome/browser/chromeos/login/signin/merge_session_load_page.h" 15 #include "chrome/browser/chromeos/login/signin/merge_session_load_page.h"
16 #include "chrome/browser/chromeos/login/signin/merge_session_xhr_request_waiter. h" 16 #include "chrome/browser/chromeos/login/signin/merge_session_xhr_request_waiter. h"
17 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" 17 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h"
18 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" 18 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h"
19 #include "chrome/browser/chromeos/login/users/user_manager.h"
20 #include "chrome/browser/chromeos/login/users/user_manager.h"
21 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
22 #include "components/google/core/browser/google_util.h" 20 #include "components/google/core/browser/google_util.h"
21 #include "components/user_manager/user_manager.h"
22 #include "components/user_manager/user_manager.h"
23 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/render_view_host.h" 24 #include "content/public/browser/render_view_host.h"
25 #include "content/public/browser/resource_controller.h" 25 #include "content/public/browser/resource_controller.h"
26 #include "content/public/browser/resource_request_info.h" 26 #include "content/public/browser/resource_request_info.h"
27 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
28 #include "net/base/net_errors.h" 28 #include "net/base/net_errors.h"
29 #include "net/base/net_util.h" 29 #include "net/base/net_util.h"
30 #include "net/base/network_change_notifier.h" 30 #include "net/base/network_change_notifier.h"
31 #include "net/url_request/url_request.h" 31 #include "net/url_request/url_request.h"
32 #include "net/url_request/url_request_context.h" 32 #include "net/url_request/url_request_context.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 DVLOG(1) << "All profiles merged " << all_profiles_restored_; 156 DVLOG(1) << "All profiles merged " << all_profiles_restored_;
157 } 157 }
158 } 158 }
159 159
160 // static 160 // static
161 bool MergeSessionThrottle::ShouldDelayRequest( 161 bool MergeSessionThrottle::ShouldDelayRequest(
162 int render_process_id, 162 int render_process_id,
163 int render_view_id) { 163 int render_view_id) {
164 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 164 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
165 165
166 if (!chromeos::UserManager::Get()->IsUserLoggedIn()) { 166 if (!user_manager::UserManager::Get()->IsUserLoggedIn()) {
167 return false; 167 return false;
168 } else if (!chromeos::UserManager::Get()->IsLoggedInAsRegularUser()) { 168 } else if (!user_manager::UserManager::Get()->IsLoggedInAsRegularUser()) {
169 // 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
170 // permanently. 170 // permanently.
171 if (!AreAllSessionMergedAlready()) 171 if (!AreAllSessionMergedAlready())
172 base::AtomicRefCountInc(&all_profiles_restored_); 172 base::AtomicRefCountInc(&all_profiles_restored_);
173 173
174 return false; 174 return false;
175 } 175 }
176 176
177 RenderViewHost* render_view_host = 177 RenderViewHost* render_view_host =
178 RenderViewHost::FromID(render_process_id, render_view_id); 178 RenderViewHost::FromID(render_process_id, render_view_id);
(...skipping 20 matching lines...) Expand all
199 if (!login_manager) 199 if (!login_manager)
200 return false; 200 return false;
201 201
202 switch (login_manager->state()) { 202 switch (login_manager->state()) {
203 case chromeos::OAuth2LoginManager::SESSION_RESTORE_NOT_STARTED: 203 case chromeos::OAuth2LoginManager::SESSION_RESTORE_NOT_STARTED:
204 // 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
205 // block for now. 205 // block for now.
206 // In theory this should not happen since we should 206 // In theory this should not happen since we should
207 // kick off the session restore process for the newly added profile 207 // kick off the session restore process for the newly added profile
208 // before we attempt loading any page. 208 // before we attempt loading any page.
209 if (chromeos::UserManager::Get()->IsLoggedInAsRegularUser() && 209 if (user_manager::UserManager::Get()->IsLoggedInAsRegularUser() &&
210 !chromeos::UserManager::Get()->IsLoggedInAsStub()) { 210 !user_manager::UserManager::Get()->IsLoggedInAsStub()) {
211 LOG(WARNING) << "Loading content for a profile without " 211 LOG(WARNING) << "Loading content for a profile without "
212 << "session restore?"; 212 << "session restore?";
213 } 213 }
214 return false; 214 return false;
215 case chromeos::OAuth2LoginManager::SESSION_RESTORE_PREPARING: 215 case chromeos::OAuth2LoginManager::SESSION_RESTORE_PREPARING:
216 case chromeos::OAuth2LoginManager::SESSION_RESTORE_IN_PROGRESS: { 216 case chromeos::OAuth2LoginManager::SESSION_RESTORE_IN_PROGRESS: {
217 // 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.
218 // If so, don't attempt to block page loading. 218 // If so, don't attempt to block page loading.
219 if ((base::Time::Now() - 219 if ((base::Time::Now() -
220 login_manager->session_restore_start()).InSeconds() > 220 login_manager->session_restore_start()).InSeconds() >
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 Profile* profile = Profile::FromBrowserContext( 266 Profile* profile = Profile::FromBrowserContext(
267 web_contents->GetBrowserContext()); 267 web_contents->GetBrowserContext());
268 (new chromeos::MergeSessionXHRRequestWaiter(profile, 268 (new chromeos::MergeSessionXHRRequestWaiter(profile,
269 callback))->StartWaiting(); 269 callback))->StartWaiting();
270 } 270 }
271 } else { 271 } else {
272 BrowserThread::PostTask( 272 BrowserThread::PostTask(
273 BrowserThread::IO, FROM_HERE, callback); 273 BrowserThread::IO, FROM_HERE, callback);
274 } 274 }
275 } 275 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698