Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: chrome/browser/ui/autofill/save_card_bubble_controller_impl.h

Issue 2789843004: [Payments] Upload card UI now has a CVC prompt (Closed)
Patch Set: Address code review comment Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_ 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_
6 #define CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_ 6 #define CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/timer/elapsed_timer.h" 11 #include "base/timer/elapsed_timer.h"
12 #include "chrome/browser/ui/autofill/save_card_bubble_controller.h"
13 #include "components/autofill/core/browser/credit_card.h" 12 #include "components/autofill/core/browser/credit_card.h"
13 #include "components/autofill/core/browser/ui/save_card_bubble_controller.h"
14 #include "content/public/browser/web_contents_observer.h" 14 #include "content/public/browser/web_contents_observer.h"
15 #include "content/public/browser/web_contents_user_data.h" 15 #include "content/public/browser/web_contents_user_data.h"
16 16
17 namespace autofill { 17 namespace autofill {
18 18
19 // Implementation of per-tab class to control the save credit card bubble and 19 // Implementation of per-tab class to control the save credit card bubble and
20 // Omnibox icon. 20 // Omnibox icon.
21 class SaveCardBubbleControllerImpl 21 class SaveCardBubbleControllerImpl
22 : public SaveCardBubbleController, 22 : public SaveCardBubbleController,
23 public content::WebContentsObserver, 23 public content::WebContentsObserver,
24 public content::WebContentsUserData<SaveCardBubbleControllerImpl> { 24 public content::WebContentsUserData<SaveCardBubbleControllerImpl> {
25 public: 25 public:
26 // Sets up the controller for local save and shows the bubble. 26 // Sets up the controller for local save and shows the bubble.
27 // |save_card_callback| will be invoked if and when the Save button is 27 // |save_card_callback| will be invoked if and when the Save button is
28 // pressed. 28 // pressed.
29 void ShowBubbleForLocalSave(const CreditCard& card, 29 void ShowBubbleForLocalSave(const CreditCard& card,
30 const base::Closure& save_card_callback); 30 const base::Closure& save_card_callback);
31 31
32 // Sets up the controller for upload and shows the bubble. 32 // Sets up the controller for upload and shows the bubble.
33 // |save_card_callback| will be invoked if and when the Save button is 33 // |save_card_callback| will be invoked if and when the Save button is
34 // pressed. The contents of |legal_message| will be displayed in the bubble. 34 // pressed. The contents of |legal_message| will be displayed in the bubble.
35 // A field requesting CVC will appear in the bubble if
36 // |should_cvc_be_requested| is true.
35 void ShowBubbleForUpload(const CreditCard& card, 37 void ShowBubbleForUpload(const CreditCard& card,
36 std::unique_ptr<base::DictionaryValue> legal_message, 38 std::unique_ptr<base::DictionaryValue> legal_message,
39 bool should_cvc_be_requested,
37 const base::Closure& save_card_callback); 40 const base::Closure& save_card_callback);
38 41
39 void HideBubble(); 42 void HideBubble();
40 void ReshowBubble(); 43 void ReshowBubble();
41 44
42 // Returns true if Omnibox save credit card icon should be visible. 45 // Returns true if Omnibox save credit card icon should be visible.
43 bool IsIconVisible() const; 46 bool IsIconVisible() const;
44 47
45 // Returns nullptr if no bubble is currently shown. 48 // Returns nullptr if no bubble is currently shown.
46 SaveCardBubbleView* save_card_bubble_view() const; 49 SaveCardBubbleView* save_card_bubble_view() const;
47 50
48 // SaveCardBubbleController: 51 // SaveCardBubbleController:
49 base::string16 GetWindowTitle() const override; 52 base::string16 GetWindowTitle() const override;
50 base::string16 GetExplanatoryMessage() const override; 53 base::string16 GetExplanatoryMessage() const override;
51 const CreditCard GetCard() const override; 54 const CreditCard GetCard() const override;
52 void OnSaveButton() override; 55 int GetCvcImageResourceId() const override;
56 bool ShouldRequestCvcFromUser() const override;
57 base::string16 GetCvcEnteredByUser() const override;
58 void OnSaveButton(const base::string16& cvc = base::string16()) override;
53 void OnCancelButton() override; 59 void OnCancelButton() override;
54 void OnLearnMoreClicked() override; 60 void OnLearnMoreClicked() override;
55 void OnLegalMessageLinkClicked(const GURL& url) override; 61 void OnLegalMessageLinkClicked(const GURL& url) override;
56 void OnBubbleClosed() override; 62 void OnBubbleClosed() override;
57 63
58 const LegalMessageLines& GetLegalMessageLines() const override; 64 const LegalMessageLines& GetLegalMessageLines() const override;
59 65
66 // Used to check if an entered CVC value is a valid CVC for the current card.
67 // Valid CVCs are a certain length for their card type (4 for AMEX, 3
68 // otherwise) and are comprised only of numbers.
69 bool InputCvcIsValid(const base::string16& input_text) const override;
70
60 protected: 71 protected:
61 explicit SaveCardBubbleControllerImpl(content::WebContents* web_contents); 72 explicit SaveCardBubbleControllerImpl(content::WebContents* web_contents);
62 ~SaveCardBubbleControllerImpl() override; 73 ~SaveCardBubbleControllerImpl() override;
63 74
64 // Returns the time elapsed since |timer_| was initialized. 75 // Returns the time elapsed since |timer_| was initialized.
65 // Exists for testing. 76 // Exists for testing.
66 virtual base::TimeDelta Elapsed() const; 77 virtual base::TimeDelta Elapsed() const;
67 78
68 // content::WebContentsObserver: 79 // content::WebContentsObserver:
69 void DidFinishNavigation( 80 void DidFinishNavigation(
(...skipping 11 matching lines...) Expand all
81 92
82 // Weak reference. Will be nullptr if no bubble is currently shown. 93 // Weak reference. Will be nullptr if no bubble is currently shown.
83 SaveCardBubbleView* save_card_bubble_view_; 94 SaveCardBubbleView* save_card_bubble_view_;
84 95
85 // Callback to run if user presses Save button in the bubble. 96 // Callback to run if user presses Save button in the bubble.
86 // If save_card_callback_.is_null() is true then no bubble is available to 97 // If save_card_callback_.is_null() is true then no bubble is available to
87 // show and the icon is not visible. 98 // show and the icon is not visible.
88 base::Closure save_card_callback_; 99 base::Closure save_card_callback_;
89 100
90 // Governs whether the upload or local save version of the UI should be shown. 101 // Governs whether the upload or local save version of the UI should be shown.
91 bool is_uploading_; 102 bool is_uploading_{false};
92 103
93 // Whether ReshowBubble() has been called since ShowBubbleFor*() was called. 104 // Whether ReshowBubble() has been called since ShowBubbleFor*() was called.
94 bool is_reshow_; 105 bool is_reshow_{false};
106
107 // Whether the upload save version of the UI should ask the user for CVC.
108 bool should_cvc_be_requested_{false};
109
110 // The value of the CVC entered by the user (if it was requested).
111 base::string16 cvc_entered_by_user_;
95 112
96 // Contains the details of the card that will be saved if the user accepts. 113 // Contains the details of the card that will be saved if the user accepts.
97 CreditCard card_; 114 CreditCard card_;
98 115
99 // If no legal message should be shown then this variable is an empty vector. 116 // If no legal message should be shown then this variable is an empty vector.
100 LegalMessageLines legal_message_lines_; 117 LegalMessageLines legal_message_lines_;
101 118
102 // Used to measure the amount of time on a page; if it's less than some 119 // Used to measure the amount of time on a page; if it's less than some
103 // reasonable limit, then don't close the bubble upon navigation. 120 // reasonable limit, then don't close the bubble upon navigation.
104 std::unique_ptr<base::ElapsedTimer> timer_; 121 std::unique_ptr<base::ElapsedTimer> timer_;
105 122
106 DISALLOW_COPY_AND_ASSIGN(SaveCardBubbleControllerImpl); 123 DISALLOW_COPY_AND_ASSIGN(SaveCardBubbleControllerImpl);
107 }; 124 };
108 125
109 } // namespace autofill 126 } // namespace autofill
110 127
111 #endif // CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_ 128 #endif // CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698