Compare commits

...

399 Commits

Author SHA1 Message Date
Cheng Zhao
79a5de3fd8 Bump v1.4.3 2016-10-06 17:12:07 +09:00
Cheng Zhao
2624738534 Lock the version of electron-docs-linter 2016-10-06 17:12:06 +09:00
Cheng Zhao
10b91b1291 Merge pull request #7488 from electron/native-image-resize-and-crop
Support resizing and cropping native images
2016-10-06 15:01:41 +09:00
Cheng Zhao
1781ceb25b Merge pull request #7494 from thomsonreuters/Update_Test_For_Missing_Additional_Features
Update BrowserWindow's test to check additional features upon window.open() call
2016-10-06 14:45:28 +09:00
Cheng Zhao
051e5c27b3 Update brightray for #7332 2016-10-06 14:42:14 +09:00
Cheng Zhao
5285b729be Merge pull request #7407 from thomsonreuters/New_Window_Handler_Can_Create_And_Return_Window
New-window event handler can return its own BrowserWindow instance
2016-10-06 14:37:48 +09:00
Kevin Sawicki
4b95f3a462 Mark width/height as optional 2016-10-05 11:02:58 -07:00
Kevin Sawicki
4ffae1d563 Add spec for getAspectRatio 2016-10-05 11:02:58 -07:00
Kevin Sawicki
abffd98e29 Resize images with preserve aspect ratio 2016-10-05 11:02:58 -07:00
Kevin Sawicki
56f9cc683a bounds -> rect 2016-10-05 11:02:57 -07:00
Kevin Sawicki
49cc00dedf Add tests of resizing/cropping an empty image 2016-10-05 11:02:57 -07:00
Kevin Sawicki
9fa13710aa Document crop and resize 2016-10-05 11:02:57 -07:00
Kevin Sawicki
0eda33f057 Add tests for cropping native images 2016-10-05 11:02:57 -07:00
Kevin Sawicki
2b4fff70d5 Add initial crop method 2016-10-05 11:02:57 -07:00
Kevin Sawicki
a80f4c1605 Add specs for other create image helpers 2016-10-05 11:02:57 -07:00
Kevin Sawicki
6aba4e916a 🎨 Use deepEqual asserts 2016-10-05 11:02:57 -07:00
Kevin Sawicki
6a7f0d70fd Add native image resize tests 2016-10-05 11:02:56 -07:00
Kevin Sawicki
042684fb38 Add resize method to native image 2016-10-05 11:02:56 -07:00
Kevin Sawicki
018575de71 Merge pull request #7496 from electron/app-doc-fix
Add newline before return list
2016-10-05 09:36:01 -07:00
Kevin Sawicki
8c0588d4e0 Merge pull request #7495 from toonborgers/translate-nl
📝 Dutch translation for CONTRIBUTING.md [ci skip]
2016-10-05 09:34:08 -07:00
Kevin Sawicki
aaa8c56686 Merge pull request #7487 from fplucas/master
📝 Fix the link source-code-directory-structure.md on pt-br [ci skip]
2016-10-05 09:33:07 -07:00
Kevin Sawicki
5e936a24ac Add newline before list 2016-10-05 09:24:33 -07:00
Michael Vasseur
edd80d88a9 Update BrowserWindow's test to check additional features upon window.open() call 2016-10-05 13:45:15 +02:00
Toon Borgers
25659e482e Fix relative url 2016-10-05 12:28:36 +02:00
Toon Borgers
a097d17166 Fix relative link, added translation link for dutch 2016-10-05 12:28:08 +02:00
Toon Borgers
d4bbc24031 Translate CONTRIBUTING.md 2016-10-05 12:25:50 +02:00
Michael Vasseur
3dd41bc09a Fix errors 2016-10-05 11:46:55 +02:00
Michael Vasseur
9490ec7686 Fix JS Lint issues 2016-10-05 09:47:39 +02:00
Michael Vasseur
a2b3cf95a7 Sets correct openerId in mergeBrowserWindowOptions() to give correct options to 'new-window' event handler 2016-10-05 09:47:39 +02:00
Michael Vasseur
cc7f4fedf6 Rebase with recent changes 2016-10-05 09:47:39 +02:00
Michael Vasseur
22bd7c0271 Updated the related documentation 2016-10-05 09:47:38 +02:00
Michael Vasseur
3408c8038e Fix indentation 2016-10-05 09:47:38 +02:00
Michael Vasseur
5a4cdcfde1 'new-window' event handlers can return their window when default behavior is prevented 2016-10-05 09:46:54 +02:00
Toon Borgers
0babe4a5ed Add english version to start from 2016-10-05 09:27:20 +02:00
Toon Borgers
a538b37854 Create CONTRIBUTING.md 2016-10-05 09:16:34 +02:00
Cheng Zhao
ebaeec1677 Merge pull request #7491 from electron/initialize-direct-write-font-proxy
Enable emoji as fallback font on Windows 10
2016-10-05 14:15:55 +09:00
Kevin Sawicki
1f1d9cefca Update libchromiumcontent for #7334 2016-10-04 17:28:46 -07:00
Kevin Sawicki
43f4eb76c4 Merge pull request #7489 from davej/patch-2
Docs: Correct image.getSize() type signature
2016-10-04 13:36:48 -07:00
Dave Jeffery
29b9fbcc9a Docs: Move buffer link to end of file 2016-10-04 21:34:24 +01:00
Dave Jeffery
4d10b9a31b Docs: Correct image.getSize() type signature 2016-10-04 21:20:42 +01:00
Lucas Pugliesi
0727102c5e 📝 Fix the link source-code-directory-structure.md on pt-br [ci skip] 2016-10-04 14:43:11 -03:00
Kevin Sawicki
4c2590ed92 Merge pull request #7486 from fplucas/master
📝 Translation of build-instructions-osx.md to pt-br [ci skip]
2016-10-04 10:31:08 -07:00
Lucas Pugliesi
66ce176b22 Merge remote-tracking branch 'upstream/master' 2016-10-04 14:27:00 -03:00
Lucas Pugliesi
a824ff479a 📝 Translation of build-instructions-osx.md to pt-br [ci skip] 2016-10-04 14:26:41 -03:00
Kevin Sawicki
c88c6b1323 Merge pull request #7481 from fplucas/master
📝 Translation of synopsis.md to pt-br [ci skip]
2016-10-04 09:11:16 -07:00
Kevin Sawicki
b459f00bd3 Merge pull request #7478 from tinydew4/translate-ko
Update the ko-KR docs related to the `additionalFeatures`.
2016-10-04 09:10:55 -07:00
Lucas Pugliesi
85a8b149bb 📝 Translation of synopsis.md to pt-br [ci skip] 2016-10-04 09:37:18 -03:00
tinydew4
3fcb57559a Update the ko-KR docs related to the . 2016-10-04 08:35:07 +00:00
Cheng Zhao
bf21892cfa Merge pull request #7291 from thomsonreuters/Fix_Missing_Additional_Features_New_Popup_Windows
Fix for missing additional features fields when creating new popup windows
2016-10-04 15:42:36 +09:00
Cheng Zhao
c4576463e2 Format the docs according to style guide 2016-10-04 14:41:37 +09:00
Michael Vasseur
3af686daff Documented JavasScript API changes related to the fix for additional features processing 2016-10-04 14:38:32 +09:00
Michael Vasseur
c811188e22 Updated required code to handle missing additional features for popup windows 2016-10-04 14:38:32 +09:00
Cheng Zhao
ef88a06f08 Update libchromiumcontent for #7291 2016-10-04 14:30:59 +09:00
Cheng Zhao
cf050ff9e2 Merge pull request #7468 from electron/focus-window-when-menu-is-clicked
Focus window when menu button is pressed
2016-10-04 14:22:49 +09:00
Kevin Sawicki
bb04069e83 Merge pull request #7437 from fplucas/master
📝 Translation of CONTRIBUTING.md to pt-br [ci skip]
2016-10-03 15:37:52 -07:00
Lucas Pugliesi
8d35576a36 Merge CONTRIBUTING.md 2016-10-03 15:18:03 -03:00
Kevin Sawicki
9cae04edde Remove unused ButtonListener 2016-10-03 10:26:18 -07:00
Kevin Sawicki
11684c2c73 Focus submenu buttons when clicked 2016-10-03 10:13:41 -07:00
Kevin Sawicki
e258973490 Merge pull request #7434 from rafaelstz/patch-2
Update year in LICENSE file
2016-10-03 09:29:54 -07:00
Kevin Sawicki
00d57fa547 Merge pull request #7433 from rafaelstz/patch-1
Update license in README file
2016-10-03 09:29:26 -07:00
Kevin Sawicki
24106469c5 Merge pull request #7456 from amitmerchant1990/patch-1
Update accessibility.md
2016-10-03 09:28:22 -07:00
Kevin Sawicki
9c55280917 Merge pull request #7457 from josephfrazier/fix-findinpage-links
Fix webContents.findInPage links in docs
2016-10-03 09:22:53 -07:00
Cheng Zhao
98333049ec Merge pull request #7452 from enlight/node-buffer-safe-free
Prevent undefined behavior when some Node Buffer objects are destroyed
2016-10-03 21:57:37 +09:00
Cheng Zhao
63b45a873b Merge pull request #7451 from was4444/master
keep up with en version
2016-10-03 21:35:06 +09:00
Cheng Zhao
ec34bfde26 Merge pull request #7432 from electron/check-if-window-closed
Ignore already closed windows
2016-10-03 21:21:35 +09:00
Cheng Zhao
8ae91ea2ee Merge pull request #7444 from rogerlista/master
📝 Translation of CODE OF CONDUCT.md to pt-BR [ci skip]
2016-10-03 21:19:35 +09:00
Cheng Zhao
772c456513 Merge pull request #7335 from miniak/set-default-error-mode
Add process.setDefaultErrorMode()
2016-10-03 20:53:42 +09:00
Cheng Zhao
3a4cd19226 Merge pull request #7461 from electron/revert-7416-fix-windows-draggable-high-dpi
Revert "Fix for issues seen on frameless window (Windows) when at 200% resolution"
2016-10-03 20:42:44 +09:00
Cheng Zhao
4d8c1c61a5 Revert "Fix for issues seen on frameless window (Windows) when at 200% resolution" 2016-10-03 20:41:52 +09:00
Cheng Zhao
bee3abe334 Merge pull request #7416 from bsclifton/fix-windows-draggable-high-dpi
Fix for issues seen on frameless window (Windows) when at 200% resolution
2016-10-03 18:34:18 +09:00
Joseph Frazier
5d1c626a53 Fix webContents.findInPage links in docs 2016-10-03 02:07:52 -04:00
Amit Merchant
fb612075c4 Update accessibility.md 2016-10-03 11:13:25 +05:30
Vadim Macagon
7c5d3296e7 Prevent undefined behavior when some Node Buffer objects are destroyed
If node::Buffer::New() is used to wrap an existing chunk of memory
without providing a custom callback to release that memory then Node
will just use `free()`. In a couple of places Node buffer objects were
constructed from chunks of memory that were allocated with `new[]`, but
a custom callback to release that memory was omitted, this resulted in
undefined behavior when those buffers were destroyed because `free()`
was used to release memory allocated with `new[]`.

