mirror of
https://github.com/electron/electron.git
synced 2026-02-26 03:01:17 -05:00
Compare commits
439 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2cddb5bb4e | ||
|
|
b90e23306e | ||
|
|
8cc29c2e22 | ||
|
|
a3af6bd9f5 | ||
|
|
a23d8ed702 | ||
|
|
3766fb6652 | ||
|
|
a7891e584a | ||
|
|
e82b41724d | ||
|
|
6af7cfff33 | ||
|
|
057fda5352 | ||
|
|
71512ad244 | ||
|
|
edb3967a0f | ||
|
|
ade16a7823 | ||
|
|
f7bdf5d04e | ||
|
|
dcbc10ac38 | ||
|
|
feac8685f4 | ||
|
|
9ccc78c62f | ||
|
|
1d824d4645 | ||
|
|
b26428c43c | ||
|
|
815cb1b31c | ||
|
|
dcf9a395c2 | ||
|
|
2e62d81c24 | ||
|
|
13acf7a6a3 | ||
|
|
f35224b0e4 | ||
|
|
6bcfd0630c | ||
|
|
f4f0174746 | ||
|
|
37b7dda3c5 | ||
|
|
fbcbfbda6a | ||
|
|
de4be56b09 | ||
|
|
f3852c57fc | ||
|
|
2e6d08c652 | ||
|
|
bb260343de | ||
|
|
3f7b3c4bd7 | ||
|
|
95054f443f | ||
|
|
eef72647b4 | ||
|
|
33b6ab11f2 | ||
|
|
dacfb2f596 | ||
|
|
3ac6019f42 | ||
|
|
0f7af8043a | ||
|
|
14a1e673c6 | ||
|
|
802ed62d5b | ||
|
|
572fc058d3 | ||
|
|
b348cdeae8 | ||
|
|
ea2273dde5 | ||
|
|
ad3b837ad5 | ||
|
|
b56bdc83af | ||
|
|
2e7dbe6c6b | ||
|
|
309ac75284 | ||
|
|
4f5c725dde | ||
|
|
5b6397aaa6 | ||
|
|
2928fe5c43 | ||
|
|
5da4f032c3 | ||
|
|
c5e68ec165 | ||
|
|
78e0b80dc7 | ||
|
|
073d8c2177 | ||
|
|
d194a84ae4 | ||
|
|
4bca6fe672 | ||
|
|
cdf33ff3dc | ||
|
|
08b203fed1 | ||
|
|
736befe90f | ||
|
|
b6c5e9a126 | ||
|
|
4ebe54043a | ||
|
|
e6f5f60f3a | ||
|
|
48facf6343 | ||
|
|
170f2f61f9 | ||
|
|
0244a73c49 | ||
|
|
9089d55342 | ||
|
|
9e0547b98f | ||
|
|
b97db68f0c | ||
|
|
436a6d5c0f | ||
|
|
a64bdbd306 | ||
|
|
ac6aeae915 | ||
|
|
f92f851f11 | ||
|
|
99e21a2235 | ||
|
|
f7d3dc742d | ||
|
|
cf6e215a66 | ||
|
|
e4688f1c5a | ||
|
|
315daf1a10 | ||
|
|
75e81f00e2 | ||
|
|
ec71440f09 | ||
|
|
2a825310ea | ||
|
|
323edb9d53 | ||
|
|
726bab0293 | ||
|
|
b52367e3b2 | ||
|
|
9ff1f6bbde | ||
|
|
97dd680b32 | ||
|
|
8098ca3b66 | ||
|
|
8f63fdb278 | ||
|
|
c5da330cdf | ||
|
|
9e89ec041e | ||
|
|
070bbcfc3d | ||
|
|
cef9cd3cfc | ||
|
|
ed4f4b3954 | ||
|
|
cfb6069b83 | ||
|
|
caacc4580f | ||
|
|
f3b03908f9 | ||
|
|
c6ccf9f2b5 | ||
|
|
5204d6ce45 | ||
|
|
24b5abcc39 | ||
|
|
8ada7fe30b | ||
|
|
d8366115f5 | ||
|
|
e5aad9857d | ||
|
|
75a05c2814 | ||
|
|
64a36170a9 | ||
|
|
871c3fc11e | ||
|
|
6ef1a9150c | ||
|
|
222734b5f5 | ||
|
|
1f08634d62 | ||
|
|
52390120ae | ||
|
|
fb35f06114 | ||
|
|
bfafc6d5fd | ||
|
|
1f07977f09 | ||
|
|
fd23c7bf76 | ||
|
|
1944fdc962 | ||
|
|
12382f064b | ||
|
|
b942c54bea | ||
|
|
0a7dccbad8 | ||
|
|
5f862effaa | ||
|
|
d200cf2e77 | ||
|
|
eb533e04b9 | ||
|
|
58fa8add31 | ||
|
|
34afa3b8a5 | ||
|
|
17ef05672b | ||
|
|
c5fe173e47 | ||
|
|
456ea04683 | ||
|
|
0e5fc9c4e4 | ||
|
|
cf5689371a | ||
|
|
e788b9f959 | ||
|
|
d3d09ff25f | ||
|
|
2c259990da | ||
|
|
e2d60940a2 | ||
|
|
dc786996ef | ||
|
|
cc3ac9b1da | ||
|
|
431faf58ff | ||
|
|
63ae55be2b | ||
|
|
14d6a70fa8 | ||
|
|
1ff6fc6491 | ||
|
|
a376d09be5 | ||
|
|
02d7203b4f | ||
|
|
e65cc8a245 | ||
|
|
dc1eca14f0 | ||
|
|
0b7b2f5a57 | ||
|
|
6cff48112d | ||
|
|
fe0a577c8b | ||
|
|
91e93e6a5a | ||
|
|
a1ef49c26f | ||
|
|
339f4b8c31 | ||
|
|
406b0fdbcc | ||
|
|
349972368c | ||
|
|
4225524b6f | ||
|
|
aac916857d | ||
|
|
25246c6db7 | ||
|
|
800689fc81 | ||
|
|
d9fbead8ca | ||
|
|
496c741513 | ||
|
|
c392710802 | ||
|
|
b0886e2abf | ||
|
|
3d35f01bd1 | ||
|
|
d86662cb80 | ||
|
|
afa3bd2143 | ||
|
|
196cb2dda4 | ||
|
|
fc75080c28 | ||
|
|
f8d41f1f68 | ||
|
|
6ea1bacc73 | ||
|
|
6324270221 | ||
|
|
41afeb744a | ||
|
|
219693d91f | ||
|
|
25c80f314b | ||
|
|
5d505f9139 | ||
|
|
bc39964ece | ||
|
|
abea1196de | ||
|
|
1308f790ad | ||
|
|
095f304d7d | ||
|
|
5a54d90d72 | ||
|
|
003fdd2382 | ||
|
|
5b9b33f32d | ||
|
|
5ee3915c40 | ||
|
|
dcead89507 | ||
|
|
6f2f3ed1ac | ||
|
|
738c8c047e | ||
|
|
d224f5d998 | ||
|
|
f8a9f628ae | ||
|
|
6995b51f2c | ||
|
|
c989ea43f5 | ||
|
|
b0c4c79c49 | ||
|
|
eb4038d626 | ||
|
|
7562a8b662 | ||
|
|
c75a1f08fd | ||
|
|
1085c28612 | ||
|
|
eca9bffb01 | ||
|
|
b28a865436 | ||
|
|
57d682a050 | ||
|
|
8c5f26373b | ||
|
|
87f09131aa | ||
|
|
371b347ee9 | ||
|
|
ad2627b05a | ||
|
|
bb012c3db2 | ||
|
|
387dd67b60 | ||
|
|
b22eb0d65f | ||
|
|
ec46d57816 | ||
|
|
e296d4826f | ||
|
|
3cfe94c5ef | ||
|
|
7e82e12468 | ||
|
|
f81908711b | ||
|
|
2b955a5ae1 | ||
|
|
aeedd36168 | ||
|
|
e57cb713b2 | ||
|
|
a098bf30d4 | ||
|
|
f1692f3274 | ||
|
|
a39dc1b78a | ||
|
|
ead5275d63 | ||
|
|
4e8c21549b | ||
|
|
ed081c8834 | ||
|
|
f99dabbac6 | ||
|
|
707b1d1b79 | ||
|
|
026711e750 | ||
|
|
b9f569f7fb | ||
|
|
0a5f51fd03 | ||
|
|
d20e2ec349 | ||
|
|
f9417e3fcc | ||
|
|
41c352c306 | ||
|
|
1ef0f6beff | ||
|
|
c70eb81e32 | ||
|
|
38681d0a2b | ||
|
|
c5097ae483 | ||
|
|
5bb196dce3 | ||
|
|
cb47de5eca | ||
|
|
56a8e17b21 | ||
|
|
e3b23842dd | ||
|
|
12cb35ef61 | ||
|
|
2fb8839d31 | ||
|
|
6578498e31 | ||
|
|
2e1feb63e4 | ||
|
|
9e626c5fee | ||
|
|
78a89c666b | ||
|
|
6352afb07a | ||
|
|
683d8033f0 | ||
|
|
e2bb8088d4 | ||
|
|
64116e5d7c | ||
|
|
219a6b175b | ||
|
|
2a8b36c761 | ||
|
|
b853671132 | ||
|
|
2fbf560668 | ||
|
|
cd067bca37 | ||
|
|
98d4e186e3 | ||
|
|
8680a08a8d | ||
|
|
3b259b4243 | ||
|
|
25feb9232d | ||
|
|
590bde5e14 | ||
|
|
88dac36c91 | ||
|
|
7842040d9d | ||
|
|
3237c6751a | ||
|
|
7a5ec96d53 | ||
|
|
5ae80d541b | ||
|
|
25ac23ab17 | ||
|
|
a3b65ad481 | ||
|
|
9d2c9df992 | ||
|
|
7ceb8d1ab8 | ||
|
|
a609e52a14 | ||
|
|
39875c90f1 | ||
|
|
3290c6b335 | ||
|
|
0f93515ede | ||
|
|
dfc25d0ca5 | ||
|
|
db0beb6c36 | ||
|
|
7b240d82fd | ||
|
|
704433f3d6 | ||
|
|
8ae7d01d1a | ||
|
|
2bd8ef83d1 | ||
|
|
c108088110 | ||
|
|
cb7715a572 | ||
|
|
2e1e893675 | ||
|
|
3796d7a6a1 | ||
|
|
b08bc02cde | ||
|
|
04e873f78e | ||
|
|
04da9257ef | ||
|
|
cae601a682 | ||
|
|
f2aabeefd5 | ||
|
|
1d288b69e2 | ||
|
|
cac85d2a12 | ||
|
|
381f55b3cb | ||
|
|
04fa85f67f | ||
|
|
bacf6511a6 | ||
|
|
4e01ab59c1 | ||
|
|
a46040a4fa | ||
|
|
b458201874 | ||
|
|
99ea50649a | ||
|
|
9d2e23413e | ||
|
|
4b53cd9c3c | ||
|
|
ee88e0054b | ||
|
|
e77fa72d6d | ||
|
|
2fa9ca1f6d | ||
|
|
a2d1a5258b | ||
|
|
009c00cdc6 | ||
|
|
1a0fbf84f9 | ||
|
|
9ea391e03d | ||
|
|
6bcf4b1112 | ||
|
|
82bd1d98d5 | ||
|
|
de625bfb65 | ||
|
|
c751d42d1a | ||
|
|
198f5f237f | ||
|
|
dc5b27069a | ||
|
|
6a829e0179 | ||
|
|
4085ba309a | ||
|
|
975d677f55 | ||
|
|
21be9a3309 | ||
|
|
7456b9ae17 | ||
|
|
35349643af | ||
|
|
952e3bac2c | ||
|
|
d705f4cbac | ||
|
|
5d94221c61 | ||
|
|
f124732431 | ||
|
|
d944219b28 | ||
|
|
86961d0f44 | ||
|
|
3dde669ee8 | ||
|
|
ccdeb915fa | ||
|
|
5345b08d24 | ||
|
|
54d27a390b | ||
|
|
ba44dca34a | ||
|
|
61d91579df | ||
|
|
ea2e2def55 | ||
|
|
a7a06a483e | ||
|
|
388b601503 | ||
|
|
2b8b76a527 | ||
|
|
cbddbdb296 | ||
|
|
06701786c4 | ||
|
|
1c45285fe3 | ||
|
|
18c0cfa6f5 | ||
|
|
32ae3a52b8 | ||
|
|
e198b6945c | ||
|
|
f1f73eff04 | ||
|
|
9adb232d99 | ||
|
|
63bffbc460 | ||
|
|
3e128abb73 | ||
|
|
820fb3b82b | ||
|
|
03263bb5b6 | ||
|
|
b0a1e2988b | ||
|
|
571592a5a4 | ||
|
|
d1da48ff0f | ||
|
|
6c214ed386 | ||
|
|
b29f7b9acb | ||
|
|
c2f516067f | ||
|
|
58cae1d8de | ||
|
|
a9d4d9ad85 | ||
|
|
e043dabcb8 | ||
|
|
3de3fb53bd | ||
|
|
d6d85ade8e | ||
|
|
1278e8cebc | ||
|
|
de0ec9b33c | ||
|
|
3b99827540 | ||
|
|
635c909aab | ||
|
|
f894da13b0 | ||
|
|
c27633dff4 | ||
|
|
c1a02d6556 | ||
|
|
ec43dd067c | ||
|
|
f3d391e3f2 | ||
|
|
851f490168 | ||
|
|
07f99c06ea | ||
|
|
d0643250f7 | ||
|
|
f56b00718b | ||
|
|
af555bd879 | ||
|
|
b61e1fd69f | ||
|
|
c8ff67ab75 | ||
|
|
f72942bff1 | ||
|
|
36371357cd | ||
|
|
750bd9a88b | ||
|
|
5660b1e225 | ||
|
|
acfded9687 | ||
|
|
a9f4c208a0 | ||
|
|
bca7a6baa9 | ||
|
|
3cb3d8f981 | ||
|
|
9904da9a48 | ||
|
|
8d9328fbee | ||
|
|
eaa5d071ef | ||
|
|
d86f0a1686 | ||
|
|
f0566f3790 | ||
|
|
f5f790863d | ||
|
|
10386edea5 | ||
|
|
4ccc3d9fb3 | ||
|
|
77fa7ce977 | ||
|
|
2c8ab72269 | ||
|
|
df179ed28d | ||
|
|
3ec0e2f132 | ||
|
|
477ac313ab | ||
|
|
72e559458f | ||
|
|
21f0b2bd2a | ||
|
|
cc2936cfdf | ||
|
|
d20e664ea8 | ||
|
|
fee7683b86 | ||
|
|
d7e7c2b17f | ||
|
|
1afa41477d | ||
|
|
217848ca52 | ||
|
|
486b6b9096 | ||
|
|
18c49285a8 | ||
|
|
fb74f5576d | ||
|
|
4aa2b093ff | ||
|
|
446065b88c | ||
|
|
594aaec7bb | ||
|
|
07994f50f3 | ||
|
|
1c6e166af5 | ||
|
|
0b9a2f6be6 | ||
|
|
0c73140b07 | ||
|
|
02cbd24165 | ||
|
|
f4be3782a2 | ||
|
|
bb9876bd6e | ||
|
|
2bf6f28152 | ||
|
|
a7dedb3a13 | ||
|
|
4b61a4d3de | ||
|
|
285a36f9de | ||
|
|
5a1a2616aa | ||
|
|
0d1804b2a0 | ||
|
|
0b9530efd7 | ||
|
|
6bbd92368f | ||
|
|
7b8eb3e09c | ||
|
|
774b2f99f2 | ||
|
|
a7395118af | ||
|
|
3897a88082 | ||
|
|
0a61aad499 | ||
|
|
5abecadfd3 | ||
|
|
fff59271af | ||
|
|
d5a0dd39a1 | ||
|
|
3ac9858726 | ||
|
|
92fe82a208 | ||
|
|
4ff7cf2bcc | ||
|
|
f6a6ca8a22 | ||
|
|
c9615a201c | ||
|
|
921b474919 | ||
|
|
06960704c4 | ||
|
|
f8b738e6c2 | ||
|
|
b305020c1d | ||
|
|
782417b1fa | ||
|
|
38b14fc912 | ||
|
|
ac9e0b458d | ||
|
|
00d9baa605 | ||
|
|
356d0520ae | ||
|
|
a69ee76705 | ||
|
|
0e9d973715 | ||
|
|
7880d37d73 | ||
|
|
c657186920 | ||
|
|
c61414e11b |
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -12,7 +12,7 @@
|
||||
url = https://github.com/electron/chromium-breakpad.git
|
||||
[submodule "vendor/native_mate"]
|
||||
path = vendor/native_mate
|
||||
url = https://github.com/zcbenz/native-mate.git
|
||||
url = https://github.com/electron/native-mate.git
|
||||
[submodule "vendor/crashpad"]
|
||||
path = vendor/crashpad
|
||||
url = https://github.com/electron/crashpad.git
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2013-2016 GitHub Inc.
|
||||
Copyright (c) 2013-2017 GitHub Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
@@ -22,7 +22,7 @@ behavior to electron@github.com.
|
||||
## Downloads
|
||||
|
||||
To install prebuilt Electron binaries, use
|
||||
[`npm`](https://docs.npmjs.com/) (or [`yarn`](https://yarnpkg.com/en/docs/managing-dependencies)):
|
||||
[`npm`](https://docs.npmjs.com/):
|
||||
|
||||
```sh
|
||||
# Install as a development dependency
|
||||
@@ -73,7 +73,7 @@ forums
|
||||
- [`Atom`](http://atom-slack.herokuapp.com/) channel on Slack
|
||||
- [`electron-br`](https://electron-br.slack.com) *(Brazilian Portuguese)*
|
||||
- [`electron-kr`](http://www.meetup.com/electron-kr/) *(Korean)*
|
||||
- [`electron-jp`](https://electron-jp-slackin.herokuapp.com/) *(Japanese)*
|
||||
- [`electron-jp`](https://electron-jp.slack.com) *(Japanese)*
|
||||
- [`electron-tr`](http://www.meetup.com/Electron-JS-Istanbul/) *(Turkish)*
|
||||
- [`electron-id`](https://electron-id.slack.com) *(Indonesia)*
|
||||
|
||||
|
||||
@@ -197,11 +197,20 @@ void AtomContentClient::AddServiceWorkerSchemes(
|
||||
std::vector<std::string> schemes;
|
||||
ConvertStringWithSeparatorToVector(&schemes, ",",
|
||||
switches::kRegisterServiceWorkerSchemes);
|
||||
if (!schemes.empty()) {
|
||||
for (const std::string& scheme : schemes)
|
||||
service_worker_schemes->insert(scheme);
|
||||
}
|
||||
for (const std::string& scheme : schemes)
|
||||
service_worker_schemes->insert(scheme);
|
||||
|
||||
service_worker_schemes->insert(url::kFileScheme);
|
||||
}
|
||||
|
||||
void AtomContentClient::AddSecureSchemesAndOrigins(
|
||||
std::set<std::string>* secure_schemes,
|
||||
std::set<GURL>* secure_origins) {
|
||||
std::vector<std::string> schemes;
|
||||
ConvertStringWithSeparatorToVector(&schemes, ",", switches::kSecureSchemes);
|
||||
for (const std::string& scheme : schemes)
|
||||
secure_schemes->insert(scheme);
|
||||
}
|
||||
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -31,6 +31,9 @@ class AtomContentClient : public brightray::ContentClient {
|
||||
std::vector<content::PepperPluginInfo>* plugins) override;
|
||||
void AddServiceWorkerSchemes(
|
||||
std::set<std::string>* service_worker_schemes) override;
|
||||
void AddSecureSchemesAndOrigins(
|
||||
std::set<std::string>* secure_schemes,
|
||||
std::set<GURL>* secure_origins) override;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomContentClient);
|
||||
|
||||
@@ -378,9 +378,21 @@ void OnClientCertificateSelected(
|
||||
v8::Isolate* isolate,
|
||||
std::shared_ptr<content::ClientCertificateDelegate> delegate,
|
||||
mate::Arguments* args) {
|
||||
if (args->Length() == 2) {
|
||||
delegate->ContinueWithCertificate(nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> val;
|
||||
args->GetNext(&val);
|
||||
if (val->IsNull()) {
|
||||
delegate->ContinueWithCertificate(nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
mate::Dictionary cert_data;
|
||||
if (!args->GetNext(&cert_data)) {
|
||||
args->ThrowError();
|
||||
if (!mate::ConvertFromV8(isolate, val, &cert_data)) {
|
||||
args->ThrowError("Must pass valid certificate object.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -146,6 +146,10 @@ const GURL& DownloadItem::GetURL() const {
|
||||
return download_item_->GetURL();
|
||||
}
|
||||
|
||||
const std::vector<GURL>& DownloadItem::GetURLChain() const {
|
||||
return download_item_->GetUrlChain();
|
||||
}
|
||||
|
||||
content::DownloadItem::DownloadState DownloadItem::GetState() const {
|
||||
return download_item_->GetState();
|
||||
}
|
||||
@@ -162,6 +166,18 @@ base::FilePath DownloadItem::GetSavePath() const {
|
||||
return save_path_;
|
||||
}
|
||||
|
||||
std::string DownloadItem::GetLastModifiedTime() const {
|
||||
return download_item_->GetLastModifiedTime();
|
||||
}
|
||||
|
||||
std::string DownloadItem::GetETag() const {
|
||||
return download_item_->GetETag();
|
||||
}
|
||||
|
||||
double DownloadItem::GetStartTime() const {
|
||||
return download_item_->GetStartTime().ToDoubleT();
|
||||
}
|
||||
|
||||
// static
|
||||
void DownloadItem::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
@@ -180,10 +196,14 @@ void DownloadItem::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("getFilename", &DownloadItem::GetFilename)
|
||||
.SetMethod("getContentDisposition", &DownloadItem::GetContentDisposition)
|
||||
.SetMethod("getURL", &DownloadItem::GetURL)
|
||||
.SetMethod("getURLChain", &DownloadItem::GetURLChain)
|
||||
.SetMethod("getState", &DownloadItem::GetState)
|
||||
.SetMethod("isDone", &DownloadItem::IsDone)
|
||||
.SetMethod("setSavePath", &DownloadItem::SetSavePath)
|
||||
.SetMethod("getSavePath", &DownloadItem::GetSavePath);
|
||||
.SetMethod("getSavePath", &DownloadItem::GetSavePath)
|
||||
.SetMethod("getLastModifiedTime", &DownloadItem::GetLastModifiedTime)
|
||||
.SetMethod("getETag", &DownloadItem::GetETag)
|
||||
.SetMethod("getStartTime", &DownloadItem::GetStartTime);
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#define ATOM_BROWSER_API_ATOM_API_DOWNLOAD_ITEM_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/api/trackable_object.h"
|
||||
#include "base/files/file_path.h"
|
||||
@@ -38,10 +39,14 @@ class DownloadItem : public mate::TrackableObject<DownloadItem>,
|
||||
std::string GetFilename() const;
|
||||
std::string GetContentDisposition() const;
|
||||
const GURL& GetURL() const;
|
||||
const std::vector<GURL>& GetURLChain() const;
|
||||
content::DownloadItem::DownloadState GetState() const;
|
||||
bool IsDone() const;
|
||||
void SetSavePath(const base::FilePath& path);
|
||||
base::FilePath GetSavePath() const;
|
||||
std::string GetLastModifiedTime() const;
|
||||
std::string GetETag() const;
|
||||
double GetStartTime() const;
|
||||
|
||||
protected:
|
||||
DownloadItem(v8::Isolate* isolate, content::DownloadItem* download_item);
|
||||
|
||||
@@ -46,7 +46,8 @@ std::vector<std::string> GetStandardSchemes() {
|
||||
return g_standard_schemes;
|
||||
}
|
||||
|
||||
void RegisterStandardSchemes(const std::vector<std::string>& schemes) {
|
||||
void RegisterStandardSchemes(const std::vector<std::string>& schemes,
|
||||
mate::Arguments* args) {
|
||||
g_standard_schemes = schemes;
|
||||
|
||||
auto* policy = content::ChildProcessSecurityPolicy::GetInstance();
|
||||
@@ -55,8 +56,17 @@ void RegisterStandardSchemes(const std::vector<std::string>& schemes) {
|
||||
policy->RegisterWebSafeScheme(scheme);
|
||||
}
|
||||
|
||||
// add switches to register as standard
|
||||
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
||||
atom::switches::kStandardSchemes, base::JoinString(schemes, ","));
|
||||
|
||||
mate::Dictionary opts;
|
||||
bool secure = false;
|
||||
if (args->GetNext(&opts) && opts.Get("secure", &secure) && secure) {
|
||||
// add switches to register as secure
|
||||
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
||||
atom::switches::kSecureSchemes, base::JoinString(schemes, ","));
|
||||
}
|
||||
}
|
||||
|
||||
Protocol::Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
||||
@@ -220,7 +230,7 @@ void RegisterStandardSchemes(
|
||||
return;
|
||||
}
|
||||
|
||||
atom::api::RegisterStandardSchemes(schemes);
|
||||
atom::api::RegisterStandardSchemes(schemes, args);
|
||||
}
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||
|
||||
@@ -29,7 +29,8 @@ namespace atom {
|
||||
namespace api {
|
||||
|
||||
std::vector<std::string> GetStandardSchemes();
|
||||
void RegisterStandardSchemes(const std::vector<std::string>& schemes);
|
||||
void RegisterStandardSchemes(const std::vector<std::string>& schemes,
|
||||
mate::Arguments* args);
|
||||
|
||||
class Protocol : public mate::TrackableObject<Protocol> {
|
||||
public:
|
||||
|
||||
@@ -29,11 +29,13 @@
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "brightray/browser/media/media_device_id_salt.h"
|
||||
#include "brightray/browser/net/devtools_network_conditions.h"
|
||||
#include "brightray/browser/net/devtools_network_controller_handle.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/download_manager_delegate.h"
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
@@ -61,6 +63,15 @@ struct ClearStorageDataOptions {
|
||||
uint32_t quota_types = StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL;
|
||||
};
|
||||
|
||||
struct ClearAuthCacheOptions {
|
||||
std::string type;
|
||||
GURL origin;
|
||||
std::string realm;
|
||||
base::string16 username;
|
||||
base::string16 password;
|
||||
net::HttpAuth::Scheme auth_scheme;
|
||||
};
|
||||
|
||||
uint32_t GetStorageMask(const std::vector<std::string>& storage_types) {
|
||||
uint32_t storage_mask = 0;
|
||||
for (const auto& it : storage_types) {
|
||||
@@ -99,6 +110,18 @@ uint32_t GetQuotaMask(const std::vector<std::string>& quota_types) {
|
||||
return quota_mask;
|
||||
}
|
||||
|
||||
net::HttpAuth::Scheme GetAuthSchemeFromString(const std::string& scheme) {
|
||||
if (scheme == "basic")
|
||||
return net::HttpAuth::AUTH_SCHEME_BASIC;
|
||||
if (scheme == "digest")
|
||||
return net::HttpAuth::AUTH_SCHEME_DIGEST;
|
||||
if (scheme == "ntlm")
|
||||
return net::HttpAuth::AUTH_SCHEME_NTLM;
|
||||
if (scheme == "negotiate")
|
||||
return net::HttpAuth::AUTH_SCHEME_NEGOTIATE;
|
||||
return net::HttpAuth::AUTH_SCHEME_MAX;
|
||||
}
|
||||
|
||||
void SetUserAgentInIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||
const std::string& accept_lang,
|
||||
const std::string& user_agent) {
|
||||
@@ -130,7 +153,27 @@ struct Converter<ClearStorageDataOptions> {
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
template <>
|
||||
struct Converter<ClearAuthCacheOptions> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
ClearAuthCacheOptions* out) {
|
||||
mate::Dictionary options;
|
||||
if (!ConvertFromV8(isolate, val, &options))
|
||||
return false;
|
||||
options.Get("type", &out->type);
|
||||
options.Get("origin", &out->origin);
|
||||
options.Get("realm", &out->realm);
|
||||
options.Get("username", &out->username);
|
||||
options.Get("password", &out->password);
|
||||
std::string scheme;
|
||||
if (options.Get("scheme", &scheme))
|
||||
out->auth_scheme = GetAuthSchemeFromString(scheme);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<net::ProxyConfig> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
@@ -313,6 +356,33 @@ void ClearHostResolverCacheInIO(
|
||||
}
|
||||
}
|
||||
|
||||
void ClearAuthCacheInIO(
|
||||
const scoped_refptr<net::URLRequestContextGetter>& context_getter,
|
||||
const ClearAuthCacheOptions& options,
|
||||
const base::Closure& callback) {
|
||||
auto request_context = context_getter->GetURLRequestContext();
|
||||
auto network_session =
|
||||
request_context->http_transaction_factory()->GetSession();
|
||||
if (network_session) {
|
||||
if (options.type == "password") {
|
||||
auto auth_cache = network_session->http_auth_cache();
|
||||
if (!options.origin.is_empty()) {
|
||||
auth_cache->Remove(
|
||||
options.origin, options.realm, options.auth_scheme,
|
||||
net::AuthCredentials(options.username, options.password));
|
||||
} else {
|
||||
auth_cache->Clear();
|
||||
}
|
||||
} else if (options.type == "clientCertificate") {
|
||||
auto client_auth_cache = network_session->ssl_client_auth_cache();
|
||||
client_auth_cache->Remove(net::HostPortPair::FromURL(options.origin));
|
||||
}
|
||||
network_session->CloseAllConnections();
|
||||
}
|
||||
if (!callback.is_null())
|
||||
RunCallbackInUI(callback);
|
||||
}
|
||||
|
||||
void AllowNTLMCredentialsForDomainsInIO(
|
||||
const scoped_refptr<net::URLRequestContextGetter>& context_getter,
|
||||
const std::string& domains) {
|
||||
@@ -331,6 +401,25 @@ void OnClearStorageDataDone(const base::Closure& callback) {
|
||||
callback.Run();
|
||||
}
|
||||
|
||||
void DownloadIdCallback(content::DownloadManager* download_manager,
|
||||
const base::FilePath& path,
|
||||
const std::vector<GURL>& url_chain,
|
||||
const std::string& mime_type,
|
||||
int64_t offset,
|
||||
int64_t length,
|
||||
const std::string& last_modified,
|
||||
const std::string& etag,
|
||||
const base::Time& start_time,
|
||||
uint32_t id) {
|
||||
download_manager->CreateDownloadItem(
|
||||
base::GenerateGUID(), id, path, path, url_chain, GURL(), GURL(), GURL(),
|
||||
GURL(), mime_type, mime_type, start_time, base::Time(), etag,
|
||||
last_modified, offset, length, std::string(),
|
||||
content::DownloadItem::INTERRUPTED,
|
||||
content::DownloadDangerType::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
|
||||
content::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT, false);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Session::Session(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
||||
@@ -357,10 +446,10 @@ void Session::OnDownloadCreated(content::DownloadManager* manager,
|
||||
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
bool prevent_default = Emit(
|
||||
"will-download",
|
||||
DownloadItem::Create(isolate(), item),
|
||||
item->GetWebContents());
|
||||
auto handle = DownloadItem::Create(isolate(), item);
|
||||
if (item->GetState() == content::DownloadItem::INTERRUPTED)
|
||||
handle->SetSavePath(item->GetTargetFilePath());
|
||||
bool prevent_default = Emit("will-download", handle, item->GetWebContents());
|
||||
if (prevent_default) {
|
||||
item->Cancel(true);
|
||||
item->Remove();
|
||||
@@ -389,6 +478,11 @@ void Session::ClearStorageData(mate::Arguments* args) {
|
||||
|
||||
auto storage_partition =
|
||||
content::BrowserContext::GetStoragePartition(browser_context(), nullptr);
|
||||
if (options.storage_types & StoragePartition::REMOVE_DATA_MASK_COOKIES) {
|
||||
// Reset media device id salt when cookies are cleared.
|
||||
// https://w3c.github.io/mediacapture-main/#dom-mediadeviceinfo-deviceid
|
||||
brightray::MediaDeviceIDSalt::Reset(browser_context()->prefs());
|
||||
}
|
||||
storage_partition->ClearData(
|
||||
options.storage_types, options.quota_types, options.origin,
|
||||
content::StoragePartition::OriginMatcherFunction(),
|
||||
@@ -481,6 +575,22 @@ void Session::ClearHostResolverCache(mate::Arguments* args) {
|
||||
callback));
|
||||
}
|
||||
|
||||
void Session::ClearAuthCache(mate::Arguments* args) {
|
||||
ClearAuthCacheOptions options;
|
||||
if (!args->GetNext(&options)) {
|
||||
args->ThrowError("Must specify options object");
|
||||
return;
|
||||
}
|
||||
base::Closure callback;
|
||||
args->GetNext(&callback);
|
||||
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(&ClearAuthCacheInIO,
|
||||
make_scoped_refptr(browser_context_->GetRequestContext()),
|
||||
options, callback));
|
||||
}
|
||||
|
||||
void Session::AllowNTLMCredentialsForDomains(const std::string& domains) {
|
||||
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(&AllowNTLMCredentialsForDomainsInIO,
|
||||
@@ -520,6 +630,37 @@ void Session::GetBlobData(
|
||||
callback));
|
||||
}
|
||||
|
||||
void Session::CreateInterruptedDownload(const mate::Dictionary& options) {
|
||||
int64_t offset = 0, length = 0;
|
||||
double start_time = 0.0;
|
||||
std::string mime_type, last_modified, etag;
|
||||
base::FilePath path;
|
||||
std::vector<GURL> url_chain;
|
||||
options.Get("path", &path);
|
||||
options.Get("urlChain", &url_chain);
|
||||
options.Get("mimeType", &mime_type);
|
||||
options.Get("offset", &offset);
|
||||
options.Get("length", &length);
|
||||
options.Get("lastModified", &last_modified);
|
||||
options.Get("eTag", &etag);
|
||||
options.Get("startTime", &start_time);
|
||||
if (path.empty() || url_chain.empty() || length == 0) {
|
||||
isolate()->ThrowException(v8::Exception::Error(mate::StringToV8(
|
||||
isolate(), "Must pass non-empty path, urlChain and length.")));
|
||||
return;
|
||||
}
|
||||
if (offset >= length) {
|
||||
isolate()->ThrowException(v8::Exception::Error(mate::StringToV8(
|
||||
isolate(), "Must pass an offset value less than length.")));
|
||||
return;
|
||||
}
|
||||
auto download_manager =
|
||||
content::BrowserContext::GetDownloadManager(browser_context());
|
||||
download_manager->GetDelegate()->GetNextId(base::Bind(
|
||||
&DownloadIdCallback, download_manager, path, url_chain, mime_type, offset,
|
||||
length, last_modified, etag, base::Time::FromDoubleT(start_time)));
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> Session::Cookies(v8::Isolate* isolate) {
|
||||
if (cookies_.IsEmpty()) {
|
||||
auto handle = Cookies::Create(isolate, browser_context());
|
||||
@@ -598,11 +739,14 @@ void Session::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("setPermissionRequestHandler",
|
||||
&Session::SetPermissionRequestHandler)
|
||||
.SetMethod("clearHostResolverCache", &Session::ClearHostResolverCache)
|
||||
.SetMethod("clearAuthCache", &Session::ClearAuthCache)
|
||||
.SetMethod("allowNTLMCredentialsForDomains",
|
||||
&Session::AllowNTLMCredentialsForDomains)
|
||||
.SetMethod("setUserAgent", &Session::SetUserAgent)
|
||||
.SetMethod("getUserAgent", &Session::GetUserAgent)
|
||||
.SetMethod("getBlobData", &Session::GetBlobData)
|
||||
.SetMethod("createInterruptedDownload",
|
||||
&Session::CreateInterruptedDownload)
|
||||
.SetProperty("cookies", &Session::Cookies)
|
||||
.SetProperty("protocol", &Session::Protocol)
|
||||
.SetProperty("webRequest", &Session::WebRequest);
|
||||
|
||||
@@ -74,11 +74,13 @@ class Session: public mate::TrackableObject<Session>,
|
||||
void SetPermissionRequestHandler(v8::Local<v8::Value> val,
|
||||
mate::Arguments* args);
|
||||
void ClearHostResolverCache(mate::Arguments* args);
|
||||
void ClearAuthCache(mate::Arguments* args);
|
||||
void AllowNTLMCredentialsForDomains(const std::string& domains);
|
||||
void SetUserAgent(const std::string& user_agent, mate::Arguments* args);
|
||||
std::string GetUserAgent();
|
||||
void GetBlobData(const std::string& uuid,
|
||||
const AtomBlobReader::CompletionCallback& callback);
|
||||
void CreateInterruptedDownload(const mate::Dictionary& options);
|
||||
v8::Local<v8::Value> Cookies(v8::Isolate* isolate);
|
||||
v8::Local<v8::Value> Protocol(v8::Isolate* isolate);
|
||||
v8::Local<v8::Value> WebRequest(v8::Isolate* isolate);
|
||||
|
||||
@@ -67,6 +67,7 @@ void SystemPreferences::BuildPrototype(
|
||||
.SetMethod("unsubscribeLocalNotification",
|
||||
&SystemPreferences::UnsubscribeLocalNotification)
|
||||
.SetMethod("getUserDefault", &SystemPreferences::GetUserDefault)
|
||||
.SetMethod("setUserDefault", &SystemPreferences::SetUserDefault)
|
||||
.SetMethod("isSwipeTrackingFromScrollEventsEnabled",
|
||||
&SystemPreferences::IsSwipeTrackingFromScrollEventsEnabled)
|
||||
#endif
|
||||
|
||||
@@ -67,6 +67,9 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||
void UnsubscribeLocalNotification(int request_id);
|
||||
v8::Local<v8::Value> GetUserDefault(const std::string& name,
|
||||
const std::string& type);
|
||||
void SetUserDefault(const std::string& name,
|
||||
const std::string& type,
|
||||
mate::Arguments* args);
|
||||
bool IsSwipeTrackingFromScrollEventsEnabled();
|
||||
#endif
|
||||
bool IsDarkMode();
|
||||
|
||||
@@ -144,6 +144,91 @@ v8::Local<v8::Value> SystemPreferences::GetUserDefault(
|
||||
}
|
||||
}
|
||||
|
||||
void SystemPreferences::SetUserDefault(const std::string& name,
|
||||
const std::string& type,
|
||||
mate::Arguments* args) {
|
||||
const auto throwConversionError = [&] {
|
||||
args->ThrowError("Unable to convert value to: " + type);
|
||||
};
|
||||
|
||||
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
|
||||
NSString* key = base::SysUTF8ToNSString(name);
|
||||
if (type == "string") {
|
||||
std::string value;
|
||||
if (!args->GetNext(&value)) {
|
||||
throwConversionError();
|
||||
return;
|
||||
}
|
||||
|
||||
[defaults setObject:base::SysUTF8ToNSString(value) forKey:key];
|
||||
} else if (type == "boolean") {
|
||||
bool value;
|
||||
if (!args->GetNext(&value)) {
|
||||
throwConversionError();
|
||||
return;
|
||||
}
|
||||
|
||||
[defaults setBool:value forKey:key];
|
||||
} else if (type == "float") {
|
||||
float value;
|
||||
if (!args->GetNext(&value)) {
|
||||
throwConversionError();
|
||||
return;
|
||||
}
|
||||
|
||||
[defaults setFloat:value forKey:key];
|
||||
} else if (type == "integer") {
|
||||
int value;
|
||||
if (!args->GetNext(&value)) {
|
||||
throwConversionError();
|
||||
return;
|
||||
}
|
||||
|
||||
[defaults setInteger:value forKey:key];
|
||||
} else if (type == "double") {
|
||||
double value;
|
||||
if (!args->GetNext(&value)) {
|
||||
throwConversionError();
|
||||
return;
|
||||
}
|
||||
|
||||
[defaults setDouble:value forKey:key];
|
||||
} else if (type == "url") {
|
||||
GURL value;
|
||||
if (!args->GetNext(&value)) {
|
||||
throwConversionError();
|
||||
return;
|
||||
}
|
||||
|
||||
if (NSURL* url = net::NSURLWithGURL(value)) {
|
||||
[defaults setURL:url forKey:key];
|
||||
}
|
||||
} else if (type == "array") {
|
||||
base::ListValue value;
|
||||
if (!args->GetNext(&value)) {
|
||||
throwConversionError();
|
||||
return;
|
||||
}
|
||||
|
||||
if (NSArray* array = ListValueToNSArray(value)) {
|
||||
[defaults setObject:array forKey:key];
|
||||
}
|
||||
} else if (type == "dictionary") {
|
||||
base::DictionaryValue value;
|
||||
if (!args->GetNext(&value)) {
|
||||
throwConversionError();
|
||||
return;
|
||||
}
|
||||
|
||||
if (NSDictionary* dict = DictionaryValueToNSDictionary(value)) {
|
||||
[defaults setObject:dict forKey:key];
|
||||
}
|
||||
} else {
|
||||
args->ThrowError("Invalid type: " + type);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool SystemPreferences::IsDarkMode() {
|
||||
NSString* mode = [[NSUserDefaults standardUserDefaults]
|
||||
stringForKey:@"AppleInterfaceStyle"];
|
||||
|
||||
@@ -176,6 +176,7 @@ void URLRequest::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("setExtraHeader", &URLRequest::SetExtraHeader)
|
||||
.SetMethod("removeExtraHeader", &URLRequest::RemoveExtraHeader)
|
||||
.SetMethod("setChunkedUpload", &URLRequest::SetChunkedUpload)
|
||||
.SetMethod("_setLoadFlags", &URLRequest::SetLoadFlags)
|
||||
.SetProperty("notStarted", &URLRequest::NotStarted)
|
||||
.SetProperty("finished", &URLRequest::Finished)
|
||||
// Response APi
|
||||
@@ -292,6 +293,18 @@ void URLRequest::SetChunkedUpload(bool is_chunked_upload) {
|
||||
}
|
||||
}
|
||||
|
||||
void URLRequest::SetLoadFlags(int flags) {
|
||||
// State must be equal to not started.
|
||||
if (!request_state_.NotStarted()) {
|
||||
// Cannot change load flags after start.
|
||||
return;
|
||||
}
|
||||
DCHECK(atom_request_);
|
||||
if (atom_request_) {
|
||||
atom_request_->SetLoadFlags(flags);
|
||||
}
|
||||
}
|
||||
|
||||
void URLRequest::OnAuthenticationRequired(
|
||||
scoped_refptr<const net::AuthChallengeInfo> auth_info) {
|
||||
if (request_state_.Canceled() || request_state_.Closed()) {
|
||||
|
||||
@@ -173,6 +173,7 @@ class URLRequest : public mate::EventEmitter<URLRequest> {
|
||||
bool SetExtraHeader(const std::string& name, const std::string& value);
|
||||
void RemoveExtraHeader(const std::string& name);
|
||||
void SetChunkedUpload(bool is_chunked_upload);
|
||||
void SetLoadFlags(int flags);
|
||||
|
||||
int StatusCode() const;
|
||||
std::string StatusMessage() const;
|
||||
|
||||
@@ -419,9 +419,11 @@ void WebContents::AddNewContents(content::WebContents* source,
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
auto api_web_contents = CreateFrom(isolate(), new_contents);
|
||||
Emit("-add-new-contents", api_web_contents, disposition, user_gesture,
|
||||
if (Emit("-add-new-contents", api_web_contents, disposition, user_gesture,
|
||||
initial_rect.x(), initial_rect.y(), initial_rect.width(),
|
||||
initial_rect.height());
|
||||
initial_rect.height())) {
|
||||
api_web_contents->DestroyWebContents();
|
||||
}
|
||||
}
|
||||
|
||||
content::WebContents* WebContents::OpenURLFromTab(
|
||||
@@ -439,6 +441,11 @@ content::WebContents* WebContents::OpenURLFromTab(
|
||||
if (Emit("will-navigate", params.url))
|
||||
return nullptr;
|
||||
|
||||
// Don't load the URL if the web contents was marked as destroyed from a
|
||||
// will-navigate event listener
|
||||
if (IsDestroyed())
|
||||
return nullptr;
|
||||
|
||||
return CommonWebContentsDelegate::OpenURLFromTab(source, params);
|
||||
}
|
||||
|
||||
@@ -488,6 +495,17 @@ void WebContents::HandleKeyboardEvent(
|
||||
}
|
||||
}
|
||||
|
||||
bool WebContents::PreHandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event,
|
||||
bool* is_keyboard_shortcut) {
|
||||
if (event.type == blink::WebInputEvent::Type::RawKeyDown
|
||||
|| event.type == blink::WebInputEvent::Type::KeyUp)
|
||||
return Emit("before-input-event", event);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void WebContents::EnterFullscreenModeForTab(content::WebContents* source,
|
||||
const GURL& origin) {
|
||||
auto permission_helper =
|
||||
@@ -597,6 +615,14 @@ void WebContents::BeforeUnloadFired(const base::TimeTicks& proceed_time) {
|
||||
// there are two virtual functions named BeforeUnloadFired.
|
||||
}
|
||||
|
||||
void WebContents::RenderViewCreated(content::RenderViewHost* render_view_host) {
|
||||
const auto impl = content::RenderWidgetHostImpl::FromID(
|
||||
render_view_host->GetProcess()->GetID(),
|
||||
render_view_host->GetRoutingID());
|
||||
if (impl)
|
||||
impl->disable_hidden_ = !background_throttling_;
|
||||
}
|
||||
|
||||
void WebContents::RenderViewDeleted(content::RenderViewHost* render_view_host) {
|
||||
Emit("render-view-deleted", render_view_host->GetProcess()->GetID());
|
||||
}
|
||||
@@ -881,11 +907,6 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
|
||||
} else {
|
||||
view->SetBackgroundColor(SK_ColorTRANSPARENT);
|
||||
}
|
||||
|
||||
// For the same reason we can only disable hidden here.
|
||||
const auto host = static_cast<content::RenderWidgetHostImpl*>(
|
||||
view->GetRenderWidgetHost());
|
||||
host->disable_hidden_ = !background_throttling_;
|
||||
}
|
||||
|
||||
void WebContents::DownloadURL(const GURL& url) {
|
||||
|
||||
@@ -244,6 +244,9 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
void HandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) override;
|
||||
bool PreHandleKeyboardEvent(content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event,
|
||||
bool* is_keyboard_shortcut) override;
|
||||
void EnterFullscreenModeForTab(content::WebContents* source,
|
||||
const GURL& origin) override;
|
||||
void ExitFullscreenModeForTab(content::WebContents* source) override;
|
||||
@@ -275,6 +278,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
|
||||
// content::WebContentsObserver:
|
||||
void BeforeUnloadFired(const base::TimeTicks& proceed_time) override;
|
||||
void RenderViewCreated(content::RenderViewHost*) override;
|
||||
void RenderViewDeleted(content::RenderViewHost*) override;
|
||||
void RenderProcessGone(base::TerminationStatus status) override;
|
||||
void DocumentLoadedInFrame(
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||
#include "atom/common/native_mate_converters/image_converter.h"
|
||||
@@ -28,6 +29,7 @@
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "atom/browser/ui/win/taskbar_host.h"
|
||||
#include "ui/base/win/shell.h"
|
||||
#endif
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
@@ -88,6 +90,13 @@ Window::Window(v8::Isolate* isolate, v8::Local<v8::Object> wrapper,
|
||||
if (options.Get("transparent", &transparent))
|
||||
web_preferences.Set("transparent", transparent);
|
||||
|
||||
// Offscreen windows are always created frameless.
|
||||
bool offscreen;
|
||||
if (web_preferences.Get("offscreen", &offscreen) && offscreen) {
|
||||
auto window_options = const_cast<mate::Dictionary&>(options);
|
||||
window_options.Set(options::kFrame, false);
|
||||
}
|
||||
|
||||
// Creates the WebContents used by BrowserWindow.
|
||||
web_contents = WebContents::Create(isolate, web_preferences);
|
||||
}
|
||||
@@ -708,6 +717,25 @@ bool Window::SetThumbnailToolTip(const std::string& tooltip) {
|
||||
return window->taskbar_host().SetThumbnailToolTip(
|
||||
window_->GetAcceleratedWidget(), tooltip);
|
||||
}
|
||||
|
||||
void Window::SetAppDetails(const mate::Dictionary& options) {
|
||||
base::string16 app_id;
|
||||
base::FilePath app_icon_path;
|
||||
int app_icon_index = 0;
|
||||
base::string16 relaunch_command;
|
||||
base::string16 relaunch_display_name;
|
||||
|
||||
options.Get("appId", &app_id);
|
||||
options.Get("appIconPath", &app_icon_path);
|
||||
options.Get("appIconIndex", &app_icon_index);
|
||||
options.Get("relaunchCommand", &relaunch_command);
|
||||
options.Get("relaunchDisplayName", &relaunch_display_name);
|
||||
|
||||
ui::win::SetAppDetailsForWindow(
|
||||
app_id, app_icon_path, app_icon_index,
|
||||
relaunch_command, relaunch_display_name,
|
||||
window_->GetAcceleratedWidget());
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
@@ -736,6 +764,10 @@ void Window::PreviewFile(const std::string& path, mate::Arguments* args) {
|
||||
window_->PreviewFile(path, display_name);
|
||||
}
|
||||
|
||||
void Window::CloseFilePreview() {
|
||||
window_->CloseFilePreview();
|
||||
}
|
||||
|
||||
void Window::SetParentWindow(v8::Local<v8::Value> value,
|
||||
mate::Arguments* args) {
|
||||
if (IsModal()) {
|
||||
@@ -786,6 +818,10 @@ bool Window::IsVisibleOnAllWorkspaces() {
|
||||
return window_->IsVisibleOnAllWorkspaces();
|
||||
}
|
||||
|
||||
void Window::SetAutoHideCursor(bool auto_hide) {
|
||||
window_->SetAutoHideCursor(auto_hide);
|
||||
}
|
||||
|
||||
void Window::SetVibrancy(mate::Arguments* args) {
|
||||
std::string type;
|
||||
|
||||
@@ -840,6 +876,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("isFullScreen", &Window::IsFullscreen)
|
||||
.SetMethod("setAspectRatio", &Window::SetAspectRatio)
|
||||
.SetMethod("previewFile", &Window::PreviewFile)
|
||||
.SetMethod("closeFilePreview", &Window::CloseFilePreview)
|
||||
#if !defined(OS_WIN)
|
||||
.SetMethod("setParentWindow", &Window::SetParentWindow)
|
||||
#endif
|
||||
@@ -908,6 +945,9 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
||||
&Window::SetVisibleOnAllWorkspaces)
|
||||
.SetMethod("isVisibleOnAllWorkspaces",
|
||||
&Window::IsVisibleOnAllWorkspaces)
|
||||
#if defined(OS_MACOSX)
|
||||
.SetMethod("setAutoHideCursor", &Window::SetAutoHideCursor)
|
||||
#endif
|
||||
.SetMethod("setVibrancy", &Window::SetVibrancy)
|
||||
#if defined(OS_WIN)
|
||||
.SetMethod("hookWindowMessage", &Window::HookWindowMessage)
|
||||
@@ -916,6 +956,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("unhookAllWindowMessages", &Window::UnhookAllWindowMessages)
|
||||
.SetMethod("setThumbnailClip", &Window::SetThumbnailClip)
|
||||
.SetMethod("setThumbnailToolTip", &Window::SetThumbnailToolTip)
|
||||
.SetMethod("setAppDetails", &Window::SetAppDetails)
|
||||
#endif
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
.SetMethod("setIcon", &Window::SetIcon)
|
||||
|
||||
@@ -171,6 +171,7 @@ class Window : public mate::TrackableObject<Window>,
|
||||
bool IsMenuBarVisible();
|
||||
void SetAspectRatio(double aspect_ratio, mate::Arguments* args);
|
||||
void PreviewFile(const std::string& path, mate::Arguments* args);
|
||||
void CloseFilePreview();
|
||||
void SetParentWindow(v8::Local<v8::Value> value, mate::Arguments* args);
|
||||
v8::Local<v8::Value> GetParentWindow() const;
|
||||
std::vector<v8::Local<v8::Object>> GetChildWindows() const;
|
||||
@@ -187,6 +188,7 @@ class Window : public mate::TrackableObject<Window>,
|
||||
void UnhookAllWindowMessages();
|
||||
bool SetThumbnailClip(const gfx::Rect& region);
|
||||
bool SetThumbnailToolTip(const std::string& tooltip);
|
||||
void SetAppDetails(const mate::Dictionary& options);
|
||||
#endif
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
@@ -196,6 +198,8 @@ class Window : public mate::TrackableObject<Window>,
|
||||
void SetVisibleOnAllWorkspaces(bool visible);
|
||||
bool IsVisibleOnAllWorkspaces();
|
||||
|
||||
void SetAutoHideCursor(bool auto_hide);
|
||||
|
||||
void SetVibrancy(mate::Arguments* args);
|
||||
|
||||
int32_t ID() const;
|
||||
|
||||
@@ -65,6 +65,12 @@ class TrackableObject : public TrackableObjectBase,
|
||||
Wrappable<T>::GetWrapper()->SetAlignedPointerInInternalField(0, nullptr);
|
||||
}
|
||||
|
||||
bool IsDestroyed() {
|
||||
v8::Local<v8::Object> wrapper = Wrappable<T>::GetWrapper();
|
||||
return wrapper->InternalFieldCount() == 0 ||
|
||||
wrapper->GetAlignedPointerFromInternalField(0) == nullptr;
|
||||
}
|
||||
|
||||
// Finds out the TrackableObject from its ID in weak map.
|
||||
static T* FromWeakMapID(v8::Isolate* isolate, int32_t id) {
|
||||
if (!weak_map_)
|
||||
|
||||
@@ -234,7 +234,8 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
||||
// Copy following switches to child process.
|
||||
static const char* const kCommonSwitchNames[] = {
|
||||
switches::kStandardSchemes,
|
||||
switches::kEnableSandbox
|
||||
switches::kEnableSandbox,
|
||||
switches::kSecureSchemes
|
||||
};
|
||||
command_line->CopySwitchesFrom(
|
||||
*base::CommandLine::ForCurrentProcess(),
|
||||
|
||||
@@ -5,20 +5,49 @@
|
||||
#include "atom/browser/atom_javascript_dialog_manager.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/ui/message_box.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
|
||||
using content::JavaScriptMessageType;
|
||||
|
||||
namespace atom {
|
||||
|
||||
void AtomJavaScriptDialogManager::RunJavaScriptDialog(
|
||||
content::WebContents* web_contents,
|
||||
const GURL& origin_url,
|
||||
content::JavaScriptMessageType javascript_message_type,
|
||||
JavaScriptMessageType message_type,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
const DialogClosedCallback& callback,
|
||||
bool* did_suppress_message) {
|
||||
callback.Run(false, base::string16());
|
||||
|
||||
if (message_type != JavaScriptMessageType::JAVASCRIPT_MESSAGE_TYPE_ALERT &&
|
||||
message_type != JavaScriptMessageType::JAVASCRIPT_MESSAGE_TYPE_CONFIRM) {
|
||||
callback.Run(false, base::string16());
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> buttons = {"OK"};
|
||||
if (message_type == JavaScriptMessageType::JAVASCRIPT_MESSAGE_TYPE_CONFIRM) {
|
||||
buttons.push_back("Cancel");
|
||||
}
|
||||
|
||||
atom::ShowMessageBox(NativeWindow::FromWebContents(web_contents),
|
||||
atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE,
|
||||
buttons,
|
||||
-1,
|
||||
0,
|
||||
atom::MessageBoxOptions::MESSAGE_BOX_NONE,
|
||||
"",
|
||||
base::UTF16ToUTF8(message_text),
|
||||
"",
|
||||
gfx::ImageSkia(),
|
||||
base::Bind(&OnMessageBoxCallback, callback));
|
||||
}
|
||||
|
||||
void AtomJavaScriptDialogManager::RunBeforeUnloadDialog(
|
||||
@@ -29,4 +58,10 @@ void AtomJavaScriptDialogManager::RunBeforeUnloadDialog(
|
||||
callback.Run(false, base::ASCIIToUTF16("This should not be displayed"));
|
||||
}
|
||||
|
||||
// static
|
||||
void AtomJavaScriptDialogManager::OnMessageBoxCallback(
|
||||
const DialogClosedCallback& callback, int code) {
|
||||
callback.Run(code == 0, base::string16());
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -29,6 +29,10 @@ class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager {
|
||||
void CancelActiveAndPendingDialogs(
|
||||
content::WebContents* web_contents) override {}
|
||||
void ResetDialogState(content::WebContents* web_contents) override {};
|
||||
|
||||
private:
|
||||
static void OnMessageBoxCallback(const DialogClosedCallback& callback,
|
||||
int code);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -16,13 +16,15 @@ class DictionaryValue;
|
||||
|
||||
namespace atom {
|
||||
|
||||
NSArray* ListValueToNSArray(const base::ListValue& value);
|
||||
|
||||
std::unique_ptr<base::ListValue> NSArrayToListValue(NSArray* arr);
|
||||
|
||||
NSDictionary* DictionaryValueToNSDictionary(const base::DictionaryValue& value);
|
||||
|
||||
std::unique_ptr<base::DictionaryValue> NSDictionaryToDictionaryValue(
|
||||
NSDictionary* dict);
|
||||
|
||||
std::unique_ptr<base::ListValue> NSArrayToListValue(NSArray* arr);
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_MAC_DICT_UTIL_H_
|
||||
|
||||
@@ -10,6 +10,18 @@
|
||||
|
||||
namespace atom {
|
||||
|
||||
NSArray* ListValueToNSArray(const base::ListValue& value) {
|
||||
std::string json;
|
||||
if (!base::JSONWriter::Write(value, &json))
|
||||
return nil;
|
||||
NSData* jsonData = [NSData dataWithBytes:json.c_str() length:json.length()];
|
||||
id obj =
|
||||
[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil];
|
||||
if (![obj isKindOfClass:[NSArray class]])
|
||||
return nil;
|
||||
return obj;
|
||||
}
|
||||
|
||||
std::unique_ptr<base::ListValue> NSArrayToListValue(NSArray* arr) {
|
||||
if (!arr)
|
||||
return nullptr;
|
||||
|
||||
@@ -333,6 +333,9 @@ void NativeWindow::SetParentWindow(NativeWindow* parent) {
|
||||
parent_ = parent;
|
||||
}
|
||||
|
||||
void NativeWindow::SetAutoHideCursor(bool auto_hide) {
|
||||
}
|
||||
|
||||
void NativeWindow::SetVibrancy(const std::string& filename) {
|
||||
}
|
||||
|
||||
@@ -381,6 +384,9 @@ void NativeWindow::PreviewFile(const std::string& path,
|
||||
const std::string& display_name) {
|
||||
}
|
||||
|
||||
void NativeWindow::CloseFilePreview() {
|
||||
}
|
||||
|
||||
void NativeWindow::RequestToClosePage() {
|
||||
bool prevent_default = false;
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver,
|
||||
|
||||
@@ -161,6 +161,8 @@ class NativeWindow : public base::SupportsUserData,
|
||||
virtual void SetVisibleOnAllWorkspaces(bool visible) = 0;
|
||||
virtual bool IsVisibleOnAllWorkspaces() = 0;
|
||||
|
||||
virtual void SetAutoHideCursor(bool auto_hide);
|
||||
|
||||
// Vibrancy API
|
||||
virtual void SetVibrancy(const std::string& type);
|
||||
|
||||
@@ -179,8 +181,11 @@ class NativeWindow : public base::SupportsUserData,
|
||||
double GetAspectRatio();
|
||||
gfx::Size GetAspectRatioExtraSize();
|
||||
virtual void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size);
|
||||
|
||||
// File preview APIs.
|
||||
virtual void PreviewFile(const std::string& path,
|
||||
const std::string& display_name);
|
||||
virtual void CloseFilePreview();
|
||||
|
||||
base::WeakPtr<NativeWindow> GetWeakPtr() {
|
||||
return weak_factory_.GetWeakPtr();
|
||||
|
||||
@@ -57,6 +57,7 @@ class NativeWindowMac : public NativeWindow,
|
||||
override;
|
||||
void PreviewFile(const std::string& path, const std::string& display_name)
|
||||
override;
|
||||
void CloseFilePreview() override;
|
||||
bool IsMovable() override;
|
||||
void SetMinimizable(bool minimizable) override;
|
||||
bool IsMinimizable() override;
|
||||
@@ -90,8 +91,12 @@ class NativeWindowMac : public NativeWindow,
|
||||
void SetProgressBar(double progress, const ProgressState state) override;
|
||||
void SetOverlayIcon(const gfx::Image& overlay,
|
||||
const std::string& description) override;
|
||||
|
||||
void SetVisibleOnAllWorkspaces(bool visible) override;
|
||||
bool IsVisibleOnAllWorkspaces() override;
|
||||
|
||||
void SetAutoHideCursor(bool auto_hide) override;
|
||||
|
||||
void SetVibrancy(const std::string& type) override;
|
||||
|
||||
// content::RenderWidgetHost::InputEventObserver:
|
||||
@@ -157,6 +162,8 @@ class NativeWindowMac : public NativeWindow,
|
||||
|
||||
bool is_kiosk_;
|
||||
|
||||
bool was_fullscreen_;
|
||||
|
||||
bool zoom_to_page_width_;
|
||||
|
||||
NSInteger attention_request_id_; // identifier from requestUserAttention
|
||||
|
||||
@@ -619,6 +619,7 @@ NativeWindowMac::NativeWindowMac(
|
||||
NativeWindow* parent)
|
||||
: NativeWindow(web_contents, options, parent),
|
||||
is_kiosk_(false),
|
||||
was_fullscreen_(false),
|
||||
zoom_to_page_width_(false),
|
||||
attention_request_id_(0),
|
||||
title_bar_style_(NORMAL) {
|
||||
@@ -626,7 +627,7 @@ NativeWindowMac::NativeWindowMac(
|
||||
options.Get(options::kWidth, &width);
|
||||
options.Get(options::kHeight, &height);
|
||||
|
||||
NSRect main_screen_rect = [[[NSScreen screens] objectAtIndex:0] frame];
|
||||
NSRect main_screen_rect = [[[NSScreen screens] firstObject] frame];
|
||||
NSRect cocoa_bounds = NSMakeRect(
|
||||
round((NSWidth(main_screen_rect) - width) / 2) ,
|
||||
round((NSHeight(main_screen_rect) - height) / 2),
|
||||
@@ -937,7 +938,7 @@ void NativeWindowMac::SetBounds(const gfx::Rect& bounds, bool animate) {
|
||||
|
||||
NSRect cocoa_bounds = NSMakeRect(bounds.x(), 0, size.width(), size.height());
|
||||
// Flip coordinates based on the primary screen.
|
||||
NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
|
||||
NSScreen* screen = [[NSScreen screens] firstObject];
|
||||
cocoa_bounds.origin.y =
|
||||
NSHeight([screen frame]) - size.height() - bounds.y();
|
||||
|
||||
@@ -947,7 +948,7 @@ void NativeWindowMac::SetBounds(const gfx::Rect& bounds, bool animate) {
|
||||
gfx::Rect NativeWindowMac::GetBounds() {
|
||||
NSRect frame = [window_ frame];
|
||||
gfx::Rect bounds(frame.origin.x, 0, NSWidth(frame), NSHeight(frame));
|
||||
NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
|
||||
NSScreen* screen = [[NSScreen screens] firstObject];
|
||||
bounds.set_y(NSHeight([screen frame]) - NSMaxY(frame));
|
||||
return bounds;
|
||||
}
|
||||
@@ -1004,6 +1005,12 @@ void NativeWindowMac::PreviewFile(const std::string& path,
|
||||
[window_ previewFileAtPath:path_ns withName:name_ns];
|
||||
}
|
||||
|
||||
void NativeWindowMac::CloseFilePreview() {
|
||||
if ([QLPreviewPanel sharedPreviewPanelExists]) {
|
||||
[[QLPreviewPanel sharedPreviewPanel] close];
|
||||
}
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetMovable(bool movable) {
|
||||
[window_ setMovable:movable];
|
||||
}
|
||||
@@ -1067,6 +1074,7 @@ void NativeWindowMac::SetAlwaysOnTop(bool top, const std::string& level) {
|
||||
} else if (level == "screen-saver") {
|
||||
windowLevel = NSScreenSaverWindowLevel;
|
||||
} else if (level == "dock") {
|
||||
// Deprecated by macOS, but kept for backwards compatibility
|
||||
windowLevel = NSDockWindowLevel;
|
||||
}
|
||||
}
|
||||
@@ -1119,10 +1127,11 @@ void NativeWindowMac::SetKiosk(bool kiosk) {
|
||||
NSApplicationPresentationDisableHideApplication;
|
||||
[NSApp setPresentationOptions:options];
|
||||
is_kiosk_ = true;
|
||||
SetFullScreen(true);
|
||||
was_fullscreen_ = IsFullscreen();
|
||||
if (!was_fullscreen_) SetFullScreen(true);
|
||||
} else if (!kiosk && is_kiosk_) {
|
||||
is_kiosk_ = false;
|
||||
SetFullScreen(false);
|
||||
if (!was_fullscreen_) SetFullScreen(false);
|
||||
[NSApp setPresentationOptions:kiosk_options_];
|
||||
}
|
||||
}
|
||||
@@ -1249,6 +1258,10 @@ bool NativeWindowMac::IsVisibleOnAllWorkspaces() {
|
||||
return collectionBehavior & NSWindowCollectionBehaviorCanJoinAllSpaces;
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetAutoHideCursor(bool auto_hide) {
|
||||
[window_ setDisableAutoHideCursor:!auto_hide];
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetVibrancy(const std::string& type) {
|
||||
if (!base::mac::IsOSYosemiteOrLater()) return;
|
||||
|
||||
@@ -1391,10 +1404,10 @@ void NativeWindowMac::ShowWindowButton(NSWindowButton button) {
|
||||
}
|
||||
|
||||
void NativeWindowMac::InstallView() {
|
||||
// Make sure the bottom corner is rounded: http://crbug.com/396264.
|
||||
// Make sure the bottom corner is rounded for non-modal windows: http://crbug.com/396264.
|
||||
// But do not enable it on OS X 10.9 for transparent window, otherwise a
|
||||
// semi-transparent frame would show.
|
||||
if (!(transparent() && base::mac::IsOSMavericks()))
|
||||
if (!(transparent() && base::mac::IsOSMavericks()) && !is_modal())
|
||||
[[window_ contentView] setWantsLayer:YES];
|
||||
|
||||
NSView* view = inspectable_web_contents()->GetView()->GetNativeView();
|
||||
|
||||
@@ -426,7 +426,7 @@ bool NativeWindowViews::IsEnabled() {
|
||||
void NativeWindowViews::Maximize() {
|
||||
#if defined(OS_WIN)
|
||||
// For window without WS_THICKFRAME style, we can not call Maximize().
|
||||
if (!thick_frame_) {
|
||||
if (!(::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_THICKFRAME)) {
|
||||
restore_bounds_ = GetBounds();
|
||||
auto display =
|
||||
display::Screen::GetScreen()->GetDisplayNearestPoint(GetPosition());
|
||||
@@ -444,7 +444,7 @@ void NativeWindowViews::Maximize() {
|
||||
|
||||
void NativeWindowViews::Unmaximize() {
|
||||
#if defined(OS_WIN)
|
||||
if (!thick_frame_) {
|
||||
if (!(::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_THICKFRAME)) {
|
||||
SetBounds(restore_bounds_, false);
|
||||
return;
|
||||
}
|
||||
@@ -488,6 +488,7 @@ void NativeWindowViews::SetFullScreen(bool fullscreen) {
|
||||
}
|
||||
|
||||
// For window without WS_THICKFRAME style, we can not call SetFullscreen().
|
||||
// This path will be used for transparent windows as well.
|
||||
if (!thick_frame_) {
|
||||
if (fullscreen) {
|
||||
restore_bounds_ = GetBounds();
|
||||
@@ -572,7 +573,7 @@ void NativeWindowViews::SetContentSizeConstraints(
|
||||
|
||||
void NativeWindowViews::SetResizable(bool resizable) {
|
||||
#if defined(OS_WIN)
|
||||
if (thick_frame_)
|
||||
if (has_frame())
|
||||
FlipWindowStyle(GetAcceleratedWidget(), resizable, WS_THICKFRAME);
|
||||
#elif defined(USE_X11)
|
||||
if (resizable != resizable_) {
|
||||
@@ -595,11 +596,10 @@ void NativeWindowViews::SetResizable(bool resizable) {
|
||||
|
||||
bool NativeWindowViews::IsResizable() {
|
||||
#if defined(OS_WIN)
|
||||
if (thick_frame_) {
|
||||
if (has_frame())
|
||||
return ::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_THICKFRAME;
|
||||
} else {
|
||||
else
|
||||
return CanResize();
|
||||
}
|
||||
#else
|
||||
return CanResize();
|
||||
#endif
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "net/base/elements_upload_data_stream.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/base/load_flags.h"
|
||||
#include "net/base/upload_bytes_element_reader.h"
|
||||
|
||||
namespace {
|
||||
@@ -113,6 +114,8 @@ void AtomURLRequest::DoInitialize(
|
||||
return;
|
||||
}
|
||||
request_->set_method(method);
|
||||
// Do not send cookies from the cookie store.
|
||||
DoSetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES);
|
||||
}
|
||||
|
||||
void AtomURLRequest::DoTerminate() {
|
||||
@@ -177,6 +180,13 @@ void AtomURLRequest::PassLoginInformation(
|
||||
}
|
||||
}
|
||||
|
||||
void AtomURLRequest::SetLoadFlags(int flags) const {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(&AtomURLRequest::DoSetLoadFlags, this, flags));
|
||||
}
|
||||
|
||||
void AtomURLRequest::DoWriteBuffer(
|
||||
scoped_refptr<const net::IOBufferWithSize> buffer,
|
||||
bool is_last) {
|
||||
@@ -244,6 +254,7 @@ void AtomURLRequest::DoSetExtraHeader(const std::string& name,
|
||||
}
|
||||
request_->SetExtraRequestHeaderByName(name, value, true);
|
||||
}
|
||||
|
||||
void AtomURLRequest::DoRemoveExtraHeader(const std::string& name) const {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
||||
if (!request_) {
|
||||
@@ -278,6 +289,14 @@ void AtomURLRequest::DoCancelWithError(const std::string& error,
|
||||
isRequestError));
|
||||
}
|
||||
|
||||
void AtomURLRequest::DoSetLoadFlags(int flags) const {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
||||
if (!request_) {
|
||||
return;
|
||||
}
|
||||
request_->SetLoadFlags(request_->load_flags() | flags);
|
||||
}
|
||||
|
||||
void AtomURLRequest::OnAuthRequired(net::URLRequest* request,
|
||||
net::AuthChallengeInfo* auth_info) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
||||
|
||||
@@ -40,6 +40,7 @@ class AtomURLRequest : public base::RefCountedThreadSafe<AtomURLRequest>,
|
||||
void RemoveExtraHeader(const std::string& name) const;
|
||||
void PassLoginInformation(const base::string16& username,
|
||||
const base::string16& password) const;
|
||||
void SetLoadFlags(int flags) const;
|
||||
|
||||
protected:
|
||||
// Overrides of net::URLRequest::Delegate
|
||||
@@ -71,6 +72,7 @@ class AtomURLRequest : public base::RefCountedThreadSafe<AtomURLRequest>,
|
||||
const base::string16& password) const;
|
||||
void DoCancelAuth() const;
|
||||
void DoCancelWithError(const std::string& error, bool isRequestError);
|
||||
void DoSetLoadFlags(int flags) const;
|
||||
|
||||
void ReadResponse();
|
||||
bool CopyAndPostBuffer(int bytes_read);
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
#include "atom/browser/api/atom_api_session.h"
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
@@ -89,15 +91,23 @@ void URLRequestFetchJob::BeforeStartInUI(
|
||||
return;
|
||||
|
||||
// When |session| is set to |null| we use a new request context for fetch job.
|
||||
// TODO(zcbenz): Handle the case when it is not null.
|
||||
v8::Local<v8::Value> session;
|
||||
if (options.Get("session", &session) && session->IsNull()) {
|
||||
// We have to create the URLRequestContextGetter on UI thread.
|
||||
url_request_context_getter_ = new brightray::URLRequestContextGetter(
|
||||
this, nullptr, nullptr, base::FilePath(), true,
|
||||
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO),
|
||||
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE),
|
||||
nullptr, content::URLRequestInterceptorScopedVector());
|
||||
v8::Local<v8::Value> val;
|
||||
if (options.Get("session", &val)) {
|
||||
if (val->IsNull()) {
|
||||
// We have to create the URLRequestContextGetter on UI thread.
|
||||
url_request_context_getter_ = new brightray::URLRequestContextGetter(
|
||||
this, nullptr, nullptr, base::FilePath(), true,
|
||||
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO),
|
||||
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE),
|
||||
nullptr, content::URLRequestInterceptorScopedVector());
|
||||
} else {
|
||||
mate::Handle<api::Session> session;
|
||||
if (mate::ConvertFromV8(isolate, val, &session) && !session.IsEmpty()) {
|
||||
AtomBrowserContext* browser_context = session->browser_context();
|
||||
url_request_context_getter_ =
|
||||
browser_context->url_request_context_getter();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,21 +247,21 @@ int URLRequestFetchJob::GetResponseCode() const {
|
||||
}
|
||||
|
||||
void URLRequestFetchJob::OnURLFetchComplete(const net::URLFetcher* source) {
|
||||
if (!response_info_) {
|
||||
// Since we notify header completion only after first write there will be
|
||||
// no response object constructed for http respones with no content 204.
|
||||
// We notify header completion here.
|
||||
HeadersCompleted();
|
||||
return;
|
||||
}
|
||||
|
||||
ClearPendingBuffer();
|
||||
ClearWriteBuffer();
|
||||
|
||||
if (fetcher_->GetStatus().is_success())
|
||||
if (fetcher_->GetStatus().is_success()) {
|
||||
if (!response_info_) {
|
||||
// Since we notify header completion only after first write there will be
|
||||
// no response object constructed for http respones with no content 204.
|
||||
// We notify header completion here.
|
||||
HeadersCompleted();
|
||||
return;
|
||||
}
|
||||
ReadRawDataComplete(0);
|
||||
else
|
||||
} else {
|
||||
NotifyStartError(fetcher_->GetStatus());
|
||||
}
|
||||
}
|
||||
|
||||
int URLRequestFetchJob::BufferCopy(net::IOBuffer* source, int num_bytes,
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>electron.icns</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.4.10</string>
|
||||
<string>1.4.15</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.4.10</string>
|
||||
<string>1.4.15</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,4,10,0
|
||||
PRODUCTVERSION 1,4,10,0
|
||||
FILEVERSION 1,4,15,0
|
||||
PRODUCTVERSION 1,4,15,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -74,12 +74,12 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "GitHub, Inc."
|
||||
VALUE "FileDescription", "Electron"
|
||||
VALUE "FileVersion", "1.4.10"
|
||||
VALUE "FileVersion", "1.4.15"
|
||||
VALUE "InternalName", "electron.exe"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved."
|
||||
VALUE "OriginalFilename", "electron.exe"
|
||||
VALUE "ProductName", "Electron"
|
||||
VALUE "ProductVersion", "1.4.10"
|
||||
VALUE "ProductVersion", "1.4.15"
|
||||
VALUE "SquirrelAwareVersion", "1"
|
||||
END
|
||||
END
|
||||
|
||||
@@ -37,8 +37,8 @@ typedef base::Callback<void(int code)> MessageBoxCallback;
|
||||
int ShowMessageBox(NativeWindow* parent_window,
|
||||
MessageBoxType type,
|
||||
const std::vector<std::string>& buttons,
|
||||
int cancel_id,
|
||||
int default_id,
|
||||
int cancel_id,
|
||||
int options,
|
||||
const std::string& title,
|
||||
const std::string& message,
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "atom/browser/ui/message_box.h"
|
||||
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/browser/native_window_observer.h"
|
||||
#include "atom/browser/native_window_views.h"
|
||||
#include "atom/browser/unresponsive_suppressor.h"
|
||||
#include "base/callback.h"
|
||||
@@ -25,7 +26,7 @@ namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
class GtkMessageBox {
|
||||
class GtkMessageBox : public NativeWindowObserver {
|
||||
public:
|
||||
GtkMessageBox(NativeWindow* parent_window,
|
||||
MessageBoxType type,
|
||||
@@ -77,6 +78,7 @@ class GtkMessageBox {
|
||||
|
||||
// Parent window.
|
||||
if (parent_) {
|
||||
parent_->AddObserver(this);
|
||||
parent_->SetEnabled(false);
|
||||
libgtk2ui::SetGtkTransientForAura(dialog_, parent_->GetNativeWindow());
|
||||
gtk_window_set_modal(GTK_WINDOW(dialog_), TRUE);
|
||||
@@ -85,8 +87,10 @@ class GtkMessageBox {
|
||||
|
||||
~GtkMessageBox() {
|
||||
gtk_widget_destroy(dialog_);
|
||||
if (parent_)
|
||||
if (parent_) {
|
||||
parent_->RemoveObserver(this);
|
||||
parent_->SetEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
GtkMessageType GetMessageType(MessageBoxType type) {
|
||||
@@ -144,6 +148,11 @@ class GtkMessageBox {
|
||||
Show();
|
||||
}
|
||||
|
||||
void OnWindowClosed() override {
|
||||
parent_->RemoveObserver(this);
|
||||
parent_ = nullptr;
|
||||
}
|
||||
|
||||
CHROMEGTK_CALLBACK_1(GtkMessageBox, void, OnResponseDialog, int);
|
||||
|
||||
private:
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "atom/browser/native_window_views.h"
|
||||
#include "ui/display/win/screen_win.h"
|
||||
#endif
|
||||
|
||||
namespace atom {
|
||||
@@ -13,13 +14,17 @@ namespace atom {
|
||||
namespace {
|
||||
|
||||
#if defined(OS_WIN)
|
||||
gfx::Rect SubstractBorderSize(gfx::Rect bounds) {
|
||||
int border_width = GetSystemMetrics(SM_CXSIZEFRAME) - 1;
|
||||
int border_height = GetSystemMetrics(SM_CYSIZEFRAME) - 1;
|
||||
bounds.set_x(bounds.x() + border_width);
|
||||
bounds.set_y(bounds.y() + border_height);
|
||||
bounds.set_width(bounds.width() - 2 * border_width);
|
||||
bounds.set_height(bounds.height() - 2 * border_height);
|
||||
gfx::Rect SubtractBorderSize(gfx::Rect bounds) {
|
||||
gfx::Point borderSize = gfx::Point(
|
||||
GetSystemMetrics(SM_CXSIZEFRAME) - 1, // width
|
||||
GetSystemMetrics(SM_CYSIZEFRAME) - 1); // height
|
||||
gfx::Point dpiAdjustedSize =
|
||||
display::win::ScreenWin::ScreenToDIPPoint(borderSize);
|
||||
|
||||
bounds.set_x(bounds.x() + dpiAdjustedSize.x());
|
||||
bounds.set_y(bounds.y() + dpiAdjustedSize.y());
|
||||
bounds.set_width(bounds.width() - 2 * dpiAdjustedSize.x());
|
||||
bounds.set_height(bounds.height() - 2 * dpiAdjustedSize.y());
|
||||
return bounds;
|
||||
}
|
||||
#endif
|
||||
@@ -39,7 +44,7 @@ void MenuLayout::Layout(views::View* host) {
|
||||
// Reserve border space for maximized frameless window so we won't have the
|
||||
// content go outside of screen.
|
||||
if (!window_->has_frame() && window_->IsMaximized()) {
|
||||
gfx::Rect bounds = SubstractBorderSize(host->GetContentsBounds());
|
||||
gfx::Rect bounds = SubtractBorderSize(host->GetContentsBounds());
|
||||
host->child_at(0)->SetBoundsRect(bounds);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,4 +25,12 @@ bool AtomDesktopWindowTreeHostWin::PreHandleMSG(
|
||||
return delegate_->PreHandleMSG(message, w_param, l_param, result);
|
||||
}
|
||||
|
||||
/** Override the client area inset
|
||||
* Returning true forces a border of 0 for frameless windows
|
||||
*/
|
||||
bool AtomDesktopWindowTreeHostWin::GetClientAreaInsets(
|
||||
gfx::Insets* insets) const {
|
||||
return !HasFrame();
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -27,6 +27,7 @@ class AtomDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin {
|
||||
protected:
|
||||
bool PreHandleMSG(
|
||||
UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) override;
|
||||
bool GetClientAreaInsets(gfx::Insets* insets) const override;
|
||||
|
||||
private:
|
||||
MessageHandlerDelegate* delegate_; // weak ref
|
||||
|
||||
@@ -31,7 +31,7 @@ bool AppendTask(const JumpListItem& item, IObjectCollection* collection) {
|
||||
item.icon_index)))
|
||||
return false;
|
||||
|
||||
CComQIPtr<IPropertyStore> property_store = link;
|
||||
CComQIPtr<IPropertyStore> property_store(link);
|
||||
if (!base::win::SetStringValueForPropertyStore(property_store, PKEY_Title,
|
||||
item.title.c_str()))
|
||||
return false;
|
||||
@@ -44,7 +44,7 @@ bool AppendSeparator(IObjectCollection* collection) {
|
||||
|
||||
CComPtr<IShellLink> shell_link;
|
||||
if (SUCCEEDED(shell_link.CoCreateInstance(CLSID_ShellLink))) {
|
||||
CComQIPtr<IPropertyStore> property_store = shell_link;
|
||||
CComQIPtr<IPropertyStore> property_store(shell_link);
|
||||
if (base::win::SetBooleanValueForPropertyStore(
|
||||
property_store, PKEY_AppUserModel_IsDestListSeparator, true))
|
||||
return SUCCEEDED(collection->AddObject(shell_link));
|
||||
@@ -254,7 +254,7 @@ JumpListResult JumpList::AppendCategory(const JumpListCategory& category) {
|
||||
result = JumpListResult::GENERIC_ERROR;
|
||||
}
|
||||
|
||||
CComQIPtr<IObjectArray> items = collection;
|
||||
CComQIPtr<IObjectArray> items(collection);
|
||||
|
||||
if (category.type == JumpListCategory::Type::TASKS) {
|
||||
if (FAILED(destinations_->AddUserTasks(items))) {
|
||||
|
||||
@@ -119,6 +119,12 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
|
||||
LOG(ERROR) << "preload url must be file:// protocol.";
|
||||
}
|
||||
|
||||
// Run Electron APIs and preload script in isolated world
|
||||
bool isolated;
|
||||
if (web_preferences.GetBoolean(options::kContextIsolation, &isolated) &&
|
||||
isolated)
|
||||
command_line->AppendSwitch(switches::kContextIsolation);
|
||||
|
||||
// --background-color.
|
||||
std::string color;
|
||||
if (web_preferences.GetString(options::kBackgroundColor, &color))
|
||||
@@ -190,7 +196,7 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
|
||||
if (window) {
|
||||
bool visible = window->IsVisible() && !window->IsMinimized();
|
||||
if (!visible) // Default state is visible.
|
||||
command_line->AppendSwitch("hidden-page");
|
||||
command_line->AppendSwitch(switches::kHiddenPage);
|
||||
}
|
||||
|
||||
// Use frame scheduling for offscreen renderers.
|
||||
@@ -251,6 +257,10 @@ void WebContentsPreferences::OverrideWebkitPrefs(
|
||||
prefs->sans_serif_font_family_map[content::kCommonScript] = font;
|
||||
if (fonts->GetString("monospace", &font))
|
||||
prefs->fixed_font_family_map[content::kCommonScript] = font;
|
||||
if (fonts->GetString("cursive", &font))
|
||||
prefs->cursive_font_family_map[content::kCommonScript] = font;
|
||||
if (fonts->GetString("fantasy", &font))
|
||||
prefs->fantasy_font_family_map[content::kCommonScript] = font;
|
||||
}
|
||||
int size;
|
||||
if (self->web_preferences_.GetInteger("defaultFontSize", &size))
|
||||
|
||||
@@ -40,6 +40,10 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||
base::Bind(&CrashReporter::Start, report));
|
||||
dict.SetMethod("_getUploadedReports",
|
||||
base::Bind(&CrashReporter::GetUploadedReports, report));
|
||||
dict.SetMethod("_setUploadToServer",
|
||||
base::Bind(&CrashReporter::SetUploadToServer, report));
|
||||
dict.SetMethod("_getUploadToServer",
|
||||
base::Bind(&CrashReporter::GetUploadToServer, report));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -79,6 +79,8 @@ float GetScaleFactorFromPath(const base::FilePath& path) {
|
||||
bool AddImageSkiaRep(gfx::ImageSkia* image,
|
||||
const unsigned char* data,
|
||||
size_t size,
|
||||
int width,
|
||||
int height,
|
||||
double scale_factor) {
|
||||
std::unique_ptr<SkBitmap> decoded(new SkBitmap());
|
||||
|
||||
@@ -87,8 +89,17 @@ bool AddImageSkiaRep(gfx::ImageSkia* image,
|
||||
// Try JPEG.
|
||||
decoded = gfx::JPEGCodec::Decode(data, size);
|
||||
|
||||
if (!decoded)
|
||||
return false;
|
||||
if (!decoded) {
|
||||
// Try Bitmap
|
||||
if (width > 0 && height > 0) {
|
||||
decoded.reset(new SkBitmap);
|
||||
decoded->allocN32Pixels(width, height, false);
|
||||
decoded->setPixels(
|
||||
const_cast<void*>(reinterpret_cast<const void*>(data)));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
image->AddRepresentation(gfx::ImageSkiaRep(*decoded, scale_factor));
|
||||
return true;
|
||||
@@ -104,7 +115,7 @@ bool AddImageSkiaRep(gfx::ImageSkia* image,
|
||||
const unsigned char* data =
|
||||
reinterpret_cast<const unsigned char*>(file_contents.data());
|
||||
size_t size = file_contents.size();
|
||||
return AddImageSkiaRep(image, data, size, scale_factor);
|
||||
return AddImageSkiaRep(image, data, size, 0, 0, scale_factor);
|
||||
}
|
||||
|
||||
bool PopulateImageSkiaRepsFromPath(gfx::ImageSkia* image,
|
||||
@@ -395,13 +406,26 @@ mate::Handle<NativeImage> NativeImage::CreateFromPath(
|
||||
// static
|
||||
mate::Handle<NativeImage> NativeImage::CreateFromBuffer(
|
||||
mate::Arguments* args, v8::Local<v8::Value> buffer) {
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
double scale_factor = 1.;
|
||||
args->GetNext(&scale_factor);
|
||||
|
||||
mate::Dictionary options;
|
||||
if (args->GetNext(&options)) {
|
||||
options.Get("width", &width);
|
||||
options.Get("height", &height);
|
||||
options.Get("scaleFactor", &scale_factor);
|
||||
} else {
|
||||
// TODO(kevinsawicki): Remove in 2.0, deprecate before then with warnings
|
||||
args->GetNext(&scale_factor);
|
||||
}
|
||||
|
||||
gfx::ImageSkia image_skia;
|
||||
AddImageSkiaRep(&image_skia,
|
||||
reinterpret_cast<unsigned char*>(node::Buffer::Data(buffer)),
|
||||
node::Buffer::Length(buffer),
|
||||
width,
|
||||
height,
|
||||
scale_factor);
|
||||
return Create(args->isolate(), gfx::Image(image_skia));
|
||||
}
|
||||
|
||||
@@ -112,6 +112,7 @@ void AtomBindings::BindTo(v8::Isolate* isolate,
|
||||
|
||||
mate::Dictionary versions;
|
||||
if (dict.Get("versions", &versions)) {
|
||||
// TODO(kevinsawicki): Make read-only in 2.0 to match node
|
||||
versions.Set(ATOM_PROJECT_NAME, ATOM_VERSION_STRING);
|
||||
versions.Set("chrome", CHROME_VERSION_STRING);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#define ATOM_MAJOR_VERSION 1
|
||||
#define ATOM_MINOR_VERSION 4
|
||||
#define ATOM_PATCH_VERSION 10
|
||||
#define ATOM_PATCH_VERSION 15
|
||||
|
||||
#define ATOM_VERSION_IS_RELEASE 1
|
||||
|
||||
|
||||
@@ -26,13 +26,13 @@ void CrashReporter::Start(const std::string& product_name,
|
||||
const std::string& company_name,
|
||||
const std::string& submit_url,
|
||||
const base::FilePath& crashes_dir,
|
||||
bool auto_submit,
|
||||
bool upload_to_server,
|
||||
bool skip_system_crash_handler,
|
||||
const StringMap& extra_parameters) {
|
||||
SetUploadParameters(extra_parameters);
|
||||
|
||||
InitBreakpad(product_name, ATOM_VERSION_STRING, company_name, submit_url,
|
||||
crashes_dir, auto_submit, skip_system_crash_handler);
|
||||
crashes_dir, upload_to_server, skip_system_crash_handler);
|
||||
}
|
||||
|
||||
void CrashReporter::SetUploadParameters(const StringMap& parameters) {
|
||||
@@ -43,6 +43,13 @@ void CrashReporter::SetUploadParameters(const StringMap& parameters) {
|
||||
SetUploadParameters();
|
||||
}
|
||||
|
||||
void CrashReporter::SetUploadToServer(const bool upload_to_server) {
|
||||
}
|
||||
|
||||
bool CrashReporter::GetUploadToServer() {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<CrashReporter::UploadReportResult>
|
||||
CrashReporter::GetUploadedReports(const base::FilePath& crashes_dir) {
|
||||
std::string file_content;
|
||||
|
||||
@@ -26,13 +26,16 @@ class CrashReporter {
|
||||
const std::string& company_name,
|
||||
const std::string& submit_url,
|
||||
const base::FilePath& crashes_dir,
|
||||
bool auto_submit,
|
||||
bool upload_to_server,
|
||||
bool skip_system_crash_handler,
|
||||
const StringMap& extra_parameters);
|
||||
|
||||
virtual std::vector<CrashReporter::UploadReportResult> GetUploadedReports(
|
||||
const base::FilePath& crashes_dir);
|
||||
|
||||
virtual void SetUploadToServer(bool upload_to_server);
|
||||
virtual bool GetUploadToServer();
|
||||
|
||||
protected:
|
||||
CrashReporter();
|
||||
virtual ~CrashReporter();
|
||||
@@ -42,7 +45,7 @@ class CrashReporter {
|
||||
const std::string& company_name,
|
||||
const std::string& submit_url,
|
||||
const base::FilePath& crashes_dir,
|
||||
bool auto_submit,
|
||||
bool upload_to_server,
|
||||
bool skip_system_crash_handler);
|
||||
virtual void SetUploadParameters();
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ void CrashReporterLinux::InitBreakpad(const std::string& product_name,
|
||||
const std::string& company_name,
|
||||
const std::string& submit_url,
|
||||
const base::FilePath& crashes_dir,
|
||||
bool auto_submit,
|
||||
bool upload_to_server,
|
||||
bool skip_system_crash_handler) {
|
||||
EnableCrashDumping(crashes_dir);
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class CrashReporterLinux : public CrashReporter {
|
||||
const std::string& company_name,
|
||||
const std::string& submit_url,
|
||||
const base::FilePath& crashes_dir,
|
||||
bool auto_submit,
|
||||
bool upload_to_server,
|
||||
bool skip_system_crash_handler) override;
|
||||
void SetUploadParameters() override;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "atom/common/crash_reporter/crash_reporter.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "vendor/crashpad/client/crash_report_database.h"
|
||||
#include "vendor/crashpad/client/simple_string_dictionary.h"
|
||||
|
||||
namespace base {
|
||||
@@ -28,9 +29,11 @@ class CrashReporterMac : public CrashReporter {
|
||||
const std::string& company_name,
|
||||
const std::string& submit_url,
|
||||
const base::FilePath& crashes_dir,
|
||||
bool auto_submit,
|
||||
bool upload_to_server,
|
||||
bool skip_system_crash_handler) override;
|
||||
void SetUploadParameters() override;
|
||||
void SetUploadToServer(bool upload_to_server) override;
|
||||
bool GetUploadToServer() override;
|
||||
|
||||
private:
|
||||
friend struct base::DefaultSingletonTraits<CrashReporterMac>;
|
||||
@@ -46,6 +49,7 @@ class CrashReporterMac : public CrashReporter {
|
||||
const base::FilePath& crashes_dir) override;
|
||||
|
||||
std::unique_ptr<crashpad::SimpleStringDictionary> simple_string_dictionary_;
|
||||
std::unique_ptr<crashpad::CrashReportDatabase> database_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CrashReporterMac);
|
||||
};
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "vendor/crashpad/client/crash_report_database.h"
|
||||
#include "vendor/crashpad/client/crashpad_client.h"
|
||||
#include "vendor/crashpad/client/crashpad_info.h"
|
||||
#include "vendor/crashpad/client/settings.h"
|
||||
@@ -31,7 +30,7 @@ void CrashReporterMac::InitBreakpad(const std::string& product_name,
|
||||
const std::string& company_name,
|
||||
const std::string& submit_url,
|
||||
const base::FilePath& crashes_dir,
|
||||
bool auto_submit,
|
||||
bool upload_to_server,
|
||||
bool skip_system_crash_handler) {
|
||||
// check whether crashpad has been initialized.
|
||||
// Only need to initialize once.
|
||||
@@ -73,11 +72,23 @@ void CrashReporterMac::InitBreakpad(const std::string& product_name,
|
||||
SetCrashKeyValue(upload_parameter.first, upload_parameter.second);
|
||||
}
|
||||
if (is_browser_) {
|
||||
std::unique_ptr<crashpad::CrashReportDatabase> database =
|
||||
database_ =
|
||||
crashpad::CrashReportDatabase::Initialize(crashes_dir);
|
||||
if (database) {
|
||||
database->GetSettings()->SetUploadsEnabled(auto_submit);
|
||||
}
|
||||
SetUploadToServer(upload_to_server);
|
||||
}
|
||||
}
|
||||
|
||||
bool CrashReporterMac::GetUploadToServer() {
|
||||
bool enabled = true;
|
||||
if (database_) {
|
||||
database_->GetSettings()->GetUploadsEnabled(&enabled);
|
||||
}
|
||||
return enabled;
|
||||
}
|
||||
|
||||
void CrashReporterMac::SetUploadToServer(const bool upload_to_server) {
|
||||
if (database_) {
|
||||
database_->GetSettings()->SetUploadsEnabled(upload_to_server);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ void CrashReporterWin::InitBreakpad(const std::string& product_name,
|
||||
const std::string& company_name,
|
||||
const std::string& submit_url,
|
||||
const base::FilePath& crashes_dir,
|
||||
bool auto_submit,
|
||||
bool upload_to_server,
|
||||
bool skip_system_crash_handler) {
|
||||
skip_system_crash_handler_ = skip_system_crash_handler;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class CrashReporterWin : public CrashReporter {
|
||||
const std::string& company_name,
|
||||
const std::string& submit_url,
|
||||
const base::FilePath& crashes_dir,
|
||||
bool auto_submit,
|
||||
bool upload_to_server,
|
||||
bool skip_system_crash_handler) override;
|
||||
void SetUploadParameters() override;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "third_party/WebKit/public/web/WebFindOptions.h"
|
||||
#include "third_party/WebKit/public/web/WebInputEvent.h"
|
||||
#include "ui/base/clipboard/clipboard.h"
|
||||
#include "ui/events/keycodes/dom/keycode_converter.h"
|
||||
#include "ui/events/keycodes/keyboard_code_conversion.h"
|
||||
|
||||
namespace {
|
||||
@@ -215,6 +216,26 @@ bool Converter<content::NativeWebKeyboardEvent>::FromV8(
|
||||
return true;
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> Converter<content::NativeWebKeyboardEvent>::ToV8(
|
||||
v8::Isolate* isolate, const content::NativeWebKeyboardEvent& in) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
|
||||
if (in.type == blink::WebInputEvent::Type::RawKeyDown)
|
||||
dict.Set("type", "keyDown");
|
||||
else if (in.type == blink::WebInputEvent::Type::KeyUp)
|
||||
dict.Set("type", "keyUp");
|
||||
dict.Set("key", ui::KeycodeConverter::DomKeyToKeyString(in.domKey));
|
||||
|
||||
using Modifiers = blink::WebInputEvent::Modifiers;
|
||||
dict.Set("isAutoRepeat", (in.modifiers & Modifiers::IsAutoRepeat) != 0);
|
||||
dict.Set("shift", (in.modifiers & Modifiers::ShiftKey) != 0);
|
||||
dict.Set("control", (in.modifiers & Modifiers::ControlKey) != 0);
|
||||
dict.Set("alt", (in.modifiers & Modifiers::AltKey) != 0);
|
||||
dict.Set("meta", (in.modifiers & Modifiers::MetaKey) != 0);
|
||||
|
||||
return dict.GetHandle();
|
||||
}
|
||||
|
||||
bool Converter<blink::WebMouseEvent>::FromV8(
|
||||
v8::Isolate* isolate, v8::Local<v8::Value> val, blink::WebMouseEvent* out) {
|
||||
mate::Dictionary dict;
|
||||
|
||||
@@ -45,6 +45,8 @@ template<>
|
||||
struct Converter<content::NativeWebKeyboardEvent> {
|
||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
||||
content::NativeWebKeyboardEvent* out);
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const content::NativeWebKeyboardEvent& in);
|
||||
};
|
||||
|
||||
template<>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/trace_event/trace_event.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/common/content_paths.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
@@ -239,8 +240,15 @@ void NodeBindings::UvRunOnce() {
|
||||
v8::MicrotasksScope script_scope(env->isolate(),
|
||||
v8::MicrotasksScope::kRunMicrotasks);
|
||||
|
||||
if (!is_browser_)
|
||||
TRACE_EVENT_BEGIN0("devtools.timeline", "FunctionCall");
|
||||
|
||||
// Deal with uv events.
|
||||
int r = uv_run(uv_loop_, UV_RUN_NOWAIT);
|
||||
|
||||
if (!is_browser_)
|
||||
TRACE_EVENT_END0("devtools.timeline", "FunctionCall");
|
||||
|
||||
if (r == 0)
|
||||
message_loop_->QuitWhenIdle(); // Quit from uv.
|
||||
|
||||
|
||||
@@ -99,7 +99,10 @@ const char kPreloadURL[] = "preloadURL";
|
||||
// Enable the node integration.
|
||||
const char kNodeIntegration[] = "nodeIntegration";
|
||||
|
||||
// Instancd ID of guest WebContents.
|
||||
// Enable context isolation of Electron APIs and preload script
|
||||
const char kContextIsolation[] = "contextIsolation";
|
||||
|
||||
// Instance ID of guest WebContents.
|
||||
const char kGuestInstanceID[] = "guestInstanceId";
|
||||
|
||||
// Web runtime features.
|
||||
@@ -144,6 +147,9 @@ const char kStandardSchemes[] = "standard-schemes";
|
||||
// Register schemes to handle service worker.
|
||||
const char kRegisterServiceWorkerSchemes[] = "register-service-worker-schemes";
|
||||
|
||||
// Register schemes as secure.
|
||||
const char kSecureSchemes[] = "secure-schemes";
|
||||
|
||||
// The minimum SSL/TLS version ("tls1", "tls1.1", or "tls1.2") that
|
||||
// TLS fallback will accept.
|
||||
const char kSSLVersionFallbackMin[] = "ssl-version-fallback-min";
|
||||
@@ -155,14 +161,16 @@ const char kCipherSuiteBlacklist[] = "cipher-suite-blacklist";
|
||||
const char kAppUserModelId[] = "app-user-model-id";
|
||||
|
||||
// The command line switch versions of the options.
|
||||
const char kBackgroundColor[] = "background-color";
|
||||
const char kZoomFactor[] = "zoom-factor";
|
||||
const char kPreloadScript[] = "preload";
|
||||
const char kPreloadURL[] = "preload-url";
|
||||
const char kNodeIntegration[] = "node-integration";
|
||||
const char kGuestInstanceID[] = "guest-instance-id";
|
||||
const char kOpenerID[] = "opener-id";
|
||||
const char kScrollBounce[] = "scroll-bounce";
|
||||
const char kBackgroundColor[] = "background-color";
|
||||
const char kZoomFactor[] = "zoom-factor";
|
||||
const char kPreloadScript[] = "preload";
|
||||
const char kPreloadURL[] = "preload-url";
|
||||
const char kNodeIntegration[] = "node-integration";
|
||||
const char kContextIsolation[] = "context-isolation";
|
||||
const char kGuestInstanceID[] = "guest-instance-id";
|
||||
const char kOpenerID[] = "opener-id";
|
||||
const char kScrollBounce[] = "scroll-bounce";
|
||||
const char kHiddenPage[] = "hidden-page";
|
||||
|
||||
// Widevine options
|
||||
// Path to Widevine CDM binaries.
|
||||
|
||||
@@ -54,6 +54,7 @@ extern const char kZoomFactor[];
|
||||
extern const char kPreloadScript[];
|
||||
extern const char kPreloadURL[];
|
||||
extern const char kNodeIntegration[];
|
||||
extern const char kContextIsolation[];
|
||||
extern const char kGuestInstanceID[];
|
||||
extern const char kExperimentalFeatures[];
|
||||
extern const char kExperimentalCanvasFeatures[];
|
||||
@@ -76,6 +77,7 @@ extern const char kPpapiFlashVersion[];
|
||||
extern const char kDisableHttpCache[];
|
||||
extern const char kStandardSchemes[];
|
||||
extern const char kRegisterServiceWorkerSchemes[];
|
||||
extern const char kSecureSchemes[];
|
||||
extern const char kSSLVersionFallbackMin[];
|
||||
extern const char kCipherSuiteBlacklist[];
|
||||
extern const char kAppUserModelId[];
|
||||
@@ -85,9 +87,11 @@ extern const char kZoomFactor[];
|
||||
extern const char kPreloadScript[];
|
||||
extern const char kPreloadURL[];
|
||||
extern const char kNodeIntegration[];
|
||||
extern const char kContextIsolation[];
|
||||
extern const char kGuestInstanceID[];
|
||||
extern const char kOpenerID[];
|
||||
extern const char kScrollBounce[];
|
||||
extern const char kHiddenPage[];
|
||||
|
||||
extern const char kWidevineCdmPath[];
|
||||
extern const char kWidevineCdmVersion[];
|
||||
|
||||
@@ -133,6 +133,7 @@ void WebFrame::SetSpellCheckProvider(mate::Arguments* args,
|
||||
}
|
||||
|
||||
void WebFrame::RegisterURLSchemeAsSecure(const std::string& scheme) {
|
||||
// TODO(pfrazee): Remove 2.0
|
||||
// Register scheme to secure list (https, wss, data).
|
||||
blink::WebSecurityPolicy::registerURLSchemeAsSecure(
|
||||
blink::WebString::fromUTF8(scheme));
|
||||
@@ -165,6 +166,7 @@ void WebFrame::RegisterURLSchemeAsPrivileged(const std::string& scheme,
|
||||
// Register scheme to privileged list (https, wss, data, chrome-extension)
|
||||
blink::WebString privileged_scheme(blink::WebString::fromUTF8(scheme));
|
||||
if (secure) {
|
||||
// TODO(pfrazee): Remove 2.0
|
||||
blink::WebSecurityPolicy::registerURLSchemeAsSecure(privileged_scheme);
|
||||
}
|
||||
if (bypassCSP) {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "atom/renderer/atom_renderer_client.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/trace_event/trace_event.h"
|
||||
#include "content/public/renderer/render_view.h"
|
||||
#include "ipc/ipc_message_macros.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
@@ -75,6 +76,7 @@ AtomRenderViewObserver::AtomRenderViewObserver(
|
||||
content::RenderView* render_view,
|
||||
AtomRendererClient* renderer_client)
|
||||
: content::RenderViewObserver(render_view),
|
||||
renderer_client_(renderer_client),
|
||||
document_created_(false) {
|
||||
// Initialise resource for directory listing.
|
||||
net::NetModule::SetResourceProvider(NetResourceProvider);
|
||||
@@ -92,7 +94,7 @@ void AtomRenderViewObserver::EmitIPCEvent(blink::WebFrame* frame,
|
||||
v8::Isolate* isolate = blink::mainThreadIsolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
||||
v8::Local<v8::Context> context = frame->mainWorldScriptContext();
|
||||
v8::Local<v8::Context> context = renderer_client_->GetContext(frame, isolate);
|
||||
v8::Context::Scope context_scope(context);
|
||||
|
||||
// Only emit IPC event for context with node integration.
|
||||
@@ -102,6 +104,7 @@ void AtomRenderViewObserver::EmitIPCEvent(blink::WebFrame* frame,
|
||||
|
||||
v8::Local<v8::Object> ipc;
|
||||
if (GetIPCObject(isolate, context, &ipc)) {
|
||||
TRACE_EVENT0("devtools.timeline", "FunctionCall");
|
||||
auto args_vector = ListValueToVector(isolate, args);
|
||||
// Insert the Event object, event.sender is ipc.
|
||||
mate::Dictionary event = mate::Dictionary::CreateEmpty(isolate);
|
||||
|
||||
@@ -40,6 +40,8 @@ class AtomRenderViewObserver : public content::RenderViewObserver {
|
||||
const base::string16& channel,
|
||||
const base::ListValue& args);
|
||||
|
||||
AtomRendererClient* renderer_client_;
|
||||
|
||||
// Whether the document object has been created.
|
||||
bool document_created_;
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom_natives.h" // NOLINT: This file is generated with js2c
|
||||
|
||||
#include "atom/common/api/api_messages.h"
|
||||
#include "atom/common/api/atom_bindings.h"
|
||||
#include "atom/common/api/event_emitter_caller.h"
|
||||
@@ -14,6 +16,7 @@
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "atom/common/node_bindings.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "atom/renderer/api/atom_api_renderer_ipc.h"
|
||||
#include "atom/renderer/atom_render_view_observer.h"
|
||||
#include "atom/renderer/content_settings_observer.h"
|
||||
#include "atom/renderer/guest_view_container.h"
|
||||
@@ -57,6 +60,17 @@ namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
enum World {
|
||||
MAIN_WORLD = 0,
|
||||
// Use a high number far away from 0 to not collide with any other world
|
||||
// IDs created internally by Chrome.
|
||||
ISOLATED_WORLD = 999
|
||||
};
|
||||
|
||||
enum ExtensionGroup {
|
||||
MAIN_GROUP = 1
|
||||
};
|
||||
|
||||
// Helper class to forward the messages to the client.
|
||||
class AtomRenderFrameObserver : public content::RenderFrameObserver {
|
||||
public:
|
||||
@@ -64,7 +78,6 @@ class AtomRenderFrameObserver : public content::RenderFrameObserver {
|
||||
AtomRendererClient* renderer_client)
|
||||
: content::RenderFrameObserver(frame),
|
||||
render_frame_(frame),
|
||||
world_id_(-1),
|
||||
renderer_client_(renderer_client) {}
|
||||
|
||||
// content::RenderFrameObserver:
|
||||
@@ -72,19 +85,82 @@ class AtomRenderFrameObserver : public content::RenderFrameObserver {
|
||||
renderer_client_->DidClearWindowObject(render_frame_);
|
||||
}
|
||||
|
||||
void CreateIsolatedWorldContext() {
|
||||
// This maps to the name shown in the context combo box in the Console tab
|
||||
// of the dev tools.
|
||||
render_frame_->GetWebFrame()->setIsolatedWorldHumanReadableName(
|
||||
World::ISOLATED_WORLD,
|
||||
blink::WebString::fromUTF8("Electron Isolated Context"));
|
||||
|
||||
blink::WebScriptSource source("void 0");
|
||||
render_frame_->GetWebFrame()->executeScriptInIsolatedWorld(
|
||||
World::ISOLATED_WORLD, &source, 1, ExtensionGroup::MAIN_GROUP);
|
||||
}
|
||||
|
||||
void SetupMainWorldOverrides(v8::Handle<v8::Context> context) {
|
||||
// Setup window overrides in the main world context
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
|
||||
// Wrap the bundle into a function that receives the binding object as
|
||||
// an argument.
|
||||
std::string bundle(node::isolated_bundle_native,
|
||||
node::isolated_bundle_native + sizeof(node::isolated_bundle_native));
|
||||
std::string wrapper = "(function (binding) {\n" + bundle + "\n})";
|
||||
auto script = v8::Script::Compile(
|
||||
mate::ConvertToV8(isolate, wrapper)->ToString());
|
||||
auto func = v8::Handle<v8::Function>::Cast(
|
||||
script->Run(context).ToLocalChecked());
|
||||
|
||||
auto binding = v8::Object::New(isolate);
|
||||
api::Initialize(binding, v8::Null(isolate), context, nullptr);
|
||||
|
||||
// Pass in CLI flags needed to setup window
|
||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
mate::Dictionary dict(isolate, binding);
|
||||
if (command_line->HasSwitch(switches::kGuestInstanceID))
|
||||
dict.Set(options::kGuestInstanceID,
|
||||
command_line->GetSwitchValueASCII(switches::kGuestInstanceID));
|
||||
if (command_line->HasSwitch(switches::kOpenerID))
|
||||
dict.Set(options::kOpenerID,
|
||||
command_line->GetSwitchValueASCII(switches::kOpenerID));
|
||||
dict.Set("hiddenPage", command_line->HasSwitch(switches::kHiddenPage));
|
||||
|
||||
v8::Local<v8::Value> args[] = { binding };
|
||||
ignore_result(func->Call(context, v8::Null(isolate), 1, args));
|
||||
}
|
||||
|
||||
bool IsMainWorld(int world_id) {
|
||||
return world_id == World::MAIN_WORLD;
|
||||
}
|
||||
|
||||
bool IsIsolatedWorld(int world_id) {
|
||||
return world_id == World::ISOLATED_WORLD;
|
||||
}
|
||||
|
||||
bool ShouldNotifyClient(int world_id) {
|
||||
if (renderer_client_->isolated_world() && render_frame_->IsMainFrame())
|
||||
return IsIsolatedWorld(world_id);
|
||||
else
|
||||
return IsMainWorld(world_id);
|
||||
}
|
||||
|
||||
void DidCreateScriptContext(v8::Handle<v8::Context> context,
|
||||
int extension_group,
|
||||
int world_id) override {
|
||||
if (world_id_ != -1 && world_id_ != world_id)
|
||||
return;
|
||||
world_id_ = world_id;
|
||||
renderer_client_->DidCreateScriptContext(context, render_frame_);
|
||||
if (ShouldNotifyClient(world_id))
|
||||
renderer_client_->DidCreateScriptContext(context, render_frame_);
|
||||
|
||||
if (renderer_client_->isolated_world() && IsMainWorld(world_id)
|
||||
&& render_frame_->IsMainFrame()) {
|
||||
CreateIsolatedWorldContext();
|
||||
SetupMainWorldOverrides(context);
|
||||
}
|
||||
}
|
||||
|
||||
void WillReleaseScriptContext(v8::Local<v8::Context> context,
|
||||
int world_id) override {
|
||||
if (world_id_ != world_id)
|
||||
return;
|
||||
renderer_client_->WillReleaseScriptContext(context, render_frame_);
|
||||
if (ShouldNotifyClient(world_id))
|
||||
renderer_client_->WillReleaseScriptContext(context, render_frame_);
|
||||
}
|
||||
|
||||
void OnDestruct() override {
|
||||
@@ -93,7 +169,6 @@ class AtomRenderFrameObserver : public content::RenderFrameObserver {
|
||||
|
||||
private:
|
||||
content::RenderFrame* render_frame_;
|
||||
int world_id_;
|
||||
AtomRendererClient* renderer_client_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomRenderFrameObserver);
|
||||
@@ -121,21 +196,25 @@ bool IsDevToolsExtension(content::RenderFrame* render_frame) {
|
||||
.SchemeIs("chrome-extension");
|
||||
}
|
||||
|
||||
std::vector<std::string> ParseSchemesCLISwitch(const char* switch_name) {
|
||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
std::string custom_schemes = command_line->GetSwitchValueASCII(switch_name);
|
||||
return base::SplitString(
|
||||
custom_schemes, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
AtomRendererClient::AtomRendererClient()
|
||||
: node_bindings_(NodeBindings::Create(false)),
|
||||
atom_bindings_(new AtomBindings) {
|
||||
isolated_world_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kContextIsolation);
|
||||
// Parse --standard-schemes=scheme1,scheme2
|
||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
std::string custom_schemes = command_line->GetSwitchValueASCII(
|
||||
switches::kStandardSchemes);
|
||||
if (!custom_schemes.empty()) {
|
||||
std::vector<std::string> schemes_list = base::SplitString(
|
||||
custom_schemes, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
|
||||
for (const std::string& scheme : schemes_list)
|
||||
url::AddStandardScheme(scheme.c_str(), url::SCHEME_WITHOUT_PORT);
|
||||
}
|
||||
std::vector<std::string> standard_schemes_list =
|
||||
ParseSchemesCLISwitch(switches::kStandardSchemes);
|
||||
for (const std::string& scheme : standard_schemes_list)
|
||||
url::AddStandardScheme(scheme.c_str(), url::SCHEME_WITHOUT_PORT);
|
||||
}
|
||||
|
||||
AtomRendererClient::~AtomRendererClient() {
|
||||
@@ -182,6 +261,13 @@ void AtomRendererClient::RenderFrameCreated(
|
||||
// Allow file scheme to handle service worker by default.
|
||||
// FIXME(zcbenz): Can this be moved elsewhere?
|
||||
blink::WebSecurityPolicy::registerURLSchemeAsAllowingServiceWorkers("file");
|
||||
|
||||
// Parse --secure-schemes=scheme1,scheme2
|
||||
std::vector<std::string> secure_schemes_list =
|
||||
ParseSchemesCLISwitch(switches::kSecureSchemes);
|
||||
for (const std::string& secure_scheme : secure_schemes_list)
|
||||
blink::WebSecurityPolicy::registerURLSchemeAsSecure(
|
||||
blink::WebString::fromUTF8(secure_scheme));
|
||||
}
|
||||
|
||||
void AtomRendererClient::RenderViewCreated(content::RenderView* render_view) {
|
||||
@@ -327,4 +413,13 @@ void AtomRendererClient::AddSupportedKeySystems(
|
||||
AddChromeKeySystems(key_systems);
|
||||
}
|
||||
|
||||
v8::Local<v8::Context> AtomRendererClient::GetContext(
|
||||
blink::WebFrame* frame, v8::Isolate* isolate) {
|
||||
if (isolated_world())
|
||||
return frame->worldScriptContext(
|
||||
isolate, World::ISOLATED_WORLD, ExtensionGroup::MAIN_GROUP);
|
||||
else
|
||||
return frame->mainWorldScriptContext();
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -27,6 +27,11 @@ class AtomRendererClient : public content::ContentRendererClient {
|
||||
void WillReleaseScriptContext(
|
||||
v8::Handle<v8::Context> context, content::RenderFrame* render_frame);
|
||||
|
||||
// Get the context that the Electron API is running in.
|
||||
v8::Local<v8::Context> GetContext(
|
||||
blink::WebFrame* frame, v8::Isolate* isolate);
|
||||
bool isolated_world() { return isolated_world_; }
|
||||
|
||||
private:
|
||||
enum NodeIntegration {
|
||||
ALL,
|
||||
@@ -64,6 +69,7 @@ class AtomRendererClient : public content::ContentRendererClient {
|
||||
std::unique_ptr<NodeBindings> node_bindings_;
|
||||
std::unique_ptr<AtomBindings> atom_bindings_;
|
||||
std::unique_ptr<PreferencesManager> preferences_manager_;
|
||||
bool isolated_world_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomRendererClient);
|
||||
};
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "atom/renderer/api/atom_api_renderer_ipc.h"
|
||||
#include "atom/renderer/atom_render_view_observer.h"
|
||||
#include "base/command_line.h"
|
||||
#include "chrome/renderer/printing/print_web_view_helper.h"
|
||||
#include "content/public/renderer/render_frame.h"
|
||||
#include "content/public/renderer/render_frame_observer.h"
|
||||
#include "content/public/renderer/render_view.h"
|
||||
@@ -126,6 +127,7 @@ void AtomSandboxedRendererClient::RenderFrameCreated(
|
||||
|
||||
void AtomSandboxedRendererClient::RenderViewCreated(
|
||||
content::RenderView* render_view) {
|
||||
new printing::PrintWebViewHelper(render_view);
|
||||
new AtomSandboxedRenderViewObserver(render_view, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,9 @@
|
||||
|
||||
BrowserProcess* g_browser_process = NULL;
|
||||
|
||||
BrowserProcess::BrowserProcess() {
|
||||
BrowserProcess::BrowserProcess()
|
||||
: print_job_manager_(new printing::PrintJobManager) {
|
||||
g_browser_process = this;
|
||||
|
||||
print_job_manager_.reset(new printing::PrintJobManager);
|
||||
}
|
||||
|
||||
BrowserProcess::~BrowserProcess() {
|
||||
|
||||
99
docs-translations/cz/README.md
Normal file
99
docs-translations/cz/README.md
Normal file
@@ -0,0 +1,99 @@
|
||||
Ujistěte se, že budete používat dokumenty, které jsou určeny pro verzi Electronu, který používáte.
|
||||
Číslo verze by měla být součástí adresy URL stránky. Pokud tomu tak není, pravděpodobně používáte
|
||||
dokumentaci vývojové větve, která může obsahovat změny v API, a ty nejsou kompatibilní s vaší verzí Electronu.
|
||||
Chcete-li zobrazit starší verze dokumentace, můžete je procházet podle tagů na GitHub, a to otevřením "přepínač větve / tagu", který odpovídá vaší verzi.
|
||||
|
||||
## FAQ / Často kladené dotazy
|
||||
|
||||
There are questions that are asked quite often. Check this out before creating
|
||||
an issue:
|
||||
|
||||
* [Electron FAQ](faq.md)
|
||||
|
||||
## Návody
|
||||
|
||||
* [Supported Platforms](tutorial/supported-platforms.md)
|
||||
* [Security](tutorial/security.md)
|
||||
* [Electron Versioning](tutorial/electron-versioning.md)
|
||||
* [Application Distribution](tutorial/application-distribution.md)
|
||||
* [Mac App Store Submission Guide](tutorial/mac-app-store-submission-guide.md)
|
||||
* [Windows Store Guide](tutorial/windows-store-guide.md)
|
||||
* [Application Packaging](tutorial/application-packaging.md)
|
||||
* [Using Native Node Modules](tutorial/using-native-node-modules.md)
|
||||
* [Debugging Main Process](tutorial/debugging-main-process.md)
|
||||
* [Using Selenium and WebDriver](tutorial/using-selenium-and-webdriver.md)
|
||||
* [DevTools Extension](tutorial/devtools-extension.md)
|
||||
* [Using Pepper Flash Plugin](tutorial/using-pepper-flash-plugin.md)
|
||||
* [Using Widevine CDM Plugin](tutorial/using-widevine-cdm-plugin.md)
|
||||
* [Testing on Headless CI Systems (Travis, Jenkins)](tutorial/testing-on-headless-ci.md)
|
||||
* [Offscreen Rendering](tutorial/offscreen-rendering.md)
|
||||
|
||||
## Tutoriály
|
||||
|
||||
* [Quick Start](tutorial/quick-start.md)
|
||||
* [Desktop Environment Integration](tutorial/desktop-environment-integration.md)
|
||||
* [Online/Offline Event Detection](tutorial/online-offline-events.md)
|
||||
* [REPL](tutorial/repl.md)
|
||||
|
||||
## API Reference
|
||||
|
||||
* [Synopsis](api/synopsis.md)
|
||||
* [Process Object](api/process.md)
|
||||
* [Supported Chrome Command Line Switches](api/chrome-command-line-switches.md)
|
||||
* [Environment Variables](api/environment-variables.md)
|
||||
|
||||
### Volitelné DOM Elementy:
|
||||
|
||||
* [`File` Object](api/file-object.md)
|
||||
* [`<webview>` Tag](api/web-view-tag.md)
|
||||
* [`window.open` Function](api/window-open.md)
|
||||
|
||||
### Moduly pro Main Process:
|
||||
|
||||
* [app](api/app.md)
|
||||
* [autoUpdater](api/auto-updater.md)
|
||||
* [BrowserWindow](api/browser-window.md)
|
||||
* [contentTracing](api/content-tracing.md)
|
||||
* [dialog](api/dialog.md)
|
||||
* [globalShortcut](api/global-shortcut.md)
|
||||
* [ipcMain](api/ipc-main.md)
|
||||
* [Menu](api/menu.md)
|
||||
* [MenuItem](api/menu-item.md)
|
||||
* [net](api/net.md)
|
||||
* [powerMonitor](api/power-monitor.md)
|
||||
* [powerSaveBlocker](api/power-save-blocker.md)
|
||||
* [protocol](api/protocol.md)
|
||||
* [session](api/session.md)
|
||||
* [systemPreferences](api/system-preferences.md)
|
||||
* [Tray](api/tray.md)
|
||||
* [webContents](api/web-contents.md)
|
||||
|
||||
### Moduly pro Renderer Process (Web Page):
|
||||
|
||||
* [desktopCapturer](api/desktop-capturer.md)
|
||||
* [ipcRenderer](api/ipc-renderer.md)
|
||||
* [remote](api/remote.md)
|
||||
* [webFrame](api/web-frame.md)
|
||||
|
||||
### Moduly pro Both Processes:
|
||||
|
||||
* [clipboard](api/clipboard.md)
|
||||
* [crashReporter](api/crash-reporter.md)
|
||||
* [nativeImage](api/native-image.md)
|
||||
* [screen](api/screen.md)
|
||||
* [shell](api/shell.md)
|
||||
|
||||
## Vývoj
|
||||
|
||||
* [Coding Style](development/coding-style.md)
|
||||
* [Using clang-format on C++ Code](development/clang-format.md)
|
||||
* [Source Code Directory Structure](development/source-code-directory-structure.md)
|
||||
* [Technical Differences to NW.js (formerly node-webkit)](development/atom-shell-vs-node-webkit.md)
|
||||
* [Build System Overview](development/build-system-overview.md)
|
||||
* [Build Instructions (macOS)](development/build-instructions-osx.md)
|
||||
* [Build Instructions (Windows)](development/build-instructions-windows.md)
|
||||
* [Build Instructions (Linux)](development/build-instructions-linux.md)
|
||||
* [Debug Instructions (macOS)](development/debugging-instructions-macos.md)
|
||||
* [Debug Instructions (Windows)](development/debug-instructions-windows.md)
|
||||
* [Setting Up Symbol Server in debugger](development/setting-up-symbol-server.md)
|
||||
* [Documentation Styleguide](styleguide.md)
|
||||
@@ -24,7 +24,7 @@
|
||||
### Elementos DOM personalizados:
|
||||
|
||||
* [Objeto `File`](../../docs/api/file-object.md)
|
||||
* [Etiqueta `<webview>`](../../docs/api/web-view-tag.md)
|
||||
* [Etiqueta `<webview>`](../../docs/api/webview-tag.md)
|
||||
* [Función `window.open`](../../docs/api/window-open.md)
|
||||
|
||||
### Módulos del Proceso Principal:
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
Siga las siguientes pautas para la construcción de Electron en Linux.
|
||||
#Requisitos previos
|
||||
|
||||
* Python 2.7.x. Algunas distribuciones como CentOS siguen utilizando Python 2.6.x por lo que puede que tenga que comprobar su versión de Python con `Python -V`.
|
||||
* Python 2.7.x. Algunas distribuciones como CentOS 6.x siguen utilizando Python 2.6.x por lo que puede que tenga que comprobar su versión de Python con `Python -V`.
|
||||
* Node.js v0.12.x. Hay varias formas de instalar Node. Puede descargar el código fuente de Node.js y compilar desde las fuentes. Si lo hace, permite la instalación de Node en el directorio personal como usuario estándar. O intentar de repositorios como NodeSource.
|
||||
* Clang 3.4 o mayor.
|
||||
* Cabeceras de desarrollo de GTK + y libnotify.
|
||||
|
||||
|
||||
En Ubuntu, instalar las siguientes bibliotecas:
|
||||
|
||||
`$ sudo apt-get install build-essential clang libdbus-1-dev libgtk2.0-dev \
|
||||
@@ -15,11 +15,19 @@ En Ubuntu, instalar las siguientes bibliotecas:
|
||||
libasound2-dev libcap-dev libcups2-dev libxtst-dev \
|
||||
libxss1 libnss3-dev gcc-multilib g++-multilib`
|
||||
|
||||
En RHEL / CentOS, instale las siguientes bibliotecas:
|
||||
|
||||
`$ sudo yum install clang dbus-devel gtk2-devel libnotify-devel \
|
||||
libgnome-keyring-devel xorg-x11-server-utils libcap-devel \
|
||||
cups-devel libXtst-devel alsa-lib-devel libXrandr-devel \
|
||||
GConf2-devel nss-devel`
|
||||
|
||||
En Fedora, instale las siguientes bibliotecas:
|
||||
|
||||
`$ sudo yum install clang dbus-devel gtk2-devel libnotify-devel libgnome-keyring-devel \
|
||||
xorg-x11-server-utils libcap-devel cups-devel libXtst-devel \
|
||||
alsa-lib-devel libXrandr-devel GConf2-devel nss-devel`
|
||||
`$ sudo dnf install clang dbus-devel gtk2-devel libnotify-devel \
|
||||
libgnome-keyring-devel xorg-x11-server-utils libcap-devel \
|
||||
cups-devel libXtst-devel alsa-lib-devel libXrandr-devel \
|
||||
GConf2-devel nss-devel`
|
||||
|
||||
Otras distribuciones pueden ofrecer paquetes similares para la instalación, a través de gestores de paquetes como el pacman. O puede compilarlo a partir del código fuente.
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ dans la FAQ :
|
||||
### Eléments DOM Personnalisés:
|
||||
|
||||
* [Objet `File`](api/file-object.md)
|
||||
* [Tag `<webview>`](api/web-view-tag.md)
|
||||
* [Tag `<webview>`](api/webview-tag.md)
|
||||
* [Fonction `window.open`](api/window-open.md)
|
||||
|
||||
### Modules pour le Processus Principal :
|
||||
|
||||
14
docs-translations/fr-FR/tutorial/electron-versioning.md
Normal file
14
docs-translations/fr-FR/tutorial/electron-versioning.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# Versionage d'Electron
|
||||
|
||||
Si vous êtes un développeur Node expérimenté, vous êtes sûrement au courant de `semver` - et pourrez l'utiliser pour donner à vos systèmes de gestion de dépendences seulement des lignes directrices générales plutôt que des numéros de version fixes. En raison d'une forte dépendence avec Node et
|
||||
Chromium, Electron est dans une position quelque peu difficile et ne suit pas
|
||||
semver. Vous devez donc toujours faire référence à une version spécifique d'Electron.
|
||||
|
||||
Les numéros de version sont mis à jour selon les règle suivantes:
|
||||
|
||||
* Majeur: Pour les gros changements entrainant des ruptures dans l'API d'Electron - Si vous passez de la version `0.37.0`
|
||||
à `1.0.0`, vous devrez effectuer une migration de votre application.
|
||||
* Mineur: Pour des changements majeurs de Chrome et des changements mineur de Node; ou des changements important d'Electron - si vous mettez à jour de `1.0.0` vers `1.1.0`, le plus gros de votre application fonctionnera, seul de petits changements seront à effectuer.
|
||||
* Patch: Pour de nouvelles fonctionalités et des résolutions de bugs - si vous passez de la version `1.0.0` à `1.0.1`, votre application continuera de s'exécuter telle quelle.
|
||||
|
||||
Si vous utilisez `electron` ou `electron-prebuilt`, nous vous recommandons de fixer le numéro de version (`1.1.0` instead of `^1.1.0`) pour être sûr que toutes les mises à jour d'Electron sont une opération manuelle faite par vous, le développeur.
|
||||
247
docs-translations/fr-FR/tutorial/quick-start.md
Normal file
247
docs-translations/fr-FR/tutorial/quick-start.md
Normal file
@@ -0,0 +1,247 @@
|
||||
# Démarrage Rapide
|
||||
|
||||
Electron vous permet de créer des applications de bureau avec du JavaScript
|
||||
fournissant un runtime avec des API riches natives (système d'exploitation).
|
||||
Vous pourriez le voir comme une variante d'un Node.js directement exécutable
|
||||
sur le bureau au lieu des serveurs Web.
|
||||
|
||||
Cela ne signifie pas que Electron est une liaison JavaScript à l'interface
|
||||
utilisateur graphique (GUI). Au lieu de cela, Electron utilise des pages
|
||||
Web comme GUI, donc vous pouvez aussi le voir comme un navigateur minimal
|
||||
Chromium, contrôlé par JavaScript.
|
||||
|
||||
### Processus principal
|
||||
|
||||
Dans Electron, le processus qui exécute le script `main` de` package.json`
|
||||
est appelé __ le processus principal__. Le script qui s'exécute dans le
|
||||
processus principal peut afficher une interface graphique en créant des
|
||||
pages Web.
|
||||
|
||||
### Processus de rendu
|
||||
|
||||
Puisque Electron utilise Chromium pour afficher des pages Web, Chromium
|
||||
Multi-process architecture est également utilisé. Chaque page Web d'Electron
|
||||
fonctionne avec son propre processus, qui est appelé __le processus de rendu.__.
|
||||
|
||||
Dans les navigateurs normaux, les pages Web sont habituellement exécutées
|
||||
dans un environnement aux ressources indépendantes. Les utilisateurs d'électrons
|
||||
ont cependant le pouvoir d'utiliser les API Node.js dans des pages Web permettant
|
||||
un système d'exploitation de niveau inférieur d'interactions.
|
||||
|
||||
### Différences entre le processus principal et le processus de rendu
|
||||
|
||||
Le processus principal crée des pages Web en créant des instances `BrowserWindow`.
|
||||
Chaque instance `BrowserWindow` exécute la page Web dans son propre processus
|
||||
de rendu. Lorsqu'une occurrence `BrowserWindow` est détruite, le processus
|
||||
de rendu correspondant est également terminée.
|
||||
|
||||
Le processus principal gère toutes les pages Web et leur processus rendu correspondant.
|
||||
Chaque processus de rendu est isolé et ne se soucie que de la page Web en cours
|
||||
d'exécution.
|
||||
|
||||
Dans les pages Web, l'appel des API relatives aux GUI natives n'est pas autorisé
|
||||
car la gestion des ressources natives GUI dans les pages Web sont très dangereuse,
|
||||
il est facile de perdre des ressources. Si vous souhaitez effectuer des opérations
|
||||
GUI dans une page Web, le Processus de la page Web doit communiquer avec le
|
||||
processus principal pour lui demander d'effectur ces opérations.
|
||||
|
||||
Dans Electron, nous avons plusieurs façons de communiquer entre le processus principal et
|
||||
le processeurs. Comme [`ipcRenderer`] (../ api / ipc-renderer.md) et [`IpcMain`]
|
||||
(../ api / ipc-main.md) pour envoyer des messages, et les [Remote] (../ api / remote.md)
|
||||
pour la communication de style RPC. Il y a aussi une entrée de FAQ sur
|
||||
[comment partager des données entre des pages Web] [share-data].
|
||||
|
||||
## Écrivez votre première application Electron
|
||||
|
||||
Généralement, une application Electron est structurée comme ceci:
|
||||
|
||||
```text
|
||||
your-app/
|
||||
├── package.json
|
||||
├── main.js
|
||||
└── index.html
|
||||
```
|
||||
|
||||
Le format de `package.json` est exactement le même que celui des modules de Node, et
|
||||
le script spécifié par le champ `main` est le script de démarrage de votre application,
|
||||
qui exécutera le processus principal. Un exemple de votre `package.json` peut être
|
||||
comme cela:
|
||||
|
||||
```json
|
||||
{
|
||||
"name" : "your-app",
|
||||
"version" : "0.1.0",
|
||||
"main" : "main.js"
|
||||
}
|
||||
```
|
||||
|
||||
__Note__: Si le champ `main` n'est pas présent dans` package.json`, Electron
|
||||
tenter de charger un fichier `index.js`.
|
||||
|
||||
Le fichier `main.js` devrait créer des fenêtres et gérer les événements du système.
|
||||
Exemple:
|
||||
|
||||
```javascript
|
||||
const {app, BrowserWindow} = require('electron')
|
||||
const path = require('path')
|
||||
const url = require('url')
|
||||
|
||||
// Gardez une référence globale de l'objet fenêtre, sinon, la fenêtre
|
||||
// sera automatiquement fermée lorsque l'objet JavaScript est récupéré.
|
||||
let win
|
||||
|
||||
function createWindow () {
|
||||
// Créer la fenêtre du navigateur.
|
||||
win = new BrowserWindow({width: 800, height: 600})
|
||||
|
||||
// charger index.html de l'application.
|
||||
win.loadURL(url.format({
|
||||
pathname: path.join(__dirname, 'index.html'),
|
||||
protocol: 'file:',
|
||||
slashes: true
|
||||
}))
|
||||
|
||||
// Ouvrir DevTools.
|
||||
win.webContents.openDevTools()
|
||||
|
||||
// Émis lorsque la fenêtre est fermée.
|
||||
win.on('closed', () => {
|
||||
// Déréférencer l'objet fenêtre, habituellement vous stocker des fenêtres
|
||||
// dans un tableau si votre application prend en charge plusieurs fenêtres,
|
||||
// c'est l'heure où vous devez supprimer l'élément correspondant.
|
||||
win = null
|
||||
})
|
||||
}
|
||||
|
||||
// Cette méthode sera appelée lorsque Electron aura terminé l'initialisation
|
||||
// et est prét à créer des fenêtres de navigation. Certaines API ne peuvent
|
||||
// être utilisées qu'après le lancement de cet événement.
|
||||
app.on('ready', createWindow)
|
||||
|
||||
// Quittez lorsque toutes les fenêtres sont fermées.
|
||||
app.on('window-all-closed', () => {
|
||||
// Sur macOS, il est fréquent que les applications et leur barre de menus
|
||||
// restent actives jusqu'à ce que l'utilisateur quitte explicitement avec Cmd + Q
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit()
|
||||
}
|
||||
})
|
||||
|
||||
app.on('activate', () => {
|
||||
// Sur macOS, il est fréquent de recréer une fenêtre dans l'application lorsque
|
||||
// l'icône du dock est cliquée et qu'il n'y a pas d'autres fenêtres ouvertes.
|
||||
if (win === null) {
|
||||
createWindow()
|
||||
}
|
||||
})
|
||||
|
||||
// Dans ce fichier, vous pouvez inclure le reste du code du processus principal
|
||||
// spécifique de votre application. Vous pouvez également les mettres dans des
|
||||
// fichiers distincts et les écrire ici.
|
||||
```
|
||||
|
||||
Enfin, `index.html` est la page web que vous voulez afficher:
|
||||
|
||||
```html
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Hello World!</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello World!</h1>
|
||||
Nous utilisons le noeud <script>document.write(process.versions.node)</script>,
|
||||
Chrome <script>document.write(process.versions.chrome)</script>,
|
||||
et Electron <script>document.write(process.versions.electron)</script>.
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
## Exécuter votre application
|
||||
|
||||
Une fois que vous avez créé vos fichiers `main.js`,` index.html` et `package.json`,
|
||||
vous voudriez probablement essayer d'exécuter votre application localement pour la
|
||||
tester et vous assurer qu'elle fonctionne comme prévu.
|
||||
|
||||
### `electron`
|
||||
|
||||
[`electron`](https://github.com/electron-userland/electron-prebuilt) est
|
||||
un module `npm` qui contient des versions pré-compilées d'Electron.
|
||||
|
||||
Si vous l'avez installé globalement avec `npm`, vous n'en aurez pas besoin
|
||||
dans le répertoire source de votre application:
|
||||
|
||||
```bash
|
||||
electron .
|
||||
```
|
||||
|
||||
Si vous l'avez installé localement:
|
||||
|
||||
#### macOS / Linux
|
||||
|
||||
```bash
|
||||
$ ./node_modules/.bin/electron .
|
||||
```
|
||||
|
||||
#### Windows
|
||||
|
||||
```bash
|
||||
$ .\node_modules\.bin\electron .
|
||||
```
|
||||
|
||||
### Executable d'Electron téléchargé manuellement
|
||||
|
||||
Si vous avez téléchargé Electron manuellement, vous pouvez également utiliser
|
||||
binaire pour exécuter votre application directement.
|
||||
|
||||
#### Windows
|
||||
|
||||
```bash
|
||||
$ .\electron\electron.exe your-app\
|
||||
```
|
||||
|
||||
#### Linux
|
||||
|
||||
```bash
|
||||
$ ./electron/electron your-app/
|
||||
```
|
||||
|
||||
#### macOS
|
||||
|
||||
```bash
|
||||
$ ./Electron.app/Contents/MacOS/Electron your-app/
|
||||
```
|
||||
|
||||
`Electron.app` fait partie du package de libération de l'Electron, vous pouvez
|
||||
télécharger à partir [here](https://github.com/electron/electron/releases).
|
||||
|
||||
### Exécuter en tant que distribution
|
||||
|
||||
Une fois que vous avez terminé d'écrire votre application, vous pouvez
|
||||
créer une distribution en suivant le guide [Distribuer une application]
|
||||
(./application-distribution.md) puis exécuter l'application packagée.
|
||||
|
||||
### Essayez cet exemple
|
||||
|
||||
Clonez et exécutez le code dans ce didacticiel en utilisant le
|
||||
[`electron/electron-quick-start`] (https://github.com/electron/electron-quick-start).
|
||||
|
||||
**Note**: Exécuter cela nécessite [Git](https://git-scm.com) et [Node.js](https://nodejs.org/en/download/) (que comprend [npm](https://npmjs.org)) sur votre système.
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
$ git clone https://github.com/electron/electron-quick-start
|
||||
# Go into the repository
|
||||
$ cd electron-quick-start
|
||||
# Install dependencies
|
||||
$ npm install
|
||||
# Run the app
|
||||
$ npm start
|
||||
```
|
||||
|
||||
Pour plus d'exemples app, consultez la section
|
||||
[list of boilerplates](http://electron.atom.io/community/#boilerplates)
|
||||
Créé par la communauté impressionnante d'électrons.
|
||||
|
||||
[share-data]: ../faq.md#how-to-share-data-between-web-pages
|
||||
76
docs-translations/fr-FR/tutorial/security.md
Normal file
76
docs-translations/fr-FR/tutorial/security.md
Normal file
@@ -0,0 +1,76 @@
|
||||
# Securité, Application Natives, et Votre Responsabilité
|
||||
|
||||
En tant que développeurs Web, nous avons l'habitude de bénéficier d'une sécurité élevée au niveau du navigateur - les
|
||||
risques associés au code que nous écrivons sont relativement faibles. Nos sites internet ont des droit limités au sein
|
||||
d'une sandbox, et nous faisons confiance à nos utilisateurs pour utiliser des navigateurs créés par de grosses équipes d'ingénieurs
|
||||
capables de réagir rapidement lorsqu'une faille de sécurité est découverte.
|
||||
|
||||
Quand on travaille avec Electron, il est important de comprendre qu'Electron n'est pas un navigateur web.
|
||||
Il vous permet de construire des applications de bureau riches de fonctionnalités au travers de technologies web familaires,
|
||||
mais votre code a beaucoup plus de possibilités. Javascript peut accéder au système de fichier, au shell, et plus.
|
||||
Cela vous permet de construire des applications natives de haute qualité, mais les problèmes de sécurité sont inhérents à toutes ces possibilités.
|
||||
|
||||
Avec ça en tête, soyez conscient qu'afficher du contenu arbitraire depuis des sources extérieures pose un gros risque au niveau de la sécurité qu'Electron ne peut gérer.
|
||||
En fait, les applications utilisant Electron les plus populaires (Atom, Slack, Visual Studio Code, ...etc) affichent principalement du contenu local (ou de confiance, il s'agit alors de contenu distant sécurisé sans intégration avec Node) - si votre application exécute du code depuis une source extérieur, il est de votre responsabilité de vous assurer que ce code n'est pas malveillant.
|
||||
|
||||
|
||||
## Problèmes de sécurités liés à Chromium et mises à jour
|
||||
|
||||
Tandis qu'Electron essai de supporter les nouvelles versions de Chromium dès que possible,
|
||||
les developpeurs doivent garder à l'esprit que le fait de mettre à jour l'application est une tâche laborieuse durant laquelle plusieurs douzaines, voir plusieurs centaines de fichiers doivent être modifiés à la main.
|
||||
Selon les ressources et les contributions actuelles, Electron ne fonctionnera pas toujours avec la dernière version de Chromium, un délai de quelques jours voir quelques semaines est à prévoir.
|
||||
|
||||
Nous pensons que notre système actuel de mises à jour du composant Chromium correspond à
|
||||
équilibre approprié entre les ressources dont nous disposons et les besoins de la
|
||||
majorité des applications construites autour du framework.
|
||||
Les Pull requests et les contributions supportant cet effort sont toujours les bienvenues.
|
||||
|
||||
## Ignorer les conseils précédents
|
||||
|
||||
Un problème de sécurité existe quand vous recevez du code depuis une source distante puis l'exécutez localement. Prenons comme exemple l'affichage d'un site web distant affiché à l'intérieur d'une fenêtre de navigateur.
|
||||
Si un attaquant parvient d'une quelconque façon de changer son contenu
|
||||
(soit en attaquant la source directement, ou bien en se placant entre votre application et sa destination actuelle), ils seront capables d'executer du code natif sur la machine de l'utilisateur.
|
||||
|
||||
> :warning: En aucun cas vous ne devez charger puis exécuter du code distant avec Node. A la place, utilisez seulement des fichiers locaux (regroupés avec votre application) pour exécuter du code de Node. Pour afficher du contenu distant, utilisez le tag
|
||||
`webview` et assurez vous de désactiver `nodeIntegration`.
|
||||
|
||||
#### Checklist
|
||||
|
||||
Il ne s'agit pas d'une liste exhaustive, mais au moins, pour palier aux problèmes de sécurités vous devez essayer de:
|
||||
|
||||
* Afficher seulement du contenu (https) sécurisé
|
||||
* Désactiver l'intégration de Node dans tout ce qui gère le rendu avec du contenu distant
|
||||
(using `webPreferences`)
|
||||
* Ne pas désactiver `webSecurity`. Disabling it will disable the same-origin policy.
|
||||
* Définir une [`Content-Security-Policy`](http://www.html5rocks.com/en/tutorials/security/content-security-policy/)
|
||||
, et utiliser des règles strictes (i.e. `script-src 'self'`)
|
||||
* [Surcharger et désactiver `eval`](https://github.com/nylas/N1/blob/0abc5d5defcdb057120d726b271933425b75b415/static/index.js#L6-L8)
|
||||
, qui permet à des chaines de caractères d'être exécutées comme du code.
|
||||
* Ne pas assigner `allowDisplayingInsecureContent` à true.
|
||||
* Ne pas assigner `allowRunningInsecureContent` à true.
|
||||
* Ne pas activer `experimentalFeatures` ou `experimentalCanvasFeatures` à moins d'être sûr ce que vous faites.
|
||||
* Ne pas utiliser `blinkFeatures` à moins d'être sûr ce que vous faites.
|
||||
* WebViews: Assigner `nodeintegration` à false
|
||||
* WebViews: Ne pas utiliser `disablewebsecurity`
|
||||
* WebViews: Ne pas utiliser `allowpopups`
|
||||
* WebViews: Ne pas utiliser `insertCSS` ou `executeJavaScript` avec du CSS/JS distant.
|
||||
|
||||
Encore une fois, cette liste permet de diminuer les risques de problème de sécurité, mais en aucun cas elle ne l'enlève complètement. Si votre objectif est d'afficher un site internet, choisir un navigateur sera une option plus sûre.
|
||||
|
||||
## Buffer Global
|
||||
|
||||
La classe [Buffer](https://nodejs.org/api/buffer.html) de Node est actuellement disponible
|
||||
en tant que global même quand `nodeIntegration` est à `false`. Vous pouvez le supprimer en faisant la manipulation suivante dans votre script `preload`:
|
||||
|
||||
```js
|
||||
delete global.Buffer
|
||||
```
|
||||
|
||||
Le supprimer peut casser les modules Node utilisés dans votre script preload script et votre application depuis que plusieurs librairies s'attendent à ce qu'il soit en tant que global plutôt que de le demander de manière explicite via:
|
||||
|
||||
```js
|
||||
const {Buffer} = require('buffer')
|
||||
```
|
||||
|
||||
Le `Buffer` global risque d'être supprimé dans de futures versions d'Electron.
|
||||
|
||||
@@ -4,15 +4,14 @@ Les plateformes suivantes sont supportées par Electron:
|
||||
|
||||
### macOS
|
||||
|
||||
Seulement les binaires en 64bit sont fournis sur macOS, et la version minimale de macOS suportée est macOS 10.9.
|
||||
Seuls les binaires en 64bit sont fournis sur macOS, et la version minimale de macOS suportée est macOS 10.9.
|
||||
|
||||
### Windows
|
||||
|
||||
Windows 7 et suivants sont supportés, les systèmes d'exploitation plus ancien ne sont pas supporté
|
||||
(et ne marchent pas).
|
||||
Les systèmes d'exploitations Windows 7 et supérieur sont supportés. Les versions antérieures ne sont pas supportées (et ne marchent pas).
|
||||
|
||||
Les binaires `ia32` (`x86`) et `x64` (`amd64`) sont fournis pour Windows.
|
||||
Veuillez noter que la version `ARM` de Windows n'est pas supporté à ce jour.
|
||||
Veuillez noter que la version `ARM` de Windows n'est pas supportée à ce jour.
|
||||
|
||||
### Linux
|
||||
|
||||
@@ -20,7 +19,7 @@ Les binaires précompilés `ia32` (`i686`) et `x64` (`amd64`) d'Electron sont co
|
||||
Ubuntu 12.04, le binaire `arm` est compilé à partir d'une version ARM v7 hard-float ABI et
|
||||
NEON pour Debian Wheezy.
|
||||
|
||||
Le binaire précompilé peut tourner sur une distribution si la distribution contient les librairies liées à Electron, sur la plateforme de compilation. Donc il est ganranti de pouvoir le faire marcher seulement sur Ubuntu 12.04, mais les plateformes suivantes sont aussi vérifiées comme capable de faire marcher la version précompilé des binaires d'Electron :
|
||||
Pour que les binaires pré-compilés puissent s'exécuter sur une certaine distribution, il faut que cette distribution inclut les librairies dont Electron a besoin. C'est à dire que seulement Ubuntu 12.04 est guaranti de fonctionner, même si les plateformes suivantes sont aussi verifiées et capables d'exécuter les binaires pré-compilés d'Electron:
|
||||
|
||||
* Ubuntu 12.04 et suivantes
|
||||
* Fedora 21
|
||||
|
||||
@@ -49,7 +49,7 @@ sezione prima di creare una issue:
|
||||
### Elementi personalizzati DOM:
|
||||
|
||||
* [Oggetto `File`](api/oggetto-file.md)
|
||||
* [Tag `<webview>`](api/web-view-tag.md)
|
||||
* [Tag `<webview>`](api/webview-tag.md)
|
||||
* [Funzione `window.open`](api/window-open.md)
|
||||
|
||||
### Moduli per il Processo Main:
|
||||
|
||||
@@ -44,7 +44,7 @@ _リンクになっていないリストは未翻訳のものです。_
|
||||
### カスタムDOM要素:
|
||||
|
||||
* [`File` Object](api/file-object.md)
|
||||
* [`<webview>` タグ](api/web-view-tag.md)
|
||||
* [`<webview>` タグ](api/webview-tag.md)
|
||||
* [`window.open` 関数](api/window-open.md)
|
||||
|
||||
### Main Processのモジュール:
|
||||
|
||||
@@ -396,11 +396,11 @@ Executes editing command `undo` in page.
|
||||
* `wordStart` Boolean - ワード始まりからの検索かを指定します。省略時は`false`で、語途中でもマッチします。
|
||||
* `medialCapitalAsWordStart` Boolean - `wordStart`指定時、CamelCaseの途中もワード始まりと見なすかを指定します。省略時は`false`です。
|
||||
|
||||
`text`をページ内全てから検索し、リクエストに使用するリクエストID(`Integer`)を返します。リクエストの結果は、[`found-in-page`](web-view-tag.md#event-found-in-page)イベントを介して受け取ることができます。
|
||||
`text`をページ内全てから検索し、リクエストに使用するリクエストID(`Integer`)を返します。リクエストの結果は、[`found-in-page`](webview-tag.md#event-found-in-page)イベントを介して受け取ることができます。
|
||||
|
||||
### `<webview>.stopFindInPage(action)`
|
||||
|
||||
* `action` String - [`<webview>.findInPage`](web-view-tag.md#webviewtagfindinpage)リクエストを終わらせる時にとるアクションを指定します。
|
||||
* `action` String - [`<webview>.findInPage`](webview-tag.md#webviewtagfindinpage)リクエストを終わらせる時にとるアクションを指定します。
|
||||
* `clearSelection` - 選択をクリアします。
|
||||
* `keepSelection` - 選択を通常の選択へと変換します。
|
||||
* `activateSelection` - 選択ノードにフォーカスを当て、クリックします。
|
||||
@@ -573,7 +573,7 @@ webview.addEventListener('console-message', (e) => {
|
||||
* `matches` Integer (optional) - マッチした数です。
|
||||
* `selectionArea` Object (optional) - 最初のマッチした場所です。
|
||||
|
||||
[`webview.findInPage`](web-view-tag.md#webviewtagfindinpage)リクエストで結果が得られた場合に発生します。
|
||||
[`webview.findInPage`](webview-tag.md#webviewtagfindinpage)リクエストで結果が得られた場合に発生します。
|
||||
|
||||
```javascript
|
||||
webview.addEventListener('found-in-page', (e) => {
|
||||
@@ -5,7 +5,7 @@ Linux で Electron をビルドする際は以下のガイドラインに従っ
|
||||
## 事前準備
|
||||
|
||||
* 25GB のディスク空き容量と8GB の RAM が少なくとも必要です
|
||||
* Python 2.7.xが必要です。CentOS のようないくつかのディストリビューションはまだ Python 2.6.x を使ってるので、`python -V` で Python のバージョンを確認する必要があるでしょう。
|
||||
* Python 2.7.xが必要です。CentOS 6.x のようないくつかのディストリビューションはまだ Python 2.6.x を使ってるので、`python -V` で Python のバージョンを確認する必要があるでしょう。
|
||||
* Node.js v0.12.x が必要です。Node のインストールには色んな方法があります。[Node.js](http://nodejs.org) からソースコードをダウンロードしてビルドすることもできます。そうすることで root でないユーザーのホームディレクトリに Node をインストールすることもできます。あるいは [NodeSource](https://nodesource.com/blog/nodejs-v012-iojs-and-the-nodesource-linux-repositories) のようなレポジトリを試してみてください。
|
||||
* Clang 3.4 以上が必要です。
|
||||
* GTK+ と libnotify の開発用ヘッダーが必要です。
|
||||
@@ -19,12 +19,22 @@ $ sudo apt-get install build-essential clang libdbus-1-dev libgtk2.0-dev \
|
||||
libxss1 libnss3-dev gcc-multilib g++-multilib curl
|
||||
```
|
||||
|
||||
RHEL / CentOS では以下のライブラリをインストールしてください。
|
||||
|
||||
```bash
|
||||
$ sudo yum install clang dbus-devel gtk2-devel libnotify-devel \
|
||||
libgnome-keyring-devel xorg-x11-server-utils libcap-devel \
|
||||
cups-devel libXtst-devel alsa-lib-devel libXrandr-devel \
|
||||
GConf2-devel nss-devel
|
||||
```
|
||||
|
||||
Fedora では以下のライブラリをインストールしてください。
|
||||
|
||||
```bash
|
||||
$ sudo yum install clang dbus-devel gtk2-devel libnotify-devel libgnome-keyring-devel \
|
||||
xorg-x11-server-utils libcap-devel cups-devel libXtst-devel \
|
||||
alsa-lib-devel libXrandr-devel GConf2-devel nss-devel
|
||||
$ sudo dnf install clang dbus-devel gtk2-devel libnotify-devel \
|
||||
libgnome-keyring-devel xorg-x11-server-utils libcap-devel \
|
||||
cups-devel libXtst-devel alsa-lib-devel libXrandr-devel \
|
||||
GConf2-devel nss-devel
|
||||
```
|
||||
|
||||
他のディストリビューションでは pacman のようなパッケージマネージャーを通して似たようなインストールパッケージを提供しているかもしれません。あるいはソースコードからコンパイルもできます。
|
||||
|
||||
@@ -51,7 +51,7 @@ Electron에 대해 자주 묻는 질문이 있습니다. 이슈를 생성하기
|
||||
### 커스텀 DOM 요소:
|
||||
|
||||
* [`File` 객체](api/file-object.md)
|
||||
* [`<webview>` 태그](api/web-view-tag.md)
|
||||
* [`<webview>` 태그](api/webview-tag.md)
|
||||
* [`window.open` 함수](api/window-open.md)
|
||||
|
||||
### 메인 프로세스에서 사용할 수 있는 모듈:
|
||||
|
||||
52
docs-translations/ko-KR/api/browser-window-proxy.md
Normal file
52
docs-translations/ko-KR/api/browser-window-proxy.md
Normal file
@@ -0,0 +1,52 @@
|
||||
## Class: BrowserWindowProxy
|
||||
|
||||
> 자식 브라우저 윈도우를 제어합니다.
|
||||
|
||||
프로세스: [렌더러 프로세스](../tutorial/quick-start.md#renderer-process)
|
||||
|
||||
`BrowserWindowProxy` 객체는 `window.open`에서 반환되며, 자식 윈도우와 함께 제한된 기능을 제공합니다.
|
||||
|
||||
### Instance Methods (인스턴스 메소드)
|
||||
|
||||
`BrowserWindowProxy` 객체는 다음과 같은 Instance Methods(인스턴스 메소드)가 있습니다.
|
||||
|
||||
#### `win.blur()`
|
||||
|
||||
자식 윈도우에서 포커스를 제거합니다.
|
||||
|
||||
#### `win.close()`
|
||||
|
||||
unload 이벤트를 호출하지 않고, 자식 윈도우를 강제로 종료합니다.
|
||||
|
||||
#### `win.eval(code)`
|
||||
|
||||
* `code` String
|
||||
|
||||
자식 윈도우에서 코드를 실행합니다.
|
||||
|
||||
#### `win.focus()`
|
||||
|
||||
자식 윈도우을 강조합니다 (윈도우를 앞으로 가져옵니다).
|
||||
Focuses the child window (brings the window to front).
|
||||
|
||||
#### `win.print()`
|
||||
|
||||
자식 윈도우에서 print dialog를 호출합니다.
|
||||
|
||||
#### `win.postMessage(message, targetOrigin)`
|
||||
|
||||
* `message` String
|
||||
* `targetOrigin` String
|
||||
|
||||
지정된 origin과 함께 메시지를 보냅니다. 별도의 origin이 지정되어 있지 않다면 `*`을 작성합니다.
|
||||
|
||||
이 메소드들 외에도 자식 윈도우는 속성이 없는 단일 메소드가 있는 `window.opener` 객체를 구현합니다.
|
||||
|
||||
### Instance Properties (인스턴스 속성)
|
||||
|
||||
`BrowserWindowProxy` 객체는 다음과 같은 instance properties(인스턴스 속성)를 가집니다.
|
||||
|
||||
#### `win.closed`
|
||||
|
||||
자식 윈도우가 닫힌 후에 true로 설정된 Boolean값 입니다.
|
||||
|
||||
@@ -473,12 +473,12 @@ Returns `Boolean` - 게스트 페이지 음소거 여부.
|
||||
|
||||
웹 페이지에서 `text`에 일치하는 모든 대상을 찾는 요청을 시작하고 요청에 사용된 요청을
|
||||
표현하는 `정수(integer)`를 반환합니다. 요청의 결과는
|
||||
[`found-in-page`](web-view-tag.md#event-found-in-page) 이벤트를 통해 취득할 수
|
||||
[`found-in-page`](webview-tag.md#event-found-in-page) 이벤트를 통해 취득할 수
|
||||
있습니다.
|
||||
|
||||
### `webContents.stopFindInPage(action)`
|
||||
|
||||
* `action` String - [`<webview>.findInPage`](web-view-tag.md#webviewtagfindinpage)
|
||||
* `action` String - [`<webview>.findInPage`](webview-tag.md#webviewtagfindinpage)
|
||||
요청이 종료되었을 때 일어날 수 있는 작업을 지정합니다.
|
||||
* `clearSelection` - 선택을 취소합니다.
|
||||
* `keepSelection` - 선택을 일반 선택으로 변경합니다.
|
||||
@@ -5,7 +5,7 @@
|
||||
## 빌드전 요구사양
|
||||
|
||||
* 최소한 25GB 이상의 디스크 공간과 8GB 램이 필요합니다.
|
||||
* Python 2.7.x. 몇몇 CentOS와 같은 배포판들은 아직도 Python 2.6.x 버전을 사용합니다.
|
||||
* Python 2.7.x. 몇몇 CentOS 6.x와 같은 배포판들은 아직도 Python 2.6.x 버전을 사용합니다.
|
||||
그래서 먼저 `python -V`를 통해 버전을 확인할 필요가 있습니다.
|
||||
* Node.js v0.12.x. Node를 설치하는 방법은 여러 가지가 있습니다. 먼저,
|
||||
[Node.js](http://nodejs.org) 사이트에서 소스 코드를 받아 빌드하는 방법입니다.
|
||||
@@ -26,13 +26,22 @@ $ sudo apt-get install build-essential clang libdbus-1-dev libgtk2.0-dev \
|
||||
gperf bison
|
||||
```
|
||||
|
||||
RHEL / CentOS를 사용하고 있다면 다음과 같이 라이브러리를 설치해야 합니다:
|
||||
|
||||
```bash
|
||||
$ sudo yum install clang dbus-devel gtk2-devel libnotify-devel \
|
||||
libgnome-keyring-devel xorg-x11-server-utils libcap-devel \
|
||||
cups-devel libXtst-devel alsa-lib-devel libXrandr-devel \
|
||||
GConf2-devel nss-devel
|
||||
```
|
||||
|
||||
Fedora를 사용하고 있다면 다음과 같이 라이브러리를 설치해야 합니다:
|
||||
|
||||
```bash
|
||||
$ sudo yum install clang dbus-devel gtk2-devel libnotify-devel libgnome-keyring-devel \
|
||||
xorg-x11-server-utils libcap-devel cups-devel libXtst-devel \
|
||||
alsa-lib-devel libXrandr-devel GConf2-devel nss-devel bison \
|
||||
gperf
|
||||
$ sudo dnf install clang dbus-devel gtk2-devel libnotify-devel \
|
||||
libgnome-keyring-devel xorg-x11-server-utils libcap-devel \
|
||||
cups-devel libXtst-devel alsa-lib-devel libXrandr-devel \
|
||||
GConf2-devel nss-devel
|
||||
```
|
||||
|
||||
다른 배포판의 경우 pacman 같은 패키지 매니저를 통해 패키지를 설치 할 수 있습니다.
|
||||
|
||||
@@ -41,7 +41,7 @@ Existem muitas perguntas comuns que são feitas, verifique antes de criar uma is
|
||||
### Elementos DOM Personalizados:
|
||||
|
||||
* [Objeto `File`](api/file-object.md)
|
||||
* [Tag `<webview>`](../../docs/api/web-view-tag.md)
|
||||
* [Tag `<webview>`](../../docs/api/webview-tag.md)
|
||||
* [Função `window.open`](api/window-open.md)
|
||||
|
||||
### Módulos para o Processo Principal:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
> loquear o sistema de entrar no modo de pouca energia (suspenso).
|
||||
|
||||
Processo: [Main](../tutorial/quick-start.md#main-process)
|
||||
Processo: [Main](../glossary.md#main-process)
|
||||
|
||||
Por exemplo:
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ Siga as orientações abaixo pra fazer o build do Electron no Linux.
|
||||
|
||||
## Pré-requisitos
|
||||
|
||||
* Python 2.7.x. Algumas distribuições como CentOS ainda usam Python 2.6.x,
|
||||
* Python 2.7.x. Algumas distribuições como CentOS 6.x ainda usam Python 2.6.x,
|
||||
então você precisa checar a sua versão do Python com `python -V`.
|
||||
* Node.js v0.12.x. Há várias maneiras de instalar o Node. Você pode baixar o
|
||||
código fonte do [Node.js](http://nodejs.org) e compilar a partir dele.
|
||||
Fazer isto permite que você instale o Node no seu próprio diretório home
|
||||
Fazer isto permite que você instale o Node no seu próprio diretório home
|
||||
como um usuário comum.
|
||||
Ou tente repositórios como [NodeSource](https://nodesource.com/blog/nodejs-v012-iojs-and-the-nodesource-linux-repositories).
|
||||
* Clang 3.4 ou mais recente.
|
||||
@@ -23,12 +23,22 @@ $ sudo apt-get install build-essential clang libdbus-1-dev libgtk2.0-dev \
|
||||
libxss1 libnss3-dev gcc-multilib g++-multilib
|
||||
```
|
||||
|
||||
No RHEL / CentOS, instale as seguintes bibliotecas:
|
||||
|
||||
```bash
|
||||
$ sudo yum install clang dbus-devel gtk2-devel libnotify-devel \
|
||||
libgnome-keyring-devel xorg-x11-server-utils libcap-devel \
|
||||
cups-devel libXtst-devel alsa-lib-devel libXrandr-devel \
|
||||
GConf2-devel nss-devel
|
||||
```
|
||||
|
||||
No Fedora, instale as seguintes bibliotecas:
|
||||
|
||||
```bash
|
||||
$ sudo yum install clang dbus-devel gtk2-devel libnotify-devel libgnome-keyring-devel \
|
||||
xorg-x11-server-utils libcap-devel cups-devel libXtst-devel \
|
||||
alsa-lib-devel libXrandr-devel GConf2-devel nss-devel
|
||||
$ sudo dnf install clang dbus-devel gtk2-devel libnotify-devel \
|
||||
libgnome-keyring-devel xorg-x11-server-utils libcap-devel \
|
||||
cups-devel libXtst-devel alsa-lib-devel libXrandr-devel \
|
||||
GConf2-devel nss-devel
|
||||
```
|
||||
|
||||
Outras distribuições podem oferecer pacotes similares para instalação através
|
||||
@@ -121,7 +131,7 @@ Certifique-se de que você tenha instalado todas as dependências do build.
|
||||
### Error While Loading Shared Libraries: libtinfo.so.5
|
||||
|
||||
O `clang` prebuilt irá tentar fazer o link com `libtinfo.so.5`. Dependendo
|
||||
da arquitetura do host, faça um link simbólico para o `libncurses` apropriado:
|
||||
da arquitetura do host, faça um link simbólico para o `libncurses` apropriado:
|
||||
|
||||
```bash
|
||||
$ sudo ln -s /usr/lib/libncurses.so.5 /usr/lib/libtinfo.so.5
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
### Пользовательские элементы DOM:
|
||||
|
||||
* [`File` Object](api/file-object.md)
|
||||
* [`<webview>` Tag](api/web-view-tag.md)
|
||||
* [`<webview>` Tag](api/webview-tag.md)
|
||||
* [`window.open` Function](api/window-open.md)
|
||||
|
||||
### Модули для Main Process:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Распространение приложения
|
||||
|
||||
Чтобы разпространять ваше приложение на Electron, папка с вашим приложением
|
||||
Чтобы распространять ваше приложение на Electron, папка с вашим приложением
|
||||
должна называться `app` и находиться в папке ресурсов Electron (в macOS это
|
||||
`Electron.app/Contents/Resources/`, в Linux и Windows - `resources/`),
|
||||
вот так:
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
### การปรับแต่ง DOM:
|
||||
|
||||
* [วัตถุ `File`](api/file-object.md)
|
||||
* [แท็ก `<webview>`](api/web-view-tag.md)
|
||||
* [แท็ก `<webview>`](api/webview-tag.md)
|
||||
* [ฟังก์ชัน `window.open`](api/window-open.md)
|
||||
|
||||
### โมดูลสำหรับกระบวนการหลัก :
|
||||
|
||||
@@ -37,7 +37,7 @@ Bir problem(issue) bildirmeden önce sıkça sorulan sorulara göz atın:
|
||||
### Özel DOM Elementleri:
|
||||
|
||||
* [`File` Nesnesi](api/file-object.md)
|
||||
* [`<webview>` Etiketi](https://github.com/electron/electron/tree/master/docs/api/web-view-tag.md)
|
||||
* [`<webview>` Etiketi](https://github.com/electron/electron/tree/master/docs/api/webview-tag.md)
|
||||
* [`window.open` Fonksiyonu](https://github.com/electron/electron/tree/master/docs/api/window-open.md)
|
||||
|
||||
### Ana Süreç(Main Process) Modülleri:
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
### Користувальницькі елементи DOM
|
||||
|
||||
* [`File` Object](api/file-object.md)
|
||||
* [`<webview>` Tag](api/web-view-tag.md)
|
||||
* [`<webview>` Tag](api/webview-tag.md)
|
||||
* [`window.open` Function](api/window-open.md)
|
||||
|
||||
### Модулі для Main Process:
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
|
||||
## 常见问题
|
||||
|
||||
这里是一些被经常问到的问题,再提 issue 之前请先看一下这里。
|
||||
这里是一些被经常问到的问题,在提 issue 之前请先看一下这里。
|
||||
|
||||
+ [Electron 常见问题](faq/electron-faq.md) 需要更新
|
||||
+ [Electron 常见问题](faq/electron-faq.md)
|
||||
|
||||
## 向导
|
||||
|
||||
* [术语表](glossary.md)
|
||||
* [支持平台](tutorial/supported-platforms.md)
|
||||
* [安全性](tutorial/security.md) 未翻译
|
||||
* [Electron 版本管理](tutorial/electron-versioning.md) 未翻译
|
||||
@@ -43,7 +44,7 @@
|
||||
### 自定义的 DOM 元素:
|
||||
|
||||
* [`File` 对象](api/file-object.md)
|
||||
* [`<webview>` 标签](api/web-view-tag.md)
|
||||
* [`<webview>` 标签](api/webview-tag.md)
|
||||
* [`window.open` 函数](api/window-open.md)
|
||||
|
||||
### 在主进程内可用的模块:
|
||||
@@ -57,11 +58,12 @@
|
||||
* [ipcMain](api/ipc-main.md)
|
||||
* [Menu](api/menu.md)
|
||||
* [MenuItem](api/menu-item.md)
|
||||
* [net](api/net.md)
|
||||
* [powerMonitor](api/power-monitor.md)
|
||||
* [powerSaveBlocker](api/power-save-blocker.md)
|
||||
* [protocol](api/protocol.md)
|
||||
* [session](api/session.md)
|
||||
* [systemPreferences](api/system-preferences.md) 未翻译
|
||||
* [systemPreferences](api/system-preferences.md)
|
||||
* [Tray](api/tray.md)
|
||||
* [webContents](api/web-contents.md)
|
||||
|
||||
@@ -83,7 +85,7 @@
|
||||
## 开发
|
||||
|
||||
* [代码规范](development/coding-style.md)
|
||||
* [在 C++ 代码中试用 clang格式化工具](development/clang-format.md) 未翻译
|
||||
* [在 C++ 代码中使用 clang格式化工具](development/clang-format.md) 未翻译
|
||||
* [源码目录结构](development/source-code-directory-structure.md)
|
||||
* [与 NW.js(原 node-webkit)在技术上的差异](development/atom-shell-vs-node-webkit.md)
|
||||
* [构建系统概览](development/build-system-overview.md)
|
||||
|
||||
@@ -59,7 +59,7 @@ win.show()
|
||||
* `acceptFirstMouse` Boolean - 是否允许单击web view来激活窗口 . 默认为 `false`.
|
||||
* `disableAutoHideCursor` Boolean - 当 typing 时是否隐藏鼠标.默认 `false`.
|
||||
* `autoHideMenuBar` Boolean - 除非点击 `Alt`,否则隐藏菜单栏.默认为 `false`.
|
||||
* `enableLargerThanScreen` Boolean - 是否允许允许改变窗口大小大于屏幕. 默认是 `false`.
|
||||
* `enableLargerThanScreen` Boolean - 是否允许改变窗口大小大于屏幕. 默认是 `false`.
|
||||
* `backgroundColor` String -窗口的 background color 值为十六进制,如 `#66CD00` 或 `#FFF` 或 `#80FFFFFF` (支持透明度). 默认为在 Linux 和 Windows 上为
|
||||
`#000` (黑色) , Mac上为 `#FFF`(或透明).
|
||||
* `hasShadow` Boolean - 窗口是否有阴影. 只在 macOS 上有效. 默认为 `true`.
|
||||
|
||||
@@ -79,7 +79,7 @@ console.log(dialog.showOpenDialog({properties: ['openFile', 'openDirectory', 'mu
|
||||
* `detail` String - 额外信息.
|
||||
* `icon` [NativeImage](native-image.md)
|
||||
* `cancelId` Integer - 当用户关闭对话框的时候,不是通过点击对话框的button,就返回值.默认值为对应 "cancel" 或 "no" 标签button 的索引值, 或者如果没有这种button,就返回0. 在 macOS 和 Windows 上, "Cancel" button 的索引值将一直是 `cancelId`, 不管之前是不是特别指出的.
|
||||
* `noLink` Boolean - 在 Windows ,Electron 将尝试识别哪个button 是普通 button (如 "Cancel" 或 "Yes"), 然后再对话框中以链接命令(command links)方式展现其它的 button . 这能让对话框展示得很炫酷.如果你不喜欢这种效果,你可以设置 `noLink` 为 `true`.
|
||||
* `noLink` Boolean - 在 Windows ,Electron 将尝试识别哪个button 是普通 button (如 "Cancel" 或 "Yes"), 然后在对话框中以链接命令(command links)方式展现其它的 button . 这能让对话框展示得很炫酷.如果你不喜欢这种效果,你可以设置 `noLink` 为 `true`.
|
||||
* `callback` Function
|
||||
|
||||
展示 message box, 它会阻塞进程,直到 message box 关闭为止.返回点击按钮的索引值.
|
||||
|
||||
@@ -46,7 +46,7 @@ Windows 控制台:
|
||||
|
||||
## `ELECTRON_FORCE_WINDOW_MENU_BAR` _Linux_
|
||||
|
||||
不可再 Linux 上使用全局菜单栏.
|
||||
不可在 Linux 上使用全局菜单栏.
|
||||
|
||||
## `ELECTRON_HIDE_INTERNAL_MODULES`
|
||||
|
||||
|
||||
54
docs-translations/zh-CN/api/net.md
Normal file
54
docs-translations/zh-CN/api/net.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# net
|
||||
|
||||
> 使用原生 Chromium 的 networking 库来解决 HTTP/HTTPS 请求问题。
|
||||
|
||||
可使用的进程: [主进程](../tutorial/quick-start.md#main-process)
|
||||
|
||||
`net` 模块是一个客户端 API 用于解决 HTTP(S) 请求问题。它和 Node.js 中的 [HTTP](https://nodejs.org/api/http.html) 和 [HTTPS](https://nodejs.org/api/https.html) 模块比较相似,但是它使用了 Chromium 的原生 API 来替代 Node.js 的方案 ,相对而言更加适合 web 端的请求处理。
|
||||
|
||||
以下是部分简要的原因来阐述为什么你需要考虑使用 `net` 来替代 Node.js 的原生模块:
|
||||
|
||||
* 自动管理系统代理设置,支持 wpad 协议和 pac 代理配置文件。
|
||||
* 自动使用隧道通过 HTTPS 请求。
|
||||
* 支持 basic, digest, NTLM, Kerberos or
|
||||
negotiate 等身份验证模式作为身份验证代理。
|
||||
* 支持 traffic monitoring proxies: 类似于 Fiddler 的代理用于监控和操作网络请求。
|
||||
|
||||
`net` 模块的 API 在设计上特别的模仿了 Node.js 的 API 从而达到比较接近的体验。在 API 组件中包含了类,方法,属性还有事件等名称,这些都像是在使用 Node.js 的 API。
|
||||
|
||||
例如下面一个例子就快速展示了如何使用 `net` API :
|
||||
|
||||
```javascript
|
||||
const {app} = require('electron')
|
||||
app.on('ready', () => {
|
||||
const {net} = require('electron')
|
||||
const request = net.request('https://github.com')
|
||||
request.on('response', (response) => {
|
||||
console.log(`STATUS: ${response.statusCode}`)
|
||||
console.log(`HEADERS: ${JSON.stringify(response.headers)}`)
|
||||
response.on('data', (chunk) => {
|
||||
console.log(`BODY: ${chunk}`)
|
||||
})
|
||||
response.on('end', () => {
|
||||
console.log('No more data in response.')
|
||||
})
|
||||
})
|
||||
request.end()
|
||||
})
|
||||
```
|
||||
|
||||
也就是说,它对于你使用过 Node.js 的 [HTTP](https://nodejs.org/api/http.html)/[HTTPS](https://nodejs.org/api/https.html) 模块来说是非常的相似的。
|
||||
|
||||
`net` API 只有在应用触发 `ready` 事件后才可以使用。如果在 `ready` 事件前尝试使用会抛出一个错误。
|
||||
|
||||
## 方法
|
||||
|
||||
`net` 模块拥有以下方法:
|
||||
|
||||
### `net.request(options)`
|
||||
|
||||
* `options` (Object | String) - `ClientRequest` 的构造参数。
|
||||
|
||||
返回 `ClientRequest`
|
||||
|
||||
创建一个 [`ClientRequest`](./client-request.md) 使用提供的参数来作为构造器。`net.request` 方法会根据设置中的相应的协议方来处理处理安全和不受信任的 HTTP 请求。
|
||||
@@ -1,27 +1,26 @@
|
||||
# 进程
|
||||
|
||||
Electron 中的 `process` 对象 与 upstream node 中的有以下的不同点:
|
||||
> process 对象扩展。
|
||||
|
||||
* `process.type` String - 进程类型, 可以是 `browser` (i.e. main process)
|
||||
或 `renderer`.
|
||||
* `process.versions.electron` String - Electron的版本.
|
||||
* `process.versions.chrome` String - Chromium的版本.
|
||||
* `process.resourcesPath` String - JavaScript源代码路径.
|
||||
* `process.mas` Boolean - 在Mac App Store 创建, 它的值为 `true`, 在其它的地方值为 `undefined`.
|
||||
Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process)
|
||||
|
||||
Electron 的 `process` 对象是
|
||||
[Node.js `process` 对象](https://nodejs.org/api/process.html) 的扩展。
|
||||
它添加了以下事件、属性和方法:
|
||||
|
||||
## 事件
|
||||
|
||||
### 事件: 'loaded'
|
||||
|
||||
在Electron已经加载了其内部预置脚本和它准备加载主进程或渲染进程的时候触发.
|
||||
在Electron已经加载了其内部预置脚本和它准备加载网页或者主进程的时候触发。
|
||||
|
||||
当node被完全关闭的时候,它可以被预加载脚本使用来添加(原文: removed)与node无关的全局符号来回退到全局范围:
|
||||
当node被完全关闭的时候,它可以被预加载脚本使用来添加(原文: removed)与node无关的全局符号来回退到全局范围:
|
||||
|
||||
```javascript
|
||||
// preload.js
|
||||
var _setImmediate = setImmediate
|
||||
var _clearImmediate = clearImmediate
|
||||
process.once('loaded', function () {
|
||||
const _setImmediate = setImmediate
|
||||
const _clearImmediate = clearImmediate
|
||||
process.once('loaded', () => {
|
||||
global.setImmediate = _setImmediate
|
||||
global.clearImmediate = _clearImmediate
|
||||
})
|
||||
@@ -31,18 +30,72 @@ process.once('loaded', function () {
|
||||
|
||||
### `process.noAsar`
|
||||
|
||||
设置它为 `true` 可以使 `asar` 文件在node的内置模块中失效.
|
||||
设置它为 `true` 可以使 `asar` 文件在node的内置模块中失效。
|
||||
|
||||
### `process.type`
|
||||
|
||||
当前 `process` 的类型,值为`"browser"` (即主进程) 或 `"renderer"`。
|
||||
|
||||
### `process.versions.electron`
|
||||
|
||||
Electron的版本号。
|
||||
|
||||
### `process.versions.chrome`
|
||||
|
||||
Chrome的版本号。
|
||||
|
||||
### `process.resourcesPath`
|
||||
|
||||
资源文件夹的路径。
|
||||
|
||||
### `process.mas`
|
||||
|
||||
在 Mac App Store 的构建中,该属性为 `true`, 其他平台的构建均为 `undefined`。
|
||||
|
||||
### `process.windowsStore`
|
||||
|
||||
如果 app 是运行在 Windows Store app (appx) 中,该属性为 `true`, 其他情况均为 `undefined`。
|
||||
|
||||
### `process.defaultApp`
|
||||
|
||||
当 app 在启动时,被作为参数传递给默认应用程序,在主进程中该属性为 `true`, 其他情况均为 `undefined`。
|
||||
|
||||
## 方法
|
||||
|
||||
`process` 对象有如下方法:
|
||||
`process` 对象有如下方法:
|
||||
|
||||
### `process.crash()`
|
||||
|
||||
使当前进程的主线程崩溃。
|
||||
|
||||
### `process.hang()`
|
||||
|
||||
使当前进程的主线程挂起.
|
||||
使当前进程的主线程挂起。
|
||||
|
||||
### `process.setFdLimit(maxDescriptors)` _macOS_ _Linux_
|
||||
|
||||
* `maxDescriptors` Integer
|
||||
|
||||
设置文件描述符软限制于 `maxDescriptors` 或硬限制与os, 无论它是否低于当前进程.
|
||||
设置文件描述符软限制于 `maxDescriptors` 或硬限制于OS, 无论它是否低于当前进程。
|
||||
|
||||
### `process.getProcessMemoryInfo()`
|
||||
|
||||
返回 `Object`:
|
||||
|
||||
* `workingSetSize` Integer - 当前固定到实际物理内存的内存量。
|
||||
* `peakWorkingSetSize` Integer - 被固定在实际物理内存上的最大内存量。
|
||||
* `privateBytes` Integer - 不被其他进程共享的内存量,如JS堆或HTML内容。
|
||||
* `sharedBytes` Integer - 进程之间共享的内存量,通常是 Electron 代码本身所消耗的内存。
|
||||
|
||||
返回当前进程的内存使用统计信息的对象。请注意,所有数据的单位都是KB。
|
||||
|
||||
### `process.getSystemMemoryInfo()`
|
||||
|
||||
返回 `Object`:
|
||||
|
||||
* `total` Integer - 系统的物理内存总量。
|
||||
* `free` Integer - 未被应用程序或磁盘缓存使用的物理内存总量。
|
||||
* `swapTotal` Integer - 系统 swap 分区(虚拟内存)总量。 _Windows_ _Linux_
|
||||
* `swapFree` Integer - 系统剩余可用的 swap 分区(虚拟内存)量。 _Windows_ _Linux_
|
||||
|
||||
返回系统的内存使用统计信息的对象。请注意,所有数据的单位都是KB。
|
||||
|
||||
215
docs-translations/zh-CN/api/system-preferences.md
Normal file
215
docs-translations/zh-CN/api/system-preferences.md
Normal file
@@ -0,0 +1,215 @@
|
||||
# systemPreferences
|
||||
|
||||
> 获取系统偏好设置.
|
||||
|
||||
可使用的进程: [主进程](../tutorial/quick-start.md#main-process)
|
||||
|
||||
```javascript
|
||||
const {systemPreferences} = require('electron')
|
||||
console.log(systemPreferences.isDarkMode())
|
||||
```
|
||||
|
||||
## 事件
|
||||
|
||||
`systemPreferences` 对象会触发以下事件:
|
||||
|
||||
### Event: 'accent-color-changed' _Windows_
|
||||
|
||||
返回:
|
||||
|
||||
* `event` Event
|
||||
* `newColor` String - 用户给系统颜色设置的新的 RGBA 色值。
|
||||
|
||||
### Event: 'color-changed' _Windows_
|
||||
|
||||
返回:
|
||||
|
||||
* `event` Event
|
||||
|
||||
### Event: 'inverted-color-scheme-changed' _Windows_
|
||||
|
||||
返回:
|
||||
|
||||
* `event` Event
|
||||
* `invertedColorScheme` Boolean - 如果一个反色的配色方案正在被使用,比如一个高对比度的主题,则返回 `true` ,否则返回 `false` 。
|
||||
|
||||
## 方法
|
||||
|
||||
### `systemPreferences.isDarkMode()` _macOS_
|
||||
|
||||
返回 `Boolean` - 系统是否处于深色模式.
|
||||
|
||||
### `systemPreferences.isSwipeTrackingFromScrollEventsEnabled()` _macOS_
|
||||
|
||||
返回 `Boolean` - 是否开启页面间滑动功能。
|
||||
|
||||
### `systemPreferences.postNotification(event, userInfo)` _macOS_
|
||||
|
||||
* `event` String
|
||||
* `userInfo` Object
|
||||
|
||||
在 macOS 上使用原生系统通知来发布 `event` 。`userInfo` 是包含了用户向通知发送的信息字典的一个对象。
|
||||
|
||||
### `systemPreferences.postLocalNotification(event, userInfo)` _macOS_
|
||||
|
||||
* `event` String
|
||||
* `userInfo` Object
|
||||
|
||||
在 macOS 上使用原生系统通知来发布 `event` 。`userInfo` 是包含了用户向通知发送的信息字典的一个对象。
|
||||
|
||||
### `systemPreferences.subscribeNotification(event, callback)` _macOS_
|
||||
|
||||
* `event` String
|
||||
* `callback` Function
|
||||
* `event` String
|
||||
* `userInfo` Object
|
||||
|
||||
在 macOS 上订阅一个原生消息。当相关 `event` 发生, `callback` 将会被 `callback(event, userInfo)` 调用。`userInfo` 是包含了用户向通知发送的信息字典的一个对象。
|
||||
|
||||
订阅者的 `id` 将会被返回,它能够用于取消订阅相关 `event` 。
|
||||
|
||||
这个API在底层上订阅于 `NSDistributedNotificationCenter`,
|
||||
`event` 的一些实例值如下:
|
||||
|
||||
* `AppleInterfaceThemeChangedNotification`
|
||||
* `AppleAquaColorVariantChanged`
|
||||
* `AppleColorPreferencesChangedNotification`
|
||||
* `AppleShowScrollBarsSettingChanged`
|
||||
|
||||
### `systemPreferences.unsubscribeNotification(id)` _macOS_
|
||||
|
||||
* `id` Integer
|
||||
|
||||
移除当前 `id` 下的订阅。
|
||||
|
||||
### `systemPreferences.subscribeLocalNotification(event, callback)` _macOS_
|
||||
|
||||
* `event` String
|
||||
* `callback` Function
|
||||
* `event` String
|
||||
* `userInfo` Object
|
||||
|
||||
大体上如同 `subscribeNotification` ,但默认使用本地 `subscribeNotification` 。一些事件必须使用它,比如 `NSUserDefaultsDidChangeNotification` 。
|
||||
|
||||
### `systemPreferences.unsubscribeLocalNotification(id)` _macOS_
|
||||
|
||||
* `id` Integer
|
||||
|
||||
大体上如同 `unsubscribeNotification` , 但是是从 `NSNotificationCenter` 中移除订阅者。
|
||||
|
||||
### `systemPreferences.getUserDefault(key, type)` _macOS_
|
||||
|
||||
* `key` String
|
||||
* `type` String - Can be `string`, `boolean`, `integer`, `float`, `double`,
|
||||
`url`, `array`, `dictionary`
|
||||
|
||||
获取系统偏好中相应的 `key` 的值。
|
||||
|
||||
这个 API 在 macOS 系统中使用的是 `NSUserDefaults` 。以下是一些热门的 `key` 和 `type`:
|
||||
|
||||
* `AppleInterfaceStyle`: `string`
|
||||
* `AppleAquaColorVariant`: `integer`
|
||||
* `AppleHighlightColor`: `string`
|
||||
* `AppleShowScrollBars`: `string`
|
||||
* `NSNavRecentPlaces`: `array`
|
||||
* `NSPreferredWebServices`: `dictionary`
|
||||
* `NSUserDictionaryReplacementItems`: `array`
|
||||
|
||||
### `systemPreferences.setUserDefault(key, type, value)` _macOS_
|
||||
|
||||
* `key` String
|
||||
* `type` String - 详见 [`getUserDefault`][#systempreferencesgetuserdefaultkey-type-macos]
|
||||
* `value` String
|
||||
|
||||
设置系统偏好中相应的 `key` 的值。
|
||||
|
||||
需要注意的是 `type` 需要与实际的类型的 `value` 对应。不然会抛出一个异常。
|
||||
|
||||
这个 API 在 macOS 系统中使用的是 `NSUserDefaults` 。以下是一些热门的 `key` 和 `type`:
|
||||
|
||||
* `ApplePressAndHoldEnabled`: `boolean`
|
||||
|
||||
### `systemPreferences.isAeroGlassEnabled()` _Windows_
|
||||
|
||||
如果 [DWM composition][dwm-composition] (毛玻璃效果)开启则会返回 `true` 否则返回 `false` 。
|
||||
|
||||
以下是一个实例去使用它来确定是否应该创建一个透明的窗口(透明的窗口在 DWM composition 禁止的情况下无法正确运行):
|
||||
|
||||
```javascript
|
||||
const {BrowserWindow, systemPreferences} = require('electron')
|
||||
let browserOptions = {width: 1000, height: 800}
|
||||
|
||||
// 如果平台支持的话便新建一个透明的窗口。
|
||||
if (process.platform !== 'win32' || systemPreferences.isAeroGlassEnabled()) {
|
||||
browserOptions.transparent = true
|
||||
browserOptions.frame = false
|
||||
}
|
||||
|
||||
// 创建窗口。
|
||||
let win = new BrowserWindow(browserOptions)
|
||||
|
||||
// 区分环境进行加载。
|
||||
if (browserOptions.transparent) {
|
||||
win.loadURL(`file://${__dirname}/index.html`)
|
||||
} else {
|
||||
// No transparency, so we load a fallback that uses basic styles.
|
||||
win.loadURL(`file://${__dirname}/fallback.html`)
|
||||
}
|
||||
```
|
||||
|
||||
[dwm-composition]:https://msdn.microsoft.com/en-us/library/windows/desktop/aa969540.aspx
|
||||
|
||||
### `systemPreferences.getAccentColor()` _Windows_
|
||||
|
||||
返回 `String` - 用户当前系统颜色偏好的16进制 RGBA 色值。
|
||||
|
||||
```js
|
||||
const color = systemPreferences.getAccentColor() // `"aabbccdd"`
|
||||
const red = color.substr(0, 2) // "aa"
|
||||
const green = color.substr(2, 2) // "bb"
|
||||
const blue = color.substr(4, 2) // "cc"
|
||||
const alpha = color.substr(6, 2) // "dd"
|
||||
```
|
||||
|
||||
### `systemPreferences.getColor(color)` _Windows_
|
||||
|
||||
* `color` String - 接下来的一个值:
|
||||
* `3d-dark-shadow` - 3D 元素的暗部的色值。
|
||||
* `3d-face` - 3D 肤色,以及对话框背景。
|
||||
* `3d-highlight` - 高亮的3D元素。
|
||||
* `3d-light` - 3D 元素亮部。
|
||||
* `3d-shadow` - 3D 元素的阴影。
|
||||
* `active-border` - 活跃窗口边框。
|
||||
* `active-caption` - 活跃窗口标题。 具体来说是指开启渐变效果下活跃窗口中左侧色彩梯度。
|
||||
* `active-caption-gradient` - 活跃窗口标题栏中右侧颜色梯度。
|
||||
* `app-workspace` - 多文档(MDI)应用界面背景颜色。
|
||||
* `button-text` - 推送按钮的文本。
|
||||
* `caption-text` - 标题栏,尺寸框,滚动条尖头框上的文本。
|
||||
* `desktop` - 桌面背景颜色。
|
||||
* `disabled-text` - 灰色(禁止的)文本。
|
||||
* `highlight` - 元素的元素。
|
||||
* `highlight-text` - 选中的文本。
|
||||
* `hotlight` - 热链或者超链接的色值。
|
||||
* `inactive-border` - 不活跃窗口的边框。
|
||||
* `inactive-caption` - 不活跃窗口标题。具体来说是指开启渐变效果下不活跃窗口中左侧色彩梯度。
|
||||
* `inactive-caption-gradient` - 不活跃窗口标题栏中右侧色彩梯度。
|
||||
* `inactive-caption-text` - 不活跃的标题文本。
|
||||
* `info-background` - 工具栏背景。
|
||||
* `info-text` - 工具栏文本。
|
||||
* `menu` - 菜单背景。
|
||||
* `menu-highlight` - 当菜单作为平面菜单时高亮的菜单颜色。
|
||||
* `menubar` - 当菜单作为平面菜单时菜单栏背景。
|
||||
* `menu-text` - 菜单文本。
|
||||
* `scrollbar` - 滚动条灰色区域。
|
||||
* `window` - 窗口背景。
|
||||
* `window-frame` - 窗口框架。
|
||||
* `window-text` - 窗口内文本。
|
||||
|
||||
返回 `String` - 系统设置色值的16进制形式(`#ABCDEF`)。
|
||||
详见 [Windows docs][windows-colors] 获取更多细节。
|
||||
|
||||
### `systemPreferences.isInvertedColorScheme()` _Windows_
|
||||
|
||||
返回 `Boolean` - 如果一个反色的配色方案正在被使用,比如一个高对比度的主题,则返回 `true` ,否则返回 `false` 。
|
||||
|
||||
[windows-colors]:https://msdn.microsoft.com/en-us/library/windows/desktop/ms724371(v=vs.85).aspx
|
||||
@@ -359,12 +359,12 @@ guest page 导航到指定的相对位置.
|
||||
默认为 `false`.
|
||||
* `medialCapitalAsWordStart` Boolean - 当配合 `wordStart`的时候,接受一个文字中的匹配项,要求匹配项是以大写字母开头后面跟小写字母或者没有字母。可以接受一些其他单词内部匹配, 默认为 `false`.
|
||||
|
||||
发起一个请求来寻找页面中的所有匹配 `text` 的地方并且返回一个 `Integer`来表示这个请求用的请求Id. 这个请求结果可以通过订阅[`found-in-page`](web-view-tag.md#event-found-in-page) 事件来取得.
|
||||
发起一个请求来寻找页面中的所有匹配 `text` 的地方并且返回一个 `Integer`来表示这个请求用的请求Id. 这个请求结果可以通过订阅[`found-in-page`](webview-tag.md#event-found-in-page) 事件来取得.
|
||||
|
||||
### `<webview>.stopFindInPage(action)`
|
||||
|
||||
* `action` String - 指定一个行为来接替停止
|
||||
[`<webview>.findInPage`](web-view-tag.md#webviewtagfindinpage) 请求.
|
||||
[`<webview>.findInPage`](webview-tag.md#webviewtagfindinpage) 请求.
|
||||
* `clearSelection` - 转变为一个普通的 selection.
|
||||
* `keepSelection` - 清除 selection.
|
||||
* `activateSelection` - 聚焦并点击 selection node.
|
||||
@@ -533,7 +533,7 @@ webview.addEventListener('console-message', function (e) {
|
||||
* `matches` Integer (optional) - 匹配数量.
|
||||
* `selectionArea` Object (optional) - 整合第一个匹配域.
|
||||
|
||||
在请求[`webview.findInPage`](web-view-tag.md#webviewtagfindinpage)结果有效时触发.
|
||||
在请求[`webview.findInPage`](webview-tag.md#webviewtagfindinpage)结果有效时触发.
|
||||
|
||||
```javascript
|
||||
webview.addEventListener('found-in-page', function (e) {
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user