mirror of
https://github.com/electron/electron.git
synced 2026-02-26 03:01:17 -05:00
Compare commits
656 Commits
v6.1.10
...
v7.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
601c3f97ea | ||
|
|
d01a8eaa39 | ||
|
|
54e1c11b2b | ||
|
|
c1ad66b104 | ||
|
|
a905259646 | ||
|
|
356045ff57 | ||
|
|
a9f69bf732 | ||
|
|
3e181b8efc | ||
|
|
171c76e3cb | ||
|
|
0299f69fd1 | ||
|
|
0bdb7b164c | ||
|
|
ea9cfc127c | ||
|
|
0afb1a8188 | ||
|
|
f154dbda40 | ||
|
|
c3013d2e9f | ||
|
|
3272564eac | ||
|
|
a0f4632461 | ||
|
|
8ddf837d49 | ||
|
|
9822953d31 | ||
|
|
c6061cce41 | ||
|
|
a9602682c5 | ||
|
|
b7e5213afc | ||
|
|
9b70d9aa68 | ||
|
|
d9bfac32e3 | ||
|
|
9e815afc02 | ||
|
|
47a38daee2 | ||
|
|
cde79501e3 | ||
|
|
51ce3e5a83 | ||
|
|
d6605193a1 | ||
|
|
69646f4258 | ||
|
|
e74daf2d19 | ||
|
|
af3316707f | ||
|
|
6e367dab9a | ||
|
|
38c918ed5c | ||
|
|
9ab3ec080f | ||
|
|
42a483ad27 | ||
|
|
c06007175f | ||
|
|
aaca9011ae | ||
|
|
33d1e87163 | ||
|
|
71b1b69339 | ||
|
|
ceb64b3b1b | ||
|
|
9da1251dbc | ||
|
|
c1d7d60ca2 | ||
|
|
8a33118e36 | ||
|
|
4838bd7834 | ||
|
|
5e930bf940 | ||
|
|
2983701c75 | ||
|
|
0732da1b4a | ||
|
|
4e0e615406 | ||
|
|
c9a455ea49 | ||
|
|
00a1f4395b | ||
|
|
6c9d40ec33 | ||
|
|
50c7eb58a1 | ||
|
|
c6bcf49acc | ||
|
|
5aa1385cfc | ||
|
|
db3cf52add | ||
|
|
12bbbef688 | ||
|
|
48f2807473 | ||
|
|
504407c5df | ||
|
|
4d23b9e031 | ||
|
|
dc5574cbde | ||
|
|
636dd38164 | ||
|
|
d50298ed96 | ||
|
|
2a5d40617a | ||
|
|
16011cacef | ||
|
|
4639c68a7b | ||
|
|
44efaea6d5 | ||
|
|
bdd626f57a | ||
|
|
477661d0e4 | ||
|
|
8028c57b42 | ||
|
|
0f5cb7995f | ||
|
|
e58f8a79ee | ||
|
|
6b7c66aa04 | ||
|
|
49096c2359 | ||
|
|
65648756b5 | ||
|
|
f6fb877de9 | ||
|
|
539078f281 | ||
|
|
86c2ea1cb8 | ||
|
|
95977291f7 | ||
|
|
bd526f97a5 | ||
|
|
6d83eaaf4b | ||
|
|
a46e459595 | ||
|
|
2132fdfa28 | ||
|
|
60821c8ab0 | ||
|
|
cf2103d6e9 | ||
|
|
1d06f67672 | ||
|
|
637cfdd9a0 | ||
|
|
62e6957f68 | ||
|
|
9dfc4eb2ff | ||
|
|
898adbce5c | ||
|
|
a25b15bc2a | ||
|
|
d11d222da2 | ||
|
|
9910507bc4 | ||
|
|
358f4eebae | ||
|
|
9a7276dffc | ||
|
|
b7f554f1dc | ||
|
|
bb90a36701 | ||
|
|
ad6fb20486 | ||
|
|
b3fb7497c2 | ||
|
|
103b38650f | ||
|
|
2c383b51c1 | ||
|
|
2e3d757f46 | ||
|
|
38507974d6 | ||
|
|
5dcac23aea | ||
|
|
384ba8da64 | ||
|
|
13c152717f | ||
|
|
eb6660f534 | ||
|
|
d45694dcb0 | ||
|
|
6ff2d69842 | ||
|
|
3395a1d4db | ||
|
|
0490189531 | ||
|
|
526f9d442d | ||
|
|
6e55b81c56 | ||
|
|
0c0197a0ef | ||
|
|
1f2f1fb82d | ||
|
|
42d4c579c3 | ||
|
|
e389fa75ea | ||
|
|
dc30b86377 | ||
|
|
1edbd30987 | ||
|
|
8fc38ed549 | ||
|
|
6fc648cd25 | ||
|
|
2467350180 | ||
|
|
9711fc895e | ||
|
|
d82e7af9be | ||
|
|
90684bd5b1 | ||
|
|
3ee95cf0e8 | ||
|
|
e510816cf6 | ||
|
|
afa5266c7e | ||
|
|
fbcbdb051b | ||
|
|
478360f317 | ||
|
|
c79613b037 | ||
|
|
134d76dcdd | ||
|
|
7b69730e82 | ||
|
|
8452a7ffa5 | ||
|
|
d1c9f5e309 | ||
|
|
b57e623c11 | ||
|
|
70857e9a5d | ||
|
|
42f283c281 | ||
|
|
3ded946686 | ||
|
|
c5e249b85c | ||
|
|
b5f69e0b9f | ||
|
|
355b307618 | ||
|
|
3d2eb8360a | ||
|
|
9a7426dc25 | ||
|
|
4d547bdd3a | ||
|
|
27599a851f | ||
|
|
7249b25868 | ||
|
|
aa211c6c50 | ||
|
|
da672a3b5c | ||
|
|
4439249617 | ||
|
|
50f4977048 | ||
|
|
f6a29707b6 | ||
|
|
0db6789210 | ||
|
|
bd50115bfe | ||
|
|
b49ca7ba2e | ||
|
|
6d5e494782 | ||
|
|
d0ece2bc93 | ||
|
|
2ce68df27a | ||
|
|
c9bc4aeb90 | ||
|
|
f101c72cbe | ||
|
|
a4cffd29b7 | ||
|
|
1ff2704445 | ||
|
|
8a57fe5466 | ||
|
|
3957a791b7 | ||
|
|
4d8a05568b | ||
|
|
ab8b940151 | ||
|
|
079a173a72 | ||
|
|
e6e94fc59d | ||
|
|
32fec3e8f9 | ||
|
|
150a92d093 | ||
|
|
beb996b847 | ||
|
|
9a42ddd2b8 | ||
|
|
35294891ae | ||
|
|
e26f366405 | ||
|
|
75a020e0ac | ||
|
|
c756b955b3 | ||
|
|
79114ff40a | ||
|
|
6d34314457 | ||
|
|
0dbeb49ee0 | ||
|
|
1f70dfbffd | ||
|
|
06d48514c6 | ||
|
|
692df804cf | ||
|
|
8b31953d40 | ||
|
|
faa2710485 | ||
|
|
015e1348e0 | ||
|
|
e3440f1975 | ||
|
|
62a3666773 | ||
|
|
fdbb97e876 | ||
|
|
b32bee5d84 | ||
|
|
436d5c9ac1 | ||
|
|
d79e6bbffe | ||
|
|
a90306876e | ||
|
|
419ce494e9 | ||
|
|
c3ae476deb | ||
|
|
a04a458156 | ||
|
|
550b2269be | ||
|
|
69369cf365 | ||
|
|
949f8685d2 | ||
|
|
09c3277b42 | ||
|
|
e6a7a84834 | ||
|
|
106cc6189c | ||
|
|
269a93177d | ||
|
|
731edbe2b6 | ||
|
|
acdb290469 | ||
|
|
87b1dab497 | ||
|
|
c933d19a1b | ||
|
|
2a3793485f | ||
|
|
4b674c1daf | ||
|
|
5a1b661f42 | ||
|
|
e6108740c0 | ||
|
|
da64fae690 | ||
|
|
43b4a3ae6a | ||
|
|
d362be5cd9 | ||
|
|
ae01a48fca | ||
|
|
d1292833e9 | ||
|
|
8782d06ed6 | ||
|
|
de072c6ef5 | ||
|
|
69ea0b4ebf | ||
|
|
50b9c7051e | ||
|
|
9bef48216f | ||
|
|
616856552f | ||
|
|
c2d78deeca | ||
|
|
39c4a5411d | ||
|
|
9a4e551c8b | ||
|
|
dee331519c | ||
|
|
4e2990d3aa | ||
|
|
21d04ed3f4 | ||
|
|
5154b95447 | ||
|
|
5a3073128c | ||
|
|
c7da54e82a | ||
|
|
3173b66d00 | ||
|
|
3038846f5d | ||
|
|
3859244a79 | ||
|
|
cc223d7cd2 | ||
|
|
f62d9f1411 | ||
|
|
0348b60a34 | ||
|
|
684d1838f9 | ||
|
|
6ece477779 | ||
|
|
e03a40026a | ||
|
|
6eed4a98ce | ||
|
|
1d8e16bc6e | ||
|
|
23b8c9c917 | ||
|
|
769dcce9d7 | ||
|
|
a4f61565c3 | ||
|
|
e44bb8474b | ||
|
|
0a9438dbba | ||
|
|
127d617db5 | ||
|
|
1a6a16e346 | ||
|
|
ec8697bcdc | ||
|
|
fdb2502a19 | ||
|
|
e8e360a902 | ||
|
|
819cebff5d | ||
|
|
c1ad0725d8 | ||
|
|
6243dba068 | ||
|
|
d643921313 | ||
|
|
5298358b72 | ||
|
|
2b3a256647 | ||
|
|
c87394ee25 | ||
|
|
ab5ec0af33 | ||
|
|
dc2cd8e780 | ||
|
|
24ffc3cfb0 | ||
|
|
99e3de56df | ||
|
|
1304f259cc | ||
|
|
ed5c624b08 | ||
|
|
764be844ec | ||
|
|
fb01c94511 | ||
|
|
5686a0713e | ||
|
|
1cd7c21f38 | ||
|
|
a084093d73 | ||
|
|
79ac99c09b | ||
|
|
e8c8328081 | ||
|
|
792f6b246c | ||
|
|
bef9610f6a | ||
|
|
81497c7f2e | ||
|
|
236d552d6a | ||
|
|
57c099d8b8 | ||
|
|
7e5ea179a1 | ||
|
|
536327151d | ||
|
|
e95d2129be | ||
|
|
c27231ce5c | ||
|
|
6251a6d307 | ||
|
|
f3f2990b9e | ||
|
|
23286fe557 | ||
|
|
dca583a77f | ||
|
|
34c4c8d508 | ||
|
|
8c4496a9c9 | ||
|
|
56930338e8 | ||
|
|
2160c1fcc9 | ||
|
|
d7f07e8a80 | ||
|
|
4575a4aae3 | ||
|
|
257fd2c0df | ||
|
|
aa522731a2 | ||
|
|
5247fe6038 | ||
|
|
5cb25c27b0 | ||
|
|
f8f0540487 | ||
|
|
ee01810395 | ||
|
|
79f0c444fd | ||
|
|
7201845894 | ||
|
|
504edf2cf6 | ||
|
|
0146cc0eb5 | ||
|
|
00d18917d0 | ||
|
|
ae49aa4a03 | ||
|
|
98bc0ae7ee | ||
|
|
edb56500c7 | ||
|
|
450aa33775 | ||
|
|
a0b2810640 | ||
|
|
a42ed950ca | ||
|
|
c720803413 | ||
|
|
b98c1d0472 | ||
|
|
d5811607eb | ||
|
|
3f7cce6d8c | ||
|
|
1aac7ac9d0 | ||
|
|
ccd15fc12e | ||
|
|
0af3548b55 | ||
|
|
4dc38d39e9 | ||
|
|
c9bca78a7a | ||
|
|
5a08522b98 | ||
|
|
deebde66f9 | ||
|
|
632bbf948d | ||
|
|
77d5e0c1ef | ||
|
|
8959c98251 | ||
|
|
1d6e5e6e70 | ||
|
|
7d0a93858d | ||
|
|
d59689b170 | ||
|
|
d77159a19e | ||
|
|
370e9522b4 | ||
|
|
4ef8de69ef | ||
|
|
3309005325 | ||
|
|
441857c6e7 | ||
|
|
0a9df1e37d | ||
|
|
7b26048d9e | ||
|
|
45f5f2ba1a | ||
|
|
d9215dd4ce | ||
|
|
0bdc05bf24 | ||
|
|
83c3f71980 | ||
|
|
44ea7ab093 | ||
|
|
bfcce8aa27 | ||
|
|
ffb53405fb | ||
|
|
6e327184bd | ||
|
|
da58ac7c20 | ||
|
|
29decbdd4d | ||
|
|
390e7f5719 | ||
|
|
5e320291b4 | ||
|
|
9856e5df3b | ||
|
|
ac02ab9fde | ||
|
|
7c76d0e34a | ||
|
|
f98454e5dd | ||
|
|
ddec3c0e78 | ||
|
|
ba96cdb7dc | ||
|
|
ec10fd3044 | ||
|
|
292a240e1b | ||
|
|
5317211b0b | ||
|
|
0bf83b7183 | ||
|
|
0e3ab7c128 | ||
|
|
e5d1e7b4da | ||
|
|
81ad355355 | ||
|
|
3a1d6d2ce1 | ||
|
|
c6dc7d5b79 | ||
|
|
af108764c7 | ||
|
|
4321df13f2 | ||
|
|
64f7974252 | ||
|
|
605cd9bec9 | ||
|
|
54449d044d | ||
|
|
ad54d38678 | ||
|
|
bb19142389 | ||
|
|
a9f601612f | ||
|
|
b10c946564 | ||
|
|
abab90f563 | ||
|
|
b30484d3a9 | ||
|
|
8da17ffe37 | ||
|
|
8330507efd | ||
|
|
eec12b399a | ||
|
|
4b9da4dd0e | ||
|
|
a45afddb75 | ||
|
|
0fc172fcaf | ||
|
|
7d326f6bc5 | ||
|
|
291ee2dafc | ||
|
|
bd80e68698 | ||
|
|
796d2636e6 | ||
|
|
aa030f9fd5 | ||
|
|
a0b1f4fe0b | ||
|
|
164cc43440 | ||
|
|
9e8bd433df | ||
|
|
ed5fb4a720 | ||
|
|
f80601da16 | ||
|
|
69e32ad9ce | ||
|
|
74825e4df7 | ||
|
|
d008d217f9 | ||
|
|
641e1d6587 | ||
|
|
d1371c5dd0 | ||
|
|
24b3d66767 | ||
|
|
901cdb22e3 | ||
|
|
cf628d9287 | ||
|
|
3c8acf3687 | ||
|
|
b4276835d8 | ||
|
|
cec61d010b | ||
|
|
cb4579fe28 | ||
|
|
8b5473c170 | ||
|
|
4feb769378 | ||
|
|
fd9e031f0d | ||
|
|
0ee2f8a64a | ||
|
|
477b09db3e | ||
|
|
911cdd809a | ||
|
|
7f369c3292 | ||
|
|
eedbdedef9 | ||
|
|
0b25176893 | ||
|
|
52c76d737a | ||
|
|
4cb6be453a | ||
|
|
18acda7888 | ||
|
|
449d2752f2 | ||
|
|
bc527f6b51 | ||
|
|
a19e55a902 | ||
|
|
9187759460 | ||
|
|
04dd52e4dc | ||
|
|
90caedb552 | ||
|
|
87ae9324ac | ||
|
|
26155c8a00 | ||
|
|
81366b5bfb | ||
|
|
c436997840 | ||
|
|
b180fb376c | ||
|
|
ab70e854f8 | ||
|
|
a31faaae61 | ||
|
|
1e3e5a6619 | ||
|
|
ac35f41e8d | ||
|
|
554ee92b39 | ||
|
|
02dc1b266c | ||
|
|
81ba491e53 | ||
|
|
09d544f6ad | ||
|
|
a1226d75ff | ||
|
|
2dbd2c07e4 | ||
|
|
f4c792d014 | ||
|
|
babe2b68fb | ||
|
|
9af5072115 | ||
|
|
96371b6d75 | ||
|
|
3d8db573d9 | ||
|
|
f5b3d00b47 | ||
|
|
471d457576 | ||
|
|
03a02b8d6c | ||
|
|
93b8dc2362 | ||
|
|
815b9d7707 | ||
|
|
1a609f0caf | ||
|
|
2923ae8b03 | ||
|
|
0e2dedaf4e | ||
|
|
96b32a814c | ||
|
|
c621615112 | ||
|
|
1688ebdd40 | ||
|
|
01cd6e7a06 | ||
|
|
43f8a7ef00 | ||
|
|
af8d4e1bc5 | ||
|
|
00964b98b9 | ||
|
|
c0c5ebb271 | ||
|
|
ac002b3c3c | ||
|
|
4ed989587b | ||
|
|
cfd4eace42 | ||
|
|
723625c065 | ||
|
|
a6637fbce9 | ||
|
|
cbc177708e | ||
|
|
54cbe5f749 | ||
|
|
646f572b77 | ||
|
|
d57df5a4a1 | ||
|
|
c4147aed3f | ||
|
|
4604985b2e | ||
|
|
842830d709 | ||
|
|
53954494a9 | ||
|
|
e32cf5c418 | ||
|
|
f8ab48adac | ||
|
|
68dbef48da | ||
|
|
b48dd6a11c | ||
|
|
05e986816e | ||
|
|
72b1c01836 | ||
|
|
8f200595ba | ||
|
|
aea042cc83 | ||
|
|
87a337a536 | ||
|
|
9e9d0c3435 | ||
|
|
2fcb785d3e | ||
|
|
4f6d24026d | ||
|
|
7d212b17f8 | ||
|
|
e56adafc1f | ||
|
|
ec3a4cea6a | ||
|
|
da98beac54 | ||
|
|
e1a2cc7f36 | ||
|
|
287345c778 | ||
|
|
12f95429bf | ||
|
|
a5e6e957cf | ||
|
|
5b507cc562 | ||
|
|
e96f9c06f0 | ||
|
|
79f62cc1aa | ||
|
|
ca283c74c9 | ||
|
|
446944c677 | ||
|
|
75609f784c | ||
|
|
a8ff6899d4 | ||
|
|
1941a46825 | ||
|
|
e39c76bfe1 | ||
|
|
1a2ab11c90 | ||
|
|
c832533f5f | ||
|
|
e73a0e6cc6 | ||
|
|
d1207e9d8f | ||
|
|
b7357d5750 | ||
|
|
f106ea0029 | ||
|
|
286fdaa53c | ||
|
|
204e3808d2 | ||
|
|
e81afed66d | ||
|
|
cac50608d6 | ||
|
|
340014a9d3 | ||
|
|
c1cccfc082 | ||
|
|
9c21c66b97 | ||
|
|
5a7b56b042 | ||
|
|
dbb8617214 | ||
|
|
623ea9b0f1 | ||
|
|
89105e7e57 | ||
|
|
24d06c4725 | ||
|
|
7e2cbf528e | ||
|
|
af0ad4454e | ||
|
|
0af06a3136 | ||
|
|
2b4ad2cb09 | ||
|
|
cf5224140b | ||
|
|
aa00b19c92 | ||
|
|
e38127323f | ||
|
|
7a0058fbdb | ||
|
|
8a7de89b97 | ||
|
|
2d14a0e90d | ||
|
|
18d70e6e57 | ||
|
|
03ee12d13e | ||
|
|
cae2f1f537 | ||
|
|
0580a2fb3e | ||
|
|
941851b3eb | ||
|
|
1fa5bf0140 | ||
|
|
19550bd444 | ||
|
|
6f0524d87f | ||
|
|
6c6555c13c | ||
|
|
e794260d89 | ||
|
|
f14eb32758 | ||
|
|
111baba29c | ||
|
|
c7d93c7579 | ||
|
|
76783e2a90 | ||
|
|
2a08bfbcc6 | ||
|
|
2ad62cedc3 | ||
|
|
fde3137b90 | ||
|
|
d027be05a6 | ||
|
|
6609138959 | ||
|
|
23b0487e9b | ||
|
|
367868613f | ||
|
|
78d45a17c8 | ||
|
|
3a5e6f2551 | ||
|
|
326215e1f1 | ||
|
|
85c24c0b47 | ||
|
|
8de9ba6df6 | ||
|
|
019b31d084 | ||
|
|
96e19f1cc4 | ||
|
|
be484ee8a4 | ||
|
|
b3fcc080d5 | ||
|
|
8759e30f04 | ||
|
|
6e29611788 | ||
|
|
6770a8c64a | ||
|
|
e63f527e76 | ||
|
|
0ab3d7a0be | ||
|
|
d79dc056bc | ||
|
|
02710ef574 | ||
|
|
cfb6e847a0 | ||
|
|
91e3421525 | ||
|
|
175fae722a | ||
|
|
237f74a01f | ||
|
|
a96b6e2c96 | ||
|
|
9ec59cbc6c | ||
|
|
636273b6cb | ||
|
|
99d4537075 | ||
|
|
cb13d7a0a8 | ||
|
|
6d96f30ed3 | ||
|
|
0755857a0c | ||
|
|
c25c31e018 | ||
|
|
a59dc56fa6 | ||
|
|
0a6eb8afca | ||
|
|
cc00fa8874 | ||
|
|
4808f30538 | ||
|
|
c278043511 | ||
|
|
5f28f89c9c | ||
|
|
55a7f92297 | ||
|
|
2dd108e9c9 | ||
|
|
9585818a90 | ||
|
|
8785e9007c | ||
|
|
d507ba68a7 | ||
|
|
d4f5ebefe6 | ||
|
|
649d7c0d9e | ||
|
|
3949f0bd50 | ||
|
|
493af7f84c | ||
|
|
e736d04e7f | ||
|
|
f316c8470c | ||
|
|
61effac72a | ||
|
|
dd3913fada | ||
|
|
913bd4c832 | ||
|
|
496d796833 | ||
|
|
1abe658ef4 | ||
|
|
d2cebc62d1 | ||
|
|
b333ce2628 | ||
|
|
5ed11aa1f3 | ||
|
|
6f5c850d60 | ||
|
|
aebad6fd21 | ||
|
|
2616911f7a | ||
|
|
00358545a9 | ||
|
|
67b3fbca89 | ||
|
|
4e5a0946c7 | ||
|
|
24bf2c29e4 | ||
|
|
98c51dd660 | ||
|
|
8d83518f9a | ||
|
|
f2d41b7812 | ||
|
|
fcf0af15de | ||
|
|
d87b3ead76 | ||
|
|
fdf5f838f4 | ||
|
|
e9d88e965e | ||
|
|
277f93653e | ||
|
|
7b55ee9d36 | ||
|
|
4ee201c56e | ||
|
|
4a3771ff7f | ||
|
|
cc1e8ecef6 | ||
|
|
2fd3029040 | ||
|
|
77a4946069 | ||
|
|
8b79776b5e | ||
|
|
9714a91392 | ||
|
|
7574f91f31 | ||
|
|
18b77a4de6 | ||
|
|
6f83977f47 | ||
|
|
fe618631f1 | ||
|
|
72baff1c88 | ||
|
|
e7ef374899 | ||
|
|
68f448ee73 | ||
|
|
84212b8e8b | ||
|
|
d673865881 | ||
|
|
2e7ad1a527 | ||
|
|
a4fcc32799 | ||
|
|
e1acfffaf8 | ||
|
|
075b818a8e | ||
|
|
6530c99cfa | ||
|
|
2108044bdb | ||
|
|
c2c3a04628 | ||
|
|
2ad942323c | ||
|
|
a2e5cb82fc | ||
|
|
3142d5ca00 | ||
|
|
93d9dafacc | ||
|
|
02c7b92095 | ||
|
|
aed0b1ee54 | ||
|
|
4588fc2232 | ||
|
|
f7a38ec72a | ||
|
|
4556433f3b | ||
|
|
253d049ac9 | ||
|
|
9b779657fb | ||
|
|
e1e055a837 | ||
|
|
53c453567f | ||
|
|
132137081a | ||
|
|
341592119f | ||
|
|
bb9e92a5d9 | ||
|
|
0b0f677432 | ||
|
|
316abe21f9 | ||
|
|
e9114b3c00 | ||
|
|
df269ecb24 | ||
|
|
0c24ac9ae7 | ||
|
|
716cb28430 |
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,3 @@
|
||||
*
|
||||
!tools/xvfb-init.sh
|
||||
!tools/run-electron.sh
|
||||
!build/install-build-deps.sh
|
||||
|
||||
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -1,4 +1,3 @@
|
||||
# `git apply` and friends don't understand CRLF, even on windows. Force those
|
||||
# files to be checked out with LF endings even if core.autocrlf is true.
|
||||
*.patch text eol=lf
|
||||
patches/**/.patches merge=union
|
||||
|
||||
5
.github/CODEOWNERS
vendored
5
.github/CODEOWNERS
vendored
@@ -11,12 +11,11 @@
|
||||
|
||||
# Upgrades WG
|
||||
/patches/ @electron/wg-upgrades
|
||||
DEPS @electron/wg-upgrades
|
||||
|
||||
|
||||
# Docs & Tooling WG
|
||||
/default_app/ @electron/wg-docs-tools
|
||||
/default_app/ @electron/wg-docs-tools
|
||||
/docs/ @electron/wg-docs-tools
|
||||
|
||||
# Releases WG
|
||||
/npm/ @electron/wg-releases
|
||||
/script/release @electron/wg-releases
|
||||
10
.github/ISSUE_TEMPLATE/Bug_report.md
vendored
10
.github/ISSUE_TEMPLATE/Bug_report.md
vendored
@@ -20,7 +20,7 @@ about: Create a report to help us improve Electron
|
||||
* <!-- (output of `node_modules/.bin/electron --version`) e.g. 4.0.3 -->
|
||||
* **Operating System:**
|
||||
* <!-- (Platform and Version) e.g. macOS 10.13.6 / Windows 10 (1803) / Ubuntu 18.04 x64 -->
|
||||
* **Last Known Working Electron version:**:
|
||||
* **Last Known Working Electron version:**
|
||||
* <!-- (if applicable) e.g. 3.1.0 -->
|
||||
|
||||
### Expected Behavior
|
||||
@@ -31,11 +31,15 @@ about: Create a report to help us improve Electron
|
||||
|
||||
### To Reproduce
|
||||
<!--
|
||||
Your best chance of getting this bug looked at quickly is to provide a REPOSITORY that can be cloned and run.
|
||||
Your best chance of getting this bug looked at quickly is to provide an example.
|
||||
-->
|
||||
|
||||
<!--
|
||||
You can fork electron-quick-start (https://github.com/electron/electron-quick-start) and include a link to the branch with your changes.
|
||||
For bugs that can be encapsulated in a small experiment, you can use Electron Fiddle (https://github.com/electron/fiddle) to publish your example to a GitHub Gist and link it your bug report.
|
||||
-->
|
||||
|
||||
<!--
|
||||
If Fiddle is insufficient to produce an example, please provide an example REPOSITORY that can be cloned and run. You can fork electron-quick-start (https://github.com/electron/electron-quick-start) and include a link to the branch with your changes.
|
||||
-->
|
||||
|
||||
<!--
|
||||
|
||||
10
.github/main.workflow
vendored
Normal file
10
.github/main.workflow
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
workflow "Clerk" {
|
||||
#TODO(codebytere): make this work properly on pull_request
|
||||
on = "repository_dispatch"
|
||||
resolves = "Check release notes"
|
||||
}
|
||||
|
||||
action "Check release notes" {
|
||||
uses = "electron/clerk@master"
|
||||
secrets = [ "GITHUB_TOKEN" ]
|
||||
}
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -62,3 +62,6 @@ spec/.hash
|
||||
|
||||
# If someone runs tsc this is where stuff will end up
|
||||
ts-gen
|
||||
|
||||
# Used to accelerate CI builds
|
||||
.depshash
|
||||
|
||||
397
BUILD.gn
397
BUILD.gn
@@ -12,9 +12,10 @@ import("//tools/v8_context_snapshot/v8_context_snapshot.gni")
|
||||
import("//v8/gni/snapshot_toolchain.gni")
|
||||
import("build/asar.gni")
|
||||
import("build/extract_symbols.gni")
|
||||
import("build/js_wrap.gni")
|
||||
import("build/npm.gni")
|
||||
import("build/templated_file.gni")
|
||||
import("build/tsc.gni")
|
||||
import("build/webpack/webpack.gni")
|
||||
import("buildflags/buildflags.gni")
|
||||
import("electron_paks.gni")
|
||||
import("filenames.auto.gni")
|
||||
@@ -42,7 +43,7 @@ if (is_linux) {
|
||||
}
|
||||
}
|
||||
|
||||
branding = read_file("atom/app/BRANDING.json", "json")
|
||||
branding = read_file("shell/app/BRANDING.json", "json")
|
||||
electron_project_name = branding.project_name
|
||||
electron_product_name = branding.product_name
|
||||
electron_mac_bundle_id = branding.mac_bundle_id
|
||||
@@ -54,8 +55,8 @@ if (is_mas_build) {
|
||||
|
||||
config("branding") {
|
||||
defines = [
|
||||
"ATOM_PRODUCT_NAME=\"$electron_product_name\"",
|
||||
"ATOM_PROJECT_NAME=\"$electron_project_name\"",
|
||||
"ELECTRON_PRODUCT_NAME=\"$electron_product_name\"",
|
||||
"ELECTRON_PROJECT_NAME=\"$electron_project_name\"",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -74,135 +75,70 @@ npm_action("build_electron_definitions") {
|
||||
]
|
||||
}
|
||||
|
||||
npm_action("atom_browserify_sandbox_unwrapped") {
|
||||
script = "browserify"
|
||||
webpack_build("electron_browser_bundle") {
|
||||
deps = [
|
||||
":build_electron_definitions",
|
||||
]
|
||||
|
||||
inputs = auto_filenames.sandbox_browserify_deps
|
||||
inputs = auto_filenames.browser_bundle_deps
|
||||
|
||||
outputs = [
|
||||
"$target_gen_dir/js2c/sandbox_bundle_unwrapped.js",
|
||||
]
|
||||
|
||||
args = [
|
||||
"lib/sandboxed_renderer/init.js",
|
||||
"-r",
|
||||
"./lib/sandboxed_renderer/api/exports/electron.js:electron",
|
||||
"-t",
|
||||
"aliasify",
|
||||
"-p",
|
||||
"[",
|
||||
"tsify",
|
||||
"-p",
|
||||
"tsconfig.electron.json",
|
||||
"]",
|
||||
"--standalone",
|
||||
"sandboxed_preload",
|
||||
"-o",
|
||||
rebase_path(outputs[0]),
|
||||
]
|
||||
config_file = "//electron/build/webpack/webpack.config.browser.js"
|
||||
out_file = "$target_gen_dir/js2c/browser_init.js"
|
||||
}
|
||||
|
||||
npm_action("atom_browserify_isolated_unwrapped") {
|
||||
script = "browserify"
|
||||
webpack_build("electron_renderer_bundle") {
|
||||
deps = [
|
||||
":build_electron_definitions",
|
||||
]
|
||||
|
||||
inputs = auto_filenames.isolated_browserify_deps
|
||||
inputs = auto_filenames.renderer_bundle_deps
|
||||
|
||||
outputs = [
|
||||
"$target_gen_dir/js2c/isolated_bundle_unwrapped.js",
|
||||
]
|
||||
|
||||
args = [
|
||||
"lib/isolated_renderer/init.js",
|
||||
"-t",
|
||||
"aliasify",
|
||||
"-p",
|
||||
"[",
|
||||
"tsify",
|
||||
"-p",
|
||||
"tsconfig.electron.json",
|
||||
"]",
|
||||
"--standalone",
|
||||
"isolated_preload",
|
||||
"-o",
|
||||
rebase_path(outputs[0]),
|
||||
]
|
||||
config_file = "//electron/build/webpack/webpack.config.renderer.js"
|
||||
out_file = "$target_gen_dir/js2c/renderer_init.js"
|
||||
}
|
||||
|
||||
npm_action("atom_browserify_content_script_unwrapped") {
|
||||
script = "browserify"
|
||||
webpack_build("electron_worker_bundle") {
|
||||
deps = [
|
||||
":build_electron_definitions",
|
||||
]
|
||||
|
||||
inputs = auto_filenames.context_script_browserify_deps
|
||||
inputs = auto_filenames.worker_bundle_deps
|
||||
|
||||
outputs = [
|
||||
"$target_gen_dir/js2c/content_script_bundle_unwrapped.js",
|
||||
]
|
||||
|
||||
args = [
|
||||
"lib/content_script/init.js",
|
||||
"-t",
|
||||
"aliasify",
|
||||
"-p",
|
||||
"[",
|
||||
"tsify",
|
||||
"-p",
|
||||
"tsconfig.electron.json",
|
||||
"]",
|
||||
"--standalone",
|
||||
"content_script_preload",
|
||||
"-o",
|
||||
rebase_path(outputs[0]),
|
||||
]
|
||||
config_file = "//electron/build/webpack/webpack.config.worker.js"
|
||||
out_file = "$target_gen_dir/js2c/worker_init.js"
|
||||
}
|
||||
|
||||
js_wrap("atom_browserify_content_script") {
|
||||
webpack_build("electron_sandboxed_renderer_bundle") {
|
||||
deps = [
|
||||
":atom_browserify_content_script_unwrapped",
|
||||
":build_electron_definitions",
|
||||
]
|
||||
|
||||
inputs = [
|
||||
"$target_gen_dir/js2c/content_script_bundle_unwrapped.js",
|
||||
]
|
||||
inputs = auto_filenames.sandbox_bundle_deps
|
||||
|
||||
outputs = [
|
||||
"$target_gen_dir/js2c/content_script_bundle.js",
|
||||
]
|
||||
config_file = "//electron/build/webpack/webpack.config.sandboxed_renderer.js"
|
||||
out_file = "$target_gen_dir/js2c/sandbox_bundle.js"
|
||||
}
|
||||
|
||||
js_wrap("atom_browserify_isolated") {
|
||||
webpack_build("electron_isolated_renderer_bundle") {
|
||||
deps = [
|
||||
":atom_browserify_isolated_unwrapped",
|
||||
":build_electron_definitions",
|
||||
]
|
||||
|
||||
inputs = [
|
||||
"$target_gen_dir/js2c/isolated_bundle_unwrapped.js",
|
||||
]
|
||||
inputs = auto_filenames.isolated_bundle_deps
|
||||
|
||||
outputs = [
|
||||
"$target_gen_dir/js2c/isolated_bundle.js",
|
||||
]
|
||||
config_file = "//electron/build/webpack/webpack.config.isolated_renderer.js"
|
||||
out_file = "$target_gen_dir/js2c/isolated_bundle.js"
|
||||
}
|
||||
|
||||
js_wrap("atom_browserify_sandbox") {
|
||||
webpack_build("electron_content_script_bundle") {
|
||||
deps = [
|
||||
":atom_browserify_sandbox_unwrapped",
|
||||
":build_electron_definitions",
|
||||
]
|
||||
|
||||
inputs = [
|
||||
"$target_gen_dir/js2c/sandbox_bundle_unwrapped.js",
|
||||
]
|
||||
inputs = auto_filenames.content_script_bundle_deps
|
||||
|
||||
outputs = [
|
||||
"$target_gen_dir/js2c/sandbox_bundle.js",
|
||||
]
|
||||
config_file = "//electron/build/webpack/webpack.config.content_script.js"
|
||||
out_file = "$target_gen_dir/js2c/content_script_bundle.js"
|
||||
}
|
||||
|
||||
copy("atom_js2c_copy") {
|
||||
@@ -217,19 +153,25 @@ copy("atom_js2c_copy") {
|
||||
|
||||
action("atom_js2c") {
|
||||
deps = [
|
||||
":atom_browserify_content_script",
|
||||
":atom_browserify_isolated",
|
||||
":atom_browserify_sandbox",
|
||||
":atom_js2c_copy",
|
||||
":electron_browser_bundle",
|
||||
":electron_content_script_bundle",
|
||||
":electron_isolated_renderer_bundle",
|
||||
":electron_renderer_bundle",
|
||||
":electron_sandboxed_renderer_bundle",
|
||||
":electron_worker_bundle",
|
||||
]
|
||||
|
||||
browserify_sources = [
|
||||
webpack_sources = [
|
||||
"$target_gen_dir/js2c/browser_init.js",
|
||||
"$target_gen_dir/js2c/renderer_init.js",
|
||||
"$target_gen_dir/js2c/worker_init.js",
|
||||
"$target_gen_dir/js2c/content_script_bundle.js",
|
||||
"$target_gen_dir/js2c/isolated_bundle.js",
|
||||
"$target_gen_dir/js2c/sandbox_bundle.js",
|
||||
]
|
||||
|
||||
sources = browserify_sources + [
|
||||
sources = webpack_sources + [
|
||||
"$target_gen_dir/js2c/asar.js",
|
||||
"$target_gen_dir/js2c/asar_init.js",
|
||||
]
|
||||
@@ -245,51 +187,8 @@ action("atom_js2c") {
|
||||
rebase_path(sources, root_build_dir)
|
||||
}
|
||||
|
||||
target_gen_electron_js = "$target_gen_dir/js/electron"
|
||||
target_gen_default_app_js = "$target_gen_dir/js/default_app"
|
||||
|
||||
typescript_build("lib_js") {
|
||||
deps = [
|
||||
":build_electron_definitions",
|
||||
]
|
||||
type_root = rebase_path("$target_gen_dir/tsc/electron/typings")
|
||||
|
||||
sources = filenames.js_sources
|
||||
if (enable_desktop_capturer) {
|
||||
sources += [
|
||||
"lib/browser/desktop-capturer.js",
|
||||
"lib/renderer/api/desktop-capturer.js",
|
||||
]
|
||||
}
|
||||
if (enable_view_api) {
|
||||
sources += [
|
||||
"lib/browser/api/views/box-layout.js",
|
||||
"lib/browser/api/views/button.js",
|
||||
"lib/browser/api/views/label-button.js",
|
||||
"lib/browser/api/views/layout-manager.js",
|
||||
"lib/browser/api/views/md-text-button.js",
|
||||
"lib/browser/api/views/resize-area.js",
|
||||
"lib/browser/api/views/text-field.js",
|
||||
]
|
||||
}
|
||||
|
||||
output_gen_dir = target_gen_electron_js
|
||||
output_dir_name = "lib"
|
||||
tsconfig = "tsconfig.electron.json"
|
||||
}
|
||||
|
||||
asar("electron_asar") {
|
||||
deps = [
|
||||
":lib_js",
|
||||
]
|
||||
|
||||
root = "$target_gen_electron_js/electron/lib"
|
||||
sources = get_target_outputs(":lib_js")
|
||||
outputs = [
|
||||
"$root_out_dir/resources/electron.asar",
|
||||
]
|
||||
}
|
||||
|
||||
typescript_build("default_app_js") {
|
||||
deps = [
|
||||
":build_electron_definitions",
|
||||
@@ -390,16 +289,15 @@ if (is_linux) {
|
||||
|
||||
source_set("manifests") {
|
||||
sources = [
|
||||
"//electron/atom/app/manifests.cc",
|
||||
"//electron/atom/app/manifests.h",
|
||||
"//electron/shell/app/manifests.cc",
|
||||
"//electron/shell/app/manifests.h",
|
||||
]
|
||||
|
||||
include_dirs = [ "//electron" ]
|
||||
|
||||
deps = [
|
||||
"//electron/atom/common/api:mojo",
|
||||
"//electron/shell/common/api:mojo",
|
||||
"//printing/buildflags",
|
||||
"//services/proxy_resolver/public/cpp:manifest",
|
||||
"//services/service_manager/public/cpp",
|
||||
]
|
||||
|
||||
@@ -412,7 +310,33 @@ source_set("manifests") {
|
||||
}
|
||||
}
|
||||
|
||||
static_library("electron_lib") {
|
||||
npm_action("electron_version_args") {
|
||||
script = "generate-version-json"
|
||||
|
||||
outputs = [
|
||||
"$target_gen_dir/electron_version.args",
|
||||
]
|
||||
|
||||
args = rebase_path(outputs)
|
||||
|
||||
inputs = [
|
||||
"ELECTRON_VERSION",
|
||||
"script/generate-version-json.js",
|
||||
]
|
||||
}
|
||||
|
||||
templated_file("electron_version_header") {
|
||||
deps = [
|
||||
":electron_version_args",
|
||||
]
|
||||
|
||||
template = "build/templates/electron_version.tmpl"
|
||||
output = "$target_gen_dir/electron_version.h"
|
||||
|
||||
args_files = get_target_outputs(":electron_version_args")
|
||||
}
|
||||
|
||||
source_set("electron_lib") {
|
||||
configs += [ "//v8:external_startup_data" ]
|
||||
configs += [ "//third_party/electron_node:node_internals" ]
|
||||
|
||||
@@ -420,12 +344,13 @@ static_library("electron_lib") {
|
||||
|
||||
deps = [
|
||||
":atom_js2c",
|
||||
":electron_version_header",
|
||||
":manifests",
|
||||
":resources",
|
||||
"atom/common/api:mojo",
|
||||
"buildflags",
|
||||
"chromium_src:chrome",
|
||||
"native_mate",
|
||||
"shell/common/api:mojo",
|
||||
"//base:base_static",
|
||||
"//base/allocator:buildflags",
|
||||
"//chrome/app/resources:platform_locale_settings",
|
||||
@@ -439,9 +364,11 @@ static_library("electron_lib") {
|
||||
"//content/public/browser",
|
||||
"//content/public/child",
|
||||
"//content/public/common:service_names",
|
||||
"//content/public/gpu",
|
||||
"//content/public/renderer",
|
||||
"//content/public/utility",
|
||||
"//device/bluetooth",
|
||||
"//device/bluetooth/public/cpp",
|
||||
"//gin",
|
||||
"//media/capture/mojom:video_capture",
|
||||
"//media/mojo/interfaces",
|
||||
@@ -541,8 +468,8 @@ static_library("electron_lib") {
|
||||
|
||||
if (enable_fake_location_provider) {
|
||||
sources += [
|
||||
"atom/browser/fake_location_provider.cc",
|
||||
"atom/browser/fake_location_provider.h",
|
||||
"shell/browser/fake_location_provider.cc",
|
||||
"shell/browser/fake_location_provider.h",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -553,15 +480,15 @@ static_library("electron_lib") {
|
||||
"//ui/accelerated_widget_mac",
|
||||
]
|
||||
sources += [
|
||||
"atom/browser/ui/views/autofill_popup_view.cc",
|
||||
"atom/browser/ui/views/autofill_popup_view.h",
|
||||
"shell/browser/ui/views/autofill_popup_view.cc",
|
||||
"shell/browser/ui/views/autofill_popup_view.h",
|
||||
]
|
||||
if (is_mas_build) {
|
||||
sources += [ "atom/browser/api/atom_api_app_mas.mm" ]
|
||||
sources += [ "shell/browser/api/atom_api_app_mas.mm" ]
|
||||
sources -= [
|
||||
"atom/browser/auto_updater_mac.mm",
|
||||
"atom/common/crash_reporter/crash_reporter_mac.h",
|
||||
"atom/common/crash_reporter/crash_reporter_mac.mm",
|
||||
"shell/browser/auto_updater_mac.mm",
|
||||
"shell/common/crash_reporter/crash_reporter_mac.h",
|
||||
"shell/common/crash_reporter/crash_reporter_mac.mm",
|
||||
]
|
||||
defines += [ "MAS_BUILD" ]
|
||||
} else {
|
||||
@@ -594,6 +521,7 @@ static_library("electron_lib") {
|
||||
]
|
||||
configs += [ ":gio_unix" ]
|
||||
include_dirs += [ "//third_party/breakpad" ]
|
||||
configs += [ "//build/config/linux:x11" ]
|
||||
defines += [
|
||||
# Disable warnings for g_settings_list_schemas.
|
||||
"GLIB_DISABLE_DEPRECATION_WARNINGS",
|
||||
@@ -617,8 +545,8 @@ static_library("electron_lib") {
|
||||
|
||||
if ((is_mac && !is_mas_build) || is_win) {
|
||||
sources += [
|
||||
"atom/common/crash_reporter/crash_reporter_crashpad.cc",
|
||||
"atom/common/crash_reporter/crash_reporter_crashpad.h",
|
||||
"shell/common/crash_reporter/crash_reporter_crashpad.cc",
|
||||
"shell/common/crash_reporter/crash_reporter_crashpad.h",
|
||||
]
|
||||
deps += [ "//third_party/crashpad/crashpad/client" ]
|
||||
}
|
||||
@@ -629,25 +557,25 @@ static_library("electron_lib") {
|
||||
|
||||
if (enable_run_as_node) {
|
||||
sources += [
|
||||
"atom/app/node_main.cc",
|
||||
"atom/app/node_main.h",
|
||||
"shell/app/node_main.cc",
|
||||
"shell/app/node_main.h",
|
||||
]
|
||||
}
|
||||
|
||||
if (enable_osr) {
|
||||
sources += [
|
||||
"atom/browser/osr/osr_host_display_client.cc",
|
||||
"atom/browser/osr/osr_host_display_client.h",
|
||||
"atom/browser/osr/osr_host_display_client_mac.mm",
|
||||
"atom/browser/osr/osr_render_widget_host_view.cc",
|
||||
"atom/browser/osr/osr_render_widget_host_view.h",
|
||||
"atom/browser/osr/osr_video_consumer.cc",
|
||||
"atom/browser/osr/osr_video_consumer.h",
|
||||
"atom/browser/osr/osr_view_proxy.cc",
|
||||
"atom/browser/osr/osr_view_proxy.h",
|
||||
"atom/browser/osr/osr_web_contents_view.cc",
|
||||
"atom/browser/osr/osr_web_contents_view.h",
|
||||
"atom/browser/osr/osr_web_contents_view_mac.mm",
|
||||
"shell/browser/osr/osr_host_display_client.cc",
|
||||
"shell/browser/osr/osr_host_display_client.h",
|
||||
"shell/browser/osr/osr_host_display_client_mac.mm",
|
||||
"shell/browser/osr/osr_render_widget_host_view.cc",
|
||||
"shell/browser/osr/osr_render_widget_host_view.h",
|
||||
"shell/browser/osr/osr_video_consumer.cc",
|
||||
"shell/browser/osr/osr_video_consumer.h",
|
||||
"shell/browser/osr/osr_view_proxy.cc",
|
||||
"shell/browser/osr/osr_view_proxy.h",
|
||||
"shell/browser/osr/osr_web_contents_view.cc",
|
||||
"shell/browser/osr/osr_web_contents_view.h",
|
||||
"shell/browser/osr/osr_web_contents_view_mac.mm",
|
||||
]
|
||||
deps += [
|
||||
"//components/viz/service",
|
||||
@@ -657,46 +585,62 @@ static_library("electron_lib") {
|
||||
}
|
||||
|
||||
if (enable_desktop_capturer) {
|
||||
if (is_component_build && !is_linux) {
|
||||
if (is_component_build && is_win) {
|
||||
# On windows the implementation relies on unexported
|
||||
# DxgiDuplicatorController class.
|
||||
deps += [ "//third_party/webrtc/modules/desktop_capture" ]
|
||||
}
|
||||
sources += [
|
||||
"atom/browser/api/atom_api_desktop_capturer.cc",
|
||||
"atom/browser/api/atom_api_desktop_capturer.h",
|
||||
"shell/browser/api/atom_api_desktop_capturer.cc",
|
||||
"shell/browser/api/atom_api_desktop_capturer.h",
|
||||
]
|
||||
}
|
||||
|
||||
if (enable_view_api) {
|
||||
sources += [
|
||||
"atom/browser/api/views/atom_api_box_layout.cc",
|
||||
"atom/browser/api/views/atom_api_box_layout.h",
|
||||
"atom/browser/api/views/atom_api_button.cc",
|
||||
"atom/browser/api/views/atom_api_button.h",
|
||||
"atom/browser/api/views/atom_api_label_button.cc",
|
||||
"atom/browser/api/views/atom_api_label_button.h",
|
||||
"atom/browser/api/views/atom_api_layout_manager.cc",
|
||||
"atom/browser/api/views/atom_api_layout_manager.h",
|
||||
"atom/browser/api/views/atom_api_md_text_button.cc",
|
||||
"atom/browser/api/views/atom_api_md_text_button.h",
|
||||
"atom/browser/api/views/atom_api_resize_area.cc",
|
||||
"atom/browser/api/views/atom_api_resize_area.h",
|
||||
"atom/browser/api/views/atom_api_text_field.cc",
|
||||
"atom/browser/api/views/atom_api_text_field.h",
|
||||
"shell/browser/api/views/atom_api_box_layout.cc",
|
||||
"shell/browser/api/views/atom_api_box_layout.h",
|
||||
"shell/browser/api/views/atom_api_button.cc",
|
||||
"shell/browser/api/views/atom_api_button.h",
|
||||
"shell/browser/api/views/atom_api_label_button.cc",
|
||||
"shell/browser/api/views/atom_api_label_button.h",
|
||||
"shell/browser/api/views/atom_api_layout_manager.cc",
|
||||
"shell/browser/api/views/atom_api_layout_manager.h",
|
||||
"shell/browser/api/views/atom_api_md_text_button.cc",
|
||||
"shell/browser/api/views/atom_api_md_text_button.h",
|
||||
"shell/browser/api/views/atom_api_resize_area.cc",
|
||||
"shell/browser/api/views/atom_api_resize_area.h",
|
||||
"shell/browser/api/views/atom_api_text_field.cc",
|
||||
"shell/browser/api/views/atom_api_text_field.h",
|
||||
]
|
||||
}
|
||||
|
||||
if (enable_basic_printing) {
|
||||
sources += [
|
||||
"atom/browser/printing/print_preview_message_handler.cc",
|
||||
"atom/browser/printing/print_preview_message_handler.h",
|
||||
"atom/renderer/printing/print_render_frame_helper_delegate.cc",
|
||||
"atom/renderer/printing/print_render_frame_helper_delegate.h",
|
||||
"shell/browser/printing/print_preview_message_handler.cc",
|
||||
"shell/browser/printing/print_preview_message_handler.h",
|
||||
"shell/renderer/printing/print_render_frame_helper_delegate.cc",
|
||||
"shell/renderer/printing/print_render_frame_helper_delegate.h",
|
||||
]
|
||||
}
|
||||
|
||||
if (enable_pepper_flash) {
|
||||
deps += [ "components/pepper_flash" ]
|
||||
}
|
||||
|
||||
public_deps += [ "shell/common/extensions/api:extensions_features" ]
|
||||
deps += [
|
||||
"//components/pref_registry",
|
||||
"//components/user_prefs",
|
||||
"//extensions/browser",
|
||||
"//extensions/browser:core_api_provider",
|
||||
"//extensions/common",
|
||||
"//extensions/common:core_api_provider",
|
||||
"//extensions/renderer",
|
||||
]
|
||||
if (enable_electron_extensions) {
|
||||
sources += filenames.lib_sources_extensions
|
||||
}
|
||||
}
|
||||
|
||||
electron_paks("packed_resources") {
|
||||
@@ -715,12 +659,6 @@ if (is_mac) {
|
||||
electron_framework_version = "A"
|
||||
electron_version = read_file("ELECTRON_VERSION", "trim string")
|
||||
|
||||
mac_xib_bundle_data("electron_xibs") {
|
||||
sources = [
|
||||
"atom/common/resources/mac/MainMenu.xib",
|
||||
]
|
||||
}
|
||||
|
||||
bundle_data("electron_framework_resources") {
|
||||
public_deps = [
|
||||
":packed_resources",
|
||||
@@ -835,15 +773,14 @@ if (is_mac) {
|
||||
":electron_framework_libraries",
|
||||
":electron_framework_resources",
|
||||
":electron_swiftshader_library",
|
||||
":electron_xibs",
|
||||
]
|
||||
if (!is_mas_build) {
|
||||
deps += [ ":electron_crashpad_helper" ]
|
||||
}
|
||||
info_plist = "atom/common/resources/mac/Info.plist"
|
||||
info_plist = "shell/common/resources/mac/Info.plist"
|
||||
|
||||
extra_substitutions = [
|
||||
"ATOM_BUNDLE_ID=$electron_mac_bundle_id.framework",
|
||||
"ELECTRON_BUNDLE_ID=$electron_mac_bundle_id.framework",
|
||||
"ELECTRON_VERSION=$electron_version",
|
||||
]
|
||||
|
||||
@@ -894,10 +831,11 @@ if (is_mac) {
|
||||
}
|
||||
defines = [ "HELPER_EXECUTABLE" ]
|
||||
sources = filenames.app_sources
|
||||
sources += [ "atom/common/atom_constants.cc" ]
|
||||
sources += [ "shell/common/atom_constants.cc" ]
|
||||
include_dirs = [ "." ]
|
||||
info_plist = "atom/renderer/resources/mac/Info.plist"
|
||||
extra_substitutions = [ "ATOM_BUNDLE_ID=$electron_mac_bundle_id.helper" ]
|
||||
info_plist = "shell/renderer/resources/mac/Info.plist"
|
||||
extra_substitutions =
|
||||
[ "ELECTRON_BUNDLE_ID=$electron_mac_bundle_id.helper" ]
|
||||
ldflags = [
|
||||
"-rpath",
|
||||
"@executable_path/../../..",
|
||||
@@ -950,9 +888,9 @@ if (is_mac) {
|
||||
sources = filenames.login_helper_sources
|
||||
include_dirs = [ "." ]
|
||||
libs = [ "AppKit.framework" ]
|
||||
info_plist = "atom/app/resources/mac/loginhelper-Info.plist"
|
||||
info_plist = "shell/app/resources/mac/loginhelper-Info.plist"
|
||||
extra_substitutions =
|
||||
[ "ATOM_BUNDLE_ID=$electron_mac_bundle_id.loginhelper" ]
|
||||
[ "ELECTRON_BUNDLE_ID=$electron_mac_bundle_id.loginhelper" ]
|
||||
}
|
||||
|
||||
bundle_data("electron_login_helper_app") {
|
||||
@@ -1001,12 +939,10 @@ if (is_mac) {
|
||||
public_deps = [
|
||||
":default_app_asar",
|
||||
":electron_app_strings_bundle_data",
|
||||
":electron_asar",
|
||||
]
|
||||
sources = [
|
||||
"$root_out_dir/resources/default_app.asar",
|
||||
"$root_out_dir/resources/electron.asar",
|
||||
"atom/browser/resources/mac/electron.icns",
|
||||
"shell/browser/resources/mac/electron.icns",
|
||||
]
|
||||
outputs = [
|
||||
"{{bundle_resources_dir}}/{{source_file_part}}",
|
||||
@@ -1016,7 +952,7 @@ if (is_mac) {
|
||||
mac_app_bundle("electron_app") {
|
||||
output_name = electron_product_name
|
||||
sources = filenames.app_sources
|
||||
sources += [ "atom/common/atom_constants.cc" ]
|
||||
sources += [ "shell/common/atom_constants.cc" ]
|
||||
include_dirs = [ "." ]
|
||||
deps = [
|
||||
":electron_app_framework_bundle_data",
|
||||
@@ -1025,8 +961,11 @@ if (is_mac) {
|
||||
if (is_mas_build) {
|
||||
deps += [ ":electron_login_helper_app" ]
|
||||
}
|
||||
info_plist = "atom/browser/resources/mac/Info.plist"
|
||||
extra_substitutions = [ "ATOM_BUNDLE_ID=$electron_mac_bundle_id" ]
|
||||
info_plist = "shell/browser/resources/mac/Info.plist"
|
||||
extra_substitutions = [
|
||||
"ELECTRON_BUNDLE_ID=$electron_mac_bundle_id",
|
||||
"ELECTRON_VERSION=$electron_version",
|
||||
]
|
||||
ldflags = [
|
||||
"-rpath",
|
||||
"@executable_path/../Frameworks",
|
||||
@@ -1114,8 +1053,8 @@ if (is_mac) {
|
||||
} else {
|
||||
windows_manifest("electron_app_manifest") {
|
||||
sources = [
|
||||
"atom/browser/resources/win/disable_window_filtering.manifest",
|
||||
"atom/browser/resources/win/dpi_aware.manifest",
|
||||
"shell/browser/resources/win/disable_window_filtering.manifest",
|
||||
"shell/browser/resources/win/dpi_aware.manifest",
|
||||
as_invoker_manifest,
|
||||
common_controls_manifest,
|
||||
default_compatibility_manifest,
|
||||
@@ -1129,7 +1068,6 @@ if (is_mac) {
|
||||
deps = [
|
||||
":default_app_asar",
|
||||
":electron_app_manifest",
|
||||
":electron_asar",
|
||||
":electron_lib",
|
||||
":packed_resources",
|
||||
"//content:sandbox_helper_win",
|
||||
@@ -1150,7 +1088,6 @@ if (is_mac) {
|
||||
|
||||
if (!is_mac) {
|
||||
data += [ "$root_out_dir/resources/default_app.asar" ]
|
||||
data += [ "$root_out_dir/resources/electron.asar" ]
|
||||
}
|
||||
|
||||
public_deps = [
|
||||
@@ -1160,9 +1097,8 @@ if (is_mac) {
|
||||
if (is_win) {
|
||||
sources += [
|
||||
# TODO: we should be generating our .rc files more like how chrome does
|
||||
"atom/browser/resources/win/atom.ico",
|
||||
"atom/browser/resources/win/atom.rc",
|
||||
"atom/browser/resources/win/resource.h",
|
||||
"shell/browser/resources/win/atom.rc",
|
||||
"shell/browser/resources/win/resource.h",
|
||||
]
|
||||
|
||||
libs = [
|
||||
@@ -1188,6 +1124,7 @@ if (is_mac) {
|
||||
# See https://github.com/nodejs/node-gyp/commit/52ceec3a6d15de3a8f385f43dbe5ecf5456ad07a
|
||||
ldflags += [ "/DEF:" + rebase_path("build/electron.def", root_build_dir) ]
|
||||
inputs = [
|
||||
"shell/browser/resources/win/atom.ico",
|
||||
"build/electron.def",
|
||||
]
|
||||
}
|
||||
@@ -1348,18 +1285,12 @@ dist_zip("electron_chromedriver_zip") {
|
||||
]
|
||||
}
|
||||
|
||||
mksnapshot_deps = [
|
||||
":licenses",
|
||||
"//tools/v8_context_snapshot:v8_context_snapshot_generator",
|
||||
"//v8:mksnapshot($v8_snapshot_toolchain)",
|
||||
]
|
||||
|
||||
group("electron_mksnapshot") {
|
||||
public_deps = mksnapshot_deps
|
||||
}
|
||||
|
||||
dist_zip("electron_mksnapshot_zip") {
|
||||
data_deps = mksnapshot_deps
|
||||
data_deps = [
|
||||
"//v8:mksnapshot($v8_snapshot_toolchain)",
|
||||
"//tools/v8_context_snapshot:v8_context_snapshot_generator",
|
||||
":licenses",
|
||||
]
|
||||
outputs = [
|
||||
"$root_build_dir/mksnapshot.zip",
|
||||
]
|
||||
|
||||
@@ -28,6 +28,18 @@ the issue will be closed.
|
||||
* If an issue has been closed and you still feel it's relevant, feel free to
|
||||
ping a maintainer or add a comment!
|
||||
|
||||
### Languages
|
||||
|
||||
We accept issues in *any* language.
|
||||
When an issue is posted in a language besides English, it is acceptable and encouraged to post an English-translated copy as a reply.
|
||||
Anyone may post the translated reply.
|
||||
In most cases, a quick pass through translation software is sufficient.
|
||||
Having the original text _as well as_ the translation can help mitigate translation errors.
|
||||
|
||||
Responses to posted issues may or may not be in the original language.
|
||||
|
||||
**Please note** that using non-English as an attempt to circumvent our [Code of Conduct](https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md) will be an immediate, and possibly indefinite, ban from the project.
|
||||
|
||||
## [Pull Requests](https://electronjs.org/docs/development/pull-requests)
|
||||
|
||||
Pull Requests are the way concrete changes are made to the code, documentation,
|
||||
@@ -57,4 +69,4 @@ See [Coding Style](https://electronjs.org/docs/development/coding-style) for inf
|
||||
## Further Reading
|
||||
|
||||
For more in-depth guides on developing Electron, see
|
||||
[/docs/development](/docs/development/README.md)
|
||||
[/docs/development](/docs/development/README.md)
|
||||
|
||||
33
DEPS
33
DEPS
@@ -10,9 +10,11 @@ gclient_gn_args = [
|
||||
|
||||
vars = {
|
||||
'chromium_version':
|
||||
'76.0.3809.146',
|
||||
'78.0.3866.0',
|
||||
'node_version':
|
||||
'v12.4.0',
|
||||
'v12.8.0',
|
||||
'nan_version':
|
||||
'2ee313aaca52e2b478965ac50eb5082520380d1b',
|
||||
|
||||
'boto_version': 'f7574aa6cc2c819430c1f05e9a1a1a666ef8169b',
|
||||
'pyyaml_version': '3.12',
|
||||
@@ -25,21 +27,19 @@ vars = {
|
||||
'requests_git': 'https://github.com/kennethreitz',
|
||||
'yaml_git': 'https://github.com/yaml',
|
||||
|
||||
# KEEP IN SYNC WITH spec-runner FILE
|
||||
# KEEP IN SYNC WITH utils.js FILE
|
||||
'yarn_version': '1.15.2',
|
||||
|
||||
# To be able to build clean Chromium from sources.
|
||||
'apply_patches': True,
|
||||
|
||||
# Apply the patches specific to windows on arm64
|
||||
'apply_win_arm64_patches': False,
|
||||
|
||||
# Python interface to Amazon Web Services. Is used for releases only.
|
||||
'checkout_boto': False,
|
||||
|
||||
# To allow in-house builds to checkout those manually.
|
||||
'checkout_chromium': True,
|
||||
'checkout_node': True,
|
||||
'checkout_nan': True,
|
||||
|
||||
# It's only needed to parse the native tests configurations.
|
||||
'checkout_pyyaml': False,
|
||||
@@ -49,9 +49,10 @@ vars = {
|
||||
|
||||
# To allow running hooks without parsing the DEPS tree
|
||||
'process_deps': True,
|
||||
|
||||
# It is always needed for normal Electron builds,
|
||||
# but might be impossible for custom in-house builds.
|
||||
'download_external_binaries': False,
|
||||
'download_external_binaries': True,
|
||||
|
||||
'checkout_nacl':
|
||||
False,
|
||||
@@ -72,6 +73,10 @@ deps = {
|
||||
'url': (Var("chromium_git")) + '/chromium/src.git@' + (Var("chromium_version")),
|
||||
'condition': 'checkout_chromium and process_deps',
|
||||
},
|
||||
'src/third_party/nan': {
|
||||
'url': (Var("nodejs_git")) + '/nan.git@' + (Var("nan_version")),
|
||||
'condition': 'checkout_nan and process_deps',
|
||||
},
|
||||
'src/third_party/electron_node': {
|
||||
'url': (Var("nodejs_git")) + '/node.git@' + (Var("node_version")),
|
||||
'condition': 'checkout_node and process_deps',
|
||||
@@ -98,17 +103,7 @@ hooks = [
|
||||
'action': [
|
||||
'python',
|
||||
'src/electron/script/apply_all_patches.py',
|
||||
'src/electron/patches/common/config.json',
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'patch_chromium',
|
||||
'condition': '(checkout_chromium and apply_patches) and apply_win_arm64_patches',
|
||||
'pattern': 'src/electron',
|
||||
'action': [
|
||||
'python',
|
||||
'src/electron/script/apply_all_patches.py',
|
||||
'src/electron/patches/win_arm64/config.json',
|
||||
'src/electron/patches/config.json',
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -154,5 +149,3 @@ hooks = [
|
||||
recursedeps = [
|
||||
'src',
|
||||
]
|
||||
|
||||
# Touch DEPS to bust cache
|
||||
|
||||
@@ -10,6 +10,7 @@ RUN chmod a+rwx /tmp
|
||||
# Install Linux packages
|
||||
ADD build/install-build-deps.sh /setup/install-build-deps.sh
|
||||
RUN echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections
|
||||
RUN dpkg --add-architecture i386
|
||||
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
curl \
|
||||
libnotify-bin \
|
||||
@@ -22,6 +23,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
sudo \
|
||||
vim-nox \
|
||||
wget \
|
||||
g++-multilib \
|
||||
libgl1:i386 \
|
||||
&& /setup/install-build-deps.sh --syms --no-prompt --no-chromeos-fonts --lib32 --arm \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
|
||||
@@ -19,8 +19,6 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
libcap-dev \
|
||||
libcups2-dev \
|
||||
libdbus-1-dev \
|
||||
libgconf-2-4 \
|
||||
libgconf2-dev \
|
||||
libgnome-keyring-dev \
|
||||
libgtk2.0-0 \
|
||||
libgtk2.0-dev \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM arm64v8/ubuntu:16.04
|
||||
FROM arm64v8/ubuntu:18.04
|
||||
|
||||
RUN groupadd --gid 1000 builduser \
|
||||
&& useradd --uid 1000 --gid builduser --shell /bin/bash --create-home builduser
|
||||
@@ -22,8 +22,6 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
libcap-dev \
|
||||
libcups2-dev \
|
||||
libdbus-1-dev \
|
||||
libgconf-2-4 \
|
||||
libgconf2-dev \
|
||||
libgnome-keyring-dev \
|
||||
libgtk2.0-0 \
|
||||
libgtk2.0-dev \
|
||||
@@ -41,7 +39,6 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
nano \
|
||||
python-setuptools \
|
||||
python-pip \
|
||||
python-dbusmock \
|
||||
sudo \
|
||||
unzip \
|
||||
wget \
|
||||
@@ -56,6 +53,9 @@ RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \
|
||||
# crcmod is required by gsutil, which is used for filling the gclient git cache
|
||||
RUN pip install -U crcmod
|
||||
|
||||
# dbusmock is needed for Electron tests
|
||||
RUN pip install python-dbusmock
|
||||
|
||||
ADD tools/xvfb-init.sh /etc/init.d/xvfb
|
||||
RUN chmod a+x /etc/init.d/xvfb
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.1.10
|
||||
7.0.0-beta.3
|
||||
@@ -91,6 +91,10 @@ const child = proc.spawn(electron)
|
||||
|
||||
Find documentation translations in [electron/i18n](https://github.com/electron/i18n).
|
||||
|
||||
## Contributing
|
||||
|
||||
If you are interested in reporting/fixing issues and contributing directly to the code base, please see [CONTRIBUTING.md](CONTRIBUTING.md) for more information on what we're looking for and how to get started.
|
||||
|
||||
## Community
|
||||
|
||||
Info on reporting bugs, getting help, finding third-party tools and sample apps,
|
||||
|
||||
41
appveyor.yml
41
appveyor.yml
@@ -23,13 +23,29 @@
|
||||
# https://www.appveyor.com/docs/build-configuration/#secure-variables
|
||||
# https://www.appveyor.com/docs/build-configuration/#custom-environment-variables
|
||||
|
||||
# Uncomment these lines to enable RDP
|
||||
#on_finish:
|
||||
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||
|
||||
version: 1.0.{build}
|
||||
build_cloud: libcc-20
|
||||
image: libcc-20-vs2017-15.9
|
||||
image: vs2017-15.9-10.0.18362
|
||||
environment:
|
||||
GIT_CACHE_PATH: C:\Users\electron\libcc_cache
|
||||
ELECTRON_OUT_DIR: Default
|
||||
ELECTRON_ENABLE_STACK_DUMPING: 1
|
||||
MOCHA_REPORTER: mocha-multi-reporters
|
||||
MOCHA_MULTI_REPORTERS: mocha-appveyor-reporter, tap
|
||||
notifications:
|
||||
- provider: Webhook
|
||||
url: https://electron-mission-control.herokuapp.com/rest/appveyor-hook
|
||||
method: POST
|
||||
headers:
|
||||
x-mission-control-secret:
|
||||
secure: 90BLVPcqhJPG7d24v0q/RRray6W3wDQ8uVQlQjOHaBWkw1i8FoA1lsjr2C/v1dVok+tS2Pi6KxDctPUkwIb4T27u4RhvmcPzQhVpfwVJAG9oNtq+yKN7vzHfg7k/pojEzVdJpQLzeJGcSrZu7VY39Q==
|
||||
on_build_success: false
|
||||
on_build_failure: true
|
||||
on_build_status_changed: false
|
||||
build_script:
|
||||
- ps: >-
|
||||
if(($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME -split "/")[0] -eq ($env:APPVEYOR_REPO_NAME -split "/")[0]) {
|
||||
@@ -38,13 +54,15 @@ build_script:
|
||||
- echo "Building $env:GN_CONFIG build"
|
||||
- git config --global core.longpaths true
|
||||
- cd ..
|
||||
- ps: if (Test-Path src\electron) { Remove-Item src\electron -Recurse }
|
||||
- mkdir src
|
||||
- ps: Move-Item $env:APPVEYOR_BUILD_FOLDER -Destination src\electron
|
||||
- ps: $env:CHROMIUM_BUILDTOOLS_PATH="$pwd\src\buildtools"
|
||||
- ps: $env:SCCACHE_PATH="$pwd\src\electron\external_binaries\sccache.exe"
|
||||
- ps: >-
|
||||
if ($env:GN_CONFIG -eq 'release') {
|
||||
$env:GCLIENT_EXTRA_ARGS="$env:GCLIENT_EXTRA_ARGS --custom-var=checkout_boto=True --custom-var=checkout_requests=True"
|
||||
$env:GCLIENT_EXTRA_ARGS="--custom-var=checkout_boto=True --custom-var=checkout_requests=True"
|
||||
} else {
|
||||
$env:NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] "
|
||||
}
|
||||
- >-
|
||||
gclient config
|
||||
@@ -53,16 +71,15 @@ build_script:
|
||||
%GCLIENT_EXTRA_ARGS%
|
||||
"https://github.com/electron/electron"
|
||||
- gclient sync --with_branch_heads --with_tags --reset
|
||||
# Manually run update-external-binaries.py with system python
|
||||
- python src/electron/script/update-external-binaries.py
|
||||
- cd src
|
||||
- ps: $env:BUILD_CONFIG_PATH="//electron/build/args/%GN_CONFIG%.gn"
|
||||
- gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") %GN_EXTRA_ARGS%"
|
||||
- gn check out/Default //electron:electron_lib
|
||||
- gn check out/Default //electron:electron_app
|
||||
- gn check out/Default //electron:manifests
|
||||
- gn check out/Default //electron/atom/common/api:mojo
|
||||
- gn check out/Default //electron/shell/common/api:mojo
|
||||
- ninja -C out/Default electron:electron_app
|
||||
- if "%GN_CONFIG%"=="testing" ( python C:\Users\electron\depot_tools\post_build_ninja_summary.py -C out\Default )
|
||||
- gn gen out/ffmpeg "--args=import(\"//electron/build/args/ffmpeg.gn\") %GN_EXTRA_ARGS%"
|
||||
- ninja -C out/ffmpeg electron:electron_ffmpeg_zip
|
||||
- ninja -C out/Default electron:electron_dist_zip
|
||||
@@ -72,10 +89,6 @@ build_script:
|
||||
- appveyor PushArtifact out/Default/dist.zip
|
||||
- appveyor PushArtifact out/Default/chromedriver.zip
|
||||
- appveyor PushArtifact out/ffmpeg/ffmpeg.zip
|
||||
- 7z a node_headers.zip out\Default\gen\node_headers
|
||||
- appveyor PushArtifact node_headers.zip
|
||||
- appveyor PushArtifact out/Default/mksnapshot.zip
|
||||
- appveyor PushArtifact out/Default/electron.lib
|
||||
- ps: >-
|
||||
if ($env:GN_CONFIG -eq 'release') {
|
||||
# Needed for msdia140.dll on 64-bit windows
|
||||
@@ -92,7 +105,7 @@ test_script:
|
||||
# Workaround for https://github.com/appveyor/ci/issues/2420
|
||||
- set "PATH=%PATH%;C:\Program Files\Git\mingw64\libexec\git-core"
|
||||
- ps: >-
|
||||
if ((-Not (Test-Path Env:\TEST_WOA)) -And (-Not (Test-Path Env:\ELECTRON_RELEASE)) -And ($env:GN_CONFIG -in "testing", "release")) {
|
||||
if ((-Not (Test-Path Env:\ELECTRON_RELEASE)) -And ($env:GN_CONFIG -in "testing", "release")) {
|
||||
$env:RUN_TESTS="true"
|
||||
}
|
||||
- ps: >-
|
||||
@@ -115,11 +128,9 @@ deploy_script:
|
||||
if (Test-Path Env:\ELECTRON_RELEASE) {
|
||||
if (Test-Path Env:\UPLOAD_TO_S3) {
|
||||
Write-Output "Uploading Electron release distribution to s3"
|
||||
& python script\upload.py --upload_to_s3
|
||||
& python script\release\uploaders\upload.py --upload_to_s3
|
||||
} else {
|
||||
Write-Output "Uploading Electron release distribution to github releases"
|
||||
& python script\upload.py
|
||||
& python script\release\uploaders\upload.py
|
||||
}
|
||||
} elseif (Test-Path Env:\TEST_WOA) {
|
||||
node script/ci-release-build.js --job=electron-woa-testing --ci=VSTS --armTest --appveyorJobId=$env:APPVEYOR_JOB_ID $env:APPVEYOR_REPO_BRANCH
|
||||
}
|
||||
|
||||
@@ -1,407 +0,0 @@
|
||||
// Copyright (c) 2015 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/api/atom_api_cookies.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/cookie_change_notifier.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/values.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
#include "net/cookies/canonical_cookie.h"
|
||||
#include "net/cookies/cookie_store.h"
|
||||
#include "net/cookies/cookie_util.h"
|
||||
#include "net/url_request/url_request_context.h"
|
||||
#include "net/url_request/url_request_context_getter.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
namespace mate {
|
||||
|
||||
template <>
|
||||
struct Converter<atom::api::Cookies::Error> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
atom::api::Cookies::Error val) {
|
||||
if (val == atom::api::Cookies::SUCCESS)
|
||||
return v8::Null(isolate);
|
||||
else
|
||||
return v8::Exception::Error(StringToV8(isolate, "Setting cookie failed"));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<net::CanonicalCookie> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const net::CanonicalCookie& val) {
|
||||
mate::Dictionary dict(isolate, v8::Object::New(isolate));
|
||||
dict.Set("name", val.Name());
|
||||
dict.Set("value", val.Value());
|
||||
dict.Set("domain", val.Domain());
|
||||
dict.Set("hostOnly", net::cookie_util::DomainIsHostOnly(val.Domain()));
|
||||
dict.Set("path", val.Path());
|
||||
dict.Set("secure", val.IsSecure());
|
||||
dict.Set("httpOnly", val.IsHttpOnly());
|
||||
dict.Set("session", !val.IsPersistent());
|
||||
if (val.IsPersistent())
|
||||
dict.Set("expirationDate", val.ExpiryDate().ToDoubleT());
|
||||
return dict.GetHandle();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<network::mojom::CookieChangeCause> {
|
||||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const network::mojom::CookieChangeCause& val) {
|
||||
switch (val) {
|
||||
case network::mojom::CookieChangeCause::INSERTED:
|
||||
case network::mojom::CookieChangeCause::EXPLICIT:
|
||||
return mate::StringToV8(isolate, "explicit");
|
||||
case network::mojom::CookieChangeCause::OVERWRITE:
|
||||
return mate::StringToV8(isolate, "overwrite");
|
||||
case network::mojom::CookieChangeCause::EXPIRED:
|
||||
return mate::StringToV8(isolate, "expired");
|
||||
case network::mojom::CookieChangeCause::EVICTED:
|
||||
return mate::StringToV8(isolate, "evicted");
|
||||
case network::mojom::CookieChangeCause::EXPIRED_OVERWRITE:
|
||||
return mate::StringToV8(isolate, "expired-overwrite");
|
||||
default:
|
||||
return mate::StringToV8(isolate, "unknown");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
namespace {
|
||||
|
||||
// Returns whether |domain| matches |filter|.
|
||||
bool MatchesDomain(std::string filter, const std::string& domain) {
|
||||
// Add a leading '.' character to the filter domain if it doesn't exist.
|
||||
if (net::cookie_util::DomainIsHostOnly(filter))
|
||||
filter.insert(0, ".");
|
||||
|
||||
std::string sub_domain(domain);
|
||||
// Strip any leading '.' character from the input cookie domain.
|
||||
if (!net::cookie_util::DomainIsHostOnly(sub_domain))
|
||||
sub_domain = sub_domain.substr(1);
|
||||
|
||||
// Now check whether the domain argument is a subdomain of the filter domain.
|
||||
for (sub_domain.insert(0, "."); sub_domain.length() >= filter.length();) {
|
||||
if (sub_domain == filter)
|
||||
return true;
|
||||
const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot.
|
||||
sub_domain.erase(0, next_dot);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns whether |cookie| matches |filter|.
|
||||
bool MatchesCookie(const base::DictionaryValue* filter,
|
||||
const net::CanonicalCookie& cookie) {
|
||||
std::string str;
|
||||
bool b;
|
||||
if (filter->GetString("name", &str) && str != cookie.Name())
|
||||
return false;
|
||||
if (filter->GetString("path", &str) && str != cookie.Path())
|
||||
return false;
|
||||
if (filter->GetString("domain", &str) && !MatchesDomain(str, cookie.Domain()))
|
||||
return false;
|
||||
if (filter->GetBoolean("secure", &b) && b != cookie.IsSecure())
|
||||
return false;
|
||||
if (filter->GetBoolean("session", &b) && b != !cookie.IsPersistent())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Helper to returns the CookieStore.
|
||||
inline net::CookieStore* GetCookieStore(
|
||||
scoped_refptr<net::URLRequestContextGetter> getter) {
|
||||
return getter->GetURLRequestContext()->cookie_store();
|
||||
}
|
||||
|
||||
// Remove cookies from |list| not matching |filter|, and pass it to |callback|.
|
||||
void FilterCookies(std::unique_ptr<base::DictionaryValue> filter,
|
||||
util::Promise promise,
|
||||
const net::CookieList& list,
|
||||
const net::CookieStatusList& excluded_list) {
|
||||
net::CookieList result;
|
||||
for (const auto& cookie : list) {
|
||||
if (MatchesCookie(filter.get(), cookie))
|
||||
result.push_back(cookie);
|
||||
}
|
||||
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::UI},
|
||||
base::BindOnce(util::Promise::ResolvePromise<const net::CookieList&>,
|
||||
std::move(promise), std::move(result)));
|
||||
}
|
||||
|
||||
// Receives cookies matching |filter| in IO thread.
|
||||
void GetCookiesOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||
std::unique_ptr<base::DictionaryValue> filter,
|
||||
util::Promise promise) {
|
||||
std::string url;
|
||||
filter->GetString("url", &url);
|
||||
|
||||
auto filtered_callback =
|
||||
base::BindOnce(FilterCookies, std::move(filter), std::move(promise));
|
||||
|
||||
// Empty url will match all url cookies.
|
||||
if (url.empty())
|
||||
GetCookieStore(getter)->GetAllCookiesAsync(std::move(filtered_callback));
|
||||
else
|
||||
GetCookieStore(getter)->GetAllCookiesForURLAsync(
|
||||
GURL(url), std::move(filtered_callback));
|
||||
}
|
||||
|
||||
// Removes cookie with |url| and |name| in IO thread.
|
||||
void RemoveCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||
const GURL& url,
|
||||
const std::string& name,
|
||||
util::Promise promise) {
|
||||
net::CookieDeletionInfo cookie_info;
|
||||
cookie_info.url = url;
|
||||
cookie_info.name = name;
|
||||
GetCookieStore(getter)->DeleteAllMatchingInfoAsync(
|
||||
std::move(cookie_info),
|
||||
base::BindOnce(
|
||||
[](util::Promise promise, uint32_t num_deleted) {
|
||||
util::Promise::ResolveEmptyPromise(std::move(promise));
|
||||
},
|
||||
std::move(promise)));
|
||||
}
|
||||
|
||||
// Callback of SetCookie.
|
||||
void OnSetCookie(util::Promise promise,
|
||||
net::CanonicalCookie::CookieInclusionStatus status) {
|
||||
std::string errmsg;
|
||||
switch (status) {
|
||||
case net::CanonicalCookie::CookieInclusionStatus::EXCLUDE_HTTP_ONLY:
|
||||
errmsg = "Failed to create httponly cookie";
|
||||
break;
|
||||
case net::CanonicalCookie::CookieInclusionStatus::EXCLUDE_SECURE_ONLY:
|
||||
errmsg = "Cannot create a secure cookie from an insecure URL";
|
||||
break;
|
||||
case net::CanonicalCookie::CookieInclusionStatus::EXCLUDE_FAILURE_TO_STORE:
|
||||
errmsg = "Failed to parse cookie";
|
||||
break;
|
||||
case net::CanonicalCookie::CookieInclusionStatus::EXCLUDE_INVALID_DOMAIN:
|
||||
errmsg = "Failed to get cookie domain";
|
||||
break;
|
||||
case net::CanonicalCookie::CookieInclusionStatus::EXCLUDE_INVALID_PREFIX:
|
||||
errmsg = "Failed because the cookie violated prefix rules.";
|
||||
break;
|
||||
case net::CanonicalCookie::CookieInclusionStatus::
|
||||
EXCLUDE_NONCOOKIEABLE_SCHEME:
|
||||
errmsg = "Cannot set cookie for current scheme";
|
||||
break;
|
||||
case net::CanonicalCookie::CookieInclusionStatus::INCLUDE:
|
||||
errmsg = "";
|
||||
break;
|
||||
default:
|
||||
errmsg = "Setting cookie failed";
|
||||
break;
|
||||
}
|
||||
if (errmsg.empty()) {
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::UI},
|
||||
base::BindOnce(util::Promise::ResolveEmptyPromise, std::move(promise)));
|
||||
} else {
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::UI},
|
||||
base::BindOnce(util::Promise::RejectPromise, std::move(promise),
|
||||
std::move(errmsg)));
|
||||
}
|
||||
}
|
||||
|
||||
// Flushes cookie store in IO thread.
|
||||
void FlushCookieStoreOnIOThread(
|
||||
scoped_refptr<net::URLRequestContextGetter> getter,
|
||||
util::Promise promise) {
|
||||
GetCookieStore(getter)->FlushStore(
|
||||
base::BindOnce(util::Promise::ResolveEmptyPromise, std::move(promise)));
|
||||
}
|
||||
|
||||
// Sets cookie with |details| in IO thread.
|
||||
void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||
std::unique_ptr<base::DictionaryValue> details,
|
||||
util::Promise promise) {
|
||||
std::string url_string, name, value, domain, path;
|
||||
bool secure = false;
|
||||
bool http_only = false;
|
||||
double creation_date;
|
||||
double expiration_date;
|
||||
double last_access_date;
|
||||
details->GetString("url", &url_string);
|
||||
details->GetString("name", &name);
|
||||
details->GetString("value", &value);
|
||||
details->GetString("domain", &domain);
|
||||
details->GetString("path", &path);
|
||||
details->GetBoolean("secure", &secure);
|
||||
details->GetBoolean("httpOnly", &http_only);
|
||||
|
||||
base::Time creation_time;
|
||||
if (details->GetDouble("creationDate", &creation_date)) {
|
||||
creation_time = (creation_date == 0)
|
||||
? base::Time::UnixEpoch()
|
||||
: base::Time::FromDoubleT(creation_date);
|
||||
}
|
||||
|
||||
base::Time expiration_time;
|
||||
if (details->GetDouble("expirationDate", &expiration_date)) {
|
||||
expiration_time = (expiration_date == 0)
|
||||
? base::Time::UnixEpoch()
|
||||
: base::Time::FromDoubleT(expiration_date);
|
||||
}
|
||||
|
||||
base::Time last_access_time;
|
||||
if (details->GetDouble("lastAccessDate", &last_access_date)) {
|
||||
last_access_time = (last_access_date == 0)
|
||||
? base::Time::UnixEpoch()
|
||||
: base::Time::FromDoubleT(last_access_date);
|
||||
}
|
||||
|
||||
GURL url(url_string);
|
||||
std::unique_ptr<net::CanonicalCookie> canonical_cookie(
|
||||
net::CanonicalCookie::CreateSanitizedCookie(
|
||||
url, name, value, domain, path, creation_time, expiration_time,
|
||||
last_access_time, secure, http_only,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_DEFAULT));
|
||||
auto completion_callback = base::BindOnce(OnSetCookie, std::move(promise));
|
||||
if (!canonical_cookie || !canonical_cookie->IsCanonical()) {
|
||||
std::move(completion_callback)
|
||||
.Run(net::CanonicalCookie::CookieInclusionStatus::
|
||||
EXCLUDE_FAILURE_TO_STORE);
|
||||
return;
|
||||
}
|
||||
if (!url.is_valid()) {
|
||||
std::move(completion_callback)
|
||||
.Run(net::CanonicalCookie::CookieInclusionStatus::
|
||||
EXCLUDE_INVALID_DOMAIN);
|
||||
return;
|
||||
}
|
||||
if (name.empty()) {
|
||||
std::move(completion_callback)
|
||||
.Run(net::CanonicalCookie::CookieInclusionStatus::
|
||||
EXCLUDE_FAILURE_TO_STORE);
|
||||
return;
|
||||
}
|
||||
net::CookieOptions options;
|
||||
if (http_only) {
|
||||
options.set_include_httponly();
|
||||
}
|
||||
GetCookieStore(getter)->SetCanonicalCookieAsync(
|
||||
std::move(canonical_cookie), url.scheme(), options,
|
||||
std::move(completion_callback));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Cookies::Cookies(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
||||
: browser_context_(browser_context) {
|
||||
Init(isolate);
|
||||
cookie_change_subscription_ =
|
||||
browser_context_->cookie_change_notifier()->RegisterCookieChangeCallback(
|
||||
base::Bind(&Cookies::OnCookieChanged, base::Unretained(this)));
|
||||
}
|
||||
|
||||
Cookies::~Cookies() {}
|
||||
|
||||
v8::Local<v8::Promise> Cookies::Get(const base::DictionaryValue& filter) {
|
||||
util::Promise promise(isolate());
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
auto copy = base::DictionaryValue::From(
|
||||
base::Value::ToUniquePtrValue(filter.Clone()));
|
||||
auto* getter = browser_context_->GetRequestContext();
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(GetCookiesOnIO, base::RetainedRef(getter), std::move(copy),
|
||||
std::move(promise)));
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> Cookies::Remove(const GURL& url,
|
||||
const std::string& name) {
|
||||
util::Promise promise(isolate());
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
auto* getter = browser_context_->GetRequestContext();
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(RemoveCookieOnIO, base::RetainedRef(getter), url, name,
|
||||
std::move(promise)));
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> Cookies::Set(const base::DictionaryValue& details) {
|
||||
util::Promise promise(isolate());
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
auto copy = base::DictionaryValue::From(
|
||||
base::Value::ToUniquePtrValue(details.Clone()));
|
||||
auto* getter = browser_context_->GetRequestContext();
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(SetCookieOnIO, base::RetainedRef(getter), std::move(copy),
|
||||
std::move(promise)));
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> Cookies::FlushStore() {
|
||||
util::Promise promise(isolate());
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
auto* getter = browser_context_->GetRequestContext();
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(FlushCookieStoreOnIOThread, base::RetainedRef(getter),
|
||||
std::move(promise)));
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void Cookies::OnCookieChanged(const CookieDetails* details) {
|
||||
Emit("changed", *(details->cookie), details->cause, details->removed);
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<Cookies> Cookies::Create(v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context) {
|
||||
return mate::CreateHandle(isolate, new Cookies(isolate, browser_context));
|
||||
}
|
||||
|
||||
// static
|
||||
void Cookies::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "Cookies"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("get", &Cookies::Get)
|
||||
.SetMethod("remove", &Cookies::Remove)
|
||||
.SetMethod("set", &Cookies::Set)
|
||||
.SetMethod("flushStore", &Cookies::FlushStore);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
@@ -1,132 +0,0 @@
|
||||
// Copyright (c) 2013 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/api/atom_api_browser_window.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/ui/certificate_trust.h"
|
||||
#include "atom/browser/ui/file_dialog.h"
|
||||
#include "atom/browser/ui/message_box.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/file_dialog_converter.h"
|
||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||
#include "atom/common/native_mate_converters/image_converter.h"
|
||||
#include "atom/common/native_mate_converters/net_converter.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "atom/common/promise_util.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
||||
namespace {
|
||||
|
||||
int ShowMessageBoxSync(int type,
|
||||
const std::vector<std::string>& buttons,
|
||||
int default_id,
|
||||
int cancel_id,
|
||||
int options,
|
||||
const std::string& title,
|
||||
const std::string& message,
|
||||
const std::string& detail,
|
||||
const std::string& checkbox_label,
|
||||
bool checkbox_checked,
|
||||
const gfx::ImageSkia& icon,
|
||||
atom::NativeWindow* window) {
|
||||
return atom::ShowMessageBoxSync(
|
||||
window, static_cast<atom::MessageBoxType>(type), buttons, default_id,
|
||||
cancel_id, options, title, message, detail, icon);
|
||||
}
|
||||
|
||||
void ResolvePromiseObject(atom::util::Promise promise,
|
||||
int result,
|
||||
bool checkbox_checked) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(promise.isolate());
|
||||
|
||||
dict.Set("response", result);
|
||||
dict.Set("checkboxChecked", checkbox_checked);
|
||||
|
||||
promise.Resolve(dict.GetHandle());
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> ShowMessageBox(int type,
|
||||
const std::vector<std::string>& buttons,
|
||||
int default_id,
|
||||
int cancel_id,
|
||||
int options,
|
||||
const std::string& title,
|
||||
const std::string& message,
|
||||
const std::string& detail,
|
||||
const std::string& checkbox_label,
|
||||
bool checkbox_checked,
|
||||
const gfx::ImageSkia& icon,
|
||||
atom::NativeWindow* window,
|
||||
mate::Arguments* args) {
|
||||
v8::Isolate* isolate = args->isolate();
|
||||
atom::util::Promise promise(isolate);
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
atom::ShowMessageBox(
|
||||
window, static_cast<atom::MessageBoxType>(type), buttons, default_id,
|
||||
cancel_id, options, title, message, detail, checkbox_label,
|
||||
checkbox_checked, icon,
|
||||
base::BindOnce(&ResolvePromiseObject, std::move(promise)));
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void ShowOpenDialogSync(const file_dialog::DialogSettings& settings,
|
||||
mate::Arguments* args) {
|
||||
std::vector<base::FilePath> paths;
|
||||
if (file_dialog::ShowOpenDialogSync(settings, &paths))
|
||||
args->Return(paths);
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> ShowOpenDialog(
|
||||
const file_dialog::DialogSettings& settings,
|
||||
mate::Arguments* args) {
|
||||
atom::util::Promise promise(args->isolate());
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
file_dialog::ShowOpenDialog(settings, std::move(promise));
|
||||
return handle;
|
||||
}
|
||||
|
||||
void ShowSaveDialogSync(const file_dialog::DialogSettings& settings,
|
||||
mate::Arguments* args) {
|
||||
base::FilePath path;
|
||||
if (file_dialog::ShowSaveDialogSync(settings, &path))
|
||||
args->Return(path);
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> ShowSaveDialog(
|
||||
const file_dialog::DialogSettings& settings,
|
||||
mate::Arguments* args) {
|
||||
atom::util::Promise promise(args->isolate());
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
file_dialog::ShowSaveDialog(settings, std::move(promise));
|
||||
return handle;
|
||||
}
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("showMessageBoxSync", &ShowMessageBoxSync);
|
||||
dict.SetMethod("showMessageBox", &ShowMessageBox);
|
||||
dict.SetMethod("showErrorBox", &atom::ShowErrorBox);
|
||||
dict.SetMethod("showOpenDialogSync", &ShowOpenDialogSync);
|
||||
dict.SetMethod("showOpenDialog", &ShowOpenDialog);
|
||||
dict.SetMethod("showSaveDialogSync", &ShowSaveDialogSync);
|
||||
dict.SetMethod("showSaveDialog", &ShowSaveDialog);
|
||||
#if defined(OS_MACOSX) || defined(OS_WIN)
|
||||
dict.SetMethod("showCertificateTrustDialog",
|
||||
&certificate_trust::ShowCertificateTrust);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_dialog, Initialize)
|
||||
@@ -1,140 +0,0 @@
|
||||
// Copyright (c) 2018 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/api/atom_api_net_log.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/net/system_network_context_manager.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "base/command_line.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "components/net_log/chrome_net_log.h"
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "net/url_request/url_request_context_getter.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
NetLog::NetLog(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
||||
: browser_context_(browser_context) {
|
||||
Init(isolate);
|
||||
|
||||
net_log_writer_ = g_browser_process->system_network_context_manager()
|
||||
->GetNetExportFileWriter();
|
||||
net_log_writer_->AddObserver(this);
|
||||
}
|
||||
|
||||
NetLog::~NetLog() {
|
||||
net_log_writer_->RemoveObserver(this);
|
||||
}
|
||||
|
||||
void NetLog::StartLogging(mate::Arguments* args) {
|
||||
base::FilePath log_path;
|
||||
if (!args->GetNext(&log_path) || log_path.empty()) {
|
||||
args->ThrowError("The first parameter must be a valid string");
|
||||
return;
|
||||
}
|
||||
|
||||
auto* network_context =
|
||||
content::BrowserContext::GetDefaultStoragePartition(browser_context_)
|
||||
->GetNetworkContext();
|
||||
|
||||
// TODO(deepak1556): Provide more flexibility to this module
|
||||
// by allowing customizations on the capturing options.
|
||||
net_log_writer_->StartNetLog(
|
||||
log_path, net::NetLogCaptureMode::Default(),
|
||||
net_log::NetExportFileWriter::kNoLimit /* file size limit */,
|
||||
base::CommandLine::ForCurrentProcess()->GetCommandLineString(),
|
||||
std::string(), network_context);
|
||||
}
|
||||
|
||||
std::string NetLog::GetLoggingState() const {
|
||||
if (!net_log_state_)
|
||||
return std::string();
|
||||
const base::Value* current_log_state =
|
||||
net_log_state_->FindKeyOfType("state", base::Value::Type::STRING);
|
||||
if (!current_log_state)
|
||||
return std::string();
|
||||
return current_log_state->GetString();
|
||||
}
|
||||
|
||||
bool NetLog::IsCurrentlyLogging() const {
|
||||
const std::string log_state = GetLoggingState();
|
||||
return (log_state == "STARTING_LOG") || (log_state == "LOGGING");
|
||||
}
|
||||
|
||||
std::string NetLog::GetCurrentlyLoggingPath() const {
|
||||
// Net log exporter has a default path which will be used
|
||||
// when no log path is provided, but since we don't allow
|
||||
// net log capture without user provided file path, this
|
||||
// check is completely safe.
|
||||
if (IsCurrentlyLogging()) {
|
||||
const base::Value* current_log_path =
|
||||
net_log_state_->FindKeyOfType("file", base::Value::Type::STRING);
|
||||
if (current_log_path)
|
||||
return current_log_path->GetString();
|
||||
}
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> NetLog::StopLogging(mate::Arguments* args) {
|
||||
util::Promise promise(isolate());
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
if (IsCurrentlyLogging()) {
|
||||
stop_callback_queue_.emplace_back(std::move(promise));
|
||||
net_log_writer_->StopNetLog(nullptr);
|
||||
} else {
|
||||
promise.Resolve(base::FilePath());
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void NetLog::OnNewState(const base::DictionaryValue& state) {
|
||||
net_log_state_ = state.CreateDeepCopy();
|
||||
|
||||
if (stop_callback_queue_.empty())
|
||||
return;
|
||||
|
||||
if (GetLoggingState() == "NOT_LOGGING") {
|
||||
for (auto& promise : stop_callback_queue_) {
|
||||
// TODO(zcbenz): Remove the use of CopyablePromise when the
|
||||
// GetFilePathToCompletedLog API accepts OnceCallback.
|
||||
net_log_writer_->GetFilePathToCompletedLog(base::Bind(
|
||||
util::CopyablePromise::ResolveCopyablePromise<const base::FilePath&>,
|
||||
util::CopyablePromise(promise)));
|
||||
}
|
||||
stop_callback_queue_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<NetLog> NetLog::Create(v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context) {
|
||||
return mate::CreateHandle(isolate, new NetLog(isolate, browser_context));
|
||||
}
|
||||
|
||||
// static
|
||||
void NetLog::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "NetLog"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetProperty("currentlyLogging", &NetLog::IsCurrentlyLogging)
|
||||
.SetProperty("currentlyLoggingPath", &NetLog::GetCurrentlyLoggingPath)
|
||||
.SetMethod("startLogging", &NetLog::StartLogging)
|
||||
.SetMethod("stopLogging", &NetLog::StopLogging);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
@@ -1,60 +0,0 @@
|
||||
// Copyright (c) 2018 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_API_ATOM_API_NET_LOG_H_
|
||||
#define ATOM_BROWSER_API_ATOM_API_NET_LOG_H_
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "atom/browser/api/trackable_object.h"
|
||||
#include "atom/common/promise_util.h"
|
||||
#include "base/callback.h"
|
||||
#include "base/values.h"
|
||||
#include "components/net_log/net_export_file_writer.h"
|
||||
#include "native_mate/handle.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class AtomBrowserContext;
|
||||
|
||||
namespace api {
|
||||
|
||||
class NetLog : public mate::TrackableObject<NetLog>,
|
||||
public net_log::NetExportFileWriter::StateObserver {
|
||||
public:
|
||||
static mate::Handle<NetLog> Create(v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context);
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
void StartLogging(mate::Arguments* args);
|
||||
std::string GetLoggingState() const;
|
||||
bool IsCurrentlyLogging() const;
|
||||
std::string GetCurrentlyLoggingPath() const;
|
||||
v8::Local<v8::Promise> StopLogging(mate::Arguments* args);
|
||||
|
||||
protected:
|
||||
explicit NetLog(v8::Isolate* isolate, AtomBrowserContext* browser_context);
|
||||
~NetLog() override;
|
||||
|
||||
// net_log::NetExportFileWriter::StateObserver implementation
|
||||
void OnNewState(const base::DictionaryValue& state) override;
|
||||
|
||||
private:
|
||||
AtomBrowserContext* browser_context_;
|
||||
net_log::NetExportFileWriter* net_log_writer_;
|
||||
std::list<atom::util::Promise> stop_callback_queue_;
|
||||
std::unique_ptr<base::DictionaryValue> net_log_state_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(NetLog);
|
||||
};
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_API_ATOM_API_NET_LOG_H_
|
||||
@@ -1,90 +0,0 @@
|
||||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/api/atom_api_render_process_preferences.h"
|
||||
|
||||
#include "atom/browser/api/atom_api_web_contents.h"
|
||||
#include "atom/browser/atom_browser_client.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
namespace {
|
||||
|
||||
bool IsWebContents(v8::Isolate* isolate, content::RenderProcessHost* process) {
|
||||
content::WebContents* web_contents =
|
||||
static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())
|
||||
->GetWebContentsFromProcessID(process->GetID());
|
||||
if (!web_contents)
|
||||
return false;
|
||||
|
||||
auto api_web_contents = WebContents::FromOrCreate(isolate, web_contents);
|
||||
auto type = api_web_contents->GetType();
|
||||
return type == WebContents::Type::BROWSER_WINDOW ||
|
||||
type == WebContents::Type::WEB_VIEW;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
RenderProcessPreferences::RenderProcessPreferences(
|
||||
v8::Isolate* isolate,
|
||||
const atom::RenderProcessPreferences::Predicate& predicate)
|
||||
: preferences_(predicate) {
|
||||
Init(isolate);
|
||||
}
|
||||
|
||||
RenderProcessPreferences::~RenderProcessPreferences() {}
|
||||
|
||||
int RenderProcessPreferences::AddEntry(const base::DictionaryValue& entry) {
|
||||
return preferences_.AddEntry(entry);
|
||||
}
|
||||
|
||||
void RenderProcessPreferences::RemoveEntry(int id) {
|
||||
preferences_.RemoveEntry(id);
|
||||
}
|
||||
|
||||
// static
|
||||
void RenderProcessPreferences::BuildPrototype(
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(
|
||||
mate::StringToV8(isolate, "RenderProcessPreferences"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("addEntry", &RenderProcessPreferences::AddEntry)
|
||||
.SetMethod("removeEntry", &RenderProcessPreferences::RemoveEntry);
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<RenderProcessPreferences>
|
||||
RenderProcessPreferences::ForAllWebContents(v8::Isolate* isolate) {
|
||||
return mate::CreateHandle(isolate,
|
||||
new RenderProcessPreferences(
|
||||
isolate, base::Bind(&IsWebContents, isolate)));
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
namespace {
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("forAllWebContents",
|
||||
&atom::api::RenderProcessPreferences::ForAllWebContents);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_render_process_preferences,
|
||||
Initialize)
|
||||
@@ -1,44 +0,0 @@
|
||||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_API_ATOM_API_RENDER_PROCESS_PREFERENCES_H_
|
||||
#define ATOM_BROWSER_API_ATOM_API_RENDER_PROCESS_PREFERENCES_H_
|
||||
|
||||
#include "atom/browser/render_process_preferences.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
class RenderProcessPreferences
|
||||
: public mate::Wrappable<RenderProcessPreferences> {
|
||||
public:
|
||||
static mate::Handle<RenderProcessPreferences> ForAllWebContents(
|
||||
v8::Isolate* isolate);
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
int AddEntry(const base::DictionaryValue& entry);
|
||||
void RemoveEntry(int id);
|
||||
|
||||
protected:
|
||||
RenderProcessPreferences(
|
||||
v8::Isolate* isolate,
|
||||
const atom::RenderProcessPreferences::Predicate& predicate);
|
||||
~RenderProcessPreferences() override;
|
||||
|
||||
private:
|
||||
atom::RenderProcessPreferences preferences_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(RenderProcessPreferences);
|
||||
};
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_API_ATOM_API_RENDER_PROCESS_PREFERENCES_H_
|
||||
@@ -1,68 +0,0 @@
|
||||
// Copyright (c) 2013 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
|
||||
#include "atom/browser/atom_paths.h"
|
||||
#include "atom/browser/mac/atom_application_delegate.h"
|
||||
#include "base/mac/bundle_locations.h"
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "base/path_service.h"
|
||||
#include "ui/base/l10n/l10n_util_mac.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
void AtomBrowserMainParts::PreMainMessageLoopStart() {
|
||||
// Set our own application delegate.
|
||||
AtomApplicationDelegate* delegate = [[AtomApplicationDelegate alloc] init];
|
||||
[NSApp setDelegate:delegate];
|
||||
|
||||
PreMainMessageLoopStartCommon();
|
||||
|
||||
// Prevent Cocoa from turning command-line arguments into
|
||||
// |-application:openFiles:|, since we already handle them directly.
|
||||
[[NSUserDefaults standardUserDefaults]
|
||||
setObject:@"NO"
|
||||
forKey:@"NSTreatUnknownArgumentsAsOpen"];
|
||||
}
|
||||
|
||||
void AtomBrowserMainParts::FreeAppDelegate() {
|
||||
[[NSApp delegate] release];
|
||||
[NSApp setDelegate:nil];
|
||||
}
|
||||
|
||||
// Replicates NSApplicationMain, but doesn't start a run loop.
|
||||
void AtomBrowserMainParts::InitializeMainNib() {
|
||||
auto infoDictionary = base::mac::OuterBundle().infoDictionary;
|
||||
|
||||
auto principalClass =
|
||||
NSClassFromString([infoDictionary objectForKey:@"NSPrincipalClass"]);
|
||||
auto application = [principalClass sharedApplication];
|
||||
|
||||
NSString* mainNibName = [infoDictionary objectForKey:@"NSMainNibFile"];
|
||||
|
||||
NSNib* mainNib;
|
||||
|
||||
@try {
|
||||
mainNib = [[NSNib alloc] initWithNibNamed:mainNibName
|
||||
bundle:base::mac::FrameworkBundle()];
|
||||
// Handle failure of initWithNibNamed on SMB shares
|
||||
// TODO(codebytere): Remove when
|
||||
// https://bugs.chromium.org/p/chromium/issues/detail?id=932935 is fixed
|
||||
} @catch (NSException* exception) {
|
||||
NSString* nibPath =
|
||||
[NSString stringWithFormat:@"Resources/%@.nib", mainNibName];
|
||||
nibPath = [base::mac::FrameworkBundle().bundlePath
|
||||
stringByAppendingPathComponent:nibPath];
|
||||
|
||||
NSData* data = [NSData dataWithContentsOfFile:nibPath];
|
||||
mainNib = [[NSNib alloc] initWithNibData:data
|
||||
bundle:base::mac::FrameworkBundle()];
|
||||
}
|
||||
|
||||
[mainNib instantiateWithOwner:application topLevelObjects:nil];
|
||||
[mainNib release];
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
@@ -1,106 +0,0 @@
|
||||
// Copyright (c) 2015 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/atom_resource_dispatcher_host_delegate.h"
|
||||
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/web_contents_preferences.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/download_manager.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "net/base/escape.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
#include "atom/common/atom_constants.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "content/public/browser/stream_info.h"
|
||||
#include "net/url_request/url_request.h"
|
||||
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
void OnPdfResourceIntercepted(
|
||||
const GURL& original_url,
|
||||
int render_process_host_id,
|
||||
int render_frame_id,
|
||||
const content::ResourceRequestInfo::WebContentsGetter&
|
||||
web_contents_getter) {
|
||||
content::WebContents* web_contents = web_contents_getter.Run();
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
auto* web_preferences = WebContentsPreferences::From(web_contents);
|
||||
if (!web_preferences || !web_preferences->IsEnabled(options::kPlugins)) {
|
||||
auto* browser_context = web_contents->GetBrowserContext();
|
||||
auto* download_manager =
|
||||
content::BrowserContext::GetDownloadManager(browser_context);
|
||||
|
||||
download_manager->DownloadUrl(
|
||||
content::DownloadUrlParameters::CreateForWebContentsMainFrame(
|
||||
web_contents, original_url, NO_TRAFFIC_ANNOTATION_YET));
|
||||
return;
|
||||
}
|
||||
|
||||
// The URL passes the original pdf resource url, that will be requested
|
||||
// by the webui page.
|
||||
// chrome://pdf-viewer/index.html?src=https://somepage/123.pdf
|
||||
content::NavigationController::LoadURLParams params(GURL(base::StringPrintf(
|
||||
"%sindex.html?%s=%s", kPdfViewerUIOrigin, kPdfPluginSrc,
|
||||
net::EscapeUrlEncodedData(original_url.spec(), false).c_str())));
|
||||
|
||||
content::RenderFrameHost* frame_host =
|
||||
content::RenderFrameHost::FromID(render_process_host_id, render_frame_id);
|
||||
if (!frame_host) {
|
||||
return;
|
||||
}
|
||||
|
||||
params.frame_tree_node_id = frame_host->GetFrameTreeNodeId();
|
||||
web_contents->GetController().LoadURLWithParams(params);
|
||||
}
|
||||
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
|
||||
} // namespace
|
||||
|
||||
AtomResourceDispatcherHostDelegate::AtomResourceDispatcherHostDelegate() {}
|
||||
|
||||
bool AtomResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream(
|
||||
net::URLRequest* request,
|
||||
const std::string& mime_type,
|
||||
GURL* origin,
|
||||
std::string* payload) {
|
||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
content::ResourceRequestInfo* info =
|
||||
content::ResourceRequestInfo::ForRequest(request);
|
||||
|
||||
int render_process_host_id;
|
||||
int render_frame_id;
|
||||
if (!info->GetAssociatedRenderFrame(&render_process_host_id,
|
||||
&render_frame_id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mime_type == "application/pdf") {
|
||||
*origin = GURL(kPdfViewerUIOrigin);
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::UI},
|
||||
base::Bind(&OnPdfResourceIntercepted, request->url(),
|
||||
render_process_host_id, render_frame_id,
|
||||
info->GetWebContentsGetterForRequest()));
|
||||
return true;
|
||||
}
|
||||
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
@@ -1,31 +0,0 @@
|
||||
// Copyright (c) 2015 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_ATOM_RESOURCE_DISPATCHER_HOST_DELEGATE_H_
|
||||
#define ATOM_BROWSER_ATOM_RESOURCE_DISPATCHER_HOST_DELEGATE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "content/public/browser/resource_dispatcher_host_delegate.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class AtomResourceDispatcherHostDelegate
|
||||
: public content::ResourceDispatcherHostDelegate {
|
||||
public:
|
||||
AtomResourceDispatcherHostDelegate();
|
||||
|
||||
// content::ResourceDispatcherHostDelegate:
|
||||
bool ShouldInterceptResourceAsStream(net::URLRequest* request,
|
||||
const std::string& mime_type,
|
||||
GURL* origin,
|
||||
std::string* payload) override;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomResourceDispatcherHostDelegate);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_ATOM_RESOURCE_DISPATCHER_HOST_DELEGATE_H_
|
||||
@@ -1,22 +0,0 @@
|
||||
// Copyright (c) 2015 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_NOTIFICATIONS_MAC_NOTIFICATION_CENTER_DELEGATE_H_
|
||||
#define ATOM_BROWSER_NOTIFICATIONS_MAC_NOTIFICATION_CENTER_DELEGATE_H_
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
namespace atom {
|
||||
class NotificationPresenterMac;
|
||||
}
|
||||
|
||||
@interface NotificationCenterDelegate
|
||||
: NSObject <NSUserNotificationCenterDelegate> {
|
||||
@private
|
||||
atom::NotificationPresenterMac* presenter_;
|
||||
}
|
||||
- (instancetype)initWithPresenter:(atom::NotificationPresenterMac*)presenter;
|
||||
@end
|
||||
|
||||
#endif // ATOM_BROWSER_NOTIFICATIONS_MAC_NOTIFICATION_CENTER_DELEGATE_H_
|
||||
@@ -1,60 +0,0 @@
|
||||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/render_process_preferences.h"
|
||||
|
||||
#include "atom/common/api/api_messages.h"
|
||||
#include "content/public/browser/notification_service.h"
|
||||
#include "content/public/browser/notification_types.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
RenderProcessPreferences::RenderProcessPreferences(const Predicate& predicate)
|
||||
: predicate_(predicate) {
|
||||
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED,
|
||||
content::NotificationService::AllBrowserContextsAndSources());
|
||||
}
|
||||
|
||||
RenderProcessPreferences::~RenderProcessPreferences() {}
|
||||
|
||||
int RenderProcessPreferences::AddEntry(const base::DictionaryValue& entry) {
|
||||
int id = ++next_id_;
|
||||
entries_[id] =
|
||||
base::DictionaryValue::From(base::Value::ToUniquePtrValue(entry.Clone()));
|
||||
cache_needs_update_ = true;
|
||||
return id;
|
||||
}
|
||||
|
||||
void RenderProcessPreferences::RemoveEntry(int id) {
|
||||
cache_needs_update_ = true;
|
||||
entries_.erase(id);
|
||||
}
|
||||
|
||||
void RenderProcessPreferences::Observe(
|
||||
int type,
|
||||
const content::NotificationSource& source,
|
||||
const content::NotificationDetails& details) {
|
||||
DCHECK_EQ(type, content::NOTIFICATION_RENDERER_PROCESS_CREATED);
|
||||
content::RenderProcessHost* process =
|
||||
content::Source<content::RenderProcessHost>(source).ptr();
|
||||
|
||||
if (!predicate_.Run(process))
|
||||
return;
|
||||
|
||||
UpdateCache();
|
||||
process->Send(new AtomMsg_UpdatePreferences(cached_entries_));
|
||||
}
|
||||
|
||||
void RenderProcessPreferences::UpdateCache() {
|
||||
if (!cache_needs_update_)
|
||||
return;
|
||||
|
||||
cached_entries_.Clear();
|
||||
for (const auto& iter : entries_)
|
||||
cached_entries_.Append(base::Value::ToUniquePtrValue(iter.second->Clone()));
|
||||
cache_needs_update_ = false;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
@@ -1,61 +0,0 @@
|
||||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_RENDER_PROCESS_PREFERENCES_H_
|
||||
#define ATOM_BROWSER_RENDER_PROCESS_PREFERENCES_H_
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "base/values.h"
|
||||
#include "content/public/browser/notification_observer.h"
|
||||
#include "content/public/browser/notification_registrar.h"
|
||||
|
||||
namespace content {
|
||||
class RenderProcessHost;
|
||||
}
|
||||
|
||||
namespace atom {
|
||||
|
||||
// Sets user preferences for render processes.
|
||||
class RenderProcessPreferences : public content::NotificationObserver {
|
||||
public:
|
||||
using Predicate = base::Callback<bool(content::RenderProcessHost*)>;
|
||||
|
||||
// The |predicate| is used to determine whether to set preferences for a
|
||||
// render process.
|
||||
explicit RenderProcessPreferences(const Predicate& predicate);
|
||||
~RenderProcessPreferences() override;
|
||||
|
||||
int AddEntry(const base::DictionaryValue& entry);
|
||||
void RemoveEntry(int id);
|
||||
|
||||
private:
|
||||
// content::NotificationObserver:
|
||||
void Observe(int type,
|
||||
const content::NotificationSource& source,
|
||||
const content::NotificationDetails& details) override;
|
||||
|
||||
void UpdateCache();
|
||||
|
||||
// Manages our notification registrations.
|
||||
content::NotificationRegistrar registrar_;
|
||||
|
||||
Predicate predicate_;
|
||||
|
||||
int next_id_ = 0;
|
||||
std::unordered_map<int, std::unique_ptr<base::DictionaryValue>> entries_;
|
||||
|
||||
// We need to convert the |entries_| to ListValue for multiple times, this
|
||||
// caches is only updated when we are sending messages.
|
||||
bool cache_needs_update_ = true;
|
||||
base::ListValue cached_entries_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(RenderProcessPreferences);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_RENDER_PROCESS_PREFERENCES_H_
|
||||
@@ -1,61 +0,0 @@
|
||||
// Copyright (c) 2017 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/session_preferences.h"
|
||||
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
#if defined(OS_WIN)
|
||||
const base::FilePath::CharType kPathDelimiter = FILE_PATH_LITERAL(';');
|
||||
#else
|
||||
const base::FilePath::CharType kPathDelimiter = FILE_PATH_LITERAL(':');
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
int SessionPreferences::kLocatorKey = 0;
|
||||
|
||||
SessionPreferences::SessionPreferences(content::BrowserContext* context) {
|
||||
context->SetUserData(&kLocatorKey, base::WrapUnique(this));
|
||||
}
|
||||
|
||||
SessionPreferences::~SessionPreferences() {}
|
||||
|
||||
// static
|
||||
SessionPreferences* SessionPreferences::FromBrowserContext(
|
||||
content::BrowserContext* context) {
|
||||
return static_cast<SessionPreferences*>(context->GetUserData(&kLocatorKey));
|
||||
}
|
||||
|
||||
// static
|
||||
void SessionPreferences::AppendExtraCommandLineSwitches(
|
||||
content::BrowserContext* context,
|
||||
base::CommandLine* command_line) {
|
||||
SessionPreferences* self = FromBrowserContext(context);
|
||||
if (!self)
|
||||
return;
|
||||
|
||||
base::FilePath::StringType preloads;
|
||||
for (const auto& preload : self->preloads()) {
|
||||
if (!base::FilePath(preload).IsAbsolute()) {
|
||||
LOG(ERROR) << "preload script must have absolute path: " << preload;
|
||||
continue;
|
||||
}
|
||||
if (preloads.empty())
|
||||
preloads = preload;
|
||||
else
|
||||
preloads += kPathDelimiter + preload;
|
||||
}
|
||||
if (!preloads.empty())
|
||||
command_line->AppendSwitchNative(switches::kPreloadScripts, preloads);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
@@ -1,267 +0,0 @@
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_UI_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_
|
||||
#define ATOM_BROWSER_UI_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_
|
||||
|
||||
// Once Chrome no longer supports OSX 10.12.0, this file can be deleted.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if !defined(MAC_OS_X_VERSION_10_12_1)
|
||||
|
||||
#pragma clang assume_nonnull begin
|
||||
|
||||
@class NSTouchBar, NSTouchBarItem;
|
||||
@class NSScrubber, NSScrubberItemView, NSScrubberArrangedView,
|
||||
NSScrubberTextItemView, NSScrubberImageItemView, NSScrubberSelectionStyle;
|
||||
@protocol NSTouchBarDelegate
|
||||
, NSScrubberDelegate, NSScrubberDataSource, NSScrubberFlowLayoutDelegate,
|
||||
NSScrubberFlowLayout;
|
||||
|
||||
typedef float NSTouchBarItemPriority;
|
||||
static const NSTouchBarItemPriority NSTouchBarItemPriorityHigh = 1000;
|
||||
static const NSTouchBarItemPriority NSTouchBarItemPriorityNormal = 0;
|
||||
static const NSTouchBarItemPriority NSTouchBarItemPriorityLow = -1000;
|
||||
|
||||
enum NSScrubberMode { NSScrubberModeFixed = 0, NSScrubberModeFree };
|
||||
|
||||
typedef NSString* NSTouchBarItemIdentifier;
|
||||
typedef NSString* NSTouchBarCustomizationIdentifier;
|
||||
|
||||
static const NSTouchBarItemIdentifier NSTouchBarItemIdentifierFixedSpaceSmall =
|
||||
@"NSTouchBarItemIdentifierFixedSpaceSmall";
|
||||
|
||||
static const NSTouchBarItemIdentifier NSTouchBarItemIdentifierFixedSpaceLarge =
|
||||
@"NSTouchBarItemIdentifierFixedSpaceLarge";
|
||||
|
||||
static const NSTouchBarItemIdentifier NSTouchBarItemIdentifierFlexibleSpace =
|
||||
@"NSTouchBarItemIdentifierFlexibleSpace";
|
||||
|
||||
static const NSTouchBarItemIdentifier NSTouchBarItemIdentifierOtherItemsProxy =
|
||||
@"NSTouchBarItemIdentifierOtherItemsProxy";
|
||||
|
||||
@interface NSTouchBar : NSObject <NSCoding>
|
||||
|
||||
- (instancetype)init NS_DESIGNATED_INITIALIZER;
|
||||
- (nullable instancetype)initWithCoder:(NSCoder*)aDecoder
|
||||
NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@property(copy, nullable)
|
||||
NSTouchBarCustomizationIdentifier customizationIdentifier;
|
||||
@property(copy) NSArray* customizationAllowedItemIdentifiers;
|
||||
@property(copy) NSArray* customizationRequiredItemIdentifiers;
|
||||
@property(copy) NSArray* defaultItemIdentifiers;
|
||||
@property(copy, readonly) NSArray* itemIdentifiers;
|
||||
@property(copy, nullable) NSTouchBarItemIdentifier principalItemIdentifier;
|
||||
@property(copy, nullable)
|
||||
NSTouchBarItemIdentifier escapeKeyReplacementItemIdentifier;
|
||||
@property(copy) NSSet* templateItems;
|
||||
@property(nullable, weak) id<NSTouchBarDelegate> delegate;
|
||||
|
||||
- (nullable __kindof NSTouchBarItem*)itemForIdentifier:
|
||||
(NSTouchBarItemIdentifier)identifier;
|
||||
|
||||
@property(readonly, getter=isVisible) BOOL visible;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSTouchBarItem : NSObject <NSCoding>
|
||||
|
||||
- (instancetype)initWithIdentifier:(NSTouchBarItemIdentifier)identifier
|
||||
NS_DESIGNATED_INITIALIZER;
|
||||
- (nullable instancetype)initWithCoder:(NSCoder*)coder
|
||||
NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@property(readonly, copy) NSTouchBarItemIdentifier identifier;
|
||||
@property NSTouchBarItemPriority visibilityPriority;
|
||||
@property(readonly, nullable) NSView* view;
|
||||
@property(readonly, nullable) NSViewController* viewController;
|
||||
@property(readwrite, copy) NSString* customizationLabel;
|
||||
@property(readonly, getter=isVisible) BOOL visible;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSGroupTouchBarItem : NSTouchBarItem
|
||||
|
||||
+ (NSGroupTouchBarItem*)groupItemWithIdentifier:
|
||||
(NSTouchBarItemIdentifier)identifier
|
||||
items:(NSArray*)items;
|
||||
|
||||
@property(strong) NSTouchBar* groupTouchBar;
|
||||
@property(readwrite, copy, null_resettable) NSString* customizationLabel;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSCustomTouchBarItem : NSTouchBarItem
|
||||
|
||||
@property(readwrite, strong) __kindof NSView* view;
|
||||
@property(readwrite, strong, nullable)
|
||||
__kindof NSViewController* viewController;
|
||||
@property(readwrite, copy, null_resettable) NSString* customizationLabel;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSColorPickerTouchBarItem : NSTouchBarItem
|
||||
|
||||
@property SEL action;
|
||||
@property(weak) id target;
|
||||
@property(copy) NSColor* color;
|
||||
@property(strong) NSColorList* colorList;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSPopoverTouchBarItem : NSTouchBarItem
|
||||
|
||||
@property BOOL showsCloseButton;
|
||||
@property(strong) NSImage* collapsedRepresentationImage;
|
||||
@property(strong) NSString* collapsedRepresentationLabel;
|
||||
@property(strong) NSTouchBar* popoverTouchBar;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSSliderTouchBarItem : NSTouchBarItem
|
||||
|
||||
@property SEL action;
|
||||
@property(weak) id target;
|
||||
@property(copy) NSString* label;
|
||||
@property(strong) NSSlider* slider;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSScrubber : NSView
|
||||
|
||||
@property(weak) id<NSScrubberDelegate> delegate;
|
||||
@property(weak) id<NSScrubberDataSource> dataSource;
|
||||
@property NSScrubberMode mode;
|
||||
@property BOOL showsArrowButtons;
|
||||
@property(getter=isContinuous) BOOL continuous;
|
||||
@property(strong, nullable) NSScrubberSelectionStyle* selectionBackgroundStyle;
|
||||
@property(strong, nullable) NSScrubberSelectionStyle* selectionOverlayStyle;
|
||||
|
||||
- (void)registerClass:(Class)itemViewClass
|
||||
forItemIdentifier:(NSString*)itemIdentifier;
|
||||
|
||||
- (__kindof NSScrubberItemView*)makeItemWithIdentifier:(NSString*)itemIdentifier
|
||||
owner:(id)owner;
|
||||
- (void)reloadData;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSScrubberFlowLayout : NSObject
|
||||
@end
|
||||
|
||||
@interface NSScrubberSelectionStyle : NSObject <NSCoding>
|
||||
|
||||
@property(class, strong, readonly)
|
||||
NSScrubberSelectionStyle* outlineOverlayStyle;
|
||||
@property(class, strong, readonly)
|
||||
NSScrubberSelectionStyle* roundedBackgroundStyle;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSScrubberArrangedView : NSView
|
||||
|
||||
@end
|
||||
|
||||
@interface NSScrubberItemView : NSScrubberArrangedView
|
||||
|
||||
@end
|
||||
|
||||
@interface NSScrubberTextItemView : NSScrubberItemView
|
||||
|
||||
@property(copy) NSString* title;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSScrubberImageItemView : NSScrubberItemView
|
||||
|
||||
@property(copy) NSImage* image;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSWindow (TouchBarSDK)
|
||||
|
||||
@property(strong, readwrite, nullable) NSTouchBar* touchBar;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSButton (TouchBarSDK)
|
||||
|
||||
@property(copy) NSColor* bezelColor;
|
||||
+ (instancetype)buttonWithTitle:(NSString*)title
|
||||
target:(id)target
|
||||
action:(SEL)action;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSTextField (TouchBarSDK)
|
||||
|
||||
+ (instancetype)labelWithString:(NSString*)stringValue;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSSegmentedControl (TouchBarSDK)
|
||||
|
||||
+ (instancetype)segmentedControlWithLabels:(NSArray*)labels
|
||||
trackingMode:(NSSegmentSwitchTracking)trackingMode
|
||||
target:(id)target
|
||||
action:(SEL)action;
|
||||
|
||||
@end
|
||||
|
||||
@protocol NSTouchBarDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
- (nullable NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar
|
||||
makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier;
|
||||
|
||||
@end
|
||||
|
||||
@protocol NSScrubberDelegate <NSObject>
|
||||
|
||||
- (void)scrubber:(NSScrubber*)scrubber
|
||||
didHighlightItemAtIndex:(NSInteger)highlightedIndex;
|
||||
- (void)scrubber:(NSScrubber*)scrubber
|
||||
didSelectItemAtIndex:(NSInteger)selectedIndex;
|
||||
|
||||
@end
|
||||
|
||||
@protocol NSScrubberDataSource <NSObject>
|
||||
|
||||
- (NSInteger)numberOfItemsForScrubber:(NSScrubber*)scrubber;
|
||||
- (__kindof NSScrubberItemView*)scrubber:(NSScrubber*)scrubber
|
||||
viewForItemAtIndex:(NSInteger)index;
|
||||
|
||||
@end
|
||||
|
||||
@protocol NSScrubberFlowLayoutDelegate <NSObject>
|
||||
|
||||
- (NSSize)scrubber:(NSScrubber*)scrubber
|
||||
layout:(NSScrubberFlowLayout*)layout
|
||||
sizeForItemAtIndex:(NSInteger)itemIndex;
|
||||
|
||||
@end
|
||||
|
||||
#pragma clang assume_nonnull end
|
||||
|
||||
#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12_1
|
||||
|
||||
// When compiling against the 10.12.1 SDK or later, just provide forward
|
||||
// declarations to suppress the partial availability warnings.
|
||||
|
||||
@class NSCustomTouchBarItem;
|
||||
@class NSGroupTouchBarItem;
|
||||
@class NSTouchBar;
|
||||
@protocol NSTouchBarDelegate;
|
||||
@class NSTouchBarItem;
|
||||
|
||||
@interface NSWindow (TouchBarSDK)
|
||||
@property(strong, readonly) NSTouchBar* touchBar API_AVAILABLE(macosx(10.12.2));
|
||||
@end
|
||||
|
||||
#endif // MAC_OS_X_VERSION_10_12_1
|
||||
|
||||
#endif // ATOM_BROWSER_UI_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_
|
||||
@@ -1,69 +0,0 @@
|
||||
// Copyright (c) 2013 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_UI_MESSAGE_BOX_H_
|
||||
#define ATOM_BROWSER_UI_MESSAGE_BOX_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/callback_forward.h"
|
||||
#include "base/strings/string16.h"
|
||||
|
||||
namespace gfx {
|
||||
class ImageSkia;
|
||||
}
|
||||
|
||||
namespace atom {
|
||||
|
||||
class NativeWindow;
|
||||
|
||||
enum MessageBoxType {
|
||||
MESSAGE_BOX_TYPE_NONE = 0,
|
||||
MESSAGE_BOX_TYPE_INFORMATION,
|
||||
MESSAGE_BOX_TYPE_WARNING,
|
||||
MESSAGE_BOX_TYPE_ERROR,
|
||||
MESSAGE_BOX_TYPE_QUESTION,
|
||||
};
|
||||
|
||||
enum MessageBoxOptions {
|
||||
MESSAGE_BOX_NONE = 0,
|
||||
MESSAGE_BOX_NO_LINK = 1 << 0,
|
||||
};
|
||||
|
||||
int ShowMessageBoxSync(NativeWindow* parent_window,
|
||||
MessageBoxType type,
|
||||
const std::vector<std::string>& buttons,
|
||||
int default_id,
|
||||
int cancel_id,
|
||||
int options,
|
||||
const std::string& title,
|
||||
const std::string& message,
|
||||
const std::string& detail,
|
||||
const gfx::ImageSkia& icon);
|
||||
|
||||
typedef base::OnceCallback<void(int code, bool checkbox_checked)>
|
||||
MessageBoxCallback;
|
||||
|
||||
void ShowMessageBox(NativeWindow* parent_window,
|
||||
MessageBoxType type,
|
||||
const std::vector<std::string>& buttons,
|
||||
int default_id,
|
||||
int cancel_id,
|
||||
int options,
|
||||
const std::string& title,
|
||||
const std::string& message,
|
||||
const std::string& detail,
|
||||
const std::string& checkbox_label,
|
||||
bool checkbox_checked,
|
||||
const gfx::ImageSkia& icon,
|
||||
MessageBoxCallback callback);
|
||||
|
||||
// Like ShowMessageBox with simplest settings, but safe to call at very early
|
||||
// stage of application.
|
||||
void ShowErrorBox(const base::string16& title, const base::string16& content);
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_UI_MESSAGE_BOX_H_
|
||||
@@ -1,175 +0,0 @@
|
||||
// Copyright (c) 2013 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/ui/message_box.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "base/callback.h"
|
||||
#include "base/mac/mac_util.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "skia/ext/skia_utils_mac.h"
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
NSAlert* CreateNSAlert(NativeWindow* parent_window,
|
||||
MessageBoxType type,
|
||||
const std::vector<std::string>& buttons,
|
||||
int default_id,
|
||||
int cancel_id,
|
||||
const std::string& title,
|
||||
const std::string& message,
|
||||
const std::string& detail,
|
||||
const std::string& checkbox_label,
|
||||
bool checkbox_checked,
|
||||
const gfx::ImageSkia& icon) {
|
||||
// Ignore the title; it's the window title on other platforms and ignorable.
|
||||
NSAlert* alert = [[NSAlert alloc] init];
|
||||
[alert setMessageText:base::SysUTF8ToNSString(message)];
|
||||
[alert setInformativeText:base::SysUTF8ToNSString(detail)];
|
||||
|
||||
switch (type) {
|
||||
case MESSAGE_BOX_TYPE_INFORMATION:
|
||||
alert.alertStyle = NSInformationalAlertStyle;
|
||||
break;
|
||||
case MESSAGE_BOX_TYPE_WARNING:
|
||||
case MESSAGE_BOX_TYPE_ERROR:
|
||||
// NSWarningAlertStyle shows the app icon while NSCriticalAlertStyle
|
||||
// shows a warning icon with an app icon badge. Since there is no
|
||||
// error variant, lets just use NSCriticalAlertStyle.
|
||||
alert.alertStyle = NSCriticalAlertStyle;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < buttons.size(); ++i) {
|
||||
NSString* title = base::SysUTF8ToNSString(buttons[i]);
|
||||
// An empty title causes crash on macOS.
|
||||
if (buttons[i].empty())
|
||||
title = @"(empty)";
|
||||
NSButton* button = [alert addButtonWithTitle:title];
|
||||
[button setTag:i];
|
||||
}
|
||||
|
||||
NSArray* ns_buttons = [alert buttons];
|
||||
int button_count = static_cast<int>([ns_buttons count]);
|
||||
|
||||
if (default_id >= 0 && default_id < button_count) {
|
||||
// Highlight the button at default_id
|
||||
[[ns_buttons objectAtIndex:default_id] highlight:YES];
|
||||
|
||||
// The first button added gets set as the default selected.
|
||||
// So remove that default, and make the requested button the default.
|
||||
[[ns_buttons objectAtIndex:0] setKeyEquivalent:@""];
|
||||
[[ns_buttons objectAtIndex:default_id] setKeyEquivalent:@"\r"];
|
||||
}
|
||||
|
||||
// Bind cancel id button to escape key if there is more than one button
|
||||
if (button_count > 1 && cancel_id >= 0 && cancel_id < button_count) {
|
||||
[[ns_buttons objectAtIndex:cancel_id] setKeyEquivalent:@"\e"];
|
||||
}
|
||||
|
||||
if (!checkbox_label.empty()) {
|
||||
alert.showsSuppressionButton = YES;
|
||||
alert.suppressionButton.title = base::SysUTF8ToNSString(checkbox_label);
|
||||
alert.suppressionButton.state = checkbox_checked ? NSOnState : NSOffState;
|
||||
}
|
||||
|
||||
if (!icon.isNull()) {
|
||||
NSImage* image = skia::SkBitmapToNSImageWithColorSpace(
|
||||
*icon.bitmap(), base::mac::GetGenericRGBColorSpace());
|
||||
[alert setIcon:image];
|
||||
}
|
||||
|
||||
return alert;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int ShowMessageBoxSync(NativeWindow* parent_window,
|
||||
MessageBoxType type,
|
||||
const std::vector<std::string>& buttons,
|
||||
int default_id,
|
||||
int cancel_id,
|
||||
int options,
|
||||
const std::string& title,
|
||||
const std::string& message,
|
||||
const std::string& detail,
|
||||
const gfx::ImageSkia& icon) {
|
||||
NSAlert* alert =
|
||||
CreateNSAlert(parent_window, type, buttons, default_id, cancel_id, title,
|
||||
message, detail, "", false, icon);
|
||||
|
||||
// Use runModal for synchronous alert without parent, since we don't have a
|
||||
// window to wait for.
|
||||
if (!parent_window)
|
||||
return [[alert autorelease] runModal];
|
||||
|
||||
__block int ret_code = -1;
|
||||
|
||||
NSWindow* window = parent_window->GetNativeWindow().GetNativeNSWindow();
|
||||
[alert beginSheetModalForWindow:window
|
||||
completionHandler:^(NSModalResponse response) {
|
||||
ret_code = response;
|
||||
[NSApp stopModal];
|
||||
}];
|
||||
|
||||
[NSApp runModalForWindow:window];
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
void ShowMessageBox(NativeWindow* parent_window,
|
||||
MessageBoxType type,
|
||||
const std::vector<std::string>& buttons,
|
||||
int default_id,
|
||||
int cancel_id,
|
||||
int options,
|
||||
const std::string& title,
|
||||
const std::string& message,
|
||||
const std::string& detail,
|
||||
const std::string& checkbox_label,
|
||||
bool checkbox_checked,
|
||||
const gfx::ImageSkia& icon,
|
||||
MessageBoxCallback callback) {
|
||||
NSAlert* alert =
|
||||
CreateNSAlert(parent_window, type, buttons, default_id, cancel_id, title,
|
||||
message, detail, checkbox_label, checkbox_checked, icon);
|
||||
|
||||
// Use runModal for synchronous alert without parent, since we don't have a
|
||||
// window to wait for.
|
||||
if (!parent_window) {
|
||||
int ret = [[alert autorelease] runModal];
|
||||
std::move(callback).Run(ret, alert.suppressionButton.state == NSOnState);
|
||||
} else {
|
||||
NSWindow* window =
|
||||
parent_window ? parent_window->GetNativeWindow().GetNativeNSWindow()
|
||||
: nil;
|
||||
|
||||
// Duplicate the callback object here since c is a reference and gcd would
|
||||
// only store the pointer, by duplication we can force gcd to store a copy.
|
||||
__block MessageBoxCallback callback_ = std::move(callback);
|
||||
|
||||
[alert beginSheetModalForWindow:window
|
||||
completionHandler:^(NSModalResponse response) {
|
||||
std::move(callback_).Run(
|
||||
response, alert.suppressionButton.state == NSOnState);
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
void ShowErrorBox(const base::string16& title, const base::string16& content) {
|
||||
NSAlert* alert = [[NSAlert alloc] init];
|
||||
[alert setMessageText:base::SysUTF16ToNSString(title)];
|
||||
[alert setInformativeText:base::SysUTF16ToNSString(content)];
|
||||
[alert setAlertStyle:NSCriticalAlertStyle];
|
||||
[alert runModal];
|
||||
[alert release];
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
@@ -1,545 +0,0 @@
|
||||
// Copyright (c) 2014 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/ui/tray_icon_cocoa.h"
|
||||
|
||||
#include "atom/browser/mac/atom_application.h"
|
||||
#include "atom/browser/ui/cocoa/NSString+ANSI.h"
|
||||
#include "atom/browser/ui/cocoa/atom_menu_controller.h"
|
||||
#include "base/mac/sdk_forward_declarations.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/events/cocoa/cocoa_event_utils.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
#include "ui/gfx/mac/coordinate_conversion.h"
|
||||
#include "ui/native_theme/native_theme.h"
|
||||
|
||||
namespace {
|
||||
|
||||
// By default, macOS sets 4px to tray image as left and right padding margin.
|
||||
const CGFloat kHorizontalMargin = 4;
|
||||
// macOS tends to make the title 2px lower.
|
||||
const CGFloat kVerticalTitleMargin = 2;
|
||||
|
||||
} // namespace
|
||||
|
||||
@interface StatusItemView : NSView {
|
||||
atom::TrayIconCocoa* trayIcon_; // weak
|
||||
AtomMenuController* menuController_; // weak
|
||||
atom::TrayIcon::HighlightMode highlight_mode_;
|
||||
BOOL ignoreDoubleClickEvents_;
|
||||
BOOL forceHighlight_;
|
||||
BOOL inMouseEventSequence_;
|
||||
BOOL ANSI_;
|
||||
base::scoped_nsobject<NSImage> image_;
|
||||
base::scoped_nsobject<NSImage> alternateImage_;
|
||||
base::scoped_nsobject<NSString> title_;
|
||||
base::scoped_nsobject<NSMutableAttributedString> attributedTitle_;
|
||||
base::scoped_nsobject<NSStatusItem> statusItem_;
|
||||
base::scoped_nsobject<NSTrackingArea> trackingArea_;
|
||||
}
|
||||
|
||||
@end // @interface StatusItemView
|
||||
|
||||
@implementation StatusItemView
|
||||
|
||||
- (void)dealloc {
|
||||
trayIcon_ = nil;
|
||||
menuController_ = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id)initWithIcon:(atom::TrayIconCocoa*)icon {
|
||||
trayIcon_ = icon;
|
||||
menuController_ = nil;
|
||||
highlight_mode_ = atom::TrayIcon::HighlightMode::SELECTION;
|
||||
ignoreDoubleClickEvents_ = NO;
|
||||
forceHighlight_ = NO;
|
||||
inMouseEventSequence_ = NO;
|
||||
|
||||
if ((self = [super initWithFrame:CGRectZero])) {
|
||||
[self registerForDraggedTypes:@[
|
||||
NSFilenamesPboardType,
|
||||
NSStringPboardType,
|
||||
]];
|
||||
|
||||
// Create the status item.
|
||||
NSStatusItem* item = [[NSStatusBar systemStatusBar]
|
||||
statusItemWithLength:NSVariableStatusItemLength];
|
||||
statusItem_.reset([item retain]);
|
||||
[statusItem_ setView:self];
|
||||
// Finalize setup by sizing our views
|
||||
[self updateDimensions];
|
||||
|
||||
// Add NSTrackingArea for listening to mouseEnter, mouseExit, and mouseMove
|
||||
// events
|
||||
trackingArea_.reset([[NSTrackingArea alloc]
|
||||
initWithRect:[self bounds]
|
||||
options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved |
|
||||
NSTrackingActiveAlways
|
||||
owner:self
|
||||
userInfo:nil]);
|
||||
[self addTrackingArea:trackingArea_];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)updateDimensions {
|
||||
NSStatusBar* bar = [NSStatusBar systemStatusBar];
|
||||
[self setFrame:NSMakeRect(0, 0, [self fullWidth], [bar thickness])];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)removeItem {
|
||||
// Turn off tracking events to prevent crash
|
||||
if (trackingArea_) {
|
||||
[self removeTrackingArea:trackingArea_];
|
||||
trackingArea_.reset();
|
||||
}
|
||||
[[NSStatusBar systemStatusBar] removeStatusItem:statusItem_];
|
||||
[statusItem_ setView:nil];
|
||||
statusItem_.reset();
|
||||
}
|
||||
|
||||
- (void)drawRect:(NSRect)dirtyRect {
|
||||
// Draw the tray icon and title that align with NSStatusItem, layout:
|
||||
// ----------------
|
||||
// | icon | title |
|
||||
/// ----------------
|
||||
|
||||
CGFloat thickness = [[statusItem_ statusBar] thickness];
|
||||
|
||||
// Draw the system bar background.
|
||||
[statusItem_ drawStatusBarBackgroundInRect:self.bounds
|
||||
withHighlight:[self shouldHighlight]];
|
||||
|
||||
// Determine which image to use.
|
||||
NSImage* image = image_.get();
|
||||
if (inMouseEventSequence_ && alternateImage_) {
|
||||
image = alternateImage_.get();
|
||||
}
|
||||
// Apply the higlight color if the image is a template image. When this moves
|
||||
// to using the new [NSStatusItem button] API, this should work automagically.
|
||||
if ([image isTemplate] == YES) {
|
||||
NSImage* imageWithColor = [[image copy] autorelease];
|
||||
[imageWithColor lockFocus];
|
||||
[[self colorWithHighlight:[self isHighlighted]] set];
|
||||
CGRect imageBounds = CGRectMake(0, 0, image.size.width, image.size.height);
|
||||
NSRectFillUsingOperation(imageBounds, NSCompositeSourceAtop);
|
||||
[imageWithColor unlockFocus];
|
||||
image = imageWithColor;
|
||||
}
|
||||
|
||||
// Draw the image
|
||||
[image
|
||||
drawInRect:CGRectMake(roundf(([self iconWidth] - image.size.width) / 2),
|
||||
roundf((thickness - image.size.height) / 2),
|
||||
image.size.width, image.size.height)];
|
||||
|
||||
if (title_) {
|
||||
// Draw title.
|
||||
NSRect titleDrawRect = NSMakeRect([self iconWidth], -kVerticalTitleMargin,
|
||||
[self titleWidth], thickness);
|
||||
[attributedTitle_ drawInRect:titleDrawRect];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isDarkMode {
|
||||
if (@available(macOS 10.15, *)) {
|
||||
return ui::NativeTheme::GetInstanceForNativeUi()->SystemDarkModeEnabled();
|
||||
}
|
||||
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
|
||||
NSString* mode = [defaults stringForKey:@"AppleInterfaceStyle"];
|
||||
return mode && [mode isEqualToString:@"Dark"];
|
||||
}
|
||||
|
||||
- (BOOL)isHighlighted {
|
||||
BOOL highlight = [self shouldHighlight];
|
||||
return highlight | [self isDarkMode];
|
||||
}
|
||||
|
||||
// The width of the full status item.
|
||||
- (CGFloat)fullWidth {
|
||||
if (title_)
|
||||
return [self iconWidth] + [self titleWidth] + kHorizontalMargin;
|
||||
else
|
||||
return [self iconWidth];
|
||||
}
|
||||
|
||||
// The width of the icon.
|
||||
- (CGFloat)iconWidth {
|
||||
if (!image_ && title_)
|
||||
return kHorizontalMargin;
|
||||
CGFloat thickness = [[NSStatusBar systemStatusBar] thickness];
|
||||
CGFloat imageHeight = [image_ size].height;
|
||||
CGFloat imageWidth = [image_ size].width;
|
||||
CGFloat iconWidth = imageWidth;
|
||||
if (imageWidth < thickness) {
|
||||
// Image's width must be larger than menu bar's height.
|
||||
iconWidth = thickness;
|
||||
} else {
|
||||
CGFloat verticalMargin = thickness - imageHeight;
|
||||
// Image must have same horizontal vertical margin.
|
||||
if (verticalMargin > 0 && imageWidth != imageHeight)
|
||||
iconWidth = imageWidth + verticalMargin;
|
||||
CGFloat horizontalMargin = thickness - imageWidth;
|
||||
// Image must have at least kHorizontalMargin horizontal margin on each
|
||||
// side.
|
||||
if (horizontalMargin < 2 * kHorizontalMargin)
|
||||
iconWidth = imageWidth + 2 * kHorizontalMargin;
|
||||
}
|
||||
return iconWidth;
|
||||
}
|
||||
|
||||
// The width of the title.
|
||||
- (CGFloat)titleWidth {
|
||||
if (!title_)
|
||||
return 0;
|
||||
return [attributedTitle_ size].width;
|
||||
}
|
||||
|
||||
- (NSColor*)colorWithHighlight:(BOOL)highlight {
|
||||
return highlight ? [NSColor whiteColor]
|
||||
: [NSColor colorWithRed:0.265625
|
||||
green:0.25390625
|
||||
blue:0.234375
|
||||
alpha:1.0];
|
||||
}
|
||||
|
||||
- (void)setImage:(NSImage*)image {
|
||||
image_.reset([image copy]);
|
||||
[self updateDimensions];
|
||||
}
|
||||
|
||||
- (void)setAlternateImage:(NSImage*)image {
|
||||
alternateImage_.reset([image copy]);
|
||||
}
|
||||
|
||||
- (void)setHighlight:(atom::TrayIcon::HighlightMode)mode {
|
||||
highlight_mode_ = mode;
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)setIgnoreDoubleClickEvents:(BOOL)ignore {
|
||||
ignoreDoubleClickEvents_ = ignore;
|
||||
}
|
||||
|
||||
- (BOOL)getIgnoreDoubleClickEvents {
|
||||
return ignoreDoubleClickEvents_;
|
||||
}
|
||||
|
||||
- (void)setTitle:(NSString*)title {
|
||||
if (title.length > 0) {
|
||||
title_.reset([title copy]);
|
||||
ANSI_ = [title containsANSICodes];
|
||||
} else {
|
||||
title_.reset();
|
||||
ANSI_ = NO;
|
||||
}
|
||||
[self updateAttributedTitle];
|
||||
[self updateDimensions];
|
||||
}
|
||||
|
||||
- (NSString*)title {
|
||||
return title_;
|
||||
}
|
||||
|
||||
- (void)updateAttributedTitle {
|
||||
NSDictionary* attributes =
|
||||
@{NSFontAttributeName : [NSFont menuBarFontOfSize:0]};
|
||||
|
||||
if (ANSI_) {
|
||||
NSCharacterSet* whites = [NSCharacterSet whitespaceCharacterSet];
|
||||
NSString* title = [title_ stringByTrimmingCharactersInSet:whites];
|
||||
attributedTitle_.reset([title attributedStringParsingANSICodes]);
|
||||
[attributedTitle_ addAttributes:attributes
|
||||
range:NSMakeRange(0, [attributedTitle_ length])];
|
||||
return;
|
||||
}
|
||||
|
||||
// check title_ being nil
|
||||
NSString* title = @"";
|
||||
if (title_)
|
||||
title = title_;
|
||||
|
||||
attributedTitle_.reset([[NSMutableAttributedString alloc]
|
||||
initWithString:title
|
||||
attributes:attributes]);
|
||||
|
||||
// NSFontAttributeName:[NSFont menuBarFontOfSize:0],
|
||||
// NSForegroundColorAttributeName:[self colorWithHighlight: highlight]
|
||||
[attributedTitle_ addAttributes:attributes
|
||||
range:NSMakeRange(0, [attributedTitle_ length])];
|
||||
[attributedTitle_ addAttribute:NSForegroundColorAttributeName
|
||||
value:[self colorWithHighlight:[self isHighlighted]]
|
||||
range:NSMakeRange(0, [attributedTitle_ length])];
|
||||
}
|
||||
|
||||
- (void)setMenuController:(AtomMenuController*)menu {
|
||||
menuController_ = menu;
|
||||
}
|
||||
|
||||
- (void)mouseDown:(NSEvent*)event {
|
||||
inMouseEventSequence_ = YES;
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)mouseUp:(NSEvent*)event {
|
||||
if (!inMouseEventSequence_) {
|
||||
// If the menu is showing, when user clicked the tray icon, the `mouseDown`
|
||||
// event will be dissmissed, we need to close the menu at this time.
|
||||
[self setNeedsDisplay:YES];
|
||||
return;
|
||||
}
|
||||
inMouseEventSequence_ = NO;
|
||||
|
||||
// Show menu when there is a context menu.
|
||||
// NB(hokein): Make tray's behavior more like official one's.
|
||||
// When the tray icon gets clicked quickly multiple times, the
|
||||
// event.clickCount doesn't always return 1. Instead, it returns a value that
|
||||
// counts the clicked times.
|
||||
// So we don't check the clickCount here, just pop up the menu for each click
|
||||
// event.
|
||||
if (menuController_)
|
||||
[statusItem_ popUpStatusItemMenu:[menuController_ menu]];
|
||||
|
||||
// Don't emit click events when menu is showing.
|
||||
if (menuController_)
|
||||
return;
|
||||
|
||||
// If we are ignoring double click events, we should ignore the `clickCount`
|
||||
// value and immediately emit a click event.
|
||||
BOOL shouldBeHandledAsASingleClick =
|
||||
(event.clickCount == 1) || ignoreDoubleClickEvents_;
|
||||
if (shouldBeHandledAsASingleClick)
|
||||
trayIcon_->NotifyClicked(
|
||||
gfx::ScreenRectFromNSRect(event.window.frame),
|
||||
gfx::ScreenPointFromNSPoint([event locationInWindow]),
|
||||
ui::EventFlagsFromModifiers([event modifierFlags]));
|
||||
|
||||
// Double click event.
|
||||
BOOL shouldBeHandledAsADoubleClick =
|
||||
(event.clickCount == 2) && !ignoreDoubleClickEvents_;
|
||||
if (shouldBeHandledAsADoubleClick)
|
||||
trayIcon_->NotifyDoubleClicked(
|
||||
gfx::ScreenRectFromNSRect(event.window.frame),
|
||||
ui::EventFlagsFromModifiers([event modifierFlags]));
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)popUpContextMenu:(atom::AtomMenuModel*)menu_model {
|
||||
// Make sure events can be pumped while the menu is up.
|
||||
base::MessageLoopCurrent::ScopedNestableTaskAllower allow;
|
||||
|
||||
// Show a custom menu.
|
||||
if (menu_model) {
|
||||
base::scoped_nsobject<AtomMenuController> menuController(
|
||||
[[AtomMenuController alloc] initWithModel:menu_model
|
||||
useDefaultAccelerator:NO]);
|
||||
forceHighlight_ = YES; // Should highlight when showing menu.
|
||||
[self setNeedsDisplay:YES];
|
||||
|
||||
[statusItem_ popUpStatusItemMenu:[menuController menu]];
|
||||
forceHighlight_ = NO;
|
||||
[self setNeedsDisplay:YES];
|
||||
return;
|
||||
}
|
||||
|
||||
if (menuController_ && ![menuController_ isMenuOpen]) {
|
||||
// Ensure the UI can update while the menu is fading out.
|
||||
base::ScopedPumpMessagesInPrivateModes pump_private;
|
||||
|
||||
// Redraw the tray icon to show highlight if it is enabled.
|
||||
[self setNeedsDisplay:YES];
|
||||
|
||||
[statusItem_ popUpStatusItemMenu:[menuController_ menu]];
|
||||
// The popUpStatusItemMenu returns only after the showing menu is closed.
|
||||
// When it returns, we need to redraw the tray icon to not show highlight.
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)rightMouseUp:(NSEvent*)event {
|
||||
trayIcon_->NotifyRightClicked(
|
||||
gfx::ScreenRectFromNSRect(event.window.frame),
|
||||
ui::EventFlagsFromModifiers([event modifierFlags]));
|
||||
}
|
||||
|
||||
- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender {
|
||||
trayIcon_->NotifyDragEntered();
|
||||
return NSDragOperationCopy;
|
||||
}
|
||||
|
||||
- (void)mouseExited:(NSEvent*)event {
|
||||
trayIcon_->NotifyMouseExited(
|
||||
gfx::ScreenPointFromNSPoint([event locationInWindow]),
|
||||
ui::EventFlagsFromModifiers([event modifierFlags]));
|
||||
}
|
||||
|
||||
- (void)mouseEntered:(NSEvent*)event {
|
||||
trayIcon_->NotifyMouseEntered(
|
||||
gfx::ScreenPointFromNSPoint([event locationInWindow]),
|
||||
ui::EventFlagsFromModifiers([event modifierFlags]));
|
||||
}
|
||||
|
||||
- (void)mouseMoved:(NSEvent*)event {
|
||||
trayIcon_->NotifyMouseMoved(
|
||||
gfx::ScreenPointFromNSPoint([event locationInWindow]),
|
||||
ui::EventFlagsFromModifiers([event modifierFlags]));
|
||||
}
|
||||
|
||||
- (void)draggingExited:(id<NSDraggingInfo>)sender {
|
||||
trayIcon_->NotifyDragExited();
|
||||
}
|
||||
|
||||
- (void)draggingEnded:(id<NSDraggingInfo>)sender {
|
||||
trayIcon_->NotifyDragEnded();
|
||||
|
||||
if (NSPointInRect([sender draggingLocation], self.frame)) {
|
||||
trayIcon_->NotifyDrop();
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)handleDrop:(id<NSDraggingInfo>)sender {
|
||||
NSPasteboard* pboard = [sender draggingPasteboard];
|
||||
|
||||
if ([[pboard types] containsObject:NSFilenamesPboardType]) {
|
||||
std::vector<std::string> dropFiles;
|
||||
NSArray* files = [pboard propertyListForType:NSFilenamesPboardType];
|
||||
for (NSString* file in files)
|
||||
dropFiles.push_back(base::SysNSStringToUTF8(file));
|
||||
trayIcon_->NotifyDropFiles(dropFiles);
|
||||
return YES;
|
||||
} else if ([[pboard types] containsObject:NSStringPboardType]) {
|
||||
NSString* dropText = [pboard stringForType:NSStringPboardType];
|
||||
trayIcon_->NotifyDropText(base::SysNSStringToUTF8(dropText));
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)prepareForDragOperation:(id<NSDraggingInfo>)sender {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
|
||||
[self handleDrop:sender];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)setNeedsDisplay:(BOOL)display {
|
||||
[self updateAttributedTitle];
|
||||
[super setNeedsDisplay:display];
|
||||
}
|
||||
|
||||
- (BOOL)shouldHighlight {
|
||||
switch (highlight_mode_) {
|
||||
case atom::TrayIcon::HighlightMode::ALWAYS:
|
||||
return true;
|
||||
case atom::TrayIcon::HighlightMode::NEVER:
|
||||
return false;
|
||||
case atom::TrayIcon::HighlightMode::SELECTION:
|
||||
BOOL isMenuOpen = menuController_ && [menuController_ isMenuOpen];
|
||||
return forceHighlight_ || inMouseEventSequence_ || isMenuOpen;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
namespace atom {
|
||||
|
||||
TrayIconCocoa::TrayIconCocoa() : weak_factory_(this) {
|
||||
status_item_view_.reset([[StatusItemView alloc] initWithIcon:this]);
|
||||
}
|
||||
|
||||
TrayIconCocoa::~TrayIconCocoa() {
|
||||
[status_item_view_ removeItem];
|
||||
if (menu_model_)
|
||||
menu_model_->RemoveObserver(this);
|
||||
}
|
||||
|
||||
void TrayIconCocoa::SetImage(const gfx::Image& image) {
|
||||
[status_item_view_ setImage:image.IsEmpty() ? nil : image.AsNSImage()];
|
||||
}
|
||||
|
||||
void TrayIconCocoa::SetPressedImage(const gfx::Image& image) {
|
||||
[status_item_view_ setAlternateImage:image.AsNSImage()];
|
||||
}
|
||||
|
||||
void TrayIconCocoa::SetToolTip(const std::string& tool_tip) {
|
||||
[status_item_view_ setToolTip:base::SysUTF8ToNSString(tool_tip)];
|
||||
}
|
||||
|
||||
void TrayIconCocoa::SetTitle(const std::string& title) {
|
||||
[status_item_view_ setTitle:base::SysUTF8ToNSString(title)];
|
||||
}
|
||||
|
||||
std::string TrayIconCocoa::GetTitle() {
|
||||
return base::SysNSStringToUTF8([status_item_view_ title]);
|
||||
}
|
||||
|
||||
void TrayIconCocoa::SetHighlightMode(TrayIcon::HighlightMode mode) {
|
||||
[status_item_view_ setHighlight:mode];
|
||||
}
|
||||
|
||||
void TrayIconCocoa::SetIgnoreDoubleClickEvents(bool ignore) {
|
||||
[status_item_view_ setIgnoreDoubleClickEvents:ignore];
|
||||
}
|
||||
|
||||
bool TrayIconCocoa::GetIgnoreDoubleClickEvents() {
|
||||
return [status_item_view_ getIgnoreDoubleClickEvents];
|
||||
}
|
||||
|
||||
void TrayIconCocoa::PopUpOnUI(AtomMenuModel* menu_model) {
|
||||
[status_item_view_ popUpContextMenu:menu_model];
|
||||
}
|
||||
|
||||
void TrayIconCocoa::PopUpContextMenu(const gfx::Point& pos,
|
||||
AtomMenuModel* menu_model) {
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::BindOnce(&TrayIconCocoa::PopUpOnUI, weak_factory_.GetWeakPtr(),
|
||||
base::Unretained(menu_model)));
|
||||
}
|
||||
|
||||
void TrayIconCocoa::SetContextMenu(AtomMenuModel* menu_model) {
|
||||
// Substribe to MenuClosed event.
|
||||
if (menu_model_)
|
||||
menu_model_->RemoveObserver(this);
|
||||
|
||||
menu_model_ = menu_model;
|
||||
|
||||
if (menu_model) {
|
||||
menu_model->AddObserver(this);
|
||||
// Create native menu.
|
||||
menu_.reset([[AtomMenuController alloc] initWithModel:menu_model
|
||||
useDefaultAccelerator:NO]);
|
||||
} else {
|
||||
menu_.reset();
|
||||
}
|
||||
|
||||
[status_item_view_ setMenuController:menu_.get()];
|
||||
}
|
||||
|
||||
gfx::Rect TrayIconCocoa::GetBounds() {
|
||||
auto bounds = gfx::ScreenRectFromNSRect([status_item_view_ window].frame);
|
||||
return bounds;
|
||||
}
|
||||
|
||||
void TrayIconCocoa::OnMenuWillClose() {
|
||||
[status_item_view_ setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
// static
|
||||
TrayIcon* TrayIcon::Create() {
|
||||
return new TrayIconCocoa;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
@@ -1,36 +0,0 @@
|
||||
// Copyright (c) 2019 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/ui/util_gtk.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
namespace util_gtk {
|
||||
|
||||
// Copied from L40-L55 in
|
||||
// https://cs.chromium.org/chromium/src/chrome/browser/ui/libgtkui/select_file_dialog_impl_gtk.cc
|
||||
#if GTK_CHECK_VERSION(3, 90, 0)
|
||||
// GTK stock items have been deprecated. The docs say to switch to using the
|
||||
// strings "_Open", etc. However this breaks i18n. We could supply our own
|
||||
// internationalized strings, but the "_" in these strings is significant: it's
|
||||
// the keyboard shortcut to select these actions. TODO: Provide
|
||||
// internationalized strings when GTK provides support for it.
|
||||
const char* const kCancelLabel = "_Cancel";
|
||||
const char* const kNoLabel = "_No";
|
||||
const char* const kOkLabel = "_OK";
|
||||
const char* const kOpenLabel = "_Open";
|
||||
const char* const kSaveLabel = "_Save";
|
||||
const char* const kYesLabel = "_Yes";
|
||||
#else
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
const char* const kCancelLabel = GTK_STOCK_CANCEL;
|
||||
const char* const kNoLabel = GTK_STOCK_NO;
|
||||
const char* const kOkLabel = GTK_STOCK_OK;
|
||||
const char* const kOpenLabel = GTK_STOCK_OPEN;
|
||||
const char* const kSaveLabel = GTK_STOCK_SAVE;
|
||||
const char* const kYesLabel = GTK_STOCK_YES;
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
#endif
|
||||
|
||||
} // namespace util_gtk
|
||||
@@ -1,21 +0,0 @@
|
||||
// Copyright (c) 2019 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_UI_UTIL_GTK_H_
|
||||
#define ATOM_BROWSER_UI_UTIL_GTK_H_
|
||||
|
||||
namespace util_gtk {
|
||||
|
||||
/* These are `const char*` rather than the project-preferred `const char[]`
|
||||
because they must fit the type of an external dependency */
|
||||
extern const char* const kCancelLabel;
|
||||
extern const char* const kNoLabel;
|
||||
extern const char* const kOkLabel;
|
||||
extern const char* const kOpenLabel;
|
||||
extern const char* const kSaveLabel;
|
||||
extern const char* const kYesLabel;
|
||||
|
||||
} // namespace util_gtk
|
||||
|
||||
#endif // ATOM_BROWSER_UI_UTIL_GTK_H_
|
||||
@@ -1,156 +0,0 @@
|
||||
// Copyright (c) 2017 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE-CHROMIUM file.
|
||||
|
||||
#include "atom/browser/ui/views/atom_views_delegate.h"
|
||||
|
||||
#include <dwmapi.h>
|
||||
#include <shellapi.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/task/post_task.h"
|
||||
|
||||
namespace {
|
||||
|
||||
bool MonitorHasAutohideTaskbarForEdge(UINT edge, HMONITOR monitor) {
|
||||
APPBARDATA taskbar_data = {sizeof(APPBARDATA), NULL, 0, edge};
|
||||
taskbar_data.hWnd = ::GetForegroundWindow();
|
||||
|
||||
// MSDN documents an ABM_GETAUTOHIDEBAREX, which supposedly takes a monitor
|
||||
// rect and returns autohide bars on that monitor. This sounds like a good
|
||||
// idea for multi-monitor systems. Unfortunately, it appears to not work at
|
||||
// least some of the time (erroneously returning NULL) and there's almost no
|
||||
// online documentation or other sample code using it that suggests ways to
|
||||
// address this problem. We do the following:-
|
||||
// 1. Use the ABM_GETAUTOHIDEBAR message. If it works, i.e. returns a valid
|
||||
// window we are done.
|
||||
// 2. If the ABM_GETAUTOHIDEBAR message does not work we query the auto hide
|
||||
// state of the taskbar and then retrieve its position. That call returns
|
||||
// the edge on which the taskbar is present. If it matches the edge we
|
||||
// are looking for, we are done.
|
||||
// NOTE: This call spins a nested run loop.
|
||||
HWND taskbar = reinterpret_cast<HWND>(
|
||||
SHAppBarMessage(ABM_GETAUTOHIDEBAR, &taskbar_data));
|
||||
if (!::IsWindow(taskbar)) {
|
||||
APPBARDATA taskbar_data = {sizeof(APPBARDATA), 0, 0, 0};
|
||||
unsigned int taskbar_state = SHAppBarMessage(ABM_GETSTATE, &taskbar_data);
|
||||
if (!(taskbar_state & ABS_AUTOHIDE))
|
||||
return false;
|
||||
|
||||
taskbar_data.hWnd = ::FindWindow(L"Shell_TrayWnd", NULL);
|
||||
if (!::IsWindow(taskbar_data.hWnd))
|
||||
return false;
|
||||
|
||||
SHAppBarMessage(ABM_GETTASKBARPOS, &taskbar_data);
|
||||
if (taskbar_data.uEdge == edge)
|
||||
taskbar = taskbar_data.hWnd;
|
||||
}
|
||||
|
||||
// There is a potential race condition here:
|
||||
// 1. A maximized chrome window is fullscreened.
|
||||
// 2. It is switched back to maximized.
|
||||
// 3. In the process the window gets a WM_NCCACLSIZE message which calls us to
|
||||
// get the autohide state.
|
||||
// 4. The worker thread is invoked. It calls the API to get the autohide
|
||||
// state. On Windows versions earlier than Windows 7, taskbars could
|
||||
// easily be always on top or not.
|
||||
// This meant that we only want to look for taskbars which have the topmost
|
||||
// bit set. However this causes problems in cases where the window on the
|
||||
// main thread is still in the process of switching away from fullscreen.
|
||||
// In this case the taskbar might not yet have the topmost bit set.
|
||||
// 5. The main thread resumes and does not leave space for the taskbar and
|
||||
// hence it does not pop when hovered.
|
||||
//
|
||||
// To address point 4 above, it is best to not check for the WS_EX_TOPMOST
|
||||
// window style on the taskbar, as starting from Windows 7, the topmost
|
||||
// style is always set. We don't support XP and Vista anymore.
|
||||
if (::IsWindow(taskbar)) {
|
||||
if (MonitorFromWindow(taskbar, MONITOR_DEFAULTTONEAREST) == monitor)
|
||||
return true;
|
||||
// In some cases like when the autohide taskbar is on the left of the
|
||||
// secondary monitor, the MonitorFromWindow call above fails to return the
|
||||
// correct monitor the taskbar is on. We fallback to MonitorFromPoint for
|
||||
// the cursor position in that case, which seems to work well.
|
||||
POINT cursor_pos = {0};
|
||||
GetCursorPos(&cursor_pos);
|
||||
if (MonitorFromPoint(cursor_pos, MONITOR_DEFAULTTONEAREST) == monitor)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int GetAppbarAutohideEdgesOnWorkerThread(HMONITOR monitor) {
|
||||
DCHECK(monitor);
|
||||
|
||||
int edges = 0;
|
||||
if (MonitorHasAutohideTaskbarForEdge(ABE_LEFT, monitor))
|
||||
edges |= views::ViewsDelegate::EDGE_LEFT;
|
||||
if (MonitorHasAutohideTaskbarForEdge(ABE_TOP, monitor))
|
||||
edges |= views::ViewsDelegate::EDGE_TOP;
|
||||
if (MonitorHasAutohideTaskbarForEdge(ABE_RIGHT, monitor))
|
||||
edges |= views::ViewsDelegate::EDGE_RIGHT;
|
||||
if (MonitorHasAutohideTaskbarForEdge(ABE_BOTTOM, monitor))
|
||||
edges |= views::ViewsDelegate::EDGE_BOTTOM;
|
||||
return edges;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace atom {
|
||||
|
||||
HICON ViewsDelegate::GetDefaultWindowIcon() const {
|
||||
// Use current exe's icon as default window icon.
|
||||
return LoadIcon(GetModuleHandle(NULL),
|
||||
MAKEINTRESOURCE(1 /* IDR_MAINFRAME */));
|
||||
}
|
||||
|
||||
HICON ViewsDelegate::GetSmallWindowIcon() const {
|
||||
return GetDefaultWindowIcon();
|
||||
}
|
||||
|
||||
bool ViewsDelegate::IsWindowInMetro(gfx::NativeWindow window) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ViewsDelegate::GetAppbarAutohideEdges(HMONITOR monitor,
|
||||
base::OnceClosure callback) {
|
||||
// Initialize the map with EDGE_BOTTOM. This is important, as if we return an
|
||||
// initial value of 0 (no auto-hide edges) then we'll go fullscreen and
|
||||
// windows will automatically remove WS_EX_TOPMOST from the appbar resulting
|
||||
// in us thinking there is no auto-hide edges. By returning at least one edge
|
||||
// we don't initially go fullscreen until we figure out the real auto-hide
|
||||
// edges.
|
||||
if (!appbar_autohide_edge_map_.count(monitor))
|
||||
appbar_autohide_edge_map_[monitor] = EDGE_BOTTOM;
|
||||
|
||||
// We use the SHAppBarMessage API to get the taskbar autohide state. This API
|
||||
// spins a modal loop which could cause callers to be reentered. To avoid
|
||||
// that we retrieve the taskbar state in a worker thread.
|
||||
if (monitor && !in_autohide_edges_callback_) {
|
||||
// TODO(robliao): Annotate this task with .WithCOM() once supported.
|
||||
// https://crbug.com/662122
|
||||
base::PostTaskWithTraitsAndReplyWithResult(
|
||||
FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_BLOCKING},
|
||||
base::BindOnce(&GetAppbarAutohideEdgesOnWorkerThread, monitor),
|
||||
base::BindOnce(&ViewsDelegate::OnGotAppbarAutohideEdges,
|
||||
weak_factory_.GetWeakPtr(), std::move(callback), monitor,
|
||||
appbar_autohide_edge_map_[monitor]));
|
||||
}
|
||||
return appbar_autohide_edge_map_[monitor];
|
||||
}
|
||||
|
||||
void ViewsDelegate::OnGotAppbarAutohideEdges(base::OnceClosure callback,
|
||||
HMONITOR monitor,
|
||||
int returned_edges,
|
||||
int edges) {
|
||||
appbar_autohide_edge_map_[monitor] = edges;
|
||||
if (returned_edges == edges)
|
||||
return;
|
||||
|
||||
base::AutoReset<bool> in_callback_setter(&in_autohide_edges_callback_, true);
|
||||
std::move(callback).Run();
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
@@ -1,51 +0,0 @@
|
||||
// Copyright (c) 2013 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Multiply-included file, no traditional include guard.
|
||||
|
||||
#include "atom/common/draggable_region.h"
|
||||
#include "base/strings/string16.h"
|
||||
#include "base/values.h"
|
||||
#include "content/public/common/common_param_traits.h"
|
||||
#include "content/public/common/referrer.h"
|
||||
#include "ipc/ipc_message_macros.h"
|
||||
#include "ipc/ipc_platform_file.h"
|
||||
#include "ui/gfx/geometry/rect_f.h"
|
||||
#include "ui/gfx/ipc/gfx_param_traits.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
// The message starter should be declared in ipc/ipc_message_start.h. Since
|
||||
// we don't want to patch Chromium, we just pretend to be Content Shell.
|
||||
|
||||
#define IPC_MESSAGE_START ElectronMsgStart
|
||||
|
||||
IPC_STRUCT_TRAITS_BEGIN(atom::DraggableRegion)
|
||||
IPC_STRUCT_TRAITS_MEMBER(draggable)
|
||||
IPC_STRUCT_TRAITS_MEMBER(bounds)
|
||||
IPC_STRUCT_TRAITS_END()
|
||||
|
||||
IPC_MESSAGE_ROUTED3(AtomAutofillFrameHostMsg_ShowPopup,
|
||||
gfx::RectF /* bounds */,
|
||||
std::vector<base::string16> /* values */,
|
||||
std::vector<base::string16> /* labels */)
|
||||
|
||||
IPC_MESSAGE_ROUTED0(AtomAutofillFrameHostMsg_HidePopup)
|
||||
|
||||
IPC_MESSAGE_ROUTED1(AtomAutofillFrameMsg_AcceptSuggestion,
|
||||
base::string16 /* suggestion */)
|
||||
|
||||
// Sent by the renderer when the draggable regions are updated.
|
||||
IPC_MESSAGE_ROUTED1(AtomFrameHostMsg_UpdateDraggableRegions,
|
||||
std::vector<atom::DraggableRegion> /* regions */)
|
||||
|
||||
// Update renderer process preferences.
|
||||
IPC_MESSAGE_CONTROL1(AtomMsg_UpdatePreferences, base::ListValue)
|
||||
|
||||
// Sent by renderer to set the temporary zoom level.
|
||||
IPC_SYNC_MESSAGE_ROUTED1_1(AtomFrameHostMsg_SetTemporaryZoomLevel,
|
||||
double /* zoom level */,
|
||||
double /* result */)
|
||||
|
||||
// Sent by renderer to get the zoom level.
|
||||
IPC_SYNC_MESSAGE_ROUTED0_1(AtomFrameHostMsg_GetZoomLevel, double /* result */)
|
||||
@@ -1,69 +0,0 @@
|
||||
// Copyright (c) 2013 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "atom/common/crash_reporter/crash_reporter.h"
|
||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||
#include "base/bind.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
using crash_reporter::CrashReporter;
|
||||
|
||||
namespace mate {
|
||||
|
||||
template <>
|
||||
struct Converter<CrashReporter::UploadReportResult> {
|
||||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const CrashReporter::UploadReportResult& reports) {
|
||||
mate::Dictionary dict(isolate, v8::Object::New(isolate));
|
||||
dict.Set("date",
|
||||
v8::Date::New(isolate->GetCurrentContext(), reports.first * 1000.0)
|
||||
.ToLocalChecked());
|
||||
dict.Set("id", reports.second);
|
||||
return dict.GetHandle();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
namespace {
|
||||
|
||||
void AddExtraParameter(const std::string& key, const std::string& value) {
|
||||
CrashReporter::GetInstance()->AddExtraParameter(key, value);
|
||||
}
|
||||
|
||||
void RemoveExtraParameter(const std::string& key) {
|
||||
CrashReporter::GetInstance()->RemoveExtraParameter(key);
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> GetParameters() {
|
||||
return CrashReporter::GetInstance()->GetParameters();
|
||||
}
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
auto reporter = base::Unretained(CrashReporter::GetInstance());
|
||||
dict.SetMethod("start", base::Bind(&CrashReporter::Start, reporter));
|
||||
dict.SetMethod("addExtraParameter", &AddExtraParameter);
|
||||
dict.SetMethod("removeExtraParameter", &RemoveExtraParameter);
|
||||
dict.SetMethod("getParameters", &GetParameters);
|
||||
dict.SetMethod("getUploadedReports",
|
||||
base::Bind(&CrashReporter::GetUploadedReports, reporter));
|
||||
dict.SetMethod("setUploadToServer",
|
||||
base::Bind(&CrashReporter::SetUploadToServer, reporter));
|
||||
dict.SetMethod("getUploadToServer",
|
||||
base::Bind(&CrashReporter::GetUploadToServer, reporter));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_common_crash_reporter, Initialize)
|
||||
@@ -1,33 +0,0 @@
|
||||
// Copyright (c) 2013 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_COMMON_ATOM_VERSION_H_
|
||||
#define ATOM_COMMON_ATOM_VERSION_H_
|
||||
|
||||
#define ATOM_MAJOR_VERSION 6
|
||||
#define ATOM_MINOR_VERSION 1
|
||||
#define ATOM_PATCH_VERSION 10
|
||||
// clang-format off
|
||||
// #define ATOM_PRE_RELEASE_VERSION
|
||||
// clang-format on
|
||||
|
||||
#ifndef ATOM_STRINGIFY
|
||||
#define ATOM_STRINGIFY(n) ATOM_STRINGIFY_HELPER(n)
|
||||
#define ATOM_STRINGIFY_HELPER(n) #n
|
||||
#endif
|
||||
|
||||
#ifndef ATOM_PRE_RELEASE_VERSION
|
||||
#define ATOM_VERSION_STRING \
|
||||
ATOM_STRINGIFY(ATOM_MAJOR_VERSION) \
|
||||
"." ATOM_STRINGIFY(ATOM_MINOR_VERSION) "." ATOM_STRINGIFY(ATOM_PATCH_VERSION)
|
||||
#else
|
||||
#define ATOM_VERSION_STRING \
|
||||
ATOM_STRINGIFY(ATOM_MAJOR_VERSION) \
|
||||
"." ATOM_STRINGIFY(ATOM_MINOR_VERSION) "." ATOM_STRINGIFY( \
|
||||
ATOM_PATCH_VERSION) ATOM_STRINGIFY(ATOM_PRE_RELEASE_VERSION)
|
||||
#endif
|
||||
|
||||
#define ATOM_VERSION "v" ATOM_VERSION_STRING
|
||||
|
||||
#endif // ATOM_COMMON_ATOM_VERSION_H_
|
||||
@@ -1,31 +0,0 @@
|
||||
// Copyright (c) 2014 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Get basic type definitions.
|
||||
#define IPC_MESSAGE_IMPL
|
||||
#include "atom/common/common_message_generator.h"
|
||||
|
||||
// Generate constructors.
|
||||
#include "ipc/struct_constructor_macros.h"
|
||||
|
||||
// lint: must come after struct_constructor_macros.
|
||||
#include "atom/common/common_message_generator.h"
|
||||
|
||||
// Generate param traits write methods.
|
||||
#include "ipc/param_traits_write_macros.h"
|
||||
namespace IPC {
|
||||
#include "atom/common/common_message_generator.h"
|
||||
} // namespace IPC
|
||||
|
||||
// Generate param traits read methods.
|
||||
#include "ipc/param_traits_read_macros.h"
|
||||
namespace IPC {
|
||||
#include "atom/common/common_message_generator.h"
|
||||
} // namespace IPC
|
||||
|
||||
// Generate param traits log methods.
|
||||
#include "ipc/param_traits_log_macros.h"
|
||||
namespace IPC {
|
||||
#include "atom/common/common_message_generator.h"
|
||||
} // namespace IPC
|
||||
@@ -1,7 +0,0 @@
|
||||
// Copyright (c) 2014 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Multiply-included file, no traditional include guard.
|
||||
|
||||
#include "atom/common/api/api_messages.h"
|
||||
@@ -1,11 +0,0 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/common/draggable_region.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
DraggableRegion::DraggableRegion() : draggable(false) {}
|
||||
|
||||
} // namespace atom
|
||||
@@ -1,21 +0,0 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_COMMON_DRAGGABLE_REGION_H_
|
||||
#define ATOM_COMMON_DRAGGABLE_REGION_H_
|
||||
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
struct DraggableRegion {
|
||||
bool draggable;
|
||||
gfx::Rect bounds;
|
||||
|
||||
DraggableRegion();
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_COMMON_DRAGGABLE_REGION_H_
|
||||
@@ -1,107 +0,0 @@
|
||||
// Copyright (c) 2015 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/common/mouse_util.h"
|
||||
#include <string>
|
||||
|
||||
using Cursor = blink::WebCursorInfo::Type;
|
||||
|
||||
namespace atom {
|
||||
|
||||
std::string CursorTypeToString(const content::CursorInfo& info) {
|
||||
switch (info.type) {
|
||||
case Cursor::kTypePointer:
|
||||
return "default";
|
||||
case Cursor::kTypeCross:
|
||||
return "crosshair";
|
||||
case Cursor::kTypeHand:
|
||||
return "pointer";
|
||||
case Cursor::kTypeIBeam:
|
||||
return "text";
|
||||
case Cursor::kTypeWait:
|
||||
return "wait";
|
||||
case Cursor::kTypeHelp:
|
||||
return "help";
|
||||
case Cursor::kTypeEastResize:
|
||||
return "e-resize";
|
||||
case Cursor::kTypeNorthResize:
|
||||
return "n-resize";
|
||||
case Cursor::kTypeNorthEastResize:
|
||||
return "ne-resize";
|
||||
case Cursor::kTypeNorthWestResize:
|
||||
return "nw-resize";
|
||||
case Cursor::kTypeSouthResize:
|
||||
return "s-resize";
|
||||
case Cursor::kTypeSouthEastResize:
|
||||
return "se-resize";
|
||||
case Cursor::kTypeSouthWestResize:
|
||||
return "sw-resize";
|
||||
case Cursor::kTypeWestResize:
|
||||
return "w-resize";
|
||||
case Cursor::kTypeNorthSouthResize:
|
||||
return "ns-resize";
|
||||
case Cursor::kTypeEastWestResize:
|
||||
return "ew-resize";
|
||||
case Cursor::kTypeNorthEastSouthWestResize:
|
||||
return "nesw-resize";
|
||||
case Cursor::kTypeNorthWestSouthEastResize:
|
||||
return "nwse-resize";
|
||||
case Cursor::kTypeColumnResize:
|
||||
return "col-resize";
|
||||
case Cursor::kTypeRowResize:
|
||||
return "row-resize";
|
||||
case Cursor::kTypeMiddlePanning:
|
||||
return "m-panning";
|
||||
case Cursor::kTypeEastPanning:
|
||||
return "e-panning";
|
||||
case Cursor::kTypeNorthPanning:
|
||||
return "n-panning";
|
||||
case Cursor::kTypeNorthEastPanning:
|
||||
return "ne-panning";
|
||||
case Cursor::kTypeNorthWestPanning:
|
||||
return "nw-panning";
|
||||
case Cursor::kTypeSouthPanning:
|
||||
return "s-panning";
|
||||
case Cursor::kTypeSouthEastPanning:
|
||||
return "se-panning";
|
||||
case Cursor::kTypeSouthWestPanning:
|
||||
return "sw-panning";
|
||||
case Cursor::kTypeWestPanning:
|
||||
return "w-panning";
|
||||
case Cursor::kTypeMove:
|
||||
return "move";
|
||||
case Cursor::kTypeVerticalText:
|
||||
return "vertical-text";
|
||||
case Cursor::kTypeCell:
|
||||
return "cell";
|
||||
case Cursor::kTypeContextMenu:
|
||||
return "context-menu";
|
||||
case Cursor::kTypeAlias:
|
||||
return "alias";
|
||||
case Cursor::kTypeProgress:
|
||||
return "progress";
|
||||
case Cursor::kTypeNoDrop:
|
||||
return "nodrop";
|
||||
case Cursor::kTypeCopy:
|
||||
return "copy";
|
||||
case Cursor::kTypeNone:
|
||||
return "none";
|
||||
case Cursor::kTypeNotAllowed:
|
||||
return "not-allowed";
|
||||
case Cursor::kTypeZoomIn:
|
||||
return "zoom-in";
|
||||
case Cursor::kTypeZoomOut:
|
||||
return "zoom-out";
|
||||
case Cursor::kTypeGrab:
|
||||
return "grab";
|
||||
case Cursor::kTypeGrabbing:
|
||||
return "grabbing";
|
||||
case Cursor::kTypeCustom:
|
||||
return "custom";
|
||||
default:
|
||||
return "default";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
@@ -1,219 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
|
||||
<data>
|
||||
<int key="IBDocument.SystemTarget">101000</int>
|
||||
<string key="IBDocument.SystemVersion">14D136</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">7531</string>
|
||||
<string key="IBDocument.AppKitVersion">1347.57</string>
|
||||
<string key="IBDocument.HIToolboxVersion">758.70</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="NS.object.0">7531</string>
|
||||
</object>
|
||||
<array key="IBDocument.IntegratedClassDependencies">
|
||||
<string>NSCustomObject</string>
|
||||
<string>NSMenu</string>
|
||||
<string>NSMenuItem</string>
|
||||
</array>
|
||||
<array key="IBDocument.PluginDependencies">
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
</array>
|
||||
<object class="NSMutableDictionary" key="IBDocument.Metadata">
|
||||
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
|
||||
<integer value="1" key="NS.object.0"/>
|
||||
</object>
|
||||
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1048">
|
||||
<object class="NSCustomObject" id="1021">
|
||||
<string key="NSClassName">AtomApplication</string>
|
||||
</object>
|
||||
<object class="NSCustomObject" id="1014">
|
||||
<string key="NSClassName">FirstResponder</string>
|
||||
</object>
|
||||
<object class="NSCustomObject" id="1050">
|
||||
<string key="NSClassName">NSApplication</string>
|
||||
</object>
|
||||
<object class="NSCustomObject" id="903638069">
|
||||
<string key="NSClassName">NSFontManager</string>
|
||||
</object>
|
||||
<object class="NSMenu" id="649796088">
|
||||
<string key="NSTitle">Main Menu</string>
|
||||
<array class="NSMutableArray" key="NSMenuItems">
|
||||
<object class="NSMenuItem" id="694149608">
|
||||
<reference key="NSMenu" ref="649796088"/>
|
||||
<string key="NSTitle">Electron</string>
|
||||
<string key="NSKeyEquiv"/>
|
||||
<int key="NSMnemonicLoc">2147483647</int>
|
||||
<object class="NSCustomResource" key="NSOnImage" id="229763992">
|
||||
<string key="NSClassName">NSImage</string>
|
||||
<string key="NSResourceName">NSMenuCheckmark</string>
|
||||
</object>
|
||||
<object class="NSCustomResource" key="NSMixedImage" id="909111550">
|
||||
<string key="NSClassName">NSImage</string>
|
||||
<string key="NSResourceName">NSMenuMixedState</string>
|
||||
</object>
|
||||
<string key="NSAction">submenuAction:</string>
|
||||
<reference key="NSTarget" ref="110575045"/>
|
||||
<object class="NSMenu" key="NSSubmenu" id="110575045">
|
||||
<string key="NSTitle">Electron</string>
|
||||
<array class="NSMutableArray" key="NSMenuItems">
|
||||
<object class="NSMenuItem" id="632727374">
|
||||
<reference key="NSMenu" ref="110575045"/>
|
||||
<string key="NSTitle">Quit</string>
|
||||
<string key="NSKeyEquiv">q</string>
|
||||
<int key="NSKeyEquivModMask">1048576</int>
|
||||
<int key="NSMnemonicLoc">2147483647</int>
|
||||
<reference key="NSOnImage" ref="229763992"/>
|
||||
<reference key="NSMixedImage" ref="909111550"/>
|
||||
</object>
|
||||
<object class="NSMenuItem" id="1025936716">
|
||||
<reference key="NSMenu" ref="110575045"/>
|
||||
<string key="NSTitle">Open Recent</string>
|
||||
<string key="NSKeyEquiv"/>
|
||||
<int key="NSKeyEquivModMask">1048576</int>
|
||||
<int key="NSMnemonicLoc">2147483647</int>
|
||||
<bool key="NSIsHidden">YES</bool>
|
||||
<reference key="NSOnImage" ref="229763992"/>
|
||||
<reference key="NSMixedImage" ref="909111550"/>
|
||||
<string key="NSAction">submenuAction:</string>
|
||||
<object class="NSMenu" key="NSSubmenu" id="1065607017">
|
||||
<string key="NSTitle">Open Recent</string>
|
||||
<array class="NSMutableArray" key="NSMenuItems"></array>
|
||||
<string key="NSName">_NSRecentDocumentsMenu</string>
|
||||
</object>
|
||||
</object>
|
||||
</array>
|
||||
<string key="NSName">_NSAppleMenu</string>
|
||||
</object>
|
||||
</object>
|
||||
</array>
|
||||
<string key="NSName">_NSMainMenu</string>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||
<array key="connectionRecords">
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBActionConnection" key="connection">
|
||||
<string key="label">terminate:</string>
|
||||
<reference key="source" ref="1014"/>
|
||||
<reference key="destination" ref="632727374"/>
|
||||
</object>
|
||||
<int key="connectionID">807</int>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<array key="orderedObjects">
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">0</int>
|
||||
<array key="object" id="0"/>
|
||||
<reference key="children" ref="1048"/>
|
||||
<nil key="parent"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-2</int>
|
||||
<reference key="object" ref="1021"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">File's Owner</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-1</int>
|
||||
<reference key="object" ref="1014"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">First Responder</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-3</int>
|
||||
<reference key="object" ref="1050"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">Application</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">371</int>
|
||||
<reference key="object" ref="903638069"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
<!-- NSMenu Main Menu -->
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">29</int>
|
||||
<reference key="object" ref="649796088"/>
|
||||
<array class="NSMutableArray" key="children">
|
||||
<reference ref="694149608"/>
|
||||
</array>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
<!-- NSMenuItem Electron -->
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">56</int>
|
||||
<reference key="object" ref="694149608"/>
|
||||
<array class="NSMutableArray" key="children">
|
||||
<reference ref="110575045"/>
|
||||
</array>
|
||||
<reference key="parent" ref="649796088"/>
|
||||
</object>
|
||||
<!-- NSMenu Electron -->
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">57</int>
|
||||
<reference key="object" ref="110575045"/>
|
||||
<array class="NSMutableArray" key="children">
|
||||
<reference ref="632727374"/>
|
||||
<reference ref="1025936716"/>
|
||||
</array>
|
||||
<reference key="parent" ref="694149608"/>
|
||||
</object>
|
||||
<!-- NSMenuItem Quit -->
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">136</int>
|
||||
<reference key="object" ref="632727374"/>
|
||||
<reference key="parent" ref="110575045"/>
|
||||
</object>
|
||||
<!-- NSMenuItem Open Recent -->
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">124</int>
|
||||
<reference key="object" ref="1025936716"/>
|
||||
<array class="NSMutableArray" key="children">
|
||||
<reference ref="1065607017"/>
|
||||
</array>
|
||||
<reference key="parent" ref="110575045"/>
|
||||
</object>
|
||||
<!-- NSMenu Open Recent -->
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">125</int>
|
||||
<reference key="object" ref="1065607017"/>
|
||||
<array class="NSMutableArray" key="children"></array>
|
||||
<reference key="parent" ref="1025936716"/>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
<dictionary class="NSMutableDictionary" key="flattenedProperties">
|
||||
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="29.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="371.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="56.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="57.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="136.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="124.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="125.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
|
||||
<nil key="activeLocalization"/>
|
||||
<dictionary class="NSMutableDictionary" key="localizations"/>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">807</int>
|
||||
</object>
|
||||
<int key="IBDocument.localizationMode">0</int>
|
||||
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
|
||||
<bool key="IBDocument.previouslyAttemptedUpgradeToXcode5">NO</bool>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
|
||||
<integer value="4600" key="NS.object.0"/>
|
||||
</object>
|
||||
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
|
||||
<int key="IBDocument.defaultPropertyAccessControl">3</int>
|
||||
<dictionary class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
|
||||
<string key="NSMenuCheckmark">{12, 12}</string>
|
||||
<string key="NSMenuMixedState">{10, 2}</string>
|
||||
</dictionary>
|
||||
<bool key="IBDocument.UseAutolayout">YES</bool>
|
||||
</data>
|
||||
</archive>
|
||||
@@ -1,513 +0,0 @@
|
||||
// Copyright (c) 2019 Slack Technologies, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/renderer/api/atom_api_context_bridge.h"
|
||||
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/common/api/object_life_monitor.h"
|
||||
#include "atom/common/native_mate_converters/blink_converter.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/once_callback.h"
|
||||
#include "atom/common/promise_util.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
namespace {
|
||||
|
||||
static int kMaxRecursion = 1000;
|
||||
|
||||
content::RenderFrame* GetRenderFrame(const v8::Local<v8::Object>& value) {
|
||||
v8::Local<v8::Context> context = value->CreationContext();
|
||||
if (context.IsEmpty())
|
||||
return nullptr;
|
||||
blink::WebLocalFrame* frame = blink::WebLocalFrame::FrameForContext(context);
|
||||
if (!frame)
|
||||
return nullptr;
|
||||
return content::RenderFrame::FromWebFrame(frame);
|
||||
}
|
||||
|
||||
std::map<content::RenderFrame*, context_bridge::RenderFramePersistenceStore*>&
|
||||
GetStoreMap() {
|
||||
static base::NoDestructor<std::map<
|
||||
content::RenderFrame*, context_bridge::RenderFramePersistenceStore*>>
|
||||
store_map;
|
||||
return *store_map;
|
||||
}
|
||||
|
||||
context_bridge::RenderFramePersistenceStore* GetOrCreateStore(
|
||||
content::RenderFrame* render_frame) {
|
||||
auto it = GetStoreMap().find(render_frame);
|
||||
if (it == GetStoreMap().end()) {
|
||||
auto* store = new context_bridge::RenderFramePersistenceStore(render_frame);
|
||||
GetStoreMap().emplace(render_frame, store);
|
||||
return store;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
// Sourced from "extensions/renderer/v8_schema_registry.cc"
|
||||
// Recursively freezes every v8 object on |object|.
|
||||
bool DeepFreeze(const v8::Local<v8::Object>& object,
|
||||
const v8::Local<v8::Context>& context,
|
||||
std::set<int> frozen = std::set<int>()) {
|
||||
int hash = object->GetIdentityHash();
|
||||
if (frozen.find(hash) != frozen.end())
|
||||
return true;
|
||||
frozen.insert(hash);
|
||||
|
||||
v8::Local<v8::Array> property_names =
|
||||
object->GetOwnPropertyNames(context).ToLocalChecked();
|
||||
for (uint32_t i = 0; i < property_names->Length(); ++i) {
|
||||
v8::Local<v8::Value> child =
|
||||
object->Get(context, property_names->Get(context, i).ToLocalChecked())
|
||||
.ToLocalChecked();
|
||||
if (child->IsObject() && !child->IsTypedArray()) {
|
||||
if (!DeepFreeze(v8::Local<v8::Object>::Cast(child), context, frozen))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return mate::internal::IsTrue(
|
||||
object->SetIntegrityLevel(context, v8::IntegrityLevel::kFrozen));
|
||||
}
|
||||
|
||||
bool IsPlainObject(const v8::Local<v8::Value>& object) {
|
||||
if (!object->IsObject())
|
||||
return false;
|
||||
|
||||
return !(object->IsNullOrUndefined() || object->IsDate() ||
|
||||
object->IsArgumentsObject() || object->IsBigIntObject() ||
|
||||
object->IsBooleanObject() || object->IsNumberObject() ||
|
||||
object->IsStringObject() || object->IsSymbolObject() ||
|
||||
object->IsNativeError() || object->IsRegExp() ||
|
||||
object->IsPromise() || object->IsMap() || object->IsSet() ||
|
||||
object->IsMapIterator() || object->IsSetIterator() ||
|
||||
object->IsWeakMap() || object->IsWeakSet() ||
|
||||
object->IsArrayBuffer() || object->IsArrayBufferView() ||
|
||||
object->IsArray() || object->IsDataView() ||
|
||||
object->IsSharedArrayBuffer() || object->IsProxy() ||
|
||||
object->IsWebAssemblyCompiledModule() ||
|
||||
object->IsModuleNamespaceObject());
|
||||
}
|
||||
|
||||
bool IsPlainArray(const v8::Local<v8::Value>& arr) {
|
||||
if (!arr->IsArray())
|
||||
return false;
|
||||
|
||||
return !arr->IsTypedArray();
|
||||
}
|
||||
|
||||
class FunctionLifeMonitor final : public ObjectLifeMonitor {
|
||||
public:
|
||||
static void BindTo(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> target,
|
||||
context_bridge::RenderFramePersistenceStore* store,
|
||||
size_t func_id) {
|
||||
new FunctionLifeMonitor(isolate, target, store, func_id);
|
||||
}
|
||||
|
||||
protected:
|
||||
FunctionLifeMonitor(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> target,
|
||||
context_bridge::RenderFramePersistenceStore* store,
|
||||
size_t func_id)
|
||||
: ObjectLifeMonitor(isolate, target), store_(store), func_id_(func_id) {}
|
||||
~FunctionLifeMonitor() override = default;
|
||||
|
||||
void RunDestructor() override { store_->functions().erase(func_id_); }
|
||||
|
||||
private:
|
||||
context_bridge::RenderFramePersistenceStore* store_;
|
||||
size_t func_id_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
template <typename Sig>
|
||||
v8::Local<v8::Value> BindRepeatingFunctionToV8(
|
||||
v8::Isolate* isolate,
|
||||
const base::RepeatingCallback<Sig>& val) {
|
||||
auto translater =
|
||||
base::BindRepeating(&mate::internal::NativeFunctionInvoker<Sig>::Go, val);
|
||||
return mate::internal::CreateFunctionFromTranslater(isolate, translater,
|
||||
false);
|
||||
}
|
||||
|
||||
v8::MaybeLocal<v8::Value> PassValueToOtherContext(
|
||||
v8::Local<v8::Context> source_context,
|
||||
v8::Local<v8::Context> destination_context,
|
||||
v8::Local<v8::Value> value,
|
||||
context_bridge::RenderFramePersistenceStore* store,
|
||||
int recursion_depth) {
|
||||
if (recursion_depth >= kMaxRecursion) {
|
||||
v8::Context::Scope source_scope(source_context);
|
||||
{
|
||||
source_context->GetIsolate()->ThrowException(v8::Exception::TypeError(
|
||||
mate::StringToV8(source_context->GetIsolate(),
|
||||
"Electron contextBridge recursion depth exceeded. "
|
||||
"Nested objects "
|
||||
"deeper than 1000 are not supported.")));
|
||||
return v8::MaybeLocal<v8::Value>();
|
||||
}
|
||||
}
|
||||
// Check Cache
|
||||
auto cached_value = store->GetCachedProxiedObject(value);
|
||||
if (!cached_value.IsEmpty()) {
|
||||
return cached_value;
|
||||
}
|
||||
|
||||
// Proxy functions and monitor the lifetime in the new context to release
|
||||
// the global handle at the right time.
|
||||
if (value->IsFunction()) {
|
||||
auto func = v8::Local<v8::Function>::Cast(value);
|
||||
v8::Global<v8::Function> global_func(source_context->GetIsolate(), func);
|
||||
v8::Global<v8::Context> global_source(source_context->GetIsolate(),
|
||||
source_context);
|
||||
|
||||
size_t func_id = store->take_func_id();
|
||||
store->functions()[func_id] =
|
||||
std::make_tuple(std::move(global_func), std::move(global_source));
|
||||
v8::Context::Scope destination_scope(destination_context);
|
||||
{
|
||||
v8::Local<v8::Value> proxy_func = BindRepeatingFunctionToV8(
|
||||
destination_context->GetIsolate(),
|
||||
base::BindRepeating(&ProxyFunctionWrapper, store, func_id));
|
||||
FunctionLifeMonitor::BindTo(destination_context->GetIsolate(),
|
||||
v8::Local<v8::Object>::Cast(proxy_func),
|
||||
store, func_id);
|
||||
store->CacheProxiedObject(value, proxy_func);
|
||||
return v8::MaybeLocal<v8::Value>(proxy_func);
|
||||
}
|
||||
}
|
||||
|
||||
// Proxy promises as they have a safe and guaranteed memory lifecycle
|
||||
if (value->IsPromise()) {
|
||||
v8::Context::Scope destination_scope(destination_context);
|
||||
{
|
||||
auto source_promise = v8::Local<v8::Promise>::Cast(value);
|
||||
auto* proxied_promise =
|
||||
new util::Promise(destination_context->GetIsolate());
|
||||
v8::Local<v8::Promise> proxied_promise_handle =
|
||||
proxied_promise->GetHandle();
|
||||
|
||||
auto then_cb = base::BindOnce(
|
||||
[](util::Promise* proxied_promise, v8::Isolate* isolate,
|
||||
v8::Global<v8::Context> global_source_context,
|
||||
v8::Global<v8::Context> global_destination_context,
|
||||
context_bridge::RenderFramePersistenceStore* store,
|
||||
v8::Local<v8::Value> result) {
|
||||
auto val = PassValueToOtherContext(
|
||||
global_source_context.Get(isolate),
|
||||
global_destination_context.Get(isolate), result, store, 0);
|
||||
if (!val.IsEmpty())
|
||||
proxied_promise->Resolve(val.ToLocalChecked());
|
||||
delete proxied_promise;
|
||||
},
|
||||
proxied_promise, destination_context->GetIsolate(),
|
||||
v8::Global<v8::Context>(source_context->GetIsolate(), source_context),
|
||||
v8::Global<v8::Context>(destination_context->GetIsolate(),
|
||||
destination_context),
|
||||
store);
|
||||
auto catch_cb = base::BindOnce(
|
||||
[](util::Promise* proxied_promise, v8::Isolate* isolate,
|
||||
v8::Global<v8::Context> global_source_context,
|
||||
v8::Global<v8::Context> global_destination_context,
|
||||
context_bridge::RenderFramePersistenceStore* store,
|
||||
v8::Local<v8::Value> result) {
|
||||
auto val = PassValueToOtherContext(
|
||||
global_source_context.Get(isolate),
|
||||
global_destination_context.Get(isolate), result, store, 0);
|
||||
if (!val.IsEmpty())
|
||||
proxied_promise->Reject(val.ToLocalChecked());
|
||||
delete proxied_promise;
|
||||
},
|
||||
proxied_promise, destination_context->GetIsolate(),
|
||||
v8::Global<v8::Context>(source_context->GetIsolate(), source_context),
|
||||
v8::Global<v8::Context>(destination_context->GetIsolate(),
|
||||
destination_context),
|
||||
store);
|
||||
|
||||
ignore_result(source_promise->Then(
|
||||
source_context,
|
||||
v8::Local<v8::Function>::Cast(
|
||||
mate::ConvertToV8(destination_context->GetIsolate(), then_cb)),
|
||||
v8::Local<v8::Function>::Cast(
|
||||
mate::ConvertToV8(destination_context->GetIsolate(), catch_cb))));
|
||||
|
||||
store->CacheProxiedObject(value, proxied_promise_handle);
|
||||
return v8::MaybeLocal<v8::Value>(proxied_promise_handle);
|
||||
}
|
||||
}
|
||||
|
||||
// Errors aren't serializable currently, we need to pull the message out and
|
||||
// re-construct in the destination context
|
||||
if (value->IsNativeError()) {
|
||||
v8::Context::Scope destination_context_scope(destination_context);
|
||||
return v8::MaybeLocal<v8::Value>(v8::Exception::Error(
|
||||
v8::Exception::CreateMessage(destination_context->GetIsolate(), value)
|
||||
->Get()));
|
||||
}
|
||||
|
||||
// Manually go through the array and pass each value individually into a new
|
||||
// array so that functions deep inside arrays get proxied or arrays of
|
||||
// promises are proxied correctly.
|
||||
if (IsPlainArray(value)) {
|
||||
v8::Context::Scope destination_context_scope(destination_context);
|
||||
{
|
||||
v8::Local<v8::Array> arr = v8::Local<v8::Array>::Cast(value);
|
||||
size_t length = arr->Length();
|
||||
v8::Local<v8::Array> cloned_arr =
|
||||
v8::Array::New(destination_context->GetIsolate(), length);
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
auto value_for_array = PassValueToOtherContext(
|
||||
source_context, destination_context,
|
||||
arr->Get(source_context, i).ToLocalChecked(), store,
|
||||
recursion_depth + 1);
|
||||
if (value_for_array.IsEmpty())
|
||||
return v8::MaybeLocal<v8::Value>();
|
||||
|
||||
if (!mate::internal::IsTrue(
|
||||
cloned_arr->Set(destination_context, static_cast<int>(i),
|
||||
value_for_array.ToLocalChecked()))) {
|
||||
return v8::MaybeLocal<v8::Value>();
|
||||
}
|
||||
}
|
||||
store->CacheProxiedObject(value, cloned_arr);
|
||||
return v8::MaybeLocal<v8::Value>(cloned_arr);
|
||||
}
|
||||
}
|
||||
|
||||
// Proxy all objects
|
||||
if (IsPlainObject(value)) {
|
||||
auto object_value = v8::Local<v8::Object>::Cast(value);
|
||||
auto passed_value =
|
||||
CreateProxyForAPI(object_value, source_context, destination_context,
|
||||
store, recursion_depth + 1);
|
||||
if (passed_value.IsEmpty())
|
||||
return v8::MaybeLocal<v8::Value>();
|
||||
return v8::MaybeLocal<v8::Value>(passed_value.ToLocalChecked());
|
||||
}
|
||||
|
||||
// Serializable objects
|
||||
blink::CloneableMessage ret;
|
||||
{
|
||||
v8::Context::Scope source_context_scope(source_context);
|
||||
{
|
||||
// V8 serializer will throw an error if required
|
||||
if (!mate::ConvertFromV8(source_context->GetIsolate(), value, &ret))
|
||||
return v8::MaybeLocal<v8::Value>();
|
||||
}
|
||||
}
|
||||
|
||||
v8::Context::Scope destination_context_scope(destination_context);
|
||||
{
|
||||
v8::Local<v8::Value> cloned_value =
|
||||
mate::ConvertToV8(destination_context->GetIsolate(), ret);
|
||||
store->CacheProxiedObject(value, cloned_value);
|
||||
return v8::MaybeLocal<v8::Value>(cloned_value);
|
||||
}
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> ProxyFunctionWrapper(
|
||||
context_bridge::RenderFramePersistenceStore* store,
|
||||
size_t func_id,
|
||||
mate::Arguments* args) {
|
||||
// Context the proxy function was called from
|
||||
v8::Local<v8::Context> calling_context = args->isolate()->GetCurrentContext();
|
||||
// Context the function was created in
|
||||
v8::Local<v8::Context> func_owning_context =
|
||||
std::get<1>(store->functions()[func_id]).Get(args->isolate());
|
||||
|
||||
v8::Context::Scope func_owning_context_scope(func_owning_context);
|
||||
{
|
||||
v8::Local<v8::Function> func =
|
||||
(std::get<0>(store->functions()[func_id])).Get(args->isolate());
|
||||
|
||||
std::vector<v8::Local<v8::Value>> original_args;
|
||||
std::vector<v8::Local<v8::Value>> proxied_args;
|
||||
args->GetRemaining(&original_args);
|
||||
|
||||
for (auto value : original_args) {
|
||||
auto arg = PassValueToOtherContext(calling_context, func_owning_context,
|
||||
value, store, 0);
|
||||
if (arg.IsEmpty())
|
||||
return v8::Undefined(args->isolate());
|
||||
proxied_args.push_back(arg.ToLocalChecked());
|
||||
}
|
||||
|
||||
v8::MaybeLocal<v8::Value> maybe_return_value;
|
||||
bool did_error = false;
|
||||
std::string error_message;
|
||||
{
|
||||
v8::TryCatch try_catch(args->isolate());
|
||||
maybe_return_value = func->Call(func_owning_context, func,
|
||||
proxied_args.size(), proxied_args.data());
|
||||
if (try_catch.HasCaught()) {
|
||||
did_error = true;
|
||||
auto message = try_catch.Message();
|
||||
|
||||
if (message.IsEmpty() ||
|
||||
!mate::ConvertFromV8(args->isolate(), message->Get(),
|
||||
&error_message)) {
|
||||
error_message =
|
||||
"An unknown exception occurred in the isolated context, an error "
|
||||
"occurred but a valid exception was not thrown.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (did_error) {
|
||||
v8::Context::Scope calling_context_scope(calling_context);
|
||||
{
|
||||
args->ThrowError(error_message);
|
||||
return v8::Local<v8::Object>();
|
||||
}
|
||||
}
|
||||
|
||||
if (maybe_return_value.IsEmpty())
|
||||
return v8::Undefined(args->isolate());
|
||||
|
||||
auto ret =
|
||||
PassValueToOtherContext(func_owning_context, calling_context,
|
||||
maybe_return_value.ToLocalChecked(), store, 0);
|
||||
if (ret.IsEmpty())
|
||||
return v8::Undefined(args->isolate());
|
||||
return ret.ToLocalChecked();
|
||||
}
|
||||
}
|
||||
|
||||
v8::MaybeLocal<v8::Object> CreateProxyForAPI(
|
||||
const v8::Local<v8::Object>& api_object,
|
||||
const v8::Local<v8::Context>& source_context,
|
||||
const v8::Local<v8::Context>& destination_context,
|
||||
context_bridge::RenderFramePersistenceStore* store,
|
||||
int recursion_depth) {
|
||||
mate::Dictionary api(source_context->GetIsolate(), api_object);
|
||||
mate::Dictionary proxy =
|
||||
mate::Dictionary::CreateEmpty(destination_context->GetIsolate());
|
||||
store->CacheProxiedObject(api.GetHandle(), proxy.GetHandle());
|
||||
auto maybe_keys = api.GetHandle()->GetOwnPropertyNames(
|
||||
source_context,
|
||||
static_cast<v8::PropertyFilter>(v8::ONLY_ENUMERABLE | v8::SKIP_SYMBOLS),
|
||||
v8::KeyConversionMode::kConvertToString);
|
||||
if (maybe_keys.IsEmpty())
|
||||
return v8::MaybeLocal<v8::Object>(proxy.GetHandle());
|
||||
auto keys = maybe_keys.ToLocalChecked();
|
||||
|
||||
v8::Context::Scope destination_context_scope(destination_context);
|
||||
{
|
||||
uint32_t length = keys->Length();
|
||||
std::string key_str;
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
v8::Local<v8::Value> key =
|
||||
keys->Get(destination_context, i).ToLocalChecked();
|
||||
// Try get the key as a string
|
||||
if (!mate::ConvertFromV8(api.isolate(), key, &key_str)) {
|
||||
continue;
|
||||
}
|
||||
v8::Local<v8::Value> value;
|
||||
if (!api.Get(key_str, &value))
|
||||
continue;
|
||||
|
||||
auto passed_value =
|
||||
PassValueToOtherContext(source_context, destination_context, value,
|
||||
store, recursion_depth + 1);
|
||||
if (passed_value.IsEmpty())
|
||||
return v8::MaybeLocal<v8::Object>();
|
||||
proxy.Set(key_str, passed_value.ToLocalChecked());
|
||||
}
|
||||
|
||||
return proxy.GetHandle();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DCHECK_IS_ON
|
||||
mate::Dictionary DebugGC(mate::Dictionary empty) {
|
||||
auto* render_frame = GetRenderFrame(empty.GetHandle());
|
||||
auto* store = GetOrCreateStore(render_frame);
|
||||
mate::Dictionary ret = mate::Dictionary::CreateEmpty(empty.isolate());
|
||||
ret.Set("functionCount", store->functions().size());
|
||||
auto* proxy_map = store->proxy_map();
|
||||
ret.Set("objectCount", proxy_map->size() * 2);
|
||||
int live_from = 0;
|
||||
int live_proxy = 0;
|
||||
for (auto iter = proxy_map->begin(); iter != proxy_map->end(); iter++) {
|
||||
auto* node = iter->second;
|
||||
while (node) {
|
||||
if (!std::get<0>(node->pair).IsEmpty())
|
||||
live_from++;
|
||||
if (!std::get<1>(node->pair).IsEmpty())
|
||||
live_proxy++;
|
||||
node = node->next;
|
||||
}
|
||||
}
|
||||
ret.Set("liveFromValues", live_from);
|
||||
ret.Set("liveProxyValues", live_proxy);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
void ExposeAPIInMainWorld(const std::string& key,
|
||||
v8::Local<v8::Object> api_object,
|
||||
mate::Arguments* args) {
|
||||
auto* render_frame = GetRenderFrame(api_object);
|
||||
CHECK(render_frame);
|
||||
context_bridge::RenderFramePersistenceStore* store =
|
||||
GetOrCreateStore(render_frame);
|
||||
auto* frame = render_frame->GetWebFrame();
|
||||
CHECK(frame);
|
||||
v8::Local<v8::Context> main_context = frame->MainWorldScriptContext();
|
||||
mate::Dictionary global(main_context->GetIsolate(), main_context->Global());
|
||||
|
||||
if (global.Has(key)) {
|
||||
args->ThrowError(
|
||||
"Cannot bind an API on top of an existing property on the window "
|
||||
"object");
|
||||
return;
|
||||
}
|
||||
|
||||
v8::Local<v8::Context> isolated_context =
|
||||
frame->WorldScriptContext(args->isolate(), atom::World::ISOLATED_WORLD);
|
||||
|
||||
v8::Context::Scope main_context_scope(main_context);
|
||||
{
|
||||
v8::MaybeLocal<v8::Object> maybe_proxy =
|
||||
CreateProxyForAPI(api_object, isolated_context, main_context, store, 0);
|
||||
if (maybe_proxy.IsEmpty())
|
||||
return;
|
||||
auto proxy = maybe_proxy.ToLocalChecked();
|
||||
if (!DeepFreeze(proxy, main_context))
|
||||
return;
|
||||
|
||||
global.SetReadOnlyNonConfigurable(key, proxy);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
namespace {
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.SetMethod("exposeAPIInMainWorld", &atom::api::ExposeAPIInMainWorld);
|
||||
#ifdef DCHECK_IS_ON
|
||||
dict.SetMethod("_debugGCMaps", &atom::api::DebugGC);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_renderer_context_bridge, Initialize)
|
||||
@@ -1,41 +0,0 @@
|
||||
// Copyright (c) 2019 Slack Technologies, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_RENDERER_API_ATOM_API_CONTEXT_BRIDGE_H_
|
||||
#define ATOM_RENDERER_API_ATOM_API_CONTEXT_BRIDGE_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "atom/renderer/api/context_bridge/render_frame_context_bridge_store.h"
|
||||
#include "atom/renderer/atom_render_frame_observer.h"
|
||||
#include "content/public/renderer/render_frame.h"
|
||||
#include "content/public/renderer/render_frame_observer.h"
|
||||
#include "native_mate/converter.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "third_party/blink/public/web/web_local_frame.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
v8::Local<v8::Value> ProxyFunctionWrapper(
|
||||
context_bridge::RenderFramePersistenceStore* store,
|
||||
size_t func_id,
|
||||
mate::Arguments* args);
|
||||
|
||||
v8::MaybeLocal<v8::Object> CreateProxyForAPI(
|
||||
const v8::Local<v8::Object>& api_object,
|
||||
const v8::Local<v8::Context>& source_context,
|
||||
const v8::Local<v8::Context>& target_context,
|
||||
context_bridge::RenderFramePersistenceStore* store,
|
||||
int recursion_depth);
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_RENDERER_API_ATOM_API_CONTEXT_BRIDGE_H_
|
||||
@@ -1,178 +0,0 @@
|
||||
// Copyright (c) 2013 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "atom/common/api/api_messages.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "atom/common/node_bindings.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "base/values.h"
|
||||
#include "content/public/renderer/render_frame.h"
|
||||
#include "electron/atom/common/api/api.mojom.h"
|
||||
#include "native_mate/arguments.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
#include "services/service_manager/public/cpp/interface_provider.h"
|
||||
#include "third_party/blink/public/web/web_local_frame.h"
|
||||
|
||||
using blink::WebLocalFrame;
|
||||
using content::RenderFrame;
|
||||
|
||||
namespace {
|
||||
|
||||
RenderFrame* GetCurrentRenderFrame() {
|
||||
WebLocalFrame* frame = WebLocalFrame::FrameForCurrentContext();
|
||||
if (!frame)
|
||||
return nullptr;
|
||||
|
||||
return RenderFrame::FromWebFrame(frame);
|
||||
}
|
||||
|
||||
class IPCRenderer : public mate::Wrappable<IPCRenderer> {
|
||||
public:
|
||||
explicit IPCRenderer(v8::Isolate* isolate) {
|
||||
Init(isolate);
|
||||
RenderFrame* render_frame = GetCurrentRenderFrame();
|
||||
DCHECK(render_frame);
|
||||
render_frame->GetRemoteInterfaces()->GetInterface(
|
||||
mojo::MakeRequest(&electron_browser_ptr_));
|
||||
}
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "IPCRenderer"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("send", &IPCRenderer::Send)
|
||||
.SetMethod("sendSync", &IPCRenderer::SendSync)
|
||||
.SetMethod("sendTo", &IPCRenderer::SendTo)
|
||||
.SetMethod("sendToHost", &IPCRenderer::SendToHost);
|
||||
}
|
||||
static mate::Handle<IPCRenderer> Create(v8::Isolate* isolate) {
|
||||
return mate::CreateHandle(isolate, new IPCRenderer(isolate));
|
||||
}
|
||||
|
||||
void Send(mate::Arguments* args,
|
||||
bool internal,
|
||||
const std::string& channel,
|
||||
const base::ListValue& arguments) {
|
||||
electron_browser_ptr_->Message(internal, channel, arguments.Clone());
|
||||
}
|
||||
|
||||
void SendTo(mate::Arguments* args,
|
||||
bool internal,
|
||||
bool send_to_all,
|
||||
int32_t web_contents_id,
|
||||
const std::string& channel,
|
||||
const base::ListValue& arguments) {
|
||||
electron_browser_ptr_->MessageTo(internal, send_to_all, web_contents_id,
|
||||
channel, arguments.Clone());
|
||||
}
|
||||
|
||||
void SendToHost(mate::Arguments* args,
|
||||
const std::string& channel,
|
||||
const base::ListValue& arguments) {
|
||||
electron_browser_ptr_->MessageHost(channel, arguments.Clone());
|
||||
}
|
||||
|
||||
base::Value SendSync(mate::Arguments* args,
|
||||
bool internal,
|
||||
const std::string& channel,
|
||||
const base::ListValue& arguments) {
|
||||
std::string error;
|
||||
base::Value result;
|
||||
|
||||
// A task is posted to a separate thread to execute the request so that
|
||||
// this thread may block on a waitable event. It is safe to pass raw
|
||||
// pointers to |result| and |event| as this stack frame will survive until
|
||||
// the request is complete.
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner =
|
||||
base::CreateSingleThreadTaskRunnerWithTraits({});
|
||||
|
||||
base::WaitableEvent response_received_event;
|
||||
|
||||
// We unbind the interface from this thread to pass it over to the worker
|
||||
// thread temporarily. This requires that no callbacks be pending for this
|
||||
// interface.
|
||||
auto interface_info = electron_browser_ptr_.PassInterface();
|
||||
task_runner->PostTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(&IPCRenderer::SendMessageSyncOnWorkerThread,
|
||||
base::Unretained(this),
|
||||
base::Unretained(&interface_info),
|
||||
base::Unretained(&response_received_event),
|
||||
base::Unretained(&result), internal, channel,
|
||||
base::Unretained(&arguments), base::Unretained(&error)));
|
||||
response_received_event.Wait();
|
||||
electron_browser_ptr_.Bind(std::move(interface_info));
|
||||
if (!error.empty()) {
|
||||
args->ThrowError(error);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
void SendMessageSyncOnWorkerThread(
|
||||
atom::mojom::ElectronBrowserPtrInfo* interface_info,
|
||||
base::WaitableEvent* event,
|
||||
base::Value* result,
|
||||
bool internal,
|
||||
const std::string& channel,
|
||||
const base::ListValue* arguments,
|
||||
std::string* error) {
|
||||
atom::mojom::ElectronBrowserPtr browser_ptr(std::move(*interface_info));
|
||||
electron_browser_ptr_ = std::move(browser_ptr);
|
||||
|
||||
electron_browser_ptr_.set_connection_error_handler(
|
||||
base::BindOnce(&IPCRenderer::HandleMojoConnectionErrorOnWorkerThread,
|
||||
base::Unretained(&electron_browser_ptr_),
|
||||
base::Unretained(interface_info),
|
||||
base::Unretained(event), base::Unretained(error)));
|
||||
electron_browser_ptr_->MessageSync(
|
||||
internal, channel, arguments->Clone(),
|
||||
base::BindOnce(&IPCRenderer::ReturnSyncResponseToMainThread,
|
||||
base::Unretained(&electron_browser_ptr_),
|
||||
base::Unretained(interface_info),
|
||||
base::Unretained(event), base::Unretained(result)));
|
||||
}
|
||||
static void ReturnSyncResponseToMainThread(
|
||||
atom::mojom::ElectronBrowserPtr* ptr,
|
||||
atom::mojom::ElectronBrowserPtrInfo* interface_info,
|
||||
base::WaitableEvent* event,
|
||||
base::Value* result,
|
||||
base::Value response) {
|
||||
*result = std::move(response);
|
||||
*interface_info = ptr->PassInterface();
|
||||
event->Signal();
|
||||
}
|
||||
// If the other end of the message pipe disconnects, ensure we don't hang the
|
||||
// main thread forever.
|
||||
static void HandleMojoConnectionErrorOnWorkerThread(
|
||||
atom::mojom::ElectronBrowserPtr* ptr,
|
||||
atom::mojom::ElectronBrowserPtrInfo* interface_info,
|
||||
base::WaitableEvent* event,
|
||||
std::string* error) {
|
||||
LOG(INFO) << "Mojo connection interuppted, likely due to the Mojo receiver "
|
||||
"process crashing.";
|
||||
*error = "IPC connection fatally interrupted.";
|
||||
*interface_info = ptr->PassInterface();
|
||||
event->Signal();
|
||||
}
|
||||
|
||||
atom::mojom::ElectronBrowserPtr electron_browser_ptr_;
|
||||
};
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.Set("ipc", IPCRenderer::Create(context->GetIsolate()));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_renderer_ipc, Initialize)
|
||||
@@ -1,145 +0,0 @@
|
||||
// Copyright (c) 2019 Slack Technologies, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/renderer/api/context_bridge/render_frame_context_bridge_store.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "atom/common/api/object_life_monitor.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
namespace context_bridge {
|
||||
|
||||
namespace {
|
||||
|
||||
class CachedProxyLifeMonitor final : public ObjectLifeMonitor {
|
||||
public:
|
||||
static void BindTo(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> target,
|
||||
RenderFramePersistenceStore* store,
|
||||
WeakGlobalPairNode* node,
|
||||
int hash) {
|
||||
new CachedProxyLifeMonitor(isolate, target, store, node, hash);
|
||||
}
|
||||
|
||||
protected:
|
||||
CachedProxyLifeMonitor(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> target,
|
||||
RenderFramePersistenceStore* store,
|
||||
WeakGlobalPairNode* node,
|
||||
int hash)
|
||||
: ObjectLifeMonitor(isolate, target),
|
||||
store_(store),
|
||||
node_(node),
|
||||
hash_(hash) {}
|
||||
|
||||
void RunDestructor() override {
|
||||
if (node_->detached) {
|
||||
delete node_;
|
||||
}
|
||||
if (node_->prev) {
|
||||
node_->prev->next = node_->next;
|
||||
}
|
||||
if (node_->next) {
|
||||
node_->next->prev = node_->prev;
|
||||
}
|
||||
if (!node_->prev && !node_->next) {
|
||||
// Must be a single length linked list
|
||||
store_->proxy_map()->erase(hash_);
|
||||
}
|
||||
node_->detached = true;
|
||||
}
|
||||
|
||||
private:
|
||||
RenderFramePersistenceStore* store_;
|
||||
WeakGlobalPairNode* node_;
|
||||
int hash_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
WeakGlobalPairNode::WeakGlobalPairNode(WeakGlobalPair pair) {
|
||||
this->pair = std::move(pair);
|
||||
}
|
||||
|
||||
WeakGlobalPairNode::~WeakGlobalPairNode() {
|
||||
if (next) {
|
||||
delete next;
|
||||
}
|
||||
}
|
||||
|
||||
RenderFramePersistenceStore::RenderFramePersistenceStore(
|
||||
content::RenderFrame* render_frame)
|
||||
: content::RenderFrameObserver(render_frame) {}
|
||||
|
||||
RenderFramePersistenceStore::~RenderFramePersistenceStore() = default;
|
||||
|
||||
void RenderFramePersistenceStore::OnDestruct() {
|
||||
delete this;
|
||||
}
|
||||
|
||||
void RenderFramePersistenceStore::CacheProxiedObject(
|
||||
v8::Local<v8::Value> from,
|
||||
v8::Local<v8::Value> proxy_value) {
|
||||
if (from->IsObject() && !from->IsNullOrUndefined()) {
|
||||
auto obj = v8::Local<v8::Object>::Cast(from);
|
||||
int hash = obj->GetIdentityHash();
|
||||
auto global_from = v8::Global<v8::Value>(v8::Isolate::GetCurrent(), from);
|
||||
auto global_proxy =
|
||||
v8::Global<v8::Value>(v8::Isolate::GetCurrent(), proxy_value);
|
||||
// Do not retain
|
||||
global_from.SetWeak();
|
||||
global_proxy.SetWeak();
|
||||
auto iter = proxy_map_.find(hash);
|
||||
auto* node = new WeakGlobalPairNode(
|
||||
std::make_tuple(std::move(global_from), std::move(global_proxy)));
|
||||
CachedProxyLifeMonitor::BindTo(v8::Isolate::GetCurrent(), obj, this, node,
|
||||
hash);
|
||||
CachedProxyLifeMonitor::BindTo(v8::Isolate::GetCurrent(),
|
||||
v8::Local<v8::Object>::Cast(proxy_value),
|
||||
this, node, hash);
|
||||
if (iter == proxy_map_.end()) {
|
||||
proxy_map_.emplace(hash, node);
|
||||
} else {
|
||||
WeakGlobalPairNode* target = iter->second;
|
||||
while (target->next) {
|
||||
target = target->next;
|
||||
}
|
||||
target->next = node;
|
||||
node->prev = target;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
v8::MaybeLocal<v8::Value> RenderFramePersistenceStore::GetCachedProxiedObject(
|
||||
v8::Local<v8::Value> from) {
|
||||
if (!from->IsObject() || from->IsNullOrUndefined())
|
||||
return v8::MaybeLocal<v8::Value>();
|
||||
|
||||
auto obj = v8::Local<v8::Object>::Cast(from);
|
||||
int hash = obj->GetIdentityHash();
|
||||
auto iter = proxy_map_.find(hash);
|
||||
if (iter == proxy_map_.end())
|
||||
return v8::MaybeLocal<v8::Value>();
|
||||
WeakGlobalPairNode* target = iter->second;
|
||||
while (target) {
|
||||
auto from_cmp = std::get<0>(target->pair).Get(v8::Isolate::GetCurrent());
|
||||
if (from_cmp == from) {
|
||||
if (std::get<1>(target->pair).IsEmpty())
|
||||
return v8::MaybeLocal<v8::Value>();
|
||||
return std::get<1>(target->pair).Get(v8::Isolate::GetCurrent());
|
||||
}
|
||||
target = target->next;
|
||||
}
|
||||
return v8::MaybeLocal<v8::Value>();
|
||||
}
|
||||
|
||||
} // namespace context_bridge
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
@@ -1,71 +0,0 @@
|
||||
// Copyright (c) 2019 Slack Technologies, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_RENDERER_API_CONTEXT_BRIDGE_RENDER_FRAME_CONTEXT_BRIDGE_STORE_H_
|
||||
#define ATOM_RENDERER_API_CONTEXT_BRIDGE_RENDER_FRAME_CONTEXT_BRIDGE_STORE_H_
|
||||
|
||||
#include <map>
|
||||
#include <tuple>
|
||||
|
||||
#include "atom/renderer/atom_render_frame_observer.h"
|
||||
#include "content/public/renderer/render_frame.h"
|
||||
#include "content/public/renderer/render_frame_observer.h"
|
||||
#include "third_party/blink/public/web/web_local_frame.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
namespace context_bridge {
|
||||
|
||||
using FunctionContextPair =
|
||||
std::tuple<v8::Global<v8::Function>, v8::Global<v8::Context>>;
|
||||
|
||||
using WeakGlobalPair = std::tuple<v8::Global<v8::Value>, v8::Global<v8::Value>>;
|
||||
|
||||
struct WeakGlobalPairNode {
|
||||
explicit WeakGlobalPairNode(WeakGlobalPair pair_);
|
||||
~WeakGlobalPairNode();
|
||||
WeakGlobalPair pair;
|
||||
bool detached = false;
|
||||
struct WeakGlobalPairNode* prev = nullptr;
|
||||
struct WeakGlobalPairNode* next = nullptr;
|
||||
};
|
||||
|
||||
class RenderFramePersistenceStore final : public content::RenderFrameObserver {
|
||||
public:
|
||||
explicit RenderFramePersistenceStore(content::RenderFrame* render_frame);
|
||||
~RenderFramePersistenceStore() override;
|
||||
|
||||
// RenderFrameObserver implementation.
|
||||
void OnDestruct() override;
|
||||
|
||||
size_t take_func_id() { return next_func_id_++; }
|
||||
|
||||
std::map<size_t, FunctionContextPair>& functions() { return functions_; }
|
||||
std::map<int, WeakGlobalPairNode*>* proxy_map() { return &proxy_map_; }
|
||||
|
||||
void CacheProxiedObject(v8::Local<v8::Value> from,
|
||||
v8::Local<v8::Value> proxy_value);
|
||||
v8::MaybeLocal<v8::Value> GetCachedProxiedObject(v8::Local<v8::Value> from);
|
||||
|
||||
private:
|
||||
// func_id ==> { function, owning_context }
|
||||
std::map<size_t, FunctionContextPair> functions_;
|
||||
size_t next_func_id_ = 1;
|
||||
|
||||
// proxy maps are weak globals, i.e. these are not retained beyond
|
||||
// there normal JS lifetime. You must check IsEmpty()
|
||||
|
||||
// object_identity ==> [from_value, proxy_value]
|
||||
std::map<int, WeakGlobalPairNode*> proxy_map_;
|
||||
};
|
||||
|
||||
} // namespace context_bridge
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_RENDERER_API_CONTEXT_BRIDGE_RENDER_FRAME_CONTEXT_BRIDGE_STORE_H_
|
||||
@@ -1,34 +0,0 @@
|
||||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/renderer/preferences_manager.h"
|
||||
|
||||
#include "atom/common/api/api_messages.h"
|
||||
#include "content/public/renderer/render_thread.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
PreferencesManager::PreferencesManager() {
|
||||
content::RenderThread::Get()->AddObserver(this);
|
||||
}
|
||||
|
||||
PreferencesManager::~PreferencesManager() {}
|
||||
|
||||
bool PreferencesManager::OnControlMessageReceived(const IPC::Message& message) {
|
||||
bool handled = true;
|
||||
IPC_BEGIN_MESSAGE_MAP(PreferencesManager, message)
|
||||
IPC_MESSAGE_HANDLER(AtomMsg_UpdatePreferences, OnUpdatePreferences)
|
||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||
IPC_END_MESSAGE_MAP()
|
||||
return handled;
|
||||
}
|
||||
|
||||
void PreferencesManager::OnUpdatePreferences(
|
||||
const base::ListValue& preferences) {
|
||||
auto copy =
|
||||
base::ListValue::From(base::Value::ToUniquePtrValue(preferences.Clone()));
|
||||
preferences_.swap(copy);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
@@ -1,35 +0,0 @@
|
||||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_RENDERER_PREFERENCES_MANAGER_H_
|
||||
#define ATOM_RENDERER_PREFERENCES_MANAGER_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/values.h"
|
||||
#include "content/public/renderer/render_thread_observer.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class PreferencesManager : public content::RenderThreadObserver {
|
||||
public:
|
||||
PreferencesManager();
|
||||
~PreferencesManager() override;
|
||||
|
||||
const base::ListValue* preferences() const { return preferences_.get(); }
|
||||
|
||||
private:
|
||||
// content::RenderThreadObserver:
|
||||
bool OnControlMessageReceived(const IPC::Message& message) override;
|
||||
|
||||
void OnUpdatePreferences(const base::ListValue& preferences);
|
||||
|
||||
std::unique_ptr<base::ListValue> preferences_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(PreferencesManager);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_RENDERER_PREFERENCES_MANAGER_H_
|
||||
@@ -1,84 +0,0 @@
|
||||
steps:
|
||||
- task: CopyFiles@2
|
||||
displayName: 'Copy Files to: src\electron'
|
||||
inputs:
|
||||
TargetFolder: src\electron
|
||||
|
||||
- script: |
|
||||
cd src\electron
|
||||
node script/yarn.js install --frozen-lockfile
|
||||
displayName: 'Yarn install'
|
||||
|
||||
- powershell: |
|
||||
$localArtifactPath = "$pwd\dist.zip"
|
||||
$serverArtifactPath = "$env:APPVEYOR_URL/buildjobs/$env:APPVEYOR_JOB_ID/artifacts/dist.zip"
|
||||
Invoke-RestMethod -Method Get -Uri $serverArtifactPath -OutFile $localArtifactPath -Headers @{ "Authorization" = "Bearer $env:APPVEYOR_TOKEN" }
|
||||
& "${env:ProgramFiles(x86)}\7-Zip\7z.exe" x -osrc\out\Default -y $localArtifactPath
|
||||
displayName: 'Download and extract dist.zip for test'
|
||||
env:
|
||||
APPVEYOR_TOKEN: $(APPVEYOR_TOKEN)
|
||||
|
||||
- powershell: |
|
||||
$localArtifactPath = "$pwd\ffmpeg.zip"
|
||||
$serverArtifactPath = "$env:APPVEYOR_URL/buildjobs/$env:APPVEYOR_JOB_ID/artifacts/ffmpeg.zip"
|
||||
Invoke-RestMethod -Method Get -Uri $serverArtifactPath -OutFile $localArtifactPath -Headers @{ "Authorization" = "Bearer $env:APPVEYOR_TOKEN" }
|
||||
& "${env:ProgramFiles(x86)}\7-Zip\7z.exe" x -osrc\out\ffmpeg $localArtifactPath
|
||||
displayName: 'Download and extract ffmpeg.zip for test'
|
||||
env:
|
||||
APPVEYOR_TOKEN: $(APPVEYOR_TOKEN)
|
||||
|
||||
- powershell: |
|
||||
$localArtifactPath = "$pwd\src\node_headers.zip"
|
||||
$serverArtifactPath = "$env:APPVEYOR_URL/buildjobs/$env:APPVEYOR_JOB_ID/artifacts/node_headers.zip"
|
||||
Invoke-RestMethod -Method Get -Uri $serverArtifactPath -OutFile $localArtifactPath -Headers @{ "Authorization" = "Bearer $env:APPVEYOR_TOKEN" }
|
||||
cd src
|
||||
& "${env:ProgramFiles(x86)}\7-Zip\7z.exe" x -y node_headers.zip
|
||||
displayName: 'Download node headers for test'
|
||||
env:
|
||||
APPVEYOR_TOKEN: $(APPVEYOR_TOKEN)
|
||||
|
||||
- powershell: |
|
||||
$localArtifactPath = "$pwd\src\out\Default\electron.lib"
|
||||
$serverArtifactPath = "$env:APPVEYOR_URL/buildjobs/$env:APPVEYOR_JOB_ID/artifacts/electron.lib"
|
||||
Invoke-RestMethod -Method Get -Uri $serverArtifactPath -OutFile $localArtifactPath -Headers @{ "Authorization" = "Bearer $env:APPVEYOR_TOKEN" }
|
||||
displayName: 'Download electron.lib for test'
|
||||
env:
|
||||
APPVEYOR_TOKEN: $(APPVEYOR_TOKEN)
|
||||
|
||||
- powershell: |
|
||||
New-Item src\out\Default\gen\node_headers\Release -Type directory
|
||||
Copy-Item -path src\out\Default\electron.lib -destination src\out\Default\gen\node_headers\Release\node.lib
|
||||
displayName: 'Setup node headers'
|
||||
|
||||
- script: |
|
||||
cd src
|
||||
set npm_config_nodedir=%cd%\out\Default\gen\node_headers
|
||||
set npm_config_arch=arm64
|
||||
cd electron
|
||||
node script/yarn test -- --ci --enable-logging --verbose
|
||||
displayName: 'Run Electron tests'
|
||||
env:
|
||||
ELECTRON_OUT_DIR: Default
|
||||
IGNORE_YARN_INSTALL_ERROR: 1
|
||||
ELECTRON_TEST_RESULTS_DIR: junit
|
||||
MOCHA_MULTI_REPORTERS: 'mocha-junit-reporter, tap'
|
||||
MOCHA_REPORTER: mocha-multi-reporters
|
||||
|
||||
- task: PublishTestResults@2
|
||||
displayName: 'Publish Test Results'
|
||||
inputs:
|
||||
testResultsFiles: '*.xml'
|
||||
searchFolder: '$(System.DefaultWorkingDirectory)/src/junit/'
|
||||
condition: always()
|
||||
|
||||
- script: |
|
||||
cd src
|
||||
echo "Verifying non proprietary ffmpeg"
|
||||
python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg
|
||||
displayName: 'Verify ffmpeg'
|
||||
|
||||
- powershell: |
|
||||
Get-Process | Where Name –Like "electron*" | Stop-Process
|
||||
Get-Process | Where Name –Like "MicrosoftEdge*" | Stop-Process
|
||||
displayName: 'Kill processes left running from last test run'
|
||||
condition: always()
|
||||
@@ -3,7 +3,7 @@ use_jumbo_build = true
|
||||
root_extra_deps = [ "//electron" ]
|
||||
|
||||
# Registry of NMVs --> https://github.com/nodejs/node/blob/master/doc/abi_version_registry.json
|
||||
node_module_version = 73
|
||||
node_module_version = 75
|
||||
|
||||
v8_promise_internal_field_count = 1
|
||||
v8_typed_array_max_size_in_heap = 0
|
||||
@@ -20,3 +20,7 @@ enable_basic_printing = true
|
||||
angle_enable_vulkan_validation_layers = false
|
||||
|
||||
is_cfi = false
|
||||
|
||||
# TODO: Remove this and update CI to contain 10.14 SDK once
|
||||
# crbug.com/986701 is fixed.
|
||||
mac_sdk_min = "10.13"
|
||||
|
||||
@@ -4,3 +4,4 @@ is_component_ffmpeg = true
|
||||
is_official_build = true
|
||||
proprietary_codecs = false
|
||||
ffmpeg_branding = "Chromium"
|
||||
enable_dsyms = false
|
||||
|
||||
16
build/generate-template.py
Normal file
16
build/generate-template.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import json
|
||||
import sys
|
||||
from string import Template
|
||||
|
||||
inpath = sys.argv[1]
|
||||
outpath = sys.argv[2]
|
||||
argpaths = sys.argv[3:]
|
||||
|
||||
with open(inpath, 'r') as infile, open(outpath, 'w') as outfile:
|
||||
data = {}
|
||||
for argpath in argpaths:
|
||||
with open(argpath, 'r') as argfile:
|
||||
data.update(json.load(argfile))
|
||||
|
||||
s = Template(infile.read()).substitute(data)
|
||||
outfile.write(s)
|
||||
@@ -255,16 +255,10 @@ backwards_compatible_list="\
|
||||
libappindicator-dev
|
||||
libappindicator1
|
||||
libappindicator3-1:i386
|
||||
libdconf-dev
|
||||
libdconf-dev:i386
|
||||
libdconf1
|
||||
libdconf1:i386
|
||||
libexif-dev
|
||||
libexif12
|
||||
libexif12:i386
|
||||
libgbm-dev
|
||||
libgconf-2-4:i386
|
||||
libgconf2-dev
|
||||
libgl1-mesa-dev
|
||||
libgl1-mesa-glx:i386
|
||||
libgles2-mesa-dev
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
template("js_wrap") {
|
||||
assert(defined(invoker.inputs), "Need input JS script")
|
||||
assert(defined(invoker.outputs), "Need output JS script")
|
||||
|
||||
action(target_name) {
|
||||
forward_variables_from(invoker,
|
||||
[
|
||||
"deps",
|
||||
"public_deps",
|
||||
"sources",
|
||||
"inputs",
|
||||
"outputs",
|
||||
])
|
||||
|
||||
script = "//electron/build/js_wrap.py"
|
||||
args = [ "--in" ] + rebase_path(invoker.inputs) + [ "--out" ] +
|
||||
rebase_path(invoker.outputs)
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import sys
|
||||
|
||||
in_start = sys.argv.index("--in") + 1
|
||||
out_start = sys.argv.index("--out") + 1
|
||||
|
||||
in_bundles = sys.argv[in_start:out_start - 1]
|
||||
out_bundles = sys.argv[out_start:]
|
||||
|
||||
if len(in_bundles) != len(out_bundles):
|
||||
print("--out and --in must provide the same number of arguments")
|
||||
sys.exit(1)
|
||||
|
||||
for i in range(len(in_bundles)):
|
||||
in_bundle = in_bundles[i]
|
||||
out_path = out_bundles[i]
|
||||
with open(in_bundle, 'r') as f:
|
||||
lines = ["(function(){var exports={},module={exports};"] + f.readlines() + ["})();"]
|
||||
with open(out_path, 'w') as out_f:
|
||||
out_f.writelines(lines)
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -13,6 +14,6 @@ args = [cmd, "run",
|
||||
] + sys.argv[1:]
|
||||
try:
|
||||
subprocess.check_output(args, stderr=subprocess.STDOUT)
|
||||
except subprocess.CalledProcessError, e:
|
||||
except subprocess.CalledProcessError as e:
|
||||
print("NPM script '" + sys.argv[2] + "' failed with code '" + str(e.returncode) + "':\n" + e.output)
|
||||
sys.exit(e.returncode)
|
||||
|
||||
39
build/templated_file.gni
Normal file
39
build/templated_file.gni
Normal file
@@ -0,0 +1,39 @@
|
||||
template("templated_file") {
|
||||
assert(defined(invoker.template), "Need template file to run")
|
||||
assert(defined(invoker.output), "Need output file to run")
|
||||
|
||||
if (defined(invoker.values)) {
|
||||
args_path = "$target_gen_dir/$target_name.args"
|
||||
write_file(args_path, invoker.values, "json")
|
||||
}
|
||||
|
||||
action(target_name) {
|
||||
forward_variables_from(invoker,
|
||||
[
|
||||
"deps",
|
||||
"public_deps",
|
||||
"inputs",
|
||||
"outputs",
|
||||
])
|
||||
inputs = [
|
||||
invoker.template,
|
||||
]
|
||||
outputs = [
|
||||
invoker.output,
|
||||
]
|
||||
script = "//electron/build/generate-template.py"
|
||||
args = [
|
||||
rebase_path(invoker.template),
|
||||
rebase_path(invoker.output),
|
||||
]
|
||||
|
||||
if (defined(invoker.values)) {
|
||||
args += rebase_path(args_path)
|
||||
}
|
||||
|
||||
if (defined(invoker.args_files)) {
|
||||
args += rebase_path(invoker.args_files)
|
||||
inputs += invoker.args_files
|
||||
}
|
||||
}
|
||||
}
|
||||
23
build/templates/electron_version.tmpl
Normal file
23
build/templates/electron_version.tmpl
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) 2019 Slack Technologies, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ELECTRON_ELECTRON_VERSION_H
|
||||
#define ELECTRON_ELECTRON_VERSION_H
|
||||
|
||||
#define ELECTRON_MAJOR_VERSION $major
|
||||
#define ELECTRON_MINOR_VERSION $minor
|
||||
#define ELECTRON_PATCH_VERSION $patch
|
||||
#if $has_prerelease
|
||||
#define ELECTRON_PRE_RELEASE_VERSION -$prerelease
|
||||
#endif
|
||||
|
||||
#ifndef ELECTRON_PRE_RELEASE_VERSION
|
||||
#define ELECTRON_VERSION_STRING "$major.$minor.$patch"
|
||||
#else
|
||||
#define ELECTRON_VERSION_STRING "$major.$minor.$patch-$prerelease"
|
||||
#endif
|
||||
|
||||
#define ELECTRON_VERSION "v" ELECTRON_VERSION_STRING
|
||||
|
||||
#endif // ELECTRON_ELECTRON_VERSION_H
|
||||
@@ -24,7 +24,6 @@ template("typescript_build") {
|
||||
"//electron/yarn.lock",
|
||||
"//electron/typings/internal-ambient.d.ts",
|
||||
"//electron/typings/internal-electron.d.ts",
|
||||
"//electron/typings/internal-helpers.d.ts",
|
||||
]
|
||||
|
||||
type_roots = "node_modules/@types,typings"
|
||||
|
||||
2
build/webpack/get-outputs.js
Normal file
2
build/webpack/get-outputs.js
Normal file
@@ -0,0 +1,2 @@
|
||||
process.env.PRINT_WEBPACK_GRAPH = true
|
||||
require('./run-compiler')
|
||||
22
build/webpack/run-compiler.js
Normal file
22
build/webpack/run-compiler.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const path = require('path')
|
||||
const webpack = require('webpack')
|
||||
|
||||
const configPath = process.argv[2]
|
||||
const outPath = path.resolve(process.argv[3])
|
||||
const config = require(configPath)
|
||||
config.output = {
|
||||
path: path.dirname(outPath),
|
||||
filename: path.basename(outPath)
|
||||
}
|
||||
|
||||
webpack(config, (err, stats) => {
|
||||
if (err) {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
} else if (stats.hasErrors()) {
|
||||
console.error(stats.toString('normal'))
|
||||
process.exit(1)
|
||||
} else {
|
||||
process.exit(0)
|
||||
}
|
||||
})
|
||||
80
build/webpack/webpack.config.base.js
Normal file
80
build/webpack/webpack.config.base.js
Normal file
@@ -0,0 +1,80 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const webpack = require('webpack')
|
||||
|
||||
const electronRoot = path.resolve(__dirname, '../..')
|
||||
|
||||
const onlyPrintingGraph = !!process.env.PRINT_WEBPACK_GRAPH
|
||||
|
||||
class AccessDependenciesPlugin {
|
||||
apply(compiler) {
|
||||
// Only hook into webpack when we are printing the dependency graph
|
||||
if (!onlyPrintingGraph) return
|
||||
|
||||
compiler.hooks.compilation.tap('AccessDependenciesPlugin', compilation => {
|
||||
compilation.hooks.finishModules.tap('AccessDependenciesPlugin', modules => {
|
||||
const filePaths = modules.map(m => m.resource).filter(p => p).map(p => path.relative(electronRoot, p))
|
||||
console.info(JSON.stringify(filePaths))
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ({
|
||||
alwaysHasNode,
|
||||
loadElectronFromAlternateTarget,
|
||||
targetDeletesNodeGlobals,
|
||||
target
|
||||
}) => {
|
||||
let entry = path.resolve(electronRoot, 'lib', target, 'init.ts')
|
||||
if (!fs.existsSync(entry)) {
|
||||
entry = path.resolve(electronRoot, 'lib', target, 'init.js')
|
||||
}
|
||||
|
||||
return ({
|
||||
mode: 'development',
|
||||
devtool: 'inline-source-map',
|
||||
entry,
|
||||
target: alwaysHasNode ? 'node' : 'web',
|
||||
output: {
|
||||
filename: `${target}.bundle.js`
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@electron/internal': path.resolve(electronRoot, 'lib'),
|
||||
'electron': path.resolve(electronRoot, 'lib', loadElectronFromAlternateTarget || target, 'api', 'exports', 'electron.js'),
|
||||
// Force timers to resolve to our dependency that doens't use window.postMessage
|
||||
'timers': path.resolve(electronRoot, 'node_modules', 'timers-browserify', 'main.js')
|
||||
},
|
||||
extensions: ['.ts', '.js']
|
||||
},
|
||||
module: {
|
||||
rules: [{
|
||||
test: /\.ts$/,
|
||||
loader: 'ts-loader',
|
||||
options: {
|
||||
configFile: path.resolve(electronRoot, 'tsconfig.electron.json'),
|
||||
transpileOnly: onlyPrintingGraph,
|
||||
ignoreDiagnostics: [6059]
|
||||
}
|
||||
}]
|
||||
},
|
||||
node: {
|
||||
__dirname: false,
|
||||
__filename: false,
|
||||
// We provide our own "timers" import above, any usage of setImmediate inside
|
||||
// one of our renderer bundles should import it from the 'timers' package
|
||||
setImmediate: false,
|
||||
},
|
||||
plugins: [
|
||||
new AccessDependenciesPlugin(),
|
||||
...(targetDeletesNodeGlobals ? [
|
||||
new webpack.ProvidePlugin({
|
||||
process: ['@electron/internal/renderer/webpack-provider', 'process'],
|
||||
global: ['@electron/internal/renderer/webpack-provider', '_global'],
|
||||
Buffer: ['@electron/internal/renderer/webpack-provider', 'Buffer'],
|
||||
})
|
||||
] : [])
|
||||
]
|
||||
})
|
||||
}
|
||||
4
build/webpack/webpack.config.browser.js
Normal file
4
build/webpack/webpack.config.browser.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = require('./webpack.config.base')({
|
||||
target: 'browser',
|
||||
alwaysHasNode: true
|
||||
})
|
||||
4
build/webpack/webpack.config.content_script.js
Normal file
4
build/webpack/webpack.config.content_script.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = require('./webpack.config.base')({
|
||||
target: 'content_script',
|
||||
alwaysHasNode: false
|
||||
})
|
||||
4
build/webpack/webpack.config.isolated_renderer.js
Normal file
4
build/webpack/webpack.config.isolated_renderer.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = require('./webpack.config.base')({
|
||||
target: 'isolated_renderer',
|
||||
alwaysHasNode: false
|
||||
})
|
||||
5
build/webpack/webpack.config.renderer.js
Normal file
5
build/webpack/webpack.config.renderer.js
Normal file
@@ -0,0 +1,5 @@
|
||||
module.exports = require('./webpack.config.base')({
|
||||
target: 'renderer',
|
||||
alwaysHasNode: true,
|
||||
targetDeletesNodeGlobals: true
|
||||
})
|
||||
4
build/webpack/webpack.config.sandboxed_renderer.js
Normal file
4
build/webpack/webpack.config.sandboxed_renderer.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = require('./webpack.config.base')({
|
||||
target: 'sandboxed_renderer',
|
||||
alwaysHasNode: false
|
||||
})
|
||||
6
build/webpack/webpack.config.worker.js
Normal file
6
build/webpack/webpack.config.worker.js
Normal file
@@ -0,0 +1,6 @@
|
||||
module.exports = require('./webpack.config.base')({
|
||||
target: 'worker',
|
||||
loadElectronFromAlternateTarget: 'renderer',
|
||||
alwaysHasNode: true,
|
||||
targetDeletesNodeGlobals: true
|
||||
})
|
||||
34
build/webpack/webpack.gni
Normal file
34
build/webpack/webpack.gni
Normal file
@@ -0,0 +1,34 @@
|
||||
import("../npm.gni")
|
||||
|
||||
template("webpack_build") {
|
||||
assert(defined(invoker.config_file), "Need webpack config file to run")
|
||||
assert(defined(invoker.out_file), "Need output file to run")
|
||||
assert(defined(invoker.inputs), "Need webpack inputs to run")
|
||||
|
||||
npm_action(target_name) {
|
||||
forward_variables_from(invoker,
|
||||
[
|
||||
"deps",
|
||||
"public_deps",
|
||||
])
|
||||
script = "webpack"
|
||||
|
||||
inputs = [
|
||||
invoker.config_file,
|
||||
"//electron/build/webpack/webpack.config.base.js",
|
||||
"//electron/tsconfig.json",
|
||||
"//electron/yarn.lock",
|
||||
"//electron/typings/internal-ambient.d.ts",
|
||||
"//electron/typings/internal-electron.d.ts",
|
||||
] + invoker.inputs
|
||||
|
||||
args = [
|
||||
rebase_path(invoker.config_file),
|
||||
rebase_path(invoker.out_file),
|
||||
]
|
||||
|
||||
outputs = [
|
||||
invoker.out_file,
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -41,7 +42,7 @@ def execute(argv):
|
||||
output = subprocess.check_output(argv, stderr=subprocess.STDOUT)
|
||||
return output
|
||||
except subprocess.CalledProcessError as e:
|
||||
print e.output
|
||||
print(e.output)
|
||||
raise e
|
||||
|
||||
def main(argv):
|
||||
@@ -54,7 +55,7 @@ def main(argv):
|
||||
if sys.platform == 'darwin':
|
||||
execute(['zip', '-r', '-y', dist_zip] + list(dist_files))
|
||||
else:
|
||||
with zipfile.ZipFile(dist_zip, 'w', zipfile.ZIP_DEFLATED, True) as z:
|
||||
with zipfile.ZipFile(dist_zip, 'w', zipfile.ZIP_DEFLATED, allowZip64=True) as z:
|
||||
for dep in dist_files:
|
||||
if skip_path(dep, dist_zip, target_cpu):
|
||||
continue
|
||||
|
||||
@@ -17,7 +17,7 @@ buildflag_header("buildflags") {
|
||||
"ENABLE_PDF_VIEWER=$enable_pdf_viewer",
|
||||
"ENABLE_TTS=$enable_tts",
|
||||
"ENABLE_COLOR_CHOOSER=$enable_color_chooser",
|
||||
"ENABLE_MEDIA_KEY_OVERRIDES=$enable_media_key_overrides",
|
||||
"ENABLE_ELECTRON_EXTENSIONS=$enable_electron_extensions",
|
||||
"OVERRIDE_LOCATION_PROVIDER=$enable_fake_location_provider",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ declare_args() {
|
||||
|
||||
enable_color_chooser = true
|
||||
|
||||
enable_media_key_overrides = true
|
||||
|
||||
# Provide a fake location provider for mocking
|
||||
# the geolocation responses. Disable it if you
|
||||
# need to test with chromium's location provider.
|
||||
@@ -28,4 +26,7 @@ declare_args() {
|
||||
|
||||
# Enable flash plugin support.
|
||||
enable_pepper_flash = true
|
||||
|
||||
# Enable Chrome extensions support.
|
||||
enable_electron_extensions = false
|
||||
}
|
||||
|
||||
@@ -102,6 +102,10 @@ static_library("chrome") {
|
||||
"//chrome/browser/ui/cocoa/color_chooser_mac.h",
|
||||
"//chrome/browser/ui/cocoa/color_chooser_mac.mm",
|
||||
]
|
||||
deps += [
|
||||
"//components/remote_cocoa/app_shim",
|
||||
"//components/remote_cocoa/browser",
|
||||
]
|
||||
}
|
||||
|
||||
if (is_win) {
|
||||
@@ -161,7 +165,7 @@ static_library("chrome") {
|
||||
"//components/printing/browser",
|
||||
"//components/printing/renderer",
|
||||
"//components/services/pdf_compositor/public/cpp:factory",
|
||||
"//components/services/pdf_compositor/public/interfaces",
|
||||
"//components/services/pdf_compositor/public/mojom",
|
||||
]
|
||||
deps += [
|
||||
"//components/printing/common",
|
||||
|
||||
@@ -28,7 +28,7 @@ net::NSSCertDatabase* g_nss_cert_database = nullptr;
|
||||
|
||||
net::NSSCertDatabase* GetNSSCertDatabaseForResourceContext(
|
||||
content::ResourceContext* context,
|
||||
const base::Callback<void(net::NSSCertDatabase*)>& callback) {
|
||||
base::OnceCallback<void(net::NSSCertDatabase*)> callback) {
|
||||
// This initialization is not thread safe. This CHECK ensures that this code
|
||||
// is only run on a single thread.
|
||||
CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
|
||||
@@ -75,8 +75,8 @@ void CertificateManagerModel::Create(content::BrowserContext* browser_context,
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::Bind(&CertificateManagerModel::GetCertDBOnIOThread,
|
||||
browser_context->GetResourceContext(), callback));
|
||||
base::BindOnce(&CertificateManagerModel::GetCertDBOnIOThread,
|
||||
browser_context->GetResourceContext(), callback));
|
||||
}
|
||||
|
||||
CertificateManagerModel::CertificateManagerModel(
|
||||
@@ -148,8 +148,8 @@ void CertificateManagerModel::DidGetCertDBOnIOThread(
|
||||
bool is_user_db_available = !!cert_db->GetPublicSlot();
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::UI},
|
||||
base::Bind(&CertificateManagerModel::DidGetCertDBOnUIThread, cert_db,
|
||||
is_user_db_available, callback));
|
||||
base::BindOnce(&CertificateManagerModel::DidGetCertDBOnUIThread, cert_db,
|
||||
is_user_db_available, callback));
|
||||
}
|
||||
|
||||
// static
|
||||
@@ -158,8 +158,8 @@ void CertificateManagerModel::GetCertDBOnIOThread(
|
||||
const CreationCallback& callback) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||
net::NSSCertDatabase* cert_db = GetNSSCertDatabaseForResourceContext(
|
||||
context,
|
||||
base::Bind(&CertificateManagerModel::DidGetCertDBOnIOThread, callback));
|
||||
context, base::BindOnce(&CertificateManagerModel::DidGetCertDBOnIOThread,
|
||||
callback));
|
||||
if (cert_db)
|
||||
DidGetCertDBOnIOThread(callback, cert_db);
|
||||
}
|
||||
|
||||
@@ -58,9 +58,9 @@ class ProcessSingleton {
|
||||
// Chrome process was launched. Return true if the command line will be
|
||||
// handled within the current browser instance or false if the remote process
|
||||
// should handle it (i.e., because the current process is shutting down).
|
||||
using NotificationCallback =
|
||||
base::Callback<bool(const base::CommandLine::StringVector& command_line,
|
||||
const base::FilePath& current_directory)>;
|
||||
using NotificationCallback = base::RepeatingCallback<bool(
|
||||
const base::CommandLine::StringVector& command_line,
|
||||
const base::FilePath& current_directory)>;
|
||||
|
||||
ProcessSingleton(const base::FilePath& user_data_dir,
|
||||
const NotificationCallback& notification_callback);
|
||||
@@ -94,7 +94,7 @@ class ProcessSingleton {
|
||||
#if defined(OS_WIN)
|
||||
// Called to query whether to kill a hung browser process that has visible
|
||||
// windows. Return true to allow killing the hung process.
|
||||
using ShouldKillRemoteProcessCallback = base::Callback<bool()>;
|
||||
using ShouldKillRemoteProcessCallback = base::RepeatingCallback<bool()>;
|
||||
void OverrideShouldKillRemoteProcessCallbackForTesting(
|
||||
const ShouldKillRemoteProcessCallback& display_dialog_callback);
|
||||
#endif
|
||||
@@ -120,7 +120,7 @@ class ProcessSingleton {
|
||||
const base::TimeDelta& timeout);
|
||||
void OverrideCurrentPidForTesting(base::ProcessId pid);
|
||||
void OverrideKillCallbackForTesting(
|
||||
const base::Callback<void(int)>& callback);
|
||||
const base::RepeatingCallback<void(int)>& callback);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
@@ -55,8 +55,8 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/common/atom_command_line.h"
|
||||
#include "shell/browser/browser.h"
|
||||
#include "shell/common/atom_command_line.h"
|
||||
|
||||
#include "base/base_paths.h"
|
||||
#include "base/bind.h"
|
||||
@@ -482,8 +482,8 @@ class ProcessSingleton::LinuxWatcher
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||
// Wait for reads.
|
||||
fd_watch_controller_ = base::FileDescriptorWatcher::WatchReadable(
|
||||
fd, base::Bind(&SocketReader::OnSocketCanReadWithoutBlocking,
|
||||
base::Unretained(this)));
|
||||
fd, base::BindRepeating(&SocketReader::OnSocketCanReadWithoutBlocking,
|
||||
base::Unretained(this)));
|
||||
// If we haven't completed in a reasonable amount of time, give up.
|
||||
timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kTimeoutInSeconds),
|
||||
this, &SocketReader::CleanupAndDeleteSelf);
|
||||
@@ -592,8 +592,8 @@ void ProcessSingleton::LinuxWatcher::StartListening(int socket) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||
// Watch for client connections on this socket.
|
||||
socket_watcher_ = base::FileDescriptorWatcher::WatchReadable(
|
||||
socket, base::Bind(&LinuxWatcher::OnSocketCanReadWithoutBlocking,
|
||||
base::Unretained(this), socket));
|
||||
socket, base::BindRepeating(&LinuxWatcher::OnSocketCanReadWithoutBlocking,
|
||||
base::Unretained(this), socket));
|
||||
}
|
||||
|
||||
void ProcessSingleton::LinuxWatcher::HandleMessage(
|
||||
@@ -686,8 +686,8 @@ void ProcessSingleton::LinuxWatcher::SocketReader::
|
||||
|
||||
// Return to the UI thread to handle opening a new browser tab.
|
||||
ui_task_runner_->PostTask(
|
||||
FROM_HERE, base::Bind(&ProcessSingleton::LinuxWatcher::HandleMessage,
|
||||
parent_, current_dir, tokens, this));
|
||||
FROM_HERE, base::BindOnce(&ProcessSingleton::LinuxWatcher::HandleMessage,
|
||||
parent_, current_dir, tokens, this));
|
||||
fd_watch_controller_.reset();
|
||||
|
||||
// LinuxWatcher::HandleMessage() is in charge of destroying this SocketReader
|
||||
@@ -707,8 +707,8 @@ void ProcessSingleton::LinuxWatcher::SocketReader::FinishWithACK(
|
||||
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::Bind(&ProcessSingleton::LinuxWatcher::RemoveSocketReader, parent_,
|
||||
this));
|
||||
base::BindOnce(&ProcessSingleton::LinuxWatcher::RemoveSocketReader,
|
||||
parent_, this));
|
||||
// We will be deleted once the posted RemoveSocketReader task runs.
|
||||
}
|
||||
|
||||
@@ -728,8 +728,8 @@ ProcessSingleton::ProcessSingleton(
|
||||
lock_path_ = user_data_dir.Append(kSingletonLockFilename);
|
||||
cookie_path_ = user_data_dir.Append(kSingletonCookieFilename);
|
||||
|
||||
kill_callback_ =
|
||||
base::Bind(&ProcessSingleton::KillProcess, base::Unretained(this));
|
||||
kill_callback_ = base::BindRepeating(&ProcessSingleton::KillProcess,
|
||||
base::Unretained(this));
|
||||
}
|
||||
|
||||
ProcessSingleton::~ProcessSingleton() {
|
||||
@@ -827,7 +827,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout(
|
||||
return PROCESS_NONE;
|
||||
to_send.append(current_dir.value());
|
||||
|
||||
const std::vector<std::string>& argv = atom::AtomCommandLine::argv();
|
||||
const std::vector<std::string>& argv = electron::AtomCommandLine::argv();
|
||||
for (std::vector<std::string>::const_iterator it = argv.begin();
|
||||
it != argv.end(); ++it) {
|
||||
to_send.push_back(kTokenDelimiter);
|
||||
@@ -887,8 +887,8 @@ void ProcessSingleton::StartListeningOnSocket() {
|
||||
watcher_ = new LinuxWatcher(this);
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::Bind(&ProcessSingleton::LinuxWatcher::StartListening, watcher_,
|
||||
sock_));
|
||||
base::BindOnce(&ProcessSingleton::LinuxWatcher::StartListening, watcher_,
|
||||
sock_));
|
||||
}
|
||||
|
||||
void ProcessSingleton::OnBrowserReady() {
|
||||
@@ -950,7 +950,7 @@ void ProcessSingleton::OverrideCurrentPidForTesting(base::ProcessId pid) {
|
||||
}
|
||||
|
||||
void ProcessSingleton::OverrideKillCallbackForTesting(
|
||||
const base::Callback<void(int)>& callback) {
|
||||
const base::RepeatingCallback<void(int)>& callback) {
|
||||
kill_callback_ = callback;
|
||||
}
|
||||
|
||||
|
||||
@@ -176,7 +176,8 @@ ProcessSingleton::ProcessSingleton(
|
||||
is_virtualized_(false),
|
||||
lock_file_(INVALID_HANDLE_VALUE),
|
||||
user_data_dir_(user_data_dir),
|
||||
should_kill_remote_process_callback_(base::Bind(&TerminateAppWithError)) {
|
||||
should_kill_remote_process_callback_(
|
||||
base::BindRepeating(&TerminateAppWithError)) {
|
||||
// The user_data_dir may have not been created yet.
|
||||
base::CreateDirectoryAndGetError(user_data_dir, nullptr);
|
||||
}
|
||||
@@ -290,9 +291,10 @@ bool ProcessSingleton::Create() {
|
||||
if (lock_file_ != INVALID_HANDLE_VALUE) {
|
||||
// Set the window's title to the path of our user data directory so
|
||||
// other Chrome instances can decide if they should forward to us.
|
||||
bool result = window_.CreateNamed(
|
||||
base::Bind(&ProcessLaunchNotification, notification_callback_),
|
||||
user_data_dir_.value());
|
||||
bool result =
|
||||
window_.CreateNamed(base::BindRepeating(&ProcessLaunchNotification,
|
||||
notification_callback_),
|
||||
user_data_dir_.value());
|
||||
|
||||
// NB: Ensure that if the primary app gets started as elevated
|
||||
// admin inadvertently, secondary windows running not as elevated
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
#include "chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.h"
|
||||
|
||||
#include "atom/browser/ui/views/global_menu_bar_x11.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/debug/leak_annotations.h"
|
||||
#include "base/logging.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "shell/browser/ui/views/global_menu_bar_x11.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
@@ -65,7 +65,7 @@ GlobalMenuBarRegistrarX11::~GlobalMenuBarRegistrarX11() {
|
||||
|
||||
void GlobalMenuBarRegistrarX11::RegisterXID(unsigned long xid) {
|
||||
DCHECK(registrar_proxy_);
|
||||
std::string path = atom::GlobalMenuBarX11::GetPathForWindow(xid);
|
||||
std::string path = electron::GlobalMenuBarX11::GetPathForWindow(xid);
|
||||
|
||||
ANNOTATE_SCOPED_MEMORY_LEAK; // http://crbug.com/314087
|
||||
// TODO(erg): The mozilla implementation goes to a lot of callback trouble
|
||||
@@ -82,7 +82,7 @@ void GlobalMenuBarRegistrarX11::RegisterXID(unsigned long xid) {
|
||||
|
||||
void GlobalMenuBarRegistrarX11::UnregisterXID(unsigned long xid) {
|
||||
DCHECK(registrar_proxy_);
|
||||
std::string path = atom::GlobalMenuBarX11::GetPathForWindow(xid);
|
||||
std::string path = electron::GlobalMenuBarX11::GetPathForWindow(xid);
|
||||
|
||||
ANNOTATE_SCOPED_MEMORY_LEAK; // http://crbug.com/314087
|
||||
// TODO(erg): The mozilla implementation goes to a lot of callback trouble
|
||||
|
||||
@@ -37,12 +37,8 @@ function isTrustedSender (webContents: Electron.WebContents) {
|
||||
return parsedUrl.protocol === 'file:' && urlPath === indexPath
|
||||
}
|
||||
|
||||
ipcMain.on('bootstrap', (event) => {
|
||||
try {
|
||||
event.returnValue = isTrustedSender(event.sender) ? electronPath : null
|
||||
} catch {
|
||||
event.returnValue = null
|
||||
}
|
||||
ipcMain.handle('bootstrap', (event) => {
|
||||
return isTrustedSender(event.sender) ? electronPath : null
|
||||
})
|
||||
|
||||
async function createWindow () {
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
<head>
|
||||
<title>Electron</title>
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'sha256-6PH54BfkNq/EMMhUY7nhHf3c+AxloOwfy7hWyT01CM8='; style-src 'self'; img-src 'self'; connect-src 'self'" />
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self'; connect-src 'self'" />
|
||||
<link href="./styles.css" type="text/css" rel="stylesheet" />
|
||||
<link href="./octicon/build.css" type="text/css" rel="stylesheet" />
|
||||
<script defer src="./index.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -83,9 +84,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<script>
|
||||
window.electronDefaultApp.initialize()
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
30
default_app/index.ts
Normal file
30
default_app/index.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
async function getOcticonSvg (name: string) {
|
||||
try {
|
||||
const response = await fetch(`octicon/${name}.svg`)
|
||||
const div = document.createElement('div')
|
||||
div.innerHTML = await response.text()
|
||||
return div
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
async function loadSVG (element: HTMLSpanElement) {
|
||||
for (const cssClass of element.classList) {
|
||||
if (cssClass.startsWith('octicon-')) {
|
||||
const icon = await getOcticonSvg(cssClass.substr(8))
|
||||
if (icon) {
|
||||
for (const elemClass of element.classList) {
|
||||
icon.classList.add(elemClass)
|
||||
}
|
||||
element.before(icon)
|
||||
element.remove()
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const element of document.querySelectorAll<HTMLSpanElement>('.octicon')) {
|
||||
loadSVG(element)
|
||||
}
|
||||
@@ -99,9 +99,9 @@ function loadApplicationPackage (packagePath: string) {
|
||||
app.setVersion(packageJson.version)
|
||||
}
|
||||
if (packageJson.productName) {
|
||||
app.setName(packageJson.productName)
|
||||
app.name = packageJson.productName
|
||||
} else if (packageJson.name) {
|
||||
app.setName(packageJson.name)
|
||||
app.name = packageJson.name
|
||||
}
|
||||
appPath = packagePath
|
||||
}
|
||||
|
||||
@@ -1,34 +1,7 @@
|
||||
import { ipcRenderer, contextBridge } from 'electron'
|
||||
import { ipcRenderer } from 'electron'
|
||||
|
||||
async function getOcticonSvg (name: string) {
|
||||
try {
|
||||
const response = await fetch(`octicon/${name}.svg`)
|
||||
const div = document.createElement('div')
|
||||
div.innerHTML = await response.text()
|
||||
return div
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
async function loadSVG (element: HTMLSpanElement) {
|
||||
for (const cssClass of element.classList) {
|
||||
if (cssClass.startsWith('octicon-')) {
|
||||
const icon = await getOcticonSvg(cssClass.substr(8))
|
||||
if (icon) {
|
||||
for (const elemClass of element.classList) {
|
||||
icon.classList.add(elemClass)
|
||||
}
|
||||
element.before(icon)
|
||||
element.remove()
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function initialize () {
|
||||
const electronPath = ipcRenderer.sendSync('bootstrap')
|
||||
async function initialize () {
|
||||
const electronPath = await ipcRenderer.invoke('bootstrap')
|
||||
|
||||
function replaceText (selector: string, text: string) {
|
||||
const element = document.querySelector<HTMLElement>(selector)
|
||||
@@ -42,12 +15,6 @@ function initialize () {
|
||||
replaceText('.node-version', `Node v${process.versions.node}`)
|
||||
replaceText('.v8-version', `v8 v${process.versions.v8}`)
|
||||
replaceText('.command-example', `${electronPath} path-to-app`)
|
||||
|
||||
for (const element of document.querySelectorAll<HTMLSpanElement>('.octicon')) {
|
||||
loadSVG(element)
|
||||
}
|
||||
}
|
||||
|
||||
contextBridge.exposeInMainWorld('electronDefaultApp', {
|
||||
initialize
|
||||
})
|
||||
document.addEventListener('DOMContentLoaded', initialize)
|
||||
|
||||
@@ -18,6 +18,7 @@ an issue:
|
||||
|
||||
## Guides and Tutorials
|
||||
|
||||
* [About Electron](tutorial/about.md)
|
||||
* [Setting up the Development Environment](tutorial/development-environment.md)
|
||||
* [Setting up macOS](tutorial/development-environment.md#setting-up-macos)
|
||||
* [Setting up Windows](tutorial/development-environment.md#setting-up-windows)
|
||||
@@ -40,7 +41,7 @@ an issue:
|
||||
* [Using Native Node.js Modules](tutorial/using-native-node-modules.md)
|
||||
* Adding Features to Your App
|
||||
* [Notifications](tutorial/notifications.md)
|
||||
* [Recent Documents](tutorial/desktop-environment-integration.md#recent-documents)
|
||||
* [Recent Documents](tutorial/recent-documents.md)
|
||||
* [Application Progress](tutorial/progress-bar.md)
|
||||
* [Custom Dock Menu](tutorial/macos-dock.md)
|
||||
* [Custom Windows Taskbar](tutorial/windows-taskbar.md)
|
||||
@@ -49,20 +50,22 @@ an issue:
|
||||
* [Offline/Online Detection](tutorial/online-offline-events.md)
|
||||
* [Represented File for macOS BrowserWindows](tutorial/represented-file.md)
|
||||
* [Native File Drag & Drop](tutorial/native-file-drag-drop.md)
|
||||
* [Offscreen Rendering](tutorial/offscreen-rendering.md)
|
||||
* [Supporting macOS Dark Mode](tutorial/mojave-dark-mode-guide.md)
|
||||
* [Accessibility](tutorial/accessibility.md)
|
||||
* [Spectron](tutorial/accessibility.md#spectron)
|
||||
* [Devtron](tutorial/accessibility.md#devtron)
|
||||
* [Enabling Accessibility](tutorial/accessibility.md#enabling-accessibility)
|
||||
* [Testing and Debugging](tutorial/application-debugging.md)
|
||||
* [Debugging the Main Process](tutorial/debugging-main-process.md)
|
||||
* [Debugging the Main Process with Visual Studio Code](tutorial/debugging-main-process-vscode.md)
|
||||
* [Using Selenium and WebDriver](tutorial/using-selenium-and-webdriver.md)
|
||||
* [Testing on Headless CI Systems (Travis, Jenkins)](tutorial/testing-on-headless-ci.md)
|
||||
* [DevTools Extension](tutorial/devtools-extension.md)
|
||||
* [Automated Testing with a Custom Driver](tutorial/automated-testing-with-a-custom-driver.md)
|
||||
* Packaging
|
||||
* [Code Signing](tutorial/code-signing.md)
|
||||
* [Distribution](tutorial/application-distribution.md)
|
||||
* [Support](tutorial/support.md)
|
||||
* [Supported Platforms](tutorial/support.md#supported-platforms)
|
||||
* [Code Signing](tutorial/code-signing.md)
|
||||
* [Mac App Store](tutorial/mac-app-store-submission-guide.md)
|
||||
* [Windows Store](tutorial/windows-store-guide.md)
|
||||
* [Snapcraft](tutorial/snapcraft.md)
|
||||
@@ -75,27 +78,27 @@ an issue:
|
||||
* [Deploying an Update Server](tutorial/updates.md#deploying-an-update-server)
|
||||
* [Implementing Updates in Your App](tutorial/updates.md#implementing-updates-in-your-app)
|
||||
* [Applying Updates](tutorial/updates.md#applying-updates)
|
||||
* [Getting Support](tutorial/support.md)
|
||||
|
||||
## Detailed Tutorials
|
||||
|
||||
These individual tutorials expand on topics discussed in the guide above.
|
||||
|
||||
* [In Detail: Installing Electron](tutorial/installation.md)
|
||||
* [Installing Electron](tutorial/installation.md)
|
||||
* [Proxies](tutorial/installation.md#proxies)
|
||||
* [Custom Mirrors and Caches](tutorial/installation.md#custom-mirrors-and-caches)
|
||||
* [Troubleshooting](tutorial/installation.md#troubleshooting)
|
||||
* [In Detail: Electron's Versioning Scheme](tutorial/electron-versioning.md)
|
||||
* [semver](tutorial/electron-versioning.md#semver)
|
||||
* [Stabilization Branches](tutorial/electron-versioning.md#stabilization-branches)
|
||||
* [Beta Releases and Bug Fixes](tutorial/electron-versioning.md#beta-releases-and-bug-fixes)
|
||||
* [In Detail: Packaging App Source Code with asar](tutorial/application-packaging.md)
|
||||
* Electron Releases & Developer Feedback
|
||||
* [Versioning Policy](tutorial/electron-versioning.md)
|
||||
* [Release Timelines](tutorial/electron-timelines.md)
|
||||
* [App Feedback Program](tutorial/app-feedback-program.md)
|
||||
* [Packaging App Source Code with asar](tutorial/application-packaging.md)
|
||||
* [Generating asar Archives](tutorial/application-packaging.md#generating-asar-archives)
|
||||
* [Using asar Archives](tutorial/application-packaging.md#using-asar-archives)
|
||||
* [Limitations](tutorial/application-packaging.md#limitations-of-the-node-api)
|
||||
* [Adding Unpacked Files to asar Archives](tutorial/application-packaging.md#adding-unpacked-files-to-asar-archives)
|
||||
* [In Detail: Testing Widevine CDM](tutorial/testing-widevine-cdm.md)
|
||||
* [In Detail: Using Pepper Flash Plugin](tutorial/using-pepper-flash-plugin.md)
|
||||
* [Offscreen Rendering](tutorial/offscreen-rendering.md)
|
||||
* [Testing Widevine CDM](tutorial/testing-widevine-cdm.md)
|
||||
* [Using Pepper Flash Plugin](tutorial/using-pepper-flash-plugin.md)
|
||||
|
||||
---
|
||||
|
||||
@@ -114,6 +117,7 @@ These individual tutorials expand on topics discussed in the guide above.
|
||||
* [`File` Object](api/file-object.md)
|
||||
* [`<webview>` Tag](api/webview-tag.md)
|
||||
* [`window.open` Function](api/window-open.md)
|
||||
* [`BrowserWindowProxy` Object](api/browser-window-proxy.md)
|
||||
|
||||
### Modules for the Main Process:
|
||||
|
||||
@@ -133,8 +137,10 @@ These individual tutorials expand on topics discussed in the guide above.
|
||||
* [powerMonitor](api/power-monitor.md)
|
||||
* [powerSaveBlocker](api/power-save-blocker.md)
|
||||
* [protocol](api/protocol.md)
|
||||
* [screen](api/screen.md)
|
||||
* [session](api/session.md)
|
||||
* [systemPreferences](api/system-preferences.md)
|
||||
* [TouchBar](api/touch-bar.md)
|
||||
* [Tray](api/tray.md)
|
||||
* [webContents](api/web-contents.md)
|
||||
|
||||
@@ -150,7 +156,6 @@ These individual tutorials expand on topics discussed in the guide above.
|
||||
* [clipboard](api/clipboard.md)
|
||||
* [crashReporter](api/crash-reporter.md)
|
||||
* [nativeImage](api/native-image.md)
|
||||
* [screen](api/screen.md)
|
||||
* [shell](api/shell.md)
|
||||
|
||||
## Development
|
||||
|
||||
326
docs/api/app.md
326
docs/api/app.md
@@ -32,7 +32,7 @@ In most cases, you should do everything in the `ready` event handler.
|
||||
|
||||
Returns:
|
||||
|
||||
* `launchInfo` Object _macOS_
|
||||
* `launchInfo` unknown _macOS_
|
||||
|
||||
Emitted when Electron has finished initializing. On macOS, `launchInfo` holds
|
||||
the `userInfo` of the `NSUserNotification` that was used to open the application,
|
||||
@@ -122,7 +122,7 @@ Returns:
|
||||
* `url` String
|
||||
|
||||
Emitted when the user wants to open a URL with the application. Your application's
|
||||
`Info.plist` file must define the url scheme within the `CFBundleURLTypes` key, and
|
||||
`Info.plist` file must define the URL scheme within the `CFBundleURLTypes` key, and
|
||||
set `NSPrincipalClass` to `AtomApplication`.
|
||||
|
||||
You should call `event.preventDefault()` if you want to handle this event.
|
||||
@@ -146,7 +146,7 @@ Returns:
|
||||
* `event` Event
|
||||
* `type` String - A string identifying the activity. Maps to
|
||||
[`NSUserActivity.activityType`][activity-type].
|
||||
* `userInfo` Object - Contains app-specific state stored by the activity on
|
||||
* `userInfo` unknown - Contains app-specific state stored by the activity on
|
||||
another device.
|
||||
|
||||
Emitted during [Handoff][handoff] when an activity from a different device wants
|
||||
@@ -189,7 +189,7 @@ Returns:
|
||||
* `event` Event
|
||||
* `type` String - A string identifying the activity. Maps to
|
||||
[`NSUserActivity.activityType`][activity-type].
|
||||
* `userInfo` Object - Contains app-specific state stored by the activity.
|
||||
* `userInfo` unknown - Contains app-specific state stored by the activity.
|
||||
|
||||
Emitted during [Handoff][handoff] after an activity from this device was successfully
|
||||
resumed on another one.
|
||||
@@ -201,7 +201,7 @@ Returns:
|
||||
* `event` Event
|
||||
* `type` String - A string identifying the activity. Maps to
|
||||
[`NSUserActivity.activityType`][activity-type].
|
||||
* `userInfo` Object - Contains app-specific state stored by the activity.
|
||||
* `userInfo` unknown - Contains app-specific state stored by the activity.
|
||||
|
||||
Emitted when [Handoff][handoff] is about to be resumed on another device. If you need to update the state to be transferred, you should call `event.preventDefault()` immediately, construct a new `userInfo` dictionary and call `app.updateCurrentActiviy()` in a timely manner. Otherwise, the operation will fail and `continue-activity-error` will be called.
|
||||
|
||||
@@ -343,6 +343,10 @@ app.on('login', (event, webContents, request, authInfo, callback) => {
|
||||
})
|
||||
```
|
||||
|
||||
### Event: 'gpu-info-update'
|
||||
|
||||
Emitted whenever there is a GPU info update.
|
||||
|
||||
### Event: 'gpu-process-crashed'
|
||||
|
||||
Returns:
|
||||
@@ -350,7 +354,7 @@ Returns:
|
||||
* `event` Event
|
||||
* `killed` Boolean
|
||||
|
||||
Emitted when the gpu process crashes or is killed.
|
||||
Emitted when the GPU process crashes or is killed.
|
||||
|
||||
### Event: 'renderer-process-crashed'
|
||||
|
||||
@@ -572,7 +576,7 @@ Hides all application windows without minimizing them.
|
||||
Shows application windows after they were hidden. Does not automatically focus
|
||||
them.
|
||||
|
||||
### `app.setAppLogsPath(path)`
|
||||
### `app.setAppLogsPath([path])`
|
||||
|
||||
* `path` String (optional) - A custom path for your logs. Must be absolute.
|
||||
|
||||
@@ -586,55 +590,30 @@ Returns `String` - The current application directory.
|
||||
|
||||
### `app.getPath(name)`
|
||||
|
||||
* `name` String
|
||||
* `name` String - You can request the following paths by the name:
|
||||
* `home` User's home directory.
|
||||
* `appData` Per-user application data directory, which by default points to:
|
||||
* `%APPDATA%` on Windows
|
||||
* `$XDG_CONFIG_HOME` or `~/.config` on Linux
|
||||
* `~/Library/Application Support` on macOS
|
||||
* `userData` The directory for storing your app's configuration files, which by
|
||||
default it is the `appData` directory appended with your app's name.
|
||||
* `cache`
|
||||
* `temp` Temporary directory.
|
||||
* `exe` The current executable file.
|
||||
* `module` The `libchromiumcontent` library.
|
||||
* `desktop` The current user's Desktop directory.
|
||||
* `documents` Directory for a user's "My Documents".
|
||||
* `downloads` Directory for a user's downloads.
|
||||
* `music` Directory for a user's music.
|
||||
* `pictures` Directory for a user's pictures.
|
||||
* `videos` Directory for a user's videos.
|
||||
* `logs` Directory for your app's log folder.
|
||||
* `pepperFlashSystemPlugin` Full path to the system version of the Pepper Flash plugin.
|
||||
|
||||
Returns `String` - A path to a special directory or file associated with `name`. On
|
||||
failure, an `Error` is thrown.
|
||||
|
||||
You can request the following paths by the name:
|
||||
|
||||
* `home` User's home directory.
|
||||
* `appData` Per-user application data directory, which by default points to:
|
||||
* `%APPDATA%` on Windows
|
||||
* `$XDG_CONFIG_HOME` or `~/.config` on Linux
|
||||
* `~/Library/Application Support` on macOS
|
||||
* `userData` The directory for storing your app's configuration files, which by
|
||||
default it is the `appData` directory appended with your app's name.
|
||||
* `temp` Temporary directory.
|
||||
* `exe` The current executable file.
|
||||
* `module` The `libchromiumcontent` library.
|
||||
* `desktop` The current user's Desktop directory.
|
||||
* `documents` Directory for a user's "My Documents".
|
||||
* `downloads` Directory for a user's downloads.
|
||||
* `music` Directory for a user's music.
|
||||
* `pictures` Directory for a user's pictures.
|
||||
* `videos` Directory for a user's videos.
|
||||
* `logs` Directory for your app's log folder.
|
||||
* `pepperFlashSystemPlugin` Full path to the system version of the Pepper Flash plugin.
|
||||
|
||||
### `app.getFileIcon(path[, options], callback)`
|
||||
|
||||
* `path` String
|
||||
* `options` Object (optional)
|
||||
* `size` String
|
||||
* `small` - 16x16
|
||||
* `normal` - 32x32
|
||||
* `large` - 48x48 on _Linux_, 32x32 on _Windows_, unsupported on _macOS_.
|
||||
* `callback` Function
|
||||
* `error` Error
|
||||
* `icon` [NativeImage](native-image.md)
|
||||
|
||||
Fetches a path's associated icon.
|
||||
|
||||
On _Windows_, there are 2 kinds of icons:
|
||||
|
||||
* Icons associated with certain file extensions, like `.mp3`, `.png`, etc.
|
||||
* Icons inside the file itself, like `.exe`, `.dll`, `.ico`.
|
||||
|
||||
On _Linux_ and _macOS_, icons depend on the application associated with file mime type.
|
||||
|
||||
**[Deprecated Soon](modernization/promisification.md)**
|
||||
|
||||
### `app.getFileIcon(path[, options])`
|
||||
|
||||
* `path` String
|
||||
@@ -681,17 +660,21 @@ executable is returned.
|
||||
Returns `String` - The current application's name, which is the name in the application's
|
||||
`package.json` file.
|
||||
|
||||
Usually the `name` field of `package.json` is a short lowercased name, according
|
||||
Usually the `name` field of `package.json` is a short lowercase name, according
|
||||
to the npm modules spec. You should usually also specify a `productName`
|
||||
field, which is your application's full capitalized name, and which will be
|
||||
preferred over `name` by Electron.
|
||||
|
||||
**[Deprecated](modernization/property-updates.md)**
|
||||
|
||||
### `app.setName(name)`
|
||||
|
||||
* `name` String
|
||||
|
||||
Overrides the current application's name.
|
||||
|
||||
**[Deprecated](modernization/property-updates.md)**
|
||||
|
||||
### `app.getLocale()`
|
||||
|
||||
Returns `String` - The current application locale. Possible return values are documented [here](locales.md).
|
||||
@@ -705,7 +688,7 @@ To set the locale, you'll want to use a command line switch at app startup, whic
|
||||
|
||||
### `app.getLocaleCountryCode()`
|
||||
|
||||
Returns `string` - User operating system's locale two-letter [ISO 3166](https://www.iso.org/iso-3166-country-codes.html) country code. The value is taken from native OS APIs.
|
||||
Returns `String` - User operating system's locale two-letter [ISO 3166](https://www.iso.org/iso-3166-country-codes.html) country code. The value is taken from native OS APIs.
|
||||
|
||||
**Note:** When unable to detect locale country code, it returns empty string.
|
||||
|
||||
@@ -787,7 +770,7 @@ The API uses the Windows Registry and LSCopyDefaultHandlerForURLScheme internall
|
||||
|
||||
* `tasks` [Task[]](structures/task.md) - Array of `Task` objects
|
||||
|
||||
Adds `tasks` to the [Tasks][tasks] category of the JumpList on Windows.
|
||||
Adds `tasks` to the [Tasks][tasks] category of the Jump List on Windows.
|
||||
|
||||
`tasks` is an array of [`Task`](structures/task.md) objects.
|
||||
|
||||
@@ -803,15 +786,15 @@ Returns `Object`:
|
||||
* `minItems` Integer - The minimum number of items that will be shown in the
|
||||
Jump List (for a more detailed description of this value see the
|
||||
[MSDN docs][JumpListBeginListMSDN]).
|
||||
* `removedItems` [JumpListItem[]](structures/jump-list-item.md) - Array of `JumpListItem` objects that correspond to
|
||||
items that the user has explicitly removed from custom categories in the
|
||||
* `removedItems` [JumpListItem[]](structures/jump-list-item.md) - Array of `JumpListItem`
|
||||
objects that correspond to items that the user has explicitly removed from custom categories in the
|
||||
Jump List. These items must not be re-added to the Jump List in the **next**
|
||||
call to `app.setJumpList()`, Windows will not display any custom category
|
||||
that contains any of the removed items.
|
||||
|
||||
### `app.setJumpList(categories)` _Windows_
|
||||
|
||||
* `categories` [JumpListCategory[]](structures/jump-list-category.md) or `null` - Array of `JumpListCategory` objects.
|
||||
* `categories` [JumpListCategory[]](structures/jump-list-category.md) | `null` - Array of `JumpListCategory` objects.
|
||||
|
||||
Sets or removes a custom Jump List for the application, and returns one of the
|
||||
following strings:
|
||||
@@ -966,7 +949,7 @@ allow multiple instances of the application to once again run side by side.
|
||||
|
||||
* `type` String - Uniquely identifies the activity. Maps to
|
||||
[`NSUserActivity.activityType`][activity-type].
|
||||
* `userInfo` Object - App-specific state to store for use by another device.
|
||||
* `userInfo` any - App-specific state to store for use by another device.
|
||||
* `webpageURL` String (optional) - The webpage to load in a browser if no suitable app is
|
||||
installed on the resuming device. The scheme must be `http` or `https`.
|
||||
|
||||
@@ -979,16 +962,17 @@ Returns `String` - The type of the currently running activity.
|
||||
|
||||
### `app.invalidateCurrentActivity()` _macOS_
|
||||
|
||||
* `type` String - Uniquely identifies the activity. Maps to
|
||||
[`NSUserActivity.activityType`][activity-type].
|
||||
|
||||
Invalidates the current [Handoff][handoff] user activity.
|
||||
|
||||
### `app.resignCurrentActivity()` _macOS_
|
||||
|
||||
Marks the current [Handoff][handoff] user activity as inactive without invalidating it.
|
||||
|
||||
### `app.updateCurrentActivity(type, userInfo)` _macOS_
|
||||
|
||||
* `type` String - Uniquely identifies the activity. Maps to
|
||||
[`NSUserActivity.activityType`][activity-type].
|
||||
* `userInfo` Object - App-specific state to store for use by another device.
|
||||
* `userInfo` any - App-specific state to store for use by another device.
|
||||
|
||||
Updates the current activity if its type matches `type`, merging the entries from
|
||||
`userInfo` into its current `userInfo` dictionary.
|
||||
@@ -999,7 +983,7 @@ Updates the current activity if its type matches `type`, merging the entries fro
|
||||
|
||||
Changes the [Application User Model ID][app-user-model-id] to `id`.
|
||||
|
||||
### `app.importCertificate(options, callback)` _LINUX_
|
||||
### `app.importCertificate(options, callback)` _Linux_
|
||||
|
||||
* `options` Object
|
||||
* `certificate` String - Path for the pkcs12 file.
|
||||
@@ -1027,17 +1011,19 @@ This method can only be called before app is ready.
|
||||
|
||||
### `app.getAppMetrics()`
|
||||
|
||||
Returns [`ProcessMetric[]`](structures/process-metric.md): Array of `ProcessMetric` objects that correspond to memory and cpu usage statistics of all the processes associated with the app.
|
||||
Returns [`ProcessMetric[]`](structures/process-metric.md): Array of `ProcessMetric` objects that correspond to memory and CPU usage statistics of all the processes associated with the app.
|
||||
|
||||
### `app.getGPUFeatureStatus()`
|
||||
|
||||
Returns [`GPUFeatureStatus`](structures/gpu-feature-status.md) - The Graphics Feature Status from `chrome://gpu/`.
|
||||
|
||||
**Note:** This information is only usable after the `gpu-info-update` event is emitted.
|
||||
|
||||
### `app.getGPUInfo(infoType)`
|
||||
|
||||
* `infoType` String - Values can be either `basic` for basic info or `complete` for complete info.
|
||||
* `infoType` String - Can be `basic` or `complete`.
|
||||
|
||||
Returns `Promise`
|
||||
Returns `Promise<unknown>`
|
||||
|
||||
For `infoType` equal to `complete`:
|
||||
Promise is fulfilled with `Object` containing all the GPU Information as in [chromium's GPUInfo object](https://chromium.googlesource.com/chromium/src/+/4178e190e9da409b055e5dff469911ec6f6b716f/gpu/config/gpu_info.cc). This includes the version and driver information that's shown on `chrome://gpu` page.
|
||||
@@ -1066,6 +1052,7 @@ gpuDevice:
|
||||
machineModelName: 'MacBookPro',
|
||||
machineModelVersion: '11.5' }
|
||||
```
|
||||
|
||||
Using `basic` should be preferred if only basic information like `vendorId` or `driverId` is needed.
|
||||
|
||||
### `app.setBadgeCount(count)` _Linux_ _macOS_
|
||||
@@ -1082,10 +1069,14 @@ On macOS, it shows on the dock icon. On Linux, it only works for Unity launcher.
|
||||
**Note:** Unity launcher requires the existence of a `.desktop` file to work,
|
||||
for more information please read [Desktop Environment Integration][unity-requirement].
|
||||
|
||||
**[Deprecated](modernization/property-updates.md)**
|
||||
|
||||
### `app.getBadgeCount()` _Linux_ _macOS_
|
||||
|
||||
Returns `Integer` - The current value displayed in the counter badge.
|
||||
|
||||
**[Deprecated](modernization/property-updates.md)**
|
||||
|
||||
### `app.isUnityRunning()` _Linux_
|
||||
|
||||
Returns `Boolean` - Whether the current desktop environment is Unity launcher.
|
||||
@@ -1160,7 +1151,7 @@ technologies, such as screen readers, has been detected. See
|
||||
https://www.chromium.org/developers/design-documents/accessibility for more
|
||||
details.
|
||||
|
||||
**[Deprecated Soon](modernization/property-updates.md)**
|
||||
**[Deprecated](modernization/property-updates.md)**
|
||||
|
||||
### `app.setAccessibilitySupportEnabled(enabled)` _macOS_ _Windows_
|
||||
|
||||
@@ -1173,9 +1164,9 @@ This API must be called after the `ready` event is emitted.
|
||||
|
||||
**Note:** Rendering accessibility tree can significantly affect the performance of your app. It should not be enabled by default.
|
||||
|
||||
**[Deprecated Soon](modernization/property-updates.md)**
|
||||
**[Deprecated](modernization/property-updates.md)**
|
||||
|
||||
### `app.showAboutPanel` _macOS_ _Linux_
|
||||
### `app.showAboutPanel()` _macOS_ _Linux_
|
||||
|
||||
Show the app's about panel options. These options can be overridden with `app.setAboutPanelOptions(options)`.
|
||||
|
||||
@@ -1185,24 +1176,24 @@ Show the app's about panel options. These options can be overridden with `app.se
|
||||
* `applicationName` String (optional) - The app's name.
|
||||
* `applicationVersion` String (optional) - The app's version.
|
||||
* `copyright` String (optional) - Copyright information.
|
||||
* `version` String (optional) - The app's build version number. _macOS_
|
||||
* `credits` String (optional) - Credit information. _macOS_
|
||||
* `website` String (optional) - The app's website. _Linux_
|
||||
* `iconPath` String (optional) - Path to the app's icon. Will be shown as 64x64 pixels while retaining aspect ratio. _Linux_
|
||||
* `version` String (optional) _macOS_ - The app's build version number.
|
||||
* `credits` String (optional) _macOS_ - Credit information.
|
||||
* `authors` String[] (optional) _Linux_ - List of app authors.
|
||||
* `website` String (optional) _Linux_ - The app's website.
|
||||
* `iconPath` String (optional) _Linux_ - Path to the app's icon. Will be shown as 64x64 pixels while retaining aspect ratio.
|
||||
|
||||
Set the about panel options. This will override the values defined in the app's `.plist` file on MacOS. See the [Apple docs][about-panel-options] for more details. On Linux, values must be set in order to be shown; there are no defaults.
|
||||
Set the about panel options. This will override the values defined in the app's
|
||||
`.plist` file on MacOS. See the [Apple docs][about-panel-options] for more details. On Linux, values must be set in order to be shown; there are no defaults.
|
||||
|
||||
If you do not set `credits` but still wish to surface them in your app, AppKit will look for a file named "Credits.html", "Credits.rtf", and "Credits.rtfd", in that order, in the bundle returned by the NSBundle class method main. The first file found is used, and if none is found, the info area is left blank. See Apple [documentation](https://developer.apple.com/documentation/appkit/nsaboutpaneloptioncredits?language=objc) for more information.
|
||||
|
||||
### `app.isEmojiPanelSupported`
|
||||
### `app.isEmojiPanelSupported()`
|
||||
|
||||
Returns `Boolean` - whether or not the current OS version allows for native emoji pickers.
|
||||
|
||||
### `app.showEmojiPanel` _macOS_ _Windows_
|
||||
### `app.showEmojiPanel()` _macOS_ _Windows_
|
||||
|
||||
Show the platform's native emoji picker.
|
||||
|
||||
### `app.startAccessingSecurityScopedResource(bookmarkData)` _macOS (mas)_
|
||||
### `app.startAccessingSecurityScopedResource(bookmarkData)` _mas_
|
||||
|
||||
* `bookmarkData` String - The base64 encoded security scoped bookmark data returned by the `dialog.showOpenDialog` or `dialog.showSaveDialog` methods.
|
||||
|
||||
@@ -1219,42 +1210,6 @@ stopAccessingSecurityScopedResource()
|
||||
|
||||
Start accessing a security scoped resource. With this method Electron applications that are packaged for the Mac App Store may reach outside their sandbox to access files chosen by the user. See [Apple's documentation](https://developer.apple.com/library/content/documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html#//apple_ref/doc/uid/TP40011183-CH3-SW16) for a description of how this system works.
|
||||
|
||||
### `app.commandLine.appendSwitch(switch[, value])`
|
||||
|
||||
* `switch` String - A command-line switch, without the leading `--`
|
||||
* `value` String (optional) - A value for the given switch
|
||||
|
||||
Append a switch (with optional `value`) to Chromium's command line.
|
||||
|
||||
**Note:** This will not affect `process.argv`. The intended usage of this function is to
|
||||
control Chromium's behavior.
|
||||
|
||||
### `app.commandLine.appendArgument(value)`
|
||||
|
||||
* `value` String - The argument to append to the command line
|
||||
|
||||
Append an argument to Chromium's command line. The argument will be quoted
|
||||
correctly. Switches will precede arguments regardless of appending order.
|
||||
|
||||
If you're appending an argument like `--switch=value`, consider using `appendSwitch('switch', 'value')` instead.
|
||||
|
||||
**Note:** This will not affect `process.argv`. The intended usage of this function is to
|
||||
control Chromium's behavior.
|
||||
|
||||
### `app.commandLine.hasSwitch(switch)`
|
||||
|
||||
* `switch` String - A command-line switch
|
||||
|
||||
Returns `Boolean` - Whether the command-line switch is present.
|
||||
|
||||
### `app.commandLine.getSwitchValue(switch)`
|
||||
|
||||
* `switch` String - A command-line switch
|
||||
|
||||
Returns `String` - The command-line switch value.
|
||||
|
||||
**Note:** When the switch is not present or has no value, it returns empty string.
|
||||
|
||||
### `app.enableSandbox()` _Experimental_
|
||||
|
||||
Enables full sandbox mode on the app.
|
||||
@@ -1266,7 +1221,11 @@ This method can only be called before app is ready.
|
||||
Returns `Boolean` - Whether the application is currently running from the
|
||||
systems Application folder. Use in combination with `app.moveToApplicationsFolder()`
|
||||
|
||||
### `app.moveToApplicationsFolder()` _macOS_
|
||||
### `app.moveToApplicationsFolder([options])` _macOS_
|
||||
|
||||
* `options` Object (optional)
|
||||
* `conflictHandler` Function<Boolean> (optional) - A handler for potential conflict in move failure.
|
||||
* `conflictType` String - The type of move conflict encountered by the handler; can be `exists` or `existsAndRunning`, where `exists` means that an app of the same name is present in the Applications directory and `existsAndRunning` means both that it exists and that it's presently running.
|
||||
|
||||
Returns `Boolean` - Whether the move was successful. Please note that if
|
||||
the move is successful, your application will quit and relaunch.
|
||||
@@ -1279,81 +1238,31 @@ the user to confirm the operation, you may do so using the
|
||||
move to fail. For instance if the user cancels the authorization dialog, this
|
||||
method returns false. If we fail to perform the copy, then this method will
|
||||
throw an error. The message in the error should be informative and tell
|
||||
you exactly what went wrong
|
||||
you exactly what went wrong.
|
||||
|
||||
### `app.dock.bounce([type])` _macOS_
|
||||
By default, if an app of the same name as the one being moved exists in the Applications directory and is _not_ running, the existing app will be trashed and the active app moved into its place. If it _is_ running, the pre-existing running app will assume focus and the the previously active app will quit itself. This behavior can be changed by providing the optional conflict handler, where the boolean returned by the handler determines whether or not the move conflict is resolved with default behavior. i.e. returning `false` will ensure no further action is taken, returning `true` will result in the default behavior and the method continuing.
|
||||
|
||||
* `type` String (optional) - Can be `critical` or `informational`. The default is
|
||||
`informational`
|
||||
For example:
|
||||
|
||||
Returns `Integer` an ID representing the request.
|
||||
```js
|
||||
app.moveToApplicationsFolder({
|
||||
conflictHandler: (conflictType) => {
|
||||
if (conflictType === 'exists') {
|
||||
return dialog.showMessageBoxSync({
|
||||
type: 'question',
|
||||
buttons: ['Halt Move', 'Continue Move'],
|
||||
defaultId: 0,
|
||||
message: 'An app of this name already exists'
|
||||
}) === 1
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
When `critical` is passed, the dock icon will bounce until either the
|
||||
application becomes active or the request is canceled.
|
||||
|
||||
When `informational` is passed, the dock icon will bounce for one second.
|
||||
However, the request remains active until either the application becomes active
|
||||
or the request is canceled.
|
||||
|
||||
**Nota Bene:** This method can only be used while the app is not focused; when the app is focused it will return -1.
|
||||
|
||||
### `app.dock.cancelBounce(id)` _macOS_
|
||||
|
||||
* `id` Integer
|
||||
|
||||
Cancel the bounce of `id`.
|
||||
|
||||
### `app.dock.downloadFinished(filePath)` _macOS_
|
||||
|
||||
* `filePath` String
|
||||
|
||||
Bounces the Downloads stack if the filePath is inside the Downloads folder.
|
||||
|
||||
### `app.dock.setBadge(text)` _macOS_
|
||||
|
||||
* `text` String
|
||||
|
||||
Sets the string to be displayed in the dock’s badging area.
|
||||
|
||||
### `app.dock.getBadge()` _macOS_
|
||||
|
||||
Returns `String` - The badge string of the dock.
|
||||
|
||||
### `app.dock.hide()` _macOS_
|
||||
|
||||
Hides the dock icon.
|
||||
|
||||
### `app.dock.show()` _macOS_
|
||||
|
||||
Returns `Promise<void>` - Resolves when the dock icon is shown.
|
||||
|
||||
### `app.dock.isVisible()` _macOS_
|
||||
|
||||
Returns `Boolean` - Whether the dock icon is visible.
|
||||
|
||||
### `app.dock.setMenu(menu)` _macOS_
|
||||
|
||||
* `menu` [Menu](menu.md)
|
||||
|
||||
Sets the application's [dock menu][dock-menu].
|
||||
|
||||
### `app.dock.getMenu()` _macOS_
|
||||
|
||||
Returns `Menu | null` - The application's [dock menu][dock-menu].
|
||||
|
||||
### `app.dock.setIcon(image)` _macOS_
|
||||
|
||||
* `image` ([NativeImage](native-image.md) | String)
|
||||
|
||||
Sets the `image` associated with this dock icon.
|
||||
Would mean that if an app already exists in the user directory, if the user chooses to 'Continue Move' then the function would continue with its default behavior and the existing app will be trashed and the active app moved into its place.
|
||||
|
||||
## Properties
|
||||
|
||||
### `app.applicationMenu`
|
||||
|
||||
A `Menu` property that return [`Menu`](menu.md) if one has been set and `null` otherwise.
|
||||
Users can pass a [Menu](menu.md) to set this property.
|
||||
|
||||
### `app.accessibilitySupportEnabled` _macOS_ _Windows_
|
||||
|
||||
A `Boolean` property that's `true` if Chrome's accessibility support is enabled, `false` otherwise. This property will be `true` if the use of assistive technologies, such as screen readers, has been detected. Setting this property to `true` manually enables Chrome's accessibility support, allowing developers to expose accessibility switch to users in application settings.
|
||||
@@ -1364,16 +1273,31 @@ This API must be called after the `ready` event is emitted.
|
||||
|
||||
**Note:** Rendering accessibility tree can significantly affect the performance of your app. It should not be enabled by default.
|
||||
|
||||
### `app.userAgentFallback`
|
||||
### `app.applicationMenu`
|
||||
|
||||
A `String` which is the user agent string Electron will use as a global fallback.
|
||||
A `Menu | null` property that returns [`Menu`](menu.md) if one has been set and `null` otherwise.
|
||||
Users can pass a [Menu](menu.md) to set this property.
|
||||
|
||||
This is the user agent that will be used when no user agent is set at the
|
||||
`webContents` or `session` level. Useful for ensuring your entire
|
||||
app has the same user agent. Set to a custom value as early as possible
|
||||
in your apps initialization to ensure that your overridden value is used.
|
||||
### `app.badgeCount` _Linux_ _macOS_
|
||||
|
||||
### `app.isPackaged`
|
||||
An `Integer` property that returns the badge count for current app. Setting the count to `0` will hide the badge.
|
||||
|
||||
On macOS, setting this with any nonzero integer shows on the dock icon. On Linux, this property only works for Unity launcher.
|
||||
|
||||
**Note:** Unity launcher requires the existence of a `.desktop` file to work,
|
||||
for more information please read [Desktop Environment Integration][unity-requirement].
|
||||
|
||||
### `app.commandLine` _Readonly_
|
||||
|
||||
A [`CommandLine`](./command-line.md) object that allows you to read and manipulate the
|
||||
command line arguments that Chromium uses.
|
||||
|
||||
### `app.dock` _macOS_ _Readonly_
|
||||
|
||||
A [`Dock`](./dock.md) object that allows you to perform actions on your app icon in the user's
|
||||
dock on macOS.
|
||||
|
||||
### `app.isPackaged` _Readonly_
|
||||
|
||||
A `Boolean` property that returns `true` if the app is packaged, `false` otherwise. For many apps, this property can be used to distinguish development and production environments.
|
||||
|
||||
@@ -1390,6 +1314,24 @@ A `Boolean` property that returns `true` if the app is packaged, `false` otherw
|
||||
[JumpListBeginListMSDN]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378398(v=vs.85).aspx
|
||||
[about-panel-options]: https://developer.apple.com/reference/appkit/nsapplication/1428479-orderfrontstandardaboutpanelwith?language=objc
|
||||
|
||||
### `app.name`
|
||||
|
||||
A `String` property that indicates the current application's name, which is the name in the application's `package.json` file.
|
||||
|
||||
Usually the `name` field of `package.json` is a short lowercase name, according
|
||||
to the npm modules spec. You should usually also specify a `productName`
|
||||
field, which is your application's full capitalized name, and which will be
|
||||
preferred over `name` by Electron.
|
||||
|
||||
### `app.userAgentFallback`
|
||||
|
||||
A `String` which is the user agent string Electron will use as a global fallback.
|
||||
|
||||
This is the user agent that will be used when no user agent is set at the
|
||||
`webContents` or `session` level. It is useful for ensuring that your entire
|
||||
app has the same user agent. Set to a custom value as early as possible
|
||||
in your app's initialization to ensure that your overridden value is used.
|
||||
|
||||
### `app.allowRendererProcessReuse`
|
||||
|
||||
A `Boolean` which when `true` disables the overrides that Electron has in place
|
||||
|
||||
@@ -6,6 +6,8 @@ Process: [Main](../glossary.md#main-process)
|
||||
|
||||
**See also: [A detailed guide about how to implement updates in your application](../tutorial/updates.md).**
|
||||
|
||||
`autoUpdater` is an [EventEmitter][event-emitter].
|
||||
|
||||
## Platform Notices
|
||||
|
||||
Currently, only macOS and Windows are supported. There is no built-in support
|
||||
@@ -101,7 +103,7 @@ The `autoUpdater` object has the following methods:
|
||||
|
||||
* `options` Object
|
||||
* `url` String
|
||||
* `headers` Object (optional) _macOS_ - HTTP request headers.
|
||||
* `headers` Record<String, String> (optional) _macOS_ - HTTP request headers.
|
||||
* `serverType` String (optional) _macOS_ - Either `json` or `default`, see the [Squirrel.Mac][squirrel-mac]
|
||||
README for more information.
|
||||
|
||||
@@ -136,3 +138,4 @@ application starts.
|
||||
[installer-lib]: https://github.com/electron/windows-installer
|
||||
[electron-forge-lib]: https://github.com/electron-userland/electron-forge
|
||||
[app-user-model-id]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx
|
||||
[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter
|
||||
|
||||
61
docs/api/breaking-changes-ns.md
Normal file
61
docs/api/breaking-changes-ns.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# Breaking changes (NetworkService) (Draft)
|
||||
|
||||
This document describes changes to Electron APIs after migrating network code
|
||||
to NetworkService API.
|
||||
|
||||
We don't currently have an estimate of when we will enable `NetworkService` by
|
||||
default in Electron, but as Chromium is already removing non-`NetworkService`
|
||||
code, we might switch before Electron 10.
|
||||
|
||||
The content of this document should be moved to `breaking-changes.md` once we have
|
||||
determined when to enable `NetworkService` in Electron.
|
||||
|
||||
## Planned Breaking API Changes
|
||||
|
||||
### `protocol.unregisterProtocol`
|
||||
### `protocol.uninterceptProtocol`
|
||||
|
||||
The APIs are now synchronous and the optional callback is no longer needed.
|
||||
|
||||
```javascript
|
||||
// Deprecated
|
||||
protocol.unregisterProtocol(scheme, () => { /* ... */ })
|
||||
// Replace with
|
||||
protocol.unregisterProtocol(scheme)
|
||||
```
|
||||
|
||||
### `protocol.registerFileProtocol`
|
||||
### `protocol.registerBufferProtocol`
|
||||
### `protocol.registerStringProtocol`
|
||||
### `protocol.registerHttpProtocol`
|
||||
### `protocol.registerStreamProtocol`
|
||||
### `protocol.interceptFileProtocol`
|
||||
### `protocol.interceptStringProtocol`
|
||||
### `protocol.interceptBufferProtocol`
|
||||
### `protocol.interceptHttpProtocol`
|
||||
### `protocol.interceptStreamProtocol`
|
||||
|
||||
The APIs are now synchronous and the optional callback is no longer needed.
|
||||
|
||||
```javascript
|
||||
// Deprecated
|
||||
protocol.registerFileProtocol(scheme, handler, () => { /* ... */ })
|
||||
// Replace with
|
||||
protocol.registerFileProtocol(scheme, handler)
|
||||
```
|
||||
|
||||
The registered or intercepted protocol does not have effect on current page
|
||||
until navigation happens.
|
||||
|
||||
### `protocol.isProtocolHandled`
|
||||
|
||||
This API is deprecated and users should use `protocol.isProtocolRegistered`
|
||||
and `protocol.isProtocolIntercepted` instead.
|
||||
|
||||
```javascript
|
||||
// Deprecated
|
||||
protocol.isProtocolHandled(scheme).then(() => { /* ... */ })
|
||||
// Replace with
|
||||
const isRegistered = protocol.isProtocolRegistered(scheme)
|
||||
const isIntercepted = protocol.isProtocolIntercepted(scheme)
|
||||
```
|
||||
@@ -2,26 +2,75 @@
|
||||
|
||||
Breaking changes will be documented here, and deprecation warnings added to JS code where possible, at least [one major version](../tutorial/electron-versioning.md#semver) before the change is made.
|
||||
|
||||
# `FIXME` comments
|
||||
## `FIXME` comments
|
||||
|
||||
The `FIXME` string is used in code comments to denote things that should be fixed for future releases. See https://github.com/electron/electron/search?q=fixme
|
||||
|
||||
# Planned Breaking API Changes (7.0)
|
||||
## Planned Breaking API Changes (7.0)
|
||||
|
||||
## `shell.openExternalSync(url[, options])`
|
||||
### Node Headers URL
|
||||
|
||||
This is the URL specified as `disturl` in a `.npmrc` file or as the `--dist-url`
|
||||
command line flag when building native Node modules. Both will be supported for
|
||||
the foreseeable future but it is recommended that you switch.
|
||||
|
||||
Deprecated: https://atom.io/download/electron
|
||||
|
||||
Replace with: https://electronjs.org/headers
|
||||
|
||||
### `session.clearAuthCache(options)`
|
||||
|
||||
The `session.clearAuthCache` API no longer accepts options for what to clear, and instead unconditionally clears the whole cache.
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
shell.openExternalSync(url)
|
||||
session.clearAuthCache({ type: 'password' })
|
||||
// Replace with
|
||||
async function openThing (url) {
|
||||
await shell.openExternal(url)
|
||||
}
|
||||
session.clearAuthCache()
|
||||
```
|
||||
|
||||
# Planned Breaking API Changes (6.0)
|
||||
### `powerMonitor.querySystemIdleState`
|
||||
|
||||
## `win.setMenu(null)`
|
||||
```js
|
||||
// Removed in Electron 7.0
|
||||
powerMonitor.querySystemIdleState(threshold, callback)
|
||||
// Replace with synchronous API
|
||||
const idleState = getSystemIdleState(threshold)
|
||||
```
|
||||
|
||||
### `powerMonitor.querySystemIdleTime`
|
||||
|
||||
```js
|
||||
// Removed in Electron 7.0
|
||||
powerMonitor.querySystemIdleTime(callback)
|
||||
// Replace with synchronous API
|
||||
const idleTime = getSystemIdleTime()
|
||||
```
|
||||
|
||||
### webFrame Isolated World APIs
|
||||
|
||||
```js
|
||||
// Removed in Elecron 7.0
|
||||
webFrame.setIsolatedWorldContentSecurityPolicy(worldId, csp)
|
||||
webFrame.setIsolatedWorldHumanReadableName(worldId, name)
|
||||
webFrame.setIsolatedWorldSecurityOrigin(worldId, securityOrigin)
|
||||
// Replace with
|
||||
webFrame.setIsolatedWorldInfo(
|
||||
worldId,
|
||||
{
|
||||
securityOrigin: 'some_origin',
|
||||
name: 'human_readable_name',
|
||||
csp: 'content_security_policy'
|
||||
})
|
||||
```
|
||||
|
||||
### Removal of deprecated `marked` property on getBlinkMemoryInfo
|
||||
|
||||
This property was removed in Chromium 77, and as such is no longer available.
|
||||
|
||||
## Planned Breaking API Changes (6.0)
|
||||
|
||||
### `win.setMenu(null)`
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
@@ -30,7 +79,7 @@ win.setMenu(null)
|
||||
win.removeMenu()
|
||||
```
|
||||
|
||||
## `contentTracing.getTraceBufferUsage()`
|
||||
### `contentTracing.getTraceBufferUsage()`
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
@@ -43,7 +92,7 @@ contentTracing.getTraceBufferUsage().then(infoObject => {
|
||||
})
|
||||
```
|
||||
|
||||
## `electron.screen` in renderer process
|
||||
### `electron.screen` in renderer process
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
@@ -52,7 +101,7 @@ require('electron').screen
|
||||
require('electron').remote.screen
|
||||
```
|
||||
|
||||
## `require` in sandboxed renderers
|
||||
### `require` in sandboxed renderers
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
@@ -76,7 +125,7 @@ require('path')
|
||||
require('electron').remote.require('path')
|
||||
```
|
||||
|
||||
## `powerMonitor.querySystemIdleState`
|
||||
### `powerMonitor.querySystemIdleState`
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
@@ -85,7 +134,7 @@ powerMonitor.querySystemIdleState(threshold, callback)
|
||||
const idleState = getSystemIdleState(threshold)
|
||||
```
|
||||
|
||||
## `powerMonitor.querySystemIdleTime`
|
||||
### `powerMonitor.querySystemIdleTime`
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
@@ -94,7 +143,16 @@ powerMonitor.querySystemIdleTime(callback)
|
||||
const idleTime = getSystemIdleTime()
|
||||
```
|
||||
|
||||
## `Tray`
|
||||
### `app.enableMixedSandbox`
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
app.enableMixedSandbox()
|
||||
```
|
||||
|
||||
Mixed-sandbox mode is now enabled by default.
|
||||
|
||||
### `Tray`
|
||||
|
||||
Under macOS Catalina our former Tray implementation breaks.
|
||||
Apple's native substitute doesn't support changing the highlighting behavior.
|
||||
@@ -105,9 +163,9 @@ tray.setHighlightMode(mode)
|
||||
// API will be removed in v7.0 without replacement.
|
||||
```
|
||||
|
||||
# Planned Breaking API Changes (5.0)
|
||||
## Planned Breaking API Changes (5.0)
|
||||
|
||||
## `new BrowserWindow({ webPreferences })`
|
||||
### `new BrowserWindow({ webPreferences })`
|
||||
|
||||
The following `webPreferences` option default values are deprecated in favor of the new defaults listed below.
|
||||
|
||||
@@ -131,12 +189,12 @@ const w = new BrowserWindow({
|
||||
|
||||
Child windows opened with the `nativeWindowOpen` option will always have Node.js integration disabled, unless `nodeIntegrationInSubFrames` is `true.
|
||||
|
||||
## Privileged Schemes Registration
|
||||
### Privileged Schemes Registration
|
||||
|
||||
Renderer process APIs `webFrame.setRegisterURLSchemeAsPrivileged` and `webFrame.registerURLSchemeAsBypassingCSP` as well as browser process API `protocol.registerStandardSchemes` have been removed.
|
||||
A new API, `protocol.registerSchemesAsPrivileged` has been added and should be used for registering custom schemes with the required privileges. Custom schemes are required to be registered before app ready.
|
||||
|
||||
## webFrame Isolated World APIs
|
||||
### webFrame Isolated World APIs
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
@@ -153,11 +211,28 @@ webFrame.setIsolatedWorldInfo(
|
||||
})
|
||||
```
|
||||
|
||||
# Planned Breaking API Changes (4.0)
|
||||
## `webFrame.setSpellCheckProvider`
|
||||
The `spellCheck` callback is now asynchronous, and `autoCorrectWord` parameter has been removed.
|
||||
```js
|
||||
// Deprecated
|
||||
webFrame.setSpellCheckProvider('en-US', true, {
|
||||
spellCheck: (text) => {
|
||||
return !spellchecker.isMisspelled(text)
|
||||
}
|
||||
})
|
||||
// Replace with
|
||||
webFrame.setSpellCheckProvider('en-US', {
|
||||
spellCheck: (words, callback) => {
|
||||
callback(words.filter(text => spellchecker.isMisspelled(text)))
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## Planned Breaking API Changes (4.0)
|
||||
|
||||
The following list includes the breaking API changes made in Electron 4.0.
|
||||
|
||||
## `app.makeSingleInstance`
|
||||
### `app.makeSingleInstance`
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
@@ -171,7 +246,7 @@ app.on('second-instance', (event, argv, cwd) => {
|
||||
})
|
||||
```
|
||||
|
||||
## `app.releaseSingleInstance`
|
||||
### `app.releaseSingleInstance`
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
@@ -180,7 +255,7 @@ app.releaseSingleInstance()
|
||||
app.releaseSingleInstanceLock()
|
||||
```
|
||||
|
||||
## `app.getGPUInfo`
|
||||
### `app.getGPUInfo`
|
||||
|
||||
```js
|
||||
app.getGPUInfo('complete')
|
||||
@@ -188,7 +263,7 @@ app.getGPUInfo('complete')
|
||||
app.getGPUInfo('basic')
|
||||
```
|
||||
|
||||
## `win_delay_load_hook`
|
||||
### `win_delay_load_hook`
|
||||
|
||||
When building native modules for windows, the `win_delay_load_hook` variable in
|
||||
the module's `binding.gyp` must be true (which is the default). If this hook is
|
||||
@@ -196,11 +271,11 @@ not present, then the native module will fail to load on Windows, with an error
|
||||
message like `Cannot find module`. See the [native module
|
||||
guide](/docs/tutorial/using-native-node-modules.md) for more.
|
||||
|
||||
# Breaking API Changes (3.0)
|
||||
## Breaking API Changes (3.0)
|
||||
|
||||
The following list includes the breaking API changes in Electron 3.0.
|
||||
|
||||
## `app`
|
||||
### `app`
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
@@ -213,7 +288,7 @@ const metrics = app.getAppMetrics()
|
||||
const { memory } = metrics[0] // Deprecated property
|
||||
```
|
||||
|
||||
## `BrowserWindow`
|
||||
### `BrowserWindow`
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
@@ -237,7 +312,7 @@ window.on('app-command', (e, cmd) => {
|
||||
})
|
||||
```
|
||||
|
||||
## `clipboard`
|
||||
### `clipboard`
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
@@ -261,7 +336,7 @@ clipboard.writeHtml()
|
||||
clipboard.writeHTML()
|
||||
```
|
||||
|
||||
## `crashReporter`
|
||||
### `crashReporter`
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
@@ -278,7 +353,7 @@ crashReporter.start({
|
||||
})
|
||||
```
|
||||
|
||||
## `nativeImage`
|
||||
### `nativeImage`
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
@@ -289,14 +364,14 @@ nativeImage.createFromBuffer(buffer, {
|
||||
})
|
||||
```
|
||||
|
||||
## `process`
|
||||
### `process`
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
const info = process.getProcessMemoryInfo()
|
||||
```
|
||||
|
||||
## `screen`
|
||||
### `screen`
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
@@ -305,7 +380,7 @@ screen.getMenuBarHeight()
|
||||
screen.getPrimaryDisplay().workArea
|
||||
```
|
||||
|
||||
## `session`
|
||||
### `session`
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
@@ -318,7 +393,7 @@ ses.setCertificateVerifyProc((request, callback) => {
|
||||
})
|
||||
```
|
||||
|
||||
## `Tray`
|
||||
### `Tray`
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
@@ -332,7 +407,7 @@ tray.setHighlightMode(false)
|
||||
tray.setHighlightMode('off')
|
||||
```
|
||||
|
||||
## `webContents`
|
||||
### `webContents`
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
@@ -345,7 +420,7 @@ webContents.setSize(options)
|
||||
// There is no replacement for this API
|
||||
```
|
||||
|
||||
## `webFrame`
|
||||
### `webFrame`
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
@@ -359,7 +434,7 @@ webFrame.registerURLSchemeAsPrivileged('app', { secure: true })
|
||||
protocol.registerStandardSchemes(['app'], { secure: true })
|
||||
```
|
||||
|
||||
## `<webview>`
|
||||
### `<webview>`
|
||||
|
||||
```js
|
||||
// Removed
|
||||
@@ -375,7 +450,7 @@ webview.onkeydown = () => { /* handler */ }
|
||||
webview.onkeyup = () => { /* handler */ }
|
||||
```
|
||||
|
||||
## Node Headers URL
|
||||
### Node Headers URL
|
||||
|
||||
This is the URL specified as `disturl` in a `.npmrc` file or as the `--dist-url`
|
||||
command line flag when building native Node modules.
|
||||
@@ -384,12 +459,11 @@ Deprecated: https://atom.io/download/atom-shell
|
||||
|
||||
Replace with: https://atom.io/download/electron
|
||||
|
||||
|
||||
# Breaking API Changes (2.0)
|
||||
## Breaking API Changes (2.0)
|
||||
|
||||
The following list includes the breaking API changes made in Electron 2.0.
|
||||
|
||||
## `BrowserWindow`
|
||||
### `BrowserWindow`
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
@@ -400,7 +474,7 @@ let optionsB = { titleBarStyle: 'hiddenInset' }
|
||||
let windowB = new BrowserWindow(optionsB)
|
||||
```
|
||||
|
||||
## `menu`
|
||||
### `menu`
|
||||
|
||||
```js
|
||||
// Removed
|
||||
@@ -409,7 +483,7 @@ menu.popup(browserWindow, 100, 200, 2)
|
||||
menu.popup(browserWindow, { x: 100, y: 200, positioningItem: 2 })
|
||||
```
|
||||
|
||||
## `nativeImage`
|
||||
### `nativeImage`
|
||||
|
||||
```js
|
||||
// Removed
|
||||
@@ -423,13 +497,13 @@ nativeImage.toJpeg()
|
||||
nativeImage.toJPEG()
|
||||
```
|
||||
|
||||
## `process`
|
||||
### `process`
|
||||
|
||||
* `process.versions.electron` and `process.version.chrome` will be made
|
||||
read-only properties for consistency with the other `process.versions`
|
||||
properties set by Node.
|
||||
|
||||
## `webContents`
|
||||
### `webContents`
|
||||
|
||||
```js
|
||||
// Removed
|
||||
@@ -438,7 +512,7 @@ webContents.setZoomLevelLimits(1, 2)
|
||||
webContents.setVisualZoomLevelLimits(1, 2)
|
||||
```
|
||||
|
||||
## `webFrame`
|
||||
### `webFrame`
|
||||
|
||||
```js
|
||||
// Removed
|
||||
@@ -447,7 +521,7 @@ webFrame.setZoomLevelLimits(1, 2)
|
||||
webFrame.setVisualZoomLevelLimits(1, 2)
|
||||
```
|
||||
|
||||
## `<webview>`
|
||||
### `<webview>`
|
||||
|
||||
```js
|
||||
// Removed
|
||||
@@ -456,7 +530,7 @@ webview.setZoomLevelLimits(1, 2)
|
||||
webview.setVisualZoomLevelLimits(1, 2)
|
||||
```
|
||||
|
||||
## Duplicate ARM Assets
|
||||
### Duplicate ARM Assets
|
||||
|
||||
Each Electron release includes two identical ARM builds with slightly different
|
||||
filenames, like `electron-v1.7.3-linux-arm.zip` and
|
||||
@@ -465,7 +539,7 @@ to clarify to users which ARM version it supports, and to disambiguate it from
|
||||
future armv6l and arm64 assets that may be produced.
|
||||
|
||||
The file _without the prefix_ is still being published to avoid breaking any
|
||||
setups that may be consuming it. Starting at 2.0, the un-prefixed file will
|
||||
setups that may be consuming it. Starting at 2.0, the unprefixed file will
|
||||
no longer be published.
|
||||
|
||||
For details, see
|
||||
|
||||
@@ -9,7 +9,7 @@ A `BrowserView` can be used to embed additional web content into a
|
||||
relative to its owning window. It is meant to be an alternative to the
|
||||
`webview` tag.
|
||||
|
||||
## Example
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
// In the main process.
|
||||
@@ -79,14 +79,14 @@ Returns `Boolean` - Whether the view is destroyed.
|
||||
#### `view.setAutoResize(options)` _Experimental_
|
||||
|
||||
* `options` Object
|
||||
* `width` Boolean - If `true`, the view's width will grow and shrink together
|
||||
* `width` Boolean (optional) - If `true`, the view's width will grow and shrink together
|
||||
with the window. `false` by default.
|
||||
* `height` Boolean - If `true`, the view's height will grow and shrink
|
||||
* `height` Boolean (optional) - If `true`, the view's height will grow and shrink
|
||||
together with the window. `false` by default.
|
||||
* `horizontal` Boolean - If `true`, the view's x position and width will grow
|
||||
and shrink proportionly with the window. `false` by default.
|
||||
* `vertical` Boolean - If `true`, the view's y position and height will grow
|
||||
and shrink proportinaly with the window. `false` by default.
|
||||
* `horizontal` Boolean (optional) - If `true`, the view's x position and width will grow
|
||||
and shrink proportionally with the window. `false` by default.
|
||||
* `vertical` Boolean (optional) - If `true`, the view's y position and height will grow
|
||||
and shrink proportionally with the window. `false` by default.
|
||||
|
||||
#### `view.setBounds(bounds)` _Experimental_
|
||||
|
||||
@@ -94,6 +94,12 @@ Returns `Boolean` - Whether the view is destroyed.
|
||||
|
||||
Resizes and moves the view to the supplied bounds relative to the window.
|
||||
|
||||
#### `view.getBounds()` _Experimental_
|
||||
|
||||
Returns [`Rectangle`](structures/rectangle.md)
|
||||
|
||||
The `bounds` of this BrowserView instance as `Object`.
|
||||
|
||||
#### `view.setBackgroundColor(color)` _Experimental_
|
||||
|
||||
* `color` String - Color in `#aarrggbb` or `#argb` form. The alpha channel is
|
||||
|
||||
@@ -35,7 +35,7 @@ Invokes the print dialog on the child window.
|
||||
|
||||
#### `win.postMessage(message, targetOrigin)`
|
||||
|
||||
* `message` String
|
||||
* `message` any
|
||||
* `targetOrigin` String
|
||||
|
||||
Sends a message to the child window with the specified origin or `*` for no
|
||||
|
||||
@@ -33,7 +33,7 @@ you can use the [Frameless Window](frameless-window.md) API.
|
||||
When loading a page in the window directly, users may see the page load incrementally, which is not a good experience for a native app. To make the window display
|
||||
without visual flash, there are two solutions for different situations.
|
||||
|
||||
### Using `ready-to-show` event
|
||||
## Using `ready-to-show` event
|
||||
|
||||
While loading the page, the `ready-to-show` event will be emitted when the renderer
|
||||
process has rendered the page for the first time if the window has not been shown yet. Showing
|
||||
@@ -51,7 +51,7 @@ This event is usually emitted after the `did-finish-load` event, but for
|
||||
pages with many remote resources, it may be emitted before the `did-finish-load`
|
||||
event.
|
||||
|
||||
### Setting `backgroundColor`
|
||||
## Setting `backgroundColor`
|
||||
|
||||
For a complex app, the `ready-to-show` event could be emitted too late, making
|
||||
the app feel slow. In this case, it is recommended to show the window
|
||||
@@ -82,7 +82,7 @@ top.show()
|
||||
|
||||
The `child` window will always show on top of the `top` window.
|
||||
|
||||
### Modal windows
|
||||
## Modal windows
|
||||
|
||||
A modal window is a child window that disables parent window, to create a modal
|
||||
window, you have to set both `parent` and `modal` options:
|
||||
@@ -97,7 +97,7 @@ child.once('ready-to-show', () => {
|
||||
})
|
||||
```
|
||||
|
||||
### Page visibility
|
||||
## Page visibility
|
||||
|
||||
The [Page Visibility API][page-visibility-api] works as follows:
|
||||
|
||||
@@ -116,7 +116,7 @@ The [Page Visibility API][page-visibility-api] works as follows:
|
||||
It is recommended that you pause expensive operations when the visibility
|
||||
state is `hidden` in order to minimize power consumption.
|
||||
|
||||
### Platform notices
|
||||
## Platform notices
|
||||
|
||||
* On macOS modal windows will be displayed as sheets attached to the parent window.
|
||||
* On macOS the child windows will keep the relative position to parent window
|
||||
@@ -131,8 +131,7 @@ state is `hidden` in order to minimize power consumption.
|
||||
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
`BrowserWindow` is an
|
||||
[EventEmitter](https://nodejs.org/api/events.html#events_class_events_eventemitter).
|
||||
`BrowserWindow` is an [EventEmitter][event-emitter].
|
||||
|
||||
It creates a new `BrowserWindow` with native properties as set by the `options`.
|
||||
|
||||
@@ -141,9 +140,9 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
|
||||
* `options` Object (optional)
|
||||
* `width` Integer (optional) - Window's width in pixels. Default is `800`.
|
||||
* `height` Integer (optional) - Window's height in pixels. Default is `600`.
|
||||
* `x` Integer (optional) (**required** if y is used) - Window's left offset from screen.
|
||||
* `x` Integer (optional) - (**required** if y is used) Window's left offset from screen.
|
||||
Default is to center the window.
|
||||
* `y` Integer (optional) (**required** if x is used) - Window's top offset from screen.
|
||||
* `y` Integer (optional) - (**required** if x is used) Window's top offset from screen.
|
||||
Default is to center the window.
|
||||
* `useContentSize` Boolean (optional) - The `width` and `height` would be used as web
|
||||
page's size, which means the actual window's size will include window
|
||||
@@ -198,7 +197,8 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
|
||||
* `autoHideMenuBar` Boolean (optional) - Auto hide the menu bar unless the `Alt`
|
||||
key is pressed. Default is `false`.
|
||||
* `enableLargerThanScreen` Boolean (optional) - Enable the window to be resized larger
|
||||
than screen. Default is `false`.
|
||||
than screen. Only relevant for macOS, as other OSes allow
|
||||
larger-than-screen windows by default. Default is `false`.
|
||||
* `backgroundColor` String (optional) - Window's background color as a hexadecimal value,
|
||||
like `#66CD00` or `#FFF` or `#80FFFFFF` (alpha in #AARRGGBB format is supported if
|
||||
`transparent` is set to `true`). Default is `#FFF` (white).
|
||||
@@ -208,8 +208,8 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
|
||||
transparent) and 1.0 (fully opaque). This is only implemented on Windows and macOS.
|
||||
* `darkTheme` Boolean (optional) - Forces using dark theme for the window, only works on
|
||||
some GTK+3 desktop environments. Default is `false`.
|
||||
* `transparent` Boolean (optional) - Makes the window [transparent](frameless-window.md).
|
||||
Default is `false`.
|
||||
* `transparent` Boolean (optional) - Makes the window [transparent](frameless-window.md#transparent-window).
|
||||
Default is `false`. On Windows, does not work unless the window is frameless.
|
||||
* `type` String (optional) - The type of window, default is normal window. See more about
|
||||
this below.
|
||||
* `titleBarStyle` String (optional) - The style of window title bar.
|
||||
@@ -234,9 +234,7 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
|
||||
window shadow and window animations. Default is `true`.
|
||||
* `vibrancy` String (optional) - Add a type of vibrancy effect to the window, only on
|
||||
macOS. Can be `appearance-based`, `light`, `dark`, `titlebar`, `selection`,
|
||||
`menu`, `popover`, `sidebar`, `medium-light` or `ultra-dark`. Please note that
|
||||
using `frame: false` in combination with a vibrancy value requires that you use a
|
||||
non-default `titleBarStyle` as well.
|
||||
`menu`, `popover`, `sidebar`, `medium-light`, `ultra-dark`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`, `tooltip`, `content`, `under-window`, or `under-page`. Please note that using `frame: false` in combination with a vibrancy value requires that you use a non-default `titleBarStyle` as well. Also note that `appearance-based`, `light`, `dark`, `medium-light`, and `ultra-dark` have been deprecated and will be removed in an upcoming version of macOS.
|
||||
* `zoomToPageWidth` Boolean (optional) - Controls the behavior on macOS when
|
||||
option-clicking the green stoplight button on the toolbar or by clicking the
|
||||
Window > Zoom menu item. If `true`, the window will grow to the preferred
|
||||
@@ -418,7 +416,7 @@ Returns:
|
||||
|
||||
Emitted when the document changed its title, calling `event.preventDefault()`
|
||||
will prevent the native window's title from changing.
|
||||
`explicitSet` is false when title is synthesized from file url.
|
||||
`explicitSet` is false when title is synthesized from file URL.
|
||||
|
||||
#### Event: 'close'
|
||||
|
||||
@@ -590,7 +588,7 @@ win.on('app-command', (e, cmd) => {
|
||||
})
|
||||
```
|
||||
|
||||
The following app commands are explictly supported on Linux:
|
||||
The following app commands are explicitly supported on Linux:
|
||||
|
||||
* `browser-backward`
|
||||
* `browser-forward`
|
||||
@@ -616,6 +614,19 @@ Returns:
|
||||
|
||||
Emitted on 3-finger swipe. Possible directions are `up`, `right`, `down`, `left`.
|
||||
|
||||
#### Event: 'rotate-gesture' _macOS_
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `rotation` Float
|
||||
|
||||
Emitted on trackpad rotation gesture. Continually emitted until rotation gesture is
|
||||
ended. The `rotation` value on each emission is the angle in degrees rotated since
|
||||
the last emission. The last emitted event upon a rotation gesture will always be of
|
||||
value `0`. Counter-clockwise rotation values are positive, while clockwise ones are
|
||||
negative.
|
||||
|
||||
#### Event: 'sheet-begin' _macOS_
|
||||
|
||||
Emitted when the window opens a sheet.
|
||||
@@ -680,7 +691,7 @@ is emitted.
|
||||
|
||||
#### `BrowserWindow.getExtensions()`
|
||||
|
||||
Returns `Object` - The keys are the extension names and each value is
|
||||
Returns `Record<String, ExtensionInfo>` - The keys are the extension names and each value is
|
||||
an Object containing `name` and `version` properties.
|
||||
|
||||
**Note:** This API cannot be called before the `ready` event of the `app` module
|
||||
@@ -713,7 +724,7 @@ is emitted.
|
||||
|
||||
#### `BrowserWindow.getDevToolsExtensions()`
|
||||
|
||||
Returns `Object` - The keys are the extension names and each value is
|
||||
Returns `Record<string, ExtensionInfo>` - The keys are the extension names and each value is
|
||||
an Object containing `name` and `version` properties.
|
||||
|
||||
To check if a DevTools extension is installed you can run the following:
|
||||
@@ -739,7 +750,7 @@ let win = new BrowserWindow({ width: 800, height: 600 })
|
||||
win.loadURL('https://github.com')
|
||||
```
|
||||
|
||||
#### `win.webContents`
|
||||
#### `win.webContents` _Readonly_
|
||||
|
||||
A `WebContents` object this window owns. All web page related events and
|
||||
operations will be done via it.
|
||||
@@ -747,9 +758,68 @@ operations will be done via it.
|
||||
See the [`webContents` documentation](web-contents.md) for its methods and
|
||||
events.
|
||||
|
||||
#### `win.id`
|
||||
#### `win.id` _Readonly_
|
||||
|
||||
A `Integer` representing the unique ID of the window.
|
||||
A `Integer` property representing the unique ID of the window.
|
||||
|
||||
#### `win.autoHideMenuBar`
|
||||
|
||||
A `Boolean` property that determines whether the window menu bar should hide itself automatically. Once set, the menu bar will only show when users press the single `Alt` key.
|
||||
|
||||
If the menu bar is already visible, setting this property to `true` won't
|
||||
hide it immediately.
|
||||
|
||||
#### `win.minimizable`
|
||||
|
||||
A `Boolean` property that determines whether the window can be manually minimized by user.
|
||||
|
||||
On Linux the setter is a no-op, although the getter returns `true`.
|
||||
|
||||
#### `win.maximizable`
|
||||
|
||||
A `Boolean` property that determines whether the window can be manually maximized by user.
|
||||
|
||||
On Linux the setter is a no-op, although the getter returns `true`.
|
||||
|
||||
#### `win.fullScreenable`
|
||||
|
||||
A `Boolean` property that determines whether the maximize/zoom window button toggles fullscreen mode or
|
||||
maximizes the window.
|
||||
|
||||
#### `win.resizable`
|
||||
|
||||
A `Boolean` property that determines whether the window can be manually resized by user.
|
||||
|
||||
#### `win.closable`
|
||||
|
||||
A `Boolean` property that determines whether the window can be manually closed by user.
|
||||
|
||||
On Linux the setter is a no-op, although the getter returns `true`.
|
||||
|
||||
#### `win.movable`
|
||||
|
||||
A `Boolean` property that determines Whether the window can be moved by user.
|
||||
|
||||
On Linux the setter is a no-op, although the getter returns `true`.
|
||||
|
||||
#### `win.excludedFromShownWindowsMenu` _macOS_
|
||||
|
||||
A `Boolean` property that determines whether the window is excluded from the application’s Windows menu. `false` by default.
|
||||
|
||||
```js
|
||||
const win = new BrowserWindow({ height: 600, width: 600 })
|
||||
|
||||
const template = [
|
||||
{
|
||||
role: 'windowmenu'
|
||||
}
|
||||
]
|
||||
|
||||
win.excludedFromShownWindowsMenu = true
|
||||
|
||||
const menu = Menu.buildFromTemplate(template)
|
||||
Menu.setApplicationMenu(menu)
|
||||
```
|
||||
|
||||
### Instance Methods
|
||||
|
||||
@@ -862,7 +932,7 @@ Returns `Boolean` - Whether the window is in normal state (not maximized, not mi
|
||||
|
||||
* `aspectRatio` Float - The aspect ratio to maintain for some portion of the
|
||||
content view.
|
||||
* `extraSize` [Size](structures/size.md) - The extra size not to be included while
|
||||
* `extraSize` [Size](structures/size.md) (optional) - The extra size not to be included while
|
||||
maintaining the aspect ratio.
|
||||
|
||||
This will make a window maintain an aspect ratio. The extra size allows a
|
||||
@@ -908,7 +978,7 @@ Closes the currently open [Quick Look][quick-look] panel.
|
||||
|
||||
#### `win.setBounds(bounds[, animate])`
|
||||
|
||||
* `bounds` [Rectangle](structures/rectangle.md)
|
||||
* `bounds` Partial<[Rectangle](structures/rectangle.md)>
|
||||
* `animate` Boolean (optional) _macOS_
|
||||
|
||||
Resizes and moves the window to the supplied bounds. Any properties that are not supplied will default to their current values.
|
||||
@@ -955,6 +1025,10 @@ Returns [`Rectangle`](structures/rectangle.md) - Contains the window bounds of t
|
||||
|
||||
Disable or enable the window.
|
||||
|
||||
#### `win.isEnabled()`
|
||||
|
||||
Returns Boolean - whether the window is enabled.
|
||||
|
||||
#### `win.setSize(width, height[, animate])`
|
||||
|
||||
* `width` Integer
|
||||
@@ -1007,22 +1081,30 @@ Returns `Integer[]` - Contains the window's maximum width and height.
|
||||
|
||||
Sets whether the window can be manually resized by user.
|
||||
|
||||
**[Deprecated](modernization/property-updates.md)**
|
||||
|
||||
#### `win.isResizable()`
|
||||
|
||||
Returns `Boolean` - Whether the window can be manually resized by user.
|
||||
|
||||
**[Deprecated](modernization/property-updates.md)**
|
||||
|
||||
#### `win.setMovable(movable)` _macOS_ _Windows_
|
||||
|
||||
* `movable` Boolean
|
||||
|
||||
Sets whether the window can be moved by user. On Linux does nothing.
|
||||
|
||||
**[Deprecated](modernization/property-updates.md)**
|
||||
|
||||
#### `win.isMovable()` _macOS_ _Windows_
|
||||
|
||||
Returns `Boolean` - Whether the window can be moved by user.
|
||||
|
||||
On Linux always returns `true`.
|
||||
|
||||
**[Deprecated](modernization/property-updates.md)**
|
||||
|
||||
#### `win.setMinimizable(minimizable)` _macOS_ _Windows_
|
||||
|
||||
* `minimizable` Boolean
|
||||
@@ -1030,12 +1112,16 @@ On Linux always returns `true`.
|
||||
Sets whether the window can be manually minimized by user. On Linux does
|
||||
nothing.
|
||||
|
||||
**[Deprecated](modernization/property-updates.md)**
|
||||
|
||||
#### `win.isMinimizable()` _macOS_ _Windows_
|
||||
|
||||
Returns `Boolean` - Whether the window can be manually minimized by user
|
||||
|
||||
On Linux always returns `true`.
|
||||
|
||||
**[Deprecated](modernization/property-updates.md)**
|
||||
|
||||
#### `win.setMaximizable(maximizable)` _macOS_ _Windows_
|
||||
|
||||
* `maximizable` Boolean
|
||||
@@ -1043,12 +1129,16 @@ On Linux always returns `true`.
|
||||
Sets whether the window can be manually maximized by user. On Linux does
|
||||
nothing.
|
||||
|
||||
**[Deprecated](modernization/property-updates.md)**
|
||||
|
||||
#### `win.isMaximizable()` _macOS_ _Windows_
|
||||
|
||||
Returns `Boolean` - Whether the window can be manually maximized by user.
|
||||
|
||||
On Linux always returns `true`.
|
||||
|
||||
**[Deprecated](modernization/property-updates.md)**
|
||||
|
||||
#### `win.setFullScreenable(fullscreenable)`
|
||||
|
||||
* `fullscreenable` Boolean
|
||||
@@ -1056,30 +1146,42 @@ On Linux always returns `true`.
|
||||
Sets whether the maximize/zoom window button toggles fullscreen mode or
|
||||
maximizes the window.
|
||||
|
||||
**[Deprecated](modernization/property-updates.md)**
|
||||
|
||||
#### `win.isFullScreenable()`
|
||||
|
||||
Returns `Boolean` - Whether the maximize/zoom window button toggles fullscreen mode or
|
||||
maximizes the window.
|
||||
|
||||
**[Deprecated](modernization/property-updates.md)**
|
||||
|
||||
#### `win.setClosable(closable)` _macOS_ _Windows_
|
||||
|
||||
* `closable` Boolean
|
||||
|
||||
Sets whether the window can be manually closed by user. On Linux does nothing.
|
||||
|
||||
**[Deprecated](modernization/property-updates.md)**
|
||||
|
||||
#### `win.isClosable()` _macOS_ _Windows_
|
||||
|
||||
Returns `Boolean` - Whether the window can be manually closed by user.
|
||||
|
||||
On Linux always returns `true`.
|
||||
|
||||
**[Deprecated](modernization/property-updates.md)**
|
||||
|
||||
#### `win.setAlwaysOnTop(flag[, level][, relativeLevel])`
|
||||
|
||||
* `flag` Boolean
|
||||
* `level` String (optional) _macOS_ - Values include `normal`, `floating`,
|
||||
`torn-off-menu`, `modal-panel`, `main-menu`, `status`, `pop-up-menu`,
|
||||
`screen-saver`, and ~~`dock`~~ (Deprecated). The default is `floating`. See the
|
||||
[macOS docs][window-levels] for more details.
|
||||
* `level` String (optional) _macOS_ _Windows_ - Values include `normal`,
|
||||
`floating`, `torn-off-menu`, `modal-panel`, `main-menu`, `status`,
|
||||
`pop-up-menu`, `screen-saver`, and ~~`dock`~~ (Deprecated). The default is
|
||||
`floating` when `flag` is true. The `level` is reset to `normal` when the
|
||||
flag is false. Note that from `floating` to `status` included, the window is
|
||||
placed below the Dock on macOS and below the taskbar on Windows. From
|
||||
`pop-up-menu` to a higher it is shown above the Dock on macOS and above the
|
||||
taskbar on Windows. See the [macOS docs][window-levels] for more details.
|
||||
* `relativeLevel` Integer (optional) _macOS_ - The number of layers higher to set
|
||||
this window relative to the given `level`. The default is `0`. Note that Apple
|
||||
discourages setting levels higher than 1 above `screen-saver`.
|
||||
@@ -1221,18 +1323,6 @@ Returns `Boolean` - Whether the window's document has been edited.
|
||||
|
||||
#### `win.blurWebView()`
|
||||
|
||||
#### `win.capturePage([rect, ]callback)`
|
||||
|
||||
* `rect` [Rectangle](structures/rectangle.md) (optional) - The bounds to capture
|
||||
* `callback` Function
|
||||
* `image` [NativeImage](native-image.md)
|
||||
|
||||
Captures a snapshot of the page within `rect`. Upon completion `callback` will
|
||||
be called with `callback(image)`. The `image` is an instance of [NativeImage](native-image.md)
|
||||
that stores data of the snapshot. Omitting `rect` will capture the whole visible page.
|
||||
|
||||
**[Deprecated Soon](modernization/promisification.md)**
|
||||
|
||||
#### `win.capturePage([rect])`
|
||||
|
||||
* `rect` [Rectangle](structures/rectangle.md) (optional) - The bounds to capture
|
||||
@@ -1245,11 +1335,11 @@ Captures a snapshot of the page within `rect`. Omitting `rect` will capture the
|
||||
|
||||
* `url` String
|
||||
* `options` Object (optional)
|
||||
* `httpReferrer` (String | [Referrer](structures/referrer.md)) (optional) - An HTTP Referrer url.
|
||||
* `httpReferrer` (String | [Referrer](structures/referrer.md)) (optional) - An HTTP Referrer URL.
|
||||
* `userAgent` String (optional) - A user agent originating the request.
|
||||
* `extraHeaders` String (optional) - Extra headers separated by "\n"
|
||||
* `postData` ([UploadRawData[]](structures/upload-raw-data.md) | [UploadFile[]](structures/upload-file.md) | [UploadBlob[]](structures/upload-blob.md)) (optional)
|
||||
* `baseURLForDataURL` String (optional) - Base url (with trailing path separator) for files to be loaded by the data url. This is needed only if the specified `url` is a data url and needs to load other files.
|
||||
* `baseURLForDataURL` String (optional) - Base URL (with trailing path separator) for files to be loaded by the data URL. This is needed only if the specified `url` is a data URL and needs to load other files.
|
||||
|
||||
Returns `Promise<void>` - the promise will resolve when the page has finished loading
|
||||
(see [`did-finish-load`](web-contents.md#event-did-finish-load)), and rejects
|
||||
@@ -1291,7 +1381,7 @@ win.loadURL('http://localhost:8000/post', {
|
||||
|
||||
* `filePath` String
|
||||
* `options` Object (optional)
|
||||
* `query` Object (optional) - Passed to `url.format()`.
|
||||
* `query` Record<String, String> (optional) - Passed to `url.format()`.
|
||||
* `search` String (optional) - Passed to `url.format()`.
|
||||
* `hash` String (optional) - Passed to `url.format()`.
|
||||
|
||||
@@ -1330,7 +1420,7 @@ Change to indeterminate mode when progress > 1.
|
||||
|
||||
On Linux platform, only supports Unity desktop environment, you need to specify
|
||||
the `*.desktop` file name to `desktopName` field in `package.json`. By default,
|
||||
it will assume `app.getName().desktop`.
|
||||
it will assume `{app.name}.desktop`.
|
||||
|
||||
On Windows, a mode can be passed. Accepted values are `none`, `normal`,
|
||||
`indeterminate`, `error`, and `paused`. If you call `setProgressBar` without a
|
||||
@@ -1361,11 +1451,13 @@ Returns `Boolean` - Whether the window has a shadow.
|
||||
|
||||
* `opacity` Number - between 0.0 (fully transparent) and 1.0 (fully opaque)
|
||||
|
||||
Sets the opacity of the window. On Linux does nothing.
|
||||
Sets the opacity of the window. On Linux, does nothing. Out of bound number
|
||||
values are clamped to the [0, 1] range.
|
||||
|
||||
#### `win.getOpacity()` _Windows_ _macOS_
|
||||
#### `win.getOpacity()`
|
||||
|
||||
Returns `Number` - between 0.0 (fully transparent) and 1.0 (fully opaque)
|
||||
Returns `Number` - between 0.0 (fully transparent) and 1.0 (fully opaque). On
|
||||
Linux, always returns 1.
|
||||
|
||||
#### `win.setShape(rects)` _Windows_ _Linux_ _Experimental_
|
||||
|
||||
@@ -1476,10 +1568,14 @@ menu bar will only show when users press the single `Alt` key.
|
||||
If the menu bar is already visible, calling `setAutoHideMenuBar(true)` won't
|
||||
hide it immediately.
|
||||
|
||||
**[Deprecated](modernization/property-updates.md)**
|
||||
|
||||
#### `win.isMenuBarAutoHide()`
|
||||
|
||||
Returns `Boolean` - Whether menu bar automatically hides itself.
|
||||
|
||||
**[Deprecated](modernization/property-updates.md)**
|
||||
|
||||
#### `win.setMenuBarVisibility(visible)` _Windows_ _Linux_
|
||||
|
||||
* `visible` Boolean
|
||||
@@ -1532,15 +1628,17 @@ Prevents the window contents from being captured by other apps.
|
||||
On macOS it sets the NSWindow's sharingType to NSWindowSharingNone.
|
||||
On Windows it calls SetWindowDisplayAffinity with `WDA_MONITOR`.
|
||||
|
||||
#### `win.setFocusable(focusable)` _Windows_
|
||||
#### `win.setFocusable(focusable)` _macOS_ _Windows_
|
||||
|
||||
* `focusable` Boolean
|
||||
|
||||
Changes whether the window can be focused.
|
||||
|
||||
On macOS it does not remove the focus from the window.
|
||||
|
||||
#### `win.setParentWindow(parent)`
|
||||
|
||||
* `parent` BrowserWindow
|
||||
* `parent` BrowserWindow | null
|
||||
|
||||
Sets `parent` as current window's parent window, passing `null` will turn
|
||||
current window into a top-level window.
|
||||
@@ -1592,16 +1690,19 @@ Adds a window as a tab on this window, after the tab for the window instance.
|
||||
|
||||
#### `win.setVibrancy(type)` _macOS_
|
||||
|
||||
* `type` String - Can be `appearance-based`, `light`, `dark`, `titlebar`,
|
||||
`selection`, `menu`, `popover`, `sidebar`, `medium-light` or `ultra-dark`. See
|
||||
* `type` String | null - Can be `appearance-based`, `light`, `dark`, `titlebar`,
|
||||
`selection`, `menu`, `popover`, `sidebar`, `medium-light`, `ultra-dark`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`, `tooltip`, `content`, `under-window`, or `under-page`. See
|
||||
the [macOS documentation][vibrancy-docs] for more details.
|
||||
|
||||
Adds a vibrancy effect to the browser window. Passing `null` or an empty string
|
||||
will remove the vibrancy effect on the window.
|
||||
|
||||
Note that `appearance-based`, `light`, `dark`, `medium-light`, and `ultra-dark` have been
|
||||
deprecated and will be removed in an upcoming version of macOS.
|
||||
|
||||
#### `win.setTouchBar(touchBar)` _macOS_ _Experimental_
|
||||
|
||||
* `touchBar` TouchBar
|
||||
* `touchBar` TouchBar | null
|
||||
|
||||
Sets the touchBar layout for the current window. Specifying `null` or
|
||||
`undefined` clears the touch bar. This method only has an effect if the
|
||||
@@ -1612,7 +1713,7 @@ removed in future Electron releases.
|
||||
|
||||
#### `win.setBrowserView(browserView)` _Experimental_
|
||||
|
||||
* `browserView` [BrowserView](browser-view.md). Attach browserView to win.
|
||||
* `browserView` [BrowserView](browser-view.md) | null - Attach browserView to win.
|
||||
If there is some other browserViews was attached they will be removed from
|
||||
this window.
|
||||
|
||||
@@ -1633,8 +1734,8 @@ Replacement API for setBrowserView supporting work with multi browser views.
|
||||
|
||||
#### `win.getBrowserViews()` _Experimental_
|
||||
|
||||
Returns array of `BrowserView` what was an attached with addBrowserView
|
||||
or setBrowserView.
|
||||
Returns `BrowserView[]` - an array of all BrowserViews that have been attached
|
||||
with `addBrowserView` or `setBrowserView`.
|
||||
|
||||
**Note:** The BrowserView API is currently experimental and may change or be
|
||||
removed in future Electron releases.
|
||||
@@ -1645,24 +1746,4 @@ removed in future Electron releases.
|
||||
[vibrancy-docs]: https://developer.apple.com/documentation/appkit/nsvisualeffectview?preferredLanguage=objc
|
||||
[window-levels]: https://developer.apple.com/documentation/appkit/nswindow/level
|
||||
[chrome-content-scripts]: https://developer.chrome.com/extensions/content_scripts#execution-environment
|
||||
|
||||
### Properties
|
||||
|
||||
#### `win.excludedFromShownWindowsMenu` _macOS_
|
||||
|
||||
A `Boolean` property that determines whether the window is excluded from the application’s Windows menu. `false` by default.
|
||||
|
||||
```js
|
||||
const win = new BrowserWindow({ height: 600, width: 600 })
|
||||
|
||||
const template = [
|
||||
{
|
||||
role: 'windowmenu'
|
||||
}
|
||||
]
|
||||
|
||||
win.excludedFromShownWindowsMenu = true
|
||||
|
||||
const menu = Menu.buildFromTemplate(template)
|
||||
Menu.setApplicationMenu(menu)
|
||||
```
|
||||
[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter
|
||||
|
||||
@@ -46,14 +46,14 @@ Forces the maximum disk space to be used by the disk cache, in bytes.
|
||||
|
||||
## --js-flags=`flags`
|
||||
|
||||
Specifies the flags passed to the Node JS engine. It has to be passed when starting
|
||||
Specifies the flags passed to the Node.js engine. It has to be passed when starting
|
||||
Electron if you want to enable the `flags` in the main process.
|
||||
|
||||
```sh
|
||||
$ electron --js-flags="--harmony_proxies --harmony_collections" your-app
|
||||
```
|
||||
|
||||
See the [Node documentation][node-cli] or run `node --help` in your terminal for a list of available flags. Additionally, run `node --v8-options` to see a list of flags that specifically refer to Node's V8 JavaScript engine.
|
||||
See the [Node.js documentation][node-cli] or run `node --help` in your terminal for a list of available flags. Additionally, run `node --v8-options` to see a list of flags that specifically refer to Node.js's V8 JavaScript engine.
|
||||
|
||||
## --proxy-server=`address:port`
|
||||
|
||||
@@ -122,12 +122,12 @@ For example:
|
||||
```
|
||||
|
||||
then any `url` ending with `example.com`, `foobar.com`, `baz` will be considered
|
||||
for integrated authentication. Without `*` prefix the url has to match exactly.
|
||||
for integrated authentication. Without `*` prefix the URL has to match exactly.
|
||||
|
||||
## --auth-negotiate-delegate-whitelist=`url`
|
||||
|
||||
A comma-separated list of servers for which delegation of user credentials is required.
|
||||
Without `*` prefix the url has to match exactly.
|
||||
Without `*` prefix the URL has to match exactly.
|
||||
|
||||
## --ignore-certificate-errors
|
||||
|
||||
@@ -181,6 +181,11 @@ logging level for all code in the source files under a `foo/bar` directory.
|
||||
|
||||
This switch only works when `--enable-logging` is also passed.
|
||||
|
||||
## --no-sandbox
|
||||
|
||||
Disables Chromium sandbox, which is now enabled by default.
|
||||
Should only be used for testing.
|
||||
|
||||
[app]: app.md
|
||||
[append-switch]: app.md#appcommandlineappendswitchswitch-value
|
||||
[ready]: app.md#event-ready
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
`ClientRequest` implements the [Writable Stream](https://nodejs.org/api/stream.html#stream_writable_streams)
|
||||
interface and is therefore an [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter).
|
||||
interface and is therefore an [EventEmitter][event-emitter].
|
||||
|
||||
### `new ClientRequest(options)`
|
||||
|
||||
@@ -16,7 +16,7 @@ following properties:
|
||||
method.
|
||||
* `url` String (optional) - The request URL. Must be provided in the absolute
|
||||
form with the protocol scheme specified as http or https.
|
||||
* `session` Object (optional) - The [`Session`](session.md) instance with
|
||||
* `session` Session (optional) - The [`Session`](session.md) instance with
|
||||
which the request is associated.
|
||||
* `partition` String (optional) - The name of the [`partition`](session.md)
|
||||
with which the request is associated. Defaults to the empty string. The
|
||||
@@ -134,7 +134,7 @@ Returns:
|
||||
* `statusCode` Integer
|
||||
* `method` String
|
||||
* `redirectUrl` String
|
||||
* `responseHeaders` Object
|
||||
* `responseHeaders` Record<String, String[]>
|
||||
|
||||
Emitted when there is redirection and the mode is `manual`. Calling
|
||||
[`request.followRedirect`](#requestfollowredirect) will continue with the redirection.
|
||||
@@ -158,9 +158,9 @@ internally buffered inside Electron process memory.
|
||||
#### `request.setHeader(name, value)`
|
||||
|
||||
* `name` String - An extra HTTP header name.
|
||||
* `value` Object - An extra HTTP header value.
|
||||
* `value` String - An extra HTTP header value.
|
||||
|
||||
Adds an extra HTTP header. The header name will issued as it is without
|
||||
Adds an extra HTTP header. The header name will be issued as-is without
|
||||
lowercasing. It can be called only before first write. Calling this method after
|
||||
the first write will throw an error. If the passed value is not a `String`, its
|
||||
`toString()` method will be called to obtain the final value.
|
||||
@@ -169,7 +169,7 @@ the first write will throw an error. If the passed value is not a `String`, its
|
||||
|
||||
* `name` String - Specify an extra header name.
|
||||
|
||||
Returns `Object` - The value of a previously set extra header name.
|
||||
Returns `String` - The value of a previously set extra header name.
|
||||
|
||||
#### `request.removeHeader(name)`
|
||||
|
||||
@@ -229,3 +229,5 @@ no other properties will be set
|
||||
|
||||
You can use this method in conjunction with `POST` requests to get the progress
|
||||
of a file upload or other data transfer.
|
||||
|
||||
[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter
|
||||
|
||||
@@ -4,12 +4,18 @@
|
||||
|
||||
Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process)
|
||||
|
||||
The following example shows how to write a string to the clipboard:
|
||||
|
||||
```javascript
|
||||
const { clipboard } = require('electron')
|
||||
clipboard.writeText('Example String')
|
||||
```
|
||||
|
||||
On Linux, there is also a `selection` clipboard. To manipulate it
|
||||
you need to pass `selection` to each method:
|
||||
|
||||
```javascript
|
||||
const { clipboard } = require('electron')
|
||||
|
||||
clipboard.writeText('Example String', 'selection')
|
||||
console.log(clipboard.readText('selection'))
|
||||
```
|
||||
@@ -22,106 +28,56 @@ The `clipboard` module has the following methods:
|
||||
|
||||
### `clipboard.readText([type])`
|
||||
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
|
||||
|
||||
Returns `String` - The content in the clipboard as plain text.
|
||||
|
||||
```js
|
||||
const { clipboard } = require('electron')
|
||||
|
||||
clipboard.writeText('hello i am a bit of text!')
|
||||
|
||||
const text = clipboard.readText()
|
||||
console.log(text)
|
||||
// hello i am a bit of text!'
|
||||
```
|
||||
|
||||
### `clipboard.writeText(text[, type])`
|
||||
|
||||
* `text` String
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
|
||||
|
||||
Writes the `text` into the clipboard as plain text.
|
||||
|
||||
```js
|
||||
const { clipboard } = require('electron')
|
||||
|
||||
const text = 'hello i am a bit of text!'
|
||||
clipboard.writeText(text)
|
||||
```
|
||||
|
||||
### `clipboard.readHTML([type])`
|
||||
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
|
||||
|
||||
Returns `String` - The content in the clipboard as markup.
|
||||
|
||||
```js
|
||||
const { clipboard } = require('electron')
|
||||
|
||||
clipboard.writeHTML('<b>Hi</b>')
|
||||
const html = clipboard.readHTML()
|
||||
|
||||
console.log(html)
|
||||
// <meta charset='utf-8'><b>Hi</b>
|
||||
```
|
||||
|
||||
### `clipboard.writeHTML(markup[, type])`
|
||||
|
||||
* `markup` String
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
|
||||
|
||||
Writes `markup` to the clipboard.
|
||||
|
||||
```js
|
||||
const { clipboard } = require('electron')
|
||||
|
||||
clipboard.writeHTML('<b>Hi</b')
|
||||
```
|
||||
|
||||
### `clipboard.readImage([type])`
|
||||
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
|
||||
|
||||
Returns [`NativeImage`](native-image.md) - The image content in the clipboard.
|
||||
|
||||
### `clipboard.writeImage(image[, type])`
|
||||
|
||||
* `image` [NativeImage](native-image.md)
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
|
||||
|
||||
Writes `image` to the clipboard.
|
||||
|
||||
### `clipboard.readRTF([type])`
|
||||
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
|
||||
|
||||
Returns `String` - The content in the clipboard as RTF.
|
||||
|
||||
```js
|
||||
const { clipboard } = require('electron')
|
||||
|
||||
clipboard.writeRTF('{\\rtf1\\ansi{\\fonttbl\\f0\\fswiss Helvetica;}\\f0\\pard\nThis is some {\\b bold} text.\\par\n}')
|
||||
|
||||
const rtf = clipboard.readRTF()
|
||||
console.log(rtf)
|
||||
// {\\rtf1\\ansi{\\fonttbl\\f0\\fswiss Helvetica;}\\f0\\pard\nThis is some {\\b bold} text.\\par\n}
|
||||
```
|
||||
|
||||
### `clipboard.writeRTF(text[, type])`
|
||||
|
||||
* `text` String
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
|
||||
|
||||
Writes the `text` into the clipboard in RTF.
|
||||
|
||||
```js
|
||||
const { clipboard } = require('electron')
|
||||
|
||||
const rtf = '{\\rtf1\\ansi{\\fonttbl\\f0\\fswiss Helvetica;}\\f0\\pard\nThis is some {\\b bold} text.\\par\n}'
|
||||
clipboard.writeRTF(rtf)
|
||||
```
|
||||
|
||||
### `clipboard.readBookmark()` _macOS_ _Windows_
|
||||
|
||||
Returns `Object`:
|
||||
@@ -137,7 +93,7 @@ bookmark is unavailable.
|
||||
|
||||
* `title` String
|
||||
* `url` String
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
|
||||
|
||||
Writes the `title` and `url` into the clipboard as a bookmark.
|
||||
|
||||
@@ -146,9 +102,7 @@ you can use `clipboard.write` to write both a bookmark and fallback text to the
|
||||
clipboard.
|
||||
|
||||
```js
|
||||
const { clipboard } = require('electron')
|
||||
|
||||
clipboard.writeBookmark({
|
||||
clipboard.write({
|
||||
text: 'https://electronjs.org',
|
||||
bookmark: 'Electron Homepage'
|
||||
})
|
||||
@@ -156,50 +110,39 @@ clipboard.writeBookmark({
|
||||
|
||||
### `clipboard.readFindText()` _macOS_
|
||||
|
||||
Returns `String` - The text on the find pasteboard, which is the pasteboard that holds information about the current state of the active application’s find panel.
|
||||
|
||||
This method uses synchronous IPC when called from the renderer process.
|
||||
The cached value is reread from the find pasteboard whenever the application is activated.
|
||||
Returns `String` - The text on the find pasteboard. This method uses synchronous
|
||||
IPC when called from the renderer process. The cached value is reread from the
|
||||
find pasteboard whenever the application is activated.
|
||||
|
||||
### `clipboard.writeFindText(text)` _macOS_
|
||||
|
||||
* `text` String
|
||||
|
||||
Writes the `text` into the find pasteboard (the pasteboard that holds information about the current state of the active application’s find panel) as plain text. This method uses synchronous IPC when called from the renderer process.
|
||||
Writes the `text` into the find pasteboard as plain text. This method uses
|
||||
synchronous IPC when called from the renderer process.
|
||||
|
||||
### `clipboard.clear([type])`
|
||||
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
|
||||
|
||||
Clears the clipboard content.
|
||||
|
||||
### `clipboard.availableFormats([type])`
|
||||
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
|
||||
|
||||
Returns `String[]` - An array of supported formats for the clipboard `type`.
|
||||
|
||||
```js
|
||||
const { clipboard } = require('electron')
|
||||
|
||||
const formats = clipboard.availableFormats()
|
||||
console.log(formats)
|
||||
// [ 'text/plain', 'text/html' ]
|
||||
```
|
||||
|
||||
### `clipboard.has(format[, type])` _Experimental_
|
||||
|
||||
* `format` String
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
|
||||
|
||||
Returns `Boolean` - Whether the clipboard supports the specified `format`.
|
||||
|
||||
```js
|
||||
```javascript
|
||||
const { clipboard } = require('electron')
|
||||
|
||||
const hasFormat = clipboard.has('<p>selection</p>')
|
||||
console.log(hasFormat)
|
||||
// 'true' or 'false
|
||||
console.log(clipboard.has('<p>selection</p>'))
|
||||
```
|
||||
|
||||
### `clipboard.read(format)` _Experimental_
|
||||
@@ -214,33 +157,14 @@ Returns `String` - Reads `format` type from the clipboard.
|
||||
|
||||
Returns `Buffer` - Reads `format` type from the clipboard.
|
||||
|
||||
```js
|
||||
const { clipboard } = require('electron')
|
||||
|
||||
const buffer = Buffer.from('this is binary', 'utf8')
|
||||
clipboard.writeBuffer('public.utf8-plain-text', buffer)
|
||||
|
||||
const ret = clipboard.readBuffer('public.utf8-plain-text')
|
||||
|
||||
console.log(buffer.equals(out))
|
||||
// true
|
||||
```
|
||||
|
||||
### `clipboard.writeBuffer(format, buffer[, type])` _Experimental_
|
||||
|
||||
* `format` String
|
||||
* `buffer` Buffer
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
|
||||
|
||||
Writes the `buffer` into the clipboard as `format`.
|
||||
|
||||
```js
|
||||
const { clipboard } = require('electron')
|
||||
|
||||
const buffer = Buffer.from('writeBuffer', 'utf8')
|
||||
clipboard.writeBuffer('public.utf8-plain-text', buffer)
|
||||
```
|
||||
|
||||
### `clipboard.write(data[, type])`
|
||||
|
||||
* `data` Object
|
||||
@@ -249,29 +173,10 @@ clipboard.writeBuffer('public.utf8-plain-text', buffer)
|
||||
* `image` [NativeImage](native-image.md) (optional)
|
||||
* `rtf` String (optional)
|
||||
* `bookmark` String (optional) - The title of the URL at `text`.
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
|
||||
|
||||
Writes `data` to the clipboard.
|
||||
|
||||
```js
|
||||
```javascript
|
||||
const { clipboard } = require('electron')
|
||||
|
||||
clipboard.write({
|
||||
text: 'test',
|
||||
html: '<b>Hi</b>',
|
||||
rtf: '{\\rtf1\\utf8 text}',
|
||||
bookmark: 'a title'
|
||||
})
|
||||
|
||||
console.log(clipboard.readText())
|
||||
// 'test'
|
||||
|
||||
console.log(clipboard.readHTML())
|
||||
// <meta charset='utf-8'><b>Hi</b>
|
||||
|
||||
console.log(clipboard.readRTF())
|
||||
// '{\\rtf1\\utf8 text}'
|
||||
|
||||
console.log(clipboard.readBookmark())
|
||||
// { title: 'a title', url: 'test' }
|
||||
clipboard.write({ text: 'test', html: '<b>test</b>' })
|
||||
```
|
||||
Writes `data` to the clipboard.
|
||||
|
||||
54
docs/api/command-line.md
Normal file
54
docs/api/command-line.md
Normal file
@@ -0,0 +1,54 @@
|
||||
## Class: CommandLine
|
||||
|
||||
> Manipulate the command line arguments for your app that Chromium reads
|
||||
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
The following example shows how to check if the `--disable-gpu` flag is set.
|
||||
|
||||
```javascript
|
||||
const { app } = require('electron')
|
||||
app.commandLine.hasSwitch('disable-gpu')
|
||||
```
|
||||
|
||||
For more information on what kinds of flags and switches you can use, check
|
||||
out the [Chrome Command Line Switches](./chrome-command-line-switches.md)
|
||||
document.
|
||||
|
||||
### Instance Methods
|
||||
|
||||
#### `commandLine.appendSwitch(switch[, value])`
|
||||
|
||||
* `switch` String - A command-line switch, without the leading `--`
|
||||
* `value` String (optional) - A value for the given switch
|
||||
|
||||
Append a switch (with optional `value`) to Chromium's command line.
|
||||
|
||||
**Note:** This will not affect `process.argv`. The intended usage of this function is to
|
||||
control Chromium's behavior.
|
||||
|
||||
#### `commandLine.appendArgument(value)`
|
||||
|
||||
* `value` String - The argument to append to the command line
|
||||
|
||||
Append an argument to Chromium's command line. The argument will be quoted
|
||||
correctly. Switches will precede arguments regardless of appending order.
|
||||
|
||||
If you're appending an argument like `--switch=value`, consider using `appendSwitch('switch', 'value')` instead.
|
||||
|
||||
**Note:** This will not affect `process.argv`. The intended usage of this function is to
|
||||
control Chromium's behavior.
|
||||
|
||||
#### `commandLine.hasSwitch(switch)`
|
||||
|
||||
* `switch` String - A command-line switch
|
||||
|
||||
Returns `Boolean` - Whether the command-line switch is present.
|
||||
|
||||
#### `commandLine.getSwitchValue(switch)`
|
||||
|
||||
* `switch` String - A command-line switch
|
||||
|
||||
Returns `String` - The command-line switch value.
|
||||
|
||||
**Note:** When the switch is not present or has no value, it returns empty string.
|
||||
@@ -1,13 +1,11 @@
|
||||
# contentTracing
|
||||
|
||||
> Collect tracing data from Chromium's content module for finding performance
|
||||
bottlenecks and slow operations.
|
||||
> Collect tracing data from Chromium to find performance bottlenecks and slow operations.
|
||||
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
This module does not include a web interface so you need to open
|
||||
`chrome://tracing/` in a Chrome browser and load the generated file to view the
|
||||
result.
|
||||
This module does not include a web interface. To view recorded traces, use
|
||||
[trace viewer][], available at `chrome://tracing` in Chrome.
|
||||
|
||||
**Note:** You should not use this module until the `ready` event of the app
|
||||
module is emitted.
|
||||
@@ -16,20 +14,15 @@ module is emitted.
|
||||
const { app, contentTracing } = require('electron')
|
||||
|
||||
app.on('ready', () => {
|
||||
const options = {
|
||||
categoryFilter: '*',
|
||||
traceOptions: 'record-until-full,enable-sampling'
|
||||
}
|
||||
|
||||
contentTracing.startRecording(options, () => {
|
||||
(async () => {
|
||||
await contentTracing.startRecording({
|
||||
include_categories: ['*']
|
||||
})
|
||||
console.log('Tracing started')
|
||||
|
||||
setTimeout(() => {
|
||||
contentTracing.stopRecording('', (path) => {
|
||||
console.log('Tracing data recorded to ' + path)
|
||||
})
|
||||
}, 5000)
|
||||
})
|
||||
await new Promise(resolve => setTimeout(resolve, 5000))
|
||||
const path = await contentTracing.stopRecording()
|
||||
console.log('Tracing data recorded to ' + path)
|
||||
})()
|
||||
})
|
||||
```
|
||||
|
||||
@@ -37,40 +30,17 @@ app.on('ready', () => {
|
||||
|
||||
The `contentTracing` module has the following methods:
|
||||
|
||||
### `contentTracing.getCategories(callback)`
|
||||
|
||||
* `callback` Function
|
||||
* `categories` String[]
|
||||
|
||||
Get a set of category groups. The category groups can change as new code paths are reached.
|
||||
|
||||
Once all child processes have acknowledged the `getCategories` request the `callback` is invoked with an array of category groups.
|
||||
|
||||
**[Deprecated Soon](modernization/promisification.md)**
|
||||
|
||||
### `contentTracing.getCategories()`
|
||||
|
||||
Returns `Promise<String[]>` - resolves with an array of category groups once all child processes have acknowledged the `getCategories` request
|
||||
|
||||
Get a set of category groups. The category groups can change as new code paths are reached.
|
||||
|
||||
|
||||
### `contentTracing.startRecording(options, callback)`
|
||||
|
||||
* `options` ([TraceCategoriesAndOptions](structures/trace-categories-and-options.md) | [TraceConfig](structures/trace-config.md))
|
||||
* `callback` Function
|
||||
|
||||
Start recording on all processes.
|
||||
|
||||
Recording begins immediately locally and asynchronously on child processes
|
||||
as soon as they receive the EnableRecording request. The `callback` will be
|
||||
called once all child processes have acknowledged the `startRecording` request.
|
||||
|
||||
**[Deprecated Soon](modernization/promisification.md)**
|
||||
Get a set of category groups. The category groups can change as new code paths
|
||||
are reached. See also the [list of built-in tracing
|
||||
categories](https://chromium.googlesource.com/chromium/src/+/master/base/trace_event/builtin_categories.h).
|
||||
|
||||
### `contentTracing.startRecording(options)`
|
||||
|
||||
* `options` ([TraceCategoriesAndOptions](structures/trace-categories-and-options.md) | [TraceConfig](structures/trace-config.md))
|
||||
* `options` ([TraceConfig](structures/trace-config.md) | [TraceCategoriesAndOptions](structures/trace-categories-and-options.md))
|
||||
|
||||
Returns `Promise<void>` - resolved once all child processes have acknowledged the `startRecording` request.
|
||||
|
||||
@@ -79,62 +49,35 @@ Start recording on all processes.
|
||||
Recording begins immediately locally and asynchronously on child processes
|
||||
as soon as they receive the EnableRecording request.
|
||||
|
||||
### `contentTracing.stopRecording(resultFilePath, callback)`
|
||||
If a recording is already running, the promise will be immediately resolved, as
|
||||
only one trace operation can be in progress at a time.
|
||||
|
||||
* `resultFilePath` String
|
||||
* `callback` Function
|
||||
* `resultFilePath` String
|
||||
### `contentTracing.stopRecording([resultFilePath])`
|
||||
|
||||
* `resultFilePath` String (optional)
|
||||
|
||||
Returns `Promise<String>` - resolves with a path to a file that contains the traced data once all child processes have acknowledged the `stopRecording` request
|
||||
|
||||
Stop recording on all processes.
|
||||
|
||||
Child processes typically cache trace data and only rarely flush and send
|
||||
trace data back to the main process. This helps to minimize the runtime overhead
|
||||
of tracing since sending trace data over IPC can be an expensive operation. So,
|
||||
to end tracing, we must asynchronously ask all child processes to flush any
|
||||
to end tracing, Chromium asynchronously asks all child processes to flush any
|
||||
pending trace data.
|
||||
|
||||
Once all child processes have acknowledged the `stopRecording` request,
|
||||
`callback` will be called with a file that contains the traced data.
|
||||
|
||||
Trace data will be written into `resultFilePath` if it is not empty or into a
|
||||
temporary file. The actual file path will be passed to `callback` if it's not
|
||||
`null`.
|
||||
|
||||
**[Deprecated Soon](modernization/promisification.md)**
|
||||
|
||||
### `contentTracing.stopRecording(resultFilePath)`
|
||||
|
||||
* `resultFilePath` String
|
||||
|
||||
Returns `Promise<String>` - resolves with a file that contains the traced data once all child processes have acknowledged the `stopRecording` request
|
||||
|
||||
Stop recording on all processes.
|
||||
|
||||
Child processes typically cache trace data and only rarely flush and send
|
||||
trace data back to the main process. This helps to minimize the runtime overhead
|
||||
of tracing since sending trace data over IPC can be an expensive operation. So,
|
||||
to end tracing, we must asynchronously ask all child processes to flush any
|
||||
pending trace data.
|
||||
|
||||
Trace data will be written into `resultFilePath` if it is not empty or into a
|
||||
temporary file.
|
||||
|
||||
### `contentTracing.getTraceBufferUsage(callback)`
|
||||
|
||||
* `callback` Function
|
||||
* Object
|
||||
* `value` Number
|
||||
* `percentage` Number
|
||||
|
||||
Get the maximum usage across processes of trace buffer as a percentage of the
|
||||
full state. When the TraceBufferUsage value is determined the `callback` is
|
||||
called.
|
||||
|
||||
**[Deprecated Soon](modernization/promisification.md)**
|
||||
Trace data will be written into `resultFilePath`. If `resultFilePath` is empty
|
||||
or not provided, trace data will be written to a temporary file, and the path
|
||||
will be returned in the promise.
|
||||
|
||||
### `contentTracing.getTraceBufferUsage()`
|
||||
|
||||
Returns `Promise<Object>` - Resolves with an object containing the `value` and `percentage` of trace buffer maximum usage
|
||||
|
||||
* `value` Number
|
||||
* `percentage` Number
|
||||
|
||||
Get the maximum usage across processes of trace buffer as a percentage of the
|
||||
full state.
|
||||
|
||||
[trace viewer]: https://github.com/catapult-project/catapult/blob/master/tracing
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user