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

Unified Diff: chrome/browser/ui/sync/one_click_signin_helper.cc

Issue 19705013: [password autofill] Remove references to PasswordForm from RenderViewImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 side-by-side diff with in-line comments
Download patch
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 46f030d742203893285be8b68235b8c46838cada..adc3b7ed22b1c568310304e31cfe4c1c9aa9aa06 100644
--- a/chrome/browser/ui/sync/one_click_signin_helper.cc
+++ b/chrome/browser/ui/sync/one_click_signin_helper.cc
@@ -26,6 +26,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"
@@ -54,7 +55,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"
@@ -560,7 +560,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),
@@ -570,6 +571,12 @@ OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents)
untrusted_confirmation_required_(false),
do_not_clear_pending_email_(false),
weak_pointer_factory_(this) {
+ // May be NULL during testing.
+ if (password_manager) {
+ password_manager->AddSubmissionCallback(
+ base::Bind(&OneClickSigninHelper::PasswordSubmitted,
+ weak_pointer_factory_.GetWeakPtr()));
+ }
}
OneClickSigninHelper::~OneClickSigninHelper() {
@@ -585,6 +592,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,
@@ -999,29 +1016,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() {
« 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