Compare commits

...

492 Commits

Author SHA1 Message Date
Cheng Zhao
97dd71d79e Bump v1.2.1 2016-06-01 16:15:53 +09:00
Cheng Zhao
e46ef5a15a Merge pull request #5824 from electron/cleanup-web-contents
Cleanup the web-contents.js code
2016-06-01 07:14:31 +00:00
Cheng Zhao
8f49d43b69 Merge pull request #5781 from deepak1556/bluetooth_patch
webContents: add event to select bluetooth device
2016-06-01 06:40:08 +00:00
Cheng Zhao
f4dc8f6d26 Merge pull request #5823 from ColinEberhardt/patch-1
minor typo fixes
2016-06-01 06:34:57 +00:00
Cheng Zhao
01b10b3b39 Slightly improve docs of webContents.printToPDF 2016-06-01 15:32:37 +09:00
Cheng Zhao
0864d3b1ee Cleanup the printToPDF code 2016-06-01 15:32:37 +09:00
deepak1556
7434838463 fix docs 2016-06-01 11:44:29 +05:30
deepak1556
de4bff003f fix header paths and comments 2016-06-01 11:44:29 +05:30
deepak1556
db4dc4757a move bluetooth_chooser to atom/browser/lib 2016-06-01 11:43:39 +05:30
deepak1556
51daf8e194 add docs 2016-06-01 11:43:39 +05:30
deepak1556
a70749e80a browser: implement bluetooth chooser interface 2016-06-01 11:43:39 +05:30
Cheng Zhao
eb882855bc Cleanup the CoffeeScript converted code 2016-06-01 15:08:51 +09:00
Cheng Zhao
5bb8da6073 Explicitly initialize session before webContents 2016-06-01 14:57:35 +09:00
Cheng Zhao
523e8c2e1c Update libchromiumcontent and brightray for #5781 2016-06-01 14:53:05 +09:00
Cheng Zhao
0565c42add Merge pull request #5812 from vasumahesh1/feature-pdf
webContents: custom pageSize for printToPDF
2016-06-01 05:52:08 +00:00
Colin Eberhardt
89adc122c3 Minor typo fixes 2016-06-01 06:36:45 +01:00
Cheng Zhao
28c9dcc393 Merge pull request #5817 from electron/plist-vars
Add variables for plist paths
2016-06-01 04:33:27 +00:00
Cheng Zhao
15d32a9096 Merge pull request #5820 from electron/session-check
Throw error when session module is used before app is ready
2016-06-01 03:22:00 +00:00
Cheng Zhao
8dfbbcefc8 Throw error when session module is used before app is ready 2016-06-01 10:53:06 +09:00
Cheng Zhao
d105524135 Cleanup the JavaScript code of session 2016-06-01 10:42:24 +09:00
Kevin Sawicki
18f005092b Merge pull request #5819 from gjtorikian/patch-1
Fix typo
2016-05-31 17:56:16 -07:00
Garen Torikian
2aa1aedd92 Fix typo 2016-05-31 17:51:09 -07:00
Kevin Sawicki
606fc1a5b7 Add plist path variables 2016-05-31 16:48:03 -07:00
Vasu Mahesh
fc6628d159 Add: custom pageSize for printToPDF 2016-05-31 22:40:11 +05:30
Cheng Zhao
f5839c3a5b Merge pull request #5782 from electron/store-icons
Keep copies of window icons
2016-05-31 10:07:15 +00:00
Cheng Zhao
aea2135016 Keep copies of window icons 2016-05-31 17:47:45 +09:00
Cheng Zhao
6c705fdd70 Merge pull request #5776 from electron/fix-node-output
Correctly redirect output to console on Windows
2016-05-31 03:19:58 +00:00
Cheng Zhao
4d8994df92 spec: child_process.fork shouble be able to pipe stdio 2016-05-31 11:05:58 +09:00
Cheng Zhao
381da76967 Correctly redirect output to console 2016-05-31 10:19:13 +09:00
Cheng Zhao
543d4bb2b1 Merge pull request #5770 from electron/clear-before-notice
Clear the buffers before notifying the other end of the pipe
2016-05-30 22:52:01 +00:00
Cheng Zhao
f02143b8f2 Clear the buffers before notifying the other end of the pipe 2016-05-30 22:38:01 +09:00
Cheng Zhao
0c93b21a5f Merge pull request #5769 from electron/fetch-job-cleanup
Refactor the URLRequestFetchJob code
2016-05-30 12:08:12 +00:00
Cheng Zhao
49f1278601 Refactor the URLRequestFetchJob code
This makes the read end and write end of the pipe have same logic, so it
is more easy to maintain.
2016-05-30 20:31:00 +09:00
Cheng Zhao
912cedc593 Merge pull request #5753 from deepak1556/url_request_fetch_job_patch
protocol: store initial response data for when resource loader becomes ready
2016-05-30 10:53:53 +00:00
Cheng Zhao
6e14a55817 Merge pull request #5768 from electron/fix-web-securiy-node-integration
Initialize script context in DidClearWindowObject
2016-05-30 08:01:48 +00:00
Cheng Zhao
ad3b3e0162 Merge pull request #5766 from kcrt/jpdocs
Japanese: add web-view-tag.md
2016-05-30 07:51:55 +00:00
Cheng Zhao
6755aa44f6 Initialize script context in DidClearWindowObject
Doing it in RunScriptsAtDocumentStart would somehow result in weird
results when webSecurity is off.
2016-05-30 16:34:28 +09:00
Cheng Zhao
ce0d3d93ab spec: disablewebsecurity should not break preload and node integration 2016-05-30 15:23:09 +09:00
TAKAHASHI Kyohei
5ab86cc2df 📝 trivial change in web-view-tag.md
There is a mistake about the information of `stopFindInPage`.
[ci skip]
2016-05-30 14:02:15 +09:00
TAKAHASHI Kyohei
12631a18c0 📝 Japanese: add web-view-tag.md 2016-05-30 13:59:43 +09:00
Cheng Zhao
7ec467e337 docs: Move the "Packaging Tools" out of "Rebranding" chapter 2016-05-30 10:37:32 +09:00
Cheng Zhao
a176aaee01 Merge pull request #5734 from danhp/fix-aspect-ratio
Fix 'setAspectRatio(0)' not resetting the default behaviour.
2016-05-30 01:14:03 +00:00
Cheng Zhao
3e41aebaa7 Merge pull request #5763 from electron/window-icon-size
Choose the correct icon size for Windows taskbar
2016-05-30 01:01:28 +00:00
Cheng Zhao
26fa963a70 Merge pull request #5720 from danhp/release-single-instance
Add 'app.releaseSingleInstance()'
2016-05-30 00:51:13 +00:00
Cheng Zhao
5a9eb5cfa6 Choose the correct icon size for Windows taskbar 2016-05-30 09:46:42 +09:00
Cheng Zhao
79cb648b6b Merge pull request #5726 from danhp/fix-context-menu
Fix context menus only showing on primary monitor.
2016-05-30 00:16:21 +00:00
Cheng Zhao
09796587b4 Remove trailing whitespaces and cleanup the code logic 2016-05-30 09:12:16 +09:00
Cheng Zhao
ec53e49fad Merge pull request #5718 from felixrieseberg/windows-fullscreenable
Fix setFullscreen() on Windows
2016-05-30 00:08:16 +00:00
Cheng Zhao
9f0fc96025 Merge pull request #5711 from electron/extension-code-cleanup
Implement partial chrome.* API for devtools extension
2016-05-29 23:29:08 +00:00
Daniel Pham
34af9794a2 Add test for 'setAspectRatio(0)' 2016-05-29 08:47:42 -04:00
deepak1556
9d8af43617 add spec 2016-05-29 13:43:26 +05:30
deepak1556
23fbb57d72 protocol: store response data when reader is not ready 2016-05-29 13:17:31 +05:30
Cheng Zhao
d1e56f416c Update the docs on using DevTools extension 2016-05-29 15:19:41 +09:00
Cheng Zhao
5f3fdbe635 Simplify the implementation of sendToAll 2016-05-29 12:10:32 +09:00
Cheng Zhao
de001a9bbf Use meaningful name for extensionId 2016-05-29 11:57:20 +09:00
Cheng Zhao
ec1944c146 Implement chrome.tab.onCreated/onRemoved APIs 2016-05-29 11:50:14 +09:00
Cheng Zhao
2431d886bf Current handle sender.tab for background pages 2016-05-29 10:46:48 +09:00
Cheng Zhao
dd804d7432 Enable specifying custom command line switches 2016-05-29 10:34:53 +09:00
Cheng Zhao
f693b042b5 Fix js lint warnings 2016-05-28 22:46:15 +09:00
Cheng Zhao
747f910ce0 Merge pull request #5736 from electron/missing-has-own-property
Support objects with no prototype over IPC
2016-05-28 13:42:30 +00:00
Cheng Zhao
3c7d94f2d9 Merge pull request #5742 from electron/duplicate-hidden-inset-check
Remove duplicate hidden-inset check
2016-05-28 13:42:15 +00:00
Cheng Zhao
f4fe60d126 Set default mimeType for BufferJob 2016-05-28 22:36:22 +09:00
Cheng Zhao
30dca2b4e1 Pages in chrome extension should not have node integration 2016-05-28 21:46:53 +09:00
Cheng Zhao
9ed4730cba Pass sender for chrome.runtime.onMessage 2016-05-28 21:45:23 +09:00
Cheng Zhao
5eb9ed1729 Implement chrome.tabs.sendMessage 2016-05-28 21:35:07 +09:00
Cheng Zhao
62fb4f9820 Implement chrome.runtime.sendMessage 2016-05-28 21:23:43 +09:00
Cheng Zhao
ba315248e0 Use ipcRenderer.sendTo to get rid of routers in main process 2016-05-28 21:13:00 +09:00
Cheng Zhao
a58b84bbd7 spec: ipcRenderer.sendTo sends message to WebContents 2016-05-28 20:50:30 +09:00
Cheng Zhao
ae1f442b02 Add ipcRenderer.sendTo 2016-05-28 20:50:28 +09:00
Cheng Zhao
d55b96fdf5 Clean up the Chrome API implementation code 2016-05-28 20:33:18 +09:00
Cheng Zhao
31628abadc Implement chrome.tabs.executeScript 2016-05-28 16:41:12 +09:00
Cheng Zhao
db94121360 Implement port.sender 2016-05-28 16:01:16 +09:00
Cheng Zhao
f5b430d9e1 Inject chrome.* to content scripts 2016-05-28 15:37:44 +09:00
Cheng Zhao
d8db695712 Handle port disconnecting 2016-05-28 12:07:08 +09:00
Cheng Zhao
599d3c147b Background pages and content script should be loaded on startup 2016-05-28 10:39:11 +09:00
Cheng Zhao
e76c36a9a8 Make simple runtime.connect work 2016-05-28 10:26:41 +09:00
Cheng Zhao
dfe7ae2124 Add webContents.fromId 2016-05-28 10:10:24 +09:00
Kevin Sawicki
5deb86d6f9 Merge pull request #5744 from aaronang/docs-improve-structure-of-source-code
📝 Indicate directories in the Structure of Source Code section
2016-05-27 15:41:28 -07:00
Aaron Ang
0a03dcd481 📝 Indicate directories in the Structure of Source Code section
[ci skip]
2016-05-28 00:22:47 +02:00
Kevin Sawicki
6e8945d7fa Merge pull request #5738 from electron/remove-deprecated-apis-from-docs
Remove deprecated APIs from the docs
2016-05-27 15:10:45 -07:00
Kevin Sawicki
1704b1ad53 Remove APIs that are no longer present 2016-05-27 15:08:29 -07:00
Kevin Sawicki
d02c1fbbf4 Merge pull request #5670 from electron/custom-fork-docs
Create guide for how to create your own from-source Electron fork
2016-05-27 14:34:49 -07:00
Kevin Sawicki
6add7f8d49 we -> it 2016-05-27 14:34:23 -07:00
Kevin Sawicki
ba6c8b531f Add ELECTRON_REPO example 2016-05-27 14:06:40 -07:00
Kevin Sawicki
82bc98ec3c Put - at end of previous line 2016-05-27 14:06:04 -07:00
Kevin Sawicki
1e28e3fc27 Add trailing slashes to directories 2016-05-27 14:06:04 -07:00
Kevin Sawicki
2effa32e3e Tighten up section title 2016-05-27 14:06:04 -07:00
Kevin Sawicki
f17e64e726 Tweak fork section 2016-05-27 14:06:04 -07:00
Kevin Sawicki
556b39c6f2 ATOM_SHELL -> ELECTRON in env vars 2016-05-27 14:06:04 -07:00
Kevin Sawicki
4734cbaf1c Move custom fork content to app distribution doc 2016-05-27 14:06:04 -07:00
Paul Betts
153a7f19ae Add notes on S3 directory structure 2016-05-27 14:06:04 -07:00
Paul Betts
0b27db2ef4 Create guide for how to create your own from-source Electron fork
This PR adds the notes on how to use Surf to build and upload a custom version of Electron
2016-05-27 14:06:04 -07:00
Kevin Sawicki
b465f2c3c4 Remove duplicate hidden-inset check 2016-05-27 13:27:35 -07:00
Kevin Sawicki
1e99f656cc Merge pull request #5737 from electron/browser-window-proxy-print
Add print() to BrowserWindowProxy
2016-05-27 11:33:08 -07:00
Kevin Sawicki
84f6015037 Call print on webContents 2016-05-27 11:11:55 -07:00
Felix Rieseberg
fa7f084625 📠 Add print() to BrowserWindowProxy
Closes #5685
2016-05-27 11:11:19 -07:00
Kevin Sawicki
fc4b224dec Add asserts for properties 2016-05-27 10:52:56 -07:00
Kevin Sawicki
59dd7ca9df Guard against object with no hasOwnProperty 2016-05-27 10:46:02 -07:00
Kevin Sawicki
7cf6be07a6 Add failing spec for remote property with no prototype 2016-05-27 10:45:39 -07:00
Kevin Sawicki
ac394ec3ef Merge pull request #5725 from electron/clipboard-api-names
Upper case initialisms in clipboard API
2016-05-27 09:09:12 -07:00
Daniel Pham
0c710fce33 🍎 Fix 'setAspectRatio(0)' not resetting the default behaviour. 2016-05-27 08:56:34 -04:00
Cheng Zhao
9ab76fb884 Add webContents.sendToAll to send message to all frames 2016-05-27 16:58:49 +09:00
Cheng Zhao
c1facec5a6 No need to hijack setInjectedScriptForOrigin 2016-05-27 15:12:49 +09:00
Cheng Zhao
134f9019eb Enable node integration for pages in devtools extension 2016-05-27 15:10:46 +09:00
Cheng Zhao
7e1f159185 Run content scripts at correct phase 2016-05-27 11:12:51 +09:00
Cheng Zhao
49d9446cce Implement a simple content script injector 2016-05-27 10:29:57 +09:00
Cheng Zhao
97c04735a2 Handle unloading devtools correctly 2016-05-27 09:55:59 +09:00
Cheng Zhao
a63ff714f8 Read content_scripts to preferences 2016-05-27 09:47:37 +09:00
Cheng Zhao
7eab259d92 Make it possible to only set preferences for BrowserWindow 2016-05-27 09:20:46 +09:00
Cheng Zhao
4fb9e20c33 Add API to set render process preferences 2016-05-27 08:51:02 +09:00
Daniel Pham
f4c3f0423a 🎁 Add 'app.releaseSingleInstance()' 2016-05-26 18:50:06 -04:00
Cheng Zhao
b646d7a55c The consts 2016-05-27 07:43:23 +09:00
Daniel Pham
b0c72adbe1 🍎 Fix context menus only showing on primary monitor. 2016-05-26 17:43:38 -04:00
Kevin Sawicki
23962e133e Use correct TODO format 2016-05-26 14:28:33 -07:00
Kevin Sawicki
efeb9647ff Update docs for new API names 2016-05-26 14:26:12 -07:00
Kevin Sawicki
71b73a9cfb Use new APIs 2016-05-26 14:24:47 -07:00
Kevin Sawicki
dc7316f52f Upper case abbreviations 2016-05-26 14:23:20 -07:00
Felix Rieseberg
836f8ab33c 🐛 Fix setFullscreen() on Windows
This ensures that a BrowserWindow responds to `setFullscreen(true)` if
`full screenable` was not defined during creation.

This bug was on Windows only.
2016-05-26 11:52:25 -07:00
Cheng Zhao
cdfbe876a5 Make sure chrome.devtools.inspectedWindow.tabId is set 2016-05-26 19:57:10 +09:00
Cheng Zhao
edd8210ae5 Add simple support for background page 2016-05-26 19:57:10 +09:00
Cheng Zhao
99c1434051 Store the original manifest file 2016-05-26 18:38:20 +09:00
Cheng Zhao
513b66f207 Cleanup chrome-extension.js after the Coffe2ES transfer 2016-05-26 18:38:20 +09:00
Cheng Zhao
f29598d907 getHostForPath => generateHostForPath
The original name implies no side effect, but is is not true.
2016-05-26 18:38:20 +09:00
Cheng Zhao
c1272743b9 Bump v1.2.0 2016-05-26 18:07:52 +09:00
Cheng Zhao
eeb996e92f Merge pull request #5710 from electron/chrome-lastest-stable
Update to Chrome 51.0.2704.63
2016-05-26 09:07:24 +00:00
Cheng Zhao
eb8284e285 Update to Chrome 51.0.2704.63 2016-05-26 18:06:55 +09:00
Cheng Zhao
20b09e9d03 Merge pull request #5701 from danhp/propagate-close
Properly notify observers when window prevents close
2016-05-26 05:33:55 +00:00
Cheng Zhao
93b8237e1f Merge pull request #5700 from felixrieseberg/standard-7
Implement JavaScript Standard Style 7
2016-05-26 04:57:36 +00:00
Cheng Zhao
8a4b7eb062 Merge pull request #5689 from cdaringe/master
Support non-native promises
2016-05-26 04:49:40 +00:00
Cheng Zhao
4ea7602871 Merge pull request #5684 from electron/webview-visibilitychange
Support document visibility and events in webviews
2016-05-26 01:07:24 +00:00
Cheng Zhao
fa1246ccf7 Merge pull request #5683 from electron/no-more-atom-shell
Rename remaining Atom Shell references
2016-05-26 01:06:36 +00:00
Cheng Zhao
0b9c11a5f2 Fix pylint warnings 2016-05-26 10:06:25 +09:00
Kevin Sawicki
4e44900930 Initialize guest_instance_id 2016-05-25 18:05:37 -07:00
Daniel Pham
d1c302800f Fix: Properly notify observers when window prevents close 2016-05-25 19:26:57 -04:00
Felix Rieseberg
bef6748c06 🎨 Implement JS Standard Code Style 7
Updates Standard Code Style to 7 (latest major) and ensures that code
is conform.

 * camelCase is now enforced
 * No assignments in return statements
