Compare commits

...

501 Commits

Author SHA1 Message Date
Cheng Zhao
a16ea1fbf2 Bump v0.11.8. 2014-04-10 07:30:29 +00:00
Cheng Zhao
f0d9ee4ca9 Shutdown gracefully, fixes #227. 2014-04-10 15:22:17 +08:00
Cheng Zhao
538bd1116d Deprecate app.terminate API.
Users should use app.quit which can shutdown the application gracefuly.
2014-04-10 15:08:14 +08:00
Cheng Zhao
5ead4f655a Bump v0.11.7. 2014-04-08 06:50:40 +00:00
Cheng Zhao
b975d4c41f Detect unresponsive window when quitting.
Preivously this is disabled because quitting multiple windows could
bring up the unresponsive dialog, but since we now have increased the
unresponsive time limitto 5s, this is not needed anymore and could cause
confusions.

Fixes #17.
2014-04-08 14:24:44 +08:00
Cheng Zhao
cca0d8d583 📝 Add docs for executeJavaScriptInDevTools. 2014-04-08 12:52:42 +08:00
Cheng Zhao
d7a54cf3a6 Add API to execute javascript in devtools. 2014-04-08 12:50:12 +08:00
Cheng Zhao
a50d3bde5c gtk: Connect to window-state-event, fixes #226. 2014-04-08 09:32:44 +08:00
Cheng Zhao
7f496f1994 Bump v0.11.6. 2014-04-07 09:21:02 +00:00
Cheng Zhao
395eb067d1 mac: Do not destroy window immediately.
Fixes atom/atom#1841.
2014-04-07 17:20:08 +08:00
Cheng Zhao
98fcc93862 💄 Remove unsed constant. 2014-04-07 17:12:24 +08:00
Cheng Zhao
b21e5a6300 Fix capturePage under accelerated mode, fixes #223. 2014-04-07 15:43:15 +08:00
Cheng Zhao
ac11c95da6 Increase the closing time limit to 5s.
Fixes https://github.com/atom/atom/issues/1838.
2014-04-06 13:16:14 +08:00
Cheng Zhao
5bbf749693 gtk: Handle accelerators after renderer handled them.
The key-press signal captured the key events before renderer handles,
which violated the behavior on OS X and Windows.

Fixes #221.
2014-04-05 19:21:18 +08:00
Cheng Zhao
3d518c2105 gtk: Do not access clipboard in renderer process. 2014-04-05 14:49:59 +08:00
Cheng Zhao
839f875045 Merge pull request #225 from atom/devtools-menu
Enable context menu in devtools
2014-04-05 03:30:47 +00:00
Cheng Zhao
2369f6cc41 Don't build symbols in CI. 2014-04-05 11:05:51 +08:00
Cheng Zhao
ff88535cd5 💄 Fix cpplint warning build/include_what_you_use. 2014-04-05 11:00:35 +08:00
Cheng Zhao
7a38307d1f Use dialog API to override file chooser dialog in web inspector. 2014-04-05 10:24:46 +08:00
Cheng Zhao
877277d837 Enable writing files in devtools. 2014-04-05 09:22:25 +08:00
Cheng Zhao
d4e7fe3eb8 Correctly translate WebInspector menu to native menu. 2014-04-04 22:37:34 +08:00
Cheng Zhao
03e6d564d7 Make remote.getCurrentWindow work for devtools. 2014-04-04 22:28:47 +08:00
Cheng Zhao
f5fc26d8fc Enable getting a window according to its attached devtools. 2014-04-04 22:28:18 +08:00
Cheng Zhao
86ebd6e8e3 Allow sending ipc messages to devtools. 2014-04-04 22:05:43 +08:00
Cheng Zhao
a80fe40f56 Synchronous event should be bound to WebContents.
This allows us to reply to synchronous message for arbitrary
WebContents.
2014-04-04 22:04:42 +08:00
Cheng Zhao
b1f0c2d174 Override web inspector's context menu. 2014-04-03 20:54:42 +08:00
Cheng Zhao
ac794c8085 Enable intercepting devtools window. 2014-04-03 20:20:42 +08:00
Cheng Zhao
663ab8e0bf 💄 Fix cpplint warning. 2014-04-02 14:23:38 +08:00
Cheng Zhao
d2162bf9f4 Bump v0.11.5. 2014-04-02 09:59:21 +08:00
Cheng Zhao
b7a71b885e Make sure tags are pushed. 2014-04-02 09:58:56 +08:00
Cheng Zhao
9aefb9c2d3 Add /vendor/npm to gitignore. 2014-04-02 09:58:38 +08:00
Cheng Zhao
a3e1fa3350 gtk: Consider window frame in SetSize. 2014-03-29 16:07:44 +08:00
Cheng Zhao
bf6fb3872e gtk: Do some guess of window border size according to window manager. 2014-03-29 14:18:47 +08:00
Cheng Zhao
84307dd329 gtk: Fix crash when calling GetSize() for hidden window. 2014-03-29 14:08:25 +08:00
Cheng Zhao
c814803c94 💄 2014-03-28 09:42:37 +00:00
Cheng Zhao
61d54f0558 Make bootstrap script silent. 2014-03-28 09:36:35 +00:00
Cheng Zhao
9d0a11580f Fix calling apm for apm 0.37.0. 2014-03-28 09:30:15 +00:00
Cheng Zhao
7a6db019e8 Use lastes npm in CI. 2014-03-28 09:25:53 +00:00
Cheng Zhao
fdecf09d99 Upgrade to apm@0.37.0 2014-03-28 16:19:19 +08:00
Cheng Zhao
7e7f0888e5 gtk: Force size allocation in window, fixes #219. 2014-03-28 16:01:38 +08:00
Cheng Zhao
5a837f5850 gtk: Detect rare conditions when resizing. 2014-03-27 21:03:27 +08:00
Cheng Zhao
d3e6166de6 gtk: Should remove self from watcher list in destructor. 2014-03-27 18:05:28 +08:00
Cheng Zhao
c6f0968d17 gtk: Do not count menubar in work area size on Unity. 2014-03-27 17:55:28 +08:00
Cheng Zhao
abea550a4d Bump v0.11.4. 2014-03-26 02:16:32 +00:00
Cheng Zhao
d7261073e7 Free window object immediately in destory().
This put everything back to the original design, since now it's not
possible to destory a window while a context menu is showing.
2014-03-26 09:58:40 +08:00
Cheng Zhao
01a9ac21a5 Increase unresponsive time to 2s when closing.
Fixes https://github.com/atom/atom/issues/1793.
2014-03-26 09:40:53 +08:00
Cheng Zhao
8b41e78245 Fix a possible crash when destroying window.
It could happend that the JS BrowserWindow object being double deleted
when calling the destroy() method.
2014-03-26 09:14:05 +08:00
Cheng Zhao
9ab3b5293c Bump v0.11.3. 2014-03-25 10:18:53 +00:00
Cheng Zhao
7a83b16cc4 Delay the unresponsive event shortly.
It could happen that a window became responsive immediately after the
unresponsive message is sent, like after showing a context menu
synchronously.
2014-03-25 18:10:51 +08:00
Cheng Zhao
679959eeb5 BrowserWindow.destroy() should not delete window immediately.
It could cause crash when context menu is showing.
2014-03-25 17:00:03 +08:00
Cheng Zhao
e96a3abdf9 mac: Do not allow nested task when showing menu.
Fixes #163.
2014-03-25 16:56:02 +08:00
Cheng Zhao
788ed588c9 Bump v0.11.2. 2014-03-21 07:04:55 +00:00
Cheng Zhao
35229255bb gtk: Ask whether window is active from WM.
It could happpen that the WM thinks a window is active but it's actually not,
like when showing a context menu. In most cases we should follow what WM
says to keep consistent bevaviour on all platforms.
2014-03-20 17:47:38 +08:00
Cheng Zhao
f4b648385c Close devtools completely instead of hiding it.
Fixes https://github.com/atom/atom/issues/1764.
2014-03-20 09:32:00 +08:00
Cheng Zhao
eb1675a90f Update node: Build .dSYM for node modules, fixes #207. 2014-03-20 09:02:36 +08:00
Cheng Zhao
f7854e0b4c Bump v0.11.1. 2014-03-15 09:33:15 -07:00
Cheng Zhao
630e1b54e8 gtk: Fix BrowserWindow::HasModalDialog. 2014-03-18 14:52:45 +08:00
Cheng Zhao
1740355855 linux: Include content_shell.pak in distribution. 2014-03-18 14:10:35 +08:00
Cheng Zhao
239f061ffd Bump v0.11.0. 2014-03-16 19:06:46 +08:00
Cheng Zhao
5402b1b432 Should set low version field to 0 in bump-version. 2014-03-16 19:06:36 +08:00
Cheng Zhao
83ff6b607f Fix bump-version script. 2014-03-16 15:49:12 +08:00
Cheng Zhao
caa553c563 Merge pull request #216 from atom/atom-chrome-src
Put atom-shell's source code under atom/
2014-03-16 07:37:14 +00:00
Cheng Zhao
e3434b5cde Fix the location default_app is copied to. 2014-03-16 15:19:09 +08:00
Cheng Zhao
5dd5f18edf Fix process.resourcesPath. 2014-03-16 13:24:25 +08:00
Cheng Zhao
6285e26972 Fix coffeelint. 2014-03-16 09:43:19 +08:00
Cheng Zhao
b6ac06c022 Order header files. 2014-03-16 09:37:04 +08:00
Cheng Zhao
375228f266 💄 Update bootstrap script. 2014-03-16 09:27:15 +08:00
Cheng Zhao
eaab9b295b 📝 Update docs for new source code structure. 2014-03-16 09:17:45 +08:00
Cheng Zhao
b1f4a47b5b Add LICENSE in chrome/. 2014-03-16 09:15:41 +08:00
Cheng Zhao
2d808d30a2 Bring back build/include_order cpplint. 2014-03-16 09:13:06 +08:00
Cheng Zhao
bbef33a33a Bring back build/header_guard cpplint. 2014-03-16 08:58:59 +08:00
Cheng Zhao
68cb6ee861 Move atom/browser/ui/gtk to chrome/. 2014-03-16 08:39:43 +08:00
Cheng Zhao
516d46444d Move all sources under atom/. 2014-03-16 08:30:26 +08:00
Cheng Zhao
26ddbbb0ee Remove unneeded include dir. 2014-03-15 22:57:35 +08:00
Cheng Zhao
467b9122e9 Merge pull request #215 from atom/first-mouse-event
Add 'accept-first-mouse' to BrowserWindow's creation option
2014-03-15 14:37:22 +00:00
Cheng Zhao
cdf6f3ade9 📝 Add 'accept-first-mouse' to docs. 2014-03-15 19:31:29 +08:00
Cheng Zhao
b1bb4d911f Add 'accept-first-mouse' in window's option. 2014-03-15 19:28:23 +08:00
Cheng Zhao
834d02d65b Upgrade libchromiumcontent: Add support for acceptsFirstMouse. 2014-03-15 19:10:24 +08:00
Cheng Zhao
47b1a90dd7 Remove hack for using foundation_util.h. 2014-03-15 18:18:19 +08:00
Cheng Zhao
66fe74de29 Merge pull request #214 from atom/linux-menu
Implement menu API on Linux
2014-03-15 09:43:59 +00:00
Cheng Zhao
60b686ff51 gtk: Fix crash when using frameless window. 2014-03-15 17:07:44 +08:00
Cheng Zhao
ef4fb8bfe0 💄 Fix cpplint warning. 2014-03-15 16:41:31 +08:00
Cheng Zhao
e3a3c342de Separate common accelerator utils out. 2014-03-15 16:36:29 +08:00
Cheng Zhao
5e2c975758 gtk: Make menubar accelerator work. 2014-03-15 16:16:12 +08:00
Cheng Zhao
c88673d6ba Fix the menu of default_app. 2014-03-14 21:45:53 +08:00
Cheng Zhao
23ebfa2955 gtk: Enabling setting menubar for window. 2014-03-14 21:44:09 +08:00
Cheng Zhao
4e4e0f5d4d gtk: Enable creating menu bar. 2014-03-14 21:13:28 +08:00
Cheng Zhao
6939e325df gtk: Implement popup menu. 2014-03-14 20:59:11 +08:00
Cheng Zhao
a941c20af4 gtk: Add menu_gtk from Chromium. 2014-03-14 20:42:39 +08:00
Cheng Zhao
cde4017c7b gtk: Add event_utils from Chromium. 2014-03-14 20:23:17 +08:00
Cheng Zhao
af301e682e Merge pull request #213 from atom/linux-open-dialog
Implement file dialog API on Linux
2014-03-13 08:34:19 +00:00
Cheng Zhao
09ebabfc45 📝 Revise the build instructions on Linux. 2014-03-13 14:20:48 +08:00
Cheng Zhao
6248aeb1ea 📝 Revise the dialog API docs. 2014-03-13 14:09:30 +08:00
Cheng Zhao
6fe9d0fdc5 gtk: Implement synchronous open dialog. 2014-03-13 14:01:34 +08:00
Cheng Zhao
b3f9a36a77 gtk: Add file open dialog. 2014-03-13 13:58:53 +08:00
Cheng Zhao
4c63307ae7 gtk: Enable create folder in dialog. 2014-03-13 13:27:01 +08:00
Cheng Zhao
637a99ea66 gtk: Filename returned by GTK+ should be freed. 2014-03-13 13:22:49 +08:00
Cheng Zhao
434065bcdf gtk: Confirm file overwrite. 2014-03-13 13:20:43 +08:00
Cheng Zhao
52958d5d3f gtk: Implement synchronous save dialog. 2014-03-13 13:17:03 +08:00
Cheng Zhao
516551623a gtk: Set default path. 2014-03-13 13:10:13 +08:00
Cheng Zhao
be28ffa028 gtk: File dialog should be modal window. 2014-03-13 13:03:38 +08:00
Cheng Zhao
c2cff39bc5 gtk: Initial implementation of save dialog. 2014-03-13 12:58:27 +08:00
Cheng Zhao
1ebbf32f29 Merge pull request #211 from atom/linux-message-box
Implement message box API on Linux
2014-03-12 13:37:20 +00:00
Cheng Zhao
7c3ac01fd3 💄 Fix pylint warning. 2014-03-12 21:25:13 +08:00
Cheng Zhao
676a48ae28 gtk: Make synchronous message box work. 2014-03-12 21:17:13 +08:00
Cheng Zhao
5f215cfa6b gtk: Be aware of "Cancel" button in message box. 2014-03-12 21:10:00 +08:00
Cheng Zhao
4d175b8f81 gtk: Make the message box asynchronous. 2014-03-12 21:01:04 +08:00
Cheng Zhao
df692f164c gtk: Left align message box text. 2014-03-12 20:39:04 +08:00
Cheng Zhao
e30fef09c8 gtk: Add gtk_util from Chromium. 2014-03-12 20:38:52 +08:00
Cheng Zhao
6b9148127e gtk: Initial implementation of message box. 2014-03-12 20:17:22 +08:00
Cheng Zhao
63ed4acd49 Bump v0.10.7. 2014-03-11 09:54:05 +00:00
Cheng Zhao
99ee21d657 linux: Generate symbols from the symbol file. 2014-03-11 09:04:41 +00:00
Cheng Zhao
449748b044 Remove vendor/apm/node_modules in cibuild. 2014-03-11 00:01:06 +08:00
Cheng Zhao
1019952989 Merge pull request #208 from atom/default-sandboxed-iframe
Make iframe sandboxed by default
2014-03-10 15:47:39 +00:00
Cheng Zhao
1c057c8ea1 Update libchromiumcontent for iframe sandbox. 2014-03-10 22:47:21 +08:00
Cheng Zhao
89507a2524 💄 Remove console output. 2014-03-10 22:46:15 +08:00
Cheng Zhao
31b08a3ec6 Update specs with new sandbox setting. 2014-03-10 22:42:03 +08:00
Cheng Zhao
b96aee50e1 📝 Mention that iframe is sandboxed by default. 2014-03-10 22:33:34 +08:00
Cheng Zhao
337e9f9553 Fixes crash caused by NativeWindow::IsWebViewFocused.
The RenderViewHostView could be NULL when the renderer process has
crashed.

Fixes #206.
2014-03-10 09:24:51 +08:00
Cheng Zhao
3260b42b18 Bump v0.10.6. 2014-03-05 04:43:45 -08:00
Cheng Zhao
f9c5d0796c Merge pull request #202 from atom/fix-acclerated-composition
Enable accelerated composition in normal window
2014-03-06 04:25:43 +00:00
Cheng Zhao
2f113286aa Disable acclerated composition in frameless window. 2014-03-06 11:07:04 +08:00
Cheng Zhao
686493e8ec Append command line for renderer in NativeWindow. 2014-03-06 10:40:10 +08:00
Cheng Zhao
1b3e6bdb92 Bring back accelerated composition. 2014-03-06 10:30:42 +08:00
Cheng Zhao
0fe65a688e Temporary fix for flashing devtools. 2014-03-06 10:30:22 +08:00
Cheng Zhao
377666503c Bump v0.10.5. 2014-03-01 14:05:02 -08:00
Cheng Zhao
0411c2d2b6 Do not rely on thread to implement modal dialog.
Fixes #199.
2014-03-05 20:02:15 +08:00
Cheng Zhao
839a751de5 Add 'activate-with-no-open-windows' event for app.
Fixes #194.
2014-03-05 18:09:44 +08:00
Cheng Zhao
a74d3d210d Merge pull request #196 from atom/iframe-security
Fix iframe security
2014-03-04 14:12:26 +00:00
Cheng Zhao
df86c9dac1 Add spec for sanbox attribute of iframe. 2014-03-04 22:04:41 +08:00
Cheng Zhao
e3d67a304f 📝 Notice on sandbox attribute. 2014-03-04 21:44:15 +08:00
Cheng Zhao
77253abbd7 📝 Mention the change of default security of node integration. 2014-03-04 21:25:43 +08:00
Cheng Zhao
013a7717b4 Enable web security. 2014-03-04 21:23:18 +08:00
Cheng Zhao
aae4abfa86 Use except-iframe security by default. 2014-03-04 20:12:43 +08:00
Cheng Zhao
abc6e1e289 Merge pull request #195 from atom/undocked-devtools
Disable the detachment of devtools
2014-03-04 12:08:26 +00:00
Cheng Zhao
dc154f3907 Disable the detachment of devtools. 2014-03-04 19:59:25 +08:00
Cheng Zhao
9f86fa1893 Correctly free devtools window. 2014-03-04 19:02:48 +08:00
Cheng Zhao
01b42c9e59 Make devtools API aware of devtools window. 2014-03-04 18:45:36 +08:00
Cheng Zhao
6bd0b82b2e Store the devtools window in weak pointer. 2014-03-04 18:42:37 +08:00
Cheng Zhao
391468ece0 Make DevToolsDelegate respond to messages. 2014-03-04 17:50:57 +08:00
Cheng Zhao
5e05a3045c Use InspectableWebContentsDelegate. 2014-03-04 17:08:30 +08:00
Cheng Zhao
c2996d4fd1 Take control if devtools is undocked. 2014-03-04 15:46:12 +08:00
Cheng Zhao
d37bf06b5a Make the DebugDevTools API more generic. 2014-03-04 14:35:35 +08:00
Cheng Zhao
1c07235121 Disable the undocked devtools. 2014-03-04 14:25:15 +08:00
Cheng Zhao
59a2430f1d Merge pull request #191 from atom/win-ci
Try fix Windows CI
2014-03-03 12:47:03 +00:00
Cheng Zhao
87221f8f55 💄 Fix pylint warning. 2014-03-03 20:03:37 +08:00
Cheng Zhao
e3215a1f21 Update to latest apm. 2014-03-03 19:57:08 +08:00
Cheng Zhao
2522bc2298 Fix calling node in coffeelint. 2014-03-03 19:50:32 +08:00
Cheng Zhao
f3103e9b00 Merge pull request #189 from atom/linux-symbols
Dump breakpad symbols on Linux
2014-03-03 11:45:45 +00:00
Cheng Zhao
e897377879 win: Disable pylint in cibuildbuild. 2014-03-03 11:31:45 +00:00
Cheng Zhao
6833865ff3 Update libchromiumcontent: Contain linux symbols. 2014-03-03 11:12:22 +00:00
Cheng Zhao
88dde07bf1 Make sure we dump symbols before stripping binary. 2014-03-03 14:17:48 +08:00
Cheng Zhao
51f0090555 Make sure symbol is dumped from unstripped binary. 2014-03-03 14:14:02 +08:00
Cheng Zhao
b8e75df8f0 linux: Add strip binary action. 2014-03-03 12:55:04 +08:00
Cheng Zhao
de21a164ea Build with -g on Linux. 2014-03-03 12:35:52 +08:00
Cheng Zhao
95e1ea6599 Move the generate_breakpad_symbols to tools/posix. 2014-03-03 10:15:19 +08:00
Cheng Zhao
2d2fbaaa4a linux: Dump symbols in create-dist.py. 2014-03-03 09:44:16 +08:00
Cheng Zhao
7cfff62037 Bump v0.10.4. 2014-03-01 06:54:22 -08:00
Cheng Zhao
d61daf6f05 Update node: Fix crash from UVException. 2014-03-02 10:38:56 +08:00
Cheng Zhao
eca911a1b1 Update libchromiumcontent: Suppress CFAllocator warning. 2014-03-01 23:00:47 +08:00
Cheng Zhao
0a5a020466 Merge pull request #188 from atom/old-fasioned-dialog
Implement alert() and confirm() with dialog API
2014-03-01 13:32:02 +00:00
Cheng Zhao
79802c2919 Explicitly disable prompt(). 2014-03-01 20:05:52 +08:00
Cheng Zhao
3f1d540077 Implement the confirm(). 2014-03-01 20:03:49 +08:00
Cheng Zhao
ff9027fa95 Use the dialog API to implement alert(). 2014-03-01 20:01:04 +08:00
Cheng Zhao
753a1e7aff Separate overrides from init script. 2014-03-01 20:00:39 +08:00
Cheng Zhao
4c8e483bc1 Make the default alert() do nothing. 2014-03-01 19:53:50 +08:00
Cheng Zhao
8404389a31 Rename no-publish-release to publish-release. 2014-03-01 09:36:48 +08:00
Cheng Zhao
f8d6fab52b Do not publish release by default. 2014-02-28 20:45:45 +08:00
Cheng Zhao
199e975a11 Remove unused -s option of bootstrap. 2014-02-28 20:44:57 +08:00
Cheng Zhao
32f83d8e4e Bump v0.10.3. 2014-02-27 00:32:05 -08:00
Cheng Zhao
6ae3402aec Update node: Fix wrong uv error code. 2014-02-28 00:34:47 +08:00
Cheng Zhao
21ccf80ba5 Bump v0.10.2. 2014-02-24 14:25:29 -08:00
Cheng Zhao
706c56bb30 Update node: Fix crash from node::uv::ErrName. 2014-02-27 14:12:10 +08:00
Cheng Zhao
c98e16b18f Do not dectect unresponsive eagerly when quitting.
Fixes https://github.com/atom/atom/issues/1589.
2014-02-27 12:47:00 +08:00
Cheng Zhao
b386ec40be Fix crash caused by Protocol::RegisterProtocol.
From crash report this exists on OS X too, previously the fix is only
available on Linux. However we should remove all calls of protocol
things in UI thread in future.
2014-02-27 10:44:45 +08:00
Cheng Zhao
14cec9e20e Merge pull request #180 from atom/linux-breakpad
Make crash reporter work on Linux
2014-02-26 14:16:52 +00:00
Cheng Zhao
120094a81e Only print when got error for some commands. 2014-02-26 22:08:01 +08:00
Cheng Zhao
637b50044d Do not use "/" explicitly in cpplint. 2014-02-26 21:51:37 +08:00
Cheng Zhao
acef33aa2c 💄 Fix cpplint warnings. 2014-02-26 21:47:52 +08:00
Cheng Zhao
6134b9ed38 linux: Remove global variables in crash reporter. 2014-02-26 21:33:14 +08:00
Cheng Zhao
ce6f9f20bf linux: No need of |ptype| parameter. 2014-02-26 20:59:27 +08:00
Cheng Zhao
b1f9c4dfc5 Only start crash service on Windows. 2014-02-26 20:58:17 +08:00
Cheng Zhao
7660816468 linux: Set upload parameters of crash reporter. 2014-02-26 20:54:56 +08:00
Cheng Zhao
1a43ec3557 💄 Remove dead code. 2014-02-26 20:41:59 +08:00
Cheng Zhao
4a3341e31e linux: Implement crash reporter. 2014-02-26 20:39:20 +08:00
Cheng Zhao
2f088c5caa linux: Suppress compiler warnings of breakpad. 2014-02-26 15:43:22 +08:00
Cheng Zhao
38810c5518 linux: Add the missing lss dependency.
Chromium ships with it in its code base, but since libchromiumcontent
doesn't contain it in the distribution, we need to include it herer to
make breakpad_client compile.

Note that we put the header under `vendor/third_party/lss` instead of
checking out the repository under `vendor`, because we don't want to
patch breakpad.
2014-02-26 15:38:28 +08:00
Cheng Zhao
876bfc69ac linux: Link with breakpad_client. 2014-02-26 15:20:57 +08:00
Cheng Zhao
2ce1d3a784 Fix building on cygwin. 2014-02-25 19:06:15 +08:00
Cheng Zhao
a81ef7847d Bump v0.10.1. 2014-02-25 19:02:12 +08:00
Cheng Zhao
2117d06274 Disable in process stack dumping on Windows.
It would force the process to run in console.
2014-02-25 18:47:11 +08:00
Cheng Zhao
a5ec8a9110 Do not define _DEBUG.
The vc++ compiler would define some internal contants if we define
_DEBUG, since we are linking to the release build of chromiumcontent,
this would result in linking errors.
2014-02-25 18:24:07 +08:00
Cheng Zhao
30b3657c0e Update libchromiumcontent to 1df8e7cdac8aa74c91c19ae0691ce512d560ab3e. 2014-02-25 08:53:17 +08:00
Cheng Zhao
06a4f83bb7 linux: Fix upload script. 2014-02-24 05:41:16 +00:00
Cheng Zhao
7a8e43c65e linux: Fix create-dist. 2014-02-24 13:44:23 +08:00
Cheng Zhao
90cc1a7062 Bump v0.10.0. 2014-02-24 05:30:52 +00:00
Cheng Zhao
7d93b4a48f Fix polluting devtools in some cases. 2014-02-24 13:14:01 +08:00
Cheng Zhao
a2ecb554cc Merge pull request #178 from atom/debug-devtools
Add BrowserWindow.debugDevTools() API
2014-02-24 13:07:32 +08:00
Cheng Zhao
f65f95e95c The DevTools window should manage lifetime itself. 2014-02-24 12:17:10 +08:00
Cheng Zhao
eaedac2536 Add the debugDevTools JS API. 2014-02-24 12:08:33 +08:00
Cheng Zhao
8b9d35d84e Separate devtools code out. 2014-02-24 11:53:13 +08:00
Cheng Zhao
99c0de6a1a Disable stack dumping on MAC.
It would prevent the system crash reporter.
2014-02-24 11:48:11 +08:00
Cheng Zhao
f2bef6c26d Setup devtools frontend. 2014-02-24 11:28:21 +08:00
Cheng Zhao
1f57994e2a Setup devtools client for the correct contents. 2014-02-24 10:09:32 +08:00
Cheng Zhao
618040efc1 Add DebugDevTools API. 2014-02-24 09:52:20 +08:00
Cheng Zhao
ed34aa6fb3 Disable node integration in devtools. 2014-02-21 22:42:33 +08:00
Cheng Zhao
57639133a9 Merge pull request #149 from atom/linux
Add support for Linux
2014-02-21 17:33:29 +08:00
Cheng Zhao
1b7c308475 linux: Make native modules work. 2014-02-21 17:22:05 +08:00
Cheng Zhao
2b2a55d870 Update apm: fix node arch on Linux. 2014-02-21 16:23:04 +08:00
Cheng Zhao
c26a9b23a7 gtk: Should init gdk when using screen module. 2014-02-21 15:50:35 +08:00
Cheng Zhao
6c36f7e5c9 gtk: Window.focus should not change visibility. 2014-02-21 15:34:38 +08:00
Cheng Zhao
eb9673a152 linux: Implement libuv message loop polling. 2014-02-21 13:21:02 +08:00
Cheng Zhao
fbe963c7f3 💄 Fix cpplint warnings. 2014-02-21 12:57:45 +08:00
Cheng Zhao
18f8af7822 Only append arguments for browser process. 2014-02-21 01:04:27 +08:00
Cheng Zhao
3576c6d2ff Fix race condition when initializing request context getter.
Note that we are calling GetURLRequestContext() in the UI thread when
using the protocol module, this should in fact not be allowed, but for
now we just use the workaround of making sure the request context getter
has been initialized before we use the protocol module.
2014-02-21 00:56:18 +08:00
Cheng Zhao
b4ee01d43d linux: Fix one compiler warning. 2014-02-20 18:58:56 +08:00
Cheng Zhao
679aa43113 📝 List libraries required for Linux. 2014-02-20 18:56:59 +08:00
Cheng Zhao
2b82eafff4 📝 Update docs on using native modules. 2014-02-20 18:51:57 +08:00
Cheng Zhao
94b3de557e 📝 Add docs on building for Linux. 2014-02-20 18:39:24 +08:00
Cheng Zhao
c56480fd89 Update libchromiumcontent to use the thin version. 2014-02-20 18:20:29 +08:00
Cheng Zhao
e9879b150e Update runas to 0.5.* 2014-02-20 16:43:26 +08:00
Cheng Zhao
ea8d349b1b 💄 Fix cpplinting. 2014-02-19 21:25:18 +08:00
Cheng Zhao
87b78a89fb Menu::attachToWindow is available on Linux. 2014-02-19 13:10:09 +00:00
Cheng Zhao
27cd6688c1 BrowserWindow::setMenu is available on Linux. 2014-02-19 13:06:45 +00:00
Cheng Zhao
c340cac02c Build with symbols on debug build. 2014-02-19 11:39:51 +00:00
Cheng Zhao
0a9c371ca2 linux: Fix crash when using protocol module early. 2014-02-19 11:39:01 +00:00
Cheng Zhao
4a000a35c4 Enable convient stack printing. 2014-02-19 19:07:52 +08:00
Cheng Zhao
d89fb15daf Merge branch 'master' into linux 2014-02-19 11:04:15 +00:00
Cheng Zhao
d698ecf017 linux: Make test.py work. 2014-02-14 15:17:24 +00:00
Cheng Zhao
2b7b4a16f5 linux: Make binary search for libraries under current directory. 2014-02-14 15:11:57 +00:00
Cheng Zhao
526aaecc52 linux: Add dummy implementation of node bindings. 2014-02-14 14:39:57 +00:00
Cheng Zhao
e3d5b62000 gtk: Add dummy implementation of dialog. 2014-02-14 14:07:23 +00:00
Cheng Zhao
6bd56f2a52 gtk: Add utils imported from chrome. 2014-02-14 13:59:41 +00:00
Cheng Zhao
426e7645bc gtk: Add dummy implementation of Menu. 2014-02-14 13:41:20 +00:00
Cheng Zhao
521fb7d54c linux: Fix compilation error. 2014-02-14 13:34:59 +00:00
Cheng Zhao
4051d2ebdb Merge branch 'master' into linux
Conflicts:
	atom.gyp
	vendor/apm
	vendor/brightray
2014-02-14 13:17:00 +00:00
Cheng Zhao
b4fa3cd925 Bump v0.9.3. 2014-02-12 22:14:13 -08:00
Cheng Zhao
984d60f935 Override default window.close, fixes #70. 2014-02-17 18:19:55 +08:00
Cheng Zhao
65f258160e Merge pull request #176 from atom/unload-on-upgrade
Close all windows before installing update
2014-02-17 18:14:14 +08:00
Cheng Zhao
a76183c188 Do not print download progress in CI. 2014-02-17 17:50:25 +08:00
Cheng Zhao
fde4c544b8 💄 2014-02-17 17:50:16 +08:00
Cheng Zhao
274c9d04b1 Enable the quitAndInstall to be cancelled by beforeunload handler. 2014-02-17 16:25:00 +08:00
Cheng Zhao
07fc2b41af Fix using BrowserWindow as parameter for ipc.sendChannel. 2014-02-17 15:24:42 +08:00
Cheng Zhao
a9efe77ceb Fix quitAndInstall when there is no window. 2014-02-17 15:06:25 +08:00
Cheng Zhao
b932461b45 Fix crash when calling quitAndUpdate without any update. 2014-02-17 14:56:23 +08:00
Cheng Zhao
6b3ff63358 Close all windows before installing update. 2014-02-17 14:51:22 +08:00
Cheng Zhao
dd4e36a42e Bump v0.9.2. 2014-02-12 20:52:46 +08:00
Cheng Zhao
93687efee9 win: Use util.format to format arguments in console.log. 2014-02-12 20:32:30 +08:00
Cheng Zhao
9ba7db8815 win: Fix detecting attached modal dialog. 2014-02-10 20:07:38 +08:00
Cheng Zhao
f4a2c12d75 Use keydown event for accelerator.
This follows the behaivor on OS X, fixed #174.
2014-02-06 19:43:30 +08:00
Cheng Zhao
74a83e3d7c The translate-crash-log-addresses script is abandonded. 2014-02-06 18:35:54 +08:00
Cheng Zhao
283aa79c17 Fix assertions when building against Debug libchromiumcontent.
Imported from https://github.com/brightray/brightray/pull/50.
2014-02-05 11:18:32 +08:00
Cheng Zhao
dc69c7b694 Merge pull request #173 from atom/cj-fix-release-name
Parse the 4th argument into a date.
2014-02-03 16:58:53 -08:00
probablycorey
a78807b309 Bump v0.9.1. 2014-02-03 12:41:53 -08:00
probablycorey
e7248b486f Parse the 4th argument into a date. 2014-02-03 12:39:54 -08:00
Cheng Zhao
c2afa3521e Fix building on Windows. 2014-02-03 09:21:45 +08:00
Cheng Zhao
6ae38d86df Bump v0.9.0. 2014-01-30 13:32:16 -08:00
Cheng Zhao
9f0d9e0fad Merge pull request #162 from atom/cj-replace-sparkle-with-squirrel
Replace sparkle with squirrel
2014-02-02 04:56:13 -08:00
Cheng Zhao
45b626e0cc 📝 Add docs on new auto updater API. 2014-02-02 20:55:35 +08:00
Cheng Zhao
c13724b342 Fix ci. 2014-02-02 19:58:25 +08:00
probablycorey
5da1e9ed10 Handle all download events from AutoUpdater::CheckForUpdates 2014-02-01 15:55:57 -08:00
probablycorey
a8913f5ea0 Remove version string from feed url 2014-01-31 16:14:16 -08:00
probablycorey
a59756485e Handle all download events in completed block.
'update-downloaded' and 'update-not-available' events are now called
in the completed block.
2014-01-31 16:13:01 -08:00
probablycorey
6949af5427 Emit 'update-available' and 'checking-for-update' events. 2014-01-31 16:11:11 -08:00
probablycorey
da602a7c01 Include the version with the update request 2014-01-31 16:02:38 -08:00
Cheng Zhao
50eb5454d4 Still subscribe to "updates" for update notifications.
It seems that we should subscribeError to checkForUpdatesCommand to
catch all errors, and the "updates" would only work when there is no
error happened.
2014-01-31 21:47:59 +08:00
Cheng Zhao
8ee1e1d208 Subscribe to checkForUpdatesCommand's return value. 2014-01-31 21:31:42 +08:00
Cheng Zhao
73ec7783af No need to add "static" for functions in anonymouse namespace. 2014-01-31 21:10:51 +08:00
Cheng Zhao
a8f172752a 💄 Fix cpplint warning. 2014-01-31 20:28:33 +08:00
Cheng Zhao
b7e120b68c Merge branch 'master' into cj-replace-sparkle-with-squirrel 2014-01-31 19:36:26 +08:00
Cheng Zhao
a85075103f Move resources file under resources/ 2014-01-31 19:34:31 +08:00
Cheng Zhao
fe30880ec0 Add Info.plist for Atom Framework, fixes #171. 2014-01-31 17:40:47 +08:00
Cheng Zhao
c81128b675 Merge pull request #172 from atom/secure-iframe
Add "node-integration" option to BrowserWindow
2014-01-31 00:52:32 -08:00
Cheng Zhao
2634328720 Fix how we filter out atom-shell switches in process.argv. 2014-01-31 16:40:20 +08:00
Cheng Zhao
0df59e2714 💄 Fix cppling warning. 2014-01-31 15:53:01 +08:00
Cheng Zhao
18fdbb6432 Add docs on the node-integration setting. 2014-01-31 15:22:32 +08:00
Cheng Zhao
bd51a4c8cf Fix crash when opening multiple pages at the same time. 2014-01-31 15:09:13 +08:00
Cheng Zhao
6478244fbf Put common constants into one file. 2014-01-31 12:18:30 +08:00
Cheng Zhao
e0f660301c Specify the commit of libchromiumcontent to download. 2014-01-31 12:09:43 +08:00
Cheng Zhao
192014cc3f Do not use plain string iterals. 2014-01-31 10:41:20 +08:00
Cheng Zhao
61b69a4e8a Fix loss of --node-integration token after refresh. 2014-01-31 10:30:16 +08:00
Cheng Zhao
ec00da416f Rename iframe-security to node-integration. 2014-01-30 23:20:12 +08:00
Cheng Zhao
d4929de33c Add iframe-security support. 2014-01-30 22:47:21 +08:00
Cheng Zhao
a0b15661ed Append --iframe-security to renderer process. 2014-01-30 21:57:01 +08:00
Cheng Zhao
9a58706e1f Don't pollute process.argv of browser process. 2014-01-30 21:20:02 +08:00
Cheng Zhao
ce586e0835 Don't append duplicate arguments to renderer process. 2014-01-30 21:06:56 +08:00
probablycorey
795c31918a Merge remote-tracking branch 'origin/master' into cj-replace-sparkle-with-squirrel 2014-01-29 14:55:20 -08:00
Cheng Zhao
2592487c3f Sort devDependencies. 2014-01-28 09:36:32 +08:00
Cheng Zhao
f05daa8bdc Make bump-version accept major/minor/patch/build. 2014-01-27 18:37:39 +08:00
Cheng Zhao
75ec34884d Bump v0.8.7. 2014-01-23 05:02:28 -08:00
Cheng Zhao
96cb4fd6d7 Merge pull request #166 from atom/cz-v8-locker
Wrap callbacks with v8 locker in browser process
2014-01-27 00:15:22 -08:00
Cheng Zhao
d63de1ae15 Wrap callbacks with v8::Locker.
In browser process, because of the use of v8::Locker in ProxyResolverV8,
creating HandleScope requires entering locker first, so in browser
process we should just use v8::Locker whenever we need to use V8 in a
callback called from non-V8 places (like dialog's callback, work pushed
to MessageLoop).

