autofill_dialog_controller_impl.h revision d0247b1b59f9c528cb6df88b4f2b9afaf80d181e
13839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o// Copyright (c) 2012 The Chromium Authors. All rights reserved.
23839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o// Use of this source code is governed by a BSD-style license that can be
33839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o// found in the LICENSE file.
419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o
519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_
619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_
719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o
819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#include <set>
919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#include <vector>
103839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
113839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#include "base/callback.h"
123839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#include "base/memory/scoped_ptr.h"
133839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#include "base/memory/weak_ptr.h"
143839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#include "base/strings/string16.h"
153839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#include "base/time/time.h"
163839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#include "chrome/browser/ui/autofill/account_chooser_model.h"
173839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#include "chrome/browser/ui/autofill/autofill_dialog_controller.h"
18a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o#include "chrome/browser/ui/autofill/autofill_dialog_models.h"
193839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#include "chrome/browser/ui/autofill/autofill_dialog_types.h"
203839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h"
213839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h"
223839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#include "chrome/browser/ui/autofill/country_combobox_model.h"
232740156bd12747389eaf745529653b26a3a9d73dTheodore Ts'o#include "components/autofill/content/browser/wallet/wallet_client.h"
242740156bd12747389eaf745529653b26a3a9d73dTheodore Ts'o#include "components/autofill/content/browser/wallet/wallet_client_delegate.h"
252740156bd12747389eaf745529653b26a3a9d73dTheodore Ts'o#include "components/autofill/content/browser/wallet/wallet_items.h"
26a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o#include "components/autofill/content/browser/wallet/wallet_signin_helper_delegate.h"
273839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#include "components/autofill/core/browser/autofill_manager_delegate.h"
28373b8337c7b6c6243810be250083fa4773891e92Theodore Ts'o#include "components/autofill/core/browser/autofill_metrics.h"
29373b8337c7b6c6243810be250083fa4773891e92Theodore Ts'o#include "components/autofill/core/browser/autofill_popup_delegate.h"
30373b8337c7b6c6243810be250083fa4773891e92Theodore Ts'o#include "components/autofill/core/browser/field_types.h"
31a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o#include "components/autofill/core/browser/form_structure.h"
32a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o#include "components/autofill/core/browser/personal_data_manager.h"
333839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#include "components/autofill/core/browser/personal_data_manager_observer.h"
34a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o#include "content/public/browser/notification_observer.h"
35a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o#include "content/public/browser/notification_registrar.h"
363839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#include "content/public/browser/web_contents_observer.h"
37a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o#include "content/public/common/ssl_status.h"
38a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o#include "ui/base/models/simple_menu_model.h"
39a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o#include "ui/base/ui_base_types.h"
40a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o#include "ui/gfx/animation/animation_delegate.h"
41a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o#include "ui/gfx/animation/linear_animation.h"
423839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#include "url/gurl.h"
43a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o
443839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oclass Profile;
45f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o
46f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'onamespace content {
4754c637d4d29af3e6365779f8b12976abe95a4753Theodore Ts'oclass WebContents;
483839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o}
491e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o
50896938d57e7091e7a032674dfeeb91f2a17fd78bTheodore Ts'onamespace user_prefs {
513839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oclass PrefRegistrySyncable;
5263985320384bf143eaac9857af424800d9867a1aTheodore Ts'o}
533839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
54d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'onamespace autofill {
553839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
563839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oclass AutofillDataModel;
573839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oclass AutofillDialogView;
586733c2fd0046c525203034f58fc0a8c69fdf480bTheodore Ts'oclass AutofillPopupControllerImpl;
591e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'oclass DataModelWrapper;
601e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'oclass TestableAutofillDialogView;
611e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o
623839e65723771b85975f4263102dd3ceec4523cTheodore Ts'onamespace risk {
63f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'oclass Fingerprint;
643839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o}
653839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
66d48755e97f7d4cb06092921bff0d3681d30a8acaTheodore Ts'onamespace wallet {
673839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oclass WalletSigninHelper;
683839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o}
6916ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
7016ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o// This class drives the dialog that appears when a site uses the imperative
7116ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o// autocomplete API to fill out a form.
7216ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'oclass AutofillDialogControllerImpl : public AutofillDialogViewDelegate,
7316ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o                                     public AutofillDialogController,
7416ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o                                     public AutofillPopupDelegate,
7516ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o                                     public content::NotificationObserver,
7616ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o                                     public content::WebContentsObserver,
7716ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o                                     public SuggestionsMenuModelDelegate,
7816ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o                                     public wallet::WalletClientDelegate,
793839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o                                     public wallet::WalletSigninHelperDelegate,
803839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o                                     public PersonalDataManagerObserver,
8116ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o                                     public AccountChooserModelDelegate,
8216ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o                                     public gfx::AnimationDelegate {
8316ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o public:
8416ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  virtual ~AutofillDialogControllerImpl();
8516ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
863839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  static base::WeakPtr<AutofillDialogControllerImpl> Create(
8763985320384bf143eaac9857af424800d9867a1aTheodore Ts'o      content::WebContents* contents,
883839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o      const FormData& form_structure,
89d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o      const GURL& source_url,
90dc2ec525f5619bf478d2aae1b406fca2ff4b0d21Theodore Ts'o      const base::Callback<void(const FormStructure*)>& callback);
915515e6b47de9ff941164a546dd9a74e9c6da3367Theodore Ts'o
925515e6b47de9ff941164a546dd9a74e9c6da3367Theodore Ts'o  static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
9318160d26c0fcf8dbe990977c0231ebbc79fc9508Theodore Ts'o
94b10fd5e84ec7ea0e843b09e7c44784f072b8fdb7Theodore Ts'o  // AutofillDialogController implementation.
953839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void Show() OVERRIDE;
963839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void Hide() OVERRIDE;
973839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void TabActivated() OVERRIDE;
983839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
996733c2fd0046c525203034f58fc0a8c69fdf480bTheodore Ts'o  // Returns |view_| as a testable version of itself (if |view_| exists and
1003839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // actually implements |AutofillDialogView::GetTestableView()|).
1013839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  TestableAutofillDialogView* GetTestableView();
1023839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
1033839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // AutofillDialogViewDelegate implementation.
1043839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual string16 DialogTitle() const OVERRIDE;
1053839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual string16 AccountChooserText() const OVERRIDE;
1063839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual string16 SignInLinkText() const OVERRIDE;
1073839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual string16 SpinnerText() const OVERRIDE;
1083839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual string16 EditSuggestionText() const OVERRIDE;
1093839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual string16 CancelButtonText() const OVERRIDE;
1103839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual string16 ConfirmButtonText() const OVERRIDE;
1116733c2fd0046c525203034f58fc0a8c69fdf480bTheodore Ts'o  virtual string16 SaveLocallyText() const OVERRIDE;
1121dde43f0c1176f61dd0bf91aff265ce8cd1c5fd6Theodore Ts'o  virtual string16 SaveLocallyTooltip() const OVERRIDE;
1131dde43f0c1176f61dd0bf91aff265ce8cd1c5fd6Theodore Ts'o  virtual string16 LegalDocumentsText() OVERRIDE;
1141dde43f0c1176f61dd0bf91aff265ce8cd1c5fd6Theodore Ts'o  virtual bool ShouldDisableSignInLink() const OVERRIDE;
1151dde43f0c1176f61dd0bf91aff265ce8cd1c5fd6Theodore Ts'o  virtual bool ShouldShowSpinner() const OVERRIDE;
1161dde43f0c1176f61dd0bf91aff265ce8cd1c5fd6Theodore Ts'o  virtual bool ShouldOfferToSaveInChrome() const OVERRIDE;
1171dde43f0c1176f61dd0bf91aff265ce8cd1c5fd6Theodore Ts'o  virtual bool ShouldSaveInChrome() const OVERRIDE;
1181dde43f0c1176f61dd0bf91aff265ce8cd1c5fd6Theodore Ts'o  virtual ui::MenuModel* MenuModelForAccountChooser() OVERRIDE;
1191dde43f0c1176f61dd0bf91aff265ce8cd1c5fd6Theodore Ts'o  virtual gfx::Image AccountChooserImage() OVERRIDE;
1203839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual gfx::Image ButtonStripImage() const OVERRIDE;
12150787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual int GetDialogButtons() const OVERRIDE;
12250787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE;
1232740156bd12747389eaf745529653b26a3a9d73dTheodore Ts'o  virtual DialogOverlayState GetDialogOverlay() OVERRIDE;
1242740156bd12747389eaf745529653b26a3a9d73dTheodore Ts'o  virtual const std::vector<gfx::Range>& LegalDocumentLinks() OVERRIDE;
1252740156bd12747389eaf745529653b26a3a9d73dTheodore Ts'o  virtual bool SectionIsActive(DialogSection section) const OVERRIDE;
1262740156bd12747389eaf745529653b26a3a9d73dTheodore Ts'o  virtual const DetailInputs& RequestedFieldsForSection(DialogSection section)
12750787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o      const OVERRIDE;
12850787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual ui::ComboboxModel* ComboboxModelForAutofillType(
12950787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o      ServerFieldType type) OVERRIDE;
1304a6005666e1f62442cb55fabd946f454605e340eTheodore Ts'o  virtual ui::MenuModel* MenuModelForSection(DialogSection section) OVERRIDE;
1314a6005666e1f62442cb55fabd946f454605e340eTheodore Ts'o  virtual string16 LabelForSection(DialogSection section) const OVERRIDE;
1324a6005666e1f62442cb55fabd946f454605e340eTheodore Ts'o  virtual SuggestionState SuggestionStateForSection(
1334a6005666e1f62442cb55fabd946f454605e340eTheodore Ts'o      DialogSection section) OVERRIDE;
13450787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  // TODO(groby): Remove this deprecated method after Mac starts using
13550787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  // IconsForFields. http://crbug.com/292876
13650787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual gfx::Image IconForField(ServerFieldType type,
13750787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o                                  const string16& user_input) const OVERRIDE;
138dc2ec525f5619bf478d2aae1b406fca2ff4b0d21Theodore Ts'o  virtual FieldIconMap IconsForFields(const FieldValueMap& user_inputs)
13950787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o      const OVERRIDE;
14044c09c0454925e6e7756e4dc51aac6acbf5020aeTheodore Ts'o  virtual bool FieldControlsIcons(ServerFieldType type) const OVERRIDE;
14144c09c0454925e6e7756e4dc51aac6acbf5020aeTheodore Ts'o  virtual string16 InputValidityMessage(DialogSection section,
14250787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o                                        ServerFieldType type,
14350787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o                                        const string16& value) OVERRIDE;
14450787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual ValidityData InputsAreValid(
145ef9abe5f2529b3a42b46bf64c5f4232f86e7b390Theodore Ts'o      DialogSection section,
14650787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o      const DetailOutputMap& inputs,
14750787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o      ValidationType validation_type) OVERRIDE;
14850787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual void UserEditedOrActivatedInput(DialogSection section,
14950787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o                                          const DetailInput* input,
15050787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o                                          gfx::NativeView parent_view,
15150787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o                                          const gfx::Rect& content_bounds,
1529094f28440b6c504a80d97aeea2dab543f97978bTheodore Ts'o                                          const string16& field_contents,
15350787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o                                          bool was_edit) OVERRIDE;
15450787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual bool HandleKeyPressEventInInput(
15550787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o      const content::NativeWebKeyboardEvent& event) OVERRIDE;
15650787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual void FocusMoved() OVERRIDE;
15750787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual void ViewClosed() OVERRIDE;
15850787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual std::vector<DialogNotification> CurrentNotifications() OVERRIDE;
15950787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual void LinkClicked(const GURL& url) OVERRIDE;
16050787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual void SignInLinkClicked() OVERRIDE;
16150787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual void NotificationCheckboxStateChanged(DialogNotification::Type type,
16250787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o                                                bool checked) OVERRIDE;
16350787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual void LegalDocumentLinkClicked(const gfx::Range& range) OVERRIDE;
16450787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual bool OnCancel() OVERRIDE;
16550787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual bool OnAccept() OVERRIDE;
16650787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual Profile* profile() OVERRIDE;
16750787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual content::WebContents* GetWebContents() OVERRIDE;
1689094f28440b6c504a80d97aeea2dab543f97978bTheodore Ts'o
1696733c2fd0046c525203034f58fc0a8c69fdf480bTheodore Ts'o  // AutofillPopupDelegate implementation.
17050787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual void OnPopupShown(
17150787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o      content::RenderWidgetHost::KeyPressEventCallback* callback) OVERRIDE;
17250787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual void OnPopupHidden(
1739094f28440b6c504a80d97aeea2dab543f97978bTheodore Ts'o      content::RenderWidgetHost::KeyPressEventCallback* callback) OVERRIDE;
17450787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual bool ShouldRepostEvent(const ui::MouseEvent& event) OVERRIDE;
17550787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual void DidSelectSuggestion(int identifier) OVERRIDE;
17650787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  virtual void DidAcceptSuggestion(const string16& value,
1773839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o                                   int identifier) OVERRIDE;
1783839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void RemoveSuggestion(const string16& value,
1793839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o                                int identifier) OVERRIDE;
1803839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void ClearPreviewedForm() OVERRIDE;
181d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o
1823839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // content::NotificationObserver implementation.
1833839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void Observe(int type,
1843839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o                       const content::NotificationSource& source,
1853839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o                       const content::NotificationDetails& details) OVERRIDE;
1863839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
1873839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // SuggestionsMenuModelDelegate implementation.
1883839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void SuggestionItemSelected(SuggestionsMenuModel* model,
1893839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o                                      size_t index) OVERRIDE;
1903839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
1913839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // wallet::WalletClientDelegate implementation.
1923839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE;
1933839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual std::string GetRiskData() const OVERRIDE;
1943839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual std::string GetWalletCookieValue() const OVERRIDE;
1953839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual bool IsShippingAddressRequired() const OVERRIDE;
1963839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void OnDidAcceptLegalDocuments() OVERRIDE;
197d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  virtual void OnDidAuthenticateInstrument(bool success) OVERRIDE;
1983839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void OnDidGetFullWallet(
1993839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o      scoped_ptr<wallet::FullWallet> full_wallet) OVERRIDE;
2003839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void OnDidGetWalletItems(
2013839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o      scoped_ptr<wallet::WalletItems> wallet_items) OVERRIDE;
2023839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void OnDidSaveToWallet(
2033839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o      const std::string& instrument_id,
204d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o      const std::string& address_id,
2053839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o      const std::vector<wallet::RequiredAction>& required_actions,
2063839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o      const std::vector<wallet::FormFieldError>& form_field_errors) OVERRIDE;
2073839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void OnWalletError(
2083839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o      wallet::WalletClient::ErrorType error_type) OVERRIDE;
2093839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
2103839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // PersonalDataManagerObserver implementation.
2113839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void OnPersonalDataChanged() OVERRIDE;
2123839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
2133839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // AccountChooserModelDelegate implementation.
2143839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void AccountChoiceChanged() OVERRIDE;
2153839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void UpdateAccountChooserView() OVERRIDE;
2163839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
2173839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // wallet::WalletSigninHelperDelegate implementation.
218f635d7f65bd002984ce9a202d491d4f187b996b2Theodore Ts'o  virtual void OnPassiveSigninSuccess(const std::string& username) OVERRIDE;
219f635d7f65bd002984ce9a202d491d4f187b996b2Theodore Ts'o  virtual void OnPassiveSigninFailure(
2203839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o      const GoogleServiceAuthError& error) OVERRIDE;
2213839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void OnUserNameFetchSuccess(const std::string& username) OVERRIDE;
222d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  virtual void OnUserNameFetchFailure(
2233839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o      const GoogleServiceAuthError& error) OVERRIDE;
2243839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void OnDidFetchWalletCookieValue(
2253839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o      const std::string& cookie_value) OVERRIDE;
226d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o
2273839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // gfx::AnimationDelegate implementation.
2283839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE;
2293839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
230f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o
2313839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o protected:
2323839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Exposed for testing.
233d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  AutofillDialogControllerImpl(
2343839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o      content::WebContents* contents,
2353839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o      const FormData& form_structure,
2363839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o      const GURL& source_url,
2373839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o      const base::Callback<void(const FormStructure*)>& callback);
2383839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
2393839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Exposed for testing.
240f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  AutofillDialogView* view() { return view_.get(); }
2413839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual AutofillDialogView* CreateView();
2423839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  const DetailInput* input_showing_popup() const {
2433839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o    return input_showing_popup_;
2443839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  }
245f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o
246f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  // Returns the PersonalDataManager for |profile_|.
247f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  virtual PersonalDataManager* GetManager();
2483839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
2493839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Returns the WalletClient* this class uses to talk to Online Wallet. Exposed
2503839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // for testing.
2513839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual wallet::WalletClient* GetWalletClient();
2523839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
2533839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Call to disable communication to Online Wallet for this dialog.
2543839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Exposed for testing.
2553839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  void DisableWallet(wallet::WalletClient::ErrorType error_type);
2563839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
2573839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Returns whether Wallet is the current data source. Exposed for testing.
258cbbf031b6edf9bdf5511af2193e44cff7fdaa66aTheodore Ts'o  virtual bool IsPayingWithWallet() const;
259d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o
260d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  // Asks risk module to asynchronously load fingerprint data. Data will be
261d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  // returned via |OnDidLoadRiskFingerprintData()|. Exposed for testing.
262d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  virtual void LoadRiskFingerprintData();
2633839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void OnDidLoadRiskFingerprintData(
264d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o      scoped_ptr<risk::Fingerprint> fingerprint);
2653839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
2663839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Opens the given URL in a new foreground tab.
2673839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void OpenTabWithUrl(const GURL& url);
268f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o
269f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  // Whether |section| was sent into edit mode based on existing data. This
270f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  // happens when a user clicks "Edit" or a suggestion is invalid.
271f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  virtual bool IsEditingExistingData(DialogSection section) const;
272f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o
273f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  // Whether the user has chosen to enter all new data in |section|. This
274f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  // happens via choosing "Add a new X..." from a section's suggestion menu.
275f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  bool IsManuallyEditingSection(DialogSection section) const;
276f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o
277f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  // Should be called on the Wallet sign-in error.
27892bcc595dcb31ad15e12d8c72e6edfc70545c204Theodore Ts'o  virtual void OnWalletSigninError();
279f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o
280cbbf031b6edf9bdf5511af2193e44cff7fdaa66aTheodore Ts'o  // Whether the information input in this dialog will be securely transmitted
281cbbf031b6edf9bdf5511af2193e44cff7fdaa66aTheodore Ts'o  // to the requesting site.
282f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  virtual bool TransmissionWillBeSecure() const;
283f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o
284d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  // Shows a new credit card saved bubble and passes ownership of |new_card| and
285d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  // |billing_profile| to the bubble. Exposed for testing.
286f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  virtual void ShowNewCreditCardBubble(
287f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o      scoped_ptr<CreditCard> new_card,
288f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o      scoped_ptr<AutofillProfile> billing_profile);
289f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o
290f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  // Called when there's nothing left to accept, update, save, or authenticate
291f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  // in order to fill |form_structure_| and pass data back to the invoking page.
292f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  void DoFinishSubmit();
293f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o
294f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  // Delays enabling submit button for a short period of time. Exposed for
2953839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // testing.
2963839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  virtual void SubmitButtonDelayBegin();
2973839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
2983839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Ends the delay for enabling the submit button. Called only from tests.
299cbbf031b6edf9bdf5511af2193e44cff7fdaa66aTheodore Ts'o  // Without this method, the tests would have to wait for the delay timer to
3003839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // finish, which would be flaky.
301cbbf031b6edf9bdf5511af2193e44cff7fdaa66aTheodore Ts'o  void SubmitButtonDelayEndForTesting();
302d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o
3033839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o private:
3043839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  enum DialogSignedInState {
305cbbf031b6edf9bdf5511af2193e44cff7fdaa66aTheodore Ts'o    REQUIRES_RESPONSE,
306f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o    REQUIRES_SIGN_IN,
307cbbf031b6edf9bdf5511af2193e44cff7fdaa66aTheodore Ts'o    REQUIRES_PASSIVE_SIGN_IN,
3083839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o    SIGNED_IN,
3093839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o    SIGN_IN_DISABLED,
31016ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  };
31116ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
31216ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Whether or not the current request wants credit info back.
31316ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  bool RequestingCreditCardInfo() const;
31416ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
31516ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Initializes or updates |suggested_cc_| et al.
31616ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  void SuggestionsUpdated();
31716ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
3187d5633cf6ee1be74777cf4b1adfa9738ff33f2b7Theodore Ts'o  // Starts fetching the wallet items from Online Wallet.
31916ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  void GetWalletItems();
32016ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
32116ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Stop showing sign in flow.
32216ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  void HideSignIn();
3233839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
32416ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Whether the user is known to be signed in.
32516ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  DialogSignedInState SignedInState() const;
32616ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
3271dde43f0c1176f61dd0bf91aff265ce8cd1c5fd6Theodore Ts'o  // Handles the SignedInState() on Wallet or sign-in state update.
3281dde43f0c1176f61dd0bf91aff265ce8cd1c5fd6Theodore Ts'o  // Triggers the user name fetch and passive sign-in.
3291dde43f0c1176f61dd0bf91aff265ce8cd1c5fd6Theodore Ts'o  void SignedInStateUpdated();
3301dde43f0c1176f61dd0bf91aff265ce8cd1c5fd6Theodore Ts'o
33116ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Refreshes the model on Wallet or sign-in state update.
33216ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  void OnWalletOrSigninUpdate();
33316ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
33416ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Called when a Save or Update call to Wallet has validation errors.
33516ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  void OnWalletFormFieldError(
33616ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o      const std::vector<wallet::FormFieldError>& form_field_errors);
33716ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
33816ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Calculates |legal_documents_text_| and |legal_document_link_ranges_| if
33916ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // they have not already been calculated.
34016ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  void EnsureLegalDocumentsText();
34116ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
34216ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Clears previously entered manual input and removes |section| from
34316ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // |section_editing_state_|. Does not update the view.
34416ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  void ResetSectionInput(DialogSection section);
34516ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
34616ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Force |section| into edit mode if the current suggestion is invalid.
34716ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  void ShowEditUiIfBadSuggestion(DialogSection section);
34816ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
34916ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Whether the |value| of |input| should be preserved on account change.
35016ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  bool InputWasEdited(ServerFieldType type,
35116ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o                      const base::string16& value);
35216ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
35316ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Takes a snapshot of the newly inputted user data in |view_| (if it exists).
35416ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  DetailOutputMap TakeUserInputSnapshot();
35516ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
35616ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Fills the detail inputs from a previously taken user input snapshot. Does
35716ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // not update the view.
35816ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  void RestoreUserInputFromSnapshot(const DetailOutputMap& snapshot);
35916ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
36016ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Tells the view to update |section|.
36116ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  void UpdateSection(DialogSection section);
36216ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
36316ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Tells |view_| to update the validity status of its detail inputs (if
36416ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // |view_| is non-null). Currently this is used solely for highlighting
36516ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // invalid suggestions, so if no sections are based on existing data,
36616ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // |view_->UpdateForErrors()| is not called.
36716ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  void UpdateForErrors();
36816ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
36916ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Kicks off |card_scrambling_refresher_|.
37016ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  void StartCardScramblingRefresher();
37116ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
37216ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Changes |scrambled_card_number_| and pushes an update to the view.
37316ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  void RefreshCardScramblingOverlay();
37416ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
37516ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Tells the view to update the overlay.
37616ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  void PushOverlayUpdate();
37716ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
37816ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Creates a DataModelWrapper item for the item that's checked in the
37916ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // suggestion model for |section|. This may represent Autofill
38016ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // data or Wallet data, depending on whether Wallet is currently enabled.
38116ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  scoped_ptr<DataModelWrapper> CreateWrapper(DialogSection section);
38216ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
38316ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Helper to return the current Wallet instrument or address. If the dialog
38416ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // isn't using Wallet or the user is adding a new instrument or address, NULL
38516ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // will be returned.
38616ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  const wallet::WalletItems::MaskedInstrument* ActiveInstrument() const;
38716ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  const wallet::Address* ActiveShippingAddress() const;
38816ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
38916ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Fills in |section|-related fields in |output_| according to the state of
39016ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // |view_|.
39116ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  void FillOutputForSection(DialogSection section);
39216ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // As above, but uses |compare| to determine whether a DetailInput matches
39316ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // a field. Saves any new Autofill data to the PersonalDataManager.
39416ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  void FillOutputForSectionWithComparator(DialogSection section,
39516ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o                                          const InputFieldComparator& compare);
39616ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
39716ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Returns whether |form_structure|_| has any fields that match the fieldset
39816ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // represented by |section|.
39916ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  bool FormStructureCaresAboutSection(DialogSection section) const;
40016ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
40116ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Finds all fields of the given |type| in |form_structure_|, if any, and sets
40216ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // each field's value to |output|.
40316ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  void SetOutputForFieldsOfType(ServerFieldType type, const string16& output);
40416ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
40516ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Gets the value for |type| in |section|, whether it comes from manual user
40616ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // input or the active suggestion.
40716ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  string16 GetValueFromSection(DialogSection section,
40816ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o                               ServerFieldType type);
40916ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
41016ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Gets the SuggestionsMenuModel for |section|.
41116ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  SuggestionsMenuModel* SuggestionsMenuModelForSection(DialogSection section);
41216ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  const SuggestionsMenuModel* SuggestionsMenuModelForSection(
41316ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o      DialogSection section) const;
41416ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // And the reverse.
41516ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  DialogSection SectionForSuggestionsMenuModel(
41616ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o      const SuggestionsMenuModel& model);
41716ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
41816ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Suggested text and icons for sections. Suggestion text is used to show an
41916ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // abridged overview of the currently used suggestion. Extra text is used when
42016ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // part of a section is suggested but part must be manually input (e.g. during
42116ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // a CVC challenge or when using Autofill's CC section [never stores CVC]).
42216ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  bool SuggestionTextForSection(DialogSection section,
42316ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o                                base::string16* vertically_compact,
42416ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o                                base::string16* horizontally_compact);
42516ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  string16 RequiredActionTextForSection(DialogSection section) const;
42616ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  gfx::Image SuggestionIconForSection(DialogSection section);
42716ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  string16 ExtraSuggestionTextForSection(DialogSection section) const;
42816ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  gfx::Image ExtraSuggestionIconForSection(DialogSection section);
42916ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
43016ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Loads profiles that can suggest data for |type|. |field_contents| is the
43116ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // part the user has already typed. |inputs| is the rest of section.
43216ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Identifying info is loaded into the last three outparams as well as
4331dde43f0c1176f61dd0bf91aff265ce8cd1c5fd6Theodore Ts'o  // |popup_guids_|.
4343839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  void GetProfileSuggestions(
43516ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o      ServerFieldType type,
4363839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o      const string16& field_contents,
43719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o      const DetailInputs& inputs,
43819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o      std::vector<string16>* popup_values,
43916ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o      std::vector<string16>* popup_labels,
44016ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o      std::vector<string16>* popup_icons);
44116ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
44216ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Like RequestedFieldsForSection, but returns a pointer.
44316ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  DetailInputs* MutableRequestedFieldsForSection(DialogSection section);
44416ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
44516ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Hides |popup_controller_|'s popup view, if it exists.
44619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o  void HidePopup();
4477d5633cf6ee1be74777cf4b1adfa9738ff33f2b7Theodore Ts'o
4487d5633cf6ee1be74777cf4b1adfa9738ff33f2b7Theodore Ts'o  // Set whether the currently editing |section| was originally based on
4497d5633cf6ee1be74777cf4b1adfa9738ff33f2b7Theodore Ts'o  // existing Wallet or Autofill data.
4507d5633cf6ee1be74777cf4b1adfa9738ff33f2b7Theodore Ts'o  void SetEditingExistingData(DialogSection section, bool editing);
4517d5633cf6ee1be74777cf4b1adfa9738ff33f2b7Theodore Ts'o
4527d5633cf6ee1be74777cf4b1adfa9738ff33f2b7Theodore Ts'o  // Whether the user has chosen to enter all new data in at least one section.
4533839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  bool IsManuallyEditingAnySection() const;
45416ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
45516ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Returns validity message for a given credit card number.
4563839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  base::string16 CreditCardNumberValidityMessage(
4573839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o      const base::string16& number) const;
4583839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
4593839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Whether a particular DetailInput in |section| should be edited or not.
4603839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  bool InputIsEditable(const DetailInput& input, DialogSection section) const;
461f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o
4623839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Whether all of the input fields currently showing in the dialog have valid
4633839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // contents.
4643839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  bool AllSectionsAreValid();
465d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o
4663839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Whether all of the input fields currently showing in the given |section| of
4673839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // the dialog have valid contents.
468f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  bool SectionIsValid(DialogSection section);
469f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o
470f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  // Whether the currently active credit card expiration date is valid.
471f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  bool IsCreditCardExpirationValid(const base::string16& year,
472d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o                                   const base::string16& month) const;
473f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o
474f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  // Returns true if |key| refers to a suggestion, as opposed to some control
47519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o  // menu item.
47619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o  bool IsASuggestionItemKey(const std::string& key) const;
47719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o
478f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  // Whether the billing section should be used to fill in the shipping details.
479f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  bool ShouldUseBillingForShipping();
480f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o
481d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  // Whether the user wishes to save information locally to Autofill.
482f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  bool ShouldSaveDetailsLocally();
483f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o
484f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  // Change whether the controller is currently submitting details to Autofill
4853839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // or Online Wallet (|is_submitting_|) and update the view.
4863839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  void SetIsSubmitting(bool submitting);
4873839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
4883839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Whether the user has accepted all the current legal documents' terms.
4893839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  bool AreLegalDocumentsCurrent() const;
490dfcdc32f8d6623a35a9e66f503c535e4081b7266Theodore Ts'o
4913839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Accepts any pending legal documents now that the user has pressed Submit.
4923839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  void AcceptLegalDocuments();
49350787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o
4943839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Start the submit proccess to interact with Online Wallet (might do various
4953839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // things like accept documents, save details, update details, respond to
4963839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // required actions, etc.).
497d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  void SubmitWithWallet();
498d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o
4993839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Creates an instrument based on |views_|' contents.
5003839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  scoped_ptr<wallet::Instrument> CreateTransientInstrument();
5013839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
5023839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Creates an address based on the contents of |view_|.
5033839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  scoped_ptr<wallet::Address> CreateTransientAddress();
504d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o
505d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  // Gets a full wallet from Online Wallet so the user can purchase something.
5063839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // This information is decoded to reveal a fronting (proxy) card.
5073839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  void GetFullWallet();
5083839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
5093839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Updates the state of the controller and |view_| based on any required
51050787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  // actions returned by Save or Update calls to Wallet.
51150787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  void HandleSaveOrUpdateRequiredActions(
5123839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o      const std::vector<wallet::RequiredAction>& required_actions);
5133839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
5143839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Whether submission is currently waiting for |action| to be handled.
515d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  bool IsSubmitPausedOn(wallet::RequiredAction action) const;
5163839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
5173839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Shows a card generation overlay if necessary, then calls DoFinishSubmit.
5183839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  void FinishSubmit();
5193839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
5203839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Writes to prefs the choice of AutofillDataModel for |section|.
5213839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  void PersistAutofillChoice(DialogSection section,
5223839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o                             const std::string& guid);
5233839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
5243839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Sets the outparams to the default AutofillDataModel for |section| (which is
525f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  // the first one in the menu that is a suggestion item).
5263839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  void GetDefaultAutofillChoice(DialogSection section,
5273839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o                                std::string* guid);
5283839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
5293839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Reads from prefs the choice of AutofillDataModel for |section|. Returns
5303839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // whether there was a setting to read.
531d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  bool GetAutofillChoice(DialogSection section,
5323839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o                         std::string* guid);
5333839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
5343839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Logs metrics when the dialog is submitted.
5353839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  void LogOnFinishSubmitMetrics();
5363839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
5373839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Logs metrics when the dialog is canceled.
5383839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  void LogOnCancelMetrics();
539dfcdc32f8d6623a35a9e66f503c535e4081b7266Theodore Ts'o
540dfcdc32f8d6623a35a9e66f503c535e4081b7266Theodore Ts'o  // Logs metrics when the edit ui is shown for the given |section|.
5413839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  void LogEditUiShownMetric(DialogSection section);
5427f88b04341d88c5df0360d930832c38040303b61Theodore Ts'o
543f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  // Logs metrics when a suggestion item from the given |model| is selected.
5443839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  void LogSuggestionItemSelectedMetric(const SuggestionsMenuModel& model);
5453839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
5463839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Logs the time elapsed from when the dialog was shown to when the user could
5473839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // interact with it.
5483839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  void LogDialogLatencyToShow();
5493839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
5503839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Returns the metric corresponding to the user's initial state when
551e41784eb0e47ff5e460b635c86a0cef7250b48b4Theodore Ts'o  // interacting with this dialog.
552f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  AutofillMetrics::DialogInitialUserStateMetric GetInitialUserState() const;
553f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o
554f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  // Shows an educational bubble if a new credit card was saved or the first few
555f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  // times an Online Wallet fronting card was generated.
556f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  void MaybeShowCreditCardBubble();
557f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o
558e41784eb0e47ff5e460b635c86a0cef7250b48b4Theodore Ts'o  // Called when the delay for enabling the submit button ends.
559e41784eb0e47ff5e460b635c86a0cef7250b48b4Theodore Ts'o  void OnSubmitButtonDelayEnd();
560e41784eb0e47ff5e460b635c86a0cef7250b48b4Theodore Ts'o
561f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  // The |profile| for |contents_|.
562e294cf2f6409aeede04316b1268f3e78a83509d0Theodore Ts'o  Profile* const profile_;
563f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o
564f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  // For logging UMA metrics.
56516ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  const AutofillMetrics metric_logger_;
56616ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  base::Time dialog_shown_timestamp_;
56716ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  AutofillMetrics::DialogInitialUserStateMetric initial_user_state_;
56816ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
56916ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  FormStructure form_structure_;
57016ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
571dc2ec525f5619bf478d2aae1b406fca2ff4b0d21Theodore Ts'o  // Whether the URL visible to the user when this dialog was requested to be
572dc2ec525f5619bf478d2aae1b406fca2ff4b0d21Theodore Ts'o  // invoked is the same as |source_url_|.
57316ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  bool invoked_from_same_origin_;
574d6a27e0048537ab6367a6aa97fbe84a423119eeaTheodore Ts'o
575d6a27e0048537ab6367a6aa97fbe84a423119eeaTheodore Ts'o  // The URL of the invoking site.
576d6a27e0048537ab6367a6aa97fbe84a423119eeaTheodore Ts'o  GURL source_url_;
577d6a27e0048537ab6367a6aa97fbe84a423119eeaTheodore Ts'o
578d6a27e0048537ab6367a6aa97fbe84a423119eeaTheodore Ts'o  // The callback via which we return the collected data.
579d6a27e0048537ab6367a6aa97fbe84a423119eeaTheodore Ts'o  base::Callback<void(const FormStructure*)> callback_;
580d6a27e0048537ab6367a6aa97fbe84a423119eeaTheodore Ts'o
58116ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // The AccountChooserModel acts as the MenuModel for the account chooser,
58216ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // and also tracks which data source the dialog is using.
58316ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  AccountChooserModel account_chooser_model_;
58416ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
58516ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // The sign-in helper to fetch the user info and perform passive sign-in.
58616ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // The helper is set only during fetch/sign-in, and NULL otherwise.
58716ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  scoped_ptr<wallet::WalletSigninHelper> signin_helper_;
58816ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
58916ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // A client to talk to the Online Wallet API.
59016ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  wallet::WalletClient wallet_client_;
59114bbcbc31c3aa413b866f49001c517ca9e83d7d8Theodore Ts'o
59216ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // Recently received items retrieved via |wallet_client_|.
59316ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  scoped_ptr<wallet::WalletItems> wallet_items_;
59416ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  scoped_ptr<wallet::FullWallet> full_wallet_;
595dc2ec525f5619bf478d2aae1b406fca2ff4b0d21Theodore Ts'o
596dc2ec525f5619bf478d2aae1b406fca2ff4b0d21Theodore Ts'o  // The default active instrument and shipping address object IDs as of the
597dc2ec525f5619bf478d2aae1b406fca2ff4b0d21Theodore Ts'o  // last time Wallet items were fetched. These variables are only set
598dc2ec525f5619bf478d2aae1b406fca2ff4b0d21Theodore Ts'o  // (i.e. non-empty) when the Wallet items are being re-fetched.
599dc2ec525f5619bf478d2aae1b406fca2ff4b0d21Theodore Ts'o  std::string previous_default_instrument_id_;
60016ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  std::string previous_default_shipping_address_id_;
60116ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // The last active instrument and shipping address object IDs. These
60216ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // variables are only set (i.e. non-empty) when the Wallet items are being
60316ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  // re-fetched.
60416ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  std::string previously_selected_instrument_id_;
60516ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o  std::string previously_selected_shipping_address_id_;
60616ed5b3af43c72f60991222b9d7ab65cf53f203dTheodore Ts'o
607f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o  // When the Wallet items were last fetched.
6083839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  base::TimeTicks last_wallet_items_fetch_timestamp_;
6093839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
610ef9abe5f2529b3a42b46bf64c5f4232f86e7b390Theodore Ts'o  // Local machine signals to pass along on each request to trigger (or
6111e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  // discourage) risk challenges; sent if the user is up to date on legal docs.
6123839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  std::string risk_data_;
6131dde43f0c1176f61dd0bf91aff265ce8cd1c5fd6Theodore Ts'o
6143839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // The text to display when the user is accepting new terms of service, etc.
6153839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  string16 legal_documents_text_;
616d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  // The ranges within |legal_documents_text_| to linkify.
6173839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  std::vector<gfx::Range> legal_document_link_ranges_;
61850787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o
61950787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  // The instrument and address IDs from the Online Wallet server to be used
62050787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  // when getting a full wallet.
621d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  std::string active_instrument_id_;
622d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  std::string active_address_id_;
6231e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o
6241e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  // The fields for billing and shipping which the page has actually requested.
625ad6783df0c9d06e5c298167de34aec8e6e25e6c2Theodore Ts'o  DetailInputs requested_cc_fields_;
6261e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  DetailInputs requested_billing_fields_;
627d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  DetailInputs requested_cc_billing_fields_;
6281e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  DetailInputs requested_shipping_fields_;
62950787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o
630d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  // Models for the credit card expiration inputs.
63150787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o  MonthComboboxModel cc_exp_month_combobox_model_;
632d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  YearComboboxModel cc_exp_year_combobox_model_;
63350787ea22edd8b4662203daf3569411d9dcf4287Theodore Ts'o
634d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  // Model for the country input.
6353839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  CountryComboboxModel country_combobox_model_;
636d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o
6373839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // Models for the suggestion views.
6383839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  SuggestionsMenuModel suggested_cc_;
639d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  SuggestionsMenuModel suggested_billing_;
640d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  SuggestionsMenuModel suggested_cc_billing_;
641c8c071a07319939dfd7ae2ff1dedec644d750debTheodore Ts'o  SuggestionsMenuModel suggested_shipping_;
642d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o
643c8c071a07319939dfd7ae2ff1dedec644d750debTheodore Ts'o  // |DialogSection|s that are in edit mode that are based on existing data.
644d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  std::set<DialogSection> section_editing_state_;
6453839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
646d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  // Whether |form_structure_| has asked for any details that would indicate
6473839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // we should show a shipping section.
6483839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  bool cares_about_shipping_;
6493839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
6503839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // The GUIDs for the currently showing unverified profiles popup.
6513839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  std::vector<PersonalDataManager::GUIDPair> popup_guids_;
6523839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
653d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  // The controller for the currently showing popup (which helps users when
6543839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // they're manually filling the dialog).
6553839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  base::WeakPtr<AutofillPopupControllerImpl> popup_controller_;
6563839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
6573839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // The input for which |popup_controller_| is currently showing a popup
658521e36857227b21e7ab47b0a97f788d2af9f9717Theodore Ts'o  // (if any).
659521e36857227b21e7ab47b0a97f788d2af9f9717Theodore Ts'o  const DetailInput* input_showing_popup_;
6607671433a9daad089af037f84b365d640e1adf252Theodore Ts'o
6617671433a9daad089af037f84b365d640e1adf252Theodore Ts'o  scoped_ptr<AutofillDialogView> view_;
6626733c2fd0046c525203034f58fc0a8c69fdf480bTheodore Ts'o
6631dde43f0c1176f61dd0bf91aff265ce8cd1c5fd6Theodore Ts'o  // A NotificationRegistrar for tracking the completion of sign-in.
6643839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  content::NotificationRegistrar signin_registrar_;
6651dde43f0c1176f61dd0bf91aff265ce8cd1c5fd6Theodore Ts'o
6663839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  base::WeakPtrFactory<AutofillDialogControllerImpl> weak_ptr_factory_;
6671dde43f0c1176f61dd0bf91aff265ce8cd1c5fd6Theodore Ts'o
668a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o  // Whether a user accepted legal documents while this dialog is running.
6693839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  bool has_accepted_legal_documents_;
6703839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
6713839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // True after the user first accepts the dialog and presses "Submit". May
6723839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o  // continue to be true while processing required actions.
6731e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  bool is_submitting_;
6741e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o
6751e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  // True if the last call to |GetFullWallet()| returned a
6761e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  // CHOOSE_ANOTHER_INSTRUMENT_OR_ADDRESS required action, indicating that the
6771e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  // selected instrument or address had become invalid since it was originally
6781e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  // returned in |GetWalletItems()|.
6791e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  bool choose_another_instrument_or_address_;
6801e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o
6811e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  // Whether or not the server side validation errors returned by Wallet were
6821e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  // recoverable.
6831e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  bool wallet_server_validation_recoverable_;
6841e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o
6851e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  // Whether |callback_| was Run() with a filled |form_structure_|.
6861e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  bool data_was_passed_back_;
6871e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o
6881e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  typedef std::map<ServerFieldType,
6891e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o      std::pair<base::string16, base::string16> > TypeErrorInputMap;
6901e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  typedef std::map<DialogSection, TypeErrorInputMap> WalletValidationErrors;
6911e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  // Wallet validation errors. section->type->(error_msg, input_value).
692a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o  WalletValidationErrors wallet_errors_;
693a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o
694d163b0948731e6d84bd3efe75075a2d0a8009272Theodore Ts'o  // The notification that describes the current wallet error, if any.
695a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  scoped_ptr<DialogNotification> wallet_error_notification_;
696a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o
697a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  // Whether the latency to display to the UI was logged to UMA yet.
698a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  bool was_ui_latency_logged_;
699a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o
700a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  // The Google Wallet cookie value, set as an authorization header on requests
701a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  // to Wallet.
702a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  std::string wallet_cookie_value_;
703d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o
704d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  // A map from dialog sections to the GUID of a newly saved Autofill data
705a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  // models for that section. No entries present that don't have newly saved
706a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  // data models.
707a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  std::map<DialogSection, std::string> newly_saved_data_model_guids_;
708a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o
709a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  // Populated if the user chose to save a newly inputted credit card. Used to
710a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  // show a bubble as the dialog closes to confirm a user's new card info was
711a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  // saved. Never populated while incognito (as nothing's actually saved).
712a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  scoped_ptr<CreditCard> newly_saved_card_;
713a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o
714a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  // The timer that delays enabling submit button for a short period of time on
715a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  // startup.
716a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  base::OneShotTimer<AutofillDialogControllerImpl> submit_button_delay_timer_;
717a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o
718a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  // The card scrambling animation displays a random number in place of an
719a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  // actual credit card number. This is that random number.
720a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  base::string16 scrambled_card_number_;
721a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o
722a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  // Two timers to deal with the card scrambling animation. The first provides
723a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  // a one second delay before the numbers start scrambling. The second controls
724a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  // the rate of refresh for the number scrambling.
725a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  base::OneShotTimer<AutofillDialogControllerImpl> card_scrambling_delay_;
726a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  base::RepeatingTimer<AutofillDialogControllerImpl> card_scrambling_refresher_;
727d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o
728d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o  // An animation which controls the background fade when the card is done
729a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  // scrambling.
730a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  gfx::LinearAnimation card_generated_animation_;
731a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o
732a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  // A username string we display in the card scrambling/generated overlay.
733a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  base::string16 submitted_cardholder_name_;
734a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o
735a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o  DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl);
736d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o};
737a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o
738a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o}  // namespace autofill
739a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o
740a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o#endif  // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_
741d9c56d3ca0bee11e3446ff7e12e3124d28e298a7Theodore Ts'o