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

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: 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 // |upload_cvc_should_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 const bool upload_cvc_should_be_requested,
jiahuiguo 2017/03/31 22:52:19 Don't need const here?
Jared Saul 2017/04/01 04:18:02 Done.
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;
55 int GetCvcImageRid() const override;
56 bool ShouldRequestCvcFromUser() const override;
57 void SetUserProvidedCvc(const base::string16& cvc) override;
58 const base::string16 GetUserProvidedCvc() const override;
csashi 2017/03/31 21:48:15 Don't need const base::string16.
Jared Saul 2017/04/01 04:18:02 Done.
52 void OnSaveButton() override; 59 void OnSaveButton() override;
53 void OnCancelButton() override; 60 void OnCancelButton() override;
54 void OnLearnMoreClicked() override; 61 void OnLearnMoreClicked() override;
55 void OnLegalMessageLinkClicked(const GURL& url) override; 62 void OnLegalMessageLinkClicked(const GURL& url) override;
56 void OnBubbleClosed() override; 63 void OnBubbleClosed() override;
57 64
58 const LegalMessageLines& GetLegalMessageLines() const override; 65 const LegalMessageLines& GetLegalMessageLines() const override;
59 66
67 // Used to check if an entered CVC value is a valid CVC for the current card.
csashi 2017/03/31 21:48:15 I assume this is a simple check (# digits or some
Jared Saul 2017/04/01 04:18:02 Done.
68 bool InputCvcIsValid(const base::string16& input_text) const override;
csashi 2017/03/31 21:48:15 IsValidCVC ?
Shanfeng 2017/03/31 22:58:45 +1
Jared Saul 2017/04/01 04:18:02 InputCvcIsValid() is already a function in card_un
69
60 protected: 70 protected:
61 explicit SaveCardBubbleControllerImpl(content::WebContents* web_contents); 71 explicit SaveCardBubbleControllerImpl(content::WebContents* web_contents);
62 ~SaveCardBubbleControllerImpl() override; 72 ~SaveCardBubbleControllerImpl() override;
63 73
64 // Returns the time elapsed since |timer_| was initialized. 74 // Returns the time elapsed since |timer_| was initialized.
65 // Exists for testing. 75 // Exists for testing.
66 virtual base::TimeDelta Elapsed() const; 76 virtual base::TimeDelta Elapsed() const;
67 77
68 // content::WebContentsObserver: 78 // content::WebContentsObserver:
69 void DidFinishNavigation( 79 void DidFinishNavigation(
(...skipping 16 matching lines...) Expand all
86 // If save_card_callback_.is_null() is true then no bubble is available to 96 // If save_card_callback_.is_null() is true then no bubble is available to
87 // show and the icon is not visible. 97 // show and the icon is not visible.
88 base::Closure save_card_callback_; 98 base::Closure save_card_callback_;
89 99
90 // Governs whether the upload or local save version of the UI should be shown. 100 // Governs whether the upload or local save version of the UI should be shown.
91 bool is_uploading_; 101 bool is_uploading_;
92 102
93 // Whether ReshowBubble() has been called since ShowBubbleFor*() was called. 103 // Whether ReshowBubble() has been called since ShowBubbleFor*() was called.
94 bool is_reshow_; 104 bool is_reshow_;
95 105
106 // Whether the upload save version of the UI should ask the user for CVC.
107 bool upload_cvc_should_be_requested_;
108
109 // The value of the CVC entered by the user (if it was requested).
110 base::string16 cvc_entered_by_user_;
Shanfeng 2017/03/31 22:58:45 Sync the name with Getter and Setter.
Jared Saul 2017/04/01 04:18:02 Done.
111
96 // Contains the details of the card that will be saved if the user accepts. 112 // Contains the details of the card that will be saved if the user accepts.
97 CreditCard card_; 113 CreditCard card_;
98 114
99 // If no legal message should be shown then this variable is an empty vector. 115 // If no legal message should be shown then this variable is an empty vector.
100 LegalMessageLines legal_message_lines_; 116 LegalMessageLines legal_message_lines_;
101 117
102 // Used to measure the amount of time on a page; if it's less than some 118 // 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. 119 // reasonable limit, then don't close the bubble upon navigation.
104 std::unique_ptr<base::ElapsedTimer> timer_; 120 std::unique_ptr<base::ElapsedTimer> timer_;
105 121
106 DISALLOW_COPY_AND_ASSIGN(SaveCardBubbleControllerImpl); 122 DISALLOW_COPY_AND_ASSIGN(SaveCardBubbleControllerImpl);
107 }; 123 };
108 124
109 } // namespace autofill 125 } // namespace autofill
110 126
111 #endif // CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_ 127 #endif // CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698