mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
Compare commits
875 Commits
1-8-x
...
v2.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
afcbb589b6 | ||
|
|
4159103467 | ||
|
|
2a97e48465 | ||
|
|
b4ae41b484 | ||
|
|
e3d4358068 | ||
|
|
89d5e4a2f0 | ||
|
|
c3dbba00a6 | ||
|
|
77b8c81096 | ||
|
|
0ef8f1bdad | ||
|
|
f7ec346e9f | ||
|
|
6f2609f9d2 | ||
|
|
772a69e24a | ||
|
|
193febd18c | ||
|
|
719e5a93b4 | ||
|
|
f59d078eea | ||
|
|
c2575c4944 | ||
|
|
9c56b81b71 | ||
|
|
5a25b88b50 | ||
|
|
21de806c80 | ||
|
|
708f39a1a5 | ||
|
|
dcaff20cfd | ||
|
|
35e90f742b | ||
|
|
846be03f1d | ||
|
|
7bcccdec41 | ||
|
|
5065e159f1 | ||
|
|
6a3fde6e20 | ||
|
|
8d086a43cb | ||
|
|
ba933ef085 | ||
|
|
dc62e51ba4 | ||
|
|
fb7fb4972d | ||
|
|
e1b81b8a62 | ||
|
|
8d4bf3e29a | ||
|
|
a2856db982 | ||
|
|
57738e6981 | ||
|
|
98ba120ae2 | ||
|
|
211b542ae4 | ||
|
|
2a16b28be4 | ||
|
|
e4e20d667b | ||
|
|
1a3661206e | ||
|
|
fc025064f7 | ||
|
|
56f06187d5 | ||
|
|
73ab87b87f | ||
|
|
6e11a3e53d | ||
|
|
459a5e3a1f | ||
|
|
35faab89a4 | ||
|
|
af82b2037e | ||
|
|
8375d21cae | ||
|
|
9c52d273dd | ||
|
|
cd9e7142e4 | ||
|
|
d31d2087a3 | ||
|
|
56859531cd | ||
|
|
fbce7bafd7 | ||
|
|
e3efe4b378 | ||
|
|
ac57c7625a | ||
|
|
55d4d74624 | ||
|
|
2a46a63833 | ||
|
|
f3415c04cd | ||
|
|
01a6104727 | ||
|
|
bc76f35691 | ||
|
|
78ccfa0612 | ||
|
|
67fa13d7cf | ||
|
|
a20b379f26 | ||
|
|
549042160f | ||
|
|
f84b8bbfdc | ||
|
|
5e7a5ce3a9 | ||
|
|
d30310a2f2 | ||
|
|
b0469702ad | ||
|
|
4774f32065 | ||
|
|
c8e64ff870 | ||
|
|
381ed2e2b2 | ||
|
|
af92b04eb9 | ||
|
|
fdda1c55c5 | ||
|
|
6318cd781d | ||
|
|
7e2f7602c1 | ||
|
|
6f0080be4c | ||
|
|
31b074ff0e | ||
|
|
c3d11a51cc | ||
|
|
402201ac39 | ||
|
|
f8b7145c6b | ||
|
|
8a84bd8d19 | ||
|
|
a55fd06aa2 | ||
|
|
eba9abdbe5 | ||
|
|
affa21600c | ||
|
|
2b623f5d86 | ||
|
|
9c1b47361f | ||
|
|
8d55334016 | ||
|
|
546bd6da5e | ||
|
|
4ed5bb9901 | ||
|
|
9bd7d53cf8 | ||
|
|
12a8d90ef0 | ||
|
|
181169b743 | ||
|
|
baced3152f | ||
|
|
ae65938752 | ||
|
|
d1d50a4c92 | ||
|
|
9f78ef0179 | ||
|
|
01dcddef35 | ||
|
|
b3234f634b | ||
|
|
66b57858b8 | ||
|
|
6943ada7e8 | ||
|
|
e6ac2637d3 | ||
|
|
fae71f9987 | ||
|
|
8987828ecd | ||
|
|
533dfc42a8 | ||
|
|
31e0bc02ba | ||
|
|
069c6187cf | ||
|
|
e19e2b9242 | ||
|
|
647f0f3a57 | ||
|
|
36cf548114 | ||
|
|
1657c37761 | ||
|
|
e3b70dd029 | ||
|
|
d05791c1ac | ||
|
|
bf11b09d35 | ||
|
|
69e65e0d5e | ||
|
|
0b7a629a41 | ||
|
|
75b990faff | ||
|
|
1e1087abbb | ||
|
|
31baafab3b | ||
|
|
3ee3e9a3e8 | ||
|
|
09d51f0a3d | ||
|
|
844ee0a3f4 | ||
|
|
38d284590f | ||
|
|
29f9929703 | ||
|
|
0d4c6e327f | ||
|
|
be118d4f13 | ||
|
|
5818353ebc | ||
|
|
3085c78bcf | ||
|
|
5194288fce | ||
|
|
3710e0e38b | ||
|
|
4b766d26df | ||
|
|
3f5ce6d74f | ||
|
|
b107d3f440 | ||
|
|
ffff400236 | ||
|
|
647d04cf92 | ||
|
|
e5eeab6e29 | ||
|
|
0fff336481 | ||
|
|
efb44050db | ||
|
|
8b9b1e5595 | ||
|
|
1e090b9ee7 | ||
|
|
f6d389b159 | ||
|
|
e10b5e13e9 | ||
|
|
1018cdc225 | ||
|
|
ca34978e73 | ||
|
|
e3f1d90854 | ||
|
|
4ab13d9e90 | ||
|
|
e869c27041 | ||
|
|
6c6fa3190f | ||
|
|
64f509ea7a | ||
|
|
5b901d9f82 | ||
|
|
6fd5b168bc | ||
|
|
4685c46b04 | ||
|
|
a0e584efeb | ||
|
|
3f6d2eb3ab | ||
|
|
80aa399f8a | ||
|
|
131aa38768 | ||
|
|
faf08b2b77 | ||
|
|
ae632193c0 | ||
|
|
8c2c7c3634 | ||
|
|
3c64062f69 | ||
|
|
97589bbe33 | ||
|
|
5240352326 | ||
|
|
e6a5990b95 | ||
|
|
e924781ee5 | ||
|
|
42fa018277 | ||
|
|
8ac52b418b | ||
|
|
9676c0a4f9 | ||
|
|
1c43768104 | ||
|
|
87c2f0f14f | ||
|
|
5f7a173d1d | ||
|
|
72464a6db5 | ||
|
|
ab015e573b | ||
|
|
9337959f51 | ||
|
|
983e1b1a70 | ||
|
|
c470e758cc | ||
|
|
109e2c760f | ||
|
|
8ae3d9dd0b | ||
|
|
e0e7dd2a8f | ||
|
|
176c03fa15 | ||
|
|
f0e210360f | ||
|
|
45763c0afb | ||
|
|
df6328e5d7 | ||
|
|
56b53e71aa | ||
|
|
28d96e2d29 | ||
|
|
732af93fc9 | ||
|
|
d586ef2f39 | ||
|
|
62d2a3472f | ||
|
|
bd06abd523 | ||
|
|
a033a9cd5d | ||
|
|
e411b49f4e | ||
|
|
6cf0c56eaf | ||
|
|
714838d65e | ||
|
|
1545a95782 | ||
|
|
ce969c9326 | ||
|
|
be7e46b3fe | ||
|
|
495c6dcff5 | ||
|
|
e51c78f10c | ||
|
|
db6d84de74 | ||
|
|
b32a7d4cb4 | ||
|
|
77dcddf157 | ||
|
|
9d0d83a002 | ||
|
|
45119845e8 | ||
|
|
311c0873db | ||
|
|
1184eca581 | ||
|
|
1106cde687 | ||
|
|
09a2c80443 | ||
|
|
8405fe763e | ||
|
|
ce361a12e3 | ||
|
|
b74304145e | ||
|
|
b49a284ccf | ||
|
|
278c58055e | ||
|
|
7e9131d82b | ||
|
|
67196bdd3e | ||
|
|
f24eab74d8 | ||
|
|
93dc38a17b | ||
|
|
d8d19baad3 | ||
|
|
1e1729adad | ||
|
|
aea06ed95f | ||
|
|
8f685e9329 | ||
|
|
8804b09188 | ||
|
|
536ff0b7e2 | ||
|
|
fb8606dd0c | ||
|
|
c4dc8dacbf | ||
|
|
4cb22dd2ff | ||
|
|
cdb20d2692 | ||
|
|
7e79ae750f | ||
|
|
39e0efd9a4 | ||
|
|
e73f142adc | ||
|
|
5418866e87 | ||
|
|
c793ee3aeb | ||
|
|
a5c900ac7a | ||
|
|
12d4f984f3 | ||
|
|
f790c24c27 | ||
|
|
d67c64b6fa | ||
|
|
2db125890c | ||
|
|
601fbc8731 | ||
|
|
c886803d0f | ||
|
|
a9dd4c927d | ||
|
|
30581f78a2 | ||
|
|
3d032c2b57 | ||
|
|
3679a9c37a | ||
|
|
e81265bc7f | ||
|
|
e345342e36 | ||
|
|
bef4c84799 | ||
|
|
3399480304 | ||
|
|
b0a1575bb7 | ||
|
|
e3383c82d1 | ||
|
|
1ab92f7866 | ||
|
|
690a9e9483 | ||
|
|
004c9427eb | ||
|
|
df3d94b20d | ||
|
|
d172e29270 | ||
|
|
406f171c88 | ||
|
|
1a8916ed47 | ||
|
|
099bbfbafb | ||
|
|
304fd49e84 | ||
|
|
708cde92cf | ||
|
|
17d85318c3 | ||
|
|
b5d5eca224 | ||
|
|
b9c0bab8f1 | ||
|
|
0207aebad1 | ||
|
|
868e792572 | ||
|
|
19a5ebce66 | ||
|
|
4757980f9c | ||
|
|
50690d25f1 | ||
|
|
39554566cc | ||
|
|
c49cb29ddf | ||
|
|
32a1395bcf | ||
|
|
365fe6b067 | ||
|
|
8a4c76d655 | ||
|
|
2b4cc0a525 | ||
|
|
d0af17e601 | ||
|
|
8387d92cd5 | ||
|
|
f36fda3f5d | ||
|
|
8d8b8c590d | ||
|
|
5e198d9dc6 | ||
|
|
8233890e39 | ||
|
|
c6c618acdb | ||
|
|
ae65c26469 | ||
|
|
8253e50e9c | ||
|
|
ea1da93e5e | ||
|
|
565946cdff | ||
|
|
4f0e1826e5 | ||
|
|
4dab824c6b | ||
|
|
ea2056b513 | ||
|
|
7aefc73ffd | ||
|
|
28f1abcb05 | ||
|
|
d69c17a96a | ||
|
|
b45ce8ff2d | ||
|
|
a6d3dee321 | ||
|
|
74769da9a7 | ||
|
|
fa43cb6ef0 | ||
|
|
f5962538f4 | ||
|
|
fce84fbe99 | ||
|
|
bd271cffb9 | ||
|
|
a883d3d50d | ||
|
|
839df0ee5a | ||
|
|
6d9c6645a8 | ||
|
|
e77ddd3221 | ||
|
|
2dd545ebda | ||
|
|
635b753ecd | ||
|
|
133bef3deb | ||
|
|
ac6f895f64 | ||
|
|
400bfb3c5a | ||
|
|
bdeb979d41 | ||
|
|
5f1c76c688 | ||
|
|
b2542a27c3 | ||
|
|
d32632f768 | ||
|
|
eb2520488f | ||
|
|
329fddaed1 | ||
|
|
f3ae566164 | ||
|
|
143816bee1 | ||
|
|
5504294a6a | ||
|
|
8df4402722 | ||
|
|
638d8219c4 | ||
|
|
9c018744f4 | ||
|
|
83b351a8fd | ||
|
|
49844b6e5b | ||
|
|
b3743058c0 | ||
|
|
c1d68974ab | ||
|
|
f201969f12 | ||
|
|
4298aecb7c | ||
|
|
4e328a2a08 | ||
|
|
33da3153b6 | ||
|
|
c272a18204 | ||
|
|
aeffef766a | ||
|
|
435c9c1486 | ||
|
|
eb89e12c5b | ||
|
|
6bc7c8cc49 | ||
|
|
9bd192ea17 | ||
|
|
df841fa397 | ||
|
|
1553b54779 | ||
|
|
1ff872519c | ||
|
|
1072c75e38 | ||
|
|
fb78052b3d | ||
|
|
104585e772 | ||
|
|
952928dc79 | ||
|
|
0cce6b3d21 | ||
|
|
d6068759b6 | ||
|
|
0ea296b1cb | ||
|
|
14de22a8c7 | ||
|
|
cbc433d4cb | ||
|
|
de93b30d3c | ||
|
|
82452e7924 | ||
|
|
7bf156d197 | ||
|
|
7b9dd81018 | ||
|
|
b9ace16959 | ||
|
|
769fbd0d3b | ||
|
|
1b30cac372 | ||
|
|
1043f07b42 | ||
|
|
237bd6790b | ||
|
|
abe1faea5c | ||
|
|
e3a56240c9 | ||
|
|
fd297722a8 | ||
|
|
73919ea91a | ||
|
|
d27744f455 | ||
|
|
0df464e16a | ||
|
|
ee80313666 | ||
|
|
d29c27dc78 | ||
|
|
e072213923 | ||
|
|
a1592446da | ||
|
|
1912fbb073 | ||
|
|
69bd44edbb | ||
|
|
ebb0e46380 | ||
|
|
b2cef31bc0 | ||
|
|
6d9b186fa7 | ||
|
|
e30131f30b | ||
|
|
88e53b1b5e | ||
|
|
c3154d86e0 | ||
|
|
1d95241185 | ||
|
|
90acb22a58 | ||
|
|
a518c5c3c4 | ||
|
|
fedf1d889b | ||
|
|
db156865e7 | ||
|
|
b4e6516ad8 | ||
|
|
5c25855ac5 | ||
|
|
249bd41e11 | ||
|
|
99e26b8318 | ||
|
|
d04ae88426 | ||
|
|
bc61f2eafa | ||
|
|
46330ac2a9 | ||
|
|
73d78d345a | ||
|
|
2ec3b8ce76 | ||
|
|
c3eadd5b63 | ||
|
|
9c6aa9ce90 | ||
|
|
7b01a8b860 | ||
|
|
2e3d940749 | ||
|
|
d7bc127c60 | ||
|
|
46121da765 | ||
|
|
b8ec84c761 | ||
|
|
e9121936e8 | ||
|
|
5f4b62b6c8 | ||
|
|
d45914c3f7 | ||
|
|
a161f6e368 | ||
|
|
e45a125f65 | ||
|
|
75ac7d9ff2 | ||
|
|
0cafc3cf52 | ||
|
|
fe16e24406 | ||
|
|
f2e32791b1 | ||
|
|
c0c2461245 | ||
|
|
00afeaba9a | ||
|
|
a0ebde0181 | ||
|
|
5aac091f40 | ||
|
|
65871cd567 | ||
|
|
06e1fb923b | ||
|
|
7a8864063b | ||
|
|
088042841d | ||
|
|
459db92052 | ||
|
|
05bd5f456a | ||
|
|
d3eeb84208 | ||
|
|
06481b5630 | ||
|
|
a6228b97cd | ||
|
|
e4770c7604 | ||
|
|
83d2917363 | ||
|
|
5bf16c2495 | ||
|
|
ef7357dedc | ||
|
|
14b65467d8 | ||
|
|
bcef6eb3df | ||
|
|
c586806609 | ||
|
|
85ef42d99e | ||
|
|
0d9ff95526 | ||
|
|
fdcac8552f | ||
|
|
d5ab691fdb | ||
|
|
5a9221e1dc | ||
|
|
5ccfac81ed | ||
|
|
b2e6340622 | ||
|
|
4fd8b04329 | ||
|
|
4d7b85bd01 | ||
|
|
98e9311669 | ||
|
|
39ec40b901 | ||
|
|
19f2d42c07 | ||
|
|
d36e451301 | ||
|
|
0521302940 | ||
|
|
4f533dded3 | ||
|
|
2f88e69ed4 | ||
|
|
8373e1bf41 | ||
|
|
58edfc26ed | ||
|
|
30f8660a20 | ||
|
|
cab1b81026 | ||
|
|
f5f6d99cd7 | ||
|
|
589c6a5b7e | ||
|
|
512fb670b4 | ||
|
|
b6c16a520a | ||
|
|
6f4e97c53a | ||
|
|
781311aa3c | ||
|
|
c15e2e4d92 | ||
|
|
5d86da48c7 | ||
|
|
4dee778212 | ||
|
|
8953042ee3 | ||
|
|
90582dfa4f | ||
|
|
81527b71ba | ||
|
|
a02cb8009e | ||
|
|
b27e42f3f7 | ||
|
|
ae7b96991c | ||
|
|
389edb6229 | ||
|
|
f74f113d23 | ||
|
|
936d8c1117 | ||
|
|
f01cbf0482 | ||
|
|
55db062242 | ||
|
|
6198bbe963 | ||
|
|
a6bab71215 | ||
|
|
b8231b74f2 | ||
|
|
789dbb2dbb | ||
|
|
605f5472e5 | ||
|
|
ac2caef37f | ||
|
|
75cdd9ec70 | ||
|
|
8a8aaaf16c | ||
|
|
76d9756fb9 | ||
|
|
a4db8e1c55 | ||
|
|
a8b76e1a80 | ||
|
|
5a35a5a2b3 | ||
|
|
26ad37c4d1 | ||
|
|
3fc844c15a | ||
|
|
61ec8df418 | ||
|
|
0ad99444af | ||
|
|
ef7c5c8e9c | ||
|
|
d602a30bbc | ||
|
|
057f08a1f8 | ||
|
|
debe77a910 | ||
|
|
5b6b5fe835 | ||
|
|
996c914912 | ||
|
|
ffd85bfaac | ||
|
|
317422f431 | ||
|
|
8166a64f98 | ||
|
|
c4ec8b4545 | ||
|
|
76df41b5d0 | ||
|
|
ace558f54a | ||
|
|
5b7f7c8a1a | ||
|
|
ffc54967e9 | ||
|
|
5a658fa5f6 | ||
|
|
99031834ff | ||
|
|
3719ee0b53 | ||
|
|
9e660b1d32 | ||
|
|
4f901c6d24 | ||
|
|
6252ce466c | ||
|
|
8b447b9291 | ||
|
|
5720a8e7d5 | ||
|
|
da4af4c90b | ||
|
|
1c8eb03574 | ||
|
|
1caa04c0bf | ||
|
|
19f1fef040 | ||
|
|
e73fe100d5 | ||
|
|
76ee1e1cb6 | ||
|
|
99c980ab40 | ||
|
|
a8e67e7f61 | ||
|
|
927c63b477 | ||
|
|
89b90be6a2 | ||
|
|
dcf2a6f388 | ||
|
|
f7ebfff8ae | ||
|
|
dfd7598d48 | ||
|
|
22e9d665d2 | ||
|
|
93b46116f4 | ||
|
|
c8bb23a2ff | ||
|
|
027e78639a | ||
|
|
84bab48627 | ||
|
|
765f223fef | ||
|
|
87f8bd4ea7 | ||
|
|
c5aeda1fdd | ||
|
|
5e51ab9791 | ||
|
|
9a40bbd082 | ||
|
|
8a24733ee6 | ||
|
|
becabdfff2 | ||
|
|
18ee34f1a1 | ||
|
|
1ccad4a7e9 | ||
|
|
f82086e6d3 | ||
|
|
725f6c97d6 | ||
|
|
abd56eda6f | ||
|
|
955564abd7 | ||
|
|
bd6767fac6 | ||
|
|
38bb9baac5 | ||
|
|
6af18895c3 | ||
|
|
de1edeea0b | ||
|
|
079310ab5a | ||
|
|
9314d8925e | ||
|
|
7faec8e5eb | ||
|
|
6a29577ab3 | ||
|
|
0f54e56389 | ||
|
|
fe0f203312 | ||
|
|
f10c279322 | ||
|
|
63c91e7dd3 | ||
|
|
276f758560 | ||
|
|
24f60dcd1b | ||
|
|
16d96a6ef2 | ||
|
|
19de41b764 | ||
|
|
5fa29fcf58 | ||
|
|
69c6a68c22 | ||
|
|
61937eac0a | ||
|
|
fa09ff3cbb | ||
|
|
84c207750c | ||
|
|
af756e2441 | ||
|
|
8efeb4b71a | ||
|
|
78fd6d6435 | ||
|
|
4e3e9c9dbc | ||
|
|
d8368d36db | ||
|
|
7a73b1d523 | ||
|
|
4355f554cc | ||
|
|
da66e34dce | ||
|
|
d8610a3f56 | ||
|
|
46f79146ad | ||
|
|
9c109daa4b | ||
|
|
bd4c7a114a | ||
|
|
1e0a181f4b | ||
|
|
032f5ebc6f | ||
|
|
4878cd8d5d | ||
|
|
4101059323 | ||
|
|
770778f9a2 | ||
|
|
85b1cd08d3 | ||
|
|
bf043c92af | ||
|
|
e6cbb2f3aa | ||
|
|
8eed8bdee7 | ||
|
|
7598e31b16 | ||
|
|
e59aa715fd | ||
|
|
1bce00545d | ||
|
|
07a5d7957b | ||
|
|
b65b939d18 | ||
|
|
06371a6082 | ||
|
|
d519bfc5fb | ||
|
|
997f3f31d2 | ||
|
|
e77751aab5 | ||
|
|
60634cac42 | ||
|
|
f2da3e9a14 | ||
|
|
dfd98e3428 | ||
|
|
897712359f | ||
|
|
95cb601f2b | ||
|
|
24b3ee3a4a | ||
|
|
cb3a9c69ab | ||
|
|
776e8afa2b | ||
|
|
eaa4b71c24 | ||
|
|
009459bd38 | ||
|
|
e535ba4808 | ||
|
|
d1aded2831 | ||
|
|
d9359d8b6c | ||
|
|
d2707315e6 | ||
|
|
3b80ee0655 | ||
|
|
448ccc261d | ||
|
|
0ddd078aaf | ||
|
|
d598aa1a67 | ||
|
|
bdcdb6e9cf | ||
|
|
d4275b144b | ||
|
|
f62e0a4ed4 | ||
|
|
e7edc6f24f | ||
|
|
3e056eec9e | ||
|
|
1989075d54 | ||
|
|
e989005122 | ||
|
|
52c6f4bcc5 | ||
|
|
6beaafc7e5 | ||
|
|
851642f4b8 | ||
|
|
2ffcb27abe | ||
|
|
467cce6a8b | ||
|
|
ecdbe79e29 | ||
|
|
4cf6763e70 | ||
|
|
b4b729609a | ||
|
|
9646f0c99a | ||
|
|
c5abe96b39 | ||
|
|
7c8acb5ea8 | ||
|
|
f32f0fb774 | ||
|
|
ba56e5ca65 | ||
|
|
ff6596fd05 | ||
|
|
45de1e6a7c | ||
|
|
af6489576a | ||
|
|
00e8713eac | ||
|
|
7dd921811f | ||
|
|
d182bacd00 | ||
|
|
dadfbd3a4f | ||
|
|
fd7af5c1d9 | ||
|
|
7613afe6d7 | ||
|
|
8357a33d81 | ||
|
|
903a5b5100 | ||
|
|
db51dcbe7e | ||
|
|
3ab69f2358 | ||
|
|
c2ee0854f4 | ||
|
|
a48cec9b4a | ||
|
|
6d779c6ec2 | ||
|
|
88c4fd3f2b | ||
|
|
6b408de884 | ||
|
|
ea9771702b | ||
|
|
25c5938c76 | ||
|
|
580abedbb7 | ||
|
|
59476f0b30 | ||
|
|
5e4914700e | ||
|
|
0ef8f58090 | ||
|
|
aab35073ee | ||
|
|
c1728720a7 | ||
|
|
2bc8b33c2a | ||
|
|
2d75eea82a | ||
|
|
b9ed7380aa | ||
|
|
c0c983d28d | ||
|
|
04872bb001 | ||
|
|
68bceb9575 | ||
|
|
275815002f | ||
|
|
3d4ef66775 | ||
|
|
0a0d88a5dc | ||
|
|
323ea2b27b | ||
|
|
d09e8cc37f | ||
|
|
c274312a3a | ||
|
|
59607c9a17 | ||
|
|
0dc094fffc | ||
|
|
d1ebce0395 | ||
|
|
590578c187 | ||
|
|
eab3342065 | ||
|
|
c9acccaddc | ||
|
|
4ded79801f | ||
|
|
08f30e4ca6 | ||
|
|
edede7f33f | ||
|
|
a4905b3c95 | ||
|
|
e8b0897ea1 | ||
|
|
71cfb7441c | ||
|
|
7a8431086c | ||
|
|
9f89bd8d8e | ||
|
|
6a1cfafbd8 | ||
|
|
85f254316c | ||
|
|
d722d20974 | ||
|
|
1d807c552e | ||
|
|
124667c29b | ||
|
|
b161a4f515 | ||
|
|
2ad425955b | ||
|
|
18dc63ce77 | ||
|
|
2e3550b97f | ||
|
|
e24cd329d9 | ||
|
|
f8b683ca3d | ||
|
|
defa42b458 | ||
|
|
141c4e9a0e | ||
|
|
104d307a4a | ||
|
|
8fa3e71ce4 | ||
|
|
2f73f4f77e | ||
|
|
4934685f53 | ||
|
|
0c4e425872 | ||
|
|
2de7b338ad | ||
|
|
dcdc3621ac | ||
|
|
1ab4504e94 | ||
|
|
cf73fb737f | ||
|
|
3e6e327711 | ||
|
|
5d44dbaf54 | ||
|
|
828d233f2a | ||
|
|
0b9cea334f | ||
|
|
970babbfd7 | ||
|
|
8b720c120d | ||
|
|
4da2eb9366 | ||
|
|
0ba2fa5cba | ||
|
|
f0bff74995 | ||
|
|
c0e9dbcc00 | ||
|
|
1c0ea0286e | ||
|
|
295945b806 | ||
|
|
81bc0efc75 | ||
|
|
a75a85449d | ||
|
|
d1ac773e01 | ||
|
|
084292f3ab | ||
|
|
9c5acf6233 | ||
|
|
3e9f9429d1 | ||
|
|
91e4193622 | ||
|
|
df0c7e2f74 | ||
|
|
ce6af85f98 | ||
|
|
d9d2a8176e | ||
|
|
d9c7b95141 | ||
|
|
22c15082a3 | ||
|
|
6941f93627 | ||
|
|
b59557569c | ||
|
|
3e3cac6f1b | ||
|
|
00999a07d8 | ||
|
|
bd70ec5e97 | ||
|
|
1b0c1842ca | ||
|
|
ba6224039c | ||
|
|
178462b800 | ||
|
|
f91020a04d | ||
|
|
f8858a7577 | ||
|
|
c18afc924b | ||
|
|
fcc8e0924e | ||
|
|
c30faa4ee8 | ||
|
|
8e708692b8 | ||
|
|
a34d45d8c4 | ||
|
|
3138c85218 | ||
|
|
efd949ea83 | ||
|
|
d61564bfb1 | ||
|
|
c73ba5802e | ||
|
|
0b88873e77 | ||
|
|
ed4482d7a0 | ||
|
|
11f7bb34fc | ||
|
|
207150c21c | ||
|
|
1cf95d2a26 | ||
|
|
ad732b45d2 | ||
|
|
9ca658238b | ||
|
|
505f2ab9e7 | ||
|
|
214cbf357a | ||
|
|
e60557e2e6 | ||
|
|
e0860ea7a0 | ||
|
|
f3c32647af | ||
|
|
8750fde6d3 | ||
|
|
19ef7d7a48 | ||
|
|
465f9009ff | ||
|
|
82394cc06d | ||
|
|
7a9892f151 | ||
|
|
531472bad4 | ||
|
|
334b39ef1e | ||
|
|
2fa0b3d33e | ||
|
|
a0be734ccb | ||
|
|
a47497bf18 | ||
|
|
5d79dbc9a1 | ||
|
|
c9b7fc2922 | ||
|
|
e321a4a433 | ||
|
|
3a3eb69d0f | ||
|
|
69cd33395a | ||
|
|
fe9ae41f98 | ||
|
|
abcda097fb | ||
|
|
ef40bd4786 | ||
|
|
797a58bee0 | ||
|
|
1b46b5ceda | ||
|
|
a723e5a4c5 | ||
|
|
89c1b8043f | ||
|
|
9326ce8cfd | ||
|
|
6d620c24b5 | ||
|
|
4e859b4718 | ||
|
|
338604239d | ||
|
|
14eb2af876 | ||
|
|
e0d7b7d0fc | ||
|
|
93b3d8cb49 | ||
|
|
4607a1fd13 | ||
|
|
59550b203f | ||
|
|
513d4fd225 | ||
|
|
da04cbd4d8 | ||
|
|
d7e4e8d6cc | ||
|
|
7f5fbb04e2 | ||
|
|
79e59a88b4 | ||
|
|
485e43636b | ||
|
|
1073c9b1ed | ||
|
|
8c40854983 | ||
|
|
624b63a1ca | ||
|
|
3a7b3ba95e | ||
|
|
96ff534248 | ||
|
|
7a23a79b58 | ||
|
|
56e7867455 | ||
|
|
fe662ccbdc | ||
|
|
dcb9925ddd | ||
|
|
5fb0f005c5 | ||
|
|
c6333728d9 | ||
|
|
491249108e | ||
|
|
0ad967c9a5 | ||
|
|
4412836e77 | ||
|
|
59b2fb054e | ||
|
|
d817e23050 | ||
|
|
ac8c205fd7 | ||
|
|
75b41102ef | ||
|
|
a9eb0cbec0 | ||
|
|
12a4321e2b | ||
|
|
7d1c1700f8 | ||
|
|
edb7bc6572 | ||
|
|
6ba372f9f2 | ||
|
|
47d683f0ad | ||
|
|
6c7ad3ac58 | ||
|
|
b29c485ec4 | ||
|
|
933bf77a1f | ||
|
|
5a4a1a5574 | ||
|
|
f0cda8d88c | ||
|
|
4ac9659114 | ||
|
|
e4d9e12ee5 | ||
|
|
61797b7802 | ||
|
|
7608a0489c | ||
|
|
e926473e5a | ||
|
|
9566904838 | ||
|
|
5831a5ffa1 | ||
|
|
b69913975b | ||
|
|
14c61a96af | ||
|
|
fe48a92422 | ||
|
|
f694b64d71 | ||
|
|
fe431a9e58 | ||
|
|
68cbfd9f40 | ||
|
|
2c063f93ff | ||
|
|
cf00fc0661 | ||
|
|
370476c4af | ||
|
|
1127452429 | ||
|
|
a72a08bccc | ||
|
|
ea8e113b19 | ||
|
|
ea4a36039a | ||
|
|
f03ca53af5 | ||
|
|
650902c656 | ||
|
|
90b0984a14 | ||
|
|
e2a224c4e6 | ||
|
|
11fa935359 | ||
|
|
f2bcdab037 | ||
|
|
c402658c08 | ||
|
|
971002a197 | ||
|
|
fe952d5c65 | ||
|
|
ee9a547985 | ||
|
|
b81ae1c36f | ||
|
|
ba6e8b4dff | ||
|
|
b77b67bfbe | ||
|
|
364c330887 | ||
|
|
ba2f33d629 | ||
|
|
f847291272 | ||
|
|
7ad524fa34 | ||
|
|
75d02f65d9 | ||
|
|
58e0771e47 | ||
|
|
132029ea32 | ||
|
|
5315a2e8dc | ||
|
|
2bb95ce41e | ||
|
|
fed090a44c | ||
|
|
9f0df695ca | ||
|
|
0278e380de | ||
|
|
f7d6e3fa7b | ||
|
|
f81bfb7b86 | ||
|
|
97a084a591 | ||
|
|
d0ef834b4f | ||
|
|
451a44c4b5 | ||
|
|
19df1cf070 | ||
|
|
62594780e0 | ||
|
|
710ca230f3 | ||
|
|
bb5eecc16c | ||
|
|
ca76dda6a6 | ||
|
|
7a7f1ee711 | ||
|
|
5f658de19f | ||
|
|
71c16ad76f | ||
|
|
1660fc8d13 | ||
|
|
367f7f123d | ||
|
|
3e4b73ef8f | ||
|
|
df891d2aae | ||
|
|
d9481430df | ||
|
|
ada71eea39 | ||
|
|
8184cbfb06 |
@@ -3,10 +3,10 @@ version: 2
|
||||
jobs:
|
||||
electron-linux-arm:
|
||||
docker:
|
||||
- image: electronbuilds/electron:0.0.3
|
||||
- image: electronbuilds/electron:0.0.4
|
||||
environment:
|
||||
TARGET_ARCH: arm
|
||||
resource_class: xlarge
|
||||
resource_class: 2xlarge
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
@@ -58,12 +58,48 @@ jobs:
|
||||
else
|
||||
echo 'Skipping upload distribution because build is not for release'
|
||||
fi
|
||||
- run:
|
||||
name: Zip out directory
|
||||
command: |
|
||||
if [ "$ELECTRON_RELEASE" != "1" ]; then
|
||||
zip -r electron.zip out/D
|
||||
fi
|
||||
- persist_to_workspace:
|
||||
root: /home/builduser
|
||||
paths:
|
||||
- project/out
|
||||
- store_artifacts:
|
||||
path: electron.zip
|
||||
electron-linux-arm-test:
|
||||
machine: true
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: /tmp/workspace
|
||||
- checkout
|
||||
- run:
|
||||
name: Test in ARM docker container
|
||||
command: |
|
||||
if [ "$ELECTRON_RELEASE" != "1" ]; then
|
||||
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
||||
docker run -it \
|
||||
--mount type=bind,source=/tmp/workspace,target=/tmp/workspace \
|
||||
--rm electronbuilds/electronarm7:0.0.4 > version.txt
|
||||
cat version.txt
|
||||
if grep -q `script/get-version.py` version.txt; then
|
||||
echo "Versions match"
|
||||
else
|
||||
echo "Versions do not match"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Skipping test for release build"
|
||||
fi
|
||||
electron-linux-arm64:
|
||||
docker:
|
||||
- image: electronbuilds/electron:0.0.3
|
||||
- image: electronbuilds/electron:0.0.4
|
||||
environment:
|
||||
TARGET_ARCH: arm64
|
||||
resource_class: xlarge
|
||||
resource_class: 2xlarge
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
@@ -115,14 +151,54 @@ jobs:
|
||||
else
|
||||
echo 'Skipping upload distribution because build is not for release'
|
||||
fi
|
||||
- run:
|
||||
name: Zip out directory
|
||||
command: |
|
||||
if [ "$ELECTRON_RELEASE" != "1" ]; then
|
||||
zip -r electron.zip out/D
|
||||
fi
|
||||
- persist_to_workspace:
|
||||
root: /home/builduser
|
||||
paths:
|
||||
- project/out
|
||||
- store_artifacts:
|
||||
path: electron.zip
|
||||
electron-linux-arm64-test:
|
||||
machine: true
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: /tmp/workspace
|
||||
- checkout
|
||||
- run:
|
||||
name: Test in ARM64 docker container
|
||||
command: |
|
||||
if [ "$ELECTRON_RELEASE" != "1" ]; then
|
||||
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
||||
docker run -it \
|
||||
--mount type=bind,source=/tmp/workspace,target=/tmp/workspace \
|
||||
--rm electronbuilds/electronarm64:0.0.5 > version.txt
|
||||
cat version.txt
|
||||
if grep -q `script/get-version.py` version.txt; then
|
||||
echo "Versions match"
|
||||
else
|
||||
echo "Versions do not match"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Skipping test for release build"
|
||||
fi
|
||||
electron-linux-ia32:
|
||||
docker:
|
||||
- image: electronbuilds/electron:0.0.3
|
||||
- image: electronbuilds/electron:0.0.4
|
||||
environment:
|
||||
TARGET_ARCH: ia32
|
||||
DISPLAY: ':99.0'
|
||||
resource_class: xlarge
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Setup for headless testing
|
||||
command: sh -e /etc/init.d/xvfb start
|
||||
- run:
|
||||
name: Check for release
|
||||
command: |
|
||||
@@ -172,9 +248,32 @@ jobs:
|
||||
else
|
||||
echo 'Skipping upload distribution because build is not for release'
|
||||
fi
|
||||
- run:
|
||||
name: Test
|
||||
environment:
|
||||
MOCHA_FILE: junit/test-results.xml
|
||||
MOCHA_REPORTER: mocha-junit-reporter
|
||||
command: |
|
||||
if [ "$ELECTRON_RELEASE" != "1" ]; then
|
||||
echo 'Testing Electron debug build'
|
||||
out/D/electron --version
|
||||
mkdir junit
|
||||
script/test.py --ci --rebuild_native_modules
|
||||
else
|
||||
echo 'Skipping testing on release build'
|
||||
fi
|
||||
- run:
|
||||
name: Verify FFmpeg
|
||||
command: |
|
||||
if [ "$ELECTRON_RELEASE" != "1" ]; then
|
||||
echo 'Verifying ffmpeg on debug build'
|
||||
script/verify-ffmpeg.py
|
||||
else
|
||||
echo 'Skipping verify ffmpeg on release build'
|
||||
fi
|
||||
electron-linux-mips64el:
|
||||
docker:
|
||||
- image: electronbuilds/electron:0.0.3
|
||||
- image: electronbuilds/electron:0.0.4
|
||||
environment:
|
||||
TARGET_ARCH: mips64el
|
||||
resource_class: xlarge
|
||||
@@ -232,7 +331,7 @@ jobs:
|
||||
|
||||
electron-linux-x64:
|
||||
docker:
|
||||
- image: electronbuilds/electron:0.0.3
|
||||
- image: electronbuilds/electron:0.0.4
|
||||
environment:
|
||||
TARGET_ARCH: x64
|
||||
DISPLAY: ':99.0'
|
||||
@@ -330,12 +429,18 @@ workflows:
|
||||
build-arm:
|
||||
jobs:
|
||||
- electron-linux-arm
|
||||
- electron-linux-arm-test:
|
||||
requires:
|
||||
- electron-linux-arm
|
||||
build-arm64:
|
||||
jobs:
|
||||
- electron-linux-arm64
|
||||
- electron-linux-arm64-test:
|
||||
requires:
|
||||
- electron-linux-arm64
|
||||
build-ia32:
|
||||
jobs:
|
||||
- electron-linux-ia32
|
||||
build-x64:
|
||||
jobs:
|
||||
- electron-linux-x64
|
||||
jobs:
|
||||
- electron-linux-x64
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
*
|
||||
!tools/xvfb-init.sh
|
||||
!tools/run-electron.sh
|
||||
|
||||
8
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
8
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<!--
|
||||
Thank you for your Pull Request. Please provide a description above and review
|
||||
the requirements below.
|
||||
|
||||
Bug fixes and new features should include tests and possibly benchmarks.
|
||||
|
||||
Contributors guide: https://github.com/electron/electron/blob/master/CONTRIBUTING.md
|
||||
-->
|
||||
8
.github/config.yml
vendored
8
.github/config.yml
vendored
@@ -3,7 +3,7 @@
|
||||
# Comment to be posted to on first time issues
|
||||
newIssueWelcomeComment: |
|
||||
👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.
|
||||
|
||||
|
||||
To help make it easier for us to investigate your issue, please follow the [contributing guidelines](https://github.com/electron/electron/blob/master/CONTRIBUTING.md#submitting-issues).
|
||||
|
||||
# Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome
|
||||
@@ -11,7 +11,9 @@ newIssueWelcomeComment: |
|
||||
# Comment to be posted to on PRs from first time contributors in your repository
|
||||
newPRWelcomeComment: |
|
||||
💖 Thanks for opening this pull request! 💖
|
||||
|
||||
|
||||

|
||||
|
||||
Here is a list of things that will help get it across the finish line:
|
||||
- Follow the JavaScript, C++, and Python [coding style](https://github.com/electron/electron/blob/master/docs/development/coding-style.md).
|
||||
- Run `npm run lint` locally to catch formatting errors earlier.
|
||||
@@ -26,4 +28,4 @@ newPRWelcomeComment: |
|
||||
firstPRMergeComment: >
|
||||
Congrats on merging your first pull request! 🎉🎉🎉
|
||||
|
||||
# It is recommend to include as many gifs and emojis as possiblec
|
||||
# It is recommend to include as many gifs and emojis as possible
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,7 +1,7 @@
|
||||
.DS_Store
|
||||
.env
|
||||
.gclient_done
|
||||
.npmrc
|
||||
**/.npmrc
|
||||
.tags*
|
||||
.vs/
|
||||
.vscode/
|
||||
@@ -41,8 +41,8 @@
|
||||
/vendor/download/
|
||||
/vendor/llvm-build/
|
||||
/vendor/llvm/
|
||||
/vendor/node/deps/node-inspect/.npmrc
|
||||
/vendor/npm/
|
||||
/vendor/python_26/
|
||||
node_modules/
|
||||
SHASUMS256.txt
|
||||
**/package-lock.json
|
||||
|
||||
@@ -10,21 +10,15 @@ The following is a set of guidelines for contributing to Electron.
|
||||
These are just guidelines, not rules, use your best judgment and feel free to
|
||||
propose changes to this document in a pull request.
|
||||
|
||||
## Submitting Issues
|
||||
## [Issues](https://electronjs.org/docs/development/issues)
|
||||
|
||||
### Creating Issues
|
||||
* You can create an issue [here](https://github.com/electron/electron/issues/new),
|
||||
but before doing that please read the notes below and include as many details as
|
||||
possible with your report. If you can, please include:
|
||||
* The version of Electron you are using
|
||||
* The operating system you are using
|
||||
* If applicable, what you were doing when the issue arose and what you
|
||||
expected to happen
|
||||
* Other things that will help resolve your issue:
|
||||
* Screenshots and animated GIFs
|
||||
* Error output that appears in your terminal, dev tools or as an alert
|
||||
* Perform a [cursory search](https://github.com/electron/electron/issues?utf8=✓&q=is%3Aissue+)
|
||||
to see if a similar issue has already been submitted
|
||||
Issues are created [here](https://github.com/electron/electron/issues/new).
|
||||
|
||||
* [How to Contribute in Issues](https://electronjs.org/docs/development/issues#how-to-contribute-in-issues)
|
||||
* [Asking for General Help](https://electronjs.org/docs/development/issues#asking-for-general-help)
|
||||
* [Submitting a Bug Report](https://electronjs.org/docs/development/issues#submitting-a-bug-report)
|
||||
* [Triaging a Bug Report](https://electronjs.org/docs/development/issues#triaging-a-bug-report)
|
||||
* [Resolving a Bug Report](https://electronjs.org/docs/development/issues#resolving-a-bug-report)
|
||||
|
||||
### Issue Maintenance and Closure
|
||||
* If an issue is inactive for 45 days (no activity of any kind), it will be
|
||||
@@ -34,54 +28,29 @@ the issue will be closed.
|
||||
* If an issue has been closed and you still feel it's relevant, feel free to
|
||||
ping a maintainer or add a comment!
|
||||
|
||||
## [Pull Requests](https://electronjs.org/docs/development/pull-requests)
|
||||
|
||||
## Submitting Pull Requests
|
||||
Pull Requests are the way concrete changes are made to the code, documentation,
|
||||
dependencies, and tools contained in the `electron/electron` repository.
|
||||
|
||||
* Include screenshots and animated GIFs in your pull request whenever possible.
|
||||
* Follow the JavaScript, C++, and Python [coding style defined in docs](/docs/development/coding-style.md).
|
||||
* Write documentation in [Markdown](https://daringfireball.net/projects/markdown).
|
||||
See the [Documentation Styleguide](/docs/styleguide.md).
|
||||
* Use short, present tense commit messages. See [Commit Message Styleguide](#git-commit-messages).
|
||||
* [Setting up your local environment](https://electronjs.org/docs/development/pull-requests#setting-up-your-local-environment)
|
||||
* [Step 1: Fork](https://electronjs.org/docs/development/pull-requests#step-1-fork)
|
||||
* [Step 2: Build](https://electronjs.org/docs/development/pull-requests#step-2-build)
|
||||
* [Step 3: Branch](https://electronjs.org/docs/development/pull-requests#step-3-branch)
|
||||
* [The Process of Making Changes](https://electronjs.org/docs/development/pull-requests#the-process-of-making-changes)
|
||||
* [Step 4: Code](https://electronjs.org/docs/development/pull-requests#step-4-code)
|
||||
* [Step 5: Commit](https://electronjs.org/docs/development/pull-requests#step-5-commit)
|
||||
* [Commit message guidelines](https://electronjs.org/docs/development/pull-requests#commit-message-guidelines)
|
||||
* [Step 6: Rebase](https://electronjs.org/docs/development/pull-requests#step-6-rebase)
|
||||
* [Step 7: Test](https://electronjs.org/docs/development/pull-requests#step-7-test)
|
||||
* [Step 8: Push](https://electronjs.org/docs/development/pull-requests#step-8-push)
|
||||
* [Step 8: Opening the Pull Request](https://electronjs.org/docs/development/pull-requests#step-8-opening-the-pull-request)
|
||||
* [Step 9: Discuss and Update](#step-9-discuss-and-update)
|
||||
* [Approval and Request Changes Workflow](https://electronjs.org/docs/development/pull-requests#approval-and-request-changes-workflow)
|
||||
* [Step 10: Landing](https://electronjs.org/docs/development/pull-requests#step-10-landing)
|
||||
* [Continuous Integration Testing](https://electronjs.org/docs/development/pull-requests#continuous-integration-testing)
|
||||
|
||||
## Styleguides
|
||||
## Style Guides
|
||||
|
||||
### General Code
|
||||
See [Coding Style](https://electronjs.org/docs/development/coding-style) for information about which standards Electron adheres to in different parts of its codebase.
|
||||
|
||||
* End files with a newline.
|
||||
* Place requires in the following order:
|
||||
* Built in Node Modules (such as `path`)
|
||||
* Built in Electron Modules (such as `ipc`, `app`)
|
||||
* Local Modules (using relative paths)
|
||||
* Place class properties in the following order:
|
||||
* Class methods and properties (methods starting with a `@`)
|
||||
* Instance methods and properties
|
||||
* Avoid platform-dependent code:
|
||||
* Use `path.join()` to concatenate filenames.
|
||||
* Use `os.tmpdir()` rather than `/tmp` when you need to reference the
|
||||
temporary directory.
|
||||
* Using a plain `return` when returning explicitly at the end of a function.
|
||||
* Not `return null`, `return undefined`, `null`, or `undefined`
|
||||
|
||||
### Git Commit Messages
|
||||
|
||||
* Use the present tense ("Add feature" not "Added feature")
|
||||
* Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
|
||||
* Limit the first line to 72 characters or less
|
||||
* Reference issues and pull requests liberally
|
||||
* When only changing documentation, include `[ci skip]` in the commit description
|
||||
* Consider starting the commit message with an applicable emoji:
|
||||
* :art: `:art:` when improving the format/structure of the code
|
||||
* :racehorse: `:racehorse:` when improving performance
|
||||
* :non-potable_water: `:non-potable_water:` when plugging memory leaks
|
||||
* :memo: `:memo:` when writing docs
|
||||
* :penguin: `:penguin:` when fixing something on Linux
|
||||
* :apple: `:apple:` when fixing something on macOS
|
||||
* :checkered_flag: `:checkered_flag:` when fixing something on Windows
|
||||
* :bug: `:bug:` when fixing a bug
|
||||
* :fire: `:fire:` when removing code or files
|
||||
* :green_heart: `:green_heart:` when fixing the CI build
|
||||
* :white_check_mark: `:white_check_mark:` when adding tests
|
||||
* :lock: `:lock:` when dealing with security
|
||||
* :arrow_up: `:arrow_up:` when upgrading dependencies
|
||||
* :arrow_down: `:arrow_down:` when downgrading dependencies
|
||||
* :shirt: `:shirt:` when removing linter warnings
|
||||
|
||||
@@ -8,10 +8,13 @@ RUN chmod a+rwx /home
|
||||
|
||||
# Install node.js
|
||||
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
|
||||
RUN apt-get update && apt-get install -y --force-yes nodejs
|
||||
RUN apt-get update && apt-get install -y nodejs
|
||||
|
||||
# Install wget used by crash reporter
|
||||
RUN apt-get install -y --force-yes wget
|
||||
RUN apt-get install -y wget
|
||||
|
||||
# Install python-dbusmock
|
||||
RUN apt-get install -y python-dbusmock
|
||||
|
||||
# Add xvfb init script
|
||||
ADD tools/xvfb-init.sh /etc/init.d/xvfb
|
||||
|
||||
34
Dockerfile.arm64
Normal file
34
Dockerfile.arm64
Normal file
@@ -0,0 +1,34 @@
|
||||
FROM multiarch/debian-debootstrap:arm64-jessie
|
||||
|
||||
RUN apt-get update && apt-get install -y\
|
||||
bison \
|
||||
build-essential \
|
||||
clang \
|
||||
curl \
|
||||
gperf \
|
||||
libasound2 \
|
||||
libasound2-dev \
|
||||
libcap-dev \
|
||||
libcups2-dev \
|
||||
libdbus-1-dev \
|
||||
libgconf-2-4 \
|
||||
libgconf2-dev \
|
||||
libgnome-keyring-dev \
|
||||
libgtk-3-0 \
|
||||
libgtk-3-dev \
|
||||
libnotify-dev \
|
||||
libnss3 \
|
||||
libnss3-dev \
|
||||
libx11-xcb-dev \
|
||||
libxss1 \
|
||||
libxtst-dev \
|
||||
libxtst6 \
|
||||
python-dbusmock \
|
||||
wget \
|
||||
xvfb
|
||||
|
||||
ADD tools/xvfb-init.sh /etc/init.d/xvfb
|
||||
RUN chmod a+x /etc/init.d/xvfb
|
||||
ADD tools/run-electron.sh /run-electron.sh
|
||||
RUN chmod a+x /run-electron.sh
|
||||
CMD sh /run-electron.sh
|
||||
40
Dockerfile.armv7
Normal file
40
Dockerfile.armv7
Normal file
@@ -0,0 +1,40 @@
|
||||
FROM multiarch/debian-debootstrap:armhf-jessie
|
||||
|
||||
RUN apt-get update && apt-get install -y\
|
||||
bison \
|
||||
build-essential \
|
||||
clang \
|
||||
curl \
|
||||
gperf \
|
||||
libasound2 \
|
||||
libasound2-dev \
|
||||
libcap-dev \
|
||||
libcups2-dev \
|
||||
libdbus-1-dev \
|
||||
libgconf-2-4 \
|
||||
libgconf2-dev \
|
||||
libgnome-keyring-dev \
|
||||
libgtk-3-0 \
|
||||
libgtk-3-dev \
|
||||
libnotify-dev \
|
||||
libnss3 \
|
||||
libnss3-dev \
|
||||
libx11-xcb-dev \
|
||||
libxss1 \
|
||||
libxtst-dev \
|
||||
libxtst6 \
|
||||
python-dbusmock \
|
||||
git \
|
||||
wget \
|
||||
xvfb
|
||||
|
||||
# Install node.js
|
||||
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
|
||||
RUN apt-get update && apt-get install -y nodejs
|
||||
|
||||
ADD tools/xvfb-init.sh /etc/init.d/xvfb
|
||||
RUN chmod a+x /etc/init.d/xvfb
|
||||
ADD tools/run-electron.sh /run-electron.sh
|
||||
RUN chmod a+x /run-electron.sh
|
||||
|
||||
CMD sh /run-electron.sh
|
||||
@@ -4,10 +4,13 @@ USER root
|
||||
|
||||
# Install node.js
|
||||
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
|
||||
RUN apt-get update && apt-get install -y --force-yes nodejs
|
||||
RUN apt-get update && apt-get install -y nodejs
|
||||
|
||||
# Install wget used by crash reporter
|
||||
RUN apt-get install -y --force-yes wget
|
||||
RUN apt-get install -y wget
|
||||
|
||||
# Install python-dbusmock
|
||||
RUN apt-get install -y python-dbusmock
|
||||
|
||||
# Add xvfb init script
|
||||
ADD tools/xvfb-init.sh /etc/init.d/xvfb
|
||||
|
||||
20
Jenkinsfile
vendored
20
Jenkinsfile
vendored
@@ -8,10 +8,12 @@ pipeline {
|
||||
label 'osx'
|
||||
}
|
||||
steps {
|
||||
sh 'script/bootstrap.py --target_arch=x64 --dev'
|
||||
sh 'npm run lint'
|
||||
sh 'script/build.py -c D'
|
||||
sh 'script/test.py --ci --rebuild_native_modules'
|
||||
timeout(60) {
|
||||
sh 'script/bootstrap.py --target_arch=x64 --dev'
|
||||
sh 'npm run lint'
|
||||
sh 'script/build.py -c D'
|
||||
sh 'script/test.py --ci --rebuild_native_modules'
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
@@ -27,10 +29,12 @@ pipeline {
|
||||
MAS_BUILD = '1'
|
||||
}
|
||||
steps {
|
||||
sh 'script/bootstrap.py --target_arch=x64 --dev'
|
||||
sh 'npm run lint'
|
||||
sh 'script/build.py -c D'
|
||||
sh 'script/test.py --ci --rebuild_native_modules'
|
||||
timeout(60) {
|
||||
sh 'script/bootstrap.py --target_arch=x64 --dev'
|
||||
sh 'npm run lint'
|
||||
sh 'script/build.py -c D'
|
||||
sh 'script/test.py --ci --rebuild_native_modules'
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2013-2017 GitHub Inc.
|
||||
Copyright (c) 2013-2018 GitHub Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
11
README.md
11
README.md
@@ -1,7 +1,9 @@
|
||||
[](https://electronjs.org)
|
||||
|
||||
[](https://travis-ci.org/electron/electron)
|
||||
[](https://ci.appveyor.com/project/electron-bot/electron/branch/master)
|
||||
|
||||
[](https://circleci.com/gh/electron/electron/tree/master)
|
||||
[](https://windows-ci.electronjs.org/project/AppVeyor/electron/branch/master)
|
||||
[](https://mac-ci.electronjs.org/blue/organizations/jenkins/Electron%20org%2Felectron/activity?branch=master)
|
||||
[](https://david-dm.org/electron/electron?type=dev)
|
||||
[](https://atom-slack.herokuapp.com/)
|
||||
|
||||
@@ -33,10 +35,10 @@ npm install electron --save-dev --save-exact
|
||||
|
||||
The `--save-exact` flag is recommended as Electron does not follow semantic
|
||||
versioning. For info on how to manage Electron versions in your apps, see
|
||||
[Electron versioning](https://electronjs.org/docs/tutorial/electron-versioning).
|
||||
[Electron versioning](docs/tutorial/electron-versioning.md).
|
||||
|
||||
For more installation options and troubleshooting tips, see
|
||||
[installation](https://electronjs.org/docs/tutorial/installation).
|
||||
[installation](docs/tutorial/installation.md).
|
||||
|
||||
## Quick start
|
||||
|
||||
@@ -99,6 +101,7 @@ forums
|
||||
- [`electron-jp`](https://electron-jp.slack.com) *(Japanese)*
|
||||
- [`electron-tr`](https://electron-tr.herokuapp.com) *(Turkish)*
|
||||
- [`electron-id`](https://electron-id.slack.com) *(Indonesia)*
|
||||
- [`electron-pl`](https://electronpl.github.io) *(Poland)*
|
||||
|
||||
Check out [awesome-electron](https://github.com/sindresorhus/awesome-electron)
|
||||
for a community maintained list of useful example apps, tools and resources.
|
||||
|
||||
@@ -7,3 +7,6 @@ To report a security issue, email [electron@github.com](mailto:electron@github.c
|
||||
The Electron team will send a response indicating the next steps in handling your report. After the initial reply to your report, the security team will keep you informed of the progress towards a fix and full announcement, and may ask for additional information or guidance.
|
||||
|
||||
Report security bugs in third-party modules to the person or team maintaining the module. You can also report a vulnerability through the [Node Security Project](https://nodesecurity.io/report).
|
||||
|
||||
## Learning More About Security
|
||||
To learn more about securing an Electron application, please see the [security tutorial](docs/tutorial/security.md).
|
||||
|
||||
25
appveyor.yml
25
appveyor.yml
@@ -1,25 +0,0 @@
|
||||
# appveyor file
|
||||
# http://www.appveyor.com/docs/appveyor-yml
|
||||
version: "{build}"
|
||||
|
||||
os: Visual Studio 2015
|
||||
|
||||
init:
|
||||
- git config --global core.autocrlf input
|
||||
|
||||
platform:
|
||||
- x86
|
||||
- x64
|
||||
|
||||
install:
|
||||
- cmd: SET PATH=C:\Program Files (x86)\MSBuild\14.0\bin\;%PATH%
|
||||
- cmd: SET PATH=C:\python27;%PATH%
|
||||
- cmd: python script/cibuild
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
# disable build and test phases
|
||||
build: off
|
||||
test: off
|
||||
@@ -10,7 +10,7 @@
|
||||
#if defined(OS_MACOSX)
|
||||
extern "C" {
|
||||
__attribute__((visibility("default")))
|
||||
int AtomMain(int argc, const char* argv[]);
|
||||
int AtomMain(int argc, char* argv[]);
|
||||
|
||||
__attribute__((visibility("default")))
|
||||
int AtomInitializeICUandStartNode(int argc, char *argv[]);
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
#include "content/public/app/content_main.h"
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
int AtomMain(int argc, const char* argv[]) {
|
||||
int AtomMain(int argc, char* argv[]) {
|
||||
atom::AtomMainDelegate delegate;
|
||||
content::ContentMainParams params(&delegate);
|
||||
params.argc = argc;
|
||||
params.argv = argv;
|
||||
params.argv = const_cast<const char**>(argv);
|
||||
atom::AtomCommandLine::Init(argc, argv);
|
||||
return content::ContentMain(params);
|
||||
}
|
||||
|
||||
11
atom/app/atom_login_helper.mm
Normal file
11
atom/app/atom_login_helper.mm
Normal file
@@ -0,0 +1,11 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||
NSArray* pathComponents = [[[NSBundle mainBundle] bundlePath] pathComponents];
|
||||
pathComponents = [pathComponents subarrayWithRange:NSMakeRange(0, [pathComponents count] - 4)];
|
||||
NSString* path = [NSString pathWithComponents:pathComponents];
|
||||
[[NSWorkspace sharedWorkspace] launchApplication:path];
|
||||
[pool drain];
|
||||
return 0;
|
||||
}
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include "atom/app/atom_main.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
#include <vector>
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <windows.h> // windows.h must be included first
|
||||
@@ -15,9 +16,11 @@
|
||||
#include <tchar.h>
|
||||
|
||||
#include "atom/app/atom_main_delegate.h"
|
||||
#include "atom/app/command_line_args.h"
|
||||
#include "atom/common/crash_reporter/win/crash_service_main.h"
|
||||
#include "base/environment.h"
|
||||
#include "base/process/launch.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/win/windows_version.h"
|
||||
#include "content/public/app/sandbox_helper_win.h"
|
||||
#include "sandbox/win/src/sandbox_types.h"
|
||||
@@ -35,7 +38,9 @@
|
||||
|
||||
namespace {
|
||||
|
||||
#ifdef ENABLE_RUN_AS_NODE
|
||||
const auto kRunAsNode = "ELECTRON_RUN_AS_NODE";
|
||||
#endif
|
||||
|
||||
bool IsEnvSet(const char* name) {
|
||||
#if defined(OS_WIN)
|
||||
@@ -52,18 +57,23 @@ bool IsEnvSet(const char* name) {
|
||||
|
||||
#if defined(OS_WIN)
|
||||
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||
int argc = 0;
|
||||
wchar_t** wargv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
|
||||
struct Arguments {
|
||||
int argc = 0;
|
||||
wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
|
||||
|
||||
bool run_as_node = IsEnvSet(kRunAsNode);
|
||||
~Arguments() { LocalFree(argv); }
|
||||
} arguments;
|
||||
|
||||
if (!arguments.argv)
|
||||
return -1;
|
||||
|
||||
#ifdef _DEBUG
|
||||
// Don't display assert dialog boxes in CI test runs
|
||||
static const auto kCI = "ELECTRON_CI";
|
||||
bool is_ci = IsEnvSet(kCI);
|
||||
if (!is_ci) {
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
if (!_wcsicmp(wargv[i], L"--ci")) {
|
||||
for (int i = 0; i < arguments.argc; ++i) {
|
||||
if (!_wcsicmp(arguments.argv[i], L"--ci")) {
|
||||
is_ci = true;
|
||||
_putenv_s(kCI, "1"); // set flag for child processes
|
||||
break;
|
||||
@@ -81,44 +91,16 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_RUN_AS_NODE
|
||||
bool run_as_node = IsEnvSet(kRunAsNode);
|
||||
#else
|
||||
bool run_as_node = false;
|
||||
#endif
|
||||
|
||||
// Make sure the output is printed to console.
|
||||
if (run_as_node || !IsEnvSet("ELECTRON_NO_ATTACH_CONSOLE"))
|
||||
base::RouteStdioToConsole(false);
|
||||
|
||||
// Convert argv to to UTF8
|
||||
char** argv = new char*[argc];
|
||||
for (int i = 0; i < argc; i++) {
|
||||
// Compute the size of the required buffer
|
||||
DWORD size = WideCharToMultiByte(CP_UTF8,
|
||||
0,
|
||||
wargv[i],
|
||||
-1,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
if (size == 0) {
|
||||
// This should never happen.
|
||||
fprintf(stderr, "Could not convert arguments to utf8.");
|
||||
exit(1);
|
||||
}
|
||||
// Do the actual conversion
|
||||
argv[i] = new char[size];
|
||||
DWORD result = WideCharToMultiByte(CP_UTF8,
|
||||
0,
|
||||
wargv[i],
|
||||
-1,
|
||||
argv[i],
|
||||
size,
|
||||
NULL,
|
||||
NULL);
|
||||
if (result == 0) {
|
||||
// This should never happen.
|
||||
fprintf(stderr, "Could not convert arguments to utf8.");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef DEBUG
|
||||
// Chromium has its own TLS subsystem which supports automatic destruction
|
||||
// of thread-local data, and also depends on memory allocation routines
|
||||
@@ -138,15 +120,28 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||
});
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_RUN_AS_NODE
|
||||
if (run_as_node) {
|
||||
// Now that argv conversion is done, we can finally start.
|
||||
std::vector<char*> argv(arguments.argc);
|
||||
std::transform(
|
||||
arguments.argv, arguments.argv + arguments.argc, argv.begin(),
|
||||
[](auto& a) { return _strdup(base::WideToUTF8(a).c_str()); });
|
||||
|
||||
base::AtExitManager atexit_manager;
|
||||
base::i18n::InitializeICU();
|
||||
return atom::NodeMain(argc, argv);
|
||||
} else if (IsEnvSet("ELECTRON_INTERNAL_CRASH_SERVICE")) {
|
||||
auto ret = atom::NodeMain(argv.size(), argv.data());
|
||||
std::for_each(argv.begin(), argv.end(), free);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (IsEnvSet("ELECTRON_INTERNAL_CRASH_SERVICE")) {
|
||||
return crash_service::Main(cmd);
|
||||
}
|
||||
|
||||
if (!atom::CheckCommandLineArguments(arguments.argc, arguments.argv))
|
||||
return -1;
|
||||
|
||||
sandbox::SandboxInterfaceInfo sandbox_info = {0};
|
||||
content::InitializeSandboxInfo(&sandbox_info);
|
||||
atom::AtomMainDelegate delegate;
|
||||
@@ -154,34 +149,37 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||
content::ContentMainParams params(&delegate);
|
||||
params.instance = instance;
|
||||
params.sandbox_info = &sandbox_info;
|
||||
atom::AtomCommandLine::Init(argc, argv);
|
||||
atom::AtomCommandLine::InitW(argc, wargv);
|
||||
atom::AtomCommandLine::Init(arguments.argc, arguments.argv);
|
||||
return content::ContentMain(params);
|
||||
}
|
||||
|
||||
#elif defined(OS_LINUX) // defined(OS_WIN)
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
int main(int argc, char* argv[]) {
|
||||
#ifdef ENABLE_RUN_AS_NODE
|
||||
if (IsEnvSet(kRunAsNode)) {
|
||||
base::i18n::InitializeICU();
|
||||
base::AtExitManager atexit_manager;
|
||||
return atom::NodeMain(argc, const_cast<char**>(argv));
|
||||
return atom::NodeMain(argc, argv);
|
||||
}
|
||||
#endif
|
||||
|
||||
atom::AtomMainDelegate delegate;
|
||||
content::ContentMainParams params(&delegate);
|
||||
params.argc = argc;
|
||||
params.argv = argv;
|
||||
params.argv = const_cast<const char**>(argv);
|
||||
atom::AtomCommandLine::Init(argc, argv);
|
||||
return content::ContentMain(params);
|
||||
}
|
||||
|
||||
#else // defined(OS_LINUX)
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
int main(int argc, char* argv[]) {
|
||||
#ifdef ENABLE_RUN_AS_NODE
|
||||
if (IsEnvSet(kRunAsNode)) {
|
||||
return AtomInitializeICUandStartNode(argc, const_cast<char**>(argv));
|
||||
return AtomInitializeICUandStartNode(argc, argv);
|
||||
}
|
||||
#endif
|
||||
|
||||
return AtomMain(argc, argv);
|
||||
}
|
||||
|
||||
@@ -21,9 +21,18 @@
|
||||
#include "base/logging.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "ipc/ipc_features.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/base/resource/resource_bundle.h"
|
||||
|
||||
#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED)
|
||||
#define IPC_MESSAGE_MACROS_LOG_ENABLED
|
||||
#include "content/public/common/content_ipc_logging.h"
|
||||
#define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \
|
||||
content::RegisterIPCLogger(msg_id, logger)
|
||||
#include "atom/common/common_message_generator.h"
|
||||
#endif
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
@@ -86,9 +95,10 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
logging::SetLogItems(true, false, true, false);
|
||||
|
||||
// Enable convient stack printing.
|
||||
bool enable_stack_dumping = env->HasVar("ELECTRON_ENABLE_STACK_DUMPING");
|
||||
#if defined(DEBUG) && defined(OS_LINUX)
|
||||
enable_stack_dumping = true;
|
||||
bool enable_stack_dumping = true;
|
||||
#else
|
||||
bool enable_stack_dumping = env->HasVar("ELECTRON_ENABLE_STACK_DUMPING");
|
||||
#endif
|
||||
if (enable_stack_dumping)
|
||||
base::debug::EnableInProcessStackDumping();
|
||||
|
||||
@@ -44,7 +44,6 @@ class AtomMainDelegate : public brightray::MainDelegate {
|
||||
void SetUpBundleOverrides();
|
||||
#endif
|
||||
|
||||
brightray::ContentClient content_client_;
|
||||
std::unique_ptr<content::ContentBrowserClient> browser_client_;
|
||||
std::unique_ptr<content::ContentRendererClient> renderer_client_;
|
||||
std::unique_ptr<content::ContentUtilityClient> utility_client_;
|
||||
|
||||
1427
atom/app/command_line_args.cc
Normal file
1427
atom/app/command_line_args.cc
Normal file
File diff suppressed because it is too large
Load Diff
17
atom/app/command_line_args.h
Normal file
17
atom/app/command_line_args.h
Normal file
@@ -0,0 +1,17 @@
|
||||
// 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_APP_COMMAND_LINE_ARGS_H_
|
||||
#define ATOM_APP_COMMAND_LINE_ARGS_H_
|
||||
|
||||
#include "base/command_line.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
bool CheckCommandLineArguments(int argc, base::CommandLine::CharType** argv);
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_APP_COMMAND_LINE_ARGS_H_
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifdef ENABLE_RUN_AS_NODE
|
||||
|
||||
#include "atom/app/node_main.h"
|
||||
|
||||
#include "atom/app/uv_task_runner.h"
|
||||
@@ -12,6 +14,7 @@
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/feature_list.h"
|
||||
#include "base/task_scheduler/task_scheduler.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "gin/array_buffer.h"
|
||||
#include "gin/public/isolate_holder.h"
|
||||
@@ -40,6 +43,11 @@ int NodeMain(int argc, char *argv[]) {
|
||||
|
||||
gin::V8Initializer::LoadV8Snapshot();
|
||||
gin::V8Initializer::LoadV8Natives();
|
||||
|
||||
// V8 requires a task scheduler apparently
|
||||
base::TaskScheduler::CreateAndStartWithDefaultParams("Electron");
|
||||
|
||||
// Initialize gin::IsolateHolder.
|
||||
JavascriptEnvironment gin_env;
|
||||
|
||||
int exec_argc;
|
||||
@@ -53,7 +61,7 @@ int NodeMain(int argc, char *argv[]) {
|
||||
|
||||
// Enable support for v8 inspector.
|
||||
NodeDebugger node_debugger(env);
|
||||
node_debugger.Start();
|
||||
node_debugger.Start(gin_env.platform());
|
||||
|
||||
mate::Dictionary process(gin_env.isolate(), env->process_object());
|
||||
#if defined(OS_WIN)
|
||||
@@ -88,9 +96,18 @@ int NodeMain(int argc, char *argv[]) {
|
||||
node::FreeEnvironment(env);
|
||||
}
|
||||
|
||||
// According to "src/gin/shell/gin_main.cc":
|
||||
//
|
||||
// gin::IsolateHolder waits for tasks running in TaskScheduler in its
|
||||
// destructor and thus must be destroyed before TaskScheduler starts skipping
|
||||
// CONTINUE_ON_SHUTDOWN tasks.
|
||||
base::TaskScheduler::GetInstance()->Shutdown();
|
||||
|
||||
v8::V8::Dispose();
|
||||
|
||||
return exit_code;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ENABLE_RUN_AS_NODE
|
||||
|
||||
@@ -5,10 +5,14 @@
|
||||
#ifndef ATOM_APP_NODE_MAIN_H_
|
||||
#define ATOM_APP_NODE_MAIN_H_
|
||||
|
||||
#ifdef ENABLE_RUN_AS_NODE
|
||||
|
||||
namespace atom {
|
||||
|
||||
int NodeMain(int argc, char *argv[]);
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ENABLE_RUN_AS_NODE
|
||||
|
||||
#endif // ATOM_APP_NODE_MAIN_H_
|
||||
|
||||
16
atom/app/resources/mac/loginhelper-Info.plist
Normal file
16
atom/app/resources/mac/loginhelper-Info.plist
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>${ATOM_BUNDLE_ID}</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>LSBackgroundOnly</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -31,7 +31,7 @@ bool UvTaskRunner::PostDelayedTask(const tracked_objects::Location& from_here,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UvTaskRunner::RunsTasksOnCurrentThread() const {
|
||||
bool UvTaskRunner::RunsTasksInCurrentSequence() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class UvTaskRunner : public base::SingleThreadTaskRunner {
|
||||
bool PostDelayedTask(const tracked_objects::Location& from_here,
|
||||
base::OnceClosure task,
|
||||
base::TimeDelta delay) override;
|
||||
bool RunsTasksOnCurrentThread() const override;
|
||||
bool RunsTasksInCurrentSequence() const override;
|
||||
bool PostNonNestableDelayedTask(
|
||||
const tracked_objects::Location& from_here,
|
||||
base::OnceClosure task,
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#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 "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
@@ -420,19 +421,26 @@ bool NotificationCallbackWrapper(
|
||||
return !Browser::Get()->is_shutting_down();
|
||||
}
|
||||
|
||||
void GotPrivateKey(std::shared_ptr<content::ClientCertificateDelegate> delegate,
|
||||
scoped_refptr<net::X509Certificate> cert,
|
||||
scoped_refptr<net::SSLPrivateKey> private_key) {
|
||||
delegate->ContinueWithCertificate(cert, private_key);
|
||||
}
|
||||
|
||||
void OnClientCertificateSelected(
|
||||
v8::Isolate* isolate,
|
||||
std::shared_ptr<content::ClientCertificateDelegate> delegate,
|
||||
std::shared_ptr<net::ClientCertIdentityList> identities,
|
||||
mate::Arguments* args) {
|
||||
if (args->Length() == 2) {
|
||||
delegate->ContinueWithCertificate(nullptr);
|
||||
delegate->ContinueWithCertificate(nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> val;
|
||||
args->GetNext(&val);
|
||||
if (val->IsNull()) {
|
||||
delegate->ContinueWithCertificate(nullptr);
|
||||
delegate->ContinueWithCertificate(nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -448,8 +456,17 @@ void OnClientCertificateSelected(
|
||||
|
||||
auto certs = net::X509Certificate::CreateCertificateListFromBytes(
|
||||
data.c_str(), data.length(), net::X509Certificate::FORMAT_AUTO);
|
||||
if (!certs.empty())
|
||||
delegate->ContinueWithCertificate(certs[0].get());
|
||||
if (!certs.empty()) {
|
||||
scoped_refptr<net::X509Certificate> cert(certs[0].get());
|
||||
for (size_t i = 0; i < identities->size(); ++i) {
|
||||
if (cert->Equals((*identities)[i]->certificate())) {
|
||||
net::ClientCertIdentity::SelfOwningAcquirePrivateKey(
|
||||
std::move((*identities)[i]),
|
||||
base::Bind(&GotPrivateKey, delegate, std::move(cert)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PassLoginInformation(scoped_refptr<LoginHandler> login_handler,
|
||||
@@ -515,7 +532,6 @@ App::App(v8::Isolate* isolate) {
|
||||
static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())->set_delegate(this);
|
||||
Browser::Get()->AddObserver(this);
|
||||
content::GpuDataManager::GetInstance()->AddObserver(this);
|
||||
content::BrowserChildProcessObserver::Add(this);
|
||||
base::ProcessId pid = base::GetCurrentProcId();
|
||||
std::unique_ptr<atom::ProcessMetric> process_metric(
|
||||
new atom::ProcessMetric(
|
||||
@@ -582,6 +598,7 @@ void App::OnFinishLaunching(const base::DictionaryValue& launch_info) {
|
||||
}
|
||||
|
||||
void App::OnPreMainMessageLoopRun() {
|
||||
content::BrowserChildProcessObserver::Add(this);
|
||||
if (process_singleton_) {
|
||||
process_singleton_->OnBrowserReady();
|
||||
}
|
||||
@@ -650,28 +667,33 @@ void App::OnLogin(LoginHandler* login_handler,
|
||||
login_handler->CancelAuth();
|
||||
}
|
||||
|
||||
void App::OnCreateWindow(
|
||||
bool App::CanCreateWindow(
|
||||
content::RenderFrameHost* opener,
|
||||
const GURL& opener_url,
|
||||
const GURL& opener_top_level_frame_url,
|
||||
const GURL& source_origin,
|
||||
content::mojom::WindowContainerType container_type,
|
||||
const GURL& target_url,
|
||||
const content::Referrer& referrer,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const std::vector<std::string>& features,
|
||||
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
|
||||
int render_process_id,
|
||||
int render_frame_id) {
|
||||
const blink::mojom::WindowFeatures& features,
|
||||
const std::vector<std::string>& additional_features,
|
||||
const scoped_refptr<content::ResourceRequestBody>& body,
|
||||
bool user_gesture,
|
||||
bool opener_suppressed,
|
||||
bool* no_javascript_access) {
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
content::RenderFrameHost* rfh =
|
||||
content::RenderFrameHost::FromID(render_process_id, render_frame_id);
|
||||
content::WebContents* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(rfh);
|
||||
content::WebContents::FromRenderFrameHost(opener);
|
||||
if (web_contents) {
|
||||
auto api_web_contents = WebContents::CreateFrom(isolate(), web_contents);
|
||||
api_web_contents->OnCreateWindow(target_url,
|
||||
frame_name,
|
||||
disposition,
|
||||
features,
|
||||
body);
|
||||
api_web_contents->OnCreateWindow(target_url, frame_name, disposition,
|
||||
additional_features, body);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void App::AllowCertificateError(
|
||||
@@ -702,22 +724,35 @@ void App::AllowCertificateError(
|
||||
void App::SelectClientCertificate(
|
||||
content::WebContents* web_contents,
|
||||
net::SSLCertRequestInfo* cert_request_info,
|
||||
net::ClientCertIdentityList identities,
|
||||
std::unique_ptr<content::ClientCertificateDelegate> delegate) {
|
||||
std::shared_ptr<content::ClientCertificateDelegate>
|
||||
shared_delegate(delegate.release());
|
||||
|
||||
// Convert the ClientCertIdentityList to a CertificateList
|
||||
// to avoid changes in the API.
|
||||
auto client_certs = net::CertificateList();
|
||||
for (const std::unique_ptr<net::ClientCertIdentity>& identity : identities)
|
||||
client_certs.push_back(identity->certificate());
|
||||
|
||||
auto shared_identities =
|
||||
std::make_shared<net::ClientCertIdentityList>(std::move(identities));
|
||||
|
||||
bool prevent_default =
|
||||
Emit("select-client-certificate",
|
||||
WebContents::CreateFrom(isolate(), web_contents),
|
||||
cert_request_info->host_and_port.ToString(),
|
||||
cert_request_info->client_certs,
|
||||
base::Bind(&OnClientCertificateSelected,
|
||||
isolate(),
|
||||
shared_delegate));
|
||||
cert_request_info->host_and_port.ToString(), std::move(client_certs),
|
||||
base::Bind(&OnClientCertificateSelected, isolate(), shared_delegate,
|
||||
shared_identities));
|
||||
|
||||
// Default to first certificate from the platform store.
|
||||
if (!prevent_default)
|
||||
shared_delegate->ContinueWithCertificate(
|
||||
cert_request_info->client_certs[0].get());
|
||||
if (!prevent_default) {
|
||||
scoped_refptr<net::X509Certificate> cert =
|
||||
(*shared_identities)[0]->certificate();
|
||||
net::ClientCertIdentity::SelfOwningAcquirePrivateKey(
|
||||
std::move((*shared_identities)[0]),
|
||||
base::Bind(&GotPrivateKey, shared_delegate, std::move(cert)));
|
||||
}
|
||||
}
|
||||
|
||||
void App::OnGpuProcessCrashed(base::TerminationStatus status) {
|
||||
@@ -816,7 +851,7 @@ void App::SetDesktopName(const std::string& desktop_name) {
|
||||
}
|
||||
|
||||
std::string App::GetLocale() {
|
||||
return l10n_util::GetApplicationLocale("");
|
||||
return g_browser_process->GetApplicationLocale();
|
||||
}
|
||||
|
||||
bool App::MakeSingleInstance(
|
||||
@@ -832,9 +867,10 @@ bool App::MakeSingleInstance(
|
||||
switch (process_singleton_->NotifyOtherProcessOrCreate()) {
|
||||
case ProcessSingleton::NotifyResult::LOCK_ERROR:
|
||||
case ProcessSingleton::NotifyResult::PROFILE_IN_USE:
|
||||
case ProcessSingleton::NotifyResult::PROCESS_NOTIFIED:
|
||||
case ProcessSingleton::NotifyResult::PROCESS_NOTIFIED: {
|
||||
process_singleton_.reset();
|
||||
return true;
|
||||
}
|
||||
case ProcessSingleton::NotifyResult::PROCESS_NONE:
|
||||
default: // Shouldn't be needed, but VS warns if it is not there.
|
||||
return false;
|
||||
@@ -861,11 +897,7 @@ bool App::Relaunch(mate::Arguments* js_args) {
|
||||
}
|
||||
|
||||
if (!override_argv) {
|
||||
#if defined(OS_WIN)
|
||||
const relauncher::StringVector& argv = atom::AtomCommandLine::wargv();
|
||||
#else
|
||||
const relauncher::StringVector& argv = atom::AtomCommandLine::argv();
|
||||
#endif
|
||||
return relauncher::RelaunchApp(argv);
|
||||
}
|
||||
|
||||
@@ -1224,13 +1256,16 @@ void App::BuildPrototype(
|
||||
.SetMethod("getFileIcon", &App::GetFileIcon)
|
||||
.SetMethod("getAppMetrics", &App::GetAppMetrics)
|
||||
.SetMethod("getGPUFeatureStatus", &App::GetGPUFeatureStatus)
|
||||
.SetMethod("enableMixedSandbox", &App::EnableMixedSandbox)
|
||||
// TODO(juturu): Remove in 2.0, deprecate before then with warnings
|
||||
#if defined(OS_MACOSX)
|
||||
.SetMethod("moveToApplicationsFolder", &App::MoveToApplicationsFolder)
|
||||
.SetMethod("isInApplicationsFolder", &App::IsInApplicationsFolder)
|
||||
#endif
|
||||
.SetMethod("getAppMemoryInfo", &App::GetAppMetrics);
|
||||
#if defined(MAS_BUILD)
|
||||
.SetMethod("startAccessingSecurityScopedResource",
|
||||
&App::StartAccessingSecurityScopedResource)
|
||||
#endif
|
||||
.SetMethod("enableMixedSandbox", &App::EnableMixedSandbox);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "net/base/completion_callback.h"
|
||||
#include "net/ssl/client_cert_identity.h"
|
||||
|
||||
#if defined(USE_NSS_CERTS)
|
||||
#include "chrome/browser/certificate_manager_model.h"
|
||||
@@ -74,16 +75,6 @@ class App : public AtomBrowserClient::Delegate,
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
// Called when window with disposition needs to be created.
|
||||
void OnCreateWindow(
|
||||
const GURL& target_url,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const std::vector<std::string>& features,
|
||||
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
|
||||
int render_process_id,
|
||||
int render_frame_id);
|
||||
|
||||
#if defined(USE_NSS_CERTS)
|
||||
void OnCertificateManagerModelCreated(
|
||||
std::unique_ptr<base::DictionaryValue> options,
|
||||
@@ -150,7 +141,23 @@ class App : public AtomBrowserClient::Delegate,
|
||||
void SelectClientCertificate(
|
||||
content::WebContents* web_contents,
|
||||
net::SSLCertRequestInfo* cert_request_info,
|
||||
net::ClientCertIdentityList client_certs,
|
||||
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
|
||||
bool CanCreateWindow(content::RenderFrameHost* opener,
|
||||
const GURL& opener_url,
|
||||
const GURL& opener_top_level_frame_url,
|
||||
const GURL& source_origin,
|
||||
content::mojom::WindowContainerType container_type,
|
||||
const GURL& target_url,
|
||||
const content::Referrer& referrer,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::mojom::WindowFeatures& features,
|
||||
const std::vector<std::string>& additional_features,
|
||||
const scoped_refptr<content::ResourceRequestBody>& body,
|
||||
bool user_gesture,
|
||||
bool opener_suppressed,
|
||||
bool* no_javascript_access) override;
|
||||
|
||||
// content::GpuDataManagerObserver:
|
||||
void OnGpuProcessCrashed(base::TerminationStatus status) override;
|
||||
@@ -202,6 +209,10 @@ class App : public AtomBrowserClient::Delegate,
|
||||
bool MoveToApplicationsFolder(mate::Arguments* args);
|
||||
bool IsInApplicationsFolder();
|
||||
#endif
|
||||
#if defined(MAS_BUILD)
|
||||
base::Callback<void()> StartAccessingSecurityScopedResource(
|
||||
mate::Arguments* args);
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Get the current Jump List settings.
|
||||
|
||||
59
atom/browser/api/atom_api_app_mas.mm
Normal file
59
atom/browser/api/atom_api_app_mas.mm
Normal file
@@ -0,0 +1,59 @@
|
||||
// Copyright (c) 2013 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/api/atom_api_app.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
// Callback passed to js which will stop accessing the given bookmark.
|
||||
void OnStopAccessingSecurityScopedResource(NSURL* bookmarkUrl) {
|
||||
[bookmarkUrl stopAccessingSecurityScopedResource];
|
||||
[bookmarkUrl release];
|
||||
}
|
||||
|
||||
// Get base64 encoded NSData, create a bookmark for it and start accessing it.
|
||||
base::Callback<void ()> App::StartAccessingSecurityScopedResource(mate::Arguments* args) {
|
||||
std::string data;
|
||||
args->GetNext(&data);
|
||||
NSString *base64str = base::SysUTF8ToNSString(data);
|
||||
NSData *bookmarkData = [[NSData alloc] initWithBase64EncodedString: base64str options: 0];
|
||||
|
||||
// Create bookmarkUrl from NSData.
|
||||
BOOL isStale = false;
|
||||
NSError *error = nil;
|
||||
NSURL *bookmarkUrl = [NSURL URLByResolvingBookmarkData: bookmarkData
|
||||
options: NSURLBookmarkResolutionWithSecurityScope
|
||||
relativeToURL: nil
|
||||
bookmarkDataIsStale: &isStale
|
||||
error: &error];
|
||||
|
||||
if (error != nil) {
|
||||
NSString *err = [NSString stringWithFormat: @"NSError: %@ %@", error, [error userInfo]];
|
||||
args->ThrowError(base::SysNSStringToUTF8(err));
|
||||
}
|
||||
|
||||
if (isStale) {
|
||||
args->ThrowError("bookmarkDataIsStale - try recreating the bookmark");
|
||||
}
|
||||
|
||||
if (error == nil && isStale == false) {
|
||||
[bookmarkUrl startAccessingSecurityScopedResource];
|
||||
}
|
||||
|
||||
// Stop the NSURL from being GC'd.
|
||||
[bookmarkUrl retain];
|
||||
|
||||
// Return a js callback which will close the bookmark.
|
||||
return base::Bind(&OnStopAccessingSecurityScopedResource, bookmarkUrl);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
} // namespace api
|
||||
@@ -99,10 +99,8 @@ void AutoUpdater::OnWindowAllClosed() {
|
||||
QuitAndInstall();
|
||||
}
|
||||
|
||||
void AutoUpdater::SetFeedURL(const std::string& url, mate::Arguments* args) {
|
||||
auto_updater::AutoUpdater::HeaderMap headers;
|
||||
args->GetNext(&headers);
|
||||
auto_updater::AutoUpdater::SetFeedURL(url, headers);
|
||||
void AutoUpdater::SetFeedURL(mate::Arguments* args) {
|
||||
auto_updater::AutoUpdater::SetFeedURL(args);
|
||||
}
|
||||
|
||||
void AutoUpdater::QuitAndInstall() {
|
||||
|
||||
@@ -47,7 +47,7 @@ class AutoUpdater : public mate::EventEmitter<AutoUpdater>,
|
||||
|
||||
private:
|
||||
std::string GetFeedURL();
|
||||
void SetFeedURL(const std::string& url, mate::Arguments* args);
|
||||
void SetFeedURL(mate::Arguments* args);
|
||||
void QuitAndInstall();
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AutoUpdater);
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "base/json/json_reader.h"
|
||||
#include "base/json/json_writer.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "content/public/browser/devtools_agent_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
@@ -47,20 +49,11 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
|
||||
v8::Local<v8::String> local_message =
|
||||
v8::String::NewFromUtf8(isolate(), message.data());
|
||||
v8::MaybeLocal<v8::Value> parsed_message = v8::JSON::Parse(
|
||||
isolate()->GetCurrentContext(), local_message);
|
||||
if (parsed_message.IsEmpty()) {
|
||||
std::unique_ptr<base::Value> parsed_message = base::JSONReader::Read(message);
|
||||
if (!parsed_message || !parsed_message->is_dict())
|
||||
return;
|
||||
}
|
||||
|
||||
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
|
||||
if (!mate::ConvertFromV8(isolate(), parsed_message.ToLocalChecked(),
|
||||
dict.get())) {
|
||||
return;
|
||||
}
|
||||
|
||||
base::DictionaryValue* dict =
|
||||
static_cast<base::DictionaryValue*>(parsed_message.get());
|
||||
int id;
|
||||
if (!dict->GetInteger("id", &id)) {
|
||||
std::string method;
|
||||
@@ -143,7 +136,7 @@ void Debugger::SendCommand(mate::Arguments* args) {
|
||||
request.SetInteger("id", request_id);
|
||||
request.SetString("method", method);
|
||||
if (!command_params.empty())
|
||||
request.Set("params", command_params.DeepCopy());
|
||||
request.Set("params", base::WrapUnique(command_params.DeepCopy()));
|
||||
|
||||
std::string json_args;
|
||||
base::JSONWriter::Write(request, &json_args);
|
||||
|
||||
@@ -10,6 +10,7 @@ using base::PlatformThreadRef;
|
||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "chrome/browser/media/desktop_media_list.h"
|
||||
#include "content/public/browser/desktop_capture.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h"
|
||||
#include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
@@ -50,17 +51,7 @@ void DesktopCapturer::StartHandling(bool capture_window,
|
||||
bool capture_screen,
|
||||
const gfx::Size& thumbnail_size) {
|
||||
webrtc::DesktopCaptureOptions options =
|
||||
webrtc::DesktopCaptureOptions::CreateDefault();
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// On windows, desktop effects (e.g. Aero) will be disabled when the Desktop
|
||||
// capture API is active by default.
|
||||
// We keep the desktop effects in most times. Howerver, the screen still
|
||||
// fickers when the API is capturing the window due to limitation of current
|
||||
// implemetation. This is a known and wontFix issue in webrtc (see:
|
||||
// http://code.google.com/p/webrtc/issues/detail?id=3373)
|
||||
options.set_disable_effects(false);
|
||||
#endif
|
||||
content::CreateDesktopCaptureOptions();
|
||||
|
||||
std::unique_ptr<webrtc::DesktopCapturer> screen_capturer(
|
||||
capture_screen ? webrtc::DesktopCapturer::CreateScreenCapturer(options)
|
||||
|
||||
@@ -54,6 +54,9 @@ struct Converter<file_dialog::DialogSettings> {
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
115
atom/browser/api/atom_api_in_app_purchase.cc
Normal file
115
atom/browser/api/atom_api_in_app_purchase.cc
Normal file
@@ -0,0 +1,115 @@
|
||||
// Copyright (c) 2017 Amaplex Software, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/api/atom_api_in_app_purchase.h"
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
namespace mate {
|
||||
|
||||
template <>
|
||||
struct Converter<in_app_purchase::Payment> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const in_app_purchase::Payment& payment) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
dict.SetHidden("simple", true);
|
||||
dict.Set("productIdentifier", payment.productIdentifier);
|
||||
dict.Set("quantity", payment.quantity);
|
||||
return dict.GetHandle();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<in_app_purchase::Transaction> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const in_app_purchase::Transaction& val) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
dict.SetHidden("simple", true);
|
||||
dict.Set("transactionIdentifier", val.transactionIdentifier);
|
||||
dict.Set("transactionDate", val.transactionDate);
|
||||
dict.Set("originalTransactionIdentifier",
|
||||
val.originalTransactionIdentifier);
|
||||
dict.Set("transactionState", val.transactionState);
|
||||
dict.Set("errorCode", val.errorCode);
|
||||
dict.Set("errorMessage", val.errorMessage);
|
||||
dict.Set("payment", val.payment);
|
||||
return dict.GetHandle();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
// static
|
||||
mate::Handle<InAppPurchase> InAppPurchase::Create(v8::Isolate* isolate) {
|
||||
return mate::CreateHandle(isolate, new InAppPurchase(isolate));
|
||||
}
|
||||
|
||||
// static
|
||||
void InAppPurchase::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "InAppPurchase"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("canMakePayments", &in_app_purchase::CanMakePayments)
|
||||
.SetMethod("getReceiptURL", &in_app_purchase::GetReceiptURL)
|
||||
.SetMethod("purchaseProduct", &InAppPurchase::PurchaseProduct);
|
||||
}
|
||||
|
||||
InAppPurchase::InAppPurchase(v8::Isolate* isolate) {
|
||||
Init(isolate);
|
||||
}
|
||||
|
||||
InAppPurchase::~InAppPurchase() {
|
||||
}
|
||||
|
||||
void InAppPurchase::PurchaseProduct(const std::string& product_id,
|
||||
mate::Arguments* args) {
|
||||
int quantity = 1;
|
||||
in_app_purchase::InAppPurchaseCallback callback;
|
||||
args->GetNext(&quantity);
|
||||
args->GetNext(&callback);
|
||||
in_app_purchase::PurchaseProduct(product_id, quantity, callback);
|
||||
}
|
||||
|
||||
void InAppPurchase::OnTransactionsUpdated(
|
||||
const std::vector<in_app_purchase::Transaction>& transactions) {
|
||||
Emit("transactions-updated", transactions);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
namespace {
|
||||
|
||||
using atom::api::InAppPurchase;
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
#if defined(OS_MACOSX)
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.Set("inAppPurchase", InAppPurchase::Create(isolate));
|
||||
dict.Set("InAppPurchase",
|
||||
InAppPurchase::GetConstructor(isolate)->GetFunction());
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_in_app_purchase, Initialize)
|
||||
46
atom/browser/api/atom_api_in_app_purchase.h
Normal file
46
atom/browser/api/atom_api_in_app_purchase.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright (c) 2017 Amaplex Software, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_API_ATOM_API_IN_APP_PURCHASE_H_
|
||||
#define ATOM_BROWSER_API_ATOM_API_IN_APP_PURCHASE_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/api/event_emitter.h"
|
||||
#include "atom/browser/mac/in_app_purchase.h"
|
||||
#include "atom/browser/mac/in_app_purchase_observer.h"
|
||||
#include "native_mate/handle.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
class InAppPurchase: public mate::EventEmitter<InAppPurchase>,
|
||||
public in_app_purchase::TransactionObserver {
|
||||
public:
|
||||
static mate::Handle<InAppPurchase> Create(v8::Isolate* isolate);
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
protected:
|
||||
explicit InAppPurchase(v8::Isolate* isolate);
|
||||
~InAppPurchase() override;
|
||||
|
||||
void PurchaseProduct(const std::string& product_id, mate::Arguments* args);
|
||||
|
||||
// TransactionObserver:
|
||||
void OnTransactionsUpdated(
|
||||
const std::vector<in_app_purchase::Transaction>& transactions) override;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(InAppPurchase);
|
||||
};
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_API_ATOM_API_IN_APP_PURCHASE_H_
|
||||
@@ -23,9 +23,13 @@ Menu::Menu(v8::Isolate* isolate, v8::Local<v8::Object> wrapper)
|
||||
: model_(new AtomMenuModel(this)),
|
||||
parent_(nullptr) {
|
||||
InitWith(isolate, wrapper);
|
||||
model_->AddObserver(this);
|
||||
}
|
||||
|
||||
Menu::~Menu() {
|
||||
if (model_) {
|
||||
model_->RemoveObserver(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::AfterInit(v8::Isolate* isolate) {
|
||||
@@ -43,15 +47,21 @@ void Menu::AfterInit(v8::Isolate* isolate) {
|
||||
}
|
||||
|
||||
bool Menu::IsCommandIdChecked(int command_id) const {
|
||||
return is_checked_.Run(command_id);
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
return is_checked_.Run(GetWrapper(), command_id);
|
||||
}
|
||||
|
||||
bool Menu::IsCommandIdEnabled(int command_id) const {
|
||||
return is_enabled_.Run(command_id);
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
return is_enabled_.Run(GetWrapper(), command_id);
|
||||
}
|
||||
|
||||
bool Menu::IsCommandIdVisible(int command_id) const {
|
||||
return is_visible_.Run(command_id);
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
return is_visible_.Run(GetWrapper(), command_id);
|
||||
}
|
||||
|
||||
bool Menu::GetAcceleratorForCommandIdWithParams(
|
||||
@@ -61,18 +71,23 @@ bool Menu::GetAcceleratorForCommandIdWithParams(
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
v8::Local<v8::Value> val = get_accelerator_.Run(
|
||||
command_id, use_default_accelerator);
|
||||
GetWrapper(), command_id, use_default_accelerator);
|
||||
return mate::ConvertFromV8(isolate(), val, accelerator);
|
||||
}
|
||||
|
||||
void Menu::ExecuteCommand(int command_id, int flags) {
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
execute_command_.Run(
|
||||
GetWrapper(),
|
||||
mate::internal::CreateEventFromFlags(isolate(), flags),
|
||||
command_id);
|
||||
}
|
||||
|
||||
void Menu::MenuWillShow(ui::SimpleMenuModel* source) {
|
||||
menu_will_show_.Run();
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
menu_will_show_.Run(GetWrapper());
|
||||
}
|
||||
|
||||
void Menu::InsertItemAt(
|
||||
@@ -153,6 +168,14 @@ bool Menu::IsVisibleAt(int index) const {
|
||||
return model_->IsVisibleAt(index);
|
||||
}
|
||||
|
||||
void Menu::OnMenuWillClose() {
|
||||
Emit("menu-will-close");
|
||||
}
|
||||
|
||||
void Menu::OnMenuWillShow() {
|
||||
Emit("menu-will-show");
|
||||
}
|
||||
|
||||
// static
|
||||
void Menu::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
|
||||
@@ -18,7 +18,8 @@ namespace atom {
|
||||
namespace api {
|
||||
|
||||
class Menu : public mate::TrackableObject<Menu>,
|
||||
public AtomMenuModel::Delegate {
|
||||
public AtomMenuModel::Delegate,
|
||||
public AtomMenuModel::Observer {
|
||||
public:
|
||||
static mate::WrappableBase* New(mate::Arguments* args);
|
||||
|
||||
@@ -53,13 +54,17 @@ class Menu : public mate::TrackableObject<Menu>,
|
||||
void ExecuteCommand(int command_id, int event_flags) override;
|
||||
void MenuWillShow(ui::SimpleMenuModel* source) override;
|
||||
|
||||
virtual void PopupAt(
|
||||
Window* window, int x, int y, int positioning_item, bool async) = 0;
|
||||
virtual void PopupAt(Window* window, int x, int y, int positioning_item,
|
||||
const base::Closure& callback) = 0;
|
||||
virtual void ClosePopupAt(int32_t window_id) = 0;
|
||||
|
||||
std::unique_ptr<AtomMenuModel> model_;
|
||||
Menu* parent_;
|
||||
|
||||
// Observable:
|
||||
void OnMenuWillClose() override;
|
||||
void OnMenuWillShow() override;
|
||||
|
||||
private:
|
||||
void InsertItemAt(int index, int command_id, const base::string16& label);
|
||||
void InsertSeparatorAt(int index);
|
||||
@@ -88,12 +93,14 @@ class Menu : public mate::TrackableObject<Menu>,
|
||||
bool IsVisibleAt(int index) const;
|
||||
|
||||
// Stored delegate methods.
|
||||
base::Callback<bool(int)> is_checked_;
|
||||
base::Callback<bool(int)> is_enabled_;
|
||||
base::Callback<bool(int)> is_visible_;
|
||||
base::Callback<v8::Local<v8::Value>(int, bool)> get_accelerator_;
|
||||
base::Callback<void(v8::Local<v8::Value>, int)> execute_command_;
|
||||
base::Callback<void()> menu_will_show_;
|
||||
base::Callback<bool(v8::Local<v8::Value>, int)> is_checked_;
|
||||
base::Callback<bool(v8::Local<v8::Value>, int)> is_enabled_;
|
||||
base::Callback<bool(v8::Local<v8::Value>, int)> is_visible_;
|
||||
base::Callback<v8::Local<v8::Value>(v8::Local<v8::Value>, int, bool)>
|
||||
get_accelerator_;
|
||||
base::Callback<void(v8::Local<v8::Value>, v8::Local<v8::Value>, int)>
|
||||
execute_command_;
|
||||
base::Callback<void(v8::Local<v8::Value>)> menu_will_show_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Menu);
|
||||
};
|
||||
|
||||
@@ -22,17 +22,20 @@ class MenuMac : public Menu {
|
||||
protected:
|
||||
MenuMac(v8::Isolate* isolate, v8::Local<v8::Object> wrapper);
|
||||
|
||||
void PopupAt(
|
||||
Window* window, int x, int y, int positioning_item, bool async) override;
|
||||
void PopupAt(Window* window, int x, int y, int positioning_item,
|
||||
const base::Closure& callback) override;
|
||||
void PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
||||
int32_t window_id, int x, int y, int positioning_item,
|
||||
bool async);
|
||||
int32_t window_id,
|
||||
int x,
|
||||
int y,
|
||||
int positioning_item,
|
||||
base::Closure callback);
|
||||
void ClosePopupAt(int32_t window_id) override;
|
||||
|
||||
private:
|
||||
friend class Menu;
|
||||
|
||||
static void SendActionToFirstResponder(const std::string& action);
|
||||
void OnClosed(int32_t window_id, base::Closure callback);
|
||||
|
||||
scoped_nsobject<AtomMenuController> menu_controller_;
|
||||
|
||||
|
||||
@@ -27,24 +27,24 @@ MenuMac::MenuMac(v8::Isolate* isolate, v8::Local<v8::Object> wrapper)
|
||||
weak_factory_(this) {
|
||||
}
|
||||
|
||||
void MenuMac::PopupAt(
|
||||
Window* window, int x, int y, int positioning_item, bool async) {
|
||||
void MenuMac::PopupAt(Window* window, int x, int y, int positioning_item,
|
||||
const base::Closure& callback) {
|
||||
NativeWindow* native_window = window->window();
|
||||
if (!native_window)
|
||||
return;
|
||||
|
||||
auto popup = base::Bind(&MenuMac::PopupOnUI, weak_factory_.GetWeakPtr(),
|
||||
native_window->GetWeakPtr(), window->ID(), x, y,
|
||||
positioning_item, async);
|
||||
if (async)
|
||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, popup);
|
||||
else
|
||||
popup.Run();
|
||||
positioning_item, callback);
|
||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, popup);
|
||||
}
|
||||
|
||||
void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
||||
int32_t window_id, int x, int y, int positioning_item,
|
||||
bool async) {
|
||||
int32_t window_id,
|
||||
int x,
|
||||
int y,
|
||||
int positioning_item,
|
||||
base::Closure callback) {
|
||||
if (!native_window)
|
||||
return;
|
||||
brightray::InspectableWebContents* web_contents =
|
||||
@@ -52,8 +52,8 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
auto close_callback = base::Bind(&MenuMac::ClosePopupAt,
|
||||
weak_factory_.GetWeakPtr(), window_id);
|
||||
auto close_callback = base::Bind(
|
||||
&MenuMac::OnClosed, weak_factory_.GetWeakPtr(), window_id, callback);
|
||||
popup_controllers_[window_id] = base::scoped_nsobject<AtomMenuController>(
|
||||
[[AtomMenuController alloc] initWithModel:model()
|
||||
useDefaultAccelerator:NO]);
|
||||
@@ -92,33 +92,41 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
||||
if (rightmostMenuPoint > screenRight)
|
||||
position.x = position.x - [menu size].width;
|
||||
|
||||
[popup_controllers_[window_id] setCloseCallback:close_callback];
|
||||
// Make sure events can be pumped while the menu is up.
|
||||
base::MessageLoop::ScopedNestableTaskAllower allow(
|
||||
base::MessageLoop::current());
|
||||
|
||||
if (async) {
|
||||
[popup_controllers_[window_id] setCloseCallback:close_callback];
|
||||
// Make sure events can be pumped while the menu is up.
|
||||
base::MessageLoop::ScopedNestableTaskAllower allow(
|
||||
base::MessageLoop::current());
|
||||
// One of the events that could be pumped is |window.close()|.
|
||||
// User-initiated event-tracking loops protect against this by
|
||||
// setting flags in -[CrApplication sendEvent:], but since
|
||||
// web-content menus are initiated by IPC message the setup has to
|
||||
// be done manually.
|
||||
base::mac::ScopedSendingEvent sendingEventScoper;
|
||||
|
||||
// One of the events that could be pumped is |window.close()|.
|
||||
// User-initiated event-tracking loops protect against this by
|
||||
// setting flags in -[CrApplication sendEvent:], but since
|
||||
// web-content menus are initiated by IPC message the setup has to
|
||||
// be done manually.
|
||||
base::mac::ScopedSendingEvent sendingEventScoper;
|
||||
|
||||
// Don't emit unresponsive event when showing menu.
|
||||
atom::UnresponsiveSuppressor suppressor;
|
||||
[menu popUpMenuPositioningItem:item atLocation:position inView:view];
|
||||
} else {
|
||||
// Don't emit unresponsive event when showing menu.
|
||||
atom::UnresponsiveSuppressor suppressor;
|
||||
[menu popUpMenuPositioningItem:item atLocation:position inView:view];
|
||||
close_callback.Run();
|
||||
}
|
||||
// Don't emit unresponsive event when showing menu.
|
||||
atom::UnresponsiveSuppressor suppressor;
|
||||
[menu popUpMenuPositioningItem:item atLocation:position inView:view];
|
||||
}
|
||||
|
||||
void MenuMac::ClosePopupAt(int32_t window_id) {
|
||||
auto controller = popup_controllers_.find(window_id);
|
||||
if (controller != popup_controllers_.end()) {
|
||||
// Close the controller for the window.
|
||||
[controller->second cancel];
|
||||
} else if (window_id == -1) {
|
||||
// Or just close all opened controllers.
|
||||
for (auto it = popup_controllers_.begin();
|
||||
it != popup_controllers_.end();) {
|
||||
// The iterator is invalidated after the call.
|
||||
[(it++)->second cancel];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MenuMac::OnClosed(int32_t window_id, base::Closure callback) {
|
||||
popup_controllers_.erase(window_id);
|
||||
callback.Run();
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
#include "atom/browser/native_window_views.h"
|
||||
#include "atom/browser/unresponsive_suppressor.h"
|
||||
#include "content/public/browser/render_widget_host_view.h"
|
||||
#include "brightray/browser/inspectable_web_contents.h"
|
||||
#include "brightray/browser/inspectable_web_contents_view.h"
|
||||
#include "ui/display/screen.h"
|
||||
|
||||
using views::MenuRunner;
|
||||
@@ -20,30 +21,26 @@ MenuViews::MenuViews(v8::Isolate* isolate, v8::Local<v8::Object> wrapper)
|
||||
weak_factory_(this) {
|
||||
}
|
||||
|
||||
void MenuViews::PopupAt(
|
||||
Window* window, int x, int y, int positioning_item, bool async) {
|
||||
void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item,
|
||||
const base::Closure& callback) {
|
||||
NativeWindow* native_window = static_cast<NativeWindow*>(window->window());
|
||||
if (!native_window)
|
||||
return;
|
||||
content::WebContents* web_contents = native_window->web_contents();
|
||||
auto* web_contents = native_window->inspectable_web_contents();
|
||||
if (!web_contents)
|
||||
return;
|
||||
content::RenderWidgetHostView* view = web_contents->GetRenderWidgetHostView();
|
||||
if (!view)
|
||||
return;
|
||||
|
||||
// (-1, -1) means showing on mouse location.
|
||||
gfx::Point location;
|
||||
if (x == -1 || y == -1) {
|
||||
location = display::Screen::GetScreen()->GetCursorScreenPoint();
|
||||
} else {
|
||||
gfx::Point origin = view->GetViewBounds().origin();
|
||||
auto* view = web_contents->GetView()->GetWebView();
|
||||
gfx::Point origin = view->bounds().origin();
|
||||
location = gfx::Point(origin.x() + x, origin.y() + y);
|
||||
}
|
||||
|
||||
int flags = MenuRunner::CONTEXT_MENU | MenuRunner::HAS_MNEMONICS;
|
||||
if (async)
|
||||
flags |= MenuRunner::ASYNC;
|
||||
|
||||
// Don't emit unresponsive event when showing menu.
|
||||
atom::UnresponsiveSuppressor suppressor;
|
||||
@@ -51,19 +48,34 @@ void MenuViews::PopupAt(
|
||||
// Show the menu.
|
||||
int32_t window_id = window->ID();
|
||||
auto close_callback = base::Bind(
|
||||
&MenuViews::ClosePopupAt, weak_factory_.GetWeakPtr(), window_id);
|
||||
&MenuViews::OnClosed, weak_factory_.GetWeakPtr(), window_id, callback);
|
||||
menu_runners_[window_id] = std::unique_ptr<MenuRunner>(new MenuRunner(
|
||||
model(), flags, close_callback));
|
||||
ignore_result(menu_runners_[window_id]->RunMenuAt(
|
||||
menu_runners_[window_id]->RunMenuAt(
|
||||
static_cast<NativeWindowViews*>(window->window())->widget(),
|
||||
NULL,
|
||||
gfx::Rect(location, gfx::Size()),
|
||||
views::MENU_ANCHOR_TOPLEFT,
|
||||
ui::MENU_SOURCE_MOUSE));
|
||||
ui::MENU_SOURCE_MOUSE);
|
||||
}
|
||||
|
||||
void MenuViews::ClosePopupAt(int32_t window_id) {
|
||||
auto runner = menu_runners_.find(window_id);
|
||||
if (runner != menu_runners_.end()) {
|
||||
// Close the runner for the window.
|
||||
runner->second->Cancel();
|
||||
} else if (window_id == -1) {
|
||||
// Or just close all opened runners.
|
||||
for (auto it = menu_runners_.begin(); it != menu_runners_.end();) {
|
||||
// The iterator is invalidated after the call.
|
||||
(it++)->second->Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MenuViews::OnClosed(int32_t window_id, base::Closure callback) {
|
||||
menu_runners_.erase(window_id);
|
||||
callback.Run();
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
@@ -21,11 +21,13 @@ class MenuViews : public Menu {
|
||||
MenuViews(v8::Isolate* isolate, v8::Local<v8::Object> wrapper);
|
||||
|
||||
protected:
|
||||
void PopupAt(
|
||||
Window* window, int x, int y, int positioning_item, bool async) override;
|
||||
void PopupAt(Window* window, int x, int y, int positioning_item,
|
||||
const base::Closure& callback) override;
|
||||
void ClosePopupAt(int32_t window_id) override;
|
||||
|
||||
private:
|
||||
void OnClosed(int32_t window_id, base::Closure callback);
|
||||
|
||||
// window ID -> open context menu
|
||||
std::map<int32_t, std::unique_ptr<views::MenuRunner>> menu_runners_;
|
||||
|
||||
|
||||
@@ -9,13 +9,15 @@
|
||||
#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 "atom/common/node_includes.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"
|
||||
#include "url/gurl.h"
|
||||
// Must be the last in the includes list.
|
||||
// See https://github.com/electron/electron/issues/10363
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
namespace mate {
|
||||
template<>
|
||||
@@ -68,6 +70,7 @@ Notification::Notification(v8::Isolate* isolate,
|
||||
opts.Get("hasReply", &has_reply_);
|
||||
opts.Get("actions", &actions_);
|
||||
opts.Get("sound", &sound_);
|
||||
opts.Get("closeButtonText", &close_button_text_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,20 +105,24 @@ bool Notification::GetSilent() const {
|
||||
return silent_;
|
||||
}
|
||||
|
||||
bool Notification::GetHasReply() const {
|
||||
return has_reply_;
|
||||
}
|
||||
|
||||
base::string16 Notification::GetReplyPlaceholder() const {
|
||||
return reply_placeholder_;
|
||||
}
|
||||
|
||||
bool Notification::GetHasReply() const {
|
||||
return has_reply_;
|
||||
base::string16 Notification::GetSound() const {
|
||||
return sound_;
|
||||
}
|
||||
|
||||
std::vector<brightray::NotificationAction> Notification::GetActions() const {
|
||||
return actions_;
|
||||
}
|
||||
|
||||
base::string16 Notification::GetSound() const {
|
||||
return sound_;
|
||||
base::string16 Notification::GetCloseButtonText() const {
|
||||
return close_button_text_;
|
||||
}
|
||||
|
||||
// Setters
|
||||
@@ -135,12 +142,16 @@ void Notification::SetSilent(bool new_silent) {
|
||||
silent_ = new_silent;
|
||||
}
|
||||
|
||||
void Notification::SetHasReply(bool new_has_reply) {
|
||||
has_reply_ = new_has_reply;
|
||||
}
|
||||
|
||||
void Notification::SetReplyPlaceholder(const base::string16& new_placeholder) {
|
||||
reply_placeholder_ = new_placeholder;
|
||||
}
|
||||
|
||||
void Notification::SetHasReply(bool new_has_reply) {
|
||||
has_reply_ = new_has_reply;
|
||||
void Notification::SetSound(const base::string16& new_sound) {
|
||||
sound_ = new_sound;
|
||||
}
|
||||
|
||||
void Notification::SetActions(
|
||||
@@ -148,8 +159,8 @@ void Notification::SetActions(
|
||||
actions_ = actions;
|
||||
}
|
||||
|
||||
void Notification::SetSound(const base::string16& new_sound) {
|
||||
sound_ = new_sound;
|
||||
void Notification::SetCloseButtonText(const base::string16& text) {
|
||||
close_button_text_ = text;
|
||||
}
|
||||
|
||||
void Notification::NotificationAction(int index) {
|
||||
@@ -199,6 +210,7 @@ void Notification::Show() {
|
||||
options.reply_placeholder = reply_placeholder_;
|
||||
options.actions = actions_;
|
||||
options.sound = sound_;
|
||||
options.close_button_text = close_button_text_;
|
||||
notification_->Show(options);
|
||||
}
|
||||
}
|
||||
@@ -220,15 +232,18 @@ void Notification::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetProperty("subtitle", &Notification::GetSubtitle,
|
||||
&Notification::SetSubtitle)
|
||||
.SetProperty("body", &Notification::GetBody, &Notification::SetBody)
|
||||
.SetProperty("silent", &Notification::GetSilent, &Notification::SetSilent)
|
||||
.SetProperty("replyPlaceholder", &Notification::GetReplyPlaceholder,
|
||||
&Notification::SetReplyPlaceholder)
|
||||
.SetProperty("silent", &Notification::GetSilent,
|
||||
&Notification::SetSilent)
|
||||
.SetProperty("hasReply", &Notification::GetHasReply,
|
||||
&Notification::SetHasReply)
|
||||
.SetProperty("replyPlaceholder", &Notification::GetReplyPlaceholder,
|
||||
&Notification::SetReplyPlaceholder)
|
||||
.SetProperty("sound", &Notification::GetSound,
|
||||
&Notification::SetSound)
|
||||
.SetProperty("actions", &Notification::GetActions,
|
||||
&Notification::SetActions)
|
||||
.SetProperty("sound", &Notification::GetSound,
|
||||
&Notification::SetSound);
|
||||
.SetProperty("closeButtonText", &Notification::GetCloseButtonText,
|
||||
&Notification::SetCloseButtonText);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
@@ -52,20 +52,22 @@ class Notification : public mate::TrackableObject<Notification>,
|
||||
base::string16 GetSubtitle() const;
|
||||
base::string16 GetBody() const;
|
||||
bool GetSilent() const;
|
||||
base::string16 GetReplyPlaceholder() const;
|
||||
bool GetHasReply() const;
|
||||
std::vector<brightray::NotificationAction> GetActions() const;
|
||||
base::string16 GetReplyPlaceholder() const;
|
||||
base::string16 GetSound() const;
|
||||
std::vector<brightray::NotificationAction> GetActions() const;
|
||||
base::string16 GetCloseButtonText() const;
|
||||
|
||||
// Prop Setters
|
||||
void SetTitle(const base::string16& new_title);
|
||||
void SetSubtitle(const base::string16& new_subtitle);
|
||||
void SetBody(const base::string16& new_body);
|
||||
void SetSilent(bool new_silent);
|
||||
void SetReplyPlaceholder(const base::string16& new_reply_placeholder);
|
||||
void SetHasReply(bool new_has_reply);
|
||||
void SetActions(const std::vector<brightray::NotificationAction>& actions);
|
||||
void SetReplyPlaceholder(const base::string16& new_reply_placeholder);
|
||||
void SetSound(const base::string16& sound);
|
||||
void SetActions(const std::vector<brightray::NotificationAction>& actions);
|
||||
void SetCloseButtonText(const base::string16& text);
|
||||
|
||||
private:
|
||||
base::string16 title_;
|
||||
@@ -75,10 +77,11 @@ class Notification : public mate::TrackableObject<Notification>,
|
||||
base::string16 icon_path_;
|
||||
bool has_icon_ = false;
|
||||
bool silent_ = false;
|
||||
base::string16 reply_placeholder_;
|
||||
bool has_reply_ = false;
|
||||
std::vector<brightray::NotificationAction> actions_;
|
||||
base::string16 reply_placeholder_;
|
||||
base::string16 sound_;
|
||||
std::vector<brightray::NotificationAction> actions_;
|
||||
base::string16 close_button_text_;
|
||||
|
||||
brightray::NotificationPresenter* presenter_;
|
||||
|
||||
|
||||
@@ -16,6 +16,13 @@ namespace atom {
|
||||
namespace api {
|
||||
|
||||
PowerMonitor::PowerMonitor(v8::Isolate* isolate) {
|
||||
#if defined(OS_LINUX)
|
||||
SetShutdownHandler(base::Bind(&PowerMonitor::ShouldShutdown,
|
||||
base::Unretained(this)));
|
||||
#elif defined(OS_MACOSX)
|
||||
Browser::Get()->SetShutdownHandler(base::Bind(&PowerMonitor::ShouldShutdown,
|
||||
base::Unretained(this)));
|
||||
#endif
|
||||
base::PowerMonitor::Get()->AddObserver(this);
|
||||
Init(isolate);
|
||||
}
|
||||
@@ -24,6 +31,20 @@ PowerMonitor::~PowerMonitor() {
|
||||
base::PowerMonitor::Get()->RemoveObserver(this);
|
||||
}
|
||||
|
||||
bool PowerMonitor::ShouldShutdown() {
|
||||
return !Emit("shutdown");
|
||||
}
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
void PowerMonitor::BlockShutdown() {
|
||||
PowerObserverLinux::BlockShutdown();
|
||||
}
|
||||
|
||||
void PowerMonitor::UnblockShutdown() {
|
||||
PowerObserverLinux::UnblockShutdown();
|
||||
}
|
||||
#endif
|
||||
|
||||
void PowerMonitor::OnPowerStateChange(bool on_battery_power) {
|
||||
if (on_battery_power)
|
||||
Emit("on-battery");
|
||||
@@ -55,6 +76,11 @@ v8::Local<v8::Value> PowerMonitor::Create(v8::Isolate* isolate) {
|
||||
void PowerMonitor::BuildPrototype(
|
||||
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "PowerMonitor"));
|
||||
#if defined(OS_LINUX)
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("blockShutdown", &PowerMonitor::BlockShutdown)
|
||||
.SetMethod("unblockShutdown", &PowerMonitor::UnblockShutdown);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
@@ -68,10 +94,6 @@ using atom::api::PowerMonitor;
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context, void* priv) {
|
||||
#if defined(OS_MACOSX)
|
||||
base::PowerMonitorDeviceSource::AllocateSystemIOPorts();
|
||||
#endif
|
||||
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.Set("powerMonitor", PowerMonitor::Create(isolate));
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#define ATOM_BROWSER_API_ATOM_API_POWER_MONITOR_H_
|
||||
|
||||
#include "atom/browser/api/trackable_object.h"
|
||||
#include "atom/browser/lib/power_observer.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/power_monitor/power_observer.h"
|
||||
#include "native_mate/handle.h"
|
||||
|
||||
namespace atom {
|
||||
@@ -15,7 +15,7 @@ namespace atom {
|
||||
namespace api {
|
||||
|
||||
class PowerMonitor : public mate::TrackableObject<PowerMonitor>,
|
||||
public base::PowerObserver {
|
||||
public PowerObserver {
|
||||
public:
|
||||
static v8::Local<v8::Value> Create(v8::Isolate* isolate);
|
||||
|
||||
@@ -26,6 +26,15 @@ class PowerMonitor : public mate::TrackableObject<PowerMonitor>,
|
||||
explicit PowerMonitor(v8::Isolate* isolate);
|
||||
~PowerMonitor() override;
|
||||
|
||||
// Called by native calles.
|
||||
bool ShouldShutdown();
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
// Private JS APIs.
|
||||
void BlockShutdown();
|
||||
void UnblockShutdown();
|
||||
#endif
|
||||
|
||||
// base::PowerObserver implementations:
|
||||
void OnPowerStateChange(bool on_battery_power) override;
|
||||
void OnSuspend() override;
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#include <memory>
|
||||
|
||||
#include "atom/browser/api/trackable_object.h"
|
||||
#include "device/power_save_blocker/power_save_blocker.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "services/device/wake_lock/power_save_blocker/power_save_blocker.h"
|
||||
|
||||
namespace mate {
|
||||
class Dictionary;
|
||||
|
||||
@@ -78,10 +78,6 @@ class Protocol : public mate::TrackableObject<Protocol> {
|
||||
net::URLRequestJob* MaybeCreateJob(
|
||||
net::URLRequest* request,
|
||||
net::NetworkDelegate* network_delegate) const override {
|
||||
if (!request->initiator().has_value()) {
|
||||
// Don't intercept this request as it was created by `net.request`.
|
||||
return nullptr;
|
||||
}
|
||||
RequestJob* request_job = new RequestJob(request, network_delegate);
|
||||
request_job->SetHandlerInfo(isolate_, request_context_.get(), handler_);
|
||||
return request_job;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "atom/browser/atom_permission_manager.h"
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/browser/net/atom_cert_verifier.h"
|
||||
#include "atom/browser/session_preferences.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/content_converter.h"
|
||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||
@@ -32,6 +33,7 @@
|
||||
#include "brightray/browser/media/media_device_id_salt.h"
|
||||
#include "brightray/browser/net/devtools_network_conditions.h"
|
||||
#include "brightray/browser/net/devtools_network_controller_handle.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
@@ -438,6 +440,17 @@ void DownloadIdCallback(content::DownloadManager* download_manager,
|
||||
std::vector<content::DownloadItem::ReceivedSlice>());
|
||||
}
|
||||
|
||||
void SetDevToolsNetworkEmulationClientIdInIO(
|
||||
brightray::URLRequestContextGetter* context_getter,
|
||||
const std::string& client_id) {
|
||||
if (!context_getter)
|
||||
return;
|
||||
auto network_delegate =
|
||||
static_cast<AtomNetworkDelegate*>(context_getter->network_delegate());
|
||||
if (network_delegate)
|
||||
network_delegate->SetDevToolsNetworkEmulationClientId(client_id);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Session::Session(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
||||
@@ -447,6 +460,8 @@ Session::Session(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
||||
content::BrowserContext::GetDownloadManager(browser_context)->
|
||||
AddObserver(this);
|
||||
|
||||
new SessionPreferences(browser_context);
|
||||
|
||||
Init(isolate);
|
||||
AttachAsUserData(browser_context);
|
||||
}
|
||||
@@ -545,16 +560,24 @@ void Session::EnableNetworkEmulation(const mate::Dictionary& options) {
|
||||
|
||||
browser_context_->network_controller_handle()->SetNetworkState(
|
||||
devtools_network_emulation_client_id_, std::move(conditions));
|
||||
browser_context_->network_delegate()->SetDevToolsNetworkEmulationClientId(
|
||||
devtools_network_emulation_client_id_);
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(
|
||||
&SetDevToolsNetworkEmulationClientIdInIO,
|
||||
base::RetainedRef(browser_context_->url_request_context_getter()),
|
||||
devtools_network_emulation_client_id_));
|
||||
}
|
||||
|
||||
void Session::DisableNetworkEmulation() {
|
||||
std::unique_ptr<brightray::DevToolsNetworkConditions> conditions;
|
||||
browser_context_->network_controller_handle()->SetNetworkState(
|
||||
devtools_network_emulation_client_id_, std::move(conditions));
|
||||
browser_context_->network_delegate()->SetDevToolsNetworkEmulationClientId(
|
||||
std::string());
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(
|
||||
&SetDevToolsNetworkEmulationClientIdInIO,
|
||||
base::RetainedRef(browser_context_->url_request_context_getter()),
|
||||
std::string()));
|
||||
}
|
||||
|
||||
void Session::SetCertVerifyProc(v8::Local<v8::Value> val,
|
||||
@@ -620,10 +643,11 @@ void Session::SetUserAgent(const std::string& user_agent,
|
||||
mate::Arguments* args) {
|
||||
browser_context_->SetUserAgent(user_agent);
|
||||
|
||||
std::string accept_lang = l10n_util::GetApplicationLocale("");
|
||||
std::string accept_lang = g_browser_process->GetApplicationLocale();
|
||||
args->GetNext(&accept_lang);
|
||||
|
||||
auto getter = browser_context_->GetRequestContext();
|
||||
scoped_refptr<brightray::URLRequestContextGetter> getter(
|
||||
browser_context_->GetRequestContext());
|
||||
getter->GetNetworkTaskRunner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&SetUserAgentInIO, getter, accept_lang, user_agent));
|
||||
@@ -679,6 +703,19 @@ void Session::CreateInterruptedDownload(const mate::Dictionary& options) {
|
||||
length, last_modified, etag, base::Time::FromDoubleT(start_time)));
|
||||
}
|
||||
|
||||
void Session::SetPreloads(
|
||||
const std::vector<base::FilePath::StringType>& preloads) {
|
||||
auto* prefs = SessionPreferences::FromBrowserContext(browser_context());
|
||||
DCHECK(prefs);
|
||||
prefs->set_preloads(preloads);
|
||||
}
|
||||
|
||||
std::vector<base::FilePath::StringType> Session::GetPreloads() const {
|
||||
auto* prefs = SessionPreferences::FromBrowserContext(browser_context());
|
||||
DCHECK(prefs);
|
||||
return prefs->preloads();
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> Session::Cookies(v8::Isolate* isolate) {
|
||||
if (cookies_.IsEmpty()) {
|
||||
auto handle = Cookies::Create(isolate, browser_context());
|
||||
@@ -765,6 +802,8 @@ void Session::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("getBlobData", &Session::GetBlobData)
|
||||
.SetMethod("createInterruptedDownload",
|
||||
&Session::CreateInterruptedDownload)
|
||||
.SetMethod("setPreloads", &Session::SetPreloads)
|
||||
.SetMethod("getPreloads", &Session::GetPreloads)
|
||||
.SetProperty("cookies", &Session::Cookies)
|
||||
.SetProperty("protocol", &Session::Protocol)
|
||||
.SetProperty("webRequest", &Session::WebRequest);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#define ATOM_BROWSER_API_ATOM_API_SESSION_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/api/trackable_object.h"
|
||||
#include "atom/browser/atom_blob_reader.h"
|
||||
@@ -81,6 +82,8 @@ class Session: public mate::TrackableObject<Session>,
|
||||
void GetBlobData(const std::string& uuid,
|
||||
const AtomBlobReader::CompletionCallback& callback);
|
||||
void CreateInterruptedDownload(const mate::Dictionary& options);
|
||||
void SetPreloads(const std::vector<base::FilePath::StringType>& preloads);
|
||||
std::vector<base::FilePath::StringType> GetPreloads() const;
|
||||
v8::Local<v8::Value> Cookies(v8::Isolate* isolate);
|
||||
v8::Local<v8::Value> Protocol(v8::Isolate* isolate);
|
||||
v8::Local<v8::Value> WebRequest(v8::Isolate* isolate);
|
||||
|
||||
@@ -65,6 +65,7 @@ void SystemPreferences::BuildPrototype(
|
||||
&SystemPreferences::SubscribeLocalNotification)
|
||||
.SetMethod("unsubscribeLocalNotification",
|
||||
&SystemPreferences::UnsubscribeLocalNotification)
|
||||
.SetMethod("registerDefaults", &SystemPreferences::RegisterDefaults)
|
||||
.SetMethod("getUserDefault", &SystemPreferences::GetUserDefault)
|
||||
.SetMethod("setUserDefault", &SystemPreferences::SetUserDefault)
|
||||
.SetMethod("removeUserDefault", &SystemPreferences::RemoveUserDefault)
|
||||
|
||||
@@ -73,6 +73,7 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||
void UnsubscribeLocalNotification(int request_id);
|
||||
v8::Local<v8::Value> GetUserDefault(const std::string& name,
|
||||
const std::string& type);
|
||||
void RegisterDefaults(mate::Arguments* args);
|
||||
void SetUserDefault(const std::string& name,
|
||||
const std::string& type,
|
||||
mate::Arguments* args);
|
||||
|
||||
@@ -144,6 +144,28 @@ v8::Local<v8::Value> SystemPreferences::GetUserDefault(
|
||||
}
|
||||
}
|
||||
|
||||
void SystemPreferences::RegisterDefaults(mate::Arguments* args) {
|
||||
base::DictionaryValue value;
|
||||
|
||||
if(!args->GetNext(&value)) {
|
||||
args->ThrowError("Invalid userDefault data provided");
|
||||
} else {
|
||||
@try {
|
||||
NSDictionary* dict = DictionaryValueToNSDictionary(value);
|
||||
for (id key in dict) {
|
||||
id value = [dict objectForKey:key];
|
||||
if ([value isKindOfClass:[NSNull class]] || value == nil) {
|
||||
args->ThrowError("Invalid userDefault data provided");
|
||||
return;
|
||||
}
|
||||
}
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:dict];
|
||||
} @catch (NSException* exception) {
|
||||
args->ThrowError("Invalid userDefault data provided");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SystemPreferences::SetUserDefault(const std::string& name,
|
||||
const std::string& type,
|
||||
mate::Arguments* args) {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
#include "atom/browser/api/atom_api_system_preferences.h"
|
||||
|
||||
#include "atom/common/color_util.h"
|
||||
@@ -26,10 +28,10 @@ bool SystemPreferences::IsAeroGlassEnabled() {
|
||||
}
|
||||
|
||||
std::string hexColorDWORDToRGBA(DWORD color) {
|
||||
DWORD rgba = color << 8 | color >> 24;
|
||||
std::ostringstream stream;
|
||||
stream << std::hex << color;
|
||||
std::string hexColor = stream.str();
|
||||
return hexColor.substr(2) + hexColor.substr(0, 2);
|
||||
stream << std::hex << std::setw(8) << std::setfill('0') << rgba;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
std::string SystemPreferences::GetAccentColor() {
|
||||
|
||||
@@ -40,8 +40,6 @@ struct Converter<atom::TrayIcon::HighlightMode> {
|
||||
}
|
||||
}
|
||||
|
||||
// Support old boolean parameter
|
||||
// TODO(kevinsawicki): Remove in 2.0, deprecate before then with warnings
|
||||
bool highlight;
|
||||
if (ConvertFromV8(isolate, val, &highlight)) {
|
||||
if (highlight)
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/process/process_handle.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
@@ -339,7 +340,7 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
|
||||
// Obtain the session.
|
||||
std::string partition;
|
||||
mate::Handle<api::Session> session;
|
||||
if (options.Get("session", &session)) {
|
||||
if (options.Get("session", &session) && !session.IsEmpty()) {
|
||||
} else if (options.Get("partition", &partition)) {
|
||||
session = Session::FromPartition(isolate, partition);
|
||||
} else {
|
||||
@@ -377,8 +378,8 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
|
||||
options.Get("transparent", &transparent);
|
||||
|
||||
content::WebContents::CreateParams params(session->browser_context());
|
||||
auto* view = new OffScreenWebContentsView(
|
||||
transparent, base::Bind(&WebContents::OnPaint, base::Unretained(this)));
|
||||
auto* view = new OffScreenWebContentsView(transparent,
|
||||
base::Bind(&WebContents::OnPaint, base::Unretained(this)));
|
||||
params.view = view;
|
||||
params.delegate_view = view;
|
||||
|
||||
@@ -480,12 +481,7 @@ bool WebContents::DidAddMessageToConsole(content::WebContents* source,
|
||||
const base::string16& message,
|
||||
int32_t line_no,
|
||||
const base::string16& source_id) {
|
||||
if (type_ == OFF_SCREEN) {
|
||||
return false;
|
||||
} else {
|
||||
Emit("console-message", level, message, line_no, source_id);
|
||||
return true;
|
||||
}
|
||||
return Emit("console-message", level, message, line_no, source_id);
|
||||
}
|
||||
|
||||
void WebContents::OnCreateWindow(
|
||||
@@ -493,19 +489,20 @@ void WebContents::OnCreateWindow(
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const std::vector<std::string>& features,
|
||||
const scoped_refptr<content::ResourceRequestBodyImpl>& body) {
|
||||
const scoped_refptr<content::ResourceRequestBody>& body) {
|
||||
if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN)
|
||||
Emit("-new-window", target_url, frame_name, disposition, features, body);
|
||||
else
|
||||
Emit("new-window", target_url, frame_name, disposition, features);
|
||||
}
|
||||
|
||||
void WebContents::WebContentsCreated(content::WebContents* source_contents,
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
const std::string& frame_name,
|
||||
const GURL& target_url,
|
||||
content::WebContents* new_contents) {
|
||||
void WebContents::WebContentsCreated(
|
||||
content::WebContents* source_contents,
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
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);
|
||||
@@ -651,8 +648,10 @@ void WebContents::RendererResponsive(content::WebContents* source) {
|
||||
|
||||
bool WebContents::HandleContextMenu(const content::ContextMenuParams& params) {
|
||||
if (params.custom_context.is_pepper_menu) {
|
||||
Emit("pepper-context-menu", std::make_pair(params, web_contents()));
|
||||
web_contents()->NotifyContextMenuClosed(params.custom_context);
|
||||
Emit("pepper-context-menu",
|
||||
std::make_pair(params, web_contents()),
|
||||
base::Bind(&content::WebContents::NotifyContextMenuClosed,
|
||||
base::Unretained(web_contents()), params.custom_context));
|
||||
} else {
|
||||
Emit("context-menu", std::make_pair(params, web_contents()));
|
||||
}
|
||||
@@ -836,10 +835,10 @@ void WebContents::DidFinishNavigation(
|
||||
bool is_main_frame = navigation_handle->IsInMainFrame();
|
||||
if (navigation_handle->HasCommitted() && !navigation_handle->IsErrorPage()) {
|
||||
auto url = navigation_handle->GetURL();
|
||||
bool is_in_page = navigation_handle->IsSameDocument();
|
||||
if (is_main_frame && !is_in_page) {
|
||||
bool is_same_document = navigation_handle->IsSameDocument();
|
||||
if (is_main_frame && !is_same_document) {
|
||||
Emit("did-navigate", url);
|
||||
} else if (is_in_page) {
|
||||
} else if (is_same_document) {
|
||||
Emit("did-navigate-in-page", url, is_main_frame);
|
||||
}
|
||||
} else {
|
||||
@@ -864,7 +863,7 @@ void WebContents::DidUpdateFaviconURL(
|
||||
const std::vector<content::FaviconURL>& urls) {
|
||||
std::set<GURL> unique_urls;
|
||||
for (const auto& iter : urls) {
|
||||
if (iter.icon_type != content::FaviconURL::FAVICON)
|
||||
if (iter.icon_type != content::FaviconURL::IconType::kFavicon)
|
||||
continue;
|
||||
const GURL& url = iter.icon_url;
|
||||
if (url.is_valid())
|
||||
@@ -893,10 +892,11 @@ void WebContents::DevToolsOpened() {
|
||||
managed_web_contents()->CallClientFunction(
|
||||
"DevToolsAPI.setInspectedTabId", &tab_id, nullptr, nullptr);
|
||||
|
||||
// Inherit owner window in devtools.
|
||||
if (owner_window())
|
||||
handle->SetOwnerWindow(managed_web_contents()->GetDevToolsWebContents(),
|
||||
owner_window());
|
||||
// Inherit owner window in devtools when it doesn't have one.
|
||||
auto* devtools = managed_web_contents()->GetDevToolsWebContents();
|
||||
bool has_window = devtools->GetUserData(NativeWindowRelay::UserDataKey());
|
||||
if (owner_window() && !has_window)
|
||||
handle->SetOwnerWindow(devtools, owner_window());
|
||||
|
||||
Emit("devtools-opened");
|
||||
}
|
||||
@@ -986,7 +986,7 @@ void WebContents::WebContentsDestroyed() {
|
||||
void WebContents::NavigationEntryCommitted(
|
||||
const content::LoadCommittedDetails& details) {
|
||||
Emit("navigation-entry-commited", details.entry->GetURL(),
|
||||
details.is_in_page, details.did_replace_entry);
|
||||
details.is_same_document, details.did_replace_entry);
|
||||
}
|
||||
|
||||
int64_t WebContents::GetID() const {
|
||||
@@ -1042,7 +1042,7 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
|
||||
if (options.Get("extraHeaders", &extra_headers))
|
||||
params.extra_headers = extra_headers;
|
||||
|
||||
scoped_refptr<content::ResourceRequestBodyImpl> body;
|
||||
scoped_refptr<content::ResourceRequestBody> body;
|
||||
if (options.Get("postData", &body)) {
|
||||
params.post_data = body;
|
||||
params.load_type = content::NavigationController::LOAD_TYPE_HTTP_POST;
|
||||
@@ -1083,7 +1083,7 @@ void WebContents::DownloadURL(const GURL& url) {
|
||||
|
||||
download_manager->DownloadUrl(
|
||||
content::DownloadUrlParameters::CreateForWebContentsMainFrame(
|
||||
web_contents(), url));
|
||||
web_contents(), url, NO_TRAFFIC_ANNOTATION_YET));
|
||||
}
|
||||
|
||||
GURL WebContents::GetURL() const {
|
||||
@@ -1176,7 +1176,8 @@ void WebContents::OpenDevTools(mate::Arguments* args) {
|
||||
std::string state;
|
||||
if (type_ == WEB_VIEW || !owner_window()) {
|
||||
state = "detach";
|
||||
} else if (args && args->Length() == 1) {
|
||||
}
|
||||
if (args && args->Length() == 1) {
|
||||
bool detach = false;
|
||||
mate::Dictionary options;
|
||||
if (args->GetNext(&options)) {
|
||||
@@ -1335,6 +1336,7 @@ void WebContents::Print(mate::Arguments* args) {
|
||||
std::vector<printing::PrinterBasicInfo> WebContents::GetPrinterList() {
|
||||
std::vector<printing::PrinterBasicInfo> printers;
|
||||
auto print_backend = printing::PrintBackend::CreateInstance(nullptr);
|
||||
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
||||
print_backend->EnumeratePrinters(&printers);
|
||||
return printers;
|
||||
}
|
||||
@@ -1476,7 +1478,8 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
|
||||
if (!view)
|
||||
return;
|
||||
|
||||
int type = mate::GetWebInputEventType(isolate, input_event);
|
||||
blink::WebInputEvent::Type type = mate::GetWebInputEventType(isolate,
|
||||
input_event);
|
||||
if (blink::WebInputEvent::IsMouseEventType(type)) {
|
||||
blink::WebMouseEvent mouse_event;
|
||||
if (mate::ConvertFromV8(isolate, input_event, &mouse_event)) {
|
||||
@@ -1489,7 +1492,7 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
|
||||
blink::WebInputEvent::kNoModifiers,
|
||||
ui::EventTimeForNow());
|
||||
if (mate::ConvertFromV8(isolate, input_event, &keyboard_event)) {
|
||||
view->ProcessKeyboardEvent(keyboard_event);
|
||||
view->ProcessKeyboardEvent(keyboard_event, ui::LatencyInfo());
|
||||
return;
|
||||
}
|
||||
} else if (type == blink::WebInputEvent::kMouseWheel) {
|
||||
@@ -1644,10 +1647,10 @@ void WebContents::StartPainting() {
|
||||
return;
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
|
||||
web_contents()->GetRenderWidgetHostView());
|
||||
if (osr_rwhv)
|
||||
osr_rwhv->SetPainting(true);
|
||||
const auto* wc_impl = static_cast<content::WebContentsImpl*>(web_contents());
|
||||
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
|
||||
if (osr_wcv)
|
||||
osr_wcv->SetPainting(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1656,10 +1659,10 @@ void WebContents::StopPainting() {
|
||||
return;
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
|
||||
web_contents()->GetRenderWidgetHostView());
|
||||
if (osr_rwhv)
|
||||
osr_rwhv->SetPainting(false);
|
||||
const auto* wc_impl = static_cast<content::WebContentsImpl*>(web_contents());
|
||||
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
|
||||
if (osr_wcv)
|
||||
osr_wcv->SetPainting(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1668,9 +1671,10 @@ bool WebContents::IsPainting() const {
|
||||
return false;
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
const auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
|
||||
web_contents()->GetRenderWidgetHostView());
|
||||
return osr_rwhv && osr_rwhv->IsPainting();
|
||||
const auto* wc_impl = static_cast<content::WebContentsImpl*>(web_contents());
|
||||
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
|
||||
|
||||
return osr_wcv && osr_wcv->IsPainting();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
@@ -1681,10 +1685,11 @@ void WebContents::SetFrameRate(int frame_rate) {
|
||||
return;
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
|
||||
web_contents()->GetRenderWidgetHostView());
|
||||
if (osr_rwhv)
|
||||
osr_rwhv->SetFrameRate(frame_rate);
|
||||
const auto* wc_impl = static_cast<content::WebContentsImpl*>(web_contents());
|
||||
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
|
||||
|
||||
if (osr_wcv)
|
||||
osr_wcv->SetFrameRate(frame_rate);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1693,9 +1698,10 @@ int WebContents::GetFrameRate() const {
|
||||
return 0;
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
const auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
|
||||
web_contents()->GetRenderWidgetHostView());
|
||||
return osr_rwhv ? osr_rwhv->GetFrameRate() : 0;
|
||||
const auto* wc_impl = static_cast<content::WebContentsImpl*>(web_contents());
|
||||
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
|
||||
|
||||
return osr_wcv ? osr_wcv->GetFrameRate() : 0;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
@@ -1805,6 +1811,11 @@ void WebContents::SetEmbedder(const WebContents* embedder) {
|
||||
}
|
||||
}
|
||||
|
||||
void WebContents::SetDevToolsWebContents(const WebContents* devtools) {
|
||||
if (managed_web_contents())
|
||||
managed_web_contents()->SetDevToolsWebContents(devtools->web_contents());
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> WebContents::GetNativeView() const {
|
||||
gfx::NativeView ptr = web_contents()->GetNativeView();
|
||||
auto buffer = node::Buffer::Copy(
|
||||
@@ -1926,6 +1937,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("copyImageAt", &WebContents::CopyImageAt)
|
||||
.SetMethod("capturePage", &WebContents::CapturePage)
|
||||
.SetMethod("setEmbedder", &WebContents::SetEmbedder)
|
||||
.SetMethod("setDevToolsWebContents", &WebContents::SetDevToolsWebContents)
|
||||
.SetMethod("getNativeView", &WebContents::GetNativeView)
|
||||
.SetMethod("setWebRTCIPHandlingPolicy",
|
||||
&WebContents::SetWebRTCIPHandlingPolicy)
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "atom/browser/ui/autofill_popup.h"
|
||||
#include "content/common/cursors/webcursor.h"
|
||||
#include "content/public/browser/keyboard_event_processing_result.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "content/public/common/favicon_url.h"
|
||||
#include "native_mate/handle.h"
|
||||
@@ -30,7 +31,7 @@ class InspectableWebContents;
|
||||
}
|
||||
|
||||
namespace content {
|
||||
class ResourceRequestBodyImpl;
|
||||
class ResourceRequestBody;
|
||||
}
|
||||
|
||||
namespace mate {
|
||||
@@ -125,6 +126,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
void Print(mate::Arguments* args);
|
||||
std::vector<printing::PrinterBasicInfo> GetPrinterList();
|
||||
void SetEmbedder(const WebContents* embedder);
|
||||
void SetDevToolsWebContents(const WebContents* devtools);
|
||||
v8::Local<v8::Value> GetNativeView() const;
|
||||
|
||||
// Print current page as PDF.
|
||||
@@ -208,7 +210,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const std::vector<std::string>& features,
|
||||
const scoped_refptr<content::ResourceRequestBodyImpl>& body);
|
||||
const scoped_refptr<content::ResourceRequestBody>& body);
|
||||
|
||||
// Returns the web preferences of current WebContents.
|
||||
v8::Local<v8::Value> GetWebPreferences(v8::Isolate* isolate);
|
||||
@@ -247,12 +249,14 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
const base::string16& message,
|
||||
int32_t line_no,
|
||||
const base::string16& source_id) override;
|
||||
void WebContentsCreated(content::WebContents* source_contents,
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
const std::string& frame_name,
|
||||
const GURL& target_url,
|
||||
content::WebContents* new_contents) override;
|
||||
void WebContentsCreated(
|
||||
content::WebContents* source_contents,
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
const std::string& frame_name,
|
||||
const GURL& target_url,
|
||||
content::WebContents* new_contents)
|
||||
override;
|
||||
void AddNewContents(content::WebContents* source,
|
||||
content::WebContents* new_contents,
|
||||
WindowOpenDisposition disposition,
|
||||
|
||||
@@ -74,10 +74,16 @@ void WebRequest::SetListener(Method method, Event type, mate::Arguments* args) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto delegate = browser_context_->network_delegate();
|
||||
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(method, base::Unretained(delegate), type,
|
||||
patterns, listener));
|
||||
auto url_request_context_getter =
|
||||
browser_context_->url_request_context_getter();
|
||||
if (!url_request_context_getter)
|
||||
return;
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(method,
|
||||
base::Unretained(static_cast<AtomNetworkDelegate*>(
|
||||
url_request_context_getter->network_delegate())),
|
||||
type, patterns, listener));
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
@@ -7,10 +7,12 @@
|
||||
#include "atom/browser/web_view_manager.h"
|
||||
#include "atom/common/native_mate_converters/content_converter.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
// Must be the last in the includes list.
|
||||
// See https://github.com/electron/electron/issues/10363
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
using atom::WebContentsPreferences;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/api/atom_api_window.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
|
||||
#include "atom/browser/api/atom_api_browser_view.h"
|
||||
#include "atom/browser/api/atom_api_menu.h"
|
||||
@@ -17,6 +16,7 @@
|
||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||
#include "atom/common/native_mate_converters/image_converter.h"
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
@@ -101,7 +101,7 @@ Window::Window(v8::Isolate* isolate, v8::Local<v8::Object> wrapper,
|
||||
}
|
||||
#endif
|
||||
|
||||
if (options.Get("webContents", &web_contents)) {
|
||||
if (options.Get("webContents", &web_contents) && !web_contents.IsEmpty()) {
|
||||
// Set webPreferences from options if using an existing webContents.
|
||||
// These preferences will be used when the webContent launches new
|
||||
// render processes.
|
||||
@@ -135,7 +135,7 @@ void Window::Init(v8::Isolate* isolate,
|
||||
|
||||
// The parent window.
|
||||
mate::Handle<Window> parent;
|
||||
if (options.Get("parent", &parent))
|
||||
if (options.Get("parent", &parent) && !parent.IsEmpty())
|
||||
parent_window_.Reset(isolate, parent.ToV8());
|
||||
|
||||
// Creates BrowserWindow.
|
||||
@@ -149,7 +149,7 @@ void Window::Init(v8::Isolate* isolate,
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
// Sets the window icon.
|
||||
mate::Handle<NativeImage> icon;
|
||||
if (options.Get(options::kIcon, &icon))
|
||||
if (options.Get(options::kIcon, &icon) && !icon.IsEmpty())
|
||||
SetIcon(icon);
|
||||
#endif
|
||||
|
||||
@@ -184,7 +184,7 @@ void Window::WillDestroyNativeObject() {
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
for (v8::Local<v8::Value> value : child_windows_.Values(isolate())) {
|
||||
mate::Handle<Window> child;
|
||||
if (mate::ConvertFromV8(isolate(), value, &child))
|
||||
if (mate::ConvertFromV8(isolate(), value, &child) && !child.IsEmpty())
|
||||
child->window_->CloseImmediately();
|
||||
}
|
||||
}
|
||||
@@ -393,6 +393,10 @@ bool Window::IsEnabled() {
|
||||
return window_->IsEnabled();
|
||||
}
|
||||
|
||||
void Window::SetEnabled(bool enable) {
|
||||
window_->SetEnabled(enable);
|
||||
}
|
||||
|
||||
void Window::Maximize() {
|
||||
window_->Maximize();
|
||||
}
|
||||
@@ -727,7 +731,7 @@ void Window::SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> value) {
|
||||
mate::Handle<Menu> menu;
|
||||
if (value->IsObject() &&
|
||||
mate::V8ToString(value->ToObject()->GetConstructorName()) == "Menu" &&
|
||||
mate::ConvertFromV8(isolate, value, &menu)) {
|
||||
mate::ConvertFromV8(isolate, value, &menu) && !menu.IsEmpty()) {
|
||||
menu_.Reset(isolate, menu.ToV8());
|
||||
window_->SetMenu(menu->model());
|
||||
} else if (value->IsNull()) {
|
||||
@@ -847,7 +851,7 @@ void Window::SetParentWindow(v8::Local<v8::Value> value,
|
||||
}
|
||||
|
||||
mate::Handle<Window> parent;
|
||||
if (value->IsNull()) {
|
||||
if (value->IsNull() || value->IsUndefined()) {
|
||||
RemoveFromParentChildWindows();
|
||||
parent_window_.Reset();
|
||||
window_->SetParentWindow(nullptr);
|
||||
@@ -883,7 +887,7 @@ void Window::SetBrowserView(v8::Local<v8::Value> value) {
|
||||
ResetBrowserView();
|
||||
|
||||
mate::Handle<BrowserView> browser_view;
|
||||
if (value->IsNull()) {
|
||||
if (value->IsNull() || value->IsUndefined()) {
|
||||
window_->SetBrowserView(nullptr);
|
||||
} else if (mate::ConvertFromV8(isolate(), value, &browser_view)) {
|
||||
window_->SetBrowserView(browser_view->view());
|
||||
@@ -898,7 +902,8 @@ void Window::ResetBrowserView() {
|
||||
}
|
||||
|
||||
mate::Handle<BrowserView> browser_view;
|
||||
if (mate::ConvertFromV8(isolate(), GetBrowserView(), &browser_view)) {
|
||||
if (mate::ConvertFromV8(isolate(), GetBrowserView(), &browser_view)
|
||||
&& !browser_view.IsEmpty()) {
|
||||
browser_view->web_contents()->SetOwnerWindow(nullptr);
|
||||
}
|
||||
|
||||
@@ -987,8 +992,10 @@ void Window::RemoveFromParentChildWindows() {
|
||||
return;
|
||||
|
||||
mate::Handle<Window> parent;
|
||||
if (!mate::ConvertFromV8(isolate(), GetParentWindow(), &parent))
|
||||
if (!mate::ConvertFromV8(isolate(), GetParentWindow(), &parent)
|
||||
|| parent.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
parent->child_windows_.Remove(ID());
|
||||
}
|
||||
@@ -1008,6 +1015,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("hide", &Window::Hide)
|
||||
.SetMethod("isVisible", &Window::IsVisible)
|
||||
.SetMethod("isEnabled", &Window::IsEnabled)
|
||||
.SetMethod("setEnabled", & Window::SetEnabled)
|
||||
.SetMethod("maximize", &Window::Maximize)
|
||||
.SetMethod("unmaximize", &Window::Unmaximize)
|
||||
.SetMethod("isMaximized", &Window::IsMaximized)
|
||||
|
||||
@@ -112,6 +112,7 @@ class Window : public mate::TrackableObject<Window>,
|
||||
void Hide();
|
||||
bool IsVisible();
|
||||
bool IsEnabled();
|
||||
void SetEnabled(bool enable);
|
||||
void Maximize();
|
||||
void Unmaximize();
|
||||
bool IsMaximized();
|
||||
|
||||
@@ -42,8 +42,10 @@ class EventEmitter : public Wrappable<T> {
|
||||
|
||||
// Make the convinient methods visible:
|
||||
// https://isocpp.org/wiki/faq/templates#nondependent-name-lookup-members
|
||||
v8::Local<v8::Object> GetWrapper() { return Wrappable<T>::GetWrapper(); }
|
||||
v8::Isolate* isolate() const { return Wrappable<T>::isolate(); }
|
||||
v8::Local<v8::Object> GetWrapper() const {
|
||||
return Wrappable<T>::GetWrapper();
|
||||
}
|
||||
|
||||
// this.emit(name, event, args...);
|
||||
template<typename... Args>
|
||||
|
||||
@@ -65,7 +65,7 @@ EventSubscriberBase::~EventSubscriberBase() {
|
||||
}
|
||||
RemoveAllListeners();
|
||||
emitter_.Reset();
|
||||
DCHECK_EQ(js_handlers_.size(), 0);
|
||||
DCHECK_EQ(js_handlers_.size(), 0u);
|
||||
}
|
||||
|
||||
void EventSubscriberBase::On(const std::string& event_name) {
|
||||
|
||||
@@ -73,6 +73,13 @@ class EventSubscriber : internal::EventSubscriberBase {
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(
|
||||
[](EventSubscriber<HandlerType>* subscriber) {
|
||||
{
|
||||
// It is possible that this function will execute in the UI
|
||||
// thread before the outer function has returned and destroyed
|
||||
// its auto_lock. We need to acquire the lock before deleting
|
||||
// or risk a crash.
|
||||
base::AutoLock auto_lock(subscriber->handler_lock_);
|
||||
}
|
||||
delete subscriber;
|
||||
},
|
||||
ptr));
|
||||
|
||||
@@ -89,7 +89,6 @@ void FrameSubscriber::OnFrameDelivered(const FrameCaptureCallback& callback,
|
||||
auto local_buffer = buffer.ToLocalChecked();
|
||||
|
||||
{
|
||||
SkAutoLockPixels lock(bitmap);
|
||||
auto source = static_cast<const unsigned char*>(bitmap.getPixels());
|
||||
auto target = node::Buffer::Data(local_buffer);
|
||||
|
||||
|
||||
@@ -29,8 +29,7 @@ class GeoURLRequestContextGetter : public net::URLRequestContextGetter {
|
||||
net::URLRequestContextBuilder builder;
|
||||
builder.set_proxy_config_service(
|
||||
net::ProxyService::CreateSystemProxyConfigService(
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)));
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)));
|
||||
url_request_context_ = builder.Build();
|
||||
}
|
||||
return url_request_context_.get();
|
||||
@@ -55,7 +54,6 @@ class GeoURLRequestContextGetter : public net::URLRequestContextGetter {
|
||||
|
||||
AtomAccessTokenStore::AtomAccessTokenStore()
|
||||
: request_context_getter_(new internal::GeoURLRequestContextGetter) {
|
||||
device::GeolocationProvider::GetInstance()->UserDidOptIntoLocationServices();
|
||||
}
|
||||
|
||||
AtomAccessTokenStore::~AtomAccessTokenStore() {
|
||||
|
||||
@@ -72,8 +72,7 @@ void AtomBlobReader::StartReading(
|
||||
}
|
||||
|
||||
auto blob_reader = blob_data_handle->CreateReader(
|
||||
file_system_context_.get(),
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get());
|
||||
file_system_context_.get());
|
||||
BlobReadHelper* blob_read_helper =
|
||||
new BlobReadHelper(std::move(blob_reader), callback);
|
||||
blob_read_helper->Read();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "atom/browser/atom_speech_recognition_manager_delegate.h"
|
||||
#include "atom/browser/child_web_contents_tracker.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/session_preferences.h"
|
||||
#include "atom/browser/web_contents_permission_helper.h"
|
||||
#include "atom/browser/web_contents_preferences.h"
|
||||
#include "atom/browser/window_list.h"
|
||||
@@ -30,7 +31,6 @@
|
||||
#include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
|
||||
#include "chrome/browser/renderer_host/pepper/widevine_cdm_message_filter.h"
|
||||
#include "chrome/browser/speech/tts_message_filter.h"
|
||||
#include "content/common/resource_request_body_impl.h"
|
||||
#include "content/public/browser/browser_ppapi_host.h"
|
||||
#include "content/public/browser/client_certificate_delegate.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
@@ -38,7 +38,9 @@
|
||||
#include "content/public/browser/resource_dispatcher_host.h"
|
||||
#include "content/public/browser/site_instance.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/content_paths.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "content/public/common/resource_request_body.h"
|
||||
#include "content/public/common/url_constants.h"
|
||||
#include "content/public/common/web_preferences.h"
|
||||
#include "net/ssl/ssl_cert_request_info.h"
|
||||
@@ -165,11 +167,14 @@ void AtomBrowserClient::RenderProcessWillLaunch(
|
||||
|
||||
content::WebContents* web_contents = GetWebContentsFromProcessID(process_id);
|
||||
ProcessPreferences process_prefs;
|
||||
process_prefs.sandbox = WebContentsPreferences::IsSandboxed(web_contents);
|
||||
process_prefs.native_window_open
|
||||
= WebContentsPreferences::UsesNativeWindowOpen(web_contents);
|
||||
process_prefs.disable_popups
|
||||
= WebContentsPreferences::DisablePopups(web_contents);
|
||||
process_prefs.sandbox =
|
||||
WebContentsPreferences::IsPreferenceEnabled("sandbox", web_contents);
|
||||
process_prefs.native_window_open =
|
||||
WebContentsPreferences::IsPreferenceEnabled("nativeWindowOpen",
|
||||
web_contents);
|
||||
process_prefs.disable_popups =
|
||||
WebContentsPreferences::IsPreferenceEnabled("disablePopups",
|
||||
web_contents);
|
||||
AddProcessPreferences(host->GetID(), process_prefs);
|
||||
// ensure the ProcessPreferences is removed later
|
||||
host->AddObserver(this);
|
||||
@@ -184,7 +189,6 @@ void AtomBrowserClient::OverrideWebkitPrefs(
|
||||
content::RenderViewHost* host, content::WebPreferences* prefs) {
|
||||
prefs->javascript_enabled = true;
|
||||
prefs->web_security_enabled = true;
|
||||
prefs->javascript_can_open_windows_automatically = true;
|
||||
prefs->plugins_enabled = true;
|
||||
prefs->dom_paste_enabled = true;
|
||||
prefs->allow_scripts_to_close_windows = true;
|
||||
@@ -202,12 +206,8 @@ void AtomBrowserClient::OverrideWebkitPrefs(
|
||||
WebContentsPreferences::OverrideWebkitPrefs(web_contents, prefs);
|
||||
}
|
||||
|
||||
std::string AtomBrowserClient::GetApplicationLocale() {
|
||||
return l10n_util::GetApplicationLocale("");
|
||||
}
|
||||
|
||||
void AtomBrowserClient::OverrideSiteInstanceForNavigation(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
content::RenderFrameHost* rfh,
|
||||
content::BrowserContext* browser_context,
|
||||
content::SiteInstance* current_instance,
|
||||
const GURL& url,
|
||||
@@ -217,32 +217,67 @@ void AtomBrowserClient::OverrideSiteInstanceForNavigation(
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ShouldCreateNewSiteInstance(render_frame_host, browser_context,
|
||||
current_instance, url))
|
||||
if (!ShouldCreateNewSiteInstance(rfh, browser_context, current_instance, url))
|
||||
return;
|
||||
|
||||
scoped_refptr<content::SiteInstance> site_instance =
|
||||
content::SiteInstance::CreateForURL(browser_context, url);
|
||||
bool is_new_instance = true;
|
||||
scoped_refptr<content::SiteInstance> site_instance;
|
||||
|
||||
// Do we have an affinity site to manage ?
|
||||
std::string affinity;
|
||||
auto* web_contents = content::WebContents::FromRenderFrameHost(rfh);
|
||||
auto* web_preferences = web_contents ?
|
||||
WebContentsPreferences::FromWebContents(web_contents) : nullptr;
|
||||
if (web_preferences &&
|
||||
web_preferences->web_preferences()->GetString("affinity", &affinity) &&
|
||||
!affinity.empty()) {
|
||||
affinity = base::ToLowerASCII(affinity);
|
||||
auto iter = site_per_affinities.find(affinity);
|
||||
if (iter != site_per_affinities.end()) {
|
||||
site_instance = iter->second;
|
||||
is_new_instance = false;
|
||||
} else {
|
||||
// We must not provide the url.
|
||||
// This site is "isolated" and must not be taken into account
|
||||
// when Chromium looking at a candidate for an url.
|
||||
site_instance = content::SiteInstance::Create(
|
||||
browser_context);
|
||||
site_per_affinities[affinity] = site_instance.get();
|
||||
}
|
||||
} else {
|
||||
site_instance = content::SiteInstance::CreateForURL(
|
||||
browser_context,
|
||||
url);
|
||||
}
|
||||
*new_instance = site_instance.get();
|
||||
|
||||
// Make sure the |site_instance| is not freed when this function returns.
|
||||
// FIXME(zcbenz): We should adjust OverrideSiteInstanceForNavigation's
|
||||
// interface to solve this.
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(&Noop, base::RetainedRef(site_instance)));
|
||||
if (is_new_instance) {
|
||||
// Make sure the |site_instance| is not freed
|
||||
// when this function returns.
|
||||
// FIXME(zcbenz): We should adjust
|
||||
// OverrideSiteInstanceForNavigation's interface to solve this.
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(&Noop, base::RetainedRef(site_instance)));
|
||||
|
||||
// Remember the original web contents for the pending renderer process.
|
||||
auto pending_process = (*new_instance)->GetProcess();
|
||||
pending_processes_[pending_process->GetID()] =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);;
|
||||
// Clear the entry in map when process ends.
|
||||
pending_process->AddObserver(this);
|
||||
// Remember the original web contents for the pending renderer process.
|
||||
auto pending_process = site_instance->GetProcess();
|
||||
pending_processes_[pending_process->GetID()] = web_contents;
|
||||
}
|
||||
}
|
||||
|
||||
void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
||||
base::CommandLine* command_line,
|
||||
int process_id) {
|
||||
// Make sure we're about to launch a known executable
|
||||
{
|
||||
base::FilePath child_path;
|
||||
PathService::Get(content::CHILD_PROCESS_EXE, &child_path);
|
||||
|
||||
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
||||
CHECK(base::MakeAbsoluteFilePath(command_line->GetProgram()) == child_path);
|
||||
}
|
||||
|
||||
std::string process_type =
|
||||
command_line->GetSwitchValueASCII(::switches::kProcessType);
|
||||
if (process_type != ::switches::kRendererProcess)
|
||||
@@ -278,9 +313,12 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
||||
}
|
||||
|
||||
content::WebContents* web_contents = GetWebContentsFromProcessID(process_id);
|
||||
if (web_contents)
|
||||
if (web_contents) {
|
||||
WebContentsPreferences::AppendExtraCommandLineSwitches(
|
||||
web_contents, command_line);
|
||||
SessionPreferences::AppendExtraCommandLineSwitches(
|
||||
web_contents->GetBrowserContext(), command_line);
|
||||
}
|
||||
}
|
||||
|
||||
void AtomBrowserClient::DidCreatePpapiPlugin(
|
||||
@@ -316,10 +354,12 @@ void AtomBrowserClient::AllowCertificateError(
|
||||
void AtomBrowserClient::SelectClientCertificate(
|
||||
content::WebContents* web_contents,
|
||||
net::SSLCertRequestInfo* cert_request_info,
|
||||
net::ClientCertIdentityList client_certs,
|
||||
std::unique_ptr<content::ClientCertificateDelegate> delegate) {
|
||||
if (!cert_request_info->client_certs.empty() && delegate_) {
|
||||
delegate_->SelectClientCertificate(
|
||||
web_contents, cert_request_info, std::move(delegate));
|
||||
if (!client_certs.empty() && delegate_) {
|
||||
delegate_->SelectClientCertificate(web_contents, cert_request_info,
|
||||
std::move(client_certs),
|
||||
std::move(delegate));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,8 +371,7 @@ void AtomBrowserClient::ResourceDispatcherHostCreated() {
|
||||
}
|
||||
|
||||
bool AtomBrowserClient::CanCreateWindow(
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
content::RenderFrameHost* opener,
|
||||
const GURL& opener_url,
|
||||
const GURL& opener_top_level_frame_url,
|
||||
const GURL& source_origin,
|
||||
@@ -343,12 +382,13 @@ bool AtomBrowserClient::CanCreateWindow(
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::mojom::WindowFeatures& features,
|
||||
const std::vector<std::string>& additional_features,
|
||||
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
|
||||
const scoped_refptr<content::ResourceRequestBody>& body,
|
||||
bool user_gesture,
|
||||
bool opener_suppressed,
|
||||
content::ResourceContext* context,
|
||||
bool* no_javascript_access) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
|
||||
int opener_render_process_id = opener->GetProcess()->GetID();
|
||||
|
||||
if (IsRendererSandboxed(opener_render_process_id)) {
|
||||
*no_javascript_access = false;
|
||||
@@ -367,16 +407,11 @@ bool AtomBrowserClient::CanCreateWindow(
|
||||
}
|
||||
|
||||
if (delegate_) {
|
||||
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(&api::App::OnCreateWindow,
|
||||
base::Unretained(static_cast<api::App*>(delegate_)),
|
||||
target_url,
|
||||
frame_name,
|
||||
disposition,
|
||||
additional_features,
|
||||
body,
|
||||
opener_render_process_id,
|
||||
opener_render_frame_id));
|
||||
return delegate_->CanCreateWindow(
|
||||
opener, opener_url, opener_top_level_frame_url, source_origin,
|
||||
container_type, target_url, referrer, frame_name, disposition, features,
|
||||
additional_features, body, user_gesture, opener_suppressed,
|
||||
no_javascript_access);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -392,6 +427,19 @@ void AtomBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
|
||||
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) {
|
||||
if (iter->second == site_instance) {
|
||||
site_per_affinities.erase(iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
brightray::BrowserMainParts* AtomBrowserClient::OverrideCreateBrowserMainParts(
|
||||
const content::MainFunctionParams&) {
|
||||
v8::V8::Initialize(); // Init V8 before creating main parts.
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "brightray/browser/browser_client.h"
|
||||
#include "content/public/browser/render_process_host_observer.h"
|
||||
#include "net/ssl/client_cert_identity.h"
|
||||
|
||||
namespace content {
|
||||
class QuotaPermissionContext;
|
||||
@@ -52,7 +53,6 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
CreateSpeechRecognitionManagerDelegate() override;
|
||||
void OverrideWebkitPrefs(content::RenderViewHost* render_view_host,
|
||||
content::WebPreferences* prefs) override;
|
||||
std::string GetApplicationLocale() override;
|
||||
void OverrideSiteInstanceForNavigation(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
content::BrowserContext* browser_context,
|
||||
@@ -77,11 +77,11 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
void SelectClientCertificate(
|
||||
content::WebContents* web_contents,
|
||||
net::SSLCertRequestInfo* cert_request_info,
|
||||
net::ClientCertIdentityList client_certs,
|
||||
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
|
||||
void ResourceDispatcherHostCreated() override;
|
||||
bool CanCreateWindow(
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
content::RenderFrameHost* opener,
|
||||
const GURL& opener_url,
|
||||
const GURL& opener_top_level_frame_url,
|
||||
const GURL& source_origin,
|
||||
@@ -92,13 +92,13 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::mojom::WindowFeatures& features,
|
||||
const std::vector<std::string>& additional_features,
|
||||
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
|
||||
const scoped_refptr<content::ResourceRequestBody>& body,
|
||||
bool user_gesture,
|
||||
bool opener_suppressed,
|
||||
content::ResourceContext* context,
|
||||
bool* no_javascript_access) override;
|
||||
void GetAdditionalAllowedSchemesForFileSystem(
|
||||
std::vector<std::string>* schemes) override;
|
||||
void SiteInstanceDeleting(content::SiteInstance* site_instance) override;
|
||||
|
||||
// brightray::BrowserClient:
|
||||
brightray::BrowserMainParts* OverrideCreateBrowserMainParts(
|
||||
@@ -120,9 +120,9 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
content::SiteInstance* current_instance,
|
||||
const GURL& dest_url);
|
||||
struct ProcessPreferences {
|
||||
bool sandbox;
|
||||
bool native_window_open;
|
||||
bool disable_popups;
|
||||
bool sandbox = false;
|
||||
bool native_window_open = false;
|
||||
bool disable_popups = false;
|
||||
};
|
||||
void AddProcessPreferences(int process_id, ProcessPreferences prefs);
|
||||
void RemoveProcessPreferences(int process_id);
|
||||
@@ -135,6 +135,10 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
|
||||
std::map<int, ProcessPreferences> process_preferences_;
|
||||
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;
|
||||
|
||||
base::Lock process_preferences_lock_;
|
||||
|
||||
std::unique_ptr<AtomResourceDispatcherHostDelegate>
|
||||
|
||||
@@ -71,7 +71,6 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition,
|
||||
bool in_memory,
|
||||
const base::DictionaryValue& options)
|
||||
: brightray::BrowserContext(partition, in_memory),
|
||||
network_delegate_(new AtomNetworkDelegate),
|
||||
cookie_delegate_(new AtomCookieDelegate) {
|
||||
// Construct user agent string.
|
||||
Browser* browser = Browser::Get();
|
||||
@@ -104,8 +103,9 @@ void AtomBrowserContext::SetUserAgent(const std::string& user_agent) {
|
||||
user_agent_ = user_agent;
|
||||
}
|
||||
|
||||
net::NetworkDelegate* AtomBrowserContext::CreateNetworkDelegate() {
|
||||
return network_delegate_;
|
||||
std::unique_ptr<net::NetworkDelegate>
|
||||
AtomBrowserContext::CreateNetworkDelegate() {
|
||||
return base::MakeUnique<AtomNetworkDelegate>();
|
||||
}
|
||||
|
||||
net::CookieMonsterDelegate* AtomBrowserContext::CreateCookieDelegate() {
|
||||
|
||||
@@ -32,7 +32,7 @@ class AtomBrowserContext : public brightray::BrowserContext {
|
||||
void SetUserAgent(const std::string& user_agent);
|
||||
|
||||
// brightray::URLRequestContextGetter::Delegate:
|
||||
net::NetworkDelegate* CreateNetworkDelegate() override;
|
||||
std::unique_ptr<net::NetworkDelegate> CreateNetworkDelegate() override;
|
||||
net::CookieMonsterDelegate* CreateCookieDelegate() override;
|
||||
std::string GetUserAgent() override;
|
||||
std::unique_ptr<net::URLRequestJobFactory> CreateURLRequestJobFactory(
|
||||
@@ -52,7 +52,6 @@ class AtomBrowserContext : public brightray::BrowserContext {
|
||||
void RegisterPrefs(PrefRegistrySimple* pref_registry) override;
|
||||
|
||||
AtomBlobReader* GetBlobReader();
|
||||
AtomNetworkDelegate* network_delegate() const { return network_delegate_; }
|
||||
AtomCookieDelegate* cookie_delegate() const {
|
||||
return cookie_delegate_.get();
|
||||
}
|
||||
@@ -70,8 +69,6 @@ class AtomBrowserContext : public brightray::BrowserContext {
|
||||
std::string user_agent_;
|
||||
bool use_cache_;
|
||||
|
||||
// Managed by brightray::BrowserContext.
|
||||
AtomNetworkDelegate* network_delegate_;
|
||||
scoped_refptr<AtomCookieDelegate> cookie_delegate_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomBrowserContext);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "content/public/browser/child_process_security_policy.h"
|
||||
#include "device/geolocation/geolocation_delegate.h"
|
||||
#include "device/geolocation/geolocation_provider.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "v8/include/v8-debug.h"
|
||||
|
||||
#if defined(USE_X11)
|
||||
@@ -38,7 +39,10 @@ namespace {
|
||||
// A provider of Geolocation services to override AccessTokenStore.
|
||||
class AtomGeolocationDelegate : public device::GeolocationDelegate {
|
||||
public:
|
||||
AtomGeolocationDelegate() = default;
|
||||
AtomGeolocationDelegate() {
|
||||
device::GeolocationProvider::GetInstance()
|
||||
->UserDidOptIntoLocationServices();
|
||||
}
|
||||
|
||||
scoped_refptr<device::AccessTokenStore> CreateAccessTokenStore() final {
|
||||
return new AtomAccessTokenStore();
|
||||
@@ -137,7 +141,7 @@ void AtomBrowserMainParts::PostEarlyInitialization() {
|
||||
|
||||
// Enable support for v8 inspector
|
||||
node_debugger_.reset(new NodeDebugger(env));
|
||||
node_debugger_->Start();
|
||||
node_debugger_->Start(js_env_->platform());
|
||||
|
||||
// Add Electron extended APIs.
|
||||
atom_bindings_->BindTo(js_env_->isolate(), env->process_object());
|
||||
@@ -149,6 +153,15 @@ void AtomBrowserMainParts::PostEarlyInitialization() {
|
||||
node_bindings_->set_uv_env(env);
|
||||
}
|
||||
|
||||
int AtomBrowserMainParts::PreCreateThreads() {
|
||||
const int result = brightray::BrowserMainParts::PreCreateThreads();
|
||||
if (!result) {
|
||||
fake_browser_process_->SetApplicationLocale(
|
||||
brightray::BrowserClient::Get()->GetApplicationLocale());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void AtomBrowserMainParts::PreMainMessageLoopRun() {
|
||||
js_env_->OnMessageLoopCreated();
|
||||
|
||||
@@ -185,6 +198,7 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() {
|
||||
Browser::Get()->DidFinishLaunching(*empty_info);
|
||||
#endif
|
||||
|
||||
// Notify observers that main thread message loop was initialized.
|
||||
Browser::Get()->PreMainMessageLoopRun();
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
|
||||
// content::BrowserMainParts:
|
||||
void PreEarlyInitialization() override;
|
||||
void PostEarlyInitialization() override;
|
||||
int PreCreateThreads() override;
|
||||
void PreMainMessageLoopRun() override;
|
||||
bool MainMessageLoopRun(int* result_code) override;
|
||||
void PostMainMessageLoopStart() override;
|
||||
|
||||
@@ -119,9 +119,8 @@ void ShutdownDetector::ThreadMain() {
|
||||
|
||||
int signal;
|
||||
size_t bytes_read = 0;
|
||||
ssize_t ret;
|
||||
do {
|
||||
ret = HANDLE_EINTR(
|
||||
ssize_t ret = HANDLE_EINTR(
|
||||
read(shutdown_fd_,
|
||||
reinterpret_cast<char*>(&signal) + bytes_read,
|
||||
sizeof(signal) - bytes_read));
|
||||
|
||||
@@ -21,6 +21,32 @@
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
// Generate default file path to save the download.
|
||||
void CreateDownloadPath(
|
||||
const GURL& url,
|
||||
const std::string& content_disposition,
|
||||
const std::string& suggested_filename,
|
||||
const std::string& mime_type,
|
||||
const base::FilePath& default_download_path,
|
||||
const AtomDownloadManagerDelegate::CreateDownloadPathCallback& callback) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
|
||||
|
||||
auto generated_name =
|
||||
net::GenerateFileName(url, content_disposition, std::string(),
|
||||
suggested_filename, mime_type, "download");
|
||||
|
||||
if (!base::PathExists(default_download_path))
|
||||
base::CreateDirectory(default_download_path);
|
||||
|
||||
base::FilePath path(default_download_path.Append(generated_name));
|
||||
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(callback, path));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
AtomDownloadManagerDelegate::AtomDownloadManagerDelegate(
|
||||
content::DownloadManager* manager)
|
||||
: download_manager_(manager),
|
||||
@@ -46,30 +72,6 @@ void AtomDownloadManagerDelegate::GetItemSavePath(content::DownloadItem* item,
|
||||
*path = download->GetSavePath();
|
||||
}
|
||||
|
||||
void AtomDownloadManagerDelegate::CreateDownloadPath(
|
||||
const GURL& url,
|
||||
const std::string& content_disposition,
|
||||
const std::string& suggested_filename,
|
||||
const std::string& mime_type,
|
||||
const base::FilePath& default_download_path,
|
||||
const CreateDownloadPathCallback& callback) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
|
||||
|
||||
auto generated_name = net::GenerateFileName(url,
|
||||
content_disposition,
|
||||
std::string(),
|
||||
suggested_filename,
|
||||
mime_type,
|
||||
"download");
|
||||
|
||||
if (!base::PathExists(default_download_path))
|
||||
base::CreateDirectory(default_download_path);
|
||||
|
||||
base::FilePath path(default_download_path.Append(generated_name));
|
||||
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(callback, path));
|
||||
}
|
||||
|
||||
void AtomDownloadManagerDelegate::OnDownloadPathGenerated(
|
||||
uint32_t download_id,
|
||||
const content::DownloadTargetCallback& callback,
|
||||
@@ -164,14 +166,10 @@ bool AtomDownloadManagerDelegate::DetermineDownloadTarget(
|
||||
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::FILE, FROM_HERE,
|
||||
base::Bind(&AtomDownloadManagerDelegate::CreateDownloadPath,
|
||||
weak_ptr_factory_.GetWeakPtr(),
|
||||
download->GetURL(),
|
||||
base::Bind(&CreateDownloadPath, download->GetURL(),
|
||||
download->GetContentDisposition(),
|
||||
download->GetSuggestedFilename(),
|
||||
download->GetMimeType(),
|
||||
default_download_path,
|
||||
download_path_callback));
|
||||
download->GetSuggestedFilename(), download->GetMimeType(),
|
||||
default_download_path, download_path_callback));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,13 +24,6 @@ class AtomDownloadManagerDelegate : public content::DownloadManagerDelegate {
|
||||
explicit AtomDownloadManagerDelegate(content::DownloadManager* manager);
|
||||
virtual ~AtomDownloadManagerDelegate();
|
||||
|
||||
// Generate default file path to save the download.
|
||||
void CreateDownloadPath(const GURL& url,
|
||||
const std::string& suggested_filename,
|
||||
const std::string& content_disposition,
|
||||
const std::string& mime_type,
|
||||
const base::FilePath& path,
|
||||
const CreateDownloadPathCallback& callback);
|
||||
void OnDownloadPathGenerated(uint32_t download_id,
|
||||
const content::DownloadTargetCallback& callback,
|
||||
const base::FilePath& default_path);
|
||||
|
||||
@@ -97,11 +97,28 @@ int AtomPermissionManager::RequestPermission(
|
||||
const GURL& requesting_origin,
|
||||
bool user_gesture,
|
||||
const StatusCallback& response_callback) {
|
||||
return RequestPermissions(
|
||||
return RequestPermissionWithDetails(
|
||||
permission,
|
||||
render_frame_host,
|
||||
requesting_origin,
|
||||
user_gesture,
|
||||
nullptr,
|
||||
response_callback);
|
||||
}
|
||||
|
||||
int AtomPermissionManager::RequestPermissionWithDetails(
|
||||
content::PermissionType permission,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& requesting_origin,
|
||||
bool user_gesture,
|
||||
const base::DictionaryValue* details,
|
||||
const StatusCallback& response_callback) {
|
||||
return RequestPermissionsWithDetails(
|
||||
std::vector<content::PermissionType>(1, permission),
|
||||
render_frame_host,
|
||||
requesting_origin,
|
||||
user_gesture,
|
||||
details,
|
||||
base::Bind(&PermissionRequestResponseCallbackWrapper, response_callback));
|
||||
}
|
||||
|
||||
@@ -111,6 +128,18 @@ int AtomPermissionManager::RequestPermissions(
|
||||
const GURL& requesting_origin,
|
||||
bool user_gesture,
|
||||
const StatusesCallback& response_callback) {
|
||||
return RequestPermissionsWithDetails(
|
||||
permissions, render_frame_host, requesting_origin,
|
||||
user_gesture, nullptr, response_callback);
|
||||
}
|
||||
|
||||
int AtomPermissionManager::RequestPermissionsWithDetails(
|
||||
const std::vector<content::PermissionType>& permissions,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& requesting_origin,
|
||||
bool user_gesture,
|
||||
const base::DictionaryValue* details,
|
||||
const StatusesCallback& response_callback) {
|
||||
if (permissions.empty()) {
|
||||
response_callback.Run(std::vector<blink::mojom::PermissionStatus>());
|
||||
return kNoPendingOperation;
|
||||
@@ -143,7 +172,12 @@ int AtomPermissionManager::RequestPermissions(
|
||||
const auto callback =
|
||||
base::Bind(&AtomPermissionManager::OnPermissionResponse,
|
||||
base::Unretained(this), request_id, i);
|
||||
request_handler_.Run(web_contents, permission, callback);
|
||||
if (details == nullptr) {
|
||||
request_handler_.Run(web_contents, permission, callback,
|
||||
base::DictionaryValue());
|
||||
} else {
|
||||
request_handler_.Run(web_contents, permission, callback, *details);
|
||||
}
|
||||
}
|
||||
|
||||
return request_id;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "base/id_map.h"
|
||||
#include "base/values.h"
|
||||
#include "content/public/browser/permission_manager.h"
|
||||
|
||||
namespace content {
|
||||
@@ -30,7 +31,8 @@ class AtomPermissionManager : public content::PermissionManager {
|
||||
using RequestHandler =
|
||||
base::Callback<void(content::WebContents*,
|
||||
content::PermissionType,
|
||||
const StatusCallback&)>;
|
||||
const StatusCallback&,
|
||||
const base::DictionaryValue&)>;
|
||||
|
||||
// Handler to dispatch permission requests in JS.
|
||||
void SetPermissionRequestHandler(const RequestHandler& handler);
|
||||
@@ -43,6 +45,13 @@ class AtomPermissionManager : public content::PermissionManager {
|
||||
bool user_gesture,
|
||||
const base::Callback<void(blink::mojom::PermissionStatus)>& callback)
|
||||
override;
|
||||
int RequestPermissionWithDetails(
|
||||
content::PermissionType permission,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& requesting_origin,
|
||||
bool user_gesture,
|
||||
const base::DictionaryValue* details,
|
||||
const base::Callback<void(blink::mojom::PermissionStatus)>& callback);
|
||||
int RequestPermissions(
|
||||
const std::vector<content::PermissionType>& permissions,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
@@ -51,6 +60,14 @@ class AtomPermissionManager : public content::PermissionManager {
|
||||
const base::Callback<void(
|
||||
const std::vector<blink::mojom::PermissionStatus>&)>& callback)
|
||||
override;
|
||||
int RequestPermissionsWithDetails(
|
||||
const std::vector<content::PermissionType>& permissions,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& requesting_origin,
|
||||
bool user_gesture,
|
||||
const base::DictionaryValue* details,
|
||||
const base::Callback<void(
|
||||
const std::vector<blink::mojom::PermissionStatus>&)>& callback);
|
||||
|
||||
protected:
|
||||
void OnPermissionResponse(int request_id,
|
||||
|
||||
@@ -61,7 +61,8 @@ void HandleExternalProtocolInUI(
|
||||
|
||||
GURL escaped_url(net::EscapeExternalHandlerValue(url.spec()));
|
||||
auto callback = base::Bind(&OnOpenExternal, escaped_url);
|
||||
permission_helper->RequestOpenExternalPermission(callback, has_user_gesture);
|
||||
permission_helper->RequestOpenExternalPermission(callback, has_user_gesture,
|
||||
url);
|
||||
}
|
||||
|
||||
void OnPdfResourceIntercepted(
|
||||
@@ -74,14 +75,14 @@ void OnPdfResourceIntercepted(
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
if (!WebContentsPreferences::IsPluginsEnabled(web_contents)) {
|
||||
if (!WebContentsPreferences::IsPreferenceEnabled("plugins", web_contents)) {
|
||||
auto browser_context = web_contents->GetBrowserContext();
|
||||
auto download_manager =
|
||||
content::BrowserContext::GetDownloadManager(browser_context);
|
||||
|
||||
download_manager->DownloadUrl(
|
||||
content::DownloadUrlParameters::CreateForWebContentsMainFrame(
|
||||
web_contents, original_url));
|
||||
web_contents, original_url, NO_TRAFFIC_ANNOTATION_YET));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,8 +52,8 @@ void AtomSpeechRecognitionManagerDelegate::OnAudioLevelsChange(
|
||||
|
||||
void AtomSpeechRecognitionManagerDelegate::CheckRecognitionIsAllowed(
|
||||
int session_id,
|
||||
base::Callback<void(bool ask_user, bool is_allowed)> callback) {
|
||||
callback.Run(true, true);
|
||||
base::OnceCallback<void(bool ask_user, bool is_allowed)> callback) {
|
||||
std::move(callback).Run(true, true);
|
||||
}
|
||||
|
||||
content::SpeechRecognitionEventListener*
|
||||
|
||||
@@ -38,7 +38,8 @@ class AtomSpeechRecognitionManagerDelegate
|
||||
// content::SpeechRecognitionManagerDelegate:
|
||||
void CheckRecognitionIsAllowed(
|
||||
int session_id,
|
||||
base::Callback<void(bool ask_user, bool is_allowed)> callback) override;
|
||||
base::OnceCallback<void(bool ask_user, bool is_allowed)> callback)
|
||||
override;
|
||||
content::SpeechRecognitionEventListener* GetEventListener() override;
|
||||
bool FilterProfanities(int render_process_id) override;
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ AtomWebUIControllerFactory::CreateWebUIControllerForURL(content::WebUI* web_ui,
|
||||
if (url.host() == kPdfViewerUIHost) {
|
||||
base::StringPairs toplevel_params;
|
||||
base::SplitStringIntoKeyValuePairs(url.query(), '=', '&', &toplevel_params);
|
||||
std::string stream_id, src;
|
||||
std::string src;
|
||||
|
||||
const net::UnescapeRule::Type unescape_rules =
|
||||
net::UnescapeRule::SPACES | net::UnescapeRule::PATH_SEPARATORS |
|
||||
|
||||
@@ -21,8 +21,7 @@ std::string AutoUpdater::GetFeedURL() {
|
||||
return "";
|
||||
}
|
||||
|
||||
void AutoUpdater::SetFeedURL(const std::string& url,
|
||||
const HeaderMap& requestHeaders) {
|
||||
void AutoUpdater::SetFeedURL(mate::Arguments* args) {
|
||||
}
|
||||
|
||||
void AutoUpdater::CheckForUpdates() {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "build/build_config.h"
|
||||
#include "native_mate/arguments.h"
|
||||
|
||||
namespace base {
|
||||
class Time;
|
||||
@@ -53,8 +54,7 @@ class AutoUpdater {
|
||||
static void SetDelegate(Delegate* delegate);
|
||||
|
||||
static std::string GetFeedURL();
|
||||
static void SetFeedURL(const std::string& url,
|
||||
const HeaderMap& requestHeaders);
|
||||
static void SetFeedURL(mate::Arguments* args);
|
||||
static void CheckForUpdates();
|
||||
static void QuitAndInstall();
|
||||
|
||||
|
||||
@@ -9,9 +9,13 @@
|
||||
#import <ReactiveCocoa/NSObject+RACPropertySubscribing.h>
|
||||
#import <Squirrel/Squirrel.h>
|
||||
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "native_mate/converter.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
||||
namespace auto_updater {
|
||||
|
||||
@@ -34,8 +38,29 @@ std::string AutoUpdater::GetFeedURL() {
|
||||
}
|
||||
|
||||
// static
|
||||
void AutoUpdater::SetFeedURL(const std::string& feed,
|
||||
const HeaderMap& requestHeaders) {
|
||||
void AutoUpdater::SetFeedURL(mate::Arguments* args) {
|
||||
mate::Dictionary opts;
|
||||
std::string feed;
|
||||
HeaderMap requestHeaders;
|
||||
std::string serverType = "default";
|
||||
if (args->GetNext(&opts)) {
|
||||
if (!opts.Get("url", &feed)) {
|
||||
args->ThrowError("Expected options object to contain a 'url' string property in setFeedUrl call");
|
||||
return;
|
||||
}
|
||||
opts.Get("headers", &requestHeaders);
|
||||
opts.Get("serverType", &serverType);
|
||||
if (serverType != "default" && serverType != "json") {
|
||||
args->ThrowError("Expected serverType to be 'default' or 'json'");
|
||||
return;
|
||||
}
|
||||
} else if (args->GetNext(&feed)) {
|
||||
args->GetNext(&requestHeaders);
|
||||
} else {
|
||||
args->ThrowError("Expected an options object with a 'url' property to be provided");
|
||||
return;
|
||||
}
|
||||
|
||||
Delegate* delegate = GetDelegate();
|
||||
if (!delegate)
|
||||
return;
|
||||
@@ -55,7 +80,13 @@ void AutoUpdater::SetFeedURL(const std::string& feed,
|
||||
|
||||
// Initialize the SQRLUpdater.
|
||||
@try {
|
||||
g_updater = [[SQRLUpdater alloc] initWithUpdateRequest:urlRequest];
|
||||
if (serverType == "json") {
|
||||
NSString* nsAppVersion = base::SysUTF8ToNSString(atom::Browser::Get()->GetVersion());
|
||||
g_updater = [[SQRLUpdater alloc] initWithUpdateRequest:urlRequest forVersion:nsAppVersion];
|
||||
} else {
|
||||
// default
|
||||
g_updater = [[SQRLUpdater alloc] initWithUpdateRequest:urlRequest];
|
||||
}
|
||||
} @catch (NSException* error) {
|
||||
delegate->OnError(base::SysNSStringToUTF8(error.reason));
|
||||
return;
|
||||
|
||||
@@ -35,12 +35,12 @@ bool BridgeTaskRunner::PostDelayedTask(
|
||||
from_here, std::move(task), delay);
|
||||
}
|
||||
|
||||
bool BridgeTaskRunner::RunsTasksOnCurrentThread() const {
|
||||
bool BridgeTaskRunner::RunsTasksInCurrentSequence() const {
|
||||
auto message_loop = base::MessageLoop::current();
|
||||
if (!message_loop)
|
||||
return true;
|
||||
|
||||
return message_loop->task_runner()->RunsTasksOnCurrentThread();
|
||||
return message_loop->task_runner()->RunsTasksInCurrentSequence();
|
||||
}
|
||||
|
||||
bool BridgeTaskRunner::PostNonNestableDelayedTask(
|
||||
|
||||
@@ -27,7 +27,7 @@ class BridgeTaskRunner : public base::SingleThreadTaskRunner {
|
||||
bool PostDelayedTask(const tracked_objects::Location& from_here,
|
||||
base::OnceClosure task,
|
||||
base::TimeDelta delay) override;
|
||||
bool RunsTasksOnCurrentThread() const override;
|
||||
bool RunsTasksInCurrentSequence() const override;
|
||||
bool PostNonNestableDelayedTask(
|
||||
const tracked_objects::Location& from_here,
|
||||
base::OnceClosure task,
|
||||
|
||||
@@ -11,10 +11,13 @@
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/window_list.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "brightray/browser/brightray_paths.h"
|
||||
#include "brightray/common/application_info.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -94,31 +97,26 @@ void Browser::Shutdown() {
|
||||
}
|
||||
|
||||
std::string Browser::GetVersion() const {
|
||||
if (version_override_.empty()) {
|
||||
std::string version = GetExecutableFileVersion();
|
||||
if (!version.empty())
|
||||
return version;
|
||||
}
|
||||
|
||||
return version_override_;
|
||||
std::string ret = brightray::GetOverriddenApplicationVersion();
|
||||
if (ret.empty())
|
||||
ret = GetExecutableFileVersion();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Browser::SetVersion(const std::string& version) {
|
||||
version_override_ = version;
|
||||
brightray::OverrideApplicationVersion(version);
|
||||
}
|
||||
|
||||
std::string Browser::GetName() const {
|
||||
if (name_override_.empty()) {
|
||||
std::string name = GetExecutableFileProductName();
|
||||
if (!name.empty())
|
||||
return name;
|
||||
}
|
||||
|
||||
return name_override_;
|
||||
std::string ret = name_override_;
|
||||
if (ret.empty())
|
||||
ret = GetExecutableFileProductName();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Browser::SetName(const std::string& name) {
|
||||
name_override_ = name;
|
||||
brightray::OverrideApplicationName(name);
|
||||
}
|
||||
|
||||
int Browser::GetBadgeCount() {
|
||||
@@ -150,6 +148,7 @@ void Browser::WillFinishLaunching() {
|
||||
|
||||
void Browser::DidFinishLaunching(const base::DictionaryValue& launch_info) {
|
||||
// Make sure the userData directory is created.
|
||||
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
||||
base::FilePath user_data;
|
||||
if (PathService::Get(brightray::DIR_USER_DATA, &user_data))
|
||||
base::CreateDirectoryAndGetError(user_data, nullptr);
|
||||
|
||||
@@ -105,6 +105,9 @@ class Browser : public WindowListObserver {
|
||||
LoginItemSettings GetLoginItemSettings(const LoginItemSettings& options);
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
// Set the handler which decides whether to shutdown.
|
||||
void SetShutdownHandler(base::Callback<bool()> handler);
|
||||
|
||||
// Hide the application.
|
||||
void Hide();
|
||||
|
||||
@@ -270,15 +273,10 @@ class Browser : public WindowListObserver {
|
||||
// The browser is being shutdown.
|
||||
bool is_shutdown_;
|
||||
|
||||
std::string version_override_;
|
||||
std::string name_override_;
|
||||
|
||||
int badge_count_ = 0;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
base::string16 app_user_model_id_;
|
||||
#endif
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
base::DictionaryValue about_panel_options_;
|
||||
#endif
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "atom/browser/browser.h"
|
||||
|
||||
#include "atom/common/platform_util.h"
|
||||
#include "atom/browser/mac/atom_application.h"
|
||||
#include "atom/browser/mac/atom_application_delegate.h"
|
||||
#include "atom/browser/mac/dict_util.h"
|
||||
@@ -20,6 +21,10 @@
|
||||
|
||||
namespace atom {
|
||||
|
||||
void Browser::SetShutdownHandler(base::Callback<bool()> handler) {
|
||||
[[AtomApplication sharedApplication] setShutdownHandler:std::move(handler)];
|
||||
}
|
||||
|
||||
void Browser::Focus() {
|
||||
[[AtomApplication sharedApplication] activateIgnoringOtherApps:YES];
|
||||
}
|
||||
@@ -193,19 +198,27 @@ bool Browser::UpdateUserActivityState(const std::string& type,
|
||||
Browser::LoginItemSettings Browser::GetLoginItemSettings(
|
||||
const LoginItemSettings& options) {
|
||||
LoginItemSettings settings;
|
||||
#if defined(MAS_BUILD)
|
||||
settings.open_at_login = platform_util::GetLoginItemEnabled();
|
||||
#else
|
||||
settings.open_at_login = base::mac::CheckLoginItemStatus(
|
||||
&settings.open_as_hidden);
|
||||
settings.restore_state = base::mac::WasLaunchedAsLoginItemRestoreState();
|
||||
settings.opened_at_login = base::mac::WasLaunchedAsLoginOrResumeItem();
|
||||
settings.opened_as_hidden = base::mac::WasLaunchedAsHiddenLoginItem();
|
||||
#endif
|
||||
return settings;
|
||||
}
|
||||
|
||||
void Browser::SetLoginItemSettings(LoginItemSettings settings) {
|
||||
#if defined(MAS_BUILD)
|
||||
platform_util::SetLoginItemEnabled(settings.open_at_login);
|
||||
#else
|
||||
if (settings.open_at_login)
|
||||
base::mac::AddToLoginItems(settings.open_as_hidden);
|
||||
else
|
||||
base::mac::RemoveFromLoginItems();
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string Browser::GetExecutableFileVersion() const {
|
||||
|
||||
@@ -20,16 +20,16 @@
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "base/win/registry.h"
|
||||
#include "base/win/win_util.h"
|
||||
#include "base/win/windows_version.h"
|
||||
#include "brightray/common/application_info.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
const wchar_t kAppUserModelIDFormat[] = L"electron.app.$1";
|
||||
|
||||
BOOL CALLBACK WindowsEnumerationHandler(HWND hwnd, LPARAM param) {
|
||||
DWORD target_process_id = *reinterpret_cast<DWORD*>(param);
|
||||
DWORD process_id = 0;
|
||||
@@ -118,8 +118,7 @@ void Browser::ClearRecentDocuments() {
|
||||
}
|
||||
|
||||
void Browser::SetAppUserModelID(const base::string16& name) {
|
||||
app_user_model_id_ = name;
|
||||
SetCurrentProcessExplicitAppUserModelID(app_user_model_id_.c_str());
|
||||
brightray::SetAppUserModelID(name);
|
||||
}
|
||||
|
||||
bool Browser::SetUserTasks(const std::vector<UserTask>& tasks) {
|
||||
@@ -153,15 +152,19 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
|
||||
|
||||
// Main Registry Key
|
||||
HKEY root = HKEY_CURRENT_USER;
|
||||
base::string16 keyPath = base::UTF8ToUTF16("Software\\Classes\\" + protocol);
|
||||
base::string16 keyPath = L"Software\\Classes\\";
|
||||
|
||||
// Command Key
|
||||
base::string16 cmdPath = keyPath + L"\\shell\\open\\command";
|
||||
base::string16 wprotocol = base::UTF8ToUTF16(protocol);
|
||||
base::string16 shellPath = wprotocol + L"\\shell";
|
||||
base::string16 cmdPath = keyPath + shellPath + L"\\open\\command";
|
||||
|
||||
base::win::RegKey key;
|
||||
base::win::RegKey classesKey;
|
||||
base::win::RegKey commandKey;
|
||||
if (FAILED(key.Open(root, keyPath.c_str(), KEY_ALL_ACCESS)))
|
||||
// Key doesn't even exist, we can confirm that it is not set
|
||||
|
||||
if (FAILED(classesKey.Open(root, keyPath.c_str(), KEY_ALL_ACCESS)))
|
||||
// Classes key doesn't exist, that's concerning, but I guess
|
||||
// we're not the default handler
|
||||
return true;
|
||||
|
||||
if (FAILED(commandKey.Open(root, cmdPath.c_str(), KEY_ALL_ACCESS)))
|
||||
@@ -179,9 +182,25 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
|
||||
|
||||
if (keyVal == exe) {
|
||||
// Let's kill the key
|
||||
if (FAILED(key.DeleteKey(L"shell")))
|
||||
if (FAILED(classesKey.DeleteKey(shellPath.c_str())))
|
||||
return false;
|
||||
|
||||
// Let's clean up after ourselves
|
||||
base::win::RegKey protocolKey;
|
||||
base::string16 protocolPath = keyPath + wprotocol;
|
||||
|
||||
if (SUCCEEDED(protocolKey
|
||||
.Open(root, protocolPath.c_str(), KEY_ALL_ACCESS))) {
|
||||
protocolKey.DeleteValue(L"URL Protocol");
|
||||
|
||||
// Overwrite the default value to be empty, we can't delete it right away
|
||||
protocolKey.WriteValue(L"", L"");
|
||||
protocolKey.DeleteValue(L"");
|
||||
}
|
||||
|
||||
// If now empty, delete the whole key
|
||||
classesKey.DeleteEmptyKey(wprotocol.c_str());
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
@@ -303,17 +322,13 @@ Browser::LoginItemSettings Browser::GetLoginItemSettings(
|
||||
}
|
||||
|
||||
PCWSTR Browser::GetAppUserModelID() {
|
||||
if (app_user_model_id_.empty()) {
|
||||
SetAppUserModelID(base::ReplaceStringPlaceholders(
|
||||
kAppUserModelIDFormat, base::UTF8ToUTF16(GetName()), nullptr));
|
||||
}
|
||||
|
||||
return app_user_model_id_.c_str();
|
||||
return brightray::GetRawAppUserModelID();
|
||||
}
|
||||
|
||||
std::string Browser::GetExecutableFileVersion() const {
|
||||
base::FilePath path;
|
||||
if (PathService::Get(base::FILE_EXE, &path)) {
|
||||
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
||||
std::unique_ptr<FileVersionInfo> version_info(
|
||||
FileVersionInfo::CreateFileVersionInfo(path));
|
||||
return base::UTF16ToUTF8(version_info->product_version());
|
||||
@@ -323,14 +338,7 @@ std::string Browser::GetExecutableFileVersion() const {
|
||||
}
|
||||
|
||||
std::string Browser::GetExecutableFileProductName() const {
|
||||
base::FilePath path;
|
||||
if (PathService::Get(base::FILE_EXE, &path)) {
|
||||
std::unique_ptr<FileVersionInfo> version_info(
|
||||
FileVersionInfo::CreateFileVersionInfo(path));
|
||||
return base::UTF16ToUTF8(version_info->product_name());
|
||||
}
|
||||
|
||||
return ATOM_PRODUCT_NAME;
|
||||
return brightray::GetApplicationName();
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -180,12 +180,13 @@ void CommonWebContentsDelegate::SetOwnerWindow(NativeWindow* owner_window) {
|
||||
void CommonWebContentsDelegate::SetOwnerWindow(
|
||||
content::WebContents* web_contents, NativeWindow* owner_window) {
|
||||
owner_window_ = owner_window ? owner_window->GetWeakPtr() : nullptr;
|
||||
NativeWindowRelay* relay = new NativeWindowRelay(owner_window_);
|
||||
auto relay = base::MakeUnique<NativeWindowRelay>(owner_window_);
|
||||
auto relay_key = relay->key;
|
||||
if (owner_window) {
|
||||
web_contents->SetUserData(relay->key, relay);
|
||||
web_contents->SetUserData(relay_key, std::move(relay));
|
||||
} else {
|
||||
web_contents->RemoveUserData(relay->key);
|
||||
delete relay;
|
||||
web_contents->RemoveUserData(relay_key);
|
||||
relay.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/task_scheduler/initialization_util.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "gin/array_buffer.h"
|
||||
@@ -44,9 +45,17 @@ bool JavascriptEnvironment::Initialize() {
|
||||
if (!js_flags.empty())
|
||||
v8::V8::SetFlagsFromString(js_flags.c_str(), js_flags.size());
|
||||
|
||||
// The V8Platform of gin relies on Chromium's task schedule, which has not
|
||||
// been started at this point, so we have to rely on Node's V8Platform.
|
||||
platform_ = node::CreatePlatform(
|
||||
base::RecommendedMaxNumberOfThreadsInPool(3, 8, 0.1, 0),
|
||||
uv_default_loop(), nullptr);
|
||||
v8::V8::InitializePlatform(platform_);
|
||||
|
||||
gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,
|
||||
gin::IsolateHolder::kStableV8Extras,
|
||||
gin::ArrayBufferAllocator::SharedInstance());
|
||||
gin::ArrayBufferAllocator::SharedInstance(),
|
||||
false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
namespace node {
|
||||
class Environment;
|
||||
class NodePlatform;
|
||||
}
|
||||
|
||||
namespace atom {
|
||||
@@ -22,6 +23,7 @@ class JavascriptEnvironment {
|
||||
void OnMessageLoopCreated();
|
||||
void OnMessageLoopDestroying();
|
||||
|
||||
node::NodePlatform* platform() const { return platform_; }
|
||||
v8::Isolate* isolate() const { return isolate_; }
|
||||
v8::Local<v8::Context> context() const {
|
||||
return v8::Local<v8::Context>::New(isolate_, context_);
|
||||
@@ -30,6 +32,9 @@ class JavascriptEnvironment {
|
||||
private:
|
||||
bool Initialize();
|
||||
|
||||
// Leaked on exit.
|
||||
node::NodePlatform* platform_;
|
||||
|
||||
bool initialized_;
|
||||
gin::IsolateHolder isolate_holder_;
|
||||
v8::Isolate* isolate_;
|
||||
|
||||
@@ -97,6 +97,17 @@ void BluetoothChooser::AddOrUpdateDevice(const std::string& device_id,
|
||||
int signal_strength_level) {
|
||||
DeviceInfo info = {device_id, device_name};
|
||||
device_list_.push_back(info);
|
||||
|
||||
// Emit a select-bluetooth-device handler to allow for user to listen for
|
||||
// bluetooth device found.
|
||||
bool prevent_default = api_web_contents_->Emit("select-bluetooth-device",
|
||||
device_list_, base::Bind(&OnDeviceChosen, event_handler_));
|
||||
|
||||
// If emit not implimented select first device that matches the filters
|
||||
// provided.
|
||||
if (!prevent_default) {
|
||||
event_handler_.Run(Event::SELECTED, device_id);
|
||||
}
|
||||
}
|
||||
|
||||
void BluetoothChooser::RemoveDevice(const std::string& device_id) {
|
||||
|
||||
26
atom/browser/lib/power_observer.h
Normal file
26
atom/browser/lib/power_observer.h
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) 2017 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_LIB_POWER_OBSERVER_H_
|
||||
#define ATOM_BROWSER_LIB_POWER_OBSERVER_H_
|
||||
|
||||
#include "base/macros.h"
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
#include "atom/browser/lib/power_observer_linux.h"
|
||||
#else
|
||||
#include "base/power_monitor/power_observer.h"
|
||||
#endif // defined(OS_LINUX)
|
||||
|
||||
namespace atom {
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
typedef PowerObserverLinux PowerObserver;
|
||||
#else
|
||||
typedef base::PowerObserver PowerObserver;
|
||||
#endif // defined(OS_LINUX)
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_LIB_POWER_OBSERVER_H_
|
||||
165
atom/browser/lib/power_observer_linux.cc
Normal file
165
atom/browser/lib/power_observer_linux.cc
Normal file
@@ -0,0 +1,165 @@
|
||||
// Copyright (c) 2017 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
#include "atom/browser/lib/power_observer_linux.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <uv.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "device/bluetooth/dbus/dbus_thread_manager_linux.h"
|
||||
|
||||
namespace {
|
||||
|
||||
const char kLogindServiceName[] = "org.freedesktop.login1";
|
||||
const char kLogindObjectPath[] = "/org/freedesktop/login1";
|
||||
const char kLogindManagerInterface[] = "org.freedesktop.login1.Manager";
|
||||
|
||||
std::string get_executable_basename() {
|
||||
char buf[4096];
|
||||
size_t buf_size = sizeof(buf);
|
||||
std::string rv("electron");
|
||||
if (!uv_exepath(buf, &buf_size)) {
|
||||
rv = strrchr(static_cast<const char*>(buf), '/') + 1;
|
||||
}
|
||||
return std::move(rv);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace atom {
|
||||
|
||||
PowerObserverLinux::PowerObserverLinux()
|
||||
: lock_owner_name_(get_executable_basename()), weak_ptr_factory_(this) {
|
||||
auto dbus_thread_manager = bluez::DBusThreadManagerLinux::Get();
|
||||
if (dbus_thread_manager) {
|
||||
bus_ = dbus_thread_manager->GetSystemBus();
|
||||
if (bus_) {
|
||||
logind_ = bus_->GetObjectProxy(kLogindServiceName,
|
||||
dbus::ObjectPath(kLogindObjectPath));
|
||||
logind_->WaitForServiceToBeAvailable(
|
||||
base::Bind(&PowerObserverLinux::OnLoginServiceAvailable,
|
||||
weak_ptr_factory_.GetWeakPtr()));
|
||||
} else {
|
||||
LOG(WARNING) << "Failed to get system bus connection";
|
||||
}
|
||||
} else {
|
||||
LOG(WARNING) << "DBusThreadManagerLinux instance isn't available";
|
||||
}
|
||||
}
|
||||
|
||||
void PowerObserverLinux::OnLoginServiceAvailable(bool service_available) {
|
||||
if (!service_available) {
|
||||
LOG(WARNING) << kLogindServiceName << " not available";
|
||||
return;
|
||||
}
|
||||
// Connect to PrepareForShutdown/PrepareForSleep signals
|
||||
logind_->ConnectToSignal(kLogindManagerInterface, "PrepareForShutdown",
|
||||
base::Bind(&PowerObserverLinux::OnPrepareForShutdown,
|
||||
weak_ptr_factory_.GetWeakPtr()),
|
||||
base::Bind(&PowerObserverLinux::OnSignalConnected,
|
||||
weak_ptr_factory_.GetWeakPtr()));
|
||||
logind_->ConnectToSignal(kLogindManagerInterface, "PrepareForSleep",
|
||||
base::Bind(&PowerObserverLinux::OnPrepareForSleep,
|
||||
weak_ptr_factory_.GetWeakPtr()),
|
||||
base::Bind(&PowerObserverLinux::OnSignalConnected,
|
||||
weak_ptr_factory_.GetWeakPtr()));
|
||||
// Take sleep inhibit lock
|
||||
BlockSleep();
|
||||
}
|
||||
|
||||
void PowerObserverLinux::BlockSleep() {
|
||||
dbus::MethodCall sleep_inhibit_call(kLogindManagerInterface, "Inhibit");
|
||||
dbus::MessageWriter inhibit_writer(&sleep_inhibit_call);
|
||||
inhibit_writer.AppendString("sleep"); // what
|
||||
// Use the executable name as the lock owner, which will list rebrands of the
|
||||
// electron executable as separate entities.
|
||||
inhibit_writer.AppendString(lock_owner_name_); // who
|
||||
inhibit_writer.AppendString("Application cleanup before suspend"); // why
|
||||
inhibit_writer.AppendString("delay"); // mode
|
||||
logind_->CallMethod(&sleep_inhibit_call,
|
||||
dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
|
||||
base::Bind(&PowerObserverLinux::OnInhibitResponse,
|
||||
weak_ptr_factory_.GetWeakPtr(), &sleep_lock_));
|
||||
}
|
||||
|
||||
void PowerObserverLinux::UnblockSleep() {
|
||||
sleep_lock_.reset();
|
||||
}
|
||||
|
||||
void PowerObserverLinux::BlockShutdown() {
|
||||
if (shutdown_lock_.is_valid()) {
|
||||
LOG(WARNING) << "Trying to subscribe to shutdown multiple times";
|
||||
return;
|
||||
}
|
||||
dbus::MethodCall shutdown_inhibit_call(kLogindManagerInterface, "Inhibit");
|
||||
dbus::MessageWriter inhibit_writer(&shutdown_inhibit_call);
|
||||
inhibit_writer.AppendString("shutdown"); // what
|
||||
inhibit_writer.AppendString(lock_owner_name_); // who
|
||||
inhibit_writer.AppendString("Ensure a clean shutdown"); // why
|
||||
inhibit_writer.AppendString("delay"); // mode
|
||||
logind_->CallMethod(
|
||||
&shutdown_inhibit_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
|
||||
base::Bind(&PowerObserverLinux::OnInhibitResponse,
|
||||
weak_ptr_factory_.GetWeakPtr(), &shutdown_lock_));
|
||||
}
|
||||
|
||||
void PowerObserverLinux::UnblockShutdown() {
|
||||
if (!shutdown_lock_.is_valid()) {
|
||||
LOG(WARNING)
|
||||
<< "Trying to unsubscribe to shutdown without being subscribed";
|
||||
return;
|
||||
}
|
||||
shutdown_lock_.reset();
|
||||
}
|
||||
|
||||
void PowerObserverLinux::SetShutdownHandler(base::Callback<bool()> handler) {
|
||||
should_shutdown_ = std::move(handler);
|
||||
}
|
||||
|
||||
void PowerObserverLinux::OnInhibitResponse(base::ScopedFD* scoped_fd,
|
||||
dbus::Response* response) {
|
||||
dbus::MessageReader reader(response);
|
||||
reader.PopFileDescriptor(scoped_fd);
|
||||
}
|
||||
|
||||
void PowerObserverLinux::OnPrepareForSleep(dbus::Signal* signal) {
|
||||
dbus::MessageReader reader(signal);
|
||||
bool suspending;
|
||||
if (!reader.PopBool(&suspending)) {
|
||||
LOG(ERROR) << "Invalid signal: " << signal->ToString();
|
||||
return;
|
||||
}
|
||||
if (suspending) {
|
||||
OnSuspend();
|
||||
UnblockSleep();
|
||||
} else {
|
||||
BlockSleep();
|
||||
OnResume();
|
||||
}
|
||||
}
|
||||
|
||||
void PowerObserverLinux::OnPrepareForShutdown(dbus::Signal* signal) {
|
||||
dbus::MessageReader reader(signal);
|
||||
bool shutting_down;
|
||||
if (!reader.PopBool(&shutting_down)) {
|
||||
LOG(ERROR) << "Invalid signal: " << signal->ToString();
|
||||
return;
|
||||
}
|
||||
if (shutting_down) {
|
||||
if (!should_shutdown_ || should_shutdown_.Run()) {
|
||||
// The user didn't try to prevent shutdown. Release the lock and allow the
|
||||
// shutdown to continue normally.
|
||||
shutdown_lock_.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PowerObserverLinux::OnSignalConnected(const std::string& interface,
|
||||
const std::string& signal,
|
||||
bool success) {
|
||||
LOG_IF(WARNING, !success) << "Failed to connect to " << signal;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
54
atom/browser/lib/power_observer_linux.h
Normal file
54
atom/browser/lib/power_observer_linux.h
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright (c) 2017 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_LIB_POWER_OBSERVER_LINUX_H_
|
||||
#define ATOM_BROWSER_LIB_POWER_OBSERVER_LINUX_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/power_monitor/power_observer.h"
|
||||
#include "dbus/bus.h"
|
||||
#include "dbus/message.h"
|
||||
#include "dbus/object_proxy.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class PowerObserverLinux : public base::PowerObserver {
|
||||
public:
|
||||
PowerObserverLinux();
|
||||
|
||||
protected:
|
||||
void BlockSleep();
|
||||
void UnblockSleep();
|
||||
void BlockShutdown();
|
||||
void UnblockShutdown();
|
||||
|
||||
void SetShutdownHandler(base::Callback<bool()> should_shutdown);
|
||||
|
||||
private:
|
||||
void OnLoginServiceAvailable(bool available);
|
||||
void OnInhibitResponse(base::ScopedFD* scoped_fd, dbus::Response* response);
|
||||
void OnPrepareForSleep(dbus::Signal* signal);
|
||||
void OnPrepareForShutdown(dbus::Signal* signal);
|
||||
void OnSignalConnected(const std::string& interface,
|
||||
const std::string& signal,
|
||||
bool success);
|
||||
|
||||
base::Callback<bool()> should_shutdown_;
|
||||
|
||||
scoped_refptr<dbus::Bus> bus_;
|
||||
scoped_refptr<dbus::ObjectProxy> logind_;
|
||||
std::string lock_owner_name_;
|
||||
base::ScopedFD sleep_lock_;
|
||||
base::ScopedFD shutdown_lock_;
|
||||
base::WeakPtrFactory<PowerObserverLinux> weak_ptr_factory_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(PowerObserverLinux);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_LIB_POWER_OBSERVER_LINUX_H_
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user