-
Notifications
You must be signed in to change notification settings - Fork 15.4k
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: add navigationHistory.getEntryAtIndex(int index)
method
#41577
feat: add navigationHistory.getEntryAtIndex(int index)
method
#41577
Conversation
💖 Thanks for opening this pull request! 💖 We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix. Examples of commit messages with semantic prefixes:
Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
getNavigationEntryFromIndex(int index)
endpoint to web contents API
getNavigationEntryFromIndex(int index)
endpoint to web contents APIgetNavigationEntryFromIndex(int index)
to web contents API
FYI, the failing tests (returns a Promise with a NativeImage in the rendere) in CI are not from my tests, and pass locally on my machine. I don't have the permission to retry the failed tests. So let me know if this is a blocker! |
@alicelovescake if you rebase the tests have since been disabled! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @alicelovescake, can you add API documentation to the PR? We generally do API review via the Markdown API documentation (which also is used to generate the TypeScript types).
a5c4bec
to
30d5835
Compare
Will do! If it's ok with everyone, I'm going to include API documentation for some existing APIs that were not exposed before as well as my new one:
|
getNavigationEntryFromIndex(int index)
to web contents APIgetNavigationEntryFromIndex(int index)
method
getNavigationEntryFromIndex(int index)
methodcontents.getNavigationEntryFromIndex(int index)
method
contents.getNavigationEntryFromIndex(int index)
methodcontents.getNavigationEntryForIndex(int index)
method
2a600a1
to
28bde5f
Compare
contents.getNavigationEntryForIndex(int index)
methodcontents.getNavigationEntryAtIndex(int index)
method
I don't love the overloading of the webContents namespace, I think especially if we're documenting a few internal APIs too this might make sense to live on it's own So it would be Would make naming make more sense too, like "length" of a webContents doesn't make sense independent of more context, where as the length of a "history" thing does make sense +1 on the concept |
Great point Sam! I agree that we can better organize these endpoints, especially the ones all related to navigationHistory. What I can do is:
Let me know what you think and if you have other ideas! Appreciate the feedback! |
I'll take a look at the actual code / docs here next week (or at least try too 😅) |
contents.getNavigationEntryAtIndex(int index)
methodnavigationHistory.getEntryAtIndex(int index)
method
I was unable to backport this PR to "29-x-y" cleanly; |
@alicelovescake has manually backported this PR to "29-x-y", please check out #41661 |
@alicelovescake has manually backported this PR to "30-x-y", please check out #41662 |
These is missing in changelog (v29.3.0 and 30.x) |
Thanks for the callout! This is being updated! |
Description of Change
Problem
Currently, Electron does not expose APIs that provide a list of navigation history. As a result, developers have no way to implement features such as:
Proposed solution
In Chromium, a Navigation Controller manages session history. There are Chromium APIs that expose NavigationEntry, a data structure that captures all the information required to recreate a browsing state. In particular, NavigationEntry* GetEntryAtIndex(int index) allows us to fetch the navigation entry at a particular index.
NavigationEntry and NavigationController are both currently being used in the Electron codebase so there is no additional upkeep to expose new APIs that involve the same data structures.
Advantages of exposing a new API:
This PR:
getEntryAtIndex
to surface the title and url of a navigation entry at a particular index.navigationHistory
to store all navigation related methods (on the javascript side, see web-contents.ts)getActiveIndex
andlength
methods onnavigationHistory
..getActiveIndex()
and entire length of navigation history with.length()
These APIs exist but are not included in the documentation. This PR adds them to public docs.Checklist
npm test
passesRelease Notes
Notes: Added a new instance property
navigationHistory
on webContents API withnavigationHistory.getEntryAtIndex
method, enabling applications to retrieve the URL and title of any navigation entry within the browsing history.