Skip to content

Commit

Permalink
Fix ACL dialog on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Feb 20, 2018
1 parent f9b60ff commit dcbd868
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions add-on/src/lib/ipfs-proxy/request-access.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,28 @@ function createRequestAccess (browser, screen) {
return async function requestAccess (scope, permission, opts) {
opts = opts || {}

const width = opts.dialogWidth || DIALOG_WIDTH
const height = opts.dialogHeight || DIALOG_HEIGHT

const url = browser.extension.getURL(opts.dialogPath || DIALOG_PATH)
const currentWin = await browser.windows.getCurrent()

const top = Math.round(((screen.width / 2) - (width / 2)) + currentWin.left)
const left = Math.round(((screen.height / 2) - (height / 2)) + currentWin.top)

const dialogWindow = await browser.windows.create({ url, width, height, top, left, type: 'popup' })
const dialogTabId = dialogWindow.tabs[0].id
// Fix for Fx57 bug where bundled page loaded using
// browser.windows.create won't show contents unless resized.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1402110
await browser.windows.update(dialogWindow.id, {width: dialogWindow.width + 1})
let dialogTabId
if (browser && browser.windows && browser.windows.create) {
// display modal dialog in a centered popup window
const currentWin = await browser.windows.getCurrent()
const width = opts.dialogWidth || DIALOG_WIDTH
const height = opts.dialogHeight || DIALOG_HEIGHT
const top = Math.round(((screen.width / 2) - (width / 2)) + currentWin.left)
const left = Math.round(((screen.height / 2) - (height / 2)) + currentWin.top)

const dialogWindow = await browser.windows.create({ url, width, height, top, left, type: 'popup' })
dialogTabId = dialogWindow.tabs[0].id
// Fix for Fx57 bug where bundled page loaded using
// browser.windows.create won't show contents unless resized.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1402110
await browser.windows.update(dialogWindow.id, {width: dialogWindow.width + 1})
} else {
// fallback: opening dialog as a new active tab
// (runtimes without browser.windows.create, eg. Andorid)
dialogTabId = (await browser.tabs.create({active: true, url: url})).id
}

// Resolves with { allow, wildcard }
const userResponse = getUserResponse(dialogTabId, scope, permission, opts)
Expand Down

0 comments on commit dcbd868

Please sign in to comment.