1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/* import-globals-from extensionControlled.js */
/* import-globals-from preferences.js */
const PREF_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled";
const TRACKING_PROTECTION_KEY = "websites.trackingProtectionMode";
const TRACKING_PROTECTION_PREFS = [
"privacy.trackingprotection.enabled",
"privacy.trackingprotection.pbmode.enabled",
];
const CONTENT_BLOCKING_PREFS = [
"privacy.trackingprotection.enabled",
"privacy.trackingprotection.pbmode.enabled",
"network.cookie.cookieBehavior",
"privacy.trackingprotection.fingerprinting.enabled",
"privacy.trackingprotection.cryptomining.enabled",
"privacy.firstparty.isolate",
"privacy.trackingprotection.emailtracking.enabled",
"privacy.trackingprotection.emailtracking.pbmode.enabled",
"privacy.fingerprintingProtection",
"privacy.fingerprintingProtection.pbmode",
];
const PREF_OPT_OUT_STUDIES_ENABLED = "app.shield.optoutstudies.enabled";
const PREF_NORMANDY_ENABLED = "app.normandy.enabled";
const PREF_ADDON_RECOMMENDATIONS_ENABLED = "browser.discovery.enabled";
const PREF_PRIVATE_ATTRIBUTION_ENABLED =
"dom.private-attribution.submission.enabled";
const PREF_PASSWORD_GENERATION_AVAILABLE = "signon.generation.available";
const { BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN } = Ci.nsICookieService;
const PASSWORD_MANAGER_PREF_ID = "services.passwordSavingEnabled";
ChromeUtils.defineLazyGetter(this, "AlertsServiceDND", function () {
try {
let alertsService = Cc["@mozilla.org/alerts-service;1"]
.getService(Ci.nsIAlertsService)
.QueryInterface(Ci.nsIAlertsDoNotDisturb);
// This will throw if manualDoNotDisturb isn't implemented.
alertsService.manualDoNotDisturb;
return alertsService;
} catch (ex) {
return undefined;
}
});
ChromeUtils.defineLazyGetter(lazy, "AboutLoginsL10n", () => {
return new Localization(["branding/brand.ftl", "browser/aboutLogins.ftl"]);
});
ChromeUtils.defineLazyGetter(lazy, "gParentalControlsService", () =>
"@mozilla.org/parental-controls-service;1" in Cc
? Cc["@mozilla.org/parental-controls-service;1"].getService(
Ci.nsIParentalControlsService
)
: null
);
XPCOMUtils.defineLazyPreferenceGetter(
this,
"gIsFirstPartyIsolated",
"privacy.firstparty.isolate",
false
);
XPCOMUtils.defineLazyPreferenceGetter(
this,
"useOldClearHistoryDialog",
"privacy.sanitize.useOldClearHistoryDialog",
false
);
ChromeUtils.defineESModuleGetters(this, {
DoHConfigController: "moz-src:///toolkit/components/doh/DoHConfig.sys.mjs",
Sanitizer: "resource:///modules/Sanitizer.sys.mjs",
SelectableProfileService:
"resource:///modules/profiles/SelectableProfileService.sys.mjs",
});
const SANITIZE_ON_SHUTDOWN_MAPPINGS = {
history: "privacy.clearOnShutdown.history",
downloads: "privacy.clearOnShutdown.downloads",
formdata: "privacy.clearOnShutdown.formdata",
sessions: "privacy.clearOnShutdown.sessions",
siteSettings: "privacy.clearOnShutdown.siteSettings",
cookies: "privacy.clearOnShutdown.cookies",
cache: "privacy.clearOnShutdown.cache",
offlineApps: "privacy.clearOnShutdown.offlineApps",
};
/*
* Prefs that are unique to sanitizeOnShutdown and are not shared
* with the deleteOnClose mechanism like privacy.clearOnShutdown.cookies, -cache and -offlineApps
*/
const SANITIZE_ON_SHUTDOWN_PREFS_ONLY = [
"privacy.clearOnShutdown.history",
"privacy.clearOnShutdown.downloads",
"privacy.clearOnShutdown.sessions",
"privacy.clearOnShutdown.formdata",
"privacy.clearOnShutdown.siteSettings",
];
const SANITIZE_ON_SHUTDOWN_PREFS_ONLY_V2 = [
"privacy.clearOnShutdown_v2.browsingHistoryAndDownloads",
"privacy.clearOnShutdown_v2.siteSettings",
];
Preferences.addAll([
// Content blocking / Tracking Protection
{ id: "privacy.trackingprotection.enabled", type: "bool" },
{ id: "privacy.trackingprotection.pbmode.enabled", type: "bool" },
{ id: "privacy.trackingprotection.fingerprinting.enabled", type: "bool" },
{ id: "privacy.trackingprotection.cryptomining.enabled", type: "bool" },
{ id: "privacy.trackingprotection.emailtracking.enabled", type: "bool" },
{
id: "privacy.trackingprotection.emailtracking.pbmode.enabled",
type: "bool",
},
// Fingerprinting Protection
{ id: "privacy.fingerprintingProtection", type: "bool" },
{ id: "privacy.fingerprintingProtection.pbmode", type: "bool" },
// Resist Fingerprinting
{ id: "privacy.resistFingerprinting", type: "bool" },
{ id: "privacy.resistFingerprinting.pbmode", type: "bool" },
// Social tracking
{ id: "privacy.trackingprotection.socialtracking.enabled", type: "bool" },
{ id: "privacy.socialtracking.block_cookies.enabled", type: "bool" },
// Tracker list
{ id: "urlclassifier.trackingTable", type: "string" },
// Button prefs
{ id: "pref.privacy.disable_button.cookie_exceptions", type: "bool" },
{
id: "pref.privacy.disable_button.tracking_protection_exceptions",
type: "bool",
},
// Location Bar
{ id: "browser.urlbar.suggest.bookmark", type: "bool" },
{ id: "browser.urlbar.suggest.clipboard", type: "bool" },
{ id: "browser.urlbar.suggest.history", type: "bool" },
{ id: "browser.urlbar.suggest.openpage", type: "bool" },
{ id: "browser.urlbar.suggest.topsites", type: "bool" },
{ id: "browser.urlbar.suggest.engines", type: "bool" },
{ id: "browser.urlbar.suggest.quicksuggest.nonsponsored", type: "bool" },
{ id: "browser.urlbar.suggest.quicksuggest.sponsored", type: "bool" },
{ id: "browser.urlbar.quicksuggest.dataCollection.enabled", type: "bool" },
// History
{ id: "places.history.enabled", type: "bool" },
{ id: "browser.formfill.enable", type: "bool" },
{ id: "privacy.history.custom", type: "bool" },
// Cookies
{ id: "network.cookie.cookieBehavior", type: "int" },
{ id: "network.cookie.blockFutureCookies", type: "bool" },
// Content blocking category
{ id: "browser.contentblocking.category", type: "string" },
{ id: "browser.contentblocking.features.strict", type: "string" },
// Clear Private Data
{ id: "privacy.sanitize.sanitizeOnShutdown", type: "bool" },
{ id: "privacy.sanitize.timeSpan", type: "int" },
{ id: "privacy.clearOnShutdown.cookies", type: "bool" },
{ id: "privacy.clearOnShutdown_v2.cookiesAndStorage", type: "bool" },
{ id: "privacy.clearOnShutdown.cache", type: "bool" },
{ id: "privacy.clearOnShutdown_v2.cache", type: "bool" },
{ id: "privacy.clearOnShutdown.offlineApps", type: "bool" },
{ id: "privacy.clearOnShutdown.history", type: "bool" },
{
id: "privacy.clearOnShutdown_v2.browsingHistoryAndDownloads",
type: "bool",
},
{ id: "privacy.clearOnShutdown.downloads", type: "bool" },
{ id: "privacy.clearOnShutdown.sessions", type: "bool" },
{ id: "privacy.clearOnShutdown.formdata", type: "bool" },
{ id: "privacy.clearOnShutdown.siteSettings", type: "bool" },
{ id: "privacy.clearOnShutdown_v2.siteSettings", type: "bool" },
// Do not track
{ id: "privacy.donottrackheader.enabled", type: "bool" },
// Global Privacy Control
{ id: "privacy.globalprivacycontrol.enabled", type: "bool" },
// Media
{ id: "media.autoplay.default", type: "int" },
// Popups
{ id: "dom.disable_open_during_load", type: "bool" },
// Passwords
{ id: "signon.rememberSignons", type: "bool" },
{ id: "signon.generation.enabled", type: "bool" },
{ id: "signon.autofillForms", type: "bool" },
{ id: "signon.management.page.breach-alerts.enabled", type: "bool" },
{ id: "signon.firefoxRelay.feature", type: "string" },
// Buttons
{ id: "pref.privacy.disable_button.view_passwords", type: "bool" },
{ id: "pref.privacy.disable_button.view_passwords_exceptions", type: "bool" },
/* Certificates tab
* security.default_personal_cert
* - a string:
* "Select Automatically" select a certificate automatically when a site
* requests one
* "Ask Every Time" present a dialog to the user so he can select
* the certificate to use on a site which
* requests one
*/
{ id: "security.default_personal_cert", type: "string" },
{ id: "security.disable_button.openCertManager", type: "bool" },
{ id: "security.disable_button.openDeviceManager", type: "bool" },
{ id: "security.OCSP.enabled", type: "int" },
{ id: "security.enterprise_roots.enabled", type: "bool" },
// Add-ons, malware, phishing
{ id: "xpinstall.whitelist.required", type: "bool" },
{ id: "browser.safebrowsing.malware.enabled", type: "bool" },
{ id: "browser.safebrowsing.phishing.enabled", type: "bool" },
{ id: "browser.safebrowsing.downloads.enabled", type: "bool" },
{ id: "urlclassifier.malwareTable", type: "string" },
{
id: "browser.safebrowsing.downloads.remote.block_potentially_unwanted",
type: "bool",
},
{ id: "browser.safebrowsing.downloads.remote.block_uncommon", type: "bool" },
// First-Party Isolation
{ id: "privacy.firstparty.isolate", type: "bool" },
// HTTPS-Only
{ id: "dom.security.https_only_mode", type: "bool" },
{ id: "dom.security.https_only_mode_pbm", type: "bool" },
{ id: "dom.security.https_first", type: "bool" },
{ id: "dom.security.https_first_pbm", type: "bool" },
// Windows SSO
{ id: "network.http.windows-sso.enabled", type: "bool" },
// Quick Actions
{ id: "browser.urlbar.quickactions.showPrefs", type: "bool" },
{ id: "browser.urlbar.suggest.quickactions", type: "bool" },
// Cookie Banner Handling
{ id: "cookiebanners.ui.desktop.enabled", type: "bool" },
{ id: "cookiebanners.service.mode.privateBrowsing", type: "int" },
// DoH
{ id: "network.trr.mode", type: "int" },
{ id: "network.trr.uri", type: "string" },
{ id: "network.trr.default_provider_uri", type: "string" },
{ id: "network.trr.custom_uri", type: "string" },
{ id: "doh-rollout.disable-heuristics", type: "bool" },
]);
// Study opt out
if (AppConstants.MOZ_DATA_REPORTING) {
Preferences.addAll([
// Preference instances for prefs that we need to monitor while the page is open.
{ id: PREF_OPT_OUT_STUDIES_ENABLED, type: "bool" },
{ id: PREF_ADDON_RECOMMENDATIONS_ENABLED, type: "bool" },
{ id: PREF_UPLOAD_ENABLED, type: "bool" },
{ id: "datareporting.usage.uploadEnabled", type: "bool" },
{ id: "dom.private-attribution.submission.enabled", type: "bool" },
]);
}
// Privacy segmentation section
Preferences.add({
id: "browser.dataFeatureRecommendations.enabled",
type: "bool",
});
// Data Choices tab
if (AppConstants.MOZ_CRASHREPORTER) {
Preferences.add({
id: "browser.crashReports.unsubmittedCheck.autoSubmit2",
type: "bool",
});
}
function setEventListener(aId, aEventType, aCallback) {
document
.getElementById(aId)
.addEventListener(aEventType, aCallback.bind(gPrivacyPane));
}
function setSyncFromPrefListener(aId, aCallback) {
Preferences.addSyncFromPrefListener(document.getElementById(aId), aCallback);
}
function setSyncToPrefListener(aId, aCallback) {
Preferences.addSyncToPrefListener(document.getElementById(aId), aCallback);
}
function dataCollectionCheckboxHandler({
checkbox,
pref,
matchPref = () => true,
isDisabled = () => false,
}) {
function updateCheckbox() {
let collectionEnabled = Services.prefs.getBoolPref(
PREF_UPLOAD_ENABLED,
false
);
if (collectionEnabled && matchPref()) {
if (Services.prefs.getBoolPref(pref, false)) {
checkbox.setAttribute("checked", "true");
} else {
checkbox.removeAttribute("checked");
}
checkbox.setAttribute("preference", pref);
} else {
checkbox.removeAttribute("preference");
checkbox.removeAttribute("checked");
}
checkbox.disabled =
!collectionEnabled || Services.prefs.prefIsLocked(pref) || isDisabled();
}
Preferences.get(PREF_UPLOAD_ENABLED).on("change", updateCheckbox);
updateCheckbox();
}
// Sets the "Learn how" SUMO link in the Strict/Custom options of Content Blocking.
function setUpContentBlockingWarnings() {
document.getElementById("fpiIncompatibilityWarning").hidden =
!gIsFirstPartyIsolated;
document.getElementById("rfpIncompatibilityWarning").hidden =
!Preferences.get("privacy.resistFingerprinting").value &&
!Preferences.get("privacy.resistFingerprinting.pbmode").value;
}
function initTCPStandardSection() {
let cookieBehaviorPref = Preferences.get("network.cookie.cookieBehavior");
let updateTCPSectionVisibilityState = () => {
document.getElementById("etpStandardTCPBox").hidden =
cookieBehaviorPref.value !=
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN;
};
cookieBehaviorPref.on("change", updateTCPSectionVisibilityState);
updateTCPSectionVisibilityState();
}
var gPrivacyPane = {
_pane: null,
/**
* Whether the prompt to restart Firefox should appear when changing the autostart pref.
*/
_shouldPromptForRestart: true,
/**
* Update the tracking protection UI to deal with extension control.
*/
_updateTrackingProtectionUI() {
let cBPrefisLocked = CONTENT_BLOCKING_PREFS.some(pref =>
Services.prefs.prefIsLocked(pref)
);
let tPPrefisLocked = TRACKING_PROTECTION_PREFS.some(pref =>
Services.prefs.prefIsLocked(pref)
);
function setInputsDisabledState(isControlled) {
let tpDisabled = tPPrefisLocked || isControlled;
let disabled = cBPrefisLocked || isControlled;
let tpCheckbox = document.getElementById(
"contentBlockingTrackingProtectionCheckbox"
);
// Only enable the TP menu if Detect All Trackers is enabled.
document.getElementById("trackingProtectionMenu").disabled =
tpDisabled || !tpCheckbox.checked;
tpCheckbox.disabled = tpDisabled;
document.getElementById("standardRadio").disabled = disabled;
document.getElementById("strictRadio").disabled = disabled;
document
.getElementById("contentBlockingOptionStrict")
.classList.toggle("disabled", disabled);
document
.getElementById("contentBlockingOptionStandard")
.classList.toggle("disabled", disabled);
let arrowButtons = document.querySelectorAll("button.arrowhead");
for (let button of arrowButtons) {
button.disabled = disabled;
}
// Notify observers that the TP UI has been updated.
// This is needed since our tests need to be notified about the
// trackingProtectionMenu element getting disabled/enabled at the right time.
Services.obs.notifyObservers(window, "privacy-pane-tp-ui-updated");
}
let policy = Services.policies.getActivePolicies();
if (
policy &&
((policy.EnableTrackingProtection &&
policy.EnableTrackingProtection.Locked) ||
(policy.Cookies && policy.Cookies.Locked))
) {
setInputsDisabledState(true);
}
if (tPPrefisLocked) {
// An extension can't control this setting if either pref is locked.
hideControllingExtension(TRACKING_PROTECTION_KEY);
setInputsDisabledState(false);
} else {
handleControllingExtension(
PREF_SETTING_TYPE,
TRACKING_PROTECTION_KEY
).then(setInputsDisabledState);
}
},
/**
* Set up handlers for showing and hiding controlling extension info
* for tracking protection.
*/
_initTrackingProtectionExtensionControl() {
setEventListener(
"contentBlockingDisableTrackingProtectionExtension",
"command",
makeDisableControllingExtension(
PREF_SETTING_TYPE,
TRACKING_PROTECTION_KEY
)
);
let trackingProtectionObserver = {
observe() {
gPrivacyPane._updateTrackingProtectionUI();
},
};
for (let pref of TRACKING_PROTECTION_PREFS) {
Services.prefs.addObserver(pref, trackingProtectionObserver);
}
window.addEventListener("unload", () => {
for (let pref of TRACKING_PROTECTION_PREFS) {
Services.prefs.removeObserver(pref, trackingProtectionObserver);
}
});
},
_initThirdPartyCertsToggle() {
// Third-party certificate import is only implemented for Windows and Mac,
// and we should not expose this as a user-configurable setting if there's
// an enterprise policy controlling it (either to enable _or_ disable it).
let canConfigureThirdPartyCerts =
(AppConstants.platform == "win" || AppConstants.platform == "macosx") &&
typeof Services.policies.getActivePolicies()?.Certificates
?.ImportEnterpriseRoots == "undefined";
document.getElementById("certEnableThirdPartyToggleBox").hidden =
!canConfigureThirdPartyCerts;
},
syncFromHttpsOnlyPref() {
let httpsOnlyOnPref = Services.prefs.getBoolPref(
"dom.security.https_only_mode"
);
let httpsOnlyOnPBMPref = Services.prefs.getBoolPref(
"dom.security.https_only_mode_pbm"
);
let httpsFirstOnPref = Services.prefs.getBoolPref(
"dom.security.https_first"
);
let httpsFirstOnPBMPref = Services.prefs.getBoolPref(
"dom.security.https_first_pbm"
);
let httpsOnlyRadioGroup = document.getElementById("httpsOnlyRadioGroup");
let httpsOnlyExceptionButton = document.getElementById(
"httpsOnlyExceptionButton"
);
if (httpsOnlyOnPref) {
httpsOnlyRadioGroup.value = "enabled";
} else if (httpsOnlyOnPBMPref) {
httpsOnlyRadioGroup.value = "privateOnly";
} else {
httpsOnlyRadioGroup.value = "disabled";
}
httpsOnlyExceptionButton.disabled =
!httpsOnlyOnPref &&
!httpsFirstOnPref &&
!httpsOnlyOnPBMPref &&
!httpsFirstOnPBMPref;
if (
Services.prefs.prefIsLocked("dom.security.https_only_mode") ||
Services.prefs.prefIsLocked("dom.security.https_only_mode_pbm")
) {
httpsOnlyRadioGroup.disabled = true;
}
},
syncToHttpsOnlyPref() {
let value = document.getElementById("httpsOnlyRadioGroup").value;
Services.prefs.setBoolPref(
"dom.security.https_only_mode_pbm",
value == "privateOnly"
);
Services.prefs.setBoolPref(
"dom.security.https_only_mode",
value == "enabled"
);
},
/**
* Init HTTPS-Only mode and corresponding prefs
*/
initHttpsOnly() {
// Set radio-value based on the pref value
this.syncFromHttpsOnlyPref();
// Create event listener for when the user clicks
// on one of the radio buttons
setEventListener("httpsOnlyRadioGroup", "change", this.syncToHttpsOnlyPref);
// Update radio-value when the pref changes
Preferences.get("dom.security.https_only_mode").on("change", () =>
this.syncFromHttpsOnlyPref()
);
Preferences.get("dom.security.https_only_mode_pbm").on("change", () =>
this.syncFromHttpsOnlyPref()
);
Preferences.get("dom.security.https_first").on("change", () =>
this.syncFromHttpsOnlyPref()
);
Preferences.get("dom.security.https_first_pbm").on("change", () =>
this.syncFromHttpsOnlyPref()
);
},
get dnsOverHttpsResolvers() {
let providers = DoHConfigController.currentConfig.providerList;
// if there's no default, we'll hold its position with an empty string
let defaultURI = DoHConfigController.currentConfig.fallbackProviderURI;
let defaultIndex = providers.findIndex(p => p.uri == defaultURI);
if (defaultIndex == -1 && defaultURI) {
// the default value for the pref isn't included in the resolvers list
// so we'll make a stub for it. Without an id, we'll have to use the url as the label
providers.unshift({ uri: defaultURI });
}
return providers;
},
updateDoHResolverList(mode) {
let resolvers = this.dnsOverHttpsResolvers;
let currentURI = Preferences.get("network.trr.uri").value;
if (!currentURI) {
currentURI = Preferences.get("network.trr.default_provider_uri").value;
}
let menu = document.getElementById(`${mode}ResolverChoices`);
let selectedIndex = currentURI
? resolvers.findIndex(r => r.uri == currentURI)
: 0;
if (selectedIndex == -1) {
// select the last "Custom" item
selectedIndex = menu.itemCount - 1;
}
menu.selectedIndex = selectedIndex;
let customInput = document.getElementById(`${mode}InputField`);
customInput.hidden = menu.value != "custom";
},
populateDoHResolverList(mode) {
let resolvers = this.dnsOverHttpsResolvers;
let defaultURI = DoHConfigController.currentConfig.fallbackProviderURI;
let menu = document.getElementById(`${mode}ResolverChoices`);
// populate the DNS-Over-HTTPS resolver list
menu.removeAllItems();
for (let resolver of resolvers) {
let item = menu.appendItem(undefined, resolver.uri);
if (resolver.uri == defaultURI) {
document.l10n.setAttributes(
item,
"connection-dns-over-https-url-item-default",
{
name: resolver.UIName || resolver.uri,
}
);
} else {
item.label = resolver.UIName || resolver.uri;
}
}
let lastItem = menu.appendItem(undefined, "custom");
document.l10n.setAttributes(
lastItem,
"connection-dns-over-https-url-custom"
);
// set initial selection in the resolver provider picker
this.updateDoHResolverList(mode);
let customInput = document.getElementById(`${mode}InputField`);
function updateURIPref() {
if (customInput.value == "") {
// Setting the pref to empty string will make it have the default
// pref value which makes us fallback to using the default TRR
// resolver in network.trr.default_provider_uri.
// If the input is empty we set it to "(space)" which is essentially
// the same.
Services.prefs.setStringPref("network.trr.uri", " ");
} else {
Services.prefs.setStringPref("network.trr.uri", customInput.value);
}
}
menu.addEventListener("command", () => {
if (menu.value == "custom") {
customInput.hidden = false;
updateURIPref();
} else {
customInput.hidden = true;
Services.prefs.setStringPref("network.trr.uri", menu.value);
}
Glean.securityDohSettings.providerChoiceValue.record({
value: menu.value,
});
// Update other menu too.
let otherMode = mode == "dohEnabled" ? "dohStrict" : "dohEnabled";
let otherMenu = document.getElementById(`${otherMode}ResolverChoices`);
let otherInput = document.getElementById(`${otherMode}InputField`);
otherMenu.value = menu.value;
otherInput.hidden = otherMenu.value != "custom";
});
// Change the URL when you press ENTER in the input field it or loses focus
customInput.addEventListener("change", () => {
updateURIPref();
});
},
async updateDoHStatus() {
let trrURI = Services.dns.currentTrrURI;
let hostname = URL.parse(trrURI)?.hostname;
if (!hostname) {
hostname = await document.l10n.formatValue("preferences-doh-bad-url");
}
let steering = document.getElementById("dohSteeringStatus");
steering.hidden = true;
let dohResolver = document.getElementById("dohResolver");
dohResolver.hidden = true;
let status = document.getElementById("dohStatus");
async function setStatus(localizedStringName, options) {
let opts = options || {};
let statusString = await document.l10n.formatValue(
localizedStringName,
opts
);
document.l10n.setAttributes(status, "preferences-doh-status", {
status: statusString,
});
}
function computeStatus() {
let mode = Services.dns.currentTrrMode;
if (
mode == Ci.nsIDNSService.MODE_TRRFIRST ||
mode == Ci.nsIDNSService.MODE_TRRONLY
) {
if (lazy.gParentalControlsService?.parentalControlsEnabled) {
return "preferences-doh-status-not-active";
}
let confirmationState = Services.dns.currentTrrConfirmationState;
switch (confirmationState) {
case Ci.nsIDNSService.CONFIRM_TRYING_OK:
case Ci.nsIDNSService.CONFIRM_OK:
case Ci.nsIDNSService.CONFIRM_DISABLED:
return "preferences-doh-status-active";
default:
return "preferences-doh-status-not-active";
}
}
return "preferences-doh-status-disabled";
}
let errReason = "";
let confirmationStatus = Services.dns.lastConfirmationStatus;
let mode = Services.dns.currentTrrMode;
if (
(mode == Ci.nsIDNSService.MODE_TRRFIRST ||
mode == Ci.nsIDNSService.MODE_TRRONLY) &&
lazy.gParentalControlsService?.parentalControlsEnabled
) {
errReason = Services.dns.getTRRSkipReasonName(
Ci.nsITRRSkipReason.TRR_PARENTAL_CONTROL
);
} else if (confirmationStatus != Cr.NS_OK) {
errReason = ChromeUtils.getXPCOMErrorName(confirmationStatus);
} else {
errReason = Services.dns.getTRRSkipReasonName(
Services.dns.lastConfirmationSkipReason
);
}
let statusLabel = computeStatus();
// setStatus will format and set the statusLabel asynchronously.
setStatus(statusLabel, { reason: errReason });
dohResolver.hidden = statusLabel == "preferences-doh-status-disabled";
let statusLearnMore = document.getElementById("dohStatusLearnMore");
statusLearnMore.hidden = statusLabel != "preferences-doh-status-not-active";
// No need to set the resolver name since we're not going to show it.
if (statusLabel == "preferences-doh-status-disabled") {
return;
}
function nameOrDomain() {
for (let resolver of DoHConfigController.currentConfig.providerList) {
if (resolver.uri == trrURI) {
return resolver.UIName || hostname || trrURI;
}
}
// Also check if this is a steering provider.
for (let resolver of DoHConfigController.currentConfig.providerSteering
.providerList) {
if (resolver.uri == trrURI) {
steering.hidden = false;
return resolver.UIName || hostname || trrURI;
}
}
return hostname;
}
let resolverNameOrDomain = nameOrDomain();
document.l10n.setAttributes(dohResolver, "preferences-doh-resolver", {
name: resolverNameOrDomain,
});
},
highlightDoHCategoryAndUpdateStatus() {
let value = Preferences.get("network.trr.mode").value;
let defaultOption = document.getElementById("dohOptionDefault");
let enabledOption = document.getElementById("dohOptionEnabled");
let strictOption = document.getElementById("dohOptionStrict");
let offOption = document.getElementById("dohOptionOff");
defaultOption.classList.remove("selected");
enabledOption.classList.remove("selected");
strictOption.classList.remove("selected");
offOption.classList.remove("selected");
switch (value) {
case Ci.nsIDNSService.MODE_NATIVEONLY:
defaultOption.classList.add("selected");
break;
case Ci.nsIDNSService.MODE_TRRFIRST:
enabledOption.classList.add("selected");
break;
case Ci.nsIDNSService.MODE_TRRONLY:
strictOption.classList.add("selected");
break;
case Ci.nsIDNSService.MODE_TRROFF:
offOption.classList.add("selected");
break;
default:
// The pref is set to a random value.
// This shouldn't happen, but let's make sure off is selected.
offOption.classList.add("selected");
document.getElementById("dohCategoryRadioGroup").selectedIndex = 3;
break;
}
// When the mode is set to 0 we need to clear the URI so
// doh-rollout can kick in.
if (value == Ci.nsIDNSService.MODE_NATIVEONLY) {
Services.prefs.clearUserPref("network.trr.uri");
Services.prefs.clearUserPref("doh-rollout.disable-heuristics");
}
// Bug 1861285
// When the mode is set to 2 or 3, we need to check if network.trr.uri is a empty string.
// In this case, we need to update network.trr.uri to default to fallbackProviderURI.
// This occurs when the mode is previously set to 0 (Default Protection).
if (
value == Ci.nsIDNSService.MODE_TRRFIRST ||
value == Ci.nsIDNSService.MODE_TRRONLY
) {
if (!Services.prefs.getStringPref("network.trr.uri")) {
Services.prefs.setStringPref(
"network.trr.uri",
DoHConfigController.currentConfig.fallbackProviderURI
);
}
}
// Bug 1900672
// When the mode is set to 5, clear the pref to ensure that
// network.trr.uri is set to fallbackProviderURIwhen the mode is set to 2 or 3 afterwards
if (value == Ci.nsIDNSService.MODE_TRROFF) {
Services.prefs.clearUserPref("network.trr.uri");
}
gPrivacyPane.updateDoHStatus();
},
/**
* Init DoH corresponding prefs
*/
initDoH() {
setEventListener("dohDefaultArrow", "command", this.toggleExpansion);
setEventListener("dohEnabledArrow", "command", this.toggleExpansion);
setEventListener("dohStrictArrow", "command", this.toggleExpansion);
function modeButtonPressed(e) {
// Clicking the active mode again should not generate another event
if (
parseInt(e.target.value) == Preferences.get("network.trr.mode").value
) {
return;
}
Glean.securityDohSettings.modeChangedButton.record({
value: e.target.id,
});
}
setEventListener("dohDefaultRadio", "command", modeButtonPressed);
setEventListener("dohEnabledRadio", "command", modeButtonPressed);
setEventListener("dohStrictRadio", "command", modeButtonPressed);
setEventListener("dohOffRadio", "command", modeButtonPressed);
this.populateDoHResolverList("dohEnabled");
this.populateDoHResolverList("dohStrict");
Preferences.get("network.trr.uri").on("change", () => {
gPrivacyPane.updateDoHResolverList("dohEnabled");
gPrivacyPane.updateDoHResolverList("dohStrict");
gPrivacyPane.updateDoHStatus();
});
// Update status box and hightlightling when the pref changes
Preferences.get("network.trr.mode").on(
"change",
gPrivacyPane.highlightDoHCategoryAndUpdateStatus
);
this.highlightDoHCategoryAndUpdateStatus();
Services.obs.addObserver(this, "network:trr-uri-changed");
Services.obs.addObserver(this, "network:trr-mode-changed");
Services.obs.addObserver(this, "network:trr-confirmation");
let unload = () => {
Services.obs.removeObserver(this, "network:trr-uri-changed");
Services.obs.removeObserver(this, "network:trr-mode-changed");
Services.obs.removeObserver(this, "network:trr-confirmation");
};
window.addEventListener("unload", unload, { once: true });
let uriPref = Services.prefs.getStringPref("network.trr.uri");
// If the value isn't one of the providers, we need to update the
// custom_uri pref to make sure the input box contains the correct URL.
if (uriPref && !this.dnsOverHttpsResolvers.some(e => e.uri == uriPref)) {
Services.prefs.setStringPref(
"network.trr.custom_uri",
Services.prefs.getStringPref("network.trr.uri")
);
}
if (Services.prefs.prefIsLocked("network.trr.mode")) {
document.getElementById("dohCategoryRadioGroup").disabled = true;
Services.prefs.setStringPref("network.trr.custom_uri", uriPref);
}
},
initWebAuthn() {
document.getElementById("openWindowsPasskeySettings").hidden =
!Services.prefs.getBoolPref(
"security.webauthn.show_ms_settings_link",
true
);
},
/**
* Sets up the UI for the number of days of history to keep, and updates the
* label of the "Clear Now..." button.
*/
init() {
this._updateSanitizeSettingsButton();
this.initDeleteOnCloseBox();
this.syncSanitizationPrefsWithDeleteOnClose();
this.initializeHistoryMode();
this.updateHistoryModePane();
this.updatePrivacyMicroControls();
this.initAutoStartPrivateBrowsingReverter();
/* Initialize Content Blocking */
this.initContentBlocking();
this.trackingProtectionReadPrefs();
this.fingerprintingProtectionReadPrefs();
this.networkCookieBehaviorReadPrefs();
this._initTrackingProtectionExtensionControl();
this._initThirdPartyCertsToggle();
this._initProfilesInfo();
Preferences.get("privacy.trackingprotection.enabled").on(
"change",
gPrivacyPane.trackingProtectionReadPrefs.bind(gPrivacyPane)
);
Preferences.get("privacy.trackingprotection.pbmode.enabled").on(
"change",
gPrivacyPane.trackingProtectionReadPrefs.bind(gPrivacyPane)
);
// Watch all of the prefs that the new Cookies & Site Data UI depends on
Preferences.get("network.cookie.cookieBehavior").on(
"change",
gPrivacyPane.networkCookieBehaviorReadPrefs.bind(gPrivacyPane)
);
Preferences.get("browser.privatebrowsing.autostart").on(
"change",
gPrivacyPane.networkCookieBehaviorReadPrefs.bind(gPrivacyPane)
);
Preferences.get("privacy.firstparty.isolate").on(
"change",
gPrivacyPane.networkCookieBehaviorReadPrefs.bind(gPrivacyPane)
);
Preferences.get("privacy.fingerprintingProtection").on(
"change",
gPrivacyPane.fingerprintingProtectionReadPrefs.bind(gPrivacyPane)
);
Preferences.get("privacy.fingerprintingProtection.pbmode").on(
"change",
gPrivacyPane.fingerprintingProtectionReadPrefs.bind(gPrivacyPane)
);
setEventListener(
"trackingProtectionExceptions",
"command",
gPrivacyPane.showTrackingProtectionExceptions
);
Preferences.get("privacy.sanitize.sanitizeOnShutdown").on(
"change",
gPrivacyPane._updateSanitizeSettingsButton.bind(gPrivacyPane)
);
Preferences.get("browser.privatebrowsing.autostart").on(
"change",
gPrivacyPane.updatePrivacyMicroControls.bind(gPrivacyPane)
);
setEventListener("historyMode", "command", function () {
gPrivacyPane.updateHistoryModePane();
gPrivacyPane.updateHistoryModePrefs();
gPrivacyPane.updatePrivacyMicroControls();
gPrivacyPane.updateAutostart();
});
setEventListener("clearHistoryButton", "command", function () {
let historyMode = document.getElementById("historyMode");
// Select "everything" in the clear history dialog if the
// user has set their history mode to never remember history.
gPrivacyPane.clearPrivateDataNow(historyMode.value == "dontremember");
});
setEventListener(
"privateBrowsingAutoStart",
"command",
gPrivacyPane.updateAutostart
);
setEventListener(
"cookieExceptions",
"command",
gPrivacyPane.showCookieExceptions
);
setEventListener(
"httpsOnlyExceptionButton",
"command",
gPrivacyPane.showHttpsOnlyModeExceptions
);
setEventListener(
"dohExceptionsButton",
"command",
gPrivacyPane.showDoHExceptions
);
setEventListener(
"clearDataSettings",
"command",
gPrivacyPane.showClearPrivateDataSettings
);
setEventListener(
"passwordExceptions",
"command",
gPrivacyPane.showPasswordExceptions
);
setEventListener(
"useMasterPassword",
"command",
gPrivacyPane.updateMasterPasswordButton
);
setEventListener(
"changeMasterPassword",
"command",
gPrivacyPane.changeMasterPassword
);
setEventListener("showPasswords", "command", gPrivacyPane.showPasswords);
setEventListener(
"addonExceptions",
"command",
gPrivacyPane.showAddonExceptions
);
setEventListener(
"viewCertificatesButton",
"command",
gPrivacyPane.showCertificates
);
setEventListener(
"viewSecurityDevicesButton",
"command",
gPrivacyPane.showSecurityDevices
);
this._pane = document.getElementById("panePrivacy");
this._initGlobalPrivacyControlUI();
this._initPasswordGenerationUI();
this._initRelayIntegrationUI();
this._initMasterPasswordUI();
this._initOSAuthentication();
this.initListenersForExtensionControllingPasswordManager();
this._initSafeBrowsing();
setEventListener(
"autoplaySettingsButton",
"command",
gPrivacyPane.showAutoplayMediaExceptions
);
setEventListener(
"notificationSettingsButton",
"command",
gPrivacyPane.showNotificationExceptions
);
setEventListener(
"locationSettingsButton",
"command",
gPrivacyPane.showLocationExceptions
);
setEventListener(
"xrSettingsButton",
"command",
gPrivacyPane.showXRExceptions
);
setEventListener(
"cameraSettingsButton",
"command",
gPrivacyPane.showCameraExceptions
);
setEventListener(
"microphoneSettingsButton",
"command",
gPrivacyPane.showMicrophoneExceptions
);
document.getElementById("speakerSettingsRow").hidden =
!Services.prefs.getBoolPref("media.setsinkid.enabled", false);
setEventListener(
"speakerSettingsButton",
"command",
gPrivacyPane.showSpeakerExceptions
);
setEventListener(
"popupPolicyButton",
"command",
gPrivacyPane.showPopupExceptions
);
setEventListener(
"notificationsDoNotDisturb",
"command",
gPrivacyPane.toggleDoNotDisturbNotifications
);
setSyncFromPrefListener("contentBlockingBlockCookiesCheckbox", () =>
this.readBlockCookies()
);
setSyncToPrefListener("contentBlockingBlockCookiesCheckbox", () =>
this.writeBlockCookies()
);
setSyncFromPrefListener("blockCookiesMenu", () =>
this.readBlockCookiesFrom()
);
setSyncToPrefListener("blockCookiesMenu", () =>
this.writeBlockCookiesFrom()
);
setSyncFromPrefListener("savePasswords", () => this.readSavePasswords());
let microControlHandler = el =>
this.ensurePrivacyMicroControlUncheckedWhenDisabled(el);
setSyncFromPrefListener("rememberHistory", microControlHandler);
setSyncFromPrefListener("rememberForms", microControlHandler);
setSyncFromPrefListener("alwaysClear", microControlHandler);
setSyncFromPrefListener("popupPolicy", () =>
this.updateButtons("popupPolicyButton", "dom.disable_open_during_load")
);
setSyncFromPrefListener("warnAddonInstall", () =>
this.readWarnAddonInstall()
);
setSyncFromPrefListener("enableOCSP", () => this.readEnableOCSP());
setSyncToPrefListener("enableOCSP", () => this.writeEnableOCSP());
if (AlertsServiceDND) {
let notificationsDoNotDisturbBox = document.getElementById(
"notificationsDoNotDisturbBox"
);
notificationsDoNotDisturbBox.removeAttribute("hidden");
let checkbox = document.getElementById("notificationsDoNotDisturb");
document.l10n.setAttributes(checkbox, "permissions-notification-pause");
if (AlertsServiceDND.manualDoNotDisturb) {
let notificationsDoNotDisturb = document.getElementById(
"notificationsDoNotDisturb"
);
notificationsDoNotDisturb.setAttribute("checked", true);
}
}
let onNimbus = () => this._updateFirefoxSuggestToggle();
NimbusFeatures.urlbar.onUpdate(onNimbus);
this._updateFirefoxSuggestToggle();
window.addEventListener("unload", () => {
NimbusFeatures.urlbar.offUpdate(onNimbus);
});
this.initSiteDataControls();
setEventListener(
"clearSiteDataButton",
"command",
gPrivacyPane.clearSiteData
);
setEventListener(
"siteDataSettings",
"command",
gPrivacyPane.showSiteDataSettings
);
this.initCookieBannerHandling();
this.initDataCollection();
if (AppConstants.MOZ_DATA_REPORTING) {
this.updateSubmitHealthReportFromPref();
Preferences.get(PREF_UPLOAD_ENABLED).on(
"change",
gPrivacyPane.updateSubmitHealthReportFromPref
);
setEventListener(
"submitHealthReportBox",
"command",
gPrivacyPane.updateSubmitHealthReportToPref
);
if (AppConstants.MOZ_NORMANDY) {
this.initOptOutStudyCheckbox();
}
this.initAddonRecommendationsCheckbox();
this.initPrivateAttributionCheckbox();
}
let signonBundle = document.getElementById("signonBundle");
let pkiBundle = document.getElementById("pkiBundle");
appendSearchKeywords("showPasswords", [
signonBundle.getString("loginsDescriptionAll2"),
]);
appendSearchKeywords("viewSecurityDevicesButton", [
pkiBundle.getString("enable_fips"),
]);
if (!PrivateBrowsingUtils.enabled) {
document.getElementById("privateBrowsingAutoStart").hidden = true;
document.querySelector("menuitem[value='dontremember']").hidden = true;
}
let privateBrowsingPref = Preferences.get(
"browser.privatebrowsing.autostart"
);
if (privateBrowsingPref.locked) {
// If permanent private browsing mode is locked to off,
// disable the "Never Remember History" option
document.querySelector("menuitem[value='dontremember']").disabled =
!privateBrowsingPref.value;
// If we're locked in permanent private browsing mode,
// disable the dropdown menu completely
document.getElementById("historyMode").disabled =
privateBrowsingPref.value;
}
/* init HTTPS-Only mode */
this.initHttpsOnly();
this.initDoH();
this.initWebAuthn();
// Notify observers that the UI is now ready
Services.obs.notifyObservers(window, "privacy-pane-loaded");
},
initSiteDataControls() {
Services.obs.addObserver(this, "sitedatamanager:sites-updated");
Services.obs.addObserver(this, "sitedatamanager:updating-sites");
let unload = () => {
window.removeEventListener("unload", unload);
Services.obs.removeObserver(this, "sitedatamanager:sites-updated");
Services.obs.removeObserver(this, "sitedatamanager:updating-sites");
};
window.addEventListener("unload", unload);
SiteDataManager.updateSites();
},
// CONTENT BLOCKING
/**
* Initializes the content blocking section.
*/
initContentBlocking() {
setEventListener(
"contentBlockingTrackingProtectionCheckbox",
"command",
this.trackingProtectionWritePrefs
);
setEventListener(
"contentBlockingTrackingProtectionCheckbox",
"command",
this._updateTrackingProtectionUI
);
setEventListener(
"contentBlockingCryptominersCheckbox",
"command",
this.updateCryptominingLists
);
setEventListener(
"contentBlockingFingerprintersCheckbox",
"command",
this.updateFingerprintingLists
);
setEventListener(
"trackingProtectionMenu",
"command",
this.trackingProtectionWritePrefs
);
setEventListener(
"contentBlockingFingerprintingProtectionCheckbox",
"command",
e => {
const extra = { checked: e.target.checked };
Glean.privacyUiFppClick.checkbox.record(extra);
this.fingerprintingProtectionWritePrefs();
}
);
setEventListener("fingerprintingProtectionMenu", "command", e => {
const extra = { value: e.target.value };
Glean.privacyUiFppClick.menu.record(extra);
this.fingerprintingProtectionWritePrefs();
});
setEventListener("standardArrow", "command", this.toggleExpansion);
setEventListener("strictArrow", "command", this.toggleExpansion);
setEventListener("customArrow", "command", this.toggleExpansion);
Preferences.get("network.cookie.cookieBehavior").on(
"change",
gPrivacyPane.readBlockCookies.bind(gPrivacyPane)
);
Preferences.get("browser.contentblocking.category").on(
"change",
gPrivacyPane.highlightCBCategory
);
// If any relevant content blocking pref changes, show a warning that the changes will
// not be implemented until they refresh their tabs.
for (let pref of CONTENT_BLOCKING_PREFS) {
Preferences.get(pref).on("change", gPrivacyPane.maybeNotifyUserToReload);
// If the value changes, run populateCategoryContents, since that change might have been
// triggered by a default value changing in the standard category.
Preferences.get(pref).on("change", gPrivacyPane.populateCategoryContents);
}
Preferences.get("urlclassifier.trackingTable").on(
"change",
gPrivacyPane.maybeNotifyUserToReload
);
for (let button of document.querySelectorAll(".reload-tabs-button")) {
button.addEventListener("command", gPrivacyPane.reloadAllOtherTabs);
}
let cryptoMinersOption = document.getElementById(
"contentBlockingCryptominersOption"
);
let fingerprintersOption = document.getElementById(
"contentBlockingFingerprintersOption"
);
let trackingAndIsolateOption = document.querySelector(
"#blockCookiesMenu menuitem[value='trackers-plus-isolate']"
);
cryptoMinersOption.hidden = !Services.prefs.getBoolPref(
"browser.contentblocking.cryptomining.preferences.ui.enabled"
);
fingerprintersOption.hidden = !Services.prefs.getBoolPref(
"browser.contentblocking.fingerprinting.preferences.ui.enabled"
);
let updateTrackingAndIsolateOption = () => {
trackingAndIsolateOption.hidden =
!Services.prefs.getBoolPref(
"browser.contentblocking.reject-and-isolate-cookies.preferences.ui.enabled",
false
) || gIsFirstPartyIsolated;
};
Preferences.get("privacy.firstparty.isolate").on(
"change",
updateTrackingAndIsolateOption
);
updateTrackingAndIsolateOption();
Preferences.get("browser.contentblocking.features.strict").on(
"change",
this.populateCategoryContents
);
this.populateCategoryContents();
this.highlightCBCategory();
this.readBlockCookies();
// Toggles the text "Cross-site and social media trackers" based on the
// social tracking pref. If the pref is false, the text reads
// "Cross-site trackers".
const STP_COOKIES_PREF = "privacy.socialtracking.block_cookies.enabled";
if (Services.prefs.getBoolPref(STP_COOKIES_PREF)) {
let contentBlockOptionSocialMedia = document.getElementById(
"blockCookiesSocialMedia"
);
document.l10n.setAttributes(
contentBlockOptionSocialMedia,
"sitedata-option-block-cross-site-tracking-cookies"
);
}
Preferences.get("privacy.resistFingerprinting").on(
"change",
setUpContentBlockingWarnings
);
Preferences.get("privacy.resistFingerprinting.pbmode").on(
"change",
setUpContentBlockingWarnings
);
setUpContentBlockingWarnings();
initTCPStandardSection();
},
populateCategoryContents() {
for (let type of ["strict", "standard"]) {
let rulesArray = [];
let selector;
if (type == "strict") {
selector = "#contentBlockingOptionStrict";
rulesArray = Services.prefs
.getStringPref("browser.contentblocking.features.strict")
.split(",");
if (gIsFirstPartyIsolated) {
let idx = rulesArray.indexOf("cookieBehavior5");
if (idx != -1) {
rulesArray[idx] = "cookieBehavior4";
}
}
} else {
selector = "#contentBlockingOptionStandard";
// In standard show/hide UI items based on the default values of the relevant prefs.
let defaults = Services.prefs.getDefaultBranch("");
let cookieBehavior = defaults.getIntPref(
"network.cookie.cookieBehavior"
);
switch (cookieBehavior) {
case Ci.nsICookieService.BEHAVIOR_ACCEPT:
rulesArray.push("cookieBehavior0");
break;
case Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN:
rulesArray.push("cookieBehavior1");
break;
case Ci.nsICookieService.BEHAVIOR_REJECT:
rulesArray.push("cookieBehavior2");
break;
case Ci.nsICookieService.BEHAVIOR_LIMIT_FOREIGN:
rulesArray.push("cookieBehavior3");
break;
case Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER:
rulesArray.push("cookieBehavior4");
break;
case BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN:
rulesArray.push(
gIsFirstPartyIsolated ? "cookieBehavior4" : "cookieBehavior5"
);
break;
}
let cookieBehaviorPBM = defaults.getIntPref(
"network.cookie.cookieBehavior.pbmode"
);
switch (cookieBehaviorPBM) {
case Ci.nsICookieService.BEHAVIOR_ACCEPT:
rulesArray.push("cookieBehaviorPBM0");
break;
case Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN:
rulesArray.push("cookieBehaviorPBM1");
break;
case Ci.nsICookieService.BEHAVIOR_REJECT:
rulesArray.push("cookieBehaviorPBM2");
break;
case Ci.nsICookieService.BEHAVIOR_LIMIT_FOREIGN:
rulesArray.push("cookieBehaviorPBM3");
break;
case Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER:
rulesArray.push("cookieBehaviorPBM4");
break;
case BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN:
rulesArray.push(
gIsFirstPartyIsolated
? "cookieBehaviorPBM4"
: "cookieBehaviorPBM5"
);
break;
}
rulesArray.push(
defaults.getBoolPref(
"privacy.trackingprotection.cryptomining.enabled"
)
? "cryptoTP"
: "-cryptoTP"
);
rulesArray.push(
defaults.getBoolPref(
"privacy.trackingprotection.fingerprinting.enabled"
)
? "fp"
: "-fp"
);
rulesArray.push(
Services.prefs.getBoolPref(
"privacy.socialtracking.block_cookies.enabled"
)
? "stp"
: "-stp"
);
rulesArray.push(
defaults.getBoolPref("privacy.trackingprotection.enabled")
? "tp"
: "-tp"
);
rulesArray.push(
defaults.getBoolPref("privacy.trackingprotection.pbmode.enabled")
? "tpPrivate"
: "-tpPrivate"
);
}
// Hide all cookie options first, until we learn which one should be showing.
document.querySelector(selector + " .all-cookies-option").hidden = true;
document.querySelector(selector + " .unvisited-cookies-option").hidden =
true;
document.querySelector(selector + " .cross-site-cookies-option").hidden =
true;
document.querySelector(
selector + " .third-party-tracking-cookies-option"
).hidden = true;
document.querySelector(
selector + " .all-third-party-cookies-private-windows-option"
).hidden = true;
document.querySelector(
selector + " .all-third-party-cookies-option"
).hidden = true;
document.querySelector(selector + " .social-media-option").hidden = true;
for (let item of rulesArray) {
// Note "cookieBehavior0", will result in no UI changes, so is not listed here.
switch (item) {
case "tp":
document.querySelector(selector + " .trackers-option").hidden =
false;
break;
case "-tp":
document.querySelector(selector + " .trackers-option").hidden =
true;
break;
case "tpPrivate":
document.querySelector(selector + " .pb-trackers-option").hidden =
false;
break;
case "-tpPrivate":
document.querySelector(selector + " .pb-trackers-option").hidden =
true;
break;
case "fp":
document.querySelector(
selector + " .fingerprinters-option"
).hidden = false;
break;
case "-fp":
document.querySelector(
selector + " .fingerprinters-option"
).hidden = true;
break;
case "cryptoTP":
document.querySelector(selector + " .cryptominers-option").hidden =
false;
break;
case "-cryptoTP":
document.querySelector(selector + " .cryptominers-option").hidden =
true;
break;
case "stp": {
// Store social tracking cookies pref
const STP_COOKIES_PREF =
"privacy.socialtracking.block_cookies.enabled";
if (Services.prefs.getBoolPref(STP_COOKIES_PREF)) {
document.querySelector(
selector + " .social-media-option"
).hidden = false;
}
break;
}
case "-stp":
// Store social tracking cookies pref
document.querySelector(selector + " .social-media-option").hidden =
true;
break;
case "cookieBehavior1":
document.querySelector(
selector + " .all-third-party-cookies-option"
).hidden = false;
break;
case "cookieBehavior2":
document.querySelector(selector + " .all-cookies-option").hidden =
false;
break;
case "cookieBehavior3":
document.querySelector(
selector + " .unvisited-cookies-option"
).hidden = false;
break;
case "cookieBehavior4":
document.querySelector(
selector + " .third-party-tracking-cookies-option"
).hidden = false;
break;
case "cookieBehavior5":
document.querySelector(
selector + " .cross-site-cookies-option"
).hidden = false;
break;
case "cookieBehaviorPBM5":
// We only need to show the cookie option for private windows if the
// cookieBehaviors are different between regular windows and private
// windows.
if (!rulesArray.includes("cookieBehavior5")) {
document.querySelector(
selector + " .all-third-party-cookies-private-windows-option"
).hidden = false;
}
break;
}
}
// Hide the "tracking protection in private browsing" list item
// if the "tracking protection enabled in all windows" list item is showing.
if (!document.querySelector(selector + " .trackers-option").hidden) {
document.querySelector(selector + " .pb-trackers-option").hidden = true;
}
}
},
highlightCBCategory() {
let value = Preferences.get("browser.contentblocking.category").value;
let standardEl = document.getElementById("contentBlockingOptionStandard");
let strictEl = document.getElementById("contentBlockingOptionStrict");
let customEl = document.getElementById("contentBlockingOptionCustom");
standardEl.classList.remove("selected");
strictEl.classList.remove("selected");
customEl.classList.remove("selected");
switch (value) {
case "strict":
strictEl.classList.add("selected");
break;
case "custom":
customEl.classList.add("selected");
break;
case "standard":
/* fall through */
default:
standardEl.classList.add("selected");
break;
}
},
updateCryptominingLists() {
let listPrefs = [
"urlclassifier.features.cryptomining.blacklistTables",
"urlclassifier.features.cryptomining.whitelistTables",
];
let listValue = listPrefs
.map(l => Services.prefs.getStringPref(l))
.join(",");
listManager.forceUpdates(listValue);
},
updateFingerprintingLists() {
let listPrefs = [
"urlclassifier.features.fingerprinting.blacklistTables",
"urlclassifier.features.fingerprinting.whitelistTables",
];
let listValue = listPrefs
.map(l => Services.prefs.getStringPref(l))
.join(",");
listManager.forceUpdates(listValue);
},
// TRACKING PROTECTION MODE
/**
* Selects the right item of the Tracking Protection menulist and checkbox.
*/
trackingProtectionReadPrefs() {
let enabledPref = Preferences.get("privacy.trackingprotection.enabled");
let pbmPref = Preferences.get("privacy.trackingprotection.pbmode.enabled");
let tpMenu = document.getElementById("trackingProtectionMenu");
let tpCheckbox = document.getElementById(
"contentBlockingTrackingProtectionCheckbox"
);
this._updateTrackingProtectionUI();
// Global enable takes precedence over enabled in Private Browsing.
if (enabledPref.value) {
tpMenu.value = "always";
tpCheckbox.checked = true;
} else if (pbmPref.value) {
tpMenu.value = "private";
tpCheckbox.checked = true;
} else {
tpMenu.value = "never";
tpCheckbox.checked = false;
}
},
/**
* Selects the right item of the Fingerprinting Protection menulist and
* checkbox.
*/
fingerprintingProtectionReadPrefs() {
let enabledPref = Preferences.get("privacy.fingerprintingProtection");
let pbmPref = Preferences.get("privacy.fingerprintingProtection.pbmode");
let fppMenu = document.getElementById("fingerprintingProtectionMenu");
let fppCheckbox = document.getElementById(
"contentBlockingFingerprintingProtectionCheckbox"
);
// Global enable takes precedence over enabled in Private Browsing.
if (enabledPref.value) {
fppMenu.value = "always";
fppCheckbox.checked = true;
} else if (pbmPref.value) {
fppMenu.value = "private";
fppCheckbox.checked = true;
} else {
fppMenu.value = "never";
fppCheckbox.checked = false;
}
fppMenu.disabled = !fppCheckbox.checked;
},
/**
* Selects the right items of the new Cookies & Site Data UI.
*/
networkCookieBehaviorReadPrefs() {
let behavior = Services.cookies.getCookieBehavior(false);
let blockCookiesMenu = document.getElementById("blockCookiesMenu");
let deleteOnCloseCheckbox = document.getElementById("deleteOnClose");
let deleteOnCloseNote = document.getElementById("deleteOnCloseNote");
let blockCookies = behavior != Ci.nsICookieService.BEHAVIOR_ACCEPT;
let cookieBehaviorLocked = Services.prefs.prefIsLocked(
"network.cookie.cookieBehavior"
);
let blockCookiesControlsDisabled = !blockCookies || cookieBehaviorLocked;
blockCookiesMenu.disabled = blockCookiesControlsDisabled;
let completelyBlockCookies =
behavior == Ci.nsICookieService.BEHAVIOR_REJECT;
let privateBrowsing = Preferences.get(
"browser.privatebrowsing.autostart"
).value;
deleteOnCloseCheckbox.disabled = privateBrowsing || completelyBlockCookies;
deleteOnCloseNote.hidden = !privateBrowsing;
switch (behavior) {
case Ci.nsICookieService.BEHAVIOR_ACCEPT:
break;
case Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN:
blockCookiesMenu.value = "all-third-parties";
break;
case Ci.nsICookieService.BEHAVIOR_REJECT:
blockCookiesMenu.value = "always";
break;
case Ci.nsICookieService.BEHAVIOR_LIMIT_FOREIGN:
blockCookiesMenu.value = "unvisited";
break;
case Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER:
blockCookiesMenu.value = "trackers";
break;
case BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN:
blockCookiesMenu.value = "trackers-plus-isolate";
break;
}
},
/**
* Sets the pref values based on the selected item of the radiogroup.
*/
trackingProtectionWritePrefs() {
let enabledPref = Preferences.get("privacy.trackingprotection.enabled");
let pbmPref = Preferences.get("privacy.trackingprotection.pbmode.enabled");
let stpPref = Preferences.get(
"privacy.trackingprotection.socialtracking.enabled"
);
let stpCookiePref = Preferences.get(
"privacy.socialtracking.block_cookies.enabled"
);
// Currently, we don't expose the email tracking protection setting on our
// privacy UI. Instead, we use the existing tracking protection checkbox to
// control the email tracking protection.
let emailTPPref = Preferences.get(
"privacy.trackingprotection.emailtracking.enabled"
);
let emailTPPBMPref = Preferences.get(
"privacy.trackingprotection.emailtracking.pbmode.enabled"
);
let tpMenu = document.getElementById("trackingProtectionMenu");
let tpCheckbox = document.getElementById(
"contentBlockingTrackingProtectionCheckbox"
);
let value;
if (tpCheckbox.checked) {
if (tpMenu.value == "never") {
tpMenu.value = "private";
}
value = tpMenu.value;
} else {
tpMenu.value = "never";
value = "never";
}
switch (value) {
case "always":
enabledPref.value = true;
pbmPref.value = true;
emailTPPref.value = true;
emailTPPBMPref.value = true;
if (stpCookiePref.value) {
stpPref.value = true;
}
break;
case "private":
enabledPref.value = false;
pbmPref.value = true;
emailTPPref.value = false;
emailTPPBMPref.value = true;
if (stpCookiePref.value) {
stpPref.value = false;
}
break;
case "never":
enabledPref.value = false;
pbmPref.value = false;
emailTPPref.value = false;
emailTPPBMPref.value = false;
if (stpCookiePref.value) {
stpPref.value = false;
}
break;
}
},
fingerprintingProtectionWritePrefs() {
let enabledPref = Preferences.get("privacy.fingerprintingProtection");
let pbmPref = Preferences.get("privacy.fingerprintingProtection.pbmode");
let fppMenu = document.getElementById("fingerprintingProtectionMenu");
let fppCheckbox = document.getElementById(
"contentBlockingFingerprintingProtectionCheckbox"
);
let value;
if (fppCheckbox.checked) {
if (fppMenu.value == "never") {
fppMenu.value = "private";
}
value = fppMenu.value;
} else {
fppMenu.value = "never";
value = "never";
}
fppMenu.disabled = !fppCheckbox.checked;
switch (value) {
case "always":
enabledPref.value = true;
pbmPref.value = true;
break;
case "private":
enabledPref.value = false;
pbmPref.value = true;
break;
case "never":
enabledPref.value = false;
pbmPref.value = false;
break;
}
},
toggleExpansion(e) {
let carat = e.target;
carat.classList.toggle("up");
carat.closest(".privacy-detailedoption").classList.toggle("expanded");
carat.setAttribute(
"aria-expanded",
carat.getAttribute("aria-expanded") === "false"
);
},
// HISTORY MODE
/**
* The list of preferences which affect the initial history mode settings.
* If the auto start private browsing mode pref is active, the initial
* history mode would be set to "Don't remember anything".
* If ALL of these preferences are set to the values that correspond
* to keeping some part of history, and the auto-start
* private browsing mode is not active, the initial history mode would be
* set to "Remember everything".
* Otherwise, the initial history mode would be set to "Custom".
*
* Extensions adding their own preferences can set values here if needed.
*/
prefsForKeepingHistory: {
"places.history.enabled": true, // History is enabled
"browser.formfill.enable": true, // Form information is saved
"privacy.sanitize.sanitizeOnShutdown": false, // Private date is NOT cleared on shutdown
},
/**
* The list of control IDs which are dependent on the auto-start private
* browsing setting, such that in "Custom" mode they would be disabled if
* the auto-start private browsing checkbox is checked, and enabled otherwise.
*
* Extensions adding their own controls can append their IDs to this array if needed.
*/
dependentControls: [
"rememberHistory",
"rememberForms",
"alwaysClear",
"clearDataSettings",
],
/**
* Check whether preferences values are set to keep history
*
* @param aPrefs an array of pref names to check for
* @returns boolean true if all of the prefs are set to keep history,
* false otherwise
*/
_checkHistoryValues(aPrefs) {
for (let pref of Object.keys(aPrefs)) {
if (Preferences.get(pref).value != aPrefs[pref]) {
return false;
}
}
return true;
},
/**
* Initialize the history mode menulist based on the privacy preferences
*/
initializeHistoryMode() {
let mode;
let getVal = aPref => Preferences.get(aPref).value;
if (getVal("privacy.history.custom")) {
mode = "custom";
} else if (this._checkHistoryValues(this.prefsForKeepingHistory)) {
if (getVal("browser.privatebrowsing.autostart")) {
mode = "dontremember";
} else {
mode = "remember";
}
} else {
mode = "custom";
}
document.getElementById("historyMode").value = mode;
},
/**
* Update the selected pane based on the history mode menulist
*/
updateHistoryModePane() {
let selectedIndex = -1;
switch (document.getElementById("historyMode").value) {
case "remember":
selectedIndex = 0;
break;
case "dontremember":
selectedIndex = 1;
break;
case "custom":
selectedIndex = 2;
break;
}
document.getElementById("historyPane").selectedIndex = selectedIndex;
Preferences.get("privacy.history.custom").value = selectedIndex == 2;
},
/**
* Update the private browsing auto-start pref and the history mode
* micro-management prefs based on the history mode menulist
*/
updateHistoryModePrefs() {
let pref = Preferences.get("browser.privatebrowsing.autostart");
switch (document.getElementById("historyMode").value) {
case "remember":
if (pref.value) {
pref.value = false;
}
// select the remember history option if needed
Preferences.get("places.history.enabled").value = true;
// select the remember forms history option
Preferences.get("browser.formfill.enable").value = true;
// select the clear on close option
Preferences.get("privacy.sanitize.sanitizeOnShutdown").value = false;
break;
case "dontremember":
if (!pref.value) {
pref.value = true;
}
break;
}
},
/**
* Update the privacy micro-management controls based on the
* value of the private browsing auto-start preference.
*/
updatePrivacyMicroControls() {
let clearDataSettings = document.getElementById("clearDataSettings");
if (document.getElementById("historyMode").value == "custom") {
let disabled = Preferences.get("browser.privatebrowsing.autostart").value;
this.dependentControls.forEach(aElement => {
let control = document.getElementById(aElement);
let preferenceId = control.getAttribute("preference");
if (!preferenceId) {
let dependentControlId = control.getAttribute("control");
if (dependentControlId) {
let dependentControl = document.getElementById(dependentControlId);
preferenceId = dependentControl.getAttribute("preference");
}
}
let preference = preferenceId ? Preferences.get(preferenceId) : {};
control.disabled = disabled || preference.locked;
if (control != clearDataSettings) {
this.ensurePrivacyMicroControlUncheckedWhenDisabled(control);
}
});
clearDataSettings.removeAttribute("hidden");
if (!disabled) {
// adjust the Settings button for sanitizeOnShutdown
this._updateSanitizeSettingsButton();
}
} else {
clearDataSettings.hidden = true;
}
},
ensurePrivacyMicroControlUncheckedWhenDisabled(el) {
if (Preferences.get("browser.privatebrowsing.autostart").value) {
// Set checked to false when called from updatePrivacyMicroControls
el.checked = false;
// return false for the onsyncfrompreference case:
return false;
}
return undefined; // tell preferencesBindings to assign the 'right' value.
},
// CLEAR PRIVATE DATA
/*
* Preferences:
*
* privacy.sanitize.sanitizeOnShutdown
* - true if the user's private data is cleared on startup according to the
* Clear Private Data settings, false otherwise
*/
/**
* Displays the Clear Private Data settings dialog.
*/
showClearPrivateDataSettings() {
let dialogFile = useOldClearHistoryDialog
? "chrome://browser/content/preferences/dialogs/sanitize.xhtml"
: "chrome://browser/content/sanitize_v2.xhtml";
gSubDialog.open(
dialogFile,
{
features: "resizable=no",
},
{
mode: "clearOnShutdown",
}
);
},
/**
* Displays a dialog from which individual parts of private data may be
* cleared.
*/
clearPrivateDataNow(aClearEverything) {
var ts = Preferences.get("privacy.sanitize.timeSpan");
var timeSpanOrig = ts.value;
if (aClearEverything) {
ts.value = 0;
}
// Bug 1856418 We intend to remove the old dialog box
let dialogFile = useOldClearHistoryDialog
? "chrome://browser/content/sanitize.xhtml"
: "chrome://browser/content/sanitize_v2.xhtml";
gSubDialog.open(dialogFile, {
features: "resizable=no",
closingCallback: () => {
// reset the timeSpan pref
if (aClearEverything) {
ts.value = timeSpanOrig;
}
Services.obs.notifyObservers(null, "clear-private-data");
},
});
},
/*
* On loading the page, assigns the state to the deleteOnClose checkbox that fits the pref selection
*/
initDeleteOnCloseBox() {
// Make sure to do the migration for the clear history dialog before implementing logic for delete on close
// This needs to be done to make sure the migration is done before any pref changes are made to avoid unintentionally
// overwriting prefs
Sanitizer.maybeMigratePrefs("clearOnShutdown");
let deleteOnCloseBox = document.getElementById("deleteOnClose");
// We have to branch between the old clear on shutdown prefs and new prefs after the clear history revamp (Bug 1853996)
// Once the old dialog is deprecated, we can remove these branches.
let isCookiesAndStorageClearingOnShutdown;
if (useOldClearHistoryDialog) {
isCookiesAndStorageClearingOnShutdown =
Preferences.get("privacy.sanitize.sanitizeOnShutdown").value &&
Preferences.get("privacy.clearOnShutdown.cookies").value &&
Preferences.get("privacy.clearOnShutdown.cache").value &&
Preferences.get("privacy.clearOnShutdown.offlineApps").value;
} else {
isCookiesAndStorageClearingOnShutdown =
Preferences.get("privacy.sanitize.sanitizeOnShutdown").value &&
Preferences.get("privacy.clearOnShutdown_v2.cookiesAndStorage").value &&
Preferences.get("privacy.clearOnShutdown_v2.cache").value;
}
deleteOnCloseBox.checked =
isCookiesAndStorageClearingOnShutdown ||
Preferences.get("browser.privatebrowsing.autostart").value;
},
/*
* Keeps the state of the deleteOnClose checkbox in sync with the pref selection
*/
syncSanitizationPrefsWithDeleteOnClose() {
let deleteOnCloseBox = document.getElementById("deleteOnClose");
let historyMode = Preferences.get("privacy.history.custom");
let sanitizeOnShutdownPref = Preferences.get(
"privacy.sanitize.sanitizeOnShutdown"
);
// ClearOnClose cleaning categories
let cookiePref = useOldClearHistoryDialog
? Preferences.get("privacy.clearOnShutdown.cookies")
: Preferences.get("privacy.clearOnShutdown_v2.cookiesAndStorage");
let cachePref = useOldClearHistoryDialog
? Preferences.get("privacy.clearOnShutdown.cache")
: Preferences.get("privacy.clearOnShutdown_v2.cache");
let offlineAppsPref = useOldClearHistoryDialog
? Preferences.get("privacy.clearOnShutdown.offlineApps")
: Preferences.get("privacy.clearOnShutdown_v2.cookiesAndStorage");
// Sync the cleaning prefs with the deleteOnClose box
deleteOnCloseBox.addEventListener("command", () => {
let { checked } = deleteOnCloseBox;
cookiePref.value = checked;
cachePref.value = checked;
offlineAppsPref.value = checked;
// Forget the current pref selection if sanitizeOnShutdown is disabled,
// to not over clear when it gets enabled by the sync mechanism
if (!sanitizeOnShutdownPref.value) {
this._resetCleaningPrefs();
}
// If no other cleaning category is selected, sanitizeOnShutdown gets synced with deleteOnClose
sanitizeOnShutdownPref.value =
this._isCustomCleaningPrefPresent() || checked;
// Update the view of the history settings
if (checked && !historyMode.value) {
historyMode.value = "custom";
this.initializeHistoryMode();
this.updateHistoryModePane();
this.updatePrivacyMicroControls();
}
});
cookiePref.on("change", this._onSanitizePrefChangeSyncClearOnClose);
cachePref.on("change", this._onSanitizePrefChangeSyncClearOnClose);
offlineAppsPref.on("change", this._onSanitizePrefChangeSyncClearOnClose);
sanitizeOnShutdownPref.on(
"change",
this._onSanitizePrefChangeSyncClearOnClose
);
},
/*
* Sync the deleteOnClose box to its cleaning prefs
*/
_onSanitizePrefChangeSyncClearOnClose() {
let deleteOnCloseBox = document.getElementById("deleteOnClose");
// We have to branch between the old clear on shutdown prefs and new prefs after the clear history revamp (Bug 1853996)
// Once the old dialog is deprecated, we can remove these branches.
if (useOldClearHistoryDialog) {
deleteOnCloseBox.checked =
Preferences.get("privacy.sanitize.sanitizeOnShutdown").value &&
Preferences.get("privacy.clearOnShutdown.cookies").value &&
Preferences.get("privacy.clearOnShutdown.cache").value &&
Preferences.get("privacy.clearOnShutdown.offlineApps").value;
} else {
deleteOnCloseBox.checked =
Preferences.get("privacy.sanitize.sanitizeOnShutdown").value &&
Preferences.get("privacy.clearOnShutdown_v2.cookiesAndStorage").value &&
Preferences.get("privacy.clearOnShutdown_v2.cache").value;
}
},
/*
* Unsets cleaning prefs that do not belong to DeleteOnClose
*/
_resetCleaningPrefs() {
let sanitizeOnShutdownPrefsArray = useOldClearHistoryDialog
? SANITIZE_ON_SHUTDOWN_PREFS_ONLY
: SANITIZE_ON_SHUTDOWN_PREFS_ONLY_V2;
return sanitizeOnShutdownPrefsArray.forEach(
pref => (Preferences.get(pref).value = false)
);
},
/*
Checks if the user set cleaning prefs that do not belong to DeleteOnClose
*/
_isCustomCleaningPrefPresent() {
let sanitizeOnShutdownPrefsArray = useOldClearHistoryDialog
? SANITIZE_ON_SHUTDOWN_PREFS_ONLY
: SANITIZE_ON_SHUTDOWN_PREFS_ONLY_V2;
return sanitizeOnShutdownPrefsArray.some(
pref => Preferences.get(pref).value
);
},
/**
* Enables or disables the "Settings..." button depending
* on the privacy.sanitize.sanitizeOnShutdown preference value
*/
_updateSanitizeSettingsButton() {
var settingsButton = document.getElementById("clearDataSettings");
var sanitizeOnShutdownPref = Preferences.get(
"privacy.sanitize.sanitizeOnShutdown"
);
settingsButton.disabled = !sanitizeOnShutdownPref.value;
},
toggleDoNotDisturbNotifications(event) {
AlertsServiceDND.manualDoNotDisturb = event.target.checked;
},
// PRIVATE BROWSING
/**
* Initialize the starting state for the auto-start private browsing mode pref reverter.
*/
initAutoStartPrivateBrowsingReverter() {
// We determine the mode in initializeHistoryMode, which is guaranteed to have been
// called before now, so this is up-to-date.
let mode = document.getElementById("historyMode");
this._lastMode = mode.selectedIndex;
// The value of the autostart pref, on the other hand, is gotten from Preferences,
// which updates the DOM asynchronously, so we can't rely on the DOM. Get it directly
// from the prefs.
this._lastCheckState = Preferences.get(
"browser.privatebrowsing.autostart"
).value;
},
_lastMode: null,
_lastCheckState: null,
async updateAutostart() {
let mode = document.getElementById("historyMode");
let autoStart = document.getElementById("privateBrowsingAutoStart");
let pref = Preferences.get("browser.privatebrowsing.autostart");
if (
(mode.value == "custom" && this._lastCheckState == autoStart.checked) ||
(mode.value == "remember" && !this._lastCheckState) ||
(mode.value == "dontremember" && this._lastCheckState)
) {
// These are all no-op changes, so we don't need to prompt.
this._lastMode = mode.selectedIndex;
this._lastCheckState = autoStart.hasAttribute("checked");
return;
}
if (!this._shouldPromptForRestart) {
// We're performing a revert. Just let it happen.
return;
}
let buttonIndex = await confirmRestartPrompt(
autoStart.checked,
1,
true,
false
);
if (buttonIndex == CONFIRM_RESTART_PROMPT_RESTART_NOW) {
pref.value = autoStart.hasAttribute("checked");
Services.startup.quit(
Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart
);
return;
}
this._shouldPromptForRestart = false;
if (this._lastCheckState) {
autoStart.checked = "checked";
} else {
autoStart.removeAttribute("checked");
}
pref.value = autoStart.hasAttribute("checked");
mode.selectedIndex = this._lastMode;
mode.doCommand();
this._shouldPromptForRestart = true;
},
/**
* Displays fine-grained, per-site preferences for tracking protection.
*/
showTrackingProtectionExceptions() {
let params = {
permissionType: "trackingprotection",
disableETPVisible: true,
prefilledHost: "",
hideStatusColumn: true,
};
gSubDialog.open(
"chrome://browser/content/preferences/dialogs/permissions.xhtml",
undefined,
params
);
},
// COOKIES AND SITE DATA
/*
* Preferences:
*
* network.cookie.cookieBehavior
* - determines how the browser should handle cookies:
* 0 means enable all cookies
* 1 means reject all third party cookies
* 2 means disable all cookies
* 3 means reject third party cookies unless at least one is already set for the eTLD
* 4 means reject all trackers
* 5 means reject all trackers and partition third-party cookies
* see netwerk/cookie/src/CookieService.cpp for details
*/
/**
* Reads the network.cookie.cookieBehavior preference value and
* enables/disables the "blockCookiesMenu" menulist accordingly.
*/
readBlockCookies() {
let bcControl = document.getElementById("blockCookiesMenu");
bcControl.disabled =
Services.cookies.getCookieBehavior(false) ==
Ci.nsICookieService.BEHAVIOR_ACCEPT;
},
/**
* Updates the "accept third party cookies" menu based on whether the
* "contentBlockingBlockCookiesCheckbox" checkbox is checked.
*/
writeBlockCookies() {
let block = document.getElementById("contentBlockingBlockCookiesCheckbox");
let blockCookiesMenu = document.getElementById("blockCookiesMenu");
if (block.checked) {
// Automatically select 'third-party trackers' as the default.
blockCookiesMenu.selectedIndex = 0;
return this.writeBlockCookiesFrom();
}
return Ci.nsICookieService.BEHAVIOR_ACCEPT;
},
readBlockCookiesFrom() {
switch (Services.cookies.getCookieBehavior(false)) {
case Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN:
return "all-third-parties";
case Ci.nsICookieService.BEHAVIOR_REJECT:
return "always";
case Ci.nsICookieService.BEHAVIOR_LIMIT_FOREIGN:
return "unvisited";
case Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER:
return "trackers";
case BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN:
return "trackers-plus-isolate";
default:
return undefined;
}
},
writeBlockCookiesFrom() {
let block = document.getElementById("blockCookiesMenu").selectedItem;
switch (block.value) {
case "trackers":
return Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER;
case "unvisited":
return Ci.nsICookieService.BEHAVIOR_LIMIT_FOREIGN;
case "always":
return Ci.nsICookieService.BEHAVIOR_REJECT;
case "all-third-parties":
return Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN;
case "trackers-plus-isolate":
return Ci.nsICookieService
.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN;
default:
return undefined;
}
},
/**
* Discard the browsers of all tabs in all windows. Pinned tabs, as
* well as tabs for which discarding doesn't succeed (e.g. selected
* tabs, tabs with beforeunload listeners), are reloaded.
*/
reloadAllOtherTabs() {
let ourTab = BrowserWindowTracker.getTopWindow().gBrowser.selectedTab;
BrowserWindowTracker.orderedWindows.forEach(win => {
let otherGBrowser = win.gBrowser;
for (let tab of otherGBrowser.tabs) {
if (tab == ourTab) {
// Don't reload our preferences tab.
continue;
}
if (tab.pinned || tab.selected) {
otherGBrowser.reloadTab(tab);
} else {
otherGBrowser.discardBrowser(tab);
}
}
});
for (let notification of document.querySelectorAll(".reload-tabs")) {
notification.hidden = true;
}
},
/**
* If there are more tabs than just the preferences tab, show a warning to the user that
* they need to reload their tabs to apply the setting.
*/
maybeNotifyUserToReload() {
let shouldShow = false;
if (window.BrowserWindowTracker.orderedWindows.length > 1) {
shouldShow = true;
} else {
let tabbrowser = window.BrowserWindowTracker.getTopWindow().gBrowser;
if (tabbrowser.tabs.length > 1) {
shouldShow = true;
}
}
if (shouldShow) {
for (let notification of document.querySelectorAll(".reload-tabs")) {
notification.hidden = false;
}
}
},
/**
* Displays fine-grained, per-site preferences for cookies.
*/
showCookieExceptions() {
var params = {
blockVisible: true,
sessionVisible: true,
allowVisible: true,
prefilledHost: "",
permissionType: "cookie",
};
gSubDialog.open(
"chrome://browser/content/preferences/dialogs/permissions.xhtml",
undefined,
params
);
},
/**
* Displays per-site preferences for HTTPS-Only Mode exceptions.
*/
showHttpsOnlyModeExceptions() {
var params = {
blockVisible: false,
sessionVisible: true,
allowVisible: false,
prefilledHost: "",
permissionType: "https-only-load-insecure",
forcedHTTP: true,
};
gSubDialog.open(
"chrome://browser/content/preferences/dialogs/permissions.xhtml",
undefined,
params
);
},
showDoHExceptions() {
gSubDialog.open(
"chrome://browser/content/preferences/dialogs/dohExceptions.xhtml",
undefined
);
},
showSiteDataSettings() {
gSubDialog.open(
"chrome://browser/content/preferences/dialogs/siteDataSettings.xhtml"
);
},
toggleSiteData(shouldShow) {
let clearButton = document.getElementById("clearSiteDataButton");
let settingsButton = document.getElementById("siteDataSettings");
clearButton.disabled = !shouldShow;
settingsButton.disabled = !shouldShow;
},
showSiteDataLoading() {
let totalSiteDataSizeLabel = document.getElementById("totalSiteDataSize");
document.l10n.setAttributes(
totalSiteDataSizeLabel,
"sitedata-total-size-calculating"
);
},
updateTotalDataSizeLabel(siteDataUsage) {
SiteDataManager.getCacheSize().then(function (cacheUsage) {
let totalSiteDataSizeLabel = document.getElementById("totalSiteDataSize");
let totalUsage = siteDataUsage + cacheUsage;
let [value, unit] = DownloadUtils.convertByteUnits(totalUsage);
document.l10n.setAttributes(
totalSiteDataSizeLabel,
"sitedata-total-size",
{
value,
unit,
}
);
});
},
clearSiteData() {
// We have to use the full path name to avoid getting errors in
// browser/base/content/test/static/browser_all_files_referenced.js
let dialogFile = useOldClearHistoryDialog
? "chrome://browser/content/preferences/dialogs/clearSiteData.xhtml"
: "chrome://browser/content/sanitize_v2.xhtml";
gSubDialog.open(
dialogFile,
{
features: "resizable=no",
},
{
mode: "clearSiteData",
}
);
},
/**
* Initializes the cookie banner handling subgroup on the privacy pane.
*
* This UI is shown if the "cookiebanners.ui.desktop.enabled" pref is true.
*
* The cookie banner handling checkbox reflects the cookie banner feature
* state. It is enabled when the service enabled via the
* cookiebanners.service.mode pref. If detection-only mode is enabled the
* checkbox is unchecked, since in this mode no banners are handled. It is
* only used for detection for banners which means we may prompt the user to
* enable the feature via other UI surfaces such as the onboarding doorhanger.
*
* If the user checks the checkbox, the pref value is set to
* nsICookieBannerService.MODE_REJECT_OR_ACCEPT.
*
* If the user unchecks the checkbox, the mode pref value is set to
* nsICookieBannerService.MODE_DISABLED.
*
* Advanced users can choose other int-valued modes via about:config.
*/
initCookieBannerHandling() {
setSyncFromPrefListener("handleCookieBanners", () =>
this.readCookieBannerMode()
);
setSyncToPrefListener("handleCookieBanners", () =>
this.writeCookieBannerMode()
);
let preference = Preferences.get("cookiebanners.ui.desktop.enabled");
preference.on("change", () => this.updateCookieBannerHandlingVisibility());
this.updateCookieBannerHandlingVisibility();
},
/**
* Reads the cookiebanners.service.mode.privateBrowsing pref,
* interpreting the multiple modes as a true/false value
*/
readCookieBannerMode() {
return (
Preferences.get("cookiebanners.service.mode.privateBrowsing").value !=
Ci.nsICookieBannerService.MODE_DISABLED
);
},
/**
* Translates user clicks on the cookie banner handling checkbox to the
* corresponding integer-valued cookie banner mode preference.
*/
writeCookieBannerMode() {
let checkbox = document.getElementById("handleCookieBanners");
if (!checkbox.checked) {
/* because we removed UI control for the non-PBM pref, disabling it here
provides an off-ramp for profiles where it had previously been enabled from the UI */
Services.prefs.setIntPref(
"cookiebanners.service.mode",
Ci.nsICookieBannerService.MODE_DISABLED
);
return Ci.nsICookieBannerService.MODE_DISABLED;
}
return Ci.nsICookieBannerService.MODE_REJECT;
},
/**
* Shows or hides the cookie banner handling section based on the value of
* the "cookiebanners.ui.desktop.enabled" pref.
*/
updateCookieBannerHandlingVisibility() {
let groupbox = document.getElementById("cookieBannerHandlingGroup");
let isEnabled = Preferences.get("cookiebanners.ui.desktop.enabled").value;
// Because the top-level pane showing code unsets the hidden attribute, we
// manually hide the section when cookie banner handling is preffed off.
if (isEnabled) {
groupbox.removeAttribute("style");
} else {
groupbox.setAttribute("style", "display: none !important");
}
},
/**
* Updates the visibility of the Firefox Suggest Privacy Container
* based on the user's Quick Suggest settings.
*/
_updateFirefoxSuggestToggle() {
document.getElementById(
"firefoxSuggestDataCollectionPrivacyToggle"
).hidden =
!UrlbarPrefs.get("quickSuggestEnabled") ||
UrlbarPrefs.get("quickSuggestSettingsUi") !=
QuickSuggest.SETTINGS_UI.FULL;
},
// GEOLOCATION
/**
* Displays the location exceptions dialog where specific site location
* preferences can be set.
*/
showLocationExceptions() {
let params = { permissionType: "geo" };
gSubDialog.open(
"chrome://browser/content/preferences/dialogs/sitePermissions.xhtml",
{ features: "resizable=yes" },
params
);
},
// XR
/**
* Displays the XR exceptions dialog where specific site XR
* preferences can be set.
*/
showXRExceptions() {
let params = { permissionType: "xr" };
gSubDialog.open(
"chrome://browser/content/preferences/dialogs/sitePermissions.xhtml",
{ features: "resizable=yes" },
params
);
},
// CAMERA
/**
* Displays the camera exceptions dialog where specific site camera
* preferences can be set.
*/
showCameraExceptions() {
let params = { permissionType: "camera" };
gSubDialog.open(
"chrome://browser/content/preferences/dialogs/sitePermissions.xhtml",
{ features: "resizable=yes" },
params
);
},
// MICROPHONE
/**
* Displays the microphone exceptions dialog where specific site microphone
* preferences can be set.
*/
showMicrophoneExceptions() {
let params = { permissionType: "microphone" };
gSubDialog.open(
"chrome://browser/content/preferences/dialogs/sitePermissions.xhtml",
{ features: "resizable=yes" },
params
);
},
// SPEAKER
/**
* Displays the speaker exceptions dialog where specific site speaker
* preferences can be set.
*/
showSpeakerExceptions() {
let params = { permissionType: "speaker" };
gSubDialog.open(
"chrome://browser/content/preferences/dialogs/sitePermissions.xhtml",
{ features: "resizable=yes" },
params
);
},
// NOTIFICATIONS
/**
* Displays the notifications exceptions dialog where specific site notification
* preferences can be set.
*/
showNotificationExceptions() {
let params = { permissionType: "desktop-notification" };
gSubDialog.open(
"chrome://browser/content/preferences/dialogs/sitePermissions.xhtml",
{ features: "resizable=yes" },
params
);
},
// MEDIA
showAutoplayMediaExceptions() {
var params = { permissionType: "autoplay-media" };
gSubDialog.open(
"chrome://browser/content/preferences/dialogs/sitePermissions.xhtml",
{ features: "resizable=yes" },
params
);
},
// POP-UPS
/**
* Displays the popup exceptions dialog where specific site popup preferences
* can be set.
*/
showPopupExceptions() {
var params = {
blockVisible: false,
sessionVisible: false,
allowVisible: true,
prefilledHost: "",
permissionType: "popup",
};
gSubDialog.open(
"chrome://browser/content/preferences/dialogs/permissions.xhtml",
{ features: "resizable=yes" },
params
);
},
// UTILITY FUNCTIONS
/**
* Utility function to enable/disable the button specified by aButtonID based
* on the value of the Boolean preference specified by aPreferenceID.
*/
updateButtons(aButtonID, aPreferenceID) {
var button = document.getElementById(aButtonID);
var preference = Preferences.get(aPreferenceID);
button.disabled = !preference.value || preference.locked;
return undefined;
},
// BEGIN UI CODE
/*
* Preferences:
*
* dom.disable_open_during_load
* - true if popups are blocked by default, false otherwise
*/
// POP-UPS
/**
* Displays a dialog in which the user can view and modify the list of sites
* where passwords are never saved.
*/
showPasswordExceptions() {
var params = {
blockVisible: true,
sessionVisible: false,
allowVisible: false,
hideStatusColumn: true,
prefilledHost: "",
permissionType: "login-saving",
};
gSubDialog.open(
"chrome://browser/content/preferences/dialogs/permissions.xhtml",
undefined,
params
);
},
/**
* Initializes master password UI: the "use master password" checkbox, selects
* the master password button to show, and enables/disables it as necessary.
* The master password is controlled by various bits of NSS functionality, so
* the UI for it can't be controlled by the normal preference bindings.
*/
_initMasterPasswordUI() {
var noMP = !LoginHelper.isPrimaryPasswordSet();
var button = document.getElementById("changeMasterPassword");
button.disabled = noMP;
var checkbox = document.getElementById("useMasterPassword");
checkbox.checked = !noMP;
checkbox.disabled =
(noMP && !Services.policies.isAllowed("createMasterPassword")) ||
(!noMP && !Services.policies.isAllowed("removeMasterPassword"));
},
/**
* Enables/disables the master password button depending on the state of the
* "use master password" checkbox, and prompts for master password removal if
* one is set.
*/
async updateMasterPasswordButton() {
var checkbox = document.getElementById("useMasterPassword");
var button = document.getElementById("changeMasterPassword");
button.disabled = !checkbox.checked;
// unchecking the checkbox should try to immediately remove the master
// password, because it's impossible to non-destructively remove the master
// password used to encrypt all the passwords without providing it (by
// design), and it would be extremely odd to pop up that dialog when the
// user closes the prefwindow and saves his settings
if (!checkbox.checked) {
await this._removeMasterPassword();
} else {
await this.changeMasterPassword();
}
this._initMasterPasswordUI();
},
/**
* Displays the "remove master password" dialog to allow the user to remove
* the current master password. When the dialog is dismissed, master password
* UI is automatically updated.
*/
async _removeMasterPassword() {
var secmodDB = Cc["@mozilla.org/security/pkcs11moduledb;1"].getService(
Ci.nsIPKCS11ModuleDB
);
if (secmodDB.isFIPSEnabled) {
let title = document.getElementById("fips-title").textContent;
let desc = document.getElementById("fips-desc").textContent;
Services.prompt.alert(window, title, desc);
this._initMasterPasswordUI();
} else {
gSubDialog.open("chrome://mozapps/content/preferences/removemp.xhtml", {
closingCallback: this._initMasterPasswordUI.bind(this),
});
}
},
/**
* Displays a dialog in which the primary password may be changed.
*/
async changeMasterPassword() {
// Require OS authentication before the user can set a Primary Password.
// OS reauthenticate functionality is not available on Linux yet (bug 1527745)
if (
!LoginHelper.isPrimaryPasswordSet() &&
LoginHelper.getOSAuthEnabled(LoginHelper.OS_AUTH_FOR_PASSWORDS_PREF)
) {
// Uses primary-password-os-auth-dialog-message-win and
// primary-password-os-auth-dialog-message-macosx via concatenation:
let messageId =
"primary-password-os-auth-dialog-message-" + AppConstants.platform;
let [messageText, captionText] = await document.l10n.formatMessages([
{
id: messageId,
},
{
id: "master-password-os-auth-dialog-caption",
},
]);
let win = Services.wm.getMostRecentBrowserWindow();
// Note on Glean collection: because OSKeyStore.ensureLoggedIn() is not wrapped in
// verifyOSAuth(), it will be documenting "success" for unsupported platforms
// and won't record "fail_error", only "fail_user_canceled"
let loggedIn = await OSKeyStore.ensureLoggedIn(
messageText.value,
captionText.value,
win,
false
);
const result = loggedIn.authenticated ? "success" : "fail_user_canceled";
Glean.pwmgr.promptShownOsReauth.record({
trigger: "toggle_pref_primary_password",
result,
});
if (!loggedIn.authenticated) {
return;
}
}
gSubDialog.open("chrome://mozapps/content/preferences/changemp.xhtml", {
features: "resizable=no",
closingCallback: this._initMasterPasswordUI.bind(this),
});
},
/**
* Set up the initial state for the GPC/DNT UI.
* The GPC part should only appear if the functionality is
* enabled.
*/
_initGlobalPrivacyControlUI() {
let gpcEnabledPrefValue = Services.prefs.getBoolPref(
"privacy.globalprivacycontrol.functionality.enabled",
false
);
let dntEnabledPrefValue = Services.prefs.getBoolPref(
"privacy.donottrackheader.enabled",
false
);
document.getElementById("doNotTrackBox").hidden = !dntEnabledPrefValue;
// We can't rely on the hidden attribute for groupboxes because the pane
// hiding/showing code can interfere (and fires after this).
if (gpcEnabledPrefValue) {
document
.getElementById("nonTechnicalPrivacyGroup")
.removeAttribute("style");
} else {
document
.getElementById("nonTechnicalPrivacyGroup")
.setAttribute("style", "display: none !important");
}
},
/**
* Set up the initial state for the password generation UI.
* It will be hidden unless the .available pref is true
*/
_initPasswordGenerationUI() {
// we don't watch the .available pref for runtime changes
let prefValue = Services.prefs.getBoolPref(
PREF_PASSWORD_GENERATION_AVAILABLE,
false
);
document.getElementById("generatePasswordsBox").hidden = !prefValue;
},
toggleRelayIntegration() {
const checkbox = document.getElementById("relayIntegration");
if (checkbox.checked) {
FirefoxRelay.markAsAvailable();
Glean.relayIntegration.enabledPrefChange.record();
} else {
FirefoxRelay.markAsDisabled();
Glean.relayIntegration.disabledPrefChange.record();
}
},
_updateRelayIntegrationUI() {
document.getElementById("relayIntegrationBox").hidden =
!FirefoxRelay.isAvailable;
document.getElementById("relayIntegration").checked =
FirefoxRelay.isAvailable && !FirefoxRelay.isDisabled;
},
_initRelayIntegrationUI() {
document
.getElementById("relayIntegrationLearnMoreLink")
.setAttribute("href", FirefoxRelay.learnMoreUrl);
setEventListener(
"relayIntegration",
"command",
gPrivacyPane.toggleRelayIntegration.bind(gPrivacyPane)
);
Preferences.get("signon.firefoxRelay.feature").on(
"change",
gPrivacyPane._updateRelayIntegrationUI.bind(gPrivacyPane)
);
this._updateRelayIntegrationUI();
},
async _toggleOSAuth() {
let osReauthCheckbox = document.getElementById("osReauthCheckbox");
const messageText = await lazy.AboutLoginsL10n.formatValue(
"about-logins-os-auth-dialog-message"
);
const captionText = await lazy.AboutLoginsL10n.formatValue(
"about-logins-os-auth-dialog-caption"
);
let win =
osReauthCheckbox.ownerGlobal.docShell.chromeEventHandler.ownerGlobal;
// Calling OSKeyStore.ensureLoggedIn() instead of LoginHelper.verifyOSAuth()
// since we want to authenticate user each time this setting is changed.
// Note on Glean collection: because OSKeyStore.ensureLoggedIn() is not wrapped in
// verifyOSAuth(), it will be documenting "success" for unsupported platforms
// and won't record "fail_error", only "fail_user_canceled"
let isAuthorized = (
await OSKeyStore.ensureLoggedIn(messageText, captionText, win, false)
).authenticated;
Glean.pwmgr.promptShownOsReauth.record({
trigger: "toggle_pref_os_auth",
result: isAuthorized ? "success" : "fail_user_canceled",
});
if (!isAuthorized) {
osReauthCheckbox.checked = !osReauthCheckbox.checked;
return;
}
// If osReauthCheckbox is checked enable osauth.
LoginHelper.setOSAuthEnabled(
LoginHelper.OS_AUTH_FOR_PASSWORDS_PREF,
osReauthCheckbox.checked
);
Glean.pwmgr.requireOsReauthToggle.record({
toggle_state: osReauthCheckbox.checked,
});
},
_initOSAuthentication() {
let osReauthCheckbox = document.getElementById("osReauthCheckbox");
if (
!OSKeyStore.canReauth() ||
Services.prefs.getBoolPref("security.nocertdb", false)
) {
osReauthCheckbox.hidden = true;
return;
}
osReauthCheckbox.setAttribute(
"checked",
LoginHelper.getOSAuthEnabled(LoginHelper.OS_AUTH_FOR_PASSWORDS_PREF)
);
setEventListener(
"osReauthCheckbox",
"command",
gPrivacyPane._toggleOSAuth.bind(gPrivacyPane)
);
},
/**
* Shows the sites where the user has saved passwords and the associated login
* information.
*/
showPasswords() {
let loginManager = window.windowGlobalChild.getActor("LoginManager");
loginManager.sendAsyncMessage("PasswordManager:OpenPreferences", {
entryPoint: "Preferences",
});
},
/**
* Enables/disables dependent controls related to password saving
* When password saving is not enabled, we need to also disable the password generation checkbox
* The Exceptions button is used to configure sites where passwords are never saved.
*/
readSavePasswords() {
var prefValue = Preferences.get("signon.rememberSignons").value;
document.getElementById("passwordExceptions").disabled = !prefValue;
document.getElementById("generatePasswords").disabled = !prefValue;
document.getElementById("passwordAutofillCheckbox").disabled = !prefValue;
document.getElementById("relayIntegration").disabled =
!prefValue || Services.prefs.prefIsLocked("signon.firefoxRelay.feature");
// don't override pref value in UI
return undefined;
},
/**
* Initalizes pref listeners for the password manager.
*
* This ensures that the user is always notified if an extension is controlling the password manager.
*/
initListenersForExtensionControllingPasswordManager() {
this._passwordManagerCheckbox = document.getElementById("savePasswords");
this._disableExtensionButton = document.getElementById(
"disablePasswordManagerExtension"
);
this._disableExtensionButton.addEventListener(
"command",
makeDisableControllingExtension(
PREF_SETTING_TYPE,
PASSWORD_MANAGER_PREF_ID
)
);
initListenersForPrefChange(
PREF_SETTING_TYPE,
PASSWORD_MANAGER_PREF_ID,
this._passwordManagerCheckbox
);
},
/**
* Enables/disables the add-ons Exceptions button depending on whether
* or not add-on installation warnings are displayed.
*/
readWarnAddonInstall() {
var warn = Preferences.get("xpinstall.whitelist.required");
var exceptions = document.getElementById("addonExceptions");
exceptions.disabled = !warn.value || warn.locked;
// don't override the preference value
return undefined;
},
_initSafeBrowsing() {
let enableSafeBrowsing = document.getElementById("enableSafeBrowsing");
let blockDownloads = document.getElementById("blockDownloads");
let blockUncommonUnwanted = document.getElementById(
"blockUncommonUnwanted"
);
let safeBrowsingPhishingPref = Preferences.get(
"browser.safebrowsing.phishing.enabled"
);
let safeBrowsingMalwarePref = Preferences.get(
"browser.safebrowsing.malware.enabled"
);
let blockDownloadsPref = Preferences.get(
"browser.safebrowsing.downloads.enabled"
);
let malwareTable = Preferences.get("urlclassifier.malwareTable");
let blockUnwantedPref = Preferences.get(
"browser.safebrowsing.downloads.remote.block_potentially_unwanted"
);
let blockUncommonPref = Preferences.get(
"browser.safebrowsing.downloads.remote.block_uncommon"
);
enableSafeBrowsing.addEventListener("command", function () {
safeBrowsingPhishingPref.value = enableSafeBrowsing.checked;
safeBrowsingMalwarePref.value = enableSafeBrowsing.checked;
blockDownloads.disabled =
!enableSafeBrowsing.checked || blockDownloadsPref.locked;
blockUncommonUnwanted.disabled =
!blockDownloads.checked ||
!enableSafeBrowsing.checked ||
blockUnwantedPref.locked ||
blockUncommonPref.locked;
});
blockDownloads.addEventListener("command", function () {
blockDownloadsPref.value = blockDownloads.checked;
blockUncommonUnwanted.disabled =
!blockDownloads.checked ||
blockUnwantedPref.locked ||
blockUncommonPref.locked;
});
blockUncommonUnwanted.addEventListener("command", function () {
blockUnwantedPref.value = blockUncommonUnwanted.checked;
blockUncommonPref.value = blockUncommonUnwanted.checked;
let malware = malwareTable.value
.split(",")
.filter(
x =>
x !== "goog-unwanted-proto" &&
x !== "goog-unwanted-shavar" &&
x !== "moztest-unwanted-simple"
);
if (blockUncommonUnwanted.checked) {
if (malware.includes("goog-malware-shavar")) {
malware.push("goog-unwanted-shavar");
} else {
malware.push("goog-unwanted-proto");
}
malware.push("moztest-unwanted-simple");
}
// sort alphabetically to keep the pref consistent
malware.sort();
malwareTable.value = malware.join(",");
// Force an update after changing the malware table.
listManager.forceUpdates(malwareTable.value);
});
// set initial values
enableSafeBrowsing.checked =
safeBrowsingPhishingPref.value && safeBrowsingMalwarePref.value;
if (!enableSafeBrowsing.checked) {
blockDownloads.setAttribute("disabled", "true");
blockUncommonUnwanted.setAttribute("disabled", "true");
}
blockDownloads.checked = blockDownloadsPref.value;
if (!blockDownloadsPref.value) {
blockUncommonUnwanted.setAttribute("disabled", "true");
}
blockUncommonUnwanted.checked =
blockUnwantedPref.value && blockUncommonPref.value;
if (safeBrowsingPhishingPref.locked || safeBrowsingMalwarePref.locked) {
enableSafeBrowsing.disabled = true;
}
if (blockDownloadsPref.locked) {
blockDownloads.disabled = true;
}
if (blockUnwantedPref.locked || blockUncommonPref.locked) {
blockUncommonUnwanted.disabled = true;
}
},
/**
* Displays the exceptions lists for add-on installation warnings.
*/
showAddonExceptions() {
var params = this._addonParams;
gSubDialog.open(
"chrome://browser/content/preferences/dialogs/permissions.xhtml",
undefined,
params
);
},
/**
* Parameters for the add-on install permissions dialog.
*/
_addonParams: {
blockVisible: false,
sessionVisible: false,
allowVisible: true,
prefilledHost: "",
permissionType: "install",
},
/**
* readEnableOCSP is used by the preferences UI to determine whether or not
* the checkbox for OCSP fetching should be checked (it returns true if it
* should be checked and false otherwise). The about:config preference
* "security.OCSP.enabled" is an integer rather than a boolean, so it can't be
* directly mapped from {true,false} to {checked,unchecked}. The possible
* values for "security.OCSP.enabled" are:
* 0: fetching is disabled
* 1: fetch for all certificates
* 2: fetch only for EV certificates
* Hence, if "security.OCSP.enabled" is non-zero, the checkbox should be
* checked. Otherwise, it should be unchecked.
*/
readEnableOCSP() {
var preference = Preferences.get("security.OCSP.enabled");
// This is the case if the preference is the default value.
if (preference.value === undefined) {
return true;
}
return preference.value != 0;
},
/**
* writeEnableOCSP is used by the preferences UI to map the checked/unchecked
* state of the OCSP fetching checkbox to the value that the preference
* "security.OCSP.enabled" should be set to (it returns that value). See the
* readEnableOCSP documentation for more background. We unfortunately don't
* have enough information to map from {true,false} to all possible values for
* "security.OCSP.enabled", but a reasonable alternative is to map from
* {true,false} to {<the default value>,0}. That is, if the box is checked,
* "security.OCSP.enabled" will be set to whatever default it should be, given
* the platform and channel. If the box is unchecked, the preference will be
* set to 0. Obviously this won't work if the default is 0, so we will have to
* revisit this if we ever set it to 0.
*/
writeEnableOCSP() {
var checkbox = document.getElementById("enableOCSP");
var defaults = Services.prefs.getDefaultBranch(null);
var defaultValue = defaults.getIntPref("security.OCSP.enabled");
return checkbox.checked ? defaultValue : 0;
},
/**
* Displays the user's certificates and associated options.
*/
showCertificates() {
gSubDialog.open("chrome://pippki/content/certManager.xhtml");
},
/**
* Displays a dialog from which the user can manage his security devices.
*/
showSecurityDevices() {
gSubDialog.open("chrome://pippki/content/device_manager.xhtml");
},
initDataCollection() {
if (
!AppConstants.MOZ_DATA_REPORTING &&
!Services.prefs.getBoolPref(
"browser.privacySegmentation.preferences.show"
)
) {
// Nothing to control in the data collection section, remove it.
document.getElementById("dataCollectionCategory").remove();
document.getElementById("dataCollectionGroup").remove();
return;
}
this._setupLearnMoreLink(
"toolkit.datacollection.infoURL",
"dataCollectionPrivacyNotice"
);
this.initPrivacySegmentation();
},
initPrivacySegmentation() {
// Section visibility
let section = document.getElementById("privacySegmentationSection");
let updatePrivacySegmentationSectionVisibilityState = () => {
section.hidden = !Services.prefs.getBoolPref(
"browser.privacySegmentation.preferences.show"
);
};
Services.prefs.addObserver(
"browser.privacySegmentation.preferences.show",
updatePrivacySegmentationSectionVisibilityState
);
window.addEventListener("unload", () => {
Services.prefs.removeObserver(
"browser.privacySegmentation.preferences.show",
updatePrivacySegmentationSectionVisibilityState
);
});
updatePrivacySegmentationSectionVisibilityState();
},
/**
* Set up or hide the Learn More links for various data collection options
*/
_setupLearnMoreLink(pref, element) {
// set up the Learn More link with the correct URL
let url = Services.urlFormatter.formatURLPref(pref);
let el = document.getElementById(element);
if (url) {
el.setAttribute("href", url);
} else {
el.hidden = true;
}
},
/**
* Update the health report service checkbox from preference.
*/
updateSubmitHealthReportFromPref() {
let checkbox = document.getElementById("submitHealthReportBox");
let telemetryContainer = document.getElementById("telemetry-container");
// Telemetry is only sending data if MOZ_TELEMETRY_REPORTING is defined.
// We still want to display the preferences panel if that's not the case, but
// we want it to be disabled and unchecked.
if (
Services.prefs.prefIsLocked(PREF_UPLOAD_ENABLED) ||
!AppConstants.MOZ_TELEMETRY_REPORTING
) {
checkbox.setAttribute("disabled", "true");
return;
}
checkbox.checked =
Services.prefs.getBoolPref(PREF_UPLOAD_ENABLED) &&
AppConstants.MOZ_TELEMETRY_REPORTING;
telemetryContainer.hidden = checkbox.checked;
},
/**
* Update the health report preference with state from checkbox.
*/
updateSubmitHealthReportToPref() {
let checkbox = document.getElementById("submitHealthReportBox");
let telemetryContainer = document.getElementById("telemetry-container");
Services.prefs.setBoolPref(PREF_UPLOAD_ENABLED, checkbox.checked);
telemetryContainer.hidden = checkbox.checked;
},
/**
* Initialize the opt-out-study preference checkbox into about:preferences and
* handles events coming from the UI for it.
*/
initOptOutStudyCheckbox() {
// The checkbox should be disabled if any of the below are true. This
// prevents the user from changing the value in the box.
//
// * the policy forbids shield
// * Normandy is disabled
//
// The checkbox should match the value of the preference only if all of
// these are true. Otherwise, the checkbox should remain unchecked. This
// is because in these situations, Shield studies are always disabled, and
// so showing a checkbox would be confusing.
//
// * the policy allows Shield
// * Normandy is enabled
const allowedByPolicy = Services.policies.isAllowed("Shield");
const checkbox = document.getElementById("optOutStudiesEnabled");
function updateCheckbox() {
if (
allowedByPolicy &&
Services.prefs.getBoolPref(PREF_UPLOAD_ENABLED, false) &&
Services.prefs.getBoolPref(PREF_NORMANDY_ENABLED, false)
) {
if (Services.prefs.getBoolPref(PREF_OPT_OUT_STUDIES_ENABLED, false)) {
checkbox.setAttribute("checked", "true");
} else {
checkbox.removeAttribute("checked");
}
checkbox.setAttribute("preference", PREF_OPT_OUT_STUDIES_ENABLED);
checkbox.removeAttribute("disabled");
} else {
checkbox.removeAttribute("preference");
checkbox.removeAttribute("checked");
checkbox.setAttribute("disabled", "true");
}
}
Preferences.get(PREF_UPLOAD_ENABLED).on("change", updateCheckbox);
updateCheckbox();
},
initAddonRecommendationsCheckbox() {
// Setup the checkbox.
dataCollectionCheckboxHandler({
checkbox: document.getElementById("addonRecommendationEnabled"),
pref: PREF_ADDON_RECOMMENDATIONS_ENABLED,
});
},
initPrivateAttributionCheckbox() {
dataCollectionCheckboxHandler({
checkbox: document.getElementById("privateAttribution"),
pref: PREF_PRIVATE_ATTRIBUTION_ENABLED,
matchPref() {
return AppConstants.MOZ_TELEMETRY_REPORTING;
},
isDisabled() {
return !AppConstants.MOZ_TELEMETRY_REPORTING;
},
});
},
observe(aSubject, aTopic) {
switch (aTopic) {
case "sitedatamanager:updating-sites":
// While updating, we want to disable this section and display loading message until updated
this.toggleSiteData(false);
this.showSiteDataLoading();
break;
case "sitedatamanager:sites-updated":
this.toggleSiteData(true);
SiteDataManager.getTotalUsage().then(
this.updateTotalDataSizeLabel.bind(this)
);
break;
case "network:trr-uri-changed":
case "network:trr-mode-changed":
case "network:trr-confirmation":
gPrivacyPane.updateDoHStatus();
break;
}
},
_initProfilesInfo() {
setEventListener(
"dataCollectionViewProfiles",
"click",
gMainPane.manageProfiles
);
let listener = () => gPrivacyPane.updateProfilesPrivacyInfo();
SelectableProfileService.on("enableChanged", listener);
window.addEventListener("unload", () =>
SelectableProfileService.off("enableChanged", listener)
);
this.updateProfilesPrivacyInfo();
},
updateProfilesPrivacyInfo() {
let profilesInfo = document.getElementById("preferences-privacy-profiles");
profilesInfo.hidden = !SelectableProfileService.isEnabled;
},
};
|