Chromium Code Reviews| Index: chrome/browser/ui/sync/one_click_signin_helper.cc |
| diff --git a/chrome/browser/ui/sync/one_click_signin_helper.cc b/chrome/browser/ui/sync/one_click_signin_helper.cc |
| index 4c001eedb943e4842acd6c687fdbabe67cf66d3f..7801b00f05717eafb2942b8f563f5d6661546252 100644 |
| --- a/chrome/browser/ui/sync/one_click_signin_helper.cc |
| +++ b/chrome/browser/ui/sync/one_click_signin_helper.cc |
| @@ -53,7 +53,6 @@ |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/common/chrome_version_info.h" |
| #include "chrome/common/net/url_util.h" |
| -#include "chrome/common/one_click_signin_messages.h" |
| #include "chrome/common/pref_names.h" |
| #include "chrome/common/url_constants.h" |
| #include "content/public/browser/browser_thread.h" |
| @@ -551,7 +550,8 @@ DEFINE_WEB_CONTENTS_USER_DATA_KEY(OneClickSigninHelper); |
| // static |
| const int OneClickSigninHelper::kMaxNavigationsSince = 10; |
| -OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents) |
| +OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents, |
| + PasswordManager* password_manager) |
| : content::WebContentsObserver(web_contents), |
| showing_signin_(false), |
| auto_accept_(AUTO_ACCEPT_NONE), |
| @@ -560,7 +560,11 @@ OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents) |
| original_source_(SyncPromoUI::SOURCE_UNKNOWN), |
| untrusted_navigations_since_signin_visit_(0), |
| untrusted_confirmation_required_(false), |
| - do_not_clear_pending_email_(false) { |
| + do_not_clear_pending_email_(false), |
| + password_callback_(base::Bind(&OneClickSigninHelper::PasswordSubmitted, |
| + base::Unretained(this))) { |
|
Ilya Sherman
2013/07/27 01:09:48
Why is base::Unretained() safe here?
Garrett Casto
2013/08/03 00:38:42
Yes, for the same reason as the PrerenderTabHelper
|
| + if (password_manager) |
| + password_manager->AddSubmissionCallback(password_callback_); |
| } |
| OneClickSigninHelper::~OneClickSigninHelper() { |
| @@ -576,6 +580,16 @@ OneClickSigninHelper::~OneClickSigninHelper() { |
| } |
| // static |
| +void OneClickSigninHelper::CreateForWebContentsWithPasswordManager( |
| + content::WebContents* contents, |
| + PasswordManager* password_manager) { |
| + if (!FromWebContents(contents)) { |
| + contents->SetUserData(UserDataKey(), |
| + new OneClickSigninHelper(contents, password_manager)); |
| + } |
| +} |
| + |
| +// static |
| bool OneClickSigninHelper::CanOffer(content::WebContents* web_contents, |
| CanOfferFor can_offer_for, |
| const std::string& email, |
| @@ -985,29 +999,17 @@ void OneClickSigninHelper::CleanTransientState() { |
| } |
| } |
| -bool OneClickSigninHelper::OnMessageReceived(const IPC::Message& message) { |
| - bool handled = true; |
| - IPC_BEGIN_MESSAGE_MAP(OneClickSigninHelper, message) |
| - IPC_MESSAGE_HANDLER(OneClickSigninHostMsg_FormSubmitted, OnFormSubmitted) |
| - IPC_MESSAGE_UNHANDLED(handled = false) |
| - IPC_END_MESSAGE_MAP() |
| - |
| - return handled; |
| -} |
| - |
| -bool OneClickSigninHelper::OnFormSubmitted(const content::PasswordForm& form) { |
| +void OneClickSigninHelper::PasswordSubmitted( |
| + const content::PasswordForm& form) { |
| // |password_| used to be set in DidNavigateAnyFrame, this is too late because |
| // it is not executed until the end of redirect chains and password may |
| // get lost if one of the redirects requires context swap. |
|
Ilya Sherman
2013/07/27 01:09:48
nit: Is this comment still relevant? If so, shoul
Garrett Casto
2013/08/03 00:38:42
I kept the gist of this in password manager code.
|
| // We only need to scrape the password for Gaia logins. |
| - if (form.origin.is_valid() && |
| - gaia::IsGaiaSignonRealm(GURL(form.signon_realm))) { |
| + if (gaia::IsGaiaSignonRealm(GURL(form.signon_realm))) { |
| VLOG(1) << "OneClickSigninHelper::DidNavigateAnyFrame: got password"; |
| password_ = UTF16ToUTF8(form.password_value); |
| } |
| - |
| - return true; |
| } |
| void OneClickSigninHelper::SetDoNotClearPendingEmailForTesting() { |