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 479b5d8edb4d8b0b07ddefc41cca33df219fc084..1e73fee29dadd00f245faa9fdca2606466adfe8f 100644 |
--- a/chrome/browser/ui/sync/one_click_signin_helper.cc |
+++ b/chrome/browser/ui/sync/one_click_signin_helper.cc |
@@ -25,6 +25,7 @@ |
#include "chrome/browser/chrome_notification_types.h" |
#include "chrome/browser/defaults.h" |
#include "chrome/browser/google/google_util.h" |
+#include "chrome/browser/password_manager/password_manager.h" |
#include "chrome/browser/prefs/scoped_user_pref_update.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/profiles/profile_info_cache.h" |
@@ -53,7 +54,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 +551,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,6 +561,12 @@ OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents) |
untrusted_navigations_since_signin_visit_(0), |
untrusted_confirmation_required_(false), |
do_not_clear_pending_email_(false) { |
+ // May be NULL during testing. |
+ if (password_manager) { |
+ password_manager->AddSubmissionCallback( |
+ base::Bind(&OneClickSigninHelper::PasswordSubmitted, |
+ base::Unretained(this))); |
+ } |
} |
OneClickSigninHelper::~OneClickSigninHelper() { |
@@ -575,6 +582,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, |
@@ -989,29 +1006,13 @@ 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) { |
- // |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. |
- |
+void OneClickSigninHelper::PasswordSubmitted( |
+ const content::PasswordForm& form) { |
// 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() { |