To avoid undefined behavior the aforementioned buffer objects are now
constructed with a custom callback that safely releases the underlying
chunk of memory.
2016-10-03 10:26:26 +07:00
wxf
763fdb4be1 keep up with en version 2016-10-02 21:45:22 +08:00
Rogério
18c7ba94f8 📝 Translation of accessibility.md to pt-BR [ci skip] 2016-10-01 21:28:17 -03:00
Rogério
5fb72b5e05 📝 Translation of README.md to pt-BR [ci_skip] 2016-10-01 20:55:12 -03:00
Rogério
960971b195 📝 Translation of CONTRIBUTING.md to pt-BR[ci skip] 2016-10-01 19:56:01 -03:00
Rogério
b10a6422d4 Translation of CODE OF CONDUCT.md to pt-BR [ci skip] 2016-10-01 17:59:30 -03:00
Lucas Pugliesi
2714f280f5 📝 Translation of file-object.md to pt-br [ci skip] 2016-10-01 09:07:49 -03:00
Lucas Pugliesi
9c53d241fa 📝 Translation of CONTRIBUTING.md to pt-br [ci skip] 2016-10-01 08:45:31 -03:00
Rafael Corrêa Gomes
f4d33e366d Update year in LICENSE file 2016-10-01 00:34:29 -03:00
Rafael Corrêa Gomes
73cdf35c98 Update license in README file 2016-10-01 00:33:51 -03:00
Kevin Sawicki
140651c258 Ignore already closed windows 2016-09-30 15:04:13 -07:00
Kevin Sawicki
ff6a8fac2a Merge pull request #7417 from electron/check-sheet-parent-before-beginning
Only begin sheet when no sheet parent
2016-09-30 13:08:35 -07:00
Kevin Sawicki
1807458c66 Only begin sheet when no sheet parent 2016-09-30 10:43:43 -07:00
Kevin Sawicki
fb41474555 Merge pull request #7429 from electron/webview-max-listeners
Ensure webviews get reset after spec finishes
2016-09-30 10:43:27 -07:00
Kevin Sawicki
3f390c6849 Ensure webviews get reset after spec finishes 2016-09-30 10:15:11 -07:00
Kevin Sawicki
4a186069d9 Merge pull request #7428 from electron/sandbox-specs
Explicitly close popup window from sandbox spec
2016-09-30 09:28:59 -07:00
Kevin Sawicki
d942694695 openedWindow -> popupWindow 2016-09-30 08:54:24 -07:00
Kevin Sawicki
766f5afabd Explicitly close popup window 2016-09-30 08:50:41 -07:00
Kevin Sawicki
e16fa08e61 🎨 2016-09-30 08:38:21 -07:00
Kevin Sawicki
b07d4eba11 Merge pull request #7427 from tinydew4/translate-ko
Update ko-KR/api/session.md
2016-09-30 08:14:46 -07:00
tinydew4
f1d1070baa Update ko-KR/api/session.md 2016-09-30 15:09:11 +00:00
Kevin Sawicki
0c146de7dd Merge pull request #7422 from tinydew4/translate-ko
Update korean CODE_OF_CONDUCT.md
2016-09-30 07:56:07 -07:00
Cheng Zhao
5a56de501a Bump v1.4.2 2016-09-30 17:39:27 +08:00
Cheng Zhao
11d16a7342 Merge pull request #7415 from electron/disable-tab-menu-on-sierra
Hide Show Tab Bar menu item on macOS Sierra
2016-09-30 17:23:54 +08:00
Cheng Zhao
1b5db42ec6 Merge pull request #7398 from electron/cookie-changed-event
Add cookie changed event
2016-09-30 17:10:44 +08:00
tinydew4
0b6b4ca50d Update CODE_OF_CONDUCT.md 2016-09-30 06:32:07 +00:00
tinydew4
e7e8b3fdb6 Remove BOM to korean docs 2016-09-30 00:03:29 +00:00
Milan Burda
5bfa898a02 Always drop SEM_NOGPFAULTERRORBOX flag from error mode (enables WER if crashReporter is not started) 2016-09-29 13:57:41 -07:00
Kevin Sawicki
770a3509cf Add forward declaration of NSWindow.allowsAutomaticWindowTabbing 2016-09-29 10:54:59 -07:00
Kevin Sawicki
b14870d9a1 Merge pull request #7413 from deepak1556/devtools_filesystemapi_patch
browser: allow filesystem access for devtools scheme
2016-09-29 10:52:47 -07:00
Brian Clifton
52340b43f5 Possible fix for issues seen on frameless window (Windows) when at 200% 2016-09-29 10:48:36 -07:00
deepak1556
1323542373 browser: allow filesystem access for devtools scheme 2016-09-29 22:54:39 +05:30
Kevin Sawicki
24b9313958 Disable Show Tab Bar menu item on macOS Sierrra 2016-09-29 10:18:15 -07:00
Kevin Sawicki
0e1290fc10 Upgrade brightray for merged cookie delegate support 2016-09-29 09:18:21 -07:00
Kevin Sawicki
8abe8fe01d Remove unneeded locker and handle scope 2016-09-29 09:16:35 -07:00
Kevin Sawicki
77b35ba7ab Use separate session for cookies change event test 2016-09-29 09:16:35 -07:00
Kevin Sawicki
96e48ac13c Document cookie changed event 2016-09-29 09:16:35 -07:00
Kevin Sawicki
d83534d513 Add specs for cookie changed event 2016-09-29 09:16:35 -07:00
Kevin Sawicki
19c7ee0932 Use scoped_refptr for cookie delegate 2016-09-29 09:16:35 -07:00
Kevin Sawicki
24bcf6ac16 Add initial cookie changed event support 2016-09-29 09:16:29 -07:00
Kevin Sawicki
5d23d165a9 Upgrade brigthray for cookie monster delegate 2016-09-29 09:16:29 -07:00
Kevin Sawicki
b3b9994ce8 Configure ink drops on menu bar buttons (#7397)
* Add ink drop to menu bar buttons

* Pass background color to submenu button

* Sort includes
2016-09-29 09:15:12 -07:00
Arus
df0bda058f Update korean docs, according to most recent changes and other missing. (#7400)
* Apply changes

* Apply changes

* Apply changes

* Apply changes

* Fix all JS standard syntax errors

* Apply of recent changes, #7374
2016-09-29 08:52:40 -07:00
Cheng Zhao
15b8449411 Merge pull request #7393 from electron/upgrade-brigthray-for-ct-fix
Upgrade Brightray for certificate transparency crash fix
2016-09-29 16:56:31 +08:00
Cheng Zhao
e1d68fa3cd Merge pull request #7374 from electron/fixup-return-values
Update docs to contain more specific return values
2016-09-29 16:44:08 +08:00
Cheng Zhao
2c9ce3f3e0 Merge pull request #7372 from electron/update-docs-linter
update electron-docs-linter
2016-09-29 16:43:22 +08:00
Cheng Zhao
734f42b5f9 Merge pull request #7319 from Menci/master
Workaround for electron/electron#5050
2016-09-29 16:42:30 +08:00
Kevin Sawicki
3cff64001d Upgrade brightray for CT crash fix 2016-09-28 16:02:48 -07:00
Kevin Sawicki
241297fb2e Merge pull request #7388 from electron/custom-window-level-test
Add test for BrowserWindow.setAlwaysOnTop
2016-09-28 15:47:29 -07:00
Kevin Sawicki
d4583006b3 Merge pull request #7391 from kiavashps/patch-1
docs: app.md - fix relaunch arg concat syntax
2016-09-28 10:30:59 -07:00
Kiavash Page
d42e51e33a app.md - fix relaunch arg concat syntax 2016-09-28 10:23:03 -07:00
Kevin Sawicki
3bed19d70d Add spec for BrowserWindow.setAlwaysOnTop 2016-09-28 09:23:52 -07:00
Kevin Sawicki
fd6ef6712f Link to window level macOS docs 2016-09-28 09:20:22 -07:00
Cheng Zhao
c51982a231 Merge pull request #7362 from bsclifton/fix-windows-draggable-high-dpi
Fixes mouse coordinates for Windows when display is set to a higher DPI
2016-09-28 19:42:17 +08:00
Cheng Zhao
53d4c36332 Merge pull request #7353 from electron/no-login-item-apis-on-mas
document lack of MAS support for login item APIs
2016-09-28 19:20:32 +08:00
Cheng Zhao
de76bf5f63 Merge pull request #7296 from adammeyer/custom-window-level
Allow custom window level when sending window to top
2016-09-28 19:18:12 +08:00
Samuel Attard
e0e47ea9a1 Update docs to contain more specific return values 2016-09-28 18:28:44 +13:00
Zeke Sikelianos
3989139378 update electron-docs-linter 2016-09-27 22:04:22 -07:00
Menci
ca68dfe097 🎨 Remove extra semicolon 2016-09-28 06:45:15 +08:00
Kevin Sawicki
5114d571df Merge pull request #7364 from tiagotol/patch-1
Update quick-start.md
2016-09-27 13:02:25 -07:00
tiagotol
08808664b6 Update quick-start.md 2016-09-27 14:29:35 -03:00
Brian Clifton
13de65d310 Fixes mouse coordinates for Windows when display is set to a higher DPI (ex: enlarged by 150% using display settings) 2016-09-27 08:23:48 -07:00
Zeke Sikelianos
6728efe87e Merge pull request #7339 from electron/document-return-values
Document the return values of all methods in the docs
2016-09-27 07:39:25 -07:00
Cheng Zhao
458c4dd129 Merge branch 'support-chromium-sandbox' of https://github.com/tarruda/electron into tarruda-support-chromium-sandbox 2016-09-27 20:02:23 +08:00
Menci
ef45b67dbf 🐧 🐛 Move the workaround to lib/browser/init.js 2016-09-27 19:19:52 +08:00
Cheng Zhao
604700187d Merge pull request #7327 from MaxWhere/osr-fixes
Small fixes for offscreen rendering
2016-09-27 19:17:10 +08:00
Cheng Zhao
7e1ae369ed Merge pull request #7356 from electron/fix-typo
fix typo
2016-09-27 19:05:06 +08:00
Cheng Zhao
9850af93c9 Merge pull request #7313 from electron/add-type-to-webview-style-tag
add type to webview style tag
2016-09-27 19:03:08 +08:00
Cheng Zhao
4c8d0ab804 Merge pull request #7298 from deepak1556/content_settings_patch
protocol: disable storage for non standard custom schemes
2016-09-27 18:52:36 +08:00
Thiago de Arruda
47fd41715f Add some tests for "sandbox" option 2016-09-27 06:01:47 -03:00
Thiago de Arruda
a64978b812 Use the routing id on api::WebContents::GetID
The sandbox option allows multiple webContents in one renderer process, so using
the only the renderer id to identify WebContents instances is no longer an
option.

WebContents::GetID now returns a 64-bit integer, which is composed of both the
process id(high 32), and the RenderViewHost routing id(low 32). Also add a
`GetProcessID` that retrieves the renderer process id, a requirement in some of
our javascript code.
2016-09-27 06:01:47 -03:00
Thiago de Arruda
524bab530a Improve AtomSandboxedRendererClient to support preload scripts.
Add RenderFrameObserver/RenderViewObserver subclasses that implement the
necessary support for preload scripts in sandboxed renderers.
2016-09-27 06:01:47 -03:00
Thiago de Arruda
72154b64ed Embed setup bundle for preload scripts in sandboxed renderers.
Add a gyp target that creates a browserify bundle starting with
`lib/sandboxed_renderer/init.js`, which is embedded into the executable using
the `atom_js2c` target.

The goal of this bundle is to provide a very basic environment for preload
scripts where a `require` function is available.
2016-09-27 06:01:47 -03:00
Thiago de Arruda
695509e267 Add browser side support for reading files from renderer. 2016-09-27 06:01:46 -03:00
Thiago de Arruda
0f7652dc85 Move code that defines ipcRenderer methods into another file. 2016-09-27 06:01:46 -03:00
Thiago de Arruda
1713200084 Refactor the atom_js2c target to include javascript from multiple dirs.
Before invoking js2c, copy all files that must be embedded into the shared
intermediate directory, and modify the js2c wrapper script to include all files
from that directory(which is passed as argument).

This allows the build system to embed files that don't share a common base
directory, such as javascript generated at build time.
2016-09-27 06:01:46 -03:00
Thiago de Arruda
6afe8aa7f2 Move EmitIPCEvent into AtomRenderViewObserver.
Refactor this function as a method so it is possible to inherit most behavior
from AtomRenderViewObserver and override EmitIPCEvent.
2016-09-27 06:01:46 -03:00
Thiago de Arruda
c8629019f5 Expose atom_api_renderer_ipc module API 2016-09-27 06:01:46 -03:00
Thiago de Arruda
a7b6332ed0 Add atom::AtomSandboxedRendererClient class 2016-09-27 06:01:46 -03:00
Thiago de Arruda
06cc9a44fe Add support for native chromium popups on sandboxed renderers.
- Allow `api::Window` instances to be created from existing `api::WebContents`.
- Override `WebContentsCreated` and `AddNewContents` to wrap renderer-created
  `content::WebContents` into `api::WebContents`.
- For `content::WebContents` that should be displayed in new windows, pass the
  wrapped `api::WebContents` object to window manager.
2016-09-27 06:01:46 -03:00
Thiago de Arruda
0b3b29938f Allow api::WebContents to fully wrap an existing content::WebContents.
- Add an overload to `WebContents::CreateFrom` that accepts a type parameter. If
  type is `REMOTE`, initialization is the same as before(a thin wrapper). If
  not, the `api::WebContents` will be fully initialized, as if it was created by
  `api::WebContents::Create`.
- Move common initialization code to `InitWithSessionAndOptions`.
2016-09-27 06:01:46 -03:00
Thiago de Arruda
1b1541fe1a Decouple api::Window initialization from api::WebContents construction. 2016-09-27 06:01:46 -03:00
Thiago de Arruda
1d228446db Expose --enable-sandbox command-line switch.
When `--enable-sandbox` is passed, electron will use chromium sandbox to spawn
all renderers, and every new BrowserWindow will automatically have "sandboxed"
passed as a web preference(since the renderer would not work properly
otherwise).
2016-09-27 06:01:46 -03:00
Thiago de Arruda
c783ec72bc Add "sandboxed" option to "webPreferences".
When "sandboxed" is passed as a web preference for `BrowserWindow`, the newly
created renderer won't run any node.js code/integration, only communicating with
the system via the IPC API of the content module. This is a requirement for
running the renderer under chrome OS-level sandbox.

Beyond that, certain behaviors of AtomBrowserClient are modified when dealing
with sandboxed renderers:

- `OverrideSiteInstanceNavigation` no longer create a new `SiteInstance` for
  every navigation. Instead, it reuses the source `SiteInstance` when not
  navigating to a different site.
- `CanCreateWindow` will return true and allow javascript access.
2016-09-27 06:01:46 -03:00
Zeke Sikelianos
90c5972fce Merge pull request #7342 from tinydew4/update-changes
Update changes to korean docs.
2016-09-26 22:19:45 -07:00
Zeke Sikelianos
1f677ed361 fix typo 2016-09-26 22:12:51 -07:00
Zeke Sikelianos
9c19b4e3d5 Merge pull request #7343 from tinydew4/translate-ko
Translate newest styleguide.md and update changes to system-preferences.md
2016-09-26 21:47:42 -07:00
Zeke Sikelianos
d4a1f396fb tweak wording about complex objects 2016-09-26 21:04:54 -07:00
arus
72e3816143 Change a word 2016-09-27 09:38:23 +09:00
arus
9dd181c206 Change some sentences after review 2016-09-27 09:34:59 +09:00
Zeke Sikelianos
9828926002 Merge pull request #7340 from tinydew4/fix-link
Fix broken link in original docs
2016-09-26 12:04:22 -07:00
Zeke Sikelianos
bb955b6202 document lack of MAS support for login item APIs 2016-09-26 11:00:13 -07:00
Cheng Zhao
1dd05ff520 Merge pull request #7338 from electron/fix-get-accent-color-docs
Fix getAccentColor() docs in system-preferences.md
2016-09-26 15:39:40 +08:00
Cheng Zhao
19bd5ea8ba Merge pull request #7316 from tinydew4/update-ko
Update debugging-main-process and Add planned-breaking-changes
2016-09-26 12:56:22 +08:00
arus
bcf7a86dc7 Update changes to ko-KR/api 2016-09-26 00:03:32 +09:00
arus
2fbdac1034 Update changes to ko-KR/api/app.md 2016-09-25 23:50:36 +09:00
arus
577585df63 Update changes to ko-KR/api/power-monitor.md 2016-09-25 23:48:09 +09:00
arus
f13bd655a1 Update changes to ko-KR/api/screen.md 2016-09-25 23:45:56 +09:00
arus
81de0518d9 Update changes to ko-KR/api/web-contents.md 2016-09-25 23:43:24 +09:00
arus
d93a86e8cc Remove some changes 2016-09-25 23:37:34 +09:00
arus
7e186cee55 Remove some changes 2016-09-25 23:28:59 +09:00
arus
97da066ae2 Update changes to ko-KR/api/web-contents.md 2016-09-25 23:25:05 +09:00
arus
b58f73b5c9 Update change to ko-KR/README.md 2016-09-25 23:18:18 +09:00
arus
ad1cb16a76 Update changes to web-view-tag.md 2016-09-25 22:58:41 +09:00
arus
cd4a66dca5 Update changes to browser-window.md 2016-09-25 22:40:05 +09:00
arus
cc282a1114 Update /ko-KR/api/system-preferences.md 2016-09-25 21:57:43 +09:00
arus
270d6f774a Update changes to browser-window and correct a word 2016-09-25 21:40:33 +09:00
Samuel Attard
987a2e173a Fix docs linting 2016-09-25 21:57:37 +13:00
arus
66efaa5e0f Update /ko-KR/styleguide.md 2016-09-25 17:04:34 +09:00
arus
27a9f960de Fix broken link 2016-09-25 16:15:16 +09:00
arus
74e03d285e Fix broken link 2016-09-25 16:13:34 +09:00
arus
123f2a8265 Update /ko-KR/styleguide.md 2016-09-25 16:05:45 +09:00
arus
d25c2d0f41 Update /ko-KR/api/system-preferences.md 2016-09-25 16:05:45 +09:00
Samuel Attard
d2a701a465 Document the return values of all methods in the docs 2016-09-25 12:59:30 +13:00
Vadim Macagon
1df30821db Fix getAccentColor() docs in system-preferences.md
Example was using a non-existent method.
2016-09-25 01:45:34 +07:00
Zeke Sikelianos
bf88fe32fd Merge pull request #7333 from tinydew4/translate-ko
Translate CODE_OF_CONDUCT and change a word as other docs, in korean
2016-09-24 10:04:04 -07:00
arus
e21d5bd380 Change some sentences more smoothly 2016-09-24 15:58:58 +09:00
arus
04bdc87283 Change some smoothly 2016-09-24 11:33:31 +09:00
arus
177ccbc014 Translate CODE_OF_CONDUCT and change a word as other docs, in korean 2016-09-24 10:37:17 +09:00
Zeke Sikelianos
d6cd9e3034 Merge pull request #7331 from tinydew4/fix-link
Fix broken links
2016-09-23 17:19:07 -07:00
Zeke Sikelianos
d391f1b527 Merge pull request #7330 from tinydew4/translate-ko
Translate accessibility and change some in korean
2016-09-23 17:07:40 -07:00
arus
8c7a4de27b Fix broken links 2016-09-24 08:26:25 +09:00
Arus
7cd7894878 Update accessibility.md 2016-09-24 08:23:36 +09:00
arus
d7fc7ef2ee Fix errata 2016-09-24 08:19:24 +09:00
arus
6aef061362 Translate accessibility.md in korean 2016-09-24 08:14:19 +09:00
arus
e4943b3ab3 Change more smoothly 2016-09-24 07:18:39 +09:00
arus
091136908d Replace changes as link of original docs 2016-09-24 06:51:28 +09:00
Zeke Sikelianos
c6390e71d9 Merge pull request #7314 from tinydew4/translate-ko
Translate ko, debug-instructions-macos.md
2016-09-23 11:53:45 -07:00
gellert
ab5e51c209 fixes software rendering on macos and small resizing addition 2016-09-23 20:27:05 +02:00
Menci
938b9e897a 🐧 🐛 Workaround for electron/electron#5050
Chromium only show the Tray icon with libappindicator when the env `XDG_CURRENT_DESKTOP`'s value is `Unity`. But under elementaryOS its value is 'Pantheon'.

Set it to `Unity` before app startup make the tray icon show under elementaryOS.
2016-09-23 18:07:43 +08:00
arus
924033c2ba Remove notice on top 2016-09-23 14:03:42 +09:00
arus
99e256f461 Translate debug-instructinos-macos.md in korean 2016-09-23 14:03:42 +09:00
arus
d2bcbafe73 Translate additonally 2016-09-23 12:56:21 +09:00
arus
5c07643d24 Apply debugging-main-process changes in korean 2016-09-23 12:51:28 +09:00
Zeke Sikelianos
56d62ff589 add html doctype 2016-09-22 14:47:20 -07:00
Zeke Sikelianos
62375663ab add type to webview style tag 2016-09-22 14:34:03 -07:00
Kevin Sawicki
f5694daeb7 Merge pull request #7299 from Gioggio/master
Docs: Start Italian translations
2016-09-22 12:21:09 -07:00
Gioggio
3a73625ece 📝 Update translation for faq.md
[ci skip]
2016-09-22 21:07:13 +02:00
Gioggio
3b45f5a8e9 📝 Add styleguide.md
[ci skip]
2016-09-22 21:07:13 +02:00
Gioggio
78791763cf 📝 Fix typos and improve translations in README.md
[ci skip]
2016-09-22 21:07:13 +02:00
Gioggio
81b55c1700 📝 Add faq.md
[ci skip]
2016-09-22 21:07:13 +02:00
Gioggio
39a3ffdb9d 📝 Add README.md
[ci skip]
2016-09-22 21:07:13 +02:00
Kevin Sawicki
df03c92249 Compare against NSNormalWindowLevel in IsAlwaysOnTop 2016-09-22 09:41:06 -07:00
Kevin Sawicki
c336cf59c1 Ignore level when calling SetAlwaysOnTop on Widget 2016-09-22 09:38:04 -07:00
Kevin Sawicki
fcd6fd9fd5 Merge pull request #7310 from BenV/patch-1
Add npm_config_target_arch to native module doc
2016-09-22 09:34:19 -07:00
Kevin Sawicki
1ec173ad81 Merge pull request #7308 from tinydew4/translate-ko
Apply docs changes to korean docs
2016-09-22 09:32:41 -07:00
Kevin Sawicki
bce62622bb Fix compiler errors 2016-09-22 09:22:28 -07:00
Ben Vinson
1290ddb5c9 Add npm_config_target_arch to native module doc
We ran into an issue when creating a 32-bit binary on 64-bit Windows where node-pre-gyp kept using the 64-bit library. Setting the `npm_config_target_arch` environment variable resolved the problem for us and caused the 32-bit binary to be built and used.
2016-09-22 09:46:31 -06:00
Kevin Sawicki
ea42722918 Merge pull request #7284 from enlight/debugging-with-electron-inspector
Split up debugging-main-process.md, add electron-inspector guide
2016-09-22 08:40:38 -07:00
arus
aac09e5234 Fix erratum 2016-09-22 22:56:19 +09:00
arus
df3896b143 Apply docs changes to korean docs 2016-09-22 22:53:11 +09:00
Cheng Zhao
903bf444d9 Bump v1.4.1 2016-09-22 19:05:58 +09:00
Cheng Zhao
3dad8734a0 Do not copy api.json on Windows 2016-09-22 19:05:58 +09:00
Vadim Macagon
762a5bbefa Split up debugging-main-process.md, add electron-inspector guide
- Move the debugging guides for VSCode and node-inspector into separate
  files.
- Add instructions for using electron-inspector to the node-inspector
  guide.
- Remove note in node-inspector guide about crashing when inspecting
  `process` (it was fixed a long time ago:
  https://github.com/nodejs/node-v0.x-archive/issues/8205)
2016-09-22 15:43:06 +07:00
Cheng Zhao
d3a175cea8 Merge pull request #7303 from electron/fix-out-dir
electron-api.json is under out/ instead of out/R/
2016-09-22 14:39:33 +09:00
Cheng Zhao
4e0f810148 electron-api.json is under out/ instead of out/R/ 2016-09-22 14:31:28 +09:00
Cheng Zhao
32543997d4 Merge pull request #7297 from electron/clean-docs
Mention build cleaning on all three platforms
2016-09-22 14:14:36 +09:00
Cheng Zhao
c9a3ab3a81 Merge pull request #7295 from electron/native-image-bad-path-docs
Mention createFromPath bad path return value
2016-09-22 14:14:15 +09:00
Cheng Zhao
3b4a071723 Merge pull request #7294 from electron/mutate-remote-array-docs
Mention mutating remote arrays and buffers
2016-09-22 14:13:49 +09:00
Cheng Zhao
de9b01409b Merge pull request #7293 from electron/bookmark-windows-docs
Mention using fallback text when writing bookmarks on Windows
2016-09-22 14:13:28 +09:00
Cheng Zhao
296a53536d Merge pull request #7292 from electron/ct-log-verifiers
Upgrade Brigthray for CT log verifier fix
2016-09-22 14:11:20 +09:00
adammeyer
783d47f78b custom window level as string 2016-09-21 22:49:06 -04:00
adammeyer
b35bde662a custom window level docs 2016-09-21 19:06:36 -04:00
deepak1556
ad783652c8 update docs 2016-09-22 00:20:34 +05:30
deepak1556
7ba947aee9 add spec 2016-09-22 00:15:25 +05:30
Kevin Sawicki
696e5e73bc Upgrade Brigthray for CT log verifier fix 2016-09-21 11:29:09 -07:00
Kevin Sawicki
a723d17f49 Mention cleaning on all three platforms 2016-09-21 11:10:52 -07:00
Kevin Sawicki
f8236c1a65 Add more failure asserts for nativeImage.createFromPath 2016-09-21 10:48:24 -07:00
Kevin Sawicki
546c0e7822 Mention createFromPath failure cases 2016-09-21 10:48:01 -07:00
Kevin Sawicki
e7c4d2523b Mention mutating remote arrays and buffers 2016-09-21 10:44:54 -07:00
adammeyer
fbb3a288ec Allow custom window level when sending window to top 2016-09-21 13:35:59 -04:00
Kevin Sawicki
cae15ad6b5 Mention using fallback text when writing bookmarks on Windows 2016-09-21 10:31:01 -07:00
deepak1556
ed465208a2 renderer: add content settings class for managing storage 2016-09-21 21:47:30 +05:30
Kevin Sawicki
c2c48c4079 Merge pull request #7290 from tinydew4/translate-ko
Translate tutorial/about.md
2016-09-21 09:04:20 -07:00
Kevin Sawicki
dc7d2dab68 Merge pull request #7287 from tinydew4/translate-update
Update windows-store-guide.md in ko-KR docs
2016-09-21 09:03:48 -07:00
arus
146970d29d Add missing sample codes 2016-09-22 00:35:27 +09:00
arus
ba2cb42f0d Remove incorrect letters 2016-09-22 00:30:20 +09:00
arus
7dfe1a59b1 Translate remains in about.md 2016-09-22 00:18:28 +09:00
arus
4343f762ac Translate some in about.md 2016-09-22 00:15:57 +09:00
arus
e2f53c6bcc Translate some in about.md 2016-09-22 00:13:44 +09:00
arus
5c22f2ca5d Translate some in about.md 2016-09-22 00:05:26 +09:00
arus
b6d4014bd5 Translate some in about.md 2016-09-22 00:04:24 +09:00
arus
6b8f5f5b7f Translate some in about.md 2016-09-22 00:01:21 +09:00
arus
b7e2f819a3 Translate Core Philosophy in about.md 2016-09-21 23:55:16 +09:00
arus
a8e0e8d7fd Translate LTS in about.md 2016-09-21 23:42:07 +09:00
arus
beea9a7c36 Translate Update dependencies and Versioning in about.md 2016-09-21 23:35:19 +09:00
arus
a44d7a3bc6 Translate some in aboud.md 2016-09-21 23:11:29 +09:00
arus
b45db70d21 Translate Releases in about.md 2016-09-21 23:08:32 +09:00
arus
8feff471ce Modify some in about.md 2016-09-21 23:04:41 +09:00
arus
00dec166e9 Translate Core Team and Contributors in about.md 2016-09-21 23:03:23 +09:00
arus
ebbbaf1ab0 Translate Core Team and Contributors in about.md 2016-09-21 23:03:02 +09:00
arus
29312186de Translate about/about electron in Korean 2016-09-21 22:38:17 +09:00
arus
e1d9e4ffcb Merge branch 'translate-update' of https://github.com/tinydew4/electron into translate-update 2016-09-21 22:01:54 +09:00
arus
b6c04c9e35 Update windows-store-guide.md in ko-KR docs 2016-09-21 22:00:48 +09:00
arus
405b411a29 Merge branch 'translate-update' of https://github.com/tinydew4/electron into translate-update 2016-09-21 21:44:07 +09:00
arus
582fc50cf6 Update windows-store-guide.md in ko-KR docs 2016-09-21 21:43:18 +09:00
arus
b74cfda7b9 Update windows-store-guide.md in ko-KR docs 2016-09-21 21:35:35 +09:00
Cheng Zhao
805ce0dee9 Merge pull request #7276 from electron/google-api-key-env2
allow GOOGLE_API_KEY to be set
2016-09-21 15:16:29 +09:00
Zeke Sikelianos
f4a8fb9eb4 🎨 standard 2016-09-20 14:55:45 -07:00
Kevin Sawicki
85702604c3 Merge pull request #7277 from electron/dictionary-to-object
Set parameter type to Object instead of Dictionary
2016-09-20 14:48:48 -07:00
Kevin Sawicki
98999f4850 Add missing s in progress 2016-09-20 14:46:17 -07:00
Kevin Sawicki
b5e1571204 Set parameter type to Object 2016-09-20 14:26:55 -07:00
Zeke Sikelianos
d7934e7525 add link to chromium API keys doc 2016-09-20 14:13:30 -07:00
Zeke Sikelianos
7fcba6ba0f document the GOOGLE_API_KEY env var 2016-09-20 13:58:39 -07:00
Kevin Sawicki
ea1927f428 Store api_key_ on TokenLoadingJob 2016-09-20 13:24:45 -07:00
Zeke Sikelianos
fa2aaa48b1 allow GOOGLE_API_KEY to be set in environment 2016-09-20 12:01:59 -07:00
Kevin Sawicki
dee383db07 Merge pull request #7273 from tinydew4/fix-links
Fix some bronken links
2016-09-20 09:00:08 -07:00
Kevin Sawicki
04a1dc8e1e Merge pull request #7272 from tinydew4/translate-ko
Translate "offscreen rendering" in Korean
2016-09-20 08:59:53 -07:00
Kevin Sawicki
ae31ded165 Merge pull request #7265 from octref/patch-1
Add instruction for debugging main process in VSCode
2016-09-20 08:59:37 -07:00
arus
402e977b40 Fix some bronken links 2016-09-20 23:36:20 +09:00
arus
a65c8cae63 modify some 2016-09-20 23:30:46 +09:00
arus
47a03d3ca1 modify some 2016-09-20 23:29:34 +09:00
arus
b4a13fda3a Translate offscreen rendering in Korean 2016-09-20 23:19:15 +09:00
Cheng Zhao
e11672d42b Merge pull request #7262 from tinydew4/patch-1
Update browser-window.md
2016-09-20 16:04:25 +09:00
Cheng Zhao
30a6b597a5 Merge pull request #7239 from darkdh/6873
Emit scroll-touch-edge event instead of changing the behavior of scrollll-touch-begin/end
2016-09-20 14:51:10 +09:00
Pine
c45ca254e3 Add instruction for debugging main process in VSCode
I hope you don't mind me putting the VSCode part before `node-inspector`, because VSCode seems easier to setup, and VSCode could inspect `process` without crashing.
2016-09-19 22:43:05 -07:00
Cheng Zhao
143d7ab98f Merge pull request #7264 from electron/docs-readme
Docs Readme
2016-09-20 14:31:31 +09:00
Cheng Zhao
e3e450613d Merge pull request #7157 from Mossop/moveguest
Allow moving a webcontents to a different webview
2016-09-20 14:28:42 +09:00
Cheng Zhao
77fdc67235 Merge pull request #7173 from electron/windows-system-color
Add an app API method to fetch the system ColorizationColor
2016-09-20 14:06:21 +09:00
Zeke Sikelianos
61e50046bd link to the documentation styleguide 2016-09-19 21:10:36 -07:00
Zeke Sikelianos
1cdf8bbc10 break up run-on sentence 2016-09-19 21:09:31 -07:00
Zeke Sikelianos
a3d2cdaa2c website doesn't display docs for old versions any more 2016-09-19 21:09:02 -07:00
Arus
159e2f2dab Update browser-window.md 2016-09-20 11:26:04 +09:00
Kevin Sawicki
e8f3cf164b Merge pull request #7227 from electron/felix-cmd-strings
Ensure correct types for commandLine
2016-09-19 10:22:28 -07:00
Samuel Attard
456f102cdc Fix k typo 2016-09-20 02:42:41 +10:00
Samuel Attard
ba98109d33 Remove semicolons from spec 2016-09-20 02:41:26 +10:00
Samuel Attard
9f94652792 Add basic spec for getAccentColor 2016-09-20 02:41:26 +10:00
Samuel Attard
1454510549 Alphabetical method ordering 2016-09-20 02:41:26 +10:00
Samuel Attard
c0f8b4895d Update docs 2016-09-20 02:41:26 +10:00
Samuel Attard
5dd5dbb3d8 Add a systemPreferences API method to fetch the system ColorizationColor
This is useful for automatical app theming

* Fetches the color from the registry
* Returns an empty string if the fetch fails (a falsey value)
2016-09-20 02:41:26 +10:00
Kevin Sawicki
48fd2bd35f binding -> bindings 2016-09-19 09:31:59 -07:00
Felix Rieseberg
29fa48d8c3 🔧 Ensure correct types for commandLine
This commit ensures that arguments passed to `appendSwitch` and `appendArgument` are turned into strings before passing them over to the binding.
2016-09-19 09:31:59 -07:00
Felix Rieseberg
90bff4d9de 🔧 Ensure correct types for commandLine
This commit ensures that arguments passed to `appendSwitch` and `appendArgument` are turned into strings before passing them over to the binding.
2016-09-19 09:31:59 -07:00
Cheng Zhao
b05254807b Merge pull request #7253 from electron/osr-crash
Unsubscribe observer when OffScreenRenderWidgetHostView is destroyed
2016-09-19 17:54:31 +09:00
Cheng Zhao
e504d82554 spec: Suppress the download.pdf test on AppVeyor 2016-09-19 17:12:33 +09:00
Cheng Zhao
5bf746700e Unsubscribe observer when OffScreenRenderWidgetHostView is destroyed 2016-09-19 16:51:03 +09:00
Cheng Zhao
07a08077a2 Revert electron/brightray#246 2016-09-19 16:31:00 +09:00
Cheng Zhao
26004f1a66 Merge pull request #7241 from miniak/crashed-killed
Add killed argument for webContents.on("crashed") and app.on("gpu-process-crashed") events
2016-09-19 16:02:52 +09:00
Cheng Zhao
1c6586c4b9 Merge pull request #7238 from electron/felix-windows-store-docs
Update Windows Store Language
2016-09-19 15:54:23 +09:00
Cheng Zhao
0ac4b89a0a Merge pull request #7236 from yuya-oc/accelerator-for-redo
Use Ctrl+Y as the accelerator of redo on Windows
2016-09-19 15:53:44 +09:00
Cheng Zhao
6de1eef078 Merge pull request #7234 from Mossop/testhistoryreplace
 Test that replacement history entries don't break forward navigation.
2016-09-19 15:47:30 +09:00
Cheng Zhao
1fd819e500 Merge pull request #7231 from miniak/default-error-mode
Fix ELECTRON_DEFAULT_ERROR_MODE
2016-09-19 15:44:52 +09:00
Cheng Zhao
a260647b4f Merge pull request #7062 from MaxWhere/osr-sizing-fix
Offscreen invalidate and sizing fix
2016-09-19 15:38:11 +09:00
Cheng Zhao
ffe931bde7 Merge pull request #7226 from electron/power-monitor-error
Rethrow caught errors from process.binding
2016-09-19 15:25:18 +09:00
Cheng Zhao
27bc6c7883 Merge pull request #7233 from electron/deprecate-atom-shell-version
Deprecate process.versions['atom-shell']
2016-09-19 15:24:10 +09:00
Cheng Zhao
6c340cece8 Merge pull request #7229 from electron/update-clang
Update clang to r274142.
2016-09-19 15:23:57 +09:00
Cheng Zhao
64718173ef Merge pull request #7230 from electron/windows-x64-link-crypt32
Link against crypt32.lib
2016-09-19 15:23:41 +09:00
Yuya Ochiai
43f955194e 🏁 Use Ctrl+Y as the accelerator of redo on Windows 2016-09-18 17:07:34 +09:00
Milan Burda
8567f79e67 Add killed argument for webContents.on("crashed") and app.on("gpu-process-crashed") events 2016-09-17 17:02:36 -07:00
Anthony Tseng
269a87b26f Emit scroll-touch-edge event instead of changing the behavior of scroll-touch-begin/end
fix #6873
2016-09-17 22:50:10 +08:00
Felix Rieseberg
084110c56f 📝 Update Windows Store Language 2016-09-17 04:19:55 -07:00
Dave Townsend
47df447e4f Test that replacement history entries don't break forward navigation.
This is a test for #7175
2016-09-16 17:08:54 -07:00
Kevin Sawicki
1072519488 Mark atom-shell version as deprecated 2016-09-16 15:59:00 -07:00
gellert
37de2301f7 moves setsize call to osr renderwidgethostview 2016-09-16 23:28:51 +02:00
gellert
fec5a7d67a removes extra header 2016-09-16 23:27:51 +02:00
gellert
8baaad4e0d cleanup and adds docs 2016-09-16 23:27:51 +02:00
gellert
10ea0268e5 calling setsize only on osr windows 2016-09-16 23:27:11 +02:00
gellert
b4c220613f adds invalidate method and proper resizing 2016-09-16 23:27:11 +02:00
Zeke Sikelianos
d4b204799d Merge pull request #7120 from electron/lint-docs
Publish the public API as a JSON object
2016-09-16 14:05:32 -07:00
Milan Burda
12a2b144f3 Only drop the SEM_NOGPFAULTERRORBOX flag when calling SetErrorMode (ELECTRON_DEFAULT_ERROR_MODE) 2016-09-16 14:01:33 -07:00
Kevin Sawicki
7df86c48fa Link against crypt32.lib 2016-09-16 13:17:58 -07:00
Kevin Sawicki
0c3ad527e3 initialize -> require 2016-09-16 13:09:06 -07:00
Haojian Wu
37e30cef60 Update clang to r274142. 2016-09-16 21:59:25 +02:00
Kevin Sawicki
0fda86f79a Mention not requiring module until app is ready 2016-09-16 11:42:02 -07:00
Kevin Sawicki
e77d7e7f62 🎨 2016-09-16 11:41:53 -07:00
Kevin Sawicki
5d0f3534eb Rethrow binding errors 2016-09-16 11:34:52 -07:00
Kevin Sawicki
577394442b power-monitor -> powerMonitor 2016-09-16 09:58:27 -07:00
Cheng Zhao
d1274bb79f Update brightray for #7073 2016-09-16 21:28:24 +09:00
Cheng Zhao
da677b683b Merge pull request #7163 from MaxWhere/frame-sub-scale-fix
Frame subscriber improvements
2016-09-16 21:24:53 +09:00
Cheng Zhao
9dad9478fa Merge pull request #7169 from deepak1556/download_defaultname_patch
browser: provide a default filename when unable to generate from download data
2016-09-16 21:19:21 +09:00
Cheng Zhao
ea244a5188 Merge pull request #7209 from electron/remote-function-missing-properties
Guard against missing remote function properties
2016-09-16 21:11:12 +09:00
Cheng Zhao
69d4cac760 Merge branch 'release' 2016-09-16 21:03:54 +09:00
deepak1556
e7f1265b64 add save-to-disk disposition for new-window event 2016-09-16 16:30:26 +05:30
deepak1556
94faaf7d58 provide a default file name for downloads 2016-09-16 16:02:57 +05:30
deepak1556
d426d4ad90 add failing spec 2016-09-16 16:02:57 +05:30
gellert
64e53a17bd reverts subscriber api 2016-09-16 11:18:15 +02:00
Cheng Zhao
20d5a50ac9 Merge pull request #7178 from aichingm/master
🐧 Add support for different trash implementations
2016-09-16 17:43:09 +09:00
Cheng Zhao
9714348260 Merge pull request #6941 from deepak1556/blob_data_patch
protocol: provide blob uuid with uploadData
2016-09-16 17:01:15 +09:00
Plusb Preco
787bc85703 docs: Update Korean docs as upstream (#7211)
* 📝 Update `README-ko.md`

* Remove Korean readme specified header.
* Add Indonesia community link.

* 📝 Update Korean docs as upstream

* 📝 Update Korean docs as upstream

* 📝 Update Korean docs as upstream

* 📝 Update Korean docs as upstream

* 📝 Update Korean docs as upstream

* 📝 Mark untranslated docs

* 📝 Update Korean docs as upstream

[ci skip]

* 📝 Update Korean docs as upstream

[ci skip]

* 📝 Add untranslated files

[ci skip]

* 📝 Update Korean docs as upstream

[ci skip]

* 📝 Update Korean docs as upstream

* 📝 Update `README-ko.md`

* Remove Korean readme specified header.
* Add Indonesia community link.

* 📝 Update Korean docs as upstream

* 📝 Update Korean docs as upstream

* 📝 Update Korean docs as upstream

* 📝 Update Korean docs as upstream

* 📝 Update Korean docs as upstream

* 📝 Mark untranslated docs

* 📝 Update Korean docs as upstream

[ci skip]

* 📝 Update Korean docs as upstream

[ci skip]

* 📝 Add untranslated files

[ci skip]

* 📝 Update Korean docs as upstream

[ci skip]

* 📝 Update Korean docs as upstream

* 📝 Correct readme name

[ci skip]

* 📝 Update Korean docs as upstream

[ci skip]
2016-09-15 09:27:10 -07:00
Cheng Zhao
e62e62292a Bump v1.4.0 2016-09-15 14:44:38 +09:00
Cheng Zhao
b84d29fb32 Merge pull request #7213 from electron/chrome-update
Update to Chrome 53.0.2785.113
2016-09-15 14:44:10 +09:00
Cheng Zhao
5be8104104 Update to Chrome 53.0.2785.113 2016-09-15 14:27:56 +09:00
Kevin Sawicki
eef42770c6 Don't load remote properties until they are accessed 2016-09-14 13:29:49 -07:00
Kevin Sawicki
f792c720f4 Allow spec to be run multiple times in same runner 2016-09-14 11:16:44 -07:00
Kevin Sawicki
359ab2f9b3 Only set members when members exist 2016-09-14 10:54:23 -07:00
Kevin Sawicki
bc13536208 Add failing spec for missing remote properties 2016-09-14 10:53:25 -07:00
Kevin Sawicki
0d4872755c Merge pull request #7195 from Joshua-Anderson/update-node-req
Update nodejs requirement for building on linux
2016-09-14 09:52:23 -07:00
Cheng Zhao
4627311c34 Merge pull request #7104 from electron/chrome53
Upgrade to Chrome 53 and Node 6.5.0
2016-09-14 22:18:08 +09:00
Cheng Zhao
dc2ced14b8 Node module version should be 50 2016-09-14 17:08:13 +09:00
deepak1556
eafb6307d5 fix crash when using geolocation api with enableHighAccuracy option 2016-09-14 16:23:01 +09:00
Cheng Zhao
fbac635687 Only emit finalUpdate found-in-page events
Since Chrome 53 all meaningful results of found-in-page are finalUpdate.
2016-09-14 16:23:01 +09:00
Cheng Zhao
5ccd0a24e9 Fix compatibility with canScroll 2016-09-14 16:23:01 +09:00
Cheng Zhao
f8bdc7437d module search paths have changed 2016-09-14 16:23:01 +09:00
Cheng Zhao
1de2b77ee4 Update to Node 6.5.0 2016-09-14 16:23:00 +09:00
Cheng Zhao
18fd3e0329 Fix js linting error 2016-09-14 16:23:00 +09:00
Cheng Zhao
a510642a25 finalUpdate can be false 2016-09-14 16:23:00 +09:00
Cheng Zhao
30dd65e3a9 Fix failing spec when refreshing test window 2016-09-14 16:23:00 +09:00
Cheng Zhao
5708e86a05 Fix API change of findInPage API 2016-09-14 16:23:00 +09:00
Cheng Zhao
937ae7ef8f Fix crash caused by new network parameters 2016-09-14 16:23:00 +09:00
Cheng Zhao
4c56c1c2b2 Fix crash in offscreen renderer 2016-09-14 16:22:59 +09:00
Cheng Zhao
6d8f900916 Fix building on Windows 2016-09-14 16:22:43 +09:00
Cheng Zhao
4aa292c7cd Fix building on Linux 2016-09-14 16:22:43 +09:00
Cheng Zhao
f28e8d7168 Fix API changes of Chrome 53 2016-09-14 16:22:43 +09:00
Cheng Zhao
2e0a1a8a64 Upgrade to Chrome 53 2016-09-14 16:22:41 +09:00
Joshua Anderson
56b40ae6d2 Update nodejs requirement for building on linux 2016-09-13 19:41:53 -07:00
Zeke Sikelianos
9e8b0953f3 fix indentation 2016-09-12 10:47:36 -07:00
Mario Aichinger
893fc2cd53 🐧 Add support for different trash implementations
Make the trash implemantation in MoveItemToTrash selectable via an environment variable
2016-09-12 10:41:23 +02:00
gellert
2435f1b660 lint fix 2016-09-09 23:50:01 +02:00
gellert
afb551e94a updates tests 2016-09-09 23:40:10 +02:00
gellert
5754f3aea0 update docs 2016-09-09 23:26:14 +02:00
gellert
d3dc66e308 adds scale factor check and simplifies frame subscription 2016-09-09 23:17:17 +02:00
Dave Townsend
313b2faa3c Add a guestinstance attribute to webviews reflecting their current guest
instance ID and allowing moving a guest instance to a new webview.
2016-09-09 10:32:05 -07:00
Zeke Sikelianos
18585204b7 wrap line to stay under 80 chars 2016-09-09 10:07:22 -07:00
Zeke Sikelianos
3d40c720dd fix indentation and rename function 2016-09-09 10:07:22 -07:00
Zeke Sikelianos
8d201ae1ad generate electron-api.json and upload with release 2016-09-09 10:07:22 -07:00
Zeke Sikelianos
67c89b68d3 use new electron-docs-linter with node 4 support 2016-09-09 10:07:22 -07:00
Zeke Sikelianos
5937d37fc5 move linting work to electron-docs-linter's new CLI 2016-09-09 10:07:22 -07:00
Zeke Sikelianos
56a644d49f move electron.json to docs/api.json 2016-09-09 10:07:22 -07:00
Zeke Sikelianos
0c54700b16 add electron.json (compiled to target 1.2.7 release) 2016-09-09 10:07:22 -07:00
Zeke Sikelianos
3a5bf51d1d add lint-docs script 2016-09-09 10:07:22 -07:00
deepak1556
7b85ca0301 create helper class to read blob data 2016-09-01 08:52:44 +05:30
deepak1556
5cbc8d5c71 fix ambiguous constructor call 2016-09-01 01:01:52 +05:30
deepak1556
be4bc6b7ef fix docs and update specs 2016-09-01 01:01:52 +05:30
deepak1556
d2e40d4fc1 update api to work on public url and uuid 2016-09-01 01:01:52 +05:30
deepak1556
a23e7ecf8f add docs 2016-09-01 01:01:52 +05:30
deepak1556
0fb2339e3d session: api to retrieve blob data from uuid 2016-09-01 01:01:52 +05:30
deepak1556
2b0f632d51 provide blob uuid from upload data 2016-09-01 01:01:52 +05:30
291 changed files with 8457 additions and 2352 deletions

View File

@@ -1,6 +1,6 @@
# Contributing to Electron
:memo: Available Translations: [Korean](https://github.com/electron/electron/tree/master/docs-translations/ko-KR/project/CONTRIBUTING.md) | [Simplified Chinese](https://github.com/electron/electron/tree/master/docs-translations/zh-CN/project/CONTRIBUTING.md)
:memo: Available Translations: [Korean](https://github.com/electron/electron/tree/master/docs-translations/ko-KR/project/CONTRIBUTING.md) | [Simplified Chinese](https://github.com/electron/electron/tree/master/docs-translations/zh-CN/project/CONTRIBUTING.md) | [Brazilian Portuguese](https://github.com/electron/electron/tree/master/docs-translations/pt-BR/project/CONTRIBUTING.md)
:+1::tada: First off, thanks for taking the time to contribute! :tada::+1:

View File

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

View File

@@ -79,3 +79,7 @@ forums
Check out [awesome-electron](https://github.com/sindresorhus/awesome-electron)
for a community maintained list of useful example apps, tools and resources.
## License
MIT © 2016 Github

View File

@@ -11,7 +11,9 @@
#include "atom/browser/atom_browser_client.h"
#include "atom/browser/relauncher.h"
#include "atom/common/google_api_key.h"
#include "atom/common/options_switches.h"
#include "atom/renderer/atom_renderer_client.h"
#include "atom/renderer/atom_sandboxed_renderer_client.h"
#include "atom/utility/atom_content_utility_client.h"
#include "base/command_line.h"
#include "base/debug/stack_trace.h"
@@ -29,7 +31,7 @@ namespace {
const char* kRelauncherProcess = "relauncher";
bool IsBrowserProcess(base::CommandLine* cmd) {
std::string process_type = cmd->GetSwitchValueASCII(switches::kProcessType);
std::string process_type = cmd->GetSwitchValueASCII(::switches::kProcessType);
return process_type.empty();
}
@@ -72,7 +74,7 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
// Only enable logging when --enable-logging is specified.
std::unique_ptr<base::Environment> env(base::Environment::Create());
if (!command_line->HasSwitch(switches::kEnableLogging) &&
if (!command_line->HasSwitch(::switches::kEnableLogging) &&
!env->HasVar("ELECTRON_ENABLE_LOGGING")) {
settings.logging_dest = logging::LOG_NONE;
logging::SetMinLogLevel(logging::LOG_NUM_SEVERITIES);
@@ -115,17 +117,23 @@ void AtomMainDelegate::PreSandboxStartup() {
auto command_line = base::CommandLine::ForCurrentProcess();
std::string process_type = command_line->GetSwitchValueASCII(
switches::kProcessType);
::switches::kProcessType);
// Only append arguments for browser process.
if (!IsBrowserProcess(command_line))
return;
// Disable renderer sandbox for most of node's functions.
command_line->AppendSwitch(switches::kNoSandbox);
if (command_line->HasSwitch(switches::kEnableSandbox)) {
// Disable setuid sandbox since it is not longer required on linux(namespace
// sandbox is available on most distros).
command_line->AppendSwitch(::switches::kDisableSetuidSandbox);
} else {
// Disable renderer sandbox for most of node's functions.
command_line->AppendSwitch(::switches::kNoSandbox);
}
// Allow file:// URIs to read other file:// URIs by default.
command_line->AppendSwitch(switches::kAllowFileAccessFromFiles);
command_line->AppendSwitch(::switches::kAllowFileAccessFromFiles);
#if defined(OS_MACOSX)
// Enable AVFoundation.
@@ -140,7 +148,13 @@ content::ContentBrowserClient* AtomMainDelegate::CreateContentBrowserClient() {
content::ContentRendererClient*
AtomMainDelegate::CreateContentRendererClient() {
renderer_client_.reset(new AtomRendererClient);
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableSandbox)) {
renderer_client_.reset(new AtomSandboxedRendererClient);
} else {
renderer_client_.reset(new AtomRendererClient);
}
return renderer_client_.get();
}

View File

@@ -525,6 +525,7 @@ void App::OnLogin(LoginHandler* login_handler,
void App::OnCreateWindow(const GURL& target_url,
const std::string& frame_name,
WindowOpenDisposition disposition,
const std::vector<base::string16>& features,
int render_process_id,
int render_frame_id) {
v8::Locker locker(isolate());
@@ -535,7 +536,10 @@ void App::OnCreateWindow(const GURL& target_url,
content::WebContents::FromRenderFrameHost(rfh);
if (web_contents) {
auto api_web_contents = WebContents::CreateFrom(isolate(), web_contents);
api_web_contents->OnCreateWindow(target_url, frame_name, disposition);
api_web_contents->OnCreateWindow(target_url,
frame_name,
disposition,
features);
}
}
@@ -585,8 +589,9 @@ void App::SelectClientCertificate(
cert_request_info->client_certs[0].get());
}
void App::OnGpuProcessCrashed(base::TerminationStatus exit_code) {
Emit("gpu-process-crashed");
void App::OnGpuProcessCrashed(base::TerminationStatus status) {
Emit("gpu-process-crashed",
status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED);
}
base::FilePath App::GetPath(mate::Arguments* args, const std::string& name) {

View File

@@ -6,6 +6,7 @@
#define ATOM_BROWSER_API_ATOM_API_APP_H_
#include <string>
#include <vector>
#include "atom/browser/api/event_emitter.h"
#include "atom/browser/atom_browser_client.h"
@@ -50,6 +51,7 @@ class App : public AtomBrowserClient::Delegate,
void OnCreateWindow(const GURL& target_url,
const std::string& frame_name,
WindowOpenDisposition disposition,
const std::vector<base::string16>& features,
int render_process_id,
int render_frame_id);
@@ -102,7 +104,7 @@ class App : public AtomBrowserClient::Delegate,
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
// content::GpuDataManagerObserver:
void OnGpuProcessCrashed(base::TerminationStatus exit_code) override;
void OnGpuProcessCrashed(base::TerminationStatus status) override;
private:
// Get/Set the pre-defined path in PathService.

View File

@@ -7,12 +7,13 @@
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "atom/common/node_includes.h"
#include "base/bind.h"
#include "base/files/file_util.h"
#include "content/public/browser/tracing_controller.h"
#include "native_mate/dictionary.h"
#include "atom/common/node_includes.h"
using content::TracingController;
namespace mate {

View File

@@ -20,6 +20,7 @@
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
using atom::AtomCookieDelegate;
using content::BrowserThread;
namespace mate {
@@ -54,6 +55,27 @@ struct Converter<net::CanonicalCookie> {
}
};
template<>
struct Converter<AtomCookieDelegate::ChangeCause> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const AtomCookieDelegate::ChangeCause& val) {
switch (val) {
case AtomCookieDelegate::ChangeCause::CHANGE_COOKIE_EXPLICIT:
return mate::StringToV8(isolate, "explicit");
case AtomCookieDelegate::ChangeCause::CHANGE_COOKIE_OVERWRITE:
return mate::StringToV8(isolate, "overwrite");
case AtomCookieDelegate::ChangeCause::CHANGE_COOKIE_EXPIRED:
return mate::StringToV8(isolate, "expired");
case AtomCookieDelegate::ChangeCause::CHANGE_COOKIE_EVICTED:
return mate::StringToV8(isolate, "evicted");
case AtomCookieDelegate::ChangeCause::CHANGE_COOKIE_EXPIRED_OVERWRITE:
return mate::StringToV8(isolate, "expired-overwrite");
default:
return mate::StringToV8(isolate, "unknown");
}
}
};
} // namespace mate
namespace atom {
@@ -206,11 +228,14 @@ void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
Cookies::Cookies(v8::Isolate* isolate,
AtomBrowserContext* browser_context)
: request_context_getter_(browser_context->url_request_context_getter()) {
: request_context_getter_(browser_context->url_request_context_getter()),
cookie_delegate_(browser_context->cookie_delegate()) {
Init(isolate);
cookie_delegate_->AddObserver(this);
}
Cookies::~Cookies() {
cookie_delegate_->RemoveObserver(this);
}
void Cookies::Get(const base::DictionaryValue& filter,
@@ -239,6 +264,13 @@ void Cookies::Set(const base::DictionaryValue& details,
base::Bind(SetCookieOnIO, getter, Passed(&copied), callback));
}
void Cookies::OnCookieChanged(const net::CanonicalCookie& cookie,
bool removed,
AtomCookieDelegate::ChangeCause cause) {
Emit("changed", cookie, cause, removed);
}
// static
mate::Handle<Cookies> Cookies::Create(
v8::Isolate* isolate,

View File

@@ -8,6 +8,7 @@
#include <string>
#include "atom/browser/api/trackable_object.h"
#include "atom/browser/net/atom_cookie_delegate.h"
#include "base/callback.h"
#include "native_mate/handle.h"
#include "net/cookies/canonical_cookie.h"
@@ -26,7 +27,8 @@ class AtomBrowserContext;
namespace api {
class Cookies : public mate::TrackableObject<Cookies> {
class Cookies : public mate::TrackableObject<Cookies>,
public AtomCookieDelegate::Observer {
public:
enum Error {
SUCCESS,
@@ -52,8 +54,14 @@ class Cookies : public mate::TrackableObject<Cookies> {
const base::Closure& callback);
void Set(const base::DictionaryValue& details, const SetCallback& callback);
// AtomCookieDelegate::Observer:
void OnCookieChanged(const net::CanonicalCookie& cookie,
bool removed,
AtomCookieDelegate::ChangeCause cause) override;
private:
net::URLRequestContextGetter* request_context_getter_;
scoped_refptr<AtomCookieDelegate> cookie_delegate_;
DISALLOW_COPY_AND_ASSIGN(Cookies);
};

View File

@@ -9,7 +9,6 @@
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "content/public/browser/devtools_agent_host.h"
@@ -17,6 +16,8 @@
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
#include "atom/common/node_includes.h"
using content::DevToolsAgentHost;
namespace atom {
@@ -107,7 +108,7 @@ bool Debugger::IsAttached() {
void Debugger::Detach() {
if (!agent_host_.get())
return;
agent_host_->DetachClient();
agent_host_->DetachClient(this);
AgentHostClosed(agent_host_.get(), false);
agent_host_ = nullptr;
}
@@ -136,7 +137,7 @@ void Debugger::SendCommand(mate::Arguments* args) {
std::string json_args;
base::JSONWriter::Write(request, &json_args);
agent_host_->DispatchProtocolMessage(json_args);
agent_host_->DispatchProtocolMessage(this, json_args);
}
// static

View File

@@ -10,12 +10,13 @@
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "atom/common/native_mate_converters/gurl_converter.h"
#include "atom/common/node_includes.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "native_mate/dictionary.h"
#include "net/base/filename_util.h"
#include "atom/common/node_includes.h"
namespace mate {
template<>
@@ -134,7 +135,7 @@ std::string DownloadItem::GetFilename() const {
std::string(),
download_item_->GetSuggestedFilename(),
GetMimeType(),
std::string()).LossyDisplayName());
"download").LossyDisplayName());
}
std::string DownloadItem::GetContentDisposition() const {

View File

@@ -5,11 +5,12 @@
#include "atom/browser/api/atom_api_power_monitor.h"
#include "atom/browser/browser.h"
#include "atom/common/node_includes.h"
#include "base/power_monitor/power_monitor.h"
#include "base/power_monitor/power_monitor_device_source.h"
#include "native_mate/dictionary.h"
#include "atom/common/node_includes.h"
namespace atom {
namespace api {
@@ -43,7 +44,7 @@ v8::Local<v8::Value> PowerMonitor::Create(v8::Isolate* isolate) {
if (!Browser::Get()->is_ready()) {
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
isolate,
"Cannot initialize \"power-monitor\" module before app is ready")));
"Cannot require \"powerMonitor\" module before app is ready")));
return v8::Null(isolate);
}

View File

@@ -6,18 +6,19 @@
#include <string>
#include "atom/common/node_includes.h"
#include "content/public/browser/power_save_blocker.h"
#include "content/public/browser/browser_thread.h"
#include "native_mate/dictionary.h"
#include "atom/common/node_includes.h"
namespace mate {
template<>
struct Converter<content::PowerSaveBlocker::PowerSaveBlockerType> {
struct Converter<device::PowerSaveBlocker::PowerSaveBlockerType> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
content::PowerSaveBlocker::PowerSaveBlockerType* out) {
using content::PowerSaveBlocker;
device::PowerSaveBlocker::PowerSaveBlockerType* out) {
using device::PowerSaveBlocker;
std::string type;
if (!ConvertFromV8(isolate, val, &type))
return false;
@@ -39,7 +40,7 @@ namespace api {
PowerSaveBlocker::PowerSaveBlocker(v8::Isolate* isolate)
: current_blocker_type_(
content::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension) {
device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension) {
Init(isolate);
}
@@ -58,30 +59,34 @@ void PowerSaveBlocker::UpdatePowerSaveBlocker() {
// higher precedence level than |kPowerSaveBlockPreventAppSuspension|.
//
// Only the highest-precedence blocker type takes effect.
content::PowerSaveBlocker::PowerSaveBlockerType new_blocker_type =
content::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension;
device::PowerSaveBlocker::PowerSaveBlockerType new_blocker_type =
device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension;
for (const auto& element : power_save_blocker_types_) {
if (element.second ==
content::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep) {
device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep) {
new_blocker_type =
content::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep;
device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep;
break;
}
}
if (!power_save_blocker_ || new_blocker_type != current_blocker_type_) {
std::unique_ptr<content::PowerSaveBlocker> new_blocker =
content::PowerSaveBlocker::Create(
std::unique_ptr<device::PowerSaveBlocker> new_blocker(
new device::PowerSaveBlocker(
new_blocker_type,
content::PowerSaveBlocker::kReasonOther,
ATOM_PRODUCT_NAME);
device::PowerSaveBlocker::kReasonOther,
ATOM_PRODUCT_NAME,
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::UI),
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::FILE)));
power_save_blocker_.swap(new_blocker);
current_blocker_type_ = new_blocker_type;
}
}
int PowerSaveBlocker::Start(
content::PowerSaveBlocker::PowerSaveBlockerType type) {
device::PowerSaveBlocker::PowerSaveBlockerType type) {
static int count = 0;
power_save_blocker_types_[count] = type;
UpdatePowerSaveBlocker();

View File

@@ -9,7 +9,7 @@
#include <memory>
#include "atom/browser/api/trackable_object.h"
#include "content/public/browser/power_save_blocker.h"
#include "device/power_save_blocker/power_save_blocker.h"
#include "native_mate/handle.h"
namespace mate {
@@ -33,18 +33,18 @@ class PowerSaveBlocker : public mate::TrackableObject<PowerSaveBlocker> {
private:
void UpdatePowerSaveBlocker();
int Start(content::PowerSaveBlocker::PowerSaveBlockerType type);
int Start(device::PowerSaveBlocker::PowerSaveBlockerType type);
bool Stop(int id);
bool IsStarted(int id);
std::unique_ptr<content::PowerSaveBlocker> power_save_blocker_;
std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_;
// Currnet blocker type used by |power_save_blocker_|
content::PowerSaveBlocker::PowerSaveBlockerType current_blocker_type_;
device::PowerSaveBlocker::PowerSaveBlockerType current_blocker_type_;
// Map from id to the corresponding blocker type for each request.
using PowerSaveBlockerTypeMap =
std::map<int, content::PowerSaveBlocker::PowerSaveBlockerType>;
std::map<int, device::PowerSaveBlocker::PowerSaveBlockerType>;
PowerSaveBlockerTypeMap power_save_blocker_types_;
DISALLOW_COPY_AND_ASSIGN(PowerSaveBlocker);

View File

@@ -7,11 +7,12 @@
#include "atom/browser/api/atom_api_web_contents.h"
#include "atom/browser/atom_browser_client.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "content/public/browser/render_process_host.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
#include "atom/common/node_includes.h"
namespace atom {
namespace api {

View File

@@ -97,7 +97,7 @@ v8::Local<v8::Value> Screen::Create(v8::Isolate* isolate) {
if (!Browser::Get()->is_ready()) {
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
isolate,
"Cannot initialize \"screen\" module before app is ready")));
"Cannot require \"screen\" module before app is ready")));
return v8::Null(isolate);
}

View File

@@ -49,6 +49,7 @@
#include "net/url_request/url_request_context_getter.h"
#include "ui/base/l10n/l10n_util.h"
using atom::api::Cookies;
using content::BrowserThread;
using content::StoragePartition;
@@ -335,7 +336,7 @@ void OnClearStorageDataDone(const base::Closure& callback) {
Session::Session(v8::Isolate* isolate, AtomBrowserContext* browser_context)
: devtools_network_emulation_client_id_(base::GenerateGUID()),
browser_context_(browser_context) {
// Observe DownloadManger to get download notifications.
// Observe DownloadManager to get download notifications.
content::BrowserContext::GetDownloadManager(browser_context)->
AddObserver(this);
@@ -504,9 +505,24 @@ std::string Session::GetUserAgent() {
return browser_context_->GetUserAgent();
}
void Session::GetBlobData(
const std::string& uuid,
const AtomBlobReader::CompletionCallback& callback) {
if (callback.is_null())
return;
AtomBlobReader* blob_reader =
browser_context()->GetBlobReader();
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::Bind(&AtomBlobReader::StartReading,
base::Unretained(blob_reader),
uuid,
callback));
}
v8::Local<v8::Value> Session::Cookies(v8::Isolate* isolate) {
if (cookies_.IsEmpty()) {
auto handle = atom::api::Cookies::Create(isolate, browser_context());
auto handle = Cookies::Create(isolate, browser_context());
cookies_.Reset(isolate, handle.ToV8());
}
return v8::Local<v8::Value>::New(isolate, cookies_);
@@ -586,6 +602,7 @@ void Session::BuildPrototype(v8::Isolate* isolate,
&Session::AllowNTLMCredentialsForDomains)
.SetMethod("setUserAgent", &Session::SetUserAgent)
.SetMethod("getUserAgent", &Session::GetUserAgent)
.SetMethod("getBlobData", &Session::GetBlobData)
.SetProperty("cookies", &Session::Cookies)
.SetProperty("protocol", &Session::Protocol)
.SetProperty("webRequest", &Session::WebRequest);
@@ -615,6 +632,7 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("Session", Session::GetConstructor(isolate)->GetFunction());
dict.Set("Cookies", Cookies::GetConstructor(isolate)->GetFunction());
dict.SetMethod("fromPartition", &FromPartition);
}

View File

@@ -8,6 +8,7 @@
#include <string>
#include "atom/browser/api/trackable_object.h"
#include "atom/browser/atom_blob_reader.h"
#include "base/values.h"
#include "content/public/browser/download_manager.h"
#include "native_mate/handle.h"
@@ -76,6 +77,8 @@ class Session: public mate::TrackableObject<Session>,
void AllowNTLMCredentialsForDomains(const std::string& domains);
void SetUserAgent(const std::string& user_agent, mate::Arguments* args);
std::string GetUserAgent();
void GetBlobData(const std::string& uuid,
const AtomBlobReader::CompletionCallback& callback);
v8::Local<v8::Value> Cookies(v8::Isolate* isolate);
v8::Local<v8::Value> Protocol(v8::Isolate* isolate);
v8::Local<v8::Value> WebRequest(v8::Isolate* isolate);

View File

@@ -9,27 +9,20 @@
#include "atom/common/node_includes.h"
#include "native_mate/dictionary.h"
#if defined(OS_WIN)
#include "ui/base/win/shell.h"
#endif
namespace atom {
namespace api {
SystemPreferences::SystemPreferences(v8::Isolate* isolate) {
Init(isolate);
#if defined(OS_WIN)
InitializeWindow();
#endif
}
SystemPreferences::~SystemPreferences() {
}
#if defined(OS_WIN)
bool SystemPreferences::IsAeroGlassEnabled() {
return ui::win::IsAeroGlassEnabled();
}
#endif
#if !defined(OS_MACOSX)
bool SystemPreferences::IsDarkMode() {
return false;
@@ -48,6 +41,7 @@ void SystemPreferences::BuildPrototype(
prototype->SetClassName(mate::StringToV8(isolate, "SystemPreferences"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
#if defined(OS_WIN)
.SetMethod("getAccentColor", &SystemPreferences::GetAccentColor)
.SetMethod("isAeroGlassEnabled", &SystemPreferences::IsAeroGlassEnabled)
#elif defined(OS_MACOSX)
.SetMethod("postNotification",

View File

@@ -29,6 +29,17 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences> {
#if defined(OS_WIN)
bool IsAeroGlassEnabled();
typedef HRESULT (STDAPICALLTYPE *DwmGetColorizationColor)(DWORD *, BOOL *);
DwmGetColorizationColor dwmGetColorizationColor =
(DwmGetColorizationColor) GetProcAddress(LoadLibraryW(L"dwmapi.dll"),
"DwmGetColorizationColor");
std::string GetAccentColor();
void InitializeWindow();
#elif defined(OS_MACOSX)
using NotificationCallback = base::Callback<
void(const std::string&, const base::DictionaryValue&)>;
@@ -64,6 +75,25 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences> {
#endif
private:
#if defined(OS_WIN)
// Static callback invoked when a message comes in to our messaging window.
static LRESULT CALLBACK
WndProcStatic(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
LRESULT CALLBACK
WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
// The window class of |window_|.
ATOM atom_;
// The handle of the module that contains the window procedure of |window_|.
HMODULE instance_;
// The window used for processing events.
HWND window_;
std::string current_color_;
#endif
DISALLOW_COPY_AND_ASSIGN(SystemPreferences);
};

View File

@@ -0,0 +1,93 @@
// Copyright (c) 2014 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/browser/api/atom_api_system_preferences.h"
#include "base/win/wrapped_window_proc.h"
#include "ui/base/win/shell.h"
#include "ui/gfx/win/hwnd_util.h"
namespace atom {
namespace {
const wchar_t kSystemPreferencesWindowClass[] =
L"Electron_SystemPreferencesHostWindow";
} // namespace
namespace api {
bool SystemPreferences::IsAeroGlassEnabled() {
return ui::win::IsAeroGlassEnabled();
}
std::string hexColorDWORDToRGBA(DWORD color) {
std::ostringstream stream;
stream << std::hex << color;
std::string hexColor = stream.str();
return hexColor.substr(2) + hexColor.substr(0, 2);
}
std::string SystemPreferences::GetAccentColor() {
DWORD color = 0;
BOOL opaque = FALSE;
if (FAILED(dwmGetColorizationColor(&color, &opaque))) {
return "";
}
return hexColorDWORDToRGBA(color);
}
void SystemPreferences::InitializeWindow() {
WNDCLASSEX window_class;
base::win::InitializeWindowClass(
kSystemPreferencesWindowClass,
&base::win::WrappedWindowProc<SystemPreferences::WndProcStatic>,
0, 0, 0, NULL, NULL, NULL, NULL, NULL,
&window_class);
instance_ = window_class.hInstance;
atom_ = RegisterClassEx(&window_class);
// Create an offscreen window for receiving broadcast messages for the system
// colorization color. Create a hidden WS_POPUP window instead of an
// HWND_MESSAGE window, because only top-level windows such as popups can
// receive broadcast messages like "WM_DWMCOLORIZATIONCOLORCHANGED".
window_ = CreateWindow(MAKEINTATOM(atom_),
0, WS_POPUP, 0, 0, 0, 0, 0, 0, instance_, 0);
gfx::CheckWindowCreated(window_);
gfx::SetWindowUserData(window_, this);
}
LRESULT CALLBACK SystemPreferences::WndProcStatic(HWND hwnd,
UINT message,
WPARAM wparam,
LPARAM lparam) {
SystemPreferences* msg_wnd = reinterpret_cast<SystemPreferences*>(
GetWindowLongPtr(hwnd, GWLP_USERDATA));
if (msg_wnd)
return msg_wnd->WndProc(hwnd, message, wparam, lparam);
else
return ::DefWindowProc(hwnd, message, wparam, lparam);
}
LRESULT CALLBACK SystemPreferences::WndProc(HWND hwnd,
UINT message,
WPARAM wparam,
LPARAM lparam) {
if (message == WM_DWMCOLORIZATIONCOLORCHANGED) {
DWORD new_color = (DWORD) wparam;
std::string new_color_string = hexColorDWORDToRGBA(new_color);
if (new_color_string != current_color_) {
Emit("accent-color-changed", hexColorDWORDToRGBA(new_color));
current_color_ = new_color_string;
}
}
return ::DefWindowProc(hwnd, message, wparam, lparam);
}
} // namespace api
} // namespace atom

View File

@@ -37,7 +37,6 @@
#include "atom/common/native_mate_converters/image_converter.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "atom/common/options_switches.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -77,6 +76,8 @@
#include "ui/aura/window.h"
#endif
#include "atom/common/node_includes.h"
namespace {
struct PrintSettings {
@@ -133,6 +134,7 @@ struct Converter<WindowOpenDisposition> {
case NEW_FOREGROUND_TAB: disposition = "foreground-tab"; break;
case NEW_BACKGROUND_TAB: disposition = "background-tab"; break;
case NEW_POPUP: case NEW_WINDOW: disposition = "new-window"; break;
case SAVE_TO_DISK: disposition = "save-to-disk"; break;
default: break;
}
return mate::ConvertToV8(isolate, disposition);
@@ -256,17 +258,25 @@ void OnCapturePageDone(base::Callback<void(const gfx::Image&)> callback,
} // namespace
WebContents::WebContents(v8::Isolate* isolate,
content::WebContents* web_contents)
content::WebContents* web_contents,
Type type)
: content::WebContentsObserver(web_contents),
embedder_(nullptr),
type_(REMOTE),
type_(type),
request_id_(0),
background_throttling_(true),
enable_devtools_(true) {
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent());
Init(isolate);
AttachAsUserData(web_contents);
if (type == REMOTE) {
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent());
Init(isolate);
AttachAsUserData(web_contents);
} else {
const mate::Dictionary options = mate::Dictionary::CreateEmpty(isolate);
auto session = Session::CreateFrom(isolate, GetBrowserContext());
session_.Reset(isolate, session.ToV8());
InitWithSessionAndOptions(isolate, web_contents, session, options);
}
}
WebContents::WebContents(v8::Isolate* isolate,
@@ -334,6 +344,13 @@ WebContents::WebContents(v8::Isolate* isolate,
web_contents = content::WebContents::Create(params);
}
InitWithSessionAndOptions(isolate, web_contents, session, options);
}
void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
content::WebContents *web_contents,
mate::Handle<api::Session> session,
const mate::Dictionary& options) {
Observe(web_contents);
InitWithWebContents(web_contents, session->browser_context());
@@ -399,11 +416,37 @@ bool WebContents::AddMessageToConsole(content::WebContents* source,
void WebContents::OnCreateWindow(const GURL& target_url,
const std::string& frame_name,
WindowOpenDisposition disposition) {
WindowOpenDisposition disposition,
const std::vector<base::string16>& features) {
if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN)
Emit("-new-window", target_url, frame_name, disposition);
Emit("-new-window", target_url, frame_name, disposition, features);
else
Emit("new-window", target_url, frame_name, disposition);
Emit("new-window", target_url, frame_name, disposition, features);
}
void WebContents::WebContentsCreated(content::WebContents* source_contents,
int opener_render_frame_id,
const std::string& frame_name,
const GURL& target_url,
content::WebContents* new_contents) {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
auto api_web_contents = CreateFrom(isolate(), new_contents, BROWSER_WINDOW);
Emit("-web-contents-created", api_web_contents, target_url, frame_name);
}
void WebContents::AddNewContents(content::WebContents* source,
content::WebContents* new_contents,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
bool* was_blocked) {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
auto api_web_contents = CreateFrom(isolate(), new_contents);
Emit("-add-new-contents", api_web_contents, disposition, user_gesture,
initial_rect.x(), initial_rect.y(), initial_rect.width(),
initial_rect.height());
}
content::WebContents* WebContents::OpenURLFromTab(
@@ -527,22 +570,18 @@ void WebContents::FindReply(content::WebContents* web_contents,
const gfx::Rect& selection_rect,
int active_match_ordinal,
bool final_update) {
if (!final_update)
return;
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
mate::Dictionary result = mate::Dictionary::CreateEmpty(isolate());
if (number_of_matches == -1) {
result.Set("requestId", request_id);
result.Set("selectionArea", selection_rect);
result.Set("finalUpdate", final_update);
result.Set("activeMatchOrdinal", active_match_ordinal);
Emit("found-in-page", result);
} else if (final_update) {
result.Set("requestId", request_id);
result.Set("matches", number_of_matches);
result.Set("finalUpdate", final_update);
Emit("found-in-page", result);
}
result.Set("requestId", request_id);
result.Set("matches", number_of_matches);
result.Set("selectionArea", selection_rect);
result.Set("activeMatchOrdinal", active_match_ordinal);
result.Set("finalUpdate", final_update); // Deprecate after 2.0
Emit("found-in-page", result);
}
bool WebContents::CheckMediaAccessPermission(
@@ -588,7 +627,7 @@ void WebContents::RenderViewDeleted(content::RenderViewHost* render_view_host) {
}
void WebContents::RenderProcessGone(base::TerminationStatus status) {
Emit("crashed");
Emit("crashed", status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED);
}
void WebContents::PluginCrashed(const base::FilePath& plugin_path,
@@ -803,7 +842,14 @@ void WebContents::NavigationEntryCommitted(
details.is_in_page, details.did_replace_entry);
}
int WebContents::GetID() const {
int64_t WebContents::GetID() const {
int64_t process_id = web_contents()->GetRenderProcessHost()->GetID();
int64_t routing_id = web_contents()->GetRoutingID();
int64_t rv = (process_id << 32) + routing_id;
return rv;
}
int WebContents::GetProcessID() const {
return web_contents()->GetRenderProcessHost()->GetID();
}
@@ -871,7 +917,8 @@ void WebContents::DownloadURL(const GURL& url) {
content::BrowserContext::GetDownloadManager(browser_context);
download_manager->DownloadUrl(
content::DownloadUrlParameters::FromWebContents(web_contents(), url));
content::DownloadUrlParameters::CreateForWebContentsMainFrame(
web_contents(), url));
}
GURL WebContents::GetURL() const {
@@ -1177,7 +1224,7 @@ void WebContents::ShowDefinitionForSelection() {
}
void WebContents::CopyImageAt(int x, int y) {
const auto host = web_contents()->GetRenderViewHost();
const auto host = web_contents()->GetMainFrame();
if (host)
host->CopyImageAt(x, y);
}
@@ -1419,6 +1466,15 @@ int WebContents::GetFrameRate() const {
return osr_rwhv ? osr_rwhv->GetFrameRate() : 0;
}
void WebContents::Invalidate() {
if (!IsOffScreen())
return;
auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
web_contents()->GetRenderWidgetHostView());
if (osr_rwhv)
osr_rwhv->Invalidate();
}
v8::Local<v8::Value> WebContents::GetWebPreferences(v8::Isolate* isolate) {
WebContentsPreferences* web_preferences =
@@ -1447,6 +1503,25 @@ content::WebContents* WebContents::HostWebContents() {
return embedder_->web_contents();
}
void WebContents::SetEmbedder(const WebContents* embedder) {
if (embedder) {
NativeWindow* owner_window = nullptr;
auto relay = NativeWindowRelay::FromWebContents(embedder->web_contents());
if (relay) {
owner_window = relay->window.get();
}
if (owner_window)
SetOwnerWindow(owner_window);
content::RenderWidgetHostView* rwhv =
web_contents()->GetRenderWidgetHostView();
if (rwhv) {
rwhv->Hide();
rwhv->Show();
}
}
}
v8::Local<v8::Value> WebContents::DevToolsWebContents(v8::Isolate* isolate) {
if (devtools_web_contents_.IsEmpty())
return v8::Null(isolate);
@@ -1469,6 +1544,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.MakeDestroyable()
.SetMethod("getId", &WebContents::GetID)
.SetMethod("getProcessId", &WebContents::GetProcessID)
.SetMethod("equal", &WebContents::Equal)
.SetMethod("_loadURL", &WebContents::LoadURL)
.SetMethod("downloadURL", &WebContents::DownloadURL)
@@ -1528,6 +1604,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
.SetMethod("isPainting", &WebContents::IsPainting)
.SetMethod("setFrameRate", &WebContents::SetFrameRate)
.SetMethod("getFrameRate", &WebContents::GetFrameRate)
.SetMethod("invalidate", &WebContents::Invalidate)
.SetMethod("getType", &WebContents::GetType)
.SetMethod("getWebPreferences", &WebContents::GetWebPreferences)
.SetMethod("getOwnerBrowserWindow", &WebContents::GetOwnerBrowserWindow)
@@ -1543,6 +1620,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
&WebContents::ShowDefinitionForSelection)
.SetMethod("copyImageAt", &WebContents::CopyImageAt)
.SetMethod("capturePage", &WebContents::CapturePage)
.SetMethod("setEmbedder", &WebContents::SetEmbedder)
.SetProperty("id", &WebContents::ID)
.SetProperty("session", &WebContents::Session)
.SetProperty("hostWebContents", &WebContents::HostWebContents)
@@ -1576,7 +1654,15 @@ mate::Handle<WebContents> WebContents::CreateFrom(
return mate::CreateHandle(isolate, static_cast<WebContents*>(existing));
// Otherwise create a new WebContents wrapper object.
return mate::CreateHandle(isolate, new WebContents(isolate, web_contents));
return mate::CreateHandle(isolate, new WebContents(isolate, web_contents,
REMOTE));
}
mate::Handle<WebContents> WebContents::CreateFrom(
v8::Isolate* isolate, content::WebContents* web_contents, Type type) {
// Otherwise create a new WebContents wrapper object.
return mate::CreateHandle(isolate, new WebContents(isolate, web_contents,
type));
}
// static

View File

@@ -58,6 +58,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
// Create from an existing WebContents.
static mate::Handle<WebContents> CreateFrom(
v8::Isolate* isolate, content::WebContents* web_contents);
static mate::Handle<WebContents> CreateFrom(
v8::Isolate* isolate, content::WebContents* web_contents, Type type);
// Create a new WebContents.
static mate::Handle<WebContents> Create(
@@ -66,7 +68,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
int GetID() const;
int64_t GetID() const;
int GetProcessID() const;
Type GetType() const;
bool Equal(const WebContents* web_contents) const;
void LoadURL(const GURL& url, const mate::Dictionary& options);
@@ -102,6 +105,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
void SetAudioMuted(bool muted);
bool IsAudioMuted();
void Print(mate::Arguments* args);
void SetEmbedder(const WebContents* embedder);
// Print current page as PDF.
void PrintToPDF(const base::DictionaryValue& setting,
@@ -164,6 +168,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
bool IsPainting() const;
void SetFrameRate(int frame_rate);
int GetFrameRate() const;
void Invalidate();
// Callback triggered on permission response.
void OnEnterFullscreenModeForTab(content::WebContents* source,
@@ -173,7 +178,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
// Create window with the given disposition.
void OnCreateWindow(const GURL& target_url,
const std::string& frame_name,
WindowOpenDisposition disposition);
WindowOpenDisposition disposition,
const std::vector<base::string16>& features);
// Returns the web preferences of current WebContents.
v8::Local<v8::Value> GetWebPreferences(v8::Isolate* isolate);
@@ -189,16 +195,34 @@ class WebContents : public mate::TrackableObject<WebContents>,
v8::Local<v8::Value> Debugger(v8::Isolate* isolate);
protected:
WebContents(v8::Isolate* isolate, content::WebContents* web_contents);
WebContents(v8::Isolate* isolate,
content::WebContents* web_contents,
Type type);
WebContents(v8::Isolate* isolate, const mate::Dictionary& options);
~WebContents();
void InitWithSessionAndOptions(v8::Isolate* isolate,
content::WebContents *web_contents,
mate::Handle<class Session> session,
const mate::Dictionary& options);
// content::WebContentsDelegate:
bool AddMessageToConsole(content::WebContents* source,
int32_t level,
const base::string16& message,
int32_t line_no,
const base::string16& source_id) override;
void WebContentsCreated(content::WebContents* source_contents,
int opener_render_frame_id,
const std::string& frame_name,
const GURL& target_url,
content::WebContents* new_contents) override;
void AddNewContents(content::WebContents* source,
content::WebContents* new_contents,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
bool* was_blocked) override;
content::WebContents* OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params) override;

View File

@@ -14,7 +14,6 @@
#include "atom/common/native_mate_converters/gurl_converter.h"
#include "atom/common/native_mate_converters/image_converter.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/node_includes.h"
#include "atom/common/options_switches.h"
#include "base/command_line.h"
#include "content/public/browser/render_process_host.h"
@@ -31,6 +30,8 @@
#include "atom/browser/ui/win/taskbar_host.h"
#endif
#include "atom/common/node_includes.h"
#if defined(OS_WIN)
namespace mate {
@@ -71,20 +72,33 @@ v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
Window::Window(v8::Isolate* isolate, v8::Local<v8::Object> wrapper,
const mate::Dictionary& options) {
// Use options.webPreferences to create WebContents.
mate::Dictionary web_preferences = mate::Dictionary::CreateEmpty(isolate);
options.Get(options::kWebPreferences, &web_preferences);
mate::Handle<class WebContents> web_contents;
// If no WebContents was passed to the constructor, create it from options.
if (!options.Get("webContents", &web_contents)) {
// Use options.webPreferences to create WebContents.
mate::Dictionary web_preferences = mate::Dictionary::CreateEmpty(isolate);
options.Get(options::kWebPreferences, &web_preferences);
// Copy the backgroundColor to webContents.
v8::Local<v8::Value> value;
if (options.Get(options::kBackgroundColor, &value))
web_preferences.Set(options::kBackgroundColor, value);
// Copy the backgroundColor to webContents.
v8::Local<v8::Value> value;
if (options.Get(options::kBackgroundColor, &value))
web_preferences.Set(options::kBackgroundColor, value);
v8::Local<v8::Value> transparent;
if (options.Get("transparent", &transparent))
web_preferences.Set("transparent", transparent);
// Creates the WebContents used by BrowserWindow.
auto web_contents = WebContents::Create(isolate, web_preferences);
v8::Local<v8::Value> transparent;
if (options.Get("transparent", &transparent))
web_preferences.Set("transparent", transparent);
// Creates the WebContents used by BrowserWindow.
web_contents = WebContents::Create(isolate, web_preferences);
}
Init(isolate, wrapper, options, web_contents);
}
void Window::Init(v8::Isolate* isolate,
v8::Local<v8::Object> wrapper,
const mate::Dictionary& options,
mate::Handle<class WebContents> web_contents) {
web_contents_.Reset(isolate, web_contents.ToV8());
api_web_contents_ = web_contents.get();
@@ -229,6 +243,10 @@ void Window::OnWindowScrollTouchEnd() {
Emit("scroll-touch-end");
}
void Window::OnWindowScrollTouchEdge() {
Emit("scroll-touch-edge");
}
void Window::OnWindowSwipe(const std::string& direction) {
Emit("swipe", direction);
}
@@ -481,8 +499,10 @@ bool Window::IsClosable() {
return window_->IsClosable();
}
void Window::SetAlwaysOnTop(bool top) {
window_->SetAlwaysOnTop(top);
void Window::SetAlwaysOnTop(bool top, mate::Arguments* args) {
std::string level = "floating";
args->GetNext(&level);
window_->SetAlwaysOnTop(top, level);
}
bool Window::IsAlwaysOnTop() {

View File

@@ -74,6 +74,7 @@ class Window : public mate::TrackableObject<Window>,
void OnWindowMoved() override;
void OnWindowScrollTouchBegin() override;
void OnWindowScrollTouchEnd() override;
void OnWindowScrollTouchEdge() override;
void OnWindowSwipe(const std::string& direction) override;
void OnWindowEnterFullScreen() override;
void OnWindowLeaveFullScreen() override;
@@ -88,6 +89,10 @@ class Window : public mate::TrackableObject<Window>,
#endif
private:
void Init(v8::Isolate* isolate,
v8::Local<v8::Object> wrapper,
const mate::Dictionary& options,
mate::Handle<class WebContents> web_contents);
// APIs for NativeWindow.
void Close();
void Focus();
@@ -131,7 +136,7 @@ class Window : public mate::TrackableObject<Window>,
bool IsFullScreenable();
void SetClosable(bool closable);
bool IsClosable();
void SetAlwaysOnTop(bool top);
void SetAlwaysOnTop(bool top, mate::Arguments* args);
bool IsAlwaysOnTop();
void Center();
void SetPosition(int x, int y, mate::Arguments* args);

View File

@@ -5,9 +5,12 @@
#include "atom/browser/api/frame_subscriber.h"
#include "atom/common/native_mate_converters/gfx_converter.h"
#include "atom/common/node_includes.h"
#include "base/bind.h"
#include "content/public/browser/render_widget_host.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "atom/common/node_includes.h"
namespace atom {
@@ -40,6 +43,17 @@ bool FrameSubscriber::ShouldCaptureFrame(
if (only_dirty_)
rect = dirty_rect;
gfx::Size view_size = rect.size();
gfx::Size bitmap_size = view_size;
const gfx::NativeView native_view = view_->GetNativeView();
const float scale =
display::Screen::GetScreen()->GetDisplayNearestWindow(native_view)
.device_scale_factor();
if (scale > 1.0f)
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
rect = gfx::Rect(rect.origin(), bitmap_size);
host->CopyFromBackingStore(
rect,
rect.size(),

View File

@@ -4,23 +4,67 @@
#include "atom/browser/atom_access_token_store.h"
#include <string>
#include <utility>
#include "atom/browser/atom_browser_context.h"
#include "atom/common/google_api_key.h"
#include "base/environment.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/geolocation_provider.h"
using content::BrowserThread;
namespace atom {
namespace {
// Notice that we just combined the api key with the url together here, because
// if we use the standard {url: key} format Chromium would override our key with
// the predefined one in common.gypi of libchromiumcontent, which is empty.
const char* kGeolocationProviderURL =
"https://www.googleapis.com/geolocation/v1/geolocate?key="
GOOGLEAPIS_API_KEY;
// Loads access tokens and other necessary data on the UI thread, and
// calls back to the originator on the originating thread.
class TokenLoadingJob : public base::RefCountedThreadSafe<TokenLoadingJob> {
public:
explicit TokenLoadingJob(
const content::AccessTokenStore::LoadAccessTokensCallback& callback)
: callback_(callback), request_context_getter_(nullptr) {}
void Run() {
BrowserThread::PostTaskAndReply(
BrowserThread::UI,
FROM_HERE,
base::Bind(&TokenLoadingJob::PerformWorkOnUIThread, this),
base::Bind(&TokenLoadingJob::RespondOnOriginatingThread, this));
}
private:
friend class base::RefCountedThreadSafe<TokenLoadingJob>;
~TokenLoadingJob() {}
void PerformWorkOnUIThread() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto browser_context = AtomBrowserContext::From("", false);
request_context_getter_ = browser_context->GetRequestContext();
std::unique_ptr<base::Environment> env(base::Environment::Create());
if (!env->GetVar("GOOGLE_API_KEY", &api_key_))
api_key_ = GOOGLEAPIS_API_KEY;
}
void RespondOnOriginatingThread() {
// Equivalent to access_token_map[kGeolocationProviderURL].
// Somehow base::string16 is causing compilation errors when used in a pair
// of std::map on Linux, this can work around it.
content::AccessTokenStore::AccessTokenMap access_token_map;
std::pair<GURL, base::string16> token_pair;
token_pair.first = GURL(GOOGLEAPIS_ENDPOINT + api_key_);
access_token_map.insert(token_pair);
callback_.Run(access_token_map, request_context_getter_);
}
content::AccessTokenStore::LoadAccessTokensCallback callback_;
net::URLRequestContextGetter* request_context_getter_;
std::string api_key_;
};
} // namespace
@@ -33,35 +77,12 @@ AtomAccessTokenStore::~AtomAccessTokenStore() {
void AtomAccessTokenStore::LoadAccessTokens(
const LoadAccessTokensCallback& callback) {
content::BrowserThread::PostTaskAndReply(
content::BrowserThread::UI,
FROM_HERE,
base::Bind(&AtomAccessTokenStore::GetRequestContextOnUIThread, this),
base::Bind(&AtomAccessTokenStore::RespondOnOriginatingThread,
this, callback));
scoped_refptr<TokenLoadingJob> job(new TokenLoadingJob(callback));
job->Run();
}
void AtomAccessTokenStore::SaveAccessToken(const GURL& server_url,
const base::string16& access_token) {
}
void AtomAccessTokenStore::GetRequestContextOnUIThread() {
auto browser_context = AtomBrowserContext::From("", false);
request_context_getter_ = browser_context->GetRequestContext();
}
void AtomAccessTokenStore::RespondOnOriginatingThread(
const LoadAccessTokensCallback& callback) {
// Equivelent to access_token_map[kGeolocationProviderURL].
// Somehow base::string16 is causing compilation errors when used in a pair
// of std::map on Linux, this can work around it.
AccessTokenMap access_token_map;
std::pair<GURL, base::string16> token_pair;
token_pair.first = GURL(kGeolocationProviderURL);
access_token_map.insert(token_pair);
callback.Run(access_token_map, request_context_getter_.get());
request_context_getter_ = nullptr;
}
} // namespace atom

View File

@@ -21,11 +21,6 @@ class AtomAccessTokenStore : public content::AccessTokenStore {
const base::string16& access_token) override;
private:
void GetRequestContextOnUIThread();
void RespondOnOriginatingThread(const LoadAccessTokensCallback& callback);
scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
DISALLOW_COPY_AND_ASSIGN(AtomAccessTokenStore);
};

View File

@@ -0,0 +1,138 @@
// Copyright (c) 2016 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/browser/atom_blob_reader.h"
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "storage/browser/blob/blob_data_handle.h"
#include "storage/browser/blob/blob_reader.h"
#include "storage/browser/blob/blob_storage_context.h"
#include "storage/browser/fileapi/file_system_context.h"
#include "atom/common/node_includes.h"
using content::BrowserThread;
namespace atom {
namespace {
void FreeNodeBufferData(char* data, void* hint) {
delete[] data;
}
void RunCallbackInUI(
const AtomBlobReader::CompletionCallback& callback,
char* blob_data,
int size) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
if (blob_data) {
v8::Local<v8::Value> buffer = node::Buffer::New(isolate,
blob_data, static_cast<size_t>(size), &FreeNodeBufferData, nullptr)
.ToLocalChecked();
callback.Run(buffer);
} else {
callback.Run(v8::Null(isolate));
}
}
} // namespace
AtomBlobReader::AtomBlobReader(
content::ChromeBlobStorageContext* blob_context,
storage::FileSystemContext* file_system_context)
: blob_context_(blob_context),
file_system_context_(file_system_context) {
}
AtomBlobReader::~AtomBlobReader() {
}
void AtomBlobReader::StartReading(
const std::string& uuid,
const AtomBlobReader::CompletionCallback& completion_callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
auto blob_data_handle =
blob_context_->context()->GetBlobDataFromUUID(uuid);
auto callback = base::Bind(&RunCallbackInUI,
completion_callback);
if (!blob_data_handle) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(callback, nullptr, 0));
return;
}
auto blob_reader = blob_data_handle->CreateReader(
file_system_context_.get(),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get());
BlobReadHelper* blob_read_helper =
new BlobReadHelper(std::move(blob_reader), callback);
blob_read_helper->Read();
}
AtomBlobReader::BlobReadHelper::BlobReadHelper(
std::unique_ptr<storage::BlobReader> blob_reader,
const BlobReadHelper::CompletionCallback& callback)
: blob_reader_(std::move(blob_reader)),
completion_callback_(callback) {
}
AtomBlobReader::BlobReadHelper::~BlobReadHelper() {
}
void AtomBlobReader::BlobReadHelper::Read() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
storage::BlobReader::Status size_status = blob_reader_->CalculateSize(
base::Bind(&AtomBlobReader::BlobReadHelper::DidCalculateSize,
base::Unretained(this)));
if (size_status != storage::BlobReader::Status::IO_PENDING)
DidCalculateSize(net::OK);
}
void AtomBlobReader::BlobReadHelper::DidCalculateSize(int result) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (result != net::OK) {
DidReadBlobData(nullptr, 0);
return;
}
uint64_t total_size = blob_reader_->total_size();
int bytes_read = 0;
scoped_refptr<net::IOBuffer> blob_data =
new net::IOBuffer(static_cast<size_t>(total_size));
auto callback = base::Bind(&AtomBlobReader::BlobReadHelper::DidReadBlobData,
base::Unretained(this),
base::RetainedRef(blob_data));
storage::BlobReader::Status read_status = blob_reader_->Read(
blob_data.get(),
total_size,
&bytes_read,
callback);
if (read_status != storage::BlobReader::Status::IO_PENDING)
callback.Run(bytes_read);
}
void AtomBlobReader::BlobReadHelper::DidReadBlobData(
const scoped_refptr<net::IOBuffer>& blob_data,
int size) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
char* data = new char[size];
memcpy(data, blob_data->data(), size);
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(completion_callback_, data, size));
delete this;
}
} // namespace atom

View File

@@ -0,0 +1,80 @@
// Copyright (c) 2016 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_ATOM_BLOB_READER_H_
#define ATOM_BROWSER_ATOM_BLOB_READER_H_
#include <string>
#include "base/callback.h"
namespace content {
class ChromeBlobStorageContext;
}
namespace net {
class IOBuffer;
}
namespace storage {
class BlobDataHandle;
class BlobReader;
class FileSystemContext;
}
namespace v8 {
template <class T>
class Local;
class Value;
}
namespace atom {
// A class to keep track of the blob context. All methods,
// except Ctor are expected to be called on IO thread.
class AtomBlobReader {
public:
using CompletionCallback = base::Callback<void(v8::Local<v8::Value>)>;
AtomBlobReader(content::ChromeBlobStorageContext* blob_context,
storage::FileSystemContext* file_system_context);
~AtomBlobReader();
void StartReading(
const std::string& uuid,
const AtomBlobReader::CompletionCallback& callback);
private:
// A self-destroyed helper class to read the blob data.
// Must be accessed on IO thread.
class BlobReadHelper {
public:
using CompletionCallback = base::Callback<void(char*, int)>;
BlobReadHelper(std::unique_ptr<storage::BlobReader> blob_reader,
const BlobReadHelper::CompletionCallback& callback);
~BlobReadHelper();
void Read();
private:
void DidCalculateSize(int result);
void DidReadBlobData(const scoped_refptr<net::IOBuffer>& blob_data,
int bytes_read);
std::unique_ptr<storage::BlobReader> blob_reader_;
BlobReadHelper::CompletionCallback completion_callback_;
DISALLOW_COPY_AND_ASSIGN(BlobReadHelper);
};
scoped_refptr<content::ChromeBlobStorageContext> blob_context_;
scoped_refptr<storage::FileSystemContext> file_system_context_;
DISALLOW_COPY_AND_ASSIGN(AtomBlobReader);
};
} // namespace atom
#endif // ATOM_BROWSER_ATOM_BLOB_READER_H_

View File

@@ -32,11 +32,13 @@
#include "chrome/browser/speech/tts_message_filter.h"
#include "content/public/browser/browser_ppapi_host.h"
#include "content/public/browser/client_certificate_delegate.h"
#include "content/public/browser/geolocation_delegate.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/web_preferences.h"
#include "net/ssl/ssl_cert_request_info.h"
#include "ppapi/host/ppapi_host.h"
@@ -53,6 +55,19 @@ bool g_suppress_renderer_process_restart = false;
// Custom schemes to be registered to handle service worker.
std::string g_custom_service_worker_schemes = "";
// A provider of Geolocation services to override AccessTokenStore.
class AtomGeolocationDelegate : public content::GeolocationDelegate {
public:
AtomGeolocationDelegate() = default;
content::AccessTokenStore* CreateAccessTokenStore() final {
return new AtomAccessTokenStore();
}
private:
DISALLOW_COPY_AND_ASSIGN(AtomGeolocationDelegate);
};
void Noop(scoped_refptr<content::SiteInstance>) {
}
@@ -85,6 +100,44 @@ content::WebContents* AtomBrowserClient::GetWebContentsFromProcessID(
return WebContentsPreferences::GetWebContentsFromProcessID(process_id);
}
bool AtomBrowserClient::ShouldCreateNewSiteInstance(
content::BrowserContext* browser_context,
content::SiteInstance* current_instance,
const GURL& url) {
if (url.SchemeIs(url::kJavaScriptScheme))
// "javacript:" scheme should always use same SiteInstance
return false;
if (!IsRendererSandboxed(current_instance->GetProcess()->GetID()))
// non-sandboxed renderers should always create a new SiteInstance
return true;
// Create new a SiteInstance if navigating to a different site.
auto src_url = current_instance->GetSiteURL();
return
!content::SiteInstance::IsSameWebSite(browser_context, src_url, url) &&
// `IsSameWebSite` doesn't seem to work for some URIs such as `file:`,
// handle these scenarios by comparing only the site as defined by
// `GetSiteForURL`.
content::SiteInstance::GetSiteForURL(browser_context, url) != src_url;
}
void AtomBrowserClient::AddSandboxedRendererId(int process_id) {
base::AutoLock auto_lock(sandboxed_renderers_lock_);
sandboxed_renderers_.insert(process_id);
}
void AtomBrowserClient::RemoveSandboxedRendererId(int process_id) {
base::AutoLock auto_lock(sandboxed_renderers_lock_);
sandboxed_renderers_.erase(process_id);
}
bool AtomBrowserClient::IsRendererSandboxed(int process_id) {
base::AutoLock auto_lock(sandboxed_renderers_lock_);
return sandboxed_renderers_.count(process_id);
}
void AtomBrowserClient::RenderProcessWillLaunch(
content::RenderProcessHost* host) {
int process_id = host->GetID();
@@ -92,6 +145,13 @@ void AtomBrowserClient::RenderProcessWillLaunch(
host->AddFilter(new TtsMessageFilter(process_id, host->GetBrowserContext()));
host->AddFilter(
new WidevineCdmMessageFilter(process_id, host->GetBrowserContext()));
content::WebContents* web_contents = GetWebContentsFromProcessID(process_id);
if (WebContentsPreferences::IsSandboxed(web_contents)) {
AddSandboxedRendererId(host->GetID());
// ensure the sandboxed renderer id is removed later
host->AddObserver(this);
}
}
content::SpeechRecognitionManagerDelegate*
@@ -99,8 +159,9 @@ content::SpeechRecognitionManagerDelegate*
return new AtomSpeechRecognitionManagerDelegate;
}
content::AccessTokenStore* AtomBrowserClient::CreateAccessTokenStore() {
return new AtomAccessTokenStore;
content::GeolocationDelegate*
AtomBrowserClient::CreateGeolocationDelegate() {
return new AtomGeolocationDelegate();
}
void AtomBrowserClient::OverrideWebkitPrefs(
@@ -140,8 +201,7 @@ void AtomBrowserClient::OverrideSiteInstanceForNavigation(
return;
}
// Restart renderer process for all navigations except "javacript:" scheme.
if (url.SchemeIs(url::kJavaScriptScheme))
if (!ShouldCreateNewSiteInstance(browser_context, current_instance, url))
return;
scoped_refptr<content::SiteInstance> site_instance =
@@ -173,6 +233,7 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
// Copy following switches to child process.
static const char* const kCommonSwitchNames[] = {
switches::kStandardSchemes,
switches::kEnableSandbox
};
command_line->CopySwitchesFrom(
*base::CommandLine::ForCurrentProcess(),
@@ -257,6 +318,7 @@ bool AtomBrowserClient::CanCreateWindow(
const content::Referrer& referrer,
WindowOpenDisposition disposition,
const blink::WebWindowFeatures& features,
const std::vector<base::string16>& additional_features,
bool user_gesture,
bool opener_suppressed,
content::ResourceContext* context,
@@ -266,6 +328,11 @@ bool AtomBrowserClient::CanCreateWindow(
bool* no_javascript_access) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
if (IsRendererSandboxed(render_process_id)) {
*no_javascript_access = false;
return true;
}
if (delegate_) {
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
base::Bind(&api::App::OnCreateWindow,
@@ -273,6 +340,7 @@ bool AtomBrowserClient::CanCreateWindow(
target_url,
frame_name,
disposition,
additional_features,
render_process_id,
opener_render_frame_id));
}
@@ -287,6 +355,7 @@ void AtomBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
additional_schemes->insert(additional_schemes->end(),
schemes_list.begin(),
schemes_list.end());
additional_schemes->push_back(content::kChromeDevToolsScheme);
}
brightray::BrowserMainParts* AtomBrowserClient::OverrideCreateBrowserMainParts(
@@ -323,6 +392,7 @@ void AtomBrowserClient::RenderProcessHostDestroyed(
break;
}
}
RemoveSandboxedRendererId(process_id);
}
} // namespace atom

View File

@@ -6,6 +6,7 @@
#define ATOM_BROWSER_ATOM_BROWSER_CLIENT_H_
#include <map>
#include <set>
#include <string>
#include <vector>
@@ -49,7 +50,7 @@ class AtomBrowserClient : public brightray::BrowserClient,
void RenderProcessWillLaunch(content::RenderProcessHost* host) override;
content::SpeechRecognitionManagerDelegate*
CreateSpeechRecognitionManagerDelegate() override;
content::AccessTokenStore* CreateAccessTokenStore() override;
content::GeolocationDelegate* CreateGeolocationDelegate() override;
void OverrideWebkitPrefs(content::RenderViewHost* render_view_host,
content::WebPreferences* prefs) override;
std::string GetApplicationLocale() override;
@@ -87,6 +88,7 @@ class AtomBrowserClient : public brightray::BrowserClient,
const content::Referrer& referrer,
WindowOpenDisposition disposition,
const blink::WebWindowFeatures& features,
const std::vector<base::string16>& additional_features,
bool user_gesture,
bool opener_suppressed,
content::ResourceContext* context,
@@ -108,8 +110,19 @@ class AtomBrowserClient : public brightray::BrowserClient,
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
private:
bool ShouldCreateNewSiteInstance(content::BrowserContext* browser_context,
content::SiteInstance* current_instance,
const GURL& dest_url);
// Add/remove a process id to `sandboxed_renderers_`.
void AddSandboxedRendererId(int process_id);
void RemoveSandboxedRendererId(int process_id);
bool IsRendererSandboxed(int process_id);
// pending_render_process => current_render_process.
std::map<int, int> pending_processes_;
// Set that contains the process ids of all sandboxed renderers
std::set<int> sandboxed_renderers_;
base::Lock sandboxed_renderers_lock_;
std::unique_ptr<AtomResourceDispatcherHostDelegate>
resource_dispatcher_host_delegate_;

View File

@@ -5,6 +5,7 @@
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/api/atom_api_protocol.h"
#include "atom/browser/atom_blob_reader.h"
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/atom_download_manager_delegate.h"
#include "atom/browser/atom_permission_manager.h"
@@ -30,7 +31,9 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_registry_simple.h"
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/user_agent.h"
#include "net/ftp/ftp_network_layer.h"
@@ -68,7 +71,8 @@ AtomBrowserContext::AtomBrowserContext(
const std::string& partition, bool in_memory,
const base::DictionaryValue& options)
: brightray::BrowserContext(partition, in_memory),
network_delegate_(new AtomNetworkDelegate) {
network_delegate_(new AtomNetworkDelegate),
cookie_delegate_(new AtomCookieDelegate) {
// Construct user agent string.
Browser* browser = Browser::Get();
std::string name = RemoveWhitespace(browser->GetName());
@@ -104,6 +108,10 @@ net::NetworkDelegate* AtomBrowserContext::CreateNetworkDelegate() {
return network_delegate_;
}
net::CookieMonsterDelegate* AtomBrowserContext::CreateCookieDelegate() {
return cookie_delegate();
}
std::string AtomBrowserContext::GetUserAgent() {
return user_agent_;
}
@@ -207,6 +215,19 @@ void AtomBrowserContext::RegisterPrefs(PrefRegistrySimple* pref_registry) {
pref_registry->RegisterDictionaryPref(prefs::kDevToolsFileSystemPaths);
}
AtomBlobReader* AtomBrowserContext::GetBlobReader() {
if (!blob_reader_.get()) {
content::ChromeBlobStorageContext* blob_context =
content::ChromeBlobStorageContext::GetFor(this);
storage::FileSystemContext* file_system_context =
content::BrowserContext::GetStoragePartition(
this, nullptr)->GetFileSystemContext();
blob_reader_.reset(new AtomBlobReader(blob_context,
file_system_context));
}
return blob_reader_.get();
}
// static
scoped_refptr<AtomBrowserContext> AtomBrowserContext::From(
const std::string& partition, bool in_memory,

View File

@@ -8,10 +8,13 @@
#include <string>
#include <vector>
#include "atom/browser/net/atom_cookie_delegate.h"
#include "brightray/browser/browser_context.h"
#include "net/cookies/cookie_monster.h"
namespace atom {
class AtomBlobReader;
class AtomDownloadManagerDelegate;
class AtomNetworkDelegate;
class AtomPermissionManager;
@@ -30,6 +33,7 @@ class AtomBrowserContext : public brightray::BrowserContext {
// brightray::URLRequestContextGetter::Delegate:
net::NetworkDelegate* CreateNetworkDelegate() override;
net::CookieMonsterDelegate* CreateCookieDelegate() override;
std::string GetUserAgent() override;
std::unique_ptr<net::URLRequestJobFactory> CreateURLRequestJobFactory(
content::ProtocolHandlerMap* protocol_handlers) override;
@@ -47,7 +51,11 @@ class AtomBrowserContext : public brightray::BrowserContext {
// brightray::BrowserContext:
void RegisterPrefs(PrefRegistrySimple* pref_registry) override;
AtomBlobReader* GetBlobReader();
AtomNetworkDelegate* network_delegate() const { return network_delegate_; }
AtomCookieDelegate* cookie_delegate() const {
return cookie_delegate_.get();
}
protected:
AtomBrowserContext(const std::string& partition, bool in_memory,
@@ -58,11 +66,13 @@ class AtomBrowserContext : public brightray::BrowserContext {
std::unique_ptr<AtomDownloadManagerDelegate> download_manager_delegate_;
std::unique_ptr<WebViewManager> guest_manager_;
std::unique_ptr<AtomPermissionManager> permission_manager_;
std::unique_ptr<AtomBlobReader> blob_reader_;
std::string user_agent_;
bool use_cache_;
// Managed by brightray::BrowserContext.
AtomNetworkDelegate* network_delegate_;
scoped_refptr<AtomCookieDelegate> cookie_delegate_;
DISALLOW_COPY_AND_ASSIGN(AtomBrowserContext);
};

View File

@@ -117,7 +117,7 @@ void AtomBrowserMainParts::PostEarlyInitialization() {
if (node_debugger_->IsRunning())
env->AssignToContext(v8::Debug::GetDebugContext());
// Add atom-shell extended APIs.
// Add Electron extended APIs.
atom_bindings_->BindTo(js_env_->isolate(), env->process_object());
// Load everything.

View File

@@ -60,7 +60,7 @@ void AtomDownloadManagerDelegate::CreateDownloadPath(
std::string(),
suggested_filename,
mime_type,
std::string());
"download");
if (!base::PathExists(default_download_path))
base::CreateDirectory(default_download_path);

View File

@@ -10,8 +10,17 @@
#include "base/strings/utf_string_conversions.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/escape.h"
#include "net/ssl/client_cert_store.h"
#include "url/gurl.h"
#if defined(USE_NSS_CERTS)
#include "net/ssl/client_cert_store_nss.h"
#elif defined(OS_WIN)
#include "net/ssl/client_cert_store_win.h"
#elif defined(OS_MACOSX)
#include "net/ssl/client_cert_store_mac.h"
#endif
using content::BrowserThread;
namespace atom {
@@ -59,7 +68,8 @@ bool AtomResourceDispatcherHostDelegate::HandleExternalProtocol(
const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
bool is_main_frame,
ui::PageTransition transition,
bool has_user_gesture) {
bool has_user_gesture,
content::ResourceContext* resource_context) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&HandleExternalProtocolInUI,
url,
@@ -75,4 +85,19 @@ AtomResourceDispatcherHostDelegate::CreateLoginDelegate(
return new LoginHandler(auth_info, request);
}
std::unique_ptr<net::ClientCertStore>
AtomResourceDispatcherHostDelegate::CreateClientCertStore(
content::ResourceContext* resource_context) {
#if defined(USE_NSS_CERTS)
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreNSS(
net::ClientCertStoreNSS::PasswordDelegateFactory()));
#elif defined(OS_WIN)
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreWin());
#elif defined(OS_MACOSX)
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreMac());
#elif defined(USE_OPENSSL)
return std::unique_ptr<net::ClientCertStore>();
#endif
}
} // namespace atom

View File

@@ -21,10 +21,13 @@ class AtomResourceDispatcherHostDelegate
const content::ResourceRequestInfo::WebContentsGetter&,
bool is_main_frame,
ui::PageTransition transition,
bool has_user_gesture) override;
bool has_user_gesture,
content::ResourceContext* resource_context) override;
content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(
net::AuthChallengeInfo* auth_info,
net::URLRequest* request) override;
std::unique_ptr<net::ClientCertStore> CreateClientCertStore(
content::ResourceContext* resource_context) override;
};
} // namespace atom

View File

@@ -27,7 +27,7 @@ bool BridgeTaskRunner::PostDelayedTask(
base::TimeDelta delay) {
auto message_loop = base::MessageLoop::current();
if (!message_loop) {
tasks_.push_back(base::MakeTuple(from_here, task, delay));
tasks_.push_back(std::make_tuple(from_here, task, delay));
return true;
}
@@ -48,7 +48,7 @@ bool BridgeTaskRunner::PostNonNestableDelayedTask(
base::TimeDelta delay) {
auto message_loop = base::MessageLoop::current();
if (!message_loop) {
non_nestable_tasks_.push_back(base::MakeTuple(from_here, task, delay));
non_nestable_tasks_.push_back(std::make_tuple(from_here, task, delay));
return true;
}

View File

@@ -5,6 +5,7 @@
#ifndef ATOM_BROWSER_BRIDGE_TASK_RUNNER_H_
#define ATOM_BROWSER_BRIDGE_TASK_RUNNER_H_
#include <tuple>
#include <vector>
#include "base/single_thread_task_runner.h"
@@ -33,7 +34,7 @@ class BridgeTaskRunner : public base::SingleThreadTaskRunner {
base::TimeDelta delay) override;
private:
using TaskPair = base::Tuple<
using TaskPair = std::tuple<
tracked_objects::Location, base::Closure, base::TimeDelta>;
std::vector<TaskPair> tasks_;
std::vector<TaskPair> non_nestable_tasks_;

View File

@@ -60,7 +60,7 @@ class Browser : public WindowListObserver {
// Overrides the application version.
void SetVersion(const std::string& version);
// Returns the application's name, default is just Atom-Shell.
// Returns the application's name, default is just Electron.
std::string GetName() const;
// Overrides the application name.

View File

@@ -252,11 +252,11 @@ content::ColorChooser* CommonWebContentsDelegate::OpenColorChooser(
}
void CommonWebContentsDelegate::RunFileChooser(
content::WebContents* guest,
content::RenderFrameHost* render_frame_host,
const content::FileChooserParams& params) {
if (!web_dialog_helper_)
web_dialog_helper_.reset(new WebDialogHelper(owner_window()));
web_dialog_helper_->RunFileChooser(guest, params);
web_dialog_helper_->RunFileChooser(render_frame_host, params);
}
void CommonWebContentsDelegate::EnumerateDirectory(content::WebContents* guest,

View File

@@ -71,7 +71,7 @@ class CommonWebContentsDelegate
content::WebContents* web_contents,
SkColor color,
const std::vector<content::ColorSuggestion>& suggestions) override;
void RunFileChooser(content::WebContents* web_contents,
void RunFileChooser(content::RenderFrameHost* render_frame_host,
const content::FileChooserParams& params) override;
void EnumerateDirectory(content::WebContents* web_contents,
int request_id,

View File

@@ -10,6 +10,10 @@
#include "base/strings/sys_string_conversions.h"
#include "base/values.h"
@interface NSWindow (SierraSDK)
@property(class) BOOL allowsAutomaticWindowTabbing;
@end
@implementation AtomApplicationDelegate
- (void)setApplicationDockMenu:(atom::AtomMenuModel*)model {
@@ -21,6 +25,10 @@
// Don't add the "Enter Full Screen" menu item automatically.
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSFullScreenMenuItemEverywhere"];
// Don't add the "Show Tab Bar" menu item.
if ([NSWindow respondsToSelector:@selector(allowsAutomaticWindowTabbing)])
NSWindow.allowsAutomaticWindowTabbing = NO;
atom::Browser::Get()->WillFinishLaunching();
}

View File

@@ -33,6 +33,7 @@
#include "content/public/common/content_switches.h"
#include "ipc/ipc_message_macros.h"
#include "native_mate/dictionary.h"
#include "third_party/skia/include/core/SkRegion.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
@@ -390,6 +391,10 @@ void NativeWindow::RequestToClosePage() {
if (window_unresposive_closure_.IsCancelled())
ScheduleUnresponsiveEvent(5000);
if (!web_contents())
// Already closed by renderer
return;
if (web_contents()->NeedToFireBeforeUnload())
web_contents()->DispatchBeforeUnload();
else
@@ -503,6 +508,11 @@ void NativeWindow::NotifyWindowScrollTouchEnd() {
OnWindowScrollTouchEnd());
}
void NativeWindow::NotifyWindowScrollTouchEdge() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
OnWindowScrollTouchEdge());
}
void NativeWindow::NotifyWindowSwipe(const std::string& direction) {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
OnWindowSwipe(direction));

View File

@@ -118,7 +118,8 @@ class NativeWindow : public base::SupportsUserData,
virtual bool IsFullScreenable() = 0;
virtual void SetClosable(bool closable) = 0;
virtual bool IsClosable() = 0;
virtual void SetAlwaysOnTop(bool top) = 0;
virtual void SetAlwaysOnTop(bool top,
const std::string& level = "floating") = 0;
virtual bool IsAlwaysOnTop() = 0;
virtual void Center() = 0;
virtual void SetTitle(const std::string& title) = 0;
@@ -207,6 +208,7 @@ class NativeWindow : public base::SupportsUserData,
void NotifyWindowMoved();
void NotifyWindowScrollTouchBegin();
void NotifyWindowScrollTouchEnd();
void NotifyWindowScrollTouchEdge();
void NotifyWindowSwipe(const std::string& direction);
void NotifyWindowEnterFullScreen();
void NotifyWindowLeaveFullScreen();

View File

@@ -64,7 +64,7 @@ class NativeWindowMac : public NativeWindow,
bool IsFullScreenable() override;
void SetClosable(bool closable) override;
bool IsClosable() override;
void SetAlwaysOnTop(bool top) override;
void SetAlwaysOnTop(bool top, const std::string& level) override;
bool IsAlwaysOnTop() override;
void Center() override;
void SetTitle(const std::string& title) override;
@@ -160,9 +160,6 @@ class NativeWindowMac : public NativeWindow,
// The "titleBarStyle" option.
TitleBarStyle title_bar_style_;
// Whether user has scrolled the page to edge.
bool is_edge_;
DISALLOW_COPY_AND_ASSIGN(NativeWindowMac);
};

View File

@@ -22,6 +22,7 @@
#include "content/public/browser/render_widget_host_view.h"
#include "native_mate/dictionary.h"
#include "skia/ext/skia_utils_mac.h"
#include "third_party/skia/include/core/SkRegion.h"
#include "ui/gfx/skia_util.h"
namespace {
@@ -529,8 +530,7 @@ NativeWindowMac::NativeWindowMac(
: NativeWindow(web_contents, options, parent),
is_kiosk_(false),
attention_request_id_(0),
title_bar_style_(NORMAL),
is_edge_(false) {
title_bar_style_(NORMAL) {
int width = 800, height = 600;
options.Get(options::kWidth, &width);
options.Get(options::kHeight, &height);
@@ -675,16 +675,14 @@ NativeWindowMac::NativeWindowMac(
if (!web_contents)
return event;
if (!began && is_edge_ && (([event phase] == NSEventPhaseMayBegin) ||
if (!began && (([event phase] == NSEventPhaseMayBegin) ||
([event phase] == NSEventPhaseBegan))) {
this->NotifyWindowScrollTouchBegin();
began = YES;
is_edge_ = false;
} else if (began && (([event phase] == NSEventPhaseEnded) ||
([event phase] == NSEventPhaseCancelled))) {
this->NotifyWindowScrollTouchEnd();
began = NO;
is_edge_ = false;
}
return event;
}];
@@ -742,8 +740,9 @@ bool NativeWindowMac::IsFocused() {
void NativeWindowMac::Show() {
if (is_modal() && parent()) {
[parent()->GetNativeWindow() beginSheet:window_
completionHandler:^(NSModalResponse) {}];
if ([window_ sheetParent] == nil)
[parent()->GetNativeWindow() beginSheet:window_
completionHandler:^(NSModalResponse) {}];
return;
}
@@ -945,12 +944,32 @@ bool NativeWindowMac::IsClosable() {
return [window_ styleMask] & NSClosableWindowMask;
}
void NativeWindowMac::SetAlwaysOnTop(bool top) {
[window_ setLevel:(top ? NSFloatingWindowLevel : NSNormalWindowLevel)];
void NativeWindowMac::SetAlwaysOnTop(bool top, const std::string& level) {
int windowLevel = NSNormalWindowLevel;
if (top) {
if (level == "floating") {
windowLevel = NSFloatingWindowLevel;
} else if (level == "torn-off-menu") {
windowLevel = NSTornOffMenuWindowLevel;
} else if (level == "modal-panel") {
windowLevel = NSModalPanelWindowLevel;
} else if (level == "main-menu") {
windowLevel = NSMainMenuWindowLevel;
} else if (level == "status") {
windowLevel = NSStatusWindowLevel;
} else if (level == "pop-up-menu") {
windowLevel = NSPopUpMenuWindowLevel;
} else if (level == "screen-saver") {
windowLevel = NSScreenSaverWindowLevel;
} else if (level == "dock") {
windowLevel = NSDockWindowLevel;
}
}
[window_ setLevel:windowLevel];
}
bool NativeWindowMac::IsAlwaysOnTop() {
return [window_ level] == NSFloatingWindowLevel;
return [window_ level] != NSNormalWindowLevel;
}
void NativeWindowMac::Center() {
@@ -1009,8 +1028,8 @@ bool NativeWindowMac::IsKiosk() {
void NativeWindowMac::SetBackgroundColor(const std::string& color_name) {
SkColor color = ParseHexColor(color_name);
base::ScopedCFTypeRef<CGColorRef> cgcolor =
skia::CGColorCreateFromSkColor(color);
base::ScopedCFTypeRef<CGColorRef> cgcolor(
skia::CGColorCreateFromSkColor(color));
[[[window_ contentView] layer] setBackgroundColor:cgcolor];
const auto view = web_contents()->GetRenderWidgetHostView();
@@ -1130,7 +1149,7 @@ void NativeWindowMac::OnInputEvent(const blink::WebInputEvent& event) {
case blink::WebInputEvent::GestureScrollBegin:
case blink::WebInputEvent::GestureScrollUpdate:
case blink::WebInputEvent::GestureScrollEnd:
is_edge_ = true;
this->NotifyWindowScrollTouchEdge();
break;
default:
break;

View File

@@ -64,6 +64,7 @@ class NativeWindowObserver {
virtual void OnWindowMoved() {}
virtual void OnWindowScrollTouchBegin() {}
virtual void OnWindowScrollTouchEnd() {}
virtual void OnWindowScrollTouchEdge() {}
virtual void OnWindowSwipe(const std::string& direction) {}
virtual void OnWindowEnterFullScreen() {}
virtual void OnWindowLeaveFullScreen() {}

View File

@@ -682,7 +682,7 @@ bool NativeWindowViews::IsClosable() {
#endif
}
void NativeWindowViews::SetAlwaysOnTop(bool top) {
void NativeWindowViews::SetAlwaysOnTop(bool top, const std::string& level) {
window_->SetAlwaysOnTop(top);
}

View File

@@ -84,7 +84,7 @@ class NativeWindowViews : public NativeWindow,
bool IsFullScreenable() override;
void SetClosable(bool closable) override;
bool IsClosable() override;
void SetAlwaysOnTop(bool top) override;
void SetAlwaysOnTop(bool top, const std::string& level) override;
bool IsAlwaysOnTop() override;
void Center() override;
void SetTitle(const std::string& title) override;

View File

@@ -40,10 +40,7 @@ void AtomCertVerifier::SetVerifyProc(const VerifyProc& proc) {
}
int AtomCertVerifier::Verify(
net::X509Certificate* cert,
const std::string& hostname,
const std::string& ocsp_response,
int flags,
const RequestParams& params,
net::CRLSet* crl_set,
net::CertVerifyResult* verify_result,
const net::CompletionCallback& callback,
@@ -53,12 +50,11 @@ int AtomCertVerifier::Verify(
if (verify_proc_.is_null())
return default_cert_verifier_->Verify(
cert, hostname, ocsp_response, flags, crl_set, verify_result, callback,
out_req, net_log);
params, crl_set, verify_result, callback, out_req, net_log);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(verify_proc_, hostname, make_scoped_refptr(cert),
base::Bind(verify_proc_, params.hostname(), params.certificate(),
base::Bind(OnResult, verify_result, callback)));
return net::ERR_IO_PENDING;
}

View File

@@ -26,10 +26,7 @@ class AtomCertVerifier : public net::CertVerifier {
protected:
// net::CertVerifier:
int Verify(net::X509Certificate* cert,
const std::string& hostname,
const std::string& ocsp_response,
int flags,
int Verify(const RequestParams& params,
net::CRLSet* crl_set,
net::CertVerifyResult* verify_result,
const net::CompletionCallback& callback,

View File

@@ -0,0 +1,41 @@
// Copyright (c) 2016 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/atom_cookie_delegate.h"
#include "content/public/browser/browser_thread.h"
namespace atom {
AtomCookieDelegate::AtomCookieDelegate() {
}
AtomCookieDelegate::~AtomCookieDelegate() {
}
void AtomCookieDelegate::AddObserver(Observer* observer) {
observers_.AddObserver(observer);
}
void AtomCookieDelegate::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer);
}
void AtomCookieDelegate::NotifyObservers(
const net::CanonicalCookie& cookie, bool removed, ChangeCause cause) {
FOR_EACH_OBSERVER(Observer,
observers_,
OnCookieChanged(cookie, removed, cause));
}
void AtomCookieDelegate::OnCookieChanged(
const net::CanonicalCookie& cookie, bool removed, ChangeCause cause) {
content::BrowserThread::PostTask(
content::BrowserThread::UI,
FROM_HERE,
base::Bind(&AtomCookieDelegate::NotifyObservers,
this, cookie, removed, cause));
}
} // namespace atom

View File

@@ -0,0 +1,48 @@
// Copyright (c) 2016 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_ATOM_COOKIE_DELEGATE_H_
#define ATOM_BROWSER_NET_ATOM_COOKIE_DELEGATE_H_
#include "base/observer_list.h"
#include "net/cookies/cookie_monster.h"
namespace atom {
class AtomCookieDelegate : public net::CookieMonsterDelegate {
public:
AtomCookieDelegate();
~AtomCookieDelegate() override;
class Observer {
public:
virtual void OnCookieChanged(const net::CanonicalCookie& cookie,
bool removed,
ChangeCause cause) {}
protected:
virtual ~Observer() {}
};
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
// net::CookieMonsterDelegate:
void OnCookieChanged(const net::CanonicalCookie& cookie,
bool removed,
ChangeCause cause) override;
private:
base::ObserverList<Observer> observers_;
void NotifyObservers(const net::CanonicalCookie& cookie,
bool removed,
ChangeCause cause);
DISALLOW_COPY_AND_ASSIGN(AtomCookieDelegate);
};
} // namespace atom
#endif // ATOM_BROWSER_NET_ATOM_COOKIE_DELEGATE_H_

View File

@@ -239,7 +239,7 @@ int AtomNetworkDelegate::OnBeforeURLRequest(
return HandleResponseEvent(kOnBeforeRequest, request, callback, new_url);
}
int AtomNetworkDelegate::OnBeforeSendHeaders(
int AtomNetworkDelegate::OnBeforeStartTransaction(
net::URLRequest* request,
const net::CompletionCallback& callback,
net::HttpRequestHeaders* headers) {
@@ -254,18 +254,18 @@ int AtomNetworkDelegate::OnBeforeSendHeaders(
DevToolsNetworkTransaction::kDevToolsEmulateNetworkConditionsClientId,
client_id);
if (!ContainsKey(response_listeners_, kOnBeforeSendHeaders))
return brightray::NetworkDelegate::OnBeforeSendHeaders(
return brightray::NetworkDelegate::OnBeforeStartTransaction(
request, callback, headers);
return HandleResponseEvent(
kOnBeforeSendHeaders, request, callback, headers, *headers);
}
void AtomNetworkDelegate::OnSendHeaders(
void AtomNetworkDelegate::OnStartTransaction(
net::URLRequest* request,
const net::HttpRequestHeaders& headers) {
if (!ContainsKey(simple_listeners_, kOnSendHeaders)) {
brightray::NetworkDelegate::OnSendHeaders(request, headers);
brightray::NetworkDelegate::OnStartTransaction(request, headers);
return;
}

View File

@@ -77,11 +77,11 @@ class AtomNetworkDelegate : public brightray::NetworkDelegate {
int OnBeforeURLRequest(net::URLRequest* request,
const net::CompletionCallback& callback,
GURL* new_url) override;
int OnBeforeSendHeaders(net::URLRequest* request,
const net::CompletionCallback& callback,
net::HttpRequestHeaders* headers) override;
void OnSendHeaders(net::URLRequest* request,
const net::HttpRequestHeaders& headers) override;
int OnBeforeStartTransaction(net::URLRequest* request,
const net::CompletionCallback& callback,
net::HttpRequestHeaders* headers) override;
void OnStartTransaction(net::URLRequest* request,
const net::HttpRequestHeaders& headers) override;
int OnHeadersReceived(
net::URLRequest* request,
const net::CompletionCallback& callback,

View File

@@ -71,8 +71,9 @@ class AtomCopyFrameGenerator {
content::BrowserThread::PostDelayedTask(content::BrowserThread::UI,
FROM_HERE,
base::Bind(&AtomCopyFrameGenerator::InternalGenerateCopyFrame,
weak_ptr_factory_.GetWeakPtr()), base::TimeDelta::FromMilliseconds(
frame_rate_threshold_ms_ - frame_rate_delta));
weak_ptr_factory_.GetWeakPtr()),
base::TimeDelta::FromMilliseconds(
frame_rate_threshold_ms_ - frame_rate_delta));
return;
}
@@ -103,9 +104,7 @@ class AtomCopyFrameGenerator {
damage_rect));
request->set_area(gfx::Rect(view_->GetPhysicalBackingSize()));
view_->DelegatedFrameHostGetLayer()->RequestCopyOfOutput(
std::move(request));
view_->GetRootLayer()->RequestCopyOfOutput(std::move(request));
}
void CopyFromCompositingSurfaceHasResult(
@@ -302,10 +301,9 @@ class AtomBeginFrameTimer : public cc::DelayBasedTimeSourceClient {
AtomBeginFrameTimer(int frame_rate_threshold_ms,
const base::Closure& callback)
: callback_(callback) {
time_source_ = cc::DelayBasedTimeSource::Create(
base::TimeDelta::FromMilliseconds(frame_rate_threshold_ms),
time_source_.reset(new cc::DelayBasedTimeSource(
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::UI).get());
content::BrowserThread::UI).get()));
time_source_->SetClient(this);
}
@@ -351,12 +349,17 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
is_showing_(!render_widget_host_->is_hidden()),
size_(native_window->GetSize()),
painting_(true),
root_layer_(new ui::Layer(ui::LAYER_SOLID_COLOR)),
#if !defined(OS_MACOSX)
delegated_frame_host_(new content::DelegatedFrameHost(this)),
#endif
weak_ptr_factory_(this) {
DCHECK(render_widget_host_);
render_widget_host_->SetView(this);
#if !defined(OS_MACOSX)
root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
#endif
#if defined(OS_MACOSX)
CreatePlatformWidget();
#else
@@ -364,17 +367,29 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
new ui::Compositor(content::GetContextFactory(),
base::ThreadTaskRunnerHandle::Get()));
compositor_->SetAcceleratedWidget(native_window_->GetAcceleratedWidget());
#endif
compositor_->SetDelegate(this);
compositor_->SetRootLayer(root_layer_.get());
#endif
GetCompositor()->SetDelegate(this);
native_window_->AddObserver(this);
ResizeRootLayer();
}
OffScreenRenderWidgetHostView::~OffScreenRenderWidgetHostView() {
if (native_window_)
native_window_->RemoveObserver(this);
#if defined(OS_MACOSX)
if (is_showing_)
browser_compositor_->SetRenderWidgetHostIsHidden(true);
#else
// Marking the DelegatedFrameHost as removed from the window hierarchy is
// necessary to remove all connections to its old ui::Compositor.
if (is_showing_)
delegated_frame_host_->WasHidden();
delegated_frame_host_->ResetCompositor();
#endif
#if defined(OS_MACOSX)
DestroyPlatformWidget();
@@ -429,11 +444,10 @@ content::RenderWidgetHost* OffScreenRenderWidgetHostView::GetRenderWidgetHost()
void OffScreenRenderWidgetHostView::SetSize(const gfx::Size& size) {
size_ = size;
const gfx::Size& size_in_pixels =
gfx::ConvertSizeToPixel(scale_factor_, size);
root_layer_->SetBounds(gfx::Rect(size));
compositor_->SetScaleAndSize(scale_factor_, size_in_pixels);
ResizeRootLayer();
if (render_widget_host_)
render_widget_host_->WasResized();
GetDelegatedFrameHost()->WasResized();
}
void OffScreenRenderWidgetHostView::SetBounds(const gfx::Rect& new_bounds) {
@@ -464,7 +478,7 @@ bool OffScreenRenderWidgetHostView::HasFocus() const {
}
bool OffScreenRenderWidgetHostView::IsSurfaceAvailableForCopy() const {
return delegated_frame_host_->CanCopyToBitmap();
return GetDelegatedFrameHost()->CanCopyToBitmap();
}
void OffScreenRenderWidgetHostView::Show() {
@@ -472,10 +486,16 @@ void OffScreenRenderWidgetHostView::Show() {
return;
is_showing_ = true;
if (render_widget_host_)
render_widget_host_->WasShown(ui::LatencyInfo());
#if defined(OS_MACOSX)
browser_compositor_->SetRenderWidgetHostIsHidden(false);
#else
delegated_frame_host_->SetCompositor(compositor_.get());
delegated_frame_host_->WasShown(ui::LatencyInfo());
#endif
if (render_widget_host_)
render_widget_host_->WasShown(ui::LatencyInfo());
}
void OffScreenRenderWidgetHostView::Hide() {
@@ -484,8 +504,14 @@ void OffScreenRenderWidgetHostView::Hide() {
if (render_widget_host_)
render_widget_host_->WasHidden();
delegated_frame_host_->WasHidden();
delegated_frame_host_->ResetCompositor();
#if defined(OS_MACOSX)
browser_compositor_->SetRenderWidgetHostIsHidden(true);
#else
GetDelegatedFrameHost()->WasHidden();
GetDelegatedFrameHost()->ResetCompositor();
#endif
is_showing_ = false;
}
@@ -522,52 +548,63 @@ bool OffScreenRenderWidgetHostView::LockMouse() {
void OffScreenRenderWidgetHostView::UnlockMouse() {
}
bool OffScreenRenderWidgetHostView::GetScreenColorProfile(std::vector<char>*) {
return false;
}
void OffScreenRenderWidgetHostView::OnSwapCompositorFrame(
uint32_t output_surface_id,
std::unique_ptr<cc::CompositorFrame> frame) {
cc::CompositorFrame frame) {
TRACE_EVENT0("electron",
"OffScreenRenderWidgetHostView::OnSwapCompositorFrame");
if (frame->metadata.root_scroll_offset != last_scroll_offset_) {
last_scroll_offset_ = frame->metadata.root_scroll_offset;
if (frame.metadata.root_scroll_offset != last_scroll_offset_) {
last_scroll_offset_ = frame.metadata.root_scroll_offset;
}
if (frame->delegated_frame_data) {
if (frame.delegated_frame_data) {
if (software_output_device_) {
if (!begin_frame_timer_.get()) {
software_output_device_->SetActive(painting_);
}
// The compositor will draw directly to the SoftwareOutputDevice which
// then calls OnPaint.
#if defined(OS_MACOSX)
browser_compositor_->SwapCompositorFrame(output_surface_id,
std::move(frame));
#else
delegated_frame_host_->SwapDelegatedFrame(output_surface_id,
std::move(frame));
#endif
} else {
if (!copy_frame_generator_.get()) {
copy_frame_generator_.reset(
new AtomCopyFrameGenerator(frame_rate_threshold_ms_, this));
}
// Determine the damage rectangle for the current frame. This is the same
// calculation that SwapDelegatedFrame uses.
cc::RenderPass* root_pass =
frame->delegated_frame_data->render_pass_list.back().get();
frame.delegated_frame_data->render_pass_list.back().get();
gfx::Size frame_size = root_pass->output_rect.size();
gfx::Rect damage_rect =
gfx::ToEnclosingRect(gfx::RectF(root_pass->damage_rect));
damage_rect.Intersect(gfx::Rect(frame_size));
#if defined(OS_MACOSX)
browser_compositor_->SwapCompositorFrame(output_surface_id,
std::move(frame));
#else
delegated_frame_host_->SwapDelegatedFrame(output_surface_id,
std::move(frame));
#endif
if (painting_)
copy_frame_generator_->GenerateCopyFrame(true, damage_rect);
// Request a copy of the last compositor frame which will eventually call
// OnPaint asynchronously.
copy_frame_generator_->GenerateCopyFrame(true, damage_rect);
}
}
}
void OffScreenRenderWidgetHostView::ClearCompositorFrame() {
delegated_frame_host_->ClearDelegatedFrame();
GetDelegatedFrameHost()->ClearDelegatedFrame();
}
void OffScreenRenderWidgetHostView::InitAsPopup(
@@ -612,7 +649,7 @@ void OffScreenRenderWidgetHostView::CopyFromCompositingSurface(
const gfx::Size& dst_size,
const content::ReadbackRequestCallback& callback,
const SkColorType preferred_color_type) {
delegated_frame_host_->CopyFromCompositingSurface(
GetDelegatedFrameHost()->CopyFromCompositingSurface(
src_subrect, dst_size, callback, preferred_color_type);
}
@@ -620,21 +657,21 @@ void OffScreenRenderWidgetHostView::CopyFromCompositingSurfaceToVideoFrame(
const gfx::Rect& src_subrect,
const scoped_refptr<media::VideoFrame>& target,
const base::Callback<void(const gfx::Rect&, bool)>& callback) {
delegated_frame_host_->CopyFromCompositingSurfaceToVideoFrame(
GetDelegatedFrameHost()->CopyFromCompositingSurfaceToVideoFrame(
src_subrect, target, callback);
}
bool OffScreenRenderWidgetHostView::CanCopyToVideoFrame() const {
return delegated_frame_host_->CanCopyToVideoFrame();
return GetDelegatedFrameHost()->CanCopyToVideoFrame();
}
void OffScreenRenderWidgetHostView::BeginFrameSubscription(
std::unique_ptr<content::RenderWidgetHostViewFrameSubscriber> subscriber) {
delegated_frame_host_->BeginFrameSubscription(std::move(subscriber));
GetDelegatedFrameHost()->BeginFrameSubscription(std::move(subscriber));
}
void OffScreenRenderWidgetHostView::EndFrameSubscription() {
delegated_frame_host_->EndFrameSubscription();
GetDelegatedFrameHost()->EndFrameSubscription();
}
bool OffScreenRenderWidgetHostView::HasAcceleratedSurface(const gfx::Size &) {
@@ -749,7 +786,7 @@ void OffScreenRenderWidgetHostView::SetBeginFrameSource(
std::unique_ptr<cc::SoftwareOutputDevice>
OffScreenRenderWidgetHostView::CreateSoftwareOutputDevice(
ui::Compositor* compositor) {
DCHECK_EQ(compositor_.get(), compositor);
DCHECK_EQ(GetCompositor(), compositor);
DCHECK(!copy_frame_generator_);
DCHECK(!software_output_device_);
@@ -763,7 +800,11 @@ std::unique_ptr<cc::SoftwareOutputDevice>
bool OffScreenRenderWidgetHostView::InstallTransparency() {
if (transparent_) {
SetBackgroundColor(SkColor());
#if defined(OS_MACOSX)
browser_compositor_->SetHasTransparentBackground(true);
#else
compositor_->SetHostHasTransparentBackground(true);
#endif
return true;
}
return false;
@@ -816,13 +857,28 @@ int OffScreenRenderWidgetHostView::GetFrameRate() const {
return frame_rate_;
}
#if !defined(OS_MACOSX)
ui::Compositor* OffScreenRenderWidgetHostView::GetCompositor() const {
return compositor_.get();
}
ui::Layer* OffScreenRenderWidgetHostView::GetRootLayer() const {
return root_layer_.get();
}
content::DelegatedFrameHost*
OffScreenRenderWidgetHostView::GetDelegatedFrameHost() const {
return delegated_frame_host_.get();
}
#endif
void OffScreenRenderWidgetHostView::SetupFrameRate(bool force) {
if (!force && frame_rate_threshold_ms_ != 0)
return;
frame_rate_threshold_ms_ = 1000 / frame_rate_;
compositor_->vsync_manager()->SetAuthoritativeVSyncInterval(
GetCompositor()->vsync_manager()->SetAuthoritativeVSyncInterval(
base::TimeDelta::FromMilliseconds(frame_rate_threshold_ms_));
if (copy_frame_generator_.get()) {
@@ -840,6 +896,16 @@ void OffScreenRenderWidgetHostView::SetupFrameRate(bool force) {
}
}
void OffScreenRenderWidgetHostView::Invalidate() {
const gfx::Rect& bounds_in_pixels = GetViewBounds();
if (software_output_device_) {
software_output_device_->OnPaint(bounds_in_pixels);
} else if (copy_frame_generator_.get()) {
copy_frame_generator_->GenerateCopyFrame(true, bounds_in_pixels);
}
}
void OffScreenRenderWidgetHostView::ResizeRootLayer() {
SetupFrameRate(false);
@@ -848,14 +914,25 @@ void OffScreenRenderWidgetHostView::ResizeRootLayer() {
gfx::Size size = GetViewBounds().size();
if (!scaleFactorDidChange && size == root_layer_->bounds().size())
if (!scaleFactorDidChange && size == GetRootLayer()->bounds().size())
return;
const gfx::Size& size_in_pixels =
gfx::ConvertSizeToPixel(scale_factor_, size);
root_layer_->SetBounds(gfx::Rect(size));
compositor_->SetScaleAndSize(scale_factor_, size_in_pixels);
GetRootLayer()->SetBounds(gfx::Rect(size));
GetCompositor()->SetScaleAndSize(scale_factor_, size_in_pixels);
}
void OffScreenRenderWidgetHostView::OnWindowResize() {
// In offscreen mode call RenderWidgetHostView's SetSize explicitly
auto size = native_window_->GetSize();
SetSize(size);
}
void OffScreenRenderWidgetHostView::OnWindowClosed() {
native_window_->RemoveObserver(this);
native_window_ = nullptr;
}
} // namespace atom

View File

@@ -13,6 +13,7 @@
#endif
#include "atom/browser/native_window.h"
#include "atom/browser/native_window_observer.h"
#include "atom/browser/osr/osr_output_device.h"
#include "base/process/kill.h"
#include "base/threading/thread.h"
@@ -36,7 +37,6 @@
#if defined(OS_MACOSX)
#include "content/browser/renderer_host/browser_compositor_view_mac.h"
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
#endif
#if defined(OS_MACOSX)
@@ -54,13 +54,15 @@ namespace atom {
class AtomCopyFrameGenerator;
class AtomBeginFrameTimer;
#if defined(OS_MACOSX)
class MacHelper;
#endif
class OffScreenRenderWidgetHostView
: public content::RenderWidgetHostViewBase,
#if defined(OS_MACOSX)
public ui::AcceleratedWidgetMacNSView,
#endif
public ui::CompositorDelegate,
public content::DelegatedFrameHostClient {
public content::DelegatedFrameHostClient,
public NativeWindowObserver {
public:
OffScreenRenderWidgetHostView(bool transparent,
const OnPaintCallback& callback,
@@ -90,7 +92,6 @@ class OffScreenRenderWidgetHostView
void SetBackgroundColor(SkColor color) override;
bool LockMouse(void) override;
void UnlockMouse(void) override;
bool GetScreenColorProfile(std::vector<char>*) override;
#if defined(OS_MACOSX)
ui::AcceleratedWidgetMac* GetAcceleratedWidgetMac() const override;
void SetActive(bool active) override;
@@ -102,7 +103,7 @@ class OffScreenRenderWidgetHostView
#endif // defined(OS_MACOSX)
// content::RenderWidgetHostViewBase:
void OnSwapCompositorFrame(uint32_t, std::unique_ptr<cc::CompositorFrame>)
void OnSwapCompositorFrame(uint32_t, cc::CompositorFrame)
override;
void ClearCompositorFrame(void) override;
void InitAsPopup(content::RenderWidgetHostView *rwhv, const gfx::Rect& rect)
@@ -173,13 +174,9 @@ class OffScreenRenderWidgetHostView
bool IsAutoResizeEnabled() const;
void OnSetNeedsBeginFrames(bool enabled);
#if defined(OS_MACOSX)
// ui::AcceleratedWidgetMacNSView:
NSView* AcceleratedWidgetGetNSView() const override;
void AcceleratedWidgetGetVSyncParameters(
base::TimeTicks* timebase, base::TimeDelta* interval) const override;
void AcceleratedWidgetSwapCompleted() override;
#endif // defined(OS_MACOSX)
// NativeWindowObserver:
void OnWindowResize() override;
void OnWindowClosed() override;
void OnBeginFrameTimerTick();
void SendBeginFrame(base::TimeTicks frame_time,
@@ -198,9 +195,15 @@ class OffScreenRenderWidgetHostView
void SetFrameRate(int frame_rate);
int GetFrameRate() const;
ui::Compositor* compositor() const { return compositor_.get(); }
ui::Compositor* GetCompositor() const;
ui::Layer* GetRootLayer() const;
content::DelegatedFrameHost* GetDelegatedFrameHost() const;
void Invalidate();
content::RenderWidgetHostImpl* render_widget_host() const
{ return render_widget_host_; }
NativeWindow* window() const { return native_window_; }
private:
void SetupFrameRate(bool force);
@@ -233,10 +236,13 @@ class OffScreenRenderWidgetHostView
std::unique_ptr<AtomBeginFrameTimer> begin_frame_timer_;
#if defined(OS_MACOSX)
NSWindow* window_;
CALayer* background_layer_;
std::unique_ptr<content::BrowserCompositorMac> browser_compositor_;
// Can not be managed by smart pointer because its header can not be included
// in the file that has the destructor.
MacHelper* mac_helper_;
// Selected text on the renderer.
std::string selected_text_;
#endif

View File

@@ -7,48 +7,115 @@
#import <Cocoa/Cocoa.h>
#include "base/strings/utf_string_conversions.h"
#include "content/common/view_messages.h"
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
namespace atom {
class MacHelper :
public content::BrowserCompositorMacClient,
public ui::AcceleratedWidgetMacNSView {
public:
explicit MacHelper(OffScreenRenderWidgetHostView* view) : view_(view) {}
virtual ~MacHelper() {}
// content::BrowserCompositorMacClient:
NSView* BrowserCompositorMacGetNSView() const override {
// Intentionally return nil so that
// BrowserCompositorMac::DelegatedFrameHostDesiredSizeInDIP uses the layer
// size instead of the NSView size.
return nil;
}
SkColor BrowserCompositorMacGetGutterColor(SkColor color) const override {
// When making an element on the page fullscreen the element's background
// may not match the page's, so use black as the gutter color to avoid
// flashes of brighter colors during the transition.
if (view_->render_widget_host()->delegate() &&
view_->render_widget_host()->delegate()->IsFullscreenForCurrentTab()) {
return SK_ColorBLACK;
}
return color;
}
void BrowserCompositorMacSendCompositorSwapAck(
int output_surface_id,
const cc::CompositorFrameAck& ack) override {
view_->render_widget_host()->Send(new ViewMsg_SwapCompositorFrameAck(
view_->render_widget_host()->GetRoutingID(), output_surface_id, ack));
}
void BrowserCompositorMacSendReclaimCompositorResources(
int output_surface_id,
const cc::CompositorFrameAck& ack) override {
view_->render_widget_host()->Send(new ViewMsg_ReclaimCompositorResources(
view_->render_widget_host()->GetRoutingID(), output_surface_id, ack));
}
void BrowserCompositorMacOnLostCompositorResources() override {
view_->render_widget_host()->ScheduleComposite();
}
void BrowserCompositorMacUpdateVSyncParameters(
const base::TimeTicks& timebase,
const base::TimeDelta& interval) override {
view_->render_widget_host()->UpdateVSyncParameters(timebase, interval);
}
void BrowserCompositorMacSendBeginFrame(
const cc::BeginFrameArgs& args) override {
view_->render_widget_host()->Send(
new ViewMsg_BeginFrame(view_->render_widget_host()->GetRoutingID(),
args));
}
// ui::AcceleratedWidgetMacNSView:
NSView* AcceleratedWidgetGetNSView() const override {
return [view_->window()->GetNativeWindow() contentView];
}
void AcceleratedWidgetGetVSyncParameters(
base::TimeTicks* timebase, base::TimeDelta* interval) const override {
*timebase = base::TimeTicks();
*interval = base::TimeDelta();
}
void AcceleratedWidgetSwapCompleted() override {
}
private:
OffScreenRenderWidgetHostView* view_;
DISALLOW_COPY_AND_ASSIGN(MacHelper);
};
ui::AcceleratedWidgetMac*
atom::OffScreenRenderWidgetHostView::GetAcceleratedWidgetMac() const {
OffScreenRenderWidgetHostView::GetAcceleratedWidgetMac() const {
if (browser_compositor_)
return browser_compositor_->accelerated_widget_mac();
return browser_compositor_->GetAcceleratedWidgetMac();
return nullptr;
}
NSView* atom::OffScreenRenderWidgetHostView::AcceleratedWidgetGetNSView() const {
return [native_window_->GetNativeWindow() contentView];
void OffScreenRenderWidgetHostView::SetActive(bool active) {
}
void atom::OffScreenRenderWidgetHostView::AcceleratedWidgetGetVSyncParameters(
base::TimeTicks* timebase, base::TimeDelta* interval) const {
*timebase = base::TimeTicks();
*interval = base::TimeDelta();
void OffScreenRenderWidgetHostView::ShowDefinitionForSelection() {
}
void atom::OffScreenRenderWidgetHostView::AcceleratedWidgetSwapCompleted() {
}
void atom::OffScreenRenderWidgetHostView::SetActive(bool active) {
}
void atom::OffScreenRenderWidgetHostView::ShowDefinitionForSelection() {
}
bool atom::OffScreenRenderWidgetHostView::SupportsSpeech() const {
bool OffScreenRenderWidgetHostView::SupportsSpeech() const {
return false;
}
void atom::OffScreenRenderWidgetHostView::SpeakSelection() {
void OffScreenRenderWidgetHostView::SpeakSelection() {
}
bool atom::OffScreenRenderWidgetHostView::IsSpeaking() const {
bool OffScreenRenderWidgetHostView::IsSpeaking() const {
return false;
}
void atom::OffScreenRenderWidgetHostView::StopSpeaking() {
void OffScreenRenderWidgetHostView::StopSpeaking() {
}
void atom::OffScreenRenderWidgetHostView::SelectionChanged(
void OffScreenRenderWidgetHostView::SelectionChanged(
const base::string16& text,
size_t offset,
const gfx::Range& range) {
@@ -69,24 +136,28 @@ void atom::OffScreenRenderWidgetHostView::SelectionChanged(
RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
}
void atom::OffScreenRenderWidgetHostView::CreatePlatformWidget() {
browser_compositor_ = content::BrowserCompositorMac::Create();
compositor_.reset(browser_compositor_->compositor());
compositor_->SetRootLayer(root_layer_.get());
browser_compositor_->accelerated_widget_mac()->SetNSView(this);
browser_compositor_->compositor()->SetVisible(true);
compositor_->SetLocksWillTimeOut(true);
browser_compositor_->Unsuspend();
void OffScreenRenderWidgetHostView::CreatePlatformWidget() {
mac_helper_ = new MacHelper(this);
browser_compositor_.reset(new content::BrowserCompositorMac(
mac_helper_, mac_helper_, render_widget_host_->is_hidden(), true));
}
void atom::OffScreenRenderWidgetHostView::DestroyPlatformWidget() {
ui::Compositor* compositor = compositor_.release();
ALLOW_UNUSED_LOCAL(compositor);
browser_compositor_->accelerated_widget_mac()->ResetNSView();
browser_compositor_->compositor()->SetVisible(false);
browser_compositor_->compositor()->SetScaleAndSize(1.0, gfx::Size(0, 0));
browser_compositor_->compositor()->SetRootLayer(NULL);
void OffScreenRenderWidgetHostView::DestroyPlatformWidget() {
browser_compositor_.reset();
delete mac_helper_;
}
ui::Compositor* OffScreenRenderWidgetHostView::GetCompositor() const {
return browser_compositor_->GetCompositor();
}
ui::Layer* OffScreenRenderWidgetHostView::GetRootLayer() const {
return browser_compositor_->GetRootLayer();
}
content::DelegatedFrameHost*
OffScreenRenderWidgetHostView::GetDelegatedFrameHost() const {
return browser_compositor_->GetDelegatedFrameHost();
}
} // namespace

View File

@@ -4,6 +4,8 @@
#include "atom/browser/osr/osr_web_contents_view.h"
#import <Cocoa/Cocoa.h>
@interface OffScreenView : NSView
@end

View File

@@ -17,9 +17,9 @@
<key>CFBundleIconFile</key>
<string>electron.icns</string>
<key>CFBundleVersion</key>
<string>1.3.6</string>
<string>1.4.3</string>
<key>CFBundleShortVersionString</key>
<string>1.3.6</string>
<string>1.4.3</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,3,6,0
PRODUCTVERSION 1,3,6,0
FILEVERSION 1,4,3,0
PRODUCTVERSION 1,4,3,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -74,12 +74,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "GitHub, Inc."
VALUE "FileDescription", "Electron"
VALUE "FileVersion", "1.3.6"
VALUE "FileVersion", "1.4.3"
VALUE "InternalName", "electron.exe"
VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved."
VALUE "OriginalFilename", "electron.exe"
VALUE "ProductName", "Electron"
VALUE "ProductVersion", "1.3.6"
VALUE "ProductVersion", "1.4.3"
VALUE "SquirrelAwareVersion", "1"
END
END

View File

@@ -63,7 +63,9 @@ void MenuBar::SetMenu(AtomMenuModel* model) {
RemoveAllChildViews(true);
for (int i = 0; i < model->GetItemCount(); ++i) {
SubmenuButton* button = new SubmenuButton(this, model->GetLabelAt(i), this);
SubmenuButton* button = new SubmenuButton(model->GetLabelAt(i),
this,
background_color_);
button->set_tag(i);
#if defined(USE_X11)
@@ -131,9 +133,6 @@ const char* MenuBar::GetClassName() const {
return kViewClassName;
}
void MenuBar::ButtonPressed(views::Button* sender, const ui::Event& event) {
}
void MenuBar::OnMenuButtonClicked(views::MenuButton* source,
const gfx::Point& point,
const ui::Event* event) {

View File

@@ -6,7 +6,6 @@
#define ATOM_BROWSER_UI_VIEWS_MENU_BAR_H_
#include "atom/browser/ui/atom_menu_model.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/menu_button_listener.h"
#include "ui/views/view.h"
@@ -19,7 +18,6 @@ namespace atom {
class MenuDelegate;
class MenuBar : public views::View,
public views::ButtonListener,
public views::MenuButtonListener {
public:
MenuBar();
@@ -50,9 +48,6 @@ class MenuBar : public views::View,
// views::View:
const char* GetClassName() const override;
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// views::MenuButtonListener:
void OnMenuButtonClicked(views::MenuButton* source,
const gfx::Point& point,

View File

@@ -7,7 +7,10 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/text_utils.h"
#include "ui/views/animation/flood_fill_ink_drop_ripple.h"
#include "ui/views/animation/ink_drop_host_view.h"
#include "ui/views/controls/button/label_button_border.h"
namespace atom {
@@ -23,9 +26,9 @@ base::string16 FilterAccelerator(const base::string16& label) {
} // namespace
SubmenuButton::SubmenuButton(views::ButtonListener* listener,
const base::string16& title,
views::MenuButtonListener* menu_button_listener)
SubmenuButton::SubmenuButton(const base::string16& title,
views::MenuButtonListener* menu_button_listener,
const SkColor& background_color)
: views::MenuButton(FilterAccelerator(title),
menu_button_listener, false),
accelerator_(0),
@@ -34,7 +37,8 @@ SubmenuButton::SubmenuButton(views::ButtonListener* listener,
underline_end_(-1),
text_width_(0),
text_height_(0),
underline_color_(SK_ColorBLACK) {
underline_color_(SK_ColorBLACK),
background_color_(background_color) {
#if defined(OS_LINUX)
// Dont' use native style border.
SetBorder(std::move(CreateDefaultBorder()));
@@ -44,11 +48,45 @@ SubmenuButton::SubmenuButton(views::ButtonListener* listener,
&underline_end_))
gfx::Canvas::SizeStringInt(GetText(), GetFontList(), &text_width_,
&text_height_, 0, 0);
SetHasInkDrop(true);
set_ink_drop_base_color(
color_utils::BlendTowardOppositeLuma(background_color_, 0x61));
set_request_focus_on_press(true);
SetFocusForPlatform();
SetFocusPainter(nullptr);
}
SubmenuButton::~SubmenuButton() {
}
std::unique_ptr<views::InkDropRipple> SubmenuButton::CreateInkDropRipple()
const {
return base::MakeUnique<views::FloodFillInkDropRipple>(
GetLocalBounds(),
GetInkDropCenterBasedOnLastEvent(),
GetInkDropBaseColor(),
ink_drop_visible_opacity());
}
std::unique_ptr<views::InkDropHighlight>
SubmenuButton::CreateInkDropHighlight() const {
if (!ShouldShowInkDropHighlight())
return nullptr;
gfx::Size size = GetLocalBounds().size();
return base::MakeUnique<views::InkDropHighlight>(
size,
kInkDropSmallCornerRadius,
gfx::RectF(gfx::SizeF(size)).CenterPoint(),
GetInkDropBaseColor());
}
bool SubmenuButton::ShouldShowInkDropForFocus() const {
return false;
}
void SubmenuButton::SetAcceleratorVisibility(bool visible) {
if (visible == show_underline_)
return;

View File

@@ -5,6 +5,7 @@
#ifndef ATOM_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_
#define ATOM_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_
#include "ui/views/animation/ink_drop_highlight.h"
#include "ui/views/controls/button/menu_button.h"
namespace atom {
@@ -12,9 +13,9 @@ namespace atom {
// Special button that used by menu bar to show submenus.
class SubmenuButton : public views::MenuButton {
public:
SubmenuButton(views::ButtonListener* listener,
const base::string16& title,
views::MenuButtonListener* menu_button_listener);
SubmenuButton(const base::string16& title,
views::MenuButtonListener* menu_button_listener,
const SkColor& background_color);
virtual ~SubmenuButton();
void SetAcceleratorVisibility(bool visible);
@@ -28,6 +29,12 @@ class SubmenuButton : public views::MenuButton {
// views::MenuButton:
void OnPaint(gfx::Canvas* canvas) override;
// views::InkDropHostView:
std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
const override;
bool ShouldShowInkDropForFocus() const override;
private:
bool GetUnderlinePosition(const base::string16& text,
base::char16* accelerator,
@@ -44,6 +51,7 @@ class SubmenuButton : public views::MenuButton {
int text_width_;
int text_height_;
SkColor underline_color_;
SkColor background_color_;
DISALLOW_COPY_AND_ASSIGN(SubmenuButton);
};

View File

@@ -97,6 +97,12 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
command_line->AppendSwitchASCII(switches::kNodeIntegration,
node_integration ? "true" : "false");
// If the `sandbox` option was passed to the BrowserWindow's webPreferences,
// pass `--enable-sandbox` to the renderer so it won't have any node.js
// integration.
if (IsSandboxed(web_contents))
command_line->AppendSwitch(switches::kEnableSandbox);
// The preload script.
base::FilePath::StringType preload;
if (web_preferences.GetString(options::kPreloadScript, &preload)) {
@@ -194,6 +200,21 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
command_line->AppendSwitch(cc::switches::kEnableBeginFrameScheduling);
}
bool WebContentsPreferences::IsSandboxed(content::WebContents* web_contents) {
WebContentsPreferences* self;
if (!web_contents)
return false;
self = FromWebContents(web_contents);
if (!self)
return false;
base::DictionaryValue& web_preferences = self->web_preferences_;
bool sandboxed = false;
web_preferences.GetBoolean("sandbox", &sandboxed);
return sandboxed;
}
// static
void WebContentsPreferences::OverrideWebkitPrefs(
content::WebContents* web_contents, content::WebPreferences* prefs) {

View File

@@ -36,6 +36,8 @@ class WebContentsPreferences
static void AppendExtraCommandLineSwitches(
content::WebContents* web_contents, base::CommandLine* command_line);
static bool IsSandboxed(content::WebContents* web_contents);
// Modify the WebPreferences according to |web_contents|'s preferences.
static void OverrideWebkitPrefs(
content::WebContents* web_contents, content::WebPreferences* prefs);

View File

@@ -16,9 +16,11 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/file_chooser_file_info.h"
#include "content/public/common/file_chooser_params.h"
#include "net/base/mime_util.h"
#include "ui/shell_dialogs/selected_file_info.h"
@@ -75,8 +77,9 @@ WebDialogHelper::~WebDialogHelper() {
}
void WebDialogHelper::RunFileChooser(content::WebContents* web_contents,
const content::FileChooserParams& params) {
void WebDialogHelper::RunFileChooser(
content::RenderFrameHost* render_frame_host,
const content::FileChooserParams& params) {
std::vector<content::FileChooserFileInfo> result;
file_dialog::Filters filters = GetFileTypesFromAcceptType(
params.accept_types);
@@ -133,8 +136,7 @@ void WebDialogHelper::RunFileChooser(content::WebContents* web_contents,
}
}
web_contents->GetRenderViewHost()->FilesSelectedInChooser(
result, params.mode);
render_frame_host->FilesSelectedInChooser(result, params.mode);
}
void WebDialogHelper::EnumerateDirectory(content::WebContents* web_contents,

View File

@@ -13,6 +13,7 @@ class FilePath;
namespace content {
struct FileChooserParams;
class RenderFrameHost;
class WebContents;
}
@@ -25,7 +26,7 @@ class WebDialogHelper {
explicit WebDialogHelper(NativeWindow* window);
~WebDialogHelper();
void RunFileChooser(content::WebContents* web_contents,
void RunFileChooser(content::RenderFrameHost* render_frame_host,
const content::FileChooserParams& params);
void EnumerateDirectory(content::WebContents* web_contents,
int request_id,

View File

@@ -71,7 +71,8 @@ void WindowList::RemoveObserver(WindowListObserver* observer) {
void WindowList::CloseAllWindows() {
WindowVector windows = GetInstance()->windows_;
for (const auto& window : windows)
window->Close();
if (!window->IsClosed())
window->Close();
}
WindowList::WindowList() {

View File

@@ -11,7 +11,7 @@
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "atom/common/native_mate_converters/gfx_converter.h"
#include "atom/common/native_mate_converters/gurl_converter.h"
#include "atom/common/node_includes.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "base/base64.h"
#include "base/files/file_util.h"
#include "base/strings/pattern.h"
@@ -25,6 +25,7 @@
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/image/image_util.h"
#if defined(OS_WIN)
@@ -33,6 +34,8 @@
#include "ui/gfx/icon_util.h"
#endif
#include "atom/common/node_includes.h"
namespace atom {
namespace api {
@@ -281,6 +284,57 @@ gfx::Size NativeImage::GetSize() {
return image_.Size();
}
float NativeImage::GetAspectRatio() {
gfx::Size size = GetSize();
if (size.IsEmpty())
return 1.f;
else
return static_cast<float>(size.width()) / static_cast<float>(size.height());
}
mate::Handle<NativeImage> NativeImage::Resize(
v8::Isolate* isolate, const base::DictionaryValue& options) {
gfx::Size size = GetSize();
int width = size.width();
int height = size.height();
bool width_set = options.GetInteger("width", &width);
bool height_set = options.GetInteger("height", &height);
size.SetSize(width, height);
if (width_set && !height_set) {
// Scale height to preserve original aspect ratio
size.set_height(width);
size = gfx::ScaleToRoundedSize(size, 1.f, 1.f / GetAspectRatio());
} else if (height_set && !width_set) {
// Scale width to preserve original aspect ratio
size.set_width(height);
size = gfx::ScaleToRoundedSize(size, GetAspectRatio(), 1.f);
}
skia::ImageOperations::ResizeMethod method =
skia::ImageOperations::ResizeMethod::RESIZE_BEST;
std::string quality;
options.GetString("quality", &quality);
if (quality == "good")
method = skia::ImageOperations::ResizeMethod::RESIZE_GOOD;
else if (quality == "better")
method = skia::ImageOperations::ResizeMethod::RESIZE_BETTER;
gfx::ImageSkia resized = gfx::ImageSkiaOperations::CreateResizedImage(
image_.AsImageSkia(), method, size);
return mate::CreateHandle(isolate,
new NativeImage(isolate, gfx::Image(resized)));
}
mate::Handle<NativeImage> NativeImage::Crop(v8::Isolate* isolate,
const gfx::Rect& rect) {
gfx::ImageSkia cropped = gfx::ImageSkiaOperations::ExtractSubset(
image_.AsImageSkia(), rect);
return mate::CreateHandle(isolate,
new NativeImage(isolate, gfx::Image(cropped)));
}
#if !defined(OS_MACOSX)
void NativeImage::SetTemplateImage(bool setAsTemplate) {
}
@@ -381,6 +435,9 @@ void NativeImage::BuildPrototype(
.SetMethod("getSize", &NativeImage::GetSize)
.SetMethod("setTemplateImage", &NativeImage::SetTemplateImage)
.SetMethod("isTemplateImage", &NativeImage::IsTemplateImage)
.SetMethod("resize", &NativeImage::Resize)
.SetMethod("crop", &NativeImage::Crop)
.SetMethod("getAspectRatio", &NativeImage::GetAspectRatio)
// TODO(kevinsawicki): Remove in 2.0, deprecate before then with warnings
.SetMethod("toPng", &NativeImage::ToPNG)
.SetMethod("toJpeg", &NativeImage::ToJPEG);

View File

@@ -8,8 +8,10 @@
#include <map>
#include <string>
#include "base/values.h"
#include "native_mate/handle.h"
#include "native_mate/wrappable.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/image/image.h"
#if defined(OS_WIN)
@@ -75,9 +77,14 @@ class NativeImage : public mate::Wrappable<NativeImage> {
v8::Local<v8::Value> GetNativeHandle(
v8::Isolate* isolate,
mate::Arguments* args);
mate::Handle<NativeImage> Resize(v8::Isolate* isolate,
const base::DictionaryValue& options);
mate::Handle<NativeImage> Crop(v8::Isolate* isolate,
const gfx::Rect& rect);
std::string ToDataURL();
bool IsEmpty();
gfx::Size GetSize();
float GetAspectRatio();
// Mark the image as template image.
void SetTemplateImage(bool setAsTemplate);

View File

@@ -104,7 +104,7 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
dict.SetMethod("setRemoteObjectFreer", &atom::RemoteObjectFreer::BindTo);
dict.SetMethod("createIDWeakMap", &atom::api::KeyWeakMap<int32_t>::Create);
dict.SetMethod("createDoubleIDWeakMap",
&atom::api::KeyWeakMap<std::pair<int32_t, int32_t>>::Create);
&atom::api::KeyWeakMap<std::pair<int64_t, int32_t>>::Create);
}
} // namespace

View File

@@ -117,8 +117,10 @@ void AtomBindings::BindTo(v8::Isolate* isolate,
mate::Dictionary versions;
if (dict.Get("versions", &versions)) {
versions.Set(ATOM_PROJECT_NAME, ATOM_VERSION_STRING);
versions.Set("atom-shell", ATOM_VERSION_STRING); // For compatibility.
versions.Set("chrome", CHROME_VERSION_STRING);
// TODO(kevinsawicki): Remove in 2.0
versions.Set("atom-shell", ATOM_VERSION_STRING);
}
}

View File

@@ -24,7 +24,7 @@ class AtomBindings {
virtual ~AtomBindings();
// Add process.atomBinding function, which behaves like process.binding but
// load native code from atom-shell instead.
// load native code from Electron instead.
void BindTo(v8::Isolate* isolate, v8::Local<v8::Object> process);
private:

View File

@@ -12,8 +12,7 @@ namespace atom {
ObjectLifeMonitor::ObjectLifeMonitor(v8::Isolate* isolate,
v8::Local<v8::Object> target)
: isolate_(isolate),
context_(isolate, isolate->GetCurrentContext()),
: context_(isolate, isolate->GetCurrentContext()),
target_(isolate, target),
weak_ptr_factory_(this) {
target_.SetWeak(this, OnObjectGC, v8::WeakCallbackType::kParameter);

View File

@@ -22,7 +22,6 @@ class ObjectLifeMonitor {
static void OnObjectGC(const v8::WeakCallbackInfo<ObjectLifeMonitor>& data);
static void Free(const v8::WeakCallbackInfo<ObjectLifeMonitor>& data);
v8::Isolate* isolate_;
v8::Global<v8::Context> context_;
v8::Global<v8::Object> target_;

View File

@@ -6,8 +6,8 @@
#define ATOM_COMMON_ATOM_VERSION_H_
#define ATOM_MAJOR_VERSION 1
#define ATOM_MINOR_VERSION 3
#define ATOM_PATCH_VERSION 6
#define ATOM_MINOR_VERSION 4
#define ATOM_PATCH_VERSION 3
#define ATOM_VERSION_IS_RELEASE 1

View File

@@ -8,7 +8,7 @@
#ifndef ATOM_COMMON_CHROME_VERSION_H_
#define ATOM_COMMON_CHROME_VERSION_H_
#define CHROME_VERSION_STRING "52.0.2743.82"
#define CHROME_VERSION_STRING "53.0.2785.113"
#define CHROME_VERSION "v" CHROME_VERSION_STRING
#endif // ATOM_COMMON_CHROME_VERSION_H_

View File

@@ -5,6 +5,11 @@
#ifndef ATOM_COMMON_GOOGLE_API_KEY_H_
#define ATOM_COMMON_GOOGLE_API_KEY_H_
#ifndef GOOGLEAPIS_ENDPOINT
#define GOOGLEAPIS_ENDPOINT \
"https://www.googleapis.com/geolocation/v1/geolocate?key="
#endif
#ifndef GOOGLEAPIS_API_KEY
#define GOOGLEAPIS_API_KEY "AIzaSyAQfxPJiounkhOjODEO5ZieffeBv6yft2Q"
#endif

View File

@@ -238,7 +238,15 @@ bool Converter<blink::WebMouseWheelEvent>::FromV8(
dict.Get("accelerationRatioX", &out->accelerationRatioX);
dict.Get("accelerationRatioY", &out->accelerationRatioY);
dict.Get("hasPreciseScrollingDeltas", &out->hasPreciseScrollingDeltas);
dict.Get("canScroll", &out->canScroll);
#if defined(USE_AURA)
// Matches the behavior of ui/events/blink/web_input_event_traits.cc:
bool can_scroll = true;
if (dict.Get("canScroll", &can_scroll) && !can_scroll) {
out->hasPreciseScrollingDeltas = false;
out->modifiers &= ~blink::WebInputEvent::ControlKey;
}
#endif
return true;
}

View File

@@ -9,7 +9,6 @@
#include "atom/common/native_mate_converters/gurl_converter.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/values.h"
#include "native_mate/dictionary.h"
@@ -20,6 +19,9 @@
#include "net/cert/x509_certificate.h"
#include "net/http/http_response_headers.h"
#include "net/url_request/url_request.h"
#include "storage/browser/blob/upload_blob_element_reader.h"
#include "atom/common/node_includes.h"
namespace mate {
@@ -95,6 +97,10 @@ void GetUploadData(base::ListValue* upload_data_list,
reader->AsFileReader();
auto file_path = file_reader->path().AsUTF8Unsafe();
upload_data_dict->SetStringWithoutPathExpansion("file", file_path);
} else {
const storage::UploadBlobElementReader* blob_reader =
static_cast<storage::UploadBlobElementReader*>(reader.get());
upload_data_dict->SetString("blobUUID", blob_reader->uuid());
}
upload_data_list->Append(std::move(upload_data_dict));
}

View File

@@ -375,7 +375,7 @@ base::Value* V8ValueConverter::FromNodeBuffer(
FromV8ValueState* state,
v8::Isolate* isolate) const {
return base::BinaryValue::CreateWithCopiedBuffer(
node::Buffer::Data(value), node::Buffer::Length(value));
node::Buffer::Data(value), node::Buffer::Length(value)).release();
}
base::Value* V8ValueConverter::FromV8Object(

View File

@@ -144,8 +144,8 @@ void NodeBindings::Initialize() {
// uv_init overrides error mode to suppress the default crash dialog, bring
// it back if user wants to show it.
std::unique_ptr<base::Environment> env(base::Environment::Create());
if (env->HasVar("ELECTRON_DEFAULT_ERROR_MODE"))
SetErrorMode(0);
if (is_browser_ || env->HasVar("ELECTRON_DEFAULT_ERROR_MODE"))
SetErrorMode(GetErrorMode() & ~SEM_NOGPFAULTERRORBOX);
#endif
}

View File

@@ -117,6 +117,9 @@ const char kDisableBlinkFeatures[] = "disableBlinkFeatures";
namespace switches {
// Enable chromium sandbox.
const char kEnableSandbox[] = "enable-sandbox";
// Enable plugins.
const char kEnablePlugins[] = "enable-plugins";

View File

@@ -67,6 +67,7 @@ extern const char kDisableBlinkFeatures[];
namespace switches {
extern const char kEnableSandbox[];
extern const char kEnablePlugins[];
extern const char kPpapiFlashPath[];
extern const char kPpapiFlashVersion[];

View File

@@ -11,15 +11,13 @@
#include "base/process/launch.h"
#include "url/gurl.h"
#define ELECTRON_TRASH "ELECTRON_TRASH"
#define ELECTRON_DEFAULT_TRASH "gvfs-trash"
namespace {
bool XDGUtil(const std::string& util,
const std::string& arg,
bool XDGUtilV(const std::vector<std::string>& argv,
const bool wait_for_exit) {
std::vector<std::string> argv;
argv.push_back(util);
argv.push_back(arg);
base::LaunchOptions options;
options.allow_new_privs = true;
// xdg-open can fall back on mailcap which eventually might plumb through
@@ -44,6 +42,16 @@ bool XDGUtil(const std::string& util,
return (exit_code == 0);
}
bool XDGUtil(const std::string& util,
const std::string& arg,
const bool wait_for_exit) {
std::vector<std::string> argv;
argv.push_back(util);
argv.push_back(arg);
return XDGUtilV(argv, wait_for_exit);
}
bool XDGOpen(const std::string& path, const bool wait_for_exit) {
return XDGUtil("xdg-open", path, wait_for_exit);
}
@@ -81,7 +89,28 @@ bool OpenExternal(const GURL& url, bool activate) {
}
bool MoveItemToTrash(const base::FilePath& full_path) {
return XDGUtil("gvfs-trash", full_path.value(), true);
std::string trash;
if (getenv(ELECTRON_TRASH) != NULL) {
trash = getenv(ELECTRON_TRASH);
} else {
trash = ELECTRON_DEFAULT_TRASH;
}
std::vector<std::string> argv;
if (trash.compare("kioclient5") == 0 || trash.compare("kioclient") == 0) {
argv.push_back(trash);
argv.push_back("move");
argv.push_back(full_path.value());
argv.push_back("trash:/");
} else if (trash.compare("trash-cli") == 0) {
argv.push_back("trash-put");
argv.push_back(full_path.value());
} else {
argv.push_back(ELECTRON_DEFAULT_TRASH);
argv.push_back(full_path.value());
}
return XDGUtilV(argv, true);
}
void Beep() {

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/renderer/api/atom_api_renderer_ipc.h"
#include "atom/common/api/api_messages.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
@@ -15,7 +16,9 @@ using content::RenderView;
using blink::WebLocalFrame;
using blink::WebView;
namespace {
namespace atom {
namespace api {
RenderView* GetCurrentRenderView() {
WebLocalFrame* frame = WebLocalFrame::frameForCurrentContext();
@@ -69,6 +72,8 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
dict.SetMethod("sendSync", &SendSync);
}
} // namespace
} // namespace api
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_renderer_ipc, Initialize)
} // namespace atom
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_renderer_ipc, atom::api::Initialize)

View File

@@ -0,0 +1,30 @@
// Copyright (c) 2016 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_RENDERER_API_ATOM_API_RENDERER_IPC_H_
#define ATOM_RENDERER_API_ATOM_API_RENDERER_IPC_H_
#include "base/values.h"
#include "native_mate/arguments.h"
namespace atom {
namespace api {
void Send(mate::Arguments* args,
const base::string16& channel,
const base::ListValue& arguments);
base::string16 SendSync(mate::Arguments* args,
const base::string16& channel,
const base::ListValue& arguments);
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv);
} // namespace api
} // namespace atom
#endif // ATOM_RENDERER_API_ATOM_API_RENDERER_IPC_H_

View File

@@ -110,6 +110,10 @@ void WebFrame::AttachGuest(int id) {
content::RenderFrame::FromWebFrame(web_frame_)->AttachGuest(id);
}
void WebFrame::DetachGuest(int id) {
content::RenderFrame::FromWebFrame(web_frame_)->DetachGuest(id);
}
void WebFrame::SetSpellCheckProvider(mate::Arguments* args,
const std::string& language,
bool auto_spell_correct_turned_on,
@@ -202,6 +206,7 @@ void WebFrame::BuildPrototype(
.SetMethod("registerElementResizeCallback",
&WebFrame::RegisterElementResizeCallback)
.SetMethod("attachGuest", &WebFrame::AttachGuest)
.SetMethod("detachGuest", &WebFrame::DetachGuest)
.SetMethod("setSpellCheckProvider", &WebFrame::SetSpellCheckProvider)
.SetMethod("registerURLSchemeAsSecure",
&WebFrame::RegisterURLSchemeAsSecure)

View File

@@ -53,6 +53,7 @@ class WebFrame : public mate::Wrappable<WebFrame> {
int element_instance_id,
const GuestViewContainer::ResizeCallback& callback);
void AttachGuest(int element_instance_id);
void DetachGuest(int element_instance_id);
// Set the provider that will be used by SpellCheckClient for spell check.
void SetSpellCheckProvider(mate::Arguments* args,

View File

@@ -59,9 +59,33 @@ std::vector<v8::Local<v8::Value>> ListValueToVector(
return result;
}
void EmitIPCEvent(blink::WebFrame* frame,
const base::string16& channel,
const base::ListValue& args) {
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),
document_created_(false) {
// Initialise resource for directory listing.
net::NetModule::SetResourceProvider(NetResourceProvider);
}
AtomRenderViewObserver::~AtomRenderViewObserver() {
}
void AtomRenderViewObserver::EmitIPCEvent(blink::WebFrame* frame,
const base::string16& channel,
const base::ListValue& args) {
if (!frame || frame->isWebRemoteFrame())
return;
@@ -87,31 +111,6 @@ void EmitIPCEvent(blink::WebFrame* frame,
}
}
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),
document_created_(false) {
// Initialise resource for directory listing.
net::NetModule::SetResourceProvider(NetResourceProvider);
}
AtomRenderViewObserver::~AtomRenderViewObserver() {
}
void AtomRenderViewObserver::DidCreateDocumentElement(
blink::WebLocalFrame* frame) {
document_created_ = true;
@@ -132,8 +131,9 @@ void AtomRenderViewObserver::DraggableRegionsChanged(blink::WebFrame* frame) {
blink::WebVector<blink::WebDraggableRegion> webregions =
frame->document().draggableRegions();
std::vector<DraggableRegion> regions;
for (const auto& webregion : webregions) {
for (auto& webregion : webregions) {
DraggableRegion region;
render_view()->ConvertViewportToWindowViaWidget(&webregion.bounds);
region.bounds = webregion.bounds;
region.draggable = webregion.draggable;
regions.push_back(region);
@@ -151,6 +151,10 @@ bool AtomRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
return handled;
}
void AtomRenderViewObserver::OnDestruct() {
delete this;
}
void AtomRenderViewObserver::OnBrowserMessage(bool send_to_all,
const base::string16& channel,
const base::ListValue& args) {

View File

@@ -7,6 +7,7 @@
#include "base/strings/string16.h"
#include "content/public/renderer/render_view_observer.h"
#include "third_party/WebKit/public/web/WebFrame.h"
namespace base {
class ListValue;
@@ -24,19 +25,21 @@ class AtomRenderViewObserver : public content::RenderViewObserver {
protected:
virtual ~AtomRenderViewObserver();
virtual void EmitIPCEvent(blink::WebFrame* frame,
const base::string16& channel,
const base::ListValue& args);
private:
// content::RenderViewObserver implementation.
void DidCreateDocumentElement(blink::WebLocalFrame* frame) override;
void DraggableRegionsChanged(blink::WebFrame* frame) override;
bool OnMessageReceived(const IPC::Message& message) override;
void OnDestruct() override;
void OnBrowserMessage(bool send_to_all,
const base::string16& channel,
const base::ListValue& args);
// Weak reference to renderer client.
AtomRendererClient* renderer_client_;
// Whether the document object has been created.
bool document_created_;

View File

@@ -13,9 +13,9 @@
#include "atom/common/color_util.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_bindings.h"
#include "atom/common/node_includes.h"
#include "atom/common/options_switches.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/node_array_buffer_bridge.h"
#include "atom/renderer/preferences_manager.h"
@@ -51,6 +51,8 @@
#include <shlobj.h>
#endif
#include "atom/common/node_includes.h"
namespace atom {
namespace {
@@ -85,6 +87,10 @@ class AtomRenderFrameObserver : public content::RenderFrameObserver {
renderer_client_->WillReleaseScriptContext(context, render_frame_);
}
void OnDestruct() override {
delete this;
}
private:
content::RenderFrame* render_frame_;
int world_id_;
@@ -171,6 +177,7 @@ void AtomRendererClient::RenderFrameCreated(
content::RenderFrame* render_frame) {
new PepperHelper(render_frame);
new AtomRenderFrameObserver(render_frame, this);
new ContentSettingsObserver(render_frame);
// Allow file scheme to handle service worker by default.
// FIXME(zcbenz): Can this be moved elsewhere?
@@ -261,7 +268,7 @@ void AtomRendererClient::DidCreateScriptContext(
// Setup node environment for each window.
node::Environment* env = node_bindings_->CreateEnvironment(context);
// Add atom-shell extended APIs.
// Add Electron extended APIs.
atom_bindings_->BindTo(env->isolate(), env->process_object());
AddRenderBindings(env->isolate(), env->process_object(),
preferences_manager_.get());

View File

@@ -0,0 +1,201 @@
// Copyright (c) 2016 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/renderer/atom_sandboxed_renderer_client.h"
#include <string>
#include "atom_natives.h" // NOLINT: This file is generated with js2c
#include "atom/common/api/api_messages.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/options_switches.h"
#include "atom/renderer/api/atom_api_renderer_ipc.h"
#include "atom/renderer/atom_render_view_observer.h"
#include "base/command_line.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_frame_observer.h"
#include "content/public/renderer/render_view.h"
#include "content/public/renderer/render_view_observer.h"
#include "ipc/ipc_message_macros.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/WebScriptSource.h"
#include "third_party/WebKit/public/web/WebView.h"
namespace atom {
namespace {
const std::string kBindingKey = "binding";
class AtomSandboxedRenderFrameObserver : public content::RenderFrameObserver {
public:
AtomSandboxedRenderFrameObserver(content::RenderFrame* frame,
AtomSandboxedRendererClient* renderer_client)
: content::RenderFrameObserver(frame),
render_frame_(frame),
world_id_(-1),
renderer_client_(renderer_client) {}
// content::RenderFrameObserver:
void DidClearWindowObject() override {
// Make sure every page will get a script context created.
render_frame_->GetWebFrame()->executeScript(
blink::WebScriptSource("void 0"));
}
void DidCreateScriptContext(v8::Handle<v8::Context> context,
int extension_group,
int world_id) override {
if (world_id_ != -1 && world_id_ != world_id)
return;
world_id_ = world_id;
renderer_client_->DidCreateScriptContext(context, render_frame_);
}
void WillReleaseScriptContext(v8::Local<v8::Context> context,
int world_id) override {
if (world_id_ != world_id)
return;
renderer_client_->WillReleaseScriptContext(context, render_frame_);
}
void OnDestruct() override {
delete this;
}
private:
content::RenderFrame* render_frame_;
int world_id_;
AtomSandboxedRendererClient* renderer_client_;
DISALLOW_COPY_AND_ASSIGN(AtomSandboxedRenderFrameObserver);
};
class AtomSandboxedRenderViewObserver : public AtomRenderViewObserver {
public:
AtomSandboxedRenderViewObserver(content::RenderView* render_view,
AtomSandboxedRendererClient* renderer_client)
: AtomRenderViewObserver(render_view, nullptr),
renderer_client_(renderer_client) {
}
protected:
void EmitIPCEvent(blink::WebFrame* frame,
const base::string16& channel,
const base::ListValue& args) override {
if (!frame || frame->isWebRemoteFrame())
return;
auto isolate = blink::mainThreadIsolate();
v8::HandleScope handle_scope(isolate);
auto context = frame->mainWorldScriptContext();
v8::Context::Scope context_scope(context);
v8::Local<v8::Value> argv[] = {
mate::ConvertToV8(isolate, channel),
mate::ConvertToV8(isolate, args)
};
renderer_client_->InvokeBindingCallback(
context,
"onMessage",
std::vector<v8::Local<v8::Value>>(argv, argv + 2));
}
private:
AtomSandboxedRendererClient* renderer_client_;
DISALLOW_COPY_AND_ASSIGN(AtomSandboxedRenderViewObserver);
};
} // namespace
AtomSandboxedRendererClient::AtomSandboxedRendererClient() {
}
AtomSandboxedRendererClient::~AtomSandboxedRendererClient() {
}
void AtomSandboxedRendererClient::RenderFrameCreated(
content::RenderFrame* render_frame) {
new AtomSandboxedRenderFrameObserver(render_frame, this);
}
void AtomSandboxedRendererClient::RenderViewCreated(
content::RenderView* render_view) {
new AtomSandboxedRenderViewObserver(render_view, this);
}
void AtomSandboxedRendererClient::DidCreateScriptContext(
v8::Handle<v8::Context> context, content::RenderFrame* render_frame) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
std::string preload_script = command_line->GetSwitchValueASCII(
switches::kPreloadScript);
if (preload_script.empty())
return;
auto isolate = context->GetIsolate();
v8::HandleScope handle_scope(isolate);
v8::Context::Scope context_scope(context);
// Wrap the bundle into a function that receives the binding object and the
// preload script path as arguments.
std::string preload_bundle_native(node::preload_bundle_native,
node::preload_bundle_native + sizeof(node::preload_bundle_native));
std::stringstream ss;
ss << "(function(binding, preloadPath) {\n";
ss << preload_bundle_native << "\n";
ss << "})";
std::string preload_wrapper = ss.str();
// Compile the wrapper and run it to get the function object
auto script = v8::Script::Compile(
mate::ConvertToV8(isolate, preload_wrapper)->ToString());
auto func = v8::Handle<v8::Function>::Cast(
script->Run(context).ToLocalChecked());
// Create and initialize the binding object
auto binding = v8::Object::New(isolate);
api::Initialize(binding, v8::Null(isolate), context, nullptr);
v8::Local<v8::Value> args[] = {
binding,
mate::ConvertToV8(isolate, preload_script)
};
// Execute the function with proper arguments
ignore_result(func->Call(context, v8::Null(isolate), 2, args));
// Store the bindingt privately for handling messages from the main process.
auto binding_key = mate::ConvertToV8(isolate, kBindingKey)->ToString();
auto private_binding_key = v8::Private::ForApi(isolate, binding_key);
context->Global()->SetPrivate(context, private_binding_key, binding);
}
void AtomSandboxedRendererClient::WillReleaseScriptContext(
v8::Handle<v8::Context> context, content::RenderFrame* render_frame) {
auto isolate = context->GetIsolate();
v8::HandleScope handle_scope(isolate);
v8::Context::Scope context_scope(context);
InvokeBindingCallback(context, "onExit", std::vector<v8::Local<v8::Value>>());
}
void AtomSandboxedRendererClient::InvokeBindingCallback(
v8::Handle<v8::Context> context,
std::string callback_name,
std::vector<v8::Handle<v8::Value>> args) {
auto isolate = context->GetIsolate();
auto binding_key = mate::ConvertToV8(isolate, kBindingKey)->ToString();
auto private_binding_key = v8::Private::ForApi(isolate, binding_key);
auto global_object = context->Global();
v8::Local<v8::Value> value;
if (!global_object->GetPrivate(context, private_binding_key).ToLocal(&value))
return;
if (value.IsEmpty() || !value->IsObject())
return;
auto binding = value->ToObject();
auto callback_key = mate::ConvertToV8(isolate, callback_name)->ToString();
auto callback_value = binding->Get(callback_key);
DCHECK(callback_value->IsFunction()); // set by sandboxed_renderer/init.js
auto callback = v8::Handle<v8::Function>::Cast(callback_value);
ignore_result(callback->Call(context, binding, args.size(), &args[0]));
}
} // namespace atom

View File

@@ -0,0 +1,37 @@
// Copyright (c) 2016 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_RENDERER_ATOM_SANDBOXED_RENDERER_CLIENT_H_
#define ATOM_RENDERER_ATOM_SANDBOXED_RENDERER_CLIENT_H_
#include <string>
#include <vector>
#include "content/public/renderer/content_renderer_client.h"
#include "content/public/renderer/render_frame.h"
namespace atom {
class AtomSandboxedRendererClient : public content::ContentRendererClient {
public:
AtomSandboxedRendererClient();
virtual ~AtomSandboxedRendererClient();
void DidCreateScriptContext(
v8::Handle<v8::Context> context, content::RenderFrame* render_frame);
void WillReleaseScriptContext(
v8::Handle<v8::Context> context, content::RenderFrame* render_frame);
void InvokeBindingCallback(v8::Handle<v8::Context> context,
std::string callback_name,
std::vector<v8::Handle<v8::Value>> args);
// content::ContentRendererClient:
void RenderFrameCreated(content::RenderFrame*) override;
void RenderViewCreated(content::RenderView*) override;
private:
DISALLOW_COPY_AND_ASSIGN(AtomSandboxedRendererClient);
};
} // namespace atom
#endif // ATOM_RENDERER_ATOM_SANDBOXED_RENDERER_CLIENT_H_

View File

@@ -0,0 +1,65 @@
// Copyright (c) 2016 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/renderer/content_settings_observer.h"
#include "content/public/renderer/render_frame.h"
#include "third_party/WebKit/public/platform/URLConversion.h"
#include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
namespace atom {
ContentSettingsObserver::ContentSettingsObserver(
content::RenderFrame* render_frame)
: content::RenderFrameObserver(render_frame) {
render_frame->GetWebFrame()->setContentSettingsClient(this);
}
ContentSettingsObserver::~ContentSettingsObserver() {
}
bool ContentSettingsObserver::allowDatabase(
const blink::WebString& name,
const blink::WebString& display_name,
unsigned estimated_size) {
blink::WebFrame* frame = render_frame()->GetWebFrame();
if (frame->getSecurityOrigin().isUnique() ||
frame->top()->getSecurityOrigin().isUnique())
return false;
auto origin = blink::WebStringToGURL(frame->getSecurityOrigin().toString());
if (!origin.IsStandard())
return false;
return true;
}
bool ContentSettingsObserver::allowStorage(bool local) {
blink::WebFrame* frame = render_frame()->GetWebFrame();
if (frame->getSecurityOrigin().isUnique() ||
frame->top()->getSecurityOrigin().isUnique())
return false;
auto origin = blink::WebStringToGURL(frame->getSecurityOrigin().toString());
if (!origin.IsStandard())
return false;
return true;
}
bool ContentSettingsObserver::allowIndexedDB(
const blink::WebString& name,
const blink::WebSecurityOrigin& security_origin) {
blink::WebFrame* frame = render_frame()->GetWebFrame();
if (frame->getSecurityOrigin().isUnique() ||
frame->top()->getSecurityOrigin().isUnique())
return false;
auto origin = blink::WebStringToGURL(frame->getSecurityOrigin().toString());
if (!origin.IsStandard())
return false;
return true;
}
void ContentSettingsObserver::OnDestruct() {
delete this;
}
} // namespace atom

View File

@@ -0,0 +1,37 @@
// Copyright (c) 2016 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_RENDERER_CONTENT_SETTINGS_OBSERVER_H_
#define ATOM_RENDERER_CONTENT_SETTINGS_OBSERVER_H_
#include "base/compiler_specific.h"
#include "content/public/renderer/render_frame_observer.h"
#include "third_party/WebKit/public/web/WebContentSettingsClient.h"
namespace atom {
class ContentSettingsObserver : public content::RenderFrameObserver,
public blink::WebContentSettingsClient {
public:
explicit ContentSettingsObserver(content::RenderFrame* render_frame);
~ContentSettingsObserver() override;
// blink::WebContentSettingsClient implementation.
bool allowDatabase(const blink::WebString& name,
const blink::WebString& display_name,
unsigned estimated_size) override;
bool allowStorage(bool local) override;
bool allowIndexedDB(const blink::WebString& name,
const blink::WebSecurityOrigin& security_origin) override;
private:
// content::RenderFrameObserver implementation.
void OnDestruct() override;
DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver);
};
} // namespace atom
#endif // ATOM_RENDERER_CONTENT_SETTINGS_OBSERVER_H_

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