Chromium Code Reviews| 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_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_ |
| 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 // A delegate interface that needs to be supplied to AutofillManager | 36 // A delegate interface that needs to be supplied to AutofillManager |
| 37 // by the embedder. | 37 // by the embedder. |
| 38 // | 38 // |
| 39 // Each delegate instance is associated with a given context within | 39 // Each delegate instance is associated with a given context within |
| 40 // which an AutofillManager is used (e.g. a single tab), so when we | 40 // which an AutofillManager is used (e.g. a single tab), so when we |
| 41 // say "for the delegate" below, we mean "in the execution context the | 41 // say "for the delegate" below, we mean "in the execution context the |
| 42 // delegate is associated with" (e.g. for the tab the AutofillManager is | 42 // delegate is associated with" (e.g. for the tab the AutofillManager is |
| 43 // attached to). | 43 // attached to). |
| 44 class AutofillManagerDelegate { | 44 class AutofillManagerDelegate { |
| 45 public: | 45 public: |
| 46 // Copy of blink::WebFormElement::AutocompleteResult. | |
|
Dan Beam
2014/04/09 22:16:54
did you copy this because components/ can't rely o
Evan Stade
2014/04/09 22:37:42
because core/ cannot (look upthread)
Ilya Sherman
2014/04/09 22:39:33
Is there no location we can put this enum so that
| |
| 47 enum RequestAutocompleteResult { | |
| 48 AutocompleteResultSuccess, | |
| 49 AutocompleteResultErrorDisabled, | |
| 50 AutocompleteResultErrorCancel, | |
| 51 AutocompleteResultErrorInvalid, | |
| 52 // TODO(estade): add this one to WebFormElement::AutocompleteResult. | |
| 53 AutocompleteResultErrorUnsupported, | |
| 54 }; | |
| 55 | |
| 56 typedef base::Callback< | |
| 57 void(RequestAutocompleteResult, const FormStructure*)> ResultCallback; | |
| 58 | |
| 46 virtual ~AutofillManagerDelegate() {} | 59 virtual ~AutofillManagerDelegate() {} |
| 47 | 60 |
| 48 // Gets the PersonalDataManager instance associated with the delegate. | 61 // Gets the PersonalDataManager instance associated with the delegate. |
| 49 virtual PersonalDataManager* GetPersonalDataManager() = 0; | 62 virtual PersonalDataManager* GetPersonalDataManager() = 0; |
| 50 | 63 |
| 51 // Gets the AutofillWebDataService instance associated with the delegate. | 64 // Gets the AutofillWebDataService instance associated with the delegate. |
| 52 virtual scoped_refptr<AutofillWebDataService> GetDatabase() = 0; | 65 virtual scoped_refptr<AutofillWebDataService> GetDatabase() = 0; |
| 53 | 66 |
| 54 // Gets the preferences associated with the delegate. | 67 // Gets the preferences associated with the delegate. |
| 55 virtual PrefService* GetPrefs() = 0; | 68 virtual PrefService* GetPrefs() = 0; |
| 56 | 69 |
| 57 // Hides the associated request autocomplete dialog (if it exists). | 70 // Hides the associated request autocomplete dialog (if it exists). |
| 58 virtual void HideRequestAutocompleteDialog() = 0; | 71 virtual void HideRequestAutocompleteDialog() = 0; |
| 59 | 72 |
| 60 // Causes the Autofill settings UI to be shown. | 73 // Causes the Autofill settings UI to be shown. |
| 61 virtual void ShowAutofillSettings() = 0; | 74 virtual void ShowAutofillSettings() = 0; |
| 62 | 75 |
| 63 // Run |save_card_callback| if the credit card should be imported as personal | 76 // Run |save_card_callback| if the credit card should be imported as personal |
| 64 // data. |metric_logger| can be used to log user actions. | 77 // data. |metric_logger| can be used to log user actions. |
| 65 virtual void ConfirmSaveCreditCard( | 78 virtual void ConfirmSaveCreditCard( |
| 66 const AutofillMetrics& metric_logger, | 79 const AutofillMetrics& metric_logger, |
| 67 const base::Closure& save_card_callback) = 0; | 80 const base::Closure& save_card_callback) = 0; |
| 68 | 81 |
| 69 // Causes the dialog for request autocomplete feature to be shown. | 82 // Causes the dialog for request autocomplete feature to be shown. |
| 70 virtual void ShowRequestAutocompleteDialog( | 83 virtual void ShowRequestAutocompleteDialog( |
| 71 const FormData& form, | 84 const FormData& form, |
| 72 const GURL& source_url, | 85 const GURL& source_url, |
| 73 const base::Callback<void(const FormStructure*)>& callback) = 0; | 86 const ResultCallback& callback) = 0; |
| 74 | 87 |
| 75 // Shows an Autofill popup with the given |values|, |labels|, |icons|, and | 88 // Shows an Autofill popup with the given |values|, |labels|, |icons|, and |
| 76 // |identifiers| for the element at |element_bounds|. |delegate| will be | 89 // |identifiers| for the element at |element_bounds|. |delegate| will be |
| 77 // notified of popup events. | 90 // notified of popup events. |
| 78 virtual void ShowAutofillPopup( | 91 virtual void ShowAutofillPopup( |
| 79 const gfx::RectF& element_bounds, | 92 const gfx::RectF& element_bounds, |
| 80 base::i18n::TextDirection text_direction, | 93 base::i18n::TextDirection text_direction, |
| 81 const std::vector<base::string16>& values, | 94 const std::vector<base::string16>& values, |
| 82 const std::vector<base::string16>& labels, | 95 const std::vector<base::string16>& labels, |
| 83 const std::vector<base::string16>& icons, | 96 const std::vector<base::string16>& icons, |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 103 // Inform the delegate that the field has been filled. | 116 // Inform the delegate that the field has been filled. |
| 104 virtual void DidFillOrPreviewField( | 117 virtual void DidFillOrPreviewField( |
| 105 const base::string16& autofilled_value, | 118 const base::string16& autofilled_value, |
| 106 const base::string16& profile_full_name) = 0; | 119 const base::string16& profile_full_name) = 0; |
| 107 | 120 |
| 108 }; | 121 }; |
| 109 | 122 |
| 110 } // namespace autofill | 123 } // namespace autofill |
| 111 | 124 |
| 112 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_ | 125 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_ |
| OLD | NEW |