mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
Compare commits
807 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7514372e79 | ||
|
|
151a338956 | ||
|
|
d57293503d | ||
|
|
c4009760c7 | ||
|
|
3408997289 | ||
|
|
9ca2b31b7c | ||
|
|
5aa0a1a77a | ||
|
|
3825bf0b6d | ||
|
|
d15bcfb1ed | ||
|
|
ccb051caf7 | ||
|
|
3284aabd48 | ||
|
|
6d575f80fa | ||
|
|
b91dcfb314 | ||
|
|
321e66d0cc | ||
|
|
81eedb6efa | ||
|
|
b08dc0f7e6 | ||
|
|
11c1c255bf | ||
|
|
c89bab9730 | ||
|
|
5ffe634824 | ||
|
|
3ad9fb1473 | ||
|
|
b0298cca2e | ||
|
|
ed8ab7e9ad | ||
|
|
c75726f9ef | ||
|
|
ff7e22c675 | ||
|
|
946c11145c | ||
|
|
ffd2224bbe | ||
|
|
c326de860d | ||
|
|
145aa919ca | ||
|
|
2cc55fee5e | ||
|
|
119e8bec93 | ||
|
|
82f91b7efa | ||
|
|
900feef89f | ||
|
|
c58d39e71b | ||
|
|
48f190690e | ||
|
|
faa308c88c | ||
|
|
9619688706 | ||
|
|
a724aced43 | ||
|
|
9a9f7af971 | ||
|
|
0184ccd019 | ||
|
|
cdd8021509 | ||
|
|
1e31bfe287 | ||
|
|
7304af93ed | ||
|
|
69f6a44e81 | ||
|
|
354b32a9fc | ||
|
|
d5bb0e968f | ||
|
|
9e12e8c63f | ||
|
|
ebcd094222 | ||
|
|
5dd735f5b3 | ||
|
|
46841d7373 | ||
|
|
707f110c0f | ||
|
|
0e5d181cc9 | ||
|
|
f3a2c27840 | ||
|
|
0032a5247f | ||
|
|
ef38019122 | ||
|
|
e280ae11b8 | ||
|
|
14602f55d5 | ||
|
|
27b4335084 | ||
|
|
a1c1012cc4 | ||
|
|
821b88e420 | ||
|
|
d90934517d | ||
|
|
2f765ac897 | ||
|
|
d25be9cf75 | ||
|
|
1b8a25bb81 | ||
|
|
361e5b2c55 | ||
|
|
7912ea5950 | ||
|
|
5b34f9bcc9 | ||
|
|
766cfc1f4c | ||
|
|
3e999ca127 | ||
|
|
c8f80baeea | ||
|
|
d527192c49 | ||
|
|
6a93200099 | ||
|
|
2f31302b75 | ||
|
|
2cb7b6bbf3 | ||
|
|
ba00be3798 | ||
|
|
c55f806191 | ||
|
|
de9eb14d46 | ||
|
|
cf390c0efb | ||
|
|
2c9b4d1def | ||
|
|
104ec2ba12 | ||
|
|
78a2a2f18d | ||
|
|
4d620f0a11 | ||
|
|
d483a135f5 | ||
|
|
7990d9b81e | ||
|
|
2b28ed4fc6 | ||
|
|
51c5882f4c | ||
|
|
1aae1c11e3 | ||
|
|
00cfedbfd8 | ||
|
|
7e3ff0f7d2 | ||
|
|
47f005f730 | ||
|
|
4f3d6117cd | ||
|
|
119382b55e | ||
|
|
8cf0e8ed5c | ||
|
|
fce543d725 | ||
|
|
8fb7481298 | ||
|
|
9cdb5eda89 | ||
|
|
c0f307e49c | ||
|
|
e8df32f354 | ||
|
|
5c68870ad7 | ||
|
|
f3f1f6b712 | ||
|
|
4ecb96e8d7 | ||
|
|
5343ccf10b | ||
|
|
cbb9c4323c | ||
|
|
be9f302af6 | ||
|
|
180a4f34c2 | ||
|
|
b1bfc74ecb | ||
|
|
bc7d2378df | ||
|
|
e31d3b52ee | ||
|
|
277373a95a | ||
|
|
d9e9bf9b87 | ||
|
|
3396d08a3b | ||
|
|
c76872f3f9 | ||
|
|
c7175b295a | ||
|
|
2ff3a15326 | ||
|
|
a6806e9e1c | ||
|
|
200051ccc0 | ||
|
|
36726bd70f | ||
|
|
9755288527 | ||
|
|
39e380bb66 | ||
|
|
4bdf7674f9 | ||
|
|
cfe8c3efd8 | ||
|
|
46b420158c | ||
|
|
9010ee340c | ||
|
|
f1de4896d4 | ||
|
|
9bbd1074ea | ||
|
|
bb3c08f306 | ||
|
|
203c4a72b5 | ||
|
|
cf504fc1bf | ||
|
|
38c3e61a78 | ||
|
|
337e82a4c0 | ||
|
|
a482d4e288 | ||
|
|
c1cdc38e33 | ||
|
|
38865f46d2 | ||
|
|
e290438a6d | ||
|
|
355d395b00 | ||
|
|
9a5b041f74 | ||
|
|
5395810c45 | ||
|
|
a91054883f | ||
|
|
0459dc7d6f | ||
|
|
28c7b5f0ab | ||
|
|
b7018da0c1 | ||
|
|
bdd272192c | ||
|
|
d9faf76cb5 | ||
|
|
52db4693e8 | ||
|
|
b362a59173 | ||
|
|
e8e4b19348 | ||
|
|
e674061bab | ||
|
|
77b3d218a4 | ||
|
|
364dac53d4 | ||
|
|
29b9281af4 | ||
|
|
4d2815e56b | ||
|
|
302372f4b4 | ||
|
|
bbd72e5658 | ||
|
|
3db0a8ef73 | ||
|
|
1a2df2f309 | ||
|
|
d5c37c301a | ||
|
|
eabc5166ac | ||
|
|
88a5abca4b | ||
|
|
f6b6f9524e | ||
|
|
645b98d81a | ||
|
|
c605d1a044 | ||
|
|
df1d39d6ec | ||
|
|
5f08a4f8be | ||
|
|
cc9c84cad4 | ||
|
|
25e6eb9d04 | ||
|
|
b4bd96b2ca | ||
|
|
4ba51dbad8 | ||
|
|
5a8af35927 | ||
|
|
a4babe6699 | ||
|
|
c1ea592457 | ||
|
|
225264f06b | ||
|
|
30cc82d265 | ||
|
|
14c39620f0 | ||
|
|
b395a66246 | ||
|
|
04158b15bb | ||
|
|
8b5f26a9f0 | ||
|
|
c65e9079cc | ||
|
|
91a67e4867 | ||
|
|
4079787378 | ||
|
|
0dc9e32039 | ||
|
|
28c7b346db | ||
|
|
c4f993add1 | ||
|
|
bb21822c10 | ||
|
|
124bb2910f | ||
|
|
0f54df5867 | ||
|
|
2bd1a7ec1e | ||
|
|
ee97b0864a | ||
|
|
96e0dfcae9 | ||
|
|
379a7b707b | ||
|
|
3963ee6d1d | ||
|
|
64cd5bf3a5 | ||
|
|
05074bae0c | ||
|
|
174a39be8f | ||
|
|
918e3ce0b6 | ||
|
|
9c0eca1d8b | ||
|
|
26e0a7d922 | ||
|
|
a498e0c033 | ||
|
|
0f66918825 | ||
|
|
050b866b6a | ||
|
|
8115a899df | ||
|
|
3dcb7cfef9 | ||
|
|
502f24e50d | ||
|
|
6ebef9d876 | ||
|
|
60af6c2791 | ||
|
|
6d76da55e2 | ||
|
|
b31057ca16 | ||
|
|
16dfa56c77 | ||
|
|
a7ed504575 | ||
|
|
dc4c32972d | ||
|
|
d1d0efbd07 | ||
|
|
afa684ad45 | ||
|
|
f66d21e426 | ||
|
|
9a68ce87eb | ||
|
|
ecb737760c | ||
|
|
5d32cd0269 | ||
|
|
499efd5ee7 | ||
|
|
c4115ed783 | ||
|
|
969a97b54f | ||
|
|
5be0851434 | ||
|
|
233d346d5a | ||
|
|
a879981dfb | ||
|
|
3d90bd4e8e | ||
|
|
ba1dd09be2 | ||
|
|
80aa832ebd | ||
|
|
a950e1d040 | ||
|
|
4d7ddcd750 | ||
|
|
d6612d230b | ||
|
|
1d9abfdb10 | ||
|
|
871ba507a6 | ||
|
|
5d64df141b | ||
|
|
ae846204cb | ||
|
|
6dcf5c5c79 | ||
|
|
e55a9b35b6 | ||
|
|
ae85864959 | ||
|
|
5cc0539919 | ||
|
|
b070774f5c | ||
|
|
7a8548d48f | ||
|
|
ac172abda7 | ||
|
|
29e5195c63 | ||
|
|
3926d9d717 | ||
|
|
fd8b9450ee | ||
|
|
34ac68c4a8 | ||
|
|
f3e30c7ae3 | ||
|
|
0b85fb7ea2 | ||
|
|
58a6fe13d6 | ||
|
|
92b9525cfd | ||
|
|
1918e76913 | ||
|
|
ff9b23ebe5 | ||
|
|
c0f6a44e39 | ||
|
|
3828e2a53a | ||
|
|
be69192a61 | ||
|
|
8c1b5311fd | ||
|
|
6d4480ea6b | ||
|
|
1fe4b3fa28 | ||
|
|
f115376595 | ||
|
|
8122dd2c33 | ||
|
|
d2c0f9f754 | ||
|
|
03d499bf34 | ||
|
|
5e043812ef | ||
|
|
7764ca7209 | ||
|
|
ded316cd5e | ||
|
|
4b45a5fc6d | ||
|
|
078d518e36 | ||
|
|
212d858bf4 | ||
|
|
3faf2480e0 | ||
|
|
55d5b02f87 | ||
|
|
8fa33ba120 | ||
|
|
826f1cb90c | ||
|
|
ed5a865efb | ||
|
|
90b6d13714 | ||
|
|
85333a5974 | ||
|
|
5f941c5180 | ||
|
|
06a5ade3c6 | ||
|
|
374406375b | ||
|
|
4089620729 | ||
|
|
1de0152b6b | ||
|
|
94246d428b | ||
|
|
3b88dd6ef7 | ||
|
|
2cbf3080d0 | ||
|
|
d0621db8fd | ||
|
|
6f9ff39728 | ||
|
|
a64cf5514f | ||
|
|
93fbb6c092 | ||
|
|
600c3f2c2f | ||
|
|
deff96a1b0 | ||
|
|
b03daaebe4 | ||
|
|
4ddd337a64 | ||
|
|
a64a0fa88e | ||
|
|
c0cf065c1a | ||
|
|
96b2623887 | ||
|
|
e0d277e667 | ||
|
|
485bbd9ccb | ||
|
|
d228bdfb9e | ||
|
|
70887ae21a | ||
|
|
96f9611cf4 | ||
|
|
ef80cc3d56 | ||
|
|
0d9de7deaf | ||
|
|
96ca070c3a | ||
|
|
8948e27ced | ||
|
|
30e5e993c1 | ||
|
|
fd7b49b32b | ||
|
|
d36a6de25c | ||
|
|
d01db5a656 | ||
|
|
7d5cd2051a | ||
|
|
95ed3238be | ||
|
|
02e41b41b2 | ||
|
|
cd25ddeb06 | ||
|
|
7df531bc4e | ||
|
|
6cba2c50a2 | ||
|
|
dbc5f67dca | ||
|
|
7d71ad6f91 | ||
|
|
0e27f133d7 | ||
|
|
b965e54efc | ||
|
|
a9ac75c1f9 | ||
|
|
033efdcaa1 | ||
|
|
51961fccfa | ||
|
|
ac65f38842 | ||
|
|
0b0679e065 | ||
|
|
3ca87d205f | ||
|
|
dacf7f8bdc | ||
|
|
2cca0f9bb7 | ||
|
|
441c9ce376 | ||
|
|
902c239fdf | ||
|
|
9e6726f304 | ||
|
|
329d45562b | ||
|
|
83b44b735f | ||
|
|
3417c42bfd | ||
|
|
7f4064af16 | ||
|
|
ace11f9bc8 | ||
|
|
cd91440e47 | ||
|
|
5e5c71e1d7 | ||
|
|
7d4a1223fd | ||
|
|
98d0daa2fd | ||
|
|
f105c84349 | ||
|
|
720197f9c8 | ||
|
|
4d0b2ac9be | ||
|
|
1f2b02c18f | ||
|
|
32d98851bc | ||
|
|
82fc099602 | ||
|
|
34c1727cb3 | ||
|
|
23d44e322d | ||
|
|
8e2ab8b20b | ||
|
|
05755ba202 | ||
|
|
0881fd6397 | ||
|
|
52e257668d | ||
|
|
df62e78b71 | ||
|
|
dcb670fa46 | ||
|
|
134792a594 | ||
|
|
71f542d8f6 | ||
|
|
52fe92d02e | ||
|
|
92ddfd0d4c | ||
|
|
c81c9ee2b4 | ||
|
|
fc169221be | ||
|
|
c43a61c576 | ||
|
|
c4e4f085dd | ||
|
|
088f936dab | ||
|
|
e2b1394ad1 | ||
|
|
3cb9aadb80 | ||
|
|
ca218b6395 | ||
|
|
52852b963a | ||
|
|
d0ae89befa | ||
|
|
2acf9ac72f | ||
|
|
102d8fe506 | ||
|
|
2ee59cc82c | ||
|
|
03e16ffa57 | ||
|
|
782825fc29 | ||
|
|
0299328521 | ||
|
|
eb02a422de | ||
|
|
72af4941f8 | ||
|
|
744f737cba | ||
|
|
f72d5a4184 | ||
|
|
17d2467932 | ||
|
|
241baf77f1 | ||
|
|
b4299a2872 | ||
|
|
45baaeaf2c | ||
|
|
1fd7a4bfab | ||
|
|
826063a2f7 | ||
|
|
349a3c20ae | ||
|
|
6436a12d7f | ||
|
|
000be5d1d4 | ||
|
|
434f1368a0 | ||
|
|
668049a593 | ||
|
|
5c250455ad | ||
|
|
791d6de8b0 | ||
|
|
a3e5173c47 | ||
|
|
b71a5a5955 | ||
|
|
30c670bd83 | ||
|
|
596c0a8672 | ||
|
|
2ac677228d | ||
|
|
ff1c90b638 | ||
|
|
90f23c187f | ||
|
|
854443a291 | ||
|
|
9c7f6affc2 | ||
|
|
fade3eb679 | ||
|
|
cdf4bfa68f | ||
|
|
f8614ab019 | ||
|
|
6f117b8e0c | ||
|
|
dee964e0fe | ||
|
|
5957ede41a | ||
|
|
959c7a76e9 | ||
|
|
a0cdcc5f8d | ||
|
|
9cc3fbabf7 | ||
|
|
3db691d693 | ||
|
|
c1ca8476f8 | ||
|
|
21d1849723 | ||
|
|
50010934d1 | ||
|
|
849dd0db64 | ||
|
|
de0e4735de | ||
|
|
2117524102 | ||
|
|
876064036d | ||
|
|
b57046e67d | ||
|
|
03892153de | ||
|
|
439ba5116f | ||
|
|
5c378de22f | ||
|
|
3f1d22759a | ||
|
|
baaeb7cece | ||
|
|
eb8dc6b675 | ||
|
|
a5e63dc5fd | ||
|
|
5ae3d1a1b2 | ||
|
|
18ca4b6a3a | ||
|
|
51cfb5cff1 | ||
|
|
4ff7976060 | ||
|
|
90d314cc3b | ||
|
|
547097b036 | ||
|
|
df0381e76c | ||
|
|
ddc38eda26 | ||
|
|
9c783f53ba | ||
|
|
ed3e5739dc | ||
|
|
cc85946f55 | ||
|
|
03f876470e | ||
|
|
5cc4a30207 | ||
|
|
a58d989b60 | ||
|
|
dc93d94bc8 | ||
|
|
6c998aa4f2 | ||
|
|
1c7a47239b | ||
|
|
7fc8afa3e5 | ||
|
|
7ec4e7b0d8 | ||
|
|
41a3f123f1 | ||
|
|
f6081b18b6 | ||
|
|
7a6fe00f49 | ||
|
|
c64b4a3926 | ||
|
|
0431833866 | ||
|
|
280f9bf49c | ||
|
|
c7aa747891 | ||
|
|
8584c2f14b | ||
|
|
dbda1a1b05 | ||
|
|
897c6e93cb | ||
|
|
d6d245d0c3 | ||
|
|
0e6db8fd56 | ||
|
|
649633bbb7 | ||
|
|
4250f84272 | ||
|
|
f7528a0204 | ||
|
|
c65a0d90b8 | ||
|
|
1152fecb75 | ||
|
|
48abef27d8 | ||
|
|
624ade2c25 | ||
|
|
f3c64ea9d8 | ||
|
|
e383aa31c8 | ||
|
|
607b53c883 | ||
|
|
e044ada65c | ||
|
|
c74ae107f1 | ||
|
|
45a937df0a | ||
|
|
163361ee6a | ||
|
|
4b18a38e9f | ||
|
|
db2fda1b6f | ||
|
|
eb8fcf833c | ||
|
|
177091ca6f | ||
|
|
442c1b22e3 | ||
|
|
1b8c11121f | ||
|
|
2845267c18 | ||
|
|
764a10f7c7 | ||
|
|
ab2a061b59 | ||
|
|
d243a45173 | ||
|
|
3f15f51615 | ||
|
|
cfbea4a0e3 | ||
|
|
d561c5531b | ||
|
|
d5d1fa8290 | ||
|
|
46e7214974 | ||
|
|
cfb2812cea | ||
|
|
8d1d842185 | ||
|
|
c31629ad98 | ||
|
|
aa2b2f7c8f | ||
|
|
0a23c0b032 | ||
|
|
5bc86eaf9c | ||
|
|
ca7dec2082 | ||
|
|
fc4e10b6c0 | ||
|
|
e80e3a53e9 | ||
|
|
1f55f1635f | ||
|
|
77f73830e8 | ||
|
|
d3c58ea48c | ||
|
|
a1a431eb87 | ||
|
|
3ddd917ff4 | ||
|
|
a33eeda4f7 | ||
|
|
8ec3bc0272 | ||
|
|
982649bab7 | ||
|
|
a7ee737226 | ||
|
|
e842482ec8 | ||
|
|
f00b0a3485 | ||
|
|
fe943f560b | ||
|
|
975f85ea56 | ||
|
|
e734536815 | ||
|
|
3dfc0098ec | ||
|
|
06a501d4a2 | ||
|
|
e1336d8453 | ||
|
|
f8418554a3 | ||
|
|
65b7924528 | ||
|
|
5017db855c | ||
|
|
c6313b3d2d | ||
|
|
4eb0d497ab | ||
|
|
2ebea5501e | ||
|
|
2d68d60e00 | ||
|
|
6deb7afb82 | ||
|
|
8727636fcc | ||
|
|
00294a5b25 | ||
|
|
c491fa59df | ||
|
|
d97cf8c438 | ||
|
|
7a68d632e6 | ||
|
|
28cff4644e | ||
|
|
9d72bd4de4 | ||
|
|
c1b9ca14e7 | ||
|
|
32a957c455 | ||
|
|
85fdacbc49 | ||
|
|
f8f091c250 | ||
|
|
c51fef1568 | ||
|
|
1523a82bab | ||
|
|
92f50664d0 | ||
|
|
5798b152a6 | ||
|
|
b1e69e1357 | ||
|
|
9c36576ddd | ||
|
|
f7f09b028b | ||
|
|
089001bd92 | ||
|
|
97aa7b8e68 | ||
|
|
366ca47136 | ||
|
|
d21e30f57b | ||
|
|
d1da0aad7f | ||
|
|
321f87fe61 | ||
|
|
6743b83786 | ||
|
|
f464b8c4c5 | ||
|
|
25d0a7b62a | ||
|
|
b5b49c9ed0 | ||
|
|
ffeab383b5 | ||
|
|
0bd006a8eb | ||
|
|
0f9dd3736c | ||
|
|
6310d6c699 | ||
|
|
b2d53f1e1e | ||
|
|
4179cedf37 | ||
|
|
66349261a5 | ||
|
|
c1f32afeeb | ||
|
|
8f1fa4177e | ||
|
|
535d264497 | ||
|
|
2eedcde914 | ||
|
|
6b4b7c9831 | ||
|
|
b6aae790cf | ||
|
|
74d1685523 | ||
|
|
c9007557e5 | ||
|
|
c4cb90ab85 | ||
|
|
0adbcfd806 | ||
|
|
fd442df851 | ||
|
|
f927398b53 | ||
|
|
6414cb05f0 | ||
|
|
3b4e706758 | ||
|
|
559fd5cb31 | ||
|
|
1672cffe96 | ||
|
|
b8ec886609 | ||
|
|
728be219a4 | ||
|
|
2e91bf1e15 | ||
|
|
515525cfc6 | ||
|
|
83d951db7e | ||
|
|
8483cb4aa7 | ||
|
|
8cca1c987b | ||
|
|
78b88a70bb | ||
|
|
165d168ee5 | ||
|
|
753fb31c54 | ||
|
|
62eb077f29 | ||
|
|
cd8099d336 | ||
|
|
30109d64f2 | ||
|
|
ae266e2e03 | ||
|
|
c366525370 | ||
|
|
8f04def7b2 | ||
|
|
55808dffcd | ||
|
|
07f8f5f95a | ||
|
|
d7d4b8638d | ||
|
|
9890d1e251 | ||
|
|
f563fc9d5e | ||
|
|
41c2685204 | ||
|
|
73fbb69c50 | ||
|
|
5f9c857eb0 | ||
|
|
5d54d42953 | ||
|
|
81e00d8e56 | ||
|
|
455f0669e7 | ||
|
|
5bb35bbdaf | ||
|
|
d63a848011 | ||
|
|
aafbd865bf | ||
|
|
63874da087 | ||
|
|
d1f0d6c184 | ||
|
|
9ff7807be8 | ||
|
|
23de301955 | ||
|
|
0a5f8611e8 | ||
|
|
6f116eeaa4 | ||
|
|
0242818f39 | ||
|
|
3748ee49ea | ||
|
|
a8a881c8db | ||
|
|
fb52fdc592 | ||
|
|
bb7c63c052 | ||
|
|
9e8b26cc4e | ||
|
|
5db8197a5d | ||
|
|
0b0a17ff91 | ||
|
|
a68e3371f3 | ||
|
|
47bf8e1bb3 | ||
|
|
65099ab489 | ||
|
|
40619efb3b | ||
|
|
f02f9ba9fb | ||
|
|
de05ff894b | ||
|
|
57d2ae1aec | ||
|
|
46c2953edb | ||
|
|
f2d3d55e95 | ||
|
|
a59b53c7e6 | ||
|
|
08b56b7675 | ||
|
|
90795c4fa4 | ||
|
|
90d1c0b2b6 | ||
|
|
ec4212cce1 | ||
|
|
a45d5960d7 | ||
|
|
51cb36fa9b | ||
|
|
b97d7e7ecd | ||
|
|
e12c0dcf66 | ||
|
|
4f45b72381 | ||
|
|
81843f0dfb | ||
|
|
20116d7f05 | ||
|
|
0642be296d | ||
|
|
c8860d006b | ||
|
|
b53a858400 | ||
|
|
511dc9a80b | ||
|
|
7e1168c518 | ||
|
|
57356036db | ||
|
|
666a106fa8 | ||
|
|
414dcfcd07 | ||
|
|
787dbbe610 | ||
|
|
bc9a7806a5 | ||
|
|
565e4c5910 | ||
|
|
8f35198bfb | ||
|
|
c06f023313 | ||
|
|
0c46a7a4d9 | ||
|
|
b21dbdb20d | ||
|
|
c9d0960f47 | ||
|
|
a54dd1085a | ||
|
|
1cf28e8b75 | ||
|
|
9fd98bb27b | ||
|
|
025aa49f67 | ||
|
|
5994bf6745 | ||
|
|
9e2b7dbea5 | ||
|
|
edf063bae3 | ||
|
|
e7b2b93cee | ||
|
|
82322968a3 | ||
|
|
53642b2b17 | ||
|
|
fb9cf86836 | ||
|
|
faf6c5ad29 | ||
|
|
4649d1c73b | ||
|
|
703cb6deea | ||
|
|
9aed2a465f | ||
|
|
746beb0d8b | ||
|
|
6162d9090d | ||
|
|
11223cbc9b | ||
|
|
7e0e12b8a3 | ||
|
|
ca2d74e118 | ||
|
|
673004b878 | ||
|
|
2a8e8a0603 | ||
|
|
4e53019b75 | ||
|
|
833269ffde | ||
|
|
e9ba26f50e | ||
|
|
20a540e680 | ||
|
|
bf3edf8f87 | ||
|
|
10969b8c3c | ||
|
|
c52cf01a3c | ||
|
|
1672c95de3 | ||
|
|
649f04b7bc | ||
|
|
934a7fc118 | ||
|
|
3a3b197327 | ||
|
|
ece4c81c1a | ||
|
|
dcd2bf451d | ||
|
|
87565ec667 | ||
|
|
2e1c50c891 | ||
|
|
77f69cbe08 | ||
|
|
c60745b8a3 | ||
|
|
32ea2b67f0 | ||
|
|
9b05381acc | ||
|
|
a19d20cfb8 | ||
|
|
c422011d58 | ||
|
|
1f5e0c42f3 | ||
|
|
6e6ab9b907 | ||
|
|
7f73240fd5 | ||
|
|
932ffdc1e1 | ||
|
|
fe8965efa2 | ||
|
|
bdef033459 | ||
|
|
6ed70327f5 | ||
|
|
e9fab747ec | ||
|
|
feb31d088b | ||
|
|
a8f2646ba6 | ||
|
|
b2e1a93177 | ||
|
|
86064a7bd8 | ||
|
|
6d2a088be9 | ||
|
|
aa6f7a5d9f | ||
|
|
1d81d1a706 | ||
|
|
e345209f91 | ||
|
|
29964079ae | ||
|
|
94f853c654 | ||
|
|
bae652f46d | ||
|
|
59ee2859a7 | ||
|
|
2bd94293e0 | ||
|
|
c93973ab7a | ||
|
|
894ae1b3f5 | ||
|
|
00daff6ac8 | ||
|
|
f921df7ad1 | ||
|
|
bea4de9262 | ||
|
|
7a03e5f0b2 | ||
|
|
405edebc51 | ||
|
|
d56617e5d0 | ||
|
|
ec4a0e096f | ||
|
|
d21d83cfc8 | ||
|
|
1f3a89197c | ||
|
|
2f3a8ecd42 | ||
|
|
7a23980f4b | ||
|
|
9086b8067b | ||
|
|
3b6f0d83e1 | ||
|
|
6fa940f2c1 | ||
|
|
335e9f68b7 | ||
|
|
4185efa08f | ||
|
|
8ba271efba | ||
|
|
1d8ab03146 | ||
|
|
1f246229b1 | ||
|
|
9474fc0082 | ||
|
|
af339f44f4 | ||
|
|
d03527ae47 | ||
|
|
40874ddec6 | ||
|
|
465dee2c33 | ||
|
|
869e0ab14d | ||
|
|
260778e0fb | ||
|
|
43a8b6039e | ||
|
|
ca4b4709e5 | ||
|
|
809bd3757b | ||
|
|
fbbb704146 | ||
|
|
a4fefbe836 | ||
|
|
5e199152e2 | ||
|
|
13247e592b | ||
|
|
044e43397f | ||
|
|
cb9be091aa | ||
|
|
e8e7edf017 | ||
|
|
9262731f2c | ||
|
|
ba7ce7225b | ||
|
|
939ee94e67 | ||
|
|
f9f34fd628 | ||
|
|
6d844a0b67 | ||
|
|
6f3c46cc7e | ||
|
|
122017e6fa | ||
|
|
16dcc464cf | ||
|
|
94aa0762f0 | ||
|
|
b3f134de06 | ||
|
|
363712d057 | ||
|
|
8bc0c343fa | ||
|
|
37f2113032 | ||
|
|
10db2bce4e | ||
|
|
c0db0011ec | ||
|
|
4de502252b | ||
|
|
a0b9d47d5e | ||
|
|
51f3fb9bde | ||
|
|
7cab7b6c7e | ||
|
|
993c2413e8 | ||
|
|
a9ca152069 | ||
|
|
4bbb70de74 | ||
|
|
db37ab1039 | ||
|
|
dffe4fdd4f | ||
|
|
ac6d815c0e | ||
|
|
af9cbb4514 | ||
|
|
04b7f0d2d6 | ||
|
|
65fa9d2883 | ||
|
|
508551b81b | ||
|
|
a369a4172b | ||
|
|
4d085c4aae | ||
|
|
d43ef97a7b | ||
|
|
de1d24b616 | ||
|
|
0252d7686c | ||
|
|
2a4f5c3284 | ||
|
|
af0ac9b95c | ||
|
|
90d6b91bf7 | ||
|
|
30ccb6aea5 | ||
|
|
0c711f690e | ||
|
|
89bf71e580 | ||
|
|
70c49b78ae | ||
|
|
d3efc52745 | ||
|
|
72db5ed7cb | ||
|
|
8907053a9d | ||
|
|
05b7c2bf80 | ||
|
|
047cad1a4d | ||
|
|
a82bcc7e3c | ||
|
|
c806c465fa | ||
|
|
6fc2a2a051 | ||
|
|
e61b88fc2a | ||
|
|
47b12eee57 | ||
|
|
783ee3e315 | ||
|
|
9e7bbcd8f6 | ||
|
|
d1b2d1a10e | ||
|
|
5ef5d60f77 | ||
|
|
95696c9456 | ||
|
|
5788600c46 | ||
|
|
ba9a55c391 | ||
|
|
d46834265f | ||
|
|
99f5f17a8d | ||
|
|
6c3d29712f | ||
|
|
ce26687577 |
@@ -48,13 +48,13 @@ env-stack-dumping: &env-stack-dumping
|
||||
ELECTRON_ENABLE_STACK_DUMPING: '1'
|
||||
|
||||
env-browsertests: &env-browsertests
|
||||
GN_EXTRA_ARGS: 'is_component_ffmpeg = false'
|
||||
BUILD_TARGET: electron:chromium_browsertests
|
||||
GN_CONFIG: //electron/build/args/native_tests.gn
|
||||
BUILD_TARGET: electron/spec:chromium_browsertests
|
||||
TESTS_CONFIG: src/electron/spec/configs/browsertests.yml
|
||||
|
||||
env-unittests: &env-unittests
|
||||
GN_EXTRA_ARGS: 'is_component_ffmpeg = false'
|
||||
BUILD_TARGET: electron:chromium_unittests
|
||||
GN_CONFIG: //electron/build/args/native_tests.gn
|
||||
BUILD_TARGET: electron/spec:chromium_unittests
|
||||
TESTS_CONFIG: src/electron/spec/configs/unittests.yml
|
||||
|
||||
# Build targets options.
|
||||
@@ -234,6 +234,7 @@ step-gn-gen-default: &step-gn-gen-default
|
||||
step-electron-build: &step-electron-build
|
||||
run:
|
||||
name: Electron build
|
||||
no_output_timeout: 30m
|
||||
command: |
|
||||
cd src
|
||||
ninja -C out/Default electron -j $NUMBER_OF_NINJA_PROCESSES
|
||||
@@ -436,7 +437,7 @@ step-maybe-native-mksnapshot-gn-gen: &step-maybe-native-mksnapshot-gn-gen
|
||||
command: |
|
||||
if [ "$BUILD_NATIVE_MKSNAPSHOT" == "1" ]; then
|
||||
cd src
|
||||
gn gen out/native_mksnapshot --args='import("'$GN_CONFIG'") cc_wrapper="'"$SCCACHE_PATH"'" v8_snapshot_toolchain="'"$MKSNAPSHOT_TOOLCHAIN"'"'" $GN_EXTRA_ARGS"
|
||||
gn gen out/native_mksnapshot --args='import("'$GN_CONFIG'") cc_wrapper="'"$SCCACHE_PATH"'" v8_snapshot_toolchain="'"$MKSNAPSHOT_TOOLCHAIN"'"'" $GN_EXTRA_ARGS v8_enable_embedded_builtins = false"
|
||||
else
|
||||
echo 'Skipping native mksnapshot GN gen for non arm build'
|
||||
fi
|
||||
@@ -444,6 +445,7 @@ step-maybe-native-mksnapshot-gn-gen: &step-maybe-native-mksnapshot-gn-gen
|
||||
step-maybe-native-mksnapshot-build: &step-maybe-native-mksnapshot-build
|
||||
run:
|
||||
name: Native mksnapshot build (arm/arm64)
|
||||
no_output_timeout: 30m
|
||||
command: |
|
||||
if [ "$BUILD_NATIVE_MKSNAPSHOT" == "1" ]; then
|
||||
cd src
|
||||
@@ -701,7 +703,8 @@ steps-native-tests: &steps-native-tests
|
||||
python src/electron/script/native-tests.py run \
|
||||
--config $TESTS_CONFIG \
|
||||
--tests-dir src/out/Default \
|
||||
--output-dir test_results
|
||||
--output-dir test_results \
|
||||
$TESTS_ARGS
|
||||
|
||||
- store_artifacts:
|
||||
path: test_results
|
||||
@@ -944,7 +947,7 @@ jobs:
|
||||
<<: *steps-electron-build-for-publish
|
||||
|
||||
linux-arm-native-mksnapshot:
|
||||
<<: *machine-linux-medium
|
||||
<<: *machine-linux-2xlarge
|
||||
environment:
|
||||
<<: *env-linux-medium
|
||||
<<: *env-arm
|
||||
@@ -1002,7 +1005,7 @@ jobs:
|
||||
<<: *steps-electron-build-for-publish
|
||||
|
||||
linux-arm64-native-mksnapshot:
|
||||
<<: *machine-linux-medium
|
||||
<<: *machine-linux-2xlarge
|
||||
environment:
|
||||
<<: *env-linux-medium
|
||||
<<: *env-arm64
|
||||
@@ -1086,7 +1089,6 @@ jobs:
|
||||
environment:
|
||||
<<: *env-linux-2xlarge
|
||||
<<: *env-unittests
|
||||
<<: *env-testing-build
|
||||
<<: *env-enable-sccache
|
||||
<<: *env-headless-testing
|
||||
<<: *steps-native-tests
|
||||
@@ -1523,3 +1525,13 @@ workflows:
|
||||
- linux-x64-unittests:
|
||||
requires:
|
||||
- linux-checkout-for-native-tests
|
||||
|
||||
- linux-x64-disabled-unittests:
|
||||
requires:
|
||||
- linux-checkout-for-native-tests
|
||||
|
||||
- linux-checkout-for-native-tests-with-no-patches
|
||||
|
||||
- linux-x64-chromium-unittests:
|
||||
requires:
|
||||
- linux-checkout-for-native-tests-with-no-patches
|
||||
|
||||
10
.github/PULL_REQUEST_TEMPLATE.md
vendored
10
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,4 +1,4 @@
|
||||
##### Description of Change
|
||||
#### Description of Change
|
||||
<!--
|
||||
Thank you for your Pull Request. Please provide a description above and review
|
||||
the requirements below.
|
||||
@@ -6,7 +6,7 @@ the requirements below.
|
||||
Contributors guide: https://github.com/electron/electron/blob/master/CONTRIBUTING.md
|
||||
-->
|
||||
|
||||
##### Checklist
|
||||
#### Checklist
|
||||
<!-- Remove items that do not apply. For completed items, change [ ] to [x]. -->
|
||||
|
||||
- [ ] PR description included and stakeholders cc'd
|
||||
@@ -14,9 +14,9 @@ Contributors guide: https://github.com/electron/electron/blob/master/CONTRIBUTIN
|
||||
- [ ] tests are [changed or added](https://github.com/electron/electron/blob/master/docs/development/testing.md)
|
||||
- [ ] relevant documentation is changed or added
|
||||
- [ ] PR title follows semantic [commit guidelines](https://github.com/electron/electron/blob/master/docs/development/pull-requests.md#commit-message-guidelines)
|
||||
- [ ] [PR release notes](https://github.com/electron/clerk/blob/master/README.md) describe the change in a way relevant to app developers, and are [capitalized, punctuated, and past tense](https://github.com/electron/clerk/blob/master/README.md#examples).
|
||||
|
||||
|
||||
##### Release Notes
|
||||
<!-- Used to describe release notes for future release versions. See https://github.com/electron/clerk/blob/master/README.md for details. -->
|
||||
#### Release Notes
|
||||
|
||||
Notes: <!-- One-line Change Summary Here-->
|
||||
Notes: <!-- Please add a one-line description for app developers to read in the release notes, or `no-notes` if no notes relevant to app developers. Examples and help on special cases: https://github.com/electron/clerk/blob/master/README.md#examples -->
|
||||
|
||||
4
.github/config.yml
vendored
4
.github/config.yml
vendored
@@ -36,13 +36,15 @@ newPRWelcomeComment: |
|
||||
firstPRMergeComment: >
|
||||
Congrats on merging your first pull request! 🎉🎉🎉
|
||||
|
||||
# Configuration for trop - https://github.com/codebytere/trop
|
||||
# Configuration for trop - https://github.com/electron/trop
|
||||
|
||||
watchedProject:
|
||||
name: Backports
|
||||
|
||||
# Users authorized to run manual trop backports
|
||||
authorizedUsers:
|
||||
- alexeykuzmin
|
||||
- BinaryMuse
|
||||
- ckerr
|
||||
- codebytere
|
||||
- deepak1556
|
||||
|
||||
10
.gitignore
vendored
10
.gitignore
vendored
@@ -16,13 +16,6 @@
|
||||
*.vcxproj.user
|
||||
*.xcodeproj
|
||||
/.idea/
|
||||
/brightray/brightray.opensdf
|
||||
/brightray/brightray.sdf
|
||||
/brightray/brightray.sln
|
||||
/brightray/brightray.suo
|
||||
/brightray/brightray.v12.suo
|
||||
/brightray/brightray.vcxproj*
|
||||
/brightray/brightray.xcodeproj/
|
||||
/dist/
|
||||
/external_binaries/
|
||||
/out/
|
||||
@@ -63,3 +56,6 @@ spec/.hash
|
||||
|
||||
# Eslint Cache
|
||||
.eslintcache
|
||||
|
||||
# Generated native addon files
|
||||
/spec/fixtures/native-addon/echo/build/
|
||||
|
||||
356
BUILD.gn
356
BUILD.gn
@@ -1,18 +1,19 @@
|
||||
import("build/asar.gni")
|
||||
import("build/npm.gni")
|
||||
import("buildflags/buildflags.gni")
|
||||
import("electron_paks.gni")
|
||||
import("filenames.gni")
|
||||
import("//build/config/locales.gni")
|
||||
import("//build/config/ui.gni")
|
||||
import("//build/config/win/manifest.gni")
|
||||
import("//pdf/features.gni")
|
||||
import("//services/service_manager/public/service_manifest.gni")
|
||||
import("//third_party/ffmpeg/ffmpeg_options.gni")
|
||||
import("//third_party/widevine/cdm/widevine.gni")
|
||||
import("//tools/generate_library_loader/generate_library_loader.gni")
|
||||
import("//tools/grit/grit_rule.gni")
|
||||
import("//tools/grit/repack.gni")
|
||||
import("//tools/v8_context_snapshot/v8_context_snapshot.gni")
|
||||
import("//v8/snapshot_toolchain.gni")
|
||||
import("build/asar.gni")
|
||||
import("build/js_wrap.gni")
|
||||
import("build/npm.gni")
|
||||
import("buildflags/buildflags.gni")
|
||||
import("electron_paks.gni")
|
||||
import("filenames.gni")
|
||||
|
||||
if (is_mac) {
|
||||
import("//build/config/mac/rules.gni")
|
||||
@@ -26,6 +27,13 @@ if (is_linux) {
|
||||
pkg_config("gio_unix") {
|
||||
packages = [ "gio-unix-2.0" ]
|
||||
}
|
||||
|
||||
pkg_config("libnotify_config") {
|
||||
packages = [
|
||||
"glib-2.0",
|
||||
"gdk-pixbuf-2.0",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
branding = read_file("atom/app/BRANDING.json", "json")
|
||||
@@ -45,26 +53,8 @@ config("branding") {
|
||||
]
|
||||
}
|
||||
|
||||
npm_action("atom_browserify_sandbox") {
|
||||
deps = [
|
||||
":atom_js2c_copy",
|
||||
]
|
||||
|
||||
sandbox_args = [
|
||||
"lib/sandboxed_renderer/init.js",
|
||||
"-r",
|
||||
"./lib/sandboxed_renderer/api/exports/electron.js:electron",
|
||||
"-r",
|
||||
"./lib/sandboxed_renderer/api/exports/fs.js:fs",
|
||||
"-r",
|
||||
"./lib/sandboxed_renderer/api/exports/os.js:os",
|
||||
"-r",
|
||||
"./lib/sandboxed_renderer/api/exports/path.js:path",
|
||||
"-r",
|
||||
"./lib/sandboxed_renderer/api/exports/child_process.js:child_process",
|
||||
"-t",
|
||||
"aliasify",
|
||||
]
|
||||
npm_action("atom_browserify_sandbox_unwrapped") {
|
||||
script = "browserify"
|
||||
|
||||
inputs = [
|
||||
# FIXME(zcbenz): The dependencies of these files are not listed here, so
|
||||
@@ -72,41 +62,73 @@ npm_action("atom_browserify_sandbox") {
|
||||
# Use a script to generate all dependencies and put them here.
|
||||
"lib/sandboxed_renderer/init.js",
|
||||
"lib/sandboxed_renderer/api/exports/electron.js",
|
||||
"lib/sandboxed_renderer/api/exports/fs.js",
|
||||
"lib/sandboxed_renderer/api/exports/os.js",
|
||||
"lib/sandboxed_renderer/api/exports/path.js",
|
||||
"lib/sandboxed_renderer/api/exports/child_process.js",
|
||||
]
|
||||
outputs = [
|
||||
"$target_gen_dir/js2c/preload_bundle.js",
|
||||
]
|
||||
|
||||
script = "browserify"
|
||||
args = sandbox_args + [
|
||||
"-o",
|
||||
rebase_path(outputs[0]),
|
||||
]
|
||||
outputs = [
|
||||
"$target_gen_dir/js2c/preload_bundle_unwrapped.js",
|
||||
]
|
||||
|
||||
args = [
|
||||
"lib/sandboxed_renderer/init.js",
|
||||
"-r",
|
||||
"./lib/sandboxed_renderer/api/exports/electron.js:electron",
|
||||
"-t",
|
||||
"aliasify",
|
||||
"--standalone",
|
||||
"sandboxed_preload",
|
||||
"-o",
|
||||
rebase_path(outputs[0]),
|
||||
]
|
||||
}
|
||||
|
||||
npm_action("atom_browserify_isolated") {
|
||||
deps = [
|
||||
":atom_js2c_copy",
|
||||
]
|
||||
npm_action("atom_browserify_isolated_unwrapped") {
|
||||
script = "browserify"
|
||||
|
||||
inputs = [
|
||||
"lib/isolated_renderer/init.js",
|
||||
]
|
||||
|
||||
outputs = [
|
||||
"$target_gen_dir/js2c/isolated_bundle_unwrapped.js",
|
||||
]
|
||||
|
||||
args = [
|
||||
"lib/isolated_renderer/init.js",
|
||||
"-t",
|
||||
"aliasify",
|
||||
"--standalone",
|
||||
"isolated_preload",
|
||||
"-o",
|
||||
rebase_path(outputs[0]),
|
||||
]
|
||||
}
|
||||
|
||||
js_wrap("atom_browserify_isolated") {
|
||||
deps = [
|
||||
":atom_browserify_isolated_unwrapped",
|
||||
]
|
||||
|
||||
inputs = [
|
||||
"$target_gen_dir/js2c/isolated_bundle_unwrapped.js",
|
||||
]
|
||||
|
||||
outputs = [
|
||||
"$target_gen_dir/js2c/isolated_bundle.js",
|
||||
]
|
||||
}
|
||||
|
||||
script = "browserify"
|
||||
args = inputs + [
|
||||
"-t",
|
||||
"aliasify",
|
||||
"-o",
|
||||
rebase_path(outputs[0]),
|
||||
]
|
||||
js_wrap("atom_browserify_sandbox") {
|
||||
deps = [
|
||||
":atom_browserify_sandbox_unwrapped",
|
||||
]
|
||||
|
||||
inputs = [
|
||||
"$target_gen_dir/js2c/preload_bundle_unwrapped.js",
|
||||
]
|
||||
|
||||
outputs = [
|
||||
"$target_gen_dir/js2c/preload_bundle.js",
|
||||
]
|
||||
}
|
||||
|
||||
copy("atom_js2c_copy") {
|
||||
@@ -126,23 +148,25 @@ action("atom_js2c") {
|
||||
":atom_js2c_copy",
|
||||
]
|
||||
|
||||
js2c_sources = filenames.js2c_sources
|
||||
|
||||
browserify_sources = [
|
||||
"$target_gen_dir/js2c/isolated_bundle.js",
|
||||
"$target_gen_dir/js2c/preload_bundle.js",
|
||||
]
|
||||
|
||||
inputs = js2c_sources + browserify_sources
|
||||
sources = browserify_sources + [
|
||||
"$target_gen_dir/js2c/asar.js",
|
||||
"$target_gen_dir/js2c/asar_init.js",
|
||||
]
|
||||
|
||||
inputs = sources
|
||||
outputs = [
|
||||
"$target_gen_dir/atom_natives.h",
|
||||
"$root_gen_dir/atom_natives.cc",
|
||||
]
|
||||
|
||||
script = "tools/js2c.py"
|
||||
args = [ rebase_path("//third_party/electron_node") ] +
|
||||
rebase_path(outputs, root_build_dir) +
|
||||
[ rebase_path("$target_gen_dir/js2c", root_build_dir) ]
|
||||
rebase_path(sources, root_build_dir)
|
||||
}
|
||||
|
||||
asar("js2asar") {
|
||||
@@ -159,6 +183,8 @@ asar("js2asar") {
|
||||
"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",
|
||||
]
|
||||
}
|
||||
@@ -184,18 +210,53 @@ grit("resources") {
|
||||
"electron_resources.pak",
|
||||
]
|
||||
|
||||
# Mojo manifest overlays are generated.
|
||||
source_is_generated = true
|
||||
grit_flags = [
|
||||
"-E",
|
||||
"target_gen_dir=" + rebase_path(target_gen_dir, root_build_dir),
|
||||
]
|
||||
|
||||
deps = [
|
||||
":electron_content_manifest_overlays",
|
||||
":copy_shell_devtools_discovery_page",
|
||||
]
|
||||
|
||||
output_dir = "$target_gen_dir"
|
||||
}
|
||||
|
||||
copy("copy_shell_devtools_discovery_page") {
|
||||
sources = [
|
||||
"//content/shell/resources/shell_devtools_discovery_page.html",
|
||||
]
|
||||
outputs = [
|
||||
"$target_gen_dir/shell_devtools_discovery_page.html",
|
||||
]
|
||||
}
|
||||
|
||||
if (is_linux) {
|
||||
generate_library_loader("libnotify_loader") {
|
||||
name = "LibNotifyLoader"
|
||||
output_h = "libnotify_loader.h"
|
||||
output_cc = "libnotify_loader.cc"
|
||||
header = "<libnotify/notify.h>"
|
||||
config = ":libnotify_config"
|
||||
|
||||
functions = [
|
||||
"notify_is_initted",
|
||||
"notify_init",
|
||||
"notify_get_server_caps",
|
||||
"notify_get_server_info",
|
||||
"notify_notification_new",
|
||||
"notify_notification_add_action",
|
||||
"notify_notification_set_image_from_pixbuf",
|
||||
"notify_notification_set_timeout",
|
||||
"notify_notification_set_hint_string",
|
||||
"notify_notification_show",
|
||||
"notify_notification_close",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
static_library("electron_lib") {
|
||||
configs += [ "//v8:external_startup_data" ]
|
||||
configs += [ "//third_party/electron_node:node_internals" ]
|
||||
@@ -204,28 +265,39 @@ static_library("electron_lib") {
|
||||
|
||||
deps = [
|
||||
":atom_js2c",
|
||||
"brightray",
|
||||
"buildflags",
|
||||
"chromium_src:chrome",
|
||||
"manifests",
|
||||
"native_mate",
|
||||
"//base",
|
||||
"//base:base_static",
|
||||
"//base:i18n",
|
||||
"//chrome/app/resources:platform_locale_settings",
|
||||
"//components/certificate_transparency",
|
||||
"//components/net_log",
|
||||
"//components/network_session_configurator/common",
|
||||
"//components/prefs",
|
||||
"//components/spellcheck/renderer",
|
||||
"//components/viz/host",
|
||||
"//components/viz/service",
|
||||
"//content/public/app:both",
|
||||
"//content/public/browser",
|
||||
"//content/public/child",
|
||||
"//content/public/common:service_names",
|
||||
"//gin",
|
||||
"//media/capture/mojom:video_capture",
|
||||
"//media/mojo/interfaces",
|
||||
"//net:extras",
|
||||
"//net:net_resources",
|
||||
"//net:net_with_v8",
|
||||
"//ppapi/host",
|
||||
"//ppapi/proxy",
|
||||
"//ppapi/shared_impl",
|
||||
"//services/audio/public/mojom:constants",
|
||||
"//services/device/public/mojom",
|
||||
"//services/proxy_resolver:lib",
|
||||
"//services/video_capture/public/mojom:constants",
|
||||
"//services/viz/privileged/interfaces/compositing",
|
||||
"//skia",
|
||||
"//third_party/blink/public:blink",
|
||||
"//third_party/boringssl",
|
||||
@@ -240,12 +312,6 @@ static_library("electron_lib") {
|
||||
"//v8",
|
||||
]
|
||||
|
||||
# TODO: this requires a visibility patch to chromium src. it would be better
|
||||
# to use the publicly-available API, which I think is mojo-based. Once
|
||||
# electron switches to using the public API, we can remove this from the deps
|
||||
# list and remove the visibility patch from chromium.
|
||||
deps += [ "//services/device/wake_lock/power_save_blocker" ]
|
||||
|
||||
include_dirs = [
|
||||
"chromium_src",
|
||||
".",
|
||||
@@ -256,9 +322,13 @@ static_library("electron_lib") {
|
||||
"//third_party/blink/renderer",
|
||||
]
|
||||
|
||||
defines = []
|
||||
defines = [ "V8_DEPRECATION_WARNINGS" ]
|
||||
libs = []
|
||||
|
||||
if (is_linux) {
|
||||
defines += [ "GDK_DISABLE_DEPRECATION_WARNINGS" ]
|
||||
}
|
||||
|
||||
extra_source_filters = []
|
||||
if (!is_linux) {
|
||||
extra_source_filters += [
|
||||
@@ -287,8 +357,6 @@ static_library("electron_lib") {
|
||||
"*_views.cc",
|
||||
"*_views.h",
|
||||
"*\bviews/*",
|
||||
"*/autofill_popup.cc",
|
||||
"*/autofill_popup.h",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -297,16 +365,6 @@ static_library("electron_lib") {
|
||||
sources = filenames.lib_sources
|
||||
set_sources_assignment_filter(sources_assignment_filter)
|
||||
|
||||
sources += [
|
||||
"$target_gen_dir/atom_natives.h",
|
||||
"//extensions/browser/app_window/size_constraints.cc",
|
||||
"//extensions/browser/app_window/size_constraints.h",
|
||||
"//extensions/common/constants.cc",
|
||||
"//extensions/common/constants.h",
|
||||
"//extensions/common/url_pattern.cc",
|
||||
"//extensions/common/url_pattern.h",
|
||||
]
|
||||
|
||||
if (is_component_build) {
|
||||
defines += [ "NODE_SHARED_MODE" ]
|
||||
}
|
||||
@@ -323,6 +381,10 @@ static_library("electron_lib") {
|
||||
"//third_party/crashpad/crashpad/client",
|
||||
"//ui/accelerated_widget_mac",
|
||||
]
|
||||
sources += [
|
||||
"atom/browser/ui/views/autofill_popup_view.cc",
|
||||
"atom/browser/ui/views/autofill_popup_view.h",
|
||||
]
|
||||
include_dirs += [
|
||||
# NOTE(nornagon): other chromium files use the full path to include
|
||||
# crashpad; this is just here for compatibility between GN and GYP, so that
|
||||
@@ -355,8 +417,10 @@ static_library("electron_lib") {
|
||||
}
|
||||
if (is_linux) {
|
||||
deps += [
|
||||
":libnotify_loader",
|
||||
"//build/config/linux/gtk",
|
||||
"//chrome/browser/ui/libgtkui",
|
||||
"//dbus",
|
||||
"//device/bluetooth",
|
||||
"//ui/events/devices/x11",
|
||||
"//ui/events/platform/x11",
|
||||
@@ -373,7 +437,6 @@ static_library("electron_lib") {
|
||||
sources += filenames.lib_sources_nss
|
||||
}
|
||||
if (is_win) {
|
||||
sources += filenames.lib_sources_win
|
||||
libs += [ "dwmapi.lib" ]
|
||||
}
|
||||
if (is_linux || is_win) {
|
||||
@@ -394,12 +457,13 @@ static_library("electron_lib") {
|
||||
|
||||
if (enable_osr) {
|
||||
sources += [
|
||||
"atom/browser/api/atom_api_web_contents_osr.cc",
|
||||
"atom/browser/osr/osr_output_device.cc",
|
||||
"atom/browser/osr/osr_output_device.h",
|
||||
"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_render_widget_host_view_mac.mm",
|
||||
"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",
|
||||
@@ -435,6 +499,10 @@ static_library("electron_lib") {
|
||||
"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",
|
||||
]
|
||||
@@ -452,16 +520,6 @@ static_library("electron_lib") {
|
||||
if (enable_pepper_flash) {
|
||||
deps += [ "components/pepper_flash" ]
|
||||
}
|
||||
|
||||
if (enable_widevine) {
|
||||
sources += [
|
||||
"//chrome/renderer/media/chrome_key_systems.cc",
|
||||
"//chrome/renderer/media/chrome_key_systems.h",
|
||||
"//chrome/renderer/media/chrome_key_systems_provider.cc",
|
||||
"//chrome/renderer/media/chrome_key_systems_provider.h",
|
||||
]
|
||||
deps += [ "//components/cdm/renderer" ]
|
||||
}
|
||||
}
|
||||
|
||||
electron_paks("packed_resources") {
|
||||
@@ -560,7 +618,7 @@ if (is_mac) {
|
||||
}
|
||||
info_plist = "atom/common/resources/mac/Info.plist"
|
||||
|
||||
electron_version = read_file("VERSION", "trim string")
|
||||
electron_version = read_file("ELECTRON_VERSION", "trim string")
|
||||
extra_substitutions = [
|
||||
"ATOM_BUNDLE_ID=$electron_mac_bundle_id.framework",
|
||||
"ELECTRON_VERSION=$electron_version",
|
||||
@@ -579,6 +637,11 @@ if (is_mac) {
|
||||
"ServiceManagement.framework",
|
||||
"StoreKit.framework",
|
||||
]
|
||||
|
||||
if (enable_osr) {
|
||||
libs += [ "IOSurface.framework" ]
|
||||
}
|
||||
|
||||
ldflags = [
|
||||
"-F",
|
||||
rebase_path("external_binaries", root_build_dir),
|
||||
@@ -599,6 +662,10 @@ if (is_mac) {
|
||||
deps = [
|
||||
":electron_framework+link",
|
||||
]
|
||||
if (!is_mas_build) {
|
||||
deps += [ "//sandbox/mac:seatbelt" ]
|
||||
}
|
||||
defines = [ "HELPER_EXECUTABLE" ]
|
||||
sources = filenames.app_sources
|
||||
include_dirs = [ "." ]
|
||||
info_plist = "atom/renderer/resources/mac/Info.plist"
|
||||
@@ -607,6 +674,12 @@ if (is_mac) {
|
||||
"-rpath",
|
||||
"@executable_path/../../..",
|
||||
]
|
||||
if (is_component_build) {
|
||||
ldflags += [
|
||||
"-rpath",
|
||||
"@executable_path/../../../../../..",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
bundle_data("electron_app_framework_bundle_data") {
|
||||
@@ -815,75 +888,6 @@ if (is_mac) {
|
||||
}
|
||||
}
|
||||
|
||||
group("electron_tests") {
|
||||
testonly = true
|
||||
|
||||
deps = [
|
||||
":chromium_browsertests",
|
||||
":chromium_unittests",
|
||||
]
|
||||
}
|
||||
|
||||
group("chromium_unittests") {
|
||||
testonly = true
|
||||
|
||||
deps = [
|
||||
"//base:base_unittests",
|
||||
"//cc:cc_unittests",
|
||||
"//content/test:content_unittests",
|
||||
"//crypto:crypto_unittests",
|
||||
"//device:device_unittests",
|
||||
"//gin:gin_unittests",
|
||||
"//gpu:gpu_unittests",
|
||||
"//ipc:ipc_tests",
|
||||
"//media:media_unittests",
|
||||
"//media/capture:capture_unittests",
|
||||
"//media/midi:midi_unittests",
|
||||
"//media/mojo:media_mojo_unittests",
|
||||
"//mojo:mojo_unittests",
|
||||
"//net:net_unittests",
|
||||
"//ppapi:ppapi_unittests",
|
||||
"//skia:skia_unittests",
|
||||
"//sql:sql_unittests",
|
||||
"//storage:storage_unittests",
|
||||
"//third_party/angle/src/tests:angle_unittests",
|
||||
"//third_party/blink/public:all_blink",
|
||||
"//third_party/blink/public:test_support",
|
||||
"//third_party/leveldatabase:env_chromium_unittests",
|
||||
"//ui/base:ui_base_unittests",
|
||||
"//ui/compositor:compositor_unittests",
|
||||
"//ui/display:display_unittests",
|
||||
"//ui/events:events_unittests",
|
||||
"//ui/gl:gl_unittests",
|
||||
"//url:url_unittests",
|
||||
"//url/ipc:url_ipc_unittests",
|
||||
"//v8/test/unittests:unittests",
|
||||
]
|
||||
|
||||
if (enable_basic_printing) {
|
||||
deps += [ "//printing:printing_unittests" ]
|
||||
}
|
||||
|
||||
if (is_linux) {
|
||||
deps += [
|
||||
"//net:disk_cache_memory_test",
|
||||
"//sandbox/linux:sandbox_linux_unittests",
|
||||
]
|
||||
|
||||
if (use_dbus) {
|
||||
deps += [ "//dbus:dbus_unittests" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
group("chromium_browsertests") {
|
||||
testonly = true
|
||||
|
||||
deps = [
|
||||
"//content/test:content_browsertests",
|
||||
]
|
||||
}
|
||||
|
||||
template("dist_zip") {
|
||||
_runtime_deps_target = "${target_name}__deps"
|
||||
_runtime_deps_file =
|
||||
@@ -942,7 +946,7 @@ group("licenses") {
|
||||
|
||||
copy("electron_version") {
|
||||
sources = [
|
||||
"VERSION",
|
||||
"ELECTRON_VERSION",
|
||||
]
|
||||
outputs = [
|
||||
"$root_build_dir/version",
|
||||
@@ -955,6 +959,9 @@ dist_zip("electron_dist_zip") {
|
||||
":licenses",
|
||||
":electron_version",
|
||||
]
|
||||
if (is_linux) {
|
||||
data_deps += [ "//sandbox/linux:chrome_sandbox" ]
|
||||
}
|
||||
outputs = [
|
||||
"$root_build_dir/dist.zip",
|
||||
]
|
||||
@@ -991,30 +998,7 @@ dist_zip("electron_mksnapshot_zip") {
|
||||
}
|
||||
|
||||
group("electron") {
|
||||
deps = [
|
||||
public_deps = [
|
||||
":electron_app",
|
||||
]
|
||||
}
|
||||
|
||||
group("electron_content_manifest_overlays") {
|
||||
deps = [
|
||||
":electron_content_browser_manifest_overlay",
|
||||
":electron_content_packaged_services_manifest_overlay",
|
||||
]
|
||||
}
|
||||
|
||||
service_manifest("electron_content_packaged_services_manifest_overlay") {
|
||||
source = "//electron/manifests/electron_content_packaged_services_manifest_overlay.json"
|
||||
packaged_services = [ "//services/proxy_resolver:proxy_resolver_manifest" ]
|
||||
|
||||
if (enable_basic_printing) {
|
||||
packaged_services += [
|
||||
"//chrome/services/printing:manifest",
|
||||
"//components/services/pdf_compositor:pdf_compositor_manifest",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
service_manifest("electron_content_browser_manifest_overlay") {
|
||||
source = "//electron/manifests/electron_content_browser_manifest_overlay.json"
|
||||
}
|
||||
|
||||
12
DEPS
12
DEPS
@@ -10,9 +10,9 @@ gclient_gn_args = [
|
||||
|
||||
vars = {
|
||||
'chromium_version':
|
||||
'69.0.3497.128',
|
||||
'73.0.3683.119',
|
||||
'node_version':
|
||||
'8bc5d171a0873c0ba49f9433798bc8b67399788c',
|
||||
'a86a4a160dc520c61a602c949a32a1bc4c0fc633',
|
||||
|
||||
'boto_version': 'f7574aa6cc2c819430c1f05e9a1a1a666ef8169b',
|
||||
'pyyaml_version': '3.12',
|
||||
@@ -107,7 +107,7 @@ hooks = [
|
||||
'action': [
|
||||
'python',
|
||||
'-c',
|
||||
'import os, subprocess; os.chdir(os.path.join("src", "electron")); subprocess.check_call(["python", "script/lib/npm.py", "install"]);',
|
||||
'import os; os.chdir("src"); os.chdir("electron"); os.system("npm install")',
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -117,7 +117,7 @@ hooks = [
|
||||
'action': [
|
||||
'python',
|
||||
'-c',
|
||||
'import os, subprocess; os.chdir(os.path.join("src", "electron", "vendor", "boto")); subprocess.check_call(["python", "setup.py", "build"]);',
|
||||
'import os; os.chdir("src"); os.chdir("electron"); os.chdir("vendor"); os.chdir("boto"); os.system("python setup.py build");',
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -127,9 +127,9 @@ hooks = [
|
||||
'action': [
|
||||
'python',
|
||||
'-c',
|
||||
'import os, subprocess; os.chdir(os.path.join("src", "electron", "vendor", "requests")); subprocess.check_call(["python", "setup.py", "build"]);',
|
||||
'import os; os.chdir("src"); os.chdir("electron"); os.chdir("vendor"); os.chdir("requests"); os.system("python setup.py build");',
|
||||
],
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
recursedeps = [
|
||||
|
||||
1
ELECTRON_VERSION
Normal file
1
ELECTRON_VERSION
Normal file
@@ -0,0 +1 @@
|
||||
5.0.0
|
||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2013-2018 GitHub Inc.
|
||||
Copyright (c) 2013-2019 GitHub Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
[](https://circleci.com/gh/electron/electron/tree/master)
|
||||
[](https://windows-ci.electronjs.org/project/AppVeyor/electron/branch/master)
|
||||
[](https://github.visualstudio.com/electron/_build/latest?definitionId=36)
|
||||
[](https://david-dm.org/electron/electron?type=dev)
|
||||
[](https://atom-slack.herokuapp.com/)
|
||||
|
||||
|
||||
@@ -81,8 +81,6 @@ test_script:
|
||||
if ((-Not (Test-Path Env:\ELECTRON_RELEASE)) -And ($env:GN_CONFIG -in "testing", "release")) {
|
||||
$env:RUN_TESTS="true"
|
||||
}
|
||||
- if "%RUN_TESTS%"=="true" ( echo Verifying non proprietary ffmpeg & python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg )
|
||||
- if "%RUN_TESTS%"=="true" ( echo Verifying mksnapshot & python electron\script\verify-mksnapshot.py --build-dir out\Default --source-root %cd% )
|
||||
- ps: >-
|
||||
if ($env:RUN_TESTS -eq 'true') {
|
||||
New-Item .\out\Default\gen\node_headers\Release -Type directory
|
||||
@@ -91,8 +89,12 @@ test_script:
|
||||
echo "Skipping tests for $env:GN_CONFIG build"
|
||||
}
|
||||
- cd electron
|
||||
- if "%RUN_TESTS%"=="true" ( echo Running test suite & npm run test -- --ci )
|
||||
- if "%RUN_TESTS%"=="true" ( echo Running test suite & npm run test -- --ci --enable-logging)
|
||||
- cd ..
|
||||
- if "%RUN_TESTS%"=="true" ( echo Verifying non proprietary ffmpeg & python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg )
|
||||
- echo "About to verify mksnapshot"
|
||||
- if "%RUN_TESTS%"=="true" ( echo Verifying mksnapshot & python electron\script\verify-mksnapshot.py --build-dir out\Default --source-root %cd% )
|
||||
- echo "Done verifying mksnapshot"
|
||||
deploy_script:
|
||||
- cd electron
|
||||
- ps: >-
|
||||
|
||||
@@ -7,23 +7,18 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/common/atom_version.h"
|
||||
#include "atom/common/chrome_version.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "content/public/common/content_constants.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "content/public/common/pepper_plugin_info.h"
|
||||
#include "content/public/common/user_agent.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "ppapi/shared_impl/ppapi_permissions.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/base/resource/resource_bundle.h"
|
||||
#include "url/url_constants.h"
|
||||
// In SHARED_INTERMEDIATE_DIR.
|
||||
#include "widevine_cdm_version.h" // NOLINT(build/include)
|
||||
@@ -176,86 +171,59 @@ void ConvertStringWithSeparatorToVector(std::vector<std::string>* vec,
|
||||
base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
|
||||
}
|
||||
|
||||
std::string RemoveWhitespace(const std::string& str) {
|
||||
std::string trimmed;
|
||||
if (base::RemoveChars(str, " ", &trimmed))
|
||||
return trimmed;
|
||||
else
|
||||
return str;
|
||||
}
|
||||
|
||||
bool IsBrowserProcess() {
|
||||
const base::CommandLine* command_line =
|
||||
base::CommandLine::ForCurrentProcess();
|
||||
std::string process_type =
|
||||
command_line->GetSwitchValueASCII(::switches::kProcessType);
|
||||
return process_type.empty();
|
||||
}
|
||||
|
||||
std::string BuildDefaultUserAgent() {
|
||||
return "Chrome/" CHROME_VERSION_STRING " " ATOM_PRODUCT_NAME
|
||||
"/" ATOM_VERSION_STRING;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
AtomContentClient::AtomContentClient() {}
|
||||
|
||||
AtomContentClient::~AtomContentClient() {}
|
||||
|
||||
std::string AtomContentClient::GetProduct() const {
|
||||
return "Chrome/" CHROME_VERSION_STRING;
|
||||
}
|
||||
|
||||
std::string AtomContentClient::GetUserAgent() const {
|
||||
if (IsBrowserProcess()) {
|
||||
if (user_agent_override_.empty()) {
|
||||
auto* browser = Browser::Get();
|
||||
std::string name = RemoveWhitespace(browser->GetName());
|
||||
std::string user_agent;
|
||||
if (name == ATOM_PRODUCT_NAME) {
|
||||
user_agent = BuildDefaultUserAgent();
|
||||
} else {
|
||||
user_agent = base::StringPrintf(
|
||||
"%s/%s Chrome/%s " ATOM_PRODUCT_NAME "/" ATOM_VERSION_STRING,
|
||||
name.c_str(), browser->GetVersion().c_str(), CHROME_VERSION_STRING);
|
||||
}
|
||||
return content::BuildUserAgentFromProduct(user_agent);
|
||||
}
|
||||
return user_agent_override_;
|
||||
}
|
||||
// In a renderer process the user agent should be provided on the CLI
|
||||
// If it's not we just fallback to the default one, this should never happen
|
||||
// but we want to handle it gracefully
|
||||
const base::CommandLine* command_line =
|
||||
base::CommandLine::ForCurrentProcess();
|
||||
std::string cli_user_agent = command_line->GetSwitchValueASCII("user-agent");
|
||||
if (cli_user_agent.empty())
|
||||
return BuildDefaultUserAgent();
|
||||
return cli_user_agent;
|
||||
}
|
||||
|
||||
void AtomContentClient::SetUserAgent(const std::string& user_agent) {
|
||||
user_agent_override_ = user_agent;
|
||||
}
|
||||
|
||||
base::string16 AtomContentClient::GetLocalizedString(int message_id) const {
|
||||
return l10n_util::GetStringUTF16(message_id);
|
||||
}
|
||||
|
||||
void AtomContentClient::AddAdditionalSchemes(Schemes* schemes) {
|
||||
schemes->standard_schemes.push_back("chrome-extension");
|
||||
base::StringPiece AtomContentClient::GetDataResource(
|
||||
int resource_id,
|
||||
ui::ScaleFactor scale_factor) const {
|
||||
return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
|
||||
resource_id, scale_factor);
|
||||
}
|
||||
|
||||
gfx::Image& AtomContentClient::GetNativeImageNamed(int resource_id) const {
|
||||
return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
|
||||
resource_id);
|
||||
}
|
||||
|
||||
base::RefCountedMemory* AtomContentClient::GetDataResourceBytes(
|
||||
int resource_id) const {
|
||||
return ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
|
||||
resource_id);
|
||||
}
|
||||
|
||||
void AtomContentClient::AddAdditionalSchemes(Schemes* schemes) {
|
||||
std::vector<std::string> splited;
|
||||
ConvertStringWithSeparatorToVector(&splited, ",",
|
||||
switches::kRegisterServiceWorkerSchemes);
|
||||
switches::kServiceWorkerSchemes);
|
||||
for (const std::string& scheme : splited)
|
||||
schemes->service_worker_schemes.push_back(scheme);
|
||||
schemes->service_worker_schemes.push_back(url::kFileScheme);
|
||||
|
||||
ConvertStringWithSeparatorToVector(&splited, ",", switches::kStandardSchemes);
|
||||
for (const std::string& scheme : splited)
|
||||
schemes->standard_schemes.push_back(scheme);
|
||||
schemes->standard_schemes.push_back("chrome-extension");
|
||||
|
||||
ConvertStringWithSeparatorToVector(&splited, ",", switches::kSecureSchemes);
|
||||
for (const std::string& scheme : splited)
|
||||
schemes->secure_schemes.push_back(scheme);
|
||||
|
||||
ConvertStringWithSeparatorToVector(&splited, ",",
|
||||
switches::kBypassCSPSchemes);
|
||||
for (const std::string& scheme : splited)
|
||||
schemes->csp_bypassing_schemes.push_back(scheme);
|
||||
|
||||
ConvertStringWithSeparatorToVector(&splited, ",", switches::kCORSSchemes);
|
||||
for (const std::string& scheme : splited)
|
||||
schemes->cors_enabled_schemes.push_back(scheme);
|
||||
}
|
||||
|
||||
void AtomContentClient::AddPepperPlugins(
|
||||
|
||||
@@ -9,22 +9,22 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "brightray/common/content_client.h"
|
||||
#include "content/public/common/content_client.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class AtomContentClient : public brightray::ContentClient {
|
||||
class AtomContentClient : public content::ContentClient {
|
||||
public:
|
||||
AtomContentClient();
|
||||
~AtomContentClient() override;
|
||||
|
||||
std::string GetUserAgent() const override;
|
||||
void SetUserAgent(const std::string& user_agent);
|
||||
|
||||
protected:
|
||||
// content::ContentClient:
|
||||
std::string GetProduct() const override;
|
||||
base::string16 GetLocalizedString(int message_id) const override;
|
||||
base::StringPiece GetDataResource(int resource_id,
|
||||
ui::ScaleFactor) const override;
|
||||
gfx::Image& GetNativeImageNamed(int resource_id) const override;
|
||||
base::RefCountedMemory* GetDataResourceBytes(int resource_id) const override;
|
||||
void AddAdditionalSchemes(Schemes* schemes) override;
|
||||
void AddPepperPlugins(
|
||||
std::vector<content::PepperPluginInfo>* plugins) override;
|
||||
@@ -33,8 +33,6 @@ class AtomContentClient : public brightray::ContentClient {
|
||||
std::vector<media::CdmHostFilePath>* cdm_host_file_paths) override;
|
||||
|
||||
private:
|
||||
std::string user_agent_override_ = "";
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomContentClient);
|
||||
};
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
#include "atom/app/atom_main_delegate.h"
|
||||
#include "atom/app/node_main.h"
|
||||
#include "atom/common/atom_command_line.h"
|
||||
#include "atom/common/mac/main_application_bundle.h"
|
||||
#include "base/at_exit.h"
|
||||
#include "base/i18n/icu_util.h"
|
||||
#include "base/mac/bundle_locations.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "brightray/common/mac/main_application_bundle.h"
|
||||
#include "content/public/app/content_main.h"
|
||||
|
||||
int AtomMain(int argc, char* argv[]) {
|
||||
@@ -28,7 +28,7 @@ int AtomInitializeICUandStartNode(int argc, char* argv[]) {
|
||||
base::AtExitManager atexit_manager;
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
base::mac::SetOverrideFrameworkBundlePath(
|
||||
brightray::MainApplicationBundlePath()
|
||||
atom::MainApplicationBundlePath()
|
||||
.Append("Contents")
|
||||
.Append("Frameworks")
|
||||
.Append(ATOM_PRODUCT_NAME " Framework.framework"));
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "atom/app/atom_main.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#if defined(OS_WIN)
|
||||
@@ -30,6 +31,7 @@
|
||||
#include "atom/app/atom_main_delegate.h" // NOLINT
|
||||
#include "content/public/app/content_main.h"
|
||||
#else // defined(OS_LINUX)
|
||||
#include <mach-o/dyld.h>
|
||||
#include <unistd.h>
|
||||
#include <cstdio>
|
||||
#include "atom/app/atom_library_main.h"
|
||||
@@ -41,6 +43,10 @@
|
||||
#include "base/i18n/icu_util.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
|
||||
#if defined(HELPER_EXECUTABLE) && !defined(MAS_BUILD)
|
||||
#include "sandbox/mac/seatbelt_exec.h" // nogncheck
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
||||
@@ -207,6 +213,35 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HELPER_EXECUTABLE) && !defined(MAS_BUILD)
|
||||
uint32_t exec_path_size = 0;
|
||||
int rv = _NSGetExecutablePath(NULL, &exec_path_size);
|
||||
if (rv != -1) {
|
||||
fprintf(stderr, "_NSGetExecutablePath: get length failed\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
std::unique_ptr<char[]> exec_path(new char[exec_path_size]);
|
||||
rv = _NSGetExecutablePath(exec_path.get(), &exec_path_size);
|
||||
if (rv != 0) {
|
||||
fprintf(stderr, "_NSGetExecutablePath: get path failed\n");
|
||||
abort();
|
||||
}
|
||||
sandbox::SeatbeltExecServer::CreateFromArgumentsResult seatbelt =
|
||||
sandbox::SeatbeltExecServer::CreateFromArguments(exec_path.get(), argc,
|
||||
argv);
|
||||
if (seatbelt.sandbox_required) {
|
||||
if (!seatbelt.server) {
|
||||
fprintf(stderr, "Failed to create seatbelt sandbox server.\n");
|
||||
abort();
|
||||
}
|
||||
if (!seatbelt.server->InitializeSandbox()) {
|
||||
fprintf(stderr, "Failed to initialize sandbox.\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
#endif // defined(HELPER_EXECUTABLE) && !defined(MAS_BUILD)
|
||||
|
||||
return AtomMain(argc, argv);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
#include <glib.h> // for g_setenv()
|
||||
#endif
|
||||
|
||||
#include "atom/app/atom_content_client.h"
|
||||
#include "atom/browser/atom_browser_client.h"
|
||||
#include "atom/browser/relauncher.h"
|
||||
#include "atom/common/google_api_key.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "atom/renderer/atom_renderer_client.h"
|
||||
#include "atom/renderer/atom_sandboxed_renderer_client.h"
|
||||
@@ -20,12 +23,17 @@
|
||||
#include "base/debug/stack_trace.h"
|
||||
#include "base/environment.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/mac/bundle_locations.h"
|
||||
#include "base/path_service.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "ipc/ipc_buildflags.h"
|
||||
#include "services/service_manager/embedder/switches.h"
|
||||
#include "services/service_manager/sandbox/switches.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/base/resource/resource_bundle.h"
|
||||
#include "ui/base/ui_base_switches.h"
|
||||
|
||||
#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED)
|
||||
#define IPC_MESSAGE_MACROS_LOG_ENABLED
|
||||
@@ -50,6 +58,25 @@ bool IsBrowserProcess(base::CommandLine* cmd) {
|
||||
return process_type.empty();
|
||||
}
|
||||
|
||||
// Returns true if this subprocess type needs the ResourceBundle initialized
|
||||
// and resources loaded.
|
||||
bool SubprocessNeedsResourceBundle(const std::string& process_type) {
|
||||
return
|
||||
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
||||
// The zygote process opens the resources for the renderers.
|
||||
process_type == service_manager::switches::kZygoteProcess ||
|
||||
#endif
|
||||
#if defined(OS_MACOSX)
|
||||
// Mac needs them too for scrollbar related images and for sandbox
|
||||
// profiles.
|
||||
process_type == ::switches::kPpapiPluginProcess ||
|
||||
process_type == ::switches::kPpapiBrokerProcess ||
|
||||
process_type == ::switches::kGpuProcess ||
|
||||
#endif
|
||||
process_type == ::switches::kRendererProcess ||
|
||||
process_type == ::switches::kUtilityProcess;
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
void InvalidParameterHandler(const wchar_t*,
|
||||
const wchar_t*,
|
||||
@@ -62,6 +89,37 @@ void InvalidParameterHandler(const wchar_t*,
|
||||
|
||||
} // namespace
|
||||
|
||||
void LoadResourceBundle(const std::string& locale) {
|
||||
const bool initialized = ui::ResourceBundle::HasSharedInstance();
|
||||
if (initialized)
|
||||
ui::ResourceBundle::CleanupSharedInstance();
|
||||
|
||||
// Load other resource files.
|
||||
base::FilePath pak_dir;
|
||||
#if defined(OS_MACOSX)
|
||||
pak_dir =
|
||||
base::mac::FrameworkBundlePath().Append(FILE_PATH_LITERAL("Resources"));
|
||||
#else
|
||||
base::PathService::Get(base::DIR_MODULE, &pak_dir);
|
||||
#endif
|
||||
|
||||
ui::ResourceBundle::InitSharedInstanceWithLocale(
|
||||
locale, nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES);
|
||||
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
|
||||
bundle.ReloadLocaleResources(locale);
|
||||
bundle.AddDataPackFromPath(pak_dir.Append(FILE_PATH_LITERAL("resources.pak")),
|
||||
ui::SCALE_FACTOR_NONE);
|
||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
NOTIMPLEMENTED()
|
||||
<< "Hi, whoever's fixing PDF support! Thanks! The pdf "
|
||||
"viewer resources haven't been ported over to the GN build yet, so "
|
||||
"you'll probably need to change this bit of code.";
|
||||
bundle.AddDataPackFromPath(
|
||||
pak_dir.Append(FILE_PATH_LITERAL("pdf_viewer_resources.pak")),
|
||||
ui::GetSupportedScaleFactors()[0]);
|
||||
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
}
|
||||
|
||||
AtomMainDelegate::AtomMainDelegate() {}
|
||||
|
||||
AtomMainDelegate::~AtomMainDelegate() {}
|
||||
@@ -101,23 +159,19 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
// Logging with pid and timestamp.
|
||||
logging::SetLogItems(true, false, true, false);
|
||||
|
||||
// Enable convient stack printing.
|
||||
#if defined(DEBUG) && defined(OS_LINUX)
|
||||
bool enable_stack_dumping = true;
|
||||
#else
|
||||
bool enable_stack_dumping = env->HasVar("ELECTRON_ENABLE_STACK_DUMPING");
|
||||
#endif
|
||||
#if defined(ARCH_CPU_ARM_FAMILY) && defined(ARCH_CPU_32_BITS)
|
||||
// For 32bit ARM enabling stack printing would end up crashing.
|
||||
// https://github.com/electron/electron/pull/11230#issuecomment-363232482
|
||||
enable_stack_dumping = false;
|
||||
#endif
|
||||
if (enable_stack_dumping)
|
||||
// Enable convient stack printing. This is enabled by default in non-official
|
||||
// builds.
|
||||
if (env->HasVar("ELECTRON_ENABLE_STACK_DUMPING"))
|
||||
base::debug::EnableInProcessStackDumping();
|
||||
|
||||
if (env->HasVar("ELECTRON_DISABLE_SANDBOX"))
|
||||
command_line->AppendSwitch(service_manager::switches::kNoSandbox);
|
||||
|
||||
chrome::RegisterPathProvider();
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
OverrideChildProcessPath();
|
||||
OverrideFrameworkBundlePath();
|
||||
SetUpBundleOverrides();
|
||||
#endif
|
||||
|
||||
@@ -129,30 +183,60 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
base::win::DisableHandleVerifier();
|
||||
#endif
|
||||
|
||||
return brightray::MainDelegate::BasicStartupComplete(exit_code);
|
||||
content_client_ = std::make_unique<AtomContentClient>();
|
||||
SetContentClient(content_client_.get());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void AtomMainDelegate::PostEarlyInitialization(bool is_running_tests) {
|
||||
std::string custom_locale;
|
||||
ui::ResourceBundle::InitSharedInstanceWithLocale(
|
||||
custom_locale, nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES);
|
||||
auto* cmd_line = base::CommandLine::ForCurrentProcess();
|
||||
if (cmd_line->HasSwitch(::switches::kLang)) {
|
||||
const std::string locale = cmd_line->GetSwitchValueASCII(::switches::kLang);
|
||||
const base::FilePath locale_file_path =
|
||||
ui::ResourceBundle::GetSharedInstance().GetLocaleFilePath(locale, true);
|
||||
if (!locale_file_path.empty()) {
|
||||
custom_locale = locale;
|
||||
#if defined(OS_LINUX)
|
||||
/* When built with USE_GLIB, libcc's GetApplicationLocaleInternal() uses
|
||||
* glib's g_get_language_names(), which keys off of getenv("LC_ALL") */
|
||||
g_setenv("LC_ALL", custom_locale.c_str(), TRUE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
if (custom_locale.empty())
|
||||
l10n_util::OverrideLocaleWithCocoaLocale();
|
||||
#endif
|
||||
|
||||
LoadResourceBundle(custom_locale);
|
||||
|
||||
AtomBrowserClient::SetApplicationLocale(
|
||||
l10n_util::GetApplicationLocale(custom_locale));
|
||||
}
|
||||
|
||||
void AtomMainDelegate::PreSandboxStartup() {
|
||||
brightray::MainDelegate::PreSandboxStartup();
|
||||
|
||||
auto* command_line = base::CommandLine::ForCurrentProcess();
|
||||
|
||||
std::string process_type =
|
||||
command_line->GetSwitchValueASCII(::switches::kProcessType);
|
||||
|
||||
// Initialize ResourceBundle which handles files loaded from external
|
||||
// sources. The language should have been passed in to us from the
|
||||
// browser process as a command line flag.
|
||||
if (SubprocessNeedsResourceBundle(process_type)) {
|
||||
std::string locale = command_line->GetSwitchValueASCII(::switches::kLang);
|
||||
LoadResourceBundle(locale);
|
||||
}
|
||||
|
||||
// Only append arguments for browser process.
|
||||
if (!IsBrowserProcess(command_line))
|
||||
return;
|
||||
|
||||
if (!command_line->HasSwitch(switches::kEnableMixedSandbox)) {
|
||||
if (command_line->HasSwitch(switches::kEnableSandbox)) {
|
||||
// Disable setuid sandbox since it is not longer required on
|
||||
// linux(namespace sandbox is available on most distros).
|
||||
command_line->AppendSwitch(
|
||||
service_manager::switches::kDisableSetuidSandbox);
|
||||
} else {
|
||||
// Disable renderer sandbox for most of node's functions.
|
||||
command_line->AppendSwitch(service_manager::switches::kNoSandbox);
|
||||
}
|
||||
}
|
||||
|
||||
// Allow file:// URIs to read other file:// URIs by default.
|
||||
command_line->AppendSwitch(::switches::kAllowFileAccessFromFiles);
|
||||
|
||||
@@ -162,7 +246,7 @@ void AtomMainDelegate::PreSandboxStartup() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void AtomMainDelegate::PreContentInitialization() {
|
||||
void AtomMainDelegate::PreCreateMainMessageLoop() {
|
||||
#if defined(OS_MACOSX)
|
||||
RegisterAtomCrApp();
|
||||
#endif
|
||||
@@ -212,9 +296,12 @@ bool AtomMainDelegate::DelaySandboxInitialization(
|
||||
}
|
||||
#endif
|
||||
|
||||
std::unique_ptr<brightray::ContentClient>
|
||||
AtomMainDelegate::CreateContentClient() {
|
||||
return std::make_unique<AtomContentClient>();
|
||||
bool AtomMainDelegate::ShouldLockSchemeRegistry() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AtomMainDelegate::ShouldCreateFeatureList() {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -8,12 +8,14 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "brightray/common/content_client.h"
|
||||
#include "brightray/common/main_delegate.h"
|
||||
#include "content/public/app/content_main_delegate.h"
|
||||
#include "content/public/common/content_client.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class AtomMainDelegate : public brightray::MainDelegate {
|
||||
void LoadResourceBundle(const std::string& locale);
|
||||
|
||||
class AtomMainDelegate : public content::ContentMainDelegate {
|
||||
public:
|
||||
AtomMainDelegate();
|
||||
~AtomMainDelegate() override;
|
||||
@@ -22,7 +24,8 @@ class AtomMainDelegate : public brightray::MainDelegate {
|
||||
// content::ContentMainDelegate:
|
||||
bool BasicStartupComplete(int* exit_code) override;
|
||||
void PreSandboxStartup() override;
|
||||
void PreContentInitialization() override;
|
||||
void PreCreateMainMessageLoop() override;
|
||||
void PostEarlyInitialization(bool is_running_tests) override;
|
||||
content::ContentBrowserClient* CreateContentBrowserClient() override;
|
||||
content::ContentRendererClient* CreateContentRendererClient() override;
|
||||
content::ContentUtilityClient* CreateContentUtilityClient() override;
|
||||
@@ -33,20 +36,18 @@ class AtomMainDelegate : public brightray::MainDelegate {
|
||||
bool ShouldSendMachPort(const std::string& process_type) override;
|
||||
bool DelaySandboxInitialization(const std::string& process_type) override;
|
||||
#endif
|
||||
|
||||
// brightray::MainDelegate:
|
||||
std::unique_ptr<brightray::ContentClient> CreateContentClient() override;
|
||||
#if defined(OS_MACOSX)
|
||||
void OverrideChildProcessPath() override;
|
||||
void OverrideFrameworkBundlePath() override;
|
||||
#endif
|
||||
bool ShouldLockSchemeRegistry() override;
|
||||
bool ShouldCreateFeatureList() override;
|
||||
|
||||
private:
|
||||
#if defined(OS_MACOSX)
|
||||
void OverrideChildProcessPath();
|
||||
void OverrideFrameworkBundlePath();
|
||||
void SetUpBundleOverrides();
|
||||
#endif
|
||||
|
||||
std::unique_ptr<content::ContentBrowserClient> browser_client_;
|
||||
std::unique_ptr<content::ContentClient> content_client_;
|
||||
std::unique_ptr<content::ContentRendererClient> renderer_client_;
|
||||
std::unique_ptr<content::ContentUtilityClient> utility_client_;
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "atom/app/atom_main_delegate.h"
|
||||
|
||||
#include "atom/browser/mac/atom_application.h"
|
||||
#include "atom/common/application_info.h"
|
||||
#include "atom/common/mac/main_application_bundle.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/mac/bundle_locations.h"
|
||||
@@ -12,8 +14,6 @@
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "brightray/common/application_info.h"
|
||||
#include "brightray/common/mac/main_application_bundle.h"
|
||||
#include "content/public/common/content_paths.h"
|
||||
|
||||
namespace atom {
|
||||
@@ -21,9 +21,7 @@ namespace atom {
|
||||
namespace {
|
||||
|
||||
base::FilePath GetFrameworksPath() {
|
||||
return brightray::MainApplicationBundlePath()
|
||||
.Append("Contents")
|
||||
.Append("Frameworks");
|
||||
return MainApplicationBundlePath().Append("Contents").Append("Frameworks");
|
||||
}
|
||||
|
||||
base::FilePath GetHelperAppPath(const base::FilePath& frameworks_path,
|
||||
@@ -46,8 +44,7 @@ void AtomMainDelegate::OverrideChildProcessPath() {
|
||||
base::FilePath helper_path =
|
||||
GetHelperAppPath(frameworks_path, ATOM_PRODUCT_NAME);
|
||||
if (!base::PathExists(helper_path))
|
||||
helper_path =
|
||||
GetHelperAppPath(frameworks_path, brightray::GetApplicationName());
|
||||
helper_path = GetHelperAppPath(frameworks_path, GetApplicationName());
|
||||
if (!base::PathExists(helper_path))
|
||||
LOG(FATAL) << "Unable to find helper app";
|
||||
base::PathService::Override(content::CHILD_PROCESS_EXE, helper_path);
|
||||
@@ -55,7 +52,7 @@ void AtomMainDelegate::OverrideChildProcessPath() {
|
||||
|
||||
void AtomMainDelegate::SetUpBundleOverrides() {
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
NSBundle* bundle = brightray::MainApplicationBundle();
|
||||
NSBundle* bundle = MainApplicationBundle();
|
||||
std::string base_bundle_id =
|
||||
base::SysNSStringToUTF8([bundle bundleIdentifier]);
|
||||
NSString* team_id = [bundle objectForInfoDictionaryKey:@"ElectronTeamID"];
|
||||
|
||||
44
atom/app/manifests.cc
Normal file
44
atom/app/manifests.cc
Normal file
@@ -0,0 +1,44 @@
|
||||
// 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/app/manifests.h"
|
||||
|
||||
#include "base/no_destructor.h"
|
||||
#include "printing/buildflags/buildflags.h"
|
||||
#include "services/proxy_resolver/proxy_resolver_manifest.h"
|
||||
#include "services/service_manager/public/cpp/manifest_builder.h"
|
||||
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
#include "components/services/pdf_compositor/pdf_compositor_manifest.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
#include "chrome/services/printing/manifest.h"
|
||||
#endif
|
||||
|
||||
const service_manager::Manifest& GetElectronContentBrowserOverlayManifest() {
|
||||
static base::NoDestructor<service_manager::Manifest> manifest{
|
||||
service_manager::ManifestBuilder()
|
||||
.WithDisplayName("Electron (browser process)")
|
||||
.RequireCapability("device", "device:geolocation_control")
|
||||
.RequireCapability("proxy_resolver", "factory")
|
||||
.RequireCapability("chrome_printing", "converter")
|
||||
.RequireCapability("pdf_compositor", "compositor")
|
||||
.Build()};
|
||||
return *manifest;
|
||||
}
|
||||
|
||||
const std::vector<service_manager::Manifest>&
|
||||
GetElectronPackagedServicesOverlayManifest() {
|
||||
static base::NoDestructor<std::vector<service_manager::Manifest>> manifests{{
|
||||
proxy_resolver::GetManifest(),
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
pdf_compositor::GetManifest(),
|
||||
#endif
|
||||
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
chrome_printing::GetManifest(),
|
||||
#endif
|
||||
}};
|
||||
return *manifests;
|
||||
}
|
||||
16
atom/app/manifests.h
Normal file
16
atom/app/manifests.h
Normal file
@@ -0,0 +1,16 @@
|
||||
// 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_APP_MANIFESTS_H_
|
||||
#define ATOM_APP_MANIFESTS_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "services/service_manager/public/cpp/manifest.h"
|
||||
|
||||
const service_manager::Manifest& GetElectronContentBrowserOverlayManifest();
|
||||
const std::vector<service_manager::Manifest>&
|
||||
GetElectronPackagedServicesOverlayManifest();
|
||||
|
||||
#endif // ATOM_APP_MANIFESTS_H_
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "atom/common/node_bindings.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/feature_list.h"
|
||||
#include "base/task_scheduler/task_scheduler.h"
|
||||
#include "base/task/task_scheduler/task_scheduler.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "gin/array_buffer.h"
|
||||
#include "gin/public/isolate_holder.h"
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/app/atom_content_client.h"
|
||||
#include "atom/browser/api/atom_api_menu.h"
|
||||
#include "atom/browser/api/atom_api_session.h"
|
||||
#include "atom/browser/api/atom_api_web_contents.h"
|
||||
#include "atom/browser/api/gpuinfo_manager.h"
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
#include "atom/browser/atom_paths.h"
|
||||
#include "atom/browser/login_handler.h"
|
||||
#include "atom/browser/relauncher.h"
|
||||
#include "atom/common/atom_command_line.h"
|
||||
@@ -30,9 +30,7 @@
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/sys_info.h"
|
||||
#include "brightray/browser/brightray_paths.h"
|
||||
#include "base/system/sys_info.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/icon_manager.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
@@ -44,13 +42,11 @@
|
||||
#include "content/public/browser/client_certificate_delegate.h"
|
||||
#include "content/public/browser/gpu_data_manager.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/common/content_client.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "media/audio/audio_manager.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
#include "net/ssl/client_cert_identity.h"
|
||||
#include "net/ssl/ssl_cert_request_info.h"
|
||||
#include "services/network/public/cpp/network_switches.h"
|
||||
#include "services/service_manager/sandbox/switches.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
@@ -67,6 +63,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include "atom/browser/ui/cocoa/atom_bundle_mover.h"
|
||||
#endif
|
||||
|
||||
@@ -397,15 +394,15 @@ IconLoader::IconSize GetIconSizeByString(const std::string& size) {
|
||||
// Return the path constant from string.
|
||||
int GetPathConstant(const std::string& name) {
|
||||
if (name == "appData")
|
||||
return brightray::DIR_APP_DATA;
|
||||
return DIR_APP_DATA;
|
||||
else if (name == "userData")
|
||||
return brightray::DIR_USER_DATA;
|
||||
return DIR_USER_DATA;
|
||||
else if (name == "cache")
|
||||
return brightray::DIR_CACHE;
|
||||
return DIR_CACHE;
|
||||
else if (name == "userCache")
|
||||
return brightray::DIR_USER_CACHE;
|
||||
return DIR_USER_CACHE;
|
||||
else if (name == "logs")
|
||||
return brightray::DIR_APP_LOGS;
|
||||
return DIR_APP_LOGS;
|
||||
else if (name == "home")
|
||||
return base::DIR_HOME;
|
||||
else if (name == "temp")
|
||||
@@ -536,18 +533,11 @@ int ImportIntoCertStore(CertificateManagerModel* model,
|
||||
}
|
||||
#endif
|
||||
|
||||
void OnIconDataAvailable(v8::Isolate* isolate,
|
||||
const App::FileIconCallback& callback,
|
||||
gfx::Image* icon) {
|
||||
v8::Locker locker(isolate);
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
||||
void OnIconDataAvailable(util::Promise promise, gfx::Image* icon) {
|
||||
if (icon && !icon->IsEmpty()) {
|
||||
callback.Run(v8::Null(isolate), *icon);
|
||||
promise.Resolve(*icon);
|
||||
} else {
|
||||
v8::Local<v8::String> error_message =
|
||||
v8::String::NewFromUtf8(isolate, "Failed to get file icon.");
|
||||
callback.Run(v8::Exception::Error(error_message), gfx::Image());
|
||||
promise.RejectWithErrorMessage("Failed to get file icon.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -685,7 +675,7 @@ void App::OnLogin(scoped_refptr<LoginHandler> login_handler,
|
||||
content::WebContents* web_contents = login_handler->GetWebContents();
|
||||
if (web_contents) {
|
||||
prevent_default = Emit(
|
||||
"login", WebContents::CreateFrom(isolate(), web_contents),
|
||||
"login", WebContents::FromOrCreate(isolate(), web_contents),
|
||||
request_details, login_handler->auth_info(),
|
||||
base::Bind(&PassLoginInformation, base::RetainedRef(login_handler)));
|
||||
}
|
||||
@@ -699,7 +689,7 @@ bool App::CanCreateWindow(
|
||||
content::RenderFrameHost* opener,
|
||||
const GURL& opener_url,
|
||||
const GURL& opener_top_level_frame_url,
|
||||
const GURL& source_origin,
|
||||
const url::Origin& source_origin,
|
||||
content::mojom::WindowContainerType container_type,
|
||||
const GURL& target_url,
|
||||
const content::Referrer& referrer,
|
||||
@@ -716,9 +706,12 @@ bool App::CanCreateWindow(
|
||||
content::WebContents* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(opener);
|
||||
if (web_contents) {
|
||||
auto api_web_contents = WebContents::CreateFrom(isolate(), web_contents);
|
||||
api_web_contents->OnCreateWindow(target_url, referrer, frame_name,
|
||||
disposition, additional_features, body);
|
||||
auto api_web_contents = WebContents::From(isolate(), web_contents);
|
||||
// No need to emit any event if the WebContents is not available in JS.
|
||||
if (!api_web_contents.IsEmpty()) {
|
||||
api_web_contents->OnCreateWindow(target_url, referrer, frame_name,
|
||||
disposition, additional_features, body);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -737,7 +730,7 @@ void App::AllowCertificateError(
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
bool prevent_default = Emit(
|
||||
"certificate-error", WebContents::CreateFrom(isolate(), web_contents),
|
||||
"certificate-error", WebContents::FromOrCreate(isolate(), web_contents),
|
||||
request_url, net::ErrorToString(cert_error), ssl_info.cert, callback);
|
||||
|
||||
// Deny the certificate by default.
|
||||
@@ -764,7 +757,7 @@ void App::SelectClientCertificate(
|
||||
|
||||
bool prevent_default =
|
||||
Emit("select-client-certificate",
|
||||
WebContents::CreateFrom(isolate(), web_contents),
|
||||
WebContents::FromOrCreate(isolate(), web_contents),
|
||||
cert_request_info->host_and_port.ToString(), std::move(client_certs),
|
||||
base::Bind(&OnClientCertificateSelected, isolate(), shared_delegate,
|
||||
shared_identities));
|
||||
@@ -786,24 +779,24 @@ void App::OnGpuProcessCrashed(base::TerminationStatus status) {
|
||||
|
||||
void App::BrowserChildProcessLaunchedAndConnected(
|
||||
const content::ChildProcessData& data) {
|
||||
ChildProcessLaunched(data.process_type, data.handle);
|
||||
ChildProcessLaunched(data.process_type, data.GetProcess().Handle());
|
||||
}
|
||||
|
||||
void App::BrowserChildProcessHostDisconnected(
|
||||
const content::ChildProcessData& data) {
|
||||
ChildProcessDisconnected(base::GetProcId(data.handle));
|
||||
ChildProcessDisconnected(base::GetProcId(data.GetProcess().Handle()));
|
||||
}
|
||||
|
||||
void App::BrowserChildProcessCrashed(
|
||||
const content::ChildProcessData& data,
|
||||
const content::ChildProcessTerminationInfo& info) {
|
||||
ChildProcessDisconnected(base::GetProcId(data.handle));
|
||||
ChildProcessDisconnected(base::GetProcId(data.GetProcess().Handle()));
|
||||
}
|
||||
|
||||
void App::BrowserChildProcessKilled(
|
||||
const content::ChildProcessData& data,
|
||||
const content::ChildProcessTerminationInfo& info) {
|
||||
ChildProcessDisconnected(base::GetProcId(data.handle));
|
||||
ChildProcessDisconnected(base::GetProcId(data.GetProcess().Handle()));
|
||||
}
|
||||
|
||||
void App::RenderProcessReady(content::RenderProcessHost* host) {
|
||||
@@ -881,6 +874,45 @@ std::string App::GetLocale() {
|
||||
return g_browser_process->GetApplicationLocale();
|
||||
}
|
||||
|
||||
std::string App::GetLocaleCountryCode() {
|
||||
std::string region;
|
||||
#if defined(OS_WIN)
|
||||
WCHAR locale_name[LOCALE_NAME_MAX_LENGTH] = {0};
|
||||
|
||||
if (GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SISO3166CTRYNAME,
|
||||
(LPWSTR)&locale_name,
|
||||
sizeof(locale_name) / sizeof(WCHAR)) ||
|
||||
GetLocaleInfoEx(LOCALE_NAME_SYSTEM_DEFAULT, LOCALE_SISO3166CTRYNAME,
|
||||
(LPWSTR)&locale_name,
|
||||
sizeof(locale_name) / sizeof(WCHAR))) {
|
||||
base::WideToUTF8(locale_name, wcslen(locale_name), ®ion);
|
||||
}
|
||||
#elif defined(OS_MACOSX)
|
||||
CFLocaleRef locale = CFLocaleCopyCurrent();
|
||||
CFStringRef value = CFStringRef(
|
||||
static_cast<CFTypeRef>(CFLocaleGetValue(locale, kCFLocaleCountryCode)));
|
||||
const CFIndex kCStringSize = 128;
|
||||
char temporaryCString[kCStringSize] = {0};
|
||||
CFStringGetCString(value, temporaryCString, kCStringSize,
|
||||
kCFStringEncodingUTF8);
|
||||
region = temporaryCString;
|
||||
#else
|
||||
const char* locale_ptr = setlocale(LC_TIME, NULL);
|
||||
if (!locale_ptr)
|
||||
locale_ptr = setlocale(LC_NUMERIC, NULL);
|
||||
if (locale_ptr) {
|
||||
std::string locale = locale_ptr;
|
||||
std::string::size_type rpos = locale.find('.');
|
||||
if (rpos != std::string::npos)
|
||||
locale = locale.substr(0, rpos);
|
||||
rpos = locale.find('_');
|
||||
if (rpos != std::string::npos && rpos + 1 < locale.size())
|
||||
region = locale.substr(rpos + 1);
|
||||
}
|
||||
#endif
|
||||
return region.size() == 2 ? region : std::string();
|
||||
}
|
||||
|
||||
void App::OnSecondInstance(const base::CommandLine::StringVector& cmd,
|
||||
const base::FilePath& cwd) {
|
||||
Emit("second-instance", cmd, cwd);
|
||||
@@ -897,7 +929,7 @@ bool App::RequestSingleInstanceLock() {
|
||||
return true;
|
||||
|
||||
base::FilePath user_dir;
|
||||
base::PathService::Get(brightray::DIR_USER_DATA, &user_dir);
|
||||
base::PathService::Get(DIR_USER_DATA, &user_dir);
|
||||
|
||||
auto cb = base::Bind(&App::OnSecondInstance, base::Unretained(this));
|
||||
|
||||
@@ -1091,16 +1123,14 @@ JumpListResult App::SetJumpList(v8::Local<v8::Value> val,
|
||||
}
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
void App::GetFileIcon(const base::FilePath& path, mate::Arguments* args) {
|
||||
mate::Dictionary options;
|
||||
IconLoader::IconSize icon_size;
|
||||
FileIconCallback callback;
|
||||
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
|
||||
v8::Local<v8::Promise> App::GetFileIcon(const base::FilePath& path,
|
||||
mate::Arguments* args) {
|
||||
util::Promise promise(isolate());
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
base::FilePath normalized_path = path.NormalizePathSeparators();
|
||||
|
||||
IconLoader::IconSize icon_size;
|
||||
mate::Dictionary options;
|
||||
if (!args->GetNext(&options)) {
|
||||
icon_size = IconLoader::IconSize::NORMAL;
|
||||
} else {
|
||||
@@ -1109,22 +1139,18 @@ void App::GetFileIcon(const base::FilePath& path, mate::Arguments* args) {
|
||||
icon_size = GetIconSizeByString(icon_size_string);
|
||||
}
|
||||
|
||||
if (!args->GetNext(&callback)) {
|
||||
args->ThrowError("Missing required callback function");
|
||||
return;
|
||||
}
|
||||
|
||||
auto* icon_manager = AtomBrowserMainParts::Get()->GetIconManager();
|
||||
gfx::Image* icon =
|
||||
icon_manager->LookupIconFromFilepath(normalized_path, icon_size);
|
||||
if (icon) {
|
||||
callback.Run(v8::Null(isolate()), *icon);
|
||||
promise.Resolve(*icon);
|
||||
} else {
|
||||
icon_manager->LoadIcon(
|
||||
normalized_path, icon_size,
|
||||
base::Bind(&OnIconDataAvailable, isolate(), callback),
|
||||
base::BindOnce(&OnIconDataAvailable, std::move(promise)),
|
||||
&cancelable_task_tracker_);
|
||||
}
|
||||
return handle;
|
||||
}
|
||||
|
||||
std::vector<mate::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
|
||||
@@ -1172,30 +1198,30 @@ v8::Local<v8::Value> App::GetGPUFeatureStatus(v8::Isolate* isolate) {
|
||||
v8::Local<v8::Promise> App::GetGPUInfo(v8::Isolate* isolate,
|
||||
const std::string& info_type) {
|
||||
auto* const gpu_data_manager = content::GpuDataManagerImpl::GetInstance();
|
||||
scoped_refptr<util::Promise> promise = new util::Promise(isolate);
|
||||
util::Promise promise(isolate);
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
if (info_type != "basic" && info_type != "complete") {
|
||||
promise->RejectWithErrorMessage(
|
||||
promise.RejectWithErrorMessage(
|
||||
"Invalid info type. Use 'basic' or 'complete'");
|
||||
return promise->GetHandle();
|
||||
return handle;
|
||||
}
|
||||
std::string reason;
|
||||
if (!gpu_data_manager->GpuAccessAllowed(&reason)) {
|
||||
promise->RejectWithErrorMessage("GPU access not allowed. Reason: " +
|
||||
reason);
|
||||
return promise->GetHandle();
|
||||
promise.RejectWithErrorMessage("GPU access not allowed. Reason: " + reason);
|
||||
return handle;
|
||||
}
|
||||
|
||||
auto* const info_mgr = GPUInfoManager::GetInstance();
|
||||
if (info_type == "complete") {
|
||||
#if defined(OS_WIN) || defined(OS_MACOSX)
|
||||
info_mgr->FetchCompleteInfo(promise);
|
||||
info_mgr->FetchCompleteInfo(std::move(promise));
|
||||
#else
|
||||
info_mgr->FetchBasicInfo(promise);
|
||||
info_mgr->FetchBasicInfo(std::move(promise));
|
||||
#endif
|
||||
} else /* (info_type == "basic") */ {
|
||||
info_mgr->FetchBasicInfo(promise);
|
||||
info_mgr->FetchBasicInfo(std::move(promise));
|
||||
}
|
||||
return promise->GetHandle();
|
||||
return handle;
|
||||
}
|
||||
|
||||
static void RemoveNoSandboxSwitch(base::CommandLine* command_line) {
|
||||
@@ -1225,31 +1251,6 @@ void App::EnableSandbox(mate::Arguments* args) {
|
||||
command_line->AppendSwitch(switches::kEnableSandbox);
|
||||
}
|
||||
|
||||
void App::EnableMixedSandbox(mate::Arguments* args) {
|
||||
if (Browser::Get()->is_ready()) {
|
||||
args->ThrowError(
|
||||
"app.enableMixedSandbox() can only be called "
|
||||
"before app is ready");
|
||||
return;
|
||||
}
|
||||
|
||||
auto* command_line = base::CommandLine::ForCurrentProcess();
|
||||
RemoveNoSandboxSwitch(command_line);
|
||||
command_line->AppendSwitch(switches::kEnableMixedSandbox);
|
||||
}
|
||||
|
||||
void App::SetUserAgentFallback(const std::string& user_agent) {
|
||||
AtomContentClient* client =
|
||||
static_cast<AtomContentClient*>(content::GetContentClient());
|
||||
client->SetUserAgent(user_agent);
|
||||
}
|
||||
|
||||
std::string App::GetUserAgentFallback() {
|
||||
AtomContentClient* client =
|
||||
static_cast<AtomContentClient*>(content::GetContentClient());
|
||||
return client->GetUserAgent();
|
||||
}
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
bool App::MoveToApplicationsFolder(mate::Arguments* args) {
|
||||
return ui::cocoa::AtomBundleMover::Move(args);
|
||||
@@ -1308,6 +1309,11 @@ void App::BuildPrototype(v8::Isolate* isolate,
|
||||
base::Bind(&Browser::InvalidateCurrentActivity, browser))
|
||||
.SetMethod("updateCurrentActivity",
|
||||
base::Bind(&Browser::UpdateCurrentActivity, browser))
|
||||
// TODO(juturu): Remove in 2.0, deprecate before then with warnings
|
||||
.SetMethod("moveToApplicationsFolder", &App::MoveToApplicationsFolder)
|
||||
.SetMethod("isInApplicationsFolder", &App::IsInApplicationsFolder)
|
||||
#endif
|
||||
#if defined(OS_MACOSX) || defined(OS_LINUX)
|
||||
.SetMethod("setAboutPanelOptions",
|
||||
base::Bind(&Browser::SetAboutPanelOptions, browser))
|
||||
.SetMethod("showAboutPanel",
|
||||
@@ -1328,6 +1334,7 @@ void App::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("getPath", &App::GetPath)
|
||||
.SetMethod("setDesktopName", &App::SetDesktopName)
|
||||
.SetMethod("getLocale", &App::GetLocale)
|
||||
.SetMethod("getLocaleCountryCode", &App::GetLocaleCountryCode)
|
||||
#if defined(USE_NSS_CERTS)
|
||||
.SetMethod("importCertificate", &App::ImportCertificate)
|
||||
#endif
|
||||
@@ -1347,19 +1354,11 @@ void App::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("getAppMetrics", &App::GetAppMetrics)
|
||||
.SetMethod("getGPUFeatureStatus", &App::GetGPUFeatureStatus)
|
||||
.SetMethod("getGPUInfo", &App::GetGPUInfo)
|
||||
// TODO(juturu): Remove in 2.0, deprecate before then with warnings
|
||||
#if defined(OS_MACOSX)
|
||||
.SetMethod("moveToApplicationsFolder", &App::MoveToApplicationsFolder)
|
||||
.SetMethod("isInApplicationsFolder", &App::IsInApplicationsFolder)
|
||||
#endif
|
||||
#if defined(MAS_BUILD)
|
||||
.SetMethod("startAccessingSecurityScopedResource",
|
||||
&App::StartAccessingSecurityScopedResource)
|
||||
#endif
|
||||
.SetProperty("userAgentFallback", &App::GetUserAgentFallback,
|
||||
&App::SetUserAgentFallback)
|
||||
.SetMethod("enableSandbox", &App::EnableSandbox)
|
||||
.SetMethod("enableMixedSandbox", &App::EnableMixedSandbox);
|
||||
.SetMethod("enableSandbox", &App::EnableSandbox);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
@@ -1368,25 +1367,6 @@ void App::BuildPrototype(v8::Isolate* isolate,
|
||||
|
||||
namespace {
|
||||
|
||||
void AppendSwitch(const std::string& switch_string, mate::Arguments* args) {
|
||||
auto* command_line = base::CommandLine::ForCurrentProcess();
|
||||
|
||||
if (base::EndsWith(switch_string, "-path",
|
||||
base::CompareCase::INSENSITIVE_ASCII) ||
|
||||
switch_string == network::switches::kLogNetLog) {
|
||||
base::FilePath path;
|
||||
args->GetNext(&path);
|
||||
command_line->AppendSwitchPath(switch_string, path);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string value;
|
||||
if (args->GetNext(&value))
|
||||
command_line->AppendSwitchASCII(switch_string, value);
|
||||
else
|
||||
command_line->AppendSwitch(switch_string);
|
||||
}
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
int DockBounce(const std::string& type) {
|
||||
int request_id = -1;
|
||||
@@ -1407,14 +1387,11 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
auto* command_line = base::CommandLine::ForCurrentProcess();
|
||||
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.Set("App", atom::api::App::GetConstructor(isolate)->GetFunction());
|
||||
dict.Set("App", atom::api::App::GetConstructor(isolate)
|
||||
->GetFunction(context)
|
||||
.ToLocalChecked());
|
||||
dict.Set("app", atom::api::App::Create(isolate));
|
||||
dict.SetMethod("appendSwitch", &AppendSwitch);
|
||||
dict.SetMethod("appendArgument", base::Bind(&base::CommandLine::AppendArg,
|
||||
base::Unretained(command_line)));
|
||||
#if defined(OS_MACOSX)
|
||||
auto browser = base::Unretained(Browser::Get());
|
||||
dict.SetMethod("dockBounce", &DockBounce);
|
||||
@@ -1436,4 +1413,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_app, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_app, Initialize)
|
||||
|
||||
@@ -141,7 +141,7 @@ class App : public AtomBrowserClient::Delegate,
|
||||
bool CanCreateWindow(content::RenderFrameHost* opener,
|
||||
const GURL& opener_url,
|
||||
const GURL& opener_top_level_frame_url,
|
||||
const GURL& source_origin,
|
||||
const url::Origin& source_origin,
|
||||
content::mojom::WindowContainerType container_type,
|
||||
const GURL& target_url,
|
||||
const content::Referrer& referrer,
|
||||
@@ -182,6 +182,7 @@ class App : public AtomBrowserClient::Delegate,
|
||||
|
||||
void SetDesktopName(const std::string& desktop_name);
|
||||
std::string GetLocale();
|
||||
std::string GetLocaleCountryCode();
|
||||
void OnSecondInstance(const base::CommandLine::StringVector& cmd,
|
||||
const base::FilePath& cwd);
|
||||
bool HasSingleInstanceLock() const;
|
||||
@@ -197,16 +198,14 @@ class App : public AtomBrowserClient::Delegate,
|
||||
void ImportCertificate(const base::DictionaryValue& options,
|
||||
const net::CompletionCallback& callback);
|
||||
#endif
|
||||
void GetFileIcon(const base::FilePath& path, mate::Arguments* args);
|
||||
v8::Local<v8::Promise> GetFileIcon(const base::FilePath& path,
|
||||
mate::Arguments* args);
|
||||
|
||||
std::vector<mate::Dictionary> GetAppMetrics(v8::Isolate* isolate);
|
||||
v8::Local<v8::Value> GetGPUFeatureStatus(v8::Isolate* isolate);
|
||||
v8::Local<v8::Promise> GetGPUInfo(v8::Isolate* isolate,
|
||||
const std::string& info_type);
|
||||
void EnableSandbox(mate::Arguments* args);
|
||||
void EnableMixedSandbox(mate::Arguments* args);
|
||||
void SetUserAgentFallback(const std::string& user_agent);
|
||||
std::string GetUserAgentFallback();
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
bool MoveToApplicationsFolder(mate::Arguments* args);
|
||||
|
||||
@@ -147,9 +147,11 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.Set("autoUpdater", AutoUpdater::Create(isolate));
|
||||
dict.Set("AutoUpdater", AutoUpdater::GetConstructor(isolate)->GetFunction());
|
||||
dict.Set("AutoUpdater", AutoUpdater::GetConstructor(isolate)
|
||||
->GetFunction(context)
|
||||
.ToLocalChecked());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_auto_updater, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_auto_updater, Initialize)
|
||||
|
||||
@@ -159,8 +159,9 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
BrowserView::SetConstructor(isolate, base::Bind(&BrowserView::New));
|
||||
|
||||
mate::Dictionary browser_view(
|
||||
isolate, BrowserView::GetConstructor(isolate)->GetFunction());
|
||||
mate::Dictionary browser_view(isolate, BrowserView::GetConstructor(isolate)
|
||||
->GetFunction(context)
|
||||
.ToLocalChecked());
|
||||
browser_view.SetMethod("fromId",
|
||||
&mate::TrackableObject<BrowserView>::FromWeakMapID);
|
||||
browser_view.SetMethod("getAllViews",
|
||||
@@ -171,4 +172,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_browser_view, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_browser_view, Initialize)
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_owner_delegate.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "gin/converter.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "ui/gl/gpu_switching_manager.h"
|
||||
|
||||
@@ -74,10 +76,6 @@ BrowserWindow::BrowserWindow(v8::Isolate* isolate,
|
||||
mate::Dictionary(isolate, web_contents->GetWrapper())
|
||||
.Set("browserWindowOptions", options);
|
||||
|
||||
// Tell the content module to initialize renderer widget with transparent
|
||||
// mode.
|
||||
ui::GpuSwitchingManager::SetTransparent(window()->transparent());
|
||||
|
||||
// Associate with BrowserWindow.
|
||||
web_contents->SetOwnerWindow(window());
|
||||
|
||||
@@ -133,7 +131,7 @@ void BrowserWindow::RenderViewCreated(
|
||||
render_view_host->GetProcess()->GetID(),
|
||||
render_view_host->GetRoutingID());
|
||||
if (impl)
|
||||
impl->SetBackgroundOpaque(false);
|
||||
impl->owner_delegate()->SetBackgroundOpaque(false);
|
||||
}
|
||||
|
||||
void BrowserWindow::DidFirstVisuallyNonEmptyPaint() {
|
||||
@@ -241,7 +239,7 @@ void BrowserWindow::OnCloseButtonClicked(bool* prevent_default) {
|
||||
return;
|
||||
|
||||
if (web_contents()->NeedToFireBeforeUnload())
|
||||
web_contents()->DispatchBeforeUnload();
|
||||
web_contents()->DispatchBeforeUnload(false /* auto_cancel */);
|
||||
else
|
||||
web_contents()->Close();
|
||||
}
|
||||
@@ -314,7 +312,29 @@ void BrowserWindow::SetBackgroundColor(const std::string& color_name) {
|
||||
}
|
||||
|
||||
void BrowserWindow::SetBrowserView(v8::Local<v8::Value> value) {
|
||||
TopLevelWindow::SetBrowserView(value);
|
||||
TopLevelWindow::ResetBrowserViews();
|
||||
TopLevelWindow::AddBrowserView(value);
|
||||
#if defined(OS_MACOSX)
|
||||
UpdateDraggableRegions(nullptr, draggable_regions_);
|
||||
#endif
|
||||
}
|
||||
|
||||
void BrowserWindow::AddBrowserView(v8::Local<v8::Value> value) {
|
||||
TopLevelWindow::AddBrowserView(value);
|
||||
#if defined(OS_MACOSX)
|
||||
UpdateDraggableRegions(nullptr, draggable_regions_);
|
||||
#endif
|
||||
}
|
||||
|
||||
void BrowserWindow::RemoveBrowserView(v8::Local<v8::Value> value) {
|
||||
TopLevelWindow::RemoveBrowserView(value);
|
||||
#if defined(OS_MACOSX)
|
||||
UpdateDraggableRegions(nullptr, draggable_regions_);
|
||||
#endif
|
||||
}
|
||||
|
||||
void BrowserWindow::ResetBrowserViews() {
|
||||
TopLevelWindow::ResetBrowserViews();
|
||||
#if defined(OS_MACOSX)
|
||||
UpdateDraggableRegions(nullptr, draggable_regions_);
|
||||
#endif
|
||||
@@ -322,7 +342,7 @@ void BrowserWindow::SetBrowserView(v8::Local<v8::Value> value) {
|
||||
|
||||
void BrowserWindow::SetVibrancy(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> value) {
|
||||
std::string type = mate::V8ToString(value);
|
||||
std::string type = gin::V8ToString(isolate, value);
|
||||
|
||||
auto* render_view_host = web_contents()->GetRenderViewHost();
|
||||
if (render_view_host) {
|
||||
@@ -330,7 +350,8 @@ void BrowserWindow::SetVibrancy(v8::Isolate* isolate,
|
||||
render_view_host->GetProcess()->GetID(),
|
||||
render_view_host->GetRoutingID());
|
||||
if (impl)
|
||||
impl->SetBackgroundOpaque(type.empty() ? !window_->transparent() : false);
|
||||
impl->owner_delegate()->SetBackgroundOpaque(
|
||||
type.empty() ? !window_->transparent() : false);
|
||||
}
|
||||
|
||||
TopLevelWindow::SetVibrancy(isolate, value);
|
||||
@@ -460,4 +481,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_window, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_window, Initialize)
|
||||
|
||||
@@ -72,6 +72,9 @@ class BrowserWindow : public TopLevelWindow,
|
||||
void Blur() override;
|
||||
void SetBackgroundColor(const std::string& color_name) override;
|
||||
void SetBrowserView(v8::Local<v8::Value> value) override;
|
||||
void AddBrowserView(v8::Local<v8::Value> value) override;
|
||||
void RemoveBrowserView(v8::Local<v8::Value> value) override;
|
||||
void ResetBrowserViews() override;
|
||||
void SetVibrancy(v8::Isolate* isolate, v8::Local<v8::Value> value) override;
|
||||
|
||||
// BrowserWindow APIs.
|
||||
@@ -82,7 +85,7 @@ class BrowserWindow : public TopLevelWindow,
|
||||
|
||||
private:
|
||||
#if defined(OS_MACOSX)
|
||||
void OverrideNSWindowContentView(brightray::InspectableWebContents* iwc);
|
||||
void OverrideNSWindowContentView(InspectableWebContents* iwc);
|
||||
#endif
|
||||
|
||||
// Helpers.
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
#include "atom/browser/native_browser_view.h"
|
||||
#include "atom/browser/native_window_mac.h"
|
||||
#include "atom/browser/ui/inspectable_web_contents_view.h"
|
||||
#include "atom/common/draggable_region.h"
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "brightray/browser/inspectable_web_contents_view.h"
|
||||
|
||||
@interface NSView (WebContentsView)
|
||||
- (void)setMouseDownCanMoveWindow:(BOOL)can_move;
|
||||
@@ -55,13 +55,13 @@ std::vector<gfx::Rect> CalculateNonDraggableRegions(
|
||||
|
||||
} // namespace
|
||||
|
||||
void BrowserWindow::OverrideNSWindowContentView(
|
||||
brightray::InspectableWebContents* iwc) {
|
||||
void BrowserWindow::OverrideNSWindowContentView(InspectableWebContents* iwc) {
|
||||
// Make NativeWindow use a NSView as content view.
|
||||
static_cast<NativeWindowMac*>(window())->OverrideNSWindowContentView();
|
||||
// Add webview to contentView.
|
||||
NSView* webView = iwc->GetView()->GetNativeView();
|
||||
NSView* contentView = [window()->GetNativeWindow() contentView];
|
||||
NSView* webView = iwc->GetView()->GetNativeView().GetNativeNSView();
|
||||
NSView* contentView =
|
||||
[window()->GetNativeWindow().GetNativeNSWindow() contentView];
|
||||
[webView setFrame:[contentView bounds]];
|
||||
|
||||
// ensure that buttons view is floated to top of view hierarchy
|
||||
@@ -81,7 +81,7 @@ void BrowserWindow::UpdateDraggableRegions(
|
||||
// All ControlRegionViews should be added as children of the WebContentsView,
|
||||
// because WebContentsView will be removed and re-added when entering and
|
||||
// leaving fullscreen mode.
|
||||
NSView* webView = web_contents()->GetNativeView();
|
||||
NSView* webView = web_contents()->GetNativeView().GetNativeNSView();
|
||||
NSInteger webViewWidth = NSWidth([webView bounds]);
|
||||
NSInteger webViewHeight = NSHeight([webView bounds]);
|
||||
|
||||
@@ -109,8 +109,10 @@ void BrowserWindow::UpdateDraggableRegions(
|
||||
DraggableRegionsToSkRegion(regions), webViewWidth, webViewHeight);
|
||||
}
|
||||
|
||||
if (window_->browser_view())
|
||||
window_->browser_view()->UpdateDraggableRegions(drag_exclude_rects);
|
||||
auto browser_views = window_->browser_views();
|
||||
for (NativeBrowserView* view : browser_views) {
|
||||
(view)->UpdateDraggableRegions(drag_exclude_rects);
|
||||
}
|
||||
|
||||
// Create and add a ControlRegionView for each region that needs to be
|
||||
// excluded from the dragging.
|
||||
|
||||
@@ -8,8 +8,10 @@
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "atom/common/promise_util.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "content/public/browser/tracing_controller.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
||||
@@ -58,6 +60,11 @@ scoped_refptr<TracingController::TraceDataEndpoint> GetTraceDataEndpoint(
|
||||
const base::FilePath& path,
|
||||
const CompletionCallback& callback) {
|
||||
base::FilePath result_file_path = path;
|
||||
|
||||
// base::CreateTemporaryFile prevents blocking so we need to allow it
|
||||
// for now since offloading this to a different sequence would require
|
||||
// changing the api shape
|
||||
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
||||
if (result_file_path.empty() && !base::CreateTemporaryFile(&result_file_path))
|
||||
LOG(ERROR) << "Creating temporary file failed";
|
||||
|
||||
@@ -65,28 +72,72 @@ scoped_refptr<TracingController::TraceDataEndpoint> GetTraceDataEndpoint(
|
||||
result_file_path, base::Bind(callback, result_file_path));
|
||||
}
|
||||
|
||||
void StopRecording(const base::FilePath& path,
|
||||
const CompletionCallback& callback) {
|
||||
TracingController::GetInstance()->StopTracing(
|
||||
GetTraceDataEndpoint(path, callback));
|
||||
void OnRecordingStopped(const atom::util::CopyablePromise& promise,
|
||||
const base::FilePath& path) {
|
||||
promise.GetPromise().Resolve(path);
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> StopRecording(v8::Isolate* isolate,
|
||||
const base::FilePath& path) {
|
||||
atom::util::Promise promise(isolate);
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
// TODO(zcbenz): Remove the use of CopyablePromise when the
|
||||
// CreateFileEndpoint API accepts OnceCallback.
|
||||
TracingController::GetInstance()->StopTracing(GetTraceDataEndpoint(
|
||||
path,
|
||||
base::Bind(&OnRecordingStopped, atom::util::CopyablePromise(promise))));
|
||||
return handle;
|
||||
}
|
||||
|
||||
void OnCategoriesAvailable(atom::util::Promise promise,
|
||||
const std::set<std::string>& categories) {
|
||||
promise.Resolve(categories);
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> GetCategories(v8::Isolate* isolate) {
|
||||
atom::util::Promise promise(isolate);
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
// Note: This method always succeeds.
|
||||
TracingController::GetInstance()->GetCategories(
|
||||
base::BindOnce(&OnCategoriesAvailable, std::move(promise)));
|
||||
return handle;
|
||||
}
|
||||
|
||||
void OnTracingStarted(atom::util::Promise promise) {
|
||||
promise.Resolve();
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> StartTracing(
|
||||
v8::Isolate* isolate,
|
||||
const base::trace_event::TraceConfig& trace_config) {
|
||||
atom::util::Promise promise(isolate);
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
// Note: This method always succeeds.
|
||||
TracingController::GetInstance()->StartTracing(
|
||||
trace_config, base::BindOnce(&OnTracingStarted, std::move(promise)));
|
||||
return handle;
|
||||
}
|
||||
|
||||
bool GetTraceBufferUsage(
|
||||
const base::RepeatingCallback<void(float, size_t)>& callback) {
|
||||
return TracingController::GetInstance()->GetTraceBufferUsage(
|
||||
base::BindOnce(callback));
|
||||
}
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
auto controller = base::Unretained(TracingController::GetInstance());
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("getCategories",
|
||||
base::Bind(&TracingController::GetCategories, controller));
|
||||
dict.SetMethod("startRecording",
|
||||
base::Bind(&TracingController::StartTracing, controller));
|
||||
dict.SetMethod("getCategories", &GetCategories);
|
||||
dict.SetMethod("startRecording", &StartTracing);
|
||||
dict.SetMethod("stopRecording", &StopRecording);
|
||||
dict.SetMethod(
|
||||
"getTraceBufferUsage",
|
||||
base::Bind(&TracingController::GetTraceBufferUsage, controller));
|
||||
dict.SetMethod("getTraceBufferUsage", &GetTraceBufferUsage);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_content_tracing, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_content_tracing, Initialize)
|
||||
|
||||
@@ -12,9 +12,11 @@
|
||||
#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"
|
||||
@@ -134,67 +136,96 @@ inline net::CookieStore* GetCookieStore(
|
||||
return getter->GetURLRequestContext()->cookie_store();
|
||||
}
|
||||
|
||||
void ResolvePromiseWithCookies(util::Promise promise,
|
||||
const net::CookieList& cookie_list) {
|
||||
promise.Resolve(cookie_list);
|
||||
}
|
||||
|
||||
void ResolvePromise(util::Promise promise) {
|
||||
promise.Resolve();
|
||||
}
|
||||
|
||||
// Resolve |promise| in UI thread.
|
||||
void ResolvePromiseInUI(util::Promise promise) {
|
||||
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
|
||||
base::BindOnce(ResolvePromise, std::move(promise)));
|
||||
}
|
||||
|
||||
// Run |callback| on UI thread.
|
||||
void RunCallbackInUI(const base::Closure& callback) {
|
||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback);
|
||||
void RunCallbackInUI(base::OnceClosure callback) {
|
||||
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, std::move(callback));
|
||||
}
|
||||
|
||||
// Remove cookies from |list| not matching |filter|, and pass it to |callback|.
|
||||
void FilterCookies(std::unique_ptr<base::DictionaryValue> filter,
|
||||
const Cookies::GetCallback& callback,
|
||||
util::Promise promise,
|
||||
const net::CookieList& list) {
|
||||
net::CookieList result;
|
||||
for (const auto& cookie : list) {
|
||||
if (MatchesCookie(filter.get(), cookie))
|
||||
result.push_back(cookie);
|
||||
}
|
||||
RunCallbackInUI(base::Bind(callback, Cookies::SUCCESS, result));
|
||||
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::UI},
|
||||
base::BindOnce(ResolvePromiseWithCookies, std::move(promise), result));
|
||||
}
|
||||
|
||||
// Receives cookies matching |filter| in IO thread.
|
||||
void GetCookiesOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||
std::unique_ptr<base::DictionaryValue> filter,
|
||||
const Cookies::GetCallback& callback) {
|
||||
util::Promise promise) {
|
||||
std::string url;
|
||||
filter->GetString("url", &url);
|
||||
|
||||
auto filtered_callback =
|
||||
base::Bind(FilterCookies, base::Passed(&filter), callback);
|
||||
base::BindOnce(FilterCookies, std::move(filter), std::move(promise));
|
||||
|
||||
// Empty url will match all url cookies.
|
||||
if (url.empty())
|
||||
GetCookieStore(getter)->GetAllCookiesAsync(filtered_callback);
|
||||
GetCookieStore(getter)->GetAllCookiesAsync(std::move(filtered_callback));
|
||||
else
|
||||
GetCookieStore(getter)->GetAllCookiesForURLAsync(GURL(url),
|
||||
filtered_callback);
|
||||
GetCookieStore(getter)->GetAllCookiesForURLAsync(
|
||||
GURL(url), std::move(filtered_callback));
|
||||
}
|
||||
|
||||
// Removes cookie with |url| and |name| in IO thread.
|
||||
void RemoveCookieOnIOThread(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||
const GURL& url,
|
||||
const std::string& name,
|
||||
const base::Closure& callback) {
|
||||
void RemoveCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||
const GURL& url,
|
||||
const std::string& name,
|
||||
util::Promise promise) {
|
||||
GetCookieStore(getter)->DeleteCookieAsync(
|
||||
url, name, base::BindOnce(RunCallbackInUI, callback));
|
||||
url, name, base::BindOnce(ResolvePromiseInUI, std::move(promise)));
|
||||
}
|
||||
|
||||
// Resolves/rejects the |promise| in UI thread.
|
||||
void SettlePromiseInUI(util::Promise promise, const std::string& errmsg) {
|
||||
if (errmsg.empty()) {
|
||||
promise.Resolve();
|
||||
} else {
|
||||
promise.RejectWithErrorMessage(errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
// Callback of SetCookie.
|
||||
void OnSetCookie(const Cookies::SetCallback& callback, bool success) {
|
||||
void OnSetCookie(util::Promise promise, bool success) {
|
||||
const std::string errmsg = success ? "" : "Setting cookie failed";
|
||||
RunCallbackInUI(
|
||||
base::Bind(callback, success ? Cookies::SUCCESS : Cookies::FAILED));
|
||||
base::BindOnce(SettlePromiseInUI, std::move(promise), errmsg));
|
||||
}
|
||||
|
||||
// Flushes cookie store in IO thread.
|
||||
void FlushCookieStoreOnIOThread(
|
||||
scoped_refptr<net::URLRequestContextGetter> getter,
|
||||
const base::Closure& callback) {
|
||||
GetCookieStore(getter)->FlushStore(base::BindOnce(RunCallbackInUI, callback));
|
||||
util::Promise promise) {
|
||||
GetCookieStore(getter)->FlushStore(
|
||||
base::BindOnce(ResolvePromiseInUI, std::move(promise)));
|
||||
}
|
||||
|
||||
// Sets cookie with |details| in IO thread.
|
||||
void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||
std::unique_ptr<base::DictionaryValue> details,
|
||||
const Cookies::SetCallback& callback) {
|
||||
util::Promise promise) {
|
||||
std::string url, name, value, domain, path;
|
||||
bool secure = false;
|
||||
bool http_only = false;
|
||||
@@ -235,7 +266,7 @@ void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||
GURL(url), name, value, domain, path, creation_time, expiration_time,
|
||||
last_access_time, secure, http_only,
|
||||
net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT));
|
||||
auto completion_callback = base::BindOnce(OnSetCookie, callback);
|
||||
auto completion_callback = base::BindOnce(OnSetCookie, std::move(promise));
|
||||
if (!canonical_cookie || !canonical_cookie->IsCanonical()) {
|
||||
std::move(completion_callback).Run(false);
|
||||
return;
|
||||
@@ -265,44 +296,61 @@ Cookies::Cookies(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
||||
|
||||
Cookies::~Cookies() {}
|
||||
|
||||
void Cookies::Get(const base::DictionaryValue& filter,
|
||||
const GetCallback& callback) {
|
||||
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();
|
||||
content::BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(GetCookiesOnIO, base::RetainedRef(getter), std::move(copy),
|
||||
callback));
|
||||
std::move(promise)));
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void Cookies::Remove(const GURL& url,
|
||||
const std::string& name,
|
||||
const base::Closure& callback) {
|
||||
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();
|
||||
content::BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::BindOnce(RemoveCookieOnIOThread, base::RetainedRef(getter), url,
|
||||
name, callback));
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(RemoveCookieOnIO, base::RetainedRef(getter), url, name,
|
||||
std::move(promise)));
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void Cookies::Set(const base::DictionaryValue& details,
|
||||
const SetCallback& callback) {
|
||||
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();
|
||||
content::BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(SetCookieOnIO, base::RetainedRef(getter), std::move(copy),
|
||||
callback));
|
||||
std::move(promise)));
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void Cookies::FlushStore(const base::Closure& callback) {
|
||||
v8::Local<v8::Promise> Cookies::FlushStore() {
|
||||
util::Promise promise(isolate());
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
auto* getter = browser_context_->GetRequestContext();
|
||||
content::BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(FlushCookieStoreOnIOThread, base::RetainedRef(getter),
|
||||
callback));
|
||||
std::move(promise)));
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void Cookies::OnCookieChanged(const CookieDetails* details) {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "atom/browser/api/trackable_object.h"
|
||||
#include "atom/browser/net/cookie_details.h"
|
||||
#include "atom/common/promise_util.h"
|
||||
#include "base/callback_list.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "net/cookies/canonical_cookie.h"
|
||||
@@ -35,9 +36,6 @@ class Cookies : public mate::TrackableObject<Cookies> {
|
||||
FAILED,
|
||||
};
|
||||
|
||||
using GetCallback = base::Callback<void(Error, const net::CookieList&)>;
|
||||
using SetCallback = base::Callback<void(Error)>;
|
||||
|
||||
static mate::Handle<Cookies> Create(v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context);
|
||||
|
||||
@@ -49,12 +47,10 @@ class Cookies : public mate::TrackableObject<Cookies> {
|
||||
Cookies(v8::Isolate* isolate, AtomBrowserContext* browser_context);
|
||||
~Cookies() override;
|
||||
|
||||
void Get(const base::DictionaryValue& filter, const GetCallback& callback);
|
||||
void Remove(const GURL& url,
|
||||
const std::string& name,
|
||||
const base::Closure& callback);
|
||||
void Set(const base::DictionaryValue& details, const SetCallback& callback);
|
||||
void FlushStore(const base::Closure& callback);
|
||||
v8::Local<v8::Promise> Get(const base::DictionaryValue& filter);
|
||||
v8::Local<v8::Promise> Set(const base::DictionaryValue& details);
|
||||
v8::Local<v8::Promise> Remove(const GURL& url, const std::string& name);
|
||||
v8::Local<v8::Promise> FlushStore();
|
||||
|
||||
// CookieChangeNotifier subscription:
|
||||
void OnCookieChanged(const CookieDetails*);
|
||||
|
||||
@@ -61,23 +61,26 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
|
||||
params.Swap(params_value);
|
||||
Emit("message", method, params);
|
||||
} else {
|
||||
auto send_command_callback = pending_requests_[id];
|
||||
pending_requests_.erase(id);
|
||||
if (send_command_callback.is_null())
|
||||
auto it = pending_requests_.find(id);
|
||||
if (it == pending_requests_.end())
|
||||
return;
|
||||
base::DictionaryValue* error_body = nullptr;
|
||||
base::DictionaryValue error;
|
||||
bool has_error;
|
||||
if ((has_error = dict->GetDictionary("error", &error_body))) {
|
||||
error.Swap(error_body);
|
||||
}
|
||||
|
||||
base::DictionaryValue* result_body = nullptr;
|
||||
base::DictionaryValue result;
|
||||
if (dict->GetDictionary("result", &result_body))
|
||||
result.Swap(result_body);
|
||||
send_command_callback.Run(has_error ? error.Clone() : base::Value(),
|
||||
result);
|
||||
atom::util::Promise promise = std::move(it->second);
|
||||
pending_requests_.erase(it);
|
||||
|
||||
base::DictionaryValue* error = nullptr;
|
||||
if (dict->GetDictionary("error", &error)) {
|
||||
std::string message;
|
||||
error->GetString("message", &message);
|
||||
promise.RejectWithErrorMessage(message);
|
||||
} else {
|
||||
base::DictionaryValue* result_body = nullptr;
|
||||
base::DictionaryValue result;
|
||||
if (dict->GetDictionary("result", &result_body)) {
|
||||
result.Swap(result_body);
|
||||
}
|
||||
promise.Resolve(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,23 +128,27 @@ void Debugger::Detach() {
|
||||
AgentHostClosed(agent_host_.get());
|
||||
}
|
||||
|
||||
void Debugger::SendCommand(mate::Arguments* args) {
|
||||
if (!agent_host_)
|
||||
return;
|
||||
v8::Local<v8::Promise> Debugger::SendCommand(mate::Arguments* args) {
|
||||
atom::util::Promise promise(isolate());
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
if (!agent_host_) {
|
||||
promise.RejectWithErrorMessage("No target available");
|
||||
return handle;
|
||||
}
|
||||
|
||||
std::string method;
|
||||
if (!args->GetNext(&method)) {
|
||||
args->ThrowError();
|
||||
return;
|
||||
promise.RejectWithErrorMessage("Invalid method");
|
||||
return handle;
|
||||
}
|
||||
|
||||
base::DictionaryValue command_params;
|
||||
args->GetNext(&command_params);
|
||||
SendCommandCallback callback;
|
||||
args->GetNext(&callback);
|
||||
|
||||
base::DictionaryValue request;
|
||||
int request_id = ++previous_request_id_;
|
||||
pending_requests_[request_id] = callback;
|
||||
pending_requests_.emplace(request_id, std::move(promise));
|
||||
request.SetInteger("id", request_id);
|
||||
request.SetString("method", method);
|
||||
if (!command_params.empty())
|
||||
@@ -151,16 +158,13 @@ void Debugger::SendCommand(mate::Arguments* args) {
|
||||
std::string json_args;
|
||||
base::JSONWriter::Write(request, &json_args);
|
||||
agent_host_->DispatchProtocolMessage(this, json_args);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void Debugger::ClearPendingRequests() {
|
||||
if (pending_requests_.empty())
|
||||
return;
|
||||
base::Value error(base::Value::Type::DICTIONARY);
|
||||
base::Value error_msg("target closed while handling command");
|
||||
error.SetKey("message", std::move(error_msg));
|
||||
for (const auto& it : pending_requests_)
|
||||
it.second.Run(error, base::Value());
|
||||
for (auto& it : pending_requests_)
|
||||
it.second.RejectWithErrorMessage("target closed while handling command");
|
||||
}
|
||||
|
||||
// static
|
||||
@@ -194,9 +198,11 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary(isolate, exports)
|
||||
.Set("Debugger", Debugger::GetConstructor(isolate)->GetFunction());
|
||||
.Set("Debugger", Debugger::GetConstructor(isolate)
|
||||
->GetFunction(context)
|
||||
.ToLocalChecked());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_debugger, Initialize);
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_debugger, Initialize);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "atom/browser/api/trackable_object.h"
|
||||
#include "atom/common/promise_util.h"
|
||||
#include "base/callback.h"
|
||||
#include "base/values.h"
|
||||
#include "content/public/browser/devtools_agent_host_client.h"
|
||||
@@ -32,9 +33,6 @@ class Debugger : public mate::TrackableObject<Debugger>,
|
||||
public content::DevToolsAgentHostClient,
|
||||
public content::WebContentsObserver {
|
||||
public:
|
||||
using SendCommandCallback =
|
||||
base::Callback<void(const base::Value&, const base::Value&)>;
|
||||
|
||||
static mate::Handle<Debugger> Create(v8::Isolate* isolate,
|
||||
content::WebContents* web_contents);
|
||||
|
||||
@@ -56,12 +54,12 @@ class Debugger : public mate::TrackableObject<Debugger>,
|
||||
content::RenderFrameHost* new_rfh) override;
|
||||
|
||||
private:
|
||||
using PendingRequestMap = std::map<int, SendCommandCallback>;
|
||||
using PendingRequestMap = std::map<int, atom::util::Promise>;
|
||||
|
||||
void Attach(mate::Arguments* args);
|
||||
bool IsAttached();
|
||||
void Detach();
|
||||
void SendCommand(mate::Arguments* args);
|
||||
v8::Local<v8::Promise> SendCommand(mate::Arguments* args);
|
||||
void ClearPendingRequests();
|
||||
|
||||
content::WebContents* web_contents_; // Weak Reference.
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "chrome/browser/media/webrtc/desktop_media_list.h"
|
||||
#include "chrome/browser/media/webrtc/window_icon_util.h"
|
||||
#include "content/public/browser/desktop_capture.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h"
|
||||
@@ -42,6 +43,12 @@ struct Converter<atom::api::DesktopCapturer::Source> {
|
||||
atom::api::NativeImage::Create(
|
||||
isolate, gfx::Image(source.media_list_source.thumbnail)));
|
||||
dict.Set("display_id", source.display_id);
|
||||
if (source.fetch_icon) {
|
||||
dict.Set(
|
||||
"appIcon",
|
||||
atom::api::NativeImage::Create(
|
||||
isolate, gfx::Image(GetWindowIcon(source.media_list_source.id))));
|
||||
}
|
||||
return ConvertToV8(isolate, dict);
|
||||
}
|
||||
};
|
||||
@@ -60,7 +67,9 @@ DesktopCapturer::~DesktopCapturer() {}
|
||||
|
||||
void DesktopCapturer::StartHandling(bool capture_window,
|
||||
bool capture_screen,
|
||||
const gfx::Size& thumbnail_size) {
|
||||
const gfx::Size& thumbnail_size,
|
||||
bool fetch_window_icons) {
|
||||
fetch_window_icons_ = fetch_window_icons;
|
||||
#if defined(OS_WIN)
|
||||
if (content::desktop_capture::CreateDesktopCaptureOptions()
|
||||
.allow_directx_capturer()) {
|
||||
@@ -79,10 +88,6 @@ void DesktopCapturer::StartHandling(bool capture_window,
|
||||
capture_screen_ = capture_screen;
|
||||
|
||||
{
|
||||
// Remove this once
|
||||
// https://bugs.chromium.org/p/chromium/issues/detail?id=795340 is fixed.
|
||||
base::ScopedAllowBaseSyncPrimitivesForTesting
|
||||
scoped_allow_base_sync_primitives;
|
||||
// Initialize the source list.
|
||||
// Apply the new thumbnail size and restart capture.
|
||||
if (capture_window) {
|
||||
@@ -134,8 +139,8 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
|
||||
capture_window_ = false;
|
||||
const auto& media_list_sources = list->GetSources();
|
||||
for (const auto& media_list_source : media_list_sources) {
|
||||
window_sources.emplace_back(
|
||||
DesktopCapturer::Source{media_list_source, std::string()});
|
||||
window_sources.emplace_back(DesktopCapturer::Source{
|
||||
media_list_source, std::string(), fetch_window_icons_});
|
||||
}
|
||||
std::move(window_sources.begin(), window_sources.end(),
|
||||
std::back_inserter(captured_sources_));
|
||||
@@ -187,7 +192,7 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
|
||||
}
|
||||
|
||||
if (!capture_window_ && !capture_screen_)
|
||||
Emit("finished", captured_sources_);
|
||||
Emit("finished", captured_sources_, fetch_window_icons_);
|
||||
}
|
||||
|
||||
// static
|
||||
@@ -221,4 +226,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_desktop_capturer, Initialize);
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_desktop_capturer, Initialize);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/api/event_emitter.h"
|
||||
#include "atom/browser/api/trackable_object.h"
|
||||
#include "chrome/browser/media/webrtc/desktop_media_list_observer.h"
|
||||
#include "chrome/browser/media/webrtc/native_desktop_media_list.h"
|
||||
#include "native_mate/handle.h"
|
||||
@@ -18,13 +18,16 @@ namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
class DesktopCapturer : public mate::EventEmitter<DesktopCapturer>,
|
||||
class DesktopCapturer : public mate::TrackableObject<DesktopCapturer>,
|
||||
public DesktopMediaListObserver {
|
||||
public:
|
||||
struct Source {
|
||||
DesktopMediaList::Source media_list_source;
|
||||
// Will be an empty string if not available.
|
||||
std::string display_id;
|
||||
|
||||
// Whether or not this source should provide an icon.
|
||||
bool fetch_icon = false;
|
||||
};
|
||||
|
||||
static mate::Handle<DesktopCapturer> Create(v8::Isolate* isolate);
|
||||
@@ -34,7 +37,8 @@ class DesktopCapturer : public mate::EventEmitter<DesktopCapturer>,
|
||||
|
||||
void StartHandling(bool capture_window,
|
||||
bool capture_screen,
|
||||
const gfx::Size& thumbnail_size);
|
||||
const gfx::Size& thumbnail_size,
|
||||
bool fetch_window_icons);
|
||||
|
||||
protected:
|
||||
explicit DesktopCapturer(v8::Isolate* isolate);
|
||||
@@ -59,6 +63,7 @@ class DesktopCapturer : public mate::EventEmitter<DesktopCapturer>,
|
||||
std::vector<DesktopCapturer::Source> captured_sources_;
|
||||
bool capture_window_ = false;
|
||||
bool capture_screen_ = false;
|
||||
bool fetch_window_icons_ = false;
|
||||
#if defined(OS_WIN)
|
||||
bool using_directx_capturer_ = false;
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#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"
|
||||
@@ -19,50 +20,6 @@
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
namespace mate {
|
||||
|
||||
template <>
|
||||
struct Converter<file_dialog::Filter> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
file_dialog::Filter* out) {
|
||||
mate::Dictionary dict;
|
||||
if (!ConvertFromV8(isolate, val, &dict))
|
||||
return false;
|
||||
if (!dict.Get("name", &(out->first)))
|
||||
return false;
|
||||
if (!dict.Get("extensions", &(out->second)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<file_dialog::DialogSettings> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
file_dialog::DialogSettings* out) {
|
||||
mate::Dictionary dict;
|
||||
if (!ConvertFromV8(isolate, val, &dict))
|
||||
return false;
|
||||
dict.Get("window", &(out->parent_window));
|
||||
dict.Get("title", &(out->title));
|
||||
dict.Get("message", &(out->message));
|
||||
dict.Get("buttonLabel", &(out->button_label));
|
||||
dict.Get("nameFieldLabel", &(out->name_field_label));
|
||||
dict.Get("defaultPath", &(out->default_path));
|
||||
dict.Get("filters", &(out->filters));
|
||||
dict.Get("properties", &(out->properties));
|
||||
dict.Get("showsTagField", &(out->shows_tag_field));
|
||||
#if defined(MAS_BUILD)
|
||||
dict.Get("securityScopedBookmarks", &(out->security_scoped_bookmarks));
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
namespace {
|
||||
|
||||
void ShowMessageBox(int type,
|
||||
@@ -139,4 +96,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_dialog, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_dialog, Initialize)
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "atom/browser/atom_browser_main_parts.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/gurl_converter.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
@@ -102,7 +103,7 @@ bool DownloadItem::IsPaused() const {
|
||||
}
|
||||
|
||||
void DownloadItem::Resume() {
|
||||
download_item_->Resume();
|
||||
download_item_->Resume(true /* user_gesture */);
|
||||
}
|
||||
|
||||
bool DownloadItem::CanResume() const {
|
||||
@@ -165,6 +166,15 @@ base::FilePath DownloadItem::GetSavePath() const {
|
||||
return save_path_;
|
||||
}
|
||||
|
||||
file_dialog::DialogSettings DownloadItem::GetSaveDialogOptions() const {
|
||||
return dialog_options_;
|
||||
}
|
||||
|
||||
void DownloadItem::SetSaveDialogOptions(
|
||||
const file_dialog::DialogSettings& options) {
|
||||
dialog_options_ = options;
|
||||
}
|
||||
|
||||
std::string DownloadItem::GetLastModifiedTime() const {
|
||||
return download_item_->GetLastModifiedTime();
|
||||
}
|
||||
@@ -200,6 +210,8 @@ void DownloadItem::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("isDone", &DownloadItem::IsDone)
|
||||
.SetMethod("setSavePath", &DownloadItem::SetSavePath)
|
||||
.SetMethod("getSavePath", &DownloadItem::GetSavePath)
|
||||
.SetMethod("setSaveDialogOptions", &DownloadItem::SetSaveDialogOptions)
|
||||
.SetMethod("getSaveDialogOptions", &DownloadItem::GetSaveDialogOptions)
|
||||
.SetMethod("getLastModifiedTime", &DownloadItem::GetLastModifiedTime)
|
||||
.SetMethod("getETag", &DownloadItem::GetETag)
|
||||
.SetMethod("getStartTime", &DownloadItem::GetStartTime);
|
||||
@@ -232,10 +244,11 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary(isolate, exports)
|
||||
.Set("DownloadItem",
|
||||
atom::api::DownloadItem::GetConstructor(isolate)->GetFunction());
|
||||
.Set("DownloadItem", atom::api::DownloadItem::GetConstructor(isolate)
|
||||
->GetFunction(context)
|
||||
.ToLocalChecked());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_download_item, Initialize);
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_download_item, Initialize);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/api/trackable_object.h"
|
||||
#include "atom/browser/ui/file_dialog.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "components/download/public/common/download_item.h"
|
||||
#include "native_mate/handle.h"
|
||||
@@ -44,6 +45,8 @@ class DownloadItem : public mate::TrackableObject<DownloadItem>,
|
||||
bool IsDone() const;
|
||||
void SetSavePath(const base::FilePath& path);
|
||||
base::FilePath GetSavePath() const;
|
||||
file_dialog::DialogSettings GetSaveDialogOptions() const;
|
||||
void SetSaveDialogOptions(const file_dialog::DialogSettings& options);
|
||||
std::string GetLastModifiedTime() const;
|
||||
std::string GetETag() const;
|
||||
double GetStartTime() const;
|
||||
@@ -58,6 +61,7 @@ class DownloadItem : public mate::TrackableObject<DownloadItem>,
|
||||
|
||||
private:
|
||||
base::FilePath save_path_;
|
||||
file_dialog::DialogSettings dialog_options_;
|
||||
download::DownloadItem* download_item_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(DownloadItem);
|
||||
|
||||
@@ -23,4 +23,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_event, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_event, Initialize)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "atom/browser/api/atom_api_global_shortcut.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/api/atom_api_system_preferences.h"
|
||||
#include "atom/common/native_mate_converters/accelerator_converter.h"
|
||||
@@ -67,6 +68,29 @@ void GlobalShortcut::OnKeyPressed(const ui::Accelerator& accelerator) {
|
||||
accelerator_callback_map_[accelerator].Run();
|
||||
}
|
||||
|
||||
bool GlobalShortcut::RegisterAll(
|
||||
const std::vector<ui::Accelerator>& accelerators,
|
||||
const base::Closure& callback) {
|
||||
std::vector<ui::Accelerator> registered;
|
||||
|
||||
for (auto& accelerator : accelerators) {
|
||||
#if defined(OS_MACOSX)
|
||||
if (RegisteringMediaKeyForUntrustedClient(accelerator))
|
||||
return false;
|
||||
|
||||
GlobalShortcutListener* listener = GlobalShortcutListener::GetInstance();
|
||||
if (!listener->RegisterAccelerator(accelerator, this)) {
|
||||
// unregister all shortcuts if any failed
|
||||
UnregisterSome(registered);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
registered.push_back(accelerator);
|
||||
accelerator_callback_map_[accelerator] = callback;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GlobalShortcut::Register(const ui::Accelerator& accelerator,
|
||||
const base::Closure& callback) {
|
||||
#if defined(OS_MACOSX)
|
||||
@@ -92,6 +116,13 @@ void GlobalShortcut::Unregister(const ui::Accelerator& accelerator) {
|
||||
this);
|
||||
}
|
||||
|
||||
void GlobalShortcut::UnregisterSome(
|
||||
const std::vector<ui::Accelerator>& accelerators) {
|
||||
for (auto& accelerator : accelerators) {
|
||||
Unregister(accelerator);
|
||||
}
|
||||
}
|
||||
|
||||
bool GlobalShortcut::IsRegistered(const ui::Accelerator& accelerator) {
|
||||
return ContainsKey(accelerator_callback_map_, accelerator);
|
||||
}
|
||||
@@ -111,6 +142,7 @@ void GlobalShortcut::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "GlobalShortcut"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("registerAll", &GlobalShortcut::RegisterAll)
|
||||
.SetMethod("register", &GlobalShortcut::Register)
|
||||
.SetMethod("isRegistered", &GlobalShortcut::IsRegistered)
|
||||
.SetMethod("unregister", &GlobalShortcut::Unregister)
|
||||
@@ -134,4 +166,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_global_shortcut, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_global_shortcut, Initialize)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/api/trackable_object.h"
|
||||
#include "base/callback.h"
|
||||
@@ -33,10 +34,13 @@ class GlobalShortcut : public extensions::GlobalShortcutListener::Observer,
|
||||
private:
|
||||
typedef std::map<ui::Accelerator, base::Closure> AcceleratorCallbackMap;
|
||||
|
||||
bool RegisterAll(const std::vector<ui::Accelerator>& accelerators,
|
||||
const base::Closure& callback);
|
||||
bool Register(const ui::Accelerator& accelerator,
|
||||
const base::Closure& callback);
|
||||
bool IsRegistered(const ui::Accelerator& accelerator);
|
||||
void Unregister(const ui::Accelerator& accelerator);
|
||||
void UnregisterSome(const std::vector<ui::Accelerator>& accelerators);
|
||||
void UnregisterAll();
|
||||
|
||||
// GlobalShortcutListener::Observer implementation.
|
||||
|
||||
@@ -132,11 +132,12 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.Set("inAppPurchase", InAppPurchase::Create(isolate));
|
||||
dict.Set("InAppPurchase",
|
||||
InAppPurchase::GetConstructor(isolate)->GetFunction());
|
||||
dict.Set("InAppPurchase", InAppPurchase::GetConstructor(isolate)
|
||||
->GetFunction(context)
|
||||
.ToLocalChecked());
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_in_app_purchase, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_in_app_purchase, Initialize)
|
||||
|
||||
@@ -90,7 +90,7 @@ void Menu::ExecuteCommand(int command_id, int flags) {
|
||||
command_id);
|
||||
}
|
||||
|
||||
void Menu::MenuWillShow(ui::SimpleMenuModel* source) {
|
||||
void Menu::OnMenuWillShow(ui::SimpleMenuModel* source) {
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
menu_will_show_.Run(GetWrapper());
|
||||
@@ -233,7 +233,9 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
Menu::SetConstructor(isolate, base::Bind(&Menu::New));
|
||||
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.Set("Menu", Menu::GetConstructor(isolate)->GetFunction());
|
||||
dict.Set(
|
||||
"Menu",
|
||||
Menu::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
|
||||
#if defined(OS_MACOSX)
|
||||
dict.SetMethod("setApplicationMenu", &Menu::SetApplicationMenu);
|
||||
dict.SetMethod("sendActionToFirstResponder",
|
||||
@@ -243,4 +245,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_menu, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_menu, Initialize)
|
||||
|
||||
@@ -53,7 +53,7 @@ class Menu : public mate::TrackableObject<Menu>,
|
||||
ui::Accelerator* accelerator) const override;
|
||||
bool ShouldRegisterAcceleratorForCommandId(int command_id) const override;
|
||||
void ExecuteCommand(int command_id, int event_flags) override;
|
||||
void MenuWillShow(ui::SimpleMenuModel* source) override;
|
||||
void OnMenuWillShow(ui::SimpleMenuModel* source) override;
|
||||
|
||||
virtual void PopupAt(TopLevelWindow* window,
|
||||
int x,
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "base/mac/scoped_sending_event.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 "content/public/browser/web_contents.h"
|
||||
|
||||
@@ -43,7 +45,7 @@ void MenuMac::PopupAt(TopLevelWindow* window,
|
||||
auto popup = base::Bind(&MenuMac::PopupOnUI, weak_factory_.GetWeakPtr(),
|
||||
native_window->GetWeakPtr(), window->weak_map_id(), x,
|
||||
y, positioning_item, callback);
|
||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, popup);
|
||||
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, popup);
|
||||
}
|
||||
|
||||
void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
||||
@@ -54,7 +56,7 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
||||
base::Closure callback) {
|
||||
if (!native_window)
|
||||
return;
|
||||
NSWindow* nswindow = native_window->GetNativeWindow();
|
||||
NSWindow* nswindow = native_window->GetNativeWindow().GetNativeNSWindow();
|
||||
|
||||
auto close_callback = base::Bind(
|
||||
&MenuMac::OnClosed, weak_factory_.GetWeakPtr(), window_id, callback);
|
||||
@@ -97,7 +99,7 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
||||
|
||||
[popup_controllers_[window_id] setCloseCallback:close_callback];
|
||||
// Make sure events can be pumped while the menu is up.
|
||||
base::MessageLoop::ScopedNestableTaskAllower allow;
|
||||
base::MessageLoopCurrent::ScopedNestableTaskAllower allow;
|
||||
|
||||
// One of the events that could be pumped is |window.close()|.
|
||||
// User-initiated event-tracking loops protect against this by
|
||||
|
||||
@@ -31,7 +31,9 @@ void Net::BuildPrototype(v8::Isolate* isolate,
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> Net::URLRequest(v8::Isolate* isolate) {
|
||||
return URLRequest::GetConstructor(isolate)->GetFunction();
|
||||
return URLRequest::GetConstructor(isolate)
|
||||
->GetFunction(isolate->GetCurrentContext())
|
||||
.ToLocalChecked();
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
@@ -53,9 +55,10 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.Set("net", Net::Create(isolate));
|
||||
dict.Set("Net", Net::GetConstructor(isolate)->GetFunction());
|
||||
dict.Set("Net",
|
||||
Net::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_net, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_net, Initialize)
|
||||
|
||||
@@ -7,10 +7,11 @@
|
||||
#include <utility>
|
||||
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/atom_browser_main_parts.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 "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"
|
||||
@@ -27,8 +28,8 @@ NetLog::NetLog(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
||||
: browser_context_(browser_context) {
|
||||
Init(isolate);
|
||||
|
||||
net_log_writer_ =
|
||||
atom::AtomBrowserMainParts::Get()->net_log()->net_export_file_writer();
|
||||
net_log_writer_ = g_browser_process->system_network_context_manager()
|
||||
->GetNetExportFileWriter();
|
||||
net_log_writer_->AddObserver(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
#include "atom/browser/api/atom_api_notification.h"
|
||||
|
||||
#include "atom/browser/api/atom_api_menu.h"
|
||||
#include "atom/browser/atom_browser_client.h"
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||
#include "atom/common/native_mate_converters/image_converter.h"
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
#include "base/guid.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "brightray/browser/browser_client.h"
|
||||
#include "native_mate/constructor.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
@@ -22,10 +22,10 @@
|
||||
|
||||
namespace mate {
|
||||
template <>
|
||||
struct Converter<brightray::NotificationAction> {
|
||||
struct Converter<atom::NotificationAction> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
brightray::NotificationAction* out) {
|
||||
atom::NotificationAction* out) {
|
||||
mate::Dictionary dict;
|
||||
if (!ConvertFromV8(isolate, val, &dict))
|
||||
return false;
|
||||
@@ -38,7 +38,7 @@ struct Converter<brightray::NotificationAction> {
|
||||
}
|
||||
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
brightray::NotificationAction val) {
|
||||
atom::NotificationAction val) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("text", val.text);
|
||||
dict.Set("type", val.type);
|
||||
@@ -56,7 +56,8 @@ Notification::Notification(v8::Isolate* isolate,
|
||||
mate::Arguments* args) {
|
||||
InitWith(isolate, wrapper);
|
||||
|
||||
presenter_ = brightray::BrowserClient::Get()->GetNotificationPresenter();
|
||||
presenter_ = static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())
|
||||
->GetNotificationPresenter();
|
||||
|
||||
mate::Dictionary opts;
|
||||
if (args->GetNext(&opts)) {
|
||||
@@ -119,7 +120,7 @@ base::string16 Notification::GetSound() const {
|
||||
return sound_;
|
||||
}
|
||||
|
||||
std::vector<brightray::NotificationAction> Notification::GetActions() const {
|
||||
std::vector<atom::NotificationAction> Notification::GetActions() const {
|
||||
return actions_;
|
||||
}
|
||||
|
||||
@@ -157,7 +158,7 @@ void Notification::SetSound(const base::string16& new_sound) {
|
||||
}
|
||||
|
||||
void Notification::SetActions(
|
||||
const std::vector<brightray::NotificationAction>& actions) {
|
||||
const std::vector<atom::NotificationAction>& actions) {
|
||||
actions_ = actions;
|
||||
}
|
||||
|
||||
@@ -200,7 +201,7 @@ void Notification::Show() {
|
||||
if (presenter_) {
|
||||
notification_ = presenter_->CreateNotification(this, base::GenerateGUID());
|
||||
if (notification_) {
|
||||
brightray::NotificationOptions options;
|
||||
atom::NotificationOptions options;
|
||||
options.title = title_;
|
||||
options.subtitle = subtitle_;
|
||||
options.msg = body_;
|
||||
@@ -218,7 +219,8 @@ void Notification::Show() {
|
||||
}
|
||||
|
||||
bool Notification::IsSupported() {
|
||||
return !!brightray::BrowserClient::Get()->GetNotificationPresenter();
|
||||
return !!static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())
|
||||
->GetNotificationPresenter();
|
||||
}
|
||||
|
||||
// static
|
||||
@@ -261,12 +263,13 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
Notification::SetConstructor(isolate, base::Bind(&Notification::New));
|
||||
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.Set("Notification",
|
||||
Notification::GetConstructor(isolate)->GetFunction());
|
||||
dict.Set("Notification", Notification::GetConstructor(isolate)
|
||||
->GetFunction(context)
|
||||
.ToLocalChecked());
|
||||
|
||||
dict.SetMethod("isSupported", &Notification::IsSupported);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_notification, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_common_notification, Initialize)
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/api/trackable_object.h"
|
||||
#include "atom/browser/notifications/notification.h"
|
||||
#include "atom/browser/notifications/notification_delegate.h"
|
||||
#include "atom/browser/notifications/notification_presenter.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "brightray/browser/notification.h"
|
||||
#include "brightray/browser/notification_delegate.h"
|
||||
#include "brightray/browser/notification_presenter.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace atom {
|
||||
namespace api {
|
||||
|
||||
class Notification : public mate::TrackableObject<Notification>,
|
||||
public brightray::NotificationDelegate {
|
||||
public NotificationDelegate {
|
||||
public:
|
||||
static mate::WrappableBase* New(mate::Arguments* args);
|
||||
static bool IsSupported();
|
||||
@@ -55,7 +55,7 @@ class Notification : public mate::TrackableObject<Notification>,
|
||||
bool GetHasReply() const;
|
||||
base::string16 GetReplyPlaceholder() const;
|
||||
base::string16 GetSound() const;
|
||||
std::vector<brightray::NotificationAction> GetActions() const;
|
||||
std::vector<atom::NotificationAction> GetActions() const;
|
||||
base::string16 GetCloseButtonText() const;
|
||||
|
||||
// Prop Setters
|
||||
@@ -66,7 +66,7 @@ class Notification : public mate::TrackableObject<Notification>,
|
||||
void SetHasReply(bool new_has_reply);
|
||||
void SetReplyPlaceholder(const base::string16& new_reply_placeholder);
|
||||
void SetSound(const base::string16& sound);
|
||||
void SetActions(const std::vector<brightray::NotificationAction>& actions);
|
||||
void SetActions(const std::vector<atom::NotificationAction>& actions);
|
||||
void SetCloseButtonText(const base::string16& text);
|
||||
|
||||
private:
|
||||
@@ -80,12 +80,12 @@ class Notification : public mate::TrackableObject<Notification>,
|
||||
bool has_reply_ = false;
|
||||
base::string16 reply_placeholder_;
|
||||
base::string16 sound_;
|
||||
std::vector<brightray::NotificationAction> actions_;
|
||||
std::vector<atom::NotificationAction> actions_;
|
||||
base::string16 close_button_text_;
|
||||
|
||||
brightray::NotificationPresenter* presenter_;
|
||||
atom::NotificationPresenter* presenter_;
|
||||
|
||||
base::WeakPtr<brightray::Notification> notification_;
|
||||
base::WeakPtr<atom::Notification> notification_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Notification);
|
||||
};
|
||||
|
||||
@@ -84,19 +84,19 @@ void PowerMonitor::OnResume() {
|
||||
Emit("resume");
|
||||
}
|
||||
|
||||
void PowerMonitor::QuerySystemIdleState(v8::Isolate* isolate,
|
||||
int idle_threshold,
|
||||
const ui::IdleCallback& callback) {
|
||||
ui::IdleState PowerMonitor::QuerySystemIdleState(v8::Isolate* isolate,
|
||||
int idle_threshold) {
|
||||
if (idle_threshold > 0) {
|
||||
ui::CalculateIdleState(idle_threshold, callback);
|
||||
return ui::CalculateIdleState(idle_threshold);
|
||||
} else {
|
||||
isolate->ThrowException(v8::Exception::TypeError(mate::StringToV8(
|
||||
isolate, "Invalid idle threshold, must be greater than 0")));
|
||||
return ui::IDLE_STATE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
void PowerMonitor::QuerySystemIdleTime(const ui::IdleTimeCallback& callback) {
|
||||
ui::CalculateIdleTime(callback);
|
||||
int PowerMonitor::QuerySystemIdleTime() {
|
||||
return ui::CalculateIdleTime();
|
||||
}
|
||||
|
||||
// static
|
||||
@@ -122,8 +122,8 @@ void PowerMonitor::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("blockShutdown", &PowerMonitor::BlockShutdown)
|
||||
.SetMethod("unblockShutdown", &PowerMonitor::UnblockShutdown)
|
||||
#endif
|
||||
.SetMethod("querySystemIdleState", &PowerMonitor::QuerySystemIdleState)
|
||||
.SetMethod("querySystemIdleTime", &PowerMonitor::QuerySystemIdleTime);
|
||||
.SetMethod("_querySystemIdleState", &PowerMonitor::QuerySystemIdleState)
|
||||
.SetMethod("_querySystemIdleTime", &PowerMonitor::QuerySystemIdleTime);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
@@ -141,10 +141,11 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.Set("powerMonitor", PowerMonitor::Create(isolate));
|
||||
dict.Set("PowerMonitor",
|
||||
PowerMonitor::GetConstructor(isolate)->GetFunction());
|
||||
dict.Set("PowerMonitor", PowerMonitor::GetConstructor(isolate)
|
||||
->GetFunction(context)
|
||||
.ToLocalChecked());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_power_monitor, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_power_monitor, Initialize)
|
||||
|
||||
@@ -46,10 +46,8 @@ class PowerMonitor : public mate::TrackableObject<PowerMonitor>,
|
||||
void OnResume() override;
|
||||
|
||||
private:
|
||||
void QuerySystemIdleState(v8::Isolate* isolate,
|
||||
int idle_threshold,
|
||||
const ui::IdleCallback& callback);
|
||||
void QuerySystemIdleTime(const ui::IdleTimeCallback& callback);
|
||||
ui::IdleState QuerySystemIdleState(v8::Isolate* isolate, int idle_threshold);
|
||||
int QuerySystemIdleTime();
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Static callback invoked when a message comes in to our messaging window.
|
||||
|
||||
@@ -6,9 +6,13 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/task_scheduler/post_task.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "content/public/common/service_manager_connection.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "services/device/public/mojom/constants.mojom.h"
|
||||
#include "services/device/public/mojom/wake_lock_provider.mojom.h"
|
||||
#include "services/service_manager/public/cpp/connector.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
@@ -39,16 +43,19 @@ namespace atom {
|
||||
namespace api {
|
||||
|
||||
PowerSaveBlocker::PowerSaveBlocker(v8::Isolate* isolate)
|
||||
: current_blocker_type_(
|
||||
device::mojom::WakeLockType::kPreventAppSuspension) {
|
||||
: current_lock_type_(device::mojom::WakeLockType::kPreventAppSuspension),
|
||||
is_wake_lock_active_(false) {
|
||||
Init(isolate);
|
||||
}
|
||||
|
||||
PowerSaveBlocker::~PowerSaveBlocker() {}
|
||||
|
||||
void PowerSaveBlocker::UpdatePowerSaveBlocker() {
|
||||
if (power_save_blocker_types_.empty()) {
|
||||
power_save_blocker_.reset();
|
||||
if (wake_lock_types_.empty()) {
|
||||
if (is_wake_lock_active_) {
|
||||
GetWakeLock()->CancelWakeLock();
|
||||
is_wake_lock_active_ = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -58,45 +65,57 @@ void PowerSaveBlocker::UpdatePowerSaveBlocker() {
|
||||
// higher precedence level than |WakeLockType::kPreventAppSuspension|.
|
||||
//
|
||||
// Only the highest-precedence blocker type takes effect.
|
||||
device::mojom::WakeLockType new_blocker_type =
|
||||
device::mojom::WakeLockType new_lock_type =
|
||||
device::mojom::WakeLockType::kPreventAppSuspension;
|
||||
for (const auto& element : power_save_blocker_types_) {
|
||||
for (const auto& element : wake_lock_types_) {
|
||||
if (element.second == device::mojom::WakeLockType::kPreventDisplaySleep) {
|
||||
new_blocker_type = device::mojom::WakeLockType::kPreventDisplaySleep;
|
||||
new_lock_type = device::mojom::WakeLockType::kPreventDisplaySleep;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!power_save_blocker_ || new_blocker_type != current_blocker_type_) {
|
||||
auto new_blocker = std::make_unique<device::PowerSaveBlocker>(
|
||||
new_blocker_type, device::mojom::WakeLockReason::kOther,
|
||||
ATOM_PRODUCT_NAME, base::ThreadTaskRunnerHandle::Get(),
|
||||
// This task runner may be used by some device service
|
||||
// implementation bits to interface with dbus client code, which in
|
||||
// turn imposes some subtle thread affinity on the clients. We
|
||||
// therefore require a single-thread runner.
|
||||
base::CreateSingleThreadTaskRunnerWithTraits(
|
||||
{base::MayBlock(), base::TaskPriority::BACKGROUND}));
|
||||
power_save_blocker_.swap(new_blocker);
|
||||
current_blocker_type_ = new_blocker_type;
|
||||
if (current_lock_type_ != new_lock_type) {
|
||||
GetWakeLock()->ChangeType(new_lock_type, base::DoNothing());
|
||||
current_lock_type_ = new_lock_type;
|
||||
}
|
||||
if (!is_wake_lock_active_) {
|
||||
GetWakeLock()->RequestWakeLock();
|
||||
is_wake_lock_active_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
device::mojom::WakeLock* PowerSaveBlocker::GetWakeLock() {
|
||||
if (!wake_lock_) {
|
||||
device::mojom::WakeLockProviderPtr wake_lock_provider;
|
||||
DCHECK(content::ServiceManagerConnection::GetForProcess());
|
||||
auto* connector =
|
||||
content::ServiceManagerConnection::GetForProcess()->GetConnector();
|
||||
connector->BindInterface(device::mojom::kServiceName,
|
||||
mojo::MakeRequest(&wake_lock_provider));
|
||||
|
||||
wake_lock_provider->GetWakeLockWithoutContext(
|
||||
device::mojom::WakeLockType::kPreventAppSuspension,
|
||||
device::mojom::WakeLockReason::kOther, ATOM_PRODUCT_NAME,
|
||||
mojo::MakeRequest(&wake_lock_));
|
||||
}
|
||||
return wake_lock_.get();
|
||||
}
|
||||
|
||||
int PowerSaveBlocker::Start(device::mojom::WakeLockType type) {
|
||||
static int count = 0;
|
||||
power_save_blocker_types_[count] = type;
|
||||
wake_lock_types_[count] = type;
|
||||
UpdatePowerSaveBlocker();
|
||||
return count++;
|
||||
}
|
||||
|
||||
bool PowerSaveBlocker::Stop(int id) {
|
||||
bool success = power_save_blocker_types_.erase(id) > 0;
|
||||
bool success = wake_lock_types_.erase(id) > 0;
|
||||
UpdatePowerSaveBlocker();
|
||||
return success;
|
||||
}
|
||||
|
||||
bool PowerSaveBlocker::IsStarted(int id) {
|
||||
return power_save_blocker_types_.find(id) != power_save_blocker_types_.end();
|
||||
return wake_lock_types_.find(id) != wake_lock_types_.end();
|
||||
}
|
||||
|
||||
// static
|
||||
@@ -132,4 +151,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_power_save_blocker, Initialize);
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_power_save_blocker, Initialize);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "atom/browser/api/trackable_object.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "services/device/wake_lock/power_save_blocker/power_save_blocker.h"
|
||||
#include "services/device/public/mojom/wake_lock.mojom.h"
|
||||
|
||||
namespace mate {
|
||||
class Dictionary;
|
||||
@@ -37,14 +37,19 @@ class PowerSaveBlocker : public mate::TrackableObject<PowerSaveBlocker> {
|
||||
bool Stop(int id);
|
||||
bool IsStarted(int id);
|
||||
|
||||
std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_;
|
||||
device::mojom::WakeLock* GetWakeLock();
|
||||
|
||||
// Current blocker type used by |power_save_blocker_|
|
||||
device::mojom::WakeLockType current_blocker_type_;
|
||||
// Current wake lock level.
|
||||
device::mojom::WakeLockType current_lock_type_;
|
||||
|
||||
// Whether the wake lock is currently active.
|
||||
bool is_wake_lock_active_;
|
||||
|
||||
// Map from id to the corresponding blocker type for each request.
|
||||
using WakeLockTypeMap = std::map<int, device::mojom::WakeLockType>;
|
||||
WakeLockTypeMap power_save_blocker_types_;
|
||||
WakeLockTypeMap wake_lock_types_;
|
||||
|
||||
device::mojom::WakeLockPtr wake_lock_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(PowerSaveBlocker);
|
||||
};
|
||||
|
||||
@@ -24,47 +24,119 @@
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
namespace {
|
||||
|
||||
// List of registered custom standard schemes.
|
||||
std::vector<std::string> g_standard_schemes;
|
||||
|
||||
struct SchemeOptions {
|
||||
bool standard = false;
|
||||
bool secure = false;
|
||||
bool bypassCSP = false;
|
||||
bool allowServiceWorkers = false;
|
||||
bool supportFetchAPI = false;
|
||||
bool corsEnabled = false;
|
||||
};
|
||||
|
||||
struct CustomScheme {
|
||||
std::string scheme;
|
||||
SchemeOptions options;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace mate {
|
||||
|
||||
template <>
|
||||
struct Converter<CustomScheme> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
CustomScheme* out) {
|
||||
mate::Dictionary dict;
|
||||
if (!ConvertFromV8(isolate, val, &dict))
|
||||
return false;
|
||||
if (!dict.Get("scheme", &(out->scheme)))
|
||||
return false;
|
||||
mate::Dictionary opt;
|
||||
// options are optional. Default values specified in SchemeOptions are used
|
||||
if (dict.Get("privileges", &opt)) {
|
||||
opt.Get("standard", &(out->options.standard));
|
||||
opt.Get("supportFetchAPI", &(out->options.supportFetchAPI));
|
||||
opt.Get("secure", &(out->options.secure));
|
||||
opt.Get("bypassCSP", &(out->options.bypassCSP));
|
||||
opt.Get("allowServiceWorkers", &(out->options.allowServiceWorkers));
|
||||
opt.Get("supportFetchAPI", &(out->options.supportFetchAPI));
|
||||
opt.Get("corsEnabled", &(out->options.corsEnabled));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
std::vector<std::string> GetStandardSchemes() {
|
||||
return g_standard_schemes;
|
||||
}
|
||||
|
||||
void RegisterStandardSchemes(const std::vector<std::string>& schemes,
|
||||
mate::Arguments* args) {
|
||||
g_standard_schemes = schemes;
|
||||
void RegisterSchemesAsPrivileged(v8::Local<v8::Value> val,
|
||||
mate::Arguments* args) {
|
||||
std::vector<CustomScheme> custom_schemes;
|
||||
if (!mate::ConvertFromV8(args->isolate(), val, &custom_schemes)) {
|
||||
args->ThrowError("Argument must be an array of custom schemes.");
|
||||
return;
|
||||
}
|
||||
|
||||
mate::Dictionary opts;
|
||||
bool secure = false;
|
||||
args->GetNext(&opts) && opts.Get("secure", &secure);
|
||||
|
||||
// Dynamically register the schemes.
|
||||
auto* policy = content::ChildProcessSecurityPolicy::GetInstance();
|
||||
for (const std::string& scheme : schemes) {
|
||||
url::AddStandardScheme(scheme.c_str(), url::SCHEME_WITH_HOST);
|
||||
if (secure) {
|
||||
url::AddSecureScheme(scheme.c_str());
|
||||
std::vector<std::string> secure_schemes, cspbypassing_schemes, fetch_schemes,
|
||||
service_worker_schemes, cors_schemes;
|
||||
for (const auto& custom_scheme : custom_schemes) {
|
||||
// Register scheme to privileged list (https, wss, data, chrome-extension)
|
||||
if (custom_scheme.options.standard) {
|
||||
auto* policy = content::ChildProcessSecurityPolicy::GetInstance();
|
||||
url::AddStandardScheme(custom_scheme.scheme.c_str(),
|
||||
url::SCHEME_WITH_HOST);
|
||||
g_standard_schemes.push_back(custom_scheme.scheme);
|
||||
policy->RegisterWebSafeScheme(custom_scheme.scheme);
|
||||
}
|
||||
if (custom_scheme.options.secure) {
|
||||
secure_schemes.push_back(custom_scheme.scheme);
|
||||
url::AddSecureScheme(custom_scheme.scheme.c_str());
|
||||
}
|
||||
if (custom_scheme.options.bypassCSP) {
|
||||
cspbypassing_schemes.push_back(custom_scheme.scheme);
|
||||
url::AddCSPBypassingScheme(custom_scheme.scheme.c_str());
|
||||
}
|
||||
if (custom_scheme.options.corsEnabled) {
|
||||
cors_schemes.push_back(custom_scheme.scheme);
|
||||
url::AddCorsEnabledScheme(custom_scheme.scheme.c_str());
|
||||
}
|
||||
if (custom_scheme.options.supportFetchAPI) {
|
||||
fetch_schemes.push_back(custom_scheme.scheme);
|
||||
}
|
||||
if (custom_scheme.options.allowServiceWorkers) {
|
||||
service_worker_schemes.push_back(custom_scheme.scheme);
|
||||
}
|
||||
policy->RegisterWebSafeScheme(scheme);
|
||||
}
|
||||
|
||||
// Add the schemes to command line switches, so child processes can also
|
||||
// register them.
|
||||
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
||||
atom::switches::kStandardSchemes, base::JoinString(schemes, ","));
|
||||
if (secure) {
|
||||
const auto AppendSchemesToCmdLine = [](const char* switch_name,
|
||||
std::vector<std::string> schemes) {
|
||||
// Add the schemes to command line switches, so child processes can also
|
||||
// register them.
|
||||
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
||||
atom::switches::kSecureSchemes, base::JoinString(schemes, ","));
|
||||
}
|
||||
switch_name, base::JoinString(schemes, ","));
|
||||
};
|
||||
|
||||
AppendSchemesToCmdLine(atom::switches::kSecureSchemes, secure_schemes);
|
||||
AppendSchemesToCmdLine(atom::switches::kBypassCSPSchemes,
|
||||
cspbypassing_schemes);
|
||||
AppendSchemesToCmdLine(atom::switches::kCORSSchemes, cors_schemes);
|
||||
AppendSchemesToCmdLine(atom::switches::kFetchSchemes, fetch_schemes);
|
||||
AppendSchemesToCmdLine(atom::switches::kServiceWorkerSchemes,
|
||||
service_worker_schemes);
|
||||
AppendSchemesToCmdLine(atom::switches::kStandardSchemes, g_standard_schemes);
|
||||
}
|
||||
|
||||
Protocol::Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
||||
@@ -73,20 +145,14 @@ Protocol::Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
||||
}
|
||||
|
||||
Protocol::~Protocol() {}
|
||||
|
||||
void Protocol::RegisterServiceWorkerSchemes(
|
||||
const std::vector<std::string>& schemes) {
|
||||
atom::AtomBrowserClient::SetCustomServiceWorkerSchemes(schemes);
|
||||
}
|
||||
|
||||
void Protocol::UnregisterProtocol(const std::string& scheme,
|
||||
mate::Arguments* args) {
|
||||
CompletionCallback callback;
|
||||
args->GetNext(&callback);
|
||||
auto* getter = static_cast<URLRequestContextGetter*>(
|
||||
browser_context_->GetRequestContext());
|
||||
content::BrowserThread::PostTaskAndReplyWithResult(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraitsAndReplyWithResult(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&Protocol::UnregisterProtocolInIO,
|
||||
base::RetainedRef(getter), scheme),
|
||||
base::BindOnce(&Protocol::OnIOCompleted, GetWeakPtr(), callback));
|
||||
@@ -103,22 +169,30 @@ Protocol::ProtocolError Protocol::UnregisterProtocolInIO(
|
||||
return PROTOCOL_OK;
|
||||
}
|
||||
|
||||
void Protocol::IsProtocolHandled(const std::string& scheme,
|
||||
const BooleanCallback& callback) {
|
||||
auto* getter = static_cast<URLRequestContextGetter*>(
|
||||
browser_context_->GetRequestContext());
|
||||
content::BrowserThread::PostTaskAndReplyWithResult(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(&Protocol::IsProtocolHandledInIO, base::RetainedRef(getter),
|
||||
scheme),
|
||||
callback);
|
||||
}
|
||||
|
||||
// static
|
||||
bool Protocol::IsProtocolHandledInIO(
|
||||
bool IsProtocolHandledInIO(
|
||||
scoped_refptr<URLRequestContextGetter> request_context_getter,
|
||||
const std::string& scheme) {
|
||||
return request_context_getter->job_factory()->IsHandledProtocol(scheme);
|
||||
bool is_handled =
|
||||
request_context_getter->job_factory()->IsHandledProtocol(scheme);
|
||||
return is_handled;
|
||||
}
|
||||
|
||||
void PromiseCallback(util::Promise promise, bool handled) {
|
||||
promise.Resolve(handled);
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> Protocol::IsProtocolHandled(const std::string& scheme) {
|
||||
util::Promise promise(isolate());
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
auto* getter = static_cast<URLRequestContextGetter*>(
|
||||
browser_context_->GetRequestContext());
|
||||
|
||||
base::PostTaskWithTraitsAndReplyWithResult(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&IsProtocolHandledInIO, base::RetainedRef(getter), scheme),
|
||||
base::BindOnce(&PromiseCallback, std::move(promise)));
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void Protocol::UninterceptProtocol(const std::string& scheme,
|
||||
@@ -127,8 +201,8 @@ void Protocol::UninterceptProtocol(const std::string& scheme,
|
||||
args->GetNext(&callback);
|
||||
auto* getter = static_cast<URLRequestContextGetter*>(
|
||||
browser_context_->GetRequestContext());
|
||||
content::BrowserThread::PostTaskAndReplyWithResult(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraitsAndReplyWithResult(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&Protocol::UninterceptProtocolInIO,
|
||||
base::RetainedRef(getter), scheme),
|
||||
base::BindOnce(&Protocol::OnIOCompleted, GetWeakPtr(), callback));
|
||||
@@ -188,8 +262,6 @@ void Protocol::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "Protocol"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("registerServiceWorkerSchemes",
|
||||
&Protocol::RegisterServiceWorkerSchemes)
|
||||
.SetMethod("registerStringProtocol",
|
||||
&Protocol::RegisterProtocol<URLRequestStringJob>)
|
||||
.SetMethod("registerBufferProtocol",
|
||||
@@ -221,16 +293,16 @@ void Protocol::BuildPrototype(v8::Isolate* isolate,
|
||||
|
||||
namespace {
|
||||
|
||||
void RegisterStandardSchemes(const std::vector<std::string>& schemes,
|
||||
mate::Arguments* args) {
|
||||
void RegisterSchemesAsPrivileged(v8::Local<v8::Value> val,
|
||||
mate::Arguments* args) {
|
||||
if (atom::Browser::Get()->is_ready()) {
|
||||
args->ThrowError(
|
||||
"protocol.registerStandardSchemes should be called before "
|
||||
"protocol.registerSchemesAsPrivileged should be called before "
|
||||
"app is ready");
|
||||
return;
|
||||
}
|
||||
|
||||
atom::api::RegisterStandardSchemes(schemes, args);
|
||||
atom::api::RegisterSchemesAsPrivileged(val, args);
|
||||
}
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
@@ -239,10 +311,10 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.SetMethod("registerStandardSchemes", &RegisterStandardSchemes);
|
||||
dict.SetMethod("registerSchemesAsPrivileged", &RegisterSchemesAsPrivileged);
|
||||
dict.SetMethod("getStandardSchemes", &atom::api::GetStandardSchemes);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_protocol, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_protocol, Initialize)
|
||||
|
||||
@@ -14,8 +14,11 @@
|
||||
#include "atom/browser/api/trackable_object.h"
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/net/atom_url_request_job_factory.h"
|
||||
#include "atom/common/promise_util.h"
|
||||
#include "base/callback.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "native_mate/arguments.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
@@ -31,15 +34,15 @@ namespace atom {
|
||||
namespace api {
|
||||
|
||||
std::vector<std::string> GetStandardSchemes();
|
||||
void RegisterStandardSchemes(const std::vector<std::string>& schemes,
|
||||
mate::Arguments* args);
|
||||
|
||||
void RegisterSchemesAsPrivileged(v8::Local<v8::Value> val,
|
||||
mate::Arguments* args);
|
||||
|
||||
class Protocol : public mate::TrackableObject<Protocol> {
|
||||
public:
|
||||
using Handler =
|
||||
base::Callback<void(const base::DictionaryValue&, v8::Local<v8::Value>)>;
|
||||
using CompletionCallback = base::Callback<void(v8::Local<v8::Value>)>;
|
||||
using BooleanCallback = base::Callback<void(bool)>;
|
||||
|
||||
static mate::Handle<Protocol> Create(v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context);
|
||||
@@ -92,9 +95,6 @@ class Protocol : public mate::TrackableObject<Protocol> {
|
||||
DISALLOW_COPY_AND_ASSIGN(CustomProtocolHandler);
|
||||
};
|
||||
|
||||
// Register schemes that can handle service worker.
|
||||
void RegisterServiceWorkerSchemes(const std::vector<std::string>& schemes);
|
||||
|
||||
// Register the protocol with certain request job.
|
||||
template <typename RequestJob>
|
||||
void RegisterProtocol(const std::string& scheme,
|
||||
@@ -104,8 +104,8 @@ class Protocol : public mate::TrackableObject<Protocol> {
|
||||
args->GetNext(&callback);
|
||||
auto* getter = static_cast<URLRequestContextGetter*>(
|
||||
browser_context_->GetRequestContext());
|
||||
content::BrowserThread::PostTaskAndReplyWithResult(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraitsAndReplyWithResult(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&Protocol::RegisterProtocolInIO<RequestJob>,
|
||||
base::RetainedRef(getter), isolate(), scheme, handler),
|
||||
base::BindOnce(&Protocol::OnIOCompleted, GetWeakPtr(), callback));
|
||||
@@ -134,11 +134,7 @@ class Protocol : public mate::TrackableObject<Protocol> {
|
||||
const std::string& scheme);
|
||||
|
||||
// Whether the protocol has handler registered.
|
||||
void IsProtocolHandled(const std::string& scheme,
|
||||
const BooleanCallback& callback);
|
||||
static bool IsProtocolHandledInIO(
|
||||
scoped_refptr<URLRequestContextGetter> request_context_getter,
|
||||
const std::string& scheme);
|
||||
v8::Local<v8::Promise> IsProtocolHandled(const std::string& scheme);
|
||||
|
||||
// Replace the protocol handler with a new one.
|
||||
template <typename RequestJob>
|
||||
@@ -149,8 +145,8 @@ class Protocol : public mate::TrackableObject<Protocol> {
|
||||
args->GetNext(&callback);
|
||||
auto* getter = static_cast<URLRequestContextGetter*>(
|
||||
browser_context_->GetRequestContext());
|
||||
content::BrowserThread::PostTaskAndReplyWithResult(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraitsAndReplyWithResult(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&Protocol::InterceptProtocolInIO<RequestJob>,
|
||||
base::RetainedRef(getter), isolate(), scheme, handler),
|
||||
base::BindOnce(&Protocol::OnIOCompleted, GetWeakPtr(), callback));
|
||||
|
||||
@@ -26,7 +26,7 @@ bool IsWebContents(v8::Isolate* isolate, content::RenderProcessHost* process) {
|
||||
if (!web_contents)
|
||||
return false;
|
||||
|
||||
auto api_web_contents = WebContents::CreateFrom(isolate, web_contents);
|
||||
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;
|
||||
@@ -87,5 +87,5 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_render_process_preferences,
|
||||
Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_render_process_preferences,
|
||||
Initialize)
|
||||
|
||||
@@ -164,9 +164,11 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.Set("screen", Screen::Create(isolate));
|
||||
dict.Set("Screen", Screen::GetConstructor(isolate)->GetFunction());
|
||||
dict.Set(
|
||||
"Screen",
|
||||
Screen::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_screen, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_common_screen, Initialize)
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
#include "atom/browser/atom_permission_manager.h"
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/browser/media/media_device_id_salt.h"
|
||||
#include "atom/browser/net/atom_cert_verifier.h"
|
||||
#include "atom/browser/session_preferences.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
@@ -31,7 +32,7 @@
|
||||
#include "base/guid.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "brightray/browser/media/media_device_id_salt.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "components/download/public/common/download_danger_type.h"
|
||||
@@ -39,6 +40,7 @@
|
||||
#include "components/prefs/value_map_pref_store.h"
|
||||
#include "components/proxy_config/proxy_config_dictionary.h"
|
||||
#include "components/proxy_config/proxy_config_pref_names.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/download_item_utils.h"
|
||||
#include "content/public/browser/download_manager_delegate.h"
|
||||
@@ -59,7 +61,6 @@
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
using atom::api::Cookies;
|
||||
using content::BrowserThread;
|
||||
using content::StoragePartition;
|
||||
|
||||
@@ -211,12 +212,12 @@ std::map<uint32_t, v8::Global<v8::Object>> g_sessions;
|
||||
|
||||
// Runs the callback in UI thread.
|
||||
void RunCallbackInUI(const base::Callback<void()>& callback) {
|
||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback);
|
||||
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, callback);
|
||||
}
|
||||
template <typename... T>
|
||||
void RunCallbackInUI(const base::Callback<void(T...)>& callback, T... result) {
|
||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
||||
base::BindOnce(callback, result...));
|
||||
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
|
||||
base::BindOnce(callback, result...));
|
||||
}
|
||||
|
||||
// Callback of HttpCache::GetBackend.
|
||||
@@ -359,7 +360,7 @@ void DestroyGlobalHandle(v8::Isolate* isolate,
|
||||
if (!global_handle.IsEmpty()) {
|
||||
v8::Local<v8::Value> local_handle = global_handle.Get(isolate);
|
||||
if (local_handle->IsObject()) {
|
||||
v8::Local<v8::Object> object = local_handle->ToObject();
|
||||
v8::Local<v8::Object> object = local_handle->ToObject(isolate);
|
||||
void* ptr = object->GetAlignedPointerFromInternalField(0);
|
||||
if (!ptr)
|
||||
return;
|
||||
@@ -421,8 +422,8 @@ void Session::ResolveProxy(
|
||||
|
||||
template <Session::CacheAction action>
|
||||
void Session::DoCacheAction(const net::CompletionCallback& callback) {
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&DoCacheActionInIO,
|
||||
WrapRefCounted(browser_context_->GetRequestContext()),
|
||||
action, callback));
|
||||
@@ -440,12 +441,11 @@ void Session::ClearStorageData(mate::Arguments* args) {
|
||||
if (options.storage_types & StoragePartition::REMOVE_DATA_MASK_COOKIES) {
|
||||
// Reset media device id salt when cookies are cleared.
|
||||
// https://w3c.github.io/mediacapture-main/#dom-mediadeviceinfo-deviceid
|
||||
brightray::MediaDeviceIDSalt::Reset(browser_context()->prefs());
|
||||
MediaDeviceIDSalt::Reset(browser_context()->prefs());
|
||||
}
|
||||
storage_partition->ClearData(
|
||||
options.storage_types, options.quota_types, options.origin,
|
||||
content::StoragePartition::OriginMatcherFunction(), base::Time(),
|
||||
base::Time::Max(), base::Bind(&OnClearStorageDataDone, callback));
|
||||
storage_partition->ClearData(options.storage_types, options.quota_types,
|
||||
options.origin, base::Time(), base::Time::Max(),
|
||||
base::Bind(&OnClearStorageDataDone, callback));
|
||||
}
|
||||
|
||||
void Session::FlushStorageData() {
|
||||
@@ -471,13 +471,14 @@ void Session::SetProxy(const mate::Dictionary& options,
|
||||
if (!pac_url.empty()) {
|
||||
browser_context_->in_memory_pref_store()->SetValue(
|
||||
proxy_config::prefs::kProxy,
|
||||
ProxyConfigDictionary::CreatePacScript(pac_url,
|
||||
true /* pac_mandatory */),
|
||||
std::make_unique<base::Value>(ProxyConfigDictionary::CreatePacScript(
|
||||
pac_url, true /* pac_mandatory */)),
|
||||
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
|
||||
} else {
|
||||
browser_context_->in_memory_pref_store()->SetValue(
|
||||
proxy_config::prefs::kProxy,
|
||||
ProxyConfigDictionary::CreateFixedServers(proxy_rules, bypass_list),
|
||||
std::make_unique<base::Value>(ProxyConfigDictionary::CreateFixedServers(
|
||||
proxy_rules, bypass_list)),
|
||||
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
|
||||
}
|
||||
|
||||
@@ -532,8 +533,8 @@ void Session::SetCertVerifyProc(v8::Local<v8::Value> val,
|
||||
return;
|
||||
}
|
||||
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&SetCertVerifyProcInIO,
|
||||
WrapRefCounted(browser_context_->GetRequestContext()),
|
||||
base::Bind(&WrapVerifyProc, proc)));
|
||||
@@ -567,8 +568,8 @@ void Session::ClearHostResolverCache(mate::Arguments* args) {
|
||||
base::Closure callback;
|
||||
args->GetNext(&callback);
|
||||
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&ClearHostResolverCacheInIO,
|
||||
WrapRefCounted(browser_context_->GetRequestContext()),
|
||||
callback));
|
||||
@@ -583,16 +584,16 @@ void Session::ClearAuthCache(mate::Arguments* args) {
|
||||
base::Closure callback;
|
||||
args->GetNext(&callback);
|
||||
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&ClearAuthCacheInIO,
|
||||
WrapRefCounted(browser_context_->GetRequestContext()),
|
||||
options, callback));
|
||||
}
|
||||
|
||||
void Session::AllowNTLMCredentialsForDomains(const std::string& domains) {
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&AllowNTLMCredentialsForDomainsInIO,
|
||||
WrapRefCounted(browser_context_->GetRequestContext()),
|
||||
domains));
|
||||
@@ -622,8 +623,8 @@ void Session::GetBlobData(const std::string& uuid,
|
||||
return;
|
||||
|
||||
AtomBlobReader* blob_reader = browser_context()->GetBlobReader();
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&AtomBlobReader::StartReading,
|
||||
base::Unretained(blob_reader), uuid, callback));
|
||||
}
|
||||
@@ -783,6 +784,8 @@ void Session::BuildPrototype(v8::Isolate* isolate,
|
||||
|
||||
namespace {
|
||||
|
||||
using atom::api::Cookies;
|
||||
using atom::api::Protocol;
|
||||
using atom::api::Session;
|
||||
|
||||
v8::Local<v8::Value> FromPartition(const std::string& partition,
|
||||
@@ -802,11 +805,18 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.Set("Session", Session::GetConstructor(isolate)->GetFunction());
|
||||
dict.Set("Cookies", Cookies::GetConstructor(isolate)->GetFunction());
|
||||
dict.Set(
|
||||
"Session",
|
||||
Session::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
|
||||
dict.Set(
|
||||
"Cookies",
|
||||
Cookies::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
|
||||
dict.Set(
|
||||
"Protocol",
|
||||
Protocol::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
|
||||
dict.SetMethod("fromPartition", &FromPartition);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_session, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_session, Initialize)
|
||||
|
||||
@@ -37,6 +37,12 @@ bool SystemPreferences::IsInvertedColorScheme() {
|
||||
return color_utils::IsInvertedColorScheme();
|
||||
}
|
||||
|
||||
#if !defined(OS_WIN)
|
||||
bool SystemPreferences::IsHighContrastColorScheme() {
|
||||
return false;
|
||||
}
|
||||
#endif // !defined(OS_WIN)
|
||||
|
||||
// static
|
||||
mate::Handle<SystemPreferences> SystemPreferences::Create(
|
||||
v8::Isolate* isolate) {
|
||||
@@ -49,10 +55,13 @@ void SystemPreferences::BuildPrototype(
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "SystemPreferences"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
#if defined(OS_WIN)
|
||||
.SetMethod("getAccentColor", &SystemPreferences::GetAccentColor)
|
||||
.SetMethod("isAeroGlassEnabled", &SystemPreferences::IsAeroGlassEnabled)
|
||||
#if defined(OS_WIN) || defined(OS_MACOSX)
|
||||
.SetMethod("getColor", &SystemPreferences::GetColor)
|
||||
.SetMethod("getAccentColor", &SystemPreferences::GetAccentColor)
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
.SetMethod("isAeroGlassEnabled", &SystemPreferences::IsAeroGlassEnabled)
|
||||
#elif defined(OS_MACOSX)
|
||||
.SetMethod("postNotification", &SystemPreferences::PostNotification)
|
||||
.SetMethod("subscribeNotification",
|
||||
@@ -83,6 +92,7 @@ void SystemPreferences::BuildPrototype(
|
||||
&SystemPreferences::GetAppLevelAppearance)
|
||||
.SetMethod("setAppLevelAppearance",
|
||||
&SystemPreferences::SetAppLevelAppearance)
|
||||
.SetMethod("getSystemColor", &SystemPreferences::GetSystemColor)
|
||||
.SetMethod("isTrustedAccessibilityClient",
|
||||
&SystemPreferences::IsTrustedAccessibilityClient)
|
||||
.SetMethod("getMediaAccessStatus",
|
||||
@@ -91,6 +101,8 @@ void SystemPreferences::BuildPrototype(
|
||||
#endif
|
||||
.SetMethod("isInvertedColorScheme",
|
||||
&SystemPreferences::IsInvertedColorScheme)
|
||||
.SetMethod("isHighContrastColorScheme",
|
||||
&SystemPreferences::IsHighContrastColorScheme)
|
||||
.SetMethod("isDarkMode", &SystemPreferences::IsDarkMode);
|
||||
}
|
||||
|
||||
@@ -109,10 +121,11 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.Set("systemPreferences", SystemPreferences::Create(isolate));
|
||||
dict.Set("SystemPreferences",
|
||||
SystemPreferences::GetConstructor(isolate)->GetFunction());
|
||||
dict.Set("SystemPreferences", SystemPreferences::GetConstructor(isolate)
|
||||
->GetFunction(context)
|
||||
.ToLocalChecked());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_system_preferences, Initialize);
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_system_preferences, Initialize);
|
||||
|
||||
@@ -49,11 +49,12 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
#if defined(OS_WIN)
|
||||
bool IsAeroGlassEnabled();
|
||||
|
||||
#if defined(OS_WIN) || defined(OS_MACOSX)
|
||||
std::string GetAccentColor();
|
||||
std::string GetColor(const std::string& color, mate::Arguments* args);
|
||||
#endif
|
||||
#if defined(OS_WIN)
|
||||
bool IsAeroGlassEnabled();
|
||||
|
||||
void InitializeWindow();
|
||||
|
||||
@@ -68,7 +69,8 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||
base::Callback<void(const std::string&, const base::DictionaryValue&)>;
|
||||
|
||||
void PostNotification(const std::string& name,
|
||||
const base::DictionaryValue& user_info);
|
||||
const base::DictionaryValue& user_info,
|
||||
mate::Arguments* args);
|
||||
int SubscribeNotification(const std::string& name,
|
||||
const NotificationCallback& callback);
|
||||
void UnsubscribeNotification(int id);
|
||||
@@ -91,6 +93,8 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||
void RemoveUserDefault(const std::string& name);
|
||||
bool IsSwipeTrackingFromScrollEventsEnabled();
|
||||
|
||||
std::string GetSystemColor(const std::string& color, mate::Arguments* args);
|
||||
|
||||
static bool IsTrustedAccessibilityClient(bool prompt);
|
||||
|
||||
// TODO(codebytere): Write tests for these methods once we
|
||||
@@ -108,15 +112,13 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||
#endif
|
||||
bool IsDarkMode();
|
||||
bool IsInvertedColorScheme();
|
||||
bool IsHighContrastColorScheme();
|
||||
|
||||
protected:
|
||||
explicit SystemPreferences(v8::Isolate* isolate);
|
||||
~SystemPreferences() override;
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
void DoPostNotification(const std::string& name,
|
||||
const base::DictionaryValue& user_info,
|
||||
NotificationCenterKind kind);
|
||||
int DoSubscribeNotification(const std::string& name,
|
||||
const NotificationCallback& callback,
|
||||
NotificationCenterKind kind);
|
||||
@@ -149,6 +151,8 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||
|
||||
bool invertered_color_scheme_;
|
||||
|
||||
bool high_contrast_color_scheme_;
|
||||
|
||||
std::unique_ptr<gfx::ScopedSysColorChangeListener> color_change_listener_;
|
||||
#endif
|
||||
DISALLOW_COPY_AND_ASSIGN(SystemPreferences);
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "atom/browser/mac/dict_util.h"
|
||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "base/mac/sdk_forward_declarations.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "base/values.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
@@ -104,12 +106,35 @@ std::string ConvertAuthorizationStatus(AVAuthorizationStatusMac status) {
|
||||
}
|
||||
}
|
||||
|
||||
// Convert color to RGBA value like "aabbccdd"
|
||||
std::string ToRGBA(NSColor* color) {
|
||||
return base::StringPrintf(
|
||||
"%02X%02X%02X%02X", (int)(color.redComponent * 0xFF),
|
||||
(int)(color.greenComponent * 0xFF), (int)(color.blueComponent * 0xFF),
|
||||
(int)(color.alphaComponent * 0xFF));
|
||||
}
|
||||
|
||||
// Convert color to RGB hex value like "#ABCDEF"
|
||||
std::string ToRGBHex(NSColor* color) {
|
||||
return base::StringPrintf("#%02X%02X%02X", (int)(color.redComponent * 0xFF),
|
||||
(int)(color.greenComponent * 0xFF),
|
||||
(int)(color.blueComponent * 0xFF));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void SystemPreferences::PostNotification(
|
||||
const std::string& name,
|
||||
const base::DictionaryValue& user_info) {
|
||||
DoPostNotification(name, user_info, kNSDistributedNotificationCenter);
|
||||
void SystemPreferences::PostNotification(const std::string& name,
|
||||
const base::DictionaryValue& user_info,
|
||||
mate::Arguments* args) {
|
||||
bool immediate = false;
|
||||
args->GetNext(&immediate);
|
||||
|
||||
NSDistributedNotificationCenter* center =
|
||||
[NSDistributedNotificationCenter defaultCenter];
|
||||
[center postNotificationName:base::SysUTF8ToNSString(name)
|
||||
object:nil
|
||||
userInfo:DictionaryValueToNSDictionary(user_info)
|
||||
deliverImmediately:immediate];
|
||||
}
|
||||
|
||||
int SystemPreferences::SubscribeNotification(
|
||||
@@ -126,7 +151,10 @@ void SystemPreferences::UnsubscribeNotification(int request_id) {
|
||||
void SystemPreferences::PostLocalNotification(
|
||||
const std::string& name,
|
||||
const base::DictionaryValue& user_info) {
|
||||
DoPostNotification(name, user_info, kNSNotificationCenter);
|
||||
NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
|
||||
[center postNotificationName:base::SysUTF8ToNSString(name)
|
||||
object:nil
|
||||
userInfo:DictionaryValueToNSDictionary(user_info)];
|
||||
}
|
||||
|
||||
int SystemPreferences::SubscribeLocalNotification(
|
||||
@@ -142,7 +170,11 @@ void SystemPreferences::UnsubscribeLocalNotification(int request_id) {
|
||||
void SystemPreferences::PostWorkspaceNotification(
|
||||
const std::string& name,
|
||||
const base::DictionaryValue& user_info) {
|
||||
DoPostNotification(name, user_info, kNSWorkspaceNotificationCenter);
|
||||
NSNotificationCenter* center =
|
||||
[[NSWorkspace sharedWorkspace] notificationCenter];
|
||||
[center postNotificationName:base::SysUTF8ToNSString(name)
|
||||
object:nil
|
||||
userInfo:DictionaryValueToNSDictionary(user_info)];
|
||||
}
|
||||
|
||||
int SystemPreferences::SubscribeWorkspaceNotification(
|
||||
@@ -156,29 +188,6 @@ void SystemPreferences::UnsubscribeWorkspaceNotification(int request_id) {
|
||||
DoUnsubscribeNotification(request_id, kNSWorkspaceNotificationCenter);
|
||||
}
|
||||
|
||||
void SystemPreferences::DoPostNotification(
|
||||
const std::string& name,
|
||||
const base::DictionaryValue& user_info,
|
||||
NotificationCenterKind kind) {
|
||||
NSNotificationCenter* center;
|
||||
switch (kind) {
|
||||
case kNSDistributedNotificationCenter:
|
||||
center = [NSDistributedNotificationCenter defaultCenter];
|
||||
break;
|
||||
case kNSNotificationCenter:
|
||||
center = [NSNotificationCenter defaultCenter];
|
||||
break;
|
||||
case kNSWorkspaceNotificationCenter:
|
||||
center = [[NSWorkspace sharedWorkspace] notificationCenter];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
[center postNotificationName:base::SysUTF8ToNSString(name)
|
||||
object:nil
|
||||
userInfo:DictionaryValueToNSDictionary(user_info)];
|
||||
}
|
||||
|
||||
int SystemPreferences::DoSubscribeNotification(
|
||||
const std::string& name,
|
||||
const NotificationCallback& callback,
|
||||
@@ -386,12 +395,133 @@ void SystemPreferences::SetUserDefault(const std::string& name,
|
||||
}
|
||||
}
|
||||
|
||||
std::string SystemPreferences::GetAccentColor() {
|
||||
NSColor* sysColor = nil;
|
||||
if (@available(macOS 10.14, *))
|
||||
sysColor = [NSColor controlAccentColor];
|
||||
|
||||
return ToRGBA(sysColor);
|
||||
}
|
||||
|
||||
std::string SystemPreferences::GetSystemColor(const std::string& color,
|
||||
mate::Arguments* args) {
|
||||
NSColor* sysColor = nil;
|
||||
if (color == "blue") {
|
||||
sysColor = [NSColor systemBlueColor];
|
||||
} else if (color == "brown") {
|
||||
sysColor = [NSColor systemBrownColor];
|
||||
} else if (color == "gray") {
|
||||
sysColor = [NSColor systemGrayColor];
|
||||
} else if (color == "green") {
|
||||
sysColor = [NSColor systemGreenColor];
|
||||
} else if (color == "orange") {
|
||||
sysColor = [NSColor systemOrangeColor];
|
||||
} else if (color == "pink") {
|
||||
sysColor = [NSColor systemPinkColor];
|
||||
} else if (color == "purple") {
|
||||
sysColor = [NSColor systemPurpleColor];
|
||||
} else if (color == "red") {
|
||||
sysColor = [NSColor systemRedColor];
|
||||
} else if (color == "yellow") {
|
||||
sysColor = [NSColor systemYellowColor];
|
||||
} else {
|
||||
args->ThrowError("Unknown system color: " + color);
|
||||
return "";
|
||||
}
|
||||
|
||||
return ToRGBHex(sysColor);
|
||||
}
|
||||
|
||||
// static
|
||||
bool SystemPreferences::IsTrustedAccessibilityClient(bool prompt) {
|
||||
NSDictionary* options = @{(id)kAXTrustedCheckOptionPrompt : @(prompt)};
|
||||
return AXIsProcessTrustedWithOptions((CFDictionaryRef)options);
|
||||
}
|
||||
|
||||
std::string SystemPreferences::GetColor(const std::string& color,
|
||||
mate::Arguments* args) {
|
||||
NSColor* sysColor = nil;
|
||||
if (color == "alternate-selected-control-text") {
|
||||
sysColor = [NSColor alternateSelectedControlTextColor];
|
||||
} else if (color == "control-background") {
|
||||
sysColor = [NSColor controlBackgroundColor];
|
||||
} else if (color == "control") {
|
||||
sysColor = [NSColor controlColor];
|
||||
} else if (color == "control-text") {
|
||||
sysColor = [NSColor controlTextColor];
|
||||
} else if (color == "disabled-control") {
|
||||
sysColor = [NSColor disabledControlTextColor];
|
||||
} else if (color == "find-highlight") {
|
||||
if (@available(macOS 10.14, *))
|
||||
sysColor = [NSColor findHighlightColor];
|
||||
} else if (color == "grid") {
|
||||
sysColor = [NSColor gridColor];
|
||||
} else if (color == "header-text") {
|
||||
sysColor = [NSColor headerTextColor];
|
||||
} else if (color == "highlight") {
|
||||
sysColor = [NSColor highlightColor];
|
||||
} else if (color == "keyboard-focus-indicator") {
|
||||
sysColor = [NSColor keyboardFocusIndicatorColor];
|
||||
} else if (color == "label") {
|
||||
sysColor = [NSColor labelColor];
|
||||
} else if (color == "link") {
|
||||
sysColor = [NSColor linkColor];
|
||||
} else if (color == "placeholder-text") {
|
||||
sysColor = [NSColor placeholderTextColor];
|
||||
} else if (color == "quaternary-label") {
|
||||
sysColor = [NSColor quaternaryLabelColor];
|
||||
} else if (color == "scrubber-textured-background") {
|
||||
if (@available(macOS 10.12.2, *))
|
||||
sysColor = [NSColor scrubberTexturedBackgroundColor];
|
||||
} else if (color == "secondary-label") {
|
||||
sysColor = [NSColor secondaryLabelColor];
|
||||
} else if (color == "selected-content-background") {
|
||||
if (@available(macOS 10.14, *))
|
||||
sysColor = [NSColor selectedContentBackgroundColor];
|
||||
} else if (color == "selected-control") {
|
||||
sysColor = [NSColor selectedControlColor];
|
||||
} else if (color == "selected-control-text") {
|
||||
sysColor = [NSColor selectedControlTextColor];
|
||||
} else if (color == "selected-menu-item-text") {
|
||||
sysColor = [NSColor selectedMenuItemTextColor];
|
||||
} else if (color == "selected-text-background") {
|
||||
sysColor = [NSColor selectedTextBackgroundColor];
|
||||
} else if (color == "selected-text") {
|
||||
sysColor = [NSColor selectedTextColor];
|
||||
} else if (color == "separator") {
|
||||
if (@available(macOS 10.14, *))
|
||||
sysColor = [NSColor separatorColor];
|
||||
} else if (color == "shadow") {
|
||||
sysColor = [NSColor shadowColor];
|
||||
} else if (color == "tertiary-label") {
|
||||
sysColor = [NSColor tertiaryLabelColor];
|
||||
} else if (color == "text-background") {
|
||||
sysColor = [NSColor textBackgroundColor];
|
||||
} else if (color == "text") {
|
||||
sysColor = [NSColor textColor];
|
||||
} else if (color == "under-page-background") {
|
||||
sysColor = [NSColor underPageBackgroundColor];
|
||||
} else if (color == "unemphasized-selected-content-background") {
|
||||
if (@available(macOS 10.14, *))
|
||||
sysColor = [NSColor unemphasizedSelectedContentBackgroundColor];
|
||||
} else if (color == "unemphasized-selected-text-background") {
|
||||
if (@available(macOS 10.14, *))
|
||||
sysColor = [NSColor unemphasizedSelectedTextBackgroundColor];
|
||||
} else if (color == "unemphasized-selected-text") {
|
||||
if (@available(macOS 10.14, *))
|
||||
sysColor = [NSColor unemphasizedSelectedTextColor];
|
||||
} else if (color == "window-background") {
|
||||
sysColor = [NSColor windowBackgroundColor];
|
||||
} else if (color == "window-frame-text") {
|
||||
sysColor = [NSColor windowFrameTextColor];
|
||||
} else {
|
||||
args->ThrowError("Unknown color: " + color);
|
||||
return "";
|
||||
}
|
||||
|
||||
return ToRGBHex(sysColor);
|
||||
}
|
||||
|
||||
std::string SystemPreferences::GetMediaAccessStatus(
|
||||
const std::string& media_type,
|
||||
mate::Arguments* args) {
|
||||
@@ -412,25 +542,27 @@ std::string SystemPreferences::GetMediaAccessStatus(
|
||||
v8::Local<v8::Promise> SystemPreferences::AskForMediaAccess(
|
||||
v8::Isolate* isolate,
|
||||
const std::string& media_type) {
|
||||
scoped_refptr<util::Promise> promise = new util::Promise(isolate);
|
||||
util::Promise promise(isolate);
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
if (auto type = ParseMediaType(media_type)) {
|
||||
if (@available(macOS 10.14, *)) {
|
||||
__block util::Promise p = std::move(promise);
|
||||
[AVCaptureDevice requestAccessForMediaType:type
|
||||
completionHandler:^(BOOL granted) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
promise->Resolve(!!granted);
|
||||
p.Resolve(!!granted);
|
||||
});
|
||||
}];
|
||||
} else {
|
||||
// access always allowed pre-10.14 Mojave
|
||||
promise->Resolve(true);
|
||||
promise.Resolve(true);
|
||||
}
|
||||
} else {
|
||||
promise->RejectWithErrorMessage("Invalid media type");
|
||||
promise.RejectWithErrorMessage("Invalid media type");
|
||||
}
|
||||
|
||||
return promise->GetHandle();
|
||||
return handle;
|
||||
}
|
||||
|
||||
void SystemPreferences::RemoveUserDefault(const std::string& name) {
|
||||
|
||||
@@ -20,6 +20,18 @@ namespace {
|
||||
const wchar_t kSystemPreferencesWindowClass[] =
|
||||
L"Electron_SystemPreferencesHostWindow";
|
||||
|
||||
bool g_is_high_contract_color_scheme = false;
|
||||
bool g_is_high_contract_color_scheme_initialized = false;
|
||||
|
||||
void UpdateHighContrastColorScheme() {
|
||||
HIGHCONTRAST high_contrast = {0};
|
||||
high_contrast.cbSize = sizeof(HIGHCONTRAST);
|
||||
g_is_high_contract_color_scheme =
|
||||
SystemParametersInfo(SPI_GETHIGHCONTRAST, 0, &high_contrast, 0) &&
|
||||
((high_contrast.dwFlags & HCF_HIGHCONTRASTON) != 0);
|
||||
g_is_high_contract_color_scheme_initialized = true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace api {
|
||||
@@ -28,6 +40,12 @@ bool SystemPreferences::IsAeroGlassEnabled() {
|
||||
return ui::win::IsAeroGlassEnabled();
|
||||
}
|
||||
|
||||
bool SystemPreferences::IsHighContrastColorScheme() {
|
||||
if (!g_is_high_contract_color_scheme_initialized)
|
||||
UpdateHighContrastColorScheme();
|
||||
return g_is_high_contract_color_scheme;
|
||||
}
|
||||
|
||||
std::string hexColorDWORDToRGBA(DWORD color) {
|
||||
DWORD rgba = color << 8 | color >> 24;
|
||||
std::ostringstream stream;
|
||||
@@ -119,6 +137,7 @@ std::string SystemPreferences::GetColor(const std::string& color,
|
||||
|
||||
void SystemPreferences::InitializeWindow() {
|
||||
invertered_color_scheme_ = IsInvertedColorScheme();
|
||||
high_contrast_color_scheme_ = IsHighContrastColorScheme();
|
||||
|
||||
// Wait until app is ready before creating sys color listener
|
||||
// Creating this listener before the app is ready causes global shortcuts
|
||||
@@ -169,6 +188,9 @@ LRESULT CALLBACK SystemPreferences::WndProc(HWND hwnd,
|
||||
Emit("accent-color-changed", hexColorDWORDToRGBA(new_color));
|
||||
current_color_ = new_color_string;
|
||||
}
|
||||
} else if (message == WM_SYSCOLORCHANGE ||
|
||||
(message == WM_SETTINGCHANGE && wparam == SPI_SETHIGHCONTRAST)) {
|
||||
UpdateHighContrastColorScheme();
|
||||
}
|
||||
return ::DefWindowProc(hwnd, message, wparam, lparam);
|
||||
}
|
||||
@@ -179,6 +201,13 @@ void SystemPreferences::OnSysColorChange() {
|
||||
invertered_color_scheme_ = new_invertered_color_scheme;
|
||||
Emit("inverted-color-scheme-changed", new_invertered_color_scheme);
|
||||
}
|
||||
|
||||
bool new_high_contrast_color_scheme = IsHighContrastColorScheme();
|
||||
if (new_high_contrast_color_scheme != high_contrast_color_scheme_) {
|
||||
high_contrast_color_scheme_ = new_high_contrast_color_scheme;
|
||||
Emit("high-contrast-color-scheme-changed", new_high_contrast_color_scheme);
|
||||
}
|
||||
|
||||
Emit("color-changed");
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "gin/converter.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "native_mate/persistent_dictionary.h"
|
||||
|
||||
@@ -158,7 +159,7 @@ void TopLevelWindow::OnWindowClosed() {
|
||||
Emit("closed");
|
||||
|
||||
RemoveFromParentChildWindows();
|
||||
ResetBrowserView();
|
||||
TopLevelWindow::ResetBrowserViews();
|
||||
|
||||
// Destroy the native class when window is closed.
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, GetDestroyClosure());
|
||||
@@ -266,7 +267,7 @@ void TopLevelWindow::OnWindowAlwaysOnTopChanged() {
|
||||
Emit("always-on-top-changed", IsAlwaysOnTop());
|
||||
}
|
||||
|
||||
void TopLevelWindow::OnExecuteWindowsCommand(const std::string& command_name) {
|
||||
void TopLevelWindow::OnExecuteAppCommand(const std::string& command_name) {
|
||||
Emit("app-command", command_name);
|
||||
}
|
||||
|
||||
@@ -293,6 +294,7 @@ void TopLevelWindow::OnWindowMessage(UINT message,
|
||||
#endif
|
||||
|
||||
void TopLevelWindow::SetContentView(mate::Handle<View> view) {
|
||||
ResetBrowserViews();
|
||||
content_view_.Reset(isolate(), view.ToV8());
|
||||
window_->SetContentView(view->view());
|
||||
}
|
||||
@@ -643,7 +645,8 @@ void TopLevelWindow::SetFocusable(bool focusable) {
|
||||
void TopLevelWindow::SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> value) {
|
||||
mate::Handle<Menu> menu;
|
||||
if (value->IsObject() &&
|
||||
mate::V8ToString(value->ToObject()->GetConstructorName()) == "Menu" &&
|
||||
gin::V8ToString(
|
||||
isolate, value->ToObject(isolate)->GetConstructorName()) == "Menu" &&
|
||||
mate::ConvertFromV8(isolate, value, &menu) && !menu.IsEmpty()) {
|
||||
menu_.Reset(isolate, menu.ToV8());
|
||||
window_->SetMenu(menu->model());
|
||||
@@ -656,6 +659,11 @@ void TopLevelWindow::SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> value) {
|
||||
}
|
||||
}
|
||||
|
||||
void TopLevelWindow::RemoveMenu() {
|
||||
menu_.Reset();
|
||||
window_->SetMenu(nullptr);
|
||||
}
|
||||
|
||||
void TopLevelWindow::SetParentWindow(v8::Local<v8::Value> value,
|
||||
mate::Arguments* args) {
|
||||
if (IsModal()) {
|
||||
@@ -669,6 +677,7 @@ void TopLevelWindow::SetParentWindow(v8::Local<v8::Value> value,
|
||||
parent_window_.Reset();
|
||||
window_->SetParentWindow(nullptr);
|
||||
} else if (mate::ConvertFromV8(isolate(), value, &parent)) {
|
||||
RemoveFromParentChildWindows();
|
||||
parent_window_.Reset(isolate(), value);
|
||||
window_->SetParentWindow(parent->window_.get());
|
||||
parent->child_windows_.Set(isolate(), weak_map_id(), GetWrapper());
|
||||
@@ -678,18 +687,37 @@ void TopLevelWindow::SetParentWindow(v8::Local<v8::Value> value,
|
||||
}
|
||||
|
||||
void TopLevelWindow::SetBrowserView(v8::Local<v8::Value> value) {
|
||||
ResetBrowserView();
|
||||
ResetBrowserViews();
|
||||
AddBrowserView(value);
|
||||
}
|
||||
|
||||
void TopLevelWindow::AddBrowserView(v8::Local<v8::Value> value) {
|
||||
mate::Handle<BrowserView> browser_view;
|
||||
if (value->IsNull() || value->IsUndefined()) {
|
||||
window_->SetBrowserView(nullptr);
|
||||
} else if (mate::ConvertFromV8(isolate(), value, &browser_view)) {
|
||||
window_->SetBrowserView(browser_view->view());
|
||||
browser_view->web_contents()->SetOwnerWindow(window_.get());
|
||||
browser_view_.Reset(isolate(), value);
|
||||
if (value->IsObject() &&
|
||||
mate::ConvertFromV8(isolate(), value, &browser_view)) {
|
||||
auto get_that_view = browser_views_.find(browser_view->weak_map_id());
|
||||
if (get_that_view == browser_views_.end()) {
|
||||
window_->AddBrowserView(browser_view->view());
|
||||
browser_view->web_contents()->SetOwnerWindow(window_.get());
|
||||
browser_views_[browser_view->weak_map_id()].Reset(isolate(), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TopLevelWindow::RemoveBrowserView(v8::Local<v8::Value> value) {
|
||||
mate::Handle<BrowserView> browser_view;
|
||||
if (value->IsObject() &&
|
||||
mate::ConvertFromV8(isolate(), value, &browser_view)) {
|
||||
auto get_that_view = browser_views_.find(browser_view->weak_map_id());
|
||||
if (get_that_view != browser_views_.end()) {
|
||||
window_->RemoveBrowserView(browser_view->view());
|
||||
browser_view->web_contents()->SetOwnerWindow(nullptr);
|
||||
|
||||
(*get_that_view).second.Reset(isolate(), value);
|
||||
browser_views_.erase(get_that_view);
|
||||
}
|
||||
}
|
||||
}
|
||||
v8::Local<v8::Value> TopLevelWindow::GetNativeWindowHandle() {
|
||||
// TODO(MarshallOfSound): Replace once
|
||||
// https://chromium-review.googlesource.com/c/chromium/src/+/1253094/ has
|
||||
@@ -740,7 +768,7 @@ void TopLevelWindow::SetAutoHideCursor(bool auto_hide) {
|
||||
|
||||
void TopLevelWindow::SetVibrancy(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> value) {
|
||||
std::string type = mate::V8ToString(value);
|
||||
std::string type = gin::V8ToString(isolate, value);
|
||||
window_->SetVibrancy(type);
|
||||
}
|
||||
|
||||
@@ -844,12 +872,29 @@ std::vector<v8::Local<v8::Object>> TopLevelWindow::GetChildWindows() const {
|
||||
return child_windows_.Values(isolate());
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> TopLevelWindow::GetBrowserView() const {
|
||||
if (browser_view_.IsEmpty()) {
|
||||
v8::Local<v8::Value> TopLevelWindow::GetBrowserView(
|
||||
mate::Arguments* args) const {
|
||||
if (browser_views_.size() == 0) {
|
||||
return v8::Null(isolate());
|
||||
} else if (browser_views_.size() == 1) {
|
||||
auto first_view = browser_views_.begin();
|
||||
return v8::Local<v8::Value>::New(isolate(), (*first_view).second);
|
||||
} else {
|
||||
args->ThrowError(
|
||||
"BrowserWindow have multiple BrowserViews, "
|
||||
"Use getBrowserViews() instead");
|
||||
return v8::Null(isolate());
|
||||
}
|
||||
}
|
||||
|
||||
return v8::Local<v8::Value>::New(isolate(), browser_view_);
|
||||
std::vector<v8::Local<v8::Value>> TopLevelWindow::GetBrowserViews() const {
|
||||
std::vector<v8::Local<v8::Value>> ret;
|
||||
|
||||
for (auto const& views_iter : browser_views_) {
|
||||
ret.push_back(v8::Local<v8::Value>::New(isolate(), views_iter.second));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool TopLevelWindow::IsModal() const {
|
||||
@@ -941,17 +986,21 @@ int32_t TopLevelWindow::GetID() const {
|
||||
return weak_map_id();
|
||||
}
|
||||
|
||||
void TopLevelWindow::ResetBrowserView() {
|
||||
if (browser_view_.IsEmpty())
|
||||
return;
|
||||
void TopLevelWindow::ResetBrowserViews() {
|
||||
for (auto& item : browser_views_) {
|
||||
mate::Handle<BrowserView> browser_view;
|
||||
if (mate::ConvertFromV8(isolate(),
|
||||
v8::Local<v8::Value>::New(isolate(), item.second),
|
||||
&browser_view) &&
|
||||
!browser_view.IsEmpty()) {
|
||||
window_->RemoveBrowserView(browser_view->view());
|
||||
browser_view->web_contents()->SetOwnerWindow(nullptr);
|
||||
}
|
||||
|
||||
mate::Handle<BrowserView> browser_view;
|
||||
if (mate::ConvertFromV8(isolate(), GetBrowserView(), &browser_view) &&
|
||||
!browser_view.IsEmpty()) {
|
||||
browser_view->web_contents()->SetOwnerWindow(nullptr);
|
||||
item.second.Reset();
|
||||
}
|
||||
|
||||
browser_view_.Reset();
|
||||
browser_views_.clear();
|
||||
}
|
||||
|
||||
void TopLevelWindow::RemoveFromParentChildWindows() {
|
||||
@@ -1059,10 +1108,11 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("setContentProtection", &TopLevelWindow::SetContentProtection)
|
||||
.SetMethod("setFocusable", &TopLevelWindow::SetFocusable)
|
||||
.SetMethod("setMenu", &TopLevelWindow::SetMenu)
|
||||
#if !defined(OS_WIN)
|
||||
.SetMethod("removeMenu", &TopLevelWindow::RemoveMenu)
|
||||
.SetMethod("setParentWindow", &TopLevelWindow::SetParentWindow)
|
||||
#endif
|
||||
.SetMethod("setBrowserView", &TopLevelWindow::SetBrowserView)
|
||||
.SetMethod("addBrowserView", &TopLevelWindow::AddBrowserView)
|
||||
.SetMethod("removeBrowserView", &TopLevelWindow::RemoveBrowserView)
|
||||
.SetMethod("getNativeWindowHandle",
|
||||
&TopLevelWindow::GetNativeWindowHandle)
|
||||
.SetMethod("setProgressBar", &TopLevelWindow::SetProgressBar)
|
||||
@@ -1100,6 +1150,7 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("getParentWindow", &TopLevelWindow::GetParentWindow)
|
||||
.SetMethod("getChildWindows", &TopLevelWindow::GetChildWindows)
|
||||
.SetMethod("getBrowserView", &TopLevelWindow::GetBrowserView)
|
||||
.SetMethod("getBrowserViews", &TopLevelWindow::GetBrowserViews)
|
||||
.SetMethod("isModal", &TopLevelWindow::IsModal)
|
||||
.SetMethod("setThumbarButtons", &TopLevelWindow::SetThumbarButtons)
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
@@ -1134,8 +1185,9 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
TopLevelWindow::SetConstructor(isolate, base::Bind(&TopLevelWindow::New));
|
||||
|
||||
mate::Dictionary constructor(
|
||||
isolate, TopLevelWindow::GetConstructor(isolate)->GetFunction());
|
||||
mate::Dictionary constructor(isolate, TopLevelWindow::GetConstructor(isolate)
|
||||
->GetFunction(context)
|
||||
.ToLocalChecked());
|
||||
constructor.SetMethod("fromId",
|
||||
&mate::TrackableObject<TopLevelWindow>::FromWeakMapID);
|
||||
constructor.SetMethod("getAllWindows",
|
||||
@@ -1147,4 +1199,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_top_level_window, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_top_level_window, Initialize)
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/native_window_observer.h"
|
||||
#include "atom/common/api/atom_api_native_image.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "native_mate/handle.h"
|
||||
|
||||
@@ -78,7 +80,7 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
|
||||
void OnWindowEnterHtmlFullScreen() override;
|
||||
void OnWindowLeaveHtmlFullScreen() override;
|
||||
void OnWindowAlwaysOnTopChanged() override;
|
||||
void OnExecuteWindowsCommand(const std::string& command_name) override;
|
||||
void OnExecuteAppCommand(const std::string& command_name) override;
|
||||
void OnTouchBarItemResult(const std::string& item_id,
|
||||
const base::DictionaryValue& details) override;
|
||||
void OnNewWindowForTab() override;
|
||||
@@ -163,8 +165,13 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
|
||||
void SetContentProtection(bool enable);
|
||||
void SetFocusable(bool focusable);
|
||||
void SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> menu);
|
||||
void RemoveMenu();
|
||||
void SetParentWindow(v8::Local<v8::Value> value, mate::Arguments* args);
|
||||
virtual void SetBrowserView(v8::Local<v8::Value> value);
|
||||
virtual void AddBrowserView(v8::Local<v8::Value> value);
|
||||
virtual void RemoveBrowserView(v8::Local<v8::Value> value);
|
||||
virtual std::vector<v8::Local<v8::Value>> GetBrowserViews() const;
|
||||
virtual void ResetBrowserViews();
|
||||
v8::Local<v8::Value> GetNativeWindowHandle();
|
||||
void SetProgressBar(double progress, mate::Arguments* args);
|
||||
void SetOverlayIcon(const gfx::Image& overlay,
|
||||
@@ -195,7 +202,7 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
|
||||
v8::Local<v8::Value> GetContentView() const;
|
||||
v8::Local<v8::Value> GetParentWindow() const;
|
||||
std::vector<v8::Local<v8::Object>> GetChildWindows() const;
|
||||
v8::Local<v8::Value> GetBrowserView() const;
|
||||
v8::Local<v8::Value> GetBrowserView(mate::Arguments* args) const;
|
||||
bool IsModal() const;
|
||||
|
||||
// Extra APIs added in JS.
|
||||
@@ -226,8 +233,8 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
|
||||
|
||||
template <typename... Args>
|
||||
void EmitEventSoon(base::StringPiece eventName) {
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::BindOnce(base::IgnoreResult(&TopLevelWindow::Emit<Args...>),
|
||||
weak_factory_.GetWeakPtr(), eventName));
|
||||
}
|
||||
@@ -238,7 +245,7 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
|
||||
#endif
|
||||
|
||||
v8::Global<v8::Value> content_view_;
|
||||
v8::Global<v8::Value> browser_view_;
|
||||
std::map<int32_t, v8::Global<v8::Value>> browser_views_;
|
||||
v8::Global<v8::Value> menu_;
|
||||
v8::Global<v8::Value> parent_window_;
|
||||
KeyWeakMap<int> child_windows_;
|
||||
|
||||
@@ -254,9 +254,11 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
Tray::SetConstructor(isolate, base::Bind(&Tray::New));
|
||||
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.Set("Tray", Tray::GetConstructor(isolate)->GetFunction());
|
||||
dict.Set(
|
||||
"Tray",
|
||||
Tray::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_tray, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_tray, Initialize)
|
||||
|
||||
@@ -76,8 +76,9 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
View::SetConstructor(isolate, base::Bind(&View::New));
|
||||
|
||||
mate::Dictionary constructor(isolate,
|
||||
View::GetConstructor(isolate)->GetFunction());
|
||||
mate::Dictionary constructor(
|
||||
isolate,
|
||||
View::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
|
||||
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.Set("View", constructor);
|
||||
@@ -85,4 +86,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_view, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_view, Initialize)
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/net/atom_network_delegate.h"
|
||||
#include "atom/browser/ui/drag_util.h"
|
||||
#include "atom/browser/ui/inspectable_web_contents.h"
|
||||
#include "atom/browser/ui/inspectable_web_contents_view.h"
|
||||
#include "atom/browser/web_contents_permission_helper.h"
|
||||
#include "atom/browser/web_contents_preferences.h"
|
||||
#include "atom/browser/web_contents_zoom_controller.h"
|
||||
@@ -45,19 +47,18 @@
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "base/values.h"
|
||||
#include "brightray/browser/inspectable_web_contents.h"
|
||||
#include "brightray/browser/inspectable_web_contents_view.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/ssl/security_state_tab_helper.h"
|
||||
#include "content/browser/frame_host/frame_tree_node.h"
|
||||
#include "content/browser/frame_host/render_frame_host_manager.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_view_base.h"
|
||||
#include "content/common/view_messages.h"
|
||||
#include "content/common/widget_messages.h"
|
||||
#include "content/public/browser/child_process_security_policy.h"
|
||||
#include "content/public/browser/download_request_utils.h"
|
||||
#include "content/public/browser/favicon_status.h"
|
||||
@@ -80,13 +81,12 @@
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
#include "net/url_request/url_request_context.h"
|
||||
#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h"
|
||||
#include "third_party/blink/public/platform/web_input_event.h"
|
||||
#include "third_party/blink/public/web/web_find_options.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/events/base_event_utils.h"
|
||||
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
#include "atom/browser/osr/osr_output_device.h"
|
||||
#include "atom/browser/osr/osr_render_widget_host_view.h"
|
||||
#include "atom/browser/osr/osr_web_contents_view.h"
|
||||
#endif
|
||||
@@ -240,7 +240,7 @@ namespace api {
|
||||
namespace {
|
||||
|
||||
content::ServiceWorkerContext* GetServiceWorkerContext(
|
||||
const content::WebContents* web_contents) {
|
||||
content::WebContents* web_contents) {
|
||||
auto* context = web_contents->GetBrowserContext();
|
||||
auto* site_instance = web_contents->GetSiteInstance();
|
||||
if (!context || !site_instance)
|
||||
@@ -255,12 +255,11 @@ content::ServiceWorkerContext* GetServiceWorkerContext(
|
||||
}
|
||||
|
||||
// Called when CapturePage is done.
|
||||
void OnCapturePageDone(const base::Callback<void(const gfx::Image&)>& callback,
|
||||
const SkBitmap& bitmap) {
|
||||
void OnCapturePageDone(util::Promise promise, const SkBitmap& bitmap) {
|
||||
// Hack to enable transparency in captured image
|
||||
// TODO(nitsakh) Remove hack once fixed in chromium
|
||||
const_cast<SkBitmap&>(bitmap).setAlphaType(kPremul_SkAlphaType);
|
||||
callback.Run(gfx::Image::CreateFrom1xBitmap(bitmap));
|
||||
promise.Resolve(gfx::Image::CreateFrom1xBitmap(bitmap));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -287,21 +286,24 @@ struct WebContents::FrameDispatchHelper {
|
||||
};
|
||||
|
||||
WebContents::WebContents(v8::Isolate* isolate,
|
||||
content::WebContents* web_contents,
|
||||
content::WebContents* web_contents)
|
||||
: content::WebContentsObserver(web_contents), type_(REMOTE) {
|
||||
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent(),
|
||||
false);
|
||||
Init(isolate);
|
||||
AttachAsUserData(web_contents);
|
||||
InitZoomController(web_contents, mate::Dictionary::CreateEmpty(isolate));
|
||||
}
|
||||
|
||||
WebContents::WebContents(v8::Isolate* isolate,
|
||||
std::unique_ptr<content::WebContents> web_contents,
|
||||
Type type)
|
||||
: content::WebContentsObserver(web_contents), type_(type) {
|
||||
const mate::Dictionary options = mate::Dictionary::CreateEmpty(isolate);
|
||||
if (type == REMOTE) {
|
||||
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent(),
|
||||
false);
|
||||
Init(isolate);
|
||||
AttachAsUserData(web_contents);
|
||||
InitZoomController(web_contents, options);
|
||||
} else {
|
||||
auto session = Session::CreateFrom(isolate, GetBrowserContext());
|
||||
session_.Reset(isolate, session.ToV8());
|
||||
InitWithSessionAndOptions(isolate, web_contents, session, options);
|
||||
}
|
||||
: content::WebContentsObserver(web_contents.get()), type_(type) {
|
||||
DCHECK(type != REMOTE) << "Can't take ownership of a remote WebContents";
|
||||
auto session = Session::CreateFrom(isolate, GetBrowserContext());
|
||||
session_.Reset(isolate, session.ToV8());
|
||||
InitWithSessionAndOptions(isolate, std::move(web_contents), session,
|
||||
mate::Dictionary::CreateEmpty(isolate));
|
||||
}
|
||||
|
||||
WebContents::WebContents(v8::Isolate* isolate,
|
||||
@@ -387,7 +389,7 @@ WebContents::WebContents(v8::Isolate* isolate,
|
||||
web_contents = content::WebContents::Create(params);
|
||||
}
|
||||
|
||||
InitWithSessionAndOptions(isolate, web_contents.release(), session, options);
|
||||
InitWithSessionAndOptions(isolate, std::move(web_contents), session, options);
|
||||
}
|
||||
|
||||
void WebContents::InitZoomController(content::WebContents* web_contents,
|
||||
@@ -399,43 +401,47 @@ void WebContents::InitZoomController(content::WebContents* web_contents,
|
||||
zoom_controller_->SetDefaultZoomFactor(zoom_factor);
|
||||
}
|
||||
|
||||
void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
|
||||
content::WebContents* web_contents,
|
||||
mate::Handle<api::Session> session,
|
||||
const mate::Dictionary& options) {
|
||||
Observe(web_contents);
|
||||
InitWithWebContents(web_contents, session->browser_context(), IsGuest());
|
||||
void WebContents::InitWithSessionAndOptions(
|
||||
v8::Isolate* isolate,
|
||||
std::unique_ptr<content::WebContents> owned_web_contents,
|
||||
mate::Handle<api::Session> session,
|
||||
const mate::Dictionary& options) {
|
||||
Observe(owned_web_contents.get());
|
||||
// TODO(zcbenz): Make InitWithWebContents take unique_ptr.
|
||||
// At the time of writing we are going through a refactoring and I don't want
|
||||
// to make other people's work harder.
|
||||
InitWithWebContents(owned_web_contents.release(), session->browser_context(),
|
||||
IsGuest());
|
||||
|
||||
managed_web_contents()->GetView()->SetDelegate(this);
|
||||
|
||||
auto* prefs = web_contents->GetMutableRendererPrefs();
|
||||
auto* prefs = web_contents()->GetMutableRendererPrefs();
|
||||
prefs->accept_languages = g_browser_process->GetApplicationLocale();
|
||||
|
||||
#if defined(OS_LINUX) || defined(OS_WIN)
|
||||
// Update font settings.
|
||||
CR_DEFINE_STATIC_LOCAL(
|
||||
const gfx::FontRenderParams, params,
|
||||
(gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), nullptr)));
|
||||
prefs->should_antialias_text = params.antialiasing;
|
||||
prefs->use_subpixel_positioning = params.subpixel_positioning;
|
||||
prefs->hinting = params.hinting;
|
||||
prefs->use_autohinter = params.autohinter;
|
||||
prefs->use_bitmaps = params.use_bitmaps;
|
||||
prefs->subpixel_rendering = params.subpixel_rendering;
|
||||
static const base::NoDestructor<gfx::FontRenderParams> params(
|
||||
gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), nullptr));
|
||||
prefs->should_antialias_text = params->antialiasing;
|
||||
prefs->use_subpixel_positioning = params->subpixel_positioning;
|
||||
prefs->hinting = params->hinting;
|
||||
prefs->use_autohinter = params->autohinter;
|
||||
prefs->use_bitmaps = params->use_bitmaps;
|
||||
prefs->subpixel_rendering = params->subpixel_rendering;
|
||||
#endif
|
||||
|
||||
// Save the preferences in C++.
|
||||
new WebContentsPreferences(web_contents, options);
|
||||
new WebContentsPreferences(web_contents(), options);
|
||||
|
||||
// Initialize permission helper.
|
||||
WebContentsPermissionHelper::CreateForWebContents(web_contents);
|
||||
WebContentsPermissionHelper::CreateForWebContents(web_contents());
|
||||
// Initialize security state client.
|
||||
SecurityStateTabHelper::CreateForWebContents(web_contents);
|
||||
SecurityStateTabHelper::CreateForWebContents(web_contents());
|
||||
// Initialize zoom controller.
|
||||
InitZoomController(web_contents, options);
|
||||
InitZoomController(web_contents(), options);
|
||||
|
||||
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent(),
|
||||
false);
|
||||
web_contents()->SetUserAgentOverride(GetBrowserContext()->GetUserAgent(),
|
||||
false);
|
||||
|
||||
if (IsGuest()) {
|
||||
NativeWindow* owner_window = nullptr;
|
||||
@@ -451,7 +457,7 @@ void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
|
||||
}
|
||||
|
||||
Init(isolate);
|
||||
AttachAsUserData(web_contents);
|
||||
AttachAsUserData(web_contents());
|
||||
}
|
||||
|
||||
WebContents::~WebContents() {
|
||||
@@ -462,9 +468,9 @@ WebContents::~WebContents() {
|
||||
RenderViewDeleted(web_contents()->GetRenderViewHost());
|
||||
|
||||
if (type_ == WEB_VIEW) {
|
||||
DCHECK(!web_contents()->GetOuterWebContents())
|
||||
<< "Should never manually destroy an attached webview";
|
||||
// For webview simply destroy the WebContents immediately.
|
||||
// TODO(zcbenz): Add an internal API for webview instead of using
|
||||
// destroy(), so we don't have to add a special branch here.
|
||||
DestroyWebContents(false /* async */);
|
||||
} else if (type_ == BROWSER_WINDOW && owner_window()) {
|
||||
// For BrowserWindow we should close the window and clean up everything
|
||||
@@ -524,10 +530,10 @@ void WebContents::WebContentsCreated(content::WebContents* source_contents,
|
||||
const std::string& frame_name,
|
||||
const GURL& target_url,
|
||||
content::WebContents* new_contents) {
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
auto api_web_contents = CreateFrom(isolate(), new_contents, BROWSER_WINDOW);
|
||||
Emit("-web-contents-created", api_web_contents, target_url, frame_name);
|
||||
ChildWebContentsTracker::CreateForWebContents(new_contents);
|
||||
auto* tracker = ChildWebContentsTracker::FromWebContents(new_contents);
|
||||
tracker->url = target_url;
|
||||
tracker->frame_name = frame_name;
|
||||
}
|
||||
|
||||
void WebContents::AddNewContents(
|
||||
@@ -537,13 +543,17 @@ void WebContents::AddNewContents(
|
||||
const gfx::Rect& initial_rect,
|
||||
bool user_gesture,
|
||||
bool* was_blocked) {
|
||||
new ChildWebContentsTracker(new_contents.get());
|
||||
auto* tracker = ChildWebContentsTracker::FromWebContents(new_contents.get());
|
||||
DCHECK(tracker);
|
||||
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
auto api_web_contents = CreateFrom(isolate(), new_contents.release());
|
||||
auto api_web_contents =
|
||||
CreateAndTake(isolate(), std::move(new_contents), BROWSER_WINDOW);
|
||||
if (Emit("-add-new-contents", api_web_contents, disposition, user_gesture,
|
||||
initial_rect.x(), initial_rect.y(), initial_rect.width(),
|
||||
initial_rect.height())) {
|
||||
initial_rect.height(), tracker->url, tracker->frame_name)) {
|
||||
// TODO(zcbenz): Can we make this sync?
|
||||
api_web_contents->DestroyWebContents(true /* async */);
|
||||
}
|
||||
}
|
||||
@@ -587,7 +597,7 @@ void WebContents::SetContentsBounds(content::WebContents* source,
|
||||
|
||||
void WebContents::CloseContents(content::WebContents* source) {
|
||||
Emit("close");
|
||||
#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
HideAutofillPopup();
|
||||
#endif
|
||||
if (managed_web_contents())
|
||||
@@ -605,15 +615,15 @@ void WebContents::UpdateTargetURL(content::WebContents* source,
|
||||
Emit("update-target-url", url);
|
||||
}
|
||||
|
||||
void WebContents::HandleKeyboardEvent(
|
||||
bool WebContents::HandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
if (type_ == WEB_VIEW && embedder_) {
|
||||
// Send the unhandled keyboard events back to the embedder.
|
||||
embedder_->HandleKeyboardEvent(source, event);
|
||||
return embedder_->HandleKeyboardEvent(source, event);
|
||||
} else {
|
||||
// Go to the default keyboard handling.
|
||||
CommonWebContentsDelegate::HandleKeyboardEvent(source, event);
|
||||
return CommonWebContentsDelegate::HandleKeyboardEvent(source, event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -713,7 +723,7 @@ void WebContents::FindReply(content::WebContents* web_contents,
|
||||
bool WebContents::CheckMediaAccessPermission(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& security_origin,
|
||||
content::MediaStreamType type) {
|
||||
blink::MediaStreamType type) {
|
||||
auto* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
auto* permission_helper =
|
||||
@@ -756,7 +766,8 @@ void WebContents::OnAudioStateChanged(bool audible) {
|
||||
Emit("-audio-state-changed", audible);
|
||||
}
|
||||
|
||||
void WebContents::BeforeUnloadFired(const base::TimeTicks& proceed_time) {
|
||||
void WebContents::BeforeUnloadFired(bool proceed,
|
||||
const base::TimeTicks& proceed_time) {
|
||||
// Do nothing, we override this method just to avoid compilation error since
|
||||
// there are two virtual functions named BeforeUnloadFired.
|
||||
}
|
||||
@@ -769,8 +780,29 @@ void WebContents::RenderViewCreated(content::RenderViewHost* render_view_host) {
|
||||
impl->disable_hidden_ = !background_throttling_;
|
||||
}
|
||||
|
||||
void WebContents::RenderViewHostChanged(content::RenderViewHost* old_host,
|
||||
content::RenderViewHost* new_host) {
|
||||
currently_committed_process_id_ = new_host->GetProcess()->GetID();
|
||||
}
|
||||
|
||||
void WebContents::RenderViewDeleted(content::RenderViewHost* render_view_host) {
|
||||
// This event is necessary for tracking any states with respect to
|
||||
// intermediate render view hosts aka speculative render view hosts. Currently
|
||||
// used by object-registry.js to ref count remote objects.
|
||||
Emit("render-view-deleted", render_view_host->GetProcess()->GetID());
|
||||
|
||||
if (-1 == currently_committed_process_id_ ||
|
||||
render_view_host->GetProcess()->GetID() ==
|
||||
currently_committed_process_id_) {
|
||||
currently_committed_process_id_ = -1;
|
||||
|
||||
// When the RVH that has been deleted is the current RVH it means that the
|
||||
// the web contents are being closed. This is communicated by this event.
|
||||
// Currently tracked by guest-window-manager.js to destroy the
|
||||
// BrowserWindow.
|
||||
Emit("current-render-view-deleted",
|
||||
render_view_host->GetProcess()->GetID());
|
||||
}
|
||||
}
|
||||
|
||||
void WebContents::RenderProcessGone(base::TerminationStatus status) {
|
||||
@@ -807,10 +839,8 @@ void WebContents::DidChangeThemeColor(SkColor theme_color) {
|
||||
|
||||
void WebContents::DocumentLoadedInFrame(
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
if (!render_frame_host->GetParent()) {
|
||||
is_dom_ready_ = true;
|
||||
if (!render_frame_host->GetParent())
|
||||
Emit("dom-ready");
|
||||
}
|
||||
}
|
||||
|
||||
void WebContents::DidFinishLoad(content::RenderFrameHost* render_frame_host,
|
||||
@@ -837,7 +867,6 @@ void WebContents::DidFailLoad(content::RenderFrameHost* render_frame_host,
|
||||
}
|
||||
|
||||
void WebContents::DidStartLoading() {
|
||||
is_dom_ready_ = false;
|
||||
Emit("did-start-loading");
|
||||
}
|
||||
|
||||
@@ -970,8 +999,8 @@ void WebContents::DevToolsFocused() {
|
||||
void WebContents::DevToolsOpened() {
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
auto handle = WebContents::CreateFrom(
|
||||
isolate(), managed_web_contents()->GetDevToolsWebContents());
|
||||
auto handle =
|
||||
FromOrCreate(isolate(), managed_web_contents()->GetDevToolsWebContents());
|
||||
devtools_web_contents_.Reset(isolate(), handle.ToV8());
|
||||
|
||||
// Set inspected tabID.
|
||||
@@ -981,8 +1010,7 @@ void WebContents::DevToolsOpened() {
|
||||
|
||||
// Inherit owner window in devtools when it doesn't have one.
|
||||
auto* devtools = managed_web_contents()->GetDevToolsWebContents();
|
||||
bool has_window =
|
||||
devtools->GetUserData(NativeWindowRelay::kNativeWindowRelayUserDataKey);
|
||||
bool has_window = devtools->GetUserData(NativeWindowRelay::UserDataKey());
|
||||
if (owner_window() && !has_window)
|
||||
handle->SetOwnerWindow(devtools, owner_window());
|
||||
|
||||
@@ -997,7 +1025,7 @@ void WebContents::DevToolsClosed() {
|
||||
Emit("devtools-closed");
|
||||
}
|
||||
|
||||
#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
void WebContents::ShowAutofillPopup(content::RenderFrameHost* frame_host,
|
||||
const gfx::RectF& bounds,
|
||||
const std::vector<base::string16>& values,
|
||||
@@ -1022,7 +1050,7 @@ void WebContents::ShowAutofillPopup(content::RenderFrameHost* frame_host,
|
||||
bool WebContents::OnMessageReceived(const IPC::Message& message) {
|
||||
bool handled = true;
|
||||
IPC_BEGIN_MESSAGE_MAP(WebContents, message)
|
||||
IPC_MESSAGE_HANDLER_CODE(ViewHostMsg_SetCursor, OnCursorChange,
|
||||
IPC_MESSAGE_HANDLER_CODE(WidgetHostMsg_SetCursor, OnCursorChange,
|
||||
handled = false)
|
||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||
IPC_END_MESSAGE_MAP()
|
||||
@@ -1044,7 +1072,7 @@ bool WebContents::OnMessageReceived(const IPC::Message& message,
|
||||
FrameDispatchHelper::OnSetTemporaryZoomLevel)
|
||||
IPC_MESSAGE_FORWARD_DELAY_REPLY(AtomFrameHostMsg_GetZoomLevel, &helper,
|
||||
FrameDispatchHelper::OnGetZoomLevel)
|
||||
#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
IPC_MESSAGE_HANDLER(AtomAutofillFrameHostMsg_ShowPopup, ShowAutofillPopup)
|
||||
IPC_MESSAGE_HANDLER(AtomAutofillFrameHostMsg_HidePopup, HideAutofillPopup)
|
||||
#endif
|
||||
@@ -1098,7 +1126,7 @@ void WebContents::NavigationEntryCommitted(
|
||||
void WebContents::SetBackgroundThrottling(bool allowed) {
|
||||
background_throttling_ = allowed;
|
||||
|
||||
const auto* contents = web_contents();
|
||||
auto* contents = web_contents();
|
||||
if (!contents) {
|
||||
return;
|
||||
}
|
||||
@@ -1108,7 +1136,7 @@ void WebContents::SetBackgroundThrottling(bool allowed) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto* render_process_host = render_view_host->GetProcess();
|
||||
auto* render_process_host = render_view_host->GetProcess();
|
||||
if (!render_process_host) {
|
||||
return;
|
||||
}
|
||||
@@ -1157,8 +1185,9 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
|
||||
if (!options.Get("httpReferrer", ¶ms.referrer)) {
|
||||
GURL http_referrer;
|
||||
if (options.Get("httpReferrer", &http_referrer))
|
||||
params.referrer = content::Referrer(http_referrer.GetAsReferrer(),
|
||||
blink::kWebReferrerPolicyDefault);
|
||||
params.referrer =
|
||||
content::Referrer(http_referrer.GetAsReferrer(),
|
||||
network::mojom::ReferrerPolicy::kDefault);
|
||||
}
|
||||
|
||||
std::string user_agent;
|
||||
@@ -1301,14 +1330,16 @@ void WebContents::OpenDevTools(mate::Arguments* args) {
|
||||
if (type_ == WEB_VIEW || !owner_window()) {
|
||||
state = "detach";
|
||||
}
|
||||
bool activate = true;
|
||||
if (args && args->Length() == 1) {
|
||||
mate::Dictionary options;
|
||||
if (args->GetNext(&options)) {
|
||||
options.Get("mode", &state);
|
||||
options.Get("activate", &activate);
|
||||
}
|
||||
}
|
||||
managed_web_contents()->SetDockState(state);
|
||||
managed_web_contents()->ShowDevTools();
|
||||
managed_web_contents()->ShowDevTools(activate);
|
||||
}
|
||||
|
||||
void WebContents::CloseDevTools() {
|
||||
@@ -1343,8 +1374,8 @@ void WebContents::EnableDeviceEmulation(
|
||||
frame_host ? frame_host->GetView()->GetRenderWidgetHost() : nullptr;
|
||||
if (!widget_host)
|
||||
return;
|
||||
widget_host->Send(
|
||||
new ViewMsg_EnableDeviceEmulation(widget_host->GetRoutingID(), params));
|
||||
widget_host->Send(new WidgetMsg_EnableDeviceEmulation(
|
||||
widget_host->GetRoutingID(), params));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1359,7 +1390,7 @@ void WebContents::DisableDeviceEmulation() {
|
||||
if (!widget_host)
|
||||
return;
|
||||
widget_host->Send(
|
||||
new ViewMsg_DisableDeviceEmulation(widget_host->GetRoutingID()));
|
||||
new WidgetMsg_DisableDeviceEmulation(widget_host->GetRoutingID()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1452,10 +1483,6 @@ bool WebContents::IsCurrentlyAudible() {
|
||||
return web_contents()->IsCurrentlyAudible();
|
||||
}
|
||||
|
||||
bool WebContents::IsDOMReady() const {
|
||||
return is_dom_ready_;
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
void WebContents::Print(mate::Arguments* args) {
|
||||
bool silent = false, print_background = false;
|
||||
@@ -1491,11 +1518,11 @@ void WebContents::Print(mate::Arguments* args) {
|
||||
|
||||
std::vector<printing::PrinterBasicInfo> WebContents::GetPrinterList() {
|
||||
std::vector<printing::PrinterBasicInfo> printers;
|
||||
auto print_backend = printing::PrintBackend::CreateInstance(nullptr);
|
||||
{
|
||||
// TODO(deepak1556): Deprecate this api in favor of an
|
||||
// async version and post a non blocing task call.
|
||||
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
||||
auto print_backend = printing::PrintBackend::CreateInstance(nullptr);
|
||||
print_backend->EnumeratePrinters(&printers);
|
||||
}
|
||||
return printers;
|
||||
@@ -1572,17 +1599,22 @@ void WebContents::ReplaceMisspelling(const base::string16& word) {
|
||||
}
|
||||
|
||||
uint32_t WebContents::FindInPage(mate::Arguments* args) {
|
||||
uint32_t request_id = GetNextRequestId();
|
||||
base::string16 search_text;
|
||||
blink::WebFindOptions options;
|
||||
if (!args->GetNext(&search_text) || search_text.empty()) {
|
||||
args->ThrowError("Must provide a non-empty search content");
|
||||
return 0;
|
||||
}
|
||||
|
||||
args->GetNext(&options);
|
||||
uint32_t request_id = GetNextRequestId();
|
||||
mate::Dictionary dict;
|
||||
auto options = blink::mojom::FindOptions::New();
|
||||
if (args->GetNext(&dict)) {
|
||||
dict.Get("forward", &options->forward);
|
||||
dict.Get("matchCase", &options->match_case);
|
||||
dict.Get("findNext", &options->find_next);
|
||||
}
|
||||
|
||||
web_contents()->Find(request_id, search_text, options);
|
||||
web_contents()->Find(request_id, search_text, std::move(options));
|
||||
return request_id;
|
||||
}
|
||||
|
||||
@@ -1640,13 +1672,41 @@ bool WebContents::SendIPCMessageWithSender(bool internal,
|
||||
const std::string& channel,
|
||||
const base::ListValue& args,
|
||||
int32_t sender_id) {
|
||||
auto* frame_host = web_contents()->GetMainFrame();
|
||||
if (frame_host) {
|
||||
return frame_host->Send(new AtomFrameMsg_Message(frame_host->GetRoutingID(),
|
||||
internal, send_to_all,
|
||||
channel, args, sender_id));
|
||||
std::vector<content::RenderFrameHost*> target_hosts;
|
||||
if (!send_to_all) {
|
||||
auto* frame_host = web_contents()->GetMainFrame();
|
||||
if (frame_host) {
|
||||
target_hosts.push_back(frame_host);
|
||||
}
|
||||
} else {
|
||||
target_hosts = web_contents()->GetAllFrames();
|
||||
}
|
||||
return false;
|
||||
|
||||
bool handled = false;
|
||||
for (auto* frame_host : target_hosts) {
|
||||
handled = frame_host->Send(
|
||||
new AtomFrameMsg_Message(frame_host->GetRoutingID(), internal,
|
||||
false, channel, args, sender_id)) ||
|
||||
handled;
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
bool WebContents::SendIPCMessageToFrame(bool internal,
|
||||
bool send_to_all,
|
||||
int32_t frame_id,
|
||||
const std::string& channel,
|
||||
const base::ListValue& args) {
|
||||
auto frames = web_contents()->GetAllFrames();
|
||||
auto iter = std::find_if(frames.begin(), frames.end(), [frame_id](auto* f) {
|
||||
return f->GetRoutingID() == frame_id;
|
||||
});
|
||||
if (iter == frames.end())
|
||||
return false;
|
||||
if (!(*iter)->IsRenderFrameLive())
|
||||
return false;
|
||||
return (*iter)->Send(new AtomFrameMsg_Message(
|
||||
frame_id, internal, send_to_all, channel, args, 0 /* sender_id */));
|
||||
}
|
||||
|
||||
void WebContents::SendInputEvent(v8::Isolate* isolate,
|
||||
@@ -1745,28 +1805,25 @@ void WebContents::StartDrag(const mate::Dictionary& item,
|
||||
|
||||
// Start dragging.
|
||||
if (!files.empty()) {
|
||||
base::MessageLoop::ScopedNestableTaskAllower allow;
|
||||
base::MessageLoopCurrent::ScopedNestableTaskAllower allow;
|
||||
DragFileItems(files, icon->image(), web_contents()->GetNativeView());
|
||||
} else {
|
||||
args->ThrowError("Must specify either 'file' or 'files' option");
|
||||
}
|
||||
}
|
||||
|
||||
void WebContents::CapturePage(mate::Arguments* args) {
|
||||
v8::Local<v8::Promise> WebContents::CapturePage(mate::Arguments* args) {
|
||||
gfx::Rect rect;
|
||||
base::Callback<void(const gfx::Image&)> callback;
|
||||
util::Promise promise(isolate());
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
if (!(args->Length() == 1 && args->GetNext(&callback)) &&
|
||||
!(args->Length() == 2 && args->GetNext(&rect) &&
|
||||
args->GetNext(&callback))) {
|
||||
args->ThrowError();
|
||||
return;
|
||||
}
|
||||
// get rect arguments if they exist
|
||||
args->GetNext(&rect);
|
||||
|
||||
auto* const view = web_contents()->GetRenderWidgetHostView();
|
||||
if (!view) {
|
||||
callback.Run(gfx::Image());
|
||||
return;
|
||||
promise.Resolve(gfx::Image());
|
||||
return handle;
|
||||
}
|
||||
|
||||
// Capture full page if user doesn't specify a |rect|.
|
||||
@@ -1785,7 +1842,8 @@ void WebContents::CapturePage(mate::Arguments* args) {
|
||||
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
|
||||
|
||||
view->CopyFromSurface(gfx::Rect(rect.origin(), view_size), bitmap_size,
|
||||
base::BindOnce(&OnCapturePageDone, callback));
|
||||
base::BindOnce(&OnCapturePageDone, std::move(promise)));
|
||||
return handle;
|
||||
}
|
||||
|
||||
void WebContents::OnCursorChange(const content::WebCursor& cursor) {
|
||||
@@ -2080,7 +2138,6 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("setAudioMuted", &WebContents::SetAudioMuted)
|
||||
.SetMethod("isAudioMuted", &WebContents::IsAudioMuted)
|
||||
.SetMethod("isCurrentlyAudible", &WebContents::IsCurrentlyAudible)
|
||||
.SetMethod("isDomReady", &WebContents::IsDOMReady)
|
||||
.SetMethod("undo", &WebContents::Undo)
|
||||
.SetMethod("redo", &WebContents::Redo)
|
||||
.SetMethod("cut", &WebContents::Cut)
|
||||
@@ -2092,18 +2149,20 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("unselect", &WebContents::Unselect)
|
||||
.SetMethod("replace", &WebContents::Replace)
|
||||
.SetMethod("replaceMisspelling", &WebContents::ReplaceMisspelling)
|
||||
.SetMethod("_findInPage", &WebContents::FindInPage)
|
||||
.SetMethod("findInPage", &WebContents::FindInPage)
|
||||
.SetMethod("stopFindInPage", &WebContents::StopFindInPage)
|
||||
.SetMethod("focus", &WebContents::Focus)
|
||||
.SetMethod("isFocused", &WebContents::IsFocused)
|
||||
.SetMethod("tabTraverse", &WebContents::TabTraverse)
|
||||
.SetMethod("_send", &WebContents::SendIPCMessage)
|
||||
.SetMethod("_sendToFrame", &WebContents::SendIPCMessageToFrame)
|
||||
.SetMethod("sendInputEvent", &WebContents::SendInputEvent)
|
||||
.SetMethod("beginFrameSubscription", &WebContents::BeginFrameSubscription)
|
||||
.SetMethod("endFrameSubscription", &WebContents::EndFrameSubscription)
|
||||
.SetMethod("startDrag", &WebContents::StartDrag)
|
||||
.SetMethod("isGuest", &WebContents::IsGuest)
|
||||
.SetMethod("attachToIframe", &WebContents::AttachToIframe)
|
||||
.SetMethod("detachFromOuterFrame", &WebContents::DetachFromOuterFrame)
|
||||
.SetMethod("isOffscreen", &WebContents::IsOffScreen)
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
.SetMethod("startPainting", &WebContents::StartPainting)
|
||||
@@ -2114,9 +2173,9 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
||||
#endif
|
||||
.SetMethod("invalidate", &WebContents::Invalidate)
|
||||
.SetMethod("setZoomLevel", &WebContents::SetZoomLevel)
|
||||
.SetMethod("_getZoomLevel", &WebContents::GetZoomLevel)
|
||||
.SetMethod("getZoomLevel", &WebContents::GetZoomLevel)
|
||||
.SetMethod("setZoomFactor", &WebContents::SetZoomFactor)
|
||||
.SetMethod("_getZoomFactor", &WebContents::GetZoomFactor)
|
||||
.SetMethod("getZoomFactor", &WebContents::GetZoomFactor)
|
||||
.SetMethod("getType", &WebContents::GetType)
|
||||
.SetMethod("_getPreloadPath", &WebContents::GetPreloadPath)
|
||||
.SetMethod("getWebPreferences", &WebContents::GetWebPreferences)
|
||||
@@ -2162,7 +2221,7 @@ void WebContents::OnRendererMessage(content::RenderFrameHost* frame_host,
|
||||
const std::string& channel,
|
||||
const base::ListValue& args) {
|
||||
// webContents.emit(channel, new Event(), args...);
|
||||
Emit(channel, args);
|
||||
EmitWithSender(channel, frame_host, nullptr, args);
|
||||
}
|
||||
|
||||
void WebContents::OnRendererMessageSync(content::RenderFrameHost* frame_host,
|
||||
@@ -2188,35 +2247,43 @@ void WebContents::OnRendererMessageTo(content::RenderFrameHost* frame_host,
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<WebContents> WebContents::CreateFrom(
|
||||
v8::Isolate* isolate,
|
||||
content::WebContents* web_contents) {
|
||||
// We have an existing WebContents object in JS.
|
||||
auto* existing = TrackableObject::FromWrappedClass(isolate, web_contents);
|
||||
if (existing)
|
||||
return mate::CreateHandle(isolate, static_cast<WebContents*>(existing));
|
||||
|
||||
// Otherwise create a new WebContents wrapper object.
|
||||
return mate::CreateHandle(isolate,
|
||||
new WebContents(isolate, web_contents, REMOTE));
|
||||
}
|
||||
|
||||
mate::Handle<WebContents> WebContents::CreateFrom(
|
||||
v8::Isolate* isolate,
|
||||
content::WebContents* web_contents,
|
||||
Type type) {
|
||||
// Otherwise create a new WebContents wrapper object.
|
||||
return mate::CreateHandle(isolate,
|
||||
new WebContents(isolate, web_contents, type));
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<WebContents> WebContents::Create(v8::Isolate* isolate,
|
||||
const mate::Dictionary& options) {
|
||||
return mate::CreateHandle(isolate, new WebContents(isolate, options));
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<WebContents> WebContents::CreateAndTake(
|
||||
v8::Isolate* isolate,
|
||||
std::unique_ptr<content::WebContents> web_contents,
|
||||
Type type) {
|
||||
return mate::CreateHandle(
|
||||
isolate, new WebContents(isolate, std::move(web_contents), type));
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<WebContents> WebContents::From(
|
||||
v8::Isolate* isolate,
|
||||
content::WebContents* web_contents) {
|
||||
auto* existing = TrackableObject::FromWrappedClass(isolate, web_contents);
|
||||
if (existing)
|
||||
return mate::CreateHandle(isolate, static_cast<WebContents*>(existing));
|
||||
else
|
||||
return mate::Handle<WebContents>();
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<WebContents> WebContents::FromOrCreate(
|
||||
v8::Isolate* isolate,
|
||||
content::WebContents* web_contents) {
|
||||
auto existing = From(isolate, web_contents);
|
||||
if (!existing.IsEmpty())
|
||||
return existing;
|
||||
else
|
||||
return mate::CreateHandle(isolate, new WebContents(isolate, web_contents));
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
@@ -2231,7 +2298,9 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.Set("WebContents", WebContents::GetConstructor(isolate)->GetFunction());
|
||||
dict.Set("WebContents", WebContents::GetConstructor(isolate)
|
||||
->GetFunction(context)
|
||||
.ToLocalChecked());
|
||||
dict.SetMethod("create", &WebContents::Create);
|
||||
dict.SetMethod("fromId", &mate::TrackableObject<WebContents>::FromWeakMapID);
|
||||
dict.SetMethod("getAllWebContents",
|
||||
@@ -2240,4 +2309,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_web_contents, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_web_contents, Initialize)
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "atom/browser/common_web_contents_delegate.h"
|
||||
#include "atom/browser/ui/autofill_popup.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/observer_list_types.h"
|
||||
#include "content/common/cursors/webcursor.h"
|
||||
#include "content/public/browser/keyboard_event_processing_result.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
@@ -34,10 +35,6 @@ namespace blink {
|
||||
struct WebDeviceEmulationParams;
|
||||
}
|
||||
|
||||
namespace brightray {
|
||||
class InspectableWebContents;
|
||||
}
|
||||
|
||||
namespace mate {
|
||||
class Arguments;
|
||||
class Dictionary;
|
||||
@@ -51,6 +48,7 @@ namespace atom {
|
||||
|
||||
class AtomBrowserContext;
|
||||
class AtomJavaScriptDialogManager;
|
||||
class InspectableWebContents;
|
||||
class WebContentsZoomController;
|
||||
class WebViewGuestDelegate;
|
||||
class FrameSubscriber;
|
||||
@@ -63,10 +61,13 @@ namespace api {
|
||||
|
||||
// Certain events are only in WebContentsDelegate, provide our own Observer to
|
||||
// dispatch those events.
|
||||
class ExtendedWebContentsObserver {
|
||||
class ExtendedWebContentsObserver : public base::CheckedObserver {
|
||||
public:
|
||||
virtual void OnCloseContents() {}
|
||||
virtual void OnRendererResponsive() {}
|
||||
|
||||
protected:
|
||||
~ExtendedWebContentsObserver() override {}
|
||||
};
|
||||
|
||||
// Wrapper around the content::WebContents.
|
||||
@@ -83,19 +84,30 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
OFF_SCREEN, // Used for offscreen rendering
|
||||
};
|
||||
|
||||
// Create from an existing WebContents.
|
||||
static mate::Handle<WebContents> CreateFrom(
|
||||
v8::Isolate* isolate,
|
||||
content::WebContents* web_contents);
|
||||
static mate::Handle<WebContents> CreateFrom(
|
||||
v8::Isolate* isolate,
|
||||
content::WebContents* web_contents,
|
||||
Type type);
|
||||
|
||||
// Create a new WebContents.
|
||||
// Create a new WebContents and return the V8 wrapper of it.
|
||||
static mate::Handle<WebContents> Create(v8::Isolate* isolate,
|
||||
const mate::Dictionary& options);
|
||||
|
||||
// Create a new V8 wrapper for an existing |web_content|.
|
||||
//
|
||||
// The lifetime of |web_contents| will be managed by this class.
|
||||
static mate::Handle<WebContents> CreateAndTake(
|
||||
v8::Isolate* isolate,
|
||||
std::unique_ptr<content::WebContents> web_contents,
|
||||
Type type);
|
||||
|
||||
// Get the V8 wrapper of |web_content|, return empty handle if not wrapped.
|
||||
static mate::Handle<WebContents> From(v8::Isolate* isolate,
|
||||
content::WebContents* web_content);
|
||||
|
||||
// Get the V8 wrapper of the |web_contents|, or create one if not existed.
|
||||
//
|
||||
// The lifetime of |web_contents| is NOT managed by this class, and the type
|
||||
// of this wrapper is always REMOTE.
|
||||
static mate::Handle<WebContents> FromOrCreate(
|
||||
v8::Isolate* isolate,
|
||||
content::WebContents* web_contents);
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
@@ -155,7 +167,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
void SetAudioMuted(bool muted);
|
||||
bool IsAudioMuted();
|
||||
bool IsCurrentlyAudible();
|
||||
bool IsDOMReady() const;
|
||||
void SetEmbedder(const WebContents* embedder);
|
||||
void SetDevToolsWebContents(const WebContents* devtools);
|
||||
v8::Local<v8::Value> GetNativeView() const;
|
||||
@@ -207,6 +218,12 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
const base::ListValue& args,
|
||||
int32_t sender_id = 0);
|
||||
|
||||
bool SendIPCMessageToFrame(bool internal,
|
||||
bool send_to_all,
|
||||
int32_t frame_id,
|
||||
const std::string& channel,
|
||||
const base::ListValue& args);
|
||||
|
||||
// Send WebInputEvent to the page.
|
||||
void SendInputEvent(v8::Isolate* isolate, v8::Local<v8::Value> input_event);
|
||||
|
||||
@@ -219,12 +236,13 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
|
||||
// Captures the page with |rect|, |callback| would be called when capturing is
|
||||
// done.
|
||||
void CapturePage(mate::Arguments* args);
|
||||
v8::Local<v8::Promise> CapturePage(mate::Arguments* args);
|
||||
|
||||
// Methods for creating <webview>.
|
||||
bool IsGuest() const;
|
||||
void AttachToIframe(content::WebContents* embedder_web_contents,
|
||||
int embedder_frame_id);
|
||||
void DetachFromOuterFrame();
|
||||
|
||||
// Methods for offscreen rendering
|
||||
bool IsOffScreen() const;
|
||||
@@ -291,23 +309,30 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
observers_.AddObserver(obs);
|
||||
}
|
||||
void RemoveObserver(ExtendedWebContentsObserver* obs) {
|
||||
observers_.RemoveObserver(obs);
|
||||
// Trying to remove from an empty collection leads to an access violation
|
||||
if (observers_.might_have_observers())
|
||||
observers_.RemoveObserver(obs);
|
||||
}
|
||||
|
||||
bool EmitNavigationEvent(const std::string& event,
|
||||
content::NavigationHandle* navigation_handle);
|
||||
|
||||
protected:
|
||||
// Does not manage lifetime of |web_contents|.
|
||||
WebContents(v8::Isolate* isolate, content::WebContents* web_contents);
|
||||
// Takes over ownership of |web_contents|.
|
||||
WebContents(v8::Isolate* isolate,
|
||||
content::WebContents* web_contents,
|
||||
std::unique_ptr<content::WebContents> web_contents,
|
||||
Type type);
|
||||
// Creates a new content::WebContents.
|
||||
WebContents(v8::Isolate* isolate, const mate::Dictionary& options);
|
||||
~WebContents() override;
|
||||
|
||||
void InitWithSessionAndOptions(v8::Isolate* isolate,
|
||||
content::WebContents* web_contents,
|
||||
mate::Handle<class Session> session,
|
||||
const mate::Dictionary& options);
|
||||
void InitWithSessionAndOptions(
|
||||
v8::Isolate* isolate,
|
||||
std::unique_ptr<content::WebContents> web_contents,
|
||||
mate::Handle<class Session> session,
|
||||
const mate::Dictionary& options);
|
||||
|
||||
// content::WebContentsDelegate:
|
||||
bool DidAddMessageToConsole(content::WebContents* source,
|
||||
@@ -338,7 +363,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
void CloseContents(content::WebContents* source) override;
|
||||
void ActivateContents(content::WebContents* contents) override;
|
||||
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
|
||||
void HandleKeyboardEvent(
|
||||
bool HandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) override;
|
||||
content::KeyboardEventProcessingResult PreHandleKeyboardEvent(
|
||||
@@ -366,7 +391,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
bool final_update) override;
|
||||
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
|
||||
const GURL& security_origin,
|
||||
content::MediaStreamType type) override;
|
||||
blink::MediaStreamType type) override;
|
||||
void RequestMediaAccessPermission(
|
||||
content::WebContents* web_contents,
|
||||
const content::MediaStreamRequest& request,
|
||||
@@ -382,8 +407,11 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
void OnAudioStateChanged(bool audible) override;
|
||||
|
||||
// content::WebContentsObserver:
|
||||
void BeforeUnloadFired(const base::TimeTicks& proceed_time) override;
|
||||
void BeforeUnloadFired(bool proceed,
|
||||
const base::TimeTicks& proceed_time) override;
|
||||
void RenderViewCreated(content::RenderViewHost*) override;
|
||||
void RenderViewHostChanged(content::RenderViewHost* old_host,
|
||||
content::RenderViewHost* new_host) override;
|
||||
void RenderViewDeleted(content::RenderViewHost*) override;
|
||||
void RenderProcessGone(base::TerminationStatus status) override;
|
||||
void DocumentLoadedInFrame(
|
||||
@@ -421,10 +449,10 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
content::WebContentsObserver::MediaStoppedReason reason) override;
|
||||
void DidChangeThemeColor(SkColor theme_color) override;
|
||||
|
||||
// brightray::InspectableWebContentsDelegate:
|
||||
// InspectableWebContentsDelegate:
|
||||
void DevToolsReloadPage() override;
|
||||
|
||||
// brightray::InspectableWebContentsViewDelegate:
|
||||
// InspectableWebContentsViewDelegate:
|
||||
void DevToolsFocused() override;
|
||||
void DevToolsOpened() override;
|
||||
void DevToolsClosed() override;
|
||||
@@ -509,12 +537,13 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
// Whether to enable devtools.
|
||||
bool enable_devtools_ = true;
|
||||
|
||||
// Whether page's document is ready.
|
||||
bool is_dom_ready_ = false;
|
||||
|
||||
// Observers of this WebContents.
|
||||
base::ObserverList<ExtendedWebContentsObserver> observers_;
|
||||
|
||||
// The ID of the process of the currently committed RenderViewHost.
|
||||
// -1 means no speculative RVH has been committed yet.
|
||||
int currently_committed_process_id_ = -1;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(WebContents);
|
||||
};
|
||||
|
||||
|
||||
@@ -4,9 +4,12 @@
|
||||
|
||||
#include "atom/browser/api/atom_api_web_contents.h"
|
||||
|
||||
#include "content/browser/web_contents/web_contents_impl.h"
|
||||
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
#include "atom/browser/osr/osr_render_widget_host_view.h"
|
||||
#include "atom/browser/osr/osr_web_contents_view.h"
|
||||
#include "content/browser/web_contents/web_contents_impl.h"
|
||||
#endif
|
||||
|
||||
// Including both web_contents_impl.h and node.h would introduce a error, we
|
||||
// have to isolate the usage of WebContentsImpl into a clean file to fix it:
|
||||
@@ -16,6 +19,13 @@ namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
void WebContents::DetachFromOuterFrame() {
|
||||
// See detach_webview_frame.patch on how to detach.
|
||||
auto* impl = static_cast<content::WebContentsImpl*>(web_contents());
|
||||
impl->GetRenderManagerForTesting()->RemoveOuterDelegateFrame();
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
OffScreenWebContentsView* WebContents::GetOffScreenWebContentsView() const {
|
||||
if (IsOffScreen()) {
|
||||
const auto* impl =
|
||||
@@ -35,6 +45,7 @@ OffScreenRenderWidgetHostView* WebContents::GetOffScreenRenderWidgetHostView()
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace api
|
||||
|
||||
@@ -17,7 +17,7 @@ bool WebContents::IsFocused() const {
|
||||
return false;
|
||||
|
||||
if (GetType() != BACKGROUND_PAGE) {
|
||||
auto window = [web_contents()->GetNativeView() window];
|
||||
auto window = [web_contents()->GetNativeView().GetNativeNSView() window];
|
||||
// On Mac the render widget host view does not lose focus when the window
|
||||
// loses focus so check if the top level window is the key window.
|
||||
if (window && ![window isKeyWindow])
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
#include "atom/browser/api/atom_api_web_contents.h"
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/browser/ui/inspectable_web_contents_view.h"
|
||||
#include "atom/common/api/constructor.h"
|
||||
#include "brightray/browser/inspectable_web_contents_view.h"
|
||||
#include "content/public/browser/web_contents_user_data.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
||||
@@ -31,12 +31,14 @@ class WebContentsViewRelay
|
||||
|
||||
atom::api::WebContentsView* view_ = nullptr;
|
||||
|
||||
WEB_CONTENTS_USER_DATA_KEY_DECL();
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(WebContentsViewRelay);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
WEB_CONTENTS_USER_DATA_KEY_IMPL(WebContentsViewRelay)
|
||||
|
||||
DEFINE_WEB_CONTENTS_USER_DATA_KEY(WebContentsViewRelay);
|
||||
} // namespace
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -44,7 +46,7 @@ namespace api {
|
||||
|
||||
WebContentsView::WebContentsView(v8::Isolate* isolate,
|
||||
mate::Handle<WebContents> web_contents,
|
||||
brightray::InspectableWebContents* iwc)
|
||||
InspectableWebContents* iwc)
|
||||
#if defined(OS_MACOSX)
|
||||
: View(new DelayedNativeViewHost(iwc->GetView()->GetNativeView())),
|
||||
#else
|
||||
@@ -129,4 +131,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_web_contents_view, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_web_contents_view, Initialize)
|
||||
|
||||
@@ -9,12 +9,10 @@
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "native_mate/handle.h"
|
||||
|
||||
namespace brightray {
|
||||
class InspectableWebContents;
|
||||
}
|
||||
|
||||
namespace atom {
|
||||
|
||||
class InspectableWebContents;
|
||||
|
||||
namespace api {
|
||||
|
||||
class WebContents;
|
||||
@@ -30,7 +28,7 @@ class WebContentsView : public View, public content::WebContentsObserver {
|
||||
protected:
|
||||
WebContentsView(v8::Isolate* isolate,
|
||||
mate::Handle<WebContents> web_contents,
|
||||
brightray::InspectableWebContents* iwc);
|
||||
InspectableWebContents* iwc);
|
||||
~WebContentsView() override;
|
||||
|
||||
// content::WebContentsObserver:
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/net_converter.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "base/task/post_task.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"
|
||||
@@ -29,7 +31,7 @@ struct Converter<URLPattern> {
|
||||
if (!ConvertFromV8(isolate, val, &pattern))
|
||||
return false;
|
||||
*out = URLPattern(URLPattern::SCHEME_ALL);
|
||||
return out->Parse(pattern) == URLPattern::PARSE_SUCCESS;
|
||||
return out->Parse(pattern) == URLPattern::ParseResult::kSuccess;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -97,8 +99,8 @@ void WebRequest::SetListener(Method method, Event type, mate::Arguments* args) {
|
||||
browser_context_->GetRequestContext());
|
||||
if (!url_request_context_getter)
|
||||
return;
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&CallNetworkDelegateMethod<Method, Event, Listener>,
|
||||
base::RetainedRef(url_request_context_getter), method,
|
||||
type, std::move(patterns), std::move(listener)));
|
||||
|
||||
@@ -55,4 +55,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_web_view_manager, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_web_view_manager, Initialize)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "atom/browser/api/event_emitter.h"
|
||||
|
||||
#include "atom/browser/api/event.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "native_mate/arguments.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
@@ -34,7 +35,8 @@ v8::Local<v8::Object> CreateEventObject(v8::Isolate* isolate) {
|
||||
}
|
||||
|
||||
return v8::Local<v8::ObjectTemplate>::New(isolate, event_template)
|
||||
->NewInstance();
|
||||
->NewInstance(isolate->GetCurrentContext())
|
||||
.ToLocalChecked();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -55,7 +57,10 @@ v8::Local<v8::Object> CreateJSEvent(v8::Isolate* isolate,
|
||||
} else {
|
||||
event = CreateEventObject(isolate);
|
||||
}
|
||||
mate::Dictionary(isolate, event).Set("sender", object);
|
||||
mate::Dictionary dict(isolate, event);
|
||||
dict.Set("sender", object);
|
||||
if (sender)
|
||||
dict.Set("frameId", sender->GetRoutingID());
|
||||
return event;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "atom/common/api/event_emitter_caller.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
|
||||
namespace content {
|
||||
@@ -97,11 +98,13 @@ class EventEmitter : public Wrappable<T> {
|
||||
bool EmitWithEvent(const base::StringPiece& name,
|
||||
v8::Local<v8::Object> event,
|
||||
const Args&... args) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
EmitEvent(isolate(), GetWrapper(), name, event, args...);
|
||||
return event->Get(StringToV8(isolate(), "defaultPrevented"))
|
||||
->BooleanValue();
|
||||
->BooleanValue(isolate()->GetCurrentContext())
|
||||
.ToChecked();
|
||||
}
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(EventEmitter);
|
||||
|
||||
@@ -4,13 +4,12 @@
|
||||
|
||||
#include "atom/browser/api/frame_subscriber.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||
#include "components/viz/common/frame_sinks/copy_output_request.h"
|
||||
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
|
||||
#include "components/viz/service/surfaces/surface_manager.h"
|
||||
#include "content/browser/compositor/surface_utils.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_view_base.h"
|
||||
#include "ui/gfx/geometry/rect_conversions.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/render_widget_host.h"
|
||||
#include "content/public/browser/render_widget_host_view.h"
|
||||
#include "ui/gfx/skbitmap_operations.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
@@ -19,6 +18,8 @@ namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
constexpr static int kMaxFrameRate = 30;
|
||||
|
||||
FrameSubscriber::FrameSubscriber(v8::Isolate* isolate,
|
||||
content::WebContents* web_contents,
|
||||
const FrameCaptureCallback& callback,
|
||||
@@ -27,48 +28,123 @@ FrameSubscriber::FrameSubscriber(v8::Isolate* isolate,
|
||||
isolate_(isolate),
|
||||
callback_(callback),
|
||||
only_dirty_(only_dirty),
|
||||
weak_ptr_factory_(this) {}
|
||||
weak_ptr_factory_(this) {
|
||||
content::RenderViewHost* rvh = web_contents->GetRenderViewHost();
|
||||
if (rvh)
|
||||
AttachToHost(rvh->GetWidget());
|
||||
}
|
||||
|
||||
FrameSubscriber::~FrameSubscriber() = default;
|
||||
|
||||
gfx::Rect FrameSubscriber::GetDamageRect() {
|
||||
auto* view = web_contents()->GetRenderWidgetHostView();
|
||||
if (view == nullptr)
|
||||
return gfx::Rect();
|
||||
void FrameSubscriber::AttachToHost(content::RenderWidgetHost* host) {
|
||||
host_ = host;
|
||||
|
||||
auto* view_base = static_cast<content::RenderWidgetHostViewBase*>(view);
|
||||
viz::SurfaceManager* surface_manager =
|
||||
content::GetFrameSinkManager()->surface_manager();
|
||||
viz::Surface* surface =
|
||||
surface_manager->GetSurfaceForId(view_base->GetCurrentSurfaceId());
|
||||
if (surface == nullptr)
|
||||
return gfx::Rect();
|
||||
// The view can be null if the renderer process has crashed.
|
||||
// (https://crbug.com/847363)
|
||||
if (!host_->GetView())
|
||||
return;
|
||||
|
||||
if (surface->HasActiveFrame()) {
|
||||
const viz::CompositorFrame& frame = surface->GetActiveFrame();
|
||||
viz::RenderPass* root_pass = frame.render_pass_list.back().get();
|
||||
gfx::Size frame_size = root_pass->output_rect.size();
|
||||
gfx::Rect damage_rect =
|
||||
gfx::ToEnclosingRect(gfx::RectF(root_pass->damage_rect));
|
||||
damage_rect.Intersect(gfx::Rect(frame_size));
|
||||
return gfx::ScaleToEnclosedRect(damage_rect,
|
||||
1.0f / frame.device_scale_factor());
|
||||
} else {
|
||||
return gfx::Rect();
|
||||
// Create and configure the video capturer.
|
||||
video_capturer_ = host_->GetView()->CreateVideoCapturer();
|
||||
video_capturer_->SetResolutionConstraints(
|
||||
host_->GetView()->GetViewBounds().size(),
|
||||
host_->GetView()->GetViewBounds().size(), true);
|
||||
video_capturer_->SetAutoThrottlingEnabled(false);
|
||||
video_capturer_->SetMinSizeChangePeriod(base::TimeDelta());
|
||||
video_capturer_->SetFormat(media::PIXEL_FORMAT_ARGB,
|
||||
gfx::ColorSpace::CreateREC709());
|
||||
video_capturer_->SetMinCapturePeriod(base::TimeDelta::FromSeconds(1) /
|
||||
kMaxFrameRate);
|
||||
video_capturer_->Start(this);
|
||||
}
|
||||
|
||||
void FrameSubscriber::DetachFromHost() {
|
||||
if (!host_)
|
||||
return;
|
||||
video_capturer_.reset();
|
||||
host_ = nullptr;
|
||||
}
|
||||
|
||||
void FrameSubscriber::RenderViewCreated(content::RenderViewHost* host) {
|
||||
if (!host_)
|
||||
AttachToHost(host->GetWidget());
|
||||
}
|
||||
|
||||
void FrameSubscriber::RenderViewDeleted(content::RenderViewHost* host) {
|
||||
if (host->GetWidget() == host_) {
|
||||
DetachFromHost();
|
||||
}
|
||||
}
|
||||
|
||||
void FrameSubscriber::DidReceiveCompositorFrame() {
|
||||
auto* view = web_contents()->GetRenderWidgetHostView();
|
||||
if (view == nullptr)
|
||||
return;
|
||||
|
||||
view->CopyFromSurface(
|
||||
gfx::Rect(), view->GetViewBounds().size(),
|
||||
base::BindOnce(&FrameSubscriber::Done, weak_ptr_factory_.GetWeakPtr(),
|
||||
GetDamageRect()));
|
||||
void FrameSubscriber::RenderViewHostChanged(content::RenderViewHost* old_host,
|
||||
content::RenderViewHost* new_host) {
|
||||
if ((old_host && old_host->GetWidget() == host_) || (!old_host && !host_)) {
|
||||
DetachFromHost();
|
||||
AttachToHost(new_host->GetWidget());
|
||||
}
|
||||
}
|
||||
|
||||
void FrameSubscriber::OnFrameCaptured(
|
||||
base::ReadOnlySharedMemoryRegion data,
|
||||
::media::mojom::VideoFrameInfoPtr info,
|
||||
const gfx::Rect& update_rect,
|
||||
const gfx::Rect& content_rect,
|
||||
viz::mojom::FrameSinkVideoConsumerFrameCallbacksPtr callbacks) {
|
||||
gfx::Size view_size = host_->GetView()->GetViewBounds().size();
|
||||
if (view_size != content_rect.size()) {
|
||||
video_capturer_->SetResolutionConstraints(view_size, view_size, true);
|
||||
video_capturer_->RequestRefreshFrame();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.IsValid()) {
|
||||
callbacks->Done();
|
||||
return;
|
||||
}
|
||||
base::ReadOnlySharedMemoryMapping mapping = data.Map();
|
||||
if (!mapping.IsValid()) {
|
||||
DLOG(ERROR) << "Shared memory mapping failed.";
|
||||
return;
|
||||
}
|
||||
if (mapping.size() <
|
||||
media::VideoFrame::AllocationSize(info->pixel_format, info->coded_size)) {
|
||||
DLOG(ERROR) << "Shared memory size was less than expected.";
|
||||
return;
|
||||
}
|
||||
|
||||
// The SkBitmap's pixels will be marked as immutable, but the installPixels()
|
||||
// API requires a non-const pointer. So, cast away the const.
|
||||
void* const pixels = const_cast<void*>(mapping.memory());
|
||||
|
||||
// Call installPixels() with a |releaseProc| that: 1) notifies the capturer
|
||||
// that this consumer has finished with the frame, and 2) releases the shared
|
||||
// memory mapping.
|
||||
struct FramePinner {
|
||||
// Keeps the shared memory that backs |frame_| mapped.
|
||||
base::ReadOnlySharedMemoryMapping mapping;
|
||||
// Prevents FrameSinkVideoCapturer from recycling the shared memory that
|
||||
// backs |frame_|.
|
||||
viz::mojom::FrameSinkVideoConsumerFrameCallbacksPtr releaser;
|
||||
};
|
||||
|
||||
SkBitmap bitmap;
|
||||
bitmap.installPixels(
|
||||
SkImageInfo::MakeN32(content_rect.width(), content_rect.height(),
|
||||
kPremul_SkAlphaType),
|
||||
pixels,
|
||||
media::VideoFrame::RowBytes(media::VideoFrame::kARGBPlane,
|
||||
info->pixel_format, info->coded_size.width()),
|
||||
[](void* addr, void* context) {
|
||||
delete static_cast<FramePinner*>(context);
|
||||
},
|
||||
new FramePinner{std::move(mapping), std::move(callbacks)});
|
||||
bitmap.setImmutable();
|
||||
|
||||
Done(content_rect, bitmap);
|
||||
}
|
||||
|
||||
void FrameSubscriber::OnStopped() {}
|
||||
|
||||
void FrameSubscriber::Done(const gfx::Rect& damage, const SkBitmap& frame) {
|
||||
if (frame.drawsNothing())
|
||||
return;
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
#ifndef ATOM_BROWSER_API_FRAME_SUBSCRIBER_H_
|
||||
#define ATOM_BROWSER_API_FRAME_SUBSCRIBER_H_
|
||||
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include <memory>
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "components/viz/common/frame_sinks/copy_output_result.h"
|
||||
#include "components/viz/host/client_frame_sink_video_capturer.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
#include "v8/include/v8.h"
|
||||
|
||||
namespace atom {
|
||||
@@ -20,7 +20,8 @@ namespace api {
|
||||
|
||||
class WebContents;
|
||||
|
||||
class FrameSubscriber : public content::WebContentsObserver {
|
||||
class FrameSubscriber : public content::WebContentsObserver,
|
||||
public viz::mojom::FrameSinkVideoConsumer {
|
||||
public:
|
||||
using FrameCaptureCallback =
|
||||
base::Callback<void(v8::Local<v8::Value>, v8::Local<v8::Value>)>;
|
||||
@@ -32,14 +33,32 @@ class FrameSubscriber : public content::WebContentsObserver {
|
||||
~FrameSubscriber() override;
|
||||
|
||||
private:
|
||||
gfx::Rect GetDamageRect();
|
||||
void DidReceiveCompositorFrame() override;
|
||||
void AttachToHost(content::RenderWidgetHost* host);
|
||||
void DetachFromHost();
|
||||
|
||||
void RenderViewCreated(content::RenderViewHost* host) override;
|
||||
void RenderViewDeleted(content::RenderViewHost* host) override;
|
||||
void RenderViewHostChanged(content::RenderViewHost* old_host,
|
||||
content::RenderViewHost* new_host) override;
|
||||
|
||||
// viz::mojom::FrameSinkVideoConsumer implementation.
|
||||
void OnFrameCaptured(
|
||||
base::ReadOnlySharedMemoryRegion data,
|
||||
::media::mojom::VideoFrameInfoPtr info,
|
||||
const gfx::Rect& update_rect,
|
||||
const gfx::Rect& content_rect,
|
||||
viz::mojom::FrameSinkVideoConsumerFrameCallbacksPtr callbacks) override;
|
||||
void OnStopped() override;
|
||||
|
||||
void Done(const gfx::Rect& damage, const SkBitmap& frame);
|
||||
|
||||
v8::Isolate* isolate_;
|
||||
FrameCaptureCallback callback_;
|
||||
bool only_dirty_;
|
||||
|
||||
content::RenderWidgetHost* host_;
|
||||
std::unique_ptr<viz::ClientFrameSinkVideoCapturer> video_capturer_;
|
||||
|
||||
base::WeakPtrFactory<FrameSubscriber> weak_ptr_factory_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(FrameSubscriber);
|
||||
|
||||
@@ -107,6 +107,18 @@ void GPUInfoEnumerator::EndOverlayCapability() {
|
||||
value_stack.pop();
|
||||
}
|
||||
|
||||
void GPUInfoEnumerator::BeginDx12VulkanVersionInfo() {
|
||||
value_stack.push(std::move(current));
|
||||
current = std::make_unique<base::DictionaryValue>();
|
||||
}
|
||||
|
||||
void GPUInfoEnumerator::EndDx12VulkanVersionInfo() {
|
||||
auto& top_value = value_stack.top();
|
||||
top_value->SetDictionary(kDx12VulkanVersionInfoKey, std::move(current));
|
||||
current = std::move(top_value);
|
||||
value_stack.pop();
|
||||
}
|
||||
|
||||
std::unique_ptr<base::DictionaryValue> GPUInfoEnumerator::GetDictionary() {
|
||||
return std::move(current);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ class GPUInfoEnumerator final : public gpu::GPUInfo::Enumerator {
|
||||
"videoEncodeAcceleratorSupportedProfile";
|
||||
const char* kAuxAttributesKey = "auxAttributes";
|
||||
const char* kOverlayCapabilityKey = "overlayCapability";
|
||||
const char* kDx12VulkanVersionInfoKey = "dx12VulkanVersionInfo";
|
||||
|
||||
public:
|
||||
GPUInfoEnumerator();
|
||||
@@ -44,6 +45,8 @@ class GPUInfoEnumerator final : public gpu::GPUInfo::Enumerator {
|
||||
void EndAuxAttributes() override;
|
||||
void BeginOverlayCapability() override;
|
||||
void EndOverlayCapability() override;
|
||||
void BeginDx12VulkanVersionInfo() override;
|
||||
void EndDx12VulkanVersionInfo() override;
|
||||
std::unique_ptr<base::DictionaryValue> GetDictionary();
|
||||
|
||||
private:
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/api/gpuinfo_manager.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "atom/browser/api/gpu_info_enumerator.h"
|
||||
#include "base/memory/singleton.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
@@ -42,8 +45,8 @@ void GPUInfoManager::ProcessCompleteInfo() {
|
||||
const auto result = EnumerateGPUInfo(gpu_data_manager_->GetGPUInfo());
|
||||
// We have received the complete information, resolve all promises that
|
||||
// were waiting for this info.
|
||||
for (const auto& promise : complete_info_promise_set_) {
|
||||
promise->Resolve(*result);
|
||||
for (auto& promise : complete_info_promise_set_) {
|
||||
promise.Resolve(*result);
|
||||
}
|
||||
complete_info_promise_set_.clear();
|
||||
}
|
||||
@@ -58,8 +61,8 @@ void GPUInfoManager::OnGpuInfoUpdate() {
|
||||
}
|
||||
|
||||
// Should be posted to the task runner
|
||||
void GPUInfoManager::CompleteInfoFetcher(scoped_refptr<util::Promise> promise) {
|
||||
complete_info_promise_set_.push_back(promise);
|
||||
void GPUInfoManager::CompleteInfoFetcher(util::Promise promise) {
|
||||
complete_info_promise_set_.emplace_back(std::move(promise));
|
||||
|
||||
if (NeedsCompleteGpuInfoCollection()) {
|
||||
gpu_data_manager_->RequestCompleteGpuInfoIfNeeded();
|
||||
@@ -68,18 +71,18 @@ void GPUInfoManager::CompleteInfoFetcher(scoped_refptr<util::Promise> promise) {
|
||||
}
|
||||
}
|
||||
|
||||
void GPUInfoManager::FetchCompleteInfo(scoped_refptr<util::Promise> promise) {
|
||||
void GPUInfoManager::FetchCompleteInfo(util::Promise promise) {
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE, base::BindOnce(&GPUInfoManager::CompleteInfoFetcher,
|
||||
base::Unretained(this), promise));
|
||||
base::Unretained(this), std::move(promise)));
|
||||
}
|
||||
|
||||
// This fetches the info synchronously, so no need to post to the task queue.
|
||||
// There cannot be multiple promises as they are resolved synchronously.
|
||||
void GPUInfoManager::FetchBasicInfo(scoped_refptr<util::Promise> promise) {
|
||||
void GPUInfoManager::FetchBasicInfo(util::Promise promise) {
|
||||
gpu::GPUInfo gpu_info;
|
||||
CollectBasicGraphicsInfo(&gpu_info);
|
||||
promise->Resolve(*EnumerateGPUInfo(gpu_info));
|
||||
promise.Resolve(*EnumerateGPUInfo(gpu_info));
|
||||
}
|
||||
|
||||
std::unique_ptr<base::DictionaryValue> GPUInfoManager::EnumerateGPUInfo(
|
||||
|
||||
@@ -25,8 +25,8 @@ class GPUInfoManager : public content::GpuDataManagerObserver {
|
||||
GPUInfoManager();
|
||||
~GPUInfoManager() override;
|
||||
bool NeedsCompleteGpuInfoCollection() const;
|
||||
void FetchCompleteInfo(scoped_refptr<util::Promise> promise);
|
||||
void FetchBasicInfo(scoped_refptr<util::Promise> promise);
|
||||
void FetchCompleteInfo(util::Promise promise);
|
||||
void FetchBasicInfo(util::Promise promise);
|
||||
void OnGpuInfoUpdate() override;
|
||||
|
||||
private:
|
||||
@@ -34,12 +34,12 @@ class GPUInfoManager : public content::GpuDataManagerObserver {
|
||||
gpu::GPUInfo gpu_info) const;
|
||||
|
||||
// These should be posted to the task queue
|
||||
void CompleteInfoFetcher(scoped_refptr<util::Promise> promise);
|
||||
void CompleteInfoFetcher(util::Promise promise);
|
||||
void ProcessCompleteInfo();
|
||||
|
||||
// This set maintains all the promises that should be fulfilled
|
||||
// once we have the complete information data
|
||||
std::vector<scoped_refptr<util::Promise>> complete_info_promise_set_;
|
||||
std::vector<util::Promise> complete_info_promise_set_;
|
||||
content::GpuDataManager* gpu_data_manager_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(GPUInfoManager);
|
||||
|
||||
@@ -57,7 +57,9 @@ void SavePageHandler::OnDownloadUpdated(download::DownloadItem* item) {
|
||||
callback_.Run(v8::Null(isolate));
|
||||
} else {
|
||||
v8::Local<v8::String> error_message =
|
||||
v8::String::NewFromUtf8(isolate, "Fail to save page");
|
||||
v8::String::NewFromUtf8(isolate, "Fail to save page",
|
||||
v8::NewStringType::kNormal)
|
||||
.ToLocalChecked();
|
||||
callback_.Run(v8::Exception::Error(error_message));
|
||||
}
|
||||
Destroy(item);
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "atom/browser/net/url_request_stream_job.h"
|
||||
#include "atom/common/api/event_emitter_caller.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
@@ -78,23 +80,21 @@ void StreamSubscriber::OnData(mate::Arguments* args) {
|
||||
|
||||
// Pass the data to the URLJob in IO thread.
|
||||
std::vector<char> buffer(data, data + length);
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(&atom::URLRequestStreamJob::OnData, url_job_,
|
||||
base::Passed(&buffer)));
|
||||
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
|
||||
base::Bind(&atom::URLRequestStreamJob::OnData,
|
||||
url_job_, base::Passed(&buffer)));
|
||||
}
|
||||
|
||||
void StreamSubscriber::OnEnd(mate::Arguments* args) {
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::Bind(&atom::URLRequestStreamJob::OnEnd, url_job_));
|
||||
}
|
||||
|
||||
void StreamSubscriber::OnError(mate::Arguments* args) {
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(&atom::URLRequestStreamJob::OnError, url_job_,
|
||||
net::ERR_FAILED));
|
||||
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
|
||||
base::Bind(&atom::URLRequestStreamJob::OnError,
|
||||
url_job_, net::ERR_FAILED));
|
||||
}
|
||||
|
||||
void StreamSubscriber::RemoveAllListeners() {
|
||||
|
||||
@@ -84,4 +84,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_box_layout, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_box_layout, Initialize)
|
||||
|
||||
@@ -13,8 +13,10 @@ namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
Button::Button(views::Button* button) : View(button) {
|
||||
Button::Button(views::Button* impl) : View(impl) {
|
||||
view()->set_owned_by_client();
|
||||
// Make the button focusable as per the platform.
|
||||
button()->SetFocusForPlatform();
|
||||
}
|
||||
|
||||
Button::~Button() {}
|
||||
@@ -55,4 +57,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_button, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_button, Initialize)
|
||||
|
||||
@@ -27,6 +27,8 @@ class Button : public View, public views::ButtonListener {
|
||||
// views::ButtonListener:
|
||||
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
|
||||
|
||||
views::Button* button() const { return static_cast<views::Button*>(view()); }
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(Button);
|
||||
};
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "atom/common/api/constructor.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "ui/views/controls/button/label_button.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
@@ -15,11 +14,29 @@ namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
LabelButton::LabelButton(views::LabelButton* impl) : Button(impl) {}
|
||||
|
||||
LabelButton::LabelButton(const std::string& text)
|
||||
: Button(new views::LabelButton(this, base::UTF8ToUTF16(text))) {}
|
||||
|
||||
LabelButton::~LabelButton() {}
|
||||
|
||||
const base::string16& LabelButton::GetText() const {
|
||||
return label_button()->GetText();
|
||||
}
|
||||
|
||||
void LabelButton::SetText(const base::string16& text) {
|
||||
label_button()->SetText(text);
|
||||
}
|
||||
|
||||
bool LabelButton::IsDefault() const {
|
||||
return label_button()->is_default();
|
||||
}
|
||||
|
||||
void LabelButton::SetIsDefault(bool is_default) {
|
||||
label_button()->SetIsDefault(is_default);
|
||||
}
|
||||
|
||||
// static
|
||||
mate::WrappableBase* LabelButton::New(mate::Arguments* args,
|
||||
const std::string& text) {
|
||||
@@ -33,6 +50,11 @@ mate::WrappableBase* LabelButton::New(mate::Arguments* args,
|
||||
void LabelButton::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "LabelButton"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("getText", &LabelButton::GetText)
|
||||
.SetMethod("setText", &LabelButton::SetText)
|
||||
.SetMethod("isDefault", &LabelButton::IsDefault)
|
||||
.SetMethod("setIsDefault", &LabelButton::SetIsDefault);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
@@ -55,4 +77,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_label_button, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_label_button, Initialize)
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "atom/browser/api/views/atom_api_button.h"
|
||||
#include "ui/views/controls/button/label_button.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -21,10 +22,20 @@ class LabelButton : public Button {
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
const base::string16& GetText() const;
|
||||
void SetText(const base::string16& text);
|
||||
bool IsDefault() const;
|
||||
void SetIsDefault(bool is_default);
|
||||
|
||||
protected:
|
||||
explicit LabelButton(views::LabelButton* impl);
|
||||
explicit LabelButton(const std::string& text);
|
||||
~LabelButton() override;
|
||||
|
||||
views::LabelButton* label_button() const {
|
||||
return static_cast<views::LabelButton*>(view());
|
||||
}
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(LabelButton);
|
||||
};
|
||||
|
||||
@@ -60,4 +60,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_layout_manager, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_layout_manager, Initialize)
|
||||
|
||||
57
atom/browser/api/views/atom_api_md_text_button.cc
Normal file
57
atom/browser/api/views/atom_api_md_text_button.cc
Normal file
@@ -0,0 +1,57 @@
|
||||
// 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/views/atom_api_md_text_button.h"
|
||||
|
||||
#include "atom/common/api/constructor.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
MdTextButton::MdTextButton(const std::string& text)
|
||||
: LabelButton(views::MdTextButton::Create(this, base::UTF8ToUTF16(text))) {}
|
||||
|
||||
MdTextButton::~MdTextButton() {}
|
||||
|
||||
// static
|
||||
mate::WrappableBase* MdTextButton::New(mate::Arguments* args,
|
||||
const std::string& text) {
|
||||
// Constructor call.
|
||||
auto* view = new MdTextButton(text);
|
||||
view->InitWith(args->isolate(), args->GetThis());
|
||||
return view;
|
||||
}
|
||||
|
||||
// static
|
||||
void MdTextButton::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "MdTextButton"));
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
namespace {
|
||||
|
||||
using atom::api::MdTextButton;
|
||||
|
||||
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.Set("MdTextButton", mate::CreateConstructor<MdTextButton>(
|
||||
isolate, base::Bind(&MdTextButton::New)));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_md_text_button, Initialize)
|
||||
41
atom/browser/api/views/atom_api_md_text_button.h
Normal file
41
atom/browser/api/views/atom_api_md_text_button.h
Normal file
@@ -0,0 +1,41 @@
|
||||
// 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_VIEWS_ATOM_API_MD_TEXT_BUTTON_H_
|
||||
#define ATOM_BROWSER_API_VIEWS_ATOM_API_MD_TEXT_BUTTON_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "atom/browser/api/views/atom_api_label_button.h"
|
||||
#include "ui/views/controls/button/md_text_button.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
class MdTextButton : public LabelButton {
|
||||
public:
|
||||
static mate::WrappableBase* New(mate::Arguments* args,
|
||||
const std::string& text);
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
protected:
|
||||
explicit MdTextButton(const std::string& text);
|
||||
~MdTextButton() override;
|
||||
|
||||
views::MdTextButton* md_text_button() const {
|
||||
return static_cast<views::MdTextButton*>(view());
|
||||
}
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(MdTextButton);
|
||||
};
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_API_VIEWS_ATOM_API_MD_TEXT_BUTTON_H_
|
||||
60
atom/browser/api/views/atom_api_resize_area.cc
Normal file
60
atom/browser/api/views/atom_api_resize_area.cc
Normal file
@@ -0,0 +1,60 @@
|
||||
// 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/views/atom_api_resize_area.h"
|
||||
|
||||
#include "atom/common/api/constructor.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
ResizeArea::ResizeArea() : View(new views::ResizeArea(this)) {
|
||||
view()->set_owned_by_client();
|
||||
}
|
||||
|
||||
ResizeArea::~ResizeArea() {}
|
||||
|
||||
void ResizeArea::OnResize(int resize_amount, bool done_resizing) {
|
||||
Emit("resize", resize_amount, done_resizing);
|
||||
}
|
||||
|
||||
// static
|
||||
mate::WrappableBase* ResizeArea::New(mate::Arguments* args) {
|
||||
// Constructor call.
|
||||
auto* view = new ResizeArea();
|
||||
view->InitWith(args->isolate(), args->GetThis());
|
||||
return view;
|
||||
}
|
||||
|
||||
// static
|
||||
void ResizeArea::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "ResizeArea"));
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
namespace {
|
||||
|
||||
using atom::api::ResizeArea;
|
||||
|
||||
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.Set("ResizeArea", mate::CreateConstructor<ResizeArea>(
|
||||
isolate, base::Bind(&ResizeArea::New)));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_resize_area, Initialize)
|
||||
43
atom/browser/api/views/atom_api_resize_area.h
Normal file
43
atom/browser/api/views/atom_api_resize_area.h
Normal file
@@ -0,0 +1,43 @@
|
||||
// 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_VIEWS_ATOM_API_RESIZE_AREA_H_
|
||||
#define ATOM_BROWSER_API_VIEWS_ATOM_API_RESIZE_AREA_H_
|
||||
|
||||
#include "atom/browser/api/atom_api_view.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "ui/views/controls/resize_area.h"
|
||||
#include "ui/views/controls/resize_area_delegate.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
class ResizeArea : public View, protected views::ResizeAreaDelegate {
|
||||
public:
|
||||
static mate::WrappableBase* New(mate::Arguments* args);
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
protected:
|
||||
void OnResize(int resize_amount, bool done_resizing) override;
|
||||
|
||||
private:
|
||||
ResizeArea();
|
||||
~ResizeArea() override;
|
||||
|
||||
views::ResizeArea* resize_area() const {
|
||||
return static_cast<views::ResizeArea*>(view());
|
||||
}
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ResizeArea);
|
||||
};
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_API_VIEWS_ATOM_API_RESIZE_AREA_H_
|
||||
@@ -64,4 +64,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_text_field, Initialize)
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_text_field, Initialize)
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/base/net_errors.h"
|
||||
@@ -60,8 +62,8 @@ void AtomBlobReader::StartReading(
|
||||
auto blob_data_handle = blob_context_->context()->GetBlobDataFromUUID(uuid);
|
||||
auto callback = base::Bind(&RunCallbackInUI, completion_callback);
|
||||
if (!blob_data_handle) {
|
||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
||||
base::BindOnce(callback, nullptr, 0));
|
||||
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
|
||||
base::BindOnce(callback, nullptr, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -116,8 +118,8 @@ void AtomBlobReader::BlobReadHelper::DidReadBlobData(
|
||||
|
||||
char* data = new char[size];
|
||||
memcpy(data, blob_data->data(), size);
|
||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
||||
base::BindOnce(completion_callback_, data, size));
|
||||
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
|
||||
base::BindOnce(completion_callback_, data, size));
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "atom/app/manifests.h"
|
||||
#include "atom/browser/api/atom_api_app.h"
|
||||
#include "atom/browser/api/atom_api_protocol.h"
|
||||
#include "atom/browser/api/atom_api_web_contents.h"
|
||||
@@ -21,26 +22,37 @@
|
||||
#include "atom/browser/atom_resource_dispatcher_host_delegate.h"
|
||||
#include "atom/browser/atom_speech_recognition_manager_delegate.h"
|
||||
#include "atom/browser/child_web_contents_tracker.h"
|
||||
#include "atom/browser/font_defaults.h"
|
||||
#include "atom/browser/io_thread.h"
|
||||
#include "atom/browser/media/media_capture_devices_dispatcher.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/notifications/notification_presenter.h"
|
||||
#include "atom/browser/notifications/platform_notification_service.h"
|
||||
#include "atom/browser/session_preferences.h"
|
||||
#include "atom/browser/ui/devtools_manager_delegate.h"
|
||||
#include "atom/browser/web_contents_permission_helper.h"
|
||||
#include "atom/browser/web_contents_preferences.h"
|
||||
#include "atom/browser/window_list.h"
|
||||
#include "atom/common/google_api_key.h"
|
||||
#include "atom/common/application_info.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "atom/common/platform_util.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/environment.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/json/json_reader.h"
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/common/chrome_version.h"
|
||||
#include "components/net_log/chrome_net_log.h"
|
||||
#include "content/public/browser/browser_ppapi_host.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/client_certificate_delegate.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
@@ -62,6 +74,7 @@
|
||||
#include "services/device/public/cpp/geolocation/location_provider.h"
|
||||
#include "services/network/public/cpp/resource_request_body.h"
|
||||
#include "services/proxy_resolver/public/mojom/proxy_resolver.mojom.h"
|
||||
#include "services/service_manager/sandbox/switches.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/base/resource/resource_bundle.h"
|
||||
#include "v8/include/v8.h"
|
||||
@@ -72,6 +85,8 @@
|
||||
#include "net/ssl/client_cert_store_win.h"
|
||||
#elif defined(OS_MACOSX)
|
||||
#include "net/ssl/client_cert_store_mac.h"
|
||||
#include "services/audio/public/mojom/constants.mojom.h"
|
||||
#include "services/video_capture/public/mojom/constants.mojom.h"
|
||||
#elif defined(USE_OPENSSL)
|
||||
#include "net/ssl/client_cert_store.h"
|
||||
#endif
|
||||
@@ -84,16 +99,17 @@
|
||||
#include "atom/browser/fake_location_provider.h"
|
||||
#endif // BUILDFLAG(OVERRIDE_LOCATION_PROVIDER)
|
||||
|
||||
#if BUILDFLAG(ENABLE_TTS)
|
||||
#include "chrome/browser/speech/tts_controller_delegate_impl.h"
|
||||
#include "chrome/browser/speech/tts_message_filter.h"
|
||||
#endif // BUILDFLAG(ENABLE_TTS)
|
||||
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
#include "chrome/browser/printing/printing_message_filter.h"
|
||||
#include "chrome/services/printing/public/mojom/constants.mojom.h"
|
||||
#include "components/services/pdf_compositor/public/interfaces/pdf_compositor.mojom.h"
|
||||
#endif // BUILDFLAG(ENABLE_PRINTING)
|
||||
|
||||
#if BUILDFLAG(ENABLE_TTS)
|
||||
#include "chrome/browser/speech/tts_message_filter.h"
|
||||
#endif // BUILDFLAG(ENABLE_TTS)
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
namespace atom {
|
||||
@@ -103,19 +119,27 @@ namespace {
|
||||
// Next navigation should not restart renderer process.
|
||||
bool g_suppress_renderer_process_restart = false;
|
||||
|
||||
// Custom schemes to be registered to handle service worker.
|
||||
base::NoDestructor<std::string> g_custom_service_worker_schemes;
|
||||
|
||||
bool IsSameWebSite(content::BrowserContext* browser_context,
|
||||
const GURL& src_url,
|
||||
content::SiteInstance* site_instance,
|
||||
const GURL& dest_url) {
|
||||
return content::SiteInstance::IsSameWebSite(browser_context, src_url,
|
||||
dest_url) ||
|
||||
// `IsSameWebSite` doesn't seem to work for some URIs such as `file:`,
|
||||
// handle these scenarios by comparing only the site as defined by
|
||||
// `GetSiteForURL`.
|
||||
content::SiteInstance::GetSiteForURL(browser_context, dest_url) ==
|
||||
src_url;
|
||||
return site_instance->IsSameSiteWithURL(dest_url) ||
|
||||
// `IsSameSiteWithURL` doesn't seem to work for some URIs such as
|
||||
// `file:`, handle these scenarios by comparing only the site as
|
||||
// defined by `GetSiteForURL`.
|
||||
(content::SiteInstance::GetSiteForURL(browser_context, dest_url) ==
|
||||
site_instance->GetSiteURL());
|
||||
}
|
||||
|
||||
AtomBrowserClient* g_browser_client = nullptr;
|
||||
|
||||
base::LazyInstance<std::string>::DestructorAtExit
|
||||
g_io_thread_application_locale = LAZY_INSTANCE_INITIALIZER;
|
||||
|
||||
base::NoDestructor<std::string> g_application_locale;
|
||||
|
||||
void SetApplicationLocaleOnIOThread(const std::string& locale) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||
g_io_thread_application_locale.Get() = locale;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -125,19 +149,35 @@ void AtomBrowserClient::SuppressRendererProcessRestartForOnce() {
|
||||
g_suppress_renderer_process_restart = true;
|
||||
}
|
||||
|
||||
void AtomBrowserClient::SetCustomServiceWorkerSchemes(
|
||||
const std::vector<std::string>& schemes) {
|
||||
*g_custom_service_worker_schemes = base::JoinString(schemes, ",");
|
||||
AtomBrowserClient* AtomBrowserClient::Get() {
|
||||
return g_browser_client;
|
||||
}
|
||||
|
||||
AtomBrowserClient::AtomBrowserClient() {}
|
||||
// static
|
||||
void AtomBrowserClient::SetApplicationLocale(const std::string& locale) {
|
||||
if (!BrowserThread::IsThreadInitialized(BrowserThread::IO) ||
|
||||
!base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&SetApplicationLocaleOnIOThread, locale))) {
|
||||
g_io_thread_application_locale.Get() = locale;
|
||||
}
|
||||
*g_application_locale = locale;
|
||||
}
|
||||
|
||||
AtomBrowserClient::~AtomBrowserClient() {}
|
||||
AtomBrowserClient::AtomBrowserClient() {
|
||||
DCHECK(!g_browser_client);
|
||||
g_browser_client = this;
|
||||
}
|
||||
|
||||
AtomBrowserClient::~AtomBrowserClient() {
|
||||
DCHECK(g_browser_client);
|
||||
g_browser_client = nullptr;
|
||||
}
|
||||
|
||||
content::WebContents* AtomBrowserClient::GetWebContentsFromProcessID(
|
||||
int process_id) {
|
||||
// If the process is a pending process, we should use the web contents
|
||||
// for the frame host passed into OverrideSiteInstanceForNavigation.
|
||||
// for the frame host passed into RegisterPendingProcess.
|
||||
if (base::ContainsKey(pending_processes_, process_id))
|
||||
return pending_processes_[process_id];
|
||||
|
||||
@@ -146,25 +186,37 @@ content::WebContents* AtomBrowserClient::GetWebContentsFromProcessID(
|
||||
return WebContentsPreferences::GetWebContentsFromProcessID(process_id);
|
||||
}
|
||||
|
||||
bool AtomBrowserClient::ShouldCreateNewSiteInstance(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
bool AtomBrowserClient::ShouldForceNewSiteInstance(
|
||||
content::RenderFrameHost* current_rfh,
|
||||
content::RenderFrameHost* speculative_rfh,
|
||||
content::BrowserContext* browser_context,
|
||||
content::SiteInstance* current_instance,
|
||||
const GURL& url) {
|
||||
const GURL& url,
|
||||
bool has_response_started) const {
|
||||
if (url.SchemeIs(url::kJavaScriptScheme))
|
||||
// "javacript:" scheme should always use same SiteInstance
|
||||
return false;
|
||||
|
||||
content::SiteInstance* current_instance = current_rfh->GetSiteInstance();
|
||||
content::SiteInstance* speculative_instance =
|
||||
speculative_rfh ? speculative_rfh->GetSiteInstance() : nullptr;
|
||||
int process_id = current_instance->GetProcess()->GetID();
|
||||
if (!IsRendererSandboxed(process_id)) {
|
||||
if (!RendererUsesNativeWindowOpen(process_id)) {
|
||||
// non-sandboxed renderers without native window.open should always create
|
||||
// a new SiteInstance
|
||||
return true;
|
||||
}
|
||||
auto* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
if (!ChildWebContentsTracker::IsChildWebContents(web_contents)) {
|
||||
if (NavigationWasRedirectedCrossSite(browser_context, current_instance,
|
||||
speculative_instance, url,
|
||||
has_response_started)) {
|
||||
// Navigation was redirected. We can't force the current, speculative or a
|
||||
// new unrelated site instance to be used. Delegate to the content layer.
|
||||
return false;
|
||||
} else if (IsRendererSandboxed(process_id)) {
|
||||
// Renderer is sandboxed, delegate the decision to the content layer for all
|
||||
// origins.
|
||||
return false;
|
||||
} else if (!RendererUsesNativeWindowOpen(process_id)) {
|
||||
// non-sandboxed renderers without native window.open should always create
|
||||
// a new SiteInstance
|
||||
return true;
|
||||
} else {
|
||||
auto* web_contents = content::WebContents::FromRenderFrameHost(current_rfh);
|
||||
if (!ChildWebContentsTracker::FromWebContents(web_contents)) {
|
||||
// Root WebContents should always create new process to make sure
|
||||
// native addons are loaded correctly after reload / navigation.
|
||||
// (Non-root WebContents opened by window.open() should try to
|
||||
@@ -174,8 +226,26 @@ bool AtomBrowserClient::ShouldCreateNewSiteInstance(
|
||||
}
|
||||
|
||||
// Create new a SiteInstance if navigating to a different site.
|
||||
auto src_url = current_instance->GetSiteURL();
|
||||
return !IsSameWebSite(browser_context, src_url, url);
|
||||
return !IsSameWebSite(browser_context, current_instance, url);
|
||||
}
|
||||
|
||||
bool AtomBrowserClient::NavigationWasRedirectedCrossSite(
|
||||
content::BrowserContext* browser_context,
|
||||
content::SiteInstance* current_instance,
|
||||
content::SiteInstance* speculative_instance,
|
||||
const GURL& dest_url,
|
||||
bool has_response_started) const {
|
||||
bool navigation_was_redirected = false;
|
||||
if (has_response_started) {
|
||||
navigation_was_redirected =
|
||||
!IsSameWebSite(browser_context, current_instance, dest_url);
|
||||
} else {
|
||||
navigation_was_redirected =
|
||||
speculative_instance &&
|
||||
!IsSameWebSite(browser_context, speculative_instance, dest_url);
|
||||
}
|
||||
|
||||
return navigation_was_redirected;
|
||||
}
|
||||
|
||||
void AtomBrowserClient::AddProcessPreferences(
|
||||
@@ -190,29 +260,69 @@ void AtomBrowserClient::RemoveProcessPreferences(int process_id) {
|
||||
process_preferences_.erase(process_id);
|
||||
}
|
||||
|
||||
bool AtomBrowserClient::IsProcessObserved(int process_id) {
|
||||
bool AtomBrowserClient::IsProcessObserved(int process_id) const {
|
||||
base::AutoLock auto_lock(process_preferences_lock_);
|
||||
return process_preferences_.find(process_id) != process_preferences_.end();
|
||||
}
|
||||
|
||||
bool AtomBrowserClient::IsRendererSandboxed(int process_id) {
|
||||
bool AtomBrowserClient::IsRendererSandboxed(int process_id) const {
|
||||
base::AutoLock auto_lock(process_preferences_lock_);
|
||||
auto it = process_preferences_.find(process_id);
|
||||
return it != process_preferences_.end() && it->second.sandbox;
|
||||
}
|
||||
|
||||
bool AtomBrowserClient::RendererUsesNativeWindowOpen(int process_id) {
|
||||
bool AtomBrowserClient::RendererUsesNativeWindowOpen(int process_id) const {
|
||||
base::AutoLock auto_lock(process_preferences_lock_);
|
||||
auto it = process_preferences_.find(process_id);
|
||||
return it != process_preferences_.end() && it->second.native_window_open;
|
||||
}
|
||||
|
||||
bool AtomBrowserClient::RendererDisablesPopups(int process_id) {
|
||||
bool AtomBrowserClient::RendererDisablesPopups(int process_id) const {
|
||||
base::AutoLock auto_lock(process_preferences_lock_);
|
||||
auto it = process_preferences_.find(process_id);
|
||||
return it != process_preferences_.end() && it->second.disable_popups;
|
||||
}
|
||||
|
||||
std::string AtomBrowserClient::GetAffinityPreference(
|
||||
content::RenderFrameHost* rfh) const {
|
||||
auto* web_contents = content::WebContents::FromRenderFrameHost(rfh);
|
||||
auto* web_preferences = WebContentsPreferences::From(web_contents);
|
||||
std::string affinity;
|
||||
if (web_preferences &&
|
||||
web_preferences->GetPreference("affinity", &affinity) &&
|
||||
!affinity.empty()) {
|
||||
affinity = base::ToLowerASCII(affinity);
|
||||
}
|
||||
|
||||
return affinity;
|
||||
}
|
||||
|
||||
content::SiteInstance* AtomBrowserClient::GetSiteInstanceFromAffinity(
|
||||
content::BrowserContext* browser_context,
|
||||
const GURL& url,
|
||||
content::RenderFrameHost* rfh) const {
|
||||
std::string affinity = GetAffinityPreference(rfh);
|
||||
if (!affinity.empty()) {
|
||||
auto iter = site_per_affinities_.find(affinity);
|
||||
GURL dest_site = content::SiteInstance::GetSiteForURL(browser_context, url);
|
||||
if (iter != site_per_affinities_.end() &&
|
||||
IsSameWebSite(browser_context, iter->second, dest_site)) {
|
||||
return iter->second;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void AtomBrowserClient::ConsiderSiteInstanceForAffinity(
|
||||
content::RenderFrameHost* rfh,
|
||||
content::SiteInstance* site_instance) {
|
||||
std::string affinity = GetAffinityPreference(rfh);
|
||||
if (!affinity.empty()) {
|
||||
site_per_affinities_[affinity] = site_instance;
|
||||
}
|
||||
}
|
||||
|
||||
void AtomBrowserClient::RenderProcessWillLaunch(
|
||||
content::RenderProcessHost* host,
|
||||
service_manager::mojom::ServiceRequest* service_request) {
|
||||
@@ -251,6 +361,14 @@ AtomBrowserClient::CreateSpeechRecognitionManagerDelegate() {
|
||||
return new AtomSpeechRecognitionManagerDelegate;
|
||||
}
|
||||
|
||||
content::TtsControllerDelegate* AtomBrowserClient::GetTtsControllerDelegate() {
|
||||
#if BUILDFLAG(ENABLE_TTS)
|
||||
return TtsControllerDelegateImpl::GetInstance();
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
void AtomBrowserClient::OverrideWebkitPrefs(content::RenderViewHost* host,
|
||||
content::WebPreferences* prefs) {
|
||||
prefs->javascript_enabled = true;
|
||||
@@ -271,6 +389,8 @@ void AtomBrowserClient::OverrideWebkitPrefs(content::RenderViewHost* host,
|
||||
prefs->default_maximum_page_scale_factor = 1.f;
|
||||
prefs->navigate_on_drag_drop = false;
|
||||
|
||||
SetFontDefaults(prefs);
|
||||
|
||||
// Custom preferences of guest page.
|
||||
auto* web_contents = content::WebContents::FromRenderViewHost(host);
|
||||
auto* web_preferences = WebContentsPreferences::From(web_contents);
|
||||
@@ -278,62 +398,59 @@ void AtomBrowserClient::OverrideWebkitPrefs(content::RenderViewHost* host,
|
||||
web_preferences->OverrideWebkitPrefs(prefs);
|
||||
}
|
||||
|
||||
void AtomBrowserClient::OverrideSiteInstanceForNavigation(
|
||||
content::RenderFrameHost* rfh,
|
||||
content::ContentBrowserClient::SiteInstanceForNavigationType
|
||||
AtomBrowserClient::ShouldOverrideSiteInstanceForNavigation(
|
||||
content::RenderFrameHost* current_rfh,
|
||||
content::RenderFrameHost* speculative_rfh,
|
||||
content::BrowserContext* browser_context,
|
||||
const GURL& url,
|
||||
bool has_request_started,
|
||||
content::SiteInstance* candidate_instance,
|
||||
content::SiteInstance** new_instance) {
|
||||
bool has_response_started,
|
||||
content::SiteInstance** affinity_site_instance) const {
|
||||
if (g_suppress_renderer_process_restart) {
|
||||
g_suppress_renderer_process_restart = false;
|
||||
return;
|
||||
return SiteInstanceForNavigationType::ASK_CHROMIUM;
|
||||
}
|
||||
|
||||
content::SiteInstance* current_instance = rfh->GetSiteInstance();
|
||||
if (!ShouldCreateNewSiteInstance(rfh, browser_context, current_instance, url))
|
||||
return;
|
||||
|
||||
// Do we have an affinity site to manage ?
|
||||
auto* web_contents = content::WebContents::FromRenderFrameHost(rfh);
|
||||
auto* web_preferences = WebContentsPreferences::From(web_contents);
|
||||
std::string affinity;
|
||||
if (web_preferences &&
|
||||
web_preferences->GetPreference("affinity", &affinity) &&
|
||||
!affinity.empty()) {
|
||||
affinity = base::ToLowerASCII(affinity);
|
||||
auto iter = site_per_affinities.find(affinity);
|
||||
GURL dest_site = content::SiteInstance::GetSiteForURL(browser_context, url);
|
||||
if (iter != site_per_affinities.end() &&
|
||||
IsSameWebSite(browser_context, iter->second->GetSiteURL(), dest_site)) {
|
||||
*new_instance = iter->second;
|
||||
} else {
|
||||
site_per_affinities[affinity] = candidate_instance;
|
||||
*new_instance = candidate_instance;
|
||||
// Remember the original web contents for the pending renderer process.
|
||||
auto* pending_process = candidate_instance->GetProcess();
|
||||
pending_processes_[pending_process->GetID()] = web_contents;
|
||||
}
|
||||
} else {
|
||||
// OverrideSiteInstanceForNavigation will be called more than once during a
|
||||
// navigation (currently twice, on request and when it's about to commit in
|
||||
// the renderer), look at RenderFrameHostManager::GetFrameHostForNavigation.
|
||||
// In the default mode we should resuse the same site instance until the
|
||||
// request commits otherwise it will get destroyed. Currently there is no
|
||||
// unique lifetime tracker for a navigation request during site instance
|
||||
// creation. We check for the state of the request, which should be one of
|
||||
// (WAITING_FOR_RENDERER_RESPONSE, STARTED, RESPONSE_STARTED, FAILED) along
|
||||
// with the availability of a speculative render frame host.
|
||||
if (has_request_started) {
|
||||
*new_instance = current_instance;
|
||||
return;
|
||||
}
|
||||
|
||||
*new_instance = candidate_instance;
|
||||
// Remember the original web contents for the pending renderer process.
|
||||
auto* pending_process = candidate_instance->GetProcess();
|
||||
pending_processes_[pending_process->GetID()] = web_contents;
|
||||
content::SiteInstance* site_instance_from_affinity =
|
||||
GetSiteInstanceFromAffinity(browser_context, url, current_rfh);
|
||||
if (site_instance_from_affinity) {
|
||||
*affinity_site_instance = site_instance_from_affinity;
|
||||
return SiteInstanceForNavigationType::FORCE_AFFINITY;
|
||||
}
|
||||
|
||||
if (!ShouldForceNewSiteInstance(current_rfh, speculative_rfh, browser_context,
|
||||
url, has_response_started)) {
|
||||
return SiteInstanceForNavigationType::ASK_CHROMIUM;
|
||||
}
|
||||
|
||||
// ShouldOverrideSiteInstanceForNavigation will be called more than once
|
||||
// during a navigation (currently twice, on request and when it's about
|
||||
// to commit in the renderer), look at
|
||||
// RenderFrameHostManager::GetFrameHostForNavigation.
|
||||
// In the default mode we should reuse the same site instance until the
|
||||
// request commits otherwise it will get destroyed. Currently there is no
|
||||
// unique lifetime tracker for a navigation request during site instance
|
||||
// creation. We check for the state of the request, which should be one of
|
||||
// (WAITING_FOR_RENDERER_RESPONSE, STARTED, RESPONSE_STARTED, FAILED) along
|
||||
// with the availability of a speculative render frame host.
|
||||
if (has_response_started) {
|
||||
return SiteInstanceForNavigationType::FORCE_CURRENT;
|
||||
}
|
||||
|
||||
return SiteInstanceForNavigationType::FORCE_CANDIDATE_OR_NEW;
|
||||
}
|
||||
|
||||
void AtomBrowserClient::RegisterPendingSiteInstance(
|
||||
content::RenderFrameHost* rfh,
|
||||
content::SiteInstance* pending_site_instance) {
|
||||
// Do we have an affinity site to manage?
|
||||
ConsiderSiteInstanceForAffinity(rfh, pending_site_instance);
|
||||
|
||||
// Remember the original web contents for the pending renderer process.
|
||||
auto* web_contents = content::WebContents::FromRenderFrameHost(rfh);
|
||||
auto* pending_process = pending_site_instance->GetProcess();
|
||||
pending_processes_[pending_process->GetID()] = web_contents;
|
||||
}
|
||||
|
||||
void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
||||
@@ -354,17 +471,14 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
||||
return;
|
||||
|
||||
// Copy following switches to child process.
|
||||
static const char* const kCommonSwitchNames[] = {switches::kStandardSchemes,
|
||||
switches::kEnableSandbox,
|
||||
switches::kSecureSchemes};
|
||||
static const char* const kCommonSwitchNames[] = {
|
||||
switches::kStandardSchemes, switches::kEnableSandbox,
|
||||
switches::kSecureSchemes, switches::kBypassCSPSchemes,
|
||||
switches::kCORSSchemes, switches::kFetchSchemes,
|
||||
switches::kServiceWorkerSchemes};
|
||||
command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
|
||||
kCommonSwitchNames,
|
||||
arraysize(kCommonSwitchNames));
|
||||
|
||||
// The registered service worker schemes.
|
||||
if (!g_custom_service_worker_schemes->empty())
|
||||
command_line->AppendSwitchASCII(switches::kRegisterServiceWorkerSchemes,
|
||||
*g_custom_service_worker_schemes);
|
||||
base::size(kCommonSwitchNames));
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Append --app-user-model-id.
|
||||
@@ -382,6 +496,16 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
||||
|
||||
content::WebContents* web_contents = GetWebContentsFromProcessID(process_id);
|
||||
if (web_contents) {
|
||||
// devtools processes must be launched unsandboxed in order for the remote
|
||||
// API to work in devtools extensions. This is due to the fact that the
|
||||
// remote API assumes that it will only be used from the main frame, but
|
||||
// devtools extensions are loaded from an iframe.
|
||||
// It would be possible to sandbox devtools extensions processes by default
|
||||
// if we made the remote API work with multiple frames.
|
||||
if (web_contents->GetVisibleURL().SchemeIs("chrome-devtools")) {
|
||||
command_line->AppendSwitch(service_manager::switches::kNoSandbox);
|
||||
command_line->AppendSwitch(::switches::kNoZygote);
|
||||
}
|
||||
auto* web_preferences = WebContentsPreferences::From(web_contents);
|
||||
if (web_preferences)
|
||||
web_preferences->AppendCommandLineSwitches(command_line);
|
||||
@@ -390,6 +514,16 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
||||
}
|
||||
}
|
||||
|
||||
void AtomBrowserClient::AdjustUtilityServiceProcessCommandLine(
|
||||
const service_manager::Identity& identity,
|
||||
base::CommandLine* command_line) {
|
||||
#if defined(OS_MACOSX)
|
||||
if (identity.name() == video_capture::mojom::kServiceName ||
|
||||
identity.name() == audio::mojom::kServiceName)
|
||||
command_line->AppendSwitch(::switches::kMessageLoopTypeUi);
|
||||
#endif
|
||||
}
|
||||
|
||||
void AtomBrowserClient::DidCreatePpapiPlugin(content::BrowserPpapiHost* host) {
|
||||
#if BUILDFLAG(ENABLE_PEPPER_FLASH)
|
||||
host->GetPpapiHost()->AddHostFactoryFilter(
|
||||
@@ -397,11 +531,11 @@ void AtomBrowserClient::DidCreatePpapiPlugin(content::BrowserPpapiHost* host) {
|
||||
#endif
|
||||
}
|
||||
|
||||
// attempt to get api key from env
|
||||
std::string AtomBrowserClient::GetGeolocationApiKey() {
|
||||
std::unique_ptr<base::Environment> env(base::Environment::Create());
|
||||
std::string api_key;
|
||||
if (!env->GetVar("GOOGLE_API_KEY", &api_key))
|
||||
api_key = GOOGLEAPIS_API_KEY;
|
||||
env->GetVar("GOOGLE_API_KEY", &api_key);
|
||||
return api_key;
|
||||
}
|
||||
|
||||
@@ -410,6 +544,17 @@ AtomBrowserClient::CreateQuotaPermissionContext() {
|
||||
return new AtomQuotaPermissionContext;
|
||||
}
|
||||
|
||||
content::GeneratedCodeCacheSettings
|
||||
AtomBrowserClient::GetGeneratedCodeCacheSettings(
|
||||
content::BrowserContext* context) {
|
||||
// TODO(deepak1556): Use platform cache directory.
|
||||
base::FilePath cache_path = context->GetPath();
|
||||
// If we pass 0 for size, disk_cache will pick a default size using the
|
||||
// heuristics based on available disk size. These are implemented in
|
||||
// disk_cache::PreferredCacheSize in net/disk_cache/cache_util.cc.
|
||||
return content::GeneratedCodeCacheSettings(true, 0, cache_path);
|
||||
}
|
||||
|
||||
void AtomBrowserClient::AllowCertificateError(
|
||||
content::WebContents* web_contents,
|
||||
int cert_error,
|
||||
@@ -450,7 +595,7 @@ bool AtomBrowserClient::CanCreateWindow(
|
||||
content::RenderFrameHost* opener,
|
||||
const GURL& opener_url,
|
||||
const GURL& opener_top_level_frame_url,
|
||||
const GURL& source_origin,
|
||||
const url::Origin& source_origin,
|
||||
content::mojom::WindowContainerType container_type,
|
||||
const GURL& target_url,
|
||||
const content::Referrer& referrer,
|
||||
@@ -502,14 +647,19 @@ void AtomBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
|
||||
additional_schemes->push_back(content::kChromeDevToolsScheme);
|
||||
}
|
||||
|
||||
void AtomBrowserClient::GetAdditionalWebUISchemes(
|
||||
std::vector<std::string>* additional_schemes) {
|
||||
additional_schemes->push_back(content::kChromeDevToolsScheme);
|
||||
}
|
||||
|
||||
void AtomBrowserClient::SiteInstanceDeleting(
|
||||
content::SiteInstance* site_instance) {
|
||||
// We are storing weak_ptr, is it fundamental to maintain the map up-to-date
|
||||
// when an instance is destroyed.
|
||||
for (auto iter = site_per_affinities.begin();
|
||||
iter != site_per_affinities.end(); ++iter) {
|
||||
for (auto iter = site_per_affinities_.begin();
|
||||
iter != site_per_affinities_.end(); ++iter) {
|
||||
if (iter->second == site_instance) {
|
||||
site_per_affinities.erase(iter);
|
||||
site_per_affinities_.erase(iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -564,27 +714,24 @@ void AtomBrowserClient::RegisterOutOfProcessServices(
|
||||
#endif
|
||||
}
|
||||
|
||||
std::unique_ptr<base::Value> AtomBrowserClient::GetServiceManifestOverlay(
|
||||
base::StringPiece name) {
|
||||
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
|
||||
int id = -1;
|
||||
if (name == content::mojom::kBrowserServiceName)
|
||||
id = IDR_ELECTRON_CONTENT_BROWSER_MANIFEST_OVERLAY;
|
||||
else if (name == content::mojom::kPackagedServicesServiceName)
|
||||
id = IDR_ELECTRON_CONTENT_PACKAGED_SERVICES_MANIFEST_OVERLAY;
|
||||
base::Optional<service_manager::Manifest>
|
||||
AtomBrowserClient::GetServiceManifestOverlay(base::StringPiece name) {
|
||||
if (name == content::mojom::kBrowserServiceName) {
|
||||
return GetElectronContentBrowserOverlayManifest();
|
||||
} else if (name == content::mojom::kPackagedServicesServiceName) {
|
||||
service_manager::Manifest overlay;
|
||||
overlay.packaged_services = GetElectronPackagedServicesOverlayManifest();
|
||||
return overlay;
|
||||
}
|
||||
|
||||
if (id == -1)
|
||||
return nullptr;
|
||||
|
||||
base::StringPiece manifest_contents = rb.GetRawDataResource(id);
|
||||
return base::JSONReader::Read(manifest_contents);
|
||||
return base::nullopt;
|
||||
}
|
||||
|
||||
net::NetLog* AtomBrowserClient::GetNetLog() {
|
||||
return AtomBrowserMainParts::Get()->net_log();
|
||||
return g_browser_process->net_log();
|
||||
}
|
||||
|
||||
brightray::BrowserMainParts* AtomBrowserClient::OverrideCreateBrowserMainParts(
|
||||
content::BrowserMainParts* AtomBrowserClient::CreateBrowserMainParts(
|
||||
const content::MainFunctionParams& params) {
|
||||
return new AtomBrowserMainParts(params);
|
||||
}
|
||||
@@ -673,9 +820,11 @@ bool AtomBrowserClient::HandleExternalProtocol(
|
||||
content::NavigationUIData* navigation_data,
|
||||
bool is_main_frame,
|
||||
ui::PageTransition page_transition,
|
||||
bool has_user_gesture) {
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::UI, FROM_HERE,
|
||||
bool has_user_gesture,
|
||||
const std::string& method,
|
||||
const net::HttpRequestHeaders& headers) {
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::UI},
|
||||
base::BindOnce(&HandleExternalProtocolInUI, url, web_contents_getter,
|
||||
has_user_gesture));
|
||||
return true;
|
||||
@@ -689,11 +838,78 @@ AtomBrowserClient::CreateThrottlesForNavigation(
|
||||
return throttles;
|
||||
}
|
||||
|
||||
bool AtomBrowserClient::ShouldBypassCORB(int render_process_id) {
|
||||
content::MediaObserver* AtomBrowserClient::GetMediaObserver() {
|
||||
return MediaCaptureDevicesDispatcher::GetInstance();
|
||||
}
|
||||
|
||||
content::DevToolsManagerDelegate*
|
||||
AtomBrowserClient::GetDevToolsManagerDelegate() {
|
||||
return new DevToolsManagerDelegate;
|
||||
}
|
||||
|
||||
NotificationPresenter* AtomBrowserClient::GetNotificationPresenter() {
|
||||
if (!notification_presenter_) {
|
||||
notification_presenter_.reset(NotificationPresenter::Create());
|
||||
}
|
||||
return notification_presenter_.get();
|
||||
}
|
||||
|
||||
content::PlatformNotificationService*
|
||||
AtomBrowserClient::GetPlatformNotificationService() {
|
||||
if (!notification_service_) {
|
||||
notification_service_.reset(new PlatformNotificationService(this));
|
||||
}
|
||||
return notification_service_.get();
|
||||
}
|
||||
|
||||
base::FilePath AtomBrowserClient::GetDefaultDownloadDirectory() {
|
||||
// ~/Downloads
|
||||
base::FilePath path;
|
||||
if (base::PathService::Get(base::DIR_HOME, &path))
|
||||
path = path.Append(FILE_PATH_LITERAL("Downloads"));
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
scoped_refptr<network::SharedURLLoaderFactory>
|
||||
AtomBrowserClient::GetSystemSharedURLLoaderFactory() {
|
||||
if (!g_browser_process)
|
||||
return nullptr;
|
||||
return g_browser_process->shared_url_loader_factory();
|
||||
}
|
||||
|
||||
void AtomBrowserClient::OnNetworkServiceCreated(
|
||||
network::mojom::NetworkService* network_service) {
|
||||
if (!g_browser_process)
|
||||
return;
|
||||
g_browser_process->system_network_context_manager()->OnNetworkServiceCreated(
|
||||
network_service);
|
||||
}
|
||||
|
||||
bool AtomBrowserClient::ShouldBypassCORB(int render_process_id) const {
|
||||
// This is called on the network thread.
|
||||
base::AutoLock auto_lock(process_preferences_lock_);
|
||||
auto it = process_preferences_.find(render_process_id);
|
||||
return it != process_preferences_.end() && !it->second.web_security;
|
||||
}
|
||||
|
||||
std::string AtomBrowserClient::GetProduct() const {
|
||||
return "Chrome/" CHROME_VERSION_STRING;
|
||||
}
|
||||
|
||||
std::string AtomBrowserClient::GetUserAgent() const {
|
||||
return GetApplicationUserAgent();
|
||||
}
|
||||
|
||||
std::string AtomBrowserClient::GetApplicationLocale() {
|
||||
if (BrowserThread::CurrentlyOn(BrowserThread::IO))
|
||||
return g_io_thread_application_locale.Get();
|
||||
return *g_application_locale;
|
||||
}
|
||||
|
||||
bool AtomBrowserClient::ShouldEnableStrictSiteIsolation() {
|
||||
// Enable site isolation. It is off by default in Chromium <= 69.
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "base/synchronization/lock.h"
|
||||
#include "brightray/browser/browser_client.h"
|
||||
#include "content/public/browser/content_browser_client.h"
|
||||
#include "content/public/browser/render_process_host_observer.h"
|
||||
#include "net/ssl/client_cert_identity.h"
|
||||
@@ -29,10 +28,15 @@ class SSLCertRequestInfo;
|
||||
namespace atom {
|
||||
|
||||
class AtomResourceDispatcherHostDelegate;
|
||||
class NotificationPresenter;
|
||||
class PlatformNotificationService;
|
||||
|
||||
class AtomBrowserClient : public brightray::BrowserClient,
|
||||
class AtomBrowserClient : public content::ContentBrowserClient,
|
||||
public content::RenderProcessHostObserver {
|
||||
public:
|
||||
static AtomBrowserClient* Get();
|
||||
static void SetApplicationLocale(const std::string& locale);
|
||||
|
||||
AtomBrowserClient();
|
||||
~AtomBrowserClient() override;
|
||||
|
||||
@@ -45,34 +49,50 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
// Don't force renderer process to restart for once.
|
||||
static void SuppressRendererProcessRestartForOnce();
|
||||
|
||||
// Custom schemes to be registered to handle service worker.
|
||||
static void SetCustomServiceWorkerSchemes(
|
||||
const std::vector<std::string>& schemes);
|
||||
NotificationPresenter* GetNotificationPresenter();
|
||||
|
||||
void WebNotificationAllowed(int render_process_id,
|
||||
const base::Callback<void(bool, bool)>& callback);
|
||||
|
||||
// content::NavigatorDelegate
|
||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
||||
CreateThrottlesForNavigation(content::NavigationHandle* handle) override;
|
||||
|
||||
protected:
|
||||
// content::ContentBrowserClient:
|
||||
std::string GetApplicationLocale() override;
|
||||
|
||||
// content::ContentBrowserClient:
|
||||
bool ShouldEnableStrictSiteIsolation() override;
|
||||
|
||||
protected:
|
||||
void RenderProcessWillLaunch(
|
||||
content::RenderProcessHost* host,
|
||||
service_manager::mojom::ServiceRequest* service_request) override;
|
||||
content::SpeechRecognitionManagerDelegate*
|
||||
CreateSpeechRecognitionManagerDelegate() override;
|
||||
content::TtsControllerDelegate* GetTtsControllerDelegate() override;
|
||||
void OverrideWebkitPrefs(content::RenderViewHost* render_view_host,
|
||||
content::WebPreferences* prefs) override;
|
||||
void OverrideSiteInstanceForNavigation(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
SiteInstanceForNavigationType ShouldOverrideSiteInstanceForNavigation(
|
||||
content::RenderFrameHost* current_rfh,
|
||||
content::RenderFrameHost* speculative_rfh,
|
||||
content::BrowserContext* browser_context,
|
||||
const GURL& dest_url,
|
||||
const GURL& url,
|
||||
bool has_request_started,
|
||||
content::SiteInstance* candidate_instance,
|
||||
content::SiteInstance** new_instance) override;
|
||||
content::SiteInstance** affinity_site_instance) const override;
|
||||
void RegisterPendingSiteInstance(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
content::SiteInstance* pending_site_instance) override;
|
||||
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
|
||||
int child_process_id) override;
|
||||
void AdjustUtilityServiceProcessCommandLine(
|
||||
const service_manager::Identity& identity,
|
||||
base::CommandLine* command_line) override;
|
||||
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
|
||||
std::string GetGeolocationApiKey() override;
|
||||
content::QuotaPermissionContext* CreateQuotaPermissionContext() override;
|
||||
content::GeneratedCodeCacheSettings GetGeneratedCodeCacheSettings(
|
||||
content::BrowserContext* context) override;
|
||||
void AllowCertificateError(
|
||||
content::WebContents* web_contents,
|
||||
int cert_error,
|
||||
@@ -92,7 +112,7 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
bool CanCreateWindow(content::RenderFrameHost* opener,
|
||||
const GURL& opener_url,
|
||||
const GURL& opener_top_level_frame_url,
|
||||
const GURL& source_origin,
|
||||
const url::Origin& source_origin,
|
||||
content::mojom::WindowContainerType container_type,
|
||||
const GURL& target_url,
|
||||
const content::Referrer& referrer,
|
||||
@@ -105,7 +125,9 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
bool opener_suppressed,
|
||||
bool* no_javascript_access) override;
|
||||
void GetAdditionalAllowedSchemesForFileSystem(
|
||||
std::vector<std::string>* schemes) override;
|
||||
std::vector<std::string>* additional_schemes) override;
|
||||
void GetAdditionalWebUISchemes(
|
||||
std::vector<std::string>* additional_schemes) override;
|
||||
void SiteInstanceDeleting(content::SiteInstance* site_instance) override;
|
||||
std::unique_ptr<net::ClientCertStore> CreateClientCertStore(
|
||||
content::ResourceContext* resource_context) override;
|
||||
@@ -116,17 +138,23 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
bool in_memory,
|
||||
const base::FilePath& relative_partition_path) override;
|
||||
void RegisterOutOfProcessServices(OutOfProcessServiceMap* services) override;
|
||||
std::unique_ptr<base::Value> GetServiceManifestOverlay(
|
||||
base::Optional<service_manager::Manifest> GetServiceManifestOverlay(
|
||||
base::StringPiece name) override;
|
||||
net::NetLog* GetNetLog() override;
|
||||
|
||||
// brightray::BrowserClient:
|
||||
brightray::BrowserMainParts* OverrideCreateBrowserMainParts(
|
||||
content::MediaObserver* GetMediaObserver() override;
|
||||
content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
|
||||
content::PlatformNotificationService* GetPlatformNotificationService()
|
||||
override;
|
||||
content::BrowserMainParts* CreateBrowserMainParts(
|
||||
const content::MainFunctionParams&) override;
|
||||
void WebNotificationAllowed(
|
||||
int render_process_id,
|
||||
const base::Callback<void(bool, bool)>& callback) override;
|
||||
bool ShouldBypassCORB(int render_process_id) override;
|
||||
base::FilePath GetDefaultDownloadDirectory() override;
|
||||
scoped_refptr<network::SharedURLLoaderFactory>
|
||||
GetSystemSharedURLLoaderFactory() override;
|
||||
void OnNetworkServiceCreated(
|
||||
network::mojom::NetworkService* network_service) override;
|
||||
bool ShouldBypassCORB(int render_process_id) const override;
|
||||
std::string GetProduct() const override;
|
||||
std::string GetUserAgent() const override;
|
||||
|
||||
// content::RenderProcessHostObserver:
|
||||
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
||||
@@ -141,7 +169,9 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
content::NavigationUIData* navigation_data,
|
||||
bool is_main_frame,
|
||||
ui::PageTransition page_transition,
|
||||
bool has_user_gesture) override;
|
||||
bool has_user_gesture,
|
||||
const std::string& method,
|
||||
const net::HttpRequestHeaders& headers) override;
|
||||
|
||||
private:
|
||||
struct ProcessPreferences {
|
||||
@@ -151,16 +181,30 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
bool web_security = true;
|
||||
};
|
||||
|
||||
bool ShouldCreateNewSiteInstance(content::RenderFrameHost* render_frame_host,
|
||||
content::BrowserContext* browser_context,
|
||||
content::SiteInstance* current_instance,
|
||||
const GURL& dest_url);
|
||||
bool ShouldForceNewSiteInstance(content::RenderFrameHost* current_rfh,
|
||||
content::RenderFrameHost* speculative_rfh,
|
||||
content::BrowserContext* browser_context,
|
||||
const GURL& dest_url,
|
||||
bool has_request_started) const;
|
||||
bool NavigationWasRedirectedCrossSite(
|
||||
content::BrowserContext* browser_context,
|
||||
content::SiteInstance* current_instance,
|
||||
content::SiteInstance* speculative_instance,
|
||||
const GURL& dest_url,
|
||||
bool has_request_started) const;
|
||||
void AddProcessPreferences(int process_id, ProcessPreferences prefs);
|
||||
void RemoveProcessPreferences(int process_id);
|
||||
bool IsProcessObserved(int process_id);
|
||||
bool IsRendererSandboxed(int process_id);
|
||||
bool RendererUsesNativeWindowOpen(int process_id);
|
||||
bool RendererDisablesPopups(int process_id);
|
||||
bool IsProcessObserved(int process_id) const;
|
||||
bool IsRendererSandboxed(int process_id) const;
|
||||
bool RendererUsesNativeWindowOpen(int process_id) const;
|
||||
bool RendererDisablesPopups(int process_id) const;
|
||||
std::string GetAffinityPreference(content::RenderFrameHost* rfh) const;
|
||||
content::SiteInstance* GetSiteInstanceFromAffinity(
|
||||
content::BrowserContext* browser_context,
|
||||
const GURL& url,
|
||||
content::RenderFrameHost* rfh) const;
|
||||
void ConsiderSiteInstanceForAffinity(content::RenderFrameHost* rfh,
|
||||
content::SiteInstance* site_instance);
|
||||
|
||||
// pending_render_process => web contents.
|
||||
std::map<int, content::WebContents*> pending_processes_;
|
||||
@@ -168,14 +212,17 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
std::map<int, base::ProcessId> render_process_host_pids_;
|
||||
|
||||
// list of site per affinity. weak_ptr to prevent instance locking
|
||||
std::map<std::string, content::SiteInstance*> site_per_affinities;
|
||||
std::map<std::string, content::SiteInstance*> site_per_affinities_;
|
||||
|
||||
std::unique_ptr<AtomResourceDispatcherHostDelegate>
|
||||
resource_dispatcher_host_delegate_;
|
||||
|
||||
std::unique_ptr<PlatformNotificationService> notification_service_;
|
||||
std::unique_ptr<NotificationPresenter> notification_presenter_;
|
||||
|
||||
Delegate* delegate_ = nullptr;
|
||||
|
||||
base::Lock process_preferences_lock_;
|
||||
mutable base::Lock process_preferences_lock_;
|
||||
std::map<int, ProcessPreferences> process_preferences_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomBrowserClient);
|
||||
|
||||
@@ -6,31 +6,26 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "atom/app/atom_content_client.h"
|
||||
#include "atom/browser/atom_blob_reader.h"
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
#include "atom/browser/atom_download_manager_delegate.h"
|
||||
#include "atom/browser/atom_paths.h"
|
||||
#include "atom/browser/atom_permission_manager.h"
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/browser/cookie_change_notifier.h"
|
||||
#include "atom/browser/net/resolve_proxy_helper.h"
|
||||
#include "atom/browser/pref_store_delegate.h"
|
||||
#include "atom/browser/special_storage_policy.h"
|
||||
#include "atom/browser/ui/inspectable_web_contents_impl.h"
|
||||
#include "atom/browser/web_view_manager.h"
|
||||
#include "atom/common/atom_version.h"
|
||||
#include "atom/common/chrome_version.h"
|
||||
#include "atom/browser/zoom_level_delegate.h"
|
||||
#include "atom/common/application_info.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/threading/sequenced_task_runner_handle.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "brightray/browser/brightray_paths.h"
|
||||
#include "brightray/browser/inspectable_web_contents_impl.h"
|
||||
#include "brightray/browser/zoom_level_delegate.h"
|
||||
#include "brightray/common/application_info.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "components/keyed_service/content/browser_context_dependency_manager.h"
|
||||
@@ -42,9 +37,8 @@
|
||||
#include "components/proxy_config/pref_proxy_config_tracker_impl.h"
|
||||
#include "components/proxy_config/proxy_config_pref_names.h"
|
||||
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
#include "content/public/common/content_client.h"
|
||||
#include "content/public/common/user_agent.h"
|
||||
#include "net/base/escape.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
@@ -72,9 +66,7 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition,
|
||||
storage_policy_(new SpecialStoragePolicy),
|
||||
in_memory_(in_memory),
|
||||
weak_factory_(this) {
|
||||
AtomContentClient* client =
|
||||
static_cast<AtomContentClient*>(content::GetContentClient());
|
||||
user_agent_ = client->GetUserAgent();
|
||||
user_agent_ = GetApplicationUserAgent();
|
||||
|
||||
// Read options.
|
||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
@@ -84,11 +76,10 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition,
|
||||
base::StringToInt(command_line->GetSwitchValueASCII(switches::kDiskCacheSize),
|
||||
&max_cache_size_);
|
||||
|
||||
if (!base::PathService::Get(brightray::DIR_USER_DATA, &path_)) {
|
||||
base::PathService::Get(brightray::DIR_APP_DATA, &path_);
|
||||
path_ = path_.Append(
|
||||
base::FilePath::FromUTF8Unsafe(brightray::GetApplicationName()));
|
||||
base::PathService::Override(brightray::DIR_USER_DATA, path_);
|
||||
if (!base::PathService::Get(DIR_USER_DATA, &path_)) {
|
||||
base::PathService::Get(DIR_APP_DATA, &path_);
|
||||
path_ = path_.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName()));
|
||||
base::PathService::Override(DIR_USER_DATA, path_);
|
||||
}
|
||||
|
||||
if (!in_memory && !partition.empty())
|
||||
@@ -136,9 +127,9 @@ void AtomBrowserContext::InitPrefs() {
|
||||
registry->RegisterFilePathPref(prefs::kDownloadDefaultDirectory,
|
||||
download_dir);
|
||||
registry->RegisterDictionaryPref(prefs::kDevToolsFileSystemPaths);
|
||||
brightray::InspectableWebContentsImpl::RegisterPrefs(registry.get());
|
||||
brightray::MediaDeviceIDSalt::RegisterPrefs(registry.get());
|
||||
brightray::ZoomLevelDelegate::RegisterPrefs(registry.get());
|
||||
InspectableWebContentsImpl::RegisterPrefs(registry.get());
|
||||
MediaDeviceIDSalt::RegisterPrefs(registry.get());
|
||||
ZoomLevelDelegate::RegisterPrefs(registry.get());
|
||||
PrefProxyConfigTrackerImpl::RegisterPrefs(registry.get());
|
||||
|
||||
prefs_ = prefs_factory.Create(
|
||||
@@ -194,7 +185,7 @@ content::ResourceContext* AtomBrowserContext::GetResourceContext() {
|
||||
|
||||
std::string AtomBrowserContext::GetMediaDeviceIDSalt() {
|
||||
if (!media_device_id_salt_.get())
|
||||
media_device_id_salt_.reset(new brightray::MediaDeviceIDSalt(prefs_.get()));
|
||||
media_device_id_salt_.reset(new MediaDeviceIDSalt(prefs_.get()));
|
||||
return media_device_id_salt_->GetSalt();
|
||||
}
|
||||
|
||||
@@ -202,8 +193,7 @@ std::unique_ptr<content::ZoomLevelDelegate>
|
||||
AtomBrowserContext::CreateZoomLevelDelegate(
|
||||
const base::FilePath& partition_path) {
|
||||
if (!IsOffTheRecord()) {
|
||||
return std::make_unique<brightray::ZoomLevelDelegate>(prefs(),
|
||||
partition_path);
|
||||
return std::make_unique<ZoomLevelDelegate>(prefs(), partition_path);
|
||||
}
|
||||
return std::unique_ptr<content::ZoomLevelDelegate>();
|
||||
}
|
||||
@@ -271,6 +261,11 @@ AtomBrowserContext::GetBrowsingDataRemoverDelegate() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
content::ClientHintsControllerDelegate*
|
||||
AtomBrowserContext::GetClientHintsControllerDelegate() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter*
|
||||
AtomBrowserContext::CreateRequestContextForStoragePartition(
|
||||
const base::FilePath& partition_path,
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/media/media_device_id_salt.h"
|
||||
#include "atom/browser/net/url_request_context_getter.h"
|
||||
#include "base/memory/ref_counted_delete_on_sequence.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "brightray/browser/media/media_device_id_salt.h"
|
||||
#include "chrome/browser/net/proxy_config_monitor.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
|
||||
@@ -88,6 +88,8 @@ class AtomBrowserContext
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors) override;
|
||||
net::URLRequestContextGetter* CreateMediaRequestContext() override;
|
||||
content::ClientHintsControllerDelegate* GetClientHintsControllerDelegate()
|
||||
override;
|
||||
|
||||
CookieChangeNotifier* cookie_change_notifier() const {
|
||||
return cookie_change_notifier_.get();
|
||||
@@ -152,7 +154,7 @@ class AtomBrowserContext
|
||||
std::unique_ptr<WebViewManager> guest_manager_;
|
||||
std::unique_ptr<AtomPermissionManager> permission_manager_;
|
||||
std::unique_ptr<AtomBlobReader> blob_reader_;
|
||||
std::unique_ptr<brightray::MediaDeviceIDSalt> media_device_id_salt_;
|
||||
std::unique_ptr<MediaDeviceIDSalt> media_device_id_salt_;
|
||||
scoped_refptr<ResolveProxyHelper> resolve_proxy_helper_;
|
||||
scoped_refptr<storage::SpecialStoragePolicy> storage_policy_;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user