Compare commits

...

392 Commits

Author SHA1 Message Date
Electron Bot
d1ae575c66 Bump v5.0.11 2019-09-24 13:39:15 -07:00
Samuel Attard
07f0f577c2 Revert "Bump v5.0.11"
This reverts commit db96d05fed.
2019-09-24 13:37:44 -07:00
trop[bot]
b07ec8d7b1 build: use a lower process count for publish builds with no sccache (#20337) 2019-09-24 13:36:28 -07:00
trop[bot]
c7b320163b fix: correct 'Entire screen' to ' Entire Screen' (#20300) 2019-09-20 07:44:19 -07:00
trop[bot]
00bc8c265a fix: crash when exiting simple fullscreen on macOS (#20144) (#20291) 2019-09-20 10:37:48 -04:00
Shelley Vohr
1f658e98a3 docs: improve and add examples for clipboard (#20224) (#20283) (#20288)
* docs: improve and add examples for clipboard

* address feedback from jkleinsc review
2019-09-20 10:21:10 -04:00
Electron Bot
db96d05fed Bump v5.0.11 2019-09-18 12:48:14 -07:00
trop[bot]
f0f0f20a7e fix: strip chrome-sandbox typo (#20259) 2019-09-18 09:44:11 -07:00
Pedro Pontes
b39978d7ed fix: Add more checks in MojoCdmService. (#20221)
Applies b7b305f338%5E%21/
2019-09-17 13:04:06 -04:00
trop[bot]
052f14b977 build: get all the release assets when looking for one to delete (#20166)
* build: get all the release assets when looking for one to delete

yeah we totally have more than 30....

* Update upload-to-github.js
2019-09-09 06:07:22 -07:00
John Kleinschmidt
9192c85b10 ci: do not run WOA builds on older versions of Electron (#20090) 2019-09-04 17:23:27 -04:00
trop[bot]
24f454557d Revert "fix: make sure that menu bar gets focus even when you click an item to focus it first (#19710)" (#20034)
This reverts commit 27b2747b61.
2019-09-03 23:18:49 -07:00
trop[bot]
6d52197c8c fix: strip chrome_sandbox executable (#20082) 2019-09-03 09:49:17 -07:00
trop[bot]
c9b0b52f3f fix: honor cursor blink rate (#20045)
* fix: honor cursor blink rate on macOS

* fix: honor cursor blink rate on Linux

* fix: honor cursor blink rate on Windows

* refactor: clean up os_win cursor blink logic

* remove unneeded include
2019-09-03 16:22:03 +09:00
Charles Kerr
cb67e6ebc5 fix: i18n of gtk msgbox buttons (#20010)
* fix: i18n of gtk msgbox buttons

Manually backport #19904. See that PR for details.

* fix: make linter happy

* fix: make linter happy
2019-08-29 15:28:20 +09:00
Shelley Vohr
e441ac1c5a fix: add default media usage strings to info.plist (#19950) 2019-08-27 10:50:40 -04:00
Cheng Zhao
9591975f32 fix: notify views of content view size change (#19882) 2019-08-26 10:11:02 -07:00
trop[bot]
6cd9f303fe fix: command-line scheme switch values' spillover (#19939) 2019-08-25 23:01:44 -07:00
trop[bot]
65d2dd262d build: ninja count should be 2*cores + 2 (#19868) 2019-08-21 08:53:09 -07:00
Electron Bot
095d690062 Bump v5.0.10 2019-08-19 14:30:51 -07:00
trop[bot]
8b1594de25 chore: upgrades-wg owns DEPS (#19832) 2019-08-19 14:04:08 -07:00
Pedro Pontes
33a007383d fix: always use new site instance for a new navigation. (#19828) 2019-08-19 12:04:26 -07:00
Erick Zhao
1d9c3d7d2a fix: normalize behavior of win.setOpacity() for invalid number values across operating systems (#19724)
* fix: normalize behavior of `win.setOpacity()` for invalid number values across operating systems

* expect -> assert

* assert 2

* fix `this` scoping

* fix equality

* tests
2019-08-18 17:47:43 -07:00
John Kleinschmidt
c00f71513b ci: fix flaky test on arm (5-0-x) (#19806)
* ci: update docker options for arm testing
2019-08-16 16:36:59 -04:00
Charles Kerr
9c2d9ba6de fix: i18n gtk dialog buttons (#19801)
manual backport of https://github.com/electron/electron/pull/19756
2019-08-16 13:28:08 -07:00
trop[bot]
88605dd94a MessageBoxOptions.icon should allow string (#19796) 2019-08-16 13:25:30 -07:00
trop[bot]
a14285bebe fix: make sure that menu bar gets focus even when you click an item to focus it first (#19763) 2019-08-15 10:30:16 -07:00
Micha Hanselmann
b58b5980a4 fix: return correct bounds on will-resize (#19705) 2019-08-14 07:56:09 -07:00
trop[bot]
11037230eb docs: update hasShadow for win and linux (#19675) (#19721) 2019-08-12 20:57:26 -07:00
trop[bot]
bac953292f fix: avoid losing focus on inputs when opening menu (Windows/Linux) (#19707)
* remove cause of issue

* remove comment
2019-08-12 19:45:21 -07:00
Shelley Vohr
3fdfa68bd2 fix: crash on window.print() (#19678) 2019-08-08 07:52:42 -07:00
Shelley Vohr
0289c19a07 fix: serialize messages being sent over chrome message ports (#19654) 2019-08-07 08:44:22 -07:00
Electron Bot
97df834c1c Bump v5.0.9 2019-08-06 10:23:09 -07:00
Shelley Vohr
d98735cff7 fix: ensure the webContents is not destroyed before communicating (#18467) (#19627) 2019-08-06 08:56:07 -07:00
Shelley Vohr
9e0eb96141 docs: explanation on using protocols with partitions (#19628) 2019-08-06 08:54:12 -07:00
Erick Zhao
753501442f fix: handle edge behavior for about panel on Linux (#19634) 2019-08-06 08:50:13 -07:00
Shelley Vohr
303559e2f1 fix: clearRecentDocuments role on Windows (#19599) (#19640)
* fix: clear recent documents on windows

* chore: don't check for version < win 7
2019-08-06 08:37:32 -07:00
Cheng Zhao
5a8bdb2380 fix: the callback of beginFrameSubscription should pass NativeImage instead of Buffer (#17548) (#19647)
* Revert "revert: frame subscriber deprecation and re-enable tests"

This reverts commit f643ce4f66.

* fix: make sure SkBitmap's pixels are copied
2019-08-06 08:37:13 -07:00
Mark Lee
21aaf670ce docs: clean up the native module tutorial (#19629)
This is a backport of #17624 for 5-0-x.
2019-08-05 15:10:41 -07:00
trop[bot]
fa2b3a3767 fix: throw on invalid webRequest filters (#19580)
* fix: throw on invalid webRequest filters (#19337)

Closes #11371.

Previously, we didn't consider the return value of the webRequest URLPattern mate converter, which meant that when the pattern wasn't correctly parsed owing to invalid filter specification users would not be made aware of that fact and would just think that the filtering itself had failed. This corrects that error by moving the business logic of url pattern parsing out of the converter and into the function itself so that granular and specific errors can be thrown.

There's also no real reason that i'm aware of not to allow wider breadth of filters by letting users use a wildcard for effective TLD, so I also overrode that (default for the 1-arg Parse is not to allow that).

Finally, I added some examples of url filter types for users to reference.

* fix expect call test failure
2019-08-05 16:14:46 +09:00
Shelley Vohr
fc94fb4480 fix: destroy tray on current tick (#18196) (#19619)
This code was originally added in #6448 to handle an edge case crash in 10.9, and we no longer support 10.9 and therefore no longer need to account for this case.

It addressed the crash, but also created a race condition whereby when a new tray is created the old tray's destroy wouldn't have been fully completed and therefore a new one would be spawned. This fixes that by destroying the tray on the current tick once more.
2019-08-05 09:46:23 +09:00
trop[bot]
f5d936d52c fix: set size of GTK about panel icon (#18957) (#19581) 2019-08-02 19:07:16 -07:00
Micha Hanselmann
b4f5c4ba4a fix: make process.uptime() return the correct time (#19436) (#19566) 2019-08-01 14:02:00 -07:00
John Kleinschmidt
3af498e17c fix: use WeakPtr to detect deletion (#19561)
(cherry picked from commit 4bcf99dc20)
2019-08-01 14:01:40 -07:00
trop[bot]
670291b0ab fix: tray.displayBalloon() does not work with custom icon on Windows (#19530) 2019-07-30 09:22:32 -07:00
trop[bot]
7b6a14b667 fix: remove .pdb from symbol file names (#19503)
* fix: remove .pdb from symbol file names

* Update dump_syms.py
2019-07-30 09:21:42 -07:00
Shelley Vohr
4fa89a1fbc fix: correctly emit BrowserWindow alwaysOnTop status (#19506) 2019-07-30 08:46:29 -07:00
trop[bot]
6b0eaa4832 fix: clearing of the backgroundColor property on TouchBarButton (#19473) 2019-07-29 17:17:13 -07:00
trop[bot]
bc30aeac7c add desc (#19509) 2019-07-29 17:15:31 -07:00
trop[bot]
c5573d2b6c chore: omit superceded Chromium updates from notes (#19407)
* feat: omit superceded Chromium updates from notes

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

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

* chore: update old patch headers

(cherry picked from commit 0146cc0eb5)

* Update patch for 5-0-x

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

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

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

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

* chore: refactor to use base::Value

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

* main -> key

* remove useless code

* test: Add focus event spec

* test: more robust spec

* test: simplify test

* duplicate non-firing macOS event listener 😳

* destroy 🚨

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

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

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

* Backport Chromium fix crash when detaching OOPIF

Backport of 7464a6b4e3%5E%21

* Move portals_fix_crash_when_detaching_oopif_from_portal.patch as first patch

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

* lint fix

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

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

* chore: use manual invocation of npx yarn

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

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

Fixes #17967

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

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

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

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

* correct some types

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

* Some relies on preloads in opened window

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

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

* Make sure to unregisterProtocol in tests

* Introduc and use a NetworkSandbox for tests

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

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

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

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

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

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

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

* update based on @caesar's recommendation

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

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

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

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

* fix: make popup positioning better

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

* fix: unify conditions

* refactor: use PopupViewCommon from chrome directly

* lint: mark constructor explicit

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

* chore: address review suggestions

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

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

* chore: add ref to the NMV registry

* chore: update DEPS for new node revision

* chore: update node ref

* chore: update node ref in DEPS

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

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

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

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

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

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

* link to signed kernel info

* Update docs/api/desktop-capturer.md

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

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

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

* fix: backport boring ssl patch OPENSSL_clear_free

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

* refactor: load electron builtin modules with process._linkedBinding

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

* chore: roll node

* fix: add boringssl backport to support node upgrade

* fix: Update node_includes.h, add DCHECK macros

* fix: Update node Debug Options parser usage

* fix: Fix asar setup

* fix: using v8Util in isolated context

* fix: make "process" available in preload scripts

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

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

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

* chore: update node dep sha

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

This PR does two things.

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

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

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

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

* fix: update OSR patch

* fix: update patch again

* fix: update viz_osr.patch for macOS

* fix: gn check warnings

* chore: no need to change SoftwareOutputDeviceWinProxy

* chore: add check in case we missed something

* fix: consider scale factor when compare size

* fix: make GPU OSR work

* fix: autofill popups with OSR

* chore: use UNIX line ending for osr_video_consumer

* chore: code is already in defined(OS_MACOSX)

* fix: share same OSR implementation on macOS

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

* test: osr window should not crash after navigation

* fix: make osr work on Mac properly

* fix: software osr on windows

* fix: software osr on Linux

* fix: split local surface id allocation into two

* fix: update patch for 5-0-x

* fix: patch and update VideoConsumer to report proper damage_rect

* fix: update patch to resolve compilation error on Linux

* fix: compilation error on mac

* Update osr_host_display_client_mac.mm

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

* chore: santize all regex chars

* chore: extract to helper

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

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

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

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

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

* kick ci

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

* test: add tests

* docs: document webview's nodeintegrationinsubframes

* lint: fix indent

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

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

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

* fix: remove usage of pthread_chdir in MAS builds

* fix: remove usage of setapplicationisdaemon in MAS builds

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

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

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

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

* chore: fix patches, Windows bad, linux good

* Update color_chooser_mac.patch

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

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

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

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

* docs: Added missing `referrer` property in OnBeforeRequestDetails

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

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

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

* Only test native mksnapshot on arm64

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

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

* update ts-defs version

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

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

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

* Flag deprecated methods in documentation

* address comments

* Address review comments

* remove unused variable

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

This reverts commit 3dcb7cfef9.

* ci: make macOS CI faster (#16766)

* ci: cache brew update result

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

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

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

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

* add two new specs

* fix iv length

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

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

* add another spec

* fix linter error

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

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

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

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

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

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

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

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

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

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

* chore: remove original method from docs and code

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

* feat: promisify the Cookie API

* chore: update specs to test promisified cookies

* chore: add deprecate wrapper for cookie callback API

* docs: update docs to cookie promise changes

* chore: remove redundant namespace use

* docs: improve cookie example

* docs: restore docs for cookie callback API

* chore: restore cookie callback tests

* fix: syntax of cookie promise return types

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

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

* feat: promisify contentTracing.stopRecording()

* test: convert specs for new promisified apis

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

* fix: 'BREAKING CHANGE' detection in PR body

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

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

Enable logging on CI

* disable failing tests on Windows 32 bit

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

* chore: deprecate webFrame.registerURLSchemeAsPrivileged

* Add register schemes protocol api

* update branch to enable browser process API

* Revert deprecation changes

* Fetch API support

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

* Update tests

* Remove web frame API

* Minor changes

* update scheme registrations on browser and renderer process

* fix: enable ses.getBlobData spec

* Update breaking changes doc

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

* fix: update docs for protocol API

* upddate source for new attribute name

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

* fix some macos errors

* fix client reset not in guard

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

* Address review comments
2019-01-29 15:59:57 -08:00
trop[bot]
5cc0539919 fix: expose ripemd160 hash from boringssl (#16572)
Ref #16195
2019-01-29 15:58:24 -08:00
trop[bot]
b070774f5c fix: registerStreamProtocol callback with large chunks (backport: 5-0-x) (#16553) 2019-01-28 14:07:14 -08:00
trop[bot]
7a8548d48f docs: cancel is optional in OnHeadersReceivedResponse (#16549) 2019-01-25 09:48:50 -08:00
Electron Bot
ac172abda7 Bump v5.0.0-beta.1 2019-01-22 14:11:16 -08:00
Samuel Attard
29e5195c63 build: fix version bump script for first beta 2019-01-22 14:09:10 -08:00
Samuel Attard
3926d9d717 chore: reset npm version to 5.0.0-beta.0 2019-01-22 13:32:32 -08:00
557 changed files with 18744 additions and 7353 deletions

File diff suppressed because it is too large Load Diff

View File

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

34
.github/CODEOWNERS vendored
View File

@@ -3,19 +3,25 @@
# 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
DEPS @electron/wg-upgrades
# Releases WG
/npm/ @electron/wg-releases
/script/release-notes @electron/wg-releases
/script/prepare-release.js @electron/wg-releases
/script/bump-version.js @electron/wg-releases
/script/ci-release-build.js @electron/wg-releases
/script/release.js @electron/wg-releases
/script/upload-to-github.js @electron/wg-releases
/script/release-artifact-cleanup.js @electron/wg-releases
/script/get-last-major-for-master.js @electron/wg-releases
/script/find-release.js @electron/wg-releases
/script/download-circleci-artifacts.js @electron/wg-releases

View File

@@ -1,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

195
BUILD.gn
View File

@@ -2,7 +2,6 @@ import("//build/config/locales.gni")
import("//build/config/ui.gni")
import("//build/config/win/manifest.gni")
import("//pdf/features.gni")
import("//services/service_manager/public/service_manifest.gni")
import("//third_party/ffmpeg/ffmpeg_options.gni")
import("//tools/generate_library_loader/generate_library_loader.gni")
import("//tools/grit/grit_rule.gni")
@@ -10,6 +9,8 @@ import("//tools/grit/repack.gni")
import("//tools/v8_context_snapshot/v8_context_snapshot.gni")
import("//v8/snapshot_toolchain.gni")
import("build/asar.gni")
import("build/extract_symbols.gni")
import("build/js_wrap.gni")
import("build/npm.gni")
import("buildflags/buildflags.gni")
import("electron_paks.gni")
@@ -53,7 +54,7 @@ config("branding") {
]
}
npm_action("atom_browserify_sandbox") {
npm_action("atom_browserify_sandbox_unwrapped") {
script = "browserify"
inputs = [
@@ -65,7 +66,7 @@ npm_action("atom_browserify_sandbox") {
]
outputs = [
"$target_gen_dir/js2c/preload_bundle.js",
"$target_gen_dir/js2c/preload_bundle_unwrapped.js",
]
args = [
@@ -74,12 +75,14 @@ npm_action("atom_browserify_sandbox") {
"./lib/sandboxed_renderer/api/exports/electron.js:electron",
"-t",
"aliasify",
"--standalone",
"sandboxed_preload",
"-o",
rebase_path(outputs[0]),
]
}
npm_action("atom_browserify_isolated") {
npm_action("atom_browserify_isolated_unwrapped") {
script = "browserify"
inputs = [
@@ -87,18 +90,48 @@ npm_action("atom_browserify_isolated") {
]
outputs = [
"$target_gen_dir/js2c/isolated_bundle.js",
"$target_gen_dir/js2c/isolated_bundle_unwrapped.js",
]
args = [
"lib/isolated_renderer/init.js",
"-t",
"aliasify",
"--standalone",
"isolated_preload",
"-o",
rebase_path(outputs[0]),
]
}
js_wrap("atom_browserify_isolated") {
deps = [
":atom_browserify_isolated_unwrapped",
]
inputs = [
"$target_gen_dir/js2c/isolated_bundle_unwrapped.js",
]
outputs = [
"$target_gen_dir/js2c/isolated_bundle.js",
]
}
js_wrap("atom_browserify_sandbox") {
deps = [
":atom_browserify_sandbox_unwrapped",
]
inputs = [
"$target_gen_dir/js2c/preload_bundle_unwrapped.js",
]
outputs = [
"$target_gen_dir/js2c/preload_bundle.js",
]
}
copy("atom_js2c_copy") {
sources = [
"lib/common/asar.js",
@@ -187,7 +220,6 @@ grit("resources") {
deps = [
":copy_shell_devtools_discovery_page",
":electron_content_manifest_overlays",
]
output_dir = "$target_gen_dir"
@@ -236,6 +268,7 @@ static_library("electron_lib") {
":atom_js2c",
"buildflags",
"chromium_src:chrome",
"manifests",
"native_mate",
"//base",
"//base:base_static",
@@ -261,8 +294,10 @@ static_library("electron_lib") {
"//ppapi/host",
"//ppapi/proxy",
"//ppapi/shared_impl",
"//services/audio/public/mojom:constants",
"//services/device/public/mojom",
"//services/proxy_resolver:lib",
"//services/video_capture/public/mojom:constants",
"//services/viz/privileged/interfaces/compositing",
"//skia",
"//third_party/blink/public:blink",
@@ -323,8 +358,6 @@ static_library("electron_lib") {
"*_views.cc",
"*_views.h",
"*\bviews/*",
"*/autofill_popup.cc",
"*/autofill_popup.h",
]
}
@@ -349,6 +382,10 @@ static_library("electron_lib") {
"//third_party/crashpad/crashpad/client",
"//ui/accelerated_widget_mac",
]
sources += [
"atom/browser/ui/views/autofill_popup_view.cc",
"atom/browser/ui/views/autofill_popup_view.h",
]
include_dirs += [
# NOTE(nornagon): other chromium files use the full path to include
# crashpad; this is just here for compatibility between GN and GYP, so that
@@ -421,11 +458,13 @@ static_library("electron_lib") {
if (enable_osr) {
sources += [
"atom/browser/osr/osr_output_device.cc",
"atom/browser/osr/osr_output_device.h",
"atom/browser/osr/osr_host_display_client.cc",
"atom/browser/osr/osr_host_display_client.h",
"atom/browser/osr/osr_host_display_client_mac.mm",
"atom/browser/osr/osr_render_widget_host_view.cc",
"atom/browser/osr/osr_render_widget_host_view.h",
"atom/browser/osr/osr_render_widget_host_view_mac.mm",
"atom/browser/osr/osr_video_consumer.cc",
"atom/browser/osr/osr_video_consumer.h",
"atom/browser/osr/osr_view_proxy.cc",
"atom/browser/osr/osr_view_proxy.h",
"atom/browser/osr/osr_web_contents_view.cc",
@@ -498,6 +537,7 @@ if (is_mac) {
electron_helper_name = "$electron_product_name Helper"
electron_login_helper_name = "$electron_product_name Login Helper"
electron_framework_version = "A"
electron_version = read_file("ELECTRON_VERSION", "trim string")
mac_xib_bundle_data("electron_xibs") {
sources = [
@@ -580,7 +620,6 @@ if (is_mac) {
}
info_plist = "atom/common/resources/mac/Info.plist"
electron_version = read_file("ELECTRON_VERSION", "trim string")
extra_substitutions = [
"ATOM_BUNDLE_ID=$electron_mac_bundle_id.framework",
"ELECTRON_VERSION=$electron_version",
@@ -599,6 +638,11 @@ if (is_mac) {
"ServiceManagement.framework",
"StoreKit.framework",
]
if (enable_osr) {
libs += [ "IOSurface.framework" ]
}
ldflags = [
"-F",
rebase_path("external_binaries", root_build_dir),
@@ -618,8 +662,10 @@ if (is_mac) {
output_name = electron_helper_name
deps = [
":electron_framework+link",
"//sandbox/mac:seatbelt",
]
if (!is_mas_build) {
deps += [ "//sandbox/mac:seatbelt" ]
}
defines = [ "HELPER_EXECUTABLE" ]
sources = filenames.app_sources
include_dirs = [ "." ]
@@ -744,6 +790,56 @@ if (is_mac) {
"@executable_path/../Frameworks",
]
}
if (enable_dsyms) {
extract_symbols("electron_framework_syms") {
binary = "$root_out_dir/$electron_framework_name.framework/Versions/$electron_framework_version/$electron_framework_name"
symbol_dir = "$root_out_dir/breakpad_symbols"
dsym_file = "$root_out_dir/$electron_framework_name.dSYM/Contents/Resources/DWARF/$electron_framework_name"
deps = [
":electron_framework",
]
}
extract_symbols("electron_helper_syms") {
binary = "$root_out_dir/$electron_helper_name.app/Contents/MacOS/$electron_helper_name"
symbol_dir = "$root_out_dir/breakpad_symbols"
dsym_file = "$root_out_dir/$electron_helper_name.dSYM/Contents/Resources/DWARF/$electron_helper_name"
deps = [
":electron_helper_app",
]
}
extract_symbols("electron_app_syms") {
binary = "$root_out_dir/$electron_product_name.app/Contents/MacOS/$electron_product_name"
symbol_dir = "$root_out_dir/breakpad_symbols"
dsym_file = "$root_out_dir/$electron_product_name.dSYM/Contents/Resources/DWARF/$electron_product_name"
deps = [
":electron_app",
]
}
extract_symbols("crashpad_handler_syms") {
binary = "$root_out_dir/crashpad_handler"
symbol_dir = "$root_out_dir/breakpad_symbols"
dsym_file = "$root_out_dir/crashpad_handler.dSYM/Contents/Resources/DWARF/crashpad_handler"
deps = [
"//third_party/crashpad/crashpad/handler:crashpad_handler",
]
}
group("electron_symbols") {
deps = [
":crashpad_handler_syms",
":electron_app_syms",
":electron_framework_syms",
":electron_helper_syms",
]
}
} else {
group("electron_symbols") {
}
}
} else {
windows_manifest("electron_app_manifest") {
sources = [
@@ -841,6 +937,53 @@ if (is_mac) {
}
}
}
if (is_official_build) {
if (is_linux) {
_target_executable_suffix = ""
_target_shared_library_suffix = ".so"
} else if (is_win) {
_target_executable_suffix = ".exe"
_target_shared_library_suffix = ".dll"
}
extract_symbols("electron_app_symbols") {
binary = "$root_out_dir/$electron_project_name$_target_executable_suffix"
symbol_dir = "$root_out_dir/breakpad_symbols"
deps = [
":electron_app",
]
}
extract_symbols("swiftshader_egl_symbols") {
binary = "$root_out_dir/swiftshader/libEGL$_target_shared_library_suffix"
symbol_dir = "$root_out_dir/breakpad_symbols"
deps = [
"//third_party/swiftshader/src/OpenGL/libEGL:swiftshader_libEGL",
]
}
extract_symbols("swiftshader_gles_symbols") {
binary =
"$root_out_dir/swiftshader/libGLESv2$_target_shared_library_suffix"
symbol_dir = "$root_out_dir/breakpad_symbols"
deps = [
"//third_party/swiftshader/src/OpenGL/libGLESv2:swiftshader_libGLESv2",
]
}
group("electron_symbols") {
deps = [
":electron_app_symbols",
]
if (target_cpu == "x86" || target_cpu == "x64") {
deps += [
":swiftshader_egl_symbols",
":swiftshader_gles_symbols",
]
}
}
}
}
template("dist_zip") {
@@ -914,6 +1057,9 @@ dist_zip("electron_dist_zip") {
":licenses",
":electron_version",
]
if (is_linux) {
data_deps += [ "//sandbox/linux:chrome_sandbox" ]
}
outputs = [
"$root_build_dir/dist.zip",
]
@@ -954,26 +1100,3 @@ group("electron") {
":electron_app",
]
}
group("electron_content_manifest_overlays") {
deps = [
":electron_content_browser_manifest_overlay",
":electron_content_packaged_services_manifest_overlay",
]
}
service_manifest("electron_content_packaged_services_manifest_overlay") {
source = "//electron/manifests/electron_content_packaged_services_manifest_overlay.json"
packaged_services = [ "//services/proxy_resolver:proxy_resolver_manifest" ]
if (enable_basic_printing) {
packaged_services += [
"//chrome/services/printing:manifest",
"//components/services/pdf_compositor:pdf_compositor_manifest",
]
}
}
service_manifest("electron_content_browser_manifest_overlay") {
source = "//electron/manifests/electron_content_browser_manifest_overlay.json"
}

7
DEPS
View File

@@ -10,9 +10,9 @@ gclient_gn_args = [
vars = {
'chromium_version':
'72.0.3626.52',
'73.0.3683.121',
'node_version':
'ad2c89ec3be0f5db3ea02b0f591d36a5d84c51ad',
'666c67e078bddc32f25409f4a929c1e9b5f47373',
'boto_version': 'f7574aa6cc2c819430c1f05e9a1a1a666ef8169b',
'pyyaml_version': '3.12',
@@ -21,6 +21,7 @@ vars = {
'boto_git': 'https://github.com/boto',
'chromium_git': 'https://chromium.googlesource.com',
'electron_git': 'https://github.com/electron',
'nodejs_git': 'https://github.com/nodejs',
'requests_git': 'https://github.com/kennethreitz',
'yaml_git': 'https://github.com/yaml',
@@ -64,7 +65,7 @@ deps = {
'condition': 'checkout_chromium',
},
'src/third_party/electron_node': {
'url': (Var("electron_git")) + '/node.git@' + (Var("node_version")),
'url': (Var("nodejs_git")) + '/node.git@' + (Var("node_version")),
'condition': 'checkout_node',
},
'src/electron/vendor/pyyaml': {

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

View File

@@ -1 +1 @@
5.0.0-nightly.20190122
5.0.11

View File

@@ -32,6 +32,9 @@ environment:
ELECTRON_OUT_DIR: Default
build_script:
- ps: >-
if($env:APPVEYOR_PROJECT_NAME -eq "electron-woa-testing") {
Write-warning "WOA builds not supported on older versions of Electron"; Exit-AppveyorBuild
}
if(($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME -split "/")[0] -eq ($env:APPVEYOR_REPO_NAME -split "/")[0]) {
Write-warning "Skipping PR build for branch"; Exit-AppveyorBuild
}
@@ -68,21 +71,21 @@ build_script:
- appveyor PushArtifact out/ffmpeg/ffmpeg.zip
- ps: >-
if ($env:GN_CONFIG -eq 'release') {
ninja -C out/Default third_party/breakpad:dump_syms
# Needed for msdia140.dll on 64-bit windows
$env:Path += ";$pwd\third_party\llvm-build\Release+Asserts\bin"
ninja -C out/Default electron:electron_symbols
}
- if "%GN_CONFIG%"=="release" ( python electron\script\dump-symbols.py -d %cd%\out\Default\breakpad_symbols -v)
- ps: >-
if ($env:GN_CONFIG -eq 'release') {
python electron\script\zip-symbols.py
appveyor PushArtifact out/Default/symbols.zip
}
- python electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.win.%TARGET_ARCH%.manifest
test_script:
- ps: >-
if ((-Not (Test-Path Env:\ELECTRON_RELEASE)) -And ($env:GN_CONFIG -in "testing", "release")) {
$env:RUN_TESTS="true"
}
- if "%RUN_TESTS%"=="true" ( echo Verifying non proprietary ffmpeg & python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg )
- if "%RUN_TESTS%"=="true" ( echo Verifying mksnapshot & python electron\script\verify-mksnapshot.py --build-dir out\Default --source-root %cd% )
- ps: >-
if ($env:RUN_TESTS -eq 'true') {
New-Item .\out\Default\gen\node_headers\Release -Type directory
@@ -91,8 +94,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

@@ -5,19 +5,17 @@
#include "atom/app/atom_content_client.h"
#include <string>
#include <utility>
#include <vector>
#include "atom/common/atom_version.h"
#include "atom/common/options_switches.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/common/chrome_version.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/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"
@@ -164,14 +162,19 @@ void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
}
void ConvertStringWithSeparatorToVector(std::vector<std::string>* vec,
const char* separator,
const char* cmd_switch) {
void AppendDelimitedSwitchToVector(const base::StringPiece cmd_switch,
std::vector<std::string>* append_me) {
auto* command_line = base::CommandLine::ForCurrentProcess();
auto string_with_separator = command_line->GetSwitchValueASCII(cmd_switch);
if (!string_with_separator.empty())
*vec = base::SplitString(string_with_separator, separator,
base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
auto switch_value = command_line->GetSwitchValueASCII(cmd_switch);
if (!switch_value.empty()) {
constexpr base::StringPiece delimiter(",", 1);
auto tokens =
base::SplitString(switch_value, delimiter, base::TRIM_WHITESPACE,
base::SPLIT_WANT_NONEMPTY);
append_me->reserve(append_me->size() + tokens.size());
std::move(std::begin(tokens), std::end(tokens),
std::back_inserter(*append_me));
}
}
} // namespace
@@ -180,16 +183,6 @@ 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);
}
@@ -213,18 +206,19 @@ base::RefCountedMemory* AtomContentClient::GetDataResourceBytes(
}
void AtomContentClient::AddAdditionalSchemes(Schemes* schemes) {
schemes->standard_schemes.push_back("chrome-extension");
AppendDelimitedSwitchToVector(switches::kServiceWorkerSchemes,
&schemes->service_worker_schemes);
AppendDelimitedSwitchToVector(switches::kStandardSchemes,
&schemes->standard_schemes);
AppendDelimitedSwitchToVector(switches::kSecureSchemes,
&schemes->secure_schemes);
AppendDelimitedSwitchToVector(switches::kBypassCSPSchemes,
&schemes->csp_bypassing_schemes);
AppendDelimitedSwitchToVector(switches::kCORSSchemes,
&schemes->cors_enabled_schemes);
std::vector<std::string> splited;
ConvertStringWithSeparatorToVector(&splited, ",",
switches::kRegisterServiceWorkerSchemes);
for (const std::string& scheme : splited)
schemes->service_worker_schemes.push_back(scheme);
schemes->service_worker_schemes.push_back(url::kFileScheme);
ConvertStringWithSeparatorToVector(&splited, ",", switches::kSecureSchemes);
for (const std::string& scheme : splited)
schemes->secure_schemes.push_back(scheme);
schemes->standard_schemes.push_back("chrome-extension");
}
void AtomContentClient::AddPepperPlugins(

View File

@@ -20,8 +20,6 @@ class AtomContentClient : public content::ContentClient {
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;

View File

@@ -43,9 +43,9 @@
#include "base/i18n/icu_util.h"
#include "electron/buildflags/buildflags.h"
#if defined(HELPER_EXECUTABLE)
#if defined(HELPER_EXECUTABLE) && !defined(MAS_BUILD)
#include "sandbox/mac/seatbelt_exec.h" // nogncheck
#endif // defined(HELPER_EXECUTABLE)
#endif
namespace {
@@ -213,7 +213,7 @@ int main(int argc, char* argv[]) {
}
#endif
#if defined(HELPER_EXECUTABLE)
#if defined(HELPER_EXECUTABLE) && !defined(MAS_BUILD)
uint32_t exec_path_size = 0;
int rv = _NSGetExecutablePath(NULL, &exec_path_size);
if (rv != -1) {
@@ -240,7 +240,7 @@ int main(int argc, char* argv[]) {
abort();
}
}
#endif
#endif // defined(HELPER_EXECUTABLE) && !defined(MAS_BUILD)
return AtomMain(argc, argv);
}

View File

@@ -58,6 +58,11 @@ bool IsBrowserProcess(base::CommandLine* cmd) {
return process_type.empty();
}
bool IsSandboxEnabled(base::CommandLine* command_line) {
return command_line->HasSwitch(switches::kEnableSandbox) ||
!command_line->HasSwitch(service_manager::switches::kNoSandbox);
}
// Returns true if this subprocess type needs the ResourceBundle initialized
// and resources loaded.
bool SubprocessNeedsResourceBundle(const std::string& process_type) {
@@ -164,6 +169,9 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
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)
@@ -180,6 +188,14 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
base::win::DisableHandleVerifier();
#endif
#if defined(OS_LINUX)
// Check for --no-sandbox parameter when running as root.
if (getuid() == 0 && IsSandboxEnabled(command_line))
LOG(FATAL) << "Running as root without --"
<< service_manager::switches::kNoSandbox
<< " is not supported. See https://crbug.com/638180.";
#endif
content_client_ = std::make_unique<AtomContentClient>();
SetContentClient(content_client_.get());
@@ -234,10 +250,6 @@ void AtomMainDelegate::PreSandboxStartup() {
if (!IsBrowserProcess(command_line))
return;
// Disable setuid sandbox since it is not longer required on
// linux (namespace sandbox is available on most distros).
command_line->AppendSwitch(service_manager::switches::kDisableSetuidSandbox);
// Allow file:// URIs to read other file:// URIs by default.
command_line->AppendSwitch(::switches::kAllowFileAccessFromFiles);
@@ -260,10 +272,9 @@ content::ContentBrowserClient* AtomMainDelegate::CreateContentBrowserClient() {
content::ContentRendererClient*
AtomMainDelegate::CreateContentRendererClient() {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableSandbox) ||
!base::CommandLine::ForCurrentProcess()->HasSwitch(
service_manager::switches::kNoSandbox)) {
auto* command_line = base::CommandLine::ForCurrentProcess();
if (IsSandboxEnabled(command_line)) {
renderer_client_.reset(new AtomSandboxedRendererClient);
} else {
renderer_client_.reset(new AtomRendererClient);

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

@@ -0,0 +1,44 @@
// Copyright (c) 2019 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/app/manifests.h"
#include "base/no_destructor.h"
#include "printing/buildflags/buildflags.h"
#include "services/proxy_resolver/proxy_resolver_manifest.h"
#include "services/service_manager/public/cpp/manifest_builder.h"
#if BUILDFLAG(ENABLE_PRINTING)
#include "components/services/pdf_compositor/pdf_compositor_manifest.h"
#endif
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/services/printing/manifest.h"
#endif
const service_manager::Manifest& GetElectronContentBrowserOverlayManifest() {
static base::NoDestructor<service_manager::Manifest> manifest{
service_manager::ManifestBuilder()
.WithDisplayName("Electron (browser process)")
.RequireCapability("device", "device:geolocation_control")
.RequireCapability("proxy_resolver", "factory")
.RequireCapability("chrome_printing", "converter")
.RequireCapability("pdf_compositor", "compositor")
.Build()};
return *manifest;
}
const std::vector<service_manager::Manifest>&
GetElectronPackagedServicesOverlayManifest() {
static base::NoDestructor<std::vector<service_manager::Manifest>> manifests{{
proxy_resolver::GetManifest(),
#if BUILDFLAG(ENABLE_PRINTING)
pdf_compositor::GetManifest(),
#endif
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
chrome_printing::GetManifest(),
#endif
}};
return *manifests;
}

16
atom/app/manifests.h Normal file
View File

@@ -0,0 +1,16 @@
// Copyright (c) 2019 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_APP_MANIFESTS_H_
#define ATOM_APP_MANIFESTS_H_
#include <vector>
#include "services/service_manager/public/cpp/manifest.h"
const service_manager::Manifest& GetElectronContentBrowserOverlayManifest();
const std::vector<service_manager::Manifest>&
GetElectronPackagedServicesOverlayManifest();
#endif // ATOM_APP_MANIFESTS_H_

View File

@@ -96,6 +96,7 @@ int NodeMain(int argc, char* argv[]) {
}
} while (more == true);
node_debugger.Stop();
exit_code = node::EmitExit(env);
node::RunAtExit(env);
gin_env.platform()->DrainTasks(env->isolate());

View File

@@ -533,12 +533,11 @@ int ImportIntoCertStore(CertificateManagerModel* model,
}
#endif
void OnIconDataAvailable(scoped_refptr<util::Promise> promise,
gfx::Image* icon) {
void OnIconDataAvailable(util::Promise promise, gfx::Image* icon) {
if (icon && !icon->IsEmpty()) {
promise->Resolve(*icon);
promise.Resolve(*icon);
} else {
promise->RejectWithErrorMessage("Failed to get file icon.");
promise.RejectWithErrorMessage("Failed to get file icon.");
}
}
@@ -690,7 +689,7 @@ bool App::CanCreateWindow(
content::RenderFrameHost* opener,
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,
@@ -1126,7 +1125,8 @@ JumpListResult App::SetJumpList(v8::Local<v8::Value> val,
v8::Local<v8::Promise> App::GetFileIcon(const base::FilePath& path,
mate::Arguments* args) {
scoped_refptr<util::Promise> promise = new util::Promise(isolate());
util::Promise promise(isolate());
v8::Local<v8::Promise> handle = promise.GetHandle();
base::FilePath normalized_path = path.NormalizePathSeparators();
IconLoader::IconSize icon_size;
@@ -1143,13 +1143,14 @@ v8::Local<v8::Promise> App::GetFileIcon(const base::FilePath& path,
gfx::Image* icon =
icon_manager->LookupIconFromFilepath(normalized_path, icon_size);
if (icon) {
promise->Resolve(*icon);
promise.Resolve(*icon);
} else {
icon_manager->LoadIcon(normalized_path, icon_size,
base::Bind(&OnIconDataAvailable, promise),
&cancelable_task_tracker_);
icon_manager->LoadIcon(
normalized_path, icon_size,
base::BindOnce(&OnIconDataAvailable, std::move(promise)),
&cancelable_task_tracker_);
}
return promise->GetHandle();
return handle;
}
std::vector<mate::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
@@ -1197,30 +1198,30 @@ v8::Local<v8::Value> App::GetGPUFeatureStatus(v8::Isolate* isolate) {
v8::Local<v8::Promise> App::GetGPUInfo(v8::Isolate* isolate,
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) || defined(OS_MACOSX)
info_mgr->FetchCompleteInfo(promise);
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) {
@@ -1412,4 +1413,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_app, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_app, Initialize)

View File

@@ -141,7 +141,7 @@ class App : public AtomBrowserClient::Delegate,
bool CanCreateWindow(content::RenderFrameHost* opener,
const GURL& opener_url,
const GURL& opener_top_level_frame_url,
const GURL& source_origin,
const url::Origin& source_origin,
content::mojom::WindowContainerType container_type,
const GURL& target_url,
const content::Referrer& referrer,

View File

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

View File

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

View File

@@ -18,6 +18,7 @@
#include "atom/common/options_switches.h"
#include "base/threading/thread_task_runner_handle.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_owner_delegate.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "gin/converter.h"
@@ -67,7 +68,7 @@ BrowserWindow::BrowserWindow(v8::Isolate* isolate,
}
web_contents_.Reset(isolate, web_contents.ToV8());
api_web_contents_ = web_contents.get();
api_web_contents_ = web_contents->GetWeakPtr();
api_web_contents_->AddObserver(this);
Observe(api_web_contents_->web_contents());
@@ -85,8 +86,7 @@ BrowserWindow::BrowserWindow(v8::Isolate* isolate,
InitWith(isolate, wrapper);
#if defined(OS_MACOSX)
if (!window()->has_frame())
OverrideNSWindowContentView(web_contents->managed_web_contents());
OverrideNSWindowContentView(web_contents->managed_web_contents());
#endif
// Init window after everything has been setup.
@@ -94,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())
@@ -130,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() {
@@ -349,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);
@@ -479,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

@@ -116,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,8 +8,10 @@
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/promise_util.h"
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/threading/thread_restrictions.h"
#include "content/public/browser/tracing_controller.h"
#include "native_mate/dictionary.h"
@@ -58,6 +60,11 @@ scoped_refptr<TracingController::TraceDataEndpoint> GetTraceDataEndpoint(
const base::FilePath& path,
const CompletionCallback& callback) {
base::FilePath result_file_path = path;
// base::CreateTemporaryFile prevents blocking so we need to allow it
// for now since offloading this to a different sequence would require
// changing the api shape
base::ThreadRestrictions::ScopedAllowIO allow_io;
if (result_file_path.empty() && !base::CreateTemporaryFile(&result_file_path))
LOG(ERROR) << "Creating temporary file failed";
@@ -65,23 +72,53 @@ scoped_refptr<TracingController::TraceDataEndpoint> GetTraceDataEndpoint(
result_file_path, base::Bind(callback, result_file_path));
}
void StopRecording(const base::FilePath& path,
const CompletionCallback& callback) {
TracingController::GetInstance()->StopTracing(
GetTraceDataEndpoint(path, callback));
void OnRecordingStopped(const atom::util::CopyablePromise& promise,
const base::FilePath& path) {
promise.GetPromise().Resolve(path);
}
bool GetCategories(
const base::RepeatingCallback<void(const std::set<std::string>&)>&
callback) {
return TracingController::GetInstance()->GetCategories(
base::BindOnce(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(&OnRecordingStopped, atom::util::CopyablePromise(promise))));
return handle;
}
bool StartTracing(const base::trace_event::TraceConfig& trace_config,
const base::RepeatingCallback<void()>& callback) {
return TracingController::GetInstance()->StartTracing(
trace_config, base::BindOnce(callback));
void OnCategoriesAvailable(atom::util::Promise promise,
const std::set<std::string>& categories) {
promise.Resolve(categories);
}
v8::Local<v8::Promise> GetCategories(v8::Isolate* isolate) {
atom::util::Promise promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
// Note: This method always succeeds.
TracingController::GetInstance()->GetCategories(
base::BindOnce(&OnCategoriesAvailable, std::move(promise)));
return handle;
}
void OnTracingStarted(atom::util::Promise promise) {
promise.Resolve();
}
v8::Local<v8::Promise> StartTracing(
v8::Isolate* isolate,
const base::trace_event::TraceConfig& trace_config) {
atom::util::Promise promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
// Note: This method always succeeds.
TracingController::GetInstance()->StartTracing(
trace_config, base::BindOnce(&OnTracingStarted, std::move(promise)));
return handle;
}
bool GetTraceBufferUsage(
@@ -103,4 +140,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_content_tracing, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_content_tracing, Initialize)

View File

@@ -136,74 +136,103 @@ inline net::CookieStore* GetCookieStore(
return getter->GetURLRequestContext()->cookie_store();
}
void ResolvePromiseWithCookies(util::Promise promise,
const net::CookieList& cookie_list) {
promise.Resolve(cookie_list);
}
void ResolvePromise(util::Promise promise) {
promise.Resolve();
}
// Resolve |promise| in UI thread.
void ResolvePromiseInUI(util::Promise promise) {
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(ResolvePromise, std::move(promise)));
}
// Run |callback| on UI thread.
void RunCallbackInUI(const base::Closure& callback) {
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, callback);
void RunCallbackInUI(base::OnceClosure callback) {
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, std::move(callback));
}
// Remove cookies from |list| not matching |filter|, and pass it to |callback|.
void FilterCookies(std::unique_ptr<base::DictionaryValue> filter,
const Cookies::GetCallback& callback,
util::Promise promise,
const net::CookieList& list) {
net::CookieList result;
for (const auto& cookie : list) {
if (MatchesCookie(filter.get(), cookie))
result.push_back(cookie);
}
RunCallbackInUI(base::Bind(callback, Cookies::SUCCESS, result));
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(ResolvePromiseWithCookies, std::move(promise), result));
}
// Receives cookies matching |filter| in IO thread.
void GetCookiesOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
std::unique_ptr<base::DictionaryValue> filter,
const Cookies::GetCallback& callback) {
util::Promise promise) {
std::string url;
filter->GetString("url", &url);
auto filtered_callback =
base::Bind(FilterCookies, base::Passed(&filter), callback);
base::BindOnce(FilterCookies, std::move(filter), std::move(promise));
// Empty url will match all url cookies.
if (url.empty())
GetCookieStore(getter)->GetAllCookiesAsync(filtered_callback);
GetCookieStore(getter)->GetAllCookiesAsync(std::move(filtered_callback));
else
GetCookieStore(getter)->GetAllCookiesForURLAsync(GURL(url),
filtered_callback);
GetCookieStore(getter)->GetAllCookiesForURLAsync(
GURL(url), std::move(filtered_callback));
}
// Removes cookie with |url| and |name| in IO thread.
void RemoveCookieOnIOThread(scoped_refptr<net::URLRequestContextGetter> getter,
const GURL& url,
const std::string& name,
const base::Closure& callback) {
void RemoveCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
const GURL& url,
const std::string& name,
util::Promise promise) {
GetCookieStore(getter)->DeleteCookieAsync(
url, name, base::BindOnce(RunCallbackInUI, callback));
url, name, base::BindOnce(ResolvePromiseInUI, std::move(promise)));
}
// Resolves/rejects the |promise| in UI thread.
void SettlePromiseInUI(util::Promise promise, const std::string& errmsg) {
if (errmsg.empty()) {
promise.Resolve();
} else {
promise.RejectWithErrorMessage(errmsg);
}
}
// Callback of SetCookie.
void OnSetCookie(const Cookies::SetCallback& callback, bool success) {
void OnSetCookie(util::Promise promise, bool success) {
const std::string errmsg = success ? "" : "Setting cookie failed";
RunCallbackInUI(
base::Bind(callback, success ? Cookies::SUCCESS : Cookies::FAILED));
base::BindOnce(SettlePromiseInUI, std::move(promise), errmsg));
}
// Flushes cookie store in IO thread.
void FlushCookieStoreOnIOThread(
scoped_refptr<net::URLRequestContextGetter> getter,
const base::Closure& callback) {
GetCookieStore(getter)->FlushStore(base::BindOnce(RunCallbackInUI, callback));
util::Promise promise) {
GetCookieStore(getter)->FlushStore(
base::BindOnce(ResolvePromiseInUI, std::move(promise)));
}
// Sets cookie with |details| in IO thread.
void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
std::unique_ptr<base::DictionaryValue> details,
const Cookies::SetCallback& callback) {
std::string url, name, value, domain, path;
util::Promise promise) {
std::string url_string, name, value, domain, path;
bool secure = false;
bool http_only = false;
double creation_date;
double expiration_date;
double last_access_date;
details->GetString("url", &url);
details->GetString("url", &url_string);
details->GetString("name", &name);
details->GetString("value", &value);
details->GetString("domain", &domain);
@@ -232,24 +261,27 @@ void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
: base::Time::FromDoubleT(last_access_date);
}
auto completion_callback = base::BindOnce(OnSetCookie, std::move(promise));
GURL url(url_string);
if (!url.is_valid()) {
std::move(completion_callback).Run(false);
return;
}
if (name.empty()) {
std::move(completion_callback).Run(false);
return;
}
std::unique_ptr<net::CanonicalCookie> canonical_cookie(
net::CanonicalCookie::CreateSanitizedCookie(
GURL(url), name, value, domain, path, creation_time, expiration_time,
url, name, value, domain, path, creation_time, expiration_time,
last_access_time, secure, http_only,
net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT));
auto completion_callback = base::BindOnce(OnSetCookie, callback);
if (!canonical_cookie || !canonical_cookie->IsCanonical()) {
std::move(completion_callback).Run(false);
return;
}
if (url.empty()) {
std::move(completion_callback).Run(false);
return;
}
if (name.empty()) {
std::move(completion_callback).Run(false);
return;
}
GetCookieStore(getter)->SetCanonicalCookieAsync(
std::move(canonical_cookie), secure, http_only,
std::move(completion_callback));
@@ -267,43 +299,61 @@ Cookies::Cookies(v8::Isolate* isolate, AtomBrowserContext* browser_context)
Cookies::~Cookies() {}
void Cookies::Get(const base::DictionaryValue& filter,
const GetCallback& callback) {
v8::Local<v8::Promise> Cookies::Get(const base::DictionaryValue& filter) {
util::Promise promise(isolate());
v8::Local<v8::Promise> handle = promise.GetHandle();
auto copy = base::DictionaryValue::From(
base::Value::ToUniquePtrValue(filter.Clone()));
auto* getter = browser_context_->GetRequestContext();
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();
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(RemoveCookieOnIOThread, base::RetainedRef(getter), url,
name, callback));
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();
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();
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::IO},
base::BindOnce(FlushCookieStoreOnIOThread,
base::RetainedRef(getter), callback));
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(FlushCookieStoreOnIOThread, base::RetainedRef(getter),
std::move(promise)));
return handle;
}
void Cookies::OnCookieChanged(const CookieDetails* details) {

View File

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

View File

@@ -61,23 +61,26 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
params.Swap(params_value);
Emit("message", method, params);
} else {
auto send_command_callback = pending_requests_[id];
pending_requests_.erase(id);
if (send_command_callback.is_null())
auto it = pending_requests_.find(id);
if (it == pending_requests_.end())
return;
base::DictionaryValue* error_body = nullptr;
base::DictionaryValue error;
bool has_error;
if ((has_error = dict->GetDictionary("error", &error_body))) {
error.Swap(error_body);
}
base::DictionaryValue* result_body = nullptr;
base::DictionaryValue result;
if (dict->GetDictionary("result", &result_body))
result.Swap(result_body);
send_command_callback.Run(has_error ? error.Clone() : base::Value(),
result);
atom::util::Promise promise = std::move(it->second);
pending_requests_.erase(it);
base::DictionaryValue* error = nullptr;
if (dict->GetDictionary("error", &error)) {
std::string message;
error->GetString("message", &message);
promise.RejectWithErrorMessage(message);
} else {
base::DictionaryValue* result_body = nullptr;
base::DictionaryValue result;
if (dict->GetDictionary("result", &result_body)) {
result.Swap(result_body);
}
promise.Resolve(result);
}
}
}
@@ -125,23 +128,27 @@ void Debugger::Detach() {
AgentHostClosed(agent_host_.get());
}
void Debugger::SendCommand(mate::Arguments* args) {
if (!agent_host_)
return;
v8::Local<v8::Promise> Debugger::SendCommand(mate::Arguments* args) {
atom::util::Promise promise(isolate());
v8::Local<v8::Promise> handle = promise.GetHandle();
if (!agent_host_) {
promise.RejectWithErrorMessage("No target available");
return handle;
}
std::string method;
if (!args->GetNext(&method)) {
args->ThrowError();
return;
promise.RejectWithErrorMessage("Invalid method");
return handle;
}
base::DictionaryValue command_params;
args->GetNext(&command_params);
SendCommandCallback callback;
args->GetNext(&callback);
base::DictionaryValue request;
int request_id = ++previous_request_id_;
pending_requests_[request_id] = callback;
pending_requests_.emplace(request_id, std::move(promise));
request.SetInteger("id", request_id);
request.SetString("method", method);
if (!command_params.empty())
@@ -151,16 +158,13 @@ void Debugger::SendCommand(mate::Arguments* args) {
std::string json_args;
base::JSONWriter::Write(request, &json_args);
agent_host_->DispatchProtocolMessage(this, json_args);
return handle;
}
void Debugger::ClearPendingRequests() {
if (pending_requests_.empty())
return;
base::Value error(base::Value::Type::DICTIONARY);
base::Value error_msg("target closed while handling command");
error.SetKey("message", std::move(error_msg));
for (const auto& it : pending_requests_)
it.second.Run(error, base::Value());
for (auto& it : pending_requests_)
it.second.RejectWithErrorMessage("target closed while handling command");
}
// static
@@ -201,4 +205,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // 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

@@ -88,10 +88,6 @@ void DesktopCapturer::StartHandling(bool capture_window,
capture_screen_ = capture_screen;
{
// Remove this once
// https://bugs.chromium.org/p/chromium/issues/detail?id=795340 is fixed.
base::ScopedAllowBaseSyncPrimitivesForTesting
scoped_allow_base_sync_primitives;
// Initialize the source list.
// Apply the new thumbnail size and restart capture.
if (capture_window) {
@@ -230,4 +226,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_desktop_capturer, Initialize);
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_desktop_capturer, Initialize);

View File

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

View File

@@ -103,7 +103,7 @@ bool DownloadItem::IsPaused() const {
}
void DownloadItem::Resume() {
download_item_->Resume();
download_item_->Resume(true /* user_gesture */);
}
bool DownloadItem::CanResume() const {
@@ -251,4 +251,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_download_item, Initialize);
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_download_item, Initialize);

View File

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

View File

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

View File

@@ -62,7 +62,7 @@ struct Converter<in_app_purchase::Product> {
dict.Set("formattedPrice", val.formattedPrice);
// Downloadable Content Information
dict.Set("isDownloadable", val.downloadable);
dict.Set("isDownloadable", val.isDownloadable);
return dict.GetHandle();
}
@@ -140,4 +140,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // 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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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,12 +145,6 @@ 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;
@@ -111,21 +177,22 @@ bool IsProtocolHandledInIO(
return is_handled;
}
void PromiseCallback(scoped_refptr<util::Promise> promise, bool handled) {
promise->Resolve(handled);
void PromiseCallback(util::Promise promise, bool handled) {
promise.Resolve(handled);
}
v8::Local<v8::Promise> Protocol::IsProtocolHandled(const std::string& scheme) {
scoped_refptr<util::Promise> promise = new util::Promise(isolate());
util::Promise promise(isolate());
v8::Local<v8::Promise> handle = promise.GetHandle();
auto* getter = static_cast<URLRequestContextGetter*>(
browser_context_->GetRequestContext());
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, {content::BrowserThread::IO},
base::Bind(&IsProtocolHandledInIO, base::RetainedRef(getter), scheme),
base::Bind(&PromiseCallback, promise));
base::BindOnce(&IsProtocolHandledInIO, base::RetainedRef(getter), scheme),
base::BindOnce(&PromiseCallback, std::move(promise)));
return promise->GetHandle();
return handle;
}
void Protocol::UninterceptProtocol(const std::string& scheme,
@@ -195,8 +262,6 @@ void Protocol::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "Protocol"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.SetMethod("registerServiceWorkerSchemes",
&Protocol::RegisterServiceWorkerSchemes)
.SetMethod("registerStringProtocol",
&Protocol::RegisterProtocol<URLRequestStringJob>)
.SetMethod("registerBufferProtocol",
@@ -228,16 +293,16 @@ void Protocol::BuildPrototype(v8::Isolate* isolate,
namespace {
void RegisterStandardSchemes(const std::vector<std::string>& schemes,
mate::Arguments* args) {
void RegisterSchemesAsPrivileged(v8::Local<v8::Value> val,
mate::Arguments* args) {
if (atom::Browser::Get()->is_ready()) {
args->ThrowError(
"protocol.registerStandardSchemes should be called before "
"protocol.registerSchemesAsPrivileged should be called before "
"app is ready");
return;
}
atom::api::RegisterStandardSchemes(schemes, args);
atom::api::RegisterSchemesAsPrivileged(val, args);
}
void Initialize(v8::Local<v8::Object> exports,
@@ -246,10 +311,10 @@ void Initialize(v8::Local<v8::Object> exports,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.SetMethod("registerStandardSchemes", &RegisterStandardSchemes);
dict.SetMethod("registerSchemesAsPrivileged", &RegisterSchemesAsPrivileged);
dict.SetMethod("getStandardSchemes", &atom::api::GetStandardSchemes);
}
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_protocol, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_protocol, Initialize)

View File

@@ -34,8 +34,9 @@ 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:
@@ -94,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,

View File

@@ -87,5 +87,5 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_render_process_preferences,
Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_render_process_preferences,
Initialize)

View File

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

View File

@@ -61,7 +61,6 @@
#include "atom/common/node_includes.h"
using atom::api::Cookies;
using content::BrowserThread;
using content::StoragePartition;
@@ -421,6 +420,17 @@ void Session::ResolveProxy(
browser_context_->GetResolveProxyHelper()->ResolveProxy(url, callback);
}
void Session::GetCacheSize(const net::CompletionCallback& callback) {
content::BrowserContext::GetDefaultStoragePartition(browser_context_.get())
->GetNetworkContext()
->ComputeHttpCacheSize(
base::Time(), base::Time::Max(),
base::BindOnce(
[](const net::CompletionCallback& cb, bool is_upper_bound,
int64_t size_or_error) { cb.Run(size_or_error); },
callback));
}
template <Session::CacheAction action>
void Session::DoCacheAction(const net::CompletionCallback& callback) {
base::PostTaskWithTraits(
@@ -749,7 +759,7 @@ void Session::BuildPrototype(v8::Isolate* isolate,
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.MakeDestroyable()
.SetMethod("resolveProxy", &Session::ResolveProxy)
.SetMethod("getCacheSize", &Session::DoCacheAction<CacheAction::STATS>)
.SetMethod("getCacheSize", &Session::GetCacheSize)
.SetMethod("clearCache", &Session::DoCacheAction<CacheAction::CLEAR>)
.SetMethod("clearStorageData", &Session::ClearStorageData)
.SetMethod("flushStorageData", &Session::FlushStorageData)
@@ -785,6 +795,8 @@ void Session::BuildPrototype(v8::Isolate* isolate,
namespace {
using atom::api::Cookies;
using atom::api::Protocol;
using atom::api::Session;
v8::Local<v8::Value> FromPartition(const std::string& partition,
@@ -810,9 +822,12 @@ void Initialize(v8::Local<v8::Object> exports,
dict.Set(
"Cookies",
Cookies::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
dict.Set(
"Protocol",
Protocol::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
dict.SetMethod("fromPartition", &FromPartition);
}
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_session, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_session, Initialize)

View File

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

View File

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

View File

@@ -11,6 +11,7 @@
#include "atom/browser/mac/atom_application.h"
#include "atom/browser/mac/dict_util.h"
#include "atom/browser/ui/cocoa/NSColor+Hex.h"
#include "atom/common/native_mate_converters/gurl_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "base/mac/sdk_forward_declarations.h"
@@ -19,6 +20,7 @@
#include "base/values.h"
#include "native_mate/object_template_builder.h"
#include "net/base/mac/url_conversions.h"
#include "ui/native_theme/native_theme.h"
namespace mate {
template <>
@@ -56,11 +58,11 @@ struct Converter<NSAppearance*> {
return v8::Null(isolate);
}
if (val.name == NSAppearanceNameAqua) {
if ([val.name isEqualToString:NSAppearanceNameAqua]) {
return mate::ConvertToV8(isolate, "light");
}
if (@available(macOS 10.14, *)) {
if (val.name == NSAppearanceNameDarkAqua) {
if ([val.name isEqualToString:NSAppearanceNameDarkAqua]) {
return mate::ConvertToV8(isolate, "dark");
}
}
@@ -106,21 +108,6 @@ std::string ConvertAuthorizationStatus(AVAuthorizationStatusMac status) {
}
}
// Convert color to RGBA value like "aabbccdd"
std::string ToRGBA(NSColor* color) {
return base::StringPrintf(
"%02X%02X%02X%02X", (int)(color.redComponent * 0xFF),
(int)(color.greenComponent * 0xFF), (int)(color.blueComponent * 0xFF),
(int)(color.alphaComponent * 0xFF));
}
// Convert color to RGB hex value like "#ABCDEF"
std::string ToRGBHex(NSColor* color) {
return base::StringPrintf("#%02X%02X%02X", (int)(color.redComponent * 0xFF),
(int)(color.greenComponent * 0xFF),
(int)(color.blueComponent * 0xFF));
}
} // namespace
void SystemPreferences::PostNotification(const std::string& name,
@@ -400,42 +387,36 @@ std::string SystemPreferences::GetAccentColor() {
if (@available(macOS 10.14, *))
sysColor = [NSColor controlAccentColor];
return ToRGBA(sysColor);
return base::SysNSStringToUTF8([sysColor RGBAValue]);
}
std::string SystemPreferences::GetSystemColor(const std::string& color,
mate::Arguments* args) {
if (@available(macOS 10.10, *)) {
NSColor* sysColor;
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 ToRGBHex(sysColor);
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(
"This api is not available on MacOS version 10.9 or lower.");
args->ThrowError("Unknown system color: " + color);
return "";
}
return base::SysNSStringToUTF8([sysColor hexadecimalValue]);
}
// static
@@ -469,23 +450,18 @@ std::string SystemPreferences::GetColor(const std::string& color,
} else if (color == "keyboard-focus-indicator") {
sysColor = [NSColor keyboardFocusIndicatorColor];
} else if (color == "label") {
if (@available(macOS 10.10, *))
sysColor = [NSColor labelColor];
sysColor = [NSColor labelColor];
} else if (color == "link") {
if (@available(macOS 10.10, *))
sysColor = [NSColor linkColor];
sysColor = [NSColor linkColor];
} else if (color == "placeholder-text") {
if (@available(macOS 10.10, *))
sysColor = [NSColor placeholderTextColor];
sysColor = [NSColor placeholderTextColor];
} else if (color == "quaternary-label") {
if (@available(macOS 10.10, *))
sysColor = [NSColor quaternaryLabelColor];
sysColor = [NSColor quaternaryLabelColor];
} else if (color == "scrubber-textured-background") {
if (@available(macOS 10.12.2, *))
sysColor = [NSColor scrubberTexturedBackgroundColor];
} else if (color == "secondary-label") {
if (@available(macOS 10.10, *))
sysColor = [NSColor secondaryLabelColor];
sysColor = [NSColor secondaryLabelColor];
} else if (color == "selected-content-background") {
if (@available(macOS 10.14, *))
sysColor = [NSColor selectedContentBackgroundColor];
@@ -505,8 +481,7 @@ std::string SystemPreferences::GetColor(const std::string& color,
} else if (color == "shadow") {
sysColor = [NSColor shadowColor];
} else if (color == "tertiary-label") {
if (@available(macOS 10.10, *))
sysColor = [NSColor tertiaryLabelColor];
sysColor = [NSColor tertiaryLabelColor];
} else if (color == "text-background") {
sysColor = [NSColor textBackgroundColor];
} else if (color == "text") {
@@ -531,7 +506,7 @@ std::string SystemPreferences::GetColor(const std::string& color,
return "";
}
return ToRGBHex(sysColor);
return base::SysNSStringToUTF8([sysColor hexadecimalValue]);
}
std::string SystemPreferences::GetMediaAccessStatus(
@@ -554,25 +529,27 @@ std::string SystemPreferences::GetMediaAccessStatus(
v8::Local<v8::Promise> SystemPreferences::AskForMediaAccess(
v8::Isolate* isolate,
const std::string& media_type) {
scoped_refptr<util::Promise> promise = new util::Promise(isolate);
util::Promise promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
if (auto type = ParseMediaType(media_type)) {
if (@available(macOS 10.14, *)) {
__block util::Promise p = std::move(promise);
[AVCaptureDevice requestAccessForMediaType:type
completionHandler:^(BOOL granted) {
dispatch_async(dispatch_get_main_queue(), ^{
promise->Resolve(!!granted);
p.Resolve(!!granted);
});
}];
} else {
// access always allowed pre-10.14 Mojave
promise->Resolve(true);
promise.Resolve(true);
}
} else {
promise->RejectWithErrorMessage("Invalid media type");
promise.RejectWithErrorMessage("Invalid media type");
}
return promise->GetHandle();
return handle;
}
void SystemPreferences::RemoveUserDefault(const std::string& name) {
@@ -581,6 +558,9 @@ void SystemPreferences::RemoveUserDefault(const std::string& name) {
}
bool SystemPreferences::IsDarkMode() {
if (@available(macOS 10.15, *)) {
return ui::NativeTheme::GetInstanceForNativeUi()->SystemDarkModeEnabled();
}
NSString* mode = [[NSUserDefaults standardUserDefaults]
stringForKey:@"AppleInterfaceStyle"];
return [mode isEqualToString:@"Dark"];

View File

@@ -659,6 +659,11 @@ void TopLevelWindow::SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> value) {
}
}
void TopLevelWindow::RemoveMenu() {
menu_.Reset();
window_->SetMenu(nullptr);
}
void TopLevelWindow::SetParentWindow(v8::Local<v8::Value> value,
mate::Arguments* args) {
if (IsModal()) {
@@ -1103,6 +1108,7 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate,
.SetMethod("setContentProtection", &TopLevelWindow::SetContentProtection)
.SetMethod("setFocusable", &TopLevelWindow::SetFocusable)
.SetMethod("setMenu", &TopLevelWindow::SetMenu)
.SetMethod("removeMenu", &TopLevelWindow::RemoveMenu)
.SetMethod("setParentWindow", &TopLevelWindow::SetParentWindow)
.SetMethod("setBrowserView", &TopLevelWindow::SetBrowserView)
.SetMethod("addBrowserView", &TopLevelWindow::AddBrowserView)
@@ -1193,4 +1199,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_top_level_window, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_top_level_window, Initialize)

View File

@@ -165,6 +165,7 @@ 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);

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,
@@ -192,7 +188,7 @@ void Tray::DisplayBalloon(mate::Arguments* args,
#if defined(OS_WIN)
tray_icon_->DisplayBalloon(
icon.IsEmpty() ? NULL : icon->GetHICON(GetSystemMetrics(SM_CXSMICON)),
icon.IsEmpty() ? NULL : icon->GetHICON(GetSystemMetrics(SM_CXICON)),
title, content);
#else
tray_icon_->DisplayBalloon(icon.IsEmpty() ? gfx::Image() : icon->image(),
@@ -261,4 +257,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_tray, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_tray, Initialize)

View File

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

View File

@@ -87,13 +87,18 @@
#include "ui/events/base_event_utils.h"
#if BUILDFLAG(ENABLE_OSR)
#include "atom/browser/osr/osr_output_device.h"
#include "atom/browser/osr/osr_render_widget_host_view.h"
#include "atom/browser/osr/osr_web_contents_view.h"
#endif
#if !defined(OS_MACOSX)
#include "ui/aura/window.h"
#else
#include "ui/base/cocoa/defaults_utils.h"
#endif
#if defined(OS_LINUX)
#include "ui/views/linux_ui/linux_ui.h"
#endif
#if defined(OS_LINUX) || defined(OS_WIN)
@@ -256,12 +261,11 @@ content::ServiceWorkerContext* GetServiceWorkerContext(
}
// Called when CapturePage is done.
void OnCapturePageDone(scoped_refptr<util::Promise> promise,
const SkBitmap& bitmap) {
void OnCapturePageDone(util::Promise promise, const SkBitmap& bitmap) {
// Hack to enable transparency in captured image
// TODO(nitsakh) Remove hack once fixed in chromium
const_cast<SkBitmap&>(bitmap).setAlphaType(kPremul_SkAlphaType);
promise->Resolve(gfx::Image::CreateFrom1xBitmap(bitmap));
promise.Resolve(gfx::Image::CreateFrom1xBitmap(bitmap));
}
} // namespace
@@ -289,7 +293,9 @@ struct WebContents::FrameDispatchHelper {
WebContents::WebContents(v8::Isolate* isolate,
content::WebContents* web_contents)
: content::WebContentsObserver(web_contents), type_(REMOTE) {
: content::WebContentsObserver(web_contents),
type_(REMOTE),
weak_factory_(this) {
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent(),
false);
Init(isolate);
@@ -300,7 +306,9 @@ WebContents::WebContents(v8::Isolate* isolate,
WebContents::WebContents(v8::Isolate* isolate,
std::unique_ptr<content::WebContents> web_contents,
Type type)
: content::WebContentsObserver(web_contents.get()), type_(type) {
: content::WebContentsObserver(web_contents.get()),
type_(type),
weak_factory_(this) {
DCHECK(type != REMOTE) << "Can't take ownership of a remote WebContents";
auto session = Session::CreateFrom(isolate, GetBrowserContext());
session_.Reset(isolate, session.ToV8());
@@ -308,8 +316,8 @@ WebContents::WebContents(v8::Isolate* isolate,
mate::Dictionary::CreateEmpty(isolate));
}
WebContents::WebContents(v8::Isolate* isolate,
const mate::Dictionary& options) {
WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
: weak_factory_(this) {
// Read options.
options.Get("backgroundThrottling", &background_throttling_);
@@ -432,6 +440,25 @@ void WebContents::InitWithSessionAndOptions(
prefs->subpixel_rendering = params->subpixel_rendering;
#endif
// Honor the system's cursor blink rate settings
#if defined(OS_MACOSX)
base::TimeDelta interval;
if (ui::TextInsertionCaretBlinkPeriod(&interval))
prefs->caret_blink_interval = interval;
#elif defined(OS_LINUX)
views::LinuxUI* linux_ui = views::LinuxUI::instance();
if (linux_ui)
prefs->caret_blink_interval = linux_ui->GetCursorBlinkInterval();
#elif defined(OS_WIN)
const auto system_msec = ::GetCaretBlinkTime();
if (system_msec != 0) {
prefs->caret_blink_interval =
(system_msec == INFINITE)
? base::TimeDelta()
: base::TimeDelta::FromMilliseconds(system_msec);
}
#endif
// Save the preferences in C++.
new WebContentsPreferences(web_contents(), options);
@@ -599,7 +626,7 @@ void WebContents::SetContentsBounds(content::WebContents* source,
void WebContents::CloseContents(content::WebContents* source) {
Emit("close");
#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
#if defined(TOOLKIT_VIEWS)
HideAutofillPopup();
#endif
if (managed_web_contents())
@@ -725,7 +752,7 @@ void WebContents::FindReply(content::WebContents* web_contents,
bool WebContents::CheckMediaAccessPermission(
content::RenderFrameHost* render_frame_host,
const GURL& security_origin,
content::MediaStreamType type) {
blink::MediaStreamType type) {
auto* web_contents =
content::WebContents::FromRenderFrameHost(render_frame_host);
auto* permission_helper =
@@ -839,6 +866,10 @@ void WebContents::DidChangeThemeColor(SkColor theme_color) {
}
}
void WebContents::DidAcquireFullscreen(content::RenderFrameHost* rfh) {
set_fullscreen_frame(rfh);
}
void WebContents::DocumentLoadedInFrame(
content::RenderFrameHost* render_frame_host) {
if (!render_frame_host->GetParent())
@@ -1012,8 +1043,7 @@ void WebContents::DevToolsOpened() {
// Inherit owner window in devtools when it doesn't have one.
auto* devtools = managed_web_contents()->GetDevToolsWebContents();
bool has_window =
devtools->GetUserData(NativeWindowRelay::kNativeWindowRelayUserDataKey);
bool has_window = devtools->GetUserData(NativeWindowRelay::UserDataKey());
if (owner_window() && !has_window)
handle->SetOwnerWindow(devtools, owner_window());
@@ -1028,7 +1058,7 @@ void WebContents::DevToolsClosed() {
Emit("devtools-closed");
}
#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
#if defined(TOOLKIT_VIEWS)
void WebContents::ShowAutofillPopup(content::RenderFrameHost* frame_host,
const gfx::RectF& bounds,
const std::vector<base::string16>& values,
@@ -1075,7 +1105,7 @@ bool WebContents::OnMessageReceived(const IPC::Message& message,
FrameDispatchHelper::OnSetTemporaryZoomLevel)
IPC_MESSAGE_FORWARD_DELAY_REPLY(AtomFrameHostMsg_GetZoomLevel, &helper,
FrameDispatchHelper::OnGetZoomLevel)
#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
#if defined(TOOLKIT_VIEWS)
IPC_MESSAGE_HANDLER(AtomAutofillFrameHostMsg_ShowPopup, ShowAutofillPopup)
IPC_MESSAGE_HANDLER(AtomAutofillFrameHostMsg_HidePopup, HideAutofillPopup)
#endif
@@ -1139,7 +1169,7 @@ void WebContents::SetBackgroundThrottling(bool allowed) {
return;
}
const auto* render_process_host = render_view_host->GetProcess();
auto* render_process_host = render_view_host->GetProcess();
if (!render_process_host) {
return;
}
@@ -1216,6 +1246,9 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
params.transition_type = ui::PAGE_TRANSITION_TYPED;
params.should_clear_history_list = true;
params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
// Discord non-committed entries to ensure that we don't re-use a pending
// entry
web_contents()->GetController().DiscardNonCommittedEntries();
web_contents()->GetController().LoadURLWithParams(params);
// Set the background color of RenderWidgetHostView.
@@ -1485,7 +1518,7 @@ bool WebContents::IsCurrentlyAudible() {
#if BUILDFLAG(ENABLE_PRINTING)
void WebContents::Print(mate::Arguments* args) {
bool silent, print_background = false;
bool silent = false, print_background = false;
base::string16 device_name;
mate::Dictionary options = mate::Dictionary::CreateEmpty(args->isolate());
base::DictionaryValue settings;
@@ -1672,13 +1705,24 @@ bool WebContents::SendIPCMessageWithSender(bool internal,
const std::string& channel,
const base::ListValue& args,
int32_t sender_id) {
auto* frame_host = web_contents()->GetMainFrame();
if (frame_host) {
return frame_host->Send(new AtomFrameMsg_Message(frame_host->GetRoutingID(),
internal, send_to_all,
channel, args, sender_id));
std::vector<content::RenderFrameHost*> target_hosts;
if (!send_to_all) {
auto* frame_host = web_contents()->GetMainFrame();
if (frame_host) {
target_hosts.push_back(frame_host);
}
} else {
target_hosts = web_contents()->GetAllFrames();
}
return false;
bool handled = false;
for (auto* frame_host : target_hosts) {
handled = frame_host->Send(
new AtomFrameMsg_Message(frame_host->GetRoutingID(), internal,
false, channel, args, sender_id)) ||
handled;
}
return handled;
}
bool WebContents::SendIPCMessageToFrame(bool internal,
@@ -1737,6 +1781,19 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
mouse_wheel_event);
#endif
} else {
// Chromium expects phase info in wheel events (and applies a
// DCHECK to verify it). See: https://crbug.com/756524.
mouse_wheel_event.phase = blink::WebMouseWheelEvent::kPhaseBegan;
mouse_wheel_event.dispatch_type = blink::WebInputEvent::kBlocking;
rwh->ForwardWheelEvent(mouse_wheel_event);
// Send a synthetic wheel event with phaseEnded to finish scrolling.
mouse_wheel_event.has_synthetic_phase = true;
mouse_wheel_event.delta_x = 0;
mouse_wheel_event.delta_y = 0;
mouse_wheel_event.phase = blink::WebMouseWheelEvent::kPhaseEnded;
mouse_wheel_event.dispatch_type =
blink::WebInputEvent::kEventNonBlocking;
rwh->ForwardWheelEvent(mouse_wheel_event);
}
return;
@@ -1758,7 +1815,7 @@ void WebContents::BeginFrameSubscription(mate::Arguments* args) {
}
frame_subscriber_.reset(
new FrameSubscriber(isolate(), web_contents(), callback, only_dirty));
new FrameSubscriber(web_contents(), callback, only_dirty));
}
void WebContents::EndFrameSubscription() {
@@ -1803,15 +1860,16 @@ void WebContents::StartDrag(const mate::Dictionary& item,
v8::Local<v8::Promise> WebContents::CapturePage(mate::Arguments* args) {
gfx::Rect rect;
scoped_refptr<util::Promise> promise = new util::Promise(isolate());
util::Promise promise(isolate());
v8::Local<v8::Promise> handle = promise.GetHandle();
// get rect arguments if they exist
args->GetNext(&rect);
auto* const view = web_contents()->GetRenderWidgetHostView();
if (!view) {
promise->Resolve(gfx::Image());
return promise->GetHandle();
promise.Resolve(gfx::Image());
return handle;
}
// Capture full page if user doesn't specify a |rect|.
@@ -1830,8 +1888,8 @@ v8::Local<v8::Promise> WebContents::CapturePage(mate::Arguments* args) {
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
view->CopyFromSurface(gfx::Rect(rect.origin(), view_size), bitmap_size,
base::BindOnce(&OnCapturePageDone, promise));
return promise->GetHandle();
base::BindOnce(&OnCapturePageDone, std::move(promise)));
return handle;
}
void WebContents::OnCursorChange(const content::WebCursor& cursor) {
@@ -2297,4 +2355,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_web_contents, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_web_contents, Initialize)

View File

@@ -111,6 +111,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
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
@@ -391,7 +393,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
bool final_update) override;
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
const GURL& security_origin,
content::MediaStreamType type) override;
blink::MediaStreamType type) override;
void RequestMediaAccessPermission(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
@@ -448,6 +450,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
const MediaPlayerId& id,
content::WebContentsObserver::MediaStoppedReason reason) override;
void DidChangeThemeColor(SkColor theme_color) override;
void DidAcquireFullscreen(content::RenderFrameHost* rfh) override;
// InspectableWebContentsDelegate:
void DevToolsReloadPage() override;
@@ -544,6 +547,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
// -1 means no speculative RVH has been committed yet.
int currently_committed_process_id_ = -1;
base::WeakPtrFactory<WebContents> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(WebContents);
};

View File

@@ -31,9 +31,13 @@ class WebContentsViewRelay
atom::api::WebContentsView* view_ = nullptr;
WEB_CONTENTS_USER_DATA_KEY_DECL();
DISALLOW_COPY_AND_ASSIGN(WebContentsViewRelay);
};
WEB_CONTENTS_USER_DATA_KEY_IMPL(WebContentsViewRelay)
} // namespace
namespace atom {
@@ -127,4 +131,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_web_contents_view, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_web_contents_view, Initialize)

View File

@@ -4,6 +4,7 @@
#include "atom/browser/api/atom_api_web_request.h"
#include <set>
#include <string>
#include <utility>
@@ -20,23 +21,6 @@
using content::BrowserThread;
namespace mate {
template <>
struct Converter<URLPattern> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
URLPattern* out) {
std::string pattern;
if (!ConvertFromV8(isolate, val, &pattern))
return false;
*out = URLPattern(URLPattern::SCHEME_ALL);
return out->Parse(pattern) == URLPattern::ParseResult::kSuccess;
}
};
} // namespace mate
namespace atom {
namespace api {
@@ -84,7 +68,25 @@ void WebRequest::SetListener(Method method, Event type, mate::Arguments* args) {
// { urls }.
URLPatterns patterns;
mate::Dictionary dict;
args->GetNext(&dict) && dict.Get("urls", &patterns);
std::set<std::string> filter_patterns;
if (args->GetNext(&dict) && !dict.Get("urls", &filter_patterns)) {
args->ThrowError(
"onBeforeRequest parameter 'filter' must have property 'urls'.");
return;
}
URLPattern pattern(URLPattern::SCHEME_ALL);
for (const std::string& filter_pattern : filter_patterns) {
const URLPattern::ParseResult result = pattern.Parse(filter_pattern);
if (result == URLPattern::ParseResult::kSuccess) {
patterns.insert(pattern);
} else {
const char* error_type = URLPattern::GetParseResultString(result);
args->ThrowError("Invalid url pattern " + filter_pattern + ": " +
error_type);
}
}
// Function or null.
v8::Local<v8::Value> value;

View File

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

View File

@@ -10,6 +10,7 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/skbitmap_operations.h"
#include "atom/common/node_includes.h"
@@ -20,12 +21,10 @@ namespace api {
constexpr static int kMaxFrameRate = 30;
FrameSubscriber::FrameSubscriber(v8::Isolate* isolate,
content::WebContents* web_contents,
FrameSubscriber::FrameSubscriber(content::WebContents* web_contents,
const FrameCaptureCallback& callback,
bool only_dirty)
: content::WebContentsObserver(web_contents),
isolate_(isolate),
callback_(callback),
only_dirty_(only_dirty),
weak_ptr_factory_(this) {
@@ -149,26 +148,23 @@ void FrameSubscriber::Done(const gfx::Rect& damage, const SkBitmap& frame) {
if (frame.drawsNothing())
return;
v8::Locker locker(isolate_);
v8::HandleScope handle_scope(isolate_);
const_cast<SkBitmap&>(frame).setAlphaType(kPremul_SkAlphaType);
const SkBitmap& bitmap = only_dirty_ ? SkBitmapOperations::CreateTiledBitmap(
frame, damage.x(), damage.y(),
damage.width(), damage.height())
: frame;
size_t rgb_row_size = bitmap.width() * bitmap.bytesPerPixel();
auto* source = static_cast<const char*>(bitmap.getPixels());
// Copying SkBitmap does not copy the internal pixels, we have to manually
// allocate and write pixels otherwise crash may happen when the original
// frame is modified.
SkBitmap copy;
copy.allocPixels(SkImageInfo::Make(bitmap.width(), bitmap.height(),
kRGBA_8888_SkColorType,
kPremul_SkAlphaType));
SkPixmap pixmap;
bool success = bitmap.peekPixels(&pixmap) && copy.writePixels(pixmap, 0, 0);
CHECK(success);
v8::MaybeLocal<v8::Object> buffer =
node::Buffer::Copy(isolate_, source, rgb_row_size * bitmap.height());
auto local_buffer = buffer.ToLocalChecked();
v8::Local<v8::Value> damage_rect =
mate::Converter<gfx::Rect>::ToV8(isolate_, damage);
callback_.Run(local_buffer, damage_rect);
callback_.Run(gfx::Image::CreateFrom1xBitmap(copy), damage);
}
} // namespace api

View File

@@ -14,6 +14,10 @@
#include "content/public/browser/web_contents_observer.h"
#include "v8/include/v8.h"
namespace gfx {
class Image;
}
namespace atom {
namespace api {
@@ -24,10 +28,9 @@ class FrameSubscriber : public content::WebContentsObserver,
public viz::mojom::FrameSinkVideoConsumer {
public:
using FrameCaptureCallback =
base::Callback<void(v8::Local<v8::Value>, v8::Local<v8::Value>)>;
base::Callback<void(const gfx::Image&, const gfx::Rect&)>;
FrameSubscriber(v8::Isolate* isolate,
content::WebContents* web_contents,
FrameSubscriber(content::WebContents* web_contents,
const FrameCaptureCallback& callback,
bool only_dirty);
~FrameSubscriber() override;
@@ -52,7 +55,6 @@ class FrameSubscriber : public content::WebContentsObserver,
void Done(const gfx::Rect& damage, const SkBitmap& frame);
v8::Isolate* isolate_;
FrameCaptureCallback callback_;
bool only_dirty_;

View File

@@ -3,6 +3,9 @@
// found in the LICENSE file.
#include "atom/browser/api/gpuinfo_manager.h"
#include <utility>
#include "atom/browser/api/gpu_info_enumerator.h"
#include "base/memory/singleton.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -42,8 +45,8 @@ void GPUInfoManager::ProcessCompleteInfo() {
const auto result = EnumerateGPUInfo(gpu_data_manager_->GetGPUInfo());
// We have received the complete information, resolve all promises that
// were waiting for this info.
for (const auto& promise : complete_info_promise_set_) {
promise->Resolve(*result);
for (auto& promise : complete_info_promise_set_) {
promise.Resolve(*result);
}
complete_info_promise_set_.clear();
}
@@ -58,8 +61,8 @@ void GPUInfoManager::OnGpuInfoUpdate() {
}
// Should be posted to the task runner
void GPUInfoManager::CompleteInfoFetcher(scoped_refptr<util::Promise> promise) {
complete_info_promise_set_.push_back(promise);
void GPUInfoManager::CompleteInfoFetcher(util::Promise promise) {
complete_info_promise_set_.emplace_back(std::move(promise));
if (NeedsCompleteGpuInfoCollection()) {
gpu_data_manager_->RequestCompleteGpuInfoIfNeeded();
@@ -68,18 +71,18 @@ void GPUInfoManager::CompleteInfoFetcher(scoped_refptr<util::Promise> promise) {
}
}
void GPUInfoManager::FetchCompleteInfo(scoped_refptr<util::Promise> promise) {
void GPUInfoManager::FetchCompleteInfo(util::Promise promise) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(&GPUInfoManager::CompleteInfoFetcher,
base::Unretained(this), promise));
base::Unretained(this), std::move(promise)));
}
// This fetches the info synchronously, so no need to post to the task queue.
// There cannot be multiple promises as they are resolved synchronously.
void GPUInfoManager::FetchBasicInfo(scoped_refptr<util::Promise> promise) {
void GPUInfoManager::FetchBasicInfo(util::Promise promise) {
gpu::GPUInfo gpu_info;
CollectBasicGraphicsInfo(&gpu_info);
promise->Resolve(*EnumerateGPUInfo(gpu_info));
promise.Resolve(*EnumerateGPUInfo(gpu_info));
}
std::unique_ptr<base::DictionaryValue> GPUInfoManager::EnumerateGPUInfo(

View File

@@ -25,8 +25,8 @@ class GPUInfoManager : public content::GpuDataManagerObserver {
GPUInfoManager();
~GPUInfoManager() override;
bool NeedsCompleteGpuInfoCollection() const;
void FetchCompleteInfo(scoped_refptr<util::Promise> promise);
void FetchBasicInfo(scoped_refptr<util::Promise> promise);
void FetchCompleteInfo(util::Promise promise);
void FetchBasicInfo(util::Promise promise);
void OnGpuInfoUpdate() override;
private:
@@ -34,12 +34,12 @@ class GPUInfoManager : public content::GpuDataManagerObserver {
gpu::GPUInfo gpu_info) const;
// These should be posted to the task queue
void CompleteInfoFetcher(scoped_refptr<util::Promise> promise);
void CompleteInfoFetcher(util::Promise promise);
void ProcessCompleteInfo();
// This set maintains all the promises that should be fulfilled
// once we have the complete information data
std::vector<scoped_refptr<util::Promise>> complete_info_promise_set_;
std::vector<util::Promise> complete_info_promise_set_;
content::GpuDataManager* gpu_data_manager_;
DISALLOW_COPY_AND_ASSIGN(GPUInfoManager);

View File

@@ -57,7 +57,9 @@ void SavePageHandler::OnDownloadUpdated(download::DownloadItem* item) {
callback_.Run(v8::Null(isolate));
} else {
v8::Local<v8::String> error_message =
v8::String::NewFromUtf8(isolate, "Fail to save page");
v8::String::NewFromUtf8(isolate, "Fail to save page",
v8::NewStringType::kNormal)
.ToLocalChecked();
callback_.Run(v8::Exception::Error(error_message));
}
Destroy(item);

View File

@@ -19,12 +19,15 @@ namespace mate {
StreamSubscriber::StreamSubscriber(
v8::Isolate* isolate,
v8::Local<v8::Object> emitter,
base::WeakPtr<atom::URLRequestStreamJob> url_job)
: isolate_(isolate),
base::WeakPtr<atom::URLRequestStreamJob> url_job,
scoped_refptr<base::SequencedTaskRunner> ui_task_runner)
: base::RefCountedDeleteOnSequence<StreamSubscriber>(ui_task_runner),
isolate_(isolate),
emitter_(isolate, emitter),
url_job_(url_job),
weak_factory_(this) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(ui_task_runner->RunsTasksInCurrentSequence());
auto weak_self = weak_factory_.GetWeakPtr();
On("data", base::Bind(&StreamSubscriber::OnData, weak_self));
On("end", base::Bind(&StreamSubscriber::OnEnd, weak_self));
@@ -32,13 +35,12 @@ StreamSubscriber::StreamSubscriber(
}
StreamSubscriber::~StreamSubscriber() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
RemoveAllListeners();
}
void StreamSubscriber::On(const std::string& event,
EventCallback&& callback) { // NOLINT
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(owning_task_runner()->RunsTasksInCurrentSequence());
DCHECK(js_handlers_.find(event) == js_handlers_.end());
v8::Locker locker(isolate_);
@@ -52,7 +54,7 @@ void StreamSubscriber::On(const std::string& event,
}
void StreamSubscriber::Off(const std::string& event) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(owning_task_runner()->RunsTasksInCurrentSequence());
DCHECK(js_handlers_.find(event) != js_handlers_.end());
v8::Locker locker(isolate_);
@@ -96,6 +98,7 @@ void StreamSubscriber::OnError(mate::Arguments* args) {
}
void StreamSubscriber::RemoveAllListeners() {
DCHECK(owning_task_runner()->RunsTasksInCurrentSequence());
v8::Locker locker(isolate_);
v8::Isolate::Scope isolate_scope(isolate_);
v8::HandleScope handle_scope(isolate_);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -11,6 +11,7 @@
#include <memory>
#include <utility>
#include "atom/app/manifests.h"
#include "atom/browser/api/atom_api_app.h"
#include "atom/browser/api/atom_api_protocol.h"
#include "atom/browser/api/atom_api_web_contents.h"
@@ -32,6 +33,7 @@
#include "atom/browser/web_contents_permission_helper.h"
#include "atom/browser/web_contents_preferences.h"
#include "atom/browser/window_list.h"
#include "atom/common/application_info.h"
#include "atom/common/options_switches.h"
#include "atom/common/platform_util.h"
#include "base/command_line.h"
@@ -47,6 +49,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "chrome/browser/browser_process.h"
#include "chrome/common/chrome_version.h"
#include "components/net_log/chrome_net_log.h"
#include "content/public/browser/browser_ppapi_host.h"
#include "content/public/browser/browser_task_traits.h"
@@ -82,6 +85,8 @@
#include "net/ssl/client_cert_store_win.h"
#elif defined(OS_MACOSX)
#include "net/ssl/client_cert_store_mac.h"
#include "services/audio/public/mojom/constants.mojom.h"
#include "services/video_capture/public/mojom/constants.mojom.h"
#elif defined(USE_OPENSSL)
#include "net/ssl/client_cert_store.h"
#endif
@@ -114,19 +119,15 @@ namespace {
// Next navigation should not restart renderer process.
bool g_suppress_renderer_process_restart = false;
// Custom schemes to be registered to handle service worker.
base::NoDestructor<std::string> g_custom_service_worker_schemes;
bool IsSameWebSite(content::BrowserContext* browser_context,
const GURL& src_url,
content::SiteInstance* site_instance,
const GURL& dest_url) {
return content::SiteInstance::IsSameWebSite(browser_context, src_url,
dest_url) ||
// `IsSameWebSite` doesn't seem to work for some URIs such as `file:`,
// handle these scenarios by comparing only the site as defined by
// `GetSiteForURL`.
content::SiteInstance::GetSiteForURL(browser_context, dest_url) ==
src_url;
return site_instance->IsSameSiteWithURL(dest_url) ||
// `IsSameSiteWithURL` doesn't seem to work for some URIs such as
// `file:`, handle these scenarios by comparing only the site as
// defined by `GetSiteForURL`.
(content::SiteInstance::GetSiteForURL(browser_context, dest_url) ==
site_instance->GetSiteURL());
}
AtomBrowserClient* g_browser_client = nullptr;
@@ -148,11 +149,6 @@ void AtomBrowserClient::SuppressRendererProcessRestartForOnce() {
g_suppress_renderer_process_restart = true;
}
void AtomBrowserClient::SetCustomServiceWorkerSchemes(
const std::vector<std::string>& schemes) {
*g_custom_service_worker_schemes = base::JoinString(schemes, ",");
}
AtomBrowserClient* AtomBrowserClient::Get() {
return g_browser_client;
}
@@ -230,8 +226,7 @@ bool AtomBrowserClient::ShouldForceNewSiteInstance(
}
// Create new a SiteInstance if navigating to a different site.
auto src_url = current_instance->GetSiteURL();
return !IsSameWebSite(browser_context, src_url, url);
return !IsSameWebSite(browser_context, current_instance, url);
}
bool AtomBrowserClient::NavigationWasRedirectedCrossSite(
@@ -242,13 +237,12 @@ bool AtomBrowserClient::NavigationWasRedirectedCrossSite(
bool has_response_started) const {
bool navigation_was_redirected = false;
if (has_response_started) {
navigation_was_redirected = !IsSameWebSite(
browser_context, current_instance->GetSiteURL(), dest_url);
navigation_was_redirected =
!IsSameWebSite(browser_context, current_instance, dest_url);
} else {
navigation_was_redirected =
speculative_instance &&
!IsSameWebSite(browser_context, speculative_instance->GetSiteURL(),
dest_url);
!IsSameWebSite(browser_context, speculative_instance, dest_url);
}
return navigation_was_redirected;
@@ -312,7 +306,7 @@ content::SiteInstance* AtomBrowserClient::GetSiteInstanceFromAffinity(
auto iter = site_per_affinities_.find(affinity);
GURL dest_site = content::SiteInstance::GetSiteForURL(browser_context, url);
if (iter != site_per_affinities_.end() &&
IsSameWebSite(browser_context, iter->second->GetSiteURL(), dest_site)) {
IsSameWebSite(browser_context, iter->second, dest_site)) {
return iter->second;
}
}
@@ -410,6 +404,7 @@ AtomBrowserClient::ShouldOverrideSiteInstanceForNavigation(
content::RenderFrameHost* speculative_rfh,
content::BrowserContext* browser_context,
const GURL& url,
bool has_navigation_started,
bool has_response_started,
content::SiteInstance** affinity_site_instance) const {
if (g_suppress_renderer_process_restart) {
@@ -444,6 +439,13 @@ AtomBrowserClient::ShouldOverrideSiteInstanceForNavigation(
return SiteInstanceForNavigationType::FORCE_CURRENT;
}
if (!has_navigation_started) {
// If the navigation didn't start yet, ignore any candidate site instance.
// If such instance exists, it belongs to a previous navigation still
// taking place. Fixes https://github.com/electron/electron/issues/17576.
return SiteInstanceForNavigationType::FORCE_NEW;
}
return SiteInstanceForNavigationType::FORCE_CANDIDATE_OR_NEW;
}
@@ -477,17 +479,14 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
return;
// Copy following switches to child process.
static const char* const kCommonSwitchNames[] = {switches::kStandardSchemes,
switches::kEnableSandbox,
switches::kSecureSchemes};
static const char* const kCommonSwitchNames[] = {
switches::kStandardSchemes, switches::kEnableSandbox,
switches::kSecureSchemes, switches::kBypassCSPSchemes,
switches::kCORSSchemes, switches::kFetchSchemes,
switches::kServiceWorkerSchemes};
command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
kCommonSwitchNames,
arraysize(kCommonSwitchNames));
// The registered service worker schemes.
if (!g_custom_service_worker_schemes->empty())
command_line->AppendSwitchASCII(switches::kRegisterServiceWorkerSchemes,
*g_custom_service_worker_schemes);
base::size(kCommonSwitchNames));
#if defined(OS_WIN)
// Append --app-user-model-id.
@@ -523,6 +522,16 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
}
}
void AtomBrowserClient::AdjustUtilityServiceProcessCommandLine(
const service_manager::Identity& identity,
base::CommandLine* command_line) {
#if defined(OS_MACOSX)
if (identity.name() == video_capture::mojom::kServiceName ||
identity.name() == audio::mojom::kServiceName)
command_line->AppendSwitch(::switches::kMessageLoopTypeUi);
#endif
}
void AtomBrowserClient::DidCreatePpapiPlugin(content::BrowserPpapiHost* host) {
#if BUILDFLAG(ENABLE_PEPPER_FLASH)
host->GetPpapiHost()->AddHostFactoryFilter(
@@ -594,7 +603,7 @@ bool AtomBrowserClient::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,
@@ -610,11 +619,6 @@ bool AtomBrowserClient::CanCreateWindow(
int opener_render_process_id = opener->GetProcess()->GetID();
if (IsRendererSandboxed(opener_render_process_id)) {
*no_javascript_access = false;
return true;
}
if (RendererUsesNativeWindowOpen(opener_render_process_id)) {
if (RendererDisablesPopups(opener_render_process_id)) {
// <webview> without allowpopups attribute should return
@@ -713,20 +717,17 @@ void AtomBrowserClient::RegisterOutOfProcessServices(
#endif
}
std::unique_ptr<base::Value> AtomBrowserClient::GetServiceManifestOverlay(
base::StringPiece name) {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
int id = -1;
if (name == content::mojom::kBrowserServiceName)
id = IDR_ELECTRON_CONTENT_BROWSER_MANIFEST_OVERLAY;
else if (name == content::mojom::kPackagedServicesServiceName)
id = IDR_ELECTRON_CONTENT_PACKAGED_SERVICES_MANIFEST_OVERLAY;
base::Optional<service_manager::Manifest>
AtomBrowserClient::GetServiceManifestOverlay(base::StringPiece name) {
if (name == content::mojom::kBrowserServiceName) {
return GetElectronContentBrowserOverlayManifest();
} else if (name == content::mojom::kPackagedServicesServiceName) {
service_manager::Manifest overlay;
overlay.packaged_services = GetElectronPackagedServicesOverlayManifest();
return overlay;
}
if (id == -1)
return nullptr;
base::StringPiece manifest_contents = rb.GetRawDataResource(id);
return base::JSONReader::Read(manifest_contents);
return base::nullopt;
}
net::NetLog* AtomBrowserClient::GetNetLog() {
@@ -895,6 +896,14 @@ bool AtomBrowserClient::ShouldBypassCORB(int render_process_id) const {
return it != process_preferences_.end() && !it->second.web_security;
}
std::string AtomBrowserClient::GetProduct() const {
return "Chrome/" CHROME_VERSION_STRING;
}
std::string AtomBrowserClient::GetUserAgent() const {
return GetApplicationUserAgent();
}
std::string AtomBrowserClient::GetApplicationLocale() {
if (BrowserThread::CurrentlyOn(BrowserThread::IO))
return g_io_thread_application_locale.Get();

View File

@@ -49,10 +49,6 @@ class AtomBrowserClient : public content::ContentBrowserClient,
// Don't force renderer process to restart for once.
static void SuppressRendererProcessRestartForOnce();
// Custom schemes to be registered to handle service worker.
static void SetCustomServiceWorkerSchemes(
const std::vector<std::string>& schemes);
NotificationPresenter* GetNotificationPresenter();
void WebNotificationAllowed(int render_process_id,
@@ -82,6 +78,7 @@ class AtomBrowserClient : public content::ContentBrowserClient,
content::RenderFrameHost* speculative_rfh,
content::BrowserContext* browser_context,
const GURL& url,
bool has_navigation_started,
bool has_request_started,
content::SiteInstance** affinity_site_instance) const override;
void RegisterPendingSiteInstance(
@@ -89,6 +86,9 @@ class AtomBrowserClient : public content::ContentBrowserClient,
content::SiteInstance* pending_site_instance) override;
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
int child_process_id) override;
void AdjustUtilityServiceProcessCommandLine(
const service_manager::Identity& identity,
base::CommandLine* command_line) override;
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
std::string GetGeolocationApiKey() override;
content::QuotaPermissionContext* CreateQuotaPermissionContext() override;
@@ -113,7 +113,7 @@ class AtomBrowserClient : public content::ContentBrowserClient,
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,
@@ -139,7 +139,7 @@ class AtomBrowserClient : public content::ContentBrowserClient,
bool in_memory,
const base::FilePath& relative_partition_path) override;
void RegisterOutOfProcessServices(OutOfProcessServiceMap* services) override;
std::unique_ptr<base::Value> GetServiceManifestOverlay(
base::Optional<service_manager::Manifest> GetServiceManifestOverlay(
base::StringPiece name) override;
net::NetLog* GetNetLog() override;
content::MediaObserver* GetMediaObserver() override;
@@ -154,6 +154,8 @@ class AtomBrowserClient : public content::ContentBrowserClient,
void OnNetworkServiceCreated(
network::mojom::NetworkService* network_service) override;
bool ShouldBypassCORB(int render_process_id) const override;
std::string GetProduct() const override;
std::string GetUserAgent() const override;
// content::RenderProcessHostObserver:
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;

View File

@@ -11,7 +11,6 @@
#include "atom/browser/atom_download_manager_delegate.h"
#include "atom/browser/atom_paths.h"
#include "atom/browser/atom_permission_manager.h"
#include "atom/browser/browser.h"
#include "atom/browser/cookie_change_notifier.h"
#include "atom/browser/net/resolve_proxy_helper.h"
#include "atom/browser/pref_store_delegate.h"
@@ -20,17 +19,14 @@
#include "atom/browser/web_view_manager.h"
#include "atom/browser/zoom_level_delegate.h"
#include "atom/common/application_info.h"
#include "atom/common/atom_version.h"
#include "atom/common/options_switches.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_version.h"
#include "chrome/common/pref_names.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/prefs/json_pref_store.h"
@@ -41,8 +37,8 @@
#include "components/proxy_config/pref_proxy_config_tracker_impl.h"
#include "components/proxy_config/proxy_config_pref_names.h"
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/user_agent.h"
#include "net/base/escape.h"
using content::BrowserThread;
@@ -51,14 +47,6 @@ namespace atom {
namespace {
std::string RemoveWhitespace(const std::string& str) {
std::string trimmed;
if (base::RemoveChars(str, " ", &trimmed))
return trimmed;
else
return str;
}
// Convert string to lower case and escape it.
std::string MakePartitionName(const std::string& input) {
return net::EscapePath(base::ToLowerASCII(input));
@@ -78,19 +66,7 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition,
storage_policy_(new SpecialStoragePolicy),
in_memory_(in_memory),
weak_factory_(this) {
// Construct user agent string.
Browser* browser = Browser::Get();
std::string name = RemoveWhitespace(browser->GetName());
std::string user_agent;
if (name == ATOM_PRODUCT_NAME) {
user_agent = "Chrome/" CHROME_VERSION_STRING " " ATOM_PRODUCT_NAME
"/" ATOM_VERSION_STRING;
} else {
user_agent = base::StringPrintf(
"%s/%s Chrome/%s " ATOM_PRODUCT_NAME "/" ATOM_VERSION_STRING,
name.c_str(), browser->GetVersion().c_str(), CHROME_VERSION_STRING);
}
user_agent_ = content::BuildUserAgentFromProduct(user_agent);
user_agent_ = GetApplicationUserAgent();
// Read options.
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
@@ -285,6 +261,11 @@ AtomBrowserContext::GetBrowsingDataRemoverDelegate() {
return nullptr;
}
content::ClientHintsControllerDelegate*
AtomBrowserContext::GetClientHintsControllerDelegate() {
return nullptr;
}
net::URLRequestContextGetter*
AtomBrowserContext::CreateRequestContextForStoragePartition(
const base::FilePath& partition_path,

View File

@@ -88,6 +88,8 @@ class AtomBrowserContext
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) override;
net::URLRequestContextGetter* CreateMediaRequestContext() override;
content::ClientHintsControllerDelegate* GetClientHintsControllerDelegate()
override;
CookieChangeNotifier* cookie_change_notifier() const {
return cookie_change_notifier_.get();

View File

@@ -455,7 +455,7 @@ bool AtomBrowserMainParts::MainMessageLoopRun(int* result_code) {
void AtomBrowserMainParts::PreDefaultMainMessageLoopRun(
base::OnceClosure quit_closure) {
Browser::SetMainMessageLoopQuitClosure(std::move(quit_closure));
Browser::Get()->SetMainMessageLoopQuitClosure(std::move(quit_closure));
}
void AtomBrowserMainParts::PostMainMessageLoopStart() {
@@ -481,6 +481,7 @@ void AtomBrowserMainParts::PostMainMessageLoopRun() {
ui::SetX11ErrorHandlers(X11EmptyErrorHandler, X11EmptyIOErrorHandler);
#endif
node_debugger_->Stop();
js_env_->OnMessageLoopDestroying();
#if defined(OS_MACOSX)

View File

@@ -54,8 +54,26 @@ void AtomBrowserMainParts::InitializeMainNib() {
auto application = [principalClass sharedApplication];
NSString* mainNibName = [infoDictionary objectForKey:@"NSMainNibFile"];
auto mainNib = [[NSNib alloc] initWithNibNamed:mainNibName
bundle:base::mac::FrameworkBundle()];
NSNib* mainNib;
@try {
mainNib = [[NSNib alloc] initWithNibNamed:mainNibName
bundle:base::mac::FrameworkBundle()];
// Handle failure of initWithNibNamed on SMB shares
// TODO(codebytere): Remove when
// https://bugs.chromium.org/p/chromium/issues/detail?id=932935 is fixed
} @catch (NSException* exception) {
NSString* nibPath =
[NSString stringWithFormat:@"Resources/%@.nib", mainNibName];
nibPath = [base::mac::FrameworkBundle().bundlePath
stringByAppendingPathComponent:nibPath];
NSData* data = [NSData dataWithContentsOfFile:nibPath];
mainNib = [[NSNib alloc] initWithNibData:data
bundle:base::mac::FrameworkBundle()];
}
[mainNib instantiateWithOwner:application topLevelObjects:nil];
[mainNib release];
}

View File

@@ -100,23 +100,58 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated(
if (relay)
window = relay->GetNativeWindow();
auto* web_preferences = WebContentsPreferences::From(web_contents);
bool offscreen =
!web_preferences || web_preferences->IsEnabled(options::kOffscreen);
// Show save dialog if save path was not set already on item
base::FilePath path;
GetItemSavePath(item, &path);
// Show save dialog if save path was not set already on item
file_dialog::DialogSettings settings;
GetItemSaveDialogOptions(item, &settings);
if (!settings.parent_window)
settings.parent_window = window;
settings.force_detached = offscreen;
if (settings.title.size() == 0)
settings.title = item->GetURL().spec();
if (!settings.default_path.empty())
settings.default_path = default_path;
if (path.empty() && file_dialog::ShowSaveDialog(settings, &path)) {
if (path.empty()) {
file_dialog::DialogSettings settings;
GetItemSaveDialogOptions(item, &settings);
if (!settings.parent_window)
settings.parent_window = window;
if (settings.title.size() == 0)
settings.title = item->GetURL().spec();
if (settings.default_path.empty())
settings.default_path = default_path;
auto* web_preferences = WebContentsPreferences::From(web_contents);
const bool offscreen =
!web_preferences || web_preferences->IsEnabled(options::kOffscreen);
settings.force_detached = offscreen;
auto dialog_callback =
base::Bind(&AtomDownloadManagerDelegate::OnDownloadSaveDialogDone,
base::Unretained(this), download_id, callback);
file_dialog::ShowSaveDialog(settings, dialog_callback);
} else {
callback.Run(path, download::DownloadItem::TARGET_DISPOSITION_PROMPT,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, path,
download::DOWNLOAD_INTERRUPT_REASON_NONE);
}
}
#if defined(MAS_BUILD)
void AtomDownloadManagerDelegate::OnDownloadSaveDialogDone(
uint32_t download_id,
const content::DownloadTargetCallback& download_callback,
bool result,
const base::FilePath& path,
const std::string& bookmark)
#else
void AtomDownloadManagerDelegate::OnDownloadSaveDialogDone(
uint32_t download_id,
const content::DownloadTargetCallback& download_callback,
bool result,
const base::FilePath& path)
#endif
{
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
auto* item = download_manager_->GetDownload(download_id);
if (!item)
return;
if (result) {
// Remember the last selected download directory.
AtomBrowserContext* browser_context = static_cast<AtomBrowserContext*>(
download_manager_->GetBrowserContext());
@@ -133,12 +168,16 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated(
}
// Running the DownloadTargetCallback with an empty FilePath signals that the
// download should be cancelled.
// If user cancels the file save dialog, run the callback with empty FilePath.
callback.Run(path, download::DownloadItem::TARGET_DISPOSITION_PROMPT,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, path,
path.empty() ? download::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED
: download::DOWNLOAD_INTERRUPT_REASON_NONE);
// download should be cancelled. If user cancels the file save dialog, run
// the callback with empty FilePath.
const base::FilePath download_path = result ? path : base::FilePath();
const auto interrupt_reason =
download_path.empty() ? download::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED
: download::DOWNLOAD_INTERRUPT_REASON_NONE;
download_callback.Run(download_path,
download::DownloadItem::TARGET_DISPOSITION_PROMPT,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
download_path, interrupt_reason);
}
void AtomDownloadManagerDelegate::Shutdown() {

View File

@@ -25,10 +25,6 @@ class AtomDownloadManagerDelegate : public content::DownloadManagerDelegate {
explicit AtomDownloadManagerDelegate(content::DownloadManager* manager);
~AtomDownloadManagerDelegate() override;
void OnDownloadPathGenerated(uint32_t download_id,
const content::DownloadTargetCallback& callback,
const base::FilePath& default_path);
// content::DownloadManagerDelegate:
void Shutdown() override;
bool DetermineDownloadTarget(
@@ -45,6 +41,25 @@ class AtomDownloadManagerDelegate : public content::DownloadManagerDelegate {
void GetItemSaveDialogOptions(download::DownloadItem* item,
file_dialog::DialogSettings* settings);
void OnDownloadPathGenerated(uint32_t download_id,
const content::DownloadTargetCallback& callback,
const base::FilePath& default_path);
#if defined(MAS_BUILD)
void OnDownloadSaveDialogDone(
uint32_t download_id,
const content::DownloadTargetCallback& download_callback,
bool result,
const base::FilePath& path,
const std::string& bookmark);
#else
void OnDownloadSaveDialogDone(
uint32_t download_id,
const content::DownloadTargetCallback& download_callback,
bool result,
const base::FilePath& path);
#endif
content::DownloadManager* download_manager_;
base::WeakPtrFactory<AtomDownloadManagerDelegate> weak_ptr_factory_;

View File

@@ -41,7 +41,16 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
DialogClosedCallback callback,
bool* did_suppress_message) {
auto origin_url = rfh->GetLastCommittedURL();
const std::string& origin = origin_url.GetOrigin().spec();
std::string origin;
// For file:// URLs we do the alert filtering by the
// file path currently loaded
if (origin_url.SchemeIsFile()) {
origin = origin_url.path();
} else {
origin = origin_url.GetOrigin().spec();
}
if (origin_counts_[origin] == kUserWantsNoMoreDialogs) {
return std::move(callback).Run(false, base::string16());
}
@@ -52,9 +61,16 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
return;
}
// No default button
int default_id = -1;
int cancel_id = 0;
std::vector<std::string> buttons = {"OK"};
if (dialog_type == JavaScriptDialogType::JAVASCRIPT_DIALOG_TYPE_CONFIRM) {
buttons.push_back("Cancel");
// First button is default, second button is cancel
default_id = 0;
cancel_id = 1;
}
origin_counts_[origin]++;
@@ -76,8 +92,8 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
}
atom::ShowMessageBox(
window, atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, -1, 0,
atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
window, atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, default_id,
cancel_id, atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
base::UTF16ToUTF8(message_text), "", checkbox, false, gfx::ImageSkia(),
base::Bind(&AtomJavaScriptDialogManager::OnMessageBoxCallback,
base::Unretained(this), base::Passed(std::move(callback)),

View File

@@ -183,12 +183,14 @@ int AtomPermissionManager::RequestPermissionsWithDetails(
const auto callback =
base::Bind(&AtomPermissionManager::OnPermissionResponse,
base::Unretained(this), request_id, i);
if (details == nullptr) {
request_handler_.Run(web_contents, permission, callback,
base::DictionaryValue());
} else {
request_handler_.Run(web_contents, permission, callback, *details);
}
auto mutable_details =
details == nullptr ? base::DictionaryValue() : details->Clone();
mutable_details.SetKey(
"requestingUrl",
base::Value(render_frame_host->GetLastCommittedURL().spec()));
mutable_details.SetKey(
"isMainFrame", base::Value(render_frame_host->GetParent() == nullptr));
request_handler_.Run(web_contents, permission, callback, mutable_details);
}
return request_id;
@@ -241,8 +243,15 @@ bool AtomPermissionManager::CheckPermissionWithDetails(
}
auto* web_contents =
content::WebContents::FromRenderFrameHost(render_frame_host);
auto mutable_details =
details == nullptr ? base::DictionaryValue() : details->Clone();
mutable_details.SetKey(
"requestingUrl",
base::Value(render_frame_host->GetLastCommittedURL().spec()));
mutable_details.SetKey(
"isMainFrame", base::Value(render_frame_host->GetParent() == nullptr));
return check_handler_.Run(web_contents, permission, requesting_origin,
*details);
mutable_details);
}
blink::mojom::PermissionStatus

View File

@@ -31,11 +31,11 @@ class AtomPermissionManager : public content::PermissionControllerDelegate {
using RequestHandler = base::Callback<void(content::WebContents*,
content::PermissionType,
const StatusCallback&,
const base::DictionaryValue&)>;
const base::Value&)>;
using CheckHandler = base::Callback<bool(content::WebContents*,
content::PermissionType,
const GURL& requesting_origin,
const base::DictionaryValue&)>;
const base::Value&)>;
// Handler to dispatch permission requests in JS.
void SetPermissionRequestHandler(const RequestHandler& handler);

View File

@@ -25,9 +25,6 @@
namespace atom {
// Null until/unless the default main message loop is running.
base::NoDestructor<base::OnceClosure> g_quit_main_message_loop;
Browser::LoginItemSettings::LoginItemSettings() = default;
Browser::LoginItemSettings::~LoginItemSettings() = default;
Browser::LoginItemSettings::LoginItemSettings(const LoginItemSettings& other) =
@@ -95,11 +92,12 @@ void Browser::Shutdown() {
for (BrowserObserver& observer : observers_)
observer.OnQuit();
if (*g_quit_main_message_loop) {
std::move(*g_quit_main_message_loop).Run();
if (quit_main_message_loop_) {
std::move(quit_main_message_loop_).Run();
} else {
// There is no message loop available so we are in early stage.
exit(0);
// There is no message loop available so we are in early stage, wait until
// the quit_main_message_loop_ is available.
// Exiting now would leave defunct processes behind.
}
}
@@ -167,14 +165,14 @@ void Browser::DidFinishLaunching(const base::DictionaryValue& launch_info) {
observer.OnFinishLaunching(launch_info);
}
util::Promise* Browser::WhenReady(v8::Isolate* isolate) {
const util::Promise& Browser::WhenReady(v8::Isolate* isolate) {
if (!ready_promise_) {
ready_promise_ = new util::Promise(isolate);
ready_promise_.reset(new util::Promise(isolate));
if (is_ready()) {
ready_promise_->Resolve();
}
}
return ready_promise_;
return *ready_promise_;
}
void Browser::OnAccessibilitySupportChanged() {
@@ -196,7 +194,10 @@ void Browser::PreMainMessageLoopRun() {
}
void Browser::SetMainMessageLoopQuitClosure(base::OnceClosure quit_closure) {
*g_quit_main_message_loop = std::move(quit_closure);
if (is_shutdown_)
std::move(quit_closure).Run();
else
quit_main_message_loop_ = std::move(quit_closure);
}
void Browser::NotifyAndShutdown() {

View File

@@ -244,7 +244,7 @@ class Browser : public WindowListObserver {
// Stores the supplied |quit_closure|, to be run when the last Browser
// instance is destroyed.
static void SetMainMessageLoopQuitClosure(base::OnceClosure quit_closure);
void SetMainMessageLoopQuitClosure(base::OnceClosure quit_closure);
void AddObserver(BrowserObserver* obs) { observers_.AddObserver(obs); }
@@ -253,7 +253,7 @@ class Browser : public WindowListObserver {
bool is_shutting_down() const { return is_shutdown_; }
bool is_quiting() const { return is_quiting_; }
bool is_ready() const { return is_ready_; }
util::Promise* WhenReady(v8::Isolate* isolate);
const util::Promise& WhenReady(v8::Isolate* isolate);
protected:
// Returns the version of application bundle or executable file.
@@ -287,9 +287,12 @@ class Browser : public WindowListObserver {
// The browser is being shutdown.
bool is_shutdown_ = false;
// Null until/unless the default main message loop is running.
base::OnceClosure quit_main_message_loop_;
int badge_count_ = 0;
util::Promise* ready_promise_ = nullptr;
std::unique_ptr<util::Promise> ready_promise_;
#if defined(OS_LINUX) || defined(OS_MACOSX)
base::DictionaryValue about_panel_options_;

View File

@@ -145,7 +145,8 @@ bool Browser::IsUnityRunning() {
void Browser::ShowAboutPanel() {
std::string app_name, version, copyright, icon_path, website;
GtkAboutDialog* dialog = GTK_ABOUT_DIALOG(gtk_about_dialog_new());
GtkWidget* dialogWidget = gtk_about_dialog_new();
GtkAboutDialog* dialog = GTK_ABOUT_DIALOG(dialogWidget);
if (about_panel_options_.GetString("applicationName", &app_name))
gtk_about_dialog_set_program_name(dialog, app_name.c_str());
@@ -157,7 +158,12 @@ void Browser::ShowAboutPanel() {
gtk_about_dialog_set_website(dialog, website.c_str());
if (about_panel_options_.GetString("iconPath", &icon_path)) {
GError* error = nullptr;
GdkPixbuf* icon = gdk_pixbuf_new_from_file(icon_path.c_str(), &error);
constexpr int width = 64; // width of about panel icon in pixels
constexpr int height = 64; // height of about panel icon in pixels
// set preserve_aspect_ratio to true
GdkPixbuf* icon = gdk_pixbuf_new_from_file_at_size(icon_path.c_str(), width,
height, &error);
if (error != nullptr) {
g_warning("%s", error->message);
g_clear_error(&error);
@@ -168,7 +174,7 @@ void Browser::ShowAboutPanel() {
}
gtk_dialog_run(GTK_DIALOG(dialog));
g_clear_object(&dialog);
gtk_widget_destroy(dialogWidget);
}
void Browser::SetAboutPanelOptions(const base::DictionaryValue& options) {

View File

@@ -147,13 +147,9 @@ void Browser::SetUserActivity(const std::string& type,
}
std::string Browser::GetCurrentActivityType() {
if (@available(macOS 10.10, *)) {
NSUserActivity* userActivity =
[[AtomApplication sharedApplication] getCurrentActivity];
return base::SysNSStringToUTF8(userActivity.activityType);
} else {
return std::string();
}
NSUserActivity* userActivity =
[[AtomApplication sharedApplication] getCurrentActivity];
return base::SysNSStringToUTF8(userActivity.activityType);
}
void Browser::InvalidateCurrentActivity() {
@@ -231,9 +227,10 @@ LSSharedFileListItemRef GetLoginItemForApp() {
for (NSUInteger i = 0; i < [login_items_array count]; ++i) {
LSSharedFileListItemRef item =
reinterpret_cast<LSSharedFileListItemRef>(login_items_array[i]);
CFURLRef item_url_ref = NULL;
if (LSSharedFileListItemResolve(item, 0, &item_url_ref, NULL) == noErr &&
item_url_ref) {
base::ScopedCFTypeRef<CFErrorRef> error;
CFURLRef item_url_ref =
LSSharedFileListItemCopyResolvedURL(item, 0, error.InitializeInto());
if (!error && item_url_ref) {
base::ScopedCFTypeRef<CFURLRef> item_url(item_url_ref);
if (CFEqual(item_url, url)) {
CFRetain(item);
@@ -264,9 +261,10 @@ void RemoveFromLoginItems() {
for (NSUInteger i = 0; i < [login_items_array count]; ++i) {
LSSharedFileListItemRef item =
reinterpret_cast<LSSharedFileListItemRef>(login_items_array[i]);
CFURLRef url_ref = NULL;
if (LSSharedFileListItemResolve(item, 0, &url_ref, NULL) == noErr &&
item) {
base::ScopedCFTypeRef<CFErrorRef> error;
CFURLRef url_ref =
LSSharedFileListItemCopyResolvedURL(item, 0, error.InitializeInto());
if (!error && url_ref) {
base::ScopedCFTypeRef<CFURLRef> url(url_ref);
if ([[base::mac::CFToNSCast(url.get()) path]
hasPrefix:[[NSBundle mainBundle] bundlePath]])

View File

@@ -95,9 +95,6 @@ void Browser::Focus() {
}
void Browser::AddRecentDocument(const base::FilePath& path) {
if (base::win::GetVersion() < base::win::VERSION_WIN7)
return;
CComPtr<IShellItem> item;
HRESULT hr = SHCreateItemFromParsingName(path.value().c_str(), NULL,
IID_PPV_ARGS(&item));
@@ -110,13 +107,7 @@ void Browser::AddRecentDocument(const base::FilePath& path) {
}
void Browser::ClearRecentDocuments() {
CComPtr<IApplicationDestinations> destinations;
if (FAILED(destinations.CoCreateInstance(CLSID_ApplicationDestinations, NULL,
CLSCTX_INPROC_SERVER)))
return;
if (FAILED(destinations->SetAppID(GetAppUserModelID())))
return;
destinations->RemoveAllDestinations();
SHAddToRecentDocs(SHARD_APPIDINFO, nullptr);
}
void Browser::SetAppUserModelID(const base::string16& name) {

View File

@@ -0,0 +1,14 @@
// Copyright (c) 2019 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/browser/child_web_contents_tracker.h"
namespace atom {
ChildWebContentsTracker::ChildWebContentsTracker(
content::WebContents* web_contents) {}
WEB_CONTENTS_USER_DATA_KEY_IMPL(ChildWebContentsTracker)
} // namespace atom

View File

@@ -18,11 +18,12 @@ struct ChildWebContentsTracker
GURL url;
std::string frame_name;
explicit ChildWebContentsTracker(content::WebContents* web_contents) {}
private:
explicit ChildWebContentsTracker(content::WebContents* web_contents);
friend class content::WebContentsUserData<ChildWebContentsTracker>;
WEB_CONTENTS_USER_DATA_KEY_DECL();
DISALLOW_COPY_AND_ASSIGN(ChildWebContentsTracker);
};

View File

@@ -10,6 +10,7 @@
#include <utility>
#include <vector>
#include "atom/browser/atom_browser_client.h"
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/native_window.h"
#include "atom/browser/ui/file_dialog.h"
@@ -23,7 +24,7 @@
#include "base/threading/scoped_blocking_call.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "chrome/browser/ssl/security_state_tab_helper.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/color_chooser.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
@@ -183,7 +184,8 @@ void CommonWebContentsDelegate::InitWithWebContents(
#if BUILDFLAG(ENABLE_PRINTING)
PrintPreviewMessageHandler::CreateForWebContents(web_contents);
printing::PrintViewManagerBasic::CreateForWebContents(web_contents);
printing::CreateCompositeClientIfNeeded(web_contents);
printing::CreateCompositeClientIfNeeded(web_contents,
browser_context->GetUserAgent());
#endif
// Determien whether the WebContents is offscreen.
@@ -206,15 +208,14 @@ void CommonWebContentsDelegate::SetOwnerWindow(
NativeWindow* owner_window) {
if (owner_window) {
owner_window_ = owner_window->GetWeakPtr();
#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
#if defined(TOOLKIT_VIEWS)
autofill_popup_.reset(new AutofillPopup());
#endif
NativeWindowRelay::CreateForWebContents(web_contents,
owner_window->GetWeakPtr());
} else {
owner_window_ = nullptr;
web_contents->RemoveUserData(
NativeWindowRelay::kNativeWindowRelayUserDataKey);
web_contents->RemoveUserData(NativeWindowRelay::UserDataKey());
}
#if BUILDFLAG(ENABLE_OSR)
auto* osr_wcv = GetOffScreenWebContentsView();
@@ -274,6 +275,7 @@ content::WebContents* CommonWebContentsDelegate::OpenURLFromTab(
load_url_params.should_replace_current_entry =
params.should_replace_current_entry;
load_url_params.is_renderer_initiated = params.is_renderer_initiated;
load_url_params.initiator_origin = params.initiator_origin;
load_url_params.should_clear_history_list = true;
source->GetController().LoadURLWithParams(load_url_params);
@@ -320,9 +322,12 @@ void CommonWebContentsDelegate::EnterFullscreenModeForTab(
const blink::WebFullscreenOptions& options) {
if (!owner_window_)
return;
if (IsFullscreenForTabOrPending(source)) {
DCHECK_EQ(fullscreen_frame_, source->GetFocusedFrame());
return;
}
SetHtmlApiFullscreen(true);
owner_window_->NotifyWindowEnterHtmlFullScreen();
source->GetRenderViewHost()->GetWidget()->SynchronizeVisualProperties();
}
void CommonWebContentsDelegate::ExitFullscreenModeForTab(
@@ -331,7 +336,6 @@ void CommonWebContentsDelegate::ExitFullscreenModeForTab(
return;
SetHtmlApiFullscreen(false);
owner_window_->NotifyWindowLeaveHtmlFullScreen();
source->GetRenderViewHost()->GetWidget()->SynchronizeVisualProperties();
}
bool CommonWebContentsDelegate::IsFullscreenForTabOrPending(
@@ -619,4 +623,24 @@ void CommonWebContentsDelegate::SetHtmlApiFullscreen(bool enter_fullscreen) {
native_fullscreen_ = false;
}
void CommonWebContentsDelegate::ShowAutofillPopup(
content::RenderFrameHost* frame_host,
content::RenderFrameHost* embedder_frame_host,
bool offscreen,
const gfx::RectF& bounds,
const std::vector<base::string16>& values,
const std::vector<base::string16>& labels) {
if (!owner_window())
return;
autofill_popup_->CreateView(frame_host, embedder_frame_host, offscreen,
owner_window()->content_view(), bounds);
autofill_popup_->SetItems(values, labels);
}
void CommonWebContentsDelegate::HideAutofillPopup() {
if (autofill_popup_)
autofill_popup_->Hide();
}
} // namespace atom

View File

@@ -18,7 +18,7 @@
#include "content/public/browser/web_contents_delegate.h"
#include "electron/buildflags/buildflags.h"
#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
#if defined(TOOLKIT_VIEWS)
#include "atom/browser/ui/autofill_popup.h"
#endif
@@ -68,6 +68,10 @@ class CommonWebContentsDelegate : public content::WebContentsDelegate,
bool is_html_fullscreen() const { return html_fullscreen_; }
void set_fullscreen_frame(content::RenderFrameHost* rfh) {
fullscreen_frame_ = rfh;
}
protected:
#if BUILDFLAG(ENABLE_OSR)
virtual OffScreenWebContentsView* GetOffScreenWebContentsView() const;
@@ -105,7 +109,7 @@ class CommonWebContentsDelegate : public content::WebContentsDelegate,
const content::NativeWebKeyboardEvent& event) override;
// Autofill related events.
#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
#if defined(TOOLKIT_VIEWS)
void ShowAutofillPopup(content::RenderFrameHost* frame_host,
content::RenderFrameHost* embedder_frame_host,
bool offscreen,
@@ -175,7 +179,7 @@ class CommonWebContentsDelegate : public content::WebContentsDelegate,
bool native_fullscreen_ = false;
// UI related helper classes.
#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
#if defined(TOOLKIT_VIEWS)
std::unique_ptr<AutofillPopup> autofill_popup_;
#endif
std::unique_ptr<WebDialogHelper> web_dialog_helper_;
@@ -203,6 +207,9 @@ class CommonWebContentsDelegate : public content::WebContentsDelegate,
scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
// Stores the frame thats currently in fullscreen, nullptr if there is none.
content::RenderFrameHost* fullscreen_frame_ = nullptr;
base::WeakPtrFactory<CommonWebContentsDelegate> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(CommonWebContentsDelegate);

View File

@@ -41,27 +41,6 @@ bool CommonWebContentsDelegate::HandleKeyboardEvent(
return false;
}
void CommonWebContentsDelegate::ShowAutofillPopup(
content::RenderFrameHost* frame_host,
content::RenderFrameHost* embedder_frame_host,
bool offscreen,
const gfx::RectF& bounds,
const std::vector<base::string16>& values,
const std::vector<base::string16>& labels) {
if (!owner_window())
return;
auto* window = static_cast<NativeWindowViews*>(owner_window());
autofill_popup_->CreateView(frame_host, embedder_frame_host, offscreen,
window->content_view(), bounds);
autofill_popup_->SetItems(values, labels);
}
void CommonWebContentsDelegate::HideAutofillPopup() {
if (autofill_popup_)
autofill_popup_->Hide();
}
gfx::ImageSkia CommonWebContentsDelegate::GetDevToolsWindowIcon() {
if (!owner_window())
return gfx::ImageSkia();

View File

@@ -7,6 +7,7 @@
#include <string>
#include <unordered_map>
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/common/pref_names.h"
@@ -103,7 +104,7 @@ const FontDefault kFontDefaults[] = {
IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN},
#endif
};
const size_t kFontDefaultsLength = arraysize(kFontDefaults);
const size_t kFontDefaultsLength = base::size(kFontDefaults);
// ^^^^^ DO NOT EDIT ^^^^^

View File

@@ -54,10 +54,10 @@ v8::Isolate* JavascriptEnvironment::Initialize(uv_loop_t* event_loop) {
tracing_controller);
v8::V8::InitializePlatform(platform_);
gin::IsolateHolder::Initialize(
gin::IsolateHolder::kNonStrictMode, gin::IsolateHolder::kStableV8Extras,
gin::ArrayBufferAllocator::SharedInstance(),
nullptr /* external_reference_table */, false /* create_v8_platform */);
gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,
gin::ArrayBufferAllocator::SharedInstance(),
nullptr /* external_reference_table */,
false /* create_v8_platform */);
v8::Isolate* isolate = v8::Isolate::Allocate();
platform_->RegisterIsolate(isolate, event_loop);
@@ -74,6 +74,7 @@ void JavascriptEnvironment::OnMessageLoopCreated() {
void JavascriptEnvironment::OnMessageLoopDestroying() {
DCHECK(microtasks_runner_);
base::MessageLoopCurrent::Get()->RemoveTaskObserver(microtasks_runner_.get());
platform_->DrainTasks(isolate_);
platform_->UnregisterIsolate(isolate_);
}

View File

@@ -87,8 +87,7 @@ typedef NS_ENUM(NSInteger, AVAuthorizationStatusMac) {
NSUserActivityDelegate> {
@private
BOOL handlingSendEvent_;
base::scoped_nsobject<NSUserActivity> currentActivity_
API_AVAILABLE(macosx(10.10));
base::scoped_nsobject<NSUserActivity> currentActivity_;
NSCondition* handoffLock_;
BOOL updateReceived_;
base::Callback<bool()> shouldShutdown_;
@@ -104,7 +103,7 @@ typedef NS_ENUM(NSInteger, AVAuthorizationStatusMac) {
// CrAppControlProtocol:
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent;
- (NSUserActivity*)getCurrentActivity API_AVAILABLE(macosx(10.10));
- (NSUserActivity*)getCurrentActivity;
- (void)setCurrentActivity:(NSString*)type
withUserInfo:(NSDictionary*)userInfo
withWebpageURL:(NSURL*)webpageURL;

View File

@@ -69,15 +69,13 @@ inline void dispatch_sync_main(dispatch_block_t block) {
- (void)setCurrentActivity:(NSString*)type
withUserInfo:(NSDictionary*)userInfo
withWebpageURL:(NSURL*)webpageURL {
if (@available(macOS 10.10, *)) {
currentActivity_ = base::scoped_nsobject<NSUserActivity>(
[[NSUserActivity alloc] initWithActivityType:type]);
[currentActivity_ setUserInfo:userInfo];
[currentActivity_ setWebpageURL:webpageURL];
[currentActivity_ setDelegate:self];
[currentActivity_ becomeCurrent];
[currentActivity_ setNeedsSave:YES];
}
currentActivity_ = base::scoped_nsobject<NSUserActivity>(
[[NSUserActivity alloc] initWithActivityType:type]);
[currentActivity_ setUserInfo:userInfo];
[currentActivity_ setWebpageURL:webpageURL];
[currentActivity_ setDelegate:self];
[currentActivity_ becomeCurrent];
[currentActivity_ setNeedsSave:YES];
}
- (NSUserActivity*)getCurrentActivity {
@@ -103,8 +101,7 @@ inline void dispatch_sync_main(dispatch_block_t block) {
[handoffLock_ unlock];
}
- (void)userActivityWillSave:(NSUserActivity*)userActivity
API_AVAILABLE(macosx(10.10)) {
- (void)userActivityWillSave:(NSUserActivity*)userActivity {
__block BOOL shouldWait = NO;
dispatch_sync_main(^{
std::string activity_type(
@@ -132,8 +129,7 @@ inline void dispatch_sync_main(dispatch_block_t block) {
[userActivity setNeedsSave:YES];
}
- (void)userActivityWasContinued:(NSUserActivity*)userActivity
API_AVAILABLE(macosx(10.10)) {
- (void)userActivityWasContinued:(NSUserActivity*)userActivity {
dispatch_async(dispatch_get_main_queue(), ^{
std::string activity_type(
base::SysNSStringToUTF8(userActivity.activityType));

View File

@@ -103,7 +103,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
#else
(void (^)(NSArray* restorableObjects))
#endif
restorationHandler API_AVAILABLE(macosx(10.10)) {
restorationHandler {
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
std::unique_ptr<base::DictionaryValue> user_info =
atom::NSDictionaryToDictionaryValue(userActivity.userInfo);

View File

@@ -29,7 +29,7 @@ struct Product {
std::string formattedPrice;
// Downloadable Content Information
bool downloadable = false;
bool isDownloadable = false;
Product(const Product&);
Product();

View File

@@ -141,15 +141,13 @@
if (product.priceLocale != nil) {
productStruct.formattedPrice =
[[self formatPrice:product.price withLocal:product.priceLocale]
UTF8String];
[[self formatPrice:product.price
withLocal:product.priceLocale] UTF8String];
}
}
// Downloadable Content Information
if (product.downloadable == true) {
productStruct.downloadable = true;
}
productStruct.isDownloadable = [product downloadable];
return productStruct;
}

View File

@@ -7,18 +7,16 @@
#include "base/logging.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/media_capture_devices.h"
#include "content/public/common/media_stream_request.h"
namespace atom {
using content::BrowserThread;
using content::MediaStreamDevices;
namespace atom {
namespace {
// Finds a device in |devices| that has |device_id|, or NULL if not found.
const content::MediaStreamDevice* FindDeviceWithId(
const content::MediaStreamDevices& devices,
const blink::MediaStreamDevice* FindDeviceWithId(
const blink::MediaStreamDevices& devices,
const std::string& device_id) {
auto iter = devices.begin();
for (; iter != devices.end(); ++iter) {
@@ -29,11 +27,6 @@ const content::MediaStreamDevice* FindDeviceWithId(
return nullptr;
}
const MediaStreamDevices& EmptyDevices() {
static MediaStreamDevices* devices = new MediaStreamDevices;
return *devices;
}
} // namespace
MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() {
@@ -49,75 +42,75 @@ MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher()
MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher() {}
const MediaStreamDevices&
const blink::MediaStreamDevices&
MediaCaptureDevicesDispatcher::GetAudioCaptureDevices() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (is_device_enumeration_disabled_)
return EmptyDevices();
return test_audio_devices_;
return content::MediaCaptureDevices::GetInstance()->GetAudioCaptureDevices();
}
const MediaStreamDevices&
const blink::MediaStreamDevices&
MediaCaptureDevicesDispatcher::GetVideoCaptureDevices() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (is_device_enumeration_disabled_)
return EmptyDevices();
return test_video_devices_;
return content::MediaCaptureDevices::GetInstance()->GetVideoCaptureDevices();
}
void MediaCaptureDevicesDispatcher::GetDefaultDevices(
bool audio,
bool video,
content::MediaStreamDevices* devices) {
blink::MediaStreamDevices* devices) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(audio || video);
if (audio) {
const content::MediaStreamDevice* device = GetFirstAvailableAudioDevice();
const blink::MediaStreamDevice* device = GetFirstAvailableAudioDevice();
if (device)
devices->push_back(*device);
}
if (video) {
const content::MediaStreamDevice* device = GetFirstAvailableVideoDevice();
const blink::MediaStreamDevice* device = GetFirstAvailableVideoDevice();
if (device)
devices->push_back(*device);
}
}
const content::MediaStreamDevice*
const blink::MediaStreamDevice*
MediaCaptureDevicesDispatcher::GetRequestedAudioDevice(
const std::string& requested_audio_device_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
const content::MediaStreamDevices& audio_devices = GetAudioCaptureDevices();
const content::MediaStreamDevice* const device =
const blink::MediaStreamDevices& audio_devices = GetAudioCaptureDevices();
const blink::MediaStreamDevice* const device =
FindDeviceWithId(audio_devices, requested_audio_device_id);
return device;
}
const content::MediaStreamDevice*
const blink::MediaStreamDevice*
MediaCaptureDevicesDispatcher::GetFirstAvailableAudioDevice() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
const content::MediaStreamDevices& audio_devices = GetAudioCaptureDevices();
const blink::MediaStreamDevices& audio_devices = GetAudioCaptureDevices();
if (audio_devices.empty())
return nullptr;
return &(*audio_devices.begin());
}
const content::MediaStreamDevice*
const blink::MediaStreamDevice*
MediaCaptureDevicesDispatcher::GetRequestedVideoDevice(
const std::string& requested_video_device_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
const content::MediaStreamDevices& video_devices = GetVideoCaptureDevices();
const content::MediaStreamDevice* const device =
const blink::MediaStreamDevices& video_devices = GetVideoCaptureDevices();
const blink::MediaStreamDevice* const device =
FindDeviceWithId(video_devices, requested_video_device_id);
return device;
}
const content::MediaStreamDevice*
const blink::MediaStreamDevice*
MediaCaptureDevicesDispatcher::GetFirstAvailableVideoDevice() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
const content::MediaStreamDevices& video_devices = GetVideoCaptureDevices();
const blink::MediaStreamDevices& video_devices = GetVideoCaptureDevices();
if (video_devices.empty())
return nullptr;
return &(*video_devices.begin());
@@ -136,7 +129,7 @@ void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged(
int render_view_id,
int page_request_id,
const GURL& security_origin,
content::MediaStreamType stream_type,
blink::MediaStreamType stream_type,
content::MediaRequestState state) {}
void MediaCaptureDevicesDispatcher::OnCreatingAudioStream(int render_process_id,
@@ -146,7 +139,7 @@ void MediaCaptureDevicesDispatcher::OnSetCapturingLinkSecured(
int render_process_id,
int render_frame_id,
int page_request_id,
content::MediaStreamType stream_type,
blink::MediaStreamType stream_type,
bool is_secure) {}
} // namespace atom

View File

@@ -9,7 +9,8 @@
#include "base/memory/singleton.h"
#include "content/public/browser/media_observer.h"
#include "content/public/common/media_stream_request.h"
#include "content/public/browser/media_stream_request.h"
#include "third_party/blink/public/common/mediastream/media_stream_request.h"
namespace atom {
@@ -20,8 +21,8 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
static MediaCaptureDevicesDispatcher* GetInstance();
// Methods for observers. Called on UI thread.
const content::MediaStreamDevices& GetAudioCaptureDevices();
const content::MediaStreamDevices& GetVideoCaptureDevices();
const blink::MediaStreamDevices& GetAudioCaptureDevices();
const blink::MediaStreamDevices& GetVideoCaptureDevices();
// Helper to get the default devices which can be used by the media request.
// Uses the first available devices if the default devices are not available.
@@ -30,19 +31,19 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
// Called on the UI thread.
void GetDefaultDevices(bool audio,
bool video,
content::MediaStreamDevices* devices);
blink::MediaStreamDevices* devices);
// Helpers for picking particular requested devices, identified by raw id.
// If the device requested is not available it will return NULL.
const content::MediaStreamDevice* GetRequestedAudioDevice(
const blink::MediaStreamDevice* GetRequestedAudioDevice(
const std::string& requested_audio_device_id);
const content::MediaStreamDevice* GetRequestedVideoDevice(
const blink::MediaStreamDevice* GetRequestedVideoDevice(
const std::string& requested_video_device_id);
// Returns the first available audio or video device, or NULL if no devices
// are available.
const content::MediaStreamDevice* GetFirstAvailableAudioDevice();
const content::MediaStreamDevice* GetFirstAvailableVideoDevice();
const blink::MediaStreamDevice* GetFirstAvailableAudioDevice();
const blink::MediaStreamDevice* GetFirstAvailableVideoDevice();
// Unittests that do not require actual device enumeration should call this
// API on the singleton. It is safe to call this multiple times on the
@@ -56,14 +57,14 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
int render_view_id,
int page_request_id,
const GURL& security_origin,
content::MediaStreamType stream_type,
blink::MediaStreamType stream_type,
content::MediaRequestState state) override;
void OnCreatingAudioStream(int render_process_id,
int render_view_id) override;
void OnSetCapturingLinkSecured(int render_process_id,
int render_frame_id,
int page_request_id,
content::MediaStreamType stream_type,
blink::MediaStreamType stream_type,
bool is_secure) override;
private:
@@ -72,6 +73,12 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
MediaCaptureDevicesDispatcher();
~MediaCaptureDevicesDispatcher() override;
// Only for testing, a list of cached audio capture devices.
blink::MediaStreamDevices test_audio_devices_;
// Only for testing, a list of cached video capture devices.
blink::MediaStreamDevices test_video_devices_;
// Flag used by unittests to disable device enumeration.
bool is_device_enumeration_disabled_;

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