Commit 2c807895 authored by Bailey Berro's avatar Bailey Berro Committed by Commit Bot

Display more informative Smb Mount error

This change adds more descriptive mount errors in order to display more
detailed reasons for a failed mount to the user.

Bug: chromium:757625
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I11d46ca74d40d77276bce6839899ac723b3b77c6
Reviewed-on: https://chromium-review.googlesource.com/1060428
Commit-Queue: Bailey Berro <baileyberro@chromium.org>
Reviewed-by: default avatarScott Chen <scottchen@chromium.org>
Reviewed-by: default avatarZentaro Kavanagh <zentaro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559395}
parent eb7e0c83
......@@ -1392,6 +1392,18 @@
<message name="IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_ERROR_MESSAGE" desc="The message shown when mounting a new SMB share fails.">
Error mounting share. Check the file share URL and try again.
</message>
<message name="IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_AUTH_FAILED_MESSAGE" desc="The message shown when mounting a new SMB share fails due to an authentication failure.">
Error mounting share. Please check your credentials and try again.
</message>
<message name="IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_NOT_FOUND_MESSAGE" desc="The message shown when mounting a new SMB share fails because the share cannot be found.">
Error mounting share. The specified share was not found on the network.
</message>
<message name="IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_UNSUPPORTED_DEVICE_MESSAGE" desc="The message shown when mounting a new SMB share fails because the specified device is not supported.">
Error mounting share. The specified share is not supported.
</message>
<message name="IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_MOUNT_EXISTS_MESSAGE" desc="The message shown when mounting a new SMB share fails because the share is already mounted.">
Error mounting share. The specified share is already mounted.
</message>
<!-- Date/Time Page -->
<message name="IDS_SETTINGS_DATE_TIME" desc="Name of the settings page which displays date and time preferences.">
......
......@@ -28,7 +28,9 @@ namespace chromeos {
namespace smb_client {
// These values are written to logs. New enum values may be added, but existing
// enums must never be runumbered or deleted and reused.
// enums must never be runumbered or deleted and reused. Must be kept in sync
// with the SmbMountResult enum in
// chrome/browser/resources/settings/downloads_page/smb_browser_proxy.js.
enum SmbMountResult {
SUCCESS = 0, // Mount succeeded
UNKNOWN_FAILURE = 1, // Mount failed in an unrecognized way
......
......@@ -7,6 +7,20 @@
* interact with the browser. Used only on Chrome OS.
*/
/**
* @enum {number}
* These values must be kept in sync with the SmbMountResult enum in
* chrome/browser/chromeos/smb_client/smb_service.h.
*/
const SmbMountResult = {
SUCCESS: 0,
UNKNOWN_FAILURE: 1,
AUTHENTICATION_FAILED: 2,
NOT_FOUND: 3,
UNSUPPORTED_DEVICE: 4,
MOUNT_EXISTS: 5,
};
cr.define('settings', function() {
/** @interface */
class SmbBrowserProxy {
......
......@@ -36,6 +36,7 @@
<cr-toast id="errorToast" duration="3000">
<div class="error-message" id="addShareDoneMessage">
[[addShareResultText_]]
</div>
</cr-toast>
</template>
......
......@@ -10,6 +10,9 @@ Polymer({
properties: {
/** @private */
showAddSmbDialog_: Boolean,
/** @private */
addShareResultText_: String,
},
/** @override */
......@@ -28,13 +31,35 @@ Polymer({
},
/**
* @param {string} error_status
* @param {SmbMountResult} result
* @private
*/
onAddShare_: function(error_status) {
this.$.addShareDoneMessage.textContent = error_status == 'success' ?
loadTimeData.getString('smbShareAddedSuccessfulMessage') :
loadTimeData.getString('smbShareAddedErrorMessage');
onAddShare_: function(result) {
switch (result) {
case SmbMountResult.SUCCESS:
this.addShareResultText_ =
loadTimeData.getString('smbShareAddedSuccessfulMessage');
break;
case SmbMountResult.AUTHENTICATION_FAILED:
this.addShareResultText_ =
loadTimeData.getString('smbShareAddedAuthFailedMessage');
break;
case SmbMountResult.NOT_FOUND:
this.addShareResultText_ =
loadTimeData.getString('smbShareAddedNotFoundMessage');
break;
case SmbMountResult.UNSUPPORTED_DEVICE:
this.addShareResultText_ =
loadTimeData.getString('smbShareAddedUnsupportedDeviceMessage');
break;
case SmbMountResult.MOUNT_EXISTS:
this.addShareResultText_ =
loadTimeData.getString('smbShareAddedMountExistsMessage');
break;
default:
this.addShareResultText_ =
loadTimeData.getString('smbShareAddedErrorMessage');
}
this.$.errorToast.show();
},
......
......@@ -49,10 +49,8 @@ void SmbHandler::HandleSmbMount(const base::ListValue* args) {
}
void SmbHandler::HandleSmbMountResponse(SmbMountResult result) {
std::string status =
result == smb_client::SmbMountResult::SUCCESS ? "success" : "failure";
AllowJavascript();
FireWebUIListener("on-add-smb-share", base::Value(status));
FireWebUIListener("on-add-smb-share", base::Value(result));
}
} // namespace settings
......
......@@ -819,6 +819,14 @@ void AddDownloadsStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_SUCCESS_MESSAGE},
{"smbShareAddedErrorMessage",
IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_ERROR_MESSAGE},
{"smbShareAddedAuthFailedMessage",
IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_AUTH_FAILED_MESSAGE},
{"smbShareAddedNotFoundMessage",
IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_NOT_FOUND_MESSAGE},
{"smbShareAddedUnsupportedDeviceMessage",
IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_UNSUPPORTED_DEVICE_MESSAGE},
{"smbShareAddedMountExistsMessage",
IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_MOUNT_EXISTS_MESSAGE},
#endif
};
AddLocalizedStringsBulk(html_source, localized_strings,
......
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