diff options
author | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-09 08:01:53 +0000 |
---|---|---|
committer | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-09 08:01:53 +0000 |
commit | e620d36e8eae66931accf1b41c03fc6fc88ada5f (patch) | |
tree | dd28a682fddf8b99861108a96e26cb8d2b9042bc /components | |
parent | 8f56a083df5cbd49db0302b7b8297f23947d2fd0 (diff) | |
download | chromium_src-e620d36e8eae66931accf1b41c03fc6fc88ada5f.zip chromium_src-e620d36e8eae66931accf1b41c03fc6fc88ada5f.tar.gz chromium_src-e620d36e8eae66931accf1b41c03fc6fc88ada5f.tar.bz2 |
Move PasswordForm from //content to //autofill.
The primary goal of this change is to allow PasswordForm to depend on //
autofill code for password generation. A side benefit is that this change will
allow iOS to cleanly use PasswordForm.
To accommodate the fact that multiple message files need to know about PasswordForm, it is put into a newly-created autofill_param_traits_macros.h rather than autofill_messages.h.
BUG=263121
Review URL: https://chromiumcodereview.appspot.com/23742004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221991 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
19 files changed, 304 insertions, 53 deletions
diff --git a/components/autofill.gypi b/components/autofill.gypi index 92dc4d1..92df65a 100644 --- a/components/autofill.gypi +++ b/components/autofill.gypi @@ -61,6 +61,7 @@ 'autofill/core/common/autofill_messages.h', 'autofill/core/common/autofill_message_generator.cc', 'autofill/core/common/autofill_message_generator.h', + 'autofill/core/common/autofill_param_traits_macros.h', 'autofill/core/common/autofill_pref_names.cc', 'autofill/core/common/autofill_pref_names.h', 'autofill/core/common/autofill_switches.cc', @@ -73,6 +74,8 @@ 'autofill/core/common/form_field_data.h', 'autofill/core/common/form_field_data_predictions.cc', 'autofill/core/common/form_field_data_predictions.h', + 'autofill/core/common/password_form.cc', + 'autofill/core/common/password_form.h', 'autofill/core/common/password_form_fill_data.cc', 'autofill/core/common/password_form_fill_data.h', 'autofill/core/common/password_generation_util.cc', diff --git a/components/autofill/content/renderer/autofill_agent.cc b/components/autofill/content/renderer/autofill_agent.cc index 8f80e4f..15115d1 100644 --- a/components/autofill/content/renderer/autofill_agent.cc +++ b/components/autofill/content/renderer/autofill_agent.cc @@ -20,8 +20,8 @@ #include "components/autofill/core/common/form_data.h" #include "components/autofill/core/common/form_data_predictions.h" #include "components/autofill/core/common/form_field_data.h" +#include "components/autofill/core/common/password_form.h" #include "components/autofill/core/common/web_element_descriptor.h" -#include "content/public/common/password_form.h" #include "content/public/common/ssl_status.h" #include "content/public/common/url_constants.h" #include "content/public/renderer/render_view.h" diff --git a/components/autofill/content/renderer/password_autofill_agent.cc b/components/autofill/content/renderer/password_autofill_agent.cc index bc92faa..d9a12cd 100644 --- a/components/autofill/content/renderer/password_autofill_agent.cc +++ b/components/autofill/content/renderer/password_autofill_agent.cc @@ -13,8 +13,8 @@ #include "components/autofill/content/renderer/password_form_conversion_utils.h" #include "components/autofill/core/common/autofill_messages.h" #include "components/autofill/core/common/form_field_data.h" +#include "components/autofill/core/common/password_form.h" #include "components/autofill/core/common/password_form_fill_data.h" -#include "content/public/common/password_form.h" #include "content/public/renderer/render_view.h" #include "third_party/WebKit/public/platform/WebVector.h" #include "third_party/WebKit/public/web/WebAutofillClient.h" @@ -364,7 +364,7 @@ void PasswordAutofillAgent::SendPasswordForms(WebKit::WebFrame* frame, WebKit::WebVector<WebKit::WebFormElement> forms; frame->document().forms(forms); - std::vector<content::PasswordForm> password_forms; + std::vector<PasswordForm> password_forms; for (size_t i = 0; i < forms.size(); ++i) { const WebKit::WebFormElement& form = forms[i]; @@ -373,7 +373,7 @@ void PasswordAutofillAgent::SendPasswordForms(WebKit::WebFrame* frame, if (only_visible && !IsWebNodeVisible(form)) continue; - scoped_ptr<content::PasswordForm> password_form(CreatePasswordForm(form)); + scoped_ptr<PasswordForm> password_form(CreatePasswordForm(form)); if (password_form.get()) password_forms.push_back(*password_form); } @@ -445,7 +445,7 @@ void PasswordAutofillAgent::WillSendSubmitEvent( void PasswordAutofillAgent::WillSubmitForm(WebKit::WebFrame* frame, const WebKit::WebFormElement& form) { - scoped_ptr<content::PasswordForm> submitted_form = CreatePasswordForm(form); + scoped_ptr<PasswordForm> submitted_form = CreatePasswordForm(form); // If there is a provisionally saved password, copy over the previous // password value so we get the user's typed password, not the value that diff --git a/components/autofill/content/renderer/password_autofill_agent.h b/components/autofill/content/renderer/password_autofill_agent.h index 5c64223..b44ca62 100644 --- a/components/autofill/content/renderer/password_autofill_agent.h +++ b/components/autofill/content/renderer/password_autofill_agent.h @@ -74,7 +74,7 @@ class PasswordAutofillAgent : public content::RenderViewObserver { }; typedef std::map<WebKit::WebElement, PasswordInfo> LoginToPasswordInfoMap; typedef std::map<WebKit::WebFrame*, - linked_ptr<content::PasswordForm> > FrameToPasswordFormMap; + linked_ptr<PasswordForm> > FrameToPasswordFormMap; // RenderViewObserver: virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; diff --git a/components/autofill/content/renderer/password_form_conversion_utils.cc b/components/autofill/content/renderer/password_form_conversion_utils.cc index 72d0709..3066373 100644 --- a/components/autofill/content/renderer/password_form_conversion_utils.cc +++ b/components/autofill/content/renderer/password_form_conversion_utils.cc @@ -4,10 +4,9 @@ #include "components/autofill/content/renderer/password_form_conversion_utils.h" -#include "content/public/common/password_form.h" +#include "components/autofill/core/common/password_form.h" #include "third_party/WebKit/public/web/WebPasswordFormData.h" -using content::PasswordForm; using WebKit::WebFormElement; using WebKit::WebPasswordFormData; diff --git a/components/autofill/content/renderer/password_form_conversion_utils.h b/components/autofill/content/renderer/password_form_conversion_utils.h index 0abaeed..59786ed 100644 --- a/components/autofill/content/renderer/password_form_conversion_utils.h +++ b/components/autofill/content/renderer/password_form_conversion_utils.h @@ -7,21 +7,19 @@ #include "base/memory/scoped_ptr.h" -namespace content { -struct PasswordForm; -} - namespace WebKit { class WebFormElement; } namespace autofill { +struct PasswordForm; + // Create a PasswordForm from DOM form. Webkit doesn't allow storing // custom metadata to DOM nodes, so we have to do this every time an event // happens with a given form and compare against previously Create'd forms // to identify..which sucks. -scoped_ptr<content::PasswordForm> CreatePasswordForm( +scoped_ptr<PasswordForm> CreatePasswordForm( const WebKit::WebFormElement& form); } // namespace autofill diff --git a/components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc b/components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc index 142434a..01b5f55 100644 --- a/components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc +++ b/components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc @@ -5,7 +5,7 @@ #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "components/autofill/content/renderer/password_form_conversion_utils.h" -#include "content/public/common/password_form.h" +#include "components/autofill/core/common/password_form.h" #include "content/public/test/render_view_test.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/public/platform/WebVector.h" @@ -13,7 +13,6 @@ #include "third_party/WebKit/public/web/WebFormElement.h" #include "third_party/WebKit/public/web/WebPasswordFormData.h" -using content::PasswordForm; using WebKit::WebFormElement; using WebKit::WebFrame; using WebKit::WebPasswordFormData; diff --git a/components/autofill/content/renderer/password_generation_manager.cc b/components/autofill/content/renderer/password_generation_manager.cc index 2499c94..1c8c669 100644 --- a/components/autofill/content/renderer/password_generation_manager.cc +++ b/components/autofill/content/renderer/password_generation_manager.cc @@ -9,6 +9,7 @@ #include "components/autofill/content/renderer/password_form_conversion_utils.h" #include "components/autofill/core/common/autofill_messages.h" #include "components/autofill/core/common/form_data.h" +#include "components/autofill/core/common/password_form.h" #include "components/autofill/core/common/password_generation_util.h" #include "content/public/renderer/render_view.h" #include "google_apis/gaia/gaia_urls.h" @@ -72,13 +73,13 @@ bool ContainsURL(const std::vector<GURL>& urls, const GURL& url) { // Returns true if the |form1| is essentially equal to |form2|. bool FormEquals(const autofill::FormData& form1, - const content::PasswordForm& form2) { + const PasswordForm& form2) { // TODO(zysxqn): use more signals than just origin to compare. return form1.origin == form2.origin; } bool ContainsForm(const std::vector<autofill::FormData>& forms, - const content::PasswordForm& form) { + const PasswordForm& form) { for (std::vector<autofill::FormData>::const_iterator it = forms.begin(); it != forms.end(); ++it) { if (FormEquals(*it, form)) @@ -112,7 +113,7 @@ void PasswordGenerationManager::DidFinishDocumentLoad(WebKit::WebFrame* frame) { if (!frame->parent()) { not_blacklisted_password_form_origins_.clear(); account_creation_forms_.clear(); - possible_account_creation_form_.reset(new content::PasswordForm()); + possible_account_creation_form_.reset(new PasswordForm()); passwords_.clear(); } } @@ -134,7 +135,7 @@ void PasswordGenerationManager::DidFinishLoad(WebKit::WebFrame* frame) { // If we can't get a valid PasswordForm, we skip this form because the // the password won't get saved even if we generate it. - scoped_ptr<content::PasswordForm> password_form( + scoped_ptr<PasswordForm> password_form( CreatePasswordForm(forms[i])); if (!password_form.get()) { DVLOG(2) << "Skipping form as it would not be saved"; @@ -180,7 +181,7 @@ void PasswordGenerationManager::openPasswordGenerator( WebKit::WebInputElement& element) { WebKit::WebElement button(element.passwordGeneratorButtonElement()); gfx::Rect rect(button.boundsInViewportSpace()); - scoped_ptr<content::PasswordForm> password_form( + scoped_ptr<PasswordForm> password_form( CreatePasswordForm(element.form())); // We should not have shown the icon we can't create a valid PasswordForm. DCHECK(password_form.get()); @@ -209,8 +210,7 @@ bool PasswordGenerationManager::OnMessageReceived(const IPC::Message& message) { return handled; } -void PasswordGenerationManager::OnFormNotBlacklisted( - const content::PasswordForm& form) { +void PasswordGenerationManager::OnFormNotBlacklisted(const PasswordForm& form) { not_blacklisted_password_form_origins_.push_back(form.origin); MaybeShowIcon(); } diff --git a/components/autofill/content/renderer/password_generation_manager.h b/components/autofill/content/renderer/password_generation_manager.h index a8cbe92..82ce489 100644 --- a/components/autofill/content/renderer/password_generation_manager.h +++ b/components/autofill/content/renderer/password_generation_manager.h @@ -21,14 +21,9 @@ class WebDocument; } namespace autofill { -struct FormData; -} -namespace content { +struct FormData; struct PasswordForm; -} - -namespace autofill { // This class is responsible for controlling communication for password // generation between the browser (which shows the popup and generates @@ -56,7 +51,7 @@ class PasswordGenerationManager : public content::RenderViewObserver, virtual void openPasswordGenerator(WebKit::WebInputElement& element) OVERRIDE; // Message handlers. - void OnFormNotBlacklisted(const content::PasswordForm& form); + void OnFormNotBlacklisted(const PasswordForm& form); void OnPasswordAccepted(const base::string16& password); void OnPasswordGenerationEnabled(bool enabled); void OnAccountCreationFormsDetected( @@ -72,7 +67,7 @@ class PasswordGenerationManager : public content::RenderViewObserver, bool enabled_; // Stores the origin of the account creation form we detected. - scoped_ptr<content::PasswordForm> possible_account_creation_form_; + scoped_ptr<PasswordForm> possible_account_creation_form_; // Stores the origins of the password forms confirmed not to be blacklisted // by the browser. A form can be blacklisted if a user chooses "never save diff --git a/components/autofill/core/DEPS b/components/autofill/core/DEPS index caaebde..d4d63b4 100644 --- a/components/autofill/core/DEPS +++ b/components/autofill/core/DEPS @@ -5,6 +5,5 @@ include_rules = [ # and please do not introduce more #includes of these files. "!content/public/common/common_param_traits.h", "!content/public/common/common_param_traits_macros.h", - "!content/public/common/password_form.h", "!third_party/WebKit/public/web/WebFormElement.h", ] diff --git a/components/autofill/core/browser/autofill_manager_delegate.h b/components/autofill/core/browser/autofill_manager_delegate.h index 275fc91..3260d83 100644 --- a/components/autofill/core/browser/autofill_manager_delegate.h +++ b/components/autofill/core/browser/autofill_manager_delegate.h @@ -12,10 +12,6 @@ #include "base/memory/weak_ptr.h" #include "base/strings/string16.h" -namespace content { -struct PasswordForm; -} - namespace gfx { class Rect; class RectF; @@ -34,6 +30,7 @@ class FormStructure; class PasswordGenerator; class PersonalDataManager; struct FormData; +struct PasswordForm; // A delegate interface that needs to be supplied to AutofillManager // by the embedder. diff --git a/components/autofill/core/common/autofill_message_generator.cc b/components/autofill/core/common/autofill_message_generator.cc index 4898814..d55373b 100644 --- a/components/autofill/core/common/autofill_message_generator.cc +++ b/components/autofill/core/common/autofill_message_generator.cc @@ -17,17 +17,23 @@ // Generate param traits write methods. #include "ipc/param_traits_write_macros.h" namespace IPC { +#undef COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_PARAM_TRAITS_MACROS_H_ #include "components/autofill/core/common/autofill_message_generator.h" +#include "components/autofill/core/common/autofill_param_traits_macros.h" } // namespace IPC // Generate param traits read methods. #include "ipc/param_traits_read_macros.h" namespace IPC { +#undef COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_PARAM_TRAITS_MACROS_H_ #include "components/autofill/core/common/autofill_message_generator.h" +#include "components/autofill/core/common/autofill_param_traits_macros.h" } // namespace IPC // Generate param traits log methods. #include "ipc/param_traits_log_macros.h" namespace IPC { +#undef COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_PARAM_TRAITS_MACROS_H_ #include "components/autofill/core/common/autofill_message_generator.h" +#include "components/autofill/core/common/autofill_param_traits_macros.h" } // namespace IPC diff --git a/components/autofill/core/common/autofill_messages.h b/components/autofill/core/common/autofill_messages.h index 0a25c5e..136329e 100644 --- a/components/autofill/core/common/autofill_messages.h +++ b/components/autofill/core/common/autofill_messages.h @@ -7,16 +7,17 @@ #include <string> #include "base/time/time.h" +#include "components/autofill/core/common/autofill_param_traits_macros.h" #include "components/autofill/core/common/form_data.h" #include "components/autofill/core/common/form_data_predictions.h" #include "components/autofill/core/common/form_field_data.h" #include "components/autofill/core/common/form_field_data_predictions.h" #include "components/autofill/core/common/forms_seen_state.h" +#include "components/autofill/core/common/password_form.h" #include "components/autofill/core/common/password_form_fill_data.h" #include "components/autofill/core/common/web_element_descriptor.h" #include "content/public/common/common_param_traits.h" #include "content/public/common/common_param_traits_macros.h" -#include "content/public/common/password_form.h" #include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_utils.h" #include "third_party/WebKit/public/web/WebFormElement.h" @@ -155,7 +156,7 @@ IPC_MESSAGE_ROUTED1(AutofillMsg_AcceptPasswordAutofillSuggestion, // Tells the renderer that this password form is not blacklisted. A form can // be blacklisted if a user chooses "never save passwords for this site". IPC_MESSAGE_ROUTED1(AutofillMsg_FormNotBlacklisted, - content::PasswordForm /* form checked */) + autofill::PasswordForm /* form checked */) // Sent when requestAutocomplete() finishes (either succesfully or with an // error). If it was a success, the renderer fills the form that requested @@ -188,16 +189,16 @@ IPC_MESSAGE_ROUTED3(AutofillHostMsg_FormsSeen, // Notification that password forms have been seen that are candidates for // filling/submitting by the password manager. IPC_MESSAGE_ROUTED1(AutofillHostMsg_PasswordFormsParsed, - std::vector<content::PasswordForm> /* forms */) + std::vector<autofill::PasswordForm> /* forms */) // Notification that initial layout has occurred and the following password // forms are visible on the page (e.g. not set to display:none.) IPC_MESSAGE_ROUTED1(AutofillHostMsg_PasswordFormsRendered, - std::vector<content::PasswordForm> /* forms */) + std::vector<autofill::PasswordForm> /* forms */) // Notification that this password form was submitted by the user. IPC_MESSAGE_ROUTED1(AutofillHostMsg_PasswordFormSubmitted, - content::PasswordForm /* form */) + autofill::PasswordForm /* form */) // Notification that a form has been submitted. The user hit the button. IPC_MESSAGE_ROUTED2(AutofillHostMsg_FormSubmitted, @@ -253,7 +254,7 @@ IPC_MESSAGE_ROUTED0(AutofillHostMsg_HideAutofillUI) IPC_MESSAGE_ROUTED3(AutofillHostMsg_ShowPasswordGenerationPopup, gfx::Rect /* source location */, int /* max length of the password */, - content::PasswordForm) + autofill::PasswordForm) // Instruct the browser that a password mapping has been found for a field. IPC_MESSAGE_ROUTED2(AutofillHostMsg_AddPasswordFormMapping, diff --git a/components/autofill/core/common/autofill_param_traits_macros.h b/components/autofill/core/common/autofill_param_traits_macros.h new file mode 100644 index 0000000..b0a1ccf --- /dev/null +++ b/components/autofill/core/common/autofill_param_traits_macros.h @@ -0,0 +1,36 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Singly or multiply-included shared traits file depending on circumstances. +// This allows the use of Autofill IPC serialization macros in more than one IPC +// message file. +#ifndef COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_PARAM_TRAITS_MACROS_H_ +#define COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_PARAM_TRAITS_MACROS_H_ + +#include "components/autofill/core/common/password_form.h" +#include "ipc/ipc_message_macros.h" + +IPC_ENUM_TRAITS(autofill::PasswordForm::Type) + +IPC_STRUCT_TRAITS_BEGIN(autofill::PasswordForm) + IPC_STRUCT_TRAITS_MEMBER(signon_realm) + IPC_STRUCT_TRAITS_MEMBER(origin) + IPC_STRUCT_TRAITS_MEMBER(action) + IPC_STRUCT_TRAITS_MEMBER(submit_element) + IPC_STRUCT_TRAITS_MEMBER(username_element) + IPC_STRUCT_TRAITS_MEMBER(username_value) + IPC_STRUCT_TRAITS_MEMBER(other_possible_usernames) + IPC_STRUCT_TRAITS_MEMBER(password_element) + IPC_STRUCT_TRAITS_MEMBER(password_value) + IPC_STRUCT_TRAITS_MEMBER(password_autocomplete_set) + IPC_STRUCT_TRAITS_MEMBER(old_password_element) + IPC_STRUCT_TRAITS_MEMBER(old_password_value) + IPC_STRUCT_TRAITS_MEMBER(ssl_valid) + IPC_STRUCT_TRAITS_MEMBER(preferred) + IPC_STRUCT_TRAITS_MEMBER(blacklisted_by_user) + IPC_STRUCT_TRAITS_MEMBER(type) + IPC_STRUCT_TRAITS_MEMBER(times_used) +IPC_STRUCT_TRAITS_END() + +#endif // COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_PARAM_TRAITS_MACROS_H_ diff --git a/components/autofill/core/common/password_form.cc b/components/autofill/core/common/password_form.cc new file mode 100644 index 0000000..1f9c762 --- /dev/null +++ b/components/autofill/core/common/password_form.cc @@ -0,0 +1,26 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/autofill/core/common/password_form.h" + +namespace autofill { + +PasswordForm::PasswordForm() + : scheme(SCHEME_HTML), + password_autocomplete_set(true), + ssl_valid(false), + preferred(false), + blacklisted_by_user(false), + type(TYPE_MANUAL), + times_used(0) { +} + +PasswordForm::~PasswordForm() { +} + +bool PasswordForm::IsPublicSuffixMatch() const { + return !original_signon_realm.empty(); +} + +} // namespace autofill diff --git a/components/autofill/core/common/password_form.h b/components/autofill/core/common/password_form.h new file mode 100644 index 0000000..9ecb214 --- /dev/null +++ b/components/autofill/core/common/password_form.h @@ -0,0 +1,195 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_AUTOFILL_CORE_COMMON_PASSWORD_FORM_H__ +#define COMPONENTS_AUTOFILL_CORE_COMMON_PASSWORD_FORM_H__ + +#include <map> +#include <string> +#include <vector> + +#include "base/time/time.h" +#include "url/gurl.h" + +namespace autofill { + +// The PasswordForm struct encapsulates information about a login form, +// which can be an HTML form or a dialog with username/password text fields. +// +// The Web Data database stores saved username/passwords and associated form +// metdata using a PasswordForm struct, typically one that was created from +// a parsed HTMLFormElement or LoginDialog, but the saved entries could have +// also been created by imported data from another browser. +// +// The PasswordManager implements a fuzzy-matching algorithm to compare saved +// PasswordForm entries against PasswordForms that were created from a parsed +// HTML or dialog form. As one might expect, the more data contained in one +// of the saved PasswordForms, the better the job the PasswordManager can do +// in matching it against the actual form it was saved on, and autofill +// accurately. But it is not always possible, especially when importing from +// other browsers with different data models, to copy over all the information +// about a particular "saved password entry" to our PasswordForm +// representation. +// +// The field descriptions in the struct specification below are intended to +// describe which fields are not strictly required when adding a saved password +// entry to the database and how they can affect the matching process. + +struct PasswordForm { + // Enum to differentiate between HTML form based authentication, and dialogs + // using basic or digest schemes. Default is SCHEME_HTML. Only PasswordForms + // of the same Scheme will be matched/autofilled against each other. + enum Scheme { + SCHEME_HTML, + SCHEME_BASIC, + SCHEME_DIGEST, + SCHEME_OTHER + } scheme; + + // The "Realm" for the sign-on (scheme, host, port for SCHEME_HTML, and + // contains the HTTP realm for dialog-based forms). + // The signon_realm is effectively the primary key used for retrieving + // data from the database, so it must not be empty. + std::string signon_realm; + + // The original "Realm" for the sign-on (scheme, host, port for SCHEME_HTML, + // and contains the HTTP realm for dialog-based forms). This realm is only set + // when two PasswordForms are matched when trying to find a login/pass pair + // for a site. It is only set to a non-empty value during a match of the + // original stored login/pass and the current observed form if all these + // statements are true: + // 1) The full signon_realm is not the same. + // 2) The registry controlled domain is the same. For example; example.com, + // m.example.com, foo.login.example.com and www.example.com would all resolve + // to example.com since .com is the public suffix. + // 3) The scheme is the same. + // 4) The port is the same. + // For example, if there exists a stored password for http://www.example.com + // (where .com is the public suffix) and the observed form is + // http://m.example.com, |original_signon_realm| must be set to + // http://www.example.com. + std::string original_signon_realm; + + // The URL (minus query parameters) containing the form. This is the primary + // data used by the PasswordManager to decide (in longest matching prefix + // fashion) whether or not a given PasswordForm result from the database is a + // good fit for a particular form on a page, so it must not be empty. + GURL origin; + + // The action target of the form. This is the primary data used by the + // PasswordManager for form autofill; that is, the action of the saved + // credentials must match the action of the form on the page to be autofilled. + // If this is empty / not available, it will result in a "restricted" + // IE-like autofill policy, where we wait for the user to type in his + // username before autofilling the password. In these cases, after successful + // login the action URL will automatically be assigned by the + // PasswordManager. + // + // When parsing an HTML form, this must always be set. + GURL action; + + // The name of the submit button used. Optional; only used in scoring + // of PasswordForm results from the database to make matches as tight as + // possible. + // + // When parsing an HTML form, this must always be set. + string16 submit_element; + + // The name of the username input element. Optional (improves scoring). + // + // When parsing an HTML form, this must always be set. + string16 username_element; + + // The username. Optional. + // + // When parsing an HTML form, this is typically empty unless the site + // has implemented some form of autofill. + string16 username_value; + + // This member is populated in cases where we there are multiple input + // elements that could possibly be the username. Used when our heuristics for + // determining the username are incorrect. Optional. + // + // When parsing an HTML form, this is typically empty. + std::vector<string16> other_possible_usernames; + + // The name of the password input element, Optional (improves scoring). + // + // When parsing an HTML form, this must always be set. + string16 password_element; + + // The password. Required. + // + // When parsing an HTML form, this is typically empty. + string16 password_value; + + // False if autocomplete is set to "off" for the password input element; + // True otherwise. + bool password_autocomplete_set; + + // If the form was a change password form, the name of the + // 'old password' input element. Optional. + string16 old_password_element; + + // The old password. Optional. + string16 old_password_value; + + // Whether or not this login was saved under an HTTPS session with a valid + // SSL cert. We will never match or autofill a PasswordForm where + // ssl_valid == true with a PasswordForm where ssl_valid == false. This means + // passwords saved under HTTPS will never get autofilled onto an HTTP page. + // When importing, this should be set to true if the page URL is HTTPS, thus + // giving it "the benefit of the doubt" that the SSL cert was valid when it + // was saved. Default to false. + bool ssl_valid; + + // True if this PasswordForm represents the last username/password login the + // user selected to log in to the site. If there is only one saved entry for + // the site, this will always be true, but when there are multiple entries + // the PasswordManager ensures that only one of them has a preferred bit set + // to true. Default to false. + // + // When parsing an HTML form, this is not used. + bool preferred; + + // When the login was saved (by chrome). + // + // When parsing an HTML form, this is not used. + base::Time date_created; + + // Tracks if the user opted to never remember passwords for this form. Default + // to false. + // + // When parsing an HTML form, this is not used. + bool blacklisted_by_user; + + // Enum to differentiate between manually filled forms and forms with auto + // generated passwords. + enum Type { + TYPE_MANUAL, + TYPE_GENERATED, + }; + + // The form type. Not used yet. Please see http://crbug.com/152422 + Type type; + + // The number of times that this username/password has been used to + // authenticate the user. + // + // When parsing an HTML form, this is not used. + int times_used; + + // Returns true if this match was found using public suffix matching. + bool IsPublicSuffixMatch() const; + + PasswordForm(); + ~PasswordForm(); +}; + +// Map username to PasswordForm* for convenience. See password_form_manager.h. +typedef std::map<string16, PasswordForm*> PasswordFormMap; + +} // namespace autofill + +#endif // COMPONENTS_AUTOFILL_CORE_COMMON_PASSWORD_FORM_H__ diff --git a/components/autofill/core/common/password_form_fill_data.cc b/components/autofill/core/common/password_form_fill_data.cc index 80b2698..7dbc97d 100644 --- a/components/autofill/core/common/password_form_fill_data.cc +++ b/components/autofill/core/common/password_form_fill_data.cc @@ -30,9 +30,9 @@ PasswordFormFillData::~PasswordFormFillData() { } void InitPasswordFormFillData( - const content::PasswordForm& form_on_page, - const content::PasswordFormMap& matches, - const content::PasswordForm* const preferred_match, + const PasswordForm& form_on_page, + const PasswordFormMap& matches, + const PasswordForm* const preferred_match, bool wait_for_username_before_autofill, bool enable_other_possible_usernames, PasswordFormFillData* result) { @@ -57,7 +57,7 @@ void InitPasswordFormFillData( result->preferred_realm = preferred_match->original_signon_realm; // Copy additional username/value pairs. - content::PasswordFormMap::const_iterator iter; + PasswordFormMap::const_iterator iter; for (iter = matches.begin(); iter != matches.end(); iter++) { if (iter->second != preferred_match) { PasswordAndRealm value; diff --git a/components/autofill/core/common/password_form_fill_data.h b/components/autofill/core/common/password_form_fill_data.h index 9bcd538..14c4759 100644 --- a/components/autofill/core/common/password_form_fill_data.h +++ b/components/autofill/core/common/password_form_fill_data.h @@ -9,7 +9,7 @@ #include "base/memory/scoped_ptr.h" #include "components/autofill/core/common/form_data.h" -#include "content/public/common/password_form.h" +#include "components/autofill/core/common/password_form.h" namespace autofill { @@ -75,9 +75,9 @@ struct PasswordFormFillData { // If |enable_possible_usernames| is true, we will populate possible_usernames // in |result|. void InitPasswordFormFillData( - const content::PasswordForm& form_on_page, - const content::PasswordFormMap& matches, - const content::PasswordForm* const preferred_match, + const PasswordForm& form_on_page, + const PasswordFormMap& matches, + const PasswordForm* const preferred_match, bool wait_for_username_before_autofill, bool enable_other_possible_usernames, PasswordFormFillData* result); diff --git a/components/autofill/core/common/password_form_fill_data_unittest.cc b/components/autofill/core/common/password_form_fill_data_unittest.cc index 1242774..7c30f81 100644 --- a/components/autofill/core/common/password_form_fill_data_unittest.cc +++ b/components/autofill/core/common/password_form_fill_data_unittest.cc @@ -5,13 +5,10 @@ #include "components/autofill/core/common/password_form_fill_data.h" #include "base/strings/utf_string_conversions.h" -#include "content/public/common/password_form.h" +#include "components/autofill/core/common/password_form.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -using content::PasswordForm; -using content::PasswordFormMap; - namespace autofill { // Tests that the when there is a single preferred match, and no extra |