| Index: components/autofill/content/renderer/password_autofill_agent.h
|
| diff --git a/components/autofill/content/renderer/password_autofill_agent.h b/components/autofill/content/renderer/password_autofill_agent.h
|
| index 99f2a94567338cd656bc1e13727d9af50ae56f3a..d03808f642d9fc78f9ff3248522f68211c60a14a 100644
|
| --- a/components/autofill/content/renderer/password_autofill_agent.h
|
| +++ b/components/autofill/content/renderer/password_autofill_agent.h
|
| @@ -8,9 +8,11 @@
|
| #include <map>
|
| #include <vector>
|
|
|
| -#include "base/memory/linked_ptr.h"
|
| +#include "base/gtest_prod_util.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| #include "base/memory/weak_ptr.h"
|
| #include "components/autofill/core/common/password_form_fill_data.h"
|
| +#include "content/public/renderer/render_frame_observer.h"
|
| #include "content/public/renderer/render_view_observer.h"
|
| #include "third_party/WebKit/public/web/WebInputElement.h"
|
|
|
| @@ -24,13 +26,12 @@ class WebView;
|
| namespace autofill {
|
|
|
| // This class is responsible for filling password forms.
|
| -// There is one PasswordAutofillAgent per RenderView.
|
| -class PasswordAutofillAgent : public content::RenderViewObserver {
|
| +class PasswordAutofillAgent : public content::RenderFrameObserver {
|
| public:
|
| - explicit PasswordAutofillAgent(content::RenderView* render_view);
|
| + explicit PasswordAutofillAgent(content::RenderFrame* render_frame);
|
| ~PasswordAutofillAgent() override;
|
|
|
| - // WebViewClient editor related calls forwarded by the RenderView.
|
| + // WebFrameClient editor related calls forwarded by AutofillAgent.
|
| // If they return true, it indicates the event was consumed and should not
|
| // be used for any other autofill activity.
|
| bool TextFieldDidEndEditing(const blink::WebInputElement& element);
|
| @@ -54,6 +55,7 @@ class PasswordAutofillAgent : public content::RenderViewObserver {
|
| // their previous filled state. Return false if no login information was
|
| // found for the form.
|
| bool DidClearAutofillSelection(const blink::WebNode& node);
|
| +
|
| // Shows an Autofill popup with username suggestions for |element|. If
|
| // |show_all| is |true|, will show all possible suggestions for that element,
|
| // otherwise shows suggestions based on current value of |element|.
|
| @@ -61,7 +63,7 @@ class PasswordAutofillAgent : public content::RenderViewObserver {
|
| bool ShowSuggestions(const blink::WebInputElement& element, bool show_all);
|
|
|
| // Called when new form controls are inserted.
|
| - void OnDynamicFormsSeen(blink::WebFrame* frame);
|
| + void OnDynamicFormsSeen();
|
|
|
| // Called when the user first interacts with the page after a load. This is a
|
| // signal to make autofilled values of password input elements accessible to
|
| @@ -100,8 +102,6 @@ class PasswordAutofillAgent : public content::RenderViewObserver {
|
| typedef std::map<blink::WebElement, PasswordInfo> LoginToPasswordInfoMap;
|
| typedef std::map<blink::WebElement, int> LoginToPasswordInfoKeyMap;
|
| typedef std::map<blink::WebElement, blink::WebElement> PasswordToLoginMap;
|
| - typedef std::map<blink::WebFrame*,
|
| - linked_ptr<PasswordForm> > FrameToPasswordFormMap;
|
|
|
| // This class keeps track of autofilled password input elements and makes sure
|
| // the autofilled password value is not accessible to JavaScript code until
|
| @@ -132,19 +132,57 @@ class PasswordAutofillAgent : public content::RenderViewObserver {
|
| DISALLOW_COPY_AND_ASSIGN(PasswordValueGatekeeper);
|
| };
|
|
|
| - // RenderViewObserver:
|
| + // Thunk class for RenderViewObserver methods that haven't yet been migrated
|
| + // to RenderFrameObserver. Should eventually be removed.
|
| + // http://crbug.com/433486
|
| + class LegacyPasswordAutofillAgent : public content::RenderViewObserver {
|
| + public:
|
| + LegacyPasswordAutofillAgent(content::RenderView* render_view,
|
| + PasswordAutofillAgent* agent);
|
| + ~LegacyPasswordAutofillAgent() override;
|
| +
|
| + // RenderViewObserver:
|
| + void OnDestruct() override;
|
| + void DidStartLoading() override;
|
| + void DidStopLoading() override;
|
| + void DidStartProvisionalLoad(blink::WebLocalFrame* frame) override;
|
| + void FrameDetached(blink::WebFrame* frame) override;
|
| + void WillSendSubmitEvent(blink::WebLocalFrame* frame,
|
| + const blink::WebFormElement& form) override;
|
| + void WillSubmitForm(blink::WebLocalFrame* frame,
|
| + const blink::WebFormElement& form) override;
|
| +
|
| + private:
|
| + PasswordAutofillAgent* agent_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(LegacyPasswordAutofillAgent);
|
| + };
|
| + friend class LegacyPasswordAutofillAgent;
|
| + FRIEND_TEST_ALL_PREFIXES(
|
| + PasswordAutofillAgentTest,
|
| + RememberLastNonEmptyUsernameAndPasswordOnSubmit_ScriptCleared);
|
| + FRIEND_TEST_ALL_PREFIXES(
|
| + PasswordAutofillAgentTest,
|
| + RememberLastNonEmptyUsernameAndPasswordOnSubmit_UserCleared);
|
| + FRIEND_TEST_ALL_PREFIXES(
|
| + PasswordAutofillAgentTest,
|
| + RememberLastNonEmptyUsernameAndPasswordOnSubmit_New);
|
| +
|
| + // RenderFrameObserver:
|
| bool OnMessageReceived(const IPC::Message& message) override;
|
| - void DidStartProvisionalLoad(blink::WebLocalFrame* frame) override;
|
| - void DidStartLoading() override;
|
| - void DidFinishDocumentLoad(blink::WebLocalFrame* frame) override;
|
| - void DidFinishLoad(blink::WebLocalFrame* frame) override;
|
| - void DidStopLoading() override;
|
| - void FrameDetached(blink::WebFrame* frame) override;
|
| - void FrameWillClose(blink::WebFrame* frame) override;
|
| + void DidFinishDocumentLoad() override;
|
| + void DidFinishLoad() override;
|
| + void FrameWillClose() override;
|
| +
|
| + // Legacy RenderViewObserver:
|
| + void DidStartLoading();
|
| + void DidStopLoading();
|
| + void LegacyDidStartProvisionalLoad(blink::WebLocalFrame* frame);
|
| + void FrameDetached(blink::WebFrame* frame);
|
| void WillSendSubmitEvent(blink::WebLocalFrame* frame,
|
| - const blink::WebFormElement& form) override;
|
| + const blink::WebFormElement& form);
|
| void WillSubmitForm(blink::WebLocalFrame* frame,
|
| - const blink::WebFormElement& form) override;
|
| + const blink::WebFormElement& form);
|
|
|
| // RenderView IPC handlers:
|
| void OnFillPasswordForm(int key, const PasswordFormFillData& form_data);
|
| @@ -152,7 +190,7 @@ class PasswordAutofillAgent : public content::RenderViewObserver {
|
|
|
| // Scans the given frame for password forms and sends them up to the browser.
|
| // If |only_visible| is true, only forms visible in the layout are sent.
|
| - void SendPasswordForms(blink::WebFrame* frame, bool only_visible);
|
| + void SendPasswordForms(bool only_visible);
|
|
|
| bool ShowSuggestionPopup(const PasswordFormFillData& fill_data,
|
| const blink::WebInputElement& user_input,
|
| @@ -165,9 +203,8 @@ class PasswordAutofillAgent : public content::RenderViewObserver {
|
| const blink::WebInputElement& password,
|
| const PasswordFormFillData& fill_data);
|
|
|
| - // Invoked when the passed frame is closing. Gives us a chance to clear any
|
| - // reference we may have to elements in that frame.
|
| - void FrameClosing(const blink::WebFrame* frame);
|
| + // Invoked when the frame is closing.
|
| + void FrameClosing();
|
|
|
| // Finds login information for a |node| that was previously filled.
|
| bool FindLoginInfo(const blink::WebNode& node,
|
| @@ -179,17 +216,14 @@ class PasswordAutofillAgent : public content::RenderViewObserver {
|
| void ClearPreview(blink::WebInputElement* username,
|
| blink::WebInputElement* password);
|
|
|
| - // If |provisionally_saved_forms_| contains a form for |current_frame| or its
|
| - // children, return such frame.
|
| - blink::WebFrame* CurrentOrChildFrameWithSavedForms(
|
| - const blink::WebFrame* current_frame);
|
| -
|
| // Extracts a PasswordForm from |form| and saves it as
|
| - // |provisionally_saved_forms_[frame]|, as long as it satisfies |restriction|.
|
| - void ProvisionallySavePassword(blink::WebLocalFrame* frame,
|
| - const blink::WebFormElement& form,
|
| + // |provisionally_saved_form_|, as long as it satisfies |restriction|.
|
| + void ProvisionallySavePassword(const blink::WebFormElement& form,
|
| ProvisionallySaveRestriction restriction);
|
|
|
| + // Passes through |RenderViewObserver| method to |this|.
|
| + LegacyPasswordAutofillAgent legacy_;
|
| +
|
| // The logins we have filled so far with their associated info.
|
| LoginToPasswordInfoMap login_to_password_info_;
|
| // And the keys under which PasswordAutofillManager can find the same info.
|
| @@ -205,7 +239,7 @@ class PasswordAutofillAgent : public content::RenderViewObserver {
|
|
|
| // Set if the user might be submitting a password form on the current page,
|
| // but the submit may still fail (i.e. doesn't pass JavaScript validation).
|
| - FrameToPasswordFormMap provisionally_saved_forms_;
|
| + scoped_ptr<PasswordForm> provisionally_saved_form_;
|
|
|
| PasswordValueGatekeeper gatekeeper_;
|
|
|
|
|