Commit 63b694e0 authored by Yasmin's avatar Yasmin Committed by Commit Bot

Move HelpText to click to call controller.

HelpText is only available for Click to Call and not the other sharing features,
so move the logic to Click to Call.

Bug: 988461
Change-Id: I11bb24498205ed5c33da0e0bed0f3f58e726bc18
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1816559Reviewed-by: default avatarMichael van Ouwerkerk <mvanouwerkerk@chromium.org>
Commit-Queue: Yasmin Molazadeh <yasmo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#698473}
parent ab37475f
......@@ -177,4 +177,19 @@ int ClickToCallUiController::GetHeaderImageId() const {
: IDR_CLICK_TO_CALL_ILLUSTRATION_LIGHT;
}
std::unique_ptr<views::StyledLabel> ClickToCallUiController::GetHelpTextLabel(
views::StyledLabelListener* listener) {
const base::string16 link = l10n_util::GetStringUTF16(
IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_TROUBLESHOOT_LINK);
size_t offset;
const base::string16 text = l10n_util::GetStringFUTF16(
IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_HELP_TEXT_NO_DEVICES, link,
&offset);
auto label = std::make_unique<views::StyledLabel>(text, listener);
views::StyledLabel::RangeStyleInfo link_style =
views::StyledLabel::RangeStyleInfo::CreateForLink();
label->AddStyleRange(gfx::Range(offset, offset + link.length()), link_style);
return label;
}
WEB_CONTENTS_USER_DATA_KEY_IMPL(ClickToCallUiController)
......@@ -52,6 +52,8 @@ class ClickToCallUiController
base::string16 GetEducationWindowTitleText() const override;
void OnHelpTextClicked(SharingDialogType dialog_type) override;
int GetHeaderImageId() const override;
std::unique_ptr<views::StyledLabel> GetHelpTextLabel(
views::StyledLabelListener* listener) override;
protected:
explicit ClickToCallUiController(content::WebContents* web_contents);
......
......@@ -121,4 +121,11 @@ base::string16 SharedClipboardUiController::GetEducationWindowTitleText()
return base::string16();
}
// There is no Help Text for Shared Clipboard feature.
std::unique_ptr<views::StyledLabel>
SharedClipboardUiController::GetHelpTextLabel(
views::StyledLabelListener* listener) {
return nullptr;
}
WEB_CONTENTS_USER_DATA_KEY_IMPL(SharedClipboardUiController)
......@@ -44,6 +44,8 @@ class SharedClipboardUiController
base::string16 GetTextForTooltipAndAccessibleName() const override;
SharingFeatureName GetFeatureMetricsPrefix() const override;
base::string16 GetEducationWindowTitleText() const override;
std::unique_ptr<views::StyledLabel> GetHelpTextLabel(
views::StyledLabelListener* listener) override;
protected:
explicit SharedClipboardUiController(content::WebContents* web_contents);
......
......@@ -21,6 +21,8 @@
#include "components/sync/protocol/device_info_specifics.pb.h"
#include "components/sync_device_info/device_info.h"
#include "ui/gfx/image/image.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/controls/styled_label_listener.h"
class BrowserWindow;
class SharingDialog;
......@@ -74,6 +76,10 @@ class SharingUiController {
// Called by the SharingDialog when it is being closed.
virtual void OnDialogClosed(SharingDialog* dialog);
// Get the help text label for the help dialog.
virtual std::unique_ptr<views::StyledLabel> GetHelpTextLabel(
views::StyledLabelListener* listener) = 0;
// Closes the current dialog and resets all state.
void ClearLastDialog();
......
......@@ -66,23 +66,6 @@ gfx::ImageSkia CreateAppIcon(const SharingUiController::App& app) {
: app.image.AsImageSkia();
}
std::unique_ptr<views::StyledLabel> CreateHelpText(
views::StyledLabelListener* listener) {
const base::string16 link = l10n_util::GetStringUTF16(
// TODO(yasmo): rename to IDS_BROWSER_SHARING_DIALOG_TROUBLESHOOT_LINK
IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_TROUBLESHOOT_LINK);
size_t offset;
const base::string16 text = l10n_util::GetStringFUTF16(
// TODO(yasmo): rename to IDS_BROWSER_SHARING_DIALOG_HELP_TEXT_NO_DEVICES
IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_HELP_TEXT_NO_DEVICES, link,
&offset);
auto label = std::make_unique<views::StyledLabel>(text, listener);
views::StyledLabel::RangeStyleInfo link_style =
views::StyledLabel::RangeStyleInfo::CreateForLink();
label->AddStyleRange(gfx::Range(offset, offset + link.length()), link_style);
return label;
}
// TODO(himanshujaju): This is almost same as self share, we could unify these
// methods once we unify our architecture and dialog views.
base::string16 GetLastUpdatedTimeInDays(base::Time last_updated_timestamp) {
......@@ -107,6 +90,11 @@ void SharingDialogView::Hide() {
CloseBubble();
}
std::unique_ptr<views::StyledLabel> SharingDialogView::CreateHelpText(
views::StyledLabelListener* listener) {
return controller_->GetHelpTextLabel(listener);
}
int SharingDialogView::GetDialogButtons() const {
return ui::DIALOG_BUTTON_NONE;
}
......
......@@ -62,6 +62,8 @@ class SharingDialogView : public SharingDialog,
void OnThemeChanged() override;
static views::BubbleDialogDelegateView* GetAsBubble(SharingDialog* dialog);
std::unique_ptr<views::StyledLabel> CreateHelpText(
views::StyledLabelListener* listener);
private:
friend class SharingDialogViewTest;
......
......@@ -9,7 +9,6 @@
#include "chrome/browser/ui/views/page_action/page_action_icon_view.h"
#include "third_party/skia/include/core/SkColor.h"
// The location bar icon to show the sharing features bubble.
class SharingIconView : public PageActionIconView {
public:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment