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

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

Issue 11437014: Fix crash when signing in to gaia from an incognito tab (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix typo in comments Created 8 years 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 int route_id) { 674 int route_id) {
675 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 675 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
676 676
677 content::WebContents* web_contents = tab_util::GetWebContentsByID(child_id, 677 content::WebContents* web_contents = tab_util::GetWebContentsByID(child_id,
678 route_id); 678 route_id);
679 679
680 // TODO(mathp): The appearance of this infobar should be tested using a 680 // TODO(mathp): The appearance of this infobar should be tested using a
681 // browser_test. 681 // browser_test.
682 OneClickSigninHelper* helper = 682 OneClickSigninHelper* helper =
683 OneClickSigninHelper::FromWebContents(web_contents); 683 OneClickSigninHelper::FromWebContents(web_contents);
684 if (!helper)
685 return;
686
684 int error_message_id = 0; 687 int error_message_id = 0;
685 688
686 CanOfferFor can_offer_for = 689 CanOfferFor can_offer_for =
687 (auto_accept != AUTO_ACCEPT_EXPLICIT && 690 (auto_accept != AUTO_ACCEPT_EXPLICIT &&
688 helper->auto_accept_ != AUTO_ACCEPT_EXPLICIT) ? 691 helper->auto_accept_ != AUTO_ACCEPT_EXPLICIT) ?
689 CAN_OFFER_FOR_INTERSTITAL_ONLY : CAN_OFFER_FOR_ALL; 692 CAN_OFFER_FOR_INTERSTITAL_ONLY : CAN_OFFER_FOR_ALL;
690 693
691 if (!web_contents || !CanOffer(web_contents, can_offer_for, email, 694 if (!web_contents || !CanOffer(web_contents, can_offer_for, email,
692 &error_message_id)) { 695 &error_message_id)) {
693 VLOG(1) << "OneClickSigninHelper::ShowInfoBarUIThread: not offering"; 696 VLOG(1) << "OneClickSigninHelper::ShowInfoBarUIThread: not offering";
694 if (helper && helper->error_message_.empty() && error_message_id != 0) 697 if (helper && helper->error_message_.empty() && error_message_id != 0)
695 helper->error_message_ = l10n_util::GetStringUTF8(error_message_id); 698 helper->error_message_ = l10n_util::GetStringUTF8(error_message_id);
696 699
697 return; 700 return;
698 } 701 }
699 702
700 // Save the email in the one-click signin manager. The manager may 703 // Save the email in the one-click signin manager. The manager may
701 // not exist if the contents is incognito or if the profile is already 704 // not exist if the contents is incognito or if the profile is already
702 // connected to a Google account. 705 // connected to a Google account.
703 if (helper) { 706 if (!session_index.empty())
704 if (!session_index.empty()) 707 helper->session_index_ = session_index;
705 helper->session_index_ = session_index;
706 708
707 if (!email.empty()) 709 if (!email.empty())
708 helper->email_ = email; 710 helper->email_ = email;
709 711
710 if (auto_accept != NO_AUTO_ACCEPT) { 712 if (auto_accept != NO_AUTO_ACCEPT) {
711 helper->auto_accept_ = auto_accept; 713 helper->auto_accept_ = auto_accept;
712 helper->source_ = source; 714 helper->source_ = source;
713 }
714 } 715 }
715 } 716 }
716 717
717 void OneClickSigninHelper::RedirectToNTP() { 718 void OneClickSigninHelper::RedirectToNTP() {
718 // Redirect to NTP with sign in bubble visible. 719 // Redirect to NTP with sign in bubble visible.
719 content::WebContents* contents = web_contents(); 720 content::WebContents* contents = web_contents();
720 Profile* profile = 721 Profile* profile =
721 Profile::FromBrowserContext(contents->GetBrowserContext()); 722 Profile::FromBrowserContext(contents->GetBrowserContext());
722 PrefService* pref_service = profile->GetPrefs(); 723 PrefService* pref_service = profile->GetPrefs();
723 pref_service->SetBoolean(prefs::kSyncPromoShowNTPBubble, true); 724 pref_service->SetBoolean(prefs::kSyncPromoShowNTPBubble, true);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 break; 838 break;
838 } 839 }
839 } 840 }
840 841
841 RedirectToNTP(); 842 RedirectToNTP();
842 } 843 }
843 844
844 void OneClickSigninHelper::SigninSuccess() { 845 void OneClickSigninHelper::SigninSuccess() {
845 RedirectToNTP(); 846 RedirectToNTP();
846 } 847 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.h ('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