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

Delta Between Two Patch Sets: lib/ui.js

Issue 5705421486555136: First run page and subscription on install fix (FF for android) (Closed)
Left Patch Set: Created April 25, 2014, 11:40 a.m.
Right Patch Set: check if CustomizableUI is set in isToolbarIconVisible() and toggleToolbarIcon() methods Created April 25, 2014, 3:03 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 14 matching lines...) Expand all
25 let {FilterStorage} = require("filterStorage"); 25 let {FilterStorage} = require("filterStorage");
26 let {FilterNotifier} = require("filterNotifier"); 26 let {FilterNotifier} = require("filterNotifier");
27 let {RequestNotifier} = require("requestNotifier"); 27 let {RequestNotifier} = require("requestNotifier");
28 let {Filter} = require("filterClasses"); 28 let {Filter} = require("filterClasses");
29 let {Subscription, SpecialSubscription, DownloadableSubscription} = require("sub scriptionClasses"); 29 let {Subscription, SpecialSubscription, DownloadableSubscription} = require("sub scriptionClasses");
30 let {Synchronizer} = require("synchronizer"); 30 let {Synchronizer} = require("synchronizer");
31 let {KeySelector} = require("keySelector"); 31 let {KeySelector} = require("keySelector");
32 let {Notification} = require("notification"); 32 let {Notification} = require("notification");
33 let {initAntiAdblockNotification} = require("antiadblockInit"); 33 let {initAntiAdblockNotification} = require("antiadblockInit");
34 34
35 let CustomizableUI; 35 let CustomizableUI = null;
36 36
37 /** 37 /**
38 * Filter corresponding with "disable on site" menu item (set in fillIconMent()) . 38 * Filter corresponding with "disable on site" menu item (set in fillIconMent()) .
39 * @type Filter 39 * @type Filter
40 */ 40 */
41 let siteWhitelist = null; 41 let siteWhitelist = null;
42 /** 42 /**
43 * Filter corresponding with "disable on site" menu item (set in fillIconMenu()) . 43 * Filter corresponding with "disable on site" menu item (set in fillIconMenu()) .
44 * @type Filter 44 * @type Filter
45 */ 45 */
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 */ 261 */
262 let notificationTimer = null; 262 let notificationTimer = null;
263 263
264 let UI = exports.UI = 264 let UI = exports.UI =
265 { 265 {
266 /** 266 /**
267 * Gets called on startup, initializes UI integration. 267 * Gets called on startup, initializes UI integration.
268 */ 268 */
269 init: function() 269 init: function()
270 { 270 {
271 try
272 {
273 ({CustomizableUI}) = Cu.import("resource:///modules/CustomizableUI.jsm", n ull);
saroyanm 2014/04/25 12:08:06 Not sure if we need this here ?
274 }
275 catch (e)
276 {
277 // No built-in CustomizableUI API, use our own implementation.
278 ({CustomizableUI}) = require("customizableUI");
279 }
Wladimir Palant 2014/04/25 12:39:54 This doesn't resolve the circular reference. The m
saroyanm 2014/04/25 14:04:22 Thanks for descriptive comment. Done.
280
281 // We should call initDone once both overlay and filters are loaded 271 // We should call initDone once both overlay and filters are loaded
282 let overlayLoaded = false; 272 let overlayLoaded = false;
283 let filtersLoaded = false; 273 let filtersLoaded = false;
284 let sessionRestored = false; 274 let sessionRestored = false;
285 275
286 // Start loading overlay 276 // Start loading overlay
287 let request = new XMLHttpRequest(); 277 let request = new XMLHttpRequest();
288 request.mozBackgroundRequest = true; 278 request.mozBackgroundRequest = true;
289 request.open("GET", "chrome://adblockplus/content/ui/overlay.xul"); 279 request.open("GET", "chrome://adblockplus/content/ui/overlay.xul");
290 request.addEventListener("load", function(event) 280 request.addEventListener("load", function(event)
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 */ 396 */
407 initDone: function() 397 initDone: function()
408 { 398 {
409 let {WindowObserver} = require("windowObserver"); 399 let {WindowObserver} = require("windowObserver");
410 new WindowObserver(this); 400 new WindowObserver(this);
411 401
412 // Add toolbar icon 402 // Add toolbar icon
413 let {defaultToolbarPosition} = require("appSupport"); 403 let {defaultToolbarPosition} = require("appSupport");
414 if ("abp-toolbarbutton" in this.overlay && defaultToolbarPosition) 404 if ("abp-toolbarbutton" in this.overlay && defaultToolbarPosition)
415 { 405 {
406 try
407 {
408 ({CustomizableUI}) = Cu.import("resource:///modules/CustomizableUI.jsm", null);
409 }
410 catch (e)
411 {
412 // No built-in CustomizableUI API, use our own implementation.
413 ({CustomizableUI}) = require("customizableUI");
414 }
415
416 CustomizableUI.createWidget({ 416 CustomizableUI.createWidget({
417 id: "abp-toolbarbutton", 417 id: "abp-toolbarbutton",
418 type: "custom", 418 type: "custom",
419 positionAttribute: "abp-iconposition", // For emulation only 419 positionAttribute: "abp-iconposition", // For emulation only
420 defaultArea: defaultToolbarPosition.parent, 420 defaultArea: defaultToolbarPosition.parent,
421 defaultBefore: defaultToolbarPosition.before, // For emulation only 421 defaultBefore: defaultToolbarPosition.before, // For emulation only
422 defaultAfter: defaultToolbarPosition.after, // For emulation only 422 defaultAfter: defaultToolbarPosition.after, // For emulation only
423 removable: true, 423 removable: true,
424 onBuild: function(document) 424 onBuild: function(document)
425 { 425 {
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 } 1028 }
1029 1029
1030 return [parent, before]; 1030 return [parent, before];
1031 }, 1031 },
1032 1032
1033 /** 1033 /**
1034 * Toggles visibility state of the toolbar icon. 1034 * Toggles visibility state of the toolbar icon.
1035 */ 1035 */
1036 toggleToolbarIcon: function() 1036 toggleToolbarIcon: function()
1037 { 1037 {
1038 if (!CustomizableUI)
1039 return;
1038 if (this.isToolbarIconVisible()) 1040 if (this.isToolbarIconVisible())
1039 CustomizableUI.removeWidgetFromArea("abp-toolbarbutton"); 1041 CustomizableUI.removeWidgetFromArea("abp-toolbarbutton");
1040 else 1042 else
1041 { 1043 {
1042 let {defaultToolbarPosition} = require("appSupport"); 1044 let {defaultToolbarPosition} = require("appSupport");
1043 CustomizableUI.addWidgetToArea("abp-toolbarbutton", defaultToolbarPosition .parent); 1045 CustomizableUI.addWidgetToArea("abp-toolbarbutton", defaultToolbarPosition .parent);
1044 } 1046 }
1045 }, 1047 },
1046 1048
1047 /** 1049 /**
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 command.doCommand(); 1704 command.doCommand();
1703 } 1705 }
1704 } 1706 }
1705 }, 1707 },
1706 1708
1707 /** 1709 /**
1708 * Checks whether the toolbar icon is currently displayed. 1710 * Checks whether the toolbar icon is currently displayed.
1709 */ 1711 */
1710 isToolbarIconVisible: function() /**Boolean*/ 1712 isToolbarIconVisible: function() /**Boolean*/
1711 { 1713 {
1714 if (!CustomizableUI)
1715 return false;
1712 let placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); 1716 let placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton");
1713 return !!placement; 1717 return !!placement;
1714 }, 1718 },
1715 1719
1716 /** 1720 /**
1717 * Stores the selected hotkeys, initialized when the user presses a key. 1721 * Stores the selected hotkeys, initialized when the user presses a key.
1718 */ 1722 */
1719 hotkeys: null, 1723 hotkeys: null,
1720 1724
1721 /** 1725 /**
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1913 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], 1917 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)],
1914 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] 1918 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)]
1915 ]; 1919 ];
1916 1920
1917 onShutdown.add(function() 1921 onShutdown.add(function()
1918 { 1922 {
1919 for (let window in UI.applicationWindows) 1923 for (let window in UI.applicationWindows)
1920 if (UI.isBottombarOpen(window)) 1924 if (UI.isBottombarOpen(window))
1921 UI.toggleBottombar(window); 1925 UI.toggleBottombar(window);
1922 }); 1926 });
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld