| 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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 return false; | 533 return false; |
| 534 | 534 |
| 535 if (web_contents->GetBrowserContext()->IsOffTheRecord()) | 535 if (web_contents->GetBrowserContext()->IsOffTheRecord()) |
| 536 return false; | 536 return false; |
| 537 | 537 |
| 538 Profile* profile = | 538 Profile* profile = |
| 539 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 539 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 540 if (!profile) | 540 if (!profile) |
| 541 return false; | 541 return false; |
| 542 | 542 |
| 543 SigninManager* manager = |
| 544 SigninManagerFactory::GetForProfile(profile); |
| 545 if (manager && !manager->IsSigninAllowed()) |
| 546 return false; |
| 547 |
| 543 if (can_offer_for == CAN_OFFER_FOR_INTERSTITAL_ONLY && | 548 if (can_offer_for == CAN_OFFER_FOR_INTERSTITAL_ONLY && |
| 544 !profile->GetPrefs()->GetBoolean(prefs::kReverseAutologinEnabled)) | 549 !profile->GetPrefs()->GetBoolean(prefs::kReverseAutologinEnabled)) |
| 545 return false; | 550 return false; |
| 546 | 551 |
| 547 if (!SigninManager::AreSigninCookiesAllowed(profile)) | 552 if (!SigninManager::AreSigninCookiesAllowed(profile)) |
| 548 return false; | 553 return false; |
| 549 | 554 |
| 550 if (!email.empty()) { | 555 if (!email.empty()) { |
| 551 SigninManager* manager = | |
| 552 SigninManagerFactory::GetForProfile(profile); | |
| 553 if (!manager) | 556 if (!manager) |
| 554 return false; | 557 return false; |
| 555 | 558 |
| 556 // If the signin manager already has an authenticated name, then this is a | 559 // If the signin manager already has an authenticated name, then this is a |
| 557 // re-auth scenario. Make sure the email just signed in corresponds to the | 560 // re-auth scenario. Make sure the email just signed in corresponds to the |
| 558 // the one sign in manager expects. | 561 // the one sign in manager expects. |
| 559 std::string current_email = manager->GetAuthenticatedUsername(); | 562 std::string current_email = manager->GetAuthenticatedUsername(); |
| 560 const bool same_email = gaia::AreEmailsSame(current_email, email); | 563 const bool same_email = gaia::AreEmailsSame(current_email, email); |
| 561 if (!current_email.empty() && !same_email) { | 564 if (!current_email.empty() && !same_email) { |
| 562 if (error_message) { | 565 if (error_message) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 return DONT_OFFER; | 654 return DONT_OFFER; |
| 652 | 655 |
| 653 if (!SyncPromoUI::UseWebBasedSigninFlow()) | 656 if (!SyncPromoUI::UseWebBasedSigninFlow()) |
| 654 return DONT_OFFER; | 657 return DONT_OFFER; |
| 655 | 658 |
| 656 // Check for incognito before other parts of the io_data, since those | 659 // Check for incognito before other parts of the io_data, since those |
| 657 // members may not be initalized. | 660 // members may not be initalized. |
| 658 if (io_data->is_incognito()) | 661 if (io_data->is_incognito()) |
| 659 return DONT_OFFER; | 662 return DONT_OFFER; |
| 660 | 663 |
| 664 if (!SigninManager::IsSigninAllowedOnIOThread(io_data)) |
| 665 return DONT_OFFER; |
| 666 |
| 661 if (!io_data->reverse_autologin_enabled()->GetValue()) | 667 if (!io_data->reverse_autologin_enabled()->GetValue()) |
| 662 return DONT_OFFER; | 668 return DONT_OFFER; |
| 663 | 669 |
| 664 if (!io_data->google_services_username()->GetValue().empty()) | 670 if (!io_data->google_services_username()->GetValue().empty()) |
| 665 return DONT_OFFER; | 671 return DONT_OFFER; |
| 666 | 672 |
| 667 if (!SigninManager::AreSigninCookiesAllowed(io_data->GetCookieSettings())) | 673 if (!SigninManager::AreSigninCookiesAllowed(io_data->GetCookieSettings())) |
| 668 return DONT_OFFER; | 674 return DONT_OFFER; |
| 669 | 675 |
| 670 // The checks below depend on chrome already knowing what account the user | 676 // The checks below depend on chrome already knowing what account the user |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 break; | 1171 break; |
| 1166 } | 1172 } |
| 1167 } | 1173 } |
| 1168 | 1174 |
| 1169 RedirectToNTP(); | 1175 RedirectToNTP(); |
| 1170 } | 1176 } |
| 1171 | 1177 |
| 1172 void OneClickSigninHelper::SigninSuccess() { | 1178 void OneClickSigninHelper::SigninSuccess() { |
| 1173 RedirectToNTP(); | 1179 RedirectToNTP(); |
| 1174 } | 1180 } |
| OLD | NEW |