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

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

Issue 14197014: Add TestBrowserThreadBundle into RenderViewHostTestHarness. Kill some unnecessary real threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged ToT Created 7 years, 6 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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 DEFINE_WEB_CONTENTS_USER_DATA_KEY(OneClickSigninHelper); 489 DEFINE_WEB_CONTENTS_USER_DATA_KEY(OneClickSigninHelper);
490 490
491 OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents) 491 OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents)
492 : content::WebContentsObserver(web_contents), 492 : content::WebContentsObserver(web_contents),
493 showing_signin_(false), 493 showing_signin_(false),
494 auto_accept_(AUTO_ACCEPT_NONE), 494 auto_accept_(AUTO_ACCEPT_NONE),
495 source_(SyncPromoUI::SOURCE_UNKNOWN), 495 source_(SyncPromoUI::SOURCE_UNKNOWN),
496 switched_to_advanced_(false), 496 switched_to_advanced_(false),
497 original_source_(SyncPromoUI::SOURCE_UNKNOWN), 497 original_source_(SyncPromoUI::SOURCE_UNKNOWN),
498 untrusted_navigations_since_signin_visit_(0), 498 untrusted_navigations_since_signin_visit_(0),
499 untrusted_confirmation_required_(false) { 499 untrusted_confirmation_required_(false),
500 do_not_clear_pending_email_(false) {
500 } 501 }
501 502
502 OneClickSigninHelper::~OneClickSigninHelper() { 503 OneClickSigninHelper::~OneClickSigninHelper() {
503 content::WebContents* contents = web_contents(); 504 content::WebContents* contents = web_contents();
504 if (contents) { 505 if (contents) {
505 Profile* profile = 506 Profile* profile =
506 Profile::FromBrowserContext(contents->GetBrowserContext()); 507 Profile::FromBrowserContext(contents->GetBrowserContext());
507 ProfileSyncService* sync_service = 508 ProfileSyncService* sync_service =
508 ProfileSyncServiceFactory::GetForProfile(profile); 509 ProfileSyncServiceFactory::GetForProfile(profile);
509 if (sync_service && sync_service->HasObserver(this)) 510 if (sync_service && sync_service->HasObserver(this))
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 auto_accept_ = AUTO_ACCEPT_NONE; 942 auto_accept_ = AUTO_ACCEPT_NONE;
942 source_ = SyncPromoUI::SOURCE_UNKNOWN; 943 source_ = SyncPromoUI::SOURCE_UNKNOWN;
943 switched_to_advanced_ = false; 944 switched_to_advanced_ = false;
944 original_source_ = SyncPromoUI::SOURCE_UNKNOWN; 945 original_source_ = SyncPromoUI::SOURCE_UNKNOWN;
945 continue_url_ = GURL(); 946 continue_url_ = GURL();
946 untrusted_navigations_since_signin_visit_ = 0; 947 untrusted_navigations_since_signin_visit_ = 0;
947 untrusted_confirmation_required_ = false; 948 untrusted_confirmation_required_ = false;
948 error_message_.clear(); 949 error_message_.clear();
949 950
950 // Post to IO thread to clear pending email. 951 // Post to IO thread to clear pending email.
951 Profile* profile = 952 if (!do_not_clear_pending_email_) {
952 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 953 Profile* profile =
953 content::BrowserThread::PostTask( 954 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
954 content::BrowserThread::IO, FROM_HERE, 955 content::BrowserThread::PostTask(
955 base::Bind(&ClearPendingEmailOnIOThread, 956 content::BrowserThread::IO, FROM_HERE,
956 base::Unretained(profile->GetResourceContext()))); 957 base::Bind(&ClearPendingEmailOnIOThread,
958 base::Unretained(profile->GetResourceContext())));
959 }
957 } 960 }
958 961
959 bool OneClickSigninHelper::OnMessageReceived(const IPC::Message& message) { 962 bool OneClickSigninHelper::OnMessageReceived(const IPC::Message& message) {
960 bool handled = true; 963 bool handled = true;
961 IPC_BEGIN_MESSAGE_MAP(OneClickSigninHelper, message) 964 IPC_BEGIN_MESSAGE_MAP(OneClickSigninHelper, message)
962 IPC_MESSAGE_HANDLER(OneClickSigninHostMsg_FormSubmitted, OnFormSubmitted) 965 IPC_MESSAGE_HANDLER(OneClickSigninHostMsg_FormSubmitted, OnFormSubmitted)
963 IPC_MESSAGE_UNHANDLED(handled = false) 966 IPC_MESSAGE_UNHANDLED(handled = false)
964 IPC_END_MESSAGE_MAP() 967 IPC_END_MESSAGE_MAP()
965 968
966 return handled; 969 return handled;
967 } 970 }
968 971
969 bool OneClickSigninHelper::OnFormSubmitted(const content::PasswordForm& form) { 972 bool OneClickSigninHelper::OnFormSubmitted(const content::PasswordForm& form) {
970 // |password_| used to be set in DidNavigateAnyFrame, this is too late because 973 // |password_| used to be set in DidNavigateAnyFrame, this is too late because
971 // it is not executed until the end of redirect chains and password may 974 // it is not executed until the end of redirect chains and password may
972 // get lost if one of the redirects requires context swap. 975 // get lost if one of the redirects requires context swap.
973 976
974 // We only need to scrape the password for Gaia logins. 977 // We only need to scrape the password for Gaia logins.
975 if (form.origin.is_valid() && 978 if (form.origin.is_valid() &&
976 gaia::IsGaiaSignonRealm(GURL(form.signon_realm))) { 979 gaia::IsGaiaSignonRealm(GURL(form.signon_realm))) {
977 VLOG(1) << "OneClickSigninHelper::DidNavigateAnyFrame: got password"; 980 VLOG(1) << "OneClickSigninHelper::DidNavigateAnyFrame: got password";
978 password_ = UTF16ToUTF8(form.password_value); 981 password_ = UTF16ToUTF8(form.password_value);
979 } 982 }
980 983
981 return true; 984 return true;
982 } 985 }
983 986
987 void OneClickSigninHelper::SetDoNotClearPendingEmailForTesting() {
988 do_not_clear_pending_email_ = true;
989 }
990
984 void OneClickSigninHelper::NavigateToPendingEntry( 991 void OneClickSigninHelper::NavigateToPendingEntry(
985 const GURL& url, 992 const GURL& url,
986 content::NavigationController::ReloadType reload_type) { 993 content::NavigationController::ReloadType reload_type) {
987 VLOG(1) << "OneClickSigninHelper::NavigateToPendingEntry: url=" << url.spec(); 994 VLOG(1) << "OneClickSigninHelper::NavigateToPendingEntry: url=" << url.spec();
988 // If the tab navigates to a new page, and this page is not a valid Gaia 995 // If the tab navigates to a new page, and this page is not a valid Gaia
989 // sign in redirect or reponse, or the expected continue URL, make sure to 996 // sign in redirect or reponse, or the expected continue URL, make sure to
990 // clear the internal state. This is needed to detect navigations in the 997 // clear the internal state. This is needed to detect navigations in the
991 // middle of the sign in process that may redirect back to the sign in 998 // middle of the sign in process that may redirect back to the sign in
992 // process (see crbug.com/181163 for details). 999 // process (see crbug.com/181163 for details).
993 const GURL continue_url = 1000 const GURL continue_url =
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 contents->GetController().LoadURL(redirect_url_, 1271 contents->GetController().LoadURL(redirect_url_,
1265 content::Referrer(), 1272 content::Referrer(),
1266 content::PAGE_TRANSITION_AUTO_TOPLEVEL, 1273 content::PAGE_TRANSITION_AUTO_TOPLEVEL,
1267 std::string()); 1274 std::string());
1268 } 1275 }
1269 1276
1270 // Clear the redirect URL. 1277 // Clear the redirect URL.
1271 redirect_url_ = GURL(); 1278 redirect_url_ = GURL();
1272 sync_service->RemoveObserver(this); 1279 sync_service->RemoveObserver(this);
1273 } 1280 }
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