From 7de6a06acffee1568af9aa37d17c57fcc0140d87 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 10 Oct 2016 13:30:58 -0700 Subject: [PATCH] Support setting about panel options --- atom/browser/api/atom_api_app.cc | 2 ++ atom/browser/browser.h | 9 ++++++++- atom/browser/browser_mac.mm | 11 +++++++++++ atom/browser/mac/atom_application.mm | 4 ++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 0f23265fa876..1d4d67f11cdf 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -850,6 +850,8 @@ void App::BuildPrototype( base::Bind(&Browser::SetUserActivity, browser)) .SetMethod("getCurrentActivityType", base::Bind(&Browser::GetCurrentActivityType, browser)) + .SetMethod("setAboutPanelOptions", + base::Bind(&Browser::SetAboutPanelOptions, browser)) #endif #if defined(OS_WIN) .SetMethod("setUserTasks", base::Bind(&Browser::SetUserTasks, browser)) diff --git a/atom/browser/browser.h b/atom/browser/browser.h index f5e37ce6d546..69547b621904 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -14,6 +14,7 @@ #include "base/macros.h" #include "base/observer_list.h" #include "base/strings/string16.h" +#include "base/values.h" #include "native_mate/arguments.h" #if defined(OS_WIN) @@ -21,7 +22,6 @@ #endif namespace base { -class DictionaryValue; class FilePath; } @@ -146,6 +146,9 @@ class Browser : public WindowListObserver { // Set docks' icon. void DockSetIcon(const gfx::Image& image); + + void ShowAboutPanel(); + void SetAboutPanelOptions(const base::DictionaryValue& options); #endif // defined(OS_MACOSX) #if defined(OS_WIN) @@ -245,6 +248,10 @@ class Browser : public WindowListObserver { base::string16 app_user_model_id_; #endif +#if defined(OS_MACOSX) + base::DictionaryValue about_panel_options_; +#endif + DISALLOW_COPY_AND_ASSIGN(Browser); }; diff --git a/atom/browser/browser_mac.mm b/atom/browser/browser_mac.mm index 00b0f8ff21b8..3812e80cdd1f 100644 --- a/atom/browser/browser_mac.mm +++ b/atom/browser/browser_mac.mm @@ -253,4 +253,15 @@ void Browser::DockSetIcon(const gfx::Image& image) { setApplicationIconImage:image.AsNSImage()]; } +void Browser::ShowAboutPanel() { + NSDictionary* options = DictionaryValueToNSDictionary(about_panel_options_); + [[AtomApplication sharedApplication] + orderFrontStandardAboutPanelWithOptions:options]; +} + +void Browser::SetAboutPanelOptions(const base::DictionaryValue& options) { + about_panel_options_.Clear(); + about_panel_options_.MergeDictionary(&options); +} + } // namespace atom diff --git a/atom/browser/mac/atom_application.mm b/atom/browser/mac/atom_application.mm index 159852a59a83..4a0e18401664 100644 --- a/atom/browser/mac/atom_application.mm +++ b/atom/browser/mac/atom_application.mm @@ -87,4 +87,8 @@ atom::Browser::Get()->OnAccessibilitySupportChanged(); } +- (void)orderFrontStandardAboutPanel:(id)sender { + atom::Browser::Get()->ShowAboutPanel(); +} + @end