| 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_CLIENT_H_ |
| 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_CLIENT_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 | 14 |
| 15 namespace gfx { | 15 namespace gfx { |
| 16 class Rect; | 16 class Rect; |
| 17 class RectF; | 17 class RectF; |
| 18 } | 18 } |
| 19 | 19 |
| 20 class GURL; | 20 class GURL; |
| 21 class InfoBarService; | 21 class InfoBarService; |
| 22 class PrefService; | 22 class PrefService; |
| 23 | 23 |
| 24 namespace autofill { | 24 namespace autofill { |
| 25 | 25 |
| 26 class AutofillMetrics; | 26 class AutofillMetrics; |
| 27 class AutofillPopupDelegate; | 27 class AutofillPopupDelegate; |
| 28 class AutofillWebDataService; | 28 class AutofillWebDataService; |
| 29 class CreditCard; | 29 class CreditCard; |
| 30 class FormStructure; | 30 class FormStructure; |
| 31 class PasswordGenerator; | 31 class PasswordGenerator; |
| 32 class PersonalDataManager; | 32 class PersonalDataManager; |
| 33 struct FormData; | 33 struct FormData; |
| 34 struct PasswordForm; | 34 struct PasswordForm; |
| 35 | 35 |
| 36 // A delegate interface that needs to be supplied to AutofillManager | 36 // A client interface that needs to be supplied to the Autofill component by the |
| 37 // by the embedder. | 37 // embedder. |
| 38 // | 38 // |
| 39 // Each delegate instance is associated with a given context within | 39 // Each client instance is associated with a given context within which an |
| 40 // which an AutofillManager is used (e.g. a single tab), so when we | 40 // AutofillManager is used (e.g. a single tab), so when we say "for the client" |
| 41 // say "for the delegate" below, we mean "in the execution context the | 41 // below, we mean "in the execution context the client is associated with" (e.g. |
| 42 // delegate is associated with" (e.g. for the tab the AutofillManager is | 42 // for the tab the AutofillManager is attached to). |
| 43 // attached to). | 43 class AutofillClient { |
| 44 class AutofillManagerDelegate { | |
| 45 public: | 44 public: |
| 46 // Copy of blink::WebFormElement::AutocompleteResult. | 45 // Copy of blink::WebFormElement::AutocompleteResult. |
| 47 enum RequestAutocompleteResult { | 46 enum RequestAutocompleteResult { |
| 48 AutocompleteResultSuccess, | 47 AutocompleteResultSuccess, |
| 49 AutocompleteResultErrorDisabled, | 48 AutocompleteResultErrorDisabled, |
| 50 AutocompleteResultErrorCancel, | 49 AutocompleteResultErrorCancel, |
| 51 AutocompleteResultErrorInvalid, | 50 AutocompleteResultErrorInvalid, |
| 52 }; | 51 }; |
| 53 | 52 |
| 54 typedef base::Callback< | 53 typedef base::Callback<void(RequestAutocompleteResult, |
| 55 void(RequestAutocompleteResult, | 54 const base::string16&, |
| 56 const base::string16&, | 55 const FormStructure*)> ResultCallback; |
| 57 const FormStructure*)> ResultCallback; | |
| 58 | 56 |
| 59 virtual ~AutofillManagerDelegate() {} | 57 virtual ~AutofillClient() {} |
| 60 | 58 |
| 61 // Gets the PersonalDataManager instance associated with the delegate. | 59 // Gets the PersonalDataManager instance associated with the client. |
| 62 virtual PersonalDataManager* GetPersonalDataManager() = 0; | 60 virtual PersonalDataManager* GetPersonalDataManager() = 0; |
| 63 | 61 |
| 64 // Gets the AutofillWebDataService instance associated with the delegate. | 62 // Gets the AutofillWebDataService instance associated with the client. |
| 65 virtual scoped_refptr<AutofillWebDataService> GetDatabase() = 0; | 63 virtual scoped_refptr<AutofillWebDataService> GetDatabase() = 0; |
| 66 | 64 |
| 67 // Gets the preferences associated with the delegate. | 65 // Gets the preferences associated with the client. |
| 68 virtual PrefService* GetPrefs() = 0; | 66 virtual PrefService* GetPrefs() = 0; |
| 69 | 67 |
| 70 // Hides the associated request autocomplete dialog (if it exists). | 68 // Hides the associated request autocomplete dialog (if it exists). |
| 71 virtual void HideRequestAutocompleteDialog() = 0; | 69 virtual void HideRequestAutocompleteDialog() = 0; |
| 72 | 70 |
| 73 // Causes the Autofill settings UI to be shown. | 71 // Causes the Autofill settings UI to be shown. |
| 74 virtual void ShowAutofillSettings() = 0; | 72 virtual void ShowAutofillSettings() = 0; |
| 75 | 73 |
| 76 // Run |save_card_callback| if the credit card should be imported as personal | 74 // Run |save_card_callback| if the credit card should be imported as personal |
| 77 // data. |metric_logger| can be used to log user actions. | 75 // data. |metric_logger| can be used to log user actions. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 106 virtual void HideAutofillPopup() = 0; | 104 virtual void HideAutofillPopup() = 0; |
| 107 | 105 |
| 108 // Whether the Autocomplete feature of Autofill should be enabled. | 106 // Whether the Autocomplete feature of Autofill should be enabled. |
| 109 virtual bool IsAutocompleteEnabled() = 0; | 107 virtual bool IsAutocompleteEnabled() = 0; |
| 110 | 108 |
| 111 // Pass the form structures to the password generation manager to detect | 109 // Pass the form structures to the password generation manager to detect |
| 112 // account creation forms. | 110 // account creation forms. |
| 113 virtual void DetectAccountCreationForms( | 111 virtual void DetectAccountCreationForms( |
| 114 const std::vector<autofill::FormStructure*>& forms) = 0; | 112 const std::vector<autofill::FormStructure*>& forms) = 0; |
| 115 | 113 |
| 116 // Inform the delegate that the field has been filled. | 114 // Inform the client that the field has been filled. |
| 117 virtual void DidFillOrPreviewField( | 115 virtual void DidFillOrPreviewField( |
| 118 const base::string16& autofilled_value, | 116 const base::string16& autofilled_value, |
| 119 const base::string16& profile_full_name) = 0; | 117 const base::string16& profile_full_name) = 0; |
| 120 | |
| 121 }; | 118 }; |
| 122 | 119 |
| 123 } // namespace autofill | 120 } // namespace autofill |
| 124 | 121 |
| 125 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_ | 122 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_CLIENT_H_ |
| OLD | NEW |