Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the infobar for WDP CTA instead of dialog #15822

Merged
merged 3 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 16 additions & 22 deletions app/brave_generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -506,28 +506,6 @@ Or change later at <ph name="SETTINGS_EXTENIONS_LINK">$2<ex>brave://settings/ext
</message>
</if>

<!-- Web Discovery dialog -->
<if expr="not is_android">
<message name="IDS_WEB_DISCOVERY_DIALOG_HEADER_TEXT" desc="The text for web discovery dialog header">
Want to make Brave Search even better?
</message>
<message name="IDS_WEB_DISCOVERY_DIALOG_CONTENTS_TEXT" desc="The text for web discovery dialog contents">
Opt in to the Web Discovery Project to anonymously contribute some search &amp; browsing data, and improve Brave Search results for all. Privacy-preserving. And zero effort. <ph name="LEARN_MORE_TEXT">$1<ex>Learn more</ex></ph>
</message>
<message name="IDS_WEB_DISCOVERY_DIALOG_CONTENTS_TEXT_LEARN_MORE_PART" desc="The text learn more link for web discovery dialog contents. This text should be same with above Learn more text in CONTENTS_TEXT">
Learn more
</message>
<message name="IDS_WEB_DISCOVERY_DIALOG_DONT_ASK_AGAIN_TEXT" desc="The text for disabling web discovery dialog checkbox">
Don't ask again
</message>
<message name="IDS_WEB_DISCOVERY_DIALOG_OK_BUTTON_TEXT" desc="The text for ok button">
Turn on
</message>
<message name="IDS_WEB_DISCOVERY_DIALOG_CANCEL_BUTTON_TEXT" desc="The text for cancel button">
No thanks
</message>
</if>

<!-- Brave crash report permission ask dialog -->
<if expr="not is_android">
<message name="IDS_CRASH_REPORT_PERMISSION_ASK_DIALOG_OK_BUTTON_LABEL" desc="The text for ok button">
Expand Down Expand Up @@ -601,6 +579,22 @@ Or change later at <ph name="SETTINGS_EXTENIONS_LINK">$2<ex>brave://settings/ext
<message name="IDS_ACC_BRAVE_SEARCH_CONVERSION_DISMISS_BUTTON" desc="Announcement when the dismiss button is focused.">
Dismiss Brave search conversion, press Enter to remove this suggestion
</message>
<!-- web Discovery InfoBar -->
<message name="IDS_WEB_DISCOVERY_INFOBAR_MESSAGE" desc="The text for web discovery infobar message">
Help improve <ph name="SEARCH_NAME">$1<ex>Brave Search</ex></ph> by sending anonymous usage data. <ph name="MORE_INFO">$2<ex>More info</ex></ph>
</message>
<message name="IDS_WEB_DISCOVERY_INFOBAR_MESSAGE_BRAVE_SEARCH" desc="The text for brave search part in message">
Brave Search
</message>
<message name="IDS_WEB_DISCOVERY_INFOBAR_MESSAGE_MORE_INFO" desc="The text for more info link part in message">
More info
</message>
<message name="IDS_WEB_DISCOVERY_INFOBAR_OK_BUTTON_LABEL" desc="The text for ok button in infobar">
OK
</message>
<message name="IDS_WEB_DISCOVERY_INFOBAR_NO_THANKS_LABEL" desc="The text for no thanks button in infobar">
No thanks
</message>
</if>

<!-- Brave Ads -->
Expand Down
4 changes: 3 additions & 1 deletion app/theme/brave_theme_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_88" file="common/avatars/avatar_bonbon_royal.png" />
<structure type="chrome_scaled_image" name="IDR_PROFILE_AVATAR_89" file="common/avatars/avatar_bonbon_ninja.png" />

