| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/sync/one_click_signin_helper.h" | 5 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 } | 772 } |
| 773 | 773 |
| 774 VLOG(1) << "OneClickSigninHelper::CanOffer: yes we can"; | 774 VLOG(1) << "OneClickSigninHelper::CanOffer: yes we can"; |
| 775 return true; | 775 return true; |
| 776 } | 776 } |
| 777 | 777 |
| 778 // static | 778 // static |
| 779 OneClickSigninHelper::Offer OneClickSigninHelper::CanOfferOnIOThread( | 779 OneClickSigninHelper::Offer OneClickSigninHelper::CanOfferOnIOThread( |
| 780 net::URLRequest* request, | 780 net::URLRequest* request, |
| 781 ProfileIOData* io_data) { | 781 ProfileIOData* io_data) { |
| 782 return CanOfferOnIOThreadImpl(request->url(), request->referrer(), | 782 return CanOfferOnIOThreadImpl(request->url(), request, io_data); |
| 783 request, io_data); | |
| 784 } | 783 } |
| 785 | 784 |
| 786 // static | 785 // static |
| 787 OneClickSigninHelper::Offer OneClickSigninHelper::CanOfferOnIOThreadImpl( | 786 OneClickSigninHelper::Offer OneClickSigninHelper::CanOfferOnIOThreadImpl( |
| 788 const GURL& url, | 787 const GURL& url, |
| 789 const std::string& referrer, | |
| 790 base::SupportsUserData* request, | 788 base::SupportsUserData* request, |
| 791 ProfileIOData* io_data) { | 789 ProfileIOData* io_data) { |
| 792 if (!gaia::IsGaiaSignonRealm(url.GetOrigin())) | 790 if (!gaia::IsGaiaSignonRealm(url.GetOrigin())) |
| 793 return IGNORE_REQUEST; | 791 return IGNORE_REQUEST; |
| 794 | 792 |
| 795 if (!io_data) | 793 if (!io_data) |
| 796 return DONT_OFFER; | 794 return DONT_OFFER; |
| 797 | 795 |
| 798 // Check for incognito before other parts of the io_data, since those | 796 // Check for incognito before other parts of the io_data, since those |
| 799 // members may not be initalized. | 797 // members may not be initalized. |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1162 void OneClickSigninHelper::DidStartNavigationToPendingEntry( | 1160 void OneClickSigninHelper::DidStartNavigationToPendingEntry( |
| 1163 const GURL& url, | 1161 const GURL& url, |
| 1164 content::NavigationController::ReloadType reload_type) { | 1162 content::NavigationController::ReloadType reload_type) { |
| 1165 VLOG(1) << "OneClickSigninHelper::DidStartNavigationToPendingEntry: url=" << | 1163 VLOG(1) << "OneClickSigninHelper::DidStartNavigationToPendingEntry: url=" << |
| 1166 url.spec(); | 1164 url.spec(); |
| 1167 // If the tab navigates to a new page, and this page is not a valid Gaia | 1165 // If the tab navigates to a new page, and this page is not a valid Gaia |
| 1168 // sign in redirect or reponse, or the expected continue URL, make sure to | 1166 // sign in redirect or reponse, or the expected continue URL, make sure to |
| 1169 // clear the internal state. This is needed to detect navigations in the | 1167 // clear the internal state. This is needed to detect navigations in the |
| 1170 // middle of the sign in process that may redirect back to the sign in | 1168 // middle of the sign in process that may redirect back to the sign in |
| 1171 // process (see crbug.com/181163 for details). | 1169 // process (see crbug.com/181163 for details). |
| 1172 const GURL continue_url = signin::GetNextPageURLForPromoURL( | |
| 1173 signin::GetPromoURL(signin::SOURCE_START_PAGE, false)); | |
| 1174 GURL::Replacements replacements; | 1170 GURL::Replacements replacements; |
| 1175 replacements.ClearQuery(); | 1171 replacements.ClearQuery(); |
| 1176 | 1172 |
| 1177 if (!IsValidGaiaSigninRedirectOrResponseURL(url) && | 1173 if (!IsValidGaiaSigninRedirectOrResponseURL(url) && |
| 1178 continue_url_.is_valid() && | 1174 continue_url_.is_valid() && |
| 1179 url.ReplaceComponents(replacements) != | 1175 url.ReplaceComponents(replacements) != |
| 1180 continue_url_.ReplaceComponents(replacements)) { | 1176 continue_url_.ReplaceComponents(replacements)) { |
| 1181 if (++untrusted_navigations_since_signin_visit_ > kMaxNavigationsSince) | 1177 if (++untrusted_navigations_since_signin_visit_ > kMaxNavigationsSince) |
| 1182 CleanTransientState(); | 1178 CleanTransientState(); |
| 1183 } | 1179 } |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1521 // If the web contents is showing a blank page and not about to be closed, | 1517 // If the web contents is showing a blank page and not about to be closed, |
| 1522 // redirect to the NTP or apps page. | 1518 // redirect to the NTP or apps page. |
| 1523 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) && | 1519 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) && |
| 1524 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) { | 1520 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) { |
| 1525 RedirectToNtpOrAppsPage( | 1521 RedirectToNtpOrAppsPage( |
| 1526 web_contents(), | 1522 web_contents(), |
| 1527 signin::GetSourceForPromoURL(original_continue_url_)); | 1523 signin::GetSourceForPromoURL(original_continue_url_)); |
| 1528 } | 1524 } |
| 1529 } | 1525 } |
| 1530 } | 1526 } |
| OLD | NEW |