Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: mobile/android/chrome/content/browser.js

Issue 5365916275572736: Issue 2351 - Add a custom menu item for whitelisting the current site (Closed)
Patch Set: Add missing break Created April 27, 2015, 9:47 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mobile/android/base/strings.xml.in ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #filter substitution 1 #filter substitution
2 // -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2- skip-preprocessor-directives: t; -*- 2 // -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2- skip-preprocessor-directives: t; -*-
3 /* This Source Code Form is subject to the terms of the Mozilla Public 3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 "use strict"; 6 "use strict";
7 7
8 let Cc = Components.classes; 8 let Cc = Components.classes;
9 let Ci = Components.interfaces; 9 let Ci = Components.interfaces;
10 let Cu = Components.utils; 10 let Cu = Components.utils;
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 Services.obs.addObserver(this, "webapps-runtime-install", false); 356 Services.obs.addObserver(this, "webapps-runtime-install", false);
357 Services.obs.addObserver(this, "webapps-runtime-install-package", false); 357 Services.obs.addObserver(this, "webapps-runtime-install-package", false);
358 Services.obs.addObserver(this, "webapps-ask-install", false); 358 Services.obs.addObserver(this, "webapps-ask-install", false);
359 Services.obs.addObserver(this, "webapps-ask-uninstall", false); 359 Services.obs.addObserver(this, "webapps-ask-uninstall", false);
360 Services.obs.addObserver(this, "webapps-launch", false); 360 Services.obs.addObserver(this, "webapps-launch", false);
361 Services.obs.addObserver(this, "webapps-runtime-uninstall", false); 361 Services.obs.addObserver(this, "webapps-runtime-uninstall", false);
362 Services.obs.addObserver(this, "Webapps:AutoInstall", false); 362 Services.obs.addObserver(this, "Webapps:AutoInstall", false);
363 Services.obs.addObserver(this, "Webapps:Load", false); 363 Services.obs.addObserver(this, "Webapps:Load", false);
364 Services.obs.addObserver(this, "Webapps:AutoUninstall", false); 364 Services.obs.addObserver(this, "Webapps:AutoUninstall", false);
365 Services.obs.addObserver(this, "sessionstore-state-purge-complete", false); 365 Services.obs.addObserver(this, "sessionstore-state-purge-complete", false);
366 Services.obs.addObserver(this, "BlockAds:Change", false);
366 367
367 function showFullScreenWarning() { 368 function showFullScreenWarning() {
368 NativeWindow.toast.show(Strings.browser.GetStringFromName("alertFullScreen Toast"), "short"); 369 NativeWindow.toast.show(Strings.browser.GetStringFromName("alertFullScreen Toast"), "short");
369 } 370 }
370 371
371 window.addEventListener("fullscreen", function() { 372 window.addEventListener("fullscreen", function() {
372 sendMessageToJava({ 373 sendMessageToJava({
373 type: window.fullScreen ? "ToggleChrome:Show" : "ToggleChrome:Hide" 374 type: window.fullScreen ? "ToggleChrome:Show" : "ToggleChrome:Hide"
374 }); 375 });
375 }, false); 376 }, false);
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 1756
1756 // Ensure that this choice is immediately persisted, because 1757 // Ensure that this choice is immediately persisted, because
1757 // Gecko won't be told again if it forgets. 1758 // Gecko won't be told again if it forgets.
1758 Services.prefs.savePrefFile(null); 1759 Services.prefs.savePrefFile(null);
1759 1760
1760 // Blow away the string cache so that future lookups get the 1761 // Blow away the string cache so that future lookups get the
1761 // correct locale. 1762 // correct locale.
1762 Services.strings.flushBundles(); 1763 Services.strings.flushBundles();
1763 break; 1764 break;
1764 1765
1766 case "BlockAds:Change":
1767 let {blockAds, url} = JSON.parse(aData);
1768 let ioService = Cc["@mozilla.org/network/io-service;1"]
1769 .getService(Ci.nsIIOService);
1770 url = ioService.newURI(url, null, null).QueryInterface(Ci.nsIURL);
1771 AdblockPlusApi.whitelistSite(url, !blockAds);
1772 browser.webNavigation.reload(Ci.nsIWebNavigation.LOAD_FLAGS_NONE);
1773 break;
1774
1765 default: 1775 default:
1766 dump('BrowserApp.observe: unexpected topic "' + aTopic + '"\n'); 1776 dump('BrowserApp.observe: unexpected topic "' + aTopic + '"\n');
1767 break; 1777 break;
1768 1778
1769 } 1779 }
1770 }, 1780 },
1771 1781
1772 get defaultBrowserWidth() { 1782 get defaultBrowserWidth() {
1773 delete this.defaultBrowserWidth; 1783 delete this.defaultBrowserWidth;
1774 let width = Services.prefs.getIntPref("browser.viewport.desktopWidth"); 1784 let width = Services.prefs.getIntPref("browser.viewport.desktopWidth");
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1918 1928
1919 sendMessageToJava(msg); 1929 sendMessageToJava(msg);
1920 } 1930 }
1921 }, 1931 },
1922 1932
1923 menu: { 1933 menu: {
1924 _callbacks: [], 1934 _callbacks: [],
1925 _menuId: 1, 1935 _menuId: 1,
1926 toolsMenuID: -1, 1936 toolsMenuID: -1,
1927 add: function() { 1937 add: function() {
1938 // Adblock Browser doesn't support add-ons, so the only menu item that
1939 // could be added is the one for whitelisting the current domain added by
1940 // ABP - Adblock Browser has its own item for that.
1941 return;
1942
1928 let options; 1943 let options;
1929 if (arguments.length == 1) { 1944 if (arguments.length == 1) {
1930 options = arguments[0]; 1945 options = arguments[0];
1931 } else if (arguments.length == 3) { 1946 } else if (arguments.length == 3) {
1932 options = { 1947 options = {
1933 name: arguments[0], 1948 name: arguments[0],
1934 icon: arguments[1], 1949 icon: arguments[1],
1935 callback: arguments[2] 1950 callback: arguments[2]
1936 }; 1951 };
1937 } else { 1952 } else {
(...skipping 2271 matching lines...) Expand 10 before | Expand all | Expand 10 after
4209 if (bannedSchemes.indexOf(fixedURI.scheme) > -1) { 4224 if (bannedSchemes.indexOf(fixedURI.scheme) > -1) {
4210 aRequest.cancel(Cr.NS_BINDING_ABORTED); 4225 aRequest.cancel(Cr.NS_BINDING_ABORTED);
4211 4226
4212 aRequest = this.browser.docShell.displayLoadError(Cr.NS_ERROR_UNKNOWN_PR OTOCOL, fixedURI, null); 4227 aRequest = this.browser.docShell.displayLoadError(Cr.NS_ERROR_UNKNOWN_PR OTOCOL, fixedURI, null);
4213 if (aRequest) { 4228 if (aRequest) {
4214 fixedURI = aRequest.URI; 4229 fixedURI = aRequest.URI;
4215 } 4230 }
4216 } 4231 }
4217 } 4232 }
4218 4233
4234 let canBlockAds = !AdblockPlusApi.isLocal(fixedURI);
4235 sendMessageToJava({
4236 type: "BlockAds:Update",
4237 canBlockAds: canBlockAds,
4238 blockAds: canBlockAds && !AdblockPlusApi.isPageWhitelisted(fixedURI)
4239 });
4240
4219 let contentType = contentWin.document.contentType; 4241 let contentType = contentWin.document.contentType;
4220 4242
4221 // If fixedURI matches browser.lastURI, we assume this isn't a real location 4243 // If fixedURI matches browser.lastURI, we assume this isn't a real location
4222 // change but rather a spurious addition like a wyciwyg URI prefix. See Bug 747883. 4244 // change but rather a spurious addition like a wyciwyg URI prefix. See Bug 747883.
4223 // Note that we have to ensure fixedURI is not the same as aLocationURI so w e 4245 // Note that we have to ensure fixedURI is not the same as aLocationURI so w e
4224 // don't false-positive page reloads as spurious additions. 4246 // don't false-positive page reloads as spurious additions.
4225 let sameDocument = (aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_ DOCUMENT) != 0 || 4247 let sameDocument = (aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_ DOCUMENT) != 0 ||
4226 ((this.browser.lastURI != null) && fixedURI.equals(this.b rowser.lastURI) && !fixedURI.equals(aLocationURI)); 4248 ((this.browser.lastURI != null) && fixedURI.equals(this.b rowser.lastURI) && !fixedURI.equals(aLocationURI));
4227 this.browser.lastURI = fixedURI; 4249 this.browser.lastURI = fixedURI;
4228 4250
(...skipping 4216 matching lines...) Expand 10 before | Expand all | Expand 10 after
8445 disabled: elt.disabled, 8467 disabled: elt.disabled,
8446 menu: elt instanceof Ci.nsIDOMHTMLMenuElement 8468 menu: elt instanceof Ci.nsIDOMHTMLMenuElement
8447 }; 8469 };
8448 } 8470 }
8449 }, 8471 },
8450 }); 8472 });
8451 8473
8452 let {AdblockPlusApi} = Cu.import("chrome://adblockplus/content/Api.jsm"); 8474 let {AdblockPlusApi} = Cu.import("chrome://adblockplus/content/Api.jsm");
8453 AdblockPlusApi.initCommunication(); 8475 AdblockPlusApi.initCommunication();
8454 8476
OLDNEW
« no previous file with comments | « mobile/android/base/strings.xml.in ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld