OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ |
6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ | 6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "chrome/browser/ui/autofill/account_chooser_model.h" | 16 #include "chrome/browser/ui/autofill/account_chooser_model.h" |
17 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" | 17 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" |
18 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" | 18 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" |
19 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" | 19 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" |
20 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" | 20 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" |
21 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" | 21 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" |
22 #include "chrome/browser/ui/autofill/country_combobox_model.h" | 22 #include "chrome/browser/ui/autofill/country_combobox_model.h" |
23 #include "components/autofill/content/browser/autocheckout_steps.h" | |
24 #include "components/autofill/content/browser/wallet/wallet_client.h" | 23 #include "components/autofill/content/browser/wallet/wallet_client.h" |
25 #include "components/autofill/content/browser/wallet/wallet_client_delegate.h" | 24 #include "components/autofill/content/browser/wallet/wallet_client_delegate.h" |
26 #include "components/autofill/content/browser/wallet/wallet_items.h" | 25 #include "components/autofill/content/browser/wallet/wallet_items.h" |
27 #include "components/autofill/content/browser/wallet/wallet_signin_helper_delega
te.h" | 26 #include "components/autofill/content/browser/wallet/wallet_signin_helper_delega
te.h" |
28 #include "components/autofill/core/browser/autofill_manager_delegate.h" | 27 #include "components/autofill/core/browser/autofill_manager_delegate.h" |
29 #include "components/autofill/core/browser/autofill_metrics.h" | 28 #include "components/autofill/core/browser/autofill_metrics.h" |
30 #include "components/autofill/core/browser/autofill_popup_delegate.h" | 29 #include "components/autofill/core/browser/autofill_popup_delegate.h" |
31 #include "components/autofill/core/browser/field_types.h" | 30 #include "components/autofill/core/browser/field_types.h" |
32 #include "components/autofill/core/browser/form_structure.h" | 31 #include "components/autofill/core/browser/form_structure.h" |
33 #include "components/autofill/core/browser/personal_data_manager.h" | 32 #include "components/autofill/core/browser/personal_data_manager.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 const DialogType dialog_type, | 87 const DialogType dialog_type, |
89 const base::Callback<void(const FormStructure*, | 88 const base::Callback<void(const FormStructure*, |
90 const std::string&)>& callback); | 89 const std::string&)>& callback); |
91 | 90 |
92 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 91 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
93 | 92 |
94 // AutofillDialogController implementation. | 93 // AutofillDialogController implementation. |
95 virtual void Show() OVERRIDE; | 94 virtual void Show() OVERRIDE; |
96 virtual void Hide() OVERRIDE; | 95 virtual void Hide() OVERRIDE; |
97 virtual void TabActivated() OVERRIDE; | 96 virtual void TabActivated() OVERRIDE; |
98 virtual void AddAutocheckoutStep(AutocheckoutStepType step_type) OVERRIDE; | |
99 virtual void UpdateAutocheckoutStep( | |
100 AutocheckoutStepType step_type, | |
101 AutocheckoutStepStatus step_status) OVERRIDE; | |
102 virtual void OnAutocheckoutError() OVERRIDE; | |
103 virtual void OnAutocheckoutSuccess() OVERRIDE; | |
104 | 97 |
105 // Returns |view_| as a testable version of itself (if |view_| exists and | 98 // Returns |view_| as a testable version of itself (if |view_| exists and |
106 // actually implements |AutofillDialogView::GetTestableView()|). | 99 // actually implements |AutofillDialogView::GetTestableView()|). |
107 TestableAutofillDialogView* GetTestableView(); | 100 TestableAutofillDialogView* GetTestableView(); |
108 | 101 |
109 // AutofillDialogViewDelegate implementation. | 102 // AutofillDialogViewDelegate implementation. |
110 virtual string16 DialogTitle() const OVERRIDE; | 103 virtual string16 DialogTitle() const OVERRIDE; |
111 virtual string16 AccountChooserText() const OVERRIDE; | 104 virtual string16 AccountChooserText() const OVERRIDE; |
112 virtual string16 SignInLinkText() const OVERRIDE; | 105 virtual string16 SignInLinkText() const OVERRIDE; |
113 virtual string16 EditSuggestionText() const OVERRIDE; | 106 virtual string16 EditSuggestionText() const OVERRIDE; |
114 virtual string16 CancelButtonText() const OVERRIDE; | 107 virtual string16 CancelButtonText() const OVERRIDE; |
115 virtual string16 ConfirmButtonText() const OVERRIDE; | 108 virtual string16 ConfirmButtonText() const OVERRIDE; |
116 virtual string16 SaveLocallyText() const OVERRIDE; | 109 virtual string16 SaveLocallyText() const OVERRIDE; |
117 virtual string16 SaveLocallyTooltip() const OVERRIDE; | 110 virtual string16 SaveLocallyTooltip() const OVERRIDE; |
118 virtual string16 LegalDocumentsText() OVERRIDE; | 111 virtual string16 LegalDocumentsText() OVERRIDE; |
119 virtual DialogSignedInState SignedInState() const OVERRIDE; | 112 virtual DialogSignedInState SignedInState() const OVERRIDE; |
120 virtual bool ShouldShowSpinner() const OVERRIDE; | 113 virtual bool ShouldShowSpinner() const OVERRIDE; |
121 virtual bool ShouldOfferToSaveInChrome() const OVERRIDE; | 114 virtual bool ShouldOfferToSaveInChrome() const OVERRIDE; |
122 virtual ui::MenuModel* MenuModelForAccountChooser() OVERRIDE; | 115 virtual ui::MenuModel* MenuModelForAccountChooser() OVERRIDE; |
123 virtual gfx::Image AccountChooserImage() OVERRIDE; | 116 virtual gfx::Image AccountChooserImage() OVERRIDE; |
124 virtual bool ShouldShowDetailArea() const OVERRIDE; | 117 virtual bool ShouldShowDetailArea() const OVERRIDE; |
125 virtual bool ShouldShowProgressBar() const OVERRIDE; | |
126 virtual gfx::Image ButtonStripImage() const OVERRIDE; | 118 virtual gfx::Image ButtonStripImage() const OVERRIDE; |
127 virtual int GetDialogButtons() const OVERRIDE; | 119 virtual int GetDialogButtons() const OVERRIDE; |
128 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; | 120 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; |
129 virtual DialogOverlayState GetDialogOverlay() const OVERRIDE; | 121 virtual DialogOverlayState GetDialogOverlay() const OVERRIDE; |
130 virtual const std::vector<ui::Range>& LegalDocumentLinks() OVERRIDE; | 122 virtual const std::vector<ui::Range>& LegalDocumentLinks() OVERRIDE; |
131 virtual bool SectionIsActive(DialogSection section) const OVERRIDE; | 123 virtual bool SectionIsActive(DialogSection section) const OVERRIDE; |
132 virtual const DetailInputs& RequestedFieldsForSection(DialogSection section) | 124 virtual const DetailInputs& RequestedFieldsForSection(DialogSection section) |
133 const OVERRIDE; | 125 const OVERRIDE; |
134 virtual ui::ComboboxModel* ComboboxModelForAutofillType( | 126 virtual ui::ComboboxModel* ComboboxModelForAutofillType( |
135 ServerFieldType type) OVERRIDE; | 127 ServerFieldType type) OVERRIDE; |
(...skipping 16 matching lines...) Expand all Loading... |
152 gfx::NativeView parent_view, | 144 gfx::NativeView parent_view, |
153 const gfx::Rect& content_bounds, | 145 const gfx::Rect& content_bounds, |
154 const string16& field_contents, | 146 const string16& field_contents, |
155 bool was_edit) OVERRIDE; | 147 bool was_edit) OVERRIDE; |
156 virtual bool HandleKeyPressEventInInput( | 148 virtual bool HandleKeyPressEventInInput( |
157 const content::NativeWebKeyboardEvent& event) OVERRIDE; | 149 const content::NativeWebKeyboardEvent& event) OVERRIDE; |
158 virtual void FocusMoved() OVERRIDE; | 150 virtual void FocusMoved() OVERRIDE; |
159 virtual gfx::Image SplashPageImage() const OVERRIDE; | 151 virtual gfx::Image SplashPageImage() const OVERRIDE; |
160 virtual void ViewClosed() OVERRIDE; | 152 virtual void ViewClosed() OVERRIDE; |
161 virtual std::vector<DialogNotification> CurrentNotifications() OVERRIDE; | 153 virtual std::vector<DialogNotification> CurrentNotifications() OVERRIDE; |
162 virtual std::vector<DialogAutocheckoutStep> CurrentAutocheckoutSteps() | |
163 const OVERRIDE; | |
164 virtual void SignInLinkClicked() OVERRIDE; | 154 virtual void SignInLinkClicked() OVERRIDE; |
165 virtual void NotificationCheckboxStateChanged(DialogNotification::Type type, | 155 virtual void NotificationCheckboxStateChanged(DialogNotification::Type type, |
166 bool checked) OVERRIDE; | 156 bool checked) OVERRIDE; |
167 virtual void LegalDocumentLinkClicked(const ui::Range& range) OVERRIDE; | 157 virtual void LegalDocumentLinkClicked(const ui::Range& range) OVERRIDE; |
168 virtual void OverlayButtonPressed() OVERRIDE; | 158 virtual void OverlayButtonPressed() OVERRIDE; |
169 virtual bool OnCancel() OVERRIDE; | 159 virtual bool OnCancel() OVERRIDE; |
170 virtual bool OnAccept() OVERRIDE; | 160 virtual bool OnAccept() OVERRIDE; |
171 virtual Profile* profile() OVERRIDE; | 161 virtual Profile* profile() OVERRIDE; |
172 virtual content::WebContents* GetWebContents() OVERRIDE; | 162 virtual content::WebContents* GetWebContents() OVERRIDE; |
173 | 163 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 // happens via choosing "Add a new X..." from a section's suggestion menu. | 267 // happens via choosing "Add a new X..." from a section's suggestion menu. |
278 bool IsManuallyEditingSection(DialogSection section) const; | 268 bool IsManuallyEditingSection(DialogSection section) const; |
279 | 269 |
280 // Should be called on the Wallet sign-in error. | 270 // Should be called on the Wallet sign-in error. |
281 virtual void OnWalletSigninError(); | 271 virtual void OnWalletSigninError(); |
282 | 272 |
283 // Whether the information input in this dialog will be securely transmitted | 273 // Whether the information input in this dialog will be securely transmitted |
284 // to the requesting site. | 274 // to the requesting site. |
285 virtual bool TransmissionWillBeSecure() const; | 275 virtual bool TransmissionWillBeSecure() const; |
286 | 276 |
287 AutocheckoutState autocheckout_state() const { return autocheckout_state_; } | |
288 | |
289 // Shows a new credit card saved bubble and passes ownership of |new_card| and | 277 // Shows a new credit card saved bubble and passes ownership of |new_card| and |
290 // |billing_profile| to the bubble. Exposed for testing. | 278 // |billing_profile| to the bubble. Exposed for testing. |
291 virtual void ShowNewCreditCardBubble( | 279 virtual void ShowNewCreditCardBubble( |
292 scoped_ptr<CreditCard> new_card, | 280 scoped_ptr<CreditCard> new_card, |
293 scoped_ptr<AutofillProfile> billing_profile); | 281 scoped_ptr<AutofillProfile> billing_profile); |
294 | 282 |
295 private: | 283 private: |
296 // Whether or not the current request wants credit info back. | 284 // Whether or not the current request wants credit info back. |
297 bool RequestingCreditCardInfo() const; | 285 bool RequestingCreditCardInfo() const; |
298 | 286 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 // Logs metrics when the edit ui is shown for the given |section|. | 514 // Logs metrics when the edit ui is shown for the given |section|. |
527 void LogEditUiShownMetric(DialogSection section); | 515 void LogEditUiShownMetric(DialogSection section); |
528 | 516 |
529 // Logs metrics when a suggestion item from the given |model| is selected. | 517 // Logs metrics when a suggestion item from the given |model| is selected. |
530 void LogSuggestionItemSelectedMetric(const SuggestionsMenuModel& model); | 518 void LogSuggestionItemSelectedMetric(const SuggestionsMenuModel& model); |
531 | 519 |
532 // Logs the time elapsed from when the dialog was shown to when the user could | 520 // Logs the time elapsed from when the dialog was shown to when the user could |
533 // interact with it. | 521 // interact with it. |
534 void LogDialogLatencyToShow(); | 522 void LogDialogLatencyToShow(); |
535 | 523 |
536 // Sets the state of the autocheckout flow. | |
537 void SetAutocheckoutState(AutocheckoutState autocheckout_state); | |
538 | |
539 // Obscures the web contents. | 524 // Obscures the web contents. |
540 void DeemphasizeRenderView(); | 525 void DeemphasizeRenderView(); |
541 | 526 |
542 // Returns the metric corresponding to the user's initial state when | 527 // Returns the metric corresponding to the user's initial state when |
543 // interacting with this dialog. | 528 // interacting with this dialog. |
544 AutofillMetrics::DialogInitialUserStateMetric GetInitialUserState() const; | 529 AutofillMetrics::DialogInitialUserStateMetric GetInitialUserState() const; |
545 | 530 |
546 // Shows an educational bubble if a new credit card was saved or the first few | 531 // Shows an educational bubble if a new credit card was saved or the first few |
547 // times an Online Wallet fronting card was generated. | 532 // times an Online Wallet fronting card was generated. |
548 void MaybeShowCreditCardBubble(); | 533 void MaybeShowCreditCardBubble(); |
549 | 534 |
550 // The |profile| for |contents_|. | 535 // The |profile| for |contents_|. |
551 Profile* const profile_; | 536 Profile* const profile_; |
552 | 537 |
553 // For logging UMA metrics. | 538 // For logging UMA metrics. |
554 const AutofillMetrics metric_logger_; | 539 const AutofillMetrics metric_logger_; |
555 base::Time dialog_shown_timestamp_; | 540 base::Time dialog_shown_timestamp_; |
556 AutofillMetrics::DialogInitialUserStateMetric initial_user_state_; | 541 AutofillMetrics::DialogInitialUserStateMetric initial_user_state_; |
557 | 542 |
558 // The time that Autocheckout started running. Reset on error. While this is | |
559 // a valid time, |AutocheckoutIsRunning()| will return true. | |
560 base::Time autocheckout_started_timestamp_; | |
561 | |
562 // Whether this is an Autocheckout or a requestAutocomplete dialog. | 543 // Whether this is an Autocheckout or a requestAutocomplete dialog. |
563 const DialogType dialog_type_; | 544 const DialogType dialog_type_; |
564 | 545 |
565 FormStructure form_structure_; | 546 FormStructure form_structure_; |
566 | 547 |
567 // Whether the URL visible to the user when this dialog was requested to be | 548 // Whether the URL visible to the user when this dialog was requested to be |
568 // invoked is the same as |source_url_|. | 549 // invoked is the same as |source_url_|. |
569 bool invoked_from_same_origin_; | 550 bool invoked_from_same_origin_; |
570 | 551 |
571 // The URL of the invoking site. | 552 // The URL of the invoking site. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 | 664 |
684 // Whether |callback_| was Run() with a filled |form_structure_|. | 665 // Whether |callback_| was Run() with a filled |form_structure_|. |
685 bool data_was_passed_back_; | 666 bool data_was_passed_back_; |
686 | 667 |
687 typedef std::map<ServerFieldType, | 668 typedef std::map<ServerFieldType, |
688 std::pair<base::string16, base::string16> > TypeErrorInputMap; | 669 std::pair<base::string16, base::string16> > TypeErrorInputMap; |
689 typedef std::map<DialogSection, TypeErrorInputMap> WalletValidationErrors; | 670 typedef std::map<DialogSection, TypeErrorInputMap> WalletValidationErrors; |
690 // Wallet validation errors. section->type->(error_msg, input_value). | 671 // Wallet validation errors. section->type->(error_msg, input_value). |
691 WalletValidationErrors wallet_errors_; | 672 WalletValidationErrors wallet_errors_; |
692 | 673 |
693 // The current state of the Autocheckout flow. | |
694 AutocheckoutState autocheckout_state_; | |
695 | |
696 // Whether the latency to display to the UI was logged to UMA yet. | 674 // Whether the latency to display to the UI was logged to UMA yet. |
697 bool was_ui_latency_logged_; | 675 bool was_ui_latency_logged_; |
698 | 676 |
699 // Whether or not the render view has been deemphasized. | 677 // Whether or not the render view has been deemphasized. |
700 bool deemphasized_render_view_; | 678 bool deemphasized_render_view_; |
701 | 679 |
702 // State of steps in the current Autocheckout flow, or empty if not an | |
703 // Autocheckout use case. | |
704 std::vector<DialogAutocheckoutStep> steps_; | |
705 | |
706 // The Google Wallet cookie value, set as an authorization header on requests | 680 // The Google Wallet cookie value, set as an authorization header on requests |
707 // to Wallet. | 681 // to Wallet. |
708 std::string wallet_cookie_value_; | 682 std::string wallet_cookie_value_; |
709 | 683 |
710 // Populated if the user chose to save a newly inputted credit card. Used to | 684 // Populated if the user chose to save a newly inputted credit card. Used to |
711 // show a bubble as the dialog closes to confirm a user's new card info was | 685 // show a bubble as the dialog closes to confirm a user's new card info was |
712 // saved. Never populated while incognito (as nothing's actually saved). | 686 // saved. Never populated while incognito (as nothing's actually saved). |
713 scoped_ptr<CreditCard> newly_saved_card_; | 687 scoped_ptr<CreditCard> newly_saved_card_; |
714 | 688 |
715 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl); | 689 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl); |
716 }; | 690 }; |
717 | 691 |
718 } // namespace autofill | 692 } // namespace autofill |
719 | 693 |
720 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ | 694 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ |
OLD | NEW |