Pier Angelo Vendrame pushed to branch tor-browser-102.9.0esr-12.5-1 at The Tor Project / Applications / Tor Browser
Commits:
-
16c5a240
by hackademix at 2023-03-28T22:53:50+02:00
-
1d0cc334
by hackademix at 2023-03-28T23:30:47+02:00
-
e32a6cd3
by hackademix at 2023-03-28T23:33:12+02:00
-
be88af1c
by hackademix at 2023-03-29T09:52:37+02:00
5 changed files:
- browser/app/profile/000-tor-browser.js
- browser/locales/en-US/browser/languageNotification.ftl
- toolkit/components/resistfingerprinting/RFPHelper.jsm
- toolkit/torbutton/chrome/content/torbutton.js
- toolkit/torbutton/chrome/locale/en-US/torbutton.properties
Changes:
... | ... | @@ -65,11 +65,6 @@ pref("extensions.torbutton.use_nontor_proxy", false); |
65 | 65 | // State prefs:
|
66 | 66 | pref("extensions.torbutton.startup", false);
|
67 | 67 | |
68 | -// This is only used when letterboxing is disabled.
|
|
69 | -// See #7255 for details. We display the warning three times to make sure the
|
|
70 | -// user did not click on it by accident.
|
|
71 | -pref("extensions.torbutton.maximize_warnings_remaining", 3);
|
|
72 | - |
|
73 | 68 | // Security prefs:
|
74 | 69 | pref("extensions.torbutton.resize_new_windows", false);
|
75 | 70 | pref("extensions.torbutton.launch_warning", true);
|
... | ... | @@ -8,3 +8,7 @@ language-notification-label-system = { -brand-short-name } has set your display |
8 | 8 | # $language is the language Tor Browser is displayed in (already translated).
|
9 | 9 | language-notification-label = { -brand-short-name } has set your display language to { $language }.
|
10 | 10 | language-notification-button = Change Language…
|
11 | + |
|
12 | +basebrowser-rfp-maximize-warning-message = Maximizing the browser window can allow websites to determine your monitor size, which can be used to track you. We recommend that you leave browser windows in their original default size.
|
|
13 | +basebrowser-rfp-restore-window-size-button-label = Restore
|
|
14 | +basebrowser-rfp-restore-window-size-button-ak = R |
... | ... | @@ -22,16 +22,110 @@ const kPrefLetterboxingTesting = |
22 | 22 | "privacy.resistFingerprinting.letterboxing.testing";
|
23 | 23 | const kTopicDOMWindowOpened = "domwindowopened";
|
24 | 24 | |
25 | -var logConsole;
|
|
26 | -function log(msg) {
|
|
27 | - if (!logConsole) {
|
|
28 | - logConsole = console.createInstance({
|
|
29 | - prefix: "RFPHelper.jsm",
|
|
30 | - maxLogLevelPref: "privacy.resistFingerprinting.jsmloglevel",
|
|
31 | - });
|
|
25 | +const kPrefResizeWarnings = "privacy.resistFingerprinting.resizeWarnings";
|
|
26 | + |
|
27 | +XPCOMUtils.defineLazyGetter(this, "logConsole", () =>
|
|
28 | + console.createInstance({
|
|
29 | + prefix: "RFPHelper.jsm",
|
|
30 | + maxLogLevelPref: "privacy.resistFingerprinting.jsmloglevel",
|
|
31 | + })
|
|
32 | +);
|
|
33 | + |
|
34 | +function log(...args) {
|
|
35 | + logConsole.log(...args);
|
|
36 | +}
|
|
37 | + |
|
38 | +function forEachWindow(callback) {
|
|
39 | + const windowList = Services.wm.getEnumerator("navigator:browser");
|
|
40 | + while (windowList.hasMoreElements()) {
|
|
41 | + const win = windowList.getNext();
|
|
42 | + if (win.gBrowser && !win.closed) {
|
|
43 | + try {
|
|
44 | + callback(win);
|
|
45 | + } catch (e) {
|
|
46 | + logConsole.error(e);
|
|
47 | + }
|
|
48 | + }
|
|
49 | + }
|
|
50 | +}
|
|
51 | + |
|
52 | + |
|
53 | +async function windowResizeHandler(aEvent) {
|
|
54 | + if (RFPHelper.letterboxingEnabled) {
|
|
55 | + return;
|
|
56 | + }
|
|
57 | + if (Services.prefs.getIntPref(kPrefResizeWarnings, 3) <= 0) {
|
|
58 | + return;
|
|
59 | + }
|
|
60 | + |
|
61 | + const window = aEvent.currentTarget;
|
|
62 | + |
|
63 | + // Wait for end of execution queue to ensure we have correct windowState.
|
|
64 | + await new Promise(resolve => window.setTimeout(resolve, 0));
|
|
65 | + switch (window.windowState) {
|
|
66 | + case window.STATE_MAXIMIZED:
|
|
67 | + case window.STATE_FULLSCREEN:
|
|
68 | + break;
|
|
69 | + default:
|
|
70 | + return;
|
|
71 | + }
|
|
72 | + |
|
73 | + // Do not add another notification if one is already showing.
|
|
74 | + const kNotificationName = "rfp-window-resize-notification";
|
|
75 | + let box = window.gNotificationBox;
|
|
76 | + if (box.getNotificationWithValue(kNotificationName)) {
|
|
77 | + return;
|
|
32 | 78 | }
|
33 | 79 | |
34 | - logConsole.log(msg);
|
|
80 | + // Rate-limit showing our notification if needed.
|
|
81 | + if (Date.now() - (windowResizeHandler.timestamp || 0) < 1000) {
|
|
82 | + return;
|
|
83 | + }
|
|
84 | + windowResizeHandler.timestamp = Date.now();
|
|
85 | + |
|
86 | + const decreaseWarningsCount = () => {
|
|
87 | + const currentCount = Services.prefs.getIntPref(kPrefResizeWarnings);
|
|
88 | + if (currentCount > 0) {
|
|
89 | + Services.prefs.setIntPref(kPrefResizeWarnings, currentCount - 1);
|
|
90 | + }
|
|
91 | + };
|
|
92 | + |
|
93 | + const [label, accessKey] = await window.document.l10n.formatValues([
|
|
94 | + { id: "basebrowser-rfp-restore-window-size-button-label" },
|
|
95 | + { id: "basebrowser-rfp-restore-window-size-button-ak" },
|
|
96 | + ]);
|
|
97 | + |
|
98 | + const buttons = [
|
|
99 | + {
|
|
100 | + label,
|
|
101 | + accessKey,
|
|
102 | + popup: null,
|
|
103 | + callback() {
|
|
104 | + // reset notification timer to work-around resize race conditions
|
|
105 | + windowResizeHandler.timestamp = Date.now();
|
|
106 | + // restore the original (rounded) size we had stored on window startup
|
|
107 | + let { _rfpOriginalSize } = window;
|
|
108 | + window.setTimeout(() => {
|
|
109 | + window.resizeTo(_rfpOriginalSize.width, _rfpOriginalSize.height);
|
|
110 | + }, 0);
|
|
111 | + },
|
|
112 | + },
|
|
113 | + ];
|
|
114 | + |
|
115 | + box.appendNotification(
|
|
116 | + kNotificationName,
|
|
117 | + {
|
|
118 | + label: { "l10n-id": "basebrowser-rfp-maximize-warning-message" },
|
|
119 | + priority: box.PRIORITY_WARNING_LOW,
|
|
120 | + eventCallback(event) {
|
|
121 | + if (event === "dismissed") {
|
|
122 | + // user manually dismissed the notification
|
|
123 | + decreaseWarningsCount();
|
|
124 | + }
|
|
125 | + },
|
|
126 | + },
|
|
127 | + buttons
|
|
128 | + );
|
|
35 | 129 | }
|
36 | 130 | |
37 | 131 | class _RFPHelper {
|
... | ... | @@ -158,7 +252,11 @@ class _RFPHelper { |
158 | 252 | _handleResistFingerprintingChanged() {
|
159 | 253 | if (Services.prefs.getBoolPref(kPrefResistFingerprinting)) {
|
160 | 254 | this._addRFPObservers();
|
255 | + Services.ww.registerNotification(this);
|
|
256 | + forEachWindow(win => this._attachWindow(win));
|
|
161 | 257 | } else {
|
258 | + forEachWindow(win => this._detachWindow(win));
|
|
259 | + Services.ww.unregisterNotification(this);
|
|
162 | 260 | this._removeRFPObservers();
|
163 | 261 | }
|
164 | 262 | }
|
... | ... | @@ -295,13 +393,11 @@ class _RFPHelper { |
295 | 393 | }
|
296 | 394 | |
297 | 395 | _handleLetterboxingPrefChanged() {
|
298 | - if (Services.prefs.getBoolPref(kPrefLetterboxing, false)) {
|
|
299 | - Services.ww.registerNotification(this);
|
|
300 | - this._attachAllWindows();
|
|
301 | - } else {
|
|
302 | - this._detachAllWindows();
|
|
303 | - Services.ww.unregisterNotification(this);
|
|
304 | - }
|
|
396 | + this.letterboxingEnabled = Services.prefs.getBoolPref(
|
|
397 | + kPrefLetterboxing,
|
|
398 | + false
|
|
399 | + );
|
|
400 | + forEachWindow(win => this._updateSizeForTabsInWindow(win));
|
|
305 | 401 | }
|
306 | 402 | |
307 | 403 | // The function to parse the dimension set from the pref value. The pref value
|
... | ... | @@ -402,11 +498,13 @@ class _RFPHelper { |
402 | 498 | let logPrefix = `_roundContentSize[${Math.random()}]`;
|
403 | 499 | log(logPrefix);
|
404 | 500 | let win = aBrowser.ownerGlobal;
|
501 | + |
|
405 | 502 | let browserContainer = aBrowser
|
406 | 503 | .getTabBrowser()
|
407 | 504 | .getBrowserContainer(aBrowser);
|
408 | 505 | let browserParent = aBrowser.parentElement;
|
409 | 506 | browserParent.classList.remove("exclude-letterboxing");
|
507 | + |
|
410 | 508 | let [
|
411 | 509 | [contentWidth, contentHeight],
|
412 | 510 | [parentWidth, parentHeight],
|
... | ... | @@ -419,6 +517,27 @@ class _RFPHelper { |
419 | 517 | ])
|
420 | 518 | );
|
421 | 519 | |
520 | + if (
|
|
521 | + !win._rfpSizeOffset ||
|
|
522 | + (win._rfpOriginalSize &&
|
|
523 | + win.outerWidth === win._rfpOriginalSize.width &&
|
|
524 | + win.outerHeight === win._rfpOriginalSize.height)
|
|
525 | + ) {
|
|
526 | + const BASELINE_ROUNDING = 10;
|
|
527 | + const offset = s =>
|
|
528 | + s - Math.round(s / BASELINE_ROUNDING) * BASELINE_ROUNDING;
|
|
529 | + |
|
530 | + win._rfpSizeOffset = {
|
|
531 | + width: offset(parentWidth),
|
|
532 | + height: offset(parentHeight),
|
|
533 | + };
|
|
534 | + log(
|
|
535 | + `${logPrefix} Window size offsets %o (from %s, %s)`,
|
|
536 | + win._rfpSizeOffset,
|
|
537 | + parentWidth,
|
|
538 | + parentHeight
|
|
539 | + );
|
|
540 | + }
|
|
422 | 541 | log(
|
423 | 542 | `${logPrefix} contentWidth=${contentWidth} contentHeight=${contentHeight} parentWidth=${parentWidth} parentHeight=${parentHeight} containerWidth=${containerWidth} containerHeight=${containerHeight}${
|
424 | 543 | isNewTab ? " (new tab)." : "."
|
... | ... | @@ -437,6 +556,16 @@ class _RFPHelper { |
437 | 556 | });
|
438 | 557 | |
439 | 558 | let result;
|
559 | + |
|
560 | + if (!this.letterboxingEnabled) {
|
|
561 | + const offset = win._rfpSizeOffset;
|
|
562 | + result = r(aWidth - offset.width, aHeight - offset.height);
|
|
563 | + log(
|
|
564 | + `${logPrefix} Letterboxing disabled, applying baseline rounding offsets: (${aWidth}, ${aHeight}) => ${result.width} x ${result.height})`
|
|
565 | + );
|
|
566 | + return result;
|
|
567 | + }
|
|
568 | + |
|
440 | 569 | log(`${logPrefix} roundDimensions(${aWidth}, ${aHeight})`);
|
441 | 570 | // If the set is empty, we will round the content with the default
|
442 | 571 | // stepping size.
|
... | ... | @@ -554,7 +683,6 @@ class _RFPHelper { |
554 | 683 | |
555 | 684 | _updateSizeForTabsInWindow(aWindow) {
|
556 | 685 | let tabBrowser = aWindow.gBrowser;
|
557 | - |
|
558 | 686 | tabBrowser.tabpanels?.classList.add("letterboxing");
|
559 | 687 | |
560 | 688 | for (let tab of tabBrowser.tabs) {
|
... | ... | @@ -564,10 +692,18 @@ class _RFPHelper { |
564 | 692 | // we need to add this class late because otherwise new windows get maximized
|
565 | 693 | aWindow.setTimeout(() => {
|
566 | 694 | tabBrowser.tabpanels?.classList.add("letterboxing-ready");
|
695 | + if (!aWindow._rfpOriginalSize) {
|
|
696 | + aWindow._rfpOriginalSize = {
|
|
697 | + width: aWindow.outerWidth,
|
|
698 | + height: aWindow.outerHeight,
|
|
699 | + };
|
|
700 | + log("Recording original window size", aWindow._rfpOriginalSize);
|
|
701 | + }
|
|
567 | 702 | });
|
568 | 703 | }
|
569 | 704 | |
570 | 705 | _attachWindow(aWindow) {
|
706 | + aWindow.addEventListener("sizemodechange", windowResizeHandler);
|
|
571 | 707 | aWindow.gBrowser.addTabsProgressListener(this);
|
572 | 708 | aWindow.addEventListener("TabOpen", this);
|
573 | 709 | const resizeObserver = (aWindow._rfpResizeObserver = new aWindow.ResizeObserver(
|
... | ... | @@ -585,19 +721,7 @@ class _RFPHelper { |
585 | 721 | this._updateSizeForTabsInWindow(aWindow);
|
586 | 722 | }
|
587 | 723 | |
588 | - _attachAllWindows() {
|
|
589 | - let windowList = Services.wm.getEnumerator("navigator:browser");
|
|
590 | 724 | |
591 | - while (windowList.hasMoreElements()) {
|
|
592 | - let win = windowList.getNext();
|
|
593 | - |
|
594 | - if (win.closed || !win.gBrowser) {
|
|
595 | - continue;
|
|
596 | - }
|
|
597 | - |
|
598 | - this._attachWindow(win);
|
|
599 | - }
|
|
600 | - }
|
|
601 | 725 | |
602 | 726 | _detachWindow(aWindow) {
|
603 | 727 | let tabBrowser = aWindow.gBrowser;
|
... | ... | @@ -614,20 +738,7 @@ class _RFPHelper { |
614 | 738 | let browser = tab.linkedBrowser;
|
615 | 739 | this._resetContentSize(browser);
|
616 | 740 | }
|
617 | - }
|
|
618 | - |
|
619 | - _detachAllWindows() {
|
|
620 | - let windowList = Services.wm.getEnumerator("navigator:browser");
|
|
621 | - |
|
622 | - while (windowList.hasMoreElements()) {
|
|
623 | - let win = windowList.getNext();
|
|
624 | - |
|
625 | - if (win.closed || !win.gBrowser) {
|
|
626 | - continue;
|
|
627 | - }
|
|
628 | - |
|
629 | - this._detachWindow(win);
|
|
630 | - }
|
|
741 | + aWindow.removeEventListener("sizemodechange", windowResizeHandler);
|
|
631 | 742 | }
|
632 | 743 | |
633 | 744 | _handleDOMWindowOpened(win) {
|
... | ... | @@ -54,19 +54,12 @@ var torbutton_new_circuit; |
54 | 54 | m_tb_prefs.addObserver("extensions.torbutton", this);
|
55 | 55 | m_tb_prefs.addObserver("browser.privatebrowsing.autostart", this);
|
56 | 56 | m_tb_prefs.addObserver("_javascript_", this);
|
57 | - m_tb_prefs.addObserver("privacy.resistFingerprinting", this);
|
|
58 | - m_tb_prefs.addObserver("privacy.resistFingerprinting.letterboxing", this);
|
|
59 | 57 | },
|
60 | 58 | |
61 | 59 | unregister() {
|
62 | 60 | m_tb_prefs.removeObserver("extensions.torbutton", this);
|
63 | 61 | m_tb_prefs.removeObserver("browser.privatebrowsing.autostart", this);
|
64 | 62 | m_tb_prefs.removeObserver("_javascript_", this);
|
65 | - m_tb_prefs.removeObserver("privacy.resistFingerprinting", this);
|
|
66 | - m_tb_prefs.removeObserver(
|
|
67 | - "privacy.resistFingerprinting.letterboxing",
|
|
68 | - this
|
|
69 | - );
|
|
70 | 63 | },
|
71 | 64 | |
72 | 65 | // topic: what event occurred
|
... | ... | @@ -83,10 +76,6 @@ var torbutton_new_circuit; |
83 | 76 | case "extensions.torbutton.use_nontor_proxy":
|
84 | 77 | torbutton_use_nontor_proxy();
|
85 | 78 | break;
|
86 | - case "privacy.resistFingerprinting":
|
|
87 | - case "privacy.resistFingerprinting.letterboxing":
|
|
88 | - torbutton_update_fingerprinting_prefs();
|
|
89 | - break;
|
|
90 | 79 | }
|
91 | 80 | },
|
92 | 81 | };
|
... | ... | @@ -666,21 +655,6 @@ var torbutton_new_circuit; |
666 | 655 | Services.prefs.savePrefFile(null);
|
667 | 656 | }
|
668 | 657 | |
669 | - function torbutton_update_fingerprinting_prefs() {
|
|
670 | - var mode = m_tb_prefs.getBoolPref("privacy.resistFingerprinting");
|
|
671 | - var letterboxing = m_tb_prefs.getBoolPref(
|
|
672 | - "privacy.resistFingerprinting.letterboxing",
|
|
673 | - false
|
|
674 | - );
|
|
675 | - m_tb_prefs.setBoolPref(
|
|
676 | - "extensions.torbutton.resize_new_windows",
|
|
677 | - mode && !letterboxing
|
|
678 | - );
|
|
679 | - |
|
680 | - // Force prefs to be synced to disk
|
|
681 | - Services.prefs.savePrefFile(null);
|
|
682 | - }
|
|
683 | - |
|
684 | 658 | // Bug 1506 P1: This function just cleans up prefs that got set badly in previous releases
|
685 | 659 | function torbutton_fixup_old_prefs() {
|
686 | 660 | if (m_tb_prefs.getIntPref("extensions.torbutton.pref_fixup_version") < 1) {
|
... | ... | @@ -728,9 +702,6 @@ var torbutton_new_circuit; |
728 | 702 | // Bug 1506: Should probably be moved to an XPCOM component
|
729 | 703 | torbutton_do_main_window_startup();
|
730 | 704 | |
731 | - // For charsets
|
|
732 | - torbutton_update_fingerprinting_prefs();
|
|
733 | - |
|
734 | 705 | // Bug 30565: sync browser.privatebrowsing.autostart with security.nocertdb
|
735 | 706 | torbutton_update_disk_prefs();
|
736 | 707 | |
... | ... | @@ -741,46 +712,6 @@ var torbutton_new_circuit; |
741 | 712 | }
|
742 | 713 | }
|
743 | 714 | |
744 | - // Bug 1506 P3: Used to decide if we should resize the window.
|
|
745 | - //
|
|
746 | - // Returns true if the window wind is neither maximized, full screen,
|
|
747 | - // ratpoisioned/evilwmed, nor minimized.
|
|
748 | - function torbutton_is_windowed(wind) {
|
|
749 | - torbutton_log(
|
|
750 | - 3,
|
|
751 | - "Window: (" +
|
|
752 | - wind.outerWidth +
|
|
753 | - "," +
|
|
754 | - wind.outerHeight +
|
|
755 | - ") ?= (" +
|
|
756 | - wind.screen.availWidth +
|
|
757 | - "," +
|
|
758 | - wind.screen.availHeight +
|
|
759 | - ")"
|
|
760 | - );
|
|
761 | - if (
|
|
762 | - wind.windowState == Ci.nsIDOMChromeWindow.STATE_MINIMIZED ||
|
|
763 | - wind.windowState == Ci.nsIDOMChromeWindow.STATE_MAXIMIZED
|
|
764 | - ) {
|
|
765 | - torbutton_log(2, "Window is minimized/maximized");
|
|
766 | - return false;
|
|
767 | - }
|
|
768 | - if ("fullScreen" in wind && wind.fullScreen) {
|
|
769 | - torbutton_log(2, "Window is fullScreen");
|
|
770 | - return false;
|
|
771 | - }
|
|
772 | - if (
|
|
773 | - wind.outerHeight == wind.screen.availHeight &&
|
|
774 | - wind.outerWidth == wind.screen.availWidth
|
|
775 | - ) {
|
|
776 | - torbutton_log(3, "Window is ratpoisoned/evilwm'ed");
|
|
777 | - return false;
|
|
778 | - }
|
|
779 | - |
|
780 | - torbutton_log(2, "Window is normal");
|
|
781 | - return true;
|
|
782 | - }
|
|
783 | - |
|
784 | 715 | // Bug 1506 P3: This is needed pretty much only for the window resizing.
|
785 | 716 | // See comments for individual functions for details
|
786 | 717 | function torbutton_new_window(event) {
|
... | ... | @@ -797,17 +728,6 @@ var torbutton_new_circuit; |
797 | 728 | }
|
798 | 729 | |
799 | 730 | torbutton_do_startup();
|
800 | - |
|
801 | - let progress = Cc["@mozilla.org/docloaderservice;1"].getService(
|
|
802 | - Ci.nsIWebProgress
|
|
803 | - );
|
|
804 | - |
|
805 | - if (torbutton_is_windowed(window)) {
|
|
806 | - progress.addProgressListener(
|
|
807 | - torbutton_resizelistener,
|
|
808 | - Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT
|
|
809 | - );
|
|
810 | - }
|
|
811 | 731 | }
|
812 | 732 | |
813 | 733 | // Bug 1506 P2: This is only needed because we have observers
|
... | ... | @@ -815,8 +735,6 @@ var torbutton_new_circuit; |
815 | 735 | function torbutton_close_window(event) {
|
816 | 736 | torbutton_tor_check_observer.unregister();
|
817 | 737 | |
818 | - window.removeEventListener("sizemodechange", m_tb_resize_handler);
|
|
819 | - |
|
820 | 738 | // TODO: This is a real ghetto hack.. When the original window
|
821 | 739 | // closes, we need to find another window to handle observing
|
822 | 740 | // unique events... The right way to do this is to move the
|
... | ... | @@ -856,158 +774,4 @@ var torbutton_new_circuit; |
856 | 774 | |
857 | 775 | window.addEventListener("load", torbutton_new_window);
|
858 | 776 | window.addEventListener("unload", torbutton_close_window);
|
859 | - |
|
860 | - var m_tb_resize_handler = null;
|
|
861 | - var m_tb_resize_date = null;
|
|
862 | - |
|
863 | - // Bug 1506 P1/P3: Setting a fixed window size is important, but
|
|
864 | - // probably not for android.
|
|
865 | - var torbutton_resizelistener = {
|
|
866 | - QueryInterface: ChromeUtils.generateQI([
|
|
867 | - "nsIWebProgressListener",
|
|
868 | - "nsISupportsWeakReference",
|
|
869 | - ]),
|
|
870 | - |
|
871 | - onLocationChange(aProgress, aRequest, aURI) {},
|
|
872 | - onStateChange(aProgress, aRequest, aFlag, aStatus) {
|
|
873 | - if (aFlag & Ci.nsIWebProgressListener.STATE_STOP) {
|
|
874 | - window.promiseDocumentFlushed(() => {
|
|
875 | - // Here we're guaranteed to read the "final" (!) initial size, rather than [1, 1].
|
|
876 | - torbutton_resizelistener.originalSize = {
|
|
877 | - width: window.outerWidth,
|
|
878 | - height: window.outerHeight,
|
|
879 | - };
|
|
880 | - });
|
|
881 | - m_tb_resize_handler = async function() {
|
|
882 | - // Wait for end of execution queue to ensure we have correct windowState.
|
|
883 | - await new Promise(resolve => setTimeout(resolve, 0));
|
|
884 | - if (
|
|
885 | - window.windowState === window.STATE_MAXIMIZED ||
|
|
886 | - window.windowState === window.STATE_FULLSCREEN
|
|
887 | - ) {
|
|
888 | - const kRemainingWarnings =
|
|
889 | - "extensions.torbutton.maximize_warnings_remaining";
|
|
890 | - if (
|
|
891 | - Services.prefs.getBoolPref(
|
|
892 | - "extensions.torbutton.resize_new_windows"
|
|
893 | - ) &&
|
|
894 | - Services.prefs.getIntPref(kRemainingWarnings) > 0
|
|
895 | - ) {
|
|
896 | - // Do not add another notification if one is already showing.
|
|
897 | - const kNotificationName = "torbutton-maximize-notification";
|
|
898 | - |
|
899 | - const box = gNotificationBox;
|
|
900 | - if (box.getNotificationWithValue(kNotificationName)) {
|
|
901 | - return;
|
|
902 | - }
|
|
903 | - |
|
904 | - // Rate-limit showing our notification if needed.
|
|
905 | - if (m_tb_resize_date === null) {
|
|
906 | - m_tb_resize_date = Date.now();
|
|
907 | - } else {
|
|
908 | - // We wait at least another second before we show a new
|
|
909 | - // notification. Should be enough to rule out OSes that call our
|
|
910 | - // handler rapidly due to internal workings.
|
|
911 | - if (Date.now() - m_tb_resize_date < 1000) {
|
|
912 | - return;
|
|
913 | - }
|
|
914 | - // Resizing but we need to reset |m_tb_resize_date| now.
|
|
915 | - m_tb_resize_date = Date.now();
|
|
916 | - }
|
|
917 | - |
|
918 | - // No need to get "OK" translated again.
|
|
919 | - const bundle = Services.strings.createBundle(
|
|
920 | - "chrome://global/locale/commonDialogs.properties"
|
|
921 | - );
|
|
922 | - |
|
923 | - const decreaseWarningsCount = () => {
|
|
924 | - const currentCount = Services.prefs.getIntPref(
|
|
925 | - kRemainingWarnings
|
|
926 | - );
|
|
927 | - if (currentCount > 0) {
|
|
928 | - Services.prefs.setIntPref(
|
|
929 | - kRemainingWarnings,
|
|
930 | - currentCount - 1
|
|
931 | - );
|
|
932 | - }
|
|
933 | - };
|
|
934 | - |
|
935 | - let buttons = [
|
|
936 | - {
|
|
937 | - label: bundle.GetStringFromName("OK"),
|
|
938 | - accessKey: "O",
|
|
939 | - popup: null,
|
|
940 | - callback() {
|
|
941 | - // reset notification timer to work-around resize race conditions
|
|
942 | - m_tb_resize_date = Date.now();
|
|
943 | - // restore the original (rounded) size we had stored on window startup
|
|
944 | - let { originalSize } = torbutton_resizelistener;
|
|
945 | - window.resizeTo(originalSize.width, originalSize.height);
|
|
946 | - },
|
|
947 | - },
|
|
948 | - ];
|
|
949 | - |
|
950 | - const label = torbutton_get_property_string(
|
|
951 | - "torbutton.maximize_warning"
|
|
952 | - );
|
|
953 | - |
|
954 | - box.appendNotification(
|
|
955 | - kNotificationName,
|
|
956 | - {
|
|
957 | - label,
|
|
958 | - priority: box.PRIORITY_WARNING_LOW,
|
|
959 | - eventCallback(event) {
|
|
960 | - if (event === "dismissed") {
|
|
961 | - // user manually dismissed the notification
|
|
962 | - decreaseWarningsCount();
|
|
963 | - }
|
|
964 | - },
|
|
965 | - },
|
|
966 | - buttons
|
|
967 | - );
|
|
968 | - }
|
|
969 | - }
|
|
970 | - }; // m_tb_resize_handler
|
|
971 | - |
|
972 | - // We need to handle OSes that auto-maximize windows depending on user
|
|
973 | - // settings and/or screen resolution in the start-up phase and users that
|
|
974 | - // try to shoot themselves in the foot by maximizing the window manually.
|
|
975 | - // We add a listener which is triggerred as soon as the window gets
|
|
976 | - // maximized (windowState = 1). We are resizing during start-up but not
|
|
977 | - // later as the user should see only a warning there as a stopgap before
|
|
978 | - // #14229 lands.
|
|
979 | - // Alas, the Firefox window code is handling the event not itself:
|
|
980 | - // "// Note the current implementation of SetSizeMode just stores
|
|
981 | - // // the new state; it doesn't actually resize. So here we store
|
|
982 | - // // the state and pass the event on to the OS."
|
|
983 | - // (See: https://mxr.mozilla.org/mozilla-esr31/source/xpfe/appshell/src/
|
|
984 | - // nsWebShellWindow.cpp#348)
|
|
985 | - // This means we have to cope with race conditions and resizing in the
|
|
986 | - // sizemodechange listener is likely to fail. Thus, we add a specific
|
|
987 | - // resize listener that is doing the work for us. It seems (at least on
|
|
988 | - // Ubuntu) to be the case that maximizing (and then again normalizing) of
|
|
989 | - // the window triggers more than one resize event the first being not the
|
|
990 | - // one we need. Thus we can't remove the listener after the first resize
|
|
991 | - // event got fired. Thus, we have the rather klunky setTimeout() call.
|
|
992 | - window.addEventListener("sizemodechange", m_tb_resize_handler);
|
|
993 | - |
|
994 | - let progress = Cc["@mozilla.org/docloaderservice;1"].getService(
|
|
995 | - Ci.nsIWebProgress
|
|
996 | - );
|
|
997 | - progress.removeProgressListener(this);
|
|
998 | - }
|
|
999 | - }, // onStateChange
|
|
1000 | - |
|
1001 | - onProgressChange(
|
|
1002 | - aProgress,
|
|
1003 | - aRequest,
|
|
1004 | - curSelfProgress,
|
|
1005 | - maxSelfProgress,
|
|
1006 | - curTotalProgress,
|
|
1007 | - maxTotalProgress
|
|
1008 | - ) {},
|
|
1009 | - onStatusChange(aProgress, aRequest, stat, message) {},
|
|
1010 | - onSecurityChange() {},
|
|
1011 | - };
|
|
1012 | 777 | })(); |
1013 | -//vim:set ts=4 |
... | ... | @@ -115,6 +115,3 @@ torbutton.popup.no_newnym = Torbutton cannot safely give you a new identity. It |
115 | 115 | # Preferences for mobile: these strings are still referenced, but we should
|
116 | 116 | # check whether this feature is still used
|
117 | 117 | torbutton.security_settings.menu.title = Security Settings |
118 | - |
|
119 | -# Other legacy stuff we might just remove since we are using letterbox
|
|
120 | -torbutton.maximize_warning = Maximizing Tor Browser can allow websites to determine your monitor size, which can be used to track you. We recommend that you leave Tor Browser windows in their original default size. |