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

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 nits and rebase to ToT. Created 7 years, 9 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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 UMA_HISTOGRAM_ENUMERATION("Signin.Reauth", 565 UMA_HISTOGRAM_ENUMERATION("Signin.Reauth",
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 return DONT_OFFER; 657 return DONT_OFFER;
655 658
656 if (!SyncPromoUI::UseWebBasedSigninFlow()) 659 if (!SyncPromoUI::UseWebBasedSigninFlow())
657 return DONT_OFFER; 660 return DONT_OFFER;
658 661
659 // Check for incognito before other parts of the io_data, since those 662 // Check for incognito before other parts of the io_data, since those
660 // members may not be initalized. 663 // members may not be initalized.
661 if (io_data->is_incognito()) 664 if (io_data->is_incognito())
662 return DONT_OFFER; 665 return DONT_OFFER;
663 666
667 if (!SigninManager::IsSigninAllowedOnIOThread(io_data))
668 return DONT_OFFER;
669
664 if (!io_data->reverse_autologin_enabled()->GetValue()) 670 if (!io_data->reverse_autologin_enabled()->GetValue())
665 return DONT_OFFER; 671 return DONT_OFFER;
666 672
667 if (!io_data->google_services_username()->GetValue().empty()) 673 if (!io_data->google_services_username()->GetValue().empty())
668 return DONT_OFFER; 674 return DONT_OFFER;
669 675
670 if (!SigninManager::AreSigninCookiesAllowed(io_data->GetCookieSettings())) 676 if (!SigninManager::AreSigninCookiesAllowed(io_data->GetCookieSettings()))
671 return DONT_OFFER; 677 return DONT_OFFER;
672 678
673 // The checks below depend on chrome already knowing what account the user 679 // The checks below depend on chrome already knowing what account the user
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 } 1209 }
1204 } 1210 }
1205 1211
1206 RedirectToNTP(true); 1212 RedirectToNTP(true);
1207 signin_tracker_.reset(); 1213 signin_tracker_.reset();
1208 } 1214 }
1209 1215
1210 void OneClickSigninHelper::SigninSuccess() { 1216 void OneClickSigninHelper::SigninSuccess() {
1211 signin_tracker_.reset(); 1217 signin_tracker_.reset();
1212 } 1218 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/chrome_pages.cc ('k') | chrome/browser/ui/sync/one_click_signin_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698