Chromium Code Reviews| Index: components/autofill/core/browser/autofill_handler.h |
| diff --git a/components/autofill/core/browser/autofill_handler.h b/components/autofill/core/browser/autofill_handler.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6bc504c0249f95df7bc413f6bf5ff4b6a5ef61fe |
| --- /dev/null |
| +++ b/components/autofill/core/browser/autofill_handler.h |
| @@ -0,0 +1,109 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_HANDLER_H_ |
| +#define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_HANDLER_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/compiler_specific.h" |
| +#include "base/time/time.h" |
| +#include "build/build_config.h" |
| +#include "components/autofill/core/browser/autofill_driver.h" |
| +#include "components/autofill/core/common/form_data.h" |
| + |
| +namespace gfx { |
| +class RectF; |
| +} |
| + |
| +namespace autofill { |
| + |
| +struct FormData; |
| +struct FormFieldData; |
| + |
| +// 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
|
| +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
|
| + public: |
| + enum AutofillDownloadManagerState { |
| + ENABLE_AUTOFILL_DOWNLOAD_MANAGER, |
| + DISABLE_AUTOFILL_DOWNLOAD_MANAGER, |
| + }; |
| + |
| + virtual ~AutofillHandler(); |
| + |
| + void OnTextFieldDidChange(const FormData& form, |
| + const FormFieldData& field, |
| + const base::TimeTicks& timestamp); |
| + |
| + // The |bounding_box| is a window relative value. |
| + void OnQueryFormFieldAutofill(int query_id, |
| + const FormData& form, |
| + const FormFieldData& field, |
| + const gfx::RectF& bounding_box); |
| + |
| + // IMPORTANT: On iOS, this method is called when the form is submitted, |
| + // immediately before OnFormSubmitted() is called. Do not assume that |
| + // OnWillSubmitForm() will run before the form submits. |
| + // TODO(mathp): Revisit this and use a single method to track form submission. |
| + // |
| + // Processes the about-to-be-submitted |form|, uploading the possible field |
| + // types for the submitted fields to the crowdsourcing server. Returns false |
| + // if this form is not relevant for Autofill. |
| + bool OnWillSubmitForm(const FormData& form, const base::TimeTicks& timestamp); |
| + |
| + 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.
|
| + |
| + virtual void OnDidFillAutofillFormData(const FormData& form, |
| + const base::TimeTicks& timestamp) = 0; |
| + |
| + virtual void OnDidPreviewAutofillFormData() = 0; |
| + |
| + virtual void OnFormsSeen(const std::vector<FormData>& forms, |
| + const base::TimeTicks& timestamp) = 0; |
| + |
| + // Processes the submitted |form|, saving any new Autofill data to the user's |
| + // personal profile. Returns false if this form is not relevant for Autofill. |
| + virtual bool OnFormSubmitted(const FormData& form) = 0; |
| + |
| + virtual void OnDidEndTextFieldEditing() = 0; |
| + virtual void OnHidePopup() = 0; |
| + virtual void OnSetDataList(const std::vector<base::string16>& values, |
| + const std::vector<base::string16>& labels) = 0; |
| + |
| + // Resets cache. |
| + virtual void Reset() = 0; |
| + |
| + void SendFormDataToRenderer(int query_id, |
| + AutofillDriver::RendererFormDataAction action, |
| + const FormData& data); |
| + |
| + protected: |
| + AutofillHandler(AutofillDriver* driver); |
| + |
| + virtual bool OnWillSubmitFormImpl(const FormData& form, |
| + const base::TimeTicks& timestamp) = 0; |
| + |
| + virtual void OnTextFieldDidChangeImpl(const FormData& form, |
| + const FormFieldData& field, |
| + const base::TimeTicks& timestamp) = 0; |
| + |
| + virtual void OnQueryFormFieldAutofillImpl(int query_id, |
| + const FormData& form, |
| + const FormFieldData& field, |
| + const gfx::RectF& bounding_box) = 0; |
| + |
| + AutofillDriver* driver() { return driver_; } |
| + |
| + private: |
| + // Provides driver-level context to the shared code of the component. Must |
| + // outlive this object. |
| + AutofillDriver* driver_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AutofillHandler); |
| +}; |
| + |
| +} // namespace autofill |
| + |
| +#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_HANDLER_H_ |