| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/supervised_user/supervised_user_google_auth_navigation_
throttle.h" | 5 #include "chrome/browser/supervised_user/supervised_user_google_auth_navigation_
throttle.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/signin/signin_manager_factory.h" | 9 #include "chrome/browser/signin/signin_manager_factory.h" |
| 10 #include "chrome/browser/supervised_user/child_accounts/child_account_service.h" | 10 #include "chrome/browser/supervised_user/child_accounts/child_account_service.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 if (!google_util::IsGoogleSearchUrl(url) && | 67 if (!google_util::IsGoogleSearchUrl(url) && |
| 68 !google_util::IsGoogleHomePageUrl(url) && | 68 !google_util::IsGoogleHomePageUrl(url) && |
| 69 !google_util::IsYoutubeDomainUrl(url, google_util::ALLOW_SUBDOMAIN, | 69 !google_util::IsYoutubeDomainUrl(url, google_util::ALLOW_SUBDOMAIN, |
| 70 google_util::ALLOW_NON_STANDARD_PORTS)) { | 70 google_util::ALLOW_NON_STANDARD_PORTS)) { |
| 71 return content::NavigationThrottle::PROCEED; | 71 return content::NavigationThrottle::PROCEED; |
| 72 } | 72 } |
| 73 | 73 |
| 74 content::NavigationThrottle::ThrottleCheckResult result = | 74 content::NavigationThrottle::ThrottleCheckResult result = |
| 75 ShouldProceed(child_account_service_->IsGoogleAuthenticated()); | 75 ShouldProceed(child_account_service_->IsGoogleAuthenticated()); |
| 76 | 76 |
| 77 if (result == content::NavigationThrottle::DEFER) { | 77 if (result.action() == content::NavigationThrottle::DEFER) { |
| 78 google_auth_state_subscription_ = | 78 google_auth_state_subscription_ = |
| 79 child_account_service_->ObserveGoogleAuthState( | 79 child_account_service_->ObserveGoogleAuthState( |
| 80 base::Bind(&SupervisedUserGoogleAuthNavigationThrottle:: | 80 base::Bind(&SupervisedUserGoogleAuthNavigationThrottle:: |
| 81 OnGoogleAuthStateChanged, | 81 OnGoogleAuthStateChanged, |
| 82 base::Unretained(this))); | 82 base::Unretained(this))); |
| 83 } | 83 } |
| 84 | 84 |
| 85 return result; | 85 return result; |
| 86 } | 86 } |
| 87 | 87 |
| 88 void SupervisedUserGoogleAuthNavigationThrottle::OnGoogleAuthStateChanged( | 88 void SupervisedUserGoogleAuthNavigationThrottle::OnGoogleAuthStateChanged( |
| 89 bool authenticated) { | 89 bool authenticated) { |
| 90 content::NavigationThrottle::ThrottleCheckResult result = | 90 content::NavigationThrottle::ThrottleCheckResult result = |
| 91 ShouldProceed(authenticated); | 91 ShouldProceed(authenticated); |
| 92 | 92 |
| 93 switch (result) { | 93 switch (result.action()) { |
| 94 case content::NavigationThrottle::PROCEED: { | 94 case content::NavigationThrottle::PROCEED: { |
| 95 google_auth_state_subscription_.reset(); | 95 google_auth_state_subscription_.reset(); |
| 96 navigation_handle()->Resume(); | 96 navigation_handle()->Resume(); |
| 97 break; | 97 break; |
| 98 } | 98 } |
| 99 case content::NavigationThrottle::CANCEL: | 99 case content::NavigationThrottle::CANCEL: |
| 100 case content::NavigationThrottle::CANCEL_AND_IGNORE: { | 100 case content::NavigationThrottle::CANCEL_AND_IGNORE: { |
| 101 navigation_handle()->CancelDeferredNavigation(result); | 101 navigation_handle()->CancelDeferredNavigation(result); |
| 102 break; | 102 break; |
| 103 } | 103 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 if (reauth_successful) { | 145 if (reauth_successful) { |
| 146 // If reauthentication was not successful, wait until the cookies are | 146 // If reauthentication was not successful, wait until the cookies are |
| 147 // refreshed, which will call us back separately. | 147 // refreshed, which will call us back separately. |
| 148 return; | 148 return; |
| 149 } | 149 } |
| 150 | 150 |
| 151 // Otherwise cancel immediately. | 151 // Otherwise cancel immediately. |
| 152 navigation_handle()->CancelDeferredNavigation( | 152 navigation_handle()->CancelDeferredNavigation( |
| 153 content::NavigationThrottle::CANCEL_AND_IGNORE); | 153 content::NavigationThrottle::CANCEL_AND_IGNORE); |
| 154 } | 154 } |
| OLD | NEW |