mirror of
https://github.com/electron/electron.git
synced 2026-02-26 03:01:17 -05:00
Compare commits
88 Commits
roller/nod
...
v2.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de428ebec0 | ||
|
|
c6c49b9e4b | ||
|
|
98495fabfb | ||
|
|
06c33c7e56 | ||
|
|
33aad6ae11 | ||
|
|
6c00b37dd1 | ||
|
|
d209e59c30 | ||
|
|
14f8a2a0e8 | ||
|
|
65e1252da0 | ||
|
|
2903d7608c | ||
|
|
0bc72961ab | ||
|
|
b55a24c025 | ||
|
|
51bca764f7 | ||
|
|
35976a0a07 | ||
|
|
283ab23524 | ||
|
|
2343f7c287 | ||
|
|
8991ad31d8 | ||
|
|
fae6167308 | ||
|
|
bd25a5f453 | ||
|
|
c80021924e | ||
|
|
0cc4584352 | ||
|
|
706f0c436d | ||
|
|
663e1e059b | ||
|
|
433aba34e6 | ||
|
|
bd33e7198e | ||
|
|
e1b19140e5 | ||
|
|
4632ade7ae | ||
|
|
b32f332ce3 | ||
|
|
6ff0d744ee | ||
|
|
37cbf5e4f1 | ||
|
|
f48f486412 | ||
|
|
018b676efd | ||
|
|
c9e5d17950 | ||
|
|
b1dd013425 | ||
|
|
7a91c5668f | ||
|
|
2f47b71211 | ||
|
|
e8a7cc576e | ||
|
|
c00b1ac669 | ||
|
|
c4bde8853f | ||
|
|
ab77b55a90 | ||
|
|
05b0948dd0 | ||
|
|
c9e2140bca | ||
|
|
9843ce743e | ||
|
|
c846f677c9 | ||
|
|
643dd55e07 | ||
|
|
d2045b93b7 | ||
|
|
c22d53be5c | ||
|
|
e9d28f9b14 | ||
|
|
7e53a4c72c | ||
|
|
515fbb6fc3 | ||
|
|
af4dfcf6fe | ||
|
|
176abdbd80 | ||
|
|
cda7b8ccc8 | ||
|
|
1a43ba50b6 | ||
|
|
1174fc0ab8 | ||
|
|
3c5ba35d63 | ||
|
|
0f143fdba0 | ||
|
|
99ae56b782 | ||
|
|
5471bc313f | ||
|
|
b0077241ee | ||
|
|
bb40bc4aca | ||
|
|
76fb7ee87c | ||
|
|
bfc0e3f266 | ||
|
|
48e068997b | ||
|
|
f443974f3d | ||
|
|
36505ae00e | ||
|
|
b330ff8004 | ||
|
|
6cda9460ea | ||
|
|
2cac654974 | ||
|
|
5a210f3d7a | ||
|
|
4bb10c10e4 | ||
|
|
c0076d9c52 | ||
|
|
95539c5b63 | ||
|
|
4f8ca2f03a | ||
|
|
c9b92aebd3 | ||
|
|
6d3f60374e | ||
|
|
8703298e9d | ||
|
|
a42057aabd | ||
|
|
bd2ab27c25 | ||
|
|
1e6d7295cf | ||
|
|
1918da7c2e | ||
|
|
38345c7267 | ||
|
|
c4742df1ee | ||
|
|
5fc485043b | ||
|
|
967dcd3471 | ||
|
|
96f800552c | ||
|
|
afcbb589b6 | ||
|
|
4159103467 |
@@ -3,7 +3,7 @@ version: 2
|
|||||||
jobs:
|
jobs:
|
||||||
electron-linux-arm:
|
electron-linux-arm:
|
||||||
docker:
|
docker:
|
||||||
- image: electronbuilds/electron:0.0.4
|
- image: electronbuilds/electron:0.0.7
|
||||||
environment:
|
environment:
|
||||||
TARGET_ARCH: arm
|
TARGET_ARCH: arm
|
||||||
resource_class: 2xlarge
|
resource_class: 2xlarge
|
||||||
@@ -58,6 +58,29 @@ jobs:
|
|||||||
else
|
else
|
||||||
echo 'Skipping upload distribution because build is not for release'
|
echo 'Skipping upload distribution because build is not for release'
|
||||||
fi
|
fi
|
||||||
|
- run:
|
||||||
|
name: Optionally finish release
|
||||||
|
shell: /bin/sh
|
||||||
|
command: |
|
||||||
|
if [ "$ELECTRON_RELEASE" == "1" ] && [ "$AUTO_RELEASE" == "true" ]; then
|
||||||
|
echo 'Trying to finish release'
|
||||||
|
node script/release.js --validateRelease --automaticRelease
|
||||||
|
releaseExitCode=$?
|
||||||
|
if [ $releaseExitCode -eq 0 ]; then
|
||||||
|
echo 'Release is ready to go; releasing'
|
||||||
|
node script/release.js--automaticRelease
|
||||||
|
if [ $releaseExitCode -eq 0 ]; then
|
||||||
|
echo 'Release successful, now publishing to npm'
|
||||||
|
echo "//registry.npmjs.org/:_authToken=$ELECTRON_NPM_TOKEN" >> ~/.npmrc
|
||||||
|
npm run publish-to-npm
|
||||||
|
echo 'Release has been published to npm'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo 'Release is not complete, skipping publish for now'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo 'Skipping finishing release because build is not for release'
|
||||||
|
fi
|
||||||
- run:
|
- run:
|
||||||
name: Zip out directory
|
name: Zip out directory
|
||||||
command: |
|
command: |
|
||||||
@@ -83,7 +106,7 @@ jobs:
|
|||||||
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
||||||
docker run -it \
|
docker run -it \
|
||||||
--mount type=bind,source=/tmp/workspace,target=/tmp/workspace \
|
--mount type=bind,source=/tmp/workspace,target=/tmp/workspace \
|
||||||
--rm electronbuilds/electronarm7:0.0.4 > version.txt
|
--rm electronbuilds/electronarm7:0.0.5 > version.txt
|
||||||
cat version.txt
|
cat version.txt
|
||||||
if grep -q `script/get-version.py` version.txt; then
|
if grep -q `script/get-version.py` version.txt; then
|
||||||
echo "Versions match"
|
echo "Versions match"
|
||||||
@@ -96,7 +119,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
electron-linux-arm64:
|
electron-linux-arm64:
|
||||||
docker:
|
docker:
|
||||||
- image: electronbuilds/electron:0.0.4
|
- image: electronbuilds/electron:0.0.7
|
||||||
environment:
|
environment:
|
||||||
TARGET_ARCH: arm64
|
TARGET_ARCH: arm64
|
||||||
resource_class: 2xlarge
|
resource_class: 2xlarge
|
||||||
@@ -151,6 +174,29 @@ jobs:
|
|||||||
else
|
else
|
||||||
echo 'Skipping upload distribution because build is not for release'
|
echo 'Skipping upload distribution because build is not for release'
|
||||||
fi
|
fi
|
||||||
|
- run:
|
||||||
|
name: Optionally finish release
|
||||||
|
shell: /bin/sh
|
||||||
|
command: |
|
||||||
|
if [ "$ELECTRON_RELEASE" == "1" ] && [ "$AUTO_RELEASE" == "true" ]; then
|
||||||
|
echo 'Trying to finish release'
|
||||||
|
node script/release.js --validateRelease --automaticRelease
|
||||||
|
releaseExitCode=$?
|
||||||
|
if [ $releaseExitCode -eq 0 ]; then
|
||||||
|
echo 'Release is ready to go; releasing'
|
||||||
|
node script/release.js--automaticRelease
|
||||||
|
if [ $releaseExitCode -eq 0 ]; then
|
||||||
|
echo 'Release successful, now publishing to npm'
|
||||||
|
echo "//registry.npmjs.org/:_authToken=$ELECTRON_NPM_TOKEN" >> ~/.npmrc
|
||||||
|
npm run publish-to-npm
|
||||||
|
echo 'Release has been published to npm'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo 'Release is not complete, skipping publish for now'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo 'Skipping finishing release because build is not for release'
|
||||||
|
fi
|
||||||
- run:
|
- run:
|
||||||
name: Zip out directory
|
name: Zip out directory
|
||||||
command: |
|
command: |
|
||||||
@@ -176,7 +222,7 @@ jobs:
|
|||||||
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
||||||
docker run -it \
|
docker run -it \
|
||||||
--mount type=bind,source=/tmp/workspace,target=/tmp/workspace \
|
--mount type=bind,source=/tmp/workspace,target=/tmp/workspace \
|
||||||
--rm electronbuilds/electronarm64:0.0.5 > version.txt
|
--rm electronbuilds/electronarm64:0.0.6 > version.txt
|
||||||
cat version.txt
|
cat version.txt
|
||||||
if grep -q `script/get-version.py` version.txt; then
|
if grep -q `script/get-version.py` version.txt; then
|
||||||
echo "Versions match"
|
echo "Versions match"
|
||||||
@@ -189,7 +235,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
electron-linux-ia32:
|
electron-linux-ia32:
|
||||||
docker:
|
docker:
|
||||||
- image: electronbuilds/electron:0.0.4
|
- image: electronbuilds/electron:0.0.7
|
||||||
environment:
|
environment:
|
||||||
TARGET_ARCH: ia32
|
TARGET_ARCH: ia32
|
||||||
DISPLAY: ':99.0'
|
DISPLAY: ':99.0'
|
||||||
@@ -248,6 +294,29 @@ jobs:
|
|||||||
else
|
else
|
||||||
echo 'Skipping upload distribution because build is not for release'
|
echo 'Skipping upload distribution because build is not for release'
|
||||||
fi
|
fi
|
||||||
|
- run:
|
||||||
|
name: Optionally finish release
|
||||||
|
shell: /bin/sh
|
||||||
|
command: |
|
||||||
|
if [ "$ELECTRON_RELEASE" == "1" ] && [ "$AUTO_RELEASE" == "true" ]; then
|
||||||
|
echo 'Trying to finish release'
|
||||||
|
node script/release.js --validateRelease --automaticRelease
|
||||||
|
releaseExitCode=$?
|
||||||
|
if [ $releaseExitCode -eq 0 ]; then
|
||||||
|
echo 'Release is ready to go; releasing'
|
||||||
|
node script/release.js--automaticRelease
|
||||||
|
if [ $releaseExitCode -eq 0 ]; then
|
||||||
|
echo 'Release successful, now publishing to npm'
|
||||||
|
echo "//registry.npmjs.org/:_authToken=$ELECTRON_NPM_TOKEN" >> ~/.npmrc
|
||||||
|
npm run publish-to-npm
|
||||||
|
echo 'Release has been published to npm'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo 'Release is not complete, skipping publish for now'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo 'Skipping finishing release because build is not for release'
|
||||||
|
fi
|
||||||
- run:
|
- run:
|
||||||
name: Test
|
name: Test
|
||||||
environment:
|
environment:
|
||||||
@@ -273,7 +342,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
electron-linux-mips64el:
|
electron-linux-mips64el:
|
||||||
docker:
|
docker:
|
||||||
- image: electronbuilds/electron:0.0.4
|
- image: electronbuilds/electron:0.0.7
|
||||||
environment:
|
environment:
|
||||||
TARGET_ARCH: mips64el
|
TARGET_ARCH: mips64el
|
||||||
resource_class: xlarge
|
resource_class: xlarge
|
||||||
@@ -328,10 +397,33 @@ jobs:
|
|||||||
else
|
else
|
||||||
echo 'Skipping upload distribution because build is not for release'
|
echo 'Skipping upload distribution because build is not for release'
|
||||||
fi
|
fi
|
||||||
|
- run:
|
||||||
|
name: Optionally finish release
|
||||||
|
shell: /bin/sh
|
||||||
|
command: |
|
||||||
|
if [ "$ELECTRON_RELEASE" == "1" ] && [ "$AUTO_RELEASE" == "true" ]; then
|
||||||
|
echo 'Trying to finish release'
|
||||||
|
node script/release.js --validateRelease --automaticRelease
|
||||||
|
releaseExitCode=$?
|
||||||
|
if [ $releaseExitCode -eq 0 ]; then
|
||||||
|
echo 'Release is ready to go; releasing'
|
||||||
|
node script/release.js--automaticRelease
|
||||||
|
if [ $releaseExitCode -eq 0 ]; then
|
||||||
|
echo 'Release successful, now publishing to npm'
|
||||||
|
echo "//registry.npmjs.org/:_authToken=$ELECTRON_NPM_TOKEN" >> ~/.npmrc
|
||||||
|
npm run publish-to-npm
|
||||||
|
echo 'Release has been published to npm'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo 'Release is not complete, skipping publish for now'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo 'Skipping finishing release because build is not for release'
|
||||||
|
fi
|
||||||
|
|
||||||
electron-linux-x64:
|
electron-linux-x64:
|
||||||
docker:
|
docker:
|
||||||
- image: electronbuilds/electron:0.0.4
|
- image: electronbuilds/electron:0.0.7
|
||||||
environment:
|
environment:
|
||||||
TARGET_ARCH: x64
|
TARGET_ARCH: x64
|
||||||
DISPLAY: ':99.0'
|
DISPLAY: ':99.0'
|
||||||
@@ -390,6 +482,29 @@ jobs:
|
|||||||
else
|
else
|
||||||
echo 'Skipping upload distribution because build is not for release'
|
echo 'Skipping upload distribution because build is not for release'
|
||||||
fi
|
fi
|
||||||
|
- run:
|
||||||
|
name: Optionally finish release
|
||||||
|
shell: /bin/sh
|
||||||
|
command: |
|
||||||
|
if [ "$ELECTRON_RELEASE" == "1" ] && [ "$AUTO_RELEASE" == "true" ]; then
|
||||||
|
echo 'Trying to finish release'
|
||||||
|
node script/release.js --validateRelease --automaticRelease
|
||||||
|
releaseExitCode=$?
|
||||||
|
if [ $releaseExitCode -eq 0 ]; then
|
||||||
|
echo 'Release is ready to go; releasing'
|
||||||
|
node script/release.js--automaticRelease
|
||||||
|
if [ $releaseExitCode -eq 0 ]; then
|
||||||
|
echo 'Release successful, now publishing to npm'
|
||||||
|
echo "//registry.npmjs.org/:_authToken=$ELECTRON_NPM_TOKEN" >> ~/.npmrc
|
||||||
|
npm run publish-to-npm
|
||||||
|
echo 'Release has been published to npm'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo 'Release is not complete, skipping publish for now'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo 'Skipping finishing release because build is not for release'
|
||||||
|
fi
|
||||||
- run:
|
- run:
|
||||||
name: Test
|
name: Test
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -43,6 +43,8 @@
|
|||||||
/vendor/llvm/
|
/vendor/llvm/
|
||||||
/vendor/npm/
|
/vendor/npm/
|
||||||
/vendor/python_26/
|
/vendor/python_26/
|
||||||
|
/vendor/native_mksnapshot
|
||||||
|
/vendor/LICENSES.chromium.html
|
||||||
node_modules/
|
node_modules/
|
||||||
SHASUMS256.txt
|
SHASUMS256.txt
|
||||||
**/package-lock.json
|
**/package-lock.json
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ This Code of Conduct applies both within project spaces and in public spaces whe
|
|||||||
|
|
||||||
## Enforcement
|
## Enforcement
|
||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [electron@github.com](mailto:electron@github.com). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [coc@electronjs.org](mailto:coc@electronjs.org). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||||
|
|
||||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
This project adheres to the Contributor Covenant [code of conduct](CODE_OF_CONDUCT.md).
|
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
|
By participating, you are expected to uphold this code. Please report unacceptable
|
||||||
behavior to electron@github.com.
|
behavior to coc@electronjs.org.
|
||||||
|
|
||||||
The following is a set of guidelines for contributing to Electron.
|
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
|
These are just guidelines, not rules, use your best judgment and feel free to
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ ENV HOME=/home
|
|||||||
RUN chmod a+rwx /home
|
RUN chmod a+rwx /home
|
||||||
|
|
||||||
# Install node.js
|
# Install node.js
|
||||||
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
|
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
|
||||||
RUN apt-get update && apt-get install -y nodejs
|
RUN apt-get update && apt-get install -y nodejs
|
||||||
|
|
||||||
# Install wget used by crash reporter
|
# Install wget used by crash reporter
|
||||||
@@ -16,6 +16,9 @@ RUN apt-get install -y wget
|
|||||||
# Install python-dbusmock
|
# Install python-dbusmock
|
||||||
RUN apt-get install -y python-dbusmock
|
RUN apt-get install -y python-dbusmock
|
||||||
|
|
||||||
|
# Install libnotify
|
||||||
|
RUN apt-get install -y libnotify-bin
|
||||||
|
|
||||||
# Add xvfb init script
|
# Add xvfb init script
|
||||||
ADD tools/xvfb-init.sh /etc/init.d/xvfb
|
ADD tools/xvfb-init.sh /etc/init.d/xvfb
|
||||||
RUN chmod a+x /etc/init.d/xvfb
|
RUN chmod a+x /etc/init.d/xvfb
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ RUN apt-get update && apt-get install -y\
|
|||||||
libgnome-keyring-dev \
|
libgnome-keyring-dev \
|
||||||
libgtk-3-0 \
|
libgtk-3-0 \
|
||||||
libgtk-3-dev \
|
libgtk-3-dev \
|
||||||
|
libnotify-bin \
|
||||||
libnotify-dev \
|
libnotify-dev \
|
||||||
libnss3 \
|
libnss3 \
|
||||||
libnss3-dev \
|
libnss3-dev \
|
||||||
|
|||||||
63
Dockerfile.arm64v8
Normal file
63
Dockerfile.arm64v8
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
FROM arm64v8/ubuntu:16.04
|
||||||
|
|
||||||
|
RUN groupadd --gid 1000 builduser \
|
||||||
|
&& useradd --uid 1000 --gid builduser --shell /bin/bash --create-home builduser
|
||||||
|
|
||||||
|
RUN groupadd --gid 114 jenkins \
|
||||||
|
&& useradd --uid 110 --gid jenkins --shell /bin/bash --create-home jenkins
|
||||||
|
|
||||||
|
# Set up TEMP directory
|
||||||
|
ENV TEMP=/tmp
|
||||||
|
RUN chmod a+rwx /tmp
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y\
|
||||||
|
bison \
|
||||||
|
build-essential \
|
||||||
|
clang \
|
||||||
|
curl \
|
||||||
|
gperf \
|
||||||
|
git \
|
||||||
|
libasound2 \
|
||||||
|
libasound2-dev \
|
||||||
|
libcap-dev \
|
||||||
|
libcups2-dev \
|
||||||
|
libdbus-1-dev \
|
||||||
|
libgconf-2-4 \
|
||||||
|
libgconf2-dev \
|
||||||
|
libgnome-keyring-dev \
|
||||||
|
libgtk2.0-0 \
|
||||||
|
libgtk2.0-dev \
|
||||||
|
libgtk-3-0 \
|
||||||
|
libgtk-3-dev \
|
||||||
|
libnotify-dev \
|
||||||
|
libnss3 \
|
||||||
|
libnss3-dev \
|
||||||
|
libx11-xcb-dev \
|
||||||
|
libxss1 \
|
||||||
|
libxtst-dev \
|
||||||
|
libxtst6 \
|
||||||
|
lsb-release \
|
||||||
|
locales \
|
||||||
|
ninja \
|
||||||
|
python-setuptools \
|
||||||
|
python-pip \
|
||||||
|
python-dbusmock \
|
||||||
|
wget \
|
||||||
|
xvfb
|
||||||
|
|
||||||
|
# Install node.js
|
||||||
|
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
|
||||||
|
RUN apt-get update && apt-get install -y nodejs
|
||||||
|
|
||||||
|
# Install crcmod
|
||||||
|
RUN pip install -U crcmod
|
||||||
|
|
||||||
|
ADD tools/xvfb-init.sh /etc/init.d/xvfb
|
||||||
|
RUN chmod a+x /etc/init.d/xvfb
|
||||||
|
|
||||||
|
# Install ninja in /usr/local
|
||||||
|
RUN cd /usr/local && git clone https://github.com/martine/ninja.git -b v1.5.3
|
||||||
|
RUN cd /usr/local/ninja && ./configure.py --bootstrap
|
||||||
|
|
||||||
|
USER builduser
|
||||||
|
WORKDIR /home/builduser
|
||||||
@@ -16,6 +16,7 @@ RUN apt-get update && apt-get install -y\
|
|||||||
libgnome-keyring-dev \
|
libgnome-keyring-dev \
|
||||||
libgtk-3-0 \
|
libgtk-3-0 \
|
||||||
libgtk-3-dev \
|
libgtk-3-dev \
|
||||||
|
libnotify-bin \
|
||||||
libnotify-dev \
|
libnotify-dev \
|
||||||
libnss3 \
|
libnss3 \
|
||||||
libnss3-dev \
|
libnss3-dev \
|
||||||
@@ -28,13 +29,8 @@ RUN apt-get update && apt-get install -y\
|
|||||||
wget \
|
wget \
|
||||||
xvfb
|
xvfb
|
||||||
|
|
||||||
# Install node.js
|
|
||||||
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
|
|
||||||
RUN apt-get update && apt-get install -y nodejs
|
|
||||||
|
|
||||||
ADD tools/xvfb-init.sh /etc/init.d/xvfb
|
ADD tools/xvfb-init.sh /etc/init.d/xvfb
|
||||||
RUN chmod a+x /etc/init.d/xvfb
|
RUN chmod a+x /etc/init.d/xvfb
|
||||||
ADD tools/run-electron.sh /run-electron.sh
|
ADD tools/run-electron.sh /run-electron.sh
|
||||||
RUN chmod a+x /run-electron.sh
|
RUN chmod a+x /run-electron.sh
|
||||||
|
|
||||||
CMD sh /run-electron.sh
|
CMD sh /run-electron.sh
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ FROM electronbuilds/libchromiumcontent:0.0.4
|
|||||||
USER root
|
USER root
|
||||||
|
|
||||||
# Install node.js
|
# Install node.js
|
||||||
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
|
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
|
||||||
RUN apt-get update && apt-get install -y nodejs
|
RUN apt-get update && apt-get install -y nodejs
|
||||||
|
|
||||||
# Install wget used by crash reporter
|
# Install wget used by crash reporter
|
||||||
@@ -12,6 +12,9 @@ RUN apt-get install -y wget
|
|||||||
# Install python-dbusmock
|
# Install python-dbusmock
|
||||||
RUN apt-get install -y python-dbusmock
|
RUN apt-get install -y python-dbusmock
|
||||||
|
|
||||||
|
# Install libnotify
|
||||||
|
RUN apt-get install -y libnotify-bin
|
||||||
|
|
||||||
# Add xvfb init script
|
# Add xvfb init script
|
||||||
ADD tools/xvfb-init.sh /etc/init.d/xvfb
|
ADD tools/xvfb-init.sh /etc/init.d/xvfb
|
||||||
RUN chmod a+x /etc/init.d/xvfb
|
RUN chmod a+x /etc/init.d/xvfb
|
||||||
|
|||||||
36
Jenkinsfile.arm64
Normal file
36
Jenkinsfile.arm64
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
pipeline {
|
||||||
|
agent {
|
||||||
|
docker {
|
||||||
|
image 'electronbuilds/arm64v8:0.0.2'
|
||||||
|
args '--privileged'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
environment {
|
||||||
|
TARGET_ARCH='arm64'
|
||||||
|
DISPLAY=':99.0'
|
||||||
|
MOCHA_TIMEOUT='60000'
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage('Bootstrap') {
|
||||||
|
steps {
|
||||||
|
sh 'script/bootstrap.py -v --dev --target_arch=$TARGET_ARCH'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Build') {
|
||||||
|
steps {
|
||||||
|
sh 'script/build.py -c D --ninja-path /usr/local/ninja/ninja'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Test') {
|
||||||
|
steps {
|
||||||
|
sh '/etc/init.d/xvfb start'
|
||||||
|
sh 'script/test.py --ci'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
cleanWs()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,7 +21,7 @@ announcements.
|
|||||||
This project adheres to the Contributor Covenant
|
This project adheres to the Contributor Covenant
|
||||||
[code of conduct](https://github.com/electron/electron/tree/master/CODE_OF_CONDUCT.md).
|
[code of conduct](https://github.com/electron/electron/tree/master/CODE_OF_CONDUCT.md).
|
||||||
By participating, you are expected to uphold this code. Please report unacceptable
|
By participating, you are expected to uphold this code. Please report unacceptable
|
||||||
behavior to [electron@github.com](mailto:electron@github.com).
|
behavior to [coc@electronjs.org](mailto:coc@electronjs.org).
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
The Electron team and community take security bugs in Electron seriously. We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions.
|
The Electron team and community take security bugs in Electron seriously. We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions.
|
||||||
|
|
||||||
To report a security issue, email [electron@github.com](mailto:electron@github.com) and include the word "SECURITY" in the subject line.
|
To report a security issue, email [security@electronjs.org](mailto:security@electronjs.org) and include the word "SECURITY" in the subject line.
|
||||||
|
|
||||||
The Electron team will send a response indicating the next steps in handling your report. After the initial reply to your report, the security team will keep you informed of the progress towards a fix and full announcement, and may ask for additional information or guidance.
|
The Electron team will send a response indicating the next steps in handling your report. After the initial reply to your report, the security team will keep you informed of the progress towards a fix and full announcement, and may ask for additional information or guidance.
|
||||||
|
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ void BrowserView::Init(v8::Isolate* isolate,
|
|||||||
web_contents_.Reset(isolate, web_contents.ToV8());
|
web_contents_.Reset(isolate, web_contents.ToV8());
|
||||||
api_web_contents_ = web_contents.get();
|
api_web_contents_ = web_contents.get();
|
||||||
|
|
||||||
view_.reset(NativeBrowserView::Create(
|
view_.reset(
|
||||||
api_web_contents_->managed_web_contents()->GetView()));
|
NativeBrowserView::Create(api_web_contents_->managed_web_contents()));
|
||||||
|
|
||||||
InitWith(isolate, wrapper);
|
InitWith(isolate, wrapper);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,20 +23,16 @@ MenuViews::MenuViews(v8::Isolate* isolate, v8::Local<v8::Object> wrapper)
|
|||||||
|
|
||||||
void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item,
|
void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item,
|
||||||
const base::Closure& callback) {
|
const base::Closure& callback) {
|
||||||
NativeWindow* native_window = static_cast<NativeWindow*>(window->window());
|
auto* native_window = static_cast<NativeWindowViews*>(window->window());
|
||||||
if (!native_window)
|
if (!native_window)
|
||||||
return;
|
return;
|
||||||
auto* web_contents = native_window->inspectable_web_contents();
|
|
||||||
if (!web_contents)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// (-1, -1) means showing on mouse location.
|
// (-1, -1) means showing on mouse location.
|
||||||
gfx::Point location;
|
gfx::Point location;
|
||||||
if (x == -1 || y == -1) {
|
if (x == -1 || y == -1) {
|
||||||
location = display::Screen::GetScreen()->GetCursorScreenPoint();
|
location = display::Screen::GetScreen()->GetCursorScreenPoint();
|
||||||
} else {
|
} else {
|
||||||
auto* view = web_contents->GetView()->GetWebView();
|
gfx::Point origin = native_window->GetContentBounds().origin();
|
||||||
gfx::Point origin = view->bounds().origin();
|
|
||||||
location = gfx::Point(origin.x() + x, origin.y() + y);
|
location = gfx::Point(origin.x() + x, origin.y() + y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +48,7 @@ void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item,
|
|||||||
menu_runners_[window_id] = std::unique_ptr<MenuRunner>(new MenuRunner(
|
menu_runners_[window_id] = std::unique_ptr<MenuRunner>(new MenuRunner(
|
||||||
model(), flags, close_callback));
|
model(), flags, close_callback));
|
||||||
menu_runners_[window_id]->RunMenuAt(
|
menu_runners_[window_id]->RunMenuAt(
|
||||||
static_cast<NativeWindowViews*>(window->window())->widget(),
|
native_window->widget(),
|
||||||
NULL,
|
NULL,
|
||||||
gfx::Rect(location, gfx::Size()),
|
gfx::Rect(location, gfx::Size()),
|
||||||
views::MENU_ANCHOR_TOPLEFT,
|
views::MENU_ANCHOR_TOPLEFT,
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ namespace atom {
|
|||||||
|
|
||||||
namespace api {
|
namespace api {
|
||||||
|
|
||||||
|
//TODO(codebytere): deprecated; remove in 3.0
|
||||||
int Screen::getMenuBarHeight() {
|
int Screen::getMenuBarHeight() {
|
||||||
return [[NSApp mainMenu] menuBarHeight];
|
return [[NSApp mainMenu] menuBarHeight];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -441,14 +441,15 @@ void DownloadIdCallback(content::DownloadManager* download_manager,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SetDevToolsNetworkEmulationClientIdInIO(
|
void SetDevToolsNetworkEmulationClientIdInIO(
|
||||||
brightray::URLRequestContextGetter* context_getter,
|
brightray::URLRequestContextGetter* url_request_context_getter,
|
||||||
const std::string& client_id) {
|
const std::string& client_id) {
|
||||||
if (!context_getter)
|
if (!url_request_context_getter)
|
||||||
return;
|
return;
|
||||||
auto network_delegate =
|
net::URLRequestContext* context =
|
||||||
static_cast<AtomNetworkDelegate*>(context_getter->network_delegate());
|
url_request_context_getter->GetURLRequestContext();
|
||||||
if (network_delegate)
|
AtomNetworkDelegate* network_delegate =
|
||||||
network_delegate->SetDevToolsNetworkEmulationClientId(client_id);
|
static_cast<AtomNetworkDelegate*>(context->network_delegate());
|
||||||
|
network_delegate->SetDevToolsNetworkEmulationClientId(client_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -277,6 +277,27 @@ void OnCapturePageDone(const base::Callback<void(const gfx::Image&)>& callback,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
struct WebContents::FrameDispatchHelper {
|
||||||
|
WebContents* api_web_contents;
|
||||||
|
content::RenderFrameHost* rfh;
|
||||||
|
|
||||||
|
bool Send(IPC::Message* msg) { return rfh->Send(msg); }
|
||||||
|
|
||||||
|
void OnSetTemporaryZoomLevel(double level, IPC::Message* reply_msg) {
|
||||||
|
api_web_contents->OnSetTemporaryZoomLevel(rfh, level, reply_msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnGetZoomLevel(IPC::Message* reply_msg) {
|
||||||
|
api_web_contents->OnGetZoomLevel(rfh, reply_msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnRendererMessageSync(const base::string16& channel,
|
||||||
|
const base::ListValue& args,
|
||||||
|
IPC::Message* message) {
|
||||||
|
api_web_contents->OnRendererMessageSync(rfh, channel, args, message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
WebContents::WebContents(v8::Isolate* isolate,
|
WebContents::WebContents(v8::Isolate* isolate,
|
||||||
content::WebContents* web_contents,
|
content::WebContents* web_contents,
|
||||||
Type type)
|
Type type)
|
||||||
@@ -307,10 +328,6 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
|
|||||||
request_id_(0),
|
request_id_(0),
|
||||||
background_throttling_(true),
|
background_throttling_(true),
|
||||||
enable_devtools_(true) {
|
enable_devtools_(true) {
|
||||||
// WebContents may need to emit events when it is garbage collected, so it
|
|
||||||
// has to be deleted in the first gc callback.
|
|
||||||
MarkHighMemoryUsage();
|
|
||||||
|
|
||||||
// Read options.
|
// Read options.
|
||||||
options.Get("backgroundThrottling", &background_throttling_);
|
options.Get("backgroundThrottling", &background_throttling_);
|
||||||
|
|
||||||
@@ -923,13 +940,6 @@ void WebContents::ShowAutofillPopup(content::RenderFrameHost* frame_host,
|
|||||||
bool WebContents::OnMessageReceived(const IPC::Message& message) {
|
bool WebContents::OnMessageReceived(const IPC::Message& message) {
|
||||||
bool handled = true;
|
bool handled = true;
|
||||||
IPC_BEGIN_MESSAGE_MAP(WebContents, message)
|
IPC_BEGIN_MESSAGE_MAP(WebContents, message)
|
||||||
IPC_MESSAGE_HANDLER(AtomViewHostMsg_Message, OnRendererMessage)
|
|
||||||
IPC_MESSAGE_HANDLER_DELAY_REPLY(AtomViewHostMsg_Message_Sync,
|
|
||||||
OnRendererMessageSync)
|
|
||||||
IPC_MESSAGE_HANDLER_DELAY_REPLY(AtomViewHostMsg_SetTemporaryZoomLevel,
|
|
||||||
OnSetTemporaryZoomLevel)
|
|
||||||
IPC_MESSAGE_HANDLER_DELAY_REPLY(AtomViewHostMsg_GetZoomLevel,
|
|
||||||
OnGetZoomLevel)
|
|
||||||
IPC_MESSAGE_HANDLER_CODE(ViewHostMsg_SetCursor, OnCursorChange,
|
IPC_MESSAGE_HANDLER_CODE(ViewHostMsg_SetCursor, OnCursorChange,
|
||||||
handled = false)
|
handled = false)
|
||||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||||
@@ -939,17 +949,28 @@ bool WebContents::OnMessageReceived(const IPC::Message& message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool WebContents::OnMessageReceived(const IPC::Message& message,
|
bool WebContents::OnMessageReceived(const IPC::Message& message,
|
||||||
content::RenderFrameHost* frame_host) {
|
content::RenderFrameHost* frame_host) {
|
||||||
bool handled = true;
|
bool handled = true;
|
||||||
|
FrameDispatchHelper helper = {this, frame_host};
|
||||||
auto relay = NativeWindowRelay::FromWebContents(web_contents());
|
auto relay = NativeWindowRelay::FromWebContents(web_contents());
|
||||||
if (!relay)
|
if (relay) {
|
||||||
return false;
|
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(NativeWindow, message, frame_host)
|
||||||
|
IPC_MESSAGE_FORWARD(AtomAutofillFrameHostMsg_HidePopup,
|
||||||
|
relay->window.get(), NativeWindow::HideAutofillPopup)
|
||||||
|
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||||
|
IPC_END_MESSAGE_MAP()
|
||||||
|
}
|
||||||
|
|
||||||
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(WebContents, message, frame_host)
|
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(WebContents, message, frame_host)
|
||||||
|
IPC_MESSAGE_HANDLER(AtomFrameHostMsg_Message, OnRendererMessage)
|
||||||
|
IPC_MESSAGE_FORWARD_DELAY_REPLY(AtomFrameHostMsg_Message_Sync, &helper,
|
||||||
|
FrameDispatchHelper::OnRendererMessageSync)
|
||||||
|
IPC_MESSAGE_FORWARD_DELAY_REPLY(
|
||||||
|
AtomFrameHostMsg_SetTemporaryZoomLevel, &helper,
|
||||||
|
FrameDispatchHelper::OnSetTemporaryZoomLevel)
|
||||||
|
IPC_MESSAGE_FORWARD_DELAY_REPLY(AtomFrameHostMsg_GetZoomLevel, &helper,
|
||||||
|
FrameDispatchHelper::OnGetZoomLevel)
|
||||||
IPC_MESSAGE_HANDLER(AtomAutofillFrameHostMsg_ShowPopup, ShowAutofillPopup)
|
IPC_MESSAGE_HANDLER(AtomAutofillFrameHostMsg_ShowPopup, ShowAutofillPopup)
|
||||||
IPC_END_MESSAGE_MAP()
|
|
||||||
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(NativeWindow, message, frame_host)
|
|
||||||
IPC_MESSAGE_FORWARD(AtomAutofillFrameHostMsg_HidePopup,
|
|
||||||
relay->window.get(), NativeWindow::HideAutofillPopup)
|
|
||||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||||
IPC_END_MESSAGE_MAP()
|
IPC_END_MESSAGE_MAP()
|
||||||
|
|
||||||
@@ -989,13 +1010,17 @@ void WebContents::NavigationEntryCommitted(
|
|||||||
details.is_same_document, details.did_replace_entry);
|
details.is_same_document, details.did_replace_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t WebContents::GetID() const {
|
int64_t WebContents::GetIDForContents(content::WebContents* web_contents) {
|
||||||
int64_t process_id = web_contents()->GetRenderProcessHost()->GetID();
|
int64_t process_id = web_contents->GetRenderProcessHost()->GetID();
|
||||||
int64_t routing_id = web_contents()->GetRenderViewHost()->GetRoutingID();
|
int64_t routing_id = web_contents->GetMainFrame()->GetRoutingID();
|
||||||
int64_t rv = (process_id << 32) + routing_id;
|
int64_t rv = (process_id << 32) + routing_id;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t WebContents::GetID() const {
|
||||||
|
return WebContents::GetIDForContents(web_contents());
|
||||||
|
}
|
||||||
|
|
||||||
int WebContents::GetProcessID() const {
|
int WebContents::GetProcessID() const {
|
||||||
return web_contents()->GetRenderProcessHost()->GetID();
|
return web_contents()->GetRenderProcessHost()->GetID();
|
||||||
}
|
}
|
||||||
@@ -1468,7 +1493,12 @@ void WebContents::TabTraverse(bool reverse) {
|
|||||||
bool WebContents::SendIPCMessage(bool all_frames,
|
bool WebContents::SendIPCMessage(bool all_frames,
|
||||||
const base::string16& channel,
|
const base::string16& channel,
|
||||||
const base::ListValue& args) {
|
const base::ListValue& args) {
|
||||||
return Send(new AtomViewMsg_Message(routing_id(), all_frames, channel, args));
|
auto frame_host = web_contents()->GetMainFrame();
|
||||||
|
if (frame_host) {
|
||||||
|
return frame_host->Send(new AtomFrameMsg_Message(
|
||||||
|
frame_host->GetRoutingID(), all_frames, channel, args));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::SendInputEvent(v8::Isolate* isolate,
|
void WebContents::SendInputEvent(v8::Isolate* isolate,
|
||||||
@@ -1752,25 +1782,38 @@ double WebContents::GetZoomFactor() {
|
|||||||
return content::ZoomLevelToZoomFactor(level);
|
return content::ZoomLevelToZoomFactor(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::OnSetTemporaryZoomLevel(double level,
|
void WebContents::OnSetTemporaryZoomLevel(content::RenderFrameHost* rfh,
|
||||||
|
double level,
|
||||||
IPC::Message* reply_msg) {
|
IPC::Message* reply_msg) {
|
||||||
zoom_controller_->SetTemporaryZoomLevel(level);
|
zoom_controller_->SetTemporaryZoomLevel(level);
|
||||||
double new_level = zoom_controller_->GetZoomLevel();
|
double new_level = zoom_controller_->GetZoomLevel();
|
||||||
AtomViewHostMsg_SetTemporaryZoomLevel::WriteReplyParams(reply_msg, new_level);
|
AtomFrameHostMsg_SetTemporaryZoomLevel::WriteReplyParams(reply_msg,
|
||||||
Send(reply_msg);
|
new_level);
|
||||||
|
rfh->Send(reply_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::OnGetZoomLevel(IPC::Message* reply_msg) {
|
void WebContents::OnGetZoomLevel(content::RenderFrameHost* rfh,
|
||||||
AtomViewHostMsg_GetZoomLevel::WriteReplyParams(reply_msg, GetZoomLevel());
|
IPC::Message* reply_msg) {
|
||||||
Send(reply_msg);
|
AtomFrameHostMsg_GetZoomLevel::WriteReplyParams(reply_msg, GetZoomLevel());
|
||||||
|
rfh->Send(reply_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::Local<v8::Value> WebContents::GetWebPreferences(v8::Isolate* isolate) {
|
v8::Local<v8::Value> WebContents::GetWebPreferences(v8::Isolate* isolate) {
|
||||||
WebContentsPreferences* web_preferences =
|
WebContentsPreferences* web_preferences =
|
||||||
WebContentsPreferences::FromWebContents(web_contents());
|
WebContentsPreferences::FromWebContents(web_contents());
|
||||||
|
if (!web_preferences)
|
||||||
|
return v8::Null(isolate);
|
||||||
return mate::ConvertToV8(isolate, *web_preferences->web_preferences());
|
return mate::ConvertToV8(isolate, *web_preferences->web_preferences());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
v8::Local<v8::Value> WebContents::GetLastWebPreferences(v8::Isolate* isolate) {
|
||||||
|
WebContentsPreferences* web_preferences =
|
||||||
|
WebContentsPreferences::FromWebContents(web_contents());
|
||||||
|
if (!web_preferences)
|
||||||
|
return v8::Null(isolate);
|
||||||
|
return mate::ConvertToV8(isolate, *web_preferences->last_web_preferences());
|
||||||
|
}
|
||||||
|
|
||||||
v8::Local<v8::Value> WebContents::GetOwnerBrowserWindow() {
|
v8::Local<v8::Value> WebContents::GetOwnerBrowserWindow() {
|
||||||
if (owner_window())
|
if (owner_window())
|
||||||
return Window::From(isolate(), owner_window());
|
return Window::From(isolate(), owner_window());
|
||||||
@@ -1922,6 +1965,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
|||||||
.SetMethod("_getZoomFactor", &WebContents::GetZoomFactor)
|
.SetMethod("_getZoomFactor", &WebContents::GetZoomFactor)
|
||||||
.SetMethod("getType", &WebContents::GetType)
|
.SetMethod("getType", &WebContents::GetType)
|
||||||
.SetMethod("getWebPreferences", &WebContents::GetWebPreferences)
|
.SetMethod("getWebPreferences", &WebContents::GetWebPreferences)
|
||||||
|
.SetMethod("getLastWebPreferences", &WebContents::GetLastWebPreferences)
|
||||||
.SetMethod("getOwnerBrowserWindow", &WebContents::GetOwnerBrowserWindow)
|
.SetMethod("getOwnerBrowserWindow", &WebContents::GetOwnerBrowserWindow)
|
||||||
.SetMethod("hasServiceWorker", &WebContents::HasServiceWorker)
|
.SetMethod("hasServiceWorker", &WebContents::HasServiceWorker)
|
||||||
.SetMethod("unregisterServiceWorker",
|
.SetMethod("unregisterServiceWorker",
|
||||||
@@ -1955,17 +1999,19 @@ AtomBrowserContext* WebContents::GetBrowserContext() const {
|
|||||||
return static_cast<AtomBrowserContext*>(web_contents()->GetBrowserContext());
|
return static_cast<AtomBrowserContext*>(web_contents()->GetBrowserContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::OnRendererMessage(const base::string16& channel,
|
void WebContents::OnRendererMessage(content::RenderFrameHost* frame_host,
|
||||||
|
const base::string16& channel,
|
||||||
const base::ListValue& args) {
|
const base::ListValue& args) {
|
||||||
// webContents.emit(channel, new Event(), args...);
|
// webContents.emit(channel, new Event(), args...);
|
||||||
Emit(base::UTF16ToUTF8(channel), args);
|
Emit(base::UTF16ToUTF8(channel), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::OnRendererMessageSync(const base::string16& channel,
|
void WebContents::OnRendererMessageSync(content::RenderFrameHost* frame_host,
|
||||||
|
const base::string16& channel,
|
||||||
const base::ListValue& args,
|
const base::ListValue& args,
|
||||||
IPC::Message* message) {
|
IPC::Message* message) {
|
||||||
// webContents.emit(channel, new Event(sender, message), args...);
|
// webContents.emit(channel, new Event(sender, message), args...);
|
||||||
EmitWithSender(base::UTF16ToUTF8(channel), web_contents(), message, args);
|
EmitWithSender(base::UTF16ToUTF8(channel), frame_host, message, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|||||||
@@ -79,6 +79,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||||||
static void BuildPrototype(v8::Isolate* isolate,
|
static void BuildPrototype(v8::Isolate* isolate,
|
||||||
v8::Local<v8::FunctionTemplate> prototype);
|
v8::Local<v8::FunctionTemplate> prototype);
|
||||||
|
|
||||||
|
static int64_t GetIDForContents(content::WebContents* web_contents);
|
||||||
|
|
||||||
// Notifies to destroy any guest web contents before destroying self.
|
// Notifies to destroy any guest web contents before destroying self.
|
||||||
void DestroyWebContents(bool async);
|
void DestroyWebContents(bool async);
|
||||||
|
|
||||||
@@ -214,6 +216,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||||||
|
|
||||||
// Returns the web preferences of current WebContents.
|
// Returns the web preferences of current WebContents.
|
||||||
v8::Local<v8::Value> GetWebPreferences(v8::Isolate* isolate);
|
v8::Local<v8::Value> GetWebPreferences(v8::Isolate* isolate);
|
||||||
|
v8::Local<v8::Value> GetLastWebPreferences(v8::Isolate* isolate);
|
||||||
|
|
||||||
// Returns the owner window.
|
// Returns the owner window.
|
||||||
v8::Local<v8::Value> GetOwnerBrowserWindow();
|
v8::Local<v8::Value> GetOwnerBrowserWindow();
|
||||||
@@ -367,6 +370,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||||||
const std::vector<base::string16>& labels);
|
const std::vector<base::string16>& labels);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
struct FrameDispatchHelper;
|
||||||
AtomBrowserContext* GetBrowserContext() const;
|
AtomBrowserContext* GetBrowserContext() const;
|
||||||
|
|
||||||
uint32_t GetNextRequestId() {
|
uint32_t GetNextRequestId() {
|
||||||
@@ -377,21 +381,26 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||||||
void OnCursorChange(const content::WebCursor& cursor);
|
void OnCursorChange(const content::WebCursor& cursor);
|
||||||
|
|
||||||
// Called when received a message from renderer.
|
// Called when received a message from renderer.
|
||||||
void OnRendererMessage(const base::string16& channel,
|
void OnRendererMessage(content::RenderFrameHost* frame_host,
|
||||||
|
const base::string16& channel,
|
||||||
const base::ListValue& args);
|
const base::ListValue& args);
|
||||||
|
|
||||||
// Called when received a synchronous message from renderer.
|
// Called when received a synchronous message from renderer.
|
||||||
void OnRendererMessageSync(const base::string16& channel,
|
void OnRendererMessageSync(content::RenderFrameHost* frame_host,
|
||||||
|
const base::string16& channel,
|
||||||
const base::ListValue& args,
|
const base::ListValue& args,
|
||||||
IPC::Message* message);
|
IPC::Message* message);
|
||||||
|
|
||||||
// Called when received a synchronous message from renderer to
|
// Called when received a synchronous message from renderer to
|
||||||
// set temporary zoom level.
|
// set temporary zoom level.
|
||||||
void OnSetTemporaryZoomLevel(double level, IPC::Message* reply_msg);
|
void OnSetTemporaryZoomLevel(content::RenderFrameHost* frame_host,
|
||||||
|
double level,
|
||||||
|
IPC::Message* reply_msg);
|
||||||
|
|
||||||
// Called when received a synchronous message from renderer to
|
// Called when received a synchronous message from renderer to
|
||||||
// get the zoom level.
|
// get the zoom level.
|
||||||
void OnGetZoomLevel(IPC::Message* reply_msg);
|
void OnGetZoomLevel(content::RenderFrameHost* frame_host,
|
||||||
|
IPC::Message* reply_msg);
|
||||||
|
|
||||||
void InitZoomController(content::WebContents* web_contents,
|
void InitZoomController(content::WebContents* web_contents,
|
||||||
const mate::Dictionary& options);
|
const mate::Dictionary& options);
|
||||||
|
|||||||
@@ -37,6 +37,26 @@ namespace atom {
|
|||||||
|
|
||||||
namespace api {
|
namespace api {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
template<typename Method, typename Event, typename Listener>
|
||||||
|
void CallNetworkDelegateMethod(
|
||||||
|
brightray::URLRequestContextGetter* url_request_context_getter,
|
||||||
|
Method method,
|
||||||
|
Event type,
|
||||||
|
URLPatterns patterns,
|
||||||
|
Listener listener) {
|
||||||
|
// Force creating network delegate.
|
||||||
|
net::URLRequestContext* context =
|
||||||
|
url_request_context_getter->GetURLRequestContext();
|
||||||
|
// Then call the method.
|
||||||
|
AtomNetworkDelegate* network_delegate =
|
||||||
|
static_cast<AtomNetworkDelegate*>(context->network_delegate());
|
||||||
|
(network_delegate->*method)(type, std::move(patterns), std::move(listener));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
WebRequest::WebRequest(v8::Isolate* isolate,
|
WebRequest::WebRequest(v8::Isolate* isolate,
|
||||||
AtomBrowserContext* browser_context)
|
AtomBrowserContext* browser_context)
|
||||||
: browser_context_(browser_context) {
|
: browser_context_(browser_context) {
|
||||||
@@ -74,16 +94,15 @@ void WebRequest::SetListener(Method method, Event type, mate::Arguments* args) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto url_request_context_getter =
|
brightray::URLRequestContextGetter* url_request_context_getter =
|
||||||
browser_context_->url_request_context_getter();
|
browser_context_->url_request_context_getter();
|
||||||
if (!url_request_context_getter)
|
if (!url_request_context_getter)
|
||||||
return;
|
return;
|
||||||
BrowserThread::PostTask(
|
BrowserThread::PostTask(
|
||||||
BrowserThread::IO, FROM_HERE,
|
BrowserThread::IO, FROM_HERE,
|
||||||
base::Bind(method,
|
base::Bind(&CallNetworkDelegateMethod<Method, Event, Listener>,
|
||||||
base::Unretained(static_cast<AtomNetworkDelegate*>(
|
base::RetainedRef(url_request_context_getter),
|
||||||
url_request_context_getter->network_delegate())),
|
method, type, std::move(patterns), std::move(listener)));
|
||||||
type, patterns, listener));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|||||||
@@ -893,6 +893,8 @@ void Window::SetBrowserView(v8::Local<v8::Value> value) {
|
|||||||
window_->SetBrowserView(browser_view->view());
|
window_->SetBrowserView(browser_view->view());
|
||||||
browser_view->web_contents()->SetOwnerWindow(window_.get());
|
browser_view->web_contents()->SetOwnerWindow(window_.get());
|
||||||
browser_view_.Reset(isolate(), value);
|
browser_view_.Reset(isolate(), value);
|
||||||
|
|
||||||
|
window_->UpdateDraggableRegionViews();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -952,8 +954,11 @@ void Window::ToggleTabBar() {
|
|||||||
window_->ToggleTabBar();
|
window_->ToggleTabBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::AddTabbedWindow(NativeWindow* window) {
|
void Window::AddTabbedWindow(NativeWindow* window,
|
||||||
window_->AddTabbedWindow(window);
|
mate::Arguments* args) {
|
||||||
|
const bool windowAdded = window_->AddTabbedWindow(window);
|
||||||
|
if (!windowAdded)
|
||||||
|
args->ThrowError("AddTabbedWindow cannot be called by a window on itself.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::SetVibrancy(mate::Arguments* args) {
|
void Window::SetVibrancy(mate::Arguments* args) {
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ class Window : public mate::TrackableObject<Window>,
|
|||||||
void MergeAllWindows();
|
void MergeAllWindows();
|
||||||
void MoveTabToNewWindow();
|
void MoveTabToNewWindow();
|
||||||
void ToggleTabBar();
|
void ToggleTabBar();
|
||||||
void AddTabbedWindow(NativeWindow* window);
|
void AddTabbedWindow(NativeWindow* window, mate::Arguments* args);
|
||||||
|
|
||||||
void SetVibrancy(mate::Arguments* args);
|
void SetVibrancy(mate::Arguments* args);
|
||||||
void SetTouchBar(const std::vector<mate::PersistentDictionary>& items);
|
void SetTouchBar(const std::vector<mate::PersistentDictionary>& items);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "atom/common/api/api_messages.h"
|
#include "atom/common/api/api_messages.h"
|
||||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||||
|
#include "content/public/browser/render_frame_host.h"
|
||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
#include "native_mate/object_template_builder.h"
|
#include "native_mate/object_template_builder.h"
|
||||||
|
|
||||||
@@ -20,17 +21,32 @@ Event::Event(v8::Isolate* isolate)
|
|||||||
Event::~Event() {
|
Event::~Event() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Event::SetSenderAndMessage(content::WebContents* sender,
|
void Event::SetSenderAndMessage(content::RenderFrameHost* sender,
|
||||||
IPC::Message* message) {
|
IPC::Message* message) {
|
||||||
DCHECK(!sender_);
|
DCHECK(!sender_);
|
||||||
DCHECK(!message_);
|
DCHECK(!message_);
|
||||||
sender_ = sender;
|
sender_ = sender;
|
||||||
message_ = message;
|
message_ = message;
|
||||||
|
|
||||||
Observe(sender);
|
Observe(content::WebContents::FromRenderFrameHost(sender));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Event::WebContentsDestroyed() {
|
void Event::RenderFrameDeleted(content::RenderFrameHost* rfh) {
|
||||||
|
if (sender_ != rfh)
|
||||||
|
return;
|
||||||
|
sender_ = nullptr;
|
||||||
|
message_ = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Event::RenderFrameHostChanged(content::RenderFrameHost* old_rfh,
|
||||||
|
content::RenderFrameHost* new_rfh) {
|
||||||
|
if (sender_ && sender_ == old_rfh)
|
||||||
|
sender_ = new_rfh;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Event::FrameDeleted(content::RenderFrameHost* rfh) {
|
||||||
|
if (sender_ != rfh)
|
||||||
|
return;
|
||||||
sender_ = nullptr;
|
sender_ = nullptr;
|
||||||
message_ = nullptr;
|
message_ = nullptr;
|
||||||
}
|
}
|
||||||
@@ -44,7 +60,7 @@ bool Event::SendReply(const base::string16& json) {
|
|||||||
if (message_ == nullptr || sender_ == nullptr)
|
if (message_ == nullptr || sender_ == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
AtomViewHostMsg_Message_Sync::WriteReplyParams(message_, json);
|
AtomFrameHostMsg_Message_Sync::WriteReplyParams(message_, json);
|
||||||
bool success = sender_->Send(message_);
|
bool success = sender_->Send(message_);
|
||||||
message_ = nullptr;
|
message_ = nullptr;
|
||||||
sender_ = nullptr;
|
sender_ = nullptr;
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ class Event : public Wrappable<Event>,
|
|||||||
v8::Local<v8::FunctionTemplate> prototype);
|
v8::Local<v8::FunctionTemplate> prototype);
|
||||||
|
|
||||||
// Pass the sender and message to be replied.
|
// Pass the sender and message to be replied.
|
||||||
void SetSenderAndMessage(content::WebContents* sender, IPC::Message* message);
|
void SetSenderAndMessage(content::RenderFrameHost* sender,
|
||||||
|
IPC::Message* message);
|
||||||
|
|
||||||
// event.PreventDefault().
|
// event.PreventDefault().
|
||||||
void PreventDefault(v8::Isolate* isolate);
|
void PreventDefault(v8::Isolate* isolate);
|
||||||
@@ -37,11 +38,14 @@ class Event : public Wrappable<Event>,
|
|||||||
~Event() override;
|
~Event() override;
|
||||||
|
|
||||||
// content::WebContentsObserver implementations:
|
// content::WebContentsObserver implementations:
|
||||||
void WebContentsDestroyed() override;
|
void RenderFrameDeleted(content::RenderFrameHost* rfh) override;
|
||||||
|
void RenderFrameHostChanged(content::RenderFrameHost* old_rfh,
|
||||||
|
content::RenderFrameHost* new_rfh) override;
|
||||||
|
void FrameDeleted(content::RenderFrameHost* rfh) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Replyer for the synchronous messages.
|
// Replyer for the synchronous messages.
|
||||||
content::WebContents* sender_;
|
content::RenderFrameHost* sender_;
|
||||||
IPC::Message* message_;
|
IPC::Message* message_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(Event);
|
DISALLOW_COPY_AND_ASSIGN(Event);
|
||||||
|
|||||||
@@ -39,11 +39,10 @@ v8::Local<v8::Object> CreateEventObject(v8::Isolate* isolate) {
|
|||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
v8::Local<v8::Object> CreateJSEvent(
|
v8::Local<v8::Object> CreateJSEvent(v8::Isolate* isolate,
|
||||||
v8::Isolate* isolate,
|
v8::Local<v8::Object> object,
|
||||||
v8::Local<v8::Object> object,
|
content::RenderFrameHost* sender,
|
||||||
content::WebContents* sender,
|
IPC::Message* message) {
|
||||||
IPC::Message* message) {
|
|
||||||
v8::Local<v8::Object> event;
|
v8::Local<v8::Object> event;
|
||||||
bool use_native_event = sender && message;
|
bool use_native_event = sender && message;
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include "native_mate/wrappable.h"
|
#include "native_mate/wrappable.h"
|
||||||
|
|
||||||
namespace content {
|
namespace content {
|
||||||
class WebContents;
|
class RenderFrameHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
@@ -24,7 +24,7 @@ namespace internal {
|
|||||||
|
|
||||||
v8::Local<v8::Object> CreateJSEvent(v8::Isolate* isolate,
|
v8::Local<v8::Object> CreateJSEvent(v8::Isolate* isolate,
|
||||||
v8::Local<v8::Object> object,
|
v8::Local<v8::Object> object,
|
||||||
content::WebContents* sender,
|
content::RenderFrameHost* sender,
|
||||||
IPC::Message* message);
|
IPC::Message* message);
|
||||||
v8::Local<v8::Object> CreateCustomEvent(
|
v8::Local<v8::Object> CreateCustomEvent(
|
||||||
v8::Isolate* isolate,
|
v8::Isolate* isolate,
|
||||||
@@ -74,9 +74,9 @@ class EventEmitter : public Wrappable<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// this.emit(name, new Event(sender, message), args...);
|
// this.emit(name, new Event(sender, message), args...);
|
||||||
template<typename... Args>
|
template <typename... Args>
|
||||||
bool EmitWithSender(const base::StringPiece& name,
|
bool EmitWithSender(const base::StringPiece& name,
|
||||||
content::WebContents* sender,
|
content::RenderFrameHost* sender,
|
||||||
IPC::Message* message,
|
IPC::Message* message,
|
||||||
const Args&... args) {
|
const Args&... args) {
|
||||||
v8::Locker locker(isolate());
|
v8::Locker locker(isolate());
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "atom/browser/api/atom_api_app.h"
|
#include "atom/browser/api/atom_api_app.h"
|
||||||
#include "atom/browser/api/atom_api_protocol.h"
|
#include "atom/browser/api/atom_api_protocol.h"
|
||||||
|
#include "atom/browser/api/atom_api_web_contents.h"
|
||||||
#include "atom/browser/atom_browser_context.h"
|
#include "atom/browser/atom_browser_context.h"
|
||||||
#include "atom/browser/atom_browser_main_parts.h"
|
#include "atom/browser/atom_browser_main_parts.h"
|
||||||
#include "atom/browser/atom_quota_permission_context.h"
|
#include "atom/browser/atom_quota_permission_context.h"
|
||||||
@@ -318,6 +319,11 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
|||||||
web_contents, command_line);
|
web_contents, command_line);
|
||||||
SessionPreferences::AppendExtraCommandLineSwitches(
|
SessionPreferences::AppendExtraCommandLineSwitches(
|
||||||
web_contents->GetBrowserContext(), command_line);
|
web_contents->GetBrowserContext(), command_line);
|
||||||
|
|
||||||
|
auto context_id = atom::api::WebContents::GetIDForContents(
|
||||||
|
web_contents);
|
||||||
|
command_line->AppendSwitchASCII(switches::kContextId,
|
||||||
|
base::IntToString(context_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,14 +108,13 @@ void Browser::SetVersion(const std::string& version) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string Browser::GetName() const {
|
std::string Browser::GetName() const {
|
||||||
std::string ret = name_override_;
|
std::string ret = brightray::GetOverriddenApplicationName();
|
||||||
if (ret.empty())
|
if (ret.empty())
|
||||||
ret = GetExecutableFileProductName();
|
ret = GetExecutableFileProductName();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Browser::SetName(const std::string& name) {
|
void Browser::SetName(const std::string& name) {
|
||||||
name_override_ = name;
|
|
||||||
brightray::OverrideApplicationName(name);
|
brightray::OverrideApplicationName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -273,8 +273,6 @@ class Browser : public WindowListObserver {
|
|||||||
// The browser is being shutdown.
|
// The browser is being shutdown.
|
||||||
bool is_shutdown_;
|
bool is_shutdown_;
|
||||||
|
|
||||||
std::string name_override_;
|
|
||||||
|
|
||||||
int badge_count_ = 0;
|
int badge_count_ = 0;
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
|
|||||||
@@ -7,14 +7,23 @@
|
|||||||
#include "atom/browser/native_browser_view.h"
|
#include "atom/browser/native_browser_view.h"
|
||||||
|
|
||||||
#include "atom/browser/api/atom_api_web_contents.h"
|
#include "atom/browser/api/atom_api_web_contents.h"
|
||||||
#include "brightray/browser/inspectable_web_contents_view.h"
|
#include "brightray/browser/inspectable_web_contents.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
NativeBrowserView::NativeBrowserView(
|
NativeBrowserView::NativeBrowserView(
|
||||||
brightray::InspectableWebContentsView* web_contents_view)
|
brightray::InspectableWebContents* inspectable_web_contents)
|
||||||
: web_contents_view_(web_contents_view) {}
|
: inspectable_web_contents_(inspectable_web_contents) {}
|
||||||
|
|
||||||
NativeBrowserView::~NativeBrowserView() {}
|
NativeBrowserView::~NativeBrowserView() {}
|
||||||
|
|
||||||
|
brightray::InspectableWebContentsView*
|
||||||
|
NativeBrowserView::GetInspectableWebContentsView() {
|
||||||
|
return inspectable_web_contents_->GetView();
|
||||||
|
}
|
||||||
|
|
||||||
|
content::WebContents* NativeBrowserView::GetWebContents() {
|
||||||
|
return inspectable_web_contents_->GetWebContents();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|||||||
@@ -9,9 +9,11 @@
|
|||||||
|
|
||||||
#include "atom/common/draggable_region.h"
|
#include "atom/common/draggable_region.h"
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
|
#include "content/public/browser/web_contents.h"
|
||||||
#include "third_party/skia/include/core/SkColor.h"
|
#include "third_party/skia/include/core/SkColor.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
class InspectableWebContents;
|
||||||
class InspectableWebContentsView;
|
class InspectableWebContentsView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,12 +33,15 @@ class NativeBrowserView {
|
|||||||
virtual ~NativeBrowserView();
|
virtual ~NativeBrowserView();
|
||||||
|
|
||||||
static NativeBrowserView* Create(
|
static NativeBrowserView* Create(
|
||||||
brightray::InspectableWebContentsView* web_contents_view);
|
brightray::InspectableWebContents* inspectable_web_contents);
|
||||||
|
|
||||||
brightray::InspectableWebContentsView* GetInspectableWebContentsView() {
|
brightray::InspectableWebContents* GetInspectableWebContents() {
|
||||||
return web_contents_view_;
|
return inspectable_web_contents_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
brightray::InspectableWebContentsView* GetInspectableWebContentsView();
|
||||||
|
content::WebContents* GetWebContents();
|
||||||
|
|
||||||
virtual void SetAutoResizeFlags(uint8_t flags) = 0;
|
virtual void SetAutoResizeFlags(uint8_t flags) = 0;
|
||||||
virtual void SetBounds(const gfx::Rect& bounds) = 0;
|
virtual void SetBounds(const gfx::Rect& bounds) = 0;
|
||||||
virtual void SetBackgroundColor(SkColor color) = 0;
|
virtual void SetBackgroundColor(SkColor color) = 0;
|
||||||
@@ -47,9 +52,9 @@ class NativeBrowserView {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit NativeBrowserView(
|
explicit NativeBrowserView(
|
||||||
brightray::InspectableWebContentsView* web_contents_view);
|
brightray::InspectableWebContents* inspectable_web_contents);
|
||||||
|
|
||||||
brightray::InspectableWebContentsView* web_contents_view_;
|
brightray::InspectableWebContents* inspectable_web_contents_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(NativeBrowserView);
|
DISALLOW_COPY_AND_ASSIGN(NativeBrowserView);
|
||||||
|
|||||||
@@ -17,12 +17,13 @@ namespace atom {
|
|||||||
class NativeBrowserViewMac : public NativeBrowserView {
|
class NativeBrowserViewMac : public NativeBrowserView {
|
||||||
public:
|
public:
|
||||||
explicit NativeBrowserViewMac(
|
explicit NativeBrowserViewMac(
|
||||||
brightray::InspectableWebContentsView* web_contents_view);
|
brightray::InspectableWebContents* inspectable_web_contents);
|
||||||
~NativeBrowserViewMac() override;
|
~NativeBrowserViewMac() override;
|
||||||
|
|
||||||
void SetAutoResizeFlags(uint8_t flags) override;
|
void SetAutoResizeFlags(uint8_t flags) override;
|
||||||
void SetBounds(const gfx::Rect& bounds) override;
|
void SetBounds(const gfx::Rect& bounds) override;
|
||||||
void SetBackgroundColor(SkColor color) override;
|
void SetBackgroundColor(SkColor color) override;
|
||||||
|
|
||||||
void UpdateDraggableRegions(
|
void UpdateDraggableRegions(
|
||||||
const std::vector<gfx::Rect>& system_drag_exclude_areas) override;
|
const std::vector<gfx::Rect>& system_drag_exclude_areas) override;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "atom/browser/native_browser_view_mac.h"
|
#include "atom/browser/native_browser_view_mac.h"
|
||||||
|
|
||||||
|
#include "brightray/browser/inspectable_web_contents.h"
|
||||||
#include "brightray/browser/inspectable_web_contents_view.h"
|
#include "brightray/browser/inspectable_web_contents_view.h"
|
||||||
#include "skia/ext/skia_utils_mac.h"
|
#include "skia/ext/skia_utils_mac.h"
|
||||||
#include "ui/gfx/geometry/rect.h"
|
#include "ui/gfx/geometry/rect.h"
|
||||||
@@ -156,8 +157,8 @@ const NSAutoresizingMaskOptions kDefaultAutoResizingMask =
|
|||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
NativeBrowserViewMac::NativeBrowserViewMac(
|
NativeBrowserViewMac::NativeBrowserViewMac(
|
||||||
brightray::InspectableWebContentsView* web_contents_view)
|
brightray::InspectableWebContents* inspectable_web_contents)
|
||||||
: NativeBrowserView(web_contents_view) {
|
: NativeBrowserView(inspectable_web_contents) {
|
||||||
auto* view = GetInspectableWebContentsView()->GetNativeView();
|
auto* view = GetInspectableWebContentsView()->GetNativeView();
|
||||||
view.autoresizingMask = kDefaultAutoResizingMask;
|
view.autoresizingMask = kDefaultAutoResizingMask;
|
||||||
}
|
}
|
||||||
@@ -193,62 +194,46 @@ void NativeBrowserViewMac::SetBackgroundColor(SkColor color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NativeBrowserViewMac::UpdateDraggableRegions(
|
void NativeBrowserViewMac::UpdateDraggableRegions(
|
||||||
const std::vector<gfx::Rect>& system_drag_exclude_areas) {
|
const std::vector<gfx::Rect>& drag_exclude_rects) {
|
||||||
NSView* webView = GetInspectableWebContentsView()->GetNativeView();
|
NSView* web_view = GetWebContents()->GetNativeView();
|
||||||
|
NSView* inspectable_view = GetInspectableWebContentsView()->GetNativeView();
|
||||||
|
NSView* window_content_view = inspectable_view.superview;
|
||||||
|
const auto window_content_view_height = NSHeight(window_content_view.bounds);
|
||||||
|
|
||||||
NSInteger superViewHeight = NSHeight([webView.superview bounds]);
|
// Remove all DragRegionViews that were added last time. Note that we need
|
||||||
NSInteger webViewHeight = NSHeight([webView bounds]);
|
// to copy the `subviews` array to avoid mutation during iteration.
|
||||||
NSInteger webViewWidth = NSWidth([webView bounds]);
|
base::scoped_nsobject<NSArray> subviews([[web_view subviews] copy]);
|
||||||
NSInteger webViewX = NSMinX([webView frame]);
|
for (NSView* subview in subviews.get()) {
|
||||||
NSInteger webViewY = 0;
|
if ([subview isKindOfClass:[DragRegionView class]]) {
|
||||||
|
|
||||||
// Apple's NSViews have their coordinate system originate at the bottom left,
|
|
||||||
// meaning that we need to be a bit smarter when it comes to calculating our
|
|
||||||
// current top offset
|
|
||||||
if (webViewHeight > superViewHeight) {
|
|
||||||
webViewY = std::abs(webViewHeight - superViewHeight - (std::abs(NSMinY([webView frame]))));
|
|
||||||
} else {
|
|
||||||
webViewY = superViewHeight - NSMaxY([webView frame]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove all DraggableRegionViews that are added last time.
|
|
||||||
// Note that [webView subviews] returns the view's mutable internal array and
|
|
||||||
// it should be copied to avoid mutating the original array while enumerating
|
|
||||||
// it.
|
|
||||||
base::scoped_nsobject<NSArray> subviews([[webView subviews] copy]);
|
|
||||||
for (NSView* subview in subviews.get())
|
|
||||||
if ([subview isKindOfClass:[DragRegionView class]])
|
|
||||||
[subview removeFromSuperview];
|
[subview removeFromSuperview];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create one giant NSView that is draggable.
|
// Create one giant NSView that is draggable.
|
||||||
base::scoped_nsobject<NSView> dragRegion(
|
base::scoped_nsobject<NSView> drag_region_view(
|
||||||
[[DragRegionView alloc] initWithFrame:NSZeroRect]);
|
[[DragRegionView alloc] initWithFrame:web_view.bounds]);
|
||||||
[dragRegion setFrame:NSMakeRect(0,
|
[web_view addSubview:drag_region_view];
|
||||||
0,
|
|
||||||
webViewWidth,
|
|
||||||
webViewHeight)];
|
|
||||||
|
|
||||||
// Then, on top of that, add "exclusion zones"
|
// Then, on top of that, add "exclusion zones"
|
||||||
for (auto iter = system_drag_exclude_areas.begin();
|
for (const auto& rect : drag_exclude_rects) {
|
||||||
iter != system_drag_exclude_areas.end();
|
const auto window_content_view_exclude_rect =
|
||||||
++iter) {
|
NSMakeRect(rect.x(), window_content_view_height - rect.bottom(),
|
||||||
base::scoped_nsobject<NSView> controlRegion(
|
rect.width(), rect.height());
|
||||||
[[ExcludeDragRegionView alloc] initWithFrame:NSZeroRect]);
|
const auto drag_region_view_exclude_rect =
|
||||||
[controlRegion setFrame:NSMakeRect(iter->x() - webViewX,
|
[window_content_view convertRect:window_content_view_exclude_rect
|
||||||
webViewHeight - iter->bottom() + webViewY,
|
toView:drag_region_view];
|
||||||
iter->width(),
|
|
||||||
iter->height())];
|
|
||||||
[dragRegion addSubview:controlRegion];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the DragRegion to the WebView
|
base::scoped_nsobject<NSView> exclude_drag_region_view(
|
||||||
[webView addSubview:dragRegion];
|
[[ExcludeDragRegionView alloc]
|
||||||
|
initWithFrame:drag_region_view_exclude_rect]);
|
||||||
|
[drag_region_view addSubview:exclude_drag_region_view];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
NativeBrowserView* NativeBrowserView::Create(
|
NativeBrowserView* NativeBrowserView::Create(
|
||||||
brightray::InspectableWebContentsView* web_contents_view) {
|
brightray::InspectableWebContents* inspectable_web_contents) {
|
||||||
return new NativeBrowserViewMac(web_contents_view);
|
return new NativeBrowserViewMac(inspectable_web_contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
NativeBrowserViewViews::NativeBrowserViewViews(
|
NativeBrowserViewViews::NativeBrowserViewViews(
|
||||||
brightray::InspectableWebContentsView* web_contents_view)
|
brightray::InspectableWebContents* inspectable_web_contents)
|
||||||
: NativeBrowserView(web_contents_view) {}
|
: NativeBrowserView(inspectable_web_contents) {}
|
||||||
|
|
||||||
NativeBrowserViewViews::~NativeBrowserViewViews() {}
|
NativeBrowserViewViews::~NativeBrowserViewViews() {}
|
||||||
|
|
||||||
@@ -29,8 +29,8 @@ void NativeBrowserViewViews::SetBackgroundColor(SkColor color) {
|
|||||||
|
|
||||||
// static
|
// static
|
||||||
NativeBrowserView* NativeBrowserView::Create(
|
NativeBrowserView* NativeBrowserView::Create(
|
||||||
brightray::InspectableWebContentsView* web_contents_view) {
|
brightray::InspectableWebContents* inspectable_web_contents) {
|
||||||
return new NativeBrowserViewViews(web_contents_view);
|
return new NativeBrowserViewViews(inspectable_web_contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace atom {
|
|||||||
class NativeBrowserViewViews : public NativeBrowserView {
|
class NativeBrowserViewViews : public NativeBrowserView {
|
||||||
public:
|
public:
|
||||||
explicit NativeBrowserViewViews(
|
explicit NativeBrowserViewViews(
|
||||||
brightray::InspectableWebContentsView* web_contents_view);
|
brightray::InspectableWebContents* inspectable_web_contents);
|
||||||
~NativeBrowserViewViews() override;
|
~NativeBrowserViewViews() override;
|
||||||
|
|
||||||
uint8_t GetAutoResizeFlags() { return auto_resize_flags_; }
|
uint8_t GetAutoResizeFlags() { return auto_resize_flags_; }
|
||||||
|
|||||||
@@ -362,7 +362,8 @@ void NativeWindow::MoveTabToNewWindow() {
|
|||||||
void NativeWindow::ToggleTabBar() {
|
void NativeWindow::ToggleTabBar() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::AddTabbedWindow(NativeWindow* window) {
|
bool NativeWindow::AddTabbedWindow(NativeWindow* window) {
|
||||||
|
return true; // for non-Mac platforms
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::SetVibrancy(const std::string& filename) {
|
void NativeWindow::SetVibrancy(const std::string& filename) {
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ class NativeWindow : public base::SupportsUserData,
|
|||||||
virtual void MergeAllWindows();
|
virtual void MergeAllWindows();
|
||||||
virtual void MoveTabToNewWindow();
|
virtual void MoveTabToNewWindow();
|
||||||
virtual void ToggleTabBar();
|
virtual void ToggleTabBar();
|
||||||
virtual void AddTabbedWindow(NativeWindow* window);
|
virtual bool AddTabbedWindow(NativeWindow* window);
|
||||||
|
|
||||||
// Webview APIs.
|
// Webview APIs.
|
||||||
virtual void FocusOnWebView();
|
virtual void FocusOnWebView();
|
||||||
@@ -238,6 +238,8 @@ class NativeWindow : public base::SupportsUserData,
|
|||||||
const std::vector<base::string16>& labels) {}
|
const std::vector<base::string16>& labels) {}
|
||||||
virtual void HideAutofillPopup(content::RenderFrameHost* frame_host) {}
|
virtual void HideAutofillPopup(content::RenderFrameHost* frame_host) {}
|
||||||
|
|
||||||
|
virtual void UpdateDraggableRegionViews() {}
|
||||||
|
|
||||||
// Public API used by platform-dependent delegates and observers to send UI
|
// Public API used by platform-dependent delegates and observers to send UI
|
||||||
// related notifications.
|
// related notifications.
|
||||||
void NotifyWindowClosed();
|
void NotifyWindowClosed();
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ class NativeWindowMac : public NativeWindow,
|
|||||||
void MergeAllWindows() override;
|
void MergeAllWindows() override;
|
||||||
void MoveTabToNewWindow() override;
|
void MoveTabToNewWindow() override;
|
||||||
void ToggleTabBar() override;
|
void ToggleTabBar() override;
|
||||||
void AddTabbedWindow(NativeWindow* window) override;
|
bool AddTabbedWindow(NativeWindow* window) override;
|
||||||
|
|
||||||
void SetVibrancy(const std::string& type) override;
|
void SetVibrancy(const std::string& type) override;
|
||||||
void SetTouchBar(
|
void SetTouchBar(
|
||||||
@@ -127,7 +127,7 @@ class NativeWindowMac : public NativeWindow,
|
|||||||
content::RenderViewHost* new_host) override;
|
content::RenderViewHost* new_host) override;
|
||||||
|
|
||||||
// Refresh the DraggableRegion views.
|
// Refresh the DraggableRegion views.
|
||||||
void UpdateDraggableRegionViews() {
|
void UpdateDraggableRegionViews() override {
|
||||||
UpdateDraggableRegionViews(draggable_regions_);
|
UpdateDraggableRegionViews(draggable_regions_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include "skia/ext/skia_utils_mac.h"
|
#include "skia/ext/skia_utils_mac.h"
|
||||||
#include "third_party/skia/include/core/SkRegion.h"
|
#include "third_party/skia/include/core/SkRegion.h"
|
||||||
#include "ui/gfx/skia_util.h"
|
#include "ui/gfx/skia_util.h"
|
||||||
|
#include "ui/gl/gpu_switching_manager.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@@ -1677,10 +1678,14 @@ void NativeWindowMac::ToggleTabBar() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::AddTabbedWindow(NativeWindow* window) {
|
bool NativeWindowMac::AddTabbedWindow(NativeWindow* window) {
|
||||||
if ([window_ respondsToSelector:@selector(addTabbedWindow:ordered:)]) {
|
if (window_.get() == window->GetNativeWindow()) {
|
||||||
[window_ addTabbedWindow:window->GetNativeWindow() ordered:NSWindowAbove];
|
return false;
|
||||||
|
} else {
|
||||||
|
if ([window_ respondsToSelector:@selector(addTabbedWindow:ordered:)])
|
||||||
|
[window_ addTabbedWindow:window->GetNativeWindow() ordered:NSWindowAbove];
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SetRenderWidgetHostOpaque(bool opaque) {
|
void NativeWindowMac::SetRenderWidgetHostOpaque(bool opaque) {
|
||||||
@@ -1712,6 +1717,7 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
|
|||||||
|
|
||||||
[vibrant_view removeFromSuperview];
|
[vibrant_view removeFromSuperview];
|
||||||
[window_ setVibrantView:nil];
|
[window_ setVibrantView:nil];
|
||||||
|
ui::GpuSwitchingManager::SetTransparent(transparent());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1719,9 +1725,12 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
|
|||||||
SetRenderWidgetHostOpaque(false);
|
SetRenderWidgetHostOpaque(false);
|
||||||
background_color_before_vibrancy_.reset([window_ backgroundColor]);
|
background_color_before_vibrancy_.reset([window_ backgroundColor]);
|
||||||
transparency_before_vibrancy_ = [window_ titlebarAppearsTransparent];
|
transparency_before_vibrancy_ = [window_ titlebarAppearsTransparent];
|
||||||
|
ui::GpuSwitchingManager::SetTransparent(true);
|
||||||
|
|
||||||
[window_ setTitlebarAppearsTransparent:YES];
|
if (title_bar_style_ != NORMAL) {
|
||||||
[window_ setBackgroundColor:[NSColor clearColor]];
|
[window_ setTitlebarAppearsTransparent:YES];
|
||||||
|
[window_ setBackgroundColor:[NSColor clearColor]];
|
||||||
|
}
|
||||||
|
|
||||||
NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view;
|
NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view;
|
||||||
if (effect_view == nil) {
|
if (effect_view == nil) {
|
||||||
@@ -1971,25 +1980,20 @@ void NativeWindowMac::UpdateDraggableRegionViews(
|
|||||||
|
|
||||||
// Draggable regions is implemented by having the whole web view draggable
|
// Draggable regions is implemented by having the whole web view draggable
|
||||||
// (mouseDownCanMoveWindow) and overlaying regions that are not draggable.
|
// (mouseDownCanMoveWindow) and overlaying regions that are not draggable.
|
||||||
std::vector<gfx::Rect> system_drag_exclude_areas =
|
std::vector<gfx::Rect> drag_exclude_rects =
|
||||||
CalculateNonDraggableRegions(regions, webViewWidth, webViewHeight);
|
CalculateNonDraggableRegions(regions, webViewWidth, webViewHeight);
|
||||||
|
|
||||||
if (browser_view_) {
|
if (browser_view_) {
|
||||||
browser_view_->UpdateDraggableRegions(system_drag_exclude_areas);
|
browser_view_->UpdateDraggableRegions(drag_exclude_rects);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create and add a ControlRegionView for each region that needs to be
|
// Create and add a ControlRegionView for each region that needs to be
|
||||||
// excluded from the dragging.
|
// excluded from the dragging.
|
||||||
for (std::vector<gfx::Rect>::const_iterator iter =
|
for (const auto& rect : drag_exclude_rects) {
|
||||||
system_drag_exclude_areas.begin();
|
|
||||||
iter != system_drag_exclude_areas.end();
|
|
||||||
++iter) {
|
|
||||||
base::scoped_nsobject<NSView> controlRegion(
|
base::scoped_nsobject<NSView> controlRegion(
|
||||||
[[ControlRegionView alloc] initWithFrame:NSZeroRect]);
|
[[ControlRegionView alloc] initWithFrame:NSZeroRect]);
|
||||||
[controlRegion setFrame:NSMakeRect(iter->x(),
|
[controlRegion setFrame:NSMakeRect(rect.x(), webViewHeight - rect.bottom(),
|
||||||
webViewHeight - iter->bottom(),
|
rect.width(), rect.height())];
|
||||||
iter->width(),
|
|
||||||
iter->height())];
|
|
||||||
[webView addSubview:controlRegion];
|
[webView addSubview:controlRegion];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1139,6 +1139,8 @@ void NativeWindowViews::OnWidgetActivationChanged(
|
|||||||
// Hide menu bar when window is blured.
|
// Hide menu bar when window is blured.
|
||||||
if (!active && menu_bar_autohide_ && menu_bar_visible_)
|
if (!active && menu_bar_autohide_ && menu_bar_visible_)
|
||||||
SetMenuBarVisibility(false);
|
SetMenuBarVisibility(false);
|
||||||
|
|
||||||
|
menu_bar_alt_pressed_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowViews::OnWidgetBoundsChanged(
|
void NativeWindowViews::OnWidgetBoundsChanged(
|
||||||
@@ -1336,7 +1338,7 @@ void NativeWindowViews::HandleKeyboardEvent(
|
|||||||
if (event.GetType() == blink::WebInputEvent::kRawKeyDown &&
|
if (event.GetType() == blink::WebInputEvent::kRawKeyDown &&
|
||||||
!IsAltKey(event) && IsAltModifier(event)) {
|
!IsAltKey(event) && IsAltModifier(event)) {
|
||||||
if (!menu_bar_visible_ &&
|
if (!menu_bar_visible_ &&
|
||||||
(menu_bar_->GetAcceleratorIndex(event.windows_key_code) != -1))
|
(menu_bar_->HasAccelerator(event.windows_key_code)))
|
||||||
SetMenuBarVisibility(true);
|
SetMenuBarVisibility(true);
|
||||||
menu_bar_->ActivateAccelerator(event.windows_key_code);
|
menu_bar_->ActivateAccelerator(event.windows_key_code);
|
||||||
return;
|
return;
|
||||||
@@ -1444,12 +1446,9 @@ void NativeWindowViews::RegisterAccelerators(AtomMenuModel* menu_model) {
|
|||||||
|
|
||||||
// Register accelerators with focus manager.
|
// Register accelerators with focus manager.
|
||||||
accelerator_util::GenerateAcceleratorTable(&accelerator_table_, menu_model);
|
accelerator_util::GenerateAcceleratorTable(&accelerator_table_, menu_model);
|
||||||
accelerator_util::AcceleratorTable::const_iterator iter;
|
for (const auto& iter : accelerator_table_) {
|
||||||
for (iter = accelerator_table_.begin();
|
|
||||||
iter != accelerator_table_.end();
|
|
||||||
++iter) {
|
|
||||||
focus_manager->RegisterAccelerator(
|
focus_manager->RegisterAccelerator(
|
||||||
iter->first, ui::AcceleratorManager::kNormalPriority, this);
|
iter.first, ui::AcceleratorManager::kNormalPriority, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -241,10 +241,21 @@ void URLRequestAsarJob::FetchMetaInfo(const base::FilePath& file_path,
|
|||||||
meta_info->is_directory = file_info.is_directory;
|
meta_info->is_directory = file_info.is_directory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// On Windows GetMimeTypeFromFile() goes to the registry. Thus it should be
|
|
||||||
// done in WorkerPool.
|
// We use GetWellKnownMimeTypeFromExtension() to ensure that configurations
|
||||||
meta_info->mime_type_result =
|
// that may have been set by other programs on a user's machine don't affect
|
||||||
net::GetMimeTypeFromFile(file_path, &meta_info->mime_type);
|
// the mime type returned (in particular, JS should always be
|
||||||
|
// (application/javascript). See https://crbug.com/797712. Using an accurate
|
||||||
|
// mime type is necessary at least for modules and sw, which enforce strict
|
||||||
|
// mime type requirements.
|
||||||
|
// TODO(deepak1556): Revert this when sw support is removed for file scheme.
|
||||||
|
base::FilePath::StringType file_extension = file_path.Extension();
|
||||||
|
if (file_extension.empty()) {
|
||||||
|
meta_info->mime_type_result = false;
|
||||||
|
} else {
|
||||||
|
meta_info->mime_type_result = net::GetWellKnownMimeTypeFromExtension(
|
||||||
|
file_extension.substr(1), &meta_info->mime_type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void URLRequestAsarJob::DidFetchMetaInfo(const FileMetaInfo* meta_info) {
|
void URLRequestAsarJob::DidFetchMetaInfo(const FileMetaInfo* meta_info) {
|
||||||
|
|||||||
@@ -227,22 +227,22 @@ AtomNetworkDelegate::~AtomNetworkDelegate() {
|
|||||||
|
|
||||||
void AtomNetworkDelegate::SetSimpleListenerInIO(
|
void AtomNetworkDelegate::SetSimpleListenerInIO(
|
||||||
SimpleEvent type,
|
SimpleEvent type,
|
||||||
const URLPatterns& patterns,
|
URLPatterns patterns,
|
||||||
const SimpleListener& callback) {
|
SimpleListener callback) {
|
||||||
if (callback.is_null())
|
if (callback.is_null())
|
||||||
simple_listeners_.erase(type);
|
simple_listeners_.erase(type);
|
||||||
else
|
else
|
||||||
simple_listeners_[type] = { patterns, callback };
|
simple_listeners_[type] = { std::move(patterns), std::move(callback) };
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomNetworkDelegate::SetResponseListenerInIO(
|
void AtomNetworkDelegate::SetResponseListenerInIO(
|
||||||
ResponseEvent type,
|
ResponseEvent type,
|
||||||
const URLPatterns& patterns,
|
URLPatterns patterns,
|
||||||
const ResponseListener& callback) {
|
ResponseListener callback) {
|
||||||
if (callback.is_null())
|
if (callback.is_null())
|
||||||
response_listeners_.erase(type);
|
response_listeners_.erase(type);
|
||||||
else
|
else
|
||||||
response_listeners_[type] = { patterns, callback };
|
response_listeners_[type] = { std::move(patterns), std::move(callback) };
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomNetworkDelegate::SetDevToolsNetworkEmulationClientId(
|
void AtomNetworkDelegate::SetDevToolsNetworkEmulationClientId(
|
||||||
|
|||||||
@@ -62,11 +62,11 @@ class AtomNetworkDelegate : public brightray::NetworkDelegate {
|
|||||||
~AtomNetworkDelegate() override;
|
~AtomNetworkDelegate() override;
|
||||||
|
|
||||||
void SetSimpleListenerInIO(SimpleEvent type,
|
void SetSimpleListenerInIO(SimpleEvent type,
|
||||||
const URLPatterns& patterns,
|
URLPatterns patterns,
|
||||||
const SimpleListener& callback);
|
SimpleListener callback);
|
||||||
void SetResponseListenerInIO(ResponseEvent type,
|
void SetResponseListenerInIO(ResponseEvent type,
|
||||||
const URLPatterns& patterns,
|
URLPatterns patterns,
|
||||||
const ResponseListener& callback);
|
ResponseListener callback);
|
||||||
|
|
||||||
void SetDevToolsNetworkEmulationClientId(const std::string& client_id);
|
void SetDevToolsNetworkEmulationClientId(const std::string& client_id);
|
||||||
|
|
||||||
|
|||||||
@@ -17,9 +17,9 @@
|
|||||||
<key>CFBundleIconFile</key>
|
<key>CFBundleIconFile</key>
|
||||||
<string>electron.icns</string>
|
<string>electron.icns</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1.8.2</string>
|
<string>2.0.0</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.8.2</string>
|
<string>2.0.0</string>
|
||||||
<key>LSApplicationCategoryType</key>
|
<key>LSApplicationCategoryType</key>
|
||||||
<string>public.app-category.developer-tools</string>
|
<string>public.app-category.developer-tools</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
|||||||
@@ -56,8 +56,8 @@ END
|
|||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 1,8,2,2
|
FILEVERSION 2,0,0,7
|
||||||
PRODUCTVERSION 1,8,2,2
|
PRODUCTVERSION 2,0,0,7
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
@@ -74,12 +74,12 @@ BEGIN
|
|||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "GitHub, Inc."
|
VALUE "CompanyName", "GitHub, Inc."
|
||||||
VALUE "FileDescription", "Electron"
|
VALUE "FileDescription", "Electron"
|
||||||
VALUE "FileVersion", "1.8.2"
|
VALUE "FileVersion", "2.0.0"
|
||||||
VALUE "InternalName", "electron.exe"
|
VALUE "InternalName", "electron.exe"
|
||||||
VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved."
|
VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved."
|
||||||
VALUE "OriginalFilename", "electron.exe"
|
VALUE "OriginalFilename", "electron.exe"
|
||||||
VALUE "ProductName", "Electron"
|
VALUE "ProductName", "Electron"
|
||||||
VALUE "ProductVersion", "1.8.2"
|
VALUE "ProductVersion", "2.0.0"
|
||||||
VALUE "SquirrelAwareVersion", "1"
|
VALUE "SquirrelAwareVersion", "1"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
|||||||
@@ -9,12 +9,15 @@
|
|||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/strings/sys_string_conversions.h"
|
#include "base/strings/sys_string_conversions.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "ui/base/accelerators/accelerator.h"
|
#include "ui/base/accelerators/accelerator.h"
|
||||||
#include "ui/base/accelerators/platform_accelerator_cocoa.h"
|
#include "ui/base/accelerators/platform_accelerator_cocoa.h"
|
||||||
#include "ui/base/l10n/l10n_util_mac.h"
|
#include "ui/base/l10n/l10n_util_mac.h"
|
||||||
#include "ui/events/cocoa/cocoa_event_utils.h"
|
#include "ui/events/cocoa/cocoa_event_utils.h"
|
||||||
#include "ui/gfx/image/image.h"
|
#include "ui/gfx/image/image.h"
|
||||||
|
|
||||||
|
using content::BrowserThread;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct Role {
|
struct Role {
|
||||||
@@ -335,7 +338,11 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
|
|||||||
if (isMenuOpen_) {
|
if (isMenuOpen_) {
|
||||||
isMenuOpen_ = NO;
|
isMenuOpen_ = NO;
|
||||||
model_->MenuWillClose();
|
model_->MenuWillClose();
|
||||||
closeCallback.Run();
|
// Post async task so that itemSelected runs before the close callback
|
||||||
|
// deletes the controller from the map which deallocates it
|
||||||
|
if (!closeCallback.is_null()) {
|
||||||
|
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, closeCallback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -283,8 +283,9 @@ void ShowOpenDialog(const DialogSettings& settings,
|
|||||||
|
|
||||||
if (!settings.parent_window || !settings.parent_window->GetNativeWindow() ||
|
if (!settings.parent_window || !settings.parent_window->GetNativeWindow() ||
|
||||||
settings.force_detached) {
|
settings.force_detached) {
|
||||||
int chosen = [dialog runModal];
|
[dialog beginWithCompletionHandler:^(NSInteger chosen) {
|
||||||
OpenDialogCompletion(chosen, dialog, settings, callback);
|
OpenDialogCompletion(chosen, dialog, settings, callback);
|
||||||
|
}];
|
||||||
} else {
|
} else {
|
||||||
NSWindow* window = settings.parent_window->GetNativeWindow();
|
NSWindow* window = settings.parent_window->GetNativeWindow();
|
||||||
[dialog beginSheetModalForWindow:window
|
[dialog beginSheetModalForWindow:window
|
||||||
@@ -343,8 +344,9 @@ void ShowSaveDialog(const DialogSettings& settings,
|
|||||||
|
|
||||||
if (!settings.parent_window || !settings.parent_window->GetNativeWindow() ||
|
if (!settings.parent_window || !settings.parent_window->GetNativeWindow() ||
|
||||||
settings.force_detached) {
|
settings.force_detached) {
|
||||||
int chosen = [dialog runModal];
|
[dialog beginWithCompletionHandler:^(NSInteger chosen) {
|
||||||
SaveDialogCompletion(chosen, dialog, settings, callback);
|
SaveDialogCompletion(chosen, dialog, settings, callback);
|
||||||
|
}];
|
||||||
} else {
|
} else {
|
||||||
NSWindow* window = settings.parent_window->GetNativeWindow();
|
NSWindow* window = settings.parent_window->GetNativeWindow();
|
||||||
[dialog beginSheetModalForWindow:window
|
[dialog beginSheetModalForWindow:window
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ const CGFloat kVerticalTitleMargin = 2;
|
|||||||
|
|
||||||
// Draw the system bar background.
|
// Draw the system bar background.
|
||||||
[statusItem_ drawStatusBarBackgroundInRect:self.bounds
|
[statusItem_ drawStatusBarBackgroundInRect:self.bounds
|
||||||
withHighlight:[self isHighlighted]];
|
withHighlight:[self shouldHighlight]];
|
||||||
|
|
||||||
// Determine which image to use.
|
// Determine which image to use.
|
||||||
NSImage* image = image_.get();
|
NSImage* image = image_.get();
|
||||||
@@ -230,8 +230,13 @@ const CGFloat kVerticalTitleMargin = 2;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check title_ being nil
|
||||||
|
NSString *title = @"";
|
||||||
|
if (title_)
|
||||||
|
title = title_;
|
||||||
|
|
||||||
attributedTitle_.reset([[NSMutableAttributedString alloc]
|
attributedTitle_.reset([[NSMutableAttributedString alloc]
|
||||||
initWithString:title_
|
initWithString:title
|
||||||
attributes:attributes]);
|
attributes:attributes]);
|
||||||
|
|
||||||
//NSFontAttributeName:[NSFont menuBarFontOfSize:0],
|
//NSFontAttributeName:[NSFont menuBarFontOfSize:0],
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "atom/browser/browser.h"
|
#include "atom/browser/browser.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
|
#include "brightray/common/application_info.h"
|
||||||
#include "chrome/browser/ui/libgtkui/app_indicator_icon.h"
|
#include "chrome/browser/ui/libgtkui/app_indicator_icon.h"
|
||||||
#include "chrome/browser/ui/libgtkui/gtk_status_icon.h"
|
#include "chrome/browser/ui/libgtkui/gtk_status_icon.h"
|
||||||
#include "ui/gfx/image/image.h"
|
#include "ui/gfx/image/image.h"
|
||||||
@@ -32,16 +33,17 @@ void TrayIconGtk::SetImage(const gfx::Image& image) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
base::string16 empty;
|
const auto toolTip = base::UTF8ToUTF16(brightray::GetApplicationName());
|
||||||
|
|
||||||
if (libgtkui::AppIndicatorIcon::CouldOpen()) {
|
if (libgtkui::AppIndicatorIcon::CouldOpen()) {
|
||||||
++indicators_count;
|
++indicators_count;
|
||||||
icon_.reset(new libgtkui::AppIndicatorIcon(
|
icon_.reset(new libgtkui::AppIndicatorIcon(
|
||||||
base::StringPrintf(
|
base::StringPrintf(
|
||||||
"%s%d", Browser::Get()->GetName().c_str(), indicators_count),
|
"%s%d", Browser::Get()->GetName().c_str(), indicators_count),
|
||||||
image.AsImageSkia(),
|
image.AsImageSkia(),
|
||||||
empty));
|
toolTip));
|
||||||
} else {
|
} else {
|
||||||
icon_.reset(new libgtkui::Gtk2StatusIcon(image.AsImageSkia(), empty));
|
icon_.reset(new libgtkui::Gtk2StatusIcon(image.AsImageSkia(), toolTip));
|
||||||
}
|
}
|
||||||
icon_->set_delegate(this);
|
icon_->set_delegate(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,6 @@
|
|||||||
|
|
||||||
#include "atom/browser/ui/views/menu_bar.h"
|
#include "atom/browser/ui/views/menu_bar.h"
|
||||||
|
|
||||||
#if defined(USE_X11)
|
|
||||||
#include "gtk/gtk.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "atom/browser/ui/views/menu_delegate.h"
|
#include "atom/browser/ui/views/menu_delegate.h"
|
||||||
#include "atom/browser/ui/views/submenu_button.h"
|
#include "atom/browser/ui/views/submenu_button.h"
|
||||||
#include "ui/base/models/menu_model.h"
|
#include "ui/base/models/menu_model.h"
|
||||||
@@ -16,52 +12,12 @@
|
|||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
#include "ui/gfx/color_utils.h"
|
#include "ui/gfx/color_utils.h"
|
||||||
#elif defined(USE_X11)
|
|
||||||
#include "chrome/browser/ui/libgtkui/skia_utils_gtk.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
#if defined(USE_X11)
|
|
||||||
|
|
||||||
SkColor GdkRgbaToSkColor(const GdkRGBA& rgba) {
|
|
||||||
return SkColorSetARGB(rgba.alpha * 255, rgba.red * 255, rgba.green * 255,
|
|
||||||
rgba.blue * 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
SkColor GetStyleContextFgColor(GtkStyleContext* style_context,
|
|
||||||
GtkStateFlags state) {
|
|
||||||
GdkRGBA rgba;
|
|
||||||
gtk_style_context_get_color(style_context, state, &rgba);
|
|
||||||
return GdkRgbaToSkColor(rgba);
|
|
||||||
}
|
|
||||||
|
|
||||||
SkColor GetStyleContextBgColor(GtkStyleContext* style_context,
|
|
||||||
GtkStateFlags state) {
|
|
||||||
GdkRGBA rgba;
|
|
||||||
gtk_style_context_get_background_color(style_context, state, &rgba);
|
|
||||||
return GdkRgbaToSkColor(rgba);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetMenuBarColor(SkColor* enabled,
|
|
||||||
SkColor* disabled,
|
|
||||||
SkColor* highlight,
|
|
||||||
SkColor* hover,
|
|
||||||
SkColor* background) {
|
|
||||||
GtkWidget* menu_bar = gtk_menu_bar_new();
|
|
||||||
GtkStyleContext* sc = gtk_widget_get_style_context(menu_bar);
|
|
||||||
*enabled = GetStyleContextFgColor(sc, GTK_STATE_FLAG_NORMAL);
|
|
||||||
*disabled = GetStyleContextFgColor(sc, GTK_STATE_FLAG_INSENSITIVE);
|
|
||||||
*highlight = GetStyleContextFgColor(sc, GTK_STATE_FLAG_SELECTED);
|
|
||||||
*hover = GetStyleContextFgColor(sc, GTK_STATE_FLAG_PRELIGHT);
|
|
||||||
*background = GetStyleContextBgColor(sc, GTK_STATE_FLAG_NORMAL);
|
|
||||||
gtk_widget_destroy(GTK_WIDGET(menu_bar));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // USE_X11
|
|
||||||
|
|
||||||
const char kViewClassName[] = "ElectronMenuBar";
|
const char kViewClassName[] = "ElectronMenuBar";
|
||||||
|
|
||||||
// Default color of the menu bar.
|
// Default color of the menu bar.
|
||||||
@@ -71,75 +27,70 @@ const SkColor kDefaultColor = SkColorSetARGB(255, 233, 233, 233);
|
|||||||
|
|
||||||
MenuBar::MenuBar(NativeWindow* window)
|
MenuBar::MenuBar(NativeWindow* window)
|
||||||
: background_color_(kDefaultColor), menu_model_(NULL), window_(window) {
|
: background_color_(kDefaultColor), menu_model_(NULL), window_(window) {
|
||||||
UpdateMenuBarColor();
|
RefreshColorCache();
|
||||||
|
UpdateViewColors();
|
||||||
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal));
|
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal));
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuBar::~MenuBar() {}
|
MenuBar::~MenuBar() {}
|
||||||
|
|
||||||
|
void MenuBar::AddedToWidget() {
|
||||||
|
auto fm = GetFocusManager();
|
||||||
|
fm->AddFocusChangeListener(this);
|
||||||
|
// Note that we don't own fm -- this manages the _connection_
|
||||||
|
focus_manager_.reset(fm, [this](views::FocusManager* fm) {
|
||||||
|
fm->RemoveFocusChangeListener(this);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuBar::RemovedFromWidget() {
|
||||||
|
focus_manager_.reset();
|
||||||
|
}
|
||||||
|
|
||||||
void MenuBar::SetMenu(AtomMenuModel* model) {
|
void MenuBar::SetMenu(AtomMenuModel* model) {
|
||||||
menu_model_ = model;
|
menu_model_ = model;
|
||||||
RemoveAllChildViews(true);
|
RebuildChildren();
|
||||||
|
|
||||||
for (int i = 0; i < model->GetItemCount(); ++i) {
|
|
||||||
SubmenuButton* button =
|
|
||||||
new SubmenuButton(model->GetLabelAt(i), this, background_color_);
|
|
||||||
button->set_tag(i);
|
|
||||||
|
|
||||||
#if defined(USE_X11)
|
|
||||||
button->SetTextColor(views::Button::STATE_NORMAL, enabled_color_);
|
|
||||||
button->SetTextColor(views::Button::STATE_DISABLED, disabled_color_);
|
|
||||||
button->SetTextColor(views::Button::STATE_PRESSED, highlight_color_);
|
|
||||||
button->SetTextColor(views::Button::STATE_HOVERED, hover_color_);
|
|
||||||
button->SetUnderlineColor(enabled_color_);
|
|
||||||
#elif defined(OS_WIN)
|
|
||||||
button->SetUnderlineColor(color_utils::GetSysSkColor(COLOR_GRAYTEXT));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
AddChildView(button);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuBar::SetAcceleratorVisibility(bool visible) {
|
void MenuBar::SetAcceleratorVisibility(bool visible) {
|
||||||
for (int i = 0; i < child_count(); ++i)
|
for (auto* child : GetChildrenInZOrder())
|
||||||
static_cast<SubmenuButton*>(child_at(i))->SetAcceleratorVisibility(visible);
|
static_cast<SubmenuButton*>(child)->SetAcceleratorVisibility(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
int MenuBar::GetAcceleratorIndex(base::char16 key) {
|
MenuBar::View* MenuBar::FindAccelChild(base::char16 key) {
|
||||||
for (int i = 0; i < child_count(); ++i) {
|
for (auto* child : GetChildrenInZOrder()) {
|
||||||
SubmenuButton* button = static_cast<SubmenuButton*>(child_at(i));
|
if (static_cast<SubmenuButton*>(child)->accelerator() == key)
|
||||||
if (button->accelerator() == key)
|
return child;
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
return -1;
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MenuBar::HasAccelerator(base::char16 key) {
|
||||||
|
return FindAccelChild(key) != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuBar::ActivateAccelerator(base::char16 key) {
|
void MenuBar::ActivateAccelerator(base::char16 key) {
|
||||||
int i = GetAcceleratorIndex(key);
|
auto child = FindAccelChild(key);
|
||||||
if (i != -1)
|
if (child)
|
||||||
static_cast<SubmenuButton*>(child_at(i))->Activate(nullptr);
|
static_cast<SubmenuButton*>(child)->Activate(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int MenuBar::GetItemCount() const {
|
int MenuBar::GetItemCount() const {
|
||||||
return menu_model_->GetItemCount();
|
return menu_model_ ? menu_model_->GetItemCount() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MenuBar::GetMenuButtonFromScreenPoint(const gfx::Point& point,
|
bool MenuBar::GetMenuButtonFromScreenPoint(const gfx::Point& screenPoint,
|
||||||
AtomMenuModel** menu_model,
|
AtomMenuModel** menu_model,
|
||||||
views::MenuButton** button) {
|
views::MenuButton** button) {
|
||||||
gfx::Point location(point);
|
if (!GetBoundsInScreen().Contains(screenPoint))
|
||||||
views::View::ConvertPointFromScreen(this, &location);
|
|
||||||
|
|
||||||
if (location.x() < 0 || location.x() >= width() || location.y() < 0 ||
|
|
||||||
location.y() >= height())
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (int i = 0; i < child_count(); ++i) {
|
auto children = GetChildrenInZOrder();
|
||||||
views::View* view = child_at(i);
|
for (int i = 0, n = children.size(); i < n; ++i) {
|
||||||
if (view->GetMirroredBounds().Contains(location) &&
|
if (children[i]->GetBoundsInScreen().Contains(screenPoint) &&
|
||||||
(menu_model_->GetTypeAt(i) == AtomMenuModel::TYPE_SUBMENU)) {
|
(menu_model_->GetTypeAt(i) == AtomMenuModel::TYPE_SUBMENU)) {
|
||||||
*menu_model = menu_model_->GetSubmenuModelAt(i);
|
*menu_model = menu_model_->GetSubmenuModelAt(i);
|
||||||
*button = static_cast<views::MenuButton*>(view);
|
*button = static_cast<views::MenuButton*>(children[i]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,18 +126,71 @@ void MenuBar::OnMenuButtonClicked(views::MenuButton* source,
|
|||||||
menu_delegate->RunMenu(menu_model_->GetSubmenuModelAt(id), source);
|
menu_delegate->RunMenu(menu_model_->GetSubmenuModelAt(id), source);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuBar::OnNativeThemeChanged(const ui::NativeTheme* theme) {
|
void MenuBar::RefreshColorCache(const ui::NativeTheme* theme) {
|
||||||
UpdateMenuBarColor();
|
if (!theme)
|
||||||
}
|
theme = ui::NativeTheme::GetInstanceForNativeUi();
|
||||||
|
if (theme) {
|
||||||
void MenuBar::UpdateMenuBarColor() {
|
background_color_ =
|
||||||
|
theme->GetSystemColor(ui::NativeTheme::kColorId_MenuBackgroundColor);
|
||||||
|
#if defined(USE_X11)
|
||||||
|
enabled_color_ = theme->GetSystemColor(
|
||||||
|
ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor);
|
||||||
|
disabled_color_ = theme->GetSystemColor(
|
||||||
|
ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
background_color_ = color_utils::GetSysSkColor(COLOR_MENUBAR);
|
background_color_ = color_utils::GetSysSkColor(COLOR_MENUBAR);
|
||||||
#elif defined(USE_X11)
|
|
||||||
GetMenuBarColor(&enabled_color_, &disabled_color_, &highlight_color_,
|
|
||||||
&hover_color_, &background_color_);
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuBar::OnNativeThemeChanged(const ui::NativeTheme* theme) {
|
||||||
|
RefreshColorCache(theme);
|
||||||
|
UpdateViewColors();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuBar::OnDidChangeFocus(View* focused_before, View* focused_now) {
|
||||||
|
// if we've changed focus, update our view
|
||||||
|
const auto had_focus = has_focus_;
|
||||||
|
has_focus_ = focused_now != nullptr;
|
||||||
|
if (has_focus_ != had_focus)
|
||||||
|
UpdateViewColors();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuBar::RebuildChildren() {
|
||||||
|
RemoveAllChildViews(true);
|
||||||
|
for (int i = 0, n = GetItemCount(); i < n; ++i) {
|
||||||
|
auto button =
|
||||||
|
new SubmenuButton(menu_model_->GetLabelAt(i), this, background_color_);
|
||||||
|
button->set_tag(i);
|
||||||
|
AddChildView(button);
|
||||||
|
}
|
||||||
|
UpdateViewColors();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuBar::UpdateViewColors() {
|
||||||
|
// set menubar background color
|
||||||
SetBackground(views::CreateSolidBackground(background_color_));
|
SetBackground(views::CreateSolidBackground(background_color_));
|
||||||
|
|
||||||
|
// set child colors
|
||||||
|
if (menu_model_ == nullptr)
|
||||||
|
return;
|
||||||
|
#if defined(USE_X11)
|
||||||
|
const auto& textColor = has_focus_ ? enabled_color_ : disabled_color_;
|
||||||
|
for (auto* child : GetChildrenInZOrder()) {
|
||||||
|
auto button = static_cast<SubmenuButton*>(child);
|
||||||
|
button->SetTextColor(views::Button::STATE_NORMAL, textColor);
|
||||||
|
button->SetTextColor(views::Button::STATE_DISABLED, disabled_color_);
|
||||||
|
button->SetTextColor(views::Button::STATE_PRESSED, enabled_color_);
|
||||||
|
button->SetTextColor(views::Button::STATE_HOVERED, textColor);
|
||||||
|
button->SetUnderlineColor(textColor);
|
||||||
|
}
|
||||||
|
#elif defined(OS_WIN)
|
||||||
|
for (auto* child : GetChildrenInZOrder()) {
|
||||||
|
auto button = static_cast<SubmenuButton*>(child);
|
||||||
|
button->SetUnderlineColor(color_utils::GetSysSkColor(COLOR_MENUTEXT));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|||||||
@@ -5,9 +5,12 @@
|
|||||||
#ifndef ATOM_BROWSER_UI_VIEWS_MENU_BAR_H_
|
#ifndef ATOM_BROWSER_UI_VIEWS_MENU_BAR_H_
|
||||||
#define ATOM_BROWSER_UI_VIEWS_MENU_BAR_H_
|
#define ATOM_BROWSER_UI_VIEWS_MENU_BAR_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "atom/browser/native_window.h"
|
#include "atom/browser/native_window.h"
|
||||||
#include "atom/browser/ui/atom_menu_model.h"
|
#include "atom/browser/ui/atom_menu_model.h"
|
||||||
#include "ui/views/controls/button/menu_button_listener.h"
|
#include "ui/views/controls/button/menu_button_listener.h"
|
||||||
|
#include "ui/views/focus/focus_manager.h"
|
||||||
#include "ui/views/view.h"
|
#include "ui/views/view.h"
|
||||||
|
|
||||||
namespace views {
|
namespace views {
|
||||||
@@ -19,7 +22,8 @@ namespace atom {
|
|||||||
class MenuDelegate;
|
class MenuDelegate;
|
||||||
|
|
||||||
class MenuBar : public views::View,
|
class MenuBar : public views::View,
|
||||||
public views::MenuButtonListener {
|
public views::MenuButtonListener,
|
||||||
|
public views::FocusChangeListener {
|
||||||
public:
|
public:
|
||||||
explicit MenuBar(NativeWindow* window);
|
explicit MenuBar(NativeWindow* window);
|
||||||
virtual ~MenuBar();
|
virtual ~MenuBar();
|
||||||
@@ -30,9 +34,8 @@ class MenuBar : public views::View,
|
|||||||
// Shows underline under accelerators.
|
// Shows underline under accelerators.
|
||||||
void SetAcceleratorVisibility(bool visible);
|
void SetAcceleratorVisibility(bool visible);
|
||||||
|
|
||||||
// Returns which submenu has accelerator |key|, -1 would be returned when
|
// Returns true if the submenu has accelerator |key|
|
||||||
// there is no matching submenu.
|
bool HasAccelerator(base::char16 key);
|
||||||
int GetAcceleratorIndex(base::char16 key);
|
|
||||||
|
|
||||||
// Shows the submenu whose accelerator is |key|.
|
// Shows the submenu whose accelerator is |key|.
|
||||||
void ActivateAccelerator(base::char16 key);
|
void ActivateAccelerator(base::char16 key);
|
||||||
@@ -47,7 +50,9 @@ class MenuBar : public views::View,
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// views::View:
|
// views::View:
|
||||||
|
void AddedToWidget() override;
|
||||||
const char* GetClassName() const override;
|
const char* GetClassName() const override;
|
||||||
|
void RemovedFromWidget() override;
|
||||||
|
|
||||||
// views::MenuButtonListener:
|
// views::MenuButtonListener:
|
||||||
void OnMenuButtonClicked(views::MenuButton* source,
|
void OnMenuButtonClicked(views::MenuButton* source,
|
||||||
@@ -55,21 +60,29 @@ class MenuBar : public views::View,
|
|||||||
const ui::Event* event) override;
|
const ui::Event* event) override;
|
||||||
void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
|
void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
|
||||||
|
|
||||||
|
// views::FocusChangeListener:
|
||||||
|
void OnDidChangeFocus(View* focused_before, View* focused_now) override;
|
||||||
|
void OnWillChangeFocus(View* focused_before, View* focused_now) override {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateMenuBarColor();
|
void RebuildChildren();
|
||||||
|
void UpdateViewColors();
|
||||||
|
|
||||||
|
void RefreshColorCache(const ui::NativeTheme* theme = nullptr);
|
||||||
SkColor background_color_;
|
SkColor background_color_;
|
||||||
|
|
||||||
#if defined(USE_X11)
|
#if defined(USE_X11)
|
||||||
SkColor enabled_color_;
|
SkColor enabled_color_;
|
||||||
SkColor disabled_color_;
|
SkColor disabled_color_;
|
||||||
SkColor highlight_color_;
|
|
||||||
SkColor hover_color_;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NativeWindow* window_;
|
NativeWindow* window_;
|
||||||
AtomMenuModel* menu_model_;
|
AtomMenuModel* menu_model_;
|
||||||
|
|
||||||
|
View* FindAccelChild(base::char16 key);
|
||||||
|
|
||||||
|
std::shared_ptr<views::FocusManager> focus_manager_;
|
||||||
|
bool has_focus_ = true;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(MenuBar);
|
DISALLOW_COPY_AND_ASSIGN(MenuBar);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ void SubmenuButton::PaintButtonContents(gfx::Canvas* canvas) {
|
|||||||
|
|
||||||
bool SubmenuButton::GetUnderlinePosition(const base::string16& text,
|
bool SubmenuButton::GetUnderlinePosition(const base::string16& text,
|
||||||
base::char16* accelerator,
|
base::char16* accelerator,
|
||||||
int* start, int* end) {
|
int* start, int* end) const {
|
||||||
int pos, span;
|
int pos, span;
|
||||||
base::string16 trimmed = gfx::RemoveAcceleratorChar(text, '&', &pos, &span);
|
base::string16 trimmed = gfx::RemoveAcceleratorChar(text, '&', &pos, &span);
|
||||||
if (pos > -1 && span != 0) {
|
if (pos > -1 && span != 0) {
|
||||||
@@ -105,7 +105,7 @@ bool SubmenuButton::GetUnderlinePosition(const base::string16& text,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SubmenuButton::GetCharacterPosition(
|
void SubmenuButton::GetCharacterPosition(
|
||||||
const base::string16& text, int index, int* pos) {
|
const base::string16& text, int index, int* pos) const {
|
||||||
int height = 0;
|
int height = 0;
|
||||||
gfx::Canvas::SizeStringInt(text.substr(0, index), gfx::FontList(), pos,
|
gfx::Canvas::SizeStringInt(text.substr(0, index), gfx::FontList(), pos,
|
||||||
&height, 0, 0);
|
&height, 0, 0);
|
||||||
|
|||||||
@@ -21,9 +21,6 @@ class SubmenuButton : public views::MenuButton {
|
|||||||
void SetAcceleratorVisibility(bool visible);
|
void SetAcceleratorVisibility(bool visible);
|
||||||
void SetUnderlineColor(SkColor color);
|
void SetUnderlineColor(SkColor color);
|
||||||
|
|
||||||
void SetEnabledColor(SkColor color);
|
|
||||||
void SetBackgroundColor(SkColor color);
|
|
||||||
|
|
||||||
base::char16 accelerator() const { return accelerator_; }
|
base::char16 accelerator() const { return accelerator_; }
|
||||||
|
|
||||||
// views::MenuButton:
|
// views::MenuButton:
|
||||||
@@ -36,9 +33,9 @@ class SubmenuButton : public views::MenuButton {
|
|||||||
private:
|
private:
|
||||||
bool GetUnderlinePosition(const base::string16& text,
|
bool GetUnderlinePosition(const base::string16& text,
|
||||||
base::char16* accelerator,
|
base::char16* accelerator,
|
||||||
int* start, int* end);
|
int* start, int* end) const;
|
||||||
void GetCharacterPosition(
|
void GetCharacterPosition(
|
||||||
const base::string16& text, int index, int* pos);
|
const base::string16& text, int index, int* pos) const;
|
||||||
|
|
||||||
base::char16 accelerator_;
|
base::char16 accelerator_;
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,28 @@ WebContentsPreferences::WebContentsPreferences(
|
|||||||
web_contents->SetUserData(UserDataKey(), base::WrapUnique(this));
|
web_contents->SetUserData(UserDataKey(), base::WrapUnique(this));
|
||||||
|
|
||||||
instances_.push_back(this);
|
instances_.push_back(this);
|
||||||
|
|
||||||
|
// Set WebPreferences defaults onto the JS object
|
||||||
|
SetDefaultBoolIfUndefined("plugins", false);
|
||||||
|
SetDefaultBoolIfUndefined(options::kExperimentalFeatures, false);
|
||||||
|
SetDefaultBoolIfUndefined(options::kExperimentalCanvasFeatures, false);
|
||||||
|
bool node = SetDefaultBoolIfUndefined(options::kNodeIntegration, true);
|
||||||
|
SetDefaultBoolIfUndefined(options::kNodeIntegrationInWorker, false);
|
||||||
|
SetDefaultBoolIfUndefined(options::kWebviewTag, node);
|
||||||
|
SetDefaultBoolIfUndefined("sandbox", false);
|
||||||
|
SetDefaultBoolIfUndefined("nativeWindowOpen", false);
|
||||||
|
SetDefaultBoolIfUndefined(options::kContextIsolation, false);
|
||||||
|
SetDefaultBoolIfUndefined("javascript", true);
|
||||||
|
SetDefaultBoolIfUndefined("images", true);
|
||||||
|
SetDefaultBoolIfUndefined("textAreasAreResizable", true);
|
||||||
|
SetDefaultBoolIfUndefined("webgl", true);
|
||||||
|
SetDefaultBoolIfUndefined("webSecurity", true);
|
||||||
|
SetDefaultBoolIfUndefined("allowRunningInsecureContent", false);
|
||||||
|
#if defined(OS_MACOSX)
|
||||||
|
SetDefaultBoolIfUndefined(options::kScrollBounce, false);
|
||||||
|
#endif
|
||||||
|
SetDefaultBoolIfUndefined("offscreen", false);
|
||||||
|
last_web_preferences_.MergeDictionary(&web_preferences_);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebContentsPreferences::~WebContentsPreferences() {
|
WebContentsPreferences::~WebContentsPreferences() {
|
||||||
@@ -56,6 +78,16 @@ WebContentsPreferences::~WebContentsPreferences() {
|
|||||||
instances_.end());
|
instances_.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WebContentsPreferences::SetDefaultBoolIfUndefined(const std::string key,
|
||||||
|
bool val) {
|
||||||
|
bool existing;
|
||||||
|
if (!web_preferences_.GetBoolean(key, &existing)) {
|
||||||
|
web_preferences_.SetBoolean(key, val);
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
return existing;
|
||||||
|
}
|
||||||
|
|
||||||
void WebContentsPreferences::Merge(const base::DictionaryValue& extend) {
|
void WebContentsPreferences::Merge(const base::DictionaryValue& extend) {
|
||||||
web_preferences_.MergeDictionary(&extend);
|
web_preferences_.MergeDictionary(&extend);
|
||||||
}
|
}
|
||||||
@@ -80,6 +112,12 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
|
|||||||
|
|
||||||
base::DictionaryValue& web_preferences = self->web_preferences_;
|
base::DictionaryValue& web_preferences = self->web_preferences_;
|
||||||
|
|
||||||
|
// We are appending args to a webContents so let's save the current state
|
||||||
|
// of our preferences object so that during the lifetime of the WebContents
|
||||||
|
// we can fetch the options used to initally configure the WebContents
|
||||||
|
self->last_web_preferences_.Clear();
|
||||||
|
self->last_web_preferences_.MergeDictionary(&web_preferences);
|
||||||
|
|
||||||
bool b;
|
bool b;
|
||||||
// Check if plugins are enabled.
|
// Check if plugins are enabled.
|
||||||
if (web_preferences.GetBoolean("plugins", &b) && b)
|
if (web_preferences.GetBoolean("plugins", &b) && b)
|
||||||
|
|||||||
@@ -53,10 +53,16 @@ class WebContentsPreferences
|
|||||||
|
|
||||||
// Returns the web preferences.
|
// Returns the web preferences.
|
||||||
base::DictionaryValue* web_preferences() { return &web_preferences_; }
|
base::DictionaryValue* web_preferences() { return &web_preferences_; }
|
||||||
|
base::DictionaryValue* last_web_preferences() {
|
||||||
|
return &last_web_preferences_;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class content::WebContentsUserData<WebContentsPreferences>;
|
friend class content::WebContentsUserData<WebContentsPreferences>;
|
||||||
|
|
||||||
|
// Set preference value to given bool if user did not provide value
|
||||||
|
bool SetDefaultBoolIfUndefined(const std::string key, bool val);
|
||||||
|
|
||||||
// Get preferences value as integer possibly coercing it from a string
|
// Get preferences value as integer possibly coercing it from a string
|
||||||
bool GetInteger(const std::string& attributeName, int* intValue);
|
bool GetInteger(const std::string& attributeName, int* intValue);
|
||||||
|
|
||||||
@@ -64,6 +70,7 @@ class WebContentsPreferences
|
|||||||
|
|
||||||
content::WebContents* web_contents_;
|
content::WebContents* web_contents_;
|
||||||
base::DictionaryValue web_preferences_;
|
base::DictionaryValue web_preferences_;
|
||||||
|
base::DictionaryValue last_web_preferences_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(WebContentsPreferences);
|
DISALLOW_COPY_AND_ASSIGN(WebContentsPreferences);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,16 +22,16 @@ IPC_STRUCT_TRAITS_BEGIN(atom::DraggableRegion)
|
|||||||
IPC_STRUCT_TRAITS_MEMBER(bounds)
|
IPC_STRUCT_TRAITS_MEMBER(bounds)
|
||||||
IPC_STRUCT_TRAITS_END()
|
IPC_STRUCT_TRAITS_END()
|
||||||
|
|
||||||
IPC_MESSAGE_ROUTED2(AtomViewHostMsg_Message,
|
IPC_MESSAGE_ROUTED2(AtomFrameHostMsg_Message,
|
||||||
base::string16 /* channel */,
|
base::string16 /* channel */,
|
||||||
base::ListValue /* arguments */)
|
base::ListValue /* arguments */)
|
||||||
|
|
||||||
IPC_SYNC_MESSAGE_ROUTED2_1(AtomViewHostMsg_Message_Sync,
|
IPC_SYNC_MESSAGE_ROUTED2_1(AtomFrameHostMsg_Message_Sync,
|
||||||
base::string16 /* channel */,
|
base::string16 /* channel */,
|
||||||
base::ListValue /* arguments */,
|
base::ListValue /* arguments */,
|
||||||
base::string16 /* result (in JSON) */)
|
base::string16 /* result (in JSON) */)
|
||||||
|
|
||||||
IPC_MESSAGE_ROUTED3(AtomViewMsg_Message,
|
IPC_MESSAGE_ROUTED3(AtomFrameMsg_Message,
|
||||||
bool /* send_to_all */,
|
bool /* send_to_all */,
|
||||||
base::string16 /* channel */,
|
base::string16 /* channel */,
|
||||||
base::ListValue /* arguments */)
|
base::ListValue /* arguments */)
|
||||||
@@ -56,9 +56,9 @@ IPC_MESSAGE_ROUTED1(AtomFrameHostMsg_UpdateDraggableRegions,
|
|||||||
IPC_MESSAGE_CONTROL1(AtomMsg_UpdatePreferences, base::ListValue)
|
IPC_MESSAGE_CONTROL1(AtomMsg_UpdatePreferences, base::ListValue)
|
||||||
|
|
||||||
// Sent by renderer to set the temporary zoom level.
|
// Sent by renderer to set the temporary zoom level.
|
||||||
IPC_SYNC_MESSAGE_ROUTED1_1(AtomViewHostMsg_SetTemporaryZoomLevel,
|
IPC_SYNC_MESSAGE_ROUTED1_1(AtomFrameHostMsg_SetTemporaryZoomLevel,
|
||||||
double /* zoom level */,
|
double /* zoom level */,
|
||||||
double /* result */)
|
double /* result */)
|
||||||
|
|
||||||
// Sent by renderer to get the zoom level.
|
// Sent by renderer to get the zoom level.
|
||||||
IPC_SYNC_MESSAGE_ROUTED0_1(AtomViewHostMsg_GetZoomLevel, double /* result */)
|
IPC_SYNC_MESSAGE_ROUTED0_1(AtomFrameHostMsg_GetZoomLevel, double /* result */)
|
||||||
|
|||||||
@@ -223,7 +223,6 @@ NativeImage::NativeImage(v8::Isolate* isolate, const gfx::Image& image)
|
|||||||
isolate->AdjustAmountOfExternalAllocatedMemory(
|
isolate->AdjustAmountOfExternalAllocatedMemory(
|
||||||
image_.ToImageSkia()->bitmap()->computeSize64());
|
image_.ToImageSkia()->bitmap()->computeSize64());
|
||||||
}
|
}
|
||||||
MarkHighMemoryUsage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
@@ -238,7 +237,6 @@ NativeImage::NativeImage(v8::Isolate* isolate, const base::FilePath& hicon_path)
|
|||||||
isolate->AdjustAmountOfExternalAllocatedMemory(
|
isolate->AdjustAmountOfExternalAllocatedMemory(
|
||||||
image_.ToImageSkia()->bitmap()->computeSize64());
|
image_.ToImageSkia()->bitmap()->computeSize64());
|
||||||
}
|
}
|
||||||
MarkHighMemoryUsage();
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
#include "atom/common/api/api_messages.h"
|
#include "atom/common/api/api_messages.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "base/values.h"
|
#include "base/values.h"
|
||||||
|
#include "content/public/browser/render_frame_host.h"
|
||||||
|
#include "content/public/browser/web_contents.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
@@ -35,7 +37,11 @@ void RemoteCallbackFreer::RunDestructor() {
|
|||||||
base::ASCIIToUTF16("ELECTRON_RENDERER_RELEASE_CALLBACK");
|
base::ASCIIToUTF16("ELECTRON_RENDERER_RELEASE_CALLBACK");
|
||||||
base::ListValue args;
|
base::ListValue args;
|
||||||
args.AppendInteger(object_id_);
|
args.AppendInteger(object_id_);
|
||||||
Send(new AtomViewMsg_Message(routing_id(), false, channel, args));
|
auto frame_host = web_contents()->GetMainFrame();
|
||||||
|
if (frame_host) {
|
||||||
|
frame_host->Send(new AtomFrameMsg_Message(frame_host->GetRoutingID(), false,
|
||||||
|
channel, args));
|
||||||
|
}
|
||||||
|
|
||||||
Observe(nullptr);
|
Observe(nullptr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,27 +7,21 @@
|
|||||||
#include "atom/common/api/api_messages.h"
|
#include "atom/common/api/api_messages.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "base/values.h"
|
#include "base/values.h"
|
||||||
#include "content/public/renderer/render_view.h"
|
#include "content/public/renderer/render_frame.h"
|
||||||
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
||||||
#include "third_party/WebKit/public/web/WebView.h"
|
|
||||||
|
|
||||||
using blink::WebLocalFrame;
|
using blink::WebLocalFrame;
|
||||||
using blink::WebView;
|
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
content::RenderView* GetCurrentRenderView() {
|
content::RenderFrame* GetCurrentRenderFrame() {
|
||||||
WebLocalFrame* frame = WebLocalFrame::FrameForCurrentContext();
|
WebLocalFrame* frame = WebLocalFrame::FrameForCurrentContext();
|
||||||
if (!frame)
|
if (!frame)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
WebView* view = frame->View();
|
return content::RenderFrame::FromWebFrame(frame);
|
||||||
if (!view)
|
|
||||||
return nullptr; // can happen during closing.
|
|
||||||
|
|
||||||
return content::RenderView::FromWebView(view);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@@ -43,9 +37,9 @@ RemoteObjectFreer::RemoteObjectFreer(
|
|||||||
: ObjectLifeMonitor(isolate, target),
|
: ObjectLifeMonitor(isolate, target),
|
||||||
object_id_(object_id),
|
object_id_(object_id),
|
||||||
routing_id_(MSG_ROUTING_NONE) {
|
routing_id_(MSG_ROUTING_NONE) {
|
||||||
content::RenderView* render_view = GetCurrentRenderView();
|
content::RenderFrame* render_frame = GetCurrentRenderFrame();
|
||||||
if (render_view) {
|
if (render_frame) {
|
||||||
routing_id_ = render_view->GetRoutingID();
|
routing_id_ = render_frame->GetRoutingID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,17 +47,17 @@ RemoteObjectFreer::~RemoteObjectFreer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RemoteObjectFreer::RunDestructor() {
|
void RemoteObjectFreer::RunDestructor() {
|
||||||
content::RenderView* render_view =
|
content::RenderFrame* render_frame =
|
||||||
content::RenderView::FromRoutingID(routing_id_);
|
content::RenderFrame::FromRoutingID(routing_id_);
|
||||||
if (!render_view)
|
if (!render_frame)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
base::string16 channel = base::ASCIIToUTF16("ipc-message");
|
base::string16 channel = base::ASCIIToUTF16("ipc-message");
|
||||||
base::ListValue args;
|
base::ListValue args;
|
||||||
args.AppendString("ELECTRON_BROWSER_DEREFERENCE");
|
args.AppendString("ELECTRON_BROWSER_DEREFERENCE");
|
||||||
args.AppendInteger(object_id_);
|
args.AppendInteger(object_id_);
|
||||||
render_view->Send(
|
render_frame->Send(new AtomFrameHostMsg_Message(render_frame->GetRoutingID(),
|
||||||
new AtomViewHostMsg_Message(render_view->GetRoutingID(), channel, args));
|
channel, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
#ifndef ATOM_COMMON_ATOM_VERSION_H_
|
#ifndef ATOM_COMMON_ATOM_VERSION_H_
|
||||||
#define ATOM_COMMON_ATOM_VERSION_H_
|
#define ATOM_COMMON_ATOM_VERSION_H_
|
||||||
|
|
||||||
#define ATOM_MAJOR_VERSION 1
|
#define ATOM_MAJOR_VERSION 2
|
||||||
#define ATOM_MINOR_VERSION 8
|
#define ATOM_MINOR_VERSION 0
|
||||||
#define ATOM_PATCH_VERSION 2
|
#define ATOM_PATCH_VERSION 0
|
||||||
#define ATOM_PRE_RELEASE_VERSION -beta.2
|
#define ATOM_PRE_RELEASE_VERSION -beta.7
|
||||||
|
|
||||||
#ifndef ATOM_STRINGIFY
|
#ifndef ATOM_STRINGIFY
|
||||||
#define ATOM_STRINGIFY(n) ATOM_STRINGIFY_HELPER(n)
|
#define ATOM_STRINGIFY(n) ATOM_STRINGIFY_HELPER(n)
|
||||||
|
|||||||
@@ -209,7 +209,10 @@ void CrashReporterWin::SetUploadParameters() {
|
|||||||
int CrashReporterWin::CrashForException(EXCEPTION_POINTERS* info) {
|
int CrashReporterWin::CrashForException(EXCEPTION_POINTERS* info) {
|
||||||
if (breakpad_) {
|
if (breakpad_) {
|
||||||
breakpad_->WriteMinidumpForException(info);
|
breakpad_->WriteMinidumpForException(info);
|
||||||
TerminateProcessWithoutDump();
|
if (skip_system_crash_handler_)
|
||||||
|
TerminateProcessWithoutDump();
|
||||||
|
else
|
||||||
|
RaiseFailFastException(info->ExceptionRecord, info->ContextRecord, 0);
|
||||||
}
|
}
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
}
|
}
|
||||||
@@ -229,7 +232,7 @@ bool CrashReporterWin::MinidumpCallback(const wchar_t* dump_path,
|
|||||||
MDRawAssertionInfo* assertion,
|
MDRawAssertionInfo* assertion,
|
||||||
bool succeeded) {
|
bool succeeded) {
|
||||||
CrashReporterWin* self = static_cast<CrashReporterWin*>(context);
|
CrashReporterWin* self = static_cast<CrashReporterWin*>(context);
|
||||||
if (succeeded && !self->skip_system_crash_handler_)
|
if (succeeded && self->skip_system_crash_handler_)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -13,15 +13,19 @@
|
|||||||
#include "atom/common/atom_version.h"
|
#include "atom/common/atom_version.h"
|
||||||
#include "base/environment.h"
|
#include "base/environment.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
#include "brightray/common/platform_util.h"
|
||||||
#include "chrome/browser/ui/libgtkui/gtk_util.h"
|
#include "chrome/browser/ui/libgtkui/gtk_util.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
GDesktopAppInfo* get_desktop_app_info() {
|
GDesktopAppInfo* get_desktop_app_info() {
|
||||||
std::unique_ptr<base::Environment> env(base::Environment::Create());
|
GDesktopAppInfo * ret = nullptr;
|
||||||
const std::string desktop_id = libgtkui::GetDesktopName(env.get());
|
|
||||||
return desktop_id.empty() ? nullptr
|
std::string desktop_id;
|
||||||
: g_desktop_app_info_new(desktop_id.c_str());
|
if (brightray::platform_util::GetDesktopName(&desktop_id))
|
||||||
|
ret = g_desktop_app_info_new(desktop_id.c_str());
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -178,6 +178,9 @@ const char kAppUserModelId[] = "app-user-model-id";
|
|||||||
// The application path
|
// The application path
|
||||||
const char kAppPath[] = "app-path";
|
const char kAppPath[] = "app-path";
|
||||||
|
|
||||||
|
// The context ID for this process
|
||||||
|
const char kContextId[] = "context-id";
|
||||||
|
|
||||||
// The command line switch versions of the options.
|
// The command line switch versions of the options.
|
||||||
const char kBackgroundColor[] = "background-color";
|
const char kBackgroundColor[] = "background-color";
|
||||||
const char kPreloadScript[] = "preload";
|
const char kPreloadScript[] = "preload";
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ extern const char kRegisterServiceWorkerSchemes[];
|
|||||||
extern const char kSecureSchemes[];
|
extern const char kSecureSchemes[];
|
||||||
extern const char kAppUserModelId[];
|
extern const char kAppUserModelId[];
|
||||||
extern const char kAppPath[];
|
extern const char kAppPath[];
|
||||||
|
extern const char kContextId[];
|
||||||
|
|
||||||
extern const char kBackgroundColor[];
|
extern const char kBackgroundColor[];
|
||||||
extern const char kPreloadScript[];
|
extern const char kPreloadScript[];
|
||||||
|
|||||||
@@ -7,43 +7,38 @@
|
|||||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||||
#include "atom/common/native_mate_converters/value_converter.h"
|
#include "atom/common/native_mate_converters/value_converter.h"
|
||||||
#include "atom/common/node_includes.h"
|
#include "atom/common/node_includes.h"
|
||||||
#include "content/public/renderer/render_view.h"
|
#include "content/public/renderer/render_frame.h"
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
||||||
#include "third_party/WebKit/public/web/WebView.h"
|
#include "third_party/WebKit/public/web/WebView.h"
|
||||||
|
|
||||||
using content::RenderView;
|
using content::RenderFrame;
|
||||||
using blink::WebLocalFrame;
|
using blink::WebLocalFrame;
|
||||||
using blink::WebView;
|
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace api {
|
namespace api {
|
||||||
|
|
||||||
RenderView* GetCurrentRenderView() {
|
RenderFrame* GetCurrentRenderFrame() {
|
||||||
WebLocalFrame* frame = WebLocalFrame::FrameForCurrentContext();
|
WebLocalFrame* frame = WebLocalFrame::FrameForCurrentContext();
|
||||||
if (!frame)
|
if (!frame)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
WebView* view = frame->View();
|
return RenderFrame::FromWebFrame(frame);
|
||||||
if (!view)
|
|
||||||
return nullptr; // can happen during closing.
|
|
||||||
|
|
||||||
return RenderView::FromWebView(view);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Send(mate::Arguments* args,
|
void Send(mate::Arguments* args,
|
||||||
const base::string16& channel,
|
const base::string16& channel,
|
||||||
const base::ListValue& arguments) {
|
const base::ListValue& arguments) {
|
||||||
RenderView* render_view = GetCurrentRenderView();
|
RenderFrame* render_frame = GetCurrentRenderFrame();
|
||||||
if (render_view == nullptr)
|
if (render_frame == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool success = render_view->Send(new AtomViewHostMsg_Message(
|
bool success = render_frame->Send(new AtomFrameHostMsg_Message(
|
||||||
render_view->GetRoutingID(), channel, arguments));
|
render_frame->GetRoutingID(), channel, arguments));
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
args->ThrowError("Unable to send AtomViewHostMsg_Message");
|
args->ThrowError("Unable to send AtomFrameHostMsg_Message");
|
||||||
}
|
}
|
||||||
|
|
||||||
base::string16 SendSync(mate::Arguments* args,
|
base::string16 SendSync(mate::Arguments* args,
|
||||||
@@ -51,16 +46,16 @@ base::string16 SendSync(mate::Arguments* args,
|
|||||||
const base::ListValue& arguments) {
|
const base::ListValue& arguments) {
|
||||||
base::string16 json;
|
base::string16 json;
|
||||||
|
|
||||||
RenderView* render_view = GetCurrentRenderView();
|
RenderFrame* render_frame = GetCurrentRenderFrame();
|
||||||
if (render_view == nullptr)
|
if (render_frame == nullptr)
|
||||||
return json;
|
return json;
|
||||||
|
|
||||||
IPC::SyncMessage* message = new AtomViewHostMsg_Message_Sync(
|
IPC::SyncMessage* message = new AtomFrameHostMsg_Message_Sync(
|
||||||
render_view->GetRoutingID(), channel, arguments, &json);
|
render_frame->GetRoutingID(), channel, arguments, &json);
|
||||||
bool success = render_view->Send(message);
|
bool success = render_frame->Send(message);
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
args->ThrowError("Unable to send AtomViewHostMsg_Message_Sync");
|
args->ThrowError("Unable to send AtomFrameHostMsg_Message_Sync");
|
||||||
|
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,19 +125,19 @@ void WebFrame::SetName(const std::string& name) {
|
|||||||
|
|
||||||
double WebFrame::SetZoomLevel(double level) {
|
double WebFrame::SetZoomLevel(double level) {
|
||||||
double result = 0.0;
|
double result = 0.0;
|
||||||
content::RenderView* render_view =
|
content::RenderFrame* render_frame =
|
||||||
content::RenderView::FromWebView(web_frame_->View());
|
content::RenderFrame::FromWebFrame(web_frame_);
|
||||||
render_view->Send(new AtomViewHostMsg_SetTemporaryZoomLevel(
|
render_frame->Send(new AtomFrameHostMsg_SetTemporaryZoomLevel(
|
||||||
render_view->GetRoutingID(), level, &result));
|
render_frame->GetRoutingID(), level, &result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
double WebFrame::GetZoomLevel() const {
|
double WebFrame::GetZoomLevel() const {
|
||||||
double result = 0.0;
|
double result = 0.0;
|
||||||
content::RenderView* render_view =
|
content::RenderFrame* render_frame =
|
||||||
content::RenderView::FromWebView(web_frame_->View());
|
content::RenderFrame::FromWebFrame(web_frame_);
|
||||||
render_view->Send(
|
render_frame->Send(
|
||||||
new AtomViewHostMsg_GetZoomLevel(render_view->GetRoutingID(), &result));
|
new AtomFrameHostMsg_GetZoomLevel(render_frame->GetRoutingID(), &result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,6 +152,7 @@ double WebFrame::GetZoomFactor() const {
|
|||||||
|
|
||||||
void WebFrame::SetVisualZoomLevelLimits(double min_level, double max_level) {
|
void WebFrame::SetVisualZoomLevelLimits(double min_level, double max_level) {
|
||||||
web_frame_->View()->SetDefaultPageScaleLimits(min_level, max_level);
|
web_frame_->View()->SetDefaultPageScaleLimits(min_level, max_level);
|
||||||
|
web_frame_->View()->SetIgnoreViewportTagScaleLimits(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebFrame::SetLayoutZoomLevelLimits(double min_level, double max_level) {
|
void WebFrame::SetLayoutZoomLevelLimits(double min_level, double max_level) {
|
||||||
|
|||||||
@@ -4,29 +4,90 @@
|
|||||||
|
|
||||||
#include "atom/renderer/atom_render_frame_observer.h"
|
#include "atom/renderer/atom_render_frame_observer.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||||
|
|
||||||
#include "atom/common/api/api_messages.h"
|
#include "atom/common/api/api_messages.h"
|
||||||
|
#include "atom/common/api/event_emitter_caller.h"
|
||||||
|
#include "atom/common/native_mate_converters/value_converter.h"
|
||||||
|
#include "atom/common/node_includes.h"
|
||||||
|
#include "base/strings/string_number_conversions.h"
|
||||||
|
#include "base/trace_event/trace_event.h"
|
||||||
#include "content/public/renderer/render_frame.h"
|
#include "content/public/renderer/render_frame.h"
|
||||||
#include "content/public/renderer/render_view.h"
|
#include "content/public/renderer/render_view.h"
|
||||||
|
#include "ipc/ipc_message_macros.h"
|
||||||
|
#include "native_mate/dictionary.h"
|
||||||
|
#include "net/base/net_module.h"
|
||||||
|
#include "net/grit/net_resources.h"
|
||||||
#include "third_party/WebKit/public/web/WebDocument.h"
|
#include "third_party/WebKit/public/web/WebDocument.h"
|
||||||
#include "third_party/WebKit/public/web/WebDraggableRegion.h"
|
#include "third_party/WebKit/public/web/WebDraggableRegion.h"
|
||||||
|
#include "third_party/WebKit/public/web/WebElement.h"
|
||||||
|
#include "third_party/WebKit/public/web/WebKit.h"
|
||||||
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
||||||
#include "third_party/WebKit/public/web/WebScriptSource.h"
|
#include "third_party/WebKit/public/web/WebScriptSource.h"
|
||||||
|
#include "ui/base/resource/resource_bundle.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
bool GetIPCObject(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
v8::Local<v8::Object>* ipc) {
|
||||||
|
v8::Local<v8::String> key = mate::StringToV8(isolate, "ipc");
|
||||||
|
v8::Local<v8::Private> privateKey = v8::Private::ForApi(isolate, key);
|
||||||
|
v8::Local<v8::Object> global_object = context->Global();
|
||||||
|
v8::Local<v8::Value> value;
|
||||||
|
if (!global_object->GetPrivate(context, privateKey).ToLocal(&value))
|
||||||
|
return false;
|
||||||
|
if (value.IsEmpty() || !value->IsObject())
|
||||||
|
return false;
|
||||||
|
*ipc = value->ToObject();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<v8::Local<v8::Value>> ListValueToVector(
|
||||||
|
v8::Isolate* isolate,
|
||||||
|
const base::ListValue& list) {
|
||||||
|
v8::Local<v8::Value> array = mate::ConvertToV8(isolate, list);
|
||||||
|
std::vector<v8::Local<v8::Value>> result;
|
||||||
|
mate::ConvertFromV8(isolate, array, &result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
base::StringPiece NetResourceProvider(int key) {
|
||||||
|
if (key == IDR_DIR_HEADER_HTML) {
|
||||||
|
base::StringPiece html_data =
|
||||||
|
ui::ResourceBundle::GetSharedInstance().GetRawDataResource(
|
||||||
|
IDR_DIR_HEADER_HTML);
|
||||||
|
return html_data;
|
||||||
|
}
|
||||||
|
return base::StringPiece();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
AtomRenderFrameObserver::AtomRenderFrameObserver(
|
AtomRenderFrameObserver::AtomRenderFrameObserver(
|
||||||
content::RenderFrame* frame,
|
content::RenderFrame* frame,
|
||||||
RendererClientBase* renderer_client)
|
RendererClientBase* renderer_client)
|
||||||
: content::RenderFrameObserver(frame),
|
: content::RenderFrameObserver(frame),
|
||||||
render_frame_(frame),
|
render_frame_(frame),
|
||||||
renderer_client_(renderer_client) {}
|
renderer_client_(renderer_client),
|
||||||
|
document_created_(false) {
|
||||||
|
// Initialise resource for directory listing.
|
||||||
|
net::NetModule::SetResourceProvider(NetResourceProvider);
|
||||||
|
}
|
||||||
|
|
||||||
void AtomRenderFrameObserver::DidClearWindowObject() {
|
void AtomRenderFrameObserver::DidClearWindowObject() {
|
||||||
renderer_client_->DidClearWindowObject(render_frame_);
|
renderer_client_->DidClearWindowObject(render_frame_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AtomRenderFrameObserver::DidCreateDocumentElement() {
|
||||||
|
document_created_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
void AtomRenderFrameObserver::DidCreateScriptContext(
|
void AtomRenderFrameObserver::DidCreateScriptContext(
|
||||||
v8::Handle<v8::Context> context,
|
v8::Handle<v8::Context> context,
|
||||||
int world_id) {
|
int world_id) {
|
||||||
@@ -99,4 +160,70 @@ bool AtomRenderFrameObserver::ShouldNotifyClient(int world_id) {
|
|||||||
return IsMainWorld(world_id);
|
return IsMainWorld(world_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AtomRenderFrameObserver::OnMessageReceived(const IPC::Message& message) {
|
||||||
|
bool handled = true;
|
||||||
|
IPC_BEGIN_MESSAGE_MAP(AtomRenderFrameObserver, message)
|
||||||
|
IPC_MESSAGE_HANDLER(AtomFrameMsg_Message, OnBrowserMessage)
|
||||||
|
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||||
|
IPC_END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
return handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AtomRenderFrameObserver::OnBrowserMessage(bool send_to_all,
|
||||||
|
const base::string16& channel,
|
||||||
|
const base::ListValue& args) {
|
||||||
|
// Don't handle browser messages before document element is created.
|
||||||
|
// When we receive a message from the browser, we try to transfer it
|
||||||
|
// to a web page, and when we do that Blink creates an empty
|
||||||
|
// document element if it hasn't been created yet, and it makes our init
|
||||||
|
// script to run while `window.location` is still "about:blank".
|
||||||
|
if (!document_created_)
|
||||||
|
return;
|
||||||
|
|
||||||
|
blink::WebLocalFrame* frame = render_frame_->GetWebFrame();
|
||||||
|
if (!frame || !render_frame_->IsMainFrame())
|
||||||
|
return;
|
||||||
|
|
||||||
|
EmitIPCEvent(frame, channel, args);
|
||||||
|
|
||||||
|
// Also send the message to all sub-frames.
|
||||||
|
if (send_to_all) {
|
||||||
|
for (blink::WebFrame* child = frame->FirstChild(); child;
|
||||||
|
child = child->NextSibling())
|
||||||
|
if (child->IsWebLocalFrame()) {
|
||||||
|
EmitIPCEvent(child->ToWebLocalFrame(), channel, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AtomRenderFrameObserver::EmitIPCEvent(blink::WebLocalFrame* frame,
|
||||||
|
const base::string16& channel,
|
||||||
|
const base::ListValue& args) {
|
||||||
|
if (!frame)
|
||||||
|
return;
|
||||||
|
|
||||||
|
v8::Isolate* isolate = blink::MainThreadIsolate();
|
||||||
|
v8::HandleScope handle_scope(isolate);
|
||||||
|
|
||||||
|
v8::Local<v8::Context> context = renderer_client_->GetContext(frame, isolate);
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
|
||||||
|
// Only emit IPC event for context with node integration.
|
||||||
|
node::Environment* env = node::Environment::GetCurrent(context);
|
||||||
|
if (!env)
|
||||||
|
return;
|
||||||
|
|
||||||
|
v8::Local<v8::Object> ipc;
|
||||||
|
if (GetIPCObject(isolate, context, &ipc)) {
|
||||||
|
TRACE_EVENT0("devtools.timeline", "FunctionCall");
|
||||||
|
auto args_vector = ListValueToVector(isolate, args);
|
||||||
|
// Insert the Event object, event.sender is ipc.
|
||||||
|
mate::Dictionary event = mate::Dictionary::CreateEmpty(isolate);
|
||||||
|
event.Set("sender", ipc);
|
||||||
|
args_vector.insert(args_vector.begin(), event.GetHandle());
|
||||||
|
mate::EmitEvent(isolate, ipc, channel, args_vector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|||||||
@@ -6,7 +6,13 @@
|
|||||||
#define ATOM_RENDERER_ATOM_RENDER_FRAME_OBSERVER_H_
|
#define ATOM_RENDERER_ATOM_RENDER_FRAME_OBSERVER_H_
|
||||||
|
|
||||||
#include "atom/renderer/renderer_client_base.h"
|
#include "atom/renderer/renderer_client_base.h"
|
||||||
|
#include "base/strings/string16.h"
|
||||||
#include "content/public/renderer/render_frame_observer.h"
|
#include "content/public/renderer/render_frame_observer.h"
|
||||||
|
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
class ListValue;
|
||||||
|
}
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
@@ -31,15 +37,26 @@ class AtomRenderFrameObserver : public content::RenderFrameObserver {
|
|||||||
void WillReleaseScriptContext(v8::Local<v8::Context> context,
|
void WillReleaseScriptContext(v8::Local<v8::Context> context,
|
||||||
int world_id) override;
|
int world_id) override;
|
||||||
void OnDestruct() override;
|
void OnDestruct() override;
|
||||||
|
bool OnMessageReceived(const IPC::Message& message) override;
|
||||||
|
void DidCreateDocumentElement() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void EmitIPCEvent(blink::WebLocalFrame* frame,
|
||||||
|
const base::string16& channel,
|
||||||
|
const base::ListValue& args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool ShouldNotifyClient(int world_id);
|
bool ShouldNotifyClient(int world_id);
|
||||||
void CreateIsolatedWorldContext();
|
void CreateIsolatedWorldContext();
|
||||||
bool IsMainWorld(int world_id);
|
bool IsMainWorld(int world_id);
|
||||||
bool IsIsolatedWorld(int world_id);
|
bool IsIsolatedWorld(int world_id);
|
||||||
|
void OnBrowserMessage(bool send_to_all,
|
||||||
|
const base::string16& channel,
|
||||||
|
const base::ListValue& args);
|
||||||
|
|
||||||
content::RenderFrame* render_frame_;
|
content::RenderFrame* render_frame_;
|
||||||
RendererClientBase* renderer_client_;
|
RendererClientBase* renderer_client_;
|
||||||
|
bool document_created_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(AtomRenderFrameObserver);
|
DISALLOW_COPY_AND_ASSIGN(AtomRenderFrameObserver);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,118 +4,21 @@
|
|||||||
|
|
||||||
#include "atom/renderer/atom_render_view_observer.h"
|
#include "atom/renderer/atom_render_view_observer.h"
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
// Put this before event_emitter_caller.h to have string16 support.
|
|
||||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
|
||||||
|
|
||||||
#include "atom/common/api/api_messages.h"
|
#include "atom/common/api/api_messages.h"
|
||||||
#include "atom/common/api/event_emitter_caller.h"
|
|
||||||
#include "atom/common/native_mate_converters/value_converter.h"
|
|
||||||
#include "atom/common/node_includes.h"
|
|
||||||
#include "atom/renderer/atom_renderer_client.h"
|
|
||||||
#include "base/command_line.h"
|
|
||||||
#include "base/strings/string_number_conversions.h"
|
|
||||||
#include "base/trace_event/trace_event.h"
|
|
||||||
#include "content/public/renderer/render_view.h"
|
#include "content/public/renderer/render_view.h"
|
||||||
#include "ipc/ipc_message_macros.h"
|
#include "ipc/ipc_message_macros.h"
|
||||||
#include "native_mate/dictionary.h"
|
|
||||||
#include "net/base/net_module.h"
|
|
||||||
#include "net/grit/net_resources.h"
|
|
||||||
#include "third_party/WebKit/public/web/WebDocument.h"
|
|
||||||
#include "third_party/WebKit/public/web/WebElement.h"
|
|
||||||
#include "third_party/WebKit/public/web/WebFrame.h"
|
|
||||||
#include "third_party/WebKit/public/web/WebKit.h"
|
|
||||||
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
|
||||||
#include "third_party/WebKit/public/web/WebView.h"
|
#include "third_party/WebKit/public/web/WebView.h"
|
||||||
#include "ui/base/resource/resource_bundle.h"
|
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace {
|
AtomRenderViewObserver::AtomRenderViewObserver(content::RenderView* render_view)
|
||||||
|
: content::RenderViewObserver(render_view) {}
|
||||||
|
|
||||||
bool GetIPCObject(v8::Isolate* isolate,
|
AtomRenderViewObserver::~AtomRenderViewObserver() {}
|
||||||
v8::Local<v8::Context> context,
|
|
||||||
v8::Local<v8::Object>* ipc) {
|
|
||||||
v8::Local<v8::String> key = mate::StringToV8(isolate, "ipc");
|
|
||||||
v8::Local<v8::Private> privateKey = v8::Private::ForApi(isolate, key);
|
|
||||||
v8::Local<v8::Object> global_object = context->Global();
|
|
||||||
v8::Local<v8::Value> value;
|
|
||||||
if (!global_object->GetPrivate(context, privateKey).ToLocal(&value))
|
|
||||||
return false;
|
|
||||||
if (value.IsEmpty() || !value->IsObject())
|
|
||||||
return false;
|
|
||||||
*ipc = value->ToObject();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<v8::Local<v8::Value>> ListValueToVector(
|
|
||||||
v8::Isolate* isolate,
|
|
||||||
const base::ListValue& list) {
|
|
||||||
v8::Local<v8::Value> array = mate::ConvertToV8(isolate, list);
|
|
||||||
std::vector<v8::Local<v8::Value>> result;
|
|
||||||
mate::ConvertFromV8(isolate, array, &result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
base::StringPiece NetResourceProvider(int key) {
|
|
||||||
if (key == IDR_DIR_HEADER_HTML) {
|
|
||||||
base::StringPiece html_data =
|
|
||||||
ui::ResourceBundle::GetSharedInstance().GetRawDataResource(
|
|
||||||
IDR_DIR_HEADER_HTML);
|
|
||||||
return html_data;
|
|
||||||
}
|
|
||||||
return base::StringPiece();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
AtomRenderViewObserver::AtomRenderViewObserver(
|
|
||||||
content::RenderView* render_view,
|
|
||||||
AtomRendererClient* renderer_client)
|
|
||||||
: content::RenderViewObserver(render_view),
|
|
||||||
renderer_client_(renderer_client) {
|
|
||||||
// Initialise resource for directory listing.
|
|
||||||
net::NetModule::SetResourceProvider(NetResourceProvider);
|
|
||||||
}
|
|
||||||
|
|
||||||
AtomRenderViewObserver::~AtomRenderViewObserver() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void AtomRenderViewObserver::EmitIPCEvent(blink::WebLocalFrame* frame,
|
|
||||||
const base::string16& channel,
|
|
||||||
const base::ListValue& args) {
|
|
||||||
if (!frame)
|
|
||||||
return;
|
|
||||||
|
|
||||||
v8::Isolate* isolate = blink::MainThreadIsolate();
|
|
||||||
v8::HandleScope handle_scope(isolate);
|
|
||||||
|
|
||||||
v8::Local<v8::Context> context = renderer_client_->GetContext(frame, isolate);
|
|
||||||
v8::Context::Scope context_scope(context);
|
|
||||||
|
|
||||||
// Only emit IPC event for context with node integration.
|
|
||||||
node::Environment* env = node::Environment::GetCurrent(context);
|
|
||||||
if (!env)
|
|
||||||
return;
|
|
||||||
|
|
||||||
v8::Local<v8::Object> ipc;
|
|
||||||
if (GetIPCObject(isolate, context, &ipc)) {
|
|
||||||
TRACE_EVENT0("devtools.timeline", "FunctionCall");
|
|
||||||
auto args_vector = ListValueToVector(isolate, args);
|
|
||||||
// Insert the Event object, event.sender is ipc.
|
|
||||||
mate::Dictionary event = mate::Dictionary::CreateEmpty(isolate);
|
|
||||||
event.Set("sender", ipc);
|
|
||||||
args_vector.insert(args_vector.begin(), event.GetHandle());
|
|
||||||
mate::EmitEvent(isolate, ipc, channel, args_vector);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AtomRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
|
bool AtomRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
|
||||||
bool handled = true;
|
bool handled = true;
|
||||||
IPC_BEGIN_MESSAGE_MAP(AtomRenderViewObserver, message)
|
IPC_BEGIN_MESSAGE_MAP(AtomRenderViewObserver, message)
|
||||||
IPC_MESSAGE_HANDLER(AtomViewMsg_Message, OnBrowserMessage)
|
|
||||||
IPC_MESSAGE_HANDLER(AtomViewMsg_Offscreen, OnOffscreen)
|
IPC_MESSAGE_HANDLER(AtomViewMsg_Offscreen, OnOffscreen)
|
||||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||||
IPC_END_MESSAGE_MAP()
|
IPC_END_MESSAGE_MAP()
|
||||||
@@ -127,39 +30,6 @@ void AtomRenderViewObserver::OnDestruct() {
|
|||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomRenderViewObserver::OnBrowserMessage(bool send_to_all,
|
|
||||||
const base::string16& channel,
|
|
||||||
const base::ListValue& args) {
|
|
||||||
if (!render_view()->GetWebView())
|
|
||||||
return;
|
|
||||||
|
|
||||||
blink::WebFrame* frame = render_view()->GetWebView()->MainFrame();
|
|
||||||
if (!frame || !frame->IsWebLocalFrame())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Don't handle browser messages before document element is created.
|
|
||||||
// When we receive a message from the browser, we try to transfer it
|
|
||||||
// to a web page, and when we do that Blink creates an empty
|
|
||||||
// document element if it hasn't been created yet, and it makes our init
|
|
||||||
// script to run while `window.location` is still "about:blank".
|
|
||||||
blink::WebDocument document = frame->ToWebLocalFrame()->GetDocument();
|
|
||||||
blink::WebElement html_element = document.DocumentElement();
|
|
||||||
if (html_element.IsNull()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
EmitIPCEvent(frame->ToWebLocalFrame(), channel, args);
|
|
||||||
|
|
||||||
// Also send the message to all sub-frames.
|
|
||||||
if (send_to_all) {
|
|
||||||
for (blink::WebFrame* child = frame->FirstChild(); child;
|
|
||||||
child = child->NextSibling())
|
|
||||||
if (child->IsWebLocalFrame()) {
|
|
||||||
EmitIPCEvent(child->ToWebLocalFrame(), channel, args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AtomRenderViewObserver::OnOffscreen() {
|
void AtomRenderViewObserver::OnOffscreen() {
|
||||||
blink::WebView::SetUseExternalPopupMenus(false);
|
blink::WebView::SetUseExternalPopupMenus(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,43 +5,24 @@
|
|||||||
#ifndef ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_H_
|
#ifndef ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_H_
|
||||||
#define ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_H_
|
#define ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_H_
|
||||||
|
|
||||||
#include "base/strings/string16.h"
|
|
||||||
#include "content/public/renderer/render_view_observer.h"
|
#include "content/public/renderer/render_view_observer.h"
|
||||||
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
|
||||||
|
|
||||||
namespace base {
|
|
||||||
class ListValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
class AtomRendererClient;
|
|
||||||
|
|
||||||
class AtomRenderViewObserver : public content::RenderViewObserver {
|
class AtomRenderViewObserver : public content::RenderViewObserver {
|
||||||
public:
|
public:
|
||||||
explicit AtomRenderViewObserver(content::RenderView* render_view,
|
explicit AtomRenderViewObserver(content::RenderView* render_view);
|
||||||
AtomRendererClient* renderer_client);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~AtomRenderViewObserver();
|
virtual ~AtomRenderViewObserver();
|
||||||
|
|
||||||
virtual void EmitIPCEvent(blink::WebLocalFrame* frame,
|
|
||||||
const base::string16& channel,
|
|
||||||
const base::ListValue& args);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// content::RenderViewObserver implementation.
|
// content::RenderViewObserver implementation.
|
||||||
bool OnMessageReceived(const IPC::Message& message) override;
|
bool OnMessageReceived(const IPC::Message& message) override;
|
||||||
void OnDestruct() override;
|
void OnDestruct() override;
|
||||||
|
|
||||||
void OnBrowserMessage(bool send_to_all,
|
|
||||||
const base::string16& channel,
|
|
||||||
const base::ListValue& args);
|
|
||||||
|
|
||||||
void OnOffscreen();
|
void OnOffscreen();
|
||||||
|
|
||||||
AtomRendererClient* renderer_client_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(AtomRenderViewObserver);
|
DISALLOW_COPY_AND_ASSIGN(AtomRenderViewObserver);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
#include "atom/common/options_switches.h"
|
#include "atom/common/options_switches.h"
|
||||||
#include "atom/renderer/api/atom_api_renderer_ipc.h"
|
#include "atom/renderer/api/atom_api_renderer_ipc.h"
|
||||||
#include "atom/renderer/atom_render_frame_observer.h"
|
#include "atom/renderer/atom_render_frame_observer.h"
|
||||||
#include "atom/renderer/atom_render_view_observer.h"
|
|
||||||
#include "atom/renderer/web_worker_observer.h"
|
#include "atom/renderer/web_worker_observer.h"
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
#include "content/public/renderer/render_frame.h"
|
#include "content/public/renderer/render_frame.h"
|
||||||
@@ -53,11 +52,11 @@ void AtomRendererClient::RenderThreadStarted() {
|
|||||||
|
|
||||||
void AtomRendererClient::RenderFrameCreated(
|
void AtomRendererClient::RenderFrameCreated(
|
||||||
content::RenderFrame* render_frame) {
|
content::RenderFrame* render_frame) {
|
||||||
|
new AtomRenderFrameObserver(render_frame, this);
|
||||||
RendererClientBase::RenderFrameCreated(render_frame);
|
RendererClientBase::RenderFrameCreated(render_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomRendererClient::RenderViewCreated(content::RenderView* render_view) {
|
void AtomRendererClient::RenderViewCreated(content::RenderView* render_view) {
|
||||||
new AtomRenderViewObserver(render_view, this);
|
|
||||||
RendererClientBase::RenderViewCreated(render_view);
|
RendererClientBase::RenderViewCreated(render_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,20 +13,12 @@
|
|||||||
#include "atom/common/native_mate_converters/value_converter.h"
|
#include "atom/common/native_mate_converters/value_converter.h"
|
||||||
#include "atom/common/options_switches.h"
|
#include "atom/common/options_switches.h"
|
||||||
#include "atom/renderer/api/atom_api_renderer_ipc.h"
|
#include "atom/renderer/api/atom_api_renderer_ipc.h"
|
||||||
#include "atom/renderer/atom_render_view_observer.h"
|
#include "atom/renderer/atom_render_frame_observer.h"
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
#include "chrome/renderer/printing/print_web_view_helper.h"
|
#include "chrome/renderer/printing/print_web_view_helper.h"
|
||||||
#include "content/public/renderer/render_frame.h"
|
#include "content/public/renderer/render_frame.h"
|
||||||
#include "content/public/renderer/render_view.h"
|
|
||||||
#include "content/public/renderer/render_view_observer.h"
|
|
||||||
#include "ipc/ipc_message_macros.h"
|
|
||||||
#include "native_mate/converter.h"
|
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
#include "third_party/WebKit/public/web/WebFrame.h"
|
|
||||||
#include "third_party/WebKit/public/web/WebKit.h"
|
#include "third_party/WebKit/public/web/WebKit.h"
|
||||||
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
|
||||||
#include "third_party/WebKit/public/web/WebScriptSource.h"
|
|
||||||
#include "third_party/WebKit/public/web/WebView.h"
|
|
||||||
|
|
||||||
#include "atom/common/node_includes.h"
|
#include "atom/common/node_includes.h"
|
||||||
#include "atom_natives.h" // NOLINT: This file is generated with js2c
|
#include "atom_natives.h" // NOLINT: This file is generated with js2c
|
||||||
@@ -95,20 +87,20 @@ void InitializeBindings(v8::Local<v8::Object> binding,
|
|||||||
b.SetMethod("getSystemMemoryInfo", &AtomBindings::GetSystemMemoryInfo);
|
b.SetMethod("getSystemMemoryInfo", &AtomBindings::GetSystemMemoryInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
class AtomSandboxedRenderViewObserver : public AtomRenderViewObserver {
|
class AtomSandboxedRenderFrameObserver : public AtomRenderFrameObserver {
|
||||||
public:
|
public:
|
||||||
AtomSandboxedRenderViewObserver(content::RenderView* render_view,
|
AtomSandboxedRenderFrameObserver(content::RenderFrame* render_frame,
|
||||||
AtomSandboxedRendererClient* renderer_client)
|
AtomSandboxedRendererClient* renderer_client)
|
||||||
: AtomRenderViewObserver(render_view, nullptr),
|
: AtomRenderFrameObserver(render_frame, renderer_client),
|
||||||
v8_converter_(new atom::V8ValueConverter),
|
v8_converter_(new atom::V8ValueConverter),
|
||||||
renderer_client_(renderer_client) {
|
renderer_client_(renderer_client) {
|
||||||
v8_converter_->SetDisableNode(true);
|
v8_converter_->SetDisableNode(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void EmitIPCEvent(blink::WebLocalFrame* frame,
|
void EmitIPCEvent(blink::WebLocalFrame* frame,
|
||||||
const base::string16& channel,
|
const base::string16& channel,
|
||||||
const base::ListValue& args) override {
|
const base::ListValue& args) {
|
||||||
if (!frame)
|
if (!frame)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -129,7 +121,7 @@ class AtomSandboxedRenderViewObserver : public AtomRenderViewObserver {
|
|||||||
private:
|
private:
|
||||||
std::unique_ptr<atom::V8ValueConverter> v8_converter_;
|
std::unique_ptr<atom::V8ValueConverter> v8_converter_;
|
||||||
AtomSandboxedRendererClient* renderer_client_;
|
AtomSandboxedRendererClient* renderer_client_;
|
||||||
DISALLOW_COPY_AND_ASSIGN(AtomSandboxedRenderViewObserver);
|
DISALLOW_COPY_AND_ASSIGN(AtomSandboxedRenderFrameObserver);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@@ -143,12 +135,12 @@ AtomSandboxedRendererClient::~AtomSandboxedRendererClient() {
|
|||||||
|
|
||||||
void AtomSandboxedRendererClient::RenderFrameCreated(
|
void AtomSandboxedRendererClient::RenderFrameCreated(
|
||||||
content::RenderFrame* render_frame) {
|
content::RenderFrame* render_frame) {
|
||||||
|
new AtomSandboxedRenderFrameObserver(render_frame, this);
|
||||||
RendererClientBase::RenderFrameCreated(render_frame);
|
RendererClientBase::RenderFrameCreated(render_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomSandboxedRendererClient::RenderViewCreated(
|
void AtomSandboxedRendererClient::RenderViewCreated(
|
||||||
content::RenderView* render_view) {
|
content::RenderView* render_view) {
|
||||||
new AtomSandboxedRenderViewObserver(render_view, this);
|
|
||||||
RendererClientBase::RenderViewCreated(render_view);
|
RendererClientBase::RenderViewCreated(render_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "atom/common/options_switches.h"
|
#include "atom/common/options_switches.h"
|
||||||
#include "atom/renderer/atom_autofill_agent.h"
|
#include "atom/renderer/atom_autofill_agent.h"
|
||||||
#include "atom/renderer/atom_render_frame_observer.h"
|
#include "atom/renderer/atom_render_frame_observer.h"
|
||||||
|
#include "atom/renderer/atom_render_view_observer.h"
|
||||||
#include "atom/renderer/content_settings_observer.h"
|
#include "atom/renderer/content_settings_observer.h"
|
||||||
#include "atom/renderer/guest_view_container.h"
|
#include "atom/renderer/guest_view_container.h"
|
||||||
#include "atom/renderer/preferences_manager.h"
|
#include "atom/renderer/preferences_manager.h"
|
||||||
@@ -26,13 +27,13 @@
|
|||||||
#include "content/public/common/content_constants.h"
|
#include "content/public/common/content_constants.h"
|
||||||
#include "content/public/renderer/render_view.h"
|
#include "content/public/renderer/render_view.h"
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
#include "third_party/WebKit/public/web/WebCustomElement.h"
|
#include "third_party/WebKit/Source/platform/weborigin/SchemeRegistry.h"
|
||||||
|
#include "third_party/WebKit/public/web/WebCustomElement.h" // NOLINT(build/include_alpha)
|
||||||
#include "third_party/WebKit/public/web/WebFrameWidget.h"
|
#include "third_party/WebKit/public/web/WebFrameWidget.h"
|
||||||
#include "third_party/WebKit/public/web/WebKit.h"
|
#include "third_party/WebKit/public/web/WebKit.h"
|
||||||
#include "third_party/WebKit/public/web/WebPluginParams.h"
|
#include "third_party/WebKit/public/web/WebPluginParams.h"
|
||||||
#include "third_party/WebKit/public/web/WebScriptSource.h"
|
#include "third_party/WebKit/public/web/WebScriptSource.h"
|
||||||
#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
|
#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
|
||||||
#include "third_party/WebKit/Source/platform/weborigin/SchemeRegistry.h"
|
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
#include "base/mac/mac_util.h"
|
#include "base/mac/mac_util.h"
|
||||||
@@ -144,7 +145,6 @@ void RendererClientBase::RenderThreadStarted() {
|
|||||||
|
|
||||||
void RendererClientBase::RenderFrameCreated(
|
void RendererClientBase::RenderFrameCreated(
|
||||||
content::RenderFrame* render_frame) {
|
content::RenderFrame* render_frame) {
|
||||||
new AtomRenderFrameObserver(render_frame, this);
|
|
||||||
new AutofillAgent(render_frame);
|
new AutofillAgent(render_frame);
|
||||||
new PepperHelper(render_frame);
|
new PepperHelper(render_frame);
|
||||||
new ContentSettingsObserver(render_frame);
|
new ContentSettingsObserver(render_frame);
|
||||||
@@ -159,6 +159,7 @@ void RendererClientBase::RenderFrameCreated(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RendererClientBase::RenderViewCreated(content::RenderView* render_view) {
|
void RendererClientBase::RenderViewCreated(content::RenderView* render_view) {
|
||||||
|
new AtomRenderViewObserver(render_view);
|
||||||
blink::WebFrameWidget* web_frame_widget = render_view->GetWebFrameWidget();
|
blink::WebFrameWidget* web_frame_widget = render_view->GetWebFrameWidget();
|
||||||
if (!web_frame_widget)
|
if (!web_frame_widget)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -157,7 +157,6 @@
|
|||||||
'-ldl',
|
'-ldl',
|
||||||
'-lresolv',
|
'-lresolv',
|
||||||
'-lfontconfig',
|
'-lfontconfig',
|
||||||
'-lfreetype',
|
|
||||||
'-lexpat',
|
'-lexpat',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -169,14 +168,6 @@
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
# On ARM64 libchromiumcontent always links to system libfreetype
|
|
||||||
['target_arch=="arm64"', {
|
|
||||||
'link_settings': {
|
|
||||||
'libraries': [
|
|
||||||
'-lfreetype',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}],
|
|
||||||
],
|
],
|
||||||
}], # OS=="linux"
|
}], # OS=="linux"
|
||||||
['OS=="mac"', {
|
['OS=="mac"', {
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "brightray/browser/notification_delegate.h"
|
#include "brightray/browser/notification_delegate.h"
|
||||||
#include "brightray/common/application_info.h"
|
#include "brightray/common/application_info.h"
|
||||||
|
#include "brightray/common/platform_util.h"
|
||||||
|
#include "chrome/browser/ui/libgtkui/gtk_util.h"
|
||||||
#include "chrome/browser/ui/libgtkui/skia_utils_gtk.h"
|
#include "chrome/browser/ui/libgtkui/skia_utils_gtk.h"
|
||||||
#include "third_party/skia/include/core/SkBitmap.h"
|
#include "third_party/skia/include/core/SkBitmap.h"
|
||||||
|
|
||||||
@@ -126,6 +128,19 @@ void LibnotifyNotification::Show(const NotificationOptions& options) {
|
|||||||
notification_, "x-canonical-append", "true");
|
notification_, "x-canonical-append", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send the desktop name to identify the application
|
||||||
|
// The desktop-entry is the part before the .desktop
|
||||||
|
std::string desktop_id;
|
||||||
|
if (platform_util::GetDesktopName(&desktop_id)) {
|
||||||
|
const std::string suffix{".desktop"};
|
||||||
|
if (base::EndsWith(desktop_id, suffix,
|
||||||
|
base::CompareCase::INSENSITIVE_ASCII)) {
|
||||||
|
desktop_id.resize(desktop_id.size() - suffix.size());
|
||||||
|
}
|
||||||
|
libnotify_loader_.notify_notification_set_hint_string(
|
||||||
|
notification_, "desktop-entry", desktop_id.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
GError* error = nullptr;
|
GError* error = nullptr;
|
||||||
libnotify_loader_.notify_notification_show(notification_, &error);
|
libnotify_loader_.notify_notification_show(notification_, &error);
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
@@ -80,11 +80,6 @@ class URLRequestContextGetter : public net::URLRequestContextGetter {
|
|||||||
|
|
||||||
net::HostResolver* host_resolver();
|
net::HostResolver* host_resolver();
|
||||||
net::URLRequestJobFactory* job_factory() const { return job_factory_; }
|
net::URLRequestJobFactory* job_factory() const { return job_factory_; }
|
||||||
net::NetworkDelegate* network_delegate() const {
|
|
||||||
if (url_request_context_)
|
|
||||||
return url_request_context_->network_delegate();
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Delegate* delegate_;
|
Delegate* delegate_;
|
||||||
|
|||||||
@@ -7,8 +7,9 @@ namespace {
|
|||||||
std::string g_overridden_application_name;
|
std::string g_overridden_application_name;
|
||||||
std::string g_overridden_application_version;
|
std::string g_overridden_application_version;
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
|
// name
|
||||||
void OverrideApplicationName(const std::string& name) {
|
void OverrideApplicationName(const std::string& name) {
|
||||||
g_overridden_application_name = name;
|
g_overridden_application_name = name;
|
||||||
}
|
}
|
||||||
@@ -16,6 +17,7 @@ std::string GetOverriddenApplicationName() {
|
|||||||
return g_overridden_application_name;
|
return g_overridden_application_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// version
|
||||||
void OverrideApplicationVersion(const std::string& version) {
|
void OverrideApplicationVersion(const std::string& version) {
|
||||||
g_overridden_application_version = version;
|
g_overridden_application_version = version;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,10 +47,7 @@ PCWSTR GetRawAppUserModelID() {
|
|||||||
if (SUCCEEDED(GetCurrentProcessExplicitAppUserModelID(¤t_app_id))) {
|
if (SUCCEEDED(GetCurrentProcessExplicitAppUserModelID(¤t_app_id))) {
|
||||||
g_app_user_model_id = current_app_id;
|
g_app_user_model_id = current_app_id;
|
||||||
} else {
|
} else {
|
||||||
std::string name = GetOverriddenApplicationName();
|
std::string name = GetApplicationName();
|
||||||
if (name.empty()) {
|
|
||||||
name = GetApplicationName();
|
|
||||||
}
|
|
||||||
base::string16 generated_app_id = base::ReplaceStringPlaceholders(
|
base::string16 generated_app_id = base::ReplaceStringPlaceholders(
|
||||||
kAppUserModelIDFormat, base::UTF8ToUTF16(name), nullptr);
|
kAppUserModelIDFormat, base::UTF8ToUTF16(name), nullptr);
|
||||||
SetAppUserModelID(generated_app_id);
|
SetAppUserModelID(generated_app_id);
|
||||||
|
|||||||
24
brightray/common/platform_util.h
Normal file
24
brightray/common/platform_util.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
// 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 BRIGHTRAY_COMMON_PLATFORM_UTIL_H_
|
||||||
|
#define BRIGHTRAY_COMMON_PLATFORM_UTIL_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace brightray {
|
||||||
|
|
||||||
|
namespace platform_util {
|
||||||
|
|
||||||
|
#if defined(OS_LINUX)
|
||||||
|
// Returns a success flag.
|
||||||
|
// Unlike libgtkui, does *not* use "chromium-browser.desktop" as a fallback.
|
||||||
|
bool GetDesktopName(std::string* setme);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace platform_util
|
||||||
|
|
||||||
|
} // namespace brightray
|
||||||
|
|
||||||
|
#endif // BRIGHTRAY_COMMON_PLATFORM_UTIL_H_
|
||||||
30
brightray/common/platform_util_linux.cc
Normal file
30
brightray/common/platform_util_linux.cc
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
// Copyright (c) 2018 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "brightray/common/platform_util.h"
|
||||||
|
|
||||||
|
#include "base/environment.h"
|
||||||
|
#include "chrome/browser/ui/libgtkui/gtk_util.h"
|
||||||
|
|
||||||
|
namespace brightray {
|
||||||
|
|
||||||
|
namespace platform_util {
|
||||||
|
|
||||||
|
bool GetDesktopName(std::string* setme) {
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
|
std::unique_ptr<base::Environment> env(base::Environment::Create());
|
||||||
|
std::string desktop_id = libgtkui::GetDesktopName(env.get());
|
||||||
|
constexpr char const* libcc_default_id = "chromium-browser.desktop";
|
||||||
|
if (!desktop_id.empty() && (desktop_id != libcc_default_id)) {
|
||||||
|
*setme = desktop_id;
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace platform_util
|
||||||
|
|
||||||
|
} // namespace brightray
|
||||||
@@ -124,6 +124,8 @@
|
|||||||
'common/main_delegate_mac.mm',
|
'common/main_delegate_mac.mm',
|
||||||
'common/switches.cc',
|
'common/switches.cc',
|
||||||
'common/switches.h',
|
'common/switches.h',
|
||||||
|
'common/platform_util_linux.cc',
|
||||||
|
'common/platform_util.h',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,6 +73,16 @@ A `Integer` representing the unique ID of the view.
|
|||||||
|
|
||||||
Objects created with `new BrowserView` have the following instance methods:
|
Objects created with `new BrowserView` have the following instance methods:
|
||||||
|
|
||||||
|
#### `view.destroy()`
|
||||||
|
|
||||||
|
Force closing the view, the `unload` and `beforeunload` events won't be emitted
|
||||||
|
for the web page. After you're done with a view, call this function in order to
|
||||||
|
free memory and other resources as soon as possible.
|
||||||
|
|
||||||
|
#### `view.isDestroyed()`
|
||||||
|
|
||||||
|
Returns `Boolean` - Whether the view is destroyed.
|
||||||
|
|
||||||
#### `view.setAutoResize(options)` _Experimental_
|
#### `view.setAutoResize(options)` _Experimental_
|
||||||
|
|
||||||
* `options` Object
|
* `options` Object
|
||||||
|
|||||||
@@ -235,7 +235,9 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
|
|||||||
window shadow and window animations. Default is `true`.
|
window shadow and window animations. Default is `true`.
|
||||||
* `vibrancy` String (optional) - Add a type of vibrancy effect to the window, only on
|
* `vibrancy` String (optional) - Add a type of vibrancy effect to the window, only on
|
||||||
macOS. Can be `appearance-based`, `light`, `dark`, `titlebar`, `selection`,
|
macOS. Can be `appearance-based`, `light`, `dark`, `titlebar`, `selection`,
|
||||||
`menu`, `popover`, `sidebar`, `medium-light` or `ultra-dark`.
|
`menu`, `popover`, `sidebar`, `medium-light` or `ultra-dark`. Please note that
|
||||||
|
using `frame: false` in combination with a vibrancy value requires that you use a
|
||||||
|
non-default `titleBarStyle` as well.
|
||||||
* `zoomToPageWidth` Boolean (optional) - Controls the behavior on macOS when
|
* `zoomToPageWidth` Boolean (optional) - Controls the behavior on macOS when
|
||||||
option-clicking the green stoplight button on the toolbar or by clicking the
|
option-clicking the green stoplight button on the toolbar or by clicking the
|
||||||
Window > Zoom menu item. If `true`, the window will grow to the preferred
|
Window > Zoom menu item. If `true`, the window will grow to the preferred
|
||||||
@@ -1197,7 +1199,7 @@ menu bar.
|
|||||||
|
|
||||||
* `progress` Double
|
* `progress` Double
|
||||||
* `options` Object (optional)
|
* `options` Object (optional)
|
||||||
* `mode` String _Windows_ - Mode for the progress bar. Can be `none`, `normal`, `indeterminate`, `error`, or `paused`.
|
* `mode` String _Windows_ - Mode for the progress bar. Can be `none`, `normal`, `indeterminate`, `error` or `paused`.
|
||||||
|
|
||||||
Sets progress value in progress bar. Valid range is [0, 1.0].
|
Sets progress value in progress bar. Valid range is [0, 1.0].
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# Planned Breaking API Changes
|
# Planned Breaking API Changes
|
||||||
|
|
||||||
The following list includes the APIs that will be removed in Electron 2.0.
|
The following list includes the APIs that will be removed in Electron 3.0.
|
||||||
|
|
||||||
There is no timetable for when this release will occur but deprecation
|
There is no timetable for when this release will occur but deprecation
|
||||||
warnings will be added at least 90 days beforehand.
|
warnings will be added at least [one major version](electron-versioning.md#semver) beforehand.
|
||||||
|
|
||||||
## `app`
|
## `app`
|
||||||
|
|
||||||
@@ -25,16 +25,6 @@ let optionsB = {webPreferences: {enableBlinkFeatures: ''}}
|
|||||||
let windowB = new BrowserWindow(optionsB)
|
let windowB = new BrowserWindow(optionsB)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
```js
|
|
||||||
// Deprecated
|
|
||||||
let optionsA = {titleBarStyle: 'hidden-inset'}
|
|
||||||
let windowA = new BrowserWindow(optionsA)
|
|
||||||
// Replace with
|
|
||||||
let optionsB = {titleBarStyle: 'hiddenInset'}
|
|
||||||
let windowB = new BrowserWindow(optionsB)
|
|
||||||
```
|
|
||||||
|
|
||||||
## `clipboard`
|
## `clipboard`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
@@ -76,28 +66,9 @@ crashReporter.start({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
## `menu`
|
|
||||||
|
|
||||||
```js
|
|
||||||
// Deprecated
|
|
||||||
menu.popup(browserWindow, 100, 200, 2)
|
|
||||||
// Replace with
|
|
||||||
menu.popup(browserWindow, {x: 100, y: 200, positioningItem: 2})
|
|
||||||
```
|
|
||||||
|
|
||||||
## `nativeImage`
|
## `nativeImage`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// Deprecated
|
|
||||||
nativeImage.toPng()
|
|
||||||
// Replace with
|
|
||||||
nativeImage.toPNG()
|
|
||||||
|
|
||||||
// Deprecated
|
|
||||||
nativeImage.toJpeg()
|
|
||||||
// Replace with
|
|
||||||
nativeImage.toJPEG()
|
|
||||||
|
|
||||||
// Deprecated
|
// Deprecated
|
||||||
nativeImage.createFromBuffer(buffer, 1.0)
|
nativeImage.createFromBuffer(buffer, 1.0)
|
||||||
// Replace with
|
// Replace with
|
||||||
@@ -106,19 +77,15 @@ nativeImage.createFromBuffer(buffer, {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
## `process`
|
## `screen`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// Deprecated
|
// Deprecated
|
||||||
process.versions['atom-shell']
|
screen.getMenuBarHeight()
|
||||||
// Replace with
|
// Replace with
|
||||||
process.versions.electron
|
screen.getPrimaryDisplay().workArea
|
||||||
```
|
```
|
||||||
|
|
||||||
* `process.versions.electron` and `process.version.chrome` will be made
|
|
||||||
read-only properties for consistency with the other `process.versions`
|
|
||||||
properties set by Node.
|
|
||||||
|
|
||||||
## `session`
|
## `session`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
@@ -155,21 +122,9 @@ webContents.openDevTools({detach: true})
|
|||||||
webContents.openDevTools({mode: 'detach'})
|
webContents.openDevTools({mode: 'detach'})
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
|
||||||
// Deprecated
|
|
||||||
webContents.setZoomLevelLimits(1, 2)
|
|
||||||
// Replace with
|
|
||||||
webContents.setVisualZoomLevelLimits(1, 2)
|
|
||||||
```
|
|
||||||
|
|
||||||
## `webFrame`
|
## `webFrame`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// Deprecated
|
|
||||||
webFrame.setZoomLevelLimits(1, 2)
|
|
||||||
// Replace with
|
|
||||||
webFrame.setVisualZoomLevelLimits(1, 2)
|
|
||||||
|
|
||||||
// Deprecated
|
// Deprecated
|
||||||
webFrame.registerURLSchemeAsSecure('app')
|
webFrame.registerURLSchemeAsSecure('app')
|
||||||
// Replace with
|
// Replace with
|
||||||
@@ -181,15 +136,6 @@ webFrame.registerURLSchemeAsPrivileged('app', {secure: true})
|
|||||||
protocol.registerStandardSchemes(['app'], {secure: true})
|
protocol.registerStandardSchemes(['app'], {secure: true})
|
||||||
```
|
```
|
||||||
|
|
||||||
## `<webview>`
|
|
||||||
|
|
||||||
```js
|
|
||||||
// Deprecated
|
|
||||||
webview.setZoomLevelLimits(1, 2)
|
|
||||||
// Replace with
|
|
||||||
webview.setVisualZoomLevelLimits(1, 2)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Node Headers URL
|
## Node Headers URL
|
||||||
|
|
||||||
This is the URL specified as `disturl` in a `.npmrc` file or as the `--dist-url`
|
This is the URL specified as `disturl` in a `.npmrc` file or as the `--dist-url`
|
||||||
@@ -199,26 +145,8 @@ Deprecated: https://atom.io/download/atom-shell
|
|||||||
|
|
||||||
Replace with: https://atom.io/download/electron
|
Replace with: https://atom.io/download/electron
|
||||||
|
|
||||||
## Duplicate ARM Assets
|
|
||||||
|
|
||||||
Each Electron release includes two identical ARM builds with slightly different
|
|
||||||
filenames, like `electron-v1.7.3-linux-arm.zip` and
|
|
||||||
`electron-v1.7.3-linux-armv7l.zip`. The asset with the `v7l` prefix was added
|
|
||||||
to clarify to users which ARM version it supports, and to disambiguate it from
|
|
||||||
future armv6l and arm64 assets that may be produced.
|
|
||||||
|
|
||||||
The file _without the prefix_ is still being published to avoid breaking any
|
|
||||||
setups that may be consuming it. Starting at 2.0, the un-prefixed file will
|
|
||||||
no longer be published.
|
|
||||||
|
|
||||||
For details, see
|
|
||||||
[6986](https://github.com/electron/electron/pull/6986)
|
|
||||||
and
|
|
||||||
[7189](https://github.com/electron/electron/pull/7189).
|
|
||||||
|
|
||||||
|
|
||||||
## `FIXME` comments
|
## `FIXME` comments
|
||||||
|
|
||||||
The `FIXME` string is used in code comments to denote things that should be
|
The `FIXME` string is used in code comments to denote things that should be
|
||||||
fixed for the 2.0 release. See
|
fixed for the 3.0 release. See
|
||||||
https://github.com/electron/electron/search?q=fixme
|
https://github.com/electron/electron/search?q=fixme
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
'product_name%': 'Electron',
|
'product_name%': 'Electron',
|
||||||
'company_name%': 'GitHub, Inc',
|
'company_name%': 'GitHub, Inc',
|
||||||
'company_abbr%': 'github',
|
'company_abbr%': 'github',
|
||||||
'version%': '1.8.2-beta.2',
|
'version%': '2.0.0-beta.7',
|
||||||
'js2c_input_dir': '<(SHARED_INTERMEDIATE_DIR)/js2c',
|
'js2c_input_dir': '<(SHARED_INTERMEDIATE_DIR)/js2c',
|
||||||
},
|
},
|
||||||
'includes': [
|
'includes': [
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ const electron = require('electron')
|
|||||||
const {deprecate, Menu} = electron
|
const {deprecate, Menu} = electron
|
||||||
const {EventEmitter} = require('events')
|
const {EventEmitter} = require('events')
|
||||||
|
|
||||||
|
let dockMenu = null
|
||||||
|
|
||||||
// App is an EventEmitter.
|
// App is an EventEmitter.
|
||||||
Object.setPrototypeOf(App.prototype, EventEmitter.prototype)
|
Object.setPrototypeOf(App.prototype, EventEmitter.prototype)
|
||||||
EventEmitter.call(app)
|
EventEmitter.call(app)
|
||||||
@@ -49,7 +51,13 @@ if (process.platform === 'darwin') {
|
|||||||
hide: bindings.dockHide,
|
hide: bindings.dockHide,
|
||||||
show: bindings.dockShow,
|
show: bindings.dockShow,
|
||||||
isVisible: bindings.dockIsVisible,
|
isVisible: bindings.dockIsVisible,
|
||||||
setMenu: bindings.dockSetMenu,
|
setMenu (menu) {
|
||||||
|
dockMenu = menu
|
||||||
|
bindings.dockSetMenu(menu)
|
||||||
|
},
|
||||||
|
getMenu () {
|
||||||
|
return dockMenu
|
||||||
|
},
|
||||||
setIcon: bindings.dockSetIcon
|
setIcon: bindings.dockSetIcon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,20 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
throw new Error('The inAppPurchase module can only be used on macOS')
|
const {EventEmitter} = require('events')
|
||||||
|
const {inAppPurchase, InAppPurchase} = process.atomBinding('in_app_purchase')
|
||||||
|
|
||||||
|
// inAppPurchase is an EventEmitter.
|
||||||
|
Object.setPrototypeOf(InAppPurchase.prototype, EventEmitter.prototype)
|
||||||
|
EventEmitter.call(inAppPurchase)
|
||||||
|
|
||||||
|
module.exports = inAppPurchase
|
||||||
|
} else {
|
||||||
|
module.exports = {
|
||||||
|
purchaseProduct: (productID, quantity, callback) => {
|
||||||
|
throw new Error('The inAppPurchase module can only be used on macOS')
|
||||||
|
},
|
||||||
|
canMakePayments: () => false,
|
||||||
|
getReceiptURL: () => ''
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const {EventEmitter} = require('events')
|
|
||||||
const {inAppPurchase, InAppPurchase} = process.atomBinding('in_app_purchase')
|
|
||||||
|
|
||||||
// inAppPurchase is an EventEmitter.
|
|
||||||
Object.setPrototypeOf(InAppPurchase.prototype, EventEmitter.prototype)
|
|
||||||
EventEmitter.call(inAppPurchase)
|
|
||||||
|
|
||||||
module.exports = inAppPurchase
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const delegate = {
|
|||||||
getAcceleratorForCommandId: (menu, id, useDefaultAccelerator) => {
|
getAcceleratorForCommandId: (menu, id, useDefaultAccelerator) => {
|
||||||
const command = menu.commandsMap[id]
|
const command = menu.commandsMap[id]
|
||||||
if (!command) return
|
if (!command) return
|
||||||
if (command.accelerator) return command.accelerator
|
if (command.accelerator != null) return command.accelerator
|
||||||
if (useDefaultAccelerator) return command.getDefaultRoleAccelerator()
|
if (useDefaultAccelerator) return command.getDefaultRoleAccelerator()
|
||||||
},
|
},
|
||||||
executeCommand: (menu, event, id) => {
|
executeCommand: (menu, event, id) => {
|
||||||
@@ -47,6 +47,9 @@ Menu.prototype._init = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Menu.prototype.popup = function (options) {
|
Menu.prototype.popup = function (options) {
|
||||||
|
if (options == null || typeof options !== 'object') {
|
||||||
|
throw new TypeError('Options must be an object')
|
||||||
|
}
|
||||||
let {window, x, y, positioningItem, callback} = options
|
let {window, x, y, positioningItem, callback} = options
|
||||||
|
|
||||||
// no callback passed
|
// no callback passed
|
||||||
|
|||||||
@@ -1,8 +1,17 @@
|
|||||||
const {EventEmitter} = require('events')
|
const {EventEmitter} = require('events')
|
||||||
|
const {deprecate} = require('electron')
|
||||||
const {screen, Screen} = process.atomBinding('screen')
|
const {screen, Screen} = process.atomBinding('screen')
|
||||||
|
|
||||||
// Screen is an EventEmitter.
|
// Screen is an EventEmitter.
|
||||||
Object.setPrototypeOf(Screen.prototype, EventEmitter.prototype)
|
Object.setPrototypeOf(Screen.prototype, EventEmitter.prototype)
|
||||||
EventEmitter.call(screen)
|
EventEmitter.call(screen)
|
||||||
|
|
||||||
|
const nativeFn = screen.getMenuBarHeight
|
||||||
|
screen.getMenuBarHeight = function () {
|
||||||
|
if (!process.noDeprecations) {
|
||||||
|
deprecate.warn('screen.getMenuBarHeight', 'screen.getPrimaryDisplay().workArea')
|
||||||
|
}
|
||||||
|
return nativeFn.call(this)
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = screen
|
module.exports = screen
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ const createGuest = function (embedder, params) {
|
|||||||
// Forward internal web contents event to embedder to handle
|
// Forward internal web contents event to embedder to handle
|
||||||
// native window.open setup
|
// native window.open setup
|
||||||
guest.on('-add-new-contents', (...args) => {
|
guest.on('-add-new-contents', (...args) => {
|
||||||
if (guest.getWebPreferences().nativeWindowOpen === true) {
|
if (guest.getLastWebPreferences().nativeWindowOpen === true) {
|
||||||
const embedder = getEmbedder(guestInstanceId)
|
const embedder = getEmbedder(guestInstanceId)
|
||||||
if (embedder != null) {
|
if (embedder != null) {
|
||||||
embedder.emit('-add-new-contents', ...args)
|
embedder.emit('-add-new-contents', ...args)
|
||||||
@@ -164,7 +164,7 @@ const createGuest = function (embedder, params) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
guest.on('-web-contents-created', (...args) => {
|
guest.on('-web-contents-created', (...args) => {
|
||||||
if (guest.getWebPreferences().nativeWindowOpen === true) {
|
if (guest.getLastWebPreferences().nativeWindowOpen === true) {
|
||||||
const embedder = getEmbedder(guestInstanceId)
|
const embedder = getEmbedder(guestInstanceId)
|
||||||
if (embedder != null) {
|
if (embedder != null) {
|
||||||
embedder.emit('-web-contents-created', ...args)
|
embedder.emit('-web-contents-created', ...args)
|
||||||
|
|||||||
@@ -47,16 +47,24 @@ const mergeBrowserWindowOptions = function (embedder, options) {
|
|||||||
options.webPreferences = {}
|
options.webPreferences = {}
|
||||||
}
|
}
|
||||||
if (embedder.browserWindowOptions != null) {
|
if (embedder.browserWindowOptions != null) {
|
||||||
|
let parentOptions = embedder.browserWindowOptions
|
||||||
|
|
||||||
|
// if parent's visibility is available, that overrides 'show' flag (#12125)
|
||||||
|
const win = BrowserWindow.fromWebContents(embedder.webContents)
|
||||||
|
if (win != null) {
|
||||||
|
parentOptions = {...embedder.browserWindowOptions, show: win.isVisible()}
|
||||||
|
}
|
||||||
|
|
||||||
// Inherit the original options if it is a BrowserWindow.
|
// Inherit the original options if it is a BrowserWindow.
|
||||||
mergeOptions(options, embedder.browserWindowOptions)
|
mergeOptions(options, parentOptions)
|
||||||
} else {
|
} else {
|
||||||
// Or only inherit webPreferences if it is a webview.
|
// Or only inherit webPreferences if it is a webview.
|
||||||
mergeOptions(options.webPreferences, embedder.getWebPreferences())
|
mergeOptions(options.webPreferences, embedder.getLastWebPreferences())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inherit certain option values from parent window
|
// Inherit certain option values from parent window
|
||||||
for (const [name, value] of inheritedWebPreferences) {
|
for (const [name, value] of inheritedWebPreferences) {
|
||||||
if (embedder.getWebPreferences()[name] === value) {
|
if (embedder.getLastWebPreferences()[name] === value) {
|
||||||
options.webPreferences[name] = value
|
options.webPreferences[name] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -169,8 +177,8 @@ const getGuestWindow = function (guestContents) {
|
|||||||
// The W3C does not have anything on this, but from my understanding of the
|
// The W3C does not have anything on this, but from my understanding of the
|
||||||
// security model of |window.opener|, this should be fine.
|
// security model of |window.opener|, this should be fine.
|
||||||
const canAccessWindow = function (sender, target) {
|
const canAccessWindow = function (sender, target) {
|
||||||
return (target.getWebPreferences().openerId === sender.id) ||
|
return (target.getLastWebPreferences().openerId === sender.id) ||
|
||||||
(sender.getWebPreferences().nodeIntegration === true) ||
|
(sender.getLastWebPreferences().nodeIntegration === true) ||
|
||||||
isSameOrigin(sender.getURL(), target.getURL())
|
isSameOrigin(sender.getURL(), target.getURL())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -394,8 +394,8 @@ ipcMain.on('ELECTRON_BROWSER_DEREFERENCE', function (event, id) {
|
|||||||
objectsRegistry.remove(event.sender.getId(), id)
|
objectsRegistry.remove(event.sender.getId(), id)
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('ELECTRON_BROWSER_CONTEXT_RELEASE', (e) => {
|
ipcMain.on('ELECTRON_BROWSER_CONTEXT_RELEASE', (e, contextId) => {
|
||||||
objectsRegistry.clear(e.sender.getId())
|
objectsRegistry.clear(contextId)
|
||||||
e.returnValue = null
|
e.returnValue = null
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,12 @@ class CrashReporter {
|
|||||||
|
|
||||||
getLastCrashReport () {
|
getLastCrashReport () {
|
||||||
const reports = this.getUploadedReports()
|
const reports = this.getUploadedReports()
|
||||||
|
.sort((a, b) => {
|
||||||
|
const ats = (a && a.date) ? new Date(a.date).getTime() : 0
|
||||||
|
const bts = (b && b.date) ? new Date(b.date).getTime() : 0
|
||||||
|
return bts - ats
|
||||||
|
})
|
||||||
|
|
||||||
return (reports.length > 0) ? reports[0] : null
|
return (reports.length > 0) ? reports[0] : null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ ipcRenderer.on('ELECTRON_RENDERER_RELEASE_CALLBACK', (event, id) => {
|
|||||||
|
|
||||||
process.on('exit', () => {
|
process.on('exit', () => {
|
||||||
const command = 'ELECTRON_BROWSER_CONTEXT_RELEASE'
|
const command = 'ELECTRON_BROWSER_CONTEXT_RELEASE'
|
||||||
ipcRenderer.sendSync(command)
|
ipcRenderer.sendSync(command, initialContext)
|
||||||
})
|
})
|
||||||
|
|
||||||
exports.require = (module) => {
|
exports.require = (module) => {
|
||||||
@@ -295,6 +295,15 @@ exports.getCurrentWebContents = () => {
|
|||||||
return metaToValue(ipcRenderer.sendSync('ELECTRON_BROWSER_CURRENT_WEB_CONTENTS'))
|
return metaToValue(ipcRenderer.sendSync('ELECTRON_BROWSER_CURRENT_WEB_CONTENTS'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CONTEXT_ARG = '--context-id='
|
||||||
|
let initialContext = process.argv.find(arg => arg.startsWith(CONTEXT_ARG))
|
||||||
|
if (initialContext) {
|
||||||
|
initialContext = parseInt(initialContext.substr(CONTEXT_ARG.length), 10)
|
||||||
|
} else {
|
||||||
|
// In sandbox we need to pull this from remote
|
||||||
|
initialContext = exports.getCurrentWebContents().getId()
|
||||||
|
}
|
||||||
|
|
||||||
// Get a global object in browser.
|
// Get a global object in browser.
|
||||||
exports.getGlobal = (name) => {
|
exports.getGlobal = (name) => {
|
||||||
const command = 'ELECTRON_BROWSER_GLOBAL'
|
const command = 'ELECTRON_BROWSER_GLOBAL'
|
||||||
|
|||||||
@@ -141,7 +141,18 @@ if (nodeIntegration === 'true') {
|
|||||||
|
|
||||||
// Set the __filename to the path of html file if it is file: protocol.
|
// Set the __filename to the path of html file if it is file: protocol.
|
||||||
if (window.location.protocol === 'file:') {
|
if (window.location.protocol === 'file:') {
|
||||||
var pathname = process.platform === 'win32' && window.location.pathname[0] === '/' ? window.location.pathname.substr(1) : window.location.pathname
|
const location = window.location
|
||||||
|
let pathname = location.pathname
|
||||||
|
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
if (pathname[0] === '/') pathname = pathname.substr(1)
|
||||||
|
|
||||||
|
const isWindowsNetworkSharePath = location.hostname.length > 0 && globalPaths[0].startsWith('\\')
|
||||||
|
if (isWindowsNetworkSharePath) {
|
||||||
|
pathname = `//${location.host}/${pathname}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
global.__filename = path.normalize(decodeURIComponent(pathname))
|
global.__filename = path.normalize(decodeURIComponent(pathname))
|
||||||
global.__dirname = path.dirname(global.__filename)
|
global.__dirname = path.dirname(global.__filename)
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ const getWebPreferences = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { remote } = require('electron')
|
const { remote } = require('electron')
|
||||||
webPreferences = remote.getCurrentWindow().webContents.getWebPreferences()
|
webPreferences = remote.getCurrentWebContents().getLastWebPreferences()
|
||||||
return webPreferences
|
return webPreferences
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return null
|
return null
|
||||||
@@ -111,7 +111,7 @@ module.exports = {
|
|||||||
|
|
||||||
const resources = window.performance
|
const resources = window.performance
|
||||||
.getEntriesByType('resource')
|
.getEntriesByType('resource')
|
||||||
.filter(({ name }) => /^(http|ftp):?/gi.test(name || ''))
|
.filter(({ name }) => /^(http|ftp):/gi.test(name || ''))
|
||||||
.map(({ name }) => `- ${name}`)
|
.map(({ name }) => `- ${name}`)
|
||||||
.join('\n')
|
.join('\n')
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "electron",
|
"name": "electron",
|
||||||
"version": "1.8.2-beta.2",
|
"version": "2.0.0-beta.7",
|
||||||
"repository": "https://github.com/electron/electron",
|
"repository": "https://github.com/electron/electron",
|
||||||
"description": "Build cross platform desktop apps with JavaScript, HTML, and CSS",
|
"description": "Build cross platform desktop apps with JavaScript, HTML, and CSS",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
"remark-cli": "^4.0.0",
|
"remark-cli": "^4.0.0",
|
||||||
"remark-preset-lint-markdown-style-guide": "^2.1.1",
|
"remark-preset-lint-markdown-style-guide": "^2.1.1",
|
||||||
"request": "^2.68.0",
|
"request": "^2.68.0",
|
||||||
|
"serve": "^6.5.3",
|
||||||
"standard": "^10.0.0",
|
"standard": "^10.0.0",
|
||||||
"standard-markdown": "^4.0.0",
|
"standard-markdown": "^4.0.0",
|
||||||
"sumchecker": "^2.0.2",
|
"sumchecker": "^2.0.2",
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ def main():
|
|||||||
if args.target_arch == 'mips64el':
|
if args.target_arch == 'mips64el':
|
||||||
download_mips64el_toolchain()
|
download_mips64el_toolchain()
|
||||||
|
|
||||||
|
if args.target_arch.startswith('arm'):
|
||||||
|
download_native_mksnapshot(args.target_arch)
|
||||||
|
|
||||||
# Redirect to use local libchromiumcontent build.
|
# Redirect to use local libchromiumcontent build.
|
||||||
if args.build_release_libcc or args.build_debug_libcc:
|
if args.build_release_libcc or args.build_debug_libcc:
|
||||||
build_libchromiumcontent(args.verbose, args.target_arch, defines,
|
build_libchromiumcontent(args.verbose, args.target_arch, defines,
|
||||||
@@ -218,6 +221,15 @@ def download_mips64el_toolchain():
|
|||||||
subprocess.check_call(['tar', '-xf', tar_name, '-C', VENDOR_DIR])
|
subprocess.check_call(['tar', '-xf', tar_name, '-C', VENDOR_DIR])
|
||||||
os.remove(tar_name)
|
os.remove(tar_name)
|
||||||
|
|
||||||
|
def download_native_mksnapshot(arch):
|
||||||
|
if not os.path.exists(os.path.join(VENDOR_DIR,
|
||||||
|
'native_mksnapshot')):
|
||||||
|
tar_name = 'native-mksnapshot.tar.bz2'
|
||||||
|
url = '{0}/linux/{1}/{2}/{3}'.format(BASE_URL, arch,
|
||||||
|
get_libchromiumcontent_commit(), tar_name)
|
||||||
|
download(tar_name, url, os.path.join(SOURCE_ROOT, tar_name))
|
||||||
|
subprocess.call(['tar', '-jxf', tar_name, '-C', VENDOR_DIR])
|
||||||
|
os.remove(tar_name)
|
||||||
|
|
||||||
def create_chrome_version_h():
|
def create_chrome_version_h():
|
||||||
version_file = os.path.join(VENDOR_DIR, 'libchromiumcontent', 'VERSION')
|
version_file = os.path.join(VENDOR_DIR, 'libchromiumcontent', 'VERSION')
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ def main():
|
|||||||
ninja += '.exe'
|
ninja += '.exe'
|
||||||
|
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
|
if args.ninja_path:
|
||||||
|
ninja = args.ninja_path
|
||||||
if args.libcc:
|
if args.libcc:
|
||||||
if ('D' not in args.configuration
|
if ('D' not in args.configuration
|
||||||
or not os.path.exists(GCLIENT_DONE)
|
or not os.path.exists(GCLIENT_DONE)
|
||||||
@@ -67,6 +69,9 @@ def parse_args():
|
|||||||
'-d --debug_libchromiumcontent.'
|
'-d --debug_libchromiumcontent.'
|
||||||
),
|
),
|
||||||
action='store_true', default=False)
|
action='store_true', default=False)
|
||||||
|
parser.add_argument('--ninja-path',
|
||||||
|
help='Path of ninja command to use.',
|
||||||
|
required=False)
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,13 +7,12 @@ const circleCIJobs = [
|
|||||||
'electron-linux-arm',
|
'electron-linux-arm',
|
||||||
'electron-linux-arm64',
|
'electron-linux-arm64',
|
||||||
'electron-linux-ia32',
|
'electron-linux-ia32',
|
||||||
'electron-linux-mips64el',
|
// 'electron-linux-mips64el',
|
||||||
'electron-linux-x64'
|
'electron-linux-x64'
|
||||||
]
|
]
|
||||||
|
|
||||||
const jenkinsJobs = [
|
const jenkinsJobs = [
|
||||||
'electron-mas-x64-release',
|
'electron-release'
|
||||||
'electron-osx-x64-release'
|
|
||||||
]
|
]
|
||||||
|
|
||||||
async function makeRequest (requestOptions, parseResponse) {
|
async function makeRequest (requestOptions, parseResponse) {
|
||||||
@@ -38,7 +37,7 @@ async function makeRequest (requestOptions, parseResponse) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function circleCIcall (buildUrl, targetBranch, job, ghRelease) {
|
async function circleCIcall (buildUrl, targetBranch, job, options) {
|
||||||
assert(process.env.CIRCLE_TOKEN, 'CIRCLE_TOKEN not found in environment')
|
assert(process.env.CIRCLE_TOKEN, 'CIRCLE_TOKEN not found in environment')
|
||||||
console.log(`Triggering CircleCI to run build job: ${job} on branch: ${targetBranch} with release flag.`)
|
console.log(`Triggering CircleCI to run build job: ${job} on branch: ${targetBranch} with release flag.`)
|
||||||
let buildRequest = {
|
let buildRequest = {
|
||||||
@@ -47,12 +46,16 @@ async function circleCIcall (buildUrl, targetBranch, job, ghRelease) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ghRelease) {
|
if (options.ghRelease) {
|
||||||
buildRequest.build_parameters.ELECTRON_RELEASE = 1
|
buildRequest.build_parameters.ELECTRON_RELEASE = 1
|
||||||
} else {
|
} else {
|
||||||
buildRequest.build_parameters.RUN_RELEASE_BUILD = 'true'
|
buildRequest.build_parameters.RUN_RELEASE_BUILD = 'true'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.automaticRelease) {
|
||||||
|
buildRequest.build_parameters.AUTO_RELEASE = 'true'
|
||||||
|
}
|
||||||
|
|
||||||
let circleResponse = await makeRequest({
|
let circleResponse = await makeRequest({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: buildUrl,
|
url: buildUrl,
|
||||||
@@ -67,17 +70,21 @@ async function circleCIcall (buildUrl, targetBranch, job, ghRelease) {
|
|||||||
console.log(`Check ${circleResponse.build_url} for status. (${job})`)
|
console.log(`Check ${circleResponse.build_url} for status. (${job})`)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildAppVeyor (targetBranch, ghRelease) {
|
async function buildAppVeyor (targetBranch, options) {
|
||||||
console.log(`Triggering AppVeyor to run build on branch: ${targetBranch} with release flag.`)
|
console.log(`Triggering AppVeyor to run build on branch: ${targetBranch} with release flag.`)
|
||||||
assert(process.env.APPVEYOR_TOKEN, 'APPVEYOR_TOKEN not found in environment')
|
assert(process.env.APPVEYOR_TOKEN, 'APPVEYOR_TOKEN not found in environment')
|
||||||
let environmentVariables = {}
|
let environmentVariables = {}
|
||||||
|
|
||||||
if (ghRelease) {
|
if (options.ghRelease) {
|
||||||
environmentVariables.ELECTRON_RELEASE = 1
|
environmentVariables.ELECTRON_RELEASE = 1
|
||||||
} else {
|
} else {
|
||||||
environmentVariables.RUN_RELEASE_BUILD = 'true'
|
environmentVariables.RUN_RELEASE_BUILD = 'true'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.automaticRelease) {
|
||||||
|
environmentVariables.AUTO_RELEASE = 'true'
|
||||||
|
}
|
||||||
|
|
||||||
const requestOpts = {
|
const requestOpts = {
|
||||||
url: buildAppVeyorURL,
|
url: buildAppVeyorURL,
|
||||||
auth: {
|
auth: {
|
||||||
@@ -101,27 +108,27 @@ async function buildAppVeyor (targetBranch, ghRelease) {
|
|||||||
console.log(`AppVeyor release build request successful. Check build status at ${buildUrl}`)
|
console.log(`AppVeyor release build request successful. Check build status at ${buildUrl}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildCircleCI (targetBranch, ghRelease, job) {
|
function buildCircleCI (targetBranch, options) {
|
||||||
const circleBuildUrl = `https://circleci.com/api/v1.1/project/github/electron/electron/tree/${targetBranch}?circle-token=${process.env.CIRCLE_TOKEN}`
|
const circleBuildUrl = `https://circleci.com/api/v1.1/project/github/electron/electron/tree/${targetBranch}?circle-token=${process.env.CIRCLE_TOKEN}`
|
||||||
if (job) {
|
if (options.job) {
|
||||||
assert(circleCIJobs.includes(job), `Unknown CI job name: ${job}.`)
|
assert(circleCIJobs.includes(options.job), `Unknown CI job name: ${options.job}.`)
|
||||||
circleCIcall(circleBuildUrl, targetBranch, job, ghRelease)
|
circleCIcall(circleBuildUrl, targetBranch, options.job, options)
|
||||||
} else {
|
} else {
|
||||||
circleCIJobs.forEach((job) => circleCIcall(circleBuildUrl, targetBranch, job, ghRelease))
|
circleCIJobs.forEach((job) => circleCIcall(circleBuildUrl, targetBranch, job, options))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildJenkins (targetBranch, ghRelease, job) {
|
async function buildJenkins (targetBranch, options) {
|
||||||
assert(process.env.JENKINS_AUTH_TOKEN, 'JENKINS_AUTH_TOKEN not found in environment')
|
assert(process.env.JENKINS_AUTH_TOKEN, 'JENKINS_AUTH_TOKEN not found in environment')
|
||||||
assert(process.env.JENKINS_BUILD_TOKEN, 'JENKINS_BUILD_TOKEN not found in environment')
|
assert(process.env.JENKINS_BUILD_TOKEN, 'JENKINS_BUILD_TOKEN not found in environment')
|
||||||
let jenkinsCrumb = await getJenkinsCrumb()
|
let jenkinsCrumb = await getJenkinsCrumb()
|
||||||
|
|
||||||
if (job) {
|
if (options.job) {
|
||||||
assert(jenkinsJobs.includes(job), `Unknown CI job name: ${job}.`)
|
assert(jenkinsJobs.includes(options.job), `Unknown CI job name: ${options.job}.`)
|
||||||
callJenkinsBuild(job, jenkinsCrumb, targetBranch, ghRelease)
|
callJenkinsBuild(options.job, jenkinsCrumb, targetBranch, options)
|
||||||
} else {
|
} else {
|
||||||
jenkinsJobs.forEach((job) => {
|
jenkinsJobs.forEach((job) => {
|
||||||
callJenkinsBuild(job, jenkinsCrumb, targetBranch, ghRelease)
|
callJenkinsBuild(job, jenkinsCrumb, targetBranch, options)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,15 +151,18 @@ async function callJenkins (path, requestParameters, requestHeaders) {
|
|||||||
return jenkinsResponse
|
return jenkinsResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
async function callJenkinsBuild (job, jenkinsCrumb, targetBranch, ghRelease) {
|
async function callJenkinsBuild (job, jenkinsCrumb, targetBranch, options) {
|
||||||
console.log(`Triggering Jenkins to run build job: ${job} on branch: ${targetBranch} with release flag.`)
|
console.log(`Triggering Jenkins to run build job: ${job} on branch: ${targetBranch} with release flag.`)
|
||||||
let jenkinsParams = {
|
let jenkinsParams = {
|
||||||
token: process.env.JENKINS_BUILD_TOKEN,
|
token: process.env.JENKINS_BUILD_TOKEN,
|
||||||
BRANCH: targetBranch
|
BRANCH: targetBranch
|
||||||
}
|
}
|
||||||
if (!ghRelease) {
|
if (!options.ghRelease) {
|
||||||
jenkinsParams.RUN_RELEASE_BUILD = 1
|
jenkinsParams.RUN_RELEASE_BUILD = 1
|
||||||
}
|
}
|
||||||
|
if (options.automaticRelease) {
|
||||||
|
jenkinsParams.AUTO_RELEASE = 'true'
|
||||||
|
}
|
||||||
await callJenkins(`job/${job}/buildWithParameters`, jenkinsParams, jenkinsCrumb)
|
await callJenkins(`job/${job}/buildWithParameters`, jenkinsParams, jenkinsCrumb)
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.log(`Error calling Jenkins build`, err)
|
console.log(`Error calling Jenkins build`, err)
|
||||||
@@ -177,33 +187,35 @@ function runRelease (targetBranch, options) {
|
|||||||
if (options.ci) {
|
if (options.ci) {
|
||||||
switch (options.ci) {
|
switch (options.ci) {
|
||||||
case 'CircleCI': {
|
case 'CircleCI': {
|
||||||
buildCircleCI(targetBranch, options.ghRelease, options.job)
|
buildCircleCI(targetBranch, options)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'AppVeyor': {
|
case 'AppVeyor': {
|
||||||
buildAppVeyor(targetBranch, options.ghRelease)
|
buildAppVeyor(targetBranch, options)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'Jenkins': {
|
case 'Jenkins': {
|
||||||
buildJenkins(targetBranch, options.ghRelease, options.job)
|
buildJenkins(targetBranch, options)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
buildCircleCI(targetBranch, options.ghRelease, options.job)
|
buildCircleCI(targetBranch, options)
|
||||||
buildAppVeyor(targetBranch, options.ghRelease)
|
buildAppVeyor(targetBranch, options)
|
||||||
buildJenkins(targetBranch, options.ghRelease, options.job)
|
buildJenkins(targetBranch, options)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = runRelease
|
module.exports = runRelease
|
||||||
|
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
const args = require('minimist')(process.argv.slice(2), { boolean: 'ghRelease' })
|
const args = require('minimist')(process.argv.slice(2), {
|
||||||
|
boolean: ['ghRelease', 'automaticRelease']
|
||||||
|
})
|
||||||
const targetBranch = args._[0]
|
const targetBranch = args._[0]
|
||||||
if (args._.length < 1) {
|
if (args._.length < 1) {
|
||||||
console.log(`Trigger CI to build release builds of electron.
|
console.log(`Trigger CI to build release builds of electron.
|
||||||
Usage: ci-release-build.js [--job=CI_JOB_NAME] [--ci=CircleCI|AppVeyor|Jenkins] [--ghRelease] TARGET_BRANCH
|
Usage: ci-release-build.js [--job=CI_JOB_NAME] [--ci=CircleCI|AppVeyor|Jenkins] [--ghRelease] [--automaticRelease] TARGET_BRANCH
|
||||||
`)
|
`)
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ DIST_DIR = os.path.join(SOURCE_ROOT, 'dist')
|
|||||||
OUT_DIR = os.path.join(SOURCE_ROOT, 'out', 'R')
|
OUT_DIR = os.path.join(SOURCE_ROOT, 'out', 'R')
|
||||||
CHROMIUM_DIR = os.path.join(SOURCE_ROOT, 'vendor', 'download',
|
CHROMIUM_DIR = os.path.join(SOURCE_ROOT, 'vendor', 'download',
|
||||||
'libchromiumcontent', 'static_library')
|
'libchromiumcontent', 'static_library')
|
||||||
|
NATIVE_MKSNAPSHOT_DIR = os.path.join(SOURCE_ROOT, 'vendor', 'native_mksnapshot')
|
||||||
|
|
||||||
PROJECT_NAME = electron_gyp()['project_name%']
|
PROJECT_NAME = electron_gyp()['project_name%']
|
||||||
PRODUCT_NAME = electron_gyp()['product_name%']
|
PRODUCT_NAME = electron_gyp()['product_name%']
|
||||||
@@ -141,7 +142,6 @@ def copy_chrome_binary(binary):
|
|||||||
shutil.copyfile(src, dest)
|
shutil.copyfile(src, dest)
|
||||||
os.chmod(dest, os.stat(dest).st_mode | stat.S_IEXEC)
|
os.chmod(dest, os.stat(dest).st_mode | stat.S_IEXEC)
|
||||||
|
|
||||||
|
|
||||||
def copy_vcruntime_binaries():
|
def copy_vcruntime_binaries():
|
||||||
with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
|
with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
|
||||||
r"SOFTWARE\Microsoft\VisualStudio\14.0\Setup\VC", 0,
|
r"SOFTWARE\Microsoft\VisualStudio\14.0\Setup\VC", 0,
|
||||||
@@ -260,17 +260,39 @@ def create_dist_zip():
|
|||||||
|
|
||||||
|
|
||||||
def create_chrome_binary_zip(binary, version):
|
def create_chrome_binary_zip(binary, version):
|
||||||
dist_name = get_zip_name(binary, version)
|
file_suffix = ''
|
||||||
|
create_native_mksnapshot = False
|
||||||
|
if binary == 'mksnapshot':
|
||||||
|
arch = get_target_arch()
|
||||||
|
if arch.startswith('arm'):
|
||||||
|
# if the arch is arm/arm64 the mksnapshot executable is an x64 binary,
|
||||||
|
# so name it as such.
|
||||||
|
file_suffix = 'x64'
|
||||||
|
create_native_mksnapshot = True
|
||||||
|
dist_name = get_zip_name(binary, version, file_suffix)
|
||||||
zip_file = os.path.join(SOURCE_ROOT, 'dist', dist_name)
|
zip_file = os.path.join(SOURCE_ROOT, 'dist', dist_name)
|
||||||
|
|
||||||
|
files = ['LICENSE', 'LICENSES.chromium.html']
|
||||||
|
if PLATFORM == 'win32':
|
||||||
|
files += [binary + '.exe']
|
||||||
|
else:
|
||||||
|
files += [binary]
|
||||||
|
|
||||||
with scoped_cwd(DIST_DIR):
|
with scoped_cwd(DIST_DIR):
|
||||||
files = ['LICENSE', 'LICENSES.chromium.html']
|
|
||||||
if PLATFORM == 'win32':
|
|
||||||
files += [binary + '.exe']
|
|
||||||
else:
|
|
||||||
files += [binary]
|
|
||||||
make_zip(zip_file, files, [])
|
make_zip(zip_file, files, [])
|
||||||
|
|
||||||
|
if create_native_mksnapshot == True:
|
||||||
|
# Create a zip with the native version of the mksnapshot binary.
|
||||||
|
src = os.path.join(NATIVE_MKSNAPSHOT_DIR, binary)
|
||||||
|
dest = os.path.join(DIST_DIR, binary)
|
||||||
|
# Copy file and keep the executable bit.
|
||||||
|
shutil.copyfile(src, dest)
|
||||||
|
os.chmod(dest, os.stat(dest).st_mode | stat.S_IEXEC)
|
||||||
|
|
||||||
|
dist_name = get_zip_name(binary, version)
|
||||||
|
zip_file = os.path.join(SOURCE_ROOT, 'dist', dist_name)
|
||||||
|
with scoped_cwd(DIST_DIR):
|
||||||
|
make_zip(zip_file, files, [])
|
||||||
|
|
||||||
def create_ffmpeg_zip():
|
def create_ffmpeg_zip():
|
||||||
dist_name = get_zip_name('ffmpeg', ELECTRON_VERSION)
|
dist_name = get_zip_name('ffmpeg', ELECTRON_VERSION)
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user