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

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

Powered by Google App Engine
This is Rietveld 408576698