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 <map> | 8 #include <map> |
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/string16.h" | 14 #include "base/string16.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" | 16 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" |
17 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" | 17 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" |
18 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" | 18 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" |
19 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" | 19 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" |
20 #include "chrome/browser/ui/autofill/country_combobox_model.h" | 20 #include "chrome/browser/ui/autofill/country_combobox_model.h" |
21 #include "components/autofill/browser/autofill_manager_delegate.h" | 21 #include "components/autofill/browser/autofill_manager_delegate.h" |
22 #include "components/autofill/browser/autofill_metrics.h" | 22 #include "components/autofill/browser/autofill_metrics.h" |
23 #include "components/autofill/browser/autofill_popup_delegate.h" | 23 #include "components/autofill/browser/autofill_popup_delegate.h" |
24 #include "components/autofill/browser/field_types.h" | 24 #include "components/autofill/browser/field_types.h" |
25 #include "components/autofill/browser/form_structure.h" | 25 #include "components/autofill/browser/form_structure.h" |
26 #include "components/autofill/browser/personal_data_manager.h" | 26 #include "components/autofill/browser/personal_data_manager.h" |
27 #include "components/autofill/browser/personal_data_manager_observer.h" | 27 #include "components/autofill/browser/personal_data_manager_observer.h" |
28 #include "components/autofill/browser/wallet/required_action.h" | |
29 #include "components/autofill/browser/wallet/wallet_client.h" | 28 #include "components/autofill/browser/wallet/wallet_client.h" |
30 #include "components/autofill/browser/wallet/wallet_client_delegate.h" | 29 #include "components/autofill/browser/wallet/wallet_client_delegate.h" |
31 #include "components/autofill/browser/wallet/wallet_signin_helper_delegate.h" | 30 #include "components/autofill/browser/wallet/wallet_signin_helper_delegate.h" |
32 #include "content/public/browser/notification_observer.h" | 31 #include "content/public/browser/notification_observer.h" |
33 #include "content/public/browser/notification_registrar.h" | 32 #include "content/public/browser/notification_registrar.h" |
34 #include "content/public/common/ssl_status.h" | 33 #include "content/public/common/ssl_status.h" |
35 #include "googleurl/src/gurl.h" | 34 #include "googleurl/src/gurl.h" |
36 #include "ui/base/models/simple_menu_model.h" | 35 #include "ui/base/models/simple_menu_model.h" |
37 #include "ui/base/ui_base_types.h" | 36 #include "ui/base/ui_base_types.h" |
38 | 37 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 virtual bool HadAutocheckoutError() const OVERRIDE; | 111 virtual bool HadAutocheckoutError() const OVERRIDE; |
113 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; | 112 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; |
114 virtual const std::vector<ui::Range>& LegalDocumentLinks() OVERRIDE; | 113 virtual const std::vector<ui::Range>& LegalDocumentLinks() OVERRIDE; |
115 virtual bool SectionIsActive(DialogSection section) const OVERRIDE; | 114 virtual bool SectionIsActive(DialogSection section) const OVERRIDE; |
116 virtual const DetailInputs& RequestedFieldsForSection(DialogSection section) | 115 virtual const DetailInputs& RequestedFieldsForSection(DialogSection section) |
117 const OVERRIDE; | 116 const OVERRIDE; |
118 virtual ui::ComboboxModel* ComboboxModelForAutofillType( | 117 virtual ui::ComboboxModel* ComboboxModelForAutofillType( |
119 AutofillFieldType type) OVERRIDE; | 118 AutofillFieldType type) OVERRIDE; |
120 virtual ui::MenuModel* MenuModelForSection(DialogSection section) OVERRIDE; | 119 virtual ui::MenuModel* MenuModelForSection(DialogSection section) OVERRIDE; |
121 virtual string16 LabelForSection(DialogSection section) const OVERRIDE; | 120 virtual string16 LabelForSection(DialogSection section) const OVERRIDE; |
122 virtual string16 SuggestionTextForSection(DialogSection section) OVERRIDE; | 121 virtual SuggestionState SuggestionStateForSection( |
123 virtual gfx::Image SuggestionIconForSection(DialogSection section) OVERRIDE; | 122 DialogSection section) OVERRIDE; |
124 virtual void EditClickedForSection(DialogSection section) OVERRIDE; | 123 virtual void EditClickedForSection(DialogSection section) OVERRIDE; |
125 virtual void EditCancelledForSection(DialogSection section) OVERRIDE; | 124 virtual void EditCancelledForSection(DialogSection section) OVERRIDE; |
126 virtual gfx::Image IconForField(AutofillFieldType type, | 125 virtual gfx::Image IconForField(AutofillFieldType type, |
127 const string16& user_input) const OVERRIDE; | 126 const string16& user_input) const OVERRIDE; |
128 virtual bool InputIsValid(AutofillFieldType type, const string16& value) | 127 virtual bool InputIsValid(AutofillFieldType type, const string16& value) |
129 OVERRIDE; | 128 OVERRIDE; |
130 virtual std::vector<AutofillFieldType> InputsAreValid( | 129 virtual std::vector<AutofillFieldType> InputsAreValid( |
131 const DetailOutputMap& inputs, ValidationType validation_type) OVERRIDE; | 130 const DetailOutputMap& inputs, ValidationType validation_type) OVERRIDE; |
132 virtual void UserEditedOrActivatedInput(const DetailInput* input, | 131 virtual void UserEditedOrActivatedInput(const DetailInput* input, |
133 DialogSection section, | 132 DialogSection section, |
134 gfx::NativeView parent_view, | 133 gfx::NativeView parent_view, |
135 const gfx::Rect& content_bounds, | 134 const gfx::Rect& content_bounds, |
136 const string16& field_contents, | 135 const string16& field_contents, |
137 bool was_edit) OVERRIDE; | 136 bool was_edit) OVERRIDE; |
138 virtual bool HandleKeyPressEventInInput( | 137 virtual bool HandleKeyPressEventInInput( |
139 const content::NativeWebKeyboardEvent& event) OVERRIDE; | 138 const content::NativeWebKeyboardEvent& event) OVERRIDE; |
140 virtual void FocusMoved() OVERRIDE; | 139 virtual void FocusMoved() OVERRIDE; |
141 virtual void ViewClosed() OVERRIDE; | 140 virtual void ViewClosed() OVERRIDE; |
142 virtual std::vector<DialogNotification> CurrentNotifications() const OVERRIDE; | 141 virtual std::vector<DialogNotification> CurrentNotifications() const OVERRIDE; |
143 virtual void StartSignInFlow() OVERRIDE; | 142 virtual void StartSignInFlow() OVERRIDE; |
144 virtual void EndSignInFlow() OVERRIDE; | 143 virtual void EndSignInFlow() OVERRIDE; |
145 virtual void LegalDocumentLinkClicked(const ui::Range& range) OVERRIDE; | 144 virtual void LegalDocumentLinkClicked(const ui::Range& range) OVERRIDE; |
146 virtual void OnCancel() OVERRIDE; | 145 virtual void OnCancel() OVERRIDE; |
147 virtual void OnSubmit() OVERRIDE; | 146 virtual void OnAccept() OVERRIDE; |
148 virtual Profile* profile() OVERRIDE; | 147 virtual Profile* profile() OVERRIDE; |
149 virtual content::WebContents* web_contents() OVERRIDE; | 148 virtual content::WebContents* web_contents() OVERRIDE; |
150 | 149 |
151 // AutofillPopupDelegate implementation. | 150 // AutofillPopupDelegate implementation. |
152 virtual void OnPopupShown(content::KeyboardListener* listener) OVERRIDE; | 151 virtual void OnPopupShown(content::KeyboardListener* listener) OVERRIDE; |
153 virtual void OnPopupHidden(content::KeyboardListener* listener) OVERRIDE; | 152 virtual void OnPopupHidden(content::KeyboardListener* listener) OVERRIDE; |
154 virtual void DidSelectSuggestion(int identifier) OVERRIDE; | 153 virtual void DidSelectSuggestion(int identifier) OVERRIDE; |
155 virtual void DidAcceptSuggestion(const string16& value, | 154 virtual void DidAcceptSuggestion(const string16& value, |
156 int identifier) OVERRIDE; | 155 int identifier) OVERRIDE; |
157 virtual void RemoveSuggestion(const string16& value, | 156 virtual void RemoveSuggestion(const string16& value, |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 295 |
297 // Sets the CVC result on |form_structure_| to the value in |cvc|. | 296 // Sets the CVC result on |form_structure_| to the value in |cvc|. |
298 void SetCvcResult(const string16& cvc); | 297 void SetCvcResult(const string16& cvc); |
299 | 298 |
300 // Gets the SuggestionsMenuModel for |section|. | 299 // Gets the SuggestionsMenuModel for |section|. |
301 SuggestionsMenuModel* SuggestionsMenuModelForSection(DialogSection section); | 300 SuggestionsMenuModel* SuggestionsMenuModelForSection(DialogSection section); |
302 // And the reverse. | 301 // And the reverse. |
303 DialogSection SectionForSuggestionsMenuModel( | 302 DialogSection SectionForSuggestionsMenuModel( |
304 const SuggestionsMenuModel& model); | 303 const SuggestionsMenuModel& model); |
305 | 304 |
| 305 // Suggested text and icons for sections. Suggestion text is used to show an |
| 306 // abidged overview of the currently used suggestion. Extra text is used when |
| 307 // part of a section is suggested but part must be manually input (e.g. during |
| 308 // a CVC challenge or when using Autofill's CC section [never stores CVC]). |
| 309 string16 SuggestionTextForSection(DialogSection section); |
| 310 string16 RequiredActionTextForSection(DialogSection section) const; |
| 311 gfx::Image SuggestionIconForSection(DialogSection section); |
| 312 string16 ExtraSuggestionTextForSection(DialogSection section) const; |
| 313 gfx::Image ExtraSuggestionIconForSection(DialogSection section) const; |
| 314 |
| 315 // Whether |section| should be showing an "Edit" link. |
| 316 bool EditEnabledForSection(DialogSection section) const; |
| 317 |
306 // Loads profiles that can suggest data for |type|. |field_contents| is the | 318 // Loads profiles that can suggest data for |type|. |field_contents| is the |
307 // part the user has already typed. |inputs| is the rest of section. | 319 // part the user has already typed. |inputs| is the rest of section. |
308 // Identifying info is loaded into the last three outparams as well as | 320 // Identifying info is loaded into the last three outparams as well as |
309 // |popup_guids_|. | 321 // |popup_guids_|. |
310 void GetProfileSuggestions( | 322 void GetProfileSuggestions( |
311 AutofillFieldType type, | 323 AutofillFieldType type, |
312 const string16& field_contents, | 324 const string16& field_contents, |
313 const DetailInputs& inputs, | 325 const DetailInputs& inputs, |
314 std::vector<string16>* popup_values, | 326 std::vector<string16>* popup_values, |
315 std::vector<string16>* popup_labels, | 327 std::vector<string16>* popup_labels, |
(...skipping 22 matching lines...) Expand all Loading... |
338 | 350 |
339 // Start the submit proccess to interact with Online Wallet (might do various | 351 // Start the submit proccess to interact with Online Wallet (might do various |
340 // things like accept documents, save details, update details, respond to | 352 // things like accept documents, save details, update details, respond to |
341 // required actions, etc.). | 353 // required actions, etc.). |
342 void SubmitWithWallet(); | 354 void SubmitWithWallet(); |
343 | 355 |
344 // Gets a full wallet from Online Wallet so the user can purchase something. | 356 // Gets a full wallet from Online Wallet so the user can purchase something. |
345 // This information is decoded to reveal a fronting (proxy) card. | 357 // This information is decoded to reveal a fronting (proxy) card. |
346 void GetFullWallet(); | 358 void GetFullWallet(); |
347 | 359 |
| 360 // Whether submission is currently waiting for |action| to be handled. |
| 361 bool IsSubmitPausedOn(wallet::RequiredAction action) const; |
| 362 |
348 // Called when there's nothing left to accept, update, save, or authenticate | 363 // Called when there's nothing left to accept, update, save, or authenticate |
349 // in order to fill |form_structure_| and pass data back to the invoking page. | 364 // in order to fill |form_structure_| and pass data back to the invoking page. |
350 void FinishSubmit(); | 365 void FinishSubmit(); |
351 | 366 |
352 AutofillMetrics::DialogInitialUserStateMetric GetInitialUserState() const; | 367 AutofillMetrics::DialogInitialUserStateMetric GetInitialUserState() const; |
353 | 368 |
354 // The |profile| for |contents_|. | 369 // The |profile| for |contents_|. |
355 Profile* const profile_; | 370 Profile* const profile_; |
356 | 371 |
357 // The WebContents where the Autofill action originated. | 372 // The WebContents where the Autofill action originated. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 | 463 |
449 // For logging UMA metrics. | 464 // For logging UMA metrics. |
450 const AutofillMetrics& metric_logger_; | 465 const AutofillMetrics& metric_logger_; |
451 base::Time dialog_shown_timestamp_; | 466 base::Time dialog_shown_timestamp_; |
452 base::Time autocheckout_started_timestamp_; | 467 base::Time autocheckout_started_timestamp_; |
453 AutofillMetrics::DialogInitialUserStateMetric initial_user_state_; | 468 AutofillMetrics::DialogInitialUserStateMetric initial_user_state_; |
454 | 469 |
455 // Whether this is an Autocheckout or a requestAutocomplete dialog. | 470 // Whether this is an Autocheckout or a requestAutocomplete dialog. |
456 const DialogType dialog_type_; | 471 const DialogType dialog_type_; |
457 | 472 |
458 // True if the termination action was a submit. | 473 // True after the user first accepts the dialog and presses "Submit". May |
459 bool did_submit_; | 474 // continue to be true while processing required actions. |
| 475 bool is_submitting_; |
460 | 476 |
461 // Whether or not an Autocheckout flow is running. | 477 // Whether or not an Autocheckout flow is running. |
462 bool autocheckout_is_running_; | 478 bool autocheckout_is_running_; |
463 | 479 |
464 // Whether or not there was an error in the Autocheckout flow. | 480 // Whether or not there was an error in the Autocheckout flow. |
465 bool had_autocheckout_error_; | 481 bool had_autocheckout_error_; |
466 | 482 |
467 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl); | 483 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl); |
468 }; | 484 }; |
469 | 485 |
470 } // namespace autofill | 486 } // namespace autofill |
471 | 487 |
472 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ | 488 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ |
OLD | NEW |