| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ |
| 6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ | 6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "components/autofill/content/public/interfaces/autofill_agent.mojom.h" | |
| 14 #include "components/autofill/content/public/interfaces/autofill_driver.mojom.h" | 13 #include "components/autofill/content/public/interfaces/autofill_driver.mojom.h" |
| 15 #include "components/autofill/content/renderer/autofill_agent.h" | 14 #include "components/autofill/content/renderer/autofill_agent.h" |
| 16 #include "components/autofill/content/renderer/password_form_conversion_utils.h" | 15 #include "components/autofill/content/renderer/password_form_conversion_utils.h" |
| 17 #include "components/autofill/core/common/form_data_predictions.h" | 16 #include "components/autofill/core/common/form_data_predictions.h" |
| 18 #include "components/autofill/core/common/password_form.h" | 17 #include "components/autofill/core/common/password_form.h" |
| 19 #include "components/autofill/core/common/password_form_field_prediction_map.h" | 18 #include "components/autofill/core/common/password_form_field_prediction_map.h" |
| 20 #include "components/autofill/core/common/password_form_fill_data.h" | 19 #include "components/autofill/core/common/password_form_fill_data.h" |
| 21 #include "content/public/renderer/render_frame_observer.h" | 20 #include "content/public/renderer/render_frame_observer.h" |
| 22 #include "content/public/renderer/render_view_observer.h" | 21 #include "content/public/renderer/render_view_observer.h" |
| 23 #include "mojo/public/cpp/bindings/binding.h" | |
| 24 #include "third_party/WebKit/public/web/WebInputElement.h" | 22 #include "third_party/WebKit/public/web/WebInputElement.h" |
| 25 | 23 |
| 26 namespace blink { | 24 namespace blink { |
| 27 class WebInputElement; | 25 class WebInputElement; |
| 28 class WebKeyboardEvent; | 26 class WebKeyboardEvent; |
| 29 class WebSecurityOrigin; | 27 class WebSecurityOrigin; |
| 30 } | 28 } |
| 31 | 29 |
| 32 namespace autofill { | 30 namespace autofill { |
| 33 | 31 |
| 34 class RendererSavePasswordProgressLogger; | 32 class RendererSavePasswordProgressLogger; |
| 35 | 33 |
| 36 // This class is responsible for filling password forms. | 34 // This class is responsible for filling password forms. |
| 37 class PasswordAutofillAgent : public content::RenderFrameObserver, | 35 class PasswordAutofillAgent : public content::RenderFrameObserver { |
| 38 public mojom::PasswordAutofillAgent { | |
| 39 public: | 36 public: |
| 40 explicit PasswordAutofillAgent(content::RenderFrame* render_frame); | 37 explicit PasswordAutofillAgent(content::RenderFrame* render_frame); |
| 41 ~PasswordAutofillAgent() override; | 38 ~PasswordAutofillAgent() override; |
| 42 | 39 |
| 43 void BindRequest(mojom::PasswordAutofillAgentRequest request); | |
| 44 | |
| 45 void SetAutofillAgent(AutofillAgent* autofill_agent); | 40 void SetAutofillAgent(AutofillAgent* autofill_agent); |
| 46 | 41 |
| 47 const mojom::PasswordManagerDriverPtr& GetPasswordManagerDriver(); | |
| 48 | |
| 49 // mojom::PasswordAutofillAgent: | |
| 50 void FillPasswordForm(int key, | |
| 51 const PasswordFormFillData& form_data) override; | |
| 52 void SetLoggingState(bool active) override; | |
| 53 void AutofillUsernameAndPasswordDataReceived( | |
| 54 const FormsPredictionsMap& predictions) override; | |
| 55 void FindFocusedPasswordForm( | |
| 56 const FindFocusedPasswordFormCallback& callback) override; | |
| 57 | |
| 58 // WebFrameClient editor related calls forwarded by AutofillAgent. | 42 // WebFrameClient editor related calls forwarded by AutofillAgent. |
| 59 // If they return true, it indicates the event was consumed and should not | 43 // If they return true, it indicates the event was consumed and should not |
| 60 // be used for any other autofill activity. | 44 // be used for any other autofill activity. |
| 61 bool TextFieldDidEndEditing(const blink::WebInputElement& element); | 45 bool TextFieldDidEndEditing(const blink::WebInputElement& element); |
| 62 bool TextDidChangeInTextField(const blink::WebInputElement& element); | 46 bool TextDidChangeInTextField(const blink::WebInputElement& element); |
| 63 | 47 |
| 64 // Function that should be called whenever the value of |element| changes due | 48 // Function that should be called whenever the value of |element| changes due |
| 65 // to user input. This is separate from TextDidChangeInTextField() as that | 49 // to user input. This is separate from TextDidChangeInTextField() as that |
| 66 // function may trigger UI and should only be called when other UI won't be | 50 // function may trigger UI and should only be called when other UI won't be |
| 67 // shown. | 51 // shown. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 // Make the value of |element| accessible to JavaScript code. | 159 // Make the value of |element| accessible to JavaScript code. |
| 176 void ShowValue(blink::WebInputElement* element); | 160 void ShowValue(blink::WebInputElement* element); |
| 177 | 161 |
| 178 bool was_user_gesture_seen_; | 162 bool was_user_gesture_seen_; |
| 179 std::vector<blink::WebInputElement> elements_; | 163 std::vector<blink::WebInputElement> elements_; |
| 180 | 164 |
| 181 DISALLOW_COPY_AND_ASSIGN(PasswordValueGatekeeper); | 165 DISALLOW_COPY_AND_ASSIGN(PasswordValueGatekeeper); |
| 182 }; | 166 }; |
| 183 | 167 |
| 184 // RenderFrameObserver: | 168 // RenderFrameObserver: |
| 169 bool OnMessageReceived(const IPC::Message& message) override; |
| 185 void DidFinishDocumentLoad() override; | 170 void DidFinishDocumentLoad() override; |
| 186 void DidFinishLoad() override; | 171 void DidFinishLoad() override; |
| 187 void FrameDetached() override; | 172 void FrameDetached() override; |
| 188 void FrameWillClose() override; | 173 void FrameWillClose() override; |
| 189 void DidStartProvisionalLoad() override; | 174 void DidStartProvisionalLoad() override; |
| 190 void DidCommitProvisionalLoad(bool is_new_navigation, | 175 void DidCommitProvisionalLoad(bool is_new_navigation, |
| 191 bool is_same_page_navigation) override; | 176 bool is_same_page_navigation) override; |
| 192 void WillSendSubmitEvent(const blink::WebFormElement& form) override; | 177 void WillSendSubmitEvent(const blink::WebFormElement& form) override; |
| 193 void WillSubmitForm(const blink::WebFormElement& form) override; | 178 void WillSubmitForm(const blink::WebFormElement& form) override; |
| 194 void OnDestruct() override; | 179 void OnDestruct() override; |
| 195 | 180 |
| 181 // RenderView IPC handlers: |
| 182 void OnFillPasswordForm(int key, const PasswordFormFillData& form_data); |
| 183 void OnSetLoggingState(bool active); |
| 184 void OnAutofillUsernameAndPasswordDataReceived( |
| 185 const FormsPredictionsMap& predictions); |
| 186 void OnFindFocusedPasswordForm(); |
| 187 |
| 196 // Scans the given frame for password forms and sends them up to the browser. | 188 // Scans the given frame for password forms and sends them up to the browser. |
| 197 // If |only_visible| is true, only forms visible in the layout are sent. | 189 // If |only_visible| is true, only forms visible in the layout are sent. |
| 198 void SendPasswordForms(bool only_visible); | 190 void SendPasswordForms(bool only_visible); |
| 199 | 191 |
| 200 // Instructs the browser to show a pop-up suggesting which credentials could | 192 // Instructs the browser to show a pop-up suggesting which credentials could |
| 201 // be filled. |show_in_password_field| should indicate whether the pop-up is | 193 // be filled. |show_in_password_field| should indicate whether the pop-up is |
| 202 // to be shown on the password field instead of on the username field. If the | 194 // to be shown on the password field instead of on the username field. If the |
| 203 // username exists, it should be passed as |user_input|. If there is no | 195 // username exists, it should be passed as |user_input|. If there is no |
| 204 // username, pass the password field in |user_input|. In the latter case, no | 196 // username, pass the password field in |user_input|. In the latter case, no |
| 205 // username value will be shown in the pop-up. | 197 // username value will be shown in the pop-up. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 263 |
| 272 // Records the username typed before suggestions preview. | 264 // Records the username typed before suggestions preview. |
| 273 base::string16 username_query_prefix_; | 265 base::string16 username_query_prefix_; |
| 274 | 266 |
| 275 // Contains server predictions for username, password and/or new password | 267 // Contains server predictions for username, password and/or new password |
| 276 // fields for individual forms. | 268 // fields for individual forms. |
| 277 FormsPredictionsMap form_predictions_; | 269 FormsPredictionsMap form_predictions_; |
| 278 | 270 |
| 279 AutofillAgent* autofill_agent_; // Weak reference. | 271 AutofillAgent* autofill_agent_; // Weak reference. |
| 280 | 272 |
| 281 mojom::PasswordManagerDriverPtr password_manager_driver_; | |
| 282 | |
| 283 mojo::Binding<mojom::PasswordAutofillAgent> binding_; | |
| 284 | |
| 285 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent); | 273 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent); |
| 286 }; | 274 }; |
| 287 | 275 |
| 288 } // namespace autofill | 276 } // namespace autofill |
| 289 | 277 |
| 290 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ | 278 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ |
| OLD | NEW |