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

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

Powered by Google App Engine
This is Rietveld 408576698