| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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 CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_DELEGATE_H_ | |
| 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_DELEGATE_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/callback_forward.h" | |
| 11 #include "base/string16.h" | |
| 12 #include "ui/gfx/native_widget_types.h" | |
| 13 | |
| 14 namespace autofill { | |
| 15 class PasswordGenerator; | |
| 16 } | |
| 17 | |
| 18 namespace content { | |
| 19 struct PasswordForm; | |
| 20 struct SSLStatus; | |
| 21 } | |
| 22 | |
| 23 namespace gfx { | |
| 24 class Rect; | |
| 25 class RectF; | |
| 26 } | |
| 27 | |
| 28 class AutofillMetrics; | |
| 29 class AutofillPopupDelegate; | |
| 30 class CreditCard; | |
| 31 class FormStructure; | |
| 32 class GURL; | |
| 33 class InfoBarService; | |
| 34 class PersonalDataManager; | |
| 35 class PrefService; | |
| 36 class ProfileSyncServiceBase; | |
| 37 | |
| 38 struct FormData; | |
| 39 | |
| 40 namespace autofill { | |
| 41 | |
| 42 enum DialogType { | |
| 43 // Autofill dialog for the Autocheckout feature. | |
| 44 DIALOG_TYPE_AUTOCHECKOUT, | |
| 45 // Autofill dialog for the requestAutocomplete feature. | |
| 46 DIALOG_TYPE_REQUEST_AUTOCOMPLETE, | |
| 47 }; | |
| 48 | |
| 49 // A delegate interface that needs to be supplied to AutofillManager | |
| 50 // by the embedder. | |
| 51 // | |
| 52 // Each delegate instance is associated with a given context within | |
| 53 // which an AutofillManager is used (e.g. a single tab), so when we | |
| 54 // say "for the delegate" below, we mean "in the execution context the | |
| 55 // delegate is associated with" (e.g. for the tab the AutofillManager is | |
| 56 // attached to). | |
| 57 class AutofillManagerDelegate { | |
| 58 public: | |
| 59 virtual ~AutofillManagerDelegate() {} | |
| 60 | |
| 61 // Gets the PersonalDataManager instance associated with the delegate. | |
| 62 virtual PersonalDataManager* GetPersonalDataManager() = 0; | |
| 63 | |
| 64 // Gets the preferences associated with the delegate. | |
| 65 virtual PrefService* GetPrefs() = 0; | |
| 66 | |
| 67 // Hides the associated request autocomplete dialog (if it exists). | |
| 68 virtual void HideRequestAutocompleteDialog() = 0; | |
| 69 | |
| 70 // Returns true if saving passwords is currently enabled for the | |
| 71 // delegate. | |
| 72 virtual bool IsSavingPasswordsEnabled() const = 0; | |
| 73 | |
| 74 // Returns true if Sync is enabled for the passwords datatype. | |
| 75 virtual bool IsPasswordSyncEnabled() const = 0; | |
| 76 | |
| 77 // Sets a callback that will be called when sync state changes. | |
| 78 // | |
| 79 // Set the callback to an object for which |is_null()| evaluates to | |
| 80 // true to stop receiving notifications | |
| 81 // (e.g. SetSyncStateChangedCallback(base::Closure())). | |
| 82 virtual void SetSyncStateChangedCallback(const base::Closure& callback) = 0; | |
| 83 | |
| 84 // Causes an error explaining that Autocheckout has failed to be displayed to | |
| 85 // the user. | |
| 86 virtual void OnAutocheckoutError() = 0; | |
| 87 | |
| 88 // Causes the Autofill settings UI to be shown. | |
| 89 virtual void ShowAutofillSettings() = 0; | |
| 90 | |
| 91 // Run |save_card_callback| if the credit card should be imported as personal | |
| 92 // data. |metric_logger| can be used to log user actions. | |
| 93 virtual void ConfirmSaveCreditCard( | |
| 94 const AutofillMetrics& metric_logger, | |
| 95 const CreditCard& credit_card, | |
| 96 const base::Closure& save_card_callback) = 0; | |
| 97 | |
| 98 // Causes the password generation bubble UI to be shown using the | |
| 99 // specified form with the given bounds. | |
| 100 virtual void ShowPasswordGenerationBubble( | |
| 101 const gfx::Rect& bounds, | |
| 102 const content::PasswordForm& form, | |
| 103 autofill::PasswordGenerator* generator) = 0; | |
| 104 | |
| 105 // Causes the Autocheckout bubble UI to be displayed. |bounding_box| is the | |
| 106 // anchor for the bubble. |native_view| is the parent view of the bubble. | |
| 107 // |callback| is run if the bubble is accepted. | |
| 108 virtual void ShowAutocheckoutBubble( | |
| 109 const gfx::RectF& bounding_box, | |
| 110 const gfx::NativeView& native_view, | |
| 111 const base::Closure& callback) = 0; | |
| 112 | |
| 113 // Causes the dialog for request autocomplete feature to be shown. | |
| 114 virtual void ShowRequestAutocompleteDialog( | |
| 115 const FormData& form, | |
| 116 const GURL& source_url, | |
| 117 const content::SSLStatus& ssl_status, | |
| 118 const AutofillMetrics& metric_logger, | |
| 119 DialogType dialog_type, | |
| 120 const base::Callback<void(const FormStructure*)>& callback) = 0; | |
| 121 | |
| 122 // Called when the dialog for request autocomplete closes. (So UI code will | |
| 123 // free memory, etc.) | |
| 124 virtual void RequestAutocompleteDialogClosed() = 0; | |
| 125 | |
| 126 // Shows an Autofill popup with the given |values|, |labels|, |icons|, and | |
| 127 // |identifiers| for the element at |element_bounds|. |delegate| will be | |
| 128 // notified of popup events. | |
| 129 virtual void ShowAutofillPopup(const gfx::RectF& element_bounds, | |
| 130 const std::vector<string16>& values, | |
| 131 const std::vector<string16>& labels, | |
| 132 const std::vector<string16>& icons, | |
| 133 const std::vector<int>& identifiers, | |
| 134 AutofillPopupDelegate* delegate) = 0; | |
| 135 | |
| 136 // Hide the Autofill popup if one is currently showing. | |
| 137 virtual void HideAutofillPopup() = 0; | |
| 138 | |
| 139 // Updates the Autocheckout progress bar. |value| must be in [0.0, 1.0]. | |
| 140 virtual void UpdateProgressBar(double value) = 0; | |
| 141 }; | |
| 142 | |
| 143 } // namespace autofill | |
| 144 | |
| 145 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_DELEGATE_H_ | |
| OLD | NEW |