Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: About Panel credits should be dark mode aware #21924

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/api/app.md
Expand Up @@ -1186,8 +1186,9 @@ Show the app's about panel options. These options can be overridden with `app.se
* `website` String (optional) _Linux_ - The app's website.
* `iconPath` String (optional) _Linux_ - Path to the app's icon. Will be shown as 64x64 pixels while retaining aspect ratio.

Set the about panel options. This will override the values defined in the app's
`.plist` file on MacOS. See the [Apple docs][about-panel-options] for more details. On Linux, values must be set in order to be shown; there are no defaults.
Set the about panel options. This will override the values defined in the app's `.plist` file on MacOS. See the [Apple docs][about-panel-options] for more details. On Linux, values must be set in order to be shown; there are no defaults.

If you do not set `credits` but still wish to surface them in your app, AppKit will look for a file named "Credits.html", "Credits.rtf", and "Credits.rtfd", in that order, in the bundle returned by the NSBundle class method main. The first file found is used, and if none is found, the info area is left blank. See Apple [documentation](https://developer.apple.com/documentation/appkit/nsaboutpaneloptioncredits?language=objc) for more information.

### `app.isEmojiPanelSupported()`

Expand Down
15 changes: 11 additions & 4 deletions shell/browser/browser_mac.mm
Expand Up @@ -360,11 +360,18 @@ void RemoveFromLoginItems() {
NSDictionary* options = DictionaryValueToNSDictionary(about_panel_options_);

// Credits must be a NSAttributedString instead of NSString
id credits = options[@"Credits"];
NSString* credits = (NSString*)options[@"Credits"];
if (credits != nil) {
NSMutableDictionary* mutable_options = [options mutableCopy];
mutable_options[@"Credits"] = [[[NSAttributedString alloc]
initWithString:(NSString*)credits] autorelease];
base::scoped_nsobject<NSMutableDictionary> mutable_options(
[options mutableCopy]);
base::scoped_nsobject<NSAttributedString> creditString(
[[NSAttributedString alloc]
initWithString:credits
attributes:@{
NSForegroundColorAttributeName : [NSColor textColor]
}]);

[mutable_options setValue:creditString forKey:@"Credits"];
options = [NSDictionary dictionaryWithDictionary:mutable_options];
}

Expand Down