Compare commits

...

910 Commits

Author SHA1 Message Date
Electron Bot
7e80f3fb19 Bump v5.0.8 2019-07-23 11:38:39 -07:00
trop[bot]
e64d407bfd fix: emit swipe event on macOS (#19353) 2019-07-22 09:29:24 -07:00
trop[bot]
7771886073 fix zoom button when alwaysOnTop set (#19350) 2019-07-19 18:50:50 -07:00
John Kleinschmidt
9b1147c7c9 fix: delay handling occlusion events to avoid flicker on macOS (#19315)
* fix: delay handling occlusion events to avoid flicker on macOS (#18661)

* chore: add debounce on the updateWebContentsVisibility method to ensure quick changes in occlusion do not result in flickering

* chore: update old patch headers

(cherry picked from commit 0146cc0eb5)

* Update patch for 5-0-x

* Fix compilation errors
2019-07-18 10:11:23 -07:00
Milan Burda
69ff736ace fix: don't execute preload scripts for internal <iframe> in <webview> (#19260) (#19299) 2019-07-18 15:58:09 +09:00
Micha Hanselmann
04c7453074 refactor: use NativeTheme dark mode detection on macOS 10.14+ (#19310) 2019-07-17 14:31:57 -07:00
Samuel Attard
46c0859c49 build: move our node fork to our patch system (#19292)
This points our node repo at upstream (nodejs/node) and uses the base node tag as the target ref.  We then use our existing patch system and patch files to apply our changes on top of node.  This unifies how we patch upstream repos and makes our node patches easier to reason, view, understand and most importantly reduce.
2019-07-16 16:50:26 -07:00
Electron Bot
31e43f54d0 Bump v5.0.7 2019-07-16 07:51:04 -07:00
trop[bot]
d545757191 fix: don't try to dump swiftshader symbols on mac (#19261)
* fix: don't try to dump swiftshader symbols on mac

* fix: don't try to generate swiftshader symbols on arm
2019-07-15 20:53:57 -07:00
Milan Burda
ddc85869de fix: <webview> not working in scriptable popups (#19206) 2019-07-16 11:44:04 +09:00
Shelley Vohr
65faec8659 fix: silent printing (#19038) 2019-07-15 14:38:25 -07:00
trop[bot]
9b72734f7c fix: exit non-silently when running as root on Linux (#19254)
* check for sandbox param on root

* add IsSandboxEnabled
2019-07-15 14:28:04 -05:00
Erick Zhao
29a6dd079c chore: revert key -> main change in window delegate listener (#19238) 2019-07-14 10:54:20 +09:00
Milan Burda
dd58f2a6ac ci: add check for dist zip file changes (#19173) 2019-07-11 11:51:35 -05:00
Samuel Attard
8e68e6eb75 feat: provide the frame URL with permission requests and checks (#18757) (#18773)
* feat: provide the frame URL with permission requests and checks

Also provides a handy isMainFrame property to determine if it is an
iframe making the request

* chore: refactor to use base::Value

* chore: use Set<Type>Key over SetPath
2019-07-11 18:00:12 +09:00
trop[bot]
0a3ec23967 fix: check parent-child relationship in canAccessWindow (#19117) 2019-07-11 17:57:14 +09:00
trop[bot]
6f85e4de57 remove non-existent event (#19170) 2019-07-11 17:33:55 +09:00
trop[bot]
b8f3325a04 fix: don't package mojom{,-lite}.js files in dist.zip (#19192) 2019-07-11 17:19:50 +09:00
Milan Burda
3e6cd062a7 fix: don't package resources/inspector in dist.zip (#19193) 2019-07-11 17:19:00 +09:00
Jeremy Apthorp
a2f68c1e57 fix: dump correct breakpad symbols on macOS (#19157) 2019-07-09 09:47:36 +09:00
trop[bot]
bff8573646 fix: only check darkMode effectiveAppearance in 10.15 (#19082) 2019-07-02 14:15:33 -07:00
trop[bot]
32ad5be74e fix: Correct modal focus behavior on macOS (#19063)
* wip: wish i could hack the main window focus away

* main -> key

* remove useless code

* test: Add focus event spec

* test: more robust spec

* test: simplify test

* duplicate non-firing macOS event listener 😳

* destroy 🚨

* chore: remove unused variable
2019-07-02 09:20:15 -07:00
Juliette Rapala
3d60f82d03 docs: fix typo in breaking-changes.md (#19040) 2019-07-01 10:42:21 -07:00
Samuel Attard
3aa16f5632 docs: fix heading level for power-monitor docs (#19018) 2019-07-01 09:55:43 -07:00
trop[bot]
d0f7f9f894 ci: run lint on CircleCI (#19058)
* ci: run lint on CircleCI

* Fix linting errors
2019-07-01 08:47:59 -07:00
trop[bot]
7865fa37fa fix: make tray not block main process (#18880) (#19036)
* fix: make tray not block main process

* make AtomMenuModel refcounted
2019-06-28 14:00:01 -07:00
trop[bot]
714fa6f3c0 fix: delay emitting screen events by a tick to avoid re-entrancy crash (#19023) 2019-06-28 16:23:43 +09:00
Alexandre Lacheze
61d9d7c657 fix: webview crash on iframe removal (#18976)
* Remove disable detach webview frame patch

* Backport Chromium fix crash when detaching OOPIF

Backport of 7464a6b4e3%5E%21

* Move portals_fix_crash_when_detaching_oopif_from_portal.patch as first patch

* Revert disable_detach_webview_frame.patch
2019-06-28 11:16:38 +09:00
Electron Bot
558bb52847 Bump v5.0.6 2019-06-26 13:05:00 -07:00
Samuel Attard
c979c90f46 fix: override the timers module impls to activate the uv loop (#18965) 2019-06-24 19:14:30 -07:00
Micha Hanselmann
a9ada36097 fix: sanitize invalid custom protocol headers (#18928)
* fix: sanitize invalid custom protocol headers (#18854)

* lint fix

* wild guess
2019-06-24 13:28:45 -07:00
trop[bot]
0c4b2e99ec fix: make isDarkMode correctly detect dark mode in the auto setting on catalina (#18960) 2019-06-24 13:27:58 -07:00
trop[bot]
f35b166844 chore: use manual invocation of npx yarn (#18920)
* chore: Revert "build: use yarn to install arm modules (#18802)"

This reverts commit 97bec607fe.
script/yarn.js doesn't exist in 5-0-x or 6-0-x

* chore: use manual invocation of npx yarn

* Revert "chore: use manual invocation of npx yarn"

This reverts commit 8ae77f5f5b.
2019-06-24 07:54:32 -07:00
Electron Bot
ff54817a92 Bump very far --> this is electron bot fixing the release 2019-06-21 13:34:55 -07:00
Electron Bot
25e5432863 Bump very far --> this is electron bot doing nothing 2019-06-21 12:58:36 -07:00
Electron Bot
4b9ae99f34 chore: this is electron bot doing nothing 2019-06-21 12:50:31 -07:00
Samuel Attard
e2e7a82ebc chore: this is electron bot doing nothing 2019-06-21 12:45:20 -07:00
Shelley Vohr
385e548073 refactor: session.{clearCache,getCacheSize} nws13n (#18898) 2019-06-21 09:47:39 -07:00
Milan Burda
938b3440ef fix: app.getAppPath() returning default-app path for files or directories without package.json (#18763) (#18894) 2019-06-21 08:54:32 -07:00
trop[bot]
eb821a3c7f chore: fix branch trimming for blast-off releases (#18908) 2019-06-21 01:06:59 -07:00
Milan Burda
4318ad8f3a fix: set nativeWindowOpen when sandboxed (#18273) (#18798) 2019-06-20 08:25:51 -07:00
Alexey Kuzmin
b3c44d1fe6 Revert "chore: reformat code C++ to make the linter happy (#18687)" (#18881)
This reverts commit 38cca77346.
2019-06-20 07:54:11 -07:00
Samuel Attard
401f6641c8 chore: roll node to fix http2 memory leak (#18883) 2019-06-19 12:32:59 -07:00
trop[bot]
18e31da478 docs: add example on handling the webPrefs change (#17971) (#18864)
* docs: add example on handling the webPrefs change

Fixes #17967

* Update breaking-changes.md
2019-06-19 09:54:48 -07:00
Electron Bot
ae5d556845 Bump v5.0.5 2019-06-18 15:09:37 -07:00
trop[bot]
ebc937cfd5 chore: fix current branch fetch on master (#18861) 2019-06-18 08:34:23 -07:00
trop[bot]
f09f926cba fix: use effectiveAppearance to check dark mode on mojave and above (#18666) (#18852)
* fix: use effectiveAppearance to check dark mode on mojave and above

* chore: add forward declarations for dark appearance
2019-06-17 18:12:31 -07:00
Shelley Vohr
4964a09677 chore: update codeowners in 5 (#18835) 2019-06-17 14:06:43 -07:00
Milan Burda
a7c4d21427 fix: Uncaught TypeError: Cannot set property 'innerText' of null in default-app (#18819) 2019-06-17 10:24:43 -07:00
trop[bot]
07cd1e6b4d build: get current release branch from commit (#18834)
* chore: get current release branch from commit

* love too lint
2019-06-17 07:54:13 -07:00
Shelley Vohr
7a135c736b docs: better explain supported release line levels (#18800) (#18839) 2019-06-17 07:53:30 -07:00
Milan Burda
183c687f49 fix: [Liftoff] Correctly unuse Labels (#18545) 2019-06-15 19:42:31 +09:00
Milan Burda
b04eaabf4e fix: crash in BrowserWindow destructor after win.webContents.destroy() (#18686) (#18794) 2019-06-15 16:22:13 +09:00
trop[bot]
aae58ffcae build: use yarn to install arm modules (#18801) 2019-06-15 16:16:31 +09:00
Shelley Vohr
226dd755f8 fix: callback values for printing cancellation and success (#18804) 2019-06-15 16:13:49 +09:00
trop[bot]
2e6814c4b0 docs: add specific options for MenuItem.role (#18806) 2019-06-14 23:29:28 -07:00
Electron Bot
d4319badce Bump v5.0.4 2019-06-14 14:14:47 -07:00
Erick Zhao
b034bf9ae6 fix: throw error on invalid URLs when setting cookie (#18756)
With this PR, invalid inputs to the url parameter will throw an error when using cookie.set(). This is done by checking if the URL is parseable using GURL rather than checking if the URL string being passed in is empty.

Previously, invalid URLs would be able to be added as a cookie, but you would not be able to filter for them or remove them.
2019-06-14 10:54:32 -07:00
trop[bot]
c0e688ff35 docs: fully document MenuItem instance properties (#18785)
* document menuItem instance properties

* correct some types

* add correct click documentation
2019-06-13 18:45:13 -07:00
Shelley Vohr
bf9b001989 fix: HTML fullscreen request for sub frames (#18736) (#18781)
Don't re-enter fullscreen if there is a pending operation,
for subframe fullscreen request `EnterFullScreenModeForTab`
will be called for both the frame in question as well as
the outer webContents hosting it.
2019-06-13 17:59:51 -07:00
Shelley Vohr
0e0c3da49a fix: correct isDownloadable docs to match impl (#18748) 2019-06-13 16:17:23 -07:00
Shelley Vohr
63d994808c docs: fix editMenu menu role etc types (#18759) 2019-06-13 08:30:55 -07:00
Jeremy Spiegel
e0d566a7e7 fix: properly pass openExternal activate option (#18721)
A reference to an OpenExternalOptions structure was being captured by an Objective-C block that
outlived the object that was being referenced.
2019-06-12 20:56:39 -07:00
trop[bot]
eaa22b4aa8 fix: remove lingering data when notifications autodismiss on Windows 7 (#18741) 2019-06-12 21:43:48 +09:00
Alexandre Lacheze
99c3ff60bb fix: lost window.opener after cross-origin navigation (#18614)
* SiteInstance::CreateRelatedSiteInstance and use it

* Some relies on preloads in opened window

The fact that, now, we always have an opener for opened windows diables note integration in opened windows, except if `nodeIntegrationInSubFrames` is enabled.

* Add a test on window.opener after cross-orgin navigation

* Make sure to unregisterProtocol in tests

* Introduc and use a NetworkSandbox for tests

* Modify tests about zoom persistence to properly simulate cross-origin navigation

* Revert "Modify tests about zoom persistence to properly simulate cross-origin navigation"

This reverts commit 0a7537f2eb7f183ddec16637e8a2e92a0d600321.
2019-06-11 17:37:52 -07:00
Alexey Kuzmin
38cca77346 chore: reformat code C++ to make the linter happy (#18687) 2019-06-10 09:49:16 +09:00
Maya Wolf
a0872b2314 fix: contractions handling in spellchecker (#18548) 2019-06-07 19:12:17 -07:00
trop[bot]
8517c499e9 fix: use isEqual instead of pointer equality to convert NSAppearance (#18689) 2019-06-07 11:31:39 -07:00
trop[bot]
3f23f8b2a3 ci: fix issues downloading from CircleCI (#18655)
Make sure we pass along token to download from CircleCI
Also, add back off period for retries on downloads.
2019-06-05 10:54:22 -07:00
Electron Bot
45ab468ce1 Bump v5.0.3 2019-06-04 12:13:27 -07:00
Milan Burda
be458b547a build: remove Vulkan mock ICD (#18595) 2019-06-04 10:08:40 -05:00
trop[bot]
050bbfb211 build: move Windows release builds to AppVeyor cloud (#18604)
* build: move Windows release builds to AppVeyor cloud

* Use new env variable for AppVeyor cloud server
2019-06-04 10:29:37 -04:00
Milan Burda
0a4d90d41f fix: don't export private V8 symbols that can cause native node modules to crash (#18281) (#18620) 2019-06-04 10:13:29 -04:00
trop[bot]
0e56578e11 build: install python-dbusmock via pip for a Docker container (#18599)
* build: use python-dbusmock v0.18.1 on Linux

To prevent timeout errors with some other python-dbusmock versions.

* Don't use a fixed version of python-dbusmock

Co-Authored-By: John Kleinschmidt <jkleinsc@github.com>
2019-06-04 09:41:55 -04:00
trop[bot]
7a2777cc00 doc: change pyobjc link in macos build instruction (#18617) 2019-06-03 22:02:50 -07:00
trop[bot]
fc6b98766c build: strip swiftshader binaries (#18601) 2019-06-03 14:32:39 -07:00
trop[bot]
7d06861a6d ci: add retries to downloads for arm testing (#18533) 2019-05-30 21:08:57 -07:00
trop[bot]
851a84d301 docs: specify use case for the 'services' role (#18527)
* docs: specify use case for the 'services' role

* update based on @caesar's recommendation

Co-Authored-By: Caesar Schinas <caesar@caesarschinas.com>
2019-05-30 15:15:02 -07:00
trop[bot]
91bc35fbfc fix: populate phase of WebMouseWheelEvents generated in webContents.sendInputEvent. (#18495) 2019-05-30 15:11:37 -07:00
trop[bot]
76414e58d4 fix: respect minimizable/closable for customButtonsOnHover (#18485) 2019-05-29 13:00:36 -07:00
trop[bot]
d6ad3e6a17 docs: clarify that 'second-instance' is only emitted when the second instance calls app.requestSingleInstanceLock() (#18384) 2019-05-28 14:21:17 -07:00
Milan Burda
49d6f5cc14 chore: remove leftovers from memory property removal from app.getAppMetrics() (#18423) 2019-05-28 14:20:24 -07:00
Charles Kerr
610f61603d Rename 'API Contract' as 'Breaking Changes' in 5-0-x (#18400)
Backport of https://github.com/electron/electron/pull/18326 to the stable branch for visibility on electronjs.org
2019-05-23 15:03:24 -04:00
Electron Bot
6b371a5ef9 Bump v5.0.2 2019-05-22 11:33:35 -07:00
trop[bot]
7ee06c354e fix: 'page-title-updated' event forwarding + documentation (#18318) 2019-05-21 16:22:45 +09:00
trop[bot]
a60ad6aeed fix: default enable_negotiate_port to false (#18284) 2019-05-15 10:28:21 -07:00
trop[bot]
693d840202 build: linux needs java on GN (#18216) 2019-05-08 16:33:26 -07:00
trop[bot]
7a759ea0b6 fix: crash on systemPreferences.getAccentColor() (#18194) 2019-05-07 09:51:41 -07:00
trop[bot]
83a4b7371b docs: clarify clipboard type options (#18174) 2019-05-06 09:29:31 -07:00
trop[bot]
82bb6d4ccf fix: do not mark navigations interupted with same-document navigations as aborted (#18142)
* fix: do not mark navigations interupted with same-document navigations as aborted

* spec: add tests for the loadURL promise
2019-05-03 23:09:03 -07:00
Electron Bot
2de54a3dbc Bump v5.0.1 2019-05-03 13:33:57 -07:00
trop[bot]
7eac676fa7 fix: fs.promises does not work with asar paths (#18115) 2019-05-02 22:34:25 -07:00
Electron Bot
54199d21c3 chore: bump chromium in DEPS to 73.0.3683.121 (#18001) 2019-05-02 12:50:37 -07:00
trop[bot]
2483dcc09c docs: fix webContents 'new-window' event handler sample (#18097) 2019-05-01 13:43:48 -07:00
trop[bot]
1154f3c585 fix: ensure the inspector agent is shutdown before cleaning up the node env (#18076)
* fix: ensure the inspector agent is shutdown before cleaning up the node env

* spec: add tests to ensure clean shutdown with connected inspector agent

* Update node_debugger.cc
2019-05-01 12:43:54 -07:00
trop[bot]
232d9fe808 fix: explicitly focus window on win.show() (#18080) 2019-05-01 10:44:34 -07:00
trop[bot]
5693b7f3a1 chore: disable Vulkan validation layers (#18061) 2019-04-30 10:17:19 -07:00
Milan Burda
d4e631f1b9 Revert "build: disable Vulkan support by default (#17788)" (#17986)
This reverts commit 82f91b7efa.
2019-04-30 06:48:36 -07:00
Milan Burda
2252ac060e docs: update nodeIntegration section for new defaults (#18051) 2019-04-30 06:44:05 -07:00
trop[bot]
bb28195b74 docs: Correct doc for registerFileProtocol (#18049)
In the registerFileProtocol docs the "headers" argument of the callback was described as being a list.
In fact is has to be an Object mapping header-entries to values. This can be seen in Line 326 of `/spec/api-protocol-spec.js` [fe618631f1/spec/api-protocol-spec.js (L326)].
2019-04-29 15:30:25 -07:00
Milan Burda
2f426a031a fix: remove non-existent gpu-crashed event on <webview> (#17317) (#18004) 2019-04-29 15:21:52 -07:00
trop[bot]
761b14316f docs: add azure vm spinup tutorial (#17974) 2019-04-25 15:49:24 -07:00
trop[bot]
f3a05c30ae fix: crash when run from SMB network share (#17908) 2019-04-24 11:26:40 -07:00
Electron Bot
7514372e79 Bump v5.0.0 2019-04-23 14:04:26 -07:00
Samuel Attard
151a338956 Revert "Bump v5.0.0"
This reverts commit d57293503d.
2019-04-23 14:03:18 -07:00
Electron Bot
d57293503d Bump v5.0.0 2019-04-23 11:34:11 -07:00
Samuel Attard
c4009760c7 build: fix bump-version script for stable releases 2019-04-23 11:30:19 -07:00
Samuel Attard
3408997289 Revert "Bump v5.0.0"
This reverts commit 9ca2b31b7c.
2019-04-23 11:25:23 -07:00
Electron Bot
9ca2b31b7c Bump v5.0.0 2019-04-23 09:36:13 -07:00
Samuel Attard
5aa0a1a77a build: fix release notes generation 2019-04-23 09:34:35 -07:00
Jeremy Apthorp
3825bf0b6d fix: enable autofill popups on mac (backport: 5-0-x) (#17888)
* feat: enable autofill popups on mac

* fix: make popup positioning better

* fix: don't try to show popup when widget is closing or not visible

* fix: unify conditions

* refactor: use PopupViewCommon from chrome directly

* lint: mark constructor explicit

* fix: use a patch instead of dummy functions to make things compile on Windows

* chore: address review suggestions

* Update atom/browser/ui/cocoa/views_delegate_mac.mm

Co-Authored-By: brenca <benecene@gmail.com>
2019-04-22 14:55:38 -07:00
Samuel Attard
d15bcfb1ed refactor: allow embedder overriding of internal FS calls (#17906) 2019-04-22 14:54:19 -07:00
Samuel Attard
ccb051caf7 fix: remove duplicate function deprecator 2019-04-22 13:28:39 -07:00
Electron Bot
3284aabd48 chore: bump chromium in DEPS to 73.0.3683.119 (#17853) 2019-04-19 13:56:24 -07:00
Electron Bot
6d575f80fa Bump v5.0.0-beta.9 2019-04-19 11:04:37 -07:00
Cheng Zhao
b91dcfb314 fix: drain tasks before shutting down isolate (#17877) 2019-04-19 11:03:04 -07:00
Milan Burda
321e66d0cc fix: copy pixels in AddImageSkiaRepFromBuffer (#17843) (#17863) 2019-04-18 08:53:56 -07:00
trop[bot]
81eedb6efa doc: document occasional mismatch between NSImageName and string (#17849) 2019-04-17 21:01:24 -04:00
Roller Bot
b08dc0f7e6 chore: bump chromium in DEPS to 73.0.3683.117 (#17839) 2019-04-17 17:29:35 -07:00
Samuel Attard
11c1c255bf fix: ensure the sandboxed preloads globals do not leak (#17712) (#17830) 2019-04-17 17:05:24 -04:00
Samuel Attard
c89bab9730 build: override the NMV for Electron 5 (#17828)
* build: override the NMV for Electron 5

* chore: add ref to the NMV registry

* chore: update DEPS for new node revision

* chore: update node ref

* chore: update node ref in DEPS

* Update build/args/all.gn
2019-04-17 17:04:12 -04:00
trop[bot]
5ffe634824 refactor: remove superfluous ScopedAllowBaseSync in desktopCapturer (#17846) 2019-04-17 13:12:21 -07:00
Jeremy Apthorp
3ad9fb1473 fix: skip zygote for unsandboxed ppapi processes (#17829) 2019-04-17 13:13:16 -04:00
Milan Burda
b0298cca2e fix: emit process 'loaded' event in sandboxed renderers (#17808) 2019-04-16 16:24:31 -07:00
trop[bot]
ed8ab7e9ad fix: reset the NSUserNotication handle on dismiss (#17822) 2019-04-16 16:20:26 -07:00
Samuel Attard
c75726f9ef fix: maintain a ref count for objects sent over remote (#17464) (#17825)
* spec: clean up after a failed window count assertion

Previously when this assertion failed all tests that ran after the
failed assertion also failed.  This ensure that the assertion fails for
the test that actually caused the issue but cleans up the left-over
windows so that future tests do not fail.

* fix: maintain a ref count for objects sent over remote

Previously there was a race condition where a GC could occur in the
renderer process between the main process sending a meta.id and the
renderer pulling the proxy out its weakmap to stop it being GC'ed.

This fixes that race condition by maintaining a "sent" ref count in the
object registry and a "received" ref count in the object cache on the
renderer side.  The deref request now sends the number of refs the
renderer thinks it owns, if the number does not match the value in the
object registry it is assumed that there is an IPC message containing a
new reference in flight and this race condition was hit.

The browser side ref count is then reduced and we wait for the new deref
message.  This guaruntees that an object will only be removed from the
registry if every reference we sent has been guarunteed to be unreffed.
2019-04-16 17:57:25 -04:00
trop[bot]
ff7e22c675 docs: note desktop audio limitation on macOS (backport: 5-0-x) (#17814)
* docs: note desktop audio limitation on macOS

* link to signed kernel info

* Update docs/api/desktop-capturer.md

Co-Authored-By: codebytere <codebytere@github.com>
2019-04-16 13:13:17 -07:00
trop[bot]
946c11145c docs: reference the webviewTag option in the webview docs (#17812)
Closes #16773

Notes: Add a reference to the "webviewTag" option in the webview docs
2019-04-16 15:51:48 -04:00
Nitish Sakhawalkar
ffd2224bbe Node 12 Upgrade (5-0-x) (#17752)
* fix: backport boringssl patches for node compat

* refactor: prevent node macros from overriding base (#17178)

* fix: backport boring ssl patch OPENSSL_clear_free

* refactor: load electron builtin modules with process._linkedBinding (#17247)

* refactor: load electron builtin modules with process._linkedBinding

NODE_BUILTING_MODULE_CONTEXT_AWARE and process.binding are
removed in https://github.com/nodejs/node/pull/25829. This changes
uses the alternative available without any functionality change.

* chore: roll node

* fix: add boringssl backport to support node upgrade

* fix: Update node_includes.h, add DCHECK macros

* fix: Update node Debug Options parser usage

* fix: Fix asar setup

* fix: using v8Util in isolated context

* fix: make "process" available in preload scripts

* fix: use proper options parser and remove setting of _breakFirstLine

_breakFirstLine was being set on the process, but that has changed in node 12 and so is no longer needed. Node will handle it properly when --inspect-brk is provided

* fix: process.binding => _linkedBinding in sandboxed isolated preload

* chore: update node dep sha

* fix: make original-fs work with streams
2019-04-16 15:51:08 -04:00
Samuel Attard
c326de860d fix: handle remote-debugging-port=0 correctly (#17800) (#17817)
By default the Chromedriver will send remote-debugging-port=0 to let the
browser choose a free port to listen on.  The chosen port is written to
a known file in the user data dir that is passed to the app through the
CLI.

This PR does two things.

1. Correctly passes the USER_DATA_DIR to the remote debugging server so
it knows where to write the file
2. Adds support for --user-data-dir as we did not support that CLI
argument and Chromedriver relies on being able to tell the "browser"
where to write this file.

Fixes #17354
2019-04-16 15:46:27 -04:00
Roller Bot
145aa919ca chore: bump chromium in DEPS to 73.0.3683.116 (#17805) 2019-04-16 12:02:02 -04:00
trop[bot]
2cc55fee5e test: remove non-applicable processMemoryInfo specs (#17709) 2019-04-15 20:00:43 -04:00
trop[bot]
119e8bec93 fix: crash when alt key pressed with falsy menu bar visiblity (#17795) 2019-04-15 15:26:35 -04:00
Alexey Kuzmin
82f91b7efa build: disable Vulkan support by default (#17788)
Is was enabled in
327326656f
which landed in 69.0.3460.0

Vulkan support would require a command line parameter "--enable-vulkan"
to be passes to a binary to be enabled anyway,
so this change doesn't actual alter the current behaviour of Electron.

(cherry picked from commit e05e45d62d)
2019-04-15 15:26:02 -04:00
trop[bot]
900feef89f fix: incorrect default path setting for dl items (#17797) 2019-04-15 15:20:41 -04:00
trop[bot]
c58d39e71b fix crash when passing empty string to recording (#17711) 2019-04-15 14:15:31 -04:00
trop[bot]
48f190690e fix: correct crash reporter for Windows on Arm (#17792)
ARM64 cleans up and moves around RUNTIME_FUNCTION structure fields.
With this patch applied, electron should build cleanly for Windows on Arm.
2019-04-15 13:56:23 -04:00
Roller Bot
faa308c88c chore: bump chromium in DEPS to 73.0.3683.112 (#17770) 2019-04-12 14:18:19 -04:00
Milan Burda
9619688706 fix: report module name when require fails in sandboxed renderers (#17705) 2019-04-12 13:40:15 -04:00
Roller Bot
a724aced43 chore: bump chromium in DEPS to 73.0.3683.105 (#17707) 2019-04-05 10:48:30 -07:00
Electron Bot
9a9f7af971 Bump v5.0.0-beta.8 2019-04-04 09:09:31 -07:00
trop[bot]
0184ccd019 build: optionally exclude some parts of patches from being applied (#17685) 2019-04-04 09:07:32 -07:00
Roller Bot
cdd8021509 chore: bump chromium in DEPS to 73.0.3683.104 (#17692) 2019-04-04 09:06:57 -07:00
Heilig Benedek
1e31bfe287 fix: port OSR code to new viz compositor codepath (backport: 5-0-x) (#17572)
* fix: make OSR work with viz compositor

* fix: update OSR patch

* fix: update patch again

* fix: update viz_osr.patch for macOS

* fix: gn check warnings

* chore: no need to change SoftwareOutputDeviceWinProxy

* chore: add check in case we missed something

* fix: consider scale factor when compare size

* fix: make GPU OSR work

* fix: autofill popups with OSR

* chore: use UNIX line ending for osr_video_consumer

* chore: code is already in defined(OS_MACOSX)

* fix: share same OSR implementation on macOS

This should also fix the crash when there is navigation on macOS.

* test: osr window should not crash after navigation

* fix: make osr work on Mac properly

* fix: software osr on windows

* fix: software osr on Linux

* fix: split local surface id allocation into two

* fix: update patch for 5-0-x

* fix: patch and update VideoConsumer to report proper damage_rect

* fix: update patch to resolve compilation error on Linux

* fix: compilation error on mac

* Update osr_host_display_client_mac.mm

* chore: update copyright year
2019-04-03 18:08:22 -05:00
trop[bot]
7304af93ed docs: clarify cookie domain normalization (#17663) 2019-04-02 18:26:28 -07:00
Roller Bot
69f6a44e81 chore: bump chromium in DEPS to 73.0.3683.101 (#17656) 2019-04-02 15:44:33 -07:00
Samuel Attard
354b32a9fc fix: make devtools extensions load correctly (#17616) 2019-04-02 13:24:40 -07:00
Samuel Attard
d5bb0e968f fix: ensure dots in content script patterns aren't used as wildcards (#17594)
* fix: ensure dots in content script patterns aren't used as wildcards

* chore: santize all regex chars

* chore: extract to helper

* chore: fixup helper
2019-03-28 14:04:30 -07:00
trop[bot]
9e12e8c63f fix: handle a race condition between preload scripts executing and navigations (#17597)
There is a race condition between DidCreateScriptContext and another
navigation occuring in the main process. If the navigation occurs while
the preload script is running, the same process is re-used.  This
ensures that any pending navigations are completely removed / ignored
when we trigger a new navigation.

Fixes #17576
2019-03-28 12:56:29 -07:00
Heilig Benedek
ebcd094222 fix: update patch to make Windows key work with global shortcuts (#17566) 2019-03-28 11:17:39 -07:00
trop[bot]
5dd735f5b3 fix: correctly return properties on the netLog module (#17545) 2019-03-27 15:38:10 -07:00
trop[bot]
46841d7373 fix: set default_id and cancel_id correctly on confirm dialogs (#17578) 2019-03-27 15:30:21 -07:00
Electron Bot
707f110c0f Bump v5.0.0-beta.7 2019-03-27 13:58:57 -07:00
trop[bot]
0e5d181cc9 fix: use file path as key for safeDialogs on filesystem (#17579) 2019-03-27 12:45:53 -07:00
trop[bot]
f3a2c27840 fix: add missing buffer size check in nativeImage (#17568) 2019-03-27 09:37:10 -04:00
Roller Bot
0032a5247f chore: bump chromium in DEPS to 73.0.3683.94 (#17554) 2019-03-26 18:42:58 -07:00
trop[bot]
ef38019122 fix: close context menu before popup (#17509) 2019-03-22 10:25:36 -04:00
Roller Bot
e280ae11b8 chore: bump chromium in DEPS to 73.0.3683.88 (#17500) 2019-03-21 12:33:17 -07:00
trop[bot]
14602f55d5 docs: clarify documentation for getLastCrashReport (backport: 5-0-x) (#17493)
* docs: clarify documentation for getLastCrashReport

* address feedback
2019-03-20 22:04:09 -07:00
trop[bot]
27b4335084 fix: take foreground visibility into account for isVisible on macOS (#17491) 2019-03-20 20:41:18 -07:00
trop[bot]
a1c1012cc4 fix: use a more unique identifier for NSUserNotification instances (#17484)
So although apple has it documented that notifications with duplicate identifiers in the same session won't be presented.  They apparently forgot to mention that macOS also non-deterministically and without any errors, logs or warnings will also not present some notifications in future sessions if they have a previously used identifier.

As such, we're going to truly randomize these identifiers so they are
unique between apps and sessions.  The identifier now consists of a
randomly generated UUID and the app bundle id.
2019-03-20 11:19:00 -07:00
trop[bot]
821b88e420 fix: check the result when calling js function (backport: 5-0-x) (#17481)
* fix: check the result when calling js function

* test: should not crash when callback returns nothing
2019-03-20 09:54:55 -07:00
Electron Bot
d90934517d Bump v5.0.0-beta.6 2019-03-20 09:03:32 -07:00
Roller Bot
2f765ac897 chore: bump chromium to 73.0.3683.84 (5-0-x) (#17452)
* chore: bump chromium in DEPS to 73.0.3683.84

* kick ci

* kick ci
2019-03-19 13:02:49 -07:00
trop[bot]
d25be9cf75 fix: improve focused menu bar item visibility (#17360) 2019-03-19 12:20:42 -07:00
Heilig Benedek
1b8a25bb81 feat: enable NodeIntegrationInSubFrames for webview (5-0-x) (#17398)
* feat: enable nodeIntegrationInSubFrames for webview

* test: add tests

* docs: document webview's nodeintegrationinsubframes

* lint: fix indent

* chore: roll node to make CI pass for now
2019-03-19 12:17:58 -07:00
trop[bot]
361e5b2c55 fix: throw error when inserting menu items out-of-range (backport: 5-0-x) (#17435)
* fix: throw error when inserting menu items out-of-range

* also check pos < 0
2019-03-19 12:12:49 -07:00
Milan Burda
7912ea5950 fix: remove crashReporterRenderer.sendSync() workaround for init() (#17410) 2019-03-19 11:57:05 -07:00
trop[bot]
5b34f9bcc9 fix: pass the correct HostPort into the node inspector (#17439)
Fixes #17348
2019-03-18 12:39:29 -07:00
Roller Bot
766cfc1f4c chore: bump chromium in DEPS to 73.0.3683.79 (#17383) 2019-03-14 15:25:08 -07:00
trop[bot]
3e999ca127 feat: enable setuid sandbox on linux (#17343) 2019-03-13 19:34:19 -07:00
trop[bot]
c8f80baeea fix: don't crash when nativeImage.createFromBuffer() called with invalid buffer (#17374) 2019-03-13 18:21:10 -07:00
Roller Bot
d527192c49 chore: bump chromium in DEPS to 73.0.3683.78 (#17367) 2019-03-13 14:31:27 -07:00
trop[bot]
6a93200099 fix: remove label/image from segment if they are mutated to undefined/null (#17334) 2019-03-11 17:19:49 -07:00
trop[bot]
2f31302b75 spec: robustify sendInputEvent beforeEach hook (#17340) 2019-03-11 16:15:25 -07:00
Jeremy Apthorp
2cb7b6bbf3 chore: bump chromium to 73.0.3683.75 (5-0-x) (#17295)
* chore: bump chromium to 73.0.3683.69

* 73.0.3683.75
2019-03-11 16:10:23 -07:00
trop[bot]
ba00be3798 test: fix incorrect reference to skip (#17281) 2019-03-08 16:12:43 -05:00
trop[bot]
c55f806191 fix: crash in ECDH.setPrivateKey (#17296) 2019-03-08 16:11:57 -05:00
trop[bot]
de9eb14d46 fix: remove usage of private APIs in the MAS build (backport: 5-0-x) (#17293)
* fix: remove usage of abort_report_np in MAS builds

* fix: remove usage of pthread_chdir in MAS builds

* fix: remove usage of setapplicationisdaemon in MAS builds

* chore: update patch manifest
2019-03-08 11:18:54 -08:00
trop[bot]
cf390c0efb fix: run subframe preload bundles in isolated context (backport: 5-0-x) (#17275)
* fix: run subframe preload bundles in isolated context

* test subframe contextIsolation when disabled
2019-03-07 16:03:57 -08:00
trop[bot]
2c9b4d1def fix: bad assertion in crypto functions that use BN_bn2bin_padded (backport: 5-0-x) (#17255)
* chore: roll node

in particular, this picks up electron/node#70a78f07b, which fixes an issue with incorrect usage of the BN_bn2bin_padded API in boringssl

* fix tests
2019-03-07 13:06:21 -08:00
trop[bot]
104ec2ba12 fix: make StreamSubscriber ref counted (#17264)
It is owned by URLRequestStreamJob on the IO thread once request starts,
but if the ownership was abondoned while transfering it to IO thread
which is possible when a request is aborted, then we need to make sure
its destroyed on the right thread to avoid lock in v8.
2019-03-07 23:51:42 +05:30
trop[bot]
78a2a2f18d fix: backport upstream fixes for color chooser dialogs (backport: 5-0-x) (#17254)
* fix: backport upstream fixes for color chooser dialogs

* chore: fix patches, Windows bad, linux good

* Update color_chooser_mac.patch

* Update color_chooser_win.patch
2019-03-07 09:48:09 -05:00
Roller Bot
4d620f0a11 chore: bump chromium in DEPS to 73.0.3683.68 (#17261) 2019-03-07 09:45:44 -05:00
Roller Bot
d483a135f5 chore: bump chromium in DEPS to 73.0.3683.65 (#17233) 2019-03-05 11:09:38 -08:00
Electron Bot
7990d9b81e Bump v5.0.0-beta.5 2019-03-04 14:54:50 -08:00
trop[bot]
2b28ed4fc6 fix: check for pane focus before removing it. (#17215)
Fixes #16883. This bug seems to have been introduced in the #15302's
menu a11y refactor and is new in 5-0-x.
2019-03-04 14:51:15 -08:00
Jeremy Apthorp
51c5882f4c chore: bump chromium to 73.0.3683.61 (5-0-x) (#17192)
* chore: bump chromium to 73.0.3683.61

also backport https://chromium-review.googlesource.com/c/chromium/src/+/1496448

* update patch for arm64
2019-03-01 12:44:16 -08:00
trop[bot]
1aae1c11e3 fix: access of out-of-scope reference in ShowOpenDialog and ShowSaveDialog (#17177)
In the mac file dialog implementation of show*OpenDialog, a settings
object is passed down to the dialog completion handler.
However at the time the completion handler is invoked, the settings
object is already out-of-scope, resulting in an invalid access to
the security_scoped_bookmarks flag.
The fix is to capture the value of the flag and passing that directly
to the completion handler.

fixes issue #16664
2019-03-01 08:19:03 +00:00
trop[bot]
00cfedbfd8 docs: Fix types and missing property in WebRequest APIs (backport: 5-0-x) (#17167)
* docs: Fixed hook methods of WebRequest accepts null as listener

* docs: Added missing `referrer` property in OnBeforeRequestDetails

* docs: Add `referrer` to each webRequest responses
2019-02-28 13:20:18 -08:00
trop[bot]
7e3ff0f7d2 chore: replace usage of deprecated beginSheetModalForWindow API (#17162) 2019-02-28 08:33:49 +00:00
Electron Bot
47f005f730 Bump v5.0.0-beta.4 2019-02-27 09:55:18 -08:00
trop[bot]
4f3d6117cd fix: set cancelId to 1 when defaultId == 0 and no 'cancel' button (#17150) 2019-02-27 13:01:38 +00:00
trop[bot]
119382b55e docs: fix MenuItem windowMenu role description (#17118)
It was changed in https://github.com/electron/electron/pull/15930
2019-02-27 08:25:25 +00:00
trop[bot]
8cf0e8ed5c Fix webContents.print() (#17117) 2019-02-27 08:25:09 +00:00
trop[bot]
fce543d725 chore: finalize dropping support for OS X Mavericks (version 10.9) (#17122) 2019-02-27 08:24:48 +00:00
trop[bot]
8fb7481298 chore: roll chromium 73.0.3683.54 (backport: 5-0-x) (#17147)
* chore: roll chromium 73.0.3683.52

* chore: roll 73.0.3683.54
2019-02-27 12:23:55 +05:30
Electron Bot
9cdb5eda89 Revert "Bump v5.0.0-beta.4"
This reverts commit c0f307e49c.
2019-02-26 15:45:51 -08:00
Electron Bot
c0f307e49c Bump v5.0.0-beta.4 2019-02-26 14:56:25 -08:00
Cheng Zhao
e8df32f354 chore: make util::Promise a move-only type (#17113) 2019-02-26 05:15:00 +09:00
trop[bot]
5c68870ad7 chore: properly template the Then promise helper (#17058) 2019-02-25 08:51:33 +00:00
Roller Bot
f3f1f6b712 chore: bump chromium in DEPS to 73.0.3683.49 (#17094) 2019-02-22 17:17:52 -08:00
trop[bot]
4ecb96e8d7 chore: add Then helper for native promises (#17026) 2019-02-19 13:45:37 +00:00
trop[bot]
5343ccf10b build: make torque patch more specific for native arm builds (backport: 5-0-x) (#17019)
* build: make torque patch more specific

the v8_generator_toolchain should only be overriden if the snapshot toolchain is a native arm or arm64 toolchain

* Only test native mksnapshot on arm64

* Put environment variable in container
2019-02-18 11:11:20 +00:00
Shelley Vohr
cbb9c4323c chore: move ts-smoke tests to core (#16930) (#16991)
* chore: move ts smoke tests to core

* fix: fix paths for tsconfig / ts-smoke runner

* update ts-defs version

* do not lintr
2019-02-15 15:14:58 -08:00
Roller Bot
be9f302af6 chore: bump chromium in DEPS to 73.0.3683.41 (#16980) 2019-02-15 10:37:30 -08:00
trop[bot]
180a4f34c2 refactor: promisify prototype methods (#16972) 2019-02-14 17:35:10 -08:00
trop[bot]
b1bfc74ecb docs: update dialog documentation for "undefined" ret vals (#16977) 2019-02-14 17:34:19 -08:00
Electron Bot
bc7d2378df Bump v5.0.0-beta.3 2019-02-14 17:33:14 -08:00
Samuel Attard
e31d3b52ee Merge pull request #16975 from electron/5-73
feat: upgrade to Chromium 73.0.3683.27
2019-02-14 17:31:14 -08:00
Samuel Attard
277373a95a fix: remove deprecated usage of v8::String::NewFromUtf8 2019-02-14 15:39:54 -08:00
trop[bot]
d9e9bf9b87 fix: disable Chromium v2 sandbox in MAS builds (#16969) 2019-02-14 14:10:32 -08:00
deepak1556
3396d08a3b chore: remove unused patches 2019-02-15 02:28:31 +05:30
John Kleinschmidt
c76872f3f9 Run electron tests first 2019-02-14 12:40:12 -08:00
deepak1556
c7175b295a chore: roll 73.0.3683.27 2019-02-14 12:39:21 -08:00
deepak1556
2ff3a15326 Disable swiftshader for arm32 2019-02-14 12:38:37 -08:00
deepak1556
a6806e9e1c FIXME: disable OSR 2019-02-14 12:38:37 -08:00
deepak1556
200051ccc0 fix compilation error for windows testing builds 2019-02-14 12:38:37 -08:00
deepak1556
36726bd70f Disable precompiled headers
Workaround for https://crbug.com/924225
2019-02-14 12:38:37 -08:00
deepak1556
9755288527 REVIEW: fix possible -Wdeprecated-declarations warnings 2019-02-14 12:38:37 -08:00
Heilig Benedek
39e380bb66 chore: fix linking errors on Windows 2019-02-14 12:38:36 -08:00
Heilig Benedek
4bdf7674f9 chore: use c++ manifests instead of json 2019-02-14 12:38:36 -08:00
Heilig Benedek
cfe8c3efd8 chore: make OSR compile on Windows 2019-02-14 12:38:36 -08:00
deepak1556
46b420158c Remove "layouttest" or "layout test" in //content
https://chromium-review.googlesource.com/c/chromium/src/+/1367391
2019-02-14 12:38:36 -08:00
deepak1556
9010ee340c REVIEW: ui::Compositor: Simplify how ExternalBeginFrameClient is used.
https://chromium-review.googlesource.com/c/chromium/src/+/1388384
2019-02-14 12:38:36 -08:00
deepak1556
f1de4896d4 REVIEW: Have MouseWheelPhaseHandler agree on whether to route its wheel event
https://chromium-review.googlesource.com/c/chromium/src/+/1401664
2019-02-14 12:38:36 -08:00
deepak1556
9bbd1074ea ui/base: move clipboard to own folder.
https://chromium-review.googlesource.com/c/chromium/src/+/1369933
2019-02-14 12:38:36 -08:00
deepak1556
bb3c08f306 Delete tab pulsing feature.
https://chromium-review.googlesource.com/c/chromium/src/+/1407958
2019-02-14 12:38:36 -08:00
deepak1556
203c4a72b5 Rename BlendTowardOppositeLuma() to BlendTowardContrastingEndpoint().
https://chromium-review.googlesource.com/c/chromium/src/+/1400060
2019-02-14 12:38:36 -08:00
Jeremy Apthorp
cf504fc1bf gfx::Path -> SkPath
https://chromium-review.googlesource.com/c/1392181
2019-02-14 12:38:36 -08:00
deepak1556
38c3e61a78 chore: roll 73.0.3683.10 2019-02-14 12:38:35 -08:00
deepak1556
337e82a4c0 Print Preview: Add validity check for kSettingPagesPerSheet.
https://chromium-review.googlesource.com/c/chromium/src/+/1381133
2019-02-14 12:38:35 -08:00
deepak1556
a482d4e288 Enable DCHECK for renderer-initiated navigations requiring initiator.
https://chromium-review.googlesource.com/c/chromium/src/+/1385495
2019-02-14 12:38:35 -08:00
deepak1556
c1cdc38e33 chore: roll node 2019-02-14 12:38:35 -08:00
deepak1556
38865f46d2 Convert ProxyResolutionServiceProvider to use Network Service.
https://chromium-review.googlesource.com/c/chromium/src/+/1419264
2019-02-14 12:38:35 -08:00
deepak1556
e290438a6d replace network::DataElement::Type with DataElementType
https://chromium-review.googlesource.com/c/chromium/src/+/1393106
2019-02-14 12:38:35 -08:00
deepak1556
355d395b00 Autoplay: remove cross-origin autoplay policy from //chrome and //content.
https://chromium-review.googlesource.com/c/chromium/src/+/1362225
2019-02-14 12:38:35 -08:00
deepak1556
9a5b041f74 chore: roll 73.0.3679.0 2019-02-14 12:38:35 -08:00
deepak1556
5395810c45 chore: rm fix_test_compilation_error.patch 2019-02-14 12:38:35 -08:00
deepak1556
a91054883f Move client hints to content
https://chromium-review.googlesource.com/c/chromium/src/+/1376709
2019-02-14 12:37:29 -08:00
deepak1556
0459dc7d6f DevToolsFrontendHost::Create to return unique_ptr instead of raw pointer
https://chromium-review.googlesource.com/c/chromium/src/+/1396614
2019-02-14 12:37:29 -08:00
deepak1556
28c7b5f0ab Change DevToolsEmbedderMessageDispatcher to use unique_ptr instead of raw pointers.
https://chromium-review.googlesource.com/c/chromium/src/+/1382701
2019-02-14 12:37:29 -08:00
deepak1556
b7018da0c1 Replace SiteInstance::IsSameWebSite() with a new non-static method.
https://chromium-review.googlesource.com/c/chromium/src/+/1352856
2019-02-14 12:37:29 -08:00
deepak1556
bdd272192c Remove const interfaces from content::RenderProcessHost.
https://chromium-review.googlesource.com/c/chromium/src/+/1356004
2019-02-14 12:37:29 -08:00
deepak1556
d9faf76cb5 Increase scope of URLLoader::FollowRedirect() API implementation.
https://chromium-review.googlesource.com/c/chromium/src/+/1369856
2019-02-14 12:37:28 -08:00
deepak1556
52db4693e8 Make //ui/base/idle API synchronous
https://chromium-review.googlesource.com/c/chromium/src/+/1379183
2019-02-14 12:37:28 -08:00
deepak1556
b362a59173 split out color chooser browser dialog header
https://chromium-review.googlesource.com/c/chromium/src/+/1395146
2019-02-14 12:37:28 -08:00
deepak1556
e8e4b19348 Stop using GetUserAgent from non-browser process
https://chromium-review.googlesource.com/c/chromium/src/+/1353052
2019-02-14 12:37:28 -08:00
deepak1556
e674061bab More migration of ServiceContext to ServiceBinding
https://chromium-review.googlesource.com/c/chromium/src/+/1357534
2019-02-14 12:37:28 -08:00
deepak1556
77b3d218a4 Blink: Plumb correct security origin for isolated world CSPs.
https://chromium-review.googlesource.com/c/chromium/src/+/1395190
2019-02-14 12:37:28 -08:00
deepak1556
364dac53d4 v8: Remove obsolete V8 extras flag
https://chromium-review.googlesource.com/c/chromium/src/+/1404554
2019-02-14 12:37:28 -08:00
deepak1556
29b9281af4 Move BackgroundColor from widgets and child frames to the WebView.
https://chromium-review.googlesource.com/c/chromium/src/+/1382861
2019-02-14 12:37:28 -08:00
deepak1556
4d2815e56b Downloads : Adding metered network info and retry count to download item
https://chromium-review.googlesource.com/c/chromium/src/+/1352628
2019-02-14 12:37:28 -08:00
deepak1556
302372f4b4 Move GetUserAgent from ContentClient to ContentBrowserClient
https://chromium-review.googlesource.com/c/chromium/src/+/1352086
2019-02-14 12:37:27 -08:00
deepak1556
bbd72e5658 Use base::size rather than arraysize
https://bugs.chromium.org/p/chromium/issues/detail?id=837308
2019-02-14 12:37:27 -08:00
deepak1556
3db0a8ef73 Use C++ Manifests for SM embedders
https://chromium-review.googlesource.com/c/chromium/src/+/1383530
2019-02-14 12:37:27 -08:00
deepak1556
1a2df2f309 Change the source origin parameter type for CanCreateWindow from GURL to url::Origin.
https://chromium-review.googlesource.com/c/chromium/src/+/1395066
2019-02-14 12:37:27 -08:00
deepak1556
d5c37c301a content: Fix WebContentsUserData for usage across components.
https://chromium-review.googlesource.com/c/chromium/src/+/1354402
2019-02-14 12:37:27 -08:00
deepak1556
eabc5166ac Move MediaStream Mojo and public interfaces to Blink.
https://chromium-review.googlesource.com/c/chromium/src/+/1389998
2019-02-14 12:37:27 -08:00
deepak1556
88a5abca4b fix: update deprecated v8 api usage 2019-02-14 12:37:27 -08:00
deepak1556
f6b6f9524e Refactors TtsPlatform and most platform implementations to content.
https://chromium-review.googlesource.com/c/chromium/src/+/1352055
2019-02-14 12:37:27 -08:00
deepak1556
645b98d81a chore: update patches/common/ffmpeg 2019-02-14 12:37:26 -08:00
deepak1556
c605d1a044 chore: update patches/common/v8 2019-02-14 12:37:26 -08:00
deepak1556
df1d39d6ec chore: update patches/common/chromium 2019-02-14 12:34:01 -08:00
deepak1556
5f08a4f8be chore: roll 73.0.3673.0 2019-02-14 12:32:44 -08:00
trop[bot]
cc9c84cad4 fix: pass result to chrome.tabs.executeScript callback (backport: 5-0-x) (#16949)
* fix: pass result to chrome.tabs.executeScript callback

Additionally, remove `nextId` counter in favor of `originResultID` counter which is more widely used in this file.

* fix: remove need for eslint override and better match style
2019-02-14 05:35:17 -10:00
trop[bot]
25e6eb9d04 chore: Add new webFrame IsolatedWorldInfo API and deprecate (backport: 5-0-x) (#16932)
* chore: Add new webFrame IsolatedWorldInfo API and deprecate

* Flag deprecated methods in documentation

* address comments

* Address review comments

* remove unused variable

* Update based on review
2019-02-13 10:49:30 -10:00
trop[bot]
b4bd96b2ca feat: promisify debugger.sendCommand (#16931) 2019-02-13 10:48:46 -10:00
John Kleinschmidt
4ba51dbad8 ci: Move MacOS builds to CircleCI (5-0-x) (#16882)
* ci: Put back changes to build mac on CircleCI (#16656)

This reverts commit 3dcb7cfef9.

* ci: make macOS CI faster (#16766)

* ci: cache brew update result

* ci: checkout and sync the macOS build on a linux machine for speed

* ci: set MAS_BUILD=true on mas builds (#16824)

* build: remove non-arm vstsJobs (#16793)

* ci: fix binaries for chromedriver build on macOS (#16893)
2019-02-13 09:57:58 -08:00
trop[bot]
5a8af35927 build: ensure that the uploaded symbol path is correct for our symbol server (#16915) 2019-02-13 07:10:03 -10:00
trop[bot]
a4babe6699 fix: backport patch to sync exposed crypto (backport: 5-0-x) (#16909)
* fix: backport patch to sync exposed crypto

* add two new specs

* fix iv length

* fix formatting
2019-02-12 14:08:17 -08:00
trop[bot]
c1ea592457 fix: release-notes plays more nicely with clerk (#16902)
Explicitly look not just for Clerk's "notes persisted"
message but also its "no release notes" message.
2019-02-12 08:19:32 -08:00
trop[bot]
225264f06b ci: Refactor mksnapshot test so that it doesn't stall. (#16886) 2019-02-12 04:42:03 -10:00
trop[bot]
30cc82d265 feat: support capslock and numlock as accelerators (backport: 5-0-x) (#16725)
* feat: support capslock as accelerator

* also add numlock
2019-02-11 13:16:01 -08:00
trop[bot]
14c39620f0 feat: allow Menu.buildFromTemplate() to accept MenuItems (backport: 5-0-x) (#16783)
* feat: allow Menu.buildFromTemplate to accept MenuItems

* add another spec

* fix linter error

* add submenu spec
2019-02-11 13:15:00 -08:00
trop[bot]
b395a66246 chore: fix "creates offscreen window with correct size" spec on Mac with Retina display (#16878) 2019-02-11 13:14:27 -08:00
trop[bot]
04158b15bb fix: enable property having no effect on submenus (#16858) 2019-02-09 09:58:25 -08:00
trop[bot]
8b5f26a9f0 Fix memory leak when using webFrame and spell checker (backport: 5-0-x) (#16851)
* fix: do not create native api::WebFrame in webFrame

When reloading a page without restarting renderer process (for example
sandbox mode), the blink::WebFrame is not destroyed, but api::WebFrame
is always recreated for the new page context. This leaves a leak of
api::WebFrame.

* fix: remove spell checker when page context is released
2019-02-08 15:33:03 -08:00
trop[bot]
c65e9079cc chore: make crash-reporter specs not use URL module (#16850) 2019-02-08 15:32:49 -08:00
trop[bot]
91a67e4867 fix: display empty menu item for non-visible submenus (backport: 5-0-x) (#16848)
* fix: display empty menu item for nonvisible submenus

* use Chromium UI string ID
2019-02-08 15:12:38 -08:00
trop[bot]
4079787378 fix: don't construct submenu if it's invisible (#16846) 2019-02-08 15:02:52 -08:00
trop[bot]
0dc9e32039 chore: add helper to wait for a window to load in a remote-safe way (#16841) 2019-02-08 13:26:02 -08:00
Roller Bot
28c7b346db chore: bump chromium in DEPS to 72.0.3626.102 (#16829) 2019-02-08 12:56:10 -08:00
Samuel Attard
c4f993add1 chore: disable get/setLoginItemSettings specs (#16838) 2019-02-08 12:54:11 -08:00
trop[bot]
bb21822c10 chore: add standalone function deprecation helper (#16833) 2019-02-08 12:09:38 -08:00
trop[bot]
124bb2910f chore: dont log 100000000 chars of URL (#16814) 2019-02-08 10:04:53 -08:00
trop[bot]
0f54df5867 chore: improve existing error preservation in promisify (backport: 5-0-x) (#16817)
* chore: improve existing error preservation in promisify

* add a spec
2019-02-08 07:56:59 -08:00
trop[bot]
2bd1a7ec1e docs: added webContents.getType() method (backport: 5-0-x) (#16787)
* docs: added webContents.getType() method

* docs: add enumeration of return value for webContents.getType()

* docs: getType() in WebContents should be class method not module method
2019-02-07 08:51:51 -08:00
trop[bot]
ee97b0864a chore: depend on mojo audio and video in BUILD.gn (#16789) 2019-02-06 11:37:10 -08:00
trop[bot]
96e0dfcae9 fix: make getUserMedia APIs work again on C72+ (backport: 5-0-x) (#16768)
* fix: resolve macos check for video and audio capture devices

* fix: resolve a minor compilation error
2019-02-06 08:14:23 -08:00
trop[bot]
379a7b707b build: ensure index.json is actually valid JSON before uploading (backport: 5-0-x) (#16751)
* build: ensure index.json is actually valid JSON before uploading

* chore: fix py linting for validation of index.json
2019-02-05 15:01:15 -08:00
trop[bot]
3963ee6d1d docs: we shouldn't promisify net apis (#16737) 2019-02-05 08:09:00 -08:00
Shelley Vohr
64cd5bf3a5 refactor: deprecate ServiceWorker APIs (#16732) 2019-02-04 21:33:38 -08:00
trop[bot]
05074bae0c fix: crash when calling setProgressBar on macOS (backport: 5-0-x) (#16728)
* fix: correctly check whether dock has progress bar

* fix: do not leak memory when setting dockTile
2019-02-04 20:56:57 -08:00
trop[bot]
174a39be8f chore: remove unused variable in removeWindow (#16724) 2019-02-04 20:55:46 -08:00
Shelley Vohr
918e3ce0b6 chore: backport updated release upload code (#16708) 2019-02-04 16:03:23 -08:00
trop[bot]
9c0eca1d8b chore: fix falsy comments edge case in release notes (#16723) 2019-02-04 15:02:29 -08:00
trop[bot]
26e0a7d922 feat: add window removeMenu() method (backport: 5-0-x) (#16657)
* feat: add window removeMenu() method

* chore: remove original method from docs and code

* retain backwards compatibility
2019-02-04 08:44:26 -08:00
Electron Bot
a498e0c033 Bump v5.0.0-beta.2 2019-02-03 08:46:03 -08:00
Shelley Vohr
0f66918825 Revert "build: hack around GitHub upload API failure / flake (#16665)"
This reverts commit 233d346d5a.
2019-02-03 08:44:35 -08:00
Shelley Vohr
050b866b6a Revert "Bump v5.0.0-beta.2"
This reverts commit 8115a899df.
2019-02-03 08:44:13 -08:00
Electron Bot
8115a899df Bump v5.0.0-beta.2 2019-02-02 20:52:53 -08:00
Shelley Vohr
3dcb7cfef9 Revert "ci: build mac on CircleCI (#16656)"
This reverts commit 16dfa56c77.
2019-02-02 20:51:24 -08:00
Shelley Vohr
502f24e50d Revert "Bump v5.0.0-beta.2"
This reverts commit 6ebef9d876.
2019-02-02 20:38:58 -08:00
Electron Bot
6ebef9d876 Bump v5.0.0-beta.2 2019-02-02 20:33:36 -08:00
Shelley Vohr
60af6c2791 feat: promisify cookies api (#16702)
* feat: promisify cookies api (#16464)

* feat: promisify the Cookie API

* chore: update specs to test promisified cookies

* chore: add deprecate wrapper for cookie callback API

* docs: update docs to cookie promise changes

* chore: remove redundant namespace use

* docs: improve cookie example

* docs: restore docs for cookie callback API

* chore: restore cookie callback tests

* fix: syntax of cookie promise return types

* fix: use new promisify helper
2019-02-02 18:55:41 -08:00
Shelley Vohr
6d76da55e2 feat: promisify contentTracing.getCategories() (#16583) (#16624)
* feat: promisify contentTracing.getCategories()

* deprecate contentTracing/getCategories
2019-02-01 17:46:09 -08:00
Shelley Vohr
b31057ca16 feat: promisify contentTracing recording APIs (#16584) (#16642)
* feat: promisify contentTracing.startRecording()

* feat: promisify contentTracing.stopRecording()

* test: convert specs for new promisified apis

* chore: deprecate and ensure legacy tests work
2019-02-01 12:31:33 -08:00
John Kleinschmidt
16dfa56c77 ci: build mac on CircleCI (#16656) 2019-02-01 14:19:35 -05:00
Shelley Vohr
a7ed504575 fix: deprecate promise functions properly (#16643) 2019-02-01 10:37:25 -08:00
trop[bot]
dc4c32972d Update menu.md (#16677) 2019-02-01 09:40:01 -08:00
trop[bot]
d1d0efbd07 fix: shutdown after message loop is ready (#16672) 2019-02-01 09:39:46 -08:00
trop[bot]
afa684ad45 docs: fix referrer typedef in OnCompletedDetails (#16675) 2019-02-01 09:39:15 -08:00
trop[bot]
f66d21e426 fix: show proper clerk notes in release notes script (backport: 5-0-x) (#16679)
* fix: Note detection in PR

* fix: 'BREAKING CHANGE' detection in PR body

* fix: when to include PRs that landed in other branches too

* fix: when available, use clerk's notes
2019-02-01 08:34:33 -08:00
trop[bot]
9a68ce87eb feat: add ELECTRON_DISABLE_SANDBOX env var (#16662) 2019-02-01 08:33:11 -08:00
Electron Bot
ecb737760c Revert "Bump v5.0.0-beta.2"
This reverts commit 5d32cd0269.
2019-02-01 08:02:29 -08:00
Electron Bot
5d32cd0269 Bump v5.0.0-beta.2 2019-02-01 07:52:08 -08:00
Shelley Vohr
499efd5ee7 Revert "Bump v5.0.0-beta.3"
This reverts commit a879981dfb.
2019-02-01 07:49:42 -08:00
Shelley Vohr
c4115ed783 Revert "Bump v5.0.0-beta.2"
This reverts commit 5be0851434.
2019-02-01 07:49:24 -08:00
trop[bot]
969a97b54f ci: Run Windows Electron tests first to show those failures first (backport: 5-0-x) (#16655)
* Run electron tests first to show those failures first

Enable logging on CI

* disable failing tests on Windows 32 bit

* Temporarily disable testing mksnapshot as that seems to hang
2019-01-31 19:23:37 -05:00
Electron Bot
5be0851434 Bump v5.0.0-beta.2 2019-01-31 15:51:42 -08:00
trop[bot]
233d346d5a build: hack around GitHub upload API failure / flake (#16665) 2019-01-31 15:50:16 -08:00
Electron Bot
a879981dfb Bump v5.0.0-beta.3 2019-01-31 14:08:49 -08:00
Electron Bot
3d90bd4e8e Revert "Bump v5.0.0-beta.2"
This reverts commit ba1dd09be2.
2019-01-31 12:14:07 -08:00
Electron Bot
ba1dd09be2 Bump v5.0.0-beta.2 2019-01-31 10:31:46 -08:00
trop[bot]
80aa832ebd chore: fix 'browserView' typo (#16644) 2019-01-31 12:13:01 -06:00
trop[bot]
a950e1d040 chore: Fix typo in AtomDownloadManagerDelegate::OnDownloadSaveDialogDone (#16650)
I believe the existing code was fine, but better be safe than sorry.
This typo was introduced in #16612.
2019-01-31 07:48:37 -08:00
trop[bot]
4d7ddcd750 fix: use async save dialog for anchor download attribute (#16640) 2019-01-31 16:16:34 +09:00
Nitish Sakhawalkar
d6612d230b chore: Move webFrame scheme privilege methods to main process (#16625)
* feat: move webFrame scheme privilege methods to main process (#16416)

* chore: deprecate webFrame.registerURLSchemeAsPrivileged

* Add register schemes protocol api

* update branch to enable browser process API

* Revert deprecation changes

* Fetch API support

* Updated api to take an array, still working on tests

* Update tests

* Remove web frame API

* Minor changes

* update scheme registrations on browser and renderer process

* fix: enable ses.getBlobData spec

* Update breaking changes doc

* fix: update docs for protocol API (#16601)

* fix: update docs for protocol API

* upddate source for new attribute name

* update electron-typescript-definitions package
2019-01-30 14:57:20 -08:00
trop[bot]
1d9abfdb10 fix: expose aes-cfb ciphers from boringssl (#16618)
Ref #16195
2019-01-30 14:17:07 -08:00
trop[bot]
871ba507a6 fix: enable and update osr (backport: 5-0-x) (#16616)
* fix: enable OSR

* fix some macos errors

* fix client reset not in guard

* fix things not rendering on mac
2019-01-30 12:18:06 -08:00
trop[bot]
5d64df141b fix: don't forward IPC filtering events to app for dev-tools and extensions (#16613) 2019-01-30 09:58:05 -08:00
trop[bot]
ae846204cb docs: remove nonexistent contentTracing methods (#16614) 2019-01-30 08:51:59 -08:00
trop[bot]
6dcf5c5c79 fix: execute session preload scripts in sandboxed renderers (#16578) 2019-01-30 08:23:48 -08:00
trop[bot]
e55a9b35b6 fix: check process.isMainFrame in sandboxed_renderer/init.js (#16533) 2019-01-29 21:10:53 -08:00
Nitish Sakhawalkar
ae85864959 fix: correctly destroy spellcheck client (#16525)
* fix: Destroy spellcheck client

* Address review comments
2019-01-29 15:59:57 -08:00
trop[bot]
5cc0539919 fix: expose ripemd160 hash from boringssl (#16572)
Ref #16195
2019-01-29 15:58:24 -08:00
trop[bot]
b070774f5c fix: registerStreamProtocol callback with large chunks (backport: 5-0-x) (#16553) 2019-01-28 14:07:14 -08:00
trop[bot]
7a8548d48f docs: cancel is optional in OnHeadersReceivedResponse (#16549) 2019-01-25 09:48:50 -08:00
Electron Bot
ac172abda7 Bump v5.0.0-beta.1 2019-01-22 14:11:16 -08:00
Samuel Attard
29e5195c63 build: fix version bump script for first beta 2019-01-22 14:09:10 -08:00
Samuel Attard
3926d9d717 chore: reset npm version to 5.0.0-beta.0 2019-01-22 13:32:32 -08:00
Jeremy Apthorp
fd8b9450ee test: untangle a chromium-spec test (#16456) 2019-01-22 13:26:32 -08:00
John Kleinschmidt
34ac68c4a8 ci: Update build timeouts (#16492)
* Update timeout for native_mksnapshot and use bigger machines

* Revert "build: temporarily disable arm to unblock nightlies (#16479)"

This reverts commit 51961fccfa.
2019-01-22 16:14:01 -05:00
Samuel Attard
f3e30c7ae3 Merge remote-tracking branch 'origin/chromium-upgrade/72' 2019-01-22 12:01:18 -08:00
Samuel Attard
0b85fb7ea2 Revert "feat: upgrade to Chromium 72.0.3626.52 (#16334)"
This reverts commit 1918e76913.
2019-01-22 12:01:04 -08:00
Samuel Attard
58a6fe13d6 feat: preloads and nodeIntegration in iframes (#16425)
* feat: add support for node / preloads in subframes

This feature has delibrately been built / implemented in such a way
that it has minimum impact on existing apps / code-paths.
Without enabling the new "nodeSupportInSubFrames" option basically none of this
new code will be hit.

The things that I believe need extra scrutiny are:

* Introduction of `event.reply` for IPC events and usage of `event.reply` instead of `event.sender.send()`
* Usage of `node::FreeEnvironment(env)` when the new option is enabled in order to avoid memory leaks.  I have tested this quite a bit and haven't managed to cause a crash but it is still feature flagged behind the "nodeSupportInSubFrames" flag to avoid potential impact.

Closes #10569
Closes #10401
Closes #11868
Closes #12505
Closes #14035

* feat: add support preloads in subframes for sandboxed renderers

* spec: add tests for new nodeSupportInSubFrames option

* spec: fix specs for .reply and ._replyInternal for internal messages

* chore: revert change to use flag instead of environment set size

* chore: clean up subframe impl

* chore: apply suggestions from code review

Co-Authored-By: MarshallOfSound <samuel.r.attard@gmail.com>

* chore: clean up reply usage

* chore: fix TS docs generation

* chore: cleanup after rebase

* chore: rename wrap to add in event fns
2019-01-22 11:24:46 -08:00
Jeremy Apthorp
92b9525cfd feat: enable mixed-sandbox mode by default (#15894) 2019-01-22 10:44:28 -08:00
Jeremy Apthorp
1918e76913 feat: upgrade to Chromium 72.0.3626.52 (#16334) 2019-01-22 10:39:32 -08:00
Samuel Attard
ff9b23ebe5 fix: dont run window-setup on chrome:// protocol, introduced in b965e54efc (#16489) 2019-01-22 10:32:18 -08:00
John Kleinschmidt
c0f6a44e39 Try longer timeout on electron build 2019-01-22 10:32:07 -08:00
Cheng Zhao
3828e2a53a backport patch to fix arm64 build of swiftshader 2019-01-22 10:32:07 -08:00
Cheng Zhao
be69192a61 backport patch to fix compilation error in test 2019-01-22 10:32:07 -08:00
Jeremy Apthorp
8c1b5311fd robustify async webview test 2019-01-22 10:32:06 -08:00
Jeremy Apthorp
6d4480ea6b feat: allow setting autoplayPolicy in webPreferences (#16396) 2019-01-22 10:32:06 -08:00
Cheng Zhao
1fe4b3fa28 fix: add patch to disable dcheck in inter_process_time_ticks_converter.cc
I'm seeing crashes on Windows when runnings tests for serviceWorker, the
reason why the dcheck failed is unclear.
2019-01-22 10:32:06 -08:00
Jeremy Apthorp
f115376595 fix: remove pretarget handler before window destruction 2019-01-22 10:32:06 -08:00
deepak1556
8122dd2c33 backport v8 patch for linker issue in windows testing builds 2019-01-22 10:32:06 -08:00
deepak1556
d2c0f9f754 Implicitly bypass localhost when proxying requests.
https://chromium-review.googlesource.com/c/chromium/src/+/1303626
2019-01-22 10:32:06 -08:00
Cheng Zhao
03d499bf34 fix: detach webview instead of destroying it
Chromium no longer cleans up everything when a guest webcontents is
destroyed, we have to force detaching it and let Chromium destroy everything.
2019-01-22 10:32:06 -08:00
Jeremy Apthorp
5e043812ef fix HandleKeyboardEvent merge failure 2019-01-22 10:32:06 -08:00
Jeremy Apthorp
7764ca7209 add missing include for l10n_util.h on win 2019-01-22 10:32:06 -08:00
Jeremy Apthorp
ded316cd5e wait for window to be focused in openDevTools test 2019-01-22 10:32:06 -08:00
Jeremy Apthorp
4b45a5fc6d roll node
to pick up libuv compile fix on windows
2019-01-22 10:32:06 -08:00
Jeremy Apthorp
078d518e36 add missing //components/feature_engagement dep needed for color_chooser_aura 2019-01-22 10:32:06 -08:00
Jeremy Apthorp
212d858bf4 set autoplay policy to no-user-gesture-required by default 2019-01-22 10:32:06 -08:00
Jeremy Apthorp
3faf2480e0 update dom storage quota patch
https://chromium-review.googlesource.com/c/chromium/src/+/1166218/
2019-01-22 10:32:06 -08:00
Jeremy Apthorp
55d5b02f87 include glib.h in atom_main_delegate
it was complaining about 'undeclared identifier 'TRUE''
2019-01-22 10:32:06 -08:00
Jeremy Apthorp
8fa33ba120 disable visibilitychange tests as the functionality is broken upstream
https://crbug.com/920839
2019-01-22 10:32:06 -08:00
deepak1556
826f1cb90c Move the base/sys_info* files to base/system/
https://chromium-review.googlesource.com/c/chromium/src/+/1327441
2019-01-22 10:32:05 -08:00
deepak1556
ed5a865efb Update GetAccessibleName() in view::ImageView and view::Button
https://chromium-review.googlesource.com/c/chromium/src/+/1256308
2019-01-22 10:32:05 -08:00
deepak1556
90b6d13714 Remove menu_marker from MenuButton.
https://chromium-review.googlesource.com/c/chromium/src/+/1324375
2019-01-22 10:32:05 -08:00
deepak1556
85333a5974 Move ViewsDelegate::NotifyAccessibilityEvent to an observer pattern
https://chromium-review.googlesource.com/c/chromium/src/+/1352265
2019-01-22 10:32:05 -08:00
deepak1556
5f941c5180 Remove CR_DEFINE_STATIC_LOCAL
https://bugs.chromium.org/p/chromium/issues/detail?id=893317
2019-01-22 10:32:05 -08:00
deepak1556
06a5ade3c6 fixup! Use strong ownership for attached inner WebContents 2019-01-22 10:32:05 -08:00
deepak1556
374406375b Add interface and Mac implementation for responsiveness::NativeEventObserver.
https://chromium-review.googlesource.com/c/chromium/src/+/1157235/
2019-01-22 10:32:05 -08:00
deepak1556
4089620729 fix: Initialize resource bundle for the browser process earlier 2019-01-22 10:32:05 -08:00
deepak1556
1de0152b6b chore: fix gn format error 2019-01-22 10:32:05 -08:00
Jeremy Apthorp
94246d428b resource_coordinator_parts stub in BrowserProcessImpl
https://chromium-review.googlesource.com/c/1324134
2019-01-22 10:32:05 -08:00
Jeremy Apthorp
3b88dd6ef7 tts was migrated to content
https://chromium-review.googlesource.com/c/1341154

https://chromium-review.googlesource.com/c/1351806

https://chromium-review.googlesource.com/c/1352055
2019-01-22 10:32:05 -08:00
Jeremy Apthorp
2cbf3080d0 Make webkitRelativePath interoperable
https://chromium-review.googlesource.com/c/1325579
2019-01-22 10:32:05 -08:00
Jeremy Apthorp
d0621db8fd Remove ResourceContext::GetRequestContext since it's no longer used.
https://chromium-review.googlesource.com/c/1352035
2019-01-22 10:32:05 -08:00
Jeremy Apthorp
6f9ff39728 CORS -> Cors
https://chromium-review.googlesource.com/c/1333018
2019-01-22 10:32:05 -08:00
Jeremy Apthorp
a64cf5514f move pdf_compositor off ServiceContext/ServiceTest
https://chromium-review.googlesource.com/c/1343506
2019-01-22 10:32:05 -08:00
Jeremy Apthorp
93fbb6c092 remove name parameter from AllowIndexedDB
https://chromium-review.googlesource.com/c/1306914
2019-01-22 10:32:04 -08:00
Jeremy Apthorp
600c3f2c2f StoragePartition::ClearData no longer takes an OriginMatcher
https://chromium-review.googlesource.com/c/1162172
2019-01-22 10:32:04 -08:00
Jeremy Apthorp
deff96a1b0 NativeWidgetMac::CreateNSWindow params changed
https://chromium-review.googlesource.com/c/1295251
2019-01-22 10:32:04 -08:00
Jeremy Apthorp
b03daaebe4 ChildProcessData.{GetHandle() => GetProcess().GetHandle()}
https://chromium-review.googlesource.com/c/1298345
2019-01-22 10:32:04 -08:00
Jeremy Apthorp
4ddd337a64 CurrentProcessInfo::CreationTime -> Process::Current().CreationTime()
https://chromium-review.googlesource.com/c/1280642
2019-01-22 10:32:04 -08:00
Jeremy Apthorp
a64a0fa88e remove ipc/struct_destructor_macros.h
https://chromium-review.googlesource.com/c/1261082
2019-01-22 10:32:04 -08:00
Jeremy Apthorp
c0cf065c1a REVIEW: Use strong ownership for attached inner WebContents
https://chromium-review.googlesource.com/c/1301843
2019-01-22 10:32:04 -08:00
Jeremy Apthorp
96b2623887 replace base::AssertBlockingAllowed with base::ScopedBlockingCall
https://chromium-review.googlesource.com/c/1278540
2019-01-22 10:32:04 -08:00
Jeremy Apthorp
e0d277e667 CopyNSImage was removed
https://chromium-review.googlesource.com/c/1333876
2019-01-22 10:32:04 -08:00
Jeremy Apthorp
485bbd9ccb ContentRulesetService -> RulesetService
https://chromium-review.googlesource.com/c/1294299
2019-01-22 10:32:04 -08:00
Jeremy Apthorp
d228bdfb9e gfx::NativeView is no longer NSView on mac
https://chromium-review.googlesource.com/c/1270343
2019-01-22 10:32:04 -08:00
Jeremy Apthorp
70887ae21a extra parameters to BrowserClient::HandleExternalProtocol
https://chromium-review.googlesource.com/c/1318976
2019-01-22 10:32:04 -08:00
Jeremy Apthorp
96f9611cf4 GetCachePath replaced with GetGeneratedCodeCacheSettings
https://chromium-review.googlesource.com/c/1301973

https://chromium-review.googlesource.com/c/chromium/src/+/1213093
2019-01-22 10:32:04 -08:00
Jeremy Apthorp
ef80cc3d56 base/sys_info.h -> base/system/sys_info.h
https://chromium-review.googlesource.com/c/1327441
2019-01-22 10:32:04 -08:00
Jeremy Apthorp
0d9de7deaf blink::WebReferrerPolicy -> network::mojom::ReferrerPolicy
https://chromium-review.googlesource.com/c/chromium/src/+/1212345
2019-01-22 10:32:04 -08:00
Jeremy Apthorp
96ca070c3a less const in WebContents
https://chromium-review.googlesource.com/c/1349466
2019-01-22 10:32:03 -08:00
Jeremy Apthorp
8948e27ced ScopedNestableTaskAllower in MessageLoopCurrent
https://chromium-review.googlesource.com/c/chromium/src/+/1020288
2019-01-22 10:32:03 -08:00
Jeremy Apthorp
30e5e993c1 HandleKeyboardEvent returns bool
https://chromium-review.googlesource.com/c/chromium/src/+/1262404
2019-01-22 10:32:03 -08:00
Jeremy Apthorp
fd7b49b32b remove OnAreExperimentalCookieFeaturesEnabled
https://chromium-review.googlesource.com/c/1287209
2019-01-22 10:32:03 -08:00
Jeremy Apthorp
d36a6de25c OnCanEnablePrivacyMode -> OnForcePrivacyMode
https://chromium-review.googlesource.com/c/1343051
2019-01-22 10:32:03 -08:00
Jeremy Apthorp
d01db5a656 migrate to non-deprecated v8 functions
https://bugs.chromium.org/p/v8/issues/detail?id=8238

https://bugs.chromium.org/p/v8/issues/detail?id=7295

https://chromium-review.googlesource.com/c/v8/v8/+/1352273
2019-01-22 10:32:03 -08:00
Jeremy Apthorp
7d5cd2051a update boringssl patches 2019-01-22 10:32:03 -08:00
Jeremy Apthorp
95ed3238be update v8 patches 2019-01-22 10:32:03 -08:00
Jeremy Apthorp
02e41b41b2 roll Chrome to 72.0.3626.52 and update patches 2019-01-22 10:32:03 -08:00
Electron Bot
cd25ddeb06 Bump v5.0.0-nightly.20190122 2019-01-22 08:55:08 -08:00
Shelley Vohr
7df531bc4e build: fix release asset download for now (#16486) 2019-01-22 08:53:52 -08:00
Milan Burda
6cba2c50a2 feat: make ipc-message and ipc-message-sync events public (#16468) 2019-01-22 08:47:58 -08:00
Milan Burda
dbc5f67dca docs: fix web-request.md listener signatures in electron.d.ts (#16485) 2019-01-22 08:46:40 -08:00
Milan Burda
7d71ad6f91 fix: takeHeapSnapshot() using public IPC channel for internal implementation (#16480) 2019-01-22 17:32:24 +09:00
Milan Burda
0e27f133d7 refactor: delete atom_api_renderer_ipc.h (#16481) 2019-01-21 22:31:37 -08:00
Milan Burda
b965e54efc fix: <webview> not working with contextIsolation + sandbox (#16469) 2019-01-22 10:08:16 +09:00
Matthew Leffler
a9ac75c1f9 docs: Fix TouchBar API example (#16482) 2019-01-21 17:07:47 -08:00
Electron Bot
033efdcaa1 Bump v5.0.0-nightly.20190121 2019-01-21 15:28:16 -08:00
Shelley Vohr
51961fccfa build: temporarily disable arm to unblock nightlies (#16479) 2019-01-21 15:22:56 -08:00
Cheng Zhao
ac65f38842 fix: prevent double-destroy of window (#16472) 2019-01-21 14:56:30 -08:00
Samuel Attard
0b0679e065 build: auto-fix linting issues on commit (#16466)
* build: auto-fix formatting during commit

* use lint-staged as precommit hook to autofix issues
2019-01-21 14:46:32 -08:00
Shelley Vohr
3ca87d205f feat: make zoomLevel/zoomFactor sync (#16410)
* feat: make zoomLevel/zoomFactor sync

* update ts defs dep
2019-01-20 23:40:27 -08:00
Electron Bot
dacf7f8bdc Revert "Bump v5.0.0-nightly.20190119"
This reverts commit 2cca0f9bb7.
2019-01-19 21:14:06 -08:00
Electron Bot
2cca0f9bb7 Bump v5.0.0-nightly.20190119 2019-01-19 19:52:39 -08:00
Shelley Vohr
441c9ce376 feat: promisify desktopCapturer.getSources (#16427)
* feat: promisify desktopCapturer.getSources

* fix doc

* fix docs lint error
2019-01-18 15:29:32 -08:00
Electron Bot
902c239fdf Revert "Bump v5.0.0-nightly.20190118"
This reverts commit 9e6726f304.
2019-01-18 15:21:39 -08:00
Electron Bot
9e6726f304 Bump v5.0.0-nightly.20190118 2019-01-18 15:21:39 -08:00
Electron Bot
329d45562b Revert "Bump v5.0.0-nightly.20190118"
This reverts commit 83b44b735f.
2019-01-18 14:12:13 -08:00
Electron Bot
83b44b735f Bump v5.0.0-nightly.20190118 2019-01-18 14:12:01 -08:00
Shelley Vohr
3417c42bfd chore: always try to nuke tags (#16451) 2019-01-18 14:00:15 -08:00
Electron Bot
7f4064af16 Revert "Bump v5.0.0-nightly.20190118"
This reverts commit ace11f9bc8.
2019-01-18 13:42:51 -08:00
Electron Bot
ace11f9bc8 Bump v5.0.0-nightly.20190118 2019-01-18 13:42:51 -08:00
Electron Bot
cd91440e47 Revert "Bump v5.0.0-nightly.20190118"
This reverts commit 5e5c71e1d7.
2019-01-18 12:46:16 -08:00
Electron Bot
5e5c71e1d7 Bump v5.0.0-nightly.20190118 2019-01-18 12:32:29 -08:00
Milan Burda
7d4a1223fd feat: add preload-error event to webContents (#16411) 2019-01-18 12:03:43 +01:00
Jeremy Apthorp
98d0daa2fd chore: remove unused osfhandle hack (#16305) 2019-01-17 15:58:47 -08:00
Shelley Vohr
f105c84349 test: ensure legacy callback functions work (#16436)
* test: test legacy callback functions

* add TODO removal comments

* fix callback spec
2019-01-17 14:17:16 -08:00
Shelley Vohr
720197f9c8 fix: correctly handle IPC for promise-based methods (#16433) 2019-01-17 12:08:54 -08:00
Milan Burda
4d0b2ac9be docs: fix promisification.md formatting (#16434) 2019-01-17 09:30:32 -08:00
Shelley Vohr
1f2b02c18f feat: promisify protocol.isProtocolHandled() (#16423)
* feat: promisify protocol

* fix base::Bind and specs

* update documentation

* make callback-compatible

* async awaitify tests
2019-01-17 09:05:10 -08:00
Electron Bot
32d98851bc Revert "Bump v5.0.0-nightly.20190116"
This reverts commit 82fc099602.
2019-01-16 11:28:09 -08:00
Electron Bot
82fc099602 Bump v5.0.0-nightly.20190116 2019-01-16 11:04:22 -08:00
SamvelRaja
34c1727cb3 docs: fix typo in build instructions for windows (#16414) 2019-01-15 21:58:39 -08:00
Milan Burda
23d44e322d feat: use default-app behavior in packaged apps (#16310)
Unify the behavior between default app and packaged apps:
- create default application menu unless the app has one
- default window-all-closed handling unless the app handles the event
2019-01-15 21:35:53 +01:00
Shelley Vohr
8e2ab8b20b refactor: promise_util promise creation (#16401)
* refactor: promise_util creation

* enter correct contexts on resolve/reject

* return Local in helper

* set context correctly

* forgot one
2019-01-15 09:54:59 -08:00
Mosh Feu
05755ba202 docs: show the code of adding devtools extension (#16186) 2019-01-15 17:48:21 +09:00
Shelley Vohr
0881fd6397 feat: split openExternal into sync and async (#16176)
* feat: split openExternal into sync and async

* v8::Locker => mate::Locker

* fix: enter js env when resolving promise
2019-01-14 20:35:21 -08:00
Milan Burda
52e257668d fix: windowmenu did not show the window list on macOS (#16387) 2019-01-14 17:27:52 +01:00
Shelley Vohr
df62e78b71 chore: remove unused deps (#16373) 2019-01-12 16:47:09 +01:00
Alex Garbutt
dcb670fa46 fix: emit IPC event in correct context if isolation and sandbox enabled (#16352)
* fix: emit IPC event in correct context if isolation and sandbox enabled

IPC events were not being delivered to renderer processes when both
`contextIsolation` and `sandbox` were enabled. This is because the
`AtomSandboxedRenderFrameObserver` class was incorrectly using the
`MainWorldScriptContext`, rather than conditionally selecting the
context based on if isolation was enabled.

Fixes #11922
2019-01-12 14:19:20 +01:00
Electron Bot
134792a594 Revert "Bump v5.0.0-nightly.20190111"
This reverts commit 71f542d8f6.
2019-01-11 21:40:55 -08:00
Electron Bot
71f542d8f6 Bump v5.0.0-nightly.20190111 2019-01-11 21:18:40 -08:00
Robo
52fe92d02e feat: Upgrade to Chromium 71.0.3578.98 (#15966) 2019-01-11 17:00:43 -08:00
Electron Bot
92ddfd0d4c Revert "Bump v5.0.0-nightly.20190111"
This reverts commit c81c9ee2b4.
2019-01-11 12:35:25 -08:00
Electron Bot
c81c9ee2b4 Bump v5.0.0-nightly.20190111 2019-01-11 11:40:15 -08:00
Shelley Vohr
fc169221be Revert "Bump v5.0.0-nightly.20190111"
This reverts commit c43a61c576.
2019-01-11 11:38:26 -08:00
Electron Bot
c43a61c576 Bump v5.0.0-nightly.20190111 2019-01-11 10:01:46 -08:00
Electron Bot
c4e4f085dd Revert "Bump v5.0.0-nightly.20190111"
This reverts commit 088f936dab.
2019-01-11 09:55:58 -08:00
Electron Bot
088f936dab Bump v5.0.0-nightly.20190111 2019-01-11 09:54:46 -08:00
Shelley Vohr
e2b1394ad1 redo: size -> length (#16370) 2019-01-11 09:53:13 -08:00
Alexey Kuzmin
3cb9aadb80 build: fix the build with enable_run_as_node disabled (#15711) 2019-01-11 08:02:06 -08:00
Shelley Vohr
ca218b6395 test: allow retries for flaky mas loginitem specs (#16347) 2019-01-10 14:15:47 -08:00
Charles Kerr
52852b963a fix: beep on Ubuntu (#16350)
beeps on Linux are made by writing BEL to /dev/console,
which requires elevated permissions on Ubuntu. So if
opening /dev/console fails, fall back to /dev/tty.
2019-01-10 13:43:07 -08:00
Shelley Vohr
d0ae89befa chore: fix tag cleanup (#16353) 2019-01-10 13:42:42 -08:00
Charles Kerr
2acf9ac72f fix: improve release notes (#16343)
* fix: use version name in release notes

* fix: omit previously-released notes

* fix: sniff semantic commit types from PR subjects

instead of only from commit messages

* fix: do not use unrecognized semantic commit types

* chore: do not hardcode Release-Notes comment text

It used to be '<!-- One-line Change Summary Here-->',
it's currently a link to a best-practices page, and
it'll probably change again in the future. Let's just
match on <!--.*--> instead.

* chore: copyedit the help page

* chore: use clerk's OMIT_FROM_RELEASE_NOTES_KEYS

* chore: tweak comments

* chore: rename 'breaks' property as 'breaking'
2019-01-10 14:01:38 -06:00
Milan Burda
102d8fe506 chore: add 'use strict' to default app sources (#16346) 2019-01-10 20:54:34 +01:00
Electron Bot
2ee59cc82c Revert "chore: s/size/length (#16351)"
This reverts commit 03e16ffa57.
2019-01-10 11:04:31 -08:00
Shelley Vohr
03e16ffa57 chore: s/size/length (#16351) 2019-01-10 10:58:23 -08:00
Jeremy Apthorp
782825fc29 fix: return after handling Esc for fullscreen in WebContentsDelegate (#16342) 2019-01-10 11:03:48 -05:00
Electron Bot
0299328521 Bump v5.0.0-nightly.20190110 2019-01-10 07:59:58 -08:00
Milan Burda
eb02a422de feat: add fileMenu / viewMenu / appMenu roles (#16328) 2019-01-10 14:32:03 +01:00
Electron Bot
72af4941f8 Bump v5.0.0-nightly.20190109 2019-01-09 21:43:29 -08:00
Michelle Tilley
744f737cba fix: properly determine if WebContents is offscreen in WebContentsDelegate (#16329) 2019-01-09 09:55:45 -08:00
Shelley Vohr
f72d5a4184 chore: fix electron.d.ts file upload (#16335) 2019-01-08 22:51:49 -08:00
Electron Bot
17d2467932 Revert "Bump v5.0.0-nightly.20190108"
This reverts commit 241baf77f1.
2019-01-08 20:46:56 -08:00
Electron Bot
241baf77f1 Bump v5.0.0-nightly.20190108 2019-01-08 18:11:20 -08:00
Shelley Vohr
b4299a2872 chore: pass dryRun arg correctly (#16333)
* chore: pass dryRun arg correctly

* no log
2019-01-08 18:09:42 -08:00
Electron Bot
45baaeaf2c Revert "Bump v5.0.0-nightly.20190108"
This reverts commit 1fd7a4bfab.
2019-01-08 16:30:25 -08:00
Electron Bot
1fd7a4bfab Bump v5.0.0-nightly.20190108 2019-01-08 16:22:33 -08:00
Shelley Vohr
826063a2f7 chore: github => octokit in release notes (#16332) 2019-01-08 16:20:54 -08:00
Milan Burda
349a3c20ae feat: add additional remote APIs filtering (#16293) 2019-01-08 14:27:56 -08:00
Mark Lee
6436a12d7f docs: fix app.setAppUserModelId link (#16322) 2019-01-08 16:40:57 -05:00
Shelley Vohr
000be5d1d4 chore: refactor scripts for octokit update (#16284)
* chore: refactor scripts for octokit

* update release script

* update more octokit scripts

* cleanup

* remove unecessary refactor

* fixup package lock
2019-01-08 12:05:58 -08:00
Shelley Vohr
434f1368a0 test: add specs to version bump utils (#16315) 2019-01-08 12:04:27 -08:00
Vik Ramanujam
668049a593 Add instructions to get Notifications working on Win 10 Update (#16320)
Fails silently and was frustratingly hard to know why. Hope this save a lot of people some time.
2019-01-08 08:16:30 -08:00
Milan Burda
5c250455ad refactor: pass isWebViewTagEnabled via ELECTRON_BROWSER_SANDBOX_LOAD (#16238) 2019-01-08 10:12:34 +01:00
Shelley Vohr
791d6de8b0 chore: fix json parsing for npm publish (#16318) 2019-01-07 20:37:44 -08:00
Jeremy Apthorp
a3e5173c47 Merge pull request #16203 from electron/alkuzmin/add-external-binaries-config
build: extract external binaries config
2019-01-07 17:37:53 -08:00
Shelley Vohr
b71a5a5955 fix: register accelerator if role has no registerAccelerator (#16309)
* fix: register accelerator if role has no registerAccelerator

* ensure roles[role].registerAccelerator  is defined
2019-01-07 16:01:03 -08:00
Shelley Vohr
30c670bd83 chore: release notes should be an object (#16313) 2019-01-07 16:00:36 -08:00
Electron Bot
596c0a8672 Bump v5.0.0-nightly.20190107 2019-01-07 13:47:13 -08:00
Shelley Vohr
2ac677228d chore: fix pre passing to atom.rc (#16311)
* chore: fix pre passing to versionH

* preTypes => preType
2019-01-07 13:41:07 -08:00
Electron Bot
ff1c90b638 Revert "Bump v5.0.0-nightly.20190107"
This reverts commit 90f23c187f.
2019-01-07 13:14:41 -08:00
Electron Bot
90f23c187f Bump v5.0.0-nightly.20190107 2019-01-07 12:26:08 -08:00
Shelley Vohr
854443a291 chore: trim output of branch correctly (#16307) 2019-01-07 12:24:18 -08:00
Shelley Vohr
9c7f6affc2 Revert "ci: use config version 2.1 on CircleCI (#15665)" (#16304)
This reverts commit 0c46a7a4d9.
2019-01-07 11:59:45 -08:00
Milan Burda
fade3eb679 chore: make "nodeIntegration" and "webviewTag" default to false (#16235) 2019-01-07 22:19:27 +03:00
Electron Bot
cdf4bfa68f Revert "Bump v4.0.0-nightly.20190107"
This reverts commit f8614ab019.
2019-01-07 09:17:17 -08:00
Electron Bot
f8614ab019 Bump v4.0.0-nightly.20190107 2019-01-07 09:17:04 -08:00
Milan Burda
6f117b8e0c feat: add app.commandLine.hasSwitch() / app.commandLine.getSwitchValue() (#16282)
* feat: add app.commandLine.hasSwitch() / app.commandLine.getSwitchValue()

* add more tests

* refactor: move appendSwitch / appendArgument to command_line module

* replace AppendSwitchASCII with AppendSwitchNative

* remove castArgs
2019-01-07 07:48:27 -08:00
Aleksei Kuzmin
dee964e0fe build: extract external binaries config 2019-01-07 10:44:08 +01:00
Keshal Desai
5957ede41a fix: update license year (#16287) 2019-01-05 12:53:20 -08:00
Jeremy Apthorp
959c7a76e9 Merge pull request #16252 from electron/miniak/guest-view-manager
fix: security: improve IPC validation in guest-view-manager
2019-01-04 16:47:27 -08:00
Milan Burda
a0cdcc5f8d security: improve IPC validation in guest-view-manager 2019-01-05 00:06:47 +01:00
Shelley Vohr
9cc3fbabf7 chore: @electron/nightly => electron-nightly (#16273) 2019-01-04 13:48:02 -08:00
Michelle Tilley
3db691d693 chore: add additional logging during asset upload (#16279) 2019-01-04 13:14:41 -08:00
Shelley Vohr
c1ca8476f8 chore: result => result.data (#16274)
* chore: result.draft => result.data.draft

* also result.id
2019-01-04 11:26:14 -08:00
Kilian Valkhof
21d1849723 Update browser-window.md with alpha hex formatting (#16269)
HEX with alpha can be #RRGGBBAA or #AARRGGBB. In Electron it's the latter. It's nice to explicitly state that, so others wont have to try twice like me :).
2019-01-04 10:33:12 -08:00
John Kleinschmidt
50010934d1 docs: Update reference to xcode 8.3.3 (#16267)
* Update reference to xcode

* Update to reflect use of 10.12 SDK
2019-01-04 13:05:12 -05:00
Jeremy Apthorp
849dd0db64 fix: correctly pass hidden-page argument to isolated renderers (#16258) 2019-01-04 08:25:47 -08:00
Shelley Vohr
de0e4735de fix: error if a11y support changed before ready (#16261) 2019-01-04 10:20:06 -05:00
Tyler Saballus
2117524102 Fix typos in app.md (#16260)
Mostly added commas to prepositions that occur in the predicate. There was a misspelling and a few run-on sentences as well though.
2019-01-04 10:18:15 -05:00
Shelley Vohr
876064036d fix: don't register some shortcuts without accessibility (#16125)
Fixed crash on macOS when using globalShortcut for media keys when accessibility access is not granted.
2019-01-03 20:40:17 -08:00
Shelley Vohr
b57046e67d feat: add mac support to systemPrefs.getColor() (#16249) 2019-01-03 16:17:07 -08:00
Shelley Vohr
03892153de feat: expose systemPreferences.getSystemColor() (#16248) 2019-01-03 14:30:38 -08:00
Shelley Vohr
439ba5116f feat: add mac support to systemPrefs.getAccentColor() (#16251)
* feat: add mac support to systemPrefs.getAccentColor()

* note 10.14 retriction
2019-01-03 13:24:55 -08:00
Michelle Tilley
5c378de22f chore: add link to clerk readme to PR checklist (#16253) 2019-01-03 10:59:07 -08:00
Milan Burda
3f1d22759a refactor: use helpers for command-line parsing in renderer/init.js (#16239) 2019-01-03 11:22:34 -05:00
Shelley Vohr
baaeb7cece chore: update deprecated LSGetApplicationForURL (#16180)
* chore: update deprecated LSGetApplicationForURL

* wrap with @available
2019-01-02 15:20:32 -08:00
Samuel Attard
eb8dc6b675 chore: publish nightlies to electron-nightly (#15938)
* chore: publish nightlies to electron-nightly

* electron-nightly => @electron/nightly
2019-01-02 11:04:56 -08:00
Cheng Zhao
a5e63dc5fd fix: don't expose isolatedWorld to global (#16208) 2018-12-28 10:54:32 +09:00
Vladimir
5ae3d1a1b2 feat: add multi BrowserView support to BrowserWindow (#16148)
* feat: add multi BrowserView support to BrowserWindow

Add functions addBrowserView, removeBroserView, getBrowserViews to
BrowserWindow class. Existing API as setBrowserView and
getBrowserView code replaced to use new api inside.

* fix: for lint and osx compile errors

* fix: lint error in test code

* feat: add multi BrowserView support to BrowserWindow

Add functions addBrowserView, removeBroserView, getBrowserViews to
BrowserWindow class. Existing API as setBrowserView and
getBrowserView code replaced to use new api inside.

* fix: for lint and osx compile errors

* fix: lint error in test code

* fix: method to be accessible on mac api impl

* fix: missed function declarations for mac impl

* fix: use base class reset function
2018-12-22 10:49:26 +09:00
Shelley Vohr
18ca4b6a3a chore: update @types/node dep (#16174) 2018-12-21 12:59:42 -05:00
Zac Walker
51cfb5cff1 fix: extend tracing startRecording API to take a full tracing config (#13914)
This allows memory-infra to be traced correctly.
Fixes #12506.
2018-12-20 15:11:17 +03:00
Cheng Zhao
4ff7976060 fix: add missing require in chromium-spec (#16153) 2018-12-20 16:58:46 +09:00
Shelley Vohr
90d314cc3b chore: make nugget quiet by default (#16147)
* chore: make nugget quiet by default

* chore: allow nugget quiet to be passed via cli
2018-12-19 20:36:01 -07:00
Milan Burda
547097b036 security: allow to block desktopCapturer.getSources() calls (#15964)
* security: allow to block desktopCapturer.getSources() calls

* return empty instead of error

* fix: release resources of DesktopCapturer on exit
2018-12-20 11:44:30 +09:00
Charles Kerr
df0381e76c feat: add option to generate explicit URLs in the release notes (#16126) 2018-12-19 08:48:01 -07:00
Mosh Feu
ddc38eda26 docs: specify "role" types for "menu-item" (#16129) 2018-12-19 09:39:35 -05:00
Pedro Pontes
9c783f53ba fix: do not allow the window to grab focus when tabbing / shift+tabbing (#16042)
* fix: do not allow the window to grab focus when tabbing / shift+tabbing

* test: add tests.
2018-12-18 23:44:51 -07:00
Jeremy Apthorp
ed3e5739dc test: promisify a bunch of tests (#16051)
* test: promisify a bunch of tests

* fix lint

* fix affinity tests

* more cowbell^Wawait

* less done
2018-12-18 23:44:03 -07:00
David Baker
cc85946f55 feat: Support response headers in File protocol handler (#16098)
* feat: Support response headers in File protocol handler

* bugfix: Null check headers value & fix tests

* refactor: Use non-deprecated FindKeyOfType
2018-12-18 23:17:02 -07:00
Jeremy Apthorp
03f876470e docs: note that visual zoom is disabled by default (#16130) 2018-12-18 20:40:42 -07:00
Shelley Vohr
5cc4a30207 chore: release.id => release.data.id (#16132) 2018-12-18 19:51:38 -07:00
Shelley Vohr
a58d989b60 feat: expose app accessibility status api (#16119)
* feat: expose app accessibility status api

* fix prompt
2018-12-18 11:15:22 -05:00
Alex Greenland
dc93d94bc8 fix: support async child process methods without callback in asar (#15927)
* fix: support async child process methods without callback in asar

* fix: support async child process methods without callback in asar (improved)
2018-12-18 16:27:39 +09:00
Samuel Attard
6c998aa4f2 fix: fix Electron not starting in development from the CLI (#16116) 2018-12-17 19:26:22 -08:00
Milan Burda
1c7a47239b chore: remove chrome_process_finder.patch (#16113) 2018-12-18 10:00:34 +09:00
Michelle Tilley
7fc8afa3e5 chore: update PR template to request better release notes (#16080) 2018-12-17 16:10:34 -08:00
Milan Burda
7ec4e7b0d8 chore: fix chrome_process_finder.patch description (#15577) 2018-12-17 14:15:35 -08:00
Milan Burda
41a3f123f1 docs: move require related breaking changes to Electron 6.0 (#16109) 2018-12-17 14:01:00 -08:00
popod
f6081b18b6 docs: Improve the doc about BrowserWindow title property (#16086)
* Improve the doc about BrowserWindow title property

* Update docs/api/browser-window.md

Co-Authored-By: popod <popod@me.com>
2018-12-17 13:16:24 -07:00
Milan Burda
7a6fe00f49 chore: simplify code for modules internally using remote.require in sandbox (#16104) 2018-12-17 22:47:41 +03:00
Gearóid
c64b4a3926 docs: more natural language in Mac app store guide (#16095) 2018-12-17 10:27:37 -05:00
Shelley Vohr
0431833866 chore: correctly capitalize releaseID (#16079) 2018-12-14 15:15:16 -08:00
Shelley Vohr
280f9bf49c feat: allow immediate MacOS notifications (#16060)
* feat: allow immediate MacOS notifications

* fix args->GetNext

* update docs/api/system-preferences.md

Co-Authored-By: codebytere <codebytere@github.com>

* address feedback from @ckerr's review
2018-12-14 13:46:46 -08:00
Cheng Zhao
c7aa747891 chore: no need to expose Initialize of ipc module (#16066) 2018-12-14 08:01:29 -08:00
Cheng Zhao
8584c2f14b fix: register webview in main world when using contextIsolation (#16067) 2018-12-14 15:38:35 +09:00
Shelley Vohr
dbda1a1b05 chore: add BinaryMuse to troppers (#16062) 2018-12-13 16:56:31 -08:00
Cheng Zhao
897c6e93cb chore: simplify main world setup of contextIsolation (#16046) 2018-12-13 16:25:12 -05:00
Michelle Tilley
d6d245d0c3 docs: contextIsolation is no longer experimental (#16043) 2018-12-13 11:21:16 -05:00
John Kleinschmidt
0e6db8fd56 ci: Cleanup build dirs on Azure Devops (#16047)
* ci: Cleanup directories after build

* Use rm to cleanup source directory

* Update vsts.yml

* Check if files actually deleted

* Get rid of hidden files too
2018-12-13 11:11:09 -05:00
Simone Cattaneo
649633bbb7 fix: make 'setParentWindow' compatible under Windows (#15775) 2018-12-12 16:05:16 -08:00
Jeremy Apthorp
4250f84272 chore: enable v2 sandbox on mac (#15647) 2018-12-12 16:01:10 -08:00
Charles Kerr
f7528a0204 fix: fix an original-fs regression introduced in 4.0 betas (#16028)
* fix: fix an original-fs regression introduced in 4.0 betas

* chore: remove cruft from earlier draft
2018-12-12 15:32:53 -06:00
Milan Burda
c65a0d90b8 chore: misc cleanup (#16037) 2018-12-12 15:31:16 -06:00
Jeremy Apthorp
1152fecb75 test: fix flaky before-input-event test (#16027) 2018-12-11 17:01:48 -08:00
Alexey Kuzmin
48abef27d8 build: make it possible to pass a "--directory" arg to "git am" (#16024) 2018-12-11 22:49:01 +01:00
Cheng Zhao
624ade2c25 fix: return pointer instead of pointer's content (#16014) 2018-12-11 12:45:55 -05:00
Jeremy Apthorp
f3c64ea9d8 chore: add webui_resources to pak (#16009)
fixes #16006
2018-12-11 09:07:32 -08:00
Birunthan Mohanathas
e383aa31c8 fix: restore ability to disable color correct rendering (#15898)
In Electron 2.0, `--disable-features=ColorCorrectRendering` could be
used to make the app use the display color space (e.g. P3 on Macs)
instead of color correcting to sRGB. Because color correct rendering is
always enabled on Chromium 62 and later and because
`--force-color-profile` has no effect on macOS, apps that need e.g. P3
colors are currently stuck on Electron 2.0.

This restores the functionality removed in
https://chromium-review.googlesource.com/698347 in the form of the
`--disable-color-correct-rendering` switch.

This can be removed once web content (including WebGL) learn how
to deal with color spaces. That is being tracked at
https://crbug.com/634542 and https://crbug.com/711107.

As an example of a widely used app using
`--disable-features=ColorCorrectRendering`, see VSCode:
3f33ef2593/src/main.js (L138-L139)

Notes: Add `--disable-color-correct-rendering` switch
2018-12-11 21:36:14 +05:30
Milan Burda
607b53c883 security: block chrome.tabs.executeScript() for non chrome-extension: URLs (#15929) 2018-12-11 10:45:46 +01:00
bughit
e044ada65c fix: allow 2 threads for CreateIoCompletionPort on single-core to prevent busy looping (#15975)
* allow 2 threads for CreateIoCompletionPort on single-core

* use base::SysInfo::NumberOfProcessors instead of env var

* CHECK that uv_loop_ has not been used before replacing its iocp
2018-12-11 11:07:35 +09:00
Benjamin Pasero
c74ae107f1 fix: do not print an error for an expected condition (#15991) (#15992) 2018-12-10 12:06:26 -08:00
Shelley Vohr
45a937df0a fix: incorrect view ordering for customButtonsOnHover (#15564) 2018-12-10 11:05:30 -08:00
Shelley Vohr
163361ee6a chore: disable bump-version on arm32 (#15994) 2018-12-10 10:57:44 -08:00
Shelley Vohr
4b18a38e9f chore: simplify promisify helper (#15952)
chore: simplify promisify helper
2018-12-10 08:13:09 -08:00
Cheng Zhao
db2fda1b6f chore: make rpc-server reply to sender frame instead of the main frame (#15973)
* chore: make rpc-server reply to frame

* fix: check IsRenderFrameLive
2018-12-10 09:37:42 +09:00
Samuel Attard
eb8fcf833c chore: warn when people attempt to use the Electron module to do Electron things but from node (#15916)
* chore: warn when people attempt to use the Electron module to do Electron things but from node

* update node env console warning
2018-12-07 12:00:24 -08:00
Milan Burda
177091ca6f chore: rename nativeRequire to potentiallyRemoteRequire (#15971) 2018-12-06 18:12:50 -08:00
Jeremy Apthorp
442c1b22e3 feat: webContents.loadURL returns a promise (#15855) 2018-12-06 12:16:19 -08:00
Shelley Vohr
1b8c11121f chore: convert bump script to js (#15820) 2018-12-06 11:00:10 -08:00
Jeremy Apthorp
2845267c18 feat: support mixed-sandbox mode on linux (#15870) 2018-12-05 17:42:12 -08:00
Milan Burda
764a10f7c7 refactor: simplify isRemoteModuleEnabled handling in sandboxed renderers (#15961) 2018-12-05 10:07:56 -08:00
Milan Burda
ab2a061b59 refactor: use helpers when using the remote module in sandboxed renderers (#15960) 2018-12-05 10:07:32 -08:00
Saswat Bhattacharya
d243a45173 feat: implement 'app-command' events for browser history navigation keys on Linux (#15441)
* Added mouse forward/back button support on Linux

* Added browser history navigation action bindings for Windows, Mac, and Linux keyboard

* Removed new `history-action` event and modified `app-command` to execute on such events

* Removed attempt at macOS support and added constants

* Clarified app-command documentation

* Reverted 'app-command' description change

* Format code
2018-12-05 09:35:59 -08:00
Shelley Vohr
3f15f51615 feat: promisify app.getFileIcon() (#15742) 2018-12-05 08:50:12 -08:00
Moisés Neto
cfbea4a0e3 docs: es6ify 'Breaking Changes' and 'File' API pages (#15507)
* docs: apply arrow functions to app.makeSingleInstance example

* docs: apply arrow functions to session docs

* docs: change normal to arrow functions in File object docs
2018-12-05 23:14:52 +11:00
Milan Burda
d561c5531b feat: deprecate modules internally using remote.require in sandboxed renderer context (#15145) 2018-12-05 10:34:09 +01:00
Pedro Pontes
d5d1fa8290 fix: use appropriate site instance for cross-site nav's (#15821)
* fix: use Chromium's determined new site instance as candidate when navigating.

When navigating to a new address, consider using Chromium's determined site instance
for the new page as it should belong to an existing browsing instance when the
navigation was triggered by window.open().

fixes 8100.

* Revert "fix: use Chromium's determined new site instance as candidate when navigating."

This reverts commit eb95f935654a2c4d4457821297670836c10fdfd5.

* fix: delegate site instance creation back to content when sandboxed.

* fix: ensure site isolation is on

* test: adapt ut for cross-site navigation

* fix: register pending processes during a navigation.

* refactor: dont call loadURL for a window constructed from an existing webContents.

* test: add sandboxed affinity UT's.

* fix: check affinity before deciding if to force a new site instance.

* chore: adapt subsequent patch.

* refactor: constify logically const methods.

* fix: do not reuse site instances when navigation redirects cross-site.

* test: ensure localStorage accessible after x-site redirect.

* test: adapt localStorage acess denied UT for site isolation.

* fix: do not send render-view-deleted for speculative frames.

* chore: amend tests after rebase.

* test: add ut for webContents' render-view-deleted emission

* fix: introduce current-render-view-deleted for current RVH's deletions.

Revert render-view-deleted to being emitted with any RVH's deletion.
current-render-view-deleted is emitted only when the RVH being deleted
is the current one.

* refactor: style and comments fixed.
2018-12-05 17:03:39 +09:00
Shelley Vohr
46e7214974 chore: remove electabul (#15954) 2018-12-04 20:50:37 -08:00
Milan Burda
cfb2812cea docs: remove methods invoking the callback repeatedly from promisification.md (#15951) 2018-12-04 13:45:55 -08:00
Jeremy Apthorp
8d1d842185 chore: restore ppapi_host DCHECK (#15788) 2018-12-04 11:05:23 -08:00
Shelley Vohr
c31629ad98 feat: add media access APIs for macOS Mojave (#15624) 2018-12-04 07:54:13 -08:00
Milan Burda
aa2b2f7c8f fix: security: don't allow arbitrary methods to be invoked on webContents via IPC (#15919) 2018-12-04 16:12:21 +01:00
Jeremy Apthorp
0a23c0b032 chore: remove old patch for fixing ffmpeg on 32-bit linux (#15226)
It's no longer necessary, per the comment
2018-12-04 20:11:24 +09:00
Cheng Zhao
5bc86eaf9c Merge pull request #15019 from Anrock/child-window-location
fix: Introduce LocationProxy for BrowserWindowProxy
2018-12-04 20:11:00 +09:00
Cheng Zhao
ca7dec2082 fix: default prop of location should be empty str 2018-12-04 17:11:26 +09:00
Cheng Zhao
fc4e10b6c0 fix: set setter of window.location 2018-12-04 16:23:52 +09:00
Anrock
e80e3a53e9 feat: introduce LocationProxy for BrowserWindowProxy 2018-12-04 16:23:52 +09:00
Julien Isorce
1f55f1635f feat: add support for DesktopCapturerSource.appIcon
Useful to get the icon of the application owning the source.
Only available for sources of type window, i.e. not for screen.

https://github.com/electron/electron/issues/14845
2018-12-04 15:42:49 +09:00
John Kleinschmidt
77f73830e8 build: Enable arm embedded builtins (#15939)
* Revert "FIXME: disable v8 embedded builtins feature for arm flavor"

This reverts commit 8ec3bc0272.

* build: don't enable embedded builtins for arm/arm64 native mksnapshot
2018-12-04 11:17:12 +09:00
Shelley Vohr
d3c58ea48c chore: move getCurrentBranch to a util file (#15921)
* chore: move getCurrentBranch to a util file

* fix import
2018-12-03 13:28:10 -08:00
Shelley Vohr
a1a431eb87 fix: make windowMenu role correct on MacOS (#15930) 2018-12-03 11:52:46 -08:00
Samuel Attard
3ddd917ff4 Merge pull request #15405 from electron/chromium-upgrade/70
feat: upgrade to Chromium 70.0.3538.110
2018-12-04 03:26:49 +11:00
Milan Burda
a33eeda4f7 refactor: don't expose NavigationController as an internal module (#15920) 2018-12-03 17:13:09 +01:00
deepak1556
8ec3bc0272 FIXME: disable v8 embedded builtins feature for arm flavor 2018-12-03 20:07:44 +05:30
deepak1556
982649bab7 chore: update libgtkui_export.patch 2018-12-03 20:07:44 +05:30
Cheng Zhao
a7ee737226 chore: backport_958b761_from_upstream_v8.patch is not needed for Ch70 2018-12-03 20:07:44 +05:30
Cheng Zhao
e842482ec8 chore: bit_hash_seed_commits.patch is not needed for Ch70 2018-12-03 20:07:44 +05:30
Cheng Zhao
f00b0a3485 chore: pick_b0af309_from_upstream_v8.patch is not needed for Ch70 2018-12-03 20:07:44 +05:30
Cheng Zhao
fe943f560b chore: fix_font_thickness.patch is not needed for Ch70 2018-12-03 20:07:44 +05:30
Cheng Zhao
975f85ea56 chore: ensure_cookie_store.patch is not needed for Ch70 2018-12-03 20:07:44 +05:30
deepak1556
e734536815 chore: roll DEPS 70.0.3538.110 2018-12-03 20:07:44 +05:30
deepak1556
3dfc0098ec chore: move node specific build config out of //electron 2018-12-03 20:07:44 +05:30
deepak1556
06a501d4a2 chore: use base::JoinString to concatenate vector 2018-12-03 20:07:44 +05:30
deepak1556
e1336d8453 chore: fix v8 deprecation warnings 2018-12-03 20:07:43 +05:30
deepak1556
f8418554a3 chore: update fix_trackpad_scrolling.patch 2018-12-03 20:07:43 +05:30
deepak1556
65b7924528 chore: update frame_host_manager.patch 2018-12-03 20:07:43 +05:30
deepak1556
5017db855c fix: remove explicitly enabled SharedArrayBuffer feature flag
It is enabled by default now.
2018-12-03 20:07:43 +05:30
deepak1556
c6313b3d2d chore: roll DEPS 70.0.3538.102 2018-12-03 20:07:43 +05:30
deepak1556
4eb0d497ab chore: update printing.patch 2018-12-03 20:07:43 +05:30
deepak1556
2ebea5501e chore: update customizable_app_indicator_id_prefix.patch 2018-12-03 20:07:43 +05:30
deepak1556
2d68d60e00 chore: rm fix_zoom_display.patch 2018-12-03 20:07:43 +05:30
Heilig Benedek
6deb7afb82 fix: reimplement FrameSubscriber with mojo, re-enable tests 2018-12-03 20:07:43 +05:30
Heilig Benedek
8727636fcc fix: update and re-enable OSR 2018-12-03 20:07:42 +05:30
deepak1556
00294a5b25 FIXME: disable some specs 2018-12-03 20:07:42 +05:30
deepak1556
c491fa59df spec: update inspector-binding.js
* https://github.com/nodejs/node/pull/22251
* https://github.com/nodejs/node/pull/20137
2018-12-03 20:07:42 +05:30
deepak1556
d97cf8c438 spec: force create network context for proxy tests 2018-12-03 20:07:42 +05:30
deepak1556
7a68d632e6 fix: use proxy lookup api of network context to resolve proxies 2018-12-03 20:07:42 +05:30
deepak1556
28cff4644e fix: disable kSpareRendererForSitePerProcess feature 2018-12-03 20:07:42 +05:30
Samuel Attard
9d72bd4de4 chore: update CreateSkBitmapFromHICON usage for new API (no pointer)
refs: https://chromium-review.googlesource.com/c/chromium/src/+/1234372
2018-12-03 20:07:42 +05:30
Samuel Attard
c1b9ca14e7 build: disable microsoft include warning
this error is being thrown on windows due a #include inside node
2018-12-03 20:07:42 +05:30
Samuel Attard
32a957c455 build: explicitly depend on //dbus for the linux build
refs: https://chromium-review.googlesource.com/c/chromium/src/+/1273525
2018-12-03 20:07:42 +05:30
Samuel Attard
85fdacbc49 chore: replace ShowWithWindowState with Show inside native_window_views
The functionality was merged in as a parameter to the core Show method, default
for restore_bounds is an empty gfx::Rect()

refs: https://chromium-review.googlesource.com/c/chromium/src/+/1174910
2018-12-03 20:07:42 +05:30
Samuel Attard
f8f091c250 chore: update GetLabelFrontList to be GetLabelStyle in menu model
refs: https://chromium-review.googlesource.com/c/chromium/src/+/1186702
2018-12-03 20:07:41 +05:30
Shelley Vohr
c51fef1568 fix: use url::AddCORSEnabledScheme 2018-12-03 20:07:41 +05:30
Shelley Vohr
1523a82bab fixup! add missing newlines to patches 2018-12-03 20:07:41 +05:30
Samuel Attard
92f50664d0 chore: fix linting 2018-12-03 20:07:41 +05:30
Samuel Attard
5798b152a6 chore: check GetAgent as GetTracingController() crashes if no agent is set 2018-12-03 20:07:41 +05:30
Samuel Attard
b1e69e1357 chore: update asar injection for new node internal module loader 2018-12-03 20:07:41 +05:30
Samuel Attard
9c36576ddd chore: SetTracingController becomes SetAgent and corresponing contructions updated 2018-12-03 20:07:41 +05:30
deepak1556
f7f09b028b Introduce explicit configuration to CertVerifier
https://chromium-review.googlesource.com/c/chromium/src/+/1122709
2018-12-03 20:07:41 +05:30
deepak1556
089001bd92 fix: update node inspector api usage 2018-12-03 20:07:41 +05:30
deepak1556
97aa7b8e68 Use CompletionOnceCallback in URLFetcherResponseWriter.
https://chromium-review.googlesource.com/c/chromium/src/+/1155087
2018-12-03 20:07:41 +05:30
deepak1556
366ca47136 Change Value::BlobStorage to std::vector<uint8_t>
https://chromium-review.googlesource.com/c/chromium/src/+/1137819
2018-12-03 20:07:40 +05:30
deepak1556
d21e30f57b Reorganize MediaStreamType enums
https://chromium-review.googlesource.com/c/chromium/src/+/1160000
2018-12-03 20:07:40 +05:30
deepak1556
d1da0aad7f Make IsolateHolder aware of the isolate type.
https://chromium-review.googlesource.com/c/chromium/src/+/1183194
2018-12-03 20:07:40 +05:30
deepak1556
321f87fe61 Complete TaskPriority::BACKGROUND->BEST_EFFORT mass rename
https://chromium-review.googlesource.com/c/chromium/src/+/1153461
2018-12-03 20:07:40 +05:30
deepak1556
6743b83786 Add notifications to UKM.xml.
https://chromium-review.googlesource.com/c/chromium/src/+/1071649
2018-12-03 20:07:40 +05:30
deepak1556
f464b8c4c5 Respond for handling protocol commands async
https://chromium-review.googlesource.com/c/chromium/src/+/1139575
2018-12-03 20:07:40 +05:30
deepak1556
25d0a7b62a Create a CodeCache per each storage_partition to store generated code
https://chromium-review.googlesource.com/c/chromium/src/+/1120179
2018-12-03 20:07:40 +05:30
deepak1556
b5b49c9ed0 FIXME: Remove SchemeRegistry::RegisterURLSchemeAsCORSEnabled
https://chromium-review.googlesource.com/c/chromium/src/+/1157364
2018-12-03 20:07:40 +05:30
deepak1556
ffeab383b5 Move NetworkConnectionTracker getter to network_service_instance.h
https://chromium-review.googlesource.com/1162888
2018-12-03 20:07:40 +05:30
deepak1556
0bd006a8eb ProxyConfigDictionary: Use base::Value
https://chromium-review.googlesource.com/c/chromium/src/+/1150846
2018-12-03 20:07:40 +05:30
deepak1556
0f9dd3736c Move CRLSets to being part of CertVerifier::Config
https://chromium-review.googlesource.com/c/chromium/src/+/1132706
2018-12-03 20:07:39 +05:30
deepak1556
6310d6c699 Flatten ResourceRequestBody data
https://chromium-review.googlesource.com/c/chromium/src/+/1114258
2018-12-03 20:07:39 +05:30
deepak1556
b2d53f1e1e FIXME: word_start and medial_capital_as_word_start are removed from WebFindOptions
https://chromium-review.googlesource.com/c/chromium/src/+/1175645
2018-12-03 20:07:39 +05:30
deepak1556
4179cedf37 Change SubscribePermissionStatusChange to use a RFH to query permissions
https://chromium-review.googlesource.com/c/chromium/src/+/979735
2018-12-03 20:07:39 +05:30
deepak1556
66349261a5 fix: update to per context v8::Script::Compile api 2018-12-03 20:07:39 +05:30
deepak1556
c1f32afeeb Use CompletionOnceCallback in URLRequestSimpleJob.
https://chromium-review.googlesource.com/c/chromium/src/+/1155089
2018-12-03 20:07:39 +05:30
deepak1556
8f1fa4177e Fix invalid handle errors found with App Verifier
https://chromium-review.googlesource.com/c/chromium/src/+/1145767
2018-12-03 20:07:39 +05:30
deepak1556
535d264497 fix: [UI] Resolve method conflict between MenuModel, SimpleMenuModel::Delegate
https://chromium-review.googlesource.com/c/chromium/src/+/1230581
2018-12-03 20:07:39 +05:30
deepak1556
2eedcde914 fix: Remove DEFINE_WEB_CONTENTS_USER_DATA_KEY in //electron.
https://bugs.chromium.org/p/chromium/issues/detail?id=589840
2018-12-03 20:07:39 +05:30
Samuel Attard
6b4b7c9831 chore: make BrowserObserver a CheckedObserver
refs: https://chromium-review.googlesource.com/c/chromium/src/+/1053338
2018-12-03 20:07:38 +05:30
Samuel Attard
b6aae790cf fixme: C70 removed DidReceiveCompositorFrame
(OSR relatied)

refs: 1de1ca906a

cc @brenca
2018-12-03 20:07:38 +05:30
Samuel Attard
74d1685523 chore: fix ShouldFork impl, referrer stripping has been removed
refs: https://chromium-review.googlesource.com/c/chromium/src/+/1124329
2018-12-03 20:07:38 +05:30
Samuel Attard
c9007557e5 chore: post_task and friends now live under base/task
refs: https://chromium-review.googlesource.com/c/chromium/src/+/1161088
2018-12-03 20:07:38 +05:30
Samuel Attard
c4cb90ab85 chore: replace PreContentInitialization with PreCreateMainMessageLoop 2018-12-03 20:07:38 +05:30
Samuel Attard
0adbcfd806 chore: bump node 2018-12-03 20:07:38 +05:30
Samuel Attard
fd442df851 chore: update v8 patches for Chromium 70 2018-12-03 20:07:38 +05:30
Samuel Attard
f927398b53 chore: update package-lock.json 2018-12-03 20:07:38 +05:30
Jeremy Apthorp
6414cb05f0 update DEPS 2018-12-03 20:07:37 +05:30
Jeremy Apthorp
3b4e706758 rebase chromium patches on M70 2018-12-03 20:07:37 +05:30
Milan Burda
559fd5cb31 chore: remove unused module (#15917) 2018-12-02 14:43:04 -08:00
Jakub Biesiada
1672cffe96 docs: update mojave-dark-mode-guide.md (#15888)
* Update mojave-dark-mode-guide.md

Add info about dark mode support in electron-builder

* Update mojave-dark-mode-guide.md

* Update mojave-dark-mode-guide.md
2018-12-01 12:02:36 +11:00
Shelley Vohr
b8ec886609 chore: allow bumping stable => beta (#15906) 2018-11-30 11:01:57 -08:00
Shelley Vohr
728be219a4 chore: improve granular release cleanup (#15900)
* chore: improve granular release cleanup

* make releaseId optional
2018-11-30 09:58:09 -08:00
Sylvester Keil
2e91bf1e15 Fix GTK menubar item color (#15878)
Use menubar item color (not menu item color).
Closes #15194
2018-11-30 09:28:45 -08:00
John Kleinschmidt
515525cfc6 ci: Renable ffmpeg and mksnapshot tests on Azure Devops (#15800)
* ci: Renable ffmpeg and mksnapshot tests on VSTS

Also, add testing of ffmpeg and mksnapshot to arm tests
2018-11-30 11:17:01 -05:00
Jeremy Apthorp
83d951db7e chore: DCHECK that events are only emitted on the UI thread (#15873)
* chore: DCHECK that events are only emitted on the UI thread

* move dcheck to EmitWithEvent
2018-11-30 18:48:27 +09:00
Milan Burda
8483cb4aa7 security: only handle related IPCs when <webview> tag is enabled (#15859)
* refactor: move guest-view-manager related IPC handling out of rpc-server

* feat: only handle related IPCs when <webview> tag is enabled
2018-11-30 18:44:38 +09:00
Andy Dill
8cca1c987b fix: move NativeWindow tracking to OSR WCV (#15585)
* fix: move NativeWindow tracking to OSR WCV

* fix oops
2018-11-29 21:25:02 -08:00
Heilig Benedek
78b88a70bb fix: backport patch that ensures that cookie store is always created (#15836)
* fix: backport patch that ensures that cookie store is always created

* fix: disable cookie encryption

* fix: flush the cookie store when NetworkContext shuts down

* test: add test for cookie store persistance

* Update patches/common/chromium/ensure_cookie_store.patch

Co-Authored-By: brenca <benecene@gmail.com>

* Update patches/common/chromium/ensure_cookie_store.patch

Co-Authored-By: brenca <benecene@gmail.com>
2018-11-29 10:51:13 -08:00
Shelley Vohr
165d168ee5 fix: ignore unused freopen result (#15884) 2018-11-29 09:36:08 -08:00
Jeremy Apthorp
753fb31c54 test: fix flaky takeHeapSnapshot test (#15853)
ref #15095
2018-11-29 16:51:03 +01:00
Jeremy Apthorp
62eb077f29 refactor: simplify logic for enabling stack dumping (#15872)
ref #15785
2018-11-28 22:23:41 -08:00
Ho Wing Yip
cd8099d336 Fixed typo in dialog.md (#15861)
Changed "masOS" to "macOS"
2018-11-28 20:41:27 -08:00
Jeremy Apthorp
30109d64f2 test: fix a bunch of flaky tests related to emittedOnce (#15871) 2018-11-28 17:52:19 -08:00
Jeremy Apthorp
ae266e2e03 chore: remove browser_plugin_wheel.patch (#15787)
according to https://crbug.com/725970#c9, chromium should have fixed this upstream
2018-11-28 13:45:37 -08:00
Shelley Vohr
c366525370 fix: form control rendering on 10.14 Mojave (#14865) 2018-11-28 13:06:20 -08:00
Michelle Tilley
8f04def7b2 fix: prevent bluetooth device list from growing without bound (#15805)
* fix: include bluetooth strings in build

* fix: prevent bluetooth device list from growing without bound
2018-11-28 11:36:00 -05:00
Andy Dill
55808dffcd fix: osr windows respect display scale factor (#15733) 2018-11-28 11:16:03 -05:00
Milan Burda
07f8f5f95a refactor: eliminate duplicate code exposing process APIs (#15824) 2018-11-28 11:08:17 -05:00
Slapbox
d7d4b8638d docs: makes note of HTTP header CSP usage with file:// (#14768) 2018-11-28 17:58:18 +09:00
Nitish Sakhawalkar
9890d1e251 feat: Implement process.getProcessMemoryInfo to get the process memory usage (#14847)
* feat: Implement process.getMemoryFootprint to get the process memory usage

* Add spec

* fix: must enter node env in callback

* Update function call

* Update spec

* Update API data

* update spec

* Update include

* update test for shared bytes

* Update atom/common/api/atom_bindings.cc

Co-Authored-By: nitsakh <nitsakh@icloud.com>

* Update atom/common/api/atom_bindings.cc

Co-Authored-By: nitsakh <nitsakh@icloud.com>

* Update API

* Update the callback isolate

* Update to work after app ready

* Update docs

* Update docs/api/process.md

Co-Authored-By: nitsakh <nitsakh@icloud.com>

* Update docs/api/process.md

Co-Authored-By: nitsakh <nitsakh@icloud.com>

* Fix crash
2018-11-28 17:57:53 +09:00
Alexander Turinske
f563fc9d5e docs: add new widevine requirements (#14024) 2018-11-28 17:53:42 +09:00
Shelley Vohr
41c2685204 feat: promisify win.capturePage() (#15743)
* feat: promisify win.capturePage

* mark optional arg correctly

* Add to breaking changes doc

* properly deprecate win.capturePage

* remove change from api-contract

* document both callback and promise versions

* address docs feedback

* update promisification progress doc
2018-11-27 23:50:53 -05:00
Shelley Vohr
73fbb69c50 chore: change return type of platform_util::SetLoginItemEnabled (#15854) 2018-11-27 23:16:53 -05:00
Shelley Vohr
5f9c857eb0 chore: expose release id for use in cleanup (#15845) 2018-11-27 23:12:01 -05:00
Jeremy Apthorp
5d54d42953 test: fix remote-debugging-port test calling done twice (#15857) 2018-11-28 10:59:05 +09:00
Milan Burda
81e00d8e56 chore: fix V8 deprecation warnings (#15842) 2018-11-27 16:42:02 -05:00
Jeremy Apthorp
455f0669e7 fix: add missing shell_resources.pak to repack target (#15844) 2018-11-27 11:18:18 -08:00
Cheng Zhao
5bb35bbdaf fix: backport patch to fix scrolling problem (#15830) 2018-11-27 23:26:34 +09:00
Milan Burda
d63a848011 feat: add activate option to webContents.openDevTools (#13852) 2018-11-27 18:34:44 +09:00
Cheng Zhao
aafbd865bf Merge pull request #12686 from Anrock/browserview-handle-window-open
fix: handle window.open events in BrowserView
2018-11-27 15:59:17 +09:00
Cheng Zhao
63874da087 test: add test for window.open in BrowserView 2018-11-27 11:10:07 +09:00
Cheng Zhao
d1f0d6c184 fix: remove event monitor before destroying window 2018-11-27 11:10:07 +09:00
Anrock
9ff7807be8 fix: move window.open handlers from BrowserWindow to WebContents 2018-11-27 10:59:01 +09:00
Jeremy Apthorp
23de301955 chore: remove scoped_clipboard_writer.patch (#15843)
replace with already-exposed APIs
2018-11-27 09:51:26 +09:00
Shelley Vohr
0a5f8611e8 chore: add promise api runtime flag (#15841)
* chore: add promise api runtime flag

* add promisification plan document

* fix process.md typo
2018-11-26 16:00:46 -05:00
Simone Cattaneo
6f116eeaa4 fix: improved event flow management related to 'will-resize' event on Windows (#15695) 2018-11-26 12:26:48 -08:00
Heilig Benedek
0242818f39 feat: add registerAccelerator flag to allow menu items to optionally skip accelerator registration (#15723)
* feat: add registerAccelerator flag to allow menu items to skip registration

* docs: add docs for registerAccelerator

* docs: re-add accidentally removed line
2018-11-26 10:43:55 -08:00
Shelley Vohr
3748ee49ea chore: remove unused test.py (#15822) 2018-11-24 20:01:30 -05:00
Jeremy Apthorp
a8a881c8db chore: restore //url dchecks (#15637) 2018-11-22 09:02:52 -08:00
Jeremy Apthorp
fb52fdc592 chore: remove browser_plugin_guest.patch (#15786) 2018-11-21 15:53:09 -05:00
John Kleinschmidt
bb7c63c052 build: fix native_mksnapshot build (#15770)
* build: fix native_mksnapshot build

When we changed our electron_mksnapshot_zip target to include the v8_context_snapshot_generator, this dependency made the `run_mksnapshot` target run which was trying to run an arm/arm64 binary on x64 hardware.

Don't use custom build args for native_mksnapshot as they are not needed

* Added comment on why snapshot_blob.bin is skipped on arm/arm64
2018-11-21 15:19:19 -05:00
Robo
9e8b26cc4e fix: bypass CORB when web security is disabled (#15737)
* fix: extend content layer hook to bypass corb when web security is disabled.

* chore: add patch to disable CORB
2018-11-21 14:10:05 -06:00
Heilig Benedek
5db8197a5d fix: schedule a paint after browserview's background is set (#15784) 2018-11-21 13:04:10 -06:00
Samuel Attard
0b0a17ff91 fix: load the chrome.* API on chrome-extension pages in sandbox mode (#15563)
With mixed sandbox enabled we need to load the chrome.* APIs in the
sandbox init.js so that chrome extensions load correctly.

This mirrors the equivilant impl in `atom_renderer_client.cc`

Fixes #15561
2018-11-21 12:56:58 -05:00
malern
a68e3371f3 fix: remove duplicated status code (#15707)
Removed the hardcoded status code from the protocol response as the real status code is appended immediately after.
2018-11-21 10:47:05 -06:00
Cheng Zhao
47bf8e1bb3 view: add ResizeArea class (#15752) 2018-11-21 22:39:59 +09:00
Jeremy Apthorp
65099ab489 chore: remove no_stack_dumping.patch (#15785)
we build with IS_OFFICIAL_BUILD now so this should be OK
2018-11-20 23:32:43 -05:00
Charles Kerr
40619efb3b chore: remove FileChooser AddExtensionForFilename (#15510) 2018-11-20 16:24:39 -05:00
Samuel Attard
f02f9ba9fb chore: add spec for --inspect after a -- (#15237) 2018-11-20 16:23:50 -05:00
Ondřej Záruba
de05ff894b feat: Add app.getLocaleCountryCode() method for region detection (#15035)
* Add method to get system´s user region

* Fix linter

* Remove auto types

* Improved detection for POSIX

* Change name, add specs, minor fixes

* Remove left overs

* Fix locale test

* Fix Linux test

* Coding style fixes

* Fix docs

* Add test excaption for Linux

* fix spelling

* Polishing
2018-11-20 15:33:23 -05:00
Pedro Pontes
57d2ae1aec revert: "fix: window.open site instance should belong to same browsing instance (#15216)" (#15757)
This reverts commit 8f35198bfb.
2018-11-20 21:28:26 +01:00
Michelle Tilley
46c2953edb doc: Update Windows build instructions to include debugging tools (#15765) 2018-11-20 01:08:25 -05:00
Simone Cattaneo
f2d3d55e95 docs: changed German link with English one for Windows SDK Archive (#15764) 2018-11-20 01:03:03 -05:00
Daniel Turcich
a59b53c7e6 Update webview-tag.md (#15741)
Added Mouse and Scroll to list of events that webview can't have event listeners for
2018-11-20 01:01:57 -05:00
Jeremy Apthorp
08b56b7675 docs: add note about win_delay_load_hook (#15766) 2018-11-19 16:13:50 -08:00
Jeremy Apthorp
90795c4fa4 build: make make_locale_dirs idempotent (#15768) 2018-11-19 15:55:13 -08:00
Jeremy Apthorp
90d1c0b2b6 chore: don't explicitly destroy asar archives (#15734) 2018-11-19 13:12:41 -08:00
Jeremy Apthorp
ec4212cce1 docs: add troubleshooting section for win toolchain prompt (#15761) 2018-11-19 11:53:28 -08:00
Shelley Vohr
a45d5960d7 chore: allow for callback => promise deprecation (#15758)
* chore: allow for callback => promise deprecation

* cb type check is sufficient

* migrate warn to always trigger
2018-11-19 12:56:26 -05:00
Andrzej Szombierski
51cb36fa9b fix: ensure that file descriptors 0/1/2 are opened at startup (#15555)
* fix: ensure that file descriptors 0/1/2 are opened at startup

This fixes an issue where the gpu subprocess was writing messages to a
random pipe or socket. The standard file desciptors are closed in
chromium's subprocesses because of an unfortunate interaction with
libuv's tty handling code leaving them with the FD_CLOEXEC flag.

* style: fix lint warnings
2018-11-19 11:53:55 -05:00
Simone Cattaneo
b97d7e7ecd fix: On close trying to remove observer from an empty collection leads to an access violation (#15739) 2018-11-19 11:47:04 -05:00
Cheng Zhao
e12c0dcf66 Merge pull request #15618 from electron/system_netwok_context
fix: create system network context for global requests
2018-11-19 11:25:34 +09:00
Andy Dill
4f45b72381 fix: package swiftshader binaries (#15380) 2018-11-17 19:24:29 +11:00
Jeremy Apthorp
81843f0dfb ci: temporarily disable verify ffmpeg & mksnapshot tests on vsts (#15732)
* ci: temporarily disable verify ffmpeg test on vsts

* also disable verify-mksnapshot
2018-11-15 16:35:31 -08:00
Jeremy Apthorp
20116d7f05 fix: always disable setuid sandbox on linux (#15722) 2018-11-15 13:27:56 -08:00
Jeremy Apthorp
0642be296d fix: crash in sandbox on linux when getting execPath (#15701) 2018-11-15 12:59:01 -08:00
Jeremy Apthorp
c8860d006b fix: restore missing .lproj directories (#15721)
the empty lproj directories help macOS to understand what locales the app supports
2018-11-15 09:30:45 -08:00
John Kleinschmidt
b53a858400 build: use different directory for generated breakpad symbols (#15716) 2018-11-14 12:47:01 -08:00
Shelley Vohr
511dc9a80b feat: add numpad accelerator strings (#15689) 2018-11-14 14:02:18 -05:00
deepak1556
7e1168c518 fix: return system shared url loader for content layer 2018-11-14 12:42:24 +05:30
deepak1556
57356036db fix: initialize system network context from IOThread 2018-11-14 12:42:24 +05:30
deepak1556
666a106fa8 refactor: move IOThread and NetLog ownership to g_browser_process 2018-11-14 12:42:24 +05:30
deepak1556
414dcfcd07 fix: create system network context for global requests
Global requests currently includes DNS over HTTPS requests,
certain cert validation requests (OCSP, AIA, etc) on some platforms
and geolocation requests.
2018-11-14 12:42:24 +05:30
Shelley Vohr
787dbbe610 feat: add about panel customization on linux (#15658) 2018-11-13 17:12:24 -05:00
Jeremy Apthorp
bc9a7806a5 chore: remove add_atomic_lib_to_dependencies_even_for_sysroot_builds.patch (#15692) 2018-11-13 10:00:25 -08:00
Shelley Vohr
565e4c5910 chore: fix window width in spec for win (#15693) 2018-11-13 11:31:03 -05:00
Pedro Pontes
8f35198bfb fix: window.open site instance should belong to same browsing instance (#15216) 2018-11-12 22:01:43 +01:00
Shelley Vohr
c06f023313 feat: allow partial setting of window bounds (#15677)
Extend the existing win.setBounds functionality by allowing developers to partially update bounds without being forced to pass in all four bounds values. No existing functionality is altere
2018-11-12 15:31:14 -05:00
Alexey Kuzmin
0c46a7a4d9 ci: use config version 2.1 on CircleCI (#15665) 2018-11-12 11:22:21 -08:00
Jacob
b21dbdb20d fix: bypass DOM storage quota (#15596) 2018-11-12 18:19:01 +01:00
Shelley Vohr
c9d0960f47 docs: remove unsafe eval section of security tutorial (#15675)
* docs: remove unsafe eval section of security tutorial

* lintfix
2018-11-12 11:13:48 -05:00
Shelley Vohr
a54dd1085a feat: expose showAboutPanel for MacOS (#15674) 2018-11-11 22:52:27 -05:00
Samuel Attard
1cf28e8b75 build: auto-gen libnotify_loader.cc (#15648) 2018-11-10 14:21:40 -05:00
Shelley Vohr
9fd98bb27b refactor: no longer require submenu for services menuitem (#15656) 2018-11-10 12:47:55 -05:00
Nitish Sakhawalkar
025aa49f67 fix: NSWindow crash happening on macos 10.9 (#15660) 2018-11-10 14:53:35 +01:00
Nitish Sakhawalkar
5994bf6745 fix: Menu accelerators not working (#15094)
This change fixes the regression in the menu accelerators working in linux, on some environments.
2018-11-09 13:54:16 -08:00
John Kleinschmidt
9e2b7dbea5 ci: add testing for mksnapshot (#15627)
* ci: add testing for mksnapshot
2018-11-09 10:54:17 -04:00
Samuel Attard
edf063bae3 chore: remove deprecated touch-bar API (#15650) 2018-11-09 17:00:19 +11:00
Samuel Attard
e7b2b93cee chore: re-enable DCHECK in node_debugger (#15649) 2018-11-09 14:44:31 +11:00
Robo
82322968a3 refactor: printing implementation (#15143)
* refactor: basic printing

* move build files to chromium_src/BUILD.gn
* remove dependency on chrome prerender sources

* spec: move printing specs behind feature flag

* build: register pdf compositor service
2018-11-09 14:42:34 +11:00
Jeremy Apthorp
53642b2b17 chore: restore process_metrics_win.cc dcheck (#15631) 2018-11-09 00:51:53 +01:00
Jeremy Apthorp
fb9cf86836 chore: restore node.cc IsPseudoElement dcheck (#15634) 2018-11-08 13:20:20 -08:00
Jeremy Apthorp
faf6c5ad29 chore: restore blink loader dchecks (#15638) 2018-11-08 16:38:01 -04:00
Jeremy Apthorp
4649d1c73b chore: restore webui-related bindings DCHECK (#15633) 2018-11-08 11:37:00 -08:00
Jeremy Apthorp
703cb6deea chore: restore WeakReference dcheck (#15629) 2018-11-08 11:36:37 -08:00
Samuel Attard
9aed2a465f fix: send NSView* as the response to getNativeWindowHandle() instead of a null handle (#15521) 2018-11-08 09:03:19 -08:00
Cheng Zhao
746beb0d8b fix: destroy WebContents synchronously on shutdown (#15541) 2018-11-08 07:57:28 -08:00
Alexey Kuzmin
6162d9090d chore: remove the 'get-patch' script (#15586)
It is obsolete now, "script/git-export-patches"
should be used instead.
2018-11-08 16:37:00 +01:00
Jeremy Apthorp
11223cbc9b chore: restore viz dcheck (#15632) 2018-11-08 11:16:47 -04:00
Jeremy Apthorp
7e0e12b8a3 fix: match Chrome's font fallback behavior (#15486)
* fix: match Chrome's font fallback behavior

Fixes #15481

* add a cache

* add test

* another test

* fix tests

* arial -> dejavu sans on linux apparently?
2018-11-08 10:51:51 -04:00
Heilig Benedek
ca2d74e118 feat: add methods to allow customization of save dialog during will-download event (#15497)
* feat: add method to DownloadItem that allows customization of dialog options

* docs: add docs for get/setSaveDialogOptions

* add missing copy constructor for DialogSettings on mac and linux

* fix: don't filter dialog options for mas build, don't return properties

* test: add test for get/setSaveDialogOptions

* fix: remove openDevtools added for debugging

* test: fix failing test because of new event parameter

* docs: use SaveDialogOptions instead of Object
2018-11-08 10:51:06 -04:00
Jeremy Apthorp
673004b878 chore: restore kill_win.cc dcheck (#15630) 2018-11-08 10:40:34 -04:00
Michelle Tilley
2a8e8a0603 fix: make certain values on process read-only (#15628)
* docs: Add 'worker' as a possible value for `process.type`

* fix: make certain properties on `process` read only:

* `mas`
* `windowsStore`
* `versions.electron`
* `versions.chrome`
* `type`
* `pid`
* `sandboxed`
2018-11-08 10:28:06 -04:00
Samuel Attard
4e53019b75 docs: add a mojave dark mode guide (#15267) 2018-11-07 18:16:47 -06:00
Shelley Vohr
833269ffde fix: correctly display zoom in accelerator on mac (#15502)
* fix: correctly display zoom in accelerator on mac

* add release to patch info
2018-11-07 13:42:30 -08:00
Shelley Vohr
e9ba26f50e feat: allow registering multiple shortcuts (#15542)
This PR allows for multiple global shortcuts to be registered such that triggering any of them calls the same callback.
2018-11-07 09:40:38 -08:00
Jeremy Apthorp
20a540e680 chore: add explanation to resource_file_conflict.patch (#15612)
* chore: add explanation to resource_file_conflict.patch

* Update resource_file_conflict.patch
2018-11-07 11:11:01 -04:00
Jeremy Apthorp
bf3edf8f87 fix: correctly package Login Helper in mas builds (#15610) 2018-11-06 20:15:01 -08:00
Jeremy Apthorp
10969b8c3c fix: make feature strings more robust to whitespace (#15602)
Fixes #15594
2018-11-06 15:52:06 -08:00
John Kleinschmidt
c52cf01a3c build: add v8_context_snapshot_generator to mksnapshot zip (#15606)
v8_context_snapshot_generator is needed when creating custom snapshots with mksnapshot
2018-11-06 18:57:52 -04:00
Charles Kerr
1672c95de3 better release notes (#15169)
* fix: use PR 'Notes' comment in release notes

* fix: follow links in roller-bot PRs

* refactor: better reference point version selection

* if we're a stable release, use the current brnach's previous stable
* if we're a beta release, use the current branch's previous beta
* if no match found, use the newest stable that precedes this branch

* refactor: dedup the caching functions' code

* refactor: partially rewrite release note generator

* parse release notes comments from PRs
* do not display no-notes PRs
* handle roller-bot commits by following cross-repo commits/PRs
* minor tweaks to note rendering, e.g. capitalization

* fix: fix lint:js script typo

* fix: copy originalPr value to rollerbot PR chains

* fix: handle more cases in release notes generator

* handle force-pushes where no PR
* better type guessing on pre-semantic commits

* fix: handle more edge cases in the note generator

* better removal of commits that landed before the reference point
* ensure '<!-- One-line Change Summary Here-->' is removed from notes
* handle more legacy commit body notes e.g. "Chore(docs)"
* check for fix markdown in PR body e.g. a link to the issue page

* chore: tweak code comments

* refactor: easier note generator command-line args

* refactor: group related notes together

* feat: query commits locally for gyp and gn deps

* chore: slightly better filtering of old commits

* feat: omit submodule commits for .0.0 releases

More specifically, only include them if generating release
notes relative to another release on the same branch.

Before that first release, there's just too much churn.

* refactor: make release-notes usable as a module

Calling it from the command line and from require()() now
do pretty much the same thing.

* refactor: passing command-line args means use HEAD

* chore: plug in the release note generator

* feat: support multiline 'Notes:' messages.

xref: https://github.com/electron/trop/pull/56
xref: https://github.com/electron/clerk/pull/16

* remove accidental change in package.json

* simplify an overcomplicated require() call

* Don't use PascalCase on releaseNotesGenerator()

* Remove code duplication in release notes warnings

* remove commented-out code.

* don't use single-character variable names.

For example, use 'tag' instead of 't'. The latter was being
used for map/filter arrow function args.

* Look for 'backport' rather than 'ackport'.

* Wrap all block statements in curly braces.

* fix tyop

* fix oops

* Check semver validity before calling semver.sort()
2018-11-06 16:06:11 -04:00
Shelley Vohr
649f04b7bc chore: add simple set/unset loginitem spec (#15595) 2018-11-06 11:31:32 -08:00
Jeremy Apthorp
934a7fc118 refactor: don't use AppIndicatorIcon directly (#15536) 2018-11-06 11:00:37 -08:00
Alexey Kuzmin
3a3b197327 fix: update the "SSL_get_tlsext_status_type" patch (#15587)
It has been upstreamed by @nornagon
c0c9001440
2018-11-06 08:07:09 -08:00
Shelley Vohr
ece4c81c1a fix: hiddenInset titleBar console spam (#15576) 2018-11-05 21:02:46 -08:00
Shelley Vohr
dcd2bf451d refactor: remove 10.9 specific menu code (#15578) 2018-11-05 20:42:19 -08:00
Jeremy Apthorp
87565ec667 docs: add more links to the devtools protocol docs (#15581)
I missed the link at the top when I was skimming this documentation
2018-11-05 16:53:18 -08:00
Jeremy Apthorp
2e1c50c891 chore: fix missing \n at end of exported patches (#15579) 2018-11-05 13:50:35 -08:00
Jeremy Apthorp
77f69cbe08 chore: remove unused use_transparent_window.patch (#15534)
Unneeded since 6f2f761df3 (diff-0bbbec38254ebb1146b15c15277c6aa1)
2018-11-05 13:19:21 -08:00
Shelley Vohr
c60745b8a3 fix: use NSURL path for receipt url (#15355) 2018-11-05 09:49:51 -08:00
Alexey Kuzmin
32ea2b67f0 build: store the patches config in a json file (#15395) 2018-11-05 17:31:28 +01:00
Alexey Kuzmin
9b05381acc build: make pyyaml an optional dependency (#15565) 2018-11-05 11:19:00 -04:00
Milan Burda
a19d20cfb8 refactor: more cleanup of chromium_src (#15424) 2018-11-05 10:29:33 -04:00
trop[bot]
c422011d58 docs: fix the "second-instance" event handler signature in the docs (#15551) 2018-11-03 11:37:59 +11:00
Heilig Benedek
1f5e0c42f3 style: no need for done call in sync tests (#15550) 2018-11-02 10:50:17 -04:00
nixxquality
6e6ab9b907 Fix callback info for showSaveDialog and showOpenDialog (#15549) 2018-11-02 10:47:19 -04:00
Samuel Attard
7f73240fd5 chore: use chromes auto generated definition of CHROME_VERSION_STRING (#15275) 2018-11-02 23:32:33 +11:00
Jeremy Apthorp
932ffdc1e1 test: fix a possible race condition in sendInputEvent test (#15530) 2018-11-01 10:25:46 -07:00
Samuel Attard
fe8965efa2 fix: use sendToAll method correctly in chrome-api (#15518) 2018-11-01 07:16:49 -07:00
Samuel Attard
bdef033459 docs: add Size as an option for pageSize in docs for printToPDF (#15519) 2018-11-01 09:00:33 -04:00
Samuel Attard
6ed70327f5 chore: publish to the latest tag correctly when releasing old versions (#15274) 2018-11-01 12:27:35 +11:00
Samuel Attard
e9fab747ec fix: explicitly set windowsHide to the old node default (#15469)
fixes #15467
2018-11-01 10:53:11 +11:00
Charles Kerr
feb31d088b fix: honor properties.showHiddenFiles on Linux (#15503)
Previously the code only set the GtkFileChooser's property if `properties.showHiddenFiles` was set. 

This PR unconditionally sets the GtkFileChooser's property so that hidden files will be hidden if `properties.showHiddenFiles` was not set.
2018-10-31 16:13:01 -05:00
Cheng Zhao
a8f2646ba6 Fix missing remote object error when calling remote function created in preload script (#15444)
* fix: report wrong context error based on contextId

* fix: destroyed remote renderer warning is now async
2018-10-31 11:26:57 -04:00
Shelley Vohr
b2e1a93177 refactor: remove hardcoded google api key (#15478)
* refactor: remove hardcoded Google API key

* address changes from review
2018-10-31 07:49:44 -07:00
Samuel Attard
86064a7bd8 docs: add return type for subscribeNotification (#15490) 2018-10-31 10:24:50 -04:00
Heilig Benedek
6d2a088be9 feat: detect high contrast color mode (#15493)
* feat: add event and method to detect high contrast color mode

* docs: add docs for isHighContrastColorScheme and high-contrast-color-scheme-changed

* refactor: correct type of contrast
2018-10-31 10:22:18 -04:00
Heilig Benedek
aa6f7a5d9f fix: don't append Shift modifier text twice to accelerators (#15400)
* fix: don't append Shift modifier text twice to accelerators

* style: use the new way of creating patches

* test: add menu item accelerator display tests

* fix: allocate accelerator on the stack

* fix: adjust tests to match expected behavior on mac
2018-10-31 10:13:44 -04:00
Shelley Vohr
1d81d1a706 chore: re-enable protocol partition request spec (#15483) 2018-10-31 07:12:32 -05:00
Jeremy Apthorp
e345209f91 chore: remove webui_in_subframes patch (#15475) 2018-10-30 18:19:30 -05:00
Shelley Vohr
29964079ae chore: re-enable failing netlog spec (#15484) 2018-10-30 17:45:05 -05:00
Shelley Vohr
94f853c654 chore: re-enable execFileSync binary exec spec (#15476) 2018-10-30 15:45:46 -04:00
David Sanders
bae652f46d docs: http protocol handlers can access headers (#15431)
* test: check http protocol handlers can access headers

* docs: http protocol handlers can access headers
2018-10-30 11:37:49 -07:00
Samuel Attard
59ee2859a7 chore: update versioning doc for nightlies (#15468) 2018-10-30 10:33:50 -07:00
Shelley Vohr
2bd94293e0 doc: clarify menu item properties not available top-level (#15458) 2018-10-29 15:04:25 -05:00
David Sanders
c93973ab7a docs: fix protocol.isProtocolHandled documentation (#15430) 2018-10-29 15:23:23 -04:00
Heilig Benedek
894ae1b3f5 refactor: Improve accessibility of menus (#15302)
* refactor: improve menubar keyboard accessibility

* fix: create a temporary widget for tray icon context menu

* fix: focus menu bar with Alt when autohide is off

* fix: make menu bar focus work more like the native menus

* fix: only focus menu bar if it's not already focused

* fix: track accelerator registration to avoid duplicates

* docs: add docs for & notation in app menu item names

* fix: only try to activate accelerator if it's registered

* fix: add friend to monitor window focus change

* style: add <memory> include
2018-10-29 13:08:46 -05:00
John Kleinschmidt
00daff6ac8 docs: add Azure Pipelines status (#15455) 2018-10-29 12:18:34 -04:00
Milan Burda
f921df7ad1 chore: move spellcheck out of chromium_src (#15407) 2018-10-26 10:34:57 -07:00
Shelley Vohr
bea4de9262 fix: use gio as default linux trash impl (#15399)
* fix: use gio as default linux trash impl

* doc: add ELECTRON_TRASH env var
2018-10-26 08:36:56 -07:00
Shelley Vohr
7a03e5f0b2 doc: correct ipcRenderer sendTo windowId param (#15403) 2018-10-26 10:18:47 -05:00
Milan Burda
405edebc51 chore: remove unused chrome_notification_types.h (#15409)
* chore: remove unused chrome_notification_types.h

* chore: remove dummy simple_message_box.h
2018-10-26 10:16:24 -05:00
Milan Burda
d56617e5d0 chore: avoid appending git version to the exported patches (#15389)
* chore: avoid appending git version to the exported patches

* fix no-eol at end of v8 patch
2018-10-26 12:52:59 +05:30
Alexey Kuzmin
ec4a0e096f ci: run more Chromium unit tests (#15363)
* test: add an option to native tests runner to run also disabled tests

* ci: run all native tests on clean Chromium

* ci: update the disabled tests list for native unittests
2018-10-25 14:28:50 -04:00
Shelley Vohr
d21d83cfc8 fix: folder open not working in devtools (#15387) 2018-10-25 08:36:48 -07:00
Milan Burda
1f3a89197c chore: bump minimum supported macOS version to 10.10 (#15357) 2018-10-25 10:59:42 +02:00
Cheng Zhao
2f3a8ecd42 fix: child window with nativeWindowOpen should disable node integration (#15213)
* fix: child window with nativeWindowOpen should disable node integration

* Revert "fix: do not enable node integration in child window if not enabled (#15076)"

This reverts commit 0252d7686c.

This patch is not needed anymore since we are force disabling node integration
for child windows.
2018-10-25 15:31:07 +09:00
Andy Dill
7a23980f4b fix: set NSResizableWindowMask at init time (#15106) 2018-10-25 10:34:11 +09:00
John Kleinschmidt
9086b8067b ci: make sure brew installed node is available in path (#15377) 2018-10-25 11:40:23 +11:00
Islam Sharabash
3b6f0d83e1 fix: allow stream protocols to return headers with multiple values (#14887)
* fix: allow stream protocols to return headers with multiple values

This allows stream protocols to return headers with multiple values as
an array of values.

Fixes https://github.com/electron/electron/issues/14778

* Prefer ConvertFromV8

* Cleanup header conversion

1. Deduplicate the code by using a lambda
2. Remove duplicate calls to headers->Get(key)

* Fix broken test

Headers with multiple values are now being converted correctly, this
test asserted the wrong behavior.
2018-10-25 11:34:20 +11:00
Cheng Zhao
6fa940f2c1 chore: set env when invoking gn (#15354) 2018-10-24 11:25:13 -07:00
Jeremy Apthorp
335e9f68b7 chore: deprecate apply-patches in favour of git-{import,export}-patches (#15300) 2018-10-24 11:24:11 -07:00
Alexey Kuzmin
4185efa08f build: add conditions to check out Chromium and Node.js (#15319) 2018-10-24 13:50:36 -04:00
Milan Burda
8ba271efba refactor: eliminate brightray (#15240) 2018-10-24 12:49:10 +02:00
Jeremy Apthorp
1d8ab03146 refactor: use public WakeLock interface (#15351)
* refactor: use public WakeLock interface

* remove power_save_blocker visibility patch
2018-10-23 22:12:58 -07:00
Shelley Vohr
1f246229b1 test: convert node spec to expect (#15345) 2018-10-24 11:23:12 +11:00
Jeremy Apthorp
9474fc0082 chore: electron alias should be defined with public_deps (#15349) 2018-10-23 17:22:41 -07:00
Jeremy Apthorp
af339f44f4 chore: remove disable_scroll_begin_dcheck.patch (#15233) 2018-10-23 17:21:47 -07:00
Jeremy Apthorp
d03527ae47 build: skip pyproto/ resources in zip.py (#15348) 2018-10-23 17:19:02 -07:00
Shelley Vohr
40874ddec6 fix: update fs methods for options param (#15323)
* fix: update fs methods for options param

* fix: update rest of fs methods with changes
2018-10-23 15:14:05 -07:00
Milan Burda
465dee2c33 refactor: eliminate brightray::BrowserMainParts (#15336) 2018-10-23 13:15:55 -07:00
Charles Kerr
869e0ab14d fix: honor dialog.showMessageBox()'s Icon argument on Linux (#15326)
* Don't call gtk_widget_show_all() on popup dialog.

Fixes #15317.

Notes: Fixed incorrect display of some GtkMessageDialog icons.

The issue is caused because GtkMessageDialog contains an icon widget
which is not shown when there's no associated icon. Our call to
`gtk_widget_show_all()` overrides this, showing the uninitialized
icon widget.

This PR fixes the issue by calling `gtk_widget_show()` where needed
and removing use of `gtk_widget_show_all()` in the message dialog.

* use gtk_dialog_set_default_response() for default

* fix: support icons on gtk+ messageboxes.
2018-10-23 12:44:47 -05:00
Cheng Zhao
260778e0fb feat: add MdTextButton to View APIs (#15328)
* view: make button focusable by default

* view: add MdTextButton

* view: add common methods to LabelButton
2018-10-23 10:57:13 -04:00
Masato Kinugawa
43a8b6039e docs: Fix CSP header setting of sample code (#15313)
* Fix CSP header setting of sample code

Patch for #15310

* Update docs/tutorial/security.md

Co-Authored-By: masatokinugawa <masatokinugawa+github@gmail.com>
2018-10-23 10:38:48 -04:00
Nitish Sakhawalkar
ca4b4709e5 fix: Native window close crash (#15327) 2018-10-23 10:35:00 -04:00
Milan Burda
809bd3757b refactor: eliminate brightray::MainDelegate (#15333) 2018-10-23 14:16:13 +02:00
Milan Burda
fbbb704146 refactor: eliminate brightray::BrowserClient (#15320) 2018-10-23 10:45:41 +02:00
Martin Mädler
a4fefbe836 docs: update Windows build instructions (#14797) 2018-10-22 16:40:39 -04:00
Alexey Kuzmin
5e199152e2 ci: run unittests on clean Chromium (#15125)
* ci: run unittests on clean Chromium

* test: add '--run-only-disabled-tests' flag to "script/native-tests.py"

* ci: add a job to run only disabled unittests

* test: use a different GN config for the native tests

* test: enable blink_common_unittests

* test: disable WeakPtrDeathTest*
2018-10-22 16:12:19 -04:00
Michelle Tilley
13247e592b fix: correct reversed logic in NativeWindowMac::SetEnabled (#15257) 2018-10-22 13:01:45 -07:00
Jeremy Apthorp
044e43397f build: reenable -fwhole-program-vtables (#15228) 2018-10-22 12:07:46 -07:00
Cheng Zhao
cb9be091aa refactor: remove potential double free when managing WebContents (#15280)
* refactor: remove -new-contents-created event

Chromium expects us to take ownership of WebContents in AddNewContents,
we should not create V8 wrapper in WebContentsCreated, otherwise we
would have WebContents being managed by 2 unique_ptr at the same time.

* refactor: make CreateAndTake take unique_ptr
2018-10-22 13:02:25 -05:00
Milan Burda
e8e7edf017 refactor: eliminate brightray::ContentClient (#15303) 2018-10-22 19:04:23 +02:00
Samuel Attard
9262731f2c docs: we don't emit an event object for session-created (#15236) 2018-10-20 19:46:21 -07:00
Alexey Kuzmin
ba7ce7225b build: document env vars expected to be set for the CI configs (#15129)
* ci: add a var for a full path to an Electron build config
* ci: document external environment variables used by the CI build configs
2018-10-20 01:44:36 +02:00
Shelley Vohr
939ee94e67 spec: increase MAS timeout for login items (#15291) 2018-10-19 13:11:11 -07:00
Shelley Vohr
f9f34fd628 fix: ability to fetch separators by id (#15290) 2018-10-19 13:09:40 -07:00
Milan Burda
6d844a0b67 refactor: move media/net from brightray to atom (#15288) 2018-10-19 14:51:43 -04:00
Milan Burda
6f3c46cc7e refactor: move devtools from brightray to atom (#15234) 2018-10-19 15:50:30 +02:00
Samuel Attard
122017e6fa fix: trim app name and productName (#15269)
Fixes #15245
2018-10-19 23:57:55 +11:00
Samuel Attard
16dcc464cf chore: make macOS release builds higher priority to skip the queue (#15276)
Release builds should be run before branch builds on our limited macOS
infra.

Refs: https://docs.microsoft.com/en-us/rest/api/vsts/build/builds/queue?view=vsts-rest-4.1#queuepriority
2018-10-19 23:56:40 +11:00
Cheng Zhao
94aa0762f0 refactor: remove WebContents::CreateFrom (#15241) 2018-10-19 17:52:07 +09:00
Alexey Kuzmin
b3f134de06 test: asyncawaitify one of sandbox related tests (#15252) 2018-10-19 14:28:23 +11:00
Charles Kerr
363712d057 fix: make release-artifact-cleanup executable (#15225)
* fix: make release-artifact-cleanup executable

* fix misc issues in cleanup script
2018-10-18 20:20:43 -07:00
Samuel Attard
8bc0c343fa fix: convert wstring to string on windows in node_bindings (#15266) 2018-10-19 13:11:43 +11:00
Andy Dill
37f2113032 feat: expose setBackgroundThrottling api (#15104) 2018-10-19 11:32:22 +11:00
Eric
10db2bce4e fix: loading of devtools extensions on startup (#13844)
* Fix loading of devtools extensions on startup

The persisted DevTools Extensions were not being loaded correctly at startup. The `addDevToolsExtension` function was not defined when it was being called. An error was being thrown and ignored, so the whole thing would fail silently. I moved the code to load the extensions to the end of the event handler, so now it works.

* fixup: remove trailing spaces to unblock CI

* fixup: add logging when the Electron Enable Logging env var is set

* Fix linter error on undefined srcDirectory

* fixup: catch exception when loading extension

* Revert "fixup: catch exception when loading extension"

This reverts commit 42c2cf95bc.
2018-10-19 11:22:42 +11:00
Nitish Sakhawalkar
c0db0011ec fix: Convert to lower case in upload symbols script (#15258)
* fix: Convert to lower case in upload symbols script

* fix: Convert to lower case in upload symbols script
2018-10-19 11:18:35 +11:00
Jeremy Apthorp
4de502252b chore: roll node (#15177)
* chore: roll node

brings in electron/node#76 and electron/node#77

* chore: roll node
2018-10-19 10:58:46 +11:00
Shelley Vohr
a0b9d47d5e fix: enable NODE_OPTIONS env var (#15158) 2018-10-19 10:57:28 +11:00
Michelle Tilley
51f3fb9bde fix: correctly enable and disable windows on Windows and Linux (#15184) 2018-10-18 14:23:40 -07:00
Jeremy Apthorp
7cab7b6c7e chore: don't set allow_new_privs in new processes (#15229) 2018-10-18 11:53:26 -07:00
Jeremy Apthorp
993c2413e8 chore: add documentation for blink_file_path.patch (#15235) 2018-10-18 11:40:16 -07:00
Nitish Sakhawalkar
a9ca152069 feat: Spellchecker Async Implementation (#14032)
* feat:Spellchecker Async Implementation

* Adhere to chromium style

* Updating dependency to use gh branch

* Update docs and electron-typescript-definitions module

* Fix lint

* Update electron typescript definitions version

* Update spec

* Address review
2018-10-18 11:11:53 -05:00
John Kleinschmidt
4bbb70de74 ci: make sure git directories don't have unneeded files in them (#15247) 2018-10-18 11:35:40 -04:00
Milan Burda
db37ab1039 feat: add remote.require() / remote.getGlobal() filtering (#15014) 2018-10-18 14:36:45 +11:00
Jeremy Apthorp
dffe4fdd4f chore: remove disabling of ANGLE dchecks (#15227) 2018-10-17 17:00:47 -07:00
Jeremy Apthorp
ac6d815c0e chore: remove desktop_screen_win.patch (#15232)
that function is never called with a null argument (all call-sites are guarded)
2018-10-17 16:59:46 -07:00
Jeremy Apthorp
af9cbb4514 chore: remove unnecessary build_toolchain_win_patch.patch (#15231)
it fixed an issue in the GYP build that is no longer present in the GN build
2018-10-17 16:23:00 -07:00
Jeremy Apthorp
04b7f0d2d6 chore: remove skia/dcheck.patch (#15223) 2018-10-17 13:46:10 -07:00
Jeremy Apthorp
65fa9d2883 chore: remove webrtc patch to disable a warning (#15218) 2018-10-17 12:56:08 -07:00
Milan Burda
508551b81b fix: small refactoring regressions (#15206)
* fix: require('@electron/internal/browser/guest-view-manager')

* fix: add missing crashServicePid used by tests
2018-10-17 12:18:18 -07:00
Milan Burda
a369a4172b refactor: move notifications from brightray to atom (#15209) 2018-10-17 20:01:11 +02:00
Heilig Benedek
4d085c4aae fix: don't call ReadRawDataComplete if it's not necessary (#15185) 2018-10-16 21:57:26 -07:00
Adam Meyer
d43ef97a7b add width to webview iframe (#15195) 2018-10-17 09:33:31 +09:00
AbhilashJN
de1d24b616 docs: change examples in docs to use for..of and async/await (#15196) 2018-10-16 10:41:42 -07:00
Cheng Zhao
0252d7686c fix: do not enable node integration in child window if not enabled (#15076) 2018-10-16 18:10:03 +09:00
Jeremy Apthorp
2a4f5c3284 chore: add --fix option to lint:cpp (#14977)
* chore: add --fix option to lint:cpp

* fix lint errors
2018-10-15 22:59:45 -07:00
Heilig Benedek
af0ac9b95c chore: remove ColorChooser file that's no longer used (#15186) 2018-10-16 13:49:57 +11:00
John Kleinschmidt
90d6b91bf7 build: add temporary debugging to generate_breakpad_symbols.py (#15176) 2018-10-16 11:44:14 +11:00
Jeremy Apthorp
30ccb6aea5 fix: allow renaming electron.exe (#15173) 2018-10-15 17:26:34 -07:00
Nitish Sakhawalkar
0c711f690e fix: add microtask runner and fix promise test (#15071)
* fix: Promise resolution and unit test

* Update to use microtask runner

* Address review
2018-10-16 02:26:47 +11:00
Andy Dill
89bf71e580 fix: preserve background color through reload (#15105)
* fix: preserve background color through reload

* fix: only set backgroundColor on top-level frames
2018-10-14 10:59:47 -07:00
Milan Burda
70c49b78ae fix: Memory > Profiles > Load in DevTools (#15151) 2018-10-14 17:30:49 +11:00
Milan Burda
d3efc52745 feat: add webPreferences.enableRemoteModule option (#13028) 2018-10-13 20:50:07 +03:00
Shelley Vohr
72db5ed7cb fix: split out login item tests (#15135) 2018-10-13 18:52:19 +11:00
Samuel Attard
8907053a9d Revert "fix: export zlib symbols (#15103)" (#15138)
This reverts commit 47b12eee57.
2018-10-13 18:51:18 +11:00
Shelley Vohr
05b7c2bf80 chore: update pr template for no-notes (#15137) 2018-10-12 19:24:19 -07:00
John Kleinschmidt
047cad1a4d ci: Fix timeout when generating breakpad symbols (#15126)
* ci: breakup dump symbols into multiple steps.

* Update step-zip-symbols
2018-10-13 13:02:52 +11:00
Heilig Benedek
a82bcc7e3c refactor: move printing out of chromium_src (#15023)
* remove printing related things from chromium_src

* chore: add printing build flag and patch

* fix: include PrintingService on other platforms too

* fix: printing_handler is only needed on Windows

* fix: format BUILD.gn properly

* fix: rename printing build flag to avoid conflict with chromium

* fix: place previously missed printing calls behind build flag

* fix: accidentally renamed flag in patch file

* fix: don't include all printing strings

* fix: allow ShowItemInFolder and OpenItem to block, fixing a DCHECK crash

* fix: make things compile, some changes got lost while rebasing

* fix: remove rogue line from BUILD.gn

* chore: update patch description

* style: lint fix

* chore: use chromium printing buildflag, move node related stuff out of patch

* revert: remove ScopedAllowBlockingForTesting call

* fix: fix my rebase blooper

* fix: re-add header lost during rebase, update patch

* fix: add <map> include, tweak the patch a bit

* revert: remove rogue diff from patch

* fix: clean up after rebase
2018-10-13 12:57:04 +11:00
Samuel Attard
c806c465fa chore: mark browserview api as not-experimental (#15117)
I think it's safe to say this API has been around long enough to be considered past the experimental phase 👍
2018-10-13 12:31:58 +11:00
Shelley Vohr
6fc2a2a051 fix: natively implement LoginItem functions (#15010) 2018-10-12 15:19:27 -07:00
Jeremy Apthorp
e61b88fc2a build: add v8_embedder_string to build args (#15039) 2018-10-12 08:26:35 -07:00
Andy Dill
47b12eee57 fix: export zlib symbols (#15103) 2018-10-12 10:17:06 -04:00
Jeremy Apthorp
783ee3e315 chore: roll node (#15097)
picks up:
- electron/node#73: fix: export libuv symbols
- electron/node#74: fix: include names.h in zlib header package
2018-10-12 09:39:11 -04:00
Sitong Peng
9e7bbcd8f6 docs: app.getLoginItemStatus -> app.getLoginItemSettings (#15093) 2018-10-12 09:23:37 -04:00
Felix Rieseberg
d1b2d1a10e fix: Remove statSyncNoException for good (#15092)
* fix: Small JS assignment error

* fix: Call the right og method

* fix: Goodbye, statSyncNoException
2018-10-12 19:43:19 +11:00
Heilig Benedek
5ef5d60f77 refactor: move color_chooser out of chromium_src (#15091)
* chore: move color_chooser out of chromium_src

* fix: remove deleted source files

* fix: add build flag, patch and build instructions for ColorChooser
2018-10-12 10:53:46 +11:00
Heilig Benedek
95696c9456 refactor: move text-to-speech out of chromium_src (#15024)
* chore: add tts patch and buildflag, makes tts work again

* chore: add tts patch and buildflag, makes tts work again

* fix: make things compile

* build: add relevant tts files for linux

* fix: update patch and patch description, should now compile on mac

* build: move chrome specific sources under chromium_src:chrome target

* build: enable_extensions again

We are depending on them, check `//electron/chromium_src:chrome` target
for more info.

* fix: update tts.patch to receive notifications about browser context destruction

* fix: extend browser process from chrome layer

The global state g_browser_process is shared between //chrome
and //electron.

* spec: add basic speech synthesis test

* spec: skip speech tests on ci

* build: fix compilation on windows
2018-10-11 08:52:12 -05:00
Alexey Kuzmin
5788600c46 Revert "FIXME: disable isCurrentlyAudible test to unblock merge" (#15078)
This reverts commit c8a9a3f63c.
2018-10-11 08:26:37 -05:00
Shelley Vohr
ba9a55c391 fix: update and enable osr (#15046)
* fix: update and enable osr

* fix: update MacHelper view to call GetNativeView

* style: move stuff around to make more sense

* chore: move OSR related things in SetOwnerWindow to CommonWebContentsDelegate

* fix: avoid crashing when GetOffscreenRenderWidgetHostView is called

* fix: specify default for current_device_scale_factor_
2018-10-11 09:14:01 -04:00
Samuel Attard
d46834265f chore: make FILEVERSION 4th component 0 on nightly builds (#15074)
Fixes #14900
2018-10-11 09:11:20 -04:00
Alexey Kuzmin
99f5f17a8d build: add "apply_patches" flag to gclient (#15079) 2018-10-11 15:10:26 +02:00
Alexey Kuzmin
6c3d29712f test: update notification_provenance.patch to fix unittests compilation (#15060) 2018-10-11 10:38:48 +02:00
Jeremy Apthorp
ce26687577 refactor: remove global_shortcut_listener from chromium_src/ (#15070) 2018-10-11 16:02:58 +11:00
1061 changed files with 39411 additions and 35295 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
# These env vars are only necessary for creating Electron releases.
# See docs/development/releasing.md
APPVEYOR_TOKEN=
APPVEYOR_CLOUD_TOKEN=
CIRCLE_TOKEN=
ELECTRON_GITHUB_TOKEN=
VSTS_TOKEN=

33
.github/CODEOWNERS vendored
View File

@@ -3,19 +3,24 @@
# https://help.github.com/articles/about-codeowners
# https://git-scm.com/docs/gitignore
# Everything that falls through the cracks:
* @electron/reviewers
# Most stuff in here is owned by the Community & Safety WG...
/.github/* @electron/wg-community
# filename patterns
*browser_view* @electron/browserview
*notification* @electron/notifications
*pdf* @electron/printing
*printing* @electron/printing
*updater* @electron/updater
# ...except the Admin WG maintains this file.
/.github/CODEOWNERS @electron/wg-admin
# directories
/.github/ @electron/electrocats
/default_app/ @electron/docs
/docs/ @electron/docs
/docs-translations/ @electron/i18n
/npm/ @electron/electrocats
# Upgrades WG
/patches/ @electron/wg-upgrades
# Releases WG
/npm/ @electron/wg-releases
/script/release-notes @electron/wg-releases
/script/prepare-release.js @electron/wg-releases
/script/bump-version.js @electron/wg-releases
/script/ci-release-build.js @electron/wg-releases
/script/release.js @electron/wg-releases
/script/upload-to-github.js @electron/wg-releases
/script/release-artifact-cleanup.js @electron/wg-releases
/script/get-last-major-for-master.js @electron/wg-releases
/script/find-release.js @electron/wg-releases
/script/download-circleci-artifacts.js @electron/wg-releases

View File

@@ -1,4 +1,4 @@
##### Description of Change
#### Description of Change
<!--
Thank you for your Pull Request. Please provide a description above and review
the requirements below.
@@ -6,7 +6,7 @@ the requirements below.
Contributors guide: https://github.com/electron/electron/blob/master/CONTRIBUTING.md
-->
##### Checklist
#### Checklist
<!-- Remove items that do not apply. For completed items, change [ ] to [x]. -->
- [ ] PR description included and stakeholders cc'd
@@ -14,9 +14,9 @@ Contributors guide: https://github.com/electron/electron/blob/master/CONTRIBUTIN
- [ ] tests are [changed or added](https://github.com/electron/electron/blob/master/docs/development/testing.md)
- [ ] relevant documentation is changed or added
- [ ] PR title follows semantic [commit guidelines](https://github.com/electron/electron/blob/master/docs/development/pull-requests.md#commit-message-guidelines)
- [ ] [PR release notes](https://github.com/electron/clerk/blob/master/README.md) describe the change in a way relevant to app developers, and are [capitalized, punctuated, and past tense](https://github.com/electron/clerk/blob/master/README.md#examples).
##### Release Notes
<!-- Used to describe release notes for future release versions. See https://github.com/electron/clerk/blob/master/README.md for details. -->
#### Release Notes
Notes: <!-- One-line Change Summary Here-->
Notes: <!-- Please add a one-line description for app developers to read in the release notes, or `no-notes` if no notes relevant to app developers. Examples and help on special cases: https://github.com/electron/clerk/blob/master/README.md#examples -->

4
.github/config.yml vendored
View File

@@ -36,13 +36,15 @@ newPRWelcomeComment: |
firstPRMergeComment: >
Congrats on merging your first pull request! 🎉🎉🎉
# Configuration for trop - https://github.com/codebytere/trop
# Configuration for trop - https://github.com/electron/trop
watchedProject:
name: Backports
# Users authorized to run manual trop backports
authorizedUsers:
- alexeykuzmin
- BinaryMuse
- ckerr
- codebytere
- deepak1556

10
.gitignore vendored
View File

@@ -16,13 +16,6 @@
*.vcxproj.user
*.xcodeproj
/.idea/
/brightray/brightray.opensdf
/brightray/brightray.sdf
/brightray/brightray.sln
/brightray/brightray.suo
/brightray/brightray.v12.suo
/brightray/brightray.vcxproj*
/brightray/brightray.xcodeproj/
/dist/
/external_binaries/
/out/
@@ -63,3 +56,6 @@ spec/.hash
# Eslint Cache
.eslintcache
# Generated native addon files
/spec/fixtures/native-addon/echo/build/

View File

@@ -1,31 +0,0 @@
pool:
vmImage: 'Ubuntu 16.04'
steps:
- bash: |
# "depot_tools" has to be checkout into "//third_party/depot_tools" so pylint.py can a "pylintrc" file.
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git "${AGENT_BUILDDIRECTORY}/third_party/depot_tools"
echo "##vso[task.setvariable variable=PATH]$PATH:${AGENT_BUILDDIRECTORY}/third_party/depot_tools"
displayName: Setup Depot Tools
- bash: |
chromium_revision="$(grep -A1 chromium_version DEPS | tr -d '\n' | cut -d\' -f4)"
buildtools_revision="$(curl -sL "https://chromium.googlesource.com/chromium/src/+/${chromium_revision}/DEPS?format=TEXT" | base64 -d | grep buildtools_revision -A1 | tr -d '\n' | cut -d\' -f4)"
git clone https://chromium.googlesource.com/chromium/buildtools "${AGENT_TEMPDIRECTORY}/buildtools"
(cd "${AGENT_TEMPDIRECTORY}/buildtools" && git checkout "$buildtools_revision")
echo "##vso[task.setvariable variable=CHROMIUM_BUILDTOOLS_PATH]$AGENT_TEMPDIRECTORY/buildtools"
download_from_google_storage --bucket chromium-gn -s "${AGENT_TEMPDIRECTORY}/buildtools/linux64/gn.sha1"
displayName: Download gn binary
- bash: |
# gn.py tries to find a gclient root folder starting from the current dir.
# When it fails and returns "None" path, the whole script fails. Let's "fix" it.
touch .gclient
# Another option would be to checkout "buildtools" inside the Electron checkout,
# but then we would lint its contents (at least gn format), and it doesn't pass it.
npm install
npm run lint
displayName: Run Lint

487
BUILD.gn
View File

@@ -1,18 +1,20 @@
import("build/asar.gni")
import("build/npm.gni")
import("buildflags/buildflags.gni")
import("electron_paks.gni")
import("filenames.gni")
import("//build/config/locales.gni")
import("//build/config/ui.gni")
import("//build/config/win/manifest.gni")
import("//pdf/features.gni")
import("//services/service_manager/public/service_manifest.gni")
import("//third_party/ffmpeg/ffmpeg_options.gni")
import("//third_party/widevine/cdm/widevine.gni")
import("//tools/generate_library_loader/generate_library_loader.gni")
import("//tools/grit/grit_rule.gni")
import("//tools/grit/repack.gni")
import("//tools/v8_context_snapshot/v8_context_snapshot.gni")
import("//v8/snapshot_toolchain.gni")
import("build/asar.gni")
import("build/extract_symbols.gni")
import("build/js_wrap.gni")
import("build/npm.gni")
import("buildflags/buildflags.gni")
import("electron_paks.gni")
import("filenames.gni")
if (is_mac) {
import("//build/config/mac/rules.gni")
@@ -26,6 +28,13 @@ if (is_linux) {
pkg_config("gio_unix") {
packages = [ "gio-unix-2.0" ]
}
pkg_config("libnotify_config") {
packages = [
"glib-2.0",
"gdk-pixbuf-2.0",
]
}
}
branding = read_file("atom/app/BRANDING.json", "json")
@@ -45,65 +54,82 @@ config("branding") {
]
}
npm_action("atom_browserify_sandbox") {
deps = [
":atom_js2c_copy",
npm_action("atom_browserify_sandbox_unwrapped") {
script = "browserify"
inputs = [
# FIXME(zcbenz): The dependencies of these files are not listed here, so
# the generated file will be out-dated when dependencies are modified.
# Use a script to generate all dependencies and put them here.
"lib/sandboxed_renderer/init.js",
"lib/sandboxed_renderer/api/exports/electron.js",
]
sandbox_args = [
outputs = [
"$target_gen_dir/js2c/preload_bundle_unwrapped.js",
]
args = [
"lib/sandboxed_renderer/init.js",
"-r",
"./lib/sandboxed_renderer/api/exports/electron.js:electron",
"-r",
"./lib/sandboxed_renderer/api/exports/fs.js:fs",
"-r",
"./lib/sandboxed_renderer/api/exports/os.js:os",
"-r",
"./lib/sandboxed_renderer/api/exports/path.js:path",
"-r",
"./lib/sandboxed_renderer/api/exports/child_process.js:child_process",
"-t",
"aliasify",
"--standalone",
"sandboxed_preload",
"-o",
rebase_path(outputs[0]),
]
inputs = [
"lib/sandboxed_renderer/init.js",
"lib/sandboxed_renderer/api/exports/electron.js",
"lib/sandboxed_renderer/api/exports/fs.js",
"lib/sandboxed_renderer/api/exports/os.js",
"lib/sandboxed_renderer/api/exports/path.js",
"lib/sandboxed_renderer/api/exports/child_process.js",
]
outputs = [
"$target_gen_dir/js2c/preload_bundle.js",
]
script = "browserify"
args = sandbox_args + [
"-o",
rebase_path(outputs[0]),
]
}
npm_action("atom_browserify_isolated") {
deps = [
":atom_js2c_copy",
]
npm_action("atom_browserify_isolated_unwrapped") {
script = "browserify"
inputs = [
"lib/isolated_renderer/init.js",
]
outputs = [
"$target_gen_dir/js2c/isolated_bundle_unwrapped.js",
]
args = [
"lib/isolated_renderer/init.js",
"-t",
"aliasify",
"--standalone",
"isolated_preload",
"-o",
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",
]
}
script = "browserify"
args = inputs + [
"-t",
"aliasify",
"-o",
rebase_path(outputs[0]),
]
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") {
@@ -123,23 +149,25 @@ action("atom_js2c") {
":atom_js2c_copy",
]
js2c_sources = filenames.js2c_sources
browserify_sources = [
"$target_gen_dir/js2c/isolated_bundle.js",
"$target_gen_dir/js2c/preload_bundle.js",
]
inputs = js2c_sources + browserify_sources
sources = browserify_sources + [
"$target_gen_dir/js2c/asar.js",
"$target_gen_dir/js2c/asar_init.js",
]
inputs = sources
outputs = [
"$target_gen_dir/atom_natives.h",
"$root_gen_dir/atom_natives.cc",
]
script = "tools/js2c.py"
args = [ rebase_path("//third_party/electron_node") ] +
rebase_path(outputs, root_build_dir) +
[ rebase_path("$target_gen_dir/js2c", root_build_dir) ]
rebase_path(sources, root_build_dir)
}
asar("js2asar") {
@@ -156,6 +184,8 @@ asar("js2asar") {
"lib/browser/api/views/button.js",
"lib/browser/api/views/label-button.js",
"lib/browser/api/views/layout-manager.js",
"lib/browser/api/views/md-text-button.js",
"lib/browser/api/views/resize-area.js",
"lib/browser/api/views/text-field.js",
]
}
@@ -181,18 +211,53 @@ grit("resources") {
"electron_resources.pak",
]
# Mojo manifest overlays are generated.
source_is_generated = true
grit_flags = [
"-E",
"target_gen_dir=" + rebase_path(target_gen_dir, root_build_dir),
]
deps = [
":electron_content_manifest_overlays",
":copy_shell_devtools_discovery_page",
]
output_dir = "$target_gen_dir"
}
copy("copy_shell_devtools_discovery_page") {
sources = [
"//content/shell/resources/shell_devtools_discovery_page.html",
]
outputs = [
"$target_gen_dir/shell_devtools_discovery_page.html",
]
}
if (is_linux) {
generate_library_loader("libnotify_loader") {
name = "LibNotifyLoader"
output_h = "libnotify_loader.h"
output_cc = "libnotify_loader.cc"
header = "<libnotify/notify.h>"
config = ":libnotify_config"
functions = [
"notify_is_initted",
"notify_init",
"notify_get_server_caps",
"notify_get_server_info",
"notify_notification_new",
"notify_notification_add_action",
"notify_notification_set_image_from_pixbuf",
"notify_notification_set_timeout",
"notify_notification_set_hint_string",
"notify_notification_show",
"notify_notification_close",
]
}
}
static_library("electron_lib") {
configs += [ "//v8:external_startup_data" ]
configs += [ "//third_party/electron_node:node_internals" ]
@@ -201,29 +266,39 @@ static_library("electron_lib") {
deps = [
":atom_js2c",
"brightray",
"buildflags",
"chromium_src:chrome",
"manifests",
"native_mate",
"//base",
"//base:base_static",
"//base:i18n",
"//chrome/app/resources:platform_locale_settings",
"//components/certificate_transparency",
"//components/net_log",
"//components/network_session_configurator/common",
"//components/prefs",
"//components/printing/common",
"//components/spellcheck/renderer",
"//components/viz/host",
"//components/viz/service",
"//content/public/app:both",
"//content/public/browser",
"//content/public/child",
"//content/public/common:service_names",
"//gin",
"//media/capture/mojom:video_capture",
"//media/mojo/interfaces",
"//net:extras",
"//net:net_resources",
"//net:net_with_v8",
"//ppapi/host",
"//ppapi/proxy",
"//ppapi/shared_impl",
"//printing",
"//services/audio/public/mojom:constants",
"//services/device/public/mojom",
"//services/proxy_resolver:lib",
"//services/video_capture/public/mojom:constants",
"//services/viz/privileged/interfaces/compositing",
"//skia",
"//third_party/blink/public:blink",
"//third_party/boringssl",
@@ -238,12 +313,6 @@ static_library("electron_lib") {
"//v8",
]
# TODO: this requires a visibility patch to chromium src. it would be better
# to use the publicly-available API, which I think is mojo-based. Once
# electron switches to using the public API, we can remove this from the deps
# list and remove the visibility patch from chromium.
deps += [ "//services/device/wake_lock/power_save_blocker" ]
include_dirs = [
"chromium_src",
".",
@@ -254,9 +323,13 @@ static_library("electron_lib") {
"//third_party/blink/renderer",
]
defines = []
defines = [ "V8_DEPRECATION_WARNINGS" ]
libs = []
if (is_linux) {
defines += [ "GDK_DISABLE_DEPRECATION_WARNINGS" ]
}
extra_source_filters = []
if (!is_linux) {
extra_source_filters += [
@@ -285,8 +358,6 @@ static_library("electron_lib") {
"*_views.cc",
"*_views.h",
"*\bviews/*",
"*/autofill_popup.cc",
"*/autofill_popup.h",
]
}
@@ -295,16 +366,6 @@ static_library("electron_lib") {
sources = filenames.lib_sources
set_sources_assignment_filter(sources_assignment_filter)
sources += [
"$target_gen_dir/atom_natives.h",
"//extensions/browser/app_window/size_constraints.cc",
"//extensions/browser/app_window/size_constraints.h",
"//extensions/common/constants.cc",
"//extensions/common/constants.h",
"//extensions/common/url_pattern.cc",
"//extensions/common/url_pattern.h",
]
if (is_component_build) {
defines += [ "NODE_SHARED_MODE" ]
}
@@ -321,6 +382,10 @@ static_library("electron_lib") {
"//third_party/crashpad/crashpad/client",
"//ui/accelerated_widget_mac",
]
sources += [
"atom/browser/ui/views/autofill_popup_view.cc",
"atom/browser/ui/views/autofill_popup_view.h",
]
include_dirs += [
# NOTE(nornagon): other chromium files use the full path to include
# crashpad; this is just here for compatibility between GN and GYP, so that
@@ -353,8 +418,10 @@ static_library("electron_lib") {
}
if (is_linux) {
deps += [
":libnotify_loader",
"//build/config/linux/gtk",
"//chrome/browser/ui/libgtkui",
"//dbus",
"//device/bluetooth",
"//ui/events/devices/x11",
"//ui/events/platform/x11",
@@ -367,10 +434,10 @@ static_library("electron_lib") {
# Disable warnings for g_settings_list_schemas.
"GLIB_DISABLE_DEPRECATION_WARNINGS",
]
sources += filenames.lib_sources_nss
}
if (is_win) {
sources += filenames.lib_sources_win
libs += [ "dwmapi.lib" ]
}
if (is_linux || is_win) {
@@ -391,12 +458,13 @@ static_library("electron_lib") {
if (enable_osr) {
sources += [
"atom/browser/api/atom_api_web_contents_osr.cc",
"atom/browser/osr/osr_output_device.cc",
"atom/browser/osr/osr_output_device.h",
"atom/browser/osr/osr_host_display_client.cc",
"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.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.h",
"atom/browser/osr/osr_web_contents_view.cc",
@@ -432,23 +500,26 @@ static_library("electron_lib") {
"atom/browser/api/views/atom_api_label_button.h",
"atom/browser/api/views/atom_api_layout_manager.cc",
"atom/browser/api/views/atom_api_layout_manager.h",
"atom/browser/api/views/atom_api_md_text_button.cc",
"atom/browser/api/views/atom_api_md_text_button.h",
"atom/browser/api/views/atom_api_resize_area.cc",
"atom/browser/api/views/atom_api_resize_area.h",
"atom/browser/api/views/atom_api_text_field.cc",
"atom/browser/api/views/atom_api_text_field.h",
]
}
if (enable_pepper_flash) {
deps += [ "components/pepper_flash" ]
if (enable_basic_printing) {
sources += [
"atom/browser/printing/print_preview_message_handler.cc",
"atom/browser/printing/print_preview_message_handler.h",
"atom/renderer/printing/print_render_frame_helper_delegate.cc",
"atom/renderer/printing/print_render_frame_helper_delegate.h",
]
}
if (enable_widevine) {
sources += [
"//chrome/renderer/media/chrome_key_systems.cc",
"//chrome/renderer/media/chrome_key_systems.h",
"//chrome/renderer/media/chrome_key_systems_provider.cc",
"//chrome/renderer/media/chrome_key_systems_provider.h",
]
deps += [ "//components/cdm/renderer" ]
if (enable_pepper_flash) {
deps += [ "components/pepper_flash" ]
}
}
@@ -466,6 +537,7 @@ if (is_mac) {
electron_helper_name = "$electron_product_name Helper"
electron_login_helper_name = "$electron_product_name Login Helper"
electron_framework_version = "A"
electron_version = read_file("ELECTRON_VERSION", "trim string")
mac_xib_bundle_data("electron_xibs") {
sources = [
@@ -548,7 +620,6 @@ if (is_mac) {
}
info_plist = "atom/common/resources/mac/Info.plist"
electron_version = read_file("VERSION", "trim string")
extra_substitutions = [
"ATOM_BUNDLE_ID=$electron_mac_bundle_id.framework",
"ELECTRON_VERSION=$electron_version",
@@ -558,6 +629,7 @@ if (is_mac) {
sources = filenames.framework_sources
libs = [
"AVFoundation.framework",
"Carbon.framework",
"QuartzCore.framework",
"Quartz.framework",
@@ -566,6 +638,11 @@ if (is_mac) {
"ServiceManagement.framework",
"StoreKit.framework",
]
if (enable_osr) {
libs += [ "IOSurface.framework" ]
}
ldflags = [
"-F",
rebase_path("external_binaries", root_build_dir),
@@ -586,6 +663,10 @@ if (is_mac) {
deps = [
":electron_framework+link",
]
if (!is_mas_build) {
deps += [ "//sandbox/mac:seatbelt" ]
}
defines = [ "HELPER_EXECUTABLE" ]
sources = filenames.app_sources
include_dirs = [ "." ]
info_plist = "atom/renderer/resources/mac/Info.plist"
@@ -594,6 +675,12 @@ if (is_mac) {
"-rpath",
"@executable_path/../../..",
]
if (is_component_build) {
ldflags += [
"-rpath",
"@executable_path/../../../../../..",
]
}
}
bundle_data("electron_app_framework_bundle_data") {
@@ -635,13 +722,44 @@ if (is_mac) {
"$root_out_dir/$electron_login_helper_name.app",
]
outputs = [
"{{bundle_contents_dir}}/Library/LoginItems",
"{{bundle_contents_dir}}/Library/LoginItems/{{source_file_part}}",
]
}
action("electron_app_lproj_dirs") {
outputs = []
foreach(locale, locales_as_mac_outputs) {
outputs += [ "$target_gen_dir/app_infoplist_strings/$locale.lproj" ]
}
script = "build/mac/make_locale_dirs.py"
args = rebase_path(outputs)
}
foreach(locale, locales_as_mac_outputs) {
bundle_data("electron_app_strings_${locale}_bundle_data") {
sources = [
"$target_gen_dir/app_infoplist_strings/$locale.lproj",
]
outputs = [
"{{bundle_resources_dir}}/$locale.lproj",
]
public_deps = [
":electron_app_lproj_dirs",
]
}
}
group("electron_app_strings_bundle_data") {
public_deps = []
foreach(locale, locales_as_mac_outputs) {
public_deps += [ ":electron_app_strings_${locale}_bundle_data" ]
}
}
bundle_data("electron_app_resources") {
public_deps = [
":app2asar",
":electron_app_strings_bundle_data",
":js2asar",
]
sources = [
@@ -672,6 +790,56 @@ if (is_mac) {
"@executable_path/../Frameworks",
]
}
if (enable_dsyms) {
extract_symbols("electron_framework_syms") {
binary = "$root_out_dir/$electron_framework_name.framework/Versions/$electron_framework_version/$electron_framework_name"
symbol_dir = "$root_out_dir/breakpad_symbols"
dsym_file = "$root_out_dir/$electron_framework_name.dSYM/Contents/Resources/DWARF/$electron_framework_name"
deps = [
":electron_framework",
]
}
extract_symbols("electron_helper_syms") {
binary = "$root_out_dir/$electron_helper_name.app/Contents/MacOS/$electron_helper_name"
symbol_dir = "$root_out_dir/breakpad_symbols"
dsym_file = "$root_out_dir/$electron_helper_name.dSYM/Contents/Resources/DWARF/$electron_helper_name"
deps = [
":electron_helper_app",
]
}
extract_symbols("electron_app_syms") {
binary = "$root_out_dir/$electron_product_name.app/Contents/MacOS/$electron_product_name"
symbol_dir = "$root_out_dir/breakpad_symbols"
dsym_file = "$root_out_dir/$electron_product_name.dSYM/Contents/Resources/DWARF/$electron_product_name"
deps = [
":electron_app",
]
}
extract_symbols("crashpad_handler_syms") {
binary = "$root_out_dir/crashpad_handler"
symbol_dir = "$root_out_dir/breakpad_symbols"
dsym_file = "$root_out_dir/crashpad_handler.dSYM/Contents/Resources/DWARF/crashpad_handler"
deps = [
"//third_party/crashpad/crashpad/handler:crashpad_handler",
]
}
group("electron_symbols") {
deps = [
":crashpad_handler_syms",
":electron_app_syms",
":electron_framework_syms",
":electron_helper_syms",
]
}
} else {
group("electron_symbols") {
}
}
} else {
windows_manifest("electron_app_manifest") {
sources = [
@@ -750,6 +918,16 @@ if (is_mac) {
"/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll",
"/DELAYLOAD:api-ms-win-core-winrt-string-l1-1-0.dll",
]
# This is to support renaming of electron.exe. node-gyp has hard-coded
# executable names which it will recognise as node. This module definition
# file claims that the electron executable is in fact named "node.exe",
# which is one of the executable names that node-gyp recognizes.
# See https://github.com/nodejs/node-gyp/commit/52ceec3a6d15de3a8f385f43dbe5ecf5456ad07a
ldflags += [ "/DEF:" + rebase_path("build/electron.def", root_build_dir) ]
inputs = [
"build/electron.def",
]
}
if (is_linux) {
ldflags = [ "-pie" ]
@@ -759,74 +937,55 @@ if (is_mac) {
}
}
}
}
group("electron_tests") {
testonly = true
if (is_official_build) {
if (is_linux) {
_target_executable_suffix = ""
_target_shared_library_suffix = ".so"
} else if (is_win) {
_target_executable_suffix = ".exe"
_target_shared_library_suffix = ".dll"
}
deps = [
":chromium_browsertests",
":chromium_unittests",
]
}
extract_symbols("electron_app_symbols") {
binary = "$root_out_dir/$electron_project_name$_target_executable_suffix"
symbol_dir = "$root_out_dir/breakpad_symbols"
deps = [
":electron_app",
]
}
group("chromium_unittests") {
testonly = true
extract_symbols("swiftshader_egl_symbols") {
binary = "$root_out_dir/swiftshader/libEGL$_target_shared_library_suffix"
symbol_dir = "$root_out_dir/breakpad_symbols"
deps = [
"//third_party/swiftshader/src/OpenGL/libEGL:swiftshader_libEGL",
]
}
deps = [
"//base:base_unittests",
"//cc:cc_unittests",
"//content/test:content_unittests",
"//crypto:crypto_unittests",
"//device:device_unittests",
"//gin:gin_unittests",
"//gpu:gpu_unittests",
"//ipc:ipc_tests",
"//media:media_unittests",
"//media/capture:capture_unittests",
"//media/midi:midi_unittests",
"//media/mojo:media_mojo_unittests",
"//mojo:mojo_unittests",
"//net:net_unittests",
"//ppapi:ppapi_unittests",
"//printing:printing_unittests",
"//skia:skia_unittests",
"//sql:sql_unittests",
"//storage:storage_unittests",
"//third_party/angle/src/tests:angle_unittests",
"//third_party/blink/public:all_blink",
"//third_party/blink/public:test_support",
"//third_party/leveldatabase:env_chromium_unittests",
"//ui/base:ui_base_unittests",
"//ui/compositor:compositor_unittests",
"//ui/display:display_unittests",
"//ui/events:events_unittests",
"//ui/gl:gl_unittests",
"//url:url_unittests",
"//url/ipc:url_ipc_unittests",
"//v8/test/unittests:unittests",
]
extract_symbols("swiftshader_gles_symbols") {
binary =
"$root_out_dir/swiftshader/libGLESv2$_target_shared_library_suffix"
symbol_dir = "$root_out_dir/breakpad_symbols"
deps = [
"//third_party/swiftshader/src/OpenGL/libGLESv2:swiftshader_libGLESv2",
]
}
if (is_linux) {
deps += [
"//net:disk_cache_memory_test",
"//sandbox/linux:sandbox_linux_unittests",
]
if (use_dbus) {
deps += [ "//dbus:dbus_unittests" ]
group("electron_symbols") {
deps = [
":electron_app_symbols",
]
if (target_cpu == "x86" || target_cpu == "x64") {
deps += [
":swiftshader_egl_symbols",
":swiftshader_gles_symbols",
]
}
}
}
}
group("chromium_browsertests") {
testonly = true
deps = [
"//content/test:content_browsertests",
]
}
template("dist_zip") {
_runtime_deps_target = "${target_name}__deps"
_runtime_deps_file =
@@ -885,7 +1044,7 @@ group("licenses") {
copy("electron_version") {
sources = [
"VERSION",
"ELECTRON_VERSION",
]
outputs = [
"$root_build_dir/version",
@@ -898,6 +1057,9 @@ dist_zip("electron_dist_zip") {
":licenses",
":electron_version",
]
if (is_linux) {
data_deps += [ "//sandbox/linux:chrome_sandbox" ]
}
outputs = [
"$root_build_dir/dist.zip",
]
@@ -925,6 +1087,7 @@ dist_zip("electron_chromedriver_zip") {
dist_zip("electron_mksnapshot_zip") {
data_deps = [
"//v8:mksnapshot($v8_snapshot_toolchain)",
"//tools/v8_context_snapshot:v8_context_snapshot_generator",
":licenses",
]
outputs = [
@@ -933,23 +1096,7 @@ dist_zip("electron_mksnapshot_zip") {
}
group("electron") {
deps = [
public_deps = [
":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" ]
}
service_manifest("electron_content_browser_manifest_overlay") {
source = "//electron/manifests/electron_content_browser_manifest_overlay.json"
}

41
DEPS
View File

@@ -10,9 +10,9 @@ gclient_gn_args = [
vars = {
'chromium_version':
'69.0.3497.106',
'73.0.3683.121',
'node_version':
'5654c276d0497ff9a0bb0d7550b9073b2e2e7d3f',
'666c67e078bddc32f25409f4a929c1e9b5f47373',
'boto_version': 'f7574aa6cc2c819430c1f05e9a1a1a666ef8169b',
'pyyaml_version': '3.12',
@@ -21,12 +21,23 @@ vars = {
'boto_git': 'https://github.com/boto',
'chromium_git': 'https://chromium.googlesource.com',
'electron_git': 'https://github.com/electron',
'nodejs_git': 'https://github.com/nodejs',
'requests_git': 'https://github.com/kennethreitz',
'yaml_git': 'https://github.com/yaml',
# To be able to build clean Chromium from sources.
'apply_patches': True,
# Python interface to Amazon Web Services. Is used for releases only.
'checkout_boto': False,
# To allow in-house builds to checkout those manually.
'checkout_chromium': True,
'checkout_node': True,
# It's only needed to parse the native tests configurations.
'checkout_pyyaml': False,
# Python "requests" module is used for releases only.
'checkout_requests': False,
@@ -49,12 +60,18 @@ vars = {
}
deps = {
'src':
(Var("chromium_git")) + '/chromium/src.git@' + (Var("chromium_version")),
'src/third_party/electron_node':
(Var("electron_git")) + '/node.git@' + (Var("node_version")),
'src/electron/vendor/pyyaml':
(Var("yaml_git")) + '/pyyaml.git@' + (Var("pyyaml_version")),
'src': {
'url': (Var("chromium_git")) + '/chromium/src.git@' + (Var("chromium_version")),
'condition': 'checkout_chromium',
},
'src/third_party/electron_node': {
'url': (Var("nodejs_git")) + '/node.git@' + (Var("node_version")),
'condition': 'checkout_node',
},
'src/electron/vendor/pyyaml': {
'url': (Var("yaml_git")) + '/pyyaml.git@' + (Var("pyyaml_version")),
'condition': 'checkout_pyyaml',
},
'src/electron/vendor/boto': {
'url': Var('boto_git') + '/boto.git' + '@' + Var('boto_version'),
'condition': 'checkout_boto',
@@ -68,12 +85,12 @@ deps = {
hooks = [
{
'name': 'patch_chromium',
'condition': 'checkout_chromium and apply_patches',
'pattern': 'src/electron',
'action': [
'python',
'src/electron/script/apply-patches',
'--project-root=.',
'--commit',
'src/electron/script/apply_all_patches.py',
'src/electron/patches/common/config.json',
],
},
{
@@ -83,8 +100,6 @@ hooks = [
'action': [
'python',
'src/electron/script/update-external-binaries.py',
'--root-url=http://github.com/electron/electron-frameworks/releases/download',
'--version=v1.4.0',
],
},
{

View File

@@ -16,7 +16,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
locales \
lsb-release \
nano \
python-dbusmock \
python-dbus \
python-pip \
python-setuptools \
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
RUN pip install -U crcmod
# dbusmock is needed for Electron tests
RUN pip install python-dbusmock
RUN mkdir /tmp/workspace
RUN chown builduser:builduser /tmp/workspace

1
ELECTRON_VERSION Normal file
View File

@@ -0,0 +1 @@
5.0.8

View File

@@ -1,4 +1,4 @@
Copyright (c) 2013-2018 GitHub Inc.
Copyright (c) 2013-2019 GitHub Inc.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

View File

@@ -3,6 +3,7 @@
[![CircleCI Build Status](https://circleci.com/gh/electron/electron/tree/master.svg?style=shield)](https://circleci.com/gh/electron/electron/tree/master)
[![AppVeyor Build Status](https://windows-ci.electronjs.org/api/projects/status/nilyf07hcef14dvj/branch/master?svg=true)](https://windows-ci.electronjs.org/project/AppVeyor/electron/branch/master)
[![Azure Pipelines Build Status](https://github.visualstudio.com/electron/_apis/build/status/electron-builds/electron-osx-testing?branchName=master)](https://github.visualstudio.com/electron/_build/latest?definitionId=36)
[![devDependency Status](https://david-dm.org/electron/electron/dev-status.svg)](https://david-dm.org/electron/electron?type=dev)
[![Join the Electron Community on Slack](https://atom-slack.herokuapp.com/badge.svg)](https://atom-slack.herokuapp.com/)

View File

@@ -1 +0,0 @@
4.0.0-nightly.20181010

View File

@@ -1,3 +1,28 @@
# The config expects the following environment variables to be set:
# - "GN_CONFIG" Build type. One of {'debug', 'testing', 'release'}.
# - "GN_EXTRA_ARGS" Additional gn arguments for a build config,
# e.g. 'target_cpu="x86"' to build for a 32bit platform.
# https://gn.googlesource.com/gn/+/master/docs/reference.md#target_cpu
# Don't forget to set up "NPM_CONFIG_ARCH" and "TARGET_ARCH" accordningly
# if you pass a custom value for 'target_cpu'.
# - "ELECTRON_RELEASE" Set it to '1' upload binaries on success.
# - "NPM_CONFIG_ARCH" E.g. 'x86'. Is used to build native Node.js modules.
# Must match 'target_cpu' passed to "GN_EXTRA_ARGS" and "TARGET_ARCH" value.
# - "TARGET_ARCH" Choose from {'ia32', 'x64', 'arm', 'arm64', 'mips64el'}.
# Is used in some publishing scripts, but does NOT affect the Electron binary.
# Must match 'target_cpu' passed to "GN_EXTRA_ARGS" and "NPM_CONFIG_ARCH" value.
# - "UPLOAD_TO_S3" Set it to '1' upload a release to the S3 bucket.
# Otherwise the release will be uploaded to the Github Releases.
# (The value is only checked if "ELECTRON_RELEASE" is defined.)
#
# The publishing scripts expect access tokens to be defined as env vars,
# but those are not covered here.
#
# AppVeyor docs on variables:
# https://www.appveyor.com/docs/environment-variables/
# https://www.appveyor.com/docs/build-configuration/#secure-variables
# https://www.appveyor.com/docs/build-configuration/#custom-environment-variables
version: 1.0.{build}
build_cloud: libcc-20
image: libcc-20-vs2017-15.7.4
@@ -29,7 +54,8 @@ build_script:
"https://github.com/electron/electron"
- gclient sync --with_branch_heads --with_tags
- cd src
- gn gen out/Default "--args=import(\"//electron/build/args/%GN_CONFIG%.gn\") %GN_EXTRA_ARGS%"
- ps: $env:BUILD_CONFIG_PATH="//electron/build/args/%GN_CONFIG%.gn"
- gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") %GN_EXTRA_ARGS%"
- ninja -C out/Default electron:electron_app
- gn gen out/ffmpeg "--args=import(\"//electron/build/args/ffmpeg.gn\") %GN_EXTRA_ARGS%"
- ninja -C out/ffmpeg electron:electron_ffmpeg_zip
@@ -42,20 +68,21 @@ build_script:
- appveyor PushArtifact out/ffmpeg/ffmpeg.zip
- ps: >-
if ($env:GN_CONFIG -eq 'release') {
ninja -C out/Default third_party/breakpad:dump_syms
# Needed for msdia140.dll on 64-bit windows
$env:Path += ";$pwd\third_party\llvm-build\Release+Asserts\bin"
ninja -C out/Default electron:electron_symbols
}
- if "%GN_CONFIG%"=="release" ( python electron\script\dump-symbols.py -d %cd%\out\Default\electron.breakpad.syms -v)
- ps: >-
if ($env:GN_CONFIG -eq 'release') {
python electron\script\zip-symbols.py
appveyor PushArtifact out/Default/symbols.zip
}
- python electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.win.%TARGET_ARCH%.manifest
test_script:
- ps: >-
if ((-Not (Test-Path Env:\ELECTRON_RELEASE)) -And ($env:GN_CONFIG -in "testing", "release")) {
$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 )
- ps: >-
if ($env:RUN_TESTS -eq 'true') {
New-Item .\out\Default\gen\node_headers\Release -Type directory
@@ -64,8 +91,12 @@ test_script:
echo "Skipping tests for $env:GN_CONFIG build"
}
- 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 ..
- 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:
- cd electron
- ps: >-

View File

@@ -7,8 +7,6 @@
#include <string>
#include <vector>
#include "atom/common/atom_version.h"
#include "atom/common/chrome_version.h"
#include "atom/common/options_switches.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
@@ -17,10 +15,10 @@
#include "base/strings/utf_string_conversions.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/pepper_plugin_info.h"
#include "content/public/common/user_agent.h"
#include "electron/buildflags/buildflags.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "url/url_constants.h"
// In SHARED_INTERMEDIATE_DIR.
#include "widevine_cdm_version.h" // NOLINT(build/include)
@@ -179,33 +177,53 @@ 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 {
return l10n_util::GetStringUTF16(message_id);
}
void AtomContentClient::AddAdditionalSchemes(Schemes* schemes) {
schemes->standard_schemes.push_back("chrome-extension");
base::StringPiece AtomContentClient::GetDataResource(
int resource_id,
ui::ScaleFactor scale_factor) const {
return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
resource_id, scale_factor);
}
gfx::Image& AtomContentClient::GetNativeImageNamed(int resource_id) const {
return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
resource_id);
}
base::RefCountedMemory* AtomContentClient::GetDataResourceBytes(
int resource_id) const {
return ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
resource_id);
}
void AtomContentClient::AddAdditionalSchemes(Schemes* schemes) {
std::vector<std::string> splited;
ConvertStringWithSeparatorToVector(&splited, ",",
switches::kRegisterServiceWorkerSchemes);
switches::kServiceWorkerSchemes);
for (const std::string& scheme : splited)
schemes->service_worker_schemes.push_back(scheme);
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);
for (const std::string& scheme : splited)
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(

View File

@@ -9,20 +9,22 @@
#include <string>
#include <vector>
#include "brightray/common/content_client.h"
#include "content/public/common/content_client.h"
namespace atom {
class AtomContentClient : public brightray::ContentClient {
class AtomContentClient : public content::ContentClient {
public:
AtomContentClient();
~AtomContentClient() override;
protected:
// content::ContentClient:
std::string GetProduct() const override;
std::string GetUserAgent() const override;
base::string16 GetLocalizedString(int message_id) const override;
base::StringPiece GetDataResource(int resource_id,
ui::ScaleFactor) const override;
gfx::Image& GetNativeImageNamed(int resource_id) const override;
base::RefCountedMemory* GetDataResourceBytes(int resource_id) const override;
void AddAdditionalSchemes(Schemes* schemes) override;
void AddPepperPlugins(
std::vector<content::PepperPluginInfo>* plugins) override;

View File

@@ -7,11 +7,11 @@
#include "atom/app/atom_main_delegate.h"
#include "atom/app/node_main.h"
#include "atom/common/atom_command_line.h"
#include "atom/common/mac/main_application_bundle.h"
#include "base/at_exit.h"
#include "base/i18n/icu_util.h"
#include "base/mac/bundle_locations.h"
#include "base/mac/scoped_nsautorelease_pool.h"
#include "brightray/common/mac/main_application_bundle.h"
#include "content/public/app/content_main.h"
int AtomMain(int argc, char* argv[]) {
@@ -28,7 +28,7 @@ int AtomInitializeICUandStartNode(int argc, char* argv[]) {
base::AtExitManager atexit_manager;
base::mac::ScopedNSAutoreleasePool pool;
base::mac::SetOverrideFrameworkBundlePath(
brightray::MainApplicationBundlePath()
atom::MainApplicationBundlePath()
.Append("Contents")
.Append("Frameworks")
.Append(ATOM_PRODUCT_NAME " Framework.framework"));

View File

@@ -5,6 +5,7 @@
#include "atom/app/atom_main.h"
#include <cstdlib>
#include <memory>
#include <vector>
#if defined(OS_WIN)
@@ -24,10 +25,15 @@
#include "base/win/windows_version.h"
#include "content/public/app/sandbox_helper_win.h"
#include "sandbox/win/src/sandbox_types.h"
#elif defined(OS_LINUX) // defined(OS_WIN)
#elif defined(OS_LINUX) // defined(OS_WIN)
#include <unistd.h>
#include <cstdio>
#include "atom/app/atom_main_delegate.h" // NOLINT
#include "content/public/app/content_main.h"
#else // defined(OS_LINUX)
#include <mach-o/dyld.h>
#include <unistd.h>
#include <cstdio>
#include "atom/app/atom_library_main.h"
#endif // defined(OS_MACOSX)
@@ -37,13 +43,17 @@
#include "base/i18n/icu_util.h"
#include "electron/buildflags/buildflags.h"
#if defined(HELPER_EXECUTABLE) && !defined(MAS_BUILD)
#include "sandbox/mac/seatbelt_exec.h" // nogncheck
#endif
namespace {
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
const char kRunAsNode[] = "ELECTRON_RUN_AS_NODE";
#endif
bool IsEnvSet(const char* name) {
ALLOW_UNUSED_TYPE bool IsEnvSet(const char* name) {
#if defined(OS_WIN)
size_t required_size;
getenv_s(&required_size, nullptr, 0, name);
@@ -54,6 +64,25 @@ bool IsEnvSet(const char* name) {
#endif
}
#if defined(OS_POSIX)
void FixStdioStreams() {
// libuv may mark stdin/stdout/stderr as close-on-exec, which interferes
// with chromium's subprocess spawning. As a workaround, we detect if these
// streams are closed on startup, and reopen them as /dev/null if necessary.
// Otherwise, an unrelated file descriptor will be assigned as stdout/stderr
// which may cause various errors when attempting to write to them.
//
// For details see https://github.com/libuv/libuv/issues/2062
struct stat st;
if (fstat(STDIN_FILENO, &st) < 0 && errno == EBADF)
ignore_result(freopen("/dev/null", "r", stdin));
if (fstat(STDOUT_FILENO, &st) < 0 && errno == EBADF)
ignore_result(freopen("/dev/null", "w", stdout));
if (fstat(STDERR_FILENO, &st) < 0 && errno == EBADF)
ignore_result(freopen("/dev/null", "w", stderr));
}
#endif
} // namespace
#if defined(OS_WIN)
@@ -155,6 +184,8 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
#elif defined(OS_LINUX) // defined(OS_WIN)
int main(int argc, char* argv[]) {
FixStdioStreams();
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
if (IsEnvSet(kRunAsNode)) {
base::i18n::InitializeICU();
@@ -174,12 +205,43 @@ int main(int argc, char* argv[]) {
#else // defined(OS_LINUX)
int main(int argc, char* argv[]) {
FixStdioStreams();
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
if (IsEnvSet(kRunAsNode)) {
return AtomInitializeICUandStartNode(argc, argv);
}
#endif
#if defined(HELPER_EXECUTABLE) && !defined(MAS_BUILD)
uint32_t exec_path_size = 0;
int rv = _NSGetExecutablePath(NULL, &exec_path_size);
if (rv != -1) {
fprintf(stderr, "_NSGetExecutablePath: get length failed\n");
abort();
}
std::unique_ptr<char[]> exec_path(new char[exec_path_size]);
rv = _NSGetExecutablePath(exec_path.get(), &exec_path_size);
if (rv != 0) {
fprintf(stderr, "_NSGetExecutablePath: get path failed\n");
abort();
}
sandbox::SeatbeltExecServer::CreateFromArgumentsResult seatbelt =
sandbox::SeatbeltExecServer::CreateFromArguments(exec_path.get(), argc,
argv);
if (seatbelt.sandbox_required) {
if (!seatbelt.server) {
fprintf(stderr, "Failed to create seatbelt sandbox server.\n");
abort();
}
if (!seatbelt.server->InitializeSandbox()) {
fprintf(stderr, "Failed to initialize sandbox.\n");
abort();
}
}
#endif // defined(HELPER_EXECUTABLE) && !defined(MAS_BUILD)
return AtomMain(argc, argv);
}

View File

@@ -8,10 +8,13 @@
#include <memory>
#include <string>
#if defined(OS_LINUX)
#include <glib.h> // for g_setenv()
#endif
#include "atom/app/atom_content_client.h"
#include "atom/browser/atom_browser_client.h"
#include "atom/browser/relauncher.h"
#include "atom/common/google_api_key.h"
#include "atom/common/options_switches.h"
#include "atom/renderer/atom_renderer_client.h"
#include "atom/renderer/atom_sandboxed_renderer_client.h"
@@ -20,12 +23,17 @@
#include "base/debug/stack_trace.h"
#include "base/environment.h"
#include "base/logging.h"
#include "base/mac/bundle_locations.h"
#include "base/path_service.h"
#include "chrome/common/chrome_paths.h"
#include "content/public/common/content_switches.h"
#include "electron/buildflags/buildflags.h"
#include "ipc/ipc_buildflags.h"
#include "services/service_manager/embedder/switches.h"
#include "services/service_manager/sandbox/switches.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_switches.h"
#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED)
#define IPC_MESSAGE_MACROS_LOG_ENABLED
@@ -50,6 +58,30 @@ bool IsBrowserProcess(base::CommandLine* cmd) {
return process_type.empty();
}
bool IsSandboxEnabled(base::CommandLine* command_line) {
return command_line->HasSwitch(switches::kEnableSandbox) ||
!command_line->HasSwitch(service_manager::switches::kNoSandbox);
}
// Returns true if this subprocess type needs the ResourceBundle initialized
// and resources loaded.
bool SubprocessNeedsResourceBundle(const std::string& process_type) {
return
#if defined(OS_POSIX) && !defined(OS_MACOSX)
// The zygote process opens the resources for the renderers.
process_type == service_manager::switches::kZygoteProcess ||
#endif
#if defined(OS_MACOSX)
// Mac needs them too for scrollbar related images and for sandbox
// profiles.
process_type == ::switches::kPpapiPluginProcess ||
process_type == ::switches::kPpapiBrokerProcess ||
process_type == ::switches::kGpuProcess ||
#endif
process_type == ::switches::kRendererProcess ||
process_type == ::switches::kUtilityProcess;
}
#if defined(OS_WIN)
void InvalidParameterHandler(const wchar_t*,
const wchar_t*,
@@ -62,6 +94,37 @@ void InvalidParameterHandler(const wchar_t*,
} // namespace
void LoadResourceBundle(const std::string& locale) {
const bool initialized = ui::ResourceBundle::HasSharedInstance();
if (initialized)
ui::ResourceBundle::CleanupSharedInstance();
// Load other resource files.
base::FilePath pak_dir;
#if defined(OS_MACOSX)
pak_dir =
base::mac::FrameworkBundlePath().Append(FILE_PATH_LITERAL("Resources"));
#else
base::PathService::Get(base::DIR_MODULE, &pak_dir);
#endif
ui::ResourceBundle::InitSharedInstanceWithLocale(
locale, nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES);
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
bundle.ReloadLocaleResources(locale);
bundle.AddDataPackFromPath(pak_dir.Append(FILE_PATH_LITERAL("resources.pak")),
ui::SCALE_FACTOR_NONE);
#if BUILDFLAG(ENABLE_PDF_VIEWER)
NOTIMPLEMENTED()
<< "Hi, whoever's fixing PDF support! Thanks! The pdf "
"viewer resources haven't been ported over to the GN build yet, so "
"you'll probably need to change this bit of code.";
bundle.AddDataPackFromPath(
pak_dir.Append(FILE_PATH_LITERAL("pdf_viewer_resources.pak")),
ui::GetSupportedScaleFactors()[0]);
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
}
AtomMainDelegate::AtomMainDelegate() {}
AtomMainDelegate::~AtomMainDelegate() {}
@@ -101,23 +164,19 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
// Logging with pid and timestamp.
logging::SetLogItems(true, false, true, false);
// Enable convient stack printing.
#if defined(DEBUG) && defined(OS_LINUX)
bool enable_stack_dumping = true;
#else
bool enable_stack_dumping = env->HasVar("ELECTRON_ENABLE_STACK_DUMPING");
#endif
#if defined(ARCH_CPU_ARM_FAMILY) && defined(ARCH_CPU_32_BITS)
// For 32bit ARM enabling stack printing would end up crashing.
// https://github.com/electron/electron/pull/11230#issuecomment-363232482
enable_stack_dumping = false;
#endif
if (enable_stack_dumping)
// Enable convient stack printing. This is enabled by default in non-official
// builds.
if (env->HasVar("ELECTRON_ENABLE_STACK_DUMPING"))
base::debug::EnableInProcessStackDumping();
if (env->HasVar("ELECTRON_DISABLE_SANDBOX"))
command_line->AppendSwitch(service_manager::switches::kNoSandbox);
chrome::RegisterPathProvider();
#if defined(OS_MACOSX)
OverrideChildProcessPath();
OverrideFrameworkBundlePath();
SetUpBundleOverrides();
#endif
@@ -129,30 +188,68 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
base::win::DisableHandleVerifier();
#endif
return brightray::MainDelegate::BasicStartupComplete(exit_code);
#if defined(OS_LINUX)
// Check for --no-sandbox parameter when running as root.
if (getuid() == 0 && IsSandboxEnabled(command_line))
LOG(FATAL) << "Running as root without --"
<< service_manager::switches::kNoSandbox
<< " is not supported. See https://crbug.com/638180.";
#endif
content_client_ = std::make_unique<AtomContentClient>();
SetContentClient(content_client_.get());
return false;
}
void AtomMainDelegate::PostEarlyInitialization(bool is_running_tests) {
std::string custom_locale;
ui::ResourceBundle::InitSharedInstanceWithLocale(
custom_locale, nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES);
auto* cmd_line = base::CommandLine::ForCurrentProcess();
if (cmd_line->HasSwitch(::switches::kLang)) {
const std::string locale = cmd_line->GetSwitchValueASCII(::switches::kLang);
const base::FilePath locale_file_path =
ui::ResourceBundle::GetSharedInstance().GetLocaleFilePath(locale, true);
if (!locale_file_path.empty()) {
custom_locale = locale;
#if defined(OS_LINUX)
/* When built with USE_GLIB, libcc's GetApplicationLocaleInternal() uses
* glib's g_get_language_names(), which keys off of getenv("LC_ALL") */
g_setenv("LC_ALL", custom_locale.c_str(), TRUE);
#endif
}
}
#if defined(OS_MACOSX)
if (custom_locale.empty())
l10n_util::OverrideLocaleWithCocoaLocale();
#endif
LoadResourceBundle(custom_locale);
AtomBrowserClient::SetApplicationLocale(
l10n_util::GetApplicationLocale(custom_locale));
}
void AtomMainDelegate::PreSandboxStartup() {
brightray::MainDelegate::PreSandboxStartup();
auto* command_line = base::CommandLine::ForCurrentProcess();
std::string process_type =
command_line->GetSwitchValueASCII(::switches::kProcessType);
// Initialize ResourceBundle which handles files loaded from external
// sources. The language should have been passed in to us from the
// browser process as a command line flag.
if (SubprocessNeedsResourceBundle(process_type)) {
std::string locale = command_line->GetSwitchValueASCII(::switches::kLang);
LoadResourceBundle(locale);
}
// Only append arguments for browser process.
if (!IsBrowserProcess(command_line))
return;
if (!command_line->HasSwitch(switches::kEnableMixedSandbox)) {
if (command_line->HasSwitch(switches::kEnableSandbox)) {
// 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);
} else {
// Disable renderer sandbox for most of node's functions.
command_line->AppendSwitch(service_manager::switches::kNoSandbox);
}
}
// Allow file:// URIs to read other file:// URIs by default.
command_line->AppendSwitch(::switches::kAllowFileAccessFromFiles);
@@ -162,7 +259,7 @@ void AtomMainDelegate::PreSandboxStartup() {
#endif
}
void AtomMainDelegate::PreContentInitialization() {
void AtomMainDelegate::PreCreateMainMessageLoop() {
#if defined(OS_MACOSX)
RegisterAtomCrApp();
#endif
@@ -175,10 +272,9 @@ content::ContentBrowserClient* AtomMainDelegate::CreateContentBrowserClient() {
content::ContentRendererClient*
AtomMainDelegate::CreateContentRendererClient() {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableSandbox) ||
!base::CommandLine::ForCurrentProcess()->HasSwitch(
service_manager::switches::kNoSandbox)) {
auto* command_line = base::CommandLine::ForCurrentProcess();
if (IsSandboxEnabled(command_line)) {
renderer_client_.reset(new AtomSandboxedRendererClient);
} else {
renderer_client_.reset(new AtomRendererClient);
@@ -212,9 +308,12 @@ bool AtomMainDelegate::DelaySandboxInitialization(
}
#endif
std::unique_ptr<brightray::ContentClient>
AtomMainDelegate::CreateContentClient() {
return std::make_unique<AtomContentClient>();
bool AtomMainDelegate::ShouldLockSchemeRegistry() {
return false;
}
bool AtomMainDelegate::ShouldCreateFeatureList() {
return false;
}
} // namespace atom

View File

@@ -8,12 +8,14 @@
#include <memory>
#include <string>
#include "brightray/common/content_client.h"
#include "brightray/common/main_delegate.h"
#include "content/public/app/content_main_delegate.h"
#include "content/public/common/content_client.h"
namespace atom {
class AtomMainDelegate : public brightray::MainDelegate {
void LoadResourceBundle(const std::string& locale);
class AtomMainDelegate : public content::ContentMainDelegate {
public:
AtomMainDelegate();
~AtomMainDelegate() override;
@@ -22,7 +24,8 @@ class AtomMainDelegate : public brightray::MainDelegate {
// content::ContentMainDelegate:
bool BasicStartupComplete(int* exit_code) override;
void PreSandboxStartup() override;
void PreContentInitialization() override;
void PreCreateMainMessageLoop() override;
void PostEarlyInitialization(bool is_running_tests) override;
content::ContentBrowserClient* CreateContentBrowserClient() override;
content::ContentRendererClient* CreateContentRendererClient() override;
content::ContentUtilityClient* CreateContentUtilityClient() override;
@@ -33,20 +36,18 @@ class AtomMainDelegate : public brightray::MainDelegate {
bool ShouldSendMachPort(const std::string& process_type) override;
bool DelaySandboxInitialization(const std::string& process_type) override;
#endif
// brightray::MainDelegate:
std::unique_ptr<brightray::ContentClient> CreateContentClient() override;
#if defined(OS_MACOSX)
void OverrideChildProcessPath() override;
void OverrideFrameworkBundlePath() override;
#endif
bool ShouldLockSchemeRegistry() override;
bool ShouldCreateFeatureList() override;
private:
#if defined(OS_MACOSX)
void OverrideChildProcessPath();
void OverrideFrameworkBundlePath();
void SetUpBundleOverrides();
#endif
std::unique_ptr<content::ContentBrowserClient> browser_client_;
std::unique_ptr<content::ContentClient> content_client_;
std::unique_ptr<content::ContentRendererClient> renderer_client_;
std::unique_ptr<content::ContentUtilityClient> utility_client_;

View File

@@ -5,6 +5,8 @@
#include "atom/app/atom_main_delegate.h"
#include "atom/browser/mac/atom_application.h"
#include "atom/common/application_info.h"
#include "atom/common/mac/main_application_bundle.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/mac/bundle_locations.h"
@@ -12,8 +14,6 @@
#include "base/mac/scoped_nsautorelease_pool.h"
#include "base/path_service.h"
#include "base/strings/sys_string_conversions.h"
#include "brightray/common/application_info.h"
#include "brightray/common/mac/main_application_bundle.h"
#include "content/public/common/content_paths.h"
namespace atom {
@@ -21,9 +21,7 @@ namespace atom {
namespace {
base::FilePath GetFrameworksPath() {
return brightray::MainApplicationBundlePath()
.Append("Contents")
.Append("Frameworks");
return MainApplicationBundlePath().Append("Contents").Append("Frameworks");
}
base::FilePath GetHelperAppPath(const base::FilePath& frameworks_path,
@@ -46,8 +44,7 @@ void AtomMainDelegate::OverrideChildProcessPath() {
base::FilePath helper_path =
GetHelperAppPath(frameworks_path, ATOM_PRODUCT_NAME);
if (!base::PathExists(helper_path))
helper_path =
GetHelperAppPath(frameworks_path, brightray::GetApplicationName());
helper_path = GetHelperAppPath(frameworks_path, GetApplicationName());
if (!base::PathExists(helper_path))
LOG(FATAL) << "Unable to find helper app";
base::PathService::Override(content::CHILD_PROCESS_EXE, helper_path);
@@ -55,7 +52,7 @@ void AtomMainDelegate::OverrideChildProcessPath() {
void AtomMainDelegate::SetUpBundleOverrides() {
base::mac::ScopedNSAutoreleasePool pool;
NSBundle* bundle = brightray::MainApplicationBundle();
NSBundle* bundle = MainApplicationBundle();
std::string base_bundle_id =
base::SysNSStringToUTF8([bundle bundleIdentifier]);
NSString* team_id = [bundle objectForInfoDictionaryKey:@"ElectronTeamID"];

44
atom/app/manifests.cc Normal file
View 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
View 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_

View File

@@ -16,7 +16,7 @@
#include "atom/common/node_bindings.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/task_scheduler/task_scheduler.h"
#include "base/task/task_scheduler/task_scheduler.h"
#include "base/threading/thread_task_runner_handle.h"
#include "gin/array_buffer.h"
#include "gin/public/isolate_holder.h"
@@ -96,6 +96,7 @@ int NodeMain(int argc, char* argv[]) {
}
} while (more == true);
node_debugger.Stop();
exit_code = node::EmitExit(env);
node::RunAtExit(env);
gin_env.platform()->DrainTasks(env->isolate());

View File

@@ -13,6 +13,7 @@
#include "atom/browser/api/gpuinfo_manager.h"
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/atom_paths.h"
#include "atom/browser/login_handler.h"
#include "atom/browser/relauncher.h"
#include "atom/common/atom_command_line.h"
@@ -23,16 +24,13 @@
#include "atom/common/native_mate_converters/net_converter.h"
#include "atom/common/native_mate_converters/network_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "atom/common/options_switches.h"
#include "base/command_line.h"
#include "base/environment.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/sys_info.h"
#include "brightray/browser/brightray_paths.h"
#include "base/system/sys_info.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/icon_manager.h"
#include "chrome/common/chrome_paths.h"
@@ -49,17 +47,23 @@
#include "native_mate/object_template_builder.h"
#include "net/ssl/client_cert_identity.h"
#include "net/ssl/ssl_cert_request_info.h"
#include "services/network/public/cpp/network_switches.h"
#include "services/service_manager/sandbox/switches.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/image/image.h"
// clang-format off
// This header should be declared at the end to avoid
// redefinition errors.
#include "atom/common/node_includes.h" // NOLINT(build/include_alpha)
// clang-format on
#if defined(OS_WIN)
#include "atom/browser/ui/win/jump_list.h"
#include "base/strings/utf_string_conversions.h"
#endif
#if defined(OS_MACOSX)
#include <CoreFoundation/CoreFoundation.h>
#include "atom/browser/ui/cocoa/atom_bundle_mover.h"
#endif
@@ -390,15 +394,15 @@ IconLoader::IconSize GetIconSizeByString(const std::string& size) {
// Return the path constant from string.
int GetPathConstant(const std::string& name) {
if (name == "appData")
return brightray::DIR_APP_DATA;
return DIR_APP_DATA;
else if (name == "userData")
return brightray::DIR_USER_DATA;
return DIR_USER_DATA;
else if (name == "cache")
return brightray::DIR_CACHE;
return DIR_CACHE;
else if (name == "userCache")
return brightray::DIR_USER_CACHE;
return DIR_USER_CACHE;
else if (name == "logs")
return brightray::DIR_APP_LOGS;
return DIR_APP_LOGS;
else if (name == "home")
return base::DIR_HOME;
else if (name == "temp")
@@ -529,18 +533,11 @@ int ImportIntoCertStore(CertificateManagerModel* model,
}
#endif
void OnIconDataAvailable(v8::Isolate* isolate,
const App::FileIconCallback& callback,
gfx::Image* icon) {
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
void OnIconDataAvailable(util::Promise promise, gfx::Image* icon) {
if (icon && !icon->IsEmpty()) {
callback.Run(v8::Null(isolate), *icon);
promise.Resolve(*icon);
} else {
v8::Local<v8::String> error_message =
v8::String::NewFromUtf8(isolate, "Failed to get file icon.");
callback.Run(v8::Exception::Error(error_message), gfx::Image());
promise.RejectWithErrorMessage("Failed to get file icon.");
}
}
@@ -678,7 +675,7 @@ void App::OnLogin(scoped_refptr<LoginHandler> login_handler,
content::WebContents* web_contents = login_handler->GetWebContents();
if (web_contents) {
prevent_default = Emit(
"login", WebContents::CreateFrom(isolate(), web_contents),
"login", WebContents::FromOrCreate(isolate(), web_contents),
request_details, login_handler->auth_info(),
base::Bind(&PassLoginInformation, base::RetainedRef(login_handler)));
}
@@ -692,7 +689,7 @@ bool App::CanCreateWindow(
content::RenderFrameHost* opener,
const GURL& opener_url,
const GURL& opener_top_level_frame_url,
const GURL& source_origin,
const url::Origin& source_origin,
content::mojom::WindowContainerType container_type,
const GURL& target_url,
const content::Referrer& referrer,
@@ -709,9 +706,12 @@ bool App::CanCreateWindow(
content::WebContents* web_contents =
content::WebContents::FromRenderFrameHost(opener);
if (web_contents) {
auto api_web_contents = WebContents::CreateFrom(isolate(), web_contents);
api_web_contents->OnCreateWindow(target_url, referrer, frame_name,
disposition, additional_features, body);
auto api_web_contents = WebContents::From(isolate(), web_contents);
// No need to emit any event if the WebContents is not available in JS.
if (!api_web_contents.IsEmpty()) {
api_web_contents->OnCreateWindow(target_url, referrer, frame_name,
disposition, additional_features, body);
}
}
return false;
@@ -730,7 +730,7 @@ void App::AllowCertificateError(
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
bool prevent_default = Emit(
"certificate-error", WebContents::CreateFrom(isolate(), web_contents),
"certificate-error", WebContents::FromOrCreate(isolate(), web_contents),
request_url, net::ErrorToString(cert_error), ssl_info.cert, callback);
// Deny the certificate by default.
@@ -757,7 +757,7 @@ void App::SelectClientCertificate(
bool prevent_default =
Emit("select-client-certificate",
WebContents::CreateFrom(isolate(), web_contents),
WebContents::FromOrCreate(isolate(), web_contents),
cert_request_info->host_and_port.ToString(), std::move(client_certs),
base::Bind(&OnClientCertificateSelected, isolate(), shared_delegate,
shared_identities));
@@ -779,24 +779,24 @@ void App::OnGpuProcessCrashed(base::TerminationStatus status) {
void App::BrowserChildProcessLaunchedAndConnected(
const content::ChildProcessData& data) {
ChildProcessLaunched(data.process_type, data.handle);
ChildProcessLaunched(data.process_type, data.GetProcess().Handle());
}
void App::BrowserChildProcessHostDisconnected(
const content::ChildProcessData& data) {
ChildProcessDisconnected(base::GetProcId(data.handle));
ChildProcessDisconnected(base::GetProcId(data.GetProcess().Handle()));
}
void App::BrowserChildProcessCrashed(
const content::ChildProcessData& data,
const content::ChildProcessTerminationInfo& info) {
ChildProcessDisconnected(base::GetProcId(data.handle));
ChildProcessDisconnected(base::GetProcId(data.GetProcess().Handle()));
}
void App::BrowserChildProcessKilled(
const content::ChildProcessData& data,
const content::ChildProcessTerminationInfo& info) {
ChildProcessDisconnected(base::GetProcId(data.handle));
ChildProcessDisconnected(base::GetProcId(data.GetProcess().Handle()));
}
void App::RenderProcessReady(content::RenderProcessHost* host) {
@@ -874,6 +874,45 @@ std::string App::GetLocale() {
return g_browser_process->GetApplicationLocale();
}
std::string App::GetLocaleCountryCode() {
std::string region;
#if defined(OS_WIN)
WCHAR locale_name[LOCALE_NAME_MAX_LENGTH] = {0};
if (GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SISO3166CTRYNAME,
(LPWSTR)&locale_name,
sizeof(locale_name) / sizeof(WCHAR)) ||
GetLocaleInfoEx(LOCALE_NAME_SYSTEM_DEFAULT, LOCALE_SISO3166CTRYNAME,
(LPWSTR)&locale_name,
sizeof(locale_name) / sizeof(WCHAR))) {
base::WideToUTF8(locale_name, wcslen(locale_name), &region);
}
#elif defined(OS_MACOSX)
CFLocaleRef locale = CFLocaleCopyCurrent();
CFStringRef value = CFStringRef(
static_cast<CFTypeRef>(CFLocaleGetValue(locale, kCFLocaleCountryCode)));
const CFIndex kCStringSize = 128;
char temporaryCString[kCStringSize] = {0};
CFStringGetCString(value, temporaryCString, kCStringSize,
kCFStringEncodingUTF8);
region = temporaryCString;
#else
const char* locale_ptr = setlocale(LC_TIME, NULL);
if (!locale_ptr)
locale_ptr = setlocale(LC_NUMERIC, NULL);
if (locale_ptr) {
std::string locale = locale_ptr;
std::string::size_type rpos = locale.find('.');
if (rpos != std::string::npos)
locale = locale.substr(0, rpos);
rpos = locale.find('_');
if (rpos != std::string::npos && rpos + 1 < locale.size())
region = locale.substr(rpos + 1);
}
#endif
return region.size() == 2 ? region : std::string();
}
void App::OnSecondInstance(const base::CommandLine::StringVector& cmd,
const base::FilePath& cwd) {
Emit("second-instance", cmd, cwd);
@@ -890,7 +929,7 @@ bool App::RequestSingleInstanceLock() {
return true;
base::FilePath user_dir;
base::PathService::Get(brightray::DIR_USER_DATA, &user_dir);
base::PathService::Get(DIR_USER_DATA, &user_dir);
auto cb = base::Bind(&App::OnSecondInstance, base::Unretained(this));
@@ -976,7 +1015,14 @@ bool App::IsAccessibilitySupportEnabled() {
return ax_state->IsAccessibleBrowser();
}
void App::SetAccessibilitySupportEnabled(bool enabled) {
void App::SetAccessibilitySupportEnabled(bool enabled, mate::Arguments* args) {
if (!Browser::Get()->is_ready()) {
args->ThrowError(
"app.setAccessibilitySupportEnabled() can only be called "
"after app is ready");
return;
}
auto* ax_state = content::BrowserAccessibilityState::GetInstance();
if (enabled) {
ax_state->OnScreenReaderDetected();
@@ -1077,16 +1123,14 @@ JumpListResult App::SetJumpList(v8::Local<v8::Value> val,
}
#endif // defined(OS_WIN)
void App::GetFileIcon(const base::FilePath& path, mate::Arguments* args) {
mate::Dictionary options;
IconLoader::IconSize icon_size;
FileIconCallback callback;
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
v8::Local<v8::Promise> App::GetFileIcon(const base::FilePath& path,
mate::Arguments* args) {
util::Promise promise(isolate());
v8::Local<v8::Promise> handle = promise.GetHandle();
base::FilePath normalized_path = path.NormalizePathSeparators();
IconLoader::IconSize icon_size;
mate::Dictionary options;
if (!args->GetNext(&options)) {
icon_size = IconLoader::IconSize::NORMAL;
} else {
@@ -1095,22 +1139,18 @@ void App::GetFileIcon(const base::FilePath& path, mate::Arguments* args) {
icon_size = GetIconSizeByString(icon_size_string);
}
if (!args->GetNext(&callback)) {
args->ThrowError("Missing required callback function");
return;
}
auto* icon_manager = AtomBrowserMainParts::Get()->GetIconManager();
gfx::Image* icon =
icon_manager->LookupIconFromFilepath(normalized_path, icon_size);
if (icon) {
callback.Run(v8::Null(isolate()), *icon);
promise.Resolve(*icon);
} else {
icon_manager->LoadIcon(
normalized_path, icon_size,
base::Bind(&OnIconDataAvailable, isolate(), callback),
base::BindOnce(&OnIconDataAvailable, std::move(promise)),
&cancelable_task_tracker_);
}
return handle;
}
std::vector<mate::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
@@ -1158,30 +1198,30 @@ v8::Local<v8::Value> App::GetGPUFeatureStatus(v8::Isolate* isolate) {
v8::Local<v8::Promise> App::GetGPUInfo(v8::Isolate* isolate,
const std::string& info_type) {
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") {
promise->RejectWithErrorMessage(
promise.RejectWithErrorMessage(
"Invalid info type. Use 'basic' or 'complete'");
return promise->GetHandle();
return handle;
}
std::string reason;
if (!gpu_data_manager->GpuAccessAllowed(&reason)) {
promise->RejectWithErrorMessage("GPU access not allowed. Reason: " +
reason);
return promise->GetHandle();
promise.RejectWithErrorMessage("GPU access not allowed. Reason: " + reason);
return handle;
}
auto* const info_mgr = GPUInfoManager::GetInstance();
if (info_type == "complete") {
#if defined(OS_WIN)
info_mgr->FetchCompleteInfo(promise);
#if defined(OS_WIN) || defined(OS_MACOSX)
info_mgr->FetchCompleteInfo(std::move(promise));
#else
info_mgr->FetchBasicInfo(promise);
info_mgr->FetchBasicInfo(std::move(promise));
#endif
} 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) {
@@ -1211,19 +1251,6 @@ void App::EnableSandbox(mate::Arguments* args) {
command_line->AppendSwitch(switches::kEnableSandbox);
}
void App::EnableMixedSandbox(mate::Arguments* args) {
if (Browser::Get()->is_ready()) {
args->ThrowError(
"app.enableMixedSandbox() can only be called "
"before app is ready");
return;
}
auto* command_line = base::CommandLine::ForCurrentProcess();
RemoveNoSandboxSwitch(command_line);
command_line->AppendSwitch(switches::kEnableMixedSandbox);
}
#if defined(OS_MACOSX)
bool App::MoveToApplicationsFolder(mate::Arguments* args) {
return ui::cocoa::AtomBundleMover::Move(args);
@@ -1282,8 +1309,15 @@ void App::BuildPrototype(v8::Isolate* isolate,
base::Bind(&Browser::InvalidateCurrentActivity, browser))
.SetMethod("updateCurrentActivity",
base::Bind(&Browser::UpdateCurrentActivity, browser))
// TODO(juturu): Remove in 2.0, deprecate before then with warnings
.SetMethod("moveToApplicationsFolder", &App::MoveToApplicationsFolder)
.SetMethod("isInApplicationsFolder", &App::IsInApplicationsFolder)
#endif
#if defined(OS_MACOSX) || defined(OS_LINUX)
.SetMethod("setAboutPanelOptions",
base::Bind(&Browser::SetAboutPanelOptions, browser))
.SetMethod("showAboutPanel",
base::Bind(&Browser::ShowAboutPanel, browser))
#endif
#if defined(OS_WIN)
.SetMethod("setUserTasks", base::Bind(&Browser::SetUserTasks, browser))
@@ -1300,6 +1334,7 @@ void App::BuildPrototype(v8::Isolate* isolate,
.SetMethod("getPath", &App::GetPath)
.SetMethod("setDesktopName", &App::SetDesktopName)
.SetMethod("getLocale", &App::GetLocale)
.SetMethod("getLocaleCountryCode", &App::GetLocaleCountryCode)
#if defined(USE_NSS_CERTS)
.SetMethod("importCertificate", &App::ImportCertificate)
#endif
@@ -1319,17 +1354,11 @@ void App::BuildPrototype(v8::Isolate* isolate,
.SetMethod("getAppMetrics", &App::GetAppMetrics)
.SetMethod("getGPUFeatureStatus", &App::GetGPUFeatureStatus)
.SetMethod("getGPUInfo", &App::GetGPUInfo)
// TODO(juturu): Remove in 2.0, deprecate before then with warnings
#if defined(OS_MACOSX)
.SetMethod("moveToApplicationsFolder", &App::MoveToApplicationsFolder)
.SetMethod("isInApplicationsFolder", &App::IsInApplicationsFolder)
#endif
#if defined(MAS_BUILD)
.SetMethod("startAccessingSecurityScopedResource",
&App::StartAccessingSecurityScopedResource)
#endif
.SetMethod("enableSandbox", &App::EnableSandbox)
.SetMethod("enableMixedSandbox", &App::EnableMixedSandbox);
.SetMethod("enableSandbox", &App::EnableSandbox);
}
} // namespace api
@@ -1338,25 +1367,6 @@ void App::BuildPrototype(v8::Isolate* isolate,
namespace {
void AppendSwitch(const std::string& switch_string, mate::Arguments* args) {
auto* command_line = base::CommandLine::ForCurrentProcess();
if (base::EndsWith(switch_string, "-path",
base::CompareCase::INSENSITIVE_ASCII) ||
switch_string == network::switches::kLogNetLog) {
base::FilePath path;
args->GetNext(&path);
command_line->AppendSwitchPath(switch_string, path);
return;
}
std::string value;
if (args->GetNext(&value))
command_line->AppendSwitchASCII(switch_string, value);
else
command_line->AppendSwitch(switch_string);
}
#if defined(OS_MACOSX)
int DockBounce(const std::string& type) {
int request_id = -1;
@@ -1377,14 +1387,11 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
auto* command_line = base::CommandLine::ForCurrentProcess();
mate::Dictionary dict(isolate, exports);
dict.Set("App", atom::api::App::GetConstructor(isolate)->GetFunction());
dict.Set("App", atom::api::App::GetConstructor(isolate)
->GetFunction(context)
.ToLocalChecked());
dict.Set("app", atom::api::App::Create(isolate));
dict.SetMethod("appendSwitch", &AppendSwitch);
dict.SetMethod("appendArgument", base::Bind(&base::CommandLine::AppendArg,
base::Unretained(command_line)));
#if defined(OS_MACOSX)
auto browser = base::Unretained(Browser::Get());
dict.SetMethod("dockBounce", &DockBounce);
@@ -1406,4 +1413,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_app, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_app, Initialize)

View File

@@ -141,7 +141,7 @@ class App : public AtomBrowserClient::Delegate,
bool CanCreateWindow(content::RenderFrameHost* opener,
const GURL& opener_url,
const GURL& opener_top_level_frame_url,
const GURL& source_origin,
const url::Origin& source_origin,
content::mojom::WindowContainerType container_type,
const GURL& target_url,
const content::Referrer& referrer,
@@ -182,6 +182,7 @@ class App : public AtomBrowserClient::Delegate,
void SetDesktopName(const std::string& desktop_name);
std::string GetLocale();
std::string GetLocaleCountryCode();
void OnSecondInstance(const base::CommandLine::StringVector& cmd,
const base::FilePath& cwd);
bool HasSingleInstanceLock() const;
@@ -191,20 +192,20 @@ class App : public AtomBrowserClient::Delegate,
void DisableHardwareAcceleration(mate::Arguments* args);
void DisableDomainBlockingFor3DAPIs(mate::Arguments* args);
bool IsAccessibilitySupportEnabled();
void SetAccessibilitySupportEnabled(bool enabled);
void SetAccessibilitySupportEnabled(bool enabled, mate::Arguments* args);
Browser::LoginItemSettings GetLoginItemSettings(mate::Arguments* args);
#if defined(USE_NSS_CERTS)
void ImportCertificate(const base::DictionaryValue& options,
const net::CompletionCallback& callback);
#endif
void GetFileIcon(const base::FilePath& path, mate::Arguments* args);
v8::Local<v8::Promise> GetFileIcon(const base::FilePath& path,
mate::Arguments* args);
std::vector<mate::Dictionary> GetAppMetrics(v8::Isolate* isolate);
v8::Local<v8::Value> GetGPUFeatureStatus(v8::Isolate* isolate);
v8::Local<v8::Promise> GetGPUInfo(v8::Isolate* isolate,
const std::string& info_type);
void EnableSandbox(mate::Arguments* args);
void EnableMixedSandbox(mate::Arguments* args);
#if defined(OS_MACOSX)
bool MoveToApplicationsFolder(mate::Arguments* args);

View File

@@ -147,9 +147,11 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("autoUpdater", AutoUpdater::Create(isolate));
dict.Set("AutoUpdater", AutoUpdater::GetConstructor(isolate)->GetFunction());
dict.Set("AutoUpdater", AutoUpdater::GetConstructor(isolate)
->GetFunction(context)
.ToLocalChecked());
}
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_auto_updater, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_auto_updater, Initialize)

View File

@@ -66,6 +66,7 @@ void BrowserView::Init(v8::Isolate* isolate,
web_contents_.Reset(isolate, web_contents.ToV8());
api_web_contents_ = web_contents.get();
Observe(web_contents->web_contents());
view_.reset(
NativeBrowserView::Create(api_web_contents_->managed_web_contents()));
@@ -74,7 +75,16 @@ void BrowserView::Init(v8::Isolate* isolate,
}
BrowserView::~BrowserView() {
api_web_contents_->DestroyWebContents(true /* async */);
if (api_web_contents_) { // destroy() is called
// Destroy WebContents asynchronously unless app is shutting down,
// because destroy() might be called inside WebContents's event handler.
api_web_contents_->DestroyWebContents(!Browser::Get()->is_shutting_down());
}
}
void BrowserView::WebContentsDestroyed() {
api_web_contents_ = nullptr;
web_contents_.Reset();
}
// static
@@ -149,8 +159,9 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Isolate* isolate = context->GetIsolate();
BrowserView::SetConstructor(isolate, base::Bind(&BrowserView::New));
mate::Dictionary browser_view(
isolate, BrowserView::GetConstructor(isolate)->GetFunction());
mate::Dictionary browser_view(isolate, BrowserView::GetConstructor(isolate)
->GetFunction(context)
.ToLocalChecked());
browser_view.SetMethod("fromId",
&mate::TrackableObject<BrowserView>::FromWeakMapID);
browser_view.SetMethod("getAllViews",
@@ -161,4 +172,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_browser_view, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_browser_view, Initialize)

View File

@@ -10,6 +10,7 @@
#include "atom/browser/api/trackable_object.h"
#include "atom/browser/native_browser_view.h"
#include "content/public/browser/web_contents_observer.h"
#include "native_mate/handle.h"
namespace gfx {
@@ -29,7 +30,8 @@ namespace api {
class WebContents;
class BrowserView : public mate::TrackableObject<BrowserView> {
class BrowserView : public mate::TrackableObject<BrowserView>,
public content::WebContentsObserver {
public:
static mate::WrappableBase* New(mate::Arguments* args);
@@ -47,6 +49,9 @@ class BrowserView : public mate::TrackableObject<BrowserView> {
const mate::Dictionary& options);
~BrowserView() override;
// content::WebContentsObserver:
void WebContentsDestroyed() override;
private:
void Init(v8::Isolate* isolate,
v8::Local<v8::Object> wrapper,

View File

@@ -18,8 +18,10 @@
#include "atom/common/options_switches.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_owner_delegate.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "gin/converter.h"
#include "native_mate/dictionary.h"
#include "ui/gl/gpu_switching_manager.h"
@@ -66,7 +68,7 @@ BrowserWindow::BrowserWindow(v8::Isolate* isolate,
}
web_contents_.Reset(isolate, web_contents.ToV8());
api_web_contents_ = web_contents.get();
api_web_contents_ = web_contents->GetWeakPtr();
api_web_contents_->AddObserver(this);
Observe(api_web_contents_->web_contents());
@@ -74,10 +76,6 @@ BrowserWindow::BrowserWindow(v8::Isolate* isolate,
mate::Dictionary(isolate, web_contents->GetWrapper())
.Set("browserWindowOptions", options);
// Tell the content module to initialize renderer widget with transparent
// mode.
ui::GpuSwitchingManager::SetTransparent(window()->transparent());
// Associate with BrowserWindow.
web_contents->SetOwnerWindow(window());
@@ -88,8 +86,7 @@ BrowserWindow::BrowserWindow(v8::Isolate* isolate,
InitWith(isolate, wrapper);
#if defined(OS_MACOSX)
if (!window()->has_frame())
OverrideNSWindowContentView(web_contents->managed_web_contents());
OverrideNSWindowContentView(web_contents->managed_web_contents());
#endif
// Init window after everything has been setup.
@@ -97,7 +94,9 @@ BrowserWindow::BrowserWindow(v8::Isolate* isolate,
}
BrowserWindow::~BrowserWindow() {
api_web_contents_->RemoveObserver(this);
// FIXME This is a hack rather than a proper fix preventing shutdown crashes.
if (api_web_contents_)
api_web_contents_->RemoveObserver(this);
// Note that the OnWindowClosed will not be called after the destructor runs,
// since the window object is managed by the TopLevelWindow class.
if (web_contents())
@@ -133,7 +132,7 @@ void BrowserWindow::RenderViewCreated(
render_view_host->GetProcess()->GetID(),
render_view_host->GetRoutingID());
if (impl)
impl->SetBackgroundOpaque(false);
impl->owner_delegate()->SetBackgroundOpaque(false);
}
void BrowserWindow::DidFirstVisuallyNonEmptyPaint() {
@@ -185,7 +184,14 @@ bool BrowserWindow::OnMessageReceived(const IPC::Message& message,
}
void BrowserWindow::OnCloseContents() {
DCHECK(web_contents());
// On some machines it may happen that the window gets destroyed for twice,
// checking web_contents() can effectively guard against that.
// https://github.com/electron/electron/issues/16202.
//
// TODO(zcbenz): We should find out the root cause and improve the closing
// procedure of BrowserWindow.
if (!web_contents())
return;
// Close all child windows before closing current window.
v8::Locker locker(isolate());
@@ -234,7 +240,7 @@ void BrowserWindow::OnCloseButtonClicked(bool* prevent_default) {
return;
if (web_contents()->NeedToFireBeforeUnload())
web_contents()->DispatchBeforeUnload();
web_contents()->DispatchBeforeUnload(false /* auto_cancel */);
else
web_contents()->Close();
}
@@ -307,7 +313,29 @@ void BrowserWindow::SetBackgroundColor(const std::string& color_name) {
}
void BrowserWindow::SetBrowserView(v8::Local<v8::Value> value) {
TopLevelWindow::SetBrowserView(value);
TopLevelWindow::ResetBrowserViews();
TopLevelWindow::AddBrowserView(value);
#if defined(OS_MACOSX)
UpdateDraggableRegions(nullptr, draggable_regions_);
#endif
}
void BrowserWindow::AddBrowserView(v8::Local<v8::Value> value) {
TopLevelWindow::AddBrowserView(value);
#if defined(OS_MACOSX)
UpdateDraggableRegions(nullptr, draggable_regions_);
#endif
}
void BrowserWindow::RemoveBrowserView(v8::Local<v8::Value> value) {
TopLevelWindow::RemoveBrowserView(value);
#if defined(OS_MACOSX)
UpdateDraggableRegions(nullptr, draggable_regions_);
#endif
}
void BrowserWindow::ResetBrowserViews() {
TopLevelWindow::ResetBrowserViews();
#if defined(OS_MACOSX)
UpdateDraggableRegions(nullptr, draggable_regions_);
#endif
@@ -315,7 +343,7 @@ void BrowserWindow::SetBrowserView(v8::Local<v8::Value> value) {
void BrowserWindow::SetVibrancy(v8::Isolate* isolate,
v8::Local<v8::Value> value) {
std::string type = mate::V8ToString(value);
std::string type = gin::V8ToString(isolate, value);
auto* render_view_host = web_contents()->GetRenderViewHost();
if (render_view_host) {
@@ -323,7 +351,8 @@ void BrowserWindow::SetVibrancy(v8::Isolate* isolate,
render_view_host->GetProcess()->GetID(),
render_view_host->GetRoutingID());
if (impl)
impl->SetBackgroundOpaque(type.empty() ? !window_->transparent() : false);
impl->owner_delegate()->SetBackgroundOpaque(
type.empty() ? !window_->transparent() : false);
}
TopLevelWindow::SetVibrancy(isolate, value);
@@ -385,7 +414,9 @@ void BrowserWindow::Cleanup() {
if (host)
host->GetWidget()->RemoveInputEventObserver(this);
api_web_contents_->DestroyWebContents(true /* async */);
// Destroy WebContents asynchronously unless app is shutting down,
// because destroy() might be called inside WebContents's event handler.
api_web_contents_->DestroyWebContents(!Browser::Get()->is_shutting_down());
Observe(nullptr);
}
@@ -451,4 +482,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_window, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_window, Initialize)

View File

@@ -72,6 +72,9 @@ class BrowserWindow : public TopLevelWindow,
void Blur() override;
void SetBackgroundColor(const std::string& color_name) override;
void SetBrowserView(v8::Local<v8::Value> value) override;
void AddBrowserView(v8::Local<v8::Value> value) override;
void RemoveBrowserView(v8::Local<v8::Value> value) override;
void ResetBrowserViews() override;
void SetVibrancy(v8::Isolate* isolate, v8::Local<v8::Value> value) override;
// BrowserWindow APIs.
@@ -82,7 +85,7 @@ class BrowserWindow : public TopLevelWindow,
private:
#if defined(OS_MACOSX)
void OverrideNSWindowContentView(brightray::InspectableWebContents* iwc);
void OverrideNSWindowContentView(InspectableWebContents* iwc);
#endif
// Helpers.
@@ -113,7 +116,7 @@ class BrowserWindow : public TopLevelWindow,
#endif
v8::Global<v8::Value> web_contents_;
api::WebContents* api_web_contents_;
base::WeakPtr<api::WebContents> api_web_contents_;
base::WeakPtrFactory<BrowserWindow> weak_factory_;

View File

@@ -8,9 +8,9 @@
#include "atom/browser/native_browser_view.h"
#include "atom/browser/native_window_mac.h"
#include "atom/browser/ui/inspectable_web_contents_view.h"
#include "atom/common/draggable_region.h"
#include "base/mac/scoped_nsobject.h"
#include "brightray/browser/inspectable_web_contents_view.h"
@interface NSView (WebContentsView)
- (void)setMouseDownCanMoveWindow:(BOOL)can_move;
@@ -55,15 +55,20 @@ std::vector<gfx::Rect> CalculateNonDraggableRegions(
} // namespace
void BrowserWindow::OverrideNSWindowContentView(
brightray::InspectableWebContents* iwc) {
void BrowserWindow::OverrideNSWindowContentView(InspectableWebContents* iwc) {
// Make NativeWindow use a NSView as content view.
static_cast<NativeWindowMac*>(window())->OverrideNSWindowContentView();
// Add webview to contentView.
NSView* webView = iwc->GetView()->GetNativeView();
NSView* contentView = [window()->GetNativeWindow() contentView];
NSView* webView = iwc->GetView()->GetNativeView().GetNativeNSView();
NSView* contentView =
[window()->GetNativeWindow().GetNativeNSWindow() contentView];
[webView setFrame:[contentView bounds]];
[contentView addSubview:webView];
// ensure that buttons view is floated to top of view hierarchy
NSArray* subviews = [contentView subviews];
NSView* last = subviews.lastObject;
[contentView addSubview:webView positioned:NSWindowBelow relativeTo:last];
[contentView viewDidMoveToWindow];
}
@@ -76,7 +81,7 @@ void BrowserWindow::UpdateDraggableRegions(
// All ControlRegionViews should be added as children of the WebContentsView,
// because WebContentsView will be removed and re-added when entering and
// leaving fullscreen mode.
NSView* webView = web_contents()->GetNativeView();
NSView* webView = web_contents()->GetNativeView().GetNativeNSView();
NSInteger webViewWidth = NSWidth([webView bounds]);
NSInteger webViewHeight = NSHeight([webView bounds]);
@@ -104,8 +109,10 @@ void BrowserWindow::UpdateDraggableRegions(
DraggableRegionsToSkRegion(regions), webViewWidth, webViewHeight);
}
if (window_->browser_view())
window_->browser_view()->UpdateDraggableRegions(drag_exclude_rects);
auto browser_views = window_->browser_views();
for (NativeBrowserView* view : browser_views) {
(view)->UpdateDraggableRegions(drag_exclude_rects);
}
// Create and add a ControlRegionView for each region that needs to be
// excluded from the dragging.

View File

@@ -7,8 +7,11 @@
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/promise_util.h"
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/threading/thread_restrictions.h"
#include "content/public/browser/tracing_controller.h"
#include "native_mate/dictionary.h"
@@ -23,15 +26,27 @@ struct Converter<base::trace_event::TraceConfig> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
base::trace_event::TraceConfig* out) {
// (alexeykuzmin): A combination of "categoryFilter" and "traceOptions"
// has to be checked first because none of the fields
// in the `memory_dump_config` dict below are mandatory
// and we cannot check the config format.
Dictionary options;
if (!ConvertFromV8(isolate, val, &options))
return false;
std::string category_filter, trace_options;
if (!options.Get("categoryFilter", &category_filter) ||
!options.Get("traceOptions", &trace_options))
return false;
*out = base::trace_event::TraceConfig(category_filter, trace_options);
return true;
if (ConvertFromV8(isolate, val, &options)) {
std::string category_filter, trace_options;
if (options.Get("categoryFilter", &category_filter) &&
options.Get("traceOptions", &trace_options)) {
*out = base::trace_event::TraceConfig(category_filter, trace_options);
return true;
}
}
base::DictionaryValue memory_dump_config;
if (ConvertFromV8(isolate, val, &memory_dump_config)) {
*out = base::trace_event::TraceConfig(memory_dump_config);
return true;
}
return false;
}
};
@@ -45,6 +60,11 @@ scoped_refptr<TracingController::TraceDataEndpoint> GetTraceDataEndpoint(
const base::FilePath& path,
const CompletionCallback& callback) {
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))
LOG(ERROR) << "Creating temporary file failed";
@@ -52,28 +72,72 @@ scoped_refptr<TracingController::TraceDataEndpoint> GetTraceDataEndpoint(
result_file_path, base::Bind(callback, result_file_path));
}
void StopRecording(const base::FilePath& path,
const CompletionCallback& callback) {
TracingController::GetInstance()->StopTracing(
GetTraceDataEndpoint(path, callback));
void OnRecordingStopped(const atom::util::CopyablePromise& promise,
const base::FilePath& path) {
promise.GetPromise().Resolve(path);
}
v8::Local<v8::Promise> StopRecording(v8::Isolate* isolate,
const base::FilePath& path) {
atom::util::Promise promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
// 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;
}
void OnCategoriesAvailable(atom::util::Promise promise,
const std::set<std::string>& categories) {
promise.Resolve(categories);
}
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(
const base::RepeatingCallback<void(float, size_t)>& callback) {
return TracingController::GetInstance()->GetTraceBufferUsage(
base::BindOnce(callback));
}
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
auto controller = base::Unretained(TracingController::GetInstance());
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("getCategories",
base::Bind(&TracingController::GetCategories, controller));
dict.SetMethod("startRecording",
base::Bind(&TracingController::StartTracing, controller));
dict.SetMethod("getCategories", &GetCategories);
dict.SetMethod("startRecording", &StartTracing);
dict.SetMethod("stopRecording", &StopRecording);
dict.SetMethod(
"getTraceBufferUsage",
base::Bind(&TracingController::GetTraceBufferUsage, controller));
dict.SetMethod("getTraceBufferUsage", &GetTraceBufferUsage);
}
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_content_tracing, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_content_tracing, Initialize)

View File

@@ -12,9 +12,11 @@
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/gurl_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "base/task/post_task.h"
#include "base/time/time.h"
#include "base/values.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
@@ -134,74 +136,103 @@ inline net::CookieStore* GetCookieStore(
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.
void RunCallbackInUI(const base::Closure& callback) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback);
void RunCallbackInUI(base::OnceClosure callback) {
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, std::move(callback));
}
// Remove cookies from |list| not matching |filter|, and pass it to |callback|.
void FilterCookies(std::unique_ptr<base::DictionaryValue> filter,
const Cookies::GetCallback& callback,
util::Promise promise,
const net::CookieList& list) {
net::CookieList result;
for (const auto& cookie : list) {
if (MatchesCookie(filter.get(), 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.
void GetCookiesOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
std::unique_ptr<base::DictionaryValue> filter,
const Cookies::GetCallback& callback) {
util::Promise promise) {
std::string url;
filter->GetString("url", &url);
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.
if (url.empty())
GetCookieStore(getter)->GetAllCookiesAsync(filtered_callback);
GetCookieStore(getter)->GetAllCookiesAsync(std::move(filtered_callback));
else
GetCookieStore(getter)->GetAllCookiesForURLAsync(GURL(url),
filtered_callback);
GetCookieStore(getter)->GetAllCookiesForURLAsync(
GURL(url), std::move(filtered_callback));
}
// Removes cookie with |url| and |name| in IO thread.
void RemoveCookieOnIOThread(scoped_refptr<net::URLRequestContextGetter> getter,
const GURL& url,
const std::string& name,
const base::Closure& callback) {
void RemoveCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
const GURL& url,
const std::string& name,
util::Promise promise) {
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.
void OnSetCookie(const Cookies::SetCallback& callback, bool success) {
void OnSetCookie(util::Promise promise, bool success) {
const std::string errmsg = success ? "" : "Setting cookie failed";
RunCallbackInUI(
base::Bind(callback, success ? Cookies::SUCCESS : Cookies::FAILED));
base::BindOnce(SettlePromiseInUI, std::move(promise), errmsg));
}
// Flushes cookie store in IO thread.
void FlushCookieStoreOnIOThread(
scoped_refptr<net::URLRequestContextGetter> getter,
const base::Closure& callback) {
GetCookieStore(getter)->FlushStore(base::BindOnce(RunCallbackInUI, callback));
util::Promise promise) {
GetCookieStore(getter)->FlushStore(
base::BindOnce(ResolvePromiseInUI, std::move(promise)));
}
// Sets cookie with |details| in IO thread.
void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
std::unique_ptr<base::DictionaryValue> details,
const Cookies::SetCallback& callback) {
std::string url, name, value, domain, path;
util::Promise promise) {
std::string url_string, name, value, domain, path;
bool secure = false;
bool http_only = false;
double creation_date;
double expiration_date;
double last_access_date;
details->GetString("url", &url);
details->GetString("url", &url_string);
details->GetString("name", &name);
details->GetString("value", &value);
details->GetString("domain", &domain);
@@ -230,24 +261,27 @@ void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
: base::Time::FromDoubleT(last_access_date);
}
auto completion_callback = base::BindOnce(OnSetCookie, std::move(promise));
GURL url(url_string);
if (!url.is_valid()) {
std::move(completion_callback).Run(false);
return;
}
if (name.empty()) {
std::move(completion_callback).Run(false);
return;
}
std::unique_ptr<net::CanonicalCookie> canonical_cookie(
net::CanonicalCookie::CreateSanitizedCookie(
GURL(url), name, value, domain, path, creation_time, expiration_time,
url, name, value, domain, path, creation_time, expiration_time,
last_access_time, secure, http_only,
net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT));
auto completion_callback = base::BindOnce(OnSetCookie, callback);
if (!canonical_cookie || !canonical_cookie->IsCanonical()) {
std::move(completion_callback).Run(false);
return;
}
if (url.empty()) {
std::move(completion_callback).Run(false);
return;
}
if (name.empty()) {
std::move(completion_callback).Run(false);
return;
}
GetCookieStore(getter)->SetCanonicalCookieAsync(
std::move(canonical_cookie), secure, http_only,
std::move(completion_callback));
@@ -265,44 +299,61 @@ Cookies::Cookies(v8::Isolate* isolate, AtomBrowserContext* browser_context)
Cookies::~Cookies() {}
void Cookies::Get(const base::DictionaryValue& filter,
const GetCallback& callback) {
v8::Local<v8::Promise> Cookies::Get(const base::DictionaryValue& filter) {
util::Promise promise(isolate());
v8::Local<v8::Promise> handle = promise.GetHandle();
auto copy = base::DictionaryValue::From(
base::Value::ToUniquePtrValue(filter.Clone()));
auto* getter = browser_context_->GetRequestContext();
content::BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(GetCookiesOnIO, base::RetainedRef(getter), std::move(copy),
callback));
std::move(promise)));
return handle;
}
void Cookies::Remove(const GURL& url,
const std::string& name,
const base::Closure& callback) {
v8::Local<v8::Promise> Cookies::Remove(const GURL& url,
const std::string& name) {
util::Promise promise(isolate());
v8::Local<v8::Promise> handle = promise.GetHandle();
auto* getter = browser_context_->GetRequestContext();
content::BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::BindOnce(RemoveCookieOnIOThread, base::RetainedRef(getter), url,
name, callback));
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(RemoveCookieOnIO, base::RetainedRef(getter), url, name,
std::move(promise)));
return handle;
}
void Cookies::Set(const base::DictionaryValue& details,
const SetCallback& callback) {
v8::Local<v8::Promise> Cookies::Set(const base::DictionaryValue& details) {
util::Promise promise(isolate());
v8::Local<v8::Promise> handle = promise.GetHandle();
auto copy = base::DictionaryValue::From(
base::Value::ToUniquePtrValue(details.Clone()));
auto* getter = browser_context_->GetRequestContext();
content::BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
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();
content::BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(FlushCookieStoreOnIOThread, base::RetainedRef(getter),
callback));
std::move(promise)));
return handle;
}
void Cookies::OnCookieChanged(const CookieDetails* details) {

View File

@@ -10,6 +10,7 @@
#include "atom/browser/api/trackable_object.h"
#include "atom/browser/net/cookie_details.h"
#include "atom/common/promise_util.h"
#include "base/callback_list.h"
#include "native_mate/handle.h"
#include "net/cookies/canonical_cookie.h"
@@ -35,9 +36,6 @@ class Cookies : public mate::TrackableObject<Cookies> {
FAILED,
};
using GetCallback = base::Callback<void(Error, const net::CookieList&)>;
using SetCallback = base::Callback<void(Error)>;
static mate::Handle<Cookies> Create(v8::Isolate* isolate,
AtomBrowserContext* browser_context);
@@ -49,12 +47,10 @@ class Cookies : public mate::TrackableObject<Cookies> {
Cookies(v8::Isolate* isolate, AtomBrowserContext* browser_context);
~Cookies() override;
void Get(const base::DictionaryValue& filter, const GetCallback& callback);
void Remove(const GURL& url,
const std::string& name,
const base::Closure& callback);
void Set(const base::DictionaryValue& details, const SetCallback& callback);
void FlushStore(const base::Closure& callback);
v8::Local<v8::Promise> Get(const base::DictionaryValue& filter);
v8::Local<v8::Promise> Set(const base::DictionaryValue& details);
v8::Local<v8::Promise> Remove(const GURL& url, const std::string& name);
v8::Local<v8::Promise> FlushStore();
// CookieChangeNotifier subscription:
void OnCookieChanged(const CookieDetails*);

View File

@@ -61,23 +61,26 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
params.Swap(params_value);
Emit("message", method, params);
} else {
auto send_command_callback = pending_requests_[id];
pending_requests_.erase(id);
if (send_command_callback.is_null())
auto it = pending_requests_.find(id);
if (it == pending_requests_.end())
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;
base::DictionaryValue result;
if (dict->GetDictionary("result", &result_body))
result.Swap(result_body);
send_command_callback.Run(has_error ? error.Clone() : base::Value(),
result);
atom::util::Promise promise = std::move(it->second);
pending_requests_.erase(it);
base::DictionaryValue* error = nullptr;
if (dict->GetDictionary("error", &error)) {
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());
}
void Debugger::SendCommand(mate::Arguments* args) {
if (!agent_host_)
return;
v8::Local<v8::Promise> Debugger::SendCommand(mate::Arguments* args) {
atom::util::Promise promise(isolate());
v8::Local<v8::Promise> handle = promise.GetHandle();
if (!agent_host_) {
promise.RejectWithErrorMessage("No target available");
return handle;
}
std::string method;
if (!args->GetNext(&method)) {
args->ThrowError();
return;
promise.RejectWithErrorMessage("Invalid method");
return handle;
}
base::DictionaryValue command_params;
args->GetNext(&command_params);
SendCommandCallback callback;
args->GetNext(&callback);
base::DictionaryValue request;
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.SetString("method", method);
if (!command_params.empty())
@@ -151,16 +158,13 @@ void Debugger::SendCommand(mate::Arguments* args) {
std::string json_args;
base::JSONWriter::Write(request, &json_args);
agent_host_->DispatchProtocolMessage(this, json_args);
return handle;
}
void Debugger::ClearPendingRequests() {
if (pending_requests_.empty())
return;
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());
for (auto& it : pending_requests_)
it.second.RejectWithErrorMessage("target closed while handling command");
}
// static
@@ -194,9 +198,11 @@ void Initialize(v8::Local<v8::Object> exports,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary(isolate, exports)
.Set("Debugger", Debugger::GetConstructor(isolate)->GetFunction());
.Set("Debugger", Debugger::GetConstructor(isolate)
->GetFunction(context)
.ToLocalChecked());
}
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_debugger, Initialize);
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_debugger, Initialize);

View File

@@ -9,6 +9,7 @@
#include <string>
#include "atom/browser/api/trackable_object.h"
#include "atom/common/promise_util.h"
#include "base/callback.h"
#include "base/values.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::WebContentsObserver {
public:
using SendCommandCallback =
base::Callback<void(const base::Value&, const base::Value&)>;
static mate::Handle<Debugger> Create(v8::Isolate* isolate,
content::WebContents* web_contents);
@@ -56,12 +54,12 @@ class Debugger : public mate::TrackableObject<Debugger>,
content::RenderFrameHost* new_rfh) override;
private:
using PendingRequestMap = std::map<int, SendCommandCallback>;
using PendingRequestMap = std::map<int, atom::util::Promise>;
void Attach(mate::Arguments* args);
bool IsAttached();
void Detach();
void SendCommand(mate::Arguments* args);
v8::Local<v8::Promise> SendCommand(mate::Arguments* args);
void ClearPendingRequests();
content::WebContents* web_contents_; // Weak Reference.

View File

@@ -14,6 +14,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/media/webrtc/desktop_media_list.h"
#include "chrome/browser/media/webrtc/window_icon_util.h"
#include "content/public/browser/desktop_capture.h"
#include "native_mate/dictionary.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h"
@@ -42,6 +43,12 @@ struct Converter<atom::api::DesktopCapturer::Source> {
atom::api::NativeImage::Create(
isolate, gfx::Image(source.media_list_source.thumbnail)));
dict.Set("display_id", source.display_id);
if (source.fetch_icon) {
dict.Set(
"appIcon",
atom::api::NativeImage::Create(
isolate, gfx::Image(GetWindowIcon(source.media_list_source.id))));
}
return ConvertToV8(isolate, dict);
}
};
@@ -60,7 +67,9 @@ DesktopCapturer::~DesktopCapturer() {}
void DesktopCapturer::StartHandling(bool capture_window,
bool capture_screen,
const gfx::Size& thumbnail_size) {
const gfx::Size& thumbnail_size,
bool fetch_window_icons) {
fetch_window_icons_ = fetch_window_icons;
#if defined(OS_WIN)
if (content::desktop_capture::CreateDesktopCaptureOptions()
.allow_directx_capturer()) {
@@ -79,10 +88,6 @@ void DesktopCapturer::StartHandling(bool capture_window,
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.
// Apply the new thumbnail size and restart capture.
if (capture_window) {
@@ -134,8 +139,8 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
capture_window_ = false;
const auto& media_list_sources = list->GetSources();
for (const auto& media_list_source : media_list_sources) {
window_sources.emplace_back(
DesktopCapturer::Source{media_list_source, std::string()});
window_sources.emplace_back(DesktopCapturer::Source{
media_list_source, std::string(), fetch_window_icons_});
}
std::move(window_sources.begin(), window_sources.end(),
std::back_inserter(captured_sources_));
@@ -187,7 +192,7 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
}
if (!capture_window_ && !capture_screen_)
Emit("finished", captured_sources_);
Emit("finished", captured_sources_, fetch_window_icons_);
}
// static
@@ -221,4 +226,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_desktop_capturer, Initialize);
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_desktop_capturer, Initialize);

View File

@@ -9,7 +9,7 @@
#include <string>
#include <vector>
#include "atom/browser/api/event_emitter.h"
#include "atom/browser/api/trackable_object.h"
#include "chrome/browser/media/webrtc/desktop_media_list_observer.h"
#include "chrome/browser/media/webrtc/native_desktop_media_list.h"
#include "native_mate/handle.h"
@@ -18,13 +18,16 @@ namespace atom {
namespace api {
class DesktopCapturer : public mate::EventEmitter<DesktopCapturer>,
class DesktopCapturer : public mate::TrackableObject<DesktopCapturer>,
public DesktopMediaListObserver {
public:
struct Source {
DesktopMediaList::Source media_list_source;
// Will be an empty string if not available.
std::string display_id;
// Whether or not this source should provide an icon.
bool fetch_icon = false;
};
static mate::Handle<DesktopCapturer> Create(v8::Isolate* isolate);
@@ -34,7 +37,8 @@ class DesktopCapturer : public mate::EventEmitter<DesktopCapturer>,
void StartHandling(bool capture_window,
bool capture_screen,
const gfx::Size& thumbnail_size);
const gfx::Size& thumbnail_size,
bool fetch_window_icons);
protected:
explicit DesktopCapturer(v8::Isolate* isolate);
@@ -59,6 +63,7 @@ class DesktopCapturer : public mate::EventEmitter<DesktopCapturer>,
std::vector<DesktopCapturer::Source> captured_sources_;
bool capture_window_ = false;
bool capture_screen_ = false;
bool fetch_window_icons_ = false;
#if defined(OS_WIN)
bool using_directx_capturer_ = false;
#endif // defined(OS_WIN)

View File

@@ -12,6 +12,7 @@
#include "atom/browser/ui/file_dialog.h"
#include "atom/browser/ui/message_box.h"
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/file_dialog_converter.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "atom/common/native_mate_converters/image_converter.h"
#include "atom/common/native_mate_converters/net_converter.h"
@@ -19,50 +20,6 @@
#include "atom/common/node_includes.h"
namespace mate {
template <>
struct Converter<file_dialog::Filter> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
file_dialog::Filter* out) {
mate::Dictionary dict;
if (!ConvertFromV8(isolate, val, &dict))
return false;
if (!dict.Get("name", &(out->first)))
return false;
if (!dict.Get("extensions", &(out->second)))
return false;
return true;
}
};
template <>
struct Converter<file_dialog::DialogSettings> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
file_dialog::DialogSettings* out) {
mate::Dictionary dict;
if (!ConvertFromV8(isolate, val, &dict))
return false;
dict.Get("window", &(out->parent_window));
dict.Get("title", &(out->title));
dict.Get("message", &(out->message));
dict.Get("buttonLabel", &(out->button_label));
dict.Get("nameFieldLabel", &(out->name_field_label));
dict.Get("defaultPath", &(out->default_path));
dict.Get("filters", &(out->filters));
dict.Get("properties", &(out->properties));
dict.Get("showsTagField", &(out->shows_tag_field));
#if defined(MAS_BUILD)
dict.Get("securityScopedBookmarks", &(out->security_scoped_bookmarks));
#endif
return true;
}
};
} // namespace mate
namespace {
void ShowMessageBox(int type,
@@ -139,4 +96,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_dialog, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_dialog, Initialize)

View File

@@ -8,6 +8,7 @@
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/file_dialog_converter.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "atom/common/native_mate_converters/gurl_converter.h"
#include "base/strings/utf_string_conversions.h"
@@ -102,7 +103,7 @@ bool DownloadItem::IsPaused() const {
}
void DownloadItem::Resume() {
download_item_->Resume();
download_item_->Resume(true /* user_gesture */);
}
bool DownloadItem::CanResume() const {
@@ -165,6 +166,15 @@ base::FilePath DownloadItem::GetSavePath() const {
return save_path_;
}
file_dialog::DialogSettings DownloadItem::GetSaveDialogOptions() const {
return dialog_options_;
}
void DownloadItem::SetSaveDialogOptions(
const file_dialog::DialogSettings& options) {
dialog_options_ = options;
}
std::string DownloadItem::GetLastModifiedTime() const {
return download_item_->GetLastModifiedTime();
}
@@ -200,6 +210,8 @@ void DownloadItem::BuildPrototype(v8::Isolate* isolate,
.SetMethod("isDone", &DownloadItem::IsDone)
.SetMethod("setSavePath", &DownloadItem::SetSavePath)
.SetMethod("getSavePath", &DownloadItem::GetSavePath)
.SetMethod("setSaveDialogOptions", &DownloadItem::SetSaveDialogOptions)
.SetMethod("getSaveDialogOptions", &DownloadItem::GetSaveDialogOptions)
.SetMethod("getLastModifiedTime", &DownloadItem::GetLastModifiedTime)
.SetMethod("getETag", &DownloadItem::GetETag)
.SetMethod("getStartTime", &DownloadItem::GetStartTime);
@@ -232,10 +244,11 @@ void Initialize(v8::Local<v8::Object> exports,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary(isolate, exports)
.Set("DownloadItem",
atom::api::DownloadItem::GetConstructor(isolate)->GetFunction());
.Set("DownloadItem", atom::api::DownloadItem::GetConstructor(isolate)
->GetFunction(context)
.ToLocalChecked());
}
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_download_item, Initialize);
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_download_item, Initialize);

View File

@@ -9,6 +9,7 @@
#include <vector>
#include "atom/browser/api/trackable_object.h"
#include "atom/browser/ui/file_dialog.h"
#include "base/files/file_path.h"
#include "components/download/public/common/download_item.h"
#include "native_mate/handle.h"
@@ -44,6 +45,8 @@ class DownloadItem : public mate::TrackableObject<DownloadItem>,
bool IsDone() const;
void SetSavePath(const base::FilePath& path);
base::FilePath GetSavePath() const;
file_dialog::DialogSettings GetSaveDialogOptions() const;
void SetSaveDialogOptions(const file_dialog::DialogSettings& options);
std::string GetLastModifiedTime() const;
std::string GetETag() const;
double GetStartTime() const;
@@ -58,6 +61,7 @@ class DownloadItem : public mate::TrackableObject<DownloadItem>,
private:
base::FilePath save_path_;
file_dialog::DialogSettings dialog_options_;
download::DownloadItem* download_item_;
DISALLOW_COPY_AND_ASSIGN(DownloadItem);

View File

@@ -0,0 +1,26 @@
// Copyright (c) 2018 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/browser/api/event_emitter.h"
#include "atom/common/node_includes.h"
#include "native_mate/dictionary.h"
namespace {
v8::Local<v8::Object> CreateWithSender(v8::Isolate* isolate,
v8::Local<v8::Object> sender) {
return mate::internal::CreateJSEvent(isolate, sender, nullptr, nullptr);
}
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("createWithSender", &CreateWithSender);
}
} // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_event, Initialize)

View File

@@ -5,16 +5,46 @@
#include "atom/browser/api/atom_api_global_shortcut.h"
#include <string>
#include <vector>
#include "atom/browser/api/atom_api_system_preferences.h"
#include "atom/common/native_mate_converters/accelerator_converter.h"
#include "atom/common/native_mate_converters/callback.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "native_mate/dictionary.h"
#include "atom/common/node_includes.h"
#if defined(OS_MACOSX)
#include "base/mac/mac_util.h"
#endif
using extensions::GlobalShortcutListener;
namespace {
#if defined(OS_MACOSX)
bool RegisteringMediaKeyForUntrustedClient(const ui::Accelerator& accelerator) {
if (base::mac::IsAtLeastOS10_14()) {
constexpr ui::KeyboardCode mediaKeys[] = {
ui::VKEY_MEDIA_PLAY_PAUSE, ui::VKEY_MEDIA_NEXT_TRACK,
ui::VKEY_MEDIA_PREV_TRACK, ui::VKEY_MEDIA_STOP};
if (std::find(std::begin(mediaKeys), std::end(mediaKeys),
accelerator.key_code()) != std::end(mediaKeys)) {
bool trusted =
atom::api::SystemPreferences::IsTrustedAccessibilityClient(false);
if (!trusted)
return true;
}
}
return false;
}
#endif
} // namespace
namespace atom {
namespace api {
@@ -31,15 +61,43 @@ void GlobalShortcut::OnKeyPressed(const ui::Accelerator& accelerator) {
if (accelerator_callback_map_.find(accelerator) ==
accelerator_callback_map_.end()) {
// This should never occur, because if it does, GlobalGlobalShortcutListener
// notifes us with wrong accelerator.
// notifies us with wrong accelerator.
NOTREACHED();
return;
}
accelerator_callback_map_[accelerator].Run();
}
bool GlobalShortcut::RegisterAll(
const std::vector<ui::Accelerator>& accelerators,
const base::Closure& callback) {
std::vector<ui::Accelerator> registered;
for (auto& accelerator : accelerators) {
#if defined(OS_MACOSX)
if (RegisteringMediaKeyForUntrustedClient(accelerator))
return false;
GlobalShortcutListener* listener = GlobalShortcutListener::GetInstance();
if (!listener->RegisterAccelerator(accelerator, this)) {
// unregister all shortcuts if any failed
UnregisterSome(registered);
return false;
}
#endif
registered.push_back(accelerator);
accelerator_callback_map_[accelerator] = callback;
}
return true;
}
bool GlobalShortcut::Register(const ui::Accelerator& accelerator,
const base::Closure& callback) {
#if defined(OS_MACOSX)
if (RegisteringMediaKeyForUntrustedClient(accelerator))
return false;
#endif
if (!GlobalShortcutListener::GetInstance()->RegisterAccelerator(accelerator,
this)) {
return false;
@@ -58,6 +116,13 @@ void GlobalShortcut::Unregister(const ui::Accelerator& accelerator) {
this);
}
void GlobalShortcut::UnregisterSome(
const std::vector<ui::Accelerator>& accelerators) {
for (auto& accelerator : accelerators) {
Unregister(accelerator);
}
}
bool GlobalShortcut::IsRegistered(const ui::Accelerator& accelerator) {
return ContainsKey(accelerator_callback_map_, accelerator);
}
@@ -77,6 +142,7 @@ void GlobalShortcut::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "GlobalShortcut"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.SetMethod("registerAll", &GlobalShortcut::RegisterAll)
.SetMethod("register", &GlobalShortcut::Register)
.SetMethod("isRegistered", &GlobalShortcut::IsRegistered)
.SetMethod("unregister", &GlobalShortcut::Unregister)
@@ -100,4 +166,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_global_shortcut, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_global_shortcut, Initialize)

View File

@@ -7,6 +7,7 @@
#include <map>
#include <string>
#include <vector>
#include "atom/browser/api/trackable_object.h"
#include "base/callback.h"
@@ -33,10 +34,13 @@ class GlobalShortcut : public extensions::GlobalShortcutListener::Observer,
private:
typedef std::map<ui::Accelerator, base::Closure> AcceleratorCallbackMap;
bool RegisterAll(const std::vector<ui::Accelerator>& accelerators,
const base::Closure& callback);
bool Register(const ui::Accelerator& accelerator,
const base::Closure& callback);
bool IsRegistered(const ui::Accelerator& accelerator);
void Unregister(const ui::Accelerator& accelerator);
void UnregisterSome(const std::vector<ui::Accelerator>& accelerators);
void UnregisterAll();
// GlobalShortcutListener::Observer implementation.

View File

@@ -62,7 +62,7 @@ struct Converter<in_app_purchase::Product> {
dict.Set("formattedPrice", val.formattedPrice);
// Downloadable Content Information
dict.Set("isDownloadable", val.downloadable);
dict.Set("isDownloadable", val.isDownloadable);
return dict.GetHandle();
}
@@ -132,11 +132,12 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("inAppPurchase", InAppPurchase::Create(isolate));
dict.Set("InAppPurchase",
InAppPurchase::GetConstructor(isolate)->GetFunction());
dict.Set("InAppPurchase", InAppPurchase::GetConstructor(isolate)
->GetFunction(context)
.ToLocalChecked());
#endif
}
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_in_app_purchase, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_in_app_purchase, Initialize)

View File

@@ -41,6 +41,8 @@ void Menu::AfterInit(v8::Isolate* isolate) {
delegate.Get("isCommandIdEnabled", &is_enabled_);
delegate.Get("isCommandIdVisible", &is_visible_);
delegate.Get("getAcceleratorForCommandId", &get_accelerator_);
delegate.Get("shouldRegisterAcceleratorForCommandId",
&should_register_accelerator_);
delegate.Get("executeCommand", &execute_command_);
delegate.Get("menuWillShow", &menu_will_show_);
}
@@ -74,6 +76,12 @@ bool Menu::GetAcceleratorForCommandIdWithParams(
return mate::ConvertFromV8(isolate(), val, accelerator);
}
bool Menu::ShouldRegisterAcceleratorForCommandId(int command_id) const {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
return should_register_accelerator_.Run(GetWrapper(), command_id);
}
void Menu::ExecuteCommand(int command_id, int flags) {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
@@ -82,7 +90,7 @@ void Menu::ExecuteCommand(int command_id, int flags) {
command_id);
}
void Menu::MenuWillShow(ui::SimpleMenuModel* source) {
void Menu::OnMenuWillShow(ui::SimpleMenuModel* source) {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
menu_will_show_.Run(GetWrapper());
@@ -155,6 +163,12 @@ base::string16 Menu::GetSublabelAt(int index) const {
return model_->GetSublabelAt(index);
}
base::string16 Menu::GetAcceleratorTextAt(int index) const {
ui::Accelerator accelerator;
model_->GetAcceleratorAtWithParams(index, true, &accelerator);
return accelerator.GetShortcutText();
}
bool Menu::IsItemCheckedAt(int index) const {
return model_->IsItemCheckedAt(index);
}
@@ -195,6 +209,7 @@ void Menu::BuildPrototype(v8::Isolate* isolate,
.SetMethod("getCommandIdAt", &Menu::GetCommandIdAt)
.SetMethod("getLabelAt", &Menu::GetLabelAt)
.SetMethod("getSublabelAt", &Menu::GetSublabelAt)
.SetMethod("getAcceleratorTextAt", &Menu::GetAcceleratorTextAt)
.SetMethod("isItemCheckedAt", &Menu::IsItemCheckedAt)
.SetMethod("isEnabledAt", &Menu::IsEnabledAt)
.SetMethod("isVisibleAt", &Menu::IsVisibleAt)
@@ -218,7 +233,9 @@ void Initialize(v8::Local<v8::Object> exports,
Menu::SetConstructor(isolate, base::Bind(&Menu::New));
mate::Dictionary dict(isolate, exports);
dict.Set("Menu", Menu::GetConstructor(isolate)->GetFunction());
dict.Set(
"Menu",
Menu::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
#if defined(OS_MACOSX)
dict.SetMethod("setApplicationMenu", &Menu::SetApplicationMenu);
dict.SetMethod("sendActionToFirstResponder",
@@ -228,4 +245,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_menu, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_menu, Initialize)

View File

@@ -51,8 +51,9 @@ class Menu : public mate::TrackableObject<Menu>,
int command_id,
bool use_default_accelerator,
ui::Accelerator* accelerator) const override;
bool ShouldRegisterAcceleratorForCommandId(int command_id) const override;
void ExecuteCommand(int command_id, int event_flags) override;
void MenuWillShow(ui::SimpleMenuModel* source) override;
void OnMenuWillShow(ui::SimpleMenuModel* source) override;
virtual void PopupAt(TopLevelWindow* window,
int x,
@@ -91,6 +92,7 @@ class Menu : public mate::TrackableObject<Menu>,
int GetCommandIdAt(int index) const;
base::string16 GetLabelAt(int index) const;
base::string16 GetSublabelAt(int index) const;
base::string16 GetAcceleratorTextAt(int index) const;
bool IsItemCheckedAt(int index) const;
bool IsEnabledAt(int index) const;
bool IsVisibleAt(int index) const;
@@ -101,6 +103,7 @@ class Menu : public mate::TrackableObject<Menu>,
base::Callback<bool(v8::Local<v8::Value>, int)> is_visible_;
base::Callback<v8::Local<v8::Value>(v8::Local<v8::Value>, int, bool)>
get_accelerator_;
base::Callback<bool(v8::Local<v8::Value>, int)> should_register_accelerator_;
base::Callback<void(v8::Local<v8::Value>, v8::Local<v8::Value>, int)>
execute_command_;
base::Callback<void(v8::Local<v8::Value>)> menu_will_show_;

View File

@@ -9,6 +9,8 @@
#include "base/mac/scoped_sending_event.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/sys_string_conversions.h"
#include "base/task/post_task.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
@@ -43,7 +45,7 @@ void MenuMac::PopupAt(TopLevelWindow* window,
auto popup = base::Bind(&MenuMac::PopupOnUI, weak_factory_.GetWeakPtr(),
native_window->GetWeakPtr(), window->weak_map_id(), x,
y, positioning_item, callback);
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, popup);
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, popup);
}
void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
@@ -54,7 +56,7 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
base::Closure callback) {
if (!native_window)
return;
NSWindow* nswindow = native_window->GetNativeWindow();
NSWindow* nswindow = native_window->GetNativeWindow().GetNativeNSWindow();
auto close_callback = base::Bind(
&MenuMac::OnClosed, weak_factory_.GetWeakPtr(), window_id, callback);
@@ -97,7 +99,7 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
[popup_controllers_[window_id] setCloseCallback:close_callback];
// Make sure events can be pumped while the menu is up.
base::MessageLoop::ScopedNestableTaskAllower allow;
base::MessageLoopCurrent::ScopedNestableTaskAllower allow;
// One of the events that could be pumped is |window.close()|.
// User-initiated event-tracking loops protect against this by

View File

@@ -31,7 +31,9 @@ void Net::BuildPrototype(v8::Isolate* isolate,
}
v8::Local<v8::Value> Net::URLRequest(v8::Isolate* isolate) {
return URLRequest::GetConstructor(isolate)->GetFunction();
return URLRequest::GetConstructor(isolate)
->GetFunction(isolate->GetCurrentContext())
.ToLocalChecked();
}
} // namespace api
@@ -53,9 +55,10 @@ void Initialize(v8::Local<v8::Object> exports,
mate::Dictionary dict(isolate, exports);
dict.Set("net", Net::Create(isolate));
dict.Set("Net", Net::GetConstructor(isolate)->GetFunction());
dict.Set("Net",
Net::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
}
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_net, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_net, Initialize)

View File

@@ -7,10 +7,11 @@
#include <utility>
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/net/system_network_context_manager.h"
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "base/command_line.h"
#include "chrome/browser/browser_process.h"
#include "components/net_log/chrome_net_log.h"
#include "content/public/browser/storage_partition.h"
#include "native_mate/dictionary.h"
@@ -27,8 +28,8 @@ NetLog::NetLog(v8::Isolate* isolate, AtomBrowserContext* browser_context)
: browser_context_(browser_context) {
Init(isolate);
net_log_writer_ =
atom::AtomBrowserMainParts::Get()->net_log()->net_export_file_writer();
net_log_writer_ = g_browser_process->system_network_context_manager()
->GetNetExportFileWriter();
net_log_writer_->AddObserver(this);
}

View File

@@ -5,13 +5,13 @@
#include "atom/browser/api/atom_api_notification.h"
#include "atom/browser/api/atom_api_menu.h"
#include "atom/browser/atom_browser_client.h"
#include "atom/browser/browser.h"
#include "atom/common/native_mate_converters/gfx_converter.h"
#include "atom/common/native_mate_converters/image_converter.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "base/guid.h"
#include "base/strings/utf_string_conversions.h"
#include "brightray/browser/browser_client.h"
#include "native_mate/constructor.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
@@ -22,10 +22,10 @@
namespace mate {
template <>
struct Converter<brightray::NotificationAction> {
struct Converter<atom::NotificationAction> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
brightray::NotificationAction* out) {
atom::NotificationAction* out) {
mate::Dictionary dict;
if (!ConvertFromV8(isolate, val, &dict))
return false;
@@ -38,7 +38,7 @@ struct Converter<brightray::NotificationAction> {
}
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
brightray::NotificationAction val) {
atom::NotificationAction val) {
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
dict.Set("text", val.text);
dict.Set("type", val.type);
@@ -56,7 +56,8 @@ Notification::Notification(v8::Isolate* isolate,
mate::Arguments* args) {
InitWith(isolate, wrapper);
presenter_ = brightray::BrowserClient::Get()->GetNotificationPresenter();
presenter_ = static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())
->GetNotificationPresenter();
mate::Dictionary opts;
if (args->GetNext(&opts)) {
@@ -119,7 +120,7 @@ base::string16 Notification::GetSound() const {
return sound_;
}
std::vector<brightray::NotificationAction> Notification::GetActions() const {
std::vector<atom::NotificationAction> Notification::GetActions() const {
return actions_;
}
@@ -157,7 +158,7 @@ void Notification::SetSound(const base::string16& new_sound) {
}
void Notification::SetActions(
const std::vector<brightray::NotificationAction>& actions) {
const std::vector<atom::NotificationAction>& actions) {
actions_ = actions;
}
@@ -200,7 +201,7 @@ void Notification::Show() {
if (presenter_) {
notification_ = presenter_->CreateNotification(this, base::GenerateGUID());
if (notification_) {
brightray::NotificationOptions options;
atom::NotificationOptions options;
options.title = title_;
options.subtitle = subtitle_;
options.msg = body_;
@@ -218,7 +219,8 @@ void Notification::Show() {
}
bool Notification::IsSupported() {
return !!brightray::BrowserClient::Get()->GetNotificationPresenter();
return !!static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())
->GetNotificationPresenter();
}
// static
@@ -261,12 +263,13 @@ void Initialize(v8::Local<v8::Object> exports,
Notification::SetConstructor(isolate, base::Bind(&Notification::New));
mate::Dictionary dict(isolate, exports);
dict.Set("Notification",
Notification::GetConstructor(isolate)->GetFunction());
dict.Set("Notification", Notification::GetConstructor(isolate)
->GetFunction(context)
.ToLocalChecked());
dict.SetMethod("isSupported", &Notification::IsSupported);
}
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_notification, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_common_notification, Initialize)

View File

@@ -10,10 +10,10 @@
#include <vector>
#include "atom/browser/api/trackable_object.h"
#include "atom/browser/notifications/notification.h"
#include "atom/browser/notifications/notification_delegate.h"
#include "atom/browser/notifications/notification_presenter.h"
#include "base/strings/utf_string_conversions.h"
#include "brightray/browser/notification.h"
#include "brightray/browser/notification_delegate.h"
#include "brightray/browser/notification_presenter.h"
#include "native_mate/handle.h"
#include "ui/gfx/image/image.h"
@@ -22,7 +22,7 @@ namespace atom {
namespace api {
class Notification : public mate::TrackableObject<Notification>,
public brightray::NotificationDelegate {
public NotificationDelegate {
public:
static mate::WrappableBase* New(mate::Arguments* args);
static bool IsSupported();
@@ -55,7 +55,7 @@ class Notification : public mate::TrackableObject<Notification>,
bool GetHasReply() const;
base::string16 GetReplyPlaceholder() const;
base::string16 GetSound() const;
std::vector<brightray::NotificationAction> GetActions() const;
std::vector<atom::NotificationAction> GetActions() const;
base::string16 GetCloseButtonText() const;
// Prop Setters
@@ -66,7 +66,7 @@ class Notification : public mate::TrackableObject<Notification>,
void SetHasReply(bool new_has_reply);
void SetReplyPlaceholder(const base::string16& new_reply_placeholder);
void SetSound(const base::string16& sound);
void SetActions(const std::vector<brightray::NotificationAction>& actions);
void SetActions(const std::vector<atom::NotificationAction>& actions);
void SetCloseButtonText(const base::string16& text);
private:
@@ -80,12 +80,12 @@ class Notification : public mate::TrackableObject<Notification>,
bool has_reply_ = false;
base::string16 reply_placeholder_;
base::string16 sound_;
std::vector<brightray::NotificationAction> actions_;
std::vector<atom::NotificationAction> actions_;
base::string16 close_button_text_;
brightray::NotificationPresenter* presenter_;
atom::NotificationPresenter* presenter_;
base::WeakPtr<brightray::Notification> notification_;
base::WeakPtr<atom::Notification> notification_;
DISALLOW_COPY_AND_ASSIGN(Notification);
};

View File

@@ -84,19 +84,19 @@ void PowerMonitor::OnResume() {
Emit("resume");
}
void PowerMonitor::QuerySystemIdleState(v8::Isolate* isolate,
int idle_threshold,
const ui::IdleCallback& callback) {
ui::IdleState PowerMonitor::QuerySystemIdleState(v8::Isolate* isolate,
int idle_threshold) {
if (idle_threshold > 0) {
ui::CalculateIdleState(idle_threshold, callback);
return ui::CalculateIdleState(idle_threshold);
} else {
isolate->ThrowException(v8::Exception::TypeError(mate::StringToV8(
isolate, "Invalid idle threshold, must be greater than 0")));
return ui::IDLE_STATE_UNKNOWN;
}
}
void PowerMonitor::QuerySystemIdleTime(const ui::IdleTimeCallback& callback) {
ui::CalculateIdleTime(callback);
int PowerMonitor::QuerySystemIdleTime() {
return ui::CalculateIdleTime();
}
// static
@@ -122,8 +122,8 @@ void PowerMonitor::BuildPrototype(v8::Isolate* isolate,
.SetMethod("blockShutdown", &PowerMonitor::BlockShutdown)
.SetMethod("unblockShutdown", &PowerMonitor::UnblockShutdown)
#endif
.SetMethod("querySystemIdleState", &PowerMonitor::QuerySystemIdleState)
.SetMethod("querySystemIdleTime", &PowerMonitor::QuerySystemIdleTime);
.SetMethod("_querySystemIdleState", &PowerMonitor::QuerySystemIdleState)
.SetMethod("_querySystemIdleTime", &PowerMonitor::QuerySystemIdleTime);
}
} // namespace api
@@ -141,10 +141,11 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("powerMonitor", PowerMonitor::Create(isolate));
dict.Set("PowerMonitor",
PowerMonitor::GetConstructor(isolate)->GetFunction());
dict.Set("PowerMonitor", PowerMonitor::GetConstructor(isolate)
->GetFunction(context)
.ToLocalChecked());
}
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_power_monitor, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_power_monitor, Initialize)

View File

@@ -46,10 +46,8 @@ class PowerMonitor : public mate::TrackableObject<PowerMonitor>,
void OnResume() override;
private:
void QuerySystemIdleState(v8::Isolate* isolate,
int idle_threshold,
const ui::IdleCallback& callback);
void QuerySystemIdleTime(const ui::IdleTimeCallback& callback);
ui::IdleState QuerySystemIdleState(v8::Isolate* isolate, int idle_threshold);
int QuerySystemIdleTime();
#if defined(OS_WIN)
// Static callback invoked when a message comes in to our messaging window.

View File

@@ -6,9 +6,13 @@
#include <string>
#include "base/task_scheduler/post_task.h"
#include "base/task/post_task.h"
#include "base/threading/thread_task_runner_handle.h"
#include "content/public/common/service_manager_connection.h"
#include "native_mate/dictionary.h"
#include "services/device/public/mojom/constants.mojom.h"
#include "services/device/public/mojom/wake_lock_provider.mojom.h"
#include "services/service_manager/public/cpp/connector.h"
#include "atom/common/node_includes.h"
@@ -39,16 +43,19 @@ namespace atom {
namespace api {
PowerSaveBlocker::PowerSaveBlocker(v8::Isolate* isolate)
: current_blocker_type_(
device::mojom::WakeLockType::kPreventAppSuspension) {
: current_lock_type_(device::mojom::WakeLockType::kPreventAppSuspension),
is_wake_lock_active_(false) {
Init(isolate);
}
PowerSaveBlocker::~PowerSaveBlocker() {}
void PowerSaveBlocker::UpdatePowerSaveBlocker() {
if (power_save_blocker_types_.empty()) {
power_save_blocker_.reset();
if (wake_lock_types_.empty()) {
if (is_wake_lock_active_) {
GetWakeLock()->CancelWakeLock();
is_wake_lock_active_ = false;
}
return;
}
@@ -58,45 +65,57 @@ void PowerSaveBlocker::UpdatePowerSaveBlocker() {
// higher precedence level than |WakeLockType::kPreventAppSuspension|.
//
// Only the highest-precedence blocker type takes effect.
device::mojom::WakeLockType new_blocker_type =
device::mojom::WakeLockType new_lock_type =
device::mojom::WakeLockType::kPreventAppSuspension;
for (const auto& element : power_save_blocker_types_) {
for (const auto& element : wake_lock_types_) {
if (element.second == device::mojom::WakeLockType::kPreventDisplaySleep) {
new_blocker_type = device::mojom::WakeLockType::kPreventDisplaySleep;
new_lock_type = device::mojom::WakeLockType::kPreventDisplaySleep;
break;
}
}
if (!power_save_blocker_ || new_blocker_type != current_blocker_type_) {
auto new_blocker = std::make_unique<device::PowerSaveBlocker>(
new_blocker_type, device::mojom::WakeLockReason::kOther,
ATOM_PRODUCT_NAME, base::ThreadTaskRunnerHandle::Get(),
// This task runner may be used by some device service
// implementation bits to interface with dbus client code, which in
// turn imposes some subtle thread affinity on the clients. We
// therefore require a single-thread runner.
base::CreateSingleThreadTaskRunnerWithTraits(
{base::MayBlock(), base::TaskPriority::BACKGROUND}));
power_save_blocker_.swap(new_blocker);
current_blocker_type_ = new_blocker_type;
if (current_lock_type_ != new_lock_type) {
GetWakeLock()->ChangeType(new_lock_type, base::DoNothing());
current_lock_type_ = new_lock_type;
}
if (!is_wake_lock_active_) {
GetWakeLock()->RequestWakeLock();
is_wake_lock_active_ = true;
}
}
device::mojom::WakeLock* PowerSaveBlocker::GetWakeLock() {
if (!wake_lock_) {
device::mojom::WakeLockProviderPtr wake_lock_provider;
DCHECK(content::ServiceManagerConnection::GetForProcess());
auto* connector =
content::ServiceManagerConnection::GetForProcess()->GetConnector();
connector->BindInterface(device::mojom::kServiceName,
mojo::MakeRequest(&wake_lock_provider));
wake_lock_provider->GetWakeLockWithoutContext(
device::mojom::WakeLockType::kPreventAppSuspension,
device::mojom::WakeLockReason::kOther, ATOM_PRODUCT_NAME,
mojo::MakeRequest(&wake_lock_));
}
return wake_lock_.get();
}
int PowerSaveBlocker::Start(device::mojom::WakeLockType type) {
static int count = 0;
power_save_blocker_types_[count] = type;
wake_lock_types_[count] = type;
UpdatePowerSaveBlocker();
return count++;
}
bool PowerSaveBlocker::Stop(int id) {
bool success = power_save_blocker_types_.erase(id) > 0;
bool success = wake_lock_types_.erase(id) > 0;
UpdatePowerSaveBlocker();
return success;
}
bool PowerSaveBlocker::IsStarted(int id) {
return power_save_blocker_types_.find(id) != power_save_blocker_types_.end();
return wake_lock_types_.find(id) != wake_lock_types_.end();
}
// static
@@ -132,4 +151,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_power_save_blocker, Initialize);
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_power_save_blocker, Initialize);

View File

@@ -10,7 +10,7 @@
#include "atom/browser/api/trackable_object.h"
#include "native_mate/handle.h"
#include "services/device/wake_lock/power_save_blocker/power_save_blocker.h"
#include "services/device/public/mojom/wake_lock.mojom.h"
namespace mate {
class Dictionary;
@@ -37,14 +37,19 @@ class PowerSaveBlocker : public mate::TrackableObject<PowerSaveBlocker> {
bool Stop(int id);
bool IsStarted(int id);
std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_;
device::mojom::WakeLock* GetWakeLock();
// Current blocker type used by |power_save_blocker_|
device::mojom::WakeLockType current_blocker_type_;
// Current wake lock level.
device::mojom::WakeLockType current_lock_type_;
// Whether the wake lock is currently active.
bool is_wake_lock_active_;
// Map from id to the corresponding blocker type for each request.
using WakeLockTypeMap = std::map<int, device::mojom::WakeLockType>;
WakeLockTypeMap power_save_blocker_types_;
WakeLockTypeMap wake_lock_types_;
device::mojom::WakeLockPtr wake_lock_;
DISALLOW_COPY_AND_ASSIGN(PowerSaveBlocker);
};

View File

@@ -24,47 +24,119 @@
using content::BrowserThread;
namespace atom {
namespace api {
namespace {
// List of registered custom 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 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() {
return g_standard_schemes;
}
void RegisterStandardSchemes(const std::vector<std::string>& schemes,
mate::Arguments* args) {
g_standard_schemes = schemes;
void RegisterSchemesAsPrivileged(v8::Local<v8::Value> val,
mate::Arguments* args) {
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;
bool secure = false;
args->GetNext(&opts) && opts.Get("secure", &secure);
// Dynamically register the schemes.
auto* policy = content::ChildProcessSecurityPolicy::GetInstance();
for (const std::string& scheme : schemes) {
url::AddStandardScheme(scheme.c_str(), url::SCHEME_WITH_HOST);
if (secure) {
url::AddSecureScheme(scheme.c_str());
std::vector<std::string> secure_schemes, cspbypassing_schemes, fetch_schemes,
service_worker_schemes, cors_schemes;
for (const auto& custom_scheme : custom_schemes) {
// Register scheme to privileged list (https, wss, data, chrome-extension)
if (custom_scheme.options.standard) {
auto* policy = content::ChildProcessSecurityPolicy::GetInstance();
url::AddStandardScheme(custom_scheme.scheme.c_str(),
url::SCHEME_WITH_HOST);
g_standard_schemes.push_back(custom_scheme.scheme);
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
// register them.
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
atom::switches::kStandardSchemes, base::JoinString(schemes, ","));
if (secure) {
const auto AppendSchemesToCmdLine = [](const char* switch_name,
std::vector<std::string> schemes) {
// Add the schemes to command line switches, so child processes can also
// register them.
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)
@@ -73,20 +145,14 @@ Protocol::Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context)
}
Protocol::~Protocol() {}
void Protocol::RegisterServiceWorkerSchemes(
const std::vector<std::string>& schemes) {
atom::AtomBrowserClient::SetCustomServiceWorkerSchemes(schemes);
}
void Protocol::UnregisterProtocol(const std::string& scheme,
mate::Arguments* args) {
CompletionCallback callback;
args->GetNext(&callback);
auto* getter = static_cast<URLRequestContextGetter*>(
browser_context_->GetRequestContext());
content::BrowserThread::PostTaskAndReplyWithResult(
content::BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&Protocol::UnregisterProtocolInIO,
base::RetainedRef(getter), scheme),
base::BindOnce(&Protocol::OnIOCompleted, GetWeakPtr(), callback));
@@ -103,22 +169,30 @@ Protocol::ProtocolError Protocol::UnregisterProtocolInIO(
return PROTOCOL_OK;
}
void Protocol::IsProtocolHandled(const std::string& scheme,
const BooleanCallback& callback) {
auto* getter = static_cast<URLRequestContextGetter*>(
browser_context_->GetRequestContext());
content::BrowserThread::PostTaskAndReplyWithResult(
content::BrowserThread::IO, FROM_HERE,
base::Bind(&Protocol::IsProtocolHandledInIO, base::RetainedRef(getter),
scheme),
callback);
}
// static
bool Protocol::IsProtocolHandledInIO(
bool IsProtocolHandledInIO(
scoped_refptr<URLRequestContextGetter> request_context_getter,
const std::string& scheme) {
return request_context_getter->job_factory()->IsHandledProtocol(scheme);
bool is_handled =
request_context_getter->job_factory()->IsHandledProtocol(scheme);
return is_handled;
}
void PromiseCallback(util::Promise promise, bool handled) {
promise.Resolve(handled);
}
v8::Local<v8::Promise> Protocol::IsProtocolHandled(const std::string& scheme) {
util::Promise promise(isolate());
v8::Local<v8::Promise> handle = promise.GetHandle();
auto* getter = static_cast<URLRequestContextGetter*>(
browser_context_->GetRequestContext());
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&IsProtocolHandledInIO, base::RetainedRef(getter), scheme),
base::BindOnce(&PromiseCallback, std::move(promise)));
return handle;
}
void Protocol::UninterceptProtocol(const std::string& scheme,
@@ -127,8 +201,8 @@ void Protocol::UninterceptProtocol(const std::string& scheme,
args->GetNext(&callback);
auto* getter = static_cast<URLRequestContextGetter*>(
browser_context_->GetRequestContext());
content::BrowserThread::PostTaskAndReplyWithResult(
content::BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&Protocol::UninterceptProtocolInIO,
base::RetainedRef(getter), scheme),
base::BindOnce(&Protocol::OnIOCompleted, GetWeakPtr(), callback));
@@ -188,8 +262,6 @@ void Protocol::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "Protocol"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.SetMethod("registerServiceWorkerSchemes",
&Protocol::RegisterServiceWorkerSchemes)
.SetMethod("registerStringProtocol",
&Protocol::RegisterProtocol<URLRequestStringJob>)
.SetMethod("registerBufferProtocol",
@@ -221,16 +293,16 @@ void Protocol::BuildPrototype(v8::Isolate* isolate,
namespace {
void RegisterStandardSchemes(const std::vector<std::string>& schemes,
mate::Arguments* args) {
void RegisterSchemesAsPrivileged(v8::Local<v8::Value> val,
mate::Arguments* args) {
if (atom::Browser::Get()->is_ready()) {
args->ThrowError(
"protocol.registerStandardSchemes should be called before "
"protocol.registerSchemesAsPrivileged should be called before "
"app is ready");
return;
}
atom::api::RegisterStandardSchemes(schemes, args);
atom::api::RegisterSchemesAsPrivileged(val, args);
}
void Initialize(v8::Local<v8::Object> exports,
@@ -239,10 +311,10 @@ void Initialize(v8::Local<v8::Object> exports,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.SetMethod("registerStandardSchemes", &RegisterStandardSchemes);
dict.SetMethod("registerSchemesAsPrivileged", &RegisterSchemesAsPrivileged);
dict.SetMethod("getStandardSchemes", &atom::api::GetStandardSchemes);
}
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_protocol, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_protocol, Initialize)

View File

@@ -14,8 +14,11 @@
#include "atom/browser/api/trackable_object.h"
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/net/atom_url_request_job_factory.h"
#include "atom/common/promise_util.h"
#include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "base/task/post_task.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "native_mate/arguments.h"
#include "native_mate/dictionary.h"
@@ -31,15 +34,15 @@ namespace atom {
namespace api {
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> {
public:
using Handler =
base::Callback<void(const base::DictionaryValue&, v8::Local<v8::Value>)>;
using CompletionCallback = base::Callback<void(v8::Local<v8::Value>)>;
using BooleanCallback = base::Callback<void(bool)>;
static mate::Handle<Protocol> Create(v8::Isolate* isolate,
AtomBrowserContext* browser_context);
@@ -92,9 +95,6 @@ class Protocol : public mate::TrackableObject<Protocol> {
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.
template <typename RequestJob>
void RegisterProtocol(const std::string& scheme,
@@ -104,8 +104,8 @@ class Protocol : public mate::TrackableObject<Protocol> {
args->GetNext(&callback);
auto* getter = static_cast<URLRequestContextGetter*>(
browser_context_->GetRequestContext());
content::BrowserThread::PostTaskAndReplyWithResult(
content::BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&Protocol::RegisterProtocolInIO<RequestJob>,
base::RetainedRef(getter), isolate(), scheme, handler),
base::BindOnce(&Protocol::OnIOCompleted, GetWeakPtr(), callback));
@@ -134,11 +134,7 @@ class Protocol : public mate::TrackableObject<Protocol> {
const std::string& scheme);
// Whether the protocol has handler registered.
void IsProtocolHandled(const std::string& scheme,
const BooleanCallback& callback);
static bool IsProtocolHandledInIO(
scoped_refptr<URLRequestContextGetter> request_context_getter,
const std::string& scheme);
v8::Local<v8::Promise> IsProtocolHandled(const std::string& scheme);
// Replace the protocol handler with a new one.
template <typename RequestJob>
@@ -149,8 +145,8 @@ class Protocol : public mate::TrackableObject<Protocol> {
args->GetNext(&callback);
auto* getter = static_cast<URLRequestContextGetter*>(
browser_context_->GetRequestContext());
content::BrowserThread::PostTaskAndReplyWithResult(
content::BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&Protocol::InterceptProtocolInIO<RequestJob>,
base::RetainedRef(getter), isolate(), scheme, handler),
base::BindOnce(&Protocol::OnIOCompleted, GetWeakPtr(), callback));

View File

@@ -26,7 +26,7 @@ bool IsWebContents(v8::Isolate* isolate, content::RenderProcessHost* process) {
if (!web_contents)
return false;
auto api_web_contents = WebContents::CreateFrom(isolate, web_contents);
auto api_web_contents = WebContents::FromOrCreate(isolate, web_contents);
auto type = api_web_contents->GetType();
return type == WebContents::Type::BROWSER_WINDOW ||
type == WebContents::Type::WEB_VIEW;
@@ -87,5 +87,5 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_render_process_preferences,
Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_render_process_preferences,
Initialize)

View File

@@ -52,6 +52,19 @@ std::vector<std::string> MetricsToArray(uint32_t metrics) {
return array;
}
void DelayEmit(Screen* screen,
const base::StringPiece& name,
const display::Display& display) {
screen->Emit(name, display);
}
void DelayEmitWithMetrics(Screen* screen,
const base::StringPiece& name,
const display::Display& display,
const std::vector<std::string>& metrics) {
screen->Emit(name, display, metrics);
}
} // namespace
Screen::Screen(v8::Isolate* isolate, display::Screen* screen)
@@ -101,16 +114,23 @@ static gfx::Rect DIPToScreenRect(atom::NativeWindow* window,
#endif
void Screen::OnDisplayAdded(const display::Display& new_display) {
Emit("display-added", new_display);
base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask(
FROM_HERE, base::Bind(&DelayEmit, base::Unretained(this), "display-added",
new_display));
}
void Screen::OnDisplayRemoved(const display::Display& old_display) {
Emit("display-removed", old_display);
base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask(
FROM_HERE, base::Bind(&DelayEmit, base::Unretained(this),
"display-removed", old_display));
}
void Screen::OnDisplayMetricsChanged(const display::Display& display,
uint32_t changed_metrics) {
Emit("display-metrics-changed", display, MetricsToArray(changed_metrics));
base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask(
FROM_HERE, base::Bind(&DelayEmitWithMetrics, base::Unretained(this),
"display-metrics-changed", display,
MetricsToArray(changed_metrics)));
}
// static
@@ -164,9 +184,11 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("screen", Screen::Create(isolate));
dict.Set("Screen", Screen::GetConstructor(isolate)->GetFunction());
dict.Set(
"Screen",
Screen::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
}
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_screen, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_common_screen, Initialize)

View File

@@ -19,6 +19,7 @@
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/atom_permission_manager.h"
#include "atom/browser/browser.h"
#include "atom/browser/media/media_device_id_salt.h"
#include "atom/browser/net/atom_cert_verifier.h"
#include "atom/browser/session_preferences.h"
#include "atom/common/native_mate_converters/callback.h"
@@ -31,7 +32,7 @@
#include "base/guid.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "brightray/browser/media/media_device_id_salt.h"
#include "base/task/post_task.h"
#include "chrome/browser/browser_process.h"
#include "chrome/common/pref_names.h"
#include "components/download/public/common/download_danger_type.h"
@@ -39,6 +40,7 @@
#include "components/prefs/value_map_pref_store.h"
#include "components/proxy_config/proxy_config_dictionary.h"
#include "components/proxy_config/proxy_config_pref_names.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_item_utils.h"
#include "content/public/browser/download_manager_delegate.h"
@@ -59,7 +61,6 @@
#include "atom/common/node_includes.h"
using atom::api::Cookies;
using content::BrowserThread;
using content::StoragePartition;
@@ -211,12 +212,12 @@ std::map<uint32_t, v8::Global<v8::Object>> g_sessions;
// Runs the callback in UI thread.
void RunCallbackInUI(const base::Callback<void()>& callback) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback);
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, callback);
}
template <typename... T>
void RunCallbackInUI(const base::Callback<void(T...)>& callback, T... result) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(callback, result...));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, result...));
}
// Callback of HttpCache::GetBackend.
@@ -359,7 +360,7 @@ void DestroyGlobalHandle(v8::Isolate* isolate,
if (!global_handle.IsEmpty()) {
v8::Local<v8::Value> local_handle = global_handle.Get(isolate);
if (local_handle->IsObject()) {
v8::Local<v8::Object> object = local_handle->ToObject();
v8::Local<v8::Object> object = local_handle->ToObject(isolate);
void* ptr = object->GetAlignedPointerFromInternalField(0);
if (!ptr)
return;
@@ -419,10 +420,21 @@ void Session::ResolveProxy(
browser_context_->GetResolveProxyHelper()->ResolveProxy(url, callback);
}
void Session::GetCacheSize(const net::CompletionCallback& callback) {
content::BrowserContext::GetDefaultStoragePartition(browser_context_.get())
->GetNetworkContext()
->ComputeHttpCacheSize(
base::Time(), base::Time::Max(),
base::BindOnce(
[](const net::CompletionCallback& cb, bool is_upper_bound,
int64_t size_or_error) { cb.Run(size_or_error); },
callback));
}
template <Session::CacheAction action>
void Session::DoCacheAction(const net::CompletionCallback& callback) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&DoCacheActionInIO,
WrapRefCounted(browser_context_->GetRequestContext()),
action, callback));
@@ -440,12 +452,11 @@ void Session::ClearStorageData(mate::Arguments* args) {
if (options.storage_types & StoragePartition::REMOVE_DATA_MASK_COOKIES) {
// Reset media device id salt when cookies are cleared.
// https://w3c.github.io/mediacapture-main/#dom-mediadeviceinfo-deviceid
brightray::MediaDeviceIDSalt::Reset(browser_context()->prefs());
MediaDeviceIDSalt::Reset(browser_context()->prefs());
}
storage_partition->ClearData(
options.storage_types, options.quota_types, options.origin,
content::StoragePartition::OriginMatcherFunction(), base::Time(),
base::Time::Max(), base::Bind(&OnClearStorageDataDone, callback));
storage_partition->ClearData(options.storage_types, options.quota_types,
options.origin, base::Time(), base::Time::Max(),
base::Bind(&OnClearStorageDataDone, callback));
}
void Session::FlushStorageData() {
@@ -471,13 +482,14 @@ void Session::SetProxy(const mate::Dictionary& options,
if (!pac_url.empty()) {
browser_context_->in_memory_pref_store()->SetValue(
proxy_config::prefs::kProxy,
ProxyConfigDictionary::CreatePacScript(pac_url,
true /* pac_mandatory */),
std::make_unique<base::Value>(ProxyConfigDictionary::CreatePacScript(
pac_url, true /* pac_mandatory */)),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
} else {
browser_context_->in_memory_pref_store()->SetValue(
proxy_config::prefs::kProxy,
ProxyConfigDictionary::CreateFixedServers(proxy_rules, bypass_list),
std::make_unique<base::Value>(ProxyConfigDictionary::CreateFixedServers(
proxy_rules, bypass_list)),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
}
@@ -532,8 +544,8 @@ void Session::SetCertVerifyProc(v8::Local<v8::Value> val,
return;
}
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&SetCertVerifyProcInIO,
WrapRefCounted(browser_context_->GetRequestContext()),
base::Bind(&WrapVerifyProc, proc)));
@@ -567,8 +579,8 @@ void Session::ClearHostResolverCache(mate::Arguments* args) {
base::Closure callback;
args->GetNext(&callback);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&ClearHostResolverCacheInIO,
WrapRefCounted(browser_context_->GetRequestContext()),
callback));
@@ -583,16 +595,16 @@ void Session::ClearAuthCache(mate::Arguments* args) {
base::Closure callback;
args->GetNext(&callback);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&ClearAuthCacheInIO,
WrapRefCounted(browser_context_->GetRequestContext()),
options, callback));
}
void Session::AllowNTLMCredentialsForDomains(const std::string& domains) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&AllowNTLMCredentialsForDomainsInIO,
WrapRefCounted(browser_context_->GetRequestContext()),
domains));
@@ -622,8 +634,8 @@ void Session::GetBlobData(const std::string& uuid,
return;
AtomBlobReader* blob_reader = browser_context()->GetBlobReader();
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&AtomBlobReader::StartReading,
base::Unretained(blob_reader), uuid, callback));
}
@@ -747,7 +759,7 @@ void Session::BuildPrototype(v8::Isolate* isolate,
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.MakeDestroyable()
.SetMethod("resolveProxy", &Session::ResolveProxy)
.SetMethod("getCacheSize", &Session::DoCacheAction<CacheAction::STATS>)
.SetMethod("getCacheSize", &Session::GetCacheSize)
.SetMethod("clearCache", &Session::DoCacheAction<CacheAction::CLEAR>)
.SetMethod("clearStorageData", &Session::ClearStorageData)
.SetMethod("flushStorageData", &Session::FlushStorageData)
@@ -783,6 +795,8 @@ void Session::BuildPrototype(v8::Isolate* isolate,
namespace {
using atom::api::Cookies;
using atom::api::Protocol;
using atom::api::Session;
v8::Local<v8::Value> FromPartition(const std::string& partition,
@@ -802,11 +816,18 @@ void Initialize(v8::Local<v8::Object> exports,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("Session", Session::GetConstructor(isolate)->GetFunction());
dict.Set("Cookies", Cookies::GetConstructor(isolate)->GetFunction());
dict.Set(
"Session",
Session::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
dict.Set(
"Cookies",
Cookies::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
dict.Set(
"Protocol",
Protocol::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
dict.SetMethod("fromPartition", &FromPartition);
}
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_session, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_session, Initialize)

View File

@@ -66,6 +66,7 @@ class Session : public mate::TrackableObject<Session>,
const ResolveProxyHelper::ResolveProxyCallback& callback);
template <CacheAction action>
void DoCacheAction(const net::CompletionCallback& callback);
void GetCacheSize(const net::CompletionCallback& callback);
void ClearStorageData(mate::Arguments* args);
void FlushStorageData();
void SetProxy(const mate::Dictionary& options, const base::Closure& callback);

View File

@@ -37,6 +37,12 @@ bool SystemPreferences::IsInvertedColorScheme() {
return color_utils::IsInvertedColorScheme();
}
#if !defined(OS_WIN)
bool SystemPreferences::IsHighContrastColorScheme() {
return false;
}
#endif // !defined(OS_WIN)
// static
mate::Handle<SystemPreferences> SystemPreferences::Create(
v8::Isolate* isolate) {
@@ -49,10 +55,13 @@ void SystemPreferences::BuildPrototype(
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "SystemPreferences"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
#if defined(OS_WIN)
.SetMethod("getAccentColor", &SystemPreferences::GetAccentColor)
.SetMethod("isAeroGlassEnabled", &SystemPreferences::IsAeroGlassEnabled)
#if defined(OS_WIN) || defined(OS_MACOSX)
.SetMethod("getColor", &SystemPreferences::GetColor)
.SetMethod("getAccentColor", &SystemPreferences::GetAccentColor)
#endif
#if defined(OS_WIN)
.SetMethod("isAeroGlassEnabled", &SystemPreferences::IsAeroGlassEnabled)
#elif defined(OS_MACOSX)
.SetMethod("postNotification", &SystemPreferences::PostNotification)
.SetMethod("subscribeNotification",
@@ -83,9 +92,17 @@ void SystemPreferences::BuildPrototype(
&SystemPreferences::GetAppLevelAppearance)
.SetMethod("setAppLevelAppearance",
&SystemPreferences::SetAppLevelAppearance)
.SetMethod("getSystemColor", &SystemPreferences::GetSystemColor)
.SetMethod("isTrustedAccessibilityClient",
&SystemPreferences::IsTrustedAccessibilityClient)
.SetMethod("getMediaAccessStatus",
&SystemPreferences::GetMediaAccessStatus)
.SetMethod("askForMediaAccess", &SystemPreferences::AskForMediaAccess)
#endif
.SetMethod("isInvertedColorScheme",
&SystemPreferences::IsInvertedColorScheme)
.SetMethod("isHighContrastColorScheme",
&SystemPreferences::IsHighContrastColorScheme)
.SetMethod("isDarkMode", &SystemPreferences::IsDarkMode);
}
@@ -104,10 +121,11 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("systemPreferences", SystemPreferences::Create(isolate));
dict.Set("SystemPreferences",
SystemPreferences::GetConstructor(isolate)->GetFunction());
dict.Set("SystemPreferences", SystemPreferences::GetConstructor(isolate)
->GetFunction(context)
.ToLocalChecked());
}
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_system_preferences, Initialize);
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_system_preferences, Initialize);

View File

@@ -9,6 +9,7 @@
#include <string>
#include "atom/browser/api/event_emitter.h"
#include "atom/common/promise_util.h"
#include "base/callback.h"
#include "base/values.h"
#include "native_mate/handle.h"
@@ -48,11 +49,12 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
#if defined(OS_WIN)
bool IsAeroGlassEnabled();
#if defined(OS_WIN) || defined(OS_MACOSX)
std::string GetAccentColor();
std::string GetColor(const std::string& color, mate::Arguments* args);
#endif
#if defined(OS_WIN)
bool IsAeroGlassEnabled();
void InitializeWindow();
@@ -67,7 +69,8 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
base::Callback<void(const std::string&, const base::DictionaryValue&)>;
void PostNotification(const std::string& name,
const base::DictionaryValue& user_info);
const base::DictionaryValue& user_info,
mate::Arguments* args);
int SubscribeNotification(const std::string& name,
const NotificationCallback& callback);
void UnsubscribeNotification(int id);
@@ -90,6 +93,17 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
void RemoveUserDefault(const std::string& name);
bool IsSwipeTrackingFromScrollEventsEnabled();
std::string GetSystemColor(const std::string& color, mate::Arguments* args);
static bool IsTrustedAccessibilityClient(bool prompt);
// TODO(codebytere): Write tests for these methods once we
// are running tests on a Mojave machine
std::string GetMediaAccessStatus(const std::string& media_type,
mate::Arguments* args);
v8::Local<v8::Promise> AskForMediaAccess(v8::Isolate* isolate,
const std::string& media_type);
// TODO(MarshallOfSound): Write tests for these methods once we
// are running tests on a Mojave machine
v8::Local<v8::Value> GetEffectiveAppearance(v8::Isolate* isolate);
@@ -98,15 +112,13 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
#endif
bool IsDarkMode();
bool IsInvertedColorScheme();
bool IsHighContrastColorScheme();
protected:
explicit SystemPreferences(v8::Isolate* isolate);
~SystemPreferences() override;
#if defined(OS_MACOSX)
void DoPostNotification(const std::string& name,
const base::DictionaryValue& user_info,
NotificationCenterKind kind);
int DoSubscribeNotification(const std::string& name,
const NotificationCallback& callback,
NotificationCenterKind kind);
@@ -139,6 +151,8 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
bool invertered_color_scheme_;
bool high_contrast_color_scheme_;
std::unique_ptr<gfx::ScopedSysColorChangeListener> color_change_listener_;
#endif
DISALLOW_COPY_AND_ASSIGN(SystemPreferences);

View File

@@ -6,16 +6,21 @@
#include <map>
#import <AVFoundation/AVFoundation.h>
#import <Cocoa/Cocoa.h>
#include "atom/browser/mac/atom_application.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/value_converter.h"
#include "base/mac/sdk_forward_declarations.h"
#include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h"
#include "base/values.h"
#include "native_mate/object_template_builder.h"
#include "net/base/mac/url_conversions.h"
#include "ui/native_theme/native_theme.h"
namespace mate {
template <>
@@ -53,11 +58,11 @@ struct Converter<NSAppearance*> {
return v8::Null(isolate);
}
if (val.name == NSAppearanceNameAqua) {
if ([val.name isEqualToString:NSAppearanceNameAqua]) {
return mate::ConvertToV8(isolate, "light");
}
if (@available(macOS 10.14, *)) {
if (val.name == NSAppearanceNameDarkAqua) {
if ([val.name isEqualToString:NSAppearanceNameDarkAqua]) {
return mate::ConvertToV8(isolate, "dark");
}
}
@@ -78,12 +83,45 @@ int g_next_id = 0;
// The map to convert |id| to |int|.
std::map<int, id> g_id_map;
AVMediaType ParseMediaType(const std::string& media_type) {
if (media_type == "camera") {
return AVMediaTypeVideo;
} else if (media_type == "microphone") {
return AVMediaTypeAudio;
} else {
return nil;
}
}
std::string ConvertAuthorizationStatus(AVAuthorizationStatusMac status) {
switch (status) {
case AVAuthorizationStatusNotDeterminedMac:
return "not-determined";
case AVAuthorizationStatusRestrictedMac:
return "restricted";
case AVAuthorizationStatusDeniedMac:
return "denied";
case AVAuthorizationStatusAuthorizedMac:
return "granted";
default:
return "unknown";
}
}
} // namespace
void SystemPreferences::PostNotification(
const std::string& name,
const base::DictionaryValue& user_info) {
DoPostNotification(name, user_info, kNSDistributedNotificationCenter);
void SystemPreferences::PostNotification(const std::string& name,
const base::DictionaryValue& user_info,
mate::Arguments* args) {
bool immediate = false;
args->GetNext(&immediate);
NSDistributedNotificationCenter* center =
[NSDistributedNotificationCenter defaultCenter];
[center postNotificationName:base::SysUTF8ToNSString(name)
object:nil
userInfo:DictionaryValueToNSDictionary(user_info)
deliverImmediately:immediate];
}
int SystemPreferences::SubscribeNotification(
@@ -100,7 +138,10 @@ void SystemPreferences::UnsubscribeNotification(int request_id) {
void SystemPreferences::PostLocalNotification(
const std::string& name,
const base::DictionaryValue& user_info) {
DoPostNotification(name, user_info, kNSNotificationCenter);
NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
[center postNotificationName:base::SysUTF8ToNSString(name)
object:nil
userInfo:DictionaryValueToNSDictionary(user_info)];
}
int SystemPreferences::SubscribeLocalNotification(
@@ -116,7 +157,11 @@ void SystemPreferences::UnsubscribeLocalNotification(int request_id) {
void SystemPreferences::PostWorkspaceNotification(
const std::string& name,
const base::DictionaryValue& user_info) {
DoPostNotification(name, user_info, kNSWorkspaceNotificationCenter);
NSNotificationCenter* center =
[[NSWorkspace sharedWorkspace] notificationCenter];
[center postNotificationName:base::SysUTF8ToNSString(name)
object:nil
userInfo:DictionaryValueToNSDictionary(user_info)];
}
int SystemPreferences::SubscribeWorkspaceNotification(
@@ -130,29 +175,6 @@ void SystemPreferences::UnsubscribeWorkspaceNotification(int request_id) {
DoUnsubscribeNotification(request_id, kNSWorkspaceNotificationCenter);
}
void SystemPreferences::DoPostNotification(
const std::string& name,
const base::DictionaryValue& user_info,
NotificationCenterKind kind) {
NSNotificationCenter* center;
switch (kind) {
case kNSDistributedNotificationCenter:
center = [NSDistributedNotificationCenter defaultCenter];
break;
case kNSNotificationCenter:
center = [NSNotificationCenter defaultCenter];
break;
case kNSWorkspaceNotificationCenter:
center = [[NSWorkspace sharedWorkspace] notificationCenter];
break;
default:
break;
}
[center postNotificationName:base::SysUTF8ToNSString(name)
object:nil
userInfo:DictionaryValueToNSDictionary(user_info)];
}
int SystemPreferences::DoSubscribeNotification(
const std::string& name,
const NotificationCallback& callback,
@@ -360,12 +382,185 @@ void SystemPreferences::SetUserDefault(const std::string& name,
}
}
std::string SystemPreferences::GetAccentColor() {
NSColor* sysColor = nil;
if (@available(macOS 10.14, *))
sysColor = [NSColor controlAccentColor];
return base::SysNSStringToUTF8([sysColor RGBAValue]);
}
std::string SystemPreferences::GetSystemColor(const std::string& color,
mate::Arguments* args) {
NSColor* sysColor = nil;
if (color == "blue") {
sysColor = [NSColor systemBlueColor];
} else if (color == "brown") {
sysColor = [NSColor systemBrownColor];
} else if (color == "gray") {
sysColor = [NSColor systemGrayColor];
} else if (color == "green") {
sysColor = [NSColor systemGreenColor];
} else if (color == "orange") {
sysColor = [NSColor systemOrangeColor];
} else if (color == "pink") {
sysColor = [NSColor systemPinkColor];
} else if (color == "purple") {
sysColor = [NSColor systemPurpleColor];
} else if (color == "red") {
sysColor = [NSColor systemRedColor];
} else if (color == "yellow") {
sysColor = [NSColor systemYellowColor];
} else {
args->ThrowError("Unknown system color: " + color);
return "";
}
return base::SysNSStringToUTF8([sysColor hexadecimalValue]);
}
// static
bool SystemPreferences::IsTrustedAccessibilityClient(bool prompt) {
NSDictionary* options = @{(id)kAXTrustedCheckOptionPrompt : @(prompt)};
return AXIsProcessTrustedWithOptions((CFDictionaryRef)options);
}
std::string SystemPreferences::GetColor(const std::string& color,
mate::Arguments* args) {
NSColor* sysColor = nil;
if (color == "alternate-selected-control-text") {
sysColor = [NSColor alternateSelectedControlTextColor];
} else if (color == "control-background") {
sysColor = [NSColor controlBackgroundColor];
} else if (color == "control") {
sysColor = [NSColor controlColor];
} else if (color == "control-text") {
sysColor = [NSColor controlTextColor];
} else if (color == "disabled-control") {
sysColor = [NSColor disabledControlTextColor];
} else if (color == "find-highlight") {
if (@available(macOS 10.14, *))
sysColor = [NSColor findHighlightColor];
} else if (color == "grid") {
sysColor = [NSColor gridColor];
} else if (color == "header-text") {
sysColor = [NSColor headerTextColor];
} else if (color == "highlight") {
sysColor = [NSColor highlightColor];
} else if (color == "keyboard-focus-indicator") {
sysColor = [NSColor keyboardFocusIndicatorColor];
} else if (color == "label") {
sysColor = [NSColor labelColor];
} else if (color == "link") {
sysColor = [NSColor linkColor];
} else if (color == "placeholder-text") {
sysColor = [NSColor placeholderTextColor];
} else if (color == "quaternary-label") {
sysColor = [NSColor quaternaryLabelColor];
} else if (color == "scrubber-textured-background") {
if (@available(macOS 10.12.2, *))
sysColor = [NSColor scrubberTexturedBackgroundColor];
} else if (color == "secondary-label") {
sysColor = [NSColor secondaryLabelColor];
} else if (color == "selected-content-background") {
if (@available(macOS 10.14, *))
sysColor = [NSColor selectedContentBackgroundColor];
} else if (color == "selected-control") {
sysColor = [NSColor selectedControlColor];
} else if (color == "selected-control-text") {
sysColor = [NSColor selectedControlTextColor];
} else if (color == "selected-menu-item-text") {
sysColor = [NSColor selectedMenuItemTextColor];
} else if (color == "selected-text-background") {
sysColor = [NSColor selectedTextBackgroundColor];
} else if (color == "selected-text") {
sysColor = [NSColor selectedTextColor];
} else if (color == "separator") {
if (@available(macOS 10.14, *))
sysColor = [NSColor separatorColor];
} else if (color == "shadow") {
sysColor = [NSColor shadowColor];
} else if (color == "tertiary-label") {
sysColor = [NSColor tertiaryLabelColor];
} else if (color == "text-background") {
sysColor = [NSColor textBackgroundColor];
} else if (color == "text") {
sysColor = [NSColor textColor];
} else if (color == "under-page-background") {
sysColor = [NSColor underPageBackgroundColor];
} else if (color == "unemphasized-selected-content-background") {
if (@available(macOS 10.14, *))
sysColor = [NSColor unemphasizedSelectedContentBackgroundColor];
} else if (color == "unemphasized-selected-text-background") {
if (@available(macOS 10.14, *))
sysColor = [NSColor unemphasizedSelectedTextBackgroundColor];
} else if (color == "unemphasized-selected-text") {
if (@available(macOS 10.14, *))
sysColor = [NSColor unemphasizedSelectedTextColor];
} else if (color == "window-background") {
sysColor = [NSColor windowBackgroundColor];
} else if (color == "window-frame-text") {
sysColor = [NSColor windowFrameTextColor];
} else {
args->ThrowError("Unknown color: " + color);
return "";
}
return base::SysNSStringToUTF8([sysColor hexadecimalValue]);
}
std::string SystemPreferences::GetMediaAccessStatus(
const std::string& media_type,
mate::Arguments* args) {
if (auto type = ParseMediaType(media_type)) {
if (@available(macOS 10.14, *)) {
return ConvertAuthorizationStatus(
[AVCaptureDevice authorizationStatusForMediaType:type]);
} else {
// access always allowed pre-10.14 Mojave
return ConvertAuthorizationStatus(AVAuthorizationStatusAuthorizedMac);
}
} else {
args->ThrowError("Invalid media type");
return std::string();
}
}
v8::Local<v8::Promise> SystemPreferences::AskForMediaAccess(
v8::Isolate* isolate,
const std::string& media_type) {
util::Promise promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
if (auto type = ParseMediaType(media_type)) {
if (@available(macOS 10.14, *)) {
__block util::Promise p = std::move(promise);
[AVCaptureDevice requestAccessForMediaType:type
completionHandler:^(BOOL granted) {
dispatch_async(dispatch_get_main_queue(), ^{
p.Resolve(!!granted);
});
}];
} else {
// access always allowed pre-10.14 Mojave
promise.Resolve(true);
}
} else {
promise.RejectWithErrorMessage("Invalid media type");
}
return handle;
}
void SystemPreferences::RemoveUserDefault(const std::string& name) {
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
[defaults removeObjectForKey:base::SysUTF8ToNSString(name)];
}
bool SystemPreferences::IsDarkMode() {
if (@available(macOS 10.15, *)) {
return ui::NativeTheme::GetInstanceForNativeUi()->SystemDarkModeEnabled();
}
NSString* mode = [[NSUserDefaults standardUserDefaults]
stringForKey:@"AppleInterfaceStyle"];
return [mode isEqualToString:@"Dark"];

View File

@@ -20,6 +20,18 @@ namespace {
const wchar_t kSystemPreferencesWindowClass[] =
L"Electron_SystemPreferencesHostWindow";
bool g_is_high_contract_color_scheme = false;
bool g_is_high_contract_color_scheme_initialized = false;
void UpdateHighContrastColorScheme() {
HIGHCONTRAST high_contrast = {0};
high_contrast.cbSize = sizeof(HIGHCONTRAST);
g_is_high_contract_color_scheme =
SystemParametersInfo(SPI_GETHIGHCONTRAST, 0, &high_contrast, 0) &&
((high_contrast.dwFlags & HCF_HIGHCONTRASTON) != 0);
g_is_high_contract_color_scheme_initialized = true;
}
} // namespace
namespace api {
@@ -28,6 +40,12 @@ bool SystemPreferences::IsAeroGlassEnabled() {
return ui::win::IsAeroGlassEnabled();
}
bool SystemPreferences::IsHighContrastColorScheme() {
if (!g_is_high_contract_color_scheme_initialized)
UpdateHighContrastColorScheme();
return g_is_high_contract_color_scheme;
}
std::string hexColorDWORDToRGBA(DWORD color) {
DWORD rgba = color << 8 | color >> 24;
std::ostringstream stream;
@@ -119,6 +137,7 @@ std::string SystemPreferences::GetColor(const std::string& color,
void SystemPreferences::InitializeWindow() {
invertered_color_scheme_ = IsInvertedColorScheme();
high_contrast_color_scheme_ = IsHighContrastColorScheme();
// Wait until app is ready before creating sys color listener
// Creating this listener before the app is ready causes global shortcuts
@@ -169,6 +188,9 @@ LRESULT CALLBACK SystemPreferences::WndProc(HWND hwnd,
Emit("accent-color-changed", hexColorDWORDToRGBA(new_color));
current_color_ = new_color_string;
}
} else if (message == WM_SYSCOLORCHANGE ||
(message == WM_SETTINGCHANGE && wparam == SPI_SETHIGHCONTRAST)) {
UpdateHighContrastColorScheme();
}
return ::DefWindowProc(hwnd, message, wparam, lparam);
}
@@ -179,6 +201,13 @@ void SystemPreferences::OnSysColorChange() {
invertered_color_scheme_ = new_invertered_color_scheme;
Emit("inverted-color-scheme-changed", new_invertered_color_scheme);
}
bool new_high_contrast_color_scheme = IsHighContrastColorScheme();
if (new_high_contrast_color_scheme != high_contrast_color_scheme_) {
high_contrast_color_scheme_ = new_high_contrast_color_scheme;
Emit("high-contrast-color-scheme-changed", new_high_contrast_color_scheme);
}
Emit("color-changed");
}

View File

@@ -20,6 +20,7 @@
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/options_switches.h"
#include "electron/buildflags/buildflags.h"
#include "gin/converter.h"
#include "native_mate/handle.h"
#include "native_mate/persistent_dictionary.h"
@@ -158,7 +159,7 @@ void TopLevelWindow::OnWindowClosed() {
Emit("closed");
RemoveFromParentChildWindows();
ResetBrowserView();
TopLevelWindow::ResetBrowserViews();
// Destroy the native class when window is closed.
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, GetDestroyClosure());
@@ -266,7 +267,7 @@ void TopLevelWindow::OnWindowAlwaysOnTopChanged() {
Emit("always-on-top-changed", IsAlwaysOnTop());
}
void TopLevelWindow::OnExecuteWindowsCommand(const std::string& command_name) {
void TopLevelWindow::OnExecuteAppCommand(const std::string& command_name) {
Emit("app-command", command_name);
}
@@ -293,6 +294,7 @@ void TopLevelWindow::OnWindowMessage(UINT message,
#endif
void TopLevelWindow::SetContentView(mate::Handle<View> view) {
ResetBrowserViews();
content_view_.Reset(isolate(), view.ToV8());
window_->SetContentView(view->view());
}
@@ -643,7 +645,8 @@ void TopLevelWindow::SetFocusable(bool focusable) {
void TopLevelWindow::SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> value) {
mate::Handle<Menu> menu;
if (value->IsObject() &&
mate::V8ToString(value->ToObject()->GetConstructorName()) == "Menu" &&
gin::V8ToString(
isolate, value->ToObject(isolate)->GetConstructorName()) == "Menu" &&
mate::ConvertFromV8(isolate, value, &menu) && !menu.IsEmpty()) {
menu_.Reset(isolate, menu.ToV8());
window_->SetMenu(menu->model());
@@ -656,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,
mate::Arguments* args) {
if (IsModal()) {
@@ -669,6 +677,7 @@ void TopLevelWindow::SetParentWindow(v8::Local<v8::Value> value,
parent_window_.Reset();
window_->SetParentWindow(nullptr);
} else if (mate::ConvertFromV8(isolate(), value, &parent)) {
RemoveFromParentChildWindows();
parent_window_.Reset(isolate(), value);
window_->SetParentWindow(parent->window_.get());
parent->child_windows_.Set(isolate(), weak_map_id(), GetWrapper());
@@ -678,21 +687,43 @@ void TopLevelWindow::SetParentWindow(v8::Local<v8::Value> value,
}
void TopLevelWindow::SetBrowserView(v8::Local<v8::Value> value) {
ResetBrowserView();
ResetBrowserViews();
AddBrowserView(value);
}
void TopLevelWindow::AddBrowserView(v8::Local<v8::Value> value) {
mate::Handle<BrowserView> browser_view;
if (value->IsNull() || value->IsUndefined()) {
window_->SetBrowserView(nullptr);
} else if (mate::ConvertFromV8(isolate(), value, &browser_view)) {
window_->SetBrowserView(browser_view->view());
browser_view->web_contents()->SetOwnerWindow(window_.get());
browser_view_.Reset(isolate(), value);
if (value->IsObject() &&
mate::ConvertFromV8(isolate(), value, &browser_view)) {
auto get_that_view = browser_views_.find(browser_view->weak_map_id());
if (get_that_view == browser_views_.end()) {
window_->AddBrowserView(browser_view->view());
browser_view->web_contents()->SetOwnerWindow(window_.get());
browser_views_[browser_view->weak_map_id()].Reset(isolate(), value);
}
}
}
void TopLevelWindow::RemoveBrowserView(v8::Local<v8::Value> value) {
mate::Handle<BrowserView> browser_view;
if (value->IsObject() &&
mate::ConvertFromV8(isolate(), value, &browser_view)) {
auto get_that_view = browser_views_.find(browser_view->weak_map_id());
if (get_that_view != browser_views_.end()) {
window_->RemoveBrowserView(browser_view->view());
browser_view->web_contents()->SetOwnerWindow(nullptr);
(*get_that_view).second.Reset(isolate(), value);
browser_views_.erase(get_that_view);
}
}
}
v8::Local<v8::Value> TopLevelWindow::GetNativeWindowHandle() {
gfx::AcceleratedWidget handle = window_->GetAcceleratedWidget();
return ToBuffer(isolate(), static_cast<void*>(&handle), sizeof(handle));
// TODO(MarshallOfSound): Replace once
// https://chromium-review.googlesource.com/c/chromium/src/+/1253094/ has
// landed
NativeWindowHandle handle = window_->GetNativeWindowHandle();
return ToBuffer(isolate(), &handle, sizeof(handle));
}
void TopLevelWindow::SetProgressBar(double progress, mate::Arguments* args) {
@@ -737,7 +768,7 @@ void TopLevelWindow::SetAutoHideCursor(bool auto_hide) {
void TopLevelWindow::SetVibrancy(v8::Isolate* isolate,
v8::Local<v8::Value> value) {
std::string type = mate::V8ToString(value);
std::string type = gin::V8ToString(isolate, value);
window_->SetVibrancy(type);
}
@@ -841,12 +872,29 @@ std::vector<v8::Local<v8::Object>> TopLevelWindow::GetChildWindows() const {
return child_windows_.Values(isolate());
}
v8::Local<v8::Value> TopLevelWindow::GetBrowserView() const {
if (browser_view_.IsEmpty()) {
v8::Local<v8::Value> TopLevelWindow::GetBrowserView(
mate::Arguments* args) const {
if (browser_views_.size() == 0) {
return v8::Null(isolate());
} else if (browser_views_.size() == 1) {
auto first_view = browser_views_.begin();
return v8::Local<v8::Value>::New(isolate(), (*first_view).second);
} else {
args->ThrowError(
"BrowserWindow have multiple BrowserViews, "
"Use getBrowserViews() instead");
return v8::Null(isolate());
}
}
return v8::Local<v8::Value>::New(isolate(), browser_view_);
std::vector<v8::Local<v8::Value>> TopLevelWindow::GetBrowserViews() const {
std::vector<v8::Local<v8::Value>> ret;
for (auto const& views_iter : browser_views_) {
ret.push_back(v8::Local<v8::Value>::New(isolate(), views_iter.second));
}
return ret;
}
bool TopLevelWindow::IsModal() const {
@@ -938,17 +986,21 @@ int32_t TopLevelWindow::GetID() const {
return weak_map_id();
}
void TopLevelWindow::ResetBrowserView() {
if (browser_view_.IsEmpty())
return;
void TopLevelWindow::ResetBrowserViews() {
for (auto& item : browser_views_) {
mate::Handle<BrowserView> browser_view;
if (mate::ConvertFromV8(isolate(),
v8::Local<v8::Value>::New(isolate(), item.second),
&browser_view) &&
!browser_view.IsEmpty()) {
window_->RemoveBrowserView(browser_view->view());
browser_view->web_contents()->SetOwnerWindow(nullptr);
}
mate::Handle<BrowserView> browser_view;
if (mate::ConvertFromV8(isolate(), GetBrowserView(), &browser_view) &&
!browser_view.IsEmpty()) {
browser_view->web_contents()->SetOwnerWindow(nullptr);
item.second.Reset();
}
browser_view_.Reset();
browser_views_.clear();
}
void TopLevelWindow::RemoveFromParentChildWindows() {
@@ -1056,10 +1108,11 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate,
.SetMethod("setContentProtection", &TopLevelWindow::SetContentProtection)
.SetMethod("setFocusable", &TopLevelWindow::SetFocusable)
.SetMethod("setMenu", &TopLevelWindow::SetMenu)
#if !defined(OS_WIN)
.SetMethod("removeMenu", &TopLevelWindow::RemoveMenu)
.SetMethod("setParentWindow", &TopLevelWindow::SetParentWindow)
#endif
.SetMethod("setBrowserView", &TopLevelWindow::SetBrowserView)
.SetMethod("addBrowserView", &TopLevelWindow::AddBrowserView)
.SetMethod("removeBrowserView", &TopLevelWindow::RemoveBrowserView)
.SetMethod("getNativeWindowHandle",
&TopLevelWindow::GetNativeWindowHandle)
.SetMethod("setProgressBar", &TopLevelWindow::SetProgressBar)
@@ -1097,6 +1150,7 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate,
.SetMethod("getParentWindow", &TopLevelWindow::GetParentWindow)
.SetMethod("getChildWindows", &TopLevelWindow::GetChildWindows)
.SetMethod("getBrowserView", &TopLevelWindow::GetBrowserView)
.SetMethod("getBrowserViews", &TopLevelWindow::GetBrowserViews)
.SetMethod("isModal", &TopLevelWindow::IsModal)
.SetMethod("setThumbarButtons", &TopLevelWindow::SetThumbarButtons)
#if defined(TOOLKIT_VIEWS)
@@ -1131,8 +1185,9 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Isolate* isolate = context->GetIsolate();
TopLevelWindow::SetConstructor(isolate, base::Bind(&TopLevelWindow::New));
mate::Dictionary constructor(
isolate, TopLevelWindow::GetConstructor(isolate)->GetFunction());
mate::Dictionary constructor(isolate, TopLevelWindow::GetConstructor(isolate)
->GetFunction(context)
.ToLocalChecked());
constructor.SetMethod("fromId",
&mate::TrackableObject<TopLevelWindow>::FromWeakMapID);
constructor.SetMethod("getAllWindows",
@@ -1144,4 +1199,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_top_level_window, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_top_level_window, Initialize)

View File

@@ -14,6 +14,8 @@
#include "atom/browser/native_window.h"
#include "atom/browser/native_window_observer.h"
#include "atom/common/api/atom_api_native_image.h"
#include "base/task/post_task.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "native_mate/handle.h"
@@ -78,7 +80,7 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
void OnWindowEnterHtmlFullScreen() override;
void OnWindowLeaveHtmlFullScreen() override;
void OnWindowAlwaysOnTopChanged() override;
void OnExecuteWindowsCommand(const std::string& command_name) override;
void OnExecuteAppCommand(const std::string& command_name) override;
void OnTouchBarItemResult(const std::string& item_id,
const base::DictionaryValue& details) override;
void OnNewWindowForTab() override;
@@ -163,8 +165,13 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
void SetContentProtection(bool enable);
void SetFocusable(bool focusable);
void SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> menu);
void RemoveMenu();
void SetParentWindow(v8::Local<v8::Value> value, mate::Arguments* args);
virtual void SetBrowserView(v8::Local<v8::Value> value);
virtual void AddBrowserView(v8::Local<v8::Value> value);
virtual void RemoveBrowserView(v8::Local<v8::Value> value);
virtual std::vector<v8::Local<v8::Value>> GetBrowserViews() const;
virtual void ResetBrowserViews();
v8::Local<v8::Value> GetNativeWindowHandle();
void SetProgressBar(double progress, mate::Arguments* args);
void SetOverlayIcon(const gfx::Image& overlay,
@@ -195,7 +202,7 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
v8::Local<v8::Value> GetContentView() const;
v8::Local<v8::Value> GetParentWindow() const;
std::vector<v8::Local<v8::Object>> GetChildWindows() const;
v8::Local<v8::Value> GetBrowserView() const;
v8::Local<v8::Value> GetBrowserView(mate::Arguments* args) const;
bool IsModal() const;
// Extra APIs added in JS.
@@ -226,8 +233,8 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
template <typename... Args>
void EmitEventSoon(base::StringPiece eventName) {
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(base::IgnoreResult(&TopLevelWindow::Emit<Args...>),
weak_factory_.GetWeakPtr(), eventName));
}
@@ -238,7 +245,7 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
#endif
v8::Global<v8::Value> content_view_;
v8::Global<v8::Value> browser_view_;
std::map<int32_t, v8::Global<v8::Value>> browser_views_;
v8::Global<v8::Value> menu_;
v8::Global<v8::Value> parent_window_;
KeyWeakMap<int> child_windows_;

View File

@@ -254,9 +254,11 @@ void Initialize(v8::Local<v8::Object> exports,
Tray::SetConstructor(isolate, base::Bind(&Tray::New));
mate::Dictionary dict(isolate, exports);
dict.Set("Tray", Tray::GetConstructor(isolate)->GetFunction());
dict.Set(
"Tray",
Tray::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
}
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_tray, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_tray, Initialize)

View File

@@ -76,8 +76,9 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Isolate* isolate = context->GetIsolate();
View::SetConstructor(isolate, base::Bind(&View::New));
mate::Dictionary constructor(isolate,
View::GetConstructor(isolate)->GetFunction());
mate::Dictionary constructor(
isolate,
View::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
mate::Dictionary dict(isolate, exports);
dict.Set("View", constructor);
@@ -85,4 +86,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_view, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_view, Initialize)

View File

@@ -17,11 +17,14 @@
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/atom_javascript_dialog_manager.h"
#include "atom/browser/atom_navigation_throttle.h"
#include "atom/browser/browser.h"
#include "atom/browser/child_web_contents_tracker.h"
#include "atom/browser/lib/bluetooth_chooser.h"
#include "atom/browser/native_window.h"
#include "atom/browser/net/atom_network_delegate.h"
#include "atom/browser/ui/drag_util.h"
#include "atom/browser/ui/inspectable_web_contents.h"
#include "atom/browser/ui/inspectable_web_contents_view.h"
#include "atom/browser/web_contents_permission_helper.h"
#include "atom/browser/web_contents_preferences.h"
#include "atom/browser/web_contents_zoom_controller.h"
@@ -44,21 +47,18 @@
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/options_switches.h"
#include "base/message_loop/message_loop.h"
#include "base/no_destructor.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
#include "brightray/browser/inspectable_web_contents.h"
#include "brightray/browser/inspectable_web_contents_view.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/printing/print_preview_message_handler.h"
#include "chrome/browser/printing/print_view_manager_basic.h"
#include "chrome/browser/ssl/security_state_tab_helper.h"
#include "content/browser/frame_host/frame_tree_node.h"
#include "content/browser/frame_host/render_frame_host_manager.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "content/common/view_messages.h"
#include "content/common/widget_messages.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/download_request_utils.h"
#include "content/public/browser/favicon_status.h"
@@ -81,13 +81,12 @@
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
#include "net/url_request/url_request_context.h"
#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h"
#include "third_party/blink/public/platform/web_input_event.h"
#include "third_party/blink/public/web/web_find_options.h"
#include "ui/display/screen.h"
#include "ui/events/base_event_utils.h"
#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_web_contents_view.h"
#endif
@@ -101,34 +100,16 @@
#include "ui/gfx/font_render_params.h"
#endif
#if BUILDFLAG(ENABLE_PRINTING)
#include "chrome/browser/printing/print_view_manager_basic.h"
#include "components/printing/common/print_messages.h"
#endif
#include "atom/common/node_includes.h"
namespace {
struct PrintSettings {
bool silent;
bool print_background;
base::string16 device_name;
};
} // namespace
namespace mate {
template <>
struct Converter<PrintSettings> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
PrintSettings* out) {
mate::Dictionary dict;
if (!ConvertFromV8(isolate, val, &dict))
return false;
dict.Get("silent", &(out->silent));
dict.Get("printBackground", &(out->print_background));
dict.Get("deviceName", &(out->device_name));
return true;
}
};
#if BUILDFLAG(ENABLE_PRINTING)
template <>
struct Converter<printing::PrinterBasicInfo> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
@@ -142,6 +123,7 @@ struct Converter<printing::PrinterBasicInfo> {
return dict.GetHandle();
}
};
#endif
template <>
struct Converter<WindowOpenDisposition> {
@@ -258,7 +240,7 @@ namespace api {
namespace {
content::ServiceWorkerContext* GetServiceWorkerContext(
const content::WebContents* web_contents) {
content::WebContents* web_contents) {
auto* context = web_contents->GetBrowserContext();
auto* site_instance = web_contents->GetSiteInstance();
if (!context || !site_instance)
@@ -273,12 +255,11 @@ content::ServiceWorkerContext* GetServiceWorkerContext(
}
// Called when CapturePage is done.
void OnCapturePageDone(const base::Callback<void(const gfx::Image&)>& callback,
const SkBitmap& bitmap) {
void OnCapturePageDone(util::Promise promise, const SkBitmap& bitmap) {
// Hack to enable transparency in captured image
// TODO(nitsakh) Remove hack once fixed in chromium
const_cast<SkBitmap&>(bitmap).setAlphaType(kPremul_SkAlphaType);
callback.Run(gfx::Image::CreateFrom1xBitmap(bitmap));
promise.Resolve(gfx::Image::CreateFrom1xBitmap(bitmap));
}
} // namespace
@@ -305,25 +286,32 @@ struct WebContents::FrameDispatchHelper {
};
WebContents::WebContents(v8::Isolate* isolate,
content::WebContents* web_contents,
Type type)
: content::WebContentsObserver(web_contents), type_(type) {
const mate::Dictionary options = mate::Dictionary::CreateEmpty(isolate);
if (type == REMOTE) {
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent(),
false);
Init(isolate);
AttachAsUserData(web_contents);
InitZoomController(web_contents, options);
} else {
auto session = Session::CreateFrom(isolate, GetBrowserContext());
session_.Reset(isolate, session.ToV8());
InitWithSessionAndOptions(isolate, web_contents, session, options);
}
content::WebContents* web_contents)
: content::WebContentsObserver(web_contents),
type_(REMOTE),
weak_factory_(this) {
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent(),
false);
Init(isolate);
AttachAsUserData(web_contents);
InitZoomController(web_contents, mate::Dictionary::CreateEmpty(isolate));
}
WebContents::WebContents(v8::Isolate* isolate,
const mate::Dictionary& options) {
std::unique_ptr<content::WebContents> web_contents,
Type type)
: content::WebContentsObserver(web_contents.get()),
type_(type),
weak_factory_(this) {
DCHECK(type != REMOTE) << "Can't take ownership of a remote WebContents";
auto session = Session::CreateFrom(isolate, GetBrowserContext());
session_.Reset(isolate, session.ToV8());
InitWithSessionAndOptions(isolate, std::move(web_contents), session,
mate::Dictionary::CreateEmpty(isolate));
}
WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
: weak_factory_(this) {
// Read options.
options.Get("backgroundThrottling", &background_throttling_);
@@ -405,7 +393,7 @@ WebContents::WebContents(v8::Isolate* isolate,
web_contents = content::WebContents::Create(params);
}
InitWithSessionAndOptions(isolate, web_contents.release(), session, options);
InitWithSessionAndOptions(isolate, std::move(web_contents), session, options);
}
void WebContents::InitZoomController(content::WebContents* web_contents,
@@ -417,43 +405,47 @@ void WebContents::InitZoomController(content::WebContents* web_contents,
zoom_controller_->SetDefaultZoomFactor(zoom_factor);
}
void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
content::WebContents* web_contents,
mate::Handle<api::Session> session,
const mate::Dictionary& options) {
Observe(web_contents);
InitWithWebContents(web_contents, session->browser_context(), IsGuest());
void WebContents::InitWithSessionAndOptions(
v8::Isolate* isolate,
std::unique_ptr<content::WebContents> owned_web_contents,
mate::Handle<api::Session> session,
const mate::Dictionary& options) {
Observe(owned_web_contents.get());
// TODO(zcbenz): Make InitWithWebContents take unique_ptr.
// At the time of writing we are going through a refactoring and I don't want
// to make other people's work harder.
InitWithWebContents(owned_web_contents.release(), session->browser_context(),
IsGuest());
managed_web_contents()->GetView()->SetDelegate(this);
auto* prefs = web_contents->GetMutableRendererPrefs();
auto* prefs = web_contents()->GetMutableRendererPrefs();
prefs->accept_languages = g_browser_process->GetApplicationLocale();
#if defined(OS_LINUX) || defined(OS_WIN)
// Update font settings.
CR_DEFINE_STATIC_LOCAL(
const gfx::FontRenderParams, params,
(gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), nullptr)));
prefs->should_antialias_text = params.antialiasing;
prefs->use_subpixel_positioning = params.subpixel_positioning;
prefs->hinting = params.hinting;
prefs->use_autohinter = params.autohinter;
prefs->use_bitmaps = params.use_bitmaps;
prefs->subpixel_rendering = params.subpixel_rendering;
static const base::NoDestructor<gfx::FontRenderParams> params(
gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), nullptr));
prefs->should_antialias_text = params->antialiasing;
prefs->use_subpixel_positioning = params->subpixel_positioning;
prefs->hinting = params->hinting;
prefs->use_autohinter = params->autohinter;
prefs->use_bitmaps = params->use_bitmaps;
prefs->subpixel_rendering = params->subpixel_rendering;
#endif
// Save the preferences in C++.
new WebContentsPreferences(web_contents, options);
new WebContentsPreferences(web_contents(), options);
// Initialize permission helper.
WebContentsPermissionHelper::CreateForWebContents(web_contents);
WebContentsPermissionHelper::CreateForWebContents(web_contents());
// Initialize security state client.
SecurityStateTabHelper::CreateForWebContents(web_contents);
SecurityStateTabHelper::CreateForWebContents(web_contents());
// Initialize zoom controller.
InitZoomController(web_contents, options);
InitZoomController(web_contents(), options);
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent(),
false);
web_contents()->SetUserAgentOverride(GetBrowserContext()->GetUserAgent(),
false);
if (IsGuest()) {
NativeWindow* owner_window = nullptr;
@@ -469,7 +461,7 @@ void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
}
Init(isolate);
AttachAsUserData(web_contents);
AttachAsUserData(web_contents());
}
WebContents::~WebContents() {
@@ -480,14 +472,25 @@ WebContents::~WebContents() {
RenderViewDeleted(web_contents()->GetRenderViewHost());
if (type_ == WEB_VIEW) {
DCHECK(!web_contents()->GetOuterWebContents())
<< "Should never manually destroy an attached webview";
// For webview simply destroy the WebContents immediately.
DestroyWebContents(false /* async */);
} else if (type_ == BROWSER_WINDOW && owner_window()) {
// For BrowserWindow we should close the window and clean up everything
// before WebContents is destroyed.
for (ExtendedWebContentsObserver& observer : observers_)
observer.OnCloseContents();
// BrowserWindow destroys WebContents asynchronously, manually emit the
// destroyed event here.
WebContentsDestroyed();
} else if (Browser::Get()->is_shutting_down()) {
// Destroy WebContents directly when app is shutting down.
DestroyWebContents(false /* async */);
} else {
if (type_ == BROWSER_WINDOW && owner_window()) {
for (ExtendedWebContentsObserver& observer : observers_)
observer.OnCloseContents();
} else {
DestroyWebContents(true /* async */);
}
// Destroy WebContents asynchronously unless app is shutting down,
// because destroy() might be called inside WebContents's event handler.
DestroyWebContents(true /* async */);
// The WebContentsDestroyed will not be called automatically because we
// destroy the webContents in the next tick. So we have to manually
// call it here to make sure "destroyed" event is emitted.
@@ -531,10 +534,10 @@ void WebContents::WebContentsCreated(content::WebContents* source_contents,
const std::string& frame_name,
const GURL& target_url,
content::WebContents* new_contents) {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
auto api_web_contents = CreateFrom(isolate(), new_contents, BROWSER_WINDOW);
Emit("-web-contents-created", api_web_contents, target_url, frame_name);
ChildWebContentsTracker::CreateForWebContents(new_contents);
auto* tracker = ChildWebContentsTracker::FromWebContents(new_contents);
tracker->url = target_url;
tracker->frame_name = frame_name;
}
void WebContents::AddNewContents(
@@ -544,13 +547,17 @@ void WebContents::AddNewContents(
const gfx::Rect& initial_rect,
bool user_gesture,
bool* was_blocked) {
new ChildWebContentsTracker(new_contents.get());
auto* tracker = ChildWebContentsTracker::FromWebContents(new_contents.get());
DCHECK(tracker);
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
auto api_web_contents = CreateFrom(isolate(), new_contents.release());
auto api_web_contents =
CreateAndTake(isolate(), std::move(new_contents), BROWSER_WINDOW);
if (Emit("-add-new-contents", api_web_contents, disposition, user_gesture,
initial_rect.x(), initial_rect.y(), initial_rect.width(),
initial_rect.height())) {
initial_rect.height(), tracker->url, tracker->frame_name)) {
// TODO(zcbenz): Can we make this sync?
api_web_contents->DestroyWebContents(true /* async */);
}
}
@@ -594,7 +601,7 @@ void WebContents::SetContentsBounds(content::WebContents* source,
void WebContents::CloseContents(content::WebContents* source) {
Emit("close");
#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
#if defined(TOOLKIT_VIEWS)
HideAutofillPopup();
#endif
if (managed_web_contents())
@@ -612,15 +619,15 @@ void WebContents::UpdateTargetURL(content::WebContents* source,
Emit("update-target-url", url);
}
void WebContents::HandleKeyboardEvent(
bool WebContents::HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) {
if (type_ == WEB_VIEW && embedder_) {
// Send the unhandled keyboard events back to the embedder.
embedder_->HandleKeyboardEvent(source, event);
return embedder_->HandleKeyboardEvent(source, event);
} else {
// Go to the default keyboard handling.
CommonWebContentsDelegate::HandleKeyboardEvent(source, event);
return CommonWebContentsDelegate::HandleKeyboardEvent(source, event);
}
}
@@ -720,7 +727,7 @@ void WebContents::FindReply(content::WebContents* web_contents,
bool WebContents::CheckMediaAccessPermission(
content::RenderFrameHost* render_frame_host,
const GURL& security_origin,
content::MediaStreamType type) {
blink::MediaStreamType type) {
auto* web_contents =
content::WebContents::FromRenderFrameHost(render_frame_host);
auto* permission_helper =
@@ -763,7 +770,8 @@ void WebContents::OnAudioStateChanged(bool audible) {
Emit("-audio-state-changed", audible);
}
void WebContents::BeforeUnloadFired(const base::TimeTicks& proceed_time) {
void WebContents::BeforeUnloadFired(bool proceed,
const base::TimeTicks& proceed_time) {
// Do nothing, we override this method just to avoid compilation error since
// there are two virtual functions named BeforeUnloadFired.
}
@@ -776,8 +784,29 @@ void WebContents::RenderViewCreated(content::RenderViewHost* render_view_host) {
impl->disable_hidden_ = !background_throttling_;
}
void WebContents::RenderViewHostChanged(content::RenderViewHost* old_host,
content::RenderViewHost* new_host) {
currently_committed_process_id_ = new_host->GetProcess()->GetID();
}
void WebContents::RenderViewDeleted(content::RenderViewHost* render_view_host) {
// This event is necessary for tracking any states with respect to
// intermediate render view hosts aka speculative render view hosts. Currently
// used by object-registry.js to ref count remote objects.
Emit("render-view-deleted", render_view_host->GetProcess()->GetID());
if (-1 == currently_committed_process_id_ ||
render_view_host->GetProcess()->GetID() ==
currently_committed_process_id_) {
currently_committed_process_id_ = -1;
// When the RVH that has been deleted is the current RVH it means that the
// the web contents are being closed. This is communicated by this event.
// Currently tracked by guest-window-manager.js to destroy the
// BrowserWindow.
Emit("current-render-view-deleted",
render_view_host->GetProcess()->GetID());
}
}
void WebContents::RenderProcessGone(base::TerminationStatus status) {
@@ -812,6 +841,10 @@ void WebContents::DidChangeThemeColor(SkColor theme_color) {
}
}
void WebContents::DidAcquireFullscreen(content::RenderFrameHost* rfh) {
set_fullscreen_frame(rfh);
}
void WebContents::DocumentLoadedInFrame(
content::RenderFrameHost* render_frame_host) {
if (!render_frame_host->GetParent())
@@ -974,8 +1007,8 @@ void WebContents::DevToolsFocused() {
void WebContents::DevToolsOpened() {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
auto handle = WebContents::CreateFrom(
isolate(), managed_web_contents()->GetDevToolsWebContents());
auto handle =
FromOrCreate(isolate(), managed_web_contents()->GetDevToolsWebContents());
devtools_web_contents_.Reset(isolate(), handle.ToV8());
// Set inspected tabID.
@@ -985,8 +1018,7 @@ void WebContents::DevToolsOpened() {
// Inherit owner window in devtools when it doesn't have one.
auto* devtools = managed_web_contents()->GetDevToolsWebContents();
bool has_window =
devtools->GetUserData(NativeWindowRelay::kNativeWindowRelayUserDataKey);
bool has_window = devtools->GetUserData(NativeWindowRelay::UserDataKey());
if (owner_window() && !has_window)
handle->SetOwnerWindow(devtools, owner_window());
@@ -1001,7 +1033,7 @@ void WebContents::DevToolsClosed() {
Emit("devtools-closed");
}
#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
#if defined(TOOLKIT_VIEWS)
void WebContents::ShowAutofillPopup(content::RenderFrameHost* frame_host,
const gfx::RectF& bounds,
const std::vector<base::string16>& values,
@@ -1026,7 +1058,7 @@ void WebContents::ShowAutofillPopup(content::RenderFrameHost* frame_host,
bool WebContents::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(WebContents, message)
IPC_MESSAGE_HANDLER_CODE(ViewHostMsg_SetCursor, OnCursorChange,
IPC_MESSAGE_HANDLER_CODE(WidgetHostMsg_SetCursor, OnCursorChange,
handled = false)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -1048,7 +1080,7 @@ bool WebContents::OnMessageReceived(const IPC::Message& message,
FrameDispatchHelper::OnSetTemporaryZoomLevel)
IPC_MESSAGE_FORWARD_DELAY_REPLY(AtomFrameHostMsg_GetZoomLevel, &helper,
FrameDispatchHelper::OnGetZoomLevel)
#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
#if defined(TOOLKIT_VIEWS)
IPC_MESSAGE_HANDLER(AtomAutofillFrameHostMsg_ShowPopup, ShowAutofillPopup)
IPC_MESSAGE_HANDLER(AtomAutofillFrameHostMsg_HidePopup, HideAutofillPopup)
#endif
@@ -1099,6 +1131,37 @@ void WebContents::NavigationEntryCommitted(
details.is_same_document, details.did_replace_entry);
}
void WebContents::SetBackgroundThrottling(bool allowed) {
background_throttling_ = allowed;
auto* contents = web_contents();
if (!contents) {
return;
}
const auto* render_view_host = contents->GetRenderViewHost();
if (!render_view_host) {
return;
}
auto* render_process_host = render_view_host->GetProcess();
if (!render_process_host) {
return;
}
auto* render_widget_host_impl = content::RenderWidgetHostImpl::FromID(
render_process_host->GetID(), render_view_host->GetRoutingID());
if (!render_widget_host_impl) {
return;
}
render_widget_host_impl->disable_hidden_ = !background_throttling_;
if (render_widget_host_impl->is_hidden()) {
render_widget_host_impl->WasShown(false);
}
}
int WebContents::GetProcessID() const {
return web_contents()->GetMainFrame()->GetProcess()->GetID();
}
@@ -1130,8 +1193,9 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
if (!options.Get("httpReferrer", &params.referrer)) {
GURL http_referrer;
if (options.Get("httpReferrer", &http_referrer))
params.referrer = content::Referrer(http_referrer.GetAsReferrer(),
blink::kWebReferrerPolicyDefault);
params.referrer =
content::Referrer(http_referrer.GetAsReferrer(),
network::mojom::ReferrerPolicy::kDefault);
}
std::string user_agent;
@@ -1157,6 +1221,9 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
params.transition_type = ui::PAGE_TRANSITION_TYPED;
params.should_clear_history_list = 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);
// Set the background color of RenderWidgetHostView.
@@ -1271,14 +1338,16 @@ void WebContents::OpenDevTools(mate::Arguments* args) {
if (type_ == WEB_VIEW || !owner_window()) {
state = "detach";
}
bool activate = true;
if (args && args->Length() == 1) {
mate::Dictionary options;
if (args->GetNext(&options)) {
options.Get("mode", &state);
options.Get("activate", &activate);
}
}
managed_web_contents()->SetDockState(state);
managed_web_contents()->ShowDevTools();
managed_web_contents()->ShowDevTools(activate);
}
void WebContents::CloseDevTools() {
@@ -1313,8 +1382,8 @@ void WebContents::EnableDeviceEmulation(
frame_host ? frame_host->GetView()->GetRenderWidgetHost() : nullptr;
if (!widget_host)
return;
widget_host->Send(
new ViewMsg_EnableDeviceEmulation(widget_host->GetRoutingID(), params));
widget_host->Send(new WidgetMsg_EnableDeviceEmulation(
widget_host->GetRoutingID(), params));
}
}
@@ -1329,7 +1398,7 @@ void WebContents::DisableDeviceEmulation() {
if (!widget_host)
return;
widget_host->Send(
new ViewMsg_DisableDeviceEmulation(widget_host->GetRoutingID()));
new WidgetMsg_DisableDeviceEmulation(widget_host->GetRoutingID()));
}
}
@@ -1422,40 +1491,58 @@ bool WebContents::IsCurrentlyAudible() {
return web_contents()->IsCurrentlyAudible();
}
#if BUILDFLAG(ENABLE_PRINTING)
void WebContents::Print(mate::Arguments* args) {
PrintSettings settings = {false, false, base::string16()};
if (args->Length() >= 1 && !args->GetNext(&settings)) {
args->ThrowError();
bool silent = false, print_background = false;
base::string16 device_name;
mate::Dictionary options = mate::Dictionary::CreateEmpty(args->isolate());
base::DictionaryValue settings;
if (args->Length() >= 1 && !args->GetNext(&options)) {
args->ThrowError("Invalid print settings specified");
return;
}
auto* print_view_manager_basic_ptr =
printing::PrintViewManagerBasic::FromWebContents(web_contents());
if (args->Length() == 2) {
base::Callback<void(bool)> callback;
if (!args->GetNext(&callback)) {
args->ThrowError();
return;
}
print_view_manager_basic_ptr->SetCallback(callback);
printing::CompletionCallback callback;
if (args->Length() == 2 && !args->GetNext(&callback)) {
args->ThrowError("Invalid optional callback provided");
return;
}
print_view_manager_basic_ptr->PrintNow(
web_contents()->GetMainFrame(), settings.silent,
settings.print_background, settings.device_name);
options.Get("silent", &silent);
options.Get("printBackground", &print_background);
if (options.Get("deviceName", &device_name) && !device_name.empty()) {
settings.SetString(printing::kSettingDeviceName, device_name);
}
auto* print_view_manager =
printing::PrintViewManagerBasic::FromWebContents(web_contents());
auto* focused_frame = web_contents()->GetFocusedFrame();
auto* rfh = focused_frame && focused_frame->HasSelection()
? focused_frame
: web_contents()->GetMainFrame();
print_view_manager->PrintNow(
rfh,
std::make_unique<PrintMsg_PrintPages>(rfh->GetRoutingID(), silent,
print_background, settings),
std::move(callback));
}
std::vector<printing::PrinterBasicInfo> WebContents::GetPrinterList() {
std::vector<printing::PrinterBasicInfo> printers;
auto print_backend = printing::PrintBackend::CreateInstance(nullptr);
base::ThreadRestrictions::ScopedAllowIO allow_io;
print_backend->EnumeratePrinters(&printers);
{
// TODO(deepak1556): Deprecate this api in favor of an
// async version and post a non blocing task call.
base::ThreadRestrictions::ScopedAllowIO allow_io;
print_backend->EnumeratePrinters(&printers);
}
return printers;
}
void WebContents::PrintToPDF(const base::DictionaryValue& setting,
const PrintToPDFCallback& callback) {
printing::PrintPreviewMessageHandler::FromWebContents(web_contents())
->PrintToPDF(setting, callback);
void WebContents::PrintToPDF(
const base::DictionaryValue& settings,
const PrintPreviewMessageHandler::PrintToPDFCallback& callback) {
PrintPreviewMessageHandler::FromWebContents(web_contents())
->PrintToPDF(settings, callback);
}
#endif
void WebContents::AddWorkSpace(mate::Arguments* args,
const base::FilePath& path) {
@@ -1520,17 +1607,22 @@ void WebContents::ReplaceMisspelling(const base::string16& word) {
}
uint32_t WebContents::FindInPage(mate::Arguments* args) {
uint32_t request_id = GetNextRequestId();
base::string16 search_text;
blink::WebFindOptions options;
if (!args->GetNext(&search_text) || search_text.empty()) {
args->ThrowError("Must provide a non-empty search content");
return 0;
}
args->GetNext(&options);
uint32_t request_id = GetNextRequestId();
mate::Dictionary dict;
auto options = blink::mojom::FindOptions::New();
if (args->GetNext(&dict)) {
dict.Get("forward", &options->forward);
dict.Get("matchCase", &options->match_case);
dict.Get("findNext", &options->find_next);
}
web_contents()->Find(request_id, search_text, options);
web_contents()->Find(request_id, search_text, std::move(options));
return request_id;
}
@@ -1588,13 +1680,41 @@ bool WebContents::SendIPCMessageWithSender(bool internal,
const std::string& channel,
const base::ListValue& args,
int32_t sender_id) {
auto* frame_host = web_contents()->GetMainFrame();
if (frame_host) {
return frame_host->Send(new AtomFrameMsg_Message(frame_host->GetRoutingID(),
internal, send_to_all,
channel, args, sender_id));
std::vector<content::RenderFrameHost*> target_hosts;
if (!send_to_all) {
auto* frame_host = web_contents()->GetMainFrame();
if (frame_host) {
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 send_to_all,
int32_t frame_id,
const std::string& channel,
const base::ListValue& args) {
auto frames = web_contents()->GetAllFrames();
auto iter = std::find_if(frames.begin(), frames.end(), [frame_id](auto* f) {
return f->GetRoutingID() == frame_id;
});
if (iter == frames.end())
return false;
if (!(*iter)->IsRenderFrameLive())
return false;
return (*iter)->Send(new AtomFrameMsg_Message(
frame_id, internal, send_to_all, channel, args, 0 /* sender_id */));
}
void WebContents::SendInputEvent(v8::Isolate* isolate,
@@ -1636,6 +1756,19 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
mouse_wheel_event);
#endif
} 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);
}
return;
@@ -1693,28 +1826,25 @@ void WebContents::StartDrag(const mate::Dictionary& item,
// Start dragging.
if (!files.empty()) {
base::MessageLoop::ScopedNestableTaskAllower allow;
base::MessageLoopCurrent::ScopedNestableTaskAllower allow;
DragFileItems(files, icon->image(), web_contents()->GetNativeView());
} else {
args->ThrowError("Must specify either 'file' or 'files' option");
}
}
void WebContents::CapturePage(mate::Arguments* args) {
v8::Local<v8::Promise> WebContents::CapturePage(mate::Arguments* args) {
gfx::Rect rect;
base::Callback<void(const gfx::Image&)> callback;
util::Promise promise(isolate());
v8::Local<v8::Promise> handle = promise.GetHandle();
if (!(args->Length() == 1 && args->GetNext(&callback)) &&
!(args->Length() == 2 && args->GetNext(&rect) &&
args->GetNext(&callback))) {
args->ThrowError();
return;
}
// get rect arguments if they exist
args->GetNext(&rect);
auto* const view = web_contents()->GetRenderWidgetHostView();
if (!view) {
callback.Run(gfx::Image());
return;
promise.Resolve(gfx::Image());
return handle;
}
// Capture full page if user doesn't specify a |rect|.
@@ -1733,7 +1863,8 @@ void WebContents::CapturePage(mate::Arguments* args) {
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
view->CopyFromSurface(gfx::Rect(rect.origin(), view_size), bitmap_size,
base::BindOnce(&OnCapturePageDone, callback));
base::BindOnce(&OnCapturePageDone, std::move(promise)));
return handle;
}
void WebContents::OnCursorChange(const content::WebCursor& cursor) {
@@ -1889,6 +2020,13 @@ v8::Local<v8::Value> WebContents::GetLastWebPreferences(
return mate::ConvertToV8(isolate, *web_preferences->last_preference());
}
bool WebContents::IsRemoteModuleEnabled() const {
if (auto* web_preferences = WebContentsPreferences::From(web_contents())) {
return web_preferences->IsRemoteModuleEnabled();
}
return true;
}
v8::Local<v8::Value> WebContents::GetOwnerBrowserWindow() const {
if (owner_window())
return BrowserWindow::From(isolate(), owner_window());
@@ -1989,6 +2127,8 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
prototype->SetClassName(mate::StringToV8(isolate, "WebContents"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.MakeDestroyable()
.SetMethod("setBackgroundThrottling",
&WebContents::SetBackgroundThrottling)
.SetMethod("getProcessId", &WebContents::GetProcessID)
.SetMethod("getOSProcessId", &WebContents::GetOSProcessID)
.SetMethod("equal", &WebContents::Equal)
@@ -2036,12 +2176,14 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
.SetMethod("isFocused", &WebContents::IsFocused)
.SetMethod("tabTraverse", &WebContents::TabTraverse)
.SetMethod("_send", &WebContents::SendIPCMessage)
.SetMethod("_sendToFrame", &WebContents::SendIPCMessageToFrame)
.SetMethod("sendInputEvent", &WebContents::SendInputEvent)
.SetMethod("beginFrameSubscription", &WebContents::BeginFrameSubscription)
.SetMethod("endFrameSubscription", &WebContents::EndFrameSubscription)
.SetMethod("startDrag", &WebContents::StartDrag)
.SetMethod("isGuest", &WebContents::IsGuest)
.SetMethod("attachToIframe", &WebContents::AttachToIframe)
.SetMethod("detachFromOuterFrame", &WebContents::DetachFromOuterFrame)
.SetMethod("isOffscreen", &WebContents::IsOffScreen)
#if BUILDFLAG(ENABLE_OSR)
.SetMethod("startPainting", &WebContents::StartPainting)
@@ -2052,21 +2194,24 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
#endif
.SetMethod("invalidate", &WebContents::Invalidate)
.SetMethod("setZoomLevel", &WebContents::SetZoomLevel)
.SetMethod("_getZoomLevel", &WebContents::GetZoomLevel)
.SetMethod("getZoomLevel", &WebContents::GetZoomLevel)
.SetMethod("setZoomFactor", &WebContents::SetZoomFactor)
.SetMethod("_getZoomFactor", &WebContents::GetZoomFactor)
.SetMethod("getZoomFactor", &WebContents::GetZoomFactor)
.SetMethod("getType", &WebContents::GetType)
.SetMethod("_getPreloadPath", &WebContents::GetPreloadPath)
.SetMethod("getWebPreferences", &WebContents::GetWebPreferences)
.SetMethod("getLastWebPreferences", &WebContents::GetLastWebPreferences)
.SetMethod("_isRemoteModuleEnabled", &WebContents::IsRemoteModuleEnabled)
.SetMethod("getOwnerBrowserWindow", &WebContents::GetOwnerBrowserWindow)
.SetMethod("hasServiceWorker", &WebContents::HasServiceWorker)
.SetMethod("unregisterServiceWorker",
&WebContents::UnregisterServiceWorker)
.SetMethod("inspectServiceWorker", &WebContents::InspectServiceWorker)
.SetMethod("print", &WebContents::Print)
.SetMethod("getPrinters", &WebContents::GetPrinterList)
#if BUILDFLAG(ENABLE_PRINTING)
.SetMethod("_print", &WebContents::Print)
.SetMethod("_getPrinters", &WebContents::GetPrinterList)
.SetMethod("_printToPDF", &WebContents::PrintToPDF)
#endif
.SetMethod("addWorkSpace", &WebContents::AddWorkSpace)
.SetMethod("removeWorkSpace", &WebContents::RemoveWorkSpace)
.SetMethod("showDefinitionForSelection",
@@ -2097,7 +2242,7 @@ void WebContents::OnRendererMessage(content::RenderFrameHost* frame_host,
const std::string& channel,
const base::ListValue& args) {
// webContents.emit(channel, new Event(), args...);
Emit(channel, args);
EmitWithSender(channel, frame_host, nullptr, args);
}
void WebContents::OnRendererMessageSync(content::RenderFrameHost* frame_host,
@@ -2123,35 +2268,43 @@ void WebContents::OnRendererMessageTo(content::RenderFrameHost* frame_host,
}
}
// static
mate::Handle<WebContents> WebContents::CreateFrom(
v8::Isolate* isolate,
content::WebContents* web_contents) {
// We have an existing WebContents object in JS.
auto* existing = TrackableObject::FromWrappedClass(isolate, web_contents);
if (existing)
return mate::CreateHandle(isolate, static_cast<WebContents*>(existing));
// Otherwise create a new WebContents wrapper object.
return mate::CreateHandle(isolate,
new WebContents(isolate, web_contents, REMOTE));
}
mate::Handle<WebContents> WebContents::CreateFrom(
v8::Isolate* isolate,
content::WebContents* web_contents,
Type type) {
// Otherwise create a new WebContents wrapper object.
return mate::CreateHandle(isolate,
new WebContents(isolate, web_contents, type));
}
// static
mate::Handle<WebContents> WebContents::Create(v8::Isolate* isolate,
const mate::Dictionary& options) {
return mate::CreateHandle(isolate, new WebContents(isolate, options));
}
// static
mate::Handle<WebContents> WebContents::CreateAndTake(
v8::Isolate* isolate,
std::unique_ptr<content::WebContents> web_contents,
Type type) {
return mate::CreateHandle(
isolate, new WebContents(isolate, std::move(web_contents), type));
}
// static
mate::Handle<WebContents> WebContents::From(
v8::Isolate* isolate,
content::WebContents* web_contents) {
auto* existing = TrackableObject::FromWrappedClass(isolate, web_contents);
if (existing)
return mate::CreateHandle(isolate, static_cast<WebContents*>(existing));
else
return mate::Handle<WebContents>();
}
// static
mate::Handle<WebContents> WebContents::FromOrCreate(
v8::Isolate* isolate,
content::WebContents* web_contents) {
auto existing = From(isolate, web_contents);
if (!existing.IsEmpty())
return existing;
else
return mate::CreateHandle(isolate, new WebContents(isolate, web_contents));
}
} // namespace api
} // namespace atom
@@ -2166,7 +2319,9 @@ void Initialize(v8::Local<v8::Object> exports,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("WebContents", WebContents::GetConstructor(isolate)->GetFunction());
dict.Set("WebContents", WebContents::GetConstructor(isolate)
->GetFunction(context)
.ToLocalChecked());
dict.SetMethod("create", &WebContents::Create);
dict.SetMethod("fromId", &mate::TrackableObject<WebContents>::FromWeakMapID);
dict.SetMethod("getAllWebContents",
@@ -2175,4 +2330,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_web_contents, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_web_contents, Initialize)

View File

@@ -15,6 +15,7 @@
#include "atom/browser/common_web_contents_delegate.h"
#include "atom/browser/ui/autofill_popup.h"
#include "base/observer_list.h"
#include "base/observer_list_types.h"
#include "content/common/cursors/webcursor.h"
#include "content/public/browser/keyboard_event_processing_result.h"
#include "content/public/browser/web_contents.h"
@@ -22,17 +23,18 @@
#include "content/public/common/favicon_url.h"
#include "electron/buildflags/buildflags.h"
#include "native_mate/handle.h"
#include "printing/backend/print_backend.h"
#include "printing/buildflags/buildflags.h"
#include "ui/gfx/image/image.h"
#if BUILDFLAG(ENABLE_PRINTING)
#include "atom/browser/printing/print_preview_message_handler.h"
#include "printing/backend/print_backend.h"
#endif
namespace blink {
struct WebDeviceEmulationParams;
}
namespace brightray {
class InspectableWebContents;
}
namespace mate {
class Arguments;
class Dictionary;
@@ -46,12 +48,12 @@ namespace atom {
class AtomBrowserContext;
class AtomJavaScriptDialogManager;
class InspectableWebContents;
class WebContentsZoomController;
class WebViewGuestDelegate;
class FrameSubscriber;
#if BUILDFLAG(ENABLE_OSR)
class OffScreenWebContentsView;
class OffScreenRenderWidgetHostView;
#endif
@@ -59,10 +61,13 @@ namespace api {
// Certain events are only in WebContentsDelegate, provide our own Observer to
// dispatch those events.
class ExtendedWebContentsObserver {
class ExtendedWebContentsObserver : public base::CheckedObserver {
public:
virtual void OnCloseContents() {}
virtual void OnRendererResponsive() {}
protected:
~ExtendedWebContentsObserver() override {}
};
// Wrapper around the content::WebContents.
@@ -79,29 +84,51 @@ class WebContents : public mate::TrackableObject<WebContents>,
OFF_SCREEN, // Used for offscreen rendering
};
// For node.js callback function type: function(error, buffer)
using PrintToPDFCallback =
base::Callback<void(v8::Local<v8::Value>, v8::Local<v8::Value>)>;
// Create from an existing WebContents.
static mate::Handle<WebContents> CreateFrom(
v8::Isolate* isolate,
content::WebContents* web_contents);
static mate::Handle<WebContents> CreateFrom(
v8::Isolate* isolate,
content::WebContents* web_contents,
Type type);
// Create a new WebContents.
// Create a new WebContents and return the V8 wrapper of it.
static mate::Handle<WebContents> Create(v8::Isolate* isolate,
const mate::Dictionary& options);
// Create a new V8 wrapper for an existing |web_content|.
//
// The lifetime of |web_contents| will be managed by this class.
static mate::Handle<WebContents> CreateAndTake(
v8::Isolate* isolate,
std::unique_ptr<content::WebContents> web_contents,
Type type);
// Get the V8 wrapper of |web_content|, return empty handle if not wrapped.
static mate::Handle<WebContents> From(v8::Isolate* isolate,
content::WebContents* web_content);
// Get the V8 wrapper of the |web_contents|, or create one if not existed.
//
// The lifetime of |web_contents| is NOT managed by this class, and the type
// of this wrapper is always REMOTE.
static mate::Handle<WebContents> FromOrCreate(
v8::Isolate* isolate,
content::WebContents* web_contents);
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
// Notifies to destroy any guest web contents before destroying self.
base::WeakPtr<WebContents> GetWeakPtr() { return weak_factory_.GetWeakPtr(); }
// Destroy the managed content::WebContents instance.
//
// Note: The |async| should only be |true| when users are expecting to use the
// webContents immediately after the call. Always pass |false| if you are not
// sure.
// See https://github.com/electron/electron/issues/8930.
//
// Note: When destroying a webContents member inside a destructor, the |async|
// should always be |false|, otherwise the destroy task might be delayed after
// normal shutdown procedure, resulting in an assertion.
// The normal pattern for calling this method in destructor is:
// api_web_contents_->DestroyWebContents(!Browser::Get()->is_shutting_down())
// See https://github.com/electron/electron/issues/15133.
void DestroyWebContents(bool async);
void SetBackgroundThrottling(bool allowed);
int GetProcessID() const;
base::ProcessId GetOSProcessID() const;
Type GetType() const;
@@ -142,15 +169,18 @@ class WebContents : public mate::TrackableObject<WebContents>,
void SetAudioMuted(bool muted);
bool IsAudioMuted();
bool IsCurrentlyAudible();
void Print(mate::Arguments* args);
std::vector<printing::PrinterBasicInfo> GetPrinterList();
void SetEmbedder(const WebContents* embedder);
void SetDevToolsWebContents(const WebContents* devtools);
v8::Local<v8::Value> GetNativeView() const;
#if BUILDFLAG(ENABLE_PRINTING)
void Print(mate::Arguments* args);
std::vector<printing::PrinterBasicInfo> GetPrinterList();
// Print current page as PDF.
void PrintToPDF(const base::DictionaryValue& setting,
const PrintToPDFCallback& callback);
void PrintToPDF(
const base::DictionaryValue& settings,
const PrintPreviewMessageHandler::PrintToPDFCallback& callback);
#endif
// DevTools workspace api.
void AddWorkSpace(mate::Arguments* args, const base::FilePath& path);
@@ -190,6 +220,12 @@ class WebContents : public mate::TrackableObject<WebContents>,
const base::ListValue& args,
int32_t sender_id = 0);
bool SendIPCMessageToFrame(bool internal,
bool send_to_all,
int32_t frame_id,
const std::string& channel,
const base::ListValue& args);
// Send WebInputEvent to the page.
void SendInputEvent(v8::Isolate* isolate, v8::Local<v8::Value> input_event);
@@ -202,12 +238,13 @@ class WebContents : public mate::TrackableObject<WebContents>,
// Captures the page with |rect|, |callback| would be called when capturing is
// done.
void CapturePage(mate::Arguments* args);
v8::Local<v8::Promise> CapturePage(mate::Arguments* args);
// Methods for creating <webview>.
bool IsGuest() const;
void AttachToIframe(content::WebContents* embedder_web_contents,
int embedder_frame_id);
void DetachFromOuterFrame();
// Methods for offscreen rendering
bool IsOffScreen() const;
@@ -249,6 +286,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
v8::Local<v8::Value> GetWebPreferences(v8::Isolate* isolate) const;
v8::Local<v8::Value> GetLastWebPreferences(v8::Isolate* isolate) const;
bool IsRemoteModuleEnabled() const;
// Returns the owner window.
v8::Local<v8::Value> GetOwnerBrowserWindow() const;
@@ -272,23 +311,30 @@ class WebContents : public mate::TrackableObject<WebContents>,
observers_.AddObserver(obs);
}
void RemoveObserver(ExtendedWebContentsObserver* obs) {
observers_.RemoveObserver(obs);
// Trying to remove from an empty collection leads to an access violation
if (observers_.might_have_observers())
observers_.RemoveObserver(obs);
}
bool EmitNavigationEvent(const std::string& event,
content::NavigationHandle* navigation_handle);
protected:
// Does not manage lifetime of |web_contents|.
WebContents(v8::Isolate* isolate, content::WebContents* web_contents);
// Takes over ownership of |web_contents|.
WebContents(v8::Isolate* isolate,
content::WebContents* web_contents,
std::unique_ptr<content::WebContents> web_contents,
Type type);
// Creates a new content::WebContents.
WebContents(v8::Isolate* isolate, const mate::Dictionary& options);
~WebContents() override;
void InitWithSessionAndOptions(v8::Isolate* isolate,
content::WebContents* web_contents,
mate::Handle<class Session> session,
const mate::Dictionary& options);
void InitWithSessionAndOptions(
v8::Isolate* isolate,
std::unique_ptr<content::WebContents> web_contents,
mate::Handle<class Session> session,
const mate::Dictionary& options);
// content::WebContentsDelegate:
bool DidAddMessageToConsole(content::WebContents* source,
@@ -319,7 +365,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
void CloseContents(content::WebContents* source) override;
void ActivateContents(content::WebContents* contents) override;
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
void HandleKeyboardEvent(
bool HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) override;
content::KeyboardEventProcessingResult PreHandleKeyboardEvent(
@@ -347,7 +393,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
bool final_update) override;
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
const GURL& security_origin,
content::MediaStreamType type) override;
blink::MediaStreamType type) override;
void RequestMediaAccessPermission(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
@@ -363,8 +409,11 @@ class WebContents : public mate::TrackableObject<WebContents>,
void OnAudioStateChanged(bool audible) override;
// content::WebContentsObserver:
void BeforeUnloadFired(const base::TimeTicks& proceed_time) override;
void BeforeUnloadFired(bool proceed,
const base::TimeTicks& proceed_time) override;
void RenderViewCreated(content::RenderViewHost*) override;
void RenderViewHostChanged(content::RenderViewHost* old_host,
content::RenderViewHost* new_host) override;
void RenderViewDeleted(content::RenderViewHost*) override;
void RenderProcessGone(base::TerminationStatus status) override;
void DocumentLoadedInFrame(
@@ -401,11 +450,12 @@ class WebContents : public mate::TrackableObject<WebContents>,
const MediaPlayerId& id,
content::WebContentsObserver::MediaStoppedReason reason) override;
void DidChangeThemeColor(SkColor theme_color) override;
void DidAcquireFullscreen(content::RenderFrameHost* rfh) override;
// brightray::InspectableWebContentsDelegate:
// InspectableWebContentsDelegate:
void DevToolsReloadPage() override;
// brightray::InspectableWebContentsViewDelegate:
// InspectableWebContentsViewDelegate:
void DevToolsFocused() override;
void DevToolsOpened() override;
void DevToolsClosed() override;
@@ -424,7 +474,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
uint32_t GetNextRequestId() { return ++request_id_; }
#if BUILDFLAG(ENABLE_OSR)
OffScreenWebContentsView* GetOffScreenWebContentsView() const;
OffScreenWebContentsView* GetOffScreenWebContentsView() const override;
OffScreenRenderWidgetHostView* GetOffScreenRenderWidgetHostView() const;
#endif
@@ -470,7 +520,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
std::unique_ptr<AtomJavaScriptDialogManager> dialog_manager_;
std::unique_ptr<WebViewGuestDelegate> guest_delegate_;
std::unique_ptr<FrameSubscriber> frame_subscriber_;
// The host webcontents that may contain this webcontents.
@@ -494,6 +543,12 @@ class WebContents : public mate::TrackableObject<WebContents>,
// Observers of this WebContents.
base::ObserverList<ExtendedWebContentsObserver> observers_;
// The ID of the process of the currently committed RenderViewHost.
// -1 means no speculative RVH has been committed yet.
int currently_committed_process_id_ = -1;
base::WeakPtrFactory<WebContents> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(WebContents);
};

View File

@@ -4,9 +4,12 @@
#include "atom/browser/api/atom_api_web_contents.h"
#include "content/browser/web_contents/web_contents_impl.h"
#if BUILDFLAG(ENABLE_OSR)
#include "atom/browser/osr/osr_render_widget_host_view.h"
#include "atom/browser/osr/osr_web_contents_view.h"
#include "content/browser/web_contents/web_contents_impl.h"
#endif
// Including both web_contents_impl.h and node.h would introduce a error, we
// have to isolate the usage of WebContentsImpl into a clean file to fix it:
@@ -16,17 +19,33 @@ namespace atom {
namespace api {
void WebContents::DetachFromOuterFrame() {
// See detach_webview_frame.patch on how to detach.
auto* impl = static_cast<content::WebContentsImpl*>(web_contents());
impl->GetRenderManagerForTesting()->RemoveOuterDelegateFrame();
}
#if BUILDFLAG(ENABLE_OSR)
OffScreenWebContentsView* WebContents::GetOffScreenWebContentsView() const {
const auto* impl =
static_cast<const content::WebContentsImpl*>(web_contents());
return static_cast<OffScreenWebContentsView*>(impl->GetView());
if (IsOffScreen()) {
const auto* impl =
static_cast<const content::WebContentsImpl*>(web_contents());
return static_cast<OffScreenWebContentsView*>(impl->GetView());
} else {
return nullptr;
}
}
OffScreenRenderWidgetHostView* WebContents::GetOffScreenRenderWidgetHostView()
const {
return static_cast<OffScreenRenderWidgetHostView*>(
web_contents()->GetRenderWidgetHostView());
if (IsOffScreen()) {
return static_cast<OffScreenRenderWidgetHostView*>(
web_contents()->GetRenderWidgetHostView());
} else {
return nullptr;
}
}
#endif
} // namespace api

View File

@@ -17,7 +17,7 @@ bool WebContents::IsFocused() const {
return false;
if (GetType() != BACKGROUND_PAGE) {
auto window = [web_contents()->GetNativeView() window];
auto window = [web_contents()->GetNativeView().GetNativeNSView() window];
// On Mac the render widget host view does not lose focus when the window
// loses focus so check if the top level window is the key window.
if (window && ![window isKeyWindow])

View File

@@ -5,8 +5,9 @@
#include "atom/browser/api/atom_api_web_contents_view.h"
#include "atom/browser/api/atom_api_web_contents.h"
#include "atom/browser/browser.h"
#include "atom/browser/ui/inspectable_web_contents_view.h"
#include "atom/common/api/constructor.h"
#include "brightray/browser/inspectable_web_contents_view.h"
#include "content/public/browser/web_contents_user_data.h"
#include "native_mate/dictionary.h"
@@ -30,12 +31,14 @@ class WebContentsViewRelay
atom::api::WebContentsView* view_ = nullptr;
WEB_CONTENTS_USER_DATA_KEY_DECL();
DISALLOW_COPY_AND_ASSIGN(WebContentsViewRelay);
};
} // namespace
WEB_CONTENTS_USER_DATA_KEY_IMPL(WebContentsViewRelay)
DEFINE_WEB_CONTENTS_USER_DATA_KEY(WebContentsViewRelay);
} // namespace
namespace atom {
@@ -43,7 +46,7 @@ namespace api {
WebContentsView::WebContentsView(v8::Isolate* isolate,
mate::Handle<WebContents> web_contents,
brightray::InspectableWebContents* iwc)
InspectableWebContents* iwc)
#if defined(OS_MACOSX)
: View(new DelayedNativeViewHost(iwc->GetView()->GetNativeView())),
#else
@@ -64,8 +67,11 @@ WebContentsView::WebContentsView(v8::Isolate* isolate,
}
WebContentsView::~WebContentsView() {
if (api_web_contents_)
api_web_contents_->DestroyWebContents(false /* async */);
if (api_web_contents_) { // destroy() is called
// Destroy WebContents asynchronously unless app is shutting down,
// because destroy() might be called inside WebContents's event handler.
api_web_contents_->DestroyWebContents(!Browser::Get()->is_shutting_down());
}
}
void WebContentsView::WebContentsDestroyed() {
@@ -125,4 +131,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_web_contents_view, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_web_contents_view, Initialize)

View File

@@ -9,12 +9,10 @@
#include "content/public/browser/web_contents_observer.h"
#include "native_mate/handle.h"
namespace brightray {
class InspectableWebContents;
}
namespace atom {
class InspectableWebContents;
namespace api {
class WebContents;
@@ -30,7 +28,7 @@ class WebContentsView : public View, public content::WebContentsObserver {
protected:
WebContentsView(v8::Isolate* isolate,
mate::Handle<WebContents> web_contents,
brightray::InspectableWebContents* iwc);
InspectableWebContents* iwc);
~WebContentsView() override;
// content::WebContentsObserver:

View File

@@ -12,6 +12,8 @@
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/net_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "base/task/post_task.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
@@ -29,7 +31,7 @@ struct Converter<URLPattern> {
if (!ConvertFromV8(isolate, val, &pattern))
return false;
*out = URLPattern(URLPattern::SCHEME_ALL);
return out->Parse(pattern) == URLPattern::PARSE_SUCCESS;
return out->Parse(pattern) == URLPattern::ParseResult::kSuccess;
}
};
@@ -97,8 +99,8 @@ void WebRequest::SetListener(Method method, Event type, mate::Arguments* args) {
browser_context_->GetRequestContext());
if (!url_request_context_getter)
return;
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&CallNetworkDelegateMethod<Method, Event, Listener>,
base::RetainedRef(url_request_context_getter), method,
type, std::move(patterns), std::move(listener)));

View File

@@ -55,4 +55,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_web_view_manager, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_web_view_manager, Initialize)

View File

@@ -5,6 +5,7 @@
#include "atom/browser/api/event_emitter.h"
#include "atom/browser/api/event.h"
#include "content/public/browser/render_frame_host.h"
#include "native_mate/arguments.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
@@ -34,7 +35,8 @@ v8::Local<v8::Object> CreateEventObject(v8::Isolate* isolate) {
}
return v8::Local<v8::ObjectTemplate>::New(isolate, event_template)
->NewInstance();
->NewInstance(isolate->GetCurrentContext())
.ToLocalChecked();
}
} // namespace
@@ -55,7 +57,10 @@ v8::Local<v8::Object> CreateJSEvent(v8::Isolate* isolate,
} else {
event = CreateEventObject(isolate);
}
mate::Dictionary(isolate, event).Set("sender", object);
mate::Dictionary dict(isolate, event);
dict.Set("sender", object);
if (sender)
dict.Set("frameId", sender->GetRoutingID());
return event;
}

View File

@@ -8,6 +8,7 @@
#include <vector>
#include "atom/common/api/event_emitter_caller.h"
#include "content/public/browser/browser_thread.h"
#include "native_mate/wrappable.h"
namespace content {
@@ -97,11 +98,13 @@ class EventEmitter : public Wrappable<T> {
bool EmitWithEvent(const base::StringPiece& name,
v8::Local<v8::Object> event,
const Args&... args) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
EmitEvent(isolate(), GetWrapper(), name, event, args...);
return event->Get(StringToV8(isolate(), "defaultPrevented"))
->BooleanValue();
->BooleanValue(isolate()->GetCurrentContext())
.ToChecked();
}
DISALLOW_COPY_AND_ASSIGN(EventEmitter);

View File

@@ -4,13 +4,12 @@
#include "atom/browser/api/frame_subscriber.h"
#include <utility>
#include "atom/common/native_mate_converters/gfx_converter.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
#include "components/viz/service/surfaces/surface_manager.h"
#include "content/browser/compositor/surface_utils.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "ui/gfx/skbitmap_operations.h"
#include "atom/common/node_includes.h"
@@ -19,6 +18,8 @@ namespace atom {
namespace api {
constexpr static int kMaxFrameRate = 30;
FrameSubscriber::FrameSubscriber(v8::Isolate* isolate,
content::WebContents* web_contents,
const FrameCaptureCallback& callback,
@@ -27,48 +28,123 @@ FrameSubscriber::FrameSubscriber(v8::Isolate* isolate,
isolate_(isolate),
callback_(callback),
only_dirty_(only_dirty),
weak_ptr_factory_(this) {}
weak_ptr_factory_(this) {
content::RenderViewHost* rvh = web_contents->GetRenderViewHost();
if (rvh)
AttachToHost(rvh->GetWidget());
}
FrameSubscriber::~FrameSubscriber() = default;
gfx::Rect FrameSubscriber::GetDamageRect() {
auto* view = web_contents()->GetRenderWidgetHostView();
if (view == nullptr)
return gfx::Rect();
void FrameSubscriber::AttachToHost(content::RenderWidgetHost* host) {
host_ = host;
auto* view_base = static_cast<content::RenderWidgetHostViewBase*>(view);
viz::SurfaceManager* surface_manager =
content::GetFrameSinkManager()->surface_manager();
viz::Surface* surface =
surface_manager->GetSurfaceForId(view_base->GetCurrentSurfaceId());
if (surface == nullptr)
return gfx::Rect();
// The view can be null if the renderer process has crashed.
// (https://crbug.com/847363)
if (!host_->GetView())
return;
if (surface->HasActiveFrame()) {
const viz::CompositorFrame& frame = surface->GetActiveFrame();
viz::RenderPass* root_pass = frame.render_pass_list.back().get();
gfx::Size frame_size = root_pass->output_rect.size();
gfx::Rect damage_rect =
gfx::ToEnclosingRect(gfx::RectF(root_pass->damage_rect));
damage_rect.Intersect(gfx::Rect(frame_size));
return gfx::ScaleToEnclosedRect(damage_rect,
1.0f / frame.device_scale_factor());
} else {
return gfx::Rect();
// Create and configure the video capturer.
video_capturer_ = host_->GetView()->CreateVideoCapturer();
video_capturer_->SetResolutionConstraints(
host_->GetView()->GetViewBounds().size(),
host_->GetView()->GetViewBounds().size(), true);
video_capturer_->SetAutoThrottlingEnabled(false);
video_capturer_->SetMinSizeChangePeriod(base::TimeDelta());
video_capturer_->SetFormat(media::PIXEL_FORMAT_ARGB,
gfx::ColorSpace::CreateREC709());
video_capturer_->SetMinCapturePeriod(base::TimeDelta::FromSeconds(1) /
kMaxFrameRate);
video_capturer_->Start(this);
}
void FrameSubscriber::DetachFromHost() {
if (!host_)
return;
video_capturer_.reset();
host_ = nullptr;
}
void FrameSubscriber::RenderViewCreated(content::RenderViewHost* host) {
if (!host_)
AttachToHost(host->GetWidget());
}
void FrameSubscriber::RenderViewDeleted(content::RenderViewHost* host) {
if (host->GetWidget() == host_) {
DetachFromHost();
}
}
void FrameSubscriber::DidReceiveCompositorFrame() {
auto* view = web_contents()->GetRenderWidgetHostView();
if (view == nullptr)
return;
view->CopyFromSurface(
gfx::Rect(), view->GetViewBounds().size(),
base::BindOnce(&FrameSubscriber::Done, weak_ptr_factory_.GetWeakPtr(),
GetDamageRect()));
void FrameSubscriber::RenderViewHostChanged(content::RenderViewHost* old_host,
content::RenderViewHost* new_host) {
if ((old_host && old_host->GetWidget() == host_) || (!old_host && !host_)) {
DetachFromHost();
AttachToHost(new_host->GetWidget());
}
}
void FrameSubscriber::OnFrameCaptured(
base::ReadOnlySharedMemoryRegion data,
::media::mojom::VideoFrameInfoPtr info,
const gfx::Rect& update_rect,
const gfx::Rect& content_rect,
viz::mojom::FrameSinkVideoConsumerFrameCallbacksPtr callbacks) {
gfx::Size view_size = host_->GetView()->GetViewBounds().size();
if (view_size != content_rect.size()) {
video_capturer_->SetResolutionConstraints(view_size, view_size, true);
video_capturer_->RequestRefreshFrame();
return;
}
if (!data.IsValid()) {
callbacks->Done();
return;
}
base::ReadOnlySharedMemoryMapping mapping = data.Map();
if (!mapping.IsValid()) {
DLOG(ERROR) << "Shared memory mapping failed.";
return;
}
if (mapping.size() <
media::VideoFrame::AllocationSize(info->pixel_format, info->coded_size)) {
DLOG(ERROR) << "Shared memory size was less than expected.";
return;
}
// The SkBitmap's pixels will be marked as immutable, but the installPixels()
// API requires a non-const pointer. So, cast away the const.
void* const pixels = const_cast<void*>(mapping.memory());
// Call installPixels() with a |releaseProc| that: 1) notifies the capturer
// that this consumer has finished with the frame, and 2) releases the shared
// memory mapping.
struct FramePinner {
// Keeps the shared memory that backs |frame_| mapped.
base::ReadOnlySharedMemoryMapping mapping;
// Prevents FrameSinkVideoCapturer from recycling the shared memory that
// backs |frame_|.
viz::mojom::FrameSinkVideoConsumerFrameCallbacksPtr releaser;
};
SkBitmap bitmap;
bitmap.installPixels(
SkImageInfo::MakeN32(content_rect.width(), content_rect.height(),
kPremul_SkAlphaType),
pixels,
media::VideoFrame::RowBytes(media::VideoFrame::kARGBPlane,
info->pixel_format, info->coded_size.width()),
[](void* addr, void* context) {
delete static_cast<FramePinner*>(context);
},
new FramePinner{std::move(mapping), std::move(callbacks)});
bitmap.setImmutable();
Done(content_rect, bitmap);
}
void FrameSubscriber::OnStopped() {}
void FrameSubscriber::Done(const gfx::Rect& damage, const SkBitmap& frame) {
if (frame.drawsNothing())
return;

View File

@@ -5,13 +5,13 @@
#ifndef ATOM_BROWSER_API_FRAME_SUBSCRIBER_H_
#define ATOM_BROWSER_API_FRAME_SUBSCRIBER_H_
#include "content/public/browser/web_contents.h"
#include <memory>
#include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "components/viz/common/frame_sinks/copy_output_result.h"
#include "components/viz/host/client_frame_sink_video_capturer.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "ui/gfx/image/image.h"
#include "v8/include/v8.h"
namespace atom {
@@ -20,7 +20,8 @@ namespace api {
class WebContents;
class FrameSubscriber : public content::WebContentsObserver {
class FrameSubscriber : public content::WebContentsObserver,
public viz::mojom::FrameSinkVideoConsumer {
public:
using FrameCaptureCallback =
base::Callback<void(v8::Local<v8::Value>, v8::Local<v8::Value>)>;
@@ -32,14 +33,32 @@ class FrameSubscriber : public content::WebContentsObserver {
~FrameSubscriber() override;
private:
gfx::Rect GetDamageRect();
void DidReceiveCompositorFrame() override;
void AttachToHost(content::RenderWidgetHost* host);
void DetachFromHost();
void RenderViewCreated(content::RenderViewHost* host) override;
void RenderViewDeleted(content::RenderViewHost* host) override;
void RenderViewHostChanged(content::RenderViewHost* old_host,
content::RenderViewHost* new_host) override;
// viz::mojom::FrameSinkVideoConsumer implementation.
void OnFrameCaptured(
base::ReadOnlySharedMemoryRegion data,
::media::mojom::VideoFrameInfoPtr info,
const gfx::Rect& update_rect,
const gfx::Rect& content_rect,
viz::mojom::FrameSinkVideoConsumerFrameCallbacksPtr callbacks) override;
void OnStopped() override;
void Done(const gfx::Rect& damage, const SkBitmap& frame);
v8::Isolate* isolate_;
FrameCaptureCallback callback_;
bool only_dirty_;
content::RenderWidgetHost* host_;
std::unique_ptr<viz::ClientFrameSinkVideoCapturer> video_capturer_;
base::WeakPtrFactory<FrameSubscriber> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(FrameSubscriber);

View File

@@ -107,6 +107,18 @@ void GPUInfoEnumerator::EndOverlayCapability() {
value_stack.pop();
}
void GPUInfoEnumerator::BeginDx12VulkanVersionInfo() {
value_stack.push(std::move(current));
current = std::make_unique<base::DictionaryValue>();
}
void GPUInfoEnumerator::EndDx12VulkanVersionInfo() {
auto& top_value = value_stack.top();
top_value->SetDictionary(kDx12VulkanVersionInfoKey, std::move(current));
current = std::move(top_value);
value_stack.pop();
}
std::unique_ptr<base::DictionaryValue> GPUInfoEnumerator::GetDictionary() {
return std::move(current);
}

View File

@@ -24,6 +24,7 @@ class GPUInfoEnumerator final : public gpu::GPUInfo::Enumerator {
"videoEncodeAcceleratorSupportedProfile";
const char* kAuxAttributesKey = "auxAttributes";
const char* kOverlayCapabilityKey = "overlayCapability";
const char* kDx12VulkanVersionInfoKey = "dx12VulkanVersionInfo";
public:
GPUInfoEnumerator();
@@ -44,6 +45,8 @@ class GPUInfoEnumerator final : public gpu::GPUInfo::Enumerator {
void EndAuxAttributes() override;
void BeginOverlayCapability() override;
void EndOverlayCapability() override;
void BeginDx12VulkanVersionInfo() override;
void EndDx12VulkanVersionInfo() override;
std::unique_ptr<base::DictionaryValue> GetDictionary();
private:

View File

@@ -3,6 +3,9 @@
// found in the LICENSE file.
#include "atom/browser/api/gpuinfo_manager.h"
#include <utility>
#include "atom/browser/api/gpu_info_enumerator.h"
#include "base/memory/singleton.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -26,11 +29,12 @@ GPUInfoManager::~GPUInfoManager() {
// Based on
// https://chromium.googlesource.com/chromium/src.git/+/69.0.3497.106/content/browser/gpu/gpu_data_manager_impl_private.cc#838
bool GPUInfoManager::NeedsCompleteGpuInfoCollection() {
#if defined(OS_WIN)
const auto& gpu_info = gpu_data_manager_->GetGPUInfo();
return (gpu_info.dx_diagnostics.values.empty() &&
gpu_info.dx_diagnostics.children.empty());
bool GPUInfoManager::NeedsCompleteGpuInfoCollection() const {
#if defined(OS_MACOSX)
return gpu_data_manager_->GetGPUInfo().gl_vendor.empty();
#elif defined(OS_WIN)
return (gpu_data_manager_->GetGPUInfo().dx_diagnostics.values.empty() &&
gpu_data_manager_->GetGPUInfo().dx_diagnostics.children.empty());
#else
return false;
#endif
@@ -41,8 +45,8 @@ void GPUInfoManager::ProcessCompleteInfo() {
const auto result = EnumerateGPUInfo(gpu_data_manager_->GetGPUInfo());
// We have received the complete information, resolve all promises that
// were waiting for this info.
for (const auto& promise : complete_info_promise_set_) {
promise->Resolve(*result);
for (auto& promise : complete_info_promise_set_) {
promise.Resolve(*result);
}
complete_info_promise_set_.clear();
}
@@ -57,8 +61,8 @@ void GPUInfoManager::OnGpuInfoUpdate() {
}
// Should be posted to the task runner
void GPUInfoManager::CompleteInfoFetcher(scoped_refptr<util::Promise> promise) {
complete_info_promise_set_.push_back(promise);
void GPUInfoManager::CompleteInfoFetcher(util::Promise promise) {
complete_info_promise_set_.emplace_back(std::move(promise));
if (NeedsCompleteGpuInfoCollection()) {
gpu_data_manager_->RequestCompleteGpuInfoIfNeeded();
@@ -67,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(
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.
// 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;
CollectBasicGraphicsInfo(&gpu_info);
promise->Resolve(*EnumerateGPUInfo(gpu_info));
promise.Resolve(*EnumerateGPUInfo(gpu_info));
}
std::unique_ptr<base::DictionaryValue> GPUInfoManager::EnumerateGPUInfo(

View File

@@ -24,9 +24,9 @@ class GPUInfoManager : public content::GpuDataManagerObserver {
GPUInfoManager();
~GPUInfoManager() override;
bool NeedsCompleteGpuInfoCollection();
void FetchCompleteInfo(scoped_refptr<util::Promise> promise);
void FetchBasicInfo(scoped_refptr<util::Promise> promise);
bool NeedsCompleteGpuInfoCollection() const;
void FetchCompleteInfo(util::Promise promise);
void FetchBasicInfo(util::Promise promise);
void OnGpuInfoUpdate() override;
private:
@@ -34,12 +34,12 @@ class GPUInfoManager : public content::GpuDataManagerObserver {
gpu::GPUInfo gpu_info) const;
// These should be posted to the task queue
void CompleteInfoFetcher(scoped_refptr<util::Promise> promise);
void CompleteInfoFetcher(util::Promise promise);
void ProcessCompleteInfo();
// This set maintains all the promises that should be fulfilled
// 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_;
DISALLOW_COPY_AND_ASSIGN(GPUInfoManager);

View File

@@ -57,7 +57,9 @@ void SavePageHandler::OnDownloadUpdated(download::DownloadItem* item) {
callback_.Run(v8::Null(isolate));
} else {
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));
}
Destroy(item);

View File

@@ -9,6 +9,8 @@
#include "atom/browser/net/url_request_stream_job.h"
#include "atom/common/api/event_emitter_caller.h"
#include "atom/common/native_mate_converters/callback.h"
#include "base/task/post_task.h"
#include "content/public/browser/browser_task_traits.h"
#include "atom/common/node_includes.h"
@@ -17,12 +19,15 @@ namespace mate {
StreamSubscriber::StreamSubscriber(
v8::Isolate* isolate,
v8::Local<v8::Object> emitter,
base::WeakPtr<atom::URLRequestStreamJob> url_job)
: isolate_(isolate),
base::WeakPtr<atom::URLRequestStreamJob> url_job,
scoped_refptr<base::SequencedTaskRunner> ui_task_runner)
: base::RefCountedDeleteOnSequence<StreamSubscriber>(ui_task_runner),
isolate_(isolate),
emitter_(isolate, emitter),
url_job_(url_job),
weak_factory_(this) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(ui_task_runner->RunsTasksInCurrentSequence());
auto weak_self = weak_factory_.GetWeakPtr();
On("data", base::Bind(&StreamSubscriber::OnData, weak_self));
On("end", base::Bind(&StreamSubscriber::OnEnd, weak_self));
@@ -30,13 +35,12 @@ StreamSubscriber::StreamSubscriber(
}
StreamSubscriber::~StreamSubscriber() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
RemoveAllListeners();
}
void StreamSubscriber::On(const std::string& event,
EventCallback&& callback) { // NOLINT
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(owning_task_runner()->RunsTasksInCurrentSequence());
DCHECK(js_handlers_.find(event) == js_handlers_.end());
v8::Locker locker(isolate_);
@@ -50,7 +54,7 @@ void StreamSubscriber::On(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());
v8::Locker locker(isolate_);
@@ -76,26 +80,25 @@ void StreamSubscriber::OnData(mate::Arguments* args) {
// Pass the data to the URLJob in IO thread.
std::vector<char> buffer(data, data + length);
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::Bind(&atom::URLRequestStreamJob::OnData, url_job_,
base::Passed(&buffer)));
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
base::Bind(&atom::URLRequestStreamJob::OnData,
url_job_, base::Passed(&buffer)));
}
void StreamSubscriber::OnEnd(mate::Arguments* args) {
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::Bind(&atom::URLRequestStreamJob::OnEnd, url_job_));
}
void StreamSubscriber::OnError(mate::Arguments* args) {
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::Bind(&atom::URLRequestStreamJob::OnError, url_job_,
net::ERR_FAILED));
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
base::Bind(&atom::URLRequestStreamJob::OnError,
url_job_, net::ERR_FAILED));
}
void StreamSubscriber::RemoveAllListeners() {
DCHECK(owning_task_runner()->RunsTasksInCurrentSequence());
v8::Locker locker(isolate_);
v8::Isolate::Scope isolate_scope(isolate_);
v8::HandleScope handle_scope(isolate_);

View File

@@ -11,6 +11,8 @@
#include <vector>
#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 "content/public/browser/browser_thread.h"
#include "v8/include/v8.h"
@@ -23,17 +25,25 @@ namespace mate {
class Arguments;
class StreamSubscriber {
class StreamSubscriber
: public base::RefCountedDeleteOnSequence<StreamSubscriber> {
public:
REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE();
StreamSubscriber(v8::Isolate* isolate,
v8::Local<v8::Object> emitter,
base::WeakPtr<atom::URLRequestStreamJob> url_job);
~StreamSubscriber();
base::WeakPtr<atom::URLRequestStreamJob> url_job,
scoped_refptr<base::SequencedTaskRunner> ui_task_runner);
private:
friend class base::DeleteHelper<StreamSubscriber>;
friend class base::RefCountedDeleteOnSequence<StreamSubscriber>;
using JSHandlersMap = std::map<std::string, v8::Global<v8::Value>>;
using EventCallback = base::Callback<void(mate::Arguments* args)>;
~StreamSubscriber();
void On(const std::string& event, EventCallback&& callback); // NOLINT
void Off(const std::string& event);

View File

@@ -84,4 +84,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_box_layout, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_box_layout, Initialize)

View File

@@ -13,8 +13,10 @@ namespace atom {
namespace api {
Button::Button(views::Button* button) : View(button) {
Button::Button(views::Button* impl) : View(impl) {
view()->set_owned_by_client();
// Make the button focusable as per the platform.
button()->SetFocusForPlatform();
}
Button::~Button() {}
@@ -55,4 +57,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_button, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_button, Initialize)

View File

@@ -27,6 +27,8 @@ class Button : public View, public views::ButtonListener {
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
views::Button* button() const { return static_cast<views::Button*>(view()); }
private:
DISALLOW_COPY_AND_ASSIGN(Button);
};

View File

@@ -7,7 +7,6 @@
#include "atom/common/api/constructor.h"
#include "base/strings/utf_string_conversions.h"
#include "native_mate/dictionary.h"
#include "ui/views/controls/button/label_button.h"
#include "atom/common/node_includes.h"
@@ -15,11 +14,29 @@ namespace atom {
namespace api {
LabelButton::LabelButton(views::LabelButton* impl) : Button(impl) {}
LabelButton::LabelButton(const std::string& text)
: Button(new views::LabelButton(this, base::UTF8ToUTF16(text))) {}
LabelButton::~LabelButton() {}
const base::string16& LabelButton::GetText() const {
return label_button()->GetText();
}
void LabelButton::SetText(const base::string16& text) {
label_button()->SetText(text);
}
bool LabelButton::IsDefault() const {
return label_button()->is_default();
}
void LabelButton::SetIsDefault(bool is_default) {
label_button()->SetIsDefault(is_default);
}
// static
mate::WrappableBase* LabelButton::New(mate::Arguments* args,
const std::string& text) {
@@ -33,6 +50,11 @@ mate::WrappableBase* LabelButton::New(mate::Arguments* args,
void LabelButton::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "LabelButton"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.SetMethod("getText", &LabelButton::GetText)
.SetMethod("setText", &LabelButton::SetText)
.SetMethod("isDefault", &LabelButton::IsDefault)
.SetMethod("setIsDefault", &LabelButton::SetIsDefault);
}
} // namespace api
@@ -55,4 +77,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_label_button, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_label_button, Initialize)

View File

@@ -8,6 +8,7 @@
#include <string>
#include "atom/browser/api/views/atom_api_button.h"
#include "ui/views/controls/button/label_button.h"
namespace atom {
@@ -21,10 +22,20 @@ class LabelButton : public Button {
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
const base::string16& GetText() const;
void SetText(const base::string16& text);
bool IsDefault() const;
void SetIsDefault(bool is_default);
protected:
explicit LabelButton(views::LabelButton* impl);
explicit LabelButton(const std::string& text);
~LabelButton() override;
views::LabelButton* label_button() const {
return static_cast<views::LabelButton*>(view());
}
private:
DISALLOW_COPY_AND_ASSIGN(LabelButton);
};

View File

@@ -60,4 +60,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_layout_manager, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_layout_manager, Initialize)

View File

@@ -0,0 +1,57 @@
// Copyright (c) 2018 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/browser/api/views/atom_api_md_text_button.h"
#include "atom/common/api/constructor.h"
#include "base/strings/utf_string_conversions.h"
#include "native_mate/dictionary.h"
#include "atom/common/node_includes.h"
namespace atom {
namespace api {
MdTextButton::MdTextButton(const std::string& text)
: LabelButton(views::MdTextButton::Create(this, base::UTF8ToUTF16(text))) {}
MdTextButton::~MdTextButton() {}
// static
mate::WrappableBase* MdTextButton::New(mate::Arguments* args,
const std::string& text) {
// Constructor call.
auto* view = new MdTextButton(text);
view->InitWith(args->isolate(), args->GetThis());
return view;
}
// static
void MdTextButton::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "MdTextButton"));
}
} // namespace api
} // namespace atom
namespace {
using atom::api::MdTextButton;
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("MdTextButton", mate::CreateConstructor<MdTextButton>(
isolate, base::Bind(&MdTextButton::New)));
}
} // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_md_text_button, Initialize)

View File

@@ -0,0 +1,41 @@
// Copyright (c) 2018 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_API_VIEWS_ATOM_API_MD_TEXT_BUTTON_H_
#define ATOM_BROWSER_API_VIEWS_ATOM_API_MD_TEXT_BUTTON_H_
#include <string>
#include "atom/browser/api/views/atom_api_label_button.h"
#include "ui/views/controls/button/md_text_button.h"
namespace atom {
namespace api {
class MdTextButton : public LabelButton {
public:
static mate::WrappableBase* New(mate::Arguments* args,
const std::string& text);
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
protected:
explicit MdTextButton(const std::string& text);
~MdTextButton() override;
views::MdTextButton* md_text_button() const {
return static_cast<views::MdTextButton*>(view());
}
private:
DISALLOW_COPY_AND_ASSIGN(MdTextButton);
};
} // namespace api
} // namespace atom
#endif // ATOM_BROWSER_API_VIEWS_ATOM_API_MD_TEXT_BUTTON_H_

View File

@@ -0,0 +1,60 @@
// Copyright (c) 2018 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/browser/api/views/atom_api_resize_area.h"
#include "atom/common/api/constructor.h"
#include "native_mate/dictionary.h"
#include "atom/common/node_includes.h"
namespace atom {
namespace api {
ResizeArea::ResizeArea() : View(new views::ResizeArea(this)) {
view()->set_owned_by_client();
}
ResizeArea::~ResizeArea() {}
void ResizeArea::OnResize(int resize_amount, bool done_resizing) {
Emit("resize", resize_amount, done_resizing);
}
// static
mate::WrappableBase* ResizeArea::New(mate::Arguments* args) {
// Constructor call.
auto* view = new ResizeArea();
view->InitWith(args->isolate(), args->GetThis());
return view;
}
// static
void ResizeArea::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "ResizeArea"));
}
} // namespace api
} // namespace atom
namespace {
using atom::api::ResizeArea;
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("ResizeArea", mate::CreateConstructor<ResizeArea>(
isolate, base::Bind(&ResizeArea::New)));
}
} // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_resize_area, Initialize)

Some files were not shown because too many files have changed in this diff Show More