But also notice that the renderer process doesn't use v8::Locker, so we
have to be careful not to use it, otherwise blink would crash when
creating HandleScope.
2014-01-27 15:14:11 +08:00
Cheng Zhao
5250871e69 Remove unneeded HandleScopes.
It's not necessary to create HandleScope in v8 native binding functions,
because it's guarrenteed that the there is a upper HandleScope when the
native function is called. So unless we are urgent to free the handles,
not using HandleScope in native binding functions is a cleaner and safer
choice.
2014-01-27 15:01:06 +08:00
Cheng Zhao
426bc97194 Use node_isolate instead of Isolate::GetCurrent(). 2014-01-27 14:04:34 +08:00
Cheng Zhao
76098255f0 Should decode when setting __filename from location. 2014-01-24 21:20:30 +08:00
Cheng Zhao
e8594b492e It's safe to send message to nil. 2014-01-22 12:00:34 +08:00
Cheng Zhao
d4e362ec89 Add error and update-not-available events for auto updater. 2014-01-21 22:50:46 +08:00
Cheng Zhao
df399f7c8c Implement auto_updater with Squirrel. 2014-01-21 22:13:34 +08:00
Cheng Zhao
ef8e5505c8 Merge branch 'master' into cj-replace-sparkle-with-squirrel 2014-01-21 20:40:19 +08:00
Cheng Zhao
71fd147c47 Fix gyp error on CI. 2014-01-21 20:34:35 +08:00
Cheng Zhao
c271d89677 Fix cpplint warnings. 2014-01-21 20:25:01 +08:00
probablycorey
7cf040e7ca I don't think fix_framework_link_command is needed anymore.
tool -L says Squirrel (and its dependencies) already use @rpath

```
@rpath/Squirrel.framework/Squirrel (compatibility version 1.0.0, current version 1.0.0)
@rpath/ReactiveCocoa.framework/ReactiveCocoa (compatibility version 1.0.0, current version 1.0.0)
@rpath/Mantle.framework/Mantle (compatibility version 1.0.0, current version 1.0.0)
```
2014-01-20 16:32:56 -08:00
probablycorey
a6c92f20c8 Link Sparkle frameworks 2014-01-20 16:25:48 -08:00
probablycorey
400e963b8b Download Squirrel frameworks instead of Sparkle 2014-01-20 16:25:33 -08:00
probablycorey
2a7244a366 Remove references to Sparkle 2014-01-20 16:22:49 -08:00
probablycorey
5741bad918 💄 2014-01-20 16:22:32 -08:00
Cheng Zhao
1d7445c5aa Fix uv loop hack on child_process. 2014-01-18 17:01:30 +08:00
Cheng Zhao
4a1f8cf1c9 Activate uv loop when uv loop's watcher queue changes, fixes #159. 2014-01-18 16:56:46 +08:00
Cheng Zhao
a2bf1b3907 Update to latest apm. 2014-01-18 16:29:24 +08:00
Cheng Zhao
b2d4d76bcf 📝 Update docs on source code structure. 2014-01-16 10:31:59 +08:00
Cheng Zhao
9ac555c302 move atom_menu_controller_mac to browser/ui/cocoa. 2014-01-16 10:22:33 +08:00
Cheng Zhao
43711083f7 Move atom_event_processing_window to browser/ui/cocoa. 2014-01-16 10:09:36 +08:00
Cheng Zhao
9b07c2b894 Move nsalert_synchronous_sheet_mac to browser/ui/cocoa. 2014-01-16 10:06:05 +08:00
Cheng Zhao
2c28725722 gtk: Support frameless window. 2014-01-15 15:15:45 +00:00
Cheng Zhao
53a4f34433 📝 Add docs on window events. 2014-01-15 14:42:47 +00:00
Cheng Zhao
406f0b7bc7 Implement "blur" window event. 2014-01-15 14:38:38 +00:00
Cheng Zhao
6912a0513a gtk: Set WebKit's style from current theme. 2014-01-15 14:31:26 +00:00
Cheng Zhao
0398577e93 gtk: Implement basic native window methods. 2014-01-15 13:28:00 +00:00
Cheng Zhao
42dc9c1ec6 Add dummy implementation of crash reporter. 2014-01-15 12:01:03 +00:00
Cheng Zhao
2f798c5116 Merge branch 'master' into linux
Conflicts:
	vendor/apm
2014-01-15 11:18:40 +00:00
Cheng Zhao
363f1da77e Bump v0.8.6. 2014-01-14 01:34:07 -08:00
Cheng Zhao
8655dec00e Crash when there is fatal error in V8. 2014-01-23 20:30:44 +08:00
Cheng Zhao
fbc68ecce5 Bump v0.8.5. 2014-01-14 16:24:53 +08:00
Cheng Zhao
8d4ac15834 :lipstip: Remove unneed output. 2014-01-14 16:04:47 +08:00
Cheng Zhao
249366c90a Restart renderer process for all navigations and reloads, fixes #157. 2014-01-14 16:03:01 +08:00
Cheng Zhao
931182b677 Fix crash when calling dialog's callback. 2014-01-14 14:18:32 +08:00
Cheng Zhao
2a129f892f Bump v0.8.4. 2014-01-13 18:46:19 +08:00
Cheng Zhao
57a27876ec Fix warnings of node_lib. 2014-01-13 18:43:09 +08:00
Cheng Zhao
fc2e069efe Fix warnings of openssl-cli. 2014-01-13 18:41:40 +08:00
Cheng Zhao
58d4ec5587 Update node-pathwatcher to v0.14.0. 2014-01-13 18:25:04 +08:00
Cheng Zhao
b0c23294fe Also use uv loop fixes in browser process. 2014-01-13 13:57:08 +08:00
Cheng Zhao
290dd36bb0 Activate uv loop when calling childProcess.fork.
Fixes #156.
2014-01-13 11:52:24 +08:00
Cheng Zhao
84529de10d Update apm: update node version to v0.11.10. 2014-01-10 18:50:53 +08:00
Cheng Zhao
bde4a732c4 Bump node version to v0.11.10. 2014-01-10 18:37:05 +08:00
Cheng Zhao
535b936c87 Update node to v0.11.10. 2014-01-10 18:24:44 +08:00
Cheng Zhao
dc880b16f1 Merge pull request #155 from atom/fix-q
Fix executing process.nextTick's callbacks
2014-01-10 02:13:07 -08:00
Cheng Zhao
5eb1f52421 Make sure nextTick is called when activating uv loop. 2014-01-10 16:47:33 +08:00
Cheng Zhao
3747048218 💄 get_uv_env() => uv_env(). 2014-01-10 16:29:38 +08:00
Cheng Zhao
a1a091d805 Add spec for q. 2014-01-10 15:58:14 +08:00
Cheng Zhao
e536d0e7a8 Leak the node environment when unloading. 2014-01-10 11:04:54 +08:00
Cheng Zhao
e050494e5d Merge pull request #154 from atom/safe-context
Wrap uv loop with web page context in renderer
2014-01-09 06:28:35 -08:00
Cheng Zhao
bbc01e704c Monitor file events in pathwatcher spec. 2014-01-09 22:13:48 +08:00
Cheng Zhao
fff743053a Store all created environments in renderer. 2014-01-09 22:13:06 +08:00
Cheng Zhao
e7b7efeb0a Wrap uv loop with web page context in renderer. 2014-01-09 21:35:29 +08:00
Cheng Zhao
968fc71b78 Add spec for using setTimeout in pure uv callback. 2014-01-09 20:34:17 +08:00
Cheng Zhao
d0494024a9 Add process.scheduleCallback.
It will schedule a callback to be executed by pure uv loop.
2014-01-09 20:33:07 +08:00
Cheng Zhao
a12754f980 Add spec for pathwatcher module. 2014-01-09 20:29:54 +08:00
Cheng Zhao
c76f510cea Bump v0.8.3. 2014-01-07 08:26:12 -08:00
Cheng Zhao
968f75529a Fix possible crashes when quiting message loop. 2014-01-08 11:55:54 +08:00
Cheng Zhao
93d5a2e195 Fix invoking non-exist method when quiting. 2014-01-08 10:51:32 +08:00
Cheng Zhao
367285f3f3 Merge pull request #152 from atom/gfx-module
Add screen module
2014-01-07 04:46:24 -08:00
Cheng Zhao
95b2003193 📝 Add docs on screen module. 2014-01-07 20:35:13 +08:00
Cheng Zhao
bcdc44c1c6 Support converting v8 value to arbitrary vector or map. 2014-01-07 20:29:17 +08:00
Cheng Zhao
4ae2738ce5 Add screen.getPrimaryDisplay() API. 2014-01-07 20:15:55 +08:00
Cheng Zhao
e09a2ff811 Add support to convert gfx::Rect and gfx::Size to v8 value. 2014-01-07 20:15:23 +08:00
Cheng Zhao
7253a35455 Add initial screen module. 2014-01-07 20:00:25 +08:00
Cheng Zhao
1b1cf87115 Add support to convert gfx::Point to v8 value. 2014-01-07 20:00:02 +08:00
Cheng Zhao
3ec755e978 💄 2014-01-07 19:44:37 +08:00
Cheng Zhao
cf4616de7f api::EventEmitter could also be used by renderer. 2014-01-07 19:32:40 +08:00
Cheng Zhao
2755fbaadf Update apm. 2014-01-07 02:50:52 -08:00
Cheng Zhao
6f222651d7 Bump v0.8.2. 2014-01-07 18:44:37 +08:00
Cheng Zhao
fe4841a1cd Set module's filename to path of html.
The relative require relies on module.filename to work as expected.
2014-01-07 14:30:18 +08:00
Cheng Zhao
fe8a2b9ee0 Still support 'atom-delegate' API for old apps. 2014-01-07 09:50:00 +08:00
Cheng Zhao
b939232670 mac: Should set default size when creating window. 2014-01-06 18:58:30 +08:00
Cheng Zhao
a4253e3899 linux: Implemnt browser methods. 2014-01-02 14:47:54 +00:00
Cheng Zhao
52b5f769f0 linux: Add empty implementation of auto updater. 2014-01-02 14:15:02 +00:00
Cheng Zhao
b73a114f8f gtk: Implement accelerator_util. 2014-01-02 14:12:05 +00:00
Cheng Zhao
7ca152070a Update brightray. 2014-01-01 02:31:33 +00:00
Cheng Zhao
f24ccd3841 linux: Implement platform_util. 2013-12-31 12:59:33 +00:00
Cheng Zhao
66ac11ca5f linux: Implement brightray's stub functions. 2013-12-31 12:24:53 +00:00
Cheng Zhao
7afef0fcdb Fix entry function under Linux. 2013-12-31 11:51:17 +00:00
Cheng Zhao
627f487b36 Disable compilation errors in node under Linux. 2013-12-31 11:40:19 +00:00
Cheng Zhao
c64a793364 Build with clang under Linux. 2013-12-31 11:27:31 +00:00
Cheng Zhao
63852a8c82 Update brightray for linux_clang flag. 2013-12-31 11:16:18 +00:00
Cheng Zhao
c97afdbdb3 Update apm. 2013-12-31 08:33:17 +00:00
Cheng Zhao
6c5ea4ea32 Compile coffee script on Linux. 2013-12-31 08:01:08 +00:00
Cheng Zhao
cac3973731 Flip the y axis in CapturePage API, fixes #148. 2013-12-31 14:40:42 +08:00
Cheng Zhao
19a35b58f0 Merge pull request #147 from atom/remote-docs
Revise the docs on remote module
2013-12-30 18:02:14 -08:00
Cheng Zhao
5e51ad30d7 Add notes about remote buffer in capturePage API's docs. 2013-12-31 10:00:29 +08:00
Cheng Zhao
e1e5cb5ba4 Add notes on remote buffer. 2013-12-30 23:15:15 +08:00
Cheng Zhao
8d124c7157 Revise the docs of remote module. 2013-12-30 22:06:33 +08:00
Cheng Zhao
67ed72294b Bump v0.8.1. 2013-12-29 23:09:19 +08:00
Cheng Zhao
1bb5481071 Fix circulate require. 2013-12-29 22:33:53 +08:00
Cheng Zhao
876063b1ba Fix console.log under Windows.
The process.log is not added until the next iteration of uv loop.
2013-12-29 22:32:26 +08:00
Cheng Zhao
7d193033f5 💄 Fix wrong order of parameter when killing process. 2013-12-29 22:11:54 +08:00
Cheng Zhao
074ea374e0 We are now on v0.8.0 release. 2013-12-27 16:22:34 +08:00
Cheng Zhao
f6c3a69595 Merge pull request #146 from atom/window-open
Implement window.open in pure js
2013-12-26 23:54:19 -08:00
Cheng Zhao
f28881e203 Fix crash caused by BrowserWindow.destroy(). 2013-12-27 15:41:00 +08:00
Cheng Zhao
6312c1108a Add spec for window.open. 2013-12-27 14:58:13 +08:00
Cheng Zhao
0de40febab Add basic support for window.open's features. 2013-12-27 14:57:53 +08:00
Cheng Zhao
1701f572e2 Fix crash when calling method of destroyed object. 2013-12-27 14:47:50 +08:00
Cheng Zhao
15a9be6b93 Implement a simple window.open with pure js. 2013-12-27 14:39:23 +08:00
Cheng Zhao
a60be1563f Do not implement window.open. 2013-12-27 14:32:24 +08:00
Cheng Zhao
a2522efb25 Build for x64 architecture on OS X, fixes #132. 2013-12-27 14:17:35 +08:00
Cheng Zhao
7c3f22a333 Bump v0.8.0. 2013-12-27 14:09:10 +08:00
Cheng Zhao
2945e1b50a Merge pull request #140 from atom/chrome31
Update to Chrome 31
2013-12-26 22:07:17 -08:00
Cheng Zhao
aedacd39d2 Rename 'finish-launching' event to 'ready',
'finish-launching' is more like a OS X message name, and in atom-shell
it means initialization has done, so 'ready' seems to be a better name
and more easy to remember.

The 'will-finish-launching' event just represents the corresponding
message on OS X and is the same with 'ready' on other platforms, so we
keep its name to indicate that it's only useful for OS X specified
code.
2013-12-27 11:08:26 +08:00
Cheng Zhao
d3f33152d0 Get rid of the ugly ATOM_BROWSER_INTERNAL_NEW message. 2013-12-26 18:41:21 +08:00
Cheng Zhao
cfca12d4a5 Use the gyp vendored by brightray. 2013-12-25 18:47:19 +08:00
Cheng Zhao
754cd88cc2 Update brightray: Fix building on Windows. 2013-12-24 16:05:50 +08:00
Cheng Zhao
031426d54e Use our fork of V8ValueConverter for all cases. 2013-12-23 22:42:21 +08:00
Cheng Zhao
980e8ca4dc Free the node environment when releasing context. 2013-12-23 22:19:51 +08:00
Cheng Zhao
df0094b6cb Move node integration from RenderViewObserver to RendererClient. 2013-12-23 22:08:45 +08:00
Cheng Zhao
02d94c8b2e Print pid when logging. 2013-12-23 22:04:49 +08:00
Cheng Zhao
902be9bab5 Update node: Removed two unused patches. 2013-12-20 14:20:24 +08:00
Cheng Zhao
f646d2dda8 Enable high DPI support. 2013-12-20 14:14:07 +08:00
Cheng Zhao
92b19f89d9 Remove the unzip spec completely. 2013-12-17 23:21:40 +08:00
Cheng Zhao
d8eb465eb9 Fix protocol spec on Windows. 2013-12-17 23:03:36 +08:00
Cheng Zhao
c04a9933cc Fix __filename on Windows. 2013-12-17 22:16:15 +08:00
Cheng Zhao
5b12f80d01 Discard the require('atom-delegate') API. 2013-12-17 22:08:45 +08:00
Cheng Zhao
75c44ca057 Fix initializing V8 on Windows. 2013-12-17 21:55:56 +08:00
Cheng Zhao
56f709ff1f Continue fixing compilation erros on Windows. 2013-12-17 18:34:45 +08:00
Cheng Zhao
0215c2fbee Make all the windows code compile for Chrome 31. 2013-12-17 17:52:57 +08:00
Cheng Zhao
6e079d8bc4 Also search C:/Program Files (x86) for node binary. 2013-12-17 13:14:54 +08:00
Cheng Zhao
a4715f936b Merge branch 'master' into chrome31
Conflicts:
	common/atom_version.h
2013-12-17 12:58:25 +08:00
Cheng Zhao
1d88b31edd Use node-runas for testing native modules. 2013-12-17 12:00:21 +08:00
Cheng Zhao
e07e26ca76 Fix third party module specs. 2013-12-16 22:46:16 +08:00
Cheng Zhao
c82e73a4ec Update apm: Fix installing for node v0.11.x. 2013-12-16 22:37:43 +08:00
Cheng Zhao
eda4249bf8 Add deps/npm and deps/mdb_v8 in node headers. 2013-12-16 22:37:17 +08:00
Cheng Zhao
09201e3e65 Update brightray: Remove webkit hacks. 2013-12-16 21:19:12 +08:00
Cheng Zhao
2ca2d37e93 Clean out node_modules in cibuild. 2013-12-16 15:15:33 +08:00
Cheng Zhao
d3416e2873 Bump node version to v0.11.9. 2013-12-16 14:52:15 +08:00
Cheng Zhao
4e4e316005 Include Environment declarations in node_common.h. 2013-12-16 14:46:05 +08:00
Cheng Zhao
8fc1e055bf Update apm for node version and architecture change. 2013-12-16 14:40:03 +08:00
Cheng Zhao
d51ea21afa Use singular form of spec names. 2013-12-16 00:31:40 +08:00
Cheng Zhao
abf982e4e5 Remove the on_watcher_queue_updated hack. 2013-12-15 19:50:43 +08:00
Cheng Zhao
998e9792fb Make setImmediate have the same side effect with upstream node. 2013-12-15 19:09:00 +08:00
Cheng Zhao
c87b21148c Supress the unzip module spec.
The unzip module is not compatible with node v0.11.x, so we do not need
to test it anymore.
2013-12-15 19:08:10 +08:00
Cheng Zhao
7e67f7632d 💄 Fix cpplint warnings. 2013-12-15 17:09:35 +08:00
Cheng Zhao
cd68396bd5 Disable use of deprecated functions in specs. 2013-12-15 17:02:43 +08:00
Cheng Zhao
474e1fcd3b Fix protocol module specs. 2013-12-15 16:53:07 +08:00
Cheng Zhao
cfeeec37eb Fix capturePage() spec. 2013-12-15 16:32:49 +08:00
Cheng Zhao
0a84c30d3b Redirect window.onerror to uncaughtException. 2013-12-15 16:32:41 +08:00
Cheng Zhao
7ba03ce23d Add setImmediate function in renderer. 2013-12-15 16:21:23 +08:00
Cheng Zhao
cc5db4dab9 Suppress the EventEmitter's warning for ObjectsRegistry.
It's possible that many objects subscribed to it.
2013-12-15 16:15:18 +08:00
Cheng Zhao
aa3e8385df Set __filename to the html file in renderer. 2013-12-15 16:11:00 +08:00
Cheng Zhao
886ebdb002 Use node's Environment feature to add "require" in renderer. 2013-12-15 14:20:28 +08:00
Kevin Sawicki
ea2f87683a Merge pull request #144 from shama/typo
Fix a couple minor typos in docs
2013-12-13 08:44:06 -08:00
Kyle Robinson Young
c116f6b35c Fix a couple minor typos in docs 2013-12-12 22:31:19 -08:00
Cheng Zhao
2413eebd7b Disable accelerated compositing to fix everything. 2013-12-13 00:57:08 +08:00
Cheng Zhao
7708e7a8c4 Update node for renderer node integration fixes. 2013-12-12 16:49:56 +08:00
Cheng Zhao
1c0b391419 Fix the black devtools view.
Without using UnderlayOpenGLHostingWindow the devtools view would just
be black.
2013-12-12 15:49:08 +08:00
Cheng Zhao
28f5d184b3 Do not depend on node to set include_dirs.
Part of atom/node#2.
2013-12-12 14:07:00 +08:00
Cheng Zhao
fc00da9732 Update brightray, which contains all our patches in master. 2013-12-12 10:43:50 +08:00
Cheng Zhao
9ea75b7519 We are now at v0.8.0-pre. 2013-12-12 10:43:34 +08:00
Cheng Zhao
61c63a6af9 Fix crashes about persistent v8 functions. 2013-12-12 00:10:09 +08:00
Cheng Zhao
e4bfa373de Fix node integration to browser after updated to Chrome31. 2013-12-11 23:59:03 +08:00
Cheng Zhao
d53915c6ab Fix recursive calling of handle(). 2013-12-11 23:57:37 +08:00
Cheng Zhao
409a431892 Huge commit to use new V8 and Content APIs.
Still got a lots of linking errors!
2013-12-11 15:48:19 +08:00
Cheng Zhao
d82cfc023f 💄 There should be no space between & and type name. 2013-12-10 14:27:25 +08:00
Cheng Zhao
f9c41f33e5 node::ObjectWrap how had a handle() method. 2013-12-10 14:15:37 +08:00
Cheng Zhao
4ec4b01218 base/string16.h was moved to base/strings/string16.h. 2013-12-10 14:14:05 +08:00
Cheng Zhao
0a37852757 Update to node v0.11.9. 2013-12-10 14:07:32 +08:00
Cheng Zhao
42ffa5813f Update libchromiumcontent and brightray to use Chrome31. 2013-12-09 17:23:32 +08:00
Cheng Zhao
597e17b540 Fix template related compilation errors of VC++. 2013-12-09 16:34:10 +08:00
Cheng Zhao
9ac0591386 Bump v0.7.6. 2013-12-08 22:42:43 -08:00
Cheng Zhao
cb73a3c572 Remove the RestartHangMonitorTimeout API, which is useless now. 2013-12-09 14:17:56 +08:00
Cheng Zhao
2c672052e6 Flatten spec files, make them seem cleaner. 2013-12-06 22:23:02 +08:00
Cheng Zhao
b431e96f9d Update node: Add fs.lstatSyncNoException, closes #138. 2013-12-06 21:51:47 +08:00
Cheng Zhao
36445f8d8b Merge pull request #139 from atom/browser-cleaner
Do not rely on renderer to report the deletion of render view
2013-12-06 05:17:27 -08:00
Cheng Zhao
085b1a45ee Report the right render view that is deleted. 2013-12-06 15:53:40 +08:00
Cheng Zhao
844fccc177 Use random number as id in CallbacksRegistry.
It's very possible that the callbacks got GCed before the render view is
closed (like page getting refreshed), so we should not let browser call
the wrong callback, instead we should throw error whenever a callback is
not found.
2013-12-06 15:04:51 +08:00
Cheng Zhao
0a63395b0f 💄 Restore old settings in app specs. 2013-12-06 14:54:29 +08:00
Cheng Zhao
623e0f3ae4 Release render view's remote objects when it's deleted.
Privously we release them when the window is unloaded, which is not
correct since a render view can have multiple windows (or js contexts)
and when the unload event is emitted the render view could already have
gone.

This PR does the cleaning work purely in browser, so here is no need to
worry about renderer's life time.
2013-12-06 14:44:25 +08:00
Cheng Zhao
e9e90b481a 💄 Fix cpplint warnings. 2013-12-05 23:54:57 +08:00
Cheng Zhao
4a1ee39156 Get rid of manually converting to base::Value when possible. 2013-12-05 23:47:07 +08:00
Cheng Zhao
e5afa72b4d Fail quietly when getting null renderer view.
It happens when the window is closing.
2013-12-05 23:34:43 +08:00
Cheng Zhao
287c948845 Enable getting scoped_ptr type from v8 value.
God damned C++ template.
2013-12-05 23:25:14 +08:00
Cheng Zhao
4625f051c8 Simplify V8 operations in renderer ipc code. 2013-12-05 22:12:27 +08:00
Cheng Zhao
8d271a6655 Update node: Fixed a handle leak in fs.statNoException(). 2013-12-05 21:41:39 +08:00
Cheng Zhao
65b3435156 Bump v0.7.5. 2013-12-05 13:48:19 +08:00
Cheng Zhao
3c60e07653 Merge pull request #136 from atom/fix-ua
Use name and version information of package.json
2013-12-04 21:44:35 -08:00
Cheng Zhao
564c5c1664 Add simple specs for app.getName() and app.getVersion(). 2013-12-05 13:37:01 +08:00
Cheng Zhao
5f4a9316f1 📝 Add usage of productName of package.json. 2013-12-05 11:46:36 +08:00
Cheng Zhao
a0c0bb18b7 Choose a better name for the default_app. 2013-12-05 11:31:16 +08:00
Cheng Zhao
284160bf2d Set application's name and version from the package.json. 2013-12-05 11:30:06 +08:00
Cheng Zhao
0229c3187b Override the user agent to contain application and atom-shell's version. 2013-12-05 11:21:11 +08:00
Cheng Zhao
eec8560119 📝 Update documentation on changes of "app" module. 2013-12-05 11:02:09 +08:00
Cheng Zhao
fc4ed9be12 Use bundle's name as application name when we have one. 2013-12-05 10:42:04 +08:00
Cheng Zhao
a614134144 Simplify V8 operations. 2013-12-05 10:35:57 +08:00
Cheng Zhao
5670ee7693 Add API to get and override application name. 2013-12-05 10:32:58 +08:00
Cheng Zhao
420ae1a2cc Add API to override browser version. 2013-12-05 10:26:01 +08:00
Cheng Zhao
02bbf07d3a Enable overriding UA strings. 2013-12-05 10:08:11 +08:00
Cheng Zhao
121163f9ca Add conversions between V8 Value and GURL. 2013-12-05 10:07:51 +08:00
Kevin Sawicki
d79626f02f 📝 Update repo link to atom/atom 2013-12-04 09:09:30 -08:00
Cheng Zhao
7cffbc8a1a Bump v0.7.4. 2013-12-04 22:12:58 +08:00
Cheng Zhao
170ef2362f Merge pull request #133 from atom/sheet-unresponsive
Do not send "unresponsive" message if window is showing a modal dialog.
2013-12-04 06:11:38 -08:00
Cheng Zhao
e45f83e62a Make sure browserWindow.destroy() doesn't leave zombie processes. 2013-12-04 22:00:20 +08:00
Cheng Zhao
687c9de5d7 win: Implement NativeWindowWin::HasModalDialog(). 2013-12-04 21:18:53 +08:00
Cheng Zhao
e43b39a009 Do not send "unresponsive" message if window is showing a modal dialog. 2013-12-04 17:18:55 +08:00
Cheng Zhao
bfe8928ab1 Do not use flags to mark whether the window is unresponsive.
It's error prone.
2013-12-04 17:10:59 +08:00
Cheng Zhao
d6d1604623 mac: Add API to return whether the window has attached sheet. 2013-12-04 16:32:32 +08:00
Cheng Zhao
7d5826df85 Add "Cmd" and "Control" alias for "Command" and "Ctrl". 2013-11-29 16:31:38 +08:00
Cheng Zhao
9493c1b0bb Bump v0.7.3. 2013-11-29 16:22:27 +08:00
Cheng Zhao
a2aa20b6b2 Add "Edit" menu in specs window. 2013-11-29 16:21:43 +08:00
Cheng Zhao
c8d0968e00 Use CommandOrControl to replace Command in specs windows. 2013-11-29 16:14:44 +08:00
Cheng Zhao
8237edcf0d Add "CommandOrControl" to represent "Command" on OS X and "Ctrl" on other platforms. 2013-11-29 16:11:48 +08:00
Cheng Zhao
13261921a7 Merge pull request #130 from atom/force-closing
Send the "unresponsive" event if window does not close or cancel the close in 500ms when closing it.
2013-11-28 23:42:27 -08:00
Cheng Zhao
adc5495d2b Prompt unresponsive state in spec window. 2013-11-29 15:19:30 +08:00
Cheng Zhao
02d14ed23b Fix returning the chosen option for synchronous dialogs. 2013-11-29 15:19:00 +08:00
Cheng Zhao
a0a5b20ef1 Send the "unresponsive" event if window is not closed in 500ms when closing it. 2013-11-29 14:52:12 +08:00
314 changed files with 14645 additions and 4066 deletions

1
.gitignore vendored
View File

@@ -5,6 +5,7 @@
/out/
/vendor/brightray/vendor/download/
/vendor/python_26/
/vendor/npm/
node_modules/
*.xcodeproj
*.swp

3
.gitmodules vendored
View File

@@ -4,9 +4,6 @@
[submodule "vendor/node"]
path = vendor/node
url = https://github.com/atom/node.git
[submodule "vendor/gyp"]
path = vendor/gyp
url = https://github.com/svn2github/gyp.git
[submodule "vendor/depot_tools"]
path = vendor/depot_tools
url = https://chromium.googlesource.com/chromium/tools/depot_tools.git

View File

