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 class defines the interface should be implemented by autofill | |
| 27 // implementation in browser side to interact with AutofillDriver. | |
| 28 class AutofillHandler { | |
| 29 public: | |
| 30 enum AutofillDownloadManagerState { | |
| 31 ENABLE_AUTOFILL_DOWNLOAD_MANAGER, | |
| 32 DISABLE_AUTOFILL_DOWNLOAD_MANAGER, | |
| 33 }; | |
| 34 | |
| 35 virtual ~AutofillHandler(); | |
| 36 | |
| 37 // Invoked when the value of textfield is changed. | |
| 38 void OnTextFieldDidChange(const FormData& form, | |
| 39 const FormFieldData& field, | |
| 40 const base::TimeTicks& timestamp); | |
|
Roger McFarlane (Chromium)
2017/05/31 18:33:23
nit: prefer to pass base::TimeTicks by value throu
michaelbai
2017/05/31 21:05:54
Done.
| |
| 41 | |
| 42 // Invoked when the |form| needs to be autofilled, the |bounding_box| is | |
| 43 // a window relative value of |field|. | |
| 44 void OnQueryFormFieldAutofill(int query_id, | |
| 45 const FormData& form, | |
| 46 const FormFieldData& field, | |
| 47 const gfx::RectF& bounding_box); | |
| 48 | |
| 49 // Invoked when the specified form will be submitted, returns false if this | |
| 50 // form is not relevant for Autofill. | |
| 51 // | |
| 52 // IMPORTANT: On iOS, this method is called when the form is submitted, | |
| 53 // immediately before OnFormSubmitted() is called. Do not assume that | |
| 54 // OnWillSubmitForm() will run before the form submits. | |
| 55 // TODO(mathp): Revisit this and use a single method to track form submission. | |
| 56 // | |
| 57 // Processes the about-to-be-submitted |form|, uploading the possible field | |
| 58 // types for the submitted fields to the crowdsourcing server. | |
| 59 bool OnWillSubmitForm(const FormData& form, const base::TimeTicks& timestamp); | |
| 60 | |
| 61 // Invoked when focus is no longer on form. | |
| 62 virtual void OnFocusNoLongerOnForm() = 0; | |
| 63 | |
| 64 // Invoked when |form| has been filled with the value given by | |
| 65 // SendFormDataToRenderer. | |
| 66 virtual void OnDidFillAutofillFormData(const FormData& form, | |
| 67 const base::TimeTicks& timestamp) = 0; | |
| 68 | |
| 69 // Invoked when preview autofill value has been shown. | |
| 70 virtual void OnDidPreviewAutofillFormData() = 0; | |
| 71 | |
| 72 // Invoked when |forms| has been detected. | |
| 73 virtual void OnFormsSeen(const std::vector<FormData>& forms, | |
| 74 const base::TimeTicks& timestamp) = 0; | |
| 75 | |
| 76 // Invoked when |form| has been submitted. | |
| 77 // Processes the submitted |form|, saving any new Autofill data to the user's | |
| 78 // personal profile. Returns false if this form is not relevant for Autofill. | |
| 79 virtual bool OnFormSubmitted(const FormData& form) = 0; | |
| 80 | |
| 81 // Invoked when textfeild editing ended | |
| 82 virtual void OnDidEndTextFieldEditing() = 0; | |
| 83 | |
| 84 // Invoked when popup window should be hidden. | |
| 85 virtual void OnHidePopup() = 0; | |
| 86 | |
| 87 // Invoked when data list need to be set. | |
| 88 virtual void OnSetDataList(const std::vector<base::string16>& values, | |
| 89 const std::vector<base::string16>& labels) = 0; | |
| 90 | |
| 91 // Resets cache. | |
| 92 virtual void Reset() = 0; | |
| 93 | |
| 94 // Send the form |data| to renderer for the specified |action|. | |
| 95 void SendFormDataToRenderer(int query_id, | |
| 96 AutofillDriver::RendererFormDataAction action, | |
| 97 const FormData& data); | |
| 98 | |
| 99 protected: | |
| 100 AutofillHandler(AutofillDriver* driver); | |
| 101 | |
| 102 virtual bool OnWillSubmitFormImpl(const FormData& form, | |
| 103 const base::TimeTicks& timestamp) = 0; | |
| 104 | |
| 105 virtual void OnTextFieldDidChangeImpl(const FormData& form, | |
| 106 const FormFieldData& field, | |
| 107 const base::TimeTicks& timestamp) = 0; | |
| 108 | |
| 109 virtual void OnQueryFormFieldAutofillImpl(int query_id, | |
| 110 const FormData& form, | |
| 111 const FormFieldData& field, | |
| 112 const gfx::RectF& bounding_box) = 0; | |
| 113 | |
| 114 AutofillDriver* driver() { return driver_; } | |
| 115 | |
| 116 private: | |
| 117 // Provides driver-level context to the shared code of the component. Must | |
| 118 // outlive this object. | |
| 119 AutofillDriver* driver_; | |
| 120 | |
| 121 DISALLOW_COPY_AND_ASSIGN(AutofillHandler); | |
| 122 }; | |
| 123 | |
| 124 } // namespace autofill | |
| 125 | |
| 126 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_HANDLER_H_ | |
| OLD | NEW |