Commit 4e6d7ece authored by Christopher Benson's avatar Christopher Benson Committed by Commit Bot

Adds NewTabPromo as a member of NewTabButton to support browsertests

Changes this CL:
- Renames NewTabPromo::CreateSelfOwned to NewTabPromo::Create.
- Adds a NewTabPromo as a member variable of NewTabButton for the following reasons:
1. To make the promo more accessible in order to check visibility in browsertests.
2. To tie the NewTabPromo to the specific NewTabButton it is being shown by. 

Bug: 734132
Change-Id: I71993f0185d712b62ac98706b165b078c4bb574b
Reviewed-on: https://chromium-review.googlesource.com/594627
Commit-Queue: Christopher Benson <chrisbenson@google.com>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491625}
parent 9b50d5d0
......@@ -53,6 +53,7 @@ sk_sp<SkDrawLooper> CreateShadowDrawLooper(SkColor color) {
NewTabButton::NewTabButton(TabStrip* tab_strip, views::ButtonListener* listener)
: views::ImageButton(listener),
tab_strip_(tab_strip),
new_tab_promo_(nullptr),
destroyed_(nullptr),
new_tab_promo_observer_(this) {
set_animate_on_state_change(true);
......@@ -78,8 +79,8 @@ int NewTabButton::GetTopOffset() {
void NewTabButton::ShowPromo() {
// Owned by its native widget. Will be destroyed as its widget is destroyed.
NewTabPromo* new_tab_promo = NewTabPromo::CreateSelfOwned(GetVisibleBounds());
new_tab_promo_observer_.Add(new_tab_promo->GetWidget());
new_tab_promo_ = NewTabPromo::Create(GetVisibleBounds());
new_tab_promo_observer_.Add(new_tab_promo_->GetWidget());
NewTabButton::SchedulePaint();
}
......
......@@ -41,6 +41,8 @@ class NewTabButton : public views::ImageButton,
// Shows the NewTabPromo when the NewTabFeatureEngagementTracker calls for it.
void ShowPromo();
NewTabPromo* new_tab_promo() { return new_tab_promo_; }
private:
// views::ImageButton:
#if defined(OS_WIN)
......@@ -81,6 +83,10 @@ class NewTabButton : public views::ImageButton,
// Tab strip that contains this button.
TabStrip* tab_strip_;
// Promotional UI that appears next to the NewTabButton and encourages its
// use. Owned by its NativeWidget.
NewTabPromo* new_tab_promo_;
// The offset used to paint the background image.
gfx::Point background_offset_;
......
......@@ -33,7 +33,7 @@ constexpr base::TimeDelta kBubbleCloseDelayShort =
} // namespace
// static
NewTabPromo* NewTabPromo::CreateSelfOwned(const gfx::Rect& anchor_rect) {
NewTabPromo* NewTabPromo::Create(const gfx::Rect& anchor_rect) {
return new NewTabPromo(anchor_rect);
}
......
......@@ -22,8 +22,9 @@ class MouseEvent;
// when prompted by the NewTabFeatureEngagementTracker.
class NewTabPromo : public views::BubbleDialogDelegateView {
public:
// Returns a self owned raw pointer to the NewTabButton.
static NewTabPromo* CreateSelfOwned(const gfx::Rect& anchor_rect);
// Returns a raw pointer to the NewTabButton. This raw pointer is owned by its
// NativeWidget.
static NewTabPromo* Create(const gfx::Rect& anchor_rect);
private:
// Constructs NewTabPromo. Anchors the bubble to the NewTabButton.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment