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

Added a new example, session-state #300

Merged
merged 3 commits into from
Oct 17, 2017
Merged

Added a new example, session-state #300

merged 3 commits into from
Oct 17, 2017

Conversation

wbamberg
Copy link

This adds an example of using sessions.setTabValue and sessions.getTabValue to store and retrieve state that the extension wants to associate with a tab. This means the extension can restore this state if the user closes and then restores the tab.

I'd like feedback on whether this is a good example of how to use the API, as well as whether the code seems to be correct. I'm not very keen on the onCreated->onUpdated stuff I do here, but it seems that onCreated is too early to call insertCSS. Of course there are alternative ways we could illustrate the concept without needing insertCSS, but they bring they own complexities too. But I'd be happy to hear suggestions for simplifying the example.

@wbamberg
Copy link
Author

@bobsilverberg , since you reviewed the code for these APIs, I wondered if you would mind reviewing this example?


## What it shows

This example demonstrates how you can use the [sessions](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/sessions) API to store and retrieve arbitrary state that you want to associate with a tab or window. Then if the tab/window is closed and subsequently restored, you can retrieve the state.

Choose a reason for hiding this comment

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

I would maybe add some notes about how to do a restore in firefox, as mentioned on IRC so its clear the difference between that and just opening example.com again :)

* Add a context menu item to borderify the current tab.
*/
browser.menus.create({
id: "borderify",

Choose a reason for hiding this comment

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

minor nit, but if someone had this and borderify installed this might be confusing

}
});
});
*/

Choose a reason for hiding this comment

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

just remove this?

@bobsilverberg
Copy link
Contributor

It looks like a decent example to me, @wbamberg. Thanks for creating it.

@wbamberg wbamberg merged commit c88c967 into master Oct 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants