diff --git a/docs/api/dialog.md b/docs/api/dialog.md index ab2833d14251a..4a40c71ed98fc 100644 --- a/docs/api/dialog.md +++ b/docs/api/dialog.md @@ -234,6 +234,7 @@ expanding and collapsing the dialog. * `title` String (optional) - Title of the message box, some platforms will not show it. * `detail` String (optional) - Extra information of the message. * `icon` ([NativeImage](native-image.md) | String) (optional) + * `textWidth` Integer (optional) _macOS_ - Custom width of the text in the message box. * `cancelId` Integer (optional) - The index of the button to be used to cancel the dialog, via the `Esc` key. By default this is assigned to the first button with "cancel" or "no" as the label. If no such labeled buttons exist and this option is not set, `0` will be used as the @@ -285,6 +286,7 @@ If `browserWindow` is not shown dialog will not be attached to it. In such case * `checkboxChecked` Boolean (optional) - Initial checked state of the checkbox. `false` by default. * `icon` [NativeImage](native-image.md) (optional) + * `textWidth` Integer (optional) _macOS_ - Custom width of the text in the message box. * `cancelId` Integer (optional) - The index of the button to be used to cancel the dialog, via the `Esc` key. By default this is assigned to the first button with "cancel" or "no" as the label. If no such labeled buttons exist and this option is not set, `0` will be used as the diff --git a/lib/browser/api/dialog.ts b/lib/browser/api/dialog.ts index a46bf01a1d066..4dc623dff092f 100644 --- a/lib/browser/api/dialog.ts +++ b/lib/browser/api/dialog.ts @@ -168,6 +168,7 @@ const messageBox = (sync: boolean, window: BrowserWindow | null, options?: Messa defaultId = -1, detail = '', icon = null, + textWidth = 0, noLink = false, message = '', title = '', @@ -225,7 +226,8 @@ const messageBox = (sync: boolean, window: BrowserWindow | null, options?: Messa detail, checkboxLabel, checkboxChecked, - icon + icon, + textWidth }; if (sync) { diff --git a/shell/browser/ui/message_box.h b/shell/browser/ui/message_box.h index da29f96708fa1..d680208ea9aa0 100644 --- a/shell/browser/ui/message_box.h +++ b/shell/browser/ui/message_box.h @@ -38,6 +38,7 @@ struct MessageBoxSettings { std::string checkbox_label; bool checkbox_checked = false; gfx::ImageSkia icon; + int text_width = 0; MessageBoxSettings(); MessageBoxSettings(const MessageBoxSettings&); diff --git a/shell/browser/ui/message_box_mac.mm b/shell/browser/ui/message_box_mac.mm index b034aa33cc8aa..45d4a20e13058 100644 --- a/shell/browser/ui/message_box_mac.mm +++ b/shell/browser/ui/message_box_mac.mm @@ -98,6 +98,11 @@ [alert setIcon:image]; } + if (settings.text_width > 0) { + auto rect = NSMakeRect(0, 0, settings.text_width, 0); + [alert setAccessoryView:[[NSView alloc] initWithFrame:rect]]; + } + return alert; } diff --git a/shell/common/gin_converters/message_box_converter.cc b/shell/common/gin_converters/message_box_converter.cc index acf22289ca094..0cda21800de08 100644 --- a/shell/common/gin_converters/message_box_converter.cc +++ b/shell/common/gin_converters/message_box_converter.cc @@ -32,6 +32,7 @@ bool Converter::FromV8( dict.Get("noLink", &out->no_link); dict.Get("checkboxChecked", &out->checkbox_checked); dict.Get("icon", &out->icon); + dict.Get("textWidth", &out->text_width); return true; }