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

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: Fix tests 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 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 url.ReplaceComponents(replacements) != 1045 url.ReplaceComponents(replacements) !=
1046 continue_url_.ReplaceComponents(replacements)) { 1046 continue_url_.ReplaceComponents(replacements)) {
1047 if (++untrusted_navigations_since_signin_visit_ > kMaxNavigationsSince) 1047 if (++untrusted_navigations_since_signin_visit_ > kMaxNavigationsSince)
1048 CleanTransientState(); 1048 CleanTransientState();
1049 } 1049 }
1050 } 1050 }
1051 1051
1052 void OneClickSigninHelper::DidNavigateMainFrame( 1052 void OneClickSigninHelper::DidNavigateMainFrame(
1053 const content::LoadCommittedDetails& details, 1053 const content::LoadCommittedDetails& details,
1054 const content::FrameNavigateParams& params) { 1054 const content::FrameNavigateParams& params) {
1055 // If we navigate to a non-sign-in URL, make sure that the renderer process
1056 // is no longer considered the trusted sign-in process.
1057 if (!SigninManager::IsWebBasedSigninFlowURL(params.url)) { 1055 if (!SigninManager::IsWebBasedSigninFlowURL(params.url)) {
1056 // Make sure the renderer process is no longer considered the trusted
1057 // sign-in process when a navigation to a non-sign-in URL occurs.
1058 Profile* profile = 1058 Profile* profile =
1059 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 1059 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
1060 SigninManager* manager = profile ? 1060 SigninManager* manager = profile ?
1061 SigninManagerFactory::GetForProfile(profile) : NULL; 1061 SigninManagerFactory::GetForProfile(profile) : NULL;
1062 int process_id = web_contents()->GetRenderProcessHost()->GetID(); 1062 int process_id = web_contents()->GetRenderProcessHost()->GetID();
1063 if (manager && manager->IsSigninProcess(process_id)) 1063 if (manager && manager->IsSigninProcess(process_id))
1064 manager->ClearSigninProcess(); 1064 manager->ClearSigninProcess();
1065
1066 // If the navigation to a non-sign-in URL hasn't been triggered by the web
1067 // contents, the sign in flow has been aborted and the state must be
1068 // cleaned (crbug.com/269421).
1069 if (!content::PageTransitionIsWebTriggerable(params.transition) &&
1070 auto_accept_ != AUTO_ACCEPT_NONE)
fdoray 2013/08/09 14:32:25 CleanTransientState() cannot be executed in a unit
(NOT FOR CODE REVIEWS) 2013/08/09 14:43:04 Is it only for tests? Can you set do_not_clear_pe
fdoray 2013/08/09 17:42:14 It's for tests, but it also avoids unnecessary cal
1071 CleanTransientState();
(NOT FOR CODE REVIEWS) 2013/08/09 14:43:04 Should add { and } to this if statement since cond
fdoray 2013/08/09 17:42:14 Done.
1065 } 1072 }
1066 } 1073 }
1067 1074
1068 void OneClickSigninHelper::DidStopLoading( 1075 void OneClickSigninHelper::DidStopLoading(
1069 content::RenderViewHost* render_view_host) { 1076 content::RenderViewHost* render_view_host) {
1070 // If the user left the sign in process, clear all members. 1077 // If the user left the sign in process, clear all members.
1071 // TODO(rogerta): might need to allow some youtube URLs. 1078 // TODO(rogerta): might need to allow some youtube URLs.
1072 content::WebContents* contents = web_contents(); 1079 content::WebContents* contents = web_contents();
1073 const GURL url = contents->GetLastCommittedURL(); 1080 const GURL url = contents->GetLastCommittedURL();
1074 Profile* profile = 1081 Profile* profile =
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 // If the web contents is showing a blank page and not about to be closed, 1379 // If the web contents is showing a blank page and not about to be closed,
1373 // redirect to the NTP or apps page. 1380 // redirect to the NTP or apps page.
1374 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) && 1381 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) &&
1375 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) { 1382 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) {
1376 RedirectToNtpOrAppsPage( 1383 RedirectToNtpOrAppsPage(
1377 web_contents(), 1384 web_contents(),
1378 signin::GetSourceForPromoURL(original_continue_url_)); 1385 signin::GetSourceForPromoURL(original_continue_url_));
1379 } 1386 }
1380 } 1387 }
1381 } 1388 }
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