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/gtest_prod_util.h" | |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
14 #include "base/string16.h" | 15 #include "base/string16.h" |
15 #include "base/time.h" | 16 #include "base/time.h" |
16 #include "chrome/browser/ui/autofill/account_chooser_model.h" | 17 #include "chrome/browser/ui/autofill/account_chooser_model.h" |
17 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" | 18 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" |
18 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" | 19 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" |
19 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" | 20 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" |
20 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" | 21 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" |
21 #include "chrome/browser/ui/autofill/country_combobox_model.h" | 22 #include "chrome/browser/ui/autofill/country_combobox_model.h" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 // Call to disable communication to Online Wallet for this dialog. | 259 // Call to disable communication to Online Wallet for this dialog. |
259 // Exposed for testing. | 260 // Exposed for testing. |
260 void DisableWallet(); | 261 void DisableWallet(); |
261 | 262 |
262 // Returns whether Wallet is the current data source. Exposed for testing. | 263 // Returns whether Wallet is the current data source. Exposed for testing. |
263 virtual bool IsPayingWithWallet() const; | 264 virtual bool IsPayingWithWallet() const; |
264 | 265 |
265 // Exposed and virtual for testing. | 266 // Exposed and virtual for testing. |
266 virtual bool IsFirstRun() const; | 267 virtual bool IsFirstRun() const; |
267 | 268 |
269 // Asks risk module to asynchronously load fingerprint data. Data will be | |
270 // returned via |OnDidLoadRiskFingerprintData()|. Exposed for testing. | |
271 virtual void LoadRiskFingerprintData(); | |
272 | |
268 // Opens the given URL in a new foreground tab. | 273 // Opens the given URL in a new foreground tab. |
269 virtual void OpenTabWithUrl(const GURL& url); | 274 virtual void OpenTabWithUrl(const GURL& url); |
270 | 275 |
271 private: | 276 private: |
277 FRIEND_TEST_ALL_PREFIXES(AutofillDialogControllerTest, AcceptLegalDocuments); | |
278 FRIEND_TEST_ALL_PREFIXES(AutofillDialogControllerTest, VerifyCvv); | |
279 FRIEND_TEST_ALL_PREFIXES(AutofillDialogControllerTest, ErrorDuringSubmit); | |
280 FRIEND_TEST_ALL_PREFIXES(AutofillDialogControllerTest, ErrorDuringVerifyCvv); | |
281 FRIEND_TEST_ALL_PREFIXES(AutofillDialogControllerTest, | |
282 ChangeAccountDuringSubmit); | |
283 FRIEND_TEST_ALL_PREFIXES(AutofillDialogControllerTest, | |
284 ChangeAccountDuringVerifyCvv); | |
285 FRIEND_TEST_ALL_PREFIXES(AutofillDialogControllerTest, | |
286 RiskLoadsWithoutPendingLegalDocuments); | |
287 FRIEND_TEST_ALL_PREFIXES(AutofillDialogControllerTest, | |
288 RiskLoadsAfterAcceptingLegalDocuments); | |
Ilya Sherman
2013/05/22 22:34:24
Rather than adding lots of friend tests, please up
Dan Beam
2013/05/22 23:25:20
Done.
| |
289 | |
272 // Whether or not the current request wants credit info back. | 290 // Whether or not the current request wants credit info back. |
273 bool RequestingCreditCardInfo() const; | 291 bool RequestingCreditCardInfo() const; |
274 | 292 |
275 // Whether the information input in this dialog will be securely transmitted | 293 // Whether the information input in this dialog will be securely transmitted |
276 // to the requesting site. | 294 // to the requesting site. |
277 bool TransmissionWillBeSecure() const; | 295 bool TransmissionWillBeSecure() const; |
278 | 296 |
279 // Initializes |suggested_email_| et al. | 297 // Initializes |suggested_email_| et al. |
280 void SuggestionsUpdated(); | 298 void SuggestionsUpdated(); |
281 | 299 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 std::vector<string16>* popup_values, | 390 std::vector<string16>* popup_values, |
373 std::vector<string16>* popup_labels, | 391 std::vector<string16>* popup_labels, |
374 std::vector<string16>* popup_icons); | 392 std::vector<string16>* popup_icons); |
375 | 393 |
376 // Like RequestedFieldsForSection, but returns a pointer. | 394 // Like RequestedFieldsForSection, but returns a pointer. |
377 DetailInputs* MutableRequestedFieldsForSection(DialogSection section); | 395 DetailInputs* MutableRequestedFieldsForSection(DialogSection section); |
378 | 396 |
379 // Hides |popup_controller_|'s popup view, if it exists. | 397 // Hides |popup_controller_|'s popup view, if it exists. |
380 void HidePopup(); | 398 void HidePopup(); |
381 | 399 |
382 // Asks risk module to asynchronously load fingerprint data. Data will be | 400 // Called when loading of risk fingerprint data is done. |
383 // returned via OnDidLoadRiskFingerprintData. | |
384 void LoadRiskFingerprintData(); | |
385 void OnDidLoadRiskFingerprintData(scoped_ptr<risk::Fingerprint> fingerprint); | 401 void OnDidLoadRiskFingerprintData(scoped_ptr<risk::Fingerprint> fingerprint); |
386 | 402 |
387 // Whether the user has chosen to enter all new data in |section|. This | 403 // Whether the user has chosen to enter all new data in |section|. This |
388 // happens via choosing "Add a new X..." from a section's suggestion menu. | 404 // happens via choosing "Add a new X..." from a section's suggestion menu. |
389 bool IsManuallyEditingSection(DialogSection section) const; | 405 bool IsManuallyEditingSection(DialogSection section) const; |
390 | 406 |
391 // Whether the user has chosen to enter all new data in at least one section. | 407 // Whether the user has chosen to enter all new data in at least one section. |
392 bool IsManuallyEditingAnySection() const; | 408 bool IsManuallyEditingAnySection() const; |
393 | 409 |
394 // Returns true if the |value| is a valid string for the given autofill field | 410 // Returns true if the |value| is a valid string for the given autofill field |
(...skipping 15 matching lines...) Expand all Loading... | |
410 // Whether the billing section should be used to fill in the shipping details. | 426 // Whether the billing section should be used to fill in the shipping details. |
411 bool ShouldUseBillingForShipping(); | 427 bool ShouldUseBillingForShipping(); |
412 | 428 |
413 // Whether the user wishes to save information locally to Autofill. | 429 // Whether the user wishes to save information locally to Autofill. |
414 bool ShouldSaveDetailsLocally(); | 430 bool ShouldSaveDetailsLocally(); |
415 | 431 |
416 // Change whether the controller is currently submitting details to Autofill | 432 // Change whether the controller is currently submitting details to Autofill |
417 // or Online Wallet (|is_submitting_|) and update the view. | 433 // or Online Wallet (|is_submitting_|) and update the view. |
418 void SetIsSubmitting(bool submitting); | 434 void SetIsSubmitting(bool submitting); |
419 | 435 |
436 // Whether the user has accepted all the current legal documents' terms. | |
437 bool LegalDocumentsAreCurrent() const; | |
438 | |
420 // Start the submit proccess to interact with Online Wallet (might do various | 439 // Start the submit proccess to interact with Online Wallet (might do various |
421 // things like accept documents, save details, update details, respond to | 440 // things like accept documents, save details, update details, respond to |
422 // required actions, etc.). | 441 // required actions, etc.). |
423 void SubmitWithWallet(); | 442 void SubmitWithWallet(); |
424 | 443 |
425 // Creates an instrument based on |views_|' contents. | 444 // Creates an instrument based on |views_|' contents. |
426 scoped_ptr<wallet::Instrument> CreateTransientInstrument(); | 445 scoped_ptr<wallet::Instrument> CreateTransientInstrument(); |
427 | 446 |
428 // Creates an update request based on |instrument|. May return NULL. | 447 // Creates an update request based on |instrument|. May return NULL. |
429 scoped_ptr<wallet::WalletClient::UpdateInstrumentRequest> | 448 scoped_ptr<wallet::WalletClient::UpdateInstrumentRequest> |
430 CreateUpdateInstrumentRequest(const wallet::Instrument* instrument, | 449 CreateUpdateInstrumentRequest(const wallet::Instrument* instrument, |
431 const std::string& instrument_id); | 450 const std::string& instrument_id); |
432 | 451 |
433 // Creates an address based on the contents of |view_|. | 452 // Creates an address based on the contents of |view_|. |
434 scoped_ptr<wallet::Address> CreateTransientAddress(); | 453 scoped_ptr<wallet::Address> CreateTransientAddress(); |
435 | 454 |
436 // Gets a full wallet from Online Wallet so the user can purchase something. | 455 // Gets a full wallet from Online Wallet so the user can purchase something if |
Ilya Sherman
2013/05/22 22:34:24
nit: Spurious diff.
Dan Beam
2013/05/22 23:25:20
Done.
| |
437 // This information is decoded to reveal a fronting (proxy) card. | 456 // This information is decoded to reveal a fronting (proxy) card. |
438 void GetFullWallet(); | 457 void GetFullWallet(); |
439 | 458 |
459 // Calls |GetFullWallet()| if the required members (|risk_data_|, | |
460 // |active_instrument_id_|, and |active_address_id_|) are populated. | |
461 void GetFullWalletIfReady(); | |
462 | |
440 // Updates the state of the controller and |view_| based on any required | 463 // Updates the state of the controller and |view_| based on any required |
441 // actions returned by Save or Update calls to Wallet. | 464 // actions returned by Save or Update calls to Wallet. |
442 void HandleSaveOrUpdateRequiredActions( | 465 void HandleSaveOrUpdateRequiredActions( |
443 const std::vector<wallet::RequiredAction>& required_actions); | 466 const std::vector<wallet::RequiredAction>& required_actions); |
444 | 467 |
445 // Whether submission is currently waiting for |action| to be handled. | 468 // Whether submission is currently waiting for |action| to be handled. |
446 bool IsSubmitPausedOn(wallet::RequiredAction action) const; | 469 bool IsSubmitPausedOn(wallet::RequiredAction action) const; |
447 | 470 |
448 // Called when there's nothing left to accept, update, save, or authenticate | 471 // Called when there's nothing left to accept, update, save, or authenticate |
449 // in order to fill |form_structure_| and pass data back to the invoking page. | 472 // in order to fill |form_structure_| and pass data back to the invoking page. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
511 // The helper is set only during fetch/sign-in, and NULL otherwise. | 534 // The helper is set only during fetch/sign-in, and NULL otherwise. |
512 scoped_ptr<wallet::WalletSigninHelper> signin_helper_; | 535 scoped_ptr<wallet::WalletSigninHelper> signin_helper_; |
513 | 536 |
514 // A client to talk to the Online Wallet API. | 537 // A client to talk to the Online Wallet API. |
515 wallet::WalletClient wallet_client_; | 538 wallet::WalletClient wallet_client_; |
516 | 539 |
517 // Recently received items retrieved via |wallet_client_|. | 540 // Recently received items retrieved via |wallet_client_|. |
518 scoped_ptr<wallet::WalletItems> wallet_items_; | 541 scoped_ptr<wallet::WalletItems> wallet_items_; |
519 scoped_ptr<wallet::FullWallet> full_wallet_; | 542 scoped_ptr<wallet::FullWallet> full_wallet_; |
520 | 543 |
544 // Local machine signals to pass along on each request to trigger (or | |
545 // discourage) risk challenges; sent if the user is up to date on legal docs. | |
546 std::string risk_data_; | |
547 | |
521 // The text to display when the user is accepting new terms of service, etc. | 548 // The text to display when the user is accepting new terms of service, etc. |
522 string16 legal_documents_text_; | 549 string16 legal_documents_text_; |
523 // The ranges within |legal_documents_text_| to linkify. | 550 // The ranges within |legal_documents_text_| to linkify. |
524 std::vector<ui::Range> legal_document_link_ranges_; | 551 std::vector<ui::Range> legal_document_link_ranges_; |
525 | 552 |
526 // The instrument and address IDs from the Online Wallet server to be used | 553 // The instrument and address IDs from the Online Wallet server to be used |
527 // when getting a full wallet. | 554 // when getting a full wallet. |
528 std::string active_instrument_id_; | 555 std::string active_instrument_id_; |
529 std::string active_address_id_; | 556 std::string active_address_id_; |
530 | 557 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
567 scoped_ptr<AutofillDialogView> view_; | 594 scoped_ptr<AutofillDialogView> view_; |
568 | 595 |
569 // A NotificationRegistrar for tracking the completion of sign-in. | 596 // A NotificationRegistrar for tracking the completion of sign-in. |
570 content::NotificationRegistrar signin_registrar_; | 597 content::NotificationRegistrar signin_registrar_; |
571 | 598 |
572 base::WeakPtrFactory<AutofillDialogControllerImpl> weak_ptr_factory_; | 599 base::WeakPtrFactory<AutofillDialogControllerImpl> weak_ptr_factory_; |
573 | 600 |
574 // Whether this is the first time this profile has seen the Autofill dialog. | 601 // Whether this is the first time this profile has seen the Autofill dialog. |
575 bool is_first_run_; | 602 bool is_first_run_; |
576 | 603 |
604 // Whether a user accepted legal documents while this dialog is running. | |
605 bool accepted_legal_documents_; | |
Ilya Sherman
2013/05/22 22:34:24
nit: "has_accepted_..."
Dan Beam
2013/05/22 23:25:20
Done.
| |
606 | |
577 // True after the user first accepts the dialog and presses "Submit". May | 607 // True after the user first accepts the dialog and presses "Submit". May |
578 // continue to be true while processing required actions. | 608 // continue to be true while processing required actions. |
579 bool is_submitting_; | 609 bool is_submitting_; |
580 | 610 |
581 // Whether or not there was a server side validation error saving or updating | 611 // Whether or not there was a server side validation error saving or updating |
582 // Wallet data. | 612 // Wallet data. |
583 bool wallet_server_validation_error_; | 613 bool wallet_server_validation_error_; |
584 | 614 |
585 // The current state of the Autocheckout flow. | 615 // The current state of the Autocheckout flow. |
586 AutocheckoutState autocheckout_state_; | 616 AutocheckoutState autocheckout_state_; |
587 | 617 |
588 // Whether the latency to display to the UI was logged to UMA yet. | 618 // Whether the latency to display to the UI was logged to UMA yet. |
589 bool was_ui_latency_logged_; | 619 bool was_ui_latency_logged_; |
590 | 620 |
591 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl); | 621 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl); |
592 }; | 622 }; |
593 | 623 |
594 } // namespace autofill | 624 } // namespace autofill |
595 | 625 |
596 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ | 626 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ |
OLD | NEW |