Remove StyledLabelListener.
This replaces it with direct callback registration on the underlying links, conveyed by setting the callback on the RangeStyleInfo corresponding to the link. This allows eliminating parameters like the range, since a different callback or different bound arguments can be set for each range. With a change to how ContentSettingBubbleContents works (which was the other place using the Link* argument of Link::ClickedCallback), this allows reducing Link::ClickedCallback to one argument as well. It makes sense to make these changes simultaneously since they mostly affect the same listeners and thus this avoids changing lots of signatures twice. Bug: 1108460 Change-Id: Ie7c9cc7cafeb92b91aad2949e176b99d26d493e3 AX-Relnotes: n/a. Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2388944 Commit-Queue: Peter Kasting <pkasting@chromium.org> Reviewed-by: Xiyuan Xia <xiyuan@chromium.org> Reviewed-by: Peter Boström <pbos@chromium.org> Reviewed-by: Elly Fong-Jones <ellyjones@chromium.org> Cr-Commit-Position: refs/heads/master@{#805956}
This commit is contained in:

committed by
Commit Bot

parent
ef634b9bea
commit
10d5bf9896
ash
chrome/browser/ui/views
accessibility
apps
autofill
content_setting_bubble_contents.cccontent_setting_bubble_contents.hdevice_chooser_content_view.ccdevice_chooser_content_view.hdevice_chooser_content_view_unittest.ccinfobars
layout_provider_unittest.ccmedia_router
network_profile_bubble_view.ccpage_info
page_info_bubble_view.ccpage_info_bubble_view.hsafety_tip_page_info_bubble_view.ccsafety_tip_page_info_bubble_view.h
passwords
password_generation_confirmation_view.ccpassword_generation_confirmation_view.hpost_save_compromised_bubble_view.ccpost_save_compromised_bubble_view.h
payments
credit_card_editor_view_controller.cccredit_card_editor_view_controller.hcredit_card_editor_view_controller_browsertest.ccpayment_request_browsertest.ccpayment_request_sheet_controller.hpayment_sheet_view_controller.ccpayment_sheet_view_controller.h
profiles
safe_browsing
session_crashed_bubble_view.ccsession_crashed_bubble_view.hsharing
sync
tab_modal_confirm_dialog_views.cctab_modal_confirm_dialog_views.htoolbar
ui/views
@@ -2225,6 +2225,7 @@ test("ash_unittests") {
|
|||||||
"//ash/system/machine_learning:user_settings_event_proto",
|
"//ash/system/machine_learning:user_settings_event_proto",
|
||||||
"//base",
|
"//base",
|
||||||
"//base/test:test_support",
|
"//base/test:test_support",
|
||||||
|
"//base/util/ranges",
|
||||||
"//base/util/values:values_util",
|
"//base/util/values:values_util",
|
||||||
"//build:branding_buildflags",
|
"//build:branding_buildflags",
|
||||||
"//chromeos:test_support",
|
"//chromeos:test_support",
|
||||||
|
@@ -215,13 +215,6 @@ void PrivacyInfoView::ButtonPressed(views::Button* sender,
|
|||||||
CloseButtonPressed();
|
CloseButtonPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrivacyInfoView::StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) {
|
|
||||||
if (label == text_view_)
|
|
||||||
LinkClicked();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrivacyInfoView::InitLayout() {
|
void PrivacyInfoView::InitLayout() {
|
||||||
auto* layout_manager = SetLayoutManager(std::make_unique<views::BoxLayout>(
|
auto* layout_manager = SetLayoutManager(std::make_unique<views::BoxLayout>(
|
||||||
views::BoxLayout::Orientation::kHorizontal,
|
views::BoxLayout::Orientation::kHorizontal,
|
||||||
@@ -262,7 +255,7 @@ void PrivacyInfoView::InitText() {
|
|||||||
size_t offset;
|
size_t offset;
|
||||||
const base::string16 text =
|
const base::string16 text =
|
||||||
l10n_util::GetStringFUTF16(info_string_id_, link, &offset);
|
l10n_util::GetStringFUTF16(info_string_id_, link, &offset);
|
||||||
text_view_ = AddChildView(std::make_unique<views::StyledLabel>(this));
|
text_view_ = AddChildView(std::make_unique<views::StyledLabel>());
|
||||||
text_view_->SetText(text);
|
text_view_->SetText(text);
|
||||||
|
|
||||||
views::StyledLabel::RangeStyleInfo style;
|
views::StyledLabel::RangeStyleInfo style;
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include "ash/app_list/views/search_result_base_view.h"
|
#include "ash/app_list/views/search_result_base_view.h"
|
||||||
#include "ui/views/controls/styled_label.h"
|
#include "ui/views/controls/styled_label.h"
|
||||||
#include "ui/views/controls/styled_label_listener.h"
|
|
||||||
#include "ui/views/view.h"
|
#include "ui/views/view.h"
|
||||||
|
|
||||||
namespace views {
|
namespace views {
|
||||||
@@ -21,8 +20,7 @@ class StyledLabel;
|
|||||||
namespace ash {
|
namespace ash {
|
||||||
|
|
||||||
// View representing privacy info in Launcher.
|
// View representing privacy info in Launcher.
|
||||||
class PrivacyInfoView : public SearchResultBaseView,
|
class PrivacyInfoView : public SearchResultBaseView {
|
||||||
public views::StyledLabelListener {
|
|
||||||
public:
|
public:
|
||||||
~PrivacyInfoView() override;
|
~PrivacyInfoView() override;
|
||||||
|
|
||||||
@@ -40,11 +38,6 @@ class PrivacyInfoView : public SearchResultBaseView,
|
|||||||
// views::ButtonListener:
|
// views::ButtonListener:
|
||||||
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
|
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
|
||||||
|
|
||||||
// views::StyledLabelListener:
|
|
||||||
void StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) override;
|
|
||||||
|
|
||||||
// SearchResultBaseView:
|
// SearchResultBaseView:
|
||||||
void SelectInitialResultAction(bool reverse_tab_order) override;
|
void SelectInitialResultAction(bool reverse_tab_order) override;
|
||||||
bool SelectNextResultAction(bool reverse_tab_order) override;
|
bool SelectNextResultAction(bool reverse_tab_order) override;
|
||||||
|
@@ -32,7 +32,6 @@
|
|||||||
#include "ui/views/border.h"
|
#include "ui/views/border.h"
|
||||||
#include "ui/views/controls/image_view.h"
|
#include "ui/views/controls/image_view.h"
|
||||||
#include "ui/views/controls/label.h"
|
#include "ui/views/controls/label.h"
|
||||||
#include "ui/views/controls/styled_label_listener.h"
|
|
||||||
#include "ui/views/layout/box_layout.h"
|
#include "ui/views/layout/box_layout.h"
|
||||||
#include "ui/views/layout/fill_layout.h"
|
#include "ui/views/layout/fill_layout.h"
|
||||||
|
|
||||||
@@ -293,12 +292,9 @@ class MonitoringWarningView : public NonAccessibleView {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Implements the right part of the expanded public session view.
|
// Implements the right part of the expanded public session view.
|
||||||
class RightPaneView : public NonAccessibleView,
|
class RightPaneView : public NonAccessibleView, public views::ButtonListener {
|
||||||
public views::ButtonListener,
|
|
||||||
public views::StyledLabelListener {
|
|
||||||
public:
|
public:
|
||||||
explicit RightPaneView(const base::RepeatingClosure& on_learn_more_tapped)
|
explicit RightPaneView(const base::RepeatingClosure& on_learn_more_tapped) {
|
||||||
: on_learn_more_tapped_(on_learn_more_tapped) {
|
|
||||||
SetPreferredSize(
|
SetPreferredSize(
|
||||||
gfx::Size(kExpandedViewWidthDp / 2, kExpandedViewHeightDp));
|
gfx::Size(kExpandedViewWidthDp / 2, kExpandedViewHeightDp));
|
||||||
SetBorder(views::CreateEmptyBorder(gfx::Insets(kHorizontalMarginPaneDp)));
|
SetBorder(views::CreateEmptyBorder(gfx::Insets(kHorizontalMarginPaneDp)));
|
||||||
@@ -322,7 +318,7 @@ class RightPaneView : public NonAccessibleView,
|
|||||||
const base::string16 text = l10n_util::GetStringFUTF16(
|
const base::string16 text = l10n_util::GetStringFUTF16(
|
||||||
IDS_ASH_LOGIN_PUBLIC_ACCOUNT_SIGNOUT_REMINDER, link, &offset);
|
IDS_ASH_LOGIN_PUBLIC_ACCOUNT_SIGNOUT_REMINDER, link, &offset);
|
||||||
learn_more_label_ =
|
learn_more_label_ =
|
||||||
labels_view_->AddChildView(std::make_unique<views::StyledLabel>(this));
|
labels_view_->AddChildView(std::make_unique<views::StyledLabel>());
|
||||||
learn_more_label_->SetText(text);
|
learn_more_label_->SetText(text);
|
||||||
|
|
||||||
views::StyledLabel::RangeStyleInfo style;
|
views::StyledLabel::RangeStyleInfo style;
|
||||||
@@ -332,7 +328,7 @@ class RightPaneView : public NonAccessibleView,
|
|||||||
learn_more_label_->AddStyleRange(gfx::Range(0, offset), style);
|
learn_more_label_->AddStyleRange(gfx::Range(0, offset), style);
|
||||||
|
|
||||||
views::StyledLabel::RangeStyleInfo link_style =
|
views::StyledLabel::RangeStyleInfo link_style =
|
||||||
views::StyledLabel::RangeStyleInfo::CreateForLink();
|
views::StyledLabel::RangeStyleInfo::CreateForLink(on_learn_more_tapped);
|
||||||
link_style.override_color = kPublicSessionBlueColor;
|
link_style.override_color = kPublicSessionBlueColor;
|
||||||
learn_more_label_->AddStyleRange(gfx::Range(offset, offset + link.length()),
|
learn_more_label_->AddStyleRange(gfx::Range(offset, offset + link.length()),
|
||||||
link_style);
|
link_style);
|
||||||
@@ -482,14 +478,6 @@ class RightPaneView : public NonAccessibleView,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// "Learn more" is clicked to show additional information of what the device
|
|
||||||
// admin may monitor.
|
|
||||||
void StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) override {
|
|
||||||
on_learn_more_tapped_.Run();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateForUser(const LoginUserInfo& user) {
|
void UpdateForUser(const LoginUserInfo& user) {
|
||||||
DCHECK_EQ(user.basic_user_info.type,
|
DCHECK_EQ(user.basic_user_info.type,
|
||||||
user_manager::USER_TYPE_PUBLIC_ACCOUNT);
|
user_manager::USER_TYPE_PUBLIC_ACCOUNT);
|
||||||
@@ -655,8 +643,6 @@ class RightPaneView : public NonAccessibleView,
|
|||||||
bool show_advanced_changed_by_user_ = false;
|
bool show_advanced_changed_by_user_ = false;
|
||||||
bool language_changed_by_user_ = false;
|
bool language_changed_by_user_ = false;
|
||||||
|
|
||||||
base::RepeatingClosure on_learn_more_tapped_;
|
|
||||||
|
|
||||||
base::WeakPtrFactory<RightPaneView> weak_factory_{this};
|
base::WeakPtrFactory<RightPaneView> weak_factory_{this};
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(RightPaneView);
|
DISALLOW_COPY_AND_ASSIGN(RightPaneView);
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
#include "ash/public/cpp/login_types.h"
|
#include "ash/public/cpp/login_types.h"
|
||||||
#include "ash/strings/grit/ash_strings.h"
|
#include "ash/strings/grit/ash_strings.h"
|
||||||
#include "base/bind_helpers.h"
|
#include "base/bind_helpers.h"
|
||||||
|
#include "base/util/ranges/algorithm.h"
|
||||||
#include "chromeos/strings/grit/chromeos_strings.h"
|
#include "chromeos/strings/grit/chromeos_strings.h"
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
#include "ui/base/l10n/l10n_util.h"
|
#include "ui/base/l10n/l10n_util.h"
|
||||||
@@ -158,13 +159,14 @@ TEST_P(LoginExpandedPublicAccountViewTest, ToggleAdvancedView) {
|
|||||||
// Verifies warning dialog shows up correctly.
|
// Verifies warning dialog shows up correctly.
|
||||||
TEST_P(LoginExpandedPublicAccountViewTest, ShowWarningDialog) {
|
TEST_P(LoginExpandedPublicAccountViewTest, ShowWarningDialog) {
|
||||||
LoginExpandedPublicAccountView::TestApi test_api(public_account_);
|
LoginExpandedPublicAccountView::TestApi test_api(public_account_);
|
||||||
views::StyledLabel::TestApi styled_label_test(test_api.learn_more_label());
|
|
||||||
EXPECT_EQ(test_api.warning_dialog(), nullptr);
|
EXPECT_EQ(test_api.warning_dialog(), nullptr);
|
||||||
ASSERT_EQ(styled_label_test.link_targets().size(), 1U);
|
|
||||||
|
|
||||||
// Tap on the learn more link.
|
// Tap on the learn more link.
|
||||||
views::Link* link = styled_label_test.link_targets().begin()->first;
|
const auto& children = test_api.learn_more_label()->children();
|
||||||
TapOnView(link);
|
const auto it = util::ranges::find(children, views::Link::kViewClassName,
|
||||||
|
&views::View::GetClassName);
|
||||||
|
DCHECK(it != children.cend());
|
||||||
|
TapOnView(*it);
|
||||||
ASSERT_NE(test_api.warning_dialog(), nullptr);
|
ASSERT_NE(test_api.warning_dialog(), nullptr);
|
||||||
EXPECT_TRUE(test_api.warning_dialog()->GetVisible());
|
EXPECT_TRUE(test_api.warning_dialog()->GetVisible());
|
||||||
|
|
||||||
|
@@ -72,7 +72,7 @@ class InvertBubbleView : public views::BubbleDialogDelegateView,
|
|||||||
// Overridden from views::ButtonListener:
|
// Overridden from views::ButtonListener:
|
||||||
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
|
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
|
||||||
|
|
||||||
void OpenLink(const std::string& url, views::Link* source, int event_flags);
|
void OpenLink(const std::string& url, int event_flags);
|
||||||
|
|
||||||
Browser* browser_;
|
Browser* browser_;
|
||||||
|
|
||||||
@@ -141,12 +141,10 @@ bool InvertBubbleView::ShouldShowCloseButton() const {
|
|||||||
void InvertBubbleView::ButtonPressed(views::Button* sender,
|
void InvertBubbleView::ButtonPressed(views::Button* sender,
|
||||||
const ui::Event& event) {
|
const ui::Event& event) {
|
||||||
if (sender->tag() == kLearnMoreButton)
|
if (sender->tag() == kLearnMoreButton)
|
||||||
OpenLink(kLearnMoreUrl, nullptr, event.flags());
|
OpenLink(kLearnMoreUrl, event.flags());
|
||||||
}
|
}
|
||||||
|
|
||||||
void InvertBubbleView::OpenLink(const std::string& url,
|
void InvertBubbleView::OpenLink(const std::string& url, int event_flags) {
|
||||||
views::Link* source,
|
|
||||||
int event_flags) {
|
|
||||||
WindowOpenDisposition disposition = ui::DispositionFromEventFlags(
|
WindowOpenDisposition disposition = ui::DispositionFromEventFlags(
|
||||||
event_flags, WindowOpenDisposition::NEW_FOREGROUND_TAB);
|
event_flags, WindowOpenDisposition::NEW_FOREGROUND_TAB);
|
||||||
content::OpenURLParams params(GURL(url), content::Referrer(), disposition,
|
content::OpenURLParams params(GURL(url), content::Referrer(), disposition,
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "chrome/browser/ui/views/apps/app_dialog/app_uninstall_dialog_view.h"
|
#include "chrome/browser/ui/views/apps/app_dialog/app_uninstall_dialog_view.h"
|
||||||
|
|
||||||
|
#include "base/bind.h"
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
#include "base/feature_list.h"
|
#include "base/feature_list.h"
|
||||||
#include "base/strings/string16.h"
|
#include "base/strings/string16.h"
|
||||||
@@ -211,7 +212,7 @@ void AppUninstallDialogView::InitializeCheckbox(const GURL& app_launch_url) {
|
|||||||
l10n_util::GetStringUTF16(IDS_APP_UNINSTALL_PROMPT_LEARN_MORE);
|
l10n_util::GetStringUTF16(IDS_APP_UNINSTALL_PROMPT_LEARN_MORE);
|
||||||
replacements.push_back(learn_more_text);
|
replacements.push_back(learn_more_text);
|
||||||
|
|
||||||
auto checkbox_label = std::make_unique<views::StyledLabel>(this);
|
auto checkbox_label = std::make_unique<views::StyledLabel>();
|
||||||
std::vector<size_t> offsets;
|
std::vector<size_t> offsets;
|
||||||
checkbox_label->SetText(l10n_util::GetStringFUTF16(
|
checkbox_label->SetText(l10n_util::GetStringFUTF16(
|
||||||
is_google ? IDS_APP_UNINSTALL_PROMPT_REMOVE_DATA_CHECKBOX_FOR_GOOGLE
|
is_google ? IDS_APP_UNINSTALL_PROMPT_REMOVE_DATA_CHECKBOX_FOR_GOOGLE
|
||||||
@@ -222,7 +223,15 @@ void AppUninstallDialogView::InitializeCheckbox(const GURL& app_launch_url) {
|
|||||||
|
|
||||||
checkbox_label->AddStyleRange(
|
checkbox_label->AddStyleRange(
|
||||||
gfx::Range(offset, offset + learn_more_text.length()),
|
gfx::Range(offset, offset + learn_more_text.length()),
|
||||||
views::StyledLabel::RangeStyleInfo::CreateForLink());
|
views::StyledLabel::RangeStyleInfo::CreateForLink(base::BindRepeating(
|
||||||
|
[](Profile* profile) {
|
||||||
|
NavigateParams params(
|
||||||
|
profile,
|
||||||
|
GURL("https://support.google.com/chromebook/?p=uninstallpwa"),
|
||||||
|
ui::PAGE_TRANSITION_LINK);
|
||||||
|
Navigate(¶ms);
|
||||||
|
},
|
||||||
|
profile_)));
|
||||||
views::StyledLabel::RangeStyleInfo checkbox_style;
|
views::StyledLabel::RangeStyleInfo checkbox_style;
|
||||||
checkbox_style.text_style = views::style::STYLE_PRIMARY;
|
checkbox_style.text_style = views::style::STYLE_PRIMARY;
|
||||||
gfx::Range before_link_range(0, offset);
|
gfx::Range before_link_range(0, offset);
|
||||||
@@ -311,15 +320,6 @@ void AppUninstallDialogView::InitializeViewWithMessage(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void AppUninstallDialogView::StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) {
|
|
||||||
NavigateParams params(
|
|
||||||
profile_, GURL("https://support.google.com/chromebook/?p=uninstallpwa"),
|
|
||||||
ui::PAGE_TRANSITION_LINK);
|
|
||||||
Navigate(¶ms);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppUninstallDialogView::OnDialogCancelled() {
|
void AppUninstallDialogView::OnDialogCancelled() {
|
||||||
uninstall_dialog()->OnDialogClosed(false /* uninstall */,
|
uninstall_dialog()->OnDialogClosed(false /* uninstall */,
|
||||||
false /* clear_site_data */,
|
false /* clear_site_data */,
|
||||||
|
@@ -12,7 +12,6 @@
|
|||||||
#include "chrome/browser/ui/views/apps/app_dialog/app_dialog_view.h"
|
#include "chrome/browser/ui/views/apps/app_dialog/app_dialog_view.h"
|
||||||
#include "components/services/app_service/public/mojom/types.mojom-forward.h"
|
#include "components/services/app_service/public/mojom/types.mojom-forward.h"
|
||||||
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
|
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
|
||||||
#include "ui/views/controls/styled_label_listener.h"
|
|
||||||
|
|
||||||
class Profile;
|
class Profile;
|
||||||
|
|
||||||
@@ -29,8 +28,7 @@ class ImageSkia;
|
|||||||
// apps::UninstallDialog::UiBase to notify AppService, which transfers control
|
// apps::UninstallDialog::UiBase to notify AppService, which transfers control
|
||||||
// to the publisher to uninstall the app.
|
// to the publisher to uninstall the app.
|
||||||
class AppUninstallDialogView : public apps::UninstallDialog::UiBase,
|
class AppUninstallDialogView : public apps::UninstallDialog::UiBase,
|
||||||
public AppDialogView,
|
public AppDialogView {
|
||||||
public views::StyledLabelListener {
|
|
||||||
public:
|
public:
|
||||||
AppUninstallDialogView(Profile* profile,
|
AppUninstallDialogView(Profile* profile,
|
||||||
apps::mojom::AppType app_type,
|
apps::mojom::AppType app_type,
|
||||||
@@ -60,11 +58,6 @@ class AppUninstallDialogView : public apps::UninstallDialog::UiBase,
|
|||||||
void InitializeViewWithMessage(const base::string16& message);
|
void InitializeViewWithMessage(const base::string16& message);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// views::StyledLabelListener methods.
|
|
||||||
void StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) override;
|
|
||||||
|
|
||||||
void OnDialogCancelled();
|
void OnDialogCancelled();
|
||||||
void OnDialogAccepted();
|
void OnDialogAccepted();
|
||||||
|
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "chrome/browser/ui/views/autofill/payments/payments_view_util.h"
|
#include "chrome/browser/ui/views/autofill/payments/payments_view_util.h"
|
||||||
|
|
||||||
|
#include "base/bind.h"
|
||||||
#include "base/util/ranges/algorithm.h"
|
#include "base/util/ranges/algorithm.h"
|
||||||
#include "build/branding_buildflags.h"
|
#include "build/branding_buildflags.h"
|
||||||
#include "chrome/app/vector_icons/vector_icons.h"
|
#include "chrome/app/vector_icons/vector_icons.h"
|
||||||
@@ -131,38 +132,25 @@ std::unique_ptr<views::Textfield> CreateCvcTextfield() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LegalMessageView::LegalMessageView(const LegalMessageLines& legal_message_lines,
|
LegalMessageView::LegalMessageView(const LegalMessageLines& legal_message_lines,
|
||||||
LinkClickedCallback callback)
|
LinkClickedCallback callback) {
|
||||||
: legal_message_lines_(legal_message_lines),
|
|
||||||
callback_(std::move(callback)) {
|
|
||||||
SetLayoutManager(std::make_unique<views::BoxLayout>(
|
SetLayoutManager(std::make_unique<views::BoxLayout>(
|
||||||
views::BoxLayout::Orientation::kVertical));
|
views::BoxLayout::Orientation::kVertical));
|
||||||
for (const LegalMessageLine& line : legal_message_lines) {
|
for (const LegalMessageLine& line : legal_message_lines) {
|
||||||
views::StyledLabel* label =
|
views::StyledLabel* label =
|
||||||
AddChildView(std::make_unique<views::StyledLabel>(this));
|
AddChildView(std::make_unique<views::StyledLabel>());
|
||||||
label->SetText(line.text());
|
label->SetText(line.text());
|
||||||
label->SetTextContext(views::style::CONTEXT_DIALOG_BODY_TEXT);
|
label->SetTextContext(views::style::CONTEXT_DIALOG_BODY_TEXT);
|
||||||
label->SetDefaultTextStyle(views::style::STYLE_SECONDARY);
|
label->SetDefaultTextStyle(views::style::STYLE_SECONDARY);
|
||||||
for (const LegalMessageLine::Link& link : line.links()) {
|
for (const LegalMessageLine::Link& link : line.links()) {
|
||||||
label->AddStyleRange(link.range,
|
label->AddStyleRange(link.range,
|
||||||
views::StyledLabel::RangeStyleInfo::CreateForLink());
|
views::StyledLabel::RangeStyleInfo::CreateForLink(
|
||||||
|
base::BindRepeating(callback, link.url)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LegalMessageView::~LegalMessageView() = default;
|
LegalMessageView::~LegalMessageView() = default;
|
||||||
|
|
||||||
void LegalMessageView::StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) {
|
|
||||||
const int label_index = GetIndexOf(label);
|
|
||||||
DCHECK_LT(size_t{label_index}, legal_message_lines_.size());
|
|
||||||
const auto& links = legal_message_lines_[label_index].links();
|
|
||||||
const auto it =
|
|
||||||
util::ranges::find(links, range, &LegalMessageLine::Link::range);
|
|
||||||
DCHECK(it != links.end());
|
|
||||||
callback_.Run(it->url);
|
|
||||||
}
|
|
||||||
|
|
||||||
PaymentsBubbleClosedReason GetPaymentsBubbleClosedReasonFromWidgetClosedReason(
|
PaymentsBubbleClosedReason GetPaymentsBubbleClosedReasonFromWidgetClosedReason(
|
||||||
views::Widget::ClosedReason reason) {
|
views::Widget::ClosedReason reason) {
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
|
@@ -13,13 +13,11 @@
|
|||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
#include "third_party/skia/include/core/SkColor.h"
|
#include "third_party/skia/include/core/SkColor.h"
|
||||||
#include "ui/gfx/color_palette.h"
|
#include "ui/gfx/color_palette.h"
|
||||||
#include "ui/views/controls/styled_label_listener.h"
|
|
||||||
#include "ui/views/view.h"
|
#include "ui/views/view.h"
|
||||||
#include "ui/views/widget/widget.h"
|
#include "ui/views/widget/widget.h"
|
||||||
#include "url/gurl.h"
|
#include "url/gurl.h"
|
||||||
|
|
||||||
namespace views {
|
namespace views {
|
||||||
class StyledLabel;
|
|
||||||
class Textfield;
|
class Textfield;
|
||||||
} // namespace views
|
} // namespace views
|
||||||
|
|
||||||
@@ -43,22 +41,13 @@ std::unique_ptr<views::Textfield> CreateCvcTextfield();
|
|||||||
|
|
||||||
// Defines a view with legal message. This class handles the legal message
|
// Defines a view with legal message. This class handles the legal message
|
||||||
// parsing and the links clicking events.
|
// parsing and the links clicking events.
|
||||||
class LegalMessageView : public views::View, public views::StyledLabelListener {
|
class LegalMessageView : public views::View {
|
||||||
public:
|
public:
|
||||||
using LinkClickedCallback = base::RepeatingCallback<void(const GURL&)>;
|
using LinkClickedCallback = base::RepeatingCallback<void(const GURL&)>;
|
||||||
|
|
||||||
explicit LegalMessageView(const LegalMessageLines& legal_message_lines,
|
explicit LegalMessageView(const LegalMessageLines& legal_message_lines,
|
||||||
LinkClickedCallback callback);
|
LinkClickedCallback callback);
|
||||||
~LegalMessageView() override;
|
~LegalMessageView() override;
|
||||||
|
|
||||||
// views::StyledLabelListener:
|
|
||||||
void StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const LegalMessageLines legal_message_lines_;
|
|
||||||
const LinkClickedCallback callback_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PaymentsBubbleClosedReason GetPaymentsBubbleClosedReasonFromWidgetClosedReason(
|
PaymentsBubbleClosedReason GetPaymentsBubbleClosedReasonFromWidgetClosedReason(
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
|
#include "base/util/ranges/algorithm.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
#include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
|
#include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
|
||||||
#include "chrome/browser/ui/browser_dialogs.h"
|
#include "chrome/browser/ui/browser_dialogs.h"
|
||||||
@@ -200,9 +201,6 @@ class ContentSettingBubbleContents::ListItemContainer : public views::View {
|
|||||||
// Calling this will delete related children.
|
// Calling this will delete related children.
|
||||||
void RemoveRowAtIndex(int index);
|
void RemoveRowAtIndex(int index);
|
||||||
|
|
||||||
// Returns row index of |link| among list items.
|
|
||||||
int GetRowIndexOf(const views::Link* link) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using Row = std::pair<views::ImageView*, views::View*>;
|
using Row = std::pair<views::ImageView*, views::View*>;
|
||||||
using NewRow = std::pair<std::unique_ptr<views::ImageView>,
|
using NewRow = std::pair<std::unique_ptr<views::ImageView>,
|
||||||
@@ -252,7 +250,14 @@ void ContentSettingBubbleContents::ListItemContainer::AddItem(
|
|||||||
link->SetElideBehavior(gfx::ELIDE_MIDDLE);
|
link->SetElideBehavior(gfx::ELIDE_MIDDLE);
|
||||||
link->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT);
|
link->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT);
|
||||||
link->set_callback(base::BindRepeating(
|
link->set_callback(base::BindRepeating(
|
||||||
&ContentSettingBubbleContents::LinkClicked, base::Unretained(parent_)));
|
[](const std::vector<Row>* items, const views::Link* link,
|
||||||
|
ContentSettingBubbleContents* parent, int event_flags) {
|
||||||
|
const auto it = util::ranges::find(*items, link, &Row::second);
|
||||||
|
DCHECK(it != items->cend());
|
||||||
|
parent->LinkClicked(std::distance(items->cbegin(), it), event_flags);
|
||||||
|
},
|
||||||
|
base::Unretained(&list_item_views_), base::Unretained(link.get()),
|
||||||
|
base::Unretained(parent_)));
|
||||||
item_contents = std::move(link);
|
item_contents = std::move(link);
|
||||||
} else {
|
} else {
|
||||||
item_contents = std::make_unique<views::View>();
|
item_contents = std::make_unique<views::View>();
|
||||||
@@ -292,16 +297,6 @@ void ContentSettingBubbleContents::ListItemContainer::RemoveRowAtIndex(
|
|||||||
AddRowToLayout(row);
|
AddRowToLayout(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ContentSettingBubbleContents::ListItemContainer::GetRowIndexOf(
|
|
||||||
const views::Link* link) const {
|
|
||||||
auto has_link = [link](const Row& row) { return row.second == link; };
|
|
||||||
auto iter =
|
|
||||||
std::find_if(list_item_views_.begin(), list_item_views_.end(), has_link);
|
|
||||||
return (iter == list_item_views_.end())
|
|
||||||
? -1
|
|
||||||
: std::distance(list_item_views_.begin(), iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContentSettingBubbleContents::ListItemContainer::ResetLayout() {
|
void ContentSettingBubbleContents::ListItemContainer::ResetLayout() {
|
||||||
views::GridLayout* layout =
|
views::GridLayout* layout =
|
||||||
SetLayoutManager(std::make_unique<views::GridLayout>());
|
SetLayoutManager(std::make_unique<views::GridLayout>());
|
||||||
@@ -624,10 +619,8 @@ ContentSettingBubbleContents::CreateHelpAndManageView() {
|
|||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSettingBubbleContents::LinkClicked(views::Link* source,
|
void ContentSettingBubbleContents::LinkClicked(int row, int event_flags) {
|
||||||
int event_flags) {
|
|
||||||
DCHECK(content_setting_bubble_model_);
|
DCHECK(content_setting_bubble_model_);
|
||||||
int row = list_item_container_->GetRowIndexOf(source);
|
|
||||||
DCHECK_NE(row, -1);
|
DCHECK_NE(row, -1);
|
||||||
content_setting_bubble_model_->OnListItemClicked(row, event_flags);
|
content_setting_bubble_model_->OnListItemClicked(row, event_flags);
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,6 @@ class Combobox;
|
|||||||
class ImageButton;
|
class ImageButton;
|
||||||
class RadioButton;
|
class RadioButton;
|
||||||
class LabelButton;
|
class LabelButton;
|
||||||
class Link;
|
|
||||||
} // namespace views
|
} // namespace views
|
||||||
|
|
||||||
// ContentSettingBubbleContents is used when the user turns on different kinds
|
// ContentSettingBubbleContents is used when the user turns on different kinds
|
||||||
@@ -77,7 +76,7 @@ class ContentSettingBubbleContents : public content::WebContentsObserver,
|
|||||||
// "learn more" button and a "manage" button.
|
// "learn more" button and a "manage" button.
|
||||||
std::unique_ptr<View> CreateHelpAndManageView();
|
std::unique_ptr<View> CreateHelpAndManageView();
|
||||||
|
|
||||||
void LinkClicked(views::Link* source, int event_flags);
|
void LinkClicked(int row, int event_flags);
|
||||||
void CustomLinkClicked();
|
void CustomLinkClicked();
|
||||||
|
|
||||||
void OnPerformAction(views::Combobox* combobox);
|
void OnPerformAction(views::Combobox* combobox);
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "chrome/browser/ui/views/device_chooser_content_view.h"
|
#include "chrome/browser/ui/views/device_chooser_content_view.h"
|
||||||
|
|
||||||
|
#include "base/bind.h"
|
||||||
#include "base/numerics/safe_conversions.h"
|
#include "base/numerics/safe_conversions.h"
|
||||||
#include "base/stl_util.h"
|
#include "base/stl_util.h"
|
||||||
#include "chrome/browser/ui/views/chrome_layout_provider.h"
|
#include "chrome/browser/ui/views/chrome_layout_provider.h"
|
||||||
@@ -157,11 +158,13 @@ DeviceChooserContentView::DeviceChooserContentView(
|
|||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
base::string16 text = l10n_util::GetStringFUTF16(
|
base::string16 text = l10n_util::GetStringFUTF16(
|
||||||
IDS_BLUETOOTH_DEVICE_CHOOSER_TURN_ADAPTER_OFF, link_text, &offset);
|
IDS_BLUETOOTH_DEVICE_CHOOSER_TURN_ADAPTER_OFF, link_text, &offset);
|
||||||
auto adapter_off_help = std::make_unique<views::StyledLabel>(this);
|
auto adapter_off_help = std::make_unique<views::StyledLabel>();
|
||||||
adapter_off_help->SetText(text);
|
adapter_off_help->SetText(text);
|
||||||
adapter_off_help->AddStyleRange(
|
adapter_off_help->AddStyleRange(
|
||||||
gfx::Range(0, link_text.size()),
|
gfx::Range(offset, offset + link_text.size()),
|
||||||
views::StyledLabel::RangeStyleInfo::CreateForLink());
|
views::StyledLabel::RangeStyleInfo::CreateForLink(
|
||||||
|
base::BindRepeating(&ChooserController::OpenAdapterOffHelpUrl,
|
||||||
|
base::Unretained(chooser_controller_.get()))));
|
||||||
adapter_off_view_ = add_centering_view(std::move(adapter_off_help));
|
adapter_off_view_ = add_centering_view(std::move(adapter_off_help));
|
||||||
|
|
||||||
UpdateTableView();
|
UpdateTableView();
|
||||||
@@ -271,12 +274,6 @@ void DeviceChooserContentView::OnRefreshStateChanged(bool refreshing) {
|
|||||||
GetWidget()->GetRootView()->Layout();
|
GetWidget()->GetRootView()->Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceChooserContentView::StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) {
|
|
||||||
chooser_controller_->OpenAdapterOffHelpUrl();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceChooserContentView::ButtonPressed(views::Button* sender,
|
void DeviceChooserContentView::ButtonPressed(views::Button* sender,
|
||||||
const ui::Event& event) {
|
const ui::Event& event) {
|
||||||
if (sender->tag() == kHelpButtonTag) {
|
if (sender->tag() == kHelpButtonTag) {
|
||||||
|
@@ -13,7 +13,6 @@
|
|||||||
#include "ui/base/models/table_model.h"
|
#include "ui/base/models/table_model.h"
|
||||||
#include "ui/gfx/range/range.h"
|
#include "ui/gfx/range/range.h"
|
||||||
#include "ui/views/controls/button/button.h"
|
#include "ui/views/controls/button/button.h"
|
||||||
#include "ui/views/controls/styled_label_listener.h"
|
|
||||||
#include "ui/views/view.h"
|
#include "ui/views/view.h"
|
||||||
|
|
||||||
class BluetoothStatusContainer;
|
class BluetoothStatusContainer;
|
||||||
@@ -30,7 +29,6 @@ class Throbber;
|
|||||||
class DeviceChooserContentView : public views::View,
|
class DeviceChooserContentView : public views::View,
|
||||||
public ui::TableModel,
|
public ui::TableModel,
|
||||||
public ChooserController::View,
|
public ChooserController::View,
|
||||||
public views::StyledLabelListener,
|
|
||||||
public views::ButtonListener {
|
public views::ButtonListener {
|
||||||
public:
|
public:
|
||||||
DeviceChooserContentView(
|
DeviceChooserContentView(
|
||||||
@@ -55,11 +53,6 @@ class DeviceChooserContentView : public views::View,
|
|||||||
void OnAdapterEnabledChanged(bool enabled) override;
|
void OnAdapterEnabledChanged(bool enabled) override;
|
||||||
void OnRefreshStateChanged(bool refreshing) override;
|
void OnRefreshStateChanged(bool refreshing) override;
|
||||||
|
|
||||||
// views::StyledLabelListener:
|
|
||||||
void StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) override;
|
|
||||||
|
|
||||||
// views::ButtonListener:
|
// views::ButtonListener:
|
||||||
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
|
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
|
||||||
|
|
||||||
|
@@ -41,11 +41,13 @@ class DeviceChooserContentViewTest : public ChromeViewsTestBase {
|
|||||||
table_observer_ = std::make_unique<MockTableViewObserver>();
|
table_observer_ = std::make_unique<MockTableViewObserver>();
|
||||||
auto controller = std::make_unique<FakeBluetoothChooserController>();
|
auto controller = std::make_unique<FakeBluetoothChooserController>();
|
||||||
controller_ = controller.get();
|
controller_ = controller.get();
|
||||||
content_view_ = std::make_unique<DeviceChooserContentView>(
|
widget_ = CreateTestWidget();
|
||||||
table_observer_.get(), std::move(controller));
|
content_view_ =
|
||||||
|
widget_->SetContentsView(std::make_unique<DeviceChooserContentView>(
|
||||||
|
table_observer_.get(), std::move(controller)));
|
||||||
|
|
||||||
// Also creates |bluetooth_status_container_|.
|
// Also creates |bluetooth_status_container_|.
|
||||||
extra_views_container_ = content_view().CreateExtraView();
|
extra_views_container_ = content_view_->CreateExtraView();
|
||||||
|
|
||||||
ASSERT_NE(nullptr, table_view());
|
ASSERT_NE(nullptr, table_view());
|
||||||
ASSERT_NE(nullptr, no_options_view());
|
ASSERT_NE(nullptr, no_options_view());
|
||||||
@@ -58,23 +60,31 @@ class DeviceChooserContentViewTest : public ChromeViewsTestBase {
|
|||||||
FakeBluetoothChooserController::BluetoothStatus::IDLE);
|
FakeBluetoothChooserController::BluetoothStatus::IDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TearDown() override {
|
||||||
|
// All windows need to be closed before tear down.
|
||||||
|
widget_.reset();
|
||||||
|
|
||||||
|
ChromeViewsTestBase::TearDown();
|
||||||
|
}
|
||||||
|
|
||||||
FakeBluetoothChooserController* controller() { return controller_; }
|
FakeBluetoothChooserController* controller() { return controller_; }
|
||||||
MockTableViewObserver& table_observer() { return *table_observer_; }
|
MockTableViewObserver& table_observer() { return *table_observer_; }
|
||||||
DeviceChooserContentView& content_view() { return *content_view_; }
|
DeviceChooserContentView* content_view() { return content_view_; }
|
||||||
|
views::Widget* widget() { return widget_.get(); }
|
||||||
|
|
||||||
views::TableView* table_view() {
|
views::TableView* table_view() {
|
||||||
return content_view().table_view_for_testing();
|
return content_view_->table_view_for_testing();
|
||||||
}
|
}
|
||||||
views::View* table_parent() { return content_view().table_parent_; }
|
views::View* table_parent() { return content_view_->table_parent_; }
|
||||||
ui::TableModel* table_model() { return table_view()->model(); }
|
ui::TableModel* table_model() { return table_view()->model(); }
|
||||||
views::View* no_options_view() { return content_view().no_options_view_; }
|
views::View* no_options_view() { return content_view_->no_options_view_; }
|
||||||
views::View* adapter_off_view() { return content_view().adapter_off_view_; }
|
views::View* adapter_off_view() { return content_view_->adapter_off_view_; }
|
||||||
views::LabelButton* re_scan_button() {
|
views::LabelButton* re_scan_button() {
|
||||||
return content_view().ReScanButtonForTesting();
|
return content_view_->ReScanButtonForTesting();
|
||||||
}
|
}
|
||||||
views::Throbber* throbber() { return content_view().ThrobberForTesting(); }
|
views::Throbber* throbber() { return content_view_->ThrobberForTesting(); }
|
||||||
views::Label* scanning_label() {
|
views::Label* scanning_label() {
|
||||||
return content_view().ScanningLabelForTesting();
|
return content_view_->ScanningLabelForTesting();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddUnpairedDevice() {
|
void AddUnpairedDevice() {
|
||||||
@@ -126,7 +136,8 @@ class DeviceChooserContentViewTest : public ChromeViewsTestBase {
|
|||||||
private:
|
private:
|
||||||
std::unique_ptr<MockTableViewObserver> table_observer_;
|
std::unique_ptr<MockTableViewObserver> table_observer_;
|
||||||
FakeBluetoothChooserController* controller_ = nullptr;
|
FakeBluetoothChooserController* controller_ = nullptr;
|
||||||
std::unique_ptr<DeviceChooserContentView> content_view_;
|
DeviceChooserContentView* content_view_ = nullptr;
|
||||||
|
std::unique_ptr<views::Widget> widget_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(DeviceChooserContentViewTest);
|
DISALLOW_COPY_AND_ASSIGN(DeviceChooserContentViewTest);
|
||||||
};
|
};
|
||||||
@@ -255,9 +266,10 @@ TEST_F(DeviceChooserContentViewTest, ScanForDevices) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DeviceChooserContentViewTest, ClickAdapterOffHelpLink) {
|
TEST_F(DeviceChooserContentViewTest, ClickAdapterOffHelpLink) {
|
||||||
|
widget()->LayoutRootViewIfNecessary();
|
||||||
EXPECT_CALL(*controller(), OpenAdapterOffHelpUrl()).Times(1);
|
EXPECT_CALL(*controller(), OpenAdapterOffHelpUrl()).Times(1);
|
||||||
static_cast<views::StyledLabel*>(adapter_off_view()->children().front())
|
static_cast<views::StyledLabel*>(adapter_off_view()->children().front())
|
||||||
->LinkClicked(nullptr, 0);
|
->ClickLinkForTesting();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DeviceChooserContentViewTest, ClickRescanButton) {
|
TEST_F(DeviceChooserContentViewTest, ClickRescanButton) {
|
||||||
@@ -266,7 +278,7 @@ TEST_F(DeviceChooserContentViewTest, ClickRescanButton) {
|
|||||||
const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, point, point,
|
const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, point, point,
|
||||||
ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
|
ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
|
||||||
ui::EF_LEFT_MOUSE_BUTTON);
|
ui::EF_LEFT_MOUSE_BUTTON);
|
||||||
content_view().ButtonPressed(re_scan_button(), event);
|
content_view()->ButtonPressed(re_scan_button(), event);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DeviceChooserContentViewTest, ClickHelpButton) {
|
TEST_F(DeviceChooserContentViewTest, ClickHelpButton) {
|
||||||
@@ -279,7 +291,7 @@ TEST_F(DeviceChooserContentViewTest, ClickHelpButton) {
|
|||||||
const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, point, point,
|
const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, point, point,
|
||||||
ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
|
ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
|
||||||
ui::EF_LEFT_MOUSE_BUTTON);
|
ui::EF_LEFT_MOUSE_BUTTON);
|
||||||
content_view().ButtonPressed(help_button, event);
|
content_view()->ButtonPressed(help_button, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DeviceChooserContentViewTest, SetTableViewAlwaysDisabled) {
|
TEST_F(DeviceChooserContentViewTest, SetTableViewAlwaysDisabled) {
|
||||||
|
@@ -402,7 +402,7 @@ void InfoBarView::SetLabelDetails(views::Label* label) const {
|
|||||||
0));
|
0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void InfoBarView::LinkClicked(views::Link* source, int event_flags) {
|
void InfoBarView::LinkClicked(int event_flags) {
|
||||||
if (!owner())
|
if (!owner())
|
||||||
return; // We're closing; don't call anything, it might access the owner.
|
return; // We're closing; don't call anything, it might access the owner.
|
||||||
if (delegate()->LinkClicked(ui::DispositionFromEventFlags(event_flags)))
|
if (delegate()->LinkClicked(ui::DispositionFromEventFlags(event_flags)))
|
||||||
|
@@ -109,7 +109,7 @@ class InfoBarView : public infobars::InfoBar,
|
|||||||
void SetLabelDetails(views::Label* label) const;
|
void SetLabelDetails(views::Label* label) const;
|
||||||
|
|
||||||
// Callback used by the link created by CreateLink().
|
// Callback used by the link created by CreateLink().
|
||||||
void LinkClicked(views::Link* source, int event_flags);
|
void LinkClicked(int event_flags);
|
||||||
|
|
||||||
// The optional icon at the left edge of the InfoBar.
|
// The optional icon at the left edge of the InfoBar.
|
||||||
views::ImageView* icon_ = nullptr;
|
views::ImageView* icon_ = nullptr;
|
||||||
|
@@ -405,8 +405,9 @@ TEST_F(LayoutProviderTest, ExplicitTypographyLineHeight) {
|
|||||||
EXPECT_EQ(kBodyLineHeight, styled_label.height());
|
EXPECT_EQ(kBodyLineHeight, styled_label.height());
|
||||||
|
|
||||||
// Adding a link should not change the size.
|
// Adding a link should not change the size.
|
||||||
styled_label.AddStyleRange(
|
styled_label.AddStyleRange(gfx::Range(0, 2),
|
||||||
gfx::Range(0, 2), views::StyledLabel::RangeStyleInfo::CreateForLink());
|
views::StyledLabel::RangeStyleInfo::CreateForLink(
|
||||||
|
base::RepeatingClosure()));
|
||||||
styled_label.SizeToFit(kStyledLabelWidth);
|
styled_label.SizeToFit(kStyledLabelWidth);
|
||||||
EXPECT_EQ(kBodyLineHeight, styled_label.height());
|
EXPECT_EQ(kBodyLineHeight, styled_label.height());
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "chrome/browser/ui/views/media_router/cloud_services_dialog_view.h"
|
#include "chrome/browser/ui/views/media_router/cloud_services_dialog_view.h"
|
||||||
|
|
||||||
|
#include "base/bind.h"
|
||||||
#include "chrome/browser/ui/browser.h"
|
#include "chrome/browser/ui/browser.h"
|
||||||
#include "chrome/browser/ui/browser_tabstrip.h"
|
#include "chrome/browser/ui/browser_tabstrip.h"
|
||||||
#include "chrome/browser/ui/media_router/cloud_services_dialog.h"
|
#include "chrome/browser/ui/media_router/cloud_services_dialog.h"
|
||||||
@@ -111,11 +112,17 @@ void CloudServicesDialogView::Init() {
|
|||||||
gfx::Range learn_more_range(offsets[1], text.length());
|
gfx::Range learn_more_range(offsets[1], text.length());
|
||||||
|
|
||||||
views::StyledLabel::RangeStyleInfo link_style =
|
views::StyledLabel::RangeStyleInfo link_style =
|
||||||
views::StyledLabel::RangeStyleInfo::CreateForLink();
|
views::StyledLabel::RangeStyleInfo::CreateForLink(base::BindRepeating(
|
||||||
|
[](Browser* browser) {
|
||||||
|
chrome::AddSelectedTabWithURL(
|
||||||
|
browser, GURL(chrome::kCastCloudServicesHelpURL),
|
||||||
|
ui::PAGE_TRANSITION_LINK);
|
||||||
|
},
|
||||||
|
base::Unretained(browser_)));
|
||||||
link_style.disable_line_wrapping = false;
|
link_style.disable_line_wrapping = false;
|
||||||
|
|
||||||
views::StyledLabel* body_text =
|
views::StyledLabel* body_text =
|
||||||
AddChildView(std::make_unique<views::StyledLabel>(this));
|
AddChildView(std::make_unique<views::StyledLabel>());
|
||||||
body_text->SetText(text);
|
body_text->SetText(text);
|
||||||
body_text->SetHorizontalAlignment(gfx::ALIGN_LEFT);
|
body_text->SetHorizontalAlignment(gfx::ALIGN_LEFT);
|
||||||
body_text->AddStyleRange(learn_more_range, link_style);
|
body_text->AddStyleRange(learn_more_range, link_style);
|
||||||
@@ -126,13 +133,6 @@ void CloudServicesDialogView::WindowClosing() {
|
|||||||
instance_ = nullptr;
|
instance_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloudServicesDialogView::StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) {
|
|
||||||
const GURL url = GURL(chrome::kCastCloudServicesHelpURL);
|
|
||||||
chrome::AddSelectedTabWithURL(browser_, url, ui::PAGE_TRANSITION_LINK);
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
CloudServicesDialogView* CloudServicesDialogView::instance_ = nullptr;
|
CloudServicesDialogView* CloudServicesDialogView::instance_ = nullptr;
|
||||||
|
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include "base/strings/string16.h"
|
#include "base/strings/string16.h"
|
||||||
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
|
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
|
||||||
#include "ui/views/controls/styled_label_listener.h"
|
|
||||||
|
|
||||||
class Browser;
|
class Browser;
|
||||||
|
|
||||||
@@ -15,8 +14,7 @@ namespace media_router {
|
|||||||
|
|
||||||
// Dialog that asks the user whether they want to enable cloud services for the
|
// Dialog that asks the user whether they want to enable cloud services for the
|
||||||
// Cast feature.
|
// Cast feature.
|
||||||
class CloudServicesDialogView : public views::BubbleDialogDelegateView,
|
class CloudServicesDialogView : public views::BubbleDialogDelegateView {
|
||||||
public views::StyledLabelListener {
|
|
||||||
public:
|
public:
|
||||||
// Instantiates and shows the singleton dialog.
|
// Instantiates and shows the singleton dialog.
|
||||||
static void ShowDialog(views::View* anchor_view, Browser* browser);
|
static void ShowDialog(views::View* anchor_view, Browser* browser);
|
||||||
@@ -42,11 +40,6 @@ class CloudServicesDialogView : public views::BubbleDialogDelegateView,
|
|||||||
void Init() override;
|
void Init() override;
|
||||||
void WindowClosing() override;
|
void WindowClosing() override;
|
||||||
|
|
||||||
// views::StyledLabelListener:
|
|
||||||
void StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) override;
|
|
||||||
|
|
||||||
// The singleton dialog instance. This is a nullptr when a dialog is not
|
// The singleton dialog instance. This is a nullptr when a dialog is not
|
||||||
// shown.
|
// shown.
|
||||||
static CloudServicesDialogView* instance_;
|
static CloudServicesDialogView* instance_;
|
||||||
|
@@ -35,7 +35,7 @@ class NetworkProfileBubbleView : public views::BubbleDialogDelegateView {
|
|||||||
void Init() override;
|
void Init() override;
|
||||||
bool Accept() override;
|
bool Accept() override;
|
||||||
|
|
||||||
void LinkClicked(views::Link* source, int event_flags);
|
void LinkClicked(int event_flags);
|
||||||
|
|
||||||
// Used for loading pages.
|
// Used for loading pages.
|
||||||
content::PageNavigator* navigator_;
|
content::PageNavigator* navigator_;
|
||||||
@@ -87,8 +87,7 @@ bool NetworkProfileBubbleView::Accept() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkProfileBubbleView::LinkClicked(views::Link* source,
|
void NetworkProfileBubbleView::LinkClicked(int event_flags) {
|
||||||
int event_flags) {
|
|
||||||
NetworkProfileBubble::RecordUmaEvent(
|
NetworkProfileBubble::RecordUmaEvent(
|
||||||
NetworkProfileBubble::METRIC_LEARN_MORE_CLICKED);
|
NetworkProfileBubble::METRIC_LEARN_MORE_CLICKED);
|
||||||
WindowOpenDisposition disposition = ui::DispositionFromEventFlags(
|
WindowOpenDisposition disposition = ui::DispositionFromEventFlags(
|
||||||
|
@@ -132,16 +132,11 @@ std::unique_ptr<views::View> CreateSiteSettingsLink(
|
|||||||
// BubbleHeaderView is the UI element (view) that represents the header of a
|
// BubbleHeaderView is the UI element (view) that represents the header of a
|
||||||
// PageInfoBubbleView. The header shows the status of the site's identity check
|
// PageInfoBubbleView. The header shows the status of the site's identity check
|
||||||
// and the name of the site's identity.
|
// and the name of the site's identity.
|
||||||
class BubbleHeaderView : public views::View, public views::StyledLabelListener {
|
class BubbleHeaderView : public views::View {
|
||||||
public:
|
public:
|
||||||
BubbleHeaderView(PageInfoBubbleView* bubble, int side_margin);
|
BubbleHeaderView(PageInfoBubbleView* bubble, int side_margin);
|
||||||
~BubbleHeaderView() override;
|
~BubbleHeaderView() override;
|
||||||
|
|
||||||
// views::StyledLabelListener:
|
|
||||||
void StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) override;
|
|
||||||
|
|
||||||
// Sets the security summary for the current page.
|
// Sets the security summary for the current page.
|
||||||
void SetSummary(const base::string16& summary_text);
|
void SetSummary(const base::string16& summary_text);
|
||||||
|
|
||||||
@@ -216,9 +211,7 @@ BubbleHeaderView::BubbleHeaderView(PageInfoBubbleView* bubble, int side_margin)
|
|||||||
|
|
||||||
layout->StartRow(views::GridLayout::kFixedSize, label_column_status);
|
layout->StartRow(views::GridLayout::kFixedSize, label_column_status);
|
||||||
|
|
||||||
auto security_details_label = std::make_unique<views::StyledLabel>(this);
|
auto security_details_label = std::make_unique<views::StyledLabel>();
|
||||||
security_details_label->SetID(
|
|
||||||
PageInfoBubbleView::VIEW_ID_PAGE_INFO_LABEL_SECURITY_DETAILS);
|
|
||||||
security_details_label_ =
|
security_details_label_ =
|
||||||
layout->AddView(std::move(security_details_label), 1.0, 1.0,
|
layout->AddView(std::move(security_details_label), 1.0, 1.0,
|
||||||
views::GridLayout::FILL, views::GridLayout::LEADING);
|
views::GridLayout::FILL, views::GridLayout::LEADING);
|
||||||
@@ -240,20 +233,6 @@ BubbleHeaderView::BubbleHeaderView(PageInfoBubbleView* bubble, int side_margin)
|
|||||||
|
|
||||||
BubbleHeaderView::~BubbleHeaderView() = default;
|
BubbleHeaderView::~BubbleHeaderView() = default;
|
||||||
|
|
||||||
void BubbleHeaderView::StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) {
|
|
||||||
if (label->GetID() ==
|
|
||||||
PageInfoBubbleView::VIEW_ID_PAGE_INFO_LABEL_SECURITY_DETAILS) {
|
|
||||||
bubble_->SecurityDetailsClicked(event_flags);
|
|
||||||
} else {
|
|
||||||
DCHECK_EQ(
|
|
||||||
PageInfoBubbleView::VIEW_ID_PAGE_INFO_LABEL_RESET_CERTIFICATE_DECISIONS,
|
|
||||||
label->GetID());
|
|
||||||
bubble_->ResetDecisionsClicked();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BubbleHeaderView::SetDetails(const base::string16& details_text) {
|
void BubbleHeaderView::SetDetails(const base::string16& details_text) {
|
||||||
std::vector<base::string16> subst;
|
std::vector<base::string16> subst;
|
||||||
subst.push_back(details_text);
|
subst.push_back(details_text);
|
||||||
@@ -267,7 +246,9 @@ void BubbleHeaderView::SetDetails(const base::string16& details_text) {
|
|||||||
gfx::Range details_range(offsets[1], text.length());
|
gfx::Range details_range(offsets[1], text.length());
|
||||||
|
|
||||||
views::StyledLabel::RangeStyleInfo link_style =
|
views::StyledLabel::RangeStyleInfo link_style =
|
||||||
views::StyledLabel::RangeStyleInfo::CreateForLink();
|
views::StyledLabel::RangeStyleInfo::CreateForLink(
|
||||||
|
base::BindRepeating(&PageInfoBubbleView::SecurityDetailsClicked,
|
||||||
|
base::Unretained(bubble_)));
|
||||||
link_style.disable_line_wrapping = false;
|
link_style.disable_line_wrapping = false;
|
||||||
|
|
||||||
security_details_label_->AddStyleRange(details_range, link_style);
|
security_details_label_->AddStyleRange(details_range, link_style);
|
||||||
@@ -291,14 +272,14 @@ void BubbleHeaderView::AddResetDecisionsLabel() {
|
|||||||
base::ASCIIToUTF16("$1 $2"), subst, &offsets);
|
base::ASCIIToUTF16("$1 $2"), subst, &offsets);
|
||||||
views::StyledLabel* reset_cert_decisions_label =
|
views::StyledLabel* reset_cert_decisions_label =
|
||||||
reset_decisions_label_container_->AddChildView(
|
reset_decisions_label_container_->AddChildView(
|
||||||
std::make_unique<views::StyledLabel>(this));
|
std::make_unique<views::StyledLabel>());
|
||||||
reset_cert_decisions_label->SetText(text);
|
reset_cert_decisions_label->SetText(text);
|
||||||
reset_cert_decisions_label->SetID(
|
|
||||||
PageInfoBubbleView::VIEW_ID_PAGE_INFO_LABEL_RESET_CERTIFICATE_DECISIONS);
|
|
||||||
gfx::Range link_range(offsets[1], text.length());
|
gfx::Range link_range(offsets[1], text.length());
|
||||||
|
|
||||||
views::StyledLabel::RangeStyleInfo link_style =
|
views::StyledLabel::RangeStyleInfo link_style =
|
||||||
views::StyledLabel::RangeStyleInfo::CreateForLink();
|
views::StyledLabel::RangeStyleInfo::CreateForLink(
|
||||||
|
base::BindRepeating(&PageInfoBubbleView::ResetDecisionsClicked,
|
||||||
|
base::Unretained(bubble_)));
|
||||||
link_style.disable_line_wrapping = false;
|
link_style.disable_line_wrapping = false;
|
||||||
|
|
||||||
reset_cert_decisions_label->AddStyleRange(link_range, link_style);
|
reset_cert_decisions_label->AddStyleRange(link_range, link_style);
|
||||||
|
@@ -73,9 +73,7 @@ class PageInfoBubbleView : public PageInfoBubbleViewBase,
|
|||||||
VIEW_ID_PAGE_INFO_BUTTON_CLOSE,
|
VIEW_ID_PAGE_INFO_BUTTON_CLOSE,
|
||||||
VIEW_ID_PAGE_INFO_BUTTON_CHANGE_PASSWORD,
|
VIEW_ID_PAGE_INFO_BUTTON_CHANGE_PASSWORD,
|
||||||
VIEW_ID_PAGE_INFO_BUTTON_ALLOWLIST_PASSWORD_REUSE,
|
VIEW_ID_PAGE_INFO_BUTTON_ALLOWLIST_PASSWORD_REUSE,
|
||||||
VIEW_ID_PAGE_INFO_LABEL_SECURITY_DETAILS,
|
|
||||||
VIEW_ID_PAGE_INFO_LABEL_EV_CERTIFICATE_DETAILS,
|
VIEW_ID_PAGE_INFO_LABEL_EV_CERTIFICATE_DETAILS,
|
||||||
VIEW_ID_PAGE_INFO_LABEL_RESET_CERTIFICATE_DECISIONS,
|
|
||||||
VIEW_ID_PAGE_INFO_LINK_OR_BUTTON_COOKIE_DIALOG,
|
VIEW_ID_PAGE_INFO_LINK_OR_BUTTON_COOKIE_DIALOG,
|
||||||
VIEW_ID_PAGE_INFO_LINK_OR_BUTTON_SITE_SETTINGS,
|
VIEW_ID_PAGE_INFO_LINK_OR_BUTTON_SITE_SETTINGS,
|
||||||
VIEW_ID_PAGE_INFO_LINK_OR_BUTTON_CERTIFICATE_VIEWER,
|
VIEW_ID_PAGE_INFO_LINK_OR_BUTTON_CERTIFICATE_VIEWER,
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "chrome/browser/ui/views/page_info/safety_tip_page_info_bubble_view.h"
|
#include "chrome/browser/ui/views/page_info/safety_tip_page_info_bubble_view.h"
|
||||||
|
|
||||||
|
#include "base/bind.h"
|
||||||
#include "chrome/browser/platform_util.h"
|
#include "chrome/browser/platform_util.h"
|
||||||
#include "chrome/browser/reputation/reputation_service.h"
|
#include "chrome/browser/reputation/reputation_service.h"
|
||||||
#include "chrome/browser/reputation/safety_tip_ui_helper.h"
|
#include "chrome/browser/reputation/safety_tip_ui_helper.h"
|
||||||
@@ -172,10 +173,12 @@ SafetyTipPageInfoBubbleView::SafetyTipPageInfoBubbleView(
|
|||||||
// More info button.
|
// More info button.
|
||||||
auto info_text =
|
auto info_text =
|
||||||
l10n_util::GetStringUTF16(IDS_PAGE_INFO_SAFETY_TIP_MORE_INFO_LINK);
|
l10n_util::GetStringUTF16(IDS_PAGE_INFO_SAFETY_TIP_MORE_INFO_LINK);
|
||||||
auto info_link = std::make_unique<views::StyledLabel>(this);
|
auto info_link = std::make_unique<views::StyledLabel>();
|
||||||
info_link->SetText(info_text);
|
info_link->SetText(info_text);
|
||||||
views::StyledLabel::RangeStyleInfo link_style =
|
views::StyledLabel::RangeStyleInfo link_style =
|
||||||
views::StyledLabel::RangeStyleInfo::CreateForLink();
|
views::StyledLabel::RangeStyleInfo::CreateForLink(
|
||||||
|
base::BindRepeating(&SafetyTipPageInfoBubbleView::OpenHelpCenter,
|
||||||
|
base::Unretained(this)));
|
||||||
gfx::Range details_range(0, info_text.length());
|
gfx::Range details_range(0, info_text.length());
|
||||||
info_link->AddStyleRange(details_range, link_style);
|
info_link->AddStyleRange(details_range, link_style);
|
||||||
info_link->SizeToFit(0);
|
info_link->SizeToFit(0);
|
||||||
@@ -256,13 +259,6 @@ void SafetyTipPageInfoBubbleView::ButtonPressed(views::Button* button,
|
|||||||
: GURL());
|
: GURL());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SafetyTipPageInfoBubbleView::StyledLabelLinkClicked(
|
|
||||||
views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) {
|
|
||||||
OpenHelpCenter();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SafetyTipPageInfoBubbleView::OpenHelpCenter() {
|
void SafetyTipPageInfoBubbleView::OpenHelpCenter() {
|
||||||
action_taken_ = SafetyTipInteraction::kLearnMore;
|
action_taken_ = SafetyTipInteraction::kLearnMore;
|
||||||
OpenHelpCenterFromSafetyTip(web_contents());
|
OpenHelpCenterFromSafetyTip(web_contents());
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
#include "components/security_state/core/security_state.h"
|
#include "components/security_state/core/security_state.h"
|
||||||
#include "ui/views/controls/button/button.h"
|
#include "ui/views/controls/button/button.h"
|
||||||
#include "ui/views/controls/styled_label.h"
|
#include "ui/views/controls/styled_label.h"
|
||||||
#include "ui/views/controls/styled_label_listener.h"
|
|
||||||
|
|
||||||
namespace content {
|
namespace content {
|
||||||
class WebContents;
|
class WebContents;
|
||||||
@@ -29,8 +28,7 @@ class Widget;
|
|||||||
// without all of the details. Safety tip info is still displayed in the usual
|
// without all of the details. Safety tip info is still displayed in the usual
|
||||||
// PageInfoBubbleView, just less prominently.
|
// PageInfoBubbleView, just less prominently.
|
||||||
class SafetyTipPageInfoBubbleView : public PageInfoBubbleViewBase,
|
class SafetyTipPageInfoBubbleView : public PageInfoBubbleViewBase,
|
||||||
public views::ButtonListener,
|
public views::ButtonListener {
|
||||||
public views::StyledLabelListener {
|
|
||||||
public:
|
public:
|
||||||
// If |anchor_view| is nullptr, or has no Widget, |parent_window| may be
|
// If |anchor_view| is nullptr, or has no Widget, |parent_window| may be
|
||||||
// provided to ensure this bubble is closed when the parent closes.
|
// provided to ensure this bubble is closed when the parent closes.
|
||||||
@@ -54,11 +52,6 @@ class SafetyTipPageInfoBubbleView : public PageInfoBubbleViewBase,
|
|||||||
// views::ButtonListener:
|
// views::ButtonListener:
|
||||||
void ButtonPressed(views::Button* button, const ui::Event& event) override;
|
void ButtonPressed(views::Button* button, const ui::Event& event) override;
|
||||||
|
|
||||||
// views::StyledLabelListener:
|
|
||||||
void StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class SafetyTipPageInfoBubbleViewBrowserTest;
|
friend class SafetyTipPageInfoBubbleViewBrowserTest;
|
||||||
|
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "base/bind.h"
|
||||||
#include "chrome/browser/ui/passwords/passwords_model_delegate.h"
|
#include "chrome/browser/ui/passwords/passwords_model_delegate.h"
|
||||||
#include "chrome/browser/ui/views/chrome_layout_provider.h"
|
#include "chrome/browser/ui/views/chrome_layout_provider.h"
|
||||||
#include "chrome/browser/ui/views/chrome_typography.h"
|
#include "chrome/browser/ui/views/chrome_typography.h"
|
||||||
@@ -32,11 +33,14 @@ PasswordGenerationConfirmationView::PasswordGenerationConfirmationView(
|
|||||||
|
|
||||||
SetButtons(ui::DIALOG_BUTTON_NONE);
|
SetButtons(ui::DIALOG_BUTTON_NONE);
|
||||||
|
|
||||||
auto label = std::make_unique<views::StyledLabel>(this);
|
auto label = std::make_unique<views::StyledLabel>();
|
||||||
label->SetText(controller_.save_confirmation_text());
|
label->SetText(controller_.save_confirmation_text());
|
||||||
label->SetTextContext(views::style::CONTEXT_DIALOG_BODY_TEXT);
|
label->SetTextContext(views::style::CONTEXT_DIALOG_BODY_TEXT);
|
||||||
label->SetDefaultTextStyle(views::style::STYLE_SECONDARY);
|
label->SetDefaultTextStyle(views::style::STYLE_SECONDARY);
|
||||||
auto link_style = views::StyledLabel::RangeStyleInfo::CreateForLink();
|
auto link_style =
|
||||||
|
views::StyledLabel::RangeStyleInfo::CreateForLink(base::BindRepeating(
|
||||||
|
&PasswordGenerationConfirmationView::StyledLabelLinkClicked,
|
||||||
|
base::Unretained(this)));
|
||||||
link_style.disable_line_wrapping = false;
|
link_style.disable_line_wrapping = false;
|
||||||
label->AddStyleRange(controller_.save_confirmation_link_range(), link_style);
|
label->AddStyleRange(controller_.save_confirmation_link_range(), link_style);
|
||||||
|
|
||||||
@@ -60,11 +64,7 @@ bool PasswordGenerationConfirmationView::ShouldShowCloseButton() const {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PasswordGenerationConfirmationView::StyledLabelLinkClicked(
|
void PasswordGenerationConfirmationView::StyledLabelLinkClicked() {
|
||||||
views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) {
|
|
||||||
DCHECK_EQ(range, controller_.save_confirmation_link_range());
|
|
||||||
controller_.OnNavigateToPasswordManagerAccountDashboardLinkClicked(
|
controller_.OnNavigateToPasswordManagerAccountDashboardLinkClicked(
|
||||||
password_manager::ManagePasswordsReferrer::
|
password_manager::ManagePasswordsReferrer::
|
||||||
kPasswordGenerationConfirmation);
|
kPasswordGenerationConfirmation);
|
||||||
|
@@ -7,13 +7,11 @@
|
|||||||
|
|
||||||
#include "chrome/browser/ui/passwords/bubble_controllers/generation_confirmation_bubble_controller.h"
|
#include "chrome/browser/ui/passwords/bubble_controllers/generation_confirmation_bubble_controller.h"
|
||||||
#include "chrome/browser/ui/views/passwords/password_bubble_view_base.h"
|
#include "chrome/browser/ui/views/passwords/password_bubble_view_base.h"
|
||||||
#include "ui/views/controls/styled_label_listener.h"
|
|
||||||
#include "ui/views/view.h"
|
#include "ui/views/view.h"
|
||||||
|
|
||||||
// A view confirming to the user that a generated password was saved and
|
// A view confirming to the user that a generated password was saved and
|
||||||
// offering a link to the Google account manager.
|
// offering a link to the Google account manager.
|
||||||
class PasswordGenerationConfirmationView : public PasswordBubbleViewBase,
|
class PasswordGenerationConfirmationView : public PasswordBubbleViewBase {
|
||||||
public views::StyledLabelListener {
|
|
||||||
public:
|
public:
|
||||||
explicit PasswordGenerationConfirmationView(
|
explicit PasswordGenerationConfirmationView(
|
||||||
content::WebContents* web_contents,
|
content::WebContents* web_contents,
|
||||||
@@ -26,10 +24,7 @@ class PasswordGenerationConfirmationView : public PasswordBubbleViewBase,
|
|||||||
PasswordBubbleControllerBase* GetController() override;
|
PasswordBubbleControllerBase* GetController() override;
|
||||||
const PasswordBubbleControllerBase* GetController() const override;
|
const PasswordBubbleControllerBase* GetController() const override;
|
||||||
|
|
||||||
// views::StyledLabelListener:
|
void StyledLabelLinkClicked();
|
||||||
void StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) override;
|
|
||||||
|
|
||||||
// LocationBarBubbleDelegateView:
|
// LocationBarBubbleDelegateView:
|
||||||
bool ShouldShowCloseButton() const override;
|
bool ShouldShowCloseButton() const override;
|
||||||
|
@@ -32,14 +32,17 @@ PostSaveCompromisedBubbleView::PostSaveCompromisedBubbleView(
|
|||||||
SetButtonLabel(ui::DIALOG_BUTTON_OK, std::move(button));
|
SetButtonLabel(ui::DIALOG_BUTTON_OK, std::move(button));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto label = std::make_unique<views::StyledLabel>(this);
|
auto label = std::make_unique<views::StyledLabel>();
|
||||||
label->SetText(controller_.GetBody());
|
label->SetText(controller_.GetBody());
|
||||||
label->SetTextContext(views::style::CONTEXT_DIALOG_BODY_TEXT);
|
label->SetTextContext(views::style::CONTEXT_DIALOG_BODY_TEXT);
|
||||||
label->SetDefaultTextStyle(views::style::STYLE_SECONDARY);
|
label->SetDefaultTextStyle(views::style::STYLE_SECONDARY);
|
||||||
gfx::Range range = controller_.GetSettingLinkRange();
|
gfx::Range range = controller_.GetSettingLinkRange();
|
||||||
if (!range.is_empty()) {
|
if (!range.is_empty()) {
|
||||||
label->AddStyleRange(range,
|
label->AddStyleRange(
|
||||||
views::StyledLabel::RangeStyleInfo::CreateForLink());
|
range,
|
||||||
|
views::StyledLabel::RangeStyleInfo::CreateForLink(base::BindRepeating(
|
||||||
|
&PostSaveCompromisedBubbleController::OnSettingsClicked,
|
||||||
|
base::Unretained(&controller_))));
|
||||||
}
|
}
|
||||||
AddChildView(std::move(label));
|
AddChildView(std::move(label));
|
||||||
|
|
||||||
@@ -80,10 +83,3 @@ void PostSaveCompromisedBubbleView::OnThemeChanged() {
|
|||||||
*ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(image_id));
|
*ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(image_id));
|
||||||
GetBubbleFrameView()->SetHeaderView(std::move(image_view));
|
GetBubbleFrameView()->SetHeaderView(std::move(image_view));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostSaveCompromisedBubbleView::StyledLabelLinkClicked(
|
|
||||||
views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) {
|
|
||||||
controller_.OnSettingsClicked();
|
|
||||||
}
|
|
||||||
|
@@ -7,12 +7,10 @@
|
|||||||
|
|
||||||
#include "chrome/browser/ui/passwords/bubble_controllers/post_save_compromised_bubble_controller.h"
|
#include "chrome/browser/ui/passwords/bubble_controllers/post_save_compromised_bubble_controller.h"
|
||||||
#include "chrome/browser/ui/views/passwords/password_bubble_view_base.h"
|
#include "chrome/browser/ui/views/passwords/password_bubble_view_base.h"
|
||||||
#include "ui/views/controls/styled_label_listener.h"
|
|
||||||
|
|
||||||
// Bubble notifying the user about remaining compromised credentials in the
|
// Bubble notifying the user about remaining compromised credentials in the
|
||||||
// store.
|
// store.
|
||||||
class PostSaveCompromisedBubbleView : public PasswordBubbleViewBase,
|
class PostSaveCompromisedBubbleView : public PasswordBubbleViewBase {
|
||||||
public views::StyledLabelListener {
|
|
||||||
public:
|
public:
|
||||||
explicit PostSaveCompromisedBubbleView(content::WebContents* web_contents,
|
explicit PostSaveCompromisedBubbleView(content::WebContents* web_contents,
|
||||||
views::View* anchor_view);
|
views::View* anchor_view);
|
||||||
@@ -26,11 +24,6 @@ class PostSaveCompromisedBubbleView : public PasswordBubbleViewBase,
|
|||||||
bool ShouldShowCloseButton() const override;
|
bool ShouldShowCloseButton() const override;
|
||||||
void OnThemeChanged() override;
|
void OnThemeChanged() override;
|
||||||
|
|
||||||
// views::StyledLabelListener:
|
|
||||||
void StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) override;
|
|
||||||
|
|
||||||
PostSaveCompromisedBubbleController controller_;
|
PostSaveCompromisedBubbleController controller_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -258,7 +258,7 @@ CreditCardEditorViewController::CreateHeaderView() {
|
|||||||
.release());
|
.release());
|
||||||
|
|
||||||
// "Edit" link.
|
// "Edit" link.
|
||||||
auto edit_link = std::make_unique<views::StyledLabel>(this);
|
auto edit_link = std::make_unique<views::StyledLabel>();
|
||||||
base::string16 link_text =
|
base::string16 link_text =
|
||||||
l10n_util::GetStringUTF16(IDS_AUTOFILL_WALLET_MANAGEMENT_LINK_TEXT);
|
l10n_util::GetStringUTF16(IDS_AUTOFILL_WALLET_MANAGEMENT_LINK_TEXT);
|
||||||
edit_link->SetText(link_text);
|
edit_link->SetText(link_text);
|
||||||
@@ -266,7 +266,14 @@ CreditCardEditorViewController::CreateHeaderView() {
|
|||||||
static_cast<int>(DialogViewID::GOOGLE_PAYMENTS_EDIT_LINK_LABEL));
|
static_cast<int>(DialogViewID::GOOGLE_PAYMENTS_EDIT_LINK_LABEL));
|
||||||
edit_link->AddStyleRange(
|
edit_link->AddStyleRange(
|
||||||
gfx::Range(0, link_text.size()),
|
gfx::Range(0, link_text.size()),
|
||||||
views::StyledLabel::RangeStyleInfo::CreateForLink());
|
views::StyledLabel::RangeStyleInfo::CreateForLink(base::BindRepeating(
|
||||||
|
[](PaymentRequestDialogView* dialog) {
|
||||||
|
chrome::ScopedTabbedBrowserDisplayer displayer(
|
||||||
|
dialog->GetProfile());
|
||||||
|
ShowSingletonTab(displayer.browser(),
|
||||||
|
autofill::payments::GetManageAddressesUrl());
|
||||||
|
},
|
||||||
|
base::Unretained(dialog()))));
|
||||||
edit_link->SizeToFit(0);
|
edit_link->SizeToFit(0);
|
||||||
data_source->AddChildView(edit_link.release());
|
data_source->AddChildView(edit_link.release());
|
||||||
|
|
||||||
@@ -541,17 +548,6 @@ CreditCardEditorViewController::GetComboboxModelForType(
|
|||||||
return std::unique_ptr<ui::ComboboxModel>();
|
return std::unique_ptr<ui::ComboboxModel>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreditCardEditorViewController::StyledLabelLinkClicked(
|
|
||||||
views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) {
|
|
||||||
// The only thing that can trigger this is the user clicking on the "edit"
|
|
||||||
// link for a server card.
|
|
||||||
chrome::ScopedTabbedBrowserDisplayer displayer(dialog()->GetProfile());
|
|
||||||
ShowSingletonTab(displayer.browser(),
|
|
||||||
autofill::payments::GetManageAddressesUrl());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CreditCardEditorViewController::SelectBasicCardNetworkIcon(
|
void CreditCardEditorViewController::SelectBasicCardNetworkIcon(
|
||||||
const std::string& basic_card_network) {
|
const std::string& basic_card_network) {
|
||||||
// If empty string was passed or if the icon representing |basic_card_network|
|
// If empty string was passed or if the icon representing |basic_card_network|
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
#include "chrome/browser/ui/views/payments/editor_view_controller.h"
|
#include "chrome/browser/ui/views/payments/editor_view_controller.h"
|
||||||
#include "chrome/browser/ui/views/payments/validation_delegate.h"
|
#include "chrome/browser/ui/views/payments/validation_delegate.h"
|
||||||
#include "ui/base/models/simple_combobox_model.h"
|
#include "ui/base/models/simple_combobox_model.h"
|
||||||
#include "ui/views/controls/styled_label_listener.h"
|
|
||||||
|
|
||||||
namespace autofill {
|
namespace autofill {
|
||||||
class AutofillProfile;
|
class AutofillProfile;
|
||||||
@@ -30,8 +29,7 @@ class PaymentRequestState;
|
|||||||
class PaymentRequestDialogView;
|
class PaymentRequestDialogView;
|
||||||
|
|
||||||
// Credit card editor screen of the Payment Request flow.
|
// Credit card editor screen of the Payment Request flow.
|
||||||
class CreditCardEditorViewController : public EditorViewController,
|
class CreditCardEditorViewController : public EditorViewController {
|
||||||
public views::StyledLabelListener {
|
|
||||||
public:
|
public:
|
||||||
// Does not take ownership of the arguments (except for the |on_edited| and
|
// Does not take ownership of the arguments (except for the |on_edited| and
|
||||||
// |on_added| callbacks), which should outlive this object. Additionally,
|
// |on_added| callbacks), which should outlive this object. Additionally,
|
||||||
@@ -69,11 +67,6 @@ class CreditCardEditorViewController : public EditorViewController,
|
|||||||
std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType(
|
std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType(
|
||||||
const autofill::ServerFieldType& type) override;
|
const autofill::ServerFieldType& type) override;
|
||||||
|
|
||||||
// views::StyledLabelListener:
|
|
||||||
void StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) override;
|
|
||||||
|
|
||||||
// Selects the icon in the UI corresponding to |basic_card_network| with
|
// Selects the icon in the UI corresponding to |basic_card_network| with
|
||||||
// higher opacity. If empty string, selects none of them (all full opacity).
|
// higher opacity. If empty string, selects none of them (all full opacity).
|
||||||
void SelectBasicCardNetworkIcon(const std::string& basic_card_network);
|
void SelectBasicCardNetworkIcon(const std::string& basic_card_network);
|
||||||
|
@@ -356,7 +356,7 @@ IN_PROC_BROWSER_TEST_F(PaymentRequestCreditCardEditorTestWithGooglePayEnabled,
|
|||||||
EXPECT_TRUE(styled_label);
|
EXPECT_TRUE(styled_label);
|
||||||
|
|
||||||
content::WebContentsAddedObserver web_contents_added_observer;
|
content::WebContentsAddedObserver web_contents_added_observer;
|
||||||
styled_label->LinkClicked(nullptr, ui::EF_NONE);
|
styled_label->ClickLinkForTesting();
|
||||||
content::WebContents* new_tab_contents =
|
content::WebContents* new_tab_contents =
|
||||||
web_contents_added_observer.GetWebContents();
|
web_contents_added_observer.GetWebContents();
|
||||||
|
|
||||||
|
@@ -367,9 +367,8 @@ IN_PROC_BROWSER_TEST_F(PaymentRequestSettingsLinkTest, ClickSettingsLink) {
|
|||||||
static_cast<views::StyledLabel*>(dialog_view()->GetViewByID(
|
static_cast<views::StyledLabel*>(dialog_view()->GetViewByID(
|
||||||
static_cast<int>(DialogViewID::DATA_SOURCE_LABEL)));
|
static_cast<int>(DialogViewID::DATA_SOURCE_LABEL)));
|
||||||
EXPECT_TRUE(styled_label);
|
EXPECT_TRUE(styled_label);
|
||||||
// The Link is the only child of the StyledLabel.
|
|
||||||
content::WebContentsAddedObserver web_contents_added_observer;
|
content::WebContentsAddedObserver web_contents_added_observer;
|
||||||
styled_label->LinkClicked(nullptr, ui::EF_NONE);
|
styled_label->ClickLinkForTesting();
|
||||||
content::WebContents* new_tab_contents =
|
content::WebContents* new_tab_contents =
|
||||||
web_contents_added_observer.GetWebContents();
|
web_contents_added_observer.GetWebContents();
|
||||||
|
|
||||||
|
@@ -182,9 +182,9 @@ class PaymentRequestSheetController : public views::ButtonListener {
|
|||||||
void AddSecondaryButton(views::View* container);
|
void AddSecondaryButton(views::View* container);
|
||||||
|
|
||||||
// All these are not owned. Will outlive this.
|
// All these are not owned. Will outlive this.
|
||||||
PaymentRequestSpec* spec_ = nullptr;
|
PaymentRequestSpec* const spec_ = nullptr;
|
||||||
PaymentRequestState* state_ = nullptr;
|
PaymentRequestState* const state_ = nullptr;
|
||||||
PaymentRequestDialogView* dialog_ = nullptr;
|
PaymentRequestDialogView* const dialog_ = nullptr;
|
||||||
|
|
||||||
// This view is owned by its encompassing ScrollView.
|
// This view is owned by its encompassing ScrollView.
|
||||||
views::View* pane_ = nullptr;
|
views::View* pane_ = nullptr;
|
||||||
|
@@ -571,16 +571,6 @@ void PaymentSheetViewController::ButtonPressed(views::Button* sender,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaymentSheetViewController::StyledLabelLinkClicked(
|
|
||||||
views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) {
|
|
||||||
if (dialog()->IsInteractive()) {
|
|
||||||
chrome::ShowSettingsSubPageForProfile(dialog()->GetProfile(),
|
|
||||||
chrome::kPaymentsSubPage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PaymentSheetViewController::UpdatePayButtonState(bool enabled) {
|
void PaymentSheetViewController::UpdatePayButtonState(bool enabled) {
|
||||||
primary_button()->SetEnabled(enabled);
|
primary_button()->SetEnabled(enabled);
|
||||||
static_cast<views::MdTextButton*>(primary_button())
|
static_cast<views::MdTextButton*>(primary_button())
|
||||||
@@ -993,14 +983,22 @@ std::unique_ptr<views::View> PaymentSheetViewController::CreateDataSourceRow() {
|
|||||||
data_source.erase(link_end, end_tag.size());
|
data_source.erase(link_end, end_tag.size());
|
||||||
data_source.erase(link_begin, begin_tag.size());
|
data_source.erase(link_begin, begin_tag.size());
|
||||||
|
|
||||||
auto data_source_label = std::make_unique<views::StyledLabel>(this);
|
auto data_source_label = std::make_unique<views::StyledLabel>();
|
||||||
data_source_label->SetText(data_source);
|
data_source_label->SetText(data_source);
|
||||||
|
|
||||||
data_source_label->SetBorder(views::CreateEmptyBorder(22, 0, 0, 0));
|
data_source_label->SetBorder(views::CreateEmptyBorder(22, 0, 0, 0));
|
||||||
data_source_label->SetID(static_cast<int>(DialogViewID::DATA_SOURCE_LABEL));
|
data_source_label->SetID(static_cast<int>(DialogViewID::DATA_SOURCE_LABEL));
|
||||||
data_source_label->SetDefaultTextStyle(views::style::STYLE_DISABLED);
|
data_source_label->SetDefaultTextStyle(views::style::STYLE_DISABLED);
|
||||||
|
|
||||||
views::StyledLabel::RangeStyleInfo link_style =
|
views::StyledLabel::RangeStyleInfo link_style =
|
||||||
views::StyledLabel::RangeStyleInfo::CreateForLink();
|
views::StyledLabel::RangeStyleInfo::CreateForLink(base::BindRepeating(
|
||||||
|
[](PaymentRequestDialogView* dialog) {
|
||||||
|
if (dialog->IsInteractive()) {
|
||||||
|
chrome::ShowSettingsSubPageForProfile(dialog->GetProfile(),
|
||||||
|
chrome::kPaymentsSubPage);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
base::Unretained(dialog())));
|
||||||
|
|
||||||
// TODO(pbos): Investigate whether this override is necessary.
|
// TODO(pbos): Investigate whether this override is necessary.
|
||||||
link_style.override_color = gfx::kGoogleBlue700;
|
link_style.override_color = gfx::kGoogleBlue700;
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
#include "chrome/browser/ui/views/payments/payment_request_sheet_controller.h"
|
#include "chrome/browser/ui/views/payments/payment_request_sheet_controller.h"
|
||||||
#include "components/payments/content/payment_request_spec.h"
|
#include "components/payments/content/payment_request_spec.h"
|
||||||
#include "components/payments/content/payment_request_state.h"
|
#include "components/payments/content/payment_request_state.h"
|
||||||
#include "ui/views/controls/styled_label_listener.h"
|
|
||||||
|
|
||||||
namespace payments {
|
namespace payments {
|
||||||
|
|
||||||
@@ -22,8 +21,7 @@ class PaymentRequestRowView;
|
|||||||
// Payment Request dialog.
|
// Payment Request dialog.
|
||||||
class PaymentSheetViewController : public PaymentRequestSheetController,
|
class PaymentSheetViewController : public PaymentRequestSheetController,
|
||||||
public PaymentRequestSpec::Observer,
|
public PaymentRequestSpec::Observer,
|
||||||
public PaymentRequestState::Observer,
|
public PaymentRequestState::Observer {
|
||||||
public views::StyledLabelListener {
|
|
||||||
public:
|
public:
|
||||||
// Does not take ownership of the arguments, which should outlive this object.
|
// Does not take ownership of the arguments, which should outlive this object.
|
||||||
PaymentSheetViewController(PaymentRequestSpec* spec,
|
PaymentSheetViewController(PaymentRequestSpec* spec,
|
||||||
@@ -48,11 +46,6 @@ class PaymentSheetViewController : public PaymentRequestSheetController,
|
|||||||
std::unique_ptr<views::View> CreateExtraFooterView() override;
|
std::unique_ptr<views::View> CreateExtraFooterView() override;
|
||||||
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
|
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
|
||||||
|
|
||||||
// views::StyledLabelListener:
|
|
||||||
void StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) override;
|
|
||||||
|
|
||||||
void UpdatePayButtonState(bool enabled);
|
void UpdatePayButtonState(bool enabled);
|
||||||
|
|
||||||
// These functions create the various sections and rows of the payment sheet.
|
// These functions create the various sections and rows of the payment sheet.
|
||||||
|
@@ -41,7 +41,6 @@
|
|||||||
#include "ui/views/controls/link.h"
|
#include "ui/views/controls/link.h"
|
||||||
#include "ui/views/controls/scroll_view.h"
|
#include "ui/views/controls/scroll_view.h"
|
||||||
#include "ui/views/controls/separator.h"
|
#include "ui/views/controls/separator.h"
|
||||||
#include "ui/views/controls/styled_label.h"
|
|
||||||
#include "ui/views/layout/fill_layout.h"
|
#include "ui/views/layout/fill_layout.h"
|
||||||
#include "ui/views/layout/flex_layout.h"
|
#include "ui/views/layout/flex_layout.h"
|
||||||
#include "ui/views/layout/flex_layout_types.h"
|
#include "ui/views/layout/flex_layout_types.h"
|
||||||
@@ -952,19 +951,9 @@ bool ProfileMenuViewBase::HandleContextMenu(
|
|||||||
|
|
||||||
void ProfileMenuViewBase::ButtonPressed(views::Button* button,
|
void ProfileMenuViewBase::ButtonPressed(views::Button* button,
|
||||||
const ui::Event& event) {
|
const ui::Event& event) {
|
||||||
OnClick(button);
|
DCHECK(!click_actions_[button].is_null());
|
||||||
}
|
|
||||||
|
|
||||||
void ProfileMenuViewBase::StyledLabelLinkClicked(views::StyledLabel* link,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) {
|
|
||||||
OnClick(link);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProfileMenuViewBase::OnClick(views::View* clickable_view) {
|
|
||||||
DCHECK(!click_actions_[clickable_view].is_null());
|
|
||||||
signin_ui_util::RecordProfileMenuClick(browser()->profile());
|
signin_ui_util::RecordProfileMenuClick(browser()->profile());
|
||||||
click_actions_[clickable_view].Run();
|
click_actions_[button].Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileMenuViewBase::RegisterClickAction(views::View* clickable_view,
|
void ProfileMenuViewBase::RegisterClickAction(views::View* clickable_view,
|
||||||
|
@@ -20,7 +20,6 @@
|
|||||||
#include "ui/gfx/paint_vector_icon.h"
|
#include "ui/gfx/paint_vector_icon.h"
|
||||||
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
|
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
|
||||||
#include "ui/views/controls/button/button.h"
|
#include "ui/views/controls/button/button.h"
|
||||||
#include "ui/views/controls/styled_label_listener.h"
|
|
||||||
#include "ui/views/layout/box_layout.h"
|
#include "ui/views/layout/box_layout.h"
|
||||||
#include "ui/views/style/typography.h"
|
#include "ui/views/style/typography.h"
|
||||||
|
|
||||||
@@ -38,8 +37,7 @@ class ImageModel;
|
|||||||
// clicking the avatar button.
|
// clicking the avatar button.
|
||||||
class ProfileMenuViewBase : public content::WebContentsDelegate,
|
class ProfileMenuViewBase : public content::WebContentsDelegate,
|
||||||
public views::BubbleDialogDelegateView,
|
public views::BubbleDialogDelegateView,
|
||||||
public views::ButtonListener,
|
public views::ButtonListener {
|
||||||
public views::StyledLabelListener {
|
|
||||||
public:
|
public:
|
||||||
// Enumeration of all actionable items in the profile menu.
|
// Enumeration of all actionable items in the profile menu.
|
||||||
// These values are persisted to logs. Entries should not be renumbered and
|
// These values are persisted to logs. Entries should not be renumbered and
|
||||||
@@ -192,14 +190,6 @@ class ProfileMenuViewBase : public content::WebContentsDelegate,
|
|||||||
// views::ButtonListener:
|
// views::ButtonListener:
|
||||||
void ButtonPressed(views::Button* button, const ui::Event& event) final;
|
void ButtonPressed(views::Button* button, const ui::Event& event) final;
|
||||||
|
|
||||||
// views::StyledLabelListener:
|
|
||||||
void StyledLabelLinkClicked(views::StyledLabel* link,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) final;
|
|
||||||
|
|
||||||
// Handles all click events.
|
|
||||||
void OnClick(views::View* clickable_view);
|
|
||||||
|
|
||||||
void RegisterClickAction(views::View* clickable_view,
|
void RegisterClickAction(views::View* clickable_view,
|
||||||
base::RepeatingClosure action);
|
base::RepeatingClosure action);
|
||||||
|
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "base/bind.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "chrome/browser/ui/views/chrome_layout_provider.h"
|
#include "chrome/browser/ui/views/chrome_layout_provider.h"
|
||||||
@@ -43,9 +44,7 @@ PromptForScanningModalDialog::PromptForScanningModalDialog(
|
|||||||
const base::string16& filename,
|
const base::string16& filename,
|
||||||
base::OnceClosure accept_callback,
|
base::OnceClosure accept_callback,
|
||||||
base::OnceClosure open_now_callback)
|
base::OnceClosure open_now_callback)
|
||||||
: web_contents_(web_contents),
|
: filename_(filename), open_now_callback_(std::move(open_now_callback)) {
|
||||||
filename_(filename),
|
|
||||||
open_now_callback_(std::move(open_now_callback)) {
|
|
||||||
SetTitle(IDS_DEEP_SCANNING_INFO_DIALOG_TITLE);
|
SetTitle(IDS_DEEP_SCANNING_INFO_DIALOG_TITLE);
|
||||||
SetButtonLabel(
|
SetButtonLabel(
|
||||||
ui::DIALOG_BUTTON_OK,
|
ui::DIALOG_BUTTON_OK,
|
||||||
@@ -80,12 +79,21 @@ PromptForScanningModalDialog::PromptForScanningModalDialog(
|
|||||||
&offsets);
|
&offsets);
|
||||||
|
|
||||||
// Add the message label.
|
// Add the message label.
|
||||||
auto label = std::make_unique<views::StyledLabel>(this);
|
auto label = std::make_unique<views::StyledLabel>();
|
||||||
label->SetText(message_text);
|
label->SetText(message_text);
|
||||||
|
|
||||||
gfx::Range learn_more_range(offsets[1], message_text.length());
|
gfx::Range learn_more_range(offsets[1], message_text.length());
|
||||||
views::StyledLabel::RangeStyleInfo link_style =
|
views::StyledLabel::RangeStyleInfo link_style =
|
||||||
views::StyledLabel::RangeStyleInfo::CreateForLink();
|
views::StyledLabel::RangeStyleInfo::CreateForLink(base::BindRepeating(
|
||||||
|
[](content::WebContents* web_contents, int event_flags) {
|
||||||
|
web_contents->OpenURL(content::OpenURLParams(
|
||||||
|
GURL(chrome::kAdvancedProtectionDownloadLearnMoreURL),
|
||||||
|
content::Referrer(),
|
||||||
|
ui::DispositionFromEventFlags(
|
||||||
|
event_flags, WindowOpenDisposition::NEW_FOREGROUND_TAB),
|
||||||
|
ui::PAGE_TRANSITION_LINK, /*is_renderer_initiated=*/false));
|
||||||
|
},
|
||||||
|
web_contents));
|
||||||
label->AddStyleRange(learn_more_range, link_style);
|
label->AddStyleRange(learn_more_range, link_style);
|
||||||
|
|
||||||
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
|
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
|
||||||
@@ -117,16 +125,4 @@ void PromptForScanningModalDialog::ButtonPressed(views::Button* sender,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PromptForScanningModalDialog::StyledLabelLinkClicked(
|
|
||||||
views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) {
|
|
||||||
web_contents_->OpenURL(content::OpenURLParams(
|
|
||||||
GURL(chrome::kAdvancedProtectionDownloadLearnMoreURL),
|
|
||||||
content::Referrer(),
|
|
||||||
ui::DispositionFromEventFlags(event_flags,
|
|
||||||
WindowOpenDisposition::NEW_FOREGROUND_TAB),
|
|
||||||
ui::PAGE_TRANSITION_LINK, /*is_renderer_initiated=*/false));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace safe_browsing
|
} // namespace safe_browsing
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
#include "ui/base/ui_base_types.h"
|
#include "ui/base/ui_base_types.h"
|
||||||
#include "ui/views/controls/button/button.h"
|
#include "ui/views/controls/button/button.h"
|
||||||
#include "ui/views/controls/styled_label.h"
|
#include "ui/views/controls/styled_label.h"
|
||||||
#include "ui/views/controls/styled_label_listener.h"
|
|
||||||
#include "ui/views/window/dialog_delegate.h"
|
#include "ui/views/window/dialog_delegate.h"
|
||||||
|
|
||||||
namespace content {
|
namespace content {
|
||||||
@@ -23,8 +22,7 @@ namespace safe_browsing {
|
|||||||
// A tab modal dialog that provides more information to the user about the
|
// A tab modal dialog that provides more information to the user about the
|
||||||
// prompt for deep scanning.
|
// prompt for deep scanning.
|
||||||
class PromptForScanningModalDialog : public views::DialogDelegateView,
|
class PromptForScanningModalDialog : public views::DialogDelegateView,
|
||||||
public views::ButtonListener,
|
public views::ButtonListener {
|
||||||
public views::StyledLabelListener {
|
|
||||||
public:
|
public:
|
||||||
// Show this dialog for the given |web_contents|.
|
// Show this dialog for the given |web_contents|.
|
||||||
static void ShowForWebContents(content::WebContents* web_contents,
|
static void ShowForWebContents(content::WebContents* web_contents,
|
||||||
@@ -53,15 +51,7 @@ class PromptForScanningModalDialog : public views::DialogDelegateView,
|
|||||||
// views::ButtonListener implementation:
|
// views::ButtonListener implementation:
|
||||||
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
|
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
|
||||||
|
|
||||||
// views::StyledLabelListener implementation:
|
|
||||||
void StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The WebContents this dialog is attached to. This is unowned.
|
|
||||||
content::WebContents* web_contents_;
|
|
||||||
|
|
||||||
// The name of the file that this prompt was created for.
|
// The name of the file that this prompt was created for.
|
||||||
base::string16 filename_;
|
base::string16 filename_;
|
||||||
|
|
||||||
|
@@ -272,10 +272,13 @@ std::unique_ptr<views::View> SessionCrashedBubbleView::CreateUmaOptInView() {
|
|||||||
&offset);
|
&offset);
|
||||||
|
|
||||||
auto* uma_label =
|
auto* uma_label =
|
||||||
uma_view->AddChildView(std::make_unique<views::StyledLabel>(this));
|
uma_view->AddChildView(std::make_unique<views::StyledLabel>());
|
||||||
uma_label->SetText(uma_text);
|
uma_label->SetText(uma_text);
|
||||||
uma_label->AddStyleRange(gfx::Range(offset, offset + link_text.length()),
|
uma_label->AddStyleRange(
|
||||||
views::StyledLabel::RangeStyleInfo::CreateForLink());
|
gfx::Range(offset, offset + link_text.length()),
|
||||||
|
views::StyledLabel::RangeStyleInfo::CreateForLink(base::BindRepeating(
|
||||||
|
&SessionCrashedBubbleView::ExplainStatisticsLinkClicked,
|
||||||
|
base::Unretained(this))));
|
||||||
views::StyledLabel::RangeStyleInfo uma_style;
|
views::StyledLabel::RangeStyleInfo uma_style;
|
||||||
uma_style.text_style = views::style::STYLE_SECONDARY;
|
uma_style.text_style = views::style::STYLE_SECONDARY;
|
||||||
gfx::Range before_link_range(0, offset);
|
gfx::Range before_link_range(0, offset);
|
||||||
@@ -290,9 +293,7 @@ std::unique_ptr<views::View> SessionCrashedBubbleView::CreateUmaOptInView() {
|
|||||||
return uma_view;
|
return uma_view;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionCrashedBubbleView::StyledLabelLinkClicked(views::StyledLabel* label,
|
void SessionCrashedBubbleView::ExplainStatisticsLinkClicked(int event_flags) {
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) {
|
|
||||||
browser_->OpenURL(content::OpenURLParams(
|
browser_->OpenURL(content::OpenURLParams(
|
||||||
GURL("https://support.google.com/chrome/answer/96817"),
|
GURL("https://support.google.com/chrome/answer/96817"),
|
||||||
content::Referrer(),
|
content::Referrer(),
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "chrome/browser/ui/session_crashed_bubble.h"
|
#include "chrome/browser/ui/session_crashed_bubble.h"
|
||||||
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
|
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
|
||||||
#include "ui/views/controls/styled_label_listener.h"
|
|
||||||
|
|
||||||
namespace views {
|
namespace views {
|
||||||
class Checkbox;
|
class Checkbox;
|
||||||
@@ -23,8 +22,7 @@ class Browser;
|
|||||||
// previous session. If metrics reporting is not enabled a checkbox is presented
|
// previous session. If metrics reporting is not enabled a checkbox is presented
|
||||||
// allowing the user to turn it on.
|
// allowing the user to turn it on.
|
||||||
class SessionCrashedBubbleView : public SessionCrashedBubble,
|
class SessionCrashedBubbleView : public SessionCrashedBubble,
|
||||||
public views::BubbleDialogDelegateView,
|
public views::BubbleDialogDelegateView {
|
||||||
public views::StyledLabelListener {
|
|
||||||
public:
|
public:
|
||||||
// A helper class that listens to browser removal event.
|
// A helper class that listens to browser removal event.
|
||||||
class BrowserRemovalObserver;
|
class BrowserRemovalObserver;
|
||||||
@@ -54,15 +52,13 @@ class SessionCrashedBubbleView : public SessionCrashedBubble,
|
|||||||
// views::BubbleDialogDelegateView methods.
|
// views::BubbleDialogDelegateView methods.
|
||||||
void Init() override;
|
void Init() override;
|
||||||
|
|
||||||
// views::StyledLabelListener methods.
|
|
||||||
void StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) override;
|
|
||||||
|
|
||||||
// Creates a view allowing the user to opt-in to reporting information to UMA.
|
// Creates a view allowing the user to opt-in to reporting information to UMA.
|
||||||
// Returns nullptr if offer is unavailable.
|
// Returns nullptr if offer is unavailable.
|
||||||
std::unique_ptr<views::View> CreateUmaOptInView();
|
std::unique_ptr<views::View> CreateUmaOptInView();
|
||||||
|
|
||||||
|
// Called when the user clicks the "statistics" link to get more information.
|
||||||
|
void ExplainStatisticsLinkClicked(int event_flags);
|
||||||
|
|
||||||
// Restore previous session after user selects so.
|
// Restore previous session after user selects so.
|
||||||
void RestorePreviousSession();
|
void RestorePreviousSession();
|
||||||
|
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "chrome/browser/ui/views/sharing/sharing_dialog_view.h"
|
#include "chrome/browser/ui/views/sharing/sharing_dialog_view.h"
|
||||||
|
|
||||||
|
#include "base/bind.h"
|
||||||
#include "base/optional.h"
|
#include "base/optional.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
@@ -178,11 +179,8 @@ void SharingDialogView::AddedToWidget() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharingDialogView::StyledLabelLinkClicked(views::StyledLabel* label,
|
SharingDialogType SharingDialogView::GetDialogType() const {
|
||||||
const gfx::Range& range,
|
return data_.type;
|
||||||
int event_flags) {
|
|
||||||
std::move(data_.help_callback).Run(GetDialogType());
|
|
||||||
CloseBubble();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharingDialogView::ButtonPressed(views::Button* sender,
|
void SharingDialogView::ButtonPressed(views::Button* sender,
|
||||||
@@ -228,10 +226,6 @@ views::BubbleDialogDelegateView* SharingDialogView::GetAsBubbleForClickToCall(
|
|||||||
return static_cast<SharingDialogView*>(dialog);
|
return static_cast<SharingDialogView*>(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
SharingDialogType SharingDialogView::GetDialogType() const {
|
|
||||||
return data_.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SharingDialogView::Init() {
|
void SharingDialogView::Init() {
|
||||||
SetLayoutManager(std::make_unique<views::BoxLayout>(
|
SetLayoutManager(std::make_unique<views::BoxLayout>(
|
||||||
views::BoxLayout::Orientation::kVertical));
|
views::BoxLayout::Orientation::kVertical));
|
||||||
@@ -352,12 +346,18 @@ std::unique_ptr<views::StyledLabel> SharingDialogView::CreateHelpText() {
|
|||||||
const base::string16 link =
|
const base::string16 link =
|
||||||
l10n_util::GetStringUTF16(data_.help_link_text_id);
|
l10n_util::GetStringUTF16(data_.help_link_text_id);
|
||||||
size_t offset;
|
size_t offset;
|
||||||
auto label = std::make_unique<views::StyledLabel>(this);
|
auto label = std::make_unique<views::StyledLabel>();
|
||||||
label->SetText(ShouldShowOrigin(data_, web_contents())
|
label->SetText(ShouldShowOrigin(data_, web_contents())
|
||||||
? PrepareHelpTextWithOrigin(data_, link, &offset)
|
? PrepareHelpTextWithOrigin(data_, link, &offset)
|
||||||
: PrepareHelpTextWithoutOrigin(data_, link, &offset));
|
: PrepareHelpTextWithoutOrigin(data_, link, &offset));
|
||||||
views::StyledLabel::RangeStyleInfo link_style =
|
views::StyledLabel::RangeStyleInfo link_style =
|
||||||
views::StyledLabel::RangeStyleInfo::CreateForLink();
|
views::StyledLabel::RangeStyleInfo::CreateForLink(base::BindRepeating(
|
||||||
|
&SharingDialogView::HelpLinkClicked, base::Unretained(this)));
|
||||||
label->AddStyleRange(gfx::Range(offset, offset + link.length()), link_style);
|
label->AddStyleRange(gfx::Range(offset, offset + link.length()), link_style);
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SharingDialogView::HelpLinkClicked(int event_flags) {
|
||||||
|
std::move(data_.help_callback).Run(GetDialogType());
|
||||||
|
CloseBubble();
|
||||||
|
}
|
||||||
|
@@ -12,7 +12,6 @@
|
|||||||
#include "chrome/browser/sharing/sharing_dialog_data.h"
|
#include "chrome/browser/sharing/sharing_dialog_data.h"
|
||||||
#include "chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.h"
|
#include "chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.h"
|
||||||
#include "ui/views/controls/button/button.h"
|
#include "ui/views/controls/button/button.h"
|
||||||
#include "ui/views/controls/styled_label_listener.h"
|
|
||||||
|
|
||||||
namespace views {
|
namespace views {
|
||||||
class StyledLabel;
|
class StyledLabel;
|
||||||
@@ -24,7 +23,6 @@ enum class SharingDialogType;
|
|||||||
|
|
||||||
class SharingDialogView : public SharingDialog,
|
class SharingDialogView : public SharingDialog,
|
||||||
public views::ButtonListener,
|
public views::ButtonListener,
|
||||||
public views::StyledLabelListener,
|
|
||||||
public LocationBarBubbleDelegateView {
|
public LocationBarBubbleDelegateView {
|
||||||
public:
|
public:
|
||||||
// Bubble will be anchored to |anchor_view|.
|
// Bubble will be anchored to |anchor_view|.
|
||||||
@@ -45,11 +43,6 @@ class SharingDialogView : public SharingDialog,
|
|||||||
gfx::Size CalculatePreferredSize() const override;
|
gfx::Size CalculatePreferredSize() const override;
|
||||||
void AddedToWidget() override;
|
void AddedToWidget() override;
|
||||||
|
|
||||||
// views::StyledLabelListener:
|
|
||||||
void StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) override;
|
|
||||||
|
|
||||||
// views::ButtonListener:
|
// views::ButtonListener:
|
||||||
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
|
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
|
||||||
|
|
||||||
@@ -63,6 +56,8 @@ class SharingDialogView : public SharingDialog,
|
|||||||
FRIEND_TEST_ALL_PREFIXES(SharingDialogViewTest, PopulateDialogView);
|
FRIEND_TEST_ALL_PREFIXES(SharingDialogViewTest, PopulateDialogView);
|
||||||
FRIEND_TEST_ALL_PREFIXES(SharingDialogViewTest, DevicePressed);
|
FRIEND_TEST_ALL_PREFIXES(SharingDialogViewTest, DevicePressed);
|
||||||
FRIEND_TEST_ALL_PREFIXES(SharingDialogViewTest, AppPressed);
|
FRIEND_TEST_ALL_PREFIXES(SharingDialogViewTest, AppPressed);
|
||||||
|
FRIEND_TEST_ALL_PREFIXES(SharingDialogViewTest, HelpTextClickedEmpty);
|
||||||
|
FRIEND_TEST_ALL_PREFIXES(SharingDialogViewTest, HelpTextClickedOnlyApps);
|
||||||
FRIEND_TEST_ALL_PREFIXES(SharingDialogViewTest, ThemeChangedEmptyList);
|
FRIEND_TEST_ALL_PREFIXES(SharingDialogViewTest, ThemeChangedEmptyList);
|
||||||
|
|
||||||
FRIEND_TEST_ALL_PREFIXES(ClickToCallBrowserTest, LeftClick_ChooseDevice);
|
FRIEND_TEST_ALL_PREFIXES(ClickToCallBrowserTest, LeftClick_ChooseDevice);
|
||||||
@@ -79,6 +74,9 @@ class SharingDialogView : public SharingDialog,
|
|||||||
|
|
||||||
std::unique_ptr<views::StyledLabel> CreateHelpText();
|
std::unique_ptr<views::StyledLabel> CreateHelpText();
|
||||||
|
|
||||||
|
// Called when the "help" link is clicked.
|
||||||
|
void HelpLinkClicked(int event_flags);
|
||||||
|
|
||||||
SharingDialogData data_;
|
SharingDialogData data_;
|
||||||
|
|
||||||
// References to device and app buttons views.
|
// References to device and app buttons views.
|
||||||
|
@@ -181,7 +181,7 @@ TEST_F(SharingDialogViewTest, HelpTextClickedEmpty) {
|
|||||||
auto dialog_data = CreateDialogData(/*devices=*/0, /*apps=*/0);
|
auto dialog_data = CreateDialogData(/*devices=*/0, /*apps=*/0);
|
||||||
auto dialog = CreateDialogView(std::move(dialog_data));
|
auto dialog = CreateDialogView(std::move(dialog_data));
|
||||||
|
|
||||||
dialog->StyledLabelLinkClicked(nullptr, gfx::Range(), ui::EF_NONE);
|
dialog->HelpLinkClicked(ui::EF_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SharingDialogViewTest, HelpTextClickedOnlyApps) {
|
TEST_F(SharingDialogViewTest, HelpTextClickedOnlyApps) {
|
||||||
@@ -191,7 +191,7 @@ TEST_F(SharingDialogViewTest, HelpTextClickedOnlyApps) {
|
|||||||
auto dialog_data = CreateDialogData(/*devices=*/0, /*apps=*/1);
|
auto dialog_data = CreateDialogData(/*devices=*/0, /*apps=*/1);
|
||||||
auto dialog = CreateDialogView(std::move(dialog_data));
|
auto dialog = CreateDialogView(std::move(dialog_data));
|
||||||
|
|
||||||
dialog->StyledLabelLinkClicked(nullptr, gfx::Range(), ui::EF_NONE);
|
dialog->HelpLinkClicked(ui::EF_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SharingDialogViewTest, ThemeChangedEmptyList) {
|
TEST_F(SharingDialogViewTest, ThemeChangedEmptyList) {
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
#include "google_apis/gaia/gaia_auth_util.h"
|
#include "google_apis/gaia/gaia_auth_util.h"
|
||||||
#include "third_party/skia/include/core/SkColor.h"
|
#include "third_party/skia/include/core/SkColor.h"
|
||||||
#include "ui/base/l10n/l10n_util.h"
|
#include "ui/base/l10n/l10n_util.h"
|
||||||
|
#include "ui/base/window_open_disposition.h"
|
||||||
#include "ui/gfx/color_palette.h"
|
#include "ui/gfx/color_palette.h"
|
||||||
#include "ui/gfx/font.h"
|
#include "ui/gfx/font.h"
|
||||||
#include "ui/gfx/native_widget_types.h"
|
#include "ui/gfx/native_widget_types.h"
|
||||||
@@ -145,7 +146,7 @@ void ProfileSigninConfirmationDialogViews::ViewHierarchyChanged(
|
|||||||
l10n_util::GetStringFUTF16(
|
l10n_util::GetStringFUTF16(
|
||||||
IDS_ENTERPRISE_SIGNIN_ALERT,
|
IDS_ENTERPRISE_SIGNIN_ALERT,
|
||||||
domain, &offset);
|
domain, &offset);
|
||||||
auto prompt_label = std::make_unique<views::StyledLabel>(this);
|
auto prompt_label = std::make_unique<views::StyledLabel>();
|
||||||
prompt_label->SetText(prompt_text);
|
prompt_label->SetText(prompt_text);
|
||||||
prompt_label->SetDisplayedOnBackgroundColor(kPromptBarBackgroundColor);
|
prompt_label->SetDisplayedOnBackgroundColor(kPromptBarBackgroundColor);
|
||||||
|
|
||||||
@@ -171,11 +172,13 @@ void ProfileSigninConfirmationDialogViews::ViewHierarchyChanged(
|
|||||||
IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITH_PROFILE_CREATION :
|
IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITH_PROFILE_CREATION :
|
||||||
IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITHOUT_PROFILE_CREATION,
|
IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITHOUT_PROFILE_CREATION,
|
||||||
username, learn_more_text, &offsets);
|
username, learn_more_text, &offsets);
|
||||||
auto explanation_label = std::make_unique<views::StyledLabel>(this);
|
auto explanation_label = std::make_unique<views::StyledLabel>();
|
||||||
explanation_label->SetText(signin_explanation_text);
|
explanation_label->SetText(signin_explanation_text);
|
||||||
explanation_label->AddStyleRange(
|
explanation_label->AddStyleRange(
|
||||||
gfx::Range(offsets[1], offsets[1] + learn_more_text.size()),
|
gfx::Range(offsets[1], offsets[1] + learn_more_text.size()),
|
||||||
views::StyledLabel::RangeStyleInfo::CreateForLink());
|
views::StyledLabel::RangeStyleInfo::CreateForLink(base::BindRepeating(
|
||||||
|
&ProfileSigninConfirmationDialogViews::LearnMoreClicked,
|
||||||
|
base::Unretained(this))));
|
||||||
|
|
||||||
// Layout the components.
|
// Layout the components.
|
||||||
const gfx::Insets content_insets =
|
const gfx::Insets content_insets =
|
||||||
@@ -243,18 +246,6 @@ void ProfileSigninConfirmationDialogViews::ViewHierarchyChanged(
|
|||||||
kPreferredWidth, explanation_label_height);
|
kPreferredWidth, explanation_label_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileSigninConfirmationDialogViews::StyledLabelLinkClicked(
|
|
||||||
views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) {
|
|
||||||
NavigateParams params(
|
|
||||||
browser_, GURL("https://support.google.com/chromebook/answer/1331549"),
|
|
||||||
ui::PAGE_TRANSITION_LINK);
|
|
||||||
params.disposition = WindowOpenDisposition::NEW_POPUP;
|
|
||||||
params.window_action = NavigateParams::SHOW_WINDOW;
|
|
||||||
Navigate(¶ms);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProfileSigninConfirmationDialogViews::ButtonPressed(
|
void ProfileSigninConfirmationDialogViews::ButtonPressed(
|
||||||
views::Button* sender,
|
views::Button* sender,
|
||||||
const ui::Event& event) {
|
const ui::Event& event) {
|
||||||
@@ -265,3 +256,13 @@ void ProfileSigninConfirmationDialogViews::ButtonPressed(
|
|||||||
}
|
}
|
||||||
GetWidget()->Close();
|
GetWidget()->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProfileSigninConfirmationDialogViews::LearnMoreClicked(int event_flags) {
|
||||||
|
NavigateParams params(
|
||||||
|
browser_, GURL("https://support.google.com/chromebook/answer/1331549"),
|
||||||
|
ui::PAGE_TRANSITION_LINK);
|
||||||
|
params.disposition = ui::DispositionFromEventFlags(
|
||||||
|
event_flags, WindowOpenDisposition::NEW_POPUP);
|
||||||
|
params.window_action = NavigateParams::SHOW_WINDOW;
|
||||||
|
Navigate(¶ms);
|
||||||
|
}
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h"
|
#include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h"
|
||||||
#include "ui/views/controls/button/button.h"
|
#include "ui/views/controls/button/button.h"
|
||||||
#include "ui/views/controls/styled_label_listener.h"
|
|
||||||
#include "ui/views/window/dialog_delegate.h"
|
#include "ui/views/window/dialog_delegate.h"
|
||||||
|
|
||||||
class Browser;
|
class Browser;
|
||||||
@@ -20,7 +19,6 @@ class Profile;
|
|||||||
// A tab-modal dialog to allow a user signing in with a managed account
|
// A tab-modal dialog to allow a user signing in with a managed account
|
||||||
// to create a new Chrome profile.
|
// to create a new Chrome profile.
|
||||||
class ProfileSigninConfirmationDialogViews : public views::DialogDelegateView,
|
class ProfileSigninConfirmationDialogViews : public views::DialogDelegateView,
|
||||||
public views::StyledLabelListener,
|
|
||||||
public views::ButtonListener {
|
public views::ButtonListener {
|
||||||
public:
|
public:
|
||||||
// Create and show the dialog, which owns itself.
|
// Create and show the dialog, which owns itself.
|
||||||
@@ -49,14 +47,12 @@ class ProfileSigninConfirmationDialogViews : public views::DialogDelegateView,
|
|||||||
void ViewHierarchyChanged(
|
void ViewHierarchyChanged(
|
||||||
const views::ViewHierarchyChangedDetails& details) override;
|
const views::ViewHierarchyChangedDetails& details) override;
|
||||||
|
|
||||||
// views::StyledLabelListener:
|
|
||||||
void StyledLabelLinkClicked(views::StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) override;
|
|
||||||
|
|
||||||
// views::ButtonListener:
|
// views::ButtonListener:
|
||||||
void ButtonPressed(views::Button*, const ui::Event& event) override;
|
void ButtonPressed(views::Button*, const ui::Event& event) override;
|
||||||
|
|
||||||
|
// Called when the "learn more" link is clicked.
|
||||||
|
void LearnMoreClicked(int event_flags);
|
||||||
|
|
||||||
// Weak ptr to parent view.
|
// Weak ptr to parent view.
|
||||||
Browser* const browser_;
|
Browser* const browser_;
|
||||||
|
|
||||||
|
@@ -105,8 +105,7 @@ void TabModalConfirmDialogViews::CloseDialog() {
|
|||||||
GetWidget()->Close();
|
GetWidget()->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabModalConfirmDialogViews::LinkClicked(views::Link* source,
|
void TabModalConfirmDialogViews::LinkClicked(int event_flags) {
|
||||||
int event_flags) {
|
|
||||||
delegate_->LinkClicked(ui::DispositionFromEventFlags(event_flags));
|
delegate_->LinkClicked(ui::DispositionFromEventFlags(event_flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,7 +18,6 @@ class WebContents;
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace views {
|
namespace views {
|
||||||
class Link;
|
|
||||||
class MessageBoxView;
|
class MessageBoxView;
|
||||||
class Widget;
|
class Widget;
|
||||||
}
|
}
|
||||||
@@ -51,7 +50,7 @@ class TabModalConfirmDialogViews : public TabModalConfirmDialog,
|
|||||||
void CancelTabModalDialog() override;
|
void CancelTabModalDialog() override;
|
||||||
void CloseDialog() override;
|
void CloseDialog() override;
|
||||||
|
|
||||||
void LinkClicked(views::Link* source, int event_flags);
|
void LinkClicked(int event_flags);
|
||||||
|
|
||||||
views::View* GetInitiallyFocusedView() override;
|
views::View* GetInitiallyFocusedView() override;
|
||||||
|
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "chrome/browser/ui/views/toolbar/home_button.h"
|
#include "chrome/browser/ui/views/toolbar/home_button.h"
|
||||||
|
|
||||||
|
#include "base/bind.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "chrome/app/vector_icons/vector_icons.h"
|
#include "chrome/app/vector_icons/vector_icons.h"
|
||||||
@@ -21,7 +22,6 @@
|
|||||||
#include "ui/base/models/menu_model.h"
|
#include "ui/base/models/menu_model.h"
|
||||||
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
|
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
|
||||||
#include "ui/views/controls/styled_label.h"
|
#include "ui/views/controls/styled_label.h"
|
||||||
#include "ui/views/controls/styled_label_listener.h"
|
|
||||||
#include "ui/views/layout/fill_layout.h"
|
#include "ui/views/layout/fill_layout.h"
|
||||||
#include "ui/views/widget/widget.h"
|
#include "ui/views/widget/widget.h"
|
||||||
|
|
||||||
@@ -29,8 +29,7 @@
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HomePageUndoBubble : public views::BubbleDialogDelegateView,
|
class HomePageUndoBubble : public views::BubbleDialogDelegateView {
|
||||||
public views::StyledLabelListener {
|
|
||||||
public:
|
public:
|
||||||
HomePageUndoBubble(const HomePageUndoBubble&) = delete;
|
HomePageUndoBubble(const HomePageUndoBubble&) = delete;
|
||||||
HomePageUndoBubble& operator=(const HomePageUndoBubble&) = delete;
|
HomePageUndoBubble& operator=(const HomePageUndoBubble&) = delete;
|
||||||
@@ -50,10 +49,8 @@ class HomePageUndoBubble : public views::BubbleDialogDelegateView,
|
|||||||
void Init() override;
|
void Init() override;
|
||||||
void WindowClosing() override;
|
void WindowClosing() override;
|
||||||
|
|
||||||
// views::StyledLabelListener:
|
// Called when the "undo" link is clicked.
|
||||||
void StyledLabelLinkClicked(views::StyledLabel* label,
|
void UndoClicked();
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) override;
|
|
||||||
|
|
||||||
static HomePageUndoBubble* home_page_undo_bubble_;
|
static HomePageUndoBubble* home_page_undo_bubble_;
|
||||||
|
|
||||||
@@ -107,22 +104,22 @@ void HomePageUndoBubble::Init() {
|
|||||||
std::vector<base::string16> message = {
|
std::vector<base::string16> message = {
|
||||||
l10n_util::GetStringUTF16(IDS_TOOLBAR_INFORM_SET_HOME_PAGE), undo_string};
|
l10n_util::GetStringUTF16(IDS_TOOLBAR_INFORM_SET_HOME_PAGE), undo_string};
|
||||||
views::StyledLabel* label =
|
views::StyledLabel* label =
|
||||||
AddChildView(std::make_unique<views::StyledLabel>(this));
|
AddChildView(std::make_unique<views::StyledLabel>());
|
||||||
label->SetText(
|
label->SetText(
|
||||||
base::JoinString(message, base::StringPiece16(base::ASCIIToUTF16(" "))));
|
base::JoinString(message, base::StringPiece16(base::ASCIIToUTF16(" "))));
|
||||||
|
|
||||||
gfx::Range undo_range(label->GetText().length() - undo_string.length(),
|
gfx::Range undo_range(label->GetText().length() - undo_string.length(),
|
||||||
label->GetText().length());
|
label->GetText().length());
|
||||||
label->AddStyleRange(undo_range,
|
label->AddStyleRange(
|
||||||
views::StyledLabel::RangeStyleInfo::CreateForLink());
|
undo_range,
|
||||||
|
views::StyledLabel::RangeStyleInfo::CreateForLink(base::BindRepeating(
|
||||||
|
&HomePageUndoBubble::UndoClicked, base::Unretained(this))));
|
||||||
|
|
||||||
// Ensure StyledLabel has a cached size to return in GetPreferredSize().
|
// Ensure StyledLabel has a cached size to return in GetPreferredSize().
|
||||||
label->SizeToFit(0);
|
label->SizeToFit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HomePageUndoBubble::StyledLabelLinkClicked(views::StyledLabel* label,
|
void HomePageUndoBubble::UndoClicked() {
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) {
|
|
||||||
PrefService* prefs = user_prefs::UserPrefs::Get(browser_->profile());
|
PrefService* prefs = user_prefs::UserPrefs::Get(browser_->profile());
|
||||||
prefs->SetBoolean(prefs::kHomePageIsNewTabPage, undo_value_is_ntp_);
|
prefs->SetBoolean(prefs::kHomePageIsNewTabPage, undo_value_is_ntp_);
|
||||||
prefs->SetString(prefs::kHomePage, undo_url_.spec());
|
prefs->SetString(prefs::kHomePage, undo_url_.spec());
|
||||||
|
@@ -167,7 +167,6 @@ component("views") {
|
|||||||
"controls/separator.h",
|
"controls/separator.h",
|
||||||
"controls/slider.h",
|
"controls/slider.h",
|
||||||
"controls/styled_label.h",
|
"controls/styled_label.h",
|
||||||
"controls/styled_label_listener.h",
|
|
||||||
"controls/tabbed_pane/tabbed_pane.h",
|
"controls/tabbed_pane/tabbed_pane.h",
|
||||||
"controls/tabbed_pane/tabbed_pane_listener.h",
|
"controls/tabbed_pane/tabbed_pane_listener.h",
|
||||||
"controls/table/table_grouper.h",
|
"controls/table/table_grouper.h",
|
||||||
@@ -481,6 +480,7 @@ component("views") {
|
|||||||
deps = [
|
deps = [
|
||||||
"//base:i18n",
|
"//base:i18n",
|
||||||
"//base/third_party/dynamic_annotations",
|
"//base/third_party/dynamic_annotations",
|
||||||
|
"//base/util/ranges",
|
||||||
"//cc/paint",
|
"//cc/paint",
|
||||||
"//mojo/public/cpp/bindings",
|
"//mojo/public/cpp/bindings",
|
||||||
"//skia",
|
"//skia",
|
||||||
|
@@ -84,13 +84,8 @@ void Link::OnMouseReleased(const ui::MouseEvent& event) {
|
|||||||
OnMouseCaptureLost();
|
OnMouseCaptureLost();
|
||||||
if (GetEnabled() &&
|
if (GetEnabled() &&
|
||||||
(event.IsLeftMouseButton() || event.IsMiddleMouseButton()) &&
|
(event.IsLeftMouseButton() || event.IsMiddleMouseButton()) &&
|
||||||
HitTestPoint(event.location())) {
|
HitTestPoint(event.location()))
|
||||||
// Focus the link on click.
|
OnClick(event.flags());
|
||||||
RequestFocus();
|
|
||||||
|
|
||||||
if (!callback_.is_null())
|
|
||||||
callback_.Run(this, event.flags());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Link::OnMouseCaptureLost() {
|
void Link::OnMouseCaptureLost() {
|
||||||
@@ -106,13 +101,7 @@ bool Link::OnKeyPressed(const ui::KeyEvent& event) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
SetPressed(false);
|
SetPressed(false);
|
||||||
|
OnClick(event.flags());
|
||||||
// Focus the link on key pressed.
|
|
||||||
RequestFocus();
|
|
||||||
|
|
||||||
if (!callback_.is_null())
|
|
||||||
callback_.Run(this, event.flags());
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,9 +112,7 @@ void Link::OnGestureEvent(ui::GestureEvent* event) {
|
|||||||
if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
|
if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
|
||||||
SetPressed(true);
|
SetPressed(true);
|
||||||
} else if (event->type() == ui::ET_GESTURE_TAP) {
|
} else if (event->type() == ui::ET_GESTURE_TAP) {
|
||||||
RequestFocus();
|
OnClick(event->flags());
|
||||||
if (!callback_.is_null())
|
|
||||||
callback_.Run(this, event->flags());
|
|
||||||
} else {
|
} else {
|
||||||
SetPressed(false);
|
SetPressed(false);
|
||||||
return;
|
return;
|
||||||
@@ -195,6 +182,12 @@ void Link::SetPressed(bool pressed) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Link::OnClick(int event_flags) {
|
||||||
|
RequestFocus();
|
||||||
|
if (!callback_.is_null())
|
||||||
|
callback_.Run(event_flags);
|
||||||
|
}
|
||||||
|
|
||||||
void Link::RecalculateFont() {
|
void Link::RecalculateFont() {
|
||||||
const int style = font_list().GetFontStyle();
|
const int style = font_list().GetFontStyle();
|
||||||
const int intended_style = (GetEnabled() && HasFocus())
|
const int intended_style = (GetEnabled() && HasFocus())
|
||||||
|
@@ -32,8 +32,7 @@ class VIEWS_EXPORT Link : public Label {
|
|||||||
|
|
||||||
// A callback to be called when the link is clicked. Closures are also
|
// A callback to be called when the link is clicked. Closures are also
|
||||||
// accepted; see below.
|
// accepted; see below.
|
||||||
using ClickedCallback =
|
using ClickedCallback = base::RepeatingCallback<void(int event_flags)>;
|
||||||
base::RepeatingCallback<void(Link* source, int event_flags)>;
|
|
||||||
|
|
||||||
explicit Link(const base::string16& title = base::string16(),
|
explicit Link(const base::string16& title = base::string16(),
|
||||||
int text_context = style::CONTEXT_LABEL,
|
int text_context = style::CONTEXT_LABEL,
|
||||||
@@ -44,9 +43,9 @@ class VIEWS_EXPORT Link : public Label {
|
|||||||
// callers don't care about the arguments and can avoid adapter functions this
|
// callers don't care about the arguments and can avoid adapter functions this
|
||||||
// way.
|
// way.
|
||||||
void set_callback(base::RepeatingClosure callback) {
|
void set_callback(base::RepeatingClosure callback) {
|
||||||
// Adapt this closure to a ClickedCallback by discarding the extra args.
|
// Adapt this closure to a ClickedCallback by discarding the extra arg.
|
||||||
callback_ = base::BindRepeating(
|
callback_ = base::BindRepeating(
|
||||||
[](base::RepeatingClosure closure, Link*, int) { closure.Run(); },
|
[](base::RepeatingClosure closure, int) { closure.Run(); },
|
||||||
std::move(callback));
|
std::move(callback));
|
||||||
}
|
}
|
||||||
void set_callback(ClickedCallback callback) {
|
void set_callback(ClickedCallback callback) {
|
||||||
@@ -77,6 +76,8 @@ class VIEWS_EXPORT Link : public Label {
|
|||||||
private:
|
private:
|
||||||
void SetPressed(bool pressed);
|
void SetPressed(bool pressed);
|
||||||
|
|
||||||
|
void OnClick(int event_flags);
|
||||||
|
|
||||||
void RecalculateFont();
|
void RecalculateFont();
|
||||||
|
|
||||||
void ConfigureFocus();
|
void ConfigureFocus();
|
||||||
|
@@ -52,10 +52,9 @@ TEST_F(LinkTest, Metadata) {
|
|||||||
|
|
||||||
TEST_F(LinkTest, TestLinkClick) {
|
TEST_F(LinkTest, TestLinkClick) {
|
||||||
bool link_clicked = false;
|
bool link_clicked = false;
|
||||||
link()->set_callback(
|
link()->set_callback(base::BindRepeating(
|
||||||
base::BindRepeating([](bool* link_clicked, Link* link,
|
[](bool* link_clicked, int event_flags) { *link_clicked = true; },
|
||||||
int event_flags) { *link_clicked = true; },
|
&link_clicked));
|
||||||
&link_clicked));
|
|
||||||
link()->SizeToPreferredSize();
|
link()->SizeToPreferredSize();
|
||||||
gfx::Point point = link()->bounds().CenterPoint();
|
gfx::Point point = link()->bounds().CenterPoint();
|
||||||
ui::MouseEvent release(ui::ET_MOUSE_RELEASED, point, point,
|
ui::MouseEvent release(ui::ET_MOUSE_RELEASED, point, point,
|
||||||
@@ -67,10 +66,9 @@ TEST_F(LinkTest, TestLinkClick) {
|
|||||||
|
|
||||||
TEST_F(LinkTest, TestLinkTap) {
|
TEST_F(LinkTest, TestLinkTap) {
|
||||||
bool link_clicked = false;
|
bool link_clicked = false;
|
||||||
link()->set_callback(
|
link()->set_callback(base::BindRepeating(
|
||||||
base::BindRepeating([](bool* link_clicked, Link* link,
|
[](bool* link_clicked, int event_flags) { *link_clicked = true; },
|
||||||
int event_flags) { *link_clicked = true; },
|
&link_clicked));
|
||||||
&link_clicked));
|
|
||||||
link()->SizeToPreferredSize();
|
link()->SizeToPreferredSize();
|
||||||
gfx::Point point = link()->bounds().CenterPoint();
|
gfx::Point point = link()->bounds().CenterPoint();
|
||||||
ui::GestureEvent tap_event(point.x(), point.y(), 0, ui::EventTimeForNow(),
|
ui::GestureEvent tap_event(point.x(), point.y(), 0, ui::EventTimeForNow(),
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "base/i18n/rtl.h"
|
#include "base/i18n/rtl.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
|
#include "base/util/ranges/algorithm.h"
|
||||||
#include "ui/accessibility/ax_enums.mojom.h"
|
#include "ui/accessibility/ax_enums.mojom.h"
|
||||||
#include "ui/accessibility/ax_node_data.h"
|
#include "ui/accessibility/ax_node_data.h"
|
||||||
#include "ui/gfx/font_list.h"
|
#include "ui/gfx/font_list.h"
|
||||||
@@ -19,22 +20,12 @@
|
|||||||
#include "ui/gfx/text_utils.h"
|
#include "ui/gfx/text_utils.h"
|
||||||
#include "ui/native_theme/native_theme.h"
|
#include "ui/native_theme/native_theme.h"
|
||||||
#include "ui/views/controls/label.h"
|
#include "ui/views/controls/label.h"
|
||||||
#include "ui/views/controls/link.h"
|
|
||||||
#include "ui/views/controls/styled_label_listener.h"
|
|
||||||
#include "ui/views/view_class_properties.h"
|
#include "ui/views/view_class_properties.h"
|
||||||
|
|
||||||
namespace views {
|
namespace views {
|
||||||
|
|
||||||
DEFINE_UI_CLASS_PROPERTY_KEY(bool, kStyledLabelCustomViewKey, false)
|
DEFINE_UI_CLASS_PROPERTY_KEY(bool, kStyledLabelCustomViewKey, false)
|
||||||
|
|
||||||
StyledLabel::TestApi::TestApi(StyledLabel* view) : view_(view) {}
|
|
||||||
|
|
||||||
StyledLabel::TestApi::~TestApi() = default;
|
|
||||||
|
|
||||||
const StyledLabel::LinkTargets& StyledLabel::TestApi::link_targets() {
|
|
||||||
return view_->link_targets_;
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledLabel::RangeStyleInfo::RangeStyleInfo() = default;
|
StyledLabel::RangeStyleInfo::RangeStyleInfo() = default;
|
||||||
StyledLabel::RangeStyleInfo::RangeStyleInfo(const RangeStyleInfo&) = default;
|
StyledLabel::RangeStyleInfo::RangeStyleInfo(const RangeStyleInfo&) = default;
|
||||||
StyledLabel::RangeStyleInfo& StyledLabel::RangeStyleInfo::operator=(
|
StyledLabel::RangeStyleInfo& StyledLabel::RangeStyleInfo::operator=(
|
||||||
@@ -42,17 +33,24 @@ StyledLabel::RangeStyleInfo& StyledLabel::RangeStyleInfo::operator=(
|
|||||||
StyledLabel::RangeStyleInfo::~RangeStyleInfo() = default;
|
StyledLabel::RangeStyleInfo::~RangeStyleInfo() = default;
|
||||||
|
|
||||||
// static
|
// static
|
||||||
StyledLabel::RangeStyleInfo StyledLabel::RangeStyleInfo::CreateForLink() {
|
StyledLabel::RangeStyleInfo StyledLabel::RangeStyleInfo::CreateForLink(
|
||||||
|
base::RepeatingClosure callback) {
|
||||||
|
// Adapt this closure to a Link::ClickedCallback by discarding the extra arg.
|
||||||
|
return CreateForLink(base::BindRepeating(
|
||||||
|
[](base::RepeatingClosure closure, int) { closure.Run(); },
|
||||||
|
std::move(callback)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
StyledLabel::RangeStyleInfo StyledLabel::RangeStyleInfo::CreateForLink(
|
||||||
|
Link::ClickedCallback callback) {
|
||||||
RangeStyleInfo result;
|
RangeStyleInfo result;
|
||||||
|
result.callback = std::move(callback);
|
||||||
result.disable_line_wrapping = true;
|
result.disable_line_wrapping = true;
|
||||||
result.text_style = style::STYLE_LINK;
|
result.text_style = style::STYLE_LINK;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StyledLabel::RangeStyleInfo::IsLink() const {
|
|
||||||
return text_style && text_style.value() == style::STYLE_LINK;
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledLabel::LayoutSizeInfo::LayoutSizeInfo(int max_valid_width)
|
StyledLabel::LayoutSizeInfo::LayoutSizeInfo(int max_valid_width)
|
||||||
: max_valid_width(max_valid_width) {}
|
: max_valid_width(max_valid_width) {}
|
||||||
|
|
||||||
@@ -67,9 +65,6 @@ bool StyledLabel::StyleRange::operator<(
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct StyledLabel::LayoutViews {
|
struct StyledLabel::LayoutViews {
|
||||||
// The updated data for StyledLabel::link_targets_.
|
|
||||||
LinkTargets link_targets;
|
|
||||||
|
|
||||||
// All views to be added as children, line by line.
|
// All views to be added as children, line by line.
|
||||||
std::vector<std::vector<View*>> views_per_line;
|
std::vector<std::vector<View*>> views_per_line;
|
||||||
|
|
||||||
@@ -78,7 +73,7 @@ struct StyledLabel::LayoutViews {
|
|||||||
std::vector<std::unique_ptr<View>> owned_views;
|
std::vector<std::unique_ptr<View>> owned_views;
|
||||||
};
|
};
|
||||||
|
|
||||||
StyledLabel::StyledLabel(StyledLabelListener* listener) : listener_(listener) {}
|
StyledLabel::StyledLabel() = default;
|
||||||
|
|
||||||
StyledLabel::~StyledLabel() = default;
|
StyledLabel::~StyledLabel() = default;
|
||||||
|
|
||||||
@@ -206,11 +201,9 @@ void StyledLabel::SizeToFit(int fixed_width) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StyledLabel::GetAccessibleNodeData(ui::AXNodeData* node_data) {
|
void StyledLabel::GetAccessibleNodeData(ui::AXNodeData* node_data) {
|
||||||
if (text_context_ == style::CONTEXT_DIALOG_TITLE)
|
node_data->role = (text_context_ == style::CONTEXT_DIALOG_TITLE)
|
||||||
node_data->role = ax::mojom::Role::kTitleBar;
|
? ax::mojom::Role::kTitleBar
|
||||||
else
|
: ax::mojom::Role::kStaticText;
|
||||||
node_data->role = ax::mojom::Role::kStaticText;
|
|
||||||
|
|
||||||
node_data->SetName(GetText());
|
node_data->SetName(GetText());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,12 +222,6 @@ void StyledLabel::Layout() {
|
|||||||
|
|
||||||
// If the layout has been recalculated, add and position all views.
|
// If the layout has been recalculated, add and position all views.
|
||||||
if (layout_views_) {
|
if (layout_views_) {
|
||||||
for (auto& link_target : layout_views_->link_targets) {
|
|
||||||
link_target.first->set_callback(base::BindRepeating(
|
|
||||||
&StyledLabel::LinkClicked, base::Unretained(this)));
|
|
||||||
}
|
|
||||||
link_targets_ = std::move(layout_views_->link_targets);
|
|
||||||
|
|
||||||
// Delete all non-custom views on removal; custom views are temporarily
|
// Delete all non-custom views on removal; custom views are temporarily
|
||||||
// moved to |custom_views_|.
|
// moved to |custom_views_|.
|
||||||
RemoveOrDeleteAllChildViews();
|
RemoveOrDeleteAllChildViews();
|
||||||
@@ -310,11 +297,6 @@ void StyledLabel::OnThemeChanged() {
|
|||||||
UpdateLabelBackgroundColor();
|
UpdateLabelBackgroundColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyledLabel::LinkClicked(Link* source, int event_flags) {
|
|
||||||
if (listener_)
|
|
||||||
listener_->StyledLabelLinkClicked(this, link_targets_[source], event_flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(wutao): support gfx::ALIGN_TO_HEAD alignment.
|
// TODO(wutao): support gfx::ALIGN_TO_HEAD alignment.
|
||||||
void StyledLabel::SetHorizontalAlignment(gfx::HorizontalAlignment alignment) {
|
void StyledLabel::SetHorizontalAlignment(gfx::HorizontalAlignment alignment) {
|
||||||
DCHECK_NE(gfx::ALIGN_TO_HEAD, alignment);
|
DCHECK_NE(gfx::ALIGN_TO_HEAD, alignment);
|
||||||
@@ -331,6 +313,14 @@ void StyledLabel::ClearStyleRanges() {
|
|||||||
PreferredSizeChanged();
|
PreferredSizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StyledLabel::ClickLinkForTesting() {
|
||||||
|
const auto it =
|
||||||
|
util::ranges::find(children(), Link::kViewClassName, &View::GetClassName);
|
||||||
|
DCHECK(it != children().cend());
|
||||||
|
(*it)->OnKeyPressed(
|
||||||
|
ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_SPACE, ui::EF_NONE));
|
||||||
|
}
|
||||||
|
|
||||||
int StyledLabel::StartX(int excess_space) const {
|
int StyledLabel::StartX(int excess_space) const {
|
||||||
int x = GetInsets().left();
|
int x = GetInsets().left();
|
||||||
if (horizontal_alignment_ == gfx::ALIGN_LEFT)
|
if (horizontal_alignment_ == gfx::ALIGN_LEFT)
|
||||||
@@ -530,14 +520,13 @@ std::unique_ptr<Label> StyledLabel::CreateLabel(
|
|||||||
const RangeStyleInfo& style_info,
|
const RangeStyleInfo& style_info,
|
||||||
const gfx::Range& range) const {
|
const gfx::Range& range) const {
|
||||||
std::unique_ptr<Label> result;
|
std::unique_ptr<Label> result;
|
||||||
if (style_info.IsLink()) {
|
if (style_info.text_style == style::STYLE_LINK) {
|
||||||
// Nothing should (and nothing does) use a custom font for links.
|
// Nothing should (and nothing does) use a custom font for links.
|
||||||
DCHECK(!style_info.custom_font);
|
DCHECK(!style_info.custom_font);
|
||||||
|
|
||||||
// Note this ignores |default_text_style_|, in favor of style::STYLE_LINK.
|
// Note this ignores |default_text_style_|, in favor of style::STYLE_LINK.
|
||||||
auto link = std::make_unique<Link>(text, text_context_);
|
auto link = std::make_unique<Link>(text, text_context_);
|
||||||
|
link->set_callback(style_info.callback);
|
||||||
layout_views_->link_targets[link.get()] = range;
|
|
||||||
|
|
||||||
result = std::move(link);
|
result = std::move(link);
|
||||||
} else if (style_info.custom_font) {
|
} else if (style_info.custom_font) {
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "base/callback_forward.h"
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "base/optional.h"
|
#include "base/optional.h"
|
||||||
#include "base/strings/string16.h"
|
#include "base/strings/string16.h"
|
||||||
@@ -20,6 +21,7 @@
|
|||||||
#include "ui/gfx/geometry/size.h"
|
#include "ui/gfx/geometry/size.h"
|
||||||
#include "ui/gfx/range/range.h"
|
#include "ui/gfx/range/range.h"
|
||||||
#include "ui/gfx/text_constants.h"
|
#include "ui/gfx/text_constants.h"
|
||||||
|
#include "ui/views/controls/link.h"
|
||||||
#include "ui/views/style/typography.h"
|
#include "ui/views/style/typography.h"
|
||||||
#include "ui/views/view.h"
|
#include "ui/views/view.h"
|
||||||
|
|
||||||
@@ -27,7 +29,6 @@ namespace views {
|
|||||||
|
|
||||||
class Label;
|
class Label;
|
||||||
class Link;
|
class Link;
|
||||||
class StyledLabelListener;
|
|
||||||
|
|
||||||
// A class which can apply mixed styles to a block of text. Currently, text is
|
// A class which can apply mixed styles to a block of text. Currently, text is
|
||||||
// always multiline. Trailing whitespace in the styled label text is not
|
// always multiline. Trailing whitespace in the styled label text is not
|
||||||
@@ -38,22 +39,6 @@ class VIEWS_EXPORT StyledLabel : public View {
|
|||||||
public:
|
public:
|
||||||
METADATA_HEADER(StyledLabel);
|
METADATA_HEADER(StyledLabel);
|
||||||
|
|
||||||
using LinkTargets = std::map<Link*, gfx::Range>;
|
|
||||||
|
|
||||||
// TestApi is used for tests to get internal implementation details.
|
|
||||||
class VIEWS_EXPORT TestApi {
|
|
||||||
public:
|
|
||||||
explicit TestApi(StyledLabel* view);
|
|
||||||
~TestApi();
|
|
||||||
|
|
||||||
const LinkTargets& link_targets();
|
|
||||||
|
|
||||||
private:
|
|
||||||
StyledLabel* const view_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(TestApi);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Parameters that define label style for a styled label's text range.
|
// Parameters that define label style for a styled label's text range.
|
||||||
struct VIEWS_EXPORT RangeStyleInfo {
|
struct VIEWS_EXPORT RangeStyleInfo {
|
||||||
RangeStyleInfo();
|
RangeStyleInfo();
|
||||||
@@ -62,9 +47,8 @@ class VIEWS_EXPORT StyledLabel : public View {
|
|||||||
~RangeStyleInfo();
|
~RangeStyleInfo();
|
||||||
|
|
||||||
// Creates a range style info with default values for link.
|
// Creates a range style info with default values for link.
|
||||||
static RangeStyleInfo CreateForLink();
|
static RangeStyleInfo CreateForLink(Link::ClickedCallback callback);
|
||||||
|
static RangeStyleInfo CreateForLink(base::RepeatingClosure callback);
|
||||||
bool IsLink() const;
|
|
||||||
|
|
||||||
// Allows full customization of the font used in the range. Ignores the
|
// Allows full customization of the font used in the range. Ignores the
|
||||||
// StyledLabel's default text context and |text_style|.
|
// StyledLabel's default text context and |text_style|.
|
||||||
@@ -77,6 +61,10 @@ class VIEWS_EXPORT StyledLabel : public View {
|
|||||||
// DEPRECATED: Use TextStyle.
|
// DEPRECATED: Use TextStyle.
|
||||||
base::Optional<SkColor> override_color;
|
base::Optional<SkColor> override_color;
|
||||||
|
|
||||||
|
// A callback to be called when this link is clicked. Only used if
|
||||||
|
// |text_style| is style::STYLE_LINK.
|
||||||
|
Link::ClickedCallback callback;
|
||||||
|
|
||||||
// Tooltip for the range.
|
// Tooltip for the range.
|
||||||
base::string16 tooltip;
|
base::string16 tooltip;
|
||||||
|
|
||||||
@@ -110,7 +98,7 @@ class VIEWS_EXPORT StyledLabel : public View {
|
|||||||
std::vector<gfx::Size> line_sizes;
|
std::vector<gfx::Size> line_sizes;
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit StyledLabel(StyledLabelListener* listener = nullptr);
|
StyledLabel();
|
||||||
~StyledLabel() override;
|
~StyledLabel() override;
|
||||||
|
|
||||||
// Sets the text to be displayed, and clears any previous styling. Trailing
|
// Sets the text to be displayed, and clears any previous styling. Trailing
|
||||||
@@ -177,15 +165,16 @@ class VIEWS_EXPORT StyledLabel : public View {
|
|||||||
void PreferredSizeChanged() override;
|
void PreferredSizeChanged() override;
|
||||||
void OnThemeChanged() override;
|
void OnThemeChanged() override;
|
||||||
|
|
||||||
// Called when any of the child links are clicked.
|
|
||||||
void LinkClicked(Link* source, int event_flags);
|
|
||||||
|
|
||||||
// Sets the horizontal alignment; the argument value is mirrored in RTL UI.
|
// Sets the horizontal alignment; the argument value is mirrored in RTL UI.
|
||||||
void SetHorizontalAlignment(gfx::HorizontalAlignment alignment);
|
void SetHorizontalAlignment(gfx::HorizontalAlignment alignment);
|
||||||
|
|
||||||
// Clears all the styles applied to the label.
|
// Clears all the styles applied to the label.
|
||||||
void ClearStyleRanges();
|
void ClearStyleRanges();
|
||||||
|
|
||||||
|
// Sends a space keypress to the first child that is a link. Assumes at least
|
||||||
|
// one such child exists.
|
||||||
|
void ClickLinkForTesting();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct StyleRange {
|
struct StyleRange {
|
||||||
StyleRange(const gfx::Range& range, const RangeStyleInfo& style_info)
|
StyleRange(const gfx::Range& range, const RangeStyleInfo& style_info)
|
||||||
@@ -235,16 +224,9 @@ class VIEWS_EXPORT StyledLabel : public View {
|
|||||||
|
|
||||||
base::Optional<int> line_height_;
|
base::Optional<int> line_height_;
|
||||||
|
|
||||||
// The listener that will be informed of link clicks.
|
|
||||||
StyledLabelListener* listener_;
|
|
||||||
|
|
||||||
// The ranges that should be linkified, sorted by start position.
|
// The ranges that should be linkified, sorted by start position.
|
||||||
StyleRanges style_ranges_;
|
StyleRanges style_ranges_;
|
||||||
|
|
||||||
// A mapping from a view to the range it corresponds to in |text_|. Only views
|
|
||||||
// that correspond to ranges with is_link style set will be added to the map.
|
|
||||||
LinkTargets link_targets_;
|
|
||||||
|
|
||||||
// Temporarily owns the custom views until they've been been placed into the
|
// Temporarily owns the custom views until they've been been placed into the
|
||||||
// StyledLabel's child list. This list also holds the custom views during
|
// StyledLabel's child list. This list also holds the custom views during
|
||||||
// layout.
|
// layout.
|
||||||
|
@@ -1,31 +0,0 @@
|
|||||||
// Copyright 2013 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 UI_VIEWS_CONTROLS_STYLED_LABEL_LISTENER_H_
|
|
||||||
#define UI_VIEWS_CONTROLS_STYLED_LABEL_LISTENER_H_
|
|
||||||
|
|
||||||
#include "ui/views/views_export.h"
|
|
||||||
|
|
||||||
namespace gfx {
|
|
||||||
class Range;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace views {
|
|
||||||
|
|
||||||
class StyledLabel;
|
|
||||||
|
|
||||||
// A listener interface for StyledLabel.
|
|
||||||
class VIEWS_EXPORT StyledLabelListener {
|
|
||||||
public:
|
|
||||||
virtual void StyledLabelLinkClicked(StyledLabel* label,
|
|
||||||
const gfx::Range& range,
|
|
||||||
int event_flags) = 0;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual ~StyledLabelListener() = default;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace views
|
|
||||||
|
|
||||||
#endif // UI_VIEWS_CONTROLS_STYLED_LABEL_LISTENER_H_
|
|
@@ -247,14 +247,18 @@ TEST_F(StyledLabelTest, CreateLinks) {
|
|||||||
EXPECT_TRUE(styled()->GetInsets().IsEmpty());
|
EXPECT_TRUE(styled()->GetInsets().IsEmpty());
|
||||||
|
|
||||||
// Now let's add some links.
|
// Now let's add some links.
|
||||||
styled()->AddStyleRange(gfx::Range(0, 1),
|
styled()->AddStyleRange(
|
||||||
StyledLabel::RangeStyleInfo::CreateForLink());
|
gfx::Range(0, 1),
|
||||||
styled()->AddStyleRange(gfx::Range(1, 2),
|
StyledLabel::RangeStyleInfo::CreateForLink(base::RepeatingClosure()));
|
||||||
StyledLabel::RangeStyleInfo::CreateForLink());
|
styled()->AddStyleRange(
|
||||||
styled()->AddStyleRange(gfx::Range(10, 11),
|
gfx::Range(1, 2),
|
||||||
StyledLabel::RangeStyleInfo::CreateForLink());
|
StyledLabel::RangeStyleInfo::CreateForLink(base::RepeatingClosure()));
|
||||||
styled()->AddStyleRange(gfx::Range(12, 13),
|
styled()->AddStyleRange(
|
||||||
StyledLabel::RangeStyleInfo::CreateForLink());
|
gfx::Range(10, 11),
|
||||||
|
StyledLabel::RangeStyleInfo::CreateForLink(base::RepeatingClosure()));
|
||||||
|
styled()->AddStyleRange(
|
||||||
|
gfx::Range(12, 13),
|
||||||
|
StyledLabel::RangeStyleInfo::CreateForLink(base::RepeatingClosure()));
|
||||||
|
|
||||||
// Insets shouldn't change when links are added, since the links indicate
|
// Insets shouldn't change when links are added, since the links indicate
|
||||||
// focus by adding an underline instead.
|
// focus by adding an underline instead.
|
||||||
@@ -272,7 +276,7 @@ TEST_F(StyledLabelTest, DontBreakLinks) {
|
|||||||
InitStyledLabel(text + link_text);
|
InitStyledLabel(text + link_text);
|
||||||
styled()->AddStyleRange(
|
styled()->AddStyleRange(
|
||||||
gfx::Range(text.size(), text.size() + link_text.size()),
|
gfx::Range(text.size(), text.size() + link_text.size()),
|
||||||
StyledLabel::RangeStyleInfo::CreateForLink());
|
StyledLabel::RangeStyleInfo::CreateForLink(base::RepeatingClosure()));
|
||||||
|
|
||||||
Label label(ASCIIToUTF16(text + link_text.substr(0, link_text.size() / 2)));
|
Label label(ASCIIToUTF16(text + link_text.substr(0, link_text.size() / 2)));
|
||||||
gfx::Size label_preferred_size = label.GetPreferredSize();
|
gfx::Size label_preferred_size = label.GetPreferredSize();
|
||||||
@@ -403,7 +407,7 @@ TEST_F(StyledLabelInWidgetTest, Color) {
|
|||||||
styled()->AddStyleRange(gfx::Range(0u, text_blue.size()), style_info_blue);
|
styled()->AddStyleRange(gfx::Range(0u, text_blue.size()), style_info_blue);
|
||||||
|
|
||||||
StyledLabel::RangeStyleInfo style_info_link =
|
StyledLabel::RangeStyleInfo style_info_link =
|
||||||
StyledLabel::RangeStyleInfo::CreateForLink();
|
StyledLabel::RangeStyleInfo::CreateForLink(base::RepeatingClosure());
|
||||||
styled()->AddStyleRange(
|
styled()->AddStyleRange(
|
||||||
gfx::Range(text_blue.size(), text_blue.size() + text_link.size()),
|
gfx::Range(text_blue.size(), text_blue.size() + text_link.size()),
|
||||||
style_info_link);
|
style_info_link);
|
||||||
@@ -457,8 +461,9 @@ TEST_F(StyledLabelTest, StyledRangeWithTooltip) {
|
|||||||
styled()->AddStyleRange(
|
styled()->AddStyleRange(
|
||||||
gfx::Range(tooltip_start, tooltip_start + tooltip_text.size()),
|
gfx::Range(tooltip_start, tooltip_start + tooltip_text.size()),
|
||||||
tooltip_style);
|
tooltip_style);
|
||||||
styled()->AddStyleRange(gfx::Range(link_start, link_start + link_text.size()),
|
styled()->AddStyleRange(
|
||||||
StyledLabel::RangeStyleInfo::CreateForLink());
|
gfx::Range(link_start, link_start + link_text.size()),
|
||||||
|
StyledLabel::RangeStyleInfo::CreateForLink(base::RepeatingClosure()));
|
||||||
|
|
||||||
// Break line inside the range with the tooltip.
|
// Break line inside the range with the tooltip.
|
||||||
Label label(
|
Label label(
|
||||||
@@ -536,12 +541,15 @@ TEST_F(StyledLabelTest, LineHeightWithLink) {
|
|||||||
InitStyledLabel(text);
|
InitStyledLabel(text);
|
||||||
styled()->SetLineHeight(18);
|
styled()->SetLineHeight(18);
|
||||||
|
|
||||||
styled()->AddStyleRange(gfx::Range(0, 3),
|
styled()->AddStyleRange(
|
||||||
StyledLabel::RangeStyleInfo::CreateForLink());
|
gfx::Range(0, 3),
|
||||||
styled()->AddStyleRange(gfx::Range(4, 7),
|
StyledLabel::RangeStyleInfo::CreateForLink(base::RepeatingClosure()));
|
||||||
StyledLabel::RangeStyleInfo::CreateForLink());
|
styled()->AddStyleRange(
|
||||||
styled()->AddStyleRange(gfx::Range(8, 13),
|
gfx::Range(4, 7),
|
||||||
StyledLabel::RangeStyleInfo::CreateForLink());
|
StyledLabel::RangeStyleInfo::CreateForLink(base::RepeatingClosure()));
|
||||||
|
styled()->AddStyleRange(
|
||||||
|
gfx::Range(8, 13),
|
||||||
|
StyledLabel::RangeStyleInfo::CreateForLink(base::RepeatingClosure()));
|
||||||
EXPECT_EQ(18 * 3, styled()->GetHeightForWidth(100));
|
EXPECT_EQ(18 * 3, styled()->GetHeightForWidth(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -742,7 +750,7 @@ TEST_F(StyledLabelTest, ViewsCenteredWithLinkAndCustomView) {
|
|||||||
InitStyledLabel(text + link_text + custom_view_text);
|
InitStyledLabel(text + link_text + custom_view_text);
|
||||||
styled()->AddStyleRange(
|
styled()->AddStyleRange(
|
||||||
gfx::Range(text.size(), text.size() + link_text.size()),
|
gfx::Range(text.size(), text.size() + link_text.size()),
|
||||||
StyledLabel::RangeStyleInfo::CreateForLink());
|
StyledLabel::RangeStyleInfo::CreateForLink(base::RepeatingClosure()));
|
||||||
|
|
||||||
int custom_view_height = 25;
|
int custom_view_height = 25;
|
||||||
std::unique_ptr<View> custom_view =
|
std::unique_ptr<View> custom_view =
|
||||||
|
Reference in New Issue
Block a user