<structure type="chrome_scaled_image" name="IDR_BRAVE_WEB_DISCOVERY_INFOBAR_BG_GRAPHIC" file="brave/brave_web_discovery_infobar_bg_graphic.png" />
<structure type="chrome_scaled_image" name="IDR_BRAVE_WEB_DISCOVERY_INFOBAR_BG_GRAPHIC_DARK" file="brave/brave_web_discovery_infobar_bg_graphic_dark.png" />
<structure type="chrome_scaled_image" name="IDR_BRAVE_WEB_DISCOVERY_INFOBAR_ICON" file="brave/brave_web_discovery_infobar_icon.png" />
<structure type="chrome_scaled_image" name="IDR_BRAVE_SEARCH_CONVERSION_BANNER_GRAPHIC" file="brave/brave_search_conversion_banner_graphic.png" />
<structure type="chrome_scaled_image" name="IDR_BRAVE_SEARCH_CONVERSION_BANNER_GRAPHIC_DARK" file="brave/brave_search_conversion_banner_graphic_dark.png" />
<structure type="chrome_scaled_image" name="IDR_BRAVE_SEARCH_LOGO_IN_WEB_DISCOVERY_DIALOG" file="brave/brave_search_logo_in_web_discovery_dialog.png" />
<structure type="chrome_scaled_image" name="IDR_BRAVE_SEARCH_LOGO_IN_SEARCH_PROMOTION" file="brave/brave_search_logo_in_search_promotion.png" />
</if>
</structures>
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/vector_icons/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ aggregate_vector_icons("brave_vector_icons") {
"sidebar_toolbar_button_right.icon",
"vpn_indicator.icon",
"wallet_toolbar_button.icon",
"web_discovery_infobar_close_button.icon",
]

if (enable_sidebar) {
Expand Down
21 changes: 21 additions & 0 deletions app/vector_icons/web_discovery_infobar_close_button.icon
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2022 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// you can obtain one at http://mozilla.org/MPL/2.0/.

CANVAS_DIMENSIONS, 20,
MOVE_TO, 4.99f, 4.99f,
R_ARC_TO, 0.71f, 0.71f, 0, 0, 0, 0, 1,
LINE_TO, 9, 10,
LINE_TO, 4.99f, 14.01f,
R_ARC_TO, 0.71f, 0.71f, 0, 1, 0, 1, 1,
LINE_TO, 10, 11,
R_LINE_TO, 4.01f, 4.01f,
R_ARC_TO, 0.71f, 0.71f, 0, 0, 0, 1, -1,
LINE_TO, 11, 10,
R_LINE_TO, 4.01f, -4.01f,
R_ARC_TO, 0.71f, 0.71f, 0, 1, 0, -1, -1,
LINE_TO, 10, 9,
LINE_TO, 6, 4.99f,
R_ARC_TO, 0.71f, 0.71f, 0, 0, 0, -1, 0,
CLOSE
9 changes: 7 additions & 2 deletions browser/brave_profile_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ void RegisterProfilePrefsForMigration(

// Added 01/2022
registry->RegisterBooleanPref(brave_rewards::prefs::kHideButton, false);

#if BUILDFLAG(ENABLE_EXTENSIONS)
// Added 11/2022
registry->RegisterBooleanPref(kDontAskEnableWebDiscovery, false);
registry->RegisterIntegerPref(kBraveSearchVisitCount, 0);
sangwoo108 marked this conversation as resolved.
Show resolved Hide resolved
#endif
}

void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
Expand Down Expand Up @@ -393,8 +399,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
#if BUILDFLAG(ENABLE_EXTENSIONS)
// Web discovery extension, default false
registry->RegisterBooleanPref(kWebDiscoveryEnabled, false);
registry->RegisterBooleanPref(kDontAskEnableWebDiscovery, false);
registry->RegisterIntegerPref(kBraveSearchVisitCount, 0);
registry->RegisterDictionaryPref(kWebDiscoveryCTAState);
sangwoo108 marked this conversation as resolved.
Show resolved Hide resolved
#endif

#if BUILDFLAG(ENABLE_SPEEDREADER)
Expand Down
2 changes: 0 additions & 2 deletions browser/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,6 @@ source_set("ui") {
"views/toolbar/bookmark_button.h",
"views/toolbar/brave_app_menu.cc",
"views/toolbar/brave_app_menu.h",
"views/web_discovery_dialog_view.cc",
"views/web_discovery_dialog_view.h",
"views/window_closing_confirm_dialog_view.cc",
"views/window_closing_confirm_dialog_view.h",
]
Expand Down
5 changes: 0 additions & 5 deletions browser/ui/browser_dialogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@

class Browser;

namespace content {
class WebContents;
} // namespace content

namespace brave {

// Tab restore dialog will be launched after ask dialog is closed.
void ShowCrashReportPermissionAskDialog(Browser* browser);
void ShowWebDiscoveryDialog(Browser* browser, content::WebContents* contents);

} // namespace brave

Expand Down
5 changes: 5 additions & 0 deletions browser/ui/color/brave_color_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
E_CPONLY(kColorLocationBarFocusRing) \
E_CPONLY(kColorDialogDontAskAgainButton) \
E_CPONLY(kColorDialogDontAskAgainButtonHovered) \
E_CPONLY(kColorWebDiscoveryInfoBarBackground) \
E_CPONLY(kColorWebDiscoveryInfoBarMessage) \
E_CPONLY(kColorWebDiscoveryInfoBarLink) \
E_CPONLY(kColorWebDiscoveryInfoBarNoThanks) \
E_CPONLY(kColorWebDiscoveryInfoBarClose)

#define BRAVE_SEARCH_CONVERSION_COLOR_IDS \
E_CPONLY(kColorSearchConversionBannerTypeBackgroundBorder) \
Expand Down
16 changes: 16 additions & 0 deletions browser/ui/color/brave_color_mixer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,13 @@ void AddBraveLightThemeColorMixer(ui::ColorProvider* provider,
SkColorSetRGB(0xF0, 0xF2, 0xFF))};
#endif

