* handle communications from iframe (now <browser>) to chrome using location setting

* (specifically, make 'close' button in debug tab work
* remove ff-overlay.js, which we don't need anymore
* move a bit of code in the python side that was misordered (r=shanec)
* add 403 handling in theory (r=shanec, but not working for me so far)
* upgrade overlay.js to javascript 1.8 because why not?
This commit is contained in:
David Ascher 2010-09-07 21:21:26 -07:00
Родитель 206a9d5e36
Коммит 2eed297529
5 изменённых файлов: 42 добавлений и 49 удалений

Просмотреть файл

@ -1,39 +0,0 @@
ffshare.onFirefoxLoad = function(event) {
document.getElementById("contentAreaContextMenu")
.addEventListener("popupshowing", function (e){ ffshare.showFirefoxContextMenu(e); }, false);
// For now we'll just insert ourselves on every window even though this isn't nice in the long run
try {
var firefoxnav = document.getElementById("nav-bar");
var curSet = firefoxnav.currentSet;
if (curSet.indexOf("my-extension-button") == -1) {
var set;
// Place the button just after the urlbar
if (curSet.indexOf("urlbar-container") != -1) {
set = curSet.replace(/urlbar-container/, "urlbar-container,ffshare-toolbar-button");
}
else { // otherwise at the very end
set = curSet + ",my-extension-button";
}
firefoxnav.setAttribute("currentset", set);
firefoxnav.currentSet = set;
document.persist("nav-bar", "currentset");
// If you don't do the following call, funny things happen
try {
BrowserToolboxCustomizeDone(true);
}
catch (e) { }
}
}
catch(e) { }
};
ffshare.showFirefoxContextMenu = function(event) {
// show or hide the menuitem based on what the context menu is on
document.getElementById("context-ffshare").hidden = gContextMenu.onImage;
// Always hide the old send link context menu
document.getElementById("context-sendlink").hidden = true;
};
window.addEventListener("load", ffshare.onFirefoxLoad, false);

Просмотреть файл

@ -3,8 +3,7 @@
<!DOCTYPE overlay SYSTEM "chrome://ffshare/locale/overlay.dtd">
<overlay id="ffshare-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<script src="overlay.js"/>
<script src="ff-overlay.js"/>
<script type="application/javascript;version=1.8" src="overlay.js"></script>
<stringbundleset id="stringbundleset">
<stringbundle id="ffshare-strings" src="chrome://ffshare/locale/overlay.properties"/>

Просмотреть файл

@ -152,7 +152,38 @@ var ffshare;
return frecency;
},
QueryInterface: function(aIID) {
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
aIID.equals(Components.interfaces.nsIWebProgressListener2) ||
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
aIID.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_NOINTERFACE;
},
registerListener: function() {
//var tab = gBrowser.selectedTab,
// linkedBrowser = tab.linkedBrowser;
this.shareFrame.webProgress.addProgressListener(this, Components.interfaces.nsIWebProgress.NOTIFY_LOCATION);
},
unregisterListener: function(listener) {
this.shareFrame.webProgress.removeProgressListener(this);
},
onLocationChange: function(/*in nsIWebProgress*/ aWebProgress,
/*in nsIRequest*/ aRequest,
/*in nsIURI*/ aLocation) {
var hashIndex = aLocation.spec.indexOf("#");
if (hashIndex != -1) {
var tail = aLocation.spec.slice(hashIndex+1, aLocation.spec.length)
if (tail == "!close")
this.hide();
}
},
hide: function () {
this.unregisterListener();
this.changeHeight(0, fn.bind(this, function () {
this.shareFrame.parentNode.removeChild(this.shareFrame);
this.shareFrame = null;
@ -163,7 +194,7 @@ var ffshare;
//Create the iframe.
var tab = gBrowser.selectedTab,
parentNode = tab.linkedBrowser.parentNode,
iframeNode = document.createElement("iframe"),
iframeNode = document.createElement("browser"),
url, options;
//Remember iframe node for later.
@ -204,8 +235,10 @@ var ffshare;
url = this.shareUrl +
'#options=' + encodeURIComponent(JSON.stringify(options));
iframeNode.setAttribute("type", "content");
iframeNode.setAttribute("src", url);
parentNode.insertBefore(iframeNode, parentNode.firstChild);
this.registerListener();
},
changeHeight: function (height, onEnd) {

Просмотреть файл

@ -38,12 +38,6 @@ The 'send' namespace is used to send updates to our supported services.
# If we don't have a userkey in our session we bail early with a
# 401
userkey = session.get('userkey')
if not userkey:
error = {'provider': domain,
'reason': "no session for that domain",
'code': 401
}
return {'result': result, 'error': error}
try:
domain = request.POST.get('domain')
message = request.POST['message']
@ -52,6 +46,12 @@ The 'send' namespace is used to send updates to our supported services.
'reason': "'%s' request param is not optional" % (what,),
}
return {'result': result, 'error': error}
if not userkey:
error = {'provider': domain,
'reason': "no session for that domain",
'code': 401
}
return {'result': result, 'error': error}
provider = get_provider(domain)
# even if we have a session key, we must have an account for that

Просмотреть файл

@ -91,7 +91,7 @@ function (require, $, fn, rdapi, placeholder, url) {
$("#resultMsg").removeClass("hidden")
if (json['error'] && json['error']['reason']) {
$("#resultReason").text("Error: "+json['error']['reason']);
if (json['error']['code'] == 401) {
if (json['error']['code'] == 401 || json['error']['code'] == 403 ) {
reauthorize();
}
}