@@ -1,6 +1,6 @@
# Atom Shell
Native layer for the [Atom](https://github.com/github/atom).
Native layer for the [Atom editor](https://github.com/atom/atom).
## Features

541
atom.gyp
View File

@@ -4,199 +4,232 @@
'product_name': 'Atom',
'framework_name': 'Atom Framework',
'app_sources': [
'app/atom_main.cc',
'app/atom_main.h',
'atom/app/atom_main.cc',
'atom/app/atom_main.h',
],
'bundle_sources': [
'browser/mac/atom.icns',
'atom/browser/resources/mac/atom.icns',
],
'coffee_sources': [
'browser/api/lib/app.coffee',
'browser/api/lib/atom-delegate.coffee',
'browser/api/lib/auto-updater.coffee',
'browser/api/lib/browser-window.coffee',
'browser/api/lib/dialog.coffee',
'browser/api/lib/ipc.coffee',
'browser/api/lib/menu.coffee',
'browser/api/lib/menu-item.coffee',
'browser/api/lib/power-monitor.coffee',
'browser/api/lib/protocol.coffee',
'browser/atom/atom.coffee',
'browser/atom/objects-registry.coffee',
'browser/atom/rpc-server.coffee',
'common/api/lib/callbacks-registry.coffee',
'common/api/lib/clipboard.coffee',
'common/api/lib/crash-reporter.coffee',
'common/api/lib/id-weak-map.coffee',
'common/api/lib/shell.coffee',
'renderer/api/lib/ipc.coffee',
'renderer/api/lib/remote.coffee',
'atom/browser/api/lib/app.coffee',
'atom/browser/api/lib/atom-delegate.coffee',
'atom/browser/api/lib/auto-updater.coffee',
'atom/browser/api/lib/browser-window.coffee',
'atom/browser/api/lib/dialog.coffee',
'atom/browser/api/lib/ipc.coffee',
'atom/browser/api/lib/menu.coffee',
'atom/browser/api/lib/menu-item.coffee',
'atom/browser/api/lib/power-monitor.coffee',
'atom/browser/api/lib/protocol.coffee',
'atom/browser/lib/init.coffee',
'atom/browser/lib/objects-registry.coffee',
'atom/browser/lib/rpc-server.coffee',
'atom/common/api/lib/callbacks-registry.coffee',
'atom/common/api/lib/clipboard.coffee',
'atom/common/api/lib/crash-reporter.coffee',
'atom/common/api/lib/id-weak-map.coffee',
'atom/common/api/lib/screen.coffee',
'atom/common/api/lib/shell.coffee',
'atom/common/lib/init.coffee',
'atom/renderer/lib/init.coffee',
'atom/renderer/lib/inspector.coffee',
'atom/renderer/lib/override.coffee',
'atom/renderer/api/lib/ipc.coffee',
'atom/renderer/api/lib/remote.coffee',
],
'lib_sources': [
'app/atom_main_delegate.cc',
'app/atom_main_delegate.h',
'app/atom_main_delegate_mac.mm',
'browser/api/atom_api_app.cc',
'browser/api/atom_api_app.h',
'browser/api/atom_api_auto_updater.cc',
'browser/api/atom_api_auto_updater.h',
'browser/api/atom_api_browser_ipc.cc',
'browser/api/atom_api_browser_ipc.h',
'browser/api/atom_api_dialog.cc',
'browser/api/atom_api_dialog.h',
'browser/api/atom_api_event.cc',
'browser/api/atom_api_event.h',
'browser/api/atom_api_event_emitter.cc',
'browser/api/atom_api_event_emitter.h',
'browser/api/atom_api_menu.cc',
'browser/api/atom_api_menu.h',
'browser/api/atom_api_menu_mac.h',
'browser/api/atom_api_menu_mac.mm',
'browser/api/atom_api_menu_win.cc',
'browser/api/atom_api_menu_win.h',
'browser/api/atom_api_power_monitor.cc',
'browser/api/atom_api_power_monitor.h',
'browser/api/atom_api_protocol.cc',
'browser/api/atom_api_protocol.h',
'browser/api/atom_api_window.cc',
'browser/api/atom_api_window.h',
'browser/api/atom_browser_bindings.cc',
'browser/api/atom_browser_bindings.h',
'browser/auto_updater.cc',
'browser/auto_updater.h',
'browser/auto_updater_delegate.cc',
'browser/auto_updater_delegate.h',
'browser/auto_updater_mac.mm',
'browser/auto_updater_win.cc',
'browser/atom_application_mac.h',
'browser/atom_application_mac.mm',
'browser/atom_application_delegate_mac.h',
'browser/atom_application_delegate_mac.mm',
'browser/atom_browser_client.cc',
'browser/atom_browser_client.h',
'browser/atom_browser_context.cc',
'browser/atom_browser_context.h',
'browser/atom_browser_main_parts.cc',
'browser/atom_browser_main_parts.h',
'browser/atom_browser_main_parts_mac.mm',
'browser/atom_javascript_dialog_manager.cc',
'browser/atom_javascript_dialog_manager.h',
'browser/browser.cc',
'browser/browser.h',
'browser/browser_mac.mm',
'browser/browser_win.cc',
'browser/browser_observer.h',
'browser/native_window.cc',
'browser/native_window.h',
'browser/native_window_mac.h',
'browser/native_window_mac.mm',
'browser/native_window_win.cc',
'browser/native_window_win.h',
'browser/native_window_observer.h',
'browser/net/adapter_request_job.cc',
'browser/net/adapter_request_job.h',
'browser/net/atom_url_request_context_getter.cc',
'browser/net/atom_url_request_context_getter.h',
'browser/net/atom_url_request_job_factory.cc',
'browser/net/atom_url_request_job_factory.h',
'browser/net/url_request_string_job.cc',
'browser/net/url_request_string_job.h',
'browser/ui/accelerator_util.cc',
'browser/ui/accelerator_util.h',
'browser/ui/accelerator_util_mac.mm',
'browser/ui/accelerator_util_win.cc',
'browser/ui/atom_event_processing_window.h',
'browser/ui/atom_event_processing_window.mm',
'browser/ui/atom_menu_controller_mac.h',
'browser/ui/atom_menu_controller_mac.mm',
'browser/ui/file_dialog.h',
'browser/ui/file_dialog_mac.mm',
'browser/ui/file_dialog_win.cc',
'browser/ui/message_box.h',
'browser/ui/message_box_mac.mm',
'browser/ui/message_box_win.cc',
'browser/ui/nsalert_synchronous_sheet_mac.h',
'browser/ui/nsalert_synchronous_sheet_mac.mm',
'browser/ui/win/menu_2.cc',
'browser/ui/win/menu_2.h',
'browser/ui/win/native_menu_win.cc',
'browser/ui/win/native_menu_win.h',
'browser/window_list.cc',
'browser/window_list.h',
'browser/window_list_observer.h',
'common/api/api_messages.cc',
'common/api/api_messages.h',
'common/api/atom_api_clipboard.cc',
'common/api/atom_api_clipboard.h',
'common/api/atom_api_crash_reporter.cc',
'common/api/atom_api_crash_reporter.h',
'common/api/atom_api_id_weak_map.cc',
'common/api/atom_api_id_weak_map.h',
'common/api/atom_api_shell.cc',
'common/api/atom_api_shell.h',
'common/api/atom_api_v8_util.cc',
'common/api/atom_bindings.cc',
'common/api/atom_bindings.h',
'common/api/atom_extensions.cc',
'common/api/atom_extensions.h',
'common/api/object_life_monitor.cc',
'common/api/object_life_monitor.h',
'common/crash_reporter/crash_reporter.cc',
'common/crash_reporter/crash_reporter.h',
'common/crash_reporter/crash_reporter_mac.h',
'common/crash_reporter/crash_reporter_mac.mm',
'common/crash_reporter/crash_reporter_win.cc',
'common/crash_reporter/crash_reporter_win.h',
'common/crash_reporter/win/crash_service.cc',
'common/crash_reporter/win/crash_service.h',
'common/crash_reporter/win/crash_service_main.cc',
'common/crash_reporter/win/crash_service_main.h',
'common/draggable_region.cc',
'common/draggable_region.h',
'common/node_bindings.cc',
'common/node_bindings.h',
'common/node_bindings_mac.cc',
'common/node_bindings_mac.h',
'common/node_bindings_win.cc',
'common/node_bindings_win.h',
'common/options_switches.cc',
'common/options_switches.h',
'common/platform_util.h',
'common/platform_util_mac.mm',
'common/platform_util_win.cc',
'common/v8_conversions.h',
'common/v8_value_converter_impl.cc',
'common/v8_value_converter_impl.h',
'renderer/api/atom_api_renderer_ipc.cc',
'renderer/api/atom_api_renderer_ipc.h',
'renderer/api/atom_renderer_bindings.cc',
'renderer/api/atom_renderer_bindings.h',
'renderer/atom_render_view_observer.cc',
'renderer/atom_render_view_observer.h',
'renderer/atom_renderer_client.cc',
'renderer/atom_renderer_client.h',
'atom/app/atom_main_delegate.cc',
'atom/app/atom_main_delegate.h',
'atom/app/atom_main_delegate_mac.mm',
'atom/browser/api/atom_api_app.cc',
'atom/browser/api/atom_api_app.h',
'atom/browser/api/atom_api_auto_updater.cc',
'atom/browser/api/atom_api_auto_updater.h',
'atom/browser/api/atom_api_browser_ipc.cc',
'atom/browser/api/atom_api_browser_ipc.h',
'atom/browser/api/atom_api_dialog.cc',
'atom/browser/api/atom_api_dialog.h',
'atom/browser/api/atom_api_event.cc',
'atom/browser/api/atom_api_event.h',
'atom/browser/api/atom_api_menu.cc',
'atom/browser/api/atom_api_menu.h',
'atom/browser/api/atom_api_menu_gtk.cc',
'atom/browser/api/atom_api_menu_gtk.h',
'atom/browser/api/atom_api_menu_mac.h',
'atom/browser/api/atom_api_menu_mac.mm',
'atom/browser/api/atom_api_menu_win.cc',
'atom/browser/api/atom_api_menu_win.h',
'atom/browser/api/atom_api_power_monitor.cc',
'atom/browser/api/atom_api_power_monitor.h',
'atom/browser/api/atom_api_protocol.cc',
'atom/browser/api/atom_api_protocol.h',
'atom/browser/api/atom_api_window.cc',
'atom/browser/api/atom_api_window.h',
'atom/browser/api/atom_browser_bindings.cc',
'atom/browser/api/atom_browser_bindings.h',
'atom/browser/auto_updater.cc',
'atom/browser/auto_updater.h',
'atom/browser/auto_updater_delegate.h',
'atom/browser/auto_updater_linux.cc',
'atom/browser/auto_updater_mac.mm',
'atom/browser/auto_updater_win.cc',
'atom/browser/atom_application_mac.h',
'atom/browser/atom_application_mac.mm',
'atom/browser/atom_application_delegate_mac.h',
'atom/browser/atom_application_delegate_mac.mm',
'atom/browser/atom_browser_client.cc',
'atom/browser/atom_browser_client.h',
'atom/browser/atom_browser_context.cc',
'atom/browser/atom_browser_context.h',
'atom/browser/atom_browser_main_parts.cc',
'atom/browser/atom_browser_main_parts.h',
'atom/browser/atom_browser_main_parts_mac.mm',
'atom/browser/atom_javascript_dialog_manager.cc',
'atom/browser/atom_javascript_dialog_manager.h',
'atom/browser/browser.cc',
'atom/browser/browser.h',
'atom/browser/browser_linux.cc',
'atom/browser/browser_mac.mm',
'atom/browser/browser_win.cc',
'atom/browser/browser_observer.h',
'atom/browser/devtools_delegate.cc',
'atom/browser/devtools_delegate.h',
'atom/browser/devtools_web_contents_observer.cc',
'atom/browser/devtools_web_contents_observer.h',
'atom/browser/native_window.cc',
'atom/browser/native_window.h',
'atom/browser/native_window_gtk.cc',
'atom/browser/native_window_gtk.h',
'atom/browser/native_window_mac.h',
'atom/browser/native_window_mac.mm',
'atom/browser/native_window_win.cc',
'atom/browser/native_window_win.h',
'atom/browser/native_window_observer.h',
'atom/browser/net/adapter_request_job.cc',
'atom/browser/net/adapter_request_job.h',
'atom/browser/net/atom_url_request_context_getter.cc',
'atom/browser/net/atom_url_request_context_getter.h',
'atom/browser/net/atom_url_request_job_factory.cc',
'atom/browser/net/atom_url_request_job_factory.h',
'atom/browser/net/url_request_string_job.cc',
'atom/browser/net/url_request_string_job.h',
'atom/browser/ui/accelerator_util.cc',
'atom/browser/ui/accelerator_util.h',
'atom/browser/ui/accelerator_util_gtk.cc',
'atom/browser/ui/accelerator_util_mac.mm',
'atom/browser/ui/accelerator_util_win.cc',
'atom/browser/ui/cocoa/atom_menu_controller.h',
'atom/browser/ui/cocoa/atom_menu_controller.mm',
'atom/browser/ui/cocoa/event_processing_window.h',
'atom/browser/ui/cocoa/event_processing_window.mm',
'atom/browser/ui/file_dialog.h',
'atom/browser/ui/file_dialog_gtk.cc',
'atom/browser/ui/file_dialog_mac.mm',
'atom/browser/ui/file_dialog_win.cc',
'atom/browser/ui/message_box.h',
'atom/browser/ui/message_box_gtk.cc',
'atom/browser/ui/message_box_mac.mm',
'atom/browser/ui/message_box_win.cc',
'atom/browser/ui/win/menu_2.cc',
'atom/browser/ui/win/menu_2.h',
'atom/browser/ui/win/native_menu_win.cc',
'atom/browser/ui/win/native_menu_win.h',
'atom/browser/window_list.cc',
'atom/browser/window_list.h',
'atom/browser/window_list_observer.h',
'atom/common/api/api_messages.cc',
'atom/common/api/api_messages.h',
'atom/common/api/atom_api_clipboard.cc',
'atom/common/api/atom_api_clipboard.h',
'atom/common/api/atom_api_crash_reporter.cc',
'atom/common/api/atom_api_crash_reporter.h',
'atom/common/api/atom_api_event_emitter.cc',
'atom/common/api/atom_api_event_emitter.h',
'atom/common/api/atom_api_id_weak_map.cc',
'atom/common/api/atom_api_id_weak_map.h',
'atom/common/api/atom_api_screen.cc',
'atom/common/api/atom_api_screen.h',
'atom/common/api/atom_api_shell.cc',
'atom/common/api/atom_api_shell.h',
'atom/common/api/atom_api_v8_util.cc',
'atom/common/api/atom_bindings.cc',
'atom/common/api/atom_bindings.h',
'atom/common/api/atom_extensions.cc',
'atom/common/api/atom_extensions.h',
'atom/common/api/object_life_monitor.cc',
'atom/common/api/object_life_monitor.h',
'atom/common/crash_reporter/crash_reporter.cc',
'atom/common/crash_reporter/crash_reporter.h',
'atom/common/crash_reporter/crash_reporter_linux.cc',
'atom/common/crash_reporter/crash_reporter_linux.h',
'atom/common/crash_reporter/crash_reporter_mac.h',
'atom/common/crash_reporter/crash_reporter_mac.mm',
'atom/common/crash_reporter/crash_reporter_win.cc',
'atom/common/crash_reporter/crash_reporter_win.h',
'atom/common/crash_reporter/linux/crash_dump_handler.cc',
'atom/common/crash_reporter/linux/crash_dump_handler.h',
'atom/common/crash_reporter/win/crash_service.cc',
'atom/common/crash_reporter/win/crash_service.h',
'atom/common/crash_reporter/win/crash_service_main.cc',
'atom/common/crash_reporter/win/crash_service_main.h',
'atom/common/draggable_region.cc',
'atom/common/draggable_region.h',
'atom/common/linux/application_info.cc',
'atom/common/node_bindings.cc',
'atom/common/node_bindings.h',
'atom/common/node_bindings_linux.cc',
'atom/common/node_bindings_linux.h',
'atom/common/node_bindings_mac.cc',
'atom/common/node_bindings_mac.h',
'atom/common/node_bindings_win.cc',
'atom/common/node_bindings_win.h',
'atom/common/options_switches.cc',
'atom/common/options_switches.h',
'atom/common/platform_util.h',
'atom/common/platform_util_linux.cc',
'atom/common/platform_util_mac.mm',
'atom/common/platform_util_win.cc',
'atom/common/swap_or_assign.h',
'atom/common/v8/node_common.h',
'atom/common/v8/scoped_persistent.h',
'atom/common/v8/native_type_conversions.h',
'atom/common/v8/v8_value_converter.cc',
'atom/common/v8/v8_value_converter.h',
'atom/renderer/api/atom_api_renderer_ipc.cc',
'atom/renderer/api/atom_api_renderer_ipc.h',
'atom/renderer/api/atom_renderer_bindings.cc',
'atom/renderer/api/atom_renderer_bindings.h',
'atom/renderer/atom_render_view_observer.cc',
'atom/renderer/atom_render_view_observer.h',
'atom/renderer/atom_renderer_client.cc',
'atom/renderer/atom_renderer_client.h',
'chrome/browser/ui/gtk/event_utils.cc',
'chrome/browser/ui/gtk/event_utils.h',
'chrome/browser/ui/gtk/gtk_custom_menu.cc',
'chrome/browser/ui/gtk/gtk_custom_menu.h',
'chrome/browser/ui/gtk/gtk_custom_menu_item.cc',
'chrome/browser/ui/gtk/gtk_custom_menu_item.h',
'chrome/browser/ui/gtk/gtk_util.cc',
'chrome/browser/ui/gtk/gtk_util.h',
'chrome/browser/ui/gtk/gtk_window_util.cc',
'chrome/browser/ui/gtk/gtk_window_util.h',
'chrome/browser/ui/gtk/menu_gtk.cc',
'chrome/browser/ui/gtk/menu_gtk.h',
],
'framework_sources': [
'app/atom_library_main.cc',
'app/atom_library_main.h',
'atom/app/atom_library_main.cc',
'atom/app/atom_library_main.h',
],
'conditions': [
['OS=="win"', {
'app_sources': [
'app/win/resource.h',
'app/win/atom.ico',
'app/win/atom.rc',
'atom/browser/resources/win/resource.h',
'atom/browser/resources/win/atom.ico',
'atom/browser/resources/win/atom.rc',
'<(libchromiumcontent_src_dir)/content/app/startup_helper_win.cc',
],
}], # OS=="win"
],
'fix_framework_link_command': [
'install_name_tool',
'-change',
'@loader_path/../Frameworks/Sparkle.framework/Versions/A/Sparkle',
'@rpath/Sparkle.framework/Versions/A/Sparkle',
'${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}'
],
'atom_source_root': '<!(python tools/atom_source_root.py)',
},
'target_defaults': {
@@ -209,9 +242,8 @@
],
'configurations': {
'Debug': {
'defines': [
'DEBUG',
],
'defines': [ 'DEBUG' ],
'cflags': [ '-g', '-O0' ],
},
},
},
@@ -241,7 +273,7 @@
'<(project_name)_helper',
],
'xcode_settings': {
'INFOPLIST_FILE': 'browser/mac/Info.plist',
'INFOPLIST_FILE': 'atom/browser/resources/mac/Info.plist',
'LD_RUNPATH_SEARCH_PATHS': [
'@executable_path/../Frameworks',
],
@@ -255,23 +287,19 @@
'files': [
'<(PRODUCT_DIR)/<(product_name) Helper.app',
'<(PRODUCT_DIR)/<(framework_name).framework',
'frameworks/Sparkle.framework',
'frameworks/Squirrel.framework',
'frameworks/ReactiveCocoa.framework',
'frameworks/Mantle.framework',
],
},
{
'destination': '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources/browser',
'destination': '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources',
'files': [
'browser/default_app',
'atom/browser/default_app',
],
},
],
'postbuilds': [
{
'postbuild_name': 'Fix Framework Link',
'action': [
'<@(fix_framework_link_command)',
],
},
{
# This postbuid step is responsible for creating the following
# helpers:
@@ -303,13 +331,31 @@
],
},
{
'destination': '<(PRODUCT_DIR)/resources/browser',
'destination': '<(PRODUCT_DIR)/resources',
'files': [
'browser/default_app',
'atom/browser/default_app',
]
},
],
}], # OS=="win"
['OS=="linux"', {
'copies': [
{
'destination': '<(PRODUCT_DIR)',
'files': [
'<(libchromiumcontent_library_dir)/libchromiumcontent.so',
'<(libchromiumcontent_library_dir)/libffmpegsumo.so',
'<(libchromiumcontent_resources_dir)/content_shell.pak',
],
},
{
'destination': '<(PRODUCT_DIR)/resources',
'files': [
'atom/browser/default_app',
]
},
],
}], # OS=="linux"
],
}, # target <(project_name)
{
@@ -317,14 +363,22 @@
'type': 'static_library',
'dependencies': [
'vendor/brightray/brightray.gyp:brightray',
'vendor/node/node.gyp:node',
'vendor/node/node.gyp:node_lib',
],
'sources': [
'<@(lib_sources)',
],
'include_dirs': [
'.',
'vendor',
'vendor/brightray',
# Include directories for uv and node.
'vendor/node/src',
'vendor/node/deps/http_parser',
'vendor/node/deps/uv/include',
# The `node.h` is using `#include"v8.h"`.
'vendor/brightray/vendor/download/libchromiumcontent/src/v8/include',
# The `node.h` is using `#include"ares.h"`.
'vendor/node/deps/cares/include',
],
'direct_dependent_settings': {
'include_dirs': [
@@ -349,12 +403,34 @@
'vendor/breakpad/breakpad.gyp:breakpad_handler',
'vendor/breakpad/breakpad.gyp:breakpad_sender',
],
}],
}], # OS=="win"
['OS=="mac"', {
'dependencies': [
'vendor/breakpad/breakpad.gyp:breakpad',
],
}],
}], # OS=="mac"
['OS=="linux"', {
'link_settings': {
'ldflags': [
# Make binary search for libraries under current directory, so we
# don't have to manually set $LD_LIBRARY_PATH:
# http://serverfault.com/questions/279068/cant-find-so-in-the-same-directory-as-the-executable
'-rpath \$$ORIGIN',
# Make native module dynamic loading work.
'-rdynamic',
],
},
# Required settings of using breakpad.
'include_dirs': [
'vendor/breakpad/src',
],
'cflags': [
'-Wno-empty-body',
],
'dependencies': [
'vendor/breakpad/breakpad.gyp:breakpad_client',
],
}], # OS=="linux"
],
}, # target <(product_name)_lib
{
@@ -381,8 +457,7 @@
'<(RULE_INPUT_PATH)',
'<(PRODUCT_DIR)/<(product_name).app/Contents/Resources/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).js',
],
}], # OS=="mac"
['OS=="win"', {
},{ # OS=="mac"
'outputs': [
'<(PRODUCT_DIR)/resources/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).js',
],
@@ -392,7 +467,7 @@
'<(RULE_INPUT_PATH)',
'<(PRODUCT_DIR)/resources/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).js',
],
}], # OS=="win"
}], # OS=="win" or OS=="linux"
],
},
],
@@ -419,7 +494,7 @@
],
'action': [
'python',
'tools/mac/generate_breakpad_symbols.py',
'tools/posix/generate_breakpad_symbols.py',
'--build-dir=<(PRODUCT_DIR)',
'--binary=<(PRODUCT_DIR)/<(product_name).app/Contents/MacOS/<(product_name)',
'--symbols-dir=<(PRODUCT_DIR)/Atom-Shell.breakpad.syms',
@@ -451,6 +526,49 @@
},
],
}], # OS=="win"
['OS=="linux"', {
'dependencies': [
'vendor/breakpad/breakpad.gyp:dump_syms',
],
'actions': [
{
'action_name': 'Dump Symbols',
'inputs': [
'<(PRODUCT_DIR)/<(project_name)',
],
'outputs': [
'<(PRODUCT_DIR)/Atom-Shell.breakpad.syms',
],
'action': [
'python',
'tools/posix/generate_breakpad_symbols.py',
'--build-dir=<(PRODUCT_DIR)',
'--binary=<(PRODUCT_DIR)/<(project_name)',
'--symbols-dir=<(PRODUCT_DIR)/Atom-Shell.breakpad.syms',
'--libchromiumcontent-dir=<(libchromiumcontent_library_dir)',
'--clear',
'--jobs=16',
],
},
{
'action_name': 'Strip Binary',
'inputs': [
'<(PRODUCT_DIR)/libchromiumcontent.so',
'<(PRODUCT_DIR)/libffmpegsumo.so',
'<(PRODUCT_DIR)/<(project_name)',
# Add the syms folder as input would force this action to run
# after the 'Dump Symbols' action. And since it is a folder,
# it would be ignored by the 'strip' command.
'<(PRODUCT_DIR)/Atom-Shell.breakpad.syms',
],
'outputs': [
# Gyp action requires a output file, add a fake one here.
'<(PRODUCT_DIR)/dummy_file',
],
'action': [ 'strip', '<@(_inputs)' ],
},
],
}], # OS=="linux"
],
}, # target <(project_name>_dump_symbols
],
@@ -478,15 +596,18 @@
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
'frameworks/Sparkle.framework',
'frameworks/Squirrel.framework',
'frameworks/ReactiveCocoa.framework',
'frameworks/Mantle.framework',
],
},
'mac_bundle': 1,
'mac_bundle_resources': [
'browser/mac/MainMenu.xib',
'atom/common/resources/mac/MainMenu.xib',
'<(libchromiumcontent_resources_dir)/content_shell.pak',
],
'xcode_settings': {
'INFOPLIST_FILE': 'atom/common/resources/mac/Info.plist',
'LIBRARY_SEARCH_PATHS': [
'<(libchromiumcontent_library_dir)',
],
@@ -515,12 +636,6 @@
},
],
'postbuilds': [
{
'postbuild_name': 'Fix Framework Link',
'action': [
'<@(fix_framework_link_command)',
],
},
{
'postbuild_name': 'Add symlinks for framework subdirectories',
'action': [
@@ -547,19 +662,11 @@
],
'mac_bundle': 1,
'xcode_settings': {
'INFOPLIST_FILE': 'renderer/mac/Info.plist',
'INFOPLIST_FILE': 'atom/renderer/resources/mac/Info.plist',
'LD_RUNPATH_SEARCH_PATHS': [
'@executable_path/../../..',
],
},
'postbuilds': [
{
'postbuild_name': 'Fix Framework Link',
'action': [
'<@(fix_framework_link_command)',
],
},
],
}, # target helper
],
}], # OS==Mac

View File

@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "app/atom_library_main.h"
#include "atom/app/atom_library_main.h"
#include "app/atom_main_delegate.h"
#include "atom/app/atom_main_delegate.h"
#include "content/public/app/content_main.h"
#if defined(OS_MACOSX)

View File