mixer[kColorWebDiscoveryInfoBarBackground] = {
SkColorSetRGB(0xFF, 0xFF, 0xFF)};
mixer[kColorWebDiscoveryInfoBarMessage] = {SkColorSetRGB(0x1D, 0x1F, 0x25)};
mixer[kColorWebDiscoveryInfoBarLink] = {SkColorSetRGB(0x4C, 0x54, 0xD2)};
mixer[kColorWebDiscoveryInfoBarNoThanks] = {SkColorSetRGB(0x6B, 0x70, 0x84)};
mixer[kColorWebDiscoveryInfoBarClose] = {SkColorSetRGB(0x6B, 0x70, 0x84)};

// Colors for HelpBubble. IDs are defined in
// chrome/browser/ui/color/chrome_color_id.h
mixer[kColorFeaturePromoBubbleBackground] = {SK_ColorWHITE};
Expand Down Expand Up @@ -353,6 +360,15 @@ void AddBraveDarkThemeColorMixer(ui::ColorProvider* provider,
SkColorSetRGB(0xF0, 0xF2, 0xFF))};
#endif

mixer[kColorWebDiscoveryInfoBarBackground] = {
SkColorSetRGB(0x1A, 0x1C, 0x22)};
mixer[kColorWebDiscoveryInfoBarMessage] = {SkColorSetRGB(0xFF, 0xFF, 0xFF)};
mixer[kColorWebDiscoveryInfoBarLink] = {SkColorSetRGB(0xA6, 0xAB, 0xEC)};
mixer[kColorWebDiscoveryInfoBarNoThanks] = {
SkColorSetARGB(0xBF, 0xEC, 0xEF, 0xF2)};
mixer[kColorWebDiscoveryInfoBarClose] = {
SkColorSetARGB(0xBF, 0x8C, 0x90, 0xA1)};

