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

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

Issue 22253010: Fix unwanted sign in to Chrome when the user signs in to another service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Back to patch 7 + style fix Created 7 years, 4 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
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 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 url.ReplaceComponents(replacements) != 1043 url.ReplaceComponents(replacements) !=
1044 continue_url_.ReplaceComponents(replacements)) { 1044 continue_url_.ReplaceComponents(replacements)) {
1045 if (++untrusted_navigations_since_signin_visit_ > kMaxNavigationsSince) 1045 if (++untrusted_navigations_since_signin_visit_ > kMaxNavigationsSince)
1046 CleanTransientState(); 1046 CleanTransientState();
1047 } 1047 }
1048 } 1048 }
1049 1049
1050 void OneClickSigninHelper::DidNavigateMainFrame( 1050 void OneClickSigninHelper::DidNavigateMainFrame(
1051 const content::LoadCommittedDetails& details, 1051 const content::LoadCommittedDetails& details,
1052 const content::FrameNavigateParams& params) { 1052 const content::FrameNavigateParams& params) {
1053 // If we navigate to a non-sign-in URL, make sure that the renderer process
1054 // is no longer considered the trusted sign-in process.
1055 if (!SigninManager::IsWebBasedSigninFlowURL(params.url)) { 1053 if (!SigninManager::IsWebBasedSigninFlowURL(params.url)) {
1054 // Make sure the renderer process is no longer considered the trusted
1055 // sign-in process when a navigation to a non-sign-in URL occurs.
1056 Profile* profile = 1056 Profile* profile =
1057 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 1057 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
1058 SigninManager* manager = profile ? 1058 SigninManager* manager = profile ?
1059 SigninManagerFactory::GetForProfile(profile) : NULL; 1059 SigninManagerFactory::GetForProfile(profile) : NULL;
1060 int process_id = web_contents()->GetRenderProcessHost()->GetID(); 1060 int process_id = web_contents()->GetRenderProcessHost()->GetID();
1061 if (manager && manager->IsSigninProcess(process_id)) 1061 if (manager && manager->IsSigninProcess(process_id))
1062 manager->ClearSigninProcess(); 1062 manager->ClearSigninProcess();
1063
1064 // If the navigation to a non-sign-in URL hasn't been triggered by the web
1065 // contents, the sign in flow has been aborted and the state must be
1066 // cleaned (crbug.com/269421).
1067 if (!content::PageTransitionIsWebTriggerable(params.transition) &&
1068 auto_accept_ != AUTO_ACCEPT_NONE) {
1069 CleanTransientState();
1070 }
1063 } 1071 }
1064 } 1072 }
1065 1073
1066 void OneClickSigninHelper::DidStopLoading( 1074 void OneClickSigninHelper::DidStopLoading(
1067 content::RenderViewHost* render_view_host) { 1075 content::RenderViewHost* render_view_host) {
1068 // If the user left the sign in process, clear all members. 1076 // If the user left the sign in process, clear all members.
1069 // TODO(rogerta): might need to allow some youtube URLs. 1077 // TODO(rogerta): might need to allow some youtube URLs.
1070 content::WebContents* contents = web_contents(); 1078 content::WebContents* contents = web_contents();
1071 const GURL url = contents->GetLastCommittedURL(); 1079 const GURL url = contents->GetLastCommittedURL();
1072 Profile* profile = 1080 Profile* profile =
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 } 1194 }
1187 1195
1188 Browser* browser = chrome::FindBrowserWithWebContents(contents); 1196 Browser* browser = chrome::FindBrowserWithWebContents(contents);
1189 1197
1190 VLOG(1) << "OneClickSigninHelper::DidStopLoading: signin is go." 1198 VLOG(1) << "OneClickSigninHelper::DidStopLoading: signin is go."
1191 << " auto_accept=" << auto_accept_ 1199 << " auto_accept=" << auto_accept_
1192 << " source=" << source_; 1200 << " source=" << source_;
1193 1201
1194 switch (auto_accept_) { 1202 switch (auto_accept_) {
1195 case AUTO_ACCEPT_NONE: 1203 case AUTO_ACCEPT_NONE:
1196 if (showing_signin_) 1204 if (showing_signin_)
fdoray 2013/08/09 17:42:14 Is it possible to reach this line? |email_| would
1197 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_DISMISSED); 1205 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_DISMISSED);
1198 break; 1206 break;
1199 case AUTO_ACCEPT_ACCEPTED: 1207 case AUTO_ACCEPT_ACCEPTED:
1200 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); 1208 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED);
1201 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_DEFAULTS); 1209 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_DEFAULTS);
1202 SigninManager::DisableOneClickSignIn(profile); 1210 SigninManager::DisableOneClickSignIn(profile);
1203 // Start syncing with the default settings - prompt the user to sign in 1211 // Start syncing with the default settings - prompt the user to sign in
1204 // first. 1212 // first.
1205 StartSync(StartSyncArgs(profile, browser, auto_accept_, 1213 StartSync(StartSyncArgs(profile, browser, auto_accept_,
1206 session_index_, email_, password_, 1214 session_index_, email_, password_,
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 // If the web contents is showing a blank page and not about to be closed, 1378 // If the web contents is showing a blank page and not about to be closed,
1371 // redirect to the NTP or apps page. 1379 // redirect to the NTP or apps page.
1372 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) && 1380 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) &&
1373 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) { 1381 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) {
1374 RedirectToNtpOrAppsPage( 1382 RedirectToNtpOrAppsPage(
1375 web_contents(), 1383 web_contents(),
1376 signin::GetSourceForPromoURL(original_continue_url_)); 1384 signin::GetSourceForPromoURL(original_continue_url_));
1377 } 1385 }
1378 } 1386 }
1379 } 1387 }
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