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