Compare commits

...

311 Commits

Author SHA1 Message Date
Electron Bot
b9aed81df3 Bump v2.0.16 2018-12-18 14:15:34 -08:00
Michelle Tilley
5615913f4f chore: add additional logging for release upload failures (#16127) 2018-12-18 11:49:40 -08:00
Michelle Tilley
dd0ae203b7 Revert "Bump v2.0.16"
This reverts commit ed7534097c.
2018-12-18 11:17:58 -08:00
Electron Bot
ed7534097c Bump v2.0.16 2018-12-18 10:34:47 -08:00
Michelle Tilley
e292d6f94a Revert "Bump v2.0.16"
This reverts commit aea4751aa3.
2018-12-18 10:27:10 -08:00
Electron Bot
aea4751aa3 Bump v2.0.16 2018-12-18 09:56:07 -08:00
Roller Bot
d643b3557b chore: bump libcc submodule to daf9bdcdfdfd6bad258b5e1e48b2e17d06c1a987 (#16112) 2018-12-17 22:28:55 -06:00
Electron Bot
4495f66310 Bump v2.0.15 2018-12-13 10:24:07 -08:00
Roller Bot
5de7f2abdb chore: bump libcc submodule (#16035) 2018-12-13 03:31:26 +05:30
Roller Bot
01c892dfc3 chore: bump libcc submodule to ebe1313308aa95c71f23b2725efd091b8ece05ff (#15946) 2018-12-11 16:12:41 +09:00
Cheng Zhao
abd3fee870 fix: allow 2 threads for CreateIoCompletionPort on single-core to prevent busy looping (#15975) (#16013)
* allow 2 threads for CreateIoCompletionPort on single-core

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

* CHECK that uv_loop_ has not been used before replacing its iocp
2018-12-11 16:11:11 +09:00
Hari Juturu
9313af3f3b fix: enable webview in sandbox renderer (#13435) (#13555)
* Enable webview in sandbox renderer (#13435)

* Enable webview in sandbox renderer
Security: Inherit embedder prefs onto webview

* cache lastwebprefs

* fix expect UT issue

* Fix test
2018-11-27 17:16:11 +09:00
trop[bot]
8ed07298cc fix: schedule a paint after browserview's background is set (#15796) 2018-11-21 14:25:49 -06:00
Electron Bot
126b468eb7 Bump v2.0.14 2018-11-19 11:04:43 -08:00
trop[bot]
0035a7b663 fix: NSWindow crash happening on macos 10.9 (#15729) 2018-11-15 07:58:03 -08:00
trop[bot]
74644e53e8 docs: add Size as an option for pageSize in docs for printToPDF (#15524) 2018-11-02 22:17:55 +11:00
trop[bot]
308ee50831 chore: publish to the latest tag correctly when releasing old versions (#15515) (#15528)
Manual backport of #15274 to <= 3-0-x
2018-11-01 07:42:41 -07:00
trop[bot]
4f26aab86f fix: explicitly set windowsHide to the old node default (#15513)
Notes: fix Electron not being visible when launching in development mode on node v11
2018-10-31 20:32:28 -07:00
Electron Bot
1ebd9761fb Bump v2.0.13 2018-10-31 16:12:36 -07:00
trop[bot]
67c7554b80 docs: add return type for subscribeNotification (#15501) 2018-10-31 09:48:25 -07:00
trop[bot]
d158cce9a3 doc: clarify menu item properties not available top-level (#15460) 2018-10-29 16:23:48 -07:00
trop[bot]
5a73ec2ec8 fix: honor dialog.showMessageBox()'s Icon argument on Linux (backport: 2-0-x) (#15341)
* Don't call gtk_widget_show_all() on popup dialog.

Fixes #15317.

Notes: Fixed incorrect display of some GtkMessageDialog icons.

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

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

* use gtk_dialog_set_default_response() for default

* fix: support icons on gtk+ messageboxes.
2018-10-23 12:00:50 -07:00
Michelle Tilley
a03da04578 fix: correct reversed logic in NativeWindowMac::SetEnabled (#15322)
Backport of #15257
2018-10-23 23:22:07 +11:00
trop[bot]
d45c29087b docs: we don't emit an event object for session-created (#15306) 2018-10-21 10:17:37 -07:00
trop[bot]
00200c707e chore: make macOS release builds higher priority to skip the queue (#15283)
Release builds should be run before branch builds on our limited macOS
infra.

Refs: https://docs.microsoft.com/en-us/rest/api/vsts/build/builds/queue?view=vsts-rest-4.1#queuepriority
2018-10-19 09:12:38 -07:00
trop[bot]
b228166900 fix: make release-artifact-cleanup executable (backport: 2-0-x) (#15270)
* fix: make release-artifact-cleanup executable

* fix misc issues in cleanup script
2018-10-18 20:27:45 -07:00
Electron Bot
d281859cf5 Bump v2.0.12 2018-10-18 17:04:22 -07:00
Samuel Attard
e00d217cfb Revert "build: enable PIE when compiling Linux builds, fix #14961. (#15148)"
This reverts commit 2f2761fa47.
2018-10-18 14:12:33 +11:00
Samuel Attard
00f40e84db Revert "chore: enable BIND_NOW when compiling Linux builds"
This reverts commit 9f1e674f30.
2018-10-18 14:12:27 +11:00
Samuel Attard
dde5b3abe6 Revert "Bump v2.0.12"
This reverts commit 97bffde34c.
2018-10-18 14:12:00 +11:00
Electron Bot
97bffde34c Bump v2.0.12 2018-10-17 19:33:51 -07:00
Samuel Attard
a6a1cc3bbb Revert "Bump v2.0.12"
This reverts commit 22e71497ec.
2018-10-18 13:27:04 +11:00
Electron Bot
22e71497ec Bump v2.0.12 2018-10-17 10:29:11 -07:00
Roller Bot
a32529b8fa chore: bump libcc submodule to ccdb085454b0a387ee96e0f81a7ca9a8ce07a710 (#15200) 2018-10-18 00:54:36 +11:00
Cheng Zhao
732f053acd Merge pull request #15207 from electron/window-open-warn-leak-2-0-x
chore: warn memory leak when using nativeWindowOpen with nodeIntegration (2-0-x)
2018-10-17 11:54:32 +09:00
Cheng Zhao
90fc709194 fix: print warning after DOM is created 2018-10-17 10:49:08 +09:00
Cheng Zhao
1d2b926962 chore: warn memory leak when using nativeWindowOpen with nodeIntegration 2018-10-17 10:47:45 +09:00
Cheng Zhao
fbc7b7f8ad fix: do not enable node integration in child window if not enabled (#15109) 2018-10-16 18:10:58 +09:00
Kevin Lynagh
4279f2f3f8 fix: simpleFullscreen window should be on top of other OS X menu bars. (#15182)
If an app has no menu bar (because `app.dock.hide()` has been called),
OS X will still render the menu bar of the previously-focused app.

This commit ensures simpleFullscreen windows will be drawn on top of
that menu bar by setting their level to NSPopUpMenuWindowLevel while
simpleFullscreen mode is active.

Ref: #11468
2018-10-16 11:42:13 +11:00
Shelley Vohr
b8eec43b31 fix: natively implement LoginItem functions (backport: 2-0-x) (#15139)
* fix: natively implement LoginItem functions

* equal => deepEqual
2018-10-15 12:55:09 -07:00
trop[bot]
ce30d6c11f fix: Memory > Profiles > Load in DevTools (#15154) 2018-10-14 15:15:47 -07:00
#DeleteGithub
9f1e674f30 chore: enable BIND_NOW when compiling Linux builds
We've hardened Linux builds by enabling PIE and RELRO,
and should continue to try hardening Linux builds by
enabling BIND_NOW. With both RELRO and BIND_NOW enabled,
we can stop all GOT overwrite attacks. The same hardening
option has been enabled in official Chrome/Chromium
builds since more than five years ago.

This helps to improve the security of a whole range of
applications built upon Electron, including sensetive ones
such as Signal-Desktop.

Signed-off-by: Tom Li <tomli@tomli.me>
2018-10-14 11:13:37 -07:00
#DeleteGithub
2f2761fa47 build: enable PIE when compiling Linux builds, fix #14961. (#15148)
PIE allows an application to utilize the full benefits of ASLR
to prevent itself from exploitations, but it was disabled for
all released versions of Electron (3.0 and prior).

Currently, PIE is already enabled since 9294fac but enabling it
for all released version is still an ongoing work (#14961). This
patch backports PIE to the 2.0.x branch, which is an especially
important branch, since security is an urgency for many existing
programs including Signal-Desktop. Enabling it can help protect
many high-risk users.

Signed-off-by: Tom Li <tomli@tomli.me>
2018-10-14 12:47:45 +11:00
Charles Kerr
411f2be579 Check dbus response for null before using. (#15088)
Fixes #14958.

Manual backport of #15030. Drops some the BindOnce improvements
due to compile issues with older version of Chromium.
2018-10-11 22:01:58 -07:00
Charles Kerr
28a160fc1f fix: SetSize() should honor minSize (#13994) (#15052)
Manual backport of #14931 to fix #13994.
2018-10-10 16:18:04 -05:00
Troy
2663d3e10d Backport of #14648 (#15025) 2018-10-08 20:18:02 -05:00
trop[bot]
e55d7d6f1e fix: support ASAR in fs.copyFile (#14952) 2018-10-04 09:23:07 +10:00
Cheng Zhao
092796f5f4 fix: use white background for non-OSR renderer by default (#14933) 2018-10-02 20:08:49 -07:00
Electron Bot
3f6d86c872 Bump v2.0.11 2018-10-01 09:47:39 -07:00
Samuel Attard
bdc9faa083 Revert "Bump v2.0.11"
This reverts commit 3e35f77da4.
2018-10-02 02:42:49 +10:00
Electron Bot
3e35f77da4 Bump v2.0.11 2018-10-01 08:38:40 -07:00
Roller Bot
464f144a2b chore: bump libcc submodule to e271f9ba29ff73167bbc4a7e125657caccb32960 (#14839) 2018-09-28 10:30:16 -07:00
trop[bot]
8f92396ed4 fix: enable key accelerator flags for Windows and Linux (backport: 2-0-x) (#14858)
* Fix Accelerator Flags for Windows and Linux

* Lint fix

* Lint whitespace
2018-09-28 10:01:09 -07:00
Shelley Vohr
4e41a79404 fix: get background color from GtkMenuBar#menubar (#14813) 2018-09-27 17:44:58 +10:00
trop[bot]
d3c153e85a docs: correct key code reqs for accel doc (#14825) 2018-09-27 12:49:58 +10:00
Shelley Vohr
503b488153 fix: inconsistent titleBarStyle on transparent fullscreen (#14792) 2018-09-25 09:58:32 -04:00
trop[bot]
005a65da79 docs: clarify allowable background colors for BrowserWindow transparency (backport: 2-0-x) (#14780)
* docs: clarify allowable colors for transparency

* fix alpha value specification
2018-09-24 09:39:53 -07:00
trop[bot]
36da7dcd5f docs: specify BrowserWindow features passable to window.open (#14701) 2018-09-20 16:56:11 +10:00
trop[bot]
0e5f734a1a chore: fix await in cleanup script (#14694) 2018-09-19 10:10:20 -07:00
John Kleinschmidt
3aeaf10e64 ci: Skip VSTS testing builds on older branches (#14668)
Also, don't send slack notifications for actual releases
2018-09-19 09:55:48 -07:00
Shelley Vohr
d70942190c fix: quit properly in simpleFullScreen mode (#14671) 2018-09-19 08:31:08 -07:00
Electron Bot
ac400e5cb9 Bump v2.0.10 2018-09-19 02:18:01 -07:00
Samuel Attard
333d5fb5d2 Revert "Bump v2.0.10"
This reverts commit f2c12ccbf5.
2018-09-19 19:10:43 +10:00
Electron Bot
f2c12ccbf5 Bump v2.0.10 2018-09-18 06:45:51 -07:00
trop[bot]
79af1ea6f1 chore: dont pass --stable through to bump-version.py (#14667)
I want to clean up this "stable" and "beta" code smell eventually but
for now this will unblock the 2.0.x releases.
2018-09-18 23:41:20 +10:00
Roller Bot
1ed7875b0b chore: bump libcc submodule to cbd04c0dccc7655cd42f02baee3a622d5170ac08 (#14654) 2018-09-18 17:37:00 +10:00
John Kleinschmidt
67a690e536 Merge pull request #14593 from electron/ignore-gn-debug-builds-2-0-x
ci: don't run gn debug build on older branches (2-0-x)
2018-09-13 09:24:02 -04:00
John Kleinschmidt
5f3bedd1e0 ci: don't run gn debug build on older branches (#14584)
* ci: don't run gn debug build on older branches

Older branches that build using gyp do not run both a debug and testing build.

* Actually skip the build if debug

(cherry picked from commit f924a16055)
2018-09-12 17:10:05 -04:00
Electron Bot
670a875792 Bump v2.0.9 2018-09-10 08:21:03 -07:00
trop[bot]
faf82245dc Fix documentation tyop (#14477) 2018-09-06 10:59:35 -07:00
Shelley Vohr
066eeb5b5f chore: add release-artifact-cleanup script (#14448) 2018-09-04 11:36:57 -07:00
trop[bot]
77ec86b894 docs: added session-created event documentation (backport: 2-0-x) (#14439)
* Added session-created event documentation

Emitted at 1c0ea0286e/lib/browser/api/session.js (L21)

* Removed trailing spaces
2018-09-04 09:26:58 +10:00
trop[bot]
bf82dc7896 fix: crash when tray is destroyed (#14366)
Release the view of status item before destroying it,
gives chance to perform cleanup on the view.
2018-08-28 23:14:08 -07:00
Charles Kerr
b4c5a30469 fix: dont parse arguments after a -- in the inspector (#14297) (#14334) 2018-08-27 14:39:38 -05:00
trop[bot]
7ed6e2b909 fix: don't crash on tray.setContextMenu(null) (#14330) 2018-08-27 12:51:09 -05:00
Wenjun Che
8edd18be90 fix: issue 10962, crash when open devtool (#13808)
* fix: crash when opening devtool (#10962)

* fix: fixed linting issues
2018-08-24 14:36:47 -07:00
Shelley Vohr
3bc9ae7f5b deps: update node for two backports (#14298) 2018-08-24 14:50:55 -05:00
Cheng Zhao
760c2327b4 fix: do not bubble up resize event from webview (#14272) 2018-08-23 15:42:46 +09:00
Cheng Zhao
fcb5069d24 Revert "fix: do not bubble up resize event from webview"
This reverts commit 221ab080a1.

It was an accidental push.
2018-08-23 09:31:10 +09:00
Cheng Zhao
221ab080a1 fix: do not bubble up resize event from webview 2018-08-23 09:29:08 +09:00
Electron Bot
addf069f26 Bump v2.0.8 2018-08-22 11:10:51 -07:00
Samuel Attard
80221e52d9 fix: inheritance of webPreferences sub properties 2018-08-22 12:20:04 -05:00
trop[bot]
3403b4a4de ci: add better logging around request failures for releasing (#14244) 2018-08-21 13:31:29 -07:00
trop[bot]
a1ac930f4d chore: retry for the meta dumper a few times (#14242) 2018-08-21 13:30:53 -07:00
Electron Bot
ed8396c6f5 Bump v2.0.8-nightly.20180820 2018-08-20 16:54:02 -07:00
Samuel Attard
a457d8823a Revert "Bump v2.0.8-nightly.20180820"
This reverts commit 2d44dcb8be.
2018-08-20 16:44:17 -07:00
Electron Bot
2d44dcb8be Bump v2.0.8-nightly.20180820 2018-08-20 13:33:19 -07:00
Samuel Attard
85da731867 fix: support installing nightlies on <= 2.0.x (#14224) 2018-08-20 11:18:45 -07:00
trop[bot]
3af5fdb831 chore: remove autorelease check logic (#14221) 2018-08-20 10:56:40 -07:00
trop[bot]
f1b197acbb chore: add option to return next version from prepare-release (backport: 2-0-x) (#14216)
* chore: add option to return next version from prepare-release

* shuffle logic
2018-08-20 08:35:28 -07:00
Electron Bot
d483c81887 Bump v2.0.8-nightly.20180819 2018-08-19 16:42:46 -07:00
Samuel Attard
3ef980ae2b chore: use metadumper service to create index.json file (#14158) (#14210) 2018-08-19 16:40:49 -07:00
Samuel Attard
36e68b46df Revert "Bump v2.0.8-nightly.20180819"
This reverts commit 148d0d8d29.
2018-08-19 15:38:56 -07:00
Samuel Attard
f611dfdb5c chore: stop auto releasing from windows CI 2018-08-19 15:38:47 -07:00
Electron Bot
148d0d8d29 Bump v2.0.8-nightly.20180819 2018-08-19 14:48:54 -07:00
trop[bot]
79a1382126 chore: match the bump commit exactly, reverts should not count (#14208) 2018-08-19 14:45:49 -07:00
Samuel Attard
b0d5ba1996 Revert "Bump v2.0.8-nightly.20180819"
This reverts commit 48a4b58cc1.
2018-08-19 14:24:11 -07:00
Samuel Attard
088dc70dae chore: disable tests on release builds, this is already done on master/3-0-x (#14206) 2018-08-19 14:22:57 -07:00
trop[bot]
ad686cca68 fix: #14160 (#14204) 2018-08-19 14:13:56 -07:00
Electron Bot
48a4b58cc1 Bump v2.0.8-nightly.20180819 2018-08-19 13:18:10 -07:00
Samuel Attard
c1ef824e4c chore: fix upload script for nightly support (#14203) 2018-08-19 13:03:15 -07:00
Samuel Attard
a2eb532720 Revert "Bump v2.0.8-nightly.20180819"
This reverts commit 0cb53ceb9d.
2018-08-19 12:57:00 -07:00
Electron Bot
0cb53ceb9d Bump v2.0.8-nightly.20180819 2018-08-19 12:33:38 -07:00
Samuel Attard
afe4e610ae chore: always target master for nightly releases (#14190) (#14202) 2018-08-19 12:28:21 -07:00
Shelley Vohr
74d90fbb33 chore: backport release script updates to 2-0-x (#14191)
* chore: alter release scripts to enable sudowoodo

* add example .env file

* chore: only prepare release if last commit not a bump (#14193)
2018-08-18 19:39:06 -07:00
trop[bot]
f3bd8f6133 docs: fix electron.d.ts typings (#14137) 2018-08-16 11:11:31 -07:00
John Kleinschmidt
863c511fbf Merge pull request #13988 from K900/update-lld
fix: update clang/lld version to fix #13972
2018-08-16 10:29:21 -07:00
trop[bot]
03d8689ded fix: add a hidden option to disable remote dereferencing (#14112) 2018-08-15 08:43:41 -07:00
John Kleinschmidt
ff2bc1d705 Merge pull request #14084 from electron/appveyor-rename-2-0-x
ci: rename appveyor-override to appveyor (2-0-x)
2018-08-14 09:56:17 -07:00
John Kleinschmidt
a1df8befde Rename appveyor-override to appveyor 2018-08-14 09:44:15 -07:00
trop[bot]
75909685f7 Fix flaky sandbox tests (#14055)
Windows apparently has issues running opening two windows at once which is causing flakiness on the mixed sandbox tests.
2018-08-13 15:14:21 -07:00
trop[bot]
2e0a015168 fix: make asarStatsToFsStats nherit from fs.stats (#14040) 2018-08-12 21:13:43 -07:00
K900
740b2797c5 vendor: update clang/lld version to fix #13972
This seems like some sort of a weird linker bug, so just update the
toolchain a bit.
2018-08-10 14:55:13 +03:00
Charles Kerr
5f372f7ecc Bump v2.0.7 2018-08-08 16:23:52 -05:00
Jeremy Apthorp
e4f4a1d9f9 chore: roll libcc (#13974)
Picks up electron/libchromiumcontent#637
2018-08-08 09:59:16 -07:00
John Kleinschmidt
bdc255fa9e Merge pull request #13966 from electron/2-0-x-backport-12809
fix: Prevent menu update while it's open (backport: 2-0-x)
2018-08-07 10:05:44 -04:00
John Kleinschmidt
e8e542b3e8 Merge pull request #13960 from electron/miniak/fix-promisify-2.0
fix: some APIs modified for ASAR support cannot be util.promisify'ed (backport: 2-0-x)
2018-08-07 10:04:56 -04:00
Zhuo Lu
dd89aa6c77 Memory safety 2018-08-06 23:50:00 -07:00
Zhuo Lu
79caff69f5 Fix code style 2018-08-06 23:50:00 -07:00
Zhuo Lu
67b10135b6 Update application menu on default runloop
Menu change should be prevented while the menu is open
2018-08-06 23:49:57 -07:00
Milan Burda
6a86831b7c fix: some APIs modified for ASAR support cannot be util.promisify'ed (#13845) 2018-08-07 00:20:54 +02:00
Birunthan Mohanathas
dffd17ab70 fix: Improve --enable-features/--disable-features handling (2.0.x) (#13921)
As it turns out, we can reinitialize the feature list directly after the
user JS script has been executed instead of much later. This allows
modifications to `--enable-features`/`--disable-features` to work with a
greater set of features.

This backports #13920 to `2-0-x`.
2018-08-03 11:09:53 +10:00
Birunthan Mohanathas
cf98934dd9 build: Bump libcc to latest (2.0.x) (#13919)
This picks up electron/libchromiumcontent#627.
2018-08-03 10:54:39 +10:00
trop[bot]
2fff138740 fix: handle SIGINT and SIGTERM from the Electron CLI helper (#13888)
Fixes #12840
2018-08-01 13:25:37 +10:00
Charles Kerr
82bc83c1de Bump v2.0.6 2018-07-31 18:49:35 -05:00
Birunthan Mohanathas
3a699741da build: Bump libcc to latest (2.0.x) (#13896)
This picks up electron/libchromiumcontent#624.
2018-07-31 15:45:39 -05:00
trop[bot]
237ad9a49d fix: util.promisify(setTimeout) (#13859) 2018-07-30 15:02:28 +10:00
trop[bot]
45158bdad5 docs: fix electron.d.ts typings (#13856) 2018-07-30 11:20:02 +10:00
Birunthan Mohanathas
cf4861b575 build: Bump libcc to latest (2.0.x) (#13825)
This picks up electron/libchromiumcontent#619.
2018-07-27 23:05:49 +10:00
Zeke Sikelianos
a76adba2b3 Merge pull request #13782 from electron/fix-enable-disable-features-2-0-x
fix: Use --enable-features and --disable-features (2.0.x)
2018-07-25 11:09:15 -07:00
Birunthan Mohanathas
6689dce5ba fix: Use --enable-features and --disable-features (2.0.x)
Unlike Chrome, we were not using the --enable-features and
--disable-features command-line arguments to initialize
`base::FeatureList`.
2018-07-24 17:12:39 +02:00
Cheng Zhao
9667b835ca fix: create WebContents for webview on request (#13714) 2018-07-20 10:45:57 -07:00
John Kleinschmidt
58295a3198 Merge pull request #13735 from electron/backport-13727-2-0-x
fix: use context counter as contextId (backport 2-0-x)
2018-07-20 10:22:00 -04:00
Cheng Zhao
b60125f782 fix: use webContentsId with contextId together
After after using `processId-contextCounter` as contextId, it may happen
that contexts in different WebContents sharing the same renderer process
get the same contextId. Using webContentsId as part of key in
ObjectsRegistry can fix this.
2018-07-20 10:53:16 +09:00
Cheng Zhao
2af6d9ced7 fix: use context counter as contextId (backport 2-0-x)
For sandboxed renderer it may not have a node::Environment in the context,
using a increasing counter as contextId works for all cases.
2018-07-19 11:35:49 -07:00
Charles Kerr
664c184fcb Bump v2.0.5 2018-07-13 13:55:07 -05:00
John Kleinschmidt
c125576d48 Merge pull request #13644 from electron/release-updates-2
chore: Updates for release process (2-0-x)
2018-07-12 10:31:19 -04:00
John Kleinschmidt
6030146b45 chore: Updates for release process (2-0-x)
* Fix Appveyor URL

* Update docs to reflect current process

Also added troubleshooting steps.

(cherry picked from commit 6b5ccec0c6)
2018-07-12 09:05:02 -04:00
Cheng Zhao
17297d85f8 Merge pull request #13625 from electron/proxy_resolver_oop
fix: use mojo v8 proxy resolver with a utility process
2018-07-12 21:59:12 +09:00
deepak1556
65bbf21c08 update libcc ref 2018-07-12 19:55:42 +09:00
deepak1556
00da6ab43b link mojo proxy resolver in component build 2018-07-12 19:55:42 +09:00
deepak1556
d6d2a46821 REVIEW: create proxy helper per browser context 2018-07-12 19:55:42 +09:00
deepak1556
423bdda1b1 REVIEW: remove pre early initialization of v8 2018-07-12 19:55:42 +09:00
deepak1556
849aeced8f build: use mojo v8 proxy resolver with a utility process 2018-07-12 19:55:42 +09:00
Cheng Zhao
05a7485880 Merge pull request #13604 from electron/fix-remote-2-0-x
fix: guard against double-freeing remote references (2-0-x)
2018-07-12 11:09:38 +09:00
Cheng Zhao
3db1b5a49a fix double-freeing remote references
After the page does navigations, garbage collection can still happen in
the old context. This commit changes to store references to remote objects
by _pages_, instead of by _WebContents_.
2018-07-12 10:45:00 +09:00
Cheng Zhao
1c272503c3 add API to return an unique ID for page 2018-07-12 10:45:00 +09:00
Cheng Zhao
1ebb8975a8 fix assertion caused by PrefServiceFactory::Create 2018-07-12 10:45:00 +09:00
John Kleinschmidt
fcf4c9cef1 build: Updates to the release process (2-0-x) (#13615)
* Update to run new AppVeyor jobs

AppVeyor builds got split into two jobs, `electron-x64` and `electron-ia32`

(cherry picked from commit 90339b7260)

* Move github release checking to node.js

Our upload script was relying on an old python script to find the GitHub release for uploading.

(cherry picked from commit 2040095b96)
2018-07-11 09:08:09 -05:00
John Kleinschmidt
3e5349bf39 Use Visual Studio 2015 for 2-0-x (#13607) 2018-07-10 09:40:22 -05:00
John Kleinschmidt
66988adb0e Bump v2.0.4 2018-07-03 14:39:36 -04:00
John Kleinschmidt
91be3f343f Merge pull request #13545 from electron/fix-core-bluetooth-linking
Fix crash on startup on macOS 10.9 due to linking with CoreBluetooth
2018-07-03 09:47:35 -04:00
Cheng Zhao
475006c10d fix: weak load CoreBluetooth when building with 10.10 SDK
The CoreBluetooth framework does not exist on OS X 10.9.
2018-07-03 16:37:07 +09:00
John Kleinschmidt
d71a7d89bb Merge pull request #13538 from electron/dwm-backport
fix: Disable chromium's redraw locking on Windows when DWM is disabled (#12501)
2018-07-02 16:10:22 -04:00
John Kleinschmidt
abcba2b509 Merge pull request #13516 from trop-bot/2-0-x-bp-fix--tray-setcontextmenu-crash-1530308984992
Backport (2-0-x) - fix: tray setContextMenu crash
2018-07-02 14:12:51 -04:00
John Kleinschmidt
d06c20f836 Merge branch 'trop-bot-2-0-x-bp-fix--tray-setcontextmenu-crash-1530308984992' into 2-0-x 2018-07-02 14:10:14 -04:00
John Kleinschmidt
3ab99663eb Merge branch '2-0-x-bp-fix--tray-setcontextmenu-crash-1530308984992' of git://github.com/trop-bot/electron into trop-bot-2-0-x-bp-fix--tray-setcontextmenu-crash-1530308984992 2018-07-02 14:08:34 -04:00
trop[bot]
a253323ea1 Do not capture cookies and credentials (#13537) 2018-07-03 02:03:48 +10:00
Heilig Benedek
4abe5a2963 Disable chromium's redraw locking on Windows when DWM is disabled (#12501)
* disable redraw locking on windows

* update libcc ref

(cherry picked from commit a14ebc80d2)
2018-07-02 08:54:37 -07:00
Maxine Whitely
aada5fb167 fix: tray setContextMenu crash
Co-authored-by: Zhuo Lu <sethlu@mintkit.net>
Co-authored-by: Kristine Zhang <kzhang@slack-corp.com>
2018-06-29 21:49:51 +00:00
Robo
4efed0f5ed fix: Revert "remove MarkHghMemoryUsage api" (#13421)
* fix: Revert "remove MarkHghMemoryUsage api"

This reverts commit 0de85fd49f.

* update native_mate ref
2018-06-26 10:44:59 -07:00
John Kleinschmidt
475a1e30d9 Add release build to VSTS 2018-06-21 09:33:06 -04:00
John Kleinschmidt
4aedc2c21a Bump v2.0.3 2018-06-21 09:25:33 -04:00
John Kleinschmidt
71668858db Merge pull request #13345 from electron/miniak/fix-libcc-2-0-x
fix: patches/086-backport-f0c82253.patch in libcc
2018-06-21 09:13:25 -04:00
Milan Burda
2573d52860 Bump libcc 2018-06-21 09:29:14 +02:00
John Kleinschmidt
989c2605b3 Merge pull request #13305 from electron/2-0-x_update-libcc-subreference
update submodule reference for libchromiumcontent
2018-06-20 09:36:17 -04:00
John Kleinschmidt
afcfd473d0 Merge pull request #13330 from trop-bot/2-0-x-bp-fix--pass-down-the-bool-value-of-enableautosize-to-setsize-1529484352071
Backport (2-0-x) - fix: pass down the bool value of enableAutoSize to setSize
2018-06-20 09:24:28 -04:00
Justin Guze
1499bafe59 creating new bool for autosize 2018-06-20 08:45:58 +00:00
Justin Guze
419fae76b4 fix: pass the boolean value of enableAutoSize to setSize
The webContents setSize API takes in an optional enableAutoSize boolean.
Looking in the code, if that property is set, regardless if you pass in
true or false, it will always set it to true. This change passes the
appropriate boolean value down properly.
2018-06-20 08:45:58 +00:00
trop[bot]
c7b85a104a Mark browser window affinity as experimental (#13295) 2018-06-20 17:19:46 +10:00
trop[bot]
c6ea424858 Disable node options in node config (#13324) 2018-06-20 17:06:29 +10:00
trop[bot]
ba23c0d600 set mac protocol to none (#13325) 2018-06-19 22:39:07 -07:00
Charles Kerr
d4e716477e update submodule referefence for libchromiumcontent 2018-06-19 14:43:57 -05:00
Jeremy Apthorp
34dbe5f176 Enable WebFrame method forwarding in sandboxed renderers (#12538) (#13076)
* Enable WebFrame method forwarding in sandboxed renderers

Fixes #9073

* Non-change to kick CI
2018-06-19 09:36:14 +10:00
Milan Burda
a09fa53d80 Add FILE_DIALOG_TREAT_PACKAGE_APP_AS_DIRECTORY to web open file dialog (#13220) (#13277) 2018-06-18 10:34:21 -05:00
Milan Burda
c140c84b32 Backport "Allow lookup of videodecoder service to fix HW video decoding on macOS 10.13" (#13275)
https://chromium-review.googlesource.com/677290
2018-06-18 21:35:37 +10:00
Charles Kerr
55ab1d7370 update submodule referefence for node (#13260) 2018-06-17 14:52:25 -07:00
trop[bot]
cfa247967f fix: tray title not inverting when highlighted (#13262) 2018-06-16 11:59:46 -05:00
John Kleinschmidt
311f7ac6bb Bump v2.0.2 2018-05-22 14:52:16 -04:00
trop[bot]
52a44facfd update locale documentation (#13027) 2018-05-21 15:07:46 -05:00
trop[bot]
5acb7a0226 Backport (2-0-x) - docs: Document missing quit events during shutdown (#13026)
* docs: Document missing events during shutdown

* docs: Better language
2018-05-21 12:52:18 -07:00
trop[bot]
afcf94a85c Add a tag to libchromiumcontent when a release is created. (#13025) 2018-05-21 13:35:56 -05:00
John Kleinschmidt
c42b468966 Merge pull request #13022 from trop-bot/2-0-x-bp-fix--menu.setapplicationmenu(null)-crash-on-linux-1526913387556
Backport (2-0-x) - fix: Menu.setApplicationMenu(null) crash on Linux
2018-05-21 11:06:36 -04:00
John Kleinschmidt
e0257acdf5 Merge pull request #13009 from ajmacd/ajm-libcc
Bump libcc ref to pick up patch file extension correction.
2018-05-21 11:05:34 -04:00
Jeremy Apthorp
b555434aa0 fix: Menu.setApplicationMenu(null) crash on Linux 2018-05-21 14:36:33 +00:00
trop[bot]
9574a4f472 Only expand maximum size constraint if there was a constraint originally (#13014) 2018-05-20 19:45:51 -07:00
Andrew MacDonald
2f167ce3d1 Bump libcc ref to pick up patch file extension correction. 2018-05-19 01:01:05 -07:00
John Kleinschmidt
8655d5e9ae Bump v2.0.1 2018-05-16 13:30:26 -04:00
John Kleinschmidt
2e06e0eccd Merge pull request #12964 from trop-bot/2-0-x-bp-fix--support-multiple-inherited-ubuntu-session-for-indicators-1526485540005
Backport (2-0-x) - fix: support multiple inherited ubuntu session for indicators
2018-05-16 12:14:46 -04:00
John Kleinschmidt
773f08ca43 Merge pull request #12963 from trop-bot/2-0-x-bp-fix-empty-description-when-only-one-extension-is-given-(getfiletypesfromaccepttype)-1526480331702
Backport (2-0-x) - Fix empty description when only one extension is given (GetFileTypesFromAcceptType)
2018-05-16 11:46:51 -04:00
Didier Roche
13850b9dff Fix linting error
Thx @MarshallOfSound
2018-05-16 15:45:46 +00:00
Didier Roche
1c57c76496 fix: more scalable code by factorizing appindicator support
- introduce a currentPlatformSupportsAppIndicator() function determining
  if app indicators are supported here.
- handle undefined process.env.XDG_CURRENT_DESKTOP
- added some comments to ensure that the intents are clear
Thanks MarshallOfSound
2018-05-16 15:45:46 +00:00
Didier Roche
e459b38c5d Support multiple inherited ubuntu session for indicators
Multiple sessions inherits the "ubuntu" base settings properties in ubuntu.
One of the most popular one is communitheme: the next ubuntu default theme
has its dedicated session, with thus duplicated indicators for dropbox.
Rather than a string comparison for ubuntu, only match a substring then.
XDG_CURRENT_DESKTOP can be of form: "communitheme:ubuntu:GNOME",
"ubuntu:GNOME", …
Fixes: #12843.
2018-05-16 15:45:46 +00:00
John Kleinschmidt
9796513b83 Merge pull request #12923 from electron/fix-12875-2-0-x
Allow frameless transparent windows to be sized smaller than 64x64 on Windows
2018-05-16 11:42:35 -04:00
Milan Burda
d3e5f430c7 Fix empty description when only one extension is given 2018-05-16 14:18:57 +00:00
John Kleinschmidt
df22eccfc1 Merge pull request #12946 from trop-bot/2-0-x-bp-make-security-warnings-tests-more-robust-1526401028749
Backport (2-0-x) - Make security-warnings tests more robust
2018-05-15 13:12:10 -04:00
Cheng Zhao
214c352f71 make security-warnings tests more robust 2018-05-15 16:17:14 +00:00
John Kleinschmidt
0070637b5a Fix typescript generation error (#12940) 2018-05-15 11:13:35 -05:00
Milan Burda
72b944f862 Fix contents.setSize(options) documentation in web-contents.md 2018-05-15 11:37:45 +02:00
Heilig Benedek
2fbb371689 Lock electron-typescript-definitions at 1.3.2 2018-05-15 04:05:13 +02:00
Heilig Benedek
e2e70e9b1e Match chromium's workaround when setting size of unresizable windows 2018-05-14 21:57:34 +02:00
Charles Kerr
324b769751 update command-line backlist switches (2.0.x) (#12806)
* update command-line backlist switches

Do a better job of finding edge cases, e.g. network_switch_list.h

**NB: This can't be tropped** because the list is dependent on the libcc version

* update list
2018-05-14 11:03:37 -05:00
John Kleinschmidt
e1d54d55be Merge pull request #12856 from trop-bot/2-0-x-bp-fix--listeners-out-of-limit-warning-1525756284370
Backport (2-0-x) - fix: listeners out of limit warning
2018-05-08 10:49:17 -04:00
biuuu
1d54032ba4 fix: listeners out of limit warning
When the Chrome Extension has too many content scripts (above default
10 counts), there will be a warning: possible EventEmitter memory leak
detected. 11 listeners added.
2018-05-08 05:11:30 +00:00
Andrew MacDonald
c6e4de16de Update 2-0-x libcc ref for electron/libchromiumcontent/#533. (#12785) 2018-05-07 09:29:40 -07:00
trop[bot]
f39cc1cc46 docs: fix the type information in in-app-purchase (#12824)
Method returns Boolean, Manually confirmed the
correctness by running `npm run create-api-json`.
2018-05-04 14:50:33 -07:00
trop[bot]
6af89eb260 don't filter out invisible menu separators (#12831) 2018-05-04 11:26:21 -07:00
trop[bot]
d33b71cc2d Backport (2-0-x) - show file filter name for accessory view of file dialog (#12779)
* Show file filter name for accessory view of file dialog

- Respect filters option of dialog.showOpenDialog() and
  dialog.showSaveDialog(). (#10335)
- Show "All Files" for <input> apart from "accept" attribute. (#11456)

* Fix memory leaks in file_dialog_mac.mm
2018-05-02 09:28:16 -05:00
trop[bot]
d0bbf3fb3c Fix context menu for sandbox devtools (#12731) 2018-05-01 17:53:58 -05:00
trop[bot]
289db66fee fix flaky security-warnings test (#12776) 2018-05-01 17:52:03 -05:00
John Kleinschmidt
6b90807cb8 Bump v2.0.0 2018-05-01 16:00:36 -04:00
John Kleinschmidt
cf4f078aca Merge pull request #12768 from electron/support-policy-2-0-x
Manually backport Support Policy docs from master
2018-05-01 15:55:03 -04:00
Charles Kerr
4eedd1455d Manually backport Support Policy docs from master 2018-05-01 14:49:08 -05:00
trop[bot]
9c167b63f2 Backport (2-0-x) - Add sccache option to bootstrap (#12753)
* Add sccache option to bootstrap

Couldn't see a CC wrapper style option for gyp so we inject the sccache commands directly into the generated ninja files.

* Use CC_wrapper

* Update toolchain.gypi

* s/sccache/cc_wrapper
2018-05-01 01:31:37 +10:00
John Kleinschmidt
d18ab0ca08 Bump v2.0.0-beta.8 2018-04-26 10:56:46 -04:00
trop[bot]
724cbc967c revert to more graceful template structure check (#12703) 2018-04-24 14:17:26 -04:00
trop[bot]
b9d589439f Backport (2-0-x) - Fix transparency (#12683)
* Fix transparent window capture. Transparency is preserved and not converted to black pixels anymore

* Add test to make sure aplha channel exists in captured image
2018-04-23 01:16:18 +10:00
trop[bot]
f37bc4a9d4 Backport (2-0-x) - Correct the default of allowRunningInsecureContent as per docs (#12629)
* Correct the default of allowRunningInsecureContent as per docs

* fix linting

* Update calls to match native_mate API change
2018-04-18 05:53:32 -07:00
Alexey Kuzmin
597c8964f6 Preload doesn't load in sandboxed render if preload path contains special chars (#12037) (#12643)
* Adding missing headers

* adding ut

* Removing the file path exists check

* fixing test

* exposing window.require in UT

(cherry picked from commit 2f4fd3324b)
2018-04-17 11:00:07 -05:00
trop[bot]
652f83fc88 Backport (2-0-x) - Fix event leak on reuse of touchbar item (#12624)
* fix event leak on reuse of touchbar item

* Clean up child touch bar item event listeners and escape item listeners
2018-04-15 11:26:56 -05:00
trop[bot]
d432038aab Use CircleCI for Mac builds (#12573) 2018-04-09 19:45:35 -05:00
trop[bot]
5d8f36c53c Check for devtools in BrowserWindow.getFocusedWindow() (#12554) 2018-04-06 12:45:11 -04:00
trop[bot]
85dfdd6665 Expose IsOffScreen method always to JS. (#12531) 2018-04-04 13:25:28 -05:00
electron
de428ebec0 Bump v2.0.0-beta.7 2018-04-03 12:54:17 -07:00
John Kleinschmidt
c6c49b9e4b Add native arm/arm64 mksnapshot for 2-0-x (#12524)
* Add logic to bundle native mksnapshot for arm/arm64

(cherry picked from commit 79eff95a39)

* Update to latest libchromiumcontent
2018-04-03 14:24:38 -05:00
John Kleinschmidt
98495fabfb Fix pushRelease for autorelease (#12523) 2018-04-03 14:14:25 -05:00
trop[bot]
06c33c7e56 WebFrame.setVisualZoomLevelLimits sets user-agent scale constraints (#12510)
Fixes #11216.
2018-04-03 07:50:37 -05:00
trop[bot]
33aad6ae11 Handle in-app-purchase less fatally on non-Darwin (#12512)
Fixes #12471

Right now it throws a new error when the file is even require()d, but this isn't ideal as there are cases where everything is mass-required, such as Spectron.

Instead, we should throw an error on non-Darwin environments only when the IAP methods are invoked.
2018-04-02 19:23:28 -05:00
Charles Kerr
6c00b37dd1 update libcc submodule reference to electron-2-0-x (#12448)
* update libcc submodule reference to electron-2-0-x

* remove MarkHighMemoryUsage api
2018-04-02 19:12:55 -05:00
trop[bot]
d209e59c30 re-enable null check against menu item accelerators (#12455) 2018-03-28 16:45:34 -05:00
trop[bot]
14f8a2a0e8 Backport (2-0-x) - update doc for setProgressBar (#12454)
* update doc for setProgressBar

The linter was unable to get `paused` as a possible value for `mode`

* update doc for setProgressBar

Addressing PR feedback
2018-03-28 11:35:40 +11:00
John Kleinschmidt
65e1252da0 Bump v2.0.0-beta.6 2018-03-27 16:10:49 -04:00
trop[bot]
2903d7608c Backport (2-0-x) - Fix nil tray title crash (#12356)
* Add check for title_ being nil

* remove print stub
2018-03-23 13:05:59 -05:00
John Kleinschmidt
0bc72961ab Merge pull request #12412 from electron/autorelease-fixes
Fixes for autorelease
2018-03-22 16:08:14 -04:00
John Kleinschmidt
b55a24c025 Fixes for autorelease
1. Allow passing in of branch
2. Validate release before trying to run release
3. Fix upload-index-json.py to allow use of release build.
2018-03-22 11:48:41 -04:00
trop[bot]
51bca764f7 Do not block main process for async dialog (#12407) 2018-03-22 08:46:15 -05:00
Shelley Vohr
35976a0a07 fix tray highlight in darkmode (#12398) 2018-03-22 13:59:50 +11:00
trop[bot]
283ab23524 Use the appname as the tray icon's default tooltip (#12393)
This makes an upstream DCHECK happy in AppIndicatorIcon::SetToolTip.
Empty tooltip strings are discouraged, as discussed in commit log
b6c510aa543193337041517c2d70113840189b06.

Fixes #12386.
2018-03-21 16:02:48 -04:00
John Kleinschmidt
2343f7c287 Bump v2.0.0-beta.5 2018-03-20 15:04:20 -04:00
Birunthan Mohanathas
8991ad31d8 Backport (2-0-x) - Update draggable regions when changing BrowserView (#12370)
* Store InspectableWebContents instead of InspectableWebContentsView in NativeBrowserView

* Rename system_drag_exclude_areas => drag_exclude_rects

* Use NSView convertRect:toView: for BrowserView DragRegionView positioning

* Make BrowserView DragRegionViews children of the WebContents view

Previously they were children of the `InspectableWebContentsView` view,
which caused this assertion to fail:

f993888424/brightray/browser/mac/bry_inspectable_web_contents_view.mm (L162)

* Update draggable regions when changing BrowserView

Fixes #12150.
2018-03-20 13:03:45 -05:00
trop[bot]
fae6167308 Backport (2-0-x) - Remove the race condition between new process creation and context release (#12361)
* Remove the race condition between new process creation and old process releasing remote context

Previously there was a race condition where the getId() method would return the new context ID even
though the release was for the old context.  This changes it to send the "initial" context ID with
the release message to ensure there is no race.

* fetch context ID from remote in sandbox mode
2018-03-20 18:11:39 +11:00
John Kleinschmidt
bd25a5f453 Merge pull request #12353 from trop-bot/2-0-x-bp-update-ci-to-use-node.js-8-1521472101213
Backport (2-0-x) - Update CI to use Node.js 8
2018-03-19 13:03:25 -04:00
John Kleinschmidt
c80021924e Update CI to use Node 8 2018-03-19 15:08:27 +00:00
trop[bot]
0cc4584352 Backport (2-0-x) - Check menu.popup options are an object (#12330)
* check menu.popup options are an object

* Add a spec for menu.popup options check

* remove stray .only
2018-03-17 19:46:48 +09:00
trop[bot]
706f0c436d Backport (2-0-x) - Better GTK+ Menu color support (#12331)
* Better GTK+ Menu color support

 * Fix 'invisible menu' issue (#12275)

 * Now updates menu text color when focus changes!

 * Better caching of colors when system theme changes

 * Removed all GTK+ deprecation warnings from menubar

* Don't highlight menu text on mouseover in GTK+

* Fix textColor declaration scope error

* Simplify FocusManager connection management a bit

* Make the linter happy

* Decouple MenuBar view recoloring from rebuilding

This way we don't need to rebuild the subview each time a recolor
is needed, e.g. when window focus changes or the system theme changes

* Don't iterate child views if we don't need to

* Move variable declaration outside of a loop

* More efficient iteration of MenuBar children

* Cleaner MenuButton bounds testing

* Fix oops

* Add a nullptr check in MenuBar::GetItemCount()

* Simplify iteration in MenuBar::RebuildChildren()

* Make the linter happy

* Fix signed-unsigned comparison

* Remove declarations of nonexistent methods

* Make SubmenuButton accessor const

* Cleaner accelerator iteration

* Windows fixes
2018-03-17 19:45:14 +09:00
Charles Kerr
663e1e059b net: change mime type deduction in Change URLRequestAsarJob (#12319) (#12333) 2018-03-17 19:28:37 +09:00
John Kleinschmidt
433aba34e6 Fix AttributeError: 'dict' object has no attribute 'required' (#12307)
(cherry picked from commit 71c3483f55)
2018-03-16 10:23:22 +09:00
trop[bot]
bd33e7198e 🔧 Fix security warning (#12313) 2018-03-16 07:22:36 +09:00
John Kleinschmidt
e1b19140e5 Bump v2.0.0-beta.4 2018-03-15 08:55:16 -04:00
trop[bot]
4632ade7ae Document BrowserView.{destroy,isDestroyed} (#12299) 2018-03-15 16:37:19 +09:00
trop[bot]
b32f332ce3 Backport (2-0-x) - Set appropriate defaults for webview options (#12292)
* Persist defaults to webPreferences object to JS land can read the inferred values instead of just user defined values

* Test inherited default propogation

* Refactor to remove coupling from fetching values and defaults

* Test description type

* Fix up tests
2018-03-15 15:06:40 +09:00
trop[bot]
6ff0d744ee Backport (2-0-x) - Fix require on network share path (#12287)
* first pass at server/network require fix

* refactor for clarity
2018-03-15 12:26:52 +09:00
John Kleinschmidt
37cbf5e4f1 Merge pull request #12280 from trop-bot/2-0-x-bp-switching-all-emails-to-@electronjs.org-domain-1521056557166
Backport (2-0-x) - Switching all emails to `@electronjs.org` domain
2018-03-14 16:33:10 -04:00
John Kleinschmidt
f48f486412 Merge pull request #12249 from electron/auto-release-updates
Auto release updates
2018-03-14 16:32:12 -04:00
Jacob Groundwater
018b676efd Change Contact Emails 2018-03-14 19:42:43 +00:00
John Kleinschmidt
c9e5d17950 Fix autogeneration of release notes 2018-03-14 09:22:25 -04:00
John Kleinschmidt
b1dd013425 Upgrade to node 8 2018-03-14 09:22:25 -04:00
John Kleinschmidt
7a91c5668f Skip prompting for version when running auto build 2018-03-14 09:22:24 -04:00
John Kleinschmidt
2f47b71211 Disable mips release builds
mips builds don't currently work for 2.0.0
2018-03-14 09:22:24 -04:00
Samuel Attard
e8a7cc576e fix remote setInterval flake (#12265) 2018-03-14 15:42:44 +09:00
Cheng Zhao
c00b1ac669 Update libcc to fix private API usage in mas build (#12264) 2018-03-14 15:06:42 +09:00
trop[bot]
c4bde8853f add missing report.length > 1 assertion (#12262) 2018-03-14 14:45:06 +09:00
trop[bot]
ab77b55a90 Backport (2-0-x) - Enable easy rebuild of native modules for unreleased electron (#12260)
* Enable easy rebuild of native modules for unreleased electron

Sometimes when developing locally (as I found this morning) you want to rebuild native modules
against an unreleased version of Electron (in this case local master).  This PR adds a simple
script to launch a local HTTP server that generates and hosts the required header and checksum
files to rebuild modules.  So far only tested on macOS but should work on all OS's

* Allow custom port

* clean up serve script

* make optionality more obvious
2018-03-14 13:34:54 +09:00
trop[bot]
05b0948dd0 Fixed passing of exception to the system crash handler (#12259) 2018-03-14 12:58:26 +09:00
trop[bot]
c9e2140bca Backport - fix: Ensure that getLastCrashReport() is actually the last crash report (#12255)
* 🔧 Sort crashes

* 🔧 Actually test the method

* 🔪 Cut typo

* 👷 Fancy test

* 👷 Tests, how do they work

* 🔧 Linter's gotta lint
2018-03-14 11:36:58 +09:00
Cheng Zhao
9843ce743e Merge pull request #12218 from electron/backport_double_preload_2_0_patch
browser: fix preload loading twice in 2.x
2018-03-14 10:27:42 +09:00
Robo
c846f677c9 browser: fix null pointer dereference with getWebPreferences api (#12245)
* add failing spec

* devtools webContents don't have associated webPreferences
2018-03-14 06:06:51 +09:00
John Kleinschmidt
643dd55e07 Merge pull request #12247 from trop-bot/2-0-x-bp-spec--isolate-sw-file-scheme-spec-storage-with-temp-partition-1520962317089
Backport - spec: isolate sw file scheme spec storage with temp partition
2018-03-13 14:33:07 -04:00
deepak1556
d2045b93b7 spec: isolate sw file scheme spec storage with temp partition 2018-03-13 17:32:04 +00:00
John Kleinschmidt
c22d53be5c Merge pull request #12239 from electron/update-libcc-2.x
update libcc ref for 2.x
2018-03-13 11:35:44 -04:00
trop[bot]
e9d28f9b14 Backport - Parent's visibility trumps inherited 'show' option (#12244)
* Parent's visibility trumps inherited 'show' option

* Add tests

* Remove unnecessary work when merging options

* Use idiomatic ES6 when merging options

* Apply further ES6 bikeshedding
2018-03-13 23:27:44 +09:00
deepak1556
7e53a4c72c update libcc ref for https://github.com/electron/libchromiumcontent/pull/476 2018-03-13 11:36:07 +09:00
trop-devel[bot]
515fbb6fc3 Backport - fix: Incorrect warnings in webviews (#12236)
* 🔧 Get correct webContents

* 🔧 Err, webPreferences
2018-03-13 11:34:32 +09:00
trop-devel[bot]
af4dfcf6fe Fix menubar toggle alt key detection on focus (#12235)
Reset alt keypress flag on window blur so switching window via
Alt+* window manager keybindings can't incedentally trigger
annoying menubar toggles
2018-03-13 11:25:55 +09:00
Charles Kerr
176abdbd80 Linux named notifications - 2-0-0 (#12229)
* Newer CI images (#12188)

* Bump electronbuilds/electron* versions

The linux-appname branch has been gathering dust for awhile.
Some of the versions in `master` are higher, and some of the
versions in `linux-appname` are higher to add libnotify.

This commit takes the higher of the two numbers in each case.

* Add libnotify to the Dockerfiles

* Linux named notifications (#12192)

* Set name & desktop-entry on Linux notifications

* DBusMock now honors verbose mode flag

* Disable DBus Notification tests on ia32

* Fix desktop-id notification edge case (#12216)

* Fix desktop-id notification edge case

* Extract-method platform_util::GetDesktopName()

This removes duplicated code from libnotify_notifications.cc
and atom/common/linux/application_info.cc.

* Check for empty case in GetDesktopName().

* Move GetDesktopName() to brightray::util

* Remove unnecessary changes in platform_util

* Add a brightray::platform_util namespace

* Bump CI
2018-03-13 11:13:34 +09:00
Charles Kerr
cda7b8ccc8 clean planned breaking changes for 3.0 (#12145) (#12222) 2018-03-12 16:09:58 +09:00
deepak1556
1a43ba50b6 move ipc from rvh to rfh 2018-03-12 14:30:42 +09:00
Cheng Zhao
1174fc0ab8 Skip client-certificate test for Linux (#12213) 2018-03-12 09:25:43 +09:00
John Kleinschmidt
3c5ba35d63 Bump v2.0.0-beta.3 2018-03-09 09:15:39 -05:00
Cheng Zhao
0f143fdba0 Merge pull request #12182 from electron/update-libcc-2-0-x
Update to latest libchromiumcontent for 2-0-x
2018-03-09 10:16:43 +09:00
John Kleinschmidt
99ae56b782 Add configurable mocha timeout
Adding an environment variable, MOCHA_TIMEOUT that can be set for slower CI platforms
2018-03-08 16:29:31 -05:00
Aleš Pergl
5471bc313f Use content origin in screen coordinates for calculating popup menu position (#12181) 2018-03-09 05:55:31 +09:00
John Kleinschmidt
b0077241ee Update to latest libchromiumcontent for 2-0-x 2018-03-08 15:12:29 -05:00
John Kleinschmidt
bb40bc4aca Add logic to support automatic releases (#12177) 2018-03-09 02:46:06 +09:00
John Kleinschmidt
76fb7ee87c Allow CI testing on arm64 hardware for 2-0-x (#12178)
* Allow CI building on arm64 hardware

* Use bundled freetype from Chromium

(cherry picked from commit 51f89048d6)
2018-03-09 02:21:55 +09:00
Alexey Kuzmin
bfc0e3f266 Merge pull request #12174 from electron/cp-2-0-x/12059
Merge pull request #12059 from electron/add-tabbedwindow-warning
2018-03-08 15:13:37 +01:00
Alexey Kuzmin
48e068997b More vibrancy fixes (#12157) (#12171)
* Only set title bar to transparent when vibrant with a custom titlebar
* Correctly set the transparent state of the GpuSwitcher so vibrancy works on reload
* Document case where using frame: false without custom titleBarStyle and vibrant

(cherry picked from commit 8c138e74be)
2018-03-08 08:51:36 -05:00
Alexey Kuzmin
f443974f3d Merge pull request #12043 from kaylieEB/fix-menu-item (#12170)
Fix context menu click callback

(cherry picked from commit cc608a3fb0)
2018-03-08 08:43:38 -05:00
shelley vohr
36505ae00e Merge pull request #12059 from electron/add-tabbedwindow-warning
add warning when addTabbedWindow is called on self

(cherry picked from commit dfa1dc43df)
2018-03-08 14:33:10 +01:00
Charles Kerr
b330ff8004 Removals come >=1 major release after deprecation. (#12164) 2018-03-08 11:18:36 +09:00
John Kleinschmidt
6cda9460ea Merge pull request #12161 from electron/backport-flake-fixes
Backport flake fixes (2-0-x)
2018-03-07 14:09:14 -05:00
Charles Kerr
2cac654974 Exit gracefully on linux (#12139)
* Fix timing issue in singleton fixture.

Singleton now sends the "we've started" message out only after it's
received a `'ready'` event from `app`. Previously it sent the message
out immediately, resulting in the parent test trying to manipulate it
before Singleton's event loop was fully bootstrapped.

* Check for graceful exits on Linux, too.

Rewrite the "exits gracefully on macos" spec to run on Linux too.

* Check for graceful exits everywhere.

* Tweak comment

* Better error logging in api-app-spec.js. (#12122)

In the 'exits gracefully' test for app.exit(exitCode),
print the relevant error information if the test fails.

* Run the exit-gracefully test on macOS and Linux.

Windows does not support sending signals, but Node.js offers some
emulation with process.kill(), and subprocess.kill(). Sending signal 0
can be used to test for the existence of a process. Sending SIGINT,
SIGTERM, and SIGKILL cause the unconditional termination of the target
process.

So, we'll need a different approach if we want to test this in win32.
2018-03-07 12:45:26 -05:00
shelley vohr
5a210f3d7a Merge pull request #12137 from electron/deprecate-getMenuBatHeight-2.0.x
Deprecate screen.getMenuBarHeight (2.0.x)
2018-03-06 07:38:53 -08:00
Alexey Kuzmin
4bb10c10e4 Merge pull request #12133 from electron/update-libcc
Update libchromiumcontent for 2-0-x
2018-03-06 12:51:58 +01:00
Shelley Vohr
c0076d9c52 remove screen.getMenuBarHeight spec 2018-03-05 21:00:55 -05:00
Shelley Vohr
95539c5b63 deprecate screen.getMenuBarHeight 2018-03-05 21:00:50 -05:00
John Kleinschmidt
4f8ca2f03a Update to latest libchromiumcontent
Update to get electron/libchromiumcontent#463 security fix
2018-03-05 15:12:02 -05:00
John Kleinschmidt
c9b92aebd3 Bump v2.0.0-beta.2 2018-03-05 13:14:27 -05:00
Cheng Zhao
6d3f60374e Merge pull request #12087 from electron/fix-dock-menu-gc-2-0-x
Fix crash when setting dock menu (2.0.x)
2018-03-02 08:39:03 +09:00
Cheng Zhao
8703298e9d spec: Test garbage collecting dock menu 2018-03-01 09:48:39 +09:00
Cheng Zhao
a42057aabd Fix dockMenu not being referenced in JavaScript 2018-03-01 09:48:39 +09:00
Cheng Zhao
bd2ab27c25 Merge pull request #12053 from electron/network-delegate-race
Fix network delegate race condition in 2-0-x
2018-02-27 08:47:20 +09:00
Cheng Zhao
1e6d7295cf Move the arguments instead of const referrencing
Safer and more efficient.
2018-02-26 09:34:49 -08:00
Cheng Zhao
1918da7c2e Remove the evil URLRequestContextGetter::network_delegate 2018-02-26 09:34:40 -08:00
Cheng Zhao
38345c7267 Fix race condition when getting network delegate 2018-02-26 09:34:32 -08:00
shelley vohr
c4742df1ee Merge pull request #12016 from electron/backport-release-updates
Backport fixes from running 2.0.0-beta.1 release to 2-0-x
2018-02-22 15:27:05 -05:00
John Kleinschmidt
5fc485043b Fixes from running 2.0.0-beta.1 release
This provides the following fixes:
1. Remove logic to delete release branch because that branch is no longer used.
2. Fix --validateRelease to not verifyShasums when release is in draft mode.

(cherry picked from commit fa6510a90c)
2018-02-22 11:26:30 -05:00
shelley vohr
967dcd3471 Merge pull request #12014 from electron/backport-version-fix
Fix deprecated API in tools/dump-version-info.js for 2-0-x
2018-02-22 09:28:52 -05:00
John Kleinschmidt
96f800552c Fix deprecated API in tools/dump-version-info.js 2018-02-22 09:00:37 -05:00
John Kleinschmidt
afcbb589b6 Bump v2.0.0-beta.1 2018-02-21 14:45:36 -05:00
John Kleinschmidt
4159103467 Use new release job 2018-02-21 14:41:18 -05:00
217 changed files with 5417 additions and 1832 deletions

View File

@@ -3,7 +3,7 @@ version: 2
jobs:
electron-linux-arm:
docker:
- image: electronbuilds/electron:0.0.4
- image: electronbuilds/electron:0.0.7
environment:
TARGET_ARCH: arm
resource_class: 2xlarge
@@ -58,6 +58,29 @@ jobs:
else
echo 'Skipping upload distribution because build is not for release'
fi
- run:
name: Optionally finish release
shell: /bin/sh
command: |
if [ "$ELECTRON_RELEASE" == "1" ] && [ "$AUTO_RELEASE" == "true" ]; then
echo 'Trying to finish release'
node script/release.js --validateRelease --automaticRelease
releaseExitCode=$?
if [ $releaseExitCode -eq 0 ]; then
echo 'Release is ready to go; releasing'
node script/release.js--automaticRelease
if [ $releaseExitCode -eq 0 ]; then
echo 'Release successful, now publishing to npm'
echo "//registry.npmjs.org/:_authToken=$ELECTRON_NPM_TOKEN" >> ~/.npmrc
npm run publish-to-npm
echo 'Release has been published to npm'
fi
else
echo 'Release is not complete, skipping publish for now'
fi
else
echo 'Skipping finishing release because build is not for release'
fi
- run:
name: Zip out directory
command: |
@@ -83,7 +106,7 @@ jobs:
docker run --rm --privileged multiarch/qemu-user-static:register --reset
docker run -it \
--mount type=bind,source=/tmp/workspace,target=/tmp/workspace \
--rm electronbuilds/electronarm7:0.0.4 > version.txt
--rm electronbuilds/electronarm7:0.0.5 > version.txt
cat version.txt
if grep -q `script/get-version.py` version.txt; then
echo "Versions match"
@@ -96,7 +119,7 @@ jobs:
fi
electron-linux-arm64:
docker:
- image: electronbuilds/electron:0.0.4
- image: electronbuilds/electron:0.0.7
environment:
TARGET_ARCH: arm64
resource_class: 2xlarge
@@ -151,6 +174,29 @@ jobs:
else
echo 'Skipping upload distribution because build is not for release'
fi
- run:
name: Optionally finish release
shell: /bin/sh
command: |
if [ "$ELECTRON_RELEASE" == "1" ] && [ "$AUTO_RELEASE" == "true" ]; then
echo 'Trying to finish release'
node script/release.js --validateRelease --automaticRelease
releaseExitCode=$?
if [ $releaseExitCode -eq 0 ]; then
echo 'Release is ready to go; releasing'
node script/release.js--automaticRelease
if [ $releaseExitCode -eq 0 ]; then
echo 'Release successful, now publishing to npm'
echo "//registry.npmjs.org/:_authToken=$ELECTRON_NPM_TOKEN" >> ~/.npmrc
npm run publish-to-npm
echo 'Release has been published to npm'
fi
else
echo 'Release is not complete, skipping publish for now'
fi
else
echo 'Skipping finishing release because build is not for release'
fi
- run:
name: Zip out directory
command: |
@@ -176,7 +222,7 @@ jobs:
docker run --rm --privileged multiarch/qemu-user-static:register --reset
docker run -it \
--mount type=bind,source=/tmp/workspace,target=/tmp/workspace \
--rm electronbuilds/electronarm64:0.0.5 > version.txt
--rm electronbuilds/electronarm64:0.0.6 > version.txt
cat version.txt
if grep -q `script/get-version.py` version.txt; then
echo "Versions match"
@@ -189,7 +235,7 @@ jobs:
fi
electron-linux-ia32:
docker:
- image: electronbuilds/electron:0.0.4
- image: electronbuilds/electron:0.0.7
environment:
TARGET_ARCH: ia32
DISPLAY: ':99.0'
@@ -248,6 +294,29 @@ jobs:
else
echo 'Skipping upload distribution because build is not for release'
fi
- run:
name: Optionally finish release
shell: /bin/sh
command: |
if [ "$ELECTRON_RELEASE" == "1" ] && [ "$AUTO_RELEASE" == "true" ]; then
echo 'Trying to finish release'
node script/release.js --validateRelease --automaticRelease
releaseExitCode=$?
if [ $releaseExitCode -eq 0 ]; then
echo 'Release is ready to go; releasing'
node script/release.js--automaticRelease
if [ $releaseExitCode -eq 0 ]; then
echo 'Release successful, now publishing to npm'
echo "//registry.npmjs.org/:_authToken=$ELECTRON_NPM_TOKEN" >> ~/.npmrc
npm run publish-to-npm
echo 'Release has been published to npm'
fi
else
echo 'Release is not complete, skipping publish for now'
fi
else
echo 'Skipping finishing release because build is not for release'
fi
- run:
name: Test
environment:
@@ -273,7 +342,7 @@ jobs:
fi
electron-linux-mips64el:
docker:
- image: electronbuilds/electron:0.0.4
- image: electronbuilds/electron:0.0.7
environment:
TARGET_ARCH: mips64el
resource_class: xlarge
@@ -328,10 +397,33 @@ jobs:
else
echo 'Skipping upload distribution because build is not for release'
fi
- run:
name: Optionally finish release
shell: /bin/sh
command: |
if [ "$ELECTRON_RELEASE" == "1" ] && [ "$AUTO_RELEASE" == "true" ]; then
echo 'Trying to finish release'
node script/release.js --validateRelease --automaticRelease
releaseExitCode=$?
if [ $releaseExitCode -eq 0 ]; then
echo 'Release is ready to go; releasing'
node script/release.js--automaticRelease
if [ $releaseExitCode -eq 0 ]; then
echo 'Release successful, now publishing to npm'
echo "//registry.npmjs.org/:_authToken=$ELECTRON_NPM_TOKEN" >> ~/.npmrc
npm run publish-to-npm
echo 'Release has been published to npm'
fi
else
echo 'Release is not complete, skipping publish for now'
fi
else
echo 'Skipping finishing release because build is not for release'
fi
electron-linux-x64:
docker:
- image: electronbuilds/electron:0.0.4
- image: electronbuilds/electron:0.0.7
environment:
TARGET_ARCH: x64
DISPLAY: ':99.0'
@@ -359,6 +451,224 @@ jobs:
script/bootstrap.py --target_arch=$TARGET_ARCH --dev
fi
- run: npm run lint
- run:
name: Build
command: |
if [ "$ELECTRON_RELEASE" == "1" ]; then
echo 'Building Electron for release'
script/build.py -c R
else
echo 'Building Electron for debug'
script/build.py -c D
fi
- run:
name: Create distribution
command: |
if [ "$ELECTRON_RELEASE" == "1" ]; then
echo 'Creating Electron release distribution'
script/create-dist.py
else
echo 'Skipping create distribution because build is not for release'
fi
- run:
name: Upload distribution
command: |
if [ "$ELECTRON_RELEASE" == "1" ] && [ "$TRIGGERED_BY_API" != "1" ]; then
echo 'Uploading Electron release distribution to github releases'
script/upload.py
elif [ "$ELECTRON_RELEASE" == "1" ] && [ "$TRIGGERED_BY_API" == "1" ]; then
echo 'Uploading Electron release distribution to s3'
script/upload.py --upload_to_s3
else
echo 'Skipping upload distribution because build is not for release'
fi
- run:
name: Optionally finish release
shell: /bin/sh
command: |
if [ "$ELECTRON_RELEASE" == "1" ] && [ "$AUTO_RELEASE" == "true" ]; then
echo 'Trying to finish release'
node script/release.js --validateRelease --automaticRelease
releaseExitCode=$?
if [ $releaseExitCode -eq 0 ]; then
echo 'Release is ready to go; releasing'
node script/release.js--automaticRelease
if [ $releaseExitCode -eq 0 ]; then
echo 'Release successful, now publishing to npm'
echo "//registry.npmjs.org/:_authToken=$ELECTRON_NPM_TOKEN" >> ~/.npmrc
npm run publish-to-npm
echo 'Release has been published to npm'
fi
else
echo 'Release is not complete, skipping publish for now'
fi
else
echo 'Skipping finishing release because build is not for release'
fi
- run:
name: Test
environment:
MOCHA_FILE: junit/test-results.xml
MOCHA_REPORTER: mocha-junit-reporter
command: |
if [ "$ELECTRON_RELEASE" != "1" ]; then
echo 'Testing Electron debug build'
mkdir junit
script/test.py --ci --rebuild_native_modules
else
echo 'Skipping testing on release build'
fi
- run:
name: Verify FFmpeg
command: |
if [ "$ELECTRON_RELEASE" != "1" ]; then
echo 'Verifying ffmpeg on debug build'
script/verify-ffmpeg.py
else
echo 'Skipping verify ffmpeg on release build'
fi
- run:
name: Generate Typescript Definitions
command: npm run create-typescript-definitions
- store_test_results:
path: junit
- store_artifacts:
path: junit
- store_artifacts:
path: out/electron.d.ts
- store_artifacts:
path: out/electron-api.json
electron-osx-x64:
environment:
TARGET_ARCH: x64
macos:
xcode: "9.0"
steps:
- checkout
- run:
name: Reclaim disk space
command: |
df -h
sudo rm -rf /Library/Developer/CoreSimulator
df -h
sysctl -n hw.ncpu
- run:
name: Check for release
command: |
if [ -n "${RUN_RELEASE_BUILD}" ]; then
echo 'release build triggered from api'
echo 'export ELECTRON_RELEASE=1 TRIGGERED_BY_API=1' >> $BASH_ENV
fi
- run:
name: Bootstrap
command: |
if [ "$ELECTRON_RELEASE" == "1" ]; then
echo 'Bootstrapping Electron for release build'
script/bootstrap.py --target_arch=$TARGET_ARCH
else
echo 'Bootstrapping Electron for debug build'
script/bootstrap.py --target_arch=$TARGET_ARCH --dev
fi
- run: npm run lint
- run:
name: Build
command: |
if [ "$ELECTRON_RELEASE" == "1" ]; then
echo 'Building Electron for release'
script/build.py -c R
else
echo 'Building Electron for debug'
script/build.py -c D
fi
- run:
name: Create distribution
command: |
if [ "$ELECTRON_RELEASE" == "1" ]; then
echo 'Creating Electron release distribution'
script/create-dist.py
else
echo 'Skipping create distribution because build is not for release'
fi
- run:
name: Upload distribution
command: |
if [ "$ELECTRON_RELEASE" == "1" ] && [ "$TRIGGERED_BY_API" != "1" ]; then
echo 'Uploading Electron release distribution to github releases'
script/upload.py
elif [ "$ELECTRON_RELEASE" == "1" ] && [ "$TRIGGERED_BY_API" == "1" ]; then
echo 'Uploading Electron release distribution to s3'
script/upload.py --upload_to_s3
else
echo 'Skipping upload distribution because build is not for release'
fi
- run:
name: Test
environment:
MOCHA_FILE: junit/test-results.xml
MOCHA_REPORTER: mocha-junit-reporter
command: |
if [ "$ELECTRON_RELEASE" != "1" ]; then
echo 'Testing Electron debug build'
mkdir junit
script/test.py --ci --rebuild_native_modules
else
echo 'Skipping testing on release build'
fi
- run:
name: Verify FFmpeg
command: |
if [ "$ELECTRON_RELEASE" != "1" ]; then
echo 'Verifying ffmpeg on debug build'
script/verify-ffmpeg.py
else
echo 'Skipping verify ffmpeg on release build'
fi
- run:
name: Generate Typescript Definitions
command: npm run create-typescript-definitions
- store_test_results:
path: junit
- store_artifacts:
path: junit
- store_artifacts:
path: out/electron.d.ts
- store_artifacts:
path: out/electron-api.json
electron-mas-x64:
environment:
TARGET_ARCH: x64
MAS_BUILD: 1
macos:
xcode: "9.0"
steps:
- checkout
- run:
name: Reclaim disk space
command: |
df -h
sudo rm -rf /Library/Developer/CoreSimulator
df -h
sysctl -n hw.ncpu
- run:
name: Check for release
command: |
if [ -n "${RUN_RELEASE_BUILD}" ]; then
echo 'release build triggered from api'
echo 'export ELECTRON_RELEASE=1 TRIGGERED_BY_API=1' >> $BASH_ENV
fi
- run:
name: Bootstrap
command: |
if [ "$ELECTRON_RELEASE" == "1" ]; then
echo 'Bootstrapping Electron for release build'
script/bootstrap.py --target_arch=$TARGET_ARCH
else
echo 'Bootstrapping Electron for debug build'
script/bootstrap.py --target_arch=$TARGET_ARCH --dev
fi
- run: npm run lint
- run:
name: Build
command: |
@@ -442,5 +752,11 @@ workflows:
jobs:
- electron-linux-ia32
build-x64:
jobs:
- electron-linux-x64
jobs:
- electron-linux-x64
build-osx-x64:
jobs:
- electron-osx-x64
build-mas-x64:
jobs:
- electron-mas-x64

7
.env.example Normal file
View File

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

2
.gitignore vendored
View File

@@ -43,6 +43,8 @@
/vendor/llvm/
/vendor/npm/
/vendor/python_26/
/vendor/native_mksnapshot
/vendor/LICENSES.chromium.html
node_modules/
SHASUMS256.txt
**/package-lock.json

View File

@@ -34,7 +34,7 @@ This Code of Conduct applies both within project spaces and in public spaces whe
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [electron@github.com](mailto:electron@github.com). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [coc@electronjs.org](mailto:coc@electronjs.org). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

View File

@@ -4,7 +4,7 @@
This project adheres to the Contributor Covenant [code of conduct](CODE_OF_CONDUCT.md).
By participating, you are expected to uphold this code. Please report unacceptable
behavior to electron@github.com.
behavior to coc@electronjs.org.
The following is a set of guidelines for contributing to Electron.
These are just guidelines, not rules, use your best judgment and feel free to

View File

@@ -7,7 +7,7 @@ ENV HOME=/home
RUN chmod a+rwx /home
# Install node.js
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get update && apt-get install -y nodejs
# Install wget used by crash reporter
@@ -16,6 +16,9 @@ RUN apt-get install -y wget
# Install python-dbusmock
RUN apt-get install -y python-dbusmock
# Install libnotify
RUN apt-get install -y libnotify-bin
# Add xvfb init script
ADD tools/xvfb-init.sh /etc/init.d/xvfb
RUN chmod a+x /etc/init.d/xvfb

View File

@@ -16,6 +16,7 @@ RUN apt-get update && apt-get install -y\
libgnome-keyring-dev \
libgtk-3-0 \
libgtk-3-dev \
libnotify-bin \
libnotify-dev \
libnss3 \
libnss3-dev \

63
Dockerfile.arm64v8 Normal file
View File

@@ -0,0 +1,63 @@
FROM arm64v8/ubuntu:16.04
RUN groupadd --gid 1000 builduser \
&& useradd --uid 1000 --gid builduser --shell /bin/bash --create-home builduser
RUN groupadd --gid 114 jenkins \
&& useradd --uid 110 --gid jenkins --shell /bin/bash --create-home jenkins
# Set up TEMP directory
ENV TEMP=/tmp
RUN chmod a+rwx /tmp
RUN apt-get update && apt-get install -y\
bison \
build-essential \
clang \
curl \
gperf \
git \
libasound2 \
libasound2-dev \
libcap-dev \
libcups2-dev \
libdbus-1-dev \
libgconf-2-4 \
libgconf2-dev \
libgnome-keyring-dev \
libgtk2.0-0 \
libgtk2.0-dev \
libgtk-3-0 \
libgtk-3-dev \
libnotify-dev \
libnss3 \
libnss3-dev \
libx11-xcb-dev \
libxss1 \
libxtst-dev \
libxtst6 \
lsb-release \
locales \
ninja \
python-setuptools \
python-pip \
python-dbusmock \
wget \
xvfb
# Install node.js
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get update && apt-get install -y nodejs
# Install crcmod
RUN pip install -U crcmod
ADD tools/xvfb-init.sh /etc/init.d/xvfb
RUN chmod a+x /etc/init.d/xvfb
# Install ninja in /usr/local
RUN cd /usr/local && git clone https://github.com/martine/ninja.git -b v1.5.3
RUN cd /usr/local/ninja && ./configure.py --bootstrap
USER builduser
WORKDIR /home/builduser

View File

@@ -16,6 +16,7 @@ RUN apt-get update && apt-get install -y\
libgnome-keyring-dev \
libgtk-3-0 \
libgtk-3-dev \
libnotify-bin \
libnotify-dev \
libnss3 \
libnss3-dev \
@@ -28,13 +29,8 @@ RUN apt-get update && apt-get install -y\
wget \
xvfb
# Install node.js
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
RUN apt-get update && apt-get install -y nodejs
ADD tools/xvfb-init.sh /etc/init.d/xvfb
RUN chmod a+x /etc/init.d/xvfb
ADD tools/run-electron.sh /run-electron.sh
RUN chmod a+x /run-electron.sh
CMD sh /run-electron.sh

View File

@@ -3,7 +3,7 @@ FROM electronbuilds/libchromiumcontent:0.0.4
USER root
# Install node.js
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get update && apt-get install -y nodejs
# Install wget used by crash reporter
@@ -12,6 +12,9 @@ RUN apt-get install -y wget
# Install python-dbusmock
RUN apt-get install -y python-dbusmock
# Install libnotify
RUN apt-get install -y libnotify-bin
# Add xvfb init script
ADD tools/xvfb-init.sh /etc/init.d/xvfb
RUN chmod a+x /etc/init.d/xvfb

36
Jenkinsfile.arm64 Normal file
View File

@@ -0,0 +1,36 @@
pipeline {
agent {
docker {
image 'electronbuilds/arm64v8:0.0.2'
args '--privileged'
}
}
environment {
TARGET_ARCH='arm64'
DISPLAY=':99.0'
MOCHA_TIMEOUT='60000'
}
stages {
stage('Bootstrap') {
steps {
sh 'script/bootstrap.py -v --dev --target_arch=$TARGET_ARCH'
}
}
stage('Build') {
steps {
sh 'script/build.py -c D --ninja-path /usr/local/ninja/ninja'
}
}
stage('Test') {
steps {
sh '/etc/init.d/xvfb start'
sh 'script/test.py --ci'
}
}
}
post {
always {
cleanWs()
}
}
}

View File

@@ -21,7 +21,7 @@ announcements.
This project adheres to the Contributor Covenant
[code of conduct](https://github.com/electron/electron/tree/master/CODE_OF_CONDUCT.md).
By participating, you are expected to uphold this code. Please report unacceptable
behavior to [electron@github.com](mailto:electron@github.com).
behavior to [coc@electronjs.org](mailto:coc@electronjs.org).
## Installation
@@ -89,22 +89,8 @@ Find documentation translations in [electron/electron-i18n](https://github.com/e
## Community
You can ask questions and interact with the community in the following
locations:
- [`electron`](https://discuss.atom.io/c/electron) category on the Atom
forums
- `#atom-shell` channel on Freenode
- [`Atom`](https://atom-slack.herokuapp.com) channel on Slack
- [`electron-ru`](https://telegram.me/electron_ru) *(Russian)*
- [`electron-br`](https://electron-br.slack.com) *(Brazilian Portuguese)*
- [`electron-kr`](https://electron-kr.github.io/electron-kr) *(Korean)*
- [`electron-jp`](https://electron-jp.slack.com) *(Japanese)*
- [`electron-tr`](https://electron-tr.herokuapp.com) *(Turkish)*
- [`electron-id`](https://electron-id.slack.com) *(Indonesia)*
- [`electron-pl`](https://electronpl.github.io) *(Poland)*
Check out [awesome-electron](https://github.com/sindresorhus/awesome-electron)
for a community maintained list of useful example apps, tools and resources.
Info on reporting bugs, getting help, finding third-party tools and sample apps,
and more can be found in the [support document](docs/tutorial/support.md#finding-support).
## License

View File

@@ -2,7 +2,7 @@
The Electron team and community take security bugs in Electron seriously. We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions.
To report a security issue, email [electron@github.com](mailto:electron@github.com) and include the word "SECURITY" in the subject line.
To report a security issue, email [security@electronjs.org](mailto:security@electronjs.org) and include the word "SECURITY" in the subject line.
The Electron team will send a response indicating the next steps in handling your report. After the initial reply to your report, the security team will keep you informed of the progress towards a fix and full announcement, and may ask for additional information or guidance.

69
appveyor.yml Normal file
View File

@@ -0,0 +1,69 @@
build_cloud: electron-16
image: electron-16-vs2015
build_script:
- ps: >-
if($env:SKIP_GYP_BUILD -eq "true") {
Write-warning "Skipping debug build for older branch"; Exit-AppveyorBuild
} elseif(($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
} else {
Add-Path "$env:ProgramFiles (x86)\Windows Kits\10\Debuggers\x64"
$env:path = "$env:ProgramFiles (x86)\Windows Kits\10\Debuggers\x64;$env:path"
if($env:APPVEYOR_SCHEDULED_BUILD -eq 'True') {
$env:RUN_RELEASE_BUILD = "1"
}
$Message = (git log --format=%B -n 1 HEAD) | Out-String
if ((Test-Path Env:\RUN_RELEASE_BUILD)) {
$env:ELECTRON_RELEASE = '1'
Write-Output "release build triggered from api"
}
if ((Test-Path Env:\ELECTRON_RELEASE)) {
Write-Output "Running release build"
python script\bootstrap.py --target_arch=$env:TARGET_ARCH
python script\build.py -c R
python script\create-dist.py
} else {
Write-Output "Running debug build"
python script\bootstrap.py --target_arch=$env:TARGET_ARCH --dev
python script\build.py -c D
}
if ($? -ne 'True') {
throw "Build failed with exit code $?"
} else {
"Build succeeded."
}
Push-AppveyorArtifact out
}
test_script:
- ps: >-
if (Test-Path Env:\ELECTRON_RELEASE) {
Write-Output "Skipping tests for release build"
} else {
Write-Output "Running tests for debug build"
python script\test.py --ci --rebuild_native_modules
if ($LASTEXITCODE -ne '0') {
throw "Tests failed with exit code $LASTEXITCODE"
} else {
Write-Output "Tests succeeded."
}
python script\verify-ffmpeg.py
if ($LASTEXITCODE -ne '0') {
throw "Verify ffmpeg failed with exit code $LASTEXITCODE"
} else {
"Verify ffmpeg succeeded."
}
}
artifacts:
- path: test-results.xml
name: test-results.xml
deploy_script:
- ps: >-
if (Test-Path Env:\ELECTRON_RELEASE) {
if (Test-Path Env:\RUN_RELEASE_BUILD) {
Write-Output "Uploading Electron release distribution to s3"
& python script\upload.py --upload_to_s3
} else {
Write-Output "Uploading Electron release distribution to github releases"
& python script\upload.py
}
}

View File

@@ -43,12 +43,12 @@ bool IsUrlArg(const base::CommandLine::CharType* arg) {
* Update the list by pasting the following command into bash
* in libchromiumcontent/src/:
(find ./ -name "*switches.cc" | \
xargs grep -P --no-filename "\"\S+\";" | \
perl -pe 's|^.*?"(\S+)";| "$1",|'; \
(find ./ \( -name "*switches.cc" -o -name "*switch_list.h" \) | \
xargs grep -P --no-filename '"\S+"[);]$' | \
perl -pe 's|^.*?"(\S+)"[);]$| "$1",|'; \
echo ' "inspect",'; \
echo ' "inspect-brk",') | \
LANG=C sort | \
LANG="C" sort | \
uniq > blacklist-switches.txt
*/
@@ -62,7 +62,10 @@ const char* kBlacklist[] = {
"/prefetch:8",
"0",
"?",
"BlacklistOnly",
"ChromeOSMemoryPressureHandling",
"Disabled",
"OnlineCheckOnly",
"SafeSites",
"accept-resource-provider",
"account-consistency",
@@ -72,7 +75,6 @@ const char* kBlacklist[] = {
"aggressive",
"aggressive-cache-discard",
"aggressive-tab-discard",
"all",
"all-toolchains",
"allarticles",
"allow-cross-origin-auth-prompt",
@@ -113,7 +115,6 @@ const char* kBlacklist[] = {
"always-on",
"always-use-complex-text",
"alwaystrue",
"amd-switchable",
"android-fonts-path",
"android-stderr-port",
"android-stdin-port",
@@ -141,11 +142,12 @@ const char* kBlacklist[] = {
"arc-transition-migration-required",
"args",
"artifacts-dir",
"ash-animate-from-boot-splash-screen",
"ash-constrain-pointer-to-root",
"ash-copy-host-background-at-boot",
"ash-debug-shortcuts",
"ash-dev-shortcuts",
"ash-disable-smooth-screen-rotation",
"ash-disable-tablet-autohide-titlebars",
"ash-disable-touch-exploration-mode",
"ash-enable-magnifier-key-scroller",
"ash-enable-mirrored-screen",
@@ -174,8 +176,6 @@ const char* kBlacklist[] = {
"autoplay-policy",
"blink-settings",
"bootstrap",
"browser",
"browser-startup-dialog",
"browser-subprocess-path",
"browser-test",
"bwsi",
@@ -220,6 +220,7 @@ const char* kBlacklist[] = {
"crash-test",
"crashpad-handler",
"create-browser-on-startup-for-tests",
"create-default-gl-context",
"cros-gaia-api-v1",
"cros-region",
"cros-regions-mode",
@@ -228,7 +229,6 @@ const char* kBlacklist[] = {
"custom-devtools-frontend",
"custom-launcher-page",
"custom_summary",
"d3d-support",
"d3d11",
"d3d9",
"daemon",
@@ -254,6 +254,7 @@ const char* kBlacklist[] = {
"default-wallpaper-is-oem",
"default-wallpaper-large",
"default-wallpaper-small",
"delay-reload-stop-button-change",
"demo",
"derelict-detection-timeout",
"derelict-idle-timeout",
@@ -267,7 +268,6 @@ const char* kBlacklist[] = {
"diagnostics-format",
"diagnostics-recovery",
"dice",
"dice_fix_auth_errors",
"disable",
"disable-2d-canvas-clip-aa",
"disable-2d-canvas-image-chromium",
@@ -289,6 +289,7 @@ const char* kBlacklist[] = {
"disable-backgrounding-occluded-windows",
"disable-backing-store-limit",
"disable-blink-features",
"disable-bookmark-reordering",
"disable-boot-animation",
"disable-breakpad",
"disable-browser-task-scheduler",
@@ -316,6 +317,7 @@ const char* kBlacklist[] = {
"disable-direct-composition",
"disable-direct-composition-layers",
"disable-directwrite-for-ui",
"disable-display-color-calibration",
"disable-display-list-2d-canvas",
"disable-distance-field-text",
"disable-domain-blocking-for-3d-apis",
@@ -330,6 +332,7 @@ const char* kBlacklist[] = {
"disable-extensions-except",
"disable-extensions-file-access-check",
"disable-extensions-http-throttling",
"disable-fast-web-scroll-view-insets",
"disable-features",
"disable-field-trial-config",
"disable-file-manager-touch-mode",
@@ -364,11 +367,14 @@ const char* kBlacklist[] = {
"disable-histogram-customizer",
"disable-hosted-app-shim-creation",
"disable-hosted-apps-in-windows",
"disable-http2",
"disable-in-process-stack-traces",
"disable-infobars",
"disable-input-ime-api",
"disable-input-view",
"disable-ios-password-generation",
"disable-ios-password-suggestions",
"disable-ios-physical-web",
"disable-javascript-harmony-shipping",
"disable-kill-after-bad-ipc",
"disable-lcd-text",
@@ -382,6 +388,7 @@ const char* kBlacklist[] = {
"disable-low-end-device-mode",
"disable-low-latency-dxva",
"disable-low-res-tiling",
"disable-lru-snapshot-cache",
"disable-mac-overlays",
"disable-mac-views-native-app-windows",
"disable-machine-cert-request",
@@ -398,6 +405,7 @@ const char* kBlacklist[] = {
"disable-namespace-sandbox",
"disable-native-gpu-memory-buffers",
"disable-network-portal-notification",
"disable-new-channel-switcher-ui",
"disable-new-korean-ime",
"disable-new-virtual-keyboard-behavior",
"disable-new-zip-unpacker",
@@ -417,7 +425,6 @@ const char* kBlacklist[] = {
"disable-password-generation",
"disable-pepper-3d",
"disable-pepper-3d-image-chromium",
"disable-per-user-timezone",
"disable-permission-action-reporting",
"disable-permissions-api",
"disable-physical-keyboard-autocorrect",
@@ -431,12 +438,15 @@ const char* kBlacklist[] = {
"disable-proximity-auth-bluetooth-low-energy-discovery",
"disable-pull-to-refresh-effect",
"disable-push-api-background-mode",
"disable-quic",
"disable-reading-from-canvas",
"disable-remote-core-animation",
"disable-remote-fonts",
"disable-remote-playback-api",
"disable-renderer-accessibility",
"disable-renderer-backgrounding",
"disable-renderer-priority-management",
"disable-request-mobile-site",
"disable-resize-lock",
"disable-rgba-4444-textures",
"disable-rollback-option",
@@ -444,6 +454,7 @@ const char* kBlacklist[] = {
"disable-screen-orientation-lock",
"disable-search-geolocation-disclosure",
"disable-seccomp-filter-sandbox",
"disable-settings-window",
"disable-setuid-sandbox",
"disable-shader-name-hashing",
"disable-shared-workers",
@@ -457,17 +468,16 @@ const char* kBlacklist[] = {
"disable-software-rasterizer",
"disable-speech-api",
"disable-suggestions-ui",
"disable-surface-references",
"disable-sync",
"disable-sync-app-list",
"disable-sync-types",
"disable-system-timezone-automatic-detection",
"disable-tab-for-desktop-share",
"disable-tab-strip-autoscroll-new-tabs",
"disable-third-party-keyboard-workaround",
"disable-threaded-animation",
"disable-threaded-compositing",
"disable-threaded-scrolling",
"disable-timeouts-for-profiling",
"disable-touch-adjustment",
"disable-touch-drag-drop",
"disable-translate-new-ux",
@@ -528,18 +538,16 @@ const char* kBlacklist[] = {
"enable-appcontainer",
"enable-arc",
"enable-arc-oobe-optin",
"enable-async-event-targeting",
"enable-audio-debug-recordings-from-extension",
"enable-audio-focus",
"enable-automation",
"enable-background-fetch-persistence",
"enable-benchmarking",
"enable-ble-advertising-in-apps",
"enable-blink-features",
"enable-bookmark-reordering",
"enable-bookmark-undo",
"enable-browser-side-navigation",
"enable-browser-task-scheduler",
"enable-cast-receiver",
"enable-checker-imaging",
"enable-chromevox-arc-support",
"enable-clear-browsing-data-counters",
@@ -579,8 +587,8 @@ const char* kBlacklist[] = {
"enable-extension-activity-log-testing",
"enable-extension-activity-logging",
"enable-extension-assets-sharing",
"enable-external-drive-rename",
"enable-fast-unload",
"enable-fast-web-scroll-view-insets",
"enable-features",
"enable-file-manager-touch-mode",
"enable-first-run-ui-transitions",
@@ -603,6 +611,7 @@ const char* kBlacklist[] = {
"enable-gpu-service-tracing",
"enable-hardware-overlays",
"enable-harfbuzz-rendertext",
"enable-hdr",
"enable-heap-profiling",
"enable-hosted-app-quit-notification",
"enable-hosted-apps-in-windows",
@@ -610,9 +619,10 @@ const char* kBlacklist[] = {
"enable-hung-renderer-infobar",
"enable-inband-text-tracks",
"enable-input-ime-api",
"enable-instant-tethering",
"enable-internal-media-session",
"enable-ios-handoff-to-other-devices",
"enable-ios-password-generation",
"enable-ios-physical-web",
"enable-layer-lists",
"enable-lcd-text",
"enable-leak-detection",
@@ -622,9 +632,11 @@ const char* kBlacklist[] = {
"enable-longpress-drag-selection",
"enable-low-end-device-mode",
"enable-low-res-tiling",
"enable-lru-snapshot-cache",
"enable-mac-views-native-app-windows",
"enable-main-frame-before-activation",
"enable-md-feedback",
"enable-md-policy-page",
"enable-media-suspend",
"enable-merge-key-char-events",
"enable-message-center-always-scroll-up-upon-notification-removal",
@@ -645,7 +657,6 @@ const char* kBlacklist[] = {
"enable-offer-upload-credit-cards",
"enable-offline-auto-reload",
"enable-offline-auto-reload-visible-only",
"enable-oop-rasterization",
"enable-osk-overscroll",
"enable-override-bookmarks-ui",
"enable-partial-raster",
@@ -655,7 +666,6 @@ const char* kBlacklist[] = {
"enable-physical-keyboard-autocorrect",
"enable-picture-in-picture",
"enable-pinch",
"enable-pixel-canvas-recording",
"enable-pixel-output-in-tests",
"enable-plugin-placeholder-testing",
"enable-potentially-annoying-security-features",
@@ -667,6 +677,8 @@ const char* kBlacklist[] = {
"enable-profile-shortcut-manager",
"enable-profiling",
"enable-push-api-background-mode",
"enable-quic",
"enable-reader-mode-toolbar-icon",
"enable-refresh-token-annotation-request",
"enable-request-tablet-site",
"enable-rgba-4444-textures",
@@ -676,6 +688,7 @@ const char* kBlacklist[] = {
"enable-scripts-require-action",
"enable-scroll-prediction",
"enable-service-manager-tracing",
"enable-settings-window",
"enable-sgi-video-sync",
"enable-signin-promo",
"enable-single-click-autofill",
@@ -718,6 +731,7 @@ const char* kBlacklist[] = {
"enable-translate-new-ux",
"enable-ui-devtools",
"enable-use-zoom-for-dsf",
"enable-user-controlled-alternate-protocol-ports",
"enable-user-metrics",
"enable-usermedia-screen-capturing",
"enable-video-player-chromecast-support",
@@ -734,9 +748,8 @@ const char* kBlacklist[] = {
"enable-webgl-image-chromium",
"enable-webrtc-event-logging-from-extension",
"enable-webrtc-srtp-aes-gcm",
"enable-webrtc-srtp-encrypted-headers",
"enable-webrtc-stun-origin",
"enable-webview-variations",
"enable-webview-finch",
"enable-webvr",
"enable-wifi-credential-sync",
"enable-win7-webrtc-hw-h264-decoding",
@@ -759,8 +772,6 @@ const char* kBlacklist[] = {
"enterprise-enrollment-initial-modulus",
"enterprise-enrollment-modulus-limit",
"error-console",
"evaluate-type",
"evaluate_capability",
"experiment",
"explicitly-allowed-ports",
"expose-internals-for-testing",
@@ -808,7 +819,6 @@ const char* kBlacklist[] = {
"force-overlay-fullscreen-video",
"force-password-reauth",
"force-pnacl-subzero",
"force-presentation-receiver-for-testing",
"force-renderer-accessibility",
"force-show-update-menu-badge",
"force-show-update-menu-item",
@@ -838,6 +848,7 @@ const char* kBlacklist[] = {
"gpu-active-device-id",
"gpu-active-vendor-id",
"gpu-device-id",
"gpu-driver-bug-workarounds",
"gpu-driver-date",
"gpu-driver-vendor",
"gpu-driver-version",
@@ -863,7 +874,6 @@ const char* kBlacklist[] = {
"gpu-testing-secondary-vendor-ids",
"gpu-testing-vendor-id",
"gpu-vendor-id",
"graphics-buffer-count",
"guest-wallpaper-large",
"guest-wallpaper-small",
"h",
@@ -881,6 +891,7 @@ const char* kBlacklist[] = {
"host",
"host-pairing-oobe",
"host-resolver-rules",
"host-rules",
"icu-data-dir",
"ignore-autocomplete-off-autofill",
"ignore-autoplay-restrictions",
@@ -928,10 +939,6 @@ const char* kBlacklist[] = {
"login-manager",
"login-profile",
"login-user",
"loopback-i2s-bits",
"loopback-i2s-bus-name",
"loopback-i2s-channels",
"loopback-i2s-rate-hz",
"lso-url",
"ltr",
"main-frame-resizes-are-orientation-changes",
@@ -953,11 +960,11 @@ const char* kBlacklist[] = {
"media-cache-size",
"mem-pressure-system-reserved-kb",
"memlog",
"memlog-pipe",
"memory-pressure-off",
"memory-pressure-thresholds",
"memory-pressure-thresholds-mb",
"message-center-changes-while-open",
"method",
"metrics-client-id",
"metrics-recording-only",
"mhtml-generator-option",
@@ -1013,6 +1020,7 @@ const char* kBlacklist[] = {
"normal_vibrant",
"note-taking-app-ids",
"ntp-snippets-add-incomplete",
"ntp-switch-to-existing-tab",
"null",
"num-raster-threads",
"oauth2-client-id",
@@ -1026,6 +1034,7 @@ const char* kBlacklist[] = {
"oobe-timer-interval",
"open-ash",
"opengraph",
"origin-to-force-quic-on",
"origin-trial-disabled-features",
"origin-trial-disabled-tokens",
"origin-trial-public-key",
@@ -1058,6 +1067,7 @@ const char* kBlacklist[] = {
"ppapi-plugin-launcher",
"ppapi-startup-dialog",
"ppapi-subpixel-rendering-setting",
"prerender-from-omnibox",
"previous-app",
"primary",
"print-to-pdf",
@@ -1067,6 +1077,7 @@ const char* kBlacklist[] = {
"product-version",
"profile-directory",
"profiler-timing",
"profiling",
"profiling-at-start",
"profiling-file",
"profiling-flush",
@@ -1077,8 +1088,10 @@ const char* kBlacklist[] = {
"proxy-bypass-list",
"proxy-pac-url",
"proxy-server",
"pull-to-refresh",
"q",
"quic-connection-options",
"quic-max-packet-length",
"quic-version",
"rdp_desktop_session",
"reader-mode-feedback",
"reader-mode-heuristics",
@@ -1110,7 +1123,6 @@ const char* kBlacklist[] = {
"root",
"root-layer-scrolls",
"rtl",
"run-all-compositor-stages-before-draw",
"run-layout-test",
"runtime-deps-list-file",
"safebrowsing-disable-auto-update",
@@ -1123,6 +1135,7 @@ const char* kBlacklist[] = {
"screenshot",
"script-executable",
"scripts-require-action",
"scroll-end-effect",
"search-provider-logo-url",
"secondary",
"secondary-display-layout",
@@ -1169,7 +1182,6 @@ const char* kBlacklist[] = {
"skip-reencoding-on-skp-capture",
"slow",
"slow-connections-only",
"slow-down-compositing-scale-factor",
"slow-down-raster-scale-factor",
"sms-test-messages",
"spdy-proxy-auth-fallback",
@@ -1192,6 +1204,7 @@ const char* kBlacklist[] = {
"started",
"stub",
"stub-cros-settings",
"supports-dual-gpus",
"surface",
"swiftshader",
"swiftshader-webgl",
@@ -1208,7 +1221,6 @@ const char* kBlacklist[] = {
"system-log-upload-frequency",
"tab-management-experiment-type-disabled",
"tab-management-experiment-type-elderberry",
"task-manager-show-extra-renderers",
"task-profiler",
"team-drives",
"test-auto-update-ui",
@@ -1240,7 +1252,6 @@ const char* kBlacklist[] = {
"testing-fixed-http-port",
"testing-fixed-https-port",
"tether-stub",
"third-party-doodle-url",
"threads",
"time",
"timeout",
@@ -1300,6 +1311,7 @@ const char* kBlacklist[] = {
"unsafely-treat-insecure-origin-as-secure",
"use-angle",
"use-cras",
"use-double-buffering",
"use-fake-device-for-media-stream",
"use-fake-jpeg-decode-accelerator",
"use-fake-ui-for-media-stream",
@@ -1312,10 +1324,9 @@ const char* kBlacklist[] = {
"use-mobile-user-agent",
"use-mock-keychain",
"use-passthrough-cmd-decoder",
"use-skia-renderer",
"use-simple-cache-backend",
"use-system-default-printer",
"use-test-config",
"use-viz-hit-test",
"user-agent",
"user-always-affiliated",
"user-data-dir",
@@ -1325,8 +1336,6 @@ const char* kBlacklist[] = {
"utility-allowed-dir",
"utility-cmd-prefix",
"utility-run-elevated",
"utility-sandbox-type",
"utility-startup-dialog",
"v",
"v2-sandbox",
"v2-sandbox-enabled",
@@ -1350,6 +1359,7 @@ const char* kBlacklist[] = {
"watcher",
"waveout-buffers",
"webapk-server-url",
"webrtc-max-cpu-consumption-percentage",
"webrtc-stun-probe-trial",
"webview-enable-safebrowsing-support",
"webview-sandboxed-renderer",

View File

@@ -68,8 +68,8 @@ void BrowserView::Init(v8::Isolate* isolate,
web_contents_.Reset(isolate, web_contents.ToV8());
api_web_contents_ = web_contents.get();
view_.reset(NativeBrowserView::Create(
api_web_contents_->managed_web_contents()->GetView()));
view_.reset(
NativeBrowserView::Create(api_web_contents_->managed_web_contents()));
InitWith(isolate, wrapper);
}

View File

@@ -18,6 +18,12 @@
using content::BrowserThread;
namespace {
static scoped_nsobject<NSMenu> applicationMenu_;
} // namespace
namespace atom {
namespace api {
@@ -135,7 +141,18 @@ void Menu::SetApplicationMenu(Menu* base_menu) {
base::scoped_nsobject<AtomMenuController> menu_controller(
[[AtomMenuController alloc] initWithModel:menu->model_.get()
useDefaultAccelerator:YES]);
[NSApp setMainMenu:[menu_controller menu]];
NSRunLoop* currentRunLoop = [NSRunLoop currentRunLoop];
[currentRunLoop cancelPerformSelector:@selector(setMainMenu:)
target:NSApp
argument:applicationMenu_];
applicationMenu_.reset([[menu_controller menu] retain]);
[[NSRunLoop currentRunLoop]
performSelector:@selector(setMainMenu:)
target:NSApp
argument:applicationMenu_
order:0
modes:[NSArray arrayWithObject:NSDefaultRunLoopMode]];
// Ensure the menu_controller_ is destroyed after main menu is set.
menu_controller.swap(menu->menu_controller_);

View File

@@ -23,20 +23,16 @@ MenuViews::MenuViews(v8::Isolate* isolate, v8::Local<v8::Object> wrapper)
void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item,
const base::Closure& callback) {
NativeWindow* native_window = static_cast<NativeWindow*>(window->window());
auto* native_window = static_cast<NativeWindowViews*>(window->window());
if (!native_window)
return;
auto* web_contents = native_window->inspectable_web_contents();
if (!web_contents)
return;
// (-1, -1) means showing on mouse location.
gfx::Point location;
if (x == -1 || y == -1) {
location = display::Screen::GetScreen()->GetCursorScreenPoint();
} else {
auto* view = web_contents->GetView()->GetWebView();
gfx::Point origin = view->bounds().origin();
gfx::Point origin = native_window->GetContentBounds().origin();
location = gfx::Point(origin.x() + x, origin.y() + y);
}
@@ -52,7 +48,7 @@ void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item,
menu_runners_[window_id] = std::unique_ptr<MenuRunner>(new MenuRunner(
model(), flags, close_callback));
menu_runners_[window_id]->RunMenuAt(
static_cast<NativeWindowViews*>(window->window())->widget(),
native_window->widget(),
NULL,
gfx::Rect(location, gfx::Size()),
views::MENU_ANCHOR_TOPLEFT,

View File

@@ -9,6 +9,7 @@ namespace atom {
namespace api {
//TODO(codebytere): deprecated; remove in 3.0
int Screen::getMenuBarHeight() {
return [[NSApp mainMenu] menuBarHeight];
}

View File

@@ -29,7 +29,6 @@
#include "base/guid.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "brightray/browser/media/media_device_id_salt.h"
#include "brightray/browser/net/devtools_network_conditions.h"
#include "brightray/browser/net/devtools_network_controller_handle.h"
@@ -47,7 +46,6 @@
#include "net/http/http_auth_handler_factory.h"
#include "net/http/http_auth_preferences.h"
#include "net/proxy/proxy_config_service_fixed.h"
#include "net/proxy/proxy_service.h"
#include "net/url_request/static_http_user_agent_settings.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
@@ -232,59 +230,6 @@ const char kPersistPrefix[] = "persist:";
// Referenced session objects.
std::map<uint32_t, v8::Global<v8::Object>> g_sessions;
class ResolveProxyHelper {
public:
ResolveProxyHelper(AtomBrowserContext* browser_context,
const GURL& url,
const Session::ResolveProxyCallback& callback)
: callback_(callback),
original_thread_(base::ThreadTaskRunnerHandle::Get()) {
scoped_refptr<net::URLRequestContextGetter> context_getter =
browser_context->url_request_context_getter();
context_getter->GetNetworkTaskRunner()->PostTask(
FROM_HERE,
base::Bind(&ResolveProxyHelper::ResolveProxy,
base::Unretained(this), context_getter, url));
}
void OnResolveProxyCompleted(int result) {
std::string proxy;
if (result == net::OK)
proxy = proxy_info_.ToPacString();
original_thread_->PostTask(FROM_HERE,
base::Bind(callback_, proxy));
delete this;
}
private:
void ResolveProxy(scoped_refptr<net::URLRequestContextGetter> context_getter,
const GURL& url) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
net::ProxyService* proxy_service =
context_getter->GetURLRequestContext()->proxy_service();
net::CompletionCallback completion_callback =
base::Bind(&ResolveProxyHelper::OnResolveProxyCompleted,
base::Unretained(this));
// Start the request.
int result = proxy_service->ResolveProxy(
url, "GET", &proxy_info_, completion_callback, &pac_req_, nullptr,
net::NetLogWithSource());
// Completed synchronously.
if (result != net::ERR_IO_PENDING)
completion_callback.Run(result);
}
Session::ResolveProxyCallback callback_;
net::ProxyInfo proxy_info_;
net::ProxyService::PacRequest* pac_req_;
scoped_refptr<base::SingleThreadTaskRunner> original_thread_;
DISALLOW_COPY_AND_ASSIGN(ResolveProxyHelper);
};
// Runs the callback in UI thread.
void RunCallbackInUI(const base::Callback<void()>& callback) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback);
@@ -441,14 +386,15 @@ void DownloadIdCallback(content::DownloadManager* download_manager,
}
void SetDevToolsNetworkEmulationClientIdInIO(
brightray::URLRequestContextGetter* context_getter,
brightray::URLRequestContextGetter* url_request_context_getter,
const std::string& client_id) {
if (!context_getter)
if (!url_request_context_getter)
return;
auto network_delegate =
static_cast<AtomNetworkDelegate*>(context_getter->network_delegate());
if (network_delegate)
network_delegate->SetDevToolsNetworkEmulationClientId(client_id);
net::URLRequestContext* context =
url_request_context_getter->GetURLRequestContext();
AtomNetworkDelegate* network_delegate =
static_cast<AtomNetworkDelegate*>(context->network_delegate());
network_delegate->SetDevToolsNetworkEmulationClientId(client_id);
}
} // namespace
@@ -489,8 +435,10 @@ void Session::OnDownloadCreated(content::DownloadManager* manager,
}
}
void Session::ResolveProxy(const GURL& url, ResolveProxyCallback callback) {
new ResolveProxyHelper(browser_context(), url, callback);
void Session::ResolveProxy(
const GURL& url,
const ResolveProxyHelper::ResolveProxyCallback& callback) {
browser_context_->GetResolveProxyHelper()->ResolveProxy(url, callback);
}
template<Session::CacheAction action>

View File

@@ -10,6 +10,7 @@
#include "atom/browser/api/trackable_object.h"
#include "atom/browser/atom_blob_reader.h"
#include "atom/browser/net/resolve_proxy_helper.h"
#include "base/values.h"
#include "content/public/browser/download_manager.h"
#include "native_mate/handle.h"
@@ -39,8 +40,6 @@ namespace api {
class Session: public mate::TrackableObject<Session>,
public content::DownloadManager::Observer {
public:
using ResolveProxyCallback = base::Callback<void(std::string)>;
enum class CacheAction {
CLEAR,
STATS,
@@ -62,7 +61,8 @@ class Session: public mate::TrackableObject<Session>,
v8::Local<v8::FunctionTemplate> prototype);
// Methods.
void ResolveProxy(const GURL& url, ResolveProxyCallback callback);
void ResolveProxy(const GURL& url,
const ResolveProxyHelper::ResolveProxyCallback& callback);
template<CacheAction action>
void DoCacheAction(const net::CompletionCallback& callback);
void ClearStorageData(mate::Arguments* args);

View File

@@ -206,7 +206,7 @@ void Tray::PopUpContextMenu(mate::Arguments* args) {
void Tray::SetContextMenu(v8::Isolate* isolate, mate::Handle<Menu> menu) {
menu_.Reset(isolate, menu.ToV8());
tray_icon_->SetContextMenu(menu->model());
tray_icon_->SetContextMenu(menu.IsEmpty() ? nullptr : menu->model());
}
gfx::Rect Tray::GetBounds() {

View File

@@ -113,7 +113,7 @@ struct Converter<atom::SetSizeParams> {
return false;
bool autosize;
if (params.Get("enableAutoSize", &autosize))
out->enable_auto_size.reset(new bool(true));
out->enable_auto_size.reset(new bool(autosize));
gfx::Size size;
if (params.Get("min", &size))
out->min_size.reset(new gfx::Size(size));
@@ -272,11 +272,35 @@ content::ServiceWorkerContext* GetServiceWorkerContext(
void OnCapturePageDone(const base::Callback<void(const gfx::Image&)>& callback,
const SkBitmap& bitmap,
content::ReadbackResponse response) {
// Hack to enable transparency in captured image
// TODO(nitsakh) Remove hack once fixed in chromium
const_cast<SkBitmap&>(bitmap).setAlphaType(kPremul_SkAlphaType);
callback.Run(gfx::Image::CreateFrom1xBitmap(bitmap));
}
} // namespace
struct WebContents::FrameDispatchHelper {
WebContents* api_web_contents;
content::RenderFrameHost* rfh;
bool Send(IPC::Message* msg) { return rfh->Send(msg); }
void OnSetTemporaryZoomLevel(double level, IPC::Message* reply_msg) {
api_web_contents->OnSetTemporaryZoomLevel(rfh, level, reply_msg);
}
void OnGetZoomLevel(IPC::Message* reply_msg) {
api_web_contents->OnGetZoomLevel(rfh, reply_msg);
}
void OnRendererMessageSync(const base::string16& channel,
const base::ListValue& args,
IPC::Message* message) {
api_web_contents->OnRendererMessageSync(rfh, channel, args, message);
}
};
WebContents::WebContents(v8::Isolate* isolate,
content::WebContents* web_contents,
Type type)
@@ -286,7 +310,8 @@ WebContents::WebContents(v8::Isolate* isolate,
type_(type),
request_id_(0),
background_throttling_(true),
enable_devtools_(true) {
enable_devtools_(true),
is_dom_ready_(false) {
const mate::Dictionary options = mate::Dictionary::CreateEmpty(isolate);
if (type == REMOTE) {
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent());
@@ -775,8 +800,10 @@ void WebContents::DidChangeThemeColor(SkColor theme_color) {
void WebContents::DocumentLoadedInFrame(
content::RenderFrameHost* render_frame_host) {
if (!render_frame_host->GetParent())
if (!render_frame_host->GetParent()) {
is_dom_ready_ = true;
Emit("dom-ready");
}
}
void WebContents::DidFinishLoad(content::RenderFrameHost* render_frame_host,
@@ -798,6 +825,7 @@ void WebContents::DidFailLoad(content::RenderFrameHost* render_frame_host,
}
void WebContents::DidStartLoading() {
is_dom_ready_ = false;
Emit("did-start-loading");
}
@@ -923,13 +951,6 @@ void WebContents::ShowAutofillPopup(content::RenderFrameHost* frame_host,
bool WebContents::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(WebContents, message)
IPC_MESSAGE_HANDLER(AtomViewHostMsg_Message, OnRendererMessage)
IPC_MESSAGE_HANDLER_DELAY_REPLY(AtomViewHostMsg_Message_Sync,
OnRendererMessageSync)
IPC_MESSAGE_HANDLER_DELAY_REPLY(AtomViewHostMsg_SetTemporaryZoomLevel,
OnSetTemporaryZoomLevel)
IPC_MESSAGE_HANDLER_DELAY_REPLY(AtomViewHostMsg_GetZoomLevel,
OnGetZoomLevel)
IPC_MESSAGE_HANDLER_CODE(ViewHostMsg_SetCursor, OnCursorChange,
handled = false)
IPC_MESSAGE_UNHANDLED(handled = false)
@@ -939,17 +960,28 @@ bool WebContents::OnMessageReceived(const IPC::Message& message) {
}
bool WebContents::OnMessageReceived(const IPC::Message& message,
content::RenderFrameHost* frame_host) {
content::RenderFrameHost* frame_host) {
bool handled = true;
FrameDispatchHelper helper = {this, frame_host};
auto relay = NativeWindowRelay::FromWebContents(web_contents());
if (!relay)
return false;
if (relay) {
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(NativeWindow, message, frame_host)
IPC_MESSAGE_FORWARD(AtomAutofillFrameHostMsg_HidePopup,
relay->window.get(), NativeWindow::HideAutofillPopup)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
}
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(WebContents, message, frame_host)
IPC_MESSAGE_HANDLER(AtomFrameHostMsg_Message, OnRendererMessage)
IPC_MESSAGE_FORWARD_DELAY_REPLY(AtomFrameHostMsg_Message_Sync, &helper,
FrameDispatchHelper::OnRendererMessageSync)
IPC_MESSAGE_FORWARD_DELAY_REPLY(
AtomFrameHostMsg_SetTemporaryZoomLevel, &helper,
FrameDispatchHelper::OnSetTemporaryZoomLevel)
IPC_MESSAGE_FORWARD_DELAY_REPLY(AtomFrameHostMsg_GetZoomLevel, &helper,
FrameDispatchHelper::OnGetZoomLevel)
IPC_MESSAGE_HANDLER(AtomAutofillFrameHostMsg_ShowPopup, ShowAutofillPopup)
IPC_END_MESSAGE_MAP()
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(NativeWindow, message, frame_host)
IPC_MESSAGE_FORWARD(AtomAutofillFrameHostMsg_HidePopup,
relay->window.get(), NativeWindow::HideAutofillPopup)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -989,13 +1021,17 @@ void WebContents::NavigationEntryCommitted(
details.is_same_document, details.did_replace_entry);
}
int64_t WebContents::GetID() const {
int64_t process_id = web_contents()->GetRenderProcessHost()->GetID();
int64_t routing_id = web_contents()->GetRenderViewHost()->GetRoutingID();
int64_t WebContents::GetIDForContents(content::WebContents* web_contents) {
int64_t process_id = web_contents->GetRenderProcessHost()->GetID();
int64_t routing_id = web_contents->GetMainFrame()->GetRoutingID();
int64_t rv = (process_id << 32) + routing_id;
return rv;
}
int64_t WebContents::GetID() const {
return WebContents::GetIDForContents(web_contents());
}
int WebContents::GetProcessID() const {
return web_contents()->GetRenderProcessHost()->GetID();
}
@@ -1311,6 +1347,10 @@ bool WebContents::IsAudioMuted() {
return web_contents()->IsAudioMuted();
}
bool WebContents::IsDOMReady() const {
return is_dom_ready_;
}
void WebContents::Print(mate::Arguments* args) {
PrintSettings settings = { false, false, base::string16() };
if (args->Length() >= 1 && !args->GetNext(&settings)) {
@@ -1468,7 +1508,12 @@ void WebContents::TabTraverse(bool reverse) {
bool WebContents::SendIPCMessage(bool all_frames,
const base::string16& channel,
const base::ListValue& args) {
return Send(new AtomViewMsg_Message(routing_id(), all_frames, channel, args));
auto frame_host = web_contents()->GetMainFrame();
if (frame_host) {
return frame_host->Send(new AtomFrameMsg_Message(
frame_host->GetRoutingID(), all_frames, channel, args));
}
return false;
}
void WebContents::SendInputEvent(v8::Isolate* isolate,
@@ -1752,25 +1797,38 @@ double WebContents::GetZoomFactor() {
return content::ZoomLevelToZoomFactor(level);
}
void WebContents::OnSetTemporaryZoomLevel(double level,
void WebContents::OnSetTemporaryZoomLevel(content::RenderFrameHost* rfh,
double level,
IPC::Message* reply_msg) {
zoom_controller_->SetTemporaryZoomLevel(level);
double new_level = zoom_controller_->GetZoomLevel();
AtomViewHostMsg_SetTemporaryZoomLevel::WriteReplyParams(reply_msg, new_level);
Send(reply_msg);
AtomFrameHostMsg_SetTemporaryZoomLevel::WriteReplyParams(reply_msg,
new_level);
rfh->Send(reply_msg);
}
void WebContents::OnGetZoomLevel(IPC::Message* reply_msg) {
AtomViewHostMsg_GetZoomLevel::WriteReplyParams(reply_msg, GetZoomLevel());
Send(reply_msg);
void WebContents::OnGetZoomLevel(content::RenderFrameHost* rfh,
IPC::Message* reply_msg) {
AtomFrameHostMsg_GetZoomLevel::WriteReplyParams(reply_msg, GetZoomLevel());
rfh->Send(reply_msg);
}
v8::Local<v8::Value> WebContents::GetWebPreferences(v8::Isolate* isolate) {
WebContentsPreferences* web_preferences =
WebContentsPreferences::FromWebContents(web_contents());
if (!web_preferences)
return v8::Null(isolate);
return mate::ConvertToV8(isolate, *web_preferences->web_preferences());
}
v8::Local<v8::Value> WebContents::GetLastWebPreferences(v8::Isolate* isolate) {
WebContentsPreferences* web_preferences =
WebContentsPreferences::FromWebContents(web_contents());
if (!web_preferences)
return v8::Null(isolate);
return mate::ConvertToV8(isolate, *web_preferences->last_web_preferences());
}
v8::Local<v8::Value> WebContents::GetOwnerBrowserWindow() {
if (owner_window())
return Window::From(isolate(), owner_window());
@@ -1884,6 +1942,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
&WebContents::SetIgnoreMenuShortcuts)
.SetMethod("setAudioMuted", &WebContents::SetAudioMuted)
.SetMethod("isAudioMuted", &WebContents::IsAudioMuted)
.SetMethod("isDomReady", &WebContents::IsDOMReady)
.SetMethod("undo", &WebContents::Undo)
.SetMethod("redo", &WebContents::Redo)
.SetMethod("cut", &WebContents::Cut)
@@ -1907,9 +1966,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
.SetMethod("startDrag", &WebContents::StartDrag)
.SetMethod("setSize", &WebContents::SetSize)
.SetMethod("isGuest", &WebContents::IsGuest)
#if defined(ENABLE_OSR)
.SetMethod("isOffscreen", &WebContents::IsOffScreen)
#endif
.SetMethod("startPainting", &WebContents::StartPainting)
.SetMethod("stopPainting", &WebContents::StopPainting)
.SetMethod("isPainting", &WebContents::IsPainting)
@@ -1922,6 +1979,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
.SetMethod("_getZoomFactor", &WebContents::GetZoomFactor)
.SetMethod("getType", &WebContents::GetType)
.SetMethod("getWebPreferences", &WebContents::GetWebPreferences)
.SetMethod("getLastWebPreferences", &WebContents::GetLastWebPreferences)
.SetMethod("getOwnerBrowserWindow", &WebContents::GetOwnerBrowserWindow)
.SetMethod("hasServiceWorker", &WebContents::HasServiceWorker)
.SetMethod("unregisterServiceWorker",
@@ -1955,17 +2013,19 @@ AtomBrowserContext* WebContents::GetBrowserContext() const {
return static_cast<AtomBrowserContext*>(web_contents()->GetBrowserContext());
}
void WebContents::OnRendererMessage(const base::string16& channel,
void WebContents::OnRendererMessage(content::RenderFrameHost* frame_host,
const base::string16& channel,
const base::ListValue& args) {
// webContents.emit(channel, new Event(), args...);
Emit(base::UTF16ToUTF8(channel), args);
}
void WebContents::OnRendererMessageSync(const base::string16& channel,
void WebContents::OnRendererMessageSync(content::RenderFrameHost* frame_host,
const base::string16& channel,
const base::ListValue& args,
IPC::Message* message) {
// webContents.emit(channel, new Event(sender, message), args...);
EmitWithSender(base::UTF16ToUTF8(channel), web_contents(), message, args);
EmitWithSender(base::UTF16ToUTF8(channel), frame_host, message, args);
}
// static

View File

@@ -79,6 +79,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
static int64_t GetIDForContents(content::WebContents* web_contents);
// Notifies to destroy any guest web contents before destroying self.
void DestroyWebContents(bool async);
@@ -123,6 +125,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
void SetIgnoreMenuShortcuts(bool ignore);
void SetAudioMuted(bool muted);
bool IsAudioMuted();
bool IsDOMReady() const;
void Print(mate::Arguments* args);
std::vector<printing::PrinterBasicInfo> GetPrinterList();
void SetEmbedder(const WebContents* embedder);
@@ -214,6 +217,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
// Returns the web preferences of current WebContents.
v8::Local<v8::Value> GetWebPreferences(v8::Isolate* isolate);
v8::Local<v8::Value> GetLastWebPreferences(v8::Isolate* isolate);
// Returns the owner window.
v8::Local<v8::Value> GetOwnerBrowserWindow();
@@ -367,6 +371,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
const std::vector<base::string16>& labels);
private:
struct FrameDispatchHelper;
AtomBrowserContext* GetBrowserContext() const;
uint32_t GetNextRequestId() {
@@ -377,21 +382,26 @@ class WebContents : public mate::TrackableObject<WebContents>,
void OnCursorChange(const content::WebCursor& cursor);
// Called when received a message from renderer.
void OnRendererMessage(const base::string16& channel,
void OnRendererMessage(content::RenderFrameHost* frame_host,
const base::string16& channel,
const base::ListValue& args);
// Called when received a synchronous message from renderer.
void OnRendererMessageSync(const base::string16& channel,
void OnRendererMessageSync(content::RenderFrameHost* frame_host,
const base::string16& channel,
const base::ListValue& args,
IPC::Message* message);
// Called when received a synchronous message from renderer to
// set temporary zoom level.
void OnSetTemporaryZoomLevel(double level, IPC::Message* reply_msg);
void OnSetTemporaryZoomLevel(content::RenderFrameHost* frame_host,
double level,
IPC::Message* reply_msg);
// Called when received a synchronous message from renderer to
// get the zoom level.
void OnGetZoomLevel(IPC::Message* reply_msg);
void OnGetZoomLevel(content::RenderFrameHost* frame_host,
IPC::Message* reply_msg);
void InitZoomController(content::WebContents* web_contents,
const mate::Dictionary& options);
@@ -421,6 +431,9 @@ class WebContents : public mate::TrackableObject<WebContents>,
// Whether to enable devtools.
bool enable_devtools_;
// Whether page's document is ready.
bool is_dom_ready_;
DISALLOW_COPY_AND_ASSIGN(WebContents);
};

View File

@@ -37,6 +37,26 @@ namespace atom {
namespace api {
namespace {
template<typename Method, typename Event, typename Listener>
void CallNetworkDelegateMethod(
brightray::URLRequestContextGetter* url_request_context_getter,
Method method,
Event type,
URLPatterns patterns,
Listener listener) {
// Force creating network delegate.
net::URLRequestContext* context =
url_request_context_getter->GetURLRequestContext();
// Then call the method.
AtomNetworkDelegate* network_delegate =
static_cast<AtomNetworkDelegate*>(context->network_delegate());
(network_delegate->*method)(type, std::move(patterns), std::move(listener));
}
} // namespace
WebRequest::WebRequest(v8::Isolate* isolate,
AtomBrowserContext* browser_context)
: browser_context_(browser_context) {
@@ -74,16 +94,15 @@ void WebRequest::SetListener(Method method, Event type, mate::Arguments* args) {
return;
}
auto url_request_context_getter =
brightray::URLRequestContextGetter* url_request_context_getter =
browser_context_->url_request_context_getter();
if (!url_request_context_getter)
return;
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(method,
base::Unretained(static_cast<AtomNetworkDelegate*>(
url_request_context_getter->network_delegate())),
type, patterns, listener));
base::Bind(&CallNetworkDelegateMethod<Method, Event, Listener>,
base::RetainedRef(url_request_context_getter),
method, type, std::move(patterns), std::move(listener)));
}
// static

View File

@@ -450,9 +450,11 @@ gfx::Rect Window::GetContentBounds() {
}
void Window::SetSize(int width, int height, mate::Arguments* args) {
gfx::Size size = window_->GetMinimumSize();
size.SetToMax(gfx::Size(width, height));
bool animate = false;
args->GetNext(&animate);
window_->SetSize(gfx::Size(width, height), animate);
window_->SetSize(size, animate);
}
std::vector<int> Window::GetSize() {
@@ -893,6 +895,8 @@ void Window::SetBrowserView(v8::Local<v8::Value> value) {
window_->SetBrowserView(browser_view->view());
browser_view->web_contents()->SetOwnerWindow(window_.get());
browser_view_.Reset(isolate(), value);
window_->UpdateDraggableRegionViews();
}
}
@@ -952,8 +956,11 @@ void Window::ToggleTabBar() {
window_->ToggleTabBar();
}
void Window::AddTabbedWindow(NativeWindow* window) {
window_->AddTabbedWindow(window);
void Window::AddTabbedWindow(NativeWindow* window,
mate::Arguments* args) {
const bool windowAdded = window_->AddTabbedWindow(window);
if (!windowAdded)
args->ThrowError("AddTabbedWindow cannot be called by a window on itself.");
}
void Window::SetVibrancy(mate::Arguments* args) {

View File

@@ -222,7 +222,7 @@ class Window : public mate::TrackableObject<Window>,
void MergeAllWindows();
void MoveTabToNewWindow();
void ToggleTabBar();
void AddTabbedWindow(NativeWindow* window);
void AddTabbedWindow(NativeWindow* window, mate::Arguments* args);
void SetVibrancy(mate::Arguments* args);
void SetTouchBar(const std::vector<mate::PersistentDictionary>& items);

View File

@@ -6,6 +6,7 @@
#include "atom/common/api/api_messages.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "native_mate/object_template_builder.h"
@@ -20,17 +21,32 @@ Event::Event(v8::Isolate* isolate)
Event::~Event() {
}
void Event::SetSenderAndMessage(content::WebContents* sender,
void Event::SetSenderAndMessage(content::RenderFrameHost* sender,
IPC::Message* message) {
DCHECK(!sender_);
DCHECK(!message_);
sender_ = sender;
message_ = message;
Observe(sender);
Observe(content::WebContents::FromRenderFrameHost(sender));
}
void Event::WebContentsDestroyed() {
void Event::RenderFrameDeleted(content::RenderFrameHost* rfh) {
if (sender_ != rfh)
return;
sender_ = nullptr;
message_ = nullptr;
}
void Event::RenderFrameHostChanged(content::RenderFrameHost* old_rfh,
content::RenderFrameHost* new_rfh) {
if (sender_ && sender_ == old_rfh)
sender_ = new_rfh;
}
void Event::FrameDeleted(content::RenderFrameHost* rfh) {
if (sender_ != rfh)
return;
sender_ = nullptr;
message_ = nullptr;
}
@@ -44,7 +60,7 @@ bool Event::SendReply(const base::string16& json) {
if (message_ == nullptr || sender_ == nullptr)
return false;
AtomViewHostMsg_Message_Sync::WriteReplyParams(message_, json);
AtomFrameHostMsg_Message_Sync::WriteReplyParams(message_, json);
bool success = sender_->Send(message_);
message_ = nullptr;
sender_ = nullptr;

View File

@@ -24,7 +24,8 @@ class Event : public Wrappable<Event>,
v8::Local<v8::FunctionTemplate> prototype);
// Pass the sender and message to be replied.
void SetSenderAndMessage(content::WebContents* sender, IPC::Message* message);
void SetSenderAndMessage(content::RenderFrameHost* sender,
IPC::Message* message);
// event.PreventDefault().
void PreventDefault(v8::Isolate* isolate);
@@ -37,11 +38,14 @@ class Event : public Wrappable<Event>,
~Event() override;
// content::WebContentsObserver implementations:
void WebContentsDestroyed() override;
void RenderFrameDeleted(content::RenderFrameHost* rfh) override;
void RenderFrameHostChanged(content::RenderFrameHost* old_rfh,
content::RenderFrameHost* new_rfh) override;
void FrameDeleted(content::RenderFrameHost* rfh) override;
private:
// Replyer for the synchronous messages.
content::WebContents* sender_;
content::RenderFrameHost* sender_;
IPC::Message* message_;
DISALLOW_COPY_AND_ASSIGN(Event);

View File

@@ -39,11 +39,10 @@ v8::Local<v8::Object> CreateEventObject(v8::Isolate* isolate) {
namespace internal {
v8::Local<v8::Object> CreateJSEvent(
v8::Isolate* isolate,
v8::Local<v8::Object> object,
content::WebContents* sender,
IPC::Message* message) {
v8::Local<v8::Object> CreateJSEvent(v8::Isolate* isolate,
v8::Local<v8::Object> object,
content::RenderFrameHost* sender,
IPC::Message* message) {
v8::Local<v8::Object> event;
bool use_native_event = sender && message;

View File

@@ -11,7 +11,7 @@
#include "native_mate/wrappable.h"
namespace content {
class WebContents;
class RenderFrameHost;
}
namespace IPC {
@@ -24,7 +24,7 @@ namespace internal {
v8::Local<v8::Object> CreateJSEvent(v8::Isolate* isolate,
v8::Local<v8::Object> object,
content::WebContents* sender,
content::RenderFrameHost* sender,
IPC::Message* message);
v8::Local<v8::Object> CreateCustomEvent(
v8::Isolate* isolate,
@@ -74,9 +74,9 @@ class EventEmitter : public Wrappable<T> {
}
// this.emit(name, new Event(sender, message), args...);
template<typename... Args>
template <typename... Args>
bool EmitWithSender(const base::StringPiece& name,
content::WebContents* sender,
content::RenderFrameHost* sender,
IPC::Message* message,
const Args&... args) {
v8::Locker locker(isolate());

View File

@@ -10,6 +10,7 @@
#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"
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/atom_quota_permission_context.h"
@@ -318,6 +319,11 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
web_contents, command_line);
SessionPreferences::AppendExtraCommandLineSwitches(
web_contents->GetBrowserContext(), command_line);
auto context_id = atom::api::WebContents::GetIDForContents(
web_contents);
command_line->AppendSwitchASCII(switches::kContextId,
base::IntToString(context_id));
}
}
@@ -442,7 +448,6 @@ void AtomBrowserClient::SiteInstanceDeleting(
brightray::BrowserMainParts* AtomBrowserClient::OverrideCreateBrowserMainParts(
const content::MainFunctionParams&) {
v8::V8::Initialize(); // Init V8 before creating main parts.
return new AtomBrowserMainParts;
}

View File

@@ -16,6 +16,7 @@
#include "atom/browser/net/atom_network_delegate.h"
#include "atom/browser/net/atom_url_request_job_factory.h"
#include "atom/browser/net/http_protocol_handler.h"
#include "atom/browser/net/resolve_proxy_helper.h"
#include "atom/browser/web_view_manager.h"
#include "atom/common/atom_version.h"
#include "atom/common/chrome_version.h"
@@ -226,6 +227,14 @@ AtomBlobReader* AtomBrowserContext::GetBlobReader() {
return blob_reader_.get();
}
ResolveProxyHelper* AtomBrowserContext::GetResolveProxyHelper() {
if (!resolve_proxy_helper_.get()) {
resolve_proxy_helper_ =
base::MakeRefCounted<ResolveProxyHelper>(url_request_context_getter());
}
return resolve_proxy_helper_.get();
}
// static
scoped_refptr<AtomBrowserContext> AtomBrowserContext::From(
const std::string& partition, bool in_memory,

View File

@@ -18,6 +18,7 @@ class AtomBlobReader;
class AtomDownloadManagerDelegate;
class AtomNetworkDelegate;
class AtomPermissionManager;
class ResolveProxyHelper;
class WebViewManager;
class AtomBrowserContext : public brightray::BrowserContext {
@@ -51,6 +52,8 @@ class AtomBrowserContext : public brightray::BrowserContext {
// brightray::BrowserContext:
void RegisterPrefs(PrefRegistrySimple* pref_registry) override;
ResolveProxyHelper* GetResolveProxyHelper();
AtomBlobReader* GetBlobReader();
AtomCookieDelegate* cookie_delegate() const {
return cookie_delegate_.get();
@@ -62,6 +65,7 @@ class AtomBrowserContext : public brightray::BrowserContext {
~AtomBrowserContext() override;
private:
scoped_refptr<ResolveProxyHelper> resolve_proxy_helper_;
std::unique_ptr<AtomDownloadManagerDelegate> download_manager_delegate_;
std::unique_ptr<WebViewManager> guest_manager_;
std::unique_ptr<AtomPermissionManager> permission_manager_;

View File

@@ -151,6 +151,14 @@ void AtomBrowserMainParts::PostEarlyInitialization() {
// Wrap the uv loop with global env.
node_bindings_->set_uv_env(env);
// We already initialized the feature list in
// brightray::BrowserMainParts::PreEarlyInitialization(), but
// the user JS script would not have had a chance to alter the command-line
// switches at that point. Lets reinitialize it here to pick up the
// command-line changes.
base::FeatureList::ClearInstanceForTesting();
brightray::BrowserMainParts::InitializeFeatureList();
}
int AtomBrowserMainParts::PreCreateThreads() {

View File

@@ -108,14 +108,13 @@ void Browser::SetVersion(const std::string& version) {
}
std::string Browser::GetName() const {
std::string ret = name_override_;
std::string ret = brightray::GetOverriddenApplicationName();
if (ret.empty())
ret = GetExecutableFileProductName();
return ret;
}
void Browser::SetName(const std::string& name) {
name_override_ = name;
brightray::OverrideApplicationName(name);
}

View File

@@ -273,8 +273,6 @@ class Browser : public WindowListObserver {
// The browser is being shutdown.
bool is_shutdown_;
std::string name_override_;
int badge_count_ = 0;
#if defined(OS_MACOSX)

View File

@@ -77,6 +77,11 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
}
}
// No other app was found set it to none instead of setting it back to itself.
if ([identifier isEqualToString:(__bridge NSString*)other]) {
other = base::mac::NSToCFCast(@"None");
}
OSStatus return_code = LSSetDefaultHandlerForURLScheme(protocol_cf, other);
return return_code == noErr;
}
@@ -210,6 +215,65 @@ Browser::LoginItemSettings Browser::GetLoginItemSettings(
return settings;
}
// copied from GetLoginItemForApp in base/mac/mac_util.mm
LSSharedFileListItemRef GetLoginItemForApp() {
base::ScopedCFTypeRef<LSSharedFileListRef> login_items(
LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL));
if (!login_items.get()) {
LOG(ERROR) << "Couldn't get a Login Items list.";
return NULL;
}
base::scoped_nsobject<NSArray> login_items_array(
base::mac::CFToNSCast(LSSharedFileListCopySnapshot(login_items, NULL)));
NSURL* url = [NSURL fileURLWithPath:[base::mac::MainBundle() bundlePath]];
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<CFURLRef> item_url(item_url_ref);
if (CFEqual(item_url, url)) {
CFRetain(item);
return item;
}
}
}
return NULL;
}
void RemoveFromLoginItems() {
base::ScopedCFTypeRef<LSSharedFileListRef> list(
LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL));
if (!list) {
LOG(ERROR) << "Unable to access shared file list";
return;
}
if (GetLoginItemForApp() != NULL) {
base::scoped_nsobject<NSArray> login_items_array(
base::mac::CFToNSCast(LSSharedFileListCopySnapshot(list, NULL)));
if (!login_items_array) {
LOG(ERROR) << "No items in list of auto-loaded apps";
return;
}
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<CFURLRef> url(url_ref);
if ([[base::mac::CFToNSCast(url.get()) path]
hasPrefix:[[NSBundle mainBundle] bundlePath]])
LSSharedFileListItemRemove(list, item);
}
}
}
}
void Browser::SetLoginItemSettings(LoginItemSettings settings) {
#if defined(MAS_BUILD)
platform_util::SetLoginItemEnabled(settings.open_at_login);
@@ -217,7 +281,7 @@ void Browser::SetLoginItemSettings(LoginItemSettings settings) {
if (settings.open_at_login)
base::mac::AddToLoginItems(settings.open_as_hidden);
else
base::mac::RemoveFromLoginItems();
RemoveFromLoginItems();
#endif
}

View File

@@ -6,6 +6,7 @@
#include <unistd.h>
#include <uv.h>
#include <iostream>
#include <utility>
#include "base/bind.h"
#include "device/bluetooth/dbus/dbus_thread_manager_linux.h"
@@ -23,7 +24,7 @@ std::string get_executable_basename() {
if (!uv_exepath(buf, &buf_size)) {
rv = strrchr(static_cast<const char*>(buf), '/') + 1;
}
return std::move(rv);
return rv;
}
} // namespace
@@ -32,39 +33,37 @@ namespace atom {
PowerObserverLinux::PowerObserverLinux()
: lock_owner_name_(get_executable_basename()), weak_ptr_factory_(this) {
auto dbus_thread_manager = bluez::DBusThreadManagerLinux::Get();
if (dbus_thread_manager) {
bus_ = dbus_thread_manager->GetSystemBus();
if (bus_) {
logind_ = bus_->GetObjectProxy(kLogindServiceName,
dbus::ObjectPath(kLogindObjectPath));
logind_->WaitForServiceToBeAvailable(
base::Bind(&PowerObserverLinux::OnLoginServiceAvailable,
weak_ptr_factory_.GetWeakPtr()));
} else {
LOG(WARNING) << "Failed to get system bus connection";
}
} else {
LOG(WARNING) << "DBusThreadManagerLinux instance isn't available";
auto* bus = bluez::DBusThreadManagerLinux::Get()->GetSystemBus();
if (!bus) {
LOG(WARNING) << "Failed to get system bus connection";
return;
}
// set up the logind proxy
const auto weakThis = weak_ptr_factory_.GetWeakPtr();
logind_ = bus->GetObjectProxy(kLogindServiceName,
dbus::ObjectPath(kLogindObjectPath));
logind_->ConnectToSignal(
kLogindManagerInterface, "PrepareForShutdown",
base::BindRepeating(&PowerObserverLinux::OnPrepareForShutdown, weakThis),
base::BindRepeating(&PowerObserverLinux::OnSignalConnected, weakThis));
logind_->ConnectToSignal(
kLogindManagerInterface, "PrepareForSleep",
base::BindRepeating(&PowerObserverLinux::OnPrepareForSleep, weakThis),
base::BindRepeating(&PowerObserverLinux::OnSignalConnected, weakThis));
logind_->WaitForServiceToBeAvailable(base::BindRepeating(
&PowerObserverLinux::OnLoginServiceAvailable, weakThis));
}
PowerObserverLinux::~PowerObserverLinux() = default;
void PowerObserverLinux::OnLoginServiceAvailable(bool service_available) {
if (!service_available) {
LOG(WARNING) << kLogindServiceName << " not available";
return;
}
// Connect to PrepareForShutdown/PrepareForSleep signals
logind_->ConnectToSignal(kLogindManagerInterface, "PrepareForShutdown",
base::Bind(&PowerObserverLinux::OnPrepareForShutdown,
weak_ptr_factory_.GetWeakPtr()),
base::Bind(&PowerObserverLinux::OnSignalConnected,
weak_ptr_factory_.GetWeakPtr()));
logind_->ConnectToSignal(kLogindManagerInterface, "PrepareForSleep",
base::Bind(&PowerObserverLinux::OnPrepareForSleep,
weak_ptr_factory_.GetWeakPtr()),
base::Bind(&PowerObserverLinux::OnSignalConnected,
weak_ptr_factory_.GetWeakPtr()));
// Take sleep inhibit lock
BlockSleep();
}
@@ -120,8 +119,10 @@ void PowerObserverLinux::SetShutdownHandler(base::Callback<bool()> handler) {
void PowerObserverLinux::OnInhibitResponse(base::ScopedFD* scoped_fd,
dbus::Response* response) {
dbus::MessageReader reader(response);
reader.PopFileDescriptor(scoped_fd);
if (response != nullptr) {
dbus::MessageReader reader(response);
reader.PopFileDescriptor(scoped_fd);
}
}
void PowerObserverLinux::OnPrepareForSleep(dbus::Signal* signal) {
@@ -156,7 +157,7 @@ void PowerObserverLinux::OnPrepareForShutdown(dbus::Signal* signal) {
}
}
void PowerObserverLinux::OnSignalConnected(const std::string& interface,
void PowerObserverLinux::OnSignalConnected(const std::string& /*interface*/,
const std::string& signal,
bool success) {
LOG_IF(WARNING, !success) << "Failed to connect to " << signal;

View File

@@ -19,6 +19,7 @@ namespace atom {
class PowerObserverLinux : public base::PowerObserver {
public:
PowerObserverLinux();
~PowerObserverLinux() override;
protected:
void BlockSleep();
@@ -39,7 +40,6 @@ class PowerObserverLinux : public base::PowerObserver {
base::Callback<bool()> should_shutdown_;
scoped_refptr<dbus::Bus> bus_;
scoped_refptr<dbus::ObjectProxy> logind_;
std::string lock_owner_name_;
base::ScopedFD sleep_lock_;

View File

@@ -7,14 +7,23 @@
#include "atom/browser/native_browser_view.h"
#include "atom/browser/api/atom_api_web_contents.h"
#include "brightray/browser/inspectable_web_contents_view.h"
#include "brightray/browser/inspectable_web_contents.h"
namespace atom {
NativeBrowserView::NativeBrowserView(
brightray::InspectableWebContentsView* web_contents_view)
: web_contents_view_(web_contents_view) {}
brightray::InspectableWebContents* inspectable_web_contents)
: inspectable_web_contents_(inspectable_web_contents) {}
NativeBrowserView::~NativeBrowserView() {}
brightray::InspectableWebContentsView*
NativeBrowserView::GetInspectableWebContentsView() {
return inspectable_web_contents_->GetView();
}
content::WebContents* NativeBrowserView::GetWebContents() {
return inspectable_web_contents_->GetWebContents();
}
} // namespace atom

View File

@@ -9,9 +9,11 @@
#include "atom/common/draggable_region.h"
#include "base/macros.h"
#include "content/public/browser/web_contents.h"
#include "third_party/skia/include/core/SkColor.h"
namespace brightray {
class InspectableWebContents;
class InspectableWebContentsView;
}
@@ -31,12 +33,15 @@ class NativeBrowserView {
virtual ~NativeBrowserView();
static NativeBrowserView* Create(
brightray::InspectableWebContentsView* web_contents_view);
brightray::InspectableWebContents* inspectable_web_contents);
brightray::InspectableWebContentsView* GetInspectableWebContentsView() {
return web_contents_view_;
brightray::InspectableWebContents* GetInspectableWebContents() {
return inspectable_web_contents_;
}
brightray::InspectableWebContentsView* GetInspectableWebContentsView();
content::WebContents* GetWebContents();
virtual void SetAutoResizeFlags(uint8_t flags) = 0;
virtual void SetBounds(const gfx::Rect& bounds) = 0;
virtual void SetBackgroundColor(SkColor color) = 0;
@@ -47,9 +52,9 @@ class NativeBrowserView {
protected:
explicit NativeBrowserView(
brightray::InspectableWebContentsView* web_contents_view);
brightray::InspectableWebContents* inspectable_web_contents);
brightray::InspectableWebContentsView* web_contents_view_;
brightray::InspectableWebContents* inspectable_web_contents_;
private:
DISALLOW_COPY_AND_ASSIGN(NativeBrowserView);

View File

@@ -17,12 +17,13 @@ namespace atom {
class NativeBrowserViewMac : public NativeBrowserView {
public:
explicit NativeBrowserViewMac(
brightray::InspectableWebContentsView* web_contents_view);
brightray::InspectableWebContents* inspectable_web_contents);
~NativeBrowserViewMac() override;
void SetAutoResizeFlags(uint8_t flags) override;
void SetBounds(const gfx::Rect& bounds) override;
void SetBackgroundColor(SkColor color) override;
void UpdateDraggableRegions(
const std::vector<gfx::Rect>& system_drag_exclude_areas) override;

View File

@@ -4,6 +4,7 @@
#include "atom/browser/native_browser_view_mac.h"
#include "brightray/browser/inspectable_web_contents.h"
#include "brightray/browser/inspectable_web_contents_view.h"
#include "skia/ext/skia_utils_mac.h"
#include "ui/gfx/geometry/rect.h"
@@ -156,8 +157,8 @@ const NSAutoresizingMaskOptions kDefaultAutoResizingMask =
namespace atom {
NativeBrowserViewMac::NativeBrowserViewMac(
brightray::InspectableWebContentsView* web_contents_view)
: NativeBrowserView(web_contents_view) {
brightray::InspectableWebContents* inspectable_web_contents)
: NativeBrowserView(inspectable_web_contents) {
auto* view = GetInspectableWebContentsView()->GetNativeView();
view.autoresizingMask = kDefaultAutoResizingMask;
}
@@ -193,62 +194,46 @@ void NativeBrowserViewMac::SetBackgroundColor(SkColor color) {
}
void NativeBrowserViewMac::UpdateDraggableRegions(
const std::vector<gfx::Rect>& system_drag_exclude_areas) {
NSView* webView = GetInspectableWebContentsView()->GetNativeView();
const std::vector<gfx::Rect>& drag_exclude_rects) {
NSView* web_view = GetWebContents()->GetNativeView();
NSView* inspectable_view = GetInspectableWebContentsView()->GetNativeView();
NSView* window_content_view = inspectable_view.superview;
const auto window_content_view_height = NSHeight(window_content_view.bounds);
NSInteger superViewHeight = NSHeight([webView.superview bounds]);
NSInteger webViewHeight = NSHeight([webView bounds]);
NSInteger webViewWidth = NSWidth([webView bounds]);
NSInteger webViewX = NSMinX([webView frame]);
NSInteger webViewY = 0;
// Apple's NSViews have their coordinate system originate at the bottom left,
// meaning that we need to be a bit smarter when it comes to calculating our
// current top offset
if (webViewHeight > superViewHeight) {
webViewY = std::abs(webViewHeight - superViewHeight - (std::abs(NSMinY([webView frame]))));
} else {
webViewY = superViewHeight - NSMaxY([webView frame]);
}
// Remove all DraggableRegionViews that are added last time.
// Note that [webView subviews] returns the view's mutable internal array and
// it should be copied to avoid mutating the original array while enumerating
// it.
base::scoped_nsobject<NSArray> subviews([[webView subviews] copy]);
for (NSView* subview in subviews.get())
if ([subview isKindOfClass:[DragRegionView class]])
// Remove all DragRegionViews that were added last time. Note that we need
// to copy the `subviews` array to avoid mutation during iteration.
base::scoped_nsobject<NSArray> subviews([[web_view subviews] copy]);
for (NSView* subview in subviews.get()) {
if ([subview isKindOfClass:[DragRegionView class]]) {
[subview removeFromSuperview];
}
}
// Create one giant NSView that is draggable.
base::scoped_nsobject<NSView> dragRegion(
[[DragRegionView alloc] initWithFrame:NSZeroRect]);
[dragRegion setFrame:NSMakeRect(0,
0,
webViewWidth,
webViewHeight)];
base::scoped_nsobject<NSView> drag_region_view(
[[DragRegionView alloc] initWithFrame:web_view.bounds]);
[web_view addSubview:drag_region_view];
// Then, on top of that, add "exclusion zones"
for (auto iter = system_drag_exclude_areas.begin();
iter != system_drag_exclude_areas.end();
++iter) {
base::scoped_nsobject<NSView> controlRegion(
[[ExcludeDragRegionView alloc] initWithFrame:NSZeroRect]);
[controlRegion setFrame:NSMakeRect(iter->x() - webViewX,
webViewHeight - iter->bottom() + webViewY,
iter->width(),
iter->height())];
[dragRegion addSubview:controlRegion];
}
for (const auto& rect : drag_exclude_rects) {
const auto window_content_view_exclude_rect =
NSMakeRect(rect.x(), window_content_view_height - rect.bottom(),
rect.width(), rect.height());
const auto drag_region_view_exclude_rect =
[window_content_view convertRect:window_content_view_exclude_rect
toView:drag_region_view];
// Add the DragRegion to the WebView
[webView addSubview:dragRegion];
base::scoped_nsobject<NSView> exclude_drag_region_view(
[[ExcludeDragRegionView alloc]
initWithFrame:drag_region_view_exclude_rect]);
[drag_region_view addSubview:exclude_drag_region_view];
}
}
// static
NativeBrowserView* NativeBrowserView::Create(
brightray::InspectableWebContentsView* web_contents_view) {
return new NativeBrowserViewMac(web_contents_view);
brightray::InspectableWebContents* inspectable_web_contents) {
return new NativeBrowserViewMac(inspectable_web_contents);
}
} // namespace atom

View File

@@ -12,8 +12,8 @@
namespace atom {
NativeBrowserViewViews::NativeBrowserViewViews(
brightray::InspectableWebContentsView* web_contents_view)
: NativeBrowserView(web_contents_view) {}
brightray::InspectableWebContents* inspectable_web_contents)
: NativeBrowserView(inspectable_web_contents) {}
NativeBrowserViewViews::~NativeBrowserViewViews() {}
@@ -25,12 +25,13 @@ void NativeBrowserViewViews::SetBounds(const gfx::Rect& bounds) {
void NativeBrowserViewViews::SetBackgroundColor(SkColor color) {
auto* view = GetInspectableWebContentsView()->GetView();
view->SetBackground(views::CreateSolidBackground(color));
view->SchedulePaint();
}
// static
NativeBrowserView* NativeBrowserView::Create(
brightray::InspectableWebContentsView* web_contents_view) {
return new NativeBrowserViewViews(web_contents_view);
brightray::InspectableWebContents* inspectable_web_contents) {
return new NativeBrowserViewViews(inspectable_web_contents);
}
} // namespace atom

View File

@@ -12,7 +12,7 @@ namespace atom {
class NativeBrowserViewViews : public NativeBrowserView {
public:
explicit NativeBrowserViewViews(
brightray::InspectableWebContentsView* web_contents_view);
brightray::InspectableWebContents* inspectable_web_contents);
~NativeBrowserViewViews() override;
uint8_t GetAutoResizeFlags() { return auto_resize_flags_; }

View File

@@ -4,6 +4,7 @@
#include "atom/browser/native_window.h"
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
@@ -47,10 +48,35 @@
#include "ui/gfx/font_render_params.h"
#endif
#if defined(OS_WIN)
#include "ui/base/win/shell.h"
#include "ui/display/win/screen_win.h"
#endif
DEFINE_WEB_CONTENTS_USER_DATA_KEY(atom::NativeWindowRelay);
namespace atom {
namespace {
#if defined(OS_WIN)
gfx::Size GetExpandedWindowSize(const NativeWindow* window, gfx::Size size) {
if (!window->transparent() || !ui::win::IsAeroGlassEnabled())
return size;
gfx::Size min_size = display::win::ScreenWin::ScreenToDIPSize(
window->GetAcceleratedWidget(), gfx::Size(64, 64));
// Some AMD drivers can't display windows that are less than 64x64 pixels,
// so expand them to be at least that size. http://crbug.com/286609
gfx::Size expanded(std::max(size.width(), min_size.width()),
std::max(size.height(), min_size.height()));
return expanded;
}
#endif
} // namespace
NativeWindow::NativeWindow(
brightray::InspectableWebContents* inspectable_web_contents,
const mate::Dictionary& options,
@@ -307,6 +333,21 @@ gfx::Size NativeWindow::GetMaximumSize() const {
return GetSizeConstraints().GetMaximumSize();
}
gfx::Size NativeWindow::GetContentMinimumSize() const {
return GetContentSizeConstraints().GetMinimumSize();
}
gfx::Size NativeWindow::GetContentMaximumSize() const {
gfx::Size maximum_size = GetContentSizeConstraints().GetMaximumSize();
#if defined(OS_WIN)
return GetContentSizeConstraints().HasMaximumSize()
? GetExpandedWindowSize(this, maximum_size)
: maximum_size;
#else
return maximum_size;
#endif
}
void NativeWindow::SetSheetOffset(const double offsetX, const double offsetY) {
sheet_offset_x_ = offsetX;
sheet_offset_y_ = offsetY;
@@ -362,7 +403,8 @@ void NativeWindow::MoveTabToNewWindow() {
void NativeWindow::ToggleTabBar() {
}
void NativeWindow::AddTabbedWindow(NativeWindow* window) {
bool NativeWindow::AddTabbedWindow(NativeWindow* window) {
return true; // for non-Mac platforms
}
void NativeWindow::SetVibrancy(const std::string& filename) {

View File

@@ -41,7 +41,7 @@ namespace gfx {
class Point;
class Rect;
class Size;
}
} // namespace gfx
namespace mate {
class Dictionary;
@@ -109,6 +109,8 @@ class NativeWindow : public base::SupportsUserData,
virtual gfx::Size GetMinimumSize() const;
virtual void SetMaximumSize(const gfx::Size& size);
virtual gfx::Size GetMaximumSize() const;
virtual gfx::Size GetContentMinimumSize() const;
virtual gfx::Size GetContentMaximumSize() const;
virtual void SetSheetOffset(const double offsetX, const double offsetY);
virtual double GetSheetOffsetX();
virtual double GetSheetOffsetY();
@@ -160,15 +162,14 @@ class NativeWindow : public base::SupportsUserData,
// Taskbar/Dock APIs.
enum ProgressState {
PROGRESS_NONE, // no progress, no marking
PROGRESS_INDETERMINATE, // progress, indeterminate
PROGRESS_ERROR, // progress, errored (red)
PROGRESS_PAUSED, // progress, paused (yellow)
PROGRESS_NORMAL, // progress, not marked (green)
PROGRESS_NONE, // no progress, no marking
PROGRESS_INDETERMINATE, // progress, indeterminate
PROGRESS_ERROR, // progress, errored (red)
PROGRESS_PAUSED, // progress, paused (yellow)
PROGRESS_NORMAL, // progress, not marked (green)
};
virtual void SetProgressBar(double progress,
const ProgressState state) = 0;
virtual void SetProgressBar(double progress, const ProgressState state) = 0;
virtual void SetOverlayIcon(const gfx::Image& overlay,
const std::string& description) = 0;
@@ -193,7 +194,7 @@ class NativeWindow : public base::SupportsUserData,
virtual void MergeAllWindows();
virtual void MoveTabToNewWindow();
virtual void ToggleTabBar();
virtual void AddTabbedWindow(NativeWindow* window);
virtual bool AddTabbedWindow(NativeWindow* window);
// Webview APIs.
virtual void FocusOnWebView();
@@ -230,14 +231,15 @@ class NativeWindow : public base::SupportsUserData,
virtual void HandleKeyboardEvent(
content::WebContents*,
const content::NativeWebKeyboardEvent& event) {}
virtual void ShowAutofillPopup(
content::RenderFrameHost* frame_host,
content::WebContents* web_contents,
const gfx::RectF& bounds,
const std::vector<base::string16>& values,
const std::vector<base::string16>& labels) {}
virtual void ShowAutofillPopup(content::RenderFrameHost* frame_host,
content::WebContents* web_contents,
const gfx::RectF& bounds,
const std::vector<base::string16>& values,
const std::vector<base::string16>& labels) {}
virtual void HideAutofillPopup(content::RenderFrameHost* frame_host) {}
virtual void UpdateDraggableRegionViews() {}
// Public API used by platform-dependent delegates and observers to send UI
// related notifications.
void NotifyWindowClosed();
@@ -268,13 +270,11 @@ class NativeWindow : public base::SupportsUserData,
const base::DictionaryValue& details);
void NotifyNewWindowForTab();
#if defined(OS_WIN)
#if defined(OS_WIN)
void NotifyWindowMessage(UINT message, WPARAM w_param, LPARAM l_param);
#endif
#endif
void AddObserver(NativeWindowObserver* obs) {
observers_.AddObserver(obs);
}
void AddObserver(NativeWindowObserver* obs) { observers_.AddObserver(obs); }
void RemoveObserver(NativeWindowObserver* obs) {
observers_.RemoveObserver(obs);
}
@@ -388,11 +388,11 @@ class NativeWindow : public base::SupportsUserData,
};
// This class provides a hook to get a NativeWindow from a WebContents.
class NativeWindowRelay :
public content::WebContentsUserData<NativeWindowRelay> {
class NativeWindowRelay
: public content::WebContentsUserData<NativeWindowRelay> {
public:
explicit NativeWindowRelay(base::WeakPtr<NativeWindow> window)
: key(UserDataKey()), window(window) {}
: key(UserDataKey()), window(window) {}
static void* UserDataKey() {
return content::WebContentsUserData<NativeWindowRelay>::UserDataKey();

View File

@@ -111,7 +111,7 @@ class NativeWindowMac : public NativeWindow,
void MergeAllWindows() override;
void MoveTabToNewWindow() override;
void ToggleTabBar() override;
void AddTabbedWindow(NativeWindow* window) override;
bool AddTabbedWindow(NativeWindow* window) override;
void SetVibrancy(const std::string& type) override;
void SetTouchBar(
@@ -127,7 +127,7 @@ class NativeWindowMac : public NativeWindow,
content::RenderViewHost* new_host) override;
// Refresh the DraggableRegion views.
void UpdateDraggableRegionViews() {
void UpdateDraggableRegionViews() override {
UpdateDraggableRegionViews(draggable_regions_);
}
@@ -213,6 +213,7 @@ class NativeWindowMac : public NativeWindow,
bool was_maximizable_;
bool was_movable_;
NSRect original_frame_;
NSInteger original_level_;
NSUInteger simple_fullscreen_mask_;
base::scoped_nsobject<NSColor> background_color_before_vibrancy_;

View File

@@ -31,6 +31,7 @@
#include "skia/ext/skia_utils_mac.h"
#include "third_party/skia/include/core/SkRegion.h"
#include "ui/gfx/skia_util.h"
#include "ui/gl/gpu_switching_manager.h"
namespace {
@@ -379,6 +380,7 @@ bool ScopedDisableResize::disable_resize_ = false;
// Set window style to hide the toolbar, otherwise the toolbar will show in
// fullscreen mode.
[window setTitlebarAppearsTransparent:NO];
shell_->SetStyleMask(true, NSFullSizeContentViewWindowMask);
}
}
@@ -396,6 +398,7 @@ bool ScopedDisableResize::disable_resize_ = false;
// Turn off the style for toolbar.
if (base::mac::IsAtLeastOS10_10() &&
shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
[window setTitlebarAppearsTransparent:YES];
shell_->SetStyleMask(false, NSFullSizeContentViewWindowMask);
}
}
@@ -727,10 +730,20 @@ enum {
// Custom window button methods
- (BOOL)windowShouldClose:(id)sender { return YES; }
- (void)performClose:(id)sender {
if (shell_->title_bar_style() == atom::NativeWindowMac::CUSTOM_BUTTONS_ON_HOVER)
if (shell_->title_bar_style() ==
atom::NativeWindowMac::CUSTOM_BUTTONS_ON_HOVER) {
[[self delegate] windowShouldClose:self];
else
} else if (shell_->IsSimpleFullScreen()) {
if([[self delegate] respondsToSelector:@selector(windowShouldClose:)]) {
if(![[self delegate] windowShouldClose:self]) return;
} else if([self respondsToSelector:@selector(windowShouldClose:)]) {
if(![self windowShouldClose:self]) return;
}
[self close];
} else
[super performClose:sender];
}
@@ -1044,6 +1057,10 @@ NativeWindowMac::NativeWindowMac(
RegisterInputEventObserver(
web_contents->GetWebContents()->GetRenderViewHost());
original_frame_ = [window_ frame];
original_level_ = [window_ level];
}
NativeWindowMac::~NativeWindowMac() {
@@ -1068,6 +1085,11 @@ void NativeWindowMac::Close() {
}
void NativeWindowMac::CloseImmediately() {
// Retain the child window before closing it. If the last reference to the
// NSWindow goes away inside -[NSWindow close], then bad stuff can happen.
// See e.g. http://crbug.com/616701.
base::scoped_nsobject<NSWindow> child_window(window_,
base::scoped_policy::RETAIN);
[window_ close];
}
@@ -1138,12 +1160,12 @@ bool NativeWindowMac::IsEnabled() {
void NativeWindowMac::SetEnabled(bool enable) {
if (enable) {
[window_ endSheet: [window_ attachedSheet]];
} else {
[window_ beginSheet: window_ completionHandler:^(NSModalResponse returnCode) {
NSLog(@"modal enabled");
return;
}];
} else {
[window_ endSheet: [window_ attachedSheet]];
}
}
@@ -1410,8 +1432,9 @@ void NativeWindowMac::SetSimpleFullScreen(bool simple_fullscreen) {
if (simple_fullscreen && !is_simple_fullscreen_) {
is_simple_fullscreen_ = true;
// Take note of the current window size
// Take note of the current window size and level
original_frame_ = [window frame];
original_level_ = [window level];
simple_fullscreen_options_ = [NSApp currentSystemPresentationOptions];
simple_fullscreen_mask_ = [window styleMask];
@@ -1427,6 +1450,13 @@ void NativeWindowMac::SetSimpleFullScreen(bool simple_fullscreen) {
NSRect fullscreenFrame = [window.screen frame];
// If our app has dock hidden, set the window level higher so another app's
// menu bar doesn't appear on top of our fullscreen app.
if ([[NSRunningApplication currentApplication] activationPolicy] !=
NSApplicationActivationPolicyRegular) {
window.level = NSPopUpMenuWindowLevel;
}
if ( !fullscreen_window_title() ) {
// Hide the titlebar
SetStyleMask(false, NSTitledWindowMask);
@@ -1461,6 +1491,7 @@ void NativeWindowMac::SetSimpleFullScreen(bool simple_fullscreen) {
}
[window setFrame:original_frame_ display: YES animate: YES];
window.level = original_level_;
[NSApp setPresentationOptions:simple_fullscreen_options_];
@@ -1677,10 +1708,14 @@ void NativeWindowMac::ToggleTabBar() {
}
}
void NativeWindowMac::AddTabbedWindow(NativeWindow* window) {
if ([window_ respondsToSelector:@selector(addTabbedWindow:ordered:)]) {
[window_ addTabbedWindow:window->GetNativeWindow() ordered:NSWindowAbove];
bool NativeWindowMac::AddTabbedWindow(NativeWindow* window) {
if (window_.get() == window->GetNativeWindow()) {
return false;
} else {
if ([window_ respondsToSelector:@selector(addTabbedWindow:ordered:)])
[window_ addTabbedWindow:window->GetNativeWindow() ordered:NSWindowAbove];
}
return true;
}
void NativeWindowMac::SetRenderWidgetHostOpaque(bool opaque) {
@@ -1712,6 +1747,7 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
[vibrant_view removeFromSuperview];
[window_ setVibrantView:nil];
ui::GpuSwitchingManager::SetTransparent(transparent());
return;
}
@@ -1719,9 +1755,12 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
SetRenderWidgetHostOpaque(false);
background_color_before_vibrancy_.reset([window_ backgroundColor]);
transparency_before_vibrancy_ = [window_ titlebarAppearsTransparent];
ui::GpuSwitchingManager::SetTransparent(true);
[window_ setTitlebarAppearsTransparent:YES];
[window_ setBackgroundColor:[NSColor clearColor]];
if (title_bar_style_ != NORMAL) {
[window_ setTitlebarAppearsTransparent:YES];
[window_ setBackgroundColor:[NSColor clearColor]];
}
NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view;
if (effect_view == nil) {
@@ -1971,25 +2010,20 @@ void NativeWindowMac::UpdateDraggableRegionViews(
// Draggable regions is implemented by having the whole web view draggable
// (mouseDownCanMoveWindow) and overlaying regions that are not draggable.
std::vector<gfx::Rect> system_drag_exclude_areas =
std::vector<gfx::Rect> drag_exclude_rects =
CalculateNonDraggableRegions(regions, webViewWidth, webViewHeight);
if (browser_view_) {
browser_view_->UpdateDraggableRegions(system_drag_exclude_areas);
browser_view_->UpdateDraggableRegions(drag_exclude_rects);
}
// Create and add a ControlRegionView for each region that needs to be
// excluded from the dragging.
for (std::vector<gfx::Rect>::const_iterator iter =
system_drag_exclude_areas.begin();
iter != system_drag_exclude_areas.end();
++iter) {
for (const auto& rect : drag_exclude_rects) {
base::scoped_nsobject<NSView> controlRegion(
[[ControlRegionView alloc] initWithFrame:NSZeroRect]);
[controlRegion setFrame:NSMakeRect(iter->x(),
webViewHeight - iter->bottom(),
iter->width(),
iter->height())];
[controlRegion setFrame:NSMakeRect(rect.x(), webViewHeight - rect.bottom(),
rect.width(), rect.height())];
[webView addSubview:controlRegion];
}

View File

@@ -608,6 +608,7 @@ void NativeWindowViews::SetResizable(bool resizable) {
// both the minimum and maximum size to the window size to achieve it.
if (resizable) {
SetContentSizeConstraints(old_size_constraints_);
SetMaximizable(maximizable_);
} else {
old_size_constraints_ = GetContentSizeConstraints();
resizable_ = false;
@@ -1139,6 +1140,8 @@ void NativeWindowViews::OnWidgetActivationChanged(
// Hide menu bar when window is blured.
if (!active && menu_bar_autohide_ && menu_bar_visible_)
SetMenuBarVisibility(false);
menu_bar_alt_pressed_ = false;
}
void NativeWindowViews::OnWidgetBoundsChanged(
@@ -1336,7 +1339,7 @@ void NativeWindowViews::HandleKeyboardEvent(
if (event.GetType() == blink::WebInputEvent::kRawKeyDown &&
!IsAltKey(event) && IsAltModifier(event)) {
if (!menu_bar_visible_ &&
(menu_bar_->GetAcceleratorIndex(event.windows_key_code) != -1))
(menu_bar_->HasAccelerator(event.windows_key_code)))
SetMenuBarVisibility(true);
menu_bar_->ActivateAccelerator(event.windows_key_code);
return;
@@ -1444,12 +1447,9 @@ void NativeWindowViews::RegisterAccelerators(AtomMenuModel* menu_model) {
// Register accelerators with focus manager.
accelerator_util::GenerateAcceleratorTable(&accelerator_table_, menu_model);
accelerator_util::AcceleratorTable::const_iterator iter;
for (iter = accelerator_table_.begin();
iter != accelerator_table_.end();
++iter) {
for (const auto& iter : accelerator_table_) {
focus_manager->RegisterAccelerator(
iter->first, ui::AcceleratorManager::kNormalPriority, this);
iter.first, ui::AcceleratorManager::kNormalPriority, this);
}
}

View File

@@ -241,10 +241,21 @@ void URLRequestAsarJob::FetchMetaInfo(const base::FilePath& file_path,
meta_info->is_directory = file_info.is_directory;
}
}
// On Windows GetMimeTypeFromFile() goes to the registry. Thus it should be
// done in WorkerPool.
meta_info->mime_type_result =
net::GetMimeTypeFromFile(file_path, &meta_info->mime_type);
// We use GetWellKnownMimeTypeFromExtension() to ensure that configurations
// that may have been set by other programs on a user's machine don't affect
// the mime type returned (in particular, JS should always be
// (application/javascript). See https://crbug.com/797712. Using an accurate
// mime type is necessary at least for modules and sw, which enforce strict
// mime type requirements.
// TODO(deepak1556): Revert this when sw support is removed for file scheme.
base::FilePath::StringType file_extension = file_path.Extension();
if (file_extension.empty()) {
meta_info->mime_type_result = false;
} else {
meta_info->mime_type_result = net::GetWellKnownMimeTypeFromExtension(
file_extension.substr(1), &meta_info->mime_type);
}
}
void URLRequestAsarJob::DidFetchMetaInfo(const FileMetaInfo* meta_info) {

View File

@@ -227,22 +227,22 @@ AtomNetworkDelegate::~AtomNetworkDelegate() {
void AtomNetworkDelegate::SetSimpleListenerInIO(
SimpleEvent type,
const URLPatterns& patterns,
const SimpleListener& callback) {
URLPatterns patterns,
SimpleListener callback) {
if (callback.is_null())
simple_listeners_.erase(type);
else
simple_listeners_[type] = { patterns, callback };
simple_listeners_[type] = { std::move(patterns), std::move(callback) };
}
void AtomNetworkDelegate::SetResponseListenerInIO(
ResponseEvent type,
const URLPatterns& patterns,
const ResponseListener& callback) {
URLPatterns patterns,
ResponseListener callback) {
if (callback.is_null())
response_listeners_.erase(type);
else
response_listeners_[type] = { patterns, callback };
response_listeners_[type] = { std::move(patterns), std::move(callback) };
}
void AtomNetworkDelegate::SetDevToolsNetworkEmulationClientId(

View File

@@ -62,11 +62,11 @@ class AtomNetworkDelegate : public brightray::NetworkDelegate {
~AtomNetworkDelegate() override;
void SetSimpleListenerInIO(SimpleEvent type,
const URLPatterns& patterns,
const SimpleListener& callback);
URLPatterns patterns,
SimpleListener callback);
void SetResponseListenerInIO(ResponseEvent type,
const URLPatterns& patterns,
const ResponseListener& callback);
URLPatterns patterns,
ResponseListener callback);
void SetDevToolsNetworkEmulationClientId(const std::string& client_id);

View File

@@ -0,0 +1,85 @@
// Copyright (c) 2018 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/browser/net/resolve_proxy_helper.h"
#include "base/threading/thread_task_runner_handle.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
namespace atom {
ResolveProxyHelper::ResolveProxyHelper(net::URLRequestContextGetter* getter)
: context_getter_(getter),
original_thread_(base::ThreadTaskRunnerHandle::Get()) {}
ResolveProxyHelper::~ResolveProxyHelper() {
// Clear all pending requests if the ProxyService is still alive.
pending_requests_.clear();
}
void ResolveProxyHelper::ResolveProxy(const GURL& url,
const ResolveProxyCallback& callback) {
// Enqueue the pending request.
pending_requests_.push_back(PendingRequest(url, callback));
// If nothing is in progress, start.
if (pending_requests_.size() == 1)
StartPendingRequest();
}
void ResolveProxyHelper::SendProxyResult(const std::string& proxy) {
CHECK(!pending_requests_.empty());
const auto& completed_request = pending_requests_.front();
if (!completed_request.callback.is_null())
completed_request.callback.Run(proxy);
// Clear the current (completed) request.
pending_requests_.pop_front();
// Start the next request.
if (!pending_requests_.empty())
StartPendingRequest();
}
void ResolveProxyHelper::StartPendingRequest() {
auto& request = pending_requests_.front();
context_getter_->GetNetworkTaskRunner()->PostTask(
FROM_HERE,
base::BindOnce(&ResolveProxyHelper::StartPendingRequestInIO,
base::Unretained(this), request.url, request.pac_req));
}
void ResolveProxyHelper::OnResolveProxyCompleted(int result) {
std::string proxy;
if (result == net::OK)
proxy = proxy_info_.ToPacString();
original_thread_->PostTask(
FROM_HERE, base::BindOnce(&ResolveProxyHelper::SendProxyResult,
base::Unretained(this), proxy));
}
void ResolveProxyHelper::StartPendingRequestInIO(
const GURL& url,
net::ProxyService::PacRequest* pac_req) {
// Verify the request wasn't started yet.
DCHECK(nullptr == pac_req);
auto proxy_service = context_getter_->GetURLRequestContext()->proxy_service();
// Start the request.
int result = proxy_service->ResolveProxy(
url, std::string(), &proxy_info_,
base::Bind(&ResolveProxyHelper::OnResolveProxyCompleted,
base::Unretained(this)),
&pac_req, nullptr, net::NetLogWithSource());
// Completed synchronously.
if (result != net::ERR_IO_PENDING)
OnResolveProxyCompleted(result);
}
} // namespace atom

View File

@@ -0,0 +1,59 @@
// Copyright (c) 2018 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_NET_RESOLVE_PROXY_HELPER_H_
#define ATOM_BROWSER_NET_RESOLVE_PROXY_HELPER_H_
#include <deque>
#include <string>
#include "base/memory/ref_counted.h"
#include "net/proxy/proxy_service.h"
#include "url/gurl.h"
namespace net {
class URLRequestContextGetter;
}
namespace atom {
class ResolveProxyHelper
: public base::RefCountedThreadSafe<ResolveProxyHelper> {
public:
using ResolveProxyCallback = base::Callback<void(std::string)>;
explicit ResolveProxyHelper(net::URLRequestContextGetter* getter);
void ResolveProxy(const GURL& url, const ResolveProxyCallback& callback);
private:
friend class base::RefCountedThreadSafe<ResolveProxyHelper>;
struct PendingRequest {
public:
PendingRequest(const GURL& url, const ResolveProxyCallback& callback)
: url(url), callback(callback), pac_req(nullptr) {}
GURL url;
ResolveProxyCallback callback;
net::ProxyService::PacRequest* pac_req;
};
~ResolveProxyHelper();
void StartPendingRequest();
void StartPendingRequestInIO(const GURL& request,
net::ProxyService::PacRequest* pac_req);
void SendProxyResult(const std::string& proxy);
void OnResolveProxyCompleted(int result);
net::ProxyInfo proxy_info_;
std::deque<PendingRequest> pending_requests_;
scoped_refptr<net::URLRequestContextGetter> context_getter_;
scoped_refptr<base::SingleThreadTaskRunner> original_thread_;
DISALLOW_COPY_AND_ASSIGN(ResolveProxyHelper);
};
} // namespace atom
#endif // ATOM_BROWSER_NET_RESOLVE_PROXY_HELPER_H_

View File

@@ -4,6 +4,8 @@
#include "atom/browser/node_debugger.h"
#include <string>
#include "base/command_line.h"
#include "base/strings/utf_string_conversions.h"
#include "libplatform/libplatform.h"
@@ -28,10 +30,15 @@ void NodeDebugger::Start(node::NodePlatform* platform) {
node::DebugOptions options;
for (auto& arg : base::CommandLine::ForCurrentProcess()->argv()) {
#if defined(OS_WIN)
options.ParseOption("Electron", base::UTF16ToUTF8(arg));
const std::string nice_arg = base::UTF16ToUTF8(arg);
#else
options.ParseOption("Electron", arg);
const std::string& nice_arg = arg;
#endif
// Stop handling arguments after a "--" to be consistent with Chromium
if (nice_arg == "--")
break;
options.ParseOption("Electron", nice_arg);
}
if (options.inspector_enabled()) {

View File

@@ -17,9 +17,9 @@
<key>CFBundleIconFile</key>
<string>electron.icns</string>
<key>CFBundleVersion</key>
<string>1.8.2</string>
<string>2.0.16</string>
<key>CFBundleShortVersionString</key>
<string>1.8.2</string>
<string>2.0.16</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key>

View File

@@ -56,8 +56,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,8,2,2
PRODUCTVERSION 1,8,2,2
FILEVERSION 2,0,16,0
PRODUCTVERSION 2,0,16,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -74,12 +74,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "GitHub, Inc."
VALUE "FileDescription", "Electron"
VALUE "FileVersion", "1.8.2"
VALUE "FileVersion", "2.0.16"
VALUE "InternalName", "electron.exe"
VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved."
VALUE "OriginalFilename", "electron.exe"
VALUE "ProductName", "Electron"
VALUE "ProductVersion", "1.8.2"
VALUE "ProductVersion", "2.0.16"
VALUE "SquirrelAwareVersion", "1"
END
END

View File

@@ -91,7 +91,9 @@ bool TriggerAcceleratorTableCommand(AcceleratorTable* table,
if (base::ContainsKey(*table, accelerator)) {
const accelerator_util::MenuItem& item = (*table)[accelerator];
if (item.model->IsEnabledAt(item.position)) {
item.model->ActivatedAt(item.position);
const auto event_flags =
accelerator.MaskOutKeyEventFlags(accelerator.modifiers());
item.model->ActivatedAt(item.position, event_flags);
return true;
}
}

View File

@@ -9,12 +9,15 @@
#include "base/logging.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "content/public/browser/browser_thread.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/accelerators/platform_accelerator_cocoa.h"
#include "ui/base/l10n/l10n_util_mac.h"
#include "ui/events/cocoa/cocoa_event_utils.h"
#include "ui/gfx/image/image.h"
using content::BrowserThread;
namespace {
struct Role {
@@ -120,7 +123,9 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
[menu_ cancelTracking];
isMenuOpen_ = NO;
model_->MenuWillClose();
closeCallback.Run();
if (!closeCallback.is_null()) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, closeCallback);
}
}
}
@@ -335,7 +340,11 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
if (isMenuOpen_) {
isMenuOpen_ = NO;
model_->MenuWillClose();
closeCallback.Run();
// Post async task so that itemSelected runs before the close callback
// deletes the controller from the map which deallocates it
if (!closeCallback.is_null()) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, closeCallback);
}
}
}

View File

@@ -15,72 +15,99 @@
#include "base/strings/sys_string_conversions.h"
@interface PopUpButtonHandler : NSObject
@property (nonatomic, strong) NSSavePanel *savePanel;
@property (nonatomic, strong) NSArray *fileTypes;
- (instancetype)initWithPanel:(NSSavePanel *)panel andTypes:(NSArray *)types;
@property(nonatomic, assign) NSSavePanel* savePanel;
@property(nonatomic, strong) NSArray* fileTypesList;
- (instancetype)initWithPanel:(NSSavePanel*)panel
andTypesList:(NSArray*)typesList;
- (void)selectFormat:(id)sender;
@end
@implementation PopUpButtonHandler
- (instancetype)initWithPanel:(NSSavePanel *)panel andTypes:(NSArray *)types {
- (instancetype)initWithPanel:(NSSavePanel*)panel
andTypesList:(NSArray*)typesList {
self = [super init];
if (self) {
_savePanel = panel;
_fileTypes = types;
[self setSavePanel:panel];
[self setFileTypesList:typesList];
}
return self;
}
- (void)selectFormat:(id)sender {
NSPopUpButton *button = (NSPopUpButton *)sender;
NSPopUpButton* button = (NSPopUpButton*)sender;
NSInteger selectedItemIndex = [button indexOfSelectedItem];
NSString *nameFieldString = [[self savePanel] nameFieldStringValue];
NSString *trimmedNameFieldString = [nameFieldString stringByDeletingPathExtension];
NSString *extension = [[self fileTypes] objectAtIndex: selectedItemIndex];
NSArray* list = [self fileTypesList];
NSArray* fileTypes = [list objectAtIndex:selectedItemIndex];
NSString *nameFieldStringWithExt = [NSString stringWithFormat:@"%@.%@", trimmedNameFieldString, extension];
[[self savePanel] setNameFieldStringValue:nameFieldStringWithExt];
[[self savePanel] setAllowedFileTypes:@[extension]];
// If we meet a '*' file extension, we allow all the file types and no
// need to set the specified file types.
if ([fileTypes count] == 0 || [fileTypes containsObject:@"*"])
[[self savePanel] setAllowedFileTypes:nil];
else
[[self savePanel] setAllowedFileTypes:fileTypes];
}
@end
// Manages the PopUpButtonHandler.
@interface AtomAccessoryView : NSView
@end
@implementation AtomAccessoryView
- (void)dealloc {
auto* popupButton = static_cast<NSPopUpButton*>([[self subviews] objectAtIndex: 1]);
[[popupButton target] release];
[super dealloc];
}
@end
namespace file_dialog {
namespace {
static PopUpButtonHandler *popUpButtonHandler;
void SetAllowedFileTypes(NSSavePanel* dialog, const Filters& filters) {
NSMutableSet* file_type_set = [NSMutableSet set];
for (size_t i = 0; i < filters.size(); ++i) {
const Filter& filter = filters[i];
for (size_t j = 0; j < filter.second.size(); ++j) {
// If we meet a '*' file extension, we allow all the file types and no
// need to set the specified file types.
NSMutableArray* file_types_list = [NSMutableArray array];
NSMutableArray* filter_names = [NSMutableArray array];
if (filter.second[j] == "*") {
[dialog setAllowsOtherFileTypes:YES];
return;
}
base::ScopedCFTypeRef<CFStringRef> ext_cf(
base::SysUTF8ToCFStringRef(filter.second[j]));
// Create array to keep file types and their name.
for (const Filter& filter : filters) {
NSMutableSet* file_type_set = [NSMutableSet set];
base::ScopedCFTypeRef<CFStringRef> name_cf(
base::SysUTF8ToCFStringRef(filter.first));
[filter_names addObject:base::mac::CFToNSCast(name_cf.get())];
for (const std::string& ext : filter.second) {
base::ScopedCFTypeRef<CFStringRef> ext_cf(base::SysUTF8ToCFStringRef(ext));
[file_type_set addObject:base::mac::CFToNSCast(ext_cf.get())];
}
[file_types_list addObject:[file_type_set allObjects]];
}
// Passing empty array to setAllowedFileTypes will cause exception.
NSArray* file_types = nil;
if ([file_type_set count])
file_types = [file_type_set allObjects];
NSUInteger count = [file_types_list count];
if (count > 0) {
file_types = [[file_types_list objectAtIndex:0] allObjects];
// If we meet a '*' file extension, we allow all the file types and no
// need to set the specified file types.
if ([file_types count] == 0 || [file_types containsObject:@"*"])
file_types = nil;
}
[dialog setAllowedFileTypes:file_types];
if (!popUpButtonHandler)
popUpButtonHandler = [[PopUpButtonHandler alloc] initWithPanel:dialog andTypes:file_types];
if (count <= 1)
return; // don't add file format picker
// add file format picker
NSView *accessoryView = [[NSView alloc] initWithFrame:NSMakeRect(0.0, 0.0, 200, 32.0)];
NSTextField *label = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 60, 22)];
// Add file format picker.
AtomAccessoryView* accessoryView =
[[AtomAccessoryView alloc] initWithFrame:NSMakeRect(0.0, 0.0, 200, 32.0)];
NSTextField* label =
[[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 60, 22)];
[label setEditable:NO];
[label setStringValue:@"Format:"];
@@ -88,15 +115,18 @@ void SetAllowedFileTypes(NSSavePanel* dialog, const Filters& filters) {
[label setBezeled:NO];
[label setDrawsBackground:NO];
NSPopUpButton *popupButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(50.0, 2, 140, 22.0) pullsDown:NO];
[popupButton addItemsWithTitles:file_types];
NSPopUpButton* popupButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(50.0, 2, 140, 22.0)
pullsDown:NO];
PopUpButtonHandler* popUpButtonHandler = [[PopUpButtonHandler alloc] initWithPanel:dialog
andTypesList:file_types_list];
[popupButton addItemsWithTitles:filter_names];
[popupButton setTarget:popUpButtonHandler];
[popupButton setAction:@selector(selectFormat:)];
[accessoryView addSubview:label];
[accessoryView addSubview:popupButton];
[accessoryView addSubview:[label autorelease]];
[accessoryView addSubview:[popupButton autorelease]];
[dialog setAccessoryView:accessoryView];
[dialog setAccessoryView:[accessoryView autorelease]];
}
void SetupDialog(NSSavePanel* dialog,
@@ -118,6 +148,7 @@ void SetupDialog(NSSavePanel* dialog,
NSString* default_dir = nil;
NSString* default_filename = nil;
if (!settings.default_path.empty()) {
base::ThreadRestrictions::ScopedAllowIO allow_io;
if (base::DirectoryExists(settings.default_path)) {
default_dir = base::SysUTF8ToNSString(settings.default_path.value());
} else {
@@ -283,8 +314,9 @@ void ShowOpenDialog(const DialogSettings& settings,
if (!settings.parent_window || !settings.parent_window->GetNativeWindow() ||
settings.force_detached) {
int chosen = [dialog runModal];
OpenDialogCompletion(chosen, dialog, settings, callback);
[dialog beginWithCompletionHandler:^(NSInteger chosen) {
OpenDialogCompletion(chosen, dialog, settings, callback);
}];
} else {
NSWindow* window = settings.parent_window->GetNativeWindow();
[dialog beginSheetModalForWindow:window
@@ -343,8 +375,9 @@ void ShowSaveDialog(const DialogSettings& settings,
if (!settings.parent_window || !settings.parent_window->GetNativeWindow() ||
settings.force_detached) {
int chosen = [dialog runModal];
SaveDialogCompletion(chosen, dialog, settings, callback);
[dialog beginWithCompletionHandler:^(NSInteger chosen) {
SaveDialogCompletion(chosen, dialog, settings, callback);
}];
} else {
NSWindow* window = settings.parent_window->GetNativeWindow();
[dialog beginSheetModalForWindow:window

View File

@@ -39,7 +39,8 @@ class GtkMessageBox : public NativeWindowObserver {
const std::string& message,
const std::string& detail,
const std::string& checkbox_label,
bool checkbox_checked)
bool checkbox_checked,
const gfx::ImageSkia& icon)
: cancel_id_(cancel_id),
checkbox_checked_(false),
parent_(static_cast<NativeWindow*>(parent_window)) {
@@ -56,6 +57,21 @@ class GtkMessageBox : public NativeWindowObserver {
if (!title.empty())
gtk_window_set_title(GTK_WINDOW(dialog_), title.c_str());
if (!icon.isNull()) {
// No easy way to obtain this programmatically, but GTK+'s docs
// define GTK_ICON_SIZE_DIALOG to be 48 pixels
static constexpr int pixel_width = 48;
static constexpr int pixel_height = 48;
GdkPixbuf* pixbuf = libgtkui::GdkPixbufFromSkBitmap(*icon.bitmap());
GdkPixbuf* scaled_pixbuf = gdk_pixbuf_scale_simple(
pixbuf, pixel_width, pixel_height, GDK_INTERP_BILINEAR);
GtkWidget* w = gtk_image_new_from_pixbuf(scaled_pixbuf);
gtk_message_dialog_set_image(GTK_MESSAGE_DIALOG(dialog_), w);
gtk_widget_show(w);
g_clear_pointer(&scaled_pixbuf, gdk_pixbuf_unref);
g_clear_pointer(&pixbuf, gdk_pixbuf_unref);
}
if (!checkbox_label.empty()) {
GtkWidget* message_area =
gtk_message_dialog_get_message_area(GTK_MESSAGE_DIALOG(dialog_));
@@ -66,15 +82,15 @@ class GtkMessageBox : public NativeWindowObserver {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),
checkbox_checked);
gtk_container_add(GTK_CONTAINER(message_area), check_button);
gtk_widget_show(check_button);
}
// Add buttons.
GtkDialog* dialog = GTK_DIALOG(dialog_);
for (size_t i = 0; i < buttons.size(); ++i) {
GtkWidget* button = gtk_dialog_add_button(
GTK_DIALOG(dialog_), TranslateToStock(i, buttons[i]), i);
if (static_cast<int>(i) == default_id)
gtk_widget_grab_focus(button);
gtk_dialog_add_button(dialog, TranslateToStock(i, buttons[i]), i);
}
gtk_dialog_set_default_response(dialog, default_id);
// Parent window.
if (parent_) {
@@ -122,7 +138,7 @@ class GtkMessageBox : public NativeWindowObserver {
}
void Show() {
gtk_widget_show_all(dialog_);
gtk_widget_show(dialog_);
// We need to call gtk_window_present after making the widgets visible to
// make sure window gets correctly raised and gets focus.
int time = ui::X11EventSource::GetInstance()->GetTimestamp();
@@ -195,9 +211,9 @@ int ShowMessageBox(NativeWindow* parent,
const std::string& title,
const std::string& message,
const std::string& detail,
const gfx::ImageSkia& /*icon*/) {
const gfx::ImageSkia& icon) {
return GtkMessageBox(parent, type, buttons, default_id, cancel_id, title,
message, detail, "", false)
message, detail, "", false, icon)
.RunSynchronous();
}
@@ -212,10 +228,10 @@ void ShowMessageBox(NativeWindow* parent,
const std::string& detail,
const std::string& checkbox_label,
bool checkbox_checked,
const gfx::ImageSkia& /*icon*/,
const gfx::ImageSkia& icon,
const MessageBoxCallback& callback) {
(new GtkMessageBox(parent, type, buttons, default_id, cancel_id, title,
message, detail, checkbox_label, checkbox_checked))
message, detail, checkbox_label, checkbox_checked, icon))
->RunAsynchronous(callback);
}
@@ -223,7 +239,8 @@ void ShowErrorBox(const base::string16& title, const base::string16& content) {
if (Browser::Get()->is_ready()) {
GtkMessageBox(nullptr, MESSAGE_BOX_TYPE_ERROR, {"OK"}, -1, 0, "Error",
base::UTF16ToUTF8(title).c_str(),
base::UTF16ToUTF8(content).c_str(), "", false)
base::UTF16ToUTF8(content).c_str(), "", false,
gfx::ImageSkia())
.RunSynchronous();
} else {
fprintf(stderr, ANSI_TEXT_BOLD ANSI_BACKGROUND_GRAY ANSI_FOREGROUND_RED

View File

@@ -96,11 +96,6 @@ NSAlert* CreateNSAlert(NativeWindow* parent_window,
NSArray* ns_buttons = [alert buttons];
int button_count = static_cast<int>([ns_buttons count]);
// Bind cancel id button to escape key if there is more than one button
if (button_count > 1 && cancel_id >= 0 && cancel_id < button_count) {
[[ns_buttons objectAtIndex:cancel_id] setKeyEquivalent:@"\e"];
}
if (default_id >= 0 && default_id < button_count) {
// Focus the button at default_id if the user opted to do so.
// The first button added gets set as the default selected.
@@ -109,6 +104,11 @@ NSAlert* CreateNSAlert(NativeWindow* parent_window,
[[ns_buttons objectAtIndex:default_id] setKeyEquivalent:@"\r"];
}
// Bind cancel id button to escape key if there is more than one button
if (button_count > 1 && cancel_id >= 0 && cancel_id < button_count) {
[[ns_buttons objectAtIndex:cancel_id] setKeyEquivalent:@"\e"];
}
if (!checkbox_label.empty()) {
alert.showsSuppressionButton = YES;
alert.suppressionButton.title = base::SysUTF8ToNSString(checkbox_label);

View File

@@ -40,9 +40,16 @@ const CGFloat kVerticalTitleMargin = 2;
@implementation StatusItemView
- (void)dealloc {
trayIcon_ = nil;
menuController_ = nil;
[super dealloc];
}
- (id)initWithImage:(NSImage*)image icon:(atom::TrayIconCocoa*)icon {
image_.reset([image copy]);
trayIcon_ = icon;
menuController_ = nil;
highlight_mode_ = atom::TrayIcon::HighlightMode::SELECTION;
forceHighlight_ = NO;
inMouseEventSequence_ = NO;
@@ -85,6 +92,7 @@ const CGFloat kVerticalTitleMargin = 2;
trackingArea_.reset();
}
[[NSStatusBar systemStatusBar] removeStatusItem:statusItem_];
[statusItem_ setView:nil];
statusItem_.reset();
}
@@ -98,7 +106,7 @@ const CGFloat kVerticalTitleMargin = 2;
// Draw the system bar background.
[statusItem_ drawStatusBarBackgroundInRect:self.bounds
withHighlight:[self isHighlighted]];
withHighlight:[self shouldHighlight]];
// Determine which image to use.
NSImage* image = image_.get();
@@ -230,8 +238,13 @@ const CGFloat kVerticalTitleMargin = 2;
return;
}
// check title_ being nil
NSString *title = @"";
if (title_)
title = title_;
attributedTitle_.reset([[NSMutableAttributedString alloc]
initWithString:title_
initWithString:title
attributes:attributes]);
//NSFontAttributeName:[NSFont menuBarFontOfSize:0],
@@ -384,6 +397,11 @@ const CGFloat kVerticalTitleMargin = 2;
return YES;
}
- (void)setNeedsDisplay:(BOOL)display {
[self updateAttributedTitle];
[super setNeedsDisplay:display];
}
- (BOOL)shouldHighlight {
switch (highlight_mode_) {
case atom::TrayIcon::HighlightMode::ALWAYS:
@@ -444,11 +462,18 @@ void TrayIconCocoa::SetContextMenu(AtomMenuModel* menu_model) {
// Substribe to MenuClosed event.
if (menu_model_)
menu_model_->RemoveObserver(this);
menu_model->AddObserver(this);
// Create native menu.
menu_.reset([[AtomMenuController alloc] initWithModel:menu_model
useDefaultAccelerator:NO]);
menu_model_ = menu_model;
if (menu_model) {
menu_model->AddObserver(this);
// Create native menu.
menu_.reset([[AtomMenuController alloc] initWithModel:menu_model
useDefaultAccelerator:NO]);
} else {
menu_.reset();
}
[status_item_view_ setMenuController:menu_.get()];
}

View File

@@ -7,6 +7,7 @@
#include "atom/browser/browser.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "brightray/common/application_info.h"
#include "chrome/browser/ui/libgtkui/app_indicator_icon.h"
#include "chrome/browser/ui/libgtkui/gtk_status_icon.h"
#include "ui/gfx/image/image.h"
@@ -32,16 +33,17 @@ void TrayIconGtk::SetImage(const gfx::Image& image) {
return;
}
base::string16 empty;
const auto toolTip = base::UTF8ToUTF16(brightray::GetApplicationName());
if (libgtkui::AppIndicatorIcon::CouldOpen()) {
++indicators_count;
icon_.reset(new libgtkui::AppIndicatorIcon(
base::StringPrintf(
"%s%d", Browser::Get()->GetName().c_str(), indicators_count),
image.AsImageSkia(),
empty));
toolTip));
} else {
icon_.reset(new libgtkui::Gtk2StatusIcon(image.AsImageSkia(), empty));
icon_.reset(new libgtkui::Gtk2StatusIcon(image.AsImageSkia(), toolTip));
}
icon_->set_delegate(this);
}

View File

@@ -104,11 +104,11 @@ gfx::Size FramelessView::CalculatePreferredSize() const {
}
gfx::Size FramelessView::GetMinimumSize() const {
return window_->GetContentSizeConstraints().GetMinimumSize();
return window_->GetContentMinimumSize();
}
gfx::Size FramelessView::GetMaximumSize() const {
return window_->GetContentSizeConstraints().GetMaximumSize();
return window_->GetContentMaximumSize();
}
const char* FramelessView::GetClassName() const {

View File

@@ -209,7 +209,9 @@ void GlobalMenuBarX11::SetMenu(AtomMenuModel* menu_model) {
DbusmenuMenuitem* root_item = menuitem_new();
menuitem_property_set(root_item, kPropertyLabel, "Root");
menuitem_property_set_bool(root_item, kPropertyVisible, true);
BuildMenuFromModel(menu_model, root_item);
if (menu_model != nullptr) {
BuildMenuFromModel(menu_model, root_item);
}
server_set_root(server_, root_item);
g_object_unref(root_item);

View File

@@ -4,9 +4,8 @@
#include "atom/browser/ui/views/menu_bar.h"
#if defined(USE_X11)
#include "gtk/gtk.h"
#endif
#include <memory>
#include <string>
#include "atom/browser/ui/views/menu_delegate.h"
#include "atom/browser/ui/views/submenu_button.h"
@@ -14,54 +13,18 @@
#include "ui/views/background.h"
#include "ui/views/layout/box_layout.h"
#if defined(USE_X11)
#include "chrome/browser/ui/libgtkui/gtk_util.h"
#endif
#if defined(OS_WIN)
#include "ui/gfx/color_utils.h"
#elif defined(USE_X11)
#include "chrome/browser/ui/libgtkui/skia_utils_gtk.h"
#endif
namespace atom {
namespace {
#if defined(USE_X11)
SkColor GdkRgbaToSkColor(const GdkRGBA& rgba) {
return SkColorSetARGB(rgba.alpha * 255, rgba.red * 255, rgba.green * 255,
rgba.blue * 255);
}
SkColor GetStyleContextFgColor(GtkStyleContext* style_context,
GtkStateFlags state) {
GdkRGBA rgba;
gtk_style_context_get_color(style_context, state, &rgba);
return GdkRgbaToSkColor(rgba);
}
SkColor GetStyleContextBgColor(GtkStyleContext* style_context,
GtkStateFlags state) {
GdkRGBA rgba;
gtk_style_context_get_background_color(style_context, state, &rgba);
return GdkRgbaToSkColor(rgba);
}
void GetMenuBarColor(SkColor* enabled,
SkColor* disabled,
SkColor* highlight,
SkColor* hover,
SkColor* background) {
GtkWidget* menu_bar = gtk_menu_bar_new();
GtkStyleContext* sc = gtk_widget_get_style_context(menu_bar);
*enabled = GetStyleContextFgColor(sc, GTK_STATE_FLAG_NORMAL);
*disabled = GetStyleContextFgColor(sc, GTK_STATE_FLAG_INSENSITIVE);
*highlight = GetStyleContextFgColor(sc, GTK_STATE_FLAG_SELECTED);
*hover = GetStyleContextFgColor(sc, GTK_STATE_FLAG_PRELIGHT);
*background = GetStyleContextBgColor(sc, GTK_STATE_FLAG_NORMAL);
gtk_widget_destroy(GTK_WIDGET(menu_bar));
}
#endif // USE_X11
const char kViewClassName[] = "ElectronMenuBar";
// Default color of the menu bar.
@@ -71,75 +34,70 @@ const SkColor kDefaultColor = SkColorSetARGB(255, 233, 233, 233);
MenuBar::MenuBar(NativeWindow* window)
: background_color_(kDefaultColor), menu_model_(NULL), window_(window) {
UpdateMenuBarColor();
RefreshColorCache();
UpdateViewColors();
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal));
}
MenuBar::~MenuBar() {}
void MenuBar::AddedToWidget() {
auto fm = GetFocusManager();
fm->AddFocusChangeListener(this);
// Note that we don't own fm -- this manages the _connection_
focus_manager_.reset(fm, [this](views::FocusManager* fm) {
fm->RemoveFocusChangeListener(this);
});
}
void MenuBar::RemovedFromWidget() {
focus_manager_.reset();
}
void MenuBar::SetMenu(AtomMenuModel* model) {
menu_model_ = model;
RemoveAllChildViews(true);
for (int i = 0; i < model->GetItemCount(); ++i) {
SubmenuButton* button =
new SubmenuButton(model->GetLabelAt(i), this, background_color_);
button->set_tag(i);
#if defined(USE_X11)
button->SetTextColor(views::Button::STATE_NORMAL, enabled_color_);
button->SetTextColor(views::Button::STATE_DISABLED, disabled_color_);
button->SetTextColor(views::Button::STATE_PRESSED, highlight_color_);
button->SetTextColor(views::Button::STATE_HOVERED, hover_color_);
button->SetUnderlineColor(enabled_color_);
#elif defined(OS_WIN)
button->SetUnderlineColor(color_utils::GetSysSkColor(COLOR_GRAYTEXT));
#endif
AddChildView(button);
}
RebuildChildren();
}
void MenuBar::SetAcceleratorVisibility(bool visible) {
for (int i = 0; i < child_count(); ++i)
static_cast<SubmenuButton*>(child_at(i))->SetAcceleratorVisibility(visible);
for (auto* child : GetChildrenInZOrder())
static_cast<SubmenuButton*>(child)->SetAcceleratorVisibility(visible);
}
int MenuBar::GetAcceleratorIndex(base::char16 key) {
for (int i = 0; i < child_count(); ++i) {
SubmenuButton* button = static_cast<SubmenuButton*>(child_at(i));
if (button->accelerator() == key)
return i;
MenuBar::View* MenuBar::FindAccelChild(base::char16 key) {
for (auto* child : GetChildrenInZOrder()) {
if (static_cast<SubmenuButton*>(child)->accelerator() == key)
return child;
}
return -1;
return nullptr;
}
bool MenuBar::HasAccelerator(base::char16 key) {
return FindAccelChild(key) != nullptr;
}
void MenuBar::ActivateAccelerator(base::char16 key) {
int i = GetAcceleratorIndex(key);
if (i != -1)
static_cast<SubmenuButton*>(child_at(i))->Activate(nullptr);
auto child = FindAccelChild(key);
if (child)
static_cast<SubmenuButton*>(child)->Activate(nullptr);
}
int MenuBar::GetItemCount() const {
return menu_model_->GetItemCount();
return menu_model_ ? menu_model_->GetItemCount() : 0;
}
bool MenuBar::GetMenuButtonFromScreenPoint(const gfx::Point& point,
bool MenuBar::GetMenuButtonFromScreenPoint(const gfx::Point& screenPoint,
AtomMenuModel** menu_model,
views::MenuButton** button) {
gfx::Point location(point);
views::View::ConvertPointFromScreen(this, &location);
if (location.x() < 0 || location.x() >= width() || location.y() < 0 ||
location.y() >= height())
if (!GetBoundsInScreen().Contains(screenPoint))
return false;
for (int i = 0; i < child_count(); ++i) {
views::View* view = child_at(i);
if (view->GetMirroredBounds().Contains(location) &&
auto children = GetChildrenInZOrder();
for (int i = 0, n = children.size(); i < n; ++i) {
if (children[i]->GetBoundsInScreen().Contains(screenPoint) &&
(menu_model_->GetTypeAt(i) == AtomMenuModel::TYPE_SUBMENU)) {
*menu_model = menu_model_->GetSubmenuModelAt(i);
*button = static_cast<views::MenuButton*>(view);
*button = static_cast<views::MenuButton*>(children[i]);
return true;
}
}
@@ -175,18 +133,75 @@ void MenuBar::OnMenuButtonClicked(views::MenuButton* source,
menu_delegate->RunMenu(menu_model_->GetSubmenuModelAt(id), source);
}
void MenuBar::OnNativeThemeChanged(const ui::NativeTheme* theme) {
UpdateMenuBarColor();
}
void MenuBar::RefreshColorCache(const ui::NativeTheme* theme) {
if (!theme)
theme = ui::NativeTheme::GetInstanceForNativeUi();
if (theme) {
#if defined(USE_X11)
const std::string menubar_selector = "GtkMenuBar#menubar";
background_color_ = libgtkui::GetBgColor(menubar_selector);
void MenuBar::UpdateMenuBarColor() {
enabled_color_ = theme->GetSystemColor(
ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor);
disabled_color_ = theme->GetSystemColor(
ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor);
#else
background_color_ =
theme->GetSystemColor(ui::NativeTheme::kColorId_MenuBackgroundColor);
#endif
}
#if defined(OS_WIN)
background_color_ = color_utils::GetSysSkColor(COLOR_MENUBAR);
#elif defined(USE_X11)
GetMenuBarColor(&enabled_color_, &disabled_color_, &highlight_color_,
&hover_color_, &background_color_);
#endif
}
void MenuBar::OnNativeThemeChanged(const ui::NativeTheme* theme) {
RefreshColorCache(theme);
UpdateViewColors();
}
void MenuBar::OnDidChangeFocus(View* focused_before, View* focused_now) {
// if we've changed focus, update our view
const auto had_focus = has_focus_;
has_focus_ = focused_now != nullptr;
if (has_focus_ != had_focus)
UpdateViewColors();
}
void MenuBar::RebuildChildren() {
RemoveAllChildViews(true);
for (int i = 0, n = GetItemCount(); i < n; ++i) {
auto button =
new SubmenuButton(menu_model_->GetLabelAt(i), this, background_color_);
button->set_tag(i);
AddChildView(button);
}
UpdateViewColors();
}
void MenuBar::UpdateViewColors() {
// set menubar background color
SetBackground(views::CreateSolidBackground(background_color_));
// set child colors
if (menu_model_ == nullptr)
return;
#if defined(USE_X11)
const auto& textColor = has_focus_ ? enabled_color_ : disabled_color_;
for (auto* child : GetChildrenInZOrder()) {
auto button = static_cast<SubmenuButton*>(child);
button->SetTextColor(views::Button::STATE_NORMAL, textColor);
button->SetTextColor(views::Button::STATE_DISABLED, disabled_color_);
button->SetTextColor(views::Button::STATE_PRESSED, enabled_color_);
button->SetTextColor(views::Button::STATE_HOVERED, textColor);
button->SetUnderlineColor(textColor);
}
#elif defined(OS_WIN)
for (auto* child : GetChildrenInZOrder()) {
auto button = static_cast<SubmenuButton*>(child);
button->SetUnderlineColor(color_utils::GetSysSkColor(COLOR_MENUTEXT));
}
#endif
}
} // namespace atom

View File

@@ -5,9 +5,12 @@
#ifndef ATOM_BROWSER_UI_VIEWS_MENU_BAR_H_
#define ATOM_BROWSER_UI_VIEWS_MENU_BAR_H_
#include <memory>
#include "atom/browser/native_window.h"
#include "atom/browser/ui/atom_menu_model.h"
#include "ui/views/controls/button/menu_button_listener.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/view.h"
namespace views {
@@ -19,7 +22,8 @@ namespace atom {
class MenuDelegate;
class MenuBar : public views::View,
public views::MenuButtonListener {
public views::MenuButtonListener,
public views::FocusChangeListener {
public:
explicit MenuBar(NativeWindow* window);
virtual ~MenuBar();
@@ -30,9 +34,8 @@ class MenuBar : public views::View,
// Shows underline under accelerators.
void SetAcceleratorVisibility(bool visible);
// Returns which submenu has accelerator |key|, -1 would be returned when
// there is no matching submenu.
int GetAcceleratorIndex(base::char16 key);
// Returns true if the submenu has accelerator |key|
bool HasAccelerator(base::char16 key);
// Shows the submenu whose accelerator is |key|.
void ActivateAccelerator(base::char16 key);
@@ -47,7 +50,9 @@ class MenuBar : public views::View,
protected:
// views::View:
void AddedToWidget() override;
const char* GetClassName() const override;
void RemovedFromWidget() override;
// views::MenuButtonListener:
void OnMenuButtonClicked(views::MenuButton* source,
@@ -55,21 +60,29 @@ class MenuBar : public views::View,
const ui::Event* event) override;
void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
// views::FocusChangeListener:
void OnDidChangeFocus(View* focused_before, View* focused_now) override;
void OnWillChangeFocus(View* focused_before, View* focused_now) override {}
private:
void UpdateMenuBarColor();
void RebuildChildren();
void UpdateViewColors();
void RefreshColorCache(const ui::NativeTheme* theme = nullptr);
SkColor background_color_;
#if defined(USE_X11)
SkColor enabled_color_;
SkColor disabled_color_;
SkColor highlight_color_;
SkColor hover_color_;
#endif
NativeWindow* window_;
AtomMenuModel* menu_model_;
View* FindAccelChild(base::char16 key);
std::shared_ptr<views::FocusManager> focus_manager_;
bool has_focus_ = true;
DISALLOW_COPY_AND_ASSIGN(MenuBar);
};

View File

@@ -91,7 +91,7 @@ void SubmenuButton::PaintButtonContents(gfx::Canvas* canvas) {
bool SubmenuButton::GetUnderlinePosition(const base::string16& text,
base::char16* accelerator,
int* start, int* end) {
int* start, int* end) const {
int pos, span;
base::string16 trimmed = gfx::RemoveAcceleratorChar(text, '&', &pos, &span);
if (pos > -1 && span != 0) {
@@ -105,7 +105,7 @@ bool SubmenuButton::GetUnderlinePosition(const base::string16& text,
}
void SubmenuButton::GetCharacterPosition(
const base::string16& text, int index, int* pos) {
const base::string16& text, int index, int* pos) const {
int height = 0;
gfx::Canvas::SizeStringInt(text.substr(0, index), gfx::FontList(), pos,
&height, 0, 0);

View File

@@ -21,9 +21,6 @@ class SubmenuButton : public views::MenuButton {
void SetAcceleratorVisibility(bool visible);
void SetUnderlineColor(SkColor color);
void SetEnabledColor(SkColor color);
void SetBackgroundColor(SkColor color);
base::char16 accelerator() const { return accelerator_; }
// views::MenuButton:
@@ -36,9 +33,9 @@ class SubmenuButton : public views::MenuButton {
private:
bool GetUnderlinePosition(const base::string16& text,
base::char16* accelerator,
int* start, int* end);
int* start, int* end) const;
void GetCharacterPosition(
const base::string16& text, int index, int* pos);
const base::string16& text, int index, int* pos) const;
base::char16 accelerator_;

View File

@@ -25,4 +25,11 @@ bool AtomDesktopWindowTreeHostWin::PreHandleMSG(
return delegate_->PreHandleMSG(message, w_param, l_param, result);
}
bool AtomDesktopWindowTreeHostWin::HasNativeFrame() const {
// Since we never use chromium's titlebar implementation, we can just say
// that we use a native titlebar. This will disable the repaint locking when
// DWM composition is disabled.
return true;
}
} // namespace atom

View File

@@ -27,6 +27,7 @@ class AtomDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin {
protected:
bool PreHandleMSG(
UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) override;
bool HasNativeFrame() const override;
private:
MessageHandlerDelegate* delegate_; // weak ref

View File

@@ -48,6 +48,35 @@ WebContentsPreferences::WebContentsPreferences(
web_contents->SetUserData(UserDataKey(), base::WrapUnique(this));
instances_.push_back(this);
// Set WebPreferences defaults onto the JS object
SetDefaultBoolIfUndefined("plugins", false);
SetDefaultBoolIfUndefined(options::kExperimentalFeatures, false);
SetDefaultBoolIfUndefined(options::kExperimentalCanvasFeatures, false);
bool node = SetDefaultBoolIfUndefined(options::kNodeIntegration, true);
SetDefaultBoolIfUndefined(options::kNodeIntegrationInWorker, false);
SetDefaultBoolIfUndefined(options::kWebviewTag, node);
SetDefaultBoolIfUndefined("sandbox", false);
SetDefaultBoolIfUndefined("nativeWindowOpen", false);
SetDefaultBoolIfUndefined(options::kContextIsolation, false);
SetDefaultBoolIfUndefined("javascript", true);
SetDefaultBoolIfUndefined("images", true);
SetDefaultBoolIfUndefined("textAreasAreResizable", true);
SetDefaultBoolIfUndefined("webgl", true);
bool webSecurity = true;
SetDefaultBoolIfUndefined("webSecurity", webSecurity);
// If webSecurity was explicity set to false, let's inherit that into
// insecureContent
if (web_preferences.Get("webSecurity", &webSecurity) && !webSecurity) {
SetDefaultBoolIfUndefined("allowRunningInsecureContent", true);
} else {
SetDefaultBoolIfUndefined("allowRunningInsecureContent", false);
}
#if defined(OS_MACOSX)
SetDefaultBoolIfUndefined(options::kScrollBounce, false);
#endif
SetDefaultBoolIfUndefined("offscreen", false);
last_web_preferences_.MergeDictionary(&web_preferences_);
}
WebContentsPreferences::~WebContentsPreferences() {
@@ -56,6 +85,16 @@ WebContentsPreferences::~WebContentsPreferences() {
instances_.end());
}
bool WebContentsPreferences::SetDefaultBoolIfUndefined(const std::string key,
bool val) {
bool existing;
if (!web_preferences_.GetBoolean(key, &existing)) {
web_preferences_.SetBoolean(key, val);
return val;
}
return existing;
}
void WebContentsPreferences::Merge(const base::DictionaryValue& extend) {
web_preferences_.MergeDictionary(&extend);
}
@@ -80,6 +119,12 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
base::DictionaryValue& web_preferences = self->web_preferences_;
// We are appending args to a webContents so let's save the current state
// of our preferences object so that during the lifetime of the WebContents
// we can fetch the options used to initally configure the WebContents
self->last_web_preferences_.Clear();
self->last_web_preferences_.MergeDictionary(&web_preferences);
bool b;
// Check if plugins are enabled.
if (web_preferences.GetBoolean("plugins", &b) && b)
@@ -156,8 +201,13 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
// --background-color.
std::string color;
if (web_preferences.GetString(options::kBackgroundColor, &color))
if (web_preferences.GetString(options::kBackgroundColor, &color)) {
command_line->AppendSwitchASCII(switches::kBackgroundColor, color);
} else if (!(web_preferences.GetBoolean("offscreen", &b) && b)) {
// For non-OSR WebContents, we expect to have white background, see
// https://github.com/electron/electron/issues/13764 for more.
command_line->AppendSwitchASCII(switches::kBackgroundColor, "#fff");
}
// --guest-instance-id, which is used to identify guest WebContents.
int guest_instance_id = 0;
@@ -286,6 +336,11 @@ void WebContentsPreferences::OverrideWebkitPrefs(
std::string encoding;
if (self->web_preferences_.GetString("defaultEncoding", &encoding))
prefs->default_encoding = encoding;
bool node_integration = false;
self->web_preferences_.GetBoolean(options::kNodeIntegration,
&node_integration);
prefs->node_integration = node_integration;
}
bool WebContentsPreferences::GetInteger(const std::string& attributeName,

View File

@@ -53,10 +53,16 @@ class WebContentsPreferences
// Returns the web preferences.
base::DictionaryValue* web_preferences() { return &web_preferences_; }
base::DictionaryValue* last_web_preferences() {
return &last_web_preferences_;
}
private:
friend class content::WebContentsUserData<WebContentsPreferences>;
// Set preference value to given bool if user did not provide value
bool SetDefaultBoolIfUndefined(const std::string key, bool val);
// Get preferences value as integer possibly coercing it from a string
bool GetInteger(const std::string& attributeName, int* intValue);
@@ -64,6 +70,7 @@ class WebContentsPreferences
content::WebContents* web_contents_;
base::DictionaryValue web_preferences_;
base::DictionaryValue last_web_preferences_;
DISALLOW_COPY_AND_ASSIGN(WebContentsPreferences);
};

View File

@@ -168,10 +168,10 @@ file_dialog::Filters GetFileTypesFromAcceptType(
filters.push_back(file_dialog::Filter());
if (valid_type_count > 1 ||
(valid_type_count == 1 && description.empty() && extensions.size() > 1))
if (valid_type_count > 1 || (valid_type_count == 1 && description.empty()))
description = "Custom Files";
DCHECK(!description.empty());
filters[0].first = description;
for (const auto& extension : extensions) {
@@ -227,6 +227,7 @@ void WebDialogHelper::RunFileChooser(
flags |= file_dialog::FILE_DIALOG_MULTI_SELECTIONS;
case content::FileChooserParams::Open:
flags |= file_dialog::FILE_DIALOG_OPEN_FILE;
flags |= file_dialog::FILE_DIALOG_TREAT_PACKAGE_APP_AS_DIRECTORY;
break;
case content::FileChooserParams::UploadFolder:
flags |= file_dialog::FILE_DIALOG_OPEN_DIRECTORY;

View File

@@ -22,16 +22,16 @@ IPC_STRUCT_TRAITS_BEGIN(atom::DraggableRegion)
IPC_STRUCT_TRAITS_MEMBER(bounds)
IPC_STRUCT_TRAITS_END()
IPC_MESSAGE_ROUTED2(AtomViewHostMsg_Message,
IPC_MESSAGE_ROUTED2(AtomFrameHostMsg_Message,
base::string16 /* channel */,
base::ListValue /* arguments */)
IPC_SYNC_MESSAGE_ROUTED2_1(AtomViewHostMsg_Message_Sync,
IPC_SYNC_MESSAGE_ROUTED2_1(AtomFrameHostMsg_Message_Sync,
base::string16 /* channel */,
base::ListValue /* arguments */,
base::string16 /* result (in JSON) */)
IPC_MESSAGE_ROUTED3(AtomViewMsg_Message,
IPC_MESSAGE_ROUTED3(AtomFrameMsg_Message,
bool /* send_to_all */,
base::string16 /* channel */,
base::ListValue /* arguments */)
@@ -56,9 +56,9 @@ IPC_MESSAGE_ROUTED1(AtomFrameHostMsg_UpdateDraggableRegions,
IPC_MESSAGE_CONTROL1(AtomMsg_UpdatePreferences, base::ListValue)
// Sent by renderer to set the temporary zoom level.
IPC_SYNC_MESSAGE_ROUTED1_1(AtomViewHostMsg_SetTemporaryZoomLevel,
double /* zoom level */,
double /* result */)
IPC_SYNC_MESSAGE_ROUTED1_1(AtomFrameHostMsg_SetTemporaryZoomLevel,
double /* zoom level */,
double /* result */)
// Sent by renderer to get the zoom level.
IPC_SYNC_MESSAGE_ROUTED0_1(AtomViewHostMsg_GetZoomLevel, double /* result */)
IPC_SYNC_MESSAGE_ROUTED0_1(AtomFrameHostMsg_GetZoomLevel, double /* result */)

View File

@@ -22,7 +22,7 @@ namespace std {
template <typename Type1, typename Type2>
struct hash<std::pair<Type1, Type2>> {
std::size_t operator()(std::pair<Type1, Type2> value) const {
return base::HashInts<Type1, Type2>(value.first, value.second);
return base::HashInts(base::Hash(value.first), value.second);
}
};
@@ -114,8 +114,9 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
dict.SetMethod("setRemoteCallbackFreer", &atom::RemoteCallbackFreer::BindTo);
dict.SetMethod("setRemoteObjectFreer", &atom::RemoteObjectFreer::BindTo);
dict.SetMethod("createIDWeakMap", &atom::api::KeyWeakMap<int32_t>::Create);
dict.SetMethod("createDoubleIDWeakMap",
&atom::api::KeyWeakMap<std::pair<int64_t, int32_t>>::Create);
dict.SetMethod(
"createDoubleIDWeakMap",
&atom::api::KeyWeakMap<std::pair<std::string, int32_t>>::Create);
dict.SetMethod("requestGarbageCollectionForTesting",
&RequestGarbageCollectionForTesting);
dict.SetMethod("isSameOrigin", &IsSameOrigin);

View File

@@ -7,23 +7,28 @@
#include "atom/common/api/api_messages.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
namespace atom {
// static
void RemoteCallbackFreer::BindTo(v8::Isolate* isolate,
v8::Local<v8::Object> target,
const std::string& context_id,
int object_id,
content::WebContents* web_contents) {
new RemoteCallbackFreer(isolate, target, object_id, web_contents);
new RemoteCallbackFreer(isolate, target, context_id, object_id, web_contents);
}
RemoteCallbackFreer::RemoteCallbackFreer(v8::Isolate* isolate,
v8::Local<v8::Object> target,
const std::string& context_id,
int object_id,
content::WebContents* web_contents)
: ObjectLifeMonitor(isolate, target),
content::WebContentsObserver(web_contents),
context_id_(context_id),
object_id_(object_id) {
}
@@ -34,8 +39,13 @@ void RemoteCallbackFreer::RunDestructor() {
base::string16 channel =
base::ASCIIToUTF16("ELECTRON_RENDERER_RELEASE_CALLBACK");
base::ListValue args;
args.AppendString(context_id_);
args.AppendInteger(object_id_);
Send(new AtomViewMsg_Message(routing_id(), false, channel, args));
auto frame_host = web_contents()->GetMainFrame();
if (frame_host) {
frame_host->Send(new AtomFrameMsg_Message(frame_host->GetRoutingID(), false,
channel, args));
}
Observe(nullptr);
}

View File

@@ -4,6 +4,9 @@
#ifndef ATOM_COMMON_API_REMOTE_CALLBACK_FREER_H_
#define ATOM_COMMON_API_REMOTE_CALLBACK_FREER_H_
#include <string>
#include "atom/common/api/object_life_monitor.h"
#include "content/public/browser/web_contents_observer.h"
@@ -14,12 +17,14 @@ class RemoteCallbackFreer : public ObjectLifeMonitor,
public:
static void BindTo(v8::Isolate* isolate,
v8::Local<v8::Object> target,
const std::string& context_id,
int object_id,
content::WebContents* web_conents);
protected:
RemoteCallbackFreer(v8::Isolate* isolate,
v8::Local<v8::Object> target,
const std::string& context_id,
int object_id,
content::WebContents* web_conents);
~RemoteCallbackFreer() override;
@@ -30,6 +35,7 @@ class RemoteCallbackFreer : public ObjectLifeMonitor,
void RenderViewDeleted(content::RenderViewHost*) override;
private:
std::string context_id_;
int object_id_;
DISALLOW_COPY_AND_ASSIGN(RemoteCallbackFreer);

View File

@@ -7,45 +7,44 @@
#include "atom/common/api/api_messages.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "content/public/renderer/render_view.h"
#include "content/public/renderer/render_frame.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebView.h"
using blink::WebLocalFrame;
using blink::WebView;
namespace atom {
namespace {
content::RenderView* GetCurrentRenderView() {
content::RenderFrame* GetCurrentRenderFrame() {
WebLocalFrame* frame = WebLocalFrame::FrameForCurrentContext();
if (!frame)
return nullptr;
WebView* view = frame->View();
if (!view)
return nullptr; // can happen during closing.
return content::RenderView::FromWebView(view);
return content::RenderFrame::FromWebFrame(frame);
}
} // namespace
// static
void RemoteObjectFreer::BindTo(
v8::Isolate* isolate, v8::Local<v8::Object> target, int object_id) {
new RemoteObjectFreer(isolate, target, object_id);
void RemoteObjectFreer::BindTo(v8::Isolate* isolate,
v8::Local<v8::Object> target,
const std::string& context_id,
int object_id) {
new RemoteObjectFreer(isolate, target, context_id, object_id);
}
RemoteObjectFreer::RemoteObjectFreer(
v8::Isolate* isolate, v8::Local<v8::Object> target, int object_id)
RemoteObjectFreer::RemoteObjectFreer(v8::Isolate* isolate,
v8::Local<v8::Object> target,
const std::string& context_id,
int object_id)
: ObjectLifeMonitor(isolate, target),
context_id_(context_id),
object_id_(object_id),
routing_id_(MSG_ROUTING_NONE) {
content::RenderView* render_view = GetCurrentRenderView();
if (render_view) {
routing_id_ = render_view->GetRoutingID();
content::RenderFrame* render_frame = GetCurrentRenderFrame();
if (render_frame) {
routing_id_ = render_frame->GetRoutingID();
}
}
@@ -53,17 +52,18 @@ RemoteObjectFreer::~RemoteObjectFreer() {
}
void RemoteObjectFreer::RunDestructor() {
content::RenderView* render_view =
content::RenderView::FromRoutingID(routing_id_);
if (!render_view)
content::RenderFrame* render_frame =
content::RenderFrame::FromRoutingID(routing_id_);
if (!render_frame)
return;
base::string16 channel = base::ASCIIToUTF16("ipc-message");
base::ListValue args;
args.AppendString("ELECTRON_BROWSER_DEREFERENCE");
args.AppendString(context_id_);
args.AppendInteger(object_id_);
render_view->Send(
new AtomViewHostMsg_Message(render_view->GetRoutingID(), channel, args));
render_frame->Send(new AtomFrameHostMsg_Message(render_frame->GetRoutingID(),
channel, args));
}
} // namespace atom

View File

@@ -5,23 +5,30 @@
#ifndef ATOM_COMMON_API_REMOTE_OBJECT_FREER_H_
#define ATOM_COMMON_API_REMOTE_OBJECT_FREER_H_
#include <string>
#include "atom/common/api/object_life_monitor.h"
namespace atom {
class RemoteObjectFreer : public ObjectLifeMonitor {
public:
static void BindTo(
v8::Isolate* isolate, v8::Local<v8::Object> target, int object_id);
static void BindTo(v8::Isolate* isolate,
v8::Local<v8::Object> target,
const std::string& context_id,
int object_id);
protected:
RemoteObjectFreer(
v8::Isolate* isolate, v8::Local<v8::Object> target, int object_id);
RemoteObjectFreer(v8::Isolate* isolate,
v8::Local<v8::Object> target,
const std::string& context_id,
int object_id);
~RemoteObjectFreer() override;
void RunDestructor() override;
private:
std::string context_id_;
int object_id_;
int routing_id_;

View File

@@ -5,10 +5,10 @@
#ifndef ATOM_COMMON_ATOM_VERSION_H_
#define ATOM_COMMON_ATOM_VERSION_H_
#define ATOM_MAJOR_VERSION 1
#define ATOM_MINOR_VERSION 8
#define ATOM_PATCH_VERSION 2
#define ATOM_PRE_RELEASE_VERSION -beta.2
#define ATOM_MAJOR_VERSION 2
#define ATOM_MINOR_VERSION 0
#define ATOM_PATCH_VERSION 16
// #define ATOM_PRE_RELEASE_VERSION
#ifndef ATOM_STRINGIFY
#define ATOM_STRINGIFY(n) ATOM_STRINGIFY_HELPER(n)

View File

@@ -209,7 +209,10 @@ void CrashReporterWin::SetUploadParameters() {
int CrashReporterWin::CrashForException(EXCEPTION_POINTERS* info) {
if (breakpad_) {
breakpad_->WriteMinidumpForException(info);
TerminateProcessWithoutDump();
if (skip_system_crash_handler_)
TerminateProcessWithoutDump();
else
RaiseFailFastException(info->ExceptionRecord, info->ContextRecord, 0);
}
return EXCEPTION_CONTINUE_SEARCH;
}
@@ -229,7 +232,7 @@ bool CrashReporterWin::MinidumpCallback(const wchar_t* dump_path,
MDRawAssertionInfo* assertion,
bool succeeded) {
CrashReporterWin* self = static_cast<CrashReporterWin*>(context);
if (succeeded && !self->skip_system_crash_handler_)
if (succeeded && self->skip_system_crash_handler_)
return true;
else
return false;

View File

@@ -13,15 +13,19 @@
#include "atom/common/atom_version.h"
#include "base/environment.h"
#include "base/logging.h"
#include "brightray/common/platform_util.h"
#include "chrome/browser/ui/libgtkui/gtk_util.h"
namespace {
GDesktopAppInfo* get_desktop_app_info() {
std::unique_ptr<base::Environment> env(base::Environment::Create());
const std::string desktop_id = libgtkui::GetDesktopName(env.get());
return desktop_id.empty() ? nullptr
: g_desktop_app_info_new(desktop_id.c_str());
GDesktopAppInfo * ret = nullptr;
std::string desktop_id;
if (brightray::platform_util::GetDesktopName(&desktop_id))
ret = g_desktop_app_info_new(desktop_id.c_str());
return ret;
}
} // namespace

View File

@@ -168,6 +168,7 @@ void NodeBindings::Initialize() {
// Init node.
// (we assume node::Init would not modify the parameters under embedded mode).
// NOTE: If you change this line, please ping @codebytere or @MarshallOfSound
node::Init(nullptr, nullptr, nullptr, nullptr);
#if defined(OS_WIN)

View File

@@ -7,6 +7,7 @@
#include <windows.h>
#include "base/logging.h"
#include "base/sys_info.h"
extern "C" {
#include "vendor/node/deps/uv/src/win/internal.h"
@@ -16,6 +17,17 @@ namespace atom {
NodeBindingsWin::NodeBindingsWin(BrowserEnvironment browser_env)
: NodeBindings(browser_env) {
// on single-core the io comp port NumberOfConcurrentThreads needs to be 2
// to avoid cpu pegging likely caused by a busy loop in PollEvents
if (base::SysInfo::NumberOfProcessors() == 1) {
// the expectation is the uv_loop_ has just been initialized
// which makes iocp replacement safe
CHECK_EQ(0u, uv_loop_->active_handles);
if (uv_loop_->iocp && uv_loop_->iocp != INVALID_HANDLE_VALUE)
CloseHandle(uv_loop_->iocp);
uv_loop_->iocp = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 2);
}
}
NodeBindingsWin::~NodeBindingsWin() {

View File

@@ -178,6 +178,9 @@ const char kAppUserModelId[] = "app-user-model-id";
// The application path
const char kAppPath[] = "app-path";
// The context ID for this process
const char kContextId[] = "context-id";
// The command line switch versions of the options.
const char kBackgroundColor[] = "background-color";
const char kPreloadScript[] = "preload";

View File

@@ -88,6 +88,7 @@ extern const char kRegisterServiceWorkerSchemes[];
extern const char kSecureSchemes[];
extern const char kAppUserModelId[];
extern const char kAppPath[];
extern const char kContextId[];
extern const char kBackgroundColor[];
extern const char kPreloadScript[];

View File

@@ -7,43 +7,38 @@
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "content/public/renderer/render_view.h"
#include "content/public/renderer/render_frame.h"
#include "native_mate/dictionary.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebView.h"
using content::RenderView;
using content::RenderFrame;
using blink::WebLocalFrame;
using blink::WebView;
namespace atom {
namespace api {
RenderView* GetCurrentRenderView() {
RenderFrame* GetCurrentRenderFrame() {
WebLocalFrame* frame = WebLocalFrame::FrameForCurrentContext();
if (!frame)
return nullptr;
WebView* view = frame->View();
if (!view)
return nullptr; // can happen during closing.
return RenderView::FromWebView(view);
return RenderFrame::FromWebFrame(frame);
}
void Send(mate::Arguments* args,
const base::string16& channel,
const base::ListValue& arguments) {
RenderView* render_view = GetCurrentRenderView();
if (render_view == nullptr)
RenderFrame* render_frame = GetCurrentRenderFrame();
if (render_frame == nullptr)
return;
bool success = render_view->Send(new AtomViewHostMsg_Message(
render_view->GetRoutingID(), channel, arguments));
bool success = render_frame->Send(new AtomFrameHostMsg_Message(
render_frame->GetRoutingID(), channel, arguments));
if (!success)
args->ThrowError("Unable to send AtomViewHostMsg_Message");
args->ThrowError("Unable to send AtomFrameHostMsg_Message");
}
base::string16 SendSync(mate::Arguments* args,
@@ -51,16 +46,16 @@ base::string16 SendSync(mate::Arguments* args,
const base::ListValue& arguments) {
base::string16 json;
RenderView* render_view = GetCurrentRenderView();
if (render_view == nullptr)
RenderFrame* render_frame = GetCurrentRenderFrame();
if (render_frame == nullptr)
return json;
IPC::SyncMessage* message = new AtomViewHostMsg_Message_Sync(
render_view->GetRoutingID(), channel, arguments, &json);
bool success = render_view->Send(message);
IPC::SyncMessage* message = new AtomFrameHostMsg_Message_Sync(
render_frame->GetRoutingID(), channel, arguments, &json);
bool success = render_frame->Send(message);
if (!success)
args->ThrowError("Unable to send AtomViewHostMsg_Message_Sync");
args->ThrowError("Unable to send AtomFrameHostMsg_Message_Sync");
return json;
}

View File

@@ -125,19 +125,19 @@ void WebFrame::SetName(const std::string& name) {
double WebFrame::SetZoomLevel(double level) {
double result = 0.0;
content::RenderView* render_view =
content::RenderView::FromWebView(web_frame_->View());
render_view->Send(new AtomViewHostMsg_SetTemporaryZoomLevel(
render_view->GetRoutingID(), level, &result));
content::RenderFrame* render_frame =
content::RenderFrame::FromWebFrame(web_frame_);
render_frame->Send(new AtomFrameHostMsg_SetTemporaryZoomLevel(
render_frame->GetRoutingID(), level, &result));
return result;
}
double WebFrame::GetZoomLevel() const {
double result = 0.0;
content::RenderView* render_view =
content::RenderView::FromWebView(web_frame_->View());
render_view->Send(
new AtomViewHostMsg_GetZoomLevel(render_view->GetRoutingID(), &result));
content::RenderFrame* render_frame =
content::RenderFrame::FromWebFrame(web_frame_);
render_frame->Send(
new AtomFrameHostMsg_GetZoomLevel(render_frame->GetRoutingID(), &result));
return result;
}
@@ -152,6 +152,7 @@ double WebFrame::GetZoomFactor() const {
void WebFrame::SetVisualZoomLevelLimits(double min_level, double max_level) {
web_frame_->View()->SetDefaultPageScaleLimits(min_level, max_level);
web_frame_->View()->SetIgnoreViewportTagScaleLimits(true);
}
void WebFrame::SetLayoutZoomLevelLimits(double min_level, double max_level) {

View File

@@ -4,29 +4,90 @@
#include "atom/renderer/atom_render_frame_observer.h"
#include <string>
#include <vector>
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/api/api_messages.h"
#include "atom/common/api/event_emitter_caller.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "base/strings/string_number_conversions.h"
#include "base/trace_event/trace_event.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_view.h"
#include "ipc/ipc_message_macros.h"
#include "native_mate/dictionary.h"
#include "net/base/net_module.h"
#include "net/grit/net_resources.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebDraggableRegion.h"
#include "third_party/WebKit/public/web/WebElement.h"
#include "third_party/WebKit/public/web/WebKit.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebScriptSource.h"
#include "ui/base/resource/resource_bundle.h"
namespace atom {
namespace {
bool GetIPCObject(v8::Isolate* isolate,
v8::Local<v8::Context> context,
v8::Local<v8::Object>* ipc) {
v8::Local<v8::String> key = mate::StringToV8(isolate, "ipc");
v8::Local<v8::Private> privateKey = v8::Private::ForApi(isolate, key);
v8::Local<v8::Object> global_object = context->Global();
v8::Local<v8::Value> value;
if (!global_object->GetPrivate(context, privateKey).ToLocal(&value))
return false;
if (value.IsEmpty() || !value->IsObject())
return false;
*ipc = value->ToObject();
return true;
}
std::vector<v8::Local<v8::Value>> ListValueToVector(
v8::Isolate* isolate,
const base::ListValue& list) {
v8::Local<v8::Value> array = mate::ConvertToV8(isolate, list);
std::vector<v8::Local<v8::Value>> result;
mate::ConvertFromV8(isolate, array, &result);
return result;
}
base::StringPiece NetResourceProvider(int key) {
if (key == IDR_DIR_HEADER_HTML) {
base::StringPiece html_data =
ui::ResourceBundle::GetSharedInstance().GetRawDataResource(
IDR_DIR_HEADER_HTML);
return html_data;
}
return base::StringPiece();
}
} // namespace
AtomRenderFrameObserver::AtomRenderFrameObserver(
content::RenderFrame* frame,
RendererClientBase* renderer_client)
: content::RenderFrameObserver(frame),
render_frame_(frame),
renderer_client_(renderer_client) {}
: content::RenderFrameObserver(frame),
render_frame_(frame),
renderer_client_(renderer_client),
document_created_(false) {
// Initialise resource for directory listing.
net::NetModule::SetResourceProvider(NetResourceProvider);
}
void AtomRenderFrameObserver::DidClearWindowObject() {
renderer_client_->DidClearWindowObject(render_frame_);
}
void AtomRenderFrameObserver::DidCreateDocumentElement() {
document_created_ = true;
}
void AtomRenderFrameObserver::DidCreateScriptContext(
v8::Handle<v8::Context> context,
int world_id) {
@@ -99,4 +160,70 @@ bool AtomRenderFrameObserver::ShouldNotifyClient(int world_id) {
return IsMainWorld(world_id);
}
bool AtomRenderFrameObserver::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(AtomRenderFrameObserver, message)
IPC_MESSAGE_HANDLER(AtomFrameMsg_Message, OnBrowserMessage)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void AtomRenderFrameObserver::OnBrowserMessage(bool send_to_all,
const base::string16& channel,
const base::ListValue& args) {
// Don't handle browser messages before document element is created.
// When we receive a message from the browser, we try to transfer it
// to a web page, and when we do that Blink creates an empty
// document element if it hasn't been created yet, and it makes our init
// script to run while `window.location` is still "about:blank".
if (!document_created_)
return;
blink::WebLocalFrame* frame = render_frame_->GetWebFrame();
if (!frame || !render_frame_->IsMainFrame())
return;
EmitIPCEvent(frame, channel, args);
// Also send the message to all sub-frames.
if (send_to_all) {
for (blink::WebFrame* child = frame->FirstChild(); child;
child = child->NextSibling())
if (child->IsWebLocalFrame()) {
EmitIPCEvent(child->ToWebLocalFrame(), channel, args);
}
}
}
void AtomRenderFrameObserver::EmitIPCEvent(blink::WebLocalFrame* frame,
const base::string16& channel,
const base::ListValue& args) {
if (!frame)
return;
v8::Isolate* isolate = blink::MainThreadIsolate();
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Context> context = renderer_client_->GetContext(frame, isolate);
v8::Context::Scope context_scope(context);
// Only emit IPC event for context with node integration.
node::Environment* env = node::Environment::GetCurrent(context);
if (!env)
return;
v8::Local<v8::Object> ipc;
if (GetIPCObject(isolate, context, &ipc)) {
TRACE_EVENT0("devtools.timeline", "FunctionCall");
auto args_vector = ListValueToVector(isolate, args);
// Insert the Event object, event.sender is ipc.
mate::Dictionary event = mate::Dictionary::CreateEmpty(isolate);
event.Set("sender", ipc);
args_vector.insert(args_vector.begin(), event.GetHandle());
mate::EmitEvent(isolate, ipc, channel, args_vector);
}
}
} // namespace atom

View File

@@ -6,7 +6,13 @@
#define ATOM_RENDERER_ATOM_RENDER_FRAME_OBSERVER_H_
#include "atom/renderer/renderer_client_base.h"
#include "base/strings/string16.h"
#include "content/public/renderer/render_frame_observer.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
namespace base {
class ListValue;
}
namespace atom {
@@ -31,15 +37,26 @@ class AtomRenderFrameObserver : public content::RenderFrameObserver {
void WillReleaseScriptContext(v8::Local<v8::Context> context,
int world_id) override;
void OnDestruct() override;
bool OnMessageReceived(const IPC::Message& message) override;
void DidCreateDocumentElement() override;
protected:
virtual void EmitIPCEvent(blink::WebLocalFrame* frame,
const base::string16& channel,
const base::ListValue& args);
private:
bool ShouldNotifyClient(int world_id);
void CreateIsolatedWorldContext();
bool IsMainWorld(int world_id);
bool IsIsolatedWorld(int world_id);
void OnBrowserMessage(bool send_to_all,
const base::string16& channel,
const base::ListValue& args);
content::RenderFrame* render_frame_;
RendererClientBase* renderer_client_;
bool document_created_;
DISALLOW_COPY_AND_ASSIGN(AtomRenderFrameObserver);
};

View File

@@ -4,118 +4,21 @@
#include "atom/renderer/atom_render_view_observer.h"
#include <string>
#include <vector>
// Put this before event_emitter_caller.h to have string16 support.
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/api/api_messages.h"
#include "atom/common/api/event_emitter_caller.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "atom/renderer/atom_renderer_client.h"
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "base/trace_event/trace_event.h"
#include "content/public/renderer/render_view.h"
#include "ipc/ipc_message_macros.h"
#include "native_mate/dictionary.h"
#include "net/base/net_module.h"
#include "net/grit/net_resources.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebElement.h"
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebKit.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebView.h"
#include "ui/base/resource/resource_bundle.h"
namespace atom {
namespace {
AtomRenderViewObserver::AtomRenderViewObserver(content::RenderView* render_view)
: content::RenderViewObserver(render_view) {}
bool GetIPCObject(v8::Isolate* isolate,
v8::Local<v8::Context> context,
v8::Local<v8::Object>* ipc) {
v8::Local<v8::String> key = mate::StringToV8(isolate, "ipc");
v8::Local<v8::Private> privateKey = v8::Private::ForApi(isolate, key);
v8::Local<v8::Object> global_object = context->Global();
v8::Local<v8::Value> value;
if (!global_object->GetPrivate(context, privateKey).ToLocal(&value))
return false;
if (value.IsEmpty() || !value->IsObject())
return false;
*ipc = value->ToObject();
return true;
}
std::vector<v8::Local<v8::Value>> ListValueToVector(
v8::Isolate* isolate,
const base::ListValue& list) {
v8::Local<v8::Value> array = mate::ConvertToV8(isolate, list);
std::vector<v8::Local<v8::Value>> result;
mate::ConvertFromV8(isolate, array, &result);
return result;
}
base::StringPiece NetResourceProvider(int key) {
if (key == IDR_DIR_HEADER_HTML) {
base::StringPiece html_data =
ui::ResourceBundle::GetSharedInstance().GetRawDataResource(
IDR_DIR_HEADER_HTML);
return html_data;
}
return base::StringPiece();
}
} // namespace
AtomRenderViewObserver::AtomRenderViewObserver(
content::RenderView* render_view,
AtomRendererClient* renderer_client)
: content::RenderViewObserver(render_view),
renderer_client_(renderer_client) {
// Initialise resource for directory listing.
net::NetModule::SetResourceProvider(NetResourceProvider);
}
AtomRenderViewObserver::~AtomRenderViewObserver() {
}
void AtomRenderViewObserver::EmitIPCEvent(blink::WebLocalFrame* frame,
const base::string16& channel,
const base::ListValue& args) {
if (!frame)
return;
v8::Isolate* isolate = blink::MainThreadIsolate();
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Context> context = renderer_client_->GetContext(frame, isolate);
v8::Context::Scope context_scope(context);
// Only emit IPC event for context with node integration.
node::Environment* env = node::Environment::GetCurrent(context);
if (!env)
return;
v8::Local<v8::Object> ipc;
if (GetIPCObject(isolate, context, &ipc)) {
TRACE_EVENT0("devtools.timeline", "FunctionCall");
auto args_vector = ListValueToVector(isolate, args);
// Insert the Event object, event.sender is ipc.
mate::Dictionary event = mate::Dictionary::CreateEmpty(isolate);
event.Set("sender", ipc);
args_vector.insert(args_vector.begin(), event.GetHandle());
mate::EmitEvent(isolate, ipc, channel, args_vector);
}
}
AtomRenderViewObserver::~AtomRenderViewObserver() {}
bool AtomRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(AtomRenderViewObserver, message)
IPC_MESSAGE_HANDLER(AtomViewMsg_Message, OnBrowserMessage)
IPC_MESSAGE_HANDLER(AtomViewMsg_Offscreen, OnOffscreen)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -127,39 +30,6 @@ void AtomRenderViewObserver::OnDestruct() {
delete this;
}
void AtomRenderViewObserver::OnBrowserMessage(bool send_to_all,
const base::string16& channel,
const base::ListValue& args) {
if (!render_view()->GetWebView())
return;
blink::WebFrame* frame = render_view()->GetWebView()->MainFrame();
if (!frame || !frame->IsWebLocalFrame())
return;
// Don't handle browser messages before document element is created.
// When we receive a message from the browser, we try to transfer it
// to a web page, and when we do that Blink creates an empty
// document element if it hasn't been created yet, and it makes our init
// script to run while `window.location` is still "about:blank".
blink::WebDocument document = frame->ToWebLocalFrame()->GetDocument();
blink::WebElement html_element = document.DocumentElement();
if (html_element.IsNull()) {
return;
}
EmitIPCEvent(frame->ToWebLocalFrame(), channel, args);
// Also send the message to all sub-frames.
if (send_to_all) {
for (blink::WebFrame* child = frame->FirstChild(); child;
child = child->NextSibling())
if (child->IsWebLocalFrame()) {
EmitIPCEvent(child->ToWebLocalFrame(), channel, args);
}
}
}
void AtomRenderViewObserver::OnOffscreen() {
blink::WebView::SetUseExternalPopupMenus(false);
}

View File

@@ -5,43 +5,24 @@
#ifndef ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_H_
#define ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_H_
#include "base/strings/string16.h"
#include "content/public/renderer/render_view_observer.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
namespace base {
class ListValue;
}
namespace atom {
class AtomRendererClient;
class AtomRenderViewObserver : public content::RenderViewObserver {
public:
explicit AtomRenderViewObserver(content::RenderView* render_view,
AtomRendererClient* renderer_client);
explicit AtomRenderViewObserver(content::RenderView* render_view);
protected:
virtual ~AtomRenderViewObserver();
virtual void EmitIPCEvent(blink::WebLocalFrame* frame,
const base::string16& channel,
const base::ListValue& args);
private:
// content::RenderViewObserver implementation.
bool OnMessageReceived(const IPC::Message& message) override;
void OnDestruct() override;
void OnBrowserMessage(bool send_to_all,
const base::string16& channel,
const base::ListValue& args);
void OnOffscreen();
AtomRendererClient* renderer_client_;
DISALLOW_COPY_AND_ASSIGN(AtomRenderViewObserver);
};

View File

@@ -15,9 +15,9 @@
#include "atom/common/options_switches.h"
#include "atom/renderer/api/atom_api_renderer_ipc.h"
#include "atom/renderer/atom_render_frame_observer.h"
#include "atom/renderer/atom_render_view_observer.h"
#include "atom/renderer/web_worker_observer.h"
#include "base/command_line.h"
#include "content/public/common/web_preferences.h"
#include "content/public/renderer/render_frame.h"
#include "native_mate/dictionary.h"
#include "third_party/WebKit/public/web/WebDocument.h"
@@ -53,11 +53,11 @@ void AtomRendererClient::RenderThreadStarted() {
void AtomRendererClient::RenderFrameCreated(
content::RenderFrame* render_frame) {
new AtomRenderFrameObserver(render_frame, this);
RendererClientBase::RenderFrameCreated(render_frame);
}
void AtomRendererClient::RenderViewCreated(content::RenderView* render_view) {
new AtomRenderViewObserver(render_view, this);
RendererClientBase::RenderViewCreated(render_view);
}
@@ -83,11 +83,22 @@ void AtomRendererClient::RunScriptsAtDocumentEnd(
void AtomRendererClient::DidCreateScriptContext(
v8::Handle<v8::Context> context, content::RenderFrame* render_frame) {
RendererClientBase::DidCreateScriptContext(context, render_frame);
// Only allow node integration for the main frame, unless it is a devtools
// extension page.
if (!render_frame->IsMainFrame() && !IsDevToolsExtension(render_frame))
return;
// Don't allow node integration if this is a child window and it does not have
// node integration enabled. Otherwise we would have memory leak in the child
// window since we don't clean up node environments.
//
// TODO(zcbenz): We shouldn't allow node integration even for the top frame.
if (!render_frame->GetWebkitPreferences().node_integration &&
render_frame->GetWebFrame()->Opener())
return;
// Prepare the node bindings.
if (!node_integration_initialized_) {
node_integration_initialized_ = true;

View File

@@ -13,20 +13,14 @@
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/options_switches.h"
#include "atom/renderer/api/atom_api_renderer_ipc.h"
#include "atom/renderer/atom_render_view_observer.h"
#include "atom/renderer/atom_render_frame_observer.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "chrome/renderer/printing/print_web_view_helper.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_view.h"
#include "content/public/renderer/render_view_observer.h"
#include "ipc/ipc_message_macros.h"
#include "native_mate/converter.h"
#include "native_mate/dictionary.h"
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebKit.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebScriptSource.h"
#include "third_party/WebKit/public/web/WebView.h"
#include "atom/common/node_includes.h"
#include "atom_natives.h" // NOLINT: This file is generated with js2c
@@ -38,6 +32,11 @@ namespace {
const std::string kIpcKey = "ipcNative";
const std::string kModuleCacheKey = "native-module-cache";
bool IsDevTools(content::RenderFrame* render_frame) {
return render_frame->GetWebFrame()->GetDocument().Url()
.ProtocolIs("chrome-devtools");
}
v8::Local<v8::Object> GetModuleCache(v8::Isolate* isolate) {
mate::Dictionary global(isolate, isolate->GetCurrentContext()->Global());
v8::Local<v8::Value> cache;
@@ -93,22 +92,28 @@ void InitializeBindings(v8::Local<v8::Object> binding,
b.SetMethod("getArgv", GetArgv);
b.SetMethod("getProcessMemoryInfo", &AtomBindings::GetProcessMemoryInfo);
b.SetMethod("getSystemMemoryInfo", &AtomBindings::GetSystemMemoryInfo);
// Pass in CLI flags needed to setup the renderer
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kGuestInstanceID))
b.Set(options::kGuestInstanceID,
command_line->GetSwitchValueASCII(switches::kGuestInstanceID));
}
class AtomSandboxedRenderViewObserver : public AtomRenderViewObserver {
class AtomSandboxedRenderFrameObserver : public AtomRenderFrameObserver {
public:
AtomSandboxedRenderViewObserver(content::RenderView* render_view,
AtomSandboxedRendererClient* renderer_client)
: AtomRenderViewObserver(render_view, nullptr),
v8_converter_(new atom::V8ValueConverter),
renderer_client_(renderer_client) {
v8_converter_->SetDisableNode(true);
}
AtomSandboxedRenderFrameObserver(content::RenderFrame* render_frame,
AtomSandboxedRendererClient* renderer_client)
: AtomRenderFrameObserver(render_frame, renderer_client),
v8_converter_(new atom::V8ValueConverter),
renderer_client_(renderer_client) {
v8_converter_->SetDisableNode(true);
}
protected:
void EmitIPCEvent(blink::WebLocalFrame* frame,
const base::string16& channel,
const base::ListValue& args) override {
const base::ListValue& args) {
if (!frame)
return;
@@ -129,7 +134,7 @@ class AtomSandboxedRenderViewObserver : public AtomRenderViewObserver {
private:
std::unique_ptr<atom::V8ValueConverter> v8_converter_;
AtomSandboxedRendererClient* renderer_client_;
DISALLOW_COPY_AND_ASSIGN(AtomSandboxedRenderViewObserver);
DISALLOW_COPY_AND_ASSIGN(AtomSandboxedRenderFrameObserver);
};
} // namespace
@@ -143,27 +148,27 @@ AtomSandboxedRendererClient::~AtomSandboxedRendererClient() {
void AtomSandboxedRendererClient::RenderFrameCreated(
content::RenderFrame* render_frame) {
new AtomSandboxedRenderFrameObserver(render_frame, this);
RendererClientBase::RenderFrameCreated(render_frame);
}
void AtomSandboxedRendererClient::RenderViewCreated(
content::RenderView* render_view) {
new AtomSandboxedRenderViewObserver(render_view, this);
RendererClientBase::RenderViewCreated(render_view);
}
void AtomSandboxedRendererClient::DidCreateScriptContext(
v8::Handle<v8::Context> context, content::RenderFrame* render_frame) {
RendererClientBase::DidCreateScriptContext(context, render_frame);
// Only allow preload for the main frame
if (!render_frame->IsMainFrame())
// Only allow preload for the main frame or
// For devtools we still want to run the preload_bundle script
if (!render_frame->IsMainFrame() && !IsDevTools(render_frame))
return;
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
std::string preload_script = command_line->GetSwitchValueASCII(
base::FilePath preload_script_path = command_line->GetSwitchValuePath(
switches::kPreloadScript);
if (preload_script.empty())
return;
auto isolate = context->GetIsolate();
v8::HandleScope handle_scope(isolate);
@@ -188,7 +193,7 @@ void AtomSandboxedRendererClient::DidCreateScriptContext(
AddRenderBindings(isolate, binding);
v8::Local<v8::Value> args[] = {
binding,
mate::ConvertToV8(isolate, preload_script)
mate::ConvertToV8(isolate, preload_script_path.value())
};
// Execute the function with proper arguments
ignore_result(func->Call(context, v8::Null(isolate), 2, args));

View File

@@ -13,12 +13,15 @@
#include "atom/common/options_switches.h"
#include "atom/renderer/atom_autofill_agent.h"
#include "atom/renderer/atom_render_frame_observer.h"
#include "atom/renderer/atom_render_view_observer.h"
#include "atom/renderer/content_settings_observer.h"
#include "atom/renderer/guest_view_container.h"
#include "atom/renderer/preferences_manager.h"
#include "base/command_line.h"
#include "base/memory/ptr_util.h"
#include "base/process/process_handle.h"
#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
#include "chrome/renderer/media/chrome_key_systems.h"
#include "chrome/renderer/pepper/pepper_helper.h"
#include "chrome/renderer/printing/print_web_view_helper.h"
@@ -26,13 +29,13 @@
#include "content/public/common/content_constants.h"
#include "content/public/renderer/render_view.h"
#include "native_mate/dictionary.h"
#include "third_party/WebKit/public/web/WebCustomElement.h"
#include "third_party/WebKit/Source/platform/weborigin/SchemeRegistry.h"
#include "third_party/WebKit/public/web/WebCustomElement.h" // NOLINT(build/include_alpha)
#include "third_party/WebKit/public/web/WebFrameWidget.h"
#include "third_party/WebKit/public/web/WebKit.h"
#include "third_party/WebKit/public/web/WebPluginParams.h"
#include "third_party/WebKit/public/web/WebScriptSource.h"
#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
#include "third_party/WebKit/Source/platform/weborigin/SchemeRegistry.h"
#if defined(OS_MACOSX)
#include "base/mac/mac_util.h"
@@ -43,6 +46,14 @@
#include <shlobj.h>
#endif
// This is defined in later versions of Chromium, remove this if you see
// compiler complaining duplicate defines.
#if defined(OS_WIN) || defined(OS_FUCHSIA)
#define CrPRIdPid "ld"
#else
#define CrPRIdPid "d"
#endif
namespace atom {
namespace {
@@ -77,6 +88,19 @@ RendererClientBase::RendererClientBase() {
RendererClientBase::~RendererClientBase() {
}
void RendererClientBase::DidCreateScriptContext(
v8::Handle<v8::Context> context,
content::RenderFrame* render_frame) {
// global.setHidden("contextId", `${processId}-${++nextContextId}`)
std::string context_id = base::StringPrintf(
"%" CrPRIdPid "-%d", base::GetCurrentProcId(), ++next_context_id_);
v8::Isolate* isolate = context->GetIsolate();
v8::Local<v8::String> key = mate::StringToSymbol(isolate, "contextId");
v8::Local<v8::Private> private_key = v8::Private::ForApi(isolate, key);
v8::Local<v8::Value> value = mate::ConvertToV8(isolate, context_id);
context->Global()->SetPrivate(context, private_key, value);
}
void RendererClientBase::AddRenderBindings(
v8::Isolate* isolate,
v8::Local<v8::Object> binding_object) {
@@ -144,7 +168,6 @@ void RendererClientBase::RenderThreadStarted() {
void RendererClientBase::RenderFrameCreated(
content::RenderFrame* render_frame) {
new AtomRenderFrameObserver(render_frame, this);
new AutofillAgent(render_frame);
new PepperHelper(render_frame);
new ContentSettingsObserver(render_frame);
@@ -159,6 +182,7 @@ void RendererClientBase::RenderFrameCreated(
}
void RendererClientBase::RenderViewCreated(content::RenderView* render_view) {
new AtomRenderViewObserver(render_view);
blink::WebFrameWidget* web_frame_widget = render_view->GetWebFrameWidget();
if (!web_frame_widget)
return;

View File

@@ -21,7 +21,7 @@ class RendererClientBase : public content::ContentRendererClient {
virtual ~RendererClientBase();
virtual void DidCreateScriptContext(
v8::Handle<v8::Context> context, content::RenderFrame* render_frame) = 0;
v8::Handle<v8::Context> context, content::RenderFrame* render_frame);
virtual void WillReleaseScriptContext(
v8::Handle<v8::Context> context, content::RenderFrame* render_frame) = 0;
virtual void DidClearWindowObject(content::RenderFrame* render_frame);
@@ -57,6 +57,9 @@ class RendererClientBase : public content::ContentRendererClient {
private:
std::unique_ptr<PreferencesManager> preferences_manager_;
bool isolated_world_;
// An increasing ID used for indentifying an V8 context in this process.
int next_context_id_ = 0;
};
} // namespace atom

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