Compare commits

...

1320 Commits

Author SHA1 Message Date
Electron Bot
cb9b288d8b Bump v6.0.0-beta.12 2019-07-03 14:08:45 -07:00
Shelley Vohr
69fe33a2b1 Revert "Bump v6.0.0-beta.12"
This reverts commit 8a285f29ed.
2019-07-03 14:06:12 -07:00
Electron Bot
52b42546ed chore: bump chromium in DEPS to 76.0.3809.54 (#19095) 2019-07-03 08:36:42 -07:00
Electron Bot
8a285f29ed Bump v6.0.0-beta.12 2019-07-02 11:25:31 -07:00
Shelley Vohr
92df6cc36c fix: only check darkMode effectiveAppearance in 10.15 (#19013) 2019-07-02 11:04:30 -07:00
Electron Bot
ab91656148 chore: bump chromium in DEPS to 76.0.3809.52 (#19079) 2019-07-02 10:44:16 -07:00
Electron Bot
1fb1e5b2b2 Revert "Bump v6.0.0-beta.12"
This reverts commit 54908b56e5.
2019-07-02 10:17:31 -07:00
Electron Bot
54908b56e5 Bump v6.0.0-beta.12 2019-07-02 10:11:38 -07:00
Shelley Vohr
48bc247ef7 fix: silent printing mode (#19037) 2019-07-02 10:03:00 -07:00
trop[bot]
19d9955125 fix: Correct modal focus behavior on macOS (#19062)
* 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 🚨
2019-07-01 16:39:45 -07:00
Electron Bot
24d79d9e5c chore: bump chromium in DEPS to 76.0.3809.51 (#19057) 2019-07-01 12:14:15 -07:00
Electron Bot
27d0a4d33d chore: bump chromium in DEPS to 76.0.3809.50 (#19054) 2019-06-30 21:38:51 -07:00
Electron Bot
48226f71ad chore: bump chromium to 76.0.3809.49 (6-0-x) (#19030)
* chore: bump chromium in DEPS to 76.0.3809.48

* chore: bump chromium in DEPS to 76.0.3809.49
2019-06-29 18:46:41 -07:00
Shelley Vohr
a4acc16e10 fix: make tray not block main process (#18880) (#18969)
* fix: make tray not block main process

* make AtomMenuModel refcounted
2019-06-28 14:10:45 -05:00
trop[bot]
d8dd94e3a3 fix: delay emitting screen events by a tick to avoid re-entrancy crash (#19022) 2019-06-28 16:23:19 +09:00
Electron Bot
eb48dcf0a3 chore: bump chromium in DEPS to 76.0.3809.47 (#19010) 2019-06-27 16:34:00 -07:00
Samuel Attard
adfe537e32 docs: fix heading level for power-monitor docs (#19015) 2019-06-27 13:21:09 -07:00
Electron Bot
0d5d54cbae chore: bump chromium in DEPS to 76.0.3809.45 (#18991) 2019-06-26 08:47:25 -07:00
Electron Bot
988ad92415 chore: bump chromium in DEPS to 76.0.3809.43 (#18974) 2019-06-25 23:57:02 -07:00
Electron Bot
5dbcdbc3d8 Bump v6.0.0-beta.11 2019-06-25 14:13:13 -07:00
trop[bot]
212c6b1266 fix: override the timers module impls to activate the uv loop (#18961) 2019-06-24 14:22:57 -07:00
trop[bot]
74b06ab677 fix: make isDarkMode correctly detect dark mode in the auto setting on catalina (#18958) 2019-06-24 13:27:35 -07:00
Electron Bot
9a1c952ab6 chore: bump chromium to 76.0.3809.42 (6-0-x) (#18919)
* chore: bump chromium in DEPS to 76.0.3809.38

* chore: bump chromium in DEPS to 76.0.3809.39

* chore: bump chromium in DEPS to 76.0.3809.40

* chore: bump chromium in DEPS to 76.0.3809.42
2019-06-24 15:15:27 -04:00
Electron Bot
f36f90b60f Bump v6.0.0-beta.10 2019-06-21 15:05:57 -07:00
Micha Hanselmann
a603a4dde8 fix: sanitize invalid custom protocol headers (#18927)
* fix: sanitize invalid custom protocol headers (#18854)

* lint fix
2019-06-21 15:00:05 -07:00
trop[bot]
3e033b4f27 chore: account for remotes in branch parsing (#18931) 2019-06-21 14:03:40 -07:00
trop[bot]
03be4c67d5 fix: delay handling occlusion events to avoid flicker on macOS (#18885)
* chore: add debounce on the updateWebContentsVisibility method to ensure quick changes in occlusion do not result in flickering

* chore: update old patch headers

* chore: update patches for E6 without host refactor
2019-06-21 09:20:08 -07:00
John Kleinschmidt
b20fe76db7 chore: use manual invocation of npx yarn (#18902)
* 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
2019-06-21 08:57:05 -07:00
trop[bot]
503da640f7 fix: app.getAppPath() returning default-app path for files or directories without package.json (#18888) 2019-06-21 08:54:21 -07:00
trop[bot]
bd48dfe3cc chore: fix branch trimming for blast-off releases (#18909) 2019-06-21 01:02:54 -07:00
Jeremy Apthorp
9b47f587a6 fix: bundle swiftshader and ANGLE libraries on mac (#18904) 2019-06-20 11:12:02 -07:00
trop[bot]
3a186dad5d refactor: session.{clearCache,getCacheSize} nws13n (#18897) 2019-06-20 10:11:13 -07:00
Electron Bot
7959f2e887 chore: bump chromium to 76.0.3809.37 (6-0-x) (#18828)
* chore: bump chromium in DEPS to 76.0.3809.32

* chore: bump chromium in DEPS to 76.0.3809.33

* chore: update patches

* chore: bump chromium in DEPS to 76.0.3809.37

* chore: fix render_view_host_view_base.patch
2019-06-20 09:58:56 -07:00
trop[bot]
4868c95425 fix: building with enable_run_as_node disabled (#18892) 2019-06-19 23:48:04 -07:00
Samuel Attard
7fa41e3302 chore: roll node to fix http2 memory leak (#18882) 2019-06-19 12:33:05 -07:00
Electron Bot
f3346437be Bump v6.0.0-beta.9 2019-06-18 13:21:18 -07:00
Shelley Vohr
6de6d7f6c0 docs: add example on handling the webPrefs change (#18856)
* docs: add example on handling the webPrefs change

Fixes #17967

* Update breaking-changes.md
2019-06-18 10:35:27 -07:00
Shelley Vohr
eb15be06e3 fix: use is_valid for cookie url validation (#18770) (#18843)
Use is_valid instead of is_empty to validate url on cookies.set().
2019-06-18 09:53:10 -07:00
trop[bot]
7748decc60 chore: fix current branch fetch on master (#18862) 2019-06-18 08:34:50 -07:00
Shelley Vohr
d75750ab01 fix: use effectiveAppearance to check dark mode on mojave and above (#18666) (#18845)
* fix: use effectiveAppearance to check dark mode on mojave and above

* chore: add forward declarations for dark appearance
2019-06-17 15:54:31 -07:00
Shelley Vohr
152781226e fix: callback values for printing cancellation and success (#18803) 2019-06-17 11:33:30 -07:00
trop[bot]
7e3bbb6ace build: get current release branch from commit (#18833)
* chore: get current release branch from commit

* love too lint
2019-06-17 07:54:17 -07:00
Shelley Vohr
3c3eb2f65d docs: better explain supported release line levels (#18800) (#18838) 2019-06-17 07:53:24 -07:00
trop[bot]
5a83d9e64d feat: provide the frame URL with permission requests and checks (#18772)
* 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

* chore: fix lint
2019-06-15 16:26:21 +09:00
trop[bot]
97bec607fe build: use yarn to install arm modules (#18802) 2019-06-15 16:16:13 +09:00
trop[bot]
b56ca98b72 docs: add specific options for MenuItem.role (#18807) 2019-06-14 23:29:34 -07:00
Electron Bot
eeccdc2d5c Bump v6.0.0-beta.8 2019-06-14 09:22:25 -07:00
Milan Burda
47827ed45c fix: crash in BrowserWindow destructor after win.webContents.destroy() (#18686) (#18793) 2019-06-14 09:18:38 -07:00
Cheng Zhao
d3f7bdd0b3 fix: use crashpad on Windows (#18483) (#18766) 2019-06-13 18:51:56 -07:00
trop[bot]
438c50bf14 docs: fully document MenuItem instance properties (#18784)
* document menuItem instance properties

* correct some types

* add correct click documentation
2019-06-13 18:45:05 -07:00
trop[bot]
33d860bcea fix: reject the executeJavaScript promise when it fails to execute the script (#18714)
* fix: reject the executeJavaScript promise when it fails to execute the script

Closes #9102

* Update atom/renderer/api/atom_api_web_frame.cc

Co-Authored-By: Jeremy Apthorp <nornagon@nornagon.net>

* Update atom/renderer/api/atom_api_web_frame.cc

Co-Authored-By: Jeremy Apthorp <nornagon@nornagon.net>

* fix: missing semicolon
2019-06-13 16:13:06 -07:00
trop[bot]
2401a2afe9 fix: HTML fullscreen request for sub frames (#18775)
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 15:23:43 -07:00
Electron Bot
852f0be0b2 chore: bump chromium in DEPS to 76.0.3809.26 (#18768) 2019-06-13 13:47:13 -07:00
Samuel Attard
18ec438eaf feat: Add option to conditionally disable site instance patches (#18554)
* feat: Add option to conditionally disable site instance patches (#18396)

* chore: allow conditional disable of the site instance override patches at runtime

* feat: add app.allowRendererProcessReuse property to allow runtime disable of site instance overrides

spec: add tests for the new allowRendererProcessReuse property

feat: add console warnings / errors for loading non context-aware native modules
  * Only error if the patch is disabled
  * Warn all the time, this will ship in Electron 7

* chore: do not warn in about context aware in v6

* chore: update patches
2019-06-13 10:23:02 -07:00
trop[bot]
f7042c8d1b fix: correct isDownloadable docs to match impl (#18747) 2019-06-12 14:16:50 -07:00
Electron Bot
bc73f93e6c chore: bump chromium in DEPS to 76.0.3809.23 (#18742) 2019-06-12 13:21:35 -07:00
trop[bot]
7091508678 fix: remove lingering data when notifications autodismiss on Windows 7 (#18740) 2019-06-12 21:43:30 +09:00
Alexandre Lacheze
6d9d66b88a fix: lost window.opener after cross-origin navigation (#18624)
* SiteInstance::CreateRelatedSiteInstance and use it

* Introduce and use a NetworkSandbox and introduce a test for window.opener on x-site navigation
2019-06-11 14:34:52 -07:00
Electron Bot
fc35b0f1be Bump v6.0.0-beta.7 2019-06-11 12:59:05 -07:00
Electron Bot
17f86b1223 chore: bump chromium in DEPS to 76.0.3809.22 (#18730) 2019-06-11 10:25:24 -07:00
Samuel Attard
271531f5ff fix: modify new promise object for dialog methods to match old callback api (#18724)
This was an unexpected and undocumented breaking change, the deprecated
callback method should have the same signature it used to have.
2019-06-11 10:24:36 -07:00
Jeremy Spiegel
9ef83cd8a0 fix: properly pass openExternal activate option (#18722)
A reference to an OpenExternalOptions structure was being captured by an Objective-C block that
outlived the object that was being referenced.
2019-06-11 10:23:48 -07:00
trop[bot]
f33517dfa7 chore: fix logging to stderr (#18717) 2019-06-10 15:34:18 -07:00
Electron Bot
c69f5d9366 chore: bump chromium to 76.0.3809.20 (6-0-x) (#18684) 2019-06-10 11:42:32 -07:00
Milan Burda
7902c3ced4 fix: set nativeWindowOpen when sandboxed (#18273) (#18556) 2019-06-07 19:08:16 -07:00
trop[bot]
21f033474d fix: use isEqual instead of pointer equality to convert NSAppearance (#18690) 2019-06-07 11:32:25 -07:00
Electron Bot
549ac1ed48 chore: bump chromium in DEPS to 76.0.3809.13 (#18669) 2019-06-06 12:57:19 -07:00
Electron Bot
2dd8d1f150 chore: bump chromium in DEPS to 76.0.3809.12 (#18662) 2019-06-05 19:33:58 -07:00
Electron Bot
26ee461c32 chore: bump chromium in DEPS to 76.0.3809.10 (#18647) 2019-06-05 15:40:41 -07:00
trop[bot]
9905a4c328 ci: fix issues downloading from CircleCI (#18654)
Make sure we pass along token to download from CircleCI
Also, add back off period for retries on downloads.
2019-06-05 10:54:58 -07:00
Richard Townsend
09a22143d6 build: bring in a later compiler for Windows on Arm (#18625)
* build: allow pulling in a later version of Clang

Due to a code-generation defect related to virtual method thunks in the
official compiler used for Chromium M76, it's necessary to build for WoA
with a later version of Clang. When running gclient sync, setting
ELECTRON_BUILD_WOA=1 in the environment will download a corrected
compiler which doesn't have this defect.

* docs: add a note about building for Windows on Arm
2019-06-05 11:18:44 -04:00
Electron Bot
81e8f5c6c2 chore: bump chromium to 76.0.3809.6 (6-0-x) (#18573)
* chore: bump chromium in DEPS to 76.0.3809.4

* chore: bump chromium in DEPS to 76.0.3809.5

* chore: bump chromium in DEPS to 76.0.3809.6
2019-06-04 15:52:34 -07:00
Electron Bot
3c322b7349 Bump v6.0.0-beta.6 2019-06-04 14:52:22 -07:00
Milan Burda
b2ea1bc517 fix: don't export private V8 symbols that can cause native node modules to crash (#18281) (#18619) 2019-06-04 10:09:07 -05:00
trop[bot]
16250493b8 build: move Windows release builds to AppVeyor cloud (#18603)
* build: move Windows release builds to AppVeyor cloud

* Use new env variable for AppVeyor cloud server
2019-06-04 10:30:31 -04:00
trop[bot]
08887e016c doc: change pyobjc link in macos build instruction (#18616) 2019-06-03 22:03:06 -07:00
trop[bot]
aadcce0907 docs: Fix incorrect dialog docs (#18606)
* docs: Fix incorrect dialog docs

We had multiple definitions for `showSaveDialog`.

* docs: Update, take two
2019-06-03 15:04:26 -07:00
trop[bot]
9b5353309d build: strip swiftshader binaries (#18600) 2019-06-03 14:32:18 -07:00
trop[bot]
76303502a6 build: install python-dbusmock via pip for a Docker container (#18597)
* 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-03 17:20:55 -04:00
Milan Burda
cf07904338 build: remove Vulkan mock ICD (#18596) 2019-06-03 17:18:33 -04:00
trop[bot]
8f1e28b59c fix: don't package mojom{,-lite}.js files in dist.zip (#18486) 2019-06-03 11:44:30 -07:00
Electron Bot
10d0268070 chore: bump chromium to 76.0.3809.3 (6-0-x) (#18504)
* chore: bump chromium in DEPS to 76.0.3807.2

* chore: update patches

* fix: Don't leak system network context when nw service is disabled

https://chromium-review.googlesource.com/c/chromium/src/+/1632494
NetworkService is now deleted by using SequnceLocalStorageSlot
on the IO thread when the service is disabled, which expects
all associated NetworkContexts on that sequence to be destroyed.

* chore: bump chromium in DEPS to 76.0.3808.1

* fix: Destroy all network contexts before primary network context

* chore: update patches

* Simplify out-of-process service registration

https://chromium-review.googlesource.com/c/chromium/src/+/1615882

* [ThreadPool] Rename base::ThreadPool to base::ThreadPoolInstance

https://chromium-review.googlesource.com/c/chromium/src/+/1634851

* fix: -Winconsistent-missing-override warnings

* chore: bump chromium in DEPS to 76.0.3809.1

* chore: update patches

* Change CreateBrowserMainParts to return unique_ptrs

https://chromium-review.googlesource.com/c/chromium/src/+/1632532

* chore: bump chromium in DEPS to 76.0.3809.3
2019-06-01 13:19:00 -04:00
trop[bot]
7871e18232 fix: handle gzipped chrome WebUI resources (#18552)
Fixes: #18503
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1576232

For whatever reason Chromium made this change and then made the default
//content behavior to return false for all IsDataResourceGzipped
requests.  This PR updates our ContentClient impl to return the correct
values.

Notes: Fixed issues where some `chrome://*` URLs would not render
correctly
2019-05-31 15:47:42 -07:00
trop[bot]
ceb3792f3c fix: contractions handling in spellchecker (#18538) 2019-05-31 10:52:18 -07:00
trop[bot]
65a4bdd87a ci: add retries to downloads for arm testing (#18535) 2019-05-30 21:08:44 -07:00
trop[bot]
7094870a44 docs: specify use case for the 'services' role (#18528)
* 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:16 -07:00
trop[bot]
cee99b5f2d fix: reverse dialog cancel bool for openDialog (#18509) 2019-05-30 15:32:08 -04:00
Electron Bot
ac86d362ba Bump v6.0.0-beta.5 2019-05-29 08:10:59 -07:00
Shelley Vohr
2233a9eb5a Revert "Bump v6.0.0-beta.5"
This reverts commit 80fa2449a1.
2019-05-28 20:18:02 -07:00
Shelley Vohr
af24a4f364 build: fix breakpad symbol generation on linux arm (#18491) 2019-05-28 20:17:37 -07:00
trop[bot]
a78692f5b8 fix: create missing directories with app.setPath (#18480) 2019-05-28 19:30:49 -07:00
trop[bot]
335178098d fix: ensure the webContents is not destroyed before communicating (#18487) 2019-05-28 19:30:32 -07:00
trop[bot]
ddc0e8f7ba chore: remove leftover docs/api/structures/memory-info.md (#18430) 2019-05-28 14:20:46 -07:00
Electron Bot
80fa2449a1 Bump v6.0.0-beta.5 2019-05-28 13:31:35 -07:00
Shelley Vohr
476abafefe fix: respect minimizable/closable for customButtonsOnHover (#18478) 2019-05-28 13:29:43 -07:00
Felix Rieseberg
f7d4d51261 feat: Backport setting of global fallback user agent (#18473) 2019-05-28 12:25:07 -07:00
Electron Bot
7b08510075 chore: bump chromium to 76.0.3805.4 (6-0-x) (#18439)
* chore: bump chromium in DEPS to 76.0.3804.1

* chore: update patches

* chore: update v8 patches

* chore: bump chromium in DEPS to 76.0.3805.1

* chore: bump chromium in DEPS to 76.0.3805.2

* chore: bump chromium in DEPS to 76.0.3805.3

* chore: update patches

* Remove content_packaged_services

https://chromium-review.googlesource.com/c/chromium/src/+/1604203

* chore: fix false positive lint error

* views: wireup widget name to crash data

https://chromium-review.googlesource.com/c/chromium/src/+/1626640

* chore: bump chromium in DEPS to 76.0.3805.4
2019-05-28 11:29:10 -07:00
Jeremy Apthorp
14b62b28ce Merge pull request #18327 from electron/roller/chromium/6-0-x
chore: bump chromium to 76.0.3803.1 (6-0-x)
2019-05-23 17:08:56 -07:00
Jeremy Apthorp
1c44ed0912 Replace views_bridge_mac with remote_cocoa
https://chromium-review.googlesource.com/c/chromium/src/+/1623573
2019-05-23 15:00:02 -07:00
Jeremy Apthorp
de1edf3f4d Update function signatures for focused element change notifications
https://chromium-review.googlesource.com/c/chromium/src/+/1609749
2019-05-23 13:47:49 -07:00
deepak1556
a21ffa027a chore: update patches 2019-05-23 12:46:44 -07:00
Nitish Sakhawalkar
899d42563c Chrome changed the devtools url
chrome-devtools:// to devtools://
28b21a67f0
2019-05-23 12:36:16 -07:00
Electron Bot
6eecbb5edd chore: bump chromium in DEPS to 76.0.3803.1 2019-05-23 12:36:16 -07:00
Nitish Sakhawalkar
6a8e7a10ea Update views visible API
visible() -> GetVisible() as per c9ecec130e
2019-05-23 12:36:16 -07:00
Nitish Sakhawalkar
85bb488732 Update linux/win menu_bar.h
Chromium Commit 6a2f2686a9
2019-05-23 12:36:16 -07:00
Jeremy Apthorp
c957215854 pin user32 on startup
https://chromium-review.googlesource.com/c/chromium/src/+/1551709

Loading it later causes a blocking call where blocking calls aren't allowed.
2019-05-23 12:36:16 -07:00
Nitish Sakhawalkar
2ba3a26785 Disable custom libcxx patch 2019-05-23 12:36:16 -07:00
Jeremy Apthorp
f0dc3bc79f Manual follow-up rename in comments and variable names.
https://chromium-review.googlesource.com/c/chromium/src/+/1591429
2019-05-23 12:36:16 -07:00
Nitish Sakhawalkar
28d3edcd92 Update gpuinfo enumerator api
Related chromium change is here => 4178e190e9
2019-05-23 12:36:16 -07:00
Jeremy Apthorp
8026dee591 storage::IsolatedContext API changed
https://chromium-review.googlesource.com/c/chromium/src/+/1603486
2019-05-23 12:36:16 -07:00
Jeremy Apthorp
197cda9e45 GetNetCaptureModeFromCommandLine moved to net
https://chromium-review.googlesource.com/c/chromium/src/+/1614697
2019-05-23 12:36:16 -07:00
Jeremy Apthorp
903fd4e5e9 use base::Owned instead of base::Passed for repeating handler 2019-05-23 12:36:16 -07:00
Jeremy Apthorp
621c86b4cf Convert Callbacks to OnceCallbacks in permissions APIs.
https://chromium-review.googlesource.com/c/chromium/src/+/1592356
2019-05-23 12:36:16 -07:00
Nitish Sakhawalkar
deda7c700f Update for changed APIs
Update AllowCertificateError API (c5b8df91d1)
2019-05-23 12:36:15 -07:00
Jeremy Apthorp
d225304370 use unique_ptr instead of shared_ptr for SpellcheckRequest 2019-05-23 12:36:15 -07:00
Nitish Sakhawalkar
fd22b7ec2a Update Spellcheck API
Update WebTexhCheckingCompletion as per chromium 0e8c828e02
2019-05-23 12:36:15 -07:00
Nitish Sakhawalkar
a2b1d394b5 Update changed APIs/deps
Use brotli by default (36d58dd325)

Update Mac ui headers (897636c9f8)

Update AtomBrowserClient::HandleExternalProtocol API (cb656e1fd1)
2019-05-23 12:36:15 -07:00
Jeremy Apthorp
7d4c78e73e DelegatedFrameHost API changed
https://chromium-review.googlesource.com/c/chromium/src/+/1594924
2019-05-23 12:36:15 -07:00
Jeremy Apthorp
b37ff2b822 //ui/views_bridge_mac => //components/remote_cocoa/app_shim
https://chromium-review.googlesource.com/c/chromium/src/+/1590958
2019-05-23 12:36:15 -07:00
deepak1556
5887f5aa4f Move snapshot_toolchain.gni to gni/
https://chromium-review.googlesource.com/c/v8/v8/+/1612903
2019-05-23 12:36:15 -07:00
deepak1556
a9176a2ac8 chore: update patches 2019-05-23 12:36:15 -07:00
Electron Bot
6ceb431942 chore: bump chromium in DEPS to 76.0.3802.1 2019-05-23 12:36:15 -07:00
Electron Bot
508d131c95 chore: bump chromium in DEPS to 76.0.3801.1 2019-05-23 12:36:15 -07:00
Electron Bot
ae36659f7a chore: bump chromium in DEPS to 76.0.3800.1 2019-05-23 12:36:15 -07:00
Electron Bot
f970660766 chore: bump chromium in DEPS to 76.0.3799.1 2019-05-23 12:36:15 -07:00
Electron Bot
43c5837cda chore: bump chromium in DEPS to 76.0.3798.1 2019-05-23 12:36:15 -07:00
Electron Bot
a87e88df20 chore: bump chromium in DEPS to 76.0.3797.1 2019-05-23 12:36:15 -07:00
Electron Bot
5a5d4b06b3 chore: bump chromium in DEPS to 76.0.3796.1 2019-05-23 12:36:15 -07:00
trop[bot]
28ba88ba70 docs: rename 'API Contract' as 'Breaking Changes' (#18399)
* Use "Breaking Changes" as the changes doc's title.

Multiple people have commented that this important page is difficult
to find, in part because people search for "Breaking" or "Changes" or
"Breaking Changes" rather than "API Contract".

This PR changes the name to "Breaking Changes" so that it'll show up
on electronjs.org/docs/.

It also adds a backwards-friendly link so people still searching for
"API Contract" will get a redirect. I'm not sure if this is necessary --
the actual URL of https://electronjs.org/docs/api/breaking-changes is
unchanged -- would especially welcome feedback on this part.

* fixup! Use "Breaking Changes" as the changes doc's title.

* fixup! Use "Breaking Changes" as the changes doc's title.
2019-05-23 15:02:16 -04:00
trop[bot]
4f8ffe934e docs: clarify that 'second-instance' is only emitted when the second instance calls app.requestSingleInstanceLock() (#18385) 2019-05-21 16:25:50 -05:00
Electron Bot
c5c0a7abc5 Bump v6.0.0-beta.4 2019-05-21 11:28:46 -07:00
trop[bot]
84b762f0b3 fix: reverse saveDialog cancellation bool (#18383) 2019-05-21 13:09:35 -05:00
trop[bot]
043838f9b6 fix: set window to null when no window is passed (#18381)
Fixes #18236.

Our options parsing for dialogs correctly set options if no window was passed, but then did not correctly set the window back to null and it was then left as an object equal to options. This caused a crash when passed to native code as there is no valid circumstance where the window would be an object.
2019-05-21 08:34:40 -07:00
trop[bot]
a824e92628 fix: 'page-title-updated' event forwarding + documentation (#18319) 2019-05-21 16:21:50 +09:00
Samuel Attard
1843411e79 fix: update the FileSelectHelper to support the new promise API (#18288) (#18341)
* fix: update the FileSelectHelper to support the new promise API

Fixes #18254

So it turns out we've successfully introduced a way to write
non-typesafe C++.

This fixes two things:
* Uses the object the promise resolves
* Ensures we attach the Then handler before moving the promise

* fix: also fix misuse of Promise::Then in the download manager
2019-05-21 15:52:48 +09:00
trop[bot]
da76c4d7c5 fix: leave space for autohide taskbar for frameless maximized window (#18373) 2019-05-21 15:35:39 +09:00
trop[bot]
4468b86a81 feat: allow setting working directory in app.setUserTasks() / app.setJumpList() (#18291) 2019-05-16 09:13:30 -04:00
Electron Bot
8acbb9a3ad Bump v6.0.0-beta.3 2019-05-14 12:10:18 -07:00
trop[bot]
f5e28bc999 fix: default enable_negotiate_port to false (#18285) 2019-05-14 12:51:41 -05:00
trop[bot]
b45ad7f74e fix: destroy tray on current tick (#18218)
* fix: destroy tray on current tick

* test: add tray destroy specs

* use more idiomatic destructor syntax
2019-05-09 14:42:34 -04:00
trop[bot]
9e9238454e build: linux needs java on GN (#18217) 2019-05-09 11:05:33 -04:00
Electron Bot
3f2aba69ee Bump v6.0.0-beta.2 2019-05-07 19:51:34 -07:00
Shelley Vohr
371e804c6b Revert "Bump v6.0.0-beta.2"
This reverts commit c54b67300e.
2019-05-07 19:49:30 -07:00
trop[bot]
6131e89aa9 build: remove deprecated octokit auth calls (#18206) 2019-05-07 19:48:34 -07:00
Electron Bot
c54b67300e Bump v6.0.0-beta.2 2019-05-07 15:41:03 -07:00
John Kleinschmidt
e847f048d7 build: only delete .git directory on Mac builds (#18200) 2019-05-07 15:39:43 -07:00
Shelley Vohr
b5955fa663 Revert "Bump v6.0.0-beta.2"
This reverts commit a648e6c06d.
2019-05-07 15:00:14 -07:00
Electron Bot
a648e6c06d Bump v6.0.0-beta.2 2019-05-07 12:43:19 -07:00
Nitish Sakhawalkar
e6216da031 chore: Add patch to partially revert chromium crashpad change (#18198)
This adds a patch to support functionality that we were using but chromium changed it. Electron uses breakpad on windows, chromium uses crashpad (which is newer). So this patch is needed until we update electron to use crashpad for windows.
2019-05-07 12:35:10 -07:00
Jeremy Apthorp
5b7bd56367 chore: deprecate the 'options' argument to clearAuthCache (#18131)
The network service APIs do not support the fine-grained clearing of the auth cache. In preparation for switching to the network service in 7.x, log a warning that the options argument is deprecated. Ref #17970.

This might not be quite right as we could also potentially expose the new options that are available: namely, start and end time. #17970 does not expose those options, but it would in theory be possible to support them with the existing network service APIs. The current options object does not offer time-based cache clearing.
2019-05-07 09:55:15 -07:00
trop[bot]
01b1c0ca8b fix: crash on systemPreferences.getAccentColor() (#18195) 2019-05-07 09:51:36 -07:00
Shelley Vohr
05ced19f9f chore: deprecate shell.openExternalSync (#18179) 2019-05-07 08:19:52 -07:00
trop[bot]
b8ef669905 refactor: allow embedder overriding of internal FS calls (#17906) (#18192) 2019-05-07 08:00:40 -07:00
trop[bot]
212ce1840f docs: clarify clipboard type options (#18175) 2019-05-06 09:29:42 -07:00
trop[bot]
e090fa94d0 fix: do not mark navigations interupted with same-document navigations as aborted (#18143)
* fix: do not mark navigations interupted with same-document navigations as aborted

* spec: add tests for the loadURL promise
2019-05-03 23:08:57 -07:00
trop[bot]
a431f1a663 fix: correctly parse default_app path on windows (#18102) 2019-05-03 08:16:57 -07:00
trop[bot]
ea6815c0f7 fix: fs.promises does not work with asar paths (#18114) 2019-05-02 22:34:19 -07:00
Electron Bot
40e05eef23 chore: bump chromium to 76.0.3783.1 (6-0-x) (#18116) 2019-05-02 16:31:29 -07:00
trop[bot]
a790e702f5 build: free up space before running macos ci (#18099)
* build: free up space before running macos ci

* build: also delete 14GB of src/.git for bonus space
2019-05-01 13:48:25 -07:00
trop[bot]
be16a195fb fix: ensure the inspector agent is shutdown before cleaning up the node env (#18077)
* 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 13:47:22 -07:00
trop[bot]
2f10c0fd6d docs: fix webContents 'new-window' event handler sample (#18098) 2019-05-01 13:44:47 -07:00
trop[bot]
276c07d3d7 docs: remove incorrectly added let for the win variable (#18095) 2019-05-01 12:41:59 -07:00
Samuel Attard
57f7c8b6b9 build: ensure consistent lock files across multiple machines (#17955) (#18071)
* build: ensure consistent package-lock across multiple machines

* build: fix linting errors and use npm ci instead of npm install

* build: use a yarn.lock and yarn instead of package-lock and npm

* chore: replace package-lock.json files with yarn.lock

* chore: replace last instance of `npm install`
2019-05-01 11:11:52 -07:00
trop[bot]
2ce22ba0e9 fix: explicitly focus window on win.show() (#18081) 2019-05-01 10:44:30 -07:00
Electron Bot
7186c62a27 Bump v6.0.0-beta.1 2019-04-30 14:46:01 -07:00
Electron Bot
bf88a13f1e Revert "Bump v6.0.0-beta.1"
This reverts commit 6e9c540baf.
2019-04-30 13:16:51 -07:00
Electron Bot
6e9c540baf Bump v6.0.0-beta.1 2019-04-30 13:11:22 -07:00
Electron Bot
24b14d55ef Revert "Bump v6.0.0-beta.1"
This reverts commit 3b8eb6c061.
2019-04-30 13:09:29 -07:00
Electron Bot
3b8eb6c061 Bump v6.0.0-beta.1 2019-04-30 13:04:14 -07:00
Electron Bot
f9b7f6389e Revert "Bump v6.0.0-beta.1"
This reverts commit 8f30faacf8.
2019-04-30 13:02:36 -07:00
Electron Bot
8f30faacf8 Bump v6.0.0-beta.1 2019-04-30 12:59:08 -07:00
trop[bot]
f631890237 chore: disable Vulkan validation layers (#18062) 2019-04-30 12:49:43 -07:00
trop[bot]
8982889a8d build: fix issues for stable release we fixed in 5-0-x (#18068)
* build: fix release notes generation

* build: fix bump-version script for stable releases
2019-04-30 12:49:25 -07:00
trop[bot]
cd3539aaf8 refactor: rewire the desktop capturer API to remove race conditions (#18042)
We now create a new instance of atom::api::DesktopCapturer for every
request instead of weirdly re-using the same instance and queuing
requests.  This means there is now a 1:1 relationship between request
and DesktopCapturer so there isn't a race condition between the observer
for one request calling back before the observer of another.  This is an
issue ever since the backing APIs moved to worker threads.

This also does a few things to ensure memory management
* Only ever listen to one event per-request, after that we wipe the emit
function to ignore all future events
* Ensures we clean up the window_capturer_, screen_capturer_ and
captured_sources_ in native land once the request is over.

This _in theory_ fixes a flake we've been seeing on CI where we try to
resolve the promise for a request that no longerr exists.
2019-04-30 07:07:56 -07:00
Samuel Attard
275e277721 feat: upgrade to Node 12 (#17838) (#18044)
* 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

* chore: update node dep sha

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

* fix: make original-fs work with streams

* build: override node module version

* fix: use _linkedBinding in content_script/init.js

* chore: update node ref in DEPS

* build: node_module_version should be 73
2019-04-29 15:52:31 -07:00
trop[bot]
283b1241d5 docs: Correct doc for registerFileProtocol (#18050)
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:34 -07:00
trop[bot]
7bdea26085 docs: update nodeIntegration section for new defaults (#18047)
* docs: update nodeIntegration section for new defaults

* docs: update docs/tutorial/first-app.md

* Update docs/tutorial/security.md

Co-Authored-By: miniak <milan.burda@gmail.com>
2019-04-29 15:18:23 -07:00
Samuel Attard
f1fa589779 chore: upgrade chromium to 76 (#17921) 2019-04-29 12:48:28 -07:00
trop[bot]
7226ad1eba fix: crash when failed to get devices in desktopCapturer (#17973)
* fix: crash when failed to get devices in desktopCapturer

* return after emit
2019-04-26 08:05:12 -07:00
trop[bot]
d92743f0f3 docs: remove outdated refs to protocol.registerStandardSchemes (#17977) 2019-04-26 08:05:03 -07:00
trop[bot]
2c309efef4 docs: add azure vm spinup tutorial (#17975) 2019-04-25 15:49:21 -07:00
trop[bot]
0b418315a3 docs: clean up the native module tutorial (#17951) 2019-04-24 11:25:34 -07:00
trop[bot]
2f474867c7 fix: permission handler regression in default app (#17950) 2019-04-24 11:25:17 -07:00
trop[bot]
0b5acd9569 refactor: add missing constants for options (#17919) 2019-04-24 10:16:53 -07:00
Jeremy Apthorp
3419c3c730 chore: bump chromium to 75.0.3770.3 (#17883) 2019-04-23 14:29:16 -07:00
trop[bot]
754200f1b1 fix: crash when run from SMB network share (#17909) 2019-04-23 09:03:51 -07:00
Samuel Attard
37f4bd4dd0 build: reset version to 6.0.0-beta.0 in prep for 6.0.0-beta.1 2019-04-19 15:35:46 -07:00
Jeremy Apthorp
ab009bba26 refactor: turn OnOffscreen message into a command-line flag (#17687)
This turns the AtomViewMsg_Offscreen message, which only called the global setter blink::WebView::SetUseExternalPopupMenus(false) to get Chrome to render popup menus in the renderer instead of externally on macOS, into a command-line renderer flag --offscreen which does the same thing, except at render thread startup time, which is where Chromium sets the flag: https://chromium.googlesource.com/chromium/src/+/refs/tags/75.0.3755.3/content/renderer/render_thread_impl.cc#728.

This was the last usage of RenderViewObserver in our codebase, so this PR also removes that class.
2019-04-19 12:55:20 -07:00
Matheus Rocha Vieira
1249c6ebf4 fix: Comparison using is when operands support __eq__ (#17864)
* Comparison using is when operands support __eq__

Comparison using 'is' when equivalence is not the same as identity

When you compare two values using the is or is not operator, it is the object identities of the two values that is tested rather than their equality. If the class of either of the values in the comparison redefines equality then the is operator may return False even though the objects compare as equal. Equality is defined by the __eq__ or, in Python2, __cmp__ method. To compare two objects for equality, use the == or != operator instead.

Recommendation
When you want to compare the value of two literals, use the comparison operator == or != in place of is or is not.

If the uniqueness property or performance are important then use an object that does not redefine equality.

* fix: Comparison using is when operands support __eq__

Comparison using 'is' when equivalence is not the same as identity

When you compare two values using the is or is not operator, it is the object identities of the two values that is tested rather than their equality. If the class of either of the values in the comparison redefines equality then the is operator may return False even though the objects compare as equal. Equality is defined by the __eq__ or, in Python2, __cmp__ method. To compare two objects for equality, use the == or != operator instead.

Recommendation
When you want to compare the value of two literals, use the comparison operator == or != in place of is or is not.

If the uniqueness property or performance are important then use an object that does not redefine equality.
2019-04-19 12:24:41 -07:00
Sofia Nguy
eb9c4e3643 docs: Add Electron v6.0.0 Timeline (#17866) 2019-04-19 12:23:01 -07:00
Cheng Zhao
344197083e fix: drain tasks before shutting down isolate (#17879) 2019-04-19 11:01:45 -07:00
Shelley Vohr
0749dc4cc1 refactor: make app logs dir creation opt-in (#17841)
Previously, we were creating the app logs folder at a predefined location during initial electron startup, which meant that it had to be manually removed and prevented clean app portability. This refactors that implementation such that it's now an opt-in feature and developers must call app.setAppLogsPath(path) with an optional custom path in order to set this directory.
2019-04-18 22:04:58 -07:00
Jeremy Apthorp
841e31b7e6 feat: show underlying stack in errors in remote module (#17851) 2019-04-18 17:38:19 -07:00
Kilian Valkhof
ea6641afe5 docs: explanation on using protocols with partitions (#17759)
* docs: explanation on using protocols with partitions

* linting fixes

* Update docs/api/protocol.md

Co-Authored-By: Kilian <kilian@kilianvalkhof.com>

* Update docs/api/protocol.md

Co-Authored-By: Kilian <kilian@kilianvalkhof.com>

* Update docs/api/protocol.md

Co-Authored-By: Kilian <kilian@kilianvalkhof.com>

* be more explicit about there being a default session.
2019-04-18 12:40:04 -07:00
Kapil Patel
11ac6800cc docs: added fee hint (#17563)
* Update code-signing.md

* Update code-signing.md

* Update docs/tutorial/code-signing.md

Co-Authored-By: kapilepatel <kapilepatel@gmail.com>

* Update code-signing.md
2019-04-18 08:50:14 -07:00
Milan Burda
5e7c828c9e fix: copy pixels in AddImageSkiaRepFromBuffer (#17843) 2019-04-18 09:16:34 +09:00
Milan Burda
3c2ff97a16 fix: copy pixels in NativeImage::CreateFromBitmap (#17844) 2019-04-18 09:16:06 +09:00
Shelley Vohr
f1ee35e281 doc: document occasional mismatch between NSImageName and string (#17826) 2019-04-17 15:06:51 -07:00
Samuel Attard
829050daab build: rename sandbox bundle (#17831) 2019-04-17 17:18:03 -04:00
Heilig Benedek
81bf15877f fix: port OSR code to new viz compositor codepath (#17538)
* 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: compilation error introduced with rebase

* fix: split local surface id allocation into two

* Update osr_host_display_client_mac.mm

* chore: update copyright year

* fix: update patch
2019-04-17 14:10:04 -07:00
Shelley Vohr
1478bd36fd refactor: remove superfluous ScopedAllowBaseSync in desktopCapturer (#17842) 2019-04-17 14:32:24 -04:00
Jeremy Apthorp
fdaa75354a chore: save HEAD when git-import-patches runs (#17824) 2019-04-17 11:16:03 -07:00
Samuel Attard
f901170a4f docs: fix doc linter warnings (#17818) 2019-04-16 19:03:17 -04:00
Jeremy Apthorp
33fd20047c fix: skip zygote for unsandboxed ppapi processes (#17823) 2019-04-16 18:32:37 -04:00
Samuel Attard
78411db4b5 fix: maintain a ref count for objects sent over remote (#17464)
* 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 16:08:11 -04:00
Samuel Attard
9c3315c416 fix: reset the NSUserNotication handle on dismiss (#17796) 2019-04-16 14:38:41 -04:00
Samuel Attard
b7b9efa875 fix: handle remote-debugging-port=0 correctly (#17800)
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 14:22:51 -04:00
Samuel Attard
be6fb7cb12 fix: ensure the sandboxed preloads globals do not leak (#17712) 2019-04-16 10:57:02 -07:00
Shelley Vohr
b3d8db6996 docs: note desktop audio limitation on macOS (#17738)
Closes #10515. Notes fundamental limitation in `navigator.mediaDevices.getUserMedia` for audio capture on some platforms so that users are aware of the ongoing issue and provides a potential workaround.
2019-04-16 10:49:31 -07:00
Pedro Pontes
a7e22c78cf fix: populate phase of WebMouseWheelEvents generated in webContents.sendInputEvent. (#17757) 2019-04-16 12:23:38 -04:00
Samuel Meuli
3bf71a363a docs: update guide on MAS entitlements and export compliance (#17695)
* docs: Convert MAS app groups entitlement value to array

* docs: Update info on MAS encryption export compliance
2019-04-15 20:02:06 -04:00
Shelley Vohr
82a076855b fix: incorrect default path setting for dl items (#17773) 2019-04-15 14:11:20 -04:00
Vlad Hashimoto
258d337cf8 fix: crash when alt key pressed with falsy menu bar visiblity (#17766) 2019-04-15 13:54:27 -04:00
Cheng Zhao
748632d655 chore: make it possible to turn on NetworkService with cmd flag (#17729) 2019-04-11 08:51:17 +09:00
Cheng Zhao
e7c48922e7 fix: FrameSubscriber should not scale frame down (#17444) 2019-04-08 11:35:33 +09:00
Milan Burda
235eea6669 docs: add remote module to docs/tutorial/security.md (#17480) 2019-04-05 20:41:05 +02:00
Shelley Vohr
2b9bd0f56f fix crash when passing empty string to recording (#17698) 2019-04-05 11:19:06 -07:00
Shelley Vohr
c4020308c9 test: remove non-applicable processMemoryInfo specs (#17679) 2019-04-05 07:53:25 -07:00
Shelley Vohr
9c3cb55ef2 refactor: make accessibilitySupportEnabled a property on app (#17362)
* refactor: make accessibilitySupport a prop on app

* fix docs

* update spec
2019-04-04 19:49:04 -07:00
Electron Bot
11699d8611 Bump v6.0.0-nightly.20190404 2019-04-04 11:42:14 -07:00
Cheng Zhao
ac30185a04 fix: the callback of beginFrameSubscription should pass NativeImage instead of Buffer (#17548)
* Revert "revert: frame subscriber deprecation and re-enable tests"

This reverts commit f643ce4f66.

* fix: make sure SkBitmap's pixels are copied
2019-04-04 11:36:12 -07:00
Milan Burda
77d59e99b6 feat: emit process 'loaded' event in sandboxed renderers (#17680) 2019-04-04 11:35:06 -07:00
Jeremy Apthorp
127b87c713 refactor: mojofy MessageTo and MessageHost (#17613) 2019-04-03 14:22:23 -07:00
Samuel Attard
5d45b59f7f Merge pull request #17507 from electron/chromium-upgrade/75
chore: update to chromium 75.0.3740.3
2019-04-03 13:17:37 -07:00
Alexey Kuzmin
cd8402fc9f build: optionally exclude some parts of patches from being applied (#17625) 2019-04-03 12:42:49 -07:00
Samuel Attard
a65f242dbd chore: fixup ismediakey patch for lost changes 2019-04-03 11:36:32 -07:00
Shelley Vohr
8c8eac88a4 build: fix spec-main linting for 'only' (#17666) 2019-04-03 11:19:39 -07:00
Samuel Attard
59e3164206 build: ensure runner is defined inside the spec callback (#17664) 2019-04-02 18:25:45 -07:00
Samuel Attard
76d584c81d build: force a windows CI run 2019-04-02 17:19:36 -07:00
Samuel Attard
dc4fe537ee build: auto-generate the browserify step GN inputs (#17626) 2019-04-02 17:12:10 -07:00
Jeremy Apthorp
53f6cbccbf refactor: use mojo for electron internal IPC (#17406)
* refactor: use mojo for electron internal IPC

* add sender_id, drop MessageSync

* remove usages of AtomFrameMsg_Message

* iwyu

* first draft of renderer->browser direction

* refactor to reuse a single ipc interface

* implement TakeHeapSnapshot through mojo

* the rest of the owl^WtakeHeapSnapshot mojofication

* remove no-op overrides in AtomRendererClient

* delete renderer-side ElectronApiServiceImpl when its pipe is destroyed

* looks like we don't need to overlay the renderer manifest after all

* don't try to send 2 replies to a sync rpc

* undo changes to manifests.cc

* unify sandboxed + unsandboxed ipc events

* lint

* register ElectronBrowser mojo service on devtools WebContents

* fix takeHeapSnapshopt failure paths

* {electron_api => atom}::mojom

* add send_to_all to ElectronRenderer::Message

* keep interface alive until callback is called

* review comments

* use GetContext from RendererClientBase

* robustify a test that uses window.open

* MessageSync posts a task to put sync messages in the same queue as async ones

* add v8::MicrotasksScope and node::CallbackScope

* iwyu

* use weakptr to api::WebContents instead of Unretained

* make MessageSync an asynchronous message & use non-associated interface

* iwyu + comments

* remove unused WeakPtrFactory

* inline OnRendererMessage[Sync]

* cleanups & comments

* use helper methods instead of inline lambdas

* remove unneeded async in test

* add mojo to manifests deps

* add gn check for //electron/manifests and mojo

* don't register renderer side service until preload has been run

* update gn check targets list

* move interface registration back to RenderFrameCreated
2019-04-02 15:38:16 -07:00
Samuel Attard
63d6be0480 chore: add patch to fix MSVC++ incompatibilty on Windows 2019-04-02 14:43:06 -07:00
Samuel Attard
d1a7b42906 chore: disable custom libcxx on windows 2019-04-02 14:43:06 -07:00
Samuel Attard
2fda0bdc89 chore: enable_data_url_support does not exist anymore 2019-04-02 14:43:06 -07:00
Samuel Attard
a34c47b542 build: do not use custom libcxx on windows 2019-04-02 14:43:06 -07:00
Samuel Attard
fe06784a3b build: disable the custom libcxx on Windows 2019-04-02 14:43:06 -07:00
Jeremy Apthorp
7e9a271852 don't copy in make_shared in win32_desktop_notifications 2019-04-02 14:43:05 -07:00
Samuel Attard
e352d735f6 fix: use default constructor for NotificationData struct 2019-04-02 14:43:05 -07:00
Samuel Attard
43dc4e8a13 chore: include what we use, cmath in toast.cc 2019-04-02 14:43:05 -07:00
Samuel Attard
0fd0b3fb4b chore: make DCHECK available in win7 toast impl 2019-04-02 14:43:05 -07:00
Samuel Attard
30448bb1b8 build: allow zip files to be created larger than 2GB 2019-04-02 14:43:05 -07:00
deepak1556
515c927b14 fixup! enable_file_url_support and enable_data_url_support have been removed 2019-04-02 14:43:05 -07:00
Samuel Attard
b965abfda8 chore: replace DCHECK(a > b) with DCHECK_GT 2019-04-02 14:43:05 -07:00
Samuel Attard
90a738a4d4 fix: _ASSERT is not defined anymore, the appropriate replacement is DCHECK 2019-04-02 14:43:05 -07:00
Samuel Attard
ab66c4b7f9 fixme: IsNearDeath has been removed upstream
Adds a patch that reverts https://chromium-review.googlesource.com/c/v8/v8/+/1526195
in order to let native modules build.  nan has a strong dependency on
the IsNearDeath method.  This needs to be solved upstream in nan or V8.
2019-04-02 14:43:05 -07:00
Samuel Attard
04a8b9fe5c fix: base::LaunchOptions environ is now environment
Just a rename

Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1509795
2019-04-02 14:43:05 -07:00
Samuel Attard
b429e6e2df chore: disable clang-format and cpplint for impl of HandleExternalProtocol
NOLINT disables the linting error that we can't fix because its just
implementing a content API.

We also disable clang-format because it tries to format the // NOLINT
onto a new line which doesn't exactly work
2019-04-02 14:43:04 -07:00
Samuel Attard
126639875d Revert "device/fido/mac: add more specific check for TouchID availability"
This reverts commit 457ff0687c.

The change in Chromium that required this removal was itself reverted.

Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1504308
2019-04-02 14:43:04 -07:00
Samuel Attard
158e41e578 chore: add missing content:: namespace for BrowserContext in PlatformNotificationService 2019-04-02 14:43:04 -07:00
Samuel Attard
7382c519c9 fix: Add stub implementations for ScheduleTrigger and
ReadNextTriggerTimestamp

Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1479330
2019-04-02 14:43:04 -07:00
Samuel Attard
866cbb0147 fix: SetCanonicalCookieAsync now takes the full CookieOptions
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1471244
2019-04-02 14:43:04 -07:00
Samuel Attard
7467e91880 fix: RFH->ExecuteJavascriptForTesting now requires a callback
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1492042
2019-04-02 14:43:04 -07:00
Samuel Attard
74ac80e218 fix: ViewHierarchyChangedDetails moved to the views namespace
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1531481
2019-04-02 14:43:04 -07:00
Samuel Attard
ab92cfd174 fix: enable_file_url_support and enable_data_url_support have been
removed

Unsure how the change in default of file_url_support affects us

Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1512337
2019-04-02 14:43:04 -07:00
Samuel Attard
f95de3d6f3 fix: RFH->ExecuteJavascript now requires a callback
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1492042
2019-04-02 14:43:04 -07:00
Samuel Attard
2bf740d2fe fix: remove enable_data_url_support from OnNetworkServiceCreated
data URLs are _always_ enabled in the network service now and this is
enforced in the Content layer.

Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1512337
2019-04-02 14:43:04 -07:00
Samuel Attard
406ceaabd1 chore: update permission_status.h include for new path 2019-04-02 14:43:03 -07:00
Samuel Attard
50b9933705 build: update circle base image and mac docs for 10.13 SDK 2019-04-02 14:43:03 -07:00
Jeremy Apthorp
e44b5263a1 add extra arguments to HandleExternalProtocol
https://chromium-review.googlesource.com/c/chromium/src/+/1491812
2019-04-02 14:43:03 -07:00
Jeremy Apthorp
47d5f9f901 add //ui/base/idle dep 2019-04-02 14:43:03 -07:00
Jeremy Apthorp
9819433e88 fixup! download gn from cipd instead of GCS 2019-04-02 14:43:03 -07:00
Jeremy Apthorp
e2f0852c30 fixup! download gn from cipd instead of GCS 2019-04-02 14:43:03 -07:00
Jeremy Apthorp
9cc4cb2934 download gn from cipd instead of GCS
https://chromium-review.googlesource.com/c/chromium/src/+/1519726
2019-04-02 14:43:03 -07:00
Jeremy Apthorp
2dc422234a update chromium patches 2019-04-02 14:43:03 -07:00
Jeremy Apthorp
0f990c3bdd update boringssl patches 2019-04-02 14:43:03 -07:00
Jeremy Apthorp
7116c108d7 chore: update to chromium 75.0.3740.3 2019-04-02 14:43:02 -07:00
Tyler Dennis
5b696491db docs: remove webaudio doc from browserwindow options (#17633) 2019-04-02 13:46:45 -07:00
Kilian Valkhof
57dd192dcd docs: Lead with packaging tools on distribution page (#17639)
* Lead with packaging tools on distribution page

* fix trailing whitespace
2019-04-02 13:45:35 -07:00
Shelley Vohr
0431997c8d refactor: make applicationMenu a property on app (#17361) 2019-04-02 13:36:57 -07:00
Shelley Vohr
d412582f72 docs: clarify cookie domain normalization (#17590) 2019-04-02 13:04:20 -07:00
Roller Bot
d50e8a5c4c chore: bump chromium in DEPS to 74.0.3729.58 (#17657) 2019-04-02 10:26:42 -07:00
Mark Lee
66473e19cb Fix typos in feature request template instructions (#17651) 2019-04-02 11:20:36 -05:00
Shelley Vohr
8ea33d69ac fix: match net module headers & http.IncomingMessage headers (#17517)
* fix: match net module headers & http.IncomingMessage headers

* update net doc for cleanliness

* address feedback from review

* Update spec/api-net-spec.js

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

* add special cookie case
2019-04-02 07:41:19 -07:00
Jeremy Apthorp
7c6cedb119 test: de-flake getAllWebContents test by moving it to spec-main (#17610) 2019-04-01 18:28:11 -07:00
Jeremy Apthorp
eb27e9b055 refactor: move //electron/manifests:manifests target into main BUILD.gn (#17611) 2019-04-01 18:25:19 -07:00
Samuel Attard
75442b794f fix: make devtools extensions load correctly (#17614) 2019-03-30 17:36:13 -07:00
Milan Burda
d597a0e8b0 refactor: expose ipcRendererInternal to the main world for window-setup using the content script world pattern (#17591) 2019-03-29 18:10:21 -07:00
Samuel Attard
b8dbe4bc15 spec: add tests for the autoUpdater on macOS that actually test if it works (#17442)
* spec: add tests for the autoUpdater on macOS that actually test if it works

* spec: add express as dep

* spec: add logic to auto-trust self-signed certificate and not run autoupdate specs on MAS

* build: fix the step name for importing the codesign cert

* chore: update updater spec PR as per feedback

* fix: s/atomBinding/electronBinding

* build: use spawn instead of exec
2019-03-29 17:32:52 -07:00
Roller Bot
5045b0a962 chore: bump chromium in DEPS to 74.0.3729.48 (#17606) 2019-03-29 13:44:19 -07:00
Samuel Attard
953d1ea635 fix: ensure dots in content script patterns aren't used as wildcards (#17593)
* fix: ensure dots in content script patterns aren't used as wildcards

* chore: sanitise all regexp special chars

* chore: extract to helper

* chore: fixup helper
2019-03-28 14:03:37 -07:00
Samuel Attard
32c9597cbc build: ensure we use objc regexps for export-patches (#17598)
* build: ensure we use objc regexps for export-patches

* build: also use objc for *.m

Co-Authored-By: MarshallOfSound <samuel.r.attard@gmail.com>
2019-03-28 14:01:43 -07:00
Shelley Vohr
808783a5e4 fix: crashReporter.getParameters() takes no params (#17459) 2019-03-28 15:04:16 -04:00
Roller Bot
69d4c91895 chore: bump chromium in DEPS to 74.0.3729.45 (#17589) 2019-03-28 11:16:45 -07:00
Heilig Benedek
7a47e64e65 fix: update patch to make Windows key work with global shortcuts (#17565) 2019-03-28 11:15:22 -07:00
Samuel Attard
3475cd168e fix: handle a race condition between preload scripts executing and (#17577)
navigations

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 11:13:05 -07:00
John Kleinschmidt
7eaa57b116 build: remove native mksnapshot for arm/arm64 (#17561)
* build: remove native mksnapshot for arm/arm64
2019-03-28 11:05:43 -04:00
Milan Burda
8cf15cc931 feat: only allow bundled preload scripts (#17308) 2019-03-28 11:38:51 +01:00
Richard Townsend
3d307e5610 fix: correct crash reporter for Windows on Arm (#17533)
ARM64 cleans up and moves around RUNTIME_FUNCTION structure fields.
With this patch applied, electron should build cleanly for Windows on Arm.
2019-03-27 11:30:11 -07:00
Samuel Attard
f4434763fe fix: use file path as key for safeDialogs on filesystem (#17546) 2019-03-27 11:21:10 -07:00
Samuel Attard
2188a6ea99 fix: set default_id and cancel_id correctly on confirm dialogs (#17547) 2019-03-27 11:15:58 -07:00
Shelley Vohr
4e57a732a8 feat: allow windows to be excluded from the windows menu (#17404)
* feat: allow windows to be excluded from the windows menu

* excludedfromWindowsMenu => excludedFromShownWindowsMenu

* implement no-op for win & linux
2019-03-27 08:10:23 -04:00
Samuel Attard
ec5e0ef06e build: speed up windows download of external binaries (#17559) 2019-03-26 20:22:54 -05:00
Roller Bot
75b4db60cf chore: bump chromium in DEPS to 74.0.3729.38 (#17555) 2019-03-26 13:26:36 -07:00
Shelley Vohr
34eb5d0815 fix: correctly return properties on the netLog module (#17525) 2019-03-25 22:40:38 -04:00
Milan Burda
336db33d18 refactor: use ipcMainUtils.invokeInWebContents / ipcRendererUtils.handle helpers for Chrome APIs (#17417) 2019-03-26 11:38:35 +09:00
Milan Burda
546466b209 feat: add <webview>.getWebContentsId() (#17407) 2019-03-26 10:57:27 +09:00
Samuel Attard
9e26dfaa06 build: use async remove method to handle errors better (#16917)
On windows removeSync randomly seems to fail with DIRNOTEMPTY. By using
the async version fs-extra will do some back-off-retry logic to
hopefully get this dir deleted
2019-03-26 10:34:03 +09:00
Milan Burda
cbd884060e fix: validate sender for replies in ipcMainInternalUtils.invokeInWebContents() (#17416) 2019-03-26 10:15:51 +09:00
Milan Burda
95df531b33 fix: add missing buffer size check in nativeImage (#17465) 2019-03-26 10:13:39 +09:00
Robo
6c20c6e668 refactor: Enable network service (Part 1) (#17431)
* Convert InspectableWebContentsImpl::LoadNetworkResource to SimpleURLLoader

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

* Plumb creation of network context with the service
2019-03-26 10:10:48 +09:00
Shelley Vohr
4ec2f8b67b chore: remove some bot config options (#17506) 2019-03-22 19:29:23 -05:00
Shelley Vohr
a5febe392c chore: update issue templates with guidelines (#17505) 2019-03-22 16:56:52 -07:00
Cheng Zhao
49f13e38f9 fix: close context menu before popup (#17474) 2019-03-21 21:56:22 -07:00
Samuel Attard
d2ad8efef4 build: pass through value of unknown flag as well as the flag to make --grep work again (#17485) 2019-03-21 12:24:07 -07:00
Nitish Sakhawalkar
a16dc13f85 chore: Update node commit sha (#17486)
No changes made to node canary, just rebased with fixups.
This change updates to the new commit of `electron-node-canary`.
2019-03-21 14:19:49 -05:00
Samuel Attard
784f9742bc build: auto-fix whitespace in docs in pre-commit hook (#17490) 2019-03-21 12:15:55 -07:00
Jeremy Apthorp
6555be2636 chore: bump chromium to 74.0.3729.27 (master) (#17345)
* chore: bump chromium to 74.0.3729.5 (master)

* Remove ScopedBlockingCall constructor without location

https://chromium-review.googlesource.com/c/chromium/src/+/1496560

* Use XCode 9.4.1 for Mac SDK 10.13

* chore: roll chromium 74.0.3729.27
2019-03-21 11:45:22 -04:00
Milan Burda
07b02653ba docs: update sandbox-option.md (#17468)
* docs: update sandbox-option.md

* Update docs/api/sandbox-option.md

Co-Authored-By: miniak <milan.burda@gmail.com>
2019-03-21 14:41:53 +01:00
Shelley Vohr
b25279df89 docs: clarify documentation for getLastCrashReport (#17458)
* docs: clarify documentation for getLastCrashReport

* address feedback
2019-03-20 15:34:21 -07:00
Shelley Vohr
b140a82fe8 fix: take foreground visibility into account for isVisible on macOS (#17463) 2019-03-20 15:33:59 -07:00
Milan Burda
a82bbd010e build: strip trailing whitespace in docs (#17488) 2019-03-20 13:12:47 -07:00
Klaus Sinani
1c7b3026a6 docs: Use correct image URL on docs/tutorial/windows-taskbar.md (#17467) 2019-03-20 10:01:28 -07:00
Samuel Attard
45d90e77b7 fix: use a more unique identifier for NSUserNotification instances (#17469)
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 09:53:20 -07:00
Milan Burda
de1bacddd9 docs: process.getProcessMemoryInfo() returns a Promise (#16593)
* docs: process.getProcessMemoryInfo() returns a Promise
* chore: bump electron-typescript-definitions to get Promise<T> fix
2019-03-20 17:26:57 +01:00
Cheng Zhao
671533f7d2 fix: check the result when calling js function (#17443)
* fix: check the result when calling js function

* test: should not crash when callback returns nothing
2019-03-20 08:27:06 -07:00
Samuel Attard
1571461bae build: add a workaround for circleci known_hosts issue (#17471) 2019-03-19 19:37:52 -07:00
Shelley Vohr
1d93bc76cd feat: expose colorSpace to display object (#17405)
* feat: expose colorSpace to display object

* update doc

* add a spec
2019-03-19 15:12:03 -07:00
Milan Burda
4c51fa93f5 feat: add systemPreferences.getAnimationSettings() (#17382) 2019-03-19 12:15:40 -07:00
Milan Burda
4d8e024b6d spec: fix isEmpty() checks in nativeImage tests (#17441) 2019-03-19 12:13:15 -07:00
Zachary
9b359c6a75 docs: correction to ipc-main-event.md 'frane' to 'frame' (#17424) 2019-03-19 12:07:30 -07:00
Milan Burda
7389dfca59 fix: report module name when require fails in sandboxed renderers (#17413) 2019-03-19 12:00:41 -07:00
Milan Burda
06a4594435 chore: remove special handling for dialog methods in remote module (#17412)
* chore: remove special handling for dialog methods in remote module

* refactor: remove callFunction helper
2019-03-19 11:59:33 -07:00
Benny Neugebauer
f4c3151815 docs: fix typo in webview.md (#17454) 2019-03-19 11:43:19 -07:00
Milan Burda
ddd51525f1 refactor: make ELECTRON_INSPECTOR_CONTEXT_MENU handler async (#17411) 2019-03-19 10:37:43 -07:00
Shelley Vohr
879462af4b docs: document modernization initiative more clearly (#17376)
* docs: document modernization initiative more clearly
2019-03-19 10:31:45 -07:00
Milan Burda
53f4af7722 fix: regressions introduced by adding world isolation to Chrome extension content scripts (#17422) 2019-03-19 14:45:48 +01:00
Shelley Vohr
2fb9085e5b feat: add tray.getTitle() (#17385)
* feat: add tray.getTitle

* fix spec
2019-03-18 12:40:34 -07:00
Shelley Vohr
38d75010c7 chore: rename atomBinding to electronBinding (#17419) 2019-03-18 12:37:06 -07:00
Samuel Attard
5025c991ee fix: pass the correct HostPort into the node inspector (#17380)
Fixes #17348
2019-03-18 09:19:33 -07:00
Shelley Vohr
db29978fe0 fix: throw error when inserting menu items out-of-range (#17401)
* fix: throw error when inserting menu items out-of-range

* also check pos < 0
2019-03-18 07:58:42 -07:00
Shelley Vohr
f09f43a4a9 chore: remove unused arg parsing code in dialog (#17420) 2019-03-18 07:58:03 -07:00
Samuel Attard
108545e416 spec: add new test runner for main-process based tests (#17325) 2019-03-17 14:49:00 -07:00
Milan Burda
3a091cdea4 refactor: implement clipboard APIs without the remote module (#17200) 2019-03-15 17:32:04 -07:00
Samuel Attard
b502c62111 spec: fix fixtures path for second instance test 2019-03-15 12:29:25 -07:00
Samuel Attard
984e77e470 fix: spec runner not parsing correctly 2019-03-15 10:57:12 -07:00
Heilig Benedek
43ef561d48 feat: enable NodeIntegrationInSubFrames for webview (#17226)
* feat: enable nodeIntegrationInSubFrames for webview

* test: add tests

* docs: document webview's nodeintegrationinsubframes

* lint: fix indent

* fix: resolve some merge bloopers
2019-03-15 10:39:20 -07:00
Samuel Attard
4b6b59cc82 chore: update PR as per feedback 2019-03-14 17:22:42 -07:00
Shelley Vohr
961c9a88a8 feat: promisify dialog.showCertificateTrustDialog() (#17181)
* feat: promisify dialog.showCertificateTrustDialog()

* update promisification doc
2019-03-15 09:02:50 +09:00
Samuel Attard
6b326f7924 build: spread runner args onto the runner 2019-03-14 16:15:23 -07:00
Milan Burda
f15d0b1ed7 refactor: make ELECTRON_INSPECTOR_CONFIRM handler async (#17378) 2019-03-14 15:29:40 -07:00
Samuel Attard
df57ac4ce7 chore: steal all unknown args for use by the spec runners 2019-03-14 15:23:21 -07:00
Shelley Vohr
cb4ede453f chore: add deprecation helper for fnToProperty (#17377)
* chore: add deprecation helper for fnToProperty

* add a test
2019-03-14 15:19:19 -07:00
Samuel Attard
be60f93bd0 fix: we can not use ts-node apaprently 2019-03-14 13:39:53 -07:00
Shelley Vohr
12b6a0f5b2 feat: add native emoji picker (#17359) 2019-03-14 13:39:52 -07:00
Samuel Attard
46e5767527 update for PR feedback 2019-03-14 13:18:16 -07:00
Samuel Attard
259bc3a918 build: remove log from the spec runner 2019-03-14 12:50:06 -07:00
Samuel Attard
a55d1ef305 spec: chai is funky 2019-03-14 12:50:06 -07:00
Samuel Attard
6b65e3523e wut 2019-03-14 12:50:06 -07:00
Samuel Attard
b967ae4c51 build: downgrade chai to work around nested adssertion bug 2019-03-14 12:50:06 -07:00
Samuel Attard
2023e32130 spec: push electron/spec into the spec runner args before the linux dbus wrapper 2019-03-14 12:50:06 -07:00
Samuel Attard
3656d12cba build: auto generate electron.d.ts in the spec runner if it is missing 2019-03-14 12:50:06 -07:00
Samuel Attard
ca701bb9af spec: initial spike of main-process based tests 2019-03-14 12:50:06 -07:00
Milan Burda
2e89348541 feat: promisify executeJavaScript (#17312) 2019-03-14 12:08:54 -07:00
Milan Burda
878538f2e8 feat: add safer nativeImage.createFromBitmap(), which does not decode PNG/JPEG (#17337) 2019-03-14 11:00:38 -07:00
Shelley Vohr
aa8b66aae1 feat: promisify session.getBlobData() (#17303) 2019-03-14 08:11:01 -07:00
d1g1t4ld1n4
c082b3964c docs: clarification of requestSingleInstanceLock() docs (#17304)
* docs: upstream doc links added to default window

Added the link to the Node docs and Chromium docs to the default window (not sure if I linked the chromium docs correctly, please let me know/feel free to suggest changes if you know the correct way to do so)

* docs: clarify what requestSingleInstanceLock() does

* Revert "docs: upstream doc links added to default window"

This reverts commit 829417cf29.

* docs: clarify what requestSingleInstanceLock() does
2019-03-13 19:42:16 -07:00
Shelley Vohr
d9234798d3 chore: clean up promise resoution with helpers (#17268) 2019-03-13 14:30:21 -07:00
Shelley Vohr
3e5a98b5f4 feat: promisify In-App Purchase (#17355)
* feat: promisify In-App Purchase

* use mate::Arguments in GetProducts
2019-03-13 13:56:01 -07:00
Milan Burda
faabd0cc8b refactor: add ipcMainUtils.invokeInWebContents / ipcRendererUtils.handle helpers (#17313) 2019-03-13 12:03:17 -07:00
Milan Burda
df7dc9396e fix: don't crash when nativeImage.createFromBuffer() called with invalid buffer (#17344) 2019-03-13 08:26:11 -07:00
Jeremy Apthorp
90fcc574f4 chore: add description to accelerator.patch (#17346) 2019-03-13 10:11:07 +05:30
Jeremy Apthorp
86291236a0 spec: robustify some webview tests (#17301) 2019-03-12 15:50:28 -07:00
Heilig Benedek
14cc8a1808 fix: improve focused menu bar item visibility (#17291) 2019-03-12 15:29:45 -07:00
Shelley Vohr
5eb75e91b9 chore: fix default_app showMessageBox (#17357) 2019-03-12 14:10:18 -07:00
Shelley Vohr
8991c0056e feat: promisify dialog.showMessageBox() (#17298)
* feat: promisify dialog.showMessageBox()

* address feedback from review
2019-03-12 11:06:59 -07:00
Jeremy Apthorp
ea6a926494 test: add test for second-instance event parameter (#16798)
* test: add test for second-instance event parameter

* robustify getting data from child process

* fix test on windows

* fix lint

* Update api-app-spec.js

* fix package-lock.json
2019-03-12 11:56:28 -04:00
Milan Burda
48a95f9677 fix: remove non-existent gpu-crashed event on <webview> (#17317) 2019-03-11 17:25:46 -07:00
Nitish Sakhawalkar
e77d065875 chore: node_includes header no longer needs to be at the end of the list (#17090)
Until one of the latest version of node, the definition of the DISALLOW_COPY_AND_ASSIGN macro in node was different than in chromium. That is no longer the case, so just undefining the macro in node_includes.h works.
2019-03-11 17:13:43 -07:00
Samuel Maddock
f943db7ad5 feat: Add content script world isolation (#17032)
* Execute content script in isolated world

* Inject script into newly created extension worlds

* Create new content_script_bundle for extension scripts

* Initialize chrome API in content script bundle

* Define Chrome extension isolated world ID range

1 << 20 was chosen as it provides a sufficiently large range of IDs for extensions, but also provides a large enough buffer for any user worlds in [1000, 1 << 20).

Ultimately this range can be changed if any user application raises it as an issue.

* Insert content script CSS into document

This now avoids a script wrapper to inject the style sheet. This closely matches the code used by chromium in `ScriptInjection::InjectCss`.

* Pass extension ID to isolated world via v8 private
2019-03-11 16:27:57 -07:00
Milan Burda
6072da239d feat: add global renderer-process-crashed event (#17315) 2019-03-11 16:17:24 -07:00
Milan Burda
a8698d092b chore: increase security of default_app (#17318) 2019-03-11 16:13:46 -07:00
Jeremy Apthorp
188d31132b spec: robustify sendInputEvent beforeEach hook (#17300) 2019-03-11 13:35:44 -07:00
Samuel Attard
c7a453226d fix: remove label/image from segment if they are mutated to undefined/null (#17323) 2019-03-11 11:13:36 -07:00
Electron Bot
b43e4b8e0e Bump v6.0.0-nightly.20190311 2019-03-11 10:56:01 -07:00
Electron Bot
a958eb9c44 Bump v6.0.0-nightly.20190308 2019-03-08 19:38:21 -08:00
Electron Bot
7343a2f232 Revert "Bump v6.0.0-nightly.20190308"
This reverts commit 40af881844.
2019-03-08 19:36:24 -08:00
Electron Bot
40af881844 Bump v6.0.0-nightly.20190308 2019-03-08 19:36:08 -08:00
Samuel Attard
a968f4f999 build: remove strip_debug_info gn arg declaration as it is android only and causing release build failures on windows (#17306) 2019-03-08 19:34:39 -08:00
Shelley Vohr
9ea6c01e02 feat: promisify session.clearAuthCache() (#17259)
* feat: promisify session.clearAuthCache()

* remove unused callback runner helpers
2019-03-08 18:41:42 -08:00
Electron Bot
58a9a81895 Revert "Bump v6.0.0-nightly.20190308"
This reverts commit 4728cebd9e.
2019-03-08 17:46:53 -08:00
Electron Bot
4728cebd9e Bump v6.0.0-nightly.20190308 2019-03-08 17:13:26 -08:00
Samuel Attard
699ef08e84 Merge pull request #17088 from electron/chromium-upgrade/74
feat: upgrade to Chromium 74.0.3724.8
2019-03-08 17:08:59 -08:00
Samuel Attard
5c42f57197 test: skip failing win32 devtools keyboard spec 2019-03-08 17:07:10 -08:00
Samuel Maddock
8ee153dae1 feat: add support for content scripts 'all_frames' option (#17258)
* feat: add support for content scripts 'all_frames' option

* merged content script tests

'all_frames' test now runs on all variants of sandbox/contentIsolation configurations :D
2019-03-08 15:53:25 -08:00
Seba Kerckhof
b7fc50b7ca docs: Add information on packaging a build (#17086)
* docs: Add information on packaging a build

* Stripping only applies to linux
2019-03-08 15:24:00 -08:00
Samuel Attard
e185057ef9 chore: fix linting issues in atom_api_cookies.cc 2019-03-08 15:13:22 -08:00
Jeremy Apthorp
a46b8efc8a temporarily disable verify-mksnapshot on arm 2019-03-08 15:13:22 -08:00
Jeremy Apthorp
d548c8c692 fix: build on arm 2019-03-08 15:13:21 -08:00
deepak1556
457ff0687c device/fido/mac: add more specific check for TouchID availability
https://chromium-review.googlesource.com/c/chromium/src/+/1487811
2019-03-08 15:13:12 -08:00
Jeremy Apthorp
bf6fea3b59 AttachToOuterWebContentsFrame => AttachInnerWebContents
https://chromium-review.googlesource.com/c/1492653
2019-03-08 15:13:12 -08:00
Jeremy Apthorp
0d534b3c52 fix: compile error in frame_subscriber.h
https://chromium-review.googlesource.com/c/1460096
2019-03-08 15:13:12 -08:00
deepak1556
47b92b6413 chore: roll 74.0.3724.8 2019-03-08 15:13:12 -08:00
Jeremy Apthorp
9c76ce38e3 appveyor workaround for appveyor/ci#2420 2019-03-08 15:10:52 -08:00
Jeremy Apthorp
2840e45920 use patched robotjs to fix compile failure 2019-03-08 15:10:52 -08:00
Jeremy Apthorp
38304be688 force abstract-socket version to fix compile error 2019-03-08 15:10:52 -08:00
Jeremy Apthorp
990ba15157 update nan in spec deps 2019-03-08 15:10:52 -08:00
Jeremy Apthorp
69bf9aa605 fix extra-semi warnings 2019-03-08 15:10:52 -08:00
deepak1556
8043e2e278 build: only download gn binary for lint step 2019-03-08 15:06:16 -08:00
deepak1556
e8f6f31fe4 Disable network service
https://github.com/electron/electron/issues/15791
2019-03-08 15:06:16 -08:00
deepak1556
0243b0ffc1 Change base::JSONReader::ReadToValue() to return Optional.
https://chromium-review.googlesource.com/c/chromium/src/+/1476186
2019-03-08 15:06:16 -08:00
deepak1556
fb9d1bd83c Change net::CookieStore::SetCookiesCallback to return CookieInclusionStatus
https://chromium-review.googlesource.com/c/chromium/src/+/1470931
2019-03-08 15:06:16 -08:00
deepak1556
c735116cc3 Take scheme in CookieStore::SetCanonicalCookieAsync, not just whether it's secure.
https://chromium-review.googlesource.com/c/chromium/src/+/1450420
2019-03-08 15:06:16 -08:00
deepak1556
457abecad6 Remove obsolete WebVector::IsEmpty().
https://chromium-review.googlesource.com/c/chromium/src/+/1482145
2019-03-08 15:06:16 -08:00
deepak1556
bfe876afcd Use IPEndPoint instead of HostPortPair
https://chromium-review.googlesource.com/c/chromium/src/+/1473094
2019-03-08 15:06:16 -08:00
deepak1556
3f4f774838 Remove const interfaces from content::ResourceRequestInfo.
https://chromium-review.googlesource.com/c/chromium/src/+/1474632
2019-03-08 15:06:16 -08:00
deepak1556
66128a7152 Add RenderFrameHost as parameter to WebContentsDelegate::HandleContextMenu
https://chromium-review.googlesource.com/c/chromium/src/+/1472696
2019-03-08 15:06:16 -08:00
Jeremy Apthorp
0bae707995 fix extra-semi warning in frame_host_manager.patch 2019-03-08 15:06:16 -08:00
Jeremy Apthorp
7245546274 update chromium patches 2019-03-08 15:06:16 -08:00
Jeremy Apthorp
1650ca3699 update v8 patches
array_buffer patch upstreamed at https://chromium-review.googlesource.com/c/v8/v8/+/1462003
2019-03-08 15:06:16 -08:00
Jeremy Apthorp
36abc0e547 chore: roll to 74.0.3718.2 2019-03-08 15:06:16 -08:00
deepak1556
ffc32d8130 Move buildtools into src
https://chromium-review.googlesource.com/c/chromium/src/+/1450459
2019-03-08 15:06:16 -08:00
deepak1556
43f909a9a3 chore: update is-valid-window 2019-03-08 15:06:15 -08:00
deepak1556
8f15dc4ff9 chore: roll 74.0.3711.0 2019-03-08 15:06:15 -08:00
Jeremy Apthorp
38c3891337 fix: initialize field trial list
https://chromium-review.googlesource.com/c/1402880
2019-03-08 15:06:15 -08:00
Jeremy Apthorp
d47ed72d17 FIXME: disable field-trial descriptor DCHECK 2019-03-08 15:05:54 -08:00
Jeremy Apthorp
014654e794 [OnionSoup] Replace content::RendererPreferences with the mojom one.
https://chromium-review.googlesource.com/c/1426522
2019-03-08 15:04:32 -08:00
deepak1556
d04d11cfb5 [mojo] include mojo header
https://chromium-review.googlesource.com/c/chromium/src/+/1447145
2019-03-08 15:04:32 -08:00
deepak1556
03f9d40635 Expand GpuInfo to include image decode acceleration support.
https://chromium-review.googlesource.com/c/chromium/src/+/1471913
2019-03-08 15:04:32 -08:00
deepak1556
527e8f3a31 IWYU: add missing headers 2019-03-08 15:04:32 -08:00
deepak1556
49f414b439 [Mac] Remove GC calls from Chromium.
https://chromium-review.googlesource.com/c/chromium/src/+/1471382
2019-03-08 15:04:32 -08:00
deepak1556
43361164e8 Change signature of GetCookieListCallback to include list of excluded cookies
https://chromium-review.googlesource.com/c/chromium/src/+/1416151
2019-03-08 15:04:32 -08:00
deepak1556
ccd4a3c80c CookieStore::DeleteCookieAsync appears unused (outside a few tests), so remove it
https://chromium-review.googlesource.com/c/chromium/src/+/1456677
2019-03-08 15:04:32 -08:00
deepak1556
a7e2856bf0 //components/spellcheck: Fix 64-bit truncation issues
https://chromium-review.googlesource.com/c/chromium/src/+/1450592
2019-03-08 15:04:32 -08:00
deepak1556
ac609a3d78 Remove deprecated override of RegisterDictionaryPref
https://chromium-review.googlesource.com/c/chromium/src/+/1459538
2019-03-08 15:04:32 -08:00
deepak1556
611b36719b Remove channel_id_path from NetworkContextParams (and other related places)
https://chromium-review.googlesource.com/c/chromium/src/+/1435678
2019-03-08 15:04:32 -08:00
deepak1556
59cb0ac32e Copy base::JSONReader::Read() to ReadDeprecated().
https://chromium-review.googlesource.com/c/chromium/src/+/1435715
2019-03-08 15:04:32 -08:00
deepak1556
6f14df039e [DevTools] Stop passing base::Value to DevToolsManagerDelegate
https://chromium-review.googlesource.com/c/chromium/src/+/1459807
2019-03-08 15:04:32 -08:00
deepak1556
4450c26206 [v8] Advance deprecation for Value::BooleanValue
https://chromium-review.googlesource.com/c/v8/v8/+/1458245
2019-03-08 15:04:32 -08:00
deepak1556
7270a08f9c WebSQL: Don't pass name/metadata around, use content::StorageUsageInfo
https://chromium-review.googlesource.com/c/chromium/src/+/1432375
2019-03-08 15:04:32 -08:00
deepak1556
b99ff3448e Use base::BindOnce in notifications code
https://chromium-review.googlesource.com/c/chromium/src/+/1418170
2019-03-08 15:04:32 -08:00
deepak1556
00aeb8e5c5 Revert "Disable precompiled headers"
This reverts commit 2556d86c8a.
Required clang update is now available.
2019-03-08 15:04:32 -08:00
deepak1556
59703c60ac Convert remaining JSON service manifests
https://bugs.chromium.org/p/chromium/issues/detail?id=895616
2019-03-08 15:04:32 -08:00
deepak1556
04ad579e8f chore: update patches/common/chromium 2019-03-08 15:04:32 -08:00
deepak1556
a3deae4491 chore: update patches/common/v8 2019-03-08 15:04:31 -08:00
deepak1556
9bc3888378 chore: update patches/common/boringssl 2019-03-08 15:04:31 -08:00
deepak1556
c13bf5692a chore: roll 74.0.3710.0 2019-03-08 15:03:15 -08:00
Shelley Vohr
fc10620082 feat: promisify session cache methods (#17185) 2019-03-08 14:42:03 -08:00
Jeremy Apthorp
652e232813 feat: enable setuid sandbox on linux (#17269) 2019-03-08 13:10:26 -08:00
Samuel Attard
890f38e8fa build: use shx instead of raw cp to support windows (#17299) 2019-03-08 12:52:28 -08:00
Shelley Vohr
2769e75b49 feat: promisify session proxy methods (#17222) 2019-03-08 12:51:12 -08:00
Jeremy Apthorp
34fb6c2f35 fix: crash in ECDH.setPrivateKey (#17219) 2019-03-08 10:50:04 -08:00
Robo
5afb7dc715 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
2019-03-08 10:29:52 -08:00
Shelley Vohr
e5e6aa207c feat: promisify ses.clearHostResolverCache() (#17229) 2019-03-08 10:26:17 -08:00
Samuel Attard
9d8619f305 fix: remove usage of private APIs in the MAS build (#17224)
* 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 10:08:56 -08:00
Shelley Vohr
bbfa63fd9d feat: promisify session.clearStorageData() (#17249) 2019-03-08 09:02:30 -08:00
Milan Burda
d34f81972d refactor: make ELECTRON_BROWSER_SANDBOX_LOAD handler async (#17107) 2019-03-08 11:21:41 +01:00
Shelley Vohr
17dab8f239 build: turn gpg signing off for bootstrap (#17282) 2019-03-07 18:11:31 -08:00
Shelley Vohr
a4418a9014 chore: add static promise resolution helpers (#17223)
* chore: add static promise resolution helpers

* address feedback

* address feedback from review
2019-03-07 18:07:04 -08:00
Samuel Attard
61fc95417b build: fix new TS linting errors (#17279)
* remove unused _args var
* handle type/variable shadowing
2019-03-07 17:18:10 -08:00
John Kleinschmidt
2be62b1c33 test: fix incorrect reference to skip (#17278) 2019-03-07 16:03:10 -08:00
Samuel Maddock
42b7b25ac3 feat: support chrome extensions in sandboxed renderer (#16218)
* Add content script injector to sandboxed renderer

* Fix 'getRenderProcessPreferences' binding to the wrong object

* Pass getRenderProcessPreferences to content-scripts-injector

* Emit document-start and document-end  events in sandboxed renderer

* Use GetContext from RendererClientBase

* Prevent script context crash caused by lazily initialization

* Remove frame filtering logic for onExit callback

Since we're keeping track of which frames we've injected the bundle into, this logic is redundant.

* Add initial content script tests

* Add contextIsolation variants to content script tests

* Add set include

* Fix already loaded extension error

* Add tests for content scripts 'run_at' options

* Catch script injection eval error when CSP forbids it

This can occur in a rendered sandbox when a CSP is enabled. We'll need to switch to using isolated worlds to fix this.

* Fix content script tests not properly cleaning up extensions

* Fix lint and type errors
2019-03-07 16:00:28 -08:00
Jeremy Apthorp
825e526456 build: minor fixes to git-export-patches (#17276)
* fix: make export-patches robust to tags with dashes

* fix: --output is a required parameter of export-patches
2019-03-07 15:59:17 -08:00
Jeremy Apthorp
ca2c345997 chore: update package-lock.json with npm@latest (#17146)
* chore: update package-lock.json with npm@latest

* also for spec/
2019-03-07 15:34:33 -08:00
Milan Burda
5791a2a9ec refactor: use ipcRendererUtils.invoke / ipcMainUtils.handle for desktopCapturer.getSources() (#16619) 2019-03-07 15:31:25 -08:00
Samuel Maddock
ac88b3ead5 feat: add 'disableHtmlFullscreenWindowResize' option to webPreferences (#17203)
This option allows users to prevent the window from resizing when the HTML5 FullScreen API is used.
2019-03-07 15:29:37 -08:00
Felix Rieseberg
f3fc4023cf refactor: Port renderer/web-view to TypeScript (#17250) 2019-03-07 15:26:23 -08:00
Roller Bot
8c6bf9c848 chore: bump chromium in DEPS to 73.0.3683.68 (#17262) 2019-03-07 14:52:02 -08:00
Robo
bb88a07a94 fix: gn check errors in release build (#17274) 2019-03-07 14:48:22 -08:00
Samuel Maddock
8ec304f32f fix: run subframe preload bundles in isolated context (#17165)
* fix: run subframe preload bundles in isolated context

* test subframe contextIsolation when disabled
2019-03-07 14:46:57 -08:00
Felix Rieseberg
5581990d78 build: Update TypeScript, use @typescript-eslint (#17251)
* build: Update TypeScript to v3.3

* build: Update TypeScript, use @typescript-eslint
2019-03-07 12:56:02 -08:00
Electron Bot
8c4d6438de Bump v6.0.0-nightly.20190307 2019-03-07 12:51:33 -08:00
Electron Bot
229934ec66 Revert "Bump v6.0.0-nightly.20190307"
This reverts commit ab785e73ac.
2019-03-07 12:47:33 -08:00
Electron Bot
ab785e73ac Bump v6.0.0-nightly.20190307 2019-03-07 12:34:10 -08:00
Robo
d4d6b9862f fix: make StreamSubscriber ref counted (#17221)
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 20:50:03 +05:30
Jeremy Apthorp
b575631bb0 fix: bad assertion in crypto functions that use BN_bn2bin_padded (#17220)
* 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 07:29:53 +05:30
Heilig Benedek
5422fd9941 fix: backport upstream fixes for color chooser dialogs (#17227)
* 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 07:25:15 +05:30
Milan Burda
2733697819 refactor: make ELECTRON_INSPECTOR_SELECT_FILE handler async (#17235) 2019-03-06 22:22:45 +01:00
Shelley Vohr
6cb7b8d3a4 feat: promisify dialog.showSaveDialog() (#17054)
* feat: promisify dialog.showSaveDialog()

* address some feedback from review

* filename => filePath

* fix last filename => filePath
2019-03-05 13:48:20 -08:00
Roller Bot
92c9dbc179 chore: bump chromium in DEPS to 73.0.3683.65 (#17234) 2019-03-05 11:01:38 -08:00
Jeremy Apthorp
5a88d9e6fc docs: add troubleshooting note about pywin32 (#17216) 2019-03-05 10:40:52 -08:00
Koen [XII]
aa863f3246 Fix typo in registerSchemesAsPrivileged reference (#17214) 2019-03-05 09:20:52 -08:00
Shelley Vohr
e05985145b feat: promisify dialog.showOpenDialog() (#16973)
* feat: promisify dialog.showOpenDialog()

* address feedback from review

* address feedback from review
2019-03-05 05:54:48 -08:00
Robo
7936237677 build: enable gn check for //electron:electron_lib (#17100)
* build: enable gn check for //electron:electron_lib

* ci: add gn check step

* ci: set depot_tools path

* chrome_key_systems_provider.h nogncheck

* chore: fix gn check errors on windows

* chore: gn check //electron:electron_app
2019-03-05 10:38:55 +05:30
Charles Kerr
ed31cfebc9 fix: check for pane focus before removing it. (#17164)
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 09:47:59 -06:00
Samuel Attard
8dcb5662e3 refactor: remove chromium/net_url_request_job.patch (#17174)
Does not appear to be used any more
2019-03-02 15:23:47 +05:30
Jeremy Apthorp
f4169f3491 chore: bump chromium to 73.0.3683.61 (master) (#17191)
also backport https://chromium-review.googlesource.com/c/chromium/src/+/1496448
2019-03-01 12:35:27 -08:00
Milan Burda
bbd1ae315a refactor: use invoke/invokeSync helpers for <webview> implementation (#16784) 2019-03-01 13:33:03 -05:00
Jeremy Apthorp
2adbc7836b refactor: prevent node macros from overriding base (#17178) 2019-03-01 10:04:30 -08:00
Felix Rieseberg
59a7fa6927 refactor: Port api/web-frame to TypeScript (#17053) 2019-03-01 08:39:04 +00:00
Milan Burda
676c02611d spec: add missing checks to "validates process APIs access in sandboxed renderer" (#17129) 2019-02-28 22:24:18 -08:00
Jeremy Apthorp
67f04c0370 docs: remove dead link to chromiumdev slack (#17161)
* docs: remove dead link to chromiumdev slack

Closes #17154

* Update chromium-development.md
2019-02-28 16:43:55 -05:00
Shelley Vohr
544d8a423c feat: allow MenuItems to work optionally when hidden (#16853)
* feat: allow MenuItems to work optionally when hidden

* fix: actually include forward_declaration
2019-02-28 17:00:54 +00:00
Linda_pp
6d55498cc7 docs: Fix types and missing property in WebRequest APIs (#17046)
* 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 09:30:38 +00:00
Milan Burda
64078324bf refactor: make CHROME_GET_MESSAGES handler async (#17148) 2019-02-27 21:30:35 -06:00
Nitish Sakhawalkar
bfa07ec4be feat: Add new powerMonitor synchronous API (#17144)
`powerMonitor.querySystemIdleState` and `powerMonitor.querySystemIdleTime` had async backing APIs in chromium (https://chromium-review.googlesource.com/c/chromium/src/+/1379183). However, that has changed in ch73. So, this PR deprecates the old async APIs and adds new sync APIs.
2019-02-27 15:54:01 -05:00
Jeremy Apthorp
29ab74688d chore: update CODEOWNERS to reflect governance (#17143)
* chore: update CODEOWNERS to reflect governance

* Add /patches/ @electron/wg-upgrades

* Update CODEOWNERS
2019-02-27 15:17:35 -05:00
qwabra
d4cfaaf047 Update debugging-main-process-vscode.md (#16363)
[console.log() not printing to terminal when debugging Electron apps. #49](https://github.com/Microsoft/vscode-recipes/issues/49#issuecomment-354367330)
2019-02-27 15:03:15 -05:00
Nitish Sakhawalkar
5da89c3a2b chore:Remove transparency hack (#17128)
This change undoes the hack that was put in because of a bug in chromium. That has since been fixed in chromium, so this is no longer need, hence removing.
The 'BrowserWindow' > 'preserves transparency' test, validates this working.
2019-02-27 14:51:30 -05:00
Samuel Attard
e01c3615c4 chore: replace usage of deprecated beginSheetModalForWindow API (#16994) 2019-02-27 10:23:17 -08:00
Luca Carettoni
1bbb47be5b docs: Improved security doc, particularly around isolation and tool (#16703)
* Improved security doc, particularly around isolation and tool

* Fixes as suggested by @ckerr

* libcc update

* fixing lint stuff
2019-02-27 10:09:38 -08:00
Electron Bot
a07cb2afd7 Bump v6.0.0-nightly.20190227 2019-02-27 09:55:19 -08:00
Roller Bot
4e25dc3c3c chore: bump chromium in DEPS to 73.0.3683.58 (#17156) 2019-02-27 09:48:08 -08:00
Shelley Vohr
5ecda17c7a refactor: make shell.ShowItemInFolder asynchronous (#17121)
* fix: add scoped_blocking_calls to platform_win

https://chromium-review.googlesource.com/c/chromium/src/+/1191582

* feat: make ShowItemInFolder async

* address feedback from review

* fix build
2019-02-27 12:58:23 +00:00
Samuel Attard
08066581b0 fix: set cancelId to 1 when defaultId == 0 and no 'cancel' button (#17123) 2019-02-27 08:24:13 +00:00
Johann Fuechsl
42aa375497 fix: access of out-of-scope reference in ShowOpenDialog and ShowSaveDialog (#17126)
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-02-27 08:14:04 +00:00
Milan Burda
5a99ea4c46 refactor: merge ipcMainUtils.handle / handleSync (#17062) 2019-02-26 15:48:26 -08:00
Electron Bot
848d16525f Revert "Bump v6.0.0-nightly.20190226"
This reverts commit 7c78f11b82.
2019-02-26 15:20:32 -08:00
Electron Bot
7c78f11b82 Bump v6.0.0-nightly.20190226 2019-02-26 14:56:19 -08:00
Robo
28899c3885 chore: roll chromium 73.0.3683.54 (#17124)
* chore: roll chromium 73.0.3683.52

* chore: roll 73.0.3683.54
2019-02-26 21:35:27 +00:00
Shelley Vohr
be8f9bd597 chore: clean up issue templates (#17085)
* chore: clean up issue templates

* address feedback from review

* cleanup
2019-02-26 17:51:29 +09:00
Shelley Vohr
d9c7735a04 chore: augment promisifyMultiArg deprecation (#17066) 2019-02-25 18:25:25 -08:00
Mark Lee
7a7389ab1c build: upgrade to asar@^1.0.0 (#17061)
* build: upgrade asar to ^1.0.0

This is to remove a transitive security vulnerability.
The API changed from callbacks to Promises, so `script/gn-asar.js`
needed to be changed.

* build: add klaw to package.json

`klaw` is used in `script/lint.js`, but it was a transitive dependency.

* build: add fs-extra to package.json

`fs-extra` is used in `script/gn-asar.js`, but it was a transitive
dependency.
2019-02-25 18:25:00 -08:00
Vlad Hashimoto
30213089ae docs: allow webRequest listener to passing null (#17006) 2019-02-25 18:13:00 -08:00
Gavin Wang
391f6dd663 docs: add sample code for contents.insertCSS() (#16959)
it not work before Event: 'did-finish-load', so add this sample code to show it.
2019-02-25 18:10:56 -08:00
Felix Rieseberg
7f007109c3 refactor: Port inspector to TypeScript (#16943)
* refactor: Port inspector to TypeScript

* refactor: Add another type to inspector

* refactor: Use correct paths

* Update lib/renderer/inspector.ts

Co-Authored-By: felixrieseberg <felix@felixrieseberg.com>

* refactor: Implement feedback <3

* refactor: Don't define blob at all

* fix: Correct type
2019-02-25 18:10:25 -08:00
Robo
ddcebb096f fix: use frame tree api to remove <webview> frame (#16501)
Replaces the usage of testing api added in
03d499bf34
2019-02-25 17:47:29 -08:00
Shazron Abdullah
6da939629b fix: respect the user's active app focus (#16400)
* Respect the user's active app

Apple recommends not setting this to true. https://developer.apple.com/documentation/appkit/nsapplication/1428468-activateignoringotherapps?language=objc

* Remove atom_bundle_mover.mm change for [NSApp activateIgnoringOtherApps:]
2019-02-25 17:44:38 -08:00
Milan Burda
5e762d6a47 chore: finalize dropping support for OS X Mavericks (version 10.9) (#17102) 2019-02-25 17:21:57 +00:00
Sindre Sorhus
df5305d6a7 docs: fix MenuItem windowMenu role description (#17065)
It was changed in https://github.com/electron/electron/pull/15930
2019-02-25 13:34:32 +00:00
Thomas Beverley
1674388028 Fix webContents.print() (#17052) 2019-02-25 13:30:21 +00:00
Roller Bot
944cdb4430 chore: bump chromium in DEPS to 73.0.3683.49 (#17095) 2019-02-22 17:17:02 -08:00
Jeremy Apthorp
28b150f6dc test: fix race condition in debugger spec (#17091) 2019-02-22 16:45:48 -08:00
Roller Bot
5be93566ee chore: bump chromium in DEPS to 73.0.3683.48 (#17083) 2019-02-21 09:52:08 -08:00
Cheng Zhao
32a4de4a68 chore: make util::Promise a move-only type (#17071) 2019-02-21 12:32:44 +00:00
ZYSzys
a40d826b11 chore: remove unused catch bindings (#16121) 2019-02-21 09:26:07 +00:00
Roller Bot
08f7d60da4 chore: bump chromium in DEPS to 73.0.3683.47 (#17068) 2019-02-20 10:18:43 -08:00
Shelley Vohr
3edc497d3d feat: show user gesture type in click event (#16954) 2019-02-20 12:20:24 +00:00
Shelley Vohr
cc5ed24e23 chore: properly template the Then promise helper (#17050) 2019-02-19 21:46:59 +00:00
Roller Bot
0a730e61f5 chore: bump chromium in DEPS to 73.0.3683.45 (#17048) 2019-02-19 13:42:32 -08:00
Felix Rieseberg
91f81b4b72 refactor: Port renderer/init to TypeScript (#17027)
* refactor: Port renderer/init to TypeScript

* Update lib/renderer/init.ts

Co-Authored-By: felixrieseberg <felix@felixrieseberg.com>

* refactor: Type this a bit more loosely

* refactor: Type parseOption strictly
2019-02-19 17:05:14 +00:00
Felix Rieseberg
2223114f20 refactor: Port chrome-api to TypeScript (#17014) 2019-02-19 13:09:44 +00:00
Milan Burda
7e7abc28f5 feat: promisify netLog.stopLogging (#16862) 2019-02-19 10:48:27 +00:00
Samuel Attard
3b74837020 refactor: Split 'Event' docs/types into more specific Event types (#17038)
* Event = Base event type (with preventDefault)
* IpcMainEvent = Event that ipcMain emits (with sender, reply, etc.)
* IpcRendererEvent = Event that ipcRenderer emits (with sender,
senderId, etc.)
* KeyboardEvent = Event that we emit with keyboard flags (ctrlKey,
altKey, etc.)

This will dramatically improve peoples TS experience with IPC events
2019-02-19 09:24:19 +00:00
Shelley Vohr
ef2e7d95fe chore: add Then helper for native promises (#16978) 2019-02-18 14:25:28 +00:00
Milan Burda
a04d9ef35b feat: add process.getSystemVersion() (#16599) 2019-02-18 12:59:48 +00:00
Felix Rieseberg
eaa0e28396 refactor: Port content-scripts-injector to TypeScript (#17012) 2019-02-18 12:47:07 +00:00
John Kleinschmidt
35c3a7e130 build: make torque patch more specific for native arm builds (#16992)
* 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 10:02:50 +00:00
Felix Rieseberg
596acdcb91 refactor: Port web-frame-init to TypeScript (#16934)
* refactor: Port web-frame-init to TypeScript

* refactor: Use ipcRendererInternal
2019-02-18 00:24:18 +00:00
Felix Rieseberg
6b3ff4f1f7 refactor: Port security warnings to TypeScript (#16937)
* refactor: Port security-warnings to TypeScript

* chore: make aliasify work on .ts files as well

* refactor: Implement feedback <3

* refactor: Correctly call executeJavaScript
2019-02-16 17:06:30 -08:00
Mark Lee
0a84c61074 docs: update chromium version in 5.0.0 release schedule (#17001) 2019-02-16 08:25:25 -08:00
Samuel Attard
71366e2a0d chore: auto add filenames.auto.gni when md files are changed (#16995) 2019-02-15 17:03:50 -08:00
Shelley Vohr
1e8ac79e6f docs: document the Event interface (#16966)
* docs: document the Event interface

* update docs deps

* pull new VoidFunction update
2019-02-15 12:08:45 -08:00
Roller Bot
31ff160431 chore: bump chromium in DEPS to 73.0.3683.41 (#16981) 2019-02-15 10:37:19 -08:00
Aayush Chhabra
6d005ff137 docs: Remove redundant 'Instance Events' Headline (#16865) 2019-02-15 08:29:33 -10:00
Milan Burda
975a035d34 chore: re-enable devtools renderer sandbox (#16864)
* chore: re-enable devtools renderer sandbox

* chore: enable sandbox for chrome extension background script host renderers
2019-02-15 15:10:32 +05:30
Felix Rieseberg
2498e8d1c2 refactor: Port renderer-internal to TypeScript (#16939)
* chore: make aliasify work on .ts files as well

* refactor: Port ipc-renderer-internal to TypeScript

* refactor: Correctly import internal ipcRenderer

* refactor: One more rename

* refactor: Fix one more lint issue

* refactor: Correctly reference ipcRendererInternal
2019-02-14 17:24:25 -08:00
Samuel Attard
5790869a3f chore: refactor browser IPC into TS and app API into TS (#16921)
* chore: refactor browser IPC into typescript

* chore: refactor app.ts into Typescript

* Refactors app.dock into cpp
* Removes app.launcher which has not existed for 3 years
* Removes 2 deprecated APIs (that have been deprecated for more than one
major)
* Refactors deprecate.ts as well
2019-02-14 14:29:20 -08:00
Samuel Attard
4ccd6d5900 build: add a pre-flight check to all NPM steps in GN to ensure that we have the right NPM deps installed (#16974) 2019-02-14 14:28:41 -08:00
Samuel Attard
28638b0a6b docs: update dialog documentation for "undefined" ret vals (#16970) 2019-02-14 14:28:17 -08:00
Samuel Attard
5904544235 Merge pull request #16494 from electron/chromium-upgrade/73
feat: upgrade to Chromium 73.0.3683.27
2019-02-14 12:28:41 -08:00
John Kleinschmidt
46a49b74a6 Run electron tests first 2019-02-14 23:59:27 +05:30
deepak1556
b927be9982 chore: roll 73.0.3683.27 2019-02-14 23:59:27 +05:30
deepak1556
95386ef56f Disable swiftshader for arm32 2019-02-14 23:59:27 +05:30
deepak1556
1d9170f1bb FIXME: disable OSR 2019-02-14 23:59:27 +05:30
deepak1556
b6f7157910 fix compilation error for windows testing builds 2019-02-14 23:59:27 +05:30
deepak1556
2556d86c8a Disable precompiled headers
Workaround for https://crbug.com/924225
2019-02-14 23:59:26 +05:30
deepak1556
d7fea1b484 REVIEW: fix possible -Wdeprecated-declarations warnings 2019-02-14 23:59:26 +05:30
Heilig Benedek
2ccf5904e0 chore: fix linking errors on Windows 2019-02-14 23:59:26 +05:30
Heilig Benedek
d7557cb66a chore: use c++ manifests instead of json 2019-02-14 23:59:26 +05:30
Heilig Benedek
cece8bce0b chore: make OSR compile on Windows 2019-02-14 23:59:26 +05:30
deepak1556
66db627913 Remove "layouttest" or "layout test" in //content
https://chromium-review.googlesource.com/c/chromium/src/+/1367391
2019-02-14 23:59:26 +05:30
deepak1556
76fde58e27 REVIEW: ui::Compositor: Simplify how ExternalBeginFrameClient is used.
https://chromium-review.googlesource.com/c/chromium/src/+/1388384
2019-02-14 23:59:26 +05:30
deepak1556
8a51c9c2f6 REVIEW: Have MouseWheelPhaseHandler agree on whether to route its wheel event
https://chromium-review.googlesource.com/c/chromium/src/+/1401664
2019-02-14 23:59:26 +05:30
deepak1556
e11589b5be ui/base: move clipboard to own folder.
https://chromium-review.googlesource.com/c/chromium/src/+/1369933
2019-02-14 23:59:25 +05:30
deepak1556
3727982217 Delete tab pulsing feature.
https://chromium-review.googlesource.com/c/chromium/src/+/1407958
2019-02-14 23:59:25 +05:30
deepak1556
70bbbb84bb Rename BlendTowardOppositeLuma() to BlendTowardContrastingEndpoint().
https://chromium-review.googlesource.com/c/chromium/src/+/1400060
2019-02-14 23:59:25 +05:30
Jeremy Apthorp
34d7e019ce gfx::Path -> SkPath
https://chromium-review.googlesource.com/c/1392181
2019-02-14 23:59:25 +05:30
deepak1556
a9ab4c5039 chore: roll 73.0.3683.10 2019-02-14 23:59:25 +05:30
deepak1556
005b7d8099 Print Preview: Add validity check for kSettingPagesPerSheet.
https://chromium-review.googlesource.com/c/chromium/src/+/1381133
2019-02-14 23:59:25 +05:30
deepak1556
510ca79ddd Enable DCHECK for renderer-initiated navigations requiring initiator.
https://chromium-review.googlesource.com/c/chromium/src/+/1385495
2019-02-14 23:59:24 +05:30
deepak1556
0545d47ca7 chore: roll node 2019-02-14 23:59:24 +05:30
deepak1556
86a94126fb Convert ProxyResolutionServiceProvider to use Network Service.
https://chromium-review.googlesource.com/c/chromium/src/+/1419264
2019-02-14 23:59:24 +05:30
deepak1556
035eee5c03 [OnionSoup] replace network::DataElement::Type with DataElementType
https://chromium-review.googlesource.com/c/chromium/src/+/1393106
2019-02-14 23:59:24 +05:30
deepak1556
1b982e200a Autoplay: remove cross-origin autoplay policy from //chrome and //content.
https://chromium-review.googlesource.com/c/chromium/src/+/1362225
2019-02-14 23:59:24 +05:30
deepak1556
10850808e9 chore: roll 73.0.3679.0 2019-02-14 23:59:24 +05:30
deepak1556
c2be0846c2 chore: rm fix_test_compilation_error.patch 2019-02-14 23:59:24 +05:30
deepak1556
1d21e9c35d Move client hints to content
https://chromium-review.googlesource.com/c/chromium/src/+/1376709
2019-02-14 23:59:23 +05:30
deepak1556
315f8c0cc7 DevToolsFrontendHost::Create to return unique_ptr instead of raw pointer
https://chromium-review.googlesource.com/c/chromium/src/+/1396614
2019-02-14 23:59:23 +05:30
deepak1556
9b82e7d27b Change DevToolsEmbedderMessageDispatcher to use unique_ptr instead of raw pointers.
https://chromium-review.googlesource.com/c/chromium/src/+/1382701
2019-02-14 23:59:23 +05:30
deepak1556
61c46c6313 Replace SiteInstance::IsSameWebSite() with a new non-static method.
https://chromium-review.googlesource.com/c/chromium/src/+/1352856
2019-02-14 23:59:23 +05:30
deepak1556
e4cfc52c29 Remove const interfaces from content::RenderProcessHost.
https://chromium-review.googlesource.com/c/chromium/src/+/1356004
2019-02-14 23:59:23 +05:30
deepak1556
3898a44e88 Increase scope of URLLoader::FollowRedirect() API implementation.
https://chromium-review.googlesource.com/c/chromium/src/+/1369856
2019-02-14 23:59:23 +05:30
deepak1556
547add94d0 Make //ui/base/idle API synchronous
https://chromium-review.googlesource.com/c/chromium/src/+/1379183
2019-02-14 23:59:23 +05:30
deepak1556
dd4a31633f split out color chooser browser dialog header
https://chromium-review.googlesource.com/c/chromium/src/+/1395146
2019-02-14 23:59:23 +05:30
deepak1556
52ef6d9ae4 [Printing] Stop using GetUserAgent from non-browser process
https://chromium-review.googlesource.com/c/chromium/src/+/1353052
2019-02-14 23:59:23 +05:30
deepak1556
0e39ec688a More migration of ServiceContext to ServiceBinding
https://chromium-review.googlesource.com/c/chromium/src/+/1357534
2019-02-14 23:59:22 +05:30
deepak1556
606c84b302 Blink: Plumb correct security origin for isolated world CSPs.
https://chromium-review.googlesource.com/c/chromium/src/+/1395190
2019-02-14 23:59:22 +05:30
deepak1556
2c282203b5 v8: Remove obsolete V8 extras flag
https://chromium-review.googlesource.com/c/chromium/src/+/1404554
2019-02-14 23:59:22 +05:30
deepak1556
1c4241bff5 Move BackgroundColor from widgets and child frames to the WebView.
https://chromium-review.googlesource.com/c/chromium/src/+/1382861
2019-02-14 23:59:22 +05:30
deepak1556
b2bd9ffd70 Downloads : Adding metered network info and retry count to download item
https://chromium-review.googlesource.com/c/chromium/src/+/1352628
2019-02-14 23:59:22 +05:30
deepak1556
e1502f6953 Move GetUserAgent from ContentClient to ContentBrowserClient
https://chromium-review.googlesource.com/c/chromium/src/+/1352086
2019-02-14 23:59:22 +05:30
deepak1556
abec938b0a Use base::size rather than arraysize
https://bugs.chromium.org/p/chromium/issues/detail?id=837308
2019-02-14 23:59:22 +05:30
deepak1556
a913e396d5 [SM] Use C++ Manifests for SM embedders
https://chromium-review.googlesource.com/c/chromium/src/+/1383530
2019-02-14 23:59:21 +05:30
deepak1556
79040e348a 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 23:59:21 +05:30
deepak1556
9439ac108d content: Fix WebContentsUserData for usage across components.
https://chromium-review.googlesource.com/c/chromium/src/+/1354402
2019-02-14 23:59:21 +05:30
deepak1556
a864167d46 Move MediaStream Mojo and public interfaces to Blink.
https://chromium-review.googlesource.com/c/chromium/src/+/1389998
2019-02-14 23:59:21 +05:30
deepak1556
92cfc4a62d fix: update deprecated v8 api usage 2019-02-14 23:59:21 +05:30
deepak1556
f09cb56f19 Refactors TtsPlatform and most platform implementations to content.
https://chromium-review.googlesource.com/c/chromium/src/+/1352055
2019-02-14 23:57:59 +05:30
deepak1556
fbefab4227 chore: update patches/common/ffmpeg 2019-02-14 23:57:59 +05:30
deepak1556
e517139e3c chore: update patches/common/v8 2019-02-14 23:57:58 +05:30
deepak1556
3f75724a31 chore: update patches/common/chromium 2019-02-14 23:57:58 +05:30
deepak1556
2752ae4ae8 chore: roll 73.0.3673.0 2019-02-14 23:57:58 +05:30
Milan Burda
e769b867f0 fix: disable Chromium v2 sandbox in MAS builds (#16920) 2019-02-14 09:48:17 -08:00
Shelley Vohr
de27911661 feat: promisify webContents.savePage() (#16742)
* feat: promisify webContents.savePage()

* no need to make compatible w callbacks, we're breaking it

* fix promise resolve type

* address feedback from review

* fix promise return text

* update smoke test
2019-02-14 09:03:28 -08:00
Jeremy Apthorp
6e7dca9082 chore: restore WTF::StringImpl dchecks (#15635) 2019-02-14 08:59:04 -08:00
Stewart Lord
84ef9cae6c fix: send chrome.runtime/tabs.sendMessage result to correct sender (#16945)
Additionally, use `.once` instead of `.on` for result specific listeners.
2019-02-14 06:07:55 -10:00
Samuel Attard
8497bb1327 fix: potential flake/race in webview specs (#16950) 2019-02-14 05:49:12 -10:00
Felix Rieseberg
31494dfade refactor: Port getRemote to TypeScript (#16938)
* chore: make aliasify work on .ts files as well

* refactor: Port getRemote to TypeScript

* refactor: Implement feedback <3
2019-02-14 04:04:53 -10:00
Felix Rieseberg
6cd75744ef refactor: Port window-setup to TS (#16894)
* refactor: Port window-setup to TS

* refactor: Make the linter happy

* refactor: Sneaky little TS error

* refactor: Correctly import window-setup

* refactor: Implement feedback <3

* refactor: Allow decorators in TS

* refactor: Use named windowSetup in isolatedRenderer

* refactor: Help TS understand

* refactor: Welp, use createEvent again

* refactor: Use the correct target in the decorator
2019-02-14 03:52:38 -10:00
Milan Burda
2492f0bcac refactor: promisify prototype methods (#16935) 2019-02-14 03:40:24 -10:00
Felix Rieseberg
9112ad01be refactor: Port renderer-internal-utils to TypeScript (#16942)
* chore: make aliasify work on .ts files as well

* refactor: Port renderer-internal-utils to TypeScript

* refactor: Implement feedback <3
2019-02-13 23:05:49 -08:00
Shelley Vohr
46a24c82ff feat: add Touch ID authentication support for macOS (#16707)
This PR adds Touch ID authentication support for macOS with two new `SystemPreferences` methods.

1. `systemPreferences.promptForTouchID()` returns a Promise that resolves with `true` if successful and rejects with an error message if authentication could not be completed.
2. `systemPreferences.isTouchIDAvailable()` returns a Boolean that's `true` if this device is a Mac running a supported OS that has the necessary hardware for Touch ID and `false` otherwise.
2019-02-13 18:36:28 -08:00
Stewart Lord
228805353f fix: pass result to chrome.tabs.executeScript callback (#16941)
* 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-13 17:00:36 -08:00
Shelley Vohr
319c2853df chore: move ts-smoke tests to core (#16930)
* chore: move ts smoke tests to core

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

* update ts-defs version

* do not lintr
2019-02-13 15:24:28 -08:00
Electron Bot
95214fcd4b Bump v6.0.0-nightly.20190213 2019-02-13 13:44:57 -08:00
Shelley Vohr
fed5b99a9f feat: promisify contentTracing.getTraceBufferUsage() (#16600)
* feat: promsify contentTracing.getTraceBufferUsage()

* deprecate getTraceBufferUsage

* address feedback from review

* properly deprecate
2019-02-13 13:24:57 -08:00
Julien Isorce
9b29befdc8 feat: disable fetching thumbnails if thumbnailSize is 0 (#14906)
Capturing window thmubnails is expensive as it actually uses the
window capturer and it records one full frame per window and then
downscale to the default size 150x150. When only interested in the
window names or the app icons we do not need all of this.

Underlying change is merged in chromium72 so this patch only modifies
the doc, see:
  https://chromium.googlesource.com/chromium/src.git/+log/72.0.3626.52/chrome/browser/media/webrtc/native_desktop_media_list.cc

Example: desktopCapturer.getSources({thumbnailSize: {width: 0, height: 0}}, ...)

Also added a unit test in spec/api-desktop-capturer-spec.js that verifies
that the returned thumbails are of type NativeImage and empty,
when the user disable fetching thumbnails.

notes: Can disable fetching the thumbnails for the DesktopCapturer.

https://github.com/electron/electron/issues/14872
2019-02-13 10:27:42 -08:00
Nitish Sakhawalkar
3dfef4a376 chore: Add new webFrame IsolatedWorldInfo API and deprecate (#16801)
* 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 08:05:28 -10:00
Milan Burda
1f458eb177 feat: promisify debugger.sendCommand() (#16861)
* remove duplicate entry for desktopCapturer.getSources

* feat: promisify debugger.sendCommand
2019-02-13 07:23:53 -10:00
Roller Bot
ee4c9aa3d0 chore: bump chromium in DEPS to 72.0.3626.110 (#16924) 2019-02-13 07:20:26 -10:00
Samuel Maddock
8f6a543398 feat: add chrome.runtime.getManifest (#16891)
* feat: add chrome.runtime.getManifest

* Add test for chrome.runtime.getManifest

* Use IPC utils for getManifest internals
2019-02-13 07:16:12 -10:00
John Kleinschmidt
46f818b0c3 feat: add file preview for GTK file picker (#16447) 2019-02-13 06:52:14 -10:00
Samuel Attard
c363eed543 chore: suppress output of npm_action unless it fails (#16888) 2019-02-12 21:32:47 -08:00
Roller Bot
6385608f7f chore: bump chromium in DEPS to 72.0.3626.108 (#16899) 2019-02-12 21:31:52 -08:00
Robo
1ed7b1c76d chore: remove obsolete v8 patches (#16910)
* patches/common/v8/disable-warning-win.patch
  added in https://github.com/electron/libchromiumcontent/pull/483
* patches/common/v8/ostreams.patch
  added in https://github.com/electron/libchromiumcontent/pull/258
2019-02-12 21:31:08 -08:00
Jeremy Apthorp
8d09219533 chore: 'breaking change' in PR body overrides commit type in relnotes (#16911) 2019-02-12 21:30:39 -08:00
Shelley Vohr
ca83d36426 feat: promisify app.dock.show() (#16904)
* feat: promisify app.dock.show

* add a spec
2019-02-12 21:06:33 -08:00
Samuel Attard
cd9bf72ee8 build: ensure that the uploaded symbol path is correct for our symbol (#16908)
server
2019-02-12 14:10:24 -08:00
Shelley Vohr
cfba59929a fix: backport patch to sync exposed crypto (#16822)
* fix: backport patch to sync exposed crypto

* add two new specs

* fix iv length

* fix formatting
2019-02-12 11:57:11 -08:00
Robo
5478cc7e8e chore: fix lint errors (#16906) 2019-02-13 00:19:47 +05:30
Electron Bot
98b05b8428 Bump v6.0.0-nightly.20190212 2019-02-12 10:09:30 -08:00
Shelley Vohr
bf276ecc69 feat: add new components to Display structure (#16870)
* feat: add new components to Display structure

* add internal property

* expose colorDepth

* add specs
2019-02-12 05:34:42 -10:00
Jeremy Apthorp
5a44cc50cf docs: migration guide for register{StandardSchemes => SchemesAsPrivileged} (#16762)
* docs: migration guide for register{StandardSchemes => SchemesAsPrivileged}

cc @nitsakh

* Update docs/api/protocol.md

Co-Authored-By: nornagon <nornagon@nornagon.net>

* Update docs/api/protocol.md

Co-Authored-By: nornagon <nornagon@nornagon.net>

* Update protocol.md

* Update docs/api/protocol.md

Co-Authored-By: nornagon <nornagon@nornagon.net>
2019-02-12 04:31:53 -10:00
Samuel Attard
01c442de64 refactor: convert more files to typescript (#16820) 2019-02-12 04:22:33 -10:00
Charles Kerr
cfbdc40814 fix: release-notes plays more nicely with clerk (#16887)
Explicitly look not just for Clerk's "notes persisted"
message but also its "no release notes" message.
2019-02-12 04:21:20 -10:00
Robo
83894dc5db ci: fix binaries for chromedriver build on macOS (#16893) 2019-02-12 16:14:52 +05:30
Roller Bot
deb36d5008 chore: bump chromium in DEPS to 72.0.3626.107 (#16869) 2019-02-11 17:56:03 -08:00
Electron Bot
8141a26ba9 Bump v6.0.0-nightly.20190211 2019-02-11 17:40:41 -08:00
Samuel Attard
9deaacb454 Revert "Bump v6.0.0-nightly.20190211"
This reverts commit c92233cbc8.
2019-02-11 14:23:46 -08:00
John Kleinschmidt
6a47089c78 ci: Refactor mksnapshot test so that it doesn't stall. (#16875) 2019-02-11 12:21:00 -10:00
Samuel Attard
7baa218ca9 docs: remove removed autosize attribute (#16884)
Closes #16199

Notes: no-notes
2019-02-11 14:15:15 -08:00
Electron Bot
c92233cbc8 Bump v6.0.0-nightly.20190211 2019-02-11 14:08:24 -08:00
Samuel Attard
20d9f4b2b5 Revert "Bump v6.0.0-nightly.20190211"
This reverts commit dc0be294dd.
2019-02-11 14:05:22 -08:00
Electron Bot
dc0be294dd Bump v6.0.0-nightly.20190211 2019-02-11 13:32:01 -08:00
Shelley Vohr
9dd3338ede chore: revert "Bump v6.0.0-nightly.20190208"
This reverts commit 70042d2597.
2019-02-11 13:22:44 -08:00
Milan Burda
d8ba1278d1 chore: disable the remote module in devtools / chrome extension background scripts (#16866)
* cache isRemoteModuleEnabled

* chore: disable the remote module in devtools / chrome extension background scripts
2019-02-11 10:42:37 -10:00
robertgrzonka
a3cdf46fb6 docs: change of previously wrong added Polish emoji into proper one (#16700)
* Change Polish flag

* Change of previously setuped flag of Monaco to Polish flag

* fix: change flags

* add Indonesian flag at former place
* append Polish flag at the end
2019-02-11 10:41:06 -10:00
Samuel Attard
5301808926 docs: reference the webviewTag option in the webview docs (#16879)
Closes #16773

Notes: Add a reference to the "webviewTag" option in the webview docs
2019-02-11 10:38:36 -10:00
Heilig Benedek
ccc60a1f33 fix: enable autofill popups on mac (#16308)
* 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-02-11 09:38:58 -10:00
Milan Burda
36ce3e9546 feat: promisify webContents.printToPDF() (#16795) 2019-02-11 09:20:04 -10:00
Shelley Vohr
3effa6f20c feat: add support for scroll lock accelerator (#16873) 2019-02-11 09:13:13 -10:00
Charles Kerr
d57b9cb47f chore: bump spec dependencies (#16872)
* bump dbus-native dependency

* semver/patch and semver/minor bumps

patch bumps for basic-auth, bluebird, graceful-fs.
minor bumps for chai, mocha-junit-reporter, multiparty, temp, walkdir.

* major bumps: ws, yargs

* sync spec/package-lock.json
2019-02-11 09:12:13 -10:00
Samuel Attard
90ebd8eb12 docs: document how setAsDefaultProtocolClient works in Windows Store (#16874)
Closes #16852
2019-02-11 10:51:46 -08:00
Milan Burda
c77e187742 chore: fix "creates offscreen window with correct size" spec on Mac with Retina display (#16867) 2019-02-11 10:35:46 -08:00
Milan Burda
7a3d220347 refactor: implement Chrome Extension APIs without the remote module (#16686)
* refactor: implement Chrome Extension APIs without the remote module

* remove unused potentiallyRemoteRequire
2019-02-10 10:38:14 -08:00
Shelley Vohr
1898f91620 fix: enable property having no effect on submenus (#16835) 2019-02-08 18:07:08 -08:00
Cheng Zhao
d16b581140 fix: remove memory leak when using webFrame and spell checker (#16770)
* 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 13:38:31 -08:00
Milan Burda
3f52e18a38 chore: add menu-will-close comment explaining setTimeout (#16794) 2019-02-08 13:38:03 -08:00
Electron Bot
70042d2597 Bump v6.0.0-nightly.20190208 2019-02-08 13:28:42 -08:00
Jeremy Apthorp
72f3a22ecc docs: reorder crashReporter notes to make more sense (#16825)
the note about reports from child processes on Windows should be next to the code snippet.

Side note: is that code even still necessary?
2019-02-08 13:26:59 -08:00
Shelley Vohr
c80c3c18dc Revert "Bump v6.0.0-nightly.20190207"
This reverts commit c8282efb75.
2019-02-08 13:26:18 -08:00
Samuel Attard
10607f7e86 chore: make crash-reporter specs not use URL module (#16840) 2019-02-08 13:22:07 -08:00
Shelley Vohr
ccf46a57bc fix: display empty menu item for non-visible submenus (#16832)
* fix: display empty menu item for nonvisible submenus

* use Chromium UI string ID
2019-02-08 13:19:01 -08:00
Shelley Vohr
062778c031 fix: don't construct submenu if it's invisible (#16834) 2019-02-08 12:54:39 -08:00
Samuel Attard
833daaa2b2 chore: add helper to wait for a window to load in a remote-safe way (#16837) 2019-02-08 12:26:03 -08:00
Milan Burda
1632c4b837 refactor: implement chrome.i18n.getMessage() without the remote module (#16739)
* refactor: implement chrome.i18n.getMessage() without the remote module

* replace navigator.language with app.getLocale()
2019-02-08 12:07:09 -08:00
Roller Bot
b97f6bd7d4 chore: bump chromium in DEPS to 72.0.3626.102 (#16830) 2019-02-08 10:36:37 -08:00
Samuel Attard
23b84917e0 ci: set MAS_BUILD=true on mas builds (#16824) 2019-02-08 10:12:18 -08:00
Shelley Vohr
e790dbd737 chore: add standalone function deprecation helper (#16782) 2019-02-08 09:50:11 -08:00
Electron Bot
c8282efb75 Bump v6.0.0-nightly.20190207 2019-02-07 14:13:50 -08:00
Julien Isorce
27bd47a333 feat: implement BrowserWindow.moveTop on X11 (#16629)
It was implemented on Mac and Win but not on X11.
Tested on Ubuntu 16.04 and 18.04.

Also added a unit test in spec/api-browser-window-spec.js.
This test BrowserWindow.moveTop verifies that calling moveTop
on a window does not give the focus to this window.

notes: BrowserWindow.moveTop is now available on Linux/x11

https://github.com/electron/electron/issues/12516
2019-02-07 12:48:19 -08:00
Samuel Attard
db11b9b13b fix: restore accidentally removed chrome-extension require (#16819) 2019-02-07 12:38:57 -08:00
Jeremy Apthorp
4989ecc5e0 chore: re-export chromium patches (#16818)
this is the changeset from running import-patches && export-patches. should be idempotent now.
2019-02-07 12:03:25 -08:00
Shelley Vohr
9ebba76c03 chore: improve existing error preservation in promisify (#16815)
This PR better preserves existing behavior in `deprecate.promisify()` in the cases where the promise fails. Previously, if a callback was only called with `data` instead of `err, data` and the promise was rejected, `data` would be populated with `err`, which could be confusing to users. This makes it such that `err` is called back on promise rejection if a callback is called with `err, data` a la Node.js.
2019-02-07 10:25:20 -08:00
Samuel Attard
4f8ebafa97 chore: dont log 100000000 chars of URL (#16800) 2019-02-07 08:50:47 -08:00
Shelley Vohr
29501dbd01 Revert "Bump v6.0.0-nightly.20190206"
This reverts commit e8608c2dbd.
2019-02-06 18:23:14 -08:00
Electron Bot
acabf6f5ab Bump v6.0.0-nightly.20190206 2019-02-06 16:52:57 -08:00
Shelley Vohr
c6fc5a23fc Revert "build: hack around GitHub upload API failure / flake (#16663)" (#16802)
This reverts commit ab503c7e43.
2019-02-06 16:51:45 -08:00
Shelley Vohr
c8a1231ad7 Revert "Bump v6.0.0-nightly.20190206"
This reverts commit 2d1438456b.
2019-02-06 16:23:08 -08:00
Jeremy Apthorp
6d68026c6c chore: fix ts config to not complain about extraneous files (#16790) 2019-02-06 15:46:10 -08:00
Electron Bot
2d1438456b Bump v6.0.0-nightly.20190206 2019-02-06 15:11:34 -08:00
Roller Bot
dd5264b4d1 chore: bump chromium in DEPS to 72.0.3626.99 (#16779) 2019-02-06 14:50:58 -08:00
Electron Bot
e8608c2dbd Bump v6.0.0-nightly.20190206 2019-02-06 14:43:32 -08:00
Shelley Vohr
a569dad8c5 build: remove non-arm vstsJobs (#16793) 2019-02-06 13:36:17 -08:00
Samuel Attard
17c240a639 ci: make macOS CI faster (#16766)
* ci: cache brew update result

* ci: checkout and sync the macOS build on a linux machine for speed
2019-02-06 13:16:11 -08:00
Samuel Attard
fc06458038 ci: run lint on CircleCI (#16791) 2019-02-06 12:53:25 -08:00
Shelley Vohr
84eef16755 chore: depend on mojo audio and video in BUILD.gn (#16785) 2019-02-06 11:03:39 -08:00
pol
c76459738e docs: fix security doc url check (#16775) 2019-02-06 10:43:58 -08:00
Gilbert Emerson
76d919fff5 docs: added webContents.getType() method (#16767)
* 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-06 10:42:34 -08:00
Samuel Attard
26df9992cf build: use typescript for internal Electron JS code (#16441) 2019-02-06 10:27:20 -08:00
Shelley Vohr
858781ba83 feat: allow Menu.buildFromTemplate() to accept MenuItems (#16697)
* feat: allow Menu.buildFromTemplate to accept MenuItems

* add another spec

* fix linter error

* add submenu spec
2019-02-06 10:04:40 -08:00
Milan Burda
4211a9c69f refactor: use ipcRendererUtils.invokeSync / ipcMainUtils.handleSync (#16759) 2019-02-06 09:53:28 -08:00
Jeremy Apthorp
b7d8234a86 docs: add some troubleshooting info related to win_delay_load_hook (#16764)
* docs: add some troubleshooting info related to win_delay_load_hook

* appease lint
2019-02-06 08:29:58 -08:00
Cheng Zhao
d53b51607c fix: do not increase ref-counting in wrong thread (#16738) 2019-02-06 18:22:02 +09:00
Heilig Benedek
ff461d9d26 fix: make getUserMedia APIs work again on C72+ (#16763)
* fix: resolve macos check for video and audio capture devices

* fix: resolve a minor compilation error
2019-02-05 21:25:42 -08:00
Jeremy Apthorp
b7afec0743 docs: improve app.commandLine documentation (#16757) 2019-02-05 16:22:25 -08:00
Shelley Vohr
8946cfd4f1 chore: fix dependency vulnerabilities (#16756) 2019-02-05 15:19:55 -08:00
Shelley Vohr
793d6c3691 chore: remove release notes semantic PR map (#16758) 2019-02-05 15:19:26 -08:00
Samuel Attard
b29e8d18a8 chore: auto-format GN and python files in our precommit (#16722)
* chore: auto-format GN files in our precommit

* chore: update python linting errors and auto-lint python files

* chore: add trick for CHROMIUM_BUILDTOOLS_PATH

* chore: apply suggestions from code review

Co-Authored-By: MarshallOfSound <samuel.r.attard@gmail.com>
2019-02-05 13:54:45 -08:00
Milan Burda
6d674eebb1 refactor: crashReporterInit (#16729) 2019-02-05 12:56:44 -08:00
Roller Bot
c486ab207a chore: bump chromium in DEPS to 72.0.3626.94 (#16745) 2019-02-05 12:17:12 -08:00
Samuel Attard
b202ad1e24 refactor: remove js2asar.py and port logic to JS in more readable / GN-style way (#16718)
* refactor: remove js2asar.py and port logic to JS in more readable / GN-style way

* refactor: further clean up ASAR impl, add new node_action GN template
2019-02-05 12:10:15 -08:00
Samuel Attard
8582325e85 build: ensure index.json is actually valid JSON before uploading (#16518)
* build: ensure index.json is actually valid JSON before uploading

* chore: fix py linting for validation of index.json
2019-02-05 11:36:31 -08:00
Jeremy Apthorp
9b7eb0eecb chore: update issue template, comment out instructions (#16721) 2019-02-05 10:10:24 -08:00
Shelley Vohr
e098d08728 docs: we shouldn't promisify net apis (#16736) 2019-02-04 22:25:59 -08:00
Shelley Vohr
f303caa87c refactor: remove ServiceWorker APIs from WebContents (#16717) 2019-02-04 22:22:46 -08:00
Roller Bot
3aa8ec0818 chore: bump chromium in DEPS to 72.0.3626.90 (#16710) 2019-02-04 16:25:53 -08:00
Cheng Zhao
758d709c7a fix: crash when calling setProgressBar on macOS (#16374)
* fix: correctly check whether dock has progress bar

* fix: do not leak memory when setting dockTile
2019-02-04 15:59:06 -08:00
Shelley Vohr
698d348168 feat: support capslock and numlock as accelerators (#16719)
* feat: support capslock as accelerator

* also add numlock
2019-02-04 15:54:59 -08:00
Shelley Vohr
f142aae9eb chore: remove unused variable in removeWindow (#16715) 2019-02-04 15:00:39 -08:00
Shelley Vohr
a9991f5451 chore: fix falsy comments edge case in release notes (#16720) 2019-02-04 14:57:38 -08:00
Samuel Attard
af64140100 refactor: enforce naming of ipcMainInternal (#16689) 2019-02-04 14:49:53 -08:00
JohanG2012
cacb56b103 Add missing let (#15746) 2019-02-04 11:02:01 -08:00
Birunthan Mohanathas
24f1eac84f docs: Recommend use of callback with dialog.showSaveDialog (#16649)
See #14606.

Notes: no-notes
2019-02-03 23:56:51 -08:00
John Kleinschmidt
0a047194b6 ci: move mac release tests to nightly cron job (#16685) 2019-02-01 15:07:23 -05:00
Milan Burda
7dc565fc2e refactor: implement inspector APIs without the remote module (#16607) 2019-02-01 19:56:46 +01:00
michtsu
392458b252 Add devtools API to inspect shared worker. (#16615) 2019-02-01 10:44:24 -08:00
Charles Kerr
efe52f66e4 fix: show proper clerk notes in release notes script (#16659)
* 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 10:31:03 -06:00
Xinayu
52952f7d51 Update menu.md (#16670) 2019-02-01 08:28:28 -08:00
Shelley Vohr
bae09643c1 docs: fix referrer typedef in OnCompletedDetails (#16661) 2019-02-01 07:54:31 -08:00
Cheng Zhao
31c7ed9b8c fix: shutdown after message loop is ready (#16671) 2019-02-01 10:21:49 -05:00
Samuel Attard
ab503c7e43 build: hack around GitHub upload API failure / flake (#16663) 2019-01-31 15:21:41 -08:00
Shelley Vohr
c8c1be7ae5 feat: add window removeMenu() method (#16570)
* feat: add window removeMenu() method

* chore: remove original method from docs and code

* retain backwards compatibility
2019-01-31 10:58:23 -08:00
John Kleinschmidt
2f35c98e76 ci: build mac on CircleCI (#16552) 2019-01-31 12:59:32 -05:00
John Kleinschmidt
d71f1fb30c ci: Run Windows Electron tests first to show those failures first (#16610)
* 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 12:39:05 -05:00
Birunthan Mohanathas
6c77c220f7 chore: Fix typo in AtomDownloadManagerDelegate::OnDownloadSaveDialogDone (#16646)
I believe the existing code was fine, but better be safe than sorry.
This typo was introduced in #16612.
2019-01-31 20:18:20 +09:00
Charles Kerr
76dcbcd6ea chore: fix 'browserView' typo (#16621) 2019-01-30 21:07:08 -08:00
Shelley Vohr
ba57e1d991 feat: promisify contentTracing recording APIs (#16584)
* feat: promisify contentTracing.startRecording()

* feat: promisify contentTracing.stopRecording()

* test: convert specs for new promisified apis

* chore: deprecate and ensure legacy tests work
2019-01-30 18:53:55 -08:00
Heilig Benedek
cbb5164cc8 fix: improve the way frameless windows are handled on Windows (#16596)
* fix: improve the way frameless windows are handled on Windows

* tidy up code

* fix: return nullAcceleratedWidget instead of nullptr

* fix: format, use reinterpret cast
2019-01-31 11:19:47 +09:00
Vladimir
49ec7e1582 feat: flexible autoresize for BrowserViews (#16184)
* feat: flexible autoresize for BrowserViews

* fix: change to static_cast

* Slight format code
2019-01-31 11:07:19 +09:00
Birunthan Mohanathas
927aac306f fix: use async save dialog for anchor download attribute (#16612) 2019-01-31 11:06:55 +09:00
Nitish Sakhawalkar
bd4e14dcee 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 12:54:18 -08:00
Shelley Vohr
641b47f384 feat: promisify contentTracing.getCategories() (#16583)
* feat: promisify contentTracing.getCategories()

* deprecate contentTracing/getCategories
2019-01-30 12:39:55 -08:00
Jeremy Apthorp
9ed89ace97 fix: expose aes-cfb ciphers from boringssl (#16573)
Ref #16195
2019-01-30 10:34:14 -08:00
Shelley Vohr
c7677b23e6 fix: enable and update osr (#16517)
* fix: enable OSR

* fix some macos errors

* fix client reset not in guard

* fix things not rendering on mac
2019-01-30 09:33:32 -08:00
Shelley Vohr
6e131f2121 docs: remove nonexistent contentTracing methods (#16597) 2019-01-30 08:33:56 -08:00
Milan Burda
dfcee48f81 fix: don't forward IPC filtering events to app for dev-tools and extensions (#16565) 2019-01-30 08:20:03 -08:00
Milan Burda
56c6a51cd2 chore: add miniak to troppers (#16590) 2019-01-29 22:21:38 -08:00
SamvelRaja
8af532ba98 feat: added process.electron to get the electron version in forked process (#16450) 2019-01-29 22:13:18 -08:00
Michael Hamilton
8da91523d0 Fixed a little typo (#16550) 2019-01-29 15:58:01 -08:00
Cheng Zhao
323b688ab8 fix: check the root window in MenuBar::SetPanelFocus (#16581) 2019-01-29 13:21:32 -08:00
Nitish Sakhawalkar
940c4c0787 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
2019-01-29 16:11:01 +09:00
Jeremy Apthorp
257de6a963 feat: add ELECTRON_DISABLE_SANDBOX env var (#16576) 2019-01-29 15:30:17 +09:00
Milan Burda
fa5442f211 fix: execute session preload scripts in sandboxed renderers (#16538) 2019-01-29 10:16:46 +09:00
Shelley Vohr
a25f82c91f fix: reject with error when url not loaded (#16571)
* fix: reject with error when url not loaded

* improve descriptive spec naming
2019-01-28 14:42:36 -08:00
Jeremy Apthorp
138ba53511 fix: expose ripemd160 hash from boringssl (#16454)
Ref #16195
2019-01-28 13:36:51 -08:00
Shelley Vohr
d105dcc0d3 feat: promisify webContents.hasServiceWorker() (#16535)
* feat: promisify contents.hasServiceWorker()

* spec: add initial test for hasServiceWorker()
2019-01-26 10:23:16 -08:00
Shelley Vohr
5a35c3a279 chore: fix promisify helper (#16544)
* chore: fix promise deprecation helper

* fix deprecations

* update deprecation tests
2019-01-25 14:23:24 -08:00
Jeremy Apthorp
63bf370cc0 fix: registerStreamProtocol callback with large chunks (#16532) 2019-01-25 10:57:26 -08:00
Charles Kerr
8396a2d504 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
2019-01-25 12:11:35 -06:00
Milan Burda
e2516dc808 docs: cancel is optional in OnHeadersReceivedResponse (#16506) 2019-01-25 09:41:21 -05:00
Shahzad Lone
74c29fb610 perf: and refactor: Code Scope + Minor Performance Improvement. (#16467)
* We know result's size will be same as app_metrics_'s size so optimize the vector.

Reserving a vector to save on reallocation cost.

* Narrow scopes of variables to avoid error and optimize them.

Made two vectors scope narrower and reserved them because we know the size in advance. This helps save on allocation costs.

* fix spacing
2019-01-25 09:39:32 -05:00
Sofia Nguy
b66b5561ee Electron timelines (#16496) 2019-01-24 16:40:44 -06:00
Milan Burda
713df08e3e chore: remove deprecated modules internally using remote.require in sandboxed renderer context (#15957) 2019-01-24 10:53:52 -08:00
Milan Burda
fef262f829 fix: check process.isMainFrame in sandboxed_renderer/init.js (#16500) 2019-01-24 10:53:16 -08:00
Nitish Sakhawalkar
e6952e2a16 fix: correctly destroy spellcheck client (#16448)
* fix: Destroy spellcheck client

* Address review comments
2019-01-24 08:18:54 -08:00
Tomas Rycl
1db4dd68a7 Troubleshooting for Windows Driver Kit (#16405) 2019-01-23 12:34:18 -08:00
Electron Bot
90151879cc Bump v6.0.0-nightly.20190123 2019-01-23 11:49:22 -08:00
Shelley Vohr
f431ce4971 build: fix individual asset downloading in release script (#16493)
* Revert "build: fix release asset download for now (#16486)"

This reverts commit 7df531bc4e.

* build: clean up asset downloading
2019-01-23 11:47:36 -08:00
Jeremy Apthorp
ad3ea6ec53 ci: re-enable logging on CI (#16257) 2019-01-23 11:28:34 -08:00
Milan Burda
cc90919384 refactor: pass internal flag via IPC message struct for consistency (#16490) 2019-01-23 08:24:57 -08:00
Alexey Kuzmin
0a5adfe365 build: fail a build if some hooks don't succeed (#16369) 2019-01-23 11:31:14 +01: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
1233 changed files with 53588 additions and 55352 deletions

File diff suppressed because it is too large Load Diff

7
.circleci/fix-known-hosts.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
set -e
mkdir -p ~/.ssh
echo "|1|B3r+7aO0/x90IdefihIjxIoJrrk=|OJddGDfhbuLFc1bUyy84hhIw57M= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
|1|rGlEvW55DtzNZp+pzw9gvyOyKi4=|LLWr+7qlkAlw3YGGVfLHHxB/kR0= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~/.ssh/known_hosts

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=

View File

@@ -1,12 +1,34 @@
{
"extends": "standard",
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"env": {
"browser": true
},
"rules": {
"no-var": "error",
"no-unused-vars": 0,
"no-global-assign": 0,
"@typescript-eslint/no-unused-vars": ["error", {
"vars": "all",
"args": "after-used",
"ignoreRestSiblings": false
}],
"prefer-const": ["error", {
"destructuring": "all"
}]
}
}],
"node/no-deprecated-api": 0
},
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"overrides": [
{
"files": "*.js",
"rules": {
"@typescript-eslint/no-unused-vars": "off"
}
}
]
}

27
.github/CODEOWNERS vendored
View File

@@ -3,19 +3,18 @@
# 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
# Docs & Tooling WG
/default_app/ @electron/wg-docs-tools
/docs/ @electron/wg-docs-tools
# Releases WG
/npm/ @electron/wg-releases

View File

@@ -1,38 +0,0 @@
<!--
Thanks for opening an issue! A few things to keep in mind:
- The issue tracker is only for bugs and feature requests.
- Before reporting a bug, please try reproducing your issue against
the latest version of Electron.
- If you need general advice, join our Slack: http://atom-slack.herokuapp.com
-->
* Output of `node_modules/.bin/electron --version`:
* Operating System (Platform and Version):
<!-- If this used to work -->
* Output of `node_modules/.bin/electron --version` on last known working Electron version (if applicable):
### Expected behavior
<!-- What do you think should happen? -->
### Actual behavior
<!-- What actually happens? -->
### How to reproduce
<!--
Your best chance of getting this bug looked at quickly is to provide a REPOSITORY that can be cloned and run.
You can fork https://github.com/electron/electron-quick-start and include a link to the branch with your changes.
If you provide a URL, please list the commands required to clone/setup/run your repo e.g.
$ git clone $YOUR_URL -b $BRANCH
$ npm install
$ npm start || electron .
-->

View File

@@ -4,29 +4,51 @@ about: Create a report to help us improve Electron
---
* Output of `node_modules/.bin/electron --version`:
* Operating System (Platform and Version):
* Output of `node_modules/.bin/electron --version` on last known working Electron version (if applicable):
<!-- As an open source project with a dedicated but small maintainer team, it can sometimes take a long time for issues to be addressed so please be patient and we will get back to you as soon as we can.
-->
**Expected Behavior**
A clear and concise description of what you expected to happen.
### Preflight Checklist
<!-- Please ensure you've completed the following steps by replacing [ ] with [x]-->
**Actual behavior**
A clear and concise description of what actually happened.
* [ ] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/master/CONTRIBUTING.md) for this project.
* [ ] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md) that this project adheres to.
* [ ] I have searched the issue tracker for an issue that matches the one I want to file, without success.
**To Reproduce**
### Issue Details
* **Electron Version:**
* <!-- (output of `node_modules/.bin/electron --version`) e.g. 4.0.3 -->
* **Operating System:**
* <!-- (Platform and Version) e.g. macOS 10.13.6 / Windows 10 (1803) / Ubuntu 18.04 x64 -->
* **Last Known Working Electron version:**:
* <!-- (if applicable) e.g. 3.1.0 -->
### Expected Behavior
<!-- A clear and concise description of what you expected to happen. -->
### Actual Behavior
<!-- A clear and concise description of what actually happened. -->
### To Reproduce
<!--
Your best chance of getting this bug looked at quickly is to provide a REPOSITORY that can be cloned and run.
-->
You can fork [electron-quick-start](https://github.com/electron/electron-quick-start) and include a link to the branch with your changes.
<!--
You can fork electron-quick-start (https://github.com/electron/electron-quick-start) and include a link to the branch with your changes.
-->
<!--
If you provide a URL, please list the commands required to clone/setup/run your repo e.g.
```sh
$ git clone $YOUR_URL -b $BRANCH
$ npm install
$ npm start || electron .
```
**Screenshots**
If applicable, add screenshots to help explain your problem.
-->
**Additional Information**
Add any other context about the problem here.
### Screenshots
<!-- If applicable, add screenshots to help explain your problem. -->
### Additional Information
<!-- Add any other context about the problem here. -->

View File

@@ -4,14 +4,24 @@ about: Suggest an idea for Electron
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is.
<!-- As an open source project with a dedicated but small maintainer team, it can sometimes take a long time for issues to be addressed so please be patient and we will get back to you as soon as we can.
-->
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
### Preflight Checklist
<!-- Please ensure you've completed the following steps by replacing [ ] with [x]-->
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
* [ ] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/master/CONTRIBUTING.md) for this project.
* [ ] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md) that this project adheres to.
* [ ] I have searched the issue tracker for a feature request that matches the one I want to file, without success.
**Additional context**
Add any other context or screenshots about the feature request here.
### Problem Description
<!-- Is your feature request related to a problem? Please add a clear and concise description of what the problem is. -->
### Proposed Solution
<!-- Describe the solution you'd like in a clear and concise manner -->
### Alternatives Considered
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
### Additional Information
<!-- Add any other context about the problem here. -->

View File

@@ -1,13 +0,0 @@
---
name: Mac App Store Private API Rejection
about: Your app was rejected from the Mac App Store for using private API's
---
* Electron Version:
**Rejection Email**
Paste the contents of your rejection email here, censoring any private information such as app names.
**Additional Information**
Add any other context about the problem here.

View File

@@ -0,0 +1,25 @@
---
name: Mac App Store Private API Rejection
about: Your app was rejected from the Mac App Store for using private API's
---
<!-- As an open source project with a dedicated but small maintainer team, it can sometimes take a long time for issues to be addressed so please be patient and we will get back to you as soon as we can.
-->
### Preflight Checklist
<!-- Please ensure you've completed the following steps by replacing [ ] with [x]-->
* [ ] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/master/CONTRIBUTING.md) for this project.
* [ ] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md) that this project adheres to.
### Issue Details
* **Electron Version:**
* <!-- (output of `node_modules/.bin/electron --version`) e.g. 4.0.3 -->
### Rejection Email
<!-- Paste the contents of your rejection email here, censoring any private information such as app names.-->
### Additional Information
<!-- Add any other context about the problem here. -->

View File

@@ -4,6 +4,7 @@ about: Do not create an issue for security reports, send an email to security@el
---
Do not create an issue for security reports, send an email to:
### Notice
security@electronjs.org
**DO NOT** create an issue for security reports.
Send an email to: **security@electronjs.org**.

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,8 @@ 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
##### Release Notes
<!-- Used to describe release notes for future release versions. See https://github.com/electron/clerk/blob/master/README.md for details. -->
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 -->

18
.github/config.yml vendored
View File

@@ -1,13 +1,3 @@
# Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome
# Comment to be posted to on first time issues
newIssueWelcomeComment: |
👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.
To help make it easier for us to investigate your issue, please follow the [contributing guidelines](https://github.com/electron/electron/blob/master/CONTRIBUTING.md).
# Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome
# Comment to be posted to on PRs from first time contributors in your repository
newPRWelcomeComment: |
💖 Thanks for opening this pull request! 💖
@@ -36,18 +26,16 @@ newPRWelcomeComment: |
firstPRMergeComment: >
Congrats on merging your first pull request! 🎉🎉🎉
# Configuration for trop - https://github.com/codebytere/trop
watchedProject:
name: Backports
# Users authorized to run manual trop backports
authorizedUsers:
- alexeykuzmin
- BinaryMuse
- ckerr
- codebytere
- deepak1556
- jkleinsc
- MarshallOfSound
- miniak
- nitsakh
- nornagon
- zcbenz

15
.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/
@@ -44,7 +37,7 @@
/vendor/pyyaml
node_modules/
SHASUMS256.txt
**/yarn.lock
**/package-lock.json
compile_commands.json
.envrc
@@ -63,3 +56,9 @@ spec/.hash
# Eslint Cache
.eslintcache
# Generated native addon files
/spec/fixtures/native-addon/echo/build/
# If someone runs tsc this is where stuff will end up
ts-gen

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

693
BUILD.gn

File diff suppressed because it is too large Load Diff

51
DEPS
View File

@@ -10,9 +10,9 @@ gclient_gn_args = [
vars = {
'chromium_version':
'69.0.3497.106',
'76.0.3809.54',
'node_version':
'5654c276d0497ff9a0bb0d7550b9073b2e2e7d3f',
'0a300f60bce0c8f0cb3d846fcb0e1f55f26013ee',
'boto_version': 'f7574aa6cc2c819430c1f05e9a1a1a666ef8169b',
'pyyaml_version': '3.12',
@@ -24,9 +24,22 @@ vars = {
'requests_git': 'https://github.com/kennethreitz',
'yaml_git': 'https://github.com/yaml',
# KEEP IN SYNC WITH spec-runner FILE
'yarn_version': '1.15.2',
# 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 +62,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("electron_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 +87,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 +102,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',
],
},
{
@@ -93,7 +110,7 @@ hooks = [
'action': [
'python',
'-c',
'import os; os.chdir("src"); os.chdir("electron"); os.system("npm install")',
'import os, subprocess; os.chdir(os.path.join("src", "electron")); subprocess.check_call(["python", "script/lib/npx.py", "yarn@' + (Var("yarn_version")) + '", "install", "--frozen-lockfile"]);',
],
},
{
@@ -103,7 +120,7 @@ hooks = [
'action': [
'python',
'-c',
'import os; os.chdir("src"); os.chdir("electron"); os.chdir("vendor"); os.chdir("boto"); os.system("python setup.py build");',
'import os, subprocess; os.chdir(os.path.join("src", "electron", "vendor", "boto")); subprocess.check_call(["python", "setup.py", "build"]);',
],
},
{
@@ -113,9 +130,9 @@ hooks = [
'action': [
'python',
'-c',
'import os; os.chdir("src"); os.chdir("electron"); os.chdir("vendor"); os.chdir("requests"); os.system("python setup.py build");',
'import os, subprocess; os.chdir(os.path.join("src", "electron", "vendor", "requests")); subprocess.check_call(["python", "setup.py", "build"]);',
],
}
},
]
recursedeps = [

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 @@
6.0.0-beta.12

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,10 +3,11 @@
[![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/)
:memo: Available Translations: 🇨🇳 🇹🇼 🇧🇷 🇪🇸 🇰🇷 🇯🇵 🇷🇺 🇫🇷 🇹🇭 🇳🇱 🇹🇷 🇮🇩 🇺🇦 🇨🇿 🇮🇹.
:memo: Available Translations: 🇨🇳 🇹🇼 🇧🇷 🇪🇸 🇰🇷 🇯🇵 🇷🇺 🇫🇷 🇹🇭 🇳🇱 🇹🇷 🇮🇩 🇺🇦 🇨🇿 🇮🇹 🇵🇱.
View these docs in other languages at [electron/i18n](https://github.com/electron/i18n/tree/master/content/).
The Electron framework lets you write cross-platform desktop applications

View File

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

View File

@@ -1,10 +1,35 @@
# 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
image: libcc-20-vs2017-15.9
environment:
GIT_CACHE_PATH: C:\Users\electron\libcc_cache
DISABLE_CRASH_REPORTER_TESTS: true
ELECTRON_OUT_DIR: Default
ELECTRON_ENABLE_STACK_DUMPING: 1
build_script:
- ps: >-
if(($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME -split "/")[0] -eq ($env:APPVEYOR_REPO_NAME -split "/")[0]) {
@@ -13,7 +38,7 @@ build_script:
- echo "Building $env:GN_CONFIG build"
- git config --global core.longpaths true
- cd ..
- md src
- ps: if (Test-Path src\electron) { Remove-Item src\electron -Recurse }
- ps: Move-Item $env:APPVEYOR_BUILD_FOLDER -Destination src\electron
- ps: $env:CHROMIUM_BUILDTOOLS_PATH="$pwd\src\buildtools"
- ps: $env:SCCACHE_PATH="$pwd\src\electron\external_binaries\sccache.exe"
@@ -27,9 +52,14 @@ build_script:
--unmanaged
%GCLIENT_EXTRA_ARGS%
"https://github.com/electron/electron"
- gclient sync --with_branch_heads --with_tags
- gclient sync --with_branch_heads --with_tags --reset
- 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%"
- gn check out/Default //electron:electron_lib
- gn check out/Default //electron:electron_app
- gn check out/Default //electron:manifests
- gn check out/Default //electron/atom/common/api:mojo
- 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
@@ -44,18 +74,19 @@ build_script:
if ($env:GN_CONFIG -eq 'release') {
ninja -C out/Default third_party/breakpad:dump_syms
}
- if "%GN_CONFIG%"=="release" ( python electron\script\dump-symbols.py -d %cd%\out\Default\electron.breakpad.syms -v)
- if "%GN_CONFIG%"=="release" ( python electron\script\dump-symbols.py -d %cd%\out\Default\breakpad_symbols -v)
- ps: >-
if ($env:GN_CONFIG -eq 'release') {
python electron\script\zip-symbols.py
appveyor PushArtifact out/Default/symbols.zip
}
test_script:
# Workaround for https://github.com/appveyor/ci/issues/2420
- set "PATH=%PATH%;C:\Program Files\Git\mingw64\libexec\git-core"
- 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 +95,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(
@@ -250,4 +268,8 @@ void AtomContentClient::AddContentDecryptionModules(
}
}
bool AtomContentClient::IsDataResourceGzipped(int resource_id) const {
return ui::ResourceBundle::GetSharedInstance().IsGzipped(resource_id);
}
} // namespace atom

View File

@@ -9,26 +9,29 @@
#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;
void AddContentDecryptionModules(
std::vector<content::CdmInfo>* cdms,
std::vector<media::CdmHostFilePath>* cdm_host_file_paths) override;
bool IsDataResourceGzipped(int resource_id) const override;
private:
DISALLOW_COPY_AND_ASSIGN(AtomContentClient);

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

@@ -4,7 +4,9 @@
#include "atom/app/atom_main.h"
#include <algorithm>
#include <cstdlib>
#include <memory>
#include <vector>
#if defined(OS_WIN)
@@ -24,26 +26,32 @@
#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)
#include "atom/app/node_main.h"
#include "atom/common/atom_command_line.h"
#include "atom/common/atom_constants.h"
#include "base/at_exit.h"
#include "base/i18n/icu_util.h"
#include "electron/buildflags/buildflags.h"
namespace {
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
const char kRunAsNode[] = "ELECTRON_RUN_AS_NODE";
#if defined(HELPER_EXECUTABLE) && !defined(MAS_BUILD)
#include "sandbox/mac/seatbelt_exec.h" // nogncheck
#endif
bool IsEnvSet(const char* name) {
namespace {
ALLOW_UNUSED_TYPE bool IsEnvSet(const char* name) {
#if defined(OS_WIN)
size_t required_size;
getenv_s(&required_size, nullptr, 0, name);
@@ -54,9 +62,33 @@ 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)
namespace crash_reporter {
extern const char kCrashpadProcess[];
}
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
struct Arguments {
int argc = 0;
@@ -93,7 +125,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
#endif
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
bool run_as_node = IsEnvSet(kRunAsNode);
bool run_as_node = IsEnvSet(atom::kRunAsNode);
#else
bool run_as_node = false;
#endif
@@ -119,13 +151,11 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
atexit([]() { OnThreadExit(nullptr, DLL_THREAD_DETACH, nullptr); });
#endif
std::vector<char*> argv(arguments.argc);
std::transform(arguments.argv, arguments.argv + arguments.argc, argv.begin(),
[](auto& a) { return _strdup(base::WideToUTF8(a).c_str()); });
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
if (run_as_node) {
std::vector<char*> argv(arguments.argc);
std::transform(
arguments.argv, arguments.argv + arguments.argc, argv.begin(),
[](auto& a) { return _strdup(base::WideToUTF8(a).c_str()); });
base::AtExitManager atexit_manager;
base::i18n::InitializeICU();
auto ret = atom::NodeMain(argv.size(), argv.data());
@@ -134,8 +164,11 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
}
#endif
if (IsEnvSet("ELECTRON_INTERNAL_CRASH_SERVICE")) {
return crash_service::Main(cmd);
base::CommandLine::Init(argv.size(), argv.data());
const base::CommandLine& cmd_line = *base::CommandLine::ForCurrentProcess();
if (cmd_line.GetSwitchValueASCII("type") ==
crash_reporter::kCrashpadProcess) {
return crash_service::Main(&argv);
}
if (!atom::CheckCommandLineArguments(arguments.argc, arguments.argv))
@@ -155,8 +188,10 @@ 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)) {
if (IsEnvSet(atom::kRunAsNode)) {
base::i18n::InitializeICU();
base::AtExitManager atexit_manager;
return atom::NodeMain(argc, argv);
@@ -174,12 +209,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)) {
if (IsEnvSet(atom::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
@@ -39,6 +47,13 @@
#include "atom/app/atom_main_delegate_mac.h"
#endif
#if defined(OS_WIN)
#include "base/win/win_util.h"
#if defined(_WIN64)
#include "atom/common/crash_reporter/crash_reporter_win.h"
#endif
#endif
namespace atom {
namespace {
@@ -50,6 +65,25 @@ bool IsBrowserProcess(base::CommandLine* cmd) {
return process_type.empty();
}
// 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 +96,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() {}
@@ -71,6 +136,10 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
logging::LoggingSettings settings;
#if defined(OS_WIN)
#if defined(_WIN64)
crash_reporter::CrashReporterWin::SetUnhandledExceptionFilter();
#endif
// On Windows the terminal returns immediately, so we add a new line to
// prevent output in the same line as the prompt.
if (IsBrowserProcess(command_line))
@@ -82,10 +151,12 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
settings.lock_log = logging::LOCK_LOG_FILE;
settings.delete_old = logging::DELETE_OLD_LOG_FILE;
#else
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
settings.logging_dest =
logging::LOG_TO_SYSTEM_DEBUG_LOG | logging::LOG_TO_STDERR;
#endif // defined(DEBUG)
#else // defined(OS_WIN)
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
settings.logging_dest =
logging::LOG_TO_SYSTEM_DEBUG_LOG | logging::LOG_TO_STDERR;
#endif // !defined(OS_WIN)
// Only enable logging when --enable-logging is specified.
@@ -101,23 +172,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
@@ -127,32 +194,65 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
// Disable the ActiveVerifier, which is used by Chrome to track possible
// bugs, but no use in Electron.
base::win::DisableHandleVerifier();
if (IsBrowserProcess(command_line))
base::win::PinUser32();
#endif
return brightray::MainDelegate::BasicStartupComplete(exit_code);
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 +262,7 @@ void AtomMainDelegate::PreSandboxStartup() {
#endif
}
void AtomMainDelegate::PreContentInitialization() {
void AtomMainDelegate::PreCreateMainMessageLoop() {
#if defined(OS_MACOSX)
RegisterAtomCrApp();
#endif
@@ -212,9 +312,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"];

65
atom/app/manifests.cc Normal file
View File

@@ -0,0 +1,65 @@
// 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 "electron/atom/common/api/api.mojom.h"
#include "printing/buildflags/buildflags.h"
#include "services/proxy_resolver/public/cpp/manifest.h"
#include "services/service_manager/public/cpp/manifest_builder.h"
#if BUILDFLAG(ENABLE_PRINTING)
#include "components/services/pdf_compositor/public/cpp/manifest.h"
#endif
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/services/printing/public/cpp/manifest.h"
#endif
namespace {
// TODO(https://crbug.com/781334): Remove these helpers and just update the
// manifest definitions to be marked out-of-process. This is here only to avoid
// extra churn when transitioning away from content_packaged_services.
service_manager::Manifest MakeOutOfProcess(
const service_manager::Manifest& manifest) {
// cpplint.py emits a false positive [build/include_what_you_use]
service_manager::Manifest copy(manifest); // NOLINT
copy.options.execution_mode =
service_manager::Manifest::ExecutionMode::kOutOfProcessBuiltin;
return copy;
}
} // namespace
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")
.ExposeInterfaceFilterCapability_Deprecated(
"navigation:frame", "renderer",
service_manager::Manifest::InterfaceList<
atom::mojom::ElectronBrowser>())
.Build()};
return *manifest;
}
const std::vector<service_manager::Manifest>&
GetElectronBuiltinServiceManifests() {
static base::NoDestructor<std::vector<service_manager::Manifest>> manifests{{
MakeOutOfProcess(proxy_resolver::GetManifest()),
#if BUILDFLAG(ENABLE_PRINTING)
MakeOutOfProcess(printing::GetPdfCompositorManifest()),
#endif
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
MakeOutOfProcess(GetChromePrintingManifest()),
#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>&
GetElectronBuiltinServiceManifests();
#endif // ATOM_APP_MANIFESTS_H_

View File

@@ -10,20 +10,24 @@
#include "atom/app/uv_task_runner.h"
#include "atom/browser/javascript_environment.h"
#include "atom/browser/node_debugger.h"
#include "atom/common/api/atom_bindings.h"
#include "atom/common/api/electron_bindings.h"
#include "atom/common/atom_version.h"
#include "atom/common/crash_reporter/crash_reporter.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/node_bindings.h"
#include "atom/common/node_includes.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/task_scheduler/task_scheduler.h"
#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread_task_runner_handle.h"
#include "gin/array_buffer.h"
#include "gin/public/isolate_holder.h"
#include "gin/v8_initializer.h"
#include "native_mate/dictionary.h"
#include "atom/common/node_includes.h"
#if defined(_WIN64)
#include "atom/common/crash_reporter/crash_reporter_win.h"
#endif
namespace atom {
@@ -48,10 +52,13 @@ int NodeMain(int argc, char* argv[]) {
gin::V8Initializer::LoadV8Natives();
// V8 requires a task scheduler apparently
base::TaskScheduler::CreateAndStartWithDefaultParams("Electron");
base::ThreadPoolInstance::CreateAndStartWithDefaultParams("Electron");
// Initialize gin::IsolateHolder.
JavascriptEnvironment gin_env(loop);
#if defined(_WIN64)
crash_reporter::CrashReporterWin::SetUnhandledExceptionFilter();
#endif
// Explicitly register electron's builtin modules.
NodeBindings::RegisterBuiltinModules();
@@ -70,15 +77,20 @@ int NodeMain(int argc, char* argv[]) {
mate::Dictionary process(gin_env.isolate(), env->process_object());
#if defined(OS_WIN)
process.SetMethod("log", &AtomBindings::Log);
process.SetMethod("log", &ElectronBindings::Log);
#endif
process.SetMethod("crash", &AtomBindings::Crash);
process.SetMethod("crash", &ElectronBindings::Crash);
// Setup process.crashReporter.start in child node processes
auto reporter = mate::Dictionary::CreateEmpty(gin_env.isolate());
reporter.SetMethod("start", &crash_reporter::CrashReporter::StartInstance);
process.Set("crashReporter", reporter);
mate::Dictionary versions;
if (process.Get("versions", &versions)) {
versions.SetReadOnly(ATOM_PROJECT_NAME, ATOM_VERSION_STRING);
}
node::LoadEnvironment(env);
bool more;
@@ -96,6 +108,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());
@@ -107,10 +120,10 @@ int NodeMain(int argc, char* argv[]) {
// According to "src/gin/shell/gin_main.cc":
//
// gin::IsolateHolder waits for tasks running in TaskScheduler in its
// destructor and thus must be destroyed before TaskScheduler starts skipping
// gin::IsolateHolder waits for tasks running in ThreadPool in its
// destructor and thus must be destroyed before ThreadPool starts skipping
// CONTINUE_ON_SHUTDOWN tasks.
base::TaskScheduler::GetInstance()->Shutdown();
base::ThreadPoolInstance::Get()->Shutdown();
v8::V8::Dispose();

View File

@@ -13,8 +13,10 @@
#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/application_info.h"
#include "atom/common/atom_command_line.h"
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
@@ -30,14 +32,12 @@
#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"
#include "content/browser/gpu/compositor_util.h"
#include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/gpu/compositor_util.h" // nogncheck
#include "content/browser/gpu/gpu_data_manager_impl.h" // nogncheck
#include "content/public/browser/browser_accessibility_state.h"
#include "content/public/browser/browser_child_process_host.h"
#include "content/public/browser/child_process_data.h"
@@ -49,7 +49,6 @@
#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"
@@ -60,6 +59,7 @@
#endif
#if defined(OS_MACOSX)
#include <CoreFoundation/CoreFoundation.h>
#include "atom/browser/ui/cocoa/atom_bundle_mover.h"
#endif
@@ -84,6 +84,7 @@ struct Converter<Browser::UserTask> {
return false;
dict.Get("arguments", &(out->arguments));
dict.Get("description", &(out->description));
dict.Get("workingDirectory", &(out->working_dir));
return true;
}
};
@@ -157,6 +158,7 @@ struct Converter<JumpListItem> {
dict.Get("args", &(out->arguments));
dict.Get("description", &(out->description));
dict.Get("workingDirectory", &(out->working_dir));
return true;
case JumpListItem::Type::SEPARATOR:
@@ -183,6 +185,7 @@ struct Converter<JumpListItem> {
dict.Set("iconPath", val.icon_path);
dict.Set("iconIndex", val.icon_index);
dict.Set("description", val.description);
dict.Set("workingDirectory", val.working_dir);
break;
case JumpListItem::Type::SEPARATOR:
@@ -390,15 +393,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 +532,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);
if (icon && !icon->IsEmpty()) {
callback.Run(v8::Null(isolate), *icon);
void OnIconDataAvailable(util::Promise promise, gfx::Image icon) {
if (!icon.IsEmpty()) {
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,8 +674,8 @@ 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),
request_details, login_handler->auth_info(),
"login", WebContents::FromOrCreate(isolate(), web_contents),
request_details, *login_handler->auth_info(),
base::Bind(&PassLoginInformation, base::RetainedRef(login_handler)));
}
@@ -692,7 +688,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 +705,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;
@@ -722,7 +721,7 @@ void App::AllowCertificateError(
int cert_error,
const net::SSLInfo& ssl_info,
const GURL& request_url,
content::ResourceType resource_type,
bool is_main_frame_request,
bool strict_enforcement,
bool expired_previous_decision,
const base::Callback<void(content::CertificateRequestResultType)>&
@@ -730,7 +729,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 +756,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 +778,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) {
@@ -835,6 +834,26 @@ void App::SetAppPath(const base::FilePath& app_path) {
app_path_ = app_path;
}
#if !defined(OS_MACOSX)
void App::SetAppLogsPath(mate::Arguments* args) {
base::FilePath custom_path;
if (args->GetNext(&custom_path)) {
if (!custom_path.IsAbsolute()) {
args->ThrowError("Path must be absolute");
return;
}
base::PathService::Override(DIR_APP_LOGS, custom_path);
} else {
base::FilePath path;
if (base::PathService::Get(DIR_USER_DATA, &path)) {
path = path.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName()));
path = path.Append(base::FilePath::FromUTF8Unsafe("logs"));
base::PathService::Override(DIR_APP_LOGS, path);
}
}
}
#endif
base::FilePath App::GetPath(mate::Arguments* args, const std::string& name) {
bool succeed = false;
base::FilePath path;
@@ -874,6 +893,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 +948,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 +1034,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();
@@ -994,7 +1059,7 @@ Browser::LoginItemSettings App::GetLoginItemSettings(mate::Arguments* args) {
#if defined(USE_NSS_CERTS)
void App::ImportCertificate(const base::DictionaryValue& options,
const net::CompletionCallback& callback) {
net::CompletionRepeatingCallback callback) {
auto browser_context = AtomBrowserContext::From("", false);
if (!certificate_manager_model_) {
auto copy = base::DictionaryValue::From(
@@ -1007,17 +1072,17 @@ void App::ImportCertificate(const base::DictionaryValue& options,
}
int rv = ImportIntoCertStore(certificate_manager_model_.get(), options);
callback.Run(rv);
std::move(callback).Run(rv);
}
void App::OnCertificateManagerModelCreated(
std::unique_ptr<base::DictionaryValue> options,
const net::CompletionCallback& callback,
net::CompletionOnceCallback callback,
std::unique_ptr<CertificateManagerModel> model) {
certificate_manager_model_ = std::move(model);
int rv =
ImportIntoCertStore(certificate_manager_model_.get(), *(options.get()));
callback.Run(rv);
std::move(callback).Run(rv);
}
#endif
@@ -1077,16 +1142,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,26 +1158,23 @@ 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) {
std::vector<mate::Dictionary> result;
result.reserve(app_metrics_.size());
int processor_count = base::SysInfo::NumberOfProcessors();
for (const auto& process_metric : app_metrics_) {
@@ -1158,30 +1218,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,17 +1271,19 @@ 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;
}
void App::SetUserAgentFallback(const std::string& user_agent) {
AtomBrowserClient::Get()->SetUserAgent(user_agent);
}
auto* command_line = base::CommandLine::ForCurrentProcess();
RemoveNoSandboxSwitch(command_line);
command_line->AppendSwitch(switches::kEnableMixedSandbox);
std::string App::GetUserAgentFallback() {
return AtomBrowserClient::Get()->GetUserAgent();
}
void App::SetBrowserClientCanUseCustomSiteInstance(bool should_disable) {
AtomBrowserClient::Get()->SetCanUseCustomSiteInstance(should_disable);
}
bool App::CanBrowserClientUseCustomSiteInstance() {
return AtomBrowserClient::Get()->CanUseCustomSiteInstance();
}
#if defined(OS_MACOSX)
@@ -1232,6 +1294,46 @@ bool App::MoveToApplicationsFolder(mate::Arguments* args) {
bool App::IsInApplicationsFolder() {
return ui::cocoa::AtomBundleMover::IsCurrentAppInApplicationsFolder();
}
int DockBounce(const std::string& type) {
int request_id = -1;
if (type == "critical")
request_id = Browser::Get()->DockBounce(Browser::BOUNCE_CRITICAL);
else if (type == "informational")
request_id = Browser::Get()->DockBounce(Browser::BOUNCE_INFORMATIONAL);
return request_id;
}
void DockSetMenu(atom::api::Menu* menu) {
Browser::Get()->DockSetMenu(menu->model());
}
v8::Local<v8::Value> App::GetDockAPI(v8::Isolate* isolate) {
if (dock_.IsEmpty()) {
// Initialize the Dock API, the methods are bound to "dock" which exists
// for the lifetime of "app"
auto browser = base::Unretained(Browser::Get());
mate::Dictionary dock_obj = mate::Dictionary::CreateEmpty(isolate);
dock_obj.SetMethod("bounce", &DockBounce);
dock_obj.SetMethod("cancelBounce",
base::Bind(&Browser::DockCancelBounce, browser));
dock_obj.SetMethod("downloadFinished",
base::Bind(&Browser::DockDownloadFinished, browser));
dock_obj.SetMethod("setBadge",
base::Bind(&Browser::DockSetBadgeText, browser));
dock_obj.SetMethod("getBadge",
base::Bind(&Browser::DockGetBadgeText, browser));
dock_obj.SetMethod("hide", base::Bind(&Browser::DockHide, browser));
dock_obj.SetMethod("show", base::Bind(&Browser::DockShow, browser));
dock_obj.SetMethod("isVisible",
base::Bind(&Browser::DockIsVisible, browser));
dock_obj.SetMethod("setMenu", &DockSetMenu);
dock_obj.SetMethod("setIcon", base::Bind(&Browser::DockSetIcon, browser));
dock_.Reset(isolate, dock_obj.GetHandle());
}
return v8::Local<v8::Value>::New(isolate, dock_);
}
#endif
// static
@@ -1271,6 +1373,8 @@ void App::BuildPrototype(v8::Isolate* isolate,
.SetMethod("getLoginItemSettings", &App::GetLoginItemSettings)
.SetMethod("setLoginItemSettings",
base::Bind(&Browser::SetLoginItemSettings, browser))
.SetMethod("isEmojiPanelSupported",
base::Bind(&Browser::IsEmojiPanelSupported, browser))
#if defined(OS_MACOSX)
.SetMethod("hide", base::Bind(&Browser::Hide, browser))
.SetMethod("show", base::Bind(&Browser::Show, browser))
@@ -1282,8 +1386,22 @@ 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_MACOSX) || defined(OS_WIN)
.SetMethod("showEmojiPanel",
base::Bind(&Browser::ShowEmojiPanel, browser))
.SetProperty("accessibilitySupportEnabled",
&App::IsAccessibilitySupportEnabled,
&App::SetAccessibilitySupportEnabled)
#endif
#if defined(OS_WIN)
.SetMethod("setUserTasks", base::Bind(&Browser::SetUserTasks, browser))
@@ -1298,8 +1416,10 @@ void App::BuildPrototype(v8::Isolate* isolate,
.SetMethod("getAppPath", &App::GetAppPath)
.SetMethod("setPath", &App::SetPath)
.SetMethod("getPath", &App::GetPath)
.SetMethod("setAppLogsPath", &App::SetAppLogsPath)
.SetMethod("setDesktopName", &App::SetDesktopName)
.SetMethod("getLocale", &App::GetLocale)
.SetMethod("getLocaleCountryCode", &App::GetLocaleCountryCode)
#if defined(USE_NSS_CERTS)
.SetMethod("importCertificate", &App::ImportCertificate)
#endif
@@ -1307,9 +1427,9 @@ void App::BuildPrototype(v8::Isolate* isolate,
.SetMethod("requestSingleInstanceLock", &App::RequestSingleInstanceLock)
.SetMethod("releaseSingleInstanceLock", &App::ReleaseSingleInstanceLock)
.SetMethod("relaunch", &App::Relaunch)
.SetMethod("isAccessibilitySupportEnabled",
.SetMethod("_isAccessibilitySupportEnabled",
&App::IsAccessibilitySupportEnabled)
.SetMethod("setAccessibilitySupportEnabled",
.SetMethod("_setAccessibilitySupportEnabled",
&App::SetAccessibilitySupportEnabled)
.SetMethod("disableHardwareAcceleration",
&App::DisableHardwareAcceleration)
@@ -1319,17 +1439,19 @@ 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
#if defined(OS_MACOSX)
.SetProperty("dock", &App::GetDockAPI)
#endif
.SetProperty("userAgentFallback", &App::GetUserAgentFallback,
&App::SetUserAgentFallback)
.SetMethod("enableSandbox", &App::EnableSandbox)
.SetMethod("enableMixedSandbox", &App::EnableMixedSandbox);
.SetProperty("allowRendererProcessReuse",
&App::CanBrowserClientUseCustomSiteInstance,
&App::SetBrowserClientCanUseCustomSiteInstance);
}
} // namespace api
@@ -1338,72 +1460,18 @@ 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;
if (type == "critical")
request_id = Browser::Get()->DockBounce(Browser::BOUNCE_CRITICAL);
else if (type == "informational")
request_id = Browser::Get()->DockBounce(Browser::BOUNCE_INFORMATIONAL);
return request_id;
}
void DockSetMenu(atom::api::Menu* menu) {
Browser::Get()->DockSetMenu(menu->model());
}
#endif
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
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);
dict.SetMethod("dockCancelBounce",
base::Bind(&Browser::DockCancelBounce, browser));
dict.SetMethod("dockDownloadFinished",
base::Bind(&Browser::DockDownloadFinished, browser));
dict.SetMethod("dockSetBadgeText",
base::Bind(&Browser::DockSetBadgeText, browser));
dict.SetMethod("dockGetBadgeText",
base::Bind(&Browser::DockGetBadgeText, browser));
dict.SetMethod("dockHide", base::Bind(&Browser::DockHide, browser));
dict.SetMethod("dockShow", base::Bind(&Browser::DockShow, browser));
dict.SetMethod("dockIsVisible", base::Bind(&Browser::DockIsVisible, browser));
dict.SetMethod("dockSetMenu", &DockSetMenu);
dict.SetMethod("dockSetIcon", base::Bind(&Browser::DockSetIcon, browser));
#endif
}
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_app, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_app, Initialize)

View File

@@ -18,6 +18,7 @@
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/promise_util.h"
#include "base/process/process_iterator.h"
#include "base/process/process_metrics.h"
#include "base/task/cancelable_task_tracker.h"
#include "chrome/browser/icon_manager.h"
#include "chrome/browser/process_singleton.h"
@@ -26,7 +27,8 @@
#include "content/public/browser/render_process_host.h"
#include "native_mate/dictionary.h"
#include "native_mate/handle.h"
#include "net/base/completion_callback.h"
#include "net/base/completion_once_callback.h"
#include "net/base/completion_repeating_callback.h"
#include "net/ssl/client_cert_identity.h"
#if defined(USE_NSS_CERTS)
@@ -77,7 +79,7 @@ class App : public AtomBrowserClient::Delegate,
#if defined(USE_NSS_CERTS)
void OnCertificateManagerModelCreated(
std::unique_ptr<base::DictionaryValue> options,
const net::CompletionCallback& callback,
net::CompletionOnceCallback callback,
std::unique_ptr<CertificateManagerModel> model);
#endif
@@ -128,7 +130,7 @@ class App : public AtomBrowserClient::Delegate,
int cert_error,
const net::SSLInfo& ssl_info,
const GURL& request_url,
content::ResourceType resource_type,
bool is_main_frame_request,
bool strict_enforcement,
bool expired_previous_decision,
const base::Callback<void(content::CertificateRequestResultType)>&
@@ -141,7 +143,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,
@@ -174,6 +176,8 @@ class App : public AtomBrowserClient::Delegate,
void ChildProcessLaunched(int process_type, base::ProcessHandle handle);
void ChildProcessDisconnected(base::ProcessId pid);
void SetAppLogsPath(mate::Arguments* args);
// Get/Set the pre-defined path in PathService.
base::FilePath GetPath(mate::Arguments* args, const std::string& name);
void SetPath(mate::Arguments* args,
@@ -182,6 +186,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,25 +196,32 @@ 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);
net::CompletionRepeatingCallback 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);
void SetUserAgentFallback(const std::string& user_agent);
std::string GetUserAgentFallback();
void SetBrowserClientCanUseCustomSiteInstance(bool should_disable);
bool CanBrowserClientUseCustomSiteInstance();
#if defined(OS_MACOSX)
bool MoveToApplicationsFolder(mate::Arguments* args);
bool IsInApplicationsFolder();
v8::Local<v8::Value> GetDockAPI(v8::Isolate* isolate);
v8::Global<v8::Value> dock_;
#endif
#if defined(MAS_BUILD)
base::Callback<void()> StartAccessingSecurityScopedResource(
mate::Arguments* args);

View File

@@ -0,0 +1,38 @@
// Copyright (c) 2019 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/browser/api/atom_api_app.h"
#include "atom/browser/atom_paths.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "base/path_service.h"
#import <Cocoa/Cocoa.h>
namespace atom {
namespace api {
void App::SetAppLogsPath(mate::Arguments* args) {
base::FilePath custom_path;
if (args->GetNext(&custom_path)) {
if (!custom_path.IsAbsolute()) {
args->ThrowError("Path must be absolute");
return;
}
base::PathService::Override(DIR_APP_LOGS, custom_path);
} else {
NSString* bundle_name =
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
NSString* logs_path =
[NSString stringWithFormat:@"Library/Logs/%@", bundle_name];
NSString* library_path =
[NSHomeDirectory() stringByAppendingPathComponent:logs_path];
base::PathService::Override(DIR_APP_LOGS,
base::FilePath([library_path UTF8String]));
}
}
} // namespace atom
} // namespace api

View File

@@ -64,11 +64,17 @@ void AutoUpdater::OnError(const std::string& message,
auto errorObject =
error->ToObject(isolate()->GetCurrentContext()).ToLocalChecked();
auto context = isolate()->GetCurrentContext();
// add two new params for better error handling
errorObject->Set(mate::StringToV8(isolate(), "code"),
v8::Integer::New(isolate(), code));
errorObject->Set(mate::StringToV8(isolate(), "domain"),
mate::StringToV8(isolate(), domain));
errorObject
->Set(context, mate::StringToV8(isolate(), "code"),
v8::Integer::New(isolate(), code))
.Check();
errorObject
->Set(context, mate::StringToV8(isolate(), "domain"),
mate::StringToV8(isolate(), domain))
.Check();
mate::EmitEvent(isolate(), GetWrapper(), "error", errorObject, message);
}
@@ -147,9 +153,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

@@ -37,6 +37,14 @@ struct Converter<atom::AutoResizeFlags> {
if (params.Get("height", &height) && height) {
flags |= atom::kAutoResizeHeight;
}
bool horizontal = false;
if (params.Get("horizontal", &horizontal) && horizontal) {
flags |= atom::kAutoResizeHorizontal;
}
bool vertical = false;
if (params.Get("vertical", &vertical) && vertical) {
flags |= atom::kAutoResizeVertical;
}
*auto_resize_flags = static_cast<atom::AutoResizeFlags>(flags);
return true;
@@ -66,6 +74,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 +83,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 +167,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 +180,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

@@ -15,16 +15,17 @@
#include "atom/common/color_util.h"
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "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_impl.h" // nogncheck
#include "content/browser/renderer_host/render_widget_host_owner_delegate.h" // nogncheck
#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"
#include "atom/common/node_includes.h"
namespace atom {
namespace api {
@@ -66,7 +67,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 +75,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());
@@ -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,13 +7,15 @@
#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/node_includes.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"
#include "atom/common/node_includes.h"
using content::TracingController;
namespace mate {
@@ -23,15 +25,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 +59,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 +71,76 @@ 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));
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(atom::util::CopyablePromise::ResolveCopyablePromise<
const base::FilePath&>,
atom::util::CopyablePromise(promise))));
return handle;
}
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(
atom::util::Promise::ResolvePromise<const std::set<std::string>&>,
std::move(promise)));
return handle;
}
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(atom::util::Promise::ResolveEmptyPromise,
std::move(promise)));
return handle;
}
void OnTraceBufferUsageAvailable(atom::util::Promise promise,
float percent_full,
size_t approximate_count) {
mate::Dictionary dict = mate::Dictionary::CreateEmpty(promise.isolate());
dict.Set("percentage", percent_full);
dict.Set("value", approximate_count);
promise.Resolve(dict.GetHandle());
}
v8::Local<v8::Promise> GetTraceBufferUsage(v8::Isolate* isolate) {
atom::util::Promise promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
// Note: This method always succeeds.
TracingController::GetInstance()->GetTraceBufferUsage(
base::BindOnce(&OnTraceBufferUsageAvailable, std::move(promise)));
return handle;
}
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,120 @@ inline net::CookieStore* GetCookieStore(
return getter->GetURLRequestContext()->cookie_store();
}
// Run |callback| on UI thread.
void RunCallbackInUI(const base::Closure& callback) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 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,
const net::CookieList& list) {
util::Promise promise,
const net::CookieList& list,
const net::CookieStatusList& excluded_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(util::Promise::ResolvePromise<const net::CookieList&>,
std::move(promise), std::move(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) {
GetCookieStore(getter)->DeleteCookieAsync(
url, name, base::BindOnce(RunCallbackInUI, callback));
void RemoveCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
const GURL& url,
const std::string& name,
util::Promise promise) {
net::CookieDeletionInfo cookie_info;
cookie_info.url = url;
cookie_info.name = name;
GetCookieStore(getter)->DeleteAllMatchingInfoAsync(
std::move(cookie_info),
base::BindOnce(
[](util::Promise promise, uint32_t num_deleted) {
util::Promise::ResolveEmptyPromise(std::move(promise));
},
std::move(promise)));
}
// Callback of SetCookie.
void OnSetCookie(const Cookies::SetCallback& callback, bool success) {
RunCallbackInUI(
base::Bind(callback, success ? Cookies::SUCCESS : Cookies::FAILED));
void OnSetCookie(util::Promise promise,
net::CanonicalCookie::CookieInclusionStatus status) {
std::string errmsg;
switch (status) {
case net::CanonicalCookie::CookieInclusionStatus::EXCLUDE_HTTP_ONLY:
errmsg = "Failed to create httponly cookie";
break;
case net::CanonicalCookie::CookieInclusionStatus::EXCLUDE_SECURE_ONLY:
errmsg = "Cannot create a secure cookie from an insecure URL";
break;
case net::CanonicalCookie::CookieInclusionStatus::EXCLUDE_FAILURE_TO_STORE:
errmsg = "Failed to parse cookie";
break;
case net::CanonicalCookie::CookieInclusionStatus::EXCLUDE_INVALID_DOMAIN:
errmsg = "Failed to get cookie domain";
break;
case net::CanonicalCookie::CookieInclusionStatus::EXCLUDE_INVALID_PREFIX:
errmsg = "Failed because the cookie violated prefix rules.";
break;
case net::CanonicalCookie::CookieInclusionStatus::
EXCLUDE_NONCOOKIEABLE_SCHEME:
errmsg = "Cannot set cookie for current scheme";
break;
case net::CanonicalCookie::CookieInclusionStatus::INCLUDE:
errmsg = "";
break;
default:
errmsg = "Setting cookie failed";
break;
}
if (errmsg.empty()) {
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(util::Promise::ResolveEmptyPromise, std::move(promise)));
} else {
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(util::Promise::RejectPromise, std::move(promise),
std::move(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(util::Promise::ResolveEmptyPromise, 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,26 +278,37 @@ void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
: base::Time::FromDoubleT(last_access_date);
}
GURL url(url_string);
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);
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_DEFAULT));
auto completion_callback = base::BindOnce(OnSetCookie, std::move(promise));
if (!canonical_cookie || !canonical_cookie->IsCanonical()) {
std::move(completion_callback).Run(false);
std::move(completion_callback)
.Run(net::CanonicalCookie::CookieInclusionStatus::
EXCLUDE_FAILURE_TO_STORE);
return;
}
if (url.empty()) {
std::move(completion_callback).Run(false);
if (!url.is_valid()) {
std::move(completion_callback)
.Run(net::CanonicalCookie::CookieInclusionStatus::
EXCLUDE_INVALID_DOMAIN);
return;
}
if (name.empty()) {
std::move(completion_callback).Run(false);
std::move(completion_callback)
.Run(net::CanonicalCookie::CookieInclusionStatus::
EXCLUDE_FAILURE_TO_STORE);
return;
}
net::CookieOptions options;
if (http_only) {
options.set_include_httponly();
}
GetCookieStore(getter)->SetCanonicalCookieAsync(
std::move(canonical_cookie), secure, http_only,
std::move(canonical_cookie), url.scheme(), options,
std::move(completion_callback));
}
@@ -265,44 +324,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

@@ -10,14 +10,13 @@
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/web_contents.h"
#include "native_mate/dictionary.h"
#include "atom/common/node_includes.h"
using content::DevToolsAgentHost;
namespace atom {
@@ -45,7 +44,8 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
std::unique_ptr<base::Value> parsed_message = base::JSONReader::Read(message);
std::unique_ptr<base::Value> parsed_message =
base::JSONReader::ReadDeprecated(message);
if (!parsed_message || !parsed_message->is_dict())
return;
base::DictionaryValue* dict =
@@ -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

@@ -10,10 +10,12 @@
#include "atom/common/api/atom_api_native_image.h"
#include "atom/common/native_mate_converters/gfx_converter.h"
#include "atom/common/node_includes.h"
#include "base/strings/string_number_conversions.h"
#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"
@@ -25,8 +27,6 @@
#include "ui/display/win/display_info.h"
#endif // defined(OS_WIN)
#include "atom/common/node_includes.h"
namespace mate {
template <>
@@ -42,6 +42,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 +66,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 +87,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) {
@@ -128,24 +132,26 @@ bool DesktopCapturer::ShouldScheduleNextRefresh(DesktopMediaList* list) {
}
void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
std::vector<DesktopCapturer::Source> window_sources;
if (capture_window_ &&
list->GetMediaListType() == content::DesktopMediaID::TYPE_WINDOW) {
capture_window_ = false;
const auto& media_list_sources = list->GetSources();
std::vector<DesktopCapturer::Source> window_sources;
window_sources.reserve(media_list_sources.size());
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_));
}
std::vector<DesktopCapturer::Source> screen_sources;
if (capture_screen_ &&
list->GetMediaListType() == content::DesktopMediaID::TYPE_SCREEN) {
capture_screen_ = false;
const auto& media_list_sources = list->GetSources();
std::vector<DesktopCapturer::Source> screen_sources;
screen_sources.reserve(media_list_sources.size());
for (const auto& media_list_source : media_list_sources) {
screen_sources.emplace_back(
DesktopCapturer::Source{media_list_source, std::string()});
@@ -159,8 +165,12 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
std::vector<std::string> device_names;
// Crucially, this list of device names will be in the same order as
// |media_list_sources|.
webrtc::DxgiDuplicatorController::Instance()->GetDeviceNames(
&device_names);
if (!webrtc::DxgiDuplicatorController::Instance()->GetDeviceNames(
&device_names)) {
Emit("error", "Failed to get sources.");
return;
}
int device_name_index = 0;
for (auto& source : screen_sources) {
const auto& device_name = device_names[device_name_index++];
@@ -170,13 +180,13 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
const int64_t device_id =
display::win::DisplayInfo::DeviceIdFromDeviceName(
wide_device_name.c_str());
source.display_id = base::Int64ToString(device_id);
source.display_id = base::NumberToString(device_id);
}
}
#elif defined(OS_MACOSX)
// On Mac, the IDs across the APIs match.
for (auto& source : screen_sources) {
source.display_id = base::Int64ToString(source.media_list_source.id.id);
source.display_id = base::NumberToString(source.media_list_source.id.id);
}
#endif // defined(OS_WIN)
// TODO(ajmacd): Add Linux support. The IDs across APIs differ but Chrome
@@ -187,7 +197,7 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
}
if (!capture_window_ && !capture_screen_)
Emit("finished", captured_sources_);
Emit("finished", captured_sources_, fetch_window_icons_);
}
// static
@@ -216,9 +226,9 @@ void Initialize(v8::Local<v8::Object> exports,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("desktopCapturer", atom::api::DesktopCapturer::Create(isolate));
dict.SetMethod("createDesktopCapturer", &atom::api::DesktopCapturer::Create);
}
} // 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,114 +12,101 @@
#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"
#include "native_mate/dictionary.h"
#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
#include "atom/common/promise_util.h"
#include "native_mate/dictionary.h"
namespace {
void ShowMessageBox(int type,
const std::vector<std::string>& buttons,
int default_id,
int cancel_id,
int options,
const std::string& title,
const std::string& message,
const std::string& detail,
const std::string& checkbox_label,
bool checkbox_checked,
const gfx::ImageSkia& icon,
atom::NativeWindow* window,
mate::Arguments* args) {
v8::Local<v8::Value> peek = args->PeekNext();
atom::MessageBoxCallback callback;
if (mate::Converter<atom::MessageBoxCallback>::FromV8(args->isolate(), peek,
&callback)) {
atom::ShowMessageBox(window, static_cast<atom::MessageBoxType>(type),
buttons, default_id, cancel_id, options, title,
message, detail, checkbox_label, checkbox_checked,
icon, callback);
} else {
int chosen = atom::ShowMessageBox(
window, static_cast<atom::MessageBoxType>(type), buttons, default_id,
cancel_id, options, title, message, detail, icon);
args->Return(chosen);
}
int ShowMessageBoxSync(int type,
const std::vector<std::string>& buttons,
int default_id,
int cancel_id,
int options,
const std::string& title,
const std::string& message,
const std::string& detail,
const std::string& checkbox_label,
bool checkbox_checked,
const gfx::ImageSkia& icon,
atom::NativeWindow* window) {
return atom::ShowMessageBoxSync(
window, static_cast<atom::MessageBoxType>(type), buttons, default_id,
cancel_id, options, title, message, detail, icon);
}
void ShowOpenDialog(const file_dialog::DialogSettings& settings,
mate::Arguments* args) {
v8::Local<v8::Value> peek = args->PeekNext();
file_dialog::OpenDialogCallback callback;
if (mate::Converter<file_dialog::OpenDialogCallback>::FromV8(
args->isolate(), peek, &callback)) {
file_dialog::ShowOpenDialog(settings, callback);
} else {
std::vector<base::FilePath> paths;
if (file_dialog::ShowOpenDialog(settings, &paths))
args->Return(paths);
}
void ResolvePromiseObject(atom::util::Promise promise,
int result,
bool checkbox_checked) {
mate::Dictionary dict = mate::Dictionary::CreateEmpty(promise.isolate());
dict.Set("response", result);
dict.Set("checkboxChecked", checkbox_checked);
promise.Resolve(dict.GetHandle());
}
void ShowSaveDialog(const file_dialog::DialogSettings& settings,
mate::Arguments* args) {
v8::Local<v8::Value> peek = args->PeekNext();
file_dialog::SaveDialogCallback callback;
if (mate::Converter<file_dialog::SaveDialogCallback>::FromV8(
args->isolate(), peek, &callback)) {
file_dialog::ShowSaveDialog(settings, callback);
} else {
base::FilePath path;
if (file_dialog::ShowSaveDialog(settings, &path))
args->Return(path);
}
v8::Local<v8::Promise> ShowMessageBox(int type,
const std::vector<std::string>& buttons,
int default_id,
int cancel_id,
int options,
const std::string& title,
const std::string& message,
const std::string& detail,
const std::string& checkbox_label,
bool checkbox_checked,
const gfx::ImageSkia& icon,
atom::NativeWindow* window,
mate::Arguments* args) {
v8::Isolate* isolate = args->isolate();
atom::util::Promise promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
atom::ShowMessageBox(
window, static_cast<atom::MessageBoxType>(type), buttons, default_id,
cancel_id, options, title, message, detail, checkbox_label,
checkbox_checked, icon,
base::BindOnce(&ResolvePromiseObject, std::move(promise)));
return handle;
}
void ShowOpenDialogSync(const file_dialog::DialogSettings& settings,
mate::Arguments* args) {
std::vector<base::FilePath> paths;
if (file_dialog::ShowOpenDialogSync(settings, &paths))
args->Return(paths);
}
v8::Local<v8::Promise> ShowOpenDialog(
const file_dialog::DialogSettings& settings,
mate::Arguments* args) {
atom::util::Promise promise(args->isolate());
v8::Local<v8::Promise> handle = promise.GetHandle();
file_dialog::ShowOpenDialog(settings, std::move(promise));
return handle;
}
void ShowSaveDialogSync(const file_dialog::DialogSettings& settings,
mate::Arguments* args) {
base::FilePath path;
if (file_dialog::ShowSaveDialogSync(settings, &path))
args->Return(path);
}
v8::Local<v8::Promise> ShowSaveDialog(
const file_dialog::DialogSettings& settings,
mate::Arguments* args) {
atom::util::Promise promise(args->isolate());
v8::Local<v8::Promise> handle = promise.GetHandle();
file_dialog::ShowSaveDialog(settings, std::move(promise));
return handle;
}
void Initialize(v8::Local<v8::Object> exports,
@@ -127,9 +114,12 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Context> context,
void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("showMessageBoxSync", &ShowMessageBoxSync);
dict.SetMethod("showMessageBox", &ShowMessageBox);
dict.SetMethod("showErrorBox", &atom::ShowErrorBox);
dict.SetMethod("showOpenDialogSync", &ShowOpenDialogSync);
dict.SetMethod("showOpenDialog", &ShowOpenDialog);
dict.SetMethod("showSaveDialogSync", &ShowSaveDialogSync);
dict.SetMethod("showSaveDialog", &ShowSaveDialog);
#if defined(OS_MACOSX) || defined(OS_WIN)
dict.SetMethod("showCertificateTrustDialog",
@@ -139,4 +129,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,15 +8,15 @@
#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 "atom/common/node_includes.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "native_mate/dictionary.h"
#include "net/base/filename_util.h"
#include "atom/common/node_includes.h"
namespace mate {
template <>
@@ -102,7 +102,7 @@ bool DownloadItem::IsPaused() const {
}
void DownloadItem::Resume() {
download_item_->Resume();
download_item_->Resume(true /* user_gesture */);
}
bool DownloadItem::CanResume() const {
@@ -165,6 +165,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 +209,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 +243,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, base::nullopt);
}
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,45 @@
#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 "atom/common/node_includes.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 +60,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 +115,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 +141,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 +165,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

@@ -9,9 +9,8 @@
#include <vector>
#include "atom/common/native_mate_converters/callback.h"
#include "native_mate/dictionary.h"
#include "atom/common/node_includes.h"
#include "native_mate/dictionary.h"
namespace mate {
@@ -62,7 +61,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();
}
@@ -92,7 +91,7 @@ void InAppPurchase::BuildPrototype(v8::Isolate* isolate,
&in_app_purchase::FinishAllTransactions)
.SetMethod("finishTransactionByDate",
&in_app_purchase::FinishTransactionByDate)
.SetMethod("getProducts", &in_app_purchase::GetProducts);
.SetMethod("getProducts", &InAppPurchase::GetProducts);
}
InAppPurchase::InAppPurchase(v8::Isolate* isolate) {
@@ -101,13 +100,37 @@ InAppPurchase::InAppPurchase(v8::Isolate* isolate) {
InAppPurchase::~InAppPurchase() {}
void InAppPurchase::PurchaseProduct(const std::string& product_id,
mate::Arguments* args) {
v8::Local<v8::Promise> InAppPurchase::PurchaseProduct(
const std::string& product_id,
mate::Arguments* args) {
v8::Isolate* isolate = args->isolate();
atom::util::Promise promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
int quantity = 1;
in_app_purchase::InAppPurchaseCallback callback;
args->GetNext(&quantity);
args->GetNext(&callback);
in_app_purchase::PurchaseProduct(product_id, quantity, callback);
in_app_purchase::PurchaseProduct(
product_id, quantity,
base::BindOnce(atom::util::Promise::ResolvePromise<bool>,
std::move(promise)));
return handle;
}
v8::Local<v8::Promise> InAppPurchase::GetProducts(
const std::vector<std::string>& productIDs,
mate::Arguments* args) {
v8::Isolate* isolate = args->isolate();
atom::util::Promise promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
in_app_purchase::GetProducts(
productIDs, base::BindOnce(atom::util::Promise::ResolvePromise<
std::vector<in_app_purchase::Product>>,
std::move(promise)));
return handle;
}
void InAppPurchase::OnTransactionsUpdated(
@@ -132,11 +155,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

@@ -12,6 +12,7 @@
#include "atom/browser/mac/in_app_purchase.h"
#include "atom/browser/mac/in_app_purchase_observer.h"
#include "atom/browser/mac/in_app_purchase_product.h"
#include "atom/common/promise_util.h"
#include "native_mate/handle.h"
namespace atom {
@@ -30,7 +31,11 @@ class InAppPurchase : public mate::EventEmitter<InAppPurchase>,
explicit InAppPurchase(v8::Isolate* isolate);
~InAppPurchase() override;
void PurchaseProduct(const std::string& product_id, mate::Arguments* args);
v8::Local<v8::Promise> PurchaseProduct(const std::string& product_id,
mate::Arguments* args);
v8::Local<v8::Promise> GetProducts(const std::vector<std::string>& productIDs,
mate::Arguments* args);
// TransactionObserver:
void OnTransactionsUpdated(

View File

@@ -9,12 +9,11 @@
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/image_converter.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/node_includes.h"
#include "native_mate/constructor.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
#include "atom/common/node_includes.h"
namespace atom {
namespace api {
@@ -40,7 +39,10 @@ void Menu::AfterInit(v8::Isolate* isolate) {
delegate.Get("isCommandIdChecked", &is_checked_);
delegate.Get("isCommandIdEnabled", &is_enabled_);
delegate.Get("isCommandIdVisible", &is_visible_);
delegate.Get("shouldCommandIdWorkWhenHidden", &works_when_hidden_);
delegate.Get("getAcceleratorForCommandId", &get_accelerator_);
delegate.Get("shouldRegisterAcceleratorForCommandId",
&should_register_accelerator_);
delegate.Get("executeCommand", &execute_command_);
delegate.Get("menuWillShow", &menu_will_show_);
}
@@ -63,6 +65,12 @@ bool Menu::IsCommandIdVisible(int command_id) const {
return is_visible_.Run(GetWrapper(), command_id);
}
bool Menu::ShouldCommandIdWorkWhenHidden(int command_id) const {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
return works_when_hidden_.Run(GetWrapper(), command_id);
}
bool Menu::GetAcceleratorForCommandIdWithParams(
int command_id,
bool use_default_accelerator,
@@ -74,6 +82,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 +96,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 +169,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);
}
@@ -167,6 +187,10 @@ bool Menu::IsVisibleAt(int index) const {
return model_->IsVisibleAt(index);
}
bool Menu::WorksWhenHiddenAt(int index) const {
return model_->WorksWhenHiddenAt(index);
}
void Menu::OnMenuWillClose() {
Emit("menu-will-close");
}
@@ -195,8 +219,10 @@ 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("worksWhenHiddenAt", &Menu::WorksWhenHiddenAt)
.SetMethod("isVisibleAt", &Menu::IsVisibleAt)
.SetMethod("popupAt", &Menu::PopupAt)
.SetMethod("closePopupAt", &Menu::ClosePopupAt);
@@ -218,7 +244,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 +256,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

@@ -47,12 +47,14 @@ class Menu : public mate::TrackableObject<Menu>,
bool IsCommandIdChecked(int command_id) const override;
bool IsCommandIdEnabled(int command_id) const override;
bool IsCommandIdVisible(int command_id) const override;
bool ShouldCommandIdWorkWhenHidden(int command_id) const override;
bool GetAcceleratorForCommandIdWithParams(
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,16 +93,20 @@ 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;
bool WorksWhenHiddenAt(int index) const;
// Stored delegate methods.
base::Callback<bool(v8::Local<v8::Value>, int)> is_checked_;
base::Callback<bool(v8::Local<v8::Value>, int)> is_enabled_;
base::Callback<bool(v8::Local<v8::Value>, int)> is_visible_;
base::Callback<bool(v8::Local<v8::Value>, int)> works_when_hidden_;
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

@@ -6,14 +6,15 @@
#include "atom/browser/native_window.h"
#include "atom/browser/unresponsive_suppressor.h"
#include "atom/common/node_includes.h"
#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"
#include "atom/common/node_includes.h"
using content::BrowserThread;
namespace {
@@ -43,7 +44,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 +55,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 +98,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

@@ -52,7 +52,7 @@ void MenuViews::PopupAt(TopLevelWindow* window,
std::make_unique<MenuRunner>(model(), flags, close_callback);
menu_runners_[window_id]->RunMenuAt(
native_window->widget(), NULL, gfx::Rect(location, gfx::Size()),
views::MENU_ANCHOR_TOPLEFT, ui::MENU_SOURCE_MOUSE);
views::MenuAnchorPosition::kTopLeft, ui::MENU_SOURCE_MOUSE);
}
void MenuViews::ClosePopupAt(int32_t window_id) {

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,18 +7,18 @@
#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 "atom/common/node_includes.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"
#include "native_mate/handle.h"
#include "net/url_request/url_request_context_getter.h"
#include "atom/common/node_includes.h"
namespace atom {
namespace api {
@@ -27,8 +27,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);
}
@@ -86,19 +86,18 @@ std::string NetLog::GetCurrentlyLoggingPath() const {
return std::string();
}
void NetLog::StopLogging(mate::Arguments* args) {
net_log::NetExportFileWriter::FilePathCallback callback;
if (!args->GetNext(&callback)) {
args->ThrowError("Invalid callback function");
return;
}
v8::Local<v8::Promise> NetLog::StopLogging(mate::Arguments* args) {
util::Promise promise(isolate());
v8::Local<v8::Promise> handle = promise.GetHandle();
if (IsCurrentlyLogging()) {
stop_callback_queue_.emplace_back(callback);
stop_callback_queue_.emplace_back(std::move(promise));
net_log_writer_->StopNetLog(nullptr);
} else {
callback.Run(base::FilePath());
promise.Resolve(base::FilePath());
}
return handle;
}
void NetLog::OnNewState(const base::DictionaryValue& state) {
@@ -108,9 +107,12 @@ void NetLog::OnNewState(const base::DictionaryValue& state) {
return;
if (GetLoggingState() == "NOT_LOGGING") {
for (auto& callback : stop_callback_queue_) {
if (!callback.is_null())
net_log_writer_->GetFilePathToCompletedLog(callback);
for (auto& promise : stop_callback_queue_) {
// TODO(zcbenz): Remove the use of CopyablePromise when the
// GetFilePathToCompletedLog API accepts OnceCallback.
net_log_writer_->GetFilePathToCompletedLog(base::Bind(
util::CopyablePromise::ResolveCopyablePromise<const base::FilePath&>,
util::CopyablePromise(promise)));
}
stop_callback_queue_.clear();
}

View File

@@ -10,6 +10,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 "components/net_log/net_export_file_writer.h"
@@ -34,7 +35,7 @@ class NetLog : public mate::TrackableObject<NetLog>,
std::string GetLoggingState() const;
bool IsCurrentlyLogging() const;
std::string GetCurrentlyLoggingPath() const;
void StopLogging(mate::Arguments* args);
v8::Local<v8::Promise> StopLogging(mate::Arguments* args);
protected:
explicit NetLog(v8::Isolate* isolate, AtomBrowserContext* browser_context);
@@ -46,8 +47,7 @@ class NetLog : public mate::TrackableObject<NetLog>,
private:
AtomBrowserContext* browser_context_;
net_log::NetExportFileWriter* net_log_writer_;
std::list<net_log::NetExportFileWriter::FilePathCallback>
stop_callback_queue_;
std::list<atom::util::Promise> stop_callback_queue_;
std::unique_ptr<base::DictionaryValue> net_log_state_;
DISALLOW_COPY_AND_ASSIGN(NetLog);

View File

@@ -5,27 +5,25 @@
#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 "atom/common/node_includes.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"
#include "url/gurl.h"
// Must be the last in the includes list.
// See https://github.com/electron/electron/issues/10363
#include "atom/common/node_includes.h"
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 +36,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 +54,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 +118,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 +156,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 +199,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 +217,8 @@ void Notification::Show() {
}
bool Notification::IsSupported() {
return !!brightray::BrowserClient::Get()->GetNotificationPresenter();
return !!static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())
->GetNotificationPresenter();
}
// static
@@ -261,12 +261,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

@@ -6,12 +6,11 @@
#include "atom/browser/browser.h"
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/node_includes.h"
#include "base/power_monitor/power_monitor.h"
#include "base/power_monitor/power_monitor_device_source.h"
#include "native_mate/dictionary.h"
#include "atom/common/node_includes.h"
namespace mate {
template <>
struct Converter<ui::IdleState> {
@@ -84,19 +83,19 @@ void PowerMonitor::OnResume() {
Emit("resume");
}
void PowerMonitor::QuerySystemIdleState(v8::Isolate* isolate,
int idle_threshold,
const ui::IdleCallback& callback) {
ui::IdleState PowerMonitor::GetSystemIdleState(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::GetSystemIdleTime() {
return ui::CalculateIdleTime();
}
// static
@@ -122,8 +121,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("getSystemIdleState", &PowerMonitor::GetSystemIdleState)
.SetMethod("getSystemIdleTime", &PowerMonitor::GetSystemIdleTime);
}
} // namespace api
@@ -141,10 +140,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 GetSystemIdleState(v8::Isolate* isolate, int idle_threshold);
int GetSystemIdleTime();
#if defined(OS_WIN)
// Static callback invoked when a message comes in to our messaging window.

View File

@@ -6,11 +6,14 @@
#include <string>
#include "base/task_scheduler/post_task.h"
#include "base/threading/thread_task_runner_handle.h"
#include "native_mate/dictionary.h"
#include "atom/common/node_includes.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"
namespace mate {
@@ -39,16 +42,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 +64,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 +150,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,26 @@ 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;
}
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(util::Promise::ResolvePromise<bool>, std::move(promise)));
return handle;
}
void Protocol::UninterceptProtocol(const std::string& scheme,
@@ -127,8 +197,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 +258,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 +289,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 +307,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

@@ -7,12 +7,11 @@
#include "atom/browser/api/atom_api_web_contents.h"
#include "atom/browser/atom_browser_client.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "content/public/browser/render_process_host.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
#include "atom/common/node_includes.h"
namespace atom {
namespace api {
@@ -26,7 +25,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 +86,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

@@ -10,6 +10,7 @@
#include "atom/browser/api/atom_api_browser_window.h"
#include "atom/browser/browser.h"
#include "atom/common/native_mate_converters/gfx_converter.h"
#include "atom/common/node_includes.h"
#include "base/bind.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
@@ -21,8 +22,6 @@
#include "ui/display/win/screen_win.h"
#endif
#include "atom/common/node_includes.h"
namespace atom {
namespace api {
@@ -52,6 +51,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 +113,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 +183,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"
@@ -27,11 +28,12 @@
#include "atom/common/native_mate_converters/gurl_converter.h"
#include "atom/common/native_mate_converters/net_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "base/files/file_path.h"
#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,15 +41,15 @@
#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"
#include "content/public/browser/storage_partition.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
#include "net/base/completion_repeating_callback.h"
#include "net/base/load_flags.h"
#include "net/disk_cache/disk_cache.h"
#include "net/dns/host_cache.h"
#include "net/http/http_auth_handler_factory.h"
#include "net/http/http_auth_preferences.h"
#include "net/http/http_cache.h"
@@ -57,9 +59,6 @@
#include "net/url_request/url_request_context_getter.h"
#include "ui/base/l10n/l10n_util.h"
#include "atom/common/node_includes.h"
using atom::api::Cookies;
using content::BrowserThread;
using content::StoragePartition;
@@ -209,63 +208,6 @@ const char kPersistPrefix[] = "persist:";
// Referenced session objects.
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);
}
template <typename... T>
void RunCallbackInUI(const base::Callback<void(T...)>& callback, T... result) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(callback, result...));
}
// Callback of HttpCache::GetBackend.
void OnGetBackend(disk_cache::Backend** backend_ptr,
Session::CacheAction action,
const net::CompletionCallback& callback,
int result) {
if (result != net::OK) {
RunCallbackInUI(callback, result);
} else if (backend_ptr && *backend_ptr) {
if (action == Session::CacheAction::CLEAR) {
(*backend_ptr)
->DoomAllEntries(base::Bind(&RunCallbackInUI<int>, callback));
} else if (action == Session::CacheAction::STATS) {
base::StringPairs stats;
(*backend_ptr)->GetStats(&stats);
for (const auto& stat : stats) {
if (stat.first == "Current size") {
int current_size;
base::StringToInt(stat.second, &current_size);
RunCallbackInUI(callback, current_size);
break;
}
}
}
} else {
RunCallbackInUI<int>(callback, net::ERR_FAILED);
}
}
void DoCacheActionInIO(
const scoped_refptr<net::URLRequestContextGetter>& context_getter,
Session::CacheAction action,
const net::CompletionCallback& callback) {
auto* request_context = context_getter->GetURLRequestContext();
auto* http_cache = request_context->http_transaction_factory()->GetCache();
if (!http_cache)
RunCallbackInUI<int>(callback, net::ERR_FAILED);
// Call GetBackend and make the backend's ptr accessable in OnGetBackend.
using BackendPtr = disk_cache::Backend*;
auto** backend_ptr = new BackendPtr(nullptr);
net::CompletionCallback on_get_backend =
base::Bind(&OnGetBackend, base::Owned(backend_ptr), action, callback);
int rv = http_cache->GetBackend(backend_ptr, on_get_backend);
if (rv != net::ERR_IO_PENDING)
on_get_backend.Run(net::OK);
}
void SetCertVerifyProcInIO(
const scoped_refptr<net::URLRequestContextGetter>& context_getter,
const AtomCertVerifier::VerifyProc& proc) {
@@ -276,21 +218,22 @@ void SetCertVerifyProcInIO(
void ClearHostResolverCacheInIO(
const scoped_refptr<net::URLRequestContextGetter>& context_getter,
const base::Closure& callback) {
util::Promise promise) {
auto* request_context = context_getter->GetURLRequestContext();
auto* cache = request_context->host_resolver()->GetHostCache();
if (cache) {
cache->clear();
DCHECK_EQ(0u, cache->size());
if (!callback.is_null())
RunCallbackInUI(callback);
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(util::Promise::ResolveEmptyPromise, std::move(promise)));
}
}
void ClearAuthCacheInIO(
const scoped_refptr<net::URLRequestContextGetter>& context_getter,
const ClearAuthCacheOptions& options,
const base::Closure& callback) {
util::Promise promise) {
auto* request_context = context_getter->GetURLRequestContext();
auto* network_session =
request_context->http_transaction_factory()->GetSession();
@@ -310,8 +253,9 @@ void ClearAuthCacheInIO(
}
network_session->CloseAllConnections();
}
if (!callback.is_null())
RunCallbackInUI(callback);
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(util::Promise::ResolveEmptyPromise, std::move(promise)));
}
void AllowNTLMCredentialsForDomainsInIO(
@@ -327,11 +271,6 @@ void AllowNTLMCredentialsForDomainsInIO(
}
}
void OnClearStorageDataDone(const base::Closure& callback) {
if (!callback.is_null())
callback.Run();
}
void DownloadIdCallback(content::DownloadManager* download_manager,
const base::FilePath& path,
const std::vector<GURL>& url_chain,
@@ -344,8 +283,8 @@ void DownloadIdCallback(content::DownloadManager* download_manager,
uint32_t id) {
download_manager->CreateDownloadItem(
base::GenerateGUID(), id, path, path, url_chain, GURL(), GURL(), GURL(),
GURL(), mime_type, mime_type, start_time, base::Time(), etag,
last_modified, offset, length, std::string(),
GURL(), base::nullopt, mime_type, mime_type, start_time, base::Time(),
etag, last_modified, offset, length, std::string(),
download::DownloadItem::INTERRUPTED,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
download::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT, false, base::Time(),
@@ -358,8 +297,9 @@ void DestroyGlobalHandle(v8::Isolate* isolate,
v8::HandleScope handle_scope(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;
if (local_handle->IsObject() &&
local_handle->ToObject(isolate->GetCurrentContext()).ToLocal(&object)) {
void* ptr = object->GetAlignedPointerFromInternalField(0);
if (!ptr)
return;
@@ -413,39 +353,81 @@ void Session::OnDownloadCreated(content::DownloadManager* manager,
}
}
void Session::ResolveProxy(
const GURL& url,
const ResolveProxyHelper::ResolveProxyCallback& callback) {
browser_context_->GetResolveProxyHelper()->ResolveProxy(url, callback);
v8::Local<v8::Promise> Session::ResolveProxy(mate::Arguments* args) {
v8::Isolate* isolate = args->isolate();
util::Promise promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
GURL url;
args->GetNext(&url);
browser_context_->GetResolveProxyHelper()->ResolveProxy(
url,
base::Bind(util::CopyablePromise::ResolveCopyablePromise<std::string>,
util::CopyablePromise(promise)));
return handle;
}
template <Session::CacheAction action>
void Session::DoCacheAction(const net::CompletionCallback& callback) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::BindOnce(&DoCacheActionInIO,
WrapRefCounted(browser_context_->GetRequestContext()),
action, callback));
v8::Local<v8::Promise> Session::GetCacheSize() {
auto* isolate = v8::Isolate::GetCurrent();
auto promise = util::Promise(isolate);
auto handle = promise.GetHandle();
content::BrowserContext::GetDefaultStoragePartition(browser_context_.get())
->GetNetworkContext()
->ComputeHttpCacheSize(base::Time(), base::Time::Max(),
base::BindOnce(
[](util::Promise promise, bool is_upper_bound,
int64_t size_or_error) {
if (size_or_error < 0) {
promise.RejectWithErrorMessage(
net::ErrorToString(size_or_error));
} else {
promise.Resolve(size_or_error);
}
},
std::move(promise)));
return handle;
}
void Session::ClearStorageData(mate::Arguments* args) {
// clearStorageData([options, callback])
v8::Local<v8::Promise> Session::ClearCache() {
auto* isolate = v8::Isolate::GetCurrent();
auto promise = util::Promise(isolate);
auto handle = promise.GetHandle();
content::BrowserContext::GetDefaultStoragePartition(browser_context_.get())
->GetNetworkContext()
->ClearHttpCache(base::Time(), base::Time::Max(), nullptr,
base::BindOnce(util::Promise::ResolveEmptyPromise,
std::move(promise)));
return handle;
}
v8::Local<v8::Promise> Session::ClearStorageData(mate::Arguments* args) {
v8::Isolate* isolate = args->isolate();
util::Promise promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
ClearStorageDataOptions options;
base::Closure callback;
args->GetNext(&options);
args->GetNext(&callback);
auto* storage_partition =
content::BrowserContext::GetStoragePartition(browser_context(), nullptr);
if (options.storage_types & StoragePartition::REMOVE_DATA_MASK_COOKIES) {
// Reset media device id salt when cookies are cleared.
// https://w3c.github.io/mediacapture-main/#dom-mediadeviceinfo-deviceid
brightray::MediaDeviceIDSalt::Reset(browser_context()->prefs());
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));
options.storage_types, options.quota_types, options.origin, base::Time(),
base::Time::Max(),
base::Bind(util::CopyablePromise::ResolveEmptyCopyablePromise,
util::CopyablePromise(promise)));
return handle;
}
void Session::FlushStorageData() {
@@ -454,11 +436,17 @@ void Session::FlushStorageData() {
storage_partition->Flush();
}
void Session::SetProxy(const mate::Dictionary& options,
const base::Closure& callback) {
v8::Local<v8::Promise> Session::SetProxy(mate::Arguments* args) {
v8::Isolate* isolate = args->isolate();
util::Promise promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
mate::Dictionary options;
args->GetNext(&options);
if (!browser_context_->in_memory_pref_store()) {
callback.Run();
return;
promise.Resolve();
return handle;
}
std::string proxy_rules, bypass_list, pac_url;
@@ -471,17 +459,22 @@ 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);
}
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback);
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(util::Promise::ResolveEmptyPromise, std::move(promise)));
return handle;
}
void Session::SetDownloadPath(const base::FilePath& path) {
@@ -532,8 +525,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)));
@@ -541,14 +534,33 @@ void Session::SetCertVerifyProc(v8::Local<v8::Value> val,
void Session::SetPermissionRequestHandler(v8::Local<v8::Value> val,
mate::Arguments* args) {
AtomPermissionManager::RequestHandler handler;
if (!(val->IsNull() || mate::ConvertFromV8(args->isolate(), val, &handler))) {
auto* permission_manager = static_cast<AtomPermissionManager*>(
browser_context()->GetPermissionControllerDelegate());
if (val->IsNull()) {
permission_manager->SetPermissionRequestHandler(
AtomPermissionManager::RequestHandler());
return;
}
using StatusCallback =
base::RepeatingCallback<void(blink::mojom::PermissionStatus)>;
using RequestHandler =
base::Callback<void(content::WebContents*, content::PermissionType,
StatusCallback, const base::Value&)>;
auto handler = std::make_unique<RequestHandler>();
if (!mate::ConvertFromV8(args->isolate(), val, handler.get())) {
args->ThrowError("Must pass null or function");
return;
}
auto* permission_manager = static_cast<AtomPermissionManager*>(
browser_context()->GetPermissionControllerDelegate());
permission_manager->SetPermissionRequestHandler(handler);
permission_manager->SetPermissionRequestHandler(base::BindRepeating(
[](RequestHandler* handler, content::WebContents* web_contents,
content::PermissionType permission_type,
AtomPermissionManager::StatusCallback callback,
const base::Value& details) {
handler->Run(web_contents, permission_type,
base::AdaptCallbackForRepeating(std::move(callback)),
details);
},
base::Owned(std::move(handler))));
}
void Session::SetPermissionCheckHandler(v8::Local<v8::Value> val,
@@ -563,36 +575,41 @@ void Session::SetPermissionCheckHandler(v8::Local<v8::Value> val,
permission_manager->SetPermissionCheckHandler(handler);
}
void Session::ClearHostResolverCache(mate::Arguments* args) {
base::Closure callback;
args->GetNext(&callback);
v8::Local<v8::Promise> Session::ClearHostResolverCache(mate::Arguments* args) {
v8::Isolate* isolate = args->isolate();
util::Promise promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&ClearHostResolverCacheInIO,
WrapRefCounted(browser_context_->GetRequestContext()),
callback));
std::move(promise)));
return handle;
}
void Session::ClearAuthCache(mate::Arguments* args) {
v8::Local<v8::Promise> Session::ClearAuthCache(mate::Arguments* args) {
v8::Isolate* isolate = args->isolate();
util::Promise promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
ClearAuthCacheOptions options;
if (!args->GetNext(&options)) {
args->ThrowError("Must specify options object");
return;
promise.RejectWithErrorMessage("Must specify options object");
return handle;
}
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));
options, std::move(promise)));
return handle;
}
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));
@@ -616,16 +633,17 @@ std::string Session::GetUserAgent() {
return browser_context_->GetUserAgent();
}
void Session::GetBlobData(const std::string& uuid,
const AtomBlobReader::CompletionCallback& callback) {
if (callback.is_null())
return;
v8::Local<v8::Promise> Session::GetBlobData(v8::Isolate* isolate,
const std::string& uuid) {
util::Promise promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
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));
base::Unretained(blob_reader), uuid, std::move(promise)));
return handle;
}
void Session::CreateInterruptedDownload(const mate::Dictionary& options) {
@@ -747,8 +765,8 @@ void Session::BuildPrototype(v8::Isolate* isolate,
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.MakeDestroyable()
.SetMethod("resolveProxy", &Session::ResolveProxy)
.SetMethod("getCacheSize", &Session::DoCacheAction<CacheAction::STATS>)
.SetMethod("clearCache", &Session::DoCacheAction<CacheAction::CLEAR>)
.SetMethod("getCacheSize", &Session::GetCacheSize)
.SetMethod("clearCache", &Session::ClearCache)
.SetMethod("clearStorageData", &Session::ClearStorageData)
.SetMethod("flushStorageData", &Session::FlushStorageData)
.SetMethod("setProxy", &Session::SetProxy)
@@ -783,6 +801,9 @@ void Session::BuildPrototype(v8::Isolate* isolate,
namespace {
using atom::api::Cookies;
using atom::api::NetLog;
using atom::api::Protocol;
using atom::api::Session;
v8::Local<v8::Value> FromPartition(const std::string& partition,
@@ -802,11 +823,21 @@ 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(
"NetLog",
NetLog::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

@@ -11,10 +11,10 @@
#include "atom/browser/api/trackable_object.h"
#include "atom/browser/atom_blob_reader.h"
#include "atom/browser/net/resolve_proxy_helper.h"
#include "atom/common/promise_util.h"
#include "base/values.h"
#include "content/public/browser/download_manager.h"
#include "native_mate/handle.h"
#include "net/base/completion_callback.h"
class GURL;
@@ -62,13 +62,12 @@ class Session : public mate::TrackableObject<Session>,
v8::Local<v8::FunctionTemplate> prototype);
// Methods.
void ResolveProxy(const GURL& url,
const ResolveProxyHelper::ResolveProxyCallback& callback);
template <CacheAction action>
void DoCacheAction(const net::CompletionCallback& callback);
void ClearStorageData(mate::Arguments* args);
v8::Local<v8::Promise> ResolveProxy(mate::Arguments* args);
v8::Local<v8::Promise> GetCacheSize();
v8::Local<v8::Promise> ClearCache();
v8::Local<v8::Promise> ClearStorageData(mate::Arguments* args);
void FlushStorageData();
void SetProxy(const mate::Dictionary& options, const base::Closure& callback);
v8::Local<v8::Promise> SetProxy(mate::Arguments* args);
void SetDownloadPath(const base::FilePath& path);
void EnableNetworkEmulation(const mate::Dictionary& options);
void DisableNetworkEmulation();
@@ -77,13 +76,13 @@ class Session : public mate::TrackableObject<Session>,
mate::Arguments* args);
void SetPermissionCheckHandler(v8::Local<v8::Value> val,
mate::Arguments* args);
void ClearHostResolverCache(mate::Arguments* args);
void ClearAuthCache(mate::Arguments* args);
v8::Local<v8::Promise> ClearHostResolverCache(mate::Arguments* args);
v8::Local<v8::Promise> ClearAuthCache(mate::Arguments* args);
void AllowNTLMCredentialsForDomains(const std::string& domains);
void SetUserAgent(const std::string& user_agent, mate::Arguments* args);
std::string GetUserAgent();
void GetBlobData(const std::string& uuid,
const AtomBlobReader::CompletionCallback& callback);
v8::Local<v8::Promise> GetBlobData(v8::Isolate* isolate,
const std::string& uuid);
void CreateInterruptedDownload(const mate::Dictionary& options);
void SetPreloads(const std::vector<base::FilePath::StringType>& preloads);
std::vector<base::FilePath::StringType> GetPreloads() const;

View File

@@ -8,6 +8,7 @@
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "native_mate/dictionary.h"
#include "ui/gfx/animation/animation.h"
#include "ui/gfx/color_utils.h"
namespace atom {
@@ -37,6 +38,25 @@ bool SystemPreferences::IsInvertedColorScheme() {
return color_utils::IsInvertedColorScheme();
}
#if !defined(OS_WIN)
bool SystemPreferences::IsHighContrastColorScheme() {
return false;
}
#endif // !defined(OS_WIN)
v8::Local<v8::Value> SystemPreferences::GetAnimationSettings(
v8::Isolate* isolate) {
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("shouldRenderRichAnimation",
gfx::Animation::ShouldRenderRichAnimation());
dict.Set("scrollAnimationsEnabledBySystem",
gfx::Animation::ScrollAnimationsEnabledBySystem());
dict.Set("prefersReducedMotion", gfx::Animation::PrefersReducedMotion());
return dict.GetHandle();
}
// static
mate::Handle<SystemPreferences> SystemPreferences::Create(
v8::Isolate* isolate) {
@@ -49,10 +69,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,10 +106,22 @@ void SystemPreferences::BuildPrototype(
&SystemPreferences::GetAppLevelAppearance)
.SetMethod("setAppLevelAppearance",
&SystemPreferences::SetAppLevelAppearance)
.SetMethod("getSystemColor", &SystemPreferences::GetSystemColor)
.SetMethod("canPromptTouchID", &SystemPreferences::CanPromptTouchID)
.SetMethod("promptTouchID", &SystemPreferences::PromptTouchID)
.SetMethod("isTrustedAccessibilityClient",
&SystemPreferences::IsTrustedAccessibilityClient)
.SetMethod("getMediaAccessStatus",
&SystemPreferences::GetMediaAccessStatus)
.SetMethod("askForMediaAccess", &SystemPreferences::AskForMediaAccess)
#endif
.SetMethod("isInvertedColorScheme",
&SystemPreferences::IsInvertedColorScheme)
.SetMethod("isDarkMode", &SystemPreferences::IsDarkMode);
.SetMethod("isHighContrastColorScheme",
&SystemPreferences::IsHighContrastColorScheme)
.SetMethod("isDarkMode", &SystemPreferences::IsDarkMode)
.SetMethod("getAnimationSettings",
&SystemPreferences::GetAnimationSettings);
}
} // namespace api
@@ -104,10 +139,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,21 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
void RemoveUserDefault(const std::string& name);
bool IsSwipeTrackingFromScrollEventsEnabled();
std::string GetSystemColor(const std::string& color, mate::Arguments* args);
bool CanPromptTouchID();
v8::Local<v8::Promise> PromptTouchID(v8::Isolate* isolate,
const std::string& reason);
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 +116,14 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
#endif
bool IsDarkMode();
bool IsInvertedColorScheme();
bool IsHighContrastColorScheme();
v8::Local<v8::Value> GetAnimationSettings(v8::Isolate* isolate);
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 +156,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,13 +6,22 @@
#include <map>
#import <AVFoundation/AVFoundation.h>
#import <Cocoa/Cocoa.h>
#import <LocalAuthentication/LocalAuthentication.h>
#import <Security/Security.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/scoped_cftyperef.h"
#include "base/mac/sdk_forward_declarations.h"
#include "base/sequenced_task_runner.h"
#include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/values.h"
#include "native_mate/object_template_builder.h"
#include "net/base/mac/url_conversions.h"
@@ -53,11 +62,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 +87,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 +142,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 +161,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 +179,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 +386,249 @@ 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]);
}
bool SystemPreferences::CanPromptTouchID() {
if (@available(macOS 10.12.2, *)) {
base::scoped_nsobject<LAContext> context([[LAContext alloc] init]);
if (![context
canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
error:nil])
return false;
if (@available(macOS 10.13.2, *))
return [context biometryType] == LABiometryTypeTouchID;
return true;
}
return false;
}
v8::Local<v8::Promise> SystemPreferences::PromptTouchID(
v8::Isolate* isolate,
const std::string& reason) {
util::Promise promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
if (@available(macOS 10.12.2, *)) {
base::scoped_nsobject<LAContext> context([[LAContext alloc] init]);
base::ScopedCFTypeRef<SecAccessControlRef> access_control =
base::ScopedCFTypeRef<SecAccessControlRef>(
SecAccessControlCreateWithFlags(
kCFAllocatorDefault,
kSecAttrAccessibleWhenUnlockedThisDeviceOnly,
kSecAccessControlPrivateKeyUsage |
kSecAccessControlUserPresence,
nullptr));
scoped_refptr<base::SequencedTaskRunner> runner =
base::SequencedTaskRunnerHandle::Get();
__block util::Promise p = std::move(promise);
[context
evaluateAccessControl:access_control
operation:LAAccessControlOperationUseKeySign
localizedReason:[NSString stringWithUTF8String:reason.c_str()]
reply:^(BOOL success, NSError* error) {
if (!success) {
std::string err_msg = std::string(
[error.localizedDescription UTF8String]);
runner->PostTask(
FROM_HERE,
base::BindOnce(util::Promise::RejectPromise,
std::move(p),
std::move(err_msg)));
} else {
runner->PostTask(
FROM_HERE,
base::BindOnce(
util::Promise::ResolveEmptyPromise,
std::move(p)));
}
}];
} else {
promise.RejectWithErrorMessage(
"This API is not available on macOS versions older than 10.12.2");
}
return handle;
}
// 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 [[NSApplication sharedApplication].effectiveAppearance.name
isEqualToString:NSAppearanceNameDarkAqua];
}
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

@@ -18,8 +18,10 @@
#include "atom/common/native_mate_converters/image_converter.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.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"
@@ -32,8 +34,6 @@
#include "ui/base/win/shell.h"
#endif
#include "atom/common/node_includes.h"
#if defined(OS_WIN)
namespace mate {
@@ -158,7 +158,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 +266,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 +293,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());
}
@@ -546,11 +547,9 @@ std::vector<int> TopLevelWindow::GetPosition() {
return result;
}
#if defined(OS_WIN) || defined(OS_MACOSX)
void TopLevelWindow::MoveTop() {
window_->MoveTop();
}
#endif
void TopLevelWindow::SetTitle(const std::string& title) {
window_->SetTitle(title);
@@ -568,6 +567,14 @@ void TopLevelWindow::SetSkipTaskbar(bool skip) {
window_->SetSkipTaskbar(skip);
}
void TopLevelWindow::SetExcludedFromShownWindowsMenu(bool excluded) {
window_->SetExcludedFromShownWindowsMenu(excluded);
}
bool TopLevelWindow::IsExcludedFromShownWindowsMenu() {
return window_->IsExcludedFromShownWindowsMenu();
}
void TopLevelWindow::SetSimpleFullScreen(bool simple_fullscreen) {
window_->SetSimpleFullScreen(simple_fullscreen);
}
@@ -641,9 +648,11 @@ void TopLevelWindow::SetFocusable(bool focusable) {
}
void TopLevelWindow::SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> value) {
auto context = isolate->GetCurrentContext();
mate::Handle<Menu> menu;
if (value->IsObject() &&
mate::V8ToString(value->ToObject()->GetConstructorName()) == "Menu" &&
v8::Local<v8::Object> object;
if (value->IsObject() && value->ToObject(context).ToLocal(&object) &&
gin::V8ToString(isolate, object->GetConstructorName()) == "Menu" &&
mate::ConvertFromV8(isolate, value, &menu) && !menu.IsEmpty()) {
menu_.Reset(isolate, menu.ToV8());
window_->SetMenu(menu->model());
@@ -656,6 +665,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 +683,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 +693,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 +774,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 +878,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 +992,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() {
@@ -1015,9 +1073,7 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate,
.SetMethod("setResizable", &TopLevelWindow::SetResizable)
.SetMethod("isResizable", &TopLevelWindow::IsResizable)
.SetMethod("setMovable", &TopLevelWindow::SetMovable)
#if defined(OS_WIN) || defined(OS_MACOSX)
.SetMethod("moveTop", &TopLevelWindow::MoveTop)
#endif
.SetMethod("isMovable", &TopLevelWindow::IsMovable)
.SetMethod("setMinimizable", &TopLevelWindow::SetMinimizable)
.SetMethod("isMinimizable", &TopLevelWindow::IsMinimizable)
@@ -1056,10 +1112,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)
@@ -1085,6 +1142,9 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate,
.SetMethod("addTabbedWindow", &TopLevelWindow::AddTabbedWindow)
.SetMethod("setWindowButtonVisibility",
&TopLevelWindow::SetWindowButtonVisibility)
.SetProperty("excludedFromShownWindowsMenu",
&TopLevelWindow::IsExcludedFromShownWindowsMenu,
&TopLevelWindow::SetExcludedFromShownWindowsMenu)
#endif
.SetMethod("setAutoHideMenuBar", &TopLevelWindow::SetAutoHideMenuBar)
.SetMethod("isMenuBarAutoHide", &TopLevelWindow::IsMenuBarAutoHide)
@@ -1097,6 +1157,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 +1192,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 +1206,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;
@@ -124,9 +126,7 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
void SetResizable(bool resizable);
bool IsResizable();
void SetMovable(bool movable);
#if defined(OS_WIN) || defined(OS_MACOSX)
void MoveTop();
#endif
bool IsMovable();
void SetMinimizable(bool minimizable);
bool IsMinimizable();
@@ -145,6 +145,8 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
std::string GetTitle();
void FlashFrame(bool flash);
void SetSkipTaskbar(bool skip);
void SetExcludedFromShownWindowsMenu(bool excluded);
bool IsExcludedFromShownWindowsMenu();
void SetSimpleFullScreen(bool simple_fullscreen);
bool IsSimpleFullScreen();
void SetKiosk(bool kiosk);
@@ -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

@@ -59,11 +59,7 @@ Tray::Tray(v8::Isolate* isolate,
InitWith(isolate, wrapper);
}
Tray::~Tray() {
// Destroy the native tray in next tick.
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE,
tray_icon_.release());
}
Tray::~Tray() = default;
// static
mate::WrappableBase* Tray::New(mate::Handle<NativeImage> image,
@@ -159,7 +155,17 @@ void Tray::SetToolTip(const std::string& tool_tip) {
}
void Tray::SetTitle(const std::string& title) {
#if defined(OS_MACOSX)
tray_icon_->SetTitle(title);
#endif
}
std::string Tray::GetTitle() {
#if defined(OS_MACOSX)
return tray_icon_->GetTitle();
#else
return "";
#endif
}
void Tray::SetHighlightMode(TrayIcon::HighlightMode mode) {
@@ -227,6 +233,7 @@ void Tray::BuildPrototype(v8::Isolate* isolate,
.SetMethod("setPressedImage", &Tray::SetPressedImage)
.SetMethod("setToolTip", &Tray::SetToolTip)
.SetMethod("setTitle", &Tray::SetTitle)
.SetMethod("getTitle", &Tray::GetTitle)
.SetMethod("setHighlightMode", &Tray::SetHighlightMode)
.SetMethod("setIgnoreDoubleClickEvents",
&Tray::SetIgnoreDoubleClickEvents)
@@ -254,9 +261,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

@@ -69,6 +69,7 @@ class Tray : public mate::TrackableObject<Tray>, public TrayIconObserver {
void SetPressedImage(v8::Isolate* isolate, mate::Handle<NativeImage> image);
void SetToolTip(const std::string& tool_tip);
void SetTitle(const std::string& title);
std::string GetTitle();
void SetHighlightMode(TrayIcon::HighlightMode mode);
void SetIgnoreDoubleClickEvents(bool ignore);
bool GetIgnoreDoubleClickEvents();

View File

@@ -354,7 +354,7 @@ void URLRequest::OnReceivedRedirect(
}
void URLRequest::OnAuthenticationRequired(
scoped_refptr<const net::AuthChallengeInfo> auth_info) {
const net::AuthChallengeInfo& auth_info) {
if (request_state_.Canceled() || request_state_.Closed()) {
return;
}
@@ -364,7 +364,7 @@ void URLRequest::OnAuthenticationRequired(
return;
}
Emit("login", auth_info.get(),
Emit("login", auth_info,
base::Bind(&AtomURLRequest::PassLoginInformation, atom_request_));
}

View File

@@ -105,8 +105,7 @@ class URLRequest : public mate::EventEmitter<URLRequest> {
const std::string& method,
const GURL& url,
scoped_refptr<net::HttpResponseHeaders> response_headers);
void OnAuthenticationRequired(
scoped_refptr<const net::AuthChallengeInfo> auth_info);
void OnAuthenticationRequired(const net::AuthChallengeInfo& auth_info);
void OnResponseStarted(
scoped_refptr<net::HttpResponseHeaders> response_headers);
void OnResponseData(scoped_refptr<const net::IOBufferWithSize> data);

View File

@@ -4,9 +4,8 @@
#include "atom/browser/api/atom_api_view.h"
#include "native_mate/dictionary.h"
#include "atom/common/node_includes.h"
#include "native_mate/dictionary.h"
namespace atom {
@@ -76,8 +75,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 +85,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)

File diff suppressed because it is too large Load Diff

View File

@@ -5,6 +5,7 @@
#ifndef ATOM_BROWSER_API_ATOM_API_WEB_CONTENTS_H_
#define ATOM_BROWSER_API_ATOM_API_WEB_CONTENTS_H_
#include <map>
#include <memory>
#include <string>
#include <vector>
@@ -15,24 +16,29 @@
#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"
#include "content/public/browser/web_contents_binding_set.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/favicon_url.h"
#include "electron/atom/common/api/api.mojom.h"
#include "electron/buildflags/buildflags.h"
#include "native_mate/handle.h"
#include "printing/backend/print_backend.h"
#include "printing/buildflags/buildflags.h"
#include "services/service_manager/public/cpp/binder_registry.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 +52,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,16 +65,20 @@ 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.
class WebContents : public mate::TrackableObject<WebContents>,
public CommonWebContentsDelegate,
public content::WebContentsObserver {
public content::WebContentsObserver,
public mojom::ElectronBrowser {
public:
enum Type {
BACKGROUND_PAGE, // A DevTools extension background page.
@@ -79,29 +89,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;
@@ -124,9 +156,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
void SetUserAgent(const std::string& user_agent, mate::Arguments* args);
std::string GetUserAgent();
void InsertCSS(const std::string& css);
bool SavePage(const base::FilePath& full_file_path,
const content::SavePageType& save_type,
const SavePageHandler::SavePageCallback& callback);
v8::Local<v8::Promise> SavePage(const base::FilePath& full_file_path,
const content::SavePageType& save_type);
void OpenDevTools(mate::Arguments* args);
void CloseDevTools();
bool IsDevToolsOpened();
@@ -135,22 +166,22 @@ class WebContents : public mate::TrackableObject<WebContents>,
void EnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
void DisableDeviceEmulation();
void InspectElement(int x, int y);
void InspectSharedWorker();
void InspectServiceWorker();
void HasServiceWorker(const base::Callback<void(bool)>&);
void UnregisterServiceWorker(const base::Callback<void(bool)>&);
void SetIgnoreMenuShortcuts(bool ignore);
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);
v8::Local<v8::Promise> PrintToPDF(const base::DictionaryValue& settings);
#endif
// DevTools workspace api.
void AddWorkSpace(mate::Arguments* args, const base::FilePath& path);
@@ -190,6 +221,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 +239,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 +287,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;
@@ -256,8 +296,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
// the specified URL.
void GrantOriginAccess(const GURL& url);
bool TakeHeapSnapshot(const base::FilePath& file_path,
const std::string& channel);
void TakeHeapSnapshot(const base::FilePath& file_path,
base::Callback<void(bool)>);
// Properties.
int32_t ID() const;
@@ -272,27 +312,34 @@ 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,
int32_t level,
blink::mojom::ConsoleMessageLevel level,
const base::string16& message,
int32_t line_no,
const base::string16& source_id) override;
@@ -319,7 +366,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(
@@ -337,7 +384,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
void RendererResponsive(
content::WebContents* source,
content::RenderWidgetHost* render_widget_host) override;
bool HandleContextMenu(const content::ContextMenuParams& params) override;
bool HandleContextMenu(content::RenderFrameHost* render_frame_host,
const content::ContextMenuParams& params) override;
bool OnGoToEntryOffset(int offset) override;
void FindReply(content::WebContents* web_contents,
int request_id,
@@ -347,7 +395,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,10 +411,14 @@ 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 RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
void DocumentLoadedInFrame(
content::RenderFrameHost* render_frame_host) override;
void DidFinishLoad(content::RenderFrameHost* render_frame_host,
@@ -395,17 +447,22 @@ class WebContents : public mate::TrackableObject<WebContents>,
void PluginCrashed(const base::FilePath& plugin_path,
base::ProcessId plugin_pid) override;
void MediaStartedPlaying(const MediaPlayerInfo& video_type,
const MediaPlayerId& id) override;
const content::MediaPlayerId& id) override;
void MediaStoppedPlaying(
const MediaPlayerInfo& video_type,
const MediaPlayerId& id,
const content::MediaPlayerId& id,
content::WebContentsObserver::MediaStoppedReason reason) override;
void DidChangeThemeColor(SkColor theme_color) override;
void DidChangeThemeColor(base::Optional<SkColor> theme_color) override;
void OnInterfaceRequestFromFrame(
content::RenderFrameHost* render_frame_host,
const std::string& interface_name,
mojo::ScopedMessagePipeHandle* interface_pipe) 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;
@@ -421,35 +478,37 @@ class WebContents : public mate::TrackableObject<WebContents>,
struct FrameDispatchHelper;
AtomBrowserContext* GetBrowserContext() const;
// Binds the given request for the ElectronBrowser API. When the
// RenderFrameHost is destroyed, all related bindings will be removed.
void BindElectronBrowser(mojom::ElectronBrowserRequest request,
content::RenderFrameHost* render_frame_host);
void OnElectronBrowserConnectionError();
uint32_t GetNextRequestId() { return ++request_id_; }
#if BUILDFLAG(ENABLE_OSR)
OffScreenWebContentsView* GetOffScreenWebContentsView() const;
OffScreenWebContentsView* GetOffScreenWebContentsView() const override;
OffScreenRenderWidgetHostView* GetOffScreenRenderWidgetHostView() const;
#endif
// mojom::ElectronBrowser
void Message(bool internal,
const std::string& channel,
base::Value arguments) override;
void MessageSync(bool internal,
const std::string& channel,
base::Value arguments,
MessageSyncCallback callback) override;
void MessageTo(bool internal,
bool send_to_all,
int32_t web_contents_id,
const std::string& channel,
base::Value arguments) override;
void MessageHost(const std::string& channel, base::Value arguments) override;
// Called when we receive a CursorChange message from chromium.
void OnCursorChange(const content::WebCursor& cursor);
// Called when received a message from renderer.
void OnRendererMessage(content::RenderFrameHost* frame_host,
const std::string& channel,
const base::ListValue& args);
// Called when received a synchronous message from renderer.
void OnRendererMessageSync(content::RenderFrameHost* frame_host,
const std::string& channel,
const base::ListValue& args,
IPC::Message* message);
// Called when received a message from renderer to be forwarded.
void OnRendererMessageTo(content::RenderFrameHost* frame_host,
bool internal,
bool send_to_all,
int32_t web_contents_id,
const std::string& channel,
const base::ListValue& args);
// Called when received a synchronous message from renderer to
// set temporary zoom level.
void OnSetTemporaryZoomLevel(content::RenderFrameHost* frame_host,
@@ -470,7 +529,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 +552,17 @@ 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;
service_manager::BinderRegistryWithArgs<content::RenderFrameHost*> registry_;
mojo::BindingSet<mojom::ElectronBrowser, content::RenderFrameHost*> bindings_;
std::map<content::RenderFrameHost*, std::vector<mojo::BindingId>>
frame_to_bindings_map_;
base::WeakPtrFactory<WebContents> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(WebContents);
};

View File

@@ -0,0 +1,62 @@
// 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/atom_api_web_contents.h"
#include "content/browser/frame_host/frame_tree.h" // nogncheck
#include "content/browser/frame_host/frame_tree_node.h" // nogncheck
#include "content/browser/web_contents/web_contents_impl.h" // nogncheck
#include "content/public/browser/guest_mode.h"
#if BUILDFLAG(ENABLE_OSR)
#include "atom/browser/osr/osr_render_widget_host_view.h"
#include "atom/browser/osr/osr_web_contents_view.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:
// error C2371: 'ssize_t': redefinition; different basic types
namespace atom {
namespace api {
void WebContents::DetachFromOuterFrame() {
// See detach_webview_frame.patch on how to detach.
DCHECK(content::GuestMode::IsCrossProcessFrameGuest(web_contents()));
int frame_tree_node_id =
static_cast<content::WebContentsImpl*>(web_contents())
->GetOuterDelegateFrameTreeNodeId();
if (frame_tree_node_id != content::FrameTreeNode::kFrameTreeNodeInvalidId) {
auto* node = content::FrameTreeNode::GloballyFindByID(frame_tree_node_id);
DCHECK(node->parent());
node->frame_tree()->RemoveFrame(node);
}
}
#if BUILDFLAG(ENABLE_OSR)
OffScreenWebContentsView* WebContents::GetOffScreenWebContentsView() const {
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 {
if (IsOffScreen()) {
return static_cast<OffScreenRenderWidgetHostView*>(
web_contents()->GetRenderWidgetHostView());
} else {
return nullptr;
}
}
#endif
} // namespace api
} // namespace atom

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

@@ -1,33 +0,0 @@
// 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/atom_api_web_contents.h"
#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"
// 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:
// error C2371: 'ssize_t': redefinition; different basic types
namespace atom {
namespace api {
OffScreenWebContentsView* WebContents::GetOffScreenWebContentsView() const {
const auto* impl =
static_cast<const content::WebContentsImpl*>(web_contents());
return static_cast<OffScreenWebContentsView*>(impl->GetView());
}
OffScreenRenderWidgetHostView* WebContents::GetOffScreenRenderWidgetHostView()
const {
return static_cast<OffScreenRenderWidgetHostView*>(
web_contents()->GetRenderWidgetHostView());
}
} // namespace api
} // namespace atom

View File

@@ -5,8 +5,10 @@
#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 "atom/common/node_includes.h"
#include "content/public/browser/web_contents_user_data.h"
#include "native_mate/dictionary.h"
@@ -14,8 +16,6 @@
#include "atom/browser/ui/cocoa/delayed_native_view_host.h"
#endif
#include "atom/common/node_includes.h"
namespace {
// Used to indicate whether a WebContents already has a view.
@@ -30,12 +30,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 +45,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 +66,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 +130,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

@@ -7,14 +7,11 @@
#include "atom/browser/web_view_manager.h"
#include "atom/common/native_mate_converters/content_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "atom/common/options_switches.h"
#include "content/public/browser/browser_context.h"
#include "native_mate/dictionary.h"
// Must be the last in the includes list.
// See https://github.com/electron/electron/issues/10363
#include "atom/common/node_includes.h"
using atom::WebContentsPreferences;
namespace {
@@ -55,4 +52,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

@@ -4,6 +4,8 @@
#include "atom/browser/api/event.h"
#include <utility>
#include "atom/common/api/api_messages.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
@@ -20,11 +22,11 @@ Event::Event(v8::Isolate* isolate) {
Event::~Event() {}
void Event::SetSenderAndMessage(content::RenderFrameHost* sender,
IPC::Message* message) {
base::Optional<MessageSyncCallback> callback) {
DCHECK(!sender_);
DCHECK(!message_);
DCHECK(!callback_);
sender_ = sender;
message_ = message;
callback_ = std::move(callback);
Observe(content::WebContents::FromRenderFrameHost(sender));
}
@@ -33,7 +35,7 @@ void Event::RenderFrameDeleted(content::RenderFrameHost* rfh) {
if (sender_ != rfh)
return;
sender_ = nullptr;
message_ = nullptr;
callback_.reset();
}
void Event::RenderFrameHostChanged(content::RenderFrameHost* old_rfh,
@@ -46,22 +48,23 @@ void Event::FrameDeleted(content::RenderFrameHost* rfh) {
if (sender_ != rfh)
return;
sender_ = nullptr;
message_ = nullptr;
callback_.reset();
}
void Event::PreventDefault(v8::Isolate* isolate) {
GetWrapper()->Set(StringToV8(isolate, "defaultPrevented"), v8::True(isolate));
GetWrapper()
->Set(isolate->GetCurrentContext(),
StringToV8(isolate, "defaultPrevented"), v8::True(isolate))
.Check();
}
bool Event::SendReply(const base::ListValue& result) {
if (message_ == nullptr || sender_ == nullptr)
if (!callback_ || sender_ == nullptr)
return false;
AtomFrameHostMsg_Message_Sync::WriteReplyParams(message_, result);
bool success = sender_->Send(message_);
message_ = nullptr;
sender_ = nullptr;
return success;
std::move(*callback_).Run(result.Clone());
callback_.reset();
return true;
}
// static

View File

@@ -5,7 +5,9 @@
#ifndef ATOM_BROWSER_API_EVENT_H_
#define ATOM_BROWSER_API_EVENT_H_
#include "base/optional.h"
#include "content/public/browser/web_contents_observer.h"
#include "electron/atom/common/api/api.mojom.h"
#include "native_mate/handle.h"
#include "native_mate/wrappable.h"
@@ -17,6 +19,7 @@ namespace mate {
class Event : public Wrappable<Event>, public content::WebContentsObserver {
public:
using MessageSyncCallback = atom::mojom::ElectronBrowser::MessageSyncCallback;
static Handle<Event> Create(v8::Isolate* isolate);
static void BuildPrototype(v8::Isolate* isolate,
@@ -24,7 +27,7 @@ class Event : public Wrappable<Event>, public content::WebContentsObserver {
// Pass the sender and message to be replied.
void SetSenderAndMessage(content::RenderFrameHost* sender,
IPC::Message* message);
base::Optional<MessageSyncCallback> callback);
// event.PreventDefault().
void PreventDefault(v8::Isolate* isolate);
@@ -45,7 +48,7 @@ class Event : public Wrappable<Event>, public content::WebContentsObserver {
private:
// Replyer for the synchronous messages.
content::RenderFrameHost* sender_ = nullptr;
IPC::Message* message_ = nullptr;
base::Optional<MessageSyncCallback> callback_;
DISALLOW_COPY_AND_ASSIGN(Event);
};

View File

@@ -4,14 +4,16 @@
#include "atom/browser/api/event_emitter.h"
#include <utility>
#include "atom/browser/api/event.h"
#include "atom/common/node_includes.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"
#include "ui/events/event_constants.h"
#include "atom/common/node_includes.h"
namespace mate {
namespace {
@@ -34,28 +36,34 @@ v8::Local<v8::Object> CreateEventObject(v8::Isolate* isolate) {
}
return v8::Local<v8::ObjectTemplate>::New(isolate, event_template)
->NewInstance();
->NewInstance(isolate->GetCurrentContext())
.ToLocalChecked();
}
} // namespace
namespace internal {
v8::Local<v8::Object> CreateJSEvent(v8::Isolate* isolate,
v8::Local<v8::Object> object,
content::RenderFrameHost* sender,
IPC::Message* message) {
v8::Local<v8::Object> CreateJSEvent(
v8::Isolate* isolate,
v8::Local<v8::Object> object,
content::RenderFrameHost* sender,
base::Optional<atom::mojom::ElectronBrowser::MessageSyncCallback>
callback) {
v8::Local<v8::Object> event;
bool use_native_event = sender && message;
bool use_native_event = sender && callback;
if (use_native_event) {
mate::Handle<mate::Event> native_event = mate::Event::Create(isolate);
native_event->SetSenderAndMessage(sender, message);
native_event->SetSenderAndMessage(sender, std::move(callback));
event = v8::Local<v8::Object>::Cast(native_event.ToV8());
} 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;
}
@@ -74,6 +82,7 @@ v8::Local<v8::Object> CreateEventFromFlags(v8::Isolate* isolate, int flags) {
obj.Set("ctrlKey", static_cast<bool>(flags & ui::EF_CONTROL_DOWN));
obj.Set("altKey", static_cast<bool>(flags & ui::EF_ALT_DOWN));
obj.Set("metaKey", static_cast<bool>(flags & ui::EF_COMMAND_DOWN));
obj.Set("triggeredByAccelerator", static_cast<bool>(flags));
return obj.GetHandle();
}

View File

@@ -5,27 +5,28 @@
#ifndef ATOM_BROWSER_API_EVENT_EMITTER_H_
#define ATOM_BROWSER_API_EVENT_EMITTER_H_
#include <utility>
#include <vector>
#include "atom/common/api/event_emitter_caller.h"
#include "base/optional.h"
#include "content/public/browser/browser_thread.h"
#include "electron/atom/common/api/api.mojom.h"
#include "native_mate/wrappable.h"
namespace content {
class RenderFrameHost;
}
namespace IPC {
class Message;
}
namespace mate {
namespace internal {
v8::Local<v8::Object> CreateJSEvent(v8::Isolate* isolate,
v8::Local<v8::Object> object,
content::RenderFrameHost* sender,
IPC::Message* message);
v8::Local<v8::Object> CreateJSEvent(
v8::Isolate* isolate,
v8::Local<v8::Object> object,
content::RenderFrameHost* sender,
base::Optional<atom::mojom::ElectronBrowser::MessageSyncCallback> callback);
v8::Local<v8::Object> CreateCustomEvent(v8::Isolate* isolate,
v8::Local<v8::Object> object,
v8::Local<v8::Object> event);
@@ -68,23 +69,25 @@ class EventEmitter : public Wrappable<T> {
// this.emit(name, new Event(), args...);
template <typename... Args>
bool Emit(const base::StringPiece& name, const Args&... args) {
return EmitWithSender(name, nullptr, nullptr, args...);
return EmitWithSender(name, nullptr, base::nullopt, args...);
}
// this.emit(name, new Event(sender, message), args...);
template <typename... Args>
bool EmitWithSender(const base::StringPiece& name,
content::RenderFrameHost* sender,
IPC::Message* message,
const Args&... args) {
bool EmitWithSender(
const base::StringPiece& name,
content::RenderFrameHost* sender,
base::Optional<atom::mojom::ElectronBrowser::MessageSyncCallback>
callback,
const Args&... args) {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
v8::Local<v8::Object> wrapper = GetWrapper();
if (wrapper.IsEmpty()) {
return false;
}
v8::Local<v8::Object> event =
internal::CreateJSEvent(isolate(), wrapper, sender, message);
v8::Local<v8::Object> event = internal::CreateJSEvent(
isolate(), wrapper, sender, std::move(callback));
return EmitWithEvent(name, event, args...);
}
@@ -97,11 +100,17 @@ 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();
auto context = isolate()->GetCurrentContext();
v8::Local<v8::Value> defaultPrevented;
if (event->Get(context, StringToV8(isolate(), "defaultPrevented"))
.ToLocal(&defaultPrevented)) {
return defaultPrevented->BooleanValue(isolate());
}
return false;
}
DISALLOW_COPY_AND_ASSIGN(EventEmitter);

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