Commit 1f39fd0a authored by Himanshu Jaju's avatar Himanshu Jaju Committed by Commit Bot

Error messages according to error scenarios.

Different error scenarios should show different error messages.
The titles are made generic to make minimal changes for future features.

Bug: 996661
Change-Id: Ieb75b8f96d9f6a95f54e0b77769034eba7ec179b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1776259Reviewed-by: default avatarAlex Chau <alexchau@chromium.org>
Reviewed-by: default avatarRichard Knoll <knollr@chromium.org>
Commit-Queue: Himanshu Jaju <himanshujaju@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692116}
parent b8a6fc1e
......@@ -115,6 +115,10 @@ SharingDialog* ClickToCallUiController::DoShowDialog(BrowserWindow* window) {
return window->ShowClickToCallDialog(web_contents(), this);
}
base::string16 ClickToCallUiController::GetContentType() const {
return l10n_util::GetStringUTF16(IDS_BROWSER_SHARING_CONTENT_TYPE_NUMBER);
}
const gfx::VectorIcon& ClickToCallUiController::GetVectorIcon() const {
return vector_icons::kCallIcon;
}
......
......@@ -41,6 +41,7 @@ class ClickToCallUiController
int GetRequiredDeviceCapabilities() override;
void OnDeviceChosen(const syncer::DeviceInfo& device) override;
void OnAppChosen(const App& app) override;
base::string16 GetContentType() const override;
const gfx::VectorIcon& GetVectorIcon() const override;
base::string16 GetTextForTooltipAndAccessibleName() const override;
......
......@@ -81,6 +81,28 @@ void SharedClipboardUiController::OnHelpTextClicked() {
// No help text
}
base::string16 SharedClipboardUiController::GetContentType() const {
return l10n_util::GetStringUTF16(IDS_BROWSER_SHARING_CONTENT_TYPE_TEXT);
}
base::string16 SharedClipboardUiController::GetErrorDialogTitle() const {
if (send_result() == SharingSendMessageResult::kPayloadTooLarge) {
return l10n_util::GetStringUTF16(
IDS_BROWSER_SHARING_SHARED_CLIPBOARD_ERROR_DIALOG_TITLE_PAYLOAD_TOO_LARGE);
}
return SharingUiController::GetErrorDialogTitle();
}
base::string16 SharedClipboardUiController::GetErrorDialogText() const {
if (send_result() == SharingSendMessageResult::kPayloadTooLarge) {
return l10n_util::GetStringUTF16(
IDS_BROWSER_SHARING_SHARED_CLIPBOARD_ERROR_DIALOG_TEXT_PAYLOAD_TOO_LARGE);
}
return SharingUiController::GetErrorDialogText();
}
const gfx::VectorIcon& SharedClipboardUiController::GetVectorIcon() const {
return kSendTabToSelfIcon;
}
......
......@@ -37,6 +37,9 @@ class SharedClipboardUiController
int GetRequiredDeviceCapabilities() override;
void OnDeviceChosen(const syncer::DeviceInfo& device) override;
void OnAppChosen(const App& app) override;
base::string16 GetContentType() const override;
base::string16 GetErrorDialogTitle() const override;
base::string16 GetErrorDialogText() const override;
const gfx::VectorIcon& GetVectorIcon() const override;
base::string16 GetTextForTooltipAndAccessibleName() const override;
......
......@@ -100,6 +100,7 @@ void SharingUiController::SendMessageToDevice(
last_dialog_id_++;
is_loading_ = true;
send_result_ = SharingSendMessageResult::kSuccessful;
target_device_name_ = device.client_name();
UpdateIcon();
sharing_service_->SendMessageToDevice(
......@@ -135,18 +136,56 @@ void SharingUiController::UpdateDevices() {
sharing_service_->GetDeviceCandidates(GetRequiredDeviceCapabilities());
}
// TODO(himanshujaju): Return different title based on |send_result_|.
base::string16 SharingUiController::GetTargetDeviceName() const {
return base::UTF8ToUTF16(target_device_name_);
}
base::string16 SharingUiController::GetErrorDialogTitle() const {
DCHECK(HasSendFailed());
return l10n_util::GetStringUTF16(
IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_TITLE_FAILED_TO_SEND);
switch (send_result()) {
case SharingSendMessageResult::kDeviceNotFound:
case SharingSendMessageResult::kNetworkError:
case SharingSendMessageResult::kAckTimeout:
return l10n_util::GetStringFUTF16(
IDS_BROWSER_SHARING_ERROR_DIALOG_TITLE_GENERIC_ERROR,
base::ToLowerASCII(GetContentType()));
case SharingSendMessageResult::kSuccessful:
NOTREACHED();
FALLTHROUGH;
case SharingSendMessageResult::kPayloadTooLarge:
case SharingSendMessageResult::kInternalError:
return l10n_util::GetStringFUTF16(
IDS_BROWSER_SHARING_ERROR_DIALOG_TITLE_INTERNAL_ERROR,
base::ToLowerASCII(GetContentType()));
}
}
// TODO(himanshujaju): Return different text based on |send_result_|.
base::string16 SharingUiController::GetErrorDialogText() const {
DCHECK(HasSendFailed());
switch (send_result()) {
case SharingSendMessageResult::kDeviceNotFound:
return l10n_util::GetStringFUTF16(
IDS_BROWSER_SHARING_ERROR_DIALOG_TEXT_DEVICE_NOT_FOUND,
GetTargetDeviceName());
case SharingSendMessageResult::kNetworkError:
return l10n_util::GetStringUTF16(
IDS_BROWSER_SHARING_ERROR_DIALOG_TEXT_NETWORK_ERROR);
case SharingSendMessageResult::kAckTimeout:
return l10n_util::GetStringFUTF16(
IDS_BROWSER_SHARING_ERROR_DIALOG_TEXT_DEVICE_ACK_TIMEOUT,
GetTargetDeviceName());
case SharingSendMessageResult::kSuccessful:
NOTREACHED();
FALLTHROUGH;
case SharingSendMessageResult::kPayloadTooLarge:
case SharingSendMessageResult::kInternalError:
return l10n_util::GetStringUTF16(
IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_FAILED_MESSAGE);
IDS_BROWSER_SHARING_ERROR_DIALOG_TEXT_INTERNAL_ERROR);
}
}
void SharingUiController::OnAppsReceived(int dialog_id, std::vector<App> apps) {
......
......@@ -12,6 +12,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/sharing/proto/sharing_message.pb.h"
#include "chrome/browser/sharing/sharing_service.h"
#include "chrome/browser/ui/page_action/page_action_icon_container.h"
......@@ -70,11 +71,16 @@ class SharingUiController {
void UpdateDevices();
// Returns the message to be shown as title in error dialog.
base::string16 GetErrorDialogTitle() const;
// Function used by GetErrorDialogTitle() and GetErrorDialogText().
virtual base::string16 GetContentType() const = 0;
// Returns the message to be shown in the body of error dialog.
base::string16 GetErrorDialogText() const;
// Returns the message to be shown as title in error dialog based on
// |send_result_|.
virtual base::string16 GetErrorDialogTitle() const;
// Returns the message to be shown in the body of error dialog based on
// |send_result_|.
virtual base::string16 GetErrorDialogText() const;
// Returns the currently open SharingDialog or nullptr if there is no
// dialog open.
......@@ -113,6 +119,8 @@ class SharingUiController {
// Shows a new SharingDialog and closes the old one.
void ShowNewDialog();
base::string16 GetTargetDeviceName() const;
// Called after a message got sent to a device. Shows a new error dialog if
// |success| is false and updates the omnibox icon.
void OnMessageSentToDevice(int dialog_id, SharingSendMessageResult result);
......@@ -125,6 +133,7 @@ class SharingUiController {
bool is_loading_ = false;
SharingSendMessageResult send_result_ = SharingSendMessageResult::kSuccessful;
std::string target_device_name_;
// Currently used apps and devices since the last call to UpdateAndShowDialog.
std::vector<App> apps_;
......
......@@ -976,24 +976,55 @@ need to be translated for each locale.-->
<message name="IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_TITLE_NO_DEVICES" desc="The label to be shown as the title of the dialog when user click on a phone number, if there are no phones or apps to choose from.">
Call this number from your phone?
</message>
<message name="IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_TITLE_FAILED_TO_SEND" desc="The label to be shown as the title of the dialog when user click on a phone number, if sending it to a device failed.">
Can't send number
</message>
<message name="IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_HELP_TEXT_NO_DEVICES" desc="The label to be shown as a help text of the dialog when user click on a phone number, if there are no phones to choose from.">
To send a number from here to your Android phone, <ph name="TROUBLESHOOT_LINK">$1<ex>turn on sync</ex></ph> for both devices in settings.
</message>
<message name="IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_TROUBLESHOOT_LINK" desc="The label to be shown on the dialog when user click on a phone number for the link to a help page to turn on sync.">
turn on sync
</message>
<message name="IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_FAILED_MESSAGE" desc="The label to be shown on the dialog when user click on a phone number, if sending it to a device failed.">
Check your phone's connection and try again
</message>
<message name="IDS_BROWSER_SHARING_OMNIBOX_SENDING_LABEL" desc="The label to be shown next to the omnibox icon when the message is being sent to the other device.">
Sending...
</message>
<message name="IDS_BROWSER_SHARING_DIALOG_DEVICE_SUBTITLE_LAST_ACTIVE_DAYS" desc="The label to be shown below the name of a valid device indicating the last active time of device,">
{DAYS, plural, =0 {Active today} =1 {Active 1 day ago} other {Active # days ago}}
</message>
<!-- Sharing content types -->
<message name="IDS_BROWSER_SHARING_CONTENT_TYPE_TEXT" desc="The label used to describe that the content type being shared is a text.">
Text
</message>
<message name="IDS_BROWSER_SHARING_CONTENT_TYPE_NUMBER" desc="The label used to describe that the content type being shared is a number.">
Number
</message>
<!-- Sharing dialog error messages -->
<message name="IDS_BROWSER_SHARING_ERROR_DIALOG_TITLE_GENERIC_ERROR" desc="The label to be shown as the title of the dialog when we encounter an error that can be fixed by the user. Eg, device not connected to internet or sync turned off.">
Can't share <ph name="CONTENT_TYPE">$1<ex>video</ex></ph>
</message>
<message name="IDS_BROWSER_SHARING_ERROR_DIALOG_TITLE_INTERNAL_ERROR" desc="The label to be shown as the title of the dialog when an internal error occurred while sending the message.">
Couldn't share <ph name="CONTENT_TYPE">$1<ex>video</ex></ph>
</message>
<message name="IDS_BROWSER_SHARING_ERROR_DIALOG_TEXT_DEVICE_NOT_FOUND" desc="The text to be shown on the dialog when an error occurred because the device is not synced.">
Make sure <ph name="TARGET_DEVICE_NAME">$1<ex>Pixel XL</ex></ph> has sync turned on in Chrome, and then try sending again.
</message>
<message name="IDS_BROWSER_SHARING_ERROR_DIALOG_TEXT_NETWORK_ERROR" desc="The text to be shown on the dialog when the sender device has network issues.">
Make sure this device is connected to the internet.
</message>
<message name="IDS_BROWSER_SHARING_ERROR_DIALOG_TEXT_DEVICE_ACK_TIMEOUT" desc="The text to be shown on the dialog when the recipient device has network issues.">
Make sure <ph name="TARGET_DEVICE_NAME">$1<ex>Pixel XL</ex></ph> is connected to the internet.
</message>
<message name="IDS_BROWSER_SHARING_ERROR_DIALOG_TEXT_INTERNAL_ERROR" desc="The text to be shown on the dialog when an internal error occurred while sending the message.">
Something went wrong. Try again later.
</message>
<!-- Shared clipboard error message. Could potentially be made generic -->
<message name="IDS_BROWSER_SHARING_SHARED_CLIPBOARD_ERROR_DIALOG_TITLE_PAYLOAD_TOO_LARGE" desc="The label to be shown as the title of the dialog when the text shared is too large.">
Text is too large
</message>
<message name="IDS_BROWSER_SHARING_SHARED_CLIPBOARD_ERROR_DIALOG_TEXT_PAYLOAD_TOO_LARGE" desc="The text to be shown on the dialog when the text shared is too large.">
Try sharing the text in smaller chunks.
</message>
</messages>
</release>
</grit>
5ea3791f2b6f05be1604b41f540cfa0a2d2555eb
\ No newline at end of file
aa70a98730d2a1b5af81ae5e696a04034ebddf40
\ No newline at end of file
8a35ef7feaed6fb5ab29fc7f80ac5982ceb48e5d
\ No newline at end of file
b85ec9f19791e8f52e047da42b335c9fcdf56621
\ No newline at end of file
445ef567c151a596c38dae0d734fa5d7f08573db
\ No newline at end of file
a90b739b9c4385cd7a6c08aa32b127d68457ea73
\ No newline at end of file
2867b5731111bf9778f89c09a85887ffec5ce18c
\ No newline at end of file
2867b5731111bf9778f89c09a85887ffec5ce18c
\ No newline at end of file
a90b739b9c4385cd7a6c08aa32b127d68457ea73
\ No newline at end of file
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