Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_HANDLER_H_ | |
| 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_HANDLER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "base/time/time.h" | |
| 13 #include "build/build_config.h" | |
| 14 #include "components/autofill/core/browser/autofill_driver.h" | |
| 15 #include "components/autofill/core/common/form_data.h" | |
| 16 | |
| 17 namespace gfx { | |
| 18 class RectF; | |
| 19 } | |
| 20 | |
| 21 namespace autofill { | |
| 22 | |
| 23 struct FormData; | |
| 24 struct FormFieldData; | |
| 25 | |
| 26 // This interface is used by AutofillDriver to drive autofill. | |
|
sebsg
2017/05/24 13:32:42
This is not super clear to me, could you explain a
michaelbai
2017/05/26 23:12:08
Revised
| |
| 27 class AutofillHandler { | |
|
Roger McFarlane (Chromium)
2017/05/24 04:18:22
would the hierarchy be better named:
AutofillMa
michaelbai
2017/05/24 05:14:09
I will rename those classes, please be noticed ren
Roger McFarlane (Chromium)
2017/05/24 20:03:30
indeed. Maybe address any name changes in another
michaelbai
2017/05/24 20:43:23
Thanks I will address name changes in following up
| |
| 28 public: | |
| 29 enum AutofillDownloadManagerState { | |
| 30 ENABLE_AUTOFILL_DOWNLOAD_MANAGER, | |
| 31 DISABLE_AUTOFILL_DOWNLOAD_MANAGER, | |
| 32 }; | |
| 33 | |
| 34 virtual ~AutofillHandler(); | |
| 35 | |
| 36 void OnTextFieldDidChange(const FormData& form, | |
| 37 const FormFieldData& field, | |
| 38 const base::TimeTicks& timestamp); | |
| 39 | |
| 40 // The |bounding_box| is a window relative value. | |
| 41 void OnQueryFormFieldAutofill(int query_id, | |
| 42 const FormData& form, | |
| 43 const FormFieldData& field, | |
| 44 const gfx::RectF& bounding_box); | |
| 45 | |
| 46 // IMPORTANT: On iOS, this method is called when the form is submitted, | |
| 47 // immediately before OnFormSubmitted() is called. Do not assume that | |
| 48 // OnWillSubmitForm() will run before the form submits. | |
| 49 // TODO(mathp): Revisit this and use a single method to track form submission. | |
| 50 // | |
| 51 // Processes the about-to-be-submitted |form|, uploading the possible field | |
| 52 // types for the submitted fields to the crowdsourcing server. Returns false | |
| 53 // if this form is not relevant for Autofill. | |
| 54 bool OnWillSubmitForm(const FormData& form, const base::TimeTicks& timestamp); | |
| 55 | |
| 56 virtual void OnFocusNoLongerOnForm() = 0; | |
|
Mathieu
2017/05/24 18:02:02
Add comments to your virtual methods. This is the
michaelbai
2017/05/26 23:12:08
Acknowledged.
| |
| 57 | |
| 58 virtual void OnDidFillAutofillFormData(const FormData& form, | |
| 59 const base::TimeTicks& timestamp) = 0; | |
| 60 | |
| 61 virtual void OnDidPreviewAutofillFormData() = 0; | |
| 62 | |
| 63 virtual void OnFormsSeen(const std::vector<FormData>& forms, | |
| 64 const base::TimeTicks& timestamp) = 0; | |
| 65 | |
| 66 // Processes the submitted |form|, saving any new Autofill data to the user's | |
| 67 // personal profile. Returns false if this form is not relevant for Autofill. | |
| 68 virtual bool OnFormSubmitted(const FormData& form) = 0; | |
| 69 | |
| 70 virtual void OnDidEndTextFieldEditing() = 0; | |
| 71 virtual void OnHidePopup() = 0; | |
| 72 virtual void OnSetDataList(const std::vector<base::string16>& values, | |
| 73 const std::vector<base::string16>& labels) = 0; | |
| 74 | |
| 75 // Resets cache. | |
| 76 virtual void Reset() = 0; | |
| 77 | |
| 78 void SendFormDataToRenderer(int query_id, | |
| 79 AutofillDriver::RendererFormDataAction action, | |
| 80 const FormData& data); | |
| 81 | |
| 82 protected: | |
| 83 AutofillHandler(AutofillDriver* driver); | |
| 84 | |
| 85 virtual bool OnWillSubmitFormImpl(const FormData& form, | |
| 86 const base::TimeTicks& timestamp) = 0; | |
| 87 | |
| 88 virtual void OnTextFieldDidChangeImpl(const FormData& form, | |
| 89 const FormFieldData& field, | |
| 90 const base::TimeTicks& timestamp) = 0; | |
| 91 | |
| 92 virtual void OnQueryFormFieldAutofillImpl(int query_id, | |
| 93 const FormData& form, | |
| 94 const FormFieldData& field, | |
| 95 const gfx::RectF& bounding_box) = 0; | |
| 96 | |
| 97 AutofillDriver* driver() { return driver_; } | |
| 98 | |
| 99 private: | |
| 100 // Provides driver-level context to the shared code of the component. Must | |
| 101 // outlive this object. | |
| 102 AutofillDriver* driver_; | |
| 103 | |
| 104 DISALLOW_COPY_AND_ASSIGN(AutofillHandler); | |
| 105 }; | |
| 106 | |
| 107 } // namespace autofill | |
| 108 | |
| 109 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_HANDLER_H_ | |
| OLD | NEW |