Skip to content

Commit

Permalink
fix: about panel is a base::Value::Dict
Browse files Browse the repository at this point in the history
  • Loading branch information
clavin committed Feb 21, 2023
1 parent 32c60b2 commit b66da76
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion shell/browser/browser.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ class Browser : public WindowListObserver {
base::Time last_dock_show_;
#endif

base::Value about_panel_options_;
base::Value::Dict about_panel_options_;

#if BUILDFLAG(IS_WIN)
void UpdateBadgeContents(HWND hwnd,
Expand Down
7 changes: 3 additions & 4 deletions shell/browser/browser_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,7 @@ bool CheckLoginItemStatus(bool* is_hidden) {
}

void Browser::ShowAboutPanel() {
NSDictionary* options =
DictionaryValueToNSDictionary(about_panel_options_.GetDict());
NSDictionary* options = DictionaryValueToNSDictionary(about_panel_options_);

// Credits must be a NSAttributedString instead of NSString
NSString* credits = (NSString*)options[@"Credits"];
Expand All @@ -537,13 +536,13 @@ bool CheckLoginItemStatus(bool* is_hidden) {
}

void Browser::SetAboutPanelOptions(base::Value::Dict options) {
about_panel_options_.GetDict().clear();
about_panel_options_.clear();

for (const auto pair : options) {
std::string key = pair.first;
if (!key.empty() && pair.second.is_string()) {
key[0] = base::ToUpperASCII(key[0]);
about_panel_options_.GetDict().Set(key, pair.second.Clone());
about_panel_options_.Set(key, pair.second.Clone());
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions spec/api-app-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1966,6 +1966,19 @@ describe('default behavior', () => {
}
});
});

describe('about panel', () => {
it('app.setAboutPanelOptions() does not crash', () => {
app.setAboutPanelOptions({
applicationName: 'electron!!',
version: '1.2.3'
});
});

it('app.showAboutPanel() does not crash', () => {
app.showAboutPanel();
});
});
});

async function runTestApp (name: string, ...args: any[]) {
Expand Down

0 comments on commit b66da76

Please sign in to comment.