Closed
Bug 448741
Opened 18 years ago
Closed 18 years ago
nsISessionStore uses private methods and is not extensible
Categories
(Firefox :: Session Restore, enhancement)
Firefox
Session Restore
Tracking
()
RESOLVED
FIXED
Firefox 3.1a2
People
(Reporter: mikeperry.unused, Assigned: zeniko)
References
(Blocks 1 open bug)
Details
(Keywords: dev-doc-complete)
Attachments
(1 file, 1 obsolete file)
|
10.95 KB,
patch
|
dietrich
:
review+
|
Details | Diff | Splinter Review |
The @mozilla.org/browser/sessionstore;1 component is very difficult to extend because it uses non-IDL published versions of all its calls internally. This makes it impossible for an addon to easily alter its behavior by reimplementing a couple methods.
In my particular case, I need to prevent the session store from writing out tabs loaded during Tor mode in the Torbutton Firefox Extension (similar to the behavior planned in Bug 248970). Unfortunately, the component does not publish the function it uses to write the tabs to disk via its IDL. Worse, none of the published methods are used internally by the component itself, so reimplementing them by Contract ID hooking is not possible.
The end result is that Torbutton ultimately has to include a copy of the SessionStore for Firefox 2 and 3, keep it up to date, and determine the proper one to load at browser start. All of this for what amounts to about a 5 line diff to the actual code itself.
For further reference, the Torbutton bug filed by a developer encouraging me to explore alternatives (and my rationale for not being able to use any of them) is here: https://bugs.torproject.org/flyspray/index.php?do=details&id=722
| Assignee | ||
Comment 1•18 years ago
|
||
One possible solution for this issue would be allowing extensions to hook into the reading/writing of sessionstore.js through notifications. That's what this patch implements.
In case there's a better solution, I'd be glad to hear about it, though...
On a side note: The "sessionstore-state-read" notification would also replace the restore_prompt_uri pref which I'd like to drop once we use an error page instead of the prompt in bug 448976.
Attachment #332722 -
Flags: review?(gavin.sharp)
| Assignee | ||
Updated•18 years ago
|
Attachment #332722 -
Flags: review?(dietrich)
Comment 2•18 years ago
|
||
Comment on attachment 332722 [details] [diff] [review]
add sessionstore-state-(read|write) notifications
this seems like a reasonable approach for the pre-deserialization and post-serialization use-cases. the writing notification is testable via mochitest, so please add that to this patch. it will also serve as example for extension developers.
Attachment #332722 -
Flags: review?(dietrich)
| Assignee | ||
Comment 3•18 years ago
|
||
Assignee: nobody → zeniko
Attachment #332722 -
Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #334490 -
Flags: review?(dietrich)
Attachment #332722 -
Flags: review?(gavin.sharp)
Comment 4•18 years ago
|
||
Comment on attachment 334490 [details] [diff] [review]
includes a test
r=me, thanks for adding the test.
Attachment #334490 -
Flags: review?(dietrich) → review+
Updated•18 years ago
|
Keywords: checkin-needed
Hardware: PC → All
Comment 5•18 years ago
|
||
Pushed as 17138:181796ac1c8a.
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Flags: in-testsuite+
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 3.1a2
| Assignee | ||
Comment 6•18 years ago
|
||
So, there are now two new notifications:
* sessionstore-state-read is dispatched right after data is read from sessionstore.js and before it's used internally
* sessionstore-state-write is dispatched right before the data is written to disk
In both cases, extensions can modify that data by getting/setting the notification's subject's data member (the subject is an nsISupportsString). They can either work on that string directly or eval it into a JS object and in the end toSource() the object again. Setting the data member to an empty string will either prevent session restoration (in the -read case) resp. it will prevent the file sessionstore.js from being (over)written.
Keywords: dev-doc-needed
Comment 7•17 years ago
|
||
Documented now. See https://developer.mozilla.org/en/Observer_Notifications#Session_Store
Keywords: dev-doc-needed → dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•