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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 virtual bool HadAutocheckoutError() const OVERRIDE; | 110 virtual bool HadAutocheckoutError() const OVERRIDE; |
112 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; | 111 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; |
113 virtual const std::vector<ui::Range>& LegalDocumentLinks() OVERRIDE; | 112 virtual const std::vector<ui::Range>& LegalDocumentLinks() OVERRIDE; |
114 virtual bool SectionIsActive(DialogSection section) const OVERRIDE; | 113 virtual bool SectionIsActive(DialogSection section) const OVERRIDE; |
115 virtual const DetailInputs& RequestedFieldsForSection(DialogSection section) | 114 virtual const DetailInputs& RequestedFieldsForSection(DialogSection section) |
116 const OVERRIDE; | 115 const OVERRIDE; |
117 virtual ui::ComboboxModel* ComboboxModelForAutofillType( | 116 virtual ui::ComboboxModel* ComboboxModelForAutofillType( |
118 AutofillFieldType type) OVERRIDE; | 117 AutofillFieldType type) OVERRIDE; |
119 virtual ui::MenuModel* MenuModelForSection(DialogSection section) OVERRIDE; | 118 virtual ui::MenuModel* MenuModelForSection(DialogSection section) OVERRIDE; |
120 virtual string16 LabelForSection(DialogSection section) const OVERRIDE; | 119 virtual string16 LabelForSection(DialogSection section) const OVERRIDE; |
121 virtual string16 SuggestionTextForSection(DialogSection section) OVERRIDE; | 120 virtual SuggestionState SuggestionStateForSection( |
122 virtual gfx::Image SuggestionIconForSection(DialogSection section) OVERRIDE; | 121 DialogSection section) OVERRIDE; |
123 virtual void EditClickedForSection(DialogSection section) OVERRIDE; | 122 virtual void EditClickedForSection(DialogSection section) OVERRIDE; |
124 virtual void EditCancelledForSection(DialogSection section) OVERRIDE; | 123 virtual void EditCancelledForSection(DialogSection section) OVERRIDE; |
125 virtual gfx::Image IconForField(AutofillFieldType type, | 124 virtual gfx::Image IconForField(AutofillFieldType type, |
126 const string16& user_input) const OVERRIDE; | 125 const string16& user_input) const OVERRIDE; |
127 virtual bool InputIsValid(AutofillFieldType type, const string16& value) | 126 virtual bool InputIsValid(AutofillFieldType type, const string16& value) |
128 OVERRIDE; | 127 OVERRIDE; |
129 virtual std::vector<AutofillFieldType> InputsAreValid( | 128 virtual std::vector<AutofillFieldType> InputsAreValid( |
130 const DetailOutputMap& inputs, ValidationType validation_type) OVERRIDE; | 129 const DetailOutputMap& inputs, ValidationType validation_type) OVERRIDE; |
131 virtual void UserEditedOrActivatedInput(const DetailInput* input, | 130 virtual void UserEditedOrActivatedInput(const DetailInput* input, |
132 DialogSection section, | 131 DialogSection section, |
133 gfx::NativeView parent_view, | 132 gfx::NativeView parent_view, |
134 const gfx::Rect& content_bounds, | 133 const gfx::Rect& content_bounds, |
135 const string16& field_contents, | 134 const string16& field_contents, |
136 bool was_edit) OVERRIDE; | 135 bool was_edit) OVERRIDE; |
137 virtual bool HandleKeyPressEventInInput( | 136 virtual bool HandleKeyPressEventInInput( |
138 const content::NativeWebKeyboardEvent& event) OVERRIDE; | 137 const content::NativeWebKeyboardEvent& event) OVERRIDE; |
139 virtual void FocusMoved() OVERRIDE; | 138 virtual void FocusMoved() OVERRIDE; |
140 virtual void ViewClosed() OVERRIDE; | 139 virtual void ViewClosed() OVERRIDE; |
141 virtual std::vector<DialogNotification> CurrentNotifications() const OVERRIDE; | 140 virtual std::vector<DialogNotification> CurrentNotifications() const OVERRIDE; |
142 virtual void StartSignInFlow() OVERRIDE; | 141 virtual void StartSignInFlow() OVERRIDE; |
143 virtual void EndSignInFlow() OVERRIDE; | 142 virtual void EndSignInFlow() OVERRIDE; |
144 virtual void LegalDocumentLinkClicked(const ui::Range& range) OVERRIDE; | 143 virtual void LegalDocumentLinkClicked(const ui::Range& range) OVERRIDE; |
145 virtual void OnCancel() OVERRIDE; | 144 virtual void OnCancel() OVERRIDE; |
146 virtual void OnSubmit() OVERRIDE; | 145 virtual void OnAccept() OVERRIDE; |
147 virtual Profile* profile() OVERRIDE; | 146 virtual Profile* profile() OVERRIDE; |
148 virtual content::WebContents* web_contents() OVERRIDE; | 147 virtual content::WebContents* web_contents() OVERRIDE; |
149 | 148 |
150 // AutofillPopupDelegate implementation. | 149 // AutofillPopupDelegate implementation. |
151 virtual void OnPopupShown(content::KeyboardListener* listener) OVERRIDE; | 150 virtual void OnPopupShown(content::KeyboardListener* listener) OVERRIDE; |
152 virtual void OnPopupHidden(content::KeyboardListener* listener) OVERRIDE; | 151 virtual void OnPopupHidden(content::KeyboardListener* listener) OVERRIDE; |
153 virtual void DidSelectSuggestion(int identifier) OVERRIDE; | 152 virtual void DidSelectSuggestion(int identifier) OVERRIDE; |
154 virtual void DidAcceptSuggestion(const string16& value, | 153 virtual void DidAcceptSuggestion(const string16& value, |
155 int identifier) OVERRIDE; | 154 int identifier) OVERRIDE; |
156 virtual void RemoveSuggestion(const string16& value, | 155 virtual void RemoveSuggestion(const string16& value, |
(...skipping 139 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 | 462 |
448 // For logging UMA metrics. | 463 // For logging UMA metrics. |
449 const AutofillMetrics& metric_logger_; | 464 const AutofillMetrics& metric_logger_; |
450 base::Time dialog_shown_timestamp_; | 465 base::Time dialog_shown_timestamp_; |
451 base::Time autocheckout_started_timestamp_; | 466 base::Time autocheckout_started_timestamp_; |
452 AutofillMetrics::DialogInitialUserStateMetric initial_user_state_; | 467 AutofillMetrics::DialogInitialUserStateMetric initial_user_state_; |
453 | 468 |
454 // Whether this is an Autocheckout or a requestAutocomplete dialog. | 469 // Whether this is an Autocheckout or a requestAutocomplete dialog. |
455 const DialogType dialog_type_; | 470 const DialogType dialog_type_; |
456 | 471 |
457 // True if the termination action was a submit. | 472 // True after the user first accepts the dialog and presses "Submit". May |
458 bool did_submit_; | 473 // continue to be true while processing required actions. |
| 474 bool is_submitting_; |
459 | 475 |
460 // Whether or not an Autocheckout flow is running. | 476 // Whether or not an Autocheckout flow is running. |
461 bool autocheckout_is_running_; | 477 bool autocheckout_is_running_; |
462 | 478 |
463 // Whether or not there was an error in the Autocheckout flow. | 479 // Whether or not there was an error in the Autocheckout flow. |
464 bool had_autocheckout_error_; | 480 bool had_autocheckout_error_; |
465 | 481 |
466 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl); | 482 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl); |
467 }; | 483 }; |
468 | 484 |
469 } // namespace autofill | 485 } // namespace autofill |
470 | 486 |
471 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ | 487 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ |
OLD | NEW |