@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_APP_ATOM_LIBRARY_MAIN_
#define ATOM_APP_ATOM_LIBRARY_MAIN_
#ifndef ATOM_APP_ATOM_LIBRARY_MAIN_H_
#define ATOM_APP_ATOM_LIBRARY_MAIN_H_
#include "base/basictypes.h"
@@ -14,4 +14,4 @@ int AtomMain(int argc, const char* argv[]);
}
#endif // OS_MACOSX
#endif // ATOM_APP_ATOM_LIBRARY_MAIN_
#endif // ATOM_APP_ATOM_LIBRARY_MAIN_H_

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "app/atom_main.h"
#include "atom/app/atom_main.h"
#include <stdlib.h>
#include <string.h>
@@ -15,14 +15,17 @@
#include <windows.h>
#include <shellapi.h>
#include "app/atom_main_delegate.h"
#include "atom/app/atom_main_delegate.h"
#include "base/environment.h"
#include "common/crash_reporter/win/crash_service_main.h"
#include "atom/common/crash_reporter/win/crash_service_main.h"
#include "content/public/app/startup_helper_win.h"
#include "sandbox/win/src/sandbox_types.h"
#else // defined(OS_WIN)
#include "app/atom_library_main.h"
#endif // defined(OS_MACOSX) || defined(OS_LINUX)
#elif defined(OS_LINUX) // defined(OS_WIN)
#include "atom/app/atom_main_delegate.h" // NOLINT
#include "content/public/app/content_main.h"
#else // defined(OS_LINUX)
#include "atom/app/atom_library_main.h"
#endif // defined(OS_MACOSX)
// Declaration of node::Start.
namespace node {
@@ -98,7 +101,18 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
return content::ContentMain(instance, &sandbox_info, &delegate);
}
#else // defined(OS_WIN)
#elif defined(OS_LINUX) // defined(OS_WIN)
int main(int argc, const char* argv[]) {
char* node_indicator = getenv("ATOM_SHELL_INTERNAL_RUN_AS_NODE");
if (node_indicator != NULL && strcmp(node_indicator, "1") == 0)
return node::Start(argc, const_cast<char**>(argv));
atom::AtomMainDelegate delegate;
return content::ContentMain(argc, argv, &delegate);
}
#else // defined(OS_LINUX)
int main(int argc, const char* argv[]) {
char* node_indicator = getenv("ATOM_SHELL_INTERNAL_RUN_AS_NODE");
@@ -108,4 +122,4 @@ int main(int argc, const char* argv[]) {
return AtomMain(argc, argv);
}
#endif // defined(OS_MACOSX) || defined(OS_LINUX)
#endif // defined(OS_MACOSX)

View File

@@ -2,4 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_APP_ATOM_MAIN_H_
#define ATOM_APP_ATOM_MAIN_H_
#include "content/public/app/content_main.h"
#endif // ATOM_APP_ATOM_MAIN_H_

View File

@@ -2,13 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "app/atom_main_delegate.h"
#include "atom/app/atom_main_delegate.h"
#include <string>
#include "base/command_line.h"
#include "base/debug/stack_trace.h"
#include "base/logging.h"
#include "browser/atom_browser_client.h"
#include "atom/browser/atom_browser_client.h"
#include "content/public/common/content_switches.h"
#include "renderer/atom_renderer_client.h"
#include "atom/renderer/atom_renderer_client.h"
#include "ui/base/resource/resource_bundle.h"
#include "base/path_service.h"
@@ -23,19 +26,28 @@ AtomMainDelegate::~AtomMainDelegate() {
bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
// Disable logging out to debug.log on Windows
#if defined(OS_WIN)
logging::InitLogging(
L"debug.log",
logging::LoggingSettings settings;
#if defined(DEBUG)
logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG ,
settings.logging_dest = logging::LOG_TO_ALL;
settings.log_file = L"debug.log";
settings.lock_log = logging::LOCK_LOG_FILE;
settings.delete_old = logging::DELETE_OLD_LOG_FILE;
#else
logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
#endif // defined(NDEBUG)
logging::LOCK_LOG_FILE,
logging::DELETE_OLD_LOG_FILE,
logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS);
logging::SetLogItems(true, false, true, false);
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
#endif
settings.dcheck_state =
logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS;
logging::InitLogging(settings);
#endif // defined(OS_WIN)
// Logging with pid and timestamp.
logging::SetLogItems(true, false, true, false);
// Enable convient stack printing.
#if defined(DEBUG) && defined(OS_LINUX)
base::debug::EnableInProcessStackDumping();
#endif
return brightray::MainDelegate::BasicStartupComplete(exit_code);
}
@@ -43,13 +55,25 @@ void AtomMainDelegate::PreSandboxStartup() {
#if defined(OS_MACOSX)
OverrideChildProcessPath();
OverrideFrameworkBundlePath();
SetProcessName();
#endif
InitializeResourceBundle();
// Disable renderer sandbox for most of node's functions.
CommandLine* command_line = CommandLine::ForCurrentProcess();
std::string process_type = command_line->GetSwitchValueASCII(
switches::kProcessType);
// Only append arguments for browser process.
if (!process_type.empty())
return;
// Add a flag to mark the start of switches added by atom-shell.
command_line->AppendSwitch("atom-shell-switches-start");
// Disable renderer sandbox for most of node's functions.
command_line->AppendSwitch(switches::kNoSandbox);
// Add a flag to mark the end of switches added by atom-shell.
command_line->AppendSwitch("atom-shell-switches-end");
}
void AtomMainDelegate::InitializeResourceBundle() {

View File

@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_APP_ATOM_MAIN_DELEGATE_
#define ATOM_APP_ATOM_MAIN_DELEGATE_
#ifndef ATOM_APP_ATOM_MAIN_DELEGATE_H_
#define ATOM_APP_ATOM_MAIN_DELEGATE_H_
#include "brightray/common/main_delegate.h"
@@ -23,7 +23,6 @@ class AtomMainDelegate : public brightray::MainDelegate {
virtual base::FilePath GetResourcesPakFilePath();
virtual void OverrideChildProcessPath();
virtual void OverrideFrameworkBundlePath();
virtual void SetProcessName();
#endif
private:
@@ -39,4 +38,4 @@ class AtomMainDelegate : public brightray::MainDelegate {
} // namespace atom
#endif // ATOM_APP_ATOM_MAIN_DELEGATE_
#endif // ATOM_APP_ATOM_MAIN_DELEGATE_H_

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "app/atom_main_delegate.h"
#include "atom/app/atom_main_delegate.h"
#import "base/mac/bundle_locations.h"
#import "base/mac/foundation_util.h"
@@ -45,22 +45,4 @@ void AtomMainDelegate::OverrideChildProcessPath() {
PathService::Override(content::CHILD_PROCESS_EXE, helper_path);
}
void AtomMainDelegate::SetProcessName() {
const auto& command_line = *CommandLine::ForCurrentProcess();
auto process_type = command_line.GetSwitchValueASCII(switches::kProcessType);
std::string suffix;
if (process_type == switches::kRendererProcess)
suffix = "Renderer";
else if (process_type == switches::kPluginProcess ||
process_type == switches::kPpapiPluginProcess)
suffix = "Plug-In Host";
else if (process_type == switches::kUtilityProcess)
suffix = "Utility";
else
return;
base::mac::SetProcessName(base::mac::NSToCFCast(base::SysUTF8ToNSString(
brightray::GetApplicationName() + " " + suffix)));
}
} // namespace atom

View File

@@ -2,13 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/api/atom_api_app.h"
#include "atom/browser/api/atom_api_app.h"
#include <string>
#include "base/values.h"
#include "base/command_line.h"
#include "browser/browser.h"
#include "common/v8_conversions.h"
#include "vendor/node/src/node.h"
#include "atom/browser/browser.h"
#include "atom/common/v8/native_type_conversions.h"
#include "atom/common/v8/node_common.h"
namespace atom {
@@ -43,75 +46,68 @@ void App::OnOpenURL(const std::string& url) {
Emit("open-url", &args);
}
void App::OnActivateWithNoOpenWindows() {
Emit("activate-with-no-open-windows");
}
void App::OnWillFinishLaunching() {
Emit("will-finish-launching");
}
void App::OnFinishLaunching() {
Emit("finish-launching");
Emit("ready");
}
// static
v8::Handle<v8::Value> App::New(const v8::Arguments &args) {
v8::HandleScope scope;
void App::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::HandleScope scope(args.GetIsolate());
if (!args.IsConstructCall())
return node::ThrowError("Require constructor call");
new App(args.This());
return args.This();
}
// static
v8::Handle<v8::Value> App::Quit(const v8::Arguments &args) {
v8::HandleScope scope;
void App::Quit(const v8::FunctionCallbackInfo<v8::Value>& args) {
Browser::Get()->Quit();
return v8::Undefined();
}
// static
v8::Handle<v8::Value> App::Exit(const v8::Arguments &args) {
v8::HandleScope scope;
exit(args[0]->IntegerValue());
return v8::Undefined();
}
// static
v8::Handle<v8::Value> App::Terminate(const v8::Arguments &args) {
v8::HandleScope scope;
Browser::Get()->Terminate();
return v8::Undefined();
}
// static
v8::Handle<v8::Value> App::Focus(const v8::Arguments &args) {
v8::HandleScope scope;
void App::Focus(const v8::FunctionCallbackInfo<v8::Value>& args) {
Browser::Get()->Focus();
return v8::Undefined();
}
// static
v8::Handle<v8::Value> App::GetVersion(const v8::Arguments &args) {
v8::HandleScope scope;
std::string version(Browser::Get()->GetVersion());
return v8::String::New(version.data(), version.size());
void App::GetVersion(const v8::FunctionCallbackInfo<v8::Value>& args) {
args.GetReturnValue().Set(ToV8Value(Browser::Get()->GetVersion()));
}
// static
v8::Handle<v8::Value> App::AppendSwitch(const v8::Arguments &args) {
v8::HandleScope scope;
void App::SetVersion(const v8::FunctionCallbackInfo<v8::Value>& args) {
std::string version;
if (!FromV8Arguments(args, &version))
return node::ThrowError("Bad argument");
Browser::Get()->SetVersion(version);
}
// static
void App::GetName(const v8::FunctionCallbackInfo<v8::Value>& args) {
return args.GetReturnValue().Set(ToV8Value(Browser::Get()->GetName()));
}
// static
void App::SetName(const v8::FunctionCallbackInfo<v8::Value>& args) {
std::string name;
if (!FromV8Arguments(args, &name))
return node::ThrowError("Bad argument");
Browser::Get()->SetName(name);
}
// static
void App::AppendSwitch(const v8::FunctionCallbackInfo<v8::Value>& args) {
std::string switch_string;
if (!FromV8Arguments(args, &switch_string))
return node::ThrowError("Bad argument");
@@ -123,28 +119,25 @@ v8::Handle<v8::Value> App::AppendSwitch(const v8::Arguments &args) {
CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switch_string, value);
}
return v8::Undefined();
}
// static
v8::Handle<v8::Value> App::AppendArgument(const v8::Arguments &args) {
v8::HandleScope scope;
void App::AppendArgument(const v8::FunctionCallbackInfo<v8::Value>& args) {
std::string value;
if (!FromV8Arguments(args, &value))
return node::ThrowError("Bad argument");
CommandLine::ForCurrentProcess()->AppendArg(value);
return v8::Undefined();
}
#if defined(OS_MACOSX)
// static
v8::Handle<v8::Value> App::DockBounce(const v8::Arguments& args) {
std::string type = FromV8Value(args[0]);
void App::DockBounce(const v8::FunctionCallbackInfo<v8::Value>& args) {
std::string type;
if (!FromV8Arguments(args, &type))
return node::ThrowError("Bad argument");
int request_id = -1;
if (type == "critical")
@@ -154,42 +147,39 @@ v8::Handle<v8::Value> App::DockBounce(const v8::Arguments& args) {
else
return node::ThrowTypeError("Invalid bounce type");
return v8::Integer::New(request_id);
args.GetReturnValue().Set(request_id);
}
// static
v8::Handle<v8::Value> App::DockCancelBounce(const v8::Arguments& args) {
void App::DockCancelBounce(const v8::FunctionCallbackInfo<v8::Value>& args) {
Browser::Get()->DockCancelBounce(FromV8Value(args[0]));
return v8::Undefined();
}
// static
v8::Handle<v8::Value> App::DockSetBadgeText(const v8::Arguments& args) {
void App::DockSetBadgeText(const v8::FunctionCallbackInfo<v8::Value>& args) {
Browser::Get()->DockSetBadgeText(FromV8Value(args[0]));
return v8::Undefined();
}
// static
v8::Handle<v8::Value> App::DockGetBadgeText(const v8::Arguments& args) {
void App::DockGetBadgeText(const v8::FunctionCallbackInfo<v8::Value>& args) {
std::string text(Browser::Get()->DockGetBadgeText());
return ToV8Value(text);
args.GetReturnValue().Set(ToV8Value(text));
}
#endif // defined(OS_MACOSX)
// static
void App::Initialize(v8::Handle<v8::Object> target) {
v8::HandleScope scope;
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(App::New);
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(New);
t->InstanceTemplate()->SetInternalFieldCount(1);
t->SetClassName(v8::String::NewSymbol("Application"));
NODE_SET_PROTOTYPE_METHOD(t, "quit", Quit);
NODE_SET_PROTOTYPE_METHOD(t, "exit", Exit);
NODE_SET_PROTOTYPE_METHOD(t, "terminate", Terminate);
NODE_SET_PROTOTYPE_METHOD(t, "focus", Focus);
NODE_SET_PROTOTYPE_METHOD(t, "getVersion", GetVersion);
NODE_SET_PROTOTYPE_METHOD(t, "setVersion", SetVersion);
NODE_SET_PROTOTYPE_METHOD(t, "getName", GetName);
NODE_SET_PROTOTYPE_METHOD(t, "setName", SetName);
target->Set(v8::String::NewSymbol("Application"), t->GetFunction());

View File

@@ -5,9 +5,11 @@
#ifndef ATOM_BROWSER_API_ATOM_API_APP_H_
#define ATOM_BROWSER_API_ATOM_API_APP_H_
#include <string>
#include "base/compiler_specific.h"
#include "browser/api/atom_api_event_emitter.h"
#include "browser/browser_observer.h"
#include "atom/browser/browser_observer.h"
#include "atom/common/api/atom_api_event_emitter.h"
namespace atom {
@@ -29,25 +31,27 @@ class App : public EventEmitter,
virtual void OnOpenFile(bool* prevent_default,
const std::string& file_path) OVERRIDE;
virtual void OnOpenURL(const std::string& url) OVERRIDE;
virtual void OnActivateWithNoOpenWindows() OVERRIDE;
virtual void OnWillFinishLaunching() OVERRIDE;
virtual void OnFinishLaunching() OVERRIDE;
private:
static v8::Handle<v8::Value> New(const v8::Arguments &args);
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
static v8::Handle<v8::Value> Quit(const v8::Arguments &args);
static v8::Handle<v8::Value> Exit(const v8::Arguments &args);
static v8::Handle<v8::Value> Terminate(const v8::Arguments &args);
static v8::Handle<v8::Value> Focus(const v8::Arguments &args);
static v8::Handle<v8::Value> GetVersion(const v8::Arguments &args);
static v8::Handle<v8::Value> AppendSwitch(const v8::Arguments &args);
static v8::Handle<v8::Value> AppendArgument(const v8::Arguments &args);
static void Quit(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Focus(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GetVersion(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetVersion(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GetName(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetName(const v8::FunctionCallbackInfo<v8::Value>& args);
static void AppendSwitch(const v8::FunctionCallbackInfo<v8::Value>& args);
static void AppendArgument(const v8::FunctionCallbackInfo<v8::Value>& args);
#if defined(OS_MACOSX)
static v8::Handle<v8::Value> DockBounce(const v8::Arguments& args);
static v8::Handle<v8::Value> DockCancelBounce(const v8::Arguments& args);
static v8::Handle<v8::Value> DockSetBadgeText(const v8::Arguments& args);
static v8::Handle<v8::Value> DockGetBadgeText(const v8::Arguments& args);
static void DockBounce(const v8::FunctionCallbackInfo<v8::Value>& args);
static void DockCancelBounce(const v8::FunctionCallbackInfo<v8::Value>& args);
static void DockSetBadgeText(const v8::FunctionCallbackInfo<v8::Value>& args);
static void DockGetBadgeText(const v8::FunctionCallbackInfo<v8::Value>& args);
#endif // defined(OS_MACOSX)
DISALLOW_COPY_AND_ASSIGN(App);

View File

@@ -0,0 +1,106 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "atom/browser/api/atom_api_auto_updater.h"
#include "base/time/time.h"
#include "base/values.h"
#include "atom/browser/auto_updater.h"
#include "atom/common/v8/native_type_conversions.h"
#include "atom/common/v8/node_common.h"
namespace atom {
namespace api {
AutoUpdater::AutoUpdater(v8::Handle<v8::Object> wrapper)
: EventEmitter(wrapper) {
auto_updater::AutoUpdater::SetDelegate(this);
}
AutoUpdater::~AutoUpdater() {
auto_updater::AutoUpdater::SetDelegate(NULL);
}
void AutoUpdater::OnError(const std::string& error) {
base::ListValue args;
args.AppendString(error);
Emit("error", &args);
}
void AutoUpdater::OnCheckingForUpdate() {
Emit("checking-for-update");
}
void AutoUpdater::OnUpdateAvailable() {
Emit("update-available");
}
void AutoUpdater::OnUpdateNotAvailable() {
Emit("update-not-available");
}
void AutoUpdater::OnUpdateDownloaded(const std::string& release_notes,
const std::string& release_name,
const base::Time& release_date,
const std::string& update_url,
const base::Closure& quit_and_install) {
quit_and_install_ = quit_and_install;
base::ListValue args;
args.AppendString(release_notes);
args.AppendString(release_name);
args.AppendDouble(release_date.ToJsTime());
args.AppendString(update_url);
Emit("update-downloaded-raw", &args);
}
// static
void AutoUpdater::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (!args.IsConstructCall())
return node::ThrowError("Require constructor call");
new AutoUpdater(args.This());
}
// static
void AutoUpdater::SetFeedURL(const v8::FunctionCallbackInfo<v8::Value>& args) {
auto_updater::AutoUpdater::SetFeedURL(FromV8Value(args[0]));
}
// static
void AutoUpdater::CheckForUpdates(
const v8::FunctionCallbackInfo<v8::Value>& args) {
auto_updater::AutoUpdater::CheckForUpdates();
}
// static
void AutoUpdater::QuitAndInstall(
const v8::FunctionCallbackInfo<v8::Value>& args) {
AutoUpdater* self = AutoUpdater::Unwrap<AutoUpdater>(args.This());
if (!self->quit_and_install_.is_null())
self->quit_and_install_.Run();
}
// static
void AutoUpdater::Initialize(v8::Handle<v8::Object> target) {
v8::Local<v8::FunctionTemplate> t(
v8::FunctionTemplate::New(AutoUpdater::New));
t->InstanceTemplate()->SetInternalFieldCount(1);
t->SetClassName(v8::String::NewSymbol("AutoUpdater"));
NODE_SET_PROTOTYPE_METHOD(t, "setFeedUrl", SetFeedURL);
NODE_SET_PROTOTYPE_METHOD(t, "checkForUpdates", CheckForUpdates);
NODE_SET_PROTOTYPE_METHOD(t, "quitAndInstall", QuitAndInstall);
target->Set(v8::String::NewSymbol("AutoUpdater"), t->GetFunction());
}
} // namespace api
} // namespace atom
NODE_MODULE(atom_browser_auto_updater, atom::api::AutoUpdater::Initialize)

View File

@@ -0,0 +1,59 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_API_ATOM_API_AUTO_UPDATER_H_
#define ATOM_BROWSER_API_ATOM_API_AUTO_UPDATER_H_
#include <string>
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "atom/browser/auto_updater_delegate.h"
#include "atom/common/api/atom_api_event_emitter.h"
namespace atom {
namespace api {
class AutoUpdater : public EventEmitter,
public auto_updater::AutoUpdaterDelegate {
public:
virtual ~AutoUpdater();
static void Initialize(v8::Handle<v8::Object> target);
protected:
explicit AutoUpdater(v8::Handle<v8::Object> wrapper);
// AutoUpdaterDelegate implementations.
virtual void OnError(const std::string& error) OVERRIDE;
virtual void OnCheckingForUpdate() OVERRIDE;
virtual void OnUpdateAvailable() OVERRIDE;
virtual void OnUpdateNotAvailable() OVERRIDE;
virtual void OnUpdateDownloaded(
const std::string& release_notes,
const std::string& release_name,
const base::Time& release_date,
const std::string& update_url,
const base::Closure& quit_and_install) OVERRIDE;
private:
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetFeedURL(const v8::FunctionCallbackInfo<v8::Value>& args);
static void CheckForUpdates(const v8::FunctionCallbackInfo<v8::Value>& args);
static void ContinueUpdate(const v8::FunctionCallbackInfo<v8::Value>& args);
static void QuitAndInstall(const v8::FunctionCallbackInfo<v8::Value>& args);
base::Closure quit_and_install_;
DISALLOW_COPY_AND_ASSIGN(AutoUpdater);
};
} // namespace api
} // namespace atom
#endif // ATOM_BROWSER_API_ATOM_API_AUTO_UPDATER_H_

View File

@@ -0,0 +1,48 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "atom/browser/api/atom_api_browser_ipc.h"
#include "atom/common/api/api_messages.h"
#include "atom/common/v8/node_common.h"
#include "atom/common/v8/native_type_conversions.h"
#include "content/public/browser/render_view_host.h"
using content::RenderViewHost;
namespace atom {
namespace api {
// static
void BrowserIPC::Send(const v8::FunctionCallbackInfo<v8::Value>& args) {
string16 channel;
int process_id, routing_id;
scoped_ptr<base::Value> arguments;
if (!FromV8Arguments(args, &channel, &process_id, &routing_id, &arguments))
return node::ThrowTypeError("Bad argument");
DCHECK(arguments && arguments->IsType(base::Value::TYPE_LIST));
RenderViewHost* render_view_host(RenderViewHost::FromID(
process_id, routing_id));
if (!render_view_host)
return node::ThrowError("Invalid render view host");
args.GetReturnValue().Set(render_view_host->Send(new AtomViewMsg_Message(
routing_id,
channel,
*static_cast<base::ListValue*>(arguments.get()))));
}
// static
void BrowserIPC::Initialize(v8::Handle<v8::Object> target) {
NODE_SET_METHOD(target, "send", Send);
}
} // namespace api
} // namespace atom
NODE_MODULE(atom_browser_ipc, atom::api::BrowserIPC::Initialize)

View File

@@ -17,7 +17,7 @@ class BrowserIPC {
static void Initialize(v8::Handle<v8::Object> target);
private:
static v8::Handle<v8::Value> Send(const v8::Arguments &args);
static void Send(const v8::FunctionCallbackInfo<v8::Value>& args);
DISALLOW_IMPLICIT_CONSTRUCTORS(BrowserIPC);
};

View File

@@ -2,16 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/api/atom_api_dialog.h"
#include "atom/browser/api/atom_api_dialog.h"
#include <string>
#include <vector>
#include "base/bind.h"
#include "browser/native_window.h"
#include "browser/ui/file_dialog.h"
#include "browser/ui/message_box.h"
#include "common/v8_conversions.h"
#include "vendor/node/src/node_internals.h"
using node::node_isolate;
#include "atom/browser/native_window.h"
#include "atom/browser/ui/file_dialog.h"
#include "atom/browser/ui/message_box.h"
#include "atom/common/v8/node_common.h"
#include "atom/common/v8/native_type_conversions.h"
namespace atom {
@@ -20,19 +21,17 @@ namespace api {
namespace {
template<typename T>
void CallV8Function(v8::Persistent<v8::Function> callback, T arg) {
DCHECK(!callback.IsEmpty());
void CallV8Function(const RefCountedV8Function& callback, T arg) {
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
v8::HandleScope scope;
v8::Handle<v8::Value> value = ToV8Value(arg);
callback->Call(callback, 1, &value);
callback.Dispose(node_isolate);
callback->NewHandle(node_isolate)->Call(
v8::Context::GetCurrent()->Global(), 1, &value);
}
template<typename T>
void CallV8Function2(v8::Persistent<v8::Function> callback,
bool result,
T arg) {
void CallV8Function2(const RefCountedV8Function& callback, bool result, T arg) {
if (result)
return CallV8Function<T>(callback, arg);
else
@@ -40,8 +39,6 @@ void CallV8Function2(v8::Persistent<v8::Function> callback,
}
void Initialize(v8::Handle<v8::Object> target) {
v8::HandleScope scope;
NODE_SET_METHOD(target, "showMessageBox", ShowMessageBox);
NODE_SET_METHOD(target, "showOpenDialog", ShowOpenDialog);
NODE_SET_METHOD(target, "showSaveDialog", ShowSaveDialog);
@@ -49,9 +46,7 @@ void Initialize(v8::Handle<v8::Object> target) {
} // namespace
v8::Handle<v8::Value> ShowMessageBox(const v8::Arguments &args) {
v8::HandleScope scope;
void ShowMessageBox(const v8::FunctionCallbackInfo<v8::Value>& args) {
int type;
std::vector<std::string> buttons;
std::string title, message, detail;
@@ -59,9 +54,8 @@ v8::Handle<v8::Value> ShowMessageBox(const v8::Arguments &args) {
return node::ThrowTypeError("Bad argument");
NativeWindow* native_window = FromV8Value(args[5]);
v8::Persistent<v8::Function> callback = FromV8Value(args[6]);
if (callback.IsEmpty()) {
if (!args[6]->IsFunction()) {
int chosen = atom::ShowMessageBox(
native_window,
(MessageBoxType)type,
@@ -69,8 +63,9 @@ v8::Handle<v8::Value> ShowMessageBox(const v8::Arguments &args) {
title,
message,
detail);
return scope.Close(v8::Integer::New(chosen));
args.GetReturnValue().Set(chosen);
} else {
RefCountedV8Function callback = FromV8Value(args[6]);
atom::ShowMessageBox(
native_window,
(MessageBoxType)type,
@@ -79,13 +74,10 @@ v8::Handle<v8::Value> ShowMessageBox(const v8::Arguments &args) {
message,
detail,
base::Bind(&CallV8Function<int>, callback));
return v8::Undefined();
}
}
v8::Handle<v8::Value> ShowOpenDialog(const v8::Arguments &args) {
v8::HandleScope scope;
void ShowOpenDialog(const v8::FunctionCallbackInfo<v8::Value>& args) {
std::string title;
base::FilePath default_path;
int properties;
@@ -93,23 +85,23 @@ v8::Handle<v8::Value> ShowOpenDialog(const v8::Arguments &args) {
return node::ThrowTypeError("Bad argument");
NativeWindow* native_window = FromV8Value(args[3]);
v8::Persistent<v8::Function> callback = FromV8Value(args[4]);
if (callback.IsEmpty()) {
if (!args[4]->IsFunction()) {
std::vector<base::FilePath> paths;
if (!file_dialog::ShowOpenDialog(native_window,
title,
default_path,
properties,
&paths))
return v8::Undefined();
return;
v8::Handle<v8::Array> result = v8::Array::New(paths.size());
for (size_t i = 0; i < paths.size(); ++i)
result->Set(i, ToV8Value(paths[i]));
return scope.Close(result);
args.GetReturnValue().Set(result);
} else {
RefCountedV8Function callback = FromV8Value(args[4]);
file_dialog::ShowOpenDialog(
native_window,
title,
@@ -117,37 +109,31 @@ v8::Handle<v8::Value> ShowOpenDialog(const v8::Arguments &args) {
properties,
base::Bind(&CallV8Function2<const std::vector<base::FilePath>&>,
callback));
return v8::Undefined();
}
}
v8::Handle<v8::Value> ShowSaveDialog(const v8::Arguments &args) {
v8::HandleScope scope;
void ShowSaveDialog(const v8::FunctionCallbackInfo<v8::Value>& args) {
std::string title;
base::FilePath default_path;
if (!FromV8Arguments(args, &title, &default_path))
return node::ThrowTypeError("Bad argument");
NativeWindow* native_window = FromV8Value(args[2]);
v8::Persistent<v8::Function> callback = FromV8Value(args[3]);
if (callback.IsEmpty()) {
if (!args[3]->IsFunction()) {
base::FilePath path;
if (!file_dialog::ShowSaveDialog(native_window,
title,
default_path,
&path))
return v8::Undefined();
return scope.Close(ToV8Value(path));
if (file_dialog::ShowSaveDialog(native_window,
title,
default_path,
&path))
args.GetReturnValue().Set(ToV8Value(path));
} else {
RefCountedV8Function callback = FromV8Value(args[3]);
file_dialog::ShowSaveDialog(
native_window,
title,
default_path,
base::Bind(&CallV8Function2<const base::FilePath&>, callback));
return v8::Undefined();
}
}

View File

@@ -11,9 +11,9 @@ namespace atom {
namespace api {
v8::Handle<v8::Value> ShowMessageBox(const v8::Arguments &args);
v8::Handle<v8::Value> ShowOpenDialog(const v8::Arguments &args);
v8::Handle<v8::Value> ShowSaveDialog(const v8::Arguments &args);
void ShowMessageBox(const v8::FunctionCallbackInfo<v8::Value>& args);
void ShowOpenDialog(const v8::FunctionCallbackInfo<v8::Value>& args);
void ShowSaveDialog(const v8::FunctionCallbackInfo<v8::Value>& args);
} // namespace api

View File

@@ -2,19 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/api/atom_api_event.h"
#include "atom/browser/api/atom_api_event.h"
#include "browser/native_window.h"
#include "common/api/api_messages.h"
#include "common/v8_conversions.h"
using node::node_isolate;
#include "atom/common/api/api_messages.h"
#include "atom/common/v8/node_common.h"
#include "atom/common/v8/native_type_conversions.h"
#include "content/public/browser/web_contents.h"
namespace atom {
namespace api {
v8::Persistent<v8::FunctionTemplate> Event::constructor_template_;
ScopedPersistent<v8::Function> Event::constructor_template_;
Event::Event()
: sender_(NULL),
@@ -23,67 +22,58 @@ Event::Event()
}
Event::~Event() {
if (sender_ != NULL)
sender_->RemoveObserver(this);
}
// static
v8::Handle<v8::Object> Event::CreateV8Object() {
v8::HandleScope scope;
if (constructor_template_.IsEmpty()) {
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(New);
constructor_template_ = v8::Persistent<v8::FunctionTemplate>::New(
node_isolate, t);
constructor_template_->InstanceTemplate()->SetInternalFieldCount(1);
constructor_template_->SetClassName(v8::String::NewSymbol("Event"));
t->InstanceTemplate()->SetInternalFieldCount(1);
t->SetClassName(v8::String::NewSymbol("Event"));
NODE_SET_PROTOTYPE_METHOD(t, "preventDefault", PreventDefault);
NODE_SET_PROTOTYPE_METHOD(t, "sendReply", SendReply);
NODE_SET_PROTOTYPE_METHOD(t, "destroy", Destroy);
constructor_template_.reset(t->GetFunction());
}
v8::Handle<v8::Object> v8_event =
constructor_template_->GetFunction()->NewInstance(0, NULL);
return scope.Close(v8_event);
v8::Handle<v8::Function> t = constructor_template_.NewHandle(node_isolate);
return t->NewInstance(0, NULL);
}
void Event::SetSenderAndMessage(NativeWindow* sender, IPC::Message* message) {
void Event::SetSenderAndMessage(content::WebContents* sender,
IPC::Message* message) {
DCHECK(!sender_);
DCHECK(!message_);
sender_ = sender;
message_ = message;
sender_->AddObserver(this);
Observe(sender);
}
void Event::OnWindowClosed() {
void Event::WebContentsDestroyed(content::WebContents* web_contents) {
sender_ = NULL;
message_ = NULL;
}
// static
v8::Handle<v8::Value> Event::New(const v8::Arguments& args) {
void Event::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
Event* event = new Event;
event->Wrap(args.This());
return args.This();
}
// static
v8::Handle<v8::Value> Event::PreventDefault(const v8::Arguments& args) {
void Event::PreventDefault(const v8::FunctionCallbackInfo<v8::Value>& args) {
Event* event = Unwrap<Event>(args.This());
if (event == NULL)
return node::ThrowError("Event is already destroyed");
event->prevent_default_ = true;
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Event::SendReply(const v8::Arguments& args) {
void Event::SendReply(const v8::FunctionCallbackInfo<v8::Value>& args) {
Event* event = Unwrap<Event>(args.This());
if (event == NULL)
return node::ThrowError("Event is already destroyed");
@@ -97,14 +87,11 @@ v8::Handle<v8::Value> Event::SendReply(const v8::Arguments& args) {
event->sender_->Send(event->message_);
delete event;
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Event::Destroy(const v8::Arguments& args) {
void Event::Destroy(const v8::FunctionCallbackInfo<v8::Value>& args) {
delete Unwrap<Event>(args.This());
return v8::Undefined();
}
} // namespace api

View File

@@ -0,0 +1,65 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_API_ATOM_API_EVENT_H_
#define ATOM_BROWSER_API_ATOM_API_EVENT_H_
#include "atom/common/v8/scoped_persistent.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/strings/string16.h"
#include "content/public/browser/web_contents_observer.h"
#include "vendor/node/src/node_object_wrap.h"
namespace IPC {
class Message;
}
namespace atom {
namespace api {
class Event : public node::ObjectWrap,
public content::WebContentsObserver {
public:
virtual ~Event();
// Create a V8 Event object.
static v8::Handle<v8::Object> CreateV8Object();
// Pass the sender and message to be replied.
void SetSenderAndMessage(content::WebContents* sender, IPC::Message* message);
// Whether event.preventDefault() is called.
bool prevent_default() const { return prevent_default_; }
protected:
Event();
// content::WebContentsObserver implementations:
virtual void WebContentsDestroyed(content::WebContents*) OVERRIDE;
private:
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
static void PreventDefault(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SendReply(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Destroy(const v8::FunctionCallbackInfo<v8::Value>& args);
static ScopedPersistent<v8::Function> constructor_template_;
// Replyer for the synchronous messages.
content::WebContents* sender_;
IPC::Message* message_;
bool prevent_default_;
DISALLOW_COPY_AND_ASSIGN(Event);
};
} // namespace api
} // namespace atom
#endif // ATOM_BROWSER_API_ATOM_API_EVENT_H_

View File

@@ -2,10 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/api/atom_api_menu.h"
#include "atom/browser/api/atom_api_menu.h"
#include "browser/ui/accelerator_util.h"
#include "common/v8_conversions.h"
#include <string>
#include "atom/browser/ui/accelerator_util.h"
#include "atom/common/v8/node_common.h"
#include "atom/common/v8/native_type_conversions.h"
#define UNWRAP_MEMNU_AND_CHECK \
Menu* self = ObjectWrap::Unwrap<Menu>(args.This()); \
@@ -23,7 +26,8 @@ v8::Handle<v8::Value> CallDelegate(v8::Handle<v8::Value> default_value,
v8::Handle<v8::Object> menu,
const char* method,
int command_id) {
v8::HandleScope scope;
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
v8::Handle<v8::Value> delegate = menu->Get(v8::String::New("delegate"));
if (!delegate->IsObject())
@@ -36,7 +40,7 @@ v8::Handle<v8::Value> CallDelegate(v8::Handle<v8::Value> default_value,
v8::Handle<v8::Value> argv = v8::Integer::New(command_id);
return scope.Close(
return handle_scope.Close(
function->Call(v8::Context::GetCurrent()->Global(), 1, &argv));
}
@@ -51,32 +55,36 @@ Menu::~Menu() {
}
bool Menu::IsCommandIdChecked(int command_id) const {
v8::HandleScope scope;
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
return CallDelegate(v8::False(),
handle(),
const_cast<Menu*>(this)->handle(),
"isCommandIdChecked",
command_id)->BooleanValue();
}
bool Menu::IsCommandIdEnabled(int command_id) const {
v8::HandleScope scope;
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
return CallDelegate(v8::True(),
handle(),
const_cast<Menu*>(this)->handle(),
"isCommandIdEnabled",
command_id)->BooleanValue();
}
bool Menu::IsCommandIdVisible(int command_id) const {
v8::HandleScope scope;
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
return CallDelegate(v8::True(),
handle(),
const_cast<Menu*>(this)->handle(),
"isCommandIdVisible",
command_id)->BooleanValue();
}
bool Menu::GetAcceleratorForCommandId(int command_id,
ui::Accelerator* accelerator) {
v8::HandleScope scope;
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
v8::Handle<v8::Value> shortcut = CallDelegate(v8::Undefined(),
handle(),
"getAcceleratorForCommandId",
@@ -90,48 +98,48 @@ bool Menu::GetAcceleratorForCommandId(int command_id,
}
bool Menu::IsItemForCommandIdDynamic(int command_id) const {
v8::HandleScope scope;
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
return CallDelegate(v8::False(),
handle(),
const_cast<Menu*>(this)->handle(),
"isItemForCommandIdDynamic",
command_id)->BooleanValue();
}
string16 Menu::GetLabelForCommandId(int command_id) const {
v8::HandleScope scope;
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
return FromV8Value(CallDelegate(v8::False(),
handle(),
const_cast<Menu*>(this)->handle(),
"getLabelForCommandId",
command_id));
}
string16 Menu::GetSublabelForCommandId(int command_id) const {
v8::HandleScope scope;
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
return FromV8Value(CallDelegate(v8::False(),
handle(),
const_cast<Menu*>(this)->handle(),
"getSubLabelForCommandId",
command_id));
}
void Menu::ExecuteCommand(int command_id, int event_flags) {
v8::HandleScope scope;
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
CallDelegate(v8::False(), handle(), "executeCommand", command_id);
}
// static
v8::Handle<v8::Value> Menu::New(const v8::Arguments &args) {
v8::HandleScope scope;
void Menu::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (!args.IsConstructCall())
return node::ThrowError("Require constructor call");
Menu::Create(args.This());
return args.This();
}
// static
v8::Handle<v8::Value> Menu::InsertItem(const v8::Arguments &args) {
void Menu::InsertItem(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_MEMNU_AND_CHECK;
int index, command_id;
@@ -143,12 +151,10 @@ v8::Handle<v8::Value> Menu::InsertItem(const v8::Arguments &args) {
self->model_->AddItem(command_id, label);
else
self->model_->InsertItemAt(index, command_id, label);
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Menu::InsertCheckItem(const v8::Arguments &args) {
void Menu::InsertCheckItem(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_MEMNU_AND_CHECK;
int index, command_id;
@@ -160,12 +166,10 @@ v8::Handle<v8::Value> Menu::InsertCheckItem(const v8::Arguments &args) {
self->model_->AddCheckItem(command_id, label);
else
self->model_->InsertCheckItemAt(index, command_id, label);
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Menu::InsertRadioItem(const v8::Arguments &args) {
void Menu::InsertRadioItem(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_MEMNU_AND_CHECK;
int index, command_id, group_id;
@@ -177,12 +181,10 @@ v8::Handle<v8::Value> Menu::InsertRadioItem(const v8::Arguments &args) {
self->model_->AddRadioItem(command_id, label, group_id);
else
self->model_->InsertRadioItemAt(index, command_id, label, group_id);
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Menu::InsertSeparator(const v8::Arguments &args) {
void Menu::InsertSeparator(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_MEMNU_AND_CHECK;
int index;
@@ -193,12 +195,10 @@ v8::Handle<v8::Value> Menu::InsertSeparator(const v8::Arguments &args) {
self->model_->AddSeparator(ui::NORMAL_SEPARATOR);
else
self->model_->InsertSeparatorAt(index, ui::NORMAL_SEPARATOR);
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Menu::InsertSubMenu(const v8::Arguments &args) {
void Menu::InsertSubMenu(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_MEMNU_AND_CHECK;
int index, command_id;
@@ -215,12 +215,10 @@ v8::Handle<v8::Value> Menu::InsertSubMenu(const v8::Arguments &args) {
else
self->model_->InsertSubMenuAt(
index, command_id, label, submenu->model_.get());
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Menu::SetIcon(const v8::Arguments &args) {
void Menu::SetIcon(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_MEMNU_AND_CHECK;
int index;
@@ -229,12 +227,10 @@ v8::Handle<v8::Value> Menu::SetIcon(const v8::Arguments &args) {
return node::ThrowTypeError("Bad argument");
// FIXME use webkit_glue's image decoder here.
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Menu::SetSublabel(const v8::Arguments &args) {
void Menu::SetSublabel(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_MEMNU_AND_CHECK;
int index;
@@ -243,74 +239,72 @@ v8::Handle<v8::Value> Menu::SetSublabel(const v8::Arguments &args) {
return node::ThrowTypeError("Bad argument");
self->model_->SetSublabel(index, label);
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Menu::Clear(const v8::Arguments &args) {
void Menu::Clear(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_MEMNU_AND_CHECK;
self->model_->Clear();
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Menu::GetIndexOfCommandId(const v8::Arguments &args) {
void Menu::GetIndexOfCommandId(
const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_MEMNU_AND_CHECK;
int index = args[0]->IntegerValue();
return v8::Integer::New(self->model_->GetIndexOfCommandId(index));
int index = FromV8Value(args[0]);
args.GetReturnValue().Set(self->model_->GetIndexOfCommandId(index));
}
// static
v8::Handle<v8::Value> Menu::GetItemCount(const v8::Arguments &args) {
void Menu::GetItemCount(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_MEMNU_AND_CHECK;
return v8::Integer::New(self->model_->GetItemCount());
args.GetReturnValue().Set(self->model_->GetItemCount());
}
// static
v8::Handle<v8::Value> Menu::GetCommandIdAt(const v8::Arguments &args) {
void Menu::GetCommandIdAt(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_MEMNU_AND_CHECK;
int index = args[0]->IntegerValue();
return v8::Integer::New(self->model_->GetCommandIdAt(index));
int index = FromV8Value(args[0]);
args.GetReturnValue().Set(self->model_->GetCommandIdAt(index));
}
// static
v8::Handle<v8::Value> Menu::GetLabelAt(const v8::Arguments &args) {
void Menu::GetLabelAt(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_MEMNU_AND_CHECK;
int index = args[0]->IntegerValue();
return ToV8Value(self->model_->GetLabelAt(index));
int index = FromV8Value(args[0]);
args.GetReturnValue().Set(ToV8Value(self->model_->GetLabelAt(index)));
}
// static
v8::Handle<v8::Value> Menu::GetSublabelAt(const v8::Arguments &args) {
void Menu::GetSublabelAt(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_MEMNU_AND_CHECK;
int index = args[0]->IntegerValue();
return ToV8Value(self->model_->GetSublabelAt(index));
int index = FromV8Value(args[0]);
args.GetReturnValue().Set(ToV8Value(self->model_->GetSublabelAt(index)));
}
// static
v8::Handle<v8::Value> Menu::IsItemCheckedAt(const v8::Arguments &args) {
void Menu::IsItemCheckedAt(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_MEMNU_AND_CHECK;
int index = args[0]->IntegerValue();
return v8::Boolean::New(self->model_->IsItemCheckedAt(index));
int index = FromV8Value(args[0]);
args.GetReturnValue().Set(self->model_->IsItemCheckedAt(index));
}
// static
v8::Handle<v8::Value> Menu::IsEnabledAt(const v8::Arguments &args) {
void Menu::IsEnabledAt(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_MEMNU_AND_CHECK;
return v8::Boolean::New(self->model_->IsEnabledAt(args[0]->IntegerValue()));
int index = FromV8Value(args[0]);
args.GetReturnValue().Set(self->model_->IsEnabledAt(index));
}
// static
v8::Handle<v8::Value> Menu::IsVisibleAt(const v8::Arguments &args) {
void Menu::IsVisibleAt(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_MEMNU_AND_CHECK;
return v8::Boolean::New(self->model_->IsVisibleAt(args[0]->IntegerValue()));
int index = FromV8Value(args[0]);
args.GetReturnValue().Set(self->model_->IsVisibleAt(index));
}
// static
v8::Handle<v8::Value> Menu::Popup(const v8::Arguments &args) {
void Menu::Popup(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_MEMNU_AND_CHECK;
atom::NativeWindow* window;
@@ -318,13 +312,10 @@ v8::Handle<v8::Value> Menu::Popup(const v8::Arguments &args) {
return node::ThrowTypeError("Bad argument");
self->Popup(window);
return v8::Undefined();
}
// static
void Menu::Initialize(v8::Handle<v8::Object> target) {
v8::HandleScope scope;
v8::Local<v8::FunctionTemplate> t(v8::FunctionTemplate::New(Menu::New));
t->InstanceTemplate()->SetInternalFieldCount(1);
t->SetClassName(v8::String::NewSymbol("Menu"));
@@ -351,7 +342,7 @@ void Menu::Initialize(v8::Handle<v8::Object> target) {
NODE_SET_PROTOTYPE_METHOD(t, "popup", Popup);
#if defined(OS_WIN)
#if defined(OS_WIN) || defined(TOOLKIT_GTK)
NODE_SET_PROTOTYPE_METHOD(t, "attachToWindow", AttachToWindow);
#endif

View File

@@ -0,0 +1,88 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_API_ATOM_API_MENU_H_
#define ATOM_BROWSER_API_ATOM_API_MENU_H_
#include "base/memory/scoped_ptr.h"
#include "atom/common/api/atom_api_event_emitter.h"
#include "ui/base/models/simple_menu_model.h"
namespace atom {
class NativeWindow;
namespace api {
class Menu : public EventEmitter,
public ui::SimpleMenuModel::Delegate {
public:
virtual ~Menu();
static Menu* Create(v8::Handle<v8::Object> wrapper);
static void Initialize(v8::Handle<v8::Object> target);
protected:
explicit Menu(v8::Handle<v8::Object> wrapper);
// ui::SimpleMenuModel::Delegate implementations:
virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
virtual bool IsCommandIdVisible(int command_id) const OVERRIDE;
virtual bool GetAcceleratorForCommandId(
int command_id,
ui::Accelerator* accelerator) OVERRIDE;
virtual bool IsItemForCommandIdDynamic(int command_id) const OVERRIDE;
virtual string16 GetLabelForCommandId(int command_id) const OVERRIDE;
virtual string16 GetSublabelForCommandId(int command_id) const OVERRIDE;
virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
virtual void Popup(NativeWindow* window) = 0;
scoped_ptr<ui::SimpleMenuModel> model_;
private:
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
static void InsertItem(const v8::FunctionCallbackInfo<v8::Value>& args);
static void InsertCheckItem(const v8::FunctionCallbackInfo<v8::Value>& args);
static void InsertRadioItem(const v8::FunctionCallbackInfo<v8::Value>& args);
static void InsertSeparator(const v8::FunctionCallbackInfo<v8::Value>& args);
static void InsertSubMenu(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetIcon(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetSublabel(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Clear(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GetIndexOfCommandId(
const v8::FunctionCallbackInfo<v8::Value>& args);
static void GetItemCount(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GetCommandIdAt(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GetLabelAt(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GetSublabelAt(const v8::FunctionCallbackInfo<v8::Value>& args);
static void IsItemCheckedAt(const v8::FunctionCallbackInfo<v8::Value>& args);
static void IsEnabledAt(const v8::FunctionCallbackInfo<v8::Value>& args);
static void IsVisibleAt(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Popup(const v8::FunctionCallbackInfo<v8::Value>& args);
#if defined(OS_WIN) || defined(TOOLKIT_GTK)
static void AttachToWindow(const v8::FunctionCallbackInfo<v8::Value>& args);
#elif defined(OS_MACOSX)
static void SetApplicationMenu(
const v8::FunctionCallbackInfo<v8::Value>& args);
static void SendActionToFirstResponder(
const v8::FunctionCallbackInfo<v8::Value>& args);
#endif
DISALLOW_COPY_AND_ASSIGN(Menu);
};
} // namespace api
} // namespace atom
#endif // ATOM_BROWSER_API_ATOM_API_MENU_H_

View File

@@ -0,0 +1,64 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "atom/browser/api/atom_api_menu_gtk.h"
#include "atom/browser/native_window_gtk.h"
#include "atom/common/v8/native_type_conversions.h"
#include "content/public/browser/render_widget_host_view.h"
#include "ui/gfx/point.h"
#include "ui/gfx/screen.h"
#include "atom/common/v8/node_common.h"
namespace atom {
namespace api {
MenuGtk::MenuGtk(v8::Handle<v8::Object> wrapper)
: Menu(wrapper) {
}
MenuGtk::~MenuGtk() {
}
void MenuGtk::Popup(NativeWindow* native_window) {
uint32_t triggering_event_time;
gfx::Point point;
GdkEventButton* event = native_window->GetWebContents()->
GetRenderWidgetHostView()->GetLastMouseDown();
if (event) {
triggering_event_time = event->time;
point = gfx::Point(event->x_root, event->y_root);
} else {
triggering_event_time = GDK_CURRENT_TIME;
point = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint();
}
menu_gtk_.reset(new ::MenuGtk(this, model_.get()));
menu_gtk_->PopupAsContext(point, triggering_event_time);
}
// static
void Menu::AttachToWindow(const v8::FunctionCallbackInfo<v8::Value>& args) {
Menu* self = ObjectWrap::Unwrap<Menu>(args.This());
if (self == NULL)
return node::ThrowError("Menu is already destroyed");
NativeWindow* native_window;
if (!FromV8Arguments(args, &native_window))
return node::ThrowTypeError("Bad argument");
static_cast<NativeWindowGtk*>(native_window)->SetMenu(self->model_.get());
}
// static
Menu* Menu::Create(v8::Handle<v8::Object> wrapper) {
return new MenuGtk(wrapper);
}
} // namespace api
} // namespace atom

View File

@@ -0,0 +1,34 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_API_ATOM_API_MENU_GTK_H_
#define ATOM_BROWSER_API_ATOM_API_MENU_GTK_H_
#include "atom/browser/api/atom_api_menu.h"
#include "chrome/browser/ui/gtk/menu_gtk.h"
namespace atom {
namespace api {
class MenuGtk : public Menu,
public ::MenuGtk::Delegate {
public:
explicit MenuGtk(v8::Handle<v8::Object> wrapper);
virtual ~MenuGtk();
protected:
virtual void Popup(NativeWindow* window) OVERRIDE;
private:
scoped_ptr<::MenuGtk> menu_gtk_;
DISALLOW_COPY_AND_ASSIGN(MenuGtk);
};
} // namespace api
} // namespace atom
#endif // ATOM_BROWSER_API_ATOM_API_MENU_GTK_H_

View File

@@ -5,9 +5,11 @@
#ifndef ATOM_BROWSER_API_ATOM_API_MENU_MAC_H_
#define ATOM_BROWSER_API_ATOM_API_MENU_MAC_H_
#include "browser/api/atom_api_menu.h"
#include "atom/browser/api/atom_api_menu.h"
#import "browser/ui/atom_menu_controller_mac.h"
#include <string>
#import "atom/browser/ui/cocoa/atom_menu_controller.h"
namespace atom {
@@ -21,7 +23,7 @@ class MenuMac : public Menu {
protected:
virtual void Popup(NativeWindow* window) OVERRIDE;
scoped_nsobject<AtomMenuController> menu_controller_;
base::scoped_nsobject<AtomMenuController> menu_controller_;
private:
friend class Menu;

View File

@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "browser/api/atom_api_menu_mac.h"
#import "atom/browser/api/atom_api_menu_mac.h"
#include "base/message_loop.h"
#include "base/mac/scoped_sending_event.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/sys_string_conversions.h"
#include "browser/native_window.h"
#include "common/v8_conversions.h"
#include "atom/browser/native_window.h"
#include "atom/common/v8/node_common.h"
#include "atom/common/v8/native_type_conversions.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
@@ -24,7 +24,7 @@ MenuMac::~MenuMac() {
}
void MenuMac::Popup(NativeWindow* native_window) {
scoped_nsobject<AtomMenuController> menu_controller(
base::scoped_nsobject<AtomMenuController> menu_controller(
[[AtomMenuController alloc] initWithModel:model_.get()]);
NSWindow* window = native_window->GetNativeWindow();
@@ -44,22 +44,10 @@ void MenuMac::Popup(NativeWindow* native_window) {
clickCount:1
pressure:1.0];
{
// Make sure events can be pumped while the menu is up.
MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
// One of the events that could be pumped is |window.close()|.
// User-initiated event-tracking loops protect against this by
// setting flags in -[CrApplication sendEvent:], but since
// web-content menus are initiated by IPC message the setup has to
// be done manually.
base::mac::ScopedSendingEvent sendingEventScoper;
// Show the menu.
[NSMenu popUpContextMenu:[menu_controller menu]
withEvent:clickEvent
forView:web_contents->GetView()->GetContentNativeView()];
}
// Show the menu.
[NSMenu popUpContextMenu:[menu_controller menu]
withEvent:clickEvent
forView:web_contents->GetView()->GetContentNativeView()];
}
// static
@@ -71,9 +59,7 @@ void MenuMac::SendActionToFirstResponder(const std::string& action) {
}
// static
v8::Handle<v8::Value> Menu::SetApplicationMenu(const v8::Arguments &args) {
v8::HandleScope scope;
void Menu::SetApplicationMenu(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (!args[0]->IsObject())
return node::ThrowTypeError("Bad argument");
@@ -81,28 +67,22 @@ v8::Handle<v8::Value> Menu::SetApplicationMenu(const v8::Arguments &args) {
if (!menu)
return node::ThrowError("Menu is destroyed");
scoped_nsobject<AtomMenuController> menu_controller(
base::scoped_nsobject<AtomMenuController> menu_controller(
[[AtomMenuController alloc] initWithModel:menu->model_.get()]);
[NSApp setMainMenu:[menu_controller menu]];
// Ensure the menu_controller_ is destroyed after main menu is set.
menu_controller.swap(menu->menu_controller_);
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Menu::SendActionToFirstResponder(
const v8::Arguments &args) {
v8::HandleScope scope;
void Menu::SendActionToFirstResponder(
const v8::FunctionCallbackInfo<v8::Value>& args) {
std::string action;
if (!FromV8Arguments(args, &action))
return node::ThrowTypeError("Bad argument");
MenuMac::SendActionToFirstResponder(action);
return v8::Undefined();
}
// static

View File

@@ -2,14 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/api/atom_api_menu_win.h"
#include "atom/browser/api/atom_api_menu_win.h"
#include "browser/native_window_win.h"
#include "browser/ui/win/menu_2.h"
#include "common/v8_conversions.h"
#include "atom/browser/native_window_win.h"
#include "atom/browser/ui/win/menu_2.h"
#include "atom/common/v8/native_type_conversions.h"
#include "ui/gfx/point.h"
#include "ui/gfx/screen.h"
#include "atom/common/v8/node_common.h"
namespace atom {
namespace api {
@@ -28,9 +30,7 @@ void MenuWin::Popup(NativeWindow* native_window) {
}
// static
v8::Handle<v8::Value> Menu::AttachToWindow(const v8::Arguments& args) {
v8::HandleScope scope;
void Menu::AttachToWindow(const v8::FunctionCallbackInfo<v8::Value>& args) {
Menu* self = ObjectWrap::Unwrap<Menu>(args.This());
if (self == NULL)
return node::ThrowError("Menu is already destroyed");
@@ -40,8 +40,6 @@ v8::Handle<v8::Value> Menu::AttachToWindow(const v8::Arguments& args) {
return node::ThrowTypeError("Bad argument");
static_cast<NativeWindowWin*>(native_window)->SetMenu(self->model_.get());
return v8::Undefined();
}
// static

View File

@@ -5,7 +5,7 @@
#ifndef ATOM_BROWSER_API_ATOM_API_MENU_WIN_H_
#define ATOM_BROWSER_API_ATOM_API_MENU_WIN_H_
#include "browser/api/atom_api_menu.h"
#include "atom/browser/api/atom_api_menu.h"
namespace atom {

View File

@@ -2,9 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/api/atom_api_power_monitor.h"
#include "atom/browser/api/atom_api_power_monitor.h"
#include "base/power_monitor/power_monitor.h"
#include "base/power_monitor/power_monitor_device_source.h"
#include "atom/common/v8/node_common.h"
namespace atom {
@@ -35,20 +38,18 @@ void PowerMonitor::OnResume() {
}
// static
v8::Handle<v8::Value> PowerMonitor::New(const v8::Arguments& args) {
v8::HandleScope scope;
void PowerMonitor::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (!args.IsConstructCall())
return node::ThrowError("Require constructor call");
new PowerMonitor(args.This());
return args.This();
}
// static
void PowerMonitor::Initialize(v8::Handle<v8::Object> target) {
v8::HandleScope scope;
#if defined(OS_MACOSX)
base::PowerMonitorDeviceSource::AllocateSystemIOPorts();
#endif
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(
PowerMonitor::New);

View File

@@ -5,10 +5,9 @@
#ifndef ATOM_BROWSER_API_ATOM_API_POWER_MONITOR_H_
#define ATOM_BROWSER_API_ATOM_API_POWER_MONITOR_H_
#include "browser/api/atom_api_event_emitter.h"
#include "base/compiler_specific.h"
#include "base/power_monitor/power_observer.h"
#include "atom/common/api/atom_api_event_emitter.h"
namespace atom {
@@ -29,7 +28,7 @@ class PowerMonitor : public EventEmitter,
virtual void OnResume() OVERRIDE;
private:
static v8::Handle<v8::Value> New(const v8::Arguments &args);
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
DISALLOW_COPY_AND_ASSIGN(PowerMonitor);
};

View File

@@ -2,18 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/api/atom_api_protocol.h"
#include "atom/browser/api/atom_api_protocol.h"
#include "base/stl_util.h"
#include "browser/atom_browser_context.h"
#include "browser/net/adapter_request_job.h"
#include "browser/net/atom_url_request_context_getter.h"
#include "browser/net/atom_url_request_job_factory.h"
#include "common/v8_conversions.h"
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/net/adapter_request_job.h"
#include "atom/browser/net/atom_url_request_context_getter.h"
#include "atom/browser/net/atom_url_request_job_factory.h"
#include "atom/common/v8/native_type_conversions.h"
#include "content/public/browser/browser_thread.h"
#include "net/url_request/url_request_context.h"
#include "vendor/node/src/node.h"
#include "vendor/node/src/node_internals.h"
#include "atom/common/v8/node_common.h"
namespace atom {
@@ -24,10 +24,10 @@ typedef net::URLRequestJobFactory::ProtocolHandler ProtocolHandler;
namespace {
// The protocol module object.
v8::Persistent<v8::Object> g_protocol_object;
ScopedPersistent<v8::Object> g_protocol_object;
// Registered protocol handlers.
typedef std::map<std::string, v8::Persistent<v8::Function>> HandlersMap;
typedef std::map<std::string, RefCountedV8Function> HandlersMap;
static HandlersMap g_handlers;
static const char* kEarlyUseProtocolError = "This method can only be used"
@@ -35,25 +35,24 @@ static const char* kEarlyUseProtocolError = "This method can only be used"
// Emit an event for the protocol module.
void EmitEventInUI(const std::string& event, const std::string& parameter) {
v8::HandleScope scope;
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
v8::Handle<v8::Value> argv[] = {
ToV8Value(event),
ToV8Value(parameter),
ToV8Value(event),
ToV8Value(parameter),
};
node::MakeCallback(g_protocol_object, "emit", arraysize(argv), argv);
node::MakeCallback(g_protocol_object.NewHandle(node_isolate),
"emit", 2, argv);
}
// Convert the URLRequest object to V8 object.
v8::Handle<v8::Object> ConvertURLRequestToV8Object(
const net::URLRequest* request) {
v8::Local<v8::Object> obj = v8::Object::New();
obj->Set(v8::String::New("method"),
v8::String::New(request->method().c_str()));
obj->Set(v8::String::New("url"),
v8::String::New(request->url().spec().c_str()));
obj->Set(v8::String::New("referrer"),
v8::String::New(request->referrer().c_str()));
obj->Set(ToV8Value("method"), ToV8Value(request->method()));
obj->Set(ToV8Value("url"), ToV8Value(request->url().spec()));
obj->Set(ToV8Value("referrer"), ToV8Value(request->referrer()));
return obj;
}
@@ -74,13 +73,16 @@ class CustomProtocolRequestJob : public AdapterRequestJob {
virtual void GetJobTypeInUI() OVERRIDE {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
// Call the JS handler.
v8::HandleScope scope;
v8::Handle<v8::Value> argv[] = {
ConvertURLRequestToV8Object(request()),
};
v8::Handle<v8::Value> result = g_handlers[request()->url().scheme()]->Call(
v8::Context::GetCurrent()->Global(), arraysize(argv), argv);
RefCountedV8Function callback = g_handlers[request()->url().scheme()];
v8::Handle<v8::Value> result = callback->NewHandle(node_isolate)->Call(
v8::Context::GetCurrent()->Global(), 1, argv);
// Determine the type of the job we are going to create.
if (result->IsString()) {
@@ -180,14 +182,15 @@ class CustomProtocolHandler : public ProtocolHandler {
} // namespace
// static
v8::Handle<v8::Value> Protocol::RegisterProtocol(const v8::Arguments& args) {
void Protocol::RegisterProtocol(
const v8::FunctionCallbackInfo<v8::Value>& args) {
std::string scheme;
v8::Persistent<v8::Function> callback;
RefCountedV8Function callback;
if (!FromV8Arguments(args, &scheme, &callback))
return node::ThrowTypeError("Bad argument");
if (g_handlers.find(scheme) != g_handlers.end() ||
net::URLRequest::IsHandledProtocol(scheme))
GetRequestJobFactory()->IsHandledProtocol(scheme))
return node::ThrowError("The scheme is already registered");
if (AtomBrowserContext::Get()->url_request_context_getter() == NULL)
@@ -199,12 +202,11 @@ v8::Handle<v8::Value> Protocol::RegisterProtocol(const v8::Arguments& args) {
content::BrowserThread::PostTask(content::BrowserThread::IO,
FROM_HERE,
base::Bind(&RegisterProtocolInIO, scheme));
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Protocol::UnregisterProtocol(const v8::Arguments& args) {
void Protocol::UnregisterProtocol(
const v8::FunctionCallbackInfo<v8::Value>& args) {
std::string scheme;
if (!FromV8Arguments(args, &scheme))
return node::ThrowTypeError("Bad argument");
@@ -221,19 +223,23 @@ v8::Handle<v8::Value> Protocol::UnregisterProtocol(const v8::Arguments& args) {
content::BrowserThread::PostTask(content::BrowserThread::IO,
FROM_HERE,
base::Bind(&UnregisterProtocolInIO, scheme));
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Protocol::IsHandledProtocol(const v8::Arguments& args) {
return ToV8Value(net::URLRequest::IsHandledProtocol(FromV8Value(args[0])));
}
// static
v8::Handle<v8::Value> Protocol::InterceptProtocol(const v8::Arguments& args) {
void Protocol::IsHandledProtocol(
const v8::FunctionCallbackInfo<v8::Value>& args) {
std::string scheme;
v8::Persistent<v8::Function> callback;
if (!FromV8Arguments(args, &scheme))
return node::ThrowTypeError("Bad argument");
args.GetReturnValue().Set(GetRequestJobFactory()->IsHandledProtocol(scheme));
}
// static
void Protocol::InterceptProtocol(
const v8::FunctionCallbackInfo<v8::Value>& args) {
std::string scheme;
RefCountedV8Function callback;
if (!FromV8Arguments(args, &scheme, &callback))
return node::ThrowTypeError("Bad argument");
@@ -252,11 +258,11 @@ v8::Handle<v8::Value> Protocol::InterceptProtocol(const v8::Arguments& args) {
content::BrowserThread::PostTask(content::BrowserThread::IO,
FROM_HERE,
base::Bind(&InterceptProtocolInIO, scheme));
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Protocol::UninterceptProtocol(const v8::Arguments& args) {
void Protocol::UninterceptProtocol(
const v8::FunctionCallbackInfo<v8::Value>& args) {
std::string scheme;
if (!FromV8Arguments(args, &scheme))
return node::ThrowTypeError("Bad argument");
@@ -274,7 +280,6 @@ v8::Handle<v8::Value> Protocol::UninterceptProtocol(const v8::Arguments& args) {
FROM_HERE,
base::Bind(&UninterceptProtocolInIO,
scheme));
return v8::Undefined();
}
// static
@@ -361,14 +366,17 @@ void Protocol::UninterceptProtocolInIO(const std::string& scheme) {
// static
void Protocol::Initialize(v8::Handle<v8::Object> target) {
// Remember the protocol object, used for emitting event later.
g_protocol_object = v8::Persistent<v8::Object>::New(
node::node_isolate, target);
g_protocol_object.reset(target);
node::SetMethod(target, "registerProtocol", RegisterProtocol);
node::SetMethod(target, "unregisterProtocol", UnregisterProtocol);
node::SetMethod(target, "isHandledProtocol", IsHandledProtocol);
node::SetMethod(target, "interceptProtocol", InterceptProtocol);
node::SetMethod(target, "uninterceptProtocol", UninterceptProtocol);
// Make sure the job factory has been created.
AtomBrowserContext::Get()->url_request_context_getter()->
GetURLRequestContext();
NODE_SET_METHOD(target, "registerProtocol", RegisterProtocol);
NODE_SET_METHOD(target, "unregisterProtocol", UnregisterProtocol);
NODE_SET_METHOD(target, "isHandledProtocol", IsHandledProtocol);
NODE_SET_METHOD(target, "interceptProtocol", InterceptProtocol);
NODE_SET_METHOD(target, "uninterceptProtocol", UninterceptProtocol);
}
} // namespace api

View File

@@ -20,12 +20,16 @@ class Protocol {
static void Initialize(v8::Handle<v8::Object> target);
private:
static v8::Handle<v8::Value> RegisterProtocol(const v8::Arguments& args);
static v8::Handle<v8::Value> UnregisterProtocol(const v8::Arguments& args);
static v8::Handle<v8::Value> IsHandledProtocol(const v8::Arguments& args);
static void RegisterProtocol(const v8::FunctionCallbackInfo<v8::Value>& args);
static void UnregisterProtocol(
const v8::FunctionCallbackInfo<v8::Value>& args);
static void IsHandledProtocol(
const v8::FunctionCallbackInfo<v8::Value>& args);
static v8::Handle<v8::Value> InterceptProtocol(const v8::Arguments& args);
static v8::Handle<v8::Value> UninterceptProtocol(const v8::Arguments& args);
static void InterceptProtocol(
const v8::FunctionCallbackInfo<v8::Value>& args);
static void UninterceptProtocol(
const v8::FunctionCallbackInfo<v8::Value>& args);
static void RegisterProtocolInIO(const std::string& scheme);
static void UnregisterProtocolInIO(const std::string& scheme);

View File

@@ -2,21 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/api/atom_api_window.h"
#include "atom/browser/api/atom_api_window.h"
#include "base/values.h"
#include "browser/native_window.h"
#include "common/v8_conversions.h"
#include "common/v8_value_converter_impl.h"
#include <string>
#include "base/bind.h"
#include "base/process/kill.h"
#include "atom/browser/native_window.h"
#include "atom/common/v8/native_type_conversions.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/render_process_host.h"
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
#include "atom/common/v8/node_common.h"
#include "vendor/node/src/node_buffer.h"
using content::V8ValueConverter;
using content::NavigationController;
using node::ObjectWrap;
@@ -79,144 +81,124 @@ void Window::OnRendererResponsive() {
Emit("responsive");
}
void Window::OnRenderViewDeleted(int process_id, int routing_id) {
base::ListValue args;
args.AppendInteger(process_id);
args.AppendInteger(routing_id);
Emit("render-view-deleted", &args);
}
void Window::OnRendererCrashed() {
Emit("crashed");
}
void Window::OnCapturePageDone(v8::Persistent<v8::Function> callback,
void Window::OnCapturePageDone(const RefCountedV8Function& callback,
const std::vector<unsigned char>& data) {
v8::HandleScope scope;
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
// TODO(zcbenz): Use new Buffer API when we updated to node v0.12.x.
node::Buffer* buffer = node::Buffer::New(
v8::Local<v8::Value> buffer = node::Buffer::New(
reinterpret_cast<const char*>(data.data()),
data.size());
v8::Handle<v8::Value> arg = buffer->handle_;
callback->Call(v8::Context::GetCurrent()->Global(), 1, &arg);
callback.Dispose(v8::Isolate::GetCurrent());
callback->NewHandle(node_isolate)->Call(
v8::Context::GetCurrent()->Global(), 1, &buffer);
}
// static
v8::Handle<v8::Value> Window::New(const v8::Arguments &args) {
v8::HandleScope scope;
void Window::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (!args.IsConstructCall())
return node::ThrowError("Require constructor call");
if (!args[0]->IsObject())
return node::ThrowTypeError("Need options creating Window");
scoped_ptr<V8ValueConverter> converter(new V8ValueConverterImpl());
scoped_ptr<base::Value> options(
converter->FromV8Value(args[0], v8::Context::GetCurrent()));
scoped_ptr<base::Value> options;
if (!FromV8Arguments(args, &options))
return node::ThrowTypeError("Bad argument");
if (!options || !options->IsType(base::Value::TYPE_DICTIONARY))
return node::ThrowTypeError("Invalid options");
return node::ThrowTypeError("Options must be dictionary");
new Window(args.This(), static_cast<base::DictionaryValue*>(options.get()));
// Give js code a chance to do initialization.
node::MakeCallback(args.This(), "_init", 0, NULL);
return args.This();
}
// static
v8::Handle<v8::Value> Window::Destroy(const v8::Arguments &args) {
void Window::Destroy(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
base::ProcessHandle handle = self->window_->GetRenderProcessHandle();
delete self;
return v8::Undefined();
// Make sure the renderer process is terminated, it could happen that the
// renderer process became a zombie.
base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(base::IgnoreResult(base::KillProcess), handle, 0, false),
base::TimeDelta::FromMilliseconds(5000));
}
// static
v8::Handle<v8::Value> Window::Close(const v8::Arguments &args) {
void Window::Close(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
self->window_->Close();
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::Focus(const v8::Arguments &args) {
void Window::Focus(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
self->window_->Focus(args[0]->IsBoolean() ? args[0]->BooleanValue(): true);
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::IsFocused(const v8::Arguments &args) {
void Window::IsFocused(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
return ToV8Value(self->window_->IsFocused());
args.GetReturnValue().Set(self->window_->IsFocused());
}
// static
v8::Handle<v8::Value> Window::Show(const v8::Arguments &args) {
void Window::Show(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
self->window_->Show();
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::Hide(const v8::Arguments &args) {
void Window::Hide(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
self->window_->Hide();
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::IsVisible(const v8::Arguments& args) {
void Window::IsVisible(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
return ToV8Value(self->window_->IsVisible());
return args.GetReturnValue().Set(self->window_->IsVisible());
}
// static
v8::Handle<v8::Value> Window::Maximize(const v8::Arguments &args) {
void Window::Maximize(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
self->window_->Maximize();
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::Unmaximize(const v8::Arguments &args) {
void Window::Unmaximize(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
self->window_->Unmaximize();
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::Minimize(const v8::Arguments &args) {
void Window::Minimize(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
self->window_->Minimize();
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::Restore(const v8::Arguments &args) {
void Window::Restore(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
self->window_->Restore();
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::SetFullscreen(const v8::Arguments &args) {
void Window::SetFullscreen(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
bool fs;
@@ -224,18 +206,16 @@ v8::Handle<v8::Value> Window::SetFullscreen(const v8::Arguments &args) {
return node::ThrowTypeError("Bad argument");
self->window_->SetFullscreen(fs);
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::IsFullscreen(const v8::Arguments &args) {
void Window::IsFullscreen(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
return ToV8Value(self->window_->IsFullscreen());
args.GetReturnValue().Set(self->window_->IsFullscreen());
}
// static
v8::Handle<v8::Value> Window::SetSize(const v8::Arguments &args) {
void Window::SetSize(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
int width, height;
@@ -243,11 +223,10 @@ v8::Handle<v8::Value> Window::SetSize(const v8::Arguments &args) {
return node::ThrowTypeError("Bad argument");
self->window_->SetSize(gfx::Size(width, height));
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::GetSize(const v8::Arguments &args) {
void Window::GetSize(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
gfx::Size size = self->window_->GetSize();
@@ -255,11 +234,11 @@ v8::Handle<v8::Value> Window::GetSize(const v8::Arguments &args) {
ret->Set(0, ToV8Value(size.width()));
ret->Set(1, ToV8Value(size.height()));
return ret;
args.GetReturnValue().Set(ret);
}
// static
v8::Handle<v8::Value> Window::SetMinimumSize(const v8::Arguments &args) {
void Window::SetMinimumSize(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
int width, height;
@@ -267,11 +246,10 @@ v8::Handle<v8::Value> Window::SetMinimumSize(const v8::Arguments &args) {
return node::ThrowTypeError("Bad argument");
self->window_->SetMinimumSize(gfx::Size(width, height));
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::GetMinimumSize(const v8::Arguments &args) {
void Window::GetMinimumSize(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
gfx::Size size = self->window_->GetMinimumSize();
@@ -279,24 +257,22 @@ v8::Handle<v8::Value> Window::GetMinimumSize(const v8::Arguments &args) {
ret->Set(0, ToV8Value(size.width()));
ret->Set(1, ToV8Value(size.height()));
return ret;
args.GetReturnValue().Set(ret);
}
// static
v8::Handle<v8::Value> Window::SetMaximumSize(const v8::Arguments &args) {
void Window::SetMaximumSize(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
int width, height;
if (!FromV8Arguments(args, &width, &height))
return node::ThrowTypeError("Bad argument");
self->window_->SetMaximumSize(gfx::Size(width, height));
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::GetMaximumSize(const v8::Arguments &args) {
void Window::GetMaximumSize(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
gfx::Size size = self->window_->GetMaximumSize();
@@ -304,11 +280,11 @@ v8::Handle<v8::Value> Window::GetMaximumSize(const v8::Arguments &args) {
ret->Set(0, ToV8Value(size.width()));
ret->Set(1, ToV8Value(size.height()));
return ret;
args.GetReturnValue().Set(ret);
}
// static
v8::Handle<v8::Value> Window::SetResizable(const v8::Arguments &args) {
void Window::SetResizable(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
bool resizable;
@@ -316,18 +292,16 @@ v8::Handle<v8::Value> Window::SetResizable(const v8::Arguments &args) {
return node::ThrowTypeError("Bad argument");
self->window_->SetResizable(resizable);
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::IsResizable(const v8::Arguments &args) {
void Window::IsResizable(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
return ToV8Value(self->window_->IsResizable());
args.GetReturnValue().Set(self->window_->IsResizable());
}
// static
v8::Handle<v8::Value> Window::SetAlwaysOnTop(const v8::Arguments &args) {
void Window::SetAlwaysOnTop(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
bool top;
@@ -335,27 +309,22 @@ v8::Handle<v8::Value> Window::SetAlwaysOnTop(const v8::Arguments &args) {
return node::ThrowTypeError("Bad argument");
self->window_->SetAlwaysOnTop(top);
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::IsAlwaysOnTop(const v8::Arguments &args) {
void Window::IsAlwaysOnTop(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
return ToV8Value(self->window_->IsAlwaysOnTop());
args.GetReturnValue().Set(self->window_->IsAlwaysOnTop());
}
// static
v8::Handle<v8::Value> Window::Center(const v8::Arguments &args) {
void Window::Center(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
self->window_->Center();
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::SetPosition(const v8::Arguments &args) {
void Window::SetPosition(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
int x, y;
@@ -363,11 +332,10 @@ v8::Handle<v8::Value> Window::SetPosition(const v8::Arguments &args) {
return node::ThrowTypeError("Bad argument");
self->window_->SetPosition(gfx::Point(x, y));
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::GetPosition(const v8::Arguments &args) {
void Window::GetPosition(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
gfx::Point pos = self->window_->GetPosition();
@@ -375,11 +343,11 @@ v8::Handle<v8::Value> Window::GetPosition(const v8::Arguments &args) {
ret->Set(0, ToV8Value(pos.x()));
ret->Set(1, ToV8Value(pos.y()));
return ret;
args.GetReturnValue().Set(ret);
}
// static
v8::Handle<v8::Value> Window::SetTitle(const v8::Arguments &args) {
void Window::SetTitle(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
std::string title;
@@ -387,27 +355,23 @@ v8::Handle<v8::Value> Window::SetTitle(const v8::Arguments &args) {
return node::ThrowTypeError("Bad argument");
self->window_->SetTitle(title);
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::GetTitle(const v8::Arguments &args) {
void Window::GetTitle(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
return ToV8Value(self->window_->GetTitle());
args.GetReturnValue().Set(ToV8Value(self->window_->GetTitle()));
}
// static
v8::Handle<v8::Value> Window::FlashFrame(const v8::Arguments &args) {
void Window::FlashFrame(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
self->window_->FlashFrame(
args[0]->IsBoolean() ? args[0]->BooleanValue(): true);
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::SetKiosk(const v8::Arguments &args) {
void Window::SetKiosk(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
bool kiosk;
@@ -415,42 +379,34 @@ v8::Handle<v8::Value> Window::SetKiosk(const v8::Arguments &args) {
return node::ThrowTypeError("Bad argument");
self->window_->SetKiosk(kiosk);
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::IsKiosk(const v8::Arguments &args) {
void Window::IsKiosk(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
return ToV8Value(self->window_->IsKiosk());
args.GetReturnValue().Set(self->window_->IsKiosk());
}
// static
v8::Handle<v8::Value> Window::OpenDevTools(const v8::Arguments &args) {
void Window::OpenDevTools(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
self->window_->OpenDevTools();
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::CloseDevTools(const v8::Arguments &args) {
void Window::CloseDevTools(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
self->window_->CloseDevTools();
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::IsDevToolsOpened(const v8::Arguments& args) {
void Window::IsDevToolsOpened(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
return ToV8Value(self->window_->IsDevToolsOpened());
args.GetReturnValue().Set(self->window_->IsDevToolsOpened());
}
// static
v8::Handle<v8::Value> Window::InspectElement(const v8::Arguments& args) {
void Window::InspectElement(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
int x, y;
@@ -458,49 +414,39 @@ v8::Handle<v8::Value> Window::InspectElement(const v8::Arguments& args) {
return node::ThrowTypeError("Bad argument");
self->window_->InspectElement(x, y);
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::FocusOnWebView(const v8::Arguments &args) {
void Window::DebugDevTools(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
if (self->window_->IsDevToolsOpened())
NativeWindow::Debug(self->window_->GetDevToolsWebContents());
}
// static
void Window::FocusOnWebView(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
self->window_->FocusOnWebView();
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::BlurWebView(const v8::Arguments &args) {
void Window::BlurWebView(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
self->window_->BlurWebView();
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::IsWebViewFocused(const v8::Arguments& args) {
void Window::IsWebViewFocused(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
return ToV8Value(self->window_->IsWebViewFocused());
args.GetReturnValue().Set(self->window_->IsWebViewFocused());
}
// static
v8::Handle<v8::Value> Window::RestartHangMonitorTimeout(
const v8::Arguments &args) {
UNWRAP_WINDOW_AND_CHECK;
self->window_->RestartHangMonitorTimeout();
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::CapturePage(const v8::Arguments& args) {
void Window::CapturePage(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
gfx::Rect rect;
v8::Persistent<v8::Function> callback;
RefCountedV8Function callback;
if (!FromV8Arguments(args, &rect, &callback) &&
!FromV8Arguments(args, &callback))
return node::ThrowTypeError("Bad argument");
@@ -508,115 +454,132 @@ v8::Handle<v8::Value> Window::CapturePage(const v8::Arguments& args) {
self->window_->CapturePage(rect, base::Bind(&Window::OnCapturePageDone,
base::Unretained(self),
callback));
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::GetPageTitle(const v8::Arguments &args) {
void Window::GetPageTitle(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
return ToV8Value(self->window_->GetWebContents()->GetTitle());
args.GetReturnValue().Set(ToV8Value(
self->window_->GetWebContents()->GetTitle()));
}
// static
v8::Handle<v8::Value> Window::IsLoading(const v8::Arguments &args) {
void Window::IsLoading(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
return ToV8Value(self->window_->GetWebContents()->IsLoading());
args.GetReturnValue().Set(self->window_->GetWebContents()->IsLoading());
}
// static
v8::Handle<v8::Value> Window::IsWaitingForResponse(const v8::Arguments &args) {
void Window::IsWaitingForResponse(
const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
return ToV8Value(self->window_->GetWebContents()->IsWaitingForResponse());
args.GetReturnValue().Set(
self->window_->GetWebContents()->IsWaitingForResponse());
}
// static
v8::Handle<v8::Value> Window::Stop(const v8::Arguments &args) {
void Window::Stop(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
self->window_->GetWebContents()->Stop();
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::GetRoutingID(const v8::Arguments &args) {
void Window::GetRoutingID(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
return ToV8Value(self->window_->GetWebContents()->GetRoutingID());
args.GetReturnValue().Set(self->window_->GetWebContents()->GetRoutingID());
}
// static
v8::Handle<v8::Value> Window::GetProcessID(const v8::Arguments &args) {
void Window::GetProcessID(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
return ToV8Value(
args.GetReturnValue().Set(
self->window_->GetWebContents()->GetRenderProcessHost()->GetID());
}
// static
v8::Handle<v8::Value> Window::IsCrashed(const v8::Arguments &args) {
void Window::IsCrashed(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
return ToV8Value(self->window_->GetWebContents()->IsCrashed());
args.GetReturnValue().Set(self->window_->GetWebContents()->IsCrashed());
}
// static
v8::Handle<v8::Value> Window::LoadURL(const v8::Arguments &args) {
void Window::GetDevTools(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
std::string url;
content::WebContents* web_contents = self->window_->GetDevToolsWebContents();
v8::Local<v8::Object> devtools = v8::Object::New();
devtools->Set(ToV8Value("processId"),
ToV8Value(web_contents->GetRenderProcessHost()->GetID()));
devtools->Set(ToV8Value("routingId"),
ToV8Value(web_contents->GetRoutingID()));
args.GetReturnValue().Set(devtools);
}
// static
void Window::ExecuteJavaScriptInDevTools(
const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
std::string code;
if (!FromV8Arguments(args, &code))
return node::ThrowTypeError("Bad argument");
self->window_->ExecuteJavaScriptInDevTools(code);
}
// static
void Window::LoadURL(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
GURL url;
if (!FromV8Arguments(args, &url))
return node::ThrowTypeError("Bad argument");
NavigationController& controller =
self->window_->GetWebContents()->GetController();
controller.LoadURL(GURL(url),
content::Referrer(),
content::PAGE_TRANSITION_AUTO_TOPLEVEL,
std::string());
return v8::Undefined();
content::NavigationController::LoadURLParams params(url);
params.transition_type = content::PAGE_TRANSITION_TYPED;
params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
controller.LoadURLWithParams(params);
}
// static
v8::Handle<v8::Value> Window::GetURL(const v8::Arguments &args) {
void Window::GetURL(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
NavigationController& controller =
self->window_->GetWebContents()->GetController();
std::string url;
GURL url;
if (controller.GetActiveEntry())
url = controller.GetActiveEntry()->GetVirtualURL().spec();
url = controller.GetActiveEntry()->GetVirtualURL();
return ToV8Value(url);
args.GetReturnValue().Set(ToV8Value(url));
}
// static
v8::Handle<v8::Value> Window::CanGoBack(const v8::Arguments &args) {
void Window::CanGoBack(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
NavigationController& controller =
self->window_->GetWebContents()->GetController();
return ToV8Value(controller.CanGoBack());
args.GetReturnValue().Set(controller.CanGoBack());
}
// static
v8::Handle<v8::Value> Window::CanGoForward(const v8::Arguments &args) {
void Window::CanGoForward(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
NavigationController& controller =
self->window_->GetWebContents()->GetController();
return ToV8Value(controller.CanGoForward());
args.GetReturnValue().Set(controller.CanGoForward());
}
// static
v8::Handle<v8::Value> Window::CanGoToOffset(const v8::Arguments &args) {
void Window::CanGoToOffset(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
int offset;
@@ -626,33 +589,29 @@ v8::Handle<v8::Value> Window::CanGoToOffset(const v8::Arguments &args) {
NavigationController& controller =
self->window_->GetWebContents()->GetController();
return ToV8Value(controller.CanGoToOffset(offset));
args.GetReturnValue().Set(controller.CanGoToOffset(offset));
}
// static
v8::Handle<v8::Value> Window::GoBack(const v8::Arguments &args) {
void Window::GoBack(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
NavigationController& controller =
self->window_->GetWebContents()->GetController();
controller.GoBack();
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::GoForward(const v8::Arguments &args) {
void Window::GoForward(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
NavigationController& controller =
self->window_->GetWebContents()->GetController();
controller.GoForward();
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::GoToIndex(const v8::Arguments &args) {
void Window::GoToIndex(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
int index;
@@ -662,12 +621,10 @@ v8::Handle<v8::Value> Window::GoToIndex(const v8::Arguments &args) {
NavigationController& controller =
self->window_->GetWebContents()->GetController();
controller.GoToIndex(index);
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::GoToOffset(const v8::Arguments &args) {
void Window::GoToOffset(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
int offset;
@@ -677,37 +634,30 @@ v8::Handle<v8::Value> Window::GoToOffset(const v8::Arguments &args) {
NavigationController& controller =
self->window_->GetWebContents()->GetController();
controller.GoToOffset(offset);
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::Reload(const v8::Arguments &args) {
void Window::Reload(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
NavigationController& controller =
self->window_->GetWebContents()->GetController();
controller.Reload(args[0]->IsBoolean() ? args[0]->BooleanValue(): false);
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::ReloadIgnoringCache(const v8::Arguments &args) {
void Window::ReloadIgnoringCache(
const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
NavigationController& controller =
self->window_->GetWebContents()->GetController();
controller.ReloadIgnoringCache(
args[0]->IsBoolean() ? args[0]->BooleanValue(): false);
return v8::Undefined();
}
// static
void Window::Initialize(v8::Handle<v8::Object> target) {
v8::HandleScope scope;
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(Window::New);
t->InstanceTemplate()->SetInternalFieldCount(1);
t->SetClassName(v8::String::NewSymbol("BrowserWindow"));
@@ -747,12 +697,10 @@ void Window::Initialize(v8::Handle<v8::Object> target) {
NODE_SET_PROTOTYPE_METHOD(t, "closeDevTools", CloseDevTools);
NODE_SET_PROTOTYPE_METHOD(t, "isDevToolsOpened", IsDevToolsOpened);
NODE_SET_PROTOTYPE_METHOD(t, "inspectElement", InspectElement);
NODE_SET_PROTOTYPE_METHOD(t, "debugDevTools", DebugDevTools);
NODE_SET_PROTOTYPE_METHOD(t, "focusOnWebView", FocusOnWebView);
NODE_SET_PROTOTYPE_METHOD(t, "blurWebView", BlurWebView);
NODE_SET_PROTOTYPE_METHOD(t, "isWebViewFocused", IsWebViewFocused);
NODE_SET_PROTOTYPE_METHOD(t,
"restartHangMonitorTimeout",
RestartHangMonitorTimeout);
NODE_SET_PROTOTYPE_METHOD(t, "capturePage", CapturePage);
NODE_SET_PROTOTYPE_METHOD(t, "getPageTitle", GetPageTitle);
@@ -763,6 +711,10 @@ void Window::Initialize(v8::Handle<v8::Object> target) {
NODE_SET_PROTOTYPE_METHOD(t, "getProcessId", GetProcessID);
NODE_SET_PROTOTYPE_METHOD(t, "isCrashed", IsCrashed);
NODE_SET_PROTOTYPE_METHOD(t, "getDevTools", GetDevTools);
NODE_SET_PROTOTYPE_METHOD(
t, "executeJavaScriptInDevTools", ExecuteJavaScriptInDevTools);
NODE_SET_PROTOTYPE_METHOD(t, "loadUrl", LoadURL);
NODE_SET_PROTOTYPE_METHOD(t, "getUrl", GetURL);
NODE_SET_PROTOTYPE_METHOD(t, "canGoBack", CanGoBack);

View File

@@ -0,0 +1,138 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_API_ATOM_API_WINDOW_H_
#define ATOM_BROWSER_API_ATOM_API_WINDOW_H_
#include <string>
#include <vector>
#include "base/memory/scoped_ptr.h"
#include "atom/browser/native_window_observer.h"
#include "atom/common/api/atom_api_event_emitter.h"
#include "atom/common/v8/scoped_persistent.h"
namespace base {
class DictionaryValue;
}
namespace atom {
class NativeWindow;
namespace api {
class Window : public EventEmitter,
public NativeWindowObserver {
public:
virtual ~Window();
static void Initialize(v8::Handle<v8::Object> target);
NativeWindow* window() { return window_.get(); }
protected:
explicit Window(v8::Handle<v8::Object> wrapper,
base::DictionaryValue* options);
// Implementations of NativeWindowObserver.
virtual void OnPageTitleUpdated(bool* prevent_default,
const std::string& title) OVERRIDE;
virtual void OnLoadingStateChanged(bool is_loading) OVERRIDE;
virtual void WillCloseWindow(bool* prevent_default) OVERRIDE;
virtual void OnWindowClosed() OVERRIDE;
virtual void OnWindowBlur() OVERRIDE;
virtual void OnRendererUnresponsive() OVERRIDE;
virtual void OnRendererResponsive() OVERRIDE;
virtual void OnRenderViewDeleted(int process_id, int routing_id) OVERRIDE;
virtual void OnRendererCrashed() OVERRIDE;
private:
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Destroy(const v8::FunctionCallbackInfo<v8::Value>& args);
// APIs for NativeWindow.
static void Close(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Focus(const v8::FunctionCallbackInfo<v8::Value>& args);
static void IsFocused(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Show(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Hide(const v8::FunctionCallbackInfo<v8::Value>& args);
static void IsVisible(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Maximize(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Unmaximize(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Minimize(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Restore(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetFullscreen(const v8::FunctionCallbackInfo<v8::Value>& args);
static void IsFullscreen(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetSize(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GetSize(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetMinimumSize(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GetMinimumSize(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetMaximumSize(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GetMaximumSize(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetResizable(const v8::FunctionCallbackInfo<v8::Value>& args);
static void IsResizable(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetAlwaysOnTop(const v8::FunctionCallbackInfo<v8::Value>& args);
static void IsAlwaysOnTop(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Center(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetPosition(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GetPosition(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetTitle(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GetTitle(const v8::FunctionCallbackInfo<v8::Value>& args);
static void FlashFrame(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetKiosk(const v8::FunctionCallbackInfo<v8::Value>& args);
static void IsKiosk(const v8::FunctionCallbackInfo<v8::Value>& args);
static void OpenDevTools(const v8::FunctionCallbackInfo<v8::Value>& args);
static void CloseDevTools(const v8::FunctionCallbackInfo<v8::Value>& args);
static void IsDevToolsOpened(const v8::FunctionCallbackInfo<v8::Value>& args);
static void InspectElement(const v8::FunctionCallbackInfo<v8::Value>& args);
static void DebugDevTools(const v8::FunctionCallbackInfo<v8::Value>& args);
static void FocusOnWebView(const v8::FunctionCallbackInfo<v8::Value>& args);
static void BlurWebView(const v8::FunctionCallbackInfo<v8::Value>& args);
static void IsWebViewFocused(const v8::FunctionCallbackInfo<v8::Value>& args);
static void CapturePage(const v8::FunctionCallbackInfo<v8::Value>& args);
// APIs for WebContents.
static void GetPageTitle(const v8::FunctionCallbackInfo<v8::Value>& args);
static void IsLoading(const v8::FunctionCallbackInfo<v8::Value>& args);
static void IsWaitingForResponse(
const v8::FunctionCallbackInfo<v8::Value>& args);
static void Stop(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GetRoutingID(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GetProcessID(const v8::FunctionCallbackInfo<v8::Value>& args);
static void IsCrashed(const v8::FunctionCallbackInfo<v8::Value>& args);
// APIs for devtools.
static void GetDevTools(const v8::FunctionCallbackInfo<v8::Value>& args);
static void ExecuteJavaScriptInDevTools(
const v8::FunctionCallbackInfo<v8::Value>& args);
// APIs for NavigationController.
static void LoadURL(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GetURL(const v8::FunctionCallbackInfo<v8::Value>& args);
static void CanGoBack(const v8::FunctionCallbackInfo<v8::Value>& args);
static void CanGoForward(const v8::FunctionCallbackInfo<v8::Value>& args);
static void CanGoToOffset(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GoBack(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GoForward(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GoToIndex(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GoToOffset(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Reload(const v8::FunctionCallbackInfo<v8::Value>& args);
static void ReloadIgnoringCache(
const v8::FunctionCallbackInfo<v8::Value>& args);
// Called when capturePage is done.
void OnCapturePageDone(const RefCountedV8Function& callback,
const std::vector<unsigned char>& data);
scoped_ptr<NativeWindow> window_;
DISALLOW_COPY_AND_ASSIGN(Window);
};
} // namespace api
} // namespace atom
#endif // ATOM_BROWSER_API_ATOM_API_WINDOW_H_

View File

@@ -2,21 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/api/atom_browser_bindings.h"
#include "atom/browser/api/atom_browser_bindings.h"
#include <vector>
#include "base/logging.h"
#include "base/values.h"
#include "browser/api/atom_api_event.h"
#include "common/v8_conversions.h"
#include "common/v8_value_converter_impl.h"
#include "atom/browser/api/atom_api_event.h"
#include "atom/common/v8/native_type_conversions.h"
#include "content/public/browser/browser_thread.h"
#include "vendor/node/src/node.h"
#include "vendor/node/src/node_internals.h"
using content::V8ValueConverter;
using node::node_isolate;
#include "atom/common/v8/node_common.h"
namespace atom {
@@ -26,31 +21,14 @@ AtomBrowserBindings::AtomBrowserBindings() {
AtomBrowserBindings::~AtomBrowserBindings() {
}
void AtomBrowserBindings::AfterLoad() {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
v8::HandleScope scope;
v8::Handle<v8::Object> global = node::g_context->Global();
v8::Handle<v8::Object> atom =
global->Get(v8::String::New("__atom"))->ToObject();
DCHECK(!atom.IsEmpty());
browser_main_parts_ = v8::Persistent<v8::Object>::New(
node_isolate,
atom->Get(v8::String::New("browserMainParts"))->ToObject());
DCHECK(!browser_main_parts_.IsEmpty());
}
void AtomBrowserBindings::OnRendererMessage(int process_id,
int routing_id,
const string16& channel,
const base::ListValue& args) {
v8::HandleScope scope;
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
v8::Handle<v8::Context> context = v8::Context::GetCurrent();
scoped_ptr<V8ValueConverter> converter(new V8ValueConverterImpl());
scoped_ptr<V8ValueConverter> converter(new V8ValueConverter);
// process.emit(channel, 'message', process_id, routing_id);
std::vector<v8::Handle<v8::Value>> arguments;
@@ -58,17 +36,20 @@ void AtomBrowserBindings::OnRendererMessage(int process_id,
arguments.push_back(ToV8Value(channel));
const base::Value* value;
if (args.Get(0, &value))
arguments.push_back(converter->ToV8Value(value, context));
arguments.push_back(converter->ToV8Value(value, global_env->context()));
arguments.push_back(v8::Integer::New(process_id));
arguments.push_back(v8::Integer::New(routing_id));
for (size_t i = 1; i < args.GetSize(); i++) {
const base::Value* value;
if (args.Get(i, &value))
arguments.push_back(converter->ToV8Value(value, context));
arguments.push_back(converter->ToV8Value(value, global_env->context()));
}
node::MakeCallback(node::process, "emit", arguments.size(), &arguments[0]);
node::MakeCallback(global_env->process_object(),
"emit",
arguments.size(),
&arguments[0]);
}
void AtomBrowserBindings::OnRendererMessageSync(
@@ -76,13 +57,12 @@ void AtomBrowserBindings::OnRendererMessageSync(
int routing_id,
const string16& channel,
const base::ListValue& args,
NativeWindow* sender,
content::WebContents* sender,
IPC::Message* message) {
v8::HandleScope scope;
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
v8::Handle<v8::Context> context = v8::Context::GetCurrent();
scoped_ptr<V8ValueConverter> converter(new V8ValueConverterImpl());
scoped_ptr<V8ValueConverter> converter(new V8ValueConverter);
// Create the event object.
v8::Handle<v8::Object> event = api::Event::CreateV8Object();
@@ -94,7 +74,7 @@ void AtomBrowserBindings::OnRendererMessageSync(
arguments.push_back(ToV8Value(channel));
const base::Value* value;
if (args.Get(0, &value))
arguments.push_back(converter->ToV8Value(value, context));
arguments.push_back(converter->ToV8Value(value, global_env->context()));
arguments.push_back(event);
arguments.push_back(v8::Integer::New(process_id));
arguments.push_back(v8::Integer::New(routing_id));
@@ -102,10 +82,13 @@ void AtomBrowserBindings::OnRendererMessageSync(
for (size_t i = 1; i < args.GetSize(); i++) {
const base::Value* value;
if (args.Get(i, &value))
arguments.push_back(converter->ToV8Value(value, context));
arguments.push_back(converter->ToV8Value(value, global_env->context()));
}
node::MakeCallback(node::process, "emit", arguments.size(), &arguments[0]);
node::MakeCallback(global_env->process_object(),
"emit",
arguments.size(),
&arguments[0]);
}
} // namespace atom

View File

@@ -2,32 +2,32 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_API_ATOM_BROWSER_BINDINGS_
#define ATOM_BROWSER_API_ATOM_BROWSER_BINDINGS_
#ifndef ATOM_BROWSER_API_ATOM_BROWSER_BINDINGS_H_
#define ATOM_BROWSER_API_ATOM_BROWSER_BINDINGS_H_
#include "base/string16.h"
#include "common/api/atom_bindings.h"
#include "base/strings/string16.h"
#include "atom/common/api/atom_bindings.h"
#include "atom/common/v8/scoped_persistent.h"
namespace base {
class ListValue;
}
namespace content {
class WebContents;
}
namespace IPC {
class Message;
}
namespace atom {
class NativeWindow;
class AtomBrowserBindings : public AtomBindings {
public:
AtomBrowserBindings();
virtual ~AtomBrowserBindings();
// Called when the node.js main script has been loaded.
virtual void AfterLoad();
// Called when received a message from renderer.
void OnRendererMessage(int process_id,
int routing_id,
@@ -39,20 +39,13 @@ class AtomBrowserBindings : public AtomBindings {
int routing_id,
const string16& channel,
const base::ListValue& args,
NativeWindow* sender,
content::WebContents* sender,
IPC::Message* message);
// The require('atom').browserMainParts object.
v8::Handle<v8::Object> browser_main_parts() {
return browser_main_parts_;
}
private:
v8::Persistent<v8::Object> browser_main_parts_;
DISALLOW_COPY_AND_ASSIGN(AtomBrowserBindings);
};
} // namespace atom
#endif // ATOM_BROWSER_API_ATOM_BINDINGS_
#endif // ATOM_BROWSER_API_ATOM_BROWSER_BINDINGS_H_

View File

@@ -1,6 +1,7 @@
bindings = process.atomBinding 'app'
EventEmitter = require('events').EventEmitter
bindings = process.atomBinding 'app'
Application = bindings.Application
Application::__proto__ = EventEmitter.prototype
@@ -9,9 +10,6 @@ app = new Application
app.getHomeDir = ->
process.env[if process.platform is 'win32' then 'USERPROFILE' else 'HOME']
app.getBrowserWindows = ->
require('../../atom/objects-registry.js').getAllWindows()
app.setApplicationMenu = (menu) ->
require('menu').setApplicationMenu menu
@@ -24,10 +22,14 @@ app.commandLine =
if process.platform is 'darwin'
app.dock =
bounce: (type = 'informational') -> bindings.dockBounce type
bounce: (type='informational') -> bindings.dockBounce type
cancelBounce: bindings.dockCancelBounce
setBadge: bindings.dockSetBadgeText
getBadge: bindings.dockGetBadgeText
# Be compatible with old API.
app.once 'ready', -> app.emit 'finish-launching'
app.terminate = app.exit = app.quit
# Only one App object pemitted.
module.exports = app

View File

@@ -0,0 +1,6 @@
module.exports =
browserMainParts:
preMainMessageLoopRun: ->
setImmediate ->
module.exports.browserMainParts.preMainMessageLoopRun()

View File

@@ -0,0 +1,25 @@
AutoUpdater = process.atomBinding('auto_updater').AutoUpdater
EventEmitter = require('events').EventEmitter
AutoUpdater::__proto__ = EventEmitter.prototype
autoUpdater = new AutoUpdater
autoUpdater.on 'update-downloaded-raw', (args...) ->
args[3] = new Date(args[3]) # releaseDate
@emit 'update-downloaded', args..., => @quitAndInstall()
autoUpdater.quitAndInstall = ->
# If we don't have any window then quitAndInstall immediately.
BrowserWindow = require 'browser-window'
windows = BrowserWindow.getAllWindows()
if windows.length is 0
AutoUpdater::quitAndInstall.call this
return
# Do the restart after all windows have been closed.
app = require 'app'
app.removeAllListeners 'window-all-closed'
app.once 'window-all-closed', AutoUpdater::quitAndInstall.bind(this)
win.close() for win in windows
module.exports = autoUpdater

View File

@@ -0,0 +1,65 @@
EventEmitter = require('events').EventEmitter
IDWeakMap = require 'id-weak-map'
app = require 'app'
BrowserWindow = process.atomBinding('window').BrowserWindow
BrowserWindow::__proto__ = EventEmitter.prototype
# Store all created windows in the weak map.
BrowserWindow.windows = new IDWeakMap
BrowserWindow::_init = ->
# Simulate the application menu on platforms other than OS X.
if process.platform isnt 'darwin'
menu = app.getApplicationMenu()
@setMenu menu if menu?
# Remember the window.
id = BrowserWindow.windows.add this
# Remove the window from weak map immediately when it's destroyed, since we
# could be iterating windows before GC happended.
@once 'destroyed', ->
BrowserWindow.windows.remove id if BrowserWindow.windows.has id
# Tell the rpc server that a render view has been deleted and we need to
# release all objects owned by it.
@on 'render-view-deleted', (event, processId, routingId) ->
process.emit 'ATOM_BROWSER_RELEASE_RENDER_VIEW', processId, routingId
BrowserWindow::toggleDevTools = ->
if @isDevToolsOpened() then @closeDevTools() else @openDevTools()
BrowserWindow::restart = ->
@loadUrl(@getUrl())
BrowserWindow::setMenu = (menu) ->
if process.platform is 'darwin'
throw new Error('BrowserWindow.setMenu is not available on OS X')
throw new TypeError('Invalid menu') unless menu?.constructor?.name is 'Menu'
@menu = menu # Keep a reference of menu in case of GC.
@menu.attachToWindow this
BrowserWindow.getAllWindows = ->
windows = BrowserWindow.windows
windows.get key for key in windows.keys()
BrowserWindow.getFocusedWindow = ->
windows = BrowserWindow.getAllWindows()
return window for window in windows when window.isFocused()
BrowserWindow.fromProcessIdAndRoutingId = (processId, routingId) ->
windows = BrowserWindow.getAllWindows()
return window for window in windows when window.getProcessId() == processId and
window.getRoutingId() == routingId
BrowserWindow.fromDevTools = (processId, routingId) ->
windows = BrowserWindow.getAllWindows()
for window in windows
devtools = window.getDevTools()
return window if devtools.processId == processId and
devtools.routingId == routingId
module.exports = BrowserWindow

View File

@@ -5,10 +5,11 @@ sendWrap = (channel, processId, routingId, args...) ->
BrowserWindow = require 'browser-window'
if processId?.constructor is BrowserWindow
window = processId
args = [routingId, args...]
processId = window.getProcessId()
routingId = window.getRoutingId()
send channel, processId, routingId, args...
send channel, processId, routingId, [args...]
class Ipc extends EventEmitter
constructor: ->

View File

@@ -1,9 +1,7 @@
BrowserWindow = require 'browser-window'
EventEmitter = require('events').EventEmitter
IDWeakMap = require 'id-weak-map'
MenuItem = require 'menu-item'
app = require 'app'
bindings = process.atomBinding 'menu'
Menu = bindings.Menu
@@ -52,7 +50,7 @@ Menu.setApplicationMenu = (menu) ->
if process.platform is 'darwin'
bindings.setApplicationMenu menu
else
windows = app.getBrowserWindows()
windows = BrowserWindow.getAllWindows()
w.setMenu menu for w in windows
Menu.getApplicationMenu = -> applicationMenu

View File

@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "browser/atom_application_delegate_mac.h"
#import "atom/browser/atom_application_delegate_mac.h"
#include "base/strings/sys_string_conversions.h"
#import "browser/atom_application_mac.h"
#include "browser/browser.h"
#import "atom/browser/atom_application_mac.h"
#include "atom/browser/browser.h"
@implementation AtomApplicationDelegate
@@ -35,4 +35,15 @@
}
}
- (BOOL)applicationShouldHandleReopen:(NSApplication*)theApplication
hasVisibleWindows:(BOOL)flag {
atom::Browser* browser = atom::Browser::Get();
if (flag) {
return YES;
} else {
browser->ActivateWithNoOpenWindows();
return NO;
}
}
@end

View File

@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "browser/atom_application_mac.h"
#import "atom/browser/atom_application_mac.h"
#include "base/auto_reset.h"
#include "base/strings/sys_string_conversions.h"
#include "browser/browser.h"
#include "atom/browser/browser.h"
@implementation AtomApplication

View File

@@ -0,0 +1,124 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "atom/browser/atom_browser_client.h"
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/native_window.h"
#include "atom/browser/net/atom_url_request_context_getter.h"
#include "atom/browser/window_list.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "webkit/common/webpreferences.h"
namespace atom {
namespace {
struct FindByProcessId {
explicit FindByProcessId(int child_process_id)
: child_process_id_(child_process_id) {
}
bool operator() (NativeWindow* const window) {
int id = window->GetWebContents()->GetRenderProcessHost()->GetID();
return id == child_process_id_;
}
int child_process_id_;
};
} // namespace
AtomBrowserClient::AtomBrowserClient()
: dying_render_process_(NULL) {
}
AtomBrowserClient::~AtomBrowserClient() {
}
net::URLRequestContextGetter* AtomBrowserClient::CreateRequestContext(
content::BrowserContext* browser_context,
content::ProtocolHandlerMap* protocol_handlers) {
return static_cast<AtomBrowserContext*>(browser_context)->
CreateRequestContext(protocol_handlers);
}
void AtomBrowserClient::OverrideWebkitPrefs(
content::RenderViewHost* render_view_host,
const GURL& url,
WebPreferences* prefs) {
prefs->javascript_enabled = true;
prefs->web_security_enabled = true;
prefs->javascript_can_open_windows_automatically = true;
prefs->plugins_enabled = false;
prefs->dom_paste_enabled = true;
prefs->java_enabled = false;
prefs->allow_scripts_to_close_windows = true;
prefs->javascript_can_access_clipboard = true;
prefs->local_storage_enabled = true;
prefs->databases_enabled = true;
prefs->application_cache_enabled = true;
prefs->allow_universal_access_from_file_urls = true;
prefs->allow_file_access_from_file_urls = true;
prefs->experimental_webgl_enabled = false;
prefs->allow_displaying_insecure_content = true;
prefs->allow_running_insecure_content = true;
NativeWindow* window = NativeWindow::FromRenderView(
render_view_host->GetProcess()->GetID(),
render_view_host->GetRoutingID());
if (window)
window->OverrideWebkitPrefs(url, prefs);
}
bool AtomBrowserClient::ShouldSwapProcessesForNavigation(
content::SiteInstance* site_instance,
const GURL& current_url,
const GURL& new_url) {
if (site_instance->HasProcess())
dying_render_process_ = site_instance->GetProcess();
// Restart renderer process for all navigations.
return true;
}
void AtomBrowserClient::AppendExtraCommandLineSwitches(
CommandLine* command_line,
int child_process_id) {
WindowList* list = WindowList::GetInstance();
NativeWindow* window = NULL;
// Find the owner of this child process.
WindowList::const_iterator iter = std::find_if(
list->begin(), list->end(), FindByProcessId(child_process_id));
if (iter != list->end())
window = *iter;
// If the render process is a newly started one, which means the window still
// uses the old going-to-be-swapped render process, then we try to find the
// window from the swapped render process.
if (window == NULL && dying_render_process_ != NULL) {
child_process_id = dying_render_process_->GetID();
WindowList::const_iterator iter = std::find_if(
list->begin(), list->end(), FindByProcessId(child_process_id));
if (iter != list->end())
window = *iter;
}
if (window != NULL)
window->AppendExtraCommandLineSwitches(command_line, child_process_id);
dying_render_process_ = NULL;
}
brightray::BrowserMainParts* AtomBrowserClient::OverrideCreateBrowserMainParts(
const content::MainFunctionParams&) {
return new AtomBrowserMainParts;
}
} // namespace atom

View File

@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_ATOM_BROWSER_CLIENT_
#define ATOM_BROWSER_ATOM_BROWSER_CLIENT_
#ifndef ATOM_BROWSER_ATOM_BROWSER_CLIENT_H_
#define ATOM_BROWSER_ATOM_BROWSER_CLIENT_H_
#include "brightray/browser/browser_client.h"
@@ -25,14 +25,19 @@ class AtomBrowserClient : public brightray::BrowserClient {
content::SiteInstance* site_instance,
const GURL& current_url,
const GURL& new_url) OVERRIDE;
virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
int child_process_id) OVERRIDE;
private:
virtual brightray::BrowserMainParts* OverrideCreateBrowserMainParts(
const content::MainFunctionParams&) OVERRIDE;
// The render process which would be swapped out soon.
content::RenderProcessHost* dying_render_process_;
DISALLOW_COPY_AND_ASSIGN(AtomBrowserClient);
};
} // namespace atom
#endif // ATOM_BROWSER_ATOM_BROWSER_CLIENT_
#endif // ATOM_BROWSER_ATOM_BROWSER_CLIENT_H_

View File

@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/atom_browser_context.h"
#include "atom/browser/atom_browser_context.h"
#include "browser/atom_browser_main_parts.h"
#include "browser/net/atom_url_request_context_getter.h"
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/net/atom_url_request_context_getter.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/resource_context.h"
#include "vendor/brightray/browser/network_delegate.h"
@@ -33,6 +33,14 @@ class AtomResourceContext : public content::ResourceContext {
return getter_->GetURLRequestContext();
}
virtual bool AllowMicAccess(const GURL& origin) OVERRIDE {
return true;
}
virtual bool AllowCameraAccess(const GURL& origin) OVERRIDE {
return true;
}
private:
AtomURLRequestContextGetter* getter_;
@@ -53,7 +61,8 @@ AtomURLRequestContextGetter* AtomBrowserContext::CreateRequestContext(
GetPath(),
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO),
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE),
CreateNetworkDelegate().Pass(),
base::Bind(&AtomBrowserContext::CreateNetworkDelegate,
base::Unretained(this)),
protocol_handlers);
resource_context_->set_url_request_context_getter(url_request_getter_.get());

View File

@@ -2,17 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/atom_browser_main_parts.h"
#include "atom/browser/atom_browser_main_parts.h"
#include "base/power_monitor/power_monitor.h"
#include "browser/api/atom_browser_bindings.h"
#include "browser/atom_browser_client.h"
#include "browser/atom_browser_context.h"
#include "browser/browser.h"
#include "common/node_bindings.h"
#include "atom/browser/api/atom_browser_bindings.h"
#include "atom/browser/atom_browser_client.h"
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/browser.h"
#include "atom/common/node_bindings.h"
#include "net/proxy/proxy_resolver_v8.h"
#include "vendor/node/src/node.h"
#include "vendor/node/src/node_internals.h"
#if defined(OS_WIN)
#include "ui/gfx/win/dpi.h"
#endif
#include "atom/common/v8/node_common.h"
namespace atom {
@@ -43,37 +46,29 @@ brightray::BrowserContext* AtomBrowserMainParts::CreateBrowserContext() {
void AtomBrowserMainParts::PostEarlyInitialization() {
brightray::BrowserMainParts::PostEarlyInitialization();
#if defined(OS_MACOSX)
base::PowerMonitor::AllocateSystemIOPorts();
#endif
node_bindings_->Initialize();
v8::V8::Initialize();
// Create context.
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
v8::Local<v8::Context> context = v8::Context::New(node_isolate);
// Create the global environment.
global_env = node_bindings_->CreateEnvironment(context);
// Wrap whole process in one global context.
node::g_context->Enter();
context->Enter();
atom_bindings_->BindTo(node::process);
node_bindings_->Load();
atom_bindings_->AfterLoad();
// Add atom-shell extended APIs.
atom_bindings_->BindTo(global_env->process_object());
}
void AtomBrowserMainParts::PreMainMessageLoopRun() {
node_bindings_->PrepareMessageLoop();
brightray::BrowserMainParts::PreMainMessageLoopRun();
{
v8::HandleScope scope;
v8::Context::Scope context_scope(node::g_context);
v8::Handle<v8::Value> args;
node::MakeCallback(atom_bindings_->browser_main_parts(),
"preMainMessageLoopRun",
0, &args);
}
node_bindings_->PrepareMessageLoop();
node_bindings_->RunMessageLoop();
// Make sure the url request job factory is created before the
@@ -89,8 +84,17 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() {
}
int AtomBrowserMainParts::PreCreateThreads() {
// TODO(zcbenz): Calling CreateIsolate() on Windows when updated to Chrome30.
// Note that we are overriding the PreCreateThreads of brightray, since we
// are integrating node in browser, we can just be sure that an V8 instance
// would be prepared, while the ProxyResolverV8::CreateIsolate() would
// try to create a V8 isolate, which messed everything on Windows, so we
// have to override and call RememberDefaultIsolate on Windows instead.
net::ProxyResolverV8::RememberDefaultIsolate();
#if defined(OS_WIN)
gfx::EnableHighDPISupport();
#endif
return 0;
}

View File

@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_
#define ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_
#ifndef ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_H_
#define ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_H_
#include "brightray/browser/browser_main_parts.h"
@@ -48,4 +48,4 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
} // namespace atom
#endif // ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_
#endif // ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_H_

View File

@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/atom_browser_main_parts.h"
#include "atom/browser/atom_browser_main_parts.h"
#include "base/files/file_path.h"
#import "base/mac/foundation_util.h"
#import "browser/atom_application_mac.h"
#import "browser/atom_application_delegate_mac.h"
#import "atom/browser/atom_application_mac.h"
#import "atom/browser/atom_application_delegate_mac.h"
#import "vendor/brightray/common/mac/main_application_bundle.h"
namespace atom {

View File

@@ -2,12 +2,26 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/atom_javascript_dialog_manager.h"
#include "atom/browser/atom_javascript_dialog_manager.h"
#include "base/utf_string_conversions.h"
#include <string>
#include "base/strings/utf_string_conversions.h"
namespace atom {
void AtomJavaScriptDialogManager::RunJavaScriptDialog(
content::WebContents* web_contents,
const GURL& origin_url,
const std::string& accept_lang,
content::JavaScriptMessageType javascript_message_type,
const string16& message_text,
const string16& default_prompt_text,
const DialogClosedCallback& callback,
bool* did_suppress_message) {
callback.Run(false, string16());
}
void AtomJavaScriptDialogManager::RunBeforeUnloadDialog(
content::WebContents* web_contents,
const string16& message_text,

View File

@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROSER_ATOM_JAVASCRIPT_DIALOG_MANAGER_H_
#define ATOM_BROSER_ATOM_JAVASCRIPT_DIALOG_MANAGER_H_
#ifndef ATOM_BROWSER_ATOM_JAVASCRIPT_DIALOG_MANAGER_H_
#define ATOM_BROWSER_ATOM_JAVASCRIPT_DIALOG_MANAGER_H_
#include <string>
#include "content/public/browser/javascript_dialog_manager.h"
@@ -20,16 +22,18 @@ class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager {
const string16& message_text,
const string16& default_prompt_text,
const DialogClosedCallback& callback,
bool* did_suppress_message) OVERRIDE {}
bool* did_suppress_message) OVERRIDE;
virtual void RunBeforeUnloadDialog(
content::WebContents* web_contents,
const string16& message_text,
bool is_reload,
const DialogClosedCallback& callback) OVERRIDE;
virtual void ResetJavaScriptState(
virtual void CancelActiveAndPendingDialogs(
content::WebContents* web_contents) OVERRIDE {}
virtual void WebContentsDestroyed(
content::WebContents* web_contents) OVERRIDE {}
};
} // namespace atom
#endif // ATOM_BROSER_ATOM_JAVASCRIPT_DIALOG_MANAGER_H_
#endif // ATOM_BROWSER_ATOM_JAVASCRIPT_DIALOG_MANAGER_H_

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/auto_updater.h"
#include "atom/browser/auto_updater.h"
namespace auto_updater {

View File

@@ -19,13 +19,8 @@ class AutoUpdater {
static AutoUpdaterDelegate* GetDelegate();
static void SetDelegate(AutoUpdaterDelegate* delegate);
static void Init();
static void SetFeedURL(const std::string& url);
static void SetAutomaticallyChecksForUpdates(bool yes);
static void SetAutomaticallyDownloadsUpdates(bool yes);
static void CheckForUpdates();
static void CheckForUpdatesInBackground();
private:
static AutoUpdaterDelegate* delegate_;

View File

@@ -0,0 +1,45 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_AUTO_UPDATER_DELEGATE_H_
#define ATOM_BROWSER_AUTO_UPDATER_DELEGATE_H_
#include <string>
#include "base/callback_forward.h"
namespace base {
class Time;
}
namespace auto_updater {
class AutoUpdaterDelegate {
public:
// An error happened.
virtual void OnError(const std::string& error) {}
// Checking to see if there is an update
virtual void OnCheckingForUpdate() {}
// There is an update available and it is being downloaded
virtual void OnUpdateAvailable() {}
// There is no available update.
virtual void OnUpdateNotAvailable() {}
// There is a new update which has been downloaded.
virtual void OnUpdateDownloaded(const std::string& release_notes,
const std::string& release_name,
const base::Time& release_date,
const std::string& update_url,
const base::Closure& quit_and_install) {}
protected:
virtual ~AutoUpdaterDelegate() {}
};
} // namespace auto_updater
#endif // ATOM_BROWSER_AUTO_UPDATER_DELEGATE_H_

View File

@@ -0,0 +1,17 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "atom/browser/auto_updater.h"
namespace auto_updater {
// static
void AutoUpdater::SetFeedURL(const std::string& url) {
}
// static
void AutoUpdater::CheckForUpdates() {
}
} // namespace auto_updater

View File

@@ -0,0 +1,92 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "atom/browser/auto_updater.h"
#import <ReactiveCocoa/RACCommand.h>
#import <ReactiveCocoa/RACSignal.h>
#import <ReactiveCocoa/NSObject+RACPropertySubscribing.h>
#import <Squirrel/Squirrel.h>
#include "base/bind.h"
#include "base/time/time.h"
#include "base/strings/sys_string_conversions.h"
#include "atom/browser/auto_updater_delegate.h"
#include <iostream>
namespace auto_updater {
namespace {
// The gloal SQRLUpdater object.
SQRLUpdater* g_updater = nil;
void RelaunchToInstallUpdate() {
[[g_updater relaunchToInstallUpdate] subscribeError:^(NSError* error) {
AutoUpdaterDelegate* delegate = AutoUpdater::GetDelegate();
if (delegate)
delegate->OnError(base::SysNSStringToUTF8(error.localizedDescription));
}];
}
} // namespace
// static
void AutoUpdater::SetFeedURL(const std::string& feed) {
if (g_updater == nil) {
// Initialize the SQRLUpdater.
NSURL* url = [NSURL URLWithString:base::SysUTF8ToNSString(feed)];
NSURLRequest* urlRequest = [NSURLRequest requestWithURL:url];
g_updater = [[SQRLUpdater alloc] initWithUpdateRequest:urlRequest];
AutoUpdaterDelegate* delegate = GetDelegate();
if (!delegate)
return;
[[g_updater rac_valuesForKeyPath:@"state" observer:g_updater]
subscribeNext:^(NSNumber *stateNumber) {
int state = [stateNumber integerValue];
if (state == SQRLUpdaterStateCheckingForUpdate) {
delegate->OnCheckingForUpdate();
} else if (state == SQRLUpdaterStateDownloadingUpdate) {
delegate->OnUpdateAvailable();
}
}];
}
}
// static
void AutoUpdater::CheckForUpdates() {
AutoUpdaterDelegate* delegate = GetDelegate();
if (!delegate)
return;
[[[[g_updater.checkForUpdatesCommand
execute:nil]
// Send a `nil` after everything...
concat:[RACSignal return:nil]]
// But only take the first value. If an update is sent, we'll get that.
// Otherwise, we'll get our inserted `nil` value.
take:1]
subscribeNext:^(SQRLDownloadedUpdate *downloadedUpdate) {
if (downloadedUpdate) {
SQRLUpdate* update = downloadedUpdate.update;
// There is a new update that has been downloaded.
delegate->OnUpdateDownloaded(
base::SysNSStringToUTF8(update.releaseNotes),
base::SysNSStringToUTF8(update.releaseName),
base::Time::FromDoubleT(update.releaseDate.timeIntervalSince1970),
base::SysNSStringToUTF8(update.updateURL.absoluteString),
base::Bind(RelaunchToInstallUpdate));
} else {
// When the completed event is sent with no update, then we know there
// is no update available.
delegate->OnUpdateNotAvailable();
}
} error:^(NSError *error) {
delegate->OnError(base::SysNSStringToUTF8(error.localizedDescription));
}];
}
} // namespace auto_updater

View File

@@ -2,32 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/auto_updater.h"
#include "atom/browser/auto_updater.h"
namespace auto_updater {
// static
void AutoUpdater::Init() {
}
// static
void AutoUpdater::SetFeedURL(const std::string& url) {
}
// static
void AutoUpdater::SetAutomaticallyChecksForUpdates(bool yes) {
}
// static
void AutoUpdater::SetAutomaticallyDownloadsUpdates(bool yes) {
}
// static
void AutoUpdater::CheckForUpdates() {
}
// static
void AutoUpdater::CheckForUpdatesInBackground() {
}
} // namespace auto_updater

View File

@@ -2,10 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/browser.h"
#include "atom/browser/browser.h"
#include "browser/atom_browser_main_parts.h"
#include "browser/window_list.h"
#include <string>
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/window_list.h"
#include "base/message_loop/message_loop.h"
namespace atom {
@@ -28,11 +31,44 @@ void Browser::Quit() {
atom::WindowList* window_list = atom::WindowList::GetInstance();
if (window_list->size() == 0)
NotifyAndTerminate();
NotifyAndShutdown();
window_list->CloseAllWindows();
}
void Browser::Shutdown() {
is_quiting_ = true;
base::MessageLoop::current()->Quit();
}
std::string Browser::GetVersion() const {
if (version_override_.empty()) {
std::string version = GetExecutableFileVersion();
if (!version.empty())
return version;
}
return version_override_;
}
void Browser::SetVersion(const std::string& version) {
version_override_ = version;
}
std::string Browser::GetName() const {
if (name_override_.empty()) {
std::string name = GetExecutableFileProductName();
if (!name.empty())
return name;
}
return name_override_;
}
void Browser::SetName(const std::string& name) {
name_override_ = name;
}
bool Browser::OpenFile(const std::string& file_path) {
bool prevent_default = false;
FOR_EACH_OBSERVER(BrowserObserver,
@@ -46,6 +82,10 @@ void Browser::OpenURL(const std::string& url) {
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnOpenURL(url));
}
void Browser::ActivateWithNoOpenWindows() {
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnActivateWithNoOpenWindows());
}
void Browser::WillFinishLaunching() {
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillFinishLaunching());
}
@@ -54,7 +94,7 @@ void Browser::DidFinishLaunching() {
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnFinishLaunching());
}
void Browser::NotifyAndTerminate() {
void Browser::NotifyAndShutdown() {
bool prevent_default = false;
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillQuit(&prevent_default));
@@ -63,7 +103,7 @@ void Browser::NotifyAndTerminate() {
return;
}
Terminate();
Shutdown();
}
void Browser::OnWindowCloseCancelled(NativeWindow* window) {
@@ -78,7 +118,7 @@ void Browser::OnWindowCloseCancelled(NativeWindow* window) {
void Browser::OnWindowAllClosed() {
if (is_quiting_)
NotifyAndTerminate();
NotifyAndShutdown();
else
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWindowAllClosed());
}

View File

@@ -5,11 +5,13 @@
#ifndef ATOM_BROWSER_BROWSER_H_
#define ATOM_BROWSER_BROWSER_H_
#include <string>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/observer_list.h"
#include "browser/browser_observer.h"
#include "browser/window_list_observer.h"
#include "atom/browser/browser_observer.h"
#include "atom/browser/window_list_observer.h"
namespace atom {
@@ -24,14 +26,23 @@ class Browser : public WindowListObserver {
// Try to close all windows and quit the application.
void Quit();
// Quit the application immediately without cleanup work.
void Terminate();
// Cleanup everything and shutdown the application gracefully.
void Shutdown();
// Focus the application.
void Focus();
// Returns the version of the executable (or bundle).
std::string GetVersion();
std::string GetVersion() const;
// Overrides the application version.
void SetVersion(const std::string& version);
// Returns the application's name, default is just Atom-Shell.
std::string GetName() const;
// Overrides the application name.
void SetName(const std::string& name);
#if defined(OS_MACOSX)
// Bounce the dock icon.
@@ -53,6 +64,9 @@ class Browser : public WindowListObserver {
// Tell the application to open a url.
void OpenURL(const std::string& url);
// Tell the application that application is activated with no open windows.
void ActivateWithNoOpenWindows();
// Tell the application the loading has been done.
void WillFinishLaunching();
void DidFinishLaunching();
@@ -68,8 +82,14 @@ class Browser : public WindowListObserver {
bool is_quiting() const { return is_quiting_; }
protected:
// Send the will-quit message and then terminate the application.
void NotifyAndTerminate();
// Returns the version of application bundle or executable file.
std::string GetExecutableFileVersion() const;
// Returns the name of application bundle or executable file.
std::string GetExecutableFileProductName() const;
// Send the will-quit message and then shutdown the application.
void NotifyAndShutdown();
// Tell the system we have cancelled quiting.
void CancelQuit();
@@ -84,6 +104,9 @@ class Browser : public WindowListObserver {
// Observers of the browser.
ObserverList<BrowserObserver> observers_;
std::string version_override_;
std::string name_override_;
DISALLOW_COPY_AND_ASSIGN(Browser);
};

View File

@@ -0,0 +1,39 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "atom/browser/browser.h"
#include <stdlib.h>
#include "atom/browser/native_window.h"
#include "atom/browser/window_list.h"
#include "atom/common/atom_version.h"
namespace atom {
void Browser::Focus() {
// Focus on the first visible window.
WindowList* list = WindowList::GetInstance();
for (WindowList::iterator iter = list->begin(); iter != list->end(); ++iter) {
NativeWindow* window = *iter;
if (window->IsVisible()) {
window->Focus(true);
break;
}
}
}
std::string Browser::GetExecutableFileVersion() const {
return ATOM_VERSION_STRING;
}
std::string Browser::GetExecutableFileProductName() const {
return "Atom-Shell";
}
void Browser::CancelQuit() {
// No way to cancel quit on Linux.
}
} // namespace atom

View File

@@ -2,29 +2,30 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/browser.h"
#include "atom/browser/browser.h"
#import "base/mac/bundle_locations.h"
#include "base/strings/sys_string_conversions.h"
#import "browser/atom_application_mac.h"
#import "atom/browser/atom_application_mac.h"
namespace atom {
void Browser::Terminate() {
is_quiting_ = true;
[[AtomApplication sharedApplication] terminate:nil];
}
void Browser::Focus() {
[[AtomApplication sharedApplication] activateIgnoringOtherApps:YES];
}
std::string Browser::GetVersion() {
std::string Browser::GetExecutableFileVersion() const {
NSDictionary* infoDictionary = base::mac::OuterBundle().infoDictionary;
NSString *version = [infoDictionary objectForKey:@"CFBundleVersion"];
return base::SysNSStringToUTF8(version);
}
std::string Browser::GetExecutableFileProductName() const {
NSDictionary* infoDictionary = base::mac::OuterBundle().infoDictionary;
NSString *version = [infoDictionary objectForKey:@"CFBundleName"];
return base::SysNSStringToUTF8(version);
}
void Browser::CancelQuit() {
[[AtomApplication sharedApplication] replyToApplicationShouldTerminate:NO];
}

View File

@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROSER_BROWSER_OBSERVER_H_
#define ATOM_BROSER_BROWSER_OBSERVER_H_
#ifndef ATOM_BROWSER_BROWSER_OBSERVER_H_
#define ATOM_BROWSER_BROWSER_OBSERVER_H_
#include <string>
@@ -26,6 +26,10 @@ class BrowserObserver {
// Browser is used to open a url.
virtual void OnOpenURL(const std::string& url) {}
// The browser is activated with no open windows (usually by clicking on the
// dock icon).
virtual void OnActivateWithNoOpenWindows() {}
// The browser has finished loading.
virtual void OnWillFinishLaunching() {}
virtual void OnFinishLaunching() {}
@@ -36,4 +40,4 @@ class BrowserObserver {
} // namespace atom
#endif // ATOM_BROSER_BROWSER_OBSERVER_H_
#endif // ATOM_BROWSER_BROWSER_OBSERVER_H_

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/browser.h"
#include "atom/browser/browser.h"
#include <windows.h>
@@ -12,6 +12,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "atom/common/atom_version.h"
namespace atom {
@@ -32,18 +33,13 @@ BOOL CALLBACK WindowsEnumerationHandler(HWND hwnd, LPARAM param) {
} // namespace
void Browser::Terminate() {
is_quiting_ = true;
PostQuitMessage(0);
}
void Browser::Focus() {
// On Windows we just focus on the first window found for this process.
DWORD pid = GetCurrentProcessId();
EnumWindows(&WindowsEnumerationHandler, reinterpret_cast<LPARAM>(&pid));
}
std::string Browser::GetVersion() {
std::string Browser::GetExecutableFileVersion() const {
base::FilePath path;
if (PathService::Get(base::FILE_EXE, &path)) {
scoped_ptr<FileVersionInfo> version_info(
@@ -51,7 +47,18 @@ std::string Browser::GetVersion() {
return UTF16ToUTF8(version_info->product_version());
}
return "";
return ATOM_VERSION_STRING;
}
std::string Browser::GetExecutableFileProductName() const {
base::FilePath path;
if (PathService::Get(base::FILE_EXE, &path)) {
scoped_ptr<FileVersionInfo> version_info(
FileVersionInfo::CreateFileVersionInfo(path));
return UTF16ToUTF8(version_info->product_name());
}
return "Atom-Shell";
}
void Browser::CancelQuit() {

View File

@@ -1,6 +1,5 @@
var app = require('app');
var dialog = require('dialog');
var delegate = require('atom-delegate');
var ipc = require('ipc');
var Menu = require('menu');
var MenuItem = require('menu-item');
@@ -11,14 +10,14 @@ var menu = null;
// Quit when all windows are closed.
app.on('window-all-closed', function() {
app.terminate();
app.quit();
});
app.on('open-url', function(event, url) {
dialog.showMessageBox({message: url, buttons: ['OK']});
});
app.on('finish-launching', function() {
app.on('ready', function() {
app.commandLine.appendSwitch('js-flags', '--harmony_collections');
mainWindow = new BrowserWindow({ width: 800, height: 600 });
@@ -164,11 +163,11 @@ app.on('finish-launching', function() {
submenu: [
{
label: 'Open',
accelerator: 'Command+O',
accelerator: 'Ctrl+O',
},
{
label: 'Close',
accelerator: 'Command+W',
accelerator: 'Ctrl+W',
click: function() { mainWindow.close(); }
},
]
@@ -178,16 +177,16 @@ app.on('finish-launching', function() {
submenu: [
{
label: 'Reload',
accelerator: 'Command+R',
accelerator: 'Ctrl+R',
click: function() { mainWindow.restart(); }
},
{
label: 'Enter Fullscreen',
click: function() { mainWindow.setFullscreen(true); }
click: function() { mainWindow.setFullScreen(true); }
},
{
label: 'Toggle DevTools',
accelerator: 'Alt+Command+I',
accelerator: 'Alt+Ctrl+I',
click: function() { mainWindow.toggleDevTools(); }
},
]

View File

@@ -1,5 +1,4 @@
var app = require('app');
var dialog = require('dialog');
var path = require('path');
var optimist = require('optimist');
@@ -9,7 +8,7 @@ app.on('window-all-closed', function() {
app.quit();
});
var argv = optimist(process.argv.slice(1)).argv;
var argv = optimist(process.argv.slice(1)).boolean('ci').argv;
// Start the specified app if there is one specified in command line, otherwise
// start the default app.

View File

@@ -1,5 +1,5 @@
{
"name": "atom",
"name": "atom-shell-default-app",
"version": "0.1.0",
"main": "main.js",
"dependencies": {

View File

@@ -0,0 +1,124 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "atom/browser/devtools_delegate.h"
#include <string>
#include "base/message_loop/message_loop.h"
#include "base/values.h"
#include "atom/browser/native_window.h"
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/devtools_client_host.h"
#include "content/public/browser/devtools_http_handler.h"
#include "content/public/browser/devtools_manager.h"
#include "content/public/browser/web_contents.h"
#include "ui/gfx/point.h"
namespace atom {
DevToolsDelegate::DevToolsDelegate(NativeWindow* window,
content::WebContents* target_web_contents)
: content::WebContentsObserver(window->GetWebContents()),
owner_window_(window),
delegate_(NULL),
embedder_message_dispatcher_(
new DevToolsEmbedderMessageDispatcher(this)) {
content::WebContents* web_contents = window->GetWebContents();
// Setup devtools.
devtools_agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(
target_web_contents->GetRenderViewHost());
devtools_client_host_.reset(
content::DevToolsClientHost::CreateDevToolsFrontendHost(web_contents,
this));
content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(
devtools_agent_host_.get(), devtools_client_host_.get());
// Go!
base::DictionaryValue options;
options.SetString("title", "DevTools Debugger");
window->InitFromOptions(&options);
window->AddObserver(this);
web_contents->GetController().LoadURL(
GURL("chrome-devtools://devtools/devtools.html?dockSide=undocked"),
content::Referrer(),
content::PAGE_TRANSITION_AUTO_TOPLEVEL,
std::string());
}
DevToolsDelegate::~DevToolsDelegate() {
}
void DevToolsDelegate::DispatchOnEmbedder(const std::string& message) {
embedder_message_dispatcher_->Dispatch(message);
}
void DevToolsDelegate::InspectedContentsClosing() {
owner_window_->Close();
}
void DevToolsDelegate::AboutToNavigateRenderView(
content::RenderViewHost* render_view_host) {
content::DevToolsClientHost::SetupDevToolsFrontendClient(
owner_window_->GetWebContents()->GetRenderViewHost());
}
void DevToolsDelegate::OnWindowClosed() {
base::MessageLoop::current()->DeleteSoon(FROM_HERE, owner_window_);
}
void DevToolsDelegate::ActivateWindow() {
}
void DevToolsDelegate::CloseWindow() {
owner_window_->Close();
}
void DevToolsDelegate::MoveWindow(int x, int y) {
owner_window_->SetPosition(gfx::Point(x, y));
}
void DevToolsDelegate::SetDockSide(const std::string& dock_side) {
bool succeed = true;
if (delegate_ &&
delegate_->DevToolsSetDockSide("attach-back", &succeed) &&
succeed)
owner_window_->Close();
}
void DevToolsDelegate::OpenInNewTab(const std::string& url) {
}
void DevToolsDelegate::SaveToFile(
const std::string& url, const std::string& content, bool save_as) {
}
void DevToolsDelegate::AppendToFile(
const std::string& url, const std::string& content) {
}
void DevToolsDelegate::RequestFileSystems() {
}
void DevToolsDelegate::AddFileSystem() {
}
void DevToolsDelegate::RemoveFileSystem(const std::string& file_system_path) {
}
void DevToolsDelegate::IndexPath(
int request_id, const std::string& file_system_path) {
}
void DevToolsDelegate::StopIndexing(int request_id) {
}
void DevToolsDelegate::SearchInPath(
int request_id,
const std::string& file_system_path,
const std::string& query) {
}
} // namespace atom

View File

@@ -0,0 +1,87 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_DEVTOOLS_DELEGATE_H_
#define ATOM_BROWSER_DEVTOOLS_DELEGATE_H_
#include <string>
#include "base/memory/scoped_ptr.h"
#include "atom/browser/native_window_observer.h"
#include "content/public/browser/devtools_frontend_host_delegate.h"
#include "content/public/browser/web_contents_observer.h"
#include "vendor/brightray/browser/devtools_embedder_message_dispatcher.h"
#include "vendor/brightray/browser/inspectable_web_contents_delegate.h"
namespace content {
class DevToolsAgentHost;
class DevToolsClientHost;
}
using brightray::DevToolsEmbedderMessageDispatcher;
namespace atom {
class NativeWindow;
class DevToolsDelegate : public content::DevToolsFrontendHostDelegate,
public content::WebContentsObserver,
public NativeWindowObserver,
public DevToolsEmbedderMessageDispatcher::Delegate {
public:
DevToolsDelegate(NativeWindow* window,
content::WebContents* target_web_contents);
virtual ~DevToolsDelegate();
void SetDelegate(brightray::InspectableWebContentsDelegate* delegate) {
delegate_ = delegate;
}
protected:
// Implementations of content::DevToolsFrontendHostDelegate.
virtual void DispatchOnEmbedder(const std::string& message) OVERRIDE;
virtual void InspectedContentsClosing() OVERRIDE;
// Implementations of content::WebContentsObserver.
virtual void AboutToNavigateRenderView(
content::RenderViewHost* render_view_host) OVERRIDE;
// Implementations of NativeWindowObserver.
virtual void OnWindowClosed() OVERRIDE;
// Implementations of DevToolsEmbedderMessageDispatcher::Delegate.
virtual void ActivateWindow() OVERRIDE;
virtual void CloseWindow() OVERRIDE;
virtual void MoveWindow(int x, int y) OVERRIDE;
virtual void SetDockSide(const std::string& dock_side) OVERRIDE;
virtual void OpenInNewTab(const std::string& url) OVERRIDE;
virtual void SaveToFile(const std::string& url,
const std::string& content,
bool save_as) OVERRIDE;
virtual void AppendToFile(const std::string& url,
const std::string& content) OVERRIDE;
virtual void RequestFileSystems() OVERRIDE;
virtual void AddFileSystem() OVERRIDE;
virtual void RemoveFileSystem(const std::string& file_system_path) OVERRIDE;
virtual void IndexPath(int request_id,
const std::string& file_system_path) OVERRIDE;
virtual void StopIndexing(int request_id) OVERRIDE;
virtual void SearchInPath(int request_id,
const std::string& file_system_path,
const std::string& query) OVERRIDE;
private:
NativeWindow* owner_window_;
brightray::InspectableWebContentsDelegate* delegate_;
scoped_refptr<content::DevToolsAgentHost> devtools_agent_host_;
scoped_ptr<content::DevToolsClientHost> devtools_client_host_;
scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_;
DISALLOW_COPY_AND_ASSIGN(DevToolsDelegate);
};
} // namespace atom
#endif // ATOM_BROWSER_DEVTOOLS_DELEGATE_H_

View File

@@ -0,0 +1,64 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "atom/browser/devtools_web_contents_observer.h"
#include "atom/browser/api/atom_browser_bindings.h"
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/native_window.h"
#include "atom/common/api/api_messages.h"
#include "base/logging.h"
#include "content/public/browser/render_process_host.h"
#include "ipc/ipc_message_macros.h"
namespace atom {
DevToolsWebContentsObserver::DevToolsWebContentsObserver(
NativeWindow* native_window,
content::WebContents* web_contents)
: content::WebContentsObserver(web_contents),
inspected_window_(native_window) {
DCHECK(native_window);
}
DevToolsWebContentsObserver::~DevToolsWebContentsObserver() {
}
bool DevToolsWebContentsObserver::OnMessageReceived(
const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(DevToolsWebContentsObserver, message)
IPC_MESSAGE_HANDLER(AtomViewHostMsg_Message, OnRendererMessage)
IPC_MESSAGE_HANDLER_DELAY_REPLY(AtomViewHostMsg_Message_Sync,
OnRendererMessageSync)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void DevToolsWebContentsObserver::OnRendererMessage(
const string16& channel,
const base::ListValue& args) {
AtomBrowserMainParts::Get()->atom_bindings()->OnRendererMessage(
web_contents()->GetRenderProcessHost()->GetID(),
web_contents()->GetRoutingID(),
channel,
args);
}
void DevToolsWebContentsObserver::OnRendererMessageSync(
const string16& channel,
const base::ListValue& args,
IPC::Message* reply_msg) {
AtomBrowserMainParts::Get()->atom_bindings()->OnRendererMessageSync(
web_contents()->GetRenderProcessHost()->GetID(),
web_contents()->GetRoutingID(),
channel,
args,
web_contents(),
reply_msg);
}
} // namespace atom

View File

@@ -0,0 +1,41 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_DEVTOOLS_WEB_CONTENTS_OBSERVER_H_
#define ATOM_BROWSER_DEVTOOLS_WEB_CONTENTS_OBSERVER_H_
#include "content/public/browser/web_contents_observer.h"
namespace base {
class ListValue;
}
namespace atom {
class NativeWindow;
class DevToolsWebContentsObserver : public content::WebContentsObserver {
public:
DevToolsWebContentsObserver(NativeWindow* native_window,
content::WebContents* web_contents);
virtual ~DevToolsWebContentsObserver();
protected:
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
void OnRendererMessage(const string16& channel,
const base::ListValue& args);
void OnRendererMessageSync(const string16& channel,
const base::ListValue& args,
IPC::Message* reply_msg);
private:
NativeWindow* inspected_window_;
DISALLOW_COPY_AND_ASSIGN(DevToolsWebContentsObserver);
};
} // namespace atom
#endif // ATOM_BROWSER_DEVTOOLS_WEB_CONTENTS_OBSERVER_H_

View File

@@ -0,0 +1,80 @@
fs = require 'fs'
path = require 'path'
util = require 'util'
# Expose information of current process.
process.__atom_type = 'browser'
process.resourcesPath = path.resolve process.argv[1], '..', '..', '..', '..'
# We modified the original process.argv to let node.js load the atom.js,
# we need to restore it here.
process.argv.splice 1, 1
# Pick out switches appended by atom-shell.
startMark = process.argv.indexOf '--atom-shell-switches-start'
endMark = process.argv.indexOf '--atom-shell-switches-end'
process.execArgv = process.argv.splice startMark, endMark - startMark + 1
# Add browser/api/lib to require's search paths,
# which contains javascript part of Atom's built-in libraries.
globalPaths = require('module').globalPaths
globalPaths.push path.join process.resourcesPath, 'atom', 'browser', 'api', 'lib'
# Do loading in next tick since we still need some initialize work before
# native bindings can work.
setImmediate ->
# Import common settings.
require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init.js')
if process.platform is 'win32'
# Redirect node's console to use our own implementations, since node can not
# handle console output when running as GUI program.
print = (args...) ->
process.log util.format(args...)
console.log = console.error = console.warn = print
process.stdout.write = process.stderr.write = print
# Always returns EOF for stdin stream.
Readable = require('stream').Readable
stdin = new Readable
stdin.push null
process.__defineGetter__ 'stdin', -> stdin
# Don't quit on fatal error.
process.on 'uncaughtException', (error) ->
# Show error in GUI.
message = error.stack ? "#{error.name}: #{error.message}"
require('dialog').showMessageBox
type: 'warning'
title: 'An javascript error occured in the browser'
message: 'uncaughtException'
detail: message
buttons: ['OK']
# Load the RPC server.
require './rpc-server.js'
# Now we try to load app's package.json.
packageJson = null
packagePath = path.join process.resourcesPath, 'app'
try
# First we try to load process.resourcesPath/app
packageJson = JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json')))
catch error
# If not found then we load browser/default_app
packagePath = path.join process.resourcesPath, 'default_app'
packageJson = JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json')))
# Set application's version.
app = require 'app'
app.setVersion packageJson.version if packageJson.version?
# Set application's name.
if packageJson.productName?
app.setName packageJson.productName
else if packageJson.name?
app.setName packageJson.name
# Finally load app's main.js and transfer control to C++.
require path.join(packagePath, packageJson.main)

View File

@@ -1,4 +1,3 @@
BrowserWindow = require 'browser-window'
EventEmitter = require('events').EventEmitter
IDWeakMap = require 'id-weak-map'
v8Util = process.atomBinding 'v8_util'
@@ -41,6 +40,8 @@ class ObjectsStore
class ObjectsRegistry extends EventEmitter
constructor: ->
@setMaxListeners Number.MAX_VALUE
# Objects in weak map will be not referenced (so we won't leak memory), and
# every object created in browser will have a unique id in weak map.
@objectsWeakMap = new IDWeakMap
@@ -49,13 +50,6 @@ class ObjectsRegistry extends EventEmitter
v8Util.setHiddenValue obj, 'atomId', id
id
# Remember all windows in the weak map.
@windowsWeakMap = new IDWeakMap
process.on 'ATOM_BROWSER_INTERNAL_NEW', (obj) =>
if obj.constructor is BrowserWindow
id = @windowsWeakMap.add obj
obj.on 'destroyed', => @windowsWeakMap.remove id
# Register a new object, the object would be kept referenced until you release
# it explicitly.
add: (processId, routingId, obj) ->
@@ -87,9 +81,4 @@ class ObjectsRegistry extends EventEmitter
@emit "release-renderer-view-#{processId}-#{routingId}"
ObjectsStore.releaseForRenderView processId, routingId
# Return an array of all browser windows.
getAllWindows: ->
keys = @windowsWeakMap.keys()
@windowsWeakMap.get key for key in keys
module.exports = new ObjectsRegistry

View File

@@ -78,6 +78,10 @@ callFunction = (event, processId, routingId, func, caller, args) ->
ret = func.apply caller, args
event.returnValue = valueToMeta processId, routingId, ret
# Send by BrowserWindow when its render view is deleted.
process.on 'ATOM_BROWSER_RELEASE_RENDER_VIEW', (processId, routingId) ->
objectsRegistry.clear processId, routingId
ipc.on 'ATOM_BROWSER_REQUIRE', (event, processId, routingId, module) ->
try
event.returnValue = valueToMeta processId, routingId, require(module)
@@ -90,14 +94,11 @@ ipc.on 'ATOM_BROWSER_GLOBAL', (event, processId, routingId, name) ->
catch e
event.returnValue = errorToMeta e
ipc.on 'ATOM_BROWSER_RELEASE_RENDER_VIEW', (event, processId, routingId) ->
objectsRegistry.clear processId, routingId
event.returnValue = null
ipc.on 'ATOM_BROWSER_CURRENT_WINDOW', (event, processId, routingId) ->
try
BrowserWindow = require 'browser-window'
window = BrowserWindow.fromProcessIdAndRoutingId processId, routingId
window = BrowserWindow.fromDevTools processId, routingId unless window?
event.returnValue = valueToMeta processId, routingId, window
catch e
event.returnValue = errorToMeta e

View File

@@ -2,21 +2,32 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/native_window.h"
#include "atom/browser/native_window.h"
#include <string>
#include <utility>
#include <vector>
#include "atom/browser/api/atom_browser_bindings.h"
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/atom_javascript_dialog_manager.h"
#include "atom/browser/browser.h"
#include "atom/browser/devtools_delegate.h"
#include "atom/browser/devtools_web_contents_observer.h"
#include "atom/browser/ui/file_dialog.h"
#include "atom/browser/window_list.h"
#include "atom/common/api/api_messages.h"
#include "atom/common/atom_version.h"
#include "atom/common/options_switches.h"
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/message_loop.h"
#include "base/utf_string_conversions.h"
#include "base/json/json_writer.h"
#include "base/prefs/pref_service.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "brightray/browser/inspectable_web_contents.h"
#include "brightray/browser/inspectable_web_contents_view.h"
#include "browser/api/atom_browser_bindings.h"
#include "browser/atom_browser_context.h"
#include "browser/atom_browser_main_parts.h"
#include "browser/atom_javascript_dialog_manager.h"
#include "browser/window_list.h"
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/invalidate_type.h"
#include "content/public/browser/navigation_entry.h"
@@ -26,14 +37,17 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "common/api/api_messages.h"
#include "common/options_switches.h"
#include "content/public/browser/web_contents_view.h"
#include "content/public/common/renderer_preferences.h"
#include "ipc/ipc_message_macros.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
#include "webkit/glue/image_decoder.h"
#include "vendor/brightray/browser/inspectable_web_contents.h"
#include "vendor/brightray/browser/inspectable_web_contents_view.h"
#include "webkit/common/user_agent/user_agent_util.h"
#include "webkit/common/webpreferences.h"
using content::NavigationEntry;
@@ -44,21 +58,41 @@ NativeWindow::NativeWindow(content::WebContents* web_contents,
: content::WebContentsObserver(web_contents),
has_frame_(true),
is_closed_(false),
not_responding_(false),
node_integration_("except-iframe"),
has_dialog_attached_(false),
weak_factory_(this),
inspectable_web_contents_(
brightray::InspectableWebContents::Create(web_contents)) {
options->GetBoolean(switches::kFrame, &has_frame_);
#if defined(OS_MACOSX)
// Temporary fix for flashing devtools, try removing this after upgraded to
// Chrome 32.
web_contents->GetView()->SetAllowOverlappingViews(false);
#endif
// Read icon before window is created.
std::string icon;
if (options->GetString(switches::kIcon, &icon)) {
if (!SetIcon(icon))
LOG(ERROR) << "Failed to set icon to " << icon;
}
if (options->GetString(switches::kIcon, &icon) && !SetIcon(icon))
LOG(ERROR) << "Failed to set icon to " << icon;
// Read iframe security before any navigation.
options->GetString(switches::kNodeIntegration, &node_integration_);
web_contents->SetDelegate(this);
inspectable_web_contents()->SetDelegate(this);
WindowList::AddWindow(this);
// Override the user agent to contain application and atom-shell's version.
Browser* browser = Browser::Get();
std::string product_name = base::StringPrintf(
"%s/%s Atom-Shell/" ATOM_VERSION_STRING,
browser->GetName().c_str(),
browser->GetVersion().c_str());
web_contents->GetMutableRendererPrefs()->user_agent_override =
webkit_glue::BuildUserAgentFromProduct(product_name);
// Get notified of title updated message.
registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
content::Source<content::WebContents>(web_contents));
@@ -76,6 +110,14 @@ NativeWindow* NativeWindow::Create(base::DictionaryValue* options) {
return Create(content::WebContents::Create(create_params), options);
}
// static
NativeWindow* NativeWindow::Debug(content::WebContents* web_contents) {
base::DictionaryValue options;
NativeWindow* window = NativeWindow::Create(&options);
window->devtools_delegate_.reset(new DevToolsDelegate(window, web_contents));
return window;
}
// static
NativeWindow* NativeWindow::FromRenderView(int process_id, int routing_id) {
// Stupid iterating.
@@ -142,16 +184,37 @@ void NativeWindow::InitFromOptions(base::DictionaryValue* options) {
Show();
}
bool NativeWindow::HasModalDialog() {
return has_dialog_attached_;
}
void NativeWindow::OpenDevTools() {
inspectable_web_contents()->ShowDevTools();
if (devtools_window_) {
devtools_window_->Focus(true);
devtools_web_contents_observer_.reset(new DevToolsWebContentsObserver(
this, devtools_window_->GetWebContents()));
} else {
inspectable_web_contents()->ShowDevTools();
devtools_web_contents_observer_.reset(new DevToolsWebContentsObserver(
this, GetDevToolsWebContents()));
#if defined(OS_MACOSX)
// Temporary fix for flashing devtools, try removing this after upgraded to
// Chrome 32.
GetDevToolsWebContents()->GetView()->SetAllowOverlappingViews(false);
#endif
}
}
void NativeWindow::CloseDevTools() {
inspectable_web_contents()->GetView()->CloseDevTools();
if (devtools_window_)
devtools_window_->Close();
else
inspectable_web_contents()->CloseDevTools();
}
bool NativeWindow::IsDevToolsOpened() {
return inspectable_web_contents()->IsDevToolsOpened();
return (devtools_window_ && devtools_window_->IsFocused()) ||
inspectable_web_contents()->IsDevToolsViewShowing();
}
void NativeWindow::InspectElement(int x, int y) {
@@ -162,6 +225,11 @@ void NativeWindow::InspectElement(int x, int y) {
agent->InspectElement(x, y);
}
void NativeWindow::ExecuteJavaScriptInDevTools(const std::string& script) {
GetDevToolsWebContents()->GetRenderViewHost()->ExecuteJavascriptInWebFrame(
string16(), base::UTF8ToUTF16(script));
}
void NativeWindow::FocusOnWebView() {
GetWebContents()->GetRenderViewHost()->Focus();
}
@@ -171,11 +239,9 @@ void NativeWindow::BlurWebView() {
}
bool NativeWindow::IsWebViewFocused() {
return GetWebContents()->GetRenderViewHost()->GetView()->HasFocus();
}
void NativeWindow::RestartHangMonitorTimeout() {
GetWebContents()->GetRenderViewHost()->RestartHangMonitorTimeout();
content::RenderWidgetHostView* host_view =
GetWebContents()->GetRenderViewHost()->GetView();
return host_view && host_view->HasFocus();
}
bool NativeWindow::SetIcon(const std::string& str_path) {
@@ -183,15 +249,14 @@ bool NativeWindow::SetIcon(const std::string& str_path) {
// Read the file from disk.
std::string file_contents;
if (path.empty() || !file_util::ReadFileToString(path, &file_contents))
if (path.empty() || !base::ReadFileToString(path, &file_contents))
return false;
// Decode the bitmap using WebKit's image decoder.
const unsigned char* data =
reinterpret_cast<const unsigned char*>(file_contents.data());
webkit_glue::ImageDecoder decoder;
scoped_ptr<SkBitmap> decoded(new SkBitmap());
*decoded = decoder.Decode(data, file_contents.length());
gfx::PNGCodec::Decode(data, file_contents.length(), decoded.get());
if (decoded->empty())
return false; // Unable to decode.
@@ -199,13 +264,36 @@ bool NativeWindow::SetIcon(const std::string& str_path) {
return true;
}
base::ProcessHandle NativeWindow::GetRenderProcessHandle() {
return GetWebContents()->GetRenderProcessHost()->GetHandle();
}
void NativeWindow::CapturePage(const gfx::Rect& rect,
const CapturePageCallback& callback) {
content::RenderViewHost* render_view_host =
GetWebContents()->GetRenderViewHost();
content::RenderWidgetHostView* render_widget_host_view =
render_view_host->GetView();
if (!render_widget_host_view) {
callback.Run(std::vector<unsigned char>());
return;
}
gfx::Rect flipped_y_rect = rect;
flipped_y_rect.set_y(-rect.y());
gfx::Size size;
if (flipped_y_rect.IsEmpty())
size = render_widget_host_view->GetViewBounds().size();
else
size = flipped_y_rect.size();
GetWebContents()->GetRenderViewHost()->CopyFromBackingStore(
rect,
gfx::Size(),
flipped_y_rect,
size,
base::Bind(&NativeWindow::OnCapturePageDone,
base::Unretained(this),
weak_factory_.GetWeakPtr(),
callback));
}
@@ -221,6 +309,13 @@ void NativeWindow::CloseWebContents() {
content::WebContents* web_contents(GetWebContents());
// Assume the window is not responding if it doesn't cancel the close and is
// not closed in 5000ms, in this way we can quickly show the unresponsive
// dialog when the window is busy executing some script withouth waiting for
// the unresponsive timeout.
if (window_unresposive_closure_.IsCancelled())
ScheduleUnresponsiveEvent(5000);
if (web_contents->NeedToFireBeforeUnload())
web_contents->GetRenderViewHost()->FirePageBeforeUnload(false);
else
@@ -231,10 +326,35 @@ content::WebContents* NativeWindow::GetWebContents() const {
return inspectable_web_contents_->GetWebContents();
}
content::WebContents* NativeWindow::GetDevToolsWebContents() const {
return inspectable_web_contents()->devtools_web_contents();
}
void NativeWindow::AppendExtraCommandLineSwitches(CommandLine* command_line,
int child_process_id) {
// Append --node-integration to renderer process.
command_line->AppendSwitchASCII(switches::kNodeIntegration,
node_integration_);
}
void NativeWindow::OverrideWebkitPrefs(const GURL& url, WebPreferences* prefs) {
// FIXME Disable accelerated composition in frameless window.
if (!has_frame_)
prefs->accelerated_compositing_enabled = false;
}
void NativeWindow::NotifyWindowClosed() {
if (is_closed_)
return;
// The OnRenderViewDeleted is not called when the WebContents is destroyed
// directly (e.g. when closing the window), so we make sure it's always
// emitted to users by sending it before window is closed..
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
OnRenderViewDeleted(
GetWebContents()->GetRenderProcessHost()->GetID(),
GetWebContents()->GetRoutingID()));
is_closed_ = true;
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowClosed());
@@ -245,22 +365,28 @@ void NativeWindow::NotifyWindowBlur() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowBlur());
}
// Window opened by window.open.
void NativeWindow::WebContentsCreated(
content::WebContents* source_contents,
int64 source_frame_id,
const string16& frame_name,
const GURL& target_url,
content::WebContents* new_contents) {
LOG(WARNING) << "Please use node-style Window API to create window, "
"using window.open has very strict constrains.";
// In atom-shell all reloads and navigations started by renderer process would
// be redirected to this method, so we can have precise control of how we
// would open the url (in our case, is to restart the renderer process). See
// AtomRendererClient::ShouldFork for how this is done.
content::WebContents* NativeWindow::OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params) {
if (params.disposition != CURRENT_TAB)
return NULL;
scoped_ptr<base::DictionaryValue> options(new base::DictionaryValue);
options->SetInteger(switches::kWidth, 800);
options->SetInteger(switches::kHeight, 600);
content::NavigationController::LoadURLParams load_url_params(params.url);
load_url_params.referrer = params.referrer;
load_url_params.transition_type = params.transition;
load_url_params.extra_headers = params.extra_headers;
load_url_params.should_replace_current_entry =
params.should_replace_current_entry;
load_url_params.is_renderer_initiated = params.is_renderer_initiated;
load_url_params.transferred_global_request_id =
params.transferred_global_request_id;
NativeWindow* window = Create(new_contents, options.get());
window->InitFromOptions(options.get());
source->GetController().LoadURLWithParams(load_url_params);
return source;
}
content::JavaScriptDialogManager* NativeWindow::GetJavaScriptDialogManager() {
@@ -277,6 +403,9 @@ void NativeWindow::BeforeUnloadFired(content::WebContents* tab,
if (!proceed)
WindowList::WindowCloseCancelled(this);
// When the "beforeunload" callback is fired the window is certainly live.
window_unresposive_closure_.Cancel();
}
void NativeWindow::RequestToLockMouse(content::WebContents* web_contents,
@@ -319,6 +448,9 @@ void NativeWindow::CloseContents(content::WebContents* source) {
CloseImmediately();
NotifyWindowClosed();
// Do not sent "unresponsive" event after window is closed.
window_unresposive_closure_.Cancel();
}
bool NativeWindow::IsPopupOrPanel(const content::WebContents* source) const {
@@ -327,19 +459,32 @@ bool NativeWindow::IsPopupOrPanel(const content::WebContents* source) const {
}
void NativeWindow::RendererUnresponsive(content::WebContents* source) {
not_responding_ = true;
base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&NativeWindow::RendererUnresponsiveDelayed,
base::Unretained(this)),
base::TimeDelta::FromSeconds(1));
// Schedule the unresponsive shortly later, since we may receive the
// responsive event soon.
// This could happen after the whole application had blocked for a while.
ScheduleUnresponsiveEvent(50);
}
void NativeWindow::RendererResponsive(content::WebContents* source) {
not_responding_ = false;
window_unresposive_closure_.Cancel();
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRendererResponsive());
}
void NativeWindow::RenderViewDeleted(content::RenderViewHost* rvh) {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
OnRenderViewDeleted(rvh->GetProcess()->GetID(),
rvh->GetRoutingID()));
}
void NativeWindow::RenderProcessGone(base::TerminationStatus status) {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRendererCrashed());
}
void NativeWindow::BeforeUnloadFired(const base::TimeTicks& proceed_time) {
// Do nothing, we override this method just to avoid compilation error since
// there are two virtual functions named BeforeUnloadFired.
}
bool NativeWindow::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(NativeWindow, message)
@@ -354,17 +499,6 @@ bool NativeWindow::OnMessageReceived(const IPC::Message& message) {
return handled;
}
void NativeWindow::RenderViewGone(base::TerminationStatus status) {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRendererCrashed());
}
void NativeWindow::RendererUnresponsiveDelayed() {
if (not_responding_)
FOR_EACH_OBSERVER(NativeWindowObserver,
observers_,
OnRendererUnresponsive());
}
void NativeWindow::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
@@ -385,6 +519,76 @@ void NativeWindow::Observe(int type,
}
}
bool NativeWindow::DevToolsSetDockSide(const std::string& dock_side,
bool* succeed) {
if (dock_side == "undocked") {
*succeed = false;
return true;
} else {
return false;
}
}
bool NativeWindow::DevToolsShow(std::string* dock_side) {
if (*dock_side == "undocked")
*dock_side = "bottom";
return false;
}
void NativeWindow::DevToolsSaveToFile(const std::string& url,
const std::string& content,
bool save_as) {
base::FilePath path;
PathsMap::iterator it = saved_files_.find(url);
if (it != saved_files_.end() && !save_as) {
path = it->second;
} else {
if (!file_dialog::ShowSaveDialog(this, url, base::FilePath(url), &path))
return;
}
saved_files_[url] = path;
file_util::WriteFile(path, content.data(), content.size());
// Notify devtools.
base::StringValue url_value(url);
CallDevToolsFunction("InspectorFrontendAPI.savedURL", &url_value);
// TODO(zcbenz): In later Chrome we need to call canceledSaveURL when the save
// failed.
}
void NativeWindow::DevToolsAppendToFile(const std::string& url,
const std::string& content) {
PathsMap::iterator it = saved_files_.find(url);
if (it == saved_files_.end())
return;
file_util::AppendToFile(it->second, content.data(), content.size());
// Notify devtools.
base::StringValue url_value(url);
CallDevToolsFunction("InspectorFrontendAPI.appendedToURL", &url_value);
}
void NativeWindow::ScheduleUnresponsiveEvent(int ms) {
window_unresposive_closure_.Reset(
base::Bind(&NativeWindow::NotifyWindowUnresponsive,
weak_factory_.GetWeakPtr()));
base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
window_unresposive_closure_.callback(),
base::TimeDelta::FromMilliseconds(ms));
}
void NativeWindow::NotifyWindowUnresponsive() {
window_unresposive_closure_.Cancel();
if (!HasModalDialog())
FOR_EACH_OBSERVER(NativeWindowObserver,
observers_,
OnRendererUnresponsive());
}
void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback,
bool succeed,
const SkBitmap& bitmap) {
@@ -394,6 +598,27 @@ void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback,
callback.Run(data);
}
void NativeWindow::CallDevToolsFunction(const std::string& function_name,
const base::Value* arg1,
const base::Value* arg2,
const base::Value* arg3) {
std::string params;
if (arg1) {
std::string json;
base::JSONWriter::Write(arg1, &json);
params.append(json);
if (arg2) {
base::JSONWriter::Write(arg2, &json);
params.append(", " + json);
if (arg3) {
base::JSONWriter::Write(arg3, &json);
params.append(", " + json);
}
}
}
ExecuteJavaScriptInDevTools(function_name + "(" + params + ");");
}
void NativeWindow::OnRendererMessage(const string16& channel,
const base::ListValue& args) {
AtomBrowserMainParts::Get()->atom_bindings()->OnRendererMessage(
@@ -411,7 +636,7 @@ void NativeWindow::OnRendererMessageSync(const string16& channel,
GetWebContents()->GetRoutingID(),
channel,
args,
this,
GetWebContents(),
reply_msg);
}

View File

@@ -5,26 +5,32 @@
#ifndef ATOM_BROWSER_NATIVE_WINDOW_H_
#define ATOM_BROWSER_NATIVE_WINDOW_H_
#include <map>
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "base/cancelable_callback.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "browser/native_window_observer.h"
#include "atom/browser/native_window_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/web_contents_observer.h"
#include "ui/gfx/image/image.h"
#include "vendor/brightray/browser/default_web_contents_delegate.h"
#include "vendor/brightray/browser/inspectable_web_contents_delegate.h"
#include "vendor/brightray/browser/inspectable_web_contents_impl.h"
class CommandLine;
struct WebPreferences;
namespace base {
class DictionaryValue;
class ListValue;
}
namespace brightray {
class InspectableWebContents;
}
namespace content {
class BrowserContext;
class WebContents;
@@ -36,31 +42,55 @@ class Rect;
class Size;
}
namespace IPC {
class Message;
}
namespace atom {
class AtomJavaScriptDialogManager;
class DevToolsDelegate;
class DevToolsWebContentsObserver;
struct DraggableRegion;
class NativeWindow : public brightray::DefaultWebContentsDelegate,
public brightray::InspectableWebContentsDelegate,
public content::WebContentsObserver,
public content::NotificationObserver {
public:
typedef base::Callback<void(const std::vector<unsigned char>& buffer)>
CapturePageCallback;
class DialogScope {
public:
explicit DialogScope(NativeWindow* window)
: window_(window) {
if (window_ != NULL)
window_->set_has_dialog_attached(true);
}
~DialogScope() {
if (window_ != NULL)
window_->set_has_dialog_attached(false);
}
private:
NativeWindow* window_;
DISALLOW_COPY_AND_ASSIGN(DialogScope);
};
virtual ~NativeWindow();
// Create window with existing WebContents.
// Create window with existing WebContents, the caller is responsible for
// managing the window's live.
static NativeWindow* Create(content::WebContents* web_contents,
base::DictionaryValue* options);
// Create window with new WebContents.
// Create window with new WebContents, the caller is responsible for
// managing the window's live.
static NativeWindow* Create(base::DictionaryValue* options);
// Creates a devtools window to debug the WebContents, the returned window
// will manage its own life.
static NativeWindow* Debug(content::WebContents* web_contents);
// Find a window from its process id and routing id.
static NativeWindow* FromRenderView(int process_id, int routing_id);
@@ -98,6 +128,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
virtual void FlashFrame(bool flash) = 0;
virtual void SetKiosk(bool kiosk) = 0;
virtual bool IsKiosk() = 0;
virtual bool HasModalDialog();
virtual gfx::NativeWindow GetNativeWindow() = 0;
virtual bool IsClosed() const { return is_closed_; }
@@ -105,12 +136,18 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
virtual void CloseDevTools();
virtual bool IsDevToolsOpened();
virtual void InspectElement(int x, int y);
virtual void ExecuteJavaScriptInDevTools(const std::string& script);
virtual void FocusOnWebView();
virtual void BlurWebView();
virtual bool IsWebViewFocused();
virtual void RestartHangMonitorTimeout();
virtual bool SetIcon(const std::string& path);
// Returns the process handle of render process, useful for killing the
// render process manually
virtual base::ProcessHandle GetRenderProcessHandle();
// Captures the page with |rect|, |callback| would be called when capturing is
// done.
virtual void CapturePage(const gfx::Rect& rect,
@@ -121,7 +158,17 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
// Should be called by platform code when user want to close the window.
virtual void CloseWebContents();
base::WeakPtr<NativeWindow> GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
content::WebContents* GetWebContents() const;
content::WebContents* GetDevToolsWebContents() const;
// Called when renderer process is going to be started.
void AppendExtraCommandLineSwitches(CommandLine* command_line,
int child_process_id);
void OverrideWebkitPrefs(const GURL& url, WebPreferences* prefs);
void AddObserver(NativeWindowObserver* obs) {
observers_.AddObserver(obs);
@@ -133,12 +180,17 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
bool has_frame() const { return has_frame_; }
void set_has_dialog_attached(bool has_dialog_attached) {
has_dialog_attached_ = has_dialog_attached;
}
protected:
explicit NativeWindow(content::WebContents* web_contents,
base::DictionaryValue* options);
brightray::InspectableWebContents* inspectable_web_contents() const {
return inspectable_web_contents_.get();
brightray::InspectableWebContentsImpl* inspectable_web_contents() const {
return static_cast<brightray::InspectableWebContentsImpl*>(
inspectable_web_contents_.get());
}
void NotifyWindowClosed();
@@ -149,11 +201,9 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
const std::vector<DraggableRegion>& regions) = 0;
// Implementations of content::WebContentsDelegate.
virtual void WebContentsCreated(content::WebContents* source_contents,
int64 source_frame_id,
const string16& frame_name,
const GURL& target_url,
content::WebContents* new_contents) OVERRIDE;
virtual content::WebContents* OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params) OVERRIDE;
virtual content::JavaScriptDialogManager*
GetJavaScriptDialogManager() OVERRIDE;
virtual void BeforeUnloadFired(content::WebContents* tab,
@@ -175,14 +225,26 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
virtual void RendererResponsive(content::WebContents* source) OVERRIDE;
// Implementations of content::WebContentsObserver.
virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
virtual void RenderViewDeleted(content::RenderViewHost*) OVERRIDE;
virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
virtual void BeforeUnloadFired(const base::TimeTicks& proceed_time) OVERRIDE;
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
// Implementations of content::NotificationObserver
// Implementations of content::NotificationObserver.
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
// Implementations of brightray::InspectableWebContentsDelegate.
virtual bool DevToolsSetDockSide(const std::string& dock_side,
bool* succeed) OVERRIDE;
virtual bool DevToolsShow(std::string* dock_side) OVERRIDE;
virtual void DevToolsSaveToFile(const std::string& url,
const std::string& content,
bool save_as) OVERRIDE;
virtual void DevToolsAppendToFile(const std::string& url,
const std::string& content) OVERRIDE;
// Whether window has standard frame.
bool has_frame_;
@@ -190,7 +252,17 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
gfx::Image icon_;
private:
void RendererUnresponsiveDelayed();
// Schedule a notification unresponsive event.
void ScheduleUnresponsiveEvent(int ms);
// Dispatch unresponsive event to observers.
void NotifyWindowUnresponsive();
// Call a function in devtools.
void CallDevToolsFunction(const std::string& function_name,
const base::Value* arg1 = NULL,
const base::Value* arg2 = NULL,
const base::Value* arg3 = NULL);
// Called when CapturePage has done.
void OnCapturePageDone(const CapturePageCallback& callback,
@@ -213,12 +285,31 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
// The windows has been closed.
bool is_closed_;
// The window is not responding.
bool not_responding_;
// The security token of iframe.
std::string node_integration_;
// There is a dialog that has been attached to window.
bool has_dialog_attached_;
// Closure that would be called when window is unresponsive when closing,
// it should be cancelled when we can prove that the window is responsive.
base::CancelableClosure window_unresposive_closure_;
base::WeakPtrFactory<NativeWindow> weak_factory_;
base::WeakPtr<NativeWindow> devtools_window_;
scoped_ptr<DevToolsDelegate> devtools_delegate_;
// WebContentsObserver for the WebContents of devtools.
scoped_ptr<DevToolsWebContentsObserver> devtools_web_contents_observer_;
scoped_ptr<AtomJavaScriptDialogManager> dialog_manager_;
scoped_ptr<brightray::InspectableWebContents> inspectable_web_contents_;
// Maps url to file path, used by the file requests sent from devtools.
typedef std::map<std::string, base::FilePath> PathsMap;
PathsMap saved_files_;
DISALLOW_COPY_AND_ASSIGN(NativeWindow);
};

View File

@@ -0,0 +1,527 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "atom/browser/native_window_gtk.h"
#include <string>
#include <vector>
#include "atom/common/draggable_region.h"
#include "atom/common/options_switches.h"
#include "base/environment.h"
#include "base/nix/xdg_util.h"
#include "base/values.h"
#include "chrome/browser/ui/gtk/gtk_window_util.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "content/public/common/renderer_preferences.h"
#include "ui/base/accelerators/platform_accelerator_gtk.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/base/x/active_window_watcher_x.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/gtk_util.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/skia_utils_gtk.h"
namespace atom {
namespace {
// Dividing GTK's cursor blink cycle time (in milliseconds) by this value yields
// an appropriate value for content::RendererPreferences::caret_blink_interval.
// This matches the logic in the WebKit GTK port.
const double kGtkCursorBlinkCycleFactor = 2000.0;
// Substract window border's size from window size according to current window
// manager.
void SubstractBorderSize(int* width, int* height) {
scoped_ptr<base::Environment> env(base::Environment::Create());
base::nix::DesktopEnvironment de(base::nix::GetDesktopEnvironment(env.get()));
if (de == base::nix::DESKTOP_ENVIRONMENT_UNITY) {
*width -= 2;
*height -= 29;
} else if (de == base::nix::DESKTOP_ENVIRONMENT_GNOME) {
*width -= 2;
*height -= 33;
} else if (de == base::nix::DESKTOP_ENVIRONMENT_XFCE) {
*width -= 6;
*height -= 27;
} else {
*width -= 2;
*height -= 29;
}
}
} // namespace
NativeWindowGtk::NativeWindowGtk(content::WebContents* web_contents,
base::DictionaryValue* options)
: NativeWindow(web_contents, options),
window_(GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL))),
vbox_(gtk_vbox_new(FALSE, 0)),
state_(GDK_WINDOW_STATE_WITHDRAWN),
is_always_on_top_(false),
is_active_(false),
suppress_window_raise_(false),
has_ever_been_shown_(false),
frame_cursor_(NULL) {
gtk_container_add(GTK_CONTAINER(window_), vbox_);
gtk_container_add(GTK_CONTAINER(vbox_),
GetWebContents()->GetView()->GetNativeView());
int width = 800, height = 600;
options->GetInteger(switches::kWidth, &width);
options->GetInteger(switches::kHeight, &height);
// Fixup the initial window size.
if (has_frame_)
SubstractBorderSize(&width, &height);
// Force a size allocation so the web page of hidden window can have correct
// value of $(window).width().
GtkAllocation size = { 0, 0, width, height };
gtk_widget_show_all(vbox_);
gtk_widget_size_allocate(GTK_WIDGET(window_), &size);
gtk_window_util::SetWindowSize(window_, gfx::Size(width, height));
// Create the underlying gdk window.
gtk_widget_realize(GTK_WIDGET(window_));
if (!icon_.IsEmpty())
gtk_window_set_icon(window_, icon_.ToGdkPixbuf());
ui::ActiveWindowWatcherX::AddObserver(this);
// In some (older) versions of compiz, raising top-level windows when they
// are partially off-screen causes them to get snapped back on screen, not
// always even on the current virtual desktop. If we are running under
// compiz, suppress such raises, as they are not necessary in compiz anyway.
if (ui::GuessWindowManager() == ui::WM_COMPIZ)
suppress_window_raise_ = true;
g_signal_connect(window_, "delete-event",
G_CALLBACK(OnWindowDeleteEventThunk), this);
g_signal_connect(window_, "focus-out-event",
G_CALLBACK(OnFocusOutThunk), this);
g_signal_connect(window_, "window-state-event",
G_CALLBACK(OnWindowStateThunk), this);
if (!has_frame_) {
gtk_window_set_decorated(window_, false);
g_signal_connect(window_, "motion-notify-event",
G_CALLBACK(OnMouseMoveEventThunk), this);
g_signal_connect(window_, "button-press-event",
G_CALLBACK(OnButtonPressThunk), this);
}
SetWebKitColorStyle();
}
NativeWindowGtk::~NativeWindowGtk() {
ui::ActiveWindowWatcherX::RemoveObserver(this);
if (window_)
gtk_widget_destroy(GTK_WIDGET(window_));
}
void NativeWindowGtk::Close() {
CloseWebContents();
}
void NativeWindowGtk::CloseImmediately() {
gtk_widget_destroy(GTK_WIDGET(window_));
window_ = NULL;
}
void NativeWindowGtk::Move(const gfx::Rect& pos) {
gtk_window_move(window_, pos.x(), pos.y());
SetSize(pos.size());
}
void NativeWindowGtk::Focus(bool focus) {
if (!IsVisible())
return;
if (focus)
gtk_window_present(window_);
else
gdk_window_lower(gtk_widget_get_window(GTK_WIDGET(window_)));
}
bool NativeWindowGtk::IsFocused() {
if (ui::ActiveWindowWatcherX::WMSupportsActivation())
return is_active_;
// This still works even though we don't get the activation notification.
return gtk_window_is_active(window_);
}
void NativeWindowGtk::Show() {
has_ever_been_shown_ = true;
gtk_widget_show_all(GTK_WIDGET(window_));
}
void NativeWindowGtk::Hide() {
gtk_widget_hide(GTK_WIDGET(window_));
}
bool NativeWindowGtk::IsVisible() {
return gtk_widget_get_visible(GTK_WIDGET(window_));
}
void NativeWindowGtk::Maximize() {
gtk_window_maximize(window_);
}
void NativeWindowGtk::Unmaximize() {
gtk_window_unmaximize(window_);
}
void NativeWindowGtk::Minimize() {
gtk_window_iconify(window_);
}
void NativeWindowGtk::Restore() {
gtk_window_present(window_);
}
void NativeWindowGtk::SetFullscreen(bool fullscreen) {
if (fullscreen)
gtk_window_fullscreen(window_);
else
gtk_window_unfullscreen(window_);
}
bool NativeWindowGtk::IsFullscreen() {
return state_ & GDK_WINDOW_STATE_FULLSCREEN;
}
void NativeWindowGtk::SetSize(const gfx::Size& size) {
// When the window has not been mapped the window size does not include frame.
int width = size.width();
int height = size.height();
if (has_frame_ && !has_ever_been_shown_)
SubstractBorderSize(&width, &height);
gtk_window_util::SetWindowSize(window_, gfx::Size(width, height));
}
gfx::Size NativeWindowGtk::GetSize() {
GdkWindow* gdk_window = gtk_widget_get_window(GTK_WIDGET(window_));
GdkRectangle frame_extents;
gdk_window_get_frame_extents(gdk_window, &frame_extents);
return gfx::Size(frame_extents.width, frame_extents.height);
}
void NativeWindowGtk::SetMinimumSize(const gfx::Size& size) {
minimum_size_ = size;
GdkGeometry geometry = { 0 };
geometry.min_width = size.width();
geometry.min_height = size.height();
int hints = GDK_HINT_POS | GDK_HINT_MIN_SIZE;
gtk_window_set_geometry_hints(
window_, GTK_WIDGET(window_), &geometry, (GdkWindowHints)hints);
}
gfx::Size NativeWindowGtk::GetMinimumSize() {
return minimum_size_;
}
void NativeWindowGtk::SetMaximumSize(const gfx::Size& size) {
maximum_size_ = size;
GdkGeometry geometry = { 0 };
geometry.max_width = size.width();
geometry.max_height = size.height();
int hints = GDK_HINT_POS | GDK_HINT_MAX_SIZE;
gtk_window_set_geometry_hints(
window_, GTK_WIDGET(window_), &geometry, (GdkWindowHints)hints);
}
gfx::Size NativeWindowGtk::GetMaximumSize() {
return maximum_size_;
}
void NativeWindowGtk::SetResizable(bool resizable) {
// Should request widget size after setting unresizable, otherwise the
// window will shrink to a very small size.
if (!IsResizable()) {
gint width, height;
gtk_window_get_size(window_, &width, &height);
gtk_widget_set_size_request(GTK_WIDGET(window_), width, height);
}
gtk_window_set_resizable(window_, resizable);
}
bool NativeWindowGtk::IsResizable() {
return gtk_window_get_resizable(window_);
}
void NativeWindowGtk::SetAlwaysOnTop(bool top) {
is_always_on_top_ = top;
gtk_window_set_keep_above(window_, top ? TRUE : FALSE);
}
bool NativeWindowGtk::IsAlwaysOnTop() {
return is_always_on_top_;
}
void NativeWindowGtk::Center() {
gtk_window_set_position(window_, GTK_WIN_POS_CENTER);
}
void NativeWindowGtk::SetPosition(const gfx::Point& position) {
gtk_window_move(window_, position.x(), position.y());
}
gfx::Point NativeWindowGtk::GetPosition() {
GdkWindow* gdk_window = gtk_widget_get_window(GTK_WIDGET(window_));
GdkRectangle frame_extents;
gdk_window_get_frame_extents(gdk_window, &frame_extents);
return gfx::Point(frame_extents.x, frame_extents.y);
}
void NativeWindowGtk::SetTitle(const std::string& title) {
gtk_window_set_title(window_, title.c_str());
}
std::string NativeWindowGtk::GetTitle() {
return gtk_window_get_title(window_);
}
void NativeWindowGtk::FlashFrame(bool flash) {
gtk_window_set_urgency_hint(window_, flash);
}
void NativeWindowGtk::SetKiosk(bool kiosk) {
SetFullscreen(kiosk);
}
bool NativeWindowGtk::IsKiosk() {
return IsFullscreen();
}
gfx::NativeWindow NativeWindowGtk::GetNativeWindow() {
return window_;
}
void NativeWindowGtk::SetMenu(ui::MenuModel* menu_model) {
menu_.reset(new ::MenuGtk(this, menu_model, true));
gtk_box_pack_start(GTK_BOX(vbox_), menu_->widget(), FALSE, FALSE, 0);
gtk_box_reorder_child(GTK_BOX(vbox_), menu_->widget(), 0);
RegisterAccelerators();
}
void NativeWindowGtk::UpdateDraggableRegions(
const std::vector<DraggableRegion>& regions) {
// Draggable region is not supported for non-frameless window.
if (has_frame_)
return;
draggable_region_.reset(new SkRegion);
// By default, the whole window is non-draggable. We need to explicitly
// include those draggable regions.
for (std::vector<DraggableRegion>::const_iterator iter =
regions.begin();
iter != regions.end(); ++iter) {
const DraggableRegion& region = *iter;
draggable_region_->op(
region.bounds.x(),
region.bounds.y(),
region.bounds.right(),
region.bounds.bottom(),
region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
}
}
void NativeWindowGtk::HandleKeyboardEvent(
content::WebContents*,
const content::NativeWebKeyboardEvent& event) {
if (event.type == WebKit::WebInputEvent::RawKeyDown) {
GdkEventKey* os_event = reinterpret_cast<GdkEventKey*>(event.os_event);
ui::Accelerator accelerator = ui::AcceleratorForGdkKeyCodeAndModifier(
os_event->keyval, static_cast<GdkModifierType>(os_event->state));
accelerator_util::TriggerAcceleratorTableCommand(&accelerator_table_,
accelerator);
}
}
void NativeWindowGtk::ActiveWindowChanged(GdkWindow* active_window) {
is_active_ = gtk_widget_get_window(GTK_WIDGET(window_)) == active_window;
}
void NativeWindowGtk::RegisterAccelerators() {
DCHECK(menu_);
accelerator_table_.clear();
accelerator_util::GenerateAcceleratorTable(&accelerator_table_,
menu_->model());
}
void NativeWindowGtk::SetWebKitColorStyle() {
content::RendererPreferences* prefs =
GetWebContents()->GetMutableRendererPrefs();
GtkStyle* frame_style = gtk_rc_get_style(GTK_WIDGET(window_));
prefs->focus_ring_color =
gfx::GdkColorToSkColor(frame_style->bg[GTK_STATE_SELECTED]);
prefs->thumb_active_color = SkColorSetRGB(244, 244, 244);
prefs->thumb_inactive_color = SkColorSetRGB(234, 234, 234);
prefs->track_color = SkColorSetRGB(211, 211, 211);
GtkWidget* url_entry = gtk_entry_new();
GtkStyle* entry_style = gtk_rc_get_style(url_entry);
prefs->active_selection_bg_color =
gfx::GdkColorToSkColor(entry_style->base[GTK_STATE_SELECTED]);
prefs->active_selection_fg_color =
gfx::GdkColorToSkColor(entry_style->text[GTK_STATE_SELECTED]);
prefs->inactive_selection_bg_color =
gfx::GdkColorToSkColor(entry_style->base[GTK_STATE_ACTIVE]);
prefs->inactive_selection_fg_color =
gfx::GdkColorToSkColor(entry_style->text[GTK_STATE_ACTIVE]);
gtk_widget_destroy(url_entry);
const base::TimeDelta cursor_blink_time = gfx::GetCursorBlinkCycle();
prefs->caret_blink_interval =
cursor_blink_time.InMilliseconds() ?
cursor_blink_time.InMilliseconds() / kGtkCursorBlinkCycleFactor :
0;
}
bool NativeWindowGtk::IsMaximized() const {
return state_ & GDK_WINDOW_STATE_MAXIMIZED;
}
bool NativeWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) {
if (has_frame_)
return false;
if (IsMaximized() || IsFullscreen())
return false;
return gtk_window_util::GetWindowEdge(GetSize(), 0, x, y, edge);
}
gboolean NativeWindowGtk::OnWindowDeleteEvent(GtkWidget* widget,
GdkEvent* event) {
Close();
return TRUE;
}
gboolean NativeWindowGtk::OnFocusOut(GtkWidget* window, GdkEventFocus*) {
NotifyWindowBlur();
return FALSE;
}
gboolean NativeWindowGtk::OnWindowState(GtkWidget* window,
GdkEventWindowState* event) {
state_ = event->new_window_state;
return FALSE;
}
gboolean NativeWindowGtk::OnMouseMoveEvent(GtkWidget* widget,
GdkEventMotion* event) {
if (has_frame_) {
// Reset the cursor.
if (frame_cursor_) {
frame_cursor_ = NULL;
gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(window_)), NULL);
}
return FALSE;
}
if (!IsResizable())
return FALSE;
// Update the cursor if we're on the custom frame border.
GdkWindowEdge edge;
bool has_hit_edge = GetWindowEdge(static_cast<int>(event->x),
static_cast<int>(event->y), &edge);
GdkCursorType new_cursor = GDK_LAST_CURSOR;
if (has_hit_edge)
new_cursor = gtk_window_util::GdkWindowEdgeToGdkCursorType(edge);
GdkCursorType last_cursor = GDK_LAST_CURSOR;
if (frame_cursor_)
last_cursor = frame_cursor_->type;
if (last_cursor != new_cursor) {
frame_cursor_ = has_hit_edge ? gfx::GetCursor(new_cursor) : NULL;
gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(window_)),
frame_cursor_);
}
return FALSE;
}
gboolean NativeWindowGtk::OnButtonPress(GtkWidget* widget,
GdkEventButton* event) {
DCHECK(!has_frame_);
// Make the button press coordinate relative to the browser window.
int win_x, win_y;
GdkWindow* gdk_window = gtk_widget_get_window(GTK_WIDGET(window_));
gdk_window_get_origin(gdk_window, &win_x, &win_y);
GdkWindowEdge edge;
gfx::Point point(static_cast<int>(event->x_root - win_x),
static_cast<int>(event->y_root - win_y));
bool has_hit_edge = IsResizable() &&
GetWindowEdge(point.x(), point.y(), &edge);
bool has_hit_titlebar =
draggable_region_ && draggable_region_->contains(event->x, event->y);
if (event->button == 1) {
if (GDK_BUTTON_PRESS == event->type) {
// Raise the window after a click on either the titlebar or the border to
// match the behavior of most window managers, unless that behavior has
// been suppressed.
if ((has_hit_titlebar || has_hit_edge) && !suppress_window_raise_)
gdk_window_raise(GTK_WIDGET(widget)->window);
if (has_hit_edge) {
gtk_window_begin_resize_drag(window_, edge, event->button,
static_cast<gint>(event->x_root),
static_cast<gint>(event->y_root),
event->time);
return TRUE;
} else if (has_hit_titlebar) {
GdkRectangle window_bounds = {0};
gdk_window_get_frame_extents(gdk_window, &window_bounds);
gfx::Rect bounds(window_bounds.x, window_bounds.y,
window_bounds.width, window_bounds.height);
return gtk_window_util::HandleTitleBarLeftMousePress(
window_, bounds, event);
}
} else if (GDK_2BUTTON_PRESS == event->type) {
if (has_hit_titlebar && IsResizable()) {
// Maximize/restore on double click.
if (IsMaximized())
gtk_window_unmaximize(window_);
else
gtk_window_maximize(window_);
return TRUE;
}
}
} else if (event->button == 2) {
if (has_hit_titlebar || has_hit_edge)
gdk_window_lower(gdk_window);
return TRUE;
}
return FALSE;
}
// static
NativeWindow* NativeWindow::Create(content::WebContents* web_contents,
base::DictionaryValue* options) {
return new NativeWindowGtk(web_contents, options);
}
} // namespace atom

View File

@@ -0,0 +1,150 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_NATIVE_WINDOW_GTK_H_
#define ATOM_BROWSER_NATIVE_WINDOW_GTK_H_
#include <gtk/gtk.h>
#include <string>
#include <vector>
#include "atom/browser/native_window.h"
#include "atom/browser/ui/accelerator_util.h"
#include "chrome/browser/ui/gtk/menu_gtk.h"
#include "third_party/skia/include/core/SkRegion.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/gtk/gtk_signal.h"
#include "ui/base/x/active_window_watcher_x_observer.h"
#include "ui/gfx/size.h"
namespace atom {
class NativeWindowGtk : public NativeWindow,
public MenuGtk::Delegate,
public ui::ActiveWindowWatcherXObserver {
public:
explicit NativeWindowGtk(content::WebContents* web_contents,
base::DictionaryValue* options);
virtual ~NativeWindowGtk();
// NativeWindow implementation.
virtual void Close() OVERRIDE;
virtual void CloseImmediately() OVERRIDE;
virtual void Move(const gfx::Rect& pos) OVERRIDE;
virtual void Focus(bool focus) OVERRIDE;
virtual bool IsFocused() OVERRIDE;
virtual void Show() OVERRIDE;
virtual void Hide() OVERRIDE;
virtual bool IsVisible() OVERRIDE;
virtual void Maximize() OVERRIDE;
virtual void Unmaximize() OVERRIDE;
virtual void Minimize() OVERRIDE;
virtual void Restore() OVERRIDE;
virtual void SetFullscreen(bool fullscreen) OVERRIDE;
virtual bool IsFullscreen() OVERRIDE;
virtual void SetSize(const gfx::Size& size) OVERRIDE;
virtual gfx::Size GetSize() OVERRIDE;
virtual void SetMinimumSize(const gfx::Size& size) OVERRIDE;
virtual gfx::Size GetMinimumSize() OVERRIDE;
virtual void SetMaximumSize(const gfx::Size& size) OVERRIDE;
virtual gfx::Size GetMaximumSize() OVERRIDE;
virtual void SetResizable(bool resizable) OVERRIDE;
virtual bool IsResizable() OVERRIDE;
virtual void SetAlwaysOnTop(bool top) OVERRIDE;
virtual bool IsAlwaysOnTop() OVERRIDE;
virtual void Center() OVERRIDE;
virtual void SetPosition(const gfx::Point& position) OVERRIDE;
virtual gfx::Point GetPosition() OVERRIDE;
virtual void SetTitle(const std::string& title) OVERRIDE;
virtual std::string GetTitle() OVERRIDE;
virtual void FlashFrame(bool flash) OVERRIDE;
virtual void SetKiosk(bool kiosk) OVERRIDE;
virtual bool IsKiosk() OVERRIDE;
virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
// Set the native window menu.
void SetMenu(ui::MenuModel* menu_model);
protected:
virtual void UpdateDraggableRegions(
const std::vector<DraggableRegion>& regions) OVERRIDE;
// Overridden from content::WebContentsDelegate:
virtual void HandleKeyboardEvent(
content::WebContents*,
const content::NativeWebKeyboardEvent&) OVERRIDE;
// Overridden from ActiveWindowWatcherXObserver.
virtual void ActiveWindowChanged(GdkWindow* active_window) OVERRIDE;
private:
// Register accelerators supported by the menu model.
void RegisterAccelerators();
// Set WebKit's style from current theme.
void SetWebKitColorStyle();
// Whether window is maximized.
bool IsMaximized() const;
// If the point (|x|, |y|) is within the resize border area of the window,
// returns true and sets |edge| to the appropriate GdkWindowEdge value.
// Otherwise, returns false.
bool GetWindowEdge(int x, int y, GdkWindowEdge* edge);
CHROMEGTK_CALLBACK_1(NativeWindowGtk, gboolean, OnWindowDeleteEvent,
GdkEvent*);
CHROMEGTK_CALLBACK_1(NativeWindowGtk, gboolean, OnFocusOut, GdkEventFocus*);
CHROMEGTK_CALLBACK_1(NativeWindowGtk, gboolean, OnWindowState,
GdkEventWindowState*);
// Mouse move and mouse button press callbacks.
CHROMEGTK_CALLBACK_1(NativeWindowGtk, gboolean, OnMouseMoveEvent,
GdkEventMotion*);
CHROMEGTK_CALLBACK_1(NativeWindowGtk, gboolean, OnButtonPress,
GdkEventButton*);
GtkWindow* window_;
GtkWidget* vbox_;
GdkWindowState state_;
bool is_always_on_top_;
gfx::Size minimum_size_;
gfx::Size maximum_size_;
// The region is treated as title bar, can be dragged to move and double
// clicked to maximize.
scoped_ptr<SkRegion> draggable_region_;
// True if the window manager thinks the window is active. It could happpen
// that the WM thinks a window is active but it's actually not, like when
// showing a context menu.
bool is_active_;
// If true, don't call gdk_window_raise() when we get a click in the title
// bar or window border. This is to work around a compiz bug.
bool suppress_window_raise_;
// True if the window has been visible for once, on Linux the window frame
// would // only be considered as part of the window untill the window has
// been shown, so we need it to correctly set the window size.
bool has_ever_been_shown_;
// The current window cursor. We set it to a resize cursor when over the
// custom frame border. We set it to NULL if we want the default cursor.
GdkCursor* frame_cursor_;
// The window menu.
scoped_ptr<MenuGtk> menu_;
// Map from accelerator to menu item's command id.
accelerator_util::AcceleratorTable accelerator_table_;
DISALLOW_COPY_AND_ASSIGN(NativeWindowGtk);
};
} // namespace atom
#endif // ATOM_BROWSER_NATIVE_WINDOW_GTK_H_

View File

@@ -8,7 +8,7 @@
#import <Cocoa/Cocoa.h>
#include "base/memory/scoped_ptr.h"
#include "browser/native_window.h"
#include "atom/browser/native_window.h"
class SkRegion;
@@ -53,6 +53,7 @@ class NativeWindowMac : public NativeWindow {
virtual void FlashFrame(bool flash) OVERRIDE;
virtual void SetKiosk(bool kiosk) OVERRIDE;
virtual bool IsKiosk() OVERRIDE;
virtual bool HasModalDialog() OVERRIDE;
virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
void NotifyWindowBlur() { NativeWindow::NotifyWindowBlur(); }

View File

@@ -2,22 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/native_window_mac.h"
#include "atom/browser/native_window_mac.h"
#include <string>
// FIXME: The foundation_util.h is aborting our compilation, do not
// include it.
#define BASE_MAC_FOUNDATION_UTIL_H_
#include "base/mac/mac_util.h"
#include "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h"
#include "base/values.h"
#import "browser/ui/atom_event_processing_window.h"
#import "atom/browser/ui/cocoa/event_processing_window.h"
#include "brightray/browser/inspectable_web_contents.h"
#include "brightray/browser/inspectable_web_contents_view.h"
#include "common/draggable_region.h"
#include "common/options_switches.h"
#include "atom/common/draggable_region.h"
#include "atom/common/options_switches.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
@@ -32,18 +29,26 @@ static const CGFloat kAtomWindowCornerRadius = 4.0;
@interface AtomNSWindowDelegate : NSObject<NSWindowDelegate> {
@private
atom::NativeWindowMac* shell_;
BOOL acceptsFirstMouse_;
}
- (id)initWithShell:(atom::NativeWindowMac*)shell;
- (void)setAcceptsFirstMouse:(BOOL)accept;
@end
@implementation AtomNSWindowDelegate
- (id)initWithShell:(atom::NativeWindowMac*)shell {
if ((self = [super init]))
if ((self = [super init])) {
shell_ = shell;
acceptsFirstMouse_ = NO;
}
return self;
}
- (void)setAcceptsFirstMouse:(BOOL)accept {
acceptsFirstMouse_ = accept;
}
- (void)windowDidResignMain:(NSNotification*)notification {
shell_->NotifyWindowBlur();
}
@@ -53,6 +58,13 @@ static const CGFloat kAtomWindowCornerRadius = 4.0;
shell_->ClipWebView();
}
- (void)windowDidExitFullScreen:(NSNotification*)notification {
if (!shell_->has_frame()) {
NSWindow* window = shell_->GetNativeWindow();
[[window standardWindowButton:NSWindowFullScreenButton] setHidden:YES];
}
}
- (void)windowWillClose:(NSNotification*)notification {
shell_->window() = nil;
[self autorelease];
@@ -66,21 +78,17 @@ static const CGFloat kAtomWindowCornerRadius = 4.0;
return NO;
}
- (void)windowDidExitFullScreen:(NSNotification*)notification {
if (!shell_->has_frame()) {
NSWindow* window = shell_->GetNativeWindow();
[[window standardWindowButton:NSWindowFullScreenButton] setHidden:YES];
}
- (BOOL)acceptsFirstMouse:(NSEvent*)event {
return acceptsFirstMouse_;
}
@end
@interface AtomNSWindow : AtomEventProcessingWindow {
@interface AtomNSWindow : EventProcessingWindow {
@protected
atom::NativeWindowMac* shell_;
}
- (void)setShell:(atom::NativeWindowMac*)shell;
- (IBAction)showDevTools:(id)sender;
@end
@implementation AtomNSWindow
@@ -141,7 +149,7 @@ NativeWindowMac::NativeWindowMac(content::WebContents* web_contents,
: NativeWindow(web_contents, options),
is_kiosk_(false),
attention_request_id_(0) {
int width, height;
int width = 800, height = 600;
options->GetInteger(switches::kWidth, &width);
options->GetInteger(switches::kHeight, &height);
@@ -165,7 +173,14 @@ NativeWindowMac::NativeWindowMac(content::WebContents* web_contents,
[atomWindow setShell:this];
window_ = atomWindow;
[window() setDelegate:[[AtomNSWindowDelegate alloc] initWithShell:this]];
AtomNSWindowDelegate* delegate =
[[AtomNSWindowDelegate alloc] initWithShell:this];
[window() setDelegate:delegate];
// Enable the NSView to accept first mouse event.
bool acceptsFirstMouse = false;
options->GetBoolean(switches::kAcceptFirstMouse, &acceptsFirstMouse);
[delegate setAcceptsFirstMouse:acceptsFirstMouse];
// Disable fullscreen button when 'fullscreen' is specified to false.
bool fullscreen;
@@ -184,7 +199,8 @@ NativeWindowMac::NativeWindowMac(content::WebContents* web_contents,
NativeWindowMac::~NativeWindowMac() {
if (window())
[window() release];
// Use autorelease since we may have delegates or observers at this time.
[window() autorelease];
}
void NativeWindowMac::Close() {
@@ -387,6 +403,10 @@ bool NativeWindowMac::IsKiosk() {
return is_kiosk_;
}
bool NativeWindowMac::HasModalDialog() {
return [window() attachedSheet] != nil;
}
gfx::NativeWindow NativeWindowMac::GetNativeWindow() {
return window();
}
@@ -435,9 +455,9 @@ void NativeWindowMac::HandleKeyboardEvent(
event.type == content::NativeWebKeyboardEvent::Char)
return;
AtomEventProcessingWindow* event_window =
static_cast<AtomEventProcessingWindow*>(window());
DCHECK([event_window isKindOfClass:[AtomEventProcessingWindow class]]);
EventProcessingWindow* event_window =
static_cast<EventProcessingWindow*>(window());
DCHECK([event_window isKindOfClass:[EventProcessingWindow class]]);
[event_window redispatchKeyEvent:event.os_event];
}
@@ -486,7 +506,7 @@ void NativeWindowMac::InstallDraggableRegionViews() {
// Note that [webView subviews] returns the view's mutable internal array and
// it should be copied to avoid mutating the original array while enumerating
// it.
scoped_nsobject<NSArray> subviews([[webView subviews] copy]);
base::scoped_nsobject<NSArray> subviews([[webView subviews] copy]);
for (NSView* subview in subviews.get())
if ([subview isKindOfClass:[ControlRegionView class]])
[subview removeFromSuperview];
@@ -497,7 +517,7 @@ void NativeWindowMac::InstallDraggableRegionViews() {
system_drag_exclude_areas_.begin();
iter != system_drag_exclude_areas_.end();
++iter) {
scoped_nsobject<NSView> controlRegion(
base::scoped_nsobject<NSView> controlRegion(
[[ControlRegionView alloc] initWithShellWindow:this]);
[controlRegion setFrame:NSMakeRect(iter->x(),
webViewHeight - iter->bottom(),

View File

@@ -35,6 +35,9 @@ class NativeWindowObserver {
// Called when renderer recovers.
virtual void OnRendererResponsive() {}
// Called when a render view has been deleted.
virtual void OnRenderViewDeleted(int process_id, int routing_id) {}
// Called when renderer has crashed.
virtual void OnRendererCrashed() {}
};

View File

@@ -2,16 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/native_window_win.h"
#include "atom/browser/native_window_win.h"
#include "base/stl_util.h"
#include <string>
#include <vector>
#include "atom/browser/api/atom_api_menu.h"
#include "atom/browser/ui/win/menu_2.h"
#include "atom/browser/ui/win/native_menu_win.h"
#include "atom/common/draggable_region.h"
#include "atom/common/options_switches.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "browser/api/atom_api_menu.h"
#include "browser/ui/win/menu_2.h"
#include "browser/ui/win/native_menu_win.h"
#include "common/draggable_region.h"
#include "common/options_switches.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h"
@@ -401,7 +403,7 @@ void NativeWindowWin::UpdateDraggableRegions(
void NativeWindowWin::HandleKeyboardEvent(
content::WebContents*,
const content::NativeWebKeyboardEvent& event) {
if (event.type == WebKit::WebInputEvent::KeyUp) {
if (event.type == WebKit::WebInputEvent::RawKeyDown) {
ui::Accelerator accelerator(
static_cast<ui::KeyboardCode>(event.windowsKeyCode),
content::GetModifiersFromNativeWebKeyboardEvent(event));
@@ -423,22 +425,16 @@ void NativeWindowWin::Layout() {
OnViewWasResized();
}
void NativeWindowWin::ViewHierarchyChanged(bool is_add,
views::View* parent,
views::View* child) {
if (is_add && child == this)
void NativeWindowWin::ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) {
if (details.is_add && details.child == this)
AddChildView(web_view_);
}
bool NativeWindowWin::AcceleratorPressed(
const ui::Accelerator& accelerator) {
if (ContainsKey(accelerator_table_, accelerator)) {
const MenuItem& item = accelerator_table_[accelerator];
item.model->ActivatedAt(item.position);
return true;
} else {
return false;
}
return accelerator_util::TriggerAcceleratorTableCommand(
&accelerator_table_, accelerator);
}
void NativeWindowWin::DeleteDelegate() {
@@ -531,39 +527,17 @@ void NativeWindowWin::RegisterAccelerators() {
accelerator_table_.clear();
focus_manager->UnregisterAccelerators(this);
GenerateAcceleratorTable();
for (AcceleratorTable::const_iterator iter = accelerator_table_.begin();
iter != accelerator_table_.end(); ++iter) {
accelerator_util::GenerateAcceleratorTable(&accelerator_table_,
menu_->model());
accelerator_util::AcceleratorTable::const_iterator iter;
for (iter = accelerator_table_.begin();
iter != accelerator_table_.end();
++iter) {
focus_manager->RegisterAccelerator(
iter->first, ui::AcceleratorManager::kNormalPriority, this);
}
}
void NativeWindowWin::GenerateAcceleratorTable() {
DCHECK(menu_);
ui::SimpleMenuModel* model = static_cast<ui::SimpleMenuModel*>(
menu_->model());
FillAcceleratorTable(&accelerator_table_, model);
}
void NativeWindowWin::FillAcceleratorTable(AcceleratorTable* table,
ui::MenuModel* model) {
int count = model->GetItemCount();
for (int i = 0; i < count; ++i) {
ui::MenuModel::ItemType type = model->GetTypeAt(i);
if (type == ui::MenuModel::TYPE_SUBMENU) {
ui::MenuModel* submodel = model->GetSubmenuModelAt(i);
FillAcceleratorTable(table, submodel);
} else {
ui::Accelerator accelerator;
if (model->GetAcceleratorAt(i, &accelerator)) {
MenuItem item = { i, model };
(*table)[accelerator] = item;
}
}
}
}
// static
NativeWindow* NativeWindow::Create(content::WebContents* web_contents,
base::DictionaryValue* options) {

View File

@@ -5,10 +5,14 @@
#ifndef ATOM_BROWSER_NATIVE_WINDOW_WIN_H_
#define ATOM_BROWSER_NATIVE_WINDOW_WIN_H_
#include "base/string16.h"
#include <map>
#include <string>
#include <vector>
#include "base/memory/scoped_ptr.h"
#include "browser/native_window.h"
#include "base/strings/string16.h"
#include "atom/browser/native_window.h"
#include "atom/browser/ui/accelerator_util.h"
#include "ui/gfx/size.h"
#include "ui/views/widget/widget_delegate.h"
@@ -86,9 +90,8 @@ class NativeWindowWin : public NativeWindow,
// Overridden from views::View:
virtual void Layout() OVERRIDE;
virtual void ViewHierarchyChanged(bool is_add,
views::View* parent,
views::View* child) OVERRIDE;
virtual void ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) OVERRIDE;
virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
// Overridden from views::WidgetDelegate:
@@ -115,13 +118,6 @@ class NativeWindowWin : public NativeWindow,
// Register accelerators supported by the menu model.
void RegisterAccelerators();
// Generate a table that contains memu model's accelerators and command ids.
void GenerateAcceleratorTable();
// Helper to fill the accelerator table from the model.
void FillAcceleratorTable(AcceleratorTable* table,
ui::MenuModel* model);
scoped_ptr<views::Widget> window_;
views::WebView* web_view_; // managed by window_.
@@ -129,7 +125,7 @@ class NativeWindowWin : public NativeWindow,
scoped_ptr<atom::Menu2> menu_;
// Map from accelerator to menu item's command id.
AcceleratorTable accelerator_table_;
accelerator_util::AcceleratorTable accelerator_table_;
scoped_ptr<SkRegion> draggable_region_;

View File

@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/net/adapter_request_job.h"
#include "atom/browser/net/adapter_request_job.h"
#include "browser/net/url_request_string_job.h"
#include "base/threading/sequenced_worker_pool.h"
#include "atom/browser/net/url_request_string_job.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/net_errors.h"
#include "net/url_request/url_request_error_job.h"
@@ -87,7 +88,13 @@ void AdapterRequestJob::CreateStringJobAndStart(const std::string& mime_type,
void AdapterRequestJob::CreateFileJobAndStart(const base::FilePath& path) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
real_job_ = new net::URLRequestFileJob(request(), network_delegate(), path);
real_job_ = new net::URLRequestFileJob(
request(),
network_delegate(),
path,
content::BrowserThread::GetBlockingPool()->
GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
real_job_->Start();
}

View File

@@ -5,6 +5,8 @@
#ifndef ATOM_BROWSER_NET_ADAPTER_REQUEST_JOB_H_
#define ATOM_BROWSER_NET_ADAPTER_REQUEST_JOB_H_
#include <string>
#include "base/memory/weak_ptr.h"
#include "net/url_request/url_request_job.h"
#include "net/url_request/url_request_job_factory.h"

View File

@@ -2,11 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/net/atom_url_request_context_getter.h"
#include "atom/browser/net/atom_url_request_context_getter.h"
#include "base/string_util.h"
#include <algorithm>
#include "atom/browser/net/atom_url_request_job_factory.h"
#include "base/strings/string_util.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/worker_pool.h"
#include "browser/net/atom_url_request_job_factory.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/cookie_store_factory.h"
#include "content/public/common/url_constants.h"
@@ -36,15 +39,15 @@ using content::BrowserThread;
AtomURLRequestContextGetter::AtomURLRequestContextGetter(
const base::FilePath& base_path,
MessageLoop* io_loop,
MessageLoop* file_loop,
scoped_ptr<brightray::NetworkDelegate> network_delegate,
base::MessageLoop* io_loop,
base::MessageLoop* file_loop,
base::Callback<scoped_ptr<brightray::NetworkDelegate>(void)> factory,
content::ProtocolHandlerMap* protocol_handlers)
: base_path_(base_path),
io_loop_(io_loop),
file_loop_(file_loop),
job_factory_(NULL),
network_delegate_(network_delegate.Pass()) {
network_delegate_factory_(factory) {
// Must first be created on the UI thread.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -65,8 +68,10 @@ AtomURLRequestContextGetter::~AtomURLRequestContextGetter() {
net::URLRequestContext* AtomURLRequestContextGetter::GetURLRequestContext() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
base::AutoLock auto_lock(lock_);
if (!url_request_context_.get()) {
url_request_context_.reset(new net::URLRequestContext());
network_delegate_ = network_delegate_factory_.Run().Pass();
url_request_context_->set_network_delegate(network_delegate_.get());
storage_.reset(
new net::URLRequestContextStorage(url_request_context_.get()));
@@ -74,6 +79,7 @@ net::URLRequestContext* AtomURLRequestContextGetter::GetURLRequestContext() {
base_path_.Append(FILE_PATH_LITERAL("Cookies")),
false,
nullptr,
nullptr,
nullptr));
storage_->set_server_bound_cert_service(new net::ServerBoundCertService(
new net::DefaultServerBoundCertStore(NULL),
@@ -87,6 +93,7 @@ net::URLRequestContext* AtomURLRequestContextGetter::GetURLRequestContext() {
net::DhcpProxyScriptFetcherFactory dhcp_factory;
storage_->set_cert_verifier(net::CertVerifier::CreateDefault());
storage_->set_transport_security_state(new net::TransportSecurityState);
storage_->set_proxy_service(
net::CreateProxyServiceUsingV8ProxyResolver(
proxy_config_service_.release(),
@@ -98,7 +105,9 @@ net::URLRequestContext* AtomURLRequestContextGetter::GetURLRequestContext() {
storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults);
storage_->set_http_auth_handler_factory(
net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get()));
storage_->set_http_server_properties(new net::HttpServerPropertiesImpl);
scoped_ptr<net::HttpServerProperties> server_properties(
new net::HttpServerPropertiesImpl);
storage_->set_http_server_properties(server_properties.Pass());
base::FilePath cache_path = base_path_.Append(FILE_PATH_LITERAL("Cache"));
net::HttpCache::DefaultBackend* main_backend =
@@ -112,6 +121,8 @@ net::URLRequestContext* AtomURLRequestContextGetter::GetURLRequestContext() {
net::HttpNetworkSession::Params network_session_params;
network_session_params.cert_verifier =
url_request_context_->cert_verifier();
network_session_params.transport_security_state =
url_request_context_->transport_security_state();
network_session_params.server_bound_cert_service =
url_request_context_->server_bound_cert_service();
network_session_params.proxy_service =
@@ -147,10 +158,15 @@ net::URLRequestContext* AtomURLRequestContextGetter::GetURLRequestContext() {
}
protocol_handlers_.clear();
scoped_ptr<net::FileProtocolHandler> file_protocol_handler(
new net::FileProtocolHandler(
content::BrowserThread::GetBlockingPool()->
GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
job_factory_->SetProtocolHandler(chrome::kDataScheme,
new net::DataProtocolHandler);
job_factory_->SetProtocolHandler(chrome::kFileScheme,
new net::FileProtocolHandler);
file_protocol_handler.release());
storage_->set_job_factory(job_factory_);
}

View File

@@ -5,8 +5,10 @@
#ifndef ATOM_BROWSER_NET_ATOM_URL_REQUEST_CONTEXT_GETTER_H_
#define ATOM_BROWSER_NET_ATOM_URL_REQUEST_CONTEXT_GETTER_H_
#include "base/callback.h"
#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
#include "content/public/browser/content_browser_client.h"
#include "net/url_request/url_request_context_getter.h"
@@ -34,7 +36,7 @@ class AtomURLRequestContextGetter : public net::URLRequestContextGetter {
const base::FilePath& base_path,
base::MessageLoop* io_loop,
base::MessageLoop* file_loop,
scoped_ptr<brightray::NetworkDelegate> network_delegate,
base::Callback<scoped_ptr<brightray::NetworkDelegate>(void)>,
content::ProtocolHandlerMap* protocol_handlers);
// net::URLRequestContextGetter implementations:
@@ -53,7 +55,12 @@ class AtomURLRequestContextGetter : public net::URLRequestContextGetter {
base::FilePath base_path_;
base::MessageLoop* io_loop_;
base::MessageLoop* file_loop_;
AtomURLRequestJobFactory* job_factory_;
base::Callback<scoped_ptr<brightray::NetworkDelegate>(void)>
network_delegate_factory_;
base::Lock lock_;
scoped_ptr<net::ProxyConfigService> proxy_config_service_;
scoped_ptr<brightray::NetworkDelegate> network_delegate_;

View File

@@ -3,10 +3,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/net/atom_url_request_job_factory.h"
#include "atom/browser/net/atom_url_request_job_factory.h"
#include "base/stl_util.h"
#include "googleurl/src/gurl.h"
#include "net/base/load_flags.h"
#include "net/url_request/url_request.h"
@@ -102,4 +101,9 @@ bool AtomURLRequestJobFactory::IsHandledURL(const GURL& url) const {
return IsHandledProtocol(url.scheme());
}
bool AtomURLRequestJobFactory::IsSafeRedirectTarget(
const GURL& location) const {
return IsHandledURL(location);
}
} // namespace atom

View File

@@ -3,10 +3,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_NET_ATOM_URL_REQUEST_URL_REQUEST_JOB_FACTORY_H_
#define ATOM_BROWSER_NET_ATOM_URL_REQUEST_URL_REQUEST_JOB_FACTORY_H_
#ifndef ATOM_BROWSER_NET_ATOM_URL_REQUEST_JOB_FACTORY_H_
#define ATOM_BROWSER_NET_ATOM_URL_REQUEST_JOB_FACTORY_H_
#include <map>
#include <string>
#include <vector>
#include "base/basictypes.h"
@@ -45,6 +46,7 @@ class AtomURLRequestJobFactory : public net::URLRequestJobFactory {
net::NetworkDelegate* network_delegate) const OVERRIDE;
virtual bool IsHandledProtocol(const std::string& scheme) const OVERRIDE;
virtual bool IsHandledURL(const GURL& url) const OVERRIDE;
virtual bool IsSafeRedirectTarget(const GURL& location) const OVERRIDE;
private:
typedef std::map<std::string, ProtocolHandler*> ProtocolHandlerMap;
@@ -58,4 +60,4 @@ class AtomURLRequestJobFactory : public net::URLRequestJobFactory {
} // namespace atom
#endif // ATOM_BROWSER_NET_ATOM_URL_REQUEST_URL_REQUEST_JOB_FACTORY_H_
#endif // ATOM_BROWSER_NET_ATOM_URL_REQUEST_JOB_FACTORY_H_

View File

@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/net/url_request_string_job.h"
#include "atom/browser/net/url_request_string_job.h"
#include <string>
#include "net/base/net_errors.h"

View File

@@ -7,6 +7,8 @@
#include "net/url_request/url_request_simple_job.h"
#include <string>
namespace atom {
class URLRequestStringJob : public net::URLRequestSimpleJob {

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