Repository navigation
Add 'will-prevent-unload' event for #2579. - #9331
Merged
Merged
Conversation
kevinsawicki
suggested changes
May 9, 2017
kevinsawicki
left a comment
Contributor
There was a problem hiding this comment.
This looks good, left one minor comment, also could you resolve the conflicts in this branch? Thanks.
| #include "atom/browser/ui/message_box.h" | ||
| #include "base/bind.h" | ||
| #include "base/strings/utf_string_conversions.h" | ||
| #include "ui/base/l10n/l10n_util.h" |
Contributor
There was a problem hiding this comment.
I don't think this include is needed.
Contributor
Author
|
Thanks for reviewing this. I made the requested change and resolved the conflict. Let me know if you need any other changes. |
* const-ing * mainWindow -> win * add dialog require
kevinsawicki
approved these changes
May 11, 2017
Contributor
|
Thanks so much for this 👍 🚢 |
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change is based on my comment in issue 2579. I have very little experience with the Electron code, so I hope that "help/beginner" tag still applies.
Restructure
The biggest part of this change is getting access to the event emitting methods of the
atom::api::WebContentsclass from theatom::AtomJavaScriptDialogManagerclass. That requirement led me to shuffling around a couple dependencies.I based the changes to
atom::AtomJavaScriptDialogManageron the existingatom::BluetoothChooserclass: have a constructor that accepts anapi::WebContents*object, save a reference to it, and use itsEmitmethod later.The second part of that change is in constructing the
atom::AtomJavaScriptDialogManagerobject. Right now creating and managing thatdialog_managerobject happens in theatom::CommonWebContentsDelegatebase class, which isn't ideal for this change since it doesn't have access to any of the Emit methods. So I moved that (including all references toatom::AtomJavaScriptDialogManager) into theatom::api::WebContentsclass.One thing that makes me a little nervous about that change is this comment from
common_web_contents_delegate.h:The
dialog_manager_field is in a subclass now, so it should still be destroyed beforeweb_contents_field. But this change does affect the destruction order, so if there are any other dependencies on the destruction order then it's possible that some other problem could come from this.Reloads
One additional piece of information that the
RunBeforeUnloadDialogmethod has is anis_reloadflag. The Chromium browser uses that to choose a different title for the confirmation dialog if the unload is for a reload (Do you want to reload this site?instead ofDo you want to leave this site?).Originally I planned to make that
is_reloadflag available in the newwill-prevent-unloadevent. But in my testing the flag was always false, even for a reload (using the reload menu option from the default app). So at least for now, I left theis_reloadflag out since it would be misleading to provide it if it doesn't work, and it would probably be possible to add later if there's a demand for it.