| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_throttling_utils.h" | 5 #include "chrome/browser/chromeos/login/signin/merge_session_throttling_utils.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.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/oauth2_login_manager.h" | 15 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" |
| 16 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" | 16 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" |
| 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 17 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 18 #include "components/google/core/browser/google_util.h" | 19 #include "components/google/core/browser/google_util.h" |
| 19 #include "components/user_manager/user_manager.h" | 20 #include "components/user_manager/user_manager.h" |
| 20 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 22 #include "net/base/network_change_notifier.h" | 23 #include "net/base/network_change_notifier.h" |
| 23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 24 | 25 |
| 25 using content::BrowserThread; | 26 using content::BrowserThread; |
| 26 using content::WebContents; | 27 using content::WebContents; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // Check if there is any other profile to block on. | 99 // Check if there is any other profile to block on. |
| 99 if (ProfileSet::Get()->size() == 0) { | 100 if (ProfileSet::Get()->size() == 0) { |
| 100 base::AtomicRefCountInc(&g_all_profiles_restored_); | 101 base::AtomicRefCountInc(&g_all_profiles_restored_); |
| 101 DVLOG(1) << "All profiles merged " << g_all_profiles_restored_; | 102 DVLOG(1) << "All profiles merged " << g_all_profiles_restored_; |
| 102 } | 103 } |
| 103 } | 104 } |
| 104 | 105 |
| 105 bool ShouldDelayRequestForProfile(Profile* profile) { | 106 bool ShouldDelayRequestForProfile(Profile* profile) { |
| 106 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 107 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 107 | 108 |
| 109 if (!chromeos::ProfileHelper::Get()->GetUserByProfile(profile)) |
| 110 return false; |
| 111 |
| 112 if (!chromeos::ProfileHelper::Get()->GetUserByProfile(profile)-> |
| 113 is_profile_created()) { |
| 114 return false; |
| 115 } |
| 116 |
| 108 if (!user_manager::UserManager::Get()->IsUserLoggedIn()) { | 117 if (!user_manager::UserManager::Get()->IsUserLoggedIn()) { |
| 109 return false; | 118 return false; |
| 110 } else if (!user_manager::UserManager::Get() | 119 } else if (!user_manager::UserManager::Get() |
| 111 ->IsLoggedInAsUserWithGaiaAccount()) { | 120 ->IsLoggedInAsUserWithGaiaAccount()) { |
| 112 // This is not a regular user session, let's remove the throttle | 121 // This is not a regular user session, let's remove the throttle |
| 113 // permanently. | 122 // permanently. |
| 114 if (!AreAllSessionMergedAlready()) | 123 if (!AreAllSessionMergedAlready()) |
| 115 base::AtomicRefCountInc(&g_all_profiles_restored_); | 124 base::AtomicRefCountInc(&g_all_profiles_restored_); |
| 116 | 125 |
| 117 return false; | 126 return false; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 bool ShouldDelayUrl(const GURL& url) { | 187 bool ShouldDelayUrl(const GURL& url) { |
| 179 // If we are loading google properties while merge session is in progress, | 188 // If we are loading google properties while merge session is in progress, |
| 180 // we will show delayed loading page instead. | 189 // we will show delayed loading page instead. |
| 181 return !net::NetworkChangeNotifier::IsOffline() && | 190 return !net::NetworkChangeNotifier::IsOffline() && |
| 182 !AreAllSessionMergedAlready() && | 191 !AreAllSessionMergedAlready() && |
| 183 google_util::IsGoogleHostname(url.host_piece(), | 192 google_util::IsGoogleHostname(url.host_piece(), |
| 184 google_util::ALLOW_SUBDOMAIN); | 193 google_util::ALLOW_SUBDOMAIN); |
| 185 } | 194 } |
| 186 | 195 |
| 187 } // namespace merge_session_throttling_utils | 196 } // namespace merge_session_throttling_utils |
| OLD | NEW |