mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
Compare commits
492 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97dd71d79e | ||
|
|
e46ef5a15a | ||
|
|
8f49d43b69 | ||
|
|
f4dc8f6d26 | ||
|
|
01b10b3b39 | ||
|
|
0864d3b1ee | ||
|
|
7434838463 | ||
|
|
de4bff003f | ||
|
|
db4dc4757a | ||
|
|
51daf8e194 | ||
|
|
a70749e80a | ||
|
|
eb882855bc | ||
|
|
5bb8da6073 | ||
|
|
523e8c2e1c | ||
|
|
0565c42add | ||
|
|
89adc122c3 | ||
|
|
28c9dcc393 | ||
|
|
15d32a9096 | ||
|
|
8dfbbcefc8 | ||
|
|
d105524135 | ||
|
|
18f005092b | ||
|
|
2aa1aedd92 | ||
|
|
606fc1a5b7 | ||
|
|
fc6628d159 | ||
|
|
f5839c3a5b | ||
|
|
aea2135016 | ||
|
|
6c705fdd70 | ||
|
|
4d8994df92 | ||
|
|
381da76967 | ||
|
|
543d4bb2b1 | ||
|
|
f02143b8f2 | ||
|
|
0c93b21a5f | ||
|
|
49f1278601 | ||
|
|
912cedc593 | ||
|
|
6e14a55817 | ||
|
|
ad3b3e0162 | ||
|
|
6755aa44f6 | ||
|
|
ce0d3d93ab | ||
|
|
5ab86cc2df | ||
|
|
12631a18c0 | ||
|
|
7ec467e337 | ||
|
|
a176aaee01 | ||
|
|
3e41aebaa7 | ||
|
|
26fa963a70 | ||
|
|
5a9eb5cfa6 | ||
|
|
79cb648b6b | ||
|
|
09796587b4 | ||
|
|
ec53e49fad | ||
|
|
9f0fc96025 | ||
|
|
34af9794a2 | ||
|
|
9d8af43617 | ||
|
|
23fbb57d72 | ||
|
|
d1e56f416c | ||
|
|
5f3fdbe635 | ||
|
|
de001a9bbf | ||
|
|
ec1944c146 | ||
|
|
2431d886bf | ||
|
|
dd804d7432 | ||
|
|
f693b042b5 | ||
|
|
747f910ce0 | ||
|
|
3c7d94f2d9 | ||
|
|
f4fe60d126 | ||
|
|
30dca2b4e1 | ||
|
|
9ed4730cba | ||
|
|
5eb9ed1729 | ||
|
|
62fb4f9820 | ||
|
|
ba315248e0 | ||
|
|
a58b84bbd7 | ||
|
|
ae1f442b02 | ||
|
|
d55b96fdf5 | ||
|
|
31628abadc | ||
|
|
db94121360 | ||
|
|
f5b430d9e1 | ||
|
|
d8db695712 | ||
|
|
599d3c147b | ||
|
|
e76c36a9a8 | ||
|
|
dfe7ae2124 | ||
|
|
5deb86d6f9 | ||
|
|
0a03dcd481 | ||
|
|
6e8945d7fa | ||
|
|
1704b1ad53 | ||
|
|
d02c1fbbf4 | ||
|
|
6add7f8d49 | ||
|
|
ba6c8b531f | ||
|
|
82bc98ec3c | ||
|
|
1e28e3fc27 | ||
|
|
2effa32e3e | ||
|
|
f17e64e726 | ||
|
|
556b39c6f2 | ||
|
|
4734cbaf1c | ||
|
|
153a7f19ae | ||
|
|
0b27db2ef4 | ||
|
|
b465f2c3c4 | ||
|
|
1e99f656cc | ||
|
|
84f6015037 | ||
|
|
fa7f084625 | ||
|
|
fc4b224dec | ||
|
|
59dd7ca9df | ||
|
|
7cf6be07a6 | ||
|
|
ac394ec3ef | ||
|
|
0c710fce33 | ||
|
|
9ab76fb884 | ||
|
|
c1facec5a6 | ||
|
|
134f9019eb | ||
|
|
7e1f159185 | ||
|
|
49d9446cce | ||
|
|
97c04735a2 | ||
|
|
a63ff714f8 | ||
|
|
7eab259d92 | ||
|
|
4fb9e20c33 | ||
|
|
f4c3f0423a | ||
|
|
b646d7a55c | ||
|
|
b0c72adbe1 | ||
|
|
23962e133e | ||
|
|
efeb9647ff | ||
|
|
71b73a9cfb | ||
|
|
dc7316f52f | ||
|
|
836f8ab33c | ||
|
|
cdfbe876a5 | ||
|
|
edd8210ae5 | ||
|
|
99c1434051 | ||
|
|
513b66f207 | ||
|
|
f29598d907 | ||
|
|
c1272743b9 | ||
|
|
eeb996e92f | ||
|
|
eb8284e285 | ||
|
|
20b09e9d03 | ||
|
|
93b8237e1f | ||
|
|
8a4b7eb062 | ||
|
|
4ea7602871 | ||
|
|
fa1246ccf7 | ||
|
|
0b9c11a5f2 | ||
|
|
4e44900930 | ||
|
|
d1c302800f | ||
|
|
bef6748c06 | ||
|
|
75754804af | ||
|
|
88f665bc1b | ||
|
|
814e4377a4 | ||
|
|
6632547b17 | ||
|
|
89ffa02d75 | ||
|
|
b1ce57faa9 | ||
|
|
03c6fbf80f | ||
|
|
f58322891b | ||
|
|
583bb49f6c | ||
|
|
69c69880e5 | ||
|
|
4e68a8d16e | ||
|
|
73b07f76a3 | ||
|
|
1e15ce6ccd | ||
|
|
32073fa079 | ||
|
|
9684f61e12 | ||
|
|
6c8cf16508 | ||
|
|
43f0dfd0ab | ||
|
|
1bdb9f3de0 | ||
|
|
94c8b0e1b1 | ||
|
|
7e209dd982 | ||
|
|
8f1943bc7b | ||
|
|
3dd2f709e0 | ||
|
|
b86ded3b54 | ||
|
|
3ef0947718 | ||
|
|
c2633460eb | ||
|
|
34c4e797bb | ||
|
|
545c9f5bed | ||
|
|
4cd0de0e87 | ||
|
|
b1226a908b | ||
|
|
f34cd8767c | ||
|
|
eb0889de38 | ||
|
|
e97ce6f7e1 | ||
|
|
89538b19ee | ||
|
|
b68d1ecb83 | ||
|
|
407a5d4415 | ||
|
|
3e15021c12 | ||
|
|
ca72d4346b | ||
|
|
74cde4e714 | ||
|
|
48522d4b70 | ||
|
|
63b84923ce | ||
|
|
4a35206302 | ||
|
|
6de4249af8 | ||
|
|
deb15e60b5 | ||
|
|
f691a46d4d | ||
|
|
67c88d2f8a | ||
|
|
4d56437a26 | ||
|
|
2a7590529e | ||
|
|
28e2058ff1 | ||
|
|
1dd98171f4 | ||
|
|
994cc62031 | ||
|
|
cd444e82f9 | ||
|
|
9d924bb6d7 | ||
|
|
995a20a125 | ||
|
|
677a317274 | ||
|
|
1ba07a9d6d | ||
|
|
a4f94b89b4 | ||
|
|
5e2f36387f | ||
|
|
4a41311409 | ||
|
|
6ac0151e65 | ||
|
|
fe0ec67623 | ||
|
|
19fd841c30 | ||
|
|
566b0676bc | ||
|
|
daea448b61 | ||
|
|
7929daa48c | ||
|
|
f3af1dbd54 | ||
|
|
ee61a2880a | ||
|
|
1c9fe8d23e | ||
|
|
52888c97b5 | ||
|
|
58d9d2cf41 | ||
|
|
5010150c8c | ||
|
|
3402c7be3f | ||
|
|
37a4267450 | ||
|
|
2208b8bd6e | ||
|
|
2edf559571 | ||
|
|
0d4f1abdf9 | ||
|
|
b866b34ac8 | ||
|
|
fca91db133 | ||
|
|
badecb49f3 | ||
|
|
9f858e1243 | ||
|
|
c489d6d4b3 | ||
|
|
208acd1b9c | ||
|
|
1b9bced8c0 | ||
|
|
f756a3e682 | ||
|
|
44651656dd | ||
|
|
9d82041923 | ||
|
|
d6f9e57e33 | ||
|
|
de1fc9d432 | ||
|
|
f68d0f324f | ||
|
|
a92b4a6da4 | ||
|
|
fa0ce7ad5f | ||
|
|
06800940ec | ||
|
|
4b675a741d | ||
|
|
530f19e956 | ||
|
|
899cdb48d7 | ||
|
|
a2bd55dd3c | ||
|
|
de27b34891 | ||
|
|
7ba391da7c | ||
|
|
1d61f987cb | ||
|
|
05c2999651 | ||
|
|
fd5f120434 | ||
|
|
09de0c2766 | ||
|
|
ac6e4aff5e | ||
|
|
13b4c8bb06 | ||
|
|
7aaf974362 | ||
|
|
8f7a04f9c3 | ||
|
|
62cad610e0 | ||
|
|
4c531e909b | ||
|
|
b52b6e12c4 | ||
|
|
48b161f210 | ||
|
|
06da5d543c | ||
|
|
5267d734bb | ||
|
|
3db2daf790 | ||
|
|
9d02292dec | ||
|
|
77eb0e8e3f | ||
|
|
6f3d0e1782 | ||
|
|
6c8ffcf7a0 | ||
|
|
363ab2075c | ||
|
|
c9b314d43c | ||
|
|
0e63050916 | ||
|
|
8821cae34f | ||
|
|
f16f48aa7c | ||
|
|
e1d9229507 | ||
|
|
588420ecd2 | ||
|
|
d56c36b4a7 | ||
|
|
d983eb42e6 | ||
|
|
b08393a663 | ||
|
|
a1e59b814c | ||
|
|
f52cd31d0d | ||
|
|
f266b979af | ||
|
|
25cb0fcbb9 | ||
|
|
8b9d189671 | ||
|
|
3182485e68 | ||
|
|
a93c9462ed | ||
|
|
b33c04d041 | ||
|
|
d26480b74e | ||
|
|
ea2807c890 | ||
|
|
0059e7bcf9 | ||
|
|
9e26e5c121 | ||
|
|
67d9ae27c3 | ||
|
|
adfd99f5f0 | ||
|
|
9196a9f334 | ||
|
|
7d93642f42 | ||
|
|
7c34d8333c | ||
|
|
d5f3e5d59a | ||
|
|
8ac93e02c6 | ||
|
|
4193fb1742 | ||
|
|
844f9e989b | ||
|
|
d6dffc570c | ||
|
|
4a075866de | ||
|
|
cc7395eea8 | ||
|
|
b09c81202a | ||
|
|
4754e4aabb | ||
|
|
fef2f789cd | ||
|
|
1a27ecdad4 | ||
|
|
2bade868bb | ||
|
|
e87ced60e5 | ||
|
|
836e2e4e91 | ||
|
|
a2b6731bf2 | ||
|
|
983d611e96 | ||
|
|
0bd3e28a05 | ||
|
|
480f0fbfd7 | ||
|
|
590c2bcf23 | ||
|
|
8fd9957453 | ||
|
|
e488320d37 | ||
|
|
195e0e64d0 | ||
|
|
17528a4dfd | ||
|
|
53d0db0a28 | ||
|
|
d6ab81c1da | ||
|
|
3ee9eef308 | ||
|
|
9cbcd228f3 | ||
|
|
e1bf0ea2b4 | ||
|
|
5c8ecd8a97 | ||
|
|
2b7c3735bd | ||
|
|
f8c1db160e | ||
|
|
e609a5bee2 | ||
|
|
eaacbc86c7 | ||
|
|
4702d8b640 | ||
|
|
359123458d | ||
|
|
d8c05ecc0d | ||
|
|
f441ba2694 | ||
|
|
5d906c0e4e | ||
|
|
a361d50b95 | ||
|
|
18b2094198 | ||
|
|
1032287511 | ||
|
|
d3beaa0b16 | ||
|
|
046cb0df8d | ||
|
|
97d903bca3 | ||
|
|
0456be1535 | ||
|
|
161bd89a24 | ||
|
|
5f9976c46a | ||
|
|
872c6ea763 | ||
|
|
e995befcd0 | ||
|
|
d49302858b | ||
|
|
d3e0c08255 | ||
|
|
06e3e65c1b | ||
|
|
962ce6c44c | ||
|
|
e05f795d1d | ||
|
|
906948218f | ||
|
|
deddf98533 | ||
|
|
d7fdb16078 | ||
|
|
d2a567d6ab | ||
|
|
3d0b98c9ca | ||
|
|
68cf267b1d | ||
|
|
240c346d02 | ||
|
|
97250b53e8 | ||
|
|
49cca0978d | ||
|
|
87c10b3ac2 | ||
|
|
5f6c468f0f | ||
|
|
dc9b3fcef7 | ||
|
|
d6cb84f8a3 | ||
|
|
998ce73ad9 | ||
|
|
8a061b7183 | ||
|
|
118afab67b | ||
|
|
7fd3149031 | ||
|
|
242508e22f | ||
|
|
5368da18ad | ||
|
|
467ccabb7e | ||
|
|
397d0e34ee | ||
|
|
27da0f3338 | ||
|
|
c7f5210b50 | ||
|
|
7bd11c14f6 | ||
|
|
cee31ff67a | ||
|
|
9266f9abfc | ||
|
|
f95c46d987 | ||
|
|
866260a2a6 | ||
|
|
bfb75df49c | ||
|
|
b301c473cd | ||
|
|
3f3871b1be | ||
|
|
2043356fa3 | ||
|
|
13cfc2d2a0 | ||
|
|
8d0c5c30b8 | ||
|
|
0b4b79d0a4 | ||
|
|
7db2601ea8 | ||
|
|
77b074fbad | ||
|
|
dc86ec8ddd | ||
|
|
189380d4ea | ||
|
|
bfb4867e10 | ||
|
|
1623622073 | ||
|
|
ae2eec3efa | ||
|
|
b51be9b83f | ||
|
|
60bc2acd6c | ||
|
|
cd7bc0e50c | ||
|
|
75362450cd | ||
|
|
191b054ff0 | ||
|
|
f4538daa0a | ||
|
|
a7ac7ba4c1 | ||
|
|
7e09b1664a | ||
|
|
ee9e28dfdf | ||
|
|
fb6f5320e7 | ||
|
|
7ce87c470a | ||
|
|
90f52169af | ||
|
|
0140015500 | ||
|
|
c1399f9bdc | ||
|
|
3fedea4b9e | ||
|
|
13bfb099a2 | ||
|
|
f53aabaef5 | ||
|
|
ecbb088ea6 | ||
|
|
f5442a4888 | ||
|
|
57f082055a | ||
|
|
e53bfad018 | ||
|
|
0d3d097ce8 | ||
|
|
2317b56ac4 | ||
|
|
16c870191f | ||
|
|
54c654530e | ||
|
|
6217d497ed | ||
|
|
84cce6c2c1 | ||
|
|
40c531737d | ||
|
|
88f3c34412 | ||
|
|
fd9c9c3be7 | ||
|
|
236810a923 | ||
|
|
88dc73ec3f | ||
|
|
195a4bb3c1 | ||
|
|
c540721bd3 | ||
|
|
c11d18fe06 | ||
|
|
8ed3659bb8 | ||
|
|
ba7a32b16e | ||
|
|
800ab50b56 | ||
|
|
f43b9665c1 | ||
|
|
14906eb6c8 | ||
|
|
c53e47265d | ||
|
|
5986a302d1 | ||
|
|
f5acc8b599 | ||
|
|
e5af03547f | ||
|
|
861a79dd6a | ||
|
|
5fe270a78f | ||
|
|
b1275420a3 | ||
|
|
fb161d5f1f | ||
|
|
6ac24f592c | ||
|
|
88d158f2c1 | ||
|
|
e5036c0988 | ||
|
|
0b5efcbc75 | ||
|
|
0785c3bd15 | ||
|
|
5dc88aa543 | ||
|
|
5ec2e8d7e5 | ||
|
|
3214fdd73f | ||
|
|
d3e359ab2d | ||
|
|
c740438032 | ||
|
|
7459581d13 | ||
|
|
03052e81c1 | ||
|
|
1bac1a9028 | ||
|
|
de08473ea3 | ||
|
|
2d46f6f66f | ||
|
|
2287ad6d37 | ||
|
|
2234307d41 | ||
|
|
652913f8d6 | ||
|
|
19cba3ff85 | ||
|
|
6f0057532a | ||
|
|
908084c0fd | ||
|
|
d83c36e0fd | ||
|
|
22a3765394 | ||
|
|
61e775c055 | ||
|
|
bebf8eabca | ||
|
|
847d9580b7 | ||
|
|
faf896db67 | ||
|
|
10f144069d | ||
|
|
29b799de73 | ||
|
|
525d456f7c | ||
|
|
f1142cf2b5 | ||
|
|
08779eb6d9 | ||
|
|
2d7b5c53b1 | ||
|
|
8dc8f8f485 | ||
|
|
4a409b870e | ||
|
|
bb5b30b8a0 | ||
|
|
906ae043f9 | ||
|
|
0ad03d9ff7 | ||
|
|
3aaff23f78 | ||
|
|
e77582baee | ||
|
|
2497c73009 | ||
|
|
73223fe5c3 | ||
|
|
9c0f298064 | ||
|
|
525e3ee9c6 | ||
|
|
9ccb495f60 | ||
|
|
35d9e37220 | ||
|
|
e8c4fb6903 | ||
|
|
a9652052c4 | ||
|
|
a52dbf0784 | ||
|
|
900001e547 | ||
|
|
37ccd34a88 | ||
|
|
f93fa53aea | ||
|
|
0253aec0cd | ||
|
|
ce7c1023d5 | ||
|
|
02d72c81af | ||
|
|
22863b9f31 | ||
|
|
48e62ac0b5 | ||
|
|
732936713a | ||
|
|
f418ac5b5d | ||
|
|
d889bdef49 | ||
|
|
c04353a845 | ||
|
|
ff91aeb5d4 | ||
|
|
8a2aebd03f | ||
|
|
82f3bb26ce | ||
|
|
2da39d31aa | ||
|
|
5fda9bc6ae | ||
|
|
93e9cf4ac1 | ||
|
|
dc7928021d | ||
|
|
b78fe04f8f | ||
|
|
8d4ed037a2 |
@@ -19,8 +19,7 @@ matrix:
|
||||
- os: linux
|
||||
env: TARGET_ARCH=ia32
|
||||
allow_failures:
|
||||
- env: TARGET_ARCH=arm
|
||||
- env: TARGET_ARCH=ia32
|
||||
- os: osx
|
||||
|
||||
script: './script/cibuild'
|
||||
|
||||
|
||||
@@ -5,19 +5,17 @@
|
||||
[](https://david-dm.org/electron/electron#info=devDependencies)
|
||||
[](http://atom-slack.herokuapp.com/)
|
||||
|
||||
:zap: *Formerly known as Atom Shell* :zap:
|
||||
|
||||
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 in the [Atom
|
||||
editor](https://github.com/atom/atom).
|
||||
[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).
|
||||
|
||||
Follow [@ElectronJS](https://twitter.com/electronjs) on Twitter for important
|
||||
announcements.
|
||||
|
||||
This project adheres to the Contributor Covenant [code of conduct](CODE_OF_CONDUCT.md).
|
||||
By participating, you are expected to uphold this code. Please report unacceptable
|
||||
behavior to atom@github.com.
|
||||
behavior to electron@github.com.
|
||||
|
||||
## Downloads
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
# http://www.appveyor.com/docs/appveyor-yml
|
||||
version: "{build}"
|
||||
|
||||
os: Visual Studio 2015
|
||||
|
||||
init:
|
||||
- git config --global core.autocrlf input
|
||||
|
||||
@@ -10,7 +12,7 @@ platform:
|
||||
- x64
|
||||
|
||||
install:
|
||||
- cmd: SET PATH=C:\Program Files (x86)\MSBuild\12.0\bin\;%PATH%
|
||||
- cmd: SET PATH=C:\Program Files (x86)\MSBuild\14.0\bin\;%PATH%
|
||||
- cmd: SET PATH=C:\python27;%PATH%
|
||||
- cmd: python script/cibuild
|
||||
|
||||
|
||||
@@ -89,11 +89,9 @@ content::PepperPluginInfo CreateWidevineCdmInfo(const base::FilePath& path,
|
||||
|
||||
// Add the supported codecs as if they came from the component manifest.
|
||||
std::vector<std::string> codecs;
|
||||
codecs.push_back(kCdmSupportedCodecVorbis);
|
||||
codecs.push_back(kCdmSupportedCodecVp8);
|
||||
codecs.push_back(kCdmSupportedCodecVp9);
|
||||
#if defined(USE_PROPRIETARY_CODECS)
|
||||
codecs.push_back(kCdmSupportedCodecAac);
|
||||
codecs.push_back(kCdmSupportedCodecAvc1);
|
||||
#endif // defined(USE_PROPRIETARY_CODECS)
|
||||
std::string codec_string = base::JoinString(
|
||||
@@ -181,6 +179,7 @@ base::string16 AtomContentClient::GetLocalizedString(int message_id) const {
|
||||
|
||||
void AtomContentClient::AddAdditionalSchemes(
|
||||
std::vector<url::SchemeWithType>* standard_schemes,
|
||||
std::vector<url::SchemeWithType>* referrer_schemes,
|
||||
std::vector<std::string>* savable_schemes) {
|
||||
standard_schemes->push_back({"chrome-extension", url::SCHEME_WITHOUT_PORT});
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ class AtomContentClient : public brightray::ContentClient {
|
||||
base::string16 GetLocalizedString(int message_id) const override;
|
||||
void AddAdditionalSchemes(
|
||||
std::vector<url::SchemeWithType>* standard_schemes,
|
||||
std::vector<url::SchemeWithType>* referrer_schemes,
|
||||
std::vector<std::string>* savable_schemes) override;
|
||||
void AddPepperPlugins(
|
||||
std::vector<content::PepperPluginInfo>* plugins) override;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "atom/app/atom_main_delegate.h"
|
||||
#include "atom/common/crash_reporter/win/crash_service_main.h"
|
||||
#include "base/environment.h"
|
||||
#include "base/process/launch.h"
|
||||
#include "base/win/windows_version.h"
|
||||
#include "content/public/app/sandbox_helper_win.h"
|
||||
#include "sandbox/win/src/sandbox_types.h"
|
||||
@@ -34,7 +35,6 @@
|
||||
namespace {
|
||||
|
||||
const char* kRunAsNode = "ELECTRON_RUN_AS_NODE";
|
||||
const char* kOldRunAsNode = "ATOM_SHELL_INTERNAL_RUN_AS_NODE";
|
||||
|
||||
bool IsEnvSet(const char* name) {
|
||||
#if defined(OS_WIN)
|
||||
@@ -47,10 +47,6 @@ bool IsEnvSet(const char* name) {
|
||||
#endif
|
||||
}
|
||||
|
||||
bool IsRunAsNode() {
|
||||
return IsEnvSet(kRunAsNode) || IsEnvSet(kOldRunAsNode);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#if defined(OS_WIN)
|
||||
@@ -58,14 +54,11 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||
int argc = 0;
|
||||
wchar_t** wargv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
|
||||
|
||||
// Make output work in console if we are not in cygiwn.
|
||||
if (!IsEnvSet("TERM") && !IsEnvSet("ELECTRON_NO_ATTACH_CONSOLE")) {
|
||||
AttachConsole(ATTACH_PARENT_PROCESS);
|
||||
bool run_as_node = IsEnvSet(kRunAsNode);
|
||||
|
||||
FILE* dontcare;
|
||||
freopen_s(&dontcare, "CON", "w", stdout);
|
||||
freopen_s(&dontcare, "CON", "w", stderr);
|
||||
}
|
||||
// Make sure the output is printed to console.
|
||||
if (run_as_node || !IsEnvSet("ELECTRON_NO_ATTACH_CONSOLE"))
|
||||
base::RouteStdioToConsole(false);
|
||||
|
||||
// Convert argv to to UTF8
|
||||
char** argv = new char*[argc];
|
||||
@@ -101,12 +94,12 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||
}
|
||||
}
|
||||
|
||||
if (IsRunAsNode()) {
|
||||
if (run_as_node) {
|
||||
// Now that argv conversion is done, we can finally start.
|
||||
base::AtExitManager atexit_manager;
|
||||
base::i18n::InitializeICU();
|
||||
return atom::NodeMain(argc, argv);
|
||||
} else if (IsEnvSet("ATOM_SHELL_INTERNAL_CRASH_SERVICE")) {
|
||||
} else if (IsEnvSet("ELECTRON_INTERNAL_CRASH_SERVICE")) {
|
||||
return crash_service::Main(cmd);
|
||||
}
|
||||
|
||||
@@ -124,7 +117,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||
#elif defined(OS_LINUX) // defined(OS_WIN)
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
if (IsRunAsNode()) {
|
||||
if (IsEnvSet(kRunAsNode)) {
|
||||
base::i18n::InitializeICU();
|
||||
base::AtExitManager atexit_manager;
|
||||
return atom::NodeMain(argc, const_cast<char**>(argv));
|
||||
@@ -141,7 +134,7 @@ int main(int argc, const char* argv[]) {
|
||||
#else // defined(OS_LINUX)
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
if (IsRunAsNode()) {
|
||||
if (IsEnvSet(kRunAsNode)) {
|
||||
return AtomInitializeICUandStartNode(argc, const_cast<char**>(argv));
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,13 @@ bool IsBrowserProcess(base::CommandLine* cmd) {
|
||||
return process_type.empty();
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
void InvalidParameterHandler(const wchar_t*, const wchar_t*, const wchar_t*,
|
||||
unsigned int, uintptr_t) {
|
||||
// noop.
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
AtomMainDelegate::AtomMainDelegate() {
|
||||
@@ -61,7 +68,7 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
#endif // !defined(OS_WIN)
|
||||
|
||||
// Only enable logging when --enable-logging is specified.
|
||||
scoped_ptr<base::Environment> env(base::Environment::Create());
|
||||
std::unique_ptr<base::Environment> env(base::Environment::Create());
|
||||
if (!command_line->HasSwitch(switches::kEnableLogging) &&
|
||||
!env->HasVar("ELECTRON_ENABLE_LOGGING")) {
|
||||
settings.logging_dest = logging::LOG_NONE;
|
||||
@@ -83,6 +90,15 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
|
||||
chrome::RegisterPathProvider();
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
SetUpBundleOverrides();
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Ignore invalid parameter errors.
|
||||
_set_invalid_parameter_handler(InvalidParameterHandler);
|
||||
#endif
|
||||
|
||||
return brightray::MainDelegate::BasicStartupComplete(exit_code);
|
||||
}
|
||||
|
||||
@@ -90,7 +106,7 @@ void AtomMainDelegate::PreSandboxStartup() {
|
||||
brightray::MainDelegate::PreSandboxStartup();
|
||||
|
||||
// Set google API key.
|
||||
scoped_ptr<base::Environment> env(base::Environment::Create());
|
||||
std::unique_ptr<base::Environment> env(base::Environment::Create());
|
||||
if (!env->HasVar("GOOGLE_API_KEY"))
|
||||
env->SetVar("GOOGLE_API_KEY", GOOGLEAPIS_API_KEY);
|
||||
|
||||
@@ -130,8 +146,9 @@ content::ContentUtilityClient* AtomMainDelegate::CreateContentUtilityClient() {
|
||||
return utility_client_.get();
|
||||
}
|
||||
|
||||
scoped_ptr<brightray::ContentClient> AtomMainDelegate::CreateContentClient() {
|
||||
return scoped_ptr<brightray::ContentClient>(new AtomContentClient);
|
||||
std::unique_ptr<brightray::ContentClient>
|
||||
AtomMainDelegate::CreateContentClient() {
|
||||
return std::unique_ptr<brightray::ContentClient>(new AtomContentClient);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -24,17 +24,21 @@ class AtomMainDelegate : public brightray::MainDelegate {
|
||||
content::ContentUtilityClient* CreateContentUtilityClient() override;
|
||||
|
||||
// brightray::MainDelegate:
|
||||
scoped_ptr<brightray::ContentClient> CreateContentClient() override;
|
||||
std::unique_ptr<brightray::ContentClient> CreateContentClient() override;
|
||||
#if defined(OS_MACOSX)
|
||||
void OverrideChildProcessPath() override;
|
||||
void OverrideFrameworkBundlePath() override;
|
||||
#endif
|
||||
|
||||
private:
|
||||
#if defined(OS_MACOSX)
|
||||
void SetUpBundleOverrides();
|
||||
#endif
|
||||
|
||||
brightray::ContentClient content_client_;
|
||||
scoped_ptr<content::ContentBrowserClient> browser_client_;
|
||||
scoped_ptr<content::ContentRendererClient> renderer_client_;
|
||||
scoped_ptr<content::ContentUtilityClient> utility_client_;
|
||||
std::unique_ptr<content::ContentBrowserClient> browser_client_;
|
||||
std::unique_ptr<content::ContentRendererClient> renderer_client_;
|
||||
std::unique_ptr<content::ContentUtilityClient> utility_client_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomMainDelegate);
|
||||
};
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
#include "base/mac/bundle_locations.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "brightray/common/application_info.h"
|
||||
#include "brightray/common/mac/main_application_bundle.h"
|
||||
#include "content/public/common/content_paths.h"
|
||||
@@ -48,4 +51,15 @@ void AtomMainDelegate::OverrideChildProcessPath() {
|
||||
PathService::Override(content::CHILD_PROCESS_EXE, helper_path);
|
||||
}
|
||||
|
||||
void AtomMainDelegate::SetUpBundleOverrides() {
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
NSBundle* bundle = brightray::MainApplicationBundle();
|
||||
std::string base_bundle_id =
|
||||
base::SysNSStringToUTF8([bundle bundleIdentifier]);
|
||||
NSString* team_id = [bundle objectForInfoDictionaryKey:@"ElectronTeamID"];
|
||||
if (team_id)
|
||||
base_bundle_id = base::SysNSStringToUTF8(team_id) + "." + base_bundle_id;
|
||||
base::mac::SetBaseBundleID(base_bundle_id.c_str());
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
#include "atom/app/uv_task_runner.h"
|
||||
#include "atom/browser/javascript_environment.h"
|
||||
#include "atom/browser/node_debugger.h"
|
||||
#include "base/command_line.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/feature_list.h"
|
||||
#include "base/thread_task_runner_handle.h"
|
||||
#include "gin/array_buffer.h"
|
||||
#include "gin/public/isolate_holder.h"
|
||||
@@ -27,6 +28,11 @@ int NodeMain(int argc, char *argv[]) {
|
||||
scoped_refptr<UvTaskRunner> uv_task_runner(new UvTaskRunner(loop));
|
||||
base::ThreadTaskRunnerHandle handle(uv_task_runner);
|
||||
|
||||
// Initialize feature list.
|
||||
std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
|
||||
feature_list->InitializeFromCommandLine("", "");
|
||||
base::FeatureList::SetInstance(std::move(feature_list));
|
||||
|
||||
gin::V8Initializer::LoadV8Snapshot();
|
||||
gin::V8Initializer::LoadV8Natives();
|
||||
JavascriptEnvironment gin_env;
|
||||
|
||||
@@ -319,7 +319,7 @@ void App::AllowCertificateError(
|
||||
void App::SelectClientCertificate(
|
||||
content::WebContents* web_contents,
|
||||
net::SSLCertRequestInfo* cert_request_info,
|
||||
scoped_ptr<content::ClientCertificateDelegate> delegate) {
|
||||
std::unique_ptr<content::ClientCertificateDelegate> delegate) {
|
||||
std::shared_ptr<content::ClientCertificateDelegate>
|
||||
shared_delegate(delegate.release());
|
||||
bool prevent_default =
|
||||
@@ -370,17 +370,11 @@ void App::SetPath(mate::Arguments* args,
|
||||
|
||||
void App::SetDesktopName(const std::string& desktop_name) {
|
||||
#if defined(OS_LINUX)
|
||||
scoped_ptr<base::Environment> env(base::Environment::Create());
|
||||
std::unique_ptr<base::Environment> env(base::Environment::Create());
|
||||
env->SetVar("CHROME_DESKTOP", desktop_name);
|
||||
#endif
|
||||
}
|
||||
|
||||
void App::AllowNTLMCredentialsForAllDomains(bool should_allow) {
|
||||
auto browser_context = static_cast<AtomBrowserContext*>(
|
||||
AtomBrowserMainParts::Get()->browser_context());
|
||||
browser_context->AllowNTLMCredentialsForAllDomains(should_allow);
|
||||
}
|
||||
|
||||
std::string App::GetLocale() {
|
||||
return l10n_util::GetApplicationLocale("");
|
||||
}
|
||||
@@ -407,13 +401,20 @@ bool App::MakeSingleInstance(
|
||||
}
|
||||
}
|
||||
|
||||
void App::ReleaseSingleInstance() {
|
||||
if (process_singleton_.get()) {
|
||||
process_singleton_->Cleanup();
|
||||
process_singleton_.reset();
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(USE_NSS_CERTS)
|
||||
void App::ImportCertificate(
|
||||
const base::DictionaryValue& options,
|
||||
const net::CompletionCallback& callback) {
|
||||
auto browser_context = AtomBrowserMainParts::Get()->browser_context();
|
||||
if (!certificate_manager_model_) {
|
||||
scoped_ptr<base::DictionaryValue> copy = options.CreateDeepCopy();
|
||||
std::unique_ptr<base::DictionaryValue> copy = options.CreateDeepCopy();
|
||||
CertificateManagerModel::Create(browser_context,
|
||||
base::Bind(&App::OnCertificateManagerModelCreated,
|
||||
base::Unretained(this),
|
||||
@@ -427,9 +428,9 @@ void App::ImportCertificate(
|
||||
}
|
||||
|
||||
void App::OnCertificateManagerModelCreated(
|
||||
scoped_ptr<base::DictionaryValue> options,
|
||||
std::unique_ptr<base::DictionaryValue> options,
|
||||
const net::CompletionCallback& callback,
|
||||
scoped_ptr<CertificateManagerModel> model) {
|
||||
std::unique_ptr<CertificateManagerModel> model) {
|
||||
certificate_manager_model_ = std::move(model);
|
||||
int rv = ImportIntoCertStore(certificate_manager_model_.get(),
|
||||
*(options.get()));
|
||||
@@ -482,13 +483,12 @@ void App::BuildPrototype(
|
||||
.SetMethod("setPath", &App::SetPath)
|
||||
.SetMethod("getPath", &App::GetPath)
|
||||
.SetMethod("setDesktopName", &App::SetDesktopName)
|
||||
.SetMethod("allowNTLMCredentialsForAllDomains",
|
||||
&App::AllowNTLMCredentialsForAllDomains)
|
||||
.SetMethod("getLocale", &App::GetLocale)
|
||||
#if defined(USE_NSS_CERTS)
|
||||
.SetMethod("importCertificate", &App::ImportCertificate)
|
||||
#endif
|
||||
.SetMethod("makeSingleInstance", &App::MakeSingleInstance);
|
||||
.SetMethod("makeSingleInstance", &App::MakeSingleInstance)
|
||||
.SetMethod("releaseSingleInstance", &App::ReleaseSingleInstance);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
@@ -51,9 +51,9 @@ class App : public AtomBrowserClient::Delegate,
|
||||
|
||||
#if defined(USE_NSS_CERTS)
|
||||
void OnCertificateManagerModelCreated(
|
||||
scoped_ptr<base::DictionaryValue> options,
|
||||
std::unique_ptr<base::DictionaryValue> options,
|
||||
const net::CompletionCallback& callback,
|
||||
scoped_ptr<CertificateManagerModel> model);
|
||||
std::unique_ptr<CertificateManagerModel> model);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
@@ -93,7 +93,7 @@ class App : public AtomBrowserClient::Delegate,
|
||||
void SelectClientCertificate(
|
||||
content::WebContents* web_contents,
|
||||
net::SSLCertRequestInfo* cert_request_info,
|
||||
scoped_ptr<content::ClientCertificateDelegate> delegate) override;
|
||||
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
|
||||
|
||||
// content::GpuDataManagerObserver:
|
||||
void OnGpuProcessCrashed(base::TerminationStatus exit_code) override;
|
||||
@@ -106,9 +106,9 @@ class App : public AtomBrowserClient::Delegate,
|
||||
const base::FilePath& path);
|
||||
|
||||
void SetDesktopName(const std::string& desktop_name);
|
||||
void AllowNTLMCredentialsForAllDomains(bool should_allow);
|
||||
bool MakeSingleInstance(
|
||||
const ProcessSingleton::NotificationCallback& callback);
|
||||
void ReleaseSingleInstance();
|
||||
std::string GetLocale();
|
||||
|
||||
#if defined(USE_NSS_CERTS)
|
||||
@@ -116,10 +116,10 @@ class App : public AtomBrowserClient::Delegate,
|
||||
const net::CompletionCallback& callback);
|
||||
#endif
|
||||
|
||||
scoped_ptr<ProcessSingleton> process_singleton_;
|
||||
std::unique_ptr<ProcessSingleton> process_singleton_;
|
||||
|
||||
#if defined(USE_NSS_CERTS)
|
||||
scoped_ptr<CertificateManagerModel> certificate_manager_model_;
|
||||
std::unique_ptr<CertificateManagerModel> certificate_manager_model_;
|
||||
#endif
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(App);
|
||||
|
||||
@@ -112,7 +112,7 @@ void RunCallbackInUI(const base::Closure& callback) {
|
||||
}
|
||||
|
||||
// Remove cookies from |list| not matching |filter|, and pass it to |callback|.
|
||||
void FilterCookies(scoped_ptr<base::DictionaryValue> filter,
|
||||
void FilterCookies(std::unique_ptr<base::DictionaryValue> filter,
|
||||
const Cookies::GetCallback& callback,
|
||||
const net::CookieList& list) {
|
||||
net::CookieList result;
|
||||
@@ -125,7 +125,7 @@ void FilterCookies(scoped_ptr<base::DictionaryValue> filter,
|
||||
|
||||
// Receives cookies matching |filter| in IO thread.
|
||||
void GetCookiesOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||
scoped_ptr<base::DictionaryValue> filter,
|
||||
std::unique_ptr<base::DictionaryValue> filter,
|
||||
const Cookies::GetCallback& callback) {
|
||||
std::string url;
|
||||
filter->GetString("url", &url);
|
||||
@@ -133,12 +133,12 @@ void GetCookiesOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||
auto filtered_callback =
|
||||
base::Bind(FilterCookies, base::Passed(&filter), callback);
|
||||
|
||||
net::CookieMonster* monster = GetCookieStore(getter)->GetCookieMonster();
|
||||
// Empty url will match all url cookies.
|
||||
if (url.empty())
|
||||
monster->GetAllCookiesAsync(filtered_callback);
|
||||
GetCookieStore(getter)->GetAllCookiesAsync(filtered_callback);
|
||||
else
|
||||
monster->GetAllCookiesForURLAsync(GURL(url), filtered_callback);
|
||||
GetCookieStore(getter)->GetAllCookiesForURLAsync(GURL(url),
|
||||
filtered_callback);
|
||||
}
|
||||
|
||||
// Removes cookie with |url| and |name| in IO thread.
|
||||
@@ -157,12 +157,14 @@ void OnSetCookie(const Cookies::SetCallback& callback, bool success) {
|
||||
|
||||
// Sets cookie with |details| in IO thread.
|
||||
void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||
scoped_ptr<base::DictionaryValue> details,
|
||||
std::unique_ptr<base::DictionaryValue> details,
|
||||
const Cookies::SetCallback& callback) {
|
||||
std::string url, name, value, domain, path;
|
||||
bool secure = false;
|
||||
bool http_only = false;
|
||||
double creation_date;
|
||||
double expiration_date;
|
||||
double last_access_date;
|
||||
details->GetString("url", &url);
|
||||
details->GetString("name", &name);
|
||||
details->GetString("value", &value);
|
||||
@@ -171,6 +173,13 @@ void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||
details->GetBoolean("secure", &secure);
|
||||
details->GetBoolean("httpOnly", &http_only);
|
||||
|
||||
base::Time creation_time;
|
||||
if (details->GetDouble("creationDate", &creation_date)) {
|
||||
creation_time = (creation_date == 0) ?
|
||||
base::Time::UnixEpoch() :
|
||||
base::Time::FromDoubleT(creation_date);
|
||||
}
|
||||
|
||||
base::Time expiration_time;
|
||||
if (details->GetDouble("expirationDate", &expiration_date)) {
|
||||
expiration_time = (expiration_date == 0) ?
|
||||
@@ -178,10 +187,18 @@ void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||
base::Time::FromDoubleT(expiration_date);
|
||||
}
|
||||
|
||||
GetCookieStore(getter)->GetCookieMonster()->SetCookieWithDetailsAsync(
|
||||
GURL(url), name, value, domain, path, expiration_time, secure, http_only,
|
||||
false, false, false, net::COOKIE_PRIORITY_DEFAULT,
|
||||
base::Bind(OnSetCookie, callback));
|
||||
base::Time last_access_time;
|
||||
if (details->GetDouble("lastAccessDate", &last_access_date)) {
|
||||
last_access_time = (last_access_date == 0) ?
|
||||
base::Time::UnixEpoch() :
|
||||
base::Time::FromDoubleT(last_access_date);
|
||||
}
|
||||
|
||||
GetCookieStore(getter)->SetCookieWithDetailsAsync(
|
||||
GURL(url), name, value, domain, path, creation_time,
|
||||
expiration_time, last_access_time, secure, http_only,
|
||||
net::CookieSameSite::DEFAULT_MODE, false,
|
||||
net::COOKIE_PRIORITY_DEFAULT, base::Bind(OnSetCookie, callback));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -197,7 +214,7 @@ Cookies::~Cookies() {
|
||||
|
||||
void Cookies::Get(const base::DictionaryValue& filter,
|
||||
const GetCallback& callback) {
|
||||
scoped_ptr<base::DictionaryValue> copied(filter.CreateDeepCopy());
|
||||
std::unique_ptr<base::DictionaryValue> copied(filter.CreateDeepCopy());
|
||||
auto getter = make_scoped_refptr(request_context_getter_);
|
||||
content::BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
@@ -214,7 +231,7 @@ void Cookies::Remove(const GURL& url, const std::string& name,
|
||||
|
||||
void Cookies::Set(const base::DictionaryValue& details,
|
||||
const SetCallback& callback) {
|
||||
scoped_ptr<base::DictionaryValue> copied(details.CreateDeepCopy());
|
||||
std::unique_ptr<base::DictionaryValue> copied(details.CreateDeepCopy());
|
||||
auto getter = make_scoped_refptr(request_context_getter_);
|
||||
content::BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
|
||||
@@ -52,7 +52,7 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
|
||||
const std::string& message) {
|
||||
DCHECK(agent_host == agent_host_.get());
|
||||
|
||||
scoped_ptr<base::Value> parsed_message(base::JSONReader::Read(message));
|
||||
std::unique_ptr<base::Value> parsed_message(base::JSONReader::Read(message));
|
||||
if (!parsed_message->IsType(base::Value::TYPE_DICTIONARY))
|
||||
return;
|
||||
|
||||
|
||||
@@ -61,9 +61,9 @@ void DesktopCapturer::StartHandling(bool capture_window,
|
||||
options.set_disable_effects(false);
|
||||
#endif
|
||||
|
||||
scoped_ptr<webrtc::ScreenCapturer> screen_capturer(
|
||||
std::unique_ptr<webrtc::ScreenCapturer> screen_capturer(
|
||||
capture_screen ? webrtc::ScreenCapturer::Create(options) : nullptr);
|
||||
scoped_ptr<webrtc::WindowCapturer> window_capturer(
|
||||
std::unique_ptr<webrtc::WindowCapturer> window_capturer(
|
||||
capture_window ? webrtc::WindowCapturer::Create(options) : nullptr);
|
||||
media_list_.reset(new NativeDesktopMediaList(
|
||||
std::move(screen_capturer), std::move(window_capturer)));
|
||||
|
||||
@@ -39,7 +39,7 @@ class DesktopCapturer: public mate::EventEmitter<DesktopCapturer>,
|
||||
bool OnRefreshFinished() override;
|
||||
|
||||
private:
|
||||
scoped_ptr<DesktopMediaList> media_list_;
|
||||
std::unique_ptr<DesktopMediaList> media_list_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(DesktopCapturer);
|
||||
};
|
||||
|
||||
@@ -67,6 +67,7 @@ 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,
|
||||
@@ -77,17 +78,18 @@ void ShowOpenDialog(const std::string& title,
|
||||
if (mate::Converter<file_dialog::OpenDialogCallback>::FromV8(args->isolate(),
|
||||
peek,
|
||||
&callback)) {
|
||||
file_dialog::ShowOpenDialog(window, title, default_path, filters,
|
||||
properties, callback);
|
||||
file_dialog::ShowOpenDialog(window, title, button_label, default_path,
|
||||
filters, properties, callback);
|
||||
} else {
|
||||
std::vector<base::FilePath> paths;
|
||||
if (file_dialog::ShowOpenDialog(window, title, default_path, filters,
|
||||
properties, &paths))
|
||||
if (file_dialog::ShowOpenDialog(window, title, button_label, default_path,
|
||||
filters, properties, &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,
|
||||
@@ -97,11 +99,12 @@ void ShowSaveDialog(const std::string& title,
|
||||
if (mate::Converter<file_dialog::SaveDialogCallback>::FromV8(args->isolate(),
|
||||
peek,
|
||||
&callback)) {
|
||||
file_dialog::ShowSaveDialog(window, title, default_path, filters, callback);
|
||||
file_dialog::ShowSaveDialog(window, title, button_label, default_path,
|
||||
filters, callback);
|
||||
} else {
|
||||
base::FilePath path;
|
||||
if (file_dialog::ShowSaveDialog(window, title, default_path, filters,
|
||||
&path))
|
||||
if (file_dialog::ShowSaveDialog(window, title, button_label, default_path,
|
||||
filters, &path))
|
||||
args->Return(path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class Menu : public mate::TrackableObject<Menu>,
|
||||
int x = -1, int y = -1,
|
||||
int positioning_item = 0) = 0;
|
||||
|
||||
scoped_ptr<AtomMenuModel> model_;
|
||||
std::unique_ptr<AtomMenuModel> model_;
|
||||
Menu* parent_;
|
||||
|
||||
private:
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "atom/browser/native_window.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/web_contents.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
@@ -22,14 +24,15 @@ void MenuMac::PopupAt(Window* window, int x, int y, int positioning_item) {
|
||||
NativeWindow* native_window = window->window();
|
||||
if (!native_window)
|
||||
return;
|
||||
content::WebContents* web_contents = native_window->web_contents();
|
||||
brightray::InspectableWebContents* web_contents =
|
||||
native_window->inspectable_web_contents();
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
base::scoped_nsobject<AtomMenuController> menu_controller(
|
||||
[[AtomMenuController alloc] initWithModel:model_.get()]);
|
||||
NSMenu* menu = [menu_controller menu];
|
||||
NSView* view = web_contents->GetContentNativeView();
|
||||
NSView* view = web_contents->GetView()->GetNativeView();
|
||||
|
||||
// Which menu item to show.
|
||||
NSMenuItem* item = nil;
|
||||
@@ -46,6 +49,23 @@ void MenuMac::PopupAt(Window* window, int x, int y, int positioning_item) {
|
||||
position = NSMakePoint(x, [view frame].size.height - y);
|
||||
}
|
||||
|
||||
// If no preferred item is specified, try to show all of the menu items.
|
||||
if (!positioning_item) {
|
||||
CGFloat windowBottom = CGRectGetMinY([view window].frame);
|
||||
CGFloat lowestMenuPoint = windowBottom + position.y - [menu size].height;
|
||||
CGFloat screenBottom = CGRectGetMinY([view window].screen.frame);
|
||||
CGFloat distanceFromBottom = lowestMenuPoint - screenBottom;
|
||||
if (distanceFromBottom < 0)
|
||||
position.y = position.y - distanceFromBottom + 4;
|
||||
}
|
||||
|
||||
// Place the menu left of cursor if it is overflowing off right of screen.
|
||||
CGFloat windowLeft = CGRectGetMinX([view window].frame);
|
||||
CGFloat rightmostMenuPoint = windowLeft + position.x + [menu size].width;
|
||||
CGFloat screenRight = CGRectGetMaxX([view window].screen.frame);
|
||||
if (rightmostMenuPoint > screenRight)
|
||||
position.x = position.x - [menu size].width;
|
||||
|
||||
// Show the menu.
|
||||
[menu popUpMenuPositioningItem:item atLocation:position inView:view];
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item) {
|
||||
// (-1, -1) means showing on mouse location.
|
||||
gfx::Point location;
|
||||
if (x == -1 || y == -1) {
|
||||
location = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint();
|
||||
location = gfx::Screen::GetScreen()->GetCursorScreenPoint();
|
||||
} else {
|
||||
gfx::Point origin = view->GetViewBounds().origin();
|
||||
location = gfx::Point(origin.x() + x, origin.y() + y);
|
||||
|
||||
@@ -70,7 +70,7 @@ void PowerSaveBlocker::UpdatePowerSaveBlocker() {
|
||||
}
|
||||
|
||||
if (!power_save_blocker_ || new_blocker_type != current_blocker_type_) {
|
||||
scoped_ptr<content::PowerSaveBlocker> new_blocker =
|
||||
std::unique_ptr<content::PowerSaveBlocker> new_blocker =
|
||||
content::PowerSaveBlocker::Create(
|
||||
new_blocker_type,
|
||||
content::PowerSaveBlocker::kReasonOther,
|
||||
|
||||
@@ -37,7 +37,7 @@ class PowerSaveBlocker : public mate::TrackableObject<PowerSaveBlocker> {
|
||||
bool Stop(int id);
|
||||
bool IsStarted(int id);
|
||||
|
||||
scoped_ptr<content::PowerSaveBlocker> power_save_blocker_;
|
||||
std::unique_ptr<content::PowerSaveBlocker> power_save_blocker_;
|
||||
|
||||
// Currnet blocker type used by |power_save_blocker_|
|
||||
content::PowerSaveBlocker::PowerSaveBlockerType current_blocker_type_;
|
||||
|
||||
@@ -110,7 +110,7 @@ class Protocol : public mate::Wrappable<Protocol> {
|
||||
const Handler& handler) {
|
||||
if (job_factory_->IsHandledProtocol(scheme))
|
||||
return PROTOCOL_REGISTERED;
|
||||
scoped_ptr<CustomProtocolHandler<RequestJob>> protocol_handler(
|
||||
std::unique_ptr<CustomProtocolHandler<RequestJob>> protocol_handler(
|
||||
new CustomProtocolHandler<RequestJob>(
|
||||
isolate(), request_context_getter_, handler));
|
||||
if (job_factory_->SetProtocolHandler(scheme, std::move(protocol_handler)))
|
||||
@@ -152,7 +152,7 @@ class Protocol : public mate::Wrappable<Protocol> {
|
||||
return PROTOCOL_FAIL;
|
||||
if (ContainsKey(original_protocols_, scheme))
|
||||
return PROTOCOL_INTERCEPTED;
|
||||
scoped_ptr<CustomProtocolHandler<RequestJob>> protocol_handler(
|
||||
std::unique_ptr<CustomProtocolHandler<RequestJob>> protocol_handler(
|
||||
new CustomProtocolHandler<RequestJob>(
|
||||
isolate(), request_context_getter_, handler));
|
||||
original_protocols_.set(
|
||||
@@ -176,7 +176,7 @@ class Protocol : public mate::Wrappable<Protocol> {
|
||||
// Map that stores the original protocols of schemes.
|
||||
using OriginalProtocolsMap = base::ScopedPtrHashMap<
|
||||
std::string,
|
||||
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>>;
|
||||
std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>>;
|
||||
OriginalProtocolsMap original_protocols_;
|
||||
|
||||
AtomURLRequestJobFactory* job_factory_; // weak ref
|
||||
|
||||
88
atom/browser/api/atom_api_render_process_preferences.cc
Normal file
88
atom/browser/api/atom_api_render_process_preferences.cc
Normal file
@@ -0,0 +1,88 @@
|
||||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/api/atom_api_render_process_preferences.h"
|
||||
|
||||
#include "atom/browser/atom_browser_client.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/window_list.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
namespace {
|
||||
|
||||
bool IsBrowserWindow(content::RenderProcessHost* process) {
|
||||
content::WebContents* web_contents =
|
||||
static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())->
|
||||
GetWebContentsFromProcessID(process->GetID());
|
||||
if (!web_contents)
|
||||
return false;
|
||||
|
||||
NativeWindow* window = NativeWindow::FromWebContents(web_contents);
|
||||
if (!window)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
RenderProcessPreferences::RenderProcessPreferences(
|
||||
v8::Isolate* isolate,
|
||||
const atom::RenderProcessPreferences::Predicate& predicate)
|
||||
: preferences_(predicate) {
|
||||
Init(isolate);
|
||||
}
|
||||
|
||||
RenderProcessPreferences::~RenderProcessPreferences() {
|
||||
}
|
||||
|
||||
int RenderProcessPreferences::AddEntry(const base::DictionaryValue& entry) {
|
||||
return preferences_.AddEntry(entry);
|
||||
}
|
||||
|
||||
void RenderProcessPreferences::RemoveEntry(int id) {
|
||||
preferences_.RemoveEntry(id);
|
||||
}
|
||||
|
||||
// static
|
||||
void RenderProcessPreferences::BuildPrototype(
|
||||
v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> prototype) {
|
||||
mate::ObjectTemplateBuilder(isolate, prototype)
|
||||
.SetMethod("addEntry", &RenderProcessPreferences::AddEntry)
|
||||
.SetMethod("removeEntry", &RenderProcessPreferences::RemoveEntry);
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<RenderProcessPreferences>
|
||||
RenderProcessPreferences::ForAllBrowserWindow(v8::Isolate* isolate) {
|
||||
return mate::CreateHandle(
|
||||
isolate,
|
||||
new RenderProcessPreferences(isolate, base::Bind(&IsBrowserWindow)));
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
namespace {
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context, void* priv) {
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("forAllBrowserWindow",
|
||||
&atom::api::RenderProcessPreferences::ForAllBrowserWindow);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_render_process_preferences,
|
||||
Initialize)
|
||||
44
atom/browser/api/atom_api_render_process_preferences.h
Normal file
44
atom/browser/api/atom_api_render_process_preferences.h
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_API_ATOM_API_RENDER_PROCESS_PREFERENCES_H_
|
||||
#define ATOM_BROWSER_API_ATOM_API_RENDER_PROCESS_PREFERENCES_H_
|
||||
|
||||
#include "atom/browser/render_process_preferences.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
class RenderProcessPreferences
|
||||
: public mate::Wrappable<RenderProcessPreferences> {
|
||||
public:
|
||||
static mate::Handle<RenderProcessPreferences>
|
||||
ForAllBrowserWindow(v8::Isolate* isolate);
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::ObjectTemplate> prototype);
|
||||
|
||||
int AddEntry(const base::DictionaryValue& entry);
|
||||
void RemoveEntry(int id);
|
||||
|
||||
protected:
|
||||
RenderProcessPreferences(
|
||||
v8::Isolate* isolate,
|
||||
const atom::RenderProcessPreferences::Predicate& predicate);
|
||||
~RenderProcessPreferences() override;
|
||||
|
||||
private:
|
||||
atom::RenderProcessPreferences preferences_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(RenderProcessPreferences);
|
||||
};
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_API_ATOM_API_RENDER_PROCESS_PREFERENCES_H_
|
||||
@@ -99,7 +99,7 @@ v8::Local<v8::Value> Screen::Create(v8::Isolate* isolate) {
|
||||
return v8::Null(isolate);
|
||||
}
|
||||
|
||||
gfx::Screen* screen = gfx::Screen::GetNativeScreen();
|
||||
gfx::Screen* screen = gfx::Screen::GetScreen();
|
||||
if (!screen) {
|
||||
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
|
||||
isolate, "Failed to get screen information")));
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/guid.h"
|
||||
#include "base/prefs/pref_service.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/thread_task_runner_handle.h"
|
||||
@@ -36,6 +36,8 @@
|
||||
#include "net/base/load_flags.h"
|
||||
#include "net/disk_cache/disk_cache.h"
|
||||
#include "net/dns/host_cache.h"
|
||||
#include "net/http/http_auth_handler_factory.h"
|
||||
#include "net/http/http_auth_preferences.h"
|
||||
#include "net/proxy/proxy_service.h"
|
||||
#include "net/proxy/proxy_config_service_fixed.h"
|
||||
#include "net/url_request/url_request_context.h"
|
||||
@@ -190,7 +192,7 @@ class ResolveProxyHelper {
|
||||
|
||||
// Start the request.
|
||||
int result = proxy_service->ResolveProxy(
|
||||
url, net::LOAD_NORMAL, &proxy_info_, completion_callback,
|
||||
url, "GET", net::LOAD_NORMAL, &proxy_info_, completion_callback,
|
||||
&pac_req_, nullptr, net::BoundNetLog());
|
||||
|
||||
// Completed synchronously.
|
||||
@@ -284,6 +286,19 @@ void ClearHostResolverCacheInIO(
|
||||
}
|
||||
}
|
||||
|
||||
void AllowNTLMCredentialsForDomainsInIO(
|
||||
const scoped_refptr<net::URLRequestContextGetter>& context_getter,
|
||||
const std::string& domains) {
|
||||
auto request_context = context_getter->GetURLRequestContext();
|
||||
auto auth_handler = request_context->http_auth_handler_factory();
|
||||
if (auth_handler) {
|
||||
auto auth_preferences = const_cast<net::HttpAuthPreferences*>(
|
||||
auth_handler->http_auth_preferences());
|
||||
if (auth_preferences)
|
||||
auth_preferences->set_server_whitelist(domains);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Session::Session(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
||||
@@ -369,7 +384,7 @@ void Session::SetDownloadPath(const base::FilePath& path) {
|
||||
}
|
||||
|
||||
void Session::EnableNetworkEmulation(const mate::Dictionary& options) {
|
||||
scoped_ptr<brightray::DevToolsNetworkConditions> conditions;
|
||||
std::unique_ptr<brightray::DevToolsNetworkConditions> conditions;
|
||||
bool offline = false;
|
||||
double latency, download_throughput, upload_throughput;
|
||||
if (options.Get("offline", &offline) && offline) {
|
||||
@@ -392,7 +407,7 @@ void Session::EnableNetworkEmulation(const mate::Dictionary& options) {
|
||||
}
|
||||
|
||||
void Session::DisableNetworkEmulation() {
|
||||
scoped_ptr<brightray::DevToolsNetworkConditions> conditions;
|
||||
std::unique_ptr<brightray::DevToolsNetworkConditions> conditions;
|
||||
browser_context_->network_controller_handle()->SetNetworkState(
|
||||
devtools_network_emulation_client_id_, std::move(conditions));
|
||||
browser_context_->network_delegate()->SetDevToolsNetworkEmulationClientId(
|
||||
@@ -432,6 +447,13 @@ void Session::ClearHostResolverCache(mate::Arguments* args) {
|
||||
callback));
|
||||
}
|
||||
|
||||
void Session::AllowNTLMCredentialsForDomains(const std::string& domains) {
|
||||
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(&AllowNTLMCredentialsForDomainsInIO,
|
||||
make_scoped_refptr(browser_context_->GetRequestContext()),
|
||||
domains));
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> Session::Cookies(v8::Isolate* isolate) {
|
||||
if (cookies_.IsEmpty()) {
|
||||
auto handle = atom::api::Cookies::Create(isolate, browser_context());
|
||||
@@ -487,6 +509,8 @@ void Session::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("setPermissionRequestHandler",
|
||||
&Session::SetPermissionRequestHandler)
|
||||
.SetMethod("clearHostResolverCache", &Session::ClearHostResolverCache)
|
||||
.SetMethod("allowNTLMCredentialsForDomains",
|
||||
&Session::AllowNTLMCredentialsForDomains)
|
||||
.SetProperty("cookies", &Session::Cookies)
|
||||
.SetProperty("webRequest", &Session::WebRequest);
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ class Session: public mate::TrackableObject<Session>,
|
||||
void SetPermissionRequestHandler(v8::Local<v8::Value> val,
|
||||
mate::Arguments* args);
|
||||
void ClearHostResolverCache(mate::Arguments* args);
|
||||
void AllowNTLMCredentialsForDomains(const std::string& domains);
|
||||
v8::Local<v8::Value> Cookies(v8::Isolate* isolate);
|
||||
v8::Local<v8::Value> WebRequest(v8::Isolate* isolate);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "atom/browser/api/atom_api_system_preferences.h"
|
||||
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
#include "base/callback.h"
|
||||
#include "native_mate/handle.h"
|
||||
|
||||
namespace base {
|
||||
class DictionaryValue;
|
||||
}
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
@@ -22,11 +26,16 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences> {
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::ObjectTemplate> prototype);
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
using NotificationCallback = base::Callback<
|
||||
void(const std::string&, const base::DictionaryValue&)>;
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
bool IsAeroGlassEnabled();
|
||||
#elif defined(OS_MACOSX)
|
||||
int SubscribeNotification(const std::string& name,
|
||||
const base::Closure& callback);
|
||||
const NotificationCallback& callback);
|
||||
void UnsubscribeNotification(int id);
|
||||
v8::Local<v8::Value> GetUserDefault(const std::string& name,
|
||||
const std::string& type);
|
||||
|
||||
@@ -8,8 +8,10 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "atom/browser/mac/dict_util.h"
|
||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "base/values.h"
|
||||
#include "net/base/mac/url_conversions.h"
|
||||
|
||||
namespace atom {
|
||||
@@ -25,16 +27,26 @@ std::map<int, id> g_id_map;
|
||||
|
||||
} // namespace
|
||||
|
||||
int SystemPreferences::SubscribeNotification(const std::string& name,
|
||||
const base::Closure& callback) {
|
||||
int SystemPreferences::SubscribeNotification(
|
||||
const std::string& name, const NotificationCallback& callback) {
|
||||
int request_id = g_next_id++;
|
||||
__block base::Closure copied_callback = callback;
|
||||
__block NotificationCallback copied_callback = callback;
|
||||
g_id_map[request_id] = [[NSDistributedNotificationCenter defaultCenter]
|
||||
addObserverForName:base::SysUTF8ToNSString(name)
|
||||
object:nil
|
||||
queue:nil
|
||||
usingBlock:^(NSNotification* notification) {
|
||||
copied_callback.Run();
|
||||
std::unique_ptr<base::DictionaryValue> user_info =
|
||||
NSDictionaryToDictionaryValue(notification.userInfo);
|
||||
if (user_info) {
|
||||
copied_callback.Run(
|
||||
base::SysNSStringToUTF8(notification.name),
|
||||
*user_info);
|
||||
} else {
|
||||
copied_callback.Run(
|
||||
base::SysNSStringToUTF8(notification.name),
|
||||
base::DictionaryValue());
|
||||
}
|
||||
}
|
||||
];
|
||||
return request_id;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "atom/browser/api/atom_api_menu.h"
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/browser/ui/tray_icon.h"
|
||||
#include "atom/common/api/atom_api_native_image.h"
|
||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||
#include "atom/common/native_mate_converters/image_converter.h"
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
@@ -22,9 +23,9 @@ namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
Tray::Tray(v8::Isolate* isolate, const gfx::Image& image)
|
||||
Tray::Tray(v8::Isolate* isolate, mate::Handle<NativeImage> image)
|
||||
: tray_icon_(TrayIcon::Create()) {
|
||||
tray_icon_->SetImage(image);
|
||||
SetImage(isolate, image);
|
||||
tray_icon_->AddObserver(this);
|
||||
}
|
||||
|
||||
@@ -32,7 +33,8 @@ Tray::~Tray() {
|
||||
}
|
||||
|
||||
// static
|
||||
mate::WrappableBase* Tray::New(v8::Isolate* isolate, const gfx::Image& image) {
|
||||
mate::WrappableBase* Tray::New(v8::Isolate* isolate,
|
||||
mate::Handle<NativeImage> image) {
|
||||
if (!Browser::Get()->is_ready()) {
|
||||
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
|
||||
isolate, "Cannot create Tray before app is ready")));
|
||||
@@ -94,29 +96,38 @@ void Tray::OnDragEnded() {
|
||||
Emit("drag-end");
|
||||
}
|
||||
|
||||
void Tray::SetImage(mate::Arguments* args, const gfx::Image& image) {
|
||||
tray_icon_->SetImage(image);
|
||||
void Tray::SetImage(v8::Isolate* isolate, mate::Handle<NativeImage> image) {
|
||||
#if defined(OS_WIN)
|
||||
tray_icon_->SetImage(image->GetHICON(GetSystemMetrics(SM_CXSMICON)));
|
||||
#else
|
||||
tray_icon_->SetImage(image->image());
|
||||
#endif
|
||||
}
|
||||
|
||||
void Tray::SetPressedImage(mate::Arguments* args, const gfx::Image& image) {
|
||||
tray_icon_->SetPressedImage(image);
|
||||
void Tray::SetPressedImage(v8::Isolate* isolate,
|
||||
mate::Handle<NativeImage> image) {
|
||||
#if defined(OS_WIN)
|
||||
tray_icon_->SetPressedImage(image->GetHICON(GetSystemMetrics(SM_CXSMICON)));
|
||||
#else
|
||||
tray_icon_->SetPressedImage(image->image());
|
||||
#endif
|
||||
}
|
||||
|
||||
void Tray::SetToolTip(mate::Arguments* args, const std::string& tool_tip) {
|
||||
void Tray::SetToolTip(const std::string& tool_tip) {
|
||||
tray_icon_->SetToolTip(tool_tip);
|
||||
}
|
||||
|
||||
void Tray::SetTitle(mate::Arguments* args, const std::string& title) {
|
||||
void Tray::SetTitle(const std::string& title) {
|
||||
tray_icon_->SetTitle(title);
|
||||
}
|
||||
|
||||
void Tray::SetHighlightMode(mate::Arguments* args, bool highlight) {
|
||||
void Tray::SetHighlightMode(bool highlight) {
|
||||
tray_icon_->SetHighlightMode(highlight);
|
||||
}
|
||||
|
||||
void Tray::DisplayBalloon(mate::Arguments* args,
|
||||
const mate::Dictionary& options) {
|
||||
gfx::Image icon;
|
||||
mate::Handle<NativeImage> icon;
|
||||
options.Get("icon", &icon);
|
||||
base::string16 title, content;
|
||||
if (!options.Get("title", &title) ||
|
||||
@@ -125,7 +136,14 @@ void Tray::DisplayBalloon(mate::Arguments* args,
|
||||
return;
|
||||
}
|
||||
|
||||
tray_icon_->DisplayBalloon(icon, title, content);
|
||||
#if defined(OS_WIN)
|
||||
tray_icon_->DisplayBalloon(
|
||||
icon.IsEmpty() ? NULL : icon->GetHICON(GetSystemMetrics(SM_CXSMICON)),
|
||||
title, content);
|
||||
#else
|
||||
tray_icon_->DisplayBalloon(
|
||||
icon.IsEmpty() ? gfx::Image() : icon->image(), title, content);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Tray::PopUpContextMenu(mate::Arguments* args) {
|
||||
@@ -136,7 +154,8 @@ void Tray::PopUpContextMenu(mate::Arguments* args) {
|
||||
tray_icon_->PopUpContextMenu(pos, menu.IsEmpty() ? nullptr : menu->model());
|
||||
}
|
||||
|
||||
void Tray::SetContextMenu(mate::Arguments* args, Menu* menu) {
|
||||
void Tray::SetContextMenu(v8::Isolate* isolate, mate::Handle<Menu> menu) {
|
||||
menu_.Reset(isolate, menu.ToV8());
|
||||
tray_icon_->SetContextMenu(menu->model());
|
||||
}
|
||||
|
||||
@@ -162,7 +181,7 @@ void Tray::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("setHighlightMode", &Tray::SetHighlightMode)
|
||||
.SetMethod("displayBalloon", &Tray::DisplayBalloon)
|
||||
.SetMethod("popUpContextMenu", &Tray::PopUpContextMenu)
|
||||
.SetMethod("_setContextMenu", &Tray::SetContextMenu);
|
||||
.SetMethod("setContextMenu", &Tray::SetContextMenu);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "atom/browser/api/trackable_object.h"
|
||||
#include "atom/browser/ui/tray_icon_observer.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "native_mate/handle.h"
|
||||
|
||||
namespace gfx {
|
||||
class Image;
|
||||
@@ -28,18 +29,19 @@ class TrayIcon;
|
||||
namespace api {
|
||||
|
||||
class Menu;
|
||||
class NativeImage;
|
||||
|
||||
class Tray : public mate::TrackableObject<Tray>,
|
||||
public TrayIconObserver {
|
||||
public:
|
||||
static mate::WrappableBase* New(
|
||||
v8::Isolate* isolate, const gfx::Image& image);
|
||||
v8::Isolate* isolate, mate::Handle<NativeImage> image);
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::ObjectTemplate> prototype);
|
||||
|
||||
protected:
|
||||
Tray(v8::Isolate* isolate, const gfx::Image& image);
|
||||
Tray(v8::Isolate* isolate, mate::Handle<NativeImage> image);
|
||||
~Tray() override;
|
||||
|
||||
// TrayIconObserver:
|
||||
@@ -55,19 +57,20 @@ class Tray : public mate::TrackableObject<Tray>,
|
||||
void OnDragExited() override;
|
||||
void OnDragEnded() override;
|
||||
|
||||
void SetImage(mate::Arguments* args, const gfx::Image& image);
|
||||
void SetPressedImage(mate::Arguments* args, const gfx::Image& image);
|
||||
void SetToolTip(mate::Arguments* args, const std::string& tool_tip);
|
||||
void SetTitle(mate::Arguments* args, const std::string& title);
|
||||
void SetHighlightMode(mate::Arguments* args, bool highlight);
|
||||
void SetImage(v8::Isolate* isolate, mate::Handle<NativeImage> image);
|
||||
void SetPressedImage(v8::Isolate* isolate, mate::Handle<NativeImage> image);
|
||||
void SetToolTip(const std::string& tool_tip);
|
||||
void SetTitle(const std::string& title);
|
||||
void SetHighlightMode(bool highlight);
|
||||
void DisplayBalloon(mate::Arguments* args, const mate::Dictionary& options);
|
||||
void PopUpContextMenu(mate::Arguments* args);
|
||||
void SetContextMenu(mate::Arguments* args, Menu* menu);
|
||||
void SetContextMenu(v8::Isolate* isolate, mate::Handle<Menu> menu);
|
||||
|
||||
private:
|
||||
v8::Local<v8::Object> ModifiersToObject(v8::Isolate* isolate, int modifiers);
|
||||
|
||||
scoped_ptr<TrayIcon> tray_icon_;
|
||||
v8::Global<v8::Object> menu_;
|
||||
std::unique_ptr<TrayIcon> tray_icon_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Tray);
|
||||
};
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#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"
|
||||
#include "atom/browser/web_contents_permission_helper.h"
|
||||
@@ -63,6 +64,7 @@
|
||||
#include "net/url_request/static_http_user_agent_settings.h"
|
||||
#include "net/url_request/url_request_context.h"
|
||||
#include "third_party/WebKit/public/web/WebInputEvent.h"
|
||||
#include "third_party/WebKit/public/web/WebFindOptions.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
@@ -144,7 +146,7 @@ struct Converter<net::HttpResponseHeaders*> {
|
||||
net::HttpResponseHeaders* headers) {
|
||||
base::DictionaryValue response_headers;
|
||||
if (headers) {
|
||||
void* iter = nullptr;
|
||||
size_t iter = 0;
|
||||
std::string key;
|
||||
std::string value;
|
||||
while (headers->EnumerateHeaderLines(&iter, &key, &value)) {
|
||||
@@ -154,7 +156,7 @@ struct Converter<net::HttpResponseHeaders*> {
|
||||
if (response_headers.GetList(key, &values))
|
||||
values->AppendString(value);
|
||||
} else {
|
||||
scoped_ptr<base::ListValue> values(new base::ListValue());
|
||||
std::unique_ptr<base::ListValue> values(new base::ListValue());
|
||||
values->AppendString(value);
|
||||
response_headers.Set(key, std::move(values));
|
||||
}
|
||||
@@ -260,8 +262,9 @@ WebContents::WebContents(v8::Isolate* isolate,
|
||||
|
||||
content::WebContents* web_contents;
|
||||
if (is_guest) {
|
||||
content::SiteInstance* site_instance = content::SiteInstance::CreateForURL(
|
||||
session->browser_context(), GURL("chrome-guest://fake-host"));
|
||||
scoped_refptr<content::SiteInstance> site_instance =
|
||||
content::SiteInstance::CreateForURL(
|
||||
session->browser_context(), GURL("chrome-guest://fake-host"));
|
||||
content::WebContents::CreateParams params(
|
||||
session->browser_context(), site_instance);
|
||||
guest_delegate_.reset(new WebViewGuestDelegate);
|
||||
@@ -273,7 +276,7 @@ WebContents::WebContents(v8::Isolate* isolate,
|
||||
}
|
||||
|
||||
Observe(web_contents);
|
||||
InitWithWebContents(web_contents);
|
||||
InitWithWebContents(web_contents, session->browser_context());
|
||||
|
||||
managed_web_contents()->GetView()->SetDelegate(this);
|
||||
|
||||
@@ -378,7 +381,7 @@ void WebContents::MoveContents(content::WebContents* source,
|
||||
|
||||
void WebContents::CloseContents(content::WebContents* source) {
|
||||
Emit("close");
|
||||
if (type_ == BROWSER_WINDOW)
|
||||
if (type_ == BROWSER_WINDOW && owner_window())
|
||||
owner_window()->CloseContents(source);
|
||||
}
|
||||
|
||||
@@ -393,14 +396,12 @@ bool WebContents::IsPopupOrPanel(const content::WebContents* source) const {
|
||||
void WebContents::HandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
if (event.windowsKeyCode == ui::VKEY_ESCAPE && is_html_fullscreen()) {
|
||||
// Escape exits tabbed fullscreen mode.
|
||||
ExitFullscreenModeForTab(source);
|
||||
} else if (type_ == BROWSER_WINDOW) {
|
||||
owner_window()->HandleKeyboardEvent(source, event);
|
||||
} else if (type_ == WEB_VIEW && guest_delegate_) {
|
||||
if (type_ == WEB_VIEW && embedder_) {
|
||||
// Send the unhandled keyboard events back to the embedder.
|
||||
guest_delegate_->HandleKeyboardEvent(source, event);
|
||||
embedder_->HandleKeyboardEvent(source, event);
|
||||
} else {
|
||||
// Go to the default keyboard handling.
|
||||
CommonWebContentsDelegate::HandleKeyboardEvent(source, event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -429,13 +430,13 @@ void WebContents::ExitFullscreenModeForTab(content::WebContents* source) {
|
||||
|
||||
void WebContents::RendererUnresponsive(content::WebContents* source) {
|
||||
Emit("unresponsive");
|
||||
if (type_ == BROWSER_WINDOW)
|
||||
if (type_ == BROWSER_WINDOW && owner_window())
|
||||
owner_window()->RendererUnresponsive(source);
|
||||
}
|
||||
|
||||
void WebContents::RendererResponsive(content::WebContents* source) {
|
||||
Emit("responsive");
|
||||
if (type_ == BROWSER_WINDOW)
|
||||
if (type_ == BROWSER_WINDOW && owner_window())
|
||||
owner_window()->RendererResponsive(source);
|
||||
}
|
||||
|
||||
@@ -504,6 +505,14 @@ void WebContents::RequestToLockMouse(
|
||||
permission_helper->RequestPointerLockPermission(user_gesture);
|
||||
}
|
||||
|
||||
std::unique_ptr<content::BluetoothChooser> WebContents::RunBluetoothChooser(
|
||||
content::RenderFrameHost* frame,
|
||||
const content::BluetoothChooser::EventHandler& event_handler) {
|
||||
std::unique_ptr<BluetoothChooser> bluetooth_chooser(
|
||||
new BluetoothChooser(this, event_handler));
|
||||
return std::move(bluetooth_chooser);
|
||||
}
|
||||
|
||||
void WebContents::BeforeUnloadFired(const base::TimeTicks& proceed_time) {
|
||||
// Do nothing, we override this method just to avoid compilation error since
|
||||
// there are two virtual functions named BeforeUnloadFired.
|
||||
@@ -655,6 +664,11 @@ void WebContents::DevToolsOpened() {
|
||||
isolate(), managed_web_contents()->GetDevToolsWebContents());
|
||||
devtools_web_contents_.Reset(isolate(), handle.ToV8());
|
||||
|
||||
// Set inspected tabID.
|
||||
base::FundamentalValue tab_id(ID());
|
||||
managed_web_contents()->CallClientFunction(
|
||||
"DevToolsAPI.setInspectedTabId", &tab_id, nullptr, nullptr);
|
||||
|
||||
// Inherit owner window in devtools.
|
||||
if (owner_window())
|
||||
handle->SetOwnerWindow(managed_web_contents()->GetDevToolsWebContents(),
|
||||
@@ -865,7 +879,7 @@ void WebContents::OpenDevTools(mate::Arguments* args) {
|
||||
return;
|
||||
|
||||
std::string state;
|
||||
if (type_ == WEB_VIEW) {
|
||||
if (type_ == WEB_VIEW || !owner_window()) {
|
||||
state = "detach";
|
||||
} else if (args && args->Length() == 1) {
|
||||
bool detach = false;
|
||||
@@ -1083,9 +1097,10 @@ void WebContents::TabTraverse(bool reverse) {
|
||||
web_contents()->FocusThroughTabTraversal(reverse);
|
||||
}
|
||||
|
||||
bool WebContents::SendIPCMessage(const base::string16& channel,
|
||||
bool WebContents::SendIPCMessage(bool all_frames,
|
||||
const base::string16& channel,
|
||||
const base::ListValue& args) {
|
||||
return Send(new AtomViewMsg_Message(routing_id(), channel, args));
|
||||
return Send(new AtomViewMsg_Message(routing_id(), all_frames, channel, args));
|
||||
}
|
||||
|
||||
void WebContents::SendInputEvent(v8::Isolate* isolate,
|
||||
@@ -1126,7 +1141,7 @@ void WebContents::BeginFrameSubscription(
|
||||
const FrameSubscriber::FrameCaptureCallback& callback) {
|
||||
const auto view = web_contents()->GetRenderWidgetHostView();
|
||||
if (view) {
|
||||
scoped_ptr<FrameSubscriber> frame_subscriber(new FrameSubscriber(
|
||||
std::unique_ptr<FrameSubscriber> frame_subscriber(new FrameSubscriber(
|
||||
isolate(), view, callback));
|
||||
view->BeginFrameSubscription(std::move(frame_subscriber));
|
||||
}
|
||||
@@ -1173,6 +1188,10 @@ v8::Local<v8::Value> WebContents::GetOwnerBrowserWindow() {
|
||||
return v8::Null(isolate());
|
||||
}
|
||||
|
||||
int32_t WebContents::ID() const {
|
||||
return weak_map_id();
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> WebContents::Session(v8::Isolate* isolate) {
|
||||
return v8::Local<v8::Value>::New(isolate, session_);
|
||||
}
|
||||
@@ -1265,6 +1284,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("_printToPDF", &WebContents::PrintToPDF)
|
||||
.SetMethod("addWorkSpace", &WebContents::AddWorkSpace)
|
||||
.SetMethod("removeWorkSpace", &WebContents::RemoveWorkSpace)
|
||||
.SetProperty("id", &WebContents::ID)
|
||||
.SetProperty("session", &WebContents::Session)
|
||||
.SetProperty("hostWebContents", &WebContents::HostWebContents)
|
||||
.SetProperty("devToolsWebContents", &WebContents::DevToolsWebContents)
|
||||
@@ -1328,6 +1348,8 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.SetMethod("create", &atom::api::WebContents::Create);
|
||||
dict.SetMethod("_setWrapWebContents", &atom::api::SetWrapWebContents);
|
||||
dict.SetMethod("fromId",
|
||||
&mate::TrackableObject<atom::api::WebContents>::FromWeakMapID);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -122,7 +122,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
void TabTraverse(bool reverse);
|
||||
|
||||
// Send messages to browser.
|
||||
bool SendIPCMessage(const base::string16& channel,
|
||||
bool SendIPCMessage(bool all_frames,
|
||||
const base::string16& channel,
|
||||
const base::ListValue& args);
|
||||
|
||||
// Send WebInputEvent to the page.
|
||||
@@ -154,6 +155,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
v8::Local<v8::Value> GetOwnerBrowserWindow();
|
||||
|
||||
// Properties.
|
||||
int32_t ID() const;
|
||||
v8::Local<v8::Value> Session(v8::Isolate* isolate);
|
||||
content::WebContents* HostWebContents();
|
||||
v8::Local<v8::Value> DevToolsWebContents(v8::Isolate* isolate);
|
||||
@@ -209,6 +211,9 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
content::WebContents* web_contents,
|
||||
bool user_gesture,
|
||||
bool last_unlocked_by_target) override;
|
||||
std::unique_ptr<content::BluetoothChooser> RunBluetoothChooser(
|
||||
content::RenderFrameHost* frame,
|
||||
const content::BluetoothChooser::EventHandler& handler) override;
|
||||
|
||||
// content::WebContentsObserver:
|
||||
void BeforeUnloadFired(const base::TimeTicks& proceed_time) override;
|
||||
@@ -288,7 +293,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
v8::Global<v8::Value> devtools_web_contents_;
|
||||
v8::Global<v8::Value> debugger_;
|
||||
|
||||
scoped_ptr<WebViewGuestDelegate> guest_delegate_;
|
||||
std::unique_ptr<WebViewGuestDelegate> guest_delegate_;
|
||||
|
||||
// The host webcontents that may contain this webcontents.
|
||||
WebContents* embedder_;
|
||||
|
||||
@@ -14,22 +14,12 @@ using atom::WebContentsPreferences;
|
||||
|
||||
namespace {
|
||||
|
||||
atom::WebViewManager* GetWebViewManager(content::WebContents* web_contents) {
|
||||
auto context = web_contents->GetBrowserContext();
|
||||
if (context) {
|
||||
auto manager = context->GetGuestManager();
|
||||
return static_cast<atom::WebViewManager*>(manager);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void AddGuest(int guest_instance_id,
|
||||
int element_instance_id,
|
||||
content::WebContents* embedder,
|
||||
content::WebContents* guest_web_contents,
|
||||
const base::DictionaryValue& options) {
|
||||
auto manager = GetWebViewManager(embedder);
|
||||
auto manager = atom::WebViewManager::GetWebViewManager(embedder);
|
||||
if (manager)
|
||||
manager->AddGuest(guest_instance_id, element_instance_id, embedder,
|
||||
guest_web_contents);
|
||||
@@ -38,7 +28,7 @@ void AddGuest(int guest_instance_id,
|
||||
}
|
||||
|
||||
void RemoveGuest(content::WebContents* embedder, int guest_instance_id) {
|
||||
auto manager = GetWebViewManager(embedder);
|
||||
auto manager = atom::WebViewManager::GetWebViewManager(embedder);
|
||||
if (manager)
|
||||
manager->RemoveGuest(guest_instance_id);
|
||||
}
|
||||
|
||||
@@ -21,8 +21,11 @@
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
#include "atom/browser/native_window_views.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "atom/browser/ui/win/taskbar_host.h"
|
||||
#endif
|
||||
|
||||
@@ -99,6 +102,13 @@ Window::Window(v8::Isolate* isolate, const mate::Dictionary& options) {
|
||||
window_->InitFromOptions(options);
|
||||
window_->AddObserver(this);
|
||||
AttachAsUserData(window_.get());
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
// Sets the window icon.
|
||||
mate::Handle<NativeImage> icon;
|
||||
if (options.Get(options::kIcon, &icon))
|
||||
SetIcon(icon);
|
||||
#endif
|
||||
}
|
||||
|
||||
Window::~Window() {
|
||||
@@ -371,8 +381,10 @@ std::vector<int> Window::GetMaximumSize() {
|
||||
return result;
|
||||
}
|
||||
|
||||
void Window::SetSheetOffset(double offset) {
|
||||
window_->SetSheetOffset(offset);
|
||||
void Window::SetSheetOffset(double offsetY, mate::Arguments* args) {
|
||||
double offsetX = 0.0;
|
||||
args->GetNext(&offsetX);
|
||||
window_->SetSheetOffset(offsetX, offsetY);
|
||||
}
|
||||
|
||||
void Window::SetResizable(bool resizable) {
|
||||
@@ -617,6 +629,19 @@ void Window::ShowDefinitionForSelection() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
void Window::SetIcon(mate::Handle<NativeImage> icon) {
|
||||
#if defined(OS_WIN)
|
||||
static_cast<NativeWindowViews*>(window_.get())->SetIcon(
|
||||
icon->GetHICON(GetSystemMetrics(SM_CXSMICON)),
|
||||
icon->GetHICON(GetSystemMetrics(SM_CXICON)));
|
||||
#elif defined(USE_X11)
|
||||
static_cast<NativeWindowViews*>(window_.get())->SetIcon(
|
||||
icon->image().AsImageSkia());
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void Window::SetAspectRatio(double aspect_ratio, mate::Arguments* args) {
|
||||
gfx::Size extra_size;
|
||||
args->GetNext(&extra_size);
|
||||
@@ -738,6 +763,9 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
||||
#if defined(OS_MACOSX)
|
||||
.SetMethod("showDefinitionForSelection",
|
||||
&Window::ShowDefinitionForSelection)
|
||||
#endif
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
.SetMethod("setIcon", &Window::SetIcon)
|
||||
#endif
|
||||
.SetProperty("id", &Window::ID)
|
||||
.SetProperty("webContents", &Window::WebContents);
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "atom/browser/api/trackable_object.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/native_window_observer.h"
|
||||
#include "atom/common/api/atom_api_native_image.h"
|
||||
#include "native_mate/handle.h"
|
||||
|
||||
class GURL;
|
||||
@@ -110,7 +111,7 @@ class Window : public mate::TrackableObject<Window>,
|
||||
std::vector<int> GetMinimumSize();
|
||||
void SetMaximumSize(int width, int height);
|
||||
std::vector<int> GetMaximumSize();
|
||||
void SetSheetOffset(double offset);
|
||||
void SetSheetOffset(double offsetY, mate::Arguments* args);
|
||||
void SetResizable(bool resizable);
|
||||
bool IsResizable();
|
||||
void SetMovable(bool movable);
|
||||
@@ -172,6 +173,10 @@ class Window : public mate::TrackableObject<Window>,
|
||||
void ShowDefinitionForSelection();
|
||||
#endif
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
void SetIcon(mate::Handle<NativeImage> icon);
|
||||
#endif
|
||||
|
||||
void SetVisibleOnAllWorkspaces(bool visible);
|
||||
bool IsVisibleOnAllWorkspaces();
|
||||
|
||||
@@ -188,7 +193,7 @@ class Window : public mate::TrackableObject<Window>,
|
||||
|
||||
api::WebContents* api_web_contents_;
|
||||
|
||||
scoped_ptr<NativeWindow> window_;
|
||||
std::unique_ptr<NativeWindow> window_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Window);
|
||||
};
|
||||
|
||||
@@ -113,7 +113,7 @@ class TrackableObject : public TrackableObjectBase,
|
||||
|
||||
void AfterInit(v8::Isolate* isolate) override {
|
||||
if (!weak_map_) {
|
||||
weak_map_.reset(new atom::KeyWeakMap<int32_t>);
|
||||
weak_map_ = new atom::KeyWeakMap<int32_t>;
|
||||
}
|
||||
weak_map_id_ = ++next_id_;
|
||||
weak_map_->Set(isolate, weak_map_id_, Wrappable<T>::GetWrapper());
|
||||
@@ -123,7 +123,7 @@ class TrackableObject : public TrackableObjectBase,
|
||||
|
||||
private:
|
||||
static int32_t next_id_;
|
||||
static scoped_ptr<atom::KeyWeakMap<int32_t>> weak_map_;
|
||||
static atom::KeyWeakMap<int32_t>* weak_map_; // leaked on purpose
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(TrackableObject);
|
||||
};
|
||||
@@ -132,7 +132,7 @@ template<typename T>
|
||||
int32_t TrackableObject<T>::next_id_ = 0;
|
||||
|
||||
template<typename T>
|
||||
scoped_ptr<atom::KeyWeakMap<int32_t>> TrackableObject<T>::weak_map_;
|
||||
atom::KeyWeakMap<int32_t>* TrackableObject<T>::weak_map_ = nullptr;
|
||||
|
||||
} // namespace mate
|
||||
|
||||
|
||||
@@ -32,18 +32,18 @@ AtomAccessTokenStore::~AtomAccessTokenStore() {
|
||||
}
|
||||
|
||||
void AtomAccessTokenStore::LoadAccessTokens(
|
||||
const LoadAccessTokensCallbackType& callback) {
|
||||
AccessTokenSet access_token_set;
|
||||
const LoadAccessTokensCallback& callback) {
|
||||
AccessTokenMap access_token_map;
|
||||
|
||||
// Equivelent to access_token_set[kGeolocationProviderURL].
|
||||
// Equivelent 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.
|
||||
std::pair<GURL, base::string16> token_pair;
|
||||
token_pair.first = GURL(kGeolocationProviderURL);
|
||||
access_token_set.insert(token_pair);
|
||||
access_token_map.insert(token_pair);
|
||||
|
||||
auto browser_context = AtomBrowserMainParts::Get()->browser_context();
|
||||
callback.Run(access_token_set, browser_context->url_request_context_getter());
|
||||
callback.Run(access_token_map, browser_context->url_request_context_getter());
|
||||
}
|
||||
|
||||
void AtomAccessTokenStore::SaveAccessToken(const GURL& server_url,
|
||||
|
||||
@@ -18,7 +18,7 @@ class AtomAccessTokenStore : public content::AccessTokenStore {
|
||||
|
||||
// content::AccessTokenStore:
|
||||
void LoadAccessTokens(
|
||||
const LoadAccessTokensCallbackType& callback) override;
|
||||
const LoadAccessTokensCallback& callback) override;
|
||||
void SaveAccessToken(const GURL& server_url,
|
||||
const base::string16& access_token) override;
|
||||
|
||||
|
||||
@@ -52,6 +52,9 @@ bool g_suppress_renderer_process_restart = false;
|
||||
// Custom schemes to be registered to handle service worker.
|
||||
std::string g_custom_service_worker_schemes = "";
|
||||
|
||||
void Noop(scoped_refptr<content::SiteInstance>) {
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
@@ -70,6 +73,17 @@ AtomBrowserClient::AtomBrowserClient() : delegate_(nullptr) {
|
||||
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))
|
||||
process_id = pending_processes_[process_id];
|
||||
|
||||
// Certain render process will be created with no associated render view,
|
||||
// for example: ServiceWorker.
|
||||
return WebContentsPreferences::GetWebContentsFromProcessID(process_id);
|
||||
}
|
||||
|
||||
void AtomBrowserClient::RenderProcessWillLaunch(
|
||||
content::RenderProcessHost* host) {
|
||||
int process_id = host->GetID();
|
||||
@@ -129,7 +143,16 @@ void AtomBrowserClient::OverrideSiteInstanceForNavigation(
|
||||
if (url.SchemeIs(url::kJavaScriptScheme))
|
||||
return;
|
||||
|
||||
*new_instance = content::SiteInstance::CreateForURL(browser_context, url);
|
||||
scoped_refptr<content::SiteInstance> site_instance =
|
||||
content::SiteInstance::CreateForURL(browser_context, url);
|
||||
*new_instance = site_instance.get();
|
||||
|
||||
// Make sure the |site_instance| is not freed when this function returns.
|
||||
// FIXME(zcbenz): We should adjust OverrideSiteInstanceForNavigation's
|
||||
// interface to solve this.
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(&Noop, base::RetainedRef(site_instance)));
|
||||
|
||||
// Remember the original renderer process of the pending renderer process.
|
||||
auto current_process = current_instance->GetProcess();
|
||||
@@ -160,14 +183,7 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
||||
}
|
||||
#endif
|
||||
|
||||
// If the process is a pending process, we should use the old one.
|
||||
if (ContainsKey(pending_processes_, process_id))
|
||||
process_id = pending_processes_[process_id];
|
||||
|
||||
// Certain render process will be created with no associated render view,
|
||||
// for example: ServiceWorker.
|
||||
content::WebContents* web_contents =
|
||||
WebContentsPreferences::GetWebContentsFromProcessID(process_id);
|
||||
content::WebContents* web_contents = GetWebContentsFromProcessID(process_id);
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
@@ -208,7 +224,7 @@ void AtomBrowserClient::AllowCertificateError(
|
||||
void AtomBrowserClient::SelectClientCertificate(
|
||||
content::WebContents* web_contents,
|
||||
net::SSLCertRequestInfo* cert_request_info,
|
||||
scoped_ptr<content::ClientCertificateDelegate> delegate) {
|
||||
std::unique_ptr<content::ClientCertificateDelegate> delegate) {
|
||||
if (!cert_request_info->client_certs.empty() && delegate_) {
|
||||
delegate_->SelectClientCertificate(
|
||||
web_contents, cert_request_info, std::move(delegate));
|
||||
|
||||
@@ -34,6 +34,9 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
using Delegate = content::ContentBrowserClient;
|
||||
void set_delegate(Delegate* delegate) { delegate_ = delegate; }
|
||||
|
||||
// Returns the WebContents for pending render processes.
|
||||
content::WebContents* GetWebContentsFromProcessID(int process_id);
|
||||
|
||||
// Don't force renderer process to restart for once.
|
||||
static void SuppressRendererProcessRestartForOnce();
|
||||
|
||||
@@ -73,7 +76,7 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
void SelectClientCertificate(
|
||||
content::WebContents* web_contents,
|
||||
net::SSLCertRequestInfo* cert_request_info,
|
||||
scoped_ptr<content::ClientCertificateDelegate> delegate) override;
|
||||
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
|
||||
void ResourceDispatcherHostCreated() override;
|
||||
bool CanCreateWindow(const GURL& opener_url,
|
||||
const GURL& opener_top_level_frame_url,
|
||||
@@ -106,7 +109,7 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
// pending_render_process => current_render_process.
|
||||
std::map<int, int> pending_processes_;
|
||||
|
||||
scoped_ptr<AtomResourceDispatcherHostDelegate>
|
||||
std::unique_ptr<AtomResourceDispatcherHostDelegate>
|
||||
resource_dispatcher_host_delegate_;
|
||||
|
||||
Delegate* delegate_;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "base/command_line.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/prefs/pref_registry_simple.h"
|
||||
#include "components/prefs/pref_registry_simple.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/threading/sequenced_worker_pool.h"
|
||||
@@ -46,7 +46,7 @@ namespace {
|
||||
|
||||
class NoCacheBackend : public net::HttpCache::BackendFactory {
|
||||
int CreateBackend(net::NetLog* net_log,
|
||||
scoped_ptr<disk_cache::Backend>* backend,
|
||||
std::unique_ptr<disk_cache::Backend>* backend,
|
||||
const net::CompletionCallback& callback) override {
|
||||
return net::ERR_FAILED;
|
||||
}
|
||||
@@ -67,8 +67,7 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition,
|
||||
: brightray::BrowserContext(partition, in_memory),
|
||||
cert_verifier_(new AtomCertVerifier),
|
||||
job_factory_(new AtomURLRequestJobFactory),
|
||||
network_delegate_(new AtomNetworkDelegate),
|
||||
allow_ntlm_everywhere_(false) {
|
||||
network_delegate_(new AtomNetworkDelegate) {
|
||||
}
|
||||
|
||||
AtomBrowserContext::~AtomBrowserContext() {
|
||||
@@ -95,11 +94,11 @@ std::string AtomBrowserContext::GetUserAgent() {
|
||||
return content::BuildUserAgentFromProduct(user_agent);
|
||||
}
|
||||
|
||||
scoped_ptr<net::URLRequestJobFactory>
|
||||
std::unique_ptr<net::URLRequestJobFactory>
|
||||
AtomBrowserContext::CreateURLRequestJobFactory(
|
||||
content::ProtocolHandlerMap* handlers,
|
||||
content::URLRequestInterceptorScopedVector* interceptors) {
|
||||
scoped_ptr<AtomURLRequestJobFactory> job_factory(job_factory_);
|
||||
std::unique_ptr<AtomURLRequestJobFactory> job_factory(job_factory_);
|
||||
|
||||
for (auto& it : *handlers) {
|
||||
job_factory->SetProtocolHandler(it.first,
|
||||
@@ -134,7 +133,7 @@ AtomBrowserContext::CreateURLRequestJobFactory(
|
||||
new net::FtpNetworkLayer(host_resolver))));
|
||||
|
||||
// Set up interceptors in the reverse order.
|
||||
scoped_ptr<net::URLRequestJobFactory> top_job_factory =
|
||||
std::unique_ptr<net::URLRequestJobFactory> top_job_factory =
|
||||
std::move(job_factory);
|
||||
content::URLRequestInterceptorScopedVector::reverse_iterator it;
|
||||
for (it = interceptors->rbegin(); it != interceptors->rend(); ++it)
|
||||
@@ -177,7 +176,7 @@ content::PermissionManager* AtomBrowserContext::GetPermissionManager() {
|
||||
return permission_manager_.get();
|
||||
}
|
||||
|
||||
scoped_ptr<net::CertVerifier> AtomBrowserContext::CreateCertVerifier() {
|
||||
std::unique_ptr<net::CertVerifier> AtomBrowserContext::CreateCertVerifier() {
|
||||
return make_scoped_ptr(cert_verifier_);
|
||||
}
|
||||
|
||||
@@ -195,16 +194,6 @@ void AtomBrowserContext::RegisterPrefs(PrefRegistrySimple* pref_registry) {
|
||||
pref_registry->RegisterDictionaryPref(prefs::kDevToolsFileSystemPaths);
|
||||
}
|
||||
|
||||
bool AtomBrowserContext::AllowNTLMCredentialsForDomain(const GURL& origin) {
|
||||
if (allow_ntlm_everywhere_)
|
||||
return true;
|
||||
return Delegate::AllowNTLMCredentialsForDomain(origin);
|
||||
}
|
||||
|
||||
void AtomBrowserContext::AllowNTLMCredentialsForAllDomains(bool should_allow) {
|
||||
allow_ntlm_everywhere_ = should_allow;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
namespace brightray {
|
||||
|
||||
@@ -26,14 +26,13 @@ class AtomBrowserContext : public brightray::BrowserContext {
|
||||
// brightray::URLRequestContextGetter::Delegate:
|
||||
net::NetworkDelegate* CreateNetworkDelegate() override;
|
||||
std::string GetUserAgent() override;
|
||||
scoped_ptr<net::URLRequestJobFactory> CreateURLRequestJobFactory(
|
||||
std::unique_ptr<net::URLRequestJobFactory> CreateURLRequestJobFactory(
|
||||
content::ProtocolHandlerMap* handlers,
|
||||
content::URLRequestInterceptorScopedVector* interceptors) override;
|
||||
net::HttpCache::BackendFactory* CreateHttpCacheBackendFactory(
|
||||
const base::FilePath& base_path) override;
|
||||
scoped_ptr<net::CertVerifier> CreateCertVerifier() override;
|
||||
std::unique_ptr<net::CertVerifier> CreateCertVerifier() override;
|
||||
net::SSLConfigService* CreateSSLConfigService() override;
|
||||
bool AllowNTLMCredentialsForDomain(const GURL& auth_origin) override;
|
||||
|
||||
// content::BrowserContext:
|
||||
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
|
||||
@@ -43,8 +42,6 @@ class AtomBrowserContext : public brightray::BrowserContext {
|
||||
// brightray::BrowserContext:
|
||||
void RegisterPrefs(PrefRegistrySimple* pref_registry) override;
|
||||
|
||||
void AllowNTLMCredentialsForAllDomains(bool should_allow);
|
||||
|
||||
AtomCertVerifier* cert_verifier() const { return cert_verifier_; }
|
||||
|
||||
AtomURLRequestJobFactory* job_factory() const { return job_factory_; }
|
||||
@@ -52,17 +49,15 @@ class AtomBrowserContext : public brightray::BrowserContext {
|
||||
AtomNetworkDelegate* network_delegate() const { return network_delegate_; }
|
||||
|
||||
private:
|
||||
scoped_ptr<AtomDownloadManagerDelegate> download_manager_delegate_;
|
||||
scoped_ptr<WebViewManager> guest_manager_;
|
||||
scoped_ptr<AtomPermissionManager> permission_manager_;
|
||||
std::unique_ptr<AtomDownloadManagerDelegate> download_manager_delegate_;
|
||||
std::unique_ptr<WebViewManager> guest_manager_;
|
||||
std::unique_ptr<AtomPermissionManager> permission_manager_;
|
||||
|
||||
// Managed by brightray::BrowserContext.
|
||||
AtomCertVerifier* cert_verifier_;
|
||||
AtomURLRequestJobFactory* job_factory_;
|
||||
AtomNetworkDelegate* network_delegate_;
|
||||
|
||||
bool allow_ntlm_everywhere_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomBrowserContext);
|
||||
};
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
|
||||
#endif
|
||||
|
||||
// A fake BrowserProcess object that used to feed the source code from chrome.
|
||||
scoped_ptr<BrowserProcess> fake_browser_process_;
|
||||
std::unique_ptr<BrowserProcess> fake_browser_process_;
|
||||
|
||||
// The gin::PerIsolateData requires a task runner to create, so we feed it
|
||||
// with a task runner that will post all work to main loop.
|
||||
@@ -77,11 +77,11 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
|
||||
// Pointer to exit code.
|
||||
int* exit_code_;
|
||||
|
||||
scoped_ptr<Browser> browser_;
|
||||
scoped_ptr<JavascriptEnvironment> js_env_;
|
||||
scoped_ptr<NodeBindings> node_bindings_;
|
||||
scoped_ptr<AtomBindings> atom_bindings_;
|
||||
scoped_ptr<NodeDebugger> node_debugger_;
|
||||
std::unique_ptr<Browser> browser_;
|
||||
std::unique_ptr<JavascriptEnvironment> js_env_;
|
||||
std::unique_ptr<NodeBindings> node_bindings_;
|
||||
std::unique_ptr<AtomBindings> atom_bindings_;
|
||||
std::unique_ptr<NodeDebugger> node_debugger_;
|
||||
|
||||
base::Timer gc_timer_;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "atom/browser/ui/file_dialog.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/prefs/pref_service.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
@@ -77,7 +77,8 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated(
|
||||
window = relay->window.get();
|
||||
|
||||
base::FilePath path;
|
||||
if (file_dialog::ShowSaveDialog(window, item->GetURL().spec(), default_path,
|
||||
if (file_dialog::ShowSaveDialog(window, item->GetURL().spec(),
|
||||
"", default_path,
|
||||
file_dialog::Filters(), &path)) {
|
||||
// Remember the last selected download directory.
|
||||
AtomBrowserContext* browser_context = static_cast<AtomBrowserContext*>(
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace atom {
|
||||
void AtomJavaScriptDialogManager::RunJavaScriptDialog(
|
||||
content::WebContents* web_contents,
|
||||
const GURL& origin_url,
|
||||
const std::string& accept_lang,
|
||||
content::JavaScriptMessageType javascript_message_type,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
@@ -24,12 +23,10 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
|
||||
|
||||
void AtomJavaScriptDialogManager::RunBeforeUnloadDialog(
|
||||
content::WebContents* web_contents,
|
||||
const base::string16& message_text,
|
||||
bool is_reload,
|
||||
const DialogClosedCallback& callback) {
|
||||
bool prevent_reload = message_text.empty() ||
|
||||
message_text == base::ASCIIToUTF16("false");
|
||||
callback.Run(!prevent_reload, message_text);
|
||||
// FIXME(zcbenz): the |message_text| is removed, figure out what should we do.
|
||||
callback.Run(false, base::ASCIIToUTF16("This should not be displayed"));
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -17,7 +17,6 @@ class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager {
|
||||
void RunJavaScriptDialog(
|
||||
content::WebContents* web_contents,
|
||||
const GURL& origin_url,
|
||||
const std::string& accept_lang,
|
||||
content::JavaScriptMessageType javascript_message_type,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
@@ -25,7 +24,6 @@ class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager {
|
||||
bool* did_suppress_message) override;
|
||||
void RunBeforeUnloadDialog(
|
||||
content::WebContents* web_contents,
|
||||
const base::string16& message_text,
|
||||
bool is_reload,
|
||||
const DialogClosedCallback& callback) override;
|
||||
void CancelActiveAndPendingDialogs(
|
||||
|
||||
@@ -40,7 +40,7 @@ void AtomPermissionManager::SetPermissionRequestHandler(
|
||||
if (handler.is_null() && !pending_requests_.empty()) {
|
||||
for (const auto& request : pending_requests_) {
|
||||
if (!WebContentsDestroyed(request.second.render_process_id))
|
||||
request.second.callback.Run(content::PERMISSION_STATUS_DENIED);
|
||||
request.second.callback.Run(blink::mojom::PermissionStatus::DENIED);
|
||||
}
|
||||
pending_requests_.clear();
|
||||
}
|
||||
@@ -51,7 +51,6 @@ int AtomPermissionManager::RequestPermission(
|
||||
content::PermissionType permission,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& requesting_origin,
|
||||
bool user_gesture,
|
||||
const ResponseCallback& response_callback) {
|
||||
int process_id = render_frame_host->GetProcess()->GetID();
|
||||
|
||||
@@ -74,7 +73,7 @@ int AtomPermissionManager::RequestPermission(
|
||||
return request_id_;
|
||||
}
|
||||
|
||||
response_callback.Run(content::PERMISSION_STATUS_GRANTED);
|
||||
response_callback.Run(blink::mojom::PermissionStatus::GRANTED);
|
||||
return kNoPendingOperation;
|
||||
}
|
||||
|
||||
@@ -82,17 +81,16 @@ int AtomPermissionManager::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<content::PermissionStatus>&)>& callback) {
|
||||
const std::vector<blink::mojom::PermissionStatus>&)>& callback) {
|
||||
// FIXME(zcbenz): Just ignore multiple permissions request for now.
|
||||
std::vector<content::PermissionStatus> permissionStatuses;
|
||||
std::vector<blink::mojom::PermissionStatus> permissionStatuses;
|
||||
for (auto permission : permissions) {
|
||||
if (permission == content::PermissionType::MIDI_SYSEX) {
|
||||
content::ChildProcessSecurityPolicy::GetInstance()->
|
||||
GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
|
||||
}
|
||||
permissionStatuses.push_back(content::PERMISSION_STATUS_GRANTED);
|
||||
permissionStatuses.push_back(blink::mojom::PermissionStatus::GRANTED);
|
||||
}
|
||||
callback.Run(permissionStatuses);
|
||||
return kNoPendingOperation;
|
||||
@@ -102,7 +100,7 @@ void AtomPermissionManager::OnPermissionResponse(
|
||||
int request_id,
|
||||
const GURL& origin,
|
||||
const ResponseCallback& callback,
|
||||
content::PermissionStatus status) {
|
||||
blink::mojom::PermissionStatus status) {
|
||||
auto request = pending_requests_.find(request_id);
|
||||
if (request != pending_requests_.end()) {
|
||||
if (!WebContentsDestroyed(request->second.render_process_id))
|
||||
@@ -115,7 +113,7 @@ 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(content::PERMISSION_STATUS_DENIED);
|
||||
request->second.callback.Run(blink::mojom::PermissionStatus::DENIED);
|
||||
pending_requests_.erase(request);
|
||||
}
|
||||
}
|
||||
@@ -126,11 +124,11 @@ void AtomPermissionManager::ResetPermission(
|
||||
const GURL& embedding_origin) {
|
||||
}
|
||||
|
||||
content::PermissionStatus AtomPermissionManager::GetPermissionStatus(
|
||||
blink::mojom::PermissionStatus AtomPermissionManager::GetPermissionStatus(
|
||||
content::PermissionType permission,
|
||||
const GURL& requesting_origin,
|
||||
const GURL& embedding_origin) {
|
||||
return content::PERMISSION_STATUS_GRANTED;
|
||||
return blink::mojom::PermissionStatus::GRANTED;
|
||||
}
|
||||
|
||||
void AtomPermissionManager::RegisterPermissionUsage(
|
||||
|
||||
@@ -23,7 +23,7 @@ class AtomPermissionManager : public content::PermissionManager {
|
||||
~AtomPermissionManager() override;
|
||||
|
||||
using ResponseCallback =
|
||||
base::Callback<void(content::PermissionStatus)>;
|
||||
base::Callback<void(blink::mojom::PermissionStatus)>;
|
||||
using RequestHandler =
|
||||
base::Callback<void(content::WebContents*,
|
||||
content::PermissionType,
|
||||
@@ -37,28 +37,26 @@ class AtomPermissionManager : public content::PermissionManager {
|
||||
content::PermissionType permission,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& requesting_origin,
|
||||
bool user_gesture,
|
||||
const ResponseCallback& 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<content::PermissionStatus>&)>& callback) override;
|
||||
const std::vector<blink::mojom::PermissionStatus>&)>& callback) override;
|
||||
|
||||
protected:
|
||||
void OnPermissionResponse(int request_id,
|
||||
const GURL& url,
|
||||
const ResponseCallback& callback,
|
||||
content::PermissionStatus status);
|
||||
blink::mojom::PermissionStatus status);
|
||||
|
||||
// content::PermissionManager:
|
||||
void CancelPermissionRequest(int request_id) override;
|
||||
void ResetPermission(content::PermissionType permission,
|
||||
const GURL& requesting_origin,
|
||||
const GURL& embedding_origin) override;
|
||||
content::PermissionStatus GetPermissionStatus(
|
||||
blink::mojom::PermissionStatus GetPermissionStatus(
|
||||
content::PermissionType permission,
|
||||
const GURL& requesting_origin,
|
||||
const GURL& embedding_origin) override;
|
||||
@@ -69,7 +67,8 @@ class AtomPermissionManager : public content::PermissionManager {
|
||||
content::PermissionType permission,
|
||||
const GURL& requesting_origin,
|
||||
const GURL& embedding_origin,
|
||||
const base::Callback<void(content::PermissionStatus)>& callback) override;
|
||||
const base::Callback<void(blink::mojom::PermissionStatus)>& callback)
|
||||
override;
|
||||
void UnsubscribePermissionStatusChange(int subscription_id) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -32,7 +32,7 @@ class AtomSecurityStateModelClient
|
||||
friend class content::WebContentsUserData<AtomSecurityStateModelClient>;
|
||||
|
||||
content::WebContents* web_contents_;
|
||||
scoped_ptr<security_state::SecurityStateModel> security_state_model_;
|
||||
std::unique_ptr<security_state::SecurityStateModel> security_state_model_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomSecurityStateModelClient);
|
||||
};
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "base/strings/string16.h"
|
||||
#include "atom/browser/browser_observer.h"
|
||||
#include "atom/browser/window_list_observer.h"
|
||||
#include "native_mate/arguments.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "base/files/file_path.h"
|
||||
@@ -94,7 +95,8 @@ class Browser : public WindowListObserver {
|
||||
|
||||
// Creates an activity and sets it as the one currently in use.
|
||||
void SetUserActivity(const std::string& type,
|
||||
const base::DictionaryValue& user_info);
|
||||
const base::DictionaryValue& user_info,
|
||||
mate::Arguments* args);
|
||||
|
||||
// Returns the type name of the current user activity.
|
||||
std::string GetCurrentActivityType();
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "brightray/common/application_info.h"
|
||||
#include "net/base/mac/url_conversions.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -112,12 +114,16 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol) {
|
||||
void Browser::SetAppUserModelID(const base::string16& name) {
|
||||
}
|
||||
|
||||
void Browser::SetUserActivity(
|
||||
const std::string& type,
|
||||
const base::DictionaryValue& user_info) {
|
||||
void Browser::SetUserActivity(const std::string& type,
|
||||
const base::DictionaryValue& user_info,
|
||||
mate::Arguments* args) {
|
||||
std::string url_string;
|
||||
args->GetNext(&url_string);
|
||||
|
||||
[[AtomApplication sharedApplication]
|
||||
setCurrentActivity:base::SysUTF8ToNSString(type)
|
||||
withUserInfo:DictionaryValueToNSDictionary(user_info)];
|
||||
withUserInfo:DictionaryValueToNSDictionary(user_info)
|
||||
withWebpageURL:net::NSURLWithGURL(GURL(url_string))];
|
||||
}
|
||||
|
||||
std::string Browser::GetCurrentActivityType() {
|
||||
@@ -126,9 +132,8 @@ std::string Browser::GetCurrentActivityType() {
|
||||
return base::SysNSStringToUTF8(userActivity.activityType);
|
||||
}
|
||||
|
||||
bool Browser::ContinueUserActivity(
|
||||
const std::string& type,
|
||||
const base::DictionaryValue& user_info) {
|
||||
bool Browser::ContinueUserActivity(const std::string& type,
|
||||
const base::DictionaryValue& user_info) {
|
||||
bool prevent_default = false;
|
||||
FOR_EACH_OBSERVER(BrowserObserver,
|
||||
observers_,
|
||||
|
||||
@@ -281,7 +281,7 @@ PCWSTR Browser::GetAppUserModelID() {
|
||||
std::string Browser::GetExecutableFileVersion() const {
|
||||
base::FilePath path;
|
||||
if (PathService::Get(base::FILE_EXE, &path)) {
|
||||
scoped_ptr<FileVersionInfo> version_info(
|
||||
std::unique_ptr<FileVersionInfo> version_info(
|
||||
FileVersionInfo::CreateFileVersionInfo(path));
|
||||
return base::UTF16ToUTF8(version_info->product_version());
|
||||
}
|
||||
@@ -292,7 +292,7 @@ std::string Browser::GetExecutableFileVersion() const {
|
||||
std::string Browser::GetExecutableFileProductName() const {
|
||||
base::FilePath path;
|
||||
if (PathService::Get(base::FILE_EXE, &path)) {
|
||||
scoped_ptr<FileVersionInfo> version_info(
|
||||
std::unique_ptr<FileVersionInfo> version_info(
|
||||
FileVersionInfo::CreateFileVersionInfo(path));
|
||||
return base::UTF16ToUTF8(version_info->product_name());
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
#include "atom/browser/web_dialog_helper.h"
|
||||
#include "atom/common/atom_constants.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/prefs/pref_service.h"
|
||||
#include "base/prefs/scoped_user_pref_update.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "components/prefs/scoped_user_pref_update.h"
|
||||
#include "chrome/browser/printing/print_preview_message_handler.h"
|
||||
#include "chrome/browser/printing/print_view_manager_basic.h"
|
||||
#include "chrome/browser/ui/browser_dialogs.h"
|
||||
@@ -31,14 +31,6 @@
|
||||
#include "content/public/browser/security_style_explanations.h"
|
||||
#include "storage/browser/fileapi/isolated_context.h"
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
#include "atom/browser/native_window_views.h"
|
||||
#endif
|
||||
|
||||
#if defined(USE_X11)
|
||||
#include "atom/browser/browser.h"
|
||||
#endif
|
||||
|
||||
using content::BrowserThread;
|
||||
using security_state::SecurityStateModel;
|
||||
|
||||
@@ -182,7 +174,9 @@ CommonWebContentsDelegate::~CommonWebContentsDelegate() {
|
||||
}
|
||||
|
||||
void CommonWebContentsDelegate::InitWithWebContents(
|
||||
content::WebContents* web_contents) {
|
||||
content::WebContents* web_contents,
|
||||
AtomBrowserContext* browser_context) {
|
||||
browser_context_ = browser_context;
|
||||
web_contents->SetDelegate(this);
|
||||
|
||||
printing::PrintViewManagerBasic::CreateForWebContents(web_contents);
|
||||
@@ -389,7 +383,7 @@ void CommonWebContentsDelegate::DevToolsSaveToFile(
|
||||
} else {
|
||||
file_dialog::Filters filters;
|
||||
base::FilePath default_path(base::FilePath::FromUTF8Unsafe(url));
|
||||
if (!file_dialog::ShowSaveDialog(owner_window(), url, default_path,
|
||||
if (!file_dialog::ShowSaveDialog(owner_window(), url, "", default_path,
|
||||
filters, &path)) {
|
||||
base::StringValue url_value(url);
|
||||
web_contents_->CallClientFunction(
|
||||
@@ -455,7 +449,7 @@ void CommonWebContentsDelegate::DevToolsAddFileSystem(
|
||||
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,
|
||||
if (!file_dialog::ShowOpenDialog(owner_window(), "", "", default_path,
|
||||
filters, flag, &paths))
|
||||
return;
|
||||
|
||||
@@ -470,7 +464,7 @@ void CommonWebContentsDelegate::DevToolsAddFileSystem(
|
||||
FileSystem file_system = CreateFileSystemStruct(GetDevToolsWebContents(),
|
||||
file_system_id,
|
||||
path.AsUTF8Unsafe());
|
||||
scoped_ptr<base::DictionaryValue> file_system_value(
|
||||
std::unique_ptr<base::DictionaryValue> file_system_value(
|
||||
CreateFileSystemValue(file_system));
|
||||
|
||||
auto pref_service = GetPrefService(GetDevToolsWebContents());
|
||||
@@ -628,23 +622,6 @@ void CommonWebContentsDelegate::OnDevToolsSearchCompleted(
|
||||
&file_paths_value);
|
||||
}
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
gfx::ImageSkia CommonWebContentsDelegate::GetDevToolsWindowIcon() {
|
||||
if (!owner_window())
|
||||
return gfx::ImageSkia();
|
||||
return static_cast<views::WidgetDelegate*>(static_cast<NativeWindowViews*>(
|
||||
owner_window()))->GetWindowAppIcon();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USE_X11)
|
||||
void CommonWebContentsDelegate::GetDevToolsWindowWMClass(
|
||||
std::string* name, std::string* class_name) {
|
||||
*class_name = Browser::Get()->GetName();
|
||||
*name = base::ToLowerASCII(*class_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
void CommonWebContentsDelegate::SetHtmlApiFullscreen(bool enter_fullscreen) {
|
||||
// Window is already in fullscreen mode, save the state.
|
||||
if (enter_fullscreen && owner_window_->IsFullscreen()) {
|
||||
|
||||
@@ -19,6 +19,7 @@ using brightray::DevToolsFileSystemIndexer;
|
||||
|
||||
namespace atom {
|
||||
|
||||
class AtomBrowserContext;
|
||||
class AtomJavaScriptDialogManager;
|
||||
class NativeWindow;
|
||||
class WebDialogHelper;
|
||||
@@ -33,7 +34,8 @@ class CommonWebContentsDelegate
|
||||
|
||||
// Creates a InspectableWebContents object and takes onwership of
|
||||
// |web_contents|.
|
||||
void InitWithWebContents(content::WebContents* web_contents);
|
||||
void InitWithWebContents(content::WebContents* web_contents,
|
||||
AtomBrowserContext* browser_context);
|
||||
|
||||
// Set the window as owner window.
|
||||
void SetOwnerWindow(NativeWindow* owner_window);
|
||||
@@ -82,6 +84,9 @@ class CommonWebContentsDelegate
|
||||
content::SecurityStyle GetSecurityStyle(
|
||||
content::WebContents* web_contents,
|
||||
content::SecurityStyleExplanations* explanations) override;
|
||||
void HandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) override;
|
||||
|
||||
// brightray::InspectableWebContentsDelegate:
|
||||
void DevToolsSaveToFile(const std::string& url,
|
||||
@@ -141,15 +146,18 @@ class CommonWebContentsDelegate
|
||||
// Whether window is fullscreened by window api.
|
||||
bool native_fullscreen_;
|
||||
|
||||
scoped_ptr<WebDialogHelper> web_dialog_helper_;
|
||||
scoped_ptr<AtomJavaScriptDialogManager> dialog_manager_;
|
||||
std::unique_ptr<WebDialogHelper> web_dialog_helper_;
|
||||
std::unique_ptr<AtomJavaScriptDialogManager> dialog_manager_;
|
||||
scoped_refptr<DevToolsFileSystemIndexer> devtools_file_system_indexer_;
|
||||
|
||||
// Make sure BrowserContext is alwasys destroyed after WebContents.
|
||||
scoped_refptr<AtomBrowserContext> browser_context_;
|
||||
|
||||
// The stored InspectableWebContents object.
|
||||
// Notice that web_contents_ must be placed after dialog_manager_, so we can
|
||||
// make sure web_contents_ is destroyed before dialog_manager_, otherwise a
|
||||
// crash would happen.
|
||||
scoped_ptr<brightray::InspectableWebContents> web_contents_;
|
||||
std::unique_ptr<brightray::InspectableWebContents> web_contents_;
|
||||
|
||||
// Maps url to file path, used by the file requests sent from devtools.
|
||||
typedef std::map<std::string, base::FilePath> PathsMap;
|
||||
|
||||
39
atom/browser/common_web_contents_delegate_mac.mm
Normal file
39
atom/browser/common_web_contents_delegate_mac.mm
Normal file
@@ -0,0 +1,39 @@
|
||||
// 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/common_web_contents_delegate.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "content/public/browser/native_web_keyboard_event.h"
|
||||
#include "ui/events/keycodes/keyboard_codes.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
void CommonWebContentsDelegate::HandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
if (event.skip_in_browser ||
|
||||
event.type == content::NativeWebKeyboardEvent::Char)
|
||||
return;
|
||||
|
||||
// Escape exits tabbed fullscreen mode.
|
||||
if (event.windowsKeyCode == ui::VKEY_ESCAPE && is_html_fullscreen())
|
||||
ExitFullscreenModeForTab(source);
|
||||
|
||||
BOOL handled = [[NSApp mainMenu] performKeyEquivalent:event.os_event];
|
||||
if (!handled && event.os_event.window) {
|
||||
// Handle the cmd+~ shortcut.
|
||||
if ((event.os_event.modifierFlags & NSCommandKeyMask) /* cmd */ &&
|
||||
(event.os_event.keyCode == 50 /* ~ */)) {
|
||||
if (event.os_event.modifierFlags & NSShiftKeyMask) {
|
||||
[NSApp sendAction:@selector(_cycleWindowsReversed:) to:nil from:nil];
|
||||
} else {
|
||||
[NSApp sendAction:@selector(_cycleWindows:) to:nil from:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
45
atom/browser/common_web_contents_delegate_views.cc
Normal file
45
atom/browser/common_web_contents_delegate_views.cc
Normal file
@@ -0,0 +1,45 @@
|
||||
// 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/common_web_contents_delegate.h"
|
||||
|
||||
#include "atom/browser/native_window_views.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "content/public/browser/native_web_keyboard_event.h"
|
||||
#include "ui/events/keycodes/keyboard_codes.h"
|
||||
|
||||
#if defined(USE_X11)
|
||||
#include "atom/browser/browser.h"
|
||||
#endif
|
||||
|
||||
namespace atom {
|
||||
|
||||
void CommonWebContentsDelegate::HandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
// Escape exits tabbed fullscreen mode.
|
||||
if (event.windowsKeyCode == ui::VKEY_ESCAPE && is_html_fullscreen())
|
||||
ExitFullscreenModeForTab(source);
|
||||
|
||||
// Let the NativeWindow handle other parts.
|
||||
if (owner_window())
|
||||
owner_window()->HandleKeyboardEvent(source, event);
|
||||
}
|
||||
|
||||
gfx::ImageSkia CommonWebContentsDelegate::GetDevToolsWindowIcon() {
|
||||
if (!owner_window())
|
||||
return gfx::ImageSkia();
|
||||
return static_cast<views::WidgetDelegate*>(static_cast<NativeWindowViews*>(
|
||||
owner_window()))->GetWindowAppIcon();
|
||||
}
|
||||
|
||||
#if defined(USE_X11)
|
||||
void CommonWebContentsDelegate::GetDevToolsWindowWMClass(
|
||||
std::string* name, std::string* class_name) {
|
||||
*class_name = Browser::Get()->GetName();
|
||||
*name = base::ToLowerASCII(*class_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace atom
|
||||
107
atom/browser/lib/bluetooth_chooser.cc
Normal file
107
atom/browser/lib/bluetooth_chooser.cc
Normal file
@@ -0,0 +1,107 @@
|
||||
// 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/lib/bluetooth_chooser.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
||||
namespace mate {
|
||||
|
||||
template<>
|
||||
struct Converter<atom::BluetoothChooser::DeviceInfo> {
|
||||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate, const atom::BluetoothChooser::DeviceInfo& val) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("deviceName", val.device_name);
|
||||
dict.Set("deviceId", val.device_id);
|
||||
return mate::ConvertToV8(isolate, dict);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
const int kMaxScanRetries = 5;
|
||||
|
||||
void OnDeviceChosen(
|
||||
const content::BluetoothChooser::EventHandler& handler,
|
||||
const std::string& device_id) {
|
||||
if (device_id.empty()) {
|
||||
handler.Run(content::BluetoothChooser::Event::CANCELLED, device_id);
|
||||
} else {
|
||||
handler.Run(content::BluetoothChooser::Event::SELECTED, device_id);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
BluetoothChooser::BluetoothChooser(
|
||||
api::WebContents* contents,
|
||||
const EventHandler& event_handler)
|
||||
: api_web_contents_(contents),
|
||||
event_handler_(event_handler),
|
||||
num_retries_(0) {
|
||||
}
|
||||
|
||||
BluetoothChooser::~BluetoothChooser() {
|
||||
}
|
||||
|
||||
void BluetoothChooser::SetAdapterPresence(AdapterPresence presence) {
|
||||
switch (presence) {
|
||||
case AdapterPresence::ABSENT:
|
||||
case AdapterPresence::POWERED_OFF:
|
||||
event_handler_.Run(Event::CANCELLED, "");
|
||||
break;
|
||||
case AdapterPresence::POWERED_ON:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) {
|
||||
switch (state) {
|
||||
case DiscoveryState::FAILED_TO_START:
|
||||
event_handler_.Run(Event::CANCELLED, "");
|
||||
break;
|
||||
case DiscoveryState::IDLE:
|
||||
if (device_list_.empty()) {
|
||||
auto event = ++num_retries_ > kMaxScanRetries ? Event::CANCELLED
|
||||
: Event::RESCAN;
|
||||
event_handler_.Run(event, "");
|
||||
} else {
|
||||
bool prevent_default =
|
||||
api_web_contents_->Emit("select-bluetooth-device",
|
||||
device_list_,
|
||||
base::Bind(&OnDeviceChosen,
|
||||
event_handler_));
|
||||
if (!prevent_default) {
|
||||
auto device_id = device_list_[0].device_id;
|
||||
event_handler_.Run(Event::SELECTED, device_id);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DiscoveryState::DISCOVERING:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BluetoothChooser::AddDevice(const std::string& device_id,
|
||||
const base::string16& device_name) {
|
||||
DeviceInfo info = {device_id, device_name};
|
||||
device_list_.push_back(info);
|
||||
}
|
||||
|
||||
void BluetoothChooser::RemoveDevice(const std::string& device_id) {
|
||||
for (auto it = device_list_.begin(); it != device_list_.end(); ++it) {
|
||||
if (it->device_id == device_id) {
|
||||
device_list_.erase(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
45
atom/browser/lib/bluetooth_chooser.h
Normal file
45
atom/browser/lib/bluetooth_chooser.h
Normal file
@@ -0,0 +1,45 @@
|
||||
// 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_LIB_BLUETOOTH_CHOOSER_H_
|
||||
#define ATOM_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/api/atom_api_web_contents.h"
|
||||
#include "content/public/browser/bluetooth_chooser.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class BluetoothChooser : public content::BluetoothChooser {
|
||||
public:
|
||||
struct DeviceInfo {
|
||||
std::string device_id;
|
||||
base::string16 device_name;
|
||||
};
|
||||
|
||||
explicit BluetoothChooser(api::WebContents* contents,
|
||||
const EventHandler& handler);
|
||||
~BluetoothChooser() override;
|
||||
|
||||
// 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 RemoveDevice(const std::string& device_id) override;
|
||||
|
||||
private:
|
||||
std::vector<DeviceInfo> device_list_;
|
||||
api::WebContents* api_web_contents_;
|
||||
EventHandler event_handler_;
|
||||
int num_retries_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(BluetoothChooser);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
|
||||
@@ -37,10 +37,11 @@ LoginHandler::LoginHandler(net::AuthChallengeInfo* auth_info,
|
||||
render_frame_id_(0) {
|
||||
content::ResourceRequestInfo::ForRequest(request_)->GetAssociatedRenderFrame(
|
||||
&render_process_host_id_, &render_frame_id_);
|
||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(&Browser::RequestLogin,
|
||||
base::Unretained(Browser::Get()),
|
||||
make_scoped_refptr(this)));
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(&Browser::RequestLogin,
|
||||
base::Unretained(Browser::Get()),
|
||||
base::RetainedRef(make_scoped_refptr(this))));
|
||||
}
|
||||
|
||||
LoginHandler::~LoginHandler() {
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent;
|
||||
|
||||
- (NSUserActivity*)getCurrentActivity;
|
||||
- (void)setCurrentActivity:(NSString*)type withUserInfo:(NSDictionary*)userInfo;
|
||||
- (void)setCurrentActivity:(NSString*)type
|
||||
withUserInfo:(NSDictionary*)userInfo
|
||||
withWebpageURL:(NSURL*)webpageURL;
|
||||
|
||||
@end
|
||||
|
||||
@@ -29,10 +29,12 @@
|
||||
}
|
||||
|
||||
- (void)setCurrentActivity:(NSString*)type
|
||||
withUserInfo:(NSDictionary*)userInfo {
|
||||
withUserInfo:(NSDictionary*)userInfo
|
||||
withWebpageURL:(NSURL*)webpageURL {
|
||||
currentActivity_ = base::scoped_nsobject<NSUserActivity>(
|
||||
[[NSUserActivity alloc] initWithActivityType:type]);
|
||||
[currentActivity_ setUserInfo:userInfo];
|
||||
[currentActivity_ setWebpageURL:webpageURL];
|
||||
[currentActivity_ becomeCurrent];
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
continueUserActivity:(NSUserActivity*)userActivity
|
||||
restorationHandler:(void (^)(NSArray*restorableObjects))restorationHandler {
|
||||
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
|
||||
scoped_ptr<base::DictionaryValue> user_info =
|
||||
std::unique_ptr<base::DictionaryValue> user_info =
|
||||
atom::NSDictionaryToDictionaryValue(userActivity.userInfo);
|
||||
if (!user_info)
|
||||
return NO;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace atom {
|
||||
|
||||
NSDictionary* DictionaryValueToNSDictionary(const base::DictionaryValue& value);
|
||||
|
||||
scoped_ptr<base::DictionaryValue> NSDictionaryToDictionaryValue(
|
||||
std::unique_ptr<base::DictionaryValue> NSDictionaryToDictionaryValue(
|
||||
NSDictionary* dict);
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -4,13 +4,55 @@
|
||||
|
||||
#include "atom/browser/mac/dict_util.h"
|
||||
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "base/json/json_reader.h"
|
||||
#include "base/json/json_writer.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "base/values.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
std::unique_ptr<base::ListValue> NSArrayToListValue(NSArray* arr) {
|
||||
if (!arr)
|
||||
return nullptr;
|
||||
|
||||
std::unique_ptr<base::ListValue> result(new base::ListValue);
|
||||
for (id value in arr) {
|
||||
if ([value isKindOfClass:[NSString class]]) {
|
||||
result->AppendString(base::SysNSStringToUTF8(value));
|
||||
} else if ([value isKindOfClass:[NSNumber class]]) {
|
||||
const char* objc_type = [value objCType];
|
||||
if (strcmp(objc_type, @encode(BOOL)) == 0 ||
|
||||
strcmp(objc_type, @encode(char)) == 0)
|
||||
result->AppendBoolean([value boolValue]);
|
||||
else if (strcmp(objc_type, @encode(double)) == 0 ||
|
||||
strcmp(objc_type, @encode(float)) == 0)
|
||||
result->AppendDouble([value doubleValue]);
|
||||
else
|
||||
result->AppendInteger([value intValue]);
|
||||
} else if ([value isKindOfClass:[NSArray class]]) {
|
||||
std::unique_ptr<base::ListValue> sub_arr = NSArrayToListValue(value);
|
||||
if (sub_arr)
|
||||
result->Append(std::move(sub_arr));
|
||||
else
|
||||
result->Append(base::Value::CreateNullValue());
|
||||
} else if ([value isKindOfClass:[NSDictionary class]]) {
|
||||
std::unique_ptr<base::DictionaryValue> sub_dict =
|
||||
NSDictionaryToDictionaryValue(value);
|
||||
if (sub_dict)
|
||||
result->Append(std::move(sub_dict));
|
||||
else
|
||||
result->Append(base::Value::CreateNullValue());
|
||||
} else {
|
||||
result->AppendString(base::SysNSStringToUTF8([value description]));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NSDictionary* DictionaryValueToNSDictionary(const base::DictionaryValue& value) {
|
||||
std::string json;
|
||||
if (!base::JSONWriter::Write(value, &json))
|
||||
@@ -24,19 +66,53 @@ NSDictionary* DictionaryValueToNSDictionary(const base::DictionaryValue& value)
|
||||
return obj;
|
||||
}
|
||||
|
||||
scoped_ptr<base::DictionaryValue> NSDictionaryToDictionaryValue(
|
||||
std::unique_ptr<base::DictionaryValue> NSDictionaryToDictionaryValue(
|
||||
NSDictionary* dict) {
|
||||
NSData* data = [NSJSONSerialization dataWithJSONObject:dict
|
||||
options:0
|
||||
error:nil];
|
||||
if (!data)
|
||||
if (!dict)
|
||||
return nullptr;
|
||||
|
||||
base::scoped_nsobject<NSString> json =
|
||||
[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
||||
scoped_ptr<base::Value> value =
|
||||
base::JSONReader::Read([json UTF8String]);
|
||||
return base::DictionaryValue::From(std::move(value));
|
||||
std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue);
|
||||
for (id key in dict) {
|
||||
std::string str_key = base::SysNSStringToUTF8(
|
||||
[key isKindOfClass:[NSString class]] ? key : [key description]);
|
||||
|
||||
id value = [dict objectForKey:key];
|
||||
if ([value isKindOfClass:[NSString class]]) {
|
||||
result->SetStringWithoutPathExpansion(
|
||||
str_key, base::SysNSStringToUTF8(value));
|
||||
} else if ([value isKindOfClass:[NSNumber class]]) {
|
||||
const char* objc_type = [value objCType];
|
||||
if (strcmp(objc_type, @encode(BOOL)) == 0 ||
|
||||
strcmp(objc_type, @encode(char)) == 0)
|
||||
result->SetBooleanWithoutPathExpansion(str_key, [value boolValue]);
|
||||
else if (strcmp(objc_type, @encode(double)) == 0 ||
|
||||
strcmp(objc_type, @encode(float)) == 0)
|
||||
result->SetDoubleWithoutPathExpansion(str_key, [value doubleValue]);
|
||||
else
|
||||
result->SetIntegerWithoutPathExpansion(str_key, [value intValue]);
|
||||
} else if ([value isKindOfClass:[NSArray class]]) {
|
||||
std::unique_ptr<base::ListValue> sub_arr = NSArrayToListValue(value);
|
||||
if (sub_arr)
|
||||
result->SetWithoutPathExpansion(str_key, std::move(sub_arr));
|
||||
else
|
||||
result->SetWithoutPathExpansion(str_key,
|
||||
base::Value::CreateNullValue());
|
||||
} else if ([value isKindOfClass:[NSDictionary class]]) {
|
||||
std::unique_ptr<base::DictionaryValue> sub_dict =
|
||||
NSDictionaryToDictionaryValue(value);
|
||||
if (sub_dict)
|
||||
result->SetWithoutPathExpansion(str_key, std::move(sub_dict));
|
||||
else
|
||||
result->SetWithoutPathExpansion(str_key,
|
||||
base::Value::CreateNullValue());
|
||||
} else {
|
||||
result->SetStringWithoutPathExpansion(
|
||||
str_key,
|
||||
base::SysNSStringToUTF8([value description]));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -12,12 +12,11 @@
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
#include "atom/browser/window_list.h"
|
||||
#include "atom/common/api/api_messages.h"
|
||||
#include "atom/common/native_mate_converters/image_converter.h"
|
||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/json/json_writer.h"
|
||||
#include "base/prefs/pref_service.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "brightray/browser/inspectable_web_contents.h"
|
||||
@@ -49,12 +48,12 @@ NativeWindow::NativeWindow(
|
||||
const mate::Dictionary& options)
|
||||
: content::WebContentsObserver(inspectable_web_contents->GetWebContents()),
|
||||
has_frame_(true),
|
||||
force_using_draggable_region_(false),
|
||||
transparent_(false),
|
||||
enable_larger_than_screen_(false),
|
||||
is_closed_(false),
|
||||
has_dialog_attached_(false),
|
||||
sheet_offset_(0.0),
|
||||
sheet_offset_x_(0.0),
|
||||
sheet_offset_y_(0.0),
|
||||
aspect_ratio_(0.0),
|
||||
inspectable_web_contents_(inspectable_web_contents),
|
||||
weak_factory_(this) {
|
||||
@@ -66,9 +65,6 @@ NativeWindow::NativeWindow(
|
||||
// mode.
|
||||
ui::GpuSwitchingManager::SetTransparent(transparent_);
|
||||
|
||||
// Read icon before window is created.
|
||||
options.Get(options::kIcon, &icon_);
|
||||
|
||||
WindowList::AddWindow(this);
|
||||
}
|
||||
|
||||
@@ -141,11 +137,14 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) {
|
||||
if (options.Get(options::kAlwaysOnTop, &top) && top) {
|
||||
SetAlwaysOnTop(true);
|
||||
}
|
||||
// Disable fullscreen button if 'fullscreen' is specified to false.
|
||||
bool fullscreenable = true;
|
||||
bool fullscreen = false;
|
||||
if (options.Get(options::kFullscreen, &fullscreen) && !fullscreen)
|
||||
if (options.Get(options::kFullscreen, &fullscreen) && !fullscreen) {
|
||||
// Disable fullscreen button if 'fullscreen' is specified to false.
|
||||
#if defined(OS_MACOSX)
|
||||
fullscreenable = false;
|
||||
#endif
|
||||
}
|
||||
// Overriden by 'fullscreenable'.
|
||||
options.Get(options::kFullScreenable, &fullscreenable);
|
||||
SetFullScreenable(fullscreenable);
|
||||
@@ -255,12 +254,17 @@ gfx::Size NativeWindow::GetMaximumSize() {
|
||||
return GetSizeConstraints().GetMaximumSize();
|
||||
}
|
||||
|
||||
void NativeWindow::SetSheetOffset(const double offset) {
|
||||
sheet_offset_ = offset;
|
||||
void NativeWindow::SetSheetOffset(const double offsetX, const double offsetY) {
|
||||
sheet_offset_x_ = offsetX;
|
||||
sheet_offset_y_ = offsetY;
|
||||
}
|
||||
|
||||
double NativeWindow::GetSheetOffset() {
|
||||
return sheet_offset_;
|
||||
double NativeWindow::GetSheetOffsetX() {
|
||||
return sheet_offset_x_;
|
||||
}
|
||||
|
||||
double NativeWindow::GetSheetOffsetY() {
|
||||
return sheet_offset_y_;
|
||||
}
|
||||
|
||||
void NativeWindow::SetRepresentedFilename(const std::string& filename) {
|
||||
@@ -318,9 +322,9 @@ void NativeWindow::CapturePage(const gfx::Rect& rect,
|
||||
// current system, increase the requested bitmap size to capture it all.
|
||||
gfx::Size bitmap_size = view_size;
|
||||
const gfx::NativeView native_view = view->GetNativeView();
|
||||
gfx::Screen* const screen = gfx::Screen::GetScreenFor(native_view);
|
||||
const float scale =
|
||||
screen->GetDisplayNearestWindow(native_view).device_scale_factor();
|
||||
gfx::Screen::GetScreen()->GetDisplayNearestWindow(native_view)
|
||||
.device_scale_factor();
|
||||
if (scale > 1.0f)
|
||||
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
|
||||
|
||||
@@ -526,9 +530,9 @@ void NativeWindow::NotifyWindowMessage(
|
||||
}
|
||||
#endif
|
||||
|
||||
scoped_ptr<SkRegion> NativeWindow::DraggableRegionsToSkRegion(
|
||||
std::unique_ptr<SkRegion> NativeWindow::DraggableRegionsToSkRegion(
|
||||
const std::vector<DraggableRegion>& regions) {
|
||||
scoped_ptr<SkRegion> sk_region(new SkRegion);
|
||||
std::unique_ptr<SkRegion> sk_region(new SkRegion);
|
||||
for (const DraggableRegion& region : regions) {
|
||||
sk_region->op(
|
||||
region.bounds.x(),
|
||||
@@ -573,7 +577,7 @@ bool NativeWindow::OnMessageReceived(const IPC::Message& message) {
|
||||
void NativeWindow::UpdateDraggableRegions(
|
||||
const std::vector<DraggableRegion>& regions) {
|
||||
// Draggable region is not supported for non-frameless window.
|
||||
if (has_frame_ && !force_using_draggable_region_)
|
||||
if (has_frame_)
|
||||
return;
|
||||
draggable_region_ = DraggableRegionsToSkRegion(regions);
|
||||
}
|
||||
|
||||
@@ -123,8 +123,9 @@ class NativeWindow : public base::SupportsUserData,
|
||||
virtual gfx::Size GetMinimumSize();
|
||||
virtual void SetMaximumSize(const gfx::Size& size);
|
||||
virtual gfx::Size GetMaximumSize();
|
||||
virtual void SetSheetOffset(const double offset);
|
||||
virtual double GetSheetOffset();
|
||||
virtual void SetSheetOffset(const double offsetX, const double offsetY);
|
||||
virtual double GetSheetOffsetX();
|
||||
virtual double GetSheetOffsetY();
|
||||
virtual void SetResizable(bool resizable) = 0;
|
||||
virtual bool IsResizable() = 0;
|
||||
virtual void SetMovable(bool movable) = 0;
|
||||
@@ -190,7 +191,7 @@ class NativeWindow : public base::SupportsUserData,
|
||||
// Set the aspect ratio when resizing window.
|
||||
double GetAspectRatio();
|
||||
gfx::Size GetAspectRatioExtraSize();
|
||||
void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size);
|
||||
virtual void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size);
|
||||
|
||||
base::WeakPtr<NativeWindow> GetWeakPtr() {
|
||||
return weak_factory_.GetWeakPtr();
|
||||
@@ -246,17 +247,11 @@ class NativeWindow : public base::SupportsUserData,
|
||||
}
|
||||
|
||||
bool has_frame() const { return has_frame_; }
|
||||
void set_has_frame(bool has_frame) { has_frame_ = has_frame; }
|
||||
|
||||
bool transparent() const { return transparent_; }
|
||||
SkRegion* draggable_region() const { return draggable_region_.get(); }
|
||||
bool enable_larger_than_screen() const { return enable_larger_than_screen_; }
|
||||
gfx::ImageSkia icon() const { return icon_; }
|
||||
|
||||
bool force_using_draggable_region() const {
|
||||
return force_using_draggable_region_;
|
||||
}
|
||||
void set_force_using_draggable_region(bool force) {
|
||||
force_using_draggable_region_ = true;
|
||||
}
|
||||
|
||||
void set_has_dialog_attached(bool has_dialog_attached) {
|
||||
has_dialog_attached_ = has_dialog_attached;
|
||||
@@ -268,7 +263,7 @@ class NativeWindow : public base::SupportsUserData,
|
||||
|
||||
// Convert draggable regions in raw format to SkRegion format. Caller is
|
||||
// responsible for deleting the returned SkRegion instance.
|
||||
scoped_ptr<SkRegion> DraggableRegionsToSkRegion(
|
||||
std::unique_ptr<SkRegion> DraggableRegionsToSkRegion(
|
||||
const std::vector<DraggableRegion>& regions);
|
||||
|
||||
// Converts between content size to window size.
|
||||
@@ -299,15 +294,12 @@ class NativeWindow : public base::SupportsUserData,
|
||||
// Whether window has standard frame.
|
||||
bool has_frame_;
|
||||
|
||||
// Force the window to be aware of draggable regions.
|
||||
bool force_using_draggable_region_;
|
||||
|
||||
// Whether window is transparent.
|
||||
bool transparent_;
|
||||
|
||||
// For custom drag, the whole window is non-draggable and the draggable region
|
||||
// has to been explicitly provided.
|
||||
scoped_ptr<SkRegion> draggable_region_; // used in custom drag.
|
||||
std::unique_ptr<SkRegion> draggable_region_; // used in custom drag.
|
||||
|
||||
// Minimum and maximum size, stored as content size.
|
||||
extensions::SizeConstraints size_constraints_;
|
||||
@@ -315,9 +307,6 @@ class NativeWindow : public base::SupportsUserData,
|
||||
// Whether window can be resized larger than screen.
|
||||
bool enable_larger_than_screen_;
|
||||
|
||||
// Window icon.
|
||||
gfx::ImageSkia icon_;
|
||||
|
||||
// The windows has been closed.
|
||||
bool is_closed_;
|
||||
|
||||
@@ -328,8 +317,10 @@ class NativeWindow : public base::SupportsUserData,
|
||||
// it should be cancelled when we can prove that the window is responsive.
|
||||
base::CancelableClosure window_unresposive_closure_;
|
||||
|
||||
// Used to display sheets at the appropriate vertical offset
|
||||
double sheet_offset_;
|
||||
// Used to display sheets at the appropriate horizontal and vertical offsets
|
||||
// on OS X.
|
||||
double sheet_offset_x_;
|
||||
double sheet_offset_y_;
|
||||
|
||||
// Used to maintain the aspect ratio of a view which is inside of the
|
||||
// content view.
|
||||
|
||||
@@ -49,6 +49,8 @@ class NativeWindowMac : public NativeWindow {
|
||||
void SetResizable(bool resizable) override;
|
||||
bool IsResizable() override;
|
||||
void SetMovable(bool movable) override;
|
||||
void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size)
|
||||
override;
|
||||
bool IsMovable() override;
|
||||
void SetMinimizable(bool minimizable) override;
|
||||
bool IsMinimizable() override;
|
||||
@@ -91,16 +93,15 @@ class NativeWindowMac : public NativeWindow {
|
||||
UpdateDraggableRegionViews(draggable_regions_);
|
||||
}
|
||||
|
||||
// Set the attribute of NSWindow while work around a bug of zoom button.
|
||||
void SetStyleMask(bool on, NSUInteger flag);
|
||||
void SetCollectionBehavior(bool on, NSUInteger flag);
|
||||
|
||||
bool should_hide_native_toolbar_in_fullscreen() const {
|
||||
return should_hide_native_toolbar_in_fullscreen_;
|
||||
}
|
||||
|
||||
protected:
|
||||
// NativeWindow:
|
||||
void HandleKeyboardEvent(
|
||||
content::WebContents*,
|
||||
const content::NativeWebKeyboardEvent&) override;
|
||||
|
||||
// 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.
|
||||
std::vector<gfx::Rect> CalculateNonDraggableRegions(
|
||||
@@ -120,10 +121,6 @@ class NativeWindowMac : public NativeWindow {
|
||||
// whehter we can drag.
|
||||
void UpdateDraggableRegionViews(const std::vector<DraggableRegion>& regions);
|
||||
|
||||
// Set the attribute of NSWindow while work around a bug of zo0m button.
|
||||
void SetStyleMask(bool on, NSUInteger flag);
|
||||
void SetCollectionBehavior(bool on, NSUInteger flag);
|
||||
|
||||
base::scoped_nsobject<AtomNSWindow> window_;
|
||||
base::scoped_nsobject<AtomNSWindowDelegate> window_delegate_;
|
||||
|
||||
@@ -142,6 +139,10 @@ class NativeWindowMac : public NativeWindow {
|
||||
// The presentation options before entering kiosk mode.
|
||||
NSApplicationPresentationOptions kiosk_options_;
|
||||
|
||||
// Force showing the buttons for frameless window.
|
||||
bool force_show_buttons_;
|
||||
|
||||
// Whether to hide the native toolbar under fullscreen mode.
|
||||
bool should_hide_native_toolbar_in_fullscreen_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(NativeWindowMac);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "atom/browser/window_list.h"
|
||||
#include "atom/common/color_util.h"
|
||||
#include "atom/common/draggable_region.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
@@ -15,7 +16,6 @@
|
||||
#include "brightray/browser/inspectable_web_contents.h"
|
||||
#include "brightray/browser/inspectable_web_contents_view.h"
|
||||
#include "content/public/browser/browser_accessibility_state.h"
|
||||
#include "content/public/browser/native_web_keyboard_event.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/render_widget_host_view.h"
|
||||
@@ -142,22 +142,9 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||
newSize.width =
|
||||
roundf((frameSize.height - extraHeightPlusFrame) * aspectRatio +
|
||||
extraWidthPlusFrame);
|
||||
|
||||
// If the new width is less than the frame size use it as the primary
|
||||
// constraint. This ensures that the value returned by this method will
|
||||
// never be larger than the users requested window size.
|
||||
if (newSize.width <= frameSize.width) {
|
||||
newSize.height =
|
||||
roundf((newSize.width - extraWidthPlusFrame) / aspectRatio +
|
||||
extraHeightPlusFrame);
|
||||
} else {
|
||||
newSize.height =
|
||||
roundf((frameSize.width - extraWidthPlusFrame) / aspectRatio +
|
||||
extraHeightPlusFrame);
|
||||
newSize.width =
|
||||
roundf((newSize.height - extraHeightPlusFrame) * aspectRatio +
|
||||
extraWidthPlusFrame);
|
||||
}
|
||||
newSize.height =
|
||||
roundf((newSize.width - extraWidthPlusFrame) / aspectRatio +
|
||||
extraHeightPlusFrame);
|
||||
}
|
||||
|
||||
return newSize;
|
||||
@@ -214,10 +201,22 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
|
||||
[toolbar setShowsBaselineSeparator:NO];
|
||||
[window setToolbar:toolbar];
|
||||
|
||||
// Set window style to hide the toolbar, otherwise the toolbar will show in
|
||||
// fullscreen mode.
|
||||
shell_->SetStyleMask(true, NSFullSizeContentViewWindowMask);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)windowWillExitFullScreen:(NSNotification*)notification {
|
||||
// Turn off the style for toolbar.
|
||||
if (shell_->should_hide_native_toolbar_in_fullscreen())
|
||||
shell_->SetStyleMask(false, NSFullSizeContentViewWindowMask);
|
||||
}
|
||||
|
||||
- (void)windowDidExitFullScreen:(NSNotification*)notification {
|
||||
// For certain versions of OS X the fullscreen button will automatically show
|
||||
// after exiting fullscreen mode.
|
||||
if (!shell_->has_frame()) {
|
||||
NSWindow* window = shell_->GetNativeWindow();
|
||||
[[window standardWindowButton:NSWindowFullScreenButton] setHidden:YES];
|
||||
@@ -246,7 +245,9 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||
- (NSRect)window:(NSWindow*)window
|
||||
willPositionSheet:(NSWindow*)sheet usingRect:(NSRect)rect {
|
||||
NSView* view = window.contentView;
|
||||
rect.origin.y = view.frame.size.height - shell_->GetSheetOffset();
|
||||
|
||||
rect.origin.x = shell_->GetSheetOffsetX();
|
||||
rect.origin.y = view.frame.size.height - shell_->GetSheetOffsetY();
|
||||
return rect;
|
||||
}
|
||||
|
||||
@@ -391,6 +392,7 @@ NativeWindowMac::NativeWindowMac(
|
||||
: NativeWindow(web_contents, options),
|
||||
is_kiosk_(false),
|
||||
attention_request_id_(0),
|
||||
force_show_buttons_(false),
|
||||
should_hide_native_toolbar_in_fullscreen_(false) {
|
||||
int width = 800, height = 600;
|
||||
options.Get(options::kWidth, &width);
|
||||
@@ -438,22 +440,17 @@ NativeWindowMac::NativeWindowMac(
|
||||
if (closable) {
|
||||
styleMask |= NSClosableWindowMask;
|
||||
}
|
||||
if ((titleBarStyle == "hidden") || (titleBarStyle == "hidden-inset")) {
|
||||
// The window without titlebar is treated the same with frameless window.
|
||||
set_has_frame(false);
|
||||
force_show_buttons_ = true;
|
||||
}
|
||||
if (!useStandardWindow || transparent() || !has_frame()) {
|
||||
styleMask |= NSTexturedBackgroundWindowMask;
|
||||
}
|
||||
if (resizable) {
|
||||
styleMask |= NSResizableWindowMask;
|
||||
}
|
||||
if ((titleBarStyle == "hidden") || (titleBarStyle == "hidden-inset")) {
|
||||
styleMask |= NSFullSizeContentViewWindowMask;
|
||||
styleMask |= NSUnifiedTitleAndToolbarWindowMask;
|
||||
}
|
||||
// We capture this because we need to access the option later when
|
||||
// entering/exiting fullscreen and since the options dict is only passed to
|
||||
// the constructor but not stored, let’s store this option this way.
|
||||
if (titleBarStyle == "hidden-inset") {
|
||||
should_hide_native_toolbar_in_fullscreen_ = true;
|
||||
}
|
||||
|
||||
window_.reset([[AtomNSWindow alloc]
|
||||
initWithContentRect:cocoa_bounds
|
||||
@@ -490,17 +487,14 @@ NativeWindowMac::NativeWindowMac(
|
||||
[window_ setReleasedWhenClosed:NO];
|
||||
|
||||
// Hide the title bar.
|
||||
if ((titleBarStyle == "hidden") || (titleBarStyle == "hidden-inset")) {
|
||||
if (titleBarStyle == "hidden-inset") {
|
||||
[window_ setTitlebarAppearsTransparent:YES];
|
||||
[window_ setTitleVisibility:NSWindowTitleHidden];
|
||||
if (titleBarStyle == "hidden-inset") {
|
||||
base::scoped_nsobject<NSToolbar> toolbar(
|
||||
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
|
||||
[toolbar setShowsBaselineSeparator:NO];
|
||||
[window_ setToolbar:toolbar];
|
||||
}
|
||||
// We should be aware of draggable regions when using hidden titlebar.
|
||||
set_force_using_draggable_region(true);
|
||||
base::scoped_nsobject<NSToolbar> toolbar(
|
||||
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
|
||||
[toolbar setShowsBaselineSeparator:NO];
|
||||
[window_ setToolbar:toolbar];
|
||||
should_hide_native_toolbar_in_fullscreen_ = true;
|
||||
}
|
||||
|
||||
// On OS X the initial window size doesn't include window frame.
|
||||
@@ -558,6 +552,11 @@ NativeWindowMac::~NativeWindowMac() {
|
||||
}
|
||||
|
||||
void NativeWindowMac::Close() {
|
||||
if (!IsClosable()) {
|
||||
WindowList::WindowCloseCancelled(this);
|
||||
return;
|
||||
}
|
||||
|
||||
[window_ performClose:nil];
|
||||
}
|
||||
|
||||
@@ -713,6 +712,17 @@ bool NativeWindowMac::IsResizable() {
|
||||
return [window_ styleMask] & NSResizableWindowMask;
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetAspectRatio(double aspect_ratio,
|
||||
const gfx::Size& extra_size) {
|
||||
NativeWindow::SetAspectRatio(aspect_ratio, extra_size);
|
||||
|
||||
// Reset the behaviour to default if aspect_ratio is set to 0 or less.
|
||||
if (aspect_ratio > 0.0)
|
||||
[window_ setAspectRatio:NSMakeSize(aspect_ratio, 1.0)];
|
||||
else
|
||||
[window_ setResizeIncrements:NSMakeSize(1.0, 1.0)];
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetMovable(bool movable) {
|
||||
[window_ setMovable:movable];
|
||||
}
|
||||
@@ -928,35 +938,14 @@ bool NativeWindowMac::IsVisibleOnAllWorkspaces() {
|
||||
return collectionBehavior & NSWindowCollectionBehaviorCanJoinAllSpaces;
|
||||
}
|
||||
|
||||
void NativeWindowMac::HandleKeyboardEvent(
|
||||
content::WebContents*,
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
if (event.skip_in_browser ||
|
||||
event.type == content::NativeWebKeyboardEvent::Char)
|
||||
return;
|
||||
|
||||
BOOL handled = [[NSApp mainMenu] performKeyEquivalent:event.os_event];
|
||||
if (!handled && event.os_event.window) {
|
||||
// Handle the cmd+~ shortcut.
|
||||
if ((event.os_event.modifierFlags & NSCommandKeyMask) /* cmd */ &&
|
||||
(event.os_event.keyCode == 50 /* ~ */)) {
|
||||
if (event.os_event.modifierFlags & NSShiftKeyMask) {
|
||||
[NSApp sendAction:@selector(_cycleWindowsReversed:) to:nil from:nil];
|
||||
} else {
|
||||
[NSApp sendAction:@selector(_cycleWindows:) to:nil from:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<gfx::Rect> NativeWindowMac::CalculateNonDraggableRegions(
|
||||
const std::vector<DraggableRegion>& regions, int width, int height) {
|
||||
std::vector<gfx::Rect> result;
|
||||
if (regions.empty()) {
|
||||
result.push_back(gfx::Rect(0, 0, width, height));
|
||||
} else {
|
||||
scoped_ptr<SkRegion> draggable(DraggableRegionsToSkRegion(regions));
|
||||
scoped_ptr<SkRegion> non_draggable(new SkRegion);
|
||||
std::unique_ptr<SkRegion> draggable(DraggableRegionsToSkRegion(regions));
|
||||
std::unique_ptr<SkRegion> non_draggable(new SkRegion);
|
||||
non_draggable->op(0, 0, width, height, SkRegion::kUnion_Op);
|
||||
non_draggable->op(*draggable, SkRegion::kDifference_Op);
|
||||
for (SkRegion::Iterator it(*non_draggable); !it.done(); it.next()) {
|
||||
@@ -1013,6 +1002,10 @@ void NativeWindowMac::InstallView() {
|
||||
[view setFrame:[content_view_ bounds]];
|
||||
[content_view_ addSubview:view];
|
||||
|
||||
if (force_show_buttons_)
|
||||
return;
|
||||
|
||||
// Hide the window buttons.
|
||||
[[window_ standardWindowButton:NSWindowZoomButton] setHidden:YES];
|
||||
[[window_ standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES];
|
||||
[[window_ standardWindowButton:NSWindowCloseButton] setHidden:YES];
|
||||
@@ -1031,7 +1024,7 @@ void NativeWindowMac::UninstallView() {
|
||||
|
||||
void NativeWindowMac::UpdateDraggableRegionViews(
|
||||
const std::vector<DraggableRegion>& regions) {
|
||||
if (has_frame() && !force_using_draggable_region())
|
||||
if (has_frame())
|
||||
return;
|
||||
|
||||
// All ControlRegionViews should be added as children of the WebContentsView,
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
|
||||
#include "atom/browser/ui/views/menu_bar.h"
|
||||
#include "atom/browser/ui/views/menu_layout.h"
|
||||
#include "atom/browser/window_list.h"
|
||||
#include "atom/common/color_util.h"
|
||||
#include "atom/common/draggable_region.h"
|
||||
#include "atom/common/native_mate_converters/image_converter.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "brightray/browser/inspectable_web_contents.h"
|
||||
@@ -40,6 +42,7 @@
|
||||
#include "chrome/browser/ui/libgtk2ui/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"
|
||||
@@ -273,7 +276,6 @@ NativeWindowViews::NativeWindowViews(
|
||||
use_content_size_)
|
||||
size = ContentSizeToWindowSize(size);
|
||||
|
||||
window_->UpdateWindowIcon();
|
||||
window_->CenterWindow(size);
|
||||
Layout();
|
||||
}
|
||||
@@ -283,6 +285,11 @@ NativeWindowViews::~NativeWindowViews() {
|
||||
}
|
||||
|
||||
void NativeWindowViews::Close() {
|
||||
if (!IsClosable()) {
|
||||
WindowList::WindowCloseCancelled(this);
|
||||
return;
|
||||
}
|
||||
|
||||
window_->Close();
|
||||
}
|
||||
|
||||
@@ -623,7 +630,9 @@ void NativeWindowViews::SetBackgroundColor(const std::string& color_name) {
|
||||
// Set the background color of native window.
|
||||
HBRUSH brush = CreateSolidBrush(skia::SkColorToCOLORREF(background_color));
|
||||
ULONG_PTR previous_brush = SetClassLongPtr(
|
||||
GetAcceleratedWidget(), GCLP_HBRBACKGROUND, (LONG)brush);
|
||||
GetAcceleratedWidget(),
|
||||
GCLP_HBRBACKGROUND,
|
||||
reinterpret_cast<LONG_PTR>(brush));
|
||||
if (previous_brush)
|
||||
DeleteObject((HBRUSH)previous_brush);
|
||||
#endif
|
||||
@@ -776,6 +785,27 @@ gfx::AcceleratedWidget NativeWindowViews::GetAcceleratedWidget() {
|
||||
return GetNativeWindow()->GetHost()->GetAcceleratedWidget();
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
void NativeWindowViews::SetIcon(HICON window_icon, HICON app_icon) {
|
||||
// We are responsible for storing the images.
|
||||
window_icon_ = base::win::ScopedHICON(CopyIcon(window_icon));
|
||||
app_icon_ = base::win::ScopedHICON(CopyIcon(app_icon));
|
||||
|
||||
HWND hwnd = GetAcceleratedWidget();
|
||||
SendMessage(hwnd, WM_SETICON, ICON_SMALL,
|
||||
reinterpret_cast<LPARAM>(window_icon_.get()));
|
||||
SendMessage(hwnd, WM_SETICON, ICON_BIG,
|
||||
reinterpret_cast<LPARAM>(app_icon_.get()));
|
||||
}
|
||||
#elif defined(USE_X11)
|
||||
void NativeWindowViews::SetIcon(const gfx::ImageSkia& icon) {
|
||||
views::DesktopWindowTreeHostX11* tree_host =
|
||||
views::DesktopWindowTreeHostX11::GetHostForXID(GetAcceleratedWidget());
|
||||
static_cast<views::DesktopWindowTreeHost*>(tree_host)->SetWindowIcons(
|
||||
icon, icon);
|
||||
}
|
||||
#endif
|
||||
|
||||
void NativeWindowViews::OnWidgetActivationChanged(
|
||||
views::Widget* widget, bool active) {
|
||||
if (widget != window_.get())
|
||||
@@ -840,14 +870,6 @@ bool NativeWindowViews::ShouldHandleSystemCommands() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
gfx::ImageSkia NativeWindowViews::GetWindowAppIcon() {
|
||||
return icon();
|
||||
}
|
||||
|
||||
gfx::ImageSkia NativeWindowViews::GetWindowIcon() {
|
||||
return GetWindowAppIcon();
|
||||
}
|
||||
|
||||
views::Widget* NativeWindowViews::GetWidget() {
|
||||
return window_.get();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#if defined(OS_WIN)
|
||||
#include "atom/browser/ui/win/message_handler_delegate.h"
|
||||
#include "atom/browser/ui/win/taskbar_host.h"
|
||||
#include "base/win/scoped_gdi_object.h"
|
||||
#endif
|
||||
|
||||
namespace views {
|
||||
@@ -104,6 +105,12 @@ class NativeWindowViews : public NativeWindow,
|
||||
|
||||
gfx::AcceleratedWidget GetAcceleratedWidget() override;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
void SetIcon(HICON small_icon, HICON app_icon);
|
||||
#elif defined(USE_X11)
|
||||
void SetIcon(const gfx::ImageSkia& icon);
|
||||
#endif
|
||||
|
||||
views::Widget* widget() const { return window_.get(); }
|
||||
|
||||
#if defined(OS_WIN)
|
||||
@@ -125,8 +132,6 @@ class NativeWindowViews : public NativeWindow,
|
||||
bool CanMinimize() const override;
|
||||
base::string16 GetWindowTitle() const override;
|
||||
bool ShouldHandleSystemCommands() const override;
|
||||
gfx::ImageSkia GetWindowAppIcon() override;
|
||||
gfx::ImageSkia GetWindowIcon() override;
|
||||
views::Widget* GetWidget() override;
|
||||
const views::Widget* GetWidget() const override;
|
||||
views::View* GetContentsView() override;
|
||||
@@ -145,7 +150,6 @@ class NativeWindowViews : public NativeWindow,
|
||||
// MessageHandlerDelegate:
|
||||
bool PreHandleMSG(
|
||||
UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) override;
|
||||
|
||||
void HandleSizeEvent(WPARAM w_param, LPARAM l_param);
|
||||
#endif
|
||||
|
||||
@@ -167,19 +171,19 @@ class NativeWindowViews : public NativeWindow,
|
||||
// Returns the restore state for the window.
|
||||
ui::WindowShowState GetRestoredState();
|
||||
|
||||
scoped_ptr<views::Widget> window_;
|
||||
std::unique_ptr<views::Widget> window_;
|
||||
views::View* web_view_; // Managed by inspectable_web_contents_.
|
||||
|
||||
scoped_ptr<MenuBar> menu_bar_;
|
||||
std::unique_ptr<MenuBar> menu_bar_;
|
||||
bool menu_bar_autohide_;
|
||||
bool menu_bar_visible_;
|
||||
bool menu_bar_alt_pressed_;
|
||||
|
||||
#if defined(USE_X11)
|
||||
scoped_ptr<GlobalMenuBarX11> global_menu_bar_;
|
||||
std::unique_ptr<GlobalMenuBarX11> global_menu_bar_;
|
||||
|
||||
// Handles window state events.
|
||||
scoped_ptr<WindowStateWatcher> window_state_watcher_;
|
||||
std::unique_ptr<WindowStateWatcher> window_state_watcher_;
|
||||
|
||||
// The "resizable" flag on Linux is implemented by setting size constraints,
|
||||
// we need to make sure size constraints are restored when window becomes
|
||||
@@ -203,10 +207,13 @@ class NativeWindowViews : public NativeWindow,
|
||||
// If true we have enabled a11y
|
||||
bool enabled_a11y_support_;
|
||||
|
||||
// The icons of window and taskbar.
|
||||
base::win::ScopedHICON window_icon_;
|
||||
base::win::ScopedHICON app_icon_;
|
||||
#endif
|
||||
|
||||
// Handles unhandled keyboard messages coming back from the renderer process.
|
||||
scoped_ptr<views::UnhandledKeyboardEventHandler> keyboard_event_handler_;
|
||||
std::unique_ptr<views::UnhandledKeyboardEventHandler> keyboard_event_handler_;
|
||||
|
||||
// Map from accelerator to menu item's command id.
|
||||
accelerator_util::AcceleratorTable accelerator_table_;
|
||||
|
||||
@@ -112,7 +112,7 @@ class URLRequestAsarJob : public net::URLRequestJob {
|
||||
base::FilePath file_path_;
|
||||
Archive::FileInfo file_info_;
|
||||
|
||||
scoped_ptr<net::FileStream> stream_;
|
||||
std::unique_ptr<net::FileStream> stream_;
|
||||
FileMetaInfo meta_info_;
|
||||
scoped_refptr<base::TaskRunner> file_task_runner_;
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ int AtomCertVerifier::Verify(
|
||||
net::CRLSet* crl_set,
|
||||
net::CertVerifyResult* verify_result,
|
||||
const net::CompletionCallback& callback,
|
||||
scoped_ptr<Request>* out_req,
|
||||
std::unique_ptr<Request>* out_req,
|
||||
const net::BoundNetLog& net_log) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||
|
||||
|
||||
@@ -34,14 +34,14 @@ class AtomCertVerifier : public net::CertVerifier {
|
||||
net::CRLSet* crl_set,
|
||||
net::CertVerifyResult* verify_result,
|
||||
const net::CompletionCallback& callback,
|
||||
scoped_ptr<Request>* out_req,
|
||||
std::unique_ptr<Request>* out_req,
|
||||
const net::BoundNetLog& net_log) override;
|
||||
bool SupportsOCSPStapling() override;
|
||||
|
||||
private:
|
||||
base::Lock lock_;
|
||||
VerifyProc verify_proc_;
|
||||
scoped_ptr<net::CertVerifier> default_cert_verifier_;
|
||||
std::unique_ptr<net::CertVerifier> default_cert_verifier_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomCertVerifier);
|
||||
};
|
||||
|
||||
@@ -45,13 +45,13 @@ using ResponseHeadersContainer =
|
||||
std::pair<scoped_refptr<net::HttpResponseHeaders>*, const std::string&>;
|
||||
|
||||
void RunSimpleListener(const AtomNetworkDelegate::SimpleListener& listener,
|
||||
scoped_ptr<base::DictionaryValue> details) {
|
||||
std::unique_ptr<base::DictionaryValue> details) {
|
||||
return listener.Run(*(details.get()));
|
||||
}
|
||||
|
||||
void RunResponseListener(
|
||||
const AtomNetworkDelegate::ResponseListener& listener,
|
||||
scoped_ptr<base::DictionaryValue> details,
|
||||
std::unique_ptr<base::DictionaryValue> details,
|
||||
const AtomNetworkDelegate::ResponseCallback& callback) {
|
||||
return listener.Run(*(details.get()), callback);
|
||||
}
|
||||
@@ -79,7 +79,7 @@ void ToDictionary(base::DictionaryValue* details, net::URLRequest* request) {
|
||||
details->SetString("resourceType",
|
||||
info ? ResourceTypeToString(info->GetResourceType())
|
||||
: "other");
|
||||
scoped_ptr<base::ListValue> list(new base::ListValue);
|
||||
std::unique_ptr<base::ListValue> list(new base::ListValue);
|
||||
GetUploadData(list.get(), request);
|
||||
if (!list->empty())
|
||||
details->Set("uploadData", std::move(list));
|
||||
@@ -87,7 +87,7 @@ void ToDictionary(base::DictionaryValue* details, net::URLRequest* request) {
|
||||
|
||||
void ToDictionary(base::DictionaryValue* details,
|
||||
const net::HttpRequestHeaders& headers) {
|
||||
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
|
||||
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
|
||||
net::HttpRequestHeaders::Iterator it(headers);
|
||||
while (it.GetNext())
|
||||
dict->SetString(it.name(), it.value());
|
||||
@@ -99,8 +99,8 @@ void ToDictionary(base::DictionaryValue* details,
|
||||
if (!headers)
|
||||
return;
|
||||
|
||||
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
|
||||
void* iter = nullptr;
|
||||
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
|
||||
size_t iter = 0;
|
||||
std::string key;
|
||||
std::string value;
|
||||
while (headers->EnumerateHeaderLines(&iter, &key, &value)) {
|
||||
@@ -109,7 +109,7 @@ void ToDictionary(base::DictionaryValue* details,
|
||||
if (dict->GetList(key, &values))
|
||||
values->AppendString(value);
|
||||
} else {
|
||||
scoped_ptr<base::ListValue> values(new base::ListValue);
|
||||
std::unique_ptr<base::ListValue> values(new base::ListValue);
|
||||
values->AppendString(value);
|
||||
dict->Set(key, std::move(values));
|
||||
}
|
||||
@@ -369,7 +369,7 @@ int AtomNetworkDelegate::HandleResponseEvent(
|
||||
if (!MatchesFilterCondition(request, info.url_patterns))
|
||||
return net::OK;
|
||||
|
||||
scoped_ptr<base::DictionaryValue> details(new base::DictionaryValue);
|
||||
std::unique_ptr<base::DictionaryValue> details(new base::DictionaryValue);
|
||||
FillDetailsObject(details.get(), request, args...);
|
||||
|
||||
// The |request| could be destroyed before the |callback| is called.
|
||||
@@ -392,7 +392,7 @@ void AtomNetworkDelegate::HandleSimpleEvent(
|
||||
if (!MatchesFilterCondition(request, info.url_patterns))
|
||||
return;
|
||||
|
||||
scoped_ptr<base::DictionaryValue> details(new base::DictionaryValue);
|
||||
std::unique_ptr<base::DictionaryValue> details(new base::DictionaryValue);
|
||||
FillDetailsObject(details.get(), request, args...);
|
||||
|
||||
BrowserThread::PostTask(
|
||||
@@ -402,7 +402,7 @@ void AtomNetworkDelegate::HandleSimpleEvent(
|
||||
|
||||
template<typename T>
|
||||
void AtomNetworkDelegate::OnListenerResultInIO(
|
||||
uint64_t id, T out, scoped_ptr<base::DictionaryValue> response) {
|
||||
uint64_t id, T out, std::unique_ptr<base::DictionaryValue> response) {
|
||||
// The request has been destroyed.
|
||||
if (!ContainsKey(callbacks_, id))
|
||||
return;
|
||||
@@ -417,7 +417,7 @@ void AtomNetworkDelegate::OnListenerResultInIO(
|
||||
template<typename T>
|
||||
void AtomNetworkDelegate::OnListenerResultInUI(
|
||||
uint64_t id, T out, const base::DictionaryValue& response) {
|
||||
scoped_ptr<base::DictionaryValue> copy = response.CreateDeepCopy();
|
||||
std::unique_ptr<base::DictionaryValue> copy = response.CreateDeepCopy();
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(&AtomNetworkDelegate::OnListenerResultInIO<T>,
|
||||
|
||||
@@ -111,7 +111,7 @@ class AtomNetworkDelegate : public brightray::NetworkDelegate {
|
||||
// Deal with the results of Listener.
|
||||
template<typename T>
|
||||
void OnListenerResultInIO(
|
||||
uint64_t id, T out, scoped_ptr<base::DictionaryValue> response);
|
||||
uint64_t id, T out, std::unique_ptr<base::DictionaryValue> response);
|
||||
template<typename T>
|
||||
void OnListenerResultInUI(
|
||||
uint64_t id, T out, const base::DictionaryValue& response);
|
||||
|
||||
@@ -23,7 +23,8 @@ AtomURLRequestJobFactory::~AtomURLRequestJobFactory() {
|
||||
}
|
||||
|
||||
bool AtomURLRequestJobFactory::SetProtocolHandler(
|
||||
const std::string& scheme, scoped_ptr<ProtocolHandler> protocol_handler) {
|
||||
const std::string& scheme,
|
||||
std::unique_ptr<ProtocolHandler> protocol_handler) {
|
||||
if (!protocol_handler) {
|
||||
ProtocolHandlerMap::iterator it = protocol_handler_map_.find(scheme);
|
||||
if (it == protocol_handler_map_.end())
|
||||
@@ -40,8 +41,9 @@ bool AtomURLRequestJobFactory::SetProtocolHandler(
|
||||
return true;
|
||||
}
|
||||
|
||||
scoped_ptr<ProtocolHandler> AtomURLRequestJobFactory::ReplaceProtocol(
|
||||
const std::string& scheme, scoped_ptr<ProtocolHandler> protocol_handler) {
|
||||
std::unique_ptr<ProtocolHandler> AtomURLRequestJobFactory::ReplaceProtocol(
|
||||
const std::string& scheme,
|
||||
std::unique_ptr<ProtocolHandler> protocol_handler) {
|
||||
if (!ContainsKey(protocol_handler_map_, scheme))
|
||||
return nullptr;
|
||||
ProtocolHandler* original_protocol_handler = protocol_handler_map_[scheme];
|
||||
|
||||
@@ -24,13 +24,14 @@ class AtomURLRequestJobFactory : public net::URLRequestJobFactory {
|
||||
// Sets the ProtocolHandler for a scheme. Returns true on success, false on
|
||||
// failure (a ProtocolHandler already exists for |scheme|). On success,
|
||||
// URLRequestJobFactory takes ownership of |protocol_handler|.
|
||||
bool SetProtocolHandler(
|
||||
const std::string& scheme, scoped_ptr<ProtocolHandler> protocol_handler);
|
||||
bool SetProtocolHandler(const std::string& scheme,
|
||||
std::unique_ptr<ProtocolHandler> protocol_handler);
|
||||
|
||||
// Intercepts the ProtocolHandler for a scheme. Returns the original protocol
|
||||
// handler on success, otherwise returns NULL.
|
||||
scoped_ptr<ProtocolHandler> ReplaceProtocol(
|
||||
const std::string& scheme, scoped_ptr<ProtocolHandler> protocol_handler);
|
||||
std::unique_ptr<ProtocolHandler> ReplaceProtocol(
|
||||
const std::string& scheme,
|
||||
std::unique_ptr<ProtocolHandler> protocol_handler);
|
||||
|
||||
// Returns the protocol handler registered with scheme.
|
||||
ProtocolHandler* GetProtocolHandler(const std::string& scheme) const;
|
||||
|
||||
@@ -34,7 +34,7 @@ void HandlerCallback(const BeforeStartCallback& before_start,
|
||||
// Pass whatever user passed to the actaul request job.
|
||||
V8ValueConverter converter;
|
||||
v8::Local<v8::Context> context = args->isolate()->GetCurrentContext();
|
||||
scoped_ptr<base::Value> options(converter.FromV8Value(value, context));
|
||||
std::unique_ptr<base::Value> options(converter.FromV8Value(value, context));
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(callback, true, base::Passed(&options)));
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace internal {
|
||||
using BeforeStartCallback =
|
||||
base::Callback<void(v8::Isolate*, v8::Local<v8::Value>)>;
|
||||
using ResponseCallback =
|
||||
base::Callback<void(bool, scoped_ptr<base::Value> options)>;
|
||||
base::Callback<void(bool, std::unique_ptr<base::Value> options)>;
|
||||
|
||||
// Ask handler for options in UI thread.
|
||||
void AskForOptions(v8::Isolate* isolate,
|
||||
@@ -58,7 +58,7 @@ class JsAsker : public RequestJob {
|
||||
|
||||
// Subclass should do initailze work here.
|
||||
virtual void BeforeStartInUI(v8::Isolate*, v8::Local<v8::Value>) {}
|
||||
virtual void StartAsync(scoped_ptr<base::Value> options) = 0;
|
||||
virtual void StartAsync(std::unique_ptr<base::Value> options) = 0;
|
||||
|
||||
net::URLRequestContextGetter* request_context_getter() const {
|
||||
return request_context_getter_;
|
||||
@@ -84,7 +84,7 @@ class JsAsker : public RequestJob {
|
||||
|
||||
// Called when the JS handler has sent the response, we need to decide whether
|
||||
// to start, or fail the job.
|
||||
void OnResponse(bool success, scoped_ptr<base::Value> value) {
|
||||
void OnResponse(bool success, std::unique_ptr<base::Value> value) {
|
||||
int error = net::ERR_NOT_IMPLEMENTED;
|
||||
if (success && value && !internal::IsErrorOptions(value.get(), &error)) {
|
||||
StartAsync(std::move(value));
|
||||
|
||||
@@ -16,7 +16,7 @@ URLRequestAsyncAsarJob::URLRequestAsyncAsarJob(
|
||||
: JsAsker<asar::URLRequestAsarJob>(request, network_delegate) {
|
||||
}
|
||||
|
||||
void URLRequestAsyncAsarJob::StartAsync(scoped_ptr<base::Value> options) {
|
||||
void URLRequestAsyncAsarJob::StartAsync(std::unique_ptr<base::Value> options) {
|
||||
base::FilePath::StringType file_path;
|
||||
if (options->IsType(base::Value::TYPE_DICTIONARY)) {
|
||||
static_cast<base::DictionaryValue*>(options.get())->GetString(
|
||||
|
||||
@@ -16,7 +16,7 @@ class URLRequestAsyncAsarJob : public JsAsker<asar::URLRequestAsarJob> {
|
||||
URLRequestAsyncAsarJob(net::URLRequest*, net::NetworkDelegate*);
|
||||
|
||||
// JsAsker:
|
||||
void StartAsync(scoped_ptr<base::Value> options) override;
|
||||
void StartAsync(std::unique_ptr<base::Value> options) override;
|
||||
|
||||
// URLRequestJob:
|
||||
void GetResponseInfo(net::HttpResponseInfo* info) override;
|
||||
|
||||
@@ -8,17 +8,31 @@
|
||||
|
||||
#include "atom/common/atom_constants.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "net/base/mime_util.h"
|
||||
#include "net/base/net_errors.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
std::string GetExtFromURL(const GURL& url) {
|
||||
std::string spec = url.spec();
|
||||
size_t index = spec.find_last_of('.');
|
||||
if (index == std::string::npos || index == spec.size())
|
||||
return std::string();
|
||||
return spec.substr(index + 1, spec.size() - index - 1);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
URLRequestBufferJob::URLRequestBufferJob(
|
||||
net::URLRequest* request, net::NetworkDelegate* network_delegate)
|
||||
: JsAsker<net::URLRequestSimpleJob>(request, network_delegate),
|
||||
status_code_(net::HTTP_NOT_IMPLEMENTED) {
|
||||
}
|
||||
|
||||
void URLRequestBufferJob::StartAsync(scoped_ptr<base::Value> options) {
|
||||
void URLRequestBufferJob::StartAsync(std::unique_ptr<base::Value> options) {
|
||||
const base::BinaryValue* binary = nullptr;
|
||||
if (options->IsType(base::Value::TYPE_DICTIONARY)) {
|
||||
base::DictionaryValue* dict =
|
||||
@@ -30,6 +44,15 @@ void URLRequestBufferJob::StartAsync(scoped_ptr<base::Value> options) {
|
||||
options->GetAsBinary(&binary);
|
||||
}
|
||||
|
||||
if (mime_type_.empty()) {
|
||||
std::string ext = GetExtFromURL(request()->url());
|
||||
#if defined(OS_WIN)
|
||||
net::GetWellKnownMimeTypeFromExtension(base::UTF8ToUTF16(ext), &mime_type_);
|
||||
#else
|
||||
net::GetWellKnownMimeTypeFromExtension(ext, &mime_type_);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!binary) {
|
||||
NotifyStartError(net::URLRequestStatus(
|
||||
net::URLRequestStatus::FAILED, net::ERR_NOT_IMPLEMENTED));
|
||||
|
||||
@@ -19,7 +19,7 @@ class URLRequestBufferJob : public JsAsker<net::URLRequestSimpleJob> {
|
||||
URLRequestBufferJob(net::URLRequest*, net::NetworkDelegate*);
|
||||
|
||||
// JsAsker:
|
||||
void StartAsync(scoped_ptr<base::Value> options) override;
|
||||
void StartAsync(std::unique_ptr<base::Value> options) override;
|
||||
|
||||
// URLRequestJob:
|
||||
void GetResponseInfo(net::HttpResponseInfo* info) override;
|
||||
|
||||
@@ -59,7 +59,7 @@ class ResponsePiper : public net::URLFetcherResponseWriter {
|
||||
job_->HeadersCompleted();
|
||||
first_write_ = false;
|
||||
}
|
||||
return job_->DataAvailable(buffer, num_bytes);
|
||||
return job_->DataAvailable(buffer, num_bytes, callback);
|
||||
}
|
||||
int Finish(const net::CompletionCallback& callback) override {
|
||||
return net::OK;
|
||||
@@ -77,7 +77,8 @@ class ResponsePiper : public net::URLFetcherResponseWriter {
|
||||
URLRequestFetchJob::URLRequestFetchJob(
|
||||
net::URLRequest* request, net::NetworkDelegate* network_delegate)
|
||||
: JsAsker<net::URLRequestJob>(request, network_delegate),
|
||||
pending_buffer_size_(0) {
|
||||
pending_buffer_size_(0),
|
||||
write_num_bytes_(0) {
|
||||
}
|
||||
|
||||
void URLRequestFetchJob::BeforeStartInUI(
|
||||
@@ -99,7 +100,7 @@ void URLRequestFetchJob::BeforeStartInUI(
|
||||
}
|
||||
}
|
||||
|
||||
void URLRequestFetchJob::StartAsync(scoped_ptr<base::Value> options) {
|
||||
void URLRequestFetchJob::StartAsync(std::unique_ptr<base::Value> options) {
|
||||
if (!options->IsType(base::Value::TYPE_DICTIONARY)) {
|
||||
NotifyStartError(net::URLRequestStatus(
|
||||
net::URLRequestStatus::FAILED, net::ERR_NOT_IMPLEMENTED));
|
||||
@@ -166,22 +167,23 @@ void URLRequestFetchJob::HeadersCompleted() {
|
||||
NotifyHeadersComplete();
|
||||
}
|
||||
|
||||
int URLRequestFetchJob::DataAvailable(net::IOBuffer* buffer, int num_bytes) {
|
||||
// Do nothing if pending_buffer_ is empty, i.e. there's no ReadRawData()
|
||||
// operation waiting for IO completion.
|
||||
if (!pending_buffer_.get())
|
||||
int URLRequestFetchJob::DataAvailable(net::IOBuffer* buffer,
|
||||
int num_bytes,
|
||||
const net::CompletionCallback& callback) {
|
||||
// When pending_buffer_ is empty, there's no ReadRawData() operation waiting
|
||||
// for IO completion, we have to save the parameters until the request is
|
||||
// ready to read data.
|
||||
if (!pending_buffer_.get()) {
|
||||
write_buffer_ = buffer;
|
||||
write_num_bytes_ = num_bytes;
|
||||
write_callback_ = callback;
|
||||
return net::ERR_IO_PENDING;
|
||||
}
|
||||
|
||||
// pending_buffer_ is set to the IOBuffer instance provided to ReadRawData()
|
||||
// by URLRequestJob.
|
||||
int bytes_read = std::min(num_bytes, pending_buffer_size_);
|
||||
memcpy(pending_buffer_->data(), buffer->data(), bytes_read);
|
||||
|
||||
// Clear the buffers before notifying the read is complete, so that it is
|
||||
// safe for the observer to read.
|
||||
pending_buffer_ = nullptr;
|
||||
pending_buffer_size_ = 0;
|
||||
|
||||
// Write data to the pending buffer and clear them after the writing.
|
||||
int bytes_read = BufferCopy(buffer, num_bytes,
|
||||
pending_buffer_.get(), pending_buffer_size_);
|
||||
ClearPendingBuffer();
|
||||
ReadRawDataComplete(bytes_read);
|
||||
return bytes_read;
|
||||
}
|
||||
@@ -196,9 +198,22 @@ int URLRequestFetchJob::ReadRawData(net::IOBuffer* dest, int dest_size) {
|
||||
request()->set_received_response_content_length(prefilter_bytes_read());
|
||||
return net::OK;
|
||||
}
|
||||
pending_buffer_ = dest;
|
||||
pending_buffer_size_ = dest_size;
|
||||
return net::ERR_IO_PENDING;
|
||||
|
||||
// When write_buffer_ is empty, there is no data valable yet, we have to save
|
||||
// the dest buffer util DataAvailable.
|
||||
if (!write_buffer_.get()) {
|
||||
pending_buffer_ = dest;
|
||||
pending_buffer_size_ = dest_size;
|
||||
return net::ERR_IO_PENDING;
|
||||
}
|
||||
|
||||
// Read from the write buffer and clear them after reading.
|
||||
int bytes_read = BufferCopy(write_buffer_.get(), write_num_bytes_,
|
||||
dest, dest_size);
|
||||
net::CompletionCallback write_callback = write_callback_;
|
||||
ClearWriteBuffer();
|
||||
write_callback.Run(bytes_read);
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
bool URLRequestFetchJob::GetMimeType(std::string* mime_type) const {
|
||||
@@ -229,12 +244,31 @@ void URLRequestFetchJob::OnURLFetchComplete(const net::URLFetcher* source) {
|
||||
return;
|
||||
}
|
||||
|
||||
pending_buffer_ = nullptr;
|
||||
pending_buffer_size_ = 0;
|
||||
ClearPendingBuffer();
|
||||
ClearWriteBuffer();
|
||||
|
||||
if (fetcher_->GetStatus().is_success())
|
||||
ReadRawDataComplete(0);
|
||||
else
|
||||
NotifyStartError(fetcher_->GetStatus());
|
||||
}
|
||||
|
||||
int URLRequestFetchJob::BufferCopy(net::IOBuffer* source, int num_bytes,
|
||||
net::IOBuffer* target, int target_size) {
|
||||
int bytes_written = std::min(num_bytes, target_size);
|
||||
memcpy(target->data(), source->data(), bytes_written);
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
void URLRequestFetchJob::ClearPendingBuffer() {
|
||||
pending_buffer_ = nullptr;
|
||||
pending_buffer_size_ = 0;
|
||||
}
|
||||
|
||||
void URLRequestFetchJob::ClearWriteBuffer() {
|
||||
write_buffer_ = nullptr;
|
||||
write_num_bytes_ = 0;
|
||||
write_callback_.Reset();
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -9,14 +9,10 @@
|
||||
|
||||
#include "atom/browser/net/js_asker.h"
|
||||
#include "browser/url_request_context_getter.h"
|
||||
#include "net/url_request/url_request_context_getter.h"
|
||||
#include "net/url_request/url_fetcher_delegate.h"
|
||||
#include "net/url_request/url_request_job.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class AtomBrowserContext;
|
||||
|
||||
class URLRequestFetchJob : public JsAsker<net::URLRequestJob>,
|
||||
public net::URLFetcherDelegate,
|
||||
public brightray::URLRequestContextGetter::Delegate {
|
||||
@@ -25,12 +21,14 @@ class URLRequestFetchJob : public JsAsker<net::URLRequestJob>,
|
||||
|
||||
// Called by response writer.
|
||||
void HeadersCompleted();
|
||||
int DataAvailable(net::IOBuffer* buffer, int num_bytes);
|
||||
int DataAvailable(net::IOBuffer* buffer,
|
||||
int num_bytes,
|
||||
const net::CompletionCallback& callback);
|
||||
|
||||
protected:
|
||||
// JsAsker:
|
||||
void BeforeStartInUI(v8::Isolate*, v8::Local<v8::Value>) override;
|
||||
void StartAsync(scoped_ptr<base::Value> options) override;
|
||||
void StartAsync(std::unique_ptr<base::Value> options) override;
|
||||
|
||||
// net::URLRequestJob:
|
||||
void Kill() override;
|
||||
@@ -43,11 +41,23 @@ class URLRequestFetchJob : public JsAsker<net::URLRequestJob>,
|
||||
void OnURLFetchComplete(const net::URLFetcher* source) override;
|
||||
|
||||
private:
|
||||
int BufferCopy(net::IOBuffer* source, int num_bytes,
|
||||
net::IOBuffer* target, int target_size);
|
||||
void ClearPendingBuffer();
|
||||
void ClearWriteBuffer();
|
||||
|
||||
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
|
||||
scoped_ptr<net::URLFetcher> fetcher_;
|
||||
std::unique_ptr<net::URLFetcher> fetcher_;
|
||||
std::unique_ptr<net::HttpResponseInfo> response_info_;
|
||||
|
||||
// Saved arguments passed to ReadRawData.
|
||||
scoped_refptr<net::IOBuffer> pending_buffer_;
|
||||
int pending_buffer_size_;
|
||||
scoped_ptr<net::HttpResponseInfo> response_info_;
|
||||
|
||||
// Saved arguments passed to DataAvailable.
|
||||
scoped_refptr<net::IOBuffer> write_buffer_;
|
||||
int write_num_bytes_;
|
||||
net::CompletionCallback write_callback_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(URLRequestFetchJob);
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@ URLRequestStringJob::URLRequestStringJob(
|
||||
: JsAsker<net::URLRequestSimpleJob>(request, network_delegate) {
|
||||
}
|
||||
|
||||
void URLRequestStringJob::StartAsync(scoped_ptr<base::Value> options) {
|
||||
void URLRequestStringJob::StartAsync(std::unique_ptr<base::Value> options) {
|
||||
if (options->IsType(base::Value::TYPE_DICTIONARY)) {
|
||||
base::DictionaryValue* dict =
|
||||
static_cast<base::DictionaryValue*>(options.get());
|
||||
|
||||
@@ -17,7 +17,7 @@ class URLRequestStringJob : public JsAsker<net::URLRequestSimpleJob> {
|
||||
URLRequestStringJob(net::URLRequest*, net::NetworkDelegate*);
|
||||
|
||||
// JsAsker:
|
||||
void StartAsync(scoped_ptr<base::Value> options) override;
|
||||
void StartAsync(std::unique_ptr<base::Value> options) override;
|
||||
|
||||
// URLRequestJob:
|
||||
void GetResponseInfo(net::HttpResponseInfo* info) override;
|
||||
|
||||
@@ -145,7 +145,7 @@ void NodeDebugger::DebugMessageHandler(const v8::Debug::Message& message) {
|
||||
|
||||
void NodeDebugger::DidAccept(
|
||||
net::test_server::StreamListenSocket* server,
|
||||
scoped_ptr<net::test_server::StreamListenSocket> socket) {
|
||||
std::unique_ptr<net::test_server::StreamListenSocket> socket) {
|
||||
// Only accept one session.
|
||||
if (accepted_socket_) {
|
||||
socket->Send(std::string("Remote debugging session already active"), true);
|
||||
|
||||
@@ -38,7 +38,7 @@ class NodeDebugger : public net::test_server::StreamListenSocket::Delegate {
|
||||
// net::test_server::StreamListenSocket::Delegate:
|
||||
void DidAccept(
|
||||
net::test_server::StreamListenSocket* server,
|
||||
scoped_ptr<net::test_server::StreamListenSocket> socket) override;
|
||||
std::unique_ptr<net::test_server::StreamListenSocket> socket) override;
|
||||
void DidRead(net::test_server::StreamListenSocket* socket,
|
||||
const char* data,
|
||||
int len) override;
|
||||
@@ -49,8 +49,8 @@ class NodeDebugger : public net::test_server::StreamListenSocket::Delegate {
|
||||
uv_async_t weak_up_ui_handle_;
|
||||
|
||||
base::Thread thread_;
|
||||
scoped_ptr<net::test_server::StreamListenSocket> server_;
|
||||
scoped_ptr<net::test_server::StreamListenSocket> accepted_socket_;
|
||||
std::unique_ptr<net::test_server::StreamListenSocket> server_;
|
||||
std::unique_ptr<net::test_server::StreamListenSocket> accepted_socket_;
|
||||
|
||||
std::string buffer_;
|
||||
int content_length_;
|
||||
|
||||
63
atom/browser/render_process_preferences.cc
Normal file
63
atom/browser/render_process_preferences.cc
Normal file
@@ -0,0 +1,63 @@
|
||||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/render_process_preferences.h"
|
||||
|
||||
#include "atom/common/api/api_messages.h"
|
||||
#include "content/public/browser/notification_service.h"
|
||||
#include "content/public/browser/notification_types.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
RenderProcessPreferences::RenderProcessPreferences(const Predicate& predicate)
|
||||
: predicate_(predicate),
|
||||
next_id_(0),
|
||||
cache_needs_update_(true) {
|
||||
registrar_.Add(this,
|
||||
content::NOTIFICATION_RENDERER_PROCESS_CREATED,
|
||||
content::NotificationService::AllBrowserContextsAndSources());
|
||||
}
|
||||
|
||||
RenderProcessPreferences::~RenderProcessPreferences() {
|
||||
}
|
||||
|
||||
int RenderProcessPreferences::AddEntry(const base::DictionaryValue& entry) {
|
||||
int id = ++next_id_;
|
||||
entries_[id] = entry.CreateDeepCopy();
|
||||
cache_needs_update_ = true;
|
||||
return id;
|
||||
}
|
||||
|
||||
void RenderProcessPreferences::RemoveEntry(int id) {
|
||||
cache_needs_update_ = true;
|
||||
entries_.erase(id);
|
||||
}
|
||||
|
||||
void RenderProcessPreferences::Observe(
|
||||
int type,
|
||||
const content::NotificationSource& source,
|
||||
const content::NotificationDetails& details) {
|
||||
DCHECK_EQ(type, content::NOTIFICATION_RENDERER_PROCESS_CREATED);
|
||||
content::RenderProcessHost* process =
|
||||
content::Source<content::RenderProcessHost>(source).ptr();
|
||||
|
||||
if (!predicate_.Run(process))
|
||||
return;
|
||||
|
||||
UpdateCache();
|
||||
process->Send(new AtomMsg_UpdatePreferences(cached_entries_));
|
||||
}
|
||||
|
||||
void RenderProcessPreferences::UpdateCache() {
|
||||
if (!cache_needs_update_)
|
||||
return;
|
||||
|
||||
cached_entries_.Clear();
|
||||
for (const auto& iter : entries_)
|
||||
cached_entries_.Append(iter.second->CreateDeepCopy());
|
||||
cache_needs_update_ = false;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
61
atom/browser/render_process_preferences.h
Normal file
61
atom/browser/render_process_preferences.h
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.
|
||||
|
||||
#ifndef ATOM_BROWSER_RENDER_PROCESS_PREFERENCES_H_
|
||||
#define ATOM_BROWSER_RENDER_PROCESS_PREFERENCES_H_
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "base/values.h"
|
||||
#include "content/public/browser/notification_observer.h"
|
||||
#include "content/public/browser/notification_registrar.h"
|
||||
|
||||
namespace content {
|
||||
class RenderProcessHost;
|
||||
}
|
||||
|
||||
namespace atom {
|
||||
|
||||
// Sets user preferences for render processes.
|
||||
class RenderProcessPreferences : public content::NotificationObserver {
|
||||
public:
|
||||
using Predicate = base::Callback<bool(content::RenderProcessHost*)>;
|
||||
|
||||
// The |predicate| is used to determine whether to set preferences for a
|
||||
// render process.
|
||||
explicit RenderProcessPreferences(const Predicate& predicate);
|
||||
virtual ~RenderProcessPreferences();
|
||||
|
||||
int AddEntry(const base::DictionaryValue& entry);
|
||||
void RemoveEntry(int id);
|
||||
|
||||
private:
|
||||
// content::NotificationObserver:
|
||||
void Observe(int type,
|
||||
const content::NotificationSource& source,
|
||||
const content::NotificationDetails& details) override;
|
||||
|
||||
void UpdateCache();
|
||||
|
||||
// Manages our notification registrations.
|
||||
content::NotificationRegistrar registrar_;
|
||||
|
||||
Predicate predicate_;
|
||||
|
||||
int next_id_;
|
||||
std::unordered_map<int, std::unique_ptr<base::DictionaryValue>> entries_;
|
||||
|
||||
// We need to convert the |entries_| to ListValue for multiple times, this
|
||||
// caches is only updated when we are sending messages.
|
||||
bool cache_needs_update_;
|
||||
base::ListValue cached_entries_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(RenderProcessPreferences);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_RENDER_PROCESS_PREFERENCES_H_
|
||||
@@ -17,9 +17,9 @@
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>electron.icns</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0.2</string>
|
||||
<string>1.2.1</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.2</string>
|
||||
<string>1.2.1</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.developer-tools</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
|
||||
@@ -56,8 +56,8 @@ END
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,2,0
|
||||
PRODUCTVERSION 1,0,2,0
|
||||
FILEVERSION 1,2,1,0
|
||||
PRODUCTVERSION 1,2,1,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -74,12 +74,12 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "GitHub, Inc."
|
||||
VALUE "FileDescription", "Electron"
|
||||
VALUE "FileVersion", "1.0.2"
|
||||
VALUE "FileVersion", "1.2.1"
|
||||
VALUE "InternalName", "electron.exe"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved."
|
||||
VALUE "OriginalFilename", "electron.exe"
|
||||
VALUE "ProductName", "Electron"
|
||||
VALUE "ProductVersion", "1.0.2"
|
||||
VALUE "ProductVersion", "1.2.1"
|
||||
VALUE "SquirrelAwareVersion", "1"
|
||||
END
|
||||
END
|
||||
|
||||
@@ -32,7 +32,7 @@ void SetPlatformAccelerator(ui::Accelerator* accelerator) {
|
||||
NSString* characters =
|
||||
[[[NSString alloc] initWithCharacters:&character length:1] autorelease];
|
||||
|
||||
scoped_ptr<ui::PlatformAccelerator> platform_accelerator(
|
||||
std::unique_ptr<ui::PlatformAccelerator> platform_accelerator(
|
||||
new ui::PlatformAcceleratorCocoa(characters, modifiers));
|
||||
accelerator->set_platform_accelerator(std::move(platform_accelerator));
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ typedef base::Callback<void(
|
||||
|
||||
bool ShowOpenDialog(atom::NativeWindow* parent_window,
|
||||
const std::string& title,
|
||||
const std::string& button_label,
|
||||
const base::FilePath& default_path,
|
||||
const Filters& filters,
|
||||
int properties,
|
||||
@@ -44,6 +45,7 @@ bool ShowOpenDialog(atom::NativeWindow* parent_window,
|
||||
|
||||
void ShowOpenDialog(atom::NativeWindow* parent_window,
|
||||
const std::string& title,
|
||||
const std::string& button_label,
|
||||
const base::FilePath& default_path,
|
||||
const Filters& filters,
|
||||
int properties,
|
||||
@@ -51,12 +53,14 @@ void ShowOpenDialog(atom::NativeWindow* parent_window,
|
||||
|
||||
bool ShowSaveDialog(atom::NativeWindow* parent_window,
|
||||
const std::string& title,
|
||||
const std::string& button_label,
|
||||
const base::FilePath& default_path,
|
||||
const Filters& filters,
|
||||
base::FilePath* path);
|
||||
|
||||
void ShowSaveDialog(atom::NativeWindow* parent_window,
|
||||
const std::string& title,
|
||||
const std::string& button_label,
|
||||
const base::FilePath& default_path,
|
||||
const Filters& filters,
|
||||
const SaveDialogCallback& callback);
|
||||
|
||||
@@ -37,12 +37,16 @@ class FileChooserDialog {
|
||||
FileChooserDialog(GtkFileChooserAction action,
|
||||
atom::NativeWindow* parent_window,
|
||||
const std::string& title,
|
||||
const std::string& button_label,
|
||||
const base::FilePath& default_path,
|
||||
const Filters& filters)
|
||||
: dialog_scope_(parent_window),
|
||||
filters_(filters) {
|
||||
const char* confirm_text = GTK_STOCK_OK;
|
||||
if (action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
||||
|
||||
if (!button_label.empty())
|
||||
confirm_text = button_label.c_str();
|
||||
else if (action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
||||
confirm_text = GTK_STOCK_SAVE;
|
||||
else if (action == GTK_FILE_CHOOSER_ACTION_OPEN)
|
||||
confirm_text = GTK_STOCK_OPEN;
|
||||
@@ -173,7 +177,7 @@ void FileChooserDialog::AddFilters(const Filters& filters) {
|
||||
GtkFileFilter* gtk_filter = gtk_file_filter_new();
|
||||
|
||||
for (size_t j = 0; j < filter.second.size(); ++j) {
|
||||
scoped_ptr<std::string> file_extension(
|
||||
std::unique_ptr<std::string> file_extension(
|
||||
new std::string("." + filter.second[j]));
|
||||
gtk_file_filter_add_custom(
|
||||
gtk_filter,
|
||||
@@ -216,6 +220,7 @@ base::FilePath FileChooserDialog::AddExtensionForFilename(
|
||||
|
||||
bool ShowOpenDialog(atom::NativeWindow* parent_window,
|
||||
const std::string& title,
|
||||
const std::string& button_label,
|
||||
const base::FilePath& default_path,
|
||||
const Filters& filters,
|
||||
int properties,
|
||||
@@ -223,8 +228,8 @@ bool ShowOpenDialog(atom::NativeWindow* parent_window,
|
||||
GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
|
||||
if (properties & FILE_DIALOG_OPEN_DIRECTORY)
|
||||
action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
|
||||
FileChooserDialog open_dialog(action, parent_window, title, default_path,
|
||||
filters);
|
||||
FileChooserDialog open_dialog(action, parent_window, title, button_label,
|
||||
default_path, filters);
|
||||
if (properties & FILE_DIALOG_MULTI_SELECTIONS)
|
||||
gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(open_dialog.dialog()),
|
||||
TRUE);
|
||||
@@ -241,6 +246,7 @@ bool ShowOpenDialog(atom::NativeWindow* parent_window,
|
||||
|
||||
void ShowOpenDialog(atom::NativeWindow* parent_window,
|
||||
const std::string& title,
|
||||
const std::string& button_label,
|
||||
const base::FilePath& default_path,
|
||||
const Filters& filters,
|
||||
int properties,
|
||||
@@ -249,7 +255,7 @@ void ShowOpenDialog(atom::NativeWindow* parent_window,
|
||||
if (properties & FILE_DIALOG_OPEN_DIRECTORY)
|
||||
action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
|
||||
FileChooserDialog* open_dialog = new FileChooserDialog(
|
||||
action, parent_window, title, default_path, filters);
|
||||
action, parent_window, title, button_label, default_path, filters);
|
||||
if (properties & FILE_DIALOG_MULTI_SELECTIONS)
|
||||
gtk_file_chooser_set_select_multiple(
|
||||
GTK_FILE_CHOOSER(open_dialog->dialog()), TRUE);
|
||||
@@ -259,11 +265,12 @@ void ShowOpenDialog(atom::NativeWindow* parent_window,
|
||||
|
||||
bool ShowSaveDialog(atom::NativeWindow* parent_window,
|
||||
const std::string& title,
|
||||
const std::string& button_label,
|
||||
const base::FilePath& default_path,
|
||||
const Filters& filters,
|
||||
base::FilePath* path) {
|
||||
FileChooserDialog save_dialog(GTK_FILE_CHOOSER_ACTION_SAVE, parent_window,
|
||||
title, default_path, filters);
|
||||
title, button_label, default_path, filters);
|
||||
gtk_widget_show_all(save_dialog.dialog());
|
||||
int response = gtk_dialog_run(GTK_DIALOG(save_dialog.dialog()));
|
||||
if (response == GTK_RESPONSE_ACCEPT) {
|
||||
@@ -276,12 +283,13 @@ bool ShowSaveDialog(atom::NativeWindow* parent_window,
|
||||
|
||||
void ShowSaveDialog(atom::NativeWindow* parent_window,
|
||||
const std::string& title,
|
||||
const std::string& button_label,
|
||||
const base::FilePath& default_path,
|
||||
const Filters& filters,
|
||||
const SaveDialogCallback& callback) {
|
||||
FileChooserDialog* save_dialog = new FileChooserDialog(
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE, parent_window, title, default_path,
|
||||
filters);
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE, parent_window, title, button_label,
|
||||
default_path, filters);
|
||||
save_dialog->RunSaveAsynchronous(callback);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,11 +45,15 @@ void SetAllowedFileTypes(NSSavePanel* dialog, const Filters& filters) {
|
||||
|
||||
void SetupDialog(NSSavePanel* dialog,
|
||||
const std::string& title,
|
||||
const std::string& button_label,
|
||||
const base::FilePath& default_path,
|
||||
const Filters& filters) {
|
||||
if (!title.empty())
|
||||
[dialog setTitle:base::SysUTF8ToNSString(title)];
|
||||
|
||||
if (!button_label.empty())
|
||||
[dialog setPrompt:base::SysUTF8ToNSString(button_label)];
|
||||
|
||||
NSString* default_dir = nil;
|
||||
NSString* default_filename = nil;
|
||||
if (!default_path.empty()) {
|
||||
@@ -114,6 +118,7 @@ void ReadDialogPaths(NSOpenPanel* dialog, std::vector<base::FilePath>* paths) {
|
||||
|
||||
bool ShowOpenDialog(atom::NativeWindow* parent_window,
|
||||
const std::string& title,
|
||||
const std::string& button_label,
|
||||
const base::FilePath& default_path,
|
||||
const Filters& filters,
|
||||
int properties,
|
||||
@@ -121,7 +126,7 @@ bool ShowOpenDialog(atom::NativeWindow* parent_window,
|
||||
DCHECK(paths);
|
||||
NSOpenPanel* dialog = [NSOpenPanel openPanel];
|
||||
|
||||
SetupDialog(dialog, title, default_path, filters);
|
||||
SetupDialog(dialog, title, button_label, default_path, filters);
|
||||
SetupDialogForProperties(dialog, properties);
|
||||
|
||||
int chosen = RunModalDialog(dialog, parent_window);
|
||||
@@ -134,13 +139,14 @@ bool ShowOpenDialog(atom::NativeWindow* parent_window,
|
||||
|
||||
void ShowOpenDialog(atom::NativeWindow* parent_window,
|
||||
const std::string& title,
|
||||
const std::string& button_label,
|
||||
const base::FilePath& default_path,
|
||||
const Filters& filters,
|
||||
int properties,
|
||||
const OpenDialogCallback& c) {
|
||||
NSOpenPanel* dialog = [NSOpenPanel openPanel];
|
||||
|
||||
SetupDialog(dialog, title, default_path, filters);
|
||||
SetupDialog(dialog, title, button_label, default_path, filters);
|
||||
SetupDialogForProperties(dialog, properties);
|
||||
|
||||
// Duplicate the callback object here since c is a reference and gcd would
|
||||
@@ -162,13 +168,14 @@ void ShowOpenDialog(atom::NativeWindow* parent_window,
|
||||
|
||||
bool ShowSaveDialog(atom::NativeWindow* parent_window,
|
||||
const std::string& title,
|
||||
const std::string& button_label,
|
||||
const base::FilePath& default_path,
|
||||
const Filters& filters,
|
||||
base::FilePath* path) {
|
||||
DCHECK(path);
|
||||
NSSavePanel* dialog = [NSSavePanel savePanel];
|
||||
|
||||
SetupDialog(dialog, title, default_path, filters);
|
||||
SetupDialog(dialog, title, button_label, default_path, filters);
|
||||
|
||||
int chosen = RunModalDialog(dialog, parent_window);
|
||||
if (chosen == NSFileHandlingPanelCancelButton || ![[dialog URL] isFileURL])
|
||||
@@ -180,12 +187,13 @@ bool ShowSaveDialog(atom::NativeWindow* parent_window,
|
||||
|
||||
void ShowSaveDialog(atom::NativeWindow* parent_window,
|
||||
const std::string& title,
|
||||
const std::string& button_label,
|
||||
const base::FilePath& default_path,
|
||||
const Filters& filters,
|
||||
const SaveDialogCallback& c) {
|
||||
NSSavePanel* dialog = [NSSavePanel savePanel];
|
||||
|
||||
SetupDialog(dialog, title, default_path, filters);
|
||||
SetupDialog(dialog, title, button_label, default_path, filters);
|
||||
|
||||
__block SaveDialogCallback callback = c;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user