OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_AUTOFILL_NEW_CREDIT_CARD_BUBBLE_CONTROLLER_H_ | |
6 #define CHROME_BROWSER_UI_AUTOFILL_NEW_CREDIT_CARD_BUBBLE_CONTROLLER_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/compiler_specific.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/memory/weak_ptr.h" | |
12 #include "base/strings/string16.h" | |
13 #include "ui/gfx/image/image.h" | |
14 | |
15 class Profile; | |
16 | |
17 namespace autofill { | |
18 | |
19 class NewCreditCardBubble; | |
20 class AutofillProfile; | |
21 class CreditCard; | |
22 | |
23 // A simple wrapper that contains descriptive information about a credit card | |
24 // that should be shown in the content of the bubble. | |
25 struct CreditCardDescription { | |
26 CreditCardDescription(); | |
27 ~CreditCardDescription(); | |
28 // The icon of the credit card issuer (i.e. Visa, Mastercard). | |
29 gfx::Image icon; | |
30 // The display name of the card. Shown next to the icon. | |
31 base::string16 name; | |
32 // A longer description of the card being shown in the bubble. | |
33 base::string16 description; | |
34 }; | |
35 | |
36 //////////////////////////////////////////////////////////////////////////////// | |
37 // | |
38 // NewCreditCardBubbleController | |
39 // | |
40 // A class to control showing/hiding a bubble after saved a new card in Chrome. | |
41 // Here's a visual reference to what this bubble looks like: | |
42 // | |
43 // @----------------------------------------@ | |
44 // | Contents text that may span multiple | | |
Evan Stade
2013/08/06 22:06:25
I think this is obsolete already :)
Dan Beam
2013/08/07 02:30:22
Updated.
| |
45 // | lines. | | |
46 // | | | |
47 // | [ Card icon ] Card name | | |
48 // | Card description that will probably | | |
49 // | also span multiple lines. | | |
50 // | | | |
51 // | Learn more link | | |
52 // @----------------------------------------@ | |
53 // | |
54 //////////////////////////////////////////////////////////////////////////////// | |
55 class NewCreditCardBubbleController { | |
56 public: | |
57 virtual ~NewCreditCardBubbleController(); | |
58 | |
59 // Show a bubble informing the user that new credit card data has been saved. | |
60 // This bubble points to the settings menu. Ownership of |new_card| | |
61 // and |billing_profile| are transferred by this call. | |
62 static void Show(Profile* profile, | |
63 scoped_ptr<CreditCard> new_card, | |
64 scoped_ptr<AutofillProfile> billing_profile); | |
65 | |
66 // Text in the contents of the bubble; above any card descriptions. | |
67 const base::string16& ContentsText() const; | |
68 | |
69 // A card description to show in the bubble. | |
70 const CreditCardDescription& CardDescription() const; | |
71 | |
72 // The text of the link shown at the bubble of the bubble. | |
73 const base::string16& LinkText() const; | |
74 | |
75 // Called when |bubble_| is destroyed. | |
76 void OnBubbleDestroyed(); | |
77 | |
78 // Called when the link at the bottom of the bubble is clicked. | |
79 void OnLinkClicked(); | |
80 | |
81 // Returns the profile this bubble is associated with. | |
82 Profile* profile() { return profile_; } | |
83 | |
84 protected: | |
85 // Create a bubble attached to |profile|. | |
86 explicit NewCreditCardBubbleController(Profile* profile); | |
87 | |
88 // Returns a base::WeakPtr that references |this|. Exposed for testing. | |
89 base::WeakPtr<NewCreditCardBubbleController> GetWeakPtr(); | |
90 | |
91 // Creates and returns an Autofill credit card bubble. Exposed for testing. | |
92 virtual base::WeakPtr<NewCreditCardBubble> CreateBubble(); | |
93 | |
94 // Returns a weak reference to |bubble_|. May be invalid/NULL. | |
95 virtual base::WeakPtr<NewCreditCardBubble> bubble(); | |
96 | |
97 // Show a bubble notifying the user that new credit card data has been saved. | |
98 // Exposed for testing. | |
99 virtual void SetupAndShow(scoped_ptr<CreditCard> new_card, | |
100 scoped_ptr<AutofillProfile> billing_profile); | |
101 | |
102 private: | |
103 // Hides |bubble_| if it exists. | |
104 void Hide(); | |
105 | |
106 // The profile this bubble is associated with. | |
107 Profile* const profile_; | |
108 | |
109 // The newly saved credit card and assocated billing information. | |
110 scoped_ptr<CreditCard> new_card_; | |
111 scoped_ptr<AutofillProfile> billing_profile_; | |
112 | |
113 // Strings and descriptions that are generated based on |new_card_| and | |
114 // |billing_profile_|. | |
115 const base::string16 contents_text_; | |
116 struct CreditCardDescription card_desc_; | |
117 const base::string16 link_text_; | |
118 | |
119 // A bubble view that's created by calling either |Show*()| method; owned by | |
120 // the native widget/hierarchy, not this class (though this class must outlive | |
121 // |bubble_|). NULL in many cases. | |
122 base::WeakPtr<NewCreditCardBubble> bubble_; | |
123 | |
124 // A weak pointer factory for |Create()|. | |
125 base::WeakPtrFactory<NewCreditCardBubbleController> weak_ptr_factory_; | |
126 | |
127 DISALLOW_COPY_AND_ASSIGN(NewCreditCardBubbleController); | |
128 }; | |
129 | |
130 } // namespace autofill | |
131 | |
132 #endif // CHROME_BROWSER_UI_AUTOFILL_NEW_CREDIT_CARD_BUBBLE_CONTROLLER_H_ | |
OLD | NEW |