This repository has been archived by the owner on Oct 2, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #347 from airbornos/develop
Fix for Firefox Marketplace
- Loading branch information
Showing
6 changed files
with
144 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Launch OAuth Receiver with internal app flag | ||
Dropbox.AuthDriver.FFOSPopup.oauthReceiver(true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> | ||
<title>Dropbox Auth</title> | ||
<script src="../../scripts/cloud/dropbox.min.js"></script> | ||
<script src="../../scripts/cloud/dropbox_authdriver_firefoxos_receiver.js"></script> | ||
<script src="dropbox_oauth2.js"></script> | ||
<style> | ||
body, html { | ||
color: #515151; | ||
text-shadow: 0 0 2px white; | ||
background: #ffffff; | ||
font-size: 1em; | ||
} | ||
.container { | ||
text-align: center; | ||
padding: 1rem; | ||
} | ||
h3 { | ||
font-size: 2rem; | ||
font-weight: bold; | ||
font-family: sans-serif; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<img src="dropbox.svg" alt="Dropbox Logo" width="150" height="150" /> | ||
<h3 style="margin: 0;">You can now use Firetext with Dropbox!</h3> | ||
<p><i>This window should close automatically in a few seconds...</i></p> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Firefox OS Popup Dropbox Receiver | ||
* Copyright (C) Codexa Organization. | ||
*/ | ||
|
||
if (Dropbox && Dropbox.AuthDriver) { | ||
Dropbox.AuthDriver.FFOSPopup = (function(superClass) { | ||
var allowedOrigins = ["https://codexa.github.io", "http://firetext.codexa.bugs3.com", "localhost"]; | ||
|
||
function FFOSPopup() { | ||
} | ||
|
||
FFOSPopup.locationOrigin = function(location) { | ||
var match; | ||
match = /^(file:\/\/[^\?\#]*)/.exec(location); | ||
if (match) { | ||
return "file"; | ||
} | ||
|
||
match = /^([^\:]+\:\/\/localhost(:[0-9]*){0,1}([\/]|$))/.exec(location); | ||
if (match) { | ||
return "localhost"; | ||
} | ||
|
||
match = /^([^\:]+\:\/\/[^\/\?\#]*)/.exec(location); | ||
if (match) { | ||
return match[1]; | ||
} | ||
return location; | ||
}; | ||
|
||
FFOSPopup.oauthReceiver = function(inApp) { | ||
window.addEventListener('load', function() { | ||
var frameError, getOriginMessage, ieError, message, opener, pageUrl, receiveMessage; | ||
pageUrl = window.location.href; | ||
getOriginMessage = JSON.stringify({ | ||
_dropboxjs_needs_origin: true | ||
}); | ||
message = JSON.stringify({ | ||
_dropboxjs_oauth_info: pageUrl | ||
}); | ||
Dropbox.AuthDriver.BrowserBase.cleanupLocation(); | ||
opener = window.opener; | ||
if (window.parent !== window.top) { | ||
opener || (opener = window.parent); | ||
} | ||
if (opener) { | ||
receiveMessage = function(e) { | ||
if (e.source === opener && | ||
(allowedOrigins.indexOf(Dropbox.AuthDriver.FFOSPopup.locationOrigin(e.origin)) !== -1 || | ||
inApp)) { | ||
opener.postMessage(message, e.origin); | ||
window.close(); | ||
} | ||
}; | ||
window.addEventListener('message', receiveMessage, false); | ||
try { | ||
opener.postMessage(getOriginMessage, "*"); | ||
} catch (_error) { | ||
ieError = _error; | ||
} | ||
try { | ||
opener.Dropbox.AuthDriver.FFOSPopup.onMessage.dispatch(message); | ||
window.close(); | ||
} catch (_error) { | ||
frameError = _error; | ||
} | ||
} | ||
}); | ||
}; | ||
|
||
FFOSPopup.onMessage = new Dropbox.Util.EventSource; | ||
|
||
return FFOSPopup; | ||
})(Dropbox.AuthDriver.BrowserBase); | ||
} else { | ||
console.log("Dropbox.js is not present."); | ||
} |