// Colors for HelpBubble. IDs are defined in
// chrome/browser/ui/color/chrome_color_id.h
mixer[kColorFeaturePromoBubbleBackground] = {SkColorSetRGB(0x12, 0x13, 0x16)};
Expand Down
8 changes: 8 additions & 0 deletions browser/ui/views/infobars/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ source_set("brave_wayback_machine") {
# Remove when https://github.com/brave/brave-browser/issues/10652 is resolved
check_includes = false
sources = [
"brave_infobar_container_view.cc",
"brave_infobar_container_view.h",
"brave_wayback_machine_infobar_button_container.cc",
"brave_wayback_machine_infobar_button_container.h",
"brave_wayback_machine_infobar_contents_view.cc",
Expand All @@ -10,6 +12,12 @@ source_set("brave_wayback_machine") {
"brave_wayback_machine_infobar_throbber.h",
"brave_wayback_machine_infobar_view.cc",
"brave_wayback_machine_infobar_view.h",
"custom_styled_label.cc",
"custom_styled_label.h",
"web_discovery_infobar_content_view.cc",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this in brave_wayback_machine?

"web_discovery_infobar_content_view.h",
"web_discovery_infobar_view.cc",
"web_discovery_infobar_view.h",
]

deps = [
Expand Down
19 changes: 19 additions & 0 deletions browser/ui/views/infobars/brave_infobar_container_view.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* Copyright (c) 2022 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "brave/browser/ui/views/infobars/brave_infobar_container_view.h"

#include <memory>

BraveInfoBarContainerView::BraveInfoBarContainerView(
infobars::InfoBarContainer::Delegate* delegate)
: InfoBarContainerView(delegate) {
// To hide shadow, replace it with empty view.
DCHECK(content_shadow_);
RemoveChildViewT(content_shadow_);
content_shadow_ = AddChildView(std::make_unique<views::View>());
}

BraveInfoBarContainerView::~BraveInfoBarContainerView() = default;
21 changes: 21 additions & 0 deletions browser/ui/views/infobars/brave_infobar_container_view.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* Copyright (c) 2022 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "chrome/browser/ui/views/infobars/infobar_container_view.h"

#ifndef BRAVE_BROWSER_UI_VIEWS_INFOBARS_BRAVE_INFOBAR_CONTAINER_VIEW_H_
#define BRAVE_BROWSER_UI_VIEWS_INFOBARS_BRAVE_INFOBAR_CONTAINER_VIEW_H_

class BraveInfoBarContainerView : public InfoBarContainerView {
public:
explicit BraveInfoBarContainerView(
infobars::InfoBarContainer::Delegate* delegate);
BraveInfoBarContainerView(const BraveInfoBarContainerView&) = delete;
BraveInfoBarContainerView& operator=(const BraveInfoBarContainerView&) =
delete;
~BraveInfoBarContainerView() override;
};

#endif // BRAVE_BROWSER_UI_VIEWS_INFOBARS_BRAVE_INFOBAR_CONTAINER_VIEW_H_
49 changes: 49 additions & 0 deletions browser/ui/views/infobars/custom_styled_label.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* Copyright (c) 2022 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "brave/browser/ui/views/infobars/custom_styled_label.h"

#include <utility>

#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/views/controls/link_fragment.h"

CustomStyledLabel::~CustomStyledLabel() = default;

std::unique_ptr<views::Label> CustomStyledLabel::CreateLabel(
const std::u16string& text,
const RangeStyleInfo& style_info,
const gfx::Range& range,
views::LinkFragment** previous_link_fragment) const {
if (style_info.text_style != views::style::STYLE_LINK)
return StyledLabel::CreateLabel(text, style_info, range,
previous_link_fragment);

std::unique_ptr<views::Label> result;
auto link = std::make_unique<views::LinkFragment>(
text, text_context_, views::style::STYLE_LINK, *previous_link_fragment);
*previous_link_fragment = link.get();
link->SetCallback(style_info.callback);
link->SetFontList(style_info.custom_font.value());
if (!style_info.accessible_name.empty())
link->SetAccessibleName(style_info.accessible_name);

result = std::move(link);

if (style_info.override_color)
result->SetEnabledColor(style_info.override_color.value());
if (!style_info.tooltip.empty())
result->SetTooltipText(style_info.tooltip);
if (!style_info.accessible_name.empty())
result->SetAccessibleName(style_info.accessible_name);
if (displayed_on_background_color_)
result->SetBackgroundColor(displayed_on_background_color_.value());
result->SetAutoColorReadabilityEnabled(auto_color_readability_enabled_);
result->SetSubpixelRenderingEnabled(subpixel_rendering_enabled_);
return result;
}

BEGIN_METADATA(CustomStyledLabel, views::StyledLabel)
END_METADATA
35 changes: 35 additions & 0 deletions browser/ui/views/infobars/custom_styled_label.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* Copyright (c) 2022 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef BRAVE_BROWSER_UI_VIEWS_INFOBARS_CUSTOM_STYLED_LABEL_H_
#define BRAVE_BROWSER_UI_VIEWS_INFOBARS_CUSTOM_STYLED_LABEL_H_

#include <memory>
#include <string>

#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/views/controls/styled_label.h"

// TODO(simonhong): Move common place if needed.
// StyledLabel doesn't allow using custom font for link style.
// Use for setting custom font for link.
class CustomStyledLabel : public views::StyledLabel {
public:
METADATA_HEADER(CustomStyledLabel);
using StyledLabel::StyledLabel;
CustomStyledLabel(const CustomStyledLabel&) = delete;
CustomStyledLabel& operator=(const CustomStyledLabel&) = delete;
~CustomStyledLabel() override;

private:
// views::StyledLabel overrides:
std::unique_ptr<views::Label> CreateLabel(
sangwoo108 marked this conversation as resolved.
Show resolved Hide resolved
const std::u16string& text,
const RangeStyleInfo& style_info,
const gfx::Range& range,
views::LinkFragment** previous_link_component) const override;
};

#endif // BRAVE_BROWSER_UI_VIEWS_INFOBARS_CUSTOM_STYLED_LABEL_H_
Loading