mirror of
https://github.com/electron/electron.git
synced 2026-02-26 03:01:17 -05:00
Compare commits
273 Commits
feat/toggl
...
v5.0.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45ab468ce1 | ||
|
|
be458b547a | ||
|
|
050bbfb211 | ||
|
|
0a4d90d41f | ||
|
|
0e56578e11 | ||
|
|
7a2777cc00 | ||
|
|
fc6b98766c | ||
|
|
7d06861a6d | ||
|
|
851a84d301 | ||
|
|
91bc35fbfc | ||
|
|
76414e58d4 | ||
|
|
d6ad3e6a17 | ||
|
|
49d6f5cc14 | ||
|
|
610f61603d | ||
|
|
6b371a5ef9 | ||
|
|
7ee06c354e | ||
|
|
a60ad6aeed | ||
|
|
693d840202 | ||
|
|
7a759ea0b6 | ||
|
|
83a4b7371b | ||
|
|
82bb6d4ccf | ||
|
|
2de54a3dbc | ||
|
|
7eac676fa7 | ||
|
|
54199d21c3 | ||
|
|
2483dcc09c | ||
|
|
1154f3c585 | ||
|
|
232d9fe808 | ||
|
|
5693b7f3a1 | ||
|
|
d4e631f1b9 | ||
|
|
2252ac060e | ||
|
|
bb28195b74 | ||
|
|
2f426a031a | ||
|
|
761b14316f | ||
|
|
f3a05c30ae | ||
|
|
7514372e79 | ||
|
|
151a338956 | ||
|
|
d57293503d | ||
|
|
c4009760c7 | ||
|
|
3408997289 | ||
|
|
9ca2b31b7c | ||
|
|
5aa0a1a77a | ||
|
|
3825bf0b6d | ||
|
|
d15bcfb1ed | ||
|
|
ccb051caf7 | ||
|
|
3284aabd48 | ||
|
|
6d575f80fa | ||
|
|
b91dcfb314 | ||
|
|
321e66d0cc | ||
|
|
81eedb6efa | ||
|
|
b08dc0f7e6 | ||
|
|
11c1c255bf | ||
|
|
c89bab9730 | ||
|
|
5ffe634824 | ||
|
|
3ad9fb1473 | ||
|
|
b0298cca2e | ||
|
|
ed8ab7e9ad | ||
|
|
c75726f9ef | ||
|
|
ff7e22c675 | ||
|
|
946c11145c | ||
|
|
ffd2224bbe | ||
|
|
c326de860d | ||
|
|
145aa919ca | ||
|
|
2cc55fee5e | ||
|
|
119e8bec93 | ||
|
|
82f91b7efa | ||
|
|
900feef89f | ||
|
|
c58d39e71b | ||
|
|
48f190690e | ||
|
|
faa308c88c | ||
|
|
9619688706 | ||
|
|
a724aced43 | ||
|
|
9a9f7af971 | ||
|
|
0184ccd019 | ||
|
|
cdd8021509 | ||
|
|
1e31bfe287 | ||
|
|
7304af93ed | ||
|
|
69f6a44e81 | ||
|
|
354b32a9fc | ||
|
|
d5bb0e968f | ||
|
|
9e12e8c63f | ||
|
|
ebcd094222 | ||
|
|
5dd735f5b3 | ||
|
|
46841d7373 | ||
|
|
707f110c0f | ||
|
|
0e5d181cc9 | ||
|
|
f3a2c27840 | ||
|
|
0032a5247f | ||
|
|
ef38019122 | ||
|
|
e280ae11b8 | ||
|
|
14602f55d5 | ||
|
|
27b4335084 | ||
|
|
a1c1012cc4 | ||
|
|
821b88e420 | ||
|
|
d90934517d | ||
|
|
2f765ac897 | ||
|
|
d25be9cf75 | ||
|
|
1b8a25bb81 | ||
|
|
361e5b2c55 | ||
|
|
7912ea5950 | ||
|
|
5b34f9bcc9 | ||
|
|
766cfc1f4c | ||
|
|
3e999ca127 | ||
|
|
c8f80baeea | ||
|
|
d527192c49 | ||
|
|
6a93200099 | ||
|
|
2f31302b75 | ||
|
|
2cb7b6bbf3 | ||
|
|
ba00be3798 | ||
|
|
c55f806191 | ||
|
|
de9eb14d46 | ||
|
|
cf390c0efb | ||
|
|
2c9b4d1def | ||
|
|
104ec2ba12 | ||
|
|
78a2a2f18d | ||
|
|
4d620f0a11 | ||
|
|
d483a135f5 | ||
|
|
7990d9b81e | ||
|
|
2b28ed4fc6 | ||
|
|
51c5882f4c | ||
|
|
1aae1c11e3 | ||
|
|
00cfedbfd8 | ||
|
|
7e3ff0f7d2 | ||
|
|
47f005f730 | ||
|
|
4f3d6117cd | ||
|
|
119382b55e | ||
|
|
8cf0e8ed5c | ||
|
|
fce543d725 | ||
|
|
8fb7481298 | ||
|
|
9cdb5eda89 | ||
|
|
c0f307e49c | ||
|
|
e8df32f354 | ||
|
|
5c68870ad7 | ||
|
|
f3f1f6b712 | ||
|
|
4ecb96e8d7 | ||
|
|
5343ccf10b | ||
|
|
cbb9c4323c | ||
|
|
be9f302af6 | ||
|
|
180a4f34c2 | ||
|
|
b1bfc74ecb | ||
|
|
bc7d2378df | ||
|
|
e31d3b52ee | ||
|
|
277373a95a | ||
|
|
d9e9bf9b87 | ||
|
|
3396d08a3b | ||
|
|
c76872f3f9 | ||
|
|
c7175b295a | ||
|
|
2ff3a15326 | ||
|
|
a6806e9e1c | ||
|
|
200051ccc0 | ||
|
|
36726bd70f | ||
|
|
9755288527 | ||
|
|
39e380bb66 | ||
|
|
4bdf7674f9 | ||
|
|
cfe8c3efd8 | ||
|
|
46b420158c | ||
|
|
9010ee340c | ||
|
|
f1de4896d4 | ||
|
|
9bbd1074ea | ||
|
|
bb3c08f306 | ||
|
|
203c4a72b5 | ||
|
|
cf504fc1bf | ||
|
|
38c3e61a78 | ||
|
|
337e82a4c0 | ||
|
|
a482d4e288 | ||
|
|
c1cdc38e33 | ||
|
|
38865f46d2 | ||
|
|
e290438a6d | ||
|
|
355d395b00 | ||
|
|
9a5b041f74 | ||
|
|
5395810c45 | ||
|
|
a91054883f | ||
|
|
0459dc7d6f | ||
|
|
28c7b5f0ab | ||
|
|
b7018da0c1 | ||
|
|
bdd272192c | ||
|
|
d9faf76cb5 | ||
|
|
52db4693e8 | ||
|
|
b362a59173 | ||
|
|
e8e4b19348 | ||
|
|
e674061bab | ||
|
|
77b3d218a4 | ||
|
|
364dac53d4 | ||
|
|
29b9281af4 | ||
|
|
4d2815e56b | ||
|
|
302372f4b4 | ||
|
|
bbd72e5658 | ||
|
|
3db0a8ef73 | ||
|
|
1a2df2f309 | ||
|
|
d5c37c301a | ||
|
|
eabc5166ac | ||
|
|
88a5abca4b | ||
|
|
f6b6f9524e | ||
|
|
645b98d81a | ||
|
|
c605d1a044 | ||
|
|
df1d39d6ec | ||
|
|
5f08a4f8be | ||
|
|
cc9c84cad4 | ||
|
|
25e6eb9d04 | ||
|
|
b4bd96b2ca | ||
|
|
4ba51dbad8 | ||
|
|
5a8af35927 | ||
|
|
a4babe6699 | ||
|
|
c1ea592457 | ||
|
|
225264f06b | ||
|
|
30cc82d265 | ||
|
|
14c39620f0 | ||
|
|
b395a66246 | ||
|
|
04158b15bb | ||
|
|
8b5f26a9f0 | ||
|
|
c65e9079cc | ||
|
|
91a67e4867 | ||
|
|
4079787378 | ||
|
|
0dc9e32039 | ||
|
|
28c7b346db | ||
|
|
c4f993add1 | ||
|
|
bb21822c10 | ||
|
|
124bb2910f | ||
|
|
0f54df5867 | ||
|
|
2bd1a7ec1e | ||
|
|
ee97b0864a | ||
|
|
96e0dfcae9 | ||
|
|
379a7b707b | ||
|
|
3963ee6d1d | ||
|
|
64cd5bf3a5 | ||
|
|
05074bae0c | ||
|
|
174a39be8f | ||
|
|
918e3ce0b6 | ||
|
|
9c0eca1d8b | ||
|
|
26e0a7d922 | ||
|
|
a498e0c033 | ||
|
|
0f66918825 | ||
|
|
050b866b6a | ||
|
|
8115a899df | ||
|
|
3dcb7cfef9 | ||
|
|
502f24e50d | ||
|
|
6ebef9d876 | ||
|
|
60af6c2791 | ||
|
|
6d76da55e2 | ||
|
|
b31057ca16 | ||
|
|
16dfa56c77 | ||
|
|
a7ed504575 | ||
|
|
dc4c32972d | ||
|
|
d1d0efbd07 | ||
|
|
afa684ad45 | ||
|
|
f66d21e426 | ||
|
|
9a68ce87eb | ||
|
|
ecb737760c | ||
|
|
5d32cd0269 | ||
|
|
499efd5ee7 | ||
|
|
c4115ed783 | ||
|
|
969a97b54f | ||
|
|
5be0851434 | ||
|
|
233d346d5a | ||
|
|
a879981dfb | ||
|
|
3d90bd4e8e | ||
|
|
ba1dd09be2 | ||
|
|
80aa832ebd | ||
|
|
a950e1d040 | ||
|
|
4d7ddcd750 | ||
|
|
d6612d230b | ||
|
|
1d9abfdb10 | ||
|
|
871ba507a6 | ||
|
|
5d64df141b | ||
|
|
ae846204cb | ||
|
|
6dcf5c5c79 | ||
|
|
e55a9b35b6 | ||
|
|
ae85864959 | ||
|
|
5cc0539919 | ||
|
|
b070774f5c | ||
|
|
7a8548d48f | ||
|
|
ac172abda7 | ||
|
|
29e5195c63 | ||
|
|
3926d9d717 |
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
|||||||
# These env vars are only necessary for creating Electron releases.
|
# These env vars are only necessary for creating Electron releases.
|
||||||
# See docs/development/releasing.md
|
# See docs/development/releasing.md
|
||||||
|
|
||||||
APPVEYOR_TOKEN=
|
APPVEYOR_CLOUD_TOKEN=
|
||||||
CIRCLE_TOKEN=
|
CIRCLE_TOKEN=
|
||||||
ELECTRON_GITHUB_TOKEN=
|
ELECTRON_GITHUB_TOKEN=
|
||||||
VSTS_TOKEN=
|
VSTS_TOKEN=
|
||||||
95
BUILD.gn
95
BUILD.gn
@@ -2,7 +2,6 @@ import("//build/config/locales.gni")
|
|||||||
import("//build/config/ui.gni")
|
import("//build/config/ui.gni")
|
||||||
import("//build/config/win/manifest.gni")
|
import("//build/config/win/manifest.gni")
|
||||||
import("//pdf/features.gni")
|
import("//pdf/features.gni")
|
||||||
import("//services/service_manager/public/service_manifest.gni")
|
|
||||||
import("//third_party/ffmpeg/ffmpeg_options.gni")
|
import("//third_party/ffmpeg/ffmpeg_options.gni")
|
||||||
import("//tools/generate_library_loader/generate_library_loader.gni")
|
import("//tools/generate_library_loader/generate_library_loader.gni")
|
||||||
import("//tools/grit/grit_rule.gni")
|
import("//tools/grit/grit_rule.gni")
|
||||||
@@ -10,6 +9,7 @@ import("//tools/grit/repack.gni")
|
|||||||
import("//tools/v8_context_snapshot/v8_context_snapshot.gni")
|
import("//tools/v8_context_snapshot/v8_context_snapshot.gni")
|
||||||
import("//v8/snapshot_toolchain.gni")
|
import("//v8/snapshot_toolchain.gni")
|
||||||
import("build/asar.gni")
|
import("build/asar.gni")
|
||||||
|
import("build/js_wrap.gni")
|
||||||
import("build/npm.gni")
|
import("build/npm.gni")
|
||||||
import("buildflags/buildflags.gni")
|
import("buildflags/buildflags.gni")
|
||||||
import("electron_paks.gni")
|
import("electron_paks.gni")
|
||||||
@@ -53,7 +53,7 @@ config("branding") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
npm_action("atom_browserify_sandbox") {
|
npm_action("atom_browserify_sandbox_unwrapped") {
|
||||||
script = "browserify"
|
script = "browserify"
|
||||||
|
|
||||||
inputs = [
|
inputs = [
|
||||||
@@ -65,7 +65,7 @@ npm_action("atom_browserify_sandbox") {
|
|||||||
]
|
]
|
||||||
|
|
||||||
outputs = [
|
outputs = [
|
||||||
"$target_gen_dir/js2c/preload_bundle.js",
|
"$target_gen_dir/js2c/preload_bundle_unwrapped.js",
|
||||||
]
|
]
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
@@ -74,12 +74,14 @@ npm_action("atom_browserify_sandbox") {
|
|||||||
"./lib/sandboxed_renderer/api/exports/electron.js:electron",
|
"./lib/sandboxed_renderer/api/exports/electron.js:electron",
|
||||||
"-t",
|
"-t",
|
||||||
"aliasify",
|
"aliasify",
|
||||||
|
"--standalone",
|
||||||
|
"sandboxed_preload",
|
||||||
"-o",
|
"-o",
|
||||||
rebase_path(outputs[0]),
|
rebase_path(outputs[0]),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
npm_action("atom_browserify_isolated") {
|
npm_action("atom_browserify_isolated_unwrapped") {
|
||||||
script = "browserify"
|
script = "browserify"
|
||||||
|
|
||||||
inputs = [
|
inputs = [
|
||||||
@@ -87,18 +89,48 @@ npm_action("atom_browserify_isolated") {
|
|||||||
]
|
]
|
||||||
|
|
||||||
outputs = [
|
outputs = [
|
||||||
"$target_gen_dir/js2c/isolated_bundle.js",
|
"$target_gen_dir/js2c/isolated_bundle_unwrapped.js",
|
||||||
]
|
]
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"lib/isolated_renderer/init.js",
|
"lib/isolated_renderer/init.js",
|
||||||
"-t",
|
"-t",
|
||||||
"aliasify",
|
"aliasify",
|
||||||
|
"--standalone",
|
||||||
|
"isolated_preload",
|
||||||
"-o",
|
"-o",
|
||||||
rebase_path(outputs[0]),
|
rebase_path(outputs[0]),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
js_wrap("atom_browserify_isolated") {
|
||||||
|
deps = [
|
||||||
|
":atom_browserify_isolated_unwrapped",
|
||||||
|
]
|
||||||
|
|
||||||
|
inputs = [
|
||||||
|
"$target_gen_dir/js2c/isolated_bundle_unwrapped.js",
|
||||||
|
]
|
||||||
|
|
||||||
|
outputs = [
|
||||||
|
"$target_gen_dir/js2c/isolated_bundle.js",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
js_wrap("atom_browserify_sandbox") {
|
||||||
|
deps = [
|
||||||
|
":atom_browserify_sandbox_unwrapped",
|
||||||
|
]
|
||||||
|
|
||||||
|
inputs = [
|
||||||
|
"$target_gen_dir/js2c/preload_bundle_unwrapped.js",
|
||||||
|
]
|
||||||
|
|
||||||
|
outputs = [
|
||||||
|
"$target_gen_dir/js2c/preload_bundle.js",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
copy("atom_js2c_copy") {
|
copy("atom_js2c_copy") {
|
||||||
sources = [
|
sources = [
|
||||||
"lib/common/asar.js",
|
"lib/common/asar.js",
|
||||||
@@ -187,7 +219,6 @@ grit("resources") {
|
|||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
":copy_shell_devtools_discovery_page",
|
":copy_shell_devtools_discovery_page",
|
||||||
":electron_content_manifest_overlays",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
output_dir = "$target_gen_dir"
|
output_dir = "$target_gen_dir"
|
||||||
@@ -236,6 +267,7 @@ static_library("electron_lib") {
|
|||||||
":atom_js2c",
|
":atom_js2c",
|
||||||
"buildflags",
|
"buildflags",
|
||||||
"chromium_src:chrome",
|
"chromium_src:chrome",
|
||||||
|
"manifests",
|
||||||
"native_mate",
|
"native_mate",
|
||||||
"//base",
|
"//base",
|
||||||
"//base:base_static",
|
"//base:base_static",
|
||||||
@@ -261,8 +293,10 @@ static_library("electron_lib") {
|
|||||||
"//ppapi/host",
|
"//ppapi/host",
|
||||||
"//ppapi/proxy",
|
"//ppapi/proxy",
|
||||||
"//ppapi/shared_impl",
|
"//ppapi/shared_impl",
|
||||||
|
"//services/audio/public/mojom:constants",
|
||||||
"//services/device/public/mojom",
|
"//services/device/public/mojom",
|
||||||
"//services/proxy_resolver:lib",
|
"//services/proxy_resolver:lib",
|
||||||
|
"//services/video_capture/public/mojom:constants",
|
||||||
"//services/viz/privileged/interfaces/compositing",
|
"//services/viz/privileged/interfaces/compositing",
|
||||||
"//skia",
|
"//skia",
|
||||||
"//third_party/blink/public:blink",
|
"//third_party/blink/public:blink",
|
||||||
@@ -323,8 +357,6 @@ static_library("electron_lib") {
|
|||||||
"*_views.cc",
|
"*_views.cc",
|
||||||
"*_views.h",
|
"*_views.h",
|
||||||
"*\bviews/*",
|
"*\bviews/*",
|
||||||
"*/autofill_popup.cc",
|
|
||||||
"*/autofill_popup.h",
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,6 +381,10 @@ static_library("electron_lib") {
|
|||||||
"//third_party/crashpad/crashpad/client",
|
"//third_party/crashpad/crashpad/client",
|
||||||
"//ui/accelerated_widget_mac",
|
"//ui/accelerated_widget_mac",
|
||||||
]
|
]
|
||||||
|
sources += [
|
||||||
|
"atom/browser/ui/views/autofill_popup_view.cc",
|
||||||
|
"atom/browser/ui/views/autofill_popup_view.h",
|
||||||
|
]
|
||||||
include_dirs += [
|
include_dirs += [
|
||||||
# NOTE(nornagon): other chromium files use the full path to include
|
# NOTE(nornagon): other chromium files use the full path to include
|
||||||
# crashpad; this is just here for compatibility between GN and GYP, so that
|
# crashpad; this is just here for compatibility between GN and GYP, so that
|
||||||
@@ -421,11 +457,13 @@ static_library("electron_lib") {
|
|||||||
|
|
||||||
if (enable_osr) {
|
if (enable_osr) {
|
||||||
sources += [
|
sources += [
|
||||||
"atom/browser/osr/osr_output_device.cc",
|
"atom/browser/osr/osr_host_display_client.cc",
|
||||||
"atom/browser/osr/osr_output_device.h",
|
"atom/browser/osr/osr_host_display_client.h",
|
||||||
|
"atom/browser/osr/osr_host_display_client_mac.mm",
|
||||||
"atom/browser/osr/osr_render_widget_host_view.cc",
|
"atom/browser/osr/osr_render_widget_host_view.cc",
|
||||||
"atom/browser/osr/osr_render_widget_host_view.h",
|
"atom/browser/osr/osr_render_widget_host_view.h",
|
||||||
"atom/browser/osr/osr_render_widget_host_view_mac.mm",
|
"atom/browser/osr/osr_video_consumer.cc",
|
||||||
|
"atom/browser/osr/osr_video_consumer.h",
|
||||||
"atom/browser/osr/osr_view_proxy.cc",
|
"atom/browser/osr/osr_view_proxy.cc",
|
||||||
"atom/browser/osr/osr_view_proxy.h",
|
"atom/browser/osr/osr_view_proxy.h",
|
||||||
"atom/browser/osr/osr_web_contents_view.cc",
|
"atom/browser/osr/osr_web_contents_view.cc",
|
||||||
@@ -599,6 +637,11 @@ if (is_mac) {
|
|||||||
"ServiceManagement.framework",
|
"ServiceManagement.framework",
|
||||||
"StoreKit.framework",
|
"StoreKit.framework",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if (enable_osr) {
|
||||||
|
libs += [ "IOSurface.framework" ]
|
||||||
|
}
|
||||||
|
|
||||||
ldflags = [
|
ldflags = [
|
||||||
"-F",
|
"-F",
|
||||||
rebase_path("external_binaries", root_build_dir),
|
rebase_path("external_binaries", root_build_dir),
|
||||||
@@ -618,8 +661,10 @@ if (is_mac) {
|
|||||||
output_name = electron_helper_name
|
output_name = electron_helper_name
|
||||||
deps = [
|
deps = [
|
||||||
":electron_framework+link",
|
":electron_framework+link",
|
||||||
"//sandbox/mac:seatbelt",
|
|
||||||
]
|
]
|
||||||
|
if (!is_mas_build) {
|
||||||
|
deps += [ "//sandbox/mac:seatbelt" ]
|
||||||
|
}
|
||||||
defines = [ "HELPER_EXECUTABLE" ]
|
defines = [ "HELPER_EXECUTABLE" ]
|
||||||
sources = filenames.app_sources
|
sources = filenames.app_sources
|
||||||
include_dirs = [ "." ]
|
include_dirs = [ "." ]
|
||||||
@@ -914,6 +959,9 @@ dist_zip("electron_dist_zip") {
|
|||||||
":licenses",
|
":licenses",
|
||||||
":electron_version",
|
":electron_version",
|
||||||
]
|
]
|
||||||
|
if (is_linux) {
|
||||||
|
data_deps += [ "//sandbox/linux:chrome_sandbox" ]
|
||||||
|
}
|
||||||
outputs = [
|
outputs = [
|
||||||
"$root_build_dir/dist.zip",
|
"$root_build_dir/dist.zip",
|
||||||
]
|
]
|
||||||
@@ -954,26 +1002,3 @@ group("electron") {
|
|||||||
":electron_app",
|
":electron_app",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
group("electron_content_manifest_overlays") {
|
|
||||||
deps = [
|
|
||||||
":electron_content_browser_manifest_overlay",
|
|
||||||
":electron_content_packaged_services_manifest_overlay",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
service_manifest("electron_content_packaged_services_manifest_overlay") {
|
|
||||||
source = "//electron/manifests/electron_content_packaged_services_manifest_overlay.json"
|
|
||||||
packaged_services = [ "//services/proxy_resolver:proxy_resolver_manifest" ]
|
|
||||||
|
|
||||||
if (enable_basic_printing) {
|
|
||||||
packaged_services += [
|
|
||||||
"//chrome/services/printing:manifest",
|
|
||||||
"//components/services/pdf_compositor:pdf_compositor_manifest",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
service_manifest("electron_content_browser_manifest_overlay") {
|
|
||||||
source = "//electron/manifests/electron_content_browser_manifest_overlay.json"
|
|
||||||
}
|
|
||||||
|
|||||||
4
DEPS
4
DEPS
@@ -10,9 +10,9 @@ gclient_gn_args = [
|
|||||||
|
|
||||||
vars = {
|
vars = {
|
||||||
'chromium_version':
|
'chromium_version':
|
||||||
'72.0.3626.52',
|
'73.0.3683.121',
|
||||||
'node_version':
|
'node_version':
|
||||||
'ad2c89ec3be0f5db3ea02b0f591d36a5d84c51ad',
|
'a86a4a160dc520c61a602c949a32a1bc4c0fc633',
|
||||||
|
|
||||||
'boto_version': 'f7574aa6cc2c819430c1f05e9a1a1a666ef8169b',
|
'boto_version': 'f7574aa6cc2c819430c1f05e9a1a1a666ef8169b',
|
||||||
'pyyaml_version': '3.12',
|
'pyyaml_version': '3.12',
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
|||||||
locales \
|
locales \
|
||||||
lsb-release \
|
lsb-release \
|
||||||
nano \
|
nano \
|
||||||
python-dbusmock \
|
python-dbus \
|
||||||
python-pip \
|
python-pip \
|
||||||
python-setuptools \
|
python-setuptools \
|
||||||
sudo \
|
sudo \
|
||||||
@@ -33,6 +33,9 @@ RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \
|
|||||||
# crcmod is required by gsutil, which is used for filling the gclient git cache
|
# crcmod is required by gsutil, which is used for filling the gclient git cache
|
||||||
RUN pip install -U crcmod
|
RUN pip install -U crcmod
|
||||||
|
|
||||||
|
# dbusmock is needed for Electron tests
|
||||||
|
RUN pip install python-dbusmock
|
||||||
|
|
||||||
RUN mkdir /tmp/workspace
|
RUN mkdir /tmp/workspace
|
||||||
RUN chown builduser:builduser /tmp/workspace
|
RUN chown builduser:builduser /tmp/workspace
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
5.0.0-nightly.20190122
|
5.0.3
|
||||||
@@ -81,8 +81,6 @@ test_script:
|
|||||||
if ((-Not (Test-Path Env:\ELECTRON_RELEASE)) -And ($env:GN_CONFIG -in "testing", "release")) {
|
if ((-Not (Test-Path Env:\ELECTRON_RELEASE)) -And ($env:GN_CONFIG -in "testing", "release")) {
|
||||||
$env:RUN_TESTS="true"
|
$env:RUN_TESTS="true"
|
||||||
}
|
}
|
||||||
- if "%RUN_TESTS%"=="true" ( echo Verifying non proprietary ffmpeg & python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg )
|
|
||||||
- if "%RUN_TESTS%"=="true" ( echo Verifying mksnapshot & python electron\script\verify-mksnapshot.py --build-dir out\Default --source-root %cd% )
|
|
||||||
- ps: >-
|
- ps: >-
|
||||||
if ($env:RUN_TESTS -eq 'true') {
|
if ($env:RUN_TESTS -eq 'true') {
|
||||||
New-Item .\out\Default\gen\node_headers\Release -Type directory
|
New-Item .\out\Default\gen\node_headers\Release -Type directory
|
||||||
@@ -91,8 +89,12 @@ test_script:
|
|||||||
echo "Skipping tests for $env:GN_CONFIG build"
|
echo "Skipping tests for $env:GN_CONFIG build"
|
||||||
}
|
}
|
||||||
- cd electron
|
- cd electron
|
||||||
- if "%RUN_TESTS%"=="true" ( echo Running test suite & npm run test -- --ci )
|
- if "%RUN_TESTS%"=="true" ( echo Running test suite & npm run test -- --ci --enable-logging)
|
||||||
- cd ..
|
- cd ..
|
||||||
|
- if "%RUN_TESTS%"=="true" ( echo Verifying non proprietary ffmpeg & python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg )
|
||||||
|
- echo "About to verify mksnapshot"
|
||||||
|
- if "%RUN_TESTS%"=="true" ( echo Verifying mksnapshot & python electron\script\verify-mksnapshot.py --build-dir out\Default --source-root %cd% )
|
||||||
|
- echo "Done verifying mksnapshot"
|
||||||
deploy_script:
|
deploy_script:
|
||||||
- cd electron
|
- cd electron
|
||||||
- ps: >-
|
- ps: >-
|
||||||
|
|||||||
@@ -7,17 +7,14 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "atom/common/atom_version.h"
|
|
||||||
#include "atom/common/options_switches.h"
|
#include "atom/common/options_switches.h"
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
#include "base/files/file_util.h"
|
#include "base/files/file_util.h"
|
||||||
#include "base/strings/string_split.h"
|
#include "base/strings/string_split.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "chrome/common/chrome_version.h"
|
|
||||||
#include "content/public/common/content_constants.h"
|
#include "content/public/common/content_constants.h"
|
||||||
#include "content/public/common/pepper_plugin_info.h"
|
#include "content/public/common/pepper_plugin_info.h"
|
||||||
#include "content/public/common/user_agent.h"
|
|
||||||
#include "electron/buildflags/buildflags.h"
|
#include "electron/buildflags/buildflags.h"
|
||||||
#include "ppapi/shared_impl/ppapi_permissions.h"
|
#include "ppapi/shared_impl/ppapi_permissions.h"
|
||||||
#include "ui/base/l10n/l10n_util.h"
|
#include "ui/base/l10n/l10n_util.h"
|
||||||
@@ -180,16 +177,6 @@ AtomContentClient::AtomContentClient() {}
|
|||||||
|
|
||||||
AtomContentClient::~AtomContentClient() {}
|
AtomContentClient::~AtomContentClient() {}
|
||||||
|
|
||||||
std::string AtomContentClient::GetProduct() const {
|
|
||||||
return "Chrome/" CHROME_VERSION_STRING;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string AtomContentClient::GetUserAgent() const {
|
|
||||||
return content::BuildUserAgentFromProduct("Chrome/" CHROME_VERSION_STRING
|
|
||||||
" " ATOM_PRODUCT_NAME
|
|
||||||
"/" ATOM_VERSION_STRING);
|
|
||||||
}
|
|
||||||
|
|
||||||
base::string16 AtomContentClient::GetLocalizedString(int message_id) const {
|
base::string16 AtomContentClient::GetLocalizedString(int message_id) const {
|
||||||
return l10n_util::GetStringUTF16(message_id);
|
return l10n_util::GetStringUTF16(message_id);
|
||||||
}
|
}
|
||||||
@@ -213,18 +200,30 @@ base::RefCountedMemory* AtomContentClient::GetDataResourceBytes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AtomContentClient::AddAdditionalSchemes(Schemes* schemes) {
|
void AtomContentClient::AddAdditionalSchemes(Schemes* schemes) {
|
||||||
schemes->standard_schemes.push_back("chrome-extension");
|
|
||||||
|
|
||||||
std::vector<std::string> splited;
|
std::vector<std::string> splited;
|
||||||
ConvertStringWithSeparatorToVector(&splited, ",",
|
ConvertStringWithSeparatorToVector(&splited, ",",
|
||||||
switches::kRegisterServiceWorkerSchemes);
|
switches::kServiceWorkerSchemes);
|
||||||
for (const std::string& scheme : splited)
|
for (const std::string& scheme : splited)
|
||||||
schemes->service_worker_schemes.push_back(scheme);
|
schemes->service_worker_schemes.push_back(scheme);
|
||||||
schemes->service_worker_schemes.push_back(url::kFileScheme);
|
schemes->service_worker_schemes.push_back(url::kFileScheme);
|
||||||
|
|
||||||
|
ConvertStringWithSeparatorToVector(&splited, ",", switches::kStandardSchemes);
|
||||||
|
for (const std::string& scheme : splited)
|
||||||
|
schemes->standard_schemes.push_back(scheme);
|
||||||
|
schemes->standard_schemes.push_back("chrome-extension");
|
||||||
|
|
||||||
ConvertStringWithSeparatorToVector(&splited, ",", switches::kSecureSchemes);
|
ConvertStringWithSeparatorToVector(&splited, ",", switches::kSecureSchemes);
|
||||||
for (const std::string& scheme : splited)
|
for (const std::string& scheme : splited)
|
||||||
schemes->secure_schemes.push_back(scheme);
|
schemes->secure_schemes.push_back(scheme);
|
||||||
|
|
||||||
|
ConvertStringWithSeparatorToVector(&splited, ",",
|
||||||
|
switches::kBypassCSPSchemes);
|
||||||
|
for (const std::string& scheme : splited)
|
||||||
|
schemes->csp_bypassing_schemes.push_back(scheme);
|
||||||
|
|
||||||
|
ConvertStringWithSeparatorToVector(&splited, ",", switches::kCORSSchemes);
|
||||||
|
for (const std::string& scheme : splited)
|
||||||
|
schemes->cors_enabled_schemes.push_back(scheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomContentClient::AddPepperPlugins(
|
void AtomContentClient::AddPepperPlugins(
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ class AtomContentClient : public content::ContentClient {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// content::ContentClient:
|
// content::ContentClient:
|
||||||
std::string GetProduct() const override;
|
|
||||||
std::string GetUserAgent() const override;
|
|
||||||
base::string16 GetLocalizedString(int message_id) const override;
|
base::string16 GetLocalizedString(int message_id) const override;
|
||||||
base::StringPiece GetDataResource(int resource_id,
|
base::StringPiece GetDataResource(int resource_id,
|
||||||
ui::ScaleFactor) const override;
|
ui::ScaleFactor) const override;
|
||||||
|
|||||||
@@ -43,9 +43,9 @@
|
|||||||
#include "base/i18n/icu_util.h"
|
#include "base/i18n/icu_util.h"
|
||||||
#include "electron/buildflags/buildflags.h"
|
#include "electron/buildflags/buildflags.h"
|
||||||
|
|
||||||
#if defined(HELPER_EXECUTABLE)
|
#if defined(HELPER_EXECUTABLE) && !defined(MAS_BUILD)
|
||||||
#include "sandbox/mac/seatbelt_exec.h" // nogncheck
|
#include "sandbox/mac/seatbelt_exec.h" // nogncheck
|
||||||
#endif // defined(HELPER_EXECUTABLE)
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ int main(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HELPER_EXECUTABLE)
|
#if defined(HELPER_EXECUTABLE) && !defined(MAS_BUILD)
|
||||||
uint32_t exec_path_size = 0;
|
uint32_t exec_path_size = 0;
|
||||||
int rv = _NSGetExecutablePath(NULL, &exec_path_size);
|
int rv = _NSGetExecutablePath(NULL, &exec_path_size);
|
||||||
if (rv != -1) {
|
if (rv != -1) {
|
||||||
@@ -240,7 +240,7 @@ int main(int argc, char* argv[]) {
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif // defined(HELPER_EXECUTABLE) && !defined(MAS_BUILD)
|
||||||
|
|
||||||
return AtomMain(argc, argv);
|
return AtomMain(argc, argv);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,6 +164,9 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
|
|||||||
if (env->HasVar("ELECTRON_ENABLE_STACK_DUMPING"))
|
if (env->HasVar("ELECTRON_ENABLE_STACK_DUMPING"))
|
||||||
base::debug::EnableInProcessStackDumping();
|
base::debug::EnableInProcessStackDumping();
|
||||||
|
|
||||||
|
if (env->HasVar("ELECTRON_DISABLE_SANDBOX"))
|
||||||
|
command_line->AppendSwitch(service_manager::switches::kNoSandbox);
|
||||||
|
|
||||||
chrome::RegisterPathProvider();
|
chrome::RegisterPathProvider();
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
@@ -234,10 +237,6 @@ void AtomMainDelegate::PreSandboxStartup() {
|
|||||||
if (!IsBrowserProcess(command_line))
|
if (!IsBrowserProcess(command_line))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Disable setuid sandbox since it is not longer required on
|
|
||||||
// linux (namespace sandbox is available on most distros).
|
|
||||||
command_line->AppendSwitch(service_manager::switches::kDisableSetuidSandbox);
|
|
||||||
|
|
||||||
// Allow file:// URIs to read other file:// URIs by default.
|
// Allow file:// URIs to read other file:// URIs by default.
|
||||||
command_line->AppendSwitch(::switches::kAllowFileAccessFromFiles);
|
command_line->AppendSwitch(::switches::kAllowFileAccessFromFiles);
|
||||||
|
|
||||||
|
|||||||
44
atom/app/manifests.cc
Normal file
44
atom/app/manifests.cc
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
// Copyright (c) 2019 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "atom/app/manifests.h"
|
||||||
|
|
||||||
|
#include "base/no_destructor.h"
|
||||||
|
#include "printing/buildflags/buildflags.h"
|
||||||
|
#include "services/proxy_resolver/proxy_resolver_manifest.h"
|
||||||
|
#include "services/service_manager/public/cpp/manifest_builder.h"
|
||||||
|
|
||||||
|
#if BUILDFLAG(ENABLE_PRINTING)
|
||||||
|
#include "components/services/pdf_compositor/pdf_compositor_manifest.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||||
|
#include "chrome/services/printing/manifest.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const service_manager::Manifest& GetElectronContentBrowserOverlayManifest() {
|
||||||
|
static base::NoDestructor<service_manager::Manifest> manifest{
|
||||||
|
service_manager::ManifestBuilder()
|
||||||
|
.WithDisplayName("Electron (browser process)")
|
||||||
|
.RequireCapability("device", "device:geolocation_control")
|
||||||
|
.RequireCapability("proxy_resolver", "factory")
|
||||||
|
.RequireCapability("chrome_printing", "converter")
|
||||||
|
.RequireCapability("pdf_compositor", "compositor")
|
||||||
|
.Build()};
|
||||||
|
return *manifest;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<service_manager::Manifest>&
|
||||||
|
GetElectronPackagedServicesOverlayManifest() {
|
||||||
|
static base::NoDestructor<std::vector<service_manager::Manifest>> manifests{{
|
||||||
|
proxy_resolver::GetManifest(),
|
||||||
|
#if BUILDFLAG(ENABLE_PRINTING)
|
||||||
|
pdf_compositor::GetManifest(),
|
||||||
|
#endif
|
||||||
|
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||||
|
chrome_printing::GetManifest(),
|
||||||
|
#endif
|
||||||
|
}};
|
||||||
|
return *manifests;
|
||||||
|
}
|
||||||
16
atom/app/manifests.h
Normal file
16
atom/app/manifests.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
// Copyright (c) 2019 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef ATOM_APP_MANIFESTS_H_
|
||||||
|
#define ATOM_APP_MANIFESTS_H_
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "services/service_manager/public/cpp/manifest.h"
|
||||||
|
|
||||||
|
const service_manager::Manifest& GetElectronContentBrowserOverlayManifest();
|
||||||
|
const std::vector<service_manager::Manifest>&
|
||||||
|
GetElectronPackagedServicesOverlayManifest();
|
||||||
|
|
||||||
|
#endif // ATOM_APP_MANIFESTS_H_
|
||||||
@@ -96,6 +96,7 @@ int NodeMain(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
} while (more == true);
|
} while (more == true);
|
||||||
|
|
||||||
|
node_debugger.Stop();
|
||||||
exit_code = node::EmitExit(env);
|
exit_code = node::EmitExit(env);
|
||||||
node::RunAtExit(env);
|
node::RunAtExit(env);
|
||||||
gin_env.platform()->DrainTasks(env->isolate());
|
gin_env.platform()->DrainTasks(env->isolate());
|
||||||
|
|||||||
@@ -533,12 +533,11 @@ int ImportIntoCertStore(CertificateManagerModel* model,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void OnIconDataAvailable(scoped_refptr<util::Promise> promise,
|
void OnIconDataAvailable(util::Promise promise, gfx::Image* icon) {
|
||||||
gfx::Image* icon) {
|
|
||||||
if (icon && !icon->IsEmpty()) {
|
if (icon && !icon->IsEmpty()) {
|
||||||
promise->Resolve(*icon);
|
promise.Resolve(*icon);
|
||||||
} else {
|
} else {
|
||||||
promise->RejectWithErrorMessage("Failed to get file icon.");
|
promise.RejectWithErrorMessage("Failed to get file icon.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -690,7 +689,7 @@ bool App::CanCreateWindow(
|
|||||||
content::RenderFrameHost* opener,
|
content::RenderFrameHost* opener,
|
||||||
const GURL& opener_url,
|
const GURL& opener_url,
|
||||||
const GURL& opener_top_level_frame_url,
|
const GURL& opener_top_level_frame_url,
|
||||||
const GURL& source_origin,
|
const url::Origin& source_origin,
|
||||||
content::mojom::WindowContainerType container_type,
|
content::mojom::WindowContainerType container_type,
|
||||||
const GURL& target_url,
|
const GURL& target_url,
|
||||||
const content::Referrer& referrer,
|
const content::Referrer& referrer,
|
||||||
@@ -1126,7 +1125,8 @@ JumpListResult App::SetJumpList(v8::Local<v8::Value> val,
|
|||||||
|
|
||||||
v8::Local<v8::Promise> App::GetFileIcon(const base::FilePath& path,
|
v8::Local<v8::Promise> App::GetFileIcon(const base::FilePath& path,
|
||||||
mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
scoped_refptr<util::Promise> promise = new util::Promise(isolate());
|
util::Promise promise(isolate());
|
||||||
|
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||||
base::FilePath normalized_path = path.NormalizePathSeparators();
|
base::FilePath normalized_path = path.NormalizePathSeparators();
|
||||||
|
|
||||||
IconLoader::IconSize icon_size;
|
IconLoader::IconSize icon_size;
|
||||||
@@ -1143,13 +1143,14 @@ v8::Local<v8::Promise> App::GetFileIcon(const base::FilePath& path,
|
|||||||
gfx::Image* icon =
|
gfx::Image* icon =
|
||||||
icon_manager->LookupIconFromFilepath(normalized_path, icon_size);
|
icon_manager->LookupIconFromFilepath(normalized_path, icon_size);
|
||||||
if (icon) {
|
if (icon) {
|
||||||
promise->Resolve(*icon);
|
promise.Resolve(*icon);
|
||||||
} else {
|
} else {
|
||||||
icon_manager->LoadIcon(normalized_path, icon_size,
|
icon_manager->LoadIcon(
|
||||||
base::Bind(&OnIconDataAvailable, promise),
|
normalized_path, icon_size,
|
||||||
&cancelable_task_tracker_);
|
base::BindOnce(&OnIconDataAvailable, std::move(promise)),
|
||||||
|
&cancelable_task_tracker_);
|
||||||
}
|
}
|
||||||
return promise->GetHandle();
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<mate::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
|
std::vector<mate::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
|
||||||
@@ -1197,30 +1198,30 @@ v8::Local<v8::Value> App::GetGPUFeatureStatus(v8::Isolate* isolate) {
|
|||||||
v8::Local<v8::Promise> App::GetGPUInfo(v8::Isolate* isolate,
|
v8::Local<v8::Promise> App::GetGPUInfo(v8::Isolate* isolate,
|
||||||
const std::string& info_type) {
|
const std::string& info_type) {
|
||||||
auto* const gpu_data_manager = content::GpuDataManagerImpl::GetInstance();
|
auto* const gpu_data_manager = content::GpuDataManagerImpl::GetInstance();
|
||||||
scoped_refptr<util::Promise> promise = new util::Promise(isolate);
|
util::Promise promise(isolate);
|
||||||
|
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||||
if (info_type != "basic" && info_type != "complete") {
|
if (info_type != "basic" && info_type != "complete") {
|
||||||
promise->RejectWithErrorMessage(
|
promise.RejectWithErrorMessage(
|
||||||
"Invalid info type. Use 'basic' or 'complete'");
|
"Invalid info type. Use 'basic' or 'complete'");
|
||||||
return promise->GetHandle();
|
return handle;
|
||||||
}
|
}
|
||||||
std::string reason;
|
std::string reason;
|
||||||
if (!gpu_data_manager->GpuAccessAllowed(&reason)) {
|
if (!gpu_data_manager->GpuAccessAllowed(&reason)) {
|
||||||
promise->RejectWithErrorMessage("GPU access not allowed. Reason: " +
|
promise.RejectWithErrorMessage("GPU access not allowed. Reason: " + reason);
|
||||||
reason);
|
return handle;
|
||||||
return promise->GetHandle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* const info_mgr = GPUInfoManager::GetInstance();
|
auto* const info_mgr = GPUInfoManager::GetInstance();
|
||||||
if (info_type == "complete") {
|
if (info_type == "complete") {
|
||||||
#if defined(OS_WIN) || defined(OS_MACOSX)
|
#if defined(OS_WIN) || defined(OS_MACOSX)
|
||||||
info_mgr->FetchCompleteInfo(promise);
|
info_mgr->FetchCompleteInfo(std::move(promise));
|
||||||
#else
|
#else
|
||||||
info_mgr->FetchBasicInfo(promise);
|
info_mgr->FetchBasicInfo(std::move(promise));
|
||||||
#endif
|
#endif
|
||||||
} else /* (info_type == "basic") */ {
|
} else /* (info_type == "basic") */ {
|
||||||
info_mgr->FetchBasicInfo(promise);
|
info_mgr->FetchBasicInfo(std::move(promise));
|
||||||
}
|
}
|
||||||
return promise->GetHandle();
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void RemoveNoSandboxSwitch(base::CommandLine* command_line) {
|
static void RemoveNoSandboxSwitch(base::CommandLine* command_line) {
|
||||||
@@ -1412,4 +1413,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_app, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_app, Initialize)
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ class App : public AtomBrowserClient::Delegate,
|
|||||||
bool CanCreateWindow(content::RenderFrameHost* opener,
|
bool CanCreateWindow(content::RenderFrameHost* opener,
|
||||||
const GURL& opener_url,
|
const GURL& opener_url,
|
||||||
const GURL& opener_top_level_frame_url,
|
const GURL& opener_top_level_frame_url,
|
||||||
const GURL& source_origin,
|
const url::Origin& source_origin,
|
||||||
content::mojom::WindowContainerType container_type,
|
content::mojom::WindowContainerType container_type,
|
||||||
const GURL& target_url,
|
const GURL& target_url,
|
||||||
const content::Referrer& referrer,
|
const content::Referrer& referrer,
|
||||||
|
|||||||
@@ -154,4 +154,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_auto_updater, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_auto_updater, Initialize)
|
||||||
|
|||||||
@@ -172,4 +172,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_browser_view, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_browser_view, Initialize)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "atom/common/options_switches.h"
|
#include "atom/common/options_switches.h"
|
||||||
#include "base/threading/thread_task_runner_handle.h"
|
#include "base/threading/thread_task_runner_handle.h"
|
||||||
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
||||||
|
#include "content/browser/renderer_host/render_widget_host_owner_delegate.h"
|
||||||
#include "content/public/browser/render_process_host.h"
|
#include "content/public/browser/render_process_host.h"
|
||||||
#include "content/public/browser/render_view_host.h"
|
#include "content/public/browser/render_view_host.h"
|
||||||
#include "gin/converter.h"
|
#include "gin/converter.h"
|
||||||
@@ -130,7 +131,7 @@ void BrowserWindow::RenderViewCreated(
|
|||||||
render_view_host->GetProcess()->GetID(),
|
render_view_host->GetProcess()->GetID(),
|
||||||
render_view_host->GetRoutingID());
|
render_view_host->GetRoutingID());
|
||||||
if (impl)
|
if (impl)
|
||||||
impl->SetBackgroundOpaque(false);
|
impl->owner_delegate()->SetBackgroundOpaque(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWindow::DidFirstVisuallyNonEmptyPaint() {
|
void BrowserWindow::DidFirstVisuallyNonEmptyPaint() {
|
||||||
@@ -349,7 +350,8 @@ void BrowserWindow::SetVibrancy(v8::Isolate* isolate,
|
|||||||
render_view_host->GetProcess()->GetID(),
|
render_view_host->GetProcess()->GetID(),
|
||||||
render_view_host->GetRoutingID());
|
render_view_host->GetRoutingID());
|
||||||
if (impl)
|
if (impl)
|
||||||
impl->SetBackgroundOpaque(type.empty() ? !window_->transparent() : false);
|
impl->owner_delegate()->SetBackgroundOpaque(
|
||||||
|
type.empty() ? !window_->transparent() : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
TopLevelWindow::SetVibrancy(isolate, value);
|
TopLevelWindow::SetVibrancy(isolate, value);
|
||||||
@@ -479,4 +481,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_window, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_window, Initialize)
|
||||||
|
|||||||
@@ -8,8 +8,10 @@
|
|||||||
#include "atom/common/native_mate_converters/callback.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/file_path_converter.h"
|
||||||
#include "atom/common/native_mate_converters/value_converter.h"
|
#include "atom/common/native_mate_converters/value_converter.h"
|
||||||
|
#include "atom/common/promise_util.h"
|
||||||
#include "base/bind.h"
|
#include "base/bind.h"
|
||||||
#include "base/files/file_util.h"
|
#include "base/files/file_util.h"
|
||||||
|
#include "base/threading/thread_restrictions.h"
|
||||||
#include "content/public/browser/tracing_controller.h"
|
#include "content/public/browser/tracing_controller.h"
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
|
|
||||||
@@ -58,6 +60,11 @@ scoped_refptr<TracingController::TraceDataEndpoint> GetTraceDataEndpoint(
|
|||||||
const base::FilePath& path,
|
const base::FilePath& path,
|
||||||
const CompletionCallback& callback) {
|
const CompletionCallback& callback) {
|
||||||
base::FilePath result_file_path = path;
|
base::FilePath result_file_path = path;
|
||||||
|
|
||||||
|
// base::CreateTemporaryFile prevents blocking so we need to allow it
|
||||||
|
// for now since offloading this to a different sequence would require
|
||||||
|
// changing the api shape
|
||||||
|
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
||||||
if (result_file_path.empty() && !base::CreateTemporaryFile(&result_file_path))
|
if (result_file_path.empty() && !base::CreateTemporaryFile(&result_file_path))
|
||||||
LOG(ERROR) << "Creating temporary file failed";
|
LOG(ERROR) << "Creating temporary file failed";
|
||||||
|
|
||||||
@@ -65,23 +72,53 @@ scoped_refptr<TracingController::TraceDataEndpoint> GetTraceDataEndpoint(
|
|||||||
result_file_path, base::Bind(callback, result_file_path));
|
result_file_path, base::Bind(callback, result_file_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
void StopRecording(const base::FilePath& path,
|
void OnRecordingStopped(const atom::util::CopyablePromise& promise,
|
||||||
const CompletionCallback& callback) {
|
const base::FilePath& path) {
|
||||||
TracingController::GetInstance()->StopTracing(
|
promise.GetPromise().Resolve(path);
|
||||||
GetTraceDataEndpoint(path, callback));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetCategories(
|
v8::Local<v8::Promise> StopRecording(v8::Isolate* isolate,
|
||||||
const base::RepeatingCallback<void(const std::set<std::string>&)>&
|
const base::FilePath& path) {
|
||||||
callback) {
|
atom::util::Promise promise(isolate);
|
||||||
return TracingController::GetInstance()->GetCategories(
|
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||||
base::BindOnce(callback));
|
|
||||||
|
// TODO(zcbenz): Remove the use of CopyablePromise when the
|
||||||
|
// CreateFileEndpoint API accepts OnceCallback.
|
||||||
|
TracingController::GetInstance()->StopTracing(GetTraceDataEndpoint(
|
||||||
|
path,
|
||||||
|
base::Bind(&OnRecordingStopped, atom::util::CopyablePromise(promise))));
|
||||||
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StartTracing(const base::trace_event::TraceConfig& trace_config,
|
void OnCategoriesAvailable(atom::util::Promise promise,
|
||||||
const base::RepeatingCallback<void()>& callback) {
|
const std::set<std::string>& categories) {
|
||||||
return TracingController::GetInstance()->StartTracing(
|
promise.Resolve(categories);
|
||||||
trace_config, base::BindOnce(callback));
|
}
|
||||||
|
|
||||||
|
v8::Local<v8::Promise> GetCategories(v8::Isolate* isolate) {
|
||||||
|
atom::util::Promise promise(isolate);
|
||||||
|
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||||
|
|
||||||
|
// Note: This method always succeeds.
|
||||||
|
TracingController::GetInstance()->GetCategories(
|
||||||
|
base::BindOnce(&OnCategoriesAvailable, std::move(promise)));
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnTracingStarted(atom::util::Promise promise) {
|
||||||
|
promise.Resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
v8::Local<v8::Promise> StartTracing(
|
||||||
|
v8::Isolate* isolate,
|
||||||
|
const base::trace_event::TraceConfig& trace_config) {
|
||||||
|
atom::util::Promise promise(isolate);
|
||||||
|
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||||
|
|
||||||
|
// Note: This method always succeeds.
|
||||||
|
TracingController::GetInstance()->StartTracing(
|
||||||
|
trace_config, base::BindOnce(&OnTracingStarted, std::move(promise)));
|
||||||
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetTraceBufferUsage(
|
bool GetTraceBufferUsage(
|
||||||
@@ -103,4 +140,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_content_tracing, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_content_tracing, Initialize)
|
||||||
|
|||||||
@@ -136,67 +136,96 @@ inline net::CookieStore* GetCookieStore(
|
|||||||
return getter->GetURLRequestContext()->cookie_store();
|
return getter->GetURLRequestContext()->cookie_store();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResolvePromiseWithCookies(util::Promise promise,
|
||||||
|
const net::CookieList& cookie_list) {
|
||||||
|
promise.Resolve(cookie_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResolvePromise(util::Promise promise) {
|
||||||
|
promise.Resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resolve |promise| in UI thread.
|
||||||
|
void ResolvePromiseInUI(util::Promise promise) {
|
||||||
|
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
|
||||||
|
base::BindOnce(ResolvePromise, std::move(promise)));
|
||||||
|
}
|
||||||
|
|
||||||
// Run |callback| on UI thread.
|
// Run |callback| on UI thread.
|
||||||
void RunCallbackInUI(const base::Closure& callback) {
|
void RunCallbackInUI(base::OnceClosure callback) {
|
||||||
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, callback);
|
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, std::move(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove cookies from |list| not matching |filter|, and pass it to |callback|.
|
// Remove cookies from |list| not matching |filter|, and pass it to |callback|.
|
||||||
void FilterCookies(std::unique_ptr<base::DictionaryValue> filter,
|
void FilterCookies(std::unique_ptr<base::DictionaryValue> filter,
|
||||||
const Cookies::GetCallback& callback,
|
util::Promise promise,
|
||||||
const net::CookieList& list) {
|
const net::CookieList& list) {
|
||||||
net::CookieList result;
|
net::CookieList result;
|
||||||
for (const auto& cookie : list) {
|
for (const auto& cookie : list) {
|
||||||
if (MatchesCookie(filter.get(), cookie))
|
if (MatchesCookie(filter.get(), cookie))
|
||||||
result.push_back(cookie);
|
result.push_back(cookie);
|
||||||
}
|
}
|
||||||
RunCallbackInUI(base::Bind(callback, Cookies::SUCCESS, result));
|
|
||||||
|
base::PostTaskWithTraits(
|
||||||
|
FROM_HERE, {BrowserThread::UI},
|
||||||
|
base::BindOnce(ResolvePromiseWithCookies, std::move(promise), result));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receives cookies matching |filter| in IO thread.
|
// Receives cookies matching |filter| in IO thread.
|
||||||
void GetCookiesOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
void GetCookiesOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||||
std::unique_ptr<base::DictionaryValue> filter,
|
std::unique_ptr<base::DictionaryValue> filter,
|
||||||
const Cookies::GetCallback& callback) {
|
util::Promise promise) {
|
||||||
std::string url;
|
std::string url;
|
||||||
filter->GetString("url", &url);
|
filter->GetString("url", &url);
|
||||||
|
|
||||||
auto filtered_callback =
|
auto filtered_callback =
|
||||||
base::Bind(FilterCookies, base::Passed(&filter), callback);
|
base::BindOnce(FilterCookies, std::move(filter), std::move(promise));
|
||||||
|
|
||||||
// Empty url will match all url cookies.
|
// Empty url will match all url cookies.
|
||||||
if (url.empty())
|
if (url.empty())
|
||||||
GetCookieStore(getter)->GetAllCookiesAsync(filtered_callback);
|
GetCookieStore(getter)->GetAllCookiesAsync(std::move(filtered_callback));
|
||||||
else
|
else
|
||||||
GetCookieStore(getter)->GetAllCookiesForURLAsync(GURL(url),
|
GetCookieStore(getter)->GetAllCookiesForURLAsync(
|
||||||
filtered_callback);
|
GURL(url), std::move(filtered_callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Removes cookie with |url| and |name| in IO thread.
|
// Removes cookie with |url| and |name| in IO thread.
|
||||||
void RemoveCookieOnIOThread(scoped_refptr<net::URLRequestContextGetter> getter,
|
void RemoveCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||||
const GURL& url,
|
const GURL& url,
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
const base::Closure& callback) {
|
util::Promise promise) {
|
||||||
GetCookieStore(getter)->DeleteCookieAsync(
|
GetCookieStore(getter)->DeleteCookieAsync(
|
||||||
url, name, base::BindOnce(RunCallbackInUI, callback));
|
url, name, base::BindOnce(ResolvePromiseInUI, std::move(promise)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resolves/rejects the |promise| in UI thread.
|
||||||
|
void SettlePromiseInUI(util::Promise promise, const std::string& errmsg) {
|
||||||
|
if (errmsg.empty()) {
|
||||||
|
promise.Resolve();
|
||||||
|
} else {
|
||||||
|
promise.RejectWithErrorMessage(errmsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback of SetCookie.
|
// Callback of SetCookie.
|
||||||
void OnSetCookie(const Cookies::SetCallback& callback, bool success) {
|
void OnSetCookie(util::Promise promise, bool success) {
|
||||||
|
const std::string errmsg = success ? "" : "Setting cookie failed";
|
||||||
RunCallbackInUI(
|
RunCallbackInUI(
|
||||||
base::Bind(callback, success ? Cookies::SUCCESS : Cookies::FAILED));
|
base::BindOnce(SettlePromiseInUI, std::move(promise), errmsg));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flushes cookie store in IO thread.
|
// Flushes cookie store in IO thread.
|
||||||
void FlushCookieStoreOnIOThread(
|
void FlushCookieStoreOnIOThread(
|
||||||
scoped_refptr<net::URLRequestContextGetter> getter,
|
scoped_refptr<net::URLRequestContextGetter> getter,
|
||||||
const base::Closure& callback) {
|
util::Promise promise) {
|
||||||
GetCookieStore(getter)->FlushStore(base::BindOnce(RunCallbackInUI, callback));
|
GetCookieStore(getter)->FlushStore(
|
||||||
|
base::BindOnce(ResolvePromiseInUI, std::move(promise)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets cookie with |details| in IO thread.
|
// Sets cookie with |details| in IO thread.
|
||||||
void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||||
std::unique_ptr<base::DictionaryValue> details,
|
std::unique_ptr<base::DictionaryValue> details,
|
||||||
const Cookies::SetCallback& callback) {
|
util::Promise promise) {
|
||||||
std::string url, name, value, domain, path;
|
std::string url, name, value, domain, path;
|
||||||
bool secure = false;
|
bool secure = false;
|
||||||
bool http_only = false;
|
bool http_only = false;
|
||||||
@@ -237,7 +266,7 @@ void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
|||||||
GURL(url), name, value, domain, path, creation_time, expiration_time,
|
GURL(url), name, value, domain, path, creation_time, expiration_time,
|
||||||
last_access_time, secure, http_only,
|
last_access_time, secure, http_only,
|
||||||
net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT));
|
net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT));
|
||||||
auto completion_callback = base::BindOnce(OnSetCookie, callback);
|
auto completion_callback = base::BindOnce(OnSetCookie, std::move(promise));
|
||||||
if (!canonical_cookie || !canonical_cookie->IsCanonical()) {
|
if (!canonical_cookie || !canonical_cookie->IsCanonical()) {
|
||||||
std::move(completion_callback).Run(false);
|
std::move(completion_callback).Run(false);
|
||||||
return;
|
return;
|
||||||
@@ -267,43 +296,61 @@ Cookies::Cookies(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
|||||||
|
|
||||||
Cookies::~Cookies() {}
|
Cookies::~Cookies() {}
|
||||||
|
|
||||||
void Cookies::Get(const base::DictionaryValue& filter,
|
v8::Local<v8::Promise> Cookies::Get(const base::DictionaryValue& filter) {
|
||||||
const GetCallback& callback) {
|
util::Promise promise(isolate());
|
||||||
|
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||||
|
|
||||||
auto copy = base::DictionaryValue::From(
|
auto copy = base::DictionaryValue::From(
|
||||||
base::Value::ToUniquePtrValue(filter.Clone()));
|
base::Value::ToUniquePtrValue(filter.Clone()));
|
||||||
auto* getter = browser_context_->GetRequestContext();
|
auto* getter = browser_context_->GetRequestContext();
|
||||||
base::PostTaskWithTraits(
|
base::PostTaskWithTraits(
|
||||||
FROM_HERE, {BrowserThread::IO},
|
FROM_HERE, {BrowserThread::IO},
|
||||||
base::BindOnce(GetCookiesOnIO, base::RetainedRef(getter), std::move(copy),
|
base::BindOnce(GetCookiesOnIO, base::RetainedRef(getter), std::move(copy),
|
||||||
callback));
|
std::move(promise)));
|
||||||
|
|
||||||
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cookies::Remove(const GURL& url,
|
v8::Local<v8::Promise> Cookies::Remove(const GURL& url,
|
||||||
const std::string& name,
|
const std::string& name) {
|
||||||
const base::Closure& callback) {
|
util::Promise promise(isolate());
|
||||||
|
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||||
|
|
||||||
auto* getter = browser_context_->GetRequestContext();
|
auto* getter = browser_context_->GetRequestContext();
|
||||||
base::PostTaskWithTraits(
|
base::PostTaskWithTraits(
|
||||||
FROM_HERE, {BrowserThread::IO},
|
FROM_HERE, {BrowserThread::IO},
|
||||||
base::BindOnce(RemoveCookieOnIOThread, base::RetainedRef(getter), url,
|
base::BindOnce(RemoveCookieOnIO, base::RetainedRef(getter), url, name,
|
||||||
name, callback));
|
std::move(promise)));
|
||||||
|
|
||||||
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cookies::Set(const base::DictionaryValue& details,
|
v8::Local<v8::Promise> Cookies::Set(const base::DictionaryValue& details) {
|
||||||
const SetCallback& callback) {
|
util::Promise promise(isolate());
|
||||||
|
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||||
|
|
||||||
auto copy = base::DictionaryValue::From(
|
auto copy = base::DictionaryValue::From(
|
||||||
base::Value::ToUniquePtrValue(details.Clone()));
|
base::Value::ToUniquePtrValue(details.Clone()));
|
||||||
auto* getter = browser_context_->GetRequestContext();
|
auto* getter = browser_context_->GetRequestContext();
|
||||||
base::PostTaskWithTraits(
|
base::PostTaskWithTraits(
|
||||||
FROM_HERE, {BrowserThread::IO},
|
FROM_HERE, {BrowserThread::IO},
|
||||||
base::BindOnce(SetCookieOnIO, base::RetainedRef(getter), std::move(copy),
|
base::BindOnce(SetCookieOnIO, base::RetainedRef(getter), std::move(copy),
|
||||||
callback));
|
std::move(promise)));
|
||||||
|
|
||||||
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cookies::FlushStore(const base::Closure& callback) {
|
v8::Local<v8::Promise> Cookies::FlushStore() {
|
||||||
|
util::Promise promise(isolate());
|
||||||
|
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||||
|
|
||||||
auto* getter = browser_context_->GetRequestContext();
|
auto* getter = browser_context_->GetRequestContext();
|
||||||
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::IO},
|
base::PostTaskWithTraits(
|
||||||
base::BindOnce(FlushCookieStoreOnIOThread,
|
FROM_HERE, {BrowserThread::IO},
|
||||||
base::RetainedRef(getter), callback));
|
base::BindOnce(FlushCookieStoreOnIOThread, base::RetainedRef(getter),
|
||||||
|
std::move(promise)));
|
||||||
|
|
||||||
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cookies::OnCookieChanged(const CookieDetails* details) {
|
void Cookies::OnCookieChanged(const CookieDetails* details) {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "atom/browser/api/trackable_object.h"
|
#include "atom/browser/api/trackable_object.h"
|
||||||
#include "atom/browser/net/cookie_details.h"
|
#include "atom/browser/net/cookie_details.h"
|
||||||
|
#include "atom/common/promise_util.h"
|
||||||
#include "base/callback_list.h"
|
#include "base/callback_list.h"
|
||||||
#include "native_mate/handle.h"
|
#include "native_mate/handle.h"
|
||||||
#include "net/cookies/canonical_cookie.h"
|
#include "net/cookies/canonical_cookie.h"
|
||||||
@@ -35,9 +36,6 @@ class Cookies : public mate::TrackableObject<Cookies> {
|
|||||||
FAILED,
|
FAILED,
|
||||||
};
|
};
|
||||||
|
|
||||||
using GetCallback = base::Callback<void(Error, const net::CookieList&)>;
|
|
||||||
using SetCallback = base::Callback<void(Error)>;
|
|
||||||
|
|
||||||
static mate::Handle<Cookies> Create(v8::Isolate* isolate,
|
static mate::Handle<Cookies> Create(v8::Isolate* isolate,
|
||||||
AtomBrowserContext* browser_context);
|
AtomBrowserContext* browser_context);
|
||||||
|
|
||||||
@@ -49,12 +47,10 @@ class Cookies : public mate::TrackableObject<Cookies> {
|
|||||||
Cookies(v8::Isolate* isolate, AtomBrowserContext* browser_context);
|
Cookies(v8::Isolate* isolate, AtomBrowserContext* browser_context);
|
||||||
~Cookies() override;
|
~Cookies() override;
|
||||||
|
|
||||||
void Get(const base::DictionaryValue& filter, const GetCallback& callback);
|
v8::Local<v8::Promise> Get(const base::DictionaryValue& filter);
|
||||||
void Remove(const GURL& url,
|
v8::Local<v8::Promise> Set(const base::DictionaryValue& details);
|
||||||
const std::string& name,
|
v8::Local<v8::Promise> Remove(const GURL& url, const std::string& name);
|
||||||
const base::Closure& callback);
|
v8::Local<v8::Promise> FlushStore();
|
||||||
void Set(const base::DictionaryValue& details, const SetCallback& callback);
|
|
||||||
void FlushStore(const base::Closure& callback);
|
|
||||||
|
|
||||||
// CookieChangeNotifier subscription:
|
// CookieChangeNotifier subscription:
|
||||||
void OnCookieChanged(const CookieDetails*);
|
void OnCookieChanged(const CookieDetails*);
|
||||||
|
|||||||
@@ -61,23 +61,26 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
|
|||||||
params.Swap(params_value);
|
params.Swap(params_value);
|
||||||
Emit("message", method, params);
|
Emit("message", method, params);
|
||||||
} else {
|
} else {
|
||||||
auto send_command_callback = pending_requests_[id];
|
auto it = pending_requests_.find(id);
|
||||||
pending_requests_.erase(id);
|
if (it == pending_requests_.end())
|
||||||
if (send_command_callback.is_null())
|
|
||||||
return;
|
return;
|
||||||
base::DictionaryValue* error_body = nullptr;
|
|
||||||
base::DictionaryValue error;
|
|
||||||
bool has_error;
|
|
||||||
if ((has_error = dict->GetDictionary("error", &error_body))) {
|
|
||||||
error.Swap(error_body);
|
|
||||||
}
|
|
||||||
|
|
||||||
base::DictionaryValue* result_body = nullptr;
|
atom::util::Promise promise = std::move(it->second);
|
||||||
base::DictionaryValue result;
|
pending_requests_.erase(it);
|
||||||
if (dict->GetDictionary("result", &result_body))
|
|
||||||
result.Swap(result_body);
|
base::DictionaryValue* error = nullptr;
|
||||||
send_command_callback.Run(has_error ? error.Clone() : base::Value(),
|
if (dict->GetDictionary("error", &error)) {
|
||||||
result);
|
std::string message;
|
||||||
|
error->GetString("message", &message);
|
||||||
|
promise.RejectWithErrorMessage(message);
|
||||||
|
} else {
|
||||||
|
base::DictionaryValue* result_body = nullptr;
|
||||||
|
base::DictionaryValue result;
|
||||||
|
if (dict->GetDictionary("result", &result_body)) {
|
||||||
|
result.Swap(result_body);
|
||||||
|
}
|
||||||
|
promise.Resolve(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,23 +128,27 @@ void Debugger::Detach() {
|
|||||||
AgentHostClosed(agent_host_.get());
|
AgentHostClosed(agent_host_.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Debugger::SendCommand(mate::Arguments* args) {
|
v8::Local<v8::Promise> Debugger::SendCommand(mate::Arguments* args) {
|
||||||
if (!agent_host_)
|
atom::util::Promise promise(isolate());
|
||||||
return;
|
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||||
|
|
||||||
|
if (!agent_host_) {
|
||||||
|
promise.RejectWithErrorMessage("No target available");
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
std::string method;
|
std::string method;
|
||||||
if (!args->GetNext(&method)) {
|
if (!args->GetNext(&method)) {
|
||||||
args->ThrowError();
|
promise.RejectWithErrorMessage("Invalid method");
|
||||||
return;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
base::DictionaryValue command_params;
|
base::DictionaryValue command_params;
|
||||||
args->GetNext(&command_params);
|
args->GetNext(&command_params);
|
||||||
SendCommandCallback callback;
|
|
||||||
args->GetNext(&callback);
|
|
||||||
|
|
||||||
base::DictionaryValue request;
|
base::DictionaryValue request;
|
||||||
int request_id = ++previous_request_id_;
|
int request_id = ++previous_request_id_;
|
||||||
pending_requests_[request_id] = callback;
|
pending_requests_.emplace(request_id, std::move(promise));
|
||||||
request.SetInteger("id", request_id);
|
request.SetInteger("id", request_id);
|
||||||
request.SetString("method", method);
|
request.SetString("method", method);
|
||||||
if (!command_params.empty())
|
if (!command_params.empty())
|
||||||
@@ -151,16 +158,13 @@ void Debugger::SendCommand(mate::Arguments* args) {
|
|||||||
std::string json_args;
|
std::string json_args;
|
||||||
base::JSONWriter::Write(request, &json_args);
|
base::JSONWriter::Write(request, &json_args);
|
||||||
agent_host_->DispatchProtocolMessage(this, json_args);
|
agent_host_->DispatchProtocolMessage(this, json_args);
|
||||||
|
|
||||||
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Debugger::ClearPendingRequests() {
|
void Debugger::ClearPendingRequests() {
|
||||||
if (pending_requests_.empty())
|
for (auto& it : pending_requests_)
|
||||||
return;
|
it.second.RejectWithErrorMessage("target closed while handling command");
|
||||||
base::Value error(base::Value::Type::DICTIONARY);
|
|
||||||
base::Value error_msg("target closed while handling command");
|
|
||||||
error.SetKey("message", std::move(error_msg));
|
|
||||||
for (const auto& it : pending_requests_)
|
|
||||||
it.second.Run(error, base::Value());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
@@ -201,4 +205,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_debugger, Initialize);
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_debugger, Initialize);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "atom/browser/api/trackable_object.h"
|
#include "atom/browser/api/trackable_object.h"
|
||||||
|
#include "atom/common/promise_util.h"
|
||||||
#include "base/callback.h"
|
#include "base/callback.h"
|
||||||
#include "base/values.h"
|
#include "base/values.h"
|
||||||
#include "content/public/browser/devtools_agent_host_client.h"
|
#include "content/public/browser/devtools_agent_host_client.h"
|
||||||
@@ -32,9 +33,6 @@ class Debugger : public mate::TrackableObject<Debugger>,
|
|||||||
public content::DevToolsAgentHostClient,
|
public content::DevToolsAgentHostClient,
|
||||||
public content::WebContentsObserver {
|
public content::WebContentsObserver {
|
||||||
public:
|
public:
|
||||||
using SendCommandCallback =
|
|
||||||
base::Callback<void(const base::Value&, const base::Value&)>;
|
|
||||||
|
|
||||||
static mate::Handle<Debugger> Create(v8::Isolate* isolate,
|
static mate::Handle<Debugger> Create(v8::Isolate* isolate,
|
||||||
content::WebContents* web_contents);
|
content::WebContents* web_contents);
|
||||||
|
|
||||||
@@ -56,12 +54,12 @@ class Debugger : public mate::TrackableObject<Debugger>,
|
|||||||
content::RenderFrameHost* new_rfh) override;
|
content::RenderFrameHost* new_rfh) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using PendingRequestMap = std::map<int, SendCommandCallback>;
|
using PendingRequestMap = std::map<int, atom::util::Promise>;
|
||||||
|
|
||||||
void Attach(mate::Arguments* args);
|
void Attach(mate::Arguments* args);
|
||||||
bool IsAttached();
|
bool IsAttached();
|
||||||
void Detach();
|
void Detach();
|
||||||
void SendCommand(mate::Arguments* args);
|
v8::Local<v8::Promise> SendCommand(mate::Arguments* args);
|
||||||
void ClearPendingRequests();
|
void ClearPendingRequests();
|
||||||
|
|
||||||
content::WebContents* web_contents_; // Weak Reference.
|
content::WebContents* web_contents_; // Weak Reference.
|
||||||
|
|||||||
@@ -88,10 +88,6 @@ void DesktopCapturer::StartHandling(bool capture_window,
|
|||||||
capture_screen_ = capture_screen;
|
capture_screen_ = capture_screen;
|
||||||
|
|
||||||
{
|
{
|
||||||
// Remove this once
|
|
||||||
// https://bugs.chromium.org/p/chromium/issues/detail?id=795340 is fixed.
|
|
||||||
base::ScopedAllowBaseSyncPrimitivesForTesting
|
|
||||||
scoped_allow_base_sync_primitives;
|
|
||||||
// Initialize the source list.
|
// Initialize the source list.
|
||||||
// Apply the new thumbnail size and restart capture.
|
// Apply the new thumbnail size and restart capture.
|
||||||
if (capture_window) {
|
if (capture_window) {
|
||||||
@@ -230,4 +226,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_desktop_capturer, Initialize);
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_desktop_capturer, Initialize);
|
||||||
|
|||||||
@@ -96,4 +96,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_dialog, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_dialog, Initialize)
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ bool DownloadItem::IsPaused() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DownloadItem::Resume() {
|
void DownloadItem::Resume() {
|
||||||
download_item_->Resume();
|
download_item_->Resume(true /* user_gesture */);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DownloadItem::CanResume() const {
|
bool DownloadItem::CanResume() const {
|
||||||
@@ -251,4 +251,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_download_item, Initialize);
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_download_item, Initialize);
|
||||||
|
|||||||
@@ -23,4 +23,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_event, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_event, Initialize)
|
||||||
|
|||||||
@@ -166,4 +166,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_global_shortcut, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_global_shortcut, Initialize)
|
||||||
|
|||||||
@@ -140,4 +140,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_in_app_purchase, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_in_app_purchase, Initialize)
|
||||||
|
|||||||
@@ -245,4 +245,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_menu, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_menu, Initialize)
|
||||||
|
|||||||
@@ -61,4 +61,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_net, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_net, Initialize)
|
||||||
|
|||||||
@@ -272,4 +272,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_notification, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_common_notification, Initialize)
|
||||||
|
|||||||
@@ -84,19 +84,19 @@ void PowerMonitor::OnResume() {
|
|||||||
Emit("resume");
|
Emit("resume");
|
||||||
}
|
}
|
||||||
|
|
||||||
void PowerMonitor::QuerySystemIdleState(v8::Isolate* isolate,
|
ui::IdleState PowerMonitor::QuerySystemIdleState(v8::Isolate* isolate,
|
||||||
int idle_threshold,
|
int idle_threshold) {
|
||||||
const ui::IdleCallback& callback) {
|
|
||||||
if (idle_threshold > 0) {
|
if (idle_threshold > 0) {
|
||||||
ui::CalculateIdleState(idle_threshold, callback);
|
return ui::CalculateIdleState(idle_threshold);
|
||||||
} else {
|
} else {
|
||||||
isolate->ThrowException(v8::Exception::TypeError(mate::StringToV8(
|
isolate->ThrowException(v8::Exception::TypeError(mate::StringToV8(
|
||||||
isolate, "Invalid idle threshold, must be greater than 0")));
|
isolate, "Invalid idle threshold, must be greater than 0")));
|
||||||
|
return ui::IDLE_STATE_UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PowerMonitor::QuerySystemIdleTime(const ui::IdleTimeCallback& callback) {
|
int PowerMonitor::QuerySystemIdleTime() {
|
||||||
ui::CalculateIdleTime(callback);
|
return ui::CalculateIdleTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
@@ -122,8 +122,8 @@ void PowerMonitor::BuildPrototype(v8::Isolate* isolate,
|
|||||||
.SetMethod("blockShutdown", &PowerMonitor::BlockShutdown)
|
.SetMethod("blockShutdown", &PowerMonitor::BlockShutdown)
|
||||||
.SetMethod("unblockShutdown", &PowerMonitor::UnblockShutdown)
|
.SetMethod("unblockShutdown", &PowerMonitor::UnblockShutdown)
|
||||||
#endif
|
#endif
|
||||||
.SetMethod("querySystemIdleState", &PowerMonitor::QuerySystemIdleState)
|
.SetMethod("_querySystemIdleState", &PowerMonitor::QuerySystemIdleState)
|
||||||
.SetMethod("querySystemIdleTime", &PowerMonitor::QuerySystemIdleTime);
|
.SetMethod("_querySystemIdleTime", &PowerMonitor::QuerySystemIdleTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace api
|
} // namespace api
|
||||||
@@ -148,4 +148,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_power_monitor, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_power_monitor, Initialize)
|
||||||
|
|||||||
@@ -46,10 +46,8 @@ class PowerMonitor : public mate::TrackableObject<PowerMonitor>,
|
|||||||
void OnResume() override;
|
void OnResume() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void QuerySystemIdleState(v8::Isolate* isolate,
|
ui::IdleState QuerySystemIdleState(v8::Isolate* isolate, int idle_threshold);
|
||||||
int idle_threshold,
|
int QuerySystemIdleTime();
|
||||||
const ui::IdleCallback& callback);
|
|
||||||
void QuerySystemIdleTime(const ui::IdleTimeCallback& callback);
|
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
// Static callback invoked when a message comes in to our messaging window.
|
// Static callback invoked when a message comes in to our messaging window.
|
||||||
|
|||||||
@@ -151,4 +151,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_power_save_blocker, Initialize);
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_power_save_blocker, Initialize);
|
||||||
|
|||||||
@@ -24,47 +24,119 @@
|
|||||||
|
|
||||||
using content::BrowserThread;
|
using content::BrowserThread;
|
||||||
|
|
||||||
namespace atom {
|
|
||||||
|
|
||||||
namespace api {
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// List of registered custom standard schemes.
|
// List of registered custom standard schemes.
|
||||||
std::vector<std::string> g_standard_schemes;
|
std::vector<std::string> g_standard_schemes;
|
||||||
|
|
||||||
|
struct SchemeOptions {
|
||||||
|
bool standard = false;
|
||||||
|
bool secure = false;
|
||||||
|
bool bypassCSP = false;
|
||||||
|
bool allowServiceWorkers = false;
|
||||||
|
bool supportFetchAPI = false;
|
||||||
|
bool corsEnabled = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CustomScheme {
|
||||||
|
std::string scheme;
|
||||||
|
SchemeOptions options;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
namespace mate {
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct Converter<CustomScheme> {
|
||||||
|
static bool FromV8(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Value> val,
|
||||||
|
CustomScheme* out) {
|
||||||
|
mate::Dictionary dict;
|
||||||
|
if (!ConvertFromV8(isolate, val, &dict))
|
||||||
|
return false;
|
||||||
|
if (!dict.Get("scheme", &(out->scheme)))
|
||||||
|
return false;
|
||||||
|
mate::Dictionary opt;
|
||||||
|
// options are optional. Default values specified in SchemeOptions are used
|
||||||
|
if (dict.Get("privileges", &opt)) {
|
||||||
|
opt.Get("standard", &(out->options.standard));
|
||||||
|
opt.Get("supportFetchAPI", &(out->options.supportFetchAPI));
|
||||||
|
opt.Get("secure", &(out->options.secure));
|
||||||
|
opt.Get("bypassCSP", &(out->options.bypassCSP));
|
||||||
|
opt.Get("allowServiceWorkers", &(out->options.allowServiceWorkers));
|
||||||
|
opt.Get("supportFetchAPI", &(out->options.supportFetchAPI));
|
||||||
|
opt.Get("corsEnabled", &(out->options.corsEnabled));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mate
|
||||||
|
|
||||||
|
namespace atom {
|
||||||
|
|
||||||
|
namespace api {
|
||||||
|
|
||||||
std::vector<std::string> GetStandardSchemes() {
|
std::vector<std::string> GetStandardSchemes() {
|
||||||
return g_standard_schemes;
|
return g_standard_schemes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterStandardSchemes(const std::vector<std::string>& schemes,
|
void RegisterSchemesAsPrivileged(v8::Local<v8::Value> val,
|
||||||
mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
g_standard_schemes = schemes;
|
std::vector<CustomScheme> custom_schemes;
|
||||||
|
if (!mate::ConvertFromV8(args->isolate(), val, &custom_schemes)) {
|
||||||
|
args->ThrowError("Argument must be an array of custom schemes.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mate::Dictionary opts;
|
std::vector<std::string> secure_schemes, cspbypassing_schemes, fetch_schemes,
|
||||||
bool secure = false;
|
service_worker_schemes, cors_schemes;
|
||||||
args->GetNext(&opts) && opts.Get("secure", &secure);
|
for (const auto& custom_scheme : custom_schemes) {
|
||||||
|
// Register scheme to privileged list (https, wss, data, chrome-extension)
|
||||||
// Dynamically register the schemes.
|
if (custom_scheme.options.standard) {
|
||||||
auto* policy = content::ChildProcessSecurityPolicy::GetInstance();
|
auto* policy = content::ChildProcessSecurityPolicy::GetInstance();
|
||||||
for (const std::string& scheme : schemes) {
|
url::AddStandardScheme(custom_scheme.scheme.c_str(),
|
||||||
url::AddStandardScheme(scheme.c_str(), url::SCHEME_WITH_HOST);
|
url::SCHEME_WITH_HOST);
|
||||||
if (secure) {
|
g_standard_schemes.push_back(custom_scheme.scheme);
|
||||||
url::AddSecureScheme(scheme.c_str());
|
policy->RegisterWebSafeScheme(custom_scheme.scheme);
|
||||||
|
}
|
||||||
|
if (custom_scheme.options.secure) {
|
||||||
|
secure_schemes.push_back(custom_scheme.scheme);
|
||||||
|
url::AddSecureScheme(custom_scheme.scheme.c_str());
|
||||||
|
}
|
||||||
|
if (custom_scheme.options.bypassCSP) {
|
||||||
|
cspbypassing_schemes.push_back(custom_scheme.scheme);
|
||||||
|
url::AddCSPBypassingScheme(custom_scheme.scheme.c_str());
|
||||||
|
}
|
||||||
|
if (custom_scheme.options.corsEnabled) {
|
||||||
|
cors_schemes.push_back(custom_scheme.scheme);
|
||||||
|
url::AddCorsEnabledScheme(custom_scheme.scheme.c_str());
|
||||||
|
}
|
||||||
|
if (custom_scheme.options.supportFetchAPI) {
|
||||||
|
fetch_schemes.push_back(custom_scheme.scheme);
|
||||||
|
}
|
||||||
|
if (custom_scheme.options.allowServiceWorkers) {
|
||||||
|
service_worker_schemes.push_back(custom_scheme.scheme);
|
||||||
}
|
}
|
||||||
policy->RegisterWebSafeScheme(scheme);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the schemes to command line switches, so child processes can also
|
const auto AppendSchemesToCmdLine = [](const char* switch_name,
|
||||||
// register them.
|
std::vector<std::string> schemes) {
|
||||||
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
// Add the schemes to command line switches, so child processes can also
|
||||||
atom::switches::kStandardSchemes, base::JoinString(schemes, ","));
|
// register them.
|
||||||
if (secure) {
|
|
||||||
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
||||||
atom::switches::kSecureSchemes, base::JoinString(schemes, ","));
|
switch_name, base::JoinString(schemes, ","));
|
||||||
}
|
};
|
||||||
|
|
||||||
|
AppendSchemesToCmdLine(atom::switches::kSecureSchemes, secure_schemes);
|
||||||
|
AppendSchemesToCmdLine(atom::switches::kBypassCSPSchemes,
|
||||||
|
cspbypassing_schemes);
|
||||||
|
AppendSchemesToCmdLine(atom::switches::kCORSSchemes, cors_schemes);
|
||||||
|
AppendSchemesToCmdLine(atom::switches::kFetchSchemes, fetch_schemes);
|
||||||
|
AppendSchemesToCmdLine(atom::switches::kServiceWorkerSchemes,
|
||||||
|
service_worker_schemes);
|
||||||
|
AppendSchemesToCmdLine(atom::switches::kStandardSchemes, g_standard_schemes);
|
||||||
}
|
}
|
||||||
|
|
||||||
Protocol::Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
Protocol::Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
||||||
@@ -73,12 +145,6 @@ Protocol::Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Protocol::~Protocol() {}
|
Protocol::~Protocol() {}
|
||||||
|
|
||||||
void Protocol::RegisterServiceWorkerSchemes(
|
|
||||||
const std::vector<std::string>& schemes) {
|
|
||||||
atom::AtomBrowserClient::SetCustomServiceWorkerSchemes(schemes);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Protocol::UnregisterProtocol(const std::string& scheme,
|
void Protocol::UnregisterProtocol(const std::string& scheme,
|
||||||
mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
CompletionCallback callback;
|
CompletionCallback callback;
|
||||||
@@ -111,21 +177,22 @@ bool IsProtocolHandledInIO(
|
|||||||
return is_handled;
|
return is_handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PromiseCallback(scoped_refptr<util::Promise> promise, bool handled) {
|
void PromiseCallback(util::Promise promise, bool handled) {
|
||||||
promise->Resolve(handled);
|
promise.Resolve(handled);
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::Local<v8::Promise> Protocol::IsProtocolHandled(const std::string& scheme) {
|
v8::Local<v8::Promise> Protocol::IsProtocolHandled(const std::string& scheme) {
|
||||||
scoped_refptr<util::Promise> promise = new util::Promise(isolate());
|
util::Promise promise(isolate());
|
||||||
|
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||||
auto* getter = static_cast<URLRequestContextGetter*>(
|
auto* getter = static_cast<URLRequestContextGetter*>(
|
||||||
browser_context_->GetRequestContext());
|
browser_context_->GetRequestContext());
|
||||||
|
|
||||||
base::PostTaskWithTraitsAndReplyWithResult(
|
base::PostTaskWithTraitsAndReplyWithResult(
|
||||||
FROM_HERE, {content::BrowserThread::IO},
|
FROM_HERE, {content::BrowserThread::IO},
|
||||||
base::Bind(&IsProtocolHandledInIO, base::RetainedRef(getter), scheme),
|
base::BindOnce(&IsProtocolHandledInIO, base::RetainedRef(getter), scheme),
|
||||||
base::Bind(&PromiseCallback, promise));
|
base::BindOnce(&PromiseCallback, std::move(promise)));
|
||||||
|
|
||||||
return promise->GetHandle();
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Protocol::UninterceptProtocol(const std::string& scheme,
|
void Protocol::UninterceptProtocol(const std::string& scheme,
|
||||||
@@ -195,8 +262,6 @@ void Protocol::BuildPrototype(v8::Isolate* isolate,
|
|||||||
v8::Local<v8::FunctionTemplate> prototype) {
|
v8::Local<v8::FunctionTemplate> prototype) {
|
||||||
prototype->SetClassName(mate::StringToV8(isolate, "Protocol"));
|
prototype->SetClassName(mate::StringToV8(isolate, "Protocol"));
|
||||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||||
.SetMethod("registerServiceWorkerSchemes",
|
|
||||||
&Protocol::RegisterServiceWorkerSchemes)
|
|
||||||
.SetMethod("registerStringProtocol",
|
.SetMethod("registerStringProtocol",
|
||||||
&Protocol::RegisterProtocol<URLRequestStringJob>)
|
&Protocol::RegisterProtocol<URLRequestStringJob>)
|
||||||
.SetMethod("registerBufferProtocol",
|
.SetMethod("registerBufferProtocol",
|
||||||
@@ -228,16 +293,16 @@ void Protocol::BuildPrototype(v8::Isolate* isolate,
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void RegisterStandardSchemes(const std::vector<std::string>& schemes,
|
void RegisterSchemesAsPrivileged(v8::Local<v8::Value> val,
|
||||||
mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
if (atom::Browser::Get()->is_ready()) {
|
if (atom::Browser::Get()->is_ready()) {
|
||||||
args->ThrowError(
|
args->ThrowError(
|
||||||
"protocol.registerStandardSchemes should be called before "
|
"protocol.registerSchemesAsPrivileged should be called before "
|
||||||
"app is ready");
|
"app is ready");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
atom::api::RegisterStandardSchemes(schemes, args);
|
atom::api::RegisterSchemesAsPrivileged(val, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
@@ -246,10 +311,10 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
void* priv) {
|
void* priv) {
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
mate::Dictionary dict(isolate, exports);
|
mate::Dictionary dict(isolate, exports);
|
||||||
dict.SetMethod("registerStandardSchemes", &RegisterStandardSchemes);
|
dict.SetMethod("registerSchemesAsPrivileged", &RegisterSchemesAsPrivileged);
|
||||||
dict.SetMethod("getStandardSchemes", &atom::api::GetStandardSchemes);
|
dict.SetMethod("getStandardSchemes", &atom::api::GetStandardSchemes);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_protocol, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_protocol, Initialize)
|
||||||
|
|||||||
@@ -34,8 +34,9 @@ namespace atom {
|
|||||||
namespace api {
|
namespace api {
|
||||||
|
|
||||||
std::vector<std::string> GetStandardSchemes();
|
std::vector<std::string> GetStandardSchemes();
|
||||||
void RegisterStandardSchemes(const std::vector<std::string>& schemes,
|
|
||||||
mate::Arguments* args);
|
void RegisterSchemesAsPrivileged(v8::Local<v8::Value> val,
|
||||||
|
mate::Arguments* args);
|
||||||
|
|
||||||
class Protocol : public mate::TrackableObject<Protocol> {
|
class Protocol : public mate::TrackableObject<Protocol> {
|
||||||
public:
|
public:
|
||||||
@@ -94,9 +95,6 @@ class Protocol : public mate::TrackableObject<Protocol> {
|
|||||||
DISALLOW_COPY_AND_ASSIGN(CustomProtocolHandler);
|
DISALLOW_COPY_AND_ASSIGN(CustomProtocolHandler);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Register schemes that can handle service worker.
|
|
||||||
void RegisterServiceWorkerSchemes(const std::vector<std::string>& schemes);
|
|
||||||
|
|
||||||
// Register the protocol with certain request job.
|
// Register the protocol with certain request job.
|
||||||
template <typename RequestJob>
|
template <typename RequestJob>
|
||||||
void RegisterProtocol(const std::string& scheme,
|
void RegisterProtocol(const std::string& scheme,
|
||||||
|
|||||||
@@ -87,5 +87,5 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_render_process_preferences,
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_render_process_preferences,
|
||||||
Initialize)
|
Initialize)
|
||||||
|
|||||||
@@ -171,4 +171,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_screen, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_common_screen, Initialize)
|
||||||
|
|||||||
@@ -61,7 +61,6 @@
|
|||||||
|
|
||||||
#include "atom/common/node_includes.h"
|
#include "atom/common/node_includes.h"
|
||||||
|
|
||||||
using atom::api::Cookies;
|
|
||||||
using content::BrowserThread;
|
using content::BrowserThread;
|
||||||
using content::StoragePartition;
|
using content::StoragePartition;
|
||||||
|
|
||||||
@@ -785,6 +784,8 @@ void Session::BuildPrototype(v8::Isolate* isolate,
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
using atom::api::Cookies;
|
||||||
|
using atom::api::Protocol;
|
||||||
using atom::api::Session;
|
using atom::api::Session;
|
||||||
|
|
||||||
v8::Local<v8::Value> FromPartition(const std::string& partition,
|
v8::Local<v8::Value> FromPartition(const std::string& partition,
|
||||||
@@ -810,9 +811,12 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
dict.Set(
|
dict.Set(
|
||||||
"Cookies",
|
"Cookies",
|
||||||
Cookies::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
|
Cookies::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
|
||||||
|
dict.Set(
|
||||||
|
"Protocol",
|
||||||
|
Protocol::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
|
||||||
dict.SetMethod("fromPartition", &FromPartition);
|
dict.SetMethod("fromPartition", &FromPartition);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_session, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_session, Initialize)
|
||||||
|
|||||||
@@ -128,4 +128,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_system_preferences, Initialize);
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_system_preferences, Initialize);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include "atom/browser/mac/atom_application.h"
|
#include "atom/browser/mac/atom_application.h"
|
||||||
#include "atom/browser/mac/dict_util.h"
|
#include "atom/browser/mac/dict_util.h"
|
||||||
|
#include "atom/browser/ui/cocoa/NSColor+Hex.h"
|
||||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||||
#include "atom/common/native_mate_converters/value_converter.h"
|
#include "atom/common/native_mate_converters/value_converter.h"
|
||||||
#include "base/mac/sdk_forward_declarations.h"
|
#include "base/mac/sdk_forward_declarations.h"
|
||||||
@@ -106,21 +107,6 @@ std::string ConvertAuthorizationStatus(AVAuthorizationStatusMac status) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert color to RGBA value like "aabbccdd"
|
|
||||||
std::string ToRGBA(NSColor* color) {
|
|
||||||
return base::StringPrintf(
|
|
||||||
"%02X%02X%02X%02X", (int)(color.redComponent * 0xFF),
|
|
||||||
(int)(color.greenComponent * 0xFF), (int)(color.blueComponent * 0xFF),
|
|
||||||
(int)(color.alphaComponent * 0xFF));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert color to RGB hex value like "#ABCDEF"
|
|
||||||
std::string ToRGBHex(NSColor* color) {
|
|
||||||
return base::StringPrintf("#%02X%02X%02X", (int)(color.redComponent * 0xFF),
|
|
||||||
(int)(color.greenComponent * 0xFF),
|
|
||||||
(int)(color.blueComponent * 0xFF));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void SystemPreferences::PostNotification(const std::string& name,
|
void SystemPreferences::PostNotification(const std::string& name,
|
||||||
@@ -400,42 +386,36 @@ std::string SystemPreferences::GetAccentColor() {
|
|||||||
if (@available(macOS 10.14, *))
|
if (@available(macOS 10.14, *))
|
||||||
sysColor = [NSColor controlAccentColor];
|
sysColor = [NSColor controlAccentColor];
|
||||||
|
|
||||||
return ToRGBA(sysColor);
|
return base::SysNSStringToUTF8([sysColor RGBAValue]);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SystemPreferences::GetSystemColor(const std::string& color,
|
std::string SystemPreferences::GetSystemColor(const std::string& color,
|
||||||
mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
if (@available(macOS 10.10, *)) {
|
NSColor* sysColor = nil;
|
||||||
NSColor* sysColor;
|
if (color == "blue") {
|
||||||
if (color == "blue") {
|
sysColor = [NSColor systemBlueColor];
|
||||||
sysColor = [NSColor systemBlueColor];
|
} else if (color == "brown") {
|
||||||
} else if (color == "brown") {
|
sysColor = [NSColor systemBrownColor];
|
||||||
sysColor = [NSColor systemBrownColor];
|
} else if (color == "gray") {
|
||||||
} else if (color == "gray") {
|
sysColor = [NSColor systemGrayColor];
|
||||||
sysColor = [NSColor systemGrayColor];
|
} else if (color == "green") {
|
||||||
} else if (color == "green") {
|
sysColor = [NSColor systemGreenColor];
|
||||||
sysColor = [NSColor systemGreenColor];
|
} else if (color == "orange") {
|
||||||
} else if (color == "orange") {
|
sysColor = [NSColor systemOrangeColor];
|
||||||
sysColor = [NSColor systemOrangeColor];
|
} else if (color == "pink") {
|
||||||
} else if (color == "pink") {
|
sysColor = [NSColor systemPinkColor];
|
||||||
sysColor = [NSColor systemPinkColor];
|
} else if (color == "purple") {
|
||||||
} else if (color == "purple") {
|
sysColor = [NSColor systemPurpleColor];
|
||||||
sysColor = [NSColor systemPurpleColor];
|
} else if (color == "red") {
|
||||||
} else if (color == "red") {
|
sysColor = [NSColor systemRedColor];
|
||||||
sysColor = [NSColor systemRedColor];
|
} else if (color == "yellow") {
|
||||||
} else if (color == "yellow") {
|
sysColor = [NSColor systemYellowColor];
|
||||||
sysColor = [NSColor systemYellowColor];
|
|
||||||
} else {
|
|
||||||
args->ThrowError("Unknown system color: " + color);
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
return ToRGBHex(sysColor);
|
|
||||||
} else {
|
} else {
|
||||||
args->ThrowError(
|
args->ThrowError("Unknown system color: " + color);
|
||||||
"This api is not available on MacOS version 10.9 or lower.");
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return base::SysNSStringToUTF8([sysColor hexadecimalValue]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
@@ -469,23 +449,18 @@ std::string SystemPreferences::GetColor(const std::string& color,
|
|||||||
} else if (color == "keyboard-focus-indicator") {
|
} else if (color == "keyboard-focus-indicator") {
|
||||||
sysColor = [NSColor keyboardFocusIndicatorColor];
|
sysColor = [NSColor keyboardFocusIndicatorColor];
|
||||||
} else if (color == "label") {
|
} else if (color == "label") {
|
||||||
if (@available(macOS 10.10, *))
|
sysColor = [NSColor labelColor];
|
||||||
sysColor = [NSColor labelColor];
|
|
||||||
} else if (color == "link") {
|
} else if (color == "link") {
|
||||||
if (@available(macOS 10.10, *))
|
sysColor = [NSColor linkColor];
|
||||||
sysColor = [NSColor linkColor];
|
|
||||||
} else if (color == "placeholder-text") {
|
} else if (color == "placeholder-text") {
|
||||||
if (@available(macOS 10.10, *))
|
sysColor = [NSColor placeholderTextColor];
|
||||||
sysColor = [NSColor placeholderTextColor];
|
|
||||||
} else if (color == "quaternary-label") {
|
} else if (color == "quaternary-label") {
|
||||||
if (@available(macOS 10.10, *))
|
sysColor = [NSColor quaternaryLabelColor];
|
||||||
sysColor = [NSColor quaternaryLabelColor];
|
|
||||||
} else if (color == "scrubber-textured-background") {
|
} else if (color == "scrubber-textured-background") {
|
||||||
if (@available(macOS 10.12.2, *))
|
if (@available(macOS 10.12.2, *))
|
||||||
sysColor = [NSColor scrubberTexturedBackgroundColor];
|
sysColor = [NSColor scrubberTexturedBackgroundColor];
|
||||||
} else if (color == "secondary-label") {
|
} else if (color == "secondary-label") {
|
||||||
if (@available(macOS 10.10, *))
|
sysColor = [NSColor secondaryLabelColor];
|
||||||
sysColor = [NSColor secondaryLabelColor];
|
|
||||||
} else if (color == "selected-content-background") {
|
} else if (color == "selected-content-background") {
|
||||||
if (@available(macOS 10.14, *))
|
if (@available(macOS 10.14, *))
|
||||||
sysColor = [NSColor selectedContentBackgroundColor];
|
sysColor = [NSColor selectedContentBackgroundColor];
|
||||||
@@ -505,8 +480,7 @@ std::string SystemPreferences::GetColor(const std::string& color,
|
|||||||
} else if (color == "shadow") {
|
} else if (color == "shadow") {
|
||||||
sysColor = [NSColor shadowColor];
|
sysColor = [NSColor shadowColor];
|
||||||
} else if (color == "tertiary-label") {
|
} else if (color == "tertiary-label") {
|
||||||
if (@available(macOS 10.10, *))
|
sysColor = [NSColor tertiaryLabelColor];
|
||||||
sysColor = [NSColor tertiaryLabelColor];
|
|
||||||
} else if (color == "text-background") {
|
} else if (color == "text-background") {
|
||||||
sysColor = [NSColor textBackgroundColor];
|
sysColor = [NSColor textBackgroundColor];
|
||||||
} else if (color == "text") {
|
} else if (color == "text") {
|
||||||
@@ -531,7 +505,7 @@ std::string SystemPreferences::GetColor(const std::string& color,
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ToRGBHex(sysColor);
|
return base::SysNSStringToUTF8([sysColor hexadecimalValue]);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SystemPreferences::GetMediaAccessStatus(
|
std::string SystemPreferences::GetMediaAccessStatus(
|
||||||
@@ -554,25 +528,27 @@ std::string SystemPreferences::GetMediaAccessStatus(
|
|||||||
v8::Local<v8::Promise> SystemPreferences::AskForMediaAccess(
|
v8::Local<v8::Promise> SystemPreferences::AskForMediaAccess(
|
||||||
v8::Isolate* isolate,
|
v8::Isolate* isolate,
|
||||||
const std::string& media_type) {
|
const std::string& media_type) {
|
||||||
scoped_refptr<util::Promise> promise = new util::Promise(isolate);
|
util::Promise promise(isolate);
|
||||||
|
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||||
|
|
||||||
if (auto type = ParseMediaType(media_type)) {
|
if (auto type = ParseMediaType(media_type)) {
|
||||||
if (@available(macOS 10.14, *)) {
|
if (@available(macOS 10.14, *)) {
|
||||||
|
__block util::Promise p = std::move(promise);
|
||||||
[AVCaptureDevice requestAccessForMediaType:type
|
[AVCaptureDevice requestAccessForMediaType:type
|
||||||
completionHandler:^(BOOL granted) {
|
completionHandler:^(BOOL granted) {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
promise->Resolve(!!granted);
|
p.Resolve(!!granted);
|
||||||
});
|
});
|
||||||
}];
|
}];
|
||||||
} else {
|
} else {
|
||||||
// access always allowed pre-10.14 Mojave
|
// access always allowed pre-10.14 Mojave
|
||||||
promise->Resolve(true);
|
promise.Resolve(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
promise->RejectWithErrorMessage("Invalid media type");
|
promise.RejectWithErrorMessage("Invalid media type");
|
||||||
}
|
}
|
||||||
|
|
||||||
return promise->GetHandle();
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemPreferences::RemoveUserDefault(const std::string& name) {
|
void SystemPreferences::RemoveUserDefault(const std::string& name) {
|
||||||
|
|||||||
@@ -659,6 +659,11 @@ void TopLevelWindow::SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TopLevelWindow::RemoveMenu() {
|
||||||
|
menu_.Reset();
|
||||||
|
window_->SetMenu(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
void TopLevelWindow::SetParentWindow(v8::Local<v8::Value> value,
|
void TopLevelWindow::SetParentWindow(v8::Local<v8::Value> value,
|
||||||
mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
if (IsModal()) {
|
if (IsModal()) {
|
||||||
@@ -1103,6 +1108,7 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate,
|
|||||||
.SetMethod("setContentProtection", &TopLevelWindow::SetContentProtection)
|
.SetMethod("setContentProtection", &TopLevelWindow::SetContentProtection)
|
||||||
.SetMethod("setFocusable", &TopLevelWindow::SetFocusable)
|
.SetMethod("setFocusable", &TopLevelWindow::SetFocusable)
|
||||||
.SetMethod("setMenu", &TopLevelWindow::SetMenu)
|
.SetMethod("setMenu", &TopLevelWindow::SetMenu)
|
||||||
|
.SetMethod("removeMenu", &TopLevelWindow::RemoveMenu)
|
||||||
.SetMethod("setParentWindow", &TopLevelWindow::SetParentWindow)
|
.SetMethod("setParentWindow", &TopLevelWindow::SetParentWindow)
|
||||||
.SetMethod("setBrowserView", &TopLevelWindow::SetBrowserView)
|
.SetMethod("setBrowserView", &TopLevelWindow::SetBrowserView)
|
||||||
.SetMethod("addBrowserView", &TopLevelWindow::AddBrowserView)
|
.SetMethod("addBrowserView", &TopLevelWindow::AddBrowserView)
|
||||||
@@ -1193,4 +1199,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_top_level_window, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_top_level_window, Initialize)
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
|
|||||||
void SetContentProtection(bool enable);
|
void SetContentProtection(bool enable);
|
||||||
void SetFocusable(bool focusable);
|
void SetFocusable(bool focusable);
|
||||||
void SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> menu);
|
void SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> menu);
|
||||||
|
void RemoveMenu();
|
||||||
void SetParentWindow(v8::Local<v8::Value> value, mate::Arguments* args);
|
void SetParentWindow(v8::Local<v8::Value> value, mate::Arguments* args);
|
||||||
virtual void SetBrowserView(v8::Local<v8::Value> value);
|
virtual void SetBrowserView(v8::Local<v8::Value> value);
|
||||||
virtual void AddBrowserView(v8::Local<v8::Value> value);
|
virtual void AddBrowserView(v8::Local<v8::Value> value);
|
||||||
|
|||||||
@@ -261,4 +261,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_tray, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_tray, Initialize)
|
||||||
|
|||||||
@@ -86,4 +86,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_view, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_view, Initialize)
|
||||||
|
|||||||
@@ -87,7 +87,6 @@
|
|||||||
#include "ui/events/base_event_utils.h"
|
#include "ui/events/base_event_utils.h"
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_OSR)
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
#include "atom/browser/osr/osr_output_device.h"
|
|
||||||
#include "atom/browser/osr/osr_render_widget_host_view.h"
|
#include "atom/browser/osr/osr_render_widget_host_view.h"
|
||||||
#include "atom/browser/osr/osr_web_contents_view.h"
|
#include "atom/browser/osr/osr_web_contents_view.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -256,12 +255,11 @@ content::ServiceWorkerContext* GetServiceWorkerContext(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Called when CapturePage is done.
|
// Called when CapturePage is done.
|
||||||
void OnCapturePageDone(scoped_refptr<util::Promise> promise,
|
void OnCapturePageDone(util::Promise promise, const SkBitmap& bitmap) {
|
||||||
const SkBitmap& bitmap) {
|
|
||||||
// Hack to enable transparency in captured image
|
// Hack to enable transparency in captured image
|
||||||
// TODO(nitsakh) Remove hack once fixed in chromium
|
// TODO(nitsakh) Remove hack once fixed in chromium
|
||||||
const_cast<SkBitmap&>(bitmap).setAlphaType(kPremul_SkAlphaType);
|
const_cast<SkBitmap&>(bitmap).setAlphaType(kPremul_SkAlphaType);
|
||||||
promise->Resolve(gfx::Image::CreateFrom1xBitmap(bitmap));
|
promise.Resolve(gfx::Image::CreateFrom1xBitmap(bitmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@@ -599,7 +597,7 @@ void WebContents::SetContentsBounds(content::WebContents* source,
|
|||||||
|
|
||||||
void WebContents::CloseContents(content::WebContents* source) {
|
void WebContents::CloseContents(content::WebContents* source) {
|
||||||
Emit("close");
|
Emit("close");
|
||||||
#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
|
#if defined(TOOLKIT_VIEWS)
|
||||||
HideAutofillPopup();
|
HideAutofillPopup();
|
||||||
#endif
|
#endif
|
||||||
if (managed_web_contents())
|
if (managed_web_contents())
|
||||||
@@ -725,7 +723,7 @@ void WebContents::FindReply(content::WebContents* web_contents,
|
|||||||
bool WebContents::CheckMediaAccessPermission(
|
bool WebContents::CheckMediaAccessPermission(
|
||||||
content::RenderFrameHost* render_frame_host,
|
content::RenderFrameHost* render_frame_host,
|
||||||
const GURL& security_origin,
|
const GURL& security_origin,
|
||||||
content::MediaStreamType type) {
|
blink::MediaStreamType type) {
|
||||||
auto* web_contents =
|
auto* web_contents =
|
||||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||||
auto* permission_helper =
|
auto* permission_helper =
|
||||||
@@ -1012,8 +1010,7 @@ void WebContents::DevToolsOpened() {
|
|||||||
|
|
||||||
// Inherit owner window in devtools when it doesn't have one.
|
// Inherit owner window in devtools when it doesn't have one.
|
||||||
auto* devtools = managed_web_contents()->GetDevToolsWebContents();
|
auto* devtools = managed_web_contents()->GetDevToolsWebContents();
|
||||||
bool has_window =
|
bool has_window = devtools->GetUserData(NativeWindowRelay::UserDataKey());
|
||||||
devtools->GetUserData(NativeWindowRelay::kNativeWindowRelayUserDataKey);
|
|
||||||
if (owner_window() && !has_window)
|
if (owner_window() && !has_window)
|
||||||
handle->SetOwnerWindow(devtools, owner_window());
|
handle->SetOwnerWindow(devtools, owner_window());
|
||||||
|
|
||||||
@@ -1028,7 +1025,7 @@ void WebContents::DevToolsClosed() {
|
|||||||
Emit("devtools-closed");
|
Emit("devtools-closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
|
#if defined(TOOLKIT_VIEWS)
|
||||||
void WebContents::ShowAutofillPopup(content::RenderFrameHost* frame_host,
|
void WebContents::ShowAutofillPopup(content::RenderFrameHost* frame_host,
|
||||||
const gfx::RectF& bounds,
|
const gfx::RectF& bounds,
|
||||||
const std::vector<base::string16>& values,
|
const std::vector<base::string16>& values,
|
||||||
@@ -1075,7 +1072,7 @@ bool WebContents::OnMessageReceived(const IPC::Message& message,
|
|||||||
FrameDispatchHelper::OnSetTemporaryZoomLevel)
|
FrameDispatchHelper::OnSetTemporaryZoomLevel)
|
||||||
IPC_MESSAGE_FORWARD_DELAY_REPLY(AtomFrameHostMsg_GetZoomLevel, &helper,
|
IPC_MESSAGE_FORWARD_DELAY_REPLY(AtomFrameHostMsg_GetZoomLevel, &helper,
|
||||||
FrameDispatchHelper::OnGetZoomLevel)
|
FrameDispatchHelper::OnGetZoomLevel)
|
||||||
#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
|
#if defined(TOOLKIT_VIEWS)
|
||||||
IPC_MESSAGE_HANDLER(AtomAutofillFrameHostMsg_ShowPopup, ShowAutofillPopup)
|
IPC_MESSAGE_HANDLER(AtomAutofillFrameHostMsg_ShowPopup, ShowAutofillPopup)
|
||||||
IPC_MESSAGE_HANDLER(AtomAutofillFrameHostMsg_HidePopup, HideAutofillPopup)
|
IPC_MESSAGE_HANDLER(AtomAutofillFrameHostMsg_HidePopup, HideAutofillPopup)
|
||||||
#endif
|
#endif
|
||||||
@@ -1139,7 +1136,7 @@ void WebContents::SetBackgroundThrottling(bool allowed) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto* render_process_host = render_view_host->GetProcess();
|
auto* render_process_host = render_view_host->GetProcess();
|
||||||
if (!render_process_host) {
|
if (!render_process_host) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1216,6 +1213,9 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
|
|||||||
params.transition_type = ui::PAGE_TRANSITION_TYPED;
|
params.transition_type = ui::PAGE_TRANSITION_TYPED;
|
||||||
params.should_clear_history_list = true;
|
params.should_clear_history_list = true;
|
||||||
params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
|
params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
|
||||||
|
// Discord non-committed entries to ensure that we don't re-use a pending
|
||||||
|
// entry
|
||||||
|
web_contents()->GetController().DiscardNonCommittedEntries();
|
||||||
web_contents()->GetController().LoadURLWithParams(params);
|
web_contents()->GetController().LoadURLWithParams(params);
|
||||||
|
|
||||||
// Set the background color of RenderWidgetHostView.
|
// Set the background color of RenderWidgetHostView.
|
||||||
@@ -1485,7 +1485,7 @@ bool WebContents::IsCurrentlyAudible() {
|
|||||||
|
|
||||||
#if BUILDFLAG(ENABLE_PRINTING)
|
#if BUILDFLAG(ENABLE_PRINTING)
|
||||||
void WebContents::Print(mate::Arguments* args) {
|
void WebContents::Print(mate::Arguments* args) {
|
||||||
bool silent, print_background = false;
|
bool silent = false, print_background = false;
|
||||||
base::string16 device_name;
|
base::string16 device_name;
|
||||||
mate::Dictionary options = mate::Dictionary::CreateEmpty(args->isolate());
|
mate::Dictionary options = mate::Dictionary::CreateEmpty(args->isolate());
|
||||||
base::DictionaryValue settings;
|
base::DictionaryValue settings;
|
||||||
@@ -1672,13 +1672,24 @@ bool WebContents::SendIPCMessageWithSender(bool internal,
|
|||||||
const std::string& channel,
|
const std::string& channel,
|
||||||
const base::ListValue& args,
|
const base::ListValue& args,
|
||||||
int32_t sender_id) {
|
int32_t sender_id) {
|
||||||
auto* frame_host = web_contents()->GetMainFrame();
|
std::vector<content::RenderFrameHost*> target_hosts;
|
||||||
if (frame_host) {
|
if (!send_to_all) {
|
||||||
return frame_host->Send(new AtomFrameMsg_Message(frame_host->GetRoutingID(),
|
auto* frame_host = web_contents()->GetMainFrame();
|
||||||
internal, send_to_all,
|
if (frame_host) {
|
||||||
channel, args, sender_id));
|
target_hosts.push_back(frame_host);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
target_hosts = web_contents()->GetAllFrames();
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
bool handled = false;
|
||||||
|
for (auto* frame_host : target_hosts) {
|
||||||
|
handled = frame_host->Send(
|
||||||
|
new AtomFrameMsg_Message(frame_host->GetRoutingID(), internal,
|
||||||
|
false, channel, args, sender_id)) ||
|
||||||
|
handled;
|
||||||
|
}
|
||||||
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebContents::SendIPCMessageToFrame(bool internal,
|
bool WebContents::SendIPCMessageToFrame(bool internal,
|
||||||
@@ -1737,6 +1748,19 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
|
|||||||
mouse_wheel_event);
|
mouse_wheel_event);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
// Chromium expects phase info in wheel events (and applies a
|
||||||
|
// DCHECK to verify it). See: https://crbug.com/756524.
|
||||||
|
mouse_wheel_event.phase = blink::WebMouseWheelEvent::kPhaseBegan;
|
||||||
|
mouse_wheel_event.dispatch_type = blink::WebInputEvent::kBlocking;
|
||||||
|
rwh->ForwardWheelEvent(mouse_wheel_event);
|
||||||
|
|
||||||
|
// Send a synthetic wheel event with phaseEnded to finish scrolling.
|
||||||
|
mouse_wheel_event.has_synthetic_phase = true;
|
||||||
|
mouse_wheel_event.delta_x = 0;
|
||||||
|
mouse_wheel_event.delta_y = 0;
|
||||||
|
mouse_wheel_event.phase = blink::WebMouseWheelEvent::kPhaseEnded;
|
||||||
|
mouse_wheel_event.dispatch_type =
|
||||||
|
blink::WebInputEvent::kEventNonBlocking;
|
||||||
rwh->ForwardWheelEvent(mouse_wheel_event);
|
rwh->ForwardWheelEvent(mouse_wheel_event);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -1803,15 +1827,16 @@ void WebContents::StartDrag(const mate::Dictionary& item,
|
|||||||
|
|
||||||
v8::Local<v8::Promise> WebContents::CapturePage(mate::Arguments* args) {
|
v8::Local<v8::Promise> WebContents::CapturePage(mate::Arguments* args) {
|
||||||
gfx::Rect rect;
|
gfx::Rect rect;
|
||||||
scoped_refptr<util::Promise> promise = new util::Promise(isolate());
|
util::Promise promise(isolate());
|
||||||
|
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||||
|
|
||||||
// get rect arguments if they exist
|
// get rect arguments if they exist
|
||||||
args->GetNext(&rect);
|
args->GetNext(&rect);
|
||||||
|
|
||||||
auto* const view = web_contents()->GetRenderWidgetHostView();
|
auto* const view = web_contents()->GetRenderWidgetHostView();
|
||||||
if (!view) {
|
if (!view) {
|
||||||
promise->Resolve(gfx::Image());
|
promise.Resolve(gfx::Image());
|
||||||
return promise->GetHandle();
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Capture full page if user doesn't specify a |rect|.
|
// Capture full page if user doesn't specify a |rect|.
|
||||||
@@ -1830,8 +1855,8 @@ v8::Local<v8::Promise> WebContents::CapturePage(mate::Arguments* args) {
|
|||||||
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
|
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
|
||||||
|
|
||||||
view->CopyFromSurface(gfx::Rect(rect.origin(), view_size), bitmap_size,
|
view->CopyFromSurface(gfx::Rect(rect.origin(), view_size), bitmap_size,
|
||||||
base::BindOnce(&OnCapturePageDone, promise));
|
base::BindOnce(&OnCapturePageDone, std::move(promise)));
|
||||||
return promise->GetHandle();
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::OnCursorChange(const content::WebCursor& cursor) {
|
void WebContents::OnCursorChange(const content::WebCursor& cursor) {
|
||||||
@@ -2297,4 +2322,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_web_contents, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_web_contents, Initialize)
|
||||||
|
|||||||
@@ -391,7 +391,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||||||
bool final_update) override;
|
bool final_update) override;
|
||||||
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
|
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
|
||||||
const GURL& security_origin,
|
const GURL& security_origin,
|
||||||
content::MediaStreamType type) override;
|
blink::MediaStreamType type) override;
|
||||||
void RequestMediaAccessPermission(
|
void RequestMediaAccessPermission(
|
||||||
content::WebContents* web_contents,
|
content::WebContents* web_contents,
|
||||||
const content::MediaStreamRequest& request,
|
const content::MediaStreamRequest& request,
|
||||||
|
|||||||
@@ -31,9 +31,13 @@ class WebContentsViewRelay
|
|||||||
|
|
||||||
atom::api::WebContentsView* view_ = nullptr;
|
atom::api::WebContentsView* view_ = nullptr;
|
||||||
|
|
||||||
|
WEB_CONTENTS_USER_DATA_KEY_DECL();
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(WebContentsViewRelay);
|
DISALLOW_COPY_AND_ASSIGN(WebContentsViewRelay);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
WEB_CONTENTS_USER_DATA_KEY_IMPL(WebContentsViewRelay)
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
@@ -127,4 +131,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_web_contents_view, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_web_contents_view, Initialize)
|
||||||
|
|||||||
@@ -55,4 +55,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_web_view_manager, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_web_view_manager, Initialize)
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "atom/browser/api/gpuinfo_manager.h"
|
#include "atom/browser/api/gpuinfo_manager.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "atom/browser/api/gpu_info_enumerator.h"
|
#include "atom/browser/api/gpu_info_enumerator.h"
|
||||||
#include "base/memory/singleton.h"
|
#include "base/memory/singleton.h"
|
||||||
#include "base/threading/thread_task_runner_handle.h"
|
#include "base/threading/thread_task_runner_handle.h"
|
||||||
@@ -42,8 +45,8 @@ void GPUInfoManager::ProcessCompleteInfo() {
|
|||||||
const auto result = EnumerateGPUInfo(gpu_data_manager_->GetGPUInfo());
|
const auto result = EnumerateGPUInfo(gpu_data_manager_->GetGPUInfo());
|
||||||
// We have received the complete information, resolve all promises that
|
// We have received the complete information, resolve all promises that
|
||||||
// were waiting for this info.
|
// were waiting for this info.
|
||||||
for (const auto& promise : complete_info_promise_set_) {
|
for (auto& promise : complete_info_promise_set_) {
|
||||||
promise->Resolve(*result);
|
promise.Resolve(*result);
|
||||||
}
|
}
|
||||||
complete_info_promise_set_.clear();
|
complete_info_promise_set_.clear();
|
||||||
}
|
}
|
||||||
@@ -58,8 +61,8 @@ void GPUInfoManager::OnGpuInfoUpdate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Should be posted to the task runner
|
// Should be posted to the task runner
|
||||||
void GPUInfoManager::CompleteInfoFetcher(scoped_refptr<util::Promise> promise) {
|
void GPUInfoManager::CompleteInfoFetcher(util::Promise promise) {
|
||||||
complete_info_promise_set_.push_back(promise);
|
complete_info_promise_set_.emplace_back(std::move(promise));
|
||||||
|
|
||||||
if (NeedsCompleteGpuInfoCollection()) {
|
if (NeedsCompleteGpuInfoCollection()) {
|
||||||
gpu_data_manager_->RequestCompleteGpuInfoIfNeeded();
|
gpu_data_manager_->RequestCompleteGpuInfoIfNeeded();
|
||||||
@@ -68,18 +71,18 @@ void GPUInfoManager::CompleteInfoFetcher(scoped_refptr<util::Promise> promise) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPUInfoManager::FetchCompleteInfo(scoped_refptr<util::Promise> promise) {
|
void GPUInfoManager::FetchCompleteInfo(util::Promise promise) {
|
||||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||||
FROM_HERE, base::BindOnce(&GPUInfoManager::CompleteInfoFetcher,
|
FROM_HERE, base::BindOnce(&GPUInfoManager::CompleteInfoFetcher,
|
||||||
base::Unretained(this), promise));
|
base::Unretained(this), std::move(promise)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// This fetches the info synchronously, so no need to post to the task queue.
|
// This fetches the info synchronously, so no need to post to the task queue.
|
||||||
// There cannot be multiple promises as they are resolved synchronously.
|
// There cannot be multiple promises as they are resolved synchronously.
|
||||||
void GPUInfoManager::FetchBasicInfo(scoped_refptr<util::Promise> promise) {
|
void GPUInfoManager::FetchBasicInfo(util::Promise promise) {
|
||||||
gpu::GPUInfo gpu_info;
|
gpu::GPUInfo gpu_info;
|
||||||
CollectBasicGraphicsInfo(&gpu_info);
|
CollectBasicGraphicsInfo(&gpu_info);
|
||||||
promise->Resolve(*EnumerateGPUInfo(gpu_info));
|
promise.Resolve(*EnumerateGPUInfo(gpu_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<base::DictionaryValue> GPUInfoManager::EnumerateGPUInfo(
|
std::unique_ptr<base::DictionaryValue> GPUInfoManager::EnumerateGPUInfo(
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ class GPUInfoManager : public content::GpuDataManagerObserver {
|
|||||||
GPUInfoManager();
|
GPUInfoManager();
|
||||||
~GPUInfoManager() override;
|
~GPUInfoManager() override;
|
||||||
bool NeedsCompleteGpuInfoCollection() const;
|
bool NeedsCompleteGpuInfoCollection() const;
|
||||||
void FetchCompleteInfo(scoped_refptr<util::Promise> promise);
|
void FetchCompleteInfo(util::Promise promise);
|
||||||
void FetchBasicInfo(scoped_refptr<util::Promise> promise);
|
void FetchBasicInfo(util::Promise promise);
|
||||||
void OnGpuInfoUpdate() override;
|
void OnGpuInfoUpdate() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -34,12 +34,12 @@ class GPUInfoManager : public content::GpuDataManagerObserver {
|
|||||||
gpu::GPUInfo gpu_info) const;
|
gpu::GPUInfo gpu_info) const;
|
||||||
|
|
||||||
// These should be posted to the task queue
|
// These should be posted to the task queue
|
||||||
void CompleteInfoFetcher(scoped_refptr<util::Promise> promise);
|
void CompleteInfoFetcher(util::Promise promise);
|
||||||
void ProcessCompleteInfo();
|
void ProcessCompleteInfo();
|
||||||
|
|
||||||
// This set maintains all the promises that should be fulfilled
|
// This set maintains all the promises that should be fulfilled
|
||||||
// once we have the complete information data
|
// once we have the complete information data
|
||||||
std::vector<scoped_refptr<util::Promise>> complete_info_promise_set_;
|
std::vector<util::Promise> complete_info_promise_set_;
|
||||||
content::GpuDataManager* gpu_data_manager_;
|
content::GpuDataManager* gpu_data_manager_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(GPUInfoManager);
|
DISALLOW_COPY_AND_ASSIGN(GPUInfoManager);
|
||||||
|
|||||||
@@ -57,7 +57,9 @@ void SavePageHandler::OnDownloadUpdated(download::DownloadItem* item) {
|
|||||||
callback_.Run(v8::Null(isolate));
|
callback_.Run(v8::Null(isolate));
|
||||||
} else {
|
} else {
|
||||||
v8::Local<v8::String> error_message =
|
v8::Local<v8::String> error_message =
|
||||||
v8::String::NewFromUtf8(isolate, "Fail to save page");
|
v8::String::NewFromUtf8(isolate, "Fail to save page",
|
||||||
|
v8::NewStringType::kNormal)
|
||||||
|
.ToLocalChecked();
|
||||||
callback_.Run(v8::Exception::Error(error_message));
|
callback_.Run(v8::Exception::Error(error_message));
|
||||||
}
|
}
|
||||||
Destroy(item);
|
Destroy(item);
|
||||||
|
|||||||
@@ -19,12 +19,15 @@ namespace mate {
|
|||||||
StreamSubscriber::StreamSubscriber(
|
StreamSubscriber::StreamSubscriber(
|
||||||
v8::Isolate* isolate,
|
v8::Isolate* isolate,
|
||||||
v8::Local<v8::Object> emitter,
|
v8::Local<v8::Object> emitter,
|
||||||
base::WeakPtr<atom::URLRequestStreamJob> url_job)
|
base::WeakPtr<atom::URLRequestStreamJob> url_job,
|
||||||
: isolate_(isolate),
|
scoped_refptr<base::SequencedTaskRunner> ui_task_runner)
|
||||||
|
: base::RefCountedDeleteOnSequence<StreamSubscriber>(ui_task_runner),
|
||||||
|
isolate_(isolate),
|
||||||
emitter_(isolate, emitter),
|
emitter_(isolate, emitter),
|
||||||
url_job_(url_job),
|
url_job_(url_job),
|
||||||
weak_factory_(this) {
|
weak_factory_(this) {
|
||||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
DCHECK(ui_task_runner->RunsTasksInCurrentSequence());
|
||||||
|
|
||||||
auto weak_self = weak_factory_.GetWeakPtr();
|
auto weak_self = weak_factory_.GetWeakPtr();
|
||||||
On("data", base::Bind(&StreamSubscriber::OnData, weak_self));
|
On("data", base::Bind(&StreamSubscriber::OnData, weak_self));
|
||||||
On("end", base::Bind(&StreamSubscriber::OnEnd, weak_self));
|
On("end", base::Bind(&StreamSubscriber::OnEnd, weak_self));
|
||||||
@@ -32,13 +35,12 @@ StreamSubscriber::StreamSubscriber(
|
|||||||
}
|
}
|
||||||
|
|
||||||
StreamSubscriber::~StreamSubscriber() {
|
StreamSubscriber::~StreamSubscriber() {
|
||||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
|
||||||
RemoveAllListeners();
|
RemoveAllListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StreamSubscriber::On(const std::string& event,
|
void StreamSubscriber::On(const std::string& event,
|
||||||
EventCallback&& callback) { // NOLINT
|
EventCallback&& callback) { // NOLINT
|
||||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
DCHECK(owning_task_runner()->RunsTasksInCurrentSequence());
|
||||||
DCHECK(js_handlers_.find(event) == js_handlers_.end());
|
DCHECK(js_handlers_.find(event) == js_handlers_.end());
|
||||||
|
|
||||||
v8::Locker locker(isolate_);
|
v8::Locker locker(isolate_);
|
||||||
@@ -52,7 +54,7 @@ void StreamSubscriber::On(const std::string& event,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StreamSubscriber::Off(const std::string& event) {
|
void StreamSubscriber::Off(const std::string& event) {
|
||||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
DCHECK(owning_task_runner()->RunsTasksInCurrentSequence());
|
||||||
DCHECK(js_handlers_.find(event) != js_handlers_.end());
|
DCHECK(js_handlers_.find(event) != js_handlers_.end());
|
||||||
|
|
||||||
v8::Locker locker(isolate_);
|
v8::Locker locker(isolate_);
|
||||||
@@ -96,6 +98,7 @@ void StreamSubscriber::OnError(mate::Arguments* args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StreamSubscriber::RemoveAllListeners() {
|
void StreamSubscriber::RemoveAllListeners() {
|
||||||
|
DCHECK(owning_task_runner()->RunsTasksInCurrentSequence());
|
||||||
v8::Locker locker(isolate_);
|
v8::Locker locker(isolate_);
|
||||||
v8::Isolate::Scope isolate_scope(isolate_);
|
v8::Isolate::Scope isolate_scope(isolate_);
|
||||||
v8::HandleScope handle_scope(isolate_);
|
v8::HandleScope handle_scope(isolate_);
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/callback.h"
|
#include "base/callback.h"
|
||||||
|
#include "base/memory/ref_counted.h"
|
||||||
|
#include "base/memory/ref_counted_delete_on_sequence.h"
|
||||||
#include "base/memory/weak_ptr.h"
|
#include "base/memory/weak_ptr.h"
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "v8/include/v8.h"
|
#include "v8/include/v8.h"
|
||||||
@@ -23,17 +25,25 @@ namespace mate {
|
|||||||
|
|
||||||
class Arguments;
|
class Arguments;
|
||||||
|
|
||||||
class StreamSubscriber {
|
class StreamSubscriber
|
||||||
|
: public base::RefCountedDeleteOnSequence<StreamSubscriber> {
|
||||||
public:
|
public:
|
||||||
|
REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE();
|
||||||
|
|
||||||
StreamSubscriber(v8::Isolate* isolate,
|
StreamSubscriber(v8::Isolate* isolate,
|
||||||
v8::Local<v8::Object> emitter,
|
v8::Local<v8::Object> emitter,
|
||||||
base::WeakPtr<atom::URLRequestStreamJob> url_job);
|
base::WeakPtr<atom::URLRequestStreamJob> url_job,
|
||||||
~StreamSubscriber();
|
scoped_refptr<base::SequencedTaskRunner> ui_task_runner);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend class base::DeleteHelper<StreamSubscriber>;
|
||||||
|
friend class base::RefCountedDeleteOnSequence<StreamSubscriber>;
|
||||||
|
|
||||||
using JSHandlersMap = std::map<std::string, v8::Global<v8::Value>>;
|
using JSHandlersMap = std::map<std::string, v8::Global<v8::Value>>;
|
||||||
using EventCallback = base::Callback<void(mate::Arguments* args)>;
|
using EventCallback = base::Callback<void(mate::Arguments* args)>;
|
||||||
|
|
||||||
|
~StreamSubscriber();
|
||||||
|
|
||||||
void On(const std::string& event, EventCallback&& callback); // NOLINT
|
void On(const std::string& event, EventCallback&& callback); // NOLINT
|
||||||
void Off(const std::string& event);
|
void Off(const std::string& event);
|
||||||
|
|
||||||
|
|||||||
@@ -84,4 +84,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_box_layout, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_box_layout, Initialize)
|
||||||
|
|||||||
@@ -57,4 +57,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_button, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_button, Initialize)
|
||||||
|
|||||||
@@ -77,4 +77,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_label_button, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_label_button, Initialize)
|
||||||
|
|||||||
@@ -60,4 +60,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_layout_manager, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_layout_manager, Initialize)
|
||||||
|
|||||||
@@ -54,4 +54,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_md_text_button, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_md_text_button, Initialize)
|
||||||
|
|||||||
@@ -57,4 +57,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_resize_area, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_resize_area, Initialize)
|
||||||
|
|||||||
@@ -64,4 +64,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_text_field, Initialize)
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_text_field, Initialize)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "atom/app/manifests.h"
|
||||||
#include "atom/browser/api/atom_api_app.h"
|
#include "atom/browser/api/atom_api_app.h"
|
||||||
#include "atom/browser/api/atom_api_protocol.h"
|
#include "atom/browser/api/atom_api_protocol.h"
|
||||||
#include "atom/browser/api/atom_api_web_contents.h"
|
#include "atom/browser/api/atom_api_web_contents.h"
|
||||||
@@ -32,6 +33,7 @@
|
|||||||
#include "atom/browser/web_contents_permission_helper.h"
|
#include "atom/browser/web_contents_permission_helper.h"
|
||||||
#include "atom/browser/web_contents_preferences.h"
|
#include "atom/browser/web_contents_preferences.h"
|
||||||
#include "atom/browser/window_list.h"
|
#include "atom/browser/window_list.h"
|
||||||
|
#include "atom/common/application_info.h"
|
||||||
#include "atom/common/options_switches.h"
|
#include "atom/common/options_switches.h"
|
||||||
#include "atom/common/platform_util.h"
|
#include "atom/common/platform_util.h"
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
@@ -47,6 +49,7 @@
|
|||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "base/task/post_task.h"
|
#include "base/task/post_task.h"
|
||||||
#include "chrome/browser/browser_process.h"
|
#include "chrome/browser/browser_process.h"
|
||||||
|
#include "chrome/common/chrome_version.h"
|
||||||
#include "components/net_log/chrome_net_log.h"
|
#include "components/net_log/chrome_net_log.h"
|
||||||
#include "content/public/browser/browser_ppapi_host.h"
|
#include "content/public/browser/browser_ppapi_host.h"
|
||||||
#include "content/public/browser/browser_task_traits.h"
|
#include "content/public/browser/browser_task_traits.h"
|
||||||
@@ -82,6 +85,8 @@
|
|||||||
#include "net/ssl/client_cert_store_win.h"
|
#include "net/ssl/client_cert_store_win.h"
|
||||||
#elif defined(OS_MACOSX)
|
#elif defined(OS_MACOSX)
|
||||||
#include "net/ssl/client_cert_store_mac.h"
|
#include "net/ssl/client_cert_store_mac.h"
|
||||||
|
#include "services/audio/public/mojom/constants.mojom.h"
|
||||||
|
#include "services/video_capture/public/mojom/constants.mojom.h"
|
||||||
#elif defined(USE_OPENSSL)
|
#elif defined(USE_OPENSSL)
|
||||||
#include "net/ssl/client_cert_store.h"
|
#include "net/ssl/client_cert_store.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -114,19 +119,15 @@ namespace {
|
|||||||
// Next navigation should not restart renderer process.
|
// Next navigation should not restart renderer process.
|
||||||
bool g_suppress_renderer_process_restart = false;
|
bool g_suppress_renderer_process_restart = false;
|
||||||
|
|
||||||
// Custom schemes to be registered to handle service worker.
|
|
||||||
base::NoDestructor<std::string> g_custom_service_worker_schemes;
|
|
||||||
|
|
||||||
bool IsSameWebSite(content::BrowserContext* browser_context,
|
bool IsSameWebSite(content::BrowserContext* browser_context,
|
||||||
const GURL& src_url,
|
content::SiteInstance* site_instance,
|
||||||
const GURL& dest_url) {
|
const GURL& dest_url) {
|
||||||
return content::SiteInstance::IsSameWebSite(browser_context, src_url,
|
return site_instance->IsSameSiteWithURL(dest_url) ||
|
||||||
dest_url) ||
|
// `IsSameSiteWithURL` doesn't seem to work for some URIs such as
|
||||||
// `IsSameWebSite` doesn't seem to work for some URIs such as `file:`,
|
// `file:`, handle these scenarios by comparing only the site as
|
||||||
// handle these scenarios by comparing only the site as defined by
|
// defined by `GetSiteForURL`.
|
||||||
// `GetSiteForURL`.
|
(content::SiteInstance::GetSiteForURL(browser_context, dest_url) ==
|
||||||
content::SiteInstance::GetSiteForURL(browser_context, dest_url) ==
|
site_instance->GetSiteURL());
|
||||||
src_url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AtomBrowserClient* g_browser_client = nullptr;
|
AtomBrowserClient* g_browser_client = nullptr;
|
||||||
@@ -148,11 +149,6 @@ void AtomBrowserClient::SuppressRendererProcessRestartForOnce() {
|
|||||||
g_suppress_renderer_process_restart = true;
|
g_suppress_renderer_process_restart = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomBrowserClient::SetCustomServiceWorkerSchemes(
|
|
||||||
const std::vector<std::string>& schemes) {
|
|
||||||
*g_custom_service_worker_schemes = base::JoinString(schemes, ",");
|
|
||||||
}
|
|
||||||
|
|
||||||
AtomBrowserClient* AtomBrowserClient::Get() {
|
AtomBrowserClient* AtomBrowserClient::Get() {
|
||||||
return g_browser_client;
|
return g_browser_client;
|
||||||
}
|
}
|
||||||
@@ -230,8 +226,7 @@ bool AtomBrowserClient::ShouldForceNewSiteInstance(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create new a SiteInstance if navigating to a different site.
|
// Create new a SiteInstance if navigating to a different site.
|
||||||
auto src_url = current_instance->GetSiteURL();
|
return !IsSameWebSite(browser_context, current_instance, url);
|
||||||
return !IsSameWebSite(browser_context, src_url, url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AtomBrowserClient::NavigationWasRedirectedCrossSite(
|
bool AtomBrowserClient::NavigationWasRedirectedCrossSite(
|
||||||
@@ -242,13 +237,12 @@ bool AtomBrowserClient::NavigationWasRedirectedCrossSite(
|
|||||||
bool has_response_started) const {
|
bool has_response_started) const {
|
||||||
bool navigation_was_redirected = false;
|
bool navigation_was_redirected = false;
|
||||||
if (has_response_started) {
|
if (has_response_started) {
|
||||||
navigation_was_redirected = !IsSameWebSite(
|
navigation_was_redirected =
|
||||||
browser_context, current_instance->GetSiteURL(), dest_url);
|
!IsSameWebSite(browser_context, current_instance, dest_url);
|
||||||
} else {
|
} else {
|
||||||
navigation_was_redirected =
|
navigation_was_redirected =
|
||||||
speculative_instance &&
|
speculative_instance &&
|
||||||
!IsSameWebSite(browser_context, speculative_instance->GetSiteURL(),
|
!IsSameWebSite(browser_context, speculative_instance, dest_url);
|
||||||
dest_url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return navigation_was_redirected;
|
return navigation_was_redirected;
|
||||||
@@ -312,7 +306,7 @@ content::SiteInstance* AtomBrowserClient::GetSiteInstanceFromAffinity(
|
|||||||
auto iter = site_per_affinities_.find(affinity);
|
auto iter = site_per_affinities_.find(affinity);
|
||||||
GURL dest_site = content::SiteInstance::GetSiteForURL(browser_context, url);
|
GURL dest_site = content::SiteInstance::GetSiteForURL(browser_context, url);
|
||||||
if (iter != site_per_affinities_.end() &&
|
if (iter != site_per_affinities_.end() &&
|
||||||
IsSameWebSite(browser_context, iter->second->GetSiteURL(), dest_site)) {
|
IsSameWebSite(browser_context, iter->second, dest_site)) {
|
||||||
return iter->second;
|
return iter->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -477,17 +471,14 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Copy following switches to child process.
|
// Copy following switches to child process.
|
||||||
static const char* const kCommonSwitchNames[] = {switches::kStandardSchemes,
|
static const char* const kCommonSwitchNames[] = {
|
||||||
switches::kEnableSandbox,
|
switches::kStandardSchemes, switches::kEnableSandbox,
|
||||||
switches::kSecureSchemes};
|
switches::kSecureSchemes, switches::kBypassCSPSchemes,
|
||||||
|
switches::kCORSSchemes, switches::kFetchSchemes,
|
||||||
|
switches::kServiceWorkerSchemes};
|
||||||
command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
|
command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
|
||||||
kCommonSwitchNames,
|
kCommonSwitchNames,
|
||||||
arraysize(kCommonSwitchNames));
|
base::size(kCommonSwitchNames));
|
||||||
|
|
||||||
// The registered service worker schemes.
|
|
||||||
if (!g_custom_service_worker_schemes->empty())
|
|
||||||
command_line->AppendSwitchASCII(switches::kRegisterServiceWorkerSchemes,
|
|
||||||
*g_custom_service_worker_schemes);
|
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
// Append --app-user-model-id.
|
// Append --app-user-model-id.
|
||||||
@@ -523,6 +514,16 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AtomBrowserClient::AdjustUtilityServiceProcessCommandLine(
|
||||||
|
const service_manager::Identity& identity,
|
||||||
|
base::CommandLine* command_line) {
|
||||||
|
#if defined(OS_MACOSX)
|
||||||
|
if (identity.name() == video_capture::mojom::kServiceName ||
|
||||||
|
identity.name() == audio::mojom::kServiceName)
|
||||||
|
command_line->AppendSwitch(::switches::kMessageLoopTypeUi);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void AtomBrowserClient::DidCreatePpapiPlugin(content::BrowserPpapiHost* host) {
|
void AtomBrowserClient::DidCreatePpapiPlugin(content::BrowserPpapiHost* host) {
|
||||||
#if BUILDFLAG(ENABLE_PEPPER_FLASH)
|
#if BUILDFLAG(ENABLE_PEPPER_FLASH)
|
||||||
host->GetPpapiHost()->AddHostFactoryFilter(
|
host->GetPpapiHost()->AddHostFactoryFilter(
|
||||||
@@ -594,7 +595,7 @@ bool AtomBrowserClient::CanCreateWindow(
|
|||||||
content::RenderFrameHost* opener,
|
content::RenderFrameHost* opener,
|
||||||
const GURL& opener_url,
|
const GURL& opener_url,
|
||||||
const GURL& opener_top_level_frame_url,
|
const GURL& opener_top_level_frame_url,
|
||||||
const GURL& source_origin,
|
const url::Origin& source_origin,
|
||||||
content::mojom::WindowContainerType container_type,
|
content::mojom::WindowContainerType container_type,
|
||||||
const GURL& target_url,
|
const GURL& target_url,
|
||||||
const content::Referrer& referrer,
|
const content::Referrer& referrer,
|
||||||
@@ -713,20 +714,17 @@ void AtomBrowserClient::RegisterOutOfProcessServices(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<base::Value> AtomBrowserClient::GetServiceManifestOverlay(
|
base::Optional<service_manager::Manifest>
|
||||||
base::StringPiece name) {
|
AtomBrowserClient::GetServiceManifestOverlay(base::StringPiece name) {
|
||||||
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
|
if (name == content::mojom::kBrowserServiceName) {
|
||||||
int id = -1;
|
return GetElectronContentBrowserOverlayManifest();
|
||||||
if (name == content::mojom::kBrowserServiceName)
|
} else if (name == content::mojom::kPackagedServicesServiceName) {
|
||||||
id = IDR_ELECTRON_CONTENT_BROWSER_MANIFEST_OVERLAY;
|
service_manager::Manifest overlay;
|
||||||
else if (name == content::mojom::kPackagedServicesServiceName)
|
overlay.packaged_services = GetElectronPackagedServicesOverlayManifest();
|
||||||
id = IDR_ELECTRON_CONTENT_PACKAGED_SERVICES_MANIFEST_OVERLAY;
|
return overlay;
|
||||||
|
}
|
||||||
|
|
||||||
if (id == -1)
|
return base::nullopt;
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
base::StringPiece manifest_contents = rb.GetRawDataResource(id);
|
|
||||||
return base::JSONReader::Read(manifest_contents);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
net::NetLog* AtomBrowserClient::GetNetLog() {
|
net::NetLog* AtomBrowserClient::GetNetLog() {
|
||||||
@@ -895,6 +893,14 @@ bool AtomBrowserClient::ShouldBypassCORB(int render_process_id) const {
|
|||||||
return it != process_preferences_.end() && !it->second.web_security;
|
return it != process_preferences_.end() && !it->second.web_security;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string AtomBrowserClient::GetProduct() const {
|
||||||
|
return "Chrome/" CHROME_VERSION_STRING;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string AtomBrowserClient::GetUserAgent() const {
|
||||||
|
return GetApplicationUserAgent();
|
||||||
|
}
|
||||||
|
|
||||||
std::string AtomBrowserClient::GetApplicationLocale() {
|
std::string AtomBrowserClient::GetApplicationLocale() {
|
||||||
if (BrowserThread::CurrentlyOn(BrowserThread::IO))
|
if (BrowserThread::CurrentlyOn(BrowserThread::IO))
|
||||||
return g_io_thread_application_locale.Get();
|
return g_io_thread_application_locale.Get();
|
||||||
|
|||||||
@@ -49,10 +49,6 @@ class AtomBrowserClient : public content::ContentBrowserClient,
|
|||||||
// Don't force renderer process to restart for once.
|
// Don't force renderer process to restart for once.
|
||||||
static void SuppressRendererProcessRestartForOnce();
|
static void SuppressRendererProcessRestartForOnce();
|
||||||
|
|
||||||
// Custom schemes to be registered to handle service worker.
|
|
||||||
static void SetCustomServiceWorkerSchemes(
|
|
||||||
const std::vector<std::string>& schemes);
|
|
||||||
|
|
||||||
NotificationPresenter* GetNotificationPresenter();
|
NotificationPresenter* GetNotificationPresenter();
|
||||||
|
|
||||||
void WebNotificationAllowed(int render_process_id,
|
void WebNotificationAllowed(int render_process_id,
|
||||||
@@ -89,6 +85,9 @@ class AtomBrowserClient : public content::ContentBrowserClient,
|
|||||||
content::SiteInstance* pending_site_instance) override;
|
content::SiteInstance* pending_site_instance) override;
|
||||||
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
|
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
|
||||||
int child_process_id) override;
|
int child_process_id) override;
|
||||||
|
void AdjustUtilityServiceProcessCommandLine(
|
||||||
|
const service_manager::Identity& identity,
|
||||||
|
base::CommandLine* command_line) override;
|
||||||
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
|
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
|
||||||
std::string GetGeolocationApiKey() override;
|
std::string GetGeolocationApiKey() override;
|
||||||
content::QuotaPermissionContext* CreateQuotaPermissionContext() override;
|
content::QuotaPermissionContext* CreateQuotaPermissionContext() override;
|
||||||
@@ -113,7 +112,7 @@ class AtomBrowserClient : public content::ContentBrowserClient,
|
|||||||
bool CanCreateWindow(content::RenderFrameHost* opener,
|
bool CanCreateWindow(content::RenderFrameHost* opener,
|
||||||
const GURL& opener_url,
|
const GURL& opener_url,
|
||||||
const GURL& opener_top_level_frame_url,
|
const GURL& opener_top_level_frame_url,
|
||||||
const GURL& source_origin,
|
const url::Origin& source_origin,
|
||||||
content::mojom::WindowContainerType container_type,
|
content::mojom::WindowContainerType container_type,
|
||||||
const GURL& target_url,
|
const GURL& target_url,
|
||||||
const content::Referrer& referrer,
|
const content::Referrer& referrer,
|
||||||
@@ -139,7 +138,7 @@ class AtomBrowserClient : public content::ContentBrowserClient,
|
|||||||
bool in_memory,
|
bool in_memory,
|
||||||
const base::FilePath& relative_partition_path) override;
|
const base::FilePath& relative_partition_path) override;
|
||||||
void RegisterOutOfProcessServices(OutOfProcessServiceMap* services) override;
|
void RegisterOutOfProcessServices(OutOfProcessServiceMap* services) override;
|
||||||
std::unique_ptr<base::Value> GetServiceManifestOverlay(
|
base::Optional<service_manager::Manifest> GetServiceManifestOverlay(
|
||||||
base::StringPiece name) override;
|
base::StringPiece name) override;
|
||||||
net::NetLog* GetNetLog() override;
|
net::NetLog* GetNetLog() override;
|
||||||
content::MediaObserver* GetMediaObserver() override;
|
content::MediaObserver* GetMediaObserver() override;
|
||||||
@@ -154,6 +153,8 @@ class AtomBrowserClient : public content::ContentBrowserClient,
|
|||||||
void OnNetworkServiceCreated(
|
void OnNetworkServiceCreated(
|
||||||
network::mojom::NetworkService* network_service) override;
|
network::mojom::NetworkService* network_service) override;
|
||||||
bool ShouldBypassCORB(int render_process_id) const override;
|
bool ShouldBypassCORB(int render_process_id) const override;
|
||||||
|
std::string GetProduct() const override;
|
||||||
|
std::string GetUserAgent() const override;
|
||||||
|
|
||||||
// content::RenderProcessHostObserver:
|
// content::RenderProcessHostObserver:
|
||||||
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
#include "atom/browser/atom_download_manager_delegate.h"
|
#include "atom/browser/atom_download_manager_delegate.h"
|
||||||
#include "atom/browser/atom_paths.h"
|
#include "atom/browser/atom_paths.h"
|
||||||
#include "atom/browser/atom_permission_manager.h"
|
#include "atom/browser/atom_permission_manager.h"
|
||||||
#include "atom/browser/browser.h"
|
|
||||||
#include "atom/browser/cookie_change_notifier.h"
|
#include "atom/browser/cookie_change_notifier.h"
|
||||||
#include "atom/browser/net/resolve_proxy_helper.h"
|
#include "atom/browser/net/resolve_proxy_helper.h"
|
||||||
#include "atom/browser/pref_store_delegate.h"
|
#include "atom/browser/pref_store_delegate.h"
|
||||||
@@ -20,17 +19,14 @@
|
|||||||
#include "atom/browser/web_view_manager.h"
|
#include "atom/browser/web_view_manager.h"
|
||||||
#include "atom/browser/zoom_level_delegate.h"
|
#include "atom/browser/zoom_level_delegate.h"
|
||||||
#include "atom/common/application_info.h"
|
#include "atom/common/application_info.h"
|
||||||
#include "atom/common/atom_version.h"
|
|
||||||
#include "atom/common/options_switches.h"
|
#include "atom/common/options_switches.h"
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
#include "base/files/file_path.h"
|
#include "base/files/file_path.h"
|
||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
#include "base/strings/stringprintf.h"
|
|
||||||
#include "base/threading/sequenced_task_runner_handle.h"
|
#include "base/threading/sequenced_task_runner_handle.h"
|
||||||
#include "base/threading/thread_restrictions.h"
|
#include "base/threading/thread_restrictions.h"
|
||||||
#include "chrome/common/chrome_paths.h"
|
#include "chrome/common/chrome_paths.h"
|
||||||
#include "chrome/common/chrome_version.h"
|
|
||||||
#include "chrome/common/pref_names.h"
|
#include "chrome/common/pref_names.h"
|
||||||
#include "components/keyed_service/content/browser_context_dependency_manager.h"
|
#include "components/keyed_service/content/browser_context_dependency_manager.h"
|
||||||
#include "components/prefs/json_pref_store.h"
|
#include "components/prefs/json_pref_store.h"
|
||||||
@@ -41,8 +37,8 @@
|
|||||||
#include "components/proxy_config/pref_proxy_config_tracker_impl.h"
|
#include "components/proxy_config/pref_proxy_config_tracker_impl.h"
|
||||||
#include "components/proxy_config/proxy_config_pref_names.h"
|
#include "components/proxy_config/proxy_config_pref_names.h"
|
||||||
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
|
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
|
||||||
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "content/public/browser/storage_partition.h"
|
#include "content/public/browser/storage_partition.h"
|
||||||
#include "content/public/common/user_agent.h"
|
|
||||||
#include "net/base/escape.h"
|
#include "net/base/escape.h"
|
||||||
|
|
||||||
using content::BrowserThread;
|
using content::BrowserThread;
|
||||||
@@ -51,14 +47,6 @@ namespace atom {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
std::string RemoveWhitespace(const std::string& str) {
|
|
||||||
std::string trimmed;
|
|
||||||
if (base::RemoveChars(str, " ", &trimmed))
|
|
||||||
return trimmed;
|
|
||||||
else
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert string to lower case and escape it.
|
// Convert string to lower case and escape it.
|
||||||
std::string MakePartitionName(const std::string& input) {
|
std::string MakePartitionName(const std::string& input) {
|
||||||
return net::EscapePath(base::ToLowerASCII(input));
|
return net::EscapePath(base::ToLowerASCII(input));
|
||||||
@@ -78,19 +66,7 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition,
|
|||||||
storage_policy_(new SpecialStoragePolicy),
|
storage_policy_(new SpecialStoragePolicy),
|
||||||
in_memory_(in_memory),
|
in_memory_(in_memory),
|
||||||
weak_factory_(this) {
|
weak_factory_(this) {
|
||||||
// Construct user agent string.
|
user_agent_ = GetApplicationUserAgent();
|
||||||
Browser* browser = Browser::Get();
|
|
||||||
std::string name = RemoveWhitespace(browser->GetName());
|
|
||||||
std::string user_agent;
|
|
||||||
if (name == ATOM_PRODUCT_NAME) {
|
|
||||||
user_agent = "Chrome/" CHROME_VERSION_STRING " " ATOM_PRODUCT_NAME
|
|
||||||
"/" ATOM_VERSION_STRING;
|
|
||||||
} else {
|
|
||||||
user_agent = base::StringPrintf(
|
|
||||||
"%s/%s Chrome/%s " ATOM_PRODUCT_NAME "/" ATOM_VERSION_STRING,
|
|
||||||
name.c_str(), browser->GetVersion().c_str(), CHROME_VERSION_STRING);
|
|
||||||
}
|
|
||||||
user_agent_ = content::BuildUserAgentFromProduct(user_agent);
|
|
||||||
|
|
||||||
// Read options.
|
// Read options.
|
||||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||||
@@ -285,6 +261,11 @@ AtomBrowserContext::GetBrowsingDataRemoverDelegate() {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
content::ClientHintsControllerDelegate*
|
||||||
|
AtomBrowserContext::GetClientHintsControllerDelegate() {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
net::URLRequestContextGetter*
|
net::URLRequestContextGetter*
|
||||||
AtomBrowserContext::CreateRequestContextForStoragePartition(
|
AtomBrowserContext::CreateRequestContextForStoragePartition(
|
||||||
const base::FilePath& partition_path,
|
const base::FilePath& partition_path,
|
||||||
|
|||||||
@@ -88,6 +88,8 @@ class AtomBrowserContext
|
|||||||
content::ProtocolHandlerMap* protocol_handlers,
|
content::ProtocolHandlerMap* protocol_handlers,
|
||||||
content::URLRequestInterceptorScopedVector request_interceptors) override;
|
content::URLRequestInterceptorScopedVector request_interceptors) override;
|
||||||
net::URLRequestContextGetter* CreateMediaRequestContext() override;
|
net::URLRequestContextGetter* CreateMediaRequestContext() override;
|
||||||
|
content::ClientHintsControllerDelegate* GetClientHintsControllerDelegate()
|
||||||
|
override;
|
||||||
|
|
||||||
CookieChangeNotifier* cookie_change_notifier() const {
|
CookieChangeNotifier* cookie_change_notifier() const {
|
||||||
return cookie_change_notifier_.get();
|
return cookie_change_notifier_.get();
|
||||||
|
|||||||
@@ -455,7 +455,7 @@ bool AtomBrowserMainParts::MainMessageLoopRun(int* result_code) {
|
|||||||
|
|
||||||
void AtomBrowserMainParts::PreDefaultMainMessageLoopRun(
|
void AtomBrowserMainParts::PreDefaultMainMessageLoopRun(
|
||||||
base::OnceClosure quit_closure) {
|
base::OnceClosure quit_closure) {
|
||||||
Browser::SetMainMessageLoopQuitClosure(std::move(quit_closure));
|
Browser::Get()->SetMainMessageLoopQuitClosure(std::move(quit_closure));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomBrowserMainParts::PostMainMessageLoopStart() {
|
void AtomBrowserMainParts::PostMainMessageLoopStart() {
|
||||||
@@ -481,6 +481,7 @@ void AtomBrowserMainParts::PostMainMessageLoopRun() {
|
|||||||
ui::SetX11ErrorHandlers(X11EmptyErrorHandler, X11EmptyIOErrorHandler);
|
ui::SetX11ErrorHandlers(X11EmptyErrorHandler, X11EmptyIOErrorHandler);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
node_debugger_->Stop();
|
||||||
js_env_->OnMessageLoopDestroying();
|
js_env_->OnMessageLoopDestroying();
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
|
|||||||
@@ -54,8 +54,26 @@ void AtomBrowserMainParts::InitializeMainNib() {
|
|||||||
auto application = [principalClass sharedApplication];
|
auto application = [principalClass sharedApplication];
|
||||||
|
|
||||||
NSString* mainNibName = [infoDictionary objectForKey:@"NSMainNibFile"];
|
NSString* mainNibName = [infoDictionary objectForKey:@"NSMainNibFile"];
|
||||||
auto mainNib = [[NSNib alloc] initWithNibNamed:mainNibName
|
|
||||||
bundle:base::mac::FrameworkBundle()];
|
NSNib* mainNib;
|
||||||
|
|
||||||
|
@try {
|
||||||
|
mainNib = [[NSNib alloc] initWithNibNamed:mainNibName
|
||||||
|
bundle:base::mac::FrameworkBundle()];
|
||||||
|
// Handle failure of initWithNibNamed on SMB shares
|
||||||
|
// TODO(codebytere): Remove when
|
||||||
|
// https://bugs.chromium.org/p/chromium/issues/detail?id=932935 is fixed
|
||||||
|
} @catch (NSException* exception) {
|
||||||
|
NSString* nibPath =
|
||||||
|
[NSString stringWithFormat:@"Resources/%@.nib", mainNibName];
|
||||||
|
nibPath = [base::mac::FrameworkBundle().bundlePath
|
||||||
|
stringByAppendingPathComponent:nibPath];
|
||||||
|
|
||||||
|
NSData* data = [NSData dataWithContentsOfFile:nibPath];
|
||||||
|
mainNib = [[NSNib alloc] initWithNibData:data
|
||||||
|
bundle:base::mac::FrameworkBundle()];
|
||||||
|
}
|
||||||
|
|
||||||
[mainNib instantiateWithOwner:application topLevelObjects:nil];
|
[mainNib instantiateWithOwner:application topLevelObjects:nil];
|
||||||
[mainNib release];
|
[mainNib release];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,23 +100,58 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated(
|
|||||||
if (relay)
|
if (relay)
|
||||||
window = relay->GetNativeWindow();
|
window = relay->GetNativeWindow();
|
||||||
|
|
||||||
auto* web_preferences = WebContentsPreferences::From(web_contents);
|
// Show save dialog if save path was not set already on item
|
||||||
bool offscreen =
|
|
||||||
!web_preferences || web_preferences->IsEnabled(options::kOffscreen);
|
|
||||||
|
|
||||||
base::FilePath path;
|
base::FilePath path;
|
||||||
GetItemSavePath(item, &path);
|
GetItemSavePath(item, &path);
|
||||||
// Show save dialog if save path was not set already on item
|
if (path.empty()) {
|
||||||
file_dialog::DialogSettings settings;
|
file_dialog::DialogSettings settings;
|
||||||
GetItemSaveDialogOptions(item, &settings);
|
GetItemSaveDialogOptions(item, &settings);
|
||||||
if (!settings.parent_window)
|
|
||||||
settings.parent_window = window;
|
if (!settings.parent_window)
|
||||||
settings.force_detached = offscreen;
|
settings.parent_window = window;
|
||||||
if (settings.title.size() == 0)
|
if (settings.title.size() == 0)
|
||||||
settings.title = item->GetURL().spec();
|
settings.title = item->GetURL().spec();
|
||||||
if (!settings.default_path.empty())
|
if (settings.default_path.empty())
|
||||||
settings.default_path = default_path;
|
settings.default_path = default_path;
|
||||||
if (path.empty() && file_dialog::ShowSaveDialog(settings, &path)) {
|
|
||||||
|
auto* web_preferences = WebContentsPreferences::From(web_contents);
|
||||||
|
const bool offscreen =
|
||||||
|
!web_preferences || web_preferences->IsEnabled(options::kOffscreen);
|
||||||
|
settings.force_detached = offscreen;
|
||||||
|
|
||||||
|
auto dialog_callback =
|
||||||
|
base::Bind(&AtomDownloadManagerDelegate::OnDownloadSaveDialogDone,
|
||||||
|
base::Unretained(this), download_id, callback);
|
||||||
|
file_dialog::ShowSaveDialog(settings, dialog_callback);
|
||||||
|
} else {
|
||||||
|
callback.Run(path, download::DownloadItem::TARGET_DISPOSITION_PROMPT,
|
||||||
|
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, path,
|
||||||
|
download::DOWNLOAD_INTERRUPT_REASON_NONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(MAS_BUILD)
|
||||||
|
void AtomDownloadManagerDelegate::OnDownloadSaveDialogDone(
|
||||||
|
uint32_t download_id,
|
||||||
|
const content::DownloadTargetCallback& download_callback,
|
||||||
|
bool result,
|
||||||
|
const base::FilePath& path,
|
||||||
|
const std::string& bookmark)
|
||||||
|
#else
|
||||||
|
void AtomDownloadManagerDelegate::OnDownloadSaveDialogDone(
|
||||||
|
uint32_t download_id,
|
||||||
|
const content::DownloadTargetCallback& download_callback,
|
||||||
|
bool result,
|
||||||
|
const base::FilePath& path)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||||
|
|
||||||
|
auto* item = download_manager_->GetDownload(download_id);
|
||||||
|
if (!item)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (result) {
|
||||||
// Remember the last selected download directory.
|
// Remember the last selected download directory.
|
||||||
AtomBrowserContext* browser_context = static_cast<AtomBrowserContext*>(
|
AtomBrowserContext* browser_context = static_cast<AtomBrowserContext*>(
|
||||||
download_manager_->GetBrowserContext());
|
download_manager_->GetBrowserContext());
|
||||||
@@ -133,12 +168,16 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Running the DownloadTargetCallback with an empty FilePath signals that the
|
// Running the DownloadTargetCallback with an empty FilePath signals that the
|
||||||
// download should be cancelled.
|
// download should be cancelled. If user cancels the file save dialog, run
|
||||||
// If user cancels the file save dialog, run the callback with empty FilePath.
|
// the callback with empty FilePath.
|
||||||
callback.Run(path, download::DownloadItem::TARGET_DISPOSITION_PROMPT,
|
const base::FilePath download_path = result ? path : base::FilePath();
|
||||||
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, path,
|
const auto interrupt_reason =
|
||||||
path.empty() ? download::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED
|
download_path.empty() ? download::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED
|
||||||
: download::DOWNLOAD_INTERRUPT_REASON_NONE);
|
: download::DOWNLOAD_INTERRUPT_REASON_NONE;
|
||||||
|
download_callback.Run(download_path,
|
||||||
|
download::DownloadItem::TARGET_DISPOSITION_PROMPT,
|
||||||
|
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
|
||||||
|
download_path, interrupt_reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomDownloadManagerDelegate::Shutdown() {
|
void AtomDownloadManagerDelegate::Shutdown() {
|
||||||
|
|||||||
@@ -25,10 +25,6 @@ class AtomDownloadManagerDelegate : public content::DownloadManagerDelegate {
|
|||||||
explicit AtomDownloadManagerDelegate(content::DownloadManager* manager);
|
explicit AtomDownloadManagerDelegate(content::DownloadManager* manager);
|
||||||
~AtomDownloadManagerDelegate() override;
|
~AtomDownloadManagerDelegate() override;
|
||||||
|
|
||||||
void OnDownloadPathGenerated(uint32_t download_id,
|
|
||||||
const content::DownloadTargetCallback& callback,
|
|
||||||
const base::FilePath& default_path);
|
|
||||||
|
|
||||||
// content::DownloadManagerDelegate:
|
// content::DownloadManagerDelegate:
|
||||||
void Shutdown() override;
|
void Shutdown() override;
|
||||||
bool DetermineDownloadTarget(
|
bool DetermineDownloadTarget(
|
||||||
@@ -45,6 +41,25 @@ class AtomDownloadManagerDelegate : public content::DownloadManagerDelegate {
|
|||||||
void GetItemSaveDialogOptions(download::DownloadItem* item,
|
void GetItemSaveDialogOptions(download::DownloadItem* item,
|
||||||
file_dialog::DialogSettings* settings);
|
file_dialog::DialogSettings* settings);
|
||||||
|
|
||||||
|
void OnDownloadPathGenerated(uint32_t download_id,
|
||||||
|
const content::DownloadTargetCallback& callback,
|
||||||
|
const base::FilePath& default_path);
|
||||||
|
|
||||||
|
#if defined(MAS_BUILD)
|
||||||
|
void OnDownloadSaveDialogDone(
|
||||||
|
uint32_t download_id,
|
||||||
|
const content::DownloadTargetCallback& download_callback,
|
||||||
|
bool result,
|
||||||
|
const base::FilePath& path,
|
||||||
|
const std::string& bookmark);
|
||||||
|
#else
|
||||||
|
void OnDownloadSaveDialogDone(
|
||||||
|
uint32_t download_id,
|
||||||
|
const content::DownloadTargetCallback& download_callback,
|
||||||
|
bool result,
|
||||||
|
const base::FilePath& path);
|
||||||
|
#endif
|
||||||
|
|
||||||
content::DownloadManager* download_manager_;
|
content::DownloadManager* download_manager_;
|
||||||
base::WeakPtrFactory<AtomDownloadManagerDelegate> weak_ptr_factory_;
|
base::WeakPtrFactory<AtomDownloadManagerDelegate> weak_ptr_factory_;
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,16 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
|
|||||||
DialogClosedCallback callback,
|
DialogClosedCallback callback,
|
||||||
bool* did_suppress_message) {
|
bool* did_suppress_message) {
|
||||||
auto origin_url = rfh->GetLastCommittedURL();
|
auto origin_url = rfh->GetLastCommittedURL();
|
||||||
const std::string& origin = origin_url.GetOrigin().spec();
|
|
||||||
|
std::string origin;
|
||||||
|
// For file:// URLs we do the alert filtering by the
|
||||||
|
// file path currently loaded
|
||||||
|
if (origin_url.SchemeIsFile()) {
|
||||||
|
origin = origin_url.path();
|
||||||
|
} else {
|
||||||
|
origin = origin_url.GetOrigin().spec();
|
||||||
|
}
|
||||||
|
|
||||||
if (origin_counts_[origin] == kUserWantsNoMoreDialogs) {
|
if (origin_counts_[origin] == kUserWantsNoMoreDialogs) {
|
||||||
return std::move(callback).Run(false, base::string16());
|
return std::move(callback).Run(false, base::string16());
|
||||||
}
|
}
|
||||||
@@ -52,9 +61,16 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No default button
|
||||||
|
int default_id = -1;
|
||||||
|
int cancel_id = 0;
|
||||||
|
|
||||||
std::vector<std::string> buttons = {"OK"};
|
std::vector<std::string> buttons = {"OK"};
|
||||||
if (dialog_type == JavaScriptDialogType::JAVASCRIPT_DIALOG_TYPE_CONFIRM) {
|
if (dialog_type == JavaScriptDialogType::JAVASCRIPT_DIALOG_TYPE_CONFIRM) {
|
||||||
buttons.push_back("Cancel");
|
buttons.push_back("Cancel");
|
||||||
|
// First button is default, second button is cancel
|
||||||
|
default_id = 0;
|
||||||
|
cancel_id = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
origin_counts_[origin]++;
|
origin_counts_[origin]++;
|
||||||
@@ -76,8 +92,8 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
|
|||||||
}
|
}
|
||||||
|
|
||||||
atom::ShowMessageBox(
|
atom::ShowMessageBox(
|
||||||
window, atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, -1, 0,
|
window, atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, default_id,
|
||||||
atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
|
cancel_id, atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
|
||||||
base::UTF16ToUTF8(message_text), "", checkbox, false, gfx::ImageSkia(),
|
base::UTF16ToUTF8(message_text), "", checkbox, false, gfx::ImageSkia(),
|
||||||
base::Bind(&AtomJavaScriptDialogManager::OnMessageBoxCallback,
|
base::Bind(&AtomJavaScriptDialogManager::OnMessageBoxCallback,
|
||||||
base::Unretained(this), base::Passed(std::move(callback)),
|
base::Unretained(this), base::Passed(std::move(callback)),
|
||||||
|
|||||||
@@ -25,9 +25,6 @@
|
|||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
// Null until/unless the default main message loop is running.
|
|
||||||
base::NoDestructor<base::OnceClosure> g_quit_main_message_loop;
|
|
||||||
|
|
||||||
Browser::LoginItemSettings::LoginItemSettings() = default;
|
Browser::LoginItemSettings::LoginItemSettings() = default;
|
||||||
Browser::LoginItemSettings::~LoginItemSettings() = default;
|
Browser::LoginItemSettings::~LoginItemSettings() = default;
|
||||||
Browser::LoginItemSettings::LoginItemSettings(const LoginItemSettings& other) =
|
Browser::LoginItemSettings::LoginItemSettings(const LoginItemSettings& other) =
|
||||||
@@ -95,11 +92,12 @@ void Browser::Shutdown() {
|
|||||||
for (BrowserObserver& observer : observers_)
|
for (BrowserObserver& observer : observers_)
|
||||||
observer.OnQuit();
|
observer.OnQuit();
|
||||||
|
|
||||||
if (*g_quit_main_message_loop) {
|
if (quit_main_message_loop_) {
|
||||||
std::move(*g_quit_main_message_loop).Run();
|
std::move(quit_main_message_loop_).Run();
|
||||||
} else {
|
} else {
|
||||||
// There is no message loop available so we are in early stage.
|
// There is no message loop available so we are in early stage, wait until
|
||||||
exit(0);
|
// the quit_main_message_loop_ is available.
|
||||||
|
// Exiting now would leave defunct processes behind.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,14 +165,14 @@ void Browser::DidFinishLaunching(const base::DictionaryValue& launch_info) {
|
|||||||
observer.OnFinishLaunching(launch_info);
|
observer.OnFinishLaunching(launch_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
util::Promise* Browser::WhenReady(v8::Isolate* isolate) {
|
const util::Promise& Browser::WhenReady(v8::Isolate* isolate) {
|
||||||
if (!ready_promise_) {
|
if (!ready_promise_) {
|
||||||
ready_promise_ = new util::Promise(isolate);
|
ready_promise_.reset(new util::Promise(isolate));
|
||||||
if (is_ready()) {
|
if (is_ready()) {
|
||||||
ready_promise_->Resolve();
|
ready_promise_->Resolve();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ready_promise_;
|
return *ready_promise_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Browser::OnAccessibilitySupportChanged() {
|
void Browser::OnAccessibilitySupportChanged() {
|
||||||
@@ -196,7 +194,10 @@ void Browser::PreMainMessageLoopRun() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Browser::SetMainMessageLoopQuitClosure(base::OnceClosure quit_closure) {
|
void Browser::SetMainMessageLoopQuitClosure(base::OnceClosure quit_closure) {
|
||||||
*g_quit_main_message_loop = std::move(quit_closure);
|
if (is_shutdown_)
|
||||||
|
std::move(quit_closure).Run();
|
||||||
|
else
|
||||||
|
quit_main_message_loop_ = std::move(quit_closure);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Browser::NotifyAndShutdown() {
|
void Browser::NotifyAndShutdown() {
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ class Browser : public WindowListObserver {
|
|||||||
|
|
||||||
// Stores the supplied |quit_closure|, to be run when the last Browser
|
// Stores the supplied |quit_closure|, to be run when the last Browser
|
||||||
// instance is destroyed.
|
// instance is destroyed.
|
||||||
static void SetMainMessageLoopQuitClosure(base::OnceClosure quit_closure);
|
void SetMainMessageLoopQuitClosure(base::OnceClosure quit_closure);
|
||||||
|
|
||||||
void AddObserver(BrowserObserver* obs) { observers_.AddObserver(obs); }
|
void AddObserver(BrowserObserver* obs) { observers_.AddObserver(obs); }
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ class Browser : public WindowListObserver {
|
|||||||
bool is_shutting_down() const { return is_shutdown_; }
|
bool is_shutting_down() const { return is_shutdown_; }
|
||||||
bool is_quiting() const { return is_quiting_; }
|
bool is_quiting() const { return is_quiting_; }
|
||||||
bool is_ready() const { return is_ready_; }
|
bool is_ready() const { return is_ready_; }
|
||||||
util::Promise* WhenReady(v8::Isolate* isolate);
|
const util::Promise& WhenReady(v8::Isolate* isolate);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Returns the version of application bundle or executable file.
|
// Returns the version of application bundle or executable file.
|
||||||
@@ -287,9 +287,12 @@ class Browser : public WindowListObserver {
|
|||||||
// The browser is being shutdown.
|
// The browser is being shutdown.
|
||||||
bool is_shutdown_ = false;
|
bool is_shutdown_ = false;
|
||||||
|
|
||||||
|
// Null until/unless the default main message loop is running.
|
||||||
|
base::OnceClosure quit_main_message_loop_;
|
||||||
|
|
||||||
int badge_count_ = 0;
|
int badge_count_ = 0;
|
||||||
|
|
||||||
util::Promise* ready_promise_ = nullptr;
|
std::unique_ptr<util::Promise> ready_promise_;
|
||||||
|
|
||||||
#if defined(OS_LINUX) || defined(OS_MACOSX)
|
#if defined(OS_LINUX) || defined(OS_MACOSX)
|
||||||
base::DictionaryValue about_panel_options_;
|
base::DictionaryValue about_panel_options_;
|
||||||
|
|||||||
@@ -147,13 +147,9 @@ void Browser::SetUserActivity(const std::string& type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string Browser::GetCurrentActivityType() {
|
std::string Browser::GetCurrentActivityType() {
|
||||||
if (@available(macOS 10.10, *)) {
|
NSUserActivity* userActivity =
|
||||||
NSUserActivity* userActivity =
|
[[AtomApplication sharedApplication] getCurrentActivity];
|
||||||
[[AtomApplication sharedApplication] getCurrentActivity];
|
return base::SysNSStringToUTF8(userActivity.activityType);
|
||||||
return base::SysNSStringToUTF8(userActivity.activityType);
|
|
||||||
} else {
|
|
||||||
return std::string();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Browser::InvalidateCurrentActivity() {
|
void Browser::InvalidateCurrentActivity() {
|
||||||
@@ -231,9 +227,10 @@ LSSharedFileListItemRef GetLoginItemForApp() {
|
|||||||
for (NSUInteger i = 0; i < [login_items_array count]; ++i) {
|
for (NSUInteger i = 0; i < [login_items_array count]; ++i) {
|
||||||
LSSharedFileListItemRef item =
|
LSSharedFileListItemRef item =
|
||||||
reinterpret_cast<LSSharedFileListItemRef>(login_items_array[i]);
|
reinterpret_cast<LSSharedFileListItemRef>(login_items_array[i]);
|
||||||
CFURLRef item_url_ref = NULL;
|
base::ScopedCFTypeRef<CFErrorRef> error;
|
||||||
if (LSSharedFileListItemResolve(item, 0, &item_url_ref, NULL) == noErr &&
|
CFURLRef item_url_ref =
|
||||||
item_url_ref) {
|
LSSharedFileListItemCopyResolvedURL(item, 0, error.InitializeInto());
|
||||||
|
if (!error && item_url_ref) {
|
||||||
base::ScopedCFTypeRef<CFURLRef> item_url(item_url_ref);
|
base::ScopedCFTypeRef<CFURLRef> item_url(item_url_ref);
|
||||||
if (CFEqual(item_url, url)) {
|
if (CFEqual(item_url, url)) {
|
||||||
CFRetain(item);
|
CFRetain(item);
|
||||||
@@ -264,9 +261,10 @@ void RemoveFromLoginItems() {
|
|||||||
for (NSUInteger i = 0; i < [login_items_array count]; ++i) {
|
for (NSUInteger i = 0; i < [login_items_array count]; ++i) {
|
||||||
LSSharedFileListItemRef item =
|
LSSharedFileListItemRef item =
|
||||||
reinterpret_cast<LSSharedFileListItemRef>(login_items_array[i]);
|
reinterpret_cast<LSSharedFileListItemRef>(login_items_array[i]);
|
||||||
CFURLRef url_ref = NULL;
|
base::ScopedCFTypeRef<CFErrorRef> error;
|
||||||
if (LSSharedFileListItemResolve(item, 0, &url_ref, NULL) == noErr &&
|
CFURLRef url_ref =
|
||||||
item) {
|
LSSharedFileListItemCopyResolvedURL(item, 0, error.InitializeInto());
|
||||||
|
if (!error && url_ref) {
|
||||||
base::ScopedCFTypeRef<CFURLRef> url(url_ref);
|
base::ScopedCFTypeRef<CFURLRef> url(url_ref);
|
||||||
if ([[base::mac::CFToNSCast(url.get()) path]
|
if ([[base::mac::CFToNSCast(url.get()) path]
|
||||||
hasPrefix:[[NSBundle mainBundle] bundlePath]])
|
hasPrefix:[[NSBundle mainBundle] bundlePath]])
|
||||||
|
|||||||
14
atom/browser/child_web_contents_tracker.cc
Normal file
14
atom/browser/child_web_contents_tracker.cc
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
// Copyright (c) 2019 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "atom/browser/child_web_contents_tracker.h"
|
||||||
|
|
||||||
|
namespace atom {
|
||||||
|
|
||||||
|
ChildWebContentsTracker::ChildWebContentsTracker(
|
||||||
|
content::WebContents* web_contents) {}
|
||||||
|
|
||||||
|
WEB_CONTENTS_USER_DATA_KEY_IMPL(ChildWebContentsTracker)
|
||||||
|
|
||||||
|
} // namespace atom
|
||||||
@@ -18,11 +18,12 @@ struct ChildWebContentsTracker
|
|||||||
GURL url;
|
GURL url;
|
||||||
std::string frame_name;
|
std::string frame_name;
|
||||||
|
|
||||||
explicit ChildWebContentsTracker(content::WebContents* web_contents) {}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
explicit ChildWebContentsTracker(content::WebContents* web_contents);
|
||||||
friend class content::WebContentsUserData<ChildWebContentsTracker>;
|
friend class content::WebContentsUserData<ChildWebContentsTracker>;
|
||||||
|
|
||||||
|
WEB_CONTENTS_USER_DATA_KEY_DECL();
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ChildWebContentsTracker);
|
DISALLOW_COPY_AND_ASSIGN(ChildWebContentsTracker);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "atom/browser/atom_browser_client.h"
|
||||||
#include "atom/browser/atom_browser_context.h"
|
#include "atom/browser/atom_browser_context.h"
|
||||||
#include "atom/browser/native_window.h"
|
#include "atom/browser/native_window.h"
|
||||||
#include "atom/browser/ui/file_dialog.h"
|
#include "atom/browser/ui/file_dialog.h"
|
||||||
@@ -23,7 +24,7 @@
|
|||||||
#include "base/threading/scoped_blocking_call.h"
|
#include "base/threading/scoped_blocking_call.h"
|
||||||
#include "base/threading/sequenced_task_runner_handle.h"
|
#include "base/threading/sequenced_task_runner_handle.h"
|
||||||
#include "chrome/browser/ssl/security_state_tab_helper.h"
|
#include "chrome/browser/ssl/security_state_tab_helper.h"
|
||||||
#include "chrome/browser/ui/browser_dialogs.h"
|
#include "chrome/browser/ui/color_chooser.h"
|
||||||
#include "chrome/common/pref_names.h"
|
#include "chrome/common/pref_names.h"
|
||||||
#include "components/prefs/pref_service.h"
|
#include "components/prefs/pref_service.h"
|
||||||
#include "components/prefs/scoped_user_pref_update.h"
|
#include "components/prefs/scoped_user_pref_update.h"
|
||||||
@@ -183,7 +184,8 @@ void CommonWebContentsDelegate::InitWithWebContents(
|
|||||||
#if BUILDFLAG(ENABLE_PRINTING)
|
#if BUILDFLAG(ENABLE_PRINTING)
|
||||||
PrintPreviewMessageHandler::CreateForWebContents(web_contents);
|
PrintPreviewMessageHandler::CreateForWebContents(web_contents);
|
||||||
printing::PrintViewManagerBasic::CreateForWebContents(web_contents);
|
printing::PrintViewManagerBasic::CreateForWebContents(web_contents);
|
||||||
printing::CreateCompositeClientIfNeeded(web_contents);
|
printing::CreateCompositeClientIfNeeded(web_contents,
|
||||||
|
browser_context->GetUserAgent());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Determien whether the WebContents is offscreen.
|
// Determien whether the WebContents is offscreen.
|
||||||
@@ -206,15 +208,14 @@ void CommonWebContentsDelegate::SetOwnerWindow(
|
|||||||
NativeWindow* owner_window) {
|
NativeWindow* owner_window) {
|
||||||
if (owner_window) {
|
if (owner_window) {
|
||||||
owner_window_ = owner_window->GetWeakPtr();
|
owner_window_ = owner_window->GetWeakPtr();
|
||||||
#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
|
#if defined(TOOLKIT_VIEWS)
|
||||||
autofill_popup_.reset(new AutofillPopup());
|
autofill_popup_.reset(new AutofillPopup());
|
||||||
#endif
|
#endif
|
||||||
NativeWindowRelay::CreateForWebContents(web_contents,
|
NativeWindowRelay::CreateForWebContents(web_contents,
|
||||||
owner_window->GetWeakPtr());
|
owner_window->GetWeakPtr());
|
||||||
} else {
|
} else {
|
||||||
owner_window_ = nullptr;
|
owner_window_ = nullptr;
|
||||||
web_contents->RemoveUserData(
|
web_contents->RemoveUserData(NativeWindowRelay::UserDataKey());
|
||||||
NativeWindowRelay::kNativeWindowRelayUserDataKey);
|
|
||||||
}
|
}
|
||||||
#if BUILDFLAG(ENABLE_OSR)
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
auto* osr_wcv = GetOffScreenWebContentsView();
|
auto* osr_wcv = GetOffScreenWebContentsView();
|
||||||
@@ -274,6 +275,7 @@ content::WebContents* CommonWebContentsDelegate::OpenURLFromTab(
|
|||||||
load_url_params.should_replace_current_entry =
|
load_url_params.should_replace_current_entry =
|
||||||
params.should_replace_current_entry;
|
params.should_replace_current_entry;
|
||||||
load_url_params.is_renderer_initiated = params.is_renderer_initiated;
|
load_url_params.is_renderer_initiated = params.is_renderer_initiated;
|
||||||
|
load_url_params.initiator_origin = params.initiator_origin;
|
||||||
load_url_params.should_clear_history_list = true;
|
load_url_params.should_clear_history_list = true;
|
||||||
|
|
||||||
source->GetController().LoadURLWithParams(load_url_params);
|
source->GetController().LoadURLWithParams(load_url_params);
|
||||||
@@ -619,4 +621,24 @@ void CommonWebContentsDelegate::SetHtmlApiFullscreen(bool enter_fullscreen) {
|
|||||||
native_fullscreen_ = false;
|
native_fullscreen_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CommonWebContentsDelegate::ShowAutofillPopup(
|
||||||
|
content::RenderFrameHost* frame_host,
|
||||||
|
content::RenderFrameHost* embedder_frame_host,
|
||||||
|
bool offscreen,
|
||||||
|
const gfx::RectF& bounds,
|
||||||
|
const std::vector<base::string16>& values,
|
||||||
|
const std::vector<base::string16>& labels) {
|
||||||
|
if (!owner_window())
|
||||||
|
return;
|
||||||
|
|
||||||
|
autofill_popup_->CreateView(frame_host, embedder_frame_host, offscreen,
|
||||||
|
owner_window()->content_view(), bounds);
|
||||||
|
autofill_popup_->SetItems(values, labels);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommonWebContentsDelegate::HideAutofillPopup() {
|
||||||
|
if (autofill_popup_)
|
||||||
|
autofill_popup_->Hide();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
#include "content/public/browser/web_contents_delegate.h"
|
#include "content/public/browser/web_contents_delegate.h"
|
||||||
#include "electron/buildflags/buildflags.h"
|
#include "electron/buildflags/buildflags.h"
|
||||||
|
|
||||||
#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
|
#if defined(TOOLKIT_VIEWS)
|
||||||
#include "atom/browser/ui/autofill_popup.h"
|
#include "atom/browser/ui/autofill_popup.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ class CommonWebContentsDelegate : public content::WebContentsDelegate,
|
|||||||
const content::NativeWebKeyboardEvent& event) override;
|
const content::NativeWebKeyboardEvent& event) override;
|
||||||
|
|
||||||
// Autofill related events.
|
// Autofill related events.
|
||||||
#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
|
#if defined(TOOLKIT_VIEWS)
|
||||||
void ShowAutofillPopup(content::RenderFrameHost* frame_host,
|
void ShowAutofillPopup(content::RenderFrameHost* frame_host,
|
||||||
content::RenderFrameHost* embedder_frame_host,
|
content::RenderFrameHost* embedder_frame_host,
|
||||||
bool offscreen,
|
bool offscreen,
|
||||||
@@ -175,7 +175,7 @@ class CommonWebContentsDelegate : public content::WebContentsDelegate,
|
|||||||
bool native_fullscreen_ = false;
|
bool native_fullscreen_ = false;
|
||||||
|
|
||||||
// UI related helper classes.
|
// UI related helper classes.
|
||||||
#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
|
#if defined(TOOLKIT_VIEWS)
|
||||||
std::unique_ptr<AutofillPopup> autofill_popup_;
|
std::unique_ptr<AutofillPopup> autofill_popup_;
|
||||||
#endif
|
#endif
|
||||||
std::unique_ptr<WebDialogHelper> web_dialog_helper_;
|
std::unique_ptr<WebDialogHelper> web_dialog_helper_;
|
||||||
|
|||||||
@@ -41,27 +41,6 @@ bool CommonWebContentsDelegate::HandleKeyboardEvent(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonWebContentsDelegate::ShowAutofillPopup(
|
|
||||||
content::RenderFrameHost* frame_host,
|
|
||||||
content::RenderFrameHost* embedder_frame_host,
|
|
||||||
bool offscreen,
|
|
||||||
const gfx::RectF& bounds,
|
|
||||||
const std::vector<base::string16>& values,
|
|
||||||
const std::vector<base::string16>& labels) {
|
|
||||||
if (!owner_window())
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto* window = static_cast<NativeWindowViews*>(owner_window());
|
|
||||||
autofill_popup_->CreateView(frame_host, embedder_frame_host, offscreen,
|
|
||||||
window->content_view(), bounds);
|
|
||||||
autofill_popup_->SetItems(values, labels);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommonWebContentsDelegate::HideAutofillPopup() {
|
|
||||||
if (autofill_popup_)
|
|
||||||
autofill_popup_->Hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
gfx::ImageSkia CommonWebContentsDelegate::GetDevToolsWindowIcon() {
|
gfx::ImageSkia CommonWebContentsDelegate::GetDevToolsWindowIcon() {
|
||||||
if (!owner_window())
|
if (!owner_window())
|
||||||
return gfx::ImageSkia();
|
return gfx::ImageSkia();
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include "base/stl_util.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "chrome/common/pref_names.h"
|
#include "chrome/common/pref_names.h"
|
||||||
@@ -103,7 +104,7 @@ const FontDefault kFontDefaults[] = {
|
|||||||
IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN},
|
IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN},
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
const size_t kFontDefaultsLength = arraysize(kFontDefaults);
|
const size_t kFontDefaultsLength = base::size(kFontDefaults);
|
||||||
|
|
||||||
// ^^^^^ DO NOT EDIT ^^^^^
|
// ^^^^^ DO NOT EDIT ^^^^^
|
||||||
|
|
||||||
|
|||||||
@@ -54,10 +54,10 @@ v8::Isolate* JavascriptEnvironment::Initialize(uv_loop_t* event_loop) {
|
|||||||
tracing_controller);
|
tracing_controller);
|
||||||
|
|
||||||
v8::V8::InitializePlatform(platform_);
|
v8::V8::InitializePlatform(platform_);
|
||||||
gin::IsolateHolder::Initialize(
|
gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,
|
||||||
gin::IsolateHolder::kNonStrictMode, gin::IsolateHolder::kStableV8Extras,
|
gin::ArrayBufferAllocator::SharedInstance(),
|
||||||
gin::ArrayBufferAllocator::SharedInstance(),
|
nullptr /* external_reference_table */,
|
||||||
nullptr /* external_reference_table */, false /* create_v8_platform */);
|
false /* create_v8_platform */);
|
||||||
|
|
||||||
v8::Isolate* isolate = v8::Isolate::Allocate();
|
v8::Isolate* isolate = v8::Isolate::Allocate();
|
||||||
platform_->RegisterIsolate(isolate, event_loop);
|
platform_->RegisterIsolate(isolate, event_loop);
|
||||||
@@ -74,6 +74,7 @@ void JavascriptEnvironment::OnMessageLoopCreated() {
|
|||||||
void JavascriptEnvironment::OnMessageLoopDestroying() {
|
void JavascriptEnvironment::OnMessageLoopDestroying() {
|
||||||
DCHECK(microtasks_runner_);
|
DCHECK(microtasks_runner_);
|
||||||
base::MessageLoopCurrent::Get()->RemoveTaskObserver(microtasks_runner_.get());
|
base::MessageLoopCurrent::Get()->RemoveTaskObserver(microtasks_runner_.get());
|
||||||
|
platform_->DrainTasks(isolate_);
|
||||||
platform_->UnregisterIsolate(isolate_);
|
platform_->UnregisterIsolate(isolate_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,8 +87,7 @@ typedef NS_ENUM(NSInteger, AVAuthorizationStatusMac) {
|
|||||||
NSUserActivityDelegate> {
|
NSUserActivityDelegate> {
|
||||||
@private
|
@private
|
||||||
BOOL handlingSendEvent_;
|
BOOL handlingSendEvent_;
|
||||||
base::scoped_nsobject<NSUserActivity> currentActivity_
|
base::scoped_nsobject<NSUserActivity> currentActivity_;
|
||||||
API_AVAILABLE(macosx(10.10));
|
|
||||||
NSCondition* handoffLock_;
|
NSCondition* handoffLock_;
|
||||||
BOOL updateReceived_;
|
BOOL updateReceived_;
|
||||||
base::Callback<bool()> shouldShutdown_;
|
base::Callback<bool()> shouldShutdown_;
|
||||||
@@ -104,7 +103,7 @@ typedef NS_ENUM(NSInteger, AVAuthorizationStatusMac) {
|
|||||||
// CrAppControlProtocol:
|
// CrAppControlProtocol:
|
||||||
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent;
|
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent;
|
||||||
|
|
||||||
- (NSUserActivity*)getCurrentActivity API_AVAILABLE(macosx(10.10));
|
- (NSUserActivity*)getCurrentActivity;
|
||||||
- (void)setCurrentActivity:(NSString*)type
|
- (void)setCurrentActivity:(NSString*)type
|
||||||
withUserInfo:(NSDictionary*)userInfo
|
withUserInfo:(NSDictionary*)userInfo
|
||||||
withWebpageURL:(NSURL*)webpageURL;
|
withWebpageURL:(NSURL*)webpageURL;
|
||||||
|
|||||||
@@ -69,15 +69,13 @@ inline void dispatch_sync_main(dispatch_block_t block) {
|
|||||||
- (void)setCurrentActivity:(NSString*)type
|
- (void)setCurrentActivity:(NSString*)type
|
||||||
withUserInfo:(NSDictionary*)userInfo
|
withUserInfo:(NSDictionary*)userInfo
|
||||||
withWebpageURL:(NSURL*)webpageURL {
|
withWebpageURL:(NSURL*)webpageURL {
|
||||||
if (@available(macOS 10.10, *)) {
|
currentActivity_ = base::scoped_nsobject<NSUserActivity>(
|
||||||
currentActivity_ = base::scoped_nsobject<NSUserActivity>(
|
[[NSUserActivity alloc] initWithActivityType:type]);
|
||||||
[[NSUserActivity alloc] initWithActivityType:type]);
|
[currentActivity_ setUserInfo:userInfo];
|
||||||
[currentActivity_ setUserInfo:userInfo];
|
[currentActivity_ setWebpageURL:webpageURL];
|
||||||
[currentActivity_ setWebpageURL:webpageURL];
|
[currentActivity_ setDelegate:self];
|
||||||
[currentActivity_ setDelegate:self];
|
[currentActivity_ becomeCurrent];
|
||||||
[currentActivity_ becomeCurrent];
|
[currentActivity_ setNeedsSave:YES];
|
||||||
[currentActivity_ setNeedsSave:YES];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSUserActivity*)getCurrentActivity {
|
- (NSUserActivity*)getCurrentActivity {
|
||||||
@@ -103,8 +101,7 @@ inline void dispatch_sync_main(dispatch_block_t block) {
|
|||||||
[handoffLock_ unlock];
|
[handoffLock_ unlock];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)userActivityWillSave:(NSUserActivity*)userActivity
|
- (void)userActivityWillSave:(NSUserActivity*)userActivity {
|
||||||
API_AVAILABLE(macosx(10.10)) {
|
|
||||||
__block BOOL shouldWait = NO;
|
__block BOOL shouldWait = NO;
|
||||||
dispatch_sync_main(^{
|
dispatch_sync_main(^{
|
||||||
std::string activity_type(
|
std::string activity_type(
|
||||||
@@ -132,8 +129,7 @@ inline void dispatch_sync_main(dispatch_block_t block) {
|
|||||||
[userActivity setNeedsSave:YES];
|
[userActivity setNeedsSave:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)userActivityWasContinued:(NSUserActivity*)userActivity
|
- (void)userActivityWasContinued:(NSUserActivity*)userActivity {
|
||||||
API_AVAILABLE(macosx(10.10)) {
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
std::string activity_type(
|
std::string activity_type(
|
||||||
base::SysNSStringToUTF8(userActivity.activityType));
|
base::SysNSStringToUTF8(userActivity.activityType));
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
|
|||||||
#else
|
#else
|
||||||
(void (^)(NSArray* restorableObjects))
|
(void (^)(NSArray* restorableObjects))
|
||||||
#endif
|
#endif
|
||||||
restorationHandler API_AVAILABLE(macosx(10.10)) {
|
restorationHandler {
|
||||||
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
|
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
|
||||||
std::unique_ptr<base::DictionaryValue> user_info =
|
std::unique_ptr<base::DictionaryValue> user_info =
|
||||||
atom::NSDictionaryToDictionaryValue(userActivity.userInfo);
|
atom::NSDictionaryToDictionaryValue(userActivity.userInfo);
|
||||||
|
|||||||
@@ -7,18 +7,16 @@
|
|||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "content/public/browser/media_capture_devices.h"
|
#include "content/public/browser/media_capture_devices.h"
|
||||||
#include "content/public/common/media_stream_request.h"
|
|
||||||
|
|
||||||
namespace atom {
|
|
||||||
|
|
||||||
using content::BrowserThread;
|
using content::BrowserThread;
|
||||||
using content::MediaStreamDevices;
|
|
||||||
|
namespace atom {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// Finds a device in |devices| that has |device_id|, or NULL if not found.
|
// Finds a device in |devices| that has |device_id|, or NULL if not found.
|
||||||
const content::MediaStreamDevice* FindDeviceWithId(
|
const blink::MediaStreamDevice* FindDeviceWithId(
|
||||||
const content::MediaStreamDevices& devices,
|
const blink::MediaStreamDevices& devices,
|
||||||
const std::string& device_id) {
|
const std::string& device_id) {
|
||||||
auto iter = devices.begin();
|
auto iter = devices.begin();
|
||||||
for (; iter != devices.end(); ++iter) {
|
for (; iter != devices.end(); ++iter) {
|
||||||
@@ -29,11 +27,6 @@ const content::MediaStreamDevice* FindDeviceWithId(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MediaStreamDevices& EmptyDevices() {
|
|
||||||
static MediaStreamDevices* devices = new MediaStreamDevices;
|
|
||||||
return *devices;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() {
|
MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() {
|
||||||
@@ -49,75 +42,75 @@ MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher()
|
|||||||
|
|
||||||
MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher() {}
|
MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher() {}
|
||||||
|
|
||||||
const MediaStreamDevices&
|
const blink::MediaStreamDevices&
|
||||||
MediaCaptureDevicesDispatcher::GetAudioCaptureDevices() {
|
MediaCaptureDevicesDispatcher::GetAudioCaptureDevices() {
|
||||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||||
if (is_device_enumeration_disabled_)
|
if (is_device_enumeration_disabled_)
|
||||||
return EmptyDevices();
|
return test_audio_devices_;
|
||||||
return content::MediaCaptureDevices::GetInstance()->GetAudioCaptureDevices();
|
return content::MediaCaptureDevices::GetInstance()->GetAudioCaptureDevices();
|
||||||
}
|
}
|
||||||
|
|
||||||
const MediaStreamDevices&
|
const blink::MediaStreamDevices&
|
||||||
MediaCaptureDevicesDispatcher::GetVideoCaptureDevices() {
|
MediaCaptureDevicesDispatcher::GetVideoCaptureDevices() {
|
||||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||||
if (is_device_enumeration_disabled_)
|
if (is_device_enumeration_disabled_)
|
||||||
return EmptyDevices();
|
return test_video_devices_;
|
||||||
return content::MediaCaptureDevices::GetInstance()->GetVideoCaptureDevices();
|
return content::MediaCaptureDevices::GetInstance()->GetVideoCaptureDevices();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaCaptureDevicesDispatcher::GetDefaultDevices(
|
void MediaCaptureDevicesDispatcher::GetDefaultDevices(
|
||||||
bool audio,
|
bool audio,
|
||||||
bool video,
|
bool video,
|
||||||
content::MediaStreamDevices* devices) {
|
blink::MediaStreamDevices* devices) {
|
||||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||||
DCHECK(audio || video);
|
DCHECK(audio || video);
|
||||||
|
|
||||||
if (audio) {
|
if (audio) {
|
||||||
const content::MediaStreamDevice* device = GetFirstAvailableAudioDevice();
|
const blink::MediaStreamDevice* device = GetFirstAvailableAudioDevice();
|
||||||
if (device)
|
if (device)
|
||||||
devices->push_back(*device);
|
devices->push_back(*device);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (video) {
|
if (video) {
|
||||||
const content::MediaStreamDevice* device = GetFirstAvailableVideoDevice();
|
const blink::MediaStreamDevice* device = GetFirstAvailableVideoDevice();
|
||||||
if (device)
|
if (device)
|
||||||
devices->push_back(*device);
|
devices->push_back(*device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const content::MediaStreamDevice*
|
const blink::MediaStreamDevice*
|
||||||
MediaCaptureDevicesDispatcher::GetRequestedAudioDevice(
|
MediaCaptureDevicesDispatcher::GetRequestedAudioDevice(
|
||||||
const std::string& requested_audio_device_id) {
|
const std::string& requested_audio_device_id) {
|
||||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||||
const content::MediaStreamDevices& audio_devices = GetAudioCaptureDevices();
|
const blink::MediaStreamDevices& audio_devices = GetAudioCaptureDevices();
|
||||||
const content::MediaStreamDevice* const device =
|
const blink::MediaStreamDevice* const device =
|
||||||
FindDeviceWithId(audio_devices, requested_audio_device_id);
|
FindDeviceWithId(audio_devices, requested_audio_device_id);
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
const content::MediaStreamDevice*
|
const blink::MediaStreamDevice*
|
||||||
MediaCaptureDevicesDispatcher::GetFirstAvailableAudioDevice() {
|
MediaCaptureDevicesDispatcher::GetFirstAvailableAudioDevice() {
|
||||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||||
const content::MediaStreamDevices& audio_devices = GetAudioCaptureDevices();
|
const blink::MediaStreamDevices& audio_devices = GetAudioCaptureDevices();
|
||||||
if (audio_devices.empty())
|
if (audio_devices.empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return &(*audio_devices.begin());
|
return &(*audio_devices.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
const content::MediaStreamDevice*
|
const blink::MediaStreamDevice*
|
||||||
MediaCaptureDevicesDispatcher::GetRequestedVideoDevice(
|
MediaCaptureDevicesDispatcher::GetRequestedVideoDevice(
|
||||||
const std::string& requested_video_device_id) {
|
const std::string& requested_video_device_id) {
|
||||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||||
const content::MediaStreamDevices& video_devices = GetVideoCaptureDevices();
|
const blink::MediaStreamDevices& video_devices = GetVideoCaptureDevices();
|
||||||
const content::MediaStreamDevice* const device =
|
const blink::MediaStreamDevice* const device =
|
||||||
FindDeviceWithId(video_devices, requested_video_device_id);
|
FindDeviceWithId(video_devices, requested_video_device_id);
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
const content::MediaStreamDevice*
|
const blink::MediaStreamDevice*
|
||||||
MediaCaptureDevicesDispatcher::GetFirstAvailableVideoDevice() {
|
MediaCaptureDevicesDispatcher::GetFirstAvailableVideoDevice() {
|
||||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||||
const content::MediaStreamDevices& video_devices = GetVideoCaptureDevices();
|
const blink::MediaStreamDevices& video_devices = GetVideoCaptureDevices();
|
||||||
if (video_devices.empty())
|
if (video_devices.empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return &(*video_devices.begin());
|
return &(*video_devices.begin());
|
||||||
@@ -136,7 +129,7 @@ void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged(
|
|||||||
int render_view_id,
|
int render_view_id,
|
||||||
int page_request_id,
|
int page_request_id,
|
||||||
const GURL& security_origin,
|
const GURL& security_origin,
|
||||||
content::MediaStreamType stream_type,
|
blink::MediaStreamType stream_type,
|
||||||
content::MediaRequestState state) {}
|
content::MediaRequestState state) {}
|
||||||
|
|
||||||
void MediaCaptureDevicesDispatcher::OnCreatingAudioStream(int render_process_id,
|
void MediaCaptureDevicesDispatcher::OnCreatingAudioStream(int render_process_id,
|
||||||
@@ -146,7 +139,7 @@ void MediaCaptureDevicesDispatcher::OnSetCapturingLinkSecured(
|
|||||||
int render_process_id,
|
int render_process_id,
|
||||||
int render_frame_id,
|
int render_frame_id,
|
||||||
int page_request_id,
|
int page_request_id,
|
||||||
content::MediaStreamType stream_type,
|
blink::MediaStreamType stream_type,
|
||||||
bool is_secure) {}
|
bool is_secure) {}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
|
|
||||||
#include "base/memory/singleton.h"
|
#include "base/memory/singleton.h"
|
||||||
#include "content/public/browser/media_observer.h"
|
#include "content/public/browser/media_observer.h"
|
||||||
#include "content/public/common/media_stream_request.h"
|
#include "content/public/browser/media_stream_request.h"
|
||||||
|
#include "third_party/blink/public/common/mediastream/media_stream_request.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
@@ -20,8 +21,8 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
|
|||||||
static MediaCaptureDevicesDispatcher* GetInstance();
|
static MediaCaptureDevicesDispatcher* GetInstance();
|
||||||
|
|
||||||
// Methods for observers. Called on UI thread.
|
// Methods for observers. Called on UI thread.
|
||||||
const content::MediaStreamDevices& GetAudioCaptureDevices();
|
const blink::MediaStreamDevices& GetAudioCaptureDevices();
|
||||||
const content::MediaStreamDevices& GetVideoCaptureDevices();
|
const blink::MediaStreamDevices& GetVideoCaptureDevices();
|
||||||
|
|
||||||
// Helper to get the default devices which can be used by the media request.
|
// Helper to get the default devices which can be used by the media request.
|
||||||
// Uses the first available devices if the default devices are not available.
|
// Uses the first available devices if the default devices are not available.
|
||||||
@@ -30,19 +31,19 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
|
|||||||
// Called on the UI thread.
|
// Called on the UI thread.
|
||||||
void GetDefaultDevices(bool audio,
|
void GetDefaultDevices(bool audio,
|
||||||
bool video,
|
bool video,
|
||||||
content::MediaStreamDevices* devices);
|
blink::MediaStreamDevices* devices);
|
||||||
|
|
||||||
// Helpers for picking particular requested devices, identified by raw id.
|
// Helpers for picking particular requested devices, identified by raw id.
|
||||||
// If the device requested is not available it will return NULL.
|
// If the device requested is not available it will return NULL.
|
||||||
const content::MediaStreamDevice* GetRequestedAudioDevice(
|
const blink::MediaStreamDevice* GetRequestedAudioDevice(
|
||||||
const std::string& requested_audio_device_id);
|
const std::string& requested_audio_device_id);
|
||||||
const content::MediaStreamDevice* GetRequestedVideoDevice(
|
const blink::MediaStreamDevice* GetRequestedVideoDevice(
|
||||||
const std::string& requested_video_device_id);
|
const std::string& requested_video_device_id);
|
||||||
|
|
||||||
// Returns the first available audio or video device, or NULL if no devices
|
// Returns the first available audio or video device, or NULL if no devices
|
||||||
// are available.
|
// are available.
|
||||||
const content::MediaStreamDevice* GetFirstAvailableAudioDevice();
|
const blink::MediaStreamDevice* GetFirstAvailableAudioDevice();
|
||||||
const content::MediaStreamDevice* GetFirstAvailableVideoDevice();
|
const blink::MediaStreamDevice* GetFirstAvailableVideoDevice();
|
||||||
|
|
||||||
// Unittests that do not require actual device enumeration should call this
|
// Unittests that do not require actual device enumeration should call this
|
||||||
// API on the singleton. It is safe to call this multiple times on the
|
// API on the singleton. It is safe to call this multiple times on the
|
||||||
@@ -56,14 +57,14 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
|
|||||||
int render_view_id,
|
int render_view_id,
|
||||||
int page_request_id,
|
int page_request_id,
|
||||||
const GURL& security_origin,
|
const GURL& security_origin,
|
||||||
content::MediaStreamType stream_type,
|
blink::MediaStreamType stream_type,
|
||||||
content::MediaRequestState state) override;
|
content::MediaRequestState state) override;
|
||||||
void OnCreatingAudioStream(int render_process_id,
|
void OnCreatingAudioStream(int render_process_id,
|
||||||
int render_view_id) override;
|
int render_view_id) override;
|
||||||
void OnSetCapturingLinkSecured(int render_process_id,
|
void OnSetCapturingLinkSecured(int render_process_id,
|
||||||
int render_frame_id,
|
int render_frame_id,
|
||||||
int page_request_id,
|
int page_request_id,
|
||||||
content::MediaStreamType stream_type,
|
blink::MediaStreamType stream_type,
|
||||||
bool is_secure) override;
|
bool is_secure) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -72,6 +73,12 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
|
|||||||
MediaCaptureDevicesDispatcher();
|
MediaCaptureDevicesDispatcher();
|
||||||
~MediaCaptureDevicesDispatcher() override;
|
~MediaCaptureDevicesDispatcher() override;
|
||||||
|
|
||||||
|
// Only for testing, a list of cached audio capture devices.
|
||||||
|
blink::MediaStreamDevices test_audio_devices_;
|
||||||
|
|
||||||
|
// Only for testing, a list of cached video capture devices.
|
||||||
|
blink::MediaStreamDevices test_video_devices_;
|
||||||
|
|
||||||
// Flag used by unittests to disable device enumeration.
|
// Flag used by unittests to disable device enumeration.
|
||||||
bool is_device_enumeration_disabled_;
|
bool is_device_enumeration_disabled_;
|
||||||
|
|
||||||
|
|||||||
@@ -9,16 +9,16 @@
|
|||||||
|
|
||||||
#include "atom/browser/media/media_capture_devices_dispatcher.h"
|
#include "atom/browser/media/media_capture_devices_dispatcher.h"
|
||||||
#include "content/public/browser/desktop_media_id.h"
|
#include "content/public/browser/desktop_media_id.h"
|
||||||
#include "content/public/common/media_stream_request.h"
|
#include "content/public/browser/media_stream_request.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool HasAnyAvailableDevice() {
|
bool HasAnyAvailableDevice() {
|
||||||
const content::MediaStreamDevices& audio_devices =
|
const blink::MediaStreamDevices& audio_devices =
|
||||||
MediaCaptureDevicesDispatcher::GetInstance()->GetAudioCaptureDevices();
|
MediaCaptureDevicesDispatcher::GetInstance()->GetAudioCaptureDevices();
|
||||||
const content::MediaStreamDevices& video_devices =
|
const blink::MediaStreamDevices& video_devices =
|
||||||
MediaCaptureDevicesDispatcher::GetInstance()->GetVideoCaptureDevices();
|
MediaCaptureDevicesDispatcher::GetInstance()->GetVideoCaptureDevices();
|
||||||
|
|
||||||
return !audio_devices.empty() || !video_devices.empty();
|
return !audio_devices.empty() || !video_devices.empty();
|
||||||
@@ -34,33 +34,33 @@ MediaStreamDevicesController::MediaStreamDevicesController(
|
|||||||
// For MEDIA_OPEN_DEVICE requests (Pepper) we always request both webcam
|
// For MEDIA_OPEN_DEVICE requests (Pepper) we always request both webcam
|
||||||
// and microphone to avoid popping two infobars.
|
// and microphone to avoid popping two infobars.
|
||||||
microphone_requested_(
|
microphone_requested_(
|
||||||
request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE ||
|
request.audio_type == blink::MEDIA_DEVICE_AUDIO_CAPTURE ||
|
||||||
request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY),
|
request.request_type == blink::MEDIA_OPEN_DEVICE_PEPPER_ONLY),
|
||||||
webcam_requested_(
|
webcam_requested_(
|
||||||
request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE ||
|
request.video_type == blink::MEDIA_DEVICE_VIDEO_CAPTURE ||
|
||||||
request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY) {}
|
request.request_type == blink::MEDIA_OPEN_DEVICE_PEPPER_ONLY) {}
|
||||||
|
|
||||||
MediaStreamDevicesController::~MediaStreamDevicesController() {
|
MediaStreamDevicesController::~MediaStreamDevicesController() {
|
||||||
if (!callback_.is_null()) {
|
if (!callback_.is_null()) {
|
||||||
std::move(callback_).Run(content::MediaStreamDevices(),
|
std::move(callback_).Run(blink::MediaStreamDevices(),
|
||||||
content::MEDIA_DEVICE_INVALID_STATE,
|
blink::MEDIA_DEVICE_FAILED_DUE_TO_SHUTDOWN,
|
||||||
std::unique_ptr<content::MediaStreamUI>());
|
std::unique_ptr<content::MediaStreamUI>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MediaStreamDevicesController::TakeAction() {
|
bool MediaStreamDevicesController::TakeAction() {
|
||||||
// Do special handling of desktop screen cast.
|
// Do special handling of desktop screen cast.
|
||||||
if (request_.audio_type == content::MEDIA_GUM_TAB_AUDIO_CAPTURE ||
|
if (request_.audio_type == blink::MEDIA_GUM_TAB_AUDIO_CAPTURE ||
|
||||||
request_.video_type == content::MEDIA_GUM_TAB_VIDEO_CAPTURE ||
|
request_.video_type == blink::MEDIA_GUM_TAB_VIDEO_CAPTURE ||
|
||||||
request_.audio_type == content::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE ||
|
request_.audio_type == blink::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE ||
|
||||||
request_.video_type == content::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE) {
|
request_.video_type == blink::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE) {
|
||||||
HandleUserMediaRequest();
|
HandleUserMediaRequest();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deny the request if there is no device attached to the OS.
|
// Deny the request if there is no device attached to the OS.
|
||||||
if (!HasAnyAvailableDevice()) {
|
if (!HasAnyAvailableDevice()) {
|
||||||
Deny(content::MEDIA_DEVICE_NO_HARDWARE);
|
Deny(blink::MEDIA_DEVICE_NO_HARDWARE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,14 +70,14 @@ bool MediaStreamDevicesController::TakeAction() {
|
|||||||
|
|
||||||
void MediaStreamDevicesController::Accept() {
|
void MediaStreamDevicesController::Accept() {
|
||||||
// Get the default devices for the request.
|
// Get the default devices for the request.
|
||||||
content::MediaStreamDevices devices;
|
blink::MediaStreamDevices devices;
|
||||||
if (microphone_requested_ || webcam_requested_) {
|
if (microphone_requested_ || webcam_requested_) {
|
||||||
switch (request_.request_type) {
|
switch (request_.request_type) {
|
||||||
case content::MEDIA_OPEN_DEVICE_PEPPER_ONLY: {
|
case blink::MEDIA_OPEN_DEVICE_PEPPER_ONLY: {
|
||||||
const content::MediaStreamDevice* device = nullptr;
|
const blink::MediaStreamDevice* device = nullptr;
|
||||||
// For open device request pick the desired device or fall back to the
|
// For open device request pick the desired device or fall back to the
|
||||||
// first available of the given type.
|
// first available of the given type.
|
||||||
if (request_.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE) {
|
if (request_.audio_type == blink::MEDIA_DEVICE_AUDIO_CAPTURE) {
|
||||||
device =
|
device =
|
||||||
MediaCaptureDevicesDispatcher::GetInstance()
|
MediaCaptureDevicesDispatcher::GetInstance()
|
||||||
->GetRequestedAudioDevice(request_.requested_audio_device_id);
|
->GetRequestedAudioDevice(request_.requested_audio_device_id);
|
||||||
@@ -86,7 +86,7 @@ void MediaStreamDevicesController::Accept() {
|
|||||||
device = MediaCaptureDevicesDispatcher::GetInstance()
|
device = MediaCaptureDevicesDispatcher::GetInstance()
|
||||||
->GetFirstAvailableAudioDevice();
|
->GetFirstAvailableAudioDevice();
|
||||||
}
|
}
|
||||||
} else if (request_.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE) {
|
} else if (request_.video_type == blink::MEDIA_DEVICE_VIDEO_CAPTURE) {
|
||||||
// Pepper API opens only one device at a time.
|
// Pepper API opens only one device at a time.
|
||||||
device =
|
device =
|
||||||
MediaCaptureDevicesDispatcher::GetInstance()
|
MediaCaptureDevicesDispatcher::GetInstance()
|
||||||
@@ -101,13 +101,13 @@ void MediaStreamDevicesController::Accept() {
|
|||||||
devices.push_back(*device);
|
devices.push_back(*device);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case content::MEDIA_GENERATE_STREAM: {
|
case blink::MEDIA_GENERATE_STREAM: {
|
||||||
bool needs_audio_device = microphone_requested_;
|
bool needs_audio_device = microphone_requested_;
|
||||||
bool needs_video_device = webcam_requested_;
|
bool needs_video_device = webcam_requested_;
|
||||||
|
|
||||||
// Get the exact audio or video device if an id is specified.
|
// Get the exact audio or video device if an id is specified.
|
||||||
if (!request_.requested_audio_device_id.empty()) {
|
if (!request_.requested_audio_device_id.empty()) {
|
||||||
const content::MediaStreamDevice* audio_device =
|
const blink::MediaStreamDevice* audio_device =
|
||||||
MediaCaptureDevicesDispatcher::GetInstance()
|
MediaCaptureDevicesDispatcher::GetInstance()
|
||||||
->GetRequestedAudioDevice(request_.requested_audio_device_id);
|
->GetRequestedAudioDevice(request_.requested_audio_device_id);
|
||||||
if (audio_device) {
|
if (audio_device) {
|
||||||
@@ -116,7 +116,7 @@ void MediaStreamDevicesController::Accept() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!request_.requested_video_device_id.empty()) {
|
if (!request_.requested_video_device_id.empty()) {
|
||||||
const content::MediaStreamDevice* video_device =
|
const blink::MediaStreamDevice* video_device =
|
||||||
MediaCaptureDevicesDispatcher::GetInstance()
|
MediaCaptureDevicesDispatcher::GetInstance()
|
||||||
->GetRequestedVideoDevice(request_.requested_video_device_id);
|
->GetRequestedVideoDevice(request_.requested_video_device_id);
|
||||||
if (video_device) {
|
if (video_device) {
|
||||||
@@ -133,40 +133,45 @@ void MediaStreamDevicesController::Accept() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case content::MEDIA_DEVICE_ACCESS:
|
case blink::MEDIA_DEVICE_ACCESS: {
|
||||||
// Get the default devices for the request.
|
// Get the default devices for the request.
|
||||||
MediaCaptureDevicesDispatcher::GetInstance()->GetDefaultDevices(
|
MediaCaptureDevicesDispatcher::GetInstance()->GetDefaultDevices(
|
||||||
microphone_requested_, webcam_requested_, &devices);
|
microphone_requested_, webcam_requested_, &devices);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case blink::MEDIA_DEVICE_UPDATE: {
|
||||||
|
NOTREACHED();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::move(callback_).Run(devices, content::MEDIA_DEVICE_OK,
|
std::move(callback_).Run(devices, blink::MEDIA_DEVICE_OK,
|
||||||
std::unique_ptr<content::MediaStreamUI>());
|
std::unique_ptr<content::MediaStreamUI>());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaStreamDevicesController::Deny(
|
void MediaStreamDevicesController::Deny(
|
||||||
content::MediaStreamRequestResult result) {
|
blink::MediaStreamRequestResult result) {
|
||||||
std::move(callback_).Run(content::MediaStreamDevices(), result,
|
std::move(callback_).Run(blink::MediaStreamDevices(), result,
|
||||||
std::unique_ptr<content::MediaStreamUI>());
|
std::unique_ptr<content::MediaStreamUI>());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaStreamDevicesController::HandleUserMediaRequest() {
|
void MediaStreamDevicesController::HandleUserMediaRequest() {
|
||||||
content::MediaStreamDevices devices;
|
blink::MediaStreamDevices devices;
|
||||||
|
|
||||||
if (request_.audio_type == content::MEDIA_GUM_TAB_AUDIO_CAPTURE) {
|
if (request_.audio_type == blink::MEDIA_GUM_TAB_AUDIO_CAPTURE) {
|
||||||
devices.push_back(content::MediaStreamDevice(
|
devices.push_back(
|
||||||
content::MEDIA_GUM_TAB_AUDIO_CAPTURE, "", ""));
|
blink::MediaStreamDevice(blink::MEDIA_GUM_TAB_AUDIO_CAPTURE, "", ""));
|
||||||
}
|
}
|
||||||
if (request_.video_type == content::MEDIA_GUM_TAB_VIDEO_CAPTURE) {
|
if (request_.video_type == blink::MEDIA_GUM_TAB_VIDEO_CAPTURE) {
|
||||||
devices.push_back(content::MediaStreamDevice(
|
devices.push_back(
|
||||||
content::MEDIA_GUM_TAB_VIDEO_CAPTURE, "", ""));
|
blink::MediaStreamDevice(blink::MEDIA_GUM_TAB_VIDEO_CAPTURE, "", ""));
|
||||||
}
|
}
|
||||||
if (request_.audio_type == content::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE) {
|
if (request_.audio_type == blink::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE) {
|
||||||
devices.push_back(content::MediaStreamDevice(
|
devices.push_back(blink::MediaStreamDevice(
|
||||||
content::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE, "loopback", "System Audio"));
|
blink::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE, "loopback", "System Audio"));
|
||||||
}
|
}
|
||||||
if (request_.video_type == content::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE) {
|
if (request_.video_type == blink::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE) {
|
||||||
content::DesktopMediaID screen_id;
|
content::DesktopMediaID screen_id;
|
||||||
// If the device id wasn't specified then this is a screen capture request
|
// If the device id wasn't specified then this is a screen capture request
|
||||||
// (i.e. chooseDesktopMedia() API wasn't used to generate device id).
|
// (i.e. chooseDesktopMedia() API wasn't used to generate device id).
|
||||||
@@ -179,13 +184,13 @@ void MediaStreamDevicesController::HandleUserMediaRequest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
devices.push_back(
|
devices.push_back(
|
||||||
content::MediaStreamDevice(content::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE,
|
blink::MediaStreamDevice(blink::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE,
|
||||||
screen_id.ToString(), "Screen"));
|
screen_id.ToString(), "Screen"));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::move(callback_).Run(devices,
|
std::move(callback_).Run(devices,
|
||||||
devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE
|
devices.empty() ? blink::MEDIA_DEVICE_NO_HARDWARE
|
||||||
: content::MEDIA_DEVICE_OK,
|
: blink::MEDIA_DEVICE_OK,
|
||||||
std::unique_ptr<content::MediaStreamUI>());
|
std::unique_ptr<content::MediaStreamUI>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#define ATOM_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_
|
#define ATOM_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_
|
||||||
|
|
||||||
#include "content/public/browser/web_contents_delegate.h"
|
#include "content/public/browser/web_contents_delegate.h"
|
||||||
|
#include "third_party/blink/public/common/mediastream/media_stream_request.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
@@ -21,7 +22,7 @@ class MediaStreamDevicesController {
|
|||||||
|
|
||||||
// Explicitly accept or deny the request.
|
// Explicitly accept or deny the request.
|
||||||
void Accept();
|
void Accept();
|
||||||
void Deny(content::MediaStreamRequestResult result);
|
void Deny(blink::MediaStreamRequestResult result);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Handle the request of desktop or tab screen cast.
|
// Handle the request of desktop or tab screen cast.
|
||||||
|
|||||||
@@ -574,18 +574,15 @@ const views::Widget* NativeWindow::GetWidget() const {
|
|||||||
return widget();
|
return widget();
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
|
||||||
const void* const NativeWindowRelay::kNativeWindowRelayUserDataKey =
|
|
||||||
&NativeWindowRelay::kNativeWindowRelayUserDataKey;
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void NativeWindowRelay::CreateForWebContents(
|
void NativeWindowRelay::CreateForWebContents(
|
||||||
content::WebContents* web_contents,
|
content::WebContents* web_contents,
|
||||||
base::WeakPtr<NativeWindow> window) {
|
base::WeakPtr<NativeWindow> window) {
|
||||||
DCHECK(web_contents);
|
DCHECK(web_contents);
|
||||||
DCHECK(!web_contents->GetUserData(kNativeWindowRelayUserDataKey));
|
if (!web_contents->GetUserData(UserDataKey())) {
|
||||||
web_contents->SetUserData(kNativeWindowRelayUserDataKey,
|
web_contents->SetUserData(UserDataKey(),
|
||||||
base::WrapUnique(new NativeWindowRelay(window)));
|
base::WrapUnique(new NativeWindowRelay(window)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeWindowRelay::NativeWindowRelay(base::WeakPtr<NativeWindow> window)
|
NativeWindowRelay::NativeWindowRelay(base::WeakPtr<NativeWindow> window)
|
||||||
@@ -593,4 +590,6 @@ NativeWindowRelay::NativeWindowRelay(base::WeakPtr<NativeWindow> window)
|
|||||||
|
|
||||||
NativeWindowRelay::~NativeWindowRelay() = default;
|
NativeWindowRelay::~NativeWindowRelay() = default;
|
||||||
|
|
||||||
|
WEB_CONTENTS_USER_DATA_KEY_IMPL(NativeWindowRelay)
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|||||||
@@ -362,8 +362,6 @@ class NativeWindow : public base::SupportsUserData,
|
|||||||
class NativeWindowRelay
|
class NativeWindowRelay
|
||||||
: public content::WebContentsUserData<NativeWindowRelay> {
|
: public content::WebContentsUserData<NativeWindowRelay> {
|
||||||
public:
|
public:
|
||||||
static const void* const kNativeWindowRelayUserDataKey;
|
|
||||||
|
|
||||||
static void CreateForWebContents(content::WebContents*,
|
static void CreateForWebContents(content::WebContents*,
|
||||||
base::WeakPtr<NativeWindow>);
|
base::WeakPtr<NativeWindow>);
|
||||||
|
|
||||||
@@ -371,6 +369,8 @@ class NativeWindowRelay
|
|||||||
|
|
||||||
NativeWindow* GetNativeWindow() const { return native_window_.get(); }
|
NativeWindow* GetNativeWindow() const { return native_window_.get(); }
|
||||||
|
|
||||||
|
WEB_CONTENTS_USER_DATA_KEY_DECL();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class content::WebContentsUserData<NativeWindow>;
|
friend class content::WebContentsUserData<NativeWindow>;
|
||||||
explicit NativeWindowRelay(base::WeakPtr<NativeWindow> window);
|
explicit NativeWindowRelay(base::WeakPtr<NativeWindow> window);
|
||||||
|
|||||||
@@ -165,11 +165,9 @@ class NativeWindowMac : public NativeWindow {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// Add custom layers to the content view.
|
// Add custom layers to the content view.
|
||||||
void AddContentViewLayers();
|
void AddContentViewLayers(bool minimizable, bool closable);
|
||||||
|
|
||||||
void InternalSetParentWindow(NativeWindow* parent, bool attach);
|
void InternalSetParentWindow(NativeWindow* parent, bool attach);
|
||||||
void ShowWindowButton(NSWindowButton button);
|
|
||||||
|
|
||||||
void SetForwardMouseMessages(bool forward);
|
void SetForwardMouseMessages(bool forward);
|
||||||
|
|
||||||
AtomNSWindow* window_; // Weak ref, managed by widget_.
|
AtomNSWindow* window_; // Weak ref, managed by widget_.
|
||||||
|
|||||||
@@ -73,9 +73,11 @@
|
|||||||
NSButton* close_button =
|
NSButton* close_button =
|
||||||
[NSWindow standardWindowButton:NSWindowCloseButton
|
[NSWindow standardWindowButton:NSWindowCloseButton
|
||||||
forStyleMask:NSWindowStyleMaskTitled];
|
forStyleMask:NSWindowStyleMaskTitled];
|
||||||
|
[close_button setTag:1];
|
||||||
NSButton* miniaturize_button =
|
NSButton* miniaturize_button =
|
||||||
[NSWindow standardWindowButton:NSWindowMiniaturizeButton
|
[NSWindow standardWindowButton:NSWindowMiniaturizeButton
|
||||||
forStyleMask:NSWindowStyleMaskTitled];
|
forStyleMask:NSWindowStyleMaskTitled];
|
||||||
|
[miniaturize_button setTag:2];
|
||||||
|
|
||||||
CGFloat x = 0;
|
CGFloat x = 0;
|
||||||
const CGFloat space_between = 20;
|
const CGFloat space_between = 20;
|
||||||
@@ -233,7 +235,10 @@ namespace atom {
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool IsFramelessWindow(NSView* view) {
|
bool IsFramelessWindow(NSView* view) {
|
||||||
NativeWindow* window = [static_cast<AtomNSWindow*>([view window]) shell];
|
NSWindow* nswindow = [view window];
|
||||||
|
if (![nswindow respondsToSelector:@selector(shell)])
|
||||||
|
return false;
|
||||||
|
NativeWindow* window = [static_cast<AtomNSWindow*>(nswindow) shell];
|
||||||
return window && !window->has_frame();
|
return window && !window->has_frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,11 +320,9 @@ NativeWindowMac::NativeWindowMac(const mate::Dictionary& options,
|
|||||||
}
|
}
|
||||||
|
|
||||||
NSUInteger styleMask = NSWindowStyleMaskTitled;
|
NSUInteger styleMask = NSWindowStyleMaskTitled;
|
||||||
if (@available(macOS 10.10, *)) {
|
if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER &&
|
||||||
if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER &&
|
(!useStandardWindow || transparent() || !has_frame())) {
|
||||||
(!useStandardWindow || transparent() || !has_frame())) {
|
styleMask = NSWindowStyleMaskFullSizeContentView;
|
||||||
styleMask = NSWindowStyleMaskFullSizeContentView;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (minimizable) {
|
if (minimizable) {
|
||||||
styleMask |= NSMiniaturizableWindowMask;
|
styleMask |= NSMiniaturizableWindowMask;
|
||||||
@@ -378,11 +381,9 @@ NativeWindowMac::NativeWindowMac(const mate::Dictionary& options,
|
|||||||
[window_ setDisableKeyOrMainWindow:YES];
|
[window_ setDisableKeyOrMainWindow:YES];
|
||||||
|
|
||||||
if (transparent() || !has_frame()) {
|
if (transparent() || !has_frame()) {
|
||||||
if (@available(macOS 10.10, *)) {
|
// Don't show title bar.
|
||||||
// Don't show title bar.
|
[window_ setTitlebarAppearsTransparent:YES];
|
||||||
[window_ setTitlebarAppearsTransparent:YES];
|
[window_ setTitleVisibility:NSWindowTitleHidden];
|
||||||
[window_ setTitleVisibility:NSWindowTitleHidden];
|
|
||||||
}
|
|
||||||
// Remove non-transparent corners, see http://git.io/vfonD.
|
// Remove non-transparent corners, see http://git.io/vfonD.
|
||||||
[window_ setOpaque:NO];
|
[window_ setOpaque:NO];
|
||||||
}
|
}
|
||||||
@@ -401,22 +402,15 @@ NativeWindowMac::NativeWindowMac(const mate::Dictionary& options,
|
|||||||
|
|
||||||
// Hide the title bar background
|
// Hide the title bar background
|
||||||
if (title_bar_style_ != NORMAL) {
|
if (title_bar_style_ != NORMAL) {
|
||||||
if (@available(macOS 10.10, *)) {
|
[window_ setTitlebarAppearsTransparent:YES];
|
||||||
[window_ setTitlebarAppearsTransparent:YES];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide the title bar.
|
// Hide the title bar.
|
||||||
if (title_bar_style_ == HIDDEN_INSET) {
|
if (title_bar_style_ == HIDDEN_INSET) {
|
||||||
if (@available(macOS 10.10, *)) {
|
base::scoped_nsobject<NSToolbar> toolbar(
|
||||||
base::scoped_nsobject<NSToolbar> toolbar(
|
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
|
||||||
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
|
[toolbar setShowsBaselineSeparator:NO];
|
||||||
[toolbar setShowsBaselineSeparator:NO];
|
[window_ setToolbar:toolbar];
|
||||||
[window_ setToolbar:toolbar];
|
|
||||||
} else {
|
|
||||||
[window_ enableWindowButtonsOffset];
|
|
||||||
[window_ setWindowButtonsOffset:NSMakePoint(12, 10)];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resize to content bounds.
|
// Resize to content bounds.
|
||||||
@@ -467,7 +461,7 @@ NativeWindowMac::NativeWindowMac(const mate::Dictionary& options,
|
|||||||
|
|
||||||
// Default content view.
|
// Default content view.
|
||||||
SetContentView(new views::View());
|
SetContentView(new views::View());
|
||||||
AddContentViewLayers();
|
AddContentViewLayers(minimizable, closable);
|
||||||
|
|
||||||
original_frame_ = [window_ frame];
|
original_frame_ = [window_ frame];
|
||||||
original_level_ = [window_ level];
|
original_level_ = [window_ level];
|
||||||
@@ -587,7 +581,12 @@ void NativeWindowMac::Hide() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool NativeWindowMac::IsVisible() {
|
bool NativeWindowMac::IsVisible() {
|
||||||
return [window_ isVisible];
|
bool occluded = [window_ occlusionState] == NSWindowOcclusionStateVisible;
|
||||||
|
|
||||||
|
// For a window to be visible, it must be visible to the user in the
|
||||||
|
// foreground of the app, which means that it should not be minimized or
|
||||||
|
// occluded
|
||||||
|
return [window_ isVisible] && !occluded && !IsMinimized();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NativeWindowMac::IsEnabled() {
|
bool NativeWindowMac::IsEnabled() {
|
||||||
@@ -854,9 +853,9 @@ void NativeWindowMac::SetAlwaysOnTop(bool top,
|
|||||||
if (newLevel >= minWindowLevel && newLevel <= maxWindowLevel) {
|
if (newLevel >= minWindowLevel && newLevel <= maxWindowLevel) {
|
||||||
[window_ setLevel:newLevel];
|
[window_ setLevel:newLevel];
|
||||||
} else {
|
} else {
|
||||||
*error = std::string([
|
*error = std::string([[NSString
|
||||||
[NSString stringWithFormat:@"relativeLevel must be between %d and %d",
|
stringWithFormat:@"relativeLevel must be between %d and %d",
|
||||||
minWindowLevel, maxWindowLevel] UTF8String]);
|
minWindowLevel, maxWindowLevel] UTF8String]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -874,17 +873,11 @@ void NativeWindowMac::Invalidate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SetTitle(const std::string& title) {
|
void NativeWindowMac::SetTitle(const std::string& title) {
|
||||||
// For macOS <= 10.9, the setTitleVisibility API is not available, we have
|
|
||||||
// to avoid calling setTitle for frameless window.
|
|
||||||
if (!base::mac::IsAtLeastOS10_10() && (transparent() || !has_frame()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
[window_ setTitle:base::SysUTF8ToNSString(title)];
|
[window_ setTitle:base::SysUTF8ToNSString(title)];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string NativeWindowMac::GetTitle() {
|
std::string NativeWindowMac::GetTitle() {
|
||||||
return base::SysNSStringToUTF8([window_ title]);
|
return base::SysNSStringToUTF8([window_ title]);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::FlashFrame(bool flash) {
|
void NativeWindowMac::FlashFrame(bool flash) {
|
||||||
@@ -1101,7 +1094,7 @@ void NativeWindowMac::RemoveBrowserView(NativeBrowserView* view) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[view->GetInspectableWebContentsView()->GetNativeView().GetNativeNSView()
|
[view->GetInspectableWebContentsView()->GetNativeView().GetNativeNSView()
|
||||||
removeFromSuperview];
|
removeFromSuperview];
|
||||||
remove_browser_view(view);
|
remove_browser_view(view);
|
||||||
|
|
||||||
[CATransaction commit];
|
[CATransaction commit];
|
||||||
@@ -1131,17 +1124,23 @@ void NativeWindowMac::SetProgressBar(double progress,
|
|||||||
const NativeWindow::ProgressState state) {
|
const NativeWindow::ProgressState state) {
|
||||||
NSDockTile* dock_tile = [NSApp dockTile];
|
NSDockTile* dock_tile = [NSApp dockTile];
|
||||||
|
|
||||||
|
// Sometimes macOS would install a default contentView for dock, we must
|
||||||
|
// verify whether NSProgressIndicator has been installed.
|
||||||
|
bool first_time = !dock_tile.contentView ||
|
||||||
|
[[dock_tile.contentView subviews] count] == 0 ||
|
||||||
|
![[[dock_tile.contentView subviews] lastObject]
|
||||||
|
isKindOfClass:[NSProgressIndicator class]];
|
||||||
|
|
||||||
// For the first time API invoked, we need to create a ContentView in
|
// For the first time API invoked, we need to create a ContentView in
|
||||||
// DockTile.
|
// DockTile.
|
||||||
if (dock_tile.contentView == nullptr) {
|
if (first_time) {
|
||||||
NSImageView* image_view = [[NSImageView alloc] init];
|
NSImageView* image_view = [[[NSImageView alloc] init] autorelease];
|
||||||
[image_view setImage:[NSApp applicationIconImage]];
|
[image_view setImage:[NSApp applicationIconImage]];
|
||||||
[dock_tile setContentView:image_view];
|
[dock_tile setContentView:image_view];
|
||||||
}
|
|
||||||
|
|
||||||
if ([[dock_tile.contentView subviews] count] == 0) {
|
NSRect frame = NSMakeRect(0.0f, 0.0f, dock_tile.size.width, 15.0);
|
||||||
NSProgressIndicator* progress_indicator = [[AtomProgressBar alloc]
|
NSProgressIndicator* progress_indicator =
|
||||||
initWithFrame:NSMakeRect(0.0f, 0.0f, dock_tile.size.width, 15.0)];
|
[[[AtomProgressBar alloc] initWithFrame:frame] autorelease];
|
||||||
[progress_indicator setStyle:NSProgressIndicatorBarStyle];
|
[progress_indicator setStyle:NSProgressIndicatorBarStyle];
|
||||||
[progress_indicator setIndeterminate:NO];
|
[progress_indicator setIndeterminate:NO];
|
||||||
[progress_indicator setBezeled:YES];
|
[progress_indicator setBezeled:YES];
|
||||||
@@ -1152,7 +1151,7 @@ void NativeWindowMac::SetProgressBar(double progress,
|
|||||||
}
|
}
|
||||||
|
|
||||||
NSProgressIndicator* progress_indicator = static_cast<NSProgressIndicator*>(
|
NSProgressIndicator* progress_indicator = static_cast<NSProgressIndicator*>(
|
||||||
[[[dock_tile contentView] subviews] objectAtIndex:0]);
|
[[[dock_tile contentView] subviews] lastObject]);
|
||||||
if (progress < 0) {
|
if (progress < 0) {
|
||||||
[progress_indicator setHidden:YES];
|
[progress_indicator setHidden:YES];
|
||||||
} else if (progress > 1) {
|
} else if (progress > 1) {
|
||||||
@@ -1240,84 +1239,81 @@ bool NativeWindowMac::SetWindowButtonVisibility(bool visible) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SetVibrancy(const std::string& type) {
|
void NativeWindowMac::SetVibrancy(const std::string& type) {
|
||||||
if (@available(macOS 10.10, *)) {
|
NSView* vibrant_view = [window_ vibrantView];
|
||||||
NSView* vibrant_view = [window_ vibrantView];
|
|
||||||
|
|
||||||
if (type.empty()) {
|
|
||||||
if (background_color_before_vibrancy_) {
|
|
||||||
[window_ setBackgroundColor:background_color_before_vibrancy_];
|
|
||||||
[window_ setTitlebarAppearsTransparent:transparency_before_vibrancy_];
|
|
||||||
}
|
|
||||||
if (vibrant_view == nil)
|
|
||||||
return;
|
|
||||||
|
|
||||||
[vibrant_view removeFromSuperview];
|
|
||||||
[window_ setVibrantView:nil];
|
|
||||||
|
|
||||||
|
if (type.empty()) {
|
||||||
|
if (background_color_before_vibrancy_) {
|
||||||
|
[window_ setBackgroundColor:background_color_before_vibrancy_];
|
||||||
|
[window_ setTitlebarAppearsTransparent:transparency_before_vibrancy_];
|
||||||
|
}
|
||||||
|
if (vibrant_view == nil)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
background_color_before_vibrancy_.reset([[window_ backgroundColor] retain]);
|
[vibrant_view removeFromSuperview];
|
||||||
transparency_before_vibrancy_ = [window_ titlebarAppearsTransparent];
|
[window_ setVibrantView:nil];
|
||||||
|
|
||||||
if (title_bar_style_ != NORMAL) {
|
return;
|
||||||
[window_ setTitlebarAppearsTransparent:YES];
|
|
||||||
[window_ setBackgroundColor:[NSColor clearColor]];
|
|
||||||
}
|
|
||||||
|
|
||||||
NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view;
|
|
||||||
if (effect_view == nil) {
|
|
||||||
effect_view = [[[NSVisualEffectView alloc]
|
|
||||||
initWithFrame:[[window_ contentView] bounds]] autorelease];
|
|
||||||
[window_ setVibrantView:(NSView*)effect_view];
|
|
||||||
|
|
||||||
[effect_view
|
|
||||||
setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
|
||||||
[effect_view setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
|
|
||||||
[effect_view setState:NSVisualEffectStateActive];
|
|
||||||
[[window_ contentView] addSubview:effect_view
|
|
||||||
positioned:NSWindowBelow
|
|
||||||
relativeTo:nil];
|
|
||||||
}
|
|
||||||
|
|
||||||
NSVisualEffectMaterial vibrancyType = NSVisualEffectMaterialLight;
|
|
||||||
|
|
||||||
if (type == "appearance-based") {
|
|
||||||
vibrancyType = NSVisualEffectMaterialAppearanceBased;
|
|
||||||
} else if (type == "light") {
|
|
||||||
vibrancyType = NSVisualEffectMaterialLight;
|
|
||||||
} else if (type == "dark") {
|
|
||||||
vibrancyType = NSVisualEffectMaterialDark;
|
|
||||||
} else if (type == "titlebar") {
|
|
||||||
vibrancyType = NSVisualEffectMaterialTitlebar;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (@available(macOS 10.11, *)) {
|
|
||||||
// TODO(kevinsawicki): Use NSVisualEffectMaterial* constants directly once
|
|
||||||
// they are available in the minimum SDK version
|
|
||||||
if (type == "selection") {
|
|
||||||
// NSVisualEffectMaterialSelection
|
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(4);
|
|
||||||
} else if (type == "menu") {
|
|
||||||
// NSVisualEffectMaterialMenu
|
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(5);
|
|
||||||
} else if (type == "popover") {
|
|
||||||
// NSVisualEffectMaterialPopover
|
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(6);
|
|
||||||
} else if (type == "sidebar") {
|
|
||||||
// NSVisualEffectMaterialSidebar
|
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(7);
|
|
||||||
} else if (type == "medium-light") {
|
|
||||||
// NSVisualEffectMaterialMediumLight
|
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(8);
|
|
||||||
} else if (type == "ultra-dark") {
|
|
||||||
// NSVisualEffectMaterialUltraDark
|
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(9);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[effect_view setMaterial:vibrancyType];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
background_color_before_vibrancy_.reset([[window_ backgroundColor] retain]);
|
||||||
|
transparency_before_vibrancy_ = [window_ titlebarAppearsTransparent];
|
||||||
|
|
||||||
|
if (title_bar_style_ != NORMAL) {
|
||||||
|
[window_ setTitlebarAppearsTransparent:YES];
|
||||||
|
[window_ setBackgroundColor:[NSColor clearColor]];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view;
|
||||||
|
if (effect_view == nil) {
|
||||||
|
effect_view = [[[NSVisualEffectView alloc]
|
||||||
|
initWithFrame:[[window_ contentView] bounds]] autorelease];
|
||||||
|
[window_ setVibrantView:(NSView*)effect_view];
|
||||||
|
|
||||||
|
[effect_view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||||
|
[effect_view setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
|
||||||
|
[effect_view setState:NSVisualEffectStateActive];
|
||||||
|
[[window_ contentView] addSubview:effect_view
|
||||||
|
positioned:NSWindowBelow
|
||||||
|
relativeTo:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSVisualEffectMaterial vibrancyType = NSVisualEffectMaterialLight;
|
||||||
|
|
||||||
|
if (type == "appearance-based") {
|
||||||
|
vibrancyType = NSVisualEffectMaterialAppearanceBased;
|
||||||
|
} else if (type == "light") {
|
||||||
|
vibrancyType = NSVisualEffectMaterialLight;
|
||||||
|
} else if (type == "dark") {
|
||||||
|
vibrancyType = NSVisualEffectMaterialDark;
|
||||||
|
} else if (type == "titlebar") {
|
||||||
|
vibrancyType = NSVisualEffectMaterialTitlebar;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (@available(macOS 10.11, *)) {
|
||||||
|
// TODO(kevinsawicki): Use NSVisualEffectMaterial* constants directly once
|
||||||
|
// they are available in the minimum SDK version
|
||||||
|
if (type == "selection") {
|
||||||
|
// NSVisualEffectMaterialSelection
|
||||||
|
vibrancyType = static_cast<NSVisualEffectMaterial>(4);
|
||||||
|
} else if (type == "menu") {
|
||||||
|
// NSVisualEffectMaterialMenu
|
||||||
|
vibrancyType = static_cast<NSVisualEffectMaterial>(5);
|
||||||
|
} else if (type == "popover") {
|
||||||
|
// NSVisualEffectMaterialPopover
|
||||||
|
vibrancyType = static_cast<NSVisualEffectMaterial>(6);
|
||||||
|
} else if (type == "sidebar") {
|
||||||
|
// NSVisualEffectMaterialSidebar
|
||||||
|
vibrancyType = static_cast<NSVisualEffectMaterial>(7);
|
||||||
|
} else if (type == "medium-light") {
|
||||||
|
// NSVisualEffectMaterialMediumLight
|
||||||
|
vibrancyType = static_cast<NSVisualEffectMaterial>(8);
|
||||||
|
} else if (type == "ultra-dark") {
|
||||||
|
// NSVisualEffectMaterialUltraDark
|
||||||
|
vibrancyType = static_cast<NSVisualEffectMaterial>(9);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[effect_view setMaterial:vibrancyType];
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SetTouchBar(
|
void NativeWindowMac::SetTouchBar(
|
||||||
@@ -1380,7 +1376,7 @@ views::View* NativeWindowMac::GetContentsView() {
|
|||||||
return root_view_.get();
|
return root_view_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::AddContentViewLayers() {
|
void NativeWindowMac::AddContentViewLayers(bool minimizable, bool closable) {
|
||||||
// Make sure the bottom corner is rounded for non-modal windows:
|
// Make sure the bottom corner is rounded for non-modal windows:
|
||||||
// http://crbug.com/396264.
|
// http://crbug.com/396264.
|
||||||
if (!is_modal()) {
|
if (!is_modal()) {
|
||||||
@@ -1420,6 +1416,12 @@ void NativeWindowMac::AddContentViewLayers() {
|
|||||||
[[CustomWindowButtonView alloc] initWithFrame:NSZeroRect]);
|
[[CustomWindowButtonView alloc] initWithFrame:NSZeroRect]);
|
||||||
// NSWindowStyleMaskFullSizeContentView does not work with zoom button
|
// NSWindowStyleMaskFullSizeContentView does not work with zoom button
|
||||||
SetFullScreenable(false);
|
SetFullScreenable(false);
|
||||||
|
|
||||||
|
if (!minimizable)
|
||||||
|
[[buttons_view_ viewWithTag:2] removeFromSuperview];
|
||||||
|
if (!closable)
|
||||||
|
[[buttons_view_ viewWithTag:1] removeFromSuperview];
|
||||||
|
|
||||||
[[window_ contentView] addSubview:buttons_view_];
|
[[window_ contentView] addSubview:buttons_view_];
|
||||||
} else {
|
} else {
|
||||||
if (title_bar_style_ != NORMAL)
|
if (title_bar_style_ != NORMAL)
|
||||||
@@ -1462,11 +1464,6 @@ void NativeWindowMac::InternalSetParentWindow(NativeWindow* parent,
|
|||||||
ordered:NSWindowAbove];
|
ordered:NSWindowAbove];
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::ShowWindowButton(NSWindowButton button) {
|
|
||||||
auto view = [window_ standardWindowButton:button];
|
|
||||||
[view.superview addSubview:view positioned:NSWindowAbove relativeTo:nil];
|
|
||||||
}
|
|
||||||
|
|
||||||
void NativeWindowMac::SetForwardMouseMessages(bool forward) {
|
void NativeWindowMac::SetForwardMouseMessages(bool forward) {
|
||||||
[window_ setAcceptsMouseMovedEvents:forward];
|
[window_ setAcceptsMouseMovedEvents:forward];
|
||||||
}
|
}
|
||||||
@@ -1481,7 +1478,7 @@ void NativeWindowMac::OverrideNSWindowContentView() {
|
|||||||
setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||||
[container_view_ setFrame:[[[window_ contentView] superview] bounds]];
|
[container_view_ setFrame:[[[window_ contentView] superview] bounds]];
|
||||||
[window_ setContentView:container_view_];
|
[window_ setContentView:container_view_];
|
||||||
AddContentViewLayers();
|
AddContentViewLayers(IsMinimizable(), IsClosable());
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SetStyleMask(bool on, NSUInteger flag) {
|
void NativeWindowMac::SetStyleMask(bool on, NSUInteger flag) {
|
||||||
|
|||||||
@@ -358,6 +358,9 @@ void NativeWindowViews::Show() {
|
|||||||
|
|
||||||
widget()->native_widget_private()->Show(GetRestoredState(), gfx::Rect());
|
widget()->native_widget_private()->Show(GetRestoredState(), gfx::Rect());
|
||||||
|
|
||||||
|
// explicitly focus the window
|
||||||
|
widget()->Activate();
|
||||||
|
|
||||||
NotifyWindowShow();
|
NotifyWindowShow();
|
||||||
|
|
||||||
#if defined(USE_X11)
|
#if defined(USE_X11)
|
||||||
|
|||||||
@@ -267,8 +267,8 @@ void AtomURLRequest::DoCancel() {
|
|||||||
void AtomURLRequest::DoFollowRedirect() {
|
void AtomURLRequest::DoFollowRedirect() {
|
||||||
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
||||||
if (request_ && request_->is_redirecting() && redirect_policy_ == "manual") {
|
if (request_ && request_->is_redirecting() && redirect_policy_ == "manual") {
|
||||||
request_->FollowDeferredRedirect(
|
request_->FollowDeferredRedirect(base::nullopt /* removed_headers */,
|
||||||
base::nullopt /* modified_request_headers */);
|
base::nullopt /* modified_headers */);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ void ResolveProxyHelper::StartPendingRequest() {
|
|||||||
binding_.Bind(mojo::MakeRequest(&proxy_lookup_client));
|
binding_.Bind(mojo::MakeRequest(&proxy_lookup_client));
|
||||||
binding_.set_connection_error_handler(
|
binding_.set_connection_error_handler(
|
||||||
base::BindOnce(&ResolveProxyHelper::OnProxyLookupComplete,
|
base::BindOnce(&ResolveProxyHelper::OnProxyLookupComplete,
|
||||||
base::Unretained(this), base::nullopt));
|
base::Unretained(this), net::ERR_ABORTED, base::nullopt));
|
||||||
content::BrowserContext::GetDefaultStoragePartition(browser_context_)
|
content::BrowserContext::GetDefaultStoragePartition(browser_context_)
|
||||||
->GetNetworkContext()
|
->GetNetworkContext()
|
||||||
->LookUpProxyForURL(pending_requests_.front().url,
|
->LookUpProxyForURL(pending_requests_.front().url,
|
||||||
@@ -60,6 +60,7 @@ void ResolveProxyHelper::StartPendingRequest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ResolveProxyHelper::OnProxyLookupComplete(
|
void ResolveProxyHelper::OnProxyLookupComplete(
|
||||||
|
int32_t net_error,
|
||||||
const base::Optional<net::ProxyInfo>& proxy_info) {
|
const base::Optional<net::ProxyInfo>& proxy_info) {
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||||
DCHECK(!pending_requests_.empty());
|
DCHECK(!pending_requests_.empty());
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class ResolveProxyHelper
|
|||||||
|
|
||||||
// network::mojom::ProxyLookupClient implementation.
|
// network::mojom::ProxyLookupClient implementation.
|
||||||
void OnProxyLookupComplete(
|
void OnProxyLookupComplete(
|
||||||
|
int32_t net_error,
|
||||||
const base::Optional<net::ProxyInfo>& proxy_info) override;
|
const base::Optional<net::ProxyInfo>& proxy_info) override;
|
||||||
|
|
||||||
// Self-reference. Owned as long as there's an outstanding proxy lookup.
|
// Self-reference. Owned as long as there's an outstanding proxy lookup.
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "atom/browser/io_thread.h"
|
#include "atom/browser/io_thread.h"
|
||||||
|
#include "atom/common/application_info.h"
|
||||||
#include "atom/common/options_switches.h"
|
#include "atom/common/options_switches.h"
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
#include "base/lazy_instance.h"
|
#include "base/lazy_instance.h"
|
||||||
@@ -50,6 +51,8 @@ network::mojom::HttpAuthDynamicParamsPtr CreateHttpAuthDynamicParams() {
|
|||||||
command_line->GetSwitchValueASCII(atom::switches::kAuthServerWhitelist);
|
command_line->GetSwitchValueASCII(atom::switches::kAuthServerWhitelist);
|
||||||
auth_dynamic_params->delegate_whitelist = command_line->GetSwitchValueASCII(
|
auth_dynamic_params->delegate_whitelist = command_line->GetSwitchValueASCII(
|
||||||
atom::switches::kAuthNegotiateDelegateWhitelist);
|
atom::switches::kAuthNegotiateDelegateWhitelist);
|
||||||
|
auth_dynamic_params->enable_negotiate_port =
|
||||||
|
command_line->HasSwitch(atom::switches::kEnableAuthNegotiatePort);
|
||||||
|
|
||||||
return auth_dynamic_params;
|
return auth_dynamic_params;
|
||||||
}
|
}
|
||||||
@@ -222,6 +225,8 @@ SystemNetworkContextManager::CreateNetworkContextParams() {
|
|||||||
|
|
||||||
network_context_params->context_name = std::string("system");
|
network_context_params->context_name = std::string("system");
|
||||||
|
|
||||||
|
network_context_params->user_agent = atom::GetApplicationUserAgent();
|
||||||
|
|
||||||
network_context_params->http_cache_enabled = false;
|
network_context_params->http_cache_enabled = false;
|
||||||
|
|
||||||
// These are needed for PAC scripts that use file or data URLs (Or FTP URLs?).
|
// These are needed for PAC scripts that use file or data URLs (Or FTP URLs?).
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ void BeforeStartInUI(base::WeakPtr<URLRequestAsyncAsarJob> job,
|
|||||||
if (args->GetNext(&value)) {
|
if (args->GetNext(&value)) {
|
||||||
V8ValueConverter converter;
|
V8ValueConverter converter;
|
||||||
v8::Local<v8::Context> context = args->isolate()->GetCurrentContext();
|
v8::Local<v8::Context> context = args->isolate()->GetCurrentContext();
|
||||||
request_options.reset(converter.FromV8Value(value, context));
|
request_options = converter.FromV8Value(value, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request_options) {
|
if (request_options) {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ void BeforeStartInUI(base::WeakPtr<URLRequestBufferJob> job,
|
|||||||
if (args->GetNext(&value)) {
|
if (args->GetNext(&value)) {
|
||||||
V8ValueConverter converter;
|
V8ValueConverter converter;
|
||||||
v8::Local<v8::Context> context = args->isolate()->GetCurrentContext();
|
v8::Local<v8::Context> context = args->isolate()->GetCurrentContext();
|
||||||
request_options.reset(converter.FromV8Value(value, context));
|
request_options = converter.FromV8Value(value, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request_options) {
|
if (request_options) {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user