Compare commits

..

94 Commits

Author SHA1 Message Date
John Kleinschmidt
c30a6beece v1.6.18 2018-05-15 15:26:48 -04:00
John Kleinschmidt
1449a36d34 Merge pull request #12925 from electron/unsupported-warning_1-6-x
add end-of-support warning
2018-05-15 12:04:53 -04:00
Charles Kerr
06e375c0c2 add end-of-support warning 2018-05-14 19:15:49 -05:00
John Kleinschmidt
347f3c7dc2 v1.6.17 2018-01-31 15:12:28 -07:00
John Kleinschmidt
c29251cb9d Merge pull request #11778 from electron/parallel-releases-1-6-x
Allow multiple releases to run at once for 1-6-x
2018-01-31 13:42:38 -05:00
John Kleinschmidt
7f74a39346 Merge pull request #11786 from electron/case-insensitive-comparison-1-6-x
Do case insensitive comparisons
2018-01-31 13:38:05 -05:00
Samuel Attard
a7c8e7241b Do case insensitive comparisons 2018-01-31 10:40:24 -07:00
John Kleinschmidt
6360acb87b Allow multiple releases to run at once
Find draft release by draft flag and tag name;also backport release scripts to 1-6-x
2018-01-30 18:08:35 -07:00
John Kleinschmidt
acc04b9ca6 Backport for upload retry 2018-01-22 19:26:35 -05:00
John Kleinschmidt
fcd7692182 Bump v1.6.16 2018-01-22 17:10:13 -05:00
Aleš Pergl
ad0f44843d Disallow launching unknown apps via browser client.
CVE-2018-1000006
2018-01-22 15:26:47 -06:00
John Kleinschmidt
5a44e7c058 Bump for missing builds 2017-10-11 12:27:12 -04:00
John Kleinschmidt
bee5a70fbf Bump v1.6.15 2017-10-11 11:28:58 -04:00
John Kleinschmidt
73c4fe626b Merge pull request #10756 from electron/1-6-crankshaft-fix
Crankshaft RCE fix
2017-10-11 11:12:23 -04:00
John Kleinschmidt
befa1d9c79 Crankshaft RCE fix 2017-10-11 10:45:36 -04:00
John Kleinschmidt
40e37c68d5 Add publish-to-npm script 2017-09-28 09:20:28 -04:00
John Kleinschmidt
0c37f633b8 Remove arm64 references from prerelease check 2017-09-28 09:20:17 -04:00
John Kleinschmidt
1723c302f7 Bump for release build 2017-09-27 19:00:58 -04:00
John Kleinschmidt
f41051fe60 Merge branch 'release-1-6' of https://github.com/electron/electron into release-1-6 2017-09-27 18:55:18 -04:00
John Kleinschmidt
396a49e349 Bump for building with larger machines 2017-09-27 18:54:23 -04:00
John Kleinschmidt
482a1d2e2b Bump to add release logic to CircleCI 2017-09-27 18:50:30 -04:00
John Kleinschmidt
ca6127c802 Bump to properly set ELECTRON_RELEASE 2017-09-27 18:35:50 -04:00
John Kleinschmidt
588f906fba Bump to fix bootstrap call 2017-09-27 18:35:49 -04:00
John Kleinschmidt
14bdbbcc10 Bump to fix circleci indentation 2017-09-27 18:35:49 -04:00
John Kleinschmidt
a0cec63c91 Bump for circleCI config update 2017-09-27 18:35:49 -04:00
John Kleinschmidt
233fdeaef0 Bump to add release logic to CircleCI 2017-09-27 18:35:49 -04:00
John Kleinschmidt
54b12ba15d Bump to add prerelease check 2017-09-27 18:35:49 -04:00
John Kleinschmidt
cfa4fbc9c1 Change GitHub upload to use JS GitHub lib 2017-09-27 18:35:49 -04:00
John Kleinschmidt
4b03f5b87e Bump v1.6.14 2017-09-27 18:35:49 -04:00
John Kleinschmidt
acf6518317 Bump for building with larger machines 2017-09-27 17:44:32 -04:00
John Kleinschmidt
f7e07205b4 Bump to properly set ELECTRON_RELEASE 2017-09-27 15:59:45 -04:00
John Kleinschmidt
248c1e1118 Bump to fix bootstrap call 2017-09-27 15:37:49 -04:00
John Kleinschmidt
cb251892c2 Bump to fix circleci indentation 2017-09-27 15:30:59 -04:00
John Kleinschmidt
5fcf20a7aa Bump for circleCI config update 2017-09-27 15:27:27 -04:00
John Kleinschmidt
2e38f9ca1c Bump to add release logic to CircleCI 2017-09-27 14:42:09 -04:00
Birunthan Mohanathas
ece433f766 Merge pull request #10631 from electron/squirrel-avoid-double-update-1-6
Use Squirrel.Windows --checkForUpdate (1.6.x)
2017-09-27 21:20:30 +03:00
J.M
f6005ce28d Use Squirrel.Windows --checkForUpdate
This cherry-picks #10483 to fix #5057.
2017-09-27 20:35:08 +03:00
John Kleinschmidt
93cea48d04 Bump to add prerelease check 2017-09-27 11:27:36 -04:00
John Kleinschmidt
4fb6bef8ed Bump for release build 2017-09-24 14:41:19 +09:00
John Kleinschmidt
f4fd62db47 Change GitHub upload to use JS GitHub lib 2017-09-24 14:40:37 +09:00
John Kleinschmidt
2ede7d9ec9 Bump v1.6.14 2017-09-24 14:14:03 +09:00
John Kleinschmidt
7a67c36cdb Disable flaky cert tests 2017-09-24 10:09:46 +09:00
John Kleinschmidt
1131b5ae2f Merge pull request #10587 from electron/turbofan-fix
Apply turbofan-fix
2017-09-23 18:14:50 +09:00
John Kleinschmidt
9429eea12c Apply turbofan-fix 2017-09-23 16:54:55 +09:00
John Kleinschmidt
a0b04005a9 Fix CircleCI test step 2017-09-13 11:24:53 -04:00
John Kleinschmidt
a7d3cea6e8 Add CircleCI config 2017-09-13 10:36:20 -04:00
John Kleinschmidt
f2fe287b34 Bump v1.6.13 2017-09-06 13:17:43 -04:00
John Kleinschmidt
47242064ba Fix syntax error 2017-09-06 12:54:26 -04:00
John Kleinschmidt
da73284515 Make sure future 1.6 releases are tagged correctly 2017-09-06 12:30:47 -04:00
John Kleinschmidt
9b74f25770 Backport macOS IME backspace fix for 1.6.x (#10450) 2017-09-06 11:25:14 -04:00
Zeke Sikelianos
dcb5a34922 Bump empty commit 2017-08-03 13:31:21 -07:00
Zeke Sikelianos
df55c1e717 Bump a third time 2017-08-03 10:43:29 -07:00
Zeke Sikelianos
a62f13856b Bump v1.6.12 2017-08-03 10:38:07 -07:00
Zeke Sikelianos
c83ff61fdf lock typescript generator to older version 2017-08-03 10:37:45 -07:00
John Kleinschmidt
2b83512c44 Merge pull request #10166 from electron/1-6-fixes
Backport fixes to 1.6
2017-08-02 16:58:14 -04:00
John Kleinschmidt
c12f7d3132 Fix commitText invocation 2017-08-02 09:45:42 -04:00
Zeke Sikelianos
9c0a8ab168 point to newer 1-6-fixes commit 2017-08-01 15:57:24 -07:00
Zeke Sikelianos
8842b04567 Merge pull request #10164 from electron/backport-10070-1-6-x
Backport 10070 to 1.6
2017-08-01 10:10:18 -07:00
Zeke Sikelianos
0573919fd3 use latest commit from libcc electron-1-6-x branch 2017-07-31 16:01:36 -07:00
Cheng Zhao
5253c0a816 Leak the Node environment when context is released 2017-07-31 13:23:35 -07:00
John Kleinschmidt
05b412313d Backport 10070 to 1.6 2017-07-31 10:20:49 -04:00
Kevin Sawicki
0428632a4e Bump v1.6.11 2017-05-25 10:56:30 -07:00
Kevin Sawicki
855d2c4b20 Merge pull request #9586 from electron/upgrade-libcc
Upgrade libcc with 1.6.x fixes
2017-05-25 10:55:25 -07:00
Kevin Sawicki
f0402be869 Enable verbose bootstrap on CI 2017-05-25 10:25:51 -07:00
Kevin Sawicki
5a1e3fc0f3 Upgrade to electron/libchromiumcontent@e2ec6935 2017-05-25 09:51:16 -07:00
Kevin Sawicki
01c31ee924 Merge pull request #9564 from rreimann/pdf-plugins-preference-backport
Backport suppress dispatching to PDF viewer if plugins are disabled to 1.6.x
2017-05-24 09:04:33 -07:00
rreimann
c29316b568 Remove superfluous method 2017-05-24 07:09:51 +02:00
Kevin Sawicki
21f15fa87e Delete mock.pdf after download completes
(cherry picked from commit 647e88da5a)
2017-05-23 14:22:26 +02:00
rreimann
ab95ecda42 Fix naming and formatting
(cherry picked from commit 25015c4c63)
2017-05-23 14:22:08 +02:00
rreimann
456e83f286 Extract common code into IsPreferenceEnabled method
(cherry picked from commit 791486433d)
2017-05-23 14:21:53 +02:00
rreimann
1612ebc539 Move preferences check to OnPdfResourceIntercepted
(cherry picked from commit 65da983ccb)
2017-05-23 14:21:35 +02:00
rreimann
1ddb8a8bf1 Add new test and enable plugins for existing tests
(cherry picked from commit 13665090d5)
2017-05-23 14:21:09 +02:00
rreimann
bbcdbc2e7c Fix linting violations
(cherry picked from commit 7982754958)
2017-05-23 14:20:41 +02:00
rreimann
d94bbd1573 Suppress pdf plugin dispatch if plugins are disabled
(cherry picked from commit 1b75e45a62)
2017-05-23 14:20:00 +02:00
Kevin Sawicki
583e14efcd Merge pull request #9514 from electron/disable-crash-specs-on-linux
Backport disabling crash specs on linux to 1.6
2017-05-17 15:25:14 -07:00
Kevin Sawicki
b96803e3a0 Disable crashReporter specs on Linux CI 2017-05-17 15:00:39 -07:00
Kevin Sawicki
c03cb11aaf Merge pull request #9505 from electron/backport-sandbox-remote-exception-fix
Backport sandbox remote exception fix
2017-05-17 11:19:25 -07:00
Kevin Sawicki
5de881e668 Merge pull request #9499 from electron/node-cert-patch
Upgrade node for StartCom/WoSign cert rejection
2017-05-17 11:07:21 -07:00
Thiago de Arruda
964505398d Add test for #9387 2017-05-17 07:29:22 -03:00
Thiago de Arruda
16f2958ad7 Fix how rpc-server releases references after page reload
In addition to listening for "render-view-deleted", listen for
"ELECTRON_BROWSER_CONTEXT_RELEASE" synchronous message, which is sent by the
remote module when the page is about to be navigated.

This is required to allow child windows running in the same renderer to
correctly manage remote object references, since `render-view-deleted` is only
called when the renderer exits.

Close #9387
2017-05-17 07:29:06 -03:00
Kevin Sawicki
332b92ebab Upgrade node for StartCom/WoSign cert rejection 2017-05-16 16:29:43 -07:00
Kevin Sawicki
b9f66a342c Bump v1.6.10 2017-05-16 10:38:35 -07:00
Kevin Sawicki
23ce796450 Merge pull request #9484 from electron/1-6-x-typescript-backport
backport electron.d.ts fixes 1.6
2017-05-16 10:15:29 -07:00
Samuel Attard
df6d316dc2 Fix webcontents capital 2017-05-15 15:16:22 -07:00
Kevin Sawicki
82a93ce645 Correct property name to pid 2017-05-15 14:19:02 -07:00
Kevin Sawicki
5ceaca66f5 fix setAutoResize options 2017-05-15 14:18:44 -07:00
Kevin Sawicki
4c0e35776b fix setAutoResize options 2017-05-15 14:18:02 -07:00
Birunthan Mohanathas
cc1f213d84 bump versions of electron-docs-linter and electron-typescript-definitions 2017-05-15 14:04:22 -07:00
Birunthan Mohanathas
4c18037e6a Fix copy paste typos in BrowserView docs 2017-05-15 14:02:05 -07:00
Samuel Attard
7f0ccdadcd Fix createFromDataURL return type
Fixes #9469
2017-05-15 14:02:00 -07:00
Birunthan Mohanathas
8ac9499b45 Make docs for webview.findInPage and webContents.findInPage consistent 2017-05-15 14:01:55 -07:00
Birunthan Mohanathas
8094d68acc Fix postData type definition in docs 2017-05-15 14:01:50 -07:00
Samuel Attard
80066c22b2 Fix return type of makeSingleInstance 2017-05-15 14:01:45 -07:00
Zeke Sikelianos
8f78f3b253 add npm scripts for convenience 2017-05-15 14:01:34 -07:00
500 changed files with 6504 additions and 21662 deletions

212
.circleci/config.yml Normal file
View File

@@ -0,0 +1,212 @@
version: 2
jobs:
electron-linux-arm:
docker:
- image: electronbuilds/electron:0.0.4
environment:
TARGET_ARCH: arm
resource_class: 2xlarge
steps:
- checkout
- run:
name: Check for release
command: |
if [ -n "${RUN_RELEASE_BUILD}" ]; then
echo 'release build triggered from api'
echo 'export ELECTRON_RELEASE=1 TRIGGERED_BY_API=1' >> $BASH_ENV
fi
- run:
name: Bootstrap
command: |
if [ "$ELECTRON_RELEASE" == "1" ]; then
echo 'Bootstrapping Electron for release build'
script/bootstrap.py --target_arch=$TARGET_ARCH
else
echo 'Bootstrapping Electron for debug build'
script/bootstrap.py --target_arch=$TARGET_ARCH --dev
fi
- run: npm run lint
- run:
name: Build
command: |
if [ "$ELECTRON_RELEASE" == "1" ]; then
echo 'Building Electron for release'
script/build.py -c R
else
echo 'Building Electron for debug'
script/build.py -c D
fi
- run:
name: Create distribution
command: |
if [ "$ELECTRON_RELEASE" == "1" ]; then
echo 'Creating Electron release distribution'
script/create-dist.py
else
echo 'Skipping create distribution because build is not for release'
fi
- run:
name: Upload distribution
command: |
if [ "$ELECTRON_RELEASE" == "1" ] && [ "$TRIGGERED_BY_API" != "1" ]; then
echo 'Uploading Electron release distribution to github releases'
script/upload.py
elif [ "$ELECTRON_RELEASE" == "1" ] && [ "$TRIGGERED_BY_API" == "1" ]; then
echo 'Uploading Electron release distribution to s3'
script/upload.py --upload_to_s3
else
echo 'Skipping upload distribution because build is not for release'
fi
electron-linux-ia32:
docker:
- image: electronbuilds/electron:0.0.4
environment:
TARGET_ARCH: ia32
resource_class: xlarge
steps:
- checkout
- run:
name: Check for release
command: |
if [ -n "${RUN_RELEASE_BUILD}" ]; then
echo 'release build triggered from api'
echo 'export ELECTRON_RELEASE=1 TRIGGERED_BY_API=1' >> $BASH_ENV
fi
- run:
name: Bootstrap
command: |
if [ "$ELECTRON_RELEASE" == "1" ]; then
echo 'Bootstrapping Electron for release build'
script/bootstrap.py --target_arch=$TARGET_ARCH
else
echo 'Bootstrapping Electron for debug build'
script/bootstrap.py --target_arch=$TARGET_ARCH --dev
fi
- run: npm run lint
- run:
name: Build
command: |
if [ "$ELECTRON_RELEASE" == "1" ]; then
echo 'Building Electron for release'
script/build.py -c R
else
echo 'Building Electron for debug'
script/build.py -c D
fi
- run:
name: Create distribution
command: |
if [ "$ELECTRON_RELEASE" == "1" ]; then
echo 'Creating Electron release distribution'
script/create-dist.py
else
echo 'Skipping create distribution because build is not for release'
fi
- run:
name: Upload distribution
command: |
if [ "$ELECTRON_RELEASE" == "1" ] && [ "$TRIGGERED_BY_API" != "1" ]; then
echo 'Uploading Electron release distribution to github releases'
script/upload.py
elif [ "$ELECTRON_RELEASE" == "1" ] && [ "$TRIGGERED_BY_API" == "1" ]; then
echo 'Uploading Electron release distribution to s3'
script/upload.py --upload_to_s3
else
echo 'Skipping upload distribution because build is not for release'
fi
electron-linux-x64:
docker:
- image: electronbuilds/electron:0.0.4
environment:
TARGET_ARCH: x64
DISPLAY: ':99.0'
resource_class: xlarge
steps:
- checkout
- run:
name: Setup for headless testing
command: sh -e /etc/init.d/xvfb start
- run:
name: Check for release
command: |
if [ -n "${RUN_RELEASE_BUILD}" ]; then
echo 'release build triggered from api'
echo 'export ELECTRON_RELEASE=1 TRIGGERED_BY_API=1' >> $BASH_ENV
fi
- run:
name: Bootstrap
command: |
if [ "$ELECTRON_RELEASE" == "1" ]; then
echo 'Bootstrapping Electron for release build'
script/bootstrap.py --target_arch=$TARGET_ARCH
else
echo 'Bootstrapping Electron for debug build'
script/bootstrap.py --target_arch=$TARGET_ARCH --dev
fi
- run: npm run lint
- run:
name: Build
command: |
if [ "$ELECTRON_RELEASE" == "1" ]; then
echo 'Building Electron for release'
script/build.py -c R
else
echo 'Building Electron for debug'
script/build.py -c D
fi
- run:
name: Create distribution
command: |
if [ "$ELECTRON_RELEASE" == "1" ]; then
echo 'Creating Electron release distribution'
script/create-dist.py
else
echo 'Skipping create distribution because build is not for release'
fi
- run:
name: Upload distribution
command: |
if [ "$ELECTRON_RELEASE" == "1" ] && [ "$TRIGGERED_BY_API" != "1" ]; then
echo 'Uploading Electron release distribution to github releases'
script/upload.py
elif [ "$ELECTRON_RELEASE" == "1" ] && [ "$TRIGGERED_BY_API" == "1" ]; then
echo 'Uploading Electron release distribution to s3'
script/upload.py --upload_to_s3
else
echo 'Skipping upload distribution because build is not for release'
fi
- run:
name: Test
environment:
MOCHA_FILE: junit/test-results.xml
MOCHA_REPORTER: mocha-junit-reporter
command: |
if [ "$ELECTRON_RELEASE" != "1" ]; then
echo 'Testing Electron debug build'
mkdir junit
script/test.py --ci --rebuild_native_modules
else
echo 'Skipping testing on release build'
fi
- run:
name: Verify FFmpeg
command: |
if [ "$ELECTRON_RELEASE" != "1" ]; then
echo 'Verifying ffmpeg on debug build'
script/verify-ffmpeg.py
else
echo 'Skipping verify ffmpeg on release build'
fi
workflows:
version: 2
build-arm:
jobs:
- electron-linux-arm
build-ia32:
jobs:
- electron-linux-ia32
build-x64:
jobs:
- electron-linux-x64

13
.gitignore vendored
View File

@@ -5,11 +5,7 @@
/dist/
/external_binaries/
/out/
/vendor/download/
/vendor/debian_jessie_amd64-sysroot/
/vendor/debian_jessie_arm-sysroot/
/vendor/debian_jessie_arm64-sysroot/
/vendor/debian_jessie_i386-sysroot/
/vendor/brightray/vendor/download/
/vendor/debian_wheezy_amd64-sysroot/
/vendor/debian_wheezy_arm-sysroot/
/vendor/debian_wheezy_i386-sysroot/
@@ -31,10 +27,3 @@ node_modules/
*.vcxproj.filters
*.sln
*.log
/brightray/brightray.opensdf
/brightray/brightray.sdf
/brightray/brightray.sln
/brightray/brightray.vcxproj*
/brightray/brightray.suo
/brightray/brightray.v12.suo
/brightray/brightray.xcodeproj/

9
.gitmodules vendored
View File

@@ -1,3 +1,6 @@
[submodule "vendor/brightray"]
path = vendor/brightray
url = https://github.com/electron/brightray.git
[submodule "vendor/node"]
path = vendor/node
url = https://github.com/electron/node.git
@@ -22,9 +25,3 @@
[submodule "vendor/pdf_viewer"]
path = vendor/pdf_viewer
url = https://github.com/electron/pdf-viewer.git
[submodule "vendor/gyp"]
path = vendor/gyp
url = https://github.com/electron/gyp
[submodule "vendor/libchromiumcontent"]
path = vendor/libchromiumcontent
url = https://github.com/electron/libchromiumcontent

View File

@@ -1 +1 @@
v7.9.0
v7.4.0

View File

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

View File

@@ -5,7 +5,7 @@
[![devDependency Status](https://david-dm.org/electron/electron/dev-status.svg)](https://david-dm.org/electron/electron?type=dev)
[![Join the Electron Community on Slack](http://atom-slack.herokuapp.com/badge.svg)](http://atom-slack.herokuapp.com/)
:memo: Available Translations: [Korean](https://github.com/electron/electron/tree/master/docs-translations/ko-KR/project/README.md) | [Simplified Chinese](https://github.com/electron/electron/tree/master/docs-translations/zh-CN/project/README.md) | [Brazilian Portuguese](https://github.com/electron/electron/tree/master/docs-translations/pt-BR/project/README.md) | [Traditional Chinese](https://github.com/electron/electron/tree/master/docs-translations/zh-TW/project/README.md) | [Spanish](https://github.com/electron/electron/tree/master/docs-translations/es/project/README.md) | [Turkish](https://github.com/electron/electron/tree/master/docs-translations/tr-TR/project/README.md) | [German](https://github.com/electron/electron/tree/master/docs-translations/de-DE/project/README.md)
:memo: Available Translations: [Korean](https://github.com/electron/electron/tree/master/docs-translations/ko-KR/project/README.md) | [Simplified Chinese](https://github.com/electron/electron/tree/master/docs-translations/zh-CN/project/README.md) | [Brazilian Portuguese](https://github.com/electron/electron/tree/master/docs-translations/pt-BR/project/README.md) | [Traditional Chinese](https://github.com/electron/electron/tree/master/docs-translations/zh-TW/project/README.md) | [Spanish](https://github.com/electron/electron/tree/master/docs-translations/es/project/README.md) | [Turkish](https://github.com/electron/electron/tree/master/docs-translations/tr-TR/project/README.md)
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
@@ -54,11 +54,10 @@ contains documents describing how to build and contribute to Electron.
- [Simplified Chinese](https://github.com/electron/electron/tree/master/docs-translations/zh-CN)
- [Traditional Chinese](https://github.com/electron/electron/tree/master/docs-translations/zh-TW)
- [Turkish](https://github.com/electron/electron/tree/master/docs-translations/tr-TR)
- [Thai](https://github.com/electron/electron/tree/master/docs-translations/th-TH)
- [Thai](https://github.com/electron/electron/tree/master/docs-Translations/th-TH)
- [Ukrainian](https://github.com/electron/electron/tree/master/docs-translations/uk-UA)
- [Russian](https://github.com/electron/electron/tree/master/docs-translations/ru-RU)
- [French](https://github.com/electron/electron/tree/master/docs-translations/fr-FR)
- [Indonesian](https://github.com/electron/electron/tree/master/docs-translations/id)
## Quick Start

View File

@@ -1,25 +0,0 @@
# appveyor file
# http://www.appveyor.com/docs/appveyor-yml
version: "{build}"
os: Visual Studio 2015
init:
- git config --global core.autocrlf input
platform:
- x86
- x64
install:
- cmd: SET PATH=C:\Program Files (x86)\MSBuild\14.0\bin\;%PATH%
- cmd: SET PATH=C:\python27;%PATH%
- cmd: python script/cibuild
branches:
only:
- master
# disable build and test pahses
build: off
test: off

View File

@@ -93,9 +93,9 @@ content::PepperPluginInfo CreateWidevineCdmInfo(const base::FilePath& path,
std::vector<std::string> codecs;
codecs.push_back(kCdmSupportedCodecVp8);
codecs.push_back(kCdmSupportedCodecVp9);
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
#if defined(USE_PROPRIETARY_CODECS)
codecs.push_back(kCdmSupportedCodecAvc1);
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
#endif // defined(USE_PROPRIETARY_CODECS)
std::string codec_string = base::JoinString(
codecs, std::string(1, kCdmSupportedCodecsValueDelimiter));
widevine_cdm_mime_type.additional_param_names.push_back(
@@ -198,19 +198,11 @@ base::string16 AtomContentClient::GetLocalizedString(int message_id) const {
return l10n_util::GetStringUTF16(message_id);
}
void AtomContentClient::AddAdditionalSchemes(Schemes* schemes) {
schemes->standard_schemes.push_back("chrome-extension");
std::vector<std::string> splited;
ConvertStringWithSeparatorToVector(&splited, ",",
switches::kRegisterServiceWorkerSchemes);
for (const std::string& scheme : splited)
schemes->service_worker_schemes.push_back(scheme);
schemes->service_worker_schemes.push_back(url::kFileScheme);
ConvertStringWithSeparatorToVector(&splited, ",", switches::kSecureSchemes);
for (const std::string& scheme : splited)
schemes->secure_schemes.push_back(scheme);
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});
}
void AtomContentClient::AddPepperPlugins(
@@ -222,4 +214,25 @@ void AtomContentClient::AddPepperPlugins(
ComputeBuiltInPlugins(plugins);
}
void AtomContentClient::AddServiceWorkerSchemes(
std::set<std::string>* service_worker_schemes) {
std::vector<std::string> schemes;
ConvertStringWithSeparatorToVector(&schemes, ",",
switches::kRegisterServiceWorkerSchemes);
for (const std::string& scheme : schemes)
service_worker_schemes->insert(scheme);
service_worker_schemes->insert(url::kFileScheme);
}
void AtomContentClient::AddSecureSchemesAndOrigins(
std::set<std::string>* secure_schemes,
std::set<GURL>* secure_origins) {
std::vector<std::string> schemes;
ConvertStringWithSeparatorToVector(&schemes, ",", switches::kSecureSchemes);
for (const std::string& scheme : schemes)
secure_schemes->insert(scheme);
}
} // namespace atom

View File

@@ -23,9 +23,17 @@ class AtomContentClient : public brightray::ContentClient {
std::string GetProduct() const override;
std::string GetUserAgent() const override;
base::string16 GetLocalizedString(int message_id) const override;
void AddAdditionalSchemes(Schemes* schemes) 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;
void AddServiceWorkerSchemes(
std::set<std::string>* service_worker_schemes) override;
void AddSecureSchemesAndOrigins(
std::set<std::string>* secure_schemes,
std::set<GURL>* secure_origins) override;
private:
DISALLOW_COPY_AND_ASSIGN(AtomContentClient);

View File

@@ -10,7 +10,7 @@
#if defined(OS_MACOSX)
extern "C" {
__attribute__((visibility("default")))
int AtomMain(int argc, const char* argv[]);
int AtomMain(int argc, char* argv[]);
__attribute__((visibility("default")))
int AtomInitializeICUandStartNode(int argc, char *argv[]);

View File

@@ -15,11 +15,11 @@
#include "content/public/app/content_main.h"
#if defined(OS_MACOSX)
int AtomMain(int argc, const char* argv[]) {
int AtomMain(int argc, char* argv[]) {
atom::AtomMainDelegate delegate;
content::ContentMainParams params(&delegate);
params.argc = argc;
params.argv = argv;
params.argv = const_cast<const char**>(argv);
atom::AtomCommandLine::Init(argc, argv);
return content::ContentMain(params);
}

View File

@@ -4,7 +4,8 @@
#include "atom/app/atom_main.h"
#include <stdlib.h>
#include <cstdlib>
#include <vector>
#if defined(OS_WIN)
#include <windows.h> // windows.h must be included first
@@ -14,9 +15,11 @@
#include <tchar.h>
#include "atom/app/atom_main_delegate.h"
#include "atom/app/command_line_args.h"
#include "atom/common/crash_reporter/win/crash_service_main.h"
#include "base/environment.h"
#include "base/process/launch.h"
#include "base/strings/utf_string_conversions.h"
#include "base/win/windows_version.h"
#include "content/public/app/sandbox_helper_win.h"
#include "sandbox/win/src/sandbox_types.h"
@@ -51,8 +54,39 @@ bool IsEnvSet(const char* name) {
#if defined(OS_WIN)
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
int argc = 0;
wchar_t** wargv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
struct Arguments {
int argc = 0;
wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
~Arguments() { LocalFree(argv); }
} arguments;
if (!arguments.argv)
return -1;
#ifdef _DEBUG
// Don't display assert dialog boxes in CI test runs
static const auto kCI = "ELECTRON_CI";
bool is_ci = IsEnvSet(kCI);
if (!is_ci) {
for (int i = 0; i < arguments.argc; ++i) {
if (!_wcsicmp(arguments.argv[i], L"--ci")) {
is_ci = true;
_putenv_s(kCI, "1"); // set flag for child processes
break;
}
}
}
if (is_ci) {
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
_set_error_mode(_OUT_TO_STDERR);
}
#endif
bool run_as_node = IsEnvSet(kRunAsNode);
@@ -60,49 +94,24 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
if (run_as_node || !IsEnvSet("ELECTRON_NO_ATTACH_CONSOLE"))
base::RouteStdioToConsole(false);
// Convert argv to to UTF8
char** argv = new char*[argc];
for (int i = 0; i < argc; i++) {
// Compute the size of the required buffer
DWORD size = WideCharToMultiByte(CP_UTF8,
0,
wargv[i],
-1,
NULL,
0,
NULL,
NULL);
if (size == 0) {
// This should never happen.
fprintf(stderr, "Could not convert arguments to utf8.");
exit(1);
}
// Do the actual conversion
argv[i] = new char[size];
DWORD result = WideCharToMultiByte(CP_UTF8,
0,
wargv[i],
-1,
argv[i],
size,
NULL,
NULL);
if (result == 0) {
// This should never happen.
fprintf(stderr, "Could not convert arguments to utf8.");
exit(1);
}
}
if (run_as_node) {
// Now that argv conversion is done, we can finally start.
std::vector<char*> argv(arguments.argc);
std::transform(
arguments.argv, arguments.argv + arguments.argc, argv.begin(),
[](auto& a) { return _strdup(base::WideToUTF8(a).c_str()); });
base::AtExitManager atexit_manager;
base::i18n::InitializeICU();
return atom::NodeMain(argc, argv);
auto ret = atom::NodeMain(argv.size(), argv.data());
std::for_each(argv.begin(), argv.end(), free);
return ret;
} else if (IsEnvSet("ELECTRON_INTERNAL_CRASH_SERVICE")) {
return crash_service::Main(cmd);
}
if (!atom::CheckCommandLineArguments(arguments.argc, arguments.argv))
return -1;
sandbox::SandboxInterfaceInfo sandbox_info = {0};
content::InitializeSandboxInfo(&sandbox_info);
atom::AtomMainDelegate delegate;
@@ -110,33 +119,32 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
content::ContentMainParams params(&delegate);
params.instance = instance;
params.sandbox_info = &sandbox_info;
atom::AtomCommandLine::Init(argc, argv);
atom::AtomCommandLine::InitW(argc, wargv);
atom::AtomCommandLine::Init(arguments.argc, arguments.argv);
return content::ContentMain(params);
}
#elif defined(OS_LINUX) // defined(OS_WIN)
int main(int argc, const char* argv[]) {
int main(int argc, char* argv[]) {
if (IsEnvSet(kRunAsNode)) {
base::i18n::InitializeICU();
base::AtExitManager atexit_manager;
return atom::NodeMain(argc, const_cast<char**>(argv));
return atom::NodeMain(argc, argv);
}
atom::AtomMainDelegate delegate;
content::ContentMainParams params(&delegate);
params.argc = argc;
params.argv = argv;
params.argv = const_cast<const char**>(argv);
atom::AtomCommandLine::Init(argc, argv);
return content::ContentMain(params);
}
#else // defined(OS_LINUX)
int main(int argc, const char* argv[]) {
int main(int argc, char* argv[]) {
if (IsEnvSet(kRunAsNode)) {
return AtomInitializeICUandStartNode(argc, const_cast<char**>(argv));
return AtomInitializeICUandStartNode(argc, argv);
}
return AtomMain(argc, argv);

View File

@@ -126,15 +126,13 @@ void AtomMainDelegate::PreSandboxStartup() {
if (!IsBrowserProcess(command_line))
return;
if (!command_line->HasSwitch(switches::kEnableMixedSandbox)) {
if (command_line->HasSwitch(switches::kEnableSandbox)) {
// Disable setuid sandbox since it is not longer required on
// linux(namespace sandbox is available on most distros).
command_line->AppendSwitch(::switches::kDisableSetuidSandbox);
} else {
// Disable renderer sandbox for most of node's functions.
command_line->AppendSwitch(::switches::kNoSandbox);
}
if (command_line->HasSwitch(switches::kEnableSandbox)) {
// Disable setuid sandbox since it is not longer required on linux(namespace
// sandbox is available on most distros).
command_line->AppendSwitch(::switches::kDisableSetuidSandbox);
} else {
// Disable renderer sandbox for most of node's functions.
command_line->AppendSwitch(::switches::kNoSandbox);
}
// Allow file:// URIs to read other file:// URIs by default.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,17 @@
// Copyright (c) 2018 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_APP_COMMAND_LINE_ARGS_H_
#define ATOM_APP_COMMAND_LINE_ARGS_H_
#include "base/command_line.h"
namespace atom {
bool CheckCommandLineArguments(int argc, base::CommandLine::CharType** argv);
} // namespace atom
#endif // ATOM_APP_COMMAND_LINE_ARGS_H_

View File

@@ -51,9 +51,10 @@ int NodeMain(int argc, char *argv[]) {
&isolate_data, gin_env.context(), argc, argv,
exec_argc, exec_argv);
// Enable support for v8 inspector.
NodeDebugger node_debugger(env);
node_debugger.Start();
// Start our custom debugger implementation.
NodeDebugger node_debugger(gin_env.isolate());
if (node_debugger.IsRunning())
env->AssignToContext(v8::Debug::GetDebugContext(gin_env.isolate()));
mate::Dictionary process(gin_env.isolate(), env->process_object());
#if defined(OS_WIN)

View File

@@ -29,15 +29,12 @@
#include "base/files/file_util.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/sys_info.h"
#include "brightray/browser/brightray_paths.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/icon_manager.h"
#include "chrome/common/chrome_paths.h"
#include "content/browser/gpu/compositor_util.h"
#include "content/public/browser/browser_accessibility_state.h"
#include "content/public/browser/browser_child_process_host.h"
#include "content/public/browser/child_process_data.h"
#include "content/public/browser/client_certificate_delegate.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/render_frame_host.h"
@@ -467,8 +464,8 @@ int ImportIntoCertStore(
if (!cert_path.empty()) {
if (base::ReadFileToString(base::FilePath(cert_path), &file_data)) {
auto module = model->cert_db()->GetPrivateSlot();
rv = model->ImportFromPKCS12(module.get(),
auto module = model->cert_db()->GetPublicModule();
rv = model->ImportFromPKCS12(module,
file_data,
password,
true,
@@ -508,14 +505,6 @@ App::App(v8::Isolate* isolate) {
static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())->set_delegate(this);
Browser::Get()->AddObserver(this);
content::GpuDataManager::GetInstance()->AddObserver(this);
content::BrowserChildProcessObserver::Add(this);
base::ProcessId pid = base::GetCurrentProcId();
std::unique_ptr<atom::ProcessMetric> process_metric(
new atom::ProcessMetric(
content::PROCESS_TYPE_BROWSER,
pid,
base::ProcessMetrics::CreateCurrentProcessMetrics()));
app_metrics_[pid] = std::move(process_metric);
Init(isolate);
}
@@ -524,7 +513,6 @@ App::~App() {
nullptr);
Browser::Get()->RemoveObserver(this);
content::GpuDataManager::GetInstance()->RemoveObserver(this);
content::BrowserChildProcessObserver::Remove(this);
}
void App::OnBeforeQuit(bool* prevent_default) {
@@ -585,11 +573,6 @@ void App::OnContinueUserActivity(
const base::DictionaryValue& user_info) {
*prevent_default = Emit("continue-activity", type, user_info);
}
void App::OnNewWindowForTab() {
Emit("new-window-for-tab");
}
#endif
void App::OnLogin(LoginHandler* login_handler,
@@ -683,54 +666,6 @@ void App::OnGpuProcessCrashed(base::TerminationStatus status) {
status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED);
}
void App::BrowserChildProcessLaunchedAndConnected(
const content::ChildProcessData& data) {
ChildProcessLaunched(data.process_type, data.handle);
}
void App::BrowserChildProcessHostDisconnected(
const content::ChildProcessData& data) {
ChildProcessDisconnected(base::GetProcId(data.handle));
}
void App::BrowserChildProcessCrashed(const content::ChildProcessData& data,
int exit_code) {
ChildProcessDisconnected(base::GetProcId(data.handle));
}
void App::BrowserChildProcessKilled(const content::ChildProcessData& data,
int exit_code) {
ChildProcessDisconnected(base::GetProcId(data.handle));
}
void App::RenderProcessReady(content::RenderProcessHost* host) {
ChildProcessLaunched(content::PROCESS_TYPE_RENDERER, host->GetHandle());
}
void App::RenderProcessDisconnected(base::ProcessId host_pid) {
ChildProcessDisconnected(host_pid);
}
void App::ChildProcessLaunched(int process_type, base::ProcessHandle handle) {
auto pid = base::GetProcId(handle);
#if defined(OS_MACOSX)
std::unique_ptr<base::ProcessMetrics> metrics(
base::ProcessMetrics::CreateProcessMetrics(
handle, content::BrowserChildProcessHost::GetPortProvider()));
#else
std::unique_ptr<base::ProcessMetrics> metrics(
base::ProcessMetrics::CreateProcessMetrics(handle));
#endif
std::unique_ptr<atom::ProcessMetric> process_metric(
new atom::ProcessMetric(process_type, pid, std::move(metrics)));
app_metrics_[pid] = std::move(process_metric);
}
void App::ChildProcessDisconnected(base::ProcessId pid) {
app_metrics_.erase(pid);
}
base::FilePath App::GetAppPath() const {
return app_path_;
}
@@ -819,11 +754,7 @@ bool App::Relaunch(mate::Arguments* js_args) {
}
if (!override_argv) {
#if defined(OS_WIN)
const relauncher::StringVector& argv = atom::AtomCommandLine::wargv();
#else
const relauncher::StringVector& argv = atom::AtomCommandLine::argv();
#endif
return relauncher::RelaunchApp(argv);
}
@@ -988,78 +919,47 @@ void App::GetFileIcon(const base::FilePath& path,
}
}
std::vector<mate::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
std::vector<mate::Dictionary> App::GetAppMemoryInfo(v8::Isolate* isolate) {
AppIdProcessIterator process_iterator;
auto process_entry = process_iterator.NextProcessEntry();
std::vector<mate::Dictionary> result;
int processor_count = base::SysInfo::NumberOfProcessors();
for (const auto& process_metric : app_metrics_) {
while (process_entry != nullptr) {
int64_t pid = process_entry->pid();
auto process = base::Process::OpenWithExtraPrivileges(pid);
#if defined(OS_MACOSX)
std::unique_ptr<base::ProcessMetrics> metrics(
base::ProcessMetrics::CreateProcessMetrics(
process.Handle(), content::BrowserChildProcessHost::GetPortProvider()));
#else
std::unique_ptr<base::ProcessMetrics> metrics(
base::ProcessMetrics::CreateProcessMetrics(process.Handle()));
#endif
mate::Dictionary pid_dict = mate::Dictionary::CreateEmpty(isolate);
mate::Dictionary memory_dict = mate::Dictionary::CreateEmpty(isolate);
mate::Dictionary cpu_dict = mate::Dictionary::CreateEmpty(isolate);
memory_dict.Set("workingSetSize",
static_cast<double>(
process_metric.second->metrics->GetWorkingSetSize() >> 10));
static_cast<double>(metrics->GetWorkingSetSize() >> 10));
memory_dict.Set("peakWorkingSetSize",
static_cast<double>(
process_metric.second->metrics->GetPeakWorkingSetSize() >> 10));
static_cast<double>(metrics->GetPeakWorkingSetSize() >> 10));
size_t private_bytes, shared_bytes;
if (process_metric.second->metrics->GetMemoryBytes(&private_bytes,
&shared_bytes)) {
if (metrics->GetMemoryBytes(&private_bytes, &shared_bytes)) {
memory_dict.Set("privateBytes", static_cast<double>(private_bytes >> 10));
memory_dict.Set("sharedBytes", static_cast<double>(shared_bytes >> 10));
}
pid_dict.Set("memory", memory_dict);
cpu_dict.Set("percentCPUUsage",
process_metric.second->metrics->GetPlatformIndependentCPUUsage()
/ processor_count);
cpu_dict.Set("idleWakeupsPerSecond",
process_metric.second->metrics->GetIdleWakeupsPerSecond());
pid_dict.Set("cpu", cpu_dict);
pid_dict.Set("pid", process_metric.second->pid);
pid_dict.Set("type",
content::GetProcessTypeNameInEnglish(process_metric.second->type));
pid_dict.Set("pid", pid);
result.push_back(pid_dict);
process_entry = process_iterator.NextProcessEntry();
}
return result;
}
v8::Local<v8::Value> App::GetGPUFeatureStatus(v8::Isolate* isolate) {
auto status = content::GetFeatureStatus();
return mate::ConvertToV8(isolate,
status ? *status : base::DictionaryValue());
}
void App::EnableMixedSandbox(mate::Arguments* args) {
if (Browser::Get()->is_ready()) {
args->ThrowError("app.enableMixedSandbox() can only be called "
"before app is ready");
return;
}
auto command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(::switches::kNoSandbox)) {
#if defined(OS_WIN)
const base::CommandLine::CharType* noSandboxArg = L"--no-sandbox";
#else
const base::CommandLine::CharType* noSandboxArg = "--no-sandbox";
#endif
// Remove the --no-sandbox switch
base::CommandLine::StringVector modified_command_line;
for (auto& arg : command_line->argv()) {
if (arg.compare(noSandboxArg) != 0) {
modified_command_line.push_back(arg);
}
}
command_line->InitFromArgv(modified_command_line);
}
command_line->AppendSwitch(switches::kEnableMixedSandbox);
}
// static
mate::Handle<App> App::Create(v8::Isolate* isolate) {
return mate::CreateHandle(isolate, new App(isolate));
@@ -1132,11 +1032,7 @@ void App::BuildPrototype(
.SetMethod("disableHardwareAcceleration",
&App::DisableHardwareAcceleration)
.SetMethod("getFileIcon", &App::GetFileIcon)
.SetMethod("getAppMetrics", &App::GetAppMetrics)
.SetMethod("getGPUFeatureStatus", &App::GetGPUFeatureStatus)
.SetMethod("enableMixedSandbox", &App::EnableMixedSandbox)
// TODO(juturu): Remove in 2.0, deprecate before then with warnings
.SetMethod("getAppMemoryInfo", &App::GetAppMetrics);
.SetMethod("getAppMemoryInfo", &App::GetAppMemoryInfo);
}
} // namespace api

View File

@@ -5,9 +5,7 @@
#ifndef ATOM_BROWSER_API_ATOM_API_APP_H_
#define ATOM_BROWSER_API_ATOM_API_APP_H_
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "atom/browser/api/event_emitter.h"
@@ -19,9 +17,7 @@
#include "base/task/cancelable_task_tracker.h"
#include "chrome/browser/icon_manager.h"
#include "chrome/browser/process_singleton.h"
#include "content/public/browser/browser_child_process_observer.h"
#include "content/public/browser/gpu_data_manager_observer.h"
#include "content/public/browser/render_process_host.h"
#include "native_mate/dictionary.h"
#include "native_mate/handle.h"
#include "net/base/completion_callback.h"
@@ -44,27 +40,12 @@ namespace atom {
enum class JumpListResult : int;
#endif
struct ProcessMetric {
int type;
base::ProcessId pid;
std::unique_ptr<base::ProcessMetrics> metrics;
ProcessMetric(int type,
base::ProcessId pid,
std::unique_ptr<base::ProcessMetrics> metrics) {
this->type = type;
this->pid = pid;
this->metrics = std::move(metrics);
}
};
namespace api {
class App : public AtomBrowserClient::Delegate,
public mate::EventEmitter<App>,
public BrowserObserver,
public content::GpuDataManagerObserver,
public content::BrowserChildProcessObserver {
public content::GpuDataManagerObserver {
public:
using FileIconCallback = base::Callback<void(v8::Local<v8::Value>,
const gfx::Image&)>;
@@ -92,8 +73,6 @@ class App : public AtomBrowserClient::Delegate,
#endif
base::FilePath GetAppPath() const;
void RenderProcessReady(content::RenderProcessHost* host);
void RenderProcessDisconnected(base::ProcessId host_pid);
protected:
explicit App(v8::Isolate* isolate);
@@ -117,8 +96,6 @@ class App : public AtomBrowserClient::Delegate,
bool* prevent_default,
const std::string& type,
const base::DictionaryValue& user_info) override;
void OnNewWindowForTab() override;
#endif
// content::ContentBrowserClient:
@@ -141,20 +118,8 @@ class App : public AtomBrowserClient::Delegate,
// content::GpuDataManagerObserver:
void OnGpuProcessCrashed(base::TerminationStatus status) override;
// content::BrowserChildProcessObserver:
void BrowserChildProcessLaunchedAndConnected(
const content::ChildProcessData& data) override;
void BrowserChildProcessHostDisconnected(
const content::ChildProcessData& data) override;
void BrowserChildProcessCrashed(
const content::ChildProcessData& data, int exit_code) override;
void BrowserChildProcessKilled(
const content::ChildProcessData& data, int exit_code) override;
private:
void SetAppPath(const base::FilePath& app_path);
void ChildProcessLaunched(int process_type, base::ProcessHandle handle);
void ChildProcessDisconnected(base::ProcessId pid);
// Get/Set the pre-defined path in PathService.
base::FilePath GetPath(mate::Arguments* args, const std::string& name);
@@ -178,9 +143,7 @@ class App : public AtomBrowserClient::Delegate,
void GetFileIcon(const base::FilePath& path,
mate::Arguments* args);
std::vector<mate::Dictionary> GetAppMetrics(v8::Isolate* isolate);
v8::Local<v8::Value> GetGPUFeatureStatus(v8::Isolate* isolate);
void EnableMixedSandbox(mate::Arguments* args);
std::vector<mate::Dictionary> GetAppMemoryInfo(v8::Isolate* isolate);
#if defined(OS_WIN)
// Get the current Jump List settings.
@@ -201,11 +164,6 @@ class App : public AtomBrowserClient::Delegate,
base::FilePath app_path_;
using ProcessMetricMap =
std::unordered_map<base::ProcessId,
std::unique_ptr<atom::ProcessMetric>>;
ProcessMetricMap app_metrics_;
DISALLOW_COPY_AND_ASSIGN(App);
};

View File

@@ -36,7 +36,6 @@ class BrowserView : public mate::TrackableObject<BrowserView> {
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
WebContents* web_contents() const { return api_web_contents_; }
NativeBrowserView* view() const { return view_.get(); }
int32_t ID() const;

View File

@@ -62,10 +62,6 @@ struct Converter<net::CookieStore::ChangeCause> {
switch (val) {
case net::CookieStore::ChangeCause::INSERTED:
case net::CookieStore::ChangeCause::EXPLICIT:
case net::CookieStore::ChangeCause::EXPLICIT_DELETE_BETWEEN:
case net::CookieStore::ChangeCause::EXPLICIT_DELETE_PREDICATE:
case net::CookieStore::ChangeCause::EXPLICIT_DELETE_SINGLE:
case net::CookieStore::ChangeCause::EXPLICIT_DELETE_CANONICAL:
return mate::StringToV8(isolate, "explicit");
case net::CookieStore::ChangeCause::OVERWRITE:
return mate::StringToV8(isolate, "overwrite");
@@ -232,8 +228,8 @@ void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
GetCookieStore(getter)->SetCookieWithDetailsAsync(
GURL(url), name, value, domain, path, creation_time,
expiration_time, last_access_time, secure, http_only,
net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT,
base::Bind(OnSetCookie, callback));
net::CookieSameSite::DEFAULT_MODE, false,
net::COOKIE_PRIORITY_DEFAULT, base::Bind(OnSetCookie, callback));
}
} // namespace

View File

@@ -4,8 +4,6 @@
#include "atom/browser/api/atom_api_desktop_capturer.h"
using base::PlatformThreadRef;
#include "atom/common/api/atom_api_native_image.h"
#include "atom/common/native_mate_converters/gfx_converter.h"
#include "base/strings/utf_string_conversions.h"

View File

@@ -1,225 +0,0 @@
// Copyright (c) 2014 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/browser/api/atom_api_notification.h"
#include "atom/browser/api/atom_api_menu.h"
#include "atom/browser/browser.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"
#include "atom/common/node_includes.h"
#include "base/strings/utf_string_conversions.h"
#include "brightray/browser/browser_client.h"
#include "native_mate/constructor.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
#include "url/gurl.h"
namespace mate {
template<>
struct Converter<brightray::NotificationAction> {
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
brightray::NotificationAction* out) {
mate::Dictionary dict;
if (!ConvertFromV8(isolate, val, &dict))
return false;
if (!dict.Get("type", &(out->type))) {
return false;
}
dict.Get("text", &(out->text));
return true;
}
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
brightray::NotificationAction val) {
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
dict.Set("text", val.text);
dict.Set("type", val.type);
return dict.GetHandle();
}
};
} // namespace mate
namespace atom {
namespace api {
Notification::Notification(v8::Isolate* isolate,
v8::Local<v8::Object> wrapper,
mate::Arguments* args) {
InitWith(isolate, wrapper);
presenter_ = brightray::BrowserClient::Get()->GetNotificationPresenter();
mate::Dictionary opts;
if (args->GetNext(&opts)) {
opts.Get("title", &title_);
opts.Get("body", &body_);
has_icon_ = opts.Get("icon", &icon_);
if (has_icon_) {
opts.Get("icon", &icon_path_);
}
opts.Get("silent", &silent_);
opts.Get("replyPlaceholder", &reply_placeholder_);
opts.Get("hasReply", &has_reply_);
opts.Get("actions", &actions_);
}
}
Notification::~Notification() {
if (notification_)
notification_->set_delegate(nullptr);
}
// static
mate::WrappableBase* Notification::New(mate::Arguments* args) {
if (!Browser::Get()->is_ready()) {
args->ThrowError("Cannot create Notification before app is ready");
return nullptr;
}
return new Notification(args->isolate(), args->GetThis(), args);
}
// Getters
base::string16 Notification::GetTitle() {
return title_;
}
base::string16 Notification::GetBody() {
return body_;
}
bool Notification::GetSilent() {
return silent_;
}
base::string16 Notification::GetReplyPlaceholder() {
return reply_placeholder_;
}
bool Notification::GetHasReply() {
return has_reply_;
}
// Setters
void Notification::SetTitle(const base::string16& new_title) {
title_ = new_title;
}
void Notification::SetBody(const base::string16& new_body) {
body_ = new_body;
}
void Notification::SetSilent(bool new_silent) {
silent_ = new_silent;
}
void Notification::SetReplyPlaceholder(const base::string16& new_placeholder) {
reply_placeholder_ = new_placeholder;
}
void Notification::SetHasReply(bool new_has_reply) {
has_reply_ = new_has_reply;
}
void Notification::SetActions(
const std::vector<brightray::NotificationAction>& actions) {
actions_ = actions;
}
std::vector<brightray::NotificationAction> Notification::GetActions() {
return actions_;
}
void Notification::NotificationAction(int index) {
Emit("action", index);
}
void Notification::NotificationClick() {
Emit("click");
}
void Notification::NotificationReplied(const std::string& reply) {
Emit("reply", reply);
}
void Notification::NotificationDisplayed() {
Emit("show");
}
void Notification::NotificationDestroyed() {
Emit("close");
}
void Notification::NotificationClosed() {
}
// Showing notifications
void Notification::Show() {
if (presenter_) {
notification_ = presenter_->CreateNotification(this);
if (notification_) {
brightray::NotificationOptions options;
options.title = title_;
options.msg = body_;
options.icon_url = GURL();
options.icon = icon_.AsBitmap();
options.silent = silent_;
options.has_reply = has_reply_;
options.reply_placeholder = reply_placeholder_;
options.actions = actions_;
notification_->Show(options);
}
}
}
bool Notification::IsSupported() {
return !!brightray::BrowserClient::Get()->GetNotificationPresenter();
}
// static
void Notification::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "Notification"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.MakeDestroyable()
.SetMethod("show", &Notification::Show)
.SetProperty("title", &Notification::GetTitle, &Notification::SetTitle)
.SetProperty("body", &Notification::GetBody, &Notification::SetBody)
.SetProperty("silent", &Notification::GetSilent, &Notification::SetSilent)
.SetProperty("replyPlaceholder", &Notification::GetReplyPlaceholder,
&Notification::SetReplyPlaceholder)
.SetProperty("hasReply", &Notification::GetHasReply,
&Notification::SetHasReply)
.SetProperty("actions", &Notification::GetActions,
&Notification::SetActions);
}
} // namespace api
} // namespace atom
namespace {
using atom::api::Notification;
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
Notification::SetConstructor(isolate, base::Bind(&Notification::New));
mate::Dictionary dict(isolate, exports);
dict.Set("Notification",
Notification::GetConstructor(isolate)->GetFunction());
dict.SetMethod("isSupported", &Notification::IsSupported);
}
} // namespace
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_notification, Initialize)

View File

@@ -1,87 +0,0 @@
// Copyright (c) 2014 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_NOTIFICATION_H_
#define ATOM_BROWSER_API_ATOM_API_NOTIFICATION_H_
#include <memory>
#include <string>
#include <vector>
#include "atom/browser/api/trackable_object.h"
#include "base/strings/utf_string_conversions.h"
#include "brightray/browser/notification.h"
#include "brightray/browser/notification_delegate.h"
#include "brightray/browser/notification_presenter.h"
#include "native_mate/handle.h"
#include "ui/gfx/image/image.h"
namespace atom {
namespace api {
class Notification : public mate::TrackableObject<Notification>,
public brightray::NotificationDelegate {
public:
static mate::WrappableBase* New(mate::Arguments* args);
static bool IsSupported();
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
// NotificationDelegate:
void NotificationAction(int index) override;
void NotificationClick() override;
void NotificationReplied(const std::string& reply) override;
void NotificationDisplayed() override;
void NotificationDestroyed() override;
void NotificationClosed() override;
protected:
Notification(v8::Isolate* isolate,
v8::Local<v8::Object> wrapper,
mate::Arguments* args);
~Notification() override;
void Show();
// Prop Getters
base::string16 GetTitle();
base::string16 GetBody();
bool GetSilent();
base::string16 GetReplyPlaceholder();
bool GetHasReply();
std::vector<brightray::NotificationAction> GetActions();
// Prop Setters
void SetTitle(const base::string16& new_title);
void SetBody(const base::string16& new_body);
void SetSilent(bool new_silent);
void SetReplyPlaceholder(const base::string16& new_reply_placeholder);
void SetHasReply(bool new_has_reply);
void SetActions(const std::vector<brightray::NotificationAction>& actions);
private:
base::string16 title_;
base::string16 body_;
gfx::Image icon_;
base::string16 icon_path_;
bool has_icon_ = false;
bool silent_ = false;
base::string16 reply_placeholder_;
bool has_reply_ = false;
std::vector<brightray::NotificationAction> actions_;
brightray::NotificationPresenter* presenter_;
base::WeakPtr<brightray::Notification> notification_;
DISALLOW_COPY_AND_ASSIGN(Notification);
};
} // namespace api
} // namespace atom
#endif // ATOM_BROWSER_API_ATOM_API_NOTIFICATION_H_

View File

@@ -50,25 +50,20 @@ void RegisterStandardSchemes(const std::vector<std::string>& schemes,
mate::Arguments* args) {
g_standard_schemes = schemes;
mate::Dictionary opts;
bool secure = false;
args->GetNext(&opts) && opts.Get("secure", &secure);
// Dynamically register the schemes.
auto* policy = content::ChildProcessSecurityPolicy::GetInstance();
for (const std::string& scheme : schemes) {
url::AddStandardScheme(scheme.c_str(), url::SCHEME_WITHOUT_PORT);
if (secure) {
url::AddSecureScheme(scheme.c_str());
}
policy->RegisterWebSafeScheme(scheme);
}
// Add the schemes to command line switches, so child processes can also
// register them.
// add switches to register as standard
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
atom::switches::kStandardSchemes, base::JoinString(schemes, ","));
if (secure) {
mate::Dictionary opts;
bool secure = false;
if (args->GetNext(&opts) && opts.Get("secure", &secure) && secure) {
// add switches to register as secure
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
atom::switches::kSecureSchemes, base::JoinString(schemes, ","));
}

View File

@@ -120,9 +120,6 @@ void Screen::BuildPrototype(
.SetMethod("getPrimaryDisplay", &Screen::GetPrimaryDisplay)
.SetMethod("getAllDisplays", &Screen::GetAllDisplays)
.SetMethod("getDisplayNearestPoint", &Screen::GetDisplayNearestPoint)
#if defined(OS_MACOSX)
.SetMethod("getMenuBarHeight", &Screen::getMenuBarHeight)
#endif
.SetMethod("getDisplayMatching", &Screen::GetDisplayMatching);
}

View File

@@ -40,10 +40,6 @@ class Screen : public mate::EventEmitter<Screen>,
display::Display GetDisplayNearestPoint(const gfx::Point& point);
display::Display GetDisplayMatching(const gfx::Rect& match_rect);
#if defined(OS_MACOSX)
int getMenuBarHeight();
#endif
// display::DisplayObserver:
void OnDisplayAdded(const display::Display& new_display) override;
void OnDisplayRemoved(const display::Display& old_display) override;

View File

@@ -1,18 +0,0 @@
// Copyright (c) 2017 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#import "atom/browser/api/atom_api_screen.h"
#import <Cocoa/Cocoa.h>
namespace atom {
namespace api {
int Screen::getMenuBarHeight() {
return [[NSApp mainMenu] menuBarHeight];
}
}// namespace api
}// namespace atom

View File

@@ -432,8 +432,7 @@ void DownloadIdCallback(content::DownloadManager* download_manager,
last_modified, offset, length, std::string(),
content::DownloadItem::INTERRUPTED,
content::DownloadDangerType::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
content::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT, false,
std::vector<content::DownloadItem::ReceivedSlice>());
content::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT, false);
}
} // namespace

View File

@@ -122,14 +122,6 @@ void Tray::OnDropText(const std::string& text) {
Emit("drop-text", text);
}
void Tray::OnMouseEntered(const gfx::Point& location, int modifiers) {
EmitWithFlags("mouse-enter", modifiers, location);
}
void Tray::OnMouseExited(const gfx::Point& location, int modifiers) {
EmitWithFlags("mouse-leave", modifiers, location);
}
void Tray::OnDragEntered() {
Emit("drag-enter");
}

View File

@@ -59,8 +59,6 @@ class Tray : public mate::TrackableObject<Tray>,
void OnDragEntered() override;
void OnDragExited() override;
void OnDragEnded() override;
void OnMouseEntered(const gfx::Point& location, int modifiers) override;
void OnMouseExited(const gfx::Point& location, int modifiers) override;
void SetImage(v8::Isolate* isolate, mate::Handle<NativeImage> image);
void SetPressedImage(v8::Isolate* isolate, mate::Handle<NativeImage> image);

View File

@@ -13,8 +13,6 @@
#include "atom/browser/atom_browser_client.h"
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/atom_javascript_dialog_manager.h"
#include "atom/browser/child_web_contents_tracker.h"
#include "atom/browser/lib/bluetooth_chooser.h"
#include "atom/browser/native_window.h"
#include "atom/browser/net/atom_network_delegate.h"
@@ -41,17 +39,15 @@
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/options_switches.h"
#include "base/process/process_handle.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
#include "brightray/browser/inspectable_web_contents.h"
#include "brightray/browser/inspectable_web_contents_view.h"
#include "chrome/browser/printing/print_preview_message_handler.h"
#include "chrome/browser/printing/print_view_manager_basic.h"
#include "chrome/browser/ssl/security_state_tab_helper.h"
#include "content/browser/frame_host/navigation_entry_impl.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/view_messages.h"
#include "content/public/browser/favicon_status.h"
@@ -59,6 +55,9 @@
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
@@ -71,14 +70,12 @@
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/context_menu_params.h"
#include "native_mate/converter.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
#include "net/url_request/url_request_context.h"
#include "third_party/WebKit/public/platform/WebInputEvent.h"
#include "third_party/WebKit/public/web/WebFindOptions.h"
#include "ui/display/screen.h"
#include "ui/events/base_event_utils.h"
#if !defined(OS_MACOSX)
#include "ui/aura/window.h"
@@ -91,7 +88,6 @@ namespace {
struct PrintSettings {
bool silent;
bool print_background;
base::string16 device_name;
};
} // namespace
@@ -129,25 +125,10 @@ struct Converter<PrintSettings> {
return false;
dict.Get("silent", &(out->silent));
dict.Get("printBackground", &(out->print_background));
dict.Get("deviceName", &(out->device_name));
return true;
}
};
template<>
struct Converter<printing::PrinterBasicInfo> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const printing::PrinterBasicInfo& val) {
mate::Dictionary dict(isolate, v8::Object::New(isolate));
dict.Set("name", val.printer_name);
dict.Set("description", val.printer_description);
dict.Set("status", val.printer_status);
dict.Set("isDefault", val.is_default ? true : false);
dict.Set("options", val.options);
return dict.GetHandle();
}
};
template<>
struct Converter<WindowOpenDisposition> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
@@ -268,6 +249,22 @@ void OnCapturePageDone(const base::Callback<void(const gfx::Image&)>& callback,
callback.Run(gfx::Image::CreateFrom1xBitmap(bitmap));
}
// Set the background color of RenderWidgetHostView.
void SetBackgroundColor(content::WebContents* web_contents) {
const auto view = web_contents->GetRenderWidgetHostView();
if (view) {
WebContentsPreferences* web_preferences =
WebContentsPreferences::FromWebContents(web_contents);
std::string color_name;
if (web_preferences->web_preferences()->GetString(options::kBackgroundColor,
&color_name)) {
view->SetBackgroundColor(ParseHexColor(color_name));
} else {
view->SetBackgroundColor(SK_ColorTRANSPARENT);
}
}
}
} // namespace
WebContents::WebContents(v8::Isolate* isolate,
@@ -317,9 +314,6 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
else if (options.Get("offscreen", &b) && b)
type_ = OFF_SCREEN;
// Init embedder earlier
options.Get("embedder", &embedder_);
// Whether to enable DevTools.
options.Get("devTools", &enable_devtools_);
@@ -344,18 +338,7 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
session->browser_context(), site_instance);
guest_delegate_.reset(new WebViewGuestDelegate);
params.guest_delegate = guest_delegate_.get();
if (embedder_ && embedder_->IsOffScreen()) {
auto* view = new OffScreenWebContentsView(false,
base::Bind(&WebContents::OnPaint, base::Unretained(this)));
params.view = view;
params.delegate_view = view;
web_contents = content::WebContents::Create(params);
view->SetWebContents(web_contents);
} else {
web_contents = content::WebContents::Create(params);
}
web_contents = content::WebContents::Create(params);
} else if (IsOffScreen()) {
bool transparent = false;
options.Get("transparent", &transparent);
@@ -380,7 +363,7 @@ void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
content::WebContents *web_contents,
mate::Handle<api::Session> session,
const mate::Dictionary& options) {
Observe(web_contents);
content::WebContentsObserver::Observe(web_contents);
InitWithWebContents(web_contents, session->browser_context());
managed_web_contents()->GetView()->SetDelegate(this);
@@ -405,7 +388,7 @@ void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
guest_delegate_->Initialize(this);
NativeWindow* owner_window = nullptr;
if (embedder_) {
if (options.Get("embedder", &embedder_) && embedder_) {
// New WebContents's owner_window is the embedder's owner_window.
auto relay =
NativeWindowRelay::FromWebContents(embedder_->web_contents());
@@ -416,6 +399,11 @@ void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
SetOwnerWindow(owner_window);
}
const content::NavigationController* controller =
&web_contents->GetController();
registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING,
content::Source<content::NavigationController>(controller));
Init(isolate);
AttachAsUserData(web_contents);
}
@@ -496,7 +484,6 @@ void WebContents::AddNewContents(content::WebContents* source,
const gfx::Rect& initial_rect,
bool user_gesture,
bool* was_blocked) {
new ChildWebContentsTracker(new_contents);
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
auto api_web_contents = CreateFrom(isolate(), new_contents);
@@ -580,12 +567,11 @@ bool WebContents::PreHandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event,
bool* is_keyboard_shortcut) {
if (event.type() == blink::WebInputEvent::Type::RawKeyDown ||
event.type() == blink::WebInputEvent::Type::KeyUp) {
if (event.type == blink::WebInputEvent::Type::RawKeyDown
|| event.type == blink::WebInputEvent::Type::KeyUp)
return Emit("before-input-event", event);
} else {
else
return false;
}
}
void WebContents::EnterFullscreenModeForTab(content::WebContents* source,
@@ -694,15 +680,6 @@ std::unique_ptr<content::BluetoothChooser> WebContents::RunBluetoothChooser(
return std::move(bluetooth_chooser);
}
content::JavaScriptDialogManager*
WebContents::GetJavaScriptDialogManager(
content::WebContents* source) {
if (!dialog_manager_)
dialog_manager_.reset(new AtomJavaScriptDialogManager(this));
return dialog_manager_.get();
}
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.
@@ -803,6 +780,30 @@ void WebContents::DidGetRedirectForResourceRequest(
details.headers.get());
}
void WebContents::DidStartNavigation(
content::NavigationHandle* navigation_handle) {
if (!navigation_handle->IsInMainFrame() || navigation_handle->IsSamePage())
return;
if (deferred_load_url_.id) {
auto web_contents = navigation_handle->GetWebContents();
auto& controller = web_contents->GetController();
int id = controller.GetPendingEntry()->GetUniqueID();
if (id == deferred_load_url_.id) {
if (!deferred_load_url_.params.url.is_empty()) {
auto params = deferred_load_url_.params;
deferred_load_url_.id = 0;
deferred_load_url_.params =
content::NavigationController::LoadURLParams(GURL());
controller.LoadURLWithParams(params);
SetBackgroundColor(web_contents);
} else {
deferred_load_url_.id = 0;
}
}
}
}
void WebContents::DidFinishNavigation(
content::NavigationHandle* navigation_handle) {
bool is_main_frame = navigation_handle->IsInMainFrame();
@@ -845,6 +846,41 @@ void WebContents::DidUpdateFaviconURL(
Emit("page-favicon-updated", unique_urls);
}
void WebContents::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
switch (type) {
case content::NOTIFICATION_NAV_ENTRY_PENDING: {
content::NavigationEntry* entry =
content::Details<content::NavigationEntry>(details).ptr();
content::NavigationEntryImpl* entry_impl =
static_cast<content::NavigationEntryImpl*>(entry);
// In NavigatorImpl::DidStartMainFrameNavigation when there is no
// browser side pending entry available it creates a new one based
// on existing pending entry, hence we track the unique id here
// instead in WebContents::LoadURL with controller.GetPendingEntry()
// TODO(deepak1556): Remove once we have
// https://codereview.chromium.org/2661743002.
if (entry_impl->frame_tree_node_id() == -1) {
deferred_load_url_.id = entry->GetUniqueID();
}
break;
}
default:
NOTREACHED();
break;
}
}
void WebContents::BeforeUnloadDialogCancelled() {
if (deferred_load_url_.id) {
auto& controller = web_contents()->GetController();
if (!controller.GetPendingEntry()) {
deferred_load_url_.id = 0;
}
}
}
void WebContents::DevToolsReloadPage() {
Emit("devtools-reload-page");
}
@@ -861,7 +897,7 @@ void WebContents::DevToolsOpened() {
devtools_web_contents_.Reset(isolate(), handle.ToV8());
// Set inspected tabID.
base::Value tab_id(ID());
base::FundamentalValue tab_id(ID());
managed_web_contents()->CallClientFunction(
"DevToolsAPI.setInspectedTabId", &tab_id, nullptr, nullptr);
@@ -899,23 +935,6 @@ bool WebContents::OnMessageReceived(const IPC::Message& message) {
return handled;
}
bool WebContents::OnMessageReceived(const IPC::Message& message,
content::RenderFrameHost* frame_host) {
bool handled = true;
auto relay = NativeWindowRelay::FromWebContents(web_contents());
if (!relay)
return false;
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(NativeWindow, message, frame_host)
IPC_MESSAGE_FORWARD(AtomAutofillFrameHostMsg_ShowPopup,
relay->window.get(), NativeWindow::ShowAutofillPopup)
IPC_MESSAGE_FORWARD(AtomAutofillFrameHostMsg_HidePopup,
relay->window.get(), NativeWindow::HideAutofillPopup)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
// There are three ways of destroying a webContents:
// 1. call webContents.destroy();
// 2. garbage collection;
@@ -951,7 +970,7 @@ void WebContents::NavigationEntryCommitted(
int64_t WebContents::GetID() const {
int64_t process_id = web_contents()->GetRenderProcessHost()->GetID();
int64_t routing_id = web_contents()->GetRenderViewHost()->GetRoutingID();
int64_t routing_id = web_contents()->GetRoutingID();
int64_t rv = (process_id << 32) + routing_id;
return rv;
}
@@ -960,11 +979,6 @@ int WebContents::GetProcessID() const {
return web_contents()->GetRenderProcessHost()->GetID();
}
base::ProcessId WebContents::GetOSProcessID() const {
auto process_handle = web_contents()->GetRenderProcessHost()->GetHandle();
return base::GetProcId(process_handle);
}
WebContents::Type WebContents::GetType() const {
return type_;
}
@@ -1013,23 +1027,16 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
params.transition_type = ui::PAGE_TRANSITION_TYPED;
params.should_clear_history_list = true;
params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
web_contents()->GetController().LoadURLWithParams(params);
// Set the background color of RenderWidgetHostView.
if (deferred_load_url_.id) {
deferred_load_url_.params = params;
return;
}
web_contents()->GetController().LoadURLWithParams(params);
// We have to call it right after LoadURL because the RenderViewHost is only
// created after loading a page.
const auto view = web_contents()->GetRenderWidgetHostView();
if (view) {
WebContentsPreferences* web_preferences =
WebContentsPreferences::FromWebContents(web_contents());
std::string color_name;
if (web_preferences->web_preferences()->GetString(options::kBackgroundColor,
&color_name)) {
view->SetBackgroundColor(ParseHexColor(color_name));
} else {
view->SetBackgroundColor(SK_ColorTRANSPARENT);
}
}
SetBackgroundColor(web_contents());
}
void WebContents::DownloadURL(const GURL& url) {
@@ -1241,10 +1248,6 @@ void WebContents::UnregisterServiceWorker(
callback);
}
void WebContents::SetIgnoreMenuShortcuts(bool ignore) {
set_ignore_menu_shortcuts(ignore);
}
void WebContents::SetAudioMuted(bool muted) {
web_contents()->SetAudioMuted(muted);
}
@@ -1254,7 +1257,7 @@ bool WebContents::IsAudioMuted() {
}
void WebContents::Print(mate::Arguments* args) {
PrintSettings settings = { false, false, base::string16() };
PrintSettings settings = { false, false };
if (args->Length() == 1 && !args->GetNext(&settings)) {
args->ThrowError();
return;
@@ -1263,15 +1266,7 @@ void WebContents::Print(mate::Arguments* args) {
printing::PrintViewManagerBasic::FromWebContents(web_contents())->
PrintNow(web_contents()->GetMainFrame(),
settings.silent,
settings.print_background,
settings.device_name);
}
std::vector<printing::PrinterBasicInfo> WebContents::GetPrinterList() {
std::vector<printing::PrinterBasicInfo> printers;
auto print_backend = printing::PrintBackend::CreateInstance(nullptr);
print_backend->EnumeratePrinters(&printers);
return printers;
settings.print_background);
}
void WebContents::PrintToPDF(const base::DictionaryValue& setting,
@@ -1331,7 +1326,7 @@ void WebContents::SelectAll() {
}
void WebContents::Unselect() {
web_contents()->CollapseSelection();
web_contents()->Unselect();
}
void WebContents::Replace(const base::string16& word) {
@@ -1406,31 +1401,30 @@ bool WebContents::SendIPCMessage(bool all_frames,
void WebContents::SendInputEvent(v8::Isolate* isolate,
v8::Local<v8::Value> input_event) {
const auto view = static_cast<content::RenderWidgetHostViewBase*>(
web_contents()->GetRenderWidgetHostView());
const auto view = web_contents()->GetRenderWidgetHostView();
if (!view)
return;
const auto host = view->GetRenderWidgetHost();
if (!host)
return;
int type = mate::GetWebInputEventType(isolate, input_event);
if (blink::WebInputEvent::isMouseEventType(type)) {
blink::WebMouseEvent mouse_event;
if (mate::ConvertFromV8(isolate, input_event, &mouse_event)) {
view->ProcessMouseEvent(mouse_event, ui::LatencyInfo());
host->ForwardMouseEvent(mouse_event);
return;
}
} else if (blink::WebInputEvent::isKeyboardEventType(type)) {
content::NativeWebKeyboardEvent keyboard_event(
blink::WebKeyboardEvent::RawKeyDown,
blink::WebInputEvent::NoModifiers,
ui::EventTimeForNow());
content::NativeWebKeyboardEvent keyboard_event;
if (mate::ConvertFromV8(isolate, input_event, &keyboard_event)) {
view->ProcessKeyboardEvent(keyboard_event);
host->ForwardKeyboardEvent(keyboard_event);
return;
}
} else if (type == blink::WebInputEvent::MouseWheel) {
blink::WebMouseWheelEvent mouse_wheel_event;
if (mate::ConvertFromV8(isolate, input_event, &mouse_wheel_event)) {
view->ProcessMouseWheelEvent(mouse_wheel_event, ui::LatencyInfo());
host->ForwardWheelEvent(mouse_wheel_event);
return;
}
}
@@ -1512,7 +1506,8 @@ void WebContents::CapturePage(mate::Arguments* args) {
}
const auto view = web_contents()->GetRenderWidgetHostView();
if (!view) {
const auto host = view ? view->GetRenderWidgetHost() : nullptr;
if (!view || !host) {
callback.Run(gfx::Image());
return;
}
@@ -1532,10 +1527,10 @@ void WebContents::CapturePage(mate::Arguments* args) {
if (scale > 1.0f)
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
view->CopyFromSurface(gfx::Rect(rect.origin(), view_size),
bitmap_size,
base::Bind(&OnCapturePageDone, callback),
kBGRA_8888_SkColorType);
host->CopyFromBackingStore(gfx::Rect(rect.origin(), view_size),
bitmap_size,
base::Bind(&OnCapturePageDone, callback),
kBGRA_8888_SkColorType);
}
void WebContents::OnCursorChange(const content::WebCursor& cursor) {
@@ -1566,12 +1561,10 @@ bool WebContents::IsOffScreen() const {
return type_ == OFF_SCREEN;
}
bool WebContents::IsOffScreenOrEmbedderOffscreen() const {
return IsOffScreen() || (embedder_ && embedder_->IsOffScreen());
}
void WebContents::OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap) {
Emit("paint", dirty_rect, gfx::Image::CreateFrom1xBitmap(bitmap));
mate::Handle<NativeImage> image =
NativeImage::Create(isolate(), gfx::Image::CreateFrom1xBitmap(bitmap));
Emit("paint", dirty_rect, image);
}
void WebContents::StartPainting() {
@@ -1635,18 +1628,6 @@ void WebContents::Invalidate() {
}
}
gfx::Size WebContents::GetSizeForNewRenderView(
content::WebContents* wc) const {
if (IsOffScreen() && wc == web_contents()) {
auto relay = NativeWindowRelay::FromWebContents(web_contents());
if (relay) {
return relay->window->GetSize();
}
}
return gfx::Size();
}
void WebContents::SetZoomLevel(double level) {
zoom_controller_->SetZoomLevel(level);
}
@@ -1747,7 +1728,6 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
.MakeDestroyable()
.SetMethod("getId", &WebContents::GetID)
.SetMethod("getProcessId", &WebContents::GetProcessID)
.SetMethod("getOSProcessId", &WebContents::GetOSProcessID)
.SetMethod("equal", &WebContents::Equal)
.SetMethod("_loadURL", &WebContents::LoadURL)
.SetMethod("downloadURL", &WebContents::DownloadURL)
@@ -1768,12 +1748,12 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
.SetMethod("closeDevTools", &WebContents::CloseDevTools)
.SetMethod("isDevToolsOpened", &WebContents::IsDevToolsOpened)
.SetMethod("isDevToolsFocused", &WebContents::IsDevToolsFocused)
.SetMethod("enableDeviceEmulation", &WebContents::EnableDeviceEmulation)
.SetMethod("disableDeviceEmulation", &WebContents::DisableDeviceEmulation)
.SetMethod("enableDeviceEmulation",
&WebContents::EnableDeviceEmulation)
.SetMethod("disableDeviceEmulation",
&WebContents::DisableDeviceEmulation)
.SetMethod("toggleDevTools", &WebContents::ToggleDevTools)
.SetMethod("inspectElement", &WebContents::InspectElement)
.SetMethod("setIgnoreMenuShortcuts",
&WebContents::SetIgnoreMenuShortcuts)
.SetMethod("setAudioMuted", &WebContents::SetAudioMuted)
.SetMethod("isAudioMuted", &WebContents::IsAudioMuted)
.SetMethod("undo", &WebContents::Undo)
@@ -1794,7 +1774,8 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
.SetMethod("tabTraverse", &WebContents::TabTraverse)
.SetMethod("_send", &WebContents::SendIPCMessage)
.SetMethod("sendInputEvent", &WebContents::SendInputEvent)
.SetMethod("beginFrameSubscription", &WebContents::BeginFrameSubscription)
.SetMethod("beginFrameSubscription",
&WebContents::BeginFrameSubscription)
.SetMethod("endFrameSubscription", &WebContents::EndFrameSubscription)
.SetMethod("startDrag", &WebContents::StartDrag)
.SetMethod("setSize", &WebContents::SetSize)
@@ -1818,7 +1799,6 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
&WebContents::UnregisterServiceWorker)
.SetMethod("inspectServiceWorker", &WebContents::InspectServiceWorker)
.SetMethod("print", &WebContents::Print)
.SetMethod("getPrinters", &WebContents::GetPrinterList)
.SetMethod("_printToPDF", &WebContents::PrintToPDF)
.SetMethod("addWorkSpace", &WebContents::AddWorkSpace)
.SetMethod("removeWorkSpace", &WebContents::RemoveWorkSpace)

View File

@@ -12,12 +12,12 @@
#include "atom/browser/api/save_page_handler.h"
#include "atom/browser/api/trackable_object.h"
#include "atom/browser/common_web_contents_delegate.h"
#include "atom/browser/ui/autofill_popup.h"
#include "content/common/cursors/webcursor.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/favicon_url.h"
#include "native_mate/handle.h"
#include "printing/backend/print_backend.h"
#include "ui/gfx/image/image.h"
namespace blink {
@@ -41,7 +41,6 @@ namespace atom {
struct SetSizeParams;
class AtomBrowserContext;
class AtomJavaScriptDialogManager;
class WebContentsZoomController;
class WebViewGuestDelegate;
@@ -49,7 +48,8 @@ namespace api {
class WebContents : public mate::TrackableObject<WebContents>,
public CommonWebContentsDelegate,
public content::WebContentsObserver {
public content::WebContentsObserver,
public content::NotificationObserver {
public:
enum Type {
BACKGROUND_PAGE, // A DevTools extension background page.
@@ -82,7 +82,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
int64_t GetID() const;
int GetProcessID() const;
base::ProcessId GetOSProcessID() const;
Type GetType() const;
bool Equal(const WebContents* web_contents) const;
void LoadURL(const GURL& url, const mate::Dictionary& options);
@@ -117,11 +116,9 @@ class WebContents : public mate::TrackableObject<WebContents>,
void InspectServiceWorker();
void HasServiceWorker(const base::Callback<void(bool)>&);
void UnregisterServiceWorker(const base::Callback<void(bool)>&);
void SetIgnoreMenuShortcuts(bool ignore);
void SetAudioMuted(bool muted);
bool IsAudioMuted();
void Print(mate::Arguments* args);
std::vector<printing::PrinterBasicInfo> GetPrinterList();
void SetEmbedder(const WebContents* embedder);
// Print current page as PDF.
@@ -179,7 +176,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
// Methods for offscreen rendering
bool IsOffScreen() const;
bool IsOffScreenOrEmbedderOffscreen() const;
void OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap);
void StartPainting();
void StopPainting();
@@ -187,7 +183,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
void SetFrameRate(int frame_rate);
int GetFrameRate() const;
void Invalidate();
gfx::Size GetSizeForNewRenderView(content::WebContents*) const override;
// Methods for zoom handling.
void SetZoomLevel(double level);
@@ -301,8 +296,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
std::unique_ptr<content::BluetoothChooser> RunBluetoothChooser(
content::RenderFrameHost* frame,
const content::BluetoothChooser::EventHandler& handler) override;
content::JavaScriptDialogManager* GetJavaScriptDialogManager(
content::WebContents* source) override;
// content::WebContentsObserver:
void BeforeUnloadFired(const base::TimeTicks& proceed_time) override;
@@ -324,11 +317,11 @@ class WebContents : public mate::TrackableObject<WebContents>,
const content::ResourceRequestDetails& details) override;
void DidGetRedirectForResourceRequest(
const content::ResourceRedirectDetails& details) override;
void DidStartNavigation(
content::NavigationHandle* navigation_handle) override;
void DidFinishNavigation(
content::NavigationHandle* navigation_handle) override;
bool OnMessageReceived(const IPC::Message& message) override;
bool OnMessageReceived(const IPC::Message& message,
content::RenderFrameHost* frame_host) override;
void WebContentsDestroyed() override;
void NavigationEntryCommitted(
const content::LoadCommittedDetails& load_details) override;
@@ -343,6 +336,12 @@ class WebContents : public mate::TrackableObject<WebContents>,
const MediaPlayerId& id) override;
void DidChangeThemeColor(SkColor theme_color) override;
// content::NotificationObserver:
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
void BeforeUnloadDialogCancelled() override;
// brightray::InspectableWebContentsDelegate:
void DevToolsReloadPage() override;
@@ -352,6 +351,13 @@ class WebContents : public mate::TrackableObject<WebContents>,
void DevToolsClosed() override;
private:
struct LoadURLParams {
LoadURLParams() : params(GURL()), id(0) {}
content::NavigationController::LoadURLParams params;
int id;
};
AtomBrowserContext* GetBrowserContext() const;
uint32_t GetNextRequestId() {
@@ -382,7 +388,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
v8::Global<v8::Value> devtools_web_contents_;
v8::Global<v8::Value> debugger_;
std::unique_ptr<AtomJavaScriptDialogManager> dialog_manager_;
std::unique_ptr<WebViewGuestDelegate> guest_delegate_;
// The host webcontents that may contain this webcontents.
@@ -403,6 +408,11 @@ class WebContents : public mate::TrackableObject<WebContents>,
// Whether to enable devtools.
bool enable_devtools_;
// Container to hold url parms for deferred load when
// there is a pending navigation entry.
LoadURLParams deferred_load_url_;
content::NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(WebContents);
};

View File

@@ -186,8 +186,6 @@ void Window::OnWindowClosed() {
RemoveFromParentChildWindows();
ResetBrowserView();
// Destroy the native class when window is closed.
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, GetDestroyClosure());
@@ -302,10 +300,6 @@ void Window::OnTouchBarItemResult(const std::string& item_id,
Emit("-touch-bar-interaction", item_id, details);
}
void Window::OnNewWindowForTab() {
Emit("new-window-for-tab");
}
#if defined(OS_WIN)
void Window::OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) {
if (IsWindowMessageHooked(message)) {
@@ -844,31 +838,16 @@ v8::Local<v8::Value> Window::GetBrowserView() const {
}
void Window::SetBrowserView(v8::Local<v8::Value> value) {
ResetBrowserView();
mate::Handle<BrowserView> browser_view;
if (value->IsNull()) {
window_->SetBrowserView(nullptr);
browser_view_.Reset();
} else if (mate::ConvertFromV8(isolate(), value, &browser_view)) {
window_->SetBrowserView(browser_view->view());
browser_view->web_contents()->SetOwnerWindow(window_.get());
browser_view_.Reset(isolate(), value);
}
}
void Window::ResetBrowserView() {
if (browser_view_.IsEmpty()) {
return;
}
mate::Handle<BrowserView> browser_view;
if (mate::ConvertFromV8(isolate(), GetBrowserView(), &browser_view)) {
browser_view->web_contents()->SetOwnerWindow(nullptr);
}
browser_view_.Reset();
}
bool Window::IsModal() const {
return window_->is_modal();
}

View File

@@ -91,7 +91,6 @@ class Window : public mate::TrackableObject<Window>,
void OnExecuteWindowsCommand(const std::string& command_name) override;
void OnTouchBarItemResult(const std::string& item_id,
const base::DictionaryValue& details) override;
void OnNewWindowForTab() override;
#if defined(OS_WIN)
void OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) override;
@@ -186,7 +185,6 @@ class Window : public mate::TrackableObject<Window>,
std::vector<v8::Local<v8::Object>> GetChildWindows() const;
v8::Local<v8::Value> GetBrowserView() const;
void SetBrowserView(v8::Local<v8::Value> value);
void ResetBrowserView();
bool IsModal() const;
v8::Local<v8::Value> GetNativeWindowHandle();

View File

@@ -24,7 +24,6 @@ FrameSubscriber::FrameSubscriber(v8::Isolate* isolate,
view_(view),
callback_(callback),
only_dirty_(only_dirty),
source_id_for_copy_request_(base::UnguessableToken::Create()),
weak_factory_(this) {
}
@@ -33,7 +32,8 @@ bool FrameSubscriber::ShouldCaptureFrame(
base::TimeTicks present_time,
scoped_refptr<media::VideoFrame>* storage,
DeliverFrameCallback* callback) {
if (!view_)
const auto host = view_ ? view_->GetRenderWidgetHost() : nullptr;
if (!view_ || !host)
return false;
if (dirty_rect.IsEmpty())
@@ -54,7 +54,7 @@ bool FrameSubscriber::ShouldCaptureFrame(
rect = gfx::Rect(rect.origin(), bitmap_size);
view_->CopyFromSurface(
host->CopyFromBackingStore(
rect,
rect.size(),
base::Bind(&FrameSubscriber::OnFrameDelivered,
@@ -64,10 +64,6 @@ bool FrameSubscriber::ShouldCaptureFrame(
return false;
}
const base::UnguessableToken& FrameSubscriber::GetSourceIdForCopyRequest() {
return source_id_for_copy_request_;
}
void FrameSubscriber::OnFrameDelivered(const FrameCaptureCallback& callback,
const gfx::Rect& damage_rect,
const SkBitmap& bitmap,

View File

@@ -7,9 +7,9 @@
#include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "content/browser/renderer_host/render_widget_host_view_frame_subscriber.h"
#include "content/public/browser/readback_types.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/render_widget_host_view_frame_subscriber.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/geometry/size.h"
#include "v8/include/v8.h"
@@ -32,7 +32,6 @@ class FrameSubscriber : public content::RenderWidgetHostViewFrameSubscriber {
base::TimeTicks present_time,
scoped_refptr<media::VideoFrame>* storage,
DeliverFrameCallback* callback) override;
const base::UnguessableToken& GetSourceIdForCopyRequest() override;
private:
void OnFrameDelivered(const FrameCaptureCallback& callback,
@@ -45,8 +44,6 @@ class FrameSubscriber : public content::RenderWidgetHostViewFrameSubscriber {
FrameCaptureCallback callback_;
bool only_dirty_;
base::UnguessableToken source_id_for_copy_request_;
base::WeakPtrFactory<FrameSubscriber> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(FrameSubscriber);

View File

@@ -15,7 +15,6 @@
#include "atom/browser/atom_quota_permission_context.h"
#include "atom/browser/atom_resource_dispatcher_host_delegate.h"
#include "atom/browser/atom_speech_recognition_manager_delegate.h"
#include "atom/browser/child_web_contents_tracker.h"
#include "atom/browser/native_window.h"
#include "atom/browser/web_contents_permission_helper.h"
#include "atom/browser/web_contents_preferences.h"
@@ -23,6 +22,7 @@
#include "atom/common/options_switches.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/path_service.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
@@ -38,6 +38,7 @@
#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_paths.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/web_preferences.h"
#include "net/ssl/ssl_cert_request_info.h"
@@ -88,31 +89,17 @@ content::WebContents* AtomBrowserClient::GetWebContentsFromProcessID(
}
bool AtomBrowserClient::ShouldCreateNewSiteInstance(
content::RenderFrameHost* render_frame_host,
content::BrowserContext* browser_context,
content::SiteInstance* current_instance,
const GURL& url) {
if (url.SchemeIs(url::kJavaScriptScheme))
// "javacript:" scheme should always use same SiteInstance
return false;
int process_id = current_instance->GetProcess()->GetID();
if (!IsRendererSandboxed(process_id)) {
if (!RendererUsesNativeWindowOpen(process_id)) {
// non-sandboxed renderers without native window.open should always create
// a new SiteInstance
return true;
}
auto web_contents =
content::WebContents::FromRenderFrameHost(render_frame_host);
if (!ChildWebContentsTracker::IsChildWebContents(web_contents)) {
// Root WebContents should always create new process to make sure
// native addons are loaded correctly after reload / navigation.
// (Non-root WebContents opened by window.open() should try to
// reuse process to allow synchronous cross-window scripting.)
return true;
}
}
if (!IsRendererSandboxed(current_instance->GetProcess()->GetID()))
// non-sandboxed renderers should always create a new SiteInstance
return true;
// Create new a SiteInstance if navigating to a different site.
auto src_url = current_instance->GetSiteURL();
@@ -124,33 +111,19 @@ bool AtomBrowserClient::ShouldCreateNewSiteInstance(
content::SiteInstance::GetSiteForURL(browser_context, url) != src_url;
}
void AtomBrowserClient::AddProcessPreferences(
int process_id, AtomBrowserClient::ProcessPreferences prefs) {
base::AutoLock auto_lock(process_preferences_lock_);
process_preferences_[process_id] = prefs;
void AtomBrowserClient::AddSandboxedRendererId(int process_id) {
base::AutoLock auto_lock(sandboxed_renderers_lock_);
sandboxed_renderers_.insert(process_id);
}
void AtomBrowserClient::RemoveProcessPreferences(int process_id) {
base::AutoLock auto_lock(process_preferences_lock_);
process_preferences_.erase(process_id);
void AtomBrowserClient::RemoveSandboxedRendererId(int process_id) {
base::AutoLock auto_lock(sandboxed_renderers_lock_);
sandboxed_renderers_.erase(process_id);
}
bool AtomBrowserClient::IsRendererSandboxed(int process_id) {
base::AutoLock auto_lock(process_preferences_lock_);
auto it = process_preferences_.find(process_id);
return it != process_preferences_.end() && it->second.sandbox;
}
bool AtomBrowserClient::RendererUsesNativeWindowOpen(int process_id) {
base::AutoLock auto_lock(process_preferences_lock_);
auto it = process_preferences_.find(process_id);
return it != process_preferences_.end() && it->second.native_window_open;
}
bool AtomBrowserClient::RendererDisablesPopups(int process_id) {
base::AutoLock auto_lock(process_preferences_lock_);
auto it = process_preferences_.find(process_id);
return it != process_preferences_.end() && it->second.disable_popups;
base::AutoLock auto_lock(sandboxed_renderers_lock_);
return sandboxed_renderers_.count(process_id);
}
void AtomBrowserClient::RenderProcessWillLaunch(
@@ -162,15 +135,11 @@ void AtomBrowserClient::RenderProcessWillLaunch(
new WidevineCdmMessageFilter(process_id, host->GetBrowserContext()));
content::WebContents* web_contents = GetWebContentsFromProcessID(process_id);
ProcessPreferences process_prefs;
process_prefs.sandbox = WebContentsPreferences::IsSandboxed(web_contents);
process_prefs.native_window_open
= WebContentsPreferences::UsesNativeWindowOpen(web_contents);
process_prefs.disable_popups
= WebContentsPreferences::DisablePopups(web_contents);
AddProcessPreferences(host->GetID(), process_prefs);
// ensure the ProcessPreferences is removed later
host->AddObserver(this);
if (WebContentsPreferences::IsSandboxed(web_contents)) {
AddSandboxedRendererId(host->GetID());
// ensure the sandboxed renderer id is removed later
host->AddObserver(this);
}
}
content::SpeechRecognitionManagerDelegate*
@@ -215,8 +184,7 @@ void AtomBrowserClient::OverrideSiteInstanceForNavigation(
return;
}
if (!ShouldCreateNewSiteInstance(render_frame_host, browser_context,
current_instance, url))
if (!ShouldCreateNewSiteInstance(browser_context, current_instance, url))
return;
scoped_refptr<content::SiteInstance> site_instance =
@@ -241,6 +209,11 @@ void AtomBrowserClient::OverrideSiteInstanceForNavigation(
void AtomBrowserClient::AppendExtraCommandLineSwitches(
base::CommandLine* command_line,
int process_id) {
// Make sure we're about to launch a known executable
base::FilePath child_path;
PathService::Get(content::CHILD_PROCESS_EXE, &child_path);
CHECK(base::MakeAbsoluteFilePath(command_line->GetProgram()) == child_path);
std::string process_type = command_line->GetSwitchValueASCII("type");
if (process_type != "renderer")
return;
@@ -330,41 +303,31 @@ void AtomBrowserClient::ResourceDispatcherHostCreated() {
}
bool AtomBrowserClient::CanCreateWindow(
int opener_render_process_id,
int opener_render_frame_id,
const GURL& opener_url,
const GURL& opener_top_level_frame_url,
const GURL& source_origin,
content::mojom::WindowContainerType container_type,
WindowContainerType container_type,
const GURL& target_url,
const content::Referrer& referrer,
const std::string& frame_name,
WindowOpenDisposition disposition,
const blink::mojom::WindowFeatures& features,
const blink::WebWindowFeatures& features,
const std::vector<std::string>& additional_features,
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
bool user_gesture,
bool opener_suppressed,
content::ResourceContext* context,
int render_process_id,
int opener_render_view_id,
int opener_render_frame_id,
bool* no_javascript_access) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
if (IsRendererSandboxed(opener_render_process_id)) {
if (IsRendererSandboxed(render_process_id)) {
*no_javascript_access = false;
return true;
}
if (RendererUsesNativeWindowOpen(opener_render_process_id)) {
if (RendererDisablesPopups(opener_render_process_id)) {
// <webview> without allowpopups attribute should return
// null from window.open calls
return false;
} else {
*no_javascript_access = false;
return true;
}
}
if (delegate_) {
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
base::Bind(&api::App::OnCreateWindow,
@@ -374,7 +337,7 @@ bool AtomBrowserClient::CanCreateWindow(
disposition,
additional_features,
body,
opener_render_process_id,
render_process_id,
opener_render_frame_id));
}
@@ -425,27 +388,7 @@ void AtomBrowserClient::RenderProcessHostDestroyed(
break;
}
}
RemoveProcessPreferences(process_id);
}
void AtomBrowserClient::RenderProcessReady(content::RenderProcessHost* host) {
render_process_host_pids_[host->GetID()] = base::GetProcId(host->GetHandle());
if (delegate_) {
static_cast<api::App*>(delegate_)->RenderProcessReady(host);
}
}
void AtomBrowserClient::RenderProcessExited(content::RenderProcessHost* host,
base::TerminationStatus status,
int exit_code) {
auto host_pid = render_process_host_pids_.find(host->GetID());
if (host_pid != render_process_host_pids_.end()) {
if (delegate_) {
static_cast<api::App*>(delegate_)->RenderProcessDisconnected(
host_pid->second);
}
render_process_host_pids_.erase(host_pid);
}
RemoveSandboxedRendererId(process_id);
}
} // namespace atom

View File

@@ -80,22 +80,23 @@ class AtomBrowserClient : public brightray::BrowserClient,
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
void ResourceDispatcherHostCreated() override;
bool CanCreateWindow(
int opener_render_process_id,
int opener_render_frame_id,
const GURL& opener_url,
const GURL& opener_top_level_frame_url,
const GURL& source_origin,
content::mojom::WindowContainerType container_type,
WindowContainerType container_type,
const GURL& target_url,
const content::Referrer& referrer,
const std::string& frame_name,
WindowOpenDisposition disposition,
const blink::mojom::WindowFeatures& features,
const blink::WebWindowFeatures& features,
const std::vector<std::string>& additional_features,
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
bool user_gesture,
bool opener_suppressed,
content::ResourceContext* context,
int render_process_id,
int opener_render_view_id,
int opener_render_frame_id,
bool* no_javascript_access) override;
void GetAdditionalAllowedSchemesForFileSystem(
std::vector<std::string>* schemes) override;
@@ -109,33 +110,21 @@ class AtomBrowserClient : public brightray::BrowserClient,
// content::RenderProcessHostObserver:
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
void RenderProcessReady(content::RenderProcessHost* host) override;
void RenderProcessExited(content::RenderProcessHost* host,
base::TerminationStatus status,
int exit_code) override;
private:
bool ShouldCreateNewSiteInstance(content::RenderFrameHost* render_frame_host,
content::BrowserContext* browser_context,
bool ShouldCreateNewSiteInstance(content::BrowserContext* browser_context,
content::SiteInstance* current_instance,
const GURL& dest_url);
struct ProcessPreferences {
bool sandbox;
bool native_window_open;
bool disable_popups;
};
void AddProcessPreferences(int process_id, ProcessPreferences prefs);
void RemoveProcessPreferences(int process_id);
// Add/remove a process id to `sandboxed_renderers_`.
void AddSandboxedRendererId(int process_id);
void RemoveSandboxedRendererId(int process_id);
bool IsRendererSandboxed(int process_id);
bool RendererUsesNativeWindowOpen(int process_id);
bool RendererDisablesPopups(int process_id);
// pending_render_process => current_render_process.
std::map<int, int> pending_processes_;
std::map<int, ProcessPreferences> process_preferences_;
std::map<int, base::ProcessId> render_process_host_pids_;
base::Lock process_preferences_lock_;
// Set that contains the process ids of all sandboxed renderers
std::set<int> sandboxed_renderers_;
base::Lock sandboxed_renderers_lock_;
std::unique_ptr<AtomResourceDispatcherHostDelegate>
resource_dispatcher_host_delegate_;

View File

@@ -129,14 +129,17 @@ void AtomBrowserMainParts::PostEarlyInitialization() {
node_bindings_->Initialize();
// Support the "--debug" switch.
node_debugger_.reset(new NodeDebugger(js_env_->isolate()));
// Create the global environment.
node::Environment* env =
node_bindings_->CreateEnvironment(js_env_->context());
node_env_.reset(new NodeEnvironment(env));
// Enable support for v8 inspector
node_debugger_.reset(new NodeDebugger(env));
node_debugger_->Start();
// Make sure node can get correct environment when debugging.
if (node_debugger_->IsRunning())
env->AssignToContext(v8::Debug::GetDebugContext(js_env_->isolate()));
// Add Electron extended APIs.
atom_bindings_->BindTo(js_env_->isolate(), env->process_object());

View File

@@ -7,37 +7,33 @@
#include <string>
#include <vector>
#include "atom/browser/api/atom_api_web_contents.h"
#include "atom/browser/native_window.h"
#include "atom/browser/ui/message_box.h"
#include "base/bind.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/gfx/image/image_skia.h"
using content::JavaScriptDialogType;
using content::JavaScriptMessageType;
namespace atom {
AtomJavaScriptDialogManager::AtomJavaScriptDialogManager(
api::WebContents* api_web_contents)
: api_web_contents_(api_web_contents) {}
void AtomJavaScriptDialogManager::RunJavaScriptDialog(
content::WebContents* web_contents,
const GURL& origin_url,
JavaScriptDialogType dialog_type,
JavaScriptMessageType message_type,
const base::string16& message_text,
const base::string16& default_prompt_text,
const DialogClosedCallback& callback,
bool* did_suppress_message) {
if (dialog_type != JavaScriptDialogType::JAVASCRIPT_DIALOG_TYPE_ALERT &&
dialog_type != JavaScriptDialogType::JAVASCRIPT_DIALOG_TYPE_CONFIRM) {
if (message_type != JavaScriptMessageType::JAVASCRIPT_MESSAGE_TYPE_ALERT &&
message_type != JavaScriptMessageType::JAVASCRIPT_MESSAGE_TYPE_CONFIRM) {
callback.Run(false, base::string16());
return;
}
std::vector<std::string> buttons = {"OK"};
if (dialog_type == JavaScriptDialogType::JAVASCRIPT_DIALOG_TYPE_CONFIRM) {
if (message_type == JavaScriptMessageType::JAVASCRIPT_MESSAGE_TYPE_CONFIRM) {
buttons.push_back("Cancel");
}
@@ -53,13 +49,13 @@ void AtomJavaScriptDialogManager::RunBeforeUnloadDialog(
content::WebContents* web_contents,
bool is_reload,
const DialogClosedCallback& callback) {
bool default_prevented = api_web_contents_->Emit("will-prevent-unload");
callback.Run(default_prevented, base::string16());
return;
// FIXME(zcbenz): the |message_text| is removed, figure out what should we do.
callback.Run(false, base::ASCIIToUTF16("This should not be displayed"));
}
void AtomJavaScriptDialogManager::CancelDialogs(
content::WebContents* web_contents,
bool suppress_callbacks,
bool reset_state) {
}

View File

@@ -11,19 +11,13 @@
namespace atom {
namespace api {
class WebContents;
}
class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager {
public:
explicit AtomJavaScriptDialogManager(api::WebContents* api_web_contents);
// content::JavaScriptDialogManager implementations.
void RunJavaScriptDialog(
content::WebContents* web_contents,
const GURL& origin_url,
content::JavaScriptDialogType dialog_type,
content::JavaScriptMessageType javascript_message_type,
const base::string16& message_text,
const base::string16& default_prompt_text,
const DialogClosedCallback& callback,
@@ -33,13 +27,13 @@ class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager {
bool is_reload,
const DialogClosedCallback& callback) override;
void CancelDialogs(content::WebContents* web_contents,
bool suppress_callbacks,
bool reset_state) override;
private:
static void OnMessageBoxCallback(const DialogClosedCallback& callback,
int code,
bool checkbox_checked);
api::WebContents* api_web_contents_;
};
} // namespace atom

View File

@@ -131,7 +131,7 @@ int AtomPermissionManager::RequestPermissions(
auto web_contents =
content::WebContents::FromRenderFrameHost(render_frame_host);
int request_id = pending_requests_.Add(base::MakeUnique<PendingRequest>(
int request_id = pending_requests_.Add(new PendingRequest(
render_frame_host, permissions, response_callback));
for (size_t i = 0; i < permissions.size(); ++i) {
@@ -187,6 +187,12 @@ blink::mojom::PermissionStatus AtomPermissionManager::GetPermissionStatus(
return blink::mojom::PermissionStatus::GRANTED;
}
void AtomPermissionManager::RegisterPermissionUsage(
content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) {
}
int AtomPermissionManager::SubscribePermissionStatusChange(
content::PermissionType permission,
const GURL& requesting_origin,

View File

@@ -66,6 +66,9 @@ class AtomPermissionManager : public content::PermissionManager {
content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) override;
void RegisterPermissionUsage(content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) override;
int SubscribePermissionStatusChange(
content::PermissionType permission,
const GURL& requesting_origin,
@@ -76,7 +79,7 @@ class AtomPermissionManager : public content::PermissionManager {
private:
class PendingRequest;
using PendingRequestsMap = IDMap<std::unique_ptr<PendingRequest>>;
using PendingRequestsMap = IDMap<PendingRequest, IDMapOwnPointer>;
RequestHandler request_handler_;

View File

@@ -57,9 +57,6 @@ AtomWebUIControllerFactory::CreateWebUIControllerForURL(content::WebUI* web_ui,
src = param.second;
}
}
if (url.has_ref()) {
src = src + '#' + url.ref();
}
auto browser_context = web_ui->GetWebContents()->GetBrowserContext();
return new PdfViewerUI(browser_context, web_ui, src);
}

View File

@@ -213,11 +213,4 @@ void Browser::OnWindowAllClosed() {
}
}
#if defined(OS_MACOSX)
void Browser::NewWindowForTab() {
for (BrowserObserver& observer : observers_)
observer.OnNewWindowForTab();
}
#endif
} // namespace atom

View File

@@ -183,11 +183,6 @@ class Browser : public WindowListObserver {
// Tell the application to open a url.
void OpenURL(const std::string& url);
#if defined(OS_MACOSX)
// Tell the application to create a new window for a tab.
void NewWindowForTab();
#endif // defined(OS_MACOSX)
// Tell the application that application is activated with visible/invisible
// windows.
void Activate(bool has_visible_windows);

View File

@@ -61,9 +61,6 @@ class BrowserObserver {
bool* prevent_default,
const std::string& type,
const base::DictionaryValue& user_info) {}
// User clicked the native macOS new tab button. (macOS only)
virtual void OnNewWindowForTab() {}
#endif
protected:

View File

@@ -1,33 +0,0 @@
// Copyright (c) 2017 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/browser/child_web_contents_tracker.h"
#include <unordered_set>
namespace atom {
namespace {
std::unordered_set<content::WebContents*> g_child_web_contents;
} // namespace
ChildWebContentsTracker::ChildWebContentsTracker(
content::WebContents* web_contents)
: content::WebContentsObserver(web_contents) {
g_child_web_contents.insert(web_contents);
}
bool ChildWebContentsTracker::IsChildWebContents(
content::WebContents* web_contents) {
return g_child_web_contents.find(web_contents) != g_child_web_contents.end();
}
void ChildWebContentsTracker::WebContentsDestroyed() {
g_child_web_contents.erase(web_contents());
delete this;
}
} // namespace atom

View File

@@ -1,25 +0,0 @@
// Copyright (c) 2017 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_CHILD_WEB_CONTENTS_TRACKER_H_
#define ATOM_BROWSER_CHILD_WEB_CONTENTS_TRACKER_H_
#include "content/public/browser/web_contents_observer.h"
namespace atom {
// ChildWebContentsTracker tracks child WebContents
// created by native `window.open()`
class ChildWebContentsTracker : public content::WebContentsObserver {
public:
explicit ChildWebContentsTracker(content::WebContents* web_contents);
static bool IsChildWebContents(content::WebContents* web_contents);
protected:
void WebContentsDestroyed() override;
};
} // namespace atom
#endif // ATOM_BROWSER_CHILD_WEB_CONTENTS_TRACKER_H_

View File

@@ -9,6 +9,7 @@
#include <vector>
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/atom_javascript_dialog_manager.h"
#include "atom/browser/native_window.h"
#include "atom/browser/ui/file_dialog.h"
#include "atom/browser/web_dialog_helper.h"
@@ -149,8 +150,7 @@ bool IsDevToolsFileSystemAdded(
} // namespace
CommonWebContentsDelegate::CommonWebContentsDelegate()
: ignore_menu_shortcuts_(false),
html_fullscreen_(false),
: html_fullscreen_(false),
native_fullscreen_(false),
devtools_file_system_indexer_(new DevToolsFileSystemIndexer) {
}
@@ -230,6 +230,15 @@ bool CommonWebContentsDelegate::CanOverscrollContent() const {
return false;
}
content::JavaScriptDialogManager*
CommonWebContentsDelegate::GetJavaScriptDialogManager(
content::WebContents* source) {
if (!dialog_manager_)
dialog_manager_.reset(new AtomJavaScriptDialogManager);
return dialog_manager_.get();
}
content::ColorChooser* CommonWebContentsDelegate::OpenColorChooser(
content::WebContents* web_contents,
SkColor color,
@@ -485,9 +494,9 @@ void CommonWebContentsDelegate::OnDevToolsIndexingWorkCalculated(
int request_id,
const std::string& file_system_path,
int total_work) {
base::Value request_id_value(request_id);
base::FundamentalValue request_id_value(request_id);
base::StringValue file_system_path_value(file_system_path);
base::Value total_work_value(total_work);
base::FundamentalValue total_work_value(total_work);
web_contents_->CallClientFunction("DevToolsAPI.indexingTotalWorkCalculated",
&request_id_value,
&file_system_path_value,
@@ -498,9 +507,9 @@ void CommonWebContentsDelegate::OnDevToolsIndexingWorked(
int request_id,
const std::string& file_system_path,
int worked) {
base::Value request_id_value(request_id);
base::FundamentalValue request_id_value(request_id);
base::StringValue file_system_path_value(file_system_path);
base::Value worked_value(worked);
base::FundamentalValue worked_value(worked);
web_contents_->CallClientFunction("DevToolsAPI.indexingWorked",
&request_id_value,
&file_system_path_value,
@@ -511,7 +520,7 @@ void CommonWebContentsDelegate::OnDevToolsIndexingDone(
int request_id,
const std::string& file_system_path) {
devtools_indexing_jobs_.erase(request_id);
base::Value request_id_value(request_id);
base::FundamentalValue request_id_value(request_id);
base::StringValue file_system_path_value(file_system_path);
web_contents_->CallClientFunction("DevToolsAPI.indexingDone",
&request_id_value,
@@ -527,7 +536,7 @@ void CommonWebContentsDelegate::OnDevToolsSearchCompleted(
for (const auto& file_path : file_paths) {
file_paths_value.AppendString(file_path);
}
base::Value request_id_value(request_id);
base::FundamentalValue request_id_value(request_id);
base::StringValue file_system_path_value(file_system_path);
web_contents_->CallClientFunction("DevToolsAPI.searchCompleted",
&request_id_value,

View File

@@ -20,6 +20,7 @@ using brightray::DevToolsFileSystemIndexer;
namespace atom {
class AtomBrowserContext;
class AtomJavaScriptDialogManager;
class NativeWindow;
class WebDialogHelper;
@@ -53,10 +54,6 @@ class CommonWebContentsDelegate
NativeWindow* owner_window() const { return owner_window_.get(); }
void set_ignore_menu_shortcuts(bool ignore) {
ignore_menu_shortcuts_ = ignore;
}
bool is_html_fullscreen() const { return html_fullscreen_; }
protected:
@@ -65,6 +62,8 @@ class CommonWebContentsDelegate
content::WebContents* source,
const content::OpenURLParams& params) override;
bool CanOverscrollContent() const override;
content::JavaScriptDialogManager* GetJavaScriptDialogManager(
content::WebContents* source) override;
content::ColorChooser* OpenColorChooser(
content::WebContents* web_contents,
SkColor color,
@@ -141,8 +140,6 @@ class CommonWebContentsDelegate
// The window that this WebContents belongs to.
base::WeakPtr<NativeWindow> owner_window_;
bool ignore_menu_shortcuts_;
// Whether window is fullscreened by HTML5 api.
bool html_fullscreen_;
@@ -150,6 +147,7 @@ class CommonWebContentsDelegate
bool native_fullscreen_;
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.

View File

@@ -20,23 +20,21 @@ void CommonWebContentsDelegate::HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) {
if (event.skip_in_browser ||
event.type() == content::NativeWebKeyboardEvent::Char)
event.type == content::NativeWebKeyboardEvent::Char)
return;
// Escape exits tabbed fullscreen mode.
if (event.windowsKeyCode == ui::VKEY_ESCAPE && is_html_fullscreen())
ExitFullscreenModeForTab(source);
if (!ignore_menu_shortcuts_) {
// Send the event to the menu before sending it to the window
if (event.os_event.type == NSKeyDown &&
[[NSApp mainMenu] performKeyEquivalent:event.os_event])
return;
// Send the event to the menu before sending it to the window
if (event.os_event.type == NSKeyDown &&
[[NSApp mainMenu] performKeyEquivalent:event.os_event])
return;
if (event.os_event.window &&
[event.os_event.window isKindOfClass:[EventDispatchingWindow class]])
[event.os_event.window redispatchKeyEvent:event.os_event];
}
if (event.os_event.window &&
[event.os_event.window isKindOfClass:[EventDispatchingWindow class]])
[event.os_event.window redispatchKeyEvent:event.os_event];
}
} // namespace atom

View File

@@ -23,7 +23,7 @@ void CommonWebContentsDelegate::HandleKeyboardEvent(
ExitFullscreenModeForTab(source);
// Let the NativeWindow handle other parts.
if (!ignore_menu_shortcuts_ && owner_window())
if (owner_window())
owner_window()->HandleKeyboardEvent(source, event);
}

View File

@@ -8,7 +8,6 @@
#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
#include "base/threading/thread_task_runner_handle.h"
#include "content/public/common/content_switches.h"
#include "gin/array_buffer.h"
#include "gin/v8_initializer.h"
@@ -19,7 +18,6 @@ namespace atom {
JavascriptEnvironment::JavascriptEnvironment()
: initialized_(Initialize()),
isolate_holder_(base::ThreadTaskRunnerHandle::Get()),
isolate_(isolate_holder_.isolate()),
isolate_scope_(isolate_),
locker_(isolate_),

View File

@@ -15,12 +15,12 @@ LayeredResourceHandler::LayeredResourceHandler(
LayeredResourceHandler::~LayeredResourceHandler() {}
void LayeredResourceHandler::OnResponseStarted(
bool LayeredResourceHandler::OnResponseStarted(
content::ResourceResponse* response,
std::unique_ptr<content::ResourceController> controller) {
bool* defer) {
if (delegate_)
delegate_->OnResponseStarted(response);
next_handler_->OnResponseStarted(response, std::move(controller));
return next_handler_->OnResponseStarted(response, defer);
}
} // namespace atom

View File

@@ -26,9 +26,8 @@ class LayeredResourceHandler : public content::LayeredResourceHandler {
~LayeredResourceHandler() override;
// content::LayeredResourceHandler:
void OnResponseStarted(
content::ResourceResponse* response,
std::unique_ptr<content::ResourceController> controller) override;
bool OnResponseStarted(content::ResourceResponse* response,
bool* defer) override;
private:
Delegate* delegate_;

View File

@@ -81,8 +81,4 @@ continueUserActivity:(NSUserActivity*)userActivity
return browser->ContinueUserActivity(activity_type, *user_info) ? YES : NO;
}
- (IBAction)newWindowForTab:(id)sender {
atom::Browser::Get()->NewWindowForTab();
}
@end

View File

@@ -18,6 +18,10 @@ class Rect;
namespace atom {
namespace api {
class WebContents;
}
enum AutoResizeFlags {
kAutoResizeWidth = 0x1,
kAutoResizeHeight = 0x2,

View File

@@ -251,7 +251,7 @@ void NativeWindow::SetSizeConstraints(
SetContentSizeConstraints(content_constraints);
}
extensions::SizeConstraints NativeWindow::GetSizeConstraints() const {
extensions::SizeConstraints NativeWindow::GetSizeConstraints() {
extensions::SizeConstraints content_constraints = GetContentSizeConstraints();
extensions::SizeConstraints window_constraints;
if (content_constraints.HasMaximumSize()) {
@@ -272,7 +272,7 @@ void NativeWindow::SetContentSizeConstraints(
size_constraints_ = size_constraints;
}
extensions::SizeConstraints NativeWindow::GetContentSizeConstraints() const {
extensions::SizeConstraints NativeWindow::GetContentSizeConstraints() {
return size_constraints_;
}
@@ -282,7 +282,7 @@ void NativeWindow::SetMinimumSize(const gfx::Size& size) {
SetSizeConstraints(size_constraints);
}
gfx::Size NativeWindow::GetMinimumSize() const {
gfx::Size NativeWindow::GetMinimumSize() {
return GetSizeConstraints().GetMinimumSize();
}
@@ -292,7 +292,7 @@ void NativeWindow::SetMaximumSize(const gfx::Size& size) {
SetSizeConstraints(size_constraints);
}
gfx::Size NativeWindow::GetMaximumSize() const {
gfx::Size NativeWindow::GetMaximumSize() {
return GetSizeConstraints().GetMaximumSize();
}
@@ -597,11 +597,6 @@ void NativeWindow::NotifyTouchBarItemInteraction(
observer.OnTouchBarItemResult(item_id, details);
}
void NativeWindow::NotifyNewWindowForTab() {
for (NativeWindowObserver &observer : observers_)
observer.OnNewWindowForTab();
}
#if defined(OS_WIN)
void NativeWindow::NotifyWindowMessage(
UINT message, WPARAM w_param, LPARAM l_param) {

View File

@@ -18,12 +18,10 @@
#include "base/observer_list.h"
#include "base/supports_user_data.h"
#include "content/public/browser/readback_types.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
#include "extensions/browser/app_window/size_constraints.h"
#include "native_mate/persistent_dictionary.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
@@ -100,14 +98,14 @@ class NativeWindow : public base::SupportsUserData,
virtual gfx::Rect GetContentBounds();
virtual void SetSizeConstraints(
const extensions::SizeConstraints& size_constraints);
virtual extensions::SizeConstraints GetSizeConstraints() const;
virtual extensions::SizeConstraints GetSizeConstraints();
virtual void SetContentSizeConstraints(
const extensions::SizeConstraints& size_constraints);
virtual extensions::SizeConstraints GetContentSizeConstraints() const;
virtual extensions::SizeConstraints GetContentSizeConstraints();
virtual void SetMinimumSize(const gfx::Size& size);
virtual gfx::Size GetMinimumSize() const;
virtual gfx::Size GetMinimumSize();
virtual void SetMaximumSize(const gfx::Size& size);
virtual gfx::Size GetMaximumSize() const;
virtual gfx::Size GetMaximumSize();
virtual void SetSheetOffset(const double offsetX, const double offsetY);
virtual double GetSheetOffsetX();
virtual double GetSheetOffsetY();
@@ -149,9 +147,8 @@ class NativeWindow : public base::SupportsUserData,
virtual void SetMenu(AtomMenuModel* menu);
virtual void SetParentWindow(NativeWindow* parent);
virtual void SetBrowserView(NativeBrowserView* browser_view) = 0;
virtual gfx::NativeView GetNativeView() const = 0;
virtual gfx::NativeWindow GetNativeWindow() const = 0;
virtual gfx::AcceleratedWidget GetAcceleratedWidget() const = 0;
virtual gfx::NativeWindow GetNativeWindow() = 0;
virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0;
// Taskbar/Dock APIs.
enum ProgressState {
@@ -217,12 +214,6 @@ class NativeWindow : public base::SupportsUserData,
virtual void HandleKeyboardEvent(
content::WebContents*,
const content::NativeWebKeyboardEvent& event) {}
virtual void ShowAutofillPopup(
content::RenderFrameHost* frame_host,
const gfx::RectF& bounds,
const std::vector<base::string16>& values,
const std::vector<base::string16>& labels) {}
virtual void HideAutofillPopup(content::RenderFrameHost* frame_host) {}
// Public API used by platform-dependent delegates and observers to send UI
// related notifications.
@@ -252,7 +243,6 @@ class NativeWindow : public base::SupportsUserData,
void NotifyWindowExecuteWindowsCommand(const std::string& command);
void NotifyTouchBarItemInteraction(const std::string& item_id,
const base::DictionaryValue& details);
void NotifyNewWindowForTab();
#if defined(OS_WIN)
void NotifyWindowMessage(UINT message, WPARAM w_param, LPARAM l_param);
@@ -290,10 +280,8 @@ class NativeWindow : public base::SupportsUserData,
const std::vector<DraggableRegion>& regions);
// Converts between content bounds and window bounds.
virtual gfx::Rect ContentBoundsToWindowBounds(
const gfx::Rect& bounds) const = 0;
virtual gfx::Rect WindowBoundsToContentBounds(
const gfx::Rect& bounds) const = 0;
virtual gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& bounds) = 0;
virtual gfx::Rect WindowBoundsToContentBounds(const gfx::Rect& bounds) = 0;
// Called when the window needs to update its draggable region.
virtual void UpdateDraggableRegions(

View File

@@ -89,9 +89,8 @@ class NativeWindowMac : public NativeWindow,
void SetContentProtection(bool enable) override;
void SetBrowserView(NativeBrowserView* browser_view) override;
void SetParentWindow(NativeWindow* parent) override;
gfx::NativeView GetNativeView() const override;
gfx::NativeWindow GetNativeWindow() const override;
gfx::AcceleratedWidget GetAcceleratedWidget() const override;
gfx::NativeWindow GetNativeWindow() override;
gfx::AcceleratedWidget GetAcceleratedWidget() override;
void SetProgressBar(double progress, const ProgressState state) override;
void SetOverlayIcon(const gfx::Image& overlay,
const std::string& description) override;
@@ -127,7 +126,6 @@ class NativeWindowMac : public NativeWindow,
NORMAL,
HIDDEN,
HIDDEN_INSET,
CUSTOM_BUTTONS_ON_HOVER,
};
TitleBarStyle title_bar_style() const { return title_bar_style_; }
@@ -141,8 +139,8 @@ class NativeWindowMac : public NativeWindow,
private:
// NativeWindow:
gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& bounds) const;
gfx::Rect WindowBoundsToContentBounds(const gfx::Rect& bounds) const;
gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& bounds);
gfx::Rect WindowBoundsToContentBounds(const gfx::Rect& bounds);
void UpdateDraggableRegions(
const std::vector<DraggableRegion>& regions) override;

View File

@@ -7,7 +7,6 @@
#include <Quartz/Quartz.h>
#include <string>
#include "atom/browser/browser.h"
#include "atom/browser/native_browser_view_mac.h"
#include "atom/browser/ui/cocoa/atom_touch_bar.h"
#include "atom/browser/window_list.h"
@@ -47,102 +46,6 @@ bool ScopedDisableResize::disable_resize_ = false;
} // namespace
// Custom Quit, Minimize and Full Screen button container for frameless
// windows.
@interface CustomWindowButtonView : NSView {
@private
BOOL mouse_inside_;
}
@end
@implementation CustomWindowButtonView
- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
NSButton* close_button = [NSWindow standardWindowButton:NSWindowCloseButton
forStyleMask:NSTitledWindowMask];
NSButton* miniaturize_button =
[NSWindow standardWindowButton:NSWindowMiniaturizeButton
forStyleMask:NSTitledWindowMask];
NSButton* zoom_button = [NSWindow standardWindowButton:NSWindowZoomButton
forStyleMask:NSTitledWindowMask];
CGFloat x = 0;
const CGFloat space_between = 20;
[close_button setFrameOrigin:NSMakePoint(x, 0)];
x += space_between;
[self addSubview:close_button];
[miniaturize_button setFrameOrigin:NSMakePoint(x, 0)];
x += space_between;
[self addSubview:miniaturize_button];
[zoom_button setFrameOrigin:NSMakePoint(x, 0)];
x += space_between;
[self addSubview:zoom_button];
const auto last_button_frame = zoom_button.frame;
[self setFrameSize:NSMakeSize(last_button_frame.origin.x +
last_button_frame.size.width,
last_button_frame.size.height)];
mouse_inside_ = NO;
[self setNeedsDisplayForButtons];
return self;
}
- (void)viewDidMoveToWindow {
if (!self.window) {
return;
}
// Stay in upper left corner.
const CGFloat top_margin = 3;
const CGFloat left_margin = 7;
[self setAutoresizingMask:NSViewMaxXMargin | NSViewMinYMargin];
[self setFrameOrigin:NSMakePoint(left_margin, self.window.frame.size.height -
self.frame.size.height -
top_margin)];
}
- (BOOL)_mouseInGroup:(NSButton*)button {
return mouse_inside_;
}
- (void)updateTrackingAreas {
auto tracking_area = [[[NSTrackingArea alloc]
initWithRect:NSZeroRect
options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways |
NSTrackingInVisibleRect
owner:self
userInfo:nil] autorelease];
[self addTrackingArea:tracking_area];
}
- (void)mouseEntered:(NSEvent*)event {
[super mouseEntered:event];
mouse_inside_ = YES;
[self setNeedsDisplayForButtons];
}
- (void)mouseExited:(NSEvent*)event {
[super mouseExited:event];
mouse_inside_ = NO;
[self setNeedsDisplayForButtons];
}
- (void)setNeedsDisplayForButtons {
for (NSView* subview in self.subviews) {
[subview setHidden:!mouse_inside_];
[subview setNeedsDisplay:YES];
}
}
@end
// This view always takes the size of its superview. It is intended to be used
// as a NSWindow's contentView. It is needed because NSWindow's implementation
// explicitly resizes the contentView at inopportune times.
@@ -396,7 +299,7 @@ bool ScopedDisableResize::disable_resize_ = false;
- (BOOL)windowShouldClose:(id)window {
// When user tries to close the window by clicking the close button, we do
// not close the window immediately, instead we try to close the web page
// first, and when the web page is closed the window will also be closed.
// fisrt, and when the web page is closed the window will also be closed.
shell_->RequestToClosePage();
return NO;
}
@@ -418,11 +321,6 @@ bool ScopedDisableResize::disable_resize_ = false;
shell_->NotifyWindowSheetEnd();
}
- (IBAction)newWindowForTab:(id)sender {
shell_->NotifyNewWindowForTab();
atom::Browser::Get()->NewWindowForTab();
}
@end
@interface AtomPreviewItem : NSObject <QLPreviewItem>
@@ -698,22 +596,6 @@ enum {
[[QLPreviewPanel sharedPreviewPanel] makeKeyAndOrderFront:nil];
}
// Custom window button methods
- (void)performClose:(id)sender {
if (shell_->title_bar_style() == atom::NativeWindowMac::CUSTOM_BUTTONS_ON_HOVER)
[[self delegate] windowShouldClose:self];
else
[super performClose:sender];
}
- (void)performMiniaturize:(id)sender {
if (shell_->title_bar_style() == atom::NativeWindowMac::CUSTOM_BUTTONS_ON_HOVER)
[self miniaturize:self];
else
[super performMiniaturize:sender];
}
@end
@interface ControlRegionView : NSView
@@ -779,11 +661,9 @@ struct Converter<atom::NativeWindowMac::TitleBarStyle> {
return false;
if (title_bar_style == "hidden") {
*out = atom::NativeWindowMac::HIDDEN;
} else if (title_bar_style == "hidden-inset" || // TODO(kevinsawicki): Remove in 2.0, deprecate before then with warnings
} else if (title_bar_style == "hidden-inset" || // Deprecate this after 2.0
title_bar_style == "hiddenInset") {
*out = atom::NativeWindowMac::HIDDEN_INSET;
} else if (title_bar_style == "customButtonsOnHover") {
*out = atom::NativeWindowMac::CUSTOM_BUTTONS_ON_HOVER;
} else {
return false;
}
@@ -846,11 +726,6 @@ NativeWindowMac::NativeWindowMac(
}
NSUInteger styleMask = NSTitledWindowMask;
if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER &&
base::mac::IsAtLeastOS10_10() &&
(!useStandardWindow || transparent() || !has_frame())) {
styleMask = NSFullSizeContentViewWindowMask;
}
if (minimizable) {
styleMask |= NSMiniaturizableWindowMask;
}
@@ -905,7 +780,6 @@ NativeWindowMac::NativeWindowMac(
if (transparent() || !has_frame()) {
if (base::mac::IsAtLeastOS10_10()) {
// Don't show title bar.
[window_ setTitlebarAppearsTransparent:YES];
[window_ setTitleVisibility:NSWindowTitleHidden];
}
// Remove non-transparent corners, see http://git.io/vfonD.
@@ -1440,15 +1314,11 @@ void NativeWindowMac::SetParentWindow(NativeWindow* parent) {
[parent->GetNativeWindow() addChildWindow:window_ ordered:NSWindowAbove];
}
gfx::NativeView NativeWindowMac::GetNativeView() const {
return inspectable_web_contents()->GetView()->GetNativeView();
}
gfx::NativeWindow NativeWindowMac::GetNativeWindow() const {
gfx::NativeWindow NativeWindowMac::GetNativeWindow() {
return window_;
}
gfx::AcceleratedWidget NativeWindowMac::GetAcceleratedWidget() const {
gfx::AcceleratedWidget NativeWindowMac::GetAcceleratedWidget() {
return inspectable_web_contents()->GetView()->GetNativeView();
}
@@ -1588,7 +1458,7 @@ void NativeWindowMac::SetEscapeTouchBarItem(const mate::PersistentDictionary& it
}
void NativeWindowMac::OnInputEvent(const blink::WebInputEvent& event) {
switch (event.type()) {
switch (event.type) {
case blink::WebInputEvent::GestureScrollBegin:
case blink::WebInputEvent::GestureScrollUpdate:
case blink::WebInputEvent::GestureScrollEnd:
@@ -1624,7 +1494,7 @@ std::vector<gfx::Rect> NativeWindowMac::CalculateNonDraggableRegions(
}
gfx::Rect NativeWindowMac::ContentBoundsToWindowBounds(
const gfx::Rect& bounds) const {
const gfx::Rect& bounds) {
if (has_frame()) {
gfx::Rect window_bounds(
[window_ frameRectForContentRect:bounds.ToCGRect()]);
@@ -1637,7 +1507,7 @@ gfx::Rect NativeWindowMac::ContentBoundsToWindowBounds(
}
gfx::Rect NativeWindowMac::WindowBoundsToContentBounds(
const gfx::Rect& bounds) const {
const gfx::Rect& bounds) {
if (has_frame()) {
gfx::Rect content_bounds(
[window_ contentRectForFrameRect:bounds.ToCGRect()]);
@@ -1689,26 +1559,21 @@ void NativeWindowMac::InstallView() {
// The fullscreen button should always be hidden for frameless window.
[[window_ standardWindowButton:NSWindowFullScreenButton] setHidden:YES];
if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER) {
NSView* window_button_view = [[[CustomWindowButtonView alloc]
initWithFrame:NSZeroRect] autorelease];
[content_view_ addSubview:window_button_view];
} else {
if (title_bar_style_ != NORMAL) {
if (base::mac::IsOS10_9()) {
ShowWindowButton(NSWindowZoomButton);
ShowWindowButton(NSWindowMiniaturizeButton);
ShowWindowButton(NSWindowCloseButton);
}
return;
if (title_bar_style_ != NORMAL) {
if (base::mac::IsOS10_9()) {
ShowWindowButton(NSWindowZoomButton);
ShowWindowButton(NSWindowMiniaturizeButton);
ShowWindowButton(NSWindowCloseButton);
}
// Hide the window buttons.
[[window_ standardWindowButton:NSWindowZoomButton] setHidden:YES];
[[window_ standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES];
[[window_ standardWindowButton:NSWindowCloseButton] setHidden:YES];
return;
}
// Hide the window buttons.
[[window_ standardWindowButton:NSWindowZoomButton] setHidden:YES];
[[window_ standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES];
[[window_ standardWindowButton:NSWindowCloseButton] setHidden:YES];
// Some third-party macOS utilities check the zoom button's enabled state to
// determine whether to show custom UI on hover, so we disable it here to
// prevent them from doing so in a frameless app window.

View File

@@ -78,7 +78,6 @@ class NativeWindowObserver {
virtual void OnWindowLeaveHtmlFullScreen() {}
virtual void OnTouchBarItemResult(const std::string& item_id,
const base::DictionaryValue& details) {}
virtual void OnNewWindowForTab() {}
// Called when window message received
#if defined(OS_WIN)

View File

@@ -7,7 +7,6 @@
#include <string>
#include <vector>
#include "atom/browser/api/atom_api_web_contents.h"
#include "atom/browser/native_browser_view_views.h"
#include "atom/browser/ui/views/menu_bar.h"
#include "atom/browser/window_list.h"
@@ -87,7 +86,7 @@ bool IsAltKey(const content::NativeWebKeyboardEvent& event) {
bool IsAltModifier(const content::NativeWebKeyboardEvent& event) {
typedef content::NativeWebKeyboardEvent::Modifiers Modifiers;
int modifiers = event.modifiers();
int modifiers = event.modifiers;
modifiers &= ~Modifiers::NumLockOn;
modifiers &= ~Modifiers::CapsLockOn;
return (modifiers == Modifiers::AltKey) ||
@@ -320,8 +319,6 @@ NativeWindowViews::NativeWindowViews(
window_->CenterWindow(size);
Layout();
autofill_popup_.reset(new AutofillPopup(GetNativeView()));
#if defined(OS_WIN)
// Save initial window state.
if (fullscreen)
@@ -480,8 +477,6 @@ void NativeWindowViews::SetFullScreen(bool fullscreen) {
#if defined(OS_WIN)
// There is no native fullscreen state on Windows.
bool leaving_fullscreen = IsFullscreen() && !fullscreen;
if (fullscreen) {
last_window_state_ = ui::SHOW_STATE_FULLSCREEN;
NotifyWindowEnterFullScreen();
@@ -507,13 +502,6 @@ void NativeWindowViews::SetFullScreen(bool fullscreen) {
// We set the new value after notifying, so we can handle the size event
// correctly.
window_->SetFullscreen(fullscreen);
// If restoring from fullscreen and the window isn't visible, force visible,
// else a non-responsive window shell could be rendered.
// (this situation may arise when app starts with fullscreen: true)
// Note: the following must be after "window_->SetFullscreen(fullscreen);"
if (leaving_fullscreen && !IsVisible())
FlipWindowStyle(GetAcceleratedWidget(), true, WS_VISIBLE);
#else
if (IsVisible())
window_->SetFullscreen(fullscreen);
@@ -779,14 +767,13 @@ void NativeWindowViews::SetBackgroundColor(const std::string& color_name) {
}
void NativeWindowViews::SetHasShadow(bool has_shadow) {
wm::SetShadowElevation(
wm::SetShadowType(
GetNativeWindow(),
has_shadow ? wm::ShadowElevation::MEDIUM : wm::ShadowElevation::NONE);
has_shadow ? wm::SHADOW_TYPE_RECTANGULAR : wm::SHADOW_TYPE_NONE);
}
bool NativeWindowViews::HasShadow() {
return GetNativeWindow()->GetProperty(wm::kShadowElevationKey)
!= wm::ShadowElevation::NONE;
return wm::GetShadowType(GetNativeWindow()) != wm::SHADOW_TYPE_NONE;
}
void NativeWindowViews::SetIgnoreMouseEvents(bool ignore) {
@@ -936,11 +923,7 @@ void NativeWindowViews::SetParentWindow(NativeWindow* parent) {
#endif
}
gfx::NativeView NativeWindowViews::GetNativeView() const {
return window_->GetNativeView();
}
gfx::NativeWindow NativeWindowViews::GetNativeWindow() const {
gfx::NativeWindow NativeWindowViews::GetNativeWindow() {
return window_->GetNativeWindow();
}
@@ -1011,7 +994,7 @@ bool NativeWindowViews::IsVisibleOnAllWorkspaces() {
return false;
}
gfx::AcceleratedWidget NativeWindowViews::GetAcceleratedWidget() const {
gfx::AcceleratedWidget NativeWindowViews::GetAcceleratedWidget() {
return GetNativeWindow()->GetHost()->GetAcceleratedWidget();
}
@@ -1192,7 +1175,7 @@ void NativeWindowViews::OnWidgetMove() {
}
gfx::Rect NativeWindowViews::ContentBoundsToWindowBounds(
const gfx::Rect& bounds) const {
const gfx::Rect& bounds) {
if (!has_frame())
return bounds;
@@ -1213,7 +1196,7 @@ gfx::Rect NativeWindowViews::ContentBoundsToWindowBounds(
}
gfx::Rect NativeWindowViews::WindowBoundsToContentBounds(
const gfx::Rect& bounds) const {
const gfx::Rect& bounds) {
if (!has_frame())
return bounds;
@@ -1251,10 +1234,10 @@ void NativeWindowViews::HandleKeyboardEvent(
// Show accelerator when "Alt" is pressed.
if (menu_bar_visible_ && IsAltKey(event))
menu_bar_->SetAcceleratorVisibility(
event.type() == blink::WebInputEvent::RawKeyDown);
event.type == blink::WebInputEvent::RawKeyDown);
// Show the submenu when "Alt+Key" is pressed.
if (event.type() == blink::WebInputEvent::RawKeyDown && !IsAltKey(event) &&
if (event.type == blink::WebInputEvent::RawKeyDown && !IsAltKey(event) &&
IsAltModifier(event)) {
if (!menu_bar_visible_ &&
(menu_bar_->GetAcceleratorIndex(event.windowsKeyCode) != -1))
@@ -1267,10 +1250,10 @@ void NativeWindowViews::HandleKeyboardEvent(
return;
// Toggle the menu bar only when a single Alt is released.
if (event.type() == blink::WebInputEvent::RawKeyDown && IsAltKey(event)) {
if (event.type == blink::WebInputEvent::RawKeyDown && IsAltKey(event)) {
// When a single Alt is pressed:
menu_bar_alt_pressed_ = true;
} else if (event.type() == blink::WebInputEvent::KeyUp && IsAltKey(event) &&
} else if (event.type == blink::WebInputEvent::KeyUp && IsAltKey(event) &&
menu_bar_alt_pressed_) {
// When a single Alt is released right after a Alt is pressed:
menu_bar_alt_pressed_ = false;
@@ -1281,26 +1264,6 @@ void NativeWindowViews::HandleKeyboardEvent(
}
}
void NativeWindowViews::ShowAutofillPopup(
content::RenderFrameHost* frame_host,
const gfx::RectF& bounds,
const std::vector<base::string16>& values,
const std::vector<base::string16>& labels) {
auto wc = atom::api::WebContents::FromWrappedClass(
v8::Isolate::GetCurrent(), web_contents());
autofill_popup_->CreateView(
frame_host,
wc->IsOffScreenOrEmbedderOffscreen(),
widget(),
bounds);
autofill_popup_->SetItems(values, labels);
}
void NativeWindowViews::HideAutofillPopup(
content::RenderFrameHost* frame_host) {
autofill_popup_->Hide();
}
void NativeWindowViews::Layout() {
const auto size = GetContentsBounds().size();
const auto menu_bar_bounds =
@@ -1338,11 +1301,11 @@ void NativeWindowViews::Layout() {
}
}
gfx::Size NativeWindowViews::GetMinimumSize() const {
gfx::Size NativeWindowViews::GetMinimumSize() {
return NativeWindow::GetMinimumSize();
}
gfx::Size NativeWindowViews::GetMaximumSize() const {
gfx::Size NativeWindowViews::GetMaximumSize() {
return NativeWindow::GetMaximumSize();
}

View File

@@ -11,7 +11,6 @@
#include <vector>
#include "atom/browser/ui/accelerator_util.h"
#include "atom/browser/ui/autofill_popup.h"
#include "ui/views/widget/widget_delegate.h"
#include "ui/views/widget/widget_observer.h"
@@ -107,8 +106,7 @@ class NativeWindowViews : public NativeWindow,
void SetMenu(AtomMenuModel* menu_model) override;
void SetBrowserView(NativeBrowserView* browser_view) override;
void SetParentWindow(NativeWindow* parent) override;
gfx::NativeView GetNativeView() const override;
gfx::NativeWindow GetNativeWindow() const override;
gfx::NativeWindow GetNativeWindow() override;
void SetOverlayIcon(const gfx::Image& overlay,
const std::string& description) override;
void SetProgressBar(double progress, const ProgressState state) override;
@@ -119,7 +117,7 @@ class NativeWindowViews : public NativeWindow,
void SetVisibleOnAllWorkspaces(bool visible) override;
bool IsVisibleOnAllWorkspaces() override;
gfx::AcceleratedWidget GetAcceleratedWidget() const override;
gfx::AcceleratedWidget GetAcceleratedWidget() override;
#if defined(OS_WIN)
void SetIcon(HICON small_icon, HICON app_icon);
@@ -172,22 +170,16 @@ class NativeWindowViews : public NativeWindow,
#endif
// NativeWindow:
gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& bounds) const override;
gfx::Rect WindowBoundsToContentBounds(const gfx::Rect& bounds) const override;
gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& bounds) override;
gfx::Rect WindowBoundsToContentBounds(const gfx::Rect& bounds) override;
void HandleKeyboardEvent(
content::WebContents*,
const content::NativeWebKeyboardEvent& event) override;
void ShowAutofillPopup(
content::RenderFrameHost* frame_host,
const gfx::RectF& bounds,
const std::vector<base::string16>& values,
const std::vector<base::string16>& labels) override;
void HideAutofillPopup(content::RenderFrameHost* frame_host) override;
// views::View:
void Layout() override;
gfx::Size GetMinimumSize() const override;
gfx::Size GetMaximumSize() const override;
gfx::Size GetMinimumSize() override;
gfx::Size GetMaximumSize() override;
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
// Register accelerators supported by the menu model.
@@ -201,8 +193,6 @@ class NativeWindowViews : public NativeWindow,
NativeBrowserView* browser_view_;
std::unique_ptr<AutofillPopup> autofill_popup_;
std::unique_ptr<MenuBar> menu_bar_;
bool menu_bar_autohide_;
bool menu_bar_visible_;

View File

@@ -50,16 +50,15 @@ bool AtomURLRequestJobFactory::InterceptProtocol(
return false;
ProtocolHandler* original_protocol_handler = protocol_handler_map_[scheme];
protocol_handler_map_[scheme] = protocol_handler.release();
original_protocols_[scheme].reset(original_protocol_handler);
original_protocols_.set(scheme, base::WrapUnique(original_protocol_handler));
return true;
}
bool AtomURLRequestJobFactory::UninterceptProtocol(const std::string& scheme) {
auto it = original_protocols_.find(scheme);
if (it == original_protocols_.end())
if (!original_protocols_.contains(scheme))
return false;
protocol_handler_map_[scheme] = it->second.release();
original_protocols_.erase(it);
protocol_handler_map_[scheme] =
original_protocols_.take_and_erase(scheme).release();
return true;
}
@@ -79,9 +78,7 @@ bool AtomURLRequestJobFactory::HasProtocolHandler(
}
void AtomURLRequestJobFactory::Clear() {
for (auto& it : protocol_handler_map_)
delete it.second;
protocol_handler_map_.clear();
base::STLDeleteValues(&protocol_handler_map_);
}
net::URLRequestJob* AtomURLRequestJobFactory::MaybeCreateJobWithProtocolHandler(

View File

@@ -9,9 +9,9 @@
#include <map>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include "base/containers/scoped_ptr_hash_map.h"
#include "net/url_request/url_request_job_factory.h"
namespace atom {
@@ -64,7 +64,7 @@ class AtomURLRequestJobFactory : public net::URLRequestJobFactory {
ProtocolHandlerMap protocol_handler_map_;
// Map that stores the original protocols of schemes.
using OriginalProtocolsMap = std::unordered_map<
using OriginalProtocolsMap = base::ScopedPtrHashMap<
std::string, std::unique_ptr<ProtocolHandler>>;
// Can only be accessed in IO thread.
OriginalProtocolsMap original_protocols_;

View File

@@ -59,11 +59,11 @@ void AskForOptions(v8::Isolate* isolate,
}
bool IsErrorOptions(base::Value* value, int* error) {
if (value->IsType(base::Value::Type::DICTIONARY)) {
if (value->IsType(base::Value::TYPE_DICTIONARY)) {
base::DictionaryValue* dict = static_cast<base::DictionaryValue*>(value);
if (dict->GetInteger("error", error))
return true;
} else if (value->IsType(base::Value::Type::INTEGER)) {
} else if (value->IsType(base::Value::TYPE_INTEGER)) {
if (value->GetAsInteger(error))
return true;
}

View File

@@ -13,7 +13,6 @@
#include "content/public/browser/browser_thread.h"
#include "net/base/net_errors.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_request_job.h"
#include "v8/include/v8.h"
@@ -83,9 +82,6 @@ class JsAsker : public RequestJob {
base::Bind(&JsAsker::OnResponse,
weak_factory_.GetWeakPtr())));
}
int GetResponseCode() const override { return net::HTTP_OK; }
void GetResponseInfo(net::HttpResponseInfo* info) override {
info->headers = new net::HttpResponseHeaders("");
}

View File

@@ -7,7 +7,6 @@
#include <string>
#include "atom/common/atom_constants.h"
#include "base/threading/sequenced_worker_pool.h"
namespace atom {
@@ -19,10 +18,10 @@ URLRequestAsyncAsarJob::URLRequestAsyncAsarJob(
void URLRequestAsyncAsarJob::StartAsync(std::unique_ptr<base::Value> options) {
base::FilePath::StringType file_path;
if (options->IsType(base::Value::Type::DICTIONARY)) {
if (options->IsType(base::Value::TYPE_DICTIONARY)) {
static_cast<base::DictionaryValue*>(options.get())->GetString(
"path", &file_path);
} else if (options->IsType(base::Value::Type::STRING)) {
} else if (options->IsType(base::Value::TYPE_STRING)) {
options->GetAsString(&file_path);
}

View File

@@ -34,13 +34,13 @@ URLRequestBufferJob::URLRequestBufferJob(
void URLRequestBufferJob::StartAsync(std::unique_ptr<base::Value> options) {
const base::BinaryValue* binary = nullptr;
if (options->IsType(base::Value::Type::DICTIONARY)) {
if (options->IsType(base::Value::TYPE_DICTIONARY)) {
base::DictionaryValue* dict =
static_cast<base::DictionaryValue*>(options.get());
dict->GetString("mimeType", &mime_type_);
dict->GetString("charset", &charset_);
dict->GetBinary("data", &binary);
} else if (options->IsType(base::Value::Type::BINARY)) {
} else if (options->IsType(base::Value::TYPE_BINARY)) {
options->GetAsBinary(&binary);
}
@@ -67,7 +67,7 @@ void URLRequestBufferJob::StartAsync(std::unique_ptr<base::Value> options) {
}
void URLRequestBufferJob::GetResponseInfo(net::HttpResponseInfo* info) {
std::string status("HTTP/1.1 200 OK");
std::string status("HTTP/1.1 ");
status.append(base::IntToString(status_code_));
status.append(" ");
status.append(net::GetHttpReasonPhrase(status_code_));

View File

@@ -112,7 +112,7 @@ void URLRequestFetchJob::BeforeStartInUI(
}
void URLRequestFetchJob::StartAsync(std::unique_ptr<base::Value> options) {
if (!options->IsType(base::Value::Type::DICTIONARY)) {
if (!options->IsType(base::Value::TYPE_DICTIONARY)) {
NotifyStartError(net::URLRequestStatus(
net::URLRequestStatus::FAILED, net::ERR_NOT_IMPLEMENTED));
return;

View File

@@ -8,9 +8,7 @@
#include <string>
#include "atom/browser/net/js_asker.h"
#include "brightray/browser/url_request_context_getter.h"
#include "content/browser/streams/stream.h"
#include "content/browser/streams/stream_read_observer.h"
#include "browser/url_request_context_getter.h"
#include "net/url_request/url_fetcher_delegate.h"
namespace atom {

View File

@@ -17,13 +17,13 @@ URLRequestStringJob::URLRequestStringJob(
}
void URLRequestStringJob::StartAsync(std::unique_ptr<base::Value> options) {
if (options->IsType(base::Value::Type::DICTIONARY)) {
if (options->IsType(base::Value::TYPE_DICTIONARY)) {
base::DictionaryValue* dict =
static_cast<base::DictionaryValue*>(options.get());
dict->GetString("mimeType", &mime_type_);
dict->GetString("charset", &charset_);
dict->GetString("data", &data_);
} else if (options->IsType(base::Value::Type::STRING)) {
} else if (options->IsType(base::Value::TYPE_STRING)) {
options->GetAsString(&data_);
}
net::URLRequestSimpleJob::Start();

View File

@@ -4,49 +4,202 @@
#include "atom/browser/node_debugger.h"
#include <string>
#include "base/bind.h"
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "libplatform/libplatform.h"
#include "native_mate/dictionary.h"
#include "content/public/browser/browser_thread.h"
#include "net/test/embedded_test_server/tcp_listen_socket.h"
#include "atom/common/node_includes.h"
namespace atom {
NodeDebugger::NodeDebugger(node::Environment* env) : env_(env) {
namespace {
// NodeDebugger is stored in Isolate's data, slots 0, 1, 3 have already been
// taken by gin, blink and node, using 2 is a safe option for now.
const int kIsolateSlot = 2;
const char* kContentLength = "Content-Length";
} // namespace
NodeDebugger::NodeDebugger(v8::Isolate* isolate)
: isolate_(isolate),
thread_("NodeDebugger"),
content_length_(-1),
weak_factory_(this) {
bool use_debug_agent = false;
int port = 5858;
std::string port_str;
base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
if (cmd->HasSwitch("debug")) {
use_debug_agent = true;
port_str = cmd->GetSwitchValueASCII("debug");
} else if (cmd->HasSwitch("debug-brk")) {
use_debug_agent = true;
port_str = cmd->GetSwitchValueASCII("debug-brk");
}
if (use_debug_agent) {
if (!port_str.empty())
base::StringToInt(port_str, &port);
isolate_->SetData(kIsolateSlot, this);
v8::Debug::SetMessageHandler(isolate_, DebugMessageHandler);
weak_up_ui_handle_.data = this;
uv_async_init(uv_default_loop(), &weak_up_ui_handle_, ProcessMessageInUI);
// Start a new IO thread.
base::Thread::Options options;
options.message_loop_type = base::MessageLoop::TYPE_IO;
if (!thread_.StartWithOptions(options)) {
LOG(ERROR) << "Unable to start debugger thread";
return;
}
// Start the server in new IO thread.
thread_.task_runner()->PostTask(
FROM_HERE,
base::Bind(&NodeDebugger::StartServer, weak_factory_.GetWeakPtr(),
port));
}
}
NodeDebugger::~NodeDebugger() {
thread_.Stop();
}
void NodeDebugger::Start() {
auto inspector = env_->inspector_agent();
if (inspector == nullptr)
return;
bool NodeDebugger::IsRunning() const {
return thread_.IsRunning();
}
node::DebugOptions options;
for (auto& arg : base::CommandLine::ForCurrentProcess()->argv()) {
#if defined(OS_WIN)
options.ParseOption(base::UTF16ToUTF8(arg));
#else
options.ParseOption(arg);
#endif
void NodeDebugger::StartServer(int port) {
server_ = net::test_server::TCPListenSocket::CreateAndListen(
"127.0.0.1", port, this);
if (!server_) {
LOG(ERROR) << "Cannot start debugger server";
return;
}
}
void NodeDebugger::CloseSession() {
accepted_socket_.reset();
}
void NodeDebugger::OnMessage(const std::string& message) {
if (message.find("\"type\":\"request\",\"command\":\"disconnect\"}") !=
std::string::npos)
CloseSession();
base::string16 message16 = base::UTF8ToUTF16(message);
v8::Debug::SendCommand(
isolate_,
reinterpret_cast<const uint16_t*>(message16.data()), message16.size());
uv_async_send(&weak_up_ui_handle_);
}
void NodeDebugger::SendMessage(const std::string& message) {
if (accepted_socket_) {
std::string header = base::StringPrintf(
"%s: %d\r\n\r\n", kContentLength, static_cast<int>(message.size()));
accepted_socket_->Send(header);
accepted_socket_->Send(message);
}
}
void NodeDebugger::SendConnectMessage() {
accepted_socket_->Send(base::StringPrintf(
"Type: connect\r\n"
"V8-Version: %s\r\n"
"Protocol-Version: 1\r\n"
"Embedding-Host: %s\r\n"
"%s: 0\r\n",
v8::V8::GetVersion(), ATOM_PRODUCT_NAME, kContentLength), true);
}
// static
void NodeDebugger::ProcessMessageInUI(uv_async_t* handle) {
NodeDebugger* self = static_cast<NodeDebugger*>(handle->data);
v8::Debug::ProcessDebugMessages(self->isolate_);
}
// static
void NodeDebugger::DebugMessageHandler(const v8::Debug::Message& message) {
NodeDebugger* self = static_cast<NodeDebugger*>(
message.GetIsolate()->GetData(kIsolateSlot));
if (self) {
std::string message8(*v8::String::Utf8Value(message.GetJSON()));
self->thread_.task_runner()->PostTask(
FROM_HERE,
base::Bind(&NodeDebugger::SendMessage, self->weak_factory_.GetWeakPtr(),
message8));
}
}
void NodeDebugger::DidAccept(
net::test_server::StreamListenSocket* server,
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);
return;
}
if (options.inspector_enabled()) {
// Use custom platform since the gin platform does not work correctly
// with node's inspector agent
platform_.reset(v8::platform::CreateDefaultPlatform());
accepted_socket_ = std::move(socket);
SendConnectMessage();
}
// Set process._debugWaitConnect if --inspect-brk was specified to stop
// the debugger on the first line
if (options.wait_for_connect()) {
mate::Dictionary process(env_->isolate(), env_->process_object());
process.Set("_debugWaitConnect", true);
void NodeDebugger::DidRead(net::test_server::StreamListenSocket* socket,
const char* data,
int len) {
buffer_.append(data, len);
do {
if (buffer_.empty())
return;
// Read the "Content-Length" header.
if (content_length_ < 0) {
size_t pos = buffer_.find("\r\n\r\n");
if (pos == std::string::npos)
return;
// We can be sure that the header is "Content-Length: xxx\r\n".
std::string content_length = buffer_.substr(16, pos - 16);
if (!base::StringToInt(content_length, &content_length_)) {
DidClose(accepted_socket_.get());
return;
}
// Strip header from buffer.
buffer_ = buffer_.substr(pos + 4);
}
inspector->Start(platform_.get(), nullptr, options);
}
// Read the message.
if (buffer_.size() >= static_cast<size_t>(content_length_)) {
std::string message = buffer_.substr(0, content_length_);
buffer_ = buffer_.substr(content_length_);
OnMessage(message);
// Get ready for next message.
content_length_ = -1;
}
} while (true);
}
void NodeDebugger::DidClose(net::test_server::StreamListenSocket* socket) {
// If we lost the connection, then simulate a disconnect msg:
OnMessage("{\"seq\":1,\"type\":\"request\",\"command\":\"disconnect\"}");
}
} // namespace atom

View File

@@ -6,30 +6,56 @@
#define ATOM_BROWSER_NODE_DEBUGGER_H_
#include <memory>
#include <string>
#include "base/macros.h"
namespace node {
class Environment;
}
namespace v8 {
class Platform;
}
#include "base/memory/weak_ptr.h"
#include "base/threading/thread.h"
#include "net/test/embedded_test_server/stream_listen_socket.h"
#include "v8/include/v8-debug.h"
#include "vendor/node/deps/uv/include/uv.h"
namespace atom {
// Add support for node's "--inspect" switch.
class NodeDebugger {
// Add support for node's "--debug" switch.
class NodeDebugger : public net::test_server::StreamListenSocket::Delegate {
public:
explicit NodeDebugger(node::Environment* env);
~NodeDebugger();
explicit NodeDebugger(v8::Isolate* isolate);
virtual ~NodeDebugger();
void Start();
bool IsRunning() const;
private:
node::Environment* env_;
std::unique_ptr<v8::Platform> platform_;
void StartServer(int port);
void CloseSession();
void OnMessage(const std::string& message);
void SendMessage(const std::string& message);
void SendConnectMessage();
static void ProcessMessageInUI(uv_async_t* handle);
static void DebugMessageHandler(const v8::Debug::Message& message);
// net::test_server::StreamListenSocket::Delegate:
void DidAccept(
net::test_server::StreamListenSocket* server,
std::unique_ptr<net::test_server::StreamListenSocket> socket) override;
void DidRead(net::test_server::StreamListenSocket* socket,
const char* data,
int len) override;
void DidClose(net::test_server::StreamListenSocket* socket) override;
v8::Isolate* isolate_;
uv_async_t weak_up_ui_handle_;
base::Thread thread_;
std::unique_ptr<net::test_server::StreamListenSocket> server_;
std::unique_ptr<net::test_server::StreamListenSocket> accepted_socket_;
std::string buffer_;
int content_length_;
base::WeakPtrFactory<NodeDebugger> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(NodeDebugger);
};

View File

@@ -4,9 +4,7 @@
#include "atom/browser/osr/osr_output_device.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkRect.h"
#include "third_party/skia/src/core/SkDevice.h"
#include "third_party/skia/include/core/SkDevice.h"
#include "ui/gfx/skia_util.h"
namespace atom {
@@ -38,11 +36,8 @@ void OffScreenOutputDevice::Resize(
return;
}
if (transparent_) {
bitmap_->eraseColor(SK_ColorTRANSPARENT);
} else {
bitmap_->eraseColor(SK_ColorWHITE);
}
if (transparent_)
bitmap_->eraseARGB(0, 0, 0, 0);
canvas_.reset(new SkCanvas(*bitmap_));
}
@@ -52,17 +47,6 @@ SkCanvas* OffScreenOutputDevice::BeginPaint(const gfx::Rect& damage_rect) {
DCHECK(bitmap_.get());
damage_rect_ = damage_rect;
SkIRect damage = SkIRect::MakeXYWH(
damage_rect_.x(),
damage_rect_.y(),
damage_rect_.width(),
damage_rect_.height());
if (transparent_) {
bitmap_->erase(SK_ColorTRANSPARENT, damage);
} else {
bitmap_->erase(SK_ColorWHITE, damage);
}
return canvas_.get();
}

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,6 @@
#ifndef ATOM_BROWSER_OSR_OSR_RENDER_WIDGET_HOST_VIEW_H_
#define ATOM_BROWSER_OSR_OSR_RENDER_WIDGET_HOST_VIEW_H_
#include <set>
#include <string>
#include <vector>
@@ -16,19 +15,15 @@
#include "atom/browser/native_window.h"
#include "atom/browser/native_window_observer.h"
#include "atom/browser/osr/osr_output_device.h"
#include "atom/browser/osr/osr_view_proxy.h"
#include "base/process/kill.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "cc/output/compositor_frame.h"
#include "cc/scheduler/begin_frame_source.h"
#include "content/browser/frame_host/render_widget_host_view_guest.h"
#include "content/browser/renderer_host/delegated_frame_host.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "content/browser/renderer_host/resize_lock.h"
#include "content/browser/web_contents/web_contents_view.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/WebKit/public/platform/WebVector.h"
#include "ui/base/ime/text_input_client.h"
#include "ui/compositor/compositor.h"
@@ -69,13 +64,11 @@ class OffScreenRenderWidgetHostView
#if !defined(OS_MACOSX)
public content::DelegatedFrameHostClient,
#endif
public NativeWindowObserver,
public OffscreenViewProxyObserver {
public NativeWindowObserver {
public:
OffScreenRenderWidgetHostView(bool transparent,
const OnPaintCallback& callback,
content::RenderWidgetHost* render_widget_host,
OffScreenRenderWidgetHostView* parent_host_view,
NativeWindow* native_window);
~OffScreenRenderWidgetHostView() override;
@@ -133,33 +126,28 @@ class OffScreenRenderWidgetHostView
#endif
void SelectionBoundsChanged(const ViewHostMsg_SelectionBounds_Params &)
override;
void CopyFromSurface(
const gfx::Rect& src_subrect,
const gfx::Size& dst_size,
const content::ReadbackRequestCallback& callback,
const SkColorType color_type) override;
void CopyFromSurfaceToVideoFrame(
const gfx::Rect& src_subrect,
scoped_refptr<media::VideoFrame> target,
const base::Callback<void(const gfx::Rect&, bool)>& callback) override;
void CopyFromCompositingSurface(const gfx::Rect &,
const gfx::Size &,
const content::ReadbackRequestCallback &,
const SkColorType) override;
void CopyFromCompositingSurfaceToVideoFrame(
const gfx::Rect &,
const scoped_refptr<media::VideoFrame> &,
const base::Callback<void(const gfx::Rect &, bool),
base::internal::CopyMode::Copyable> &) override;
bool CanCopyToVideoFrame(void) const override;
void BeginFrameSubscription(
std::unique_ptr<content::RenderWidgetHostViewFrameSubscriber>) override;
void EndFrameSubscription() override;
void InitAsGuest(
content::RenderWidgetHostView*,
content::RenderWidgetHostViewGuest*) override;
bool HasAcceleratedSurface(const gfx::Size &) override;
gfx::Rect GetBoundsInRootWindow(void) override;
void LockCompositingSurface(void) override;
void UnlockCompositingSurface(void) override;
void ImeCompositionRangeChanged(
const gfx::Range &, const std::vector<gfx::Rect>&) override;
gfx::Size GetPhysicalBackingSize() const override;
gfx::Size GetRequestedRendererSize() const override;
content::RenderWidgetHostViewBase* CreateViewForWidget(
content::RenderWidgetHost*,
content::RenderWidgetHost*,
content::WebContentsView*) override;
#if !defined(OS_MACOSX)
// content::DelegatedFrameHostClient:
int DelegatedFrameHostGetGpuMemoryBufferClientId(void) const;
@@ -178,15 +166,6 @@ class OffScreenRenderWidgetHostView
void SetBeginFrameSource(cc::BeginFrameSource* source) override;
#endif // !defined(OS_MACOSX)
bool TransformPointToLocalCoordSpace(
const gfx::Point& point,
const cc::SurfaceId& original_surface,
gfx::Point* transformed_point) override;
bool TransformPointToCoordSpaceForView(
const gfx::Point& point,
RenderWidgetHostViewBase* target_view,
gfx::Point* transformed_point) override;
// ui::CompositorDelegate:
std::unique_ptr<cc::SoftwareOutputDevice> CreateSoftwareOutputDevice(
ui::Compositor* compositor) override;
@@ -203,40 +182,11 @@ class OffScreenRenderWidgetHostView
base::TimeDelta vsync_period);
#if defined(OS_MACOSX)
void CreatePlatformWidget(bool is_guest_view_hack);
void CreatePlatformWidget();
void DestroyPlatformWidget();
#endif
void CancelWidget();
void AddGuestHostView(OffScreenRenderWidgetHostView* guest_host);
void RemoveGuestHostView(OffScreenRenderWidgetHostView* guest_host);
void AddViewProxy(OffscreenViewProxy* proxy);
void RemoveViewProxy(OffscreenViewProxy* proxy);
void ProxyViewDestroyed(OffscreenViewProxy* proxy);
void RegisterGuestViewFrameSwappedCallback(
content::RenderWidgetHostViewGuest* guest_host_view);
void OnGuestViewFrameSwapped(
content::RenderWidgetHostViewGuest* guest_host_view);
void OnPaint(const gfx::Rect& damage_rect, const SkBitmap& bitmap);
void OnPopupPaint(const gfx::Rect& damage_rect, const SkBitmap& bitmap);
void OnProxyViewPaint(const gfx::Rect& damage_rect);
bool IsPopupWidget() const {
return popup_type_ != blink::WebPopupTypeNone;
}
void HoldResize();
void ReleaseResize();
void WasResized();
void ProcessKeyboardEvent(
const content::NativeWebKeyboardEvent& event) override;
void ProcessMouseEvent(const blink::WebMouseEvent& event,
const ui::LatencyInfo& latency) override;
void ProcessMouseWheelEvent(const blink::WebMouseWheelEvent& event,
const ui::LatencyInfo& latency) override;
void SetPainting(bool painting);
bool IsPainting() const;
@@ -249,7 +199,6 @@ class OffScreenRenderWidgetHostView
content::DelegatedFrameHost* GetDelegatedFrameHost() const;
void Invalidate();
void InvalidateBounds(const gfx::Rect&);
content::RenderWidgetHostImpl* render_widget_host() const
{ return render_widget_host_; }
@@ -257,54 +206,29 @@ class OffScreenRenderWidgetHostView
gfx::Size size() const { return size_; }
float scale_factor() const { return scale_factor_; }
void set_popup_host_view(OffScreenRenderWidgetHostView* popup_view) {
popup_host_view_ = popup_view;
}
void set_child_host_view(OffScreenRenderWidgetHostView* child_view) {
child_host_view_ = child_view;
}
private:
void SetupFrameRate(bool force);
void ResizeRootLayer();
cc::FrameSinkId AllocateFrameSinkId(bool is_guest_view_hack);
// Weak ptrs.
content::RenderWidgetHostImpl* render_widget_host_;
OffScreenRenderWidgetHostView* parent_host_view_;
OffScreenRenderWidgetHostView* popup_host_view_;
std::unique_ptr<SkBitmap> popup_bitmap_;
OffScreenRenderWidgetHostView* child_host_view_;
std::set<OffScreenRenderWidgetHostView*> guest_host_views_;
std::set<OffscreenViewProxy*> proxy_views_;
NativeWindow* native_window_;
OffScreenOutputDevice* software_output_device_;
const bool transparent_;
OnPaintCallback callback_;
OnPaintCallback parent_callback_;
int frame_rate_;
int frame_rate_threshold_us_;
int frame_rate_threshold_ms_;
base::Time last_time_;
float scale_factor_;
bool is_showing_;
gfx::Vector2dF last_scroll_offset_;
gfx::Size size_;
bool painting_;
bool is_showing_;
bool is_destroyed_;
gfx::Rect popup_position_;
bool hold_resize_;
bool pending_resize_;
std::unique_ptr<ui::Layer> root_layer_;
std::unique_ptr<ui::Compositor> compositor_;
std::unique_ptr<content::DelegatedFrameHost> delegated_frame_host_;
@@ -312,10 +236,6 @@ class OffScreenRenderWidgetHostView
std::unique_ptr<AtomCopyFrameGenerator> copy_frame_generator_;
std::unique_ptr<AtomBeginFrameTimer> begin_frame_timer_;
// Provides |source_id| for BeginFrameArgs that we create.
cc::StubBeginFrameSource begin_frame_source_;
uint64_t begin_frame_number_ = cc::BeginFrameArgs::kStartingFrameNumber;
#if defined(OS_MACOSX)
CALayer* background_layer_;
std::unique_ptr<content::BrowserCompositorMac> browser_compositor_;

View File

@@ -121,12 +121,10 @@ void OffScreenRenderWidgetHostView::SelectionChanged(
RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
}
void OffScreenRenderWidgetHostView::CreatePlatformWidget(
bool is_guest_view_hack) {
void OffScreenRenderWidgetHostView::CreatePlatformWidget() {
mac_helper_ = new MacHelper(this);
browser_compositor_.reset(new content::BrowserCompositorMac(
mac_helper_, mac_helper_, render_widget_host_->is_hidden(), true,
AllocateFrameSinkId(is_guest_view_hack)));
mac_helper_, mac_helper_, render_widget_host_->is_hidden(), true));
}
void OffScreenRenderWidgetHostView::DestroyPlatformWidget() {

View File

@@ -1,58 +0,0 @@
// Copyright (c) 2017 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/browser/osr/osr_view_proxy.h"
namespace atom {
OffscreenViewProxy::OffscreenViewProxy(views::View* view)
: view_(view), observer_(nullptr) {
view_bitmap_.reset(new SkBitmap);
}
OffscreenViewProxy::~OffscreenViewProxy() {
if (observer_) {
observer_->ProxyViewDestroyed(this);
}
}
void OffscreenViewProxy::SetObserver(OffscreenViewProxyObserver* observer) {
if (observer_) {
observer_->ProxyViewDestroyed(this);
}
observer_ = observer;
}
void OffscreenViewProxy::RemoveObserver() {
observer_ = nullptr;
}
const SkBitmap* OffscreenViewProxy::GetBitmap() const {
return view_bitmap_.get();
}
void OffscreenViewProxy::SetBitmap(const SkBitmap& bitmap) {
if (view_bounds_.width() == bitmap.width() &&
view_bounds_.height() == bitmap.height() &&
observer_) {
view_bitmap_.reset(new SkBitmap(bitmap));
observer_->OnProxyViewPaint(view_bounds_);
}
}
const gfx::Rect& OffscreenViewProxy::GetBounds() {
return view_bounds_;
}
void OffscreenViewProxy::SetBounds(const gfx::Rect& bounds) {
view_bounds_ = bounds;
}
void OffscreenViewProxy::OnEvent(ui::Event* event) {
if (view_) {
view_->OnEvent(event);
}
}
} // namespace atom

View File

@@ -1,53 +0,0 @@
// Copyright (c) 2017 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_OSR_OSR_VIEW_PROXY_H_
#define ATOM_BROWSER_OSR_OSR_VIEW_PROXY_H_
#include <set>
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/events/event.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/views/view.h"
namespace atom {
class OffscreenViewProxy;
class OffscreenViewProxyObserver {
public:
virtual void OnProxyViewPaint(const gfx::Rect& damage_rect) = 0;
virtual void ProxyViewDestroyed(OffscreenViewProxy* proxy) = 0;
};
class OffscreenViewProxy {
public:
explicit OffscreenViewProxy(views::View* view);
~OffscreenViewProxy();
void SetObserver(OffscreenViewProxyObserver* observer);
void RemoveObserver();
const SkBitmap* GetBitmap() const;
void SetBitmap(const SkBitmap& bitmap);
const gfx::Rect& GetBounds();
void SetBounds(const gfx::Rect& bounds);
void OnEvent(ui::Event* event);
void ResetView() { view_ = nullptr; }
private:
views::View* view_;
gfx::Rect view_bounds_;
std::unique_ptr<SkBitmap> view_bitmap_;
OffscreenViewProxyObserver* observer_;
};
} // namespace atom
#endif // ATOM_BROWSER_OSR_OSR_VIEW_PROXY_H_

View File

@@ -4,11 +4,7 @@
#include "atom/browser/osr/osr_web_contents_view.h"
#include "atom/common/api/api_messages.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/render_view_host.h"
#include "third_party/WebKit/public/platform/WebScreenInfo.h"
#include "ui/display/screen.h"
namespace atom {
@@ -31,33 +27,19 @@ OffScreenWebContentsView::~OffScreenWebContentsView() {
void OffScreenWebContentsView::SetWebContents(
content::WebContents* web_contents) {
web_contents_ = web_contents;
RenderViewCreated(web_contents_->GetRenderViewHost());
}
#if !defined(OS_MACOSX)
gfx::NativeView OffScreenWebContentsView::GetNativeView() const {
if (!web_contents_) return gfx::NativeView();
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
if (!relay) return gfx::NativeView();
return relay->window->GetNativeView();
return gfx::NativeView();
}
gfx::NativeView OffScreenWebContentsView::GetContentNativeView() const {
if (!web_contents_) return gfx::NativeView();
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
if (!relay) return gfx::NativeView();
return relay->window->GetNativeView();
return gfx::NativeView();
}
gfx::NativeWindow OffScreenWebContentsView::GetTopLevelNativeWindow() const {
if (!web_contents_) return gfx::NativeWindow();
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
if (!relay) return gfx::NativeWindow();
return relay->window->GetNativeWindow();
return gfx::NativeWindow();
}
#endif
@@ -85,7 +67,7 @@ content::DropData* OffScreenWebContentsView::GetDropData() const {
}
gfx::Rect OffScreenWebContentsView::GetViewBounds() const {
return GetView() ? GetView()->GetViewBounds() : gfx::Rect();
return view_ ? view_->GetViewBounds() : gfx::Rect();
}
void OffScreenWebContentsView::CreateView(const gfx::Size& initial_size,
@@ -95,40 +77,19 @@ void OffScreenWebContentsView::CreateView(const gfx::Size& initial_size,
content::RenderWidgetHostViewBase*
OffScreenWebContentsView::CreateViewForWidget(
content::RenderWidgetHost* render_widget_host, bool is_guest_view_hack) {
if (render_widget_host->GetView()) {
return static_cast<content::RenderWidgetHostViewBase*>(
render_widget_host->GetView());
}
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
return new OffScreenRenderWidgetHostView(
transparent_,
callback_,
render_widget_host,
nullptr,
relay->window.get());
view_ = new OffScreenRenderWidgetHostView(
transparent_, callback_, render_widget_host, relay->window.get());
return view_;
}
content::RenderWidgetHostViewBase*
OffScreenWebContentsView::CreateViewForPopupWidget(
content::RenderWidgetHost* render_widget_host) {
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
content::WebContentsImpl *web_contents_impl =
static_cast<content::WebContentsImpl*>(web_contents_);
OffScreenRenderWidgetHostView *view =
static_cast<OffScreenRenderWidgetHostView*>(
web_contents_impl->GetOuterWebContents()
? web_contents_impl->GetOuterWebContents()->GetRenderWidgetHostView()
: web_contents_impl->GetRenderWidgetHostView());
return new OffScreenRenderWidgetHostView(
transparent_,
callback_,
render_widget_host,
view,
relay->window.get());
view_ = new OffScreenRenderWidgetHostView(
transparent_, callback_, render_widget_host, relay->window.get());
return view_;
}
void OffScreenWebContentsView::SetPageTitle(const base::string16& title) {
@@ -136,12 +97,8 @@ void OffScreenWebContentsView::SetPageTitle(const base::string16& title) {
void OffScreenWebContentsView::RenderViewCreated(
content::RenderViewHost* host) {
if (GetView())
GetView()->InstallTransparency();
#if defined(OS_MACOSX)
host->Send(new AtomViewMsg_Offscreen(host->GetRoutingID()));
#endif
if (view_)
view_->InstallTransparency();
}
void OffScreenWebContentsView::RenderViewSwappedIn(
@@ -153,22 +110,14 @@ void OffScreenWebContentsView::SetOverscrollControllerEnabled(bool enabled) {
void OffScreenWebContentsView::GetScreenInfo(
content::ScreenInfo* screen_info) const {
screen_info->rect = gfx::Rect(view_->size());
screen_info->available_rect = gfx::Rect(view_->size());
screen_info->depth = 24;
screen_info->depth_per_component = 8;
screen_info->device_scale_factor = view_->scale_factor();
screen_info->orientation_angle = 0;
screen_info->device_scale_factor = 1.0;
screen_info->orientation_type =
content::SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY;
if (GetView()) {
screen_info->rect = gfx::Rect(GetView()->size());
screen_info->available_rect = gfx::Rect(GetView()->size());
} else {
const display::Display display =
display::Screen::GetScreen()->GetPrimaryDisplay();
screen_info->rect = display.bounds();
screen_info->available_rect = display.work_area();
}
}
#if defined(OS_MACOSX)
@@ -202,12 +151,4 @@ void OffScreenWebContentsView::UpdateDragCursor(
blink::WebDragOperation operation) {
}
OffScreenRenderWidgetHostView* OffScreenWebContentsView::GetView() const {
if (web_contents_) {
return static_cast<OffScreenRenderWidgetHostView*>(
web_contents_->GetRenderViewHost()->GetWidget()->GetView());
}
return nullptr;
}
} // namespace atom

View File

@@ -75,12 +75,11 @@ class OffScreenWebContentsView : public content::WebContentsView,
void PlatformDestroy();
#endif
OffScreenRenderWidgetHostView* GetView() const;
const bool transparent_;
OnPaintCallback callback_;
// Weak refs.
OffScreenRenderWidgetHostView* view_;
content::WebContents* web_contents_;
#if defined(OS_MACOSX)

View File

@@ -140,11 +140,7 @@ bool RelaunchAppWithHelper(const base::FilePath& helper,
}
int RelauncherMain(const content::MainFunctionParams& main_parameters) {
#if defined(OS_WIN)
const StringVector& argv = atom::AtomCommandLine::wargv();
#else
const StringVector& argv = atom::AtomCommandLine::argv();
#endif
if (argv.size() < 4 || argv[1] != internal::kRelauncherTypeArg) {
LOG(ERROR) << "relauncher process invoked with unexpected arguments";

View File

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

View File

@@ -26,12 +26,7 @@ void SetPlatformAccelerator(ui::Accelerator* accelerator) {
&characterIgnoringModifiers);
if (character != characterIgnoringModifiers) {
if (isdigit(characterIgnoringModifiers)) {
// The character is a number so lets not mutate it with the modifiers
character = characterIgnoringModifiers;
} else {
modifiers ^= NSShiftKeyMask;
}
modifiers ^= NSShiftKeyMask;
}
if (character == NSDeleteFunctionKey) {

View File

@@ -1,266 +0,0 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <algorithm>
#include <utility>
#include <vector>
#include "atom/browser/osr/osr_render_widget_host_view.h"
#include "atom/browser/osr/osr_view_proxy.h"
#include "atom/browser/ui/autofill_popup.h"
#include "atom/common/api/api_messages.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/vector2d.h"
#include "ui/gfx/text_utils.h"
namespace atom {
namespace {
std::pair<int, int> CalculatePopupXAndWidth(
const display::Display& left_display,
const display::Display& right_display,
int popup_required_width,
const gfx::Rect& element_bounds,
bool is_rtl) {
int leftmost_display_x = left_display.bounds().x();
int rightmost_display_x =
right_display.GetSizeInPixel().width() + right_display.bounds().x();
// Calculate the start coordinates for the popup if it is growing right or
// the end position if it is growing to the left, capped to screen space.
int right_growth_start = std::max(
leftmost_display_x, std::min(rightmost_display_x, element_bounds.x()));
int left_growth_end =
std::max(leftmost_display_x,
std::min(rightmost_display_x, element_bounds.right()));
int right_available = rightmost_display_x - right_growth_start;
int left_available = left_growth_end - leftmost_display_x;
int popup_width =
std::min(popup_required_width, std::max(right_available, left_available));
std::pair<int, int> grow_right(right_growth_start, popup_width);
std::pair<int, int> grow_left(left_growth_end - popup_width, popup_width);
// Prefer to grow towards the end (right for LTR, left for RTL). But if there
// is not enough space available in the desired direction and more space in
// the other direction, reverse it.
if (is_rtl) {
return left_available >= popup_width || left_available >= right_available
? grow_left
: grow_right;
}
return right_available >= popup_width || right_available >= left_available
? grow_right
: grow_left;
}
std::pair<int, int> CalculatePopupYAndHeight(
const display::Display& top_display,
const display::Display& bottom_display,
int popup_required_height,
const gfx::Rect& element_bounds) {
int topmost_display_y = top_display.bounds().y();
int bottommost_display_y =
bottom_display.GetSizeInPixel().height() + bottom_display.bounds().y();
// Calculate the start coordinates for the popup if it is growing down or
// the end position if it is growing up, capped to screen space.
int top_growth_end = std::max(
topmost_display_y, std::min(bottommost_display_y, element_bounds.y()));
int bottom_growth_start =
std::max(topmost_display_y,
std::min(bottommost_display_y, element_bounds.bottom()));
int top_available = bottom_growth_start - topmost_display_y;
int bottom_available = bottommost_display_y - top_growth_end;
// TODO(csharp): Restrict the popup height to what is available.
if (bottom_available >= popup_required_height ||
bottom_available >= top_available) {
// The popup can appear below the field.
return std::make_pair(bottom_growth_start, popup_required_height);
} else {
// The popup must appear above the field.
return std::make_pair(top_growth_end - popup_required_height,
popup_required_height);
}
}
display::Display GetDisplayNearestPoint(
const gfx::Point& point,
gfx::NativeView container_view) {
return display::Screen::GetScreen()->GetDisplayNearestPoint(point);
}
} // namespace
AutofillPopup::AutofillPopup(gfx::NativeView container_view)
: container_view_(container_view), view_(nullptr) {
bold_font_list_ =
gfx::FontList().DeriveWithWeight(gfx::Font::Weight::BOLD);
smaller_font_list_ =
gfx::FontList().DeriveWithSizeDelta(kSmallerFontSizeDelta);
}
AutofillPopup::~AutofillPopup() {
Hide();
}
void AutofillPopup::CreateView(
content::RenderFrameHost* frame_host,
bool offscreen,
views::Widget* parent_widget,
const gfx::RectF& r) {
frame_host_ = frame_host;
gfx::Rect lb(std::floor(r.x()), std::floor(r.y() + r.height()),
std::floor(r.width()), std::floor(r.height()));
gfx::Point menu_position(lb.origin());
popup_bounds_in_view_ = lb;
views::View::ConvertPointToScreen(
parent_widget->GetContentsView(), &menu_position);
popup_bounds_ = gfx::Rect(menu_position, lb.size());
element_bounds_ = popup_bounds_;
Hide();
view_ = new AutofillPopupView(this, parent_widget);
view_->Show();
if (offscreen) {
auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
frame_host_->GetView());
view_->view_proxy_.reset(new OffscreenViewProxy(view_));
osr_rwhv->AddViewProxy(view_->view_proxy_.get());
}
}
void AutofillPopup::Hide() {
if (view_) {
view_->Hide();
view_ = nullptr;
}
}
void AutofillPopup::SetItems(const std::vector<base::string16>& values,
const std::vector<base::string16>& labels) {
values_ = values;
labels_ = labels;
UpdatePopupBounds();
if (view_) {
view_->OnSuggestionsChanged();
}
}
void AutofillPopup::AcceptSuggestion(int index) {
frame_host_->Send(new AtomAutofillFrameMsg_AcceptSuggestion(
frame_host_->GetRoutingID(), GetValueAt(index)));
}
void AutofillPopup::UpdatePopupBounds() {
int desired_width = GetDesiredPopupWidth();
int desired_height = GetDesiredPopupHeight();
bool is_rtl = false;
gfx::Point top_left_corner_of_popup =
element_bounds_.origin() +
gfx::Vector2d(element_bounds_.width() - desired_width, -desired_height);
// This is the bottom right point of the popup if the popup is below the
// element and grows to the right (since the is the lowest and furthest right
// the popup could go).
gfx::Point bottom_right_corner_of_popup =
element_bounds_.origin() +
gfx::Vector2d(desired_width, element_bounds_.height() + desired_height);
display::Display top_left_display =
GetDisplayNearestPoint(top_left_corner_of_popup, container_view_);
display::Display bottom_right_display =
GetDisplayNearestPoint(bottom_right_corner_of_popup, container_view_);
std::pair<int, int> popup_x_and_width =
CalculatePopupXAndWidth(top_left_display, bottom_right_display,
desired_width, element_bounds_, is_rtl);
std::pair<int, int> popup_y_and_height = CalculatePopupYAndHeight(
top_left_display, bottom_right_display, desired_height, element_bounds_);
popup_bounds_ = gfx::Rect(popup_x_and_width.first, popup_y_and_height.first,
popup_x_and_width.second, popup_y_and_height.second);
popup_bounds_in_view_ = gfx::Rect(popup_bounds_in_view_.origin(),
gfx::Size(popup_x_and_width.second, popup_y_and_height.second));
}
int AutofillPopup::GetDesiredPopupHeight() {
return 2 * kPopupBorderThickness + values_.size() * kRowHeight;
}
int AutofillPopup::GetDesiredPopupWidth() {
int popup_width = element_bounds_.width();
for (size_t i = 0; i < values_.size(); ++i) {
int row_size = kEndPadding + 2 * kPopupBorderThickness +
gfx::GetStringWidth(GetValueAt(i), GetValueFontListForRow(i)) +
gfx::GetStringWidth(GetLabelAt(i), GetLabelFontListForRow(i));
if (GetLabelAt(i).length() > 0)
row_size += kNamePadding + kEndPadding;
popup_width = std::max(popup_width, row_size);
}
return popup_width;
}
gfx::Rect AutofillPopup::GetRowBounds(int index) {
int top = kPopupBorderThickness + index * kRowHeight;
return gfx::Rect(kPopupBorderThickness, top,
popup_bounds_.width() - 2 * kPopupBorderThickness,
kRowHeight);
}
const gfx::FontList& AutofillPopup::GetValueFontListForRow(int index) const {
return bold_font_list_;
}
const gfx::FontList& AutofillPopup::GetLabelFontListForRow(int index) const {
return smaller_font_list_;
}
ui::NativeTheme::ColorId AutofillPopup::GetBackgroundColorIDForRow(
int index) const {
return (view_ && index == view_->GetSelectedLine())
? ui::NativeTheme::kColorId_ResultsTableHoveredBackground
: ui::NativeTheme::kColorId_ResultsTableNormalBackground;
}
int AutofillPopup::GetLineCount() {
return values_.size();
}
base::string16 AutofillPopup::GetValueAt(int i) {
return values_.at(i);
}
base::string16 AutofillPopup::GetLabelAt(int i) {
return labels_.at(i);
}
int AutofillPopup::LineFromY(int y) const {
int current_height = kPopupBorderThickness;
for (size_t i = 0; i < values_.size(); ++i) {
current_height += kRowHeight;
if (y <= current_height)
return i;
}
return values_.size() - 1;
}
} // namespace atom

View File

@@ -1,82 +0,0 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_UI_AUTOFILL_POPUP_H_
#define ATOM_BROWSER_UI_AUTOFILL_POPUP_H_
#include <vector>
#include "atom/browser/ui/views/autofill_popup_view.h"
#include "content/public/browser/render_frame_host.h"
#include "ui/gfx/font_list.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/widget/widget.h"
namespace atom {
class AutofillPopupView;
class AutofillPopup {
public:
explicit AutofillPopup(gfx::NativeView);
~AutofillPopup();
void CreateView(content::RenderFrameHost* render_frame,
bool offscreen, views::Widget* widget, const gfx::RectF& bounds);
void Hide();
void SetItems(const std::vector<base::string16>& values,
const std::vector<base::string16>& labels);
private:
friend class AutofillPopupView;
void AcceptSuggestion(int index);
void UpdatePopupBounds();
int GetDesiredPopupHeight();
int GetDesiredPopupWidth();
gfx::Rect GetRowBounds(int i);
const gfx::FontList& GetValueFontListForRow(int index) const;
const gfx::FontList& GetLabelFontListForRow(int index) const;
ui::NativeTheme::ColorId GetBackgroundColorIDForRow(int index) const;
int GetLineCount();
base::string16 GetValueAt(int i);
base::string16 GetLabelAt(int i);
int LineFromY(int y) const;
// The native view that contains this
gfx::NativeView container_view_;
int selected_index_;
// Popup location
gfx::Rect popup_bounds_;
gfx::Rect popup_bounds_in_view_;
// Bounds of the autofilled element
gfx::Rect element_bounds_;
// Datalist suggestions
std::vector<base::string16> values_;
std::vector<base::string16> labels_;
// Font lists for the suggestions
gfx::FontList smaller_font_list_;
gfx::FontList bold_font_list_;
// For sending the accepted suggestion to the render frame that
// asked to open the popup
content::RenderFrameHost* frame_host_;
// The popup view. The lifetime is managed by the owning Widget
AutofillPopupView* view_;
DISALLOW_COPY_AND_ASSIGN(AutofillPopup);
};
} // namespace atom
#endif // ATOM_BROWSER_UI_AUTOFILL_POPUP_H_

View File

@@ -69,7 +69,7 @@
auto cert_db = net::CertDatabase::GetInstance();
// This forces Chromium to reload the certificate since it might be trusted
// now.
cert_db->NotifyObserversCertDBChanged();
cert_db->NotifyObserversCertDBChanged(cert_.get());
callback_.Run();

View File

@@ -38,7 +38,7 @@ BOOL AddToTrustedRootStore(const PCCERT_CONTEXT cert_context,
if (result) {
// force Chromium to reload it's database for this certificate
auto cert_db = net::CertDatabase::GetInstance();
cert_db->NotifyObserversCertDBChanged();
cert_db->NotifyObserversCertDBChanged(cert.get());
}
CertCloseStore(root_cert_store, CERT_CLOSE_STORE_FORCE_FLAG);

View File

@@ -72,12 +72,8 @@ class FileChooserDialog {
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog_),
settings.default_path.value().c_str());
} else {
if (settings.default_path.IsAbsolute()) {
gtk_file_chooser_set_current_folder(
GTK_FILE_CHOOSER(dialog_),
settings.default_path.DirName().value().c_str());
}
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog_),
settings.default_path.DirName().value().c_str());
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog_),
settings.default_path.BaseName().value().c_str());
}

View File

@@ -40,7 +40,6 @@ void SetAllowedFileTypes(NSSavePanel* dialog, const Filters& filters) {
if ([file_type_set count])
file_types = [file_type_set allObjects];
[dialog setExtensionHidden:NO];
[dialog setAllowedFileTypes:file_types];
}
@@ -66,29 +65,22 @@ void SetupDialog(NSSavePanel* dialog,
if (base::DirectoryExists(settings.default_path)) {
default_dir = base::SysUTF8ToNSString(settings.default_path.value());
} else {
if (settings.default_path.IsAbsolute()) {
default_dir =
base::SysUTF8ToNSString(settings.default_path.DirName().value());
}
default_dir =
base::SysUTF8ToNSString(settings.default_path.DirName().value());
default_filename =
base::SysUTF8ToNSString(settings.default_path.BaseName().value());
}
}
if (settings.filters.empty()) {
[dialog setAllowsOtherFileTypes:YES];
} else {
// Set setAllowedFileTypes before setNameFieldStringValue as it might
// override the extension set using setNameFieldStringValue
SetAllowedFileTypes(dialog, settings.filters);
}
if (default_dir)
[dialog setDirectoryURL:[NSURL fileURLWithPath:default_dir]];
if (default_filename)
[dialog setNameFieldStringValue:default_filename];
if (settings.filters.empty())
[dialog setAllowsOtherFileTypes:YES];
else
SetAllowedFileTypes(dialog, settings.filters);
}
void SetupDialogForProperties(NSOpenPanel* dialog, int properties) {

View File

@@ -105,9 +105,7 @@ class FileDialog {
}
}
if (settings.default_path.IsAbsolute()) {
SetDefaultFolder(settings.default_path);
}
SetDefaultFolder(settings.default_path);
}
bool Show(atom::NativeWindow* parent_window) {

View File

@@ -41,7 +41,7 @@ class GtkMessageBox : public NativeWindowObserver {
const gfx::ImageSkia& icon)
: cancel_id_(cancel_id),
checkbox_checked_(false),
parent_(static_cast<NativeWindow*>(parent_window)) {
parent_(static_cast<NativeWindowViews*>(parent_window)) {
// Create dialog.
dialog_ = gtk_message_dialog_new(
nullptr, // parent
@@ -94,7 +94,7 @@ class GtkMessageBox : public NativeWindowObserver {
// Parent window.
if (parent_) {
parent_->AddObserver(this);
static_cast<NativeWindowViews*>(parent_)->SetEnabled(false);
parent_->SetEnabled(false);
libgtkui::SetGtkTransientForAura(dialog_, parent_->GetNativeWindow());
gtk_window_set_modal(GTK_WINDOW(dialog_), TRUE);
}
@@ -104,7 +104,7 @@ class GtkMessageBox : public NativeWindowObserver {
gtk_widget_destroy(dialog_);
if (parent_) {
parent_->RemoveObserver(this);
static_cast<NativeWindowViews*>(parent_)->SetEnabled(true);
parent_->SetEnabled(true);
}
}
@@ -179,7 +179,7 @@ class GtkMessageBox : public NativeWindowObserver {
bool checkbox_checked_;
NativeWindow* parent_;
NativeWindowViews* parent_;
GtkWidget* dialog_;
MessageBoxCallback callback_;

View File

@@ -79,16 +79,6 @@ void TrayIcon::NotifyDropText(const std::string& text) {
observer.OnDropText(text);
}
void TrayIcon::NotifyMouseEntered(const gfx::Point& location, int modifiers) {
for (TrayIconObserver& observer : observers_)
observer.OnMouseEntered(location, modifiers);
}
void TrayIcon::NotifyMouseExited(const gfx::Point& location, int modifiers) {
for (TrayIconObserver& observer : observers_)
observer.OnMouseExited(location, modifiers);
}
void TrayIcon::NotifyDragEntered() {
for (TrayIconObserver& observer : observers_)
observer.OnDragEntered();

View File

@@ -83,10 +83,6 @@ class TrayIcon {
void NotifyDragEntered();
void NotifyDragExited();
void NotifyDragEnded();
void NotifyMouseEntered(const gfx::Point& location = gfx::Point(),
int modifiers = 0);
void NotifyMouseExited(const gfx::Point& location = gfx::Point(),
int modifiers = 0);
protected:
TrayIcon();

View File

@@ -54,16 +54,9 @@ const CGFloat kVerticalTitleMargin = 2;
statusItemWithLength:NSVariableStatusItemLength];
statusItem_.reset([item retain]);
[statusItem_ setView:self];
// Finalize setup by sizing our views
[self updateDimensions];
// Add NSTrackingArea for listening to mouseEnter and mouseExit events
auto trackingArea = [[[NSTrackingArea alloc]
initWithRect:[self bounds]
options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways
owner:self
userInfo:nil] autorelease];
[self addTrackingArea:trackingArea];
}
return self;
}
@@ -295,18 +288,6 @@ const CGFloat kVerticalTitleMargin = 2;
return NSDragOperationCopy;
}
- (void)mouseExited:(NSEvent*)event {
trayIcon_->NotifyMouseExited(
gfx::ScreenPointFromNSPoint([event locationInWindow]),
ui::EventFlagsFromModifiers([event modifierFlags]));
}
- (void)mouseEntered:(NSEvent*)event {
trayIcon_->NotifyMouseEntered(
gfx::ScreenPointFromNSPoint([event locationInWindow]),
ui::EventFlagsFromModifiers([event modifierFlags]));
}
- (void)draggingExited:(id <NSDraggingInfo>)sender {
trayIcon_->NotifyDragExited();
}

View File

@@ -10,7 +10,6 @@
namespace gfx {
class Rect;
class Point;
}
namespace atom {
@@ -29,8 +28,6 @@ class TrayIconObserver {
virtual void OnDragEntered() {}
virtual void OnDragExited() {}
virtual void OnDragEnded() {}
virtual void OnMouseEntered(const gfx::Point& location, int modifiers) {}
virtual void OnMouseExited(const gfx::Point& location, int modifiers) {}
protected:
virtual ~TrayIconObserver() {}

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