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

Side by Side Diff: chrome/browser/ui/sync/one_click_signin_helper.cc

Issue 12088040: Add a SigninAllowed policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments and rebase to ToT. Created 7 years, 10 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 (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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 return false; 532 return false;
533 533
534 if (web_contents->GetBrowserContext()->IsOffTheRecord()) 534 if (web_contents->GetBrowserContext()->IsOffTheRecord())
535 return false; 535 return false;
536 536
537 Profile* profile = 537 Profile* profile =
538 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 538 Profile::FromBrowserContext(web_contents->GetBrowserContext());
539 if (!profile) 539 if (!profile)
540 return false; 540 return false;
541 541
542 SigninManager* manager =
543 SigninManagerFactory::GetForProfile(profile);
544 if (manager && !manager->IsSigninAllowed())
545 return false;
546
542 if (can_offer_for == CAN_OFFER_FOR_INTERSTITAL_ONLY && 547 if (can_offer_for == CAN_OFFER_FOR_INTERSTITAL_ONLY &&
543 !profile->GetPrefs()->GetBoolean(prefs::kReverseAutologinEnabled)) 548 !profile->GetPrefs()->GetBoolean(prefs::kReverseAutologinEnabled))
544 return false; 549 return false;
545 550
546 if (!SigninManager::AreSigninCookiesAllowed(profile)) 551 if (!SigninManager::AreSigninCookiesAllowed(profile))
547 return false; 552 return false;
548 553
549 if (!email.empty()) { 554 if (!email.empty()) {
550 SigninManager* manager =
551 SigninManagerFactory::GetForProfile(profile);
552 if (!manager) 555 if (!manager)
553 return false; 556 return false;
554 557
555 // If the signin manager already has an authenticated name, then this is a 558 // If the signin manager already has an authenticated name, then this is a
556 // re-auth scenario. Make sure the email just signed in corresponds to the 559 // re-auth scenario. Make sure the email just signed in corresponds to the
557 // the one sign in manager expects. 560 // the one sign in manager expects.
558 std::string current_email = manager->GetAuthenticatedUsername(); 561 std::string current_email = manager->GetAuthenticatedUsername();
559 const bool same_email = gaia::AreEmailsSame(current_email, email); 562 const bool same_email = gaia::AreEmailsSame(current_email, email);
560 if (!current_email.empty() && !same_email) { 563 if (!current_email.empty() && !same_email) {
561 if (error_message) { 564 if (error_message) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 return DONT_OFFER; 653 return DONT_OFFER;
651 654
652 if (!SyncPromoUI::UseWebBasedSigninFlow()) 655 if (!SyncPromoUI::UseWebBasedSigninFlow())
653 return DONT_OFFER; 656 return DONT_OFFER;
654 657
655 // Check for incognito before other parts of the io_data, since those 658 // Check for incognito before other parts of the io_data, since those
656 // members may not be initalized. 659 // members may not be initalized.
657 if (io_data->is_incognito()) 660 if (io_data->is_incognito())
658 return DONT_OFFER; 661 return DONT_OFFER;
659 662
663 if (!SigninManager::IsSigninAllowedOnIOThread(io_data))
664 return DONT_OFFER;
665
660 if (!io_data->reverse_autologin_enabled()->GetValue()) 666 if (!io_data->reverse_autologin_enabled()->GetValue())
661 return DONT_OFFER; 667 return DONT_OFFER;
662 668
663 if (!io_data->google_services_username()->GetValue().empty()) 669 if (!io_data->google_services_username()->GetValue().empty())
664 return DONT_OFFER; 670 return DONT_OFFER;
665 671
666 if (!SigninManager::AreSigninCookiesAllowed(io_data->GetCookieSettings())) 672 if (!SigninManager::AreSigninCookiesAllowed(io_data->GetCookieSettings()))
667 return DONT_OFFER; 673 return DONT_OFFER;
668 674
669 // The checks below depend on chrome already knowing what account the user 675 // The checks below depend on chrome already knowing what account the user
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 } 1200 }
1195 } 1201 }
1196 1202
1197 RedirectToNTP(); 1203 RedirectToNTP();
1198 signin_tracker_.reset(); 1204 signin_tracker_.reset();
1199 } 1205 }
1200 1206
1201 void OneClickSigninHelper::SigninSuccess() { 1207 void OneClickSigninHelper::SigninSuccess() {
1202 signin_tracker_.reset(); 1208 signin_tracker_.reset();
1203 } 1209 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698