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

Unified Diff: chrome/browser/ui/autofill/autofill_credit_card_bubble_controller.h

Issue 21668003: Implement newly saved card bubble for realz and update generated card bubble to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/autofill/autofill_credit_card_bubble_controller.h
diff --git a/chrome/browser/ui/autofill/autofill_credit_card_bubble_controller.h b/chrome/browser/ui/autofill/autofill_credit_card_bubble_controller.h
index e6d8885d1055c3df07e1ab20612adcdd1069906e..a654fa74b7e651a49c0c669308939838ff4bfb8a 100644
--- a/chrome/browser/ui/autofill/autofill_credit_card_bubble_controller.h
+++ b/chrome/browser/ui/autofill/autofill_credit_card_bubble_controller.h
@@ -13,6 +13,8 @@
#include "base/strings/string16.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
+#include "ui/base/range/range.h"
+#include "ui/gfx/image/image.h"
class Profile;
@@ -20,14 +22,6 @@ namespace content {
class WebContents;
}
-namespace gfx {
-class Image;
-}
-
-namespace ui {
-class Range;
-}
-
namespace user_prefs {
class PrefRegistrySyncable;
}
@@ -35,6 +29,31 @@ class PrefRegistrySyncable;
namespace autofill {
class AutofillCreditCardBubble;
+class AutofillProfile;
+class CreditCard;
+
+// A simple wrapper that contains descriptive information about a credit card
+// that should be shown in the content of the bubble.
+struct CreditCardDescription {
+ CreditCardDescription();
+ ~CreditCardDescription();
+ // The icon of the credit card issuer (i.e. Visa, Mastercard).
+ gfx::Image icon;
+ // The title text, quickly describing the card, shown next to the icon.
+ base::string16 title;
+ // A longer description of the card being shown in the bubble.
+ base::string16 description;
+};
+
+// A simple struct of text highlighting range information. If |is_link| is true
+// this portion of the text should be clickable (and trigger |OnLinkClicked()|).
+// If |is_link| is false, the text denoted by |range| should be bolded.
+struct TextRange {
+ // The range of text this TextRange applies to (start and end).
+ ui::Range range;
+ // Whether this text range should be styled like a link (e.g. clickable).
+ bool is_link;
+};
////////////////////////////////////////////////////////////////////////////////
//
@@ -46,6 +65,25 @@ class AutofillCreditCardBubble;
// bubble, but only has a weak reference to it (it is often owned by the native
// platform's ui toolkit).
//
+// Here's a visual reference:
+//
+// /---------------------------------------\
+// | Title text |
+// | |
+// | Header text that will probably span |
Evan Stade 2013/08/02 16:29:45 I object to this being called "header" text.
Dan Beam 2013/08/06 02:41:35 Done.
+// | multiple lines and have bolded text |
+// | or links inline. |
+// | |
+// | [ Card icon ] Card title |
+// | Card description that will probably |
+// | also span multiple lines. |
+// | |
+// | Learn more link |
+// \---------------------------------------/
+//
+// NOTE: that basically any of these sections can be (and are) empty in some
+// variation of this bubble.
+//
////////////////////////////////////////////////////////////////////////////////
class AutofillCreditCardBubbleController
: public content::WebContentsObserver,
@@ -56,20 +94,21 @@ class AutofillCreditCardBubbleController
// Registers preferences this class cares about.
static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry);
- // Shows a clickable icon in the omnibox that informs the user about generated
- // (fronting) cards and how they are used to bill their original (backing)
- // card. Additionally, if |ShouldDisplayBubbleInitially()| is true, the bubble
- // will be shown initially (doesn't require being clicked).
- static void ShowGeneratedCardUI(content::WebContents* contents,
- const base::string16& backing_card_name,
- const base::string16& fronting_card_name);
-
- // Show a bubble and clickable omnibox icon notifying the user that new credit
- // card data has been saved. This bubble always shows initially.
- static void ShowNewCardSavedBubble(content::WebContents* contents,
- const base::string16& new_card_name);
-
- // content::WebContentsObserver implementation.
+ // Show a bubble to educate the user about generated (fronting) cards and how
+ // they are used to bill their original (backing) card.
+ static void ShowGeneratedCardBubble(content::WebContents* contents,
+ const base::string16& backing_card_name,
+ const base::string16& fronting_card_name);
+
+ // Show a bubble informing the user that new credit card data has been saved.
+ // This bubble points to the settings menu. Ownership of |new_card|
+ // and |billing_profile| are transferred by this call.
+ static void ShowNewCardSavedBubble(
+ content::WebContents* contents,
+ scoped_ptr<CreditCard> new_card,
+ scoped_ptr<AutofillProfile> billing_profile);
+
+ // content::WebContentsObserver:
virtual void DidNavigateMainFrame(
const content::LoadCommittedDetails& details,
const content::FrameNavigateParams& params) OVERRIDE;
@@ -77,25 +116,34 @@ class AutofillCreditCardBubbleController
// Whether |bubble_| is currently in the process of hiding.
bool IsHiding() const;
+ // Returns whether the bubble should be anchored to the setting menu or not.
+ bool AnchorToSettingsMenu() const;
+
// An image that should be shown as an icon in the omnibox and pointed to by
// the bubble.
gfx::Image AnchorIcon() const;
// The title of the bubble. May be empty.
- base::string16 BubbleTitle() const;
+ const base::string16& TitleText() const;
- // The main text of the bubble.
- base::string16 BubbleText() const;
+ // Text in the contents of the bubble; above any card descriptions.
+ const base::string16& HeaderText() const;
- // Ranges of text styles in the bubble's main content.
- const std::vector<ui::Range>& BubbleTextRanges() const;
+ // Ranges of text styles in the bubble's main content. May be empty.
+ const std::vector<TextRange>& HeaderTextRanges() const;
- // The text of the link shown at the bubble of the bubble.
- base::string16 LinkText() const;
+ // A card description to show in the bubble. May be NULL.
+ const CreditCardDescription* Description() const;
+
+ // The text of the link shown at the bubble of the bubble. May be empty.
+ const base::string16& LinkText() const;
// Called when the anchor for this bubble is clicked.
void OnAnchorClicked();
+ // Called when |bubble_| is destroyed.
+ void OnBubbleDestroyed();
+
// Called when the link at the bottom of the bubble is clicked.
void OnLinkClicked();
@@ -134,7 +182,9 @@ class AutofillCreditCardBubbleController
// Show a bubble notifying the user that new credit card data has been saved.
// Exposed for testing.
- virtual void ShowAsNewCardSavedBubble(const base::string16& new_card_name);
+ virtual void ShowAsNewCardSavedBubble(
+ scoped_ptr<CreditCard> new_card,
+ scoped_ptr<AutofillProfile> billing_profile);
private:
friend class content::WebContentsUserData<AutofillCreditCardBubbleController>;
@@ -165,16 +215,20 @@ class AutofillCreditCardBubbleController
// The web contents associated with this bubble.
content::WebContents* const web_contents_;
- // The newly saved credit card.
- base::string16 new_card_name_;
+ // The newly saved credit card and assocated billing information.
+ scoped_ptr<CreditCard> new_card_;
+ scoped_ptr<AutofillProfile> billing_profile_;
// The generated credit card number and associated backing card.
base::string16 fronting_card_name_;
base::string16 backing_card_name_;
- // Bubble contents text and text ranges generated in |SetUp()|.
- base::string16 bubble_text_;
- std::vector<ui::Range> bubble_text_ranges_;
+ // String, ranges, and descriptions generated in |SetUp()|.
+ base::string16 title_text_;
+ base::string16 header_text_;
+ std::vector<TextRange> header_text_ranges_;
+ scoped_ptr<CreditCardDescription> card_desc_;
+ base::string16 link_text_;
// A bubble view that's created by calling either |Show*()| method; owned by
// the native widget/hierarchy, not this class (though this class must outlive

Powered by Google App Engine
This is Rietveld 408576698