Bug 369935 - Partial feed subscription UI is shown until the feed is loaded. r=sayrer, gavin.

This commit is contained in:
mozilla.mano%sent.com 2007-02-11 00:05:19 +00:00
parent 4424ceee06
commit 83c6dc6cd5
4 changed files with 55 additions and 35 deletions

View File

@ -20,6 +20,7 @@
*
* Contributor(s):
* Ben Goodger <beng@google.com>
* Asaf Romano <mano@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -43,9 +44,13 @@ var SubscribeHandler = {
init: function SH_init() {
this._feedWriter = new BrowserFeedWriter();
this._feedWriter.write(window);
this._feedWriter.init(window);
},
writeContent: function SH_writeContent() {
this._feedWriter.writeContent();
},
uninit: function SH_uninit() {
this._feedWriter.close();
},

View File

@ -28,7 +28,7 @@
<script type="application/x-javascript"
src="chrome://browser/content/feeds/subscribe.js"/>
</head>
<body onload="SubscribeHandler.init();" onunload="SubscribeHandler.uninit();">
<body onload="SubscribeHandler.writeContent();" onunload="SubscribeHandler.uninit();">
<div id="feedHeaderContainer">
<div id="feedHeader" dir="&locale.dir;">
<div id="feedIntroText">
@ -50,7 +50,11 @@
<p>&error.message;</p>
<p id="errorCode"/>
</div>
<script type="application/x-javascript">
SubscribeHandler.init();
</script>
<div id="feedBody">
<div id="feedTitle">
<a id="feedTitleLink">

View File

@ -20,6 +20,7 @@
*
* Contributor(s):
* Ben Goodger <beng@google.com>
* Asaf Romano <mano@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -44,16 +45,21 @@ interface nsIDOMWindow;
* is trusted so can access preferences etc, but page content isn't and so
* cannot.
*/
[scriptable, uuid(e4a39f75-93da-4264-8bf2-1a5bfb1f2f68)]
[scriptable, uuid(67003393-018c-4e96-af10-c6c51a049fad)]
interface nsIFeedWriter : nsISupports
{
/**
* Write feed UI for a particular preview DOMWindow
* @param window
* The DOMWindow of the preview page that has loaded.
* window.location.href == the URI of the feed.
* Initializes the feed writer and loads the feed subscription UI.
* @param aWindow
* The DOMWindow of the preview page.
* window.location.href == the URI of the feed.
*/
void write(in nsIDOMWindow window);
void init(in nsIDOMWindow aWindow);
/**
* Writes the feed content, assumes that the feed writer is initialized.
*/
void writeContent();
/**
* Uninitialize the feed writer.

View File

@ -753,12 +753,12 @@ FeedWriter.prototype = {
/**
* Returns the original URI object of the feed and ensures that this
* component is only ever invoked from the preview document.
* @param window
* @param aWindow
* The window of the document invoking the BrowserFeedWriter
*/
_getOriginalURI: function FW__getOriginalURI(window) {
_getOriginalURI: function FW__getOriginalURI(aWindow) {
var chan =
window.QueryInterface(Ci.nsIInterfaceRequestor).
aWindow.QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIWebNavigation).
QueryInterface(Ci.nsIDocShell).currentDocumentChannel;
@ -770,8 +770,8 @@ FeedWriter.prototype = {
if (resolvedURI.equals(chan.URI))
return chan.originalURI;
else
return null;
return null;
},
_window: null,
@ -781,40 +781,45 @@ FeedWriter.prototype = {
/**
* See nsIFeedWriter
*/
write: function FW_write(window) {
init: function FW_init(aWindow) {
// Explicitly wrap |window| in an XPCNativeWrapper to make sure
// it's a real native object! This will throw an exception if we
// get a non-native object.
window = new XPCNativeWrapper(window);
var window = new XPCNativeWrapper(aWindow);
this._feedURI = this._getOriginalURI(window);
if (!this._feedURI)
return;
this._window = window;
this._document = window.document;
LOG("Subscribe Preview: feed uri = " + this._window.location.href);
// Set up the subscription UI
this._initSubscriptionUI();
var prefs = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch2);
prefs.addObserver(PREF_SELECTED_ACTION, this, false);
prefs.addObserver(PREF_SELECTED_READER, this, false);
prefs.addObserver(PREF_SELECTED_WEB, this, false);
prefs.addObserver(PREF_SELECTED_APP, this, false);
},
/**
* See nsIFeedWriter
*/
writeContent: function FW_writeContent() {
if (!this._window)
return;
try {
this._window = window;
this._document = window.document;
LOG("Subscribe Preview: feed uri = " + this._window.location.href);
// Set up the subscription UI
this._initSubscriptionUI();
var prefs =
Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch2);
prefs.addObserver(PREF_SELECTED_ACTION, this, false);
prefs.addObserver(PREF_SELECTED_READER, this, false);
prefs.addObserver(PREF_SELECTED_WEB, this, false);
prefs.addObserver(PREF_SELECTED_APP, this, false);
// Set up the feed content
var container = this._getContainer();
if (!container)
return;
this._setTitleText(container);
this._setTitleImage(container);
this._writeFeedContent(container);
}
finally {