2016-05-25 16:20:49 -07:00
Kevin Sawicki
75754804af Use auto for embedder var 2016-05-25 10:34:33 -07:00
Kevin Sawicki
88f665bc1b Restore original include location 2016-05-25 10:28:35 -07:00
Kevin Sawicki
814e4377a4 Restore original comment position 2016-05-25 10:26:59 -07:00
Kevin Sawicki
6632547b17 parent -> embedder 2016-05-25 10:26:20 -07:00
Kevin Sawicki
89ffa02d75 Tweak comment 2016-05-25 10:26:05 -07:00
Kevin Sawicki
b1ce57faa9 Remove redundant atom:: namespace use 2016-05-25 10:22:43 -07:00
Kevin Sawicki
03c6fbf80f 🎨 2016-05-25 10:20:00 -07:00
Kevin Sawicki
f58322891b Remove added switch/option 2016-05-25 10:17:35 -07:00
Kevin Sawicki
583bb49f6c Get hidden state by using parent window directly 2016-05-25 10:13:12 -07:00
Kevin Sawicki
69c69880e5 Tweak spec description 2016-05-25 09:12:52 -07:00
Kevin Sawicki
4e68a8d16e Remove logging in parent page 2016-05-25 09:12:52 -07:00
Kevin Sawicki
73b07f76a3 Support document visiblity state and events in webviews 2016-05-25 09:12:52 -07:00
Kevin Sawicki
1e15ce6ccd Add failing spec for webview visiblity changes 2016-05-25 09:12:52 -07:00
cdaringe
32073fa079 🎨 Support non-native promises 2016-05-25 10:11:18 -06:00
Kevin Sawicki
9684f61e12 atom_gyp -> electron_gyp 2016-05-25 09:10:46 -07:00
Kevin Sawicki
6c8cf16508 Deprecate ATOM_SHELL_GITHUB_TOKEN 2016-05-25 09:08:10 -07:00
Kevin Sawicki
43f0dfd0ab Deprecate old S3 env vars 2016-05-25 09:08:09 -07:00
Kevin Sawicki
1bdb9f3de0 Add fallback s3 config values 2016-05-25 09:08:09 -07:00
Kevin Sawicki
94c8b0e1b1 atom_shell -> electron 2016-05-25 09:08:09 -07:00
Kevin Sawicki
7e209dd982 ATOM_SHELL_INTERNAL_CRASH_SERVICE -> ELECTRON_INTERNAL_CRASH_SERVICE 2016-05-25 09:08:09 -07:00
Kevin Sawicki
8f1943bc7b Link to other apps 2016-05-25 09:08:09 -07:00
Kevin Sawicki
3dd2f709e0 Remove mention of Atom Shell 2016-05-25 09:08:09 -07:00
Cheng Zhao
b86ded3b54 Merge pull request #5688 from enlight/patch-1
Improve documentation of `ses.cookies.set()`
2016-05-25 10:44:33 +00:00
Cheng Zhao
3ef0947718 Merge pull request #5687 from electron/fix-invalid-parameter
Ignore invalid parameter error on Window
2016-05-25 07:03:33 +00:00
Vadim Macagon
c2633460eb Improve documentation of ses.cookies.set()
Fix description of the `details.url` param in `ses.cookies.set()`, and clarify the fact that cookies without an expiration date will not be retained between sessions.
2016-05-25 12:46:17 +07:00
Cheng Zhao
34c4e797bb Truncate the strings passed to google_breakpad::CustomInfoEntry 2016-05-25 14:46:15 +09:00
Cheng Zhao
545c9f5bed Ignore invalid parameter error in Electron 2016-05-25 14:46:15 +09:00
Cheng Zhao
4cd0de0e87 Merge pull request #5682 from electron/remove-old-run-as-node-env-var
Remove ATOM_SHELL_INTERNAL_RUN_AS_NODE support
2016-05-25 02:17:18 +00:00
Cheng Zhao
b1226a908b Update node: remove ATOM_SHELL_INTERNAL_RUN_AS_NODE 2016-05-25 10:55:02 +09:00
Cheng Zhao
f34cd8767c Merge pull request #5658 from danhp/handoff-fallback
Add fallback URL to handoff
2016-05-25 01:13:03 +00:00
Daniel Pham
eb0889de38 🍎 Add fallback URL to handoff. 2016-05-24 21:06:14 -04:00
Cheng Zhao
e97ce6f7e1 Merge pull request #5669 from felixrieseberg/build-instructions
Update Windows Build Instructions
2016-05-24 23:49:37 +00:00
Kevin Sawicki
89538b19ee Upgrade node for ELECTRON_RUN_AS_NODE change 2016-05-24 10:42:09 -07:00
Kevin Sawicki
b68d1ecb83 Remove ATOM_SHELL_INTERNAL_RUN_AS_NODE support 2016-05-24 10:17:57 -07:00
Kevin Sawicki
407a5d4415 Merge pull request #5681 from electron/default-app-error-handling
Tweak default app error handling
2016-05-24 10:15:56 -07:00
Kevin Sawicki
3e15021c12 Remove . after path to prevent confusion 2016-05-24 09:56:36 -07:00
Kevin Sawicki
ca72d4346b application -> app for consitency 2016-05-24 09:53:23 -07:00
Kevin Sawicki
74cde4e714 Log stack when available 2016-05-24 09:51:09 -07:00
Kevin Sawicki
48522d4b70 Remove custom MODULE_NOT_FOUND code check 2016-05-24 09:45:32 -07:00
Kevin Sawicki
63b84923ce Update copy 2016-05-24 09:43:25 -07:00
Kevin Sawicki
4a35206302 🎨 2016-05-24 09:42:31 -07:00
Kevin Sawicki
6de4249af8 Tweak resolve filename error message 2016-05-24 09:41:31 -07:00
Kevin Sawicki
deb15e60b5 Lead with package.json path 2016-05-24 09:38:04 -07:00
Kevin Sawicki
f691a46d4d Use dialog.showErrorBox 2016-05-24 09:37:52 -07:00
Kevin Sawicki
67c88d2f8a Move Module require to top 2016-05-24 09:33:55 -07:00
Kevin Sawicki
4d56437a26 Merge pull request #5610 from bigtimebuddy/master
The "Error opening app" dialog
2016-05-24 09:22:11 -07:00
Felix Rieseberg
2a7590529e 📝 Update Windows Build Instructions
Closes #5655
2016-05-24 06:12:07 -07:00
Cheng Zhao
28e2058ff1 Merge pull request #5648 from electron/chrome51
Update to Chrome 51
2016-05-24 10:59:11 +00:00
Cheng Zhao
1dd98171f4 Bump v1.1.2 2016-05-24 15:59:21 +09:00
Cheng Zhao
994cc62031 Merge pull request #5668 from electron/strip-ffmpeg
Strip ffmpeg in zip file
2016-05-24 04:33:09 +00:00
Cheng Zhao
cd444e82f9 Merge pull request #5666 from electron/remote-promise-reject
Handle rejection of remote promises
2016-05-24 04:30:25 +00:00
Cheng Zhao
9d924bb6d7 Merge pull request #5662 from electron/electron-require
Always return internal module when requiring electron
2016-05-24 01:46:36 +00:00
Cheng Zhao
995a20a125 Merge pull request #5653 from electron/menu-position-fix
Fix context menu not showing correctly in devtools
2016-05-24 01:02:48 +00:00
Kevin Sawicki
677a317274 Strip ffmpeg in zip file 2016-05-23 15:47:07 -07:00
Jessica Lord
1ba07a9d6d Merge pull request #5659 from danhp/patch-2
Mention that x and y have to be used together when creating new window
2016-05-23 15:44:42 -07:00
Kevin Sawicki
a4f94b89b4 Add comment about Module path 2016-05-23 15:15:39 -07:00
Kevin Sawicki
5e2f36387f Move require spec to api-app-spec 2016-05-23 15:14:55 -07:00
Kevin Sawicki
4a41311409 Test that calling regular module succeeds 2016-05-23 15:14:55 -07:00
Kevin Sawicki
6ac0151e65 Remove lint warnings 2016-05-23 15:14:55 -07:00
Kevin Sawicki
fe0ec67623 Add spec for electron module require 2016-05-23 15:14:55 -07:00
Kevin Sawicki
19fd841c30 🎨 2016-05-23 15:14:55 -07:00
Kevin Sawicki
566b0676bc Pre-resolve electron require path 2016-05-23 15:14:55 -07:00
Kevin Sawicki
daea448b61 .coffee -> .js 2016-05-23 15:14:55 -07:00
Kevin Sawicki
7929daa48c Pass both callback values to then 2016-05-23 15:07:01 -07:00
Kevin Sawicki
f3af1dbd54 Add failing spec for rejected remote promise 2016-05-23 15:06:46 -07:00
Matt Karl
ee61a2880a Removes main error, fixes messaging for JSON parse 2016-05-23 16:47:55 -04:00
Kevin Sawicki
1c9fe8d23e Merge pull request #5664 from electron/cibuild-ps1
Add a Windows script to just invoke cibuild
2016-05-23 13:07:18 -07:00
Paul Betts
52888c97b5 Add a Windows script to just invoke cibuild 2016-05-23 12:37:47 -07:00
Matt Karl
58d9d2cf41 Adds JSON parse, invalid and missing main field errors 2016-05-23 15:00:55 -04:00
Daniel Pham
5010150c8c 📝 Mention that x and y have to be used together when creating new window
[ci skip]
2016-05-23 13:00:43 -04:00
Cheng Zhao
3402c7be3f Suppress ffi test on Windows 2016-05-23 23:31:00 +09:00
Cheng Zhao
37a4267450 Update brightray: fix Windows linking problem 2016-05-23 23:24:43 +09:00
Cheng Zhao
2208b8bd6e Update symbol names of icu 2016-05-23 22:53:50 +09:00
Cheng Zhao
2edf559571 Update brightray: fix OS X linking problem 2016-05-23 22:05:26 +09:00
Cheng Zhao
0d4f1abdf9 Move the menu sightly higher when repositioning the menu
Otherwise the menu is not able to show the last menu item and the arrow
will show.
2016-05-23 21:54:06 +09:00
Cheng Zhao
b866b34ac8 The unit of position is CGFloat 2016-05-23 21:53:50 +09:00
Cheng Zhao
fca91db133 Fix showing context menu in devtools 2016-05-23 21:08:16 +09:00
Cheng Zhao
badecb49f3 Update brightray: fix Linux linking problem 2016-05-23 19:50:05 +09:00
Cheng Zhao
9f858e1243 Merge branch 'master' into chrome51 2016-05-23 19:49:43 +09:00
Cheng Zhao
c489d6d4b3 Merge pull request #5638 from deepak1556/iwa_patch
browser: flags to control iwa enabled server whitelist
2016-05-23 10:48:30 +00:00
Cheng Zhao
208acd1b9c Update brightray: Manage NetLog in BrowserClient 2016-05-23 19:02:40 +09:00
Cheng Zhao
1b9bced8c0 Merge pull request #5644 from leethomas/fix/osx-aspect-ratio
🍎  let Cocoa handle keeping aspect ratio on window resize
2016-05-23 08:15:44 +00:00
Cheng Zhao
f756a3e682 Fix crash when quitting 2016-05-23 17:03:49 +09:00
Cheng Zhao
44651656dd Fix building on Windows 2016-05-23 16:39:19 +09:00
Cheng Zhao
9d82041923 Fix js lint warnings 2016-05-23 16:15:39 +09:00
Cheng Zhao
d6f9e57e33 Fix chrome.devtools not available in devtools extensions 2016-05-23 16:04:37 +09:00
Cheng Zhao
de1fc9d432 Fix building on Linux 2016-05-23 15:27:01 +09:00
deepak1556
f68d0f324f deprecate app.allowNTLMCredentialsForAllDomains 2016-05-23 11:44:21 +05:30
Cheng Zhao
a92b4a6da4 Make |button| default to left button
This fixes the failing test of sendInputEvent.
2016-05-23 14:27:39 +09:00
Cheng Zhao
fa0ce7ad5f Adjust to the new behaviors of beforeunload handler 2016-05-23 14:27:39 +09:00
Cheng Zhao
06800940ec Fix cpplint warnings 2016-05-23 13:03:43 +09:00
Cheng Zhao
4b675a741d Init feature list in node process
It is a new dependency of gin.
2016-05-23 13:01:47 +09:00
Cheng Zhao
530f19e956 Fix crash due to site_instace being freed early 2016-05-23 12:57:46 +09:00
Cheng Zhao
899cdb48d7 Fix using invalid pointer as SiteInstance 2016-05-23 12:46:14 +09:00
Cheng Zhao
a2bd55dd3c Adapt to changes of Chrome 51 API changes (Part 2) 2016-05-23 12:29:14 +09:00
leethomas
de27b34891 disregard extraSize when initially setting the aspect ratio 2016-05-22 19:09:21 -07:00
Cheng Zhao
7ba391da7c Update to API changes of Chrome 51 2016-05-23 10:59:39 +09:00
leethomas
1d61f987cb code styling 2016-05-22 18:59:00 -07:00
Cheng Zhao
05c2999651 Update to Chrome 51.0.2704.54 2016-05-23 10:11:19 +09:00
Cheng Zhao
fd5f120434 Merge pull request #5646 from electron/update-breakpad
Fix crash reporter not working on x64 Windows
2016-05-23 00:25:24 +00:00
leethomas
09de0c2766 call base SetAspectRatio in NativeWindowMac implementation 2016-05-22 17:22:57 -07:00
leethomas
ac6e4aff5e comments 2016-05-22 17:00:14 -07:00
Cheng Zhao
13b4c8bb06 Ignore invalid parameter error in crash service process 2016-05-23 08:59:34 +09:00
leethomas
7aaf974362 override SetAspectRatio for NativeWindowMac 2016-05-22 16:50:50 -07:00
leethomas
8f7a04f9c3 🍎 let Cocoa handle keeping the aspect ratio whenever the edges are dragged 2016-05-22 15:43:47 -07:00
deepak1556
62cad610e0 bring back app.allowNTLMCredentialsForAllDomains 2016-05-23 01:52:09 +05:30
Cheng Zhao
4c531e909b Update breakpad to lastest master 2016-05-22 22:06:12 +09:00
Cheng Zhao
b52b6e12c4 Merge pull request #5640 from electron/update-crashpad
Update crashpad to latest master
2016-05-22 12:47:34 +00:00
Cheng Zhao
48b161f210 Update crashpad to 35da3b6 2016-05-22 21:00:16 +09:00
Cheng Zhao
06da5d543c Merge pull request #5622 from kcrt/jpmanual
Japanese manual: Update tutorials and api
2016-05-22 07:57:36 +00:00
Cheng Zhao
5267d734bb Merge pull request #5634 from deepak1556/net_error_description_patch
renderer: generate net error strings when requested
2016-05-22 00:34:56 +00:00
deepak1556
3db2daf790 browser: flags to control iwa enabled server whitelist 2016-05-21 23:38:50 +05:30
TAKAHASHI Kyohei
9d02292dec Japanese manual: modified template string
modified based on the comments from Flatta
[ci skip]
2016-05-22 00:22:51 +09:00
TAKAHASHI Kyohei
77eb0e8e3f Japanese manual: Update tutorials and api
[ci skip]
2016-05-22 00:17:20 +09:00
Cheng Zhao
6f3d0e1782 Merge pull request #5603 from leethomas/osx-horizontal-sheet-offset
Osx horizontal sheet offset
2016-05-21 14:07:53 +00:00
Cheng Zhao
6c8ffcf7a0 Merge pull request #5631 from electron/x64-by-default-win32
Default to amd64 on Windows
2016-05-21 13:39:25 +00:00
Cheng Zhao
363ab2075c Update libchromiumcontent for #5618 2016-05-21 20:48:06 +09:00
deepak1556
c9b314d43c renderer: generate net error strings when requested 2016-05-21 10:21:15 +05:30
Paul Betts
0e63050916 Default to amd64 on Windows 2016-05-20 14:20:48 -07:00
Kevin Sawicki
8821cae34f Merge pull request #5630 from electron/env-var-headings
Use ### for env var headings
2016-05-20 14:05:15 -07:00
Kevin Sawicki
f16f48aa7c Tweak example intros 2016-05-20 14:04:01 -07:00
Kevin Sawicki
e1d9229507 Tweak intro sentence 2016-05-20 14:03:28 -07:00
Kevin Sawicki
588420ecd2 Use active voice 2016-05-20 14:02:10 -07:00
Kevin Sawicki
d56c36b4a7 Minor wording updates 2016-05-20 14:01:08 -07:00
Kevin Sawicki
d983eb42e6 Use ### for headings for consistency 2016-05-20 13:58:48 -07:00
Matt Karl
b08393a663 Fixed linting error 2016-05-20 16:01:08 -04:00
Matt Karl
a1e59b814c Changed default button, updated link 2016-05-20 13:29:42 -04:00
Kevin Sawicki
f52cd31d0d Merge pull request #5625 from electron/doc-headings
Capitalize Object in doc heading
2016-05-20 10:01:54 -07:00
Kevin Sawicki
f266b979af Capitalize Object 2016-05-20 09:25:10 -07:00
Matt Karl
25cb0fcbb9 Added Learn More button 2016-05-20 11:04:10 -04:00
Cheng Zhao
8b9d189671 Merge pull request #5624 from electron/hicon
Feed Windows APIs with ICO icons of appropriate size
2016-05-20 14:30:00 +00:00
Cheng Zhao
3182485e68 No need to reference the icon in Tray 2016-05-20 22:44:02 +09:00
Cheng Zhao
a93c9462ed Add BrowserWindow.setIcon 2016-05-20 22:22:15 +09:00
Cheng Zhao
b33c04d041 docs: Recommend to use ICO icon 2016-05-20 19:58:47 +09:00
Cheng Zhao
d26480b74e Correctly set window icon from ICO 2016-05-20 19:46:05 +09:00
Cheng Zhao
ea2807c890 Make it possible to get different size of icons from ICO 2016-05-20 17:51:05 +09:00
Cheng Zhao
0059e7bcf9 Use LoadIconMetric to load correct icon 2016-05-20 17:12:07 +09:00
Cheng Zhao
9e26e5c121 Load HICON directly in NotifyIcon 2016-05-20 16:55:22 +09:00
Cheng Zhao
67d9ae27c3 Remove the JavaScript wrapper for setContextMenu 2016-05-20 16:18:38 +09:00
Cheng Zhao
adfd99f5f0 Convert to mate::Handle<NativeImage> instead of gfx::Image 2016-05-20 16:14:40 +09:00
leethomas
9196a9f334 update docs 2016-05-19 20:32:14 -07:00
leethomas
7d93642f42 extend setSheetOffset to accept an optional 2nd offset 2016-05-19 20:32:06 -07:00
Cheng Zhao
7c34d8333c Store ico image in HCION 2016-05-20 11:31:02 +09:00
Cheng Zhao
d5f3e5d59a Bump v1.1.1 2016-05-20 09:30:24 +09:00
Cheng Zhao
8ac93e02c6 Merge pull request #5616 from electron/inherit-zoom
Inherit zoomFactor in webview
2016-05-20 00:27:06 +00:00
Cheng Zhao
4193fb1742 Merge pull request #5617 from electron/dont-return-from-on-functions
Remove returns from event listeners
2016-05-20 00:26:29 +00:00
Cheng Zhao
844f9e989b Merge pull request #5611 from jviotti/fix/invalid-archive-asar-exec
Override `child_process.execFile` asar patch for `child_process.exec`
2016-05-20 00:24:10 +00:00
Cheng Zhao
d6dffc570c Merge pull request #5614 from electron/bengotow-remote-docs
Update remote.md to mention enumerable property limitation
2016-05-19 23:54:20 +00:00
Cheng Zhao
4a075866de Merge pull request #5608 from Gaserd/patch-4
docs : Russian
2016-05-19 23:51:22 +00:00
Kevin Sawicki
cc7395eea8 Remove returns from event listeners 2016-05-19 15:28:08 -07:00
Kevin Sawicki
b09c81202a Add test for webview zoomFactor inheritance 2016-05-19 14:46:52 -07:00
Kevin Sawicki
4754e4aabb Add zoomFactor to guest params 2016-05-19 14:32:16 -07:00
Kevin Sawicki
fef2f789cd 🎨 2016-05-19 14:30:53 -07:00
Juan Cruz Viotti
1a27ecdad4 Override child_process.execFile asar patch for child_process.exec
NodeJS implements `child_process.exec` by simply passing the whole
command to `child_process.execFile`. See:

- https://github.com/nodejs/node/blob/master/lib/child_process.js#L90
- https://github.com/nodejs/node/blob/master/lib/child_process.js#L99

Electron patches `child_process.execFile` to add support for `asar`
archives by injecting logic that extracts the required files from the
`asar` to a temporary location before delegating the work to the
original `child_process.execFile`.

In order to decide whether to inject the custom `asar` extracting logic,
Electron makes use of a helper function called `splitPath()`. See:

- https://github.com/electron/electron/blob/master/lib/common/asar.js#L37

If the first argument of the returned array equals `true`, means that
the path is considered to be an `asar` archive, and thus the extraction
logic takes place. The problem is that if the command passed to
`child_process.execFile` *contains* a path to an asar archive, padded
with other commands/arguments, `splitPath()` will consider it to be an
`asar` archive, and will try to extract it, throwing a rightfully
`Invalid package` error.

Fixes: https://github.com/electron/electron/issues/5571
Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
2016-05-19 17:19:36 -04:00
Ben Gotow
2bade868bb Update remote.md to mention enumerable property limitation
#5599
2016-05-19 09:31:02 -07:00
Matt Karl
e87ced60e5 The "Error opening app" dialog, now with less attitude 2016-05-19 10:33:22 -04:00
Sergey
836e2e4e91 docs : Russian
Russian language for http://electron.atom.io/docs/tutorial/mac-app-store-submission-guide/
2016-05-19 16:46:42 +03:00
Cheng Zhao
a2b6731bf2 Merge pull request #5606 from electron/process-docs
Cleanup the docs of process object
2016-05-19 11:59:37 +00:00
Cheng Zhao
983d611e96 Cleanup the docs of process object 2016-05-19 20:12:56 +09:00
Cheng Zhao
0bd3e28a05 Merge pull request #5526 from electron/process-stats
Process and System memory statistics API
2016-05-19 10:34:01 +00:00
Cheng Zhao
480f0fbfd7 Merge pull request #5600 from tensor5/update_clang_only_if_needed
Update Clang only if needed
2016-05-19 10:29:29 +00:00
Cheng Zhao
590c2bcf23 Merge pull request #5604 from preco21/korean-docs-5
docs: Update Korean docs as upstream
2016-05-19 10:27:03 +00:00
Cheng Zhao
8fd9957453 Merge pull request #5605 from preco21/document-fixes-5
docs: Improve docs
2016-05-19 10:26:38 +00:00
Cheng Zhao
e488320d37 Ignore failures of OS X on Travis CI 2016-05-19 19:23:02 +09:00
Cheng Zhao
195e0e64d0 Update brightray for #5578 2016-05-19 19:22:32 +09:00
Cheng Zhao
17528a4dfd Merge pull request #5578 from deepak1556/disable_http2_patch
browser: flag to disable HTTP/2 and SPDY/3.1 protocols
2016-05-19 10:21:36 +00:00
Cheng Zhao
53d0db0a28 Merge pull request #5602 from electron/static-linking-vs-runtime
Link with VS2015 libraries statically for Release build
2016-05-19 09:50:53 +00:00
Plusb Preco
d6ab81c1da 📝 Fix link to improve readability
[ci skip]
2016-05-19 18:36:26 +09:00
Plusb Preco
3ee9eef308 📝 Remove unused link
[ci skip]
2016-05-19 18:34:08 +09:00
Plusb Preco
9cbcd228f3 📝 Adjust line length to 80
[ci skip]
2016-05-19 18:32:43 +09:00
Plusb Preco
e1bf0ea2b4 📝 Adjust line length to 80
[ci skip]
2016-05-19 18:28:29 +09:00
Plusb Preco
5c8ecd8a97 📝 Small fixes
* Adjust line length to `80`.
* Fix typos

[ci skip]
2016-05-19 18:28:00 +09:00
Plusb Preco
2b7c3735bd 📝 Update Korean docs as upstream
[ci skip]
2016-05-19 17:22:51 +09:00
Cheng Zhao
f8c1db160e Only use the osfhandle hack on Windows 2016-05-19 17:02:40 +09:00
Cheng Zhao
e609a5bee2 Fix passing fd across modules 2016-05-19 16:38:37 +09:00
leethomas
eaacbc86c7 📝 update english docs to include setSheetOffsets 2016-05-18 23:59:25 -07:00
Cheng Zhao
4702d8b640 No need to download and ship vs runtime libraries 2016-05-19 15:49:26 +09:00
leethomas
359123458d 🍎 allow x-axis offset to be set for sheets 2016-05-18 23:45:54 -07:00
Cheng Zhao
d8c05ecc0d Link with Vs2015 runtime statically for Release build 2016-05-19 15:06:47 +09:00
Cheng Zhao
f441ba2694 Merge pull request #5601 from electron/team-id
Include team ID in the base bundle ID
2016-05-19 03:24:31 +00:00
Cheng Zhao
5d906c0e4e docs: Team ID is now required for signing 2016-05-19 11:13:09 +09:00
Cheng Zhao
a361d50b95 Add team ID to base Bundle ID 2016-05-19 10:57:57 +09:00
Nicola Squartini
18b2094198 Update Clang only if needed 2016-05-19 10:14:57 +09:00
Kevin Sawicki
1032287511 Merge pull request #5588 from brunoqueiros/error-message
Improve error message
2016-05-18 17:41:57 -07:00
Cheng Zhao
d3beaa0b16 Merge pull request #5595 from miniak/asar-fix
Make js2asar.py more robust
2016-05-18 23:40:11 +00:00
Bruno Queiros
046cb0df8d 🎨 Use the same stack trace for both cases 2016-05-18 19:02:42 -03:00
Kevin Sawicki
97d903bca3 Merge pull request #5587 from kcrt/master
Japanese manual: add electron-versioning.
2016-05-18 13:55:10 -07:00
Kevin Sawicki
0456be1535 Merge pull request #5594 from Gaserd/patch-3
Create supported-platforms.md
2016-05-18 13:52:47 -07:00
Milan Burda
161bd89a24 Make js2asar.py more robust 2016-05-18 12:54:53 -07:00
Sergey
5f9976c46a Create supported-platforms.md
Create new file - supported-platforms.
Russian language for this page - http://electron.atom.io/docs/tutorial/supported-platforms/
2016-05-18 22:40:12 +03:00
Paul Betts
872c6ea763 📝 2016-05-18 11:08:04 -07:00
Paul Betts
e995befcd0 Move everything into atom_bindings 2016-05-18 11:07:30 -07:00
Paul Betts
d49302858b Merge pull request #5589 from Gaserd/patch-2
исправление ошибки в слове
2016-05-18 10:57:53 -07:00
Sergey
d3e0c08255 исправление ошибки в слове
ничего критичного, просто букву не ту поставили.
2016-05-18 18:04:52 +03:00
Bruno Queiros
06e3e65c1b 🎨 Improve error message 2016-05-18 11:00:08 -03:00
TAKAHASHI Kyohei
962ce6c44c Japanese manual: add electron-versioning.
electron-versioning.md is translated.
Other tutorial files are updated.
[ci skip]
2016-05-18 22:33:21 +09:00
Cheng Zhao
e05f795d1d Merge pull request #5584 from electron/sandbox-no-expl
Enable sandboxing without using temporary-exception
2016-05-18 10:02:30 +00:00
Cheng Zhao
906948218f docs: Update MAS guide without using temporary-exception 2016-05-18 16:48:22 +09:00
Cheng Zhao
deddf98533 Currently set base bundle ID 2016-05-18 16:42:26 +09:00
Plusb Preco
d7fdb16078 📝 Update Korean docs as upstream
[ci skip]
2016-05-18 16:41:21 +09:00
Cheng Zhao
d2a567d6ab Merge pull request #5582 from electron/notification-user-info
Pass userInfo in systemPreferences.subscribeNotification
2016-05-18 07:36:31 +00:00
Cheng Zhao
3d0b98c9ca Use string description for unknown types 2016-05-18 16:01:08 +09:00
Cheng Zhao
68cf267b1d Do not convert NSDictionary to JSON 2016-05-18 15:49:33 +09:00
Cheng Zhao
240c346d02 Ignore invalid JSON object when converting NSDictionary 2016-05-18 14:54:37 +09:00
Cheng Zhao
97250b53e8 Pass userInfo in subscribeNotification 2016-05-18 14:40:19 +09:00
Cheng Zhao
49cca0978d Merge pull request #5580 from electron/annoymous-web-contents
Add support for anonymous WebContents
2016-05-18 05:31:10 +00:00
Cheng Zhao
87c10b3ac2 Make non-public module accesible via remote 2016-05-18 13:57:48 +09:00
Cheng Zhao
5f6c468f0f Handle keyboard events for WebContents that do not have owner window 2016-05-18 13:57:48 +09:00
Cheng Zhao
dc9b3fcef7 Remove WebViewGuestDelegate::HandleKeyboardEvent 2016-05-18 13:57:48 +09:00
Cheng Zhao
d6cb84f8a3 WebContents without owner window should always open detached devtools 2016-05-18 13:57:48 +09:00
Cheng Zhao
998ce73ad9 Add webContents.id property 2016-05-18 13:57:48 +09:00
Cheng Zhao
8a061b7183 A normal WebContents can have no owner window 2016-05-18 13:57:48 +09:00
Cheng Zhao
118afab67b Make sure BrowserContext is always destroyed after WebContents 2016-05-18 13:57:48 +09:00
Plusb Preco
7fd3149031 📝 Update Korean docs as upstream
[ci skip]
2016-05-18 12:15:29 +09:00
Cheng Zhao
242508e22f Merge pull request #5574 from electron/devtools-extension-test
Add test that loads a devtools extension
2016-05-18 01:46:44 +00:00
Cheng Zhao
5368da18ad Merge pull request #5575 from electron/link-to-spectron
Add spectron to ChromeDriver doc
2016-05-18 01:34:56 +00:00
deepak1556
467ccabb7e browser: flag to disable HTTP/2 and SPDY/3.1 protocols 2016-05-18 06:56:58 +05:30
Cheng Zhao
397d0e34ee Merge pull request #5559 from electron/disable-webview
Disable webview when nodeIntegration is off
2016-05-18 01:26:58 +00:00
Cheng Zhao
27da0f3338 Merge pull request #5576 from electron/title-tweaks
Tweak doc headings
2016-05-18 01:26:27 +00:00
Cheng Zhao
c7f5210b50 Merge pull request #5567 from felixrieseberg/versioning
Add Information about Versioning
2016-05-18 00:43:23 +00:00
Cheng Zhao
7bd11c14f6 Update brightray to fix linking problem on Linux 2016-05-18 09:42:38 +09:00
Kevin Sawicki
cee31ff67a Remove semicolon 2016-05-17 16:42:37 -07:00
Kevin Sawicki
9266f9abfc Update interval id variable name 2016-05-17 16:42:21 -07:00
Kevin Sawicki
f95c46d987 Show last panel by id 2016-05-17 16:40:34 -07:00
Kevin Sawicki
866260a2a6 with -> on 2016-05-17 16:05:47 -07:00
Kevin Sawicki
bfb75df49c Tweak doc headings 2016-05-17 16:02:54 -07:00
Kevin Sawicki
b301c473cd Simplify sentence 2016-05-17 15:14:50 -07:00
Kevin Sawicki
3f3871b1be Add spectron section 2016-05-17 15:13:26 -07:00
Kevin Sawicki
2043356fa3 Recommend electron-chromedriver 2016-05-17 15:09:09 -07:00
Kevin Sawicki
13cfc2d2a0 Add comment about panel switching via input event 2016-05-17 15:05:58 -07:00
Kevin Sawicki
8d0c5c30b8 Use consistent function styles 2016-05-17 15:05:27 -07:00
Kevin Sawicki
0b4b79d0a4 Use control on non-mac platforms 2016-05-17 15:01:32 -07:00
Kevin Sawicki
7db2601ea8 DRY up specs 2016-05-17 14:59:33 -07:00
Kevin Sawicki
77b074fbad Add spec for undocked devtools 2016-05-17 14:56:00 -07:00
Paul Betts
dc86ec8ddd Come Correct with Wrapping 2016-05-17 14:54:33 -07:00
Kevin Sawicki
189380d4ea Add spec for devtools extension 2016-05-17 14:52:45 -07:00
Paul Betts
bfb4867e10 🔥 old docs 2016-05-17 14:52:01 -07:00
Paul Betts
1623622073 Dox 2016-05-17 14:48:49 -07:00
Paul Betts
ae2eec3efa Move process-stats methods to process 2016-05-17 14:47:56 -07:00
Paul Betts
b51be9b83f Add docs 2016-05-17 14:47:56 -07:00
Paul Betts
60bc2acd6c Linting 2016-05-17 14:47:56 -07:00
Paul Betts
cd7bc0e50c Rename Metrics => MemoryInfo so it's consistent 2016-05-17 14:47:56 -07:00
Paul Betts
75362450cd Everything is in KB 2016-05-17 14:47:56 -07:00
Paul Betts
191b054ff0 Implement process and system memory statistics 2016-05-17 14:47:56 -07:00
Paul Betts
f4538daa0a Wire it up 2016-05-17 14:47:56 -07:00
Paul Betts
a7ac7ba4c1 Add the dumbest new builtin that works 2016-05-17 14:47:56 -07:00
Felix Rieseberg
7e09b1664a 📝 Add Information about Versioning 2016-05-17 20:20:25 +02:00
Plusb Preco
ee9e28dfdf 📝 Update Korean docs as upstream
[ci skip]
2016-05-17 21:18:31 +09:00
Cheng Zhao
fb6f5320e7 Update brightray for #5348 2016-05-17 20:33:44 +09:00
Cheng Zhao
7ce87c470a docs: webview is only available with nodeIntegration on 2016-05-17 17:10:33 +09:00
Cheng Zhao
90f52169af No more need to check for nodeIntegration when creating guest view 2016-05-17 17:06:02 +09:00
Cheng Zhao
0140015500 spec: WebView is disabled when nodeIntegration is disabled 2016-05-17 17:04:13 +09:00
Cheng Zhao
c1399f9bdc Disable webview when nodeIntegration is off 2016-05-17 16:51:06 +09:00
Cheng Zhao
3fedea4b9e Merge pull request #5557 from electron/osx-buttons
Implement titleBarStyle without using NSFullSizeContentViewWindowMask
2016-05-17 16:48:45 +09:00
Cheng Zhao
13bfb099a2 Fix the toolbar showing when titleBarStyle is hidden-inset 2016-05-17 16:25:18 +09:00
Cheng Zhao
f53aabaef5 Implement titleBarStyle without using NSFullSizeContentViewWindowMask 2016-05-17 15:48:14 +09:00
Cheng Zhao
ecbb088ea6 Merge pull request #5542 from stevekinney/standardize-requires
Standardize requires
2016-05-16 10:42:12 +09:00
Cheng Zhao
f5442a4888 Merge pull request #5540 from kcrt/master
Update: Japanese version of MAS submission guide
2016-05-16 10:33:25 +09:00
Cheng Zhao
57f082055a Merge pull request #5509 from electron/bengotow/dialog-titles
Add buttonLabel param to showOpen/showSave dialogs
2016-05-16 10:27:28 +09:00
Cheng Zhao
e53bfad018 Fix building on Windows 2016-05-16 10:09:41 +09:00
Steve Kinney
0d3d097ce8 💄 Standarize requires in JavaScript API 2016-05-15 09:41:30 -04:00
Steve Kinney
2317b56ac4 💄 Make the power-save-blocker a bit more concise 2016-05-15 09:36:13 -04:00
TAKAHASHI Kyohei
16c870191f Update: Japanese version of MAS submission-guide 2016-05-15 15:42:35 +09:00
Ben Gotow
54c654530e Fix linux support 2016-05-15 01:29:13 -05:00
Ben Gotow
6217d497ed Fix build issues 2016-05-15 01:03:32 -05:00
Ben Gotow
84cce6c2c1 Don't default to "Open", "Save", just let OS decide 2016-05-15 01:03:32 -05:00
Ben Gotow
40c531737d Add buttonLabel param to showOpen/showSave dialogs 2016-05-15 01:03:32 -05:00
Cheng Zhao
88f3c34412 Merge pull request #5532 from stevekinney/patch-2
💄 Use ES6; clean up CoffeeScript conversion in BrowserWindow module
2016-05-15 12:38:28 +09:00
Steve Kinney
fd9c9c3be7 💄 Use spread operator instead of arguments object 2016-05-14 22:33:21 -04:00
Steve Kinney
236810a923 💄 Use ES6; clean up CoffeeScript conversion
💄 Destructure app module

Address linting errors
2016-05-14 22:33:20 -04:00
Cheng Zhao
88dc73ec3f Merge pull request #5533 from stevekinney/patch-3
💄 Destructure globalShortcut module
2016-05-15 11:16:19 +09:00
Cheng Zhao
195a4bb3c1 Merge pull request #5538 from electron/vs2015-runtime
Ship with runtime libraries of Visual Studio 2015
2016-05-15 11:15:49 +09:00
Cheng Zhao
c540721bd3 Merge pull request #5537 from electron/suppress-more-tests
Suppress the tests that need to call window.open on Travis CI
2016-05-15 11:15:42 +09:00
Steve Kinney
c11d18fe06 💄 Destructure globalShortcut module
💄 Remove globalShortcut property

