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