Bug 516362 p2. Add a localized helper to notify the user if installation fails. r=mstange,zbraniecki

Depends on D122476

Differential Revision: https://phabricator.services.mozilla.com/D122685
This commit is contained in:
Jonathan Watt 2021-08-30 21:15:04 +00:00
Родитель ed7d14cf9a
Коммит 92c3b12a8b
2 изменённых файлов: 41 добавлений и 0 удалений

Просмотреть файл

@ -11,3 +11,8 @@ prompt-to-install-title = Finish installing { -brand-short-name }?
prompt-to-install-message = Complete this one-step installation to help keep { -brand-short-name } up to date and prevent data loss. { -brand-short-name } will be added to your Applications folder and Dock.
prompt-to-install-yes-button = Install
prompt-to-install-no-button = Dont Install
## Strings for a dialog that opens if the installation failed.
install-failed-title = { -brand-short-name } installation failed.
install-failed-message = { -brand-short-name } failed to install but will continue to run.

Просмотреть файл

@ -95,6 +95,42 @@ static bool AskUserIfWeShouldInstall() {
NS_OBJC_END_TRY_BLOCK_RETURN(false);
}
static void ShowInstallFailedDialog() {
NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
// Try to get the localized strings:
nsTArray<nsCString> resIds = {
"branding/brand.ftl"_ns,
"toolkit/global/run-from-dmg.ftl"_ns,
};
RefPtr<intl::Localization> l10n = intl::Localization::Create(resIds, true);
ErrorResult rv;
nsAutoCString mozTitle, mozMessage;
l10n->FormatValueSync("install-failed-title"_ns, {}, mozTitle, rv);
if (rv.Failed()) {
return;
}
l10n->FormatValueSync("install-failed-message"_ns, {}, mozMessage, rv);
if (rv.Failed()) {
return;
}
NSString* title = [NSString stringWithUTF8String:reinterpret_cast<const char*>(mozTitle.get())];
NSString* message =
[NSString stringWithUTF8String:reinterpret_cast<const char*>(mozMessage.get())];
NSAlert* alert = [[[NSAlert alloc] init] autorelease];
[alert setAlertStyle:NSAlertStyleWarning];
[alert setMessageText:title];
[alert setInformativeText:message];
[alert runModal];
NS_OBJC_END_TRY_IGNORE_BLOCK;
}
bool IsAppRunningFromDmg() {
NS_OBJC_BEGIN_TRY_BLOCK_RETURN;