Add back the globalShortcut property
2016-05-14 21:53:42 -04:00
Cheng Zhao
8ed3659bb8 Link with libraries of Visual Studio 2015 2016-05-15 10:41:43 +09:00
Cheng Zhao
ba7a32b16e Sync submodule recursively 2016-05-15 10:33:23 +09:00
Cheng Zhao
800ab50b56 Download redist files of VS2015 2016-05-15 10:30:19 +09:00
Cheng Zhao
f43b9665c1 And increase timeout for the rest 2016-05-15 10:00:29 +09:00
Cheng Zhao
14906eb6c8 Merge pull request #5530 from stevekinney/patch-1
💄 Add ES6; Clean up from CoffeeScript conversion in app module
2016-05-15 09:57:49 +09:00
Cheng Zhao
c53e47265d Merge pull request #5535 from Godoy/translate-pt-br
Translate tutorial/devtools-extension.md to Portuguese (pt-br).
2016-05-15 09:47:29 +09:00
Cheng Zhao
5986a302d1 Merge pull request #5531 from kcrt/patch-1
wrong link destination
2016-05-15 09:46:59 +09:00
Cheng Zhao
f5acc8b599 Merge pull request #5525 from stanfieldr/doc-improvements
A little confused by docs
2016-05-15 09:45:43 +09:00
Cheng Zhao
e5af03547f Merge pull request #5534 from kcrt/master
Translate tutorial/security.md to Japanese.
2016-05-15 09:41:52 +09:00
Cheng Zhao
861a79dd6a Suppress the tests that need to call window.open on Travis CI 2016-05-15 09:41:02 +09:00
Cheng Zhao
5fe270a78f Merge pull request #5522 from Wolfer/patch-1
Update application-distribution.md
2016-05-15 09:38:31 +09:00
Steve Kinney
b1275420a3 Require download_items inline 2016-05-14 19:43:30 -04:00
Adriano Godoy
fb161d5f1f PT-BR link to devtools-extension tutorial on README.md 2016-05-14 16:06:11 -03:00
Adriano Godoy
6ac24f592c Translate tutorial/devtools-extension.md to Portuguese (pt-br). 2016-05-14 16:01:52 -03:00
TAKAHASHI Kyohei
88d158f2c1 Translate tutorial/security.md to Japanese. 2016-05-15 02:37:55 +09:00
Steve Kinney
e5036c0988 Use anonymous function for wrapping native classes 2016-05-14 12:28:28 -04:00
TAKAHASHI, Kyohei
0b5efcbc75 wrong link destination 2016-05-15 00:36:11 +09:00
Steve Kinney
0785c3bd15 💄 Add spaces to comply with Standard 2016-05-14 11:31:08 -04:00
Steve Kinney
5dc88aa543 💄 Add ES6; Clean up from CoffeeScript conversion 2016-05-14 11:17:46 -04:00
Cheng Zhao
5ec2e8d7e5 Merge pull request #5413 from electron/process-resource-usage
Fetch Process resource usage from WebContents
2016-05-14 23:28:51 +09:00
Cheng Zhao
3214fdd73f Fix failing CI on OS X 2016-05-14 23:11:13 +09:00
Cheng Zhao
d3e359ab2d No need for explicit type conversion 2016-05-14 22:50:05 +09:00
Cheng Zhao
c740438032 Rename webFrame.purgeCaches to webFrame.clearCache
This matches the name of session.clearCache.
2016-05-14 22:48:25 +09:00
Cheng Zhao
7459581d13 Fix cpplint warnings 2016-05-14 22:40:18 +09:00
Cheng Zhao
03052e81c1 Merge pull request #5519 from danhp/context-menu-docs
Fix indentation for context menu docs.
2016-05-14 21:49:16 +09:00
Daniel Pham
1bac1a9028 📝 Fix styling of the context-menu docs
[ci skip]
2016-05-14 08:43:23 -04:00
Cheng Zhao
de08473ea3 Merge pull request #5518 from danhp/popup-show-all
Fix context menu positioning on OS X
2016-05-14 20:00:30 +09:00
Robert Stanfield
2d46f6f66f It isn't entirely clear to me that 'window-all-closed' is used for
this purpose. I originally looked for an event that would fire if
all windows were closed and the reason was NOT due to the application
quitting; however, this differs in that it is called regardless of
whether the app was quitting.
2016-05-13 21:34:42 -04:00
Serg F
2287ad6d37 Update application-distribution.md 2016-05-13 23:19:56 +03:00
Paul Betts
2234307d41 Whitespace issues 2016-05-13 10:54:10 -07:00
Paul Betts
652913f8d6 Just return the type directly 2016-05-13 10:54:10 -07:00
Paul Betts
19cba3ff85 Use doubles to represent memory size in bytes 2016-05-13 10:54:10 -07:00
Paul Betts
6f0057532a Forgot scripts 2016-05-13 10:54:10 -07:00
Paul Betts
908084c0fd Document resource methods 2016-05-13 10:54:10 -07:00
Paul Betts
d83c36e0fd Add a way to drop all cached memory 2016-05-13 10:54:10 -07:00
Paul Betts
22a3765394 Wire up a new method in web frame 2016-05-13 10:54:10 -07:00
Paul Betts
61e775c055 Write native_mate converters for WebCache::ResourceTypeStat and friends 2016-05-13 10:54:10 -07:00
Daniel Pham
bebf8eabca 🍎 Fix context menu positioning 2016-05-13 10:54:40 -04:00
Cheng Zhao
847d9580b7 Bump v1.1.0 2016-05-13 17:00:02 +09:00
Cheng Zhao
faf896db67 Merge pull request #5461 from electron/chrome50
Continue the work of Chrome 50 upgrade
2016-05-13 14:52:09 +09:00
Cheng Zhao
10f144069d Allow using __weak keyword 2016-05-13 13:49:53 +09:00
Cheng Zhao
29b799de73 Update clang revision to 261368 2016-05-13 11:18:16 +09:00
Cheng Zhao
525d456f7c Update to Chrome 50.0.2661.102 2016-05-13 11:14:43 +09:00
Cheng Zhao
f1142cf2b5 Adapt to changes on hash functions of Chrome 50 2016-05-13 11:12:15 +09:00
Cheng Zhao
08779eb6d9 Use VS2015 on appveyor 2016-05-13 11:12:15 +09:00
Cheng Zhao
2d7b5c53b1 Change version number so native modules can build 2016-05-13 11:12:15 +09:00
Cheng Zhao
8dc8f8f485 Update libchromiumcontent: fix Release build on Windows 2016-05-13 11:12:01 +09:00
Cheng Zhao
4a409b870e chromedriver's version is now v2.21 2016-05-13 11:12:01 +09:00
Cheng Zhao
bb5b30b8a0 It is not allowed to run scripts in DidCreateDocumentElement 2016-05-13 11:12:01 +09:00
Cheng Zhao
906ae043f9 Fix crash when creating external buffer 2016-05-13 11:12:01 +09:00
Cheng Zhao
0ad03d9ff7 Suppress crashReporter test on x64 Windows for now 2016-05-13 11:12:01 +09:00
Cheng Zhao
3aaff23f78 Do not call import_vs_env for non-win32 2016-05-13 11:12:01 +09:00
Cheng Zhao
e77582baee Fix compilation warnings introduced by VS 2015 2016-05-13 11:12:01 +09:00
Cheng Zhao
2497c73009 Import build env from VS 2015 2016-05-13 11:12:01 +09:00
Cheng Zhao
73223fe5c3 Upgrade to Node v6 2016-05-13 11:12:01 +09:00
Cheng Zhao
9c0f298064 Update libchromiumcontent to fix renderer process crash 2016-05-13 11:12:01 +09:00
Cheng Zhao
525e3ee9c6 Update crashpad with AppKit patch 2016-05-13 11:11:50 +09:00
Cheng Zhao
9ccb495f60 Do not remove the patch for Command key 2016-05-13 11:11:50 +09:00
Cheng Zhao
35d9e37220 Simplify the check for web_frame_widget 2016-05-13 11:11:50 +09:00
Brian R. Bondy
e8c4fb6903 setBaseBackgroundColor moved to WebFrameWidget 2016-05-13 11:11:50 +09:00
Brian R. Bondy
a9652052c4 Update Brightray and libchromiumcontent v50 ref (Electron maintainer use
your refs)
2016-05-13 11:11:50 +09:00
Brian R. Bondy
a52dbf0784 Update SharedMemory buf constructor 2016-05-13 11:07:17 +09:00
Brian R. Bondy
900001e547 Update PlatformCanvas to SKCanvas 2016-05-13 11:07:17 +09:00
Brian R. Bondy
37ccd34a88 Update x11 global shortcut listeners 2016-05-13 11:07:17 +09:00
Brian R. Bondy
f93fa53aea Update linux menu overrides 2016-05-13 11:07:17 +09:00
Brian R. Bondy
0253aec0cd Add SkUserConfig.h with blank SkDebugf macro
This file was copied from:
./third_party/skia/include/config/SkUserConfig.h

But because of this linking error we needed to
define a macro for SkDebugf.

```
"SkDebugf(char const*, ...)", referenced from:
      SkBitmap::allocPixels(SkImageInfo const&, unsigned long) in
      libbrave_lib.a(brave_lib.native_desktop_media_list.o)
      ld: symbol(s) not found for architecture x86_64
```

There used to be a hack to copy this file here which was removed:
8de9d9e2bc
2016-05-13 11:07:17 +09:00
Brian R. Bondy
ce7c1023d5 Minimum fixes needed for chromium_src 2016-05-13 11:07:17 +09:00
Brian R. Bondy
02d72c81af Fix linking problem with IPC::MessageT
IPC::MessageT<ChromeUtilityHostMsg_ProcessStarted_Meta, std::__1::tuple<>, void>::MessageT(IPC::Routing)
2016-05-13 11:07:17 +09:00
Brian R. Bondy
22863b9f31 Fix GURL coonstructor from webkit string error 2016-05-13 11:07:17 +09:00
Brian R. Bondy
48e62ac0b5 Remove wwebaudio from web_preferences
Becauseit doesn't exist there anymore
2016-05-13 11:07:17 +09:00
Brian R. Bondy
732936713a GetNativeScreen -> GetScreen 2016-05-13 11:07:17 +09:00
Brian R. Bondy
f418ac5b5d Update to brave crashpad dep (Electron maintainer rebase this to use
your ref)
2016-05-13 11:07:17 +09:00
Brian R. Bondy
d889bdef49 Remove user_gesture parameter from PermissionManager::RequestPermission 2016-05-13 11:07:17 +09:00
Brian R. Bondy
c04353a845 WebFindOptions in its own header 2016-05-13 11:07:17 +09:00
Brian R. Bondy
ff91aeb5d4 Iterator to use size_t 2016-05-13 11:07:17 +09:00
Brian R. Bondy
8a2aebd03f PermissionStatus constant update 2016-05-13 11:07:17 +09:00
Brian R. Bondy
82f3bb26ce AccessTokenSet -> AccessTokenMap 2016-05-13 11:07:17 +09:00
Brian R. Bondy
2da39d31aa Update to new pref service location in components 2016-05-13 11:07:17 +09:00
Brian R. Bondy
5fda9bc6ae LoadAccessTokensCallbackType -> LoadAccessTokensCallback 2016-05-13 11:07:17 +09:00
Brian R. Bondy
93e9cf4ac1 No more GetCookieMonster 2016-05-13 11:07:17 +09:00
Brian R. Bondy
dc7928021d Widevine AAC CDM no longer avail
See chromium ./third_party /widevine/cdm/widevine_cdm_common.h
2016-05-13 11:07:17 +09:00
Brian R. Bondy
b78fe04f8f Remove Vorbis from CDM support
See https://codereview.chromium.org/1690353002
2016-05-13 11:07:17 +09:00
Brian R. Bondy
8d4ed037a2 Add referrer_schems to AddAdditionalSchemes 2016-05-13 11:07:17 +09:00
393 changed files with 6521 additions and 2248 deletions

View File

@@ -19,8 +19,7 @@ matrix:
- os: linux
env: TARGET_ARCH=ia32
allow_failures:
- env: TARGET_ARCH=arm
- env: TARGET_ARCH=ia32
- os: osx
script: './script/cibuild'

View File

