-
-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for firefox on android #1516
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
5328e70
making options page accessible within android
lemnis b330291
faking popup when clicked on browser action
lemnis f222299
extra checks if specific function is available
lemnis fdaa6fb
fix for android to get tab id
lemnis d39af45
Merge remote-tracking branch 'EFForg/master'
lemnis bc231ec
Fixing small css issues, mostly visible on a phone
lemnis c61c0a8
cleanup
lemnis 0b865e8
Removes whitespace at bottom of a popup in chrome
lemnis ab5d902
removed chrome.windows api
lemnis 5a8d934
small fixes caused by container size
lemnis 323580e
Moved feature checks to top of function
lemnis 3bda018
Moved to URL api
lemnis ea950fd
changed fake popup behavior + cleanup
lemnis 7884298
update feature check
lemnis 700e92c
removed whitespace
lemnis ac18053
fixed accidental tab close
lemnis b4dd778
cleanup code
lemnis 2c986a2
Moved all FF Android functions to sep. file
lemnis e73d12d
Merge branch 'EFForg/master'
lemnis 98fbb56
small bug fixes
lemnis 2443260
improved comments
lemnis 1f230cf
fix for selenium test
lemnis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ var constants = require("constants"); | |
var pbStorage = require("storage"); | ||
|
||
var HeuristicBlocking = require("heuristicblocking"); | ||
var FirefoxAndroid = require("firefoxandroid"); | ||
var webrequest = require("webrequest"); | ||
var SocialWidgetLoader = require("socialwidgetloader"); | ||
window.SocialWidgetList = SocialWidgetLoader.loadSocialWidgetsFromFile("data/socialwidgets.json"); | ||
|
@@ -55,11 +56,9 @@ function Badger() { | |
} | ||
|
||
// Show icon as page action for all tabs that already exist | ||
chrome.windows.getAll({populate: true}, function (windows) { | ||
for (var i = 0; i < windows.length; i++) { | ||
for (var j = 0; j < windows[i].tabs.length; j++) { | ||
badger.refreshIconAndContextMenu(windows[i].tabs[j]); | ||
} | ||
chrome.tabs.query({}, function (tabs) { | ||
for (var i = 0; i < tabs.length; i++) { | ||
badger.refreshIconAndContextMenu(tabs[i]); | ||
} | ||
}); | ||
|
||
|
@@ -532,6 +531,10 @@ Badger.prototype = { | |
* @param {Integer} tabId chrome tab id | ||
*/ | ||
updateBadge: function(tabId){ | ||
if(FirefoxAndroid.isUsed){ | ||
return; | ||
} | ||
|
||
if (!this.showCounter()){ | ||
chrome.browserAction.setBadgeText({tabId: tabId, text: ""}); | ||
return; | ||
|
@@ -603,7 +606,7 @@ Badger.prototype = { | |
} | ||
return true; | ||
}, | ||
|
||
/** | ||
* Check if privacy badger is disabled, take an origin and | ||
* check against the disabledSites list | ||
|
@@ -745,7 +748,7 @@ Badger.prototype = { | |
* @param {Object} tab The tab to set the badger icon for | ||
*/ | ||
refreshIconAndContextMenu: function (tab) { | ||
if (!tab) { | ||
if (!tab || FirefoxAndroid.isUsed) { | ||
return; | ||
} | ||
|
||
|
@@ -763,7 +766,6 @@ Badger.prototype = { | |
} | ||
|
||
chrome.browserAction.setIcon({tabId: tab.id, path: iconFilename}); | ||
chrome.browserAction.setTitle({tabId: tab.id, title: "Privacy Badger"}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, now this is localized properly by the |
||
}, | ||
|
||
}; | ||
|
@@ -777,7 +779,6 @@ function startBackgroundListeners() { | |
} | ||
}, {urls: ["http://*/*", "https://*/*"]}, []); | ||
|
||
|
||
// Update icon if a tab changes location | ||
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { | ||
if(changeInfo.status == "loading") { | ||
|
@@ -827,6 +828,7 @@ var badger = window.badger = new Badger(); | |
incognito.startListeners(); | ||
webrequest.startListeners(); | ||
HeuristicBlocking.startListeners(); | ||
FirefoxAndroid.startListeners(); | ||
startBackgroundListeners(); | ||
|
||
// TODO move listeners and this message behind INITIALIZED | ||
|
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,89 @@ | ||
/* | ||
* This file is part of Privacy Badger <https://www.eff.org/privacybadger> | ||
* Copyright (C) 2014 Electronic Frontier Foundation | ||
* | ||
* Privacy Badger is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as | ||
* published by the Free Software Foundation. | ||
* | ||
* Privacy Badger is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Privacy Badger. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/* | ||
* Temporary polyfill for firefox android, | ||
* while it doesn't support the full browserAction API | ||
* Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1330159 | ||
*/ | ||
|
||
require.scopes.firefoxandroid = (function() { | ||
var isFirefoxAndroid = !( | ||
chrome.browserAction.setBadgeText && | ||
chrome.browserAction.setPopup && | ||
chrome.browserAction.getPopup | ||
); | ||
|
||
// keeps track of popup id while one is open | ||
var openPopupId = false; | ||
var popup_url = chrome.runtime.getManifest().browser_action.default_popup; | ||
|
||
// fakes a popup | ||
function openPopup() { | ||
chrome.tabs.query({active: true, lastFocusedWindow: true}, (tabs) => { | ||
var url = popup_url + "?tabId=" + tabs[0].id; | ||
chrome.tabs.create({url, index: tabs[0].index + 1}, (tab) => { | ||
openPopupId = tab.id; | ||
}); | ||
}); | ||
} | ||
|
||
// remove the 'popup' when another tab is activated | ||
function onActivated(activeInfo) { | ||
if(openPopupId != false && openPopupId != activeInfo.tabId) { | ||
chrome.tabs.remove(openPopupId, () => { | ||
openPopupId = false; | ||
}); | ||
} | ||
} | ||
|
||
// forgets the popup when the url is overwritten by the user | ||
function onUpdated(tabId, changeInfo, tab) { | ||
if(tab.url && openPopupId == tabId){ | ||
var new_url = new URL(tab.url); | ||
|
||
if(new_url.origin + new_url.pathname != popup_url){ | ||
openPopupId = false; | ||
} | ||
} | ||
} | ||
|
||
// Subscribe to events needed to fake a popup | ||
function startListeners() { | ||
if(isFirefoxAndroid){ | ||
chrome.browserAction.onClicked.addListener(openPopup); | ||
chrome.tabs.onActivated.addListener(onActivated); | ||
chrome.tabs.onUpdated.addListener(onUpdated); | ||
} | ||
} | ||
|
||
// Used in popup.js, figures out which tab opened the 'fake' popup | ||
function getParentOfPopup(callback){ | ||
chrome.tabs.query({active: true, lastFocusedWindow: true}, function(focusedTab) { | ||
var parentId = parseInt(new URL(focusedTab[0].url).searchParams.get('tabId')); | ||
chrome.tabs.get(parentId, callback); | ||
}); | ||
} | ||
|
||
/************************************** exports */ | ||
var exports = {}; | ||
exports.startListeners = startListeners; | ||
exports.isUsed = isFirefoxAndroid; | ||
exports.getParentOfPopup = getParentOfPopup; | ||
return exports; | ||
/************************************** exports */ | ||
})(); |
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
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