| 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 TextDidChangeInTextField(const blink::WebInputElement& element); | 61 bool TextDidChangeInTextField(const blink::WebInputElement& element); |
| 46 | 62 |
| 47 // Function that should be called whenever the value of |element| changes due | 63 // Function that should be called whenever the value of |element| changes due |
| 48 // to user input. This is separate from TextDidChangeInTextField() as that | 64 // to user input. This is separate from TextDidChangeInTextField() as that |
| 49 // function may trigger UI and should only be called when other UI won't be | 65 // function may trigger UI and should only be called when other UI won't be |
| 50 // shown. | 66 // shown. |
| 51 void UpdateStateForTextChange(const blink::WebInputElement& element); | 67 void UpdateStateForTextChange(const blink::WebInputElement& element); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 // Make the value of |element| accessible to JavaScript code. | 174 // Make the value of |element| accessible to JavaScript code. |
| 159 void ShowValue(blink::WebInputElement* element); | 175 void ShowValue(blink::WebInputElement* element); |
| 160 | 176 |
| 161 bool was_user_gesture_seen_; | 177 bool was_user_gesture_seen_; |
| 162 std::vector<blink::WebInputElement> elements_; | 178 std::vector<blink::WebInputElement> elements_; |
| 163 | 179 |
| 164 DISALLOW_COPY_AND_ASSIGN(PasswordValueGatekeeper); | 180 DISALLOW_COPY_AND_ASSIGN(PasswordValueGatekeeper); |
| 165 }; | 181 }; |
| 166 | 182 |
| 167 // RenderFrameObserver: | 183 // RenderFrameObserver: |
| 168 bool OnMessageReceived(const IPC::Message& message) override; | |
| 169 void DidFinishDocumentLoad() override; | 184 void DidFinishDocumentLoad() override; |
| 170 void DidFinishLoad() override; | 185 void DidFinishLoad() override; |
| 171 void FrameDetached() override; | 186 void FrameDetached() override; |
| 172 void FrameWillClose() override; | 187 void FrameWillClose() override; |
| 173 void DidStartProvisionalLoad() override; | 188 void DidStartProvisionalLoad() override; |
| 174 void DidCommitProvisionalLoad(bool is_new_navigation, | 189 void DidCommitProvisionalLoad(bool is_new_navigation, |
| 175 bool is_same_page_navigation) override; | 190 bool is_same_page_navigation) override; |
| 176 void WillSendSubmitEvent(const blink::WebFormElement& form) override; | 191 void WillSendSubmitEvent(const blink::WebFormElement& form) override; |
| 177 void WillSubmitForm(const blink::WebFormElement& form) override; | 192 void WillSubmitForm(const blink::WebFormElement& form) override; |
| 178 void OnDestruct() override; | 193 void OnDestruct() override; |
| 179 | 194 |
| 180 // RenderView IPC handlers: | |
| 181 void OnFillPasswordForm(int key, const PasswordFormFillData& form_data); | |
| 182 void OnSetLoggingState(bool active); | |
| 183 void OnAutofillUsernameAndPasswordDataReceived( | |
| 184 const FormsPredictionsMap& predictions); | |
| 185 void OnFindFocusedPasswordForm(); | |
| 186 | |
| 187 // Scans the given frame for password forms and sends them up to the browser. | 195 // Scans the given frame for password forms and sends them up to the browser. |
| 188 // If |only_visible| is true, only forms visible in the layout are sent. | 196 // If |only_visible| is true, only forms visible in the layout are sent. |
| 189 void SendPasswordForms(bool only_visible); | 197 void SendPasswordForms(bool only_visible); |
| 190 | 198 |
| 191 // Instructs the browser to show a pop-up suggesting which credentials could | 199 // Instructs the browser to show a pop-up suggesting which credentials could |
| 192 // be filled. |show_in_password_field| should indicate whether the pop-up is | 200 // be filled. |show_in_password_field| should indicate whether the pop-up is |
| 193 // to be shown on the password field instead of on the username field. If the | 201 // to be shown on the password field instead of on the username field. If the |
| 194 // username exists, it should be passed as |user_input|. If there is no | 202 // username exists, it should be passed as |user_input|. If there is no |
| 195 // username, pass the password field in |user_input|. In the latter case, no | 203 // username, pass the password field in |user_input|. In the latter case, no |
| 196 // username value will be shown in the pop-up. | 204 // username value will be shown in the pop-up. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 | 270 |
| 263 // Records the username typed before suggestions preview. | 271 // Records the username typed before suggestions preview. |
| 264 base::string16 username_query_prefix_; | 272 base::string16 username_query_prefix_; |
| 265 | 273 |
| 266 // Contains server predictions for username, password and/or new password | 274 // Contains server predictions for username, password and/or new password |
| 267 // fields for individual forms. | 275 // fields for individual forms. |
| 268 FormsPredictionsMap form_predictions_; | 276 FormsPredictionsMap form_predictions_; |
| 269 | 277 |
| 270 AutofillAgent* autofill_agent_; // Weak reference. | 278 AutofillAgent* autofill_agent_; // Weak reference. |
| 271 | 279 |
| 280 mojom::PasswordManagerDriverPtr password_manager_driver_; |
| 281 |
| 282 mojo::Binding<mojom::PasswordAutofillAgent> binding_; |
| 283 |
| 272 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent); | 284 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent); |
| 273 }; | 285 }; |
| 274 | 286 |
| 275 } // namespace autofill | 287 } // namespace autofill |
| 276 | 288 |
| 277 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ | 289 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ |
| OLD | NEW |