@@ -5,19 +5,17 @@
[![devDependency Status](https://david-dm.org/electron/electron/dev-status.svg)](https://david-dm.org/electron/electron#info=devDependencies)
[![Join the Electron Community on Slack](http://atom-slack.herokuapp.com/badge.svg)](http://atom-slack.herokuapp.com/)
:zap: *Formerly known as Atom Shell* :zap:
The Electron framework lets you write cross-platform desktop applications
using JavaScript, HTML and CSS. It is based on [Node.js](https://nodejs.org/) and
[Chromium](http://www.chromium.org) and is used in the [Atom
editor](https://github.com/atom/atom).
[Chromium](http://www.chromium.org) and is used by the [Atom
editor](https://github.com/atom/atom) and many other [apps](http://electron.atom.io/apps).
Follow [@ElectronJS](https://twitter.com/electronjs) on Twitter for important
announcements.
This project adheres to the Contributor Covenant [code of conduct](CODE_OF_CONDUCT.md).
By participating, you are expected to uphold this code. Please report unacceptable
behavior to atom@github.com.
behavior to electron@github.com.
## Downloads

View File

@@ -2,6 +2,8 @@
# http://www.appveyor.com/docs/appveyor-yml
version: "{build}"
os: Visual Studio 2015
init:
- git config --global core.autocrlf input
@@ -10,7 +12,7 @@ platform:
- x64
install:
- cmd: SET PATH=C:\Program Files (x86)\MSBuild\12.0\bin\;%PATH%
- cmd: SET PATH=C:\Program Files (x86)\MSBuild\14.0\bin\;%PATH%
- cmd: SET PATH=C:\python27;%PATH%
- cmd: python script/cibuild

View File

@@ -89,11 +89,9 @@ content::PepperPluginInfo CreateWidevineCdmInfo(const base::FilePath& path,
// Add the supported codecs as if they came from the component manifest.
std::vector<std::string> codecs;
codecs.push_back(kCdmSupportedCodecVorbis);
codecs.push_back(kCdmSupportedCodecVp8);
codecs.push_back(kCdmSupportedCodecVp9);
#if defined(USE_PROPRIETARY_CODECS)
codecs.push_back(kCdmSupportedCodecAac);
codecs.push_back(kCdmSupportedCodecAvc1);
#endif // defined(USE_PROPRIETARY_CODECS)
std::string codec_string = base::JoinString(
@@ -181,6 +179,7 @@ base::string16 AtomContentClient::GetLocalizedString(int message_id) const {
void AtomContentClient::AddAdditionalSchemes(
std::vector<url::SchemeWithType>* standard_schemes,
std::vector<url::SchemeWithType>* referrer_schemes,
std::vector<std::string>* savable_schemes) {
standard_schemes->push_back({"chrome-extension", url::SCHEME_WITHOUT_PORT});
}

View File

@@ -25,6 +25,7 @@ class AtomContentClient : public brightray::ContentClient {
base::string16 GetLocalizedString(int message_id) const override;
void AddAdditionalSchemes(
std::vector<url::SchemeWithType>* standard_schemes,
std::vector<url::SchemeWithType>* referrer_schemes,
std::vector<std::string>* savable_schemes) override;
void AddPepperPlugins(
std::vector<content::PepperPluginInfo>* plugins) override;

View File

@@ -15,6 +15,7 @@
#include "atom/app/atom_main_delegate.h"
#include "atom/common/crash_reporter/win/crash_service_main.h"
#include "base/environment.h"
#include "base/process/launch.h"
#include "base/win/windows_version.h"
#include "content/public/app/sandbox_helper_win.h"
#include "sandbox/win/src/sandbox_types.h"
@@ -34,7 +35,6 @@
namespace {
const char* kRunAsNode = "ELECTRON_RUN_AS_NODE";
const char* kOldRunAsNode = "ATOM_SHELL_INTERNAL_RUN_AS_NODE";
bool IsEnvSet(const char* name) {
#if defined(OS_WIN)
@@ -47,10 +47,6 @@ bool IsEnvSet(const char* name) {
#endif
}
bool IsRunAsNode() {
return IsEnvSet(kRunAsNode) || IsEnvSet(kOldRunAsNode);
}
} // namespace
#if defined(OS_WIN)
@@ -58,14 +54,11 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
int argc = 0;
wchar_t** wargv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
// Make output work in console if we are not in cygiwn.
if (!IsEnvSet("TERM") && !IsEnvSet("ELECTRON_NO_ATTACH_CONSOLE")) {
AttachConsole(ATTACH_PARENT_PROCESS);
bool run_as_node = IsEnvSet(kRunAsNode);
FILE* dontcare;
freopen_s(&dontcare, "CON", "w", stdout);
freopen_s(&dontcare, "CON", "w", stderr);
}
// Make sure the output is printed to console.
if (run_as_node || !IsEnvSet("ELECTRON_NO_ATTACH_CONSOLE"))
base::RouteStdioToConsole(false);
// Convert argv to to UTF8
char** argv = new char*[argc];
@@ -101,12 +94,12 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
}
}
if (IsRunAsNode()) {
if (run_as_node) {
// Now that argv conversion is done, we can finally start.
base::AtExitManager atexit_manager;
base::i18n::InitializeICU();
return atom::NodeMain(argc, argv);
} else if (IsEnvSet("ATOM_SHELL_INTERNAL_CRASH_SERVICE")) {
} else if (IsEnvSet("ELECTRON_INTERNAL_CRASH_SERVICE")) {
return crash_service::Main(cmd);
}
@@ -124,7 +117,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
#elif defined(OS_LINUX) // defined(OS_WIN)
int main(int argc, const char* argv[]) {
if (IsRunAsNode()) {
if (IsEnvSet(kRunAsNode)) {
base::i18n::InitializeICU();
base::AtExitManager atexit_manager;
return atom::NodeMain(argc, const_cast<char**>(argv));
@@ -141,7 +134,7 @@ int main(int argc, const char* argv[]) {
#else // defined(OS_LINUX)
int main(int argc, const char* argv[]) {
if (IsRunAsNode()) {
if (IsEnvSet(kRunAsNode)) {
return AtomInitializeICUandStartNode(argc, const_cast<char**>(argv));
}

View File

@@ -30,6 +30,13 @@ bool IsBrowserProcess(base::CommandLine* cmd) {
return process_type.empty();
}
#if defined(OS_WIN)
void InvalidParameterHandler(const wchar_t*, const wchar_t*, const wchar_t*,
unsigned int, uintptr_t) {
// noop.
}
#endif
} // namespace
AtomMainDelegate::AtomMainDelegate() {
@@ -61,7 +68,7 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
#endif // !defined(OS_WIN)
// Only enable logging when --enable-logging is specified.
scoped_ptr<base::Environment> env(base::Environment::Create());
std::unique_ptr<base::Environment> env(base::Environment::Create());
if (!command_line->HasSwitch(switches::kEnableLogging) &&
!env->HasVar("ELECTRON_ENABLE_LOGGING")) {
settings.logging_dest = logging::LOG_NONE;
@@ -83,6 +90,15 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
chrome::RegisterPathProvider();
#if defined(OS_MACOSX)
SetUpBundleOverrides();
#endif
#if defined(OS_WIN)
// Ignore invalid parameter errors.
_set_invalid_parameter_handler(InvalidParameterHandler);
#endif
return brightray::MainDelegate::BasicStartupComplete(exit_code);
}
@@ -90,7 +106,7 @@ void AtomMainDelegate::PreSandboxStartup() {
brightray::MainDelegate::PreSandboxStartup();
// Set google API key.
scoped_ptr<base::Environment> env(base::Environment::Create());
std::unique_ptr<base::Environment> env(base::Environment::Create());
if (!env->HasVar("GOOGLE_API_KEY"))
env->SetVar("GOOGLE_API_KEY", GOOGLEAPIS_API_KEY);
@@ -130,8 +146,9 @@ content::ContentUtilityClient* AtomMainDelegate::CreateContentUtilityClient() {
return utility_client_.get();
}
scoped_ptr<brightray::ContentClient> AtomMainDelegate::CreateContentClient() {
return scoped_ptr<brightray::ContentClient>(new AtomContentClient);
std::unique_ptr<brightray::ContentClient>
AtomMainDelegate::CreateContentClient() {
return std::unique_ptr<brightray::ContentClient>(new AtomContentClient);
}
} // namespace atom

View File

@@ -24,17 +24,21 @@ class AtomMainDelegate : public brightray::MainDelegate {
content::ContentUtilityClient* CreateContentUtilityClient() override;
// brightray::MainDelegate:
scoped_ptr<brightray::ContentClient> CreateContentClient() override;
std::unique_ptr<brightray::ContentClient> CreateContentClient() override;
#if defined(OS_MACOSX)
void OverrideChildProcessPath() override;
void OverrideFrameworkBundlePath() override;
#endif
private:
#if defined(OS_MACOSX)
void SetUpBundleOverrides();
#endif
brightray::ContentClient content_client_;
scoped_ptr<content::ContentBrowserClient> browser_client_;
scoped_ptr<content::ContentRendererClient> renderer_client_;
scoped_ptr<content::ContentUtilityClient> utility_client_;
std::unique_ptr<content::ContentBrowserClient> browser_client_;
std::unique_ptr<content::ContentRendererClient> renderer_client_;
std::unique_ptr<content::ContentUtilityClient> utility_client_;
DISALLOW_COPY_AND_ASSIGN(AtomMainDelegate);
};

View File

@@ -7,7 +7,10 @@
#include "base/mac/bundle_locations.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_nsautorelease_pool.h"
#include "base/path_service.h"
#include "base/strings/sys_string_conversions.h"
#include "brightray/common/application_info.h"
#include "brightray/common/mac/main_application_bundle.h"
#include "content/public/common/content_paths.h"
@@ -48,4 +51,15 @@ void AtomMainDelegate::OverrideChildProcessPath() {
PathService::Override(content::CHILD_PROCESS_EXE, helper_path);
}
void AtomMainDelegate::SetUpBundleOverrides() {
base::mac::ScopedNSAutoreleasePool pool;
NSBundle* bundle = brightray::MainApplicationBundle();
std::string base_bundle_id =
base::SysNSStringToUTF8([bundle bundleIdentifier]);
NSString* team_id = [bundle objectForInfoDictionaryKey:@"ElectronTeamID"];
if (team_id)
base_bundle_id = base::SysNSStringToUTF8(team_id) + "." + base_bundle_id;
base::mac::SetBaseBundleID(base_bundle_id.c_str());
}
} // namespace atom

View File

@@ -7,8 +7,9 @@
#include "atom/app/uv_task_runner.h"
#include "atom/browser/javascript_environment.h"
#include "atom/browser/node_debugger.h"
#include "base/command_line.h"
#include "atom/common/node_includes.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/thread_task_runner_handle.h"
#include "gin/array_buffer.h"
#include "gin/public/isolate_holder.h"
@@ -27,6 +28,11 @@ int NodeMain(int argc, char *argv[]) {
scoped_refptr<UvTaskRunner> uv_task_runner(new UvTaskRunner(loop));
base::ThreadTaskRunnerHandle handle(uv_task_runner);
// Initialize feature list.
std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
feature_list->InitializeFromCommandLine("", "");
base::FeatureList::SetInstance(std::move(feature_list));
gin::V8Initializer::LoadV8Snapshot();
gin::V8Initializer::LoadV8Natives();
JavascriptEnvironment gin_env;

View File

@@ -319,7 +319,7 @@ void App::AllowCertificateError(
void App::SelectClientCertificate(
content::WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info,
scoped_ptr<content::ClientCertificateDelegate> delegate) {
std::unique_ptr<content::ClientCertificateDelegate> delegate) {
std::shared_ptr<content::ClientCertificateDelegate>
shared_delegate(delegate.release());
bool prevent_default =
@@ -370,17 +370,11 @@ void App::SetPath(mate::Arguments* args,
void App::SetDesktopName(const std::string& desktop_name) {
#if defined(OS_LINUX)
scoped_ptr<base::Environment> env(base::Environment::Create());
std::unique_ptr<base::Environment> env(base::Environment::Create());
env->SetVar("CHROME_DESKTOP", desktop_name);
#endif
}
void App::AllowNTLMCredentialsForAllDomains(bool should_allow) {
auto browser_context = static_cast<AtomBrowserContext*>(
AtomBrowserMainParts::Get()->browser_context());
browser_context->AllowNTLMCredentialsForAllDomains(should_allow);
}
std::string App::GetLocale() {
return l10n_util::GetApplicationLocale("");
}
@@ -407,13 +401,20 @@ bool App::MakeSingleInstance(
}
}
void App::ReleaseSingleInstance() {
if (process_singleton_.get()) {
process_singleton_->Cleanup();
process_singleton_.reset();
}
}
#if defined(USE_NSS_CERTS)
void App::ImportCertificate(
const base::DictionaryValue& options,
const net::CompletionCallback& callback) {
auto browser_context = AtomBrowserMainParts::Get()->browser_context();
if (!certificate_manager_model_) {
scoped_ptr<base::DictionaryValue> copy = options.CreateDeepCopy();
std::unique_ptr<base::DictionaryValue> copy = options.CreateDeepCopy();
CertificateManagerModel::Create(browser_context,
base::Bind(&App::OnCertificateManagerModelCreated,
base::Unretained(this),
@@ -427,9 +428,9 @@ void App::ImportCertificate(
}
void App::OnCertificateManagerModelCreated(
scoped_ptr<base::DictionaryValue> options,
std::unique_ptr<base::DictionaryValue> options,
const net::CompletionCallback& callback,
scoped_ptr<CertificateManagerModel> model) {
std::unique_ptr<CertificateManagerModel> model) {
certificate_manager_model_ = std::move(model);
int rv = ImportIntoCertStore(certificate_manager_model_.get(),
*(options.get()));
@@ -482,13 +483,12 @@ void App::BuildPrototype(
.SetMethod("setPath", &App::SetPath)
.SetMethod("getPath", &App::GetPath)
.SetMethod("setDesktopName", &App::SetDesktopName)
.SetMethod("allowNTLMCredentialsForAllDomains",
&App::AllowNTLMCredentialsForAllDomains)
.SetMethod("getLocale", &App::GetLocale)
#if defined(USE_NSS_CERTS)
.SetMethod("importCertificate", &App::ImportCertificate)
#endif
.SetMethod("makeSingleInstance", &App::MakeSingleInstance);
.SetMethod("makeSingleInstance", &App::MakeSingleInstance)
.SetMethod("releaseSingleInstance", &App::ReleaseSingleInstance);
}
} // namespace api

View File

@@ -51,9 +51,9 @@ class App : public AtomBrowserClient::Delegate,
#if defined(USE_NSS_CERTS)
void OnCertificateManagerModelCreated(
scoped_ptr<base::DictionaryValue> options,
std::unique_ptr<base::DictionaryValue> options,
const net::CompletionCallback& callback,
scoped_ptr<CertificateManagerModel> model);
std::unique_ptr<CertificateManagerModel> model);
#endif
protected:
@@ -93,7 +93,7 @@ class App : public AtomBrowserClient::Delegate,
void SelectClientCertificate(
content::WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info,
scoped_ptr<content::ClientCertificateDelegate> delegate) override;
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
// content::GpuDataManagerObserver:
void OnGpuProcessCrashed(base::TerminationStatus exit_code) override;
@@ -106,9 +106,9 @@ class App : public AtomBrowserClient::Delegate,
const base::FilePath& path);
void SetDesktopName(const std::string& desktop_name);
void AllowNTLMCredentialsForAllDomains(bool should_allow);
bool MakeSingleInstance(
const ProcessSingleton::NotificationCallback& callback);
void ReleaseSingleInstance();
std::string GetLocale();
#if defined(USE_NSS_CERTS)
@@ -116,10 +116,10 @@ class App : public AtomBrowserClient::Delegate,
const net::CompletionCallback& callback);
#endif
scoped_ptr<ProcessSingleton> process_singleton_;
std::unique_ptr<ProcessSingleton> process_singleton_;
#if defined(USE_NSS_CERTS)
scoped_ptr<CertificateManagerModel> certificate_manager_model_;
std::unique_ptr<CertificateManagerModel> certificate_manager_model_;
#endif
DISALLOW_COPY_AND_ASSIGN(App);

View File

@@ -112,7 +112,7 @@ void RunCallbackInUI(const base::Closure& callback) {
}
// Remove cookies from |list| not matching |filter|, and pass it to |callback|.
void FilterCookies(scoped_ptr<base::DictionaryValue> filter,
void FilterCookies(std::unique_ptr<base::DictionaryValue> filter,
const Cookies::GetCallback& callback,
const net::CookieList& list) {
net::CookieList result;
@@ -125,7 +125,7 @@ void FilterCookies(scoped_ptr<base::DictionaryValue> filter,
// Receives cookies matching |filter| in IO thread.
void GetCookiesOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
scoped_ptr<base::DictionaryValue> filter,
std::unique_ptr<base::DictionaryValue> filter,
const Cookies::GetCallback& callback) {
std::string url;
filter->GetString("url", &url);
@@ -133,12 +133,12 @@ void GetCookiesOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
auto filtered_callback =
base::Bind(FilterCookies, base::Passed(&filter), callback);
net::CookieMonster* monster = GetCookieStore(getter)->GetCookieMonster();
// Empty url will match all url cookies.
if (url.empty())
monster->GetAllCookiesAsync(filtered_callback);
GetCookieStore(getter)->GetAllCookiesAsync(filtered_callback);
else
monster->GetAllCookiesForURLAsync(GURL(url), filtered_callback);
GetCookieStore(getter)->GetAllCookiesForURLAsync(GURL(url),
filtered_callback);
}
// Removes cookie with |url| and |name| in IO thread.
@@ -157,12 +157,14 @@ void OnSetCookie(const Cookies::SetCallback& callback, bool success) {
// Sets cookie with |details| in IO thread.
void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
scoped_ptr<base::DictionaryValue> details,
std::unique_ptr<base::DictionaryValue> details,
const Cookies::SetCallback& callback) {
std::string url, name, value, domain, path;
bool secure = false;
bool http_only = false;
double creation_date;
double expiration_date;
double last_access_date;
details->GetString("url", &url);
details->GetString("name", &name);
details->GetString("value", &value);
@@ -171,6 +173,13 @@ void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
details->GetBoolean("secure", &secure);
details->GetBoolean("httpOnly", &http_only);
base::Time creation_time;
if (details->GetDouble("creationDate", &creation_date)) {
creation_time = (creation_date == 0) ?
base::Time::UnixEpoch() :
base::Time::FromDoubleT(creation_date);
}
base::Time expiration_time;
if (details->GetDouble("expirationDate", &expiration_date)) {
expiration_time = (expiration_date == 0) ?
@@ -178,10 +187,18 @@ void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
base::Time::FromDoubleT(expiration_date);
}
GetCookieStore(getter)->GetCookieMonster()->SetCookieWithDetailsAsync(
GURL(url), name, value, domain, path, expiration_time, secure, http_only,
false, false, false, net::COOKIE_PRIORITY_DEFAULT,
base::Bind(OnSetCookie, callback));
base::Time last_access_time;
if (details->GetDouble("lastAccessDate", &last_access_date)) {
last_access_time = (last_access_date == 0) ?
base::Time::UnixEpoch() :
base::Time::FromDoubleT(last_access_date);
}
GetCookieStore(getter)->SetCookieWithDetailsAsync(
GURL(url), name, value, domain, path, creation_time,
expiration_time, last_access_time, secure, http_only,
net::CookieSameSite::DEFAULT_MODE, false,
net::COOKIE_PRIORITY_DEFAULT, base::Bind(OnSetCookie, callback));
}
} // namespace
@@ -197,7 +214,7 @@ Cookies::~Cookies() {
void Cookies::Get(const base::DictionaryValue& filter,
const GetCallback& callback) {
scoped_ptr<base::DictionaryValue> copied(filter.CreateDeepCopy());
std::unique_ptr<base::DictionaryValue> copied(filter.CreateDeepCopy());
auto getter = make_scoped_refptr(request_context_getter_);
content::BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
@@ -214,7 +231,7 @@ void Cookies::Remove(const GURL& url, const std::string& name,
void Cookies::Set(const base::DictionaryValue& details,
const SetCallback& callback) {
scoped_ptr<base::DictionaryValue> copied(details.CreateDeepCopy());
std::unique_ptr<base::DictionaryValue> copied(details.CreateDeepCopy());
auto getter = make_scoped_refptr(request_context_getter_);
content::BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,

View File

@@ -52,7 +52,7 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
const std::string& message) {
DCHECK(agent_host == agent_host_.get());
scoped_ptr<base::Value> parsed_message(base::JSONReader::Read(message));
std::unique_ptr<base::Value> parsed_message(base::JSONReader::Read(message));
if (!parsed_message->IsType(base::Value::TYPE_DICTIONARY))
return;

View File

@@ -61,9 +61,9 @@ void DesktopCapturer::StartHandling(bool capture_window,
options.set_disable_effects(false);
#endif
scoped_ptr<webrtc::ScreenCapturer> screen_capturer(
std::unique_ptr<webrtc::ScreenCapturer> screen_capturer(
capture_screen ? webrtc::ScreenCapturer::Create(options) : nullptr);
scoped_ptr<webrtc::WindowCapturer> window_capturer(
std::unique_ptr<webrtc::WindowCapturer> window_capturer(
capture_window ? webrtc::WindowCapturer::Create(options) : nullptr);
media_list_.reset(new NativeDesktopMediaList(
std::move(screen_capturer), std::move(window_capturer)));

View File

@@ -39,7 +39,7 @@ class DesktopCapturer: public mate::EventEmitter<DesktopCapturer>,
bool OnRefreshFinished() override;
private:
scoped_ptr<DesktopMediaList> media_list_;
std::unique_ptr<DesktopMediaList> media_list_;
DISALLOW_COPY_AND_ASSIGN(DesktopCapturer);
};

View File

@@ -67,6 +67,7 @@ void ShowMessageBox(int type,
}
void ShowOpenDialog(const std::string& title,
const std::string& button_label,
const base::FilePath& default_path,
const file_dialog::Filters& filters,
int properties,
@@ -77,17 +78,18 @@ void ShowOpenDialog(const std::string& title,
if (mate::Converter<file_dialog::OpenDialogCallback>::FromV8(args->isolate(),
peek,
&callback)) {
file_dialog::ShowOpenDialog(window, title, default_path, filters,
properties, callback);
file_dialog::ShowOpenDialog(window, title, button_label, default_path,
filters, properties, callback);
} else {
std::vector<base::FilePath> paths;
if (file_dialog::ShowOpenDialog(window, title, default_path, filters,
properties, &paths))
if (file_dialog::ShowOpenDialog(window, title, button_label, default_path,
filters, properties, &paths))
args->Return(paths);
}
}
void ShowSaveDialog(const std::string& title,
const std::string& button_label,
const base::FilePath& default_path,
const file_dialog::Filters& filters,
atom::NativeWindow* window,
@@ -97,11 +99,12 @@ void ShowSaveDialog(const std::string& title,
if (mate::Converter<file_dialog::SaveDialogCallback>::FromV8(args->isolate(),
peek,
&callback)) {
file_dialog::ShowSaveDialog(window, title, default_path, filters, callback);
file_dialog::ShowSaveDialog(window, title, button_label, default_path,
filters, callback);
} else {
base::FilePath path;
if (file_dialog::ShowSaveDialog(window, title, default_path, filters,
&path))
if (file_dialog::ShowSaveDialog(window, title, button_label, default_path,
filters, &path))
args->Return(path);
}
}

View File

@@ -55,7 +55,7 @@ class Menu : public mate::TrackableObject<Menu>,
int x = -1, int y = -1,
int positioning_item = 0) = 0;
scoped_ptr<AtomMenuModel> model_;
std::unique_ptr<AtomMenuModel> model_;
Menu* parent_;
private:

View File

@@ -7,6 +7,8 @@
#include "atom/browser/native_window.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/sys_string_conversions.h"
#include "brightray/browser/inspectable_web_contents.h"
#include "brightray/browser/inspectable_web_contents_view.h"
#include "content/public/browser/web_contents.h"
#include "atom/common/node_includes.h"
@@ -22,14 +24,15 @@ void MenuMac::PopupAt(Window* window, int x, int y, int positioning_item) {
NativeWindow* native_window = window->window();
if (!native_window)
return;
content::WebContents* web_contents = native_window->web_contents();
brightray::InspectableWebContents* web_contents =
native_window->inspectable_web_contents();
if (!web_contents)
return;
base::scoped_nsobject<AtomMenuController> menu_controller(
[[AtomMenuController alloc] initWithModel:model_.get()]);
NSMenu* menu = [menu_controller menu];
NSView* view = web_contents->GetContentNativeView();
NSView* view = web_contents->GetView()->GetNativeView();
// Which menu item to show.
NSMenuItem* item = nil;
@@ -46,6 +49,23 @@ void MenuMac::PopupAt(Window* window, int x, int y, int positioning_item) {
position = NSMakePoint(x, [view frame].size.height - y);
}
// If no preferred item is specified, try to show all of the menu items.
if (!positioning_item) {
CGFloat windowBottom = CGRectGetMinY([view window].frame);
CGFloat lowestMenuPoint = windowBottom + position.y - [menu size].height;
CGFloat screenBottom = CGRectGetMinY([view window].screen.frame);
CGFloat distanceFromBottom = lowestMenuPoint - screenBottom;
if (distanceFromBottom < 0)
position.y = position.y - distanceFromBottom + 4;
}
// Place the menu left of cursor if it is overflowing off right of screen.
CGFloat windowLeft = CGRectGetMinX([view window].frame);
CGFloat rightmostMenuPoint = windowLeft + position.x + [menu size].width;
CGFloat screenRight = CGRectGetMaxX([view window].screen.frame);
if (rightmostMenuPoint > screenRight)
position.x = position.x - [menu size].width;
// Show the menu.
[menu popUpMenuPositioningItem:item atLocation:position inView:view];
}

View File

@@ -30,7 +30,7 @@ void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item) {
// (-1, -1) means showing on mouse location.
gfx::Point location;
if (x == -1 || y == -1) {
location = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint();
location = gfx::Screen::GetScreen()->GetCursorScreenPoint();
} else {
gfx::Point origin = view->GetViewBounds().origin();
location = gfx::Point(origin.x() + x, origin.y() + y);

View File

@@ -70,7 +70,7 @@ void PowerSaveBlocker::UpdatePowerSaveBlocker() {
}
if (!power_save_blocker_ || new_blocker_type != current_blocker_type_) {
scoped_ptr<content::PowerSaveBlocker> new_blocker =
std::unique_ptr<content::PowerSaveBlocker> new_blocker =
content::PowerSaveBlocker::Create(
new_blocker_type,
content::PowerSaveBlocker::kReasonOther,

View File

@@ -37,7 +37,7 @@ class PowerSaveBlocker : public mate::TrackableObject<PowerSaveBlocker> {
bool Stop(int id);
bool IsStarted(int id);
scoped_ptr<content::PowerSaveBlocker> power_save_blocker_;
std::unique_ptr<content::PowerSaveBlocker> power_save_blocker_;
// Currnet blocker type used by |power_save_blocker_|
content::PowerSaveBlocker::PowerSaveBlockerType current_blocker_type_;

View File

@@ -110,7 +110,7 @@ class Protocol : public mate::Wrappable<Protocol> {
const Handler& handler) {
if (job_factory_->IsHandledProtocol(scheme))
return PROTOCOL_REGISTERED;
scoped_ptr<CustomProtocolHandler<RequestJob>> protocol_handler(
std::unique_ptr<CustomProtocolHandler<RequestJob>> protocol_handler(
new CustomProtocolHandler<RequestJob>(
isolate(), request_context_getter_, handler));
if (job_factory_->SetProtocolHandler(scheme, std::move(protocol_handler)))
@@ -152,7 +152,7 @@ class Protocol : public mate::Wrappable<Protocol> {
return PROTOCOL_FAIL;
if (ContainsKey(original_protocols_, scheme))
return PROTOCOL_INTERCEPTED;
scoped_ptr<CustomProtocolHandler<RequestJob>> protocol_handler(
std::unique_ptr<CustomProtocolHandler<RequestJob>> protocol_handler(
new CustomProtocolHandler<RequestJob>(
isolate(), request_context_getter_, handler));
original_protocols_.set(
@@ -176,7 +176,7 @@ class Protocol : public mate::Wrappable<Protocol> {
// Map that stores the original protocols of schemes.
using OriginalProtocolsMap = base::ScopedPtrHashMap<
std::string,
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>>;
std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>>;
OriginalProtocolsMap original_protocols_;
AtomURLRequestJobFactory* job_factory_; // weak ref

View File

@@ -0,0 +1,88 @@
// Copyright (c) 2016 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/browser/api/atom_api_render_process_preferences.h"
#include "atom/browser/atom_browser_client.h"
#include "atom/browser/native_window.h"
#include "atom/browser/window_list.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "content/public/browser/render_process_host.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
namespace atom {
namespace api {
namespace {
bool IsBrowserWindow(content::RenderProcessHost* process) {
content::WebContents* web_contents =
static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())->
GetWebContentsFromProcessID(process->GetID());
if (!web_contents)
return false;
NativeWindow* window = NativeWindow::FromWebContents(web_contents);
if (!window)
return false;
return true;
}
} // namespace
RenderProcessPreferences::RenderProcessPreferences(
v8::Isolate* isolate,
const atom::RenderProcessPreferences::Predicate& predicate)
: preferences_(predicate) {
Init(isolate);
}
RenderProcessPreferences::~RenderProcessPreferences() {
}
int RenderProcessPreferences::AddEntry(const base::DictionaryValue& entry) {
return preferences_.AddEntry(entry);
}
void RenderProcessPreferences::RemoveEntry(int id) {
preferences_.RemoveEntry(id);
}
// static
void RenderProcessPreferences::BuildPrototype(
v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> prototype) {
mate::ObjectTemplateBuilder(isolate, prototype)
.SetMethod("addEntry", &RenderProcessPreferences::AddEntry)
.SetMethod("removeEntry", &RenderProcessPreferences::RemoveEntry);
}
// static
mate::Handle<RenderProcessPreferences>
RenderProcessPreferences::ForAllBrowserWindow(v8::Isolate* isolate) {
return mate::CreateHandle(
isolate,
new RenderProcessPreferences(isolate, base::Bind(&IsBrowserWindow)));
}
} // namespace api
} // namespace atom
namespace {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("forAllBrowserWindow",
&atom::api::RenderProcessPreferences::ForAllBrowserWindow);
}
} // namespace
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_render_process_preferences,
Initialize)

View File

@@ -0,0 +1,44 @@
// Copyright (c) 2016 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_API_ATOM_API_RENDER_PROCESS_PREFERENCES_H_
#define ATOM_BROWSER_API_ATOM_API_RENDER_PROCESS_PREFERENCES_H_
#include "atom/browser/render_process_preferences.h"
#include "native_mate/handle.h"
#include "native_mate/wrappable.h"
namespace atom {
namespace api {
class RenderProcessPreferences
: public mate::Wrappable<RenderProcessPreferences> {
public:
static mate::Handle<RenderProcessPreferences>
ForAllBrowserWindow(v8::Isolate* isolate);
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> prototype);
int AddEntry(const base::DictionaryValue& entry);
void RemoveEntry(int id);
protected:
RenderProcessPreferences(
v8::Isolate* isolate,
const atom::RenderProcessPreferences::Predicate& predicate);
~RenderProcessPreferences() override;
private:
atom::RenderProcessPreferences preferences_;
DISALLOW_COPY_AND_ASSIGN(RenderProcessPreferences);
};
} // namespace api
} // namespace atom
#endif // ATOM_BROWSER_API_ATOM_API_RENDER_PROCESS_PREFERENCES_H_

View File

@@ -99,7 +99,7 @@ v8::Local<v8::Value> Screen::Create(v8::Isolate* isolate) {
return v8::Null(isolate);
}
gfx::Screen* screen = gfx::Screen::GetNativeScreen();
gfx::Screen* screen = gfx::Screen::GetScreen();
if (!screen) {
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
isolate, "Failed to get screen information")));

View File

@@ -22,7 +22,7 @@
#include "atom/common/node_includes.h"
#include "base/files/file_path.h"
#include "base/guid.h"
#include "base/prefs/pref_service.h"
#include "components/prefs/pref_service.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/thread_task_runner_handle.h"
@@ -36,6 +36,8 @@
#include "net/base/load_flags.h"
#include "net/disk_cache/disk_cache.h"
#include "net/dns/host_cache.h"
#include "net/http/http_auth_handler_factory.h"
#include "net/http/http_auth_preferences.h"
#include "net/proxy/proxy_service.h"
#include "net/proxy/proxy_config_service_fixed.h"
#include "net/url_request/url_request_context.h"
@@ -190,7 +192,7 @@ class ResolveProxyHelper {
// Start the request.
int result = proxy_service->ResolveProxy(
url, net::LOAD_NORMAL, &proxy_info_, completion_callback,
url, "GET", net::LOAD_NORMAL, &proxy_info_, completion_callback,
&pac_req_, nullptr, net::BoundNetLog());
// Completed synchronously.
@@ -284,6 +286,19 @@ void ClearHostResolverCacheInIO(
}
}
void AllowNTLMCredentialsForDomainsInIO(
const scoped_refptr<net::URLRequestContextGetter>& context_getter,
const std::string& domains) {
auto request_context = context_getter->GetURLRequestContext();
auto auth_handler = request_context->http_auth_handler_factory();
if (auth_handler) {
auto auth_preferences = const_cast<net::HttpAuthPreferences*>(
auth_handler->http_auth_preferences());
if (auth_preferences)
auth_preferences->set_server_whitelist(domains);
}
}
} // namespace
Session::Session(v8::Isolate* isolate, AtomBrowserContext* browser_context)
@@ -369,7 +384,7 @@ void Session::SetDownloadPath(const base::FilePath& path) {
}
void Session::EnableNetworkEmulation(const mate::Dictionary& options) {
scoped_ptr<brightray::DevToolsNetworkConditions> conditions;
std::unique_ptr<brightray::DevToolsNetworkConditions> conditions;
bool offline = false;
double latency, download_throughput, upload_throughput;
if (options.Get("offline", &offline) && offline) {
@@ -392,7 +407,7 @@ void Session::EnableNetworkEmulation(const mate::Dictionary& options) {
}
void Session::DisableNetworkEmulation() {
scoped_ptr<brightray::DevToolsNetworkConditions> conditions;
std::unique_ptr<brightray::DevToolsNetworkConditions> conditions;
browser_context_->network_controller_handle()->SetNetworkState(
devtools_network_emulation_client_id_, std::move(conditions));
browser_context_->network_delegate()->SetDevToolsNetworkEmulationClientId(
@@ -432,6 +447,13 @@ void Session::ClearHostResolverCache(mate::Arguments* args) {
callback));
}
void Session::AllowNTLMCredentialsForDomains(const std::string& domains) {
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::Bind(&AllowNTLMCredentialsForDomainsInIO,
make_scoped_refptr(browser_context_->GetRequestContext()),
domains));
}
v8::Local<v8::Value> Session::Cookies(v8::Isolate* isolate) {
if (cookies_.IsEmpty()) {
auto handle = atom::api::Cookies::Create(isolate, browser_context());
@@ -487,6 +509,8 @@ void Session::BuildPrototype(v8::Isolate* isolate,
.SetMethod("setPermissionRequestHandler",
&Session::SetPermissionRequestHandler)
.SetMethod("clearHostResolverCache", &Session::ClearHostResolverCache)
.SetMethod("allowNTLMCredentialsForDomains",
&Session::AllowNTLMCredentialsForDomains)
.SetProperty("cookies", &Session::Cookies)
.SetProperty("webRequest", &Session::WebRequest);
}

View File

@@ -79,6 +79,7 @@ class Session: public mate::TrackableObject<Session>,
void SetPermissionRequestHandler(v8::Local<v8::Value> val,
mate::Arguments* args);
void ClearHostResolverCache(mate::Arguments* args);
void AllowNTLMCredentialsForDomains(const std::string& domains);
v8::Local<v8::Value> Cookies(v8::Isolate* isolate);
v8::Local<v8::Value> WebRequest(v8::Isolate* isolate);

View File

@@ -5,6 +5,7 @@
#include "atom/browser/api/atom_api_system_preferences.h"
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "native_mate/dictionary.h"

View File

@@ -11,6 +11,10 @@
#include "base/callback.h"
#include "native_mate/handle.h"
namespace base {
class DictionaryValue;
}
namespace atom {
namespace api {
@@ -22,11 +26,16 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences> {
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> prototype);
#if defined(OS_MACOSX)
using NotificationCallback = base::Callback<
void(const std::string&, const base::DictionaryValue&)>;
#endif
#if defined(OS_WIN)
bool IsAeroGlassEnabled();
#elif defined(OS_MACOSX)
int SubscribeNotification(const std::string& name,
const base::Closure& callback);
const NotificationCallback& callback);
void UnsubscribeNotification(int id);
v8::Local<v8::Value> GetUserDefault(const std::string& name,
const std::string& type);

View File

@@ -8,8 +8,10 @@
#import <Cocoa/Cocoa.h>
#include "atom/browser/mac/dict_util.h"
#include "atom/common/native_mate_converters/gurl_converter.h"
#include "base/strings/sys_string_conversions.h"
#include "base/values.h"
#include "net/base/mac/url_conversions.h"
namespace atom {
@@ -25,16 +27,26 @@ std::map<int, id> g_id_map;
} // namespace
int SystemPreferences::SubscribeNotification(const std::string& name,
const base::Closure& callback) {
int SystemPreferences::SubscribeNotification(
const std::string& name, const NotificationCallback& callback) {
int request_id = g_next_id++;
__block base::Closure copied_callback = callback;
__block NotificationCallback copied_callback = callback;
g_id_map[request_id] = [[NSDistributedNotificationCenter defaultCenter]
addObserverForName:base::SysUTF8ToNSString(name)
object:nil
queue:nil
usingBlock:^(NSNotification* notification) {
copied_callback.Run();
std::unique_ptr<base::DictionaryValue> user_info =
NSDictionaryToDictionaryValue(notification.userInfo);
if (user_info) {
copied_callback.Run(
base::SysNSStringToUTF8(notification.name),
*user_info);
} else {
copied_callback.Run(
base::SysNSStringToUTF8(notification.name),
base::DictionaryValue());
}
}
];
return request_id;

View File

@@ -9,6 +9,7 @@
#include "atom/browser/api/atom_api_menu.h"
#include "atom/browser/browser.h"
#include "atom/browser/ui/tray_icon.h"
#include "atom/common/api/atom_api_native_image.h"
#include "atom/common/native_mate_converters/gfx_converter.h"
#include "atom/common/native_mate_converters/image_converter.h"
#include "atom/common/native_mate_converters/string16_converter.h"
@@ -22,9 +23,9 @@ namespace atom {
namespace api {
Tray::Tray(v8::Isolate* isolate, const gfx::Image& image)
Tray::Tray(v8::Isolate* isolate, mate::Handle<NativeImage> image)
: tray_icon_(TrayIcon::Create()) {
tray_icon_->SetImage(image);
SetImage(isolate, image);
tray_icon_->AddObserver(this);
}
@@ -32,7 +33,8 @@ Tray::~Tray() {
}
// static
mate::WrappableBase* Tray::New(v8::Isolate* isolate, const gfx::Image& image) {
mate::WrappableBase* Tray::New(v8::Isolate* isolate,
mate::Handle<NativeImage> image) {
if (!Browser::Get()->is_ready()) {
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
isolate, "Cannot create Tray before app is ready")));
@@ -94,29 +96,38 @@ void Tray::OnDragEnded() {
Emit("drag-end");
}
void Tray::SetImage(mate::Arguments* args, const gfx::Image& image) {
tray_icon_->SetImage(image);
void Tray::SetImage(v8::Isolate* isolate, mate::Handle<NativeImage> image) {
#if defined(OS_WIN)
tray_icon_->SetImage(image->GetHICON(GetSystemMetrics(SM_CXSMICON)));
#else
tray_icon_->SetImage(image->image());
#endif
}
void Tray::SetPressedImage(mate::Arguments* args, const gfx::Image& image) {
tray_icon_->SetPressedImage(image);
void Tray::SetPressedImage(v8::Isolate* isolate,
mate::Handle<NativeImage> image) {
#if defined(OS_WIN)
tray_icon_->SetPressedImage(image->GetHICON(GetSystemMetrics(SM_CXSMICON)));
#else
tray_icon_->SetPressedImage(image->image());
#endif
}
void Tray::SetToolTip(mate::Arguments* args, const std::string& tool_tip) {
void Tray::SetToolTip(const std::string& tool_tip) {
tray_icon_->SetToolTip(tool_tip);
}
void Tray::SetTitle(mate::Arguments* args, const std::string& title) {
void Tray::SetTitle(const std::string& title) {
tray_icon_->SetTitle(title);
}
void Tray::SetHighlightMode(mate::Arguments* args, bool highlight) {
void Tray::SetHighlightMode(bool highlight) {
tray_icon_->SetHighlightMode(highlight);
}
void Tray::DisplayBalloon(mate::Arguments* args,
const mate::Dictionary& options) {
gfx::Image icon;
mate::Handle<NativeImage> icon;
options.Get("icon", &icon);
base::string16 title, content;
if (!options.Get("title", &title) ||
@@ -125,7 +136,14 @@ void Tray::DisplayBalloon(mate::Arguments* args,
return;
}
tray_icon_->DisplayBalloon(icon, title, content);
#if defined(OS_WIN)
tray_icon_->DisplayBalloon(
icon.IsEmpty() ? NULL : icon->GetHICON(GetSystemMetrics(SM_CXSMICON)),
title, content);
#else
tray_icon_->DisplayBalloon(
icon.IsEmpty() ? gfx::Image() : icon->image(), title, content);
#endif
}
void Tray::PopUpContextMenu(mate::Arguments* args) {
@@ -136,7 +154,8 @@ void Tray::PopUpContextMenu(mate::Arguments* args) {
tray_icon_->PopUpContextMenu(pos, menu.IsEmpty() ? nullptr : menu->model());
}
void Tray::SetContextMenu(mate::Arguments* args, Menu* menu) {
void Tray::SetContextMenu(v8::Isolate* isolate, mate::Handle<Menu> menu) {
menu_.Reset(isolate, menu.ToV8());
tray_icon_->SetContextMenu(menu->model());
}
@@ -162,7 +181,7 @@ void Tray::BuildPrototype(v8::Isolate* isolate,
.SetMethod("setHighlightMode", &Tray::SetHighlightMode)
.SetMethod("displayBalloon", &Tray::DisplayBalloon)
.SetMethod("popUpContextMenu", &Tray::PopUpContextMenu)
.SetMethod("_setContextMenu", &Tray::SetContextMenu);
.SetMethod("setContextMenu", &Tray::SetContextMenu);
}
} // namespace api

View File

@@ -11,6 +11,7 @@
#include "atom/browser/api/trackable_object.h"
#include "atom/browser/ui/tray_icon_observer.h"
#include "base/memory/scoped_ptr.h"
#include "native_mate/handle.h"
namespace gfx {
class Image;
@@ -28,18 +29,19 @@ class TrayIcon;
namespace api {
class Menu;
class NativeImage;
class Tray : public mate::TrackableObject<Tray>,
public TrayIconObserver {
public:
static mate::WrappableBase* New(
v8::Isolate* isolate, const gfx::Image& image);
v8::Isolate* isolate, mate::Handle<NativeImage> image);
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> prototype);
protected:
Tray(v8::Isolate* isolate, const gfx::Image& image);
Tray(v8::Isolate* isolate, mate::Handle<NativeImage> image);
~Tray() override;
// TrayIconObserver:
@@ -55,19 +57,20 @@ class Tray : public mate::TrackableObject<Tray>,
void OnDragExited() override;
void OnDragEnded() override;
void SetImage(mate::Arguments* args, const gfx::Image& image);
void SetPressedImage(mate::Arguments* args, const gfx::Image& image);
void SetToolTip(mate::Arguments* args, const std::string& tool_tip);
void SetTitle(mate::Arguments* args, const std::string& title);
void SetHighlightMode(mate::Arguments* args, bool highlight);
void SetImage(v8::Isolate* isolate, mate::Handle<NativeImage> image);
void SetPressedImage(v8::Isolate* isolate, mate::Handle<NativeImage> image);
void SetToolTip(const std::string& tool_tip);
void SetTitle(const std::string& title);
void SetHighlightMode(bool highlight);
void DisplayBalloon(mate::Arguments* args, const mate::Dictionary& options);
void PopUpContextMenu(mate::Arguments* args);
void SetContextMenu(mate::Arguments* args, Menu* menu);
void SetContextMenu(v8::Isolate* isolate, mate::Handle<Menu> menu);
private:
v8::Local<v8::Object> ModifiersToObject(v8::Isolate* isolate, int modifiers);
scoped_ptr<TrayIcon> tray_icon_;
v8::Global<v8::Object> menu_;
std::unique_ptr<TrayIcon> tray_icon_;
DISALLOW_COPY_AND_ASSIGN(Tray);
};

View File

@@ -14,6 +14,7 @@
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/atom_security_state_model_client.h"
#include "atom/browser/lib/bluetooth_chooser.h"
#include "atom/browser/native_window.h"
#include "atom/browser/net/atom_network_delegate.h"
#include "atom/browser/web_contents_permission_helper.h"
@@ -63,6 +64,7 @@
#include "net/url_request/static_http_user_agent_settings.h"
#include "net/url_request/url_request_context.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "third_party/WebKit/public/web/WebFindOptions.h"
#include "ui/base/l10n/l10n_util.h"
#include "atom/common/node_includes.h"
@@ -144,7 +146,7 @@ struct Converter<net::HttpResponseHeaders*> {
net::HttpResponseHeaders* headers) {
base::DictionaryValue response_headers;
if (headers) {
void* iter = nullptr;
size_t iter = 0;
std::string key;
std::string value;
while (headers->EnumerateHeaderLines(&iter, &key, &value)) {
@@ -154,7 +156,7 @@ struct Converter<net::HttpResponseHeaders*> {
if (response_headers.GetList(key, &values))
values->AppendString(value);
} else {
scoped_ptr<base::ListValue> values(new base::ListValue());
std::unique_ptr<base::ListValue> values(new base::ListValue());
values->AppendString(value);
response_headers.Set(key, std::move(values));
}
@@ -260,8 +262,9 @@ WebContents::WebContents(v8::Isolate* isolate,
content::WebContents* web_contents;
if (is_guest) {
content::SiteInstance* site_instance = content::SiteInstance::CreateForURL(
session->browser_context(), GURL("chrome-guest://fake-host"));
scoped_refptr<content::SiteInstance> site_instance =
content::SiteInstance::CreateForURL(
session->browser_context(), GURL("chrome-guest://fake-host"));
content::WebContents::CreateParams params(
session->browser_context(), site_instance);
guest_delegate_.reset(new WebViewGuestDelegate);
@@ -273,7 +276,7 @@ WebContents::WebContents(v8::Isolate* isolate,
}
Observe(web_contents);
InitWithWebContents(web_contents);
InitWithWebContents(web_contents, session->browser_context());
managed_web_contents()->GetView()->SetDelegate(this);
@@ -378,7 +381,7 @@ void WebContents::MoveContents(content::WebContents* source,
void WebContents::CloseContents(content::WebContents* source) {
Emit("close");
if (type_ == BROWSER_WINDOW)
if (type_ == BROWSER_WINDOW && owner_window())
owner_window()->CloseContents(source);
}
@@ -393,14 +396,12 @@ bool WebContents::IsPopupOrPanel(const content::WebContents* source) const {
void WebContents::HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) {
if (event.windowsKeyCode == ui::VKEY_ESCAPE && is_html_fullscreen()) {
// Escape exits tabbed fullscreen mode.
ExitFullscreenModeForTab(source);
} else if (type_ == BROWSER_WINDOW) {
owner_window()->HandleKeyboardEvent(source, event);
} else if (type_ == WEB_VIEW && guest_delegate_) {
if (type_ == WEB_VIEW && embedder_) {
// Send the unhandled keyboard events back to the embedder.
guest_delegate_->HandleKeyboardEvent(source, event);
embedder_->HandleKeyboardEvent(source, event);
} else {
// Go to the default keyboard handling.
CommonWebContentsDelegate::HandleKeyboardEvent(source, event);
}
}
@@ -429,13 +430,13 @@ void WebContents::ExitFullscreenModeForTab(content::WebContents* source) {
void WebContents::RendererUnresponsive(content::WebContents* source) {
Emit("unresponsive");
if (type_ == BROWSER_WINDOW)
if (type_ == BROWSER_WINDOW && owner_window())
owner_window()->RendererUnresponsive(source);
}
void WebContents::RendererResponsive(content::WebContents* source) {
Emit("responsive");
if (type_ == BROWSER_WINDOW)
if (type_ == BROWSER_WINDOW && owner_window())
owner_window()->RendererResponsive(source);
}
@@ -504,6 +505,14 @@ void WebContents::RequestToLockMouse(
permission_helper->RequestPointerLockPermission(user_gesture);
}
std::unique_ptr<content::BluetoothChooser> WebContents::RunBluetoothChooser(
content::RenderFrameHost* frame,
const content::BluetoothChooser::EventHandler& event_handler) {
std::unique_ptr<BluetoothChooser> bluetooth_chooser(
new BluetoothChooser(this, event_handler));
return std::move(bluetooth_chooser);
}
void WebContents::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.
@@ -655,6 +664,11 @@ void WebContents::DevToolsOpened() {
isolate(), managed_web_contents()->GetDevToolsWebContents());
devtools_web_contents_.Reset(isolate(), handle.ToV8());
// Set inspected tabID.
base::FundamentalValue tab_id(ID());
managed_web_contents()->CallClientFunction(
"DevToolsAPI.setInspectedTabId", &tab_id, nullptr, nullptr);
// Inherit owner window in devtools.
if (owner_window())
handle->SetOwnerWindow(managed_web_contents()->GetDevToolsWebContents(),
@@ -865,7 +879,7 @@ void WebContents::OpenDevTools(mate::Arguments* args) {
return;
std::string state;
if (type_ == WEB_VIEW) {
if (type_ == WEB_VIEW || !owner_window()) {
state = "detach";
} else if (args && args->Length() == 1) {
bool detach = false;
@@ -1083,9 +1097,10 @@ void WebContents::TabTraverse(bool reverse) {
web_contents()->FocusThroughTabTraversal(reverse);
}
bool WebContents::SendIPCMessage(const base::string16& channel,
bool WebContents::SendIPCMessage(bool all_frames,
const base::string16& channel,
const base::ListValue& args) {
return Send(new AtomViewMsg_Message(routing_id(), channel, args));
return Send(new AtomViewMsg_Message(routing_id(), all_frames, channel, args));
}
void WebContents::SendInputEvent(v8::Isolate* isolate,
@@ -1126,7 +1141,7 @@ void WebContents::BeginFrameSubscription(
const FrameSubscriber::FrameCaptureCallback& callback) {
const auto view = web_contents()->GetRenderWidgetHostView();
if (view) {
scoped_ptr<FrameSubscriber> frame_subscriber(new FrameSubscriber(
std::unique_ptr<FrameSubscriber> frame_subscriber(new FrameSubscriber(
isolate(), view, callback));
view->BeginFrameSubscription(std::move(frame_subscriber));
}
@@ -1173,6 +1188,10 @@ v8::Local<v8::Value> WebContents::GetOwnerBrowserWindow() {
return v8::Null(isolate());
}
int32_t WebContents::ID() const {
return weak_map_id();
}
v8::Local<v8::Value> WebContents::Session(v8::Isolate* isolate) {
return v8::Local<v8::Value>::New(isolate, session_);
}
@@ -1265,6 +1284,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
.SetMethod("_printToPDF", &WebContents::PrintToPDF)
.SetMethod("addWorkSpace", &WebContents::AddWorkSpace)
.SetMethod("removeWorkSpace", &WebContents::RemoveWorkSpace)
.SetProperty("id", &WebContents::ID)
.SetProperty("session", &WebContents::Session)
.SetProperty("hostWebContents", &WebContents::HostWebContents)
.SetProperty("devToolsWebContents", &WebContents::DevToolsWebContents)
@@ -1328,6 +1348,8 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
mate::Dictionary dict(isolate, exports);
dict.SetMethod("create", &atom::api::WebContents::Create);
dict.SetMethod("_setWrapWebContents", &atom::api::SetWrapWebContents);
dict.SetMethod("fromId",
&mate::TrackableObject<atom::api::WebContents>::FromWeakMapID);
}
} // namespace

View File

@@ -122,7 +122,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
void TabTraverse(bool reverse);
// Send messages to browser.
bool SendIPCMessage(const base::string16& channel,
bool SendIPCMessage(bool all_frames,
const base::string16& channel,
const base::ListValue& args);
// Send WebInputEvent to the page.
@@ -154,6 +155,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
v8::Local<v8::Value> GetOwnerBrowserWindow();
// Properties.
int32_t ID() const;
v8::Local<v8::Value> Session(v8::Isolate* isolate);
content::WebContents* HostWebContents();
v8::Local<v8::Value> DevToolsWebContents(v8::Isolate* isolate);
@@ -209,6 +211,9 @@ class WebContents : public mate::TrackableObject<WebContents>,
content::WebContents* web_contents,
bool user_gesture,
bool last_unlocked_by_target) override;
std::unique_ptr<content::BluetoothChooser> RunBluetoothChooser(
content::RenderFrameHost* frame,
const content::BluetoothChooser::EventHandler& handler) override;
// content::WebContentsObserver:
void BeforeUnloadFired(const base::TimeTicks& proceed_time) override;
@@ -288,7 +293,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
v8::Global<v8::Value> devtools_web_contents_;
v8::Global<v8::Value> debugger_;
scoped_ptr<WebViewGuestDelegate> guest_delegate_;
std::unique_ptr<WebViewGuestDelegate> guest_delegate_;
// The host webcontents that may contain this webcontents.
WebContents* embedder_;

View File

@@ -14,22 +14,12 @@ using atom::WebContentsPreferences;
namespace {
atom::WebViewManager* GetWebViewManager(content::WebContents* web_contents) {
auto context = web_contents->GetBrowserContext();
if (context) {
auto manager = context->GetGuestManager();
return static_cast<atom::WebViewManager*>(manager);
} else {
return nullptr;
}
}
void AddGuest(int guest_instance_id,
int element_instance_id,
content::WebContents* embedder,
content::WebContents* guest_web_contents,
const base::DictionaryValue& options) {
auto manager = GetWebViewManager(embedder);
auto manager = atom::WebViewManager::GetWebViewManager(embedder);
if (manager)
manager->AddGuest(guest_instance_id, element_instance_id, embedder,
guest_web_contents);
@@ -38,7 +28,7 @@ void AddGuest(int guest_instance_id,
}
void RemoveGuest(content::WebContents* embedder, int guest_instance_id) {
auto manager = GetWebViewManager(embedder);
auto manager = atom::WebViewManager::GetWebViewManager(embedder);
if (manager)
manager->RemoveGuest(guest_instance_id);
}

View File

@@ -21,8 +21,11 @@
#include "native_mate/dictionary.h"
#include "ui/gfx/geometry/rect.h"
#if defined(OS_WIN)
#if defined(TOOLKIT_VIEWS)
#include "atom/browser/native_window_views.h"
#endif
#if defined(OS_WIN)
#include "atom/browser/ui/win/taskbar_host.h"
#endif
@@ -99,6 +102,13 @@ Window::Window(v8::Isolate* isolate, const mate::Dictionary& options) {
window_->InitFromOptions(options);
window_->AddObserver(this);
AttachAsUserData(window_.get());
#if defined(TOOLKIT_VIEWS)
// Sets the window icon.
mate::Handle<NativeImage> icon;
if (options.Get(options::kIcon, &icon))
SetIcon(icon);
#endif
}
Window::~Window() {
@@ -371,8 +381,10 @@ std::vector<int> Window::GetMaximumSize() {
return result;
}
void Window::SetSheetOffset(double offset) {
window_->SetSheetOffset(offset);
void Window::SetSheetOffset(double offsetY, mate::Arguments* args) {
double offsetX = 0.0;
args->GetNext(&offsetX);
window_->SetSheetOffset(offsetX, offsetY);
}
void Window::SetResizable(bool resizable) {
@@ -617,6 +629,19 @@ void Window::ShowDefinitionForSelection() {
}
#endif
#if defined(TOOLKIT_VIEWS)
void Window::SetIcon(mate::Handle<NativeImage> icon) {
#if defined(OS_WIN)
static_cast<NativeWindowViews*>(window_.get())->SetIcon(
icon->GetHICON(GetSystemMetrics(SM_CXSMICON)),
icon->GetHICON(GetSystemMetrics(SM_CXICON)));
#elif defined(USE_X11)
static_cast<NativeWindowViews*>(window_.get())->SetIcon(
icon->image().AsImageSkia());
#endif
}
#endif
void Window::SetAspectRatio(double aspect_ratio, mate::Arguments* args) {
gfx::Size extra_size;
args->GetNext(&extra_size);
@@ -738,6 +763,9 @@ void Window::BuildPrototype(v8::Isolate* isolate,
#if defined(OS_MACOSX)
.SetMethod("showDefinitionForSelection",
&Window::ShowDefinitionForSelection)
#endif
#if defined(TOOLKIT_VIEWS)
.SetMethod("setIcon", &Window::SetIcon)
#endif
.SetProperty("id", &Window::ID)
.SetProperty("webContents", &Window::WebContents);

View File

@@ -14,6 +14,7 @@
#include "atom/browser/api/trackable_object.h"
#include "atom/browser/native_window.h"
#include "atom/browser/native_window_observer.h"
#include "atom/common/api/atom_api_native_image.h"
#include "native_mate/handle.h"
class GURL;
@@ -110,7 +111,7 @@ class Window : public mate::TrackableObject<Window>,
std::vector<int> GetMinimumSize();
void SetMaximumSize(int width, int height);
std::vector<int> GetMaximumSize();
void SetSheetOffset(double offset);
void SetSheetOffset(double offsetY, mate::Arguments* args);
void SetResizable(bool resizable);
bool IsResizable();
void SetMovable(bool movable);
@@ -172,6 +173,10 @@ class Window : public mate::TrackableObject<Window>,
void ShowDefinitionForSelection();
#endif
#if defined(TOOLKIT_VIEWS)
void SetIcon(mate::Handle<NativeImage> icon);
#endif
void SetVisibleOnAllWorkspaces(bool visible);
bool IsVisibleOnAllWorkspaces();
@@ -188,7 +193,7 @@ class Window : public mate::TrackableObject<Window>,
api::WebContents* api_web_contents_;
scoped_ptr<NativeWindow> window_;
std::unique_ptr<NativeWindow> window_;
DISALLOW_COPY_AND_ASSIGN(Window);
};

View File

@@ -113,7 +113,7 @@ class TrackableObject : public TrackableObjectBase,
void AfterInit(v8::Isolate* isolate) override {
if (!weak_map_) {
weak_map_.reset(new atom::KeyWeakMap<int32_t>);
weak_map_ = new atom::KeyWeakMap<int32_t>;
}
weak_map_id_ = ++next_id_;
weak_map_->Set(isolate, weak_map_id_, Wrappable<T>::GetWrapper());
@@ -123,7 +123,7 @@ class TrackableObject : public TrackableObjectBase,
private:
static int32_t next_id_;
static scoped_ptr<atom::KeyWeakMap<int32_t>> weak_map_;
static atom::KeyWeakMap<int32_t>* weak_map_; // leaked on purpose
DISALLOW_COPY_AND_ASSIGN(TrackableObject);
};
@@ -132,7 +132,7 @@ template<typename T>
int32_t TrackableObject<T>::next_id_ = 0;
template<typename T>
scoped_ptr<atom::KeyWeakMap<int32_t>> TrackableObject<T>::weak_map_;
atom::KeyWeakMap<int32_t>* TrackableObject<T>::weak_map_ = nullptr;
} // namespace mate

View File

@@ -32,18 +32,18 @@ AtomAccessTokenStore::~AtomAccessTokenStore() {
}
void AtomAccessTokenStore::LoadAccessTokens(
const LoadAccessTokensCallbackType& callback) {
AccessTokenSet access_token_set;
const LoadAccessTokensCallback& callback) {
AccessTokenMap access_token_map;
// Equivelent to access_token_set[kGeolocationProviderURL].
// Equivelent to access_token_map[kGeolocationProviderURL].
// Somehow base::string16 is causing compilation errors when used in a pair
// of std::map on Linux, this can work around it.
std::pair<GURL, base::string16> token_pair;
token_pair.first = GURL(kGeolocationProviderURL);
access_token_set.insert(token_pair);
access_token_map.insert(token_pair);
auto browser_context = AtomBrowserMainParts::Get()->browser_context();
callback.Run(access_token_set, browser_context->url_request_context_getter());
callback.Run(access_token_map, browser_context->url_request_context_getter());
}
void AtomAccessTokenStore::SaveAccessToken(const GURL& server_url,

View File

@@ -18,7 +18,7 @@ class AtomAccessTokenStore : public content::AccessTokenStore {
// content::AccessTokenStore:
void LoadAccessTokens(
const LoadAccessTokensCallbackType& callback) override;
const LoadAccessTokensCallback& callback) override;
void SaveAccessToken(const GURL& server_url,
const base::string16& access_token) override;

View File

@@ -52,6 +52,9 @@ bool g_suppress_renderer_process_restart = false;
// Custom schemes to be registered to handle service worker.
std::string g_custom_service_worker_schemes = "";
void Noop(scoped_refptr<content::SiteInstance>) {
}
} // namespace
// static
@@ -70,6 +73,17 @@ AtomBrowserClient::AtomBrowserClient() : delegate_(nullptr) {
AtomBrowserClient::~AtomBrowserClient() {
}
content::WebContents* AtomBrowserClient::GetWebContentsFromProcessID(
int process_id) {
// If the process is a pending process, we should use the old one.
if (ContainsKey(pending_processes_, process_id))
process_id = pending_processes_[process_id];
// Certain render process will be created with no associated render view,
// for example: ServiceWorker.
return WebContentsPreferences::GetWebContentsFromProcessID(process_id);
}
void AtomBrowserClient::RenderProcessWillLaunch(
content::RenderProcessHost* host) {
int process_id = host->GetID();
@@ -129,7 +143,16 @@ void AtomBrowserClient::OverrideSiteInstanceForNavigation(
if (url.SchemeIs(url::kJavaScriptScheme))
return;
*new_instance = content::SiteInstance::CreateForURL(browser_context, url);
scoped_refptr<content::SiteInstance> site_instance =
content::SiteInstance::CreateForURL(browser_context, url);
*new_instance = site_instance.get();
// Make sure the |site_instance| is not freed when this function returns.
// FIXME(zcbenz): We should adjust OverrideSiteInstanceForNavigation's
// interface to solve this.
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(&Noop, base::RetainedRef(site_instance)));
// Remember the original renderer process of the pending renderer process.
auto current_process = current_instance->GetProcess();
@@ -160,14 +183,7 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
}
#endif
// If the process is a pending process, we should use the old one.
if (ContainsKey(pending_processes_, process_id))
process_id = pending_processes_[process_id];
// Certain render process will be created with no associated render view,
// for example: ServiceWorker.
content::WebContents* web_contents =
WebContentsPreferences::GetWebContentsFromProcessID(process_id);
content::WebContents* web_contents = GetWebContentsFromProcessID(process_id);
if (!web_contents)
return;
@@ -208,7 +224,7 @@ void AtomBrowserClient::AllowCertificateError(
void AtomBrowserClient::SelectClientCertificate(
content::WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info,
scoped_ptr<content::ClientCertificateDelegate> delegate) {
std::unique_ptr<content::ClientCertificateDelegate> delegate) {
if (!cert_request_info->client_certs.empty() && delegate_) {
delegate_->SelectClientCertificate(
web_contents, cert_request_info, std::move(delegate));

View File

@@ -34,6 +34,9 @@ class AtomBrowserClient : public brightray::BrowserClient,
using Delegate = content::ContentBrowserClient;
void set_delegate(Delegate* delegate) { delegate_ = delegate; }
// Returns the WebContents for pending render processes.
content::WebContents* GetWebContentsFromProcessID(int process_id);
// Don't force renderer process to restart for once.
static void SuppressRendererProcessRestartForOnce();
@@ -73,7 +76,7 @@ class AtomBrowserClient : public brightray::BrowserClient,
void SelectClientCertificate(
content::WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info,
scoped_ptr<content::ClientCertificateDelegate> delegate) override;
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
void ResourceDispatcherHostCreated() override;
bool CanCreateWindow(const GURL& opener_url,
const GURL& opener_top_level_frame_url,
@@ -106,7 +109,7 @@ class AtomBrowserClient : public brightray::BrowserClient,
// pending_render_process => current_render_process.
std::map<int, int> pending_processes_;
scoped_ptr<AtomResourceDispatcherHostDelegate>
std::unique_ptr<AtomResourceDispatcherHostDelegate>
resource_dispatcher_host_delegate_;
Delegate* delegate_;

View File

@@ -21,7 +21,7 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/prefs/pref_registry_simple.h"
#include "components/prefs/pref_registry_simple.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/threading/sequenced_worker_pool.h"
@@ -46,7 +46,7 @@ namespace {
class NoCacheBackend : public net::HttpCache::BackendFactory {
int CreateBackend(net::NetLog* net_log,
scoped_ptr<disk_cache::Backend>* backend,
std::unique_ptr<disk_cache::Backend>* backend,
const net::CompletionCallback& callback) override {
return net::ERR_FAILED;
}
@@ -67,8 +67,7 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition,
: brightray::BrowserContext(partition, in_memory),
cert_verifier_(new AtomCertVerifier),
job_factory_(new AtomURLRequestJobFactory),
network_delegate_(new AtomNetworkDelegate),
allow_ntlm_everywhere_(false) {
network_delegate_(new AtomNetworkDelegate) {
}
AtomBrowserContext::~AtomBrowserContext() {
@@ -95,11 +94,11 @@ std::string AtomBrowserContext::GetUserAgent() {
return content::BuildUserAgentFromProduct(user_agent);
}
scoped_ptr<net::URLRequestJobFactory>
std::unique_ptr<net::URLRequestJobFactory>
AtomBrowserContext::CreateURLRequestJobFactory(
content::ProtocolHandlerMap* handlers,
content::URLRequestInterceptorScopedVector* interceptors) {
scoped_ptr<AtomURLRequestJobFactory> job_factory(job_factory_);
std::unique_ptr<AtomURLRequestJobFactory> job_factory(job_factory_);
for (auto& it : *handlers) {
job_factory->SetProtocolHandler(it.first,
@@ -134,7 +133,7 @@ AtomBrowserContext::CreateURLRequestJobFactory(
new net::FtpNetworkLayer(host_resolver))));
// Set up interceptors in the reverse order.
scoped_ptr<net::URLRequestJobFactory> top_job_factory =
std::unique_ptr<net::URLRequestJobFactory> top_job_factory =
std::move(job_factory);
content::URLRequestInterceptorScopedVector::reverse_iterator it;
for (it = interceptors->rbegin(); it != interceptors->rend(); ++it)
@@ -177,7 +176,7 @@ content::PermissionManager* AtomBrowserContext::GetPermissionManager() {
return permission_manager_.get();
}
scoped_ptr<net::CertVerifier> AtomBrowserContext::CreateCertVerifier() {
std::unique_ptr<net::CertVerifier> AtomBrowserContext::CreateCertVerifier() {
return make_scoped_ptr(cert_verifier_);
}
@@ -195,16 +194,6 @@ void AtomBrowserContext::RegisterPrefs(PrefRegistrySimple* pref_registry) {
pref_registry->RegisterDictionaryPref(prefs::kDevToolsFileSystemPaths);
}
bool AtomBrowserContext::AllowNTLMCredentialsForDomain(const GURL& origin) {
if (allow_ntlm_everywhere_)
return true;
return Delegate::AllowNTLMCredentialsForDomain(origin);
}
void AtomBrowserContext::AllowNTLMCredentialsForAllDomains(bool should_allow) {
allow_ntlm_everywhere_ = should_allow;
}
} // namespace atom
namespace brightray {

View File

@@ -26,14 +26,13 @@ class AtomBrowserContext : public brightray::BrowserContext {
// brightray::URLRequestContextGetter::Delegate:
net::NetworkDelegate* CreateNetworkDelegate() override;
std::string GetUserAgent() override;
scoped_ptr<net::URLRequestJobFactory> CreateURLRequestJobFactory(
std::unique_ptr<net::URLRequestJobFactory> CreateURLRequestJobFactory(
content::ProtocolHandlerMap* handlers,
content::URLRequestInterceptorScopedVector* interceptors) override;
net::HttpCache::BackendFactory* CreateHttpCacheBackendFactory(
const base::FilePath& base_path) override;
scoped_ptr<net::CertVerifier> CreateCertVerifier() override;
std::unique_ptr<net::CertVerifier> CreateCertVerifier() override;
net::SSLConfigService* CreateSSLConfigService() override;
bool AllowNTLMCredentialsForDomain(const GURL& auth_origin) override;
// content::BrowserContext:
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
@@ -43,8 +42,6 @@ class AtomBrowserContext : public brightray::BrowserContext {
// brightray::BrowserContext:
void RegisterPrefs(PrefRegistrySimple* pref_registry) override;
void AllowNTLMCredentialsForAllDomains(bool should_allow);
AtomCertVerifier* cert_verifier() const { return cert_verifier_; }
AtomURLRequestJobFactory* job_factory() const { return job_factory_; }
@@ -52,17 +49,15 @@ class AtomBrowserContext : public brightray::BrowserContext {
AtomNetworkDelegate* network_delegate() const { return network_delegate_; }
private:
scoped_ptr<AtomDownloadManagerDelegate> download_manager_delegate_;
scoped_ptr<WebViewManager> guest_manager_;
scoped_ptr<AtomPermissionManager> permission_manager_;
std::unique_ptr<AtomDownloadManagerDelegate> download_manager_delegate_;
std::unique_ptr<WebViewManager> guest_manager_;
std::unique_ptr<AtomPermissionManager> permission_manager_;
// Managed by brightray::BrowserContext.
AtomCertVerifier* cert_verifier_;
AtomURLRequestJobFactory* job_factory_;
AtomNetworkDelegate* network_delegate_;
bool allow_ntlm_everywhere_;
DISALLOW_COPY_AND_ASSIGN(AtomBrowserContext);
};

View File

@@ -68,7 +68,7 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
#endif
// A fake BrowserProcess object that used to feed the source code from chrome.
scoped_ptr<BrowserProcess> fake_browser_process_;
std::unique_ptr<BrowserProcess> fake_browser_process_;
// The gin::PerIsolateData requires a task runner to create, so we feed it
// with a task runner that will post all work to main loop.
@@ -77,11 +77,11 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
// Pointer to exit code.
int* exit_code_;
scoped_ptr<Browser> browser_;
scoped_ptr<JavascriptEnvironment> js_env_;
scoped_ptr<NodeBindings> node_bindings_;
scoped_ptr<AtomBindings> atom_bindings_;
scoped_ptr<NodeDebugger> node_debugger_;
std::unique_ptr<Browser> browser_;
std::unique_ptr<JavascriptEnvironment> js_env_;
std::unique_ptr<NodeBindings> node_bindings_;
std::unique_ptr<AtomBindings> atom_bindings_;
std::unique_ptr<NodeDebugger> node_debugger_;
base::Timer gc_timer_;

View File

@@ -12,7 +12,7 @@
#include "atom/browser/ui/file_dialog.h"
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/prefs/pref_service.h"
#include "components/prefs/pref_service.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
@@ -77,7 +77,8 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated(
window = relay->window.get();
base::FilePath path;
if (file_dialog::ShowSaveDialog(window, item->GetURL().spec(), default_path,
if (file_dialog::ShowSaveDialog(window, item->GetURL().spec(),
"", default_path,
file_dialog::Filters(), &path)) {
// Remember the last selected download directory.
AtomBrowserContext* browser_context = static_cast<AtomBrowserContext*>(

View File

@@ -13,7 +13,6 @@ namespace atom {
void AtomJavaScriptDialogManager::RunJavaScriptDialog(
content::WebContents* web_contents,
const GURL& origin_url,
const std::string& accept_lang,
content::JavaScriptMessageType javascript_message_type,
const base::string16& message_text,
const base::string16& default_prompt_text,
@@ -24,12 +23,10 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
void AtomJavaScriptDialogManager::RunBeforeUnloadDialog(
content::WebContents* web_contents,
const base::string16& message_text,
bool is_reload,
const DialogClosedCallback& callback) {
bool prevent_reload = message_text.empty() ||
message_text == base::ASCIIToUTF16("false");
callback.Run(!prevent_reload, message_text);
// FIXME(zcbenz): the |message_text| is removed, figure out what should we do.
callback.Run(false, base::ASCIIToUTF16("This should not be displayed"));
}
} // namespace atom

View File

@@ -17,7 +17,6 @@ class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager {
void RunJavaScriptDialog(
content::WebContents* web_contents,
const GURL& origin_url,
const std::string& accept_lang,
content::JavaScriptMessageType javascript_message_type,
const base::string16& message_text,
const base::string16& default_prompt_text,
@@ -25,7 +24,6 @@ class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager {
bool* did_suppress_message) override;
void RunBeforeUnloadDialog(
content::WebContents* web_contents,
const base::string16& message_text,
bool is_reload,
const DialogClosedCallback& callback) override;
void CancelActiveAndPendingDialogs(

View File

@@ -40,7 +40,7 @@ void AtomPermissionManager::SetPermissionRequestHandler(
if (handler.is_null() && !pending_requests_.empty()) {
for (const auto& request : pending_requests_) {
if (!WebContentsDestroyed(request.second.render_process_id))
request.second.callback.Run(content::PERMISSION_STATUS_DENIED);
request.second.callback.Run(blink::mojom::PermissionStatus::DENIED);
}
pending_requests_.clear();
}
@@ -51,7 +51,6 @@ int AtomPermissionManager::RequestPermission(
content::PermissionType permission,
content::RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
bool user_gesture,
const ResponseCallback& response_callback) {
int process_id = render_frame_host->GetProcess()->GetID();
@@ -74,7 +73,7 @@ int AtomPermissionManager::RequestPermission(
return request_id_;
}
response_callback.Run(content::PERMISSION_STATUS_GRANTED);
response_callback.Run(blink::mojom::PermissionStatus::GRANTED);
return kNoPendingOperation;
}
@@ -82,17 +81,16 @@ int AtomPermissionManager::RequestPermissions(
const std::vector<content::PermissionType>& permissions,
content::RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
bool user_gesture,
const base::Callback<void(
const std::vector<content::PermissionStatus>&)>& callback) {
const std::vector<blink::mojom::PermissionStatus>&)>& callback) {
// FIXME(zcbenz): Just ignore multiple permissions request for now.
std::vector<content::PermissionStatus> permissionStatuses;
std::vector<blink::mojom::PermissionStatus> permissionStatuses;
for (auto permission : permissions) {
if (permission == content::PermissionType::MIDI_SYSEX) {
content::ChildProcessSecurityPolicy::GetInstance()->
GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
}
permissionStatuses.push_back(content::PERMISSION_STATUS_GRANTED);
permissionStatuses.push_back(blink::mojom::PermissionStatus::GRANTED);
}
callback.Run(permissionStatuses);
return kNoPendingOperation;
@@ -102,7 +100,7 @@ void AtomPermissionManager::OnPermissionResponse(
int request_id,
const GURL& origin,
const ResponseCallback& callback,
content::PermissionStatus status) {
blink::mojom::PermissionStatus status) {
auto request = pending_requests_.find(request_id);
if (request != pending_requests_.end()) {
if (!WebContentsDestroyed(request->second.render_process_id))
@@ -115,7 +113,7 @@ void AtomPermissionManager::CancelPermissionRequest(int request_id) {
auto request = pending_requests_.find(request_id);
if (request != pending_requests_.end()) {
if (!WebContentsDestroyed(request->second.render_process_id))
request->second.callback.Run(content::PERMISSION_STATUS_DENIED);
request->second.callback.Run(blink::mojom::PermissionStatus::DENIED);
pending_requests_.erase(request);
}
}
@@ -126,11 +124,11 @@ void AtomPermissionManager::ResetPermission(
const GURL& embedding_origin) {
}
content::PermissionStatus AtomPermissionManager::GetPermissionStatus(
blink::mojom::PermissionStatus AtomPermissionManager::GetPermissionStatus(
content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) {
return content::PERMISSION_STATUS_GRANTED;
return blink::mojom::PermissionStatus::GRANTED;
}
void AtomPermissionManager::RegisterPermissionUsage(

View File

@@ -23,7 +23,7 @@ class AtomPermissionManager : public content::PermissionManager {
~AtomPermissionManager() override;
using ResponseCallback =
base::Callback<void(content::PermissionStatus)>;
base::Callback<void(blink::mojom::PermissionStatus)>;
using RequestHandler =
base::Callback<void(content::WebContents*,
content::PermissionType,
@@ -37,28 +37,26 @@ class AtomPermissionManager : public content::PermissionManager {
content::PermissionType permission,
content::RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
bool user_gesture,
const ResponseCallback& callback) override;
int RequestPermissions(
const std::vector<content::PermissionType>& permissions,
content::RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
bool user_gesture,
const base::Callback<void(
const std::vector<content::PermissionStatus>&)>& callback) override;
const std::vector<blink::mojom::PermissionStatus>&)>& callback) override;
protected:
void OnPermissionResponse(int request_id,
const GURL& url,
const ResponseCallback& callback,
content::PermissionStatus status);
blink::mojom::PermissionStatus status);
// content::PermissionManager:
void CancelPermissionRequest(int request_id) override;
void ResetPermission(content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) override;
content::PermissionStatus GetPermissionStatus(
blink::mojom::PermissionStatus GetPermissionStatus(
content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) override;
@@ -69,7 +67,8 @@ class AtomPermissionManager : public content::PermissionManager {
content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin,
const base::Callback<void(content::PermissionStatus)>& callback) override;
const base::Callback<void(blink::mojom::PermissionStatus)>& callback)
override;
void UnsubscribePermissionStatusChange(int subscription_id) override;
private:

View File

@@ -32,7 +32,7 @@ class AtomSecurityStateModelClient
friend class content::WebContentsUserData<AtomSecurityStateModelClient>;
content::WebContents* web_contents_;
scoped_ptr<security_state::SecurityStateModel> security_state_model_;
std::unique_ptr<security_state::SecurityStateModel> security_state_model_;
DISALLOW_COPY_AND_ASSIGN(AtomSecurityStateModelClient);
};

View File

@@ -14,6 +14,7 @@
#include "base/strings/string16.h"
#include "atom/browser/browser_observer.h"
#include "atom/browser/window_list_observer.h"
#include "native_mate/arguments.h"
#if defined(OS_WIN)
#include "base/files/file_path.h"
@@ -94,7 +95,8 @@ class Browser : public WindowListObserver {
// Creates an activity and sets it as the one currently in use.
void SetUserActivity(const std::string& type,
const base::DictionaryValue& user_info);
const base::DictionaryValue& user_info,
mate::Arguments* args);
// Returns the type name of the current user activity.
std::string GetCurrentActivityType();

View File

@@ -13,6 +13,8 @@
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#include "brightray/common/application_info.h"
#include "net/base/mac/url_conversions.h"
#include "url/gurl.h"
namespace atom {
@@ -112,12 +114,16 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol) {
void Browser::SetAppUserModelID(const base::string16& name) {
}
void Browser::SetUserActivity(
const std::string& type,
const base::DictionaryValue& user_info) {
void Browser::SetUserActivity(const std::string& type,
const base::DictionaryValue& user_info,
mate::Arguments* args) {
std::string url_string;
args->GetNext(&url_string);
[[AtomApplication sharedApplication]
setCurrentActivity:base::SysUTF8ToNSString(type)
withUserInfo:DictionaryValueToNSDictionary(user_info)];
withUserInfo:DictionaryValueToNSDictionary(user_info)
withWebpageURL:net::NSURLWithGURL(GURL(url_string))];
}
std::string Browser::GetCurrentActivityType() {
@@ -126,9 +132,8 @@ std::string Browser::GetCurrentActivityType() {
return base::SysNSStringToUTF8(userActivity.activityType);
}
bool Browser::ContinueUserActivity(
const std::string& type,
const base::DictionaryValue& user_info) {
bool Browser::ContinueUserActivity(const std::string& type,
const base::DictionaryValue& user_info) {
bool prevent_default = false;
FOR_EACH_OBSERVER(BrowserObserver,
observers_,

View File

@@ -281,7 +281,7 @@ PCWSTR Browser::GetAppUserModelID() {
std::string Browser::GetExecutableFileVersion() const {
base::FilePath path;
if (PathService::Get(base::FILE_EXE, &path)) {
scoped_ptr<FileVersionInfo> version_info(
std::unique_ptr<FileVersionInfo> version_info(
FileVersionInfo::CreateFileVersionInfo(path));
return base::UTF16ToUTF8(version_info->product_version());
}
@@ -292,7 +292,7 @@ std::string Browser::GetExecutableFileVersion() const {
std::string Browser::GetExecutableFileProductName() const {
base::FilePath path;
if (PathService::Get(base::FILE_EXE, &path)) {
scoped_ptr<FileVersionInfo> version_info(
std::unique_ptr<FileVersionInfo> version_info(
FileVersionInfo::CreateFileVersionInfo(path));
return base::UTF16ToUTF8(version_info->product_name());
}

View File

@@ -16,8 +16,8 @@
#include "atom/browser/web_dialog_helper.h"
#include "atom/common/atom_constants.h"
#include "base/files/file_util.h"
#include "base/prefs/pref_service.h"
#include "base/prefs/scoped_user_pref_update.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "chrome/browser/printing/print_preview_message_handler.h"
#include "chrome/browser/printing/print_view_manager_basic.h"
#include "chrome/browser/ui/browser_dialogs.h"
@@ -31,14 +31,6 @@
#include "content/public/browser/security_style_explanations.h"
#include "storage/browser/fileapi/isolated_context.h"
#if defined(TOOLKIT_VIEWS)
#include "atom/browser/native_window_views.h"
#endif
#if defined(USE_X11)
#include "atom/browser/browser.h"
#endif
using content::BrowserThread;
using security_state::SecurityStateModel;
@@ -182,7 +174,9 @@ CommonWebContentsDelegate::~CommonWebContentsDelegate() {
}
void CommonWebContentsDelegate::InitWithWebContents(
content::WebContents* web_contents) {
content::WebContents* web_contents,
AtomBrowserContext* browser_context) {
browser_context_ = browser_context;
web_contents->SetDelegate(this);
printing::PrintViewManagerBasic::CreateForWebContents(web_contents);
@@ -389,7 +383,7 @@ void CommonWebContentsDelegate::DevToolsSaveToFile(
} else {
file_dialog::Filters filters;
base::FilePath default_path(base::FilePath::FromUTF8Unsafe(url));
if (!file_dialog::ShowSaveDialog(owner_window(), url, default_path,
if (!file_dialog::ShowSaveDialog(owner_window(), url, "", default_path,
filters, &path)) {
base::StringValue url_value(url);
web_contents_->CallClientFunction(
@@ -455,7 +449,7 @@ void CommonWebContentsDelegate::DevToolsAddFileSystem(
base::FilePath default_path;
std::vector<base::FilePath> paths;
int flag = file_dialog::FILE_DIALOG_OPEN_DIRECTORY;
if (!file_dialog::ShowOpenDialog(owner_window(), "", default_path,
if (!file_dialog::ShowOpenDialog(owner_window(), "", "", default_path,
filters, flag, &paths))
return;
@@ -470,7 +464,7 @@ void CommonWebContentsDelegate::DevToolsAddFileSystem(
FileSystem file_system = CreateFileSystemStruct(GetDevToolsWebContents(),
file_system_id,
path.AsUTF8Unsafe());
scoped_ptr<base::DictionaryValue> file_system_value(
std::unique_ptr<base::DictionaryValue> file_system_value(
CreateFileSystemValue(file_system));
auto pref_service = GetPrefService(GetDevToolsWebContents());
@@ -628,23 +622,6 @@ void CommonWebContentsDelegate::OnDevToolsSearchCompleted(
&file_paths_value);
}
#if defined(TOOLKIT_VIEWS)
gfx::ImageSkia CommonWebContentsDelegate::GetDevToolsWindowIcon() {
if (!owner_window())
return gfx::ImageSkia();
return static_cast<views::WidgetDelegate*>(static_cast<NativeWindowViews*>(
owner_window()))->GetWindowAppIcon();
}
#endif
#if defined(USE_X11)
void CommonWebContentsDelegate::GetDevToolsWindowWMClass(
std::string* name, std::string* class_name) {
*class_name = Browser::Get()->GetName();
*name = base::ToLowerASCII(*class_name);
}
#endif
void CommonWebContentsDelegate::SetHtmlApiFullscreen(bool enter_fullscreen) {
// Window is already in fullscreen mode, save the state.
if (enter_fullscreen && owner_window_->IsFullscreen()) {

View File

@@ -19,6 +19,7 @@ using brightray::DevToolsFileSystemIndexer;
namespace atom {
class AtomBrowserContext;
class AtomJavaScriptDialogManager;
class NativeWindow;
class WebDialogHelper;
@@ -33,7 +34,8 @@ class CommonWebContentsDelegate
// Creates a InspectableWebContents object and takes onwership of
// |web_contents|.
void InitWithWebContents(content::WebContents* web_contents);
void InitWithWebContents(content::WebContents* web_contents,
AtomBrowserContext* browser_context);
// Set the window as owner window.
void SetOwnerWindow(NativeWindow* owner_window);
@@ -82,6 +84,9 @@ class CommonWebContentsDelegate
content::SecurityStyle GetSecurityStyle(
content::WebContents* web_contents,
content::SecurityStyleExplanations* explanations) override;
void HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) override;
// brightray::InspectableWebContentsDelegate:
void DevToolsSaveToFile(const std::string& url,
@@ -141,15 +146,18 @@ class CommonWebContentsDelegate
// Whether window is fullscreened by window api.
bool native_fullscreen_;
scoped_ptr<WebDialogHelper> web_dialog_helper_;
scoped_ptr<AtomJavaScriptDialogManager> dialog_manager_;
std::unique_ptr<WebDialogHelper> web_dialog_helper_;
std::unique_ptr<AtomJavaScriptDialogManager> dialog_manager_;
scoped_refptr<DevToolsFileSystemIndexer> devtools_file_system_indexer_;
// Make sure BrowserContext is alwasys destroyed after WebContents.
scoped_refptr<AtomBrowserContext> browser_context_;
// The stored InspectableWebContents object.
// Notice that web_contents_ must be placed after dialog_manager_, so we can
// make sure web_contents_ is destroyed before dialog_manager_, otherwise a
// crash would happen.
scoped_ptr<brightray::InspectableWebContents> web_contents_;
std::unique_ptr<brightray::InspectableWebContents> web_contents_;
// Maps url to file path, used by the file requests sent from devtools.
typedef std::map<std::string, base::FilePath> PathsMap;

View File

@@ -0,0 +1,39 @@
// Copyright (c) 2016 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/browser/common_web_contents_delegate.h"
#import <Cocoa/Cocoa.h>
#include "content/public/browser/native_web_keyboard_event.h"
#include "ui/events/keycodes/keyboard_codes.h"
namespace atom {
void CommonWebContentsDelegate::HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) {
if (event.skip_in_browser ||
event.type == content::NativeWebKeyboardEvent::Char)
return;
// Escape exits tabbed fullscreen mode.
if (event.windowsKeyCode == ui::VKEY_ESCAPE && is_html_fullscreen())
ExitFullscreenModeForTab(source);
BOOL handled = [[NSApp mainMenu] performKeyEquivalent:event.os_event];
if (!handled && event.os_event.window) {
// Handle the cmd+~ shortcut.
if ((event.os_event.modifierFlags & NSCommandKeyMask) /* cmd */ &&
(event.os_event.keyCode == 50 /* ~ */)) {
if (event.os_event.modifierFlags & NSShiftKeyMask) {
[NSApp sendAction:@selector(_cycleWindowsReversed:) to:nil from:nil];
} else {
[NSApp sendAction:@selector(_cycleWindows:) to:nil from:nil];
}
}
}
}
} // namespace atom

View File

@@ -0,0 +1,45 @@
// Copyright (c) 2016 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/browser/common_web_contents_delegate.h"
#include "atom/browser/native_window_views.h"
#include "base/strings/string_util.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "ui/events/keycodes/keyboard_codes.h"
#if defined(USE_X11)
#include "atom/browser/browser.h"
#endif
namespace atom {
void CommonWebContentsDelegate::HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) {
// Escape exits tabbed fullscreen mode.
if (event.windowsKeyCode == ui::VKEY_ESCAPE && is_html_fullscreen())
ExitFullscreenModeForTab(source);
// Let the NativeWindow handle other parts.
if (owner_window())
owner_window()->HandleKeyboardEvent(source, event);
}
gfx::ImageSkia CommonWebContentsDelegate::GetDevToolsWindowIcon() {
if (!owner_window())
return gfx::ImageSkia();
return static_cast<views::WidgetDelegate*>(static_cast<NativeWindowViews*>(
owner_window()))->GetWindowAppIcon();
}
#if defined(USE_X11)
void CommonWebContentsDelegate::GetDevToolsWindowWMClass(
std::string* name, std::string* class_name) {
*class_name = Browser::Get()->GetName();
*name = base::ToLowerASCII(*class_name);
}
#endif
} // namespace atom

View File

@@ -0,0 +1,107 @@
// Copyright (c) 2016 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/browser/lib/bluetooth_chooser.h"
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "native_mate/dictionary.h"
namespace mate {
template<>
struct Converter<atom::BluetoothChooser::DeviceInfo> {
static v8::Local<v8::Value> ToV8(
v8::Isolate* isolate, const atom::BluetoothChooser::DeviceInfo& val) {
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
dict.Set("deviceName", val.device_name);
dict.Set("deviceId", val.device_id);
return mate::ConvertToV8(isolate, dict);
}
};
} // namespace mate
namespace atom {
namespace {
const int kMaxScanRetries = 5;
void OnDeviceChosen(
const content::BluetoothChooser::EventHandler& handler,
const std::string& device_id) {
if (device_id.empty()) {
handler.Run(content::BluetoothChooser::Event::CANCELLED, device_id);
} else {
handler.Run(content::BluetoothChooser::Event::SELECTED, device_id);
}
}
} // namespace
BluetoothChooser::BluetoothChooser(
api::WebContents* contents,
const EventHandler& event_handler)
: api_web_contents_(contents),
event_handler_(event_handler),
num_retries_(0) {
}
BluetoothChooser::~BluetoothChooser() {
}
void BluetoothChooser::SetAdapterPresence(AdapterPresence presence) {
switch (presence) {
case AdapterPresence::ABSENT:
case AdapterPresence::POWERED_OFF:
event_handler_.Run(Event::CANCELLED, "");
break;
case AdapterPresence::POWERED_ON:
break;
}
}
void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) {
switch (state) {
case DiscoveryState::FAILED_TO_START:
event_handler_.Run(Event::CANCELLED, "");
break;
case DiscoveryState::IDLE:
if (device_list_.empty()) {
auto event = ++num_retries_ > kMaxScanRetries ? Event::CANCELLED
: Event::RESCAN;
event_handler_.Run(event, "");
} else {
bool prevent_default =
api_web_contents_->Emit("select-bluetooth-device",
device_list_,
base::Bind(&OnDeviceChosen,
event_handler_));
if (!prevent_default) {
auto device_id = device_list_[0].device_id;
event_handler_.Run(Event::SELECTED, device_id);
}
}
break;
case DiscoveryState::DISCOVERING:
break;
}
}
void BluetoothChooser::AddDevice(const std::string& device_id,
const base::string16& device_name) {
DeviceInfo info = {device_id, device_name};
device_list_.push_back(info);
}
void BluetoothChooser::RemoveDevice(const std::string& device_id) {
for (auto it = device_list_.begin(); it != device_list_.end(); ++it) {
if (it->device_id == device_id) {
device_list_.erase(it);
return;
}
}
}
} // namespace atom

View File

@@ -0,0 +1,45 @@
// Copyright (c) 2016 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
#define ATOM_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
#include <string>
#include <vector>
#include "atom/browser/api/atom_api_web_contents.h"
#include "content/public/browser/bluetooth_chooser.h"
namespace atom {
class BluetoothChooser : public content::BluetoothChooser {
public:
struct DeviceInfo {
std::string device_id;
base::string16 device_name;
};
explicit BluetoothChooser(api::WebContents* contents,
const EventHandler& handler);
~BluetoothChooser() override;
// content::BluetoothChooser:
void SetAdapterPresence(AdapterPresence presence) override;
void ShowDiscoveryState(DiscoveryState state) override;
void AddDevice(const std::string& device_id,
const base::string16& device_name) override;
void RemoveDevice(const std::string& device_id) override;
private:
std::vector<DeviceInfo> device_list_;
api::WebContents* api_web_contents_;
EventHandler event_handler_;
int num_retries_;
DISALLOW_COPY_AND_ASSIGN(BluetoothChooser);
};
} // namespace atom
#endif // ATOM_BROWSER_LIB_BLUETOOTH_CHOOSER_H_

View File

@@ -37,10 +37,11 @@ LoginHandler::LoginHandler(net::AuthChallengeInfo* auth_info,
render_frame_id_(0) {
content::ResourceRequestInfo::ForRequest(request_)->GetAssociatedRenderFrame(
&render_process_host_id_, &render_frame_id_);
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&Browser::RequestLogin,
base::Unretained(Browser::Get()),
make_scoped_refptr(this)));
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&Browser::RequestLogin,
base::Unretained(Browser::Get()),
base::RetainedRef(make_scoped_refptr(this))));
}
LoginHandler::~LoginHandler() {

View File

@@ -21,6 +21,8 @@
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent;
- (NSUserActivity*)getCurrentActivity;
- (void)setCurrentActivity:(NSString*)type withUserInfo:(NSDictionary*)userInfo;
- (void)setCurrentActivity:(NSString*)type
withUserInfo:(NSDictionary*)userInfo
withWebpageURL:(NSURL*)webpageURL;
@end

View File

@@ -29,10 +29,12 @@
}
- (void)setCurrentActivity:(NSString*)type
withUserInfo:(NSDictionary*)userInfo {
withUserInfo:(NSDictionary*)userInfo
withWebpageURL:(NSURL*)webpageURL {
currentActivity_ = base::scoped_nsobject<NSUserActivity>(
[[NSUserActivity alloc] initWithActivityType:type]);
[currentActivity_ setUserInfo:userInfo];
[currentActivity_ setWebpageURL:webpageURL];
[currentActivity_ becomeCurrent];
}

View File

@@ -65,7 +65,7 @@
continueUserActivity:(NSUserActivity*)userActivity
restorationHandler:(void (^)(NSArray*restorableObjects))restorationHandler {
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
scoped_ptr<base::DictionaryValue> user_info =
std::unique_ptr<base::DictionaryValue> user_info =
atom::NSDictionaryToDictionaryValue(userActivity.userInfo);
if (!user_info)
return NO;

View File

@@ -18,7 +18,7 @@ namespace atom {
NSDictionary* DictionaryValueToNSDictionary(const base::DictionaryValue& value);
scoped_ptr<base::DictionaryValue> NSDictionaryToDictionaryValue(
std::unique_ptr<base::DictionaryValue> NSDictionaryToDictionaryValue(
NSDictionary* dict);
} // namespace atom

View File

@@ -4,13 +4,55 @@
#include "atom/browser/mac/dict_util.h"
#include "base/mac/scoped_nsobject.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/strings/sys_string_conversions.h"
#include "base/values.h"
namespace atom {
namespace {
std::unique_ptr<base::ListValue> NSArrayToListValue(NSArray* arr) {
if (!arr)
return nullptr;
std::unique_ptr<base::ListValue> result(new base::ListValue);
for (id value in arr) {
if ([value isKindOfClass:[NSString class]]) {
result->AppendString(base::SysNSStringToUTF8(value));
} else if ([value isKindOfClass:[NSNumber class]]) {
const char* objc_type = [value objCType];
if (strcmp(objc_type, @encode(BOOL)) == 0 ||
strcmp(objc_type, @encode(char)) == 0)
result->AppendBoolean([value boolValue]);
else if (strcmp(objc_type, @encode(double)) == 0 ||
strcmp(objc_type, @encode(float)) == 0)
result->AppendDouble([value doubleValue]);
else
result->AppendInteger([value intValue]);
} else if ([value isKindOfClass:[NSArray class]]) {
std::unique_ptr<base::ListValue> sub_arr = NSArrayToListValue(value);
if (sub_arr)
result->Append(std::move(sub_arr));
else
result->Append(base::Value::CreateNullValue());
} else if ([value isKindOfClass:[NSDictionary class]]) {
std::unique_ptr<base::DictionaryValue> sub_dict =
NSDictionaryToDictionaryValue(value);
if (sub_dict)
result->Append(std::move(sub_dict));
else
result->Append(base::Value::CreateNullValue());
} else {
result->AppendString(base::SysNSStringToUTF8([value description]));
}
}
return result;
}
} // namespace
NSDictionary* DictionaryValueToNSDictionary(const base::DictionaryValue& value) {
std::string json;
if (!base::JSONWriter::Write(value, &json))
@@ -24,19 +66,53 @@ NSDictionary* DictionaryValueToNSDictionary(const base::DictionaryValue& value)
return obj;
}
scoped_ptr<base::DictionaryValue> NSDictionaryToDictionaryValue(
std::unique_ptr<base::DictionaryValue> NSDictionaryToDictionaryValue(
NSDictionary* dict) {
NSData* data = [NSJSONSerialization dataWithJSONObject:dict
options:0
error:nil];
if (!data)
if (!dict)
return nullptr;
base::scoped_nsobject<NSString> json =
[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
scoped_ptr<base::Value> value =
base::JSONReader::Read([json UTF8String]);
return base::DictionaryValue::From(std::move(value));
std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue);
for (id key in dict) {
std::string str_key = base::SysNSStringToUTF8(
[key isKindOfClass:[NSString class]] ? key : [key description]);
id value = [dict objectForKey:key];
if ([value isKindOfClass:[NSString class]]) {
result->SetStringWithoutPathExpansion(
str_key, base::SysNSStringToUTF8(value));
} else if ([value isKindOfClass:[NSNumber class]]) {
const char* objc_type = [value objCType];
if (strcmp(objc_type, @encode(BOOL)) == 0 ||
strcmp(objc_type, @encode(char)) == 0)
result->SetBooleanWithoutPathExpansion(str_key, [value boolValue]);
else if (strcmp(objc_type, @encode(double)) == 0 ||
strcmp(objc_type, @encode(float)) == 0)
result->SetDoubleWithoutPathExpansion(str_key, [value doubleValue]);
else
result->SetIntegerWithoutPathExpansion(str_key, [value intValue]);
} else if ([value isKindOfClass:[NSArray class]]) {
std::unique_ptr<base::ListValue> sub_arr = NSArrayToListValue(value);
if (sub_arr)
result->SetWithoutPathExpansion(str_key, std::move(sub_arr));
else
result->SetWithoutPathExpansion(str_key,
base::Value::CreateNullValue());
} else if ([value isKindOfClass:[NSDictionary class]]) {
std::unique_ptr<base::DictionaryValue> sub_dict =
NSDictionaryToDictionaryValue(value);
if (sub_dict)
result->SetWithoutPathExpansion(str_key, std::move(sub_dict));
else
result->SetWithoutPathExpansion(str_key,
base::Value::CreateNullValue());
} else {
result->SetStringWithoutPathExpansion(
str_key,
base::SysNSStringToUTF8([value description]));
}
}
return result;
}
} // namespace atom

View File

@@ -12,12 +12,11 @@
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/window_list.h"
#include "atom/common/api/api_messages.h"
#include "atom/common/native_mate_converters/image_converter.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "atom/common/options_switches.h"
#include "base/files/file_util.h"
#include "base/json/json_writer.h"
#include "base/prefs/pref_service.h"
#include "components/prefs/pref_service.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "brightray/browser/inspectable_web_contents.h"
@@ -49,12 +48,12 @@ NativeWindow::NativeWindow(
const mate::Dictionary& options)
: content::WebContentsObserver(inspectable_web_contents->GetWebContents()),
has_frame_(true),
force_using_draggable_region_(false),
transparent_(false),
enable_larger_than_screen_(false),
is_closed_(false),
has_dialog_attached_(false),
sheet_offset_(0.0),
sheet_offset_x_(0.0),
sheet_offset_y_(0.0),
aspect_ratio_(0.0),
inspectable_web_contents_(inspectable_web_contents),
weak_factory_(this) {
@@ -66,9 +65,6 @@ NativeWindow::NativeWindow(
// mode.
ui::GpuSwitchingManager::SetTransparent(transparent_);
// Read icon before window is created.
options.Get(options::kIcon, &icon_);
WindowList::AddWindow(this);
}
@@ -141,11 +137,14 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) {
if (options.Get(options::kAlwaysOnTop, &top) && top) {
SetAlwaysOnTop(true);
}
// Disable fullscreen button if 'fullscreen' is specified to false.
bool fullscreenable = true;
bool fullscreen = false;
if (options.Get(options::kFullscreen, &fullscreen) && !fullscreen)
if (options.Get(options::kFullscreen, &fullscreen) && !fullscreen) {
// Disable fullscreen button if 'fullscreen' is specified to false.
#if defined(OS_MACOSX)
fullscreenable = false;
#endif
}
// Overriden by 'fullscreenable'.
options.Get(options::kFullScreenable, &fullscreenable);
SetFullScreenable(fullscreenable);
@@ -255,12 +254,17 @@ gfx::Size NativeWindow::GetMaximumSize() {
return GetSizeConstraints().GetMaximumSize();
}
void NativeWindow::SetSheetOffset(const double offset) {
sheet_offset_ = offset;
void NativeWindow::SetSheetOffset(const double offsetX, const double offsetY) {
sheet_offset_x_ = offsetX;
sheet_offset_y_ = offsetY;
}
double NativeWindow::GetSheetOffset() {
return sheet_offset_;
double NativeWindow::GetSheetOffsetX() {
return sheet_offset_x_;
}
double NativeWindow::GetSheetOffsetY() {
return sheet_offset_y_;
}
void NativeWindow::SetRepresentedFilename(const std::string& filename) {
@@ -318,9 +322,9 @@ void NativeWindow::CapturePage(const gfx::Rect& rect,
// current system, increase the requested bitmap size to capture it all.
gfx::Size bitmap_size = view_size;
const gfx::NativeView native_view = view->GetNativeView();
gfx::Screen* const screen = gfx::Screen::GetScreenFor(native_view);
const float scale =
screen->GetDisplayNearestWindow(native_view).device_scale_factor();
gfx::Screen::GetScreen()->GetDisplayNearestWindow(native_view)
.device_scale_factor();
if (scale > 1.0f)
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
@@ -526,9 +530,9 @@ void NativeWindow::NotifyWindowMessage(
}
#endif
scoped_ptr<SkRegion> NativeWindow::DraggableRegionsToSkRegion(
std::unique_ptr<SkRegion> NativeWindow::DraggableRegionsToSkRegion(
const std::vector<DraggableRegion>& regions) {
scoped_ptr<SkRegion> sk_region(new SkRegion);
std::unique_ptr<SkRegion> sk_region(new SkRegion);
for (const DraggableRegion& region : regions) {
sk_region->op(
region.bounds.x(),
@@ -573,7 +577,7 @@ bool NativeWindow::OnMessageReceived(const IPC::Message& message) {
void NativeWindow::UpdateDraggableRegions(
const std::vector<DraggableRegion>& regions) {
// Draggable region is not supported for non-frameless window.
if (has_frame_ && !force_using_draggable_region_)
if (has_frame_)
return;
draggable_region_ = DraggableRegionsToSkRegion(regions);
}

View File

@@ -123,8 +123,9 @@ class NativeWindow : public base::SupportsUserData,
virtual gfx::Size GetMinimumSize();
virtual void SetMaximumSize(const gfx::Size& size);
virtual gfx::Size GetMaximumSize();
virtual void SetSheetOffset(const double offset);
virtual double GetSheetOffset();
virtual void SetSheetOffset(const double offsetX, const double offsetY);
virtual double GetSheetOffsetX();
virtual double GetSheetOffsetY();
virtual void SetResizable(bool resizable) = 0;
virtual bool IsResizable() = 0;
virtual void SetMovable(bool movable) = 0;
@@ -190,7 +191,7 @@ class NativeWindow : public base::SupportsUserData,
// Set the aspect ratio when resizing window.
double GetAspectRatio();
gfx::Size GetAspectRatioExtraSize();
void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size);
virtual void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size);
base::WeakPtr<NativeWindow> GetWeakPtr() {
return weak_factory_.GetWeakPtr();
@@ -246,17 +247,11 @@ class NativeWindow : public base::SupportsUserData,
}
bool has_frame() const { return has_frame_; }
void set_has_frame(bool has_frame) { has_frame_ = has_frame; }
bool transparent() const { return transparent_; }
SkRegion* draggable_region() const { return draggable_region_.get(); }
bool enable_larger_than_screen() const { return enable_larger_than_screen_; }
gfx::ImageSkia icon() const { return icon_; }
bool force_using_draggable_region() const {
return force_using_draggable_region_;
}
void set_force_using_draggable_region(bool force) {
force_using_draggable_region_ = true;
}
void set_has_dialog_attached(bool has_dialog_attached) {
has_dialog_attached_ = has_dialog_attached;
@@ -268,7 +263,7 @@ class NativeWindow : public base::SupportsUserData,
// Convert draggable regions in raw format to SkRegion format. Caller is
// responsible for deleting the returned SkRegion instance.
scoped_ptr<SkRegion> DraggableRegionsToSkRegion(
std::unique_ptr<SkRegion> DraggableRegionsToSkRegion(
const std::vector<DraggableRegion>& regions);
// Converts between content size to window size.
@@ -299,15 +294,12 @@ class NativeWindow : public base::SupportsUserData,
// Whether window has standard frame.
bool has_frame_;
// Force the window to be aware of draggable regions.
bool force_using_draggable_region_;
// Whether window is transparent.
bool transparent_;
// For custom drag, the whole window is non-draggable and the draggable region
// has to been explicitly provided.
scoped_ptr<SkRegion> draggable_region_; // used in custom drag.
std::unique_ptr<SkRegion> draggable_region_; // used in custom drag.
// Minimum and maximum size, stored as content size.
extensions::SizeConstraints size_constraints_;
@@ -315,9 +307,6 @@ class NativeWindow : public base::SupportsUserData,
// Whether window can be resized larger than screen.
bool enable_larger_than_screen_;
// Window icon.
gfx::ImageSkia icon_;
// The windows has been closed.
bool is_closed_;
@@ -328,8 +317,10 @@ class NativeWindow : public base::SupportsUserData,
// it should be cancelled when we can prove that the window is responsive.
base::CancelableClosure window_unresposive_closure_;
// Used to display sheets at the appropriate vertical offset
double sheet_offset_;
// Used to display sheets at the appropriate horizontal and vertical offsets
// on OS X.
double sheet_offset_x_;
double sheet_offset_y_;
// Used to maintain the aspect ratio of a view which is inside of the
// content view.

View File

@@ -49,6 +49,8 @@ class NativeWindowMac : public NativeWindow {
void SetResizable(bool resizable) override;
bool IsResizable() override;
void SetMovable(bool movable) override;
void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size)
override;
bool IsMovable() override;
void SetMinimizable(bool minimizable) override;
bool IsMinimizable() override;
@@ -91,16 +93,15 @@ class NativeWindowMac : public NativeWindow {
UpdateDraggableRegionViews(draggable_regions_);
}
// Set the attribute of NSWindow while work around a bug of zoom button.
void SetStyleMask(bool on, NSUInteger flag);
void SetCollectionBehavior(bool on, NSUInteger flag);
bool should_hide_native_toolbar_in_fullscreen() const {
return should_hide_native_toolbar_in_fullscreen_;
}
protected:
// NativeWindow:
void HandleKeyboardEvent(
content::WebContents*,
const content::NativeWebKeyboardEvent&) override;
// Return a vector of non-draggable regions that fill a window of size
// |width| by |height|, but leave gaps where the window should be draggable.
std::vector<gfx::Rect> CalculateNonDraggableRegions(
@@ -120,10 +121,6 @@ class NativeWindowMac : public NativeWindow {
// whehter we can drag.
void UpdateDraggableRegionViews(const std::vector<DraggableRegion>& regions);
// Set the attribute of NSWindow while work around a bug of zo0m button.
void SetStyleMask(bool on, NSUInteger flag);
void SetCollectionBehavior(bool on, NSUInteger flag);
base::scoped_nsobject<AtomNSWindow> window_;
base::scoped_nsobject<AtomNSWindowDelegate> window_delegate_;
@@ -142,6 +139,10 @@ class NativeWindowMac : public NativeWindow {
// The presentation options before entering kiosk mode.
NSApplicationPresentationOptions kiosk_options_;
// Force showing the buttons for frameless window.
bool force_show_buttons_;
// Whether to hide the native toolbar under fullscreen mode.
bool should_hide_native_toolbar_in_fullscreen_;
DISALLOW_COPY_AND_ASSIGN(NativeWindowMac);

View File

@@ -6,6 +6,7 @@
#include <string>
#include "atom/browser/window_list.h"
#include "atom/common/color_util.h"
#include "atom/common/draggable_region.h"
#include "atom/common/options_switches.h"
@@ -15,7 +16,6 @@
#include "brightray/browser/inspectable_web_contents.h"
#include "brightray/browser/inspectable_web_contents_view.h"
#include "content/public/browser/browser_accessibility_state.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h"
@@ -142,22 +142,9 @@ bool ScopedDisableResize::disable_resize_ = false;
newSize.width =
roundf((frameSize.height - extraHeightPlusFrame) * aspectRatio +
extraWidthPlusFrame);
// If the new width is less than the frame size use it as the primary
// constraint. This ensures that the value returned by this method will
// never be larger than the users requested window size.
if (newSize.width <= frameSize.width) {
newSize.height =
roundf((newSize.width - extraWidthPlusFrame) / aspectRatio +
extraHeightPlusFrame);
} else {
newSize.height =
roundf((frameSize.width - extraWidthPlusFrame) / aspectRatio +
extraHeightPlusFrame);
newSize.width =
roundf((newSize.height - extraHeightPlusFrame) * aspectRatio +
extraWidthPlusFrame);
}
newSize.height =
roundf((newSize.width - extraWidthPlusFrame) / aspectRatio +
extraHeightPlusFrame);
}
return newSize;
@@ -214,10 +201,22 @@ bool ScopedDisableResize::disable_resize_ = false;
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
[toolbar setShowsBaselineSeparator:NO];
[window setToolbar:toolbar];
// Set window style to hide the toolbar, otherwise the toolbar will show in
// fullscreen mode.
shell_->SetStyleMask(true, NSFullSizeContentViewWindowMask);
}
}
- (void)windowWillExitFullScreen:(NSNotification*)notification {
// Turn off the style for toolbar.
if (shell_->should_hide_native_toolbar_in_fullscreen())
shell_->SetStyleMask(false, NSFullSizeContentViewWindowMask);
}
- (void)windowDidExitFullScreen:(NSNotification*)notification {
// For certain versions of OS X the fullscreen button will automatically show
// after exiting fullscreen mode.
if (!shell_->has_frame()) {
NSWindow* window = shell_->GetNativeWindow();
[[window standardWindowButton:NSWindowFullScreenButton] setHidden:YES];
@@ -246,7 +245,9 @@ bool ScopedDisableResize::disable_resize_ = false;
- (NSRect)window:(NSWindow*)window
willPositionSheet:(NSWindow*)sheet usingRect:(NSRect)rect {
NSView* view = window.contentView;
rect.origin.y = view.frame.size.height - shell_->GetSheetOffset();
rect.origin.x = shell_->GetSheetOffsetX();
rect.origin.y = view.frame.size.height - shell_->GetSheetOffsetY();
return rect;
}
@@ -391,6 +392,7 @@ NativeWindowMac::NativeWindowMac(
: NativeWindow(web_contents, options),
is_kiosk_(false),
attention_request_id_(0),
force_show_buttons_(false),
should_hide_native_toolbar_in_fullscreen_(false) {
int width = 800, height = 600;
options.Get(options::kWidth, &width);
@@ -438,22 +440,17 @@ NativeWindowMac::NativeWindowMac(
if (closable) {
styleMask |= NSClosableWindowMask;
}
if ((titleBarStyle == "hidden") || (titleBarStyle == "hidden-inset")) {
// The window without titlebar is treated the same with frameless window.
set_has_frame(false);
force_show_buttons_ = true;
}
if (!useStandardWindow || transparent() || !has_frame()) {
styleMask |= NSTexturedBackgroundWindowMask;
}
if (resizable) {
styleMask |= NSResizableWindowMask;
}
if ((titleBarStyle == "hidden") || (titleBarStyle == "hidden-inset")) {
styleMask |= NSFullSizeContentViewWindowMask;
styleMask |= NSUnifiedTitleAndToolbarWindowMask;
}
// We capture this because we need to access the option later when
// entering/exiting fullscreen and since the options dict is only passed to
// the constructor but not stored, lets store this option this way.
if (titleBarStyle == "hidden-inset") {
should_hide_native_toolbar_in_fullscreen_ = true;
}
window_.reset([[AtomNSWindow alloc]
initWithContentRect:cocoa_bounds
@@ -490,17 +487,14 @@ NativeWindowMac::NativeWindowMac(
[window_ setReleasedWhenClosed:NO];
// Hide the title bar.
if ((titleBarStyle == "hidden") || (titleBarStyle == "hidden-inset")) {
if (titleBarStyle == "hidden-inset") {
[window_ setTitlebarAppearsTransparent:YES];
[window_ setTitleVisibility:NSWindowTitleHidden];
if (titleBarStyle == "hidden-inset") {
base::scoped_nsobject<NSToolbar> toolbar(
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
[toolbar setShowsBaselineSeparator:NO];
[window_ setToolbar:toolbar];
}
// We should be aware of draggable regions when using hidden titlebar.
set_force_using_draggable_region(true);
base::scoped_nsobject<NSToolbar> toolbar(
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
[toolbar setShowsBaselineSeparator:NO];
[window_ setToolbar:toolbar];
should_hide_native_toolbar_in_fullscreen_ = true;
}
// On OS X the initial window size doesn't include window frame.
@@ -558,6 +552,11 @@ NativeWindowMac::~NativeWindowMac() {
}
void NativeWindowMac::Close() {
if (!IsClosable()) {
WindowList::WindowCloseCancelled(this);
return;
}
[window_ performClose:nil];
}
@@ -713,6 +712,17 @@ bool NativeWindowMac::IsResizable() {
return [window_ styleMask] & NSResizableWindowMask;
}
void NativeWindowMac::SetAspectRatio(double aspect_ratio,
const gfx::Size& extra_size) {
NativeWindow::SetAspectRatio(aspect_ratio, extra_size);
// Reset the behaviour to default if aspect_ratio is set to 0 or less.
if (aspect_ratio > 0.0)
[window_ setAspectRatio:NSMakeSize(aspect_ratio, 1.0)];
else
[window_ setResizeIncrements:NSMakeSize(1.0, 1.0)];
}
void NativeWindowMac::SetMovable(bool movable) {
[window_ setMovable:movable];
}
@@ -928,35 +938,14 @@ bool NativeWindowMac::IsVisibleOnAllWorkspaces() {
return collectionBehavior & NSWindowCollectionBehaviorCanJoinAllSpaces;
}
void NativeWindowMac::HandleKeyboardEvent(
content::WebContents*,
const content::NativeWebKeyboardEvent& event) {
if (event.skip_in_browser ||
event.type == content::NativeWebKeyboardEvent::Char)
return;
BOOL handled = [[NSApp mainMenu] performKeyEquivalent:event.os_event];
if (!handled && event.os_event.window) {
// Handle the cmd+~ shortcut.
if ((event.os_event.modifierFlags & NSCommandKeyMask) /* cmd */ &&
(event.os_event.keyCode == 50 /* ~ */)) {
if (event.os_event.modifierFlags & NSShiftKeyMask) {
[NSApp sendAction:@selector(_cycleWindowsReversed:) to:nil from:nil];
} else {
[NSApp sendAction:@selector(_cycleWindows:) to:nil from:nil];
}
}
}
}
std::vector<gfx::Rect> NativeWindowMac::CalculateNonDraggableRegions(
const std::vector<DraggableRegion>& regions, int width, int height) {
std::vector<gfx::Rect> result;
if (regions.empty()) {
result.push_back(gfx::Rect(0, 0, width, height));
} else {
scoped_ptr<SkRegion> draggable(DraggableRegionsToSkRegion(regions));
scoped_ptr<SkRegion> non_draggable(new SkRegion);
std::unique_ptr<SkRegion> draggable(DraggableRegionsToSkRegion(regions));
std::unique_ptr<SkRegion> non_draggable(new SkRegion);
non_draggable->op(0, 0, width, height, SkRegion::kUnion_Op);
non_draggable->op(*draggable, SkRegion::kDifference_Op);
for (SkRegion::Iterator it(*non_draggable); !it.done(); it.next()) {
@@ -1013,6 +1002,10 @@ void NativeWindowMac::InstallView() {
[view setFrame:[content_view_ bounds]];
[content_view_ addSubview:view];
if (force_show_buttons_)
return;
// Hide the window buttons.
[[window_ standardWindowButton:NSWindowZoomButton] setHidden:YES];
[[window_ standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES];
[[window_ standardWindowButton:NSWindowCloseButton] setHidden:YES];
@@ -1031,7 +1024,7 @@ void NativeWindowMac::UninstallView() {
void NativeWindowMac::UpdateDraggableRegionViews(
const std::vector<DraggableRegion>& regions) {
if (has_frame() && !force_using_draggable_region())
if (has_frame())
return;
// All ControlRegionViews should be added as children of the WebContentsView,

View File

@@ -9,8 +9,10 @@
#include "atom/browser/ui/views/menu_bar.h"
#include "atom/browser/ui/views/menu_layout.h"
#include "atom/browser/window_list.h"
#include "atom/common/color_util.h"
#include "atom/common/draggable_region.h"
#include "atom/common/native_mate_converters/image_converter.h"
#include "atom/common/options_switches.h"
#include "base/strings/utf_string_conversions.h"
#include "brightray/browser/inspectable_web_contents.h"
@@ -40,6 +42,7 @@
#include "chrome/browser/ui/libgtk2ui/unity_service.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
#include "ui/views/window/native_frame_view.h"
#elif defined(OS_WIN)
#include "atom/browser/ui/views/win_frame_view.h"
@@ -273,7 +276,6 @@ NativeWindowViews::NativeWindowViews(
use_content_size_)
size = ContentSizeToWindowSize(size);
window_->UpdateWindowIcon();
window_->CenterWindow(size);
Layout();
}
@@ -283,6 +285,11 @@ NativeWindowViews::~NativeWindowViews() {
}
void NativeWindowViews::Close() {
if (!IsClosable()) {
WindowList::WindowCloseCancelled(this);
return;
}
window_->Close();
}
@@ -623,7 +630,9 @@ void NativeWindowViews::SetBackgroundColor(const std::string& color_name) {
// Set the background color of native window.
HBRUSH brush = CreateSolidBrush(skia::SkColorToCOLORREF(background_color));
ULONG_PTR previous_brush = SetClassLongPtr(
GetAcceleratedWidget(), GCLP_HBRBACKGROUND, (LONG)brush);
GetAcceleratedWidget(),
GCLP_HBRBACKGROUND,
reinterpret_cast<LONG_PTR>(brush));
if (previous_brush)
DeleteObject((HBRUSH)previous_brush);
#endif
@@ -776,6 +785,27 @@ gfx::AcceleratedWidget NativeWindowViews::GetAcceleratedWidget() {
return GetNativeWindow()->GetHost()->GetAcceleratedWidget();
}
#if defined(OS_WIN)
void NativeWindowViews::SetIcon(HICON window_icon, HICON app_icon) {
// We are responsible for storing the images.
window_icon_ = base::win::ScopedHICON(CopyIcon(window_icon));
app_icon_ = base::win::ScopedHICON(CopyIcon(app_icon));
HWND hwnd = GetAcceleratedWidget();
SendMessage(hwnd, WM_SETICON, ICON_SMALL,
reinterpret_cast<LPARAM>(window_icon_.get()));
SendMessage(hwnd, WM_SETICON, ICON_BIG,
reinterpret_cast<LPARAM>(app_icon_.get()));
}
#elif defined(USE_X11)
void NativeWindowViews::SetIcon(const gfx::ImageSkia& icon) {
views::DesktopWindowTreeHostX11* tree_host =
views::DesktopWindowTreeHostX11::GetHostForXID(GetAcceleratedWidget());
static_cast<views::DesktopWindowTreeHost*>(tree_host)->SetWindowIcons(
icon, icon);
}
#endif
void NativeWindowViews::OnWidgetActivationChanged(
views::Widget* widget, bool active) {
if (widget != window_.get())
@@ -840,14 +870,6 @@ bool NativeWindowViews::ShouldHandleSystemCommands() const {
return true;
}
gfx::ImageSkia NativeWindowViews::GetWindowAppIcon() {
return icon();
}
gfx::ImageSkia NativeWindowViews::GetWindowIcon() {
return GetWindowAppIcon();
}
views::Widget* NativeWindowViews::GetWidget() {
return window_.get();
}

View File

@@ -17,6 +17,7 @@
#if defined(OS_WIN)
#include "atom/browser/ui/win/message_handler_delegate.h"
#include "atom/browser/ui/win/taskbar_host.h"
#include "base/win/scoped_gdi_object.h"
#endif
namespace views {
@@ -104,6 +105,12 @@ class NativeWindowViews : public NativeWindow,
gfx::AcceleratedWidget GetAcceleratedWidget() override;
#if defined(OS_WIN)
void SetIcon(HICON small_icon, HICON app_icon);
#elif defined(USE_X11)
void SetIcon(const gfx::ImageSkia& icon);
#endif
views::Widget* widget() const { return window_.get(); }
#if defined(OS_WIN)
@@ -125,8 +132,6 @@ class NativeWindowViews : public NativeWindow,
bool CanMinimize() const override;
base::string16 GetWindowTitle() const override;
bool ShouldHandleSystemCommands() const override;
gfx::ImageSkia GetWindowAppIcon() override;
gfx::ImageSkia GetWindowIcon() override;
views::Widget* GetWidget() override;
const views::Widget* GetWidget() const override;
views::View* GetContentsView() override;
@@ -145,7 +150,6 @@ class NativeWindowViews : public NativeWindow,
// MessageHandlerDelegate:
bool PreHandleMSG(
UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) override;
void HandleSizeEvent(WPARAM w_param, LPARAM l_param);
#endif
@@ -167,19 +171,19 @@ class NativeWindowViews : public NativeWindow,
// Returns the restore state for the window.
ui::WindowShowState GetRestoredState();
scoped_ptr<views::Widget> window_;
std::unique_ptr<views::Widget> window_;
views::View* web_view_; // Managed by inspectable_web_contents_.
scoped_ptr<MenuBar> menu_bar_;
std::unique_ptr<MenuBar> menu_bar_;
bool menu_bar_autohide_;
bool menu_bar_visible_;
bool menu_bar_alt_pressed_;
#if defined(USE_X11)
scoped_ptr<GlobalMenuBarX11> global_menu_bar_;
std::unique_ptr<GlobalMenuBarX11> global_menu_bar_;
// Handles window state events.
scoped_ptr<WindowStateWatcher> window_state_watcher_;
std::unique_ptr<WindowStateWatcher> window_state_watcher_;
// The "resizable" flag on Linux is implemented by setting size constraints,
// we need to make sure size constraints are restored when window becomes
@@ -203,10 +207,13 @@ class NativeWindowViews : public NativeWindow,
// If true we have enabled a11y
bool enabled_a11y_support_;
// The icons of window and taskbar.
base::win::ScopedHICON window_icon_;
base::win::ScopedHICON app_icon_;
#endif
// Handles unhandled keyboard messages coming back from the renderer process.
scoped_ptr<views::UnhandledKeyboardEventHandler> keyboard_event_handler_;
std::unique_ptr<views::UnhandledKeyboardEventHandler> keyboard_event_handler_;
// Map from accelerator to menu item's command id.
accelerator_util::AcceleratorTable accelerator_table_;

View File

@@ -112,7 +112,7 @@ class URLRequestAsarJob : public net::URLRequestJob {
base::FilePath file_path_;
Archive::FileInfo file_info_;
scoped_ptr<net::FileStream> stream_;
std::unique_ptr<net::FileStream> stream_;
FileMetaInfo meta_info_;
scoped_refptr<base::TaskRunner> file_task_runner_;

View File

@@ -48,7 +48,7 @@ int AtomCertVerifier::Verify(
net::CRLSet* crl_set,
net::CertVerifyResult* verify_result,
const net::CompletionCallback& callback,
scoped_ptr<Request>* out_req,
std::unique_ptr<Request>* out_req,
const net::BoundNetLog& net_log) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);

View File

@@ -34,14 +34,14 @@ class AtomCertVerifier : public net::CertVerifier {
net::CRLSet* crl_set,
net::CertVerifyResult* verify_result,
const net::CompletionCallback& callback,
scoped_ptr<Request>* out_req,
std::unique_ptr<Request>* out_req,
const net::BoundNetLog& net_log) override;
bool SupportsOCSPStapling() override;
private:
base::Lock lock_;
VerifyProc verify_proc_;
scoped_ptr<net::CertVerifier> default_cert_verifier_;
std::unique_ptr<net::CertVerifier> default_cert_verifier_;
DISALLOW_COPY_AND_ASSIGN(AtomCertVerifier);
};

View File

@@ -45,13 +45,13 @@ using ResponseHeadersContainer =
std::pair<scoped_refptr<net::HttpResponseHeaders>*, const std::string&>;
void RunSimpleListener(const AtomNetworkDelegate::SimpleListener& listener,
scoped_ptr<base::DictionaryValue> details) {
std::unique_ptr<base::DictionaryValue> details) {
return listener.Run(*(details.get()));
}
void RunResponseListener(
const AtomNetworkDelegate::ResponseListener& listener,
scoped_ptr<base::DictionaryValue> details,
std::unique_ptr<base::DictionaryValue> details,
const AtomNetworkDelegate::ResponseCallback& callback) {
return listener.Run(*(details.get()), callback);
}
@@ -79,7 +79,7 @@ void ToDictionary(base::DictionaryValue* details, net::URLRequest* request) {
details->SetString("resourceType",
info ? ResourceTypeToString(info->GetResourceType())
: "other");
scoped_ptr<base::ListValue> list(new base::ListValue);
std::unique_ptr<base::ListValue> list(new base::ListValue);
GetUploadData(list.get(), request);
if (!list->empty())
details->Set("uploadData", std::move(list));
@@ -87,7 +87,7 @@ void ToDictionary(base::DictionaryValue* details, net::URLRequest* request) {
void ToDictionary(base::DictionaryValue* details,
const net::HttpRequestHeaders& headers) {
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
net::HttpRequestHeaders::Iterator it(headers);
while (it.GetNext())
dict->SetString(it.name(), it.value());
@@ -99,8 +99,8 @@ void ToDictionary(base::DictionaryValue* details,
if (!headers)
return;
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
void* iter = nullptr;
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
size_t iter = 0;
std::string key;
std::string value;
while (headers->EnumerateHeaderLines(&iter, &key, &value)) {
@@ -109,7 +109,7 @@ void ToDictionary(base::DictionaryValue* details,
if (dict->GetList(key, &values))
values->AppendString(value);
} else {
scoped_ptr<base::ListValue> values(new base::ListValue);
std::unique_ptr<base::ListValue> values(new base::ListValue);
values->AppendString(value);
dict->Set(key, std::move(values));
}
@@ -369,7 +369,7 @@ int AtomNetworkDelegate::HandleResponseEvent(
if (!MatchesFilterCondition(request, info.url_patterns))
return net::OK;
scoped_ptr<base::DictionaryValue> details(new base::DictionaryValue);
std::unique_ptr<base::DictionaryValue> details(new base::DictionaryValue);
FillDetailsObject(details.get(), request, args...);
// The |request| could be destroyed before the |callback| is called.
@@ -392,7 +392,7 @@ void AtomNetworkDelegate::HandleSimpleEvent(
if (!MatchesFilterCondition(request, info.url_patterns))
return;
scoped_ptr<base::DictionaryValue> details(new base::DictionaryValue);
std::unique_ptr<base::DictionaryValue> details(new base::DictionaryValue);
FillDetailsObject(details.get(), request, args...);
BrowserThread::PostTask(
@@ -402,7 +402,7 @@ void AtomNetworkDelegate::HandleSimpleEvent(
template<typename T>
void AtomNetworkDelegate::OnListenerResultInIO(
uint64_t id, T out, scoped_ptr<base::DictionaryValue> response) {
uint64_t id, T out, std::unique_ptr<base::DictionaryValue> response) {
// The request has been destroyed.
if (!ContainsKey(callbacks_, id))
return;
@@ -417,7 +417,7 @@ void AtomNetworkDelegate::OnListenerResultInIO(
template<typename T>
void AtomNetworkDelegate::OnListenerResultInUI(
uint64_t id, T out, const base::DictionaryValue& response) {
scoped_ptr<base::DictionaryValue> copy = response.CreateDeepCopy();
std::unique_ptr<base::DictionaryValue> copy = response.CreateDeepCopy();
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&AtomNetworkDelegate::OnListenerResultInIO<T>,

View File

@@ -111,7 +111,7 @@ class AtomNetworkDelegate : public brightray::NetworkDelegate {
// Deal with the results of Listener.
template<typename T>
void OnListenerResultInIO(
uint64_t id, T out, scoped_ptr<base::DictionaryValue> response);
uint64_t id, T out, std::unique_ptr<base::DictionaryValue> response);
template<typename T>
void OnListenerResultInUI(
uint64_t id, T out, const base::DictionaryValue& response);

View File

@@ -23,7 +23,8 @@ AtomURLRequestJobFactory::~AtomURLRequestJobFactory() {
}
bool AtomURLRequestJobFactory::SetProtocolHandler(
const std::string& scheme, scoped_ptr<ProtocolHandler> protocol_handler) {
const std::string& scheme,
std::unique_ptr<ProtocolHandler> protocol_handler) {
if (!protocol_handler) {
ProtocolHandlerMap::iterator it = protocol_handler_map_.find(scheme);
if (it == protocol_handler_map_.end())
@@ -40,8 +41,9 @@ bool AtomURLRequestJobFactory::SetProtocolHandler(
return true;
}
scoped_ptr<ProtocolHandler> AtomURLRequestJobFactory::ReplaceProtocol(
const std::string& scheme, scoped_ptr<ProtocolHandler> protocol_handler) {
std::unique_ptr<ProtocolHandler> AtomURLRequestJobFactory::ReplaceProtocol(
const std::string& scheme,
std::unique_ptr<ProtocolHandler> protocol_handler) {
if (!ContainsKey(protocol_handler_map_, scheme))
return nullptr;
ProtocolHandler* original_protocol_handler = protocol_handler_map_[scheme];

View File

@@ -24,13 +24,14 @@ class AtomURLRequestJobFactory : public net::URLRequestJobFactory {
// Sets the ProtocolHandler for a scheme. Returns true on success, false on
// failure (a ProtocolHandler already exists for |scheme|). On success,
// URLRequestJobFactory takes ownership of |protocol_handler|.
bool SetProtocolHandler(
const std::string& scheme, scoped_ptr<ProtocolHandler> protocol_handler);
bool SetProtocolHandler(const std::string& scheme,
std::unique_ptr<ProtocolHandler> protocol_handler);
// Intercepts the ProtocolHandler for a scheme. Returns the original protocol
// handler on success, otherwise returns NULL.
scoped_ptr<ProtocolHandler> ReplaceProtocol(
const std::string& scheme, scoped_ptr<ProtocolHandler> protocol_handler);
std::unique_ptr<ProtocolHandler> ReplaceProtocol(
const std::string& scheme,
std::unique_ptr<ProtocolHandler> protocol_handler);
// Returns the protocol handler registered with scheme.
ProtocolHandler* GetProtocolHandler(const std::string& scheme) const;

View File

@@ -34,7 +34,7 @@ void HandlerCallback(const BeforeStartCallback& before_start,
// Pass whatever user passed to the actaul request job.
V8ValueConverter converter;
v8::Local<v8::Context> context = args->isolate()->GetCurrentContext();
scoped_ptr<base::Value> options(converter.FromV8Value(value, context));
std::unique_ptr<base::Value> options(converter.FromV8Value(value, context));
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::Bind(callback, true, base::Passed(&options)));

View File

@@ -26,7 +26,7 @@ namespace internal {
using BeforeStartCallback =
base::Callback<void(v8::Isolate*, v8::Local<v8::Value>)>;
using ResponseCallback =
base::Callback<void(bool, scoped_ptr<base::Value> options)>;
base::Callback<void(bool, std::unique_ptr<base::Value> options)>;
// Ask handler for options in UI thread.
void AskForOptions(v8::Isolate* isolate,
@@ -58,7 +58,7 @@ class JsAsker : public RequestJob {
// Subclass should do initailze work here.
virtual void BeforeStartInUI(v8::Isolate*, v8::Local<v8::Value>) {}
virtual void StartAsync(scoped_ptr<base::Value> options) = 0;
virtual void StartAsync(std::unique_ptr<base::Value> options) = 0;
net::URLRequestContextGetter* request_context_getter() const {
return request_context_getter_;
@@ -84,7 +84,7 @@ class JsAsker : public RequestJob {
// Called when the JS handler has sent the response, we need to decide whether
// to start, or fail the job.
void OnResponse(bool success, scoped_ptr<base::Value> value) {
void OnResponse(bool success, std::unique_ptr<base::Value> value) {
int error = net::ERR_NOT_IMPLEMENTED;
if (success && value && !internal::IsErrorOptions(value.get(), &error)) {
StartAsync(std::move(value));

View File

@@ -16,7 +16,7 @@ URLRequestAsyncAsarJob::URLRequestAsyncAsarJob(
: JsAsker<asar::URLRequestAsarJob>(request, network_delegate) {
}
void URLRequestAsyncAsarJob::StartAsync(scoped_ptr<base::Value> options) {
void URLRequestAsyncAsarJob::StartAsync(std::unique_ptr<base::Value> options) {
base::FilePath::StringType file_path;
if (options->IsType(base::Value::TYPE_DICTIONARY)) {
static_cast<base::DictionaryValue*>(options.get())->GetString(

View File

@@ -16,7 +16,7 @@ class URLRequestAsyncAsarJob : public JsAsker<asar::URLRequestAsarJob> {
URLRequestAsyncAsarJob(net::URLRequest*, net::NetworkDelegate*);
// JsAsker:
void StartAsync(scoped_ptr<base::Value> options) override;
void StartAsync(std::unique_ptr<base::Value> options) override;
// URLRequestJob:
void GetResponseInfo(net::HttpResponseInfo* info) override;

View File

@@ -8,17 +8,31 @@
#include "atom/common/atom_constants.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "net/base/mime_util.h"
#include "net/base/net_errors.h"
namespace atom {
namespace {
std::string GetExtFromURL(const GURL& url) {
std::string spec = url.spec();
size_t index = spec.find_last_of('.');
if (index == std::string::npos || index == spec.size())
return std::string();
return spec.substr(index + 1, spec.size() - index - 1);
}
} // namespace
URLRequestBufferJob::URLRequestBufferJob(
net::URLRequest* request, net::NetworkDelegate* network_delegate)
: JsAsker<net::URLRequestSimpleJob>(request, network_delegate),
status_code_(net::HTTP_NOT_IMPLEMENTED) {
}
void URLRequestBufferJob::StartAsync(scoped_ptr<base::Value> options) {
void URLRequestBufferJob::StartAsync(std::unique_ptr<base::Value> options) {
const base::BinaryValue* binary = nullptr;
if (options->IsType(base::Value::TYPE_DICTIONARY)) {
base::DictionaryValue* dict =
@@ -30,6 +44,15 @@ void URLRequestBufferJob::StartAsync(scoped_ptr<base::Value> options) {
options->GetAsBinary(&binary);
}
if (mime_type_.empty()) {
std::string ext = GetExtFromURL(request()->url());
#if defined(OS_WIN)
net::GetWellKnownMimeTypeFromExtension(base::UTF8ToUTF16(ext), &mime_type_);
#else
net::GetWellKnownMimeTypeFromExtension(ext, &mime_type_);
#endif
}
if (!binary) {
NotifyStartError(net::URLRequestStatus(
net::URLRequestStatus::FAILED, net::ERR_NOT_IMPLEMENTED));

View File

@@ -19,7 +19,7 @@ class URLRequestBufferJob : public JsAsker<net::URLRequestSimpleJob> {
URLRequestBufferJob(net::URLRequest*, net::NetworkDelegate*);
// JsAsker:
void StartAsync(scoped_ptr<base::Value> options) override;
void StartAsync(std::unique_ptr<base::Value> options) override;
// URLRequestJob:
void GetResponseInfo(net::HttpResponseInfo* info) override;

View File

@@ -59,7 +59,7 @@ class ResponsePiper : public net::URLFetcherResponseWriter {
job_->HeadersCompleted();
first_write_ = false;
}
return job_->DataAvailable(buffer, num_bytes);
return job_->DataAvailable(buffer, num_bytes, callback);
}
int Finish(const net::CompletionCallback& callback) override {
return net::OK;
@@ -77,7 +77,8 @@ class ResponsePiper : public net::URLFetcherResponseWriter {
URLRequestFetchJob::URLRequestFetchJob(
net::URLRequest* request, net::NetworkDelegate* network_delegate)
: JsAsker<net::URLRequestJob>(request, network_delegate),
pending_buffer_size_(0) {
pending_buffer_size_(0),
write_num_bytes_(0) {
}
void URLRequestFetchJob::BeforeStartInUI(
@@ -99,7 +100,7 @@ void URLRequestFetchJob::BeforeStartInUI(
}
}
void URLRequestFetchJob::StartAsync(scoped_ptr<base::Value> options) {
void URLRequestFetchJob::StartAsync(std::unique_ptr<base::Value> options) {
if (!options->IsType(base::Value::TYPE_DICTIONARY)) {
NotifyStartError(net::URLRequestStatus(
net::URLRequestStatus::FAILED, net::ERR_NOT_IMPLEMENTED));
@@ -166,22 +167,23 @@ void URLRequestFetchJob::HeadersCompleted() {
NotifyHeadersComplete();
}
int URLRequestFetchJob::DataAvailable(net::IOBuffer* buffer, int num_bytes) {
// Do nothing if pending_buffer_ is empty, i.e. there's no ReadRawData()
// operation waiting for IO completion.
if (!pending_buffer_.get())
int URLRequestFetchJob::DataAvailable(net::IOBuffer* buffer,
int num_bytes,
const net::CompletionCallback& callback) {
// When pending_buffer_ is empty, there's no ReadRawData() operation waiting
// for IO completion, we have to save the parameters until the request is
// ready to read data.
if (!pending_buffer_.get()) {
write_buffer_ = buffer;
write_num_bytes_ = num_bytes;
write_callback_ = callback;
return net::ERR_IO_PENDING;
}
// pending_buffer_ is set to the IOBuffer instance provided to ReadRawData()
// by URLRequestJob.
int bytes_read = std::min(num_bytes, pending_buffer_size_);
memcpy(pending_buffer_->data(), buffer->data(), bytes_read);
// Clear the buffers before notifying the read is complete, so that it is
// safe for the observer to read.
pending_buffer_ = nullptr;
pending_buffer_size_ = 0;
// Write data to the pending buffer and clear them after the writing.
int bytes_read = BufferCopy(buffer, num_bytes,
pending_buffer_.get(), pending_buffer_size_);
ClearPendingBuffer();
ReadRawDataComplete(bytes_read);
return bytes_read;
}
@@ -196,9 +198,22 @@ int URLRequestFetchJob::ReadRawData(net::IOBuffer* dest, int dest_size) {
request()->set_received_response_content_length(prefilter_bytes_read());
return net::OK;
}
pending_buffer_ = dest;
pending_buffer_size_ = dest_size;
return net::ERR_IO_PENDING;
// When write_buffer_ is empty, there is no data valable yet, we have to save
// the dest buffer util DataAvailable.
if (!write_buffer_.get()) {
pending_buffer_ = dest;
pending_buffer_size_ = dest_size;
return net::ERR_IO_PENDING;
}
// Read from the write buffer and clear them after reading.
int bytes_read = BufferCopy(write_buffer_.get(), write_num_bytes_,
dest, dest_size);
net::CompletionCallback write_callback = write_callback_;
ClearWriteBuffer();
write_callback.Run(bytes_read);
return bytes_read;
}
bool URLRequestFetchJob::GetMimeType(std::string* mime_type) const {
@@ -229,12 +244,31 @@ void URLRequestFetchJob::OnURLFetchComplete(const net::URLFetcher* source) {
return;
}
pending_buffer_ = nullptr;
pending_buffer_size_ = 0;
ClearPendingBuffer();
ClearWriteBuffer();
if (fetcher_->GetStatus().is_success())
ReadRawDataComplete(0);
else
NotifyStartError(fetcher_->GetStatus());
}
int URLRequestFetchJob::BufferCopy(net::IOBuffer* source, int num_bytes,
net::IOBuffer* target, int target_size) {
int bytes_written = std::min(num_bytes, target_size);
memcpy(target->data(), source->data(), bytes_written);
return bytes_written;
}
void URLRequestFetchJob::ClearPendingBuffer() {
pending_buffer_ = nullptr;
pending_buffer_size_ = 0;
}
void URLRequestFetchJob::ClearWriteBuffer() {
write_buffer_ = nullptr;
write_num_bytes_ = 0;
write_callback_.Reset();
}
} // namespace atom

View File

@@ -9,14 +9,10 @@
#include "atom/browser/net/js_asker.h"
#include "browser/url_request_context_getter.h"
#include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_fetcher_delegate.h"
#include "net/url_request/url_request_job.h"
namespace atom {
class AtomBrowserContext;
class URLRequestFetchJob : public JsAsker<net::URLRequestJob>,
public net::URLFetcherDelegate,
public brightray::URLRequestContextGetter::Delegate {
@@ -25,12 +21,14 @@ class URLRequestFetchJob : public JsAsker<net::URLRequestJob>,
// Called by response writer.
void HeadersCompleted();
int DataAvailable(net::IOBuffer* buffer, int num_bytes);
int DataAvailable(net::IOBuffer* buffer,
int num_bytes,
const net::CompletionCallback& callback);
protected:
// JsAsker:
void BeforeStartInUI(v8::Isolate*, v8::Local<v8::Value>) override;
void StartAsync(scoped_ptr<base::Value> options) override;
void StartAsync(std::unique_ptr<base::Value> options) override;
// net::URLRequestJob:
void Kill() override;
@@ -43,11 +41,23 @@ class URLRequestFetchJob : public JsAsker<net::URLRequestJob>,
void OnURLFetchComplete(const net::URLFetcher* source) override;
private:
int BufferCopy(net::IOBuffer* source, int num_bytes,
net::IOBuffer* target, int target_size);
void ClearPendingBuffer();
void ClearWriteBuffer();
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
scoped_ptr<net::URLFetcher> fetcher_;
std::unique_ptr<net::URLFetcher> fetcher_;
std::unique_ptr<net::HttpResponseInfo> response_info_;
// Saved arguments passed to ReadRawData.
scoped_refptr<net::IOBuffer> pending_buffer_;
int pending_buffer_size_;
scoped_ptr<net::HttpResponseInfo> response_info_;
// Saved arguments passed to DataAvailable.
scoped_refptr<net::IOBuffer> write_buffer_;
int write_num_bytes_;
net::CompletionCallback write_callback_;
DISALLOW_COPY_AND_ASSIGN(URLRequestFetchJob);
};

View File

@@ -16,7 +16,7 @@ URLRequestStringJob::URLRequestStringJob(
: JsAsker<net::URLRequestSimpleJob>(request, network_delegate) {
}
void URLRequestStringJob::StartAsync(scoped_ptr<base::Value> options) {
void URLRequestStringJob::StartAsync(std::unique_ptr<base::Value> options) {
if (options->IsType(base::Value::TYPE_DICTIONARY)) {
base::DictionaryValue* dict =
static_cast<base::DictionaryValue*>(options.get());

View File

@@ -17,7 +17,7 @@ class URLRequestStringJob : public JsAsker<net::URLRequestSimpleJob> {
URLRequestStringJob(net::URLRequest*, net::NetworkDelegate*);
// JsAsker:
void StartAsync(scoped_ptr<base::Value> options) override;
void StartAsync(std::unique_ptr<base::Value> options) override;
// URLRequestJob:
void GetResponseInfo(net::HttpResponseInfo* info) override;

View File

@@ -145,7 +145,7 @@ void NodeDebugger::DebugMessageHandler(const v8::Debug::Message& message) {
void NodeDebugger::DidAccept(
net::test_server::StreamListenSocket* server,
scoped_ptr<net::test_server::StreamListenSocket> socket) {
std::unique_ptr<net::test_server::StreamListenSocket> socket) {
// Only accept one session.
if (accepted_socket_) {
socket->Send(std::string("Remote debugging session already active"), true);

View File

@@ -38,7 +38,7 @@ class NodeDebugger : public net::test_server::StreamListenSocket::Delegate {
// net::test_server::StreamListenSocket::Delegate:
void DidAccept(
net::test_server::StreamListenSocket* server,
scoped_ptr<net::test_server::StreamListenSocket> socket) override;
std::unique_ptr<net::test_server::StreamListenSocket> socket) override;
void DidRead(net::test_server::StreamListenSocket* socket,
const char* data,
int len) override;
@@ -49,8 +49,8 @@ class NodeDebugger : public net::test_server::StreamListenSocket::Delegate {
uv_async_t weak_up_ui_handle_;
base::Thread thread_;
scoped_ptr<net::test_server::StreamListenSocket> server_;
scoped_ptr<net::test_server::StreamListenSocket> accepted_socket_;
std::unique_ptr<net::test_server::StreamListenSocket> server_;
std::unique_ptr<net::test_server::StreamListenSocket> accepted_socket_;
std::string buffer_;
int content_length_;

View File

@@ -0,0 +1,63 @@
// Copyright (c) 2016 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/browser/render_process_preferences.h"
#include "atom/common/api/api_messages.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h"
namespace atom {
RenderProcessPreferences::RenderProcessPreferences(const Predicate& predicate)
: predicate_(predicate),
next_id_(0),
cache_needs_update_(true) {
registrar_.Add(this,
content::NOTIFICATION_RENDERER_PROCESS_CREATED,
content::NotificationService::AllBrowserContextsAndSources());
}
RenderProcessPreferences::~RenderProcessPreferences() {
}
int RenderProcessPreferences::AddEntry(const base::DictionaryValue& entry) {
int id = ++next_id_;
entries_[id] = entry.CreateDeepCopy();
cache_needs_update_ = true;
return id;
}
void RenderProcessPreferences::RemoveEntry(int id) {
cache_needs_update_ = true;
entries_.erase(id);
}
void RenderProcessPreferences::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(type, content::NOTIFICATION_RENDERER_PROCESS_CREATED);
content::RenderProcessHost* process =
content::Source<content::RenderProcessHost>(source).ptr();
if (!predicate_.Run(process))
return;
UpdateCache();
process->Send(new AtomMsg_UpdatePreferences(cached_entries_));
}
void RenderProcessPreferences::UpdateCache() {
if (!cache_needs_update_)
return;
cached_entries_.Clear();
for (const auto& iter : entries_)
cached_entries_.Append(iter.second->CreateDeepCopy());
cache_needs_update_ = false;
}
} // namespace atom

View File

@@ -0,0 +1,61 @@
// Copyright (c) 2016 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_RENDER_PROCESS_PREFERENCES_H_
#define ATOM_BROWSER_RENDER_PROCESS_PREFERENCES_H_
#include <memory>
#include <unordered_map>
#include "base/callback.h"
#include "base/values.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
namespace content {
class RenderProcessHost;
}
namespace atom {
// Sets user preferences for render processes.
class RenderProcessPreferences : public content::NotificationObserver {
public:
using Predicate = base::Callback<bool(content::RenderProcessHost*)>;
// The |predicate| is used to determine whether to set preferences for a
// render process.
explicit RenderProcessPreferences(const Predicate& predicate);
virtual ~RenderProcessPreferences();
int AddEntry(const base::DictionaryValue& entry);
void RemoveEntry(int id);
private:
// content::NotificationObserver:
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
void UpdateCache();
// Manages our notification registrations.
content::NotificationRegistrar registrar_;
Predicate predicate_;
int next_id_;
std::unordered_map<int, std::unique_ptr<base::DictionaryValue>> entries_;
// We need to convert the |entries_| to ListValue for multiple times, this
// caches is only updated when we are sending messages.
bool cache_needs_update_;
base::ListValue cached_entries_;
DISALLOW_COPY_AND_ASSIGN(RenderProcessPreferences);
};
} // namespace atom
#endif // ATOM_BROWSER_RENDER_PROCESS_PREFERENCES_H_

View File

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

View File

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

View File

@@ -32,7 +32,7 @@ void SetPlatformAccelerator(ui::Accelerator* accelerator) {
NSString* characters =
[[[NSString alloc] initWithCharacters:&character length:1] autorelease];
scoped_ptr<ui::PlatformAccelerator> platform_accelerator(
std::unique_ptr<ui::PlatformAccelerator> platform_accelerator(
new ui::PlatformAcceleratorCocoa(characters, modifiers));
accelerator->set_platform_accelerator(std::move(platform_accelerator));
}

View File

@@ -37,6 +37,7 @@ typedef base::Callback<void(
bool ShowOpenDialog(atom::NativeWindow* parent_window,
const std::string& title,
const std::string& button_label,
const base::FilePath& default_path,
const Filters& filters,
int properties,
@@ -44,6 +45,7 @@ bool ShowOpenDialog(atom::NativeWindow* parent_window,
void ShowOpenDialog(atom::NativeWindow* parent_window,
const std::string& title,
const std::string& button_label,
const base::FilePath& default_path,
const Filters& filters,
int properties,
@@ -51,12 +53,14 @@ void ShowOpenDialog(atom::NativeWindow* parent_window,
bool ShowSaveDialog(atom::NativeWindow* parent_window,
const std::string& title,
const std::string& button_label,
const base::FilePath& default_path,
const Filters& filters,
base::FilePath* path);
void ShowSaveDialog(atom::NativeWindow* parent_window,
const std::string& title,
const std::string& button_label,
const base::FilePath& default_path,
const Filters& filters,
const SaveDialogCallback& callback);

View File

@@ -37,12 +37,16 @@ class FileChooserDialog {
FileChooserDialog(GtkFileChooserAction action,
atom::NativeWindow* parent_window,
const std::string& title,
const std::string& button_label,
const base::FilePath& default_path,
const Filters& filters)
: dialog_scope_(parent_window),
filters_(filters) {
const char* confirm_text = GTK_STOCK_OK;
if (action == GTK_FILE_CHOOSER_ACTION_SAVE)
if (!button_label.empty())
confirm_text = button_label.c_str();
else if (action == GTK_FILE_CHOOSER_ACTION_SAVE)
confirm_text = GTK_STOCK_SAVE;
else if (action == GTK_FILE_CHOOSER_ACTION_OPEN)
confirm_text = GTK_STOCK_OPEN;
@@ -173,7 +177,7 @@ void FileChooserDialog::AddFilters(const Filters& filters) {
GtkFileFilter* gtk_filter = gtk_file_filter_new();
for (size_t j = 0; j < filter.second.size(); ++j) {
scoped_ptr<std::string> file_extension(
std::unique_ptr<std::string> file_extension(
new std::string("." + filter.second[j]));
gtk_file_filter_add_custom(
gtk_filter,
@@ -216,6 +220,7 @@ base::FilePath FileChooserDialog::AddExtensionForFilename(
bool ShowOpenDialog(atom::NativeWindow* parent_window,
const std::string& title,
const std::string& button_label,
const base::FilePath& default_path,
const Filters& filters,
int properties,
@@ -223,8 +228,8 @@ bool ShowOpenDialog(atom::NativeWindow* parent_window,
GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
if (properties & FILE_DIALOG_OPEN_DIRECTORY)
action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
FileChooserDialog open_dialog(action, parent_window, title, default_path,
filters);
FileChooserDialog open_dialog(action, parent_window, title, button_label,
default_path, filters);
if (properties & FILE_DIALOG_MULTI_SELECTIONS)
gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(open_dialog.dialog()),
TRUE);
@@ -241,6 +246,7 @@ bool ShowOpenDialog(atom::NativeWindow* parent_window,
void ShowOpenDialog(atom::NativeWindow* parent_window,
const std::string& title,
const std::string& button_label,
const base::FilePath& default_path,
const Filters& filters,
int properties,
@@ -249,7 +255,7 @@ void ShowOpenDialog(atom::NativeWindow* parent_window,
if (properties & FILE_DIALOG_OPEN_DIRECTORY)
action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
FileChooserDialog* open_dialog = new FileChooserDialog(
action, parent_window, title, default_path, filters);
action, parent_window, title, button_label, default_path, filters);
if (properties & FILE_DIALOG_MULTI_SELECTIONS)
gtk_file_chooser_set_select_multiple(
GTK_FILE_CHOOSER(open_dialog->dialog()), TRUE);
@@ -259,11 +265,12 @@ void ShowOpenDialog(atom::NativeWindow* parent_window,
bool ShowSaveDialog(atom::NativeWindow* parent_window,
const std::string& title,
const std::string& button_label,
const base::FilePath& default_path,
const Filters& filters,
base::FilePath* path) {
FileChooserDialog save_dialog(GTK_FILE_CHOOSER_ACTION_SAVE, parent_window,
title, default_path, filters);
title, button_label, default_path, filters);
gtk_widget_show_all(save_dialog.dialog());
int response = gtk_dialog_run(GTK_DIALOG(save_dialog.dialog()));
if (response == GTK_RESPONSE_ACCEPT) {
@@ -276,12 +283,13 @@ bool ShowSaveDialog(atom::NativeWindow* parent_window,
void ShowSaveDialog(atom::NativeWindow* parent_window,
const std::string& title,
const std::string& button_label,
const base::FilePath& default_path,
const Filters& filters,
const SaveDialogCallback& callback) {
FileChooserDialog* save_dialog = new FileChooserDialog(
GTK_FILE_CHOOSER_ACTION_SAVE, parent_window, title, default_path,
filters);
GTK_FILE_CHOOSER_ACTION_SAVE, parent_window, title, button_label,
default_path, filters);
save_dialog->RunSaveAsynchronous(callback);
}

View File

@@ -45,11 +45,15 @@ void SetAllowedFileTypes(NSSavePanel* dialog, const Filters& filters) {
void SetupDialog(NSSavePanel* dialog,
const std::string& title,
const std::string& button_label,
const base::FilePath& default_path,
const Filters& filters) {
if (!title.empty())
[dialog setTitle:base::SysUTF8ToNSString(title)];
if (!button_label.empty())
[dialog setPrompt:base::SysUTF8ToNSString(button_label)];
NSString* default_dir = nil;
NSString* default_filename = nil;
if (!default_path.empty()) {
@@ -114,6 +118,7 @@ void ReadDialogPaths(NSOpenPanel* dialog, std::vector<base::FilePath>* paths) {
bool ShowOpenDialog(atom::NativeWindow* parent_window,
const std::string& title,
const std::string& button_label,
const base::FilePath& default_path,
const Filters& filters,
int properties,
@@ -121,7 +126,7 @@ bool ShowOpenDialog(atom::NativeWindow* parent_window,
DCHECK(paths);
NSOpenPanel* dialog = [NSOpenPanel openPanel];
SetupDialog(dialog, title, default_path, filters);
SetupDialog(dialog, title, button_label, default_path, filters);
SetupDialogForProperties(dialog, properties);
int chosen = RunModalDialog(dialog, parent_window);
@@ -134,13 +139,14 @@ bool ShowOpenDialog(atom::NativeWindow* parent_window,
void ShowOpenDialog(atom::NativeWindow* parent_window,
const std::string& title,
const std::string& button_label,
const base::FilePath& default_path,
const Filters& filters,
int properties,
const OpenDialogCallback& c) {
NSOpenPanel* dialog = [NSOpenPanel openPanel];
SetupDialog(dialog, title, default_path, filters);
SetupDialog(dialog, title, button_label, default_path, filters);
SetupDialogForProperties(dialog, properties);
// Duplicate the callback object here since c is a reference and gcd would
@@ -162,13 +168,14 @@ void ShowOpenDialog(atom::NativeWindow* parent_window,
bool ShowSaveDialog(atom::NativeWindow* parent_window,
const std::string& title,
const std::string& button_label,
const base::FilePath& default_path,
const Filters& filters,
base::FilePath* path) {
DCHECK(path);
NSSavePanel* dialog = [NSSavePanel savePanel];
SetupDialog(dialog, title, default_path, filters);
SetupDialog(dialog, title, button_label, default_path, filters);
int chosen = RunModalDialog(dialog, parent_window);
if (chosen == NSFileHandlingPanelCancelButton || ![[dialog URL] isFileURL])
@@ -180,12 +187,13 @@ bool ShowSaveDialog(atom::NativeWindow* parent_window,
void ShowSaveDialog(atom::NativeWindow* parent_window,
const std::string& title,
const std::string& button_label,
const base::FilePath& default_path,
const Filters& filters,
const SaveDialogCallback& c) {
NSSavePanel* dialog = [NSSavePanel savePanel];
SetupDialog(dialog, title, default_path, filters);
SetupDialog(dialog, title, button_label, default_path, filters);
__block SaveDialogCallback callback = c;

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