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; | |
125 virtual bool ShouldShowProgressBar() const OVERRIDE; | |
126 virtual gfx::Image ButtonStripImage() const OVERRIDE; | 117 virtual gfx::Image ButtonStripImage() const OVERRIDE; |
127 virtual int GetDialogButtons() const OVERRIDE; | 118 virtual int GetDialogButtons() const OVERRIDE; |
128 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; | 119 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; |
129 virtual DialogOverlayState GetDialogOverlay() const OVERRIDE; | 120 virtual DialogOverlayState GetDialogOverlay() const OVERRIDE; |
130 virtual const std::vector<ui::Range>& LegalDocumentLinks() OVERRIDE; | 121 virtual const std::vector<ui::Range>& LegalDocumentLinks() OVERRIDE; |
131 virtual bool SectionIsActive(DialogSection section) const OVERRIDE; | 122 virtual bool SectionIsActive(DialogSection section) const OVERRIDE; |
132 virtual const DetailInputs& RequestedFieldsForSection(DialogSection section) | 123 virtual const DetailInputs& RequestedFieldsForSection(DialogSection section) |
133 const OVERRIDE; | 124 const OVERRIDE; |
134 virtual ui::ComboboxModel* ComboboxModelForAutofillType( | 125 virtual ui::ComboboxModel* ComboboxModelForAutofillType( |
135 ServerFieldType type) OVERRIDE; | 126 ServerFieldType type) OVERRIDE; |
(...skipping 16 matching lines...) Expand all Loading... |
152 gfx::NativeView parent_view, | 143 gfx::NativeView parent_view, |
153 const gfx::Rect& content_bounds, | 144 const gfx::Rect& content_bounds, |
154 const string16& field_contents, | 145 const string16& field_contents, |
155 bool was_edit) OVERRIDE; | 146 bool was_edit) OVERRIDE; |
156 virtual bool HandleKeyPressEventInInput( | 147 virtual bool HandleKeyPressEventInInput( |
157 const content::NativeWebKeyboardEvent& event) OVERRIDE; | 148 const content::NativeWebKeyboardEvent& event) OVERRIDE; |
158 virtual void FocusMoved() OVERRIDE; | 149 virtual void FocusMoved() OVERRIDE; |
159 virtual gfx::Image SplashPageImage() const OVERRIDE; | 150 virtual gfx::Image SplashPageImage() const OVERRIDE; |
160 virtual void ViewClosed() OVERRIDE; | 151 virtual void ViewClosed() OVERRIDE; |
161 virtual std::vector<DialogNotification> CurrentNotifications() OVERRIDE; | 152 virtual std::vector<DialogNotification> CurrentNotifications() OVERRIDE; |
162 virtual std::vector<DialogAutocheckoutStep> CurrentAutocheckoutSteps() | |
163 const OVERRIDE; | |
164 virtual void SignInLinkClicked() OVERRIDE; | 153 virtual void SignInLinkClicked() OVERRIDE; |
165 virtual void NotificationCheckboxStateChanged(DialogNotification::Type type, | 154 virtual void NotificationCheckboxStateChanged(DialogNotification::Type type, |
166 bool checked) OVERRIDE; | 155 bool checked) OVERRIDE; |
167 virtual void LegalDocumentLinkClicked(const ui::Range& range) OVERRIDE; | 156 virtual void LegalDocumentLinkClicked(const ui::Range& range) OVERRIDE; |
168 virtual void OverlayButtonPressed() OVERRIDE; | 157 virtual void OverlayButtonPressed() OVERRIDE; |
169 virtual bool OnCancel() OVERRIDE; | 158 virtual bool OnCancel() OVERRIDE; |
170 virtual bool OnAccept() OVERRIDE; | 159 virtual bool OnAccept() OVERRIDE; |
171 virtual Profile* profile() OVERRIDE; | 160 virtual Profile* profile() OVERRIDE; |
172 virtual content::WebContents* GetWebContents() OVERRIDE; | 161 virtual content::WebContents* GetWebContents() OVERRIDE; |
173 | 162 |
(...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. | 266 // happens via choosing "Add a new X..." from a section's suggestion menu. |
278 bool IsManuallyEditingSection(DialogSection section) const; | 267 bool IsManuallyEditingSection(DialogSection section) const; |
279 | 268 |
280 // Should be called on the Wallet sign-in error. | 269 // Should be called on the Wallet sign-in error. |
281 virtual void OnWalletSigninError(); | 270 virtual void OnWalletSigninError(); |
282 | 271 |
283 // Whether the information input in this dialog will be securely transmitted | 272 // Whether the information input in this dialog will be securely transmitted |
284 // to the requesting site. | 273 // to the requesting site. |
285 virtual bool TransmissionWillBeSecure() const; | 274 virtual bool TransmissionWillBeSecure() const; |
286 | 275 |
287 AutocheckoutState autocheckout_state() const { return autocheckout_state_; } | |
288 | |
289 // Shows a new credit card saved bubble and passes ownership of |new_card| and | 276 // Shows a new credit card saved bubble and passes ownership of |new_card| and |
290 // |billing_profile| to the bubble. Exposed for testing. | 277 // |billing_profile| to the bubble. Exposed for testing. |
291 virtual void ShowNewCreditCardBubble( | 278 virtual void ShowNewCreditCardBubble( |
292 scoped_ptr<CreditCard> new_card, | 279 scoped_ptr<CreditCard> new_card, |
293 scoped_ptr<AutofillProfile> billing_profile); | 280 scoped_ptr<AutofillProfile> billing_profile); |
294 | 281 |
295 private: | 282 private: |
296 // Whether or not the current request wants credit info back. | 283 // Whether or not the current request wants credit info back. |
297 bool RequestingCreditCardInfo() const; | 284 bool RequestingCreditCardInfo() const; |
298 | 285 |
(...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|. | 513 // Logs metrics when the edit ui is shown for the given |section|. |
527 void LogEditUiShownMetric(DialogSection section); | 514 void LogEditUiShownMetric(DialogSection section); |
528 | 515 |
529 // Logs metrics when a suggestion item from the given |model| is selected. | 516 // Logs metrics when a suggestion item from the given |model| is selected. |
530 void LogSuggestionItemSelectedMetric(const SuggestionsMenuModel& model); | 517 void LogSuggestionItemSelectedMetric(const SuggestionsMenuModel& model); |
531 | 518 |
532 // Logs the time elapsed from when the dialog was shown to when the user could | 519 // Logs the time elapsed from when the dialog was shown to when the user could |
533 // interact with it. | 520 // interact with it. |
534 void LogDialogLatencyToShow(); | 521 void LogDialogLatencyToShow(); |
535 | 522 |
536 // Sets the state of the autocheckout flow. | |
537 void SetAutocheckoutState(AutocheckoutState autocheckout_state); | |
538 | |
539 // Obscures the web contents. | |
540 void DeemphasizeRenderView(); | |
541 | |
542 // Returns the metric corresponding to the user's initial state when | 523 // Returns the metric corresponding to the user's initial state when |
543 // interacting with this dialog. | 524 // interacting with this dialog. |
544 AutofillMetrics::DialogInitialUserStateMetric GetInitialUserState() const; | 525 AutofillMetrics::DialogInitialUserStateMetric GetInitialUserState() const; |
545 | 526 |
546 // Shows an educational bubble if a new credit card was saved or the first few | 527 // Shows an educational bubble if a new credit card was saved or the first few |
547 // times an Online Wallet fronting card was generated. | 528 // times an Online Wallet fronting card was generated. |
548 void MaybeShowCreditCardBubble(); | 529 void MaybeShowCreditCardBubble(); |
549 | 530 |
550 // The |profile| for |contents_|. | 531 // The |profile| for |contents_|. |
551 Profile* const profile_; | 532 Profile* const profile_; |
552 | 533 |
553 // For logging UMA metrics. | 534 // For logging UMA metrics. |
554 const AutofillMetrics metric_logger_; | 535 const AutofillMetrics metric_logger_; |
555 base::Time dialog_shown_timestamp_; | 536 base::Time dialog_shown_timestamp_; |
556 AutofillMetrics::DialogInitialUserStateMetric initial_user_state_; | 537 AutofillMetrics::DialogInitialUserStateMetric initial_user_state_; |
557 | 538 |
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. | 539 // Whether this is an Autocheckout or a requestAutocomplete dialog. |
563 const DialogType dialog_type_; | 540 const DialogType dialog_type_; |
564 | 541 |
565 FormStructure form_structure_; | 542 FormStructure form_structure_; |
566 | 543 |
567 // Whether the URL visible to the user when this dialog was requested to be | 544 // Whether the URL visible to the user when this dialog was requested to be |
568 // invoked is the same as |source_url_|. | 545 // invoked is the same as |source_url_|. |
569 bool invoked_from_same_origin_; | 546 bool invoked_from_same_origin_; |
570 | 547 |
571 // The URL of the invoking site. | 548 // The URL of the invoking site. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 | 660 |
684 // Whether |callback_| was Run() with a filled |form_structure_|. | 661 // Whether |callback_| was Run() with a filled |form_structure_|. |
685 bool data_was_passed_back_; | 662 bool data_was_passed_back_; |
686 | 663 |
687 typedef std::map<ServerFieldType, | 664 typedef std::map<ServerFieldType, |
688 std::pair<base::string16, base::string16> > TypeErrorInputMap; | 665 std::pair<base::string16, base::string16> > TypeErrorInputMap; |
689 typedef std::map<DialogSection, TypeErrorInputMap> WalletValidationErrors; | 666 typedef std::map<DialogSection, TypeErrorInputMap> WalletValidationErrors; |
690 // Wallet validation errors. section->type->(error_msg, input_value). | 667 // Wallet validation errors. section->type->(error_msg, input_value). |
691 WalletValidationErrors wallet_errors_; | 668 WalletValidationErrors wallet_errors_; |
692 | 669 |
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. | 670 // Whether the latency to display to the UI was logged to UMA yet. |
697 bool was_ui_latency_logged_; | 671 bool was_ui_latency_logged_; |
698 | 672 |
699 // Whether or not the render view has been deemphasized. | |
700 bool deemphasized_render_view_; | |
701 | |
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 | 673 // The Google Wallet cookie value, set as an authorization header on requests |
707 // to Wallet. | 674 // to Wallet. |
708 std::string wallet_cookie_value_; | 675 std::string wallet_cookie_value_; |
709 | 676 |
710 // Populated if the user chose to save a newly inputted credit card. Used to | 677 // 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 | 678 // 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). | 679 // saved. Never populated while incognito (as nothing's actually saved). |
713 scoped_ptr<CreditCard> newly_saved_card_; | 680 scoped_ptr<CreditCard> newly_saved_card_; |
714 | 681 |
715 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl); | 682 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl); |
716 }; | 683 }; |
717 | 684 |
718 } // namespace autofill | 685 } // namespace autofill |
719 | 686 |
720 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ | 687 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ |
OLD | NEW |