Commit 1825b0c1 authored by Collin Baker's avatar Collin Baker Committed by Commit Bot

Remove FeaturePromoBubbleView subclasses

This removes its subclasses and changes their clients to use
FeaturePromoBubbleView directly.

Change-Id: Ie220ab3b4e7c7653ffefe5b6fc266f76d60b492b
Reviewed-on: https://chromium-review.googlesource.com/c/1298394
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Reviewed-by: default avatarTommy Nyquist <nyquist@chromium.org>
Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604125}
parent b1c4daf9
include_rules = [ include_rules = [
"+chrome/browser/ui/views/tabs/new_tab_button.h", "+chrome/browser/ui/views/tabs/new_tab_button.h",
"+chrome/browser/ui/views/toolbar/browser_app_menu_button.h", "+chrome/browser/ui/views/toolbar/browser_app_menu_button.h",
"+chrome/browser/ui/views/feature_promos/incognito_window_promo_bubble_view.h", "+chrome/browser/ui/views/feature_promos/feature_promo_bubble_view.h",
"+chrome/browser/ui/views/frame/browser_view.h", "+chrome/browser/ui/views/frame/browser_view.h",
"+chrome/browser/ui/views/toolbar/toolbar_view.h", "+chrome/browser/ui/views/toolbar/toolbar_view.h",
] ]
......
...@@ -4,18 +4,23 @@ ...@@ -4,18 +4,23 @@
#include "chrome/browser/feature_engagement/incognito_window/incognito_window_tracker.h" #include "chrome/browser/feature_engagement/incognito_window/incognito_window_tracker.h"
#include <string>
#include "base/strings/string_number_conversions.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/metrics/desktop_session_duration/desktop_session_duration_tracker.h" #include "chrome/browser/metrics/desktop_session_duration/desktop_session_duration_tracker.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/toolbar/app_menu_icon_controller.h" #include "chrome/browser/ui/toolbar/app_menu_icon_controller.h"
#include "chrome/browser/ui/views/feature_promos/incognito_window_promo_bubble_view.h" #include "chrome/browser/ui/views/feature_promos/feature_promo_bubble_view.h"
#include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/toolbar/browser_app_menu_button.h" #include "chrome/browser/ui/views/toolbar/browser_app_menu_button.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h" #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "components/feature_engagement/public/event_constants.h" #include "components/feature_engagement/public/event_constants.h"
#include "components/feature_engagement/public/feature_constants.h" #include "components/feature_engagement/public/feature_constants.h"
#include "components/feature_engagement/public/tracker.h" #include "components/feature_engagement/public/tracker.h"
#include "components/variations/variations_associated_data.h"
namespace { namespace {
...@@ -33,6 +38,21 @@ BrowserAppMenuButton* GetAppMenuButton() { ...@@ -33,6 +38,21 @@ BrowserAppMenuButton* GetAppMenuButton() {
return browser->toolbar()->app_menu_button(); return browser->toolbar()->app_menu_button();
} }
int GetPromoStringSpecifier() {
static constexpr int kTextIds[] = {
IDS_INCOGNITOWINDOW_PROMO_0, IDS_INCOGNITOWINDOW_PROMO_1,
IDS_INCOGNITOWINDOW_PROMO_2, IDS_INCOGNITOWINDOW_PROMO_3};
const std::string& str = variations::GetVariationParamValue(
"IncognitoWindowInProductHelp", "x_promo_string");
size_t text_specifier;
if (!base::StringToSizeT(str, &text_specifier) ||
text_specifier >= base::size(kTextIds)) {
text_specifier = 0;
}
return kTextIds[text_specifier];
}
} // namespace } // namespace
namespace feature_engagement { namespace feature_engagement {
...@@ -74,8 +94,10 @@ void IncognitoWindowTracker::ShowPromo() { ...@@ -74,8 +94,10 @@ void IncognitoWindowTracker::ShowPromo() {
auto* app_menu_button = GetAppMenuButton(); auto* app_menu_button = GetAppMenuButton();
// Owned by its native widget. Will be destroyed when its widget is destroyed. // Owned by its native widget. Will be destroyed when its widget is destroyed.
incognito_promo_ = incognito_promo_ = FeaturePromoBubbleView::CreateOwned(
IncognitoWindowPromoBubbleView::CreateOwned(app_menu_button); app_menu_button, views::BubbleBorder::TOP_RIGHT,
GetPromoStringSpecifier(),
FeaturePromoBubbleView::ActivationAction::ACTIVATE);
views::Widget* widget = incognito_promo_->GetWidget(); views::Widget* widget = incognito_promo_->GetWidget();
incognito_promo_observer_.Add(widget); incognito_promo_observer_.Add(widget);
app_menu_button->SetIsProminent(true); app_menu_button->SetIsProminent(true);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "chrome/browser/feature_engagement/session_duration_updater.h" #include "chrome/browser/feature_engagement/session_duration_updater.h"
#include "ui/views/widget/widget_observer.h" #include "ui/views/widget/widget_observer.h"
class IncognitoWindowPromoBubbleView; class FeaturePromoBubbleView;
namespace feature_engagement { namespace feature_engagement {
...@@ -52,14 +52,14 @@ class IncognitoWindowTracker : public FeatureTracker, ...@@ -52,14 +52,14 @@ class IncognitoWindowTracker : public FeatureTracker,
// views::WidgetObserver: // views::WidgetObserver:
void OnWidgetDestroying(views::Widget* widget) override; void OnWidgetDestroying(views::Widget* widget) override;
IncognitoWindowPromoBubbleView* incognito_promo() { return incognito_promo_; } FeaturePromoBubbleView* incognito_promo() { return incognito_promo_; }
// FeatureTracker: // FeatureTracker:
void OnSessionTimeMet() override; void OnSessionTimeMet() override;
// Promotional UI that appears next to the AppMenuButton and encourages its // Promotional UI that appears next to the AppMenuButton and encourages its
// use. Owned by its NativeWidget. // use. Owned by its NativeWidget.
IncognitoWindowPromoBubbleView* incognito_promo_ = nullptr; FeaturePromoBubbleView* incognito_promo_ = nullptr;
// Observes the |incognito_promo_|'s Widget. Used to tell whether the promo // Observes the |incognito_promo_|'s Widget. Used to tell whether the promo
// is open and is called back when it closes. // is open and is called back when it closes.
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "chrome/browser/first_run/first_run.h" #include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/views/feature_promos/incognito_window_promo_bubble_view.h" #include "chrome/browser/ui/views/feature_promos/feature_promo_bubble_view.h"
#include "chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h" #include "chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h"
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/interactive_test_utils.h" #include "chrome/test/base/interactive_test_utils.h"
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/views/feature_promos/new_tab_promo_bubble_view.h" #include "chrome/browser/ui/views/feature_promos/feature_promo_bubble_view.h"
#include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h" #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include "chrome/browser/ui/views/tabs/new_tab_button.h" #include "chrome/browser/ui/views/tabs/new_tab_button.h"
......
...@@ -2448,14 +2448,8 @@ jumbo_split_static_library("ui") { ...@@ -2448,14 +2448,8 @@ jumbo_split_static_library("ui") {
"views/extensions/pwa_confirmation_view.h", "views/extensions/pwa_confirmation_view.h",
"views/extensions/web_app_info_image_source.cc", "views/extensions/web_app_info_image_source.cc",
"views/extensions/web_app_info_image_source.h", "views/extensions/web_app_info_image_source.h",
"views/feature_promos/bookmark_promo_bubble_view.cc",
"views/feature_promos/bookmark_promo_bubble_view.h",
"views/feature_promos/feature_promo_bubble_view.cc", "views/feature_promos/feature_promo_bubble_view.cc",
"views/feature_promos/feature_promo_bubble_view.h", "views/feature_promos/feature_promo_bubble_view.h",
"views/feature_promos/incognito_window_promo_bubble_view.cc",
"views/feature_promos/incognito_window_promo_bubble_view.h",
"views/feature_promos/new_tab_promo_bubble_view.cc",
"views/feature_promos/new_tab_promo_bubble_view.h",
"views/find_bar_host.cc", "views/find_bar_host.cc",
"views/find_bar_host.h", "views/find_bar_host.h",
"views/find_bar_view.cc", "views/find_bar_view.cc",
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/feature_promos/bookmark_promo_bubble_view.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/grit/generated_resources.h"
#include "components/variations/variations_associated_data.h"
// static
BookmarkPromoBubbleView* BookmarkPromoBubbleView::CreateOwned(
views::View* anchor_view) {
return new BookmarkPromoBubbleView(anchor_view);
}
BookmarkPromoBubbleView::BookmarkPromoBubbleView(views::View* anchor_view)
: FeaturePromoBubbleView(anchor_view,
views::BubbleBorder::TOP_RIGHT,
GetStringSpecifier(),
ActivationAction::ACTIVATE) {}
BookmarkPromoBubbleView::~BookmarkPromoBubbleView() = default;
// static
int BookmarkPromoBubbleView::GetStringSpecifier() {
static constexpr int kTextIds[] = {IDS_BOOKMARK_PROMO_0, IDS_BOOKMARK_PROMO_1,
IDS_BOOKMARK_PROMO_2};
const std::string& str = variations::GetVariationParamValue(
"BookmarkInProductHelp", "x_promo_string");
size_t text_specifier;
if (!base::StringToSizeT(str, &text_specifier) ||
text_specifier >= arraysize(kTextIds)) {
text_specifier = 0;
}
return kTextIds[text_specifier];
}
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_FEATURE_PROMOS_BOOKMARK_PROMO_BUBBLE_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_FEATURE_PROMOS_BOOKMARK_PROMO_BUBBLE_VIEW_H_
#include "base/macros.h"
#include "chrome/browser/ui/views/feature_promos/feature_promo_bubble_view.h"
// The BookmarkPromoBubbleView is a bubble anchored to the left of StarView
// to draw attention to StarView. It is created by the StarView when
// prompted by the feature_engagement::BookmarkTracker.
class BookmarkPromoBubbleView : public FeaturePromoBubbleView {
public:
// Returns a raw pointer that is owned by its native widget.
static BookmarkPromoBubbleView* CreateOwned(views::View* anchor_view);
private:
// Anchors the BookmarkPromoBubbleView to |anchor_view|.
// The bubble widget and promo are owned by their native widget.
explicit BookmarkPromoBubbleView(views::View* anchor_view);
~BookmarkPromoBubbleView() override;
// Returns the string ID to display in the promo.
static int GetStringSpecifier();
DISALLOW_COPY_AND_ASSIGN(BookmarkPromoBubbleView);
};
#endif // CHROME_BROWSER_UI_VIEWS_FEATURE_PROMOS_BOOKMARK_PROMO_BUBBLE_VIEW_H_
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/test/test_browser_dialog.h"
#include "chrome/browser/ui/views/feature_promos/bookmark_promo_bubble_view.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include "chrome/browser/ui/views/location_bar/star_view.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
class BookmarkPromoDialogTest : public DialogBrowserTest {
public:
BookmarkPromoDialogTest() = default;
// DialogBrowserTest:
void ShowUi(const std::string& name) override {
BrowserView::GetBrowserViewForBrowser(browser())
->toolbar()
->location_bar()
->star_view()
->ShowPromo();
}
private:
DISALLOW_COPY_AND_ASSIGN(BookmarkPromoDialogTest);
};
// Test that calls ShowUi("default").
IN_PROC_BROWSER_TEST_F(BookmarkPromoDialogTest, InvokeUi_BookmarkPromoBubble) {
ShowAndVerifyUi();
}
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/feature_promos/incognito_window_promo_bubble_view.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/grit/generated_resources.h"
#include "components/variations/variations_associated_data.h"
// static
IncognitoWindowPromoBubbleView* IncognitoWindowPromoBubbleView::CreateOwned(
views::View* anchor_view) {
return new IncognitoWindowPromoBubbleView(anchor_view);
}
IncognitoWindowPromoBubbleView::IncognitoWindowPromoBubbleView(
views::View* anchor_view)
: FeaturePromoBubbleView(anchor_view,
views::BubbleBorder::TOP_RIGHT,
GetStringSpecifier(),
ActivationAction::ACTIVATE) {}
IncognitoWindowPromoBubbleView::~IncognitoWindowPromoBubbleView() = default;
int IncognitoWindowPromoBubbleView::GetStringSpecifier() {
static constexpr int kTextIds[] = {
IDS_INCOGNITOWINDOW_PROMO_0, IDS_INCOGNITOWINDOW_PROMO_1,
IDS_INCOGNITOWINDOW_PROMO_2, IDS_INCOGNITOWINDOW_PROMO_3};
const std::string& str = variations::GetVariationParamValue(
"IncognitoWindowInProductHelp", "x_promo_string");
size_t text_specifier;
if (!base::StringToSizeT(str, &text_specifier) ||
text_specifier >= arraysize(kTextIds)) {
text_specifier = 0;
}
return kTextIds[text_specifier];
}
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_FEATURE_PROMOS_INCOGNITO_WINDOW_PROMO_BUBBLE_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_FEATURE_PROMOS_INCOGNITO_WINDOW_PROMO_BUBBLE_VIEW_H_
#include "base/macros.h"
#include "chrome/browser/ui/views/feature_promos/feature_promo_bubble_view.h"
// The IncognitoWindowPromoBubbleView is a bubble anchored to the right of the
// App Menu Button. It draws users' attention to the App Menu Button. It is
// created by the App Menu Button when prompted by the IncognitoWindowTracker.
class IncognitoWindowPromoBubbleView : public FeaturePromoBubbleView {
public:
// Returns a raw pointer that is owned by its native widget.
static IncognitoWindowPromoBubbleView* CreateOwned(views::View* anchor_view);
private:
// Anchors the bubble to |anchor_view|. The bubble widget and promo are
// owned by their native widget.
explicit IncognitoWindowPromoBubbleView(views::View* anchor_view);
~IncognitoWindowPromoBubbleView() override;
// Returns the string ID to display in the promo.
int GetStringSpecifier();
DISALLOW_COPY_AND_ASSIGN(IncognitoWindowPromoBubbleView);
};
#endif // CHROME_BROWSER_UI_VIEWS_FEATURE_PROMOS_INCOGNITO_WINDOW_PROMO_BUBBLE_VIEW_H_
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/feature_engagement/incognito_window/incognito_window_tracker.h"
#include "chrome/browser/feature_engagement/incognito_window/incognito_window_tracker_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/test/test_browser_dialog.h"
namespace feature_engagement {
namespace {
class IncognitoWindowPromoDialogTest : public DialogBrowserTest {
public:
IncognitoWindowPromoDialogTest() = default;
// DialogBrowserTest:
void ShowUi(const std::string& name) override {
feature_engagement::IncognitoWindowTrackerFactory::GetInstance()
->GetForProfile(browser()->profile())
->ShowPromo();
}
private:
DISALLOW_COPY_AND_ASSIGN(IncognitoWindowPromoDialogTest);
};
} // namespace
// Test that calls ShowUi("default").
IN_PROC_BROWSER_TEST_F(IncognitoWindowPromoDialogTest,
InvokeUi_IncognitoWindowPromo) {
ShowAndVerifyUi();
}
} // namespace feature_engagement
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/feature_promos/new_tab_promo_bubble_view.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/grit/generated_resources.h"
#include "components/variations/variations_associated_data.h"
// static
NewTabPromoBubbleView* NewTabPromoBubbleView::CreateOwned(
views::View* anchor_view) {
return new NewTabPromoBubbleView(anchor_view);
}
NewTabPromoBubbleView::NewTabPromoBubbleView(views::View* anchor_view)
: FeaturePromoBubbleView(anchor_view,
views::BubbleBorder::LEFT_CENTER,
GetStringSpecifier(),
ActivationAction::DO_NOT_ACTIVATE) {}
NewTabPromoBubbleView::~NewTabPromoBubbleView() = default;
// static
int NewTabPromoBubbleView::GetStringSpecifier() {
static constexpr int kTextIds[] = {IDS_NEWTAB_PROMO_0, IDS_NEWTAB_PROMO_1,
IDS_NEWTAB_PROMO_2};
const std::string& str = variations::GetVariationParamValue(
"NewTabInProductHelp", "x_promo_string");
size_t text_specifier;
if (!base::StringToSizeT(str, &text_specifier) ||
text_specifier >= arraysize(kTextIds)) {
text_specifier = 0;
}
return kTextIds[text_specifier];
}
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_FEATURE_PROMOS_NEW_TAB_PROMO_BUBBLE_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_FEATURE_PROMOS_NEW_TAB_PROMO_BUBBLE_VIEW_H_
#include "base/macros.h"
#include "chrome/browser/ui/views/feature_promos/feature_promo_bubble_view.h"
// The NewTabPromoBubbleView is a bubble anchored to the right of the New Tab
// Button. It draws users' attention to the New Tab Button. It is created by
// the New Tab Button when prompted by the NewTabTracker.
class NewTabPromoBubbleView : public FeaturePromoBubbleView {
public:
// Returns a raw pointer that is owned by its native widget.
static NewTabPromoBubbleView* CreateOwned(views::View* anchor_view);
private:
// Anchors the bubble to |anchor_view|. The bubble widget and promo are
// owned by their native widget.
explicit NewTabPromoBubbleView(views::View* anchor_view);
~NewTabPromoBubbleView() override;
// Returns the string ID to display in the promo.
static int GetStringSpecifier();
DISALLOW_COPY_AND_ASSIGN(NewTabPromoBubbleView);
};
#endif // CHROME_BROWSER_UI_VIEWS_FEATURE_PROMOS_NEW_TAB_PROMO_BUBBLE_VIEW_H_
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/test/test_browser_dialog.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/tabs/new_tab_button.h"
#include "chrome/browser/ui/views/tabs/tab_strip.h"
class NewTabPromoDialogTest : public DialogBrowserTest {
public:
NewTabPromoDialogTest() = default;
// DialogBrowserTest:
void ShowUi(const std::string& name) override {
BrowserView::GetBrowserViewForBrowser(browser())
->tabstrip()
->new_tab_button()
->ShowPromo();
}
private:
DISALLOW_COPY_AND_ASSIGN(NewTabPromoDialogTest);
};
// Test that calls ShowUi("default").
IN_PROC_BROWSER_TEST_F(NewTabPromoDialogTest, InvokeUi_NewTabPromo) {
ShowAndVerifyUi();
}
...@@ -4,22 +4,45 @@ ...@@ -4,22 +4,45 @@
#include "chrome/browser/ui/views/location_bar/star_view.h" #include "chrome/browser/ui/views/location_bar/star_view.h"
#include <string>
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/app/chrome_command_ids.h" #include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/bookmarks/bookmark_stats.h" #include "chrome/browser/bookmarks/bookmark_stats.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/view_ids.h" #include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h"
#include "chrome/browser/ui/views/feature_promos/bookmark_promo_bubble_view.h" #include "chrome/browser/ui/views/feature_promos/feature_promo_bubble_view.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/omnibox/browser/vector_icons.h" #include "components/omnibox/browser/vector_icons.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "components/variations/variations_associated_data.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/color_utils.h" #include "ui/gfx/color_utils.h"
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
#include "ui/views/widget/widget_observer.h" #include "ui/views/widget/widget_observer.h"
namespace {
// For bookmark in-product help.
int GetPromoStringSpecifier() {
static constexpr int kTextIds[] = {IDS_BOOKMARK_PROMO_0, IDS_BOOKMARK_PROMO_1,
IDS_BOOKMARK_PROMO_2};
const std::string& str = variations::GetVariationParamValue(
"BookmarkInProductHelp", "x_promo_string");
size_t text_specifier;
if (!base::StringToSizeT(str, &text_specifier) ||
text_specifier >= base::size(kTextIds)) {
text_specifier = 0;
}
return kTextIds[text_specifier];
}
} // namespace
StarView::StarView(CommandUpdater* command_updater, StarView::StarView(CommandUpdater* command_updater,
Browser* browser, Browser* browser,
PageActionIconView::Delegate* delegate) PageActionIconView::Delegate* delegate)
...@@ -37,8 +60,10 @@ void StarView::SetToggled(bool on) { ...@@ -37,8 +60,10 @@ void StarView::SetToggled(bool on) {
} }
void StarView::ShowPromo() { void StarView::ShowPromo() {
BookmarkPromoBubbleView* bookmark_promo_bubble = FeaturePromoBubbleView* bookmark_promo_bubble =
BookmarkPromoBubbleView::CreateOwned(this); FeaturePromoBubbleView::CreateOwned(
this, views::BubbleBorder::TOP_RIGHT, GetPromoStringSpecifier(),
FeaturePromoBubbleView::ActivationAction::ACTIVATE);
if (!bookmark_promo_observer_.IsObserving( if (!bookmark_promo_observer_.IsObserving(
bookmark_promo_bubble->GetWidget())) { bookmark_promo_bubble->GetWidget())) {
bookmark_promo_observer_.Add(bookmark_promo_bubble->GetWidget()); bookmark_promo_observer_.Add(bookmark_promo_bubble->GetWidget());
......
...@@ -4,15 +4,20 @@ ...@@ -4,15 +4,20 @@
#include "chrome/browser/ui/views/tabs/new_tab_button.h" #include "chrome/browser/ui/views/tabs/new_tab_button.h"
#include <string>
#include "base/strings/string_number_conversions.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/layout_constants.h" #include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h" #include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/feature_promos/new_tab_promo_bubble_view.h" #include "chrome/browser/ui/views/feature_promos/feature_promo_bubble_view.h"
#include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h"
#include "chrome/browser/ui/views/tabs/tab_strip.h" #include "chrome/browser/ui/views/tabs/tab_strip.h"
#include "chrome/grit/generated_resources.h"
#include "components/feature_engagement/buildflags.h" #include "components/feature_engagement/buildflags.h"
#include "components/variations/variations_associated_data.h"
#include "ui/base/default_theme_provider.h" #include "ui/base/default_theme_provider.h"
#include "ui/base/material_design/material_design_controller.h" #include "ui/base/material_design/material_design_controller.h"
#include "ui/gfx/color_utils.h" #include "ui/gfx/color_utils.h"
...@@ -31,9 +36,27 @@ ...@@ -31,9 +36,27 @@
#if BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP) #if BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
#include "chrome/browser/feature_engagement/new_tab/new_tab_tracker.h" #include "chrome/browser/feature_engagement/new_tab/new_tab_tracker.h"
#include "chrome/browser/feature_engagement/new_tab/new_tab_tracker_factory.h" #include "chrome/browser/feature_engagement/new_tab/new_tab_tracker_factory.h"
#include "chrome/browser/ui/views/feature_promos/new_tab_promo_bubble_view.h"
#endif #endif
namespace {
// For new tab in-product help.
int GetPromoStringSpecifier() {
static constexpr int kTextIds[] = {IDS_NEWTAB_PROMO_0, IDS_NEWTAB_PROMO_1,
IDS_NEWTAB_PROMO_2};
const std::string& str = variations::GetVariationParamValue(
"NewTabInProductHelp", "x_promo_string");
size_t text_specifier;
if (!base::StringToSizeT(str, &text_specifier) ||
text_specifier >= base::size(kTextIds)) {
text_specifier = 0;
}
return kTextIds[text_specifier];
}
} // namespace
// static // static
const gfx::Size NewTabButton::kButtonSize{28, 28}; const gfx::Size NewTabButton::kButtonSize{28, 28};
...@@ -78,7 +101,9 @@ void NewTabButton::CloseBubbleForLastActiveBrowser() { ...@@ -78,7 +101,9 @@ void NewTabButton::CloseBubbleForLastActiveBrowser() {
void NewTabButton::ShowPromo() { void NewTabButton::ShowPromo() {
DCHECK(!new_tab_promo_); DCHECK(!new_tab_promo_);
// Owned by its native widget. Will be destroyed as its widget is destroyed. // Owned by its native widget. Will be destroyed as its widget is destroyed.
new_tab_promo_ = NewTabPromoBubbleView::CreateOwned(this); new_tab_promo_ = FeaturePromoBubbleView::CreateOwned(
this, views::BubbleBorder::LEFT_CENTER, GetPromoStringSpecifier(),
FeaturePromoBubbleView::ActivationAction::DO_NOT_ACTIVATE);
new_tab_promo_observer_.Add(new_tab_promo_->GetWidget()); new_tab_promo_observer_.Add(new_tab_promo_->GetWidget());
SchedulePaint(); SchedulePaint();
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "ui/views/view.h" #include "ui/views/view.h"
#include "ui/views/widget/widget_observer.h" #include "ui/views/widget/widget_observer.h"
class NewTabPromoBubbleView; class FeaturePromoBubbleView;
namespace views { namespace views {
class InkDropContainerView; class InkDropContainerView;
...@@ -61,7 +61,7 @@ class NewTabButton : public views::ImageButton, ...@@ -61,7 +61,7 @@ class NewTabButton : public views::ImageButton,
void AnimateInkDropToStateForTesting(views::InkDropState state); void AnimateInkDropToStateForTesting(views::InkDropState state);
NewTabPromoBubbleView* new_tab_promo() { return new_tab_promo_; } FeaturePromoBubbleView* new_tab_promo() { return new_tab_promo_; }
private: private:
// views::ImageButton: // views::ImageButton:
...@@ -112,7 +112,7 @@ class NewTabButton : public views::ImageButton, ...@@ -112,7 +112,7 @@ class NewTabButton : public views::ImageButton,
// Promotional UI that appears next to the NewTabButton and encourages its // Promotional UI that appears next to the NewTabButton and encourages its
// use. Owned by its NativeWidget. // use. Owned by its NativeWidget.
NewTabPromoBubbleView* new_tab_promo_ = nullptr; FeaturePromoBubbleView* new_tab_promo_ = nullptr;
// The offset used to paint the background image. // The offset used to paint the background image.
int background_offset_; int background_offset_;
......
...@@ -1207,12 +1207,7 @@ test("browser_tests") { ...@@ -1207,12 +1207,7 @@ test("browser_tests") {
} }
if (enable_desktop_in_product_help) { if (enable_desktop_in_product_help) {
sources += [ sources += [ "../browser/ui/views/feature_promos/feature_promo_dialog_browsertest.cc" ]
"../browser/ui/views/feature_promos/bookmark_promo_dialog_browsertest.cc",
"../browser/ui/views/feature_promos/feature_promo_dialog_browsertest.cc",
"../browser/ui/views/feature_promos/incognito_window_promo_dialog_browsertest.cc",
"../browser/ui/views/feature_promos/new_tab_promo_dialog_browsertest.cc",
]
} }
if (enable_extensions) { if (enable_extensions) {
......
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