mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
Compare commits
1863 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46aed5ff6f | ||
|
|
e539129db2 | ||
|
|
c1a478179e | ||
|
|
f7e3f9035d | ||
|
|
23b235c9c7 | ||
|
|
99d3fce3c7 | ||
|
|
71c3e97e81 | ||
|
|
0287f23e3b | ||
|
|
40b35a991f | ||
|
|
940d77b9a0 | ||
|
|
033aa16e04 | ||
|
|
ab83aa0bfd | ||
|
|
a49af26e39 | ||
|
|
e496e18f6e | ||
|
|
c068285ff8 | ||
|
|
9c9c8ec5f1 | ||
|
|
d2f185bea5 | ||
|
|
69df934710 | ||
|
|
bb5ad4ac05 | ||
|
|
b467c3939e | ||
|
|
aac934b34e | ||
|
|
2cbdb6bac3 | ||
|
|
e017e157ba | ||
|
|
253caf35ab | ||
|
|
2d638e5da7 | ||
|
|
6ded27f3a9 | ||
|
|
caae03f954 | ||
|
|
286f529968 | ||
|
|
75d934e4a2 | ||
|
|
deef2da87c | ||
|
|
8060b0966f | ||
|
|
487a195320 | ||
|
|
a215e8fb82 | ||
|
|
6f047fd4b7 | ||
|
|
64984ac23b | ||
|
|
f119bc0944 | ||
|
|
c50b518493 | ||
|
|
648d3324fb | ||
|
|
11a4c7e408 | ||
|
|
3ae034deab | ||
|
|
ab05346572 | ||
|
|
0e55e5cbb5 | ||
|
|
fe5db82d47 | ||
|
|
f71353a4c5 | ||
|
|
9642381c02 | ||
|
|
a35cce5f7a | ||
|
|
469ab8b509 | ||
|
|
818738ce84 | ||
|
|
e9b955b9ec | ||
|
|
f6befbe764 | ||
|
|
6d45052eea | ||
|
|
a6e4867111 | ||
|
|
da0d0e7aac | ||
|
|
713e256843 | ||
|
|
e98ac94d51 | ||
|
|
bc31f05404 | ||
|
|
f41db87e47 | ||
|
|
466c39ed19 | ||
|
|
019883f2fa | ||
|
|
5200b1a1ab | ||
|
|
49d48a4eb0 | ||
|
|
87c219748d | ||
|
|
2e0e4e69bb | ||
|
|
6175ee05e2 | ||
|
|
8b7675baee | ||
|
|
eeccdf967c | ||
|
|
069baf8cd8 | ||
|
|
a55cddaa53 | ||
|
|
15e2b2335f | ||
|
|
80ce60f644 | ||
|
|
6e02d18a40 | ||
|
|
6be779c777 | ||
|
|
d022d108a3 | ||
|
|
4381e0895f | ||
|
|
eda413861a | ||
|
|
093cff5548 | ||
|
|
b28e686228 | ||
|
|
b1b6573bcd | ||
|
|
e5100cd103 | ||
|
|
5a8e522526 | ||
|
|
c982af991d | ||
|
|
210f40dd53 | ||
|
|
422b7acece | ||
|
|
cca1db47ee | ||
|
|
528853efbf | ||
|
|
010193ef44 | ||
|
|
e4b97a3c93 | ||
|
|
6987e3ecd0 | ||
|
|
ed89a603f3 | ||
|
|
b9710532e1 | ||
|
|
07835bf4e6 | ||
|
|
6e241c5e0d | ||
|
|
bd9a9657aa | ||
|
|
a4400dc549 | ||
|
|
3aba23b471 | ||
|
|
e90fd1444f | ||
|
|
671a8a2cd6 | ||
|
|
6cb626db88 | ||
|
|
56c0eb74ff | ||
|
|
cc09b9ac7d | ||
|
|
846d516584 | ||
|
|
8580a34f9f | ||
|
|
2b64452d9c | ||
|
|
3baa186c0a | ||
|
|
e767c59da2 | ||
|
|
c15f6af892 | ||
|
|
ddc2e0df71 | ||
|
|
de7dcdedba | ||
|
|
0c7bb72891 | ||
|
|
fd8c450ef3 | ||
|
|
008497500b | ||
|
|
945e26750e | ||
|
|
0ab37da785 | ||
|
|
578b717b5f | ||
|
|
c8b932fce4 | ||
|
|
c4dd2f4f56 | ||
|
|
3c90fabab7 | ||
|
|
41c1623824 | ||
|
|
a2db14476a | ||
|
|
8a2b9c893e | ||
|
|
a7ed7068f6 | ||
|
|
be480fb634 | ||
|
|
fdd574cea5 | ||
|
|
5e70adb511 | ||
|
|
0dcdd60010 | ||
|
|
268dd1a6c2 | ||
|
|
e52ece1a1e | ||
|
|
4f31a5c452 | ||
|
|
d7f458d232 | ||
|
|
2fe21ecdd0 | ||
|
|
37c9d76cd5 | ||
|
|
dac6e0ce66 | ||
|
|
634bd7b17f | ||
|
|
48152a813b | ||
|
|
84e7387b17 | ||
|
|
cfb3798703 | ||
|
|
a85ae27d68 | ||
|
|
25a231fc50 | ||
|
|
3b265747fe | ||
|
|
4281c73cf2 | ||
|
|
eed098277c | ||
|
|
280337bf46 | ||
|
|
da023b72ee | ||
|
|
5b1d5b39a2 | ||
|
|
3349e32196 | ||
|
|
3b2faf7b89 | ||
|
|
458e4be77c | ||
|
|
7ef69a5af5 | ||
|
|
bfe63d7a88 | ||
|
|
e6a66b6006 | ||
|
|
1c027c526b | ||
|
|
dda2288541 | ||
|
|
cd05834d96 | ||
|
|
2b8203e383 | ||
|
|
d78f3cae7b | ||
|
|
85d66d2413 | ||
|
|
44bd93589a | ||
|
|
e79a22da5d | ||
|
|
e03e37e984 | ||
|
|
14e8e463b3 | ||
|
|
14b548f27a | ||
|
|
f19998ef4c | ||
|
|
2946f624ac | ||
|
|
089bfd2cd2 | ||
|
|
6e977cbc3a | ||
|
|
7e039d92ec | ||
|
|
d67863aa9f | ||
|
|
17b70670f8 | ||
|
|
783b5e84f4 | ||
|
|
ff5081816f | ||
|
|
3c74404a3e | ||
|
|
410e80682a | ||
|
|
d5a658bbe4 | ||
|
|
c004cf0894 | ||
|
|
dcfab1b6a0 | ||
|
|
950e3436c2 | ||
|
|
1c2a78a896 | ||
|
|
224ffe44aa | ||
|
|
b5cfa2e92d | ||
|
|
4f817873f1 | ||
|
|
31cae8e1aa | ||
|
|
8852b128ec | ||
|
|
6d5fbe6be2 | ||
|
|
82a81bb26e | ||
|
|
e4ead6d018 | ||
|
|
c11cdf321b | ||
|
|
8bc65ef495 | ||
|
|
86babdd412 | ||
|
|
50ade57700 | ||
|
|
0bbbeb307e | ||
|
|
8eaf48e552 | ||
|
|
b46e48cae1 | ||
|
|
c0d57d609e | ||
|
|
dbe9893d29 | ||
|
|
e0260d6f53 | ||
|
|
5b8fcb740c | ||
|
|
bb8d42f1e1 | ||
|
|
8d512de157 | ||
|
|
f97066511f | ||
|
|
5a4d9807ee | ||
|
|
9547ff135f | ||
|
|
6bc464d4b0 | ||
|
|
6240e30be1 | ||
|
|
6fcb784f6e | ||
|
|
095e79b043 | ||
|
|
f549bda9fc | ||
|
|
886b47e713 | ||
|
|
479af3c9e2 | ||
|
|
94b7fef30f | ||
|
|
e485ff6cea | ||
|
|
d26e4a4abf | ||
|
|
cb66a769d4 | ||
|
|
8b53ff3900 | ||
|
|
c7d3d48875 | ||
|
|
9234bddc38 | ||
|
|
aaa8e81cd4 | ||
|
|
ef5c2bbded | ||
|
|
90885d1d8c | ||
|
|
e936143da2 | ||
|
|
eb827eb020 | ||
|
|
dead1ae1ba | ||
|
|
c209b886bf | ||
|
|
f97ee56c9f | ||
|
|
e315116336 | ||
|
|
4d6c779839 | ||
|
|
b879872317 | ||
|
|
2680ee9f8f | ||
|
|
0098822fcf | ||
|
|
9f323104e7 | ||
|
|
edebb32014 | ||
|
|
fde310f50d | ||
|
|
d9a8c15c69 | ||
|
|
ca2898a60e | ||
|
|
c349aeff80 | ||
|
|
002369576f | ||
|
|
81ecd4499c | ||
|
|
eb03ab561d | ||
|
|
ce12dcd3b4 | ||
|
|
a34f9d3583 | ||
|
|
506b42b563 | ||
|
|
ecc0478e3c | ||
|
|
79b17c2cd9 | ||
|
|
d1edd80ef8 | ||
|
|
8d716e8b17 | ||
|
|
93bbe8e70b | ||
|
|
70d61869a5 | ||
|
|
76f112ffc5 | ||
|
|
5fe3ac60fa | ||
|
|
708ed9d1cd | ||
|
|
5f9e9d4b36 | ||
|
|
61aa9bbff4 | ||
|
|
f153d08297 | ||
|
|
f9dd91d54d | ||
|
|
51f1c5a557 | ||
|
|
d5dbe3676e | ||
|
|
347d472841 | ||
|
|
b959f782f6 | ||
|
|
ec500b2852 | ||
|
|
812beb240b | ||
|
|
823b3baed0 | ||
|
|
98f5858b11 | ||
|
|
cbb6f8c33e | ||
|
|
1972e2eff9 | ||
|
|
28f2a4951b | ||
|
|
b39b49a15a | ||
|
|
14ef5c5957 | ||
|
|
ca29ec0101 | ||
|
|
f297ba987e | ||
|
|
b30f7c3c94 | ||
|
|
8500538793 | ||
|
|
cf7cd1f32b | ||
|
|
48515d9ecc | ||
|
|
b632cdd37d | ||
|
|
1b5149ae7a | ||
|
|
b16d649819 | ||
|
|
eff49ad19c | ||
|
|
69638a399c | ||
|
|
d4d3c78701 | ||
|
|
9bdca3bbfb | ||
|
|
9272582bd6 | ||
|
|
52905ae9b3 | ||
|
|
2a00bb30c5 | ||
|
|
ba3fbc9d1b | ||
|
|
28d5c8bbde | ||
|
|
dd09c91cf2 | ||
|
|
61949657f0 | ||
|
|
15dcc314d3 | ||
|
|
d1b3ba39bd | ||
|
|
4f0caffc3b | ||
|
|
257b32b84b | ||
|
|
43cc5079d8 | ||
|
|
269d899a99 | ||
|
|
2bc45c8665 | ||
|
|
c92c4138a8 | ||
|
|
18c7c3ece8 | ||
|
|
7857c83ea1 | ||
|
|
703b5738c8 | ||
|
|
e027f4aacf | ||
|
|
67dc1b1070 | ||
|
|
d75db0ea1a | ||
|
|
ffc7a4c8a0 | ||
|
|
23eecac288 | ||
|
|
5ee7434a54 | ||
|
|
01423f79b3 | ||
|
|
370562b129 | ||
|
|
e8c0813f46 | ||
|
|
bcda67b8eb | ||
|
|
8f7785bb05 | ||
|
|
e51a4f0af1 | ||
|
|
7fb77ee1cb | ||
|
|
7f6283352f | ||
|
|
cf198904a4 | ||
|
|
1709e74958 | ||
|
|
24574f7299 | ||
|
|
29278e500b | ||
|
|
d379b05890 | ||
|
|
a0605275b9 | ||
|
|
c06c4c0ccb | ||
|
|
4aaa936803 | ||
|
|
d009b3267a | ||
|
|
59e656586d | ||
|
|
34e21cb91f | ||
|
|
15bf7ed536 | ||
|
|
166bf7ab8c | ||
|
|
69f0cb26e7 | ||
|
|
879082b1a6 | ||
|
|
dba154b062 | ||
|
|
7a99f0435b | ||
|
|
bb1a981a01 | ||
|
|
ca8983bf6c | ||
|
|
e8a79cb88d | ||
|
|
51d6a55061 | ||
|
|
8e7a26ec25 | ||
|
|
61bce3ef39 | ||
|
|
54232ee21a | ||
|
|
1d84d83fd4 | ||
|
|
7564a9973b | ||
|
|
f4717b34e9 | ||
|
|
2f5f7721fc | ||
|
|
5fe62d23d9 | ||
|
|
76e1f882c0 | ||
|
|
19a948298b | ||
|
|
5a173965ed | ||
|
|
250c656aa7 | ||
|
|
776fd56e41 | ||
|
|
368da3300e | ||
|
|
20a9cf834b | ||
|
|
f774ea857e | ||
|
|
6b138e0215 | ||
|
|
c10f1210bc | ||
|
|
ba4a2d7c30 | ||
|
|
5c64075032 | ||
|
|
32f44d7917 | ||
|
|
dd5fa2df85 | ||
|
|
cdc6b13fc8 | ||
|
|
8e4bdec6b6 | ||
|
|
6c40b1eead | ||
|
|
ad03ba73a4 | ||
|
|
e6fec57bd8 | ||
|
|
b936221b63 | ||
|
|
be16e75be2 | ||
|
|
d01250eceb | ||
|
|
739f3ed102 | ||
|
|
c951e253c6 | ||
|
|
3e05350d6b | ||
|
|
5819acbc20 | ||
|
|
ef085a1f15 | ||
|
|
6837ec8576 | ||
|
|
a62c2f9e2e | ||
|
|
29f92bfb53 | ||
|
|
a33ffd621f | ||
|
|
ff513f2a84 | ||
|
|
cc688d7fa6 | ||
|
|
eb260c3593 | ||
|
|
ea3b14f0bb | ||
|
|
7c4529a01a | ||
|
|
62f4a77755 | ||
|
|
211bedf910 | ||
|
|
d0b07d5c36 | ||
|
|
a8d1a7aed4 | ||
|
|
2006e22aa4 | ||
|
|
6c6506e5aa | ||
|
|
ce5ac1b056 | ||
|
|
91d1af053f | ||
|
|
0a5ccdccb4 | ||
|
|
6a023dc4fe | ||
|
|
947556a23f | ||
|
|
55f90b4a4b | ||
|
|
d686cf77e9 | ||
|
|
66b6b4f1cb | ||
|
|
4430927f98 | ||
|
|
b091d104f5 | ||
|
|
636ef0fd29 | ||
|
|
85bdce0722 | ||
|
|
91bd95a0b2 | ||
|
|
c4280612c1 | ||
|
|
e5d82edf5d | ||
|
|
92092bed41 | ||
|
|
f80af6e3ed | ||
|
|
1dd37eaab7 | ||
|
|
c78d7fc125 | ||
|
|
a1ede4a4b0 | ||
|
|
1f75df0253 | ||
|
|
a57af31b99 | ||
|
|
0c022fdc36 | ||
|
|
403e7681c1 | ||
|
|
c71b44048c | ||
|
|
dfc2e6c4a8 | ||
|
|
71fd3e807c | ||
|
|
763b9ab8d8 | ||
|
|
203a920c64 | ||
|
|
5e30ccd891 | ||
|
|
e60601898d | ||
|
|
440e48fe19 | ||
|
|
91677ade89 | ||
|
|
529b84ff9c | ||
|
|
5687f8b3b7 | ||
|
|
977abc6458 | ||
|
|
8fe025d6c9 | ||
|
|
87e606627c | ||
|
|
7cb101b566 | ||
|
|
19b686c90b | ||
|
|
6dd18678a9 | ||
|
|
d97585d06d | ||
|
|
a00bb332ca | ||
|
|
9a7ac5326c | ||
|
|
70849de8c4 | ||
|
|
52801c4a41 | ||
|
|
db79f4f450 | ||
|
|
bda8af8dd3 | ||
|
|
86007fe61d | ||
|
|
35908ac398 | ||
|
|
be79417a03 | ||
|
|
0ac3969c6a | ||
|
|
a0fc5ae63d | ||
|
|
1170ecb269 | ||
|
|
f79ce38a57 | ||
|
|
20aeec7cf5 | ||
|
|
b3ab426a5e | ||
|
|
c127ce3e46 | ||
|
|
fe59f413f6 | ||
|
|
36e6501c44 | ||
|
|
9be42db8d5 | ||
|
|
52d989f908 | ||
|
|
643cb5d6de | ||
|
|
5cb6648686 | ||
|
|
82f452568c | ||
|
|
897d58bde1 | ||
|
|
272a0824e8 | ||
|
|
af7702d0f2 | ||
|
|
07173cdd9d | ||
|
|
b51adf8ae5 | ||
|
|
a4bbad03c2 | ||
|
|
f3756ccf29 | ||
|
|
3b7207da9f | ||
|
|
41fef3999c | ||
|
|
9a434af03e | ||
|
|
ba975d552a | ||
|
|
cfe3ae234b | ||
|
|
3e18d8baf5 | ||
|
|
e4c54fd0d8 | ||
|
|
e9e8595605 | ||
|
|
c54ae66fb9 | ||
|
|
624e44dd6f | ||
|
|
fdc1d3d763 | ||
|
|
8e09fcd2a9 | ||
|
|
2a18e3f9ea | ||
|
|
1933a4fc9f | ||
|
|
7e138083ef | ||
|
|
70010fdb8e | ||
|
|
80dad58a59 | ||
|
|
1f0bc7fe86 | ||
|
|
bad6954911 | ||
|
|
d56c1909df | ||
|
|
f19924bcb0 | ||
|
|
d3c967401d | ||
|
|
d7ab142e10 | ||
|
|
8c2cf03f37 | ||
|
|
a746651d1c | ||
|
|
17fe5efa13 | ||
|
|
7c33f3ee65 | ||
|
|
e45d8079b8 | ||
|
|
266c78b861 | ||
|
|
c9e5d7d1e2 | ||
|
|
070cc40af4 | ||
|
|
16382162f8 | ||
|
|
7f7df5a6dd | ||
|
|
9b8e4eb6cb | ||
|
|
593b7cc92a | ||
|
|
51d5706b48 | ||
|
|
e262f6c63e | ||
|
|
b7551b5d84 | ||
|
|
dddb6458da | ||
|
|
c9dd59eb86 | ||
|
|
9fd9b39448 | ||
|
|
6a0738aa88 | ||
|
|
50fbd5266a | ||
|
|
46c65ae5fc | ||
|
|
5efa34ce6d | ||
|
|
7a0aff2bae | ||
|
|
cbeaa6be87 | ||
|
|
e3fe3cc490 | ||
|
|
63c0e4cbb1 | ||
|
|
07794a58aa | ||
|
|
b27c94368d | ||
|
|
5e78330c6d | ||
|
|
9b6b8752d4 | ||
|
|
4d7d72256d | ||
|
|
9dd960fc97 | ||
|
|
c49363f521 | ||
|
|
45a1ffef8f | ||
|
|
43b09b7360 | ||
|
|
d3bf36e12a | ||
|
|
0f55468042 | ||
|
|
f4ea70d2c2 | ||
|
|
9ce93e6cac | ||
|
|
a78cd79a58 | ||
|
|
e008d86e76 | ||
|
|
7fdfaa13e7 | ||
|
|
888dc5702f | ||
|
|
b92c4f6ce5 | ||
|
|
e85d2f00dd | ||
|
|
5d0da398bf | ||
|
|
035d9df29b | ||
|
|
197ad915b7 | ||
|
|
e8f689ecd3 | ||
|
|
e8f0331aeb | ||
|
|
acedc3e726 | ||
|
|
81addbdcbf | ||
|
|
941f6c63e3 | ||
|
|
a7c050107b | ||
|
|
acff2f6baf | ||
|
|
8b0d3a2567 | ||
|
|
792f3c3030 | ||
|
|
46f1a49594 | ||
|
|
7eda8fbdfb | ||
|
|
706b9f6cbf | ||
|
|
5bf60ad8e8 | ||
|
|
5130ad24eb | ||
|
|
35654d872b | ||
|
|
f7f4de36af | ||
|
|
c3f3a6f133 | ||
|
|
867bb5a94e | ||
|
|
e7410976f0 | ||
|
|
7994acf0ea | ||
|
|
c8c11e68c6 | ||
|
|
347dc835b5 | ||
|
|
a4a71a1dc9 | ||
|
|
72723646dd | ||
|
|
9423143211 | ||
|
|
b0487b7d84 | ||
|
|
1bf8270c0d | ||
|
|
8843fef065 | ||
|
|
36209ddd90 | ||
|
|
cc22149beb | ||
|
|
1d612a12a1 | ||
|
|
e267a0dd41 | ||
|
|
eba65eb4d3 | ||
|
|
c7b639e282 | ||
|
|
8f542b1d69 | ||
|
|
4a78490a6a | ||
|
|
db4ad8c692 | ||
|
|
f949f83a57 | ||
|
|
a3c5eafb16 | ||
|
|
90492df1cb | ||
|
|
6adf1640e5 | ||
|
|
5d35d2476d | ||
|
|
9163b601a4 | ||
|
|
22b9c6e539 | ||
|
|
bad130f623 | ||
|
|
18e15a1e53 | ||
|
|
1e581d6814 | ||
|
|
70178adb6e | ||
|
|
5245d42d15 | ||
|
|
9c134e7bf3 | ||
|
|
6b56dfd94b | ||
|
|
37db804099 | ||
|
|
e29b64a18a | ||
|
|
d00a96ce35 | ||
|
|
e9226aa354 | ||
|
|
c1773a2c94 | ||
|
|
090255c3f4 | ||
|
|
84f8bfbdef | ||
|
|
83d31cefeb | ||
|
|
11e1f6b56c | ||
|
|
ed44b32ff5 | ||
|
|
148898fb75 | ||
|
|
5cd18fe32a | ||
|
|
0748f4fef2 | ||
|
|
f9b319e4f8 | ||
|
|
ba03f04017 | ||
|
|
0643d98d99 | ||
|
|
4630f4488e | ||
|
|
82ac4ddf19 | ||
|
|
fc1b7431c7 | ||
|
|
a4277bb616 | ||
|
|
dddc6aec49 | ||
|
|
683a758dab | ||
|
|
ee66776450 | ||
|
|
a9dae243b4 | ||
|
|
c810e64fda | ||
|
|
bcf0964c61 | ||
|
|
2b60df3d8b | ||
|
|
29452364f3 | ||
|
|
c36cdb8580 | ||
|
|
1aa4fcae08 | ||
|
|
00748889f9 | ||
|
|
c2bf5bb986 | ||
|
|
11ef2c539b | ||
|
|
5794138ed4 | ||
|
|
1b4ee6e0d8 | ||
|
|
2e85ff1f57 | ||
|
|
3d47c9b71d | ||
|
|
fe99b255c4 | ||
|
|
05cb26a174 | ||
|
|
bec671bac8 | ||
|
|
ff3aaa55f7 | ||
|
|
b25b141642 | ||
|
|
1b3cd87fc9 | ||
|
|
602aba8723 | ||
|
|
eb889b9b86 | ||
|
|
d118fed5c2 | ||
|
|
8e4ed664d9 | ||
|
|
1d24a3a175 | ||
|
|
be5b907179 | ||
|
|
0f98c9d3fb | ||
|
|
c3c5470a7c | ||
|
|
4de637779b | ||
|
|
7ec88d16a6 | ||
|
|
42f65c52fb | ||
|
|
84c180ac69 | ||
|
|
852519a826 | ||
|
|
e6fe2a93f2 | ||
|
|
85e84cc0da | ||
|
|
a2ecef26a2 | ||
|
|
a35424ef25 | ||
|
|
b8e12a0d21 | ||
|
|
8359c72347 | ||
|
|
dbb81e34e8 | ||
|
|
997799ad68 | ||
|
|
ec650b3773 | ||
|
|
864a23f72b | ||
|
|
86215d4300 | ||
|
|
e0c021bfef | ||
|
|
1ed8743da8 | ||
|
|
d483352f78 | ||
|
|
3024d0563f | ||
|
|
ab783413a2 | ||
|
|
75627ba6ad | ||
|
|
85961a0dd9 | ||
|
|
c69626336d | ||
|
|
82d796ded4 | ||
|
|
41f356a94d | ||
|
|
a98e69a80d | ||
|
|
be29ea4dad | ||
|
|
820c0827c0 | ||
|
|
55d4d44f02 | ||
|
|
6165d36351 | ||
|
|
09fcb7fb27 | ||
|
|
c72438f09f | ||
|
|
0a7c51b9aa | ||
|
|
fa4b8cff45 | ||
|
|
eb3b77f43b | ||
|
|
6763977316 | ||
|
|
81784827ff | ||
|
|
234e1bb811 | ||
|
|
411696ca19 | ||
|
|
8a6fd685e3 | ||
|
|
4a14b17255 | ||
|
|
6d5339b74e | ||
|
|
5e43ea227e | ||
|
|
6d323dd6fe | ||
|
|
53bf82dd7c | ||
|
|
e7f3a25626 | ||
|
|
2e0780308c | ||
|
|
47c1bc9f66 | ||
|
|
5cf2873b77 | ||
|
|
5162905fe4 | ||
|
|
1a15b45736 | ||
|
|
dc9000f344 | ||
|
|
3ea6d88763 | ||
|
|
c0697d8abe | ||
|
|
9882e87fbd | ||
|
|
c2f3bbb3e6 | ||
|
|
a95bd227c3 | ||
|
|
e91eed6758 | ||
|
|
85749e4dbd | ||
|
|
6eaa30e94c | ||
|
|
13a1d79ca6 | ||
|
|
3224c39371 | ||
|
|
1d29b23662 | ||
|
|
231173aa90 | ||
|
|
d4e3dade39 | ||
|
|
7a7b72ce04 | ||
|
|
c10eb73166 | ||
|
|
d8e9432b0d | ||
|
|
0a91779dfa | ||
|
|
074cad9146 | ||
|
|
406224edff | ||
|
|
c1df762656 | ||
|
|
b83676f9e9 | ||
|
|
1518ff5ddf | ||
|
|
18357512f3 | ||
|
|
1b3d3b6b75 | ||
|
|
1178915f30 | ||
|
|
b7b200c874 | ||
|
|
1c6a07c68d | ||
|
|
3c2539eced | ||
|
|
e2501a80e4 | ||
|
|
29d0a30d63 | ||
|
|
25bc02f332 | ||
|
|
d2ffd87668 | ||
|
|
852e158cc6 | ||
|
|
4fce00148d | ||
|
|
26d4a3b0ba | ||
|
|
02dfdf75a0 | ||
|
|
45e2f35eff | ||
|
|
62c8a00347 | ||
|
|
0a6a8192b6 | ||
|
|
39b6bcb621 | ||
|
|
093b844859 | ||
|
|
6df446baba | ||
|
|
de18f09588 | ||
|
|
2f3578679f | ||
|
|
7b3e998cc6 | ||
|
|
cf694ef32b | ||
|
|
b1f260ac87 | ||
|
|
fb08f56fc8 | ||
|
|
555347e726 | ||
|
|
50b9dfa61a | ||
|
|
4539a6f4d5 | ||
|
|
4abbd65628 | ||
|
|
5973aa36ad | ||
|
|
62a400b7d6 | ||
|
|
75ec73d6fe | ||
|
|
1a3abb61ed | ||
|
|
4a6cbd76c8 | ||
|
|
9e7bcda07d | ||
|
|
93b0a2caa1 | ||
|
|
930a5c6de2 | ||
|
|
daff671afc | ||
|
|
a60f341968 | ||
|
|
604c2470bc | ||
|
|
9fef6a1fd7 | ||
|
|
2cf6a026d8 | ||
|
|
87392ff046 | ||
|
|
dc1c11a841 | ||
|
|
9b2b6da3a3 | ||
|
|
2cacaa443a | ||
|
|
f0882a5058 | ||
|
|
1945771f37 | ||
|
|
37eebb1dd0 | ||
|
|
94cb605993 | ||
|
|
e99b1709d9 | ||
|
|
4e5b8ac3ee | ||
|
|
0430380de1 | ||
|
|
edbb786fb4 | ||
|
|
6e2f977f7a | ||
|
|
76e5589a31 | ||
|
|
651ea7ef02 | ||
|
|
eb6d92d427 | ||
|
|
e683f28e32 | ||
|
|
8ce1930f0d | ||
|
|
2ee5f6f358 | ||
|
|
06c025050e | ||
|
|
ff718b19db | ||
|
|
1004d205d8 | ||
|
|
24fb560a9d | ||
|
|
a4e25a8917 | ||
|
|
2cfa67bdff | ||
|
|
a851695bb9 | ||
|
|
e2e33a8cf0 | ||
|
|
515f689814 | ||
|
|
640b03f7d0 | ||
|
|
b67d515a76 | ||
|
|
9e189b9d2d | ||
|
|
1234b61fa6 | ||
|
|
104cae8f68 | ||
|
|
e1281342f6 | ||
|
|
2ad46f1842 | ||
|
|
8e69f94df0 | ||
|
|
330ac5f266 | ||
|
|
56a8eb3a94 | ||
|
|
ddedcf22d1 | ||
|
|
f6410d3b77 | ||
|
|
c213971a2d | ||
|
|
bc2f1e8199 | ||
|
|
63d8137da2 | ||
|
|
45986405b8 | ||
|
|
b04db2e546 | ||
|
|
a0b24bd155 | ||
|
|
67f7a60524 | ||
|
|
41ea169784 | ||
|
|
49c6446267 | ||
|
|
26e3ad3c2e | ||
|
|
c13ea6eb36 | ||
|
|
f104e019be | ||
|
|
8e39aea34a | ||
|
|
d8a16a8ffb | ||
|
|
1f5518b91e | ||
|
|
90470617ab | ||
|
|
ce6a46ee59 | ||
|
|
108a3473ed | ||
|
|
4985e073c4 | ||
|
|
7b03c05b4e | ||
|
|
ce472315f4 | ||
|
|
43ef4faf79 | ||
|
|
795b674996 | ||
|
|
170c51ae85 | ||
|
|
241773f2f0 | ||
|
|
d453dbdb40 | ||
|
|
2814e04e7d | ||
|
|
f1cd1c6dff | ||
|
|
4107174cfd | ||
|
|
91f8d6092b | ||
|
|
1f07cf2545 | ||
|
|
d4b44d8b69 | ||
|
|
61aff5ed35 | ||
|
|
6bb331356e | ||
|
|
284ca3114b | ||
|
|
e1fe5f4fbf | ||
|
|
2762ead5a4 | ||
|
|
0ca5ad754e | ||
|
|
4f6750a460 | ||
|
|
1960327918 | ||
|
|
8c9ebbeec2 | ||
|
|
9f03a166f7 | ||
|
|
fb741285c6 | ||
|
|
7a0a87a6f3 | ||
|
|
034230e2ae | ||
|
|
68ca873fa8 | ||
|
|
3312f98121 | ||
|
|
33820ffb85 | ||
|
|
593a3de850 | ||
|
|
05b6f95ab8 | ||
|
|
68eaf1fb9f | ||
|
|
851a7578fa | ||
|
|
0d259a6eb0 | ||
|
|
86521f325b | ||
|
|
64a1b1c474 | ||
|
|
cf54c4cbb2 | ||
|
|
91ed9aeeee | ||
|
|
bc001f8816 | ||
|
|
56882c31bd | ||
|
|
8fe8dfa410 | ||
|
|
f9dc08baf6 | ||
|
|
54559f99a0 | ||
|
|
91c70a66cb | ||
|
|
edcea3e800 | ||
|
|
11f2574fda | ||
|
|
a7a3aa848e | ||
|
|
b145131505 | ||
|
|
410f3c03d4 | ||
|
|
8a22139d57 | ||
|
|
6a80cd2b7e | ||
|
|
22b21d04bd | ||
|
|
2cddb5bb4e | ||
|
|
a560df3327 | ||
|
|
14d48e9653 | ||
|
|
c374e37cc4 | ||
|
|
54e2c480cb | ||
|
|
43067e01e9 | ||
|
|
ab4a055c05 | ||
|
|
c774bb47c5 | ||
|
|
a52d780e7a | ||
|
|
b6d0201c73 | ||
|
|
1b036a284d | ||
|
|
602db2e04f | ||
|
|
f0ceb4f065 | ||
|
|
d71f10c5a3 | ||
|
|
39ddeff5c3 | ||
|
|
cc183524fd | ||
|
|
b0ee46f862 | ||
|
|
443040e8d7 | ||
|
|
d6eb0d6629 | ||
|
|
017df93ffa | ||
|
|
2f5acfedcd | ||
|
|
18675cc6c1 | ||
|
|
977680d00b | ||
|
|
2f26dbf39e | ||
|
|
873e6e5e6b | ||
|
|
20b70b367e | ||
|
|
f2a30afcf1 | ||
|
|
ec134e7536 | ||
|
|
0568fa30ca | ||
|
|
6e0762a540 | ||
|
|
af212a9f67 | ||
|
|
ebb4c93994 | ||
|
|
fd2fdb5475 | ||
|
|
88f6f5d1b2 | ||
|
|
93a27fd3a9 | ||
|
|
497f5a1199 | ||
|
|
bdc334d797 | ||
|
|
6520396466 | ||
|
|
9716e2745b | ||
|
|
5b3d0f86f7 | ||
|
|
b90e23306e | ||
|
|
8cc29c2e22 | ||
|
|
a3af6bd9f5 | ||
|
|
a23d8ed702 | ||
|
|
3766fb6652 | ||
|
|
a7891e584a | ||
|
|
e82b41724d | ||
|
|
6af7cfff33 | ||
|
|
057fda5352 | ||
|
|
71512ad244 | ||
|
|
edb3967a0f | ||
|
|
dc5129f32e | ||
|
|
ade16a7823 | ||
|
|
f7bdf5d04e | ||
|
|
dcbc10ac38 | ||
|
|
feac8685f4 | ||
|
|
11259b0ea2 | ||
|
|
ac0ba74e87 | ||
|
|
96b7d3653c | ||
|
|
9ccc78c62f | ||
|
|
1d824d4645 | ||
|
|
b26428c43c | ||
|
|
815cb1b31c | ||
|
|
dcf9a395c2 | ||
|
|
2e62d81c24 | ||
|
|
13acf7a6a3 | ||
|
|
f35224b0e4 | ||
|
|
6bcfd0630c | ||
|
|
f4f0174746 | ||
|
|
37b7dda3c5 | ||
|
|
fbcbfbda6a | ||
|
|
de4be56b09 | ||
|
|
f3852c57fc | ||
|
|
2e6d08c652 | ||
|
|
bb260343de | ||
|
|
3f7b3c4bd7 | ||
|
|
95054f443f | ||
|
|
eef72647b4 | ||
|
|
33b6ab11f2 | ||
|
|
dacfb2f596 | ||
|
|
3ac6019f42 | ||
|
|
0f7af8043a | ||
|
|
14a1e673c6 | ||
|
|
802ed62d5b | ||
|
|
572fc058d3 | ||
|
|
b348cdeae8 | ||
|
|
ea2273dde5 | ||
|
|
ad3b837ad5 | ||
|
|
b56bdc83af | ||
|
|
2e7dbe6c6b | ||
|
|
309ac75284 | ||
|
|
4f5c725dde | ||
|
|
5b6397aaa6 | ||
|
|
2928fe5c43 | ||
|
|
5da4f032c3 | ||
|
|
c5e68ec165 | ||
|
|
78e0b80dc7 | ||
|
|
073d8c2177 | ||
|
|
d194a84ae4 | ||
|
|
4bca6fe672 | ||
|
|
cdf33ff3dc | ||
|
|
08b203fed1 | ||
|
|
736befe90f | ||
|
|
b6c5e9a126 | ||
|
|
4ebe54043a | ||
|
|
e6f5f60f3a | ||
|
|
48facf6343 | ||
|
|
170f2f61f9 | ||
|
|
0244a73c49 | ||
|
|
9089d55342 | ||
|
|
9e0547b98f | ||
|
|
b97db68f0c | ||
|
|
436a6d5c0f | ||
|
|
a64bdbd306 | ||
|
|
ac6aeae915 | ||
|
|
f92f851f11 | ||
|
|
99e21a2235 | ||
|
|
f7d3dc742d | ||
|
|
cf6e215a66 | ||
|
|
e4688f1c5a | ||
|
|
315daf1a10 | ||
|
|
75e81f00e2 | ||
|
|
ec71440f09 | ||
|
|
2a825310ea | ||
|
|
323edb9d53 | ||
|
|
726bab0293 | ||
|
|
b52367e3b2 | ||
|
|
9ff1f6bbde | ||
|
|
97dd680b32 | ||
|
|
8098ca3b66 | ||
|
|
8f63fdb278 | ||
|
|
c5da330cdf | ||
|
|
9e89ec041e | ||
|
|
070bbcfc3d | ||
|
|
cef9cd3cfc | ||
|
|
ed4f4b3954 | ||
|
|
cfb6069b83 | ||
|
|
caacc4580f | ||
|
|
f3b03908f9 | ||
|
|
c6ccf9f2b5 | ||
|
|
5204d6ce45 | ||
|
|
24b5abcc39 | ||
|
|
8ada7fe30b | ||
|
|
d8366115f5 | ||
|
|
e5aad9857d | ||
|
|
75a05c2814 | ||
|
|
64a36170a9 | ||
|
|
871c3fc11e | ||
|
|
6ef1a9150c | ||
|
|
222734b5f5 | ||
|
|
1f08634d62 | ||
|
|
52390120ae | ||
|
|
fb35f06114 | ||
|
|
bfafc6d5fd | ||
|
|
1f07977f09 | ||
|
|
fd23c7bf76 | ||
|
|
1944fdc962 | ||
|
|
12382f064b | ||
|
|
b942c54bea | ||
|
|
0a7dccbad8 | ||
|
|
5f862effaa | ||
|
|
d200cf2e77 | ||
|
|
eb533e04b9 | ||
|
|
58fa8add31 | ||
|
|
34afa3b8a5 | ||
|
|
17ef05672b | ||
|
|
c5fe173e47 | ||
|
|
456ea04683 | ||
|
|
0e5fc9c4e4 | ||
|
|
cf5689371a | ||
|
|
e788b9f959 | ||
|
|
d3d09ff25f | ||
|
|
2c259990da | ||
|
|
e2d60940a2 | ||
|
|
dc786996ef | ||
|
|
cc3ac9b1da | ||
|
|
431faf58ff | ||
|
|
63ae55be2b | ||
|
|
14d6a70fa8 | ||
|
|
1ff6fc6491 | ||
|
|
a376d09be5 | ||
|
|
02d7203b4f | ||
|
|
e65cc8a245 | ||
|
|
dc1eca14f0 | ||
|
|
0b7b2f5a57 | ||
|
|
6cff48112d | ||
|
|
fe0a577c8b | ||
|
|
91e93e6a5a | ||
|
|
a1ef49c26f | ||
|
|
339f4b8c31 | ||
|
|
406b0fdbcc | ||
|
|
349972368c | ||
|
|
4225524b6f | ||
|
|
aac916857d | ||
|
|
25246c6db7 | ||
|
|
800689fc81 | ||
|
|
d9fbead8ca | ||
|
|
496c741513 | ||
|
|
c392710802 | ||
|
|
b0886e2abf | ||
|
|
3d35f01bd1 | ||
|
|
d86662cb80 | ||
|
|
afa3bd2143 | ||
|
|
196cb2dda4 | ||
|
|
fc75080c28 | ||
|
|
f8d41f1f68 | ||
|
|
6ea1bacc73 | ||
|
|
6324270221 | ||
|
|
41afeb744a | ||
|
|
219693d91f | ||
|
|
25c80f314b | ||
|
|
5d505f9139 | ||
|
|
bc39964ece | ||
|
|
abea1196de | ||
|
|
1308f790ad | ||
|
|
095f304d7d | ||
|
|
5a54d90d72 | ||
|
|
003fdd2382 | ||
|
|
5b9b33f32d | ||
|
|
5ee3915c40 | ||
|
|
dcead89507 | ||
|
|
6f2f3ed1ac | ||
|
|
738c8c047e | ||
|
|
d224f5d998 | ||
|
|
f8a9f628ae | ||
|
|
6995b51f2c | ||
|
|
c989ea43f5 | ||
|
|
b0c4c79c49 | ||
|
|
eb4038d626 | ||
|
|
7562a8b662 | ||
|
|
c75a1f08fd | ||
|
|
1085c28612 | ||
|
|
eca9bffb01 | ||
|
|
b28a865436 | ||
|
|
57d682a050 | ||
|
|
8c5f26373b | ||
|
|
87f09131aa | ||
|
|
371b347ee9 | ||
|
|
ad2627b05a | ||
|
|
bb012c3db2 | ||
|
|
387dd67b60 | ||
|
|
b22eb0d65f | ||
|
|
ec46d57816 | ||
|
|
e296d4826f | ||
|
|
3cfe94c5ef | ||
|
|
7e82e12468 | ||
|
|
f81908711b | ||
|
|
2b955a5ae1 | ||
|
|
aeedd36168 | ||
|
|
e57cb713b2 | ||
|
|
a098bf30d4 | ||
|
|
f1692f3274 | ||
|
|
a39dc1b78a | ||
|
|
ead5275d63 | ||
|
|
4e8c21549b | ||
|
|
ed081c8834 | ||
|
|
f99dabbac6 | ||
|
|
707b1d1b79 | ||
|
|
026711e750 | ||
|
|
b9f569f7fb | ||
|
|
0a5f51fd03 | ||
|
|
d20e2ec349 | ||
|
|
f9417e3fcc | ||
|
|
41c352c306 | ||
|
|
1ef0f6beff | ||
|
|
c70eb81e32 | ||
|
|
38681d0a2b | ||
|
|
c5097ae483 | ||
|
|
5bb196dce3 | ||
|
|
cb47de5eca | ||
|
|
56a8e17b21 | ||
|
|
e3b23842dd | ||
|
|
12cb35ef61 | ||
|
|
2fb8839d31 | ||
|
|
6578498e31 | ||
|
|
2e1feb63e4 | ||
|
|
9e626c5fee | ||
|
|
78a89c666b | ||
|
|
6352afb07a | ||
|
|
683d8033f0 | ||
|
|
e2bb8088d4 | ||
|
|
64116e5d7c | ||
|
|
219a6b175b | ||
|
|
2a8b36c761 | ||
|
|
b853671132 | ||
|
|
2fbf560668 | ||
|
|
cd067bca37 | ||
|
|
98d4e186e3 | ||
|
|
8680a08a8d | ||
|
|
3b259b4243 | ||
|
|
25feb9232d | ||
|
|
590bde5e14 | ||
|
|
88dac36c91 | ||
|
|
7842040d9d | ||
|
|
3237c6751a | ||
|
|
7a5ec96d53 | ||
|
|
5ae80d541b | ||
|
|
25ac23ab17 | ||
|
|
a3b65ad481 | ||
|
|
9d2c9df992 | ||
|
|
7ceb8d1ab8 | ||
|
|
a609e52a14 | ||
|
|
39875c90f1 | ||
|
|
3290c6b335 | ||
|
|
0f93515ede | ||
|
|
dfc25d0ca5 | ||
|
|
db0beb6c36 | ||
|
|
7b240d82fd | ||
|
|
704433f3d6 | ||
|
|
8ae7d01d1a | ||
|
|
2bd8ef83d1 | ||
|
|
c108088110 | ||
|
|
cb7715a572 | ||
|
|
2e1e893675 | ||
|
|
3796d7a6a1 | ||
|
|
b08bc02cde | ||
|
|
04e873f78e | ||
|
|
04da9257ef | ||
|
|
cae601a682 | ||
|
|
f2aabeefd5 | ||
|
|
1d288b69e2 | ||
|
|
cac85d2a12 | ||
|
|
381f55b3cb | ||
|
|
04fa85f67f | ||
|
|
bacf6511a6 | ||
|
|
4e01ab59c1 | ||
|
|
a46040a4fa | ||
|
|
b458201874 | ||
|
|
99ea50649a | ||
|
|
9d2e23413e | ||
|
|
4b53cd9c3c | ||
|
|
ee88e0054b | ||
|
|
e77fa72d6d | ||
|
|
2fa9ca1f6d | ||
|
|
a2d1a5258b | ||
|
|
009c00cdc6 | ||
|
|
1a0fbf84f9 | ||
|
|
9ea391e03d | ||
|
|
6bcf4b1112 | ||
|
|
82bd1d98d5 | ||
|
|
de625bfb65 | ||
|
|
c751d42d1a | ||
|
|
198f5f237f | ||
|
|
dc5b27069a | ||
|
|
6a829e0179 | ||
|
|
4085ba309a | ||
|
|
975d677f55 | ||
|
|
21be9a3309 | ||
|
|
7456b9ae17 | ||
|
|
35349643af | ||
|
|
952e3bac2c | ||
|
|
d705f4cbac | ||
|
|
5d94221c61 | ||
|
|
f124732431 | ||
|
|
d944219b28 | ||
|
|
86961d0f44 | ||
|
|
3dde669ee8 | ||
|
|
ccdeb915fa | ||
|
|
5345b08d24 | ||
|
|
54d27a390b | ||
|
|
ba44dca34a | ||
|
|
61d91579df | ||
|
|
ea2e2def55 | ||
|
|
a7a06a483e | ||
|
|
388b601503 | ||
|
|
2b8b76a527 | ||
|
|
cbddbdb296 | ||
|
|
06701786c4 | ||
|
|
1c45285fe3 | ||
|
|
18c0cfa6f5 | ||
|
|
32ae3a52b8 | ||
|
|
e198b6945c | ||
|
|
f1f73eff04 | ||
|
|
9adb232d99 | ||
|
|
63bffbc460 | ||
|
|
3e128abb73 | ||
|
|
820fb3b82b | ||
|
|
03263bb5b6 | ||
|
|
b0a1e2988b | ||
|
|
571592a5a4 | ||
|
|
d1da48ff0f | ||
|
|
6c214ed386 | ||
|
|
b29f7b9acb | ||
|
|
c2f516067f | ||
|
|
58cae1d8de | ||
|
|
a9d4d9ad85 | ||
|
|
e043dabcb8 | ||
|
|
3de3fb53bd | ||
|
|
d6d85ade8e | ||
|
|
1278e8cebc | ||
|
|
de0ec9b33c | ||
|
|
3b99827540 | ||
|
|
635c909aab | ||
|
|
f894da13b0 | ||
|
|
c27633dff4 | ||
|
|
c1a02d6556 | ||
|
|
ec43dd067c | ||
|
|
f3d391e3f2 | ||
|
|
851f490168 | ||
|
|
07f99c06ea | ||
|
|
d0643250f7 | ||
|
|
f56b00718b | ||
|
|
af555bd879 | ||
|
|
b61e1fd69f | ||
|
|
c8ff67ab75 | ||
|
|
f72942bff1 | ||
|
|
36371357cd | ||
|
|
750bd9a88b | ||
|
|
5660b1e225 | ||
|
|
acfded9687 | ||
|
|
a9f4c208a0 | ||
|
|
bca7a6baa9 | ||
|
|
3cb3d8f981 | ||
|
|
9904da9a48 | ||
|
|
8d9328fbee | ||
|
|
eaa5d071ef | ||
|
|
d86f0a1686 | ||
|
|
f0566f3790 | ||
|
|
f5f790863d | ||
|
|
10386edea5 | ||
|
|
4ccc3d9fb3 | ||
|
|
77fa7ce977 | ||
|
|
2c8ab72269 | ||
|
|
df179ed28d | ||
|
|
3ec0e2f132 | ||
|
|
477ac313ab | ||
|
|
72e559458f | ||
|
|
21f0b2bd2a | ||
|
|
cc2936cfdf | ||
|
|
d20e664ea8 | ||
|
|
fee7683b86 | ||
|
|
d7e7c2b17f | ||
|
|
1afa41477d | ||
|
|
217848ca52 | ||
|
|
486b6b9096 | ||
|
|
18c49285a8 | ||
|
|
fb74f5576d | ||
|
|
4aa2b093ff | ||
|
|
446065b88c | ||
|
|
594aaec7bb | ||
|
|
07994f50f3 | ||
|
|
1c6e166af5 | ||
|
|
0b9a2f6be6 | ||
|
|
0c73140b07 | ||
|
|
02cbd24165 | ||
|
|
f4be3782a2 | ||
|
|
bb9876bd6e | ||
|
|
2bf6f28152 | ||
|
|
a7dedb3a13 | ||
|
|
4b61a4d3de | ||
|
|
285a36f9de | ||
|
|
5a1a2616aa | ||
|
|
0d1804b2a0 | ||
|
|
0b9530efd7 | ||
|
|
6bbd92368f | ||
|
|
7b8eb3e09c | ||
|
|
774b2f99f2 | ||
|
|
a7395118af | ||
|
|
3897a88082 | ||
|
|
0a61aad499 | ||
|
|
5abecadfd3 | ||
|
|
fff59271af | ||
|
|
d5a0dd39a1 | ||
|
|
ccabee764b | ||
|
|
5283b94bf9 | ||
|
|
6f6c5c07f0 | ||
|
|
3a29555772 | ||
|
|
145e40c2f6 | ||
|
|
41dea03007 | ||
|
|
3ac9858726 | ||
|
|
bbaab755e3 | ||
|
|
8fd6463ab0 | ||
|
|
92fe82a208 | ||
|
|
4ff7cf2bcc | ||
|
|
f6a6ca8a22 | ||
|
|
c9615a201c | ||
|
|
921b474919 | ||
|
|
06960704c4 | ||
|
|
f8b738e6c2 | ||
|
|
b036fdfee0 | ||
|
|
3930f17d9d | ||
|
|
9eb521fb38 | ||
|
|
27625d2665 | ||
|
|
0593696344 | ||
|
|
2cabfa5589 | ||
|
|
0134d62681 | ||
|
|
0799317ff5 | ||
|
|
686a26d948 | ||
|
|
cd5bfbfead | ||
|
|
9a7209d58e | ||
|
|
f89a045605 | ||
|
|
a353a94b70 | ||
|
|
5498a31493 | ||
|
|
6b34b97c29 | ||
|
|
6a8ee19bf0 | ||
|
|
cf690ae513 | ||
|
|
cd8b7f5219 | ||
|
|
37b18243f4 | ||
|
|
e356168c9a | ||
|
|
6f29d7211e | ||
|
|
414db313c6 | ||
|
|
63eec70350 | ||
|
|
c0d9175bc3 | ||
|
|
89965aa5db | ||
|
|
238beb72ee | ||
|
|
6c046704c7 | ||
|
|
5dc4b22d31 | ||
|
|
95ab4815de | ||
|
|
a7aed98d59 | ||
|
|
c4b68d88e9 | ||
|
|
d4368fabb9 | ||
|
|
9a5df9da41 | ||
|
|
756a338b05 | ||
|
|
e887fb69bd | ||
|
|
fb5bca8bc5 | ||
|
|
0d317a2e49 | ||
|
|
77e317c1eb | ||
|
|
db729b5b52 | ||
|
|
97b4f12112 | ||
|
|
926cabec78 | ||
|
|
621a934160 | ||
|
|
c65033a13b | ||
|
|
67f33cdb60 | ||
|
|
964c88a189 | ||
|
|
62b39d58ca | ||
|
|
3e85d7759b | ||
|
|
7445f9bdcc | ||
|
|
e2649ce7d8 | ||
|
|
71f94c7a3a | ||
|
|
41d6207376 | ||
|
|
82d17cb05d | ||
|
|
26137977cd | ||
|
|
cbffd598f9 | ||
|
|
2e35b1c855 | ||
|
|
ea6b53578f | ||
|
|
2fc46f638f | ||
|
|
a991570677 | ||
|
|
d4ba5b4638 | ||
|
|
b02c0e6f46 | ||
|
|
7916981da2 | ||
|
|
7896ee23a2 | ||
|
|
c5790e39dc | ||
|
|
8bc3dcd17a | ||
|
|
eab5376c25 | ||
|
|
56b15eadea | ||
|
|
61c31f8e21 | ||
|
|
8918770892 | ||
|
|
89e8ad4947 | ||
|
|
94988f89b0 | ||
|
|
b305020c1d | ||
|
|
782417b1fa | ||
|
|
38b14fc912 | ||
|
|
ac9e0b458d | ||
|
|
d6e3360aef | ||
|
|
1ee0efbe5c | ||
|
|
aac31159b8 | ||
|
|
0aa1c3c6c3 | ||
|
|
02a95a3eba | ||
|
|
996ddba715 | ||
|
|
88809b0e0b | ||
|
|
88959079bd | ||
|
|
0698b5f1be | ||
|
|
28c39d5151 | ||
|
|
5427ec4844 | ||
|
|
aef898ad93 | ||
|
|
c05ca68811 | ||
|
|
489d873306 | ||
|
|
3834f0c6a6 | ||
|
|
7c26ec8bd4 | ||
|
|
eb63bea87c | ||
|
|
5639faf069 | ||
|
|
090a5d9a61 | ||
|
|
622bad1cff | ||
|
|
5b260dbee3 | ||
|
|
f0ca9dff81 | ||
|
|
9382d48708 | ||
|
|
54222bdf28 | ||
|
|
2931c27395 | ||
|
|
31123f908d | ||
|
|
99a5258999 | ||
|
|
5e8059e0fa | ||
|
|
08a9af3a85 | ||
|
|
d186fd78e3 | ||
|
|
6524a33ffc | ||
|
|
21df08d536 | ||
|
|
cfd2a029ad | ||
|
|
c78567aba6 | ||
|
|
9ca684d87f | ||
|
|
128feb17cb | ||
|
|
3eb5f8d521 | ||
|
|
b266533dfc | ||
|
|
1b5b29901c | ||
|
|
468d8b7707 | ||
|
|
1da97f729e | ||
|
|
f9683ff99f | ||
|
|
a7fdd04751 | ||
|
|
5979dab13c | ||
|
|
c9739abf7f | ||
|
|
39330affda | ||
|
|
d6684c4dcd | ||
|
|
4770d2b526 | ||
|
|
2b689a21e7 | ||
|
|
b084dc29ea | ||
|
|
c4d74c48e4 | ||
|
|
436775b1e4 | ||
|
|
aa2824621a | ||
|
|
651eaec64f | ||
|
|
92577c37c8 | ||
|
|
04c68745db | ||
|
|
81f2e76e36 | ||
|
|
18fca785c4 | ||
|
|
a1066617a8 | ||
|
|
a1dfdbdde4 | ||
|
|
63a138b6de | ||
|
|
5167ccd147 | ||
|
|
cb0845fc49 | ||
|
|
11449b2e8c | ||
|
|
bee5ced8f4 | ||
|
|
bea1a0643c | ||
|
|
f111bb4107 | ||
|
|
f20ca63dd0 | ||
|
|
98e18a62e2 | ||
|
|
9624bc1403 | ||
|
|
fc1ce3eeab | ||
|
|
095d711848 | ||
|
|
a1dca8afc9 | ||
|
|
86321a2c60 | ||
|
|
2e5c92d41e | ||
|
|
f767f0f048 | ||
|
|
93ce2f7800 | ||
|
|
5d028f9163 | ||
|
|
446399c3c1 | ||
|
|
0ef6d4631d | ||
|
|
b87d86e9d5 | ||
|
|
35e000024c | ||
|
|
9e51c779e1 | ||
|
|
6f8eb282b7 | ||
|
|
301b8ec39a | ||
|
|
2986b7bc4a | ||
|
|
89feefac2c | ||
|
|
68a6b39920 | ||
|
|
eeffa42513 | ||
|
|
8b30439d7f | ||
|
|
01005688b6 | ||
|
|
00d9baa605 | ||
|
|
9e91f319c1 | ||
|
|
619bb31de2 | ||
|
|
dcb3a13361 | ||
|
|
c2663e48c1 | ||
|
|
621715e5e5 | ||
|
|
b9991f0494 | ||
|
|
c259b4294d | ||
|
|
4867475cee | ||
|
|
8822c7d87d | ||
|
|
06cfcd612d | ||
|
|
1404ea1c2c | ||
|
|
4deb7c6fa7 | ||
|
|
b9e950f5c7 | ||
|
|
134f8afbe6 | ||
|
|
50019f39e9 | ||
|
|
5f596b22c7 | ||
|
|
cbb68f6980 | ||
|
|
61576c39be | ||
|
|
9536ebc0ad | ||
|
|
723a3eda8b | ||
|
|
a5fd6507a9 | ||
|
|
dbe57c4ad4 | ||
|
|
ad5f944185 | ||
|
|
2044208fd6 | ||
|
|
2d7ceae320 | ||
|
|
0410a184ce | ||
|
|
7cfe1dd0af | ||
|
|
4de2493d89 | ||
|
|
b86dff45d7 | ||
|
|
fb8339830e | ||
|
|
ec7cae4a34 | ||
|
|
80a7835cdf | ||
|
|
50be8b65d1 | ||
|
|
174e51507d | ||
|
|
494afec01d | ||
|
|
aeefee7348 | ||
|
|
c1af62a3b3 | ||
|
|
11f8923c43 | ||
|
|
63ebc41778 | ||
|
|
1a9b4b4671 | ||
|
|
8a29604f1e | ||
|
|
483e007b69 | ||
|
|
2d8a61a775 | ||
|
|
5e62d28e50 | ||
|
|
2cf30c0d63 | ||
|
|
16253fe708 | ||
|
|
84a3fe50dc | ||
|
|
8ad50d1e35 | ||
|
|
ad638097b6 | ||
|
|
356d0520ae | ||
|
|
999b349e94 | ||
|
|
76375a83eb | ||
|
|
ea534aa564 | ||
|
|
055e49ab9c | ||
|
|
0d43e239d4 | ||
|
|
c04a0381dc | ||
|
|
5cebe65310 | ||
|
|
ab5a49b6ae | ||
|
|
7b463297c6 | ||
|
|
debdce1e66 | ||
|
|
8a2706d2f4 | ||
|
|
709dd0bf18 | ||
|
|
de78f3441e | ||
|
|
f23624755e | ||
|
|
0c265f8ed4 | ||
|
|
c1f2e30c5a | ||
|
|
3b415b2e99 | ||
|
|
bea9f78ddb | ||
|
|
95484a1b1a | ||
|
|
a0065e62fa | ||
|
|
3aab713d24 | ||
|
|
5d6f180413 | ||
|
|
a69ee76705 | ||
|
|
7971ce0dd9 | ||
|
|
4159a6a41d | ||
|
|
e49af23a7d | ||
|
|
30117816be | ||
|
|
b6ece7d16c | ||
|
|
6fda4fc45c | ||
|
|
18e1de105f | ||
|
|
133ad6e18b | ||
|
|
b84fed5cb2 | ||
|
|
a737732521 | ||
|
|
f454cb3408 | ||
|
|
d18a9eaf65 | ||
|
|
059433511c | ||
|
|
acacb3f551 | ||
|
|
0008bc5f82 | ||
|
|
a3e10aba95 | ||
|
|
73774f21b7 | ||
|
|
3c18de9c5a | ||
|
|
19a5d2ba2b | ||
|
|
16f57b219b | ||
|
|
0485069c7b | ||
|
|
e4d6aa30a1 | ||
|
|
89a26684e5 | ||
|
|
0e1c2b0fcb | ||
|
|
6eab14359c | ||
|
|
76f96bd99c | ||
|
|
48bcad87c2 | ||
|
|
712b15286c | ||
|
|
3053be345b | ||
|
|
8e834e9047 | ||
|
|
3e34760eef | ||
|
|
e0afb814aa | ||
|
|
0fd35cf768 | ||
|
|
0b86acfef4 | ||
|
|
36ee417d3b | ||
|
|
a1a07aed44 | ||
|
|
f0731be20b | ||
|
|
58278ee095 | ||
|
|
494a025fb8 | ||
|
|
ade8401b5b | ||
|
|
ef9d8fe9bd | ||
|
|
471b9980ec | ||
|
|
9c65b9a9f2 | ||
|
|
21105271a4 | ||
|
|
7e90bb47a5 | ||
|
|
ac68de6215 | ||
|
|
8e203592e2 | ||
|
|
9f18a6e65c | ||
|
|
857e1da6a3 | ||
|
|
75b010ce63 | ||
|
|
124fbdbd74 | ||
|
|
cf0cd5b50b | ||
|
|
0e9d973715 | ||
|
|
cc18670ae1 | ||
|
|
6228ce3f35 | ||
|
|
89511bb0cb | ||
|
|
11bc993344 | ||
|
|
9126ab6766 | ||
|
|
49cb675057 | ||
|
|
e8b119e636 | ||
|
|
e8bb79310c | ||
|
|
da3dbdcb9b | ||
|
|
b400edcc88 | ||
|
|
6580088574 | ||
|
|
794479519c | ||
|
|
97d468cf35 | ||
|
|
af6a3b3173 | ||
|
|
0c8160bfe3 | ||
|
|
a584acef46 | ||
|
|
691ad97abe | ||
|
|
836cd017a9 | ||
|
|
e70f8acf47 | ||
|
|
721924b749 | ||
|
|
7880d37d73 | ||
|
|
ba6bb45f70 | ||
|
|
379c3470c8 | ||
|
|
038718717c | ||
|
|
b8f09ecf4f | ||
|
|
e9a2792b55 | ||
|
|
aa3bc13ca3 | ||
|
|
ed3a2dae1b | ||
|
|
48eaee0c0e | ||
|
|
6b2848307d | ||
|
|
651a2d4399 | ||
|
|
7c48dd54e1 | ||
|
|
5968346c1e | ||
|
|
266d3b553b | ||
|
|
53ff706cd2 | ||
|
|
651b0c0f82 | ||
|
|
3f8e173452 | ||
|
|
078c924760 | ||
|
|
611614c649 | ||
|
|
dda3fcef91 | ||
|
|
92f8c105d9 | ||
|
|
4ee308fcc2 | ||
|
|
dfefa00a50 | ||
|
|
44146009ad | ||
|
|
b376c29937 | ||
|
|
c657186920 | ||
|
|
f613d8d0d0 | ||
|
|
a506df4d25 | ||
|
|
a0772dbbe9 | ||
|
|
f603e47226 | ||
|
|
4b0b875d6f | ||
|
|
d50cabddc0 | ||
|
|
cbda2a3e60 | ||
|
|
2006d64939 | ||
|
|
d9f3355dea | ||
|
|
c8263a9a18 | ||
|
|
6d2e9f5311 | ||
|
|
bb6d15ee10 | ||
|
|
56f7aceec7 | ||
|
|
933e013e7e | ||
|
|
a2b3abbf47 | ||
|
|
c61414e11b | ||
|
|
29470dd018 | ||
|
|
ed878b400e | ||
|
|
fbe4394bbd | ||
|
|
3e0d8841ea | ||
|
|
aeb774730b | ||
|
|
6d92457095 | ||
|
|
8fa3057e19 | ||
|
|
eed8f201e2 | ||
|
|
0add800240 | ||
|
|
9356843e27 | ||
|
|
02a7094529 | ||
|
|
76da80c5e9 | ||
|
|
7078ed80fa | ||
|
|
e97d3c21a3 | ||
|
|
9e266642f9 | ||
|
|
0f5bfadd2b | ||
|
|
d85c4da11b | ||
|
|
d982376fc4 | ||
|
|
d26601f695 | ||
|
|
0ec57cca32 | ||
|
|
cf5fc3f922 | ||
|
|
1f60aff73d | ||
|
|
9b19e6ee38 | ||
|
|
6bac17fb9a | ||
|
|
e759ce72b5 | ||
|
|
b44371f4bf | ||
|
|
9736dc3115 | ||
|
|
18ac4178fe | ||
|
|
2f7cceb11c | ||
|
|
002462ce7b | ||
|
|
4d305b06d1 | ||
|
|
9673cee4d7 | ||
|
|
526debb5ab | ||
|
|
fb444f646b | ||
|
|
26f76f8d41 | ||
|
|
9ae18c6194 | ||
|
|
9e425cd01e | ||
|
|
171b901c61 | ||
|
|
fbade9305c | ||
|
|
082cd9b72c | ||
|
|
e9db926b48 | ||
|
|
bdb3f4d4cb | ||
|
|
b44d5290e2 | ||
|
|
6a36deec3b | ||
|
|
6d7f179a9b | ||
|
|
61278f9ace | ||
|
|
7ffc1faf5b | ||
|
|
1c3b5835f4 | ||
|
|
1718697ef0 | ||
|
|
144a61c5a3 | ||
|
|
f7bf8c4fdc | ||
|
|
6f64ad30cb | ||
|
|
1c7d5df2fe | ||
|
|
65e6da2673 | ||
|
|
39a5c7dab9 | ||
|
|
b4cc3541a8 | ||
|
|
68c2c9825f | ||
|
|
3aad6a0c99 | ||
|
|
2556ed8744 | ||
|
|
f35536bdc5 | ||
|
|
775328d5d5 | ||
|
|
1a03e62717 | ||
|
|
31b4f61815 | ||
|
|
076e033236 | ||
|
|
2c50f14346 | ||
|
|
82e593b44f | ||
|
|
224d2ca93c | ||
|
|
0841c4291a | ||
|
|
271733fc53 | ||
|
|
a2a44621fd | ||
|
|
ad48aeeea4 | ||
|
|
83f47bc980 | ||
|
|
67a09d9fe0 | ||
|
|
189ae97732 | ||
|
|
632739ec6e | ||
|
|
88ac376382 | ||
|
|
b2559d7d28 | ||
|
|
98387e50cc | ||
|
|
93464b8100 | ||
|
|
52783bb67f | ||
|
|
c90d4abcf0 | ||
|
|
6f85d85c12 | ||
|
|
280235872b | ||
|
|
e93eaed5d0 | ||
|
|
32cff67fd4 | ||
|
|
d3f40212db | ||
|
|
11ad9e7f25 | ||
|
|
0c44d19249 | ||
|
|
7c17aeb6da | ||
|
|
8c19d3b210 | ||
|
|
9f15191280 | ||
|
|
69790bd7ed | ||
|
|
fdfa0f4a6d | ||
|
|
7f8b180f70 | ||
|
|
43ae784a40 | ||
|
|
6a4d9f8a87 | ||
|
|
e2c646a14b | ||
|
|
337db9fbb9 | ||
|
|
63267031e9 | ||
|
|
88b288502a | ||
|
|
b0fb0c6492 | ||
|
|
3a44663003 | ||
|
|
7549adcfce | ||
|
|
fddbde2fd5 | ||
|
|
6e5951b764 | ||
|
|
3b620b8c0c | ||
|
|
0d82fbcf37 | ||
|
|
5cd20a8e5d | ||
|
|
4ff73d8b56 | ||
|
|
f651b21cda | ||
|
|
7a73c0189f | ||
|
|
0345b62369 | ||
|
|
3a31f28f27 | ||
|
|
a5c62bb264 | ||
|
|
9bddc2cbaa | ||
|
|
43113fcfb4 | ||
|
|
6b207d65bf | ||
|
|
9d0d1c8341 | ||
|
|
82a16ee41f | ||
|
|
a06a1fa262 | ||
|
|
c198828e58 | ||
|
|
5cbbd6efe6 | ||
|
|
00d641aaf7 | ||
|
|
9b4e9c642a | ||
|
|
c6ae27c7c9 | ||
|
|
9ead3ad0a0 | ||
|
|
e7962c7ba2 | ||
|
|
194b14100e | ||
|
|
bd34db256b | ||
|
|
0e13b8dd01 | ||
|
|
ac9e6eda95 | ||
|
|
ba91bbd397 | ||
|
|
63e1b2fb46 | ||
|
|
c0c9e3ac3d | ||
|
|
4347ce4a53 | ||
|
|
9cc8bfae1c | ||
|
|
10ef6749b3 | ||
|
|
32c3f17f5a | ||
|
|
ad45c084cc | ||
|
|
de29f2dde5 | ||
|
|
6f5b0a28c5 | ||
|
|
5cf03e68d4 | ||
|
|
20323e7032 | ||
|
|
78343a62b8 | ||
|
|
b290415bbd | ||
|
|
16069cd477 | ||
|
|
ae1c33b863 | ||
|
|
d21def7b8d | ||
|
|
bd5e622bec | ||
|
|
a5c508d2d7 | ||
|
|
b731ca50bc | ||
|
|
4eb9fc1bb6 | ||
|
|
9b94dfcbdc | ||
|
|
046f48db51 | ||
|
|
b57ffbf1ab | ||
|
|
42bae9d71d | ||
|
|
dcffb51e5e | ||
|
|
8c5751e9f7 | ||
|
|
a655cca0a1 | ||
|
|
e472d11761 | ||
|
|
ec1fc5a17b | ||
|
|
bde30b90e8 | ||
|
|
42adb2afd4 | ||
|
|
0588435882 | ||
|
|
08947682b0 | ||
|
|
cbbc4376ca | ||
|
|
9498a5738a | ||
|
|
fcaf9cb031 | ||
|
|
f7525d7877 | ||
|
|
2b3b41d5f9 | ||
|
|
2d9d4af98d | ||
|
|
81eab9887b | ||
|
|
7521aeea09 | ||
|
|
e8d4abe78f |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -26,5 +26,4 @@ node_modules/
|
||||
*.vcxproj.user
|
||||
*.vcxproj.filters
|
||||
*.sln
|
||||
debug.log
|
||||
npm-debug.log
|
||||
*.log
|
||||
|
||||
5
.gitmodules
vendored
5
.gitmodules
vendored
@@ -12,7 +12,7 @@
|
||||
url = https://github.com/electron/chromium-breakpad.git
|
||||
[submodule "vendor/native_mate"]
|
||||
path = vendor/native_mate
|
||||
url = https://github.com/zcbenz/native-mate.git
|
||||
url = https://github.com/electron/native-mate.git
|
||||
[submodule "vendor/crashpad"]
|
||||
path = vendor/crashpad
|
||||
url = https://github.com/electron/crashpad.git
|
||||
@@ -22,3 +22,6 @@
|
||||
[submodule "vendor/boto"]
|
||||
path = vendor/boto
|
||||
url = https://github.com/boto/boto.git
|
||||
[submodule "vendor/pdf_viewer"]
|
||||
path = vendor/pdf_viewer
|
||||
url = https://github.com/electron/pdf-viewer.git
|
||||
|
||||
@@ -1 +1 @@
|
||||
v6.3.0
|
||||
v7.4.0
|
||||
|
||||
@@ -1,2 +1,35 @@
|
||||
<!--
|
||||
Thanks for opening an issue! A few things to keep in mind:
|
||||
|
||||
- The issue tracker is only for bugs and feature requests.
|
||||
- Before reporting a bug, please try reproducing your issue against
|
||||
the latest version of Electron.
|
||||
- If you need general advice, join our Slack: http://atom-slack.herokuapp.com
|
||||
-->
|
||||
|
||||
* Electron version:
|
||||
* Operating system:
|
||||
|
||||
### Expected behavior
|
||||
|
||||
<!-- What do you think should happen? -->
|
||||
|
||||
### Actual behavior
|
||||
|
||||
<!-- What actually happens? -->
|
||||
|
||||
### How to reproduce
|
||||
|
||||
<!--
|
||||
|
||||
Your best chance of getting this bug looked at quickly is to provide a REPOSITORY that can be cloned and run.
|
||||
|
||||
You can fork https://github.com/electron/electron-quick-start and include a link to the branch with your changes.
|
||||
|
||||
If you provide a URL, please list the commands required to clone/setup/run your repo e.g.
|
||||
|
||||
$ git clone $YOUR_URL -b $BRANCH
|
||||
$ npm install
|
||||
$ npm start || electron .
|
||||
|
||||
-->
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2016 GitHub Inc.
|
||||
Copyright (c) 2013-2017 GitHub Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
31
README.md
31
README.md
@@ -1,16 +1,16 @@
|
||||
[](http://electron.atom.io/)
|
||||
[](https://electron.atom.io/)
|
||||
|
||||
[](https://travis-ci.org/electron/electron)
|
||||
[](https://ci.appveyor.com/project/Atom/electron)
|
||||
[](https://ci.appveyor.com/project/electron-bot/electron/branch/master)
|
||||
[](https://david-dm.org/electron/electron?type=dev)
|
||||
[](http://atom-slack.herokuapp.com/)
|
||||
|
||||
:memo: Available Translations: [Korean](https://github.com/electron/electron/tree/master/docs-translations/ko-KR/project/README.md) | [Simplified Chinese](https://github.com/electron/electron/tree/master/docs-translations/zh-CN/project/README.md)
|
||||
:memo: Available Translations: [Korean](https://github.com/electron/electron/tree/master/docs-translations/ko-KR/project/README.md) | [Simplified Chinese](https://github.com/electron/electron/tree/master/docs-translations/zh-CN/project/README.md) | [Brazilian Portuguese](https://github.com/electron/electron/tree/master/docs-translations/pt-BR/project/README.md) | [Traditional Chinese](https://github.com/electron/electron/tree/master/docs-translations/zh-TW/project/README.md) | [Spanish](https://github.com/electron/electron/tree/master/docs-translations/es/project/README.md)
|
||||
|
||||
The Electron framework lets you write cross-platform desktop applications
|
||||
using JavaScript, HTML and CSS. It is based on [Node.js](https://nodejs.org/) and
|
||||
[Chromium](http://www.chromium.org) and is used by the [Atom
|
||||
editor](https://github.com/atom/atom) and many other [apps](http://electron.atom.io/apps).
|
||||
editor](https://github.com/atom/atom) and many other [apps](https://electron.atom.io/apps).
|
||||
|
||||
Follow [@ElectronJS](https://twitter.com/electronjs) on Twitter for important
|
||||
announcements.
|
||||
@@ -21,20 +21,20 @@ behavior to electron@github.com.
|
||||
|
||||
## Downloads
|
||||
|
||||
Prebuilt binaries and debug symbols of Electron for Linux, Windows and macOS can
|
||||
be found on the [releases](https://github.com/electron/electron/releases) page.
|
||||
|
||||
You can also use [`npm`](https://docs.npmjs.com/) to install prebuilt electron
|
||||
binaries:
|
||||
To install prebuilt Electron binaries, use
|
||||
[`npm`](https://docs.npmjs.com/):
|
||||
|
||||
```sh
|
||||
# Install the `electron` command globally in your $PATH
|
||||
npm install electron -g
|
||||
|
||||
# Install as a development dependency
|
||||
npm install electron --save-dev
|
||||
|
||||
# Install the `electron` command globally in your $PATH
|
||||
npm install electron -g
|
||||
```
|
||||
|
||||
See the [releases page](https://github.com/electron/electron/releases) for
|
||||
prebuilt binaries, debug symbols, and more.
|
||||
|
||||
### Mirrors
|
||||
|
||||
- [China](https://npm.taobao.org/mirrors/electron)
|
||||
@@ -54,6 +54,7 @@ contains documents describing how to build and contribute to Electron.
|
||||
- [Simplified Chinese](https://github.com/electron/electron/tree/master/docs-translations/zh-CN)
|
||||
- [Traditional Chinese](https://github.com/electron/electron/tree/master/docs-translations/zh-TW)
|
||||
- [Turkish](https://github.com/electron/electron/tree/master/docs-translations/tr-TR)
|
||||
- [Thai](https://github.com/electron/electron/tree/master/docs-Translations/th-TH)
|
||||
- [Ukrainian](https://github.com/electron/electron/tree/master/docs-translations/uk-UA)
|
||||
- [Russian](https://github.com/electron/electron/tree/master/docs-translations/ru-RU)
|
||||
- [French](https://github.com/electron/electron/tree/master/docs-translations/fr-FR)
|
||||
@@ -73,7 +74,7 @@ forums
|
||||
- [`Atom`](http://atom-slack.herokuapp.com/) channel on Slack
|
||||
- [`electron-br`](https://electron-br.slack.com) *(Brazilian Portuguese)*
|
||||
- [`electron-kr`](http://www.meetup.com/electron-kr/) *(Korean)*
|
||||
- [`electron-jp`](https://electron-jp-slackin.herokuapp.com/) *(Japanese)*
|
||||
- [`electron-jp`](https://electron-jp.slack.com) *(Japanese)*
|
||||
- [`electron-tr`](http://www.meetup.com/Electron-JS-Istanbul/) *(Turkish)*
|
||||
- [`electron-id`](https://electron-id.slack.com) *(Indonesia)*
|
||||
|
||||
@@ -82,4 +83,6 @@ for a community maintained list of useful example apps, tools and resources.
|
||||
|
||||
## License
|
||||
|
||||
MIT © 2016 Github
|
||||
[MIT](https://github.com/electron/electron/blob/master/LICENSE)
|
||||
|
||||
When using the Electron or other GitHub logos, be sure to follow the [GitHub logo guidelines](https://github.com/logos).
|
||||
|
||||
9
SECURITY.md
Normal file
9
SECURITY.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# Reporting Security Issues
|
||||
|
||||
The Electron team and community take security bugs in Electron seriously. We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions.
|
||||
|
||||
To report a security issue, email [electron@github.com](mailto:electron@github.com) and include the word "SECURITY" in the subject line.
|
||||
|
||||
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).
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/common/atom_constants.h"
|
||||
#include "atom/common/atom_version.h"
|
||||
#include "atom/common/chrome_version.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
@@ -18,12 +19,13 @@
|
||||
#include "content/public/common/content_constants.h"
|
||||
#include "content/public/common/pepper_plugin_info.h"
|
||||
#include "content/public/common/user_agent.h"
|
||||
#include "pdf/pdf.h"
|
||||
#include "ppapi/shared_impl/ppapi_permissions.h"
|
||||
#include "third_party/widevine/cdm/stub/widevine_cdm_version.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "url/url_constants.h"
|
||||
|
||||
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
|
||||
#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS)
|
||||
#include "chrome/common/widevine_cdm_constants.h"
|
||||
#endif
|
||||
|
||||
@@ -71,7 +73,7 @@ content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path,
|
||||
return plugin;
|
||||
}
|
||||
|
||||
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
|
||||
#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS)
|
||||
content::PepperPluginInfo CreateWidevineCdmInfo(const base::FilePath& path,
|
||||
const std::string& version) {
|
||||
content::PepperPluginInfo widevine_cdm;
|
||||
@@ -108,6 +110,25 @@ content::PepperPluginInfo CreateWidevineCdmInfo(const base::FilePath& path,
|
||||
}
|
||||
#endif
|
||||
|
||||
void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
|
||||
content::PepperPluginInfo pdf_info;
|
||||
pdf_info.is_internal = true;
|
||||
pdf_info.is_out_of_process = true;
|
||||
pdf_info.name = "Chromium PDF Viewer";
|
||||
pdf_info.description = "Portable Document Format";
|
||||
pdf_info.path = base::FilePath::FromUTF8Unsafe(kPdfPluginPath);
|
||||
content::WebPluginMimeType pdf_mime_type(kPdfPluginMimeType, "pdf",
|
||||
"Portable Document Format");
|
||||
pdf_info.mime_types.push_back(pdf_mime_type);
|
||||
pdf_info.internal_entry_points.get_interface = chrome_pdf::PPP_GetInterface;
|
||||
pdf_info.internal_entry_points.initialize_module =
|
||||
chrome_pdf::PPP_InitializeModule;
|
||||
pdf_info.internal_entry_points.shutdown_module =
|
||||
chrome_pdf::PPP_ShutdownModule;
|
||||
pdf_info.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV;
|
||||
plugins->push_back(pdf_info);
|
||||
}
|
||||
|
||||
void ConvertStringWithSeparatorToVector(std::vector<std::string>* vec,
|
||||
const char* separator,
|
||||
const char* cmd_switch) {
|
||||
@@ -135,7 +156,7 @@ void AddPepperFlashFromCommandLine(
|
||||
plugins->push_back(CreatePepperFlashInfo(flash_path, flash_version));
|
||||
}
|
||||
|
||||
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
|
||||
#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS)
|
||||
void AddWidevineCdmFromCommandLine(
|
||||
std::vector<content::PepperPluginInfo>* plugins) {
|
||||
auto command_line = base::CommandLine::ForCurrentProcess();
|
||||
@@ -187,9 +208,10 @@ void AtomContentClient::AddAdditionalSchemes(
|
||||
void AtomContentClient::AddPepperPlugins(
|
||||
std::vector<content::PepperPluginInfo>* plugins) {
|
||||
AddPepperFlashFromCommandLine(plugins);
|
||||
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
|
||||
#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS)
|
||||
AddWidevineCdmFromCommandLine(plugins);
|
||||
#endif
|
||||
ComputeBuiltInPlugins(plugins);
|
||||
}
|
||||
|
||||
void AtomContentClient::AddServiceWorkerSchemes(
|
||||
@@ -197,11 +219,20 @@ void AtomContentClient::AddServiceWorkerSchemes(
|
||||
std::vector<std::string> schemes;
|
||||
ConvertStringWithSeparatorToVector(&schemes, ",",
|
||||
switches::kRegisterServiceWorkerSchemes);
|
||||
if (!schemes.empty()) {
|
||||
for (const std::string& scheme : schemes)
|
||||
service_worker_schemes->insert(scheme);
|
||||
}
|
||||
for (const std::string& scheme : schemes)
|
||||
service_worker_schemes->insert(scheme);
|
||||
|
||||
service_worker_schemes->insert(url::kFileScheme);
|
||||
}
|
||||
|
||||
void AtomContentClient::AddSecureSchemesAndOrigins(
|
||||
std::set<std::string>* secure_schemes,
|
||||
std::set<GURL>* secure_origins) {
|
||||
std::vector<std::string> schemes;
|
||||
ConvertStringWithSeparatorToVector(&schemes, ",", switches::kSecureSchemes);
|
||||
for (const std::string& scheme : schemes)
|
||||
secure_schemes->insert(scheme);
|
||||
}
|
||||
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -31,6 +31,9 @@ class AtomContentClient : public brightray::ContentClient {
|
||||
std::vector<content::PepperPluginInfo>* plugins) override;
|
||||
void AddServiceWorkerSchemes(
|
||||
std::set<std::string>* service_worker_schemes) override;
|
||||
void AddSecureSchemesAndOrigins(
|
||||
std::set<std::string>* secure_schemes,
|
||||
std::set<GURL>* secure_origins) override;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomContentClient);
|
||||
|
||||
@@ -102,6 +102,9 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
#if defined(OS_WIN)
|
||||
// Ignore invalid parameter errors.
|
||||
_set_invalid_parameter_handler(InvalidParameterHandler);
|
||||
// Disable the ActiveVerifier, which is used by Chrome to track possible
|
||||
// bugs, but no use in Electron.
|
||||
base::win::DisableHandleVerifier();
|
||||
#endif
|
||||
|
||||
return brightray::MainDelegate::BasicStartupComplete(exit_code);
|
||||
|
||||
@@ -7,18 +7,16 @@
|
||||
#include "atom/app/uv_task_runner.h"
|
||||
#include "atom/browser/javascript_environment.h"
|
||||
#include "atom/browser/node_debugger.h"
|
||||
#include "atom/common/api/atom_bindings.h"
|
||||
#include "atom/common/crash_reporter/crash_reporter.h"
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/feature_list.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "gin/array_buffer.h"
|
||||
#include "gin/public/isolate_holder.h"
|
||||
#include "gin/v8_initializer.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "atom/common/api/atom_bindings.h"
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#endif
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
@@ -48,19 +46,26 @@ int NodeMain(int argc, char *argv[]) {
|
||||
const char** exec_argv;
|
||||
node::Init(&argc, const_cast<const char**>(argv), &exec_argc, &exec_argv);
|
||||
|
||||
node::IsolateData isolate_data(gin_env.isolate(), loop);
|
||||
node::Environment* env = node::CreateEnvironment(
|
||||
gin_env.isolate(), loop, gin_env.context(), argc, argv,
|
||||
&isolate_data, gin_env.context(), argc, argv,
|
||||
exec_argc, exec_argv);
|
||||
|
||||
// Start our custom debugger implementation.
|
||||
NodeDebugger node_debugger(gin_env.isolate());
|
||||
if (node_debugger.IsRunning())
|
||||
env->AssignToContext(v8::Debug::GetDebugContext());
|
||||
env->AssignToContext(v8::Debug::GetDebugContext(gin_env.isolate()));
|
||||
|
||||
#if defined(OS_WIN)
|
||||
mate::Dictionary process(gin_env.isolate(), env->process_object());
|
||||
#if defined(OS_WIN)
|
||||
process.SetMethod("log", &AtomBindings::Log);
|
||||
#endif
|
||||
process.SetMethod("crash", &AtomBindings::Crash);
|
||||
|
||||
// Setup process.crashReporter.start in child node processes
|
||||
auto reporter = mate::Dictionary::CreateEmpty(gin_env.isolate());
|
||||
reporter.SetMethod("start", &crash_reporter::CrashReporter::StartInstance);
|
||||
process.Set("crashReporter", reporter);
|
||||
|
||||
node::LoadEnvironment(env);
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include "atom/browser/api/atom_api_web_contents.h"
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/browser/login_handler.h"
|
||||
#include "atom/browser/relauncher.h"
|
||||
#include "atom/common/atom_command_line.h"
|
||||
@@ -31,6 +30,8 @@
|
||||
#include "base/path_service.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "brightray/browser/brightray_paths.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/icon_manager.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "content/public/browser/browser_accessibility_state.h"
|
||||
#include "content/public/browser/client_certificate_delegate.h"
|
||||
@@ -298,6 +299,8 @@ struct Converter<Browser::LoginItemSettings> {
|
||||
|
||||
dict.Get("openAtLogin", &(out->open_at_login));
|
||||
dict.Get("openAsHidden", &(out->open_as_hidden));
|
||||
dict.Get("path", &(out->path));
|
||||
dict.Get("args", &(out->args));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -312,8 +315,21 @@ struct Converter<Browser::LoginItemSettings> {
|
||||
return dict.GetHandle();
|
||||
}
|
||||
};
|
||||
} // namespace mate
|
||||
|
||||
template<>
|
||||
struct Converter<content::CertificateRequestResultType> {
|
||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
||||
content::CertificateRequestResultType* out) {
|
||||
bool b;
|
||||
if (!ConvertFromV8(isolate, val, &b))
|
||||
return false;
|
||||
*out = b ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE :
|
||||
content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -321,6 +337,15 @@ namespace api {
|
||||
|
||||
namespace {
|
||||
|
||||
IconLoader::IconSize GetIconSizeByString(const std::string& size) {
|
||||
if (size == "small") {
|
||||
return IconLoader::IconSize::SMALL;
|
||||
} else if (size == "large") {
|
||||
return IconLoader::IconSize::LARGE;
|
||||
}
|
||||
return IconLoader::IconSize::NORMAL;
|
||||
}
|
||||
|
||||
// Return the path constant from string.
|
||||
int GetPathConstant(const std::string& name) {
|
||||
if (name == "appData")
|
||||
@@ -378,9 +403,21 @@ void OnClientCertificateSelected(
|
||||
v8::Isolate* isolate,
|
||||
std::shared_ptr<content::ClientCertificateDelegate> delegate,
|
||||
mate::Arguments* args) {
|
||||
if (args->Length() == 2) {
|
||||
delegate->ContinueWithCertificate(nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> val;
|
||||
args->GetNext(&val);
|
||||
if (val->IsNull()) {
|
||||
delegate->ContinueWithCertificate(nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
mate::Dictionary cert_data;
|
||||
if (!args->GetNext(&cert_data)) {
|
||||
args->ThrowError();
|
||||
if (!mate::ConvertFromV8(isolate, val, &cert_data)) {
|
||||
args->ThrowError("Must pass valid certificate object.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -436,6 +473,21 @@ int ImportIntoCertStore(
|
||||
}
|
||||
#endif
|
||||
|
||||
void OnIconDataAvailable(v8::Isolate* isolate,
|
||||
const App::FileIconCallback& callback,
|
||||
gfx::Image* icon) {
|
||||
v8::Locker locker(isolate);
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
||||
if (icon && !icon->IsEmpty()) {
|
||||
callback.Run(v8::Null(isolate), *icon);
|
||||
} else {
|
||||
v8::Local<v8::String> error_message =
|
||||
v8::String::NewFromUtf8(isolate, "Failed to get file icon.");
|
||||
callback.Run(v8::Exception::Error(error_message), gfx::Image());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
App::App(v8::Isolate* isolate) {
|
||||
@@ -528,12 +580,14 @@ void App::OnLogin(LoginHandler* login_handler,
|
||||
login_handler->CancelAuth();
|
||||
}
|
||||
|
||||
void App::OnCreateWindow(const GURL& target_url,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const std::vector<base::string16>& features,
|
||||
int render_process_id,
|
||||
int render_frame_id) {
|
||||
void App::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) {
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
content::RenderFrameHost* rfh =
|
||||
@@ -545,7 +599,8 @@ void App::OnCreateWindow(const GURL& target_url,
|
||||
api_web_contents->OnCreateWindow(target_url,
|
||||
frame_name,
|
||||
disposition,
|
||||
features);
|
||||
features,
|
||||
body);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -558,8 +613,8 @@ void App::AllowCertificateError(
|
||||
bool overridable,
|
||||
bool strict_enforcement,
|
||||
bool expired_previous_decision,
|
||||
const base::Callback<void(bool)>& callback,
|
||||
content::CertificateRequestResultType* request) {
|
||||
const base::Callback<void(content::CertificateRequestResultType)>&
|
||||
callback) {
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
bool prevent_default = Emit("certificate-error",
|
||||
@@ -571,7 +626,7 @@ void App::AllowCertificateError(
|
||||
|
||||
// Deny the certificate by default.
|
||||
if (!prevent_default)
|
||||
*request = content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY;
|
||||
callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
|
||||
}
|
||||
|
||||
void App::SelectClientCertificate(
|
||||
@@ -718,6 +773,12 @@ bool App::IsAccessibilitySupportEnabled() {
|
||||
return ax_state->IsAccessibleBrowser();
|
||||
}
|
||||
|
||||
Browser::LoginItemSettings App::GetLoginItemSettings(mate::Arguments* args) {
|
||||
Browser::LoginItemSettings options;
|
||||
args->GetNext(&options);
|
||||
return Browser::Get()->GetLoginItemSettings(options);
|
||||
}
|
||||
|
||||
#if defined(USE_NSS_CERTS)
|
||||
void App::ImportCertificate(
|
||||
const base::DictionaryValue& options,
|
||||
@@ -806,6 +867,43 @@ JumpListResult App::SetJumpList(v8::Local<v8::Value> val,
|
||||
}
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
void App::GetFileIcon(const base::FilePath& path,
|
||||
mate::Arguments* args) {
|
||||
mate::Dictionary options;
|
||||
IconLoader::IconSize icon_size;
|
||||
FileIconCallback callback;
|
||||
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
|
||||
base::FilePath normalized_path = path.NormalizePathSeparators();
|
||||
|
||||
if (!args->GetNext(&options)) {
|
||||
icon_size = IconLoader::IconSize::NORMAL;
|
||||
} else {
|
||||
std::string icon_size_string;
|
||||
options.Get("size", &icon_size_string);
|
||||
icon_size = GetIconSizeByString(icon_size_string);
|
||||
}
|
||||
|
||||
if (!args->GetNext(&callback)) {
|
||||
args->ThrowError("Missing required callback function");
|
||||
return;
|
||||
}
|
||||
|
||||
auto icon_manager = g_browser_process->GetIconManager();
|
||||
gfx::Image* icon =
|
||||
icon_manager->LookupIconFromFilepath(normalized_path, icon_size);
|
||||
if (icon) {
|
||||
callback.Run(v8::Null(isolate()), *icon);
|
||||
} else {
|
||||
icon_manager->LoadIcon(
|
||||
normalized_path, icon_size,
|
||||
base::Bind(&OnIconDataAvailable, isolate(), callback),
|
||||
&cancelable_task_tracker_);
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<App> App::Create(v8::Isolate* isolate) {
|
||||
return mate::CreateHandle(isolate, new App(isolate));
|
||||
@@ -839,8 +937,7 @@ void App::BuildPrototype(
|
||||
base::Bind(&Browser::RemoveAsDefaultProtocolClient, browser))
|
||||
.SetMethod("setBadgeCount", base::Bind(&Browser::SetBadgeCount, browser))
|
||||
.SetMethod("getBadgeCount", base::Bind(&Browser::GetBadgeCount, browser))
|
||||
.SetMethod("getLoginItemSettings",
|
||||
base::Bind(&Browser::GetLoginItemSettings, browser))
|
||||
.SetMethod("getLoginItemSettings", &App::GetLoginItemSettings)
|
||||
.SetMethod("setLoginItemSettings",
|
||||
base::Bind(&Browser::SetLoginItemSettings, browser))
|
||||
#if defined(OS_MACOSX)
|
||||
@@ -875,7 +972,8 @@ void App::BuildPrototype(
|
||||
.SetMethod("isAccessibilitySupportEnabled",
|
||||
&App::IsAccessibilitySupportEnabled)
|
||||
.SetMethod("disableHardwareAcceleration",
|
||||
&App::DisableHardwareAcceleration);
|
||||
&App::DisableHardwareAcceleration)
|
||||
.SetMethod("getFileIcon", &App::GetFileIcon);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
@@ -10,8 +10,11 @@
|
||||
|
||||
#include "atom/browser/api/event_emitter.h"
|
||||
#include "atom/browser/atom_browser_client.h"
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/browser/browser_observer.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "base/task/cancelable_task_tracker.h"
|
||||
#include "chrome/browser/icon_manager.h"
|
||||
#include "chrome/browser/process_singleton.h"
|
||||
#include "content/public/browser/gpu_data_manager_observer.h"
|
||||
#include "native_mate/handle.h"
|
||||
@@ -42,18 +45,23 @@ class App : public AtomBrowserClient::Delegate,
|
||||
public BrowserObserver,
|
||||
public content::GpuDataManagerObserver {
|
||||
public:
|
||||
using FileIconCallback = base::Callback<void(v8::Local<v8::Value>,
|
||||
const gfx::Image&)>;
|
||||
|
||||
static mate::Handle<App> Create(v8::Isolate* isolate);
|
||||
|
||||
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<base::string16>& features,
|
||||
int render_process_id,
|
||||
int render_frame_id);
|
||||
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(
|
||||
@@ -96,8 +104,8 @@ class App : public AtomBrowserClient::Delegate,
|
||||
bool overridable,
|
||||
bool strict_enforcement,
|
||||
bool expired_previous_decision,
|
||||
const base::Callback<void(bool)>& callback,
|
||||
content::CertificateRequestResultType* request) override;
|
||||
const base::Callback<void(content::CertificateRequestResultType)>&
|
||||
callback) override;
|
||||
void SelectClientCertificate(
|
||||
content::WebContents* web_contents,
|
||||
net::SSLCertRequestInfo* cert_request_info,
|
||||
@@ -121,10 +129,13 @@ class App : public AtomBrowserClient::Delegate,
|
||||
bool Relaunch(mate::Arguments* args);
|
||||
void DisableHardwareAcceleration(mate::Arguments* args);
|
||||
bool IsAccessibilitySupportEnabled();
|
||||
Browser::LoginItemSettings GetLoginItemSettings(mate::Arguments* args);
|
||||
#if defined(USE_NSS_CERTS)
|
||||
void ImportCertificate(const base::DictionaryValue& options,
|
||||
const net::CompletionCallback& callback);
|
||||
#endif
|
||||
void GetFileIcon(const base::FilePath& path,
|
||||
mate::Arguments* args);
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Get the current Jump List settings.
|
||||
@@ -140,6 +151,9 @@ class App : public AtomBrowserClient::Delegate,
|
||||
std::unique_ptr<CertificateManagerModel> certificate_manager_model_;
|
||||
#endif
|
||||
|
||||
// Tracks tasks requesting file icons.
|
||||
base::CancelableTaskTracker cancelable_task_tracker_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(App);
|
||||
};
|
||||
|
||||
|
||||
@@ -69,10 +69,6 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||
dict.SetMethod("stopRecording", &StopRecording);
|
||||
dict.SetMethod("getTraceBufferUsage", base::Bind(
|
||||
&TracingController::GetTraceBufferUsage, controller));
|
||||
dict.SetMethod("setWatchEvent", base::Bind(
|
||||
&TracingController::SetWatchEvent, controller));
|
||||
dict.SetMethod("cancelWatchEvent", base::Bind(
|
||||
&TracingController::CancelWatchEvent, controller));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -56,19 +56,20 @@ struct Converter<net::CanonicalCookie> {
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Converter<AtomCookieDelegate::ChangeCause> {
|
||||
struct Converter<net::CookieStore::ChangeCause> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const AtomCookieDelegate::ChangeCause& val) {
|
||||
const net::CookieStore::ChangeCause& val) {
|
||||
switch (val) {
|
||||
case AtomCookieDelegate::ChangeCause::CHANGE_COOKIE_EXPLICIT:
|
||||
case net::CookieStore::ChangeCause::INSERTED:
|
||||
case net::CookieStore::ChangeCause::EXPLICIT:
|
||||
return mate::StringToV8(isolate, "explicit");
|
||||
case AtomCookieDelegate::ChangeCause::CHANGE_COOKIE_OVERWRITE:
|
||||
case net::CookieStore::ChangeCause::OVERWRITE:
|
||||
return mate::StringToV8(isolate, "overwrite");
|
||||
case AtomCookieDelegate::ChangeCause::CHANGE_COOKIE_EXPIRED:
|
||||
case net::CookieStore::ChangeCause::EXPIRED:
|
||||
return mate::StringToV8(isolate, "expired");
|
||||
case AtomCookieDelegate::ChangeCause::CHANGE_COOKIE_EVICTED:
|
||||
case net::CookieStore::ChangeCause::EVICTED:
|
||||
return mate::StringToV8(isolate, "evicted");
|
||||
case AtomCookieDelegate::ChangeCause::CHANGE_COOKIE_EXPIRED_OVERWRITE:
|
||||
case net::CookieStore::ChangeCause::EXPIRED_OVERWRITE:
|
||||
return mate::StringToV8(isolate, "expired-overwrite");
|
||||
default:
|
||||
return mate::StringToV8(isolate, "unknown");
|
||||
@@ -266,7 +267,7 @@ void Cookies::Set(const base::DictionaryValue& details,
|
||||
|
||||
void Cookies::OnCookieChanged(const net::CanonicalCookie& cookie,
|
||||
bool removed,
|
||||
AtomCookieDelegate::ChangeCause cause) {
|
||||
net::CookieStore::ChangeCause cause) {
|
||||
Emit("changed", cookie, cause, removed);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ class Cookies : public mate::TrackableObject<Cookies>,
|
||||
// AtomCookieDelegate::Observer:
|
||||
void OnCookieChanged(const net::CanonicalCookie& cookie,
|
||||
bool removed,
|
||||
AtomCookieDelegate::ChangeCause cause) override;
|
||||
net::CookieStore::ChangeCause cause) override;
|
||||
|
||||
private:
|
||||
net::URLRequestContextGetter* request_context_getter_;
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
#include "chrome/browser/media/desktop_media_list.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h"
|
||||
#include "third_party/webrtc/modules/desktop_capture/screen_capturer.h"
|
||||
#include "third_party/webrtc/modules/desktop_capture/window_capturer.h"
|
||||
#include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
@@ -61,10 +60,12 @@ void DesktopCapturer::StartHandling(bool capture_window,
|
||||
options.set_disable_effects(false);
|
||||
#endif
|
||||
|
||||
std::unique_ptr<webrtc::ScreenCapturer> screen_capturer(
|
||||
capture_screen ? webrtc::ScreenCapturer::Create(options) : nullptr);
|
||||
std::unique_ptr<webrtc::WindowCapturer> window_capturer(
|
||||
capture_window ? webrtc::WindowCapturer::Create(options) : nullptr);
|
||||
std::unique_ptr<webrtc::DesktopCapturer> screen_capturer(
|
||||
capture_screen ? webrtc::DesktopCapturer::CreateScreenCapturer(options)
|
||||
: nullptr);
|
||||
std::unique_ptr<webrtc::DesktopCapturer> window_capturer(
|
||||
capture_window ? webrtc::DesktopCapturer::CreateWindowCapturer(options)
|
||||
: nullptr);
|
||||
media_list_.reset(new NativeDesktopMediaList(
|
||||
std::move(screen_capturer), std::move(window_capturer)));
|
||||
|
||||
|
||||
@@ -35,6 +35,27 @@ struct Converter<file_dialog::Filter> {
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Converter<file_dialog::DialogSettings> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
file_dialog::DialogSettings* out) {
|
||||
mate::Dictionary dict;
|
||||
if (!ConvertFromV8(isolate, val, &dict))
|
||||
return false;
|
||||
dict.Get("window", &(out->parent_window));
|
||||
dict.Get("title", &(out->title));
|
||||
dict.Get("message", &(out->message));
|
||||
dict.Get("buttonLabel", &(out->button_label));
|
||||
dict.Get("nameFieldLabel", &(out->name_field_label));
|
||||
dict.Get("defaultPath", &(out->default_path));
|
||||
dict.Get("filters", &(out->filters));
|
||||
dict.Get("properties", &(out->properties));
|
||||
dict.Get("showsTagField", &(out->shows_tag_field));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
namespace {
|
||||
@@ -47,6 +68,8 @@ void ShowMessageBox(int type,
|
||||
const std::string& title,
|
||||
const std::string& message,
|
||||
const std::string& detail,
|
||||
const std::string& checkbox_label,
|
||||
bool checkbox_checked,
|
||||
const gfx::ImageSkia& icon,
|
||||
atom::NativeWindow* window,
|
||||
mate::Arguments* args) {
|
||||
@@ -56,8 +79,8 @@ void ShowMessageBox(int type,
|
||||
peek,
|
||||
&callback)) {
|
||||
atom::ShowMessageBox(window, (atom::MessageBoxType)type, buttons,
|
||||
default_id, cancel_id, options, title,
|
||||
message, detail, icon, callback);
|
||||
default_id, cancel_id, options, title, message, detail,
|
||||
checkbox_label, checkbox_checked, icon, callback);
|
||||
} else {
|
||||
int chosen = atom::ShowMessageBox(window, (atom::MessageBoxType)type,
|
||||
buttons, default_id, cancel_id,
|
||||
@@ -66,45 +89,32 @@ void ShowMessageBox(int type,
|
||||
}
|
||||
}
|
||||
|
||||
void ShowOpenDialog(const std::string& title,
|
||||
const std::string& button_label,
|
||||
const base::FilePath& default_path,
|
||||
const file_dialog::Filters& filters,
|
||||
int properties,
|
||||
atom::NativeWindow* window,
|
||||
void ShowOpenDialog(const file_dialog::DialogSettings& settings,
|
||||
mate::Arguments* args) {
|
||||
v8::Local<v8::Value> peek = args->PeekNext();
|
||||
file_dialog::OpenDialogCallback callback;
|
||||
if (mate::Converter<file_dialog::OpenDialogCallback>::FromV8(args->isolate(),
|
||||
peek,
|
||||
&callback)) {
|
||||
file_dialog::ShowOpenDialog(window, title, button_label, default_path,
|
||||
filters, properties, callback);
|
||||
file_dialog::ShowOpenDialog(settings, callback);
|
||||
} else {
|
||||
std::vector<base::FilePath> paths;
|
||||
if (file_dialog::ShowOpenDialog(window, title, button_label, default_path,
|
||||
filters, properties, &paths))
|
||||
if (file_dialog::ShowOpenDialog(settings, &paths))
|
||||
args->Return(paths);
|
||||
}
|
||||
}
|
||||
|
||||
void ShowSaveDialog(const std::string& title,
|
||||
const std::string& button_label,
|
||||
const base::FilePath& default_path,
|
||||
const file_dialog::Filters& filters,
|
||||
atom::NativeWindow* window,
|
||||
void ShowSaveDialog(const file_dialog::DialogSettings& settings,
|
||||
mate::Arguments* args) {
|
||||
v8::Local<v8::Value> peek = args->PeekNext();
|
||||
file_dialog::SaveDialogCallback callback;
|
||||
if (mate::Converter<file_dialog::SaveDialogCallback>::FromV8(args->isolate(),
|
||||
peek,
|
||||
&callback)) {
|
||||
file_dialog::ShowSaveDialog(window, title, button_label, default_path,
|
||||
filters, callback);
|
||||
file_dialog::ShowSaveDialog(settings, callback);
|
||||
} else {
|
||||
base::FilePath path;
|
||||
if (file_dialog::ShowSaveDialog(window, title, button_label, default_path,
|
||||
filters, &path))
|
||||
if (file_dialog::ShowSaveDialog(settings, &path))
|
||||
args->Return(path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "net/base/filename_util.h"
|
||||
|
||||
@@ -78,9 +78,9 @@ DownloadItem::~DownloadItem() {
|
||||
void DownloadItem::OnDownloadUpdated(content::DownloadItem* item) {
|
||||
if (download_item_->IsDone()) {
|
||||
Emit("done", item->GetState());
|
||||
|
||||
// Destroy the item once item is downloaded.
|
||||
base::MessageLoop::current()->PostTask(FROM_HERE, GetDestroyClosure());
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE, GetDestroyClosure());
|
||||
} else {
|
||||
Emit("updated", item->GetState());
|
||||
}
|
||||
@@ -110,7 +110,6 @@ bool DownloadItem::CanResume() const {
|
||||
|
||||
void DownloadItem::Cancel() {
|
||||
download_item_->Cancel(true);
|
||||
download_item_->Remove();
|
||||
}
|
||||
|
||||
int64_t DownloadItem::GetReceivedBytes() const {
|
||||
@@ -146,6 +145,10 @@ const GURL& DownloadItem::GetURL() const {
|
||||
return download_item_->GetURL();
|
||||
}
|
||||
|
||||
const std::vector<GURL>& DownloadItem::GetURLChain() const {
|
||||
return download_item_->GetUrlChain();
|
||||
}
|
||||
|
||||
content::DownloadItem::DownloadState DownloadItem::GetState() const {
|
||||
return download_item_->GetState();
|
||||
}
|
||||
@@ -162,6 +165,18 @@ base::FilePath DownloadItem::GetSavePath() const {
|
||||
return save_path_;
|
||||
}
|
||||
|
||||
std::string DownloadItem::GetLastModifiedTime() const {
|
||||
return download_item_->GetLastModifiedTime();
|
||||
}
|
||||
|
||||
std::string DownloadItem::GetETag() const {
|
||||
return download_item_->GetETag();
|
||||
}
|
||||
|
||||
double DownloadItem::GetStartTime() const {
|
||||
return download_item_->GetStartTime().ToDoubleT();
|
||||
}
|
||||
|
||||
// static
|
||||
void DownloadItem::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
@@ -180,10 +195,14 @@ void DownloadItem::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("getFilename", &DownloadItem::GetFilename)
|
||||
.SetMethod("getContentDisposition", &DownloadItem::GetContentDisposition)
|
||||
.SetMethod("getURL", &DownloadItem::GetURL)
|
||||
.SetMethod("getURLChain", &DownloadItem::GetURLChain)
|
||||
.SetMethod("getState", &DownloadItem::GetState)
|
||||
.SetMethod("isDone", &DownloadItem::IsDone)
|
||||
.SetMethod("setSavePath", &DownloadItem::SetSavePath)
|
||||
.SetMethod("getSavePath", &DownloadItem::GetSavePath);
|
||||
.SetMethod("getSavePath", &DownloadItem::GetSavePath)
|
||||
.SetMethod("getLastModifiedTime", &DownloadItem::GetLastModifiedTime)
|
||||
.SetMethod("getETag", &DownloadItem::GetETag)
|
||||
.SetMethod("getStartTime", &DownloadItem::GetStartTime);
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#define ATOM_BROWSER_API_ATOM_API_DOWNLOAD_ITEM_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/api/trackable_object.h"
|
||||
#include "base/files/file_path.h"
|
||||
@@ -38,10 +39,14 @@ class DownloadItem : public mate::TrackableObject<DownloadItem>,
|
||||
std::string GetFilename() const;
|
||||
std::string GetContentDisposition() const;
|
||||
const GURL& GetURL() const;
|
||||
const std::vector<GURL>& GetURLChain() const;
|
||||
content::DownloadItem::DownloadState GetState() const;
|
||||
bool IsDone() const;
|
||||
void SetSavePath(const base::FilePath& path);
|
||||
base::FilePath GetSavePath() const;
|
||||
std::string GetLastModifiedTime() const;
|
||||
std::string GetETag() const;
|
||||
double GetStartTime() const;
|
||||
|
||||
protected:
|
||||
DownloadItem(v8::Isolate* isolate, content::DownloadItem* download_item);
|
||||
|
||||
@@ -176,7 +176,8 @@ void Menu::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("isItemCheckedAt", &Menu::IsItemCheckedAt)
|
||||
.SetMethod("isEnabledAt", &Menu::IsEnabledAt)
|
||||
.SetMethod("isVisibleAt", &Menu::IsVisibleAt)
|
||||
.SetMethod("popupAt", &Menu::PopupAt);
|
||||
.SetMethod("popupAt", &Menu::PopupAt)
|
||||
.SetMethod("closePopupAt", &Menu::ClosePopupAt);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
@@ -53,9 +53,9 @@ 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 = -1, int y = -1,
|
||||
int positioning_item = 0) = 0;
|
||||
virtual void PopupAt(
|
||||
Window* window, int x, int y, int positioning_item, bool async) = 0;
|
||||
virtual void ClosePopupAt(int32_t window_id) = 0;
|
||||
|
||||
std::unique_ptr<AtomMenuModel> model_;
|
||||
Menu* parent_;
|
||||
|
||||
@@ -7,10 +7,13 @@
|
||||
|
||||
#include "atom/browser/api/atom_api_menu.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#import "atom/browser/ui/cocoa/atom_menu_controller.h"
|
||||
|
||||
using base::scoped_nsobject;
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
@@ -19,15 +22,25 @@ 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) override;
|
||||
|
||||
base::scoped_nsobject<AtomMenuController> menu_controller_;
|
||||
void PopupAt(
|
||||
Window* window, int x, int y, int positioning_item, bool async) override;
|
||||
void PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
||||
int32_t window_id, int x, int y, int positioning_item,
|
||||
bool async);
|
||||
void ClosePopupAt(int32_t window_id) override;
|
||||
|
||||
private:
|
||||
friend class Menu;
|
||||
|
||||
static void SendActionToFirstResponder(const std::string& action);
|
||||
|
||||
scoped_nsobject<AtomMenuController> menu_controller_;
|
||||
|
||||
// window ID -> open context menu
|
||||
std::map<int32_t, scoped_nsobject<AtomMenuController>> popup_controllers_;
|
||||
|
||||
base::WeakPtrFactory<MenuMac> weak_factory_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(MenuMac);
|
||||
};
|
||||
|
||||
|
||||
@@ -6,35 +6,58 @@
|
||||
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/unresponsive_suppressor.h"
|
||||
#include "base/mac/scoped_sending_event.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "brightray/browser/inspectable_web_contents.h"
|
||||
#include "brightray/browser/inspectable_web_contents_view.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
MenuMac::MenuMac(v8::Isolate* isolate, v8::Local<v8::Object> wrapper)
|
||||
: Menu(isolate, wrapper) {
|
||||
: Menu(isolate, wrapper),
|
||||
weak_factory_(this) {
|
||||
}
|
||||
|
||||
void MenuMac::PopupAt(Window* window, int x, int y, int positioning_item) {
|
||||
void MenuMac::PopupAt(
|
||||
Window* window, int x, int y, int positioning_item, bool async) {
|
||||
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();
|
||||
}
|
||||
|
||||
void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
||||
int32_t window_id, int x, int y, int positioning_item,
|
||||
bool async) {
|
||||
if (!native_window)
|
||||
return;
|
||||
brightray::InspectableWebContents* web_contents =
|
||||
native_window->inspectable_web_contents();
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
base::scoped_nsobject<AtomMenuController> menu_controller(
|
||||
[[AtomMenuController alloc] initWithModel:model_.get()
|
||||
auto close_callback = base::Bind(&MenuMac::ClosePopupAt,
|
||||
weak_factory_.GetWeakPtr(), window_id);
|
||||
popup_controllers_[window_id] = base::scoped_nsobject<AtomMenuController>(
|
||||
[[AtomMenuController alloc] initWithModel:model()
|
||||
useDefaultAccelerator:NO]);
|
||||
NSMenu* menu = [menu_controller menu];
|
||||
NSMenu* menu = [popup_controllers_[window_id] menu];
|
||||
NSView* view = web_contents->GetView()->GetNativeView();
|
||||
|
||||
// Which menu item to show.
|
||||
@@ -69,11 +92,33 @@ void MenuMac::PopupAt(Window* window, int x, int y, int positioning_item) {
|
||||
if (rightmostMenuPoint > screenRight)
|
||||
position.x = position.x - [menu size].width;
|
||||
|
||||
// Don't emit unresponsive event when showing menu.
|
||||
atom::UnresponsiveSuppressor suppressor;
|
||||
|
||||
// Show the menu.
|
||||
[menu popUpMenuPositioningItem:item atLocation:position inView:view];
|
||||
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;
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
||||
void MenuMac::ClosePopupAt(int32_t window_id) {
|
||||
popup_controllers_.erase(window_id);
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
@@ -8,17 +8,20 @@
|
||||
#include "atom/browser/unresponsive_suppressor.h"
|
||||
#include "content/public/browser/render_widget_host_view.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/views/controls/menu/menu_runner.h"
|
||||
|
||||
using views::MenuRunner;
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
MenuViews::MenuViews(v8::Isolate* isolate, v8::Local<v8::Object> wrapper)
|
||||
: Menu(isolate, wrapper) {
|
||||
: Menu(isolate, wrapper),
|
||||
weak_factory_(this) {
|
||||
}
|
||||
|
||||
void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item) {
|
||||
void MenuViews::PopupAt(
|
||||
Window* window, int x, int y, int positioning_item, bool async) {
|
||||
NativeWindow* native_window = static_cast<NativeWindow*>(window->window());
|
||||
if (!native_window)
|
||||
return;
|
||||
@@ -38,14 +41,20 @@ void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item) {
|
||||
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;
|
||||
|
||||
// Show the menu.
|
||||
views::MenuRunner menu_runner(
|
||||
model(),
|
||||
views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS);
|
||||
ignore_result(menu_runner.RunMenuAt(
|
||||
int32_t window_id = window->ID();
|
||||
auto close_callback = base::Bind(
|
||||
&MenuViews::ClosePopupAt, weak_factory_.GetWeakPtr(), window_id);
|
||||
menu_runners_[window_id] = std::unique_ptr<MenuRunner>(new MenuRunner(
|
||||
model(), flags, close_callback));
|
||||
ignore_result(menu_runners_[window_id]->RunMenuAt(
|
||||
static_cast<NativeWindowViews*>(window->window())->widget(),
|
||||
NULL,
|
||||
gfx::Rect(location, gfx::Size()),
|
||||
@@ -53,6 +62,10 @@ void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item) {
|
||||
ui::MENU_SOURCE_MOUSE));
|
||||
}
|
||||
|
||||
void MenuViews::ClosePopupAt(int32_t window_id) {
|
||||
menu_runners_.erase(window_id);
|
||||
}
|
||||
|
||||
// static
|
||||
mate::WrappableBase* Menu::New(mate::Arguments* args) {
|
||||
return new MenuViews(args->isolate(), args->GetThis());
|
||||
|
||||
@@ -5,8 +5,12 @@
|
||||
#ifndef ATOM_BROWSER_API_ATOM_API_MENU_VIEWS_H_
|
||||
#define ATOM_BROWSER_API_ATOM_API_MENU_VIEWS_H_
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "atom/browser/api/atom_api_menu.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/views/controls/menu/menu_runner.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -17,9 +21,16 @@ 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) override;
|
||||
void PopupAt(
|
||||
Window* window, int x, int y, int positioning_item, bool async) override;
|
||||
void ClosePopupAt(int32_t window_id) override;
|
||||
|
||||
private:
|
||||
// window ID -> open context menu
|
||||
std::map<int32_t, std::unique_ptr<views::MenuRunner>> menu_runners_;
|
||||
|
||||
base::WeakPtrFactory<MenuViews> weak_factory_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(MenuViews);
|
||||
};
|
||||
|
||||
|
||||
61
atom/browser/api/atom_api_net.cc
Normal file
61
atom/browser/api/atom_api_net.cc
Normal file
@@ -0,0 +1,61 @@
|
||||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/api/atom_api_net.h"
|
||||
#include "atom/browser/api/atom_api_url_request.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
Net::Net(v8::Isolate* isolate) {
|
||||
Init(isolate);
|
||||
}
|
||||
|
||||
Net::~Net() {}
|
||||
|
||||
// static
|
||||
v8::Local<v8::Value> Net::Create(v8::Isolate* isolate) {
|
||||
return mate::CreateHandle(isolate, new Net(isolate)).ToV8();
|
||||
}
|
||||
|
||||
// static
|
||||
void Net::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "Net"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetProperty("URLRequest", &Net::URLRequest);
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> Net::URLRequest(v8::Isolate* isolate) {
|
||||
return URLRequest::GetConstructor(isolate)->GetFunction();
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
namespace {
|
||||
|
||||
using atom::api::Net;
|
||||
using atom::api::URLRequest;
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
|
||||
URLRequest::SetConstructor(isolate, base::Bind(URLRequest::New));
|
||||
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.Set("net", Net::Create(isolate));
|
||||
dict.Set("Net", Net::GetConstructor(isolate)->GetFunction());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_net, Initialize)
|
||||
35
atom/browser/api/atom_api_net.h
Normal file
35
atom/browser/api/atom_api_net.h
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_API_ATOM_API_NET_H_
|
||||
#define ATOM_BROWSER_API_ATOM_API_NET_H_
|
||||
|
||||
#include "atom/browser/api/event_emitter.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
class Net : public mate::EventEmitter<Net> {
|
||||
public:
|
||||
static v8::Local<v8::Value> Create(v8::Isolate* isolate);
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
v8::Local<v8::Value> URLRequest(v8::Isolate* isolate);
|
||||
|
||||
protected:
|
||||
explicit Net(v8::Isolate* isolate);
|
||||
~Net() override;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(Net);
|
||||
};
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_API_ATOM_API_NET_H_
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
namespace mate {
|
||||
|
||||
template<>
|
||||
@@ -76,10 +78,8 @@ void PowerSaveBlocker::UpdatePowerSaveBlocker() {
|
||||
new_blocker_type,
|
||||
device::PowerSaveBlocker::kReasonOther,
|
||||
ATOM_PRODUCT_NAME,
|
||||
content::BrowserThread::GetMessageLoopProxyForThread(
|
||||
content::BrowserThread::UI),
|
||||
content::BrowserThread::GetMessageLoopProxyForThread(
|
||||
content::BrowserThread::FILE)));
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)));
|
||||
power_save_blocker_.swap(new_blocker);
|
||||
current_blocker_type_ = new_blocker_type;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,8 @@ std::vector<std::string> GetStandardSchemes() {
|
||||
return g_standard_schemes;
|
||||
}
|
||||
|
||||
void RegisterStandardSchemes(const std::vector<std::string>& schemes) {
|
||||
void RegisterStandardSchemes(const std::vector<std::string>& schemes,
|
||||
mate::Arguments* args) {
|
||||
g_standard_schemes = schemes;
|
||||
|
||||
auto* policy = content::ChildProcessSecurityPolicy::GetInstance();
|
||||
@@ -55,8 +56,17 @@ void RegisterStandardSchemes(const std::vector<std::string>& schemes) {
|
||||
policy->RegisterWebSafeScheme(scheme);
|
||||
}
|
||||
|
||||
// add switches to register as standard
|
||||
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
||||
atom::switches::kStandardSchemes, base::JoinString(schemes, ","));
|
||||
|
||||
mate::Dictionary opts;
|
||||
bool secure = false;
|
||||
if (args->GetNext(&opts) && opts.Get("secure", &secure) && secure) {
|
||||
// add switches to register as secure
|
||||
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
||||
atom::switches::kSecureSchemes, base::JoinString(schemes, ","));
|
||||
}
|
||||
}
|
||||
|
||||
Protocol::Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
||||
@@ -220,7 +230,7 @@ void RegisterStandardSchemes(
|
||||
return;
|
||||
}
|
||||
|
||||
atom::api::RegisterStandardSchemes(schemes);
|
||||
atom::api::RegisterStandardSchemes(schemes, args);
|
||||
}
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||
|
||||
@@ -29,7 +29,8 @@ namespace atom {
|
||||
namespace api {
|
||||
|
||||
std::vector<std::string> GetStandardSchemes();
|
||||
void RegisterStandardSchemes(const std::vector<std::string>& schemes);
|
||||
void RegisterStandardSchemes(const std::vector<std::string>& schemes,
|
||||
mate::Arguments* args);
|
||||
|
||||
class Protocol : public mate::TrackableObject<Protocol> {
|
||||
public:
|
||||
|
||||
@@ -29,11 +29,13 @@
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#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/common/pref_names.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/download_manager_delegate.h"
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
@@ -61,6 +63,15 @@ struct ClearStorageDataOptions {
|
||||
uint32_t quota_types = StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL;
|
||||
};
|
||||
|
||||
struct ClearAuthCacheOptions {
|
||||
std::string type;
|
||||
GURL origin;
|
||||
std::string realm;
|
||||
base::string16 username;
|
||||
base::string16 password;
|
||||
net::HttpAuth::Scheme auth_scheme;
|
||||
};
|
||||
|
||||
uint32_t GetStorageMask(const std::vector<std::string>& storage_types) {
|
||||
uint32_t storage_mask = 0;
|
||||
for (const auto& it : storage_types) {
|
||||
@@ -99,6 +110,18 @@ uint32_t GetQuotaMask(const std::vector<std::string>& quota_types) {
|
||||
return quota_mask;
|
||||
}
|
||||
|
||||
net::HttpAuth::Scheme GetAuthSchemeFromString(const std::string& scheme) {
|
||||
if (scheme == "basic")
|
||||
return net::HttpAuth::AUTH_SCHEME_BASIC;
|
||||
if (scheme == "digest")
|
||||
return net::HttpAuth::AUTH_SCHEME_DIGEST;
|
||||
if (scheme == "ntlm")
|
||||
return net::HttpAuth::AUTH_SCHEME_NTLM;
|
||||
if (scheme == "negotiate")
|
||||
return net::HttpAuth::AUTH_SCHEME_NEGOTIATE;
|
||||
return net::HttpAuth::AUTH_SCHEME_MAX;
|
||||
}
|
||||
|
||||
void SetUserAgentInIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||
const std::string& accept_lang,
|
||||
const std::string& user_agent) {
|
||||
@@ -130,7 +153,27 @@ struct Converter<ClearStorageDataOptions> {
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
template <>
|
||||
struct Converter<ClearAuthCacheOptions> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
ClearAuthCacheOptions* out) {
|
||||
mate::Dictionary options;
|
||||
if (!ConvertFromV8(isolate, val, &options))
|
||||
return false;
|
||||
options.Get("type", &out->type);
|
||||
options.Get("origin", &out->origin);
|
||||
options.Get("realm", &out->realm);
|
||||
options.Get("username", &out->username);
|
||||
options.Get("password", &out->password);
|
||||
std::string scheme;
|
||||
if (options.Get("scheme", &scheme))
|
||||
out->auth_scheme = GetAuthSchemeFromString(scheme);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<net::ProxyConfig> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
@@ -161,6 +204,18 @@ struct Converter<net::ProxyConfig> {
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Converter<atom::VerifyRequestParams> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
atom::VerifyRequestParams val) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("hostname", val.hostname);
|
||||
dict.Set("certificate", val.certificate);
|
||||
dict.Set("verificationResult", val.default_result);
|
||||
return dict.GetHandle();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
namespace atom {
|
||||
@@ -211,8 +266,8 @@ class ResolveProxyHelper {
|
||||
|
||||
// Start the request.
|
||||
int result = proxy_service->ResolveProxy(
|
||||
url, "GET", net::LOAD_NORMAL, &proxy_info_, completion_callback,
|
||||
&pac_req_, nullptr, net::BoundNetLog());
|
||||
url, "GET", &proxy_info_, completion_callback, &pac_req_, nullptr,
|
||||
net::NetLogWithSource());
|
||||
|
||||
// Completed synchronously.
|
||||
if (result != net::ERR_IO_PENDING)
|
||||
@@ -228,6 +283,9 @@ class ResolveProxyHelper {
|
||||
};
|
||||
|
||||
// Runs the callback in UI thread.
|
||||
void RunCallbackInUI(const base::Callback<void()>& callback) {
|
||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback);
|
||||
}
|
||||
template<typename ...T>
|
||||
void RunCallbackInUI(const base::Callback<void(T...)>& callback, T... result) {
|
||||
BrowserThread::PostTask(
|
||||
@@ -313,6 +371,33 @@ void ClearHostResolverCacheInIO(
|
||||
}
|
||||
}
|
||||
|
||||
void ClearAuthCacheInIO(
|
||||
const scoped_refptr<net::URLRequestContextGetter>& context_getter,
|
||||
const ClearAuthCacheOptions& options,
|
||||
const base::Closure& callback) {
|
||||
auto request_context = context_getter->GetURLRequestContext();
|
||||
auto network_session =
|
||||
request_context->http_transaction_factory()->GetSession();
|
||||
if (network_session) {
|
||||
if (options.type == "password") {
|
||||
auto auth_cache = network_session->http_auth_cache();
|
||||
if (!options.origin.is_empty()) {
|
||||
auth_cache->Remove(
|
||||
options.origin, options.realm, options.auth_scheme,
|
||||
net::AuthCredentials(options.username, options.password));
|
||||
} else {
|
||||
auth_cache->ClearEntriesAddedWithin(base::TimeDelta::Max());
|
||||
}
|
||||
} else if (options.type == "clientCertificate") {
|
||||
auto client_auth_cache = network_session->ssl_client_auth_cache();
|
||||
client_auth_cache->Remove(net::HostPortPair::FromURL(options.origin));
|
||||
}
|
||||
network_session->CloseAllConnections();
|
||||
}
|
||||
if (!callback.is_null())
|
||||
RunCallbackInUI(callback);
|
||||
}
|
||||
|
||||
void AllowNTLMCredentialsForDomainsInIO(
|
||||
const scoped_refptr<net::URLRequestContextGetter>& context_getter,
|
||||
const std::string& domains) {
|
||||
@@ -331,6 +416,25 @@ void OnClearStorageDataDone(const base::Closure& callback) {
|
||||
callback.Run();
|
||||
}
|
||||
|
||||
void DownloadIdCallback(content::DownloadManager* download_manager,
|
||||
const base::FilePath& path,
|
||||
const std::vector<GURL>& url_chain,
|
||||
const std::string& mime_type,
|
||||
int64_t offset,
|
||||
int64_t length,
|
||||
const std::string& last_modified,
|
||||
const std::string& etag,
|
||||
const base::Time& start_time,
|
||||
uint32_t id) {
|
||||
download_manager->CreateDownloadItem(
|
||||
base::GenerateGUID(), id, path, path, url_chain, GURL(), GURL(), GURL(),
|
||||
GURL(), mime_type, mime_type, start_time, base::Time(), etag,
|
||||
last_modified, offset, length, std::string(),
|
||||
content::DownloadItem::INTERRUPTED,
|
||||
content::DownloadDangerType::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
|
||||
content::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT, false);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Session::Session(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
||||
@@ -357,10 +461,10 @@ void Session::OnDownloadCreated(content::DownloadManager* manager,
|
||||
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
bool prevent_default = Emit(
|
||||
"will-download",
|
||||
DownloadItem::Create(isolate(), item),
|
||||
item->GetWebContents());
|
||||
auto handle = DownloadItem::Create(isolate(), item);
|
||||
if (item->GetState() == content::DownloadItem::INTERRUPTED)
|
||||
handle->SetSavePath(item->GetTargetFilePath());
|
||||
bool prevent_default = Emit("will-download", handle, item->GetWebContents());
|
||||
if (prevent_default) {
|
||||
item->Cancel(true);
|
||||
item->Remove();
|
||||
@@ -389,6 +493,11 @@ void Session::ClearStorageData(mate::Arguments* args) {
|
||||
|
||||
auto storage_partition =
|
||||
content::BrowserContext::GetStoragePartition(browser_context(), nullptr);
|
||||
if (options.storage_types & StoragePartition::REMOVE_DATA_MASK_COOKIES) {
|
||||
// Reset media device id salt when cookies are cleared.
|
||||
// https://w3c.github.io/mediacapture-main/#dom-mediadeviceinfo-deviceid
|
||||
brightray::MediaDeviceIDSalt::Reset(browser_context()->prefs());
|
||||
}
|
||||
storage_partition->ClearData(
|
||||
options.storage_types, options.quota_types, options.origin,
|
||||
content::StoragePartition::OriginMatcherFunction(),
|
||||
@@ -481,6 +590,22 @@ void Session::ClearHostResolverCache(mate::Arguments* args) {
|
||||
callback));
|
||||
}
|
||||
|
||||
void Session::ClearAuthCache(mate::Arguments* args) {
|
||||
ClearAuthCacheOptions options;
|
||||
if (!args->GetNext(&options)) {
|
||||
args->ThrowError("Must specify options object");
|
||||
return;
|
||||
}
|
||||
base::Closure callback;
|
||||
args->GetNext(&callback);
|
||||
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(&ClearAuthCacheInIO,
|
||||
make_scoped_refptr(browser_context_->GetRequestContext()),
|
||||
options, callback));
|
||||
}
|
||||
|
||||
void Session::AllowNTLMCredentialsForDomains(const std::string& domains) {
|
||||
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(&AllowNTLMCredentialsForDomainsInIO,
|
||||
@@ -520,6 +645,37 @@ void Session::GetBlobData(
|
||||
callback));
|
||||
}
|
||||
|
||||
void Session::CreateInterruptedDownload(const mate::Dictionary& options) {
|
||||
int64_t offset = 0, length = 0;
|
||||
double start_time = 0.0;
|
||||
std::string mime_type, last_modified, etag;
|
||||
base::FilePath path;
|
||||
std::vector<GURL> url_chain;
|
||||
options.Get("path", &path);
|
||||
options.Get("urlChain", &url_chain);
|
||||
options.Get("mimeType", &mime_type);
|
||||
options.Get("offset", &offset);
|
||||
options.Get("length", &length);
|
||||
options.Get("lastModified", &last_modified);
|
||||
options.Get("eTag", &etag);
|
||||
options.Get("startTime", &start_time);
|
||||
if (path.empty() || url_chain.empty() || length == 0) {
|
||||
isolate()->ThrowException(v8::Exception::Error(mate::StringToV8(
|
||||
isolate(), "Must pass non-empty path, urlChain and length.")));
|
||||
return;
|
||||
}
|
||||
if (offset >= length) {
|
||||
isolate()->ThrowException(v8::Exception::Error(mate::StringToV8(
|
||||
isolate(), "Must pass an offset value less than length.")));
|
||||
return;
|
||||
}
|
||||
auto download_manager =
|
||||
content::BrowserContext::GetDownloadManager(browser_context());
|
||||
download_manager->GetDelegate()->GetNextId(base::Bind(
|
||||
&DownloadIdCallback, download_manager, path, url_chain, mime_type, offset,
|
||||
length, last_modified, etag, base::Time::FromDoubleT(start_time)));
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> Session::Cookies(v8::Isolate* isolate) {
|
||||
if (cookies_.IsEmpty()) {
|
||||
auto handle = Cookies::Create(isolate, browser_context());
|
||||
@@ -594,15 +750,18 @@ void Session::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("setDownloadPath", &Session::SetDownloadPath)
|
||||
.SetMethod("enableNetworkEmulation", &Session::EnableNetworkEmulation)
|
||||
.SetMethod("disableNetworkEmulation", &Session::DisableNetworkEmulation)
|
||||
.SetMethod("setCertificateVerifyProc", &Session::SetCertVerifyProc)
|
||||
.SetMethod("_setCertificateVerifyProc", &Session::SetCertVerifyProc)
|
||||
.SetMethod("setPermissionRequestHandler",
|
||||
&Session::SetPermissionRequestHandler)
|
||||
.SetMethod("clearHostResolverCache", &Session::ClearHostResolverCache)
|
||||
.SetMethod("clearAuthCache", &Session::ClearAuthCache)
|
||||
.SetMethod("allowNTLMCredentialsForDomains",
|
||||
&Session::AllowNTLMCredentialsForDomains)
|
||||
.SetMethod("setUserAgent", &Session::SetUserAgent)
|
||||
.SetMethod("getUserAgent", &Session::GetUserAgent)
|
||||
.SetMethod("getBlobData", &Session::GetBlobData)
|
||||
.SetMethod("createInterruptedDownload",
|
||||
&Session::CreateInterruptedDownload)
|
||||
.SetProperty("cookies", &Session::Cookies)
|
||||
.SetProperty("protocol", &Session::Protocol)
|
||||
.SetProperty("webRequest", &Session::WebRequest);
|
||||
|
||||
@@ -74,11 +74,13 @@ class Session: public mate::TrackableObject<Session>,
|
||||
void SetPermissionRequestHandler(v8::Local<v8::Value> val,
|
||||
mate::Arguments* args);
|
||||
void ClearHostResolverCache(mate::Arguments* args);
|
||||
void ClearAuthCache(mate::Arguments* args);
|
||||
void AllowNTLMCredentialsForDomains(const std::string& domains);
|
||||
void SetUserAgent(const std::string& user_agent, mate::Arguments* args);
|
||||
std::string GetUserAgent();
|
||||
void GetBlobData(const std::string& uuid,
|
||||
const AtomBlobReader::CompletionCallback& callback);
|
||||
void CreateInterruptedDownload(const mate::Dictionary& options);
|
||||
v8::Local<v8::Value> Cookies(v8::Isolate* isolate);
|
||||
v8::Local<v8::Value> Protocol(v8::Isolate* isolate);
|
||||
v8::Local<v8::Value> WebRequest(v8::Isolate* isolate);
|
||||
|
||||
@@ -14,11 +14,7 @@ namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
SystemPreferences::SystemPreferences(v8::Isolate* isolate)
|
||||
#if defined(OS_WIN)
|
||||
: color_change_listener_(this)
|
||||
#endif
|
||||
{
|
||||
SystemPreferences::SystemPreferences(v8::Isolate* isolate) {
|
||||
Init(isolate);
|
||||
#if defined(OS_WIN)
|
||||
InitializeWindow();
|
||||
@@ -26,6 +22,9 @@ SystemPreferences::SystemPreferences(v8::Isolate* isolate)
|
||||
}
|
||||
|
||||
SystemPreferences::~SystemPreferences() {
|
||||
#if defined(OS_WIN)
|
||||
Browser::Get()->RemoveObserver(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
@@ -67,6 +66,7 @@ void SystemPreferences::BuildPrototype(
|
||||
.SetMethod("unsubscribeLocalNotification",
|
||||
&SystemPreferences::UnsubscribeLocalNotification)
|
||||
.SetMethod("getUserDefault", &SystemPreferences::GetUserDefault)
|
||||
.SetMethod("setUserDefault", &SystemPreferences::SetUserDefault)
|
||||
.SetMethod("isSwipeTrackingFromScrollEventsEnabled",
|
||||
&SystemPreferences::IsSwipeTrackingFromScrollEventsEnabled)
|
||||
#endif
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "native_mate/handle.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/browser/browser_observer.h"
|
||||
#include "ui/gfx/sys_color_change_listener.h"
|
||||
#endif
|
||||
|
||||
@@ -26,6 +28,7 @@ namespace api {
|
||||
|
||||
class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||
#if defined(OS_WIN)
|
||||
, public BrowserObserver
|
||||
, public gfx::SysColorChangeListener
|
||||
#endif
|
||||
{
|
||||
@@ -51,6 +54,9 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||
// gfx::SysColorChangeListener:
|
||||
void OnSysColorChange() override;
|
||||
|
||||
// BrowserObserver:
|
||||
void OnFinishLaunching(const base::DictionaryValue& launch_info) override;
|
||||
|
||||
#elif defined(OS_MACOSX)
|
||||
using NotificationCallback = base::Callback<
|
||||
void(const std::string&, const base::DictionaryValue&)>;
|
||||
@@ -67,6 +73,9 @@ 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 SetUserDefault(const std::string& name,
|
||||
const std::string& type,
|
||||
mate::Arguments* args);
|
||||
bool IsSwipeTrackingFromScrollEventsEnabled();
|
||||
#endif
|
||||
bool IsDarkMode();
|
||||
@@ -108,7 +117,7 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||
|
||||
bool invertered_color_scheme_;
|
||||
|
||||
gfx::ScopedSysColorChangeListener color_change_listener_;
|
||||
std::unique_ptr<gfx::ScopedSysColorChangeListener> color_change_listener_;
|
||||
#endif
|
||||
DISALLOW_COPY_AND_ASSIGN(SystemPreferences);
|
||||
};
|
||||
|
||||
@@ -28,17 +28,17 @@ std::map<int, id> g_id_map;
|
||||
|
||||
} // namespace
|
||||
|
||||
void SystemPreferences::PostNotification(const std::string& name,
|
||||
void SystemPreferences::PostNotification(const std::string& name,
|
||||
const base::DictionaryValue& user_info) {
|
||||
DoPostNotification(name, user_info, false);
|
||||
}
|
||||
|
||||
void SystemPreferences::PostLocalNotification(const std::string& name,
|
||||
void SystemPreferences::PostLocalNotification(const std::string& name,
|
||||
const base::DictionaryValue& user_info) {
|
||||
DoPostNotification(name, user_info, true);
|
||||
}
|
||||
|
||||
void SystemPreferences::DoPostNotification(const std::string& name,
|
||||
void SystemPreferences::DoPostNotification(const std::string& name,
|
||||
const base::DictionaryValue& user_info, bool is_local) {
|
||||
NSNotificationCenter* center = is_local ?
|
||||
[NSNotificationCenter defaultCenter] :
|
||||
@@ -128,16 +128,107 @@ v8::Local<v8::Value> SystemPreferences::GetUserDefault(
|
||||
return mate::ConvertToV8(isolate(),
|
||||
net::GURLWithNSURL([defaults URLForKey:key]));
|
||||
} else if (type == "array") {
|
||||
return mate::ConvertToV8(isolate(),
|
||||
*NSArrayToListValue([defaults arrayForKey:key]));
|
||||
std::unique_ptr<base::ListValue> list =
|
||||
NSArrayToListValue([defaults arrayForKey:key]);
|
||||
if (list == nullptr)
|
||||
list.reset(new base::ListValue());
|
||||
return mate::ConvertToV8(isolate(), *list);
|
||||
} else if (type == "dictionary") {
|
||||
return mate::ConvertToV8(isolate(),
|
||||
*NSDictionaryToDictionaryValue([defaults dictionaryForKey:key]));
|
||||
std::unique_ptr<base::DictionaryValue> dictionary =
|
||||
NSDictionaryToDictionaryValue([defaults dictionaryForKey:key]);
|
||||
if (dictionary == nullptr)
|
||||
dictionary.reset(new base::DictionaryValue());
|
||||
return mate::ConvertToV8(isolate(), *dictionary);
|
||||
} else {
|
||||
return v8::Undefined(isolate());
|
||||
}
|
||||
}
|
||||
|
||||
void SystemPreferences::SetUserDefault(const std::string& name,
|
||||
const std::string& type,
|
||||
mate::Arguments* args) {
|
||||
const auto throwConversionError = [&] {
|
||||
args->ThrowError("Unable to convert value to: " + type);
|
||||
};
|
||||
|
||||
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
|
||||
NSString* key = base::SysUTF8ToNSString(name);
|
||||
if (type == "string") {
|
||||
std::string value;
|
||||
if (!args->GetNext(&value)) {
|
||||
throwConversionError();
|
||||
return;
|
||||
}
|
||||
|
||||
[defaults setObject:base::SysUTF8ToNSString(value) forKey:key];
|
||||
} else if (type == "boolean") {
|
||||
bool value;
|
||||
if (!args->GetNext(&value)) {
|
||||
throwConversionError();
|
||||
return;
|
||||
}
|
||||
|
||||
[defaults setBool:value forKey:key];
|
||||
} else if (type == "float") {
|
||||
float value;
|
||||
if (!args->GetNext(&value)) {
|
||||
throwConversionError();
|
||||
return;
|
||||
}
|
||||
|
||||
[defaults setFloat:value forKey:key];
|
||||
} else if (type == "integer") {
|
||||
int value;
|
||||
if (!args->GetNext(&value)) {
|
||||
throwConversionError();
|
||||
return;
|
||||
}
|
||||
|
||||
[defaults setInteger:value forKey:key];
|
||||
} else if (type == "double") {
|
||||
double value;
|
||||
if (!args->GetNext(&value)) {
|
||||
throwConversionError();
|
||||
return;
|
||||
}
|
||||
|
||||
[defaults setDouble:value forKey:key];
|
||||
} else if (type == "url") {
|
||||
GURL value;
|
||||
if (!args->GetNext(&value)) {
|
||||
throwConversionError();
|
||||
return;
|
||||
}
|
||||
|
||||
if (NSURL* url = net::NSURLWithGURL(value)) {
|
||||
[defaults setURL:url forKey:key];
|
||||
}
|
||||
} else if (type == "array") {
|
||||
base::ListValue value;
|
||||
if (!args->GetNext(&value)) {
|
||||
throwConversionError();
|
||||
return;
|
||||
}
|
||||
|
||||
if (NSArray* array = ListValueToNSArray(value)) {
|
||||
[defaults setObject:array forKey:key];
|
||||
}
|
||||
} else if (type == "dictionary") {
|
||||
base::DictionaryValue value;
|
||||
if (!args->GetNext(&value)) {
|
||||
throwConversionError();
|
||||
return;
|
||||
}
|
||||
|
||||
if (NSDictionary* dict = DictionaryValueToNSDictionary(value)) {
|
||||
[defaults setObject:dict forKey:key];
|
||||
}
|
||||
} else {
|
||||
args->ThrowError("Invalid type: " + type);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool SystemPreferences::IsDarkMode() {
|
||||
NSString* mode = [[NSUserDefaults standardUserDefaults]
|
||||
stringForKey:@"AppleInterfaceStyle"];
|
||||
|
||||
@@ -117,6 +117,14 @@ std::string SystemPreferences::GetColor(const std::string& color,
|
||||
void SystemPreferences::InitializeWindow() {
|
||||
invertered_color_scheme_ = IsInvertedColorScheme();
|
||||
|
||||
// Wait until app is ready before creating sys color listener
|
||||
// Creating this listener before the app is ready causes global shortcuts
|
||||
// to not fire
|
||||
if (Browser::Get()->is_ready())
|
||||
color_change_listener_.reset(new gfx::ScopedSysColorChangeListener(this));
|
||||
else
|
||||
Browser::Get()->AddObserver(this);
|
||||
|
||||
WNDCLASSEX window_class;
|
||||
base::win::InitializeWindowClass(
|
||||
kSystemPreferencesWindowClass,
|
||||
@@ -172,6 +180,11 @@ void SystemPreferences::OnSysColorChange() {
|
||||
Emit("color-changed");
|
||||
}
|
||||
|
||||
void SystemPreferences::OnFinishLaunching(
|
||||
const base::DictionaryValue& launch_info) {
|
||||
color_change_listener_.reset(new gfx::ScopedSysColorChangeListener(this));
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#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/threading/thread_task_runner_handle.h"
|
||||
#include "native_mate/constructor.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
@@ -71,7 +72,8 @@ Tray::Tray(v8::Isolate* isolate, v8::Local<v8::Object> wrapper,
|
||||
|
||||
Tray::~Tray() {
|
||||
// Destroy the native tray in next tick.
|
||||
base::MessageLoop::current()->DeleteSoon(FROM_HERE, tray_icon_.release());
|
||||
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(
|
||||
FROM_HERE, tray_icon_.release());
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
448
atom/browser/api/atom_api_url_request.cc
Normal file
448
atom/browser/api/atom_api_url_request.cc
Normal file
@@ -0,0 +1,448 @@
|
||||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/api/atom_api_url_request.h"
|
||||
#include <string>
|
||||
#include "atom/browser/api/atom_api_session.h"
|
||||
#include "atom/browser/net/atom_url_request.h"
|
||||
#include "atom/common/api/event_emitter_caller.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/net_converter.h"
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
||||
namespace mate {
|
||||
|
||||
template <>
|
||||
struct Converter<scoped_refptr<const net::IOBufferWithSize>> {
|
||||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate,
|
||||
scoped_refptr<const net::IOBufferWithSize> buffer) {
|
||||
return node::Buffer::Copy(isolate, buffer->data(), buffer->size())
|
||||
.ToLocalChecked();
|
||||
}
|
||||
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
scoped_refptr<const net::IOBufferWithSize>* out) {
|
||||
auto size = node::Buffer::Length(val);
|
||||
|
||||
if (size == 0) {
|
||||
// Support conversion from empty buffer. A use case is
|
||||
// a GET request without body.
|
||||
// Since zero-sized IOBuffer(s) are not supported, we set the
|
||||
// out pointer to null.
|
||||
*out = nullptr;
|
||||
return true;
|
||||
}
|
||||
auto data = node::Buffer::Data(val);
|
||||
if (!data) {
|
||||
// This is an error as size is positive but data is null.
|
||||
return false;
|
||||
}
|
||||
|
||||
*out = new net::IOBufferWithSize(size);
|
||||
// We do a deep copy. We could have used Buffer's internal memory
|
||||
// but that is much more complicated to be properly handled.
|
||||
memcpy((*out)->data(), data, size);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
namespace atom {
|
||||
namespace api {
|
||||
|
||||
template <typename Flags>
|
||||
URLRequest::StateBase<Flags>::StateBase(Flags initialState)
|
||||
: state_(initialState) {}
|
||||
|
||||
template <typename Flags>
|
||||
void URLRequest::StateBase<Flags>::SetFlag(Flags flag) {
|
||||
state_ =
|
||||
static_cast<Flags>(static_cast<int>(state_) | static_cast<int>(flag));
|
||||
}
|
||||
|
||||
template <typename Flags>
|
||||
bool URLRequest::StateBase<Flags>::operator==(Flags flag) const {
|
||||
return state_ == flag;
|
||||
}
|
||||
|
||||
template <typename Flags>
|
||||
bool URLRequest::StateBase<Flags>::IsFlagSet(Flags flag) const {
|
||||
return static_cast<int>(state_) & static_cast<int>(flag);
|
||||
}
|
||||
|
||||
URLRequest::RequestState::RequestState()
|
||||
: StateBase(RequestStateFlags::kNotStarted) {}
|
||||
|
||||
bool URLRequest::RequestState::NotStarted() const {
|
||||
return *this == RequestStateFlags::kNotStarted;
|
||||
}
|
||||
|
||||
bool URLRequest::RequestState::Started() const {
|
||||
return IsFlagSet(RequestStateFlags::kStarted);
|
||||
}
|
||||
|
||||
bool URLRequest::RequestState::Finished() const {
|
||||
return IsFlagSet(RequestStateFlags::kFinished);
|
||||
}
|
||||
|
||||
bool URLRequest::RequestState::Canceled() const {
|
||||
return IsFlagSet(RequestStateFlags::kCanceled);
|
||||
}
|
||||
|
||||
bool URLRequest::RequestState::Failed() const {
|
||||
return IsFlagSet(RequestStateFlags::kFailed);
|
||||
}
|
||||
|
||||
bool URLRequest::RequestState::Closed() const {
|
||||
return IsFlagSet(RequestStateFlags::kClosed);
|
||||
}
|
||||
|
||||
URLRequest::ResponseState::ResponseState()
|
||||
: StateBase(ResponseStateFlags::kNotStarted) {}
|
||||
|
||||
bool URLRequest::ResponseState::NotStarted() const {
|
||||
return *this == ResponseStateFlags::kNotStarted;
|
||||
}
|
||||
|
||||
bool URLRequest::ResponseState::Started() const {
|
||||
return IsFlagSet(ResponseStateFlags::kStarted);
|
||||
}
|
||||
|
||||
bool URLRequest::ResponseState::Ended() const {
|
||||
return IsFlagSet(ResponseStateFlags::kEnded);
|
||||
}
|
||||
|
||||
bool URLRequest::ResponseState::Failed() const {
|
||||
return IsFlagSet(ResponseStateFlags::kFailed);
|
||||
}
|
||||
|
||||
URLRequest::URLRequest(v8::Isolate* isolate, v8::Local<v8::Object> wrapper) {
|
||||
InitWith(isolate, wrapper);
|
||||
}
|
||||
|
||||
URLRequest::~URLRequest() {
|
||||
// A request has been created in JS, it was not used and then
|
||||
// it got collected, no close event to cleanup, only destructor
|
||||
// is called.
|
||||
if (atom_request_) {
|
||||
atom_request_->Terminate();
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
mate::WrappableBase* URLRequest::New(mate::Arguments* args) {
|
||||
auto isolate = args->isolate();
|
||||
v8::Local<v8::Object> options;
|
||||
args->GetNext(&options);
|
||||
mate::Dictionary dict(isolate, options);
|
||||
std::string method;
|
||||
dict.Get("method", &method);
|
||||
std::string url;
|
||||
dict.Get("url", &url);
|
||||
std::string partition;
|
||||
mate::Handle<api::Session> session;
|
||||
if (dict.Get("session", &session)) {
|
||||
} else if (dict.Get("partition", &partition)) {
|
||||
session = Session::FromPartition(isolate, partition);
|
||||
} else {
|
||||
// Use the default session if not specified.
|
||||
session = Session::FromPartition(isolate, "");
|
||||
}
|
||||
auto browser_context = session->browser_context();
|
||||
auto api_url_request = new URLRequest(args->isolate(), args->GetThis());
|
||||
auto atom_url_request =
|
||||
AtomURLRequest::Create(browser_context, method, url, api_url_request);
|
||||
|
||||
api_url_request->atom_request_ = atom_url_request;
|
||||
|
||||
return api_url_request;
|
||||
}
|
||||
|
||||
// static
|
||||
void URLRequest::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "URLRequest"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
// Request API
|
||||
.MakeDestroyable()
|
||||
.SetMethod("write", &URLRequest::Write)
|
||||
.SetMethod("cancel", &URLRequest::Cancel)
|
||||
.SetMethod("setExtraHeader", &URLRequest::SetExtraHeader)
|
||||
.SetMethod("removeExtraHeader", &URLRequest::RemoveExtraHeader)
|
||||
.SetMethod("setChunkedUpload", &URLRequest::SetChunkedUpload)
|
||||
.SetMethod("_setLoadFlags", &URLRequest::SetLoadFlags)
|
||||
.SetProperty("notStarted", &URLRequest::NotStarted)
|
||||
.SetProperty("finished", &URLRequest::Finished)
|
||||
// Response APi
|
||||
.SetProperty("statusCode", &URLRequest::StatusCode)
|
||||
.SetProperty("statusMessage", &URLRequest::StatusMessage)
|
||||
.SetProperty("rawResponseHeaders", &URLRequest::RawResponseHeaders)
|
||||
.SetProperty("httpVersionMajor", &URLRequest::ResponseHttpVersionMajor)
|
||||
.SetProperty("httpVersionMinor", &URLRequest::ResponseHttpVersionMinor);
|
||||
}
|
||||
|
||||
bool URLRequest::NotStarted() const {
|
||||
return request_state_.NotStarted();
|
||||
}
|
||||
|
||||
bool URLRequest::Finished() const {
|
||||
return request_state_.Finished();
|
||||
}
|
||||
|
||||
bool URLRequest::Canceled() const {
|
||||
return request_state_.Canceled();
|
||||
}
|
||||
|
||||
bool URLRequest::Write(scoped_refptr<const net::IOBufferWithSize> buffer,
|
||||
bool is_last) {
|
||||
if (request_state_.Canceled() || request_state_.Failed() ||
|
||||
request_state_.Finished() || request_state_.Closed()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (request_state_.NotStarted()) {
|
||||
request_state_.SetFlag(RequestStateFlags::kStarted);
|
||||
// Pin on first write.
|
||||
Pin();
|
||||
}
|
||||
|
||||
if (is_last) {
|
||||
request_state_.SetFlag(RequestStateFlags::kFinished);
|
||||
EmitRequestEvent(true, "finish");
|
||||
}
|
||||
|
||||
DCHECK(atom_request_);
|
||||
if (atom_request_) {
|
||||
return atom_request_->Write(buffer, is_last);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void URLRequest::Cancel() {
|
||||
if (request_state_.Canceled() || request_state_.Closed()) {
|
||||
// Cancel only once.
|
||||
return;
|
||||
}
|
||||
|
||||
// Mark as canceled.
|
||||
request_state_.SetFlag(RequestStateFlags::kCanceled);
|
||||
|
||||
DCHECK(atom_request_);
|
||||
if (atom_request_ && request_state_.Started()) {
|
||||
// Really cancel if it was started.
|
||||
atom_request_->Cancel();
|
||||
}
|
||||
EmitRequestEvent(true, "abort");
|
||||
|
||||
if (response_state_.Started() && !response_state_.Ended()) {
|
||||
EmitResponseEvent(true, "aborted");
|
||||
}
|
||||
Close();
|
||||
}
|
||||
|
||||
bool URLRequest::SetExtraHeader(const std::string& name,
|
||||
const std::string& value) {
|
||||
// Request state must be in the initial non started state.
|
||||
if (!request_state_.NotStarted()) {
|
||||
// Cannot change headers after send.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!net::HttpUtil::IsValidHeaderName(name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!net::HttpUtil::IsValidHeaderValue(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DCHECK(atom_request_);
|
||||
if (atom_request_) {
|
||||
atom_request_->SetExtraHeader(name, value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void URLRequest::RemoveExtraHeader(const std::string& name) {
|
||||
// State must be equal to not started.
|
||||
if (!request_state_.NotStarted()) {
|
||||
// Cannot change headers after send.
|
||||
return;
|
||||
}
|
||||
DCHECK(atom_request_);
|
||||
if (atom_request_) {
|
||||
atom_request_->RemoveExtraHeader(name);
|
||||
}
|
||||
}
|
||||
|
||||
void URLRequest::SetChunkedUpload(bool is_chunked_upload) {
|
||||
// State must be equal to not started.
|
||||
if (!request_state_.NotStarted()) {
|
||||
// Cannot change headers after send.
|
||||
return;
|
||||
}
|
||||
DCHECK(atom_request_);
|
||||
if (atom_request_) {
|
||||
atom_request_->SetChunkedUpload(is_chunked_upload);
|
||||
}
|
||||
}
|
||||
|
||||
void URLRequest::SetLoadFlags(int flags) {
|
||||
// State must be equal to not started.
|
||||
if (!request_state_.NotStarted()) {
|
||||
// Cannot change load flags after start.
|
||||
return;
|
||||
}
|
||||
DCHECK(atom_request_);
|
||||
if (atom_request_) {
|
||||
atom_request_->SetLoadFlags(flags);
|
||||
}
|
||||
}
|
||||
|
||||
void URLRequest::OnAuthenticationRequired(
|
||||
scoped_refptr<const net::AuthChallengeInfo> auth_info) {
|
||||
if (request_state_.Canceled() || request_state_.Closed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
DCHECK(atom_request_);
|
||||
if (!atom_request_) {
|
||||
return;
|
||||
}
|
||||
|
||||
Emit("login", auth_info.get(),
|
||||
base::Bind(&AtomURLRequest::PassLoginInformation, atom_request_));
|
||||
}
|
||||
|
||||
void URLRequest::OnResponseStarted(
|
||||
scoped_refptr<net::HttpResponseHeaders> response_headers) {
|
||||
if (request_state_.Canceled() || request_state_.Failed() ||
|
||||
request_state_.Closed()) {
|
||||
// Don't emit any event after request cancel.
|
||||
return;
|
||||
}
|
||||
response_headers_ = response_headers;
|
||||
response_state_.SetFlag(ResponseStateFlags::kStarted);
|
||||
Emit("response");
|
||||
}
|
||||
|
||||
void URLRequest::OnResponseData(
|
||||
scoped_refptr<const net::IOBufferWithSize> buffer) {
|
||||
if (request_state_.Canceled() || request_state_.Closed() ||
|
||||
request_state_.Failed() || response_state_.Failed()) {
|
||||
// In case we received an unexpected event from Chromium net,
|
||||
// don't emit any data event after request cancel/error/close.
|
||||
return;
|
||||
}
|
||||
if (!buffer || !buffer->data() || !buffer->size()) {
|
||||
return;
|
||||
}
|
||||
Emit("data", buffer);
|
||||
}
|
||||
|
||||
void URLRequest::OnResponseCompleted() {
|
||||
if (request_state_.Canceled() || request_state_.Closed() ||
|
||||
request_state_.Failed() || response_state_.Failed()) {
|
||||
// In case we received an unexpected event from Chromium net,
|
||||
// don't emit any data event after request cancel/error/close.
|
||||
return;
|
||||
}
|
||||
response_state_.SetFlag(ResponseStateFlags::kEnded);
|
||||
Emit("end");
|
||||
Close();
|
||||
}
|
||||
|
||||
void URLRequest::OnError(const std::string& error, bool isRequestError) {
|
||||
auto error_object = v8::Exception::Error(mate::StringToV8(isolate(), error));
|
||||
if (isRequestError) {
|
||||
request_state_.SetFlag(RequestStateFlags::kFailed);
|
||||
EmitRequestEvent(false, "error", error_object);
|
||||
} else {
|
||||
response_state_.SetFlag(ResponseStateFlags::kFailed);
|
||||
EmitResponseEvent(false, "error", error_object);
|
||||
}
|
||||
Close();
|
||||
}
|
||||
|
||||
int URLRequest::StatusCode() const {
|
||||
if (response_headers_) {
|
||||
return response_headers_->response_code();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::string URLRequest::StatusMessage() const {
|
||||
std::string result;
|
||||
if (response_headers_) {
|
||||
result = response_headers_->GetStatusText();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
net::HttpResponseHeaders* URLRequest::RawResponseHeaders() const {
|
||||
return response_headers_.get();
|
||||
}
|
||||
|
||||
uint32_t URLRequest::ResponseHttpVersionMajor() const {
|
||||
if (response_headers_) {
|
||||
return response_headers_->GetHttpVersion().major_value();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t URLRequest::ResponseHttpVersionMinor() const {
|
||||
if (response_headers_) {
|
||||
return response_headers_->GetHttpVersion().minor_value();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void URLRequest::Close() {
|
||||
if (!request_state_.Closed()) {
|
||||
request_state_.SetFlag(RequestStateFlags::kClosed);
|
||||
if (response_state_.Started()) {
|
||||
// Emit a close event if we really have a response object.
|
||||
EmitResponseEvent(true, "close");
|
||||
}
|
||||
EmitRequestEvent(true, "close");
|
||||
}
|
||||
Unpin();
|
||||
if (atom_request_) {
|
||||
// A request has been created in JS, used and then it ended.
|
||||
// We release unneeded net resources.
|
||||
atom_request_->Terminate();
|
||||
}
|
||||
atom_request_ = nullptr;
|
||||
}
|
||||
|
||||
void URLRequest::Pin() {
|
||||
if (wrapper_.IsEmpty()) {
|
||||
wrapper_.Reset(isolate(), GetWrapper());
|
||||
}
|
||||
}
|
||||
|
||||
void URLRequest::Unpin() {
|
||||
wrapper_.Reset();
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void URLRequest::EmitRequestEvent(Args... args) {
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
mate::CustomEmit(isolate(), GetWrapper(), "_emitRequestEvent", args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void URLRequest::EmitResponseEvent(Args... args) {
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
mate::CustomEmit(isolate(), GetWrapper(), "_emitResponseEvent", args...);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
207
atom/browser/api/atom_api_url_request.h
Normal file
207
atom/browser/api/atom_api_url_request.h
Normal file
@@ -0,0 +1,207 @@
|
||||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_API_ATOM_API_URL_REQUEST_H_
|
||||
#define ATOM_BROWSER_API_ATOM_API_URL_REQUEST_H_
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include "atom/browser/api/event_emitter.h"
|
||||
#include "atom/browser/api/trackable_object.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "native_mate/wrappable_base.h"
|
||||
#include "net/base/auth.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/http/http_response_headers.h"
|
||||
#include "net/url_request/url_request_context.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class AtomURLRequest;
|
||||
|
||||
namespace api {
|
||||
|
||||
//
|
||||
// The URLRequest class implements the V8 binding between the JavaScript API
|
||||
// and Chromium native net library. It is responsible for handling HTTP/HTTPS
|
||||
// requests.
|
||||
//
|
||||
// The current class provides only the binding layer. Two other JavaScript
|
||||
// classes (ClientRequest and IncomingMessage) in the net module provide the
|
||||
// final API, including some state management and arguments validation.
|
||||
//
|
||||
// URLRequest's methods fall into two main categories: command and event
|
||||
// methods. They are always executed on the Browser's UI thread.
|
||||
// Command methods are called directly from JavaScript code via the API defined
|
||||
// in BuildPrototype. A command method is generally implemented by forwarding
|
||||
// the call to a corresponding method on AtomURLRequest which does the
|
||||
// synchronization on the Browser IO thread. The latter then calls into Chromium
|
||||
// net library. On the other hand, net library events originate on the IO
|
||||
// thread in AtomURLRequest and are synchronized back on the UI thread, then
|
||||
// forwarded to a corresponding event method in URLRequest and then to
|
||||
// JavaScript via the EmitRequestEvent/EmitResponseEvent helpers.
|
||||
//
|
||||
// URLRequest lifetime management: we followed the Wrapper/Wrappable pattern
|
||||
// defined in native_mate. However, we augment that pattern with a pin/unpin
|
||||
// mechanism. The main reason is that we want the JS API to provide a similar
|
||||
// lifetime guarantees as the XMLHttpRequest.
|
||||
// https://xhr.spec.whatwg.org/#garbage-collection
|
||||
//
|
||||
// The primary motivation is to not garbage collect a URLInstance as long as the
|
||||
// object is emitting network events. For instance, in the following JS code
|
||||
//
|
||||
// (function() {
|
||||
// let request = new URLRequest(...);
|
||||
// request.on('response', (response)=>{
|
||||
// response.on('data', (data) = > {
|
||||
// console.log(data.toString());
|
||||
// });
|
||||
// });
|
||||
// })();
|
||||
//
|
||||
// we still want data to be logged even if the response/request objects are n
|
||||
// more referenced in JavaScript.
|
||||
//
|
||||
// Binding by simply following the native_mate Wrapper/Wrappable pattern will
|
||||
// delete the URLRequest object when the corresponding JS object is collected.
|
||||
// The v8 handle is a private member in WrappableBase and it is always weak,
|
||||
// there is no way to make it strong without changing native_mate.
|
||||
// The solution we implement consists of maintaining some kind of state that
|
||||
// prevents collection of JS wrappers as long as the request is emitting network
|
||||
// events. At initialization, the object is unpinned. When the request starts,
|
||||
// it is pinned. When no more events would be emitted, the object is unpinned
|
||||
// and lifetime is again managed by the standard native mate Wrapper/Wrappable
|
||||
// pattern.
|
||||
//
|
||||
// pin/unpin: are implemented by constructing/reseting a V8 strong persistent
|
||||
// handle.
|
||||
//
|
||||
// The URLRequest/AtmURLRequest interaction could have been implemented in a
|
||||
// single class. However, it implies that the resulting class lifetime will be
|
||||
// managed by two conflicting mechanisms: JavaScript garbage collection and
|
||||
// Chromium reference counting. Reasoning about lifetime issues become much
|
||||
// more complex.
|
||||
//
|
||||
// We chose to split the implementation into two classes linked via a
|
||||
// reference counted/raw pointers. A URLRequest instance is deleted if it is
|
||||
// unpinned and the corresponding JS wrapper object is garbage collected. On the
|
||||
// other hand, an AtmURLRequest instance lifetime is totally governed by
|
||||
// reference counting.
|
||||
//
|
||||
class URLRequest : public mate::EventEmitter<URLRequest> {
|
||||
public:
|
||||
static mate::WrappableBase* New(mate::Arguments* args);
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
// Methods for reporting events into JavaScript.
|
||||
void OnAuthenticationRequired(
|
||||
scoped_refptr<const net::AuthChallengeInfo> auth_info);
|
||||
void OnResponseStarted(
|
||||
scoped_refptr<net::HttpResponseHeaders> response_headers);
|
||||
void OnResponseData(scoped_refptr<const net::IOBufferWithSize> data);
|
||||
void OnResponseCompleted();
|
||||
void OnError(const std::string& error, bool isRequestError);
|
||||
|
||||
protected:
|
||||
explicit URLRequest(v8::Isolate* isolate, v8::Local<v8::Object> wrapper);
|
||||
~URLRequest() override;
|
||||
|
||||
private:
|
||||
template <typename Flags>
|
||||
class StateBase {
|
||||
public:
|
||||
void SetFlag(Flags flag);
|
||||
|
||||
protected:
|
||||
explicit StateBase(Flags initialState);
|
||||
bool operator==(Flags flag) const;
|
||||
bool IsFlagSet(Flags flag) const;
|
||||
|
||||
private:
|
||||
Flags state_;
|
||||
};
|
||||
|
||||
enum class RequestStateFlags {
|
||||
kNotStarted = 0x0,
|
||||
kStarted = 0x1,
|
||||
kFinished = 0x2,
|
||||
kCanceled = 0x4,
|
||||
kFailed = 0x8,
|
||||
kClosed = 0x10
|
||||
};
|
||||
|
||||
class RequestState : public StateBase<RequestStateFlags> {
|
||||
public:
|
||||
RequestState();
|
||||
bool NotStarted() const;
|
||||
bool Started() const;
|
||||
bool Finished() const;
|
||||
bool Canceled() const;
|
||||
bool Failed() const;
|
||||
bool Closed() const;
|
||||
};
|
||||
|
||||
enum class ResponseStateFlags {
|
||||
kNotStarted = 0x0,
|
||||
kStarted = 0x1,
|
||||
kEnded = 0x2,
|
||||
kFailed = 0x4
|
||||
};
|
||||
|
||||
class ResponseState : public StateBase<ResponseStateFlags> {
|
||||
public:
|
||||
ResponseState();
|
||||
bool NotStarted() const;
|
||||
bool Started() const;
|
||||
bool Ended() const;
|
||||
bool Canceled() const;
|
||||
bool Failed() const;
|
||||
bool Closed() const;
|
||||
};
|
||||
|
||||
bool NotStarted() const;
|
||||
bool Finished() const;
|
||||
bool Canceled() const;
|
||||
bool Failed() const;
|
||||
bool Write(scoped_refptr<const net::IOBufferWithSize> buffer, bool is_last);
|
||||
void Cancel();
|
||||
bool SetExtraHeader(const std::string& name, const std::string& value);
|
||||
void RemoveExtraHeader(const std::string& name);
|
||||
void SetChunkedUpload(bool is_chunked_upload);
|
||||
void SetLoadFlags(int flags);
|
||||
|
||||
int StatusCode() const;
|
||||
std::string StatusMessage() const;
|
||||
net::HttpResponseHeaders* RawResponseHeaders() const;
|
||||
uint32_t ResponseHttpVersionMajor() const;
|
||||
uint32_t ResponseHttpVersionMinor() const;
|
||||
|
||||
void Close();
|
||||
void Pin();
|
||||
void Unpin();
|
||||
template <typename... Args>
|
||||
void EmitRequestEvent(Args... args);
|
||||
template <typename... Args>
|
||||
void EmitResponseEvent(Args... args);
|
||||
|
||||
scoped_refptr<AtomURLRequest> atom_request_;
|
||||
RequestState request_state_;
|
||||
ResponseState response_state_;
|
||||
|
||||
// Used to implement pin/unpin.
|
||||
v8::Global<v8::Object> wrapper_;
|
||||
scoped_refptr<net::HttpResponseHeaders> response_headers_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(URLRequest);
|
||||
};
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_API_ATOM_API_URL_REQUEST_H_
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "atom/browser/atom_browser_client.h"
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
#include "atom/browser/atom_security_state_model_client.h"
|
||||
#include "atom/browser/lib/bluetooth_chooser.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/net/atom_network_delegate.h"
|
||||
@@ -23,6 +22,7 @@
|
||||
#include "atom/browser/ui/drag_util.h"
|
||||
#include "atom/browser/web_contents_permission_helper.h"
|
||||
#include "atom/browser/web_contents_preferences.h"
|
||||
#include "atom/browser/web_contents_zoom_controller.h"
|
||||
#include "atom/browser/web_view_guest_delegate.h"
|
||||
#include "atom/common/api/api_messages.h"
|
||||
#include "atom/common/api/event_emitter_caller.h"
|
||||
@@ -35,15 +35,18 @@
|
||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||
#include "atom/common/native_mate_converters/image_converter.h"
|
||||
#include "atom/common/native_mate_converters/net_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/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "brightray/browser/inspectable_web_contents.h"
|
||||
#include "brightray/browser/inspectable_web_contents_view.h"
|
||||
#include "chrome/browser/printing/print_preview_message_handler.h"
|
||||
#include "chrome/browser/printing/print_view_manager_basic.h"
|
||||
#include "chrome/browser/ssl/security_state_tab_helper.h"
|
||||
#include "content/browser/frame_host/navigation_entry_impl.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
||||
#include "content/browser/web_contents/web_contents_impl.h"
|
||||
#include "content/common/view_messages.h"
|
||||
@@ -52,6 +55,9 @@
|
||||
#include "content/public/browser/navigation_details.h"
|
||||
#include "content/public/browser/navigation_entry.h"
|
||||
#include "content/public/browser/navigation_handle.h"
|
||||
#include "content/public/browser/notification_details.h"
|
||||
#include "content/public/browser/notification_source.h"
|
||||
#include "content/public/browser/notification_types.h"
|
||||
#include "content/public/browser/plugin_service.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
@@ -66,10 +72,9 @@
|
||||
#include "content/public/common/context_menu_params.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
#include "net/http/http_response_headers.h"
|
||||
#include "net/url_request/url_request_context.h"
|
||||
#include "third_party/WebKit/public/platform/WebInputEvent.h"
|
||||
#include "third_party/WebKit/public/web/WebFindOptions.h"
|
||||
#include "third_party/WebKit/public/web/WebInputEvent.h"
|
||||
#include "ui/display/screen.h"
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
@@ -130,43 +135,29 @@ struct Converter<WindowOpenDisposition> {
|
||||
WindowOpenDisposition val) {
|
||||
std::string disposition = "other";
|
||||
switch (val) {
|
||||
case CURRENT_TAB: disposition = "default"; break;
|
||||
case NEW_FOREGROUND_TAB: disposition = "foreground-tab"; break;
|
||||
case NEW_BACKGROUND_TAB: disposition = "background-tab"; break;
|
||||
case NEW_POPUP: case NEW_WINDOW: disposition = "new-window"; break;
|
||||
case SAVE_TO_DISK: disposition = "save-to-disk"; break;
|
||||
default: break;
|
||||
case WindowOpenDisposition::CURRENT_TAB:
|
||||
disposition = "default";
|
||||
break;
|
||||
case WindowOpenDisposition::NEW_FOREGROUND_TAB:
|
||||
disposition = "foreground-tab";
|
||||
break;
|
||||
case WindowOpenDisposition::NEW_BACKGROUND_TAB:
|
||||
disposition = "background-tab";
|
||||
break;
|
||||
case WindowOpenDisposition::NEW_POPUP:
|
||||
case WindowOpenDisposition::NEW_WINDOW:
|
||||
disposition = "new-window";
|
||||
break;
|
||||
case WindowOpenDisposition::SAVE_TO_DISK:
|
||||
disposition = "save-to-disk";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return mate::ConvertToV8(isolate, disposition);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Converter<net::HttpResponseHeaders*> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
net::HttpResponseHeaders* headers) {
|
||||
base::DictionaryValue response_headers;
|
||||
if (headers) {
|
||||
size_t iter = 0;
|
||||
std::string key;
|
||||
std::string value;
|
||||
while (headers->EnumerateHeaderLines(&iter, &key, &value)) {
|
||||
key = base::ToLowerASCII(key);
|
||||
if (response_headers.HasKey(key)) {
|
||||
base::ListValue* values = nullptr;
|
||||
if (response_headers.GetList(key, &values))
|
||||
values->AppendString(value);
|
||||
} else {
|
||||
std::unique_ptr<base::ListValue> values(new base::ListValue());
|
||||
values->AppendString(value);
|
||||
response_headers.Set(key, std::move(values));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ConvertToV8(isolate, response_headers);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Converter<content::SavePageType> {
|
||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
||||
@@ -255,6 +246,22 @@ void OnCapturePageDone(base::Callback<void(const gfx::Image&)> callback,
|
||||
callback.Run(gfx::Image::CreateFrom1xBitmap(bitmap));
|
||||
}
|
||||
|
||||
// Set the background color of RenderWidgetHostView.
|
||||
void SetBackgroundColor(content::WebContents* web_contents) {
|
||||
const auto view = web_contents->GetRenderWidgetHostView();
|
||||
if (view) {
|
||||
WebContentsPreferences* web_preferences =
|
||||
WebContentsPreferences::FromWebContents(web_contents);
|
||||
std::string color_name;
|
||||
if (web_preferences->web_preferences()->GetString(options::kBackgroundColor,
|
||||
&color_name)) {
|
||||
view->SetBackgroundColor(ParseHexColor(color_name));
|
||||
} else {
|
||||
view->SetBackgroundColor(SK_ColorTRANSPARENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
WebContents::WebContents(v8::Isolate* isolate,
|
||||
@@ -262,11 +269,11 @@ WebContents::WebContents(v8::Isolate* isolate,
|
||||
Type type)
|
||||
: content::WebContentsObserver(web_contents),
|
||||
embedder_(nullptr),
|
||||
zoom_controller_(nullptr),
|
||||
type_(type),
|
||||
request_id_(0),
|
||||
background_throttling_(true),
|
||||
enable_devtools_(true) {
|
||||
|
||||
if (type == REMOTE) {
|
||||
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent());
|
||||
Init(isolate);
|
||||
@@ -279,9 +286,9 @@ WebContents::WebContents(v8::Isolate* isolate,
|
||||
}
|
||||
}
|
||||
|
||||
WebContents::WebContents(v8::Isolate* isolate,
|
||||
const mate::Dictionary& options)
|
||||
WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
|
||||
: embedder_(nullptr),
|
||||
zoom_controller_(nullptr),
|
||||
type_(BROWSER_WINDOW),
|
||||
request_id_(0),
|
||||
background_throttling_(true),
|
||||
@@ -351,7 +358,7 @@ void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
|
||||
content::WebContents *web_contents,
|
||||
mate::Handle<api::Session> session,
|
||||
const mate::Dictionary& options) {
|
||||
Observe(web_contents);
|
||||
content::WebContentsObserver::Observe(web_contents);
|
||||
InitWithWebContents(web_contents, session->browser_context());
|
||||
|
||||
managed_web_contents()->GetView()->SetDelegate(this);
|
||||
@@ -359,10 +366,16 @@ void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
|
||||
// Save the preferences in C++.
|
||||
new WebContentsPreferences(web_contents, options);
|
||||
|
||||
// Intialize permission helper.
|
||||
// Initialize permission helper.
|
||||
WebContentsPermissionHelper::CreateForWebContents(web_contents);
|
||||
// Intialize security state client.
|
||||
AtomSecurityStateModelClient::CreateForWebContents(web_contents);
|
||||
// Initialize security state client.
|
||||
SecurityStateTabHelper::CreateForWebContents(web_contents);
|
||||
// Initialize zoom controller.
|
||||
WebContentsZoomController::CreateForWebContents(web_contents);
|
||||
zoom_controller_ = WebContentsZoomController::FromWebContents(web_contents);
|
||||
double zoom_factor;
|
||||
if (options.Get(options::kZoomFactor, &zoom_factor))
|
||||
zoom_controller_->SetDefaultZoomFactor(zoom_factor);
|
||||
|
||||
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent());
|
||||
|
||||
@@ -381,6 +394,11 @@ void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
|
||||
SetOwnerWindow(owner_window);
|
||||
}
|
||||
|
||||
const content::NavigationController* controller =
|
||||
&web_contents->GetController();
|
||||
registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING,
|
||||
content::Source<content::NavigationController>(controller));
|
||||
|
||||
Init(isolate);
|
||||
AttachAsUserData(web_contents);
|
||||
}
|
||||
@@ -401,11 +419,11 @@ WebContents::~WebContents() {
|
||||
}
|
||||
}
|
||||
|
||||
bool WebContents::AddMessageToConsole(content::WebContents* source,
|
||||
int32_t level,
|
||||
const base::string16& message,
|
||||
int32_t line_no,
|
||||
const base::string16& source_id) {
|
||||
bool WebContents::DidAddMessageToConsole(content::WebContents* source,
|
||||
int32_t level,
|
||||
const base::string16& message,
|
||||
int32_t line_no,
|
||||
const base::string16& source_id) {
|
||||
if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -414,17 +432,20 @@ bool WebContents::AddMessageToConsole(content::WebContents* source,
|
||||
}
|
||||
}
|
||||
|
||||
void WebContents::OnCreateWindow(const GURL& target_url,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const std::vector<base::string16>& features) {
|
||||
void WebContents::OnCreateWindow(
|
||||
const GURL& target_url,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const std::vector<std::string>& features,
|
||||
const scoped_refptr<content::ResourceRequestBodyImpl>& body) {
|
||||
if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN)
|
||||
Emit("-new-window", target_url, frame_name, disposition, features);
|
||||
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,
|
||||
@@ -444,15 +465,17 @@ void WebContents::AddNewContents(content::WebContents* source,
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
auto api_web_contents = CreateFrom(isolate(), new_contents);
|
||||
Emit("-add-new-contents", api_web_contents, disposition, user_gesture,
|
||||
if (Emit("-add-new-contents", api_web_contents, disposition, user_gesture,
|
||||
initial_rect.x(), initial_rect.y(), initial_rect.width(),
|
||||
initial_rect.height());
|
||||
initial_rect.height())) {
|
||||
api_web_contents->DestroyWebContents();
|
||||
}
|
||||
}
|
||||
|
||||
content::WebContents* WebContents::OpenURLFromTab(
|
||||
content::WebContents* source,
|
||||
const content::OpenURLParams& params) {
|
||||
if (params.disposition != CURRENT_TAB) {
|
||||
if (params.disposition != WindowOpenDisposition::CURRENT_TAB) {
|
||||
if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN)
|
||||
Emit("-new-window", params.url, "", params.disposition);
|
||||
else
|
||||
@@ -464,6 +487,11 @@ content::WebContents* WebContents::OpenURLFromTab(
|
||||
if (Emit("will-navigate", params.url))
|
||||
return nullptr;
|
||||
|
||||
// Don't load the URL if the web contents was marked as destroyed from a
|
||||
// will-navigate event listener
|
||||
if (IsDestroyed())
|
||||
return nullptr;
|
||||
|
||||
return CommonWebContentsDelegate::OpenURLFromTab(source, params);
|
||||
}
|
||||
|
||||
@@ -513,6 +541,17 @@ void WebContents::HandleKeyboardEvent(
|
||||
}
|
||||
}
|
||||
|
||||
bool WebContents::PreHandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event,
|
||||
bool* is_keyboard_shortcut) {
|
||||
if (event.type == blink::WebInputEvent::Type::RawKeyDown
|
||||
|| event.type == blink::WebInputEvent::Type::KeyUp)
|
||||
return Emit("before-input-event", event);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void WebContents::EnterFullscreenModeForTab(content::WebContents* source,
|
||||
const GURL& origin) {
|
||||
auto permission_helper =
|
||||
@@ -536,7 +575,9 @@ void WebContents::ExitFullscreenModeForTab(content::WebContents* source) {
|
||||
Emit("leave-html-full-screen");
|
||||
}
|
||||
|
||||
void WebContents::RendererUnresponsive(content::WebContents* source) {
|
||||
void WebContents::RendererUnresponsive(
|
||||
content::WebContents* source,
|
||||
const content::WebContentsUnresponsiveState& unresponsive_state) {
|
||||
Emit("unresponsive");
|
||||
if ((type_ == BROWSER_WINDOW || type_ == OFF_SCREEN) && owner_window())
|
||||
owner_window()->RendererUnresponsive(source);
|
||||
@@ -622,6 +663,14 @@ void WebContents::BeforeUnloadFired(const base::TimeTicks& proceed_time) {
|
||||
// there are two virtual functions named BeforeUnloadFired.
|
||||
}
|
||||
|
||||
void WebContents::RenderViewCreated(content::RenderViewHost* render_view_host) {
|
||||
const auto impl = content::RenderWidgetHostImpl::FromID(
|
||||
render_view_host->GetProcess()->GetID(),
|
||||
render_view_host->GetRoutingID());
|
||||
if (impl)
|
||||
impl->disable_hidden_ = !background_throttling_;
|
||||
}
|
||||
|
||||
void WebContents::RenderViewDeleted(content::RenderViewHost* render_view_host) {
|
||||
Emit("render-view-deleted", render_view_host->GetProcess()->GetID());
|
||||
}
|
||||
@@ -638,11 +687,13 @@ void WebContents::PluginCrashed(const base::FilePath& plugin_path,
|
||||
Emit("plugin-crashed", info.name, info.version);
|
||||
}
|
||||
|
||||
void WebContents::MediaStartedPlaying(const MediaPlayerId& id) {
|
||||
void WebContents::MediaStartedPlaying(const MediaPlayerInfo& video_type,
|
||||
const MediaPlayerId& id) {
|
||||
Emit("media-started-playing");
|
||||
}
|
||||
|
||||
void WebContents::MediaStoppedPlaying(const MediaPlayerId& id) {
|
||||
void WebContents::MediaStoppedPlaying(const MediaPlayerInfo& video_type,
|
||||
const MediaPlayerId& id) {
|
||||
Emit("media-paused");
|
||||
}
|
||||
|
||||
@@ -696,7 +747,6 @@ void WebContents::DidGetResourceResponseStart(
|
||||
}
|
||||
|
||||
void WebContents::DidGetRedirectForResourceRequest(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const content::ResourceRedirectDetails& details) {
|
||||
Emit("did-get-redirect-request",
|
||||
details.url,
|
||||
@@ -708,6 +758,30 @@ void WebContents::DidGetRedirectForResourceRequest(
|
||||
details.headers.get());
|
||||
}
|
||||
|
||||
void WebContents::DidStartNavigation(
|
||||
content::NavigationHandle* navigation_handle) {
|
||||
if (!navigation_handle->IsInMainFrame() || navigation_handle->IsSamePage())
|
||||
return;
|
||||
|
||||
if (deferred_load_url_.id) {
|
||||
auto web_contents = navigation_handle->GetWebContents();
|
||||
auto& controller = web_contents->GetController();
|
||||
int id = controller.GetPendingEntry()->GetUniqueID();
|
||||
if (id == deferred_load_url_.id) {
|
||||
if (!deferred_load_url_.params.url.is_empty()) {
|
||||
auto params = deferred_load_url_.params;
|
||||
deferred_load_url_.id = 0;
|
||||
deferred_load_url_.params =
|
||||
content::NavigationController::LoadURLParams(GURL());
|
||||
controller.LoadURLWithParams(params);
|
||||
SetBackgroundColor(web_contents);
|
||||
} else {
|
||||
deferred_load_url_.id = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WebContents::DidFinishNavigation(
|
||||
content::NavigationHandle* navigation_handle) {
|
||||
bool is_main_frame = navigation_handle->IsInMainFrame();
|
||||
@@ -752,6 +826,32 @@ void WebContents::DidUpdateFaviconURL(
|
||||
Emit("page-favicon-updated", unique_urls);
|
||||
}
|
||||
|
||||
void WebContents::Observe(int type,
|
||||
const content::NotificationSource& source,
|
||||
const content::NotificationDetails& details) {
|
||||
switch (type) {
|
||||
case content::NOTIFICATION_NAV_ENTRY_PENDING: {
|
||||
content::NavigationEntry* entry =
|
||||
content::Details<content::NavigationEntry>(details).ptr();
|
||||
content::NavigationEntryImpl* entry_impl =
|
||||
static_cast<content::NavigationEntryImpl*>(entry);
|
||||
// In NavigatorImpl::DidStartMainFrameNavigation when there is no
|
||||
// browser side pending entry available it creates a new one based
|
||||
// on existing pending entry, hence we track the unique id here
|
||||
// instead in WebContents::LoadURL with controller.GetPendingEntry()
|
||||
// TODO(deepak1556): Remove once we have
|
||||
// https://codereview.chromium.org/2661743002.
|
||||
if (entry_impl->frame_tree_node_id() == -1) {
|
||||
deferred_load_url_.id = entry->GetUniqueID();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
NOTREACHED();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void WebContents::DevToolsReloadPage() {
|
||||
Emit("devtools-reload-page");
|
||||
}
|
||||
@@ -794,6 +894,10 @@ bool WebContents::OnMessageReceived(const IPC::Message& message) {
|
||||
IPC_MESSAGE_HANDLER(AtomViewHostMsg_Message, OnRendererMessage)
|
||||
IPC_MESSAGE_HANDLER_DELAY_REPLY(AtomViewHostMsg_Message_Sync,
|
||||
OnRendererMessageSync)
|
||||
IPC_MESSAGE_HANDLER_DELAY_REPLY(AtomViewHostMsg_SetTemporaryZoomLevel,
|
||||
OnSetTemporaryZoomLevel)
|
||||
IPC_MESSAGE_HANDLER_DELAY_REPLY(AtomViewHostMsg_GetZoomLevel,
|
||||
OnGetZoomLevel)
|
||||
IPC_MESSAGE_HANDLER_CODE(ViewHostMsg_SetCursor, OnCursorChange,
|
||||
handled = false)
|
||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||
@@ -829,7 +933,8 @@ void WebContents::WebContentsDestroyed() {
|
||||
Emit("destroyed");
|
||||
|
||||
// Destroy the native class in next tick.
|
||||
base::MessageLoop::current()->PostTask(FROM_HERE, GetDestroyClosure());
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE, GetDestroyClosure());
|
||||
}
|
||||
|
||||
void WebContents::NavigationEntryCommitted(
|
||||
@@ -858,7 +963,7 @@ bool WebContents::Equal(const WebContents* web_contents) const {
|
||||
}
|
||||
|
||||
void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
|
||||
if (!url.is_valid()) {
|
||||
if (!url.is_valid() || url.spec().size() > url::kMaxURLChars) {
|
||||
Emit("did-fail-load",
|
||||
static_cast<int>(net::ERR_INVALID_URL),
|
||||
net::ErrorToShortString(net::ERR_INVALID_URL),
|
||||
@@ -882,29 +987,31 @@ 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;
|
||||
if (options.Get("postData", &body)) {
|
||||
params.post_data = body;
|
||||
params.load_type = content::NavigationController::LOAD_TYPE_HTTP_POST;
|
||||
}
|
||||
|
||||
GURL base_url_for_data_url;
|
||||
if (options.Get("baseURLForDataURL", &base_url_for_data_url)) {
|
||||
params.base_url_for_data_url = base_url_for_data_url;
|
||||
params.load_type = content::NavigationController::LOAD_TYPE_DATA;
|
||||
}
|
||||
|
||||
params.transition_type = ui::PAGE_TRANSITION_TYPED;
|
||||
params.should_clear_history_list = true;
|
||||
params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
|
||||
web_contents()->GetController().LoadURLWithParams(params);
|
||||
|
||||
// Set the background color of RenderWidgetHostView.
|
||||
// We have to call it right after LoadURL because the RenderViewHost is only
|
||||
// created after loading a page.
|
||||
const auto view = web_contents()->GetRenderWidgetHostView();
|
||||
WebContentsPreferences* web_preferences =
|
||||
WebContentsPreferences::FromWebContents(web_contents());
|
||||
std::string color_name;
|
||||
if (web_preferences->web_preferences()->GetString(options::kBackgroundColor,
|
||||
&color_name)) {
|
||||
view->SetBackgroundColor(ParseHexColor(color_name));
|
||||
} else {
|
||||
view->SetBackgroundColor(SK_ColorTRANSPARENT);
|
||||
if (deferred_load_url_.id) {
|
||||
deferred_load_url_.params = params;
|
||||
return;
|
||||
}
|
||||
|
||||
// For the same reason we can only disable hidden here.
|
||||
const auto host = static_cast<content::RenderWidgetHostImpl*>(
|
||||
view->GetRenderWidgetHost());
|
||||
host->disable_hidden_ = !background_throttling_;
|
||||
web_contents()->GetController().LoadURLWithParams(params);
|
||||
// We have to call it right after LoadURL because the RenderViewHost is only
|
||||
// created after loading a page.
|
||||
SetBackgroundColor(web_contents());
|
||||
}
|
||||
|
||||
void WebContents::DownloadURL(const GURL& url) {
|
||||
@@ -960,6 +1067,23 @@ void WebContents::GoToOffset(int offset) {
|
||||
web_contents()->GetController().GoToOffset(offset);
|
||||
}
|
||||
|
||||
const std::string WebContents::GetWebRTCIPHandlingPolicy() const {
|
||||
return web_contents()->
|
||||
GetMutableRendererPrefs()->webrtc_ip_handling_policy;
|
||||
}
|
||||
|
||||
void WebContents::SetWebRTCIPHandlingPolicy(
|
||||
const std::string& webrtc_ip_handling_policy) {
|
||||
if (GetWebRTCIPHandlingPolicy() == webrtc_ip_handling_policy)
|
||||
return;
|
||||
web_contents()->GetMutableRendererPrefs()->webrtc_ip_handling_policy =
|
||||
webrtc_ip_handling_policy;
|
||||
|
||||
content::RenderViewHost* host = web_contents()->GetRenderViewHost();
|
||||
if (host)
|
||||
host->SyncRendererPrefs();
|
||||
}
|
||||
|
||||
bool WebContents::IsCrashed() const {
|
||||
return web_contents()->IsCrashed();
|
||||
}
|
||||
@@ -973,10 +1097,6 @@ std::string WebContents::GetUserAgent() {
|
||||
return web_contents()->GetUserAgentOverride();
|
||||
}
|
||||
|
||||
void WebContents::InsertCSS(const std::string& css) {
|
||||
web_contents()->InsertCSS(css);
|
||||
}
|
||||
|
||||
bool WebContents::SavePage(const base::FilePath& full_file_path,
|
||||
const content::SavePageType& save_type,
|
||||
const SavePageHandler::SavePageCallback& callback) {
|
||||
@@ -1062,9 +1182,7 @@ void WebContents::InspectElement(int x, int y) {
|
||||
|
||||
if (!managed_web_contents()->GetDevToolsWebContents())
|
||||
OpenDevTools(nullptr);
|
||||
scoped_refptr<content::DevToolsAgentHost> agent(
|
||||
content::DevToolsAgentHost::GetOrCreateFor(web_contents()));
|
||||
agent->InspectElement(x, y);
|
||||
managed_web_contents()->InspectElement(x, y);
|
||||
}
|
||||
|
||||
void WebContents::InspectServiceWorker() {
|
||||
@@ -1076,7 +1194,7 @@ void WebContents::InspectServiceWorker() {
|
||||
|
||||
for (const auto& agent_host : content::DevToolsAgentHost::GetOrCreateAll()) {
|
||||
if (agent_host->GetType() ==
|
||||
content::DevToolsAgentHost::TYPE_SERVICE_WORKER) {
|
||||
content::DevToolsAgentHost::kTypeServiceWorker) {
|
||||
OpenDevTools(nullptr);
|
||||
managed_web_contents()->AttachTo(agent_host);
|
||||
break;
|
||||
@@ -1121,7 +1239,9 @@ void WebContents::Print(mate::Arguments* args) {
|
||||
}
|
||||
|
||||
printing::PrintViewManagerBasic::FromWebContents(web_contents())->
|
||||
PrintNow(settings.silent, settings.print_background);
|
||||
PrintNow(web_contents()->GetMainFrame(),
|
||||
settings.silent,
|
||||
settings.print_background);
|
||||
}
|
||||
|
||||
void WebContents::PrintToPDF(const base::DictionaryValue& setting,
|
||||
@@ -1327,17 +1447,25 @@ void WebContents::StartDrag(const mate::Dictionary& item,
|
||||
|
||||
// Error checking.
|
||||
if (icon.IsEmpty()) {
|
||||
args->ThrowError("icon must be set");
|
||||
args->ThrowError("Must specify 'icon' option");
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
// NSWindow.dragImage requires a non-empty NSImage
|
||||
if (icon->image().IsEmpty()) {
|
||||
args->ThrowError("Must specify non-empty 'icon' option");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Start dragging.
|
||||
if (!files.empty()) {
|
||||
base::MessageLoop::ScopedNestableTaskAllower allow(
|
||||
base::MessageLoop::current());
|
||||
DragFileItems(files, icon->image(), web_contents()->GetNativeView());
|
||||
} else {
|
||||
args->ThrowError("There is nothing to drag");
|
||||
args->ThrowError("Must specify either 'file' or 'files' option");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1463,13 +1591,47 @@ int WebContents::GetFrameRate() const {
|
||||
}
|
||||
|
||||
void WebContents::Invalidate() {
|
||||
if (!IsOffScreen())
|
||||
return;
|
||||
|
||||
auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
|
||||
if (IsOffScreen()) {
|
||||
auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
|
||||
web_contents()->GetRenderWidgetHostView());
|
||||
if (osr_rwhv)
|
||||
osr_rwhv->Invalidate();
|
||||
if (osr_rwhv)
|
||||
osr_rwhv->Invalidate();
|
||||
} else {
|
||||
const auto window = owner_window();
|
||||
if (window)
|
||||
window->Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void WebContents::SetZoomLevel(double level) {
|
||||
zoom_controller_->SetZoomLevel(level);
|
||||
}
|
||||
|
||||
double WebContents::GetZoomLevel() {
|
||||
return zoom_controller_->GetZoomLevel();
|
||||
}
|
||||
|
||||
void WebContents::SetZoomFactor(double factor) {
|
||||
auto level = content::ZoomFactorToZoomLevel(factor);
|
||||
SetZoomLevel(level);
|
||||
}
|
||||
|
||||
double WebContents::GetZoomFactor() {
|
||||
auto level = GetZoomLevel();
|
||||
return content::ZoomLevelToZoomFactor(level);
|
||||
}
|
||||
|
||||
void WebContents::OnSetTemporaryZoomLevel(double level,
|
||||
IPC::Message* reply_msg) {
|
||||
zoom_controller_->SetTemporaryZoomLevel(level);
|
||||
double new_level = zoom_controller_->GetZoomLevel();
|
||||
AtomViewHostMsg_SetTemporaryZoomLevel::WriteReplyParams(reply_msg, new_level);
|
||||
Send(reply_msg);
|
||||
}
|
||||
|
||||
void WebContents::OnGetZoomLevel(IPC::Message* reply_msg) {
|
||||
AtomViewHostMsg_GetZoomLevel::WriteReplyParams(reply_msg, GetZoomLevel());
|
||||
Send(reply_msg);
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> WebContents::GetWebPreferences(v8::Isolate* isolate) {
|
||||
@@ -1556,7 +1718,6 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("isCrashed", &WebContents::IsCrashed)
|
||||
.SetMethod("setUserAgent", &WebContents::SetUserAgent)
|
||||
.SetMethod("getUserAgent", &WebContents::GetUserAgent)
|
||||
.SetMethod("insertCSS", &WebContents::InsertCSS)
|
||||
.SetMethod("savePage", &WebContents::SavePage)
|
||||
.SetMethod("openDevTools", &WebContents::OpenDevTools)
|
||||
.SetMethod("closeDevTools", &WebContents::CloseDevTools)
|
||||
@@ -1601,6 +1762,10 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("setFrameRate", &WebContents::SetFrameRate)
|
||||
.SetMethod("getFrameRate", &WebContents::GetFrameRate)
|
||||
.SetMethod("invalidate", &WebContents::Invalidate)
|
||||
.SetMethod("setZoomLevel", &WebContents::SetZoomLevel)
|
||||
.SetMethod("_getZoomLevel", &WebContents::GetZoomLevel)
|
||||
.SetMethod("setZoomFactor", &WebContents::SetZoomFactor)
|
||||
.SetMethod("_getZoomFactor", &WebContents::GetZoomFactor)
|
||||
.SetMethod("getType", &WebContents::GetType)
|
||||
.SetMethod("getWebPreferences", &WebContents::GetWebPreferences)
|
||||
.SetMethod("getOwnerBrowserWindow", &WebContents::GetOwnerBrowserWindow)
|
||||
@@ -1617,6 +1782,10 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("copyImageAt", &WebContents::CopyImageAt)
|
||||
.SetMethod("capturePage", &WebContents::CapturePage)
|
||||
.SetMethod("setEmbedder", &WebContents::SetEmbedder)
|
||||
.SetMethod("setWebRTCIPHandlingPolicy",
|
||||
&WebContents::SetWebRTCIPHandlingPolicy)
|
||||
.SetMethod("getWebRTCIPHandlingPolicy",
|
||||
&WebContents::GetWebRTCIPHandlingPolicy)
|
||||
.SetProperty("id", &WebContents::ID)
|
||||
.SetProperty("session", &WebContents::Session)
|
||||
.SetProperty("hostWebContents", &WebContents::HostWebContents)
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "atom/browser/api/trackable_object.h"
|
||||
#include "atom/browser/common_web_contents_delegate.h"
|
||||
#include "content/common/cursors/webcursor.h"
|
||||
#include "content/public/browser/notification_observer.h"
|
||||
#include "content/public/browser/notification_registrar.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "content/public/common/favicon_url.h"
|
||||
#include "native_mate/handle.h"
|
||||
@@ -26,6 +28,10 @@ namespace brightray {
|
||||
class InspectableWebContents;
|
||||
}
|
||||
|
||||
namespace content {
|
||||
class ResourceRequestBodyImpl;
|
||||
}
|
||||
|
||||
namespace mate {
|
||||
class Arguments;
|
||||
class Dictionary;
|
||||
@@ -35,13 +41,15 @@ namespace atom {
|
||||
|
||||
struct SetSizeParams;
|
||||
class AtomBrowserContext;
|
||||
class WebContentsZoomController;
|
||||
class WebViewGuestDelegate;
|
||||
|
||||
namespace api {
|
||||
|
||||
class WebContents : public mate::TrackableObject<WebContents>,
|
||||
public CommonWebContentsDelegate,
|
||||
public content::WebContentsObserver {
|
||||
public content::WebContentsObserver,
|
||||
public content::NotificationObserver {
|
||||
public:
|
||||
enum Type {
|
||||
BACKGROUND_PAGE, // A DevTools extension background page.
|
||||
@@ -84,6 +92,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
void GoBack();
|
||||
void GoForward();
|
||||
void GoToOffset(int offset);
|
||||
const std::string GetWebRTCIPHandlingPolicy() const;
|
||||
void SetWebRTCIPHandlingPolicy(const std::string& webrtc_ip_handling_policy);
|
||||
bool IsCrashed() const;
|
||||
void SetUserAgent(const std::string& user_agent, mate::Arguments* args);
|
||||
std::string GetUserAgent();
|
||||
@@ -170,16 +180,24 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
int GetFrameRate() const;
|
||||
void Invalidate();
|
||||
|
||||
// Methods for zoom handling.
|
||||
void SetZoomLevel(double level);
|
||||
double GetZoomLevel();
|
||||
void SetZoomFactor(double factor);
|
||||
double GetZoomFactor();
|
||||
|
||||
// Callback triggered on permission response.
|
||||
void OnEnterFullscreenModeForTab(content::WebContents* source,
|
||||
const GURL& origin,
|
||||
bool allowed);
|
||||
|
||||
// Create window with the given disposition.
|
||||
void OnCreateWindow(const GURL& target_url,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const std::vector<base::string16>& features);
|
||||
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);
|
||||
|
||||
// Returns the web preferences of current WebContents.
|
||||
v8::Local<v8::Value> GetWebPreferences(v8::Isolate* isolate);
|
||||
@@ -194,6 +212,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
v8::Local<v8::Value> DevToolsWebContents(v8::Isolate* isolate);
|
||||
v8::Local<v8::Value> Debugger(v8::Isolate* isolate);
|
||||
|
||||
WebContentsZoomController* GetZoomController() { return zoom_controller_; }
|
||||
|
||||
protected:
|
||||
WebContents(v8::Isolate* isolate,
|
||||
content::WebContents* web_contents,
|
||||
@@ -207,12 +227,13 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
const mate::Dictionary& options);
|
||||
|
||||
// content::WebContentsDelegate:
|
||||
bool AddMessageToConsole(content::WebContents* source,
|
||||
int32_t level,
|
||||
const base::string16& message,
|
||||
int32_t line_no,
|
||||
const base::string16& source_id) override;
|
||||
bool DidAddMessageToConsole(content::WebContents* source,
|
||||
int32_t level,
|
||||
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,
|
||||
@@ -238,10 +259,15 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
void HandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) override;
|
||||
bool PreHandleKeyboardEvent(content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event,
|
||||
bool* is_keyboard_shortcut) override;
|
||||
void EnterFullscreenModeForTab(content::WebContents* source,
|
||||
const GURL& origin) override;
|
||||
void ExitFullscreenModeForTab(content::WebContents* source) override;
|
||||
void RendererUnresponsive(content::WebContents* source) override;
|
||||
void RendererUnresponsive(
|
||||
content::WebContents* source,
|
||||
const content::WebContentsUnresponsiveState& unresponsive_state) override;
|
||||
void RendererResponsive(content::WebContents* source) override;
|
||||
bool HandleContextMenu(const content::ContextMenuParams& params) override;
|
||||
bool OnGoToEntryOffset(int offset) override;
|
||||
@@ -269,6 +295,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
|
||||
// content::WebContentsObserver:
|
||||
void BeforeUnloadFired(const base::TimeTicks& proceed_time) override;
|
||||
void RenderViewCreated(content::RenderViewHost*) override;
|
||||
void RenderViewDeleted(content::RenderViewHost*) override;
|
||||
void RenderProcessGone(base::TerminationStatus status) override;
|
||||
void DocumentLoadedInFrame(
|
||||
@@ -285,8 +312,9 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
void DidGetResourceResponseStart(
|
||||
const content::ResourceRequestDetails& details) override;
|
||||
void DidGetRedirectForResourceRequest(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const content::ResourceRedirectDetails& details) override;
|
||||
void DidStartNavigation(
|
||||
content::NavigationHandle* navigation_handle) override;
|
||||
void DidFinishNavigation(
|
||||
content::NavigationHandle* navigation_handle) override;
|
||||
bool OnMessageReceived(const IPC::Message& message) override;
|
||||
@@ -298,10 +326,17 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
const std::vector<content::FaviconURL>& urls) override;
|
||||
void PluginCrashed(const base::FilePath& plugin_path,
|
||||
base::ProcessId plugin_pid) override;
|
||||
void MediaStartedPlaying(const MediaPlayerId& id) override;
|
||||
void MediaStoppedPlaying(const MediaPlayerId& id) override;
|
||||
void MediaStartedPlaying(const MediaPlayerInfo& video_type,
|
||||
const MediaPlayerId& id) override;
|
||||
void MediaStoppedPlaying(const MediaPlayerInfo& video_type,
|
||||
const MediaPlayerId& id) override;
|
||||
void DidChangeThemeColor(SkColor theme_color) override;
|
||||
|
||||
// content::NotificationObserver:
|
||||
void Observe(int type,
|
||||
const content::NotificationSource& source,
|
||||
const content::NotificationDetails& details) override;
|
||||
|
||||
// brightray::InspectableWebContentsDelegate:
|
||||
void DevToolsReloadPage() override;
|
||||
|
||||
@@ -311,6 +346,13 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
void DevToolsClosed() override;
|
||||
|
||||
private:
|
||||
struct LoadURLParams {
|
||||
LoadURLParams() : params(GURL()), id(0) {}
|
||||
|
||||
content::NavigationController::LoadURLParams params;
|
||||
int id;
|
||||
};
|
||||
|
||||
AtomBrowserContext* GetBrowserContext() const;
|
||||
|
||||
uint32_t GetNextRequestId() {
|
||||
@@ -329,6 +371,14 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
const base::ListValue& args,
|
||||
IPC::Message* message);
|
||||
|
||||
// Called when received a synchronous message from renderer to
|
||||
// set temporary zoom level.
|
||||
void OnSetTemporaryZoomLevel(double level, IPC::Message* reply_msg);
|
||||
|
||||
// Called when received a synchronous message from renderer to
|
||||
// get the zoom level.
|
||||
void OnGetZoomLevel(IPC::Message* reply_msg);
|
||||
|
||||
v8::Global<v8::Value> session_;
|
||||
v8::Global<v8::Value> devtools_web_contents_;
|
||||
v8::Global<v8::Value> debugger_;
|
||||
@@ -338,6 +388,9 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
// The host webcontents that may contain this webcontents.
|
||||
WebContents* embedder_;
|
||||
|
||||
// The zoom controller for this webContents.
|
||||
WebContentsZoomController* zoom_controller_;
|
||||
|
||||
// The type of current WebContents.
|
||||
Type type_;
|
||||
|
||||
@@ -350,6 +403,11 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
// Whether to enable devtools.
|
||||
bool enable_devtools_;
|
||||
|
||||
// Container to hold url parms for deferred load when
|
||||
// there is a pending navigation entry.
|
||||
LoadURLParams deferred_load_url_;
|
||||
content::NotificationRegistrar registrar_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(WebContents);
|
||||
};
|
||||
|
||||
|
||||
@@ -20,13 +20,14 @@ using content::BrowserThread;
|
||||
namespace mate {
|
||||
|
||||
template<>
|
||||
struct Converter<extensions::URLPattern> {
|
||||
struct Converter<URLPattern> {
|
||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
||||
extensions::URLPattern* out) {
|
||||
URLPattern* out) {
|
||||
std::string pattern;
|
||||
if (!ConvertFromV8(isolate, val, &pattern))
|
||||
return false;
|
||||
return out->Parse(pattern) == extensions::URLPattern::PARSE_SUCCESS;
|
||||
*out = URLPattern(URLPattern::SCHEME_ALL);
|
||||
return out->Parse(pattern) == URLPattern::PARSE_SUCCESS;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/web_contents_preferences.h"
|
||||
#include "atom/browser/web_contents_zoom_controller.h"
|
||||
#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"
|
||||
|
||||
@@ -24,6 +26,12 @@ void AddGuest(int guest_instance_id,
|
||||
manager->AddGuest(guest_instance_id, element_instance_id, embedder,
|
||||
guest_web_contents);
|
||||
|
||||
double zoom_factor;
|
||||
if (options.GetDouble(atom::options::kZoomFactor, &zoom_factor)) {
|
||||
atom::WebContentsZoomController::FromWebContents(guest_web_contents)
|
||||
->SetDefaultZoomFactor(zoom_factor);
|
||||
}
|
||||
|
||||
WebContentsPreferences::FromWebContents(guest_web_contents)->Merge(options);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,14 @@
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||
#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/options_switches.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "native_mate/constructor.h"
|
||||
@@ -28,6 +30,7 @@
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "atom/browser/ui/win/taskbar_host.h"
|
||||
#include "ui/base/win/shell.h"
|
||||
#endif
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
@@ -88,6 +91,13 @@ Window::Window(v8::Isolate* isolate, v8::Local<v8::Object> wrapper,
|
||||
if (options.Get("transparent", &transparent))
|
||||
web_preferences.Set("transparent", transparent);
|
||||
|
||||
// Offscreen windows are always created frameless.
|
||||
bool offscreen;
|
||||
if (web_preferences.Get("offscreen", &offscreen) && offscreen) {
|
||||
auto window_options = const_cast<mate::Dictionary&>(options);
|
||||
window_options.Set(options::kFrame, false);
|
||||
}
|
||||
|
||||
// Creates the WebContents used by BrowserWindow.
|
||||
web_contents = WebContents::Create(isolate, web_preferences);
|
||||
}
|
||||
@@ -143,7 +153,7 @@ Window::~Window() {
|
||||
|
||||
// Destroy the native window in next tick because the native code might be
|
||||
// iterating all windows.
|
||||
base::MessageLoop::current()->DeleteSoon(FROM_HERE, window_.release());
|
||||
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, window_.release());
|
||||
}
|
||||
|
||||
void Window::WillCloseWindow(bool* prevent_default) {
|
||||
@@ -176,7 +186,8 @@ void Window::OnWindowClosed() {
|
||||
RemoveFromParentChildWindows();
|
||||
|
||||
// Destroy the native class when window is closed.
|
||||
base::MessageLoop::current()->PostTask(FROM_HERE, GetDestroyClosure());
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE, GetDestroyClosure());
|
||||
}
|
||||
|
||||
void Window::OnWindowBlur() {
|
||||
@@ -271,6 +282,11 @@ void Window::OnExecuteWindowsCommand(const std::string& command_name) {
|
||||
Emit("app-command", command_name);
|
||||
}
|
||||
|
||||
void Window::OnTouchBarItemResult(const std::string& item_id,
|
||||
const base::DictionaryValue& details) {
|
||||
Emit("-touch-bar-interaction", item_id, details);
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
void Window::OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) {
|
||||
if (IsWindowMessageHooked(message)) {
|
||||
@@ -501,8 +517,17 @@ bool Window::IsClosable() {
|
||||
|
||||
void Window::SetAlwaysOnTop(bool top, mate::Arguments* args) {
|
||||
std::string level = "floating";
|
||||
int relativeLevel = 0;
|
||||
std::string error;
|
||||
|
||||
args->GetNext(&level);
|
||||
window_->SetAlwaysOnTop(top, level);
|
||||
args->GetNext(&relativeLevel);
|
||||
|
||||
window_->SetAlwaysOnTop(top, level, relativeLevel, &error);
|
||||
|
||||
if (!error.empty()) {
|
||||
args->ThrowError(error);
|
||||
}
|
||||
}
|
||||
|
||||
bool Window::IsAlwaysOnTop() {
|
||||
@@ -708,6 +733,25 @@ bool Window::SetThumbnailToolTip(const std::string& tooltip) {
|
||||
return window->taskbar_host().SetThumbnailToolTip(
|
||||
window_->GetAcceleratedWidget(), tooltip);
|
||||
}
|
||||
|
||||
void Window::SetAppDetails(const mate::Dictionary& options) {
|
||||
base::string16 app_id;
|
||||
base::FilePath app_icon_path;
|
||||
int app_icon_index = 0;
|
||||
base::string16 relaunch_command;
|
||||
base::string16 relaunch_display_name;
|
||||
|
||||
options.Get("appId", &app_id);
|
||||
options.Get("appIconPath", &app_icon_path);
|
||||
options.Get("appIconIndex", &app_icon_index);
|
||||
options.Get("relaunchCommand", &relaunch_command);
|
||||
options.Get("relaunchDisplayName", &relaunch_display_name);
|
||||
|
||||
ui::win::SetAppDetailsForWindow(
|
||||
app_id, app_icon_path, app_icon_index,
|
||||
relaunch_command, relaunch_display_name,
|
||||
window_->GetAcceleratedWidget());
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
@@ -729,6 +773,17 @@ void Window::SetAspectRatio(double aspect_ratio, mate::Arguments* args) {
|
||||
window_->SetAspectRatio(aspect_ratio, extra_size);
|
||||
}
|
||||
|
||||
void Window::PreviewFile(const std::string& path, mate::Arguments* args) {
|
||||
std::string display_name;
|
||||
if (!args->GetNext(&display_name))
|
||||
display_name = path;
|
||||
window_->PreviewFile(path, display_name);
|
||||
}
|
||||
|
||||
void Window::CloseFilePreview() {
|
||||
window_->CloseFilePreview();
|
||||
}
|
||||
|
||||
void Window::SetParentWindow(v8::Local<v8::Value> value,
|
||||
mate::Arguments* args) {
|
||||
if (IsModal()) {
|
||||
@@ -779,6 +834,25 @@ bool Window::IsVisibleOnAllWorkspaces() {
|
||||
return window_->IsVisibleOnAllWorkspaces();
|
||||
}
|
||||
|
||||
void Window::SetAutoHideCursor(bool auto_hide) {
|
||||
window_->SetAutoHideCursor(auto_hide);
|
||||
}
|
||||
|
||||
void Window::SetVibrancy(mate::Arguments* args) {
|
||||
std::string type;
|
||||
|
||||
args->GetNext(&type);
|
||||
window_->SetVibrancy(type);
|
||||
}
|
||||
|
||||
void Window::SetTouchBar(const std::vector<mate::PersistentDictionary>& items) {
|
||||
window_->SetTouchBar(items);
|
||||
}
|
||||
|
||||
void Window::RefreshTouchBarItem(const std::string& item_id) {
|
||||
window_->RefreshTouchBarItem(item_id);
|
||||
}
|
||||
|
||||
int32_t Window::ID() const {
|
||||
return weak_map_id();
|
||||
}
|
||||
@@ -825,6 +899,8 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("setFullScreen", &Window::SetFullScreen)
|
||||
.SetMethod("isFullScreen", &Window::IsFullscreen)
|
||||
.SetMethod("setAspectRatio", &Window::SetAspectRatio)
|
||||
.SetMethod("previewFile", &Window::PreviewFile)
|
||||
.SetMethod("closeFilePreview", &Window::CloseFilePreview)
|
||||
#if !defined(OS_WIN)
|
||||
.SetMethod("setParentWindow", &Window::SetParentWindow)
|
||||
#endif
|
||||
@@ -893,6 +969,12 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
||||
&Window::SetVisibleOnAllWorkspaces)
|
||||
.SetMethod("isVisibleOnAllWorkspaces",
|
||||
&Window::IsVisibleOnAllWorkspaces)
|
||||
#if defined(OS_MACOSX)
|
||||
.SetMethod("setAutoHideCursor", &Window::SetAutoHideCursor)
|
||||
#endif
|
||||
.SetMethod("setVibrancy", &Window::SetVibrancy)
|
||||
.SetMethod("_setTouchBarItems", &Window::SetTouchBar)
|
||||
.SetMethod("_refreshTouchBarItem", &Window::RefreshTouchBarItem)
|
||||
#if defined(OS_WIN)
|
||||
.SetMethod("hookWindowMessage", &Window::HookWindowMessage)
|
||||
.SetMethod("isWindowMessageHooked", &Window::IsWindowMessageHooked)
|
||||
@@ -900,6 +982,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("unhookAllWindowMessages", &Window::UnhookAllWindowMessages)
|
||||
.SetMethod("setThumbnailClip", &Window::SetThumbnailClip)
|
||||
.SetMethod("setThumbnailToolTip", &Window::SetThumbnailToolTip)
|
||||
.SetMethod("setAppDetails", &Window::SetAppDetails)
|
||||
#endif
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
.SetMethod("setIcon", &Window::SetIcon)
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "atom/common/api/atom_api_native_image.h"
|
||||
#include "atom/common/key_weak_map.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "native_mate/persistent_dictionary.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
|
||||
class GURL;
|
||||
@@ -51,6 +52,8 @@ class Window : public mate::TrackableObject<Window>,
|
||||
|
||||
NativeWindow* window() const { return window_.get(); }
|
||||
|
||||
int32_t ID() const;
|
||||
|
||||
protected:
|
||||
Window(v8::Isolate* isolate, v8::Local<v8::Object> wrapper,
|
||||
const mate::Dictionary& options);
|
||||
@@ -83,6 +86,8 @@ class Window : public mate::TrackableObject<Window>,
|
||||
void OnRendererUnresponsive() override;
|
||||
void OnRendererResponsive() override;
|
||||
void OnExecuteWindowsCommand(const std::string& command_name) override;
|
||||
void OnTouchBarItemResult(const std::string& item_id,
|
||||
const base::DictionaryValue& details) override;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
void OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) override;
|
||||
@@ -170,6 +175,8 @@ class Window : public mate::TrackableObject<Window>,
|
||||
void SetMenuBarVisibility(bool visible);
|
||||
bool IsMenuBarVisible();
|
||||
void SetAspectRatio(double aspect_ratio, mate::Arguments* args);
|
||||
void PreviewFile(const std::string& path, mate::Arguments* args);
|
||||
void CloseFilePreview();
|
||||
void SetParentWindow(v8::Local<v8::Value> value, mate::Arguments* args);
|
||||
v8::Local<v8::Value> GetParentWindow() const;
|
||||
std::vector<v8::Local<v8::Object>> GetChildWindows() const;
|
||||
@@ -186,6 +193,7 @@ class Window : public mate::TrackableObject<Window>,
|
||||
void UnhookAllWindowMessages();
|
||||
bool SetThumbnailClip(const gfx::Rect& region);
|
||||
bool SetThumbnailToolTip(const std::string& tooltip);
|
||||
void SetAppDetails(const mate::Dictionary& options);
|
||||
#endif
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
@@ -195,7 +203,12 @@ class Window : public mate::TrackableObject<Window>,
|
||||
void SetVisibleOnAllWorkspaces(bool visible);
|
||||
bool IsVisibleOnAllWorkspaces();
|
||||
|
||||
int32_t ID() const;
|
||||
void SetAutoHideCursor(bool auto_hide);
|
||||
|
||||
void SetVibrancy(mate::Arguments* args);
|
||||
void SetTouchBar(const std::vector<mate::PersistentDictionary>& items);
|
||||
void RefreshTouchBarItem(const std::string& item_id);
|
||||
|
||||
v8::Local<v8::Value> WebContents(v8::Isolate* isolate);
|
||||
|
||||
// Remove this window from parent window's |child_windows_|.
|
||||
|
||||
@@ -65,6 +65,12 @@ class TrackableObject : public TrackableObjectBase,
|
||||
Wrappable<T>::GetWrapper()->SetAlignedPointerInInternalField(0, nullptr);
|
||||
}
|
||||
|
||||
bool IsDestroyed() {
|
||||
v8::Local<v8::Object> wrapper = Wrappable<T>::GetWrapper();
|
||||
return wrapper->InternalFieldCount() == 0 ||
|
||||
wrapper->GetAlignedPointerFromInternalField(0) == nullptr;
|
||||
}
|
||||
|
||||
// Finds out the TrackableObject from its ID in weak map.
|
||||
static T* FromWeakMapID(v8::Isolate* isolate, int32_t id) {
|
||||
if (!weak_map_)
|
||||
|
||||
@@ -11,28 +11,31 @@
|
||||
#include "atom/common/google_api_key.h"
|
||||
#include "base/environment.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/geolocation_provider.h"
|
||||
#include "device/geolocation/geolocation_provider.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
namespace internal {
|
||||
|
||||
// Loads access tokens and other necessary data on the UI thread, and
|
||||
// calls back to the originator on the originating thread.
|
||||
class TokenLoadingJob : public base::RefCountedThreadSafe<TokenLoadingJob> {
|
||||
public:
|
||||
explicit TokenLoadingJob(
|
||||
const content::AccessTokenStore::LoadAccessTokensCallback& callback)
|
||||
const device::AccessTokenStore::LoadAccessTokensCallback& callback)
|
||||
: callback_(callback), request_context_getter_(nullptr) {}
|
||||
|
||||
void Run() {
|
||||
BrowserThread::PostTaskAndReply(
|
||||
BrowserThread::UI,
|
||||
FROM_HERE,
|
||||
base::Bind(&TokenLoadingJob::PerformWorkOnUIThread, this),
|
||||
base::Bind(&TokenLoadingJob::RespondOnOriginatingThread, this));
|
||||
void Run(AtomBrowserContext* browser_context) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
request_context_getter_ = browser_context->GetRequestContext();
|
||||
std::unique_ptr<base::Environment> env(base::Environment::Create());
|
||||
if (!env->GetVar("GOOGLE_API_KEY", &api_key_))
|
||||
api_key_ = GOOGLEAPIS_API_KEY;
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(&TokenLoadingJob::RespondOnIOThread, this));
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -40,20 +43,11 @@ class TokenLoadingJob : public base::RefCountedThreadSafe<TokenLoadingJob> {
|
||||
|
||||
~TokenLoadingJob() {}
|
||||
|
||||
void PerformWorkOnUIThread() {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
auto browser_context = AtomBrowserContext::From("", false);
|
||||
request_context_getter_ = browser_context->GetRequestContext();
|
||||
std::unique_ptr<base::Environment> env(base::Environment::Create());
|
||||
if (!env->GetVar("GOOGLE_API_KEY", &api_key_))
|
||||
api_key_ = GOOGLEAPIS_API_KEY;
|
||||
}
|
||||
|
||||
void RespondOnOriginatingThread() {
|
||||
void RespondOnIOThread() {
|
||||
// Equivalent to access_token_map[kGeolocationProviderURL].
|
||||
// Somehow base::string16 is causing compilation errors when used in a pair
|
||||
// of std::map on Linux, this can work around it.
|
||||
content::AccessTokenStore::AccessTokenMap access_token_map;
|
||||
device::AccessTokenStore::AccessTokenMap access_token_map;
|
||||
std::pair<GURL, base::string16> token_pair;
|
||||
token_pair.first = GURL(GOOGLEAPIS_ENDPOINT + api_key_);
|
||||
access_token_map.insert(token_pair);
|
||||
@@ -61,15 +55,16 @@ class TokenLoadingJob : public base::RefCountedThreadSafe<TokenLoadingJob> {
|
||||
callback_.Run(access_token_map, request_context_getter_);
|
||||
}
|
||||
|
||||
content::AccessTokenStore::LoadAccessTokensCallback callback_;
|
||||
device::AccessTokenStore::LoadAccessTokensCallback callback_;
|
||||
net::URLRequestContextGetter* request_context_getter_;
|
||||
std::string api_key_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace internal
|
||||
|
||||
AtomAccessTokenStore::AtomAccessTokenStore() {
|
||||
content::GeolocationProvider::GetInstance()->UserDidOptIntoLocationServices();
|
||||
browser_context_ = AtomBrowserContext::From("", false);
|
||||
device::GeolocationProvider::GetInstance()->UserDidOptIntoLocationServices();
|
||||
}
|
||||
|
||||
AtomAccessTokenStore::~AtomAccessTokenStore() {
|
||||
@@ -77,8 +72,16 @@ AtomAccessTokenStore::~AtomAccessTokenStore() {
|
||||
|
||||
void AtomAccessTokenStore::LoadAccessTokens(
|
||||
const LoadAccessTokensCallback& callback) {
|
||||
scoped_refptr<TokenLoadingJob> job(new TokenLoadingJob(callback));
|
||||
job->Run();
|
||||
scoped_refptr<internal::TokenLoadingJob> job(
|
||||
new internal::TokenLoadingJob(callback));
|
||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(&AtomAccessTokenStore::RunTokenLoadingJob,
|
||||
this, base::RetainedRef(job)));
|
||||
}
|
||||
|
||||
void AtomAccessTokenStore::RunTokenLoadingJob(
|
||||
scoped_refptr<internal::TokenLoadingJob> job) {
|
||||
job->Run(browser_context_.get());
|
||||
}
|
||||
|
||||
void AtomAccessTokenStore::SaveAccessToken(const GURL& server_url,
|
||||
|
||||
@@ -5,22 +5,31 @@
|
||||
#ifndef ATOM_BROWSER_ATOM_ACCESS_TOKEN_STORE_H_
|
||||
#define ATOM_BROWSER_ATOM_ACCESS_TOKEN_STORE_H_
|
||||
|
||||
#include "content/public/browser/access_token_store.h"
|
||||
#include "device/geolocation/access_token_store.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class AtomAccessTokenStore : public content::AccessTokenStore {
|
||||
class AtomBrowserContext;
|
||||
|
||||
namespace internal {
|
||||
class TokenLoadingJob;
|
||||
}
|
||||
|
||||
class AtomAccessTokenStore : public device::AccessTokenStore {
|
||||
public:
|
||||
AtomAccessTokenStore();
|
||||
~AtomAccessTokenStore();
|
||||
|
||||
// content::AccessTokenStore:
|
||||
// device::AccessTokenStore:
|
||||
void LoadAccessTokens(
|
||||
const LoadAccessTokensCallback& callback) override;
|
||||
void SaveAccessToken(const GURL& server_url,
|
||||
const base::string16& access_token) override;
|
||||
|
||||
private:
|
||||
void RunTokenLoadingJob(scoped_refptr<internal::TokenLoadingJob> job);
|
||||
|
||||
scoped_refptr<AtomBrowserContext> browser_context_;
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomAccessTokenStore);
|
||||
};
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ void AtomBlobReader::StartReading(
|
||||
|
||||
auto blob_reader = blob_data_handle->CreateReader(
|
||||
file_system_context_.get(),
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get());
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get());
|
||||
BlobReadHelper* blob_read_helper =
|
||||
new BlobReadHelper(std::move(blob_reader), callback);
|
||||
blob_read_helper->Read();
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "atom/browser/api/atom_api_app.h"
|
||||
#include "atom/browser/api/atom_api_protocol.h"
|
||||
#include "atom/browser/atom_access_token_store.h"
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
#include "atom/browser/atom_quota_permission_context.h"
|
||||
@@ -30,9 +29,9 @@
|
||||
#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/geolocation_delegate.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/resource_dispatcher_host.h"
|
||||
@@ -55,19 +54,6 @@ bool g_suppress_renderer_process_restart = false;
|
||||
// Custom schemes to be registered to handle service worker.
|
||||
std::string g_custom_service_worker_schemes = "";
|
||||
|
||||
// A provider of Geolocation services to override AccessTokenStore.
|
||||
class AtomGeolocationDelegate : public content::GeolocationDelegate {
|
||||
public:
|
||||
AtomGeolocationDelegate() = default;
|
||||
|
||||
content::AccessTokenStore* CreateAccessTokenStore() final {
|
||||
return new AtomAccessTokenStore();
|
||||
}
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomGeolocationDelegate);
|
||||
};
|
||||
|
||||
void Noop(scoped_refptr<content::SiteInstance>) {
|
||||
}
|
||||
|
||||
@@ -92,7 +78,7 @@ AtomBrowserClient::~AtomBrowserClient() {
|
||||
content::WebContents* AtomBrowserClient::GetWebContentsFromProcessID(
|
||||
int process_id) {
|
||||
// If the process is a pending process, we should use the old one.
|
||||
if (ContainsKey(pending_processes_, process_id))
|
||||
if (base::ContainsKey(pending_processes_, process_id))
|
||||
process_id = pending_processes_[process_id];
|
||||
|
||||
// Certain render process will be created with no associated render view,
|
||||
@@ -159,11 +145,6 @@ content::SpeechRecognitionManagerDelegate*
|
||||
return new AtomSpeechRecognitionManagerDelegate;
|
||||
}
|
||||
|
||||
content::GeolocationDelegate*
|
||||
AtomBrowserClient::CreateGeolocationDelegate() {
|
||||
return new AtomGeolocationDelegate();
|
||||
}
|
||||
|
||||
void AtomBrowserClient::OverrideWebkitPrefs(
|
||||
content::RenderViewHost* host, content::WebPreferences* prefs) {
|
||||
prefs->javascript_enabled = true;
|
||||
@@ -179,7 +160,6 @@ void AtomBrowserClient::OverrideWebkitPrefs(
|
||||
prefs->allow_universal_access_from_file_urls = true;
|
||||
prefs->allow_file_access_from_file_urls = true;
|
||||
prefs->experimental_webgl_enabled = true;
|
||||
prefs->allow_displaying_insecure_content = false;
|
||||
prefs->allow_running_insecure_content = false;
|
||||
|
||||
// Custom preferences of guest page.
|
||||
@@ -233,7 +213,8 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
||||
// Copy following switches to child process.
|
||||
static const char* const kCommonSwitchNames[] = {
|
||||
switches::kStandardSchemes,
|
||||
switches::kEnableSandbox
|
||||
switches::kEnableSandbox,
|
||||
switches::kSecureSchemes
|
||||
};
|
||||
command_line->CopySwitchesFrom(
|
||||
*base::CommandLine::ForCurrentProcess(),
|
||||
@@ -281,13 +262,13 @@ void AtomBrowserClient::AllowCertificateError(
|
||||
bool overridable,
|
||||
bool strict_enforcement,
|
||||
bool expired_previous_decision,
|
||||
const base::Callback<void(bool)>& callback,
|
||||
content::CertificateRequestResultType* request) {
|
||||
const base::Callback<void(content::CertificateRequestResultType)>&
|
||||
callback) {
|
||||
if (delegate_) {
|
||||
delegate_->AllowCertificateError(
|
||||
web_contents, cert_error, ssl_info, request_url,
|
||||
resource_type, overridable, strict_enforcement,
|
||||
expired_previous_decision, callback, request);
|
||||
expired_previous_decision, callback);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,12 +294,13 @@ bool AtomBrowserClient::CanCreateWindow(
|
||||
const GURL& opener_top_level_frame_url,
|
||||
const GURL& source_origin,
|
||||
WindowContainerType container_type,
|
||||
const std::string& frame_name,
|
||||
const GURL& target_url,
|
||||
const content::Referrer& referrer,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::WebWindowFeatures& features,
|
||||
const std::vector<base::string16>& additional_features,
|
||||
const std::vector<std::string>& additional_features,
|
||||
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
|
||||
bool user_gesture,
|
||||
bool opener_suppressed,
|
||||
content::ResourceContext* context,
|
||||
@@ -341,6 +323,7 @@ bool AtomBrowserClient::CanCreateWindow(
|
||||
frame_name,
|
||||
disposition,
|
||||
additional_features,
|
||||
body,
|
||||
render_process_id,
|
||||
opener_render_frame_id));
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
void RenderProcessWillLaunch(content::RenderProcessHost* host) override;
|
||||
content::SpeechRecognitionManagerDelegate*
|
||||
CreateSpeechRecognitionManagerDelegate() override;
|
||||
content::GeolocationDelegate* CreateGeolocationDelegate() override;
|
||||
void OverrideWebkitPrefs(content::RenderViewHost* render_view_host,
|
||||
content::WebPreferences* prefs) override;
|
||||
std::string GetApplicationLocale() override;
|
||||
@@ -72,30 +71,32 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
bool overridable,
|
||||
bool strict_enforcement,
|
||||
bool expired_previous_decision,
|
||||
const base::Callback<void(bool)>& callback,
|
||||
content::CertificateRequestResultType* request) override;
|
||||
const base::Callback<void(content::CertificateRequestResultType)>&
|
||||
callback) override;
|
||||
void SelectClientCertificate(
|
||||
content::WebContents* web_contents,
|
||||
net::SSLCertRequestInfo* cert_request_info,
|
||||
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
|
||||
void ResourceDispatcherHostCreated() override;
|
||||
bool CanCreateWindow(const GURL& opener_url,
|
||||
const GURL& opener_top_level_frame_url,
|
||||
const GURL& source_origin,
|
||||
WindowContainerType container_type,
|
||||
const std::string& frame_name,
|
||||
const GURL& target_url,
|
||||
const content::Referrer& referrer,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::WebWindowFeatures& features,
|
||||
const std::vector<base::string16>& additional_features,
|
||||
bool user_gesture,
|
||||
bool opener_suppressed,
|
||||
content::ResourceContext* context,
|
||||
int render_process_id,
|
||||
int opener_render_view_id,
|
||||
int opener_render_frame_id,
|
||||
bool* no_javascript_access) override;
|
||||
bool CanCreateWindow(
|
||||
const GURL& opener_url,
|
||||
const GURL& opener_top_level_frame_url,
|
||||
const GURL& source_origin,
|
||||
WindowContainerType container_type,
|
||||
const GURL& target_url,
|
||||
const content::Referrer& referrer,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::WebWindowFeatures& features,
|
||||
const std::vector<std::string>& additional_features,
|
||||
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
|
||||
bool user_gesture,
|
||||
bool opener_suppressed,
|
||||
content::ResourceContext* context,
|
||||
int render_process_id,
|
||||
int opener_render_view_id,
|
||||
int opener_render_frame_id,
|
||||
bool* no_javascript_access) override;
|
||||
void GetAdditionalAllowedSchemesForFileSystem(
|
||||
std::vector<std::string>* schemes) override;
|
||||
|
||||
|
||||
@@ -10,10 +10,11 @@
|
||||
#include "atom/browser/atom_download_manager_delegate.h"
|
||||
#include "atom/browser/atom_permission_manager.h"
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/browser/net/about_protocol_handler.h"
|
||||
#include "atom/browser/net/asar/asar_protocol_handler.h"
|
||||
#include "atom/browser/net/atom_cert_verifier.h"
|
||||
#include "atom/browser/net/atom_ct_delegate.h"
|
||||
#include "atom/browser/net/atom_network_delegate.h"
|
||||
#include "atom/browser/net/atom_ssl_config_service.h"
|
||||
#include "atom/browser/net/atom_url_request_job_factory.h"
|
||||
#include "atom/browser/net/http_protocol_handler.h"
|
||||
#include "atom/browser/web_view_manager.h"
|
||||
@@ -67,10 +68,11 @@ std::string RemoveWhitespace(const std::string& str) {
|
||||
|
||||
} // namespace
|
||||
|
||||
AtomBrowserContext::AtomBrowserContext(
|
||||
const std::string& partition, bool in_memory,
|
||||
const base::DictionaryValue& options)
|
||||
AtomBrowserContext::AtomBrowserContext(const std::string& partition,
|
||||
bool in_memory,
|
||||
const base::DictionaryValue& options)
|
||||
: brightray::BrowserContext(partition, in_memory),
|
||||
ct_delegate_(new AtomCTDelegate),
|
||||
network_delegate_(new AtomNetworkDelegate),
|
||||
cookie_delegate_(new AtomCookieDelegate) {
|
||||
// Construct user agent string.
|
||||
@@ -128,6 +130,8 @@ AtomBrowserContext::CreateURLRequestJobFactory(
|
||||
}
|
||||
protocol_handlers->clear();
|
||||
|
||||
job_factory->SetProtocolHandler(url::kAboutScheme,
|
||||
base::WrapUnique(new AboutProtocolHandler));
|
||||
job_factory->SetProtocolHandler(
|
||||
url::kDataScheme, base::WrapUnique(new net::DataProtocolHandler));
|
||||
job_factory->SetProtocolHandler(
|
||||
@@ -151,8 +155,7 @@ AtomBrowserContext::CreateURLRequestJobFactory(
|
||||
url_request_context_getter()->GetURLRequestContext()->host_resolver();
|
||||
job_factory->SetProtocolHandler(
|
||||
url::kFtpScheme,
|
||||
base::WrapUnique(new net::FtpProtocolHandler(
|
||||
new net::FtpNetworkLayer(host_resolver))));
|
||||
net::FtpProtocolHandler::Create(host_resolver));
|
||||
|
||||
return std::move(job_factory);
|
||||
}
|
||||
@@ -190,11 +193,7 @@ content::PermissionManager* AtomBrowserContext::GetPermissionManager() {
|
||||
}
|
||||
|
||||
std::unique_ptr<net::CertVerifier> AtomBrowserContext::CreateCertVerifier() {
|
||||
return base::WrapUnique(new AtomCertVerifier);
|
||||
}
|
||||
|
||||
net::SSLConfigService* AtomBrowserContext::CreateSSLConfigService() {
|
||||
return new AtomSSLConfigService;
|
||||
return base::WrapUnique(new AtomCertVerifier(ct_delegate_.get()));
|
||||
}
|
||||
|
||||
std::vector<std::string> AtomBrowserContext::GetCookieableSchemes() {
|
||||
@@ -205,6 +204,11 @@ std::vector<std::string> AtomBrowserContext::GetCookieableSchemes() {
|
||||
return default_schemes;
|
||||
}
|
||||
|
||||
net::TransportSecurityState::RequireCTDelegate*
|
||||
AtomBrowserContext::GetRequireCTDelegate() {
|
||||
return ct_delegate_.get();
|
||||
}
|
||||
|
||||
void AtomBrowserContext::RegisterPrefs(PrefRegistrySimple* pref_registry) {
|
||||
pref_registry->RegisterFilePathPref(prefs::kSelectFileLastDirectory,
|
||||
base::FilePath());
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
namespace atom {
|
||||
|
||||
class AtomBlobReader;
|
||||
class AtomCTDelegate;
|
||||
class AtomDownloadManagerDelegate;
|
||||
class AtomNetworkDelegate;
|
||||
class AtomPermissionManager;
|
||||
@@ -40,8 +41,9 @@ class AtomBrowserContext : public brightray::BrowserContext {
|
||||
net::HttpCache::BackendFactory* CreateHttpCacheBackendFactory(
|
||||
const base::FilePath& base_path) override;
|
||||
std::unique_ptr<net::CertVerifier> CreateCertVerifier() override;
|
||||
net::SSLConfigService* CreateSSLConfigService() override;
|
||||
std::vector<std::string> GetCookieableSchemes() override;
|
||||
net::TransportSecurityState::RequireCTDelegate* GetRequireCTDelegate()
|
||||
override;
|
||||
|
||||
// content::BrowserContext:
|
||||
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
|
||||
@@ -67,6 +69,7 @@ class AtomBrowserContext : public brightray::BrowserContext {
|
||||
std::unique_ptr<WebViewManager> guest_manager_;
|
||||
std::unique_ptr<AtomPermissionManager> permission_manager_;
|
||||
std::unique_ptr<AtomBlobReader> blob_reader_;
|
||||
std::unique_ptr<AtomCTDelegate> ct_delegate_;
|
||||
std::string user_agent_;
|
||||
bool use_cache_;
|
||||
|
||||
|
||||
@@ -5,33 +5,55 @@
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
|
||||
#include "atom/browser/api/trackable_object.h"
|
||||
#include "atom/browser/atom_access_token_store.h"
|
||||
#include "atom/browser/atom_browser_client.h"
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/atom_web_ui_controller_factory.h"
|
||||
#include "atom/browser/bridge_task_runner.h"
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/browser/javascript_environment.h"
|
||||
#include "atom/browser/node_debugger.h"
|
||||
#include "atom/common/api/atom_bindings.h"
|
||||
#include "atom/common/asar/asar_util.h"
|
||||
#include "atom/common/node_bindings.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "content/public/browser/child_process_security_policy.h"
|
||||
#include "device/geolocation/geolocation_delegate.h"
|
||||
#include "device/geolocation/geolocation_provider.h"
|
||||
#include "v8/include/v8-debug.h"
|
||||
|
||||
#if defined(USE_X11)
|
||||
#include "chrome/browser/ui/libgtk2ui/gtk2_util.h"
|
||||
#include "chrome/browser/ui/libgtkui/gtk_util.h"
|
||||
#include "ui/events/devices/x11/touch_factory_x11.h"
|
||||
#endif
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
// A provider of Geolocation services to override AccessTokenStore.
|
||||
class AtomGeolocationDelegate : public device::GeolocationDelegate {
|
||||
public:
|
||||
AtomGeolocationDelegate() = default;
|
||||
|
||||
scoped_refptr<device::AccessTokenStore> CreateAccessTokenStore() final {
|
||||
return new AtomAccessTokenStore();
|
||||
}
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomGeolocationDelegate);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
void Erase(T* container, typename T::iterator iter) {
|
||||
container->erase(iter);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
AtomBrowserMainParts* AtomBrowserMainParts::self_ = nullptr;
|
||||
|
||||
@@ -39,8 +61,8 @@ AtomBrowserMainParts::AtomBrowserMainParts()
|
||||
: fake_browser_process_(new BrowserProcess),
|
||||
exit_code_(nullptr),
|
||||
browser_(new Browser),
|
||||
node_bindings_(NodeBindings::Create(true)),
|
||||
atom_bindings_(new AtomBindings),
|
||||
node_bindings_(NodeBindings::Create(NodeBindings::BROWSER)),
|
||||
atom_bindings_(new AtomBindings(uv_default_loop())),
|
||||
gc_timer_(true, true) {
|
||||
DCHECK(!self_) << "Cannot have two AtomBrowserMainParts";
|
||||
self_ = this;
|
||||
@@ -50,6 +72,7 @@ AtomBrowserMainParts::AtomBrowserMainParts()
|
||||
}
|
||||
|
||||
AtomBrowserMainParts::~AtomBrowserMainParts() {
|
||||
asar::ClearArchives();
|
||||
// Leak the JavascriptEnvironment on exit.
|
||||
// This is to work around the bug that V8 would be waiting for background
|
||||
// tasks to finish on exit, while somehow it waits forever in Electron, more
|
||||
@@ -112,10 +135,11 @@ void AtomBrowserMainParts::PostEarlyInitialization() {
|
||||
// Create the global environment.
|
||||
node::Environment* env =
|
||||
node_bindings_->CreateEnvironment(js_env_->context());
|
||||
node_env_.reset(new NodeEnvironment(env));
|
||||
|
||||
// Make sure node can get correct environment when debugging.
|
||||
if (node_debugger_->IsRunning())
|
||||
env->AssignToContext(v8::Debug::GetDebugContext());
|
||||
env->AssignToContext(v8::Debug::GetDebugContext(js_env_->isolate()));
|
||||
|
||||
// Add Electron extended APIs.
|
||||
atom_bindings_->BindTo(js_env_->isolate(), env->process_object());
|
||||
@@ -145,12 +169,15 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() {
|
||||
base::Bind(&v8::Isolate::LowMemoryNotification,
|
||||
base::Unretained(js_env_->isolate())));
|
||||
|
||||
content::WebUIControllerFactory::RegisterFactory(
|
||||
AtomWebUIControllerFactory::GetInstance());
|
||||
|
||||
brightray::BrowserMainParts::PreMainMessageLoopRun();
|
||||
bridge_task_runner_->MessageLoopIsReady();
|
||||
bridge_task_runner_ = nullptr;
|
||||
|
||||
#if defined(USE_X11)
|
||||
libgtk2ui::GtkInitFromCommandLine(*base::CommandLine::ForCurrentProcess());
|
||||
libgtkui::GtkInitFromCommandLine(*base::CommandLine::ForCurrentProcess());
|
||||
#endif
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
@@ -171,6 +198,8 @@ void AtomBrowserMainParts::PostMainMessageLoopStart() {
|
||||
#if defined(OS_POSIX)
|
||||
HandleShutdownSignals();
|
||||
#endif
|
||||
device::GeolocationProvider::SetGeolocationDelegate(
|
||||
new AtomGeolocationDelegate());
|
||||
}
|
||||
|
||||
void AtomBrowserMainParts::PostMainMessageLoopRun() {
|
||||
|
||||
@@ -22,6 +22,7 @@ class Browser;
|
||||
class JavascriptEnvironment;
|
||||
class NodeBindings;
|
||||
class NodeDebugger;
|
||||
class NodeEnvironment;
|
||||
class BridgeTaskRunner;
|
||||
|
||||
class AtomBrowserMainParts : public brightray::BrowserMainParts {
|
||||
@@ -81,6 +82,7 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
|
||||
std::unique_ptr<JavascriptEnvironment> js_env_;
|
||||
std::unique_ptr<NodeBindings> node_bindings_;
|
||||
std::unique_ptr<AtomBindings> atom_bindings_;
|
||||
std::unique_ptr<NodeEnvironment> node_env_;
|
||||
std::unique_ptr<NodeDebugger> node_debugger_;
|
||||
|
||||
base::Timer gc_timer_;
|
||||
|
||||
@@ -90,10 +90,11 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated(
|
||||
base::FilePath path;
|
||||
GetItemSavePath(item, &path);
|
||||
// Show save dialog if save path was not set already on item
|
||||
if (path.empty() && file_dialog::ShowSaveDialog(window, item->GetURL().spec(),
|
||||
"", default_path,
|
||||
file_dialog::Filters(),
|
||||
&path)) {
|
||||
file_dialog::DialogSettings settings;
|
||||
settings.parent_window = window;
|
||||
settings.title = item->GetURL().spec();
|
||||
settings.default_path = default_path;
|
||||
if (path.empty() && file_dialog::ShowSaveDialog(settings, &path)) {
|
||||
// Remember the last selected download directory.
|
||||
AtomBrowserContext* browser_context = static_cast<AtomBrowserContext*>(
|
||||
download_manager_->GetBrowserContext());
|
||||
|
||||
@@ -5,20 +5,44 @@
|
||||
#include "atom/browser/atom_javascript_dialog_manager.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/ui/message_box.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
|
||||
using content::JavaScriptMessageType;
|
||||
|
||||
namespace atom {
|
||||
|
||||
void AtomJavaScriptDialogManager::RunJavaScriptDialog(
|
||||
content::WebContents* web_contents,
|
||||
const GURL& origin_url,
|
||||
content::JavaScriptMessageType javascript_message_type,
|
||||
JavaScriptMessageType message_type,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
const DialogClosedCallback& callback,
|
||||
bool* did_suppress_message) {
|
||||
callback.Run(false, base::string16());
|
||||
|
||||
if (message_type != JavaScriptMessageType::JAVASCRIPT_MESSAGE_TYPE_ALERT &&
|
||||
message_type != JavaScriptMessageType::JAVASCRIPT_MESSAGE_TYPE_CONFIRM) {
|
||||
callback.Run(false, base::string16());
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> buttons = {"OK"};
|
||||
if (message_type == JavaScriptMessageType::JAVASCRIPT_MESSAGE_TYPE_CONFIRM) {
|
||||
buttons.push_back("Cancel");
|
||||
}
|
||||
|
||||
atom::ShowMessageBox(NativeWindow::FromWebContents(web_contents),
|
||||
atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, -1,
|
||||
0, atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
|
||||
base::UTF16ToUTF8(message_text), "", "", false,
|
||||
gfx::ImageSkia(),
|
||||
base::Bind(&OnMessageBoxCallback, callback));
|
||||
}
|
||||
|
||||
void AtomJavaScriptDialogManager::RunBeforeUnloadDialog(
|
||||
@@ -29,4 +53,18 @@ void AtomJavaScriptDialogManager::RunBeforeUnloadDialog(
|
||||
callback.Run(false, base::ASCIIToUTF16("This should not be displayed"));
|
||||
}
|
||||
|
||||
void AtomJavaScriptDialogManager::CancelDialogs(
|
||||
content::WebContents* web_contents,
|
||||
bool suppress_callbacks,
|
||||
bool reset_state) {
|
||||
}
|
||||
|
||||
// static
|
||||
void AtomJavaScriptDialogManager::OnMessageBoxCallback(
|
||||
const DialogClosedCallback& callback,
|
||||
int code,
|
||||
bool checkbox_checked) {
|
||||
callback.Run(code == 0, base::string16());
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -26,9 +26,14 @@ class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager {
|
||||
content::WebContents* web_contents,
|
||||
bool is_reload,
|
||||
const DialogClosedCallback& callback) override;
|
||||
void CancelActiveAndPendingDialogs(
|
||||
content::WebContents* web_contents) override {}
|
||||
void ResetDialogState(content::WebContents* web_contents) override {};
|
||||
void CancelDialogs(content::WebContents* web_contents,
|
||||
bool suppress_callbacks,
|
||||
bool reset_state) override;
|
||||
|
||||
private:
|
||||
static void OnMessageBoxCallback(const DialogClosedCallback& callback,
|
||||
int code,
|
||||
bool checkbox_checked);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -26,10 +26,52 @@ bool WebContentsDestroyed(int process_id) {
|
||||
return contents->IsBeingDestroyed();
|
||||
}
|
||||
|
||||
void PermissionRequestResponseCallbackWrapper(
|
||||
const AtomPermissionManager::StatusCallback& callback,
|
||||
const std::vector<blink::mojom::PermissionStatus>& vector) {
|
||||
callback.Run(vector[0]);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
AtomPermissionManager::AtomPermissionManager()
|
||||
: request_id_(0) {
|
||||
class AtomPermissionManager::PendingRequest {
|
||||
public:
|
||||
PendingRequest(content::RenderFrameHost* render_frame_host,
|
||||
const std::vector<content::PermissionType>& permissions,
|
||||
const StatusesCallback& callback)
|
||||
: render_process_id_(render_frame_host->GetProcess()->GetID()),
|
||||
callback_(callback),
|
||||
results_(permissions.size(), blink::mojom::PermissionStatus::DENIED),
|
||||
remaining_results_(permissions.size()) {}
|
||||
|
||||
void SetPermissionStatus(int permission_id,
|
||||
blink::mojom::PermissionStatus status) {
|
||||
DCHECK(!IsComplete());
|
||||
|
||||
results_[permission_id] = status;
|
||||
--remaining_results_;
|
||||
}
|
||||
|
||||
int render_process_id() const {
|
||||
return render_process_id_;
|
||||
}
|
||||
|
||||
bool IsComplete() const {
|
||||
return remaining_results_ == 0;
|
||||
}
|
||||
|
||||
void RunCallback() const {
|
||||
callback_.Run(results_);
|
||||
}
|
||||
|
||||
private:
|
||||
int render_process_id_;
|
||||
const StatusesCallback callback_;
|
||||
std::vector<blink::mojom::PermissionStatus> results_;
|
||||
size_t remaining_results_;
|
||||
};
|
||||
|
||||
AtomPermissionManager::AtomPermissionManager() {
|
||||
}
|
||||
|
||||
AtomPermissionManager::~AtomPermissionManager() {
|
||||
@@ -37,12 +79,14 @@ AtomPermissionManager::~AtomPermissionManager() {
|
||||
|
||||
void AtomPermissionManager::SetPermissionRequestHandler(
|
||||
const RequestHandler& handler) {
|
||||
if (handler.is_null() && !pending_requests_.empty()) {
|
||||
for (const auto& request : pending_requests_) {
|
||||
if (!WebContentsDestroyed(request.second.render_process_id))
|
||||
request.second.callback.Run(blink::mojom::PermissionStatus::DENIED);
|
||||
if (handler.is_null() && !pending_requests_.IsEmpty()) {
|
||||
for (PendingRequestsMap::const_iterator iter(&pending_requests_);
|
||||
!iter.IsAtEnd(); iter.Advance()) {
|
||||
auto request = iter.GetCurrentValue();
|
||||
if (!WebContentsDestroyed(request->render_process_id()))
|
||||
request->RunCallback();
|
||||
}
|
||||
pending_requests_.clear();
|
||||
pending_requests_.Clear();
|
||||
}
|
||||
request_handler_ = handler;
|
||||
}
|
||||
@@ -51,71 +95,83 @@ int AtomPermissionManager::RequestPermission(
|
||||
content::PermissionType permission,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& requesting_origin,
|
||||
const ResponseCallback& response_callback) {
|
||||
int process_id = render_frame_host->GetProcess()->GetID();
|
||||
|
||||
if (permission == content::PermissionType::MIDI_SYSEX) {
|
||||
content::ChildProcessSecurityPolicy::GetInstance()->
|
||||
GrantSendMidiSysExMessage(process_id);
|
||||
}
|
||||
|
||||
if (!request_handler_.is_null()) {
|
||||
auto web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
++request_id_;
|
||||
auto callback = base::Bind(&AtomPermissionManager::OnPermissionResponse,
|
||||
base::Unretained(this),
|
||||
request_id_,
|
||||
requesting_origin,
|
||||
response_callback);
|
||||
pending_requests_[request_id_] = { process_id, callback };
|
||||
request_handler_.Run(web_contents, permission, callback);
|
||||
return request_id_;
|
||||
}
|
||||
|
||||
response_callback.Run(blink::mojom::PermissionStatus::GRANTED);
|
||||
return kNoPendingOperation;
|
||||
bool user_gesture,
|
||||
const StatusCallback& response_callback) {
|
||||
return RequestPermissions(
|
||||
std::vector<content::PermissionType>(1, permission),
|
||||
render_frame_host,
|
||||
requesting_origin,
|
||||
user_gesture,
|
||||
base::Bind(&PermissionRequestResponseCallbackWrapper, response_callback));
|
||||
}
|
||||
|
||||
int AtomPermissionManager::RequestPermissions(
|
||||
const std::vector<content::PermissionType>& permissions,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& requesting_origin,
|
||||
const base::Callback<void(
|
||||
const std::vector<blink::mojom::PermissionStatus>&)>& callback) {
|
||||
// FIXME(zcbenz): Just ignore multiple permissions request for now.
|
||||
std::vector<blink::mojom::PermissionStatus> permissionStatuses;
|
||||
for (auto permission : permissions) {
|
||||
bool user_gesture,
|
||||
const StatusesCallback& response_callback) {
|
||||
if (permissions.empty()) {
|
||||
response_callback.Run(std::vector<blink::mojom::PermissionStatus>());
|
||||
return kNoPendingOperation;
|
||||
}
|
||||
|
||||
if (request_handler_.is_null()) {
|
||||
std::vector<blink::mojom::PermissionStatus> statuses;
|
||||
for (auto permission : permissions) {
|
||||
if (permission == content::PermissionType::MIDI_SYSEX) {
|
||||
content::ChildProcessSecurityPolicy::GetInstance()->
|
||||
GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
|
||||
}
|
||||
statuses.push_back(blink::mojom::PermissionStatus::GRANTED);
|
||||
}
|
||||
response_callback.Run(statuses);
|
||||
return kNoPendingOperation;
|
||||
}
|
||||
|
||||
auto web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
int request_id = pending_requests_.Add(new PendingRequest(
|
||||
render_frame_host, permissions, response_callback));
|
||||
|
||||
for (size_t i = 0; i < permissions.size(); ++i) {
|
||||
auto permission = permissions[i];
|
||||
if (permission == content::PermissionType::MIDI_SYSEX) {
|
||||
content::ChildProcessSecurityPolicy::GetInstance()->
|
||||
GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
|
||||
}
|
||||
permissionStatuses.push_back(blink::mojom::PermissionStatus::GRANTED);
|
||||
const auto callback =
|
||||
base::Bind(&AtomPermissionManager::OnPermissionResponse,
|
||||
base::Unretained(this), request_id, i);
|
||||
request_handler_.Run(web_contents, permission, callback);
|
||||
}
|
||||
callback.Run(permissionStatuses);
|
||||
return kNoPendingOperation;
|
||||
|
||||
return request_id;
|
||||
}
|
||||
|
||||
void AtomPermissionManager::OnPermissionResponse(
|
||||
int request_id,
|
||||
const GURL& origin,
|
||||
const ResponseCallback& callback,
|
||||
int permission_id,
|
||||
blink::mojom::PermissionStatus status) {
|
||||
auto request = pending_requests_.find(request_id);
|
||||
if (request != pending_requests_.end()) {
|
||||
if (!WebContentsDestroyed(request->second.render_process_id))
|
||||
callback.Run(status);
|
||||
pending_requests_.erase(request);
|
||||
auto pending_request = pending_requests_.Lookup(request_id);
|
||||
if (!pending_request)
|
||||
return;
|
||||
|
||||
pending_request->SetPermissionStatus(permission_id, status);
|
||||
if (pending_request->IsComplete()) {
|
||||
pending_request->RunCallback();
|
||||
pending_requests_.Remove(request_id);
|
||||
}
|
||||
}
|
||||
|
||||
void AtomPermissionManager::CancelPermissionRequest(int request_id) {
|
||||
auto request = pending_requests_.find(request_id);
|
||||
if (request != pending_requests_.end()) {
|
||||
if (!WebContentsDestroyed(request->second.render_process_id))
|
||||
request->second.callback.Run(blink::mojom::PermissionStatus::DENIED);
|
||||
pending_requests_.erase(request);
|
||||
}
|
||||
auto pending_request = pending_requests_.Lookup(request_id);
|
||||
if (!pending_request)
|
||||
return;
|
||||
|
||||
if (!WebContentsDestroyed(pending_request->render_process_id()))
|
||||
pending_request->RunCallback();
|
||||
pending_requests_.Remove(request_id);
|
||||
}
|
||||
|
||||
void AtomPermissionManager::ResetPermission(
|
||||
@@ -141,7 +197,7 @@ int AtomPermissionManager::SubscribePermissionStatusChange(
|
||||
content::PermissionType permission,
|
||||
const GURL& requesting_origin,
|
||||
const GURL& embedding_origin,
|
||||
const ResponseCallback& callback) {
|
||||
const StatusCallback& callback) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "base/id_map.h"
|
||||
#include "content/public/browser/permission_manager.h"
|
||||
|
||||
namespace content {
|
||||
@@ -22,12 +23,14 @@ class AtomPermissionManager : public content::PermissionManager {
|
||||
AtomPermissionManager();
|
||||
~AtomPermissionManager() override;
|
||||
|
||||
using ResponseCallback =
|
||||
using StatusCallback =
|
||||
base::Callback<void(blink::mojom::PermissionStatus)>;
|
||||
using StatusesCallback =
|
||||
base::Callback<void(const std::vector<blink::mojom::PermissionStatus>&)>;
|
||||
using RequestHandler =
|
||||
base::Callback<void(content::WebContents*,
|
||||
content::PermissionType,
|
||||
const ResponseCallback&)>;
|
||||
const StatusCallback&)>;
|
||||
|
||||
// Handler to dispatch permission requests in JS.
|
||||
void SetPermissionRequestHandler(const RequestHandler& handler);
|
||||
@@ -37,18 +40,21 @@ class AtomPermissionManager : public content::PermissionManager {
|
||||
content::PermissionType permission,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& requesting_origin,
|
||||
const ResponseCallback& callback) override;
|
||||
bool user_gesture,
|
||||
const base::Callback<void(blink::mojom::PermissionStatus)>& callback)
|
||||
override;
|
||||
int RequestPermissions(
|
||||
const std::vector<content::PermissionType>& permissions,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& requesting_origin,
|
||||
bool user_gesture,
|
||||
const base::Callback<void(
|
||||
const std::vector<blink::mojom::PermissionStatus>&)>& callback) override;
|
||||
const std::vector<blink::mojom::PermissionStatus>&)>& callback)
|
||||
override;
|
||||
|
||||
protected:
|
||||
void OnPermissionResponse(int request_id,
|
||||
const GURL& url,
|
||||
const ResponseCallback& callback,
|
||||
int permission_id,
|
||||
blink::mojom::PermissionStatus status);
|
||||
|
||||
// content::PermissionManager:
|
||||
@@ -72,16 +78,12 @@ class AtomPermissionManager : public content::PermissionManager {
|
||||
void UnsubscribePermissionStatusChange(int subscription_id) override;
|
||||
|
||||
private:
|
||||
struct RequestInfo {
|
||||
int render_process_id;
|
||||
ResponseCallback callback;
|
||||
};
|
||||
class PendingRequest;
|
||||
using PendingRequestsMap = IDMap<PendingRequest, IDMapOwnPointer>;
|
||||
|
||||
RequestHandler request_handler_;
|
||||
|
||||
std::map<int, RequestInfo> pending_requests_;
|
||||
|
||||
int request_id_;
|
||||
PendingRequestsMap pending_requests_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomPermissionManager);
|
||||
};
|
||||
|
||||
@@ -6,11 +6,15 @@
|
||||
|
||||
#include "atom/browser/login_handler.h"
|
||||
#include "atom/browser/web_contents_permission_helper.h"
|
||||
#include "atom/common/atom_constants.h"
|
||||
#include "atom/common/platform_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/stream_info.h"
|
||||
#include "net/base/escape.h"
|
||||
#include "net/ssl/client_cert_store.h"
|
||||
#include "net/url_request/url_request.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
#if defined(USE_NSS_CERTS)
|
||||
@@ -57,6 +61,23 @@ void HandleExternalProtocolInUI(
|
||||
permission_helper->RequestOpenExternalPermission(callback, has_user_gesture);
|
||||
}
|
||||
|
||||
void OnPdfResourceIntercepted(
|
||||
const GURL& original_url,
|
||||
const content::ResourceRequestInfo::WebContentsGetter&
|
||||
web_contents_getter) {
|
||||
content::WebContents* web_contents = web_contents_getter.Run();
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
// The URL passes the original pdf resource url, that will be requested
|
||||
// by the webui page.
|
||||
// chrome://pdf-viewer/index.html?src=https://somepage/123.pdf
|
||||
content::NavigationController::LoadURLParams params(
|
||||
GURL(base::StringPrintf("%sindex.html?%s=%s", kPdfViewerUIOrigin,
|
||||
kPdfPluginSrc, original_url.spec().c_str())));
|
||||
web_contents->GetController().LoadURLWithParams(params);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
AtomResourceDispatcherHostDelegate::AtomResourceDispatcherHostDelegate() {
|
||||
@@ -64,17 +85,12 @@ AtomResourceDispatcherHostDelegate::AtomResourceDispatcherHostDelegate() {
|
||||
|
||||
bool AtomResourceDispatcherHostDelegate::HandleExternalProtocol(
|
||||
const GURL& url,
|
||||
int child_id,
|
||||
const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
|
||||
bool is_main_frame,
|
||||
ui::PageTransition transition,
|
||||
bool has_user_gesture,
|
||||
content::ResourceContext* resource_context) {
|
||||
content::ResourceRequestInfo* info) {
|
||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(&HandleExternalProtocolInUI,
|
||||
url,
|
||||
web_contents_getter,
|
||||
has_user_gesture));
|
||||
info->GetWebContentsGetterForRequest(),
|
||||
info->HasUserGesture()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -100,4 +116,23 @@ AtomResourceDispatcherHostDelegate::CreateClientCertStore(
|
||||
#endif
|
||||
}
|
||||
|
||||
bool AtomResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream(
|
||||
net::URLRequest* request,
|
||||
const base::FilePath& plugin_path,
|
||||
const std::string& mime_type,
|
||||
GURL* origin,
|
||||
std::string* payload) {
|
||||
const content::ResourceRequestInfo* info =
|
||||
content::ResourceRequestInfo::ForRequest(request);
|
||||
if (mime_type == "application/pdf" && info->IsMainFrame()) {
|
||||
*origin = GURL(kPdfViewerUIOrigin);
|
||||
content::BrowserThread::PostTask(
|
||||
BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(&OnPdfResourceIntercepted, request->url(),
|
||||
info->GetWebContentsGetterForRequest()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef ATOM_BROWSER_ATOM_RESOURCE_DISPATCHER_HOST_DELEGATE_H_
|
||||
#define ATOM_BROWSER_ATOM_RESOURCE_DISPATCHER_HOST_DELEGATE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "content/public/browser/resource_dispatcher_host_delegate.h"
|
||||
|
||||
namespace atom {
|
||||
@@ -15,19 +17,21 @@ class AtomResourceDispatcherHostDelegate
|
||||
AtomResourceDispatcherHostDelegate();
|
||||
|
||||
// content::ResourceDispatcherHostDelegate:
|
||||
bool HandleExternalProtocol(
|
||||
const GURL& url,
|
||||
int child_id,
|
||||
const content::ResourceRequestInfo::WebContentsGetter&,
|
||||
bool is_main_frame,
|
||||
ui::PageTransition transition,
|
||||
bool has_user_gesture,
|
||||
content::ResourceContext* resource_context) override;
|
||||
bool HandleExternalProtocol(const GURL& url,
|
||||
content::ResourceRequestInfo* info) override;
|
||||
content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(
|
||||
net::AuthChallengeInfo* auth_info,
|
||||
net::URLRequest* request) override;
|
||||
std::unique_ptr<net::ClientCertStore> CreateClientCertStore(
|
||||
content::ResourceContext* resource_context) override;
|
||||
bool ShouldInterceptResourceAsStream(net::URLRequest* request,
|
||||
const base::FilePath& plugin_path,
|
||||
const std::string& mime_type,
|
||||
GURL* origin,
|
||||
std::string* payload) override;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomResourceDispatcherHostDelegate);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/atom_security_state_model_client.h"
|
||||
|
||||
#include "content/public/browser/cert_store.h"
|
||||
#include "content/public/browser/navigation_entry.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "content/public/common/ssl_status.h"
|
||||
#include "net/cert/x509_certificate.h"
|
||||
|
||||
DEFINE_WEB_CONTENTS_USER_DATA_KEY(atom::AtomSecurityStateModelClient);
|
||||
|
||||
using security_state::SecurityStateModel;
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
SecurityStateModel::SecurityLevel GetSecurityLevelForSecurityStyle(
|
||||
content::SecurityStyle style) {
|
||||
switch (style) {
|
||||
case content::SECURITY_STYLE_UNKNOWN:
|
||||
return SecurityStateModel::NONE;
|
||||
case content::SECURITY_STYLE_UNAUTHENTICATED:
|
||||
return SecurityStateModel::NONE;
|
||||
case content::SECURITY_STYLE_AUTHENTICATION_BROKEN:
|
||||
return SecurityStateModel::SECURITY_ERROR;
|
||||
case content::SECURITY_STYLE_WARNING:
|
||||
return SecurityStateModel::SECURITY_WARNING;
|
||||
case content::SECURITY_STYLE_AUTHENTICATED:
|
||||
return SecurityStateModel::SECURE;
|
||||
}
|
||||
return SecurityStateModel::NONE;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
AtomSecurityStateModelClient::AtomSecurityStateModelClient(
|
||||
content::WebContents* web_contents)
|
||||
: web_contents_(web_contents),
|
||||
security_state_model_(new SecurityStateModel()) {
|
||||
security_state_model_->SetClient(this);
|
||||
}
|
||||
|
||||
AtomSecurityStateModelClient::~AtomSecurityStateModelClient() {
|
||||
}
|
||||
|
||||
const SecurityStateModel::SecurityInfo&
|
||||
AtomSecurityStateModelClient::GetSecurityInfo() const {
|
||||
return security_state_model_->GetSecurityInfo();
|
||||
}
|
||||
|
||||
bool AtomSecurityStateModelClient::RetrieveCert(
|
||||
scoped_refptr<net::X509Certificate>* cert) {
|
||||
content::NavigationEntry* entry =
|
||||
web_contents_->GetController().GetVisibleEntry();
|
||||
if (!entry)
|
||||
return false;
|
||||
return content::CertStore::GetInstance()->RetrieveCert(
|
||||
entry->GetSSL().cert_id, cert);
|
||||
}
|
||||
|
||||
bool AtomSecurityStateModelClient::UsedPolicyInstalledCertificate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AtomSecurityStateModelClient::IsOriginSecure(const GURL& url) {
|
||||
return content::IsOriginSecure(url);
|
||||
}
|
||||
|
||||
void AtomSecurityStateModelClient::GetVisibleSecurityState(
|
||||
SecurityStateModel::VisibleSecurityState* state) {
|
||||
content::NavigationEntry* entry =
|
||||
web_contents_->GetController().GetVisibleEntry();
|
||||
if (!entry ||
|
||||
entry->GetSSL().security_style == content::SECURITY_STYLE_UNKNOWN) {
|
||||
*state = SecurityStateModel::VisibleSecurityState();
|
||||
return;
|
||||
}
|
||||
|
||||
state->initialized = true;
|
||||
state->url = entry->GetURL();
|
||||
const content::SSLStatus& ssl = entry->GetSSL();
|
||||
state->initial_security_level =
|
||||
GetSecurityLevelForSecurityStyle(ssl.security_style);
|
||||
state->cert_id = ssl.cert_id;
|
||||
state->cert_status = ssl.cert_status;
|
||||
state->connection_status = ssl.connection_status;
|
||||
state->security_bits = ssl.security_bits;
|
||||
state->sct_verify_statuses.clear();
|
||||
state->sct_verify_statuses.insert(state->sct_verify_statuses.end(),
|
||||
ssl.num_unknown_scts,
|
||||
net::ct::SCT_STATUS_LOG_UNKNOWN);
|
||||
state->sct_verify_statuses.insert(state->sct_verify_statuses.end(),
|
||||
ssl.num_invalid_scts,
|
||||
net::ct::SCT_STATUS_INVALID);
|
||||
state->sct_verify_statuses.insert(state->sct_verify_statuses.end(),
|
||||
ssl.num_valid_scts, net::ct::SCT_STATUS_OK);
|
||||
state->displayed_mixed_content =
|
||||
(ssl.content_status & content::SSLStatus::DISPLAYED_INSECURE_CONTENT)
|
||||
? true
|
||||
: false;
|
||||
state->ran_mixed_content =
|
||||
(ssl.content_status & content::SSLStatus::RAN_INSECURE_CONTENT) ? true
|
||||
: false;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
@@ -1,42 +0,0 @@
|
||||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_ATOM_SECURITY_STATE_MODEL_CLIENT_H_
|
||||
#define ATOM_BROWSER_ATOM_SECURITY_STATE_MODEL_CLIENT_H_
|
||||
|
||||
#include "components/security_state/security_state_model.h"
|
||||
#include "components/security_state/security_state_model_client.h"
|
||||
#include "content/public/browser/web_contents_user_data.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class AtomSecurityStateModelClient
|
||||
: public security_state::SecurityStateModelClient,
|
||||
public content::WebContentsUserData<AtomSecurityStateModelClient> {
|
||||
public:
|
||||
~AtomSecurityStateModelClient() override;
|
||||
|
||||
const security_state::SecurityStateModel::SecurityInfo&
|
||||
GetSecurityInfo() const;
|
||||
|
||||
// security_state::SecurityStateModelClient:
|
||||
void GetVisibleSecurityState(
|
||||
security_state::SecurityStateModel::VisibleSecurityState* state) override;
|
||||
bool RetrieveCert(scoped_refptr<net::X509Certificate>* cert) override;
|
||||
bool UsedPolicyInstalledCertificate() override;
|
||||
bool IsOriginSecure(const GURL& url) override;
|
||||
|
||||
private:
|
||||
explicit AtomSecurityStateModelClient(content::WebContents* web_contents);
|
||||
friend class content::WebContentsUserData<AtomSecurityStateModelClient>;
|
||||
|
||||
content::WebContents* web_contents_;
|
||||
std::unique_ptr<security_state::SecurityStateModel> security_state_model_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomSecurityStateModelClient);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_ATOM_SECURITY_STATE_MODEL_CLIENT_H_
|
||||
66
atom/browser/atom_web_ui_controller_factory.cc
Normal file
66
atom/browser/atom_web_ui_controller_factory.cc
Normal file
@@ -0,0 +1,66 @@
|
||||
// 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/atom_web_ui_controller_factory.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "atom/browser/ui/webui/pdf_viewer_ui.h"
|
||||
#include "atom/common/atom_constants.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
// static
|
||||
AtomWebUIControllerFactory* AtomWebUIControllerFactory::GetInstance() {
|
||||
return base::Singleton<AtomWebUIControllerFactory>::get();
|
||||
}
|
||||
|
||||
AtomWebUIControllerFactory::AtomWebUIControllerFactory() {}
|
||||
|
||||
AtomWebUIControllerFactory::~AtomWebUIControllerFactory() {}
|
||||
|
||||
content::WebUI::TypeID AtomWebUIControllerFactory::GetWebUIType(
|
||||
content::BrowserContext* browser_context,
|
||||
const GURL& url) const {
|
||||
if (url.host() == kPdfViewerUIHost) {
|
||||
return const_cast<AtomWebUIControllerFactory*>(this);
|
||||
}
|
||||
|
||||
return content::WebUI::kNoWebUI;
|
||||
}
|
||||
|
||||
bool AtomWebUIControllerFactory::UseWebUIForURL(
|
||||
content::BrowserContext* browser_context,
|
||||
const GURL& url) const {
|
||||
return GetWebUIType(browser_context, url) != content::WebUI::kNoWebUI;
|
||||
}
|
||||
|
||||
bool AtomWebUIControllerFactory::UseWebUIBindingsForURL(
|
||||
content::BrowserContext* browser_context,
|
||||
const GURL& url) const {
|
||||
return UseWebUIForURL(browser_context, url);
|
||||
}
|
||||
|
||||
content::WebUIController*
|
||||
AtomWebUIControllerFactory::CreateWebUIControllerForURL(content::WebUI* web_ui,
|
||||
const GURL& url) const {
|
||||
if (url.host() == kPdfViewerUIHost) {
|
||||
base::StringPairs toplevel_params;
|
||||
base::SplitStringIntoKeyValuePairs(url.query(), '=', '&', &toplevel_params);
|
||||
std::string stream_id, src;
|
||||
for (const auto& param : toplevel_params) {
|
||||
if (param.first == kPdfPluginSrc) {
|
||||
src = param.second;
|
||||
}
|
||||
}
|
||||
auto browser_context = web_ui->GetWebContents()->GetBrowserContext();
|
||||
return new PdfViewerUI(browser_context, web_ui, src);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
40
atom/browser/atom_web_ui_controller_factory.h
Normal file
40
atom/browser/atom_web_ui_controller_factory.h
Normal file
@@ -0,0 +1,40 @@
|
||||
// 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_ATOM_WEB_UI_CONTROLLER_FACTORY_H_
|
||||
#define ATOM_BROWSER_ATOM_WEB_UI_CONTROLLER_FACTORY_H_
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/singleton.h"
|
||||
#include "content/public/browser/web_ui_controller_factory.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class AtomWebUIControllerFactory : public content::WebUIControllerFactory {
|
||||
public:
|
||||
static AtomWebUIControllerFactory* GetInstance();
|
||||
|
||||
AtomWebUIControllerFactory();
|
||||
virtual ~AtomWebUIControllerFactory();
|
||||
|
||||
// content::WebUIControllerFactory:
|
||||
content::WebUI::TypeID GetWebUIType(content::BrowserContext* browser_context,
|
||||
const GURL& url) const override;
|
||||
bool UseWebUIForURL(content::BrowserContext* browser_context,
|
||||
const GURL& url) const override;
|
||||
bool UseWebUIBindingsForURL(content::BrowserContext* browser_context,
|
||||
const GURL& url) const override;
|
||||
content::WebUIController* CreateWebUIControllerForURL(
|
||||
content::WebUI* web_ui,
|
||||
const GURL& url) const override;
|
||||
|
||||
private:
|
||||
friend struct base::DefaultSingletonTraits<AtomWebUIControllerFactory>;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomWebUIControllerFactory);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_ATOM_WEB_UI_CONTROLLER_FACTORY_H_
|
||||
@@ -7,11 +7,13 @@
|
||||
#include <string>
|
||||
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
#include "atom/browser/browser_observer.h"
|
||||
#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_task_runner_handle.h"
|
||||
#include "brightray/browser/brightray_paths.h"
|
||||
|
||||
namespace atom {
|
||||
@@ -82,10 +84,11 @@ void Browser::Shutdown() {
|
||||
is_shutdown_ = true;
|
||||
is_quiting_ = true;
|
||||
|
||||
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnQuit());
|
||||
for (BrowserObserver& observer : observers_)
|
||||
observer.OnQuit();
|
||||
|
||||
if (base::MessageLoop::current()) {
|
||||
base::MessageLoop::current()->PostTask(
|
||||
if (base::ThreadTaskRunnerHandle::IsSet()) {
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
|
||||
} else {
|
||||
// There is no message loop available so we are in early stage.
|
||||
@@ -127,25 +130,25 @@ int Browser::GetBadgeCount() {
|
||||
|
||||
bool Browser::OpenFile(const std::string& file_path) {
|
||||
bool prevent_default = false;
|
||||
FOR_EACH_OBSERVER(BrowserObserver,
|
||||
observers_,
|
||||
OnOpenFile(&prevent_default, file_path));
|
||||
for (BrowserObserver& observer : observers_)
|
||||
observer.OnOpenFile(&prevent_default, file_path);
|
||||
|
||||
return prevent_default;
|
||||
}
|
||||
|
||||
void Browser::OpenURL(const std::string& url) {
|
||||
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnOpenURL(url));
|
||||
for (BrowserObserver& observer : observers_)
|
||||
observer.OnOpenURL(url);
|
||||
}
|
||||
|
||||
void Browser::Activate(bool has_visible_windows) {
|
||||
FOR_EACH_OBSERVER(BrowserObserver,
|
||||
observers_,
|
||||
OnActivate(has_visible_windows));
|
||||
for (BrowserObserver& observer : observers_)
|
||||
observer.OnActivate(has_visible_windows);
|
||||
}
|
||||
|
||||
void Browser::WillFinishLaunching() {
|
||||
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillFinishLaunching());
|
||||
for (BrowserObserver& observer : observers_)
|
||||
observer.OnWillFinishLaunching();
|
||||
}
|
||||
|
||||
void Browser::DidFinishLaunching(const base::DictionaryValue& launch_info) {
|
||||
@@ -155,22 +158,20 @@ void Browser::DidFinishLaunching(const base::DictionaryValue& launch_info) {
|
||||
base::CreateDirectoryAndGetError(user_data, nullptr);
|
||||
|
||||
is_ready_ = true;
|
||||
FOR_EACH_OBSERVER(BrowserObserver, observers_,
|
||||
OnFinishLaunching(launch_info));
|
||||
for (BrowserObserver& observer : observers_)
|
||||
observer.OnFinishLaunching(launch_info);
|
||||
}
|
||||
|
||||
void Browser::OnAccessibilitySupportChanged() {
|
||||
FOR_EACH_OBSERVER(BrowserObserver,
|
||||
observers_,
|
||||
OnAccessibilitySupportChanged());
|
||||
for (BrowserObserver& observer : observers_)
|
||||
observer.OnAccessibilitySupportChanged();
|
||||
}
|
||||
|
||||
void Browser::RequestLogin(
|
||||
LoginHandler* login_handler,
|
||||
std::unique_ptr<base::DictionaryValue> request_details) {
|
||||
FOR_EACH_OBSERVER(BrowserObserver,
|
||||
observers_,
|
||||
OnLogin(login_handler, *(request_details.get())));
|
||||
for (BrowserObserver& observer : observers_)
|
||||
observer.OnLogin(login_handler, *(request_details.get()));
|
||||
}
|
||||
|
||||
void Browser::NotifyAndShutdown() {
|
||||
@@ -178,7 +179,8 @@ void Browser::NotifyAndShutdown() {
|
||||
return;
|
||||
|
||||
bool prevent_default = false;
|
||||
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillQuit(&prevent_default));
|
||||
for (BrowserObserver& observer : observers_)
|
||||
observer.OnWillQuit(&prevent_default);
|
||||
|
||||
if (prevent_default) {
|
||||
is_quiting_ = false;
|
||||
@@ -190,9 +192,8 @@ void Browser::NotifyAndShutdown() {
|
||||
|
||||
bool Browser::HandleBeforeQuit() {
|
||||
bool prevent_default = false;
|
||||
FOR_EACH_OBSERVER(BrowserObserver,
|
||||
observers_,
|
||||
OnBeforeQuit(&prevent_default));
|
||||
for (BrowserObserver& observer : observers_)
|
||||
observer.OnBeforeQuit(&prevent_default);
|
||||
|
||||
return !prevent_default;
|
||||
}
|
||||
@@ -205,12 +206,14 @@ void Browser::OnWindowCloseCancelled(NativeWindow* window) {
|
||||
}
|
||||
|
||||
void Browser::OnWindowAllClosed() {
|
||||
if (is_exiting_)
|
||||
if (is_exiting_) {
|
||||
Shutdown();
|
||||
else if (is_quiting_)
|
||||
} else if (is_quiting_) {
|
||||
NotifyAndShutdown();
|
||||
else
|
||||
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWindowAllClosed());
|
||||
} else {
|
||||
for (BrowserObserver& observer : observers_)
|
||||
observer.OnWindowAllClosed();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -98,9 +98,11 @@ class Browser : public WindowListObserver {
|
||||
bool restore_state = false;
|
||||
bool opened_at_login = false;
|
||||
bool opened_as_hidden = false;
|
||||
base::string16 path;
|
||||
std::vector<base::string16> args;
|
||||
};
|
||||
void SetLoginItemSettings(LoginItemSettings settings);
|
||||
LoginItemSettings GetLoginItemSettings();
|
||||
LoginItemSettings GetLoginItemSettings(LoginItemSettings options);
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
// Hide the application.
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "atom/browser/window_list.h"
|
||||
#include "atom/common/atom_version.h"
|
||||
#include "brightray/common/application_info.h"
|
||||
#include "chrome/browser/ui/libgtk2ui/unity_service.h"
|
||||
#include "chrome/browser/ui/libgtkui/unity_service.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -63,7 +63,8 @@ bool Browser::SetBadgeCount(int count) {
|
||||
void Browser::SetLoginItemSettings(LoginItemSettings settings) {
|
||||
}
|
||||
|
||||
Browser::LoginItemSettings Browser::GetLoginItemSettings() {
|
||||
Browser::LoginItemSettings Browser::GetLoginItemSettings(
|
||||
LoginItemSettings options) {
|
||||
return LoginItemSettings();
|
||||
}
|
||||
|
||||
|
||||
@@ -146,13 +146,13 @@ std::string Browser::GetCurrentActivityType() {
|
||||
bool Browser::ContinueUserActivity(const std::string& type,
|
||||
const base::DictionaryValue& user_info) {
|
||||
bool prevent_default = false;
|
||||
FOR_EACH_OBSERVER(BrowserObserver,
|
||||
observers_,
|
||||
OnContinueUserActivity(&prevent_default, type, user_info));
|
||||
for (BrowserObserver& observer : observers_)
|
||||
observer.OnContinueUserActivity(&prevent_default, type, user_info);
|
||||
return prevent_default;
|
||||
}
|
||||
|
||||
Browser::LoginItemSettings Browser::GetLoginItemSettings() {
|
||||
Browser::LoginItemSettings Browser::GetLoginItemSettings(
|
||||
LoginItemSettings options) {
|
||||
LoginItemSettings settings;
|
||||
settings.open_at_login = base::mac::CheckLoginItemStatus(
|
||||
&settings.open_as_hidden);
|
||||
@@ -255,6 +255,16 @@ void Browser::DockSetIcon(const gfx::Image& image) {
|
||||
|
||||
void Browser::ShowAboutPanel() {
|
||||
NSDictionary* options = DictionaryValueToNSDictionary(about_panel_options_);
|
||||
|
||||
// Credits must be a NSAttributedString instead of NSString
|
||||
id credits = options[@"Credits"];
|
||||
if (credits != nil) {
|
||||
NSMutableDictionary* mutable_options = [options mutableCopy];
|
||||
mutable_options[@"Credits"] = [[[NSAttributedString alloc]
|
||||
initWithString:(NSString*)credits] autorelease];
|
||||
options = [NSDictionary dictionaryWithDictionary:mutable_options];
|
||||
}
|
||||
|
||||
[[AtomApplication sharedApplication]
|
||||
orderFrontStandardAboutPanelWithOptions:options];
|
||||
}
|
||||
|
||||
@@ -43,15 +43,19 @@ BOOL CALLBACK WindowsEnumerationHandler(HWND hwnd, LPARAM param) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool GetProcessExecPath(base::string16* exe) {
|
||||
base::FilePath path;
|
||||
if (!PathService::Get(base::FILE_EXE, &path)) {
|
||||
LOG(ERROR) << "Error getting app exe path";
|
||||
return false;
|
||||
}
|
||||
*exe = path.value();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetProtocolLaunchPath(mate::Arguments* args, base::string16* exe) {
|
||||
// Executable Path
|
||||
if (!args->GetNext(exe)) {
|
||||
base::FilePath path;
|
||||
if (!PathService::Get(base::FILE_EXE, &path)) {
|
||||
LOG(ERROR) << "Error getting app exe path";
|
||||
return false;
|
||||
}
|
||||
*exe = path.value();
|
||||
if (!args->GetNext(exe) && !GetProcessExecPath(exe)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read in optional args arg
|
||||
@@ -65,6 +69,22 @@ bool GetProtocolLaunchPath(mate::Arguments* args, base::string16* exe) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FormatCommandLineString(base::string16* exe,
|
||||
const std::vector<base::string16>& launch_args) {
|
||||
if (exe->empty() && !GetProcessExecPath(exe)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!launch_args.empty()) {
|
||||
base::string16 formatString = L"%s %s";
|
||||
*exe = base::StringPrintf(formatString.c_str(),
|
||||
exe->c_str(),
|
||||
base::JoinString(launch_args, L" ").c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void Browser::Focus() {
|
||||
@@ -257,34 +277,32 @@ void Browser::SetLoginItemSettings(LoginItemSettings settings) {
|
||||
base::win::RegKey key(HKEY_CURRENT_USER, keyPath.c_str(), KEY_ALL_ACCESS);
|
||||
|
||||
if (settings.open_at_login) {
|
||||
base::FilePath path;
|
||||
if (PathService::Get(base::FILE_EXE, &path)) {
|
||||
base::string16 exePath(path.value());
|
||||
key.WriteValue(GetAppUserModelID(), exePath.c_str());
|
||||
base::string16 exe = settings.path;
|
||||
if (FormatCommandLineString(&exe, settings.args)) {
|
||||
key.WriteValue(GetAppUserModelID(), exe.c_str());
|
||||
}
|
||||
} else {
|
||||
key.DeleteValue(GetAppUserModelID());
|
||||
}
|
||||
}
|
||||
|
||||
Browser::LoginItemSettings Browser::GetLoginItemSettings() {
|
||||
Browser::LoginItemSettings Browser::GetLoginItemSettings(
|
||||
LoginItemSettings options) {
|
||||
LoginItemSettings settings;
|
||||
base::string16 keyPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
||||
base::win::RegKey key(HKEY_CURRENT_USER, keyPath.c_str(), KEY_ALL_ACCESS);
|
||||
base::string16 keyVal;
|
||||
|
||||
if (!FAILED(key.ReadValue(GetAppUserModelID(), &keyVal))) {
|
||||
base::FilePath path;
|
||||
if (PathService::Get(base::FILE_EXE, &path)) {
|
||||
base::string16 exePath(path.value());
|
||||
settings.open_at_login = keyVal == exePath;
|
||||
base::string16 exe = options.path;
|
||||
if (FormatCommandLineString(&exe, options.args)) {
|
||||
settings.open_at_login = keyVal == exe;
|
||||
}
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
PCWSTR Browser::GetAppUserModelID() {
|
||||
if (app_user_model_id_.empty()) {
|
||||
SetAppUserModelID(base::ReplaceStringPlaceholders(
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/atom_javascript_dialog_manager.h"
|
||||
#include "atom/browser/atom_security_state_model_client.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/ui/file_dialog.h"
|
||||
#include "atom/browser/web_dialog_helper.h"
|
||||
@@ -18,10 +17,13 @@
|
||||
#include "base/files/file_util.h"
|
||||
#include "chrome/browser/printing/print_preview_message_handler.h"
|
||||
#include "chrome/browser/printing/print_view_manager_basic.h"
|
||||
#include "chrome/browser/ssl/security_state_tab_helper.h"
|
||||
#include "chrome/browser/ui/browser_dialogs.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "components/prefs/scoped_user_pref_update.h"
|
||||
#include "components/security_state/content/content_utils.h"
|
||||
#include "components/security_state/core/security_state.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/child_process_security_policy.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
@@ -32,7 +34,6 @@
|
||||
#include "storage/browser/fileapi/isolated_context.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
using security_state::SecurityStateModel;
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -93,8 +94,10 @@ FileSystem CreateFileSystemStruct(
|
||||
return FileSystem(file_system_name, root_url, file_system_path);
|
||||
}
|
||||
|
||||
base::DictionaryValue* CreateFileSystemValue(const FileSystem& file_system) {
|
||||
auto* file_system_value = new base::DictionaryValue();
|
||||
std::unique_ptr<base::DictionaryValue> CreateFileSystemValue(
|
||||
const FileSystem& file_system) {
|
||||
std::unique_ptr<base::DictionaryValue> file_system_value(
|
||||
new base::DictionaryValue());
|
||||
file_system_value->SetString("fileSystemName", file_system.file_system_name);
|
||||
file_system_value->SetString("rootURL", file_system.root_url);
|
||||
file_system_value->SetString("fileSystemPath", file_system.file_system_path);
|
||||
@@ -144,24 +147,6 @@ bool IsDevToolsFileSystemAdded(
|
||||
return file_system_paths.find(file_system_path) != file_system_paths.end();
|
||||
}
|
||||
|
||||
content::SecurityStyle SecurityLevelToSecurityStyle(
|
||||
SecurityStateModel::SecurityLevel security_level) {
|
||||
switch (security_level) {
|
||||
case SecurityStateModel::NONE:
|
||||
return content::SECURITY_STYLE_UNAUTHENTICATED;
|
||||
case SecurityStateModel::SECURITY_WARNING:
|
||||
case SecurityStateModel::SECURITY_POLICY_WARNING:
|
||||
return content::SECURITY_STYLE_WARNING;
|
||||
case SecurityStateModel::EV_SECURE:
|
||||
case SecurityStateModel::SECURE:
|
||||
return content::SECURITY_STYLE_AUTHENTICATED;
|
||||
case SecurityStateModel::SECURITY_ERROR:
|
||||
return content::SECURITY_STYLE_AUTHENTICATION_BROKEN;
|
||||
}
|
||||
|
||||
return content::SECURITY_STYLE_UNKNOWN;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
CommonWebContentsDelegate::CommonWebContentsDelegate()
|
||||
@@ -290,88 +275,16 @@ bool CommonWebContentsDelegate::IsFullscreenForTabOrPending(
|
||||
return html_fullscreen_;
|
||||
}
|
||||
|
||||
content::SecurityStyle CommonWebContentsDelegate::GetSecurityStyle(
|
||||
blink::WebSecurityStyle CommonWebContentsDelegate::GetSecurityStyle(
|
||||
content::WebContents* web_contents,
|
||||
content::SecurityStyleExplanations* explanations) {
|
||||
auto model_client =
|
||||
AtomSecurityStateModelClient::FromWebContents(web_contents);
|
||||
|
||||
const SecurityStateModel::SecurityInfo& security_info =
|
||||
model_client->GetSecurityInfo();
|
||||
|
||||
const content::SecurityStyle security_style =
|
||||
SecurityLevelToSecurityStyle(security_info.security_level);
|
||||
|
||||
explanations->ran_insecure_content_style =
|
||||
SecurityLevelToSecurityStyle(
|
||||
SecurityStateModel::kRanInsecureContentLevel);
|
||||
explanations->displayed_insecure_content_style =
|
||||
SecurityLevelToSecurityStyle(
|
||||
SecurityStateModel::kDisplayedInsecureContentLevel);
|
||||
|
||||
explanations->scheme_is_cryptographic = security_info.scheme_is_cryptographic;
|
||||
if (!security_info.scheme_is_cryptographic)
|
||||
return security_style;
|
||||
|
||||
if (security_info.sha1_deprecation_status ==
|
||||
SecurityStateModel::DEPRECATED_SHA1_MAJOR) {
|
||||
explanations->broken_explanations.push_back(
|
||||
content::SecurityStyleExplanation(
|
||||
kSHA1Certificate,
|
||||
kSHA1MajorDescription,
|
||||
security_info.cert_id));
|
||||
} else if (security_info.sha1_deprecation_status ==
|
||||
SecurityStateModel::DEPRECATED_SHA1_MINOR) {
|
||||
explanations->unauthenticated_explanations.push_back(
|
||||
content::SecurityStyleExplanation(
|
||||
kSHA1Certificate,
|
||||
kSHA1MinorDescription,
|
||||
security_info.cert_id));
|
||||
}
|
||||
|
||||
explanations->ran_insecure_content =
|
||||
security_info.mixed_content_status ==
|
||||
SecurityStateModel::RAN_MIXED_CONTENT ||
|
||||
security_info.mixed_content_status ==
|
||||
SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT;
|
||||
explanations->displayed_insecure_content =
|
||||
security_info.mixed_content_status ==
|
||||
SecurityStateModel::DISPLAYED_MIXED_CONTENT ||
|
||||
security_info.mixed_content_status ==
|
||||
SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT;
|
||||
|
||||
if (net::IsCertStatusError(security_info.cert_status)) {
|
||||
std::string error_string = net::ErrorToString(
|
||||
net::MapCertStatusToNetError(security_info.cert_status));
|
||||
|
||||
content::SecurityStyleExplanation explanation(
|
||||
kCertificateError,
|
||||
"There are issues with the site's certificate chain " + error_string,
|
||||
security_info.cert_id);
|
||||
|
||||
if (net::IsCertStatusMinorError(security_info.cert_status))
|
||||
explanations->unauthenticated_explanations.push_back(explanation);
|
||||
else
|
||||
explanations->broken_explanations.push_back(explanation);
|
||||
} else {
|
||||
if (security_info.sha1_deprecation_status ==
|
||||
SecurityStateModel::NO_DEPRECATED_SHA1) {
|
||||
explanations->secure_explanations.push_back(
|
||||
content::SecurityStyleExplanation(
|
||||
kValidCertificate,
|
||||
kValidCertificateDescription,
|
||||
security_info.cert_id));
|
||||
}
|
||||
}
|
||||
|
||||
if (security_info.is_secure_protocol_and_ciphersuite) {
|
||||
explanations->secure_explanations.push_back(
|
||||
content::SecurityStyleExplanation(
|
||||
kSecureProtocol,
|
||||
kSecureProtocolDescription));
|
||||
}
|
||||
|
||||
return security_style;
|
||||
content::SecurityStyleExplanations* security_style_explanations) {
|
||||
SecurityStateTabHelper* helper =
|
||||
SecurityStateTabHelper::FromWebContents(web_contents);
|
||||
DCHECK(helper);
|
||||
security_state::SecurityInfo security_info;
|
||||
helper->GetSecurityInfo(&security_info);
|
||||
return security_state::GetSecurityStyle(security_info,
|
||||
security_style_explanations);
|
||||
}
|
||||
|
||||
void CommonWebContentsDelegate::DevToolsSaveToFile(
|
||||
@@ -381,10 +294,11 @@ void CommonWebContentsDelegate::DevToolsSaveToFile(
|
||||
if (it != saved_files_.end() && !save_as) {
|
||||
path = it->second;
|
||||
} else {
|
||||
file_dialog::Filters filters;
|
||||
base::FilePath default_path(base::FilePath::FromUTF8Unsafe(url));
|
||||
if (!file_dialog::ShowSaveDialog(owner_window(), url, "", default_path,
|
||||
filters, &path)) {
|
||||
file_dialog::DialogSettings settings;
|
||||
settings.parent_window = owner_window();
|
||||
settings.title = url;
|
||||
settings.default_path = base::FilePath::FromUTF8Unsafe(url);
|
||||
if (!file_dialog::ShowSaveDialog(settings, &path)) {
|
||||
base::StringValue url_value(url);
|
||||
web_contents_->CallClientFunction(
|
||||
"DevToolsAPI.canceledSaveURL", &url_value, nullptr, nullptr);
|
||||
@@ -445,12 +359,11 @@ void CommonWebContentsDelegate::DevToolsAddFileSystem(
|
||||
const base::FilePath& file_system_path) {
|
||||
base::FilePath path = file_system_path;
|
||||
if (path.empty()) {
|
||||
file_dialog::Filters filters;
|
||||
base::FilePath default_path;
|
||||
std::vector<base::FilePath> paths;
|
||||
int flag = file_dialog::FILE_DIALOG_OPEN_DIRECTORY;
|
||||
if (!file_dialog::ShowOpenDialog(owner_window(), "", "", default_path,
|
||||
filters, flag, &paths))
|
||||
file_dialog::DialogSettings settings;
|
||||
settings.parent_window = owner_window();
|
||||
settings.properties = file_dialog::FILE_DIALOG_OPEN_DIRECTORY;
|
||||
if (!file_dialog::ShowOpenDialog(settings, &paths))
|
||||
return;
|
||||
|
||||
path = paths[0];
|
||||
|
||||
@@ -81,7 +81,7 @@ class CommonWebContentsDelegate
|
||||
void ExitFullscreenModeForTab(content::WebContents* source) override;
|
||||
bool IsFullscreenForTabOrPending(
|
||||
const content::WebContents* source) const override;
|
||||
content::SecurityStyle GetSecurityStyle(
|
||||
blink::WebSecurityStyle GetSecurityStyle(
|
||||
content::WebContents* web_contents,
|
||||
content::SecurityStyleExplanations* explanations) override;
|
||||
void HandleKeyboardEvent(
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include "gin/array_buffer.h"
|
||||
#include "gin/v8_initializer.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
JavascriptEnvironment::JavascriptEnvironment()
|
||||
@@ -46,4 +48,11 @@ bool JavascriptEnvironment::Initialize() {
|
||||
return true;
|
||||
}
|
||||
|
||||
NodeEnvironment::NodeEnvironment(node::Environment* env) : env_(env) {
|
||||
}
|
||||
|
||||
NodeEnvironment::~NodeEnvironment() {
|
||||
node::FreeEnvironment(env_);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -8,8 +8,13 @@
|
||||
#include "base/macros.h"
|
||||
#include "gin/public/isolate_holder.h"
|
||||
|
||||
namespace node {
|
||||
class Environment;
|
||||
}
|
||||
|
||||
namespace atom {
|
||||
|
||||
// Manage the V8 isolate and context automatically.
|
||||
class JavascriptEnvironment {
|
||||
public:
|
||||
JavascriptEnvironment();
|
||||
@@ -37,6 +42,18 @@ class JavascriptEnvironment {
|
||||
DISALLOW_COPY_AND_ASSIGN(JavascriptEnvironment);
|
||||
};
|
||||
|
||||
// Manage the Node Environment automatically.
|
||||
class NodeEnvironment {
|
||||
public:
|
||||
explicit NodeEnvironment(node::Environment* env);
|
||||
~NodeEnvironment();
|
||||
|
||||
private:
|
||||
node::Environment* env_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(NodeEnvironment);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_JAVASCRIPT_ENVIRONMENT_H_
|
||||
|
||||
@@ -89,8 +89,12 @@ void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) {
|
||||
}
|
||||
}
|
||||
|
||||
void BluetoothChooser::AddDevice(const std::string& device_id,
|
||||
const base::string16& device_name) {
|
||||
void BluetoothChooser::AddOrUpdateDevice(const std::string& device_id,
|
||||
bool should_update_name,
|
||||
const base::string16& device_name,
|
||||
bool is_gatt_connected,
|
||||
bool is_paired,
|
||||
int signal_strength_level) {
|
||||
DeviceInfo info = {device_id, device_name};
|
||||
device_list_.push_back(info);
|
||||
}
|
||||
|
||||
@@ -27,8 +27,12 @@ class BluetoothChooser : public content::BluetoothChooser {
|
||||
// content::BluetoothChooser:
|
||||
void SetAdapterPresence(AdapterPresence presence) override;
|
||||
void ShowDiscoveryState(DiscoveryState state) override;
|
||||
void AddDevice(const std::string& device_id,
|
||||
const base::string16& device_name) override;
|
||||
void AddOrUpdateDevice(const std::string& device_id,
|
||||
bool should_update_name,
|
||||
const base::string16& device_name,
|
||||
bool is_gatt_connected,
|
||||
bool is_paired,
|
||||
int signal_strength_level) override;
|
||||
void RemoveDevice(const std::string& device_id) override;
|
||||
|
||||
private:
|
||||
|
||||
26
atom/browser/loader/layered_resource_handler.cc
Normal file
26
atom/browser/loader/layered_resource_handler.cc
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.
|
||||
|
||||
#include "atom/browser/loader/layered_resource_handler.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
LayeredResourceHandler::LayeredResourceHandler(
|
||||
net::URLRequest* request,
|
||||
std::unique_ptr<content::ResourceHandler> next_handler,
|
||||
Delegate* delegate)
|
||||
: content::LayeredResourceHandler(request, std::move(next_handler)),
|
||||
delegate_(delegate) {}
|
||||
|
||||
LayeredResourceHandler::~LayeredResourceHandler() {}
|
||||
|
||||
bool LayeredResourceHandler::OnResponseStarted(
|
||||
content::ResourceResponse* response,
|
||||
bool* defer) {
|
||||
if (delegate_)
|
||||
delegate_->OnResponseStarted(response);
|
||||
return next_handler_->OnResponseStarted(response, defer);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
40
atom/browser/loader/layered_resource_handler.h
Normal file
40
atom/browser/loader/layered_resource_handler.h
Normal file
@@ -0,0 +1,40 @@
|
||||
// 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_LOADER_LAYERED_RESOURCE_HANDLER_H_
|
||||
#define ATOM_BROWSER_LOADER_LAYERED_RESOURCE_HANDLER_H_
|
||||
|
||||
#include "content/browser/loader/layered_resource_handler.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
// Resource handler that notifies on various stages of a resource request.
|
||||
class LayeredResourceHandler : public content::LayeredResourceHandler {
|
||||
public:
|
||||
class Delegate {
|
||||
public:
|
||||
Delegate() {}
|
||||
virtual ~Delegate() {}
|
||||
|
||||
virtual void OnResponseStarted(content::ResourceResponse* response) = 0;
|
||||
};
|
||||
|
||||
LayeredResourceHandler(net::URLRequest* request,
|
||||
std::unique_ptr<content::ResourceHandler> next_handler,
|
||||
Delegate* delegate);
|
||||
~LayeredResourceHandler() override;
|
||||
|
||||
// content::LayeredResourceHandler:
|
||||
bool OnResponseStarted(content::ResourceResponse* response,
|
||||
bool* defer) override;
|
||||
|
||||
private:
|
||||
Delegate* delegate_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(LayeredResourceHandler);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_LOADER_LAYERED_RESOURCE_HANDLER_H_
|
||||
@@ -16,13 +16,15 @@ class DictionaryValue;
|
||||
|
||||
namespace atom {
|
||||
|
||||
NSArray* ListValueToNSArray(const base::ListValue& value);
|
||||
|
||||
std::unique_ptr<base::ListValue> NSArrayToListValue(NSArray* arr);
|
||||
|
||||
NSDictionary* DictionaryValueToNSDictionary(const base::DictionaryValue& value);
|
||||
|
||||
std::unique_ptr<base::DictionaryValue> NSDictionaryToDictionaryValue(
|
||||
NSDictionary* dict);
|
||||
|
||||
std::unique_ptr<base::ListValue> NSArrayToListValue(NSArray* arr);
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_MAC_DICT_UTIL_H_
|
||||
|
||||
@@ -10,6 +10,18 @@
|
||||
|
||||
namespace atom {
|
||||
|
||||
NSArray* ListValueToNSArray(const base::ListValue& value) {
|
||||
std::string json;
|
||||
if (!base::JSONWriter::Write(value, &json))
|
||||
return nil;
|
||||
NSData* jsonData = [NSData dataWithBytes:json.c_str() length:json.length()];
|
||||
id obj =
|
||||
[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil];
|
||||
if (![obj isKindOfClass:[NSArray class]])
|
||||
return nil;
|
||||
return obj;
|
||||
}
|
||||
|
||||
std::unique_ptr<base::ListValue> NSArrayToListValue(NSArray* arr) {
|
||||
if (!arr)
|
||||
return nullptr;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "base/json/json_writer.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "brightray/browser/inspectable_web_contents.h"
|
||||
#include "brightray/browser/inspectable_web_contents_view.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
@@ -333,6 +334,19 @@ void NativeWindow::SetParentWindow(NativeWindow* parent) {
|
||||
parent_ = parent;
|
||||
}
|
||||
|
||||
void NativeWindow::SetAutoHideCursor(bool auto_hide) {
|
||||
}
|
||||
|
||||
void NativeWindow::SetVibrancy(const std::string& filename) {
|
||||
}
|
||||
|
||||
void NativeWindow::SetTouchBar(
|
||||
const std::vector<mate::PersistentDictionary>& items) {
|
||||
}
|
||||
|
||||
void NativeWindow::RefreshTouchBarItem(const std::string& item_id) {
|
||||
}
|
||||
|
||||
void NativeWindow::FocusOnWebView() {
|
||||
web_contents()->GetRenderViewHost()->GetWidget()->Focus();
|
||||
}
|
||||
@@ -374,11 +388,17 @@ void NativeWindow::SetAspectRatio(double aspect_ratio,
|
||||
aspect_ratio_extraSize_ = extra_size;
|
||||
}
|
||||
|
||||
void NativeWindow::PreviewFile(const std::string& path,
|
||||
const std::string& display_name) {
|
||||
}
|
||||
|
||||
void NativeWindow::CloseFilePreview() {
|
||||
}
|
||||
|
||||
void NativeWindow::RequestToClosePage() {
|
||||
bool prevent_default = false;
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver,
|
||||
observers_,
|
||||
WillCloseWindow(&prevent_default));
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.WillCloseWindow(&prevent_default);
|
||||
if (prevent_default) {
|
||||
WindowList::WindowCloseCancelled(this);
|
||||
return;
|
||||
@@ -409,8 +429,8 @@ void NativeWindow::CloseContents(content::WebContents* source) {
|
||||
inspectable_web_contents_ = nullptr;
|
||||
Observe(nullptr);
|
||||
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
|
||||
WillDestroyNativeObject());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.WillDestroyNativeObject();
|
||||
|
||||
// When the web contents is gone, close the window immediately, but the
|
||||
// memory will not be freed until you call delete.
|
||||
@@ -436,7 +456,8 @@ void NativeWindow::RendererUnresponsive(content::WebContents* source) {
|
||||
|
||||
void NativeWindow::RendererResponsive(content::WebContents* source) {
|
||||
window_unresposive_closure_.Cancel();
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRendererResponsive());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnRendererResponsive();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowClosed() {
|
||||
@@ -446,104 +467,123 @@ void NativeWindow::NotifyWindowClosed() {
|
||||
WindowList::RemoveWindow(this);
|
||||
|
||||
is_closed_ = true;
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowClosed());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowClosed();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowBlur() {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowBlur());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowBlur();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowFocus() {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowFocus());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowFocus();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowShow() {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowShow());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowShow();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowHide() {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowHide());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowHide();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowMaximize() {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowMaximize());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowMaximize();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowUnmaximize() {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowUnmaximize());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowUnmaximize();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowMinimize() {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowMinimize());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowMinimize();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowRestore() {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowRestore());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowRestore();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowResize() {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowResize());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowResize();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowMove() {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowMove());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowMove();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowMoved() {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowMoved());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowMoved();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowEnterFullScreen() {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
|
||||
OnWindowEnterFullScreen());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowEnterFullScreen();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowScrollTouchBegin() {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
|
||||
OnWindowScrollTouchBegin());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowScrollTouchBegin();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowScrollTouchEnd() {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
|
||||
OnWindowScrollTouchEnd());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowScrollTouchEnd();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowScrollTouchEdge() {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
|
||||
OnWindowScrollTouchEdge());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowScrollTouchEdge();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowSwipe(const std::string& direction) {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
|
||||
OnWindowSwipe(direction));
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowSwipe(direction);
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowLeaveFullScreen() {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
|
||||
OnWindowLeaveFullScreen());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowLeaveFullScreen();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowEnterHtmlFullScreen() {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
|
||||
OnWindowEnterHtmlFullScreen());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowEnterHtmlFullScreen();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowLeaveHtmlFullScreen() {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
|
||||
OnWindowLeaveHtmlFullScreen());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowLeaveHtmlFullScreen();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowExecuteWindowsCommand(
|
||||
const std::string& command) {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
|
||||
OnExecuteWindowsCommand(command));
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnExecuteWindowsCommand(command);
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyTouchBarItemInteraction(
|
||||
const std::string& item_id,
|
||||
const base::DictionaryValue& details) {
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnTouchBarItemResult(item_id, details);
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
void NativeWindow::NotifyWindowMessage(
|
||||
UINT message, WPARAM w_param, LPARAM l_param) {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
|
||||
OnWindowMessage(message, w_param, l_param));
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowMessage(message, w_param, l_param);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -591,7 +631,7 @@ void NativeWindow::DidFirstVisuallyNonEmptyPaint() {
|
||||
view->SetSize(GetContentSize());
|
||||
|
||||
// Emit the ReadyToShow event in next tick in case of pending drawing work.
|
||||
base::MessageLoop::current()->PostTask(
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&NativeWindow::NotifyReadyToShow, GetWeakPtr()));
|
||||
}
|
||||
@@ -622,7 +662,7 @@ void NativeWindow::ScheduleUnresponsiveEvent(int ms) {
|
||||
window_unresposive_closure_.Reset(
|
||||
base::Bind(&NativeWindow::NotifyWindowUnresponsive,
|
||||
weak_factory_.GetWeakPtr()));
|
||||
base::MessageLoop::current()->PostDelayedTask(
|
||||
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
||||
FROM_HERE,
|
||||
window_unresposive_closure_.callback(),
|
||||
base::TimeDelta::FromMilliseconds(ms));
|
||||
@@ -631,14 +671,15 @@ void NativeWindow::ScheduleUnresponsiveEvent(int ms) {
|
||||
void NativeWindow::NotifyWindowUnresponsive() {
|
||||
window_unresposive_closure_.Cancel();
|
||||
|
||||
if (!is_closed_ && !IsUnresponsiveEventSuppressed() && IsEnabled())
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver,
|
||||
observers_,
|
||||
OnRendererUnresponsive());
|
||||
if (!is_closed_ && !IsUnresponsiveEventSuppressed() && IsEnabled()) {
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnRendererUnresponsive();
|
||||
}
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyReadyToShow() {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnReadyToShow());
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnReadyToShow();
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "content/public/browser/web_contents_user_data.h"
|
||||
#include "extensions/browser/app_window/size_constraints.h"
|
||||
#include "native_mate/persistent_dictionary.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
|
||||
@@ -119,9 +120,12 @@ class NativeWindow : public base::SupportsUserData,
|
||||
virtual void SetClosable(bool closable) = 0;
|
||||
virtual bool IsClosable() = 0;
|
||||
virtual void SetAlwaysOnTop(bool top,
|
||||
const std::string& level = "floating") = 0;
|
||||
const std::string& level = "floating",
|
||||
int relativeLevel = 0,
|
||||
std::string* error = nullptr) = 0;
|
||||
virtual bool IsAlwaysOnTop() = 0;
|
||||
virtual void Center() = 0;
|
||||
virtual void Invalidate() = 0;
|
||||
virtual void SetTitle(const std::string& title) = 0;
|
||||
virtual std::string GetTitle() = 0;
|
||||
virtual void FlashFrame(bool flash) = 0;
|
||||
@@ -161,6 +165,16 @@ class NativeWindow : public base::SupportsUserData,
|
||||
virtual void SetVisibleOnAllWorkspaces(bool visible) = 0;
|
||||
virtual bool IsVisibleOnAllWorkspaces() = 0;
|
||||
|
||||
virtual void SetAutoHideCursor(bool auto_hide);
|
||||
|
||||
// Vibrancy API
|
||||
virtual void SetVibrancy(const std::string& type);
|
||||
|
||||
// Touchbar API
|
||||
virtual void SetTouchBar(
|
||||
const std::vector<mate::PersistentDictionary>& items);
|
||||
virtual void RefreshTouchBarItem(const std::string& item_id);
|
||||
|
||||
// Webview APIs.
|
||||
virtual void FocusOnWebView();
|
||||
virtual void BlurWebView();
|
||||
@@ -177,6 +191,11 @@ class NativeWindow : public base::SupportsUserData,
|
||||
gfx::Size GetAspectRatioExtraSize();
|
||||
virtual void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size);
|
||||
|
||||
// File preview APIs.
|
||||
virtual void PreviewFile(const std::string& path,
|
||||
const std::string& display_name);
|
||||
virtual void CloseFilePreview();
|
||||
|
||||
base::WeakPtr<NativeWindow> GetWeakPtr() {
|
||||
return weak_factory_.GetWeakPtr();
|
||||
}
|
||||
@@ -215,6 +234,8 @@ class NativeWindow : public base::SupportsUserData,
|
||||
void NotifyWindowEnterHtmlFullScreen();
|
||||
void NotifyWindowLeaveHtmlFullScreen();
|
||||
void NotifyWindowExecuteWindowsCommand(const std::string& command);
|
||||
void NotifyTouchBarItemInteraction(const std::string& item_id,
|
||||
const base::DictionaryValue& details);
|
||||
|
||||
#if defined(OS_WIN)
|
||||
void NotifyWindowMessage(UINT message, WPARAM w_param, LPARAM l_param);
|
||||
|
||||
@@ -55,6 +55,9 @@ class NativeWindowMac : public NativeWindow,
|
||||
void SetMovable(bool movable) override;
|
||||
void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size)
|
||||
override;
|
||||
void PreviewFile(const std::string& path, const std::string& display_name)
|
||||
override;
|
||||
void CloseFilePreview() override;
|
||||
bool IsMovable() override;
|
||||
void SetMinimizable(bool minimizable) override;
|
||||
bool IsMinimizable() override;
|
||||
@@ -64,9 +67,11 @@ class NativeWindowMac : public NativeWindow,
|
||||
bool IsFullScreenable() override;
|
||||
void SetClosable(bool closable) override;
|
||||
bool IsClosable() override;
|
||||
void SetAlwaysOnTop(bool top, const std::string& level) override;
|
||||
void SetAlwaysOnTop(bool top, const std::string& level,
|
||||
int relativeLevel, std::string* error) override;
|
||||
bool IsAlwaysOnTop() override;
|
||||
void Center() override;
|
||||
void Invalidate() override;
|
||||
void SetTitle(const std::string& title) override;
|
||||
std::string GetTitle() override;
|
||||
void FlashFrame(bool flash) override;
|
||||
@@ -88,9 +93,17 @@ class NativeWindowMac : public NativeWindow,
|
||||
void SetProgressBar(double progress, const ProgressState state) override;
|
||||
void SetOverlayIcon(const gfx::Image& overlay,
|
||||
const std::string& description) override;
|
||||
|
||||
void SetVisibleOnAllWorkspaces(bool visible) override;
|
||||
bool IsVisibleOnAllWorkspaces() override;
|
||||
|
||||
void SetAutoHideCursor(bool auto_hide) override;
|
||||
|
||||
void SetVibrancy(const std::string& type) override;
|
||||
void SetTouchBar(
|
||||
const std::vector<mate::PersistentDictionary>& items) override;
|
||||
void RefreshTouchBarItem(const std::string& item_id) override;
|
||||
|
||||
// content::RenderWidgetHost::InputEventObserver:
|
||||
void OnInputEvent(const blink::WebInputEvent& event) override;
|
||||
|
||||
@@ -114,6 +127,8 @@ class NativeWindowMac : public NativeWindow,
|
||||
};
|
||||
TitleBarStyle title_bar_style() const { return title_bar_style_; }
|
||||
|
||||
bool zoom_to_page_width() const { return zoom_to_page_width_; }
|
||||
|
||||
protected:
|
||||
// Return a vector of non-draggable regions that fill a window of size
|
||||
// |width| by |height|, but leave gaps where the window should be draggable.
|
||||
@@ -152,6 +167,10 @@ class NativeWindowMac : public NativeWindow,
|
||||
|
||||
bool is_kiosk_;
|
||||
|
||||
bool was_fullscreen_;
|
||||
|
||||
bool zoom_to_page_width_;
|
||||
|
||||
NSInteger attention_request_id_; // identifier from requestUserAttention
|
||||
|
||||
// The presentation options before entering kiosk mode.
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
|
||||
#include "atom/browser/native_window_mac.h"
|
||||
|
||||
#include <Quartz/Quartz.h>
|
||||
#include <string>
|
||||
|
||||
#include "atom/browser/ui/cocoa/atom_touch_bar.h"
|
||||
#include "atom/browser/window_list.h"
|
||||
#include "atom/common/color_util.h"
|
||||
#include "atom/common/draggable_region.h"
|
||||
@@ -101,6 +103,41 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Called when the user clicks the zoom button or selects it from the Window
|
||||
// menu to determine the "standard size" of the window.
|
||||
- (NSRect)windowWillUseStandardFrame:(NSWindow*)window
|
||||
defaultFrame:(NSRect)frame {
|
||||
if (!shell_->zoom_to_page_width())
|
||||
return frame;
|
||||
|
||||
// If the shift key is down, maximize.
|
||||
if ([[NSApp currentEvent] modifierFlags] & NSShiftKeyMask)
|
||||
return frame;
|
||||
|
||||
content::WebContents* web_contents = shell_->web_contents();
|
||||
if (!web_contents)
|
||||
return frame;
|
||||
|
||||
CGFloat page_width = static_cast<CGFloat>(
|
||||
web_contents->GetPreferredSize().width());
|
||||
NSRect window_frame = [window frame];
|
||||
|
||||
// Never shrink from the current size on zoom.
|
||||
CGFloat zoomed_width = std::max(page_width, NSWidth(window_frame));
|
||||
|
||||
// |frame| determines our maximum extents. We need to set the origin of the
|
||||
// frame -- and only move it left if necessary.
|
||||
if (window_frame.origin.x + zoomed_width > NSMaxX(frame))
|
||||
frame.origin.x = NSMaxX(frame) - zoomed_width;
|
||||
else
|
||||
frame.origin.x = window_frame.origin.x;
|
||||
|
||||
// Set the width. Don't touch y or height.
|
||||
frame.size.width = zoomed_width;
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
- (void)windowDidBecomeMain:(NSNotification*)notification {
|
||||
content::WebContents* web_contents = shell_->web_contents();
|
||||
if (!web_contents)
|
||||
@@ -192,7 +229,7 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||
- (void)windowWillEnterFullScreen:(NSNotification*)notification {
|
||||
// Hide the native toolbar before entering fullscreen, so there is no visual
|
||||
// artifacts.
|
||||
if (base::mac::IsOSYosemiteOrLater() &&
|
||||
if (base::mac::IsAtLeastOS10_10() &&
|
||||
shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
|
||||
NSWindow* window = shell_->GetNativeWindow();
|
||||
[window setToolbar:nil];
|
||||
@@ -207,7 +244,7 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||
// have to set one, because title bar is visible here.
|
||||
NSWindow* window = shell_->GetNativeWindow();
|
||||
if ((shell_->transparent() || !shell_->has_frame()) &&
|
||||
base::mac::IsOSYosemiteOrLater() &&
|
||||
base::mac::IsAtLeastOS10_10() &&
|
||||
// FIXME(zcbenz): Showing titlebar for hiddenInset window is weird under
|
||||
// fullscreen mode.
|
||||
shell_->title_bar_style() != atom::NativeWindowMac::HIDDEN_INSET) {
|
||||
@@ -216,7 +253,7 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||
|
||||
// Restore the native toolbar immediately after entering fullscreen, if we do
|
||||
// this before leaving fullscreen, traffic light buttons will be jumping.
|
||||
if (base::mac::IsOSYosemiteOrLater() &&
|
||||
if (base::mac::IsAtLeastOS10_10() &&
|
||||
shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
|
||||
base::scoped_nsobject<NSToolbar> toolbar(
|
||||
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
|
||||
@@ -233,13 +270,13 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||
// Restore the titlebar visibility.
|
||||
NSWindow* window = shell_->GetNativeWindow();
|
||||
if ((shell_->transparent() || !shell_->has_frame()) &&
|
||||
base::mac::IsOSYosemiteOrLater() &&
|
||||
base::mac::IsAtLeastOS10_10() &&
|
||||
shell_->title_bar_style() != atom::NativeWindowMac::HIDDEN_INSET) {
|
||||
[window setTitleVisibility:NSWindowTitleHidden];
|
||||
}
|
||||
|
||||
// Turn off the style for toolbar.
|
||||
if (base::mac::IsOSYosemiteOrLater() &&
|
||||
if (base::mac::IsAtLeastOS10_10() &&
|
||||
shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
|
||||
shell_->SetStyleMask(false, NSFullSizeContentViewWindowMask);
|
||||
}
|
||||
@@ -277,20 +314,48 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||
|
||||
@end
|
||||
|
||||
@interface AtomNSWindow : EventDispatchingWindow {
|
||||
@interface AtomPreviewItem : NSObject <QLPreviewItem>
|
||||
|
||||
@property (nonatomic, retain) NSURL* previewItemURL;
|
||||
@property (nonatomic, retain) NSString* previewItemTitle;
|
||||
|
||||
- (id)initWithURL:(NSURL*)url title:(NSString*)title;
|
||||
|
||||
@end
|
||||
|
||||
@implementation AtomPreviewItem
|
||||
|
||||
- (id)initWithURL:(NSURL*)url title:(NSString*)title {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.previewItemURL = url;
|
||||
self.previewItemTitle = title;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface AtomNSWindow : EventDispatchingWindow<QLPreviewPanelDataSource, QLPreviewPanelDelegate, NSTouchBarDelegate> {
|
||||
@private
|
||||
atom::NativeWindowMac* shell_;
|
||||
bool enable_larger_than_screen_;
|
||||
base::scoped_nsobject<AtomTouchBar> atom_touch_bar_;
|
||||
CGFloat windowButtonsInterButtonSpacing_;
|
||||
}
|
||||
@property BOOL acceptsFirstMouse;
|
||||
@property BOOL disableAutoHideCursor;
|
||||
@property BOOL disableKeyOrMainWindow;
|
||||
@property NSPoint windowButtonsOffset;
|
||||
@property (nonatomic, retain) AtomPreviewItem* quickLookItem;
|
||||
@property (nonatomic, retain) NSView* vibrantView;
|
||||
|
||||
- (void)setShell:(atom::NativeWindowMac*)shell;
|
||||
- (void)setEnableLargerThanScreen:(bool)enable;
|
||||
- (void)enableWindowButtonsOffset;
|
||||
- (void)resetTouchBar:(const std::vector<mate::PersistentDictionary>&)settings;
|
||||
- (void)refreshTouchBarItem:(const std::string&)item_id;
|
||||
|
||||
@end
|
||||
|
||||
@implementation AtomNSWindow
|
||||
@@ -303,6 +368,35 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||
enable_larger_than_screen_ = enable;
|
||||
}
|
||||
|
||||
- (void)resetTouchBar:(const std::vector<mate::PersistentDictionary>&)settings {
|
||||
if (![self respondsToSelector:@selector(touchBar)]) return;
|
||||
|
||||
atom_touch_bar_.reset([[AtomTouchBar alloc] initWithDelegate:self
|
||||
window:shell_
|
||||
settings:settings]);
|
||||
self.touchBar = nil;
|
||||
}
|
||||
|
||||
- (void)refreshTouchBarItem:(const std::string&)item_id {
|
||||
if (atom_touch_bar_ && self.touchBar)
|
||||
[atom_touch_bar_ refreshTouchBarItem:self.touchBar id:item_id];
|
||||
}
|
||||
|
||||
- (NSTouchBar*)makeTouchBar {
|
||||
if (atom_touch_bar_)
|
||||
return [atom_touch_bar_ makeTouchBar];
|
||||
else
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar
|
||||
makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier {
|
||||
if (touchBar && atom_touch_bar_)
|
||||
return [atom_touch_bar_ makeItemForIdentifier:identifier];
|
||||
else
|
||||
return nil;
|
||||
}
|
||||
|
||||
// NSWindow overrides.
|
||||
|
||||
- (void)swipeWithEvent:(NSEvent *)event {
|
||||
@@ -444,6 +538,36 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||
return [[self contentView] superview];
|
||||
}
|
||||
|
||||
// Quicklook methods
|
||||
|
||||
- (BOOL)acceptsPreviewPanelControl:(QLPreviewPanel*)panel {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)beginPreviewPanelControl:(QLPreviewPanel*)panel {
|
||||
panel.delegate = self;
|
||||
panel.dataSource = self;
|
||||
}
|
||||
|
||||
- (void)endPreviewPanelControl:(QLPreviewPanel*)panel {
|
||||
panel.delegate = nil;
|
||||
panel.dataSource = nil;
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfPreviewItemsInPreviewPanel:(QLPreviewPanel*)panel {
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (id <QLPreviewItem>)previewPanel:(QLPreviewPanel*)panel previewItemAtIndex:(NSInteger)index {
|
||||
return [self quickLookItem];
|
||||
}
|
||||
|
||||
- (void)previewFileAtPath:(NSString*)path withName:(NSString*) fileName {
|
||||
NSURL* url = [[[NSURL alloc] initFileURLWithPath:path] autorelease];
|
||||
[self setQuickLookItem:[[[AtomPreviewItem alloc] initWithURL:url title:fileName] autorelease]];
|
||||
[[QLPreviewPanel sharedPreviewPanel] makeKeyAndOrderFront:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface ControlRegionView : NSView
|
||||
@@ -529,13 +653,15 @@ NativeWindowMac::NativeWindowMac(
|
||||
NativeWindow* parent)
|
||||
: NativeWindow(web_contents, options, parent),
|
||||
is_kiosk_(false),
|
||||
was_fullscreen_(false),
|
||||
zoom_to_page_width_(false),
|
||||
attention_request_id_(0),
|
||||
title_bar_style_(NORMAL) {
|
||||
int width = 800, height = 600;
|
||||
options.Get(options::kWidth, &width);
|
||||
options.Get(options::kHeight, &height);
|
||||
|
||||
NSRect main_screen_rect = [[[NSScreen screens] objectAtIndex:0] frame];
|
||||
NSRect main_screen_rect = [[[NSScreen screens] firstObject] frame];
|
||||
NSRect cocoa_bounds = NSMakeRect(
|
||||
round((NSWidth(main_screen_rect) - width) / 2) ,
|
||||
round((NSHeight(main_screen_rect) - height) / 2),
|
||||
@@ -620,7 +746,7 @@ NativeWindowMac::NativeWindowMac(
|
||||
[window_ setDisableKeyOrMainWindow:YES];
|
||||
|
||||
if (transparent() || !has_frame()) {
|
||||
if (base::mac::IsOSYosemiteOrLater()) {
|
||||
if (base::mac::IsAtLeastOS10_10()) {
|
||||
// Don't show title bar.
|
||||
[window_ setTitleVisibility:NSWindowTitleHidden];
|
||||
}
|
||||
@@ -633,7 +759,7 @@ NativeWindowMac::NativeWindowMac(
|
||||
|
||||
// Hide the title bar.
|
||||
if (title_bar_style_ == HIDDEN_INSET) {
|
||||
if (base::mac::IsOSYosemiteOrLater()) {
|
||||
if (base::mac::IsAtLeastOS10_10()) {
|
||||
[window_ setTitlebarAppearsTransparent:YES];
|
||||
base::scoped_nsobject<NSToolbar> toolbar(
|
||||
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
|
||||
@@ -651,6 +777,8 @@ NativeWindowMac::NativeWindowMac(
|
||||
if (!has_frame() || !use_content_size)
|
||||
SetSize(gfx::Size(width, height));
|
||||
|
||||
options.Get(options::kZoomToPageWidth, &zoom_to_page_width_);
|
||||
|
||||
// Enable the NSView to accept first mouse event.
|
||||
bool acceptsFirstMouse = false;
|
||||
options.Get(options::kAcceptFirstMouse, &acceptsFirstMouse);
|
||||
@@ -689,6 +817,11 @@ NativeWindowMac::NativeWindowMac(
|
||||
|
||||
InstallView();
|
||||
|
||||
std::string type;
|
||||
if (options.Get(options::kVibrancyType, &type)) {
|
||||
SetVibrancy(type);
|
||||
}
|
||||
|
||||
// Set maximizable state last to ensure zoom button does not get reset
|
||||
// by calls to other APIs.
|
||||
SetMaximizable(maximizable);
|
||||
@@ -839,7 +972,7 @@ void NativeWindowMac::SetBounds(const gfx::Rect& bounds, bool animate) {
|
||||
|
||||
NSRect cocoa_bounds = NSMakeRect(bounds.x(), 0, size.width(), size.height());
|
||||
// Flip coordinates based on the primary screen.
|
||||
NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
|
||||
NSScreen* screen = [[NSScreen screens] firstObject];
|
||||
cocoa_bounds.origin.y =
|
||||
NSHeight([screen frame]) - size.height() - bounds.y();
|
||||
|
||||
@@ -849,7 +982,7 @@ void NativeWindowMac::SetBounds(const gfx::Rect& bounds, bool animate) {
|
||||
gfx::Rect NativeWindowMac::GetBounds() {
|
||||
NSRect frame = [window_ frame];
|
||||
gfx::Rect bounds(frame.origin.x, 0, NSWidth(frame), NSHeight(frame));
|
||||
NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
|
||||
NSScreen* screen = [[NSScreen screens] firstObject];
|
||||
bounds.set_y(NSHeight([screen frame]) - NSMaxY(frame));
|
||||
return bounds;
|
||||
}
|
||||
@@ -899,6 +1032,19 @@ void NativeWindowMac::SetAspectRatio(double aspect_ratio,
|
||||
[window_ setResizeIncrements:NSMakeSize(1.0, 1.0)];
|
||||
}
|
||||
|
||||
void NativeWindowMac::PreviewFile(const std::string& path,
|
||||
const std::string& display_name) {
|
||||
NSString* path_ns = [NSString stringWithUTF8String:path.c_str()];
|
||||
NSString* name_ns = [NSString stringWithUTF8String:display_name.c_str()];
|
||||
[window_ previewFileAtPath:path_ns withName:name_ns];
|
||||
}
|
||||
|
||||
void NativeWindowMac::CloseFilePreview() {
|
||||
if ([QLPreviewPanel sharedPreviewPanelExists]) {
|
||||
[[QLPreviewPanel sharedPreviewPanel] close];
|
||||
}
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetMovable(bool movable) {
|
||||
[window_ setMovable:movable];
|
||||
}
|
||||
@@ -944,8 +1090,12 @@ bool NativeWindowMac::IsClosable() {
|
||||
return [window_ styleMask] & NSClosableWindowMask;
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetAlwaysOnTop(bool top, const std::string& level) {
|
||||
void NativeWindowMac::SetAlwaysOnTop(bool top, const std::string& level,
|
||||
int relativeLevel, std::string* error) {
|
||||
int windowLevel = NSNormalWindowLevel;
|
||||
CGWindowLevel maxWindowLevel = CGWindowLevelForKey(kCGMaximumWindowLevelKey);
|
||||
CGWindowLevel minWindowLevel = CGWindowLevelForKey(kCGMinimumWindowLevelKey);
|
||||
|
||||
if (top) {
|
||||
if (level == "floating") {
|
||||
windowLevel = NSFloatingWindowLevel;
|
||||
@@ -962,10 +1112,19 @@ void NativeWindowMac::SetAlwaysOnTop(bool top, const std::string& level) {
|
||||
} else if (level == "screen-saver") {
|
||||
windowLevel = NSScreenSaverWindowLevel;
|
||||
} else if (level == "dock") {
|
||||
// Deprecated by macOS, but kept for backwards compatibility
|
||||
windowLevel = NSDockWindowLevel;
|
||||
}
|
||||
}
|
||||
[window_ setLevel:windowLevel];
|
||||
|
||||
NSInteger newLevel = windowLevel + relativeLevel;
|
||||
if (newLevel >= minWindowLevel && newLevel <= maxWindowLevel) {
|
||||
[window_ setLevel:newLevel];
|
||||
} else {
|
||||
*error = std::string([[NSString stringWithFormat:
|
||||
@"relativeLevel must be between %d and %d", minWindowLevel,
|
||||
maxWindowLevel] UTF8String]);
|
||||
}
|
||||
}
|
||||
|
||||
bool NativeWindowMac::IsAlwaysOnTop() {
|
||||
@@ -976,10 +1135,15 @@ void NativeWindowMac::Center() {
|
||||
[window_ center];
|
||||
}
|
||||
|
||||
void NativeWindowMac::Invalidate() {
|
||||
[window_ flushWindow];
|
||||
[[window_ contentView] setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetTitle(const std::string& title) {
|
||||
// For macOS <= 10.9, the setTitleVisibility API is not available, we have
|
||||
// to avoid calling setTitle for frameless window.
|
||||
if (!base::mac::IsOSYosemiteOrLater() && (transparent() || !has_frame()))
|
||||
if (!base::mac::IsAtLeastOS10_10() && (transparent() || !has_frame()))
|
||||
return;
|
||||
|
||||
[window_ setTitle:base::SysUTF8ToNSString(title)];
|
||||
@@ -1014,10 +1178,11 @@ void NativeWindowMac::SetKiosk(bool kiosk) {
|
||||
NSApplicationPresentationDisableHideApplication;
|
||||
[NSApp setPresentationOptions:options];
|
||||
is_kiosk_ = true;
|
||||
SetFullScreen(true);
|
||||
was_fullscreen_ = IsFullscreen();
|
||||
if (!was_fullscreen_) SetFullScreen(true);
|
||||
} else if (!kiosk && is_kiosk_) {
|
||||
is_kiosk_ = false;
|
||||
SetFullScreen(false);
|
||||
if (!was_fullscreen_) SetFullScreen(false);
|
||||
[NSApp setPresentationOptions:kiosk_options_];
|
||||
}
|
||||
}
|
||||
@@ -1144,6 +1309,86 @@ bool NativeWindowMac::IsVisibleOnAllWorkspaces() {
|
||||
return collectionBehavior & NSWindowCollectionBehaviorCanJoinAllSpaces;
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetAutoHideCursor(bool auto_hide) {
|
||||
[window_ setDisableAutoHideCursor:!auto_hide];
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetVibrancy(const std::string& type) {
|
||||
if (!base::mac::IsAtLeastOS10_10()) return;
|
||||
|
||||
NSView* vibrant_view = [window_ vibrantView];
|
||||
|
||||
if (type.empty()) {
|
||||
if (vibrant_view == nil) return;
|
||||
|
||||
[vibrant_view removeFromSuperview];
|
||||
[window_ setVibrantView:nil];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view;
|
||||
if (effect_view == nil) {
|
||||
effect_view = [[[NSVisualEffectView alloc]
|
||||
initWithFrame: [[window_ contentView] bounds]] autorelease];
|
||||
[window_ setVibrantView:(NSView*)effect_view];
|
||||
|
||||
[effect_view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||
[effect_view setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
|
||||
[effect_view setState:NSVisualEffectStateActive];
|
||||
[[window_ contentView] addSubview:effect_view
|
||||
positioned:NSWindowBelow
|
||||
relativeTo:nil];
|
||||
}
|
||||
|
||||
NSVisualEffectMaterial vibrancyType = NSVisualEffectMaterialLight;
|
||||
|
||||
if (type == "appearance-based") {
|
||||
vibrancyType = NSVisualEffectMaterialAppearanceBased;
|
||||
} else if (type == "light") {
|
||||
vibrancyType = NSVisualEffectMaterialLight;
|
||||
} else if (type == "dark") {
|
||||
vibrancyType = NSVisualEffectMaterialDark;
|
||||
} else if (type == "titlebar") {
|
||||
vibrancyType = NSVisualEffectMaterialTitlebar;
|
||||
}
|
||||
|
||||
if (base::mac::IsAtLeastOS10_11()) {
|
||||
// TODO(kevinsawicki): Use NSVisualEffectMaterial* constants directly once
|
||||
// they are available in the minimum SDK version
|
||||
if (type == "selection") {
|
||||
// NSVisualEffectMaterialSelection
|
||||
vibrancyType = (NSVisualEffectMaterial) 4;
|
||||
} else if (type == "menu") {
|
||||
// NSVisualEffectMaterialMenu
|
||||
vibrancyType = (NSVisualEffectMaterial) 5;
|
||||
} else if (type == "popover") {
|
||||
// NSVisualEffectMaterialPopover
|
||||
vibrancyType = (NSVisualEffectMaterial) 6;
|
||||
} else if (type == "sidebar") {
|
||||
// NSVisualEffectMaterialSidebar
|
||||
vibrancyType = (NSVisualEffectMaterial) 7;
|
||||
} else if (type == "medium-light") {
|
||||
// NSVisualEffectMaterialMediumLight
|
||||
vibrancyType = (NSVisualEffectMaterial) 8;
|
||||
} else if (type == "ultra-dark") {
|
||||
// NSVisualEffectMaterialUltraDark
|
||||
vibrancyType = (NSVisualEffectMaterial) 9;
|
||||
}
|
||||
}
|
||||
|
||||
[effect_view setMaterial:vibrancyType];
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetTouchBar(
|
||||
const std::vector<mate::PersistentDictionary>& items) {
|
||||
[window_ resetTouchBar:items];
|
||||
}
|
||||
|
||||
void NativeWindowMac::RefreshTouchBarItem(const std::string& item_id) {
|
||||
[window_ refreshTouchBarItem:item_id];
|
||||
}
|
||||
|
||||
void NativeWindowMac::OnInputEvent(const blink::WebInputEvent& event) {
|
||||
switch (event.type) {
|
||||
case blink::WebInputEvent::GestureScrollBegin:
|
||||
@@ -1219,10 +1464,10 @@ void NativeWindowMac::ShowWindowButton(NSWindowButton button) {
|
||||
}
|
||||
|
||||
void NativeWindowMac::InstallView() {
|
||||
// Make sure the bottom corner is rounded: http://crbug.com/396264.
|
||||
// Make sure the bottom corner is rounded for non-modal windows: http://crbug.com/396264.
|
||||
// But do not enable it on OS X 10.9 for transparent window, otherwise a
|
||||
// semi-transparent frame would show.
|
||||
if (!(transparent() && base::mac::IsOSMavericks()))
|
||||
if (!(transparent() && base::mac::IsOS10_9()) && !is_modal())
|
||||
[[window_ contentView] setWantsLayer:YES];
|
||||
|
||||
NSView* view = inspectable_web_contents()->GetView()->GetNativeView();
|
||||
@@ -1247,7 +1492,7 @@ void NativeWindowMac::InstallView() {
|
||||
[[window_ standardWindowButton:NSWindowFullScreenButton] setHidden:YES];
|
||||
|
||||
if (title_bar_style_ != NORMAL) {
|
||||
if (base::mac::IsOSMavericks()) {
|
||||
if (base::mac::IsOS10_9()) {
|
||||
ShowWindowButton(NSWindowZoomButton);
|
||||
ShowWindowButton(NSWindowMiniaturizeButton);
|
||||
ShowWindowButton(NSWindowCloseButton);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "base/strings/string16.h"
|
||||
#include "base/values.h"
|
||||
#include "ui/base/window_open_disposition.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
@@ -70,6 +71,8 @@ class NativeWindowObserver {
|
||||
virtual void OnWindowLeaveFullScreen() {}
|
||||
virtual void OnWindowEnterHtmlFullScreen() {}
|
||||
virtual void OnWindowLeaveHtmlFullScreen() {}
|
||||
virtual void OnTouchBarItemResult(const std::string& item_id,
|
||||
const base::DictionaryValue& details) {}
|
||||
|
||||
// Called when window message received
|
||||
#if defined(OS_WIN)
|
||||
|
||||
@@ -41,13 +41,14 @@
|
||||
#include "atom/browser/ui/x/window_state_watcher.h"
|
||||
#include "atom/browser/ui/x/x_window_utils.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "chrome/browser/ui/libgtk2ui/unity_service.h"
|
||||
#include "chrome/browser/ui/libgtkui/unity_service.h"
|
||||
#include "ui/base/x/x11_util.h"
|
||||
#include "ui/gfx/x/x11_types.h"
|
||||
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
|
||||
#include "ui/views/window/native_frame_view.h"
|
||||
#elif defined(OS_WIN)
|
||||
#include "atom/browser/ui/views/win_frame_view.h"
|
||||
#include "atom/browser/ui/win/atom_desktop_native_widget_aura.h"
|
||||
#include "atom/browser/ui/win/atom_desktop_window_tree_host_win.h"
|
||||
#include "skia/ext/skia_utils_win.h"
|
||||
#include "ui/base/win/shell.h"
|
||||
@@ -204,8 +205,7 @@ NativeWindowViews::NativeWindowViews(
|
||||
if (parent)
|
||||
params.parent = parent->GetNativeWindow();
|
||||
|
||||
params.native_widget =
|
||||
new views::DesktopNativeWidgetAura(window_.get());
|
||||
params.native_widget = new AtomDesktopNativeWidgetAura(window_.get());
|
||||
atom_desktop_window_tree_host_win_ = new AtomDesktopWindowTreeHostWin(
|
||||
this,
|
||||
window_.get(),
|
||||
@@ -426,7 +426,7 @@ bool NativeWindowViews::IsEnabled() {
|
||||
void NativeWindowViews::Maximize() {
|
||||
#if defined(OS_WIN)
|
||||
// For window without WS_THICKFRAME style, we can not call Maximize().
|
||||
if (!thick_frame_) {
|
||||
if (!(::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_THICKFRAME)) {
|
||||
restore_bounds_ = GetBounds();
|
||||
auto display =
|
||||
display::Screen::GetScreen()->GetDisplayNearestPoint(GetPosition());
|
||||
@@ -444,7 +444,7 @@ void NativeWindowViews::Maximize() {
|
||||
|
||||
void NativeWindowViews::Unmaximize() {
|
||||
#if defined(OS_WIN)
|
||||
if (!thick_frame_) {
|
||||
if (!(::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_THICKFRAME)) {
|
||||
SetBounds(restore_bounds_, false);
|
||||
return;
|
||||
}
|
||||
@@ -488,6 +488,7 @@ void NativeWindowViews::SetFullScreen(bool fullscreen) {
|
||||
}
|
||||
|
||||
// For window without WS_THICKFRAME style, we can not call SetFullscreen().
|
||||
// This path will be used for transparent windows as well.
|
||||
if (!thick_frame_) {
|
||||
if (fullscreen) {
|
||||
restore_bounds_ = GetBounds();
|
||||
@@ -572,7 +573,7 @@ void NativeWindowViews::SetContentSizeConstraints(
|
||||
|
||||
void NativeWindowViews::SetResizable(bool resizable) {
|
||||
#if defined(OS_WIN)
|
||||
if (thick_frame_)
|
||||
if (has_frame())
|
||||
FlipWindowStyle(GetAcceleratedWidget(), resizable, WS_THICKFRAME);
|
||||
#elif defined(USE_X11)
|
||||
if (resizable != resizable_) {
|
||||
@@ -595,11 +596,10 @@ void NativeWindowViews::SetResizable(bool resizable) {
|
||||
|
||||
bool NativeWindowViews::IsResizable() {
|
||||
#if defined(OS_WIN)
|
||||
if (thick_frame_) {
|
||||
if (has_frame())
|
||||
return ::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_THICKFRAME;
|
||||
} else {
|
||||
else
|
||||
return CanResize();
|
||||
}
|
||||
#else
|
||||
return CanResize();
|
||||
#endif
|
||||
@@ -682,7 +682,8 @@ bool NativeWindowViews::IsClosable() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void NativeWindowViews::SetAlwaysOnTop(bool top, const std::string& level) {
|
||||
void NativeWindowViews::SetAlwaysOnTop(bool top, const std::string& level,
|
||||
int relativeLevel, std::string* error) {
|
||||
window_->SetAlwaysOnTop(top);
|
||||
}
|
||||
|
||||
@@ -694,6 +695,10 @@ void NativeWindowViews::Center() {
|
||||
window_->CenterWindow(GetSize());
|
||||
}
|
||||
|
||||
void NativeWindowViews::Invalidate() {
|
||||
window_->SchedulePaintInRect(gfx::Rect(GetBounds().size()));
|
||||
}
|
||||
|
||||
void NativeWindowViews::SetTitle(const std::string& title) {
|
||||
title_ = title;
|
||||
window_->UpdateWindowTitle();
|
||||
@@ -846,7 +851,7 @@ void NativeWindowViews::SetMenu(AtomMenuModel* menu_model) {
|
||||
|
||||
if (!menu_bar_) {
|
||||
gfx::Size content_size = GetContentSize();
|
||||
menu_bar_.reset(new MenuBar);
|
||||
menu_bar_.reset(new MenuBar(this));
|
||||
menu_bar_->set_owned_by_client();
|
||||
|
||||
if (!menu_bar_autohide_) {
|
||||
|
||||
@@ -86,9 +86,11 @@ class NativeWindowViews : public NativeWindow,
|
||||
bool IsFullScreenable() override;
|
||||
void SetClosable(bool closable) override;
|
||||
bool IsClosable() override;
|
||||
void SetAlwaysOnTop(bool top, const std::string& level) override;
|
||||
void SetAlwaysOnTop(bool top, const std::string& level,
|
||||
int relativeLevel, std::string* error) override;
|
||||
bool IsAlwaysOnTop() override;
|
||||
void Center() override;
|
||||
void Invalidate() override;
|
||||
void SetTitle(const std::string& title) override;
|
||||
std::string GetTitle() override;
|
||||
void FlashFrame(bool flash) override;
|
||||
@@ -216,6 +218,7 @@ class NativeWindowViews : public NativeWindow,
|
||||
// size of the window while in the normal state (not maximized, minimized or
|
||||
// fullscreen), so we restore it correctly.
|
||||
gfx::Rect last_normal_bounds_;
|
||||
gfx::Rect last_normal_bounds_before_move_;
|
||||
|
||||
// last_normal_bounds_ may or may not require update on WM_MOVE. When a
|
||||
// window is maximized, it is moved (WM_MOVE) to maximum size first and then
|
||||
|
||||
@@ -125,9 +125,12 @@ bool NativeWindowViews::PreHandleMSG(
|
||||
return taskbar_host_.HandleThumbarButtonEvent(LOWORD(w_param));
|
||||
return false;
|
||||
case WM_SIZE: {
|
||||
consecutive_moves_ = false;
|
||||
// Handle window state change.
|
||||
HandleSizeEvent(w_param, l_param);
|
||||
|
||||
consecutive_moves_ = false;
|
||||
last_normal_bounds_before_move_ = last_normal_bounds_;
|
||||
|
||||
return false;
|
||||
}
|
||||
case WM_MOVING: {
|
||||
@@ -155,6 +158,9 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
|
||||
switch (w_param) {
|
||||
case SIZE_MAXIMIZED:
|
||||
last_window_state_ = ui::SHOW_STATE_MAXIMIZED;
|
||||
if (consecutive_moves_) {
|
||||
last_normal_bounds_ = last_normal_bounds_before_move_;
|
||||
}
|
||||
NotifyWindowMaximize();
|
||||
break;
|
||||
case SIZE_MINIMIZED:
|
||||
@@ -165,14 +171,14 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
|
||||
if (last_window_state_ == ui::SHOW_STATE_NORMAL) {
|
||||
// Window was resized so we save it's new size.
|
||||
last_normal_bounds_ = GetBounds();
|
||||
last_normal_bounds_before_move_ = last_normal_bounds_;
|
||||
} else {
|
||||
switch (last_window_state_) {
|
||||
case ui::SHOW_STATE_MAXIMIZED:
|
||||
last_window_state_ = ui::SHOW_STATE_NORMAL;
|
||||
|
||||
// When the window is restored we resize it to the previous known
|
||||
// normal size.
|
||||
SetBounds(last_normal_bounds_, false);
|
||||
// Don't force out last known bounds onto the window as Windows
|
||||
// actually gets these correct
|
||||
|
||||
NotifyWindowUnmaximize();
|
||||
break;
|
||||
|
||||
25
atom/browser/net/about_protocol_handler.cc
Normal file
25
atom/browser/net/about_protocol_handler.cc
Normal file
@@ -0,0 +1,25 @@
|
||||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/net/about_protocol_handler.h"
|
||||
|
||||
#include "atom/browser/net/url_request_about_job.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
AboutProtocolHandler::AboutProtocolHandler() {}
|
||||
|
||||
AboutProtocolHandler::~AboutProtocolHandler() {}
|
||||
|
||||
net::URLRequestJob* AboutProtocolHandler::MaybeCreateJob(
|
||||
net::URLRequest* request,
|
||||
net::NetworkDelegate* network_delegate) const {
|
||||
return new URLRequestAboutJob(request, network_delegate);
|
||||
}
|
||||
|
||||
bool AboutProtocolHandler::IsSafeRedirectTarget(const GURL& location) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
29
atom/browser/net/about_protocol_handler.h
Normal file
29
atom/browser/net/about_protocol_handler.h
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_NET_ABOUT_PROTOCOL_HANDLER_H_
|
||||
#define ATOM_BROWSER_NET_ABOUT_PROTOCOL_HANDLER_H_
|
||||
|
||||
#include "net/url_request/url_request_job_factory.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class AboutProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler {
|
||||
public:
|
||||
AboutProtocolHandler();
|
||||
~AboutProtocolHandler() override;
|
||||
|
||||
// net::URLRequestJobFactory::ProtocolHandler:
|
||||
net::URLRequestJob* MaybeCreateJob(
|
||||
net::URLRequest* request,
|
||||
net::NetworkDelegate* network_delegate) const override;
|
||||
bool IsSafeRedirectTarget(const GURL& location) const override;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AboutProtocolHandler);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_NET_ABOUT_PROTOCOL_HANDLER_H_
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "net/base/load_flags.h"
|
||||
#include "net/base/mime_util.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/filter/filter.h"
|
||||
#include "net/filter/gzip_source_stream.h"
|
||||
#include "net/http/http_util.h"
|
||||
#include "net/url_request/url_request_status.h"
|
||||
|
||||
@@ -179,10 +179,14 @@ bool URLRequestAsarJob::IsRedirectResponse(GURL* location,
|
||||
#endif
|
||||
}
|
||||
|
||||
std::unique_ptr<net::Filter> URLRequestAsarJob::SetupFilter() const {
|
||||
std::unique_ptr<net::SourceStream> URLRequestAsarJob::SetUpSourceStream() {
|
||||
std::unique_ptr<net::SourceStream> source =
|
||||
net::URLRequestJob::SetUpSourceStream();
|
||||
// Bug 9936 - .svgz files needs to be decompressed.
|
||||
return base::LowerCaseEqualsASCII(file_path_.Extension(), ".svgz")
|
||||
? net::Filter::GZipFactory() : nullptr;
|
||||
? net::GzipSourceStream::Create(std::move(source),
|
||||
net::SourceStream::TYPE_GZIP)
|
||||
: std::move(source);
|
||||
}
|
||||
|
||||
bool URLRequestAsarJob::GetMimeType(std::string* mime_type) const {
|
||||
|
||||
@@ -56,7 +56,7 @@ class URLRequestAsarJob : public net::URLRequestJob {
|
||||
void Kill() override;
|
||||
int ReadRawData(net::IOBuffer* buf, int buf_size) override;
|
||||
bool IsRedirectResponse(GURL* location, int* http_status_code) override;
|
||||
std::unique_ptr<net::Filter> SetupFilter() const override;
|
||||
std::unique_ptr<net::SourceStream> SetUpSourceStream() override;
|
||||
bool GetMimeType(std::string* mime_type) const override;
|
||||
void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers) override;
|
||||
int GetResponseCode() const override;
|
||||
|
||||
@@ -5,9 +5,14 @@
|
||||
#include "atom/browser/net/atom_cert_verifier.h"
|
||||
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/browser/net/atom_ct_delegate.h"
|
||||
#include "atom/common/native_mate_converters/net_converter.h"
|
||||
#include "base/containers/linked_list.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/cert/cert_verify_result.h"
|
||||
#include "net/cert/crl_set.h"
|
||||
#include "net/cert/x509_certificate.h"
|
||||
|
||||
@@ -17,23 +22,135 @@ namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
void OnResult(
|
||||
net::CertVerifyResult* verify_result,
|
||||
const net::CompletionCallback& callback,
|
||||
bool result) {
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(callback, result ? net::OK : net::ERR_FAILED));
|
||||
}
|
||||
class Response : public base::LinkNode<Response> {
|
||||
public:
|
||||
Response(net::CertVerifyResult* verify_result,
|
||||
const net::CompletionCallback& callback)
|
||||
: verify_result_(verify_result), callback_(callback) {}
|
||||
net::CertVerifyResult* verify_result() { return verify_result_; }
|
||||
net::CompletionCallback callback() { return callback_; }
|
||||
|
||||
private:
|
||||
net::CertVerifyResult* verify_result_;
|
||||
net::CompletionCallback callback_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Response);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
AtomCertVerifier::AtomCertVerifier()
|
||||
: default_cert_verifier_(net::CertVerifier::CreateDefault()) {
|
||||
}
|
||||
class CertVerifierRequest : public AtomCertVerifier::Request {
|
||||
public:
|
||||
CertVerifierRequest(const AtomCertVerifier::RequestParams& params,
|
||||
AtomCertVerifier* cert_verifier)
|
||||
: params_(params),
|
||||
cert_verifier_(cert_verifier),
|
||||
error_(net::ERR_IO_PENDING),
|
||||
custom_response_(net::ERR_IO_PENDING),
|
||||
first_response_(true),
|
||||
weak_ptr_factory_(this) {}
|
||||
|
||||
AtomCertVerifier::~AtomCertVerifier() {
|
||||
}
|
||||
~CertVerifierRequest() {
|
||||
cert_verifier_->RemoveRequest(params_);
|
||||
default_verifier_request_.reset();
|
||||
while (!response_list_.empty() && !first_response_) {
|
||||
base::LinkNode<Response>* response_node = response_list_.head();
|
||||
response_node->RemoveFromList();
|
||||
Response* response = response_node->value();
|
||||
RunResponse(response);
|
||||
}
|
||||
cert_verifier_ = nullptr;
|
||||
weak_ptr_factory_.InvalidateWeakPtrs();
|
||||
}
|
||||
|
||||
void RunResponse(Response* response) {
|
||||
if (custom_response_ == net::ERR_ABORTED) {
|
||||
*(response->verify_result()) = result_;
|
||||
response->callback().Run(error_);
|
||||
} else {
|
||||
response->verify_result()->Reset();
|
||||
response->verify_result()->verified_cert = params_.certificate();
|
||||
cert_verifier_->ct_delegate()->AddCTExcludedHost(params_.hostname());
|
||||
response->callback().Run(custom_response_);
|
||||
}
|
||||
delete response;
|
||||
}
|
||||
|
||||
void Start(net::CRLSet* crl_set,
|
||||
const net::NetLogWithSource& net_log) {
|
||||
int error = cert_verifier_->default_verifier()->Verify(
|
||||
params_, crl_set, &result_,
|
||||
base::Bind(&CertVerifierRequest::OnDefaultVerificationDone,
|
||||
weak_ptr_factory_.GetWeakPtr()),
|
||||
&default_verifier_request_, net_log);
|
||||
if (error != net::ERR_IO_PENDING)
|
||||
OnDefaultVerificationDone(error);
|
||||
}
|
||||
|
||||
void OnDefaultVerificationDone(int error) {
|
||||
error_ = error;
|
||||
std::unique_ptr<VerifyRequestParams> request(new VerifyRequestParams());
|
||||
request->hostname = params_.hostname();
|
||||
request->default_result = net::ErrorToString(error);
|
||||
request->certificate = params_.certificate();
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(&CertVerifierRequest::OnVerifyRequestInUI,
|
||||
weak_ptr_factory_.GetWeakPtr(),
|
||||
cert_verifier_->verify_proc(),
|
||||
base::Passed(&request)));
|
||||
}
|
||||
|
||||
void OnVerifyRequestInUI(const AtomCertVerifier::VerifyProc& verify_proc,
|
||||
std::unique_ptr<VerifyRequestParams> request) {
|
||||
verify_proc.Run(*(request.get()),
|
||||
base::Bind(&CertVerifierRequest::OnResponseInUI,
|
||||
weak_ptr_factory_.GetWeakPtr()));
|
||||
}
|
||||
|
||||
void OnResponseInUI(int result) {
|
||||
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(&CertVerifierRequest::NotifyResponseInIO,
|
||||
weak_ptr_factory_.GetWeakPtr(), result));
|
||||
}
|
||||
|
||||
void NotifyResponseInIO(int result) {
|
||||
custom_response_ = result;
|
||||
first_response_ = false;
|
||||
// Responding to first request in the list will initiate destruction of
|
||||
// the class, respond to others in the list inside destructor.
|
||||
base::LinkNode<Response>* response_node = response_list_.head();
|
||||
response_node->RemoveFromList();
|
||||
Response* response = response_node->value();
|
||||
RunResponse(response);
|
||||
}
|
||||
|
||||
void AddResponseListener(net::CertVerifyResult* verify_result,
|
||||
const net::CompletionCallback& callback) {
|
||||
response_list_.Append(new Response(verify_result, callback));
|
||||
}
|
||||
|
||||
const AtomCertVerifier::RequestParams& params() const { return params_; }
|
||||
|
||||
private:
|
||||
using ResponseList = base::LinkedList<Response>;
|
||||
|
||||
const AtomCertVerifier::RequestParams params_;
|
||||
AtomCertVerifier* cert_verifier_;
|
||||
int error_;
|
||||
int custom_response_;
|
||||
bool first_response_;
|
||||
ResponseList response_list_;
|
||||
net::CertVerifyResult result_;
|
||||
std::unique_ptr<AtomCertVerifier::Request> default_verifier_request_;
|
||||
base::WeakPtrFactory<CertVerifierRequest> weak_ptr_factory_;
|
||||
};
|
||||
|
||||
AtomCertVerifier::AtomCertVerifier(AtomCTDelegate* ct_delegate)
|
||||
: default_cert_verifier_(net::CertVerifier::CreateDefault()),
|
||||
ct_delegate_(ct_delegate) {}
|
||||
|
||||
AtomCertVerifier::~AtomCertVerifier() {}
|
||||
|
||||
void AtomCertVerifier::SetVerifyProc(const VerifyProc& proc) {
|
||||
verify_proc_ = proc;
|
||||
@@ -45,22 +162,48 @@ int AtomCertVerifier::Verify(
|
||||
net::CertVerifyResult* verify_result,
|
||||
const net::CompletionCallback& callback,
|
||||
std::unique_ptr<Request>* out_req,
|
||||
const net::BoundNetLog& net_log) {
|
||||
const net::NetLogWithSource& net_log) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||
|
||||
if (verify_proc_.is_null())
|
||||
return default_cert_verifier_->Verify(
|
||||
params, crl_set, verify_result, callback, out_req, net_log);
|
||||
if (verify_proc_.is_null()) {
|
||||
ct_delegate_->ClearCTExcludedHostsList();
|
||||
return default_cert_verifier_->Verify(params, crl_set, verify_result,
|
||||
callback, out_req, net_log);
|
||||
} else {
|
||||
CertVerifierRequest* request = FindRequest(params);
|
||||
if (!request) {
|
||||
out_req->reset();
|
||||
std::unique_ptr<CertVerifierRequest> new_request =
|
||||
base::MakeUnique<CertVerifierRequest>(params, this);
|
||||
new_request->Start(crl_set, net_log);
|
||||
request = new_request.get();
|
||||
*out_req = std::move(new_request);
|
||||
inflight_requests_[params] = request;
|
||||
}
|
||||
request->AddResponseListener(verify_result, callback);
|
||||
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(verify_proc_, params.hostname(), params.certificate(),
|
||||
base::Bind(OnResult, verify_result, callback)));
|
||||
return net::ERR_IO_PENDING;
|
||||
return net::ERR_IO_PENDING;
|
||||
}
|
||||
}
|
||||
|
||||
bool AtomCertVerifier::SupportsOCSPStapling() {
|
||||
return true;
|
||||
if (verify_proc_.is_null())
|
||||
return default_cert_verifier_->SupportsOCSPStapling();
|
||||
return false;
|
||||
}
|
||||
|
||||
void AtomCertVerifier::RemoveRequest(const RequestParams& params) {
|
||||
auto it = inflight_requests_.find(params);
|
||||
if (it != inflight_requests_.end())
|
||||
inflight_requests_.erase(it);
|
||||
}
|
||||
|
||||
CertVerifierRequest* AtomCertVerifier::FindRequest(
|
||||
const RequestParams& params) {
|
||||
auto it = inflight_requests_.find(params);
|
||||
if (it != inflight_requests_.end())
|
||||
return it->second;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#ifndef ATOM_BROWSER_NET_ATOM_CERT_VERIFIER_H_
|
||||
#define ATOM_BROWSER_NET_ATOM_CERT_VERIFIER_H_
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
@@ -12,18 +13,31 @@
|
||||
|
||||
namespace atom {
|
||||
|
||||
class AtomCTDelegate;
|
||||
class CertVerifierRequest;
|
||||
|
||||
struct VerifyRequestParams {
|
||||
std::string hostname;
|
||||
std::string default_result;
|
||||
scoped_refptr<net::X509Certificate> certificate;
|
||||
};
|
||||
|
||||
class AtomCertVerifier : public net::CertVerifier {
|
||||
public:
|
||||
AtomCertVerifier();
|
||||
explicit AtomCertVerifier(AtomCTDelegate* ct_delegate);
|
||||
virtual ~AtomCertVerifier();
|
||||
|
||||
using VerifyProc =
|
||||
base::Callback<void(const std::string& hostname,
|
||||
scoped_refptr<net::X509Certificate>,
|
||||
const base::Callback<void(bool)>&)>;
|
||||
using VerifyProc = base::Callback<void(const VerifyRequestParams& request,
|
||||
const net::CompletionCallback&)>;
|
||||
|
||||
void SetVerifyProc(const VerifyProc& proc);
|
||||
|
||||
const VerifyProc verify_proc() const { return verify_proc_; }
|
||||
AtomCTDelegate* ct_delegate() const { return ct_delegate_; }
|
||||
net::CertVerifier* default_verifier() const {
|
||||
return default_cert_verifier_.get();
|
||||
}
|
||||
|
||||
protected:
|
||||
// net::CertVerifier:
|
||||
int Verify(const RequestParams& params,
|
||||
@@ -31,12 +45,19 @@ class AtomCertVerifier : public net::CertVerifier {
|
||||
net::CertVerifyResult* verify_result,
|
||||
const net::CompletionCallback& callback,
|
||||
std::unique_ptr<Request>* out_req,
|
||||
const net::BoundNetLog& net_log) override;
|
||||
const net::NetLogWithSource& net_log) override;
|
||||
bool SupportsOCSPStapling() override;
|
||||
|
||||
private:
|
||||
friend class CertVerifierRequest;
|
||||
|
||||
void RemoveRequest(const RequestParams& params);
|
||||
CertVerifierRequest* FindRequest(const RequestParams& params);
|
||||
|
||||
std::map<RequestParams, CertVerifierRequest*> inflight_requests_;
|
||||
VerifyProc verify_proc_;
|
||||
std::unique_ptr<net::CertVerifier> default_cert_verifier_;
|
||||
AtomCTDelegate* ct_delegate_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomCertVerifier);
|
||||
};
|
||||
|
||||
@@ -23,14 +23,17 @@ void AtomCookieDelegate::RemoveObserver(Observer* observer) {
|
||||
}
|
||||
|
||||
void AtomCookieDelegate::NotifyObservers(
|
||||
const net::CanonicalCookie& cookie, bool removed, ChangeCause cause) {
|
||||
FOR_EACH_OBSERVER(Observer,
|
||||
observers_,
|
||||
OnCookieChanged(cookie, removed, cause));
|
||||
const net::CanonicalCookie& cookie,
|
||||
bool removed,
|
||||
net::CookieStore::ChangeCause cause) {
|
||||
for (Observer& observer : observers_)
|
||||
observer.OnCookieChanged(cookie, removed, cause);
|
||||
}
|
||||
|
||||
void AtomCookieDelegate::OnCookieChanged(
|
||||
const net::CanonicalCookie& cookie, bool removed, ChangeCause cause) {
|
||||
const net::CanonicalCookie& cookie,
|
||||
bool removed,
|
||||
net::CookieStore::ChangeCause cause) {
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI,
|
||||
FROM_HERE,
|
||||
|
||||
@@ -19,7 +19,7 @@ class AtomCookieDelegate : public net::CookieMonsterDelegate {
|
||||
public:
|
||||
virtual void OnCookieChanged(const net::CanonicalCookie& cookie,
|
||||
bool removed,
|
||||
ChangeCause cause) {}
|
||||
net::CookieStore::ChangeCause cause) {}
|
||||
protected:
|
||||
virtual ~Observer() {}
|
||||
};
|
||||
@@ -30,7 +30,7 @@ class AtomCookieDelegate : public net::CookieMonsterDelegate {
|
||||
// net::CookieMonsterDelegate:
|
||||
void OnCookieChanged(const net::CanonicalCookie& cookie,
|
||||
bool removed,
|
||||
ChangeCause cause) override;
|
||||
net::CookieStore::ChangeCause cause) override;
|
||||
|
||||
|
||||
private:
|
||||
@@ -38,7 +38,7 @@ class AtomCookieDelegate : public net::CookieMonsterDelegate {
|
||||
|
||||
void NotifyObservers(const net::CanonicalCookie& cookie,
|
||||
bool removed,
|
||||
ChangeCause cause);
|
||||
net::CookieStore::ChangeCause cause);
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomCookieDelegate);
|
||||
};
|
||||
|
||||
34
atom/browser/net/atom_ct_delegate.cc
Normal file
34
atom/browser/net/atom_ct_delegate.cc
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/net/atom_ct_delegate.h"
|
||||
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
AtomCTDelegate::AtomCTDelegate() {}
|
||||
|
||||
AtomCTDelegate::~AtomCTDelegate() {}
|
||||
|
||||
void AtomCTDelegate::AddCTExcludedHost(const std::string& host) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
||||
ct_excluded_hosts_.insert(host);
|
||||
}
|
||||
|
||||
void AtomCTDelegate::ClearCTExcludedHostsList() {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
||||
ct_excluded_hosts_.clear();
|
||||
}
|
||||
|
||||
AtomCTDelegate::CTRequirementLevel AtomCTDelegate::IsCTRequiredForHost(
|
||||
const std::string& host) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
||||
if (!ct_excluded_hosts_.empty() &&
|
||||
(ct_excluded_hosts_.find(host) != ct_excluded_hosts_.end()))
|
||||
return CTRequirementLevel::NOT_REQUIRED;
|
||||
return CTRequirementLevel::DEFAULT;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
33
atom/browser/net/atom_ct_delegate.h
Normal file
33
atom/browser/net/atom_ct_delegate.h
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_NET_ATOM_CT_DELEGATE_H_
|
||||
#define ATOM_BROWSER_NET_ATOM_CT_DELEGATE_H_
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include "net/http/transport_security_state.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class AtomCTDelegate : public net::TransportSecurityState::RequireCTDelegate {
|
||||
public:
|
||||
AtomCTDelegate();
|
||||
~AtomCTDelegate() override;
|
||||
|
||||
void AddCTExcludedHost(const std::string& host);
|
||||
void ClearCTExcludedHostsList();
|
||||
|
||||
// net::TransportSecurityState::RequireCTDelegate:
|
||||
CTRequirementLevel IsCTRequiredForHost(const std::string& host) override;
|
||||
|
||||
private:
|
||||
std::set<std::string> ct_excluded_hosts_;
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomCTDelegate);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_NET_ATOM_CT_DELEGATE_H_
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user