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

feat: promisify dialog.showCertificateTrustDialog() #17181

Merged
merged 2 commits into from Mar 15, 2019

Conversation

codebytere
Copy link
Member

@codebytere codebytere commented Mar 1, 2019

Description of Change

Promisify dialog.showCertificateTrustDialog().

Checklist

Release Notes

Notes: Converted dialog.showCertificateTrustDialog() to return a Promise instead of taking a callback.

@electron-cation electron-cation bot added new-pr 🌱 PR opened in the last 24 hours and removed new-pr 🌱 PR opened in the last 24 hours labels Mar 1, 2019
@codebytere codebytere marked this pull request as ready for review March 8, 2019 17:23
@@ -79,7 +80,8 @@ void ShowCertificateTrust(atom::NativeWindow* parent_window,
CertFreeCertificateChain(chain_context);
}

callback.Run();
promise.Resolve();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this method is synchronous / blocking on windows? Might be worth documenting / possibly making async somehow 🤔

@codebytere codebytere force-pushed the promisify-showcerttrust branch 3 times, most recently from 7fda78f to 1e042da Compare March 12, 2019 18:08
@codebytere codebytere requested a review from zcbenz March 12, 2019 18:09
@codebytere codebytere added the semver/major incompatible API changes label Mar 13, 2019
if ((self = [super init])) {
callback_ = callback;
promise_.reset(new atom::util::Promise(std::move(promise)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need keeping promise_ in a std::unique_ptr. It is only needed when the stored promise may be empty, but in this class since the promise is guaranteed to be always available, it can just be stored as normal value.

@interface TrustDelegate : NSObject {
 @private
  atom::util::Promise promise_;
}

promise_ = std::move(promise);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized there is no constructor in objective-c classes so std::unique_ptr is the only way to go. This PR should be ready to go!

@zcbenz zcbenz merged commit 961c9a8 into master Mar 15, 2019
@release-clerk
Copy link

release-clerk bot commented Mar 15, 2019

Release Notes Persisted

Converted dialog.showCertificateTrustDialog() to return a Promise instead of taking a callback.

@zcbenz zcbenz deleted the promisify-showcerttrust branch March 15, 2019 00:02
kiku-jw pushed a commit to kiku-jw/electron that referenced this pull request May 16, 2019
* feat: promisify dialog.showCertificateTrustDialog()

* update promisification doc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/major incompatible API changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants