Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 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_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ |
| 6 | #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ |
| 7 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 8 | #include <set> |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 9 | #include <vector> |
| 10 | |
| 11 | #include "base/callback.h" |
| 12 | #include "base/memory/scoped_ptr.h" |
| 13 | #include "base/memory/weak_ptr.h" |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 14 | #include "base/strings/string16.h" |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 15 | #include "base/time/time.h" |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 16 | #include "chrome/browser/ui/autofill/account_chooser_model.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 17 | #include "chrome/browser/ui/autofill/autofill_dialog_models.h" |
| 18 | #include "chrome/browser/ui/autofill/autofill_dialog_types.h" |
Ben Murdoch | 3240926 | 2013-08-07 11:04:47 +0100 | [diff] [blame] | 19 | #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 20 | #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" |
| 21 | #include "chrome/browser/ui/autofill/country_combobox_model.h" |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 22 | #include "components/autofill/content/browser/autocheckout_steps.h" |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 23 | #include "components/autofill/content/browser/wallet/wallet_client.h" |
| 24 | #include "components/autofill/content/browser/wallet/wallet_client_delegate.h" |
| 25 | #include "components/autofill/content/browser/wallet/wallet_items.h" |
| 26 | #include "components/autofill/content/browser/wallet/wallet_signin_helper_delegate.h" |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 27 | #include "components/autofill/core/browser/autofill_manager_delegate.h" |
| 28 | #include "components/autofill/core/browser/autofill_metrics.h" |
| 29 | #include "components/autofill/core/browser/autofill_popup_delegate.h" |
| 30 | #include "components/autofill/core/browser/field_types.h" |
| 31 | #include "components/autofill/core/browser/form_structure.h" |
| 32 | #include "components/autofill/core/browser/personal_data_manager.h" |
| 33 | #include "components/autofill/core/browser/personal_data_manager_observer.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 34 | #include "content/public/browser/notification_observer.h" |
| 35 | #include "content/public/browser/notification_registrar.h" |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 36 | #include "content/public/browser/web_contents_observer.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 37 | #include "content/public/common/ssl_status.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 38 | #include "ui/base/models/simple_menu_model.h" |
| 39 | #include "ui/base/ui_base_types.h" |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 40 | #include "url/gurl.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 41 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 42 | class Profile; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 43 | |
| 44 | namespace content { |
| 45 | class WebContents; |
| 46 | } |
| 47 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 48 | namespace user_prefs { |
| 49 | class PrefRegistrySyncable; |
| 50 | } |
| 51 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 52 | namespace autofill { |
| 53 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 54 | class AutofillDataModel; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 55 | class AutofillDialogView; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 56 | class AutofillPopupControllerImpl; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 57 | class DataModelWrapper; |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 58 | class TestableAutofillDialogView; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 59 | |
| 60 | namespace risk { |
| 61 | class Fingerprint; |
| 62 | } |
| 63 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 64 | namespace wallet { |
| 65 | class WalletSigninHelper; |
| 66 | } |
| 67 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 68 | // This class drives the dialog that appears when a site uses the imperative |
| 69 | // autocomplete API to fill out a form. |
Ben Murdoch | 3240926 | 2013-08-07 11:04:47 +0100 | [diff] [blame] | 70 | class AutofillDialogControllerImpl : public AutofillDialogViewDelegate, |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 71 | public AutofillPopupDelegate, |
| 72 | public content::NotificationObserver, |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 73 | public content::WebContentsObserver, |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 74 | public SuggestionsMenuModelDelegate, |
| 75 | public wallet::WalletClientDelegate, |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 76 | public wallet::WalletSigninHelperDelegate, |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 77 | public PersonalDataManagerObserver, |
| 78 | public AccountChooserModelDelegate { |
| 79 | public: |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 80 | virtual ~AutofillDialogControllerImpl(); |
| 81 | |
| 82 | static base::WeakPtr<AutofillDialogControllerImpl> Create( |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 83 | content::WebContents* contents, |
| 84 | const FormData& form_structure, |
| 85 | const GURL& source_url, |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 86 | const DialogType dialog_type, |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 87 | const base::Callback<void(const FormStructure*, |
| 88 | const std::string&)>& callback); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 89 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 90 | static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 91 | |
| 92 | void Show(); |
| 93 | void Hide(); |
| 94 | |
Ben Murdoch | 58e6fbe | 2013-07-26 10:20:38 +0100 | [diff] [blame] | 95 | // Called when the tab hosting this dialog is activated by a user gesture. |
| 96 | // Used to trigger a refresh of the user's Wallet data. |
| 97 | void TabActivated(); |
| 98 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 99 | // Adds a step in the flow to the Autocheckout UI. |
| 100 | void AddAutocheckoutStep(AutocheckoutStepType step_type); |
| 101 | |
| 102 | // Updates the status of a step in the Autocheckout UI. |
| 103 | void UpdateAutocheckoutStep(AutocheckoutStepType step_type, |
| 104 | AutocheckoutStepStatus step_status); |
| 105 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 106 | // Called when there is an error in an active Autocheckout flow. |
| 107 | void OnAutocheckoutError(); |
| 108 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 109 | // Called when an Autocheckout flow completes successfully. |
| 110 | void OnAutocheckoutSuccess(); |
| 111 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 112 | // Returns |view_| as a testable version of itself (if |view_| exists and |
| 113 | // actually implements |AutofillDialogView::GetTestableView()|). |
| 114 | TestableAutofillDialogView* GetTestableView(); |
| 115 | |
Ben Murdoch | 3240926 | 2013-08-07 11:04:47 +0100 | [diff] [blame] | 116 | // AutofillDialogViewDelegate implementation. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 117 | virtual string16 DialogTitle() const OVERRIDE; |
| 118 | virtual string16 AccountChooserText() const OVERRIDE; |
| 119 | virtual string16 SignInLinkText() const OVERRIDE; |
| 120 | virtual string16 EditSuggestionText() const OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 121 | virtual string16 CancelButtonText() const OVERRIDE; |
| 122 | virtual string16 ConfirmButtonText() const OVERRIDE; |
| 123 | virtual string16 SaveLocallyText() const OVERRIDE; |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 124 | virtual string16 SaveLocallyTooltip() const OVERRIDE; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 125 | virtual string16 LegalDocumentsText() OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 126 | virtual DialogSignedInState SignedInState() const OVERRIDE; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 127 | virtual bool ShouldShowSpinner() const OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 128 | virtual bool ShouldOfferToSaveInChrome() const OVERRIDE; |
| 129 | virtual ui::MenuModel* MenuModelForAccountChooser() OVERRIDE; |
| 130 | virtual gfx::Image AccountChooserImage() OVERRIDE; |
Torne (Richard Coles) | b2df76e | 2013-05-13 16:52:09 +0100 | [diff] [blame] | 131 | virtual bool ShouldShowDetailArea() const OVERRIDE; |
| 132 | virtual bool ShouldShowProgressBar() const OVERRIDE; |
Ben Murdoch | 2385ea3 | 2013-08-06 11:01:04 +0100 | [diff] [blame] | 133 | virtual gfx::Image ButtonStripImage() const OVERRIDE; |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 134 | virtual int GetDialogButtons() const OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 135 | virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 136 | virtual DialogOverlayState GetDialogOverlay() const OVERRIDE; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 137 | virtual const std::vector<ui::Range>& LegalDocumentLinks() OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 138 | virtual bool SectionIsActive(DialogSection section) const OVERRIDE; |
| 139 | virtual const DetailInputs& RequestedFieldsForSection(DialogSection section) |
| 140 | const OVERRIDE; |
| 141 | virtual ui::ComboboxModel* ComboboxModelForAutofillType( |
Ben Murdoch | 3240926 | 2013-08-07 11:04:47 +0100 | [diff] [blame] | 142 | ServerFieldType type) OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 143 | virtual ui::MenuModel* MenuModelForSection(DialogSection section) OVERRIDE; |
| 144 | virtual string16 LabelForSection(DialogSection section) const OVERRIDE; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 145 | virtual SuggestionState SuggestionStateForSection( |
| 146 | DialogSection section) OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 147 | virtual void EditClickedForSection(DialogSection section) OVERRIDE; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 148 | virtual void EditCancelledForSection(DialogSection section) OVERRIDE; |
Ben Murdoch | 3240926 | 2013-08-07 11:04:47 +0100 | [diff] [blame] | 149 | virtual gfx::Image IconForField(ServerFieldType type, |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 150 | const string16& user_input) const OVERRIDE; |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 151 | virtual string16 InputValidityMessage(DialogSection section, |
Ben Murdoch | 3240926 | 2013-08-07 11:04:47 +0100 | [diff] [blame] | 152 | ServerFieldType type, |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 153 | const string16& value) OVERRIDE; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 154 | virtual ValidityData InputsAreValid( |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 155 | DialogSection section, |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 156 | const DetailOutputMap& inputs, |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 157 | ValidationType validation_type) OVERRIDE; |
| 158 | virtual void UserEditedOrActivatedInput(DialogSection section, |
| 159 | const DetailInput* input, |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 160 | gfx::NativeView parent_view, |
| 161 | const gfx::Rect& content_bounds, |
| 162 | const string16& field_contents, |
| 163 | bool was_edit) OVERRIDE; |
| 164 | virtual bool HandleKeyPressEventInInput( |
| 165 | const content::NativeWebKeyboardEvent& event) OVERRIDE; |
| 166 | virtual void FocusMoved() OVERRIDE; |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 167 | virtual gfx::Image SplashPageImage() const OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 168 | virtual void ViewClosed() OVERRIDE; |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 169 | virtual std::vector<DialogNotification> CurrentNotifications() OVERRIDE; |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 170 | virtual std::vector<DialogAutocheckoutStep> CurrentAutocheckoutSteps() |
| 171 | const OVERRIDE; |
Torne (Richard Coles) | a93a17c | 2013-05-15 11:34:50 +0100 | [diff] [blame] | 172 | virtual void SignInLinkClicked() OVERRIDE; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 173 | virtual void NotificationCheckboxStateChanged(DialogNotification::Type type, |
| 174 | bool checked) OVERRIDE; |
| 175 | virtual void LegalDocumentLinkClicked(const ui::Range& range) OVERRIDE; |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 176 | virtual void OverlayButtonPressed() OVERRIDE; |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 177 | virtual bool OnCancel() OVERRIDE; |
| 178 | virtual bool OnAccept() OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 179 | virtual Profile* profile() OVERRIDE; |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 180 | virtual content::WebContents* GetWebContents() OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 181 | |
| 182 | // AutofillPopupDelegate implementation. |
| 183 | virtual void OnPopupShown(content::KeyboardListener* listener) OVERRIDE; |
| 184 | virtual void OnPopupHidden(content::KeyboardListener* listener) OVERRIDE; |
| 185 | virtual void DidSelectSuggestion(int identifier) OVERRIDE; |
| 186 | virtual void DidAcceptSuggestion(const string16& value, |
| 187 | int identifier) OVERRIDE; |
| 188 | virtual void RemoveSuggestion(const string16& value, |
| 189 | int identifier) OVERRIDE; |
| 190 | virtual void ClearPreviewedForm() OVERRIDE; |
| 191 | |
| 192 | // content::NotificationObserver implementation. |
| 193 | virtual void Observe(int type, |
| 194 | const content::NotificationSource& source, |
| 195 | const content::NotificationDetails& details) OVERRIDE; |
| 196 | |
| 197 | // SuggestionsMenuModelDelegate implementation. |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 198 | virtual void SuggestionItemSelected(SuggestionsMenuModel* model, |
| 199 | size_t index) OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 200 | |
| 201 | // wallet::WalletClientDelegate implementation. |
| 202 | virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE; |
| 203 | virtual DialogType GetDialogType() const OVERRIDE; |
| 204 | virtual std::string GetRiskData() const OVERRIDE; |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 205 | virtual std::string GetWalletCookieValue() const OVERRIDE; |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 206 | virtual bool IsShippingAddressRequired() const OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 207 | virtual void OnDidAcceptLegalDocuments() OVERRIDE; |
| 208 | virtual void OnDidAuthenticateInstrument(bool success) OVERRIDE; |
| 209 | virtual void OnDidGetFullWallet( |
| 210 | scoped_ptr<wallet::FullWallet> full_wallet) OVERRIDE; |
| 211 | virtual void OnDidGetWalletItems( |
| 212 | scoped_ptr<wallet::WalletItems> wallet_items) OVERRIDE; |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 213 | virtual void OnDidSaveToWallet( |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 214 | const std::string& instrument_id, |
| 215 | const std::string& address_id, |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 216 | const std::vector<wallet::RequiredAction>& required_actions, |
| 217 | const std::vector<wallet::FormFieldError>& form_field_errors) OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 218 | virtual void OnWalletError( |
| 219 | wallet::WalletClient::ErrorType error_type) OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 220 | |
| 221 | // PersonalDataManagerObserver implementation. |
| 222 | virtual void OnPersonalDataChanged() OVERRIDE; |
| 223 | |
| 224 | // AccountChooserModelDelegate implementation. |
| 225 | virtual void AccountChoiceChanged() OVERRIDE; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 226 | virtual void UpdateAccountChooserView() OVERRIDE; |
| 227 | |
| 228 | // wallet::WalletSigninHelperDelegate implementation. |
| 229 | virtual void OnPassiveSigninSuccess(const std::string& username) OVERRIDE; |
| 230 | virtual void OnPassiveSigninFailure( |
| 231 | const GoogleServiceAuthError& error) OVERRIDE; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 232 | virtual void OnUserNameFetchSuccess(const std::string& username) OVERRIDE; |
| 233 | virtual void OnUserNameFetchFailure( |
| 234 | const GoogleServiceAuthError& error) OVERRIDE; |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 235 | virtual void OnDidFetchWalletCookieValue( |
| 236 | const std::string& cookie_value) OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 237 | |
| 238 | DialogType dialog_type() const { return dialog_type_; } |
| 239 | |
| 240 | protected: |
| 241 | // Exposed for testing. |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 242 | AutofillDialogControllerImpl( |
| 243 | content::WebContents* contents, |
| 244 | const FormData& form_structure, |
| 245 | const GURL& source_url, |
| 246 | const DialogType dialog_type, |
| 247 | const base::Callback<void(const FormStructure*, |
| 248 | const std::string&)>& callback); |
| 249 | |
| 250 | // Exposed for testing. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 251 | AutofillDialogView* view() { return view_.get(); } |
| 252 | virtual AutofillDialogView* CreateView(); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 253 | const DetailInput* input_showing_popup() const { |
| 254 | return input_showing_popup_; |
| 255 | } |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 256 | |
| 257 | // Returns the PersonalDataManager for |profile_|. |
| 258 | virtual PersonalDataManager* GetManager(); |
| 259 | |
| 260 | // Returns the WalletClient* this class uses to talk to Online Wallet. Exposed |
| 261 | // for testing. |
| 262 | virtual wallet::WalletClient* GetWalletClient(); |
| 263 | |
| 264 | // Call to disable communication to Online Wallet for this dialog. |
| 265 | // Exposed for testing. |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 266 | void DisableWallet(wallet::WalletClient::ErrorType error_type); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 267 | |
| 268 | // Returns whether Wallet is the current data source. Exposed for testing. |
| 269 | virtual bool IsPayingWithWallet() const; |
| 270 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 271 | // Asks risk module to asynchronously load fingerprint data. Data will be |
| 272 | // returned via |OnDidLoadRiskFingerprintData()|. Exposed for testing. |
| 273 | virtual void LoadRiskFingerprintData(); |
| 274 | virtual void OnDidLoadRiskFingerprintData( |
| 275 | scoped_ptr<risk::Fingerprint> fingerprint); |
| 276 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 277 | // Opens the given URL in a new foreground tab. |
| 278 | virtual void OpenTabWithUrl(const GURL& url); |
| 279 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 280 | // Whether |section| was sent into edit mode based on existing data. This |
| 281 | // happens when a user clicks "Edit" or a suggestion is invalid. |
| 282 | virtual bool IsEditingExistingData(DialogSection section) const; |
| 283 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 284 | // Whether the user has chosen to enter all new data in |section|. This |
| 285 | // happens via choosing "Add a new X..." from a section's suggestion menu. |
| 286 | bool IsManuallyEditingSection(DialogSection section) const; |
| 287 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 288 | // Should be called on the Wallet sign-in error. |
| 289 | virtual void OnWalletSigninError(); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 290 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 291 | // Whether the information input in this dialog will be securely transmitted |
| 292 | // to the requesting site. |
| 293 | virtual bool TransmissionWillBeSecure() const; |
| 294 | |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 295 | AutocheckoutState autocheckout_state() const { return autocheckout_state_; } |
| 296 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 297 | private: |
| 298 | // Whether or not the current request wants credit info back. |
| 299 | bool RequestingCreditCardInfo() const; |
| 300 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 301 | // Initializes or updates |suggested_email_| et al. |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 302 | void SuggestionsUpdated(); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 303 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 304 | // Whether the user's wallet items have at least one address and instrument. |
| 305 | bool HasCompleteWallet() const; |
| 306 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 307 | // Starts fetching the wallet items from Online Wallet. |
| 308 | void GetWalletItems(); |
| 309 | |
Torne (Richard Coles) | a93a17c | 2013-05-15 11:34:50 +0100 | [diff] [blame] | 310 | // Stop showing sign in flow. |
| 311 | void HideSignIn(); |
| 312 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 313 | // Handles the SignedInState() on Wallet or sign-in state update. |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 314 | // Triggers the user name fetch and passive sign-in. |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 315 | void SignedInStateUpdated(); |
| 316 | |
| 317 | // Refreshes the model on Wallet or sign-in state update. |
| 318 | void OnWalletOrSigninUpdate(); |
| 319 | |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 320 | // Called when a Save or Update call to Wallet has validation errors. |
| 321 | void OnWalletFormFieldError( |
| 322 | const std::vector<wallet::FormFieldError>& form_field_errors); |
| 323 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 324 | // Calculates |legal_documents_text_| and |legal_document_link_ranges_| if |
| 325 | // they have not already been calculated. |
| 326 | void EnsureLegalDocumentsText(); |
| 327 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 328 | // Clears previously entered manual input and removes |section| from |
| 329 | // |section_editing_state_|. Does not update the view. |
| 330 | void ResetSectionInput(DialogSection section); |
| 331 | |
| 332 | // Force |section| into edit mode if the current suggestion is invalid. |
| 333 | void ShowEditUiIfBadSuggestion(DialogSection section); |
| 334 | |
| 335 | // Whether the |value| of |input| should be preserved on account change. |
| 336 | bool InputWasEdited(const DetailInput& input, |
| 337 | const base::string16& value); |
| 338 | |
| 339 | // Takes a snapshot of the newly inputted user data in |view_| (if it exists). |
| 340 | DetailOutputMap TakeUserInputSnapshot(); |
| 341 | |
| 342 | // Fills the detail inputs from a previously taken user input snapshot. Does |
| 343 | // not update the view. |
| 344 | void RestoreUserInputFromSnapshot(const DetailOutputMap& snapshot); |
| 345 | |
| 346 | // Tells the view to update |section|. |
| 347 | void UpdateSection(DialogSection section); |
| 348 | |
| 349 | // Tells |view_| to update the validity status of its detail inputs (if |
| 350 | // |view_| is non-null). Currently this is used solely for highlighting |
| 351 | // invalid suggestions, so if no sections are based on existing data, |
| 352 | // |view_->UpdateForErrors()| is not called. |
| 353 | void UpdateForErrors(); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 354 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 355 | // Creates a DataModelWrapper item for the item that's checked in the |
| 356 | // suggestion model for |section|. This may represent Autofill |
| 357 | // data or Wallet data, depending on whether Wallet is currently enabled. |
| 358 | scoped_ptr<DataModelWrapper> CreateWrapper(DialogSection section); |
| 359 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 360 | // Helper to return the current Wallet instrument or address. If the dialog |
| 361 | // isn't using Wallet or the user is adding a new instrument or address, NULL |
| 362 | // will be returned. |
| 363 | const wallet::WalletItems::MaskedInstrument* ActiveInstrument() const; |
| 364 | const wallet::Address* ActiveShippingAddress() const; |
| 365 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 366 | // Fills in |section|-related fields in |output_| according to the state of |
| 367 | // |view_|. |
| 368 | void FillOutputForSection(DialogSection section); |
| 369 | // As above, but uses |compare| to determine whether a DetailInput matches |
| 370 | // a field. Saves any new Autofill data to the PersonalDataManager. |
| 371 | void FillOutputForSectionWithComparator(DialogSection section, |
| 372 | const InputFieldComparator& compare); |
| 373 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 374 | // Returns whether |form_structure|_| has any fields that match the fieldset |
| 375 | // represented by |section|. |
| 376 | bool FormStructureCaresAboutSection(DialogSection section) const; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 377 | |
| 378 | // Sets the CVC result on |form_structure_| to the value in |cvc|. |
| 379 | void SetCvcResult(const string16& cvc); |
| 380 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 381 | // Gets the value for |type| in |section|, whether it comes from manual user |
| 382 | // input or the active suggestion. |
| 383 | string16 GetValueFromSection(DialogSection section, |
Ben Murdoch | 3240926 | 2013-08-07 11:04:47 +0100 | [diff] [blame] | 384 | ServerFieldType type); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 385 | |
| 386 | // Saves the data in |profile| to the personal data manager. This may add |
| 387 | // a new profile or tack onto an existing profile. |
| 388 | void SaveProfileGleanedFromSection(const AutofillProfile& profile, |
| 389 | DialogSection section); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 390 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 391 | // Gets the SuggestionsMenuModel for |section|. |
| 392 | SuggestionsMenuModel* SuggestionsMenuModelForSection(DialogSection section); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 393 | const SuggestionsMenuModel* SuggestionsMenuModelForSection( |
| 394 | DialogSection section) const; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 395 | // And the reverse. |
| 396 | DialogSection SectionForSuggestionsMenuModel( |
| 397 | const SuggestionsMenuModel& model); |
| 398 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 399 | // Suggested text and icons for sections. Suggestion text is used to show an |
| 400 | // abidged overview of the currently used suggestion. Extra text is used when |
| 401 | // part of a section is suggested but part must be manually input (e.g. during |
| 402 | // a CVC challenge or when using Autofill's CC section [never stores CVC]). |
| 403 | string16 SuggestionTextForSection(DialogSection section); |
| 404 | gfx::Font::FontStyle SuggestionTextStyleForSection(DialogSection section) |
| 405 | const; |
| 406 | string16 RequiredActionTextForSection(DialogSection section) const; |
| 407 | gfx::Image SuggestionIconForSection(DialogSection section); |
| 408 | string16 ExtraSuggestionTextForSection(DialogSection section) const; |
| 409 | gfx::Image ExtraSuggestionIconForSection(DialogSection section) const; |
| 410 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 411 | // Loads profiles that can suggest data for |type|. |field_contents| is the |
| 412 | // part the user has already typed. |inputs| is the rest of section. |
| 413 | // Identifying info is loaded into the last three outparams as well as |
| 414 | // |popup_guids_|. |
| 415 | void GetProfileSuggestions( |
Ben Murdoch | 3240926 | 2013-08-07 11:04:47 +0100 | [diff] [blame] | 416 | ServerFieldType type, |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 417 | const string16& field_contents, |
| 418 | const DetailInputs& inputs, |
| 419 | std::vector<string16>* popup_values, |
| 420 | std::vector<string16>* popup_labels, |
| 421 | std::vector<string16>* popup_icons); |
| 422 | |
| 423 | // Like RequestedFieldsForSection, but returns a pointer. |
| 424 | DetailInputs* MutableRequestedFieldsForSection(DialogSection section); |
| 425 | |
| 426 | // Hides |popup_controller_|'s popup view, if it exists. |
| 427 | void HidePopup(); |
| 428 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 429 | // Set whether the currently editing |section| was originally based on |
| 430 | // existing Wallet or Autofill data. |
| 431 | void SetEditingExistingData(DialogSection section, bool editing); |
| 432 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 433 | // Whether the user has chosen to enter all new data in at least one section. |
| 434 | bool IsManuallyEditingAnySection() const; |
| 435 | |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 436 | // Returns validity message for a given credit card number. |
| 437 | base::string16 CreditCardNumberValidityMessage( |
| 438 | const base::string16& number) const; |
| 439 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 440 | // Whether a particular DetailInput in |section| should be edited or not. |
| 441 | bool InputIsEditable(const DetailInput& input, DialogSection section) const; |
Torne (Richard Coles) | a93a17c | 2013-05-15 11:34:50 +0100 | [diff] [blame] | 442 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 443 | // Whether all of the input fields currently showing in the dialog have valid |
| 444 | // contents. |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 445 | bool AllSectionsAreValid(); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 446 | |
| 447 | // Whether all of the input fields currently showing in the given |section| of |
| 448 | // the dialog have valid contents. |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 449 | bool SectionIsValid(DialogSection section); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 450 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 451 | // Whether the currently active credit card expiration date is valid. |
| 452 | bool IsCreditCardExpirationValid(const base::string16& year, |
| 453 | const base::string16& month) const; |
| 454 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 455 | // Returns true if |key| refers to a suggestion, as opposed to some control |
| 456 | // menu item. |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 457 | bool IsASuggestionItemKey(const std::string& key) const; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 458 | |
| 459 | // Whether the billing section should be used to fill in the shipping details. |
| 460 | bool ShouldUseBillingForShipping(); |
| 461 | |
| 462 | // Whether the user wishes to save information locally to Autofill. |
| 463 | bool ShouldSaveDetailsLocally(); |
| 464 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 465 | // Change whether the controller is currently submitting details to Autofill |
| 466 | // or Online Wallet (|is_submitting_|) and update the view. |
| 467 | void SetIsSubmitting(bool submitting); |
| 468 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 469 | // Whether the user has accepted all the current legal documents' terms. |
| 470 | bool AreLegalDocumentsCurrent() const; |
| 471 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 472 | // Accepts any pending legal documents now that the user has pressed Submit. |
| 473 | void AcceptLegalDocuments(); |
| 474 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 475 | // Start the submit proccess to interact with Online Wallet (might do various |
| 476 | // things like accept documents, save details, update details, respond to |
| 477 | // required actions, etc.). |
| 478 | void SubmitWithWallet(); |
| 479 | |
Torne (Richard Coles) | a93a17c | 2013-05-15 11:34:50 +0100 | [diff] [blame] | 480 | // Creates an instrument based on |views_|' contents. |
| 481 | scoped_ptr<wallet::Instrument> CreateTransientInstrument(); |
| 482 | |
Torne (Richard Coles) | a93a17c | 2013-05-15 11:34:50 +0100 | [diff] [blame] | 483 | // Creates an address based on the contents of |view_|. |
| 484 | scoped_ptr<wallet::Address> CreateTransientAddress(); |
| 485 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 486 | // Gets a full wallet from Online Wallet so the user can purchase something. |
| 487 | // This information is decoded to reveal a fronting (proxy) card. |
| 488 | void GetFullWallet(); |
| 489 | |
Torne (Richard Coles) | a93a17c | 2013-05-15 11:34:50 +0100 | [diff] [blame] | 490 | // Updates the state of the controller and |view_| based on any required |
| 491 | // actions returned by Save or Update calls to Wallet. |
| 492 | void HandleSaveOrUpdateRequiredActions( |
| 493 | const std::vector<wallet::RequiredAction>& required_actions); |
| 494 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 495 | // Whether submission is currently waiting for |action| to be handled. |
| 496 | bool IsSubmitPausedOn(wallet::RequiredAction action) const; |
| 497 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 498 | // Called when there's nothing left to accept, update, save, or authenticate |
| 499 | // in order to fill |form_structure_| and pass data back to the invoking page. |
| 500 | void FinishSubmit(); |
| 501 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 502 | // Writes to prefs the choice of AutofillDataModel for |section|. |
| 503 | void PersistAutofillChoice(DialogSection section, |
| 504 | const std::string& guid, |
| 505 | int variant); |
| 506 | |
| 507 | // Sets the outparams to the default AutofillDataModel for |section| (which is |
| 508 | // the first one in the menu that is a suggestion item). |
| 509 | void GetDefaultAutofillChoice(DialogSection section, |
| 510 | std::string* guid, |
| 511 | int* variant); |
| 512 | |
| 513 | // Reads from prefs the choice of AutofillDataModel for |section|. Returns |
| 514 | // whether there was a setting to read. |
| 515 | bool GetAutofillChoice(DialogSection section, |
| 516 | std::string* guid, |
| 517 | int* variant); |
| 518 | |
| 519 | // Calculates which AutofillDataModel variant |model| is referring to. |
| 520 | size_t GetSelectedVariantForModel(const SuggestionsMenuModel& model); |
| 521 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 522 | // Logs metrics when the dialog is submitted. |
| 523 | void LogOnFinishSubmitMetrics(); |
| 524 | |
| 525 | // Logs metrics when the dialog is canceled. |
| 526 | void LogOnCancelMetrics(); |
| 527 | |
| 528 | // Logs metrics when the edit ui is shown for the given |section|. |
| 529 | void LogEditUiShownMetric(DialogSection section); |
| 530 | |
| 531 | // Logs metrics when a suggestion item from the given |model| is selected. |
| 532 | void LogSuggestionItemSelectedMetric(const SuggestionsMenuModel& model); |
| 533 | |
| 534 | // Logs the time elapsed from when the dialog was shown to when the user could |
| 535 | // interact with it. |
| 536 | void LogDialogLatencyToShow(); |
| 537 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 538 | // Sets the state of the autocheckout flow. |
| 539 | void SetAutocheckoutState(AutocheckoutState autocheckout_state); |
| 540 | |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 541 | // Obscures the web contents. |
| 542 | void DeemphasizeRenderView(); |
| 543 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 544 | // Returns the metric corresponding to the user's initial state when |
| 545 | // interacting with this dialog. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 546 | AutofillMetrics::DialogInitialUserStateMetric GetInitialUserState() const; |
| 547 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 548 | // Shows an educational bubble if a new credit card was saved or the first few |
| 549 | // times an Online Wallet fronting card was generated. |
| 550 | void MaybeShowCreditCardBubble(); |
| 551 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 552 | // The |profile| for |contents_|. |
| 553 | Profile* const profile_; |
| 554 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 555 | // For logging UMA metrics. |
| 556 | const AutofillMetrics metric_logger_; |
| 557 | base::Time dialog_shown_timestamp_; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 558 | AutofillMetrics::DialogInitialUserStateMetric initial_user_state_; |
| 559 | |
Torne (Richard Coles) | b2df76e | 2013-05-13 16:52:09 +0100 | [diff] [blame] | 560 | // The time that Autocheckout started running. Reset on error. While this is |
| 561 | // a valid time, |AutocheckoutIsRunning()| will return true. |
| 562 | base::Time autocheckout_started_timestamp_; |
| 563 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 564 | // Whether this is an Autocheckout or a requestAutocomplete dialog. |
| 565 | const DialogType dialog_type_; |
| 566 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 567 | FormStructure form_structure_; |
| 568 | |
| 569 | // Whether the URL visible to the user when this dialog was requested to be |
| 570 | // invoked is the same as |source_url_|. |
| 571 | bool invoked_from_same_origin_; |
| 572 | |
| 573 | // The URL of the invoking site. |
| 574 | GURL source_url_; |
| 575 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 576 | // The callback via which we return the collected data and, if Online Wallet |
| 577 | // was used, the Google transaction id. |
| 578 | base::Callback<void(const FormStructure*, const std::string&)> callback_; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 579 | |
| 580 | // The AccountChooserModel acts as the MenuModel for the account chooser, |
| 581 | // and also tracks which data source the dialog is using. |
| 582 | AccountChooserModel account_chooser_model_; |
| 583 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 584 | // The sign-in helper to fetch the user info and perform passive sign-in. |
| 585 | // The helper is set only during fetch/sign-in, and NULL otherwise. |
| 586 | scoped_ptr<wallet::WalletSigninHelper> signin_helper_; |
| 587 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 588 | // A client to talk to the Online Wallet API. |
| 589 | wallet::WalletClient wallet_client_; |
| 590 | |
| 591 | // Recently received items retrieved via |wallet_client_|. |
| 592 | scoped_ptr<wallet::WalletItems> wallet_items_; |
| 593 | scoped_ptr<wallet::FullWallet> full_wallet_; |
| 594 | |
Ben Murdoch | 58e6fbe | 2013-07-26 10:20:38 +0100 | [diff] [blame] | 595 | // The last active instrument and shipping address object ids. These |
| 596 | // variables are only set (i.e. non-empty) when the Wallet items are being |
| 597 | // re-fetched. |
| 598 | std::string previously_selected_instrument_id_; |
| 599 | std::string previously_selected_shipping_address_id_; |
| 600 | |
| 601 | // When the Wallet items were last fetched. |
| 602 | base::TimeTicks last_wallet_items_fetch_timestamp_; |
| 603 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 604 | // Local machine signals to pass along on each request to trigger (or |
| 605 | // discourage) risk challenges; sent if the user is up to date on legal docs. |
| 606 | std::string risk_data_; |
| 607 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 608 | // The text to display when the user is accepting new terms of service, etc. |
| 609 | string16 legal_documents_text_; |
| 610 | // The ranges within |legal_documents_text_| to linkify. |
| 611 | std::vector<ui::Range> legal_document_link_ranges_; |
| 612 | |
Torne (Richard Coles) | a93a17c | 2013-05-15 11:34:50 +0100 | [diff] [blame] | 613 | // The instrument and address IDs from the Online Wallet server to be used |
| 614 | // when getting a full wallet. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 615 | std::string active_instrument_id_; |
| 616 | std::string active_address_id_; |
| 617 | |
| 618 | // The fields for billing and shipping which the page has actually requested. |
| 619 | DetailInputs requested_email_fields_; |
| 620 | DetailInputs requested_cc_fields_; |
| 621 | DetailInputs requested_billing_fields_; |
| 622 | DetailInputs requested_cc_billing_fields_; |
| 623 | DetailInputs requested_shipping_fields_; |
| 624 | |
| 625 | // Models for the credit card expiration inputs. |
| 626 | MonthComboboxModel cc_exp_month_combobox_model_; |
| 627 | YearComboboxModel cc_exp_year_combobox_model_; |
| 628 | |
| 629 | // Model for the country input. |
| 630 | CountryComboboxModel country_combobox_model_; |
| 631 | |
| 632 | // Models for the suggestion views. |
| 633 | SuggestionsMenuModel suggested_email_; |
| 634 | SuggestionsMenuModel suggested_cc_; |
| 635 | SuggestionsMenuModel suggested_billing_; |
| 636 | SuggestionsMenuModel suggested_cc_billing_; |
| 637 | SuggestionsMenuModel suggested_shipping_; |
| 638 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 639 | // |DialogSection|s that are in edit mode that are based on existing data. |
| 640 | std::set<DialogSection> section_editing_state_; |
| 641 | |
| 642 | // Whether |form_structure_| has asked for any details that would indicate |
| 643 | // we should show a shipping section. |
| 644 | bool cares_about_shipping_; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 645 | |
| 646 | // The GUIDs for the currently showing unverified profiles popup. |
| 647 | std::vector<PersonalDataManager::GUIDPair> popup_guids_; |
| 648 | |
| 649 | // The controller for the currently showing popup (which helps users when |
| 650 | // they're manually filling the dialog). |
| 651 | base::WeakPtr<AutofillPopupControllerImpl> popup_controller_; |
| 652 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 653 | // The input for which |popup_controller_| is currently showing a popup |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 654 | // (if any). |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 655 | const DetailInput* input_showing_popup_; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 656 | |
| 657 | scoped_ptr<AutofillDialogView> view_; |
| 658 | |
| 659 | // A NotificationRegistrar for tracking the completion of sign-in. |
Torne (Richard Coles) | a93a17c | 2013-05-15 11:34:50 +0100 | [diff] [blame] | 660 | content::NotificationRegistrar signin_registrar_; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 661 | |
| 662 | base::WeakPtrFactory<AutofillDialogControllerImpl> weak_ptr_factory_; |
| 663 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 664 | // Whether the wallet promos should be shown in the notification area. Based |
| 665 | // on whether the user has paid with Wallet or has signed into this dialog. |
| 666 | bool should_show_wallet_promo_; |
| 667 | bool has_shown_wallet_usage_confirmation_; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 668 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 669 | // Whether a user accepted legal documents while this dialog is running. |
| 670 | bool has_accepted_legal_documents_; |
| 671 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 672 | // True after the user first accepts the dialog and presses "Submit". May |
| 673 | // continue to be true while processing required actions. |
| 674 | bool is_submitting_; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 675 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 676 | // True if the last call to |GetFullWallet()| returned a |
| 677 | // CHOOSE_ANOTHER_INSTRUMENT_OR_ADDRESS required action, indicating that the |
| 678 | // selected instrument or address had become invalid since it was originally |
| 679 | // returned in |GetWalletItems()|. |
| 680 | bool choose_another_instrument_or_address_; |
| 681 | |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 682 | // Whether or not the server side validation errors returned by Wallet were |
| 683 | // recoverable. |
| 684 | bool wallet_server_validation_recoverable_; |
| 685 | |
Ben Murdoch | bbcdd45 | 2013-07-25 10:06:34 +0100 | [diff] [blame] | 686 | // Whether |callback_| was Run() with a filled |form_structure_|. |
| 687 | bool data_was_passed_back_; |
| 688 | |
Ben Murdoch | 3240926 | 2013-08-07 11:04:47 +0100 | [diff] [blame] | 689 | typedef std::map<ServerFieldType, |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 690 | std::pair<base::string16, base::string16> > TypeErrorInputMap; |
| 691 | typedef std::map<DialogSection, TypeErrorInputMap> WalletValidationErrors; |
| 692 | // Wallet validation errors. section->type->(error_msg, input_value). |
| 693 | WalletValidationErrors wallet_errors_; |
| 694 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 695 | // The current state of the Autocheckout flow. |
| 696 | AutocheckoutState autocheckout_state_; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 697 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 698 | // Whether the latency to display to the UI was logged to UMA yet. |
| 699 | bool was_ui_latency_logged_; |
| 700 | |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 701 | // Whether or not the render view has been deemphasized. |
| 702 | bool deemphasized_render_view_; |
| 703 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 704 | // State of steps in the current Autocheckout flow, or empty if not an |
| 705 | // Autocheckout use case. |
| 706 | std::vector<DialogAutocheckoutStep> steps_; |
| 707 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 708 | // The Google Wallet cookie value, set as an authorization header on requests |
| 709 | // to Wallet. |
| 710 | std::string wallet_cookie_value_; |
| 711 | |
| 712 | // Populated if the user chose to save a newly inputted credit card. Used to |
| 713 | // show a bubble as the dialog closes to confirm a user's new card info was |
| 714 | // saved. Never populated while incognito (as nothing's actually saved). |
| 715 | scoped_ptr<CreditCard> newly_saved_card_; |
| 716 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 717 | DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl); |
| 718 | }; |
| 719 | |
| 720 | } // namespace autofill |
| 721 | |
| 722 | #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ |