Compare commits

...

57 Commits

Author SHA1 Message Date
Electron Bot
c5c0a7abc5 Bump v6.0.0-beta.4 2019-05-21 11:28:46 -07:00
trop[bot]
84b762f0b3 fix: reverse saveDialog cancellation bool (#18383) 2019-05-21 13:09:35 -05:00
trop[bot]
043838f9b6 fix: set window to null when no window is passed (#18381)
Fixes #18236.

Our options parsing for dialogs correctly set options if no window was passed, but then did not correctly set the window back to null and it was then left as an object equal to options. This caused a crash when passed to native code as there is no valid circumstance where the window would be an object.
2019-05-21 08:34:40 -07:00
trop[bot]
a824e92628 fix: 'page-title-updated' event forwarding + documentation (#18319) 2019-05-21 16:21:50 +09:00
Samuel Attard
1843411e79 fix: update the FileSelectHelper to support the new promise API (#18288) (#18341)
* fix: update the FileSelectHelper to support the new promise API

Fixes #18254

So it turns out we've successfully introduced a way to write
non-typesafe C++.

This fixes two things:
* Uses the object the promise resolves
* Ensures we attach the Then handler before moving the promise

* fix: also fix misuse of Promise::Then in the download manager
2019-05-21 15:52:48 +09:00
trop[bot]
da76c4d7c5 fix: leave space for autohide taskbar for frameless maximized window (#18373) 2019-05-21 15:35:39 +09:00
trop[bot]
4468b86a81 feat: allow setting working directory in app.setUserTasks() / app.setJumpList() (#18291) 2019-05-16 09:13:30 -04:00
Electron Bot
8acbb9a3ad Bump v6.0.0-beta.3 2019-05-14 12:10:18 -07:00
trop[bot]
f5e28bc999 fix: default enable_negotiate_port to false (#18285) 2019-05-14 12:51:41 -05:00
trop[bot]
b45ad7f74e fix: destroy tray on current tick (#18218)
* fix: destroy tray on current tick

* test: add tray destroy specs

* use more idiomatic destructor syntax
2019-05-09 14:42:34 -04:00
trop[bot]
9e9238454e build: linux needs java on GN (#18217) 2019-05-09 11:05:33 -04:00
Electron Bot
3f2aba69ee Bump v6.0.0-beta.2 2019-05-07 19:51:34 -07:00
Shelley Vohr
371e804c6b Revert "Bump v6.0.0-beta.2"
This reverts commit c54b67300e.
2019-05-07 19:49:30 -07:00
trop[bot]
6131e89aa9 build: remove deprecated octokit auth calls (#18206) 2019-05-07 19:48:34 -07:00
Electron Bot
c54b67300e Bump v6.0.0-beta.2 2019-05-07 15:41:03 -07:00
John Kleinschmidt
e847f048d7 build: only delete .git directory on Mac builds (#18200) 2019-05-07 15:39:43 -07:00
Shelley Vohr
b5955fa663 Revert "Bump v6.0.0-beta.2"
This reverts commit a648e6c06d.
2019-05-07 15:00:14 -07:00
Electron Bot
a648e6c06d Bump v6.0.0-beta.2 2019-05-07 12:43:19 -07:00
Nitish Sakhawalkar
e6216da031 chore: Add patch to partially revert chromium crashpad change (#18198)
This adds a patch to support functionality that we were using but chromium changed it. Electron uses breakpad on windows, chromium uses crashpad (which is newer). So this patch is needed until we update electron to use crashpad for windows.
2019-05-07 12:35:10 -07:00
Jeremy Apthorp
5b7bd56367 chore: deprecate the 'options' argument to clearAuthCache (#18131)
The network service APIs do not support the fine-grained clearing of the auth cache. In preparation for switching to the network service in 7.x, log a warning that the options argument is deprecated. Ref #17970.

This might not be quite right as we could also potentially expose the new options that are available: namely, start and end time. #17970 does not expose those options, but it would in theory be possible to support them with the existing network service APIs. The current options object does not offer time-based cache clearing.
2019-05-07 09:55:15 -07:00
trop[bot]
01b1c0ca8b fix: crash on systemPreferences.getAccentColor() (#18195) 2019-05-07 09:51:36 -07:00
Shelley Vohr
05ced19f9f chore: deprecate shell.openExternalSync (#18179) 2019-05-07 08:19:52 -07:00
trop[bot]
b8ef669905 refactor: allow embedder overriding of internal FS calls (#17906) (#18192) 2019-05-07 08:00:40 -07:00
trop[bot]
212ce1840f docs: clarify clipboard type options (#18175) 2019-05-06 09:29:42 -07:00
trop[bot]
e090fa94d0 fix: do not mark navigations interupted with same-document navigations as aborted (#18143)
* fix: do not mark navigations interupted with same-document navigations as aborted

* spec: add tests for the loadURL promise
2019-05-03 23:08:57 -07:00
trop[bot]
a431f1a663 fix: correctly parse default_app path on windows (#18102) 2019-05-03 08:16:57 -07:00
trop[bot]
ea6815c0f7 fix: fs.promises does not work with asar paths (#18114) 2019-05-02 22:34:19 -07:00
Electron Bot
40e05eef23 chore: bump chromium to 76.0.3783.1 (6-0-x) (#18116) 2019-05-02 16:31:29 -07:00
trop[bot]
a790e702f5 build: free up space before running macos ci (#18099)
* build: free up space before running macos ci

* build: also delete 14GB of src/.git for bonus space
2019-05-01 13:48:25 -07:00
trop[bot]
be16a195fb fix: ensure the inspector agent is shutdown before cleaning up the node env (#18077)
* fix: ensure the inspector agent is shutdown before cleaning up the node env

* spec: add tests to ensure clean shutdown with connected inspector agent

* Update node_debugger.cc
2019-05-01 13:47:22 -07:00
trop[bot]
2f10c0fd6d docs: fix webContents 'new-window' event handler sample (#18098) 2019-05-01 13:44:47 -07:00
trop[bot]
276c07d3d7 docs: remove incorrectly added let for the win variable (#18095) 2019-05-01 12:41:59 -07:00
Samuel Attard
57f7c8b6b9 build: ensure consistent lock files across multiple machines (#17955) (#18071)
* build: ensure consistent package-lock across multiple machines

* build: fix linting errors and use npm ci instead of npm install

* build: use a yarn.lock and yarn instead of package-lock and npm

* chore: replace package-lock.json files with yarn.lock

* chore: replace last instance of `npm install`
2019-05-01 11:11:52 -07:00
trop[bot]
2ce22ba0e9 fix: explicitly focus window on win.show() (#18081) 2019-05-01 10:44:30 -07:00
Electron Bot
7186c62a27 Bump v6.0.0-beta.1 2019-04-30 14:46:01 -07:00
Electron Bot
bf88a13f1e Revert "Bump v6.0.0-beta.1"
This reverts commit 6e9c540baf.
2019-04-30 13:16:51 -07:00
Electron Bot
6e9c540baf Bump v6.0.0-beta.1 2019-04-30 13:11:22 -07:00
Electron Bot
24b14d55ef Revert "Bump v6.0.0-beta.1"
This reverts commit 3b8eb6c061.
2019-04-30 13:09:29 -07:00
Electron Bot
3b8eb6c061 Bump v6.0.0-beta.1 2019-04-30 13:04:14 -07:00
Electron Bot
f9b7f6389e Revert "Bump v6.0.0-beta.1"
This reverts commit 8f30faacf8.
2019-04-30 13:02:36 -07:00
Electron Bot
8f30faacf8 Bump v6.0.0-beta.1 2019-04-30 12:59:08 -07:00
trop[bot]
f631890237 chore: disable Vulkan validation layers (#18062) 2019-04-30 12:49:43 -07:00
trop[bot]
8982889a8d build: fix issues for stable release we fixed in 5-0-x (#18068)
* build: fix release notes generation

* build: fix bump-version script for stable releases
2019-04-30 12:49:25 -07:00
trop[bot]
cd3539aaf8 refactor: rewire the desktop capturer API to remove race conditions (#18042)
We now create a new instance of atom::api::DesktopCapturer for every
request instead of weirdly re-using the same instance and queuing
requests.  This means there is now a 1:1 relationship between request
and DesktopCapturer so there isn't a race condition between the observer
for one request calling back before the observer of another.  This is an
issue ever since the backing APIs moved to worker threads.

This also does a few things to ensure memory management
* Only ever listen to one event per-request, after that we wipe the emit
function to ignore all future events
* Ensures we clean up the window_capturer_, screen_capturer_ and
captured_sources_ in native land once the request is over.

This _in theory_ fixes a flake we've been seeing on CI where we try to
resolve the promise for a request that no longerr exists.
2019-04-30 07:07:56 -07:00
Samuel Attard
275e277721 feat: upgrade to Node 12 (#17838) (#18044)
* fix: add boringssl backport to support node upgrade

* fix: Update node_includes.h, add DCHECK macros

* fix: Update node Debug Options parser usage

* fix: Fix asar setup

* fix: using v8Util in isolated context

* fix: make "process" available in preload scripts

* fix: use proper options parser and remove setting of _breakFirstLine

_breakFirstLine was being set on the process, but that has changed in node 12 and so is no longer needed. Node will handle it properly when --inspect-brk is provided

* chore: update node dep sha

* fix: process.binding => _linkedBinding in sandboxed isolated preload

* fix: make original-fs work with streams

* build: override node module version

* fix: use _linkedBinding in content_script/init.js

* chore: update node ref in DEPS

* build: node_module_version should be 73
2019-04-29 15:52:31 -07:00
trop[bot]
283b1241d5 docs: Correct doc for registerFileProtocol (#18050)
In the registerFileProtocol docs the "headers" argument of the callback was described as being a list.
In fact is has to be an Object mapping header-entries to values. This can be seen in Line 326 of `/spec/api-protocol-spec.js` [fe618631f1/spec/api-protocol-spec.js (L326)].
2019-04-29 15:30:34 -07:00
trop[bot]
7bdea26085 docs: update nodeIntegration section for new defaults (#18047)
* docs: update nodeIntegration section for new defaults

* docs: update docs/tutorial/first-app.md

* Update docs/tutorial/security.md

Co-Authored-By: miniak <milan.burda@gmail.com>
2019-04-29 15:18:23 -07:00
Samuel Attard
f1fa589779 chore: upgrade chromium to 76 (#17921) 2019-04-29 12:48:28 -07:00
trop[bot]
7226ad1eba fix: crash when failed to get devices in desktopCapturer (#17973)
* fix: crash when failed to get devices in desktopCapturer

* return after emit
2019-04-26 08:05:12 -07:00
trop[bot]
d92743f0f3 docs: remove outdated refs to protocol.registerStandardSchemes (#17977) 2019-04-26 08:05:03 -07:00
trop[bot]
2c309efef4 docs: add azure vm spinup tutorial (#17975) 2019-04-25 15:49:21 -07:00
trop[bot]
0b418315a3 docs: clean up the native module tutorial (#17951) 2019-04-24 11:25:34 -07:00
trop[bot]
2f474867c7 fix: permission handler regression in default app (#17950) 2019-04-24 11:25:17 -07:00
trop[bot]
0b5acd9569 refactor: add missing constants for options (#17919) 2019-04-24 10:16:53 -07:00
Jeremy Apthorp
3419c3c730 chore: bump chromium to 75.0.3770.3 (#17883) 2019-04-23 14:29:16 -07:00
trop[bot]
754200f1b1 fix: crash when run from SMB network share (#17909) 2019-04-23 09:03:51 -07:00
Samuel Attard
37f4bd4dd0 build: reset version to 6.0.0-beta.0 in prep for 6.0.0-beta.1 2019-04-19 15:35:46 -07:00
237 changed files with 14261 additions and 16611 deletions

View File

@@ -176,6 +176,22 @@ step-restore-brew-cache: &step-restore-brew-cache
keys: keys:
- v1-brew-cache-{{ arch }} - v1-brew-cache-{{ arch }}
step-get-more-space-on-mac: &step-get-more-space-on-mac
run:
name: Free up space on MacOS
command: |
if [ "`uname`" == "Darwin" ]; then
sudo rm -rf /Library/Developer/CoreSimulator
fi
step-delete-git-directories: &step-delete-git-directories
run:
name: Delete src/.git directory on MacOS to free space
command: |
if [ "`uname`" == "Darwin" ]; then
sudo rm -rf src/.git
fi
# On macOS the npm install command during gclient sync was run on a linux # On macOS the npm install command during gclient sync was run on a linux
# machine and therefore installed a slightly different set of dependencies # machine and therefore installed a slightly different set of dependencies
# Notably "fsevents" is a macOS only dependency, we rerun npm install once # Notably "fsevents" is a macOS only dependency, we rerun npm install once
@@ -535,6 +551,7 @@ steps-checkout: &steps-checkout
- *step-depot-tools-get - *step-depot-tools-get
- *step-depot-tools-add-to-path - *step-depot-tools-add-to-path
- *step-restore-brew-cache - *step-restore-brew-cache
- *step-get-more-space-on-mac
- *step-install-gnutar-on-mac - *step-install-gnutar-on-mac
- restore_cache: - restore_cache:
@@ -651,9 +668,11 @@ steps-electron-build-for-publish: &steps-electron-build-for-publish
- *step-depot-tools-get - *step-depot-tools-get
- *step-depot-tools-add-to-path - *step-depot-tools-add-to-path
- *step-restore-brew-cache - *step-restore-brew-cache
- *step-get-more-space-on-mac
- *step-gclient-sync - *step-gclient-sync
- *step-setup-env-for-build - *step-setup-env-for-build
- *step-gn-gen-default - *step-gn-gen-default
- *step-delete-git-directories
# Electron app # Electron app
- *step-electron-build - *step-electron-build

View File

@@ -16,7 +16,8 @@
}], }],
"prefer-const": ["error", { "prefer-const": ["error", {
"destructuring": "all" "destructuring": "all"
}] }],
"node/no-deprecated-api": 0
}, },
"parserOptions": { "parserOptions": {
"ecmaVersion": 6, "ecmaVersion": 6,

2
.gitignore vendored
View File

@@ -37,7 +37,7 @@
/vendor/pyyaml /vendor/pyyaml
node_modules/ node_modules/
SHASUMS256.txt SHASUMS256.txt
**/yarn.lock **/package-lock.json
compile_commands.json compile_commands.json
.envrc .envrc

View File

@@ -64,7 +64,7 @@ config("branding") {
npm_action("build_electron_definitions") { npm_action("build_electron_definitions") {
script = "gn-typescript-definitions" script = "gn-typescript-definitions"
args = [ rebase_path("$target_gen_dir/tsc/typings/electron.d.ts") ] args = [ rebase_path("$target_gen_dir/tsc/typings/electron.d.ts") ]
inputs = auto_filenames.api_docs + [ "package-lock.json" ] inputs = auto_filenames.api_docs + [ "yarn.lock" ]
outputs = [ outputs = [
"$target_gen_dir/tsc/typings/electron.d.ts", "$target_gen_dir/tsc/typings/electron.d.ts",
@@ -547,6 +547,7 @@ static_library("electron_lib") {
deps += [ deps += [
"//third_party/crashpad/crashpad/client", "//third_party/crashpad/crashpad/client",
"//ui/accelerated_widget_mac", "//ui/accelerated_widget_mac",
"//ui/views_bridge_mac",
] ]
sources += [ sources += [
"atom/browser/ui/views/autofill_popup_view.cc", "atom/browser/ui/views/autofill_popup_view.cc",
@@ -1067,6 +1068,7 @@ template("dist_zip") {
"deps", "deps",
"data_deps", "data_deps",
"data", "data",
"testonly",
]) ])
write_runtime_deps = _runtime_deps_file write_runtime_deps = _runtime_deps_file
} }
@@ -1076,7 +1078,11 @@ template("dist_zip") {
deps = [ deps = [
":$_runtime_deps_target", ":$_runtime_deps_target",
] ]
forward_variables_from(invoker, [ "outputs" ]) forward_variables_from(invoker,
[
"outputs",
"testonly",
])
args = rebase_path(outputs + [ _runtime_deps_file ], root_build_dir) + [ args = rebase_path(outputs + [ _runtime_deps_file ], root_build_dir) + [
target_cpu, target_cpu,
target_os, target_os,
@@ -1144,6 +1150,7 @@ dist_zip("electron_ffmpeg_zip") {
} }
dist_zip("electron_chromedriver_zip") { dist_zip("electron_chromedriver_zip") {
testonly = true
data_deps = [ data_deps = [
"//chrome/test/chromedriver", "//chrome/test/chromedriver",
":licenses", ":licenses",

9
DEPS
View File

@@ -10,9 +10,9 @@ gclient_gn_args = [
vars = { vars = {
'chromium_version': 'chromium_version':
'75.0.3740.3', '76.0.3783.1',
'node_version': 'node_version':
'2dc0f8811b2b295c08d797b8a11b030234c98502', 'a86a4a160dc520c61a602c949a32a1bc4c0fc633',
'boto_version': 'f7574aa6cc2c819430c1f05e9a1a1a666ef8169b', 'boto_version': 'f7574aa6cc2c819430c1f05e9a1a1a666ef8169b',
'pyyaml_version': '3.12', 'pyyaml_version': '3.12',
@@ -24,6 +24,9 @@ vars = {
'requests_git': 'https://github.com/kennethreitz', 'requests_git': 'https://github.com/kennethreitz',
'yaml_git': 'https://github.com/yaml', 'yaml_git': 'https://github.com/yaml',
# KEEP IN SYNC WITH spec-runner FILE
'yarn_version': '1.15.2',
# To be able to build clean Chromium from sources. # To be able to build clean Chromium from sources.
'apply_patches': True, 'apply_patches': True,
@@ -107,7 +110,7 @@ hooks = [
'action': [ 'action': [
'python', 'python',
'-c', '-c',
'import os, subprocess; os.chdir(os.path.join("src", "electron")); subprocess.check_call(["python", "script/lib/npm.py", "install"]);', 'import os, subprocess; os.chdir(os.path.join("src", "electron")); subprocess.check_call(["python", "script/lib/npx.py", "yarn@' + (Var("yarn_version")) + '", "install", "--frozen-lockfile"]);',
], ],
}, },
{ {

View File

@@ -1 +1 @@
6.0.0-nightly.20190404 6.0.0-beta.4

View File

@@ -25,11 +25,12 @@
version: 1.0.{build} version: 1.0.{build}
build_cloud: libcc-20 build_cloud: libcc-20
image: libcc-20-vs2017-15.7.4 image: libcc-20-vs2017-15.9
environment: environment:
GIT_CACHE_PATH: C:\Users\electron\libcc_cache GIT_CACHE_PATH: C:\Users\electron\libcc_cache
DISABLE_CRASH_REPORTER_TESTS: true DISABLE_CRASH_REPORTER_TESTS: true
ELECTRON_OUT_DIR: Default ELECTRON_OUT_DIR: Default
ELECTRON_ENABLE_STACK_DUMPING: 1
build_script: build_script:
- ps: >- - ps: >-
if(($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME -split "/")[0] -eq ($env:APPVEYOR_REPO_NAME -split "/")[0]) { if(($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME -split "/")[0] -eq ($env:APPVEYOR_REPO_NAME -split "/")[0]) {
@@ -38,7 +39,7 @@ build_script:
- echo "Building $env:GN_CONFIG build" - echo "Building $env:GN_CONFIG build"
- git config --global core.longpaths true - git config --global core.longpaths true
- cd .. - cd ..
- md src - ps: if (Test-Path src\electron) { Remove-Item src\electron -Recurse }
- ps: Move-Item $env:APPVEYOR_BUILD_FOLDER -Destination src\electron - ps: Move-Item $env:APPVEYOR_BUILD_FOLDER -Destination src\electron
- ps: $env:CHROMIUM_BUILDTOOLS_PATH="$pwd\src\buildtools" - ps: $env:CHROMIUM_BUILDTOOLS_PATH="$pwd\src\buildtools"
- ps: $env:SCCACHE_PATH="$pwd\src\electron\external_binaries\sccache.exe" - ps: $env:SCCACHE_PATH="$pwd\src\electron\external_binaries\sccache.exe"
@@ -52,7 +53,7 @@ build_script:
--unmanaged --unmanaged
%GCLIENT_EXTRA_ARGS% %GCLIENT_EXTRA_ARGS%
"https://github.com/electron/electron" "https://github.com/electron/electron"
- gclient sync --with_branch_heads --with_tags - gclient sync --with_branch_heads --with_tags --reset
- cd src - cd src
- ps: $env:BUILD_CONFIG_PATH="//electron/build/args/%GN_CONFIG%.gn" - ps: $env:BUILD_CONFIG_PATH="//electron/build/args/%GN_CONFIG%.gn"
- gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") %GN_EXTRA_ARGS%" - gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") %GN_EXTRA_ARGS%"

View File

@@ -18,7 +18,7 @@
#include "atom/common/node_includes.h" #include "atom/common/node_includes.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/task/task_scheduler/task_scheduler.h" #include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "gin/array_buffer.h" #include "gin/array_buffer.h"
#include "gin/public/isolate_holder.h" #include "gin/public/isolate_holder.h"
@@ -48,7 +48,7 @@ int NodeMain(int argc, char* argv[]) {
gin::V8Initializer::LoadV8Natives(); gin::V8Initializer::LoadV8Natives();
// V8 requires a task scheduler apparently // V8 requires a task scheduler apparently
base::TaskScheduler::CreateAndStartWithDefaultParams("Electron"); base::ThreadPool::CreateAndStartWithDefaultParams("Electron");
// Initialize gin::IsolateHolder. // Initialize gin::IsolateHolder.
JavascriptEnvironment gin_env(loop); JavascriptEnvironment gin_env(loop);
@@ -101,6 +101,7 @@ int NodeMain(int argc, char* argv[]) {
} }
} while (more == true); } while (more == true);
node_debugger.Stop();
exit_code = node::EmitExit(env); exit_code = node::EmitExit(env);
node::RunAtExit(env); node::RunAtExit(env);
gin_env.platform()->DrainTasks(env->isolate()); gin_env.platform()->DrainTasks(env->isolate());
@@ -112,10 +113,10 @@ int NodeMain(int argc, char* argv[]) {
// According to "src/gin/shell/gin_main.cc": // According to "src/gin/shell/gin_main.cc":
// //
// gin::IsolateHolder waits for tasks running in TaskScheduler in its // gin::IsolateHolder waits for tasks running in ThreadPool in its
// destructor and thus must be destroyed before TaskScheduler starts skipping // destructor and thus must be destroyed before ThreadPool starts skipping
// CONTINUE_ON_SHUTDOWN tasks. // CONTINUE_ON_SHUTDOWN tasks.
base::TaskScheduler::GetInstance()->Shutdown(); base::ThreadPool::GetInstance()->Shutdown();
v8::V8::Dispose(); v8::V8::Dispose();

View File

@@ -84,6 +84,7 @@ struct Converter<Browser::UserTask> {
return false; return false;
dict.Get("arguments", &(out->arguments)); dict.Get("arguments", &(out->arguments));
dict.Get("description", &(out->description)); dict.Get("description", &(out->description));
dict.Get("workingDirectory", &(out->working_dir));
return true; return true;
} }
}; };
@@ -157,6 +158,7 @@ struct Converter<JumpListItem> {
dict.Get("args", &(out->arguments)); dict.Get("args", &(out->arguments));
dict.Get("description", &(out->description)); dict.Get("description", &(out->description));
dict.Get("workingDirectory", &(out->working_dir));
return true; return true;
case JumpListItem::Type::SEPARATOR: case JumpListItem::Type::SEPARATOR:
@@ -183,6 +185,7 @@ struct Converter<JumpListItem> {
dict.Set("iconPath", val.icon_path); dict.Set("iconPath", val.icon_path);
dict.Set("iconIndex", val.icon_index); dict.Set("iconIndex", val.icon_index);
dict.Set("description", val.description); dict.Set("description", val.description);
dict.Set("workingDirectory", val.working_dir);
break; break;
case JumpListItem::Type::SEPARATOR: case JumpListItem::Type::SEPARATOR:
@@ -529,9 +532,9 @@ int ImportIntoCertStore(CertificateManagerModel* model,
} }
#endif #endif
void OnIconDataAvailable(util::Promise promise, gfx::Image* icon) { void OnIconDataAvailable(util::Promise promise, gfx::Image icon) {
if (icon && !icon->IsEmpty()) { if (!icon.IsEmpty()) {
promise.Resolve(*icon); promise.Resolve(icon);
} else { } else {
promise.RejectWithErrorMessage("Failed to get file icon."); promise.RejectWithErrorMessage("Failed to get file icon.");
} }
@@ -672,7 +675,7 @@ void App::OnLogin(scoped_refptr<LoginHandler> login_handler,
if (web_contents) { if (web_contents) {
prevent_default = Emit( prevent_default = Emit(
"login", WebContents::FromOrCreate(isolate(), web_contents), "login", WebContents::FromOrCreate(isolate(), web_contents),
request_details, login_handler->auth_info(), request_details, *login_handler->auth_info(),
base::Bind(&PassLoginInformation, base::RetainedRef(login_handler))); base::Bind(&PassLoginInformation, base::RetainedRef(login_handler)));
} }
@@ -1056,7 +1059,7 @@ Browser::LoginItemSettings App::GetLoginItemSettings(mate::Arguments* args) {
#if defined(USE_NSS_CERTS) #if defined(USE_NSS_CERTS)
void App::ImportCertificate(const base::DictionaryValue& options, void App::ImportCertificate(const base::DictionaryValue& options,
const net::CompletionCallback& callback) { net::CompletionRepeatingCallback callback) {
auto browser_context = AtomBrowserContext::From("", false); auto browser_context = AtomBrowserContext::From("", false);
if (!certificate_manager_model_) { if (!certificate_manager_model_) {
auto copy = base::DictionaryValue::From( auto copy = base::DictionaryValue::From(
@@ -1069,17 +1072,17 @@ void App::ImportCertificate(const base::DictionaryValue& options,
} }
int rv = ImportIntoCertStore(certificate_manager_model_.get(), options); int rv = ImportIntoCertStore(certificate_manager_model_.get(), options);
callback.Run(rv); std::move(callback).Run(rv);
} }
void App::OnCertificateManagerModelCreated( void App::OnCertificateManagerModelCreated(
std::unique_ptr<base::DictionaryValue> options, std::unique_ptr<base::DictionaryValue> options,
const net::CompletionCallback& callback, net::CompletionOnceCallback callback,
std::unique_ptr<CertificateManagerModel> model) { std::unique_ptr<CertificateManagerModel> model) {
certificate_manager_model_ = std::move(model); certificate_manager_model_ = std::move(model);
int rv = int rv =
ImportIntoCertStore(certificate_manager_model_.get(), *(options.get())); ImportIntoCertStore(certificate_manager_model_.get(), *(options.get()));
callback.Run(rv); std::move(callback).Run(rv);
} }
#endif #endif

View File

@@ -27,7 +27,8 @@
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "native_mate/dictionary.h" #include "native_mate/dictionary.h"
#include "native_mate/handle.h" #include "native_mate/handle.h"
#include "net/base/completion_callback.h" #include "net/base/completion_once_callback.h"
#include "net/base/completion_repeating_callback.h"
#include "net/ssl/client_cert_identity.h" #include "net/ssl/client_cert_identity.h"
#if defined(USE_NSS_CERTS) #if defined(USE_NSS_CERTS)
@@ -78,7 +79,7 @@ class App : public AtomBrowserClient::Delegate,
#if defined(USE_NSS_CERTS) #if defined(USE_NSS_CERTS)
void OnCertificateManagerModelCreated( void OnCertificateManagerModelCreated(
std::unique_ptr<base::DictionaryValue> options, std::unique_ptr<base::DictionaryValue> options,
const net::CompletionCallback& callback, net::CompletionOnceCallback callback,
std::unique_ptr<CertificateManagerModel> model); std::unique_ptr<CertificateManagerModel> model);
#endif #endif
@@ -199,7 +200,7 @@ class App : public AtomBrowserClient::Delegate,
Browser::LoginItemSettings GetLoginItemSettings(mate::Arguments* args); Browser::LoginItemSettings GetLoginItemSettings(mate::Arguments* args);
#if defined(USE_NSS_CERTS) #if defined(USE_NSS_CERTS)
void ImportCertificate(const base::DictionaryValue& options, void ImportCertificate(const base::DictionaryValue& options,
const net::CompletionCallback& callback); net::CompletionRepeatingCallback callback);
#endif #endif
v8::Local<v8::Promise> GetFileIcon(const base::FilePath& path, v8::Local<v8::Promise> GetFileIcon(const base::FilePath& path,
mate::Arguments* args); mate::Arguments* args);

View File

@@ -64,11 +64,17 @@ void AutoUpdater::OnError(const std::string& message,
auto errorObject = auto errorObject =
error->ToObject(isolate()->GetCurrentContext()).ToLocalChecked(); error->ToObject(isolate()->GetCurrentContext()).ToLocalChecked();
auto context = isolate()->GetCurrentContext();
// add two new params for better error handling // add two new params for better error handling
errorObject->Set(mate::StringToV8(isolate(), "code"), errorObject
v8::Integer::New(isolate(), code)); ->Set(context, mate::StringToV8(isolate(), "code"),
errorObject->Set(mate::StringToV8(isolate(), "domain"), v8::Integer::New(isolate(), code))
mate::StringToV8(isolate(), domain)); .Check();
errorObject
->Set(context, mate::StringToV8(isolate(), "domain"),
mate::StringToV8(isolate(), domain))
.Check();
mate::EmitEvent(isolate(), GetWrapper(), "error", errorObject, message); mate::EmitEvent(isolate(), GetWrapper(), "error", errorObject, message);
} }

View File

@@ -283,7 +283,7 @@ void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
net::CanonicalCookie::CreateSanitizedCookie( net::CanonicalCookie::CreateSanitizedCookie(
url, name, value, domain, path, creation_time, expiration_time, url, name, value, domain, path, creation_time, expiration_time,
last_access_time, secure, http_only, last_access_time, secure, http_only,
net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT)); net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_DEFAULT));
auto completion_callback = base::BindOnce(OnSetCookie, std::move(promise)); auto completion_callback = base::BindOnce(OnSetCookie, std::move(promise));
if (!canonical_cookie || !canonical_cookie->IsCanonical()) { if (!canonical_cookie || !canonical_cookie->IsCanonical()) {
std::move(completion_callback) std::move(completion_callback)

View File

@@ -165,8 +165,12 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
std::vector<std::string> device_names; std::vector<std::string> device_names;
// Crucially, this list of device names will be in the same order as // Crucially, this list of device names will be in the same order as
// |media_list_sources|. // |media_list_sources|.
webrtc::DxgiDuplicatorController::Instance()->GetDeviceNames( if (!webrtc::DxgiDuplicatorController::Instance()->GetDeviceNames(
&device_names); &device_names)) {
Emit("error", "Failed to get sources.");
return;
}
int device_name_index = 0; int device_name_index = 0;
for (auto& source : screen_sources) { for (auto& source : screen_sources) {
const auto& device_name = device_names[device_name_index++]; const auto& device_name = device_names[device_name_index++];
@@ -176,13 +180,13 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
const int64_t device_id = const int64_t device_id =
display::win::DisplayInfo::DeviceIdFromDeviceName( display::win::DisplayInfo::DeviceIdFromDeviceName(
wide_device_name.c_str()); wide_device_name.c_str());
source.display_id = base::Int64ToString(device_id); source.display_id = base::NumberToString(device_id);
} }
} }
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
// On Mac, the IDs across the APIs match. // On Mac, the IDs across the APIs match.
for (auto& source : screen_sources) { for (auto& source : screen_sources) {
source.display_id = base::Int64ToString(source.media_list_source.id.id); source.display_id = base::NumberToString(source.media_list_source.id.id);
} }
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
// TODO(ajmacd): Add Linux support. The IDs across APIs differ but Chrome // TODO(ajmacd): Add Linux support. The IDs across APIs differ but Chrome
@@ -222,7 +226,7 @@ void Initialize(v8::Local<v8::Object> exports,
void* priv) { void* priv) {
v8::Isolate* isolate = context->GetIsolate(); v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports); mate::Dictionary dict(isolate, exports);
dict.Set("desktopCapturer", atom::api::DesktopCapturer::Create(isolate)); dict.SetMethod("createDesktopCapturer", &atom::api::DesktopCapturer::Create);
} }
} // namespace } // namespace

View File

@@ -52,7 +52,7 @@ void MenuViews::PopupAt(TopLevelWindow* window,
std::make_unique<MenuRunner>(model(), flags, close_callback); std::make_unique<MenuRunner>(model(), flags, close_callback);
menu_runners_[window_id]->RunMenuAt( menu_runners_[window_id]->RunMenuAt(
native_window->widget(), NULL, gfx::Rect(location, gfx::Size()), native_window->widget(), NULL, gfx::Rect(location, gfx::Size()),
views::MENU_ANCHOR_TOPLEFT, ui::MENU_SOURCE_MOUSE); views::MenuAnchorPosition::kTopLeft, ui::MENU_SOURCE_MOUSE);
} }
void MenuViews::ClosePopupAt(int32_t window_id) { void MenuViews::ClosePopupAt(int32_t window_id) {

View File

@@ -48,6 +48,7 @@
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
#include "native_mate/dictionary.h" #include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h" #include "native_mate/object_template_builder.h"
#include "net/base/completion_repeating_callback.h"
#include "net/base/load_flags.h" #include "net/base/load_flags.h"
#include "net/disk_cache/disk_cache.h" #include "net/disk_cache/disk_cache.h"
#include "net/dns/host_cache.h" // nogncheck #include "net/dns/host_cache.h" // nogncheck
@@ -268,7 +269,7 @@ void DoCacheActionInIO(
// Call GetBackend and make the backend's ptr accessable in OnGetBackend. // Call GetBackend and make the backend's ptr accessable in OnGetBackend.
using BackendPtr = disk_cache::Backend*; using BackendPtr = disk_cache::Backend*;
auto** backend_ptr = new BackendPtr(nullptr); auto** backend_ptr = new BackendPtr(nullptr);
net::CompletionCallback on_get_backend = net::CompletionRepeatingCallback on_get_backend =
base::Bind(&OnGetBackend, base::Owned(backend_ptr), action, base::Bind(&OnGetBackend, base::Owned(backend_ptr), action,
util::CopyablePromise(promise)); util::CopyablePromise(promise));
int rv = http_cache->GetBackend(backend_ptr, on_get_backend); int rv = http_cache->GetBackend(backend_ptr, on_get_backend);
@@ -365,8 +366,9 @@ void DestroyGlobalHandle(v8::Isolate* isolate,
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
if (!global_handle.IsEmpty()) { if (!global_handle.IsEmpty()) {
v8::Local<v8::Value> local_handle = global_handle.Get(isolate); v8::Local<v8::Value> local_handle = global_handle.Get(isolate);
if (local_handle->IsObject()) { v8::Local<v8::Object> object;
v8::Local<v8::Object> object = local_handle->ToObject(isolate); if (local_handle->IsObject() &&
local_handle->ToObject(isolate->GetCurrentContext()).ToLocal(&object)) {
void* ptr = object->GetAlignedPointerFromInternalField(0); void* ptr = object->GetAlignedPointerFromInternalField(0);
if (!ptr) if (!ptr)
return; return;

View File

@@ -15,7 +15,6 @@
#include "base/values.h" #include "base/values.h"
#include "content/public/browser/download_manager.h" #include "content/public/browser/download_manager.h"
#include "native_mate/handle.h" #include "native_mate/handle.h"
#include "net/base/completion_callback.h"
class GURL; class GURL;

View File

@@ -13,6 +13,7 @@
#include "atom/browser/mac/atom_application.h" #include "atom/browser/mac/atom_application.h"
#include "atom/browser/mac/dict_util.h" #include "atom/browser/mac/dict_util.h"
#include "atom/browser/ui/cocoa/NSColor+Hex.h"
#include "atom/common/native_mate_converters/gurl_converter.h" #include "atom/common/native_mate_converters/gurl_converter.h"
#include "atom/common/native_mate_converters/value_converter.h" #include "atom/common/native_mate_converters/value_converter.h"
#include "base/mac/scoped_cftyperef.h" #include "base/mac/scoped_cftyperef.h"
@@ -111,21 +112,6 @@ std::string ConvertAuthorizationStatus(AVAuthorizationStatusMac status) {
} }
} }
// Convert color to RGBA value like "aabbccdd"
std::string ToRGBA(NSColor* color) {
return base::StringPrintf(
"%02X%02X%02X%02X", (int)(color.redComponent * 0xFF),
(int)(color.greenComponent * 0xFF), (int)(color.blueComponent * 0xFF),
(int)(color.alphaComponent * 0xFF));
}
// Convert color to RGB hex value like "#ABCDEF"
std::string ToRGBHex(NSColor* color) {
return base::StringPrintf("#%02X%02X%02X", (int)(color.redComponent * 0xFF),
(int)(color.greenComponent * 0xFF),
(int)(color.blueComponent * 0xFF));
}
} // namespace } // namespace
void SystemPreferences::PostNotification(const std::string& name, void SystemPreferences::PostNotification(const std::string& name,
@@ -405,7 +391,7 @@ std::string SystemPreferences::GetAccentColor() {
if (@available(macOS 10.14, *)) if (@available(macOS 10.14, *))
sysColor = [NSColor controlAccentColor]; sysColor = [NSColor controlAccentColor];
return ToRGBA(sysColor); return base::SysNSStringToUTF8([sysColor RGBAValue]);
} }
std::string SystemPreferences::GetSystemColor(const std::string& color, std::string SystemPreferences::GetSystemColor(const std::string& color,
@@ -434,7 +420,7 @@ std::string SystemPreferences::GetSystemColor(const std::string& color,
return ""; return "";
} }
return ToRGBHex(sysColor); return base::SysNSStringToUTF8([sysColor hexadecimalValue]);
} }
bool SystemPreferences::CanPromptTouchID() { bool SystemPreferences::CanPromptTouchID() {
@@ -587,7 +573,7 @@ std::string SystemPreferences::GetColor(const std::string& color,
return ""; return "";
} }
return ToRGBHex(sysColor); return base::SysNSStringToUTF8([sysColor hexadecimalValue]);
} }
std::string SystemPreferences::GetMediaAccessStatus( std::string SystemPreferences::GetMediaAccessStatus(

View File

@@ -648,10 +648,11 @@ void TopLevelWindow::SetFocusable(bool focusable) {
} }
void TopLevelWindow::SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> value) { void TopLevelWindow::SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> value) {
auto context = isolate->GetCurrentContext();
mate::Handle<Menu> menu; mate::Handle<Menu> menu;
if (value->IsObject() && v8::Local<v8::Object> object;
gin::V8ToString( if (value->IsObject() && value->ToObject(context).ToLocal(&object) &&
isolate, value->ToObject(isolate)->GetConstructorName()) == "Menu" && gin::V8ToString(isolate, object->GetConstructorName()) == "Menu" &&
mate::ConvertFromV8(isolate, value, &menu) && !menu.IsEmpty()) { mate::ConvertFromV8(isolate, value, &menu) && !menu.IsEmpty()) {
menu_.Reset(isolate, menu.ToV8()); menu_.Reset(isolate, menu.ToV8());
window_->SetMenu(menu->model()); window_->SetMenu(menu->model());

View File

@@ -59,11 +59,7 @@ Tray::Tray(v8::Isolate* isolate,
InitWith(isolate, wrapper); InitWith(isolate, wrapper);
} }
Tray::~Tray() { Tray::~Tray() = default;
// Destroy the native tray in next tick.
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE,
tray_icon_.release());
}
// static // static
mate::WrappableBase* Tray::New(mate::Handle<NativeImage> image, mate::WrappableBase* Tray::New(mate::Handle<NativeImage> image,

View File

@@ -354,7 +354,7 @@ void URLRequest::OnReceivedRedirect(
} }
void URLRequest::OnAuthenticationRequired( void URLRequest::OnAuthenticationRequired(
scoped_refptr<const net::AuthChallengeInfo> auth_info) { const net::AuthChallengeInfo& auth_info) {
if (request_state_.Canceled() || request_state_.Closed()) { if (request_state_.Canceled() || request_state_.Closed()) {
return; return;
} }
@@ -364,7 +364,7 @@ void URLRequest::OnAuthenticationRequired(
return; return;
} }
Emit("login", auth_info.get(), Emit("login", auth_info,
base::Bind(&AtomURLRequest::PassLoginInformation, atom_request_)); base::Bind(&AtomURLRequest::PassLoginInformation, atom_request_));
} }

View File

@@ -105,8 +105,7 @@ class URLRequest : public mate::EventEmitter<URLRequest> {
const std::string& method, const std::string& method,
const GURL& url, const GURL& url,
scoped_refptr<net::HttpResponseHeaders> response_headers); scoped_refptr<net::HttpResponseHeaders> response_headers);
void OnAuthenticationRequired( void OnAuthenticationRequired(const net::AuthChallengeInfo& auth_info);
scoped_refptr<const net::AuthChallengeInfo> auth_info);
void OnResponseStarted( void OnResponseStarted(
scoped_refptr<net::HttpResponseHeaders> response_headers); scoped_refptr<net::HttpResponseHeaders> response_headers);
void OnResponseData(scoped_refptr<const net::IOBufferWithSize> data); void OnResponseData(scoped_refptr<const net::IOBufferWithSize> data);

View File

@@ -86,6 +86,7 @@
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h" #include "third_party/blink/public/mojom/frame/find_in_page.mojom.h"
#include "third_party/blink/public/platform/web_cursor_info.h"
#include "third_party/blink/public/platform/web_input_event.h" #include "third_party/blink/public/platform/web_input_event.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
#include "ui/events/base_event_utils.h" #include "ui/events/base_event_utils.h"
@@ -490,12 +491,14 @@ void WebContents::DestroyWebContents(bool async) {
ResetManagedWebContents(async); ResetManagedWebContents(async);
} }
bool WebContents::DidAddMessageToConsole(content::WebContents* source, bool WebContents::DidAddMessageToConsole(
int32_t level, content::WebContents* source,
const base::string16& message, blink::mojom::ConsoleMessageLevel level,
int32_t line_no, const base::string16& message,
const base::string16& source_id) { int32_t line_no,
return Emit("console-message", level, message, line_no, source_id); const base::string16& source_id) {
return Emit("console-message", static_cast<int32_t>(level), message, line_no,
source_id);
} }
void WebContents::OnCreateWindow( void WebContents::OnCreateWindow(
@@ -807,20 +810,20 @@ void WebContents::PluginCrashed(const base::FilePath& plugin_path,
} }
void WebContents::MediaStartedPlaying(const MediaPlayerInfo& video_type, void WebContents::MediaStartedPlaying(const MediaPlayerInfo& video_type,
const MediaPlayerId& id) { const content::MediaPlayerId& id) {
Emit("media-started-playing"); Emit("media-started-playing");
} }
void WebContents::MediaStoppedPlaying( void WebContents::MediaStoppedPlaying(
const MediaPlayerInfo& video_type, const MediaPlayerInfo& video_type,
const MediaPlayerId& id, const content::MediaPlayerId& id,
content::WebContentsObserver::MediaStoppedReason reason) { content::WebContentsObserver::MediaStoppedReason reason) {
Emit("media-paused"); Emit("media-paused");
} }
void WebContents::DidChangeThemeColor(SkColor theme_color) { void WebContents::DidChangeThemeColor(base::Optional<SkColor> theme_color) {
if (theme_color != SK_ColorTRANSPARENT) { if (theme_color) {
Emit("did-change-theme-color", atom::ToRGBHex(theme_color)); Emit("did-change-theme-color", atom::ToRGBHex(theme_color.value()));
} else { } else {
Emit("did-change-theme-color", nullptr); Emit("did-change-theme-color", nullptr);
} }
@@ -1192,7 +1195,7 @@ void WebContents::SetBackgroundThrottling(bool allowed) {
return; return;
} }
const auto* render_view_host = contents->GetRenderViewHost(); auto* render_view_host = contents->GetRenderViewHost();
if (!render_view_host) { if (!render_view_host) {
return; return;
} }
@@ -1915,10 +1918,9 @@ v8::Local<v8::Promise> WebContents::CapturePage(mate::Arguments* args) {
} }
void WebContents::OnCursorChange(const content::WebCursor& cursor) { void WebContents::OnCursorChange(const content::WebCursor& cursor) {
content::CursorInfo info; const content::CursorInfo& info = cursor.info();
cursor.GetCursorInfo(&info);
if (cursor.IsCustom()) { if (info.type == blink::WebCursorInfo::kTypeCustom) {
Emit("cursor-changed", CursorTypeToString(info), Emit("cursor-changed", CursorTypeToString(info),
gfx::Image::CreateFrom1xBitmap(info.custom_image), gfx::Image::CreateFrom1xBitmap(info.custom_image),
info.image_scale_factor, info.image_scale_factor,

View File

@@ -337,7 +337,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
// content::WebContentsDelegate: // content::WebContentsDelegate:
bool DidAddMessageToConsole(content::WebContents* source, bool DidAddMessageToConsole(content::WebContents* source,
int32_t level, blink::mojom::ConsoleMessageLevel level,
const base::string16& message, const base::string16& message,
int32_t line_no, int32_t line_no,
const base::string16& source_id) override; const base::string16& source_id) override;
@@ -445,12 +445,12 @@ class WebContents : public mate::TrackableObject<WebContents>,
void PluginCrashed(const base::FilePath& plugin_path, void PluginCrashed(const base::FilePath& plugin_path,
base::ProcessId plugin_pid) override; base::ProcessId plugin_pid) override;
void MediaStartedPlaying(const MediaPlayerInfo& video_type, void MediaStartedPlaying(const MediaPlayerInfo& video_type,
const MediaPlayerId& id) override; const content::MediaPlayerId& id) override;
void MediaStoppedPlaying( void MediaStoppedPlaying(
const MediaPlayerInfo& video_type, const MediaPlayerInfo& video_type,
const MediaPlayerId& id, const content::MediaPlayerId& id,
content::WebContentsObserver::MediaStoppedReason reason) override; content::WebContentsObserver::MediaStoppedReason reason) override;
void DidChangeThemeColor(SkColor theme_color) override; void DidChangeThemeColor(base::Optional<SkColor> theme_color) override;
void OnInterfaceRequestFromFrame( void OnInterfaceRequestFromFrame(
content::RenderFrameHost* render_frame_host, content::RenderFrameHost* render_frame_host,
const std::string& interface_name, const std::string& interface_name,

View File

@@ -52,7 +52,10 @@ void Event::FrameDeleted(content::RenderFrameHost* rfh) {
} }
void Event::PreventDefault(v8::Isolate* isolate) { void Event::PreventDefault(v8::Isolate* isolate) {
GetWrapper()->Set(StringToV8(isolate, "defaultPrevented"), v8::True(isolate)); GetWrapper()
->Set(isolate->GetCurrentContext(),
StringToV8(isolate, "defaultPrevented"), v8::True(isolate))
.Check();
} }
bool Event::SendReply(const base::ListValue& result) { bool Event::SendReply(const base::ListValue& result) {

View File

@@ -104,8 +104,13 @@ class EventEmitter : public Wrappable<T> {
v8::Locker locker(isolate()); v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate()); v8::HandleScope handle_scope(isolate());
EmitEvent(isolate(), GetWrapper(), name, event, args...); EmitEvent(isolate(), GetWrapper(), name, event, args...);
return event->Get(StringToV8(isolate(), "defaultPrevented")) auto context = isolate()->GetCurrentContext();
->BooleanValue(isolate()); v8::Local<v8::Value> defaultPrevented;
if (event->Get(context, StringToV8(isolate(), "defaultPrevented"))
.ToLocal(&defaultPrevented)) {
return defaultPrevented->BooleanValue(isolate());
}
return false;
} }
DISALLOW_COPY_AND_ASSIGN(EventEmitter); DISALLOW_COPY_AND_ASSIGN(EventEmitter);

View File

@@ -534,7 +534,7 @@ std::string AtomBrowserClient::GetGeolocationApiKey() {
return api_key; return api_key;
} }
content::QuotaPermissionContext* scoped_refptr<content::QuotaPermissionContext>
AtomBrowserClient::CreateQuotaPermissionContext() { AtomBrowserClient::CreateQuotaPermissionContext() {
return new AtomQuotaPermissionContext; return new AtomQuotaPermissionContext;
} }
@@ -867,7 +867,8 @@ NotificationPresenter* AtomBrowserClient::GetNotificationPresenter() {
} }
content::PlatformNotificationService* content::PlatformNotificationService*
AtomBrowserClient::GetPlatformNotificationService() { AtomBrowserClient::GetPlatformNotificationService(
content::BrowserContext* browser_context) {
if (!notification_service_) { if (!notification_service_) {
notification_service_.reset(new PlatformNotificationService(this)); notification_service_.reset(new PlatformNotificationService(this));
} }

View File

@@ -90,7 +90,8 @@ class AtomBrowserClient : public content::ContentBrowserClient,
base::CommandLine* command_line) override; base::CommandLine* command_line) override;
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override; void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
std::string GetGeolocationApiKey() override; std::string GetGeolocationApiKey() override;
content::QuotaPermissionContext* CreateQuotaPermissionContext() override; scoped_refptr<content::QuotaPermissionContext> CreateQuotaPermissionContext()
override;
content::GeneratedCodeCacheSettings GetGeneratedCodeCacheSettings( content::GeneratedCodeCacheSettings GetGeneratedCodeCacheSettings(
content::BrowserContext* context) override; content::BrowserContext* context) override;
void AllowCertificateError( void AllowCertificateError(
@@ -144,8 +145,8 @@ class AtomBrowserClient : public content::ContentBrowserClient,
net::NetLog* GetNetLog() override; net::NetLog* GetNetLog() override;
content::MediaObserver* GetMediaObserver() override; content::MediaObserver* GetMediaObserver() override;
content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override; content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
content::PlatformNotificationService* GetPlatformNotificationService() content::PlatformNotificationService* GetPlatformNotificationService(
override; content::BrowserContext* browser_context) override;
content::BrowserMainParts* CreateBrowserMainParts( content::BrowserMainParts* CreateBrowserMainParts(
const content::MainFunctionParams&) override; const content::MainFunctionParams&) override;
base::FilePath GetDefaultDownloadDirectory() override; base::FilePath GetDefaultDownloadDirectory() override;

View File

@@ -76,7 +76,7 @@
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/l10n_util_win.h" #include "ui/base/l10n/l10n_util_win.h"
#include "ui/display/win/dpi.h" #include "ui/display/win/dpi.h"
#include "ui/gfx/platform_font_win.h" #include "ui/gfx/system_fonts_win.h"
#include "ui/strings/grit/app_locale_settings.h" #include "ui/strings/grit/app_locale_settings.h"
#endif #endif
@@ -102,7 +102,7 @@ void Erase(T* container, typename T::iterator iter) {
#if defined(OS_WIN) #if defined(OS_WIN)
// gfx::Font callbacks // gfx::Font callbacks
void AdjustUIFont(gfx::PlatformFontWin::FontAdjustment* font_adjustment) { void AdjustUIFont(gfx::win::FontAdjustment* font_adjustment) {
l10n_util::NeedOverrideDefaultUIFont(&font_adjustment->font_family_override, l10n_util::NeedOverrideDefaultUIFont(&font_adjustment->font_family_override,
&font_adjustment->font_scale); &font_adjustment->font_scale);
font_adjustment->font_scale *= display::win::GetAccessibilityFontScale(); font_adjustment->font_scale *= display::win::GetAccessibilityFontScale();
@@ -380,8 +380,8 @@ void AtomBrowserMainParts::ToolkitInitialized() {
#endif #endif
#if defined(OS_WIN) #if defined(OS_WIN)
gfx::PlatformFontWin::SetAdjustFontCallback(&AdjustUIFont); gfx::win::SetAdjustFontCallback(&AdjustUIFont);
gfx::PlatformFontWin::SetGetMinimumFontSizeCallback(&GetMinimumFontSize); gfx::win::SetGetMinimumFontSizeCallback(&GetMinimumFontSize);
wchar_t module_name[MAX_PATH] = {0}; wchar_t module_name[MAX_PATH] = {0};
if (GetModuleFileName(NULL, module_name, MAX_PATH)) if (GetModuleFileName(NULL, module_name, MAX_PATH))
@@ -469,6 +469,7 @@ void AtomBrowserMainParts::PostMainMessageLoopRun() {
ui::SetX11ErrorHandlers(X11EmptyErrorHandler, X11EmptyIOErrorHandler); ui::SetX11ErrorHandlers(X11EmptyErrorHandler, X11EmptyIOErrorHandler);
#endif #endif
node_debugger_->Stop();
js_env_->OnMessageLoopDestroying(); js_env_->OnMessageLoopDestroying();
#if defined(OS_MACOSX) #if defined(OS_MACOSX)

View File

@@ -41,8 +41,26 @@ void AtomBrowserMainParts::InitializeMainNib() {
auto application = [principalClass sharedApplication]; auto application = [principalClass sharedApplication];
NSString* mainNibName = [infoDictionary objectForKey:@"NSMainNibFile"]; NSString* mainNibName = [infoDictionary objectForKey:@"NSMainNibFile"];
auto mainNib = [[NSNib alloc] initWithNibNamed:mainNibName
bundle:base::mac::FrameworkBundle()]; NSNib* mainNib;
@try {
mainNib = [[NSNib alloc] initWithNibNamed:mainNibName
bundle:base::mac::FrameworkBundle()];
// Handle failure of initWithNibNamed on SMB shares
// TODO(codebytere): Remove when
// https://bugs.chromium.org/p/chromium/issues/detail?id=932935 is fixed
} @catch (NSException* exception) {
NSString* nibPath =
[NSString stringWithFormat:@"Resources/%@.nib", mainNibName];
nibPath = [base::mac::FrameworkBundle().bundlePath
stringByAppendingPathComponent:nibPath];
NSData* data = [NSData dataWithContentsOfFile:nibPath];
mainNib = [[NSNib alloc] initWithNibData:data
bundle:base::mac::FrameworkBundle()];
}
[mainNib instantiateWithOwner:application topLevelObjects:nil]; [mainNib instantiateWithOwner:application topLevelObjects:nil];
[mainNib release]; [mainNib release];
} }

View File

@@ -127,8 +127,8 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated(
base::Bind(&AtomDownloadManagerDelegate::OnDownloadSaveDialogDone, base::Bind(&AtomDownloadManagerDelegate::OnDownloadSaveDialogDone,
base::Unretained(this), download_id, callback); base::Unretained(this), download_id, callback);
file_dialog::ShowSaveDialog(settings, std::move(dialog_promise));
ignore_result(dialog_promise.Then(dialog_callback)); ignore_result(dialog_promise.Then(dialog_callback));
file_dialog::ShowSaveDialog(settings, std::move(dialog_promise));
} else { } else {
callback.Run(path, download::DownloadItem::TARGET_DISPOSITION_PROMPT, callback.Run(path, download::DownloadItem::TARGET_DISPOSITION_PROMPT,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, path, download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, path,
@@ -136,54 +136,48 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated(
} }
} }
#if defined(MAS_BUILD)
void AtomDownloadManagerDelegate::OnDownloadSaveDialogDone( void AtomDownloadManagerDelegate::OnDownloadSaveDialogDone(
uint32_t download_id, uint32_t download_id,
const content::DownloadTargetCallback& download_callback, const content::DownloadTargetCallback& download_callback,
bool result, mate::Dictionary result) {
const base::FilePath& path,
const std::string& bookmark)
#else
void AtomDownloadManagerDelegate::OnDownloadSaveDialogDone(
uint32_t download_id,
const content::DownloadTargetCallback& download_callback,
bool result,
const base::FilePath& path)
#endif
{
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
auto* item = download_manager_->GetDownload(download_id); auto* item = download_manager_->GetDownload(download_id);
if (!item) if (!item)
return; return;
if (result) { bool canceled = true;
// Remember the last selected download directory. result.Get("canceled", &canceled);
AtomBrowserContext* browser_context = static_cast<AtomBrowserContext*>(
download_manager_->GetBrowserContext());
browser_context->prefs()->SetFilePath(prefs::kDownloadDefaultDirectory,
path.DirName());
v8::Isolate* isolate = v8::Isolate::GetCurrent(); base::FilePath path;
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate); if (!canceled) {
api::DownloadItem* download_item = if (result.Get("filePath", &path)) {
api::DownloadItem::FromWrappedClass(isolate, item); // Remember the last selected download directory.
if (download_item) AtomBrowserContext* browser_context = static_cast<AtomBrowserContext*>(
download_item->SetSavePath(path); download_manager_->GetBrowserContext());
browser_context->prefs()->SetFilePath(prefs::kDownloadDefaultDirectory,
path.DirName());
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
api::DownloadItem* download_item =
api::DownloadItem::FromWrappedClass(isolate, item);
if (download_item)
download_item->SetSavePath(path);
}
} }
// Running the DownloadTargetCallback with an empty FilePath signals that the // Running the DownloadTargetCallback with an empty FilePath signals that the
// download should be cancelled. If user cancels the file save dialog, run // download should be cancelled. If user cancels the file save dialog, run
// the callback with empty FilePath. // the callback with empty FilePath.
const base::FilePath download_path = result ? path : base::FilePath();
const auto interrupt_reason = const auto interrupt_reason =
download_path.empty() ? download::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED path.empty() ? download::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED
: download::DOWNLOAD_INTERRUPT_REASON_NONE; : download::DOWNLOAD_INTERRUPT_REASON_NONE;
download_callback.Run(download_path, download_callback.Run(path, download::DownloadItem::TARGET_DISPOSITION_PROMPT,
download::DownloadItem::TARGET_DISPOSITION_PROMPT, download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, path,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, interrupt_reason);
download_path, interrupt_reason);
} }
void AtomDownloadManagerDelegate::Shutdown() { void AtomDownloadManagerDelegate::Shutdown() {

View File

@@ -45,20 +45,10 @@ class AtomDownloadManagerDelegate : public content::DownloadManagerDelegate {
const content::DownloadTargetCallback& callback, const content::DownloadTargetCallback& callback,
const base::FilePath& default_path); const base::FilePath& default_path);
#if defined(MAS_BUILD)
void OnDownloadSaveDialogDone( void OnDownloadSaveDialogDone(
uint32_t download_id, uint32_t download_id,
const content::DownloadTargetCallback& download_callback, const content::DownloadTargetCallback& download_callback,
bool result, mate::Dictionary result);
const base::FilePath& path,
const std::string& bookmark);
#else
void OnDownloadSaveDialogDone(
uint32_t download_id,
const content::DownloadTargetCallback& download_callback,
bool result,
const base::FilePath& path);
#endif
content::DownloadManager* download_manager_; content::DownloadManager* download_manager_;
base::WeakPtrFactory<AtomDownloadManagerDelegate> weak_ptr_factory_; base::WeakPtrFactory<AtomDownloadManagerDelegate> weak_ptr_factory_;

View File

@@ -197,6 +197,7 @@ class Browser : public WindowListObserver {
base::string16 arguments; base::string16 arguments;
base::string16 title; base::string16 title;
base::string16 description; base::string16 description;
base::FilePath working_dir;
base::FilePath icon_path; base::FilePath icon_path;
int icon_index; int icon_index;

View File

@@ -131,7 +131,7 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol,
void Browser::SetAppUserModelID(const base::string16& name) {} void Browser::SetAppUserModelID(const base::string16& name) {}
bool Browser::SetBadgeCount(int count) { bool Browser::SetBadgeCount(int count) {
DockSetBadgeText(count != 0 ? base::IntToString(count) : ""); DockSetBadgeText(count != 0 ? base::NumberToString(count) : "");
badge_count_ = count; badge_count_ = count;
return true; return true;
} }

View File

@@ -338,3 +338,7 @@ printing::PrintJobManager* BrowserProcessImpl::print_job_manager() {
return nullptr; return nullptr;
#endif #endif
} }
StartupData* BrowserProcessImpl::startup_data() {
return nullptr;
}

View File

@@ -114,6 +114,7 @@ class BrowserProcessImpl : public BrowserProcess {
void SetApplicationLocale(const std::string& locale) override; void SetApplicationLocale(const std::string& locale) override;
const std::string& GetApplicationLocale() override; const std::string& GetApplicationLocale() override;
printing::PrintJobManager* print_job_manager() override; printing::PrintJobManager* print_job_manager() override;
StartupData* startup_data() override;
private: private:
#if BUILDFLAG(ENABLE_PRINTING) #if BUILDFLAG(ENABLE_PRINTING)

View File

@@ -96,7 +96,7 @@ void Browser::Focus() {
} }
void Browser::AddRecentDocument(const base::FilePath& path) { void Browser::AddRecentDocument(const base::FilePath& path) {
if (base::win::GetVersion() < base::win::VERSION_WIN7) if (base::win::GetVersion() < base::win::Version::WIN7)
return; return;
CComPtr<IShellItem> item; CComPtr<IShellItem> item;
@@ -141,6 +141,7 @@ bool Browser::SetUserTasks(const std::vector<UserTask>& tasks) {
item.icon_path = task.icon_path; item.icon_path = task.icon_path;
item.icon_index = task.icon_index; item.icon_index = task.icon_index;
item.description = task.description; item.description = task.description;
item.working_dir = task.working_dir;
category.items.push_back(item); category.items.push_back(item);
} }
@@ -346,7 +347,7 @@ std::string Browser::GetExecutableFileProductName() const {
bool Browser::IsEmojiPanelSupported() { bool Browser::IsEmojiPanelSupported() {
// emoji picker is supported on Windows 10's Spring 2018 update & above. // emoji picker is supported on Windows 10's Spring 2018 update & above.
return base::win::GetVersion() >= base::win::Version::VERSION_WIN10_RS4; return base::win::GetVersion() >= base::win::Version::WIN10_RS4;
} }
void Browser::ShowEmojiPanel() { void Browser::ShowEmojiPanel() {

View File

@@ -352,9 +352,8 @@ blink::WebSecurityStyle CommonWebContentsDelegate::GetSecurityStyle(
SecurityStateTabHelper* helper = SecurityStateTabHelper* helper =
SecurityStateTabHelper::FromWebContents(web_contents); SecurityStateTabHelper::FromWebContents(web_contents);
DCHECK(helper); DCHECK(helper);
security_state::SecurityInfo security_info; return security_state::GetSecurityStyle(helper->GetSecurityLevel(),
helper->GetSecurityInfo(&security_info); *helper->GetVisibleSecurityState(),
return security_state::GetSecurityStyle(security_info,
security_style_explanations); security_style_explanations);
} }

View File

@@ -45,7 +45,7 @@ void IOThread::Init() {
auto cert_verifier = std::make_unique<net::CachingCertVerifier>( auto cert_verifier = std::make_unique<net::CachingCertVerifier>(
std::make_unique<net::MultiThreadedCertVerifier>( std::make_unique<net::MultiThreadedCertVerifier>(
net::CertVerifyProc::CreateDefault())); net::CertVerifyProc::CreateDefault(nullptr)));
builder->SetCertVerifier(std::move(cert_verifier)); builder->SetCertVerifier(std::move(cert_verifier));
// Create the network service, so that shared host resolver // Create the network service, so that shared host resolver
@@ -70,5 +70,5 @@ void IOThread::CleanUp() {
system_request_context_->proxy_resolution_service()->OnShutdown(); system_request_context_->proxy_resolution_service()->OnShutdown();
if (net_log_) if (net_log_)
net_log_->ShutDownBeforeTaskScheduler(); net_log_->ShutDownBeforeThreadPool();
} }

View File

@@ -10,7 +10,7 @@
#include "atom/common/node_includes.h" #include "atom/common/node_includes.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/task/task_scheduler/initialization_util.h" #include "base/task/thread_pool/initialization_util.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "gin/array_buffer.h" #include "gin/array_buffer.h"

View File

@@ -26,7 +26,7 @@ LoginHandler::LoginHandler(net::URLRequest* request,
net::AuthCredentials* credentials, net::AuthCredentials* credentials,
content::ResourceRequestInfo* resource_request_info) content::ResourceRequestInfo* resource_request_info)
: credentials_(credentials), : credentials_(credentials),
auth_info_(&auth_info), auth_info_(std::make_unique<net::AuthChallengeInfo>(auth_info)),
auth_callback_(std::move(callback)), auth_callback_(std::move(callback)),
weak_factory_(this) { weak_factory_(this) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);

View File

@@ -5,6 +5,8 @@
#ifndef ATOM_BROWSER_LOGIN_HANDLER_H_ #ifndef ATOM_BROWSER_LOGIN_HANDLER_H_
#define ATOM_BROWSER_LOGIN_HANDLER_H_ #define ATOM_BROWSER_LOGIN_HANDLER_H_
#include <memory>
#include "base/callback.h" #include "base/callback.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
@@ -57,7 +59,7 @@ class LoginHandler : public base::RefCountedThreadSafe<LoginHandler> {
net::AuthCredentials* credentials_; net::AuthCredentials* credentials_;
// Who/where/what asked for the authentication. // Who/where/what asked for the authentication.
scoped_refptr<const net::AuthChallengeInfo> auth_info_; std::unique_ptr<const net::AuthChallengeInfo> auth_info_;
// WebContents associated with the login request. // WebContents associated with the login request.
content::ResourceRequestInfo::WebContentsGetter web_contents_getter_; content::ResourceRequestInfo::WebContentsGetter web_contents_getter_;

View File

@@ -5,7 +5,6 @@
#include "atom/browser/native_window_views.h" #include "atom/browser/native_window_views.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include <objbase.h>
#include <wrl/client.h> #include <wrl/client.h>
#endif #endif
@@ -62,7 +61,6 @@
#include "atom/browser/ui/win/atom_desktop_window_tree_host_win.h" #include "atom/browser/ui/win/atom_desktop_window_tree_host_win.h"
#include "skia/ext/skia_utils_win.h" #include "skia/ext/skia_utils_win.h"
#include "ui/base/win/shell.h" #include "ui/base/win/shell.h"
#include "ui/display/display.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
#include "ui/display/win/screen_win.h" #include "ui/display/win/screen_win.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
@@ -380,6 +378,9 @@ void NativeWindowViews::Show() {
widget()->native_widget_private()->Show(GetRestoredState(), gfx::Rect()); widget()->native_widget_private()->Show(GetRestoredState(), gfx::Rect());
// explicitly focus the window
widget()->Activate();
NotifyWindowShow(); NotifyWindowShow();
#if defined(USE_X11) #if defined(USE_X11)
@@ -470,24 +471,15 @@ void NativeWindowViews::SetEnabledInternal(bool enable) {
#endif #endif
} }
#if defined(USE_X11)
void NativeWindowViews::Maximize() { void NativeWindowViews::Maximize() {
#if defined(OS_WIN)
// For window without WS_THICKFRAME style, we can not call Maximize().
if (!(::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_THICKFRAME)) {
restore_bounds_ = GetBounds();
auto display =
display::Screen::GetScreen()->GetDisplayNearestPoint(GetPosition());
SetBounds(display.work_area(), false);
return;
}
#endif
if (IsVisible()) if (IsVisible())
widget()->Maximize(); widget()->Maximize();
else else
widget()->native_widget_private()->Show(ui::SHOW_STATE_MAXIMIZED, widget()->native_widget_private()->Show(ui::SHOW_STATE_MAXIMIZED,
gfx::Rect()); gfx::Rect());
} }
#endif
void NativeWindowViews::Unmaximize() { void NativeWindowViews::Unmaximize() {
#if defined(OS_WIN) #if defined(OS_WIN)

View File

@@ -2,14 +2,19 @@
// Use of this source code is governed by the MIT license that can be // Use of this source code is governed by the MIT license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include <dwmapi.h>
#include <shellapi.h>
#include "atom/browser/browser.h" #include "atom/browser/browser.h"
#include "atom/browser/native_window_views.h" #include "atom/browser/native_window_views.h"
#include "atom/browser/ui/views/root_view.h" #include "atom/browser/ui/views/root_view.h"
#include "atom/common/atom_constants.h" #include "atom/common/atom_constants.h"
#include "content/public/browser/browser_accessibility_state.h" #include "content/public/browser/browser_accessibility_state.h"
#include "ui/base/win/accessibility_misc_utils.h" #include "ui/base/win/accessibility_misc_utils.h"
#include "ui/display/display.h"
#include "ui/display/win/screen_win.h" #include "ui/display/win/screen_win.h"
#include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/insets.h"
#include "ui/views/widget/native_widget_private.h"
// Must be included after other Windows headers. // Must be included after other Windows headers.
#include <UIAutomationCoreApi.h> #include <UIAutomationCoreApi.h>
@@ -138,11 +143,155 @@ bool IsScreenReaderActive() {
return screenReader && UiaClientsAreListening(); return screenReader && UiaClientsAreListening();
} }
// We use "enum" instead of "enum class" because we need to do bitwise compare.
enum AppbarAutohideEdge {
TOP = 1 << 0,
LEFT = 1 << 1,
BOTTOM = 1 << 2,
RIGHT = 1 << 3,
};
// The thickness of an auto-hide taskbar in pixel.
constexpr int kAutoHideTaskbarThicknessPx = 2;
// Code is copied from chrome_views_delegate_win.cc.
bool MonitorHasAutohideTaskbarForEdge(UINT edge, HMONITOR monitor) {
APPBARDATA taskbar_data = {sizeof(APPBARDATA), NULL, 0, edge};
taskbar_data.hWnd = ::GetForegroundWindow();
// MSDN documents an ABM_GETAUTOHIDEBAREX, which supposedly takes a monitor
// rect and returns autohide bars on that monitor. This sounds like a good
// idea for multi-monitor systems. Unfortunately, it appears to not work at
// least some of the time (erroneously returning NULL) and there's almost no
// online documentation or other sample code using it that suggests ways to
// address this problem. We do the following:-
// 1. Use the ABM_GETAUTOHIDEBAR message. If it works, i.e. returns a valid
// window we are done.
// 2. If the ABM_GETAUTOHIDEBAR message does not work we query the auto hide
// state of the taskbar and then retrieve its position. That call returns
// the edge on which the taskbar is present. If it matches the edge we
// are looking for, we are done.
// NOTE: This call spins a nested run loop.
HWND taskbar = reinterpret_cast<HWND>(
SHAppBarMessage(ABM_GETAUTOHIDEBAR, &taskbar_data));
if (!::IsWindow(taskbar)) {
APPBARDATA taskbar_data = {sizeof(APPBARDATA), 0, 0, 0};
unsigned int taskbar_state = SHAppBarMessage(ABM_GETSTATE, &taskbar_data);
if (!(taskbar_state & ABS_AUTOHIDE))
return false;
taskbar_data.hWnd = ::FindWindow(L"Shell_TrayWnd", NULL);
if (!::IsWindow(taskbar_data.hWnd))
return false;
SHAppBarMessage(ABM_GETTASKBARPOS, &taskbar_data);
if (taskbar_data.uEdge == edge)
taskbar = taskbar_data.hWnd;
}
// There is a potential race condition here:
// 1. A maximized chrome window is fullscreened.
// 2. It is switched back to maximized.
// 3. In the process the window gets a WM_NCCACLSIZE message which calls us to
// get the autohide state.
// 4. The worker thread is invoked. It calls the API to get the autohide
// state. On Windows versions earlier than Windows 7, taskbars could
// easily be always on top or not.
// This meant that we only want to look for taskbars which have the topmost
// bit set. However this causes problems in cases where the window on the
// main thread is still in the process of switching away from fullscreen.
// In this case the taskbar might not yet have the topmost bit set.
// 5. The main thread resumes and does not leave space for the taskbar and
// hence it does not pop when hovered.
//
// To address point 4 above, it is best to not check for the WS_EX_TOPMOST
// window style on the taskbar, as starting from Windows 7, the topmost
// style is always set. We don't support XP and Vista anymore.
if (::IsWindow(taskbar)) {
if (MonitorFromWindow(taskbar, MONITOR_DEFAULTTONEAREST) == monitor)
return true;
// In some cases like when the autohide taskbar is on the left of the
// secondary monitor, the MonitorFromWindow call above fails to return the
// correct monitor the taskbar is on. We fallback to MonitorFromPoint for
// the cursor position in that case, which seems to work well.
POINT cursor_pos = {0};
GetCursorPos(&cursor_pos);
if (MonitorFromPoint(cursor_pos, MONITOR_DEFAULTTONEAREST) == monitor)
return true;
}
return false;
}
int GetAppbarAutohideEdges(HWND hwnd) {
HMONITOR monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONULL);
if (!monitor)
return 0;
int edges = 0;
if (MonitorHasAutohideTaskbarForEdge(ABE_LEFT, monitor))
edges |= AppbarAutohideEdge::LEFT;
if (MonitorHasAutohideTaskbarForEdge(ABE_TOP, monitor))
edges |= AppbarAutohideEdge::TOP;
if (MonitorHasAutohideTaskbarForEdge(ABE_RIGHT, monitor))
edges |= AppbarAutohideEdge::RIGHT;
if (MonitorHasAutohideTaskbarForEdge(ABE_BOTTOM, monitor))
edges |= AppbarAutohideEdge::BOTTOM;
return edges;
}
} // namespace } // namespace
std::set<NativeWindowViews*> NativeWindowViews::forwarding_windows_; std::set<NativeWindowViews*> NativeWindowViews::forwarding_windows_;
HHOOK NativeWindowViews::mouse_hook_ = NULL; HHOOK NativeWindowViews::mouse_hook_ = NULL;
void NativeWindowViews::Maximize() {
int autohide_edges = 0;
if (!has_frame())
autohide_edges = GetAppbarAutohideEdges(GetAcceleratedWidget());
// Only use Maximize() when:
// 1. window has WS_THICKFRAME style;
// 2. and window is not frameless when there is autohide taskbar.
if ((::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_THICKFRAME) &&
(has_frame() || autohide_edges == 0)) {
if (IsVisible())
widget()->Maximize();
else
widget()->native_widget_private()->Show(ui::SHOW_STATE_MAXIMIZED,
gfx::Rect());
return;
}
gfx::Insets insets;
if (!has_frame()) {
// When taskbar is autohide, we need to leave some space so the window
// isn't treated as a "fullscreen app", which would cause the taskbars
// to disappear.
//
// This trick comes from hwnd_message_handler.cc. While Chromium already
// does this for normal window, somehow it is not applying the trick when
// using frameless window, and we have to do it ourselves.
float scale_factor =
display::win::ScreenWin::GetScaleFactorForHWND(GetAcceleratedWidget());
int thickness = std::ceil(kAutoHideTaskbarThicknessPx / scale_factor);
if (autohide_edges & AppbarAutohideEdge::LEFT)
insets.set_left(-thickness);
if (autohide_edges & AppbarAutohideEdge::TOP)
insets.set_top(-thickness);
if (autohide_edges & AppbarAutohideEdge::RIGHT)
insets.set_right(thickness);
if (autohide_edges & AppbarAutohideEdge::BOTTOM)
insets.set_bottom(thickness);
}
restore_bounds_ = GetBounds();
auto display =
display::Screen::GetScreen()->GetDisplayNearestPoint(GetPosition());
gfx::Rect bounds = display.work_area();
bounds.Inset(insets);
SetBounds(bounds, false);
}
bool NativeWindowViews::ExecuteWindowsCommand(int command_id) { bool NativeWindowViews::ExecuteWindowsCommand(int command_id) {
std::string command = AppCommandToString(command_id); std::string command = AppCommandToString(command_id);
NotifyWindowExecuteAppCommand(command); NotifyWindowExecuteAppCommand(command);

View File

@@ -152,7 +152,7 @@ class CertVerifierRequest : public AtomCertVerifier::Request {
}; };
AtomCertVerifier::AtomCertVerifier(RequireCTDelegate* ct_delegate) AtomCertVerifier::AtomCertVerifier(RequireCTDelegate* ct_delegate)
: default_cert_verifier_(net::CertVerifier::CreateDefault()), : default_cert_verifier_(net::CertVerifier::CreateDefault(nullptr)),
ct_delegate_(ct_delegate) {} ct_delegate_(ct_delegate) {}
AtomCertVerifier::~AtomCertVerifier() {} AtomCertVerifier::~AtomCertVerifier() {}

View File

@@ -29,19 +29,19 @@ namespace atom {
const char* ResourceTypeToString(content::ResourceType type) { const char* ResourceTypeToString(content::ResourceType type) {
switch (type) { switch (type) {
case content::RESOURCE_TYPE_MAIN_FRAME: case content::ResourceType::kMainFrame:
return "mainFrame"; return "mainFrame";
case content::RESOURCE_TYPE_SUB_FRAME: case content::ResourceType::kSubFrame:
return "subFrame"; return "subFrame";
case content::RESOURCE_TYPE_STYLESHEET: case content::ResourceType::kStylesheet:
return "stylesheet"; return "stylesheet";
case content::RESOURCE_TYPE_SCRIPT: case content::ResourceType::kScript:
return "script"; return "script";
case content::RESOURCE_TYPE_IMAGE: case content::ResourceType::kImage:
return "image"; return "image";
case content::RESOURCE_TYPE_OBJECT: case content::ResourceType::kObject:
return "object"; return "object";
case content::RESOURCE_TYPE_XHR: case content::ResourceType::kXhr:
return "xhr"; return "xhr";
default: default:
return "other"; return "other";

View File

@@ -347,13 +347,13 @@ void AtomURLRequest::OnReceivedRedirect(net::URLRequest* request,
} }
void AtomURLRequest::OnAuthRequired(net::URLRequest* request, void AtomURLRequest::OnAuthRequired(net::URLRequest* request,
net::AuthChallengeInfo* auth_info) { const net::AuthChallengeInfo& auth_info) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO); DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
base::PostTaskWithTraits( base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI}, FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&AtomURLRequest::InformDelegateAuthenticationRequired, base::BindOnce(&AtomURLRequest::InformDelegateAuthenticationRequired,
this, scoped_refptr<net::AuthChallengeInfo>(auth_info))); this, auth_info));
} }
void AtomURLRequest::OnResponseStarted(net::URLRequest* request, void AtomURLRequest::OnResponseStarted(net::URLRequest* request,
@@ -468,7 +468,7 @@ void AtomURLRequest::InformDelegateReceivedRedirect(
} }
void AtomURLRequest::InformDelegateAuthenticationRequired( void AtomURLRequest::InformDelegateAuthenticationRequired(
scoped_refptr<net::AuthChallengeInfo> auth_info) const { const net::AuthChallengeInfo& auth_info) const {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (delegate_) if (delegate_)
delegate_->OnAuthenticationRequired(auth_info); delegate_->OnAuthenticationRequired(auth_info);

View File

@@ -53,7 +53,7 @@ class AtomURLRequest : public base::RefCountedThreadSafe<AtomURLRequest>,
const net::RedirectInfo& info, const net::RedirectInfo& info,
bool* defer_redirect) override; bool* defer_redirect) override;
void OnAuthRequired(net::URLRequest* request, void OnAuthRequired(net::URLRequest* request,
net::AuthChallengeInfo* auth_info) override; const net::AuthChallengeInfo& auth_info) override;
void OnResponseStarted(net::URLRequest* request, int net_error) override; void OnResponseStarted(net::URLRequest* request, int net_error) override;
void OnReadCompleted(net::URLRequest* request, int bytes_read) override; void OnReadCompleted(net::URLRequest* request, int bytes_read) override;
@@ -93,7 +93,7 @@ class AtomURLRequest : public base::RefCountedThreadSafe<AtomURLRequest>,
const GURL& url, const GURL& url,
scoped_refptr<net::HttpResponseHeaders> response_headers) const; scoped_refptr<net::HttpResponseHeaders> response_headers) const;
void InformDelegateAuthenticationRequired( void InformDelegateAuthenticationRequired(
scoped_refptr<net::AuthChallengeInfo> auth_info) const; const net::AuthChallengeInfo& auth_info) const;
void InformDelegateResponseStarted( void InformDelegateResponseStarted(
scoped_refptr<net::HttpResponseHeaders>) const; scoped_refptr<net::HttpResponseHeaders>) const;
void InformDelegateResponseData( void InformDelegateResponseData(

View File

@@ -50,6 +50,8 @@ network::mojom::HttpAuthDynamicParamsPtr CreateHttpAuthDynamicParams() {
command_line->GetSwitchValueASCII(atom::switches::kAuthServerWhitelist); command_line->GetSwitchValueASCII(atom::switches::kAuthServerWhitelist);
auth_dynamic_params->delegate_whitelist = command_line->GetSwitchValueASCII( auth_dynamic_params->delegate_whitelist = command_line->GetSwitchValueASCII(
atom::switches::kAuthNegotiateDelegateWhitelist); atom::switches::kAuthNegotiateDelegateWhitelist);
auth_dynamic_params->enable_negotiate_port =
command_line->HasSwitch(atom::switches::kEnableAuthNegotiatePort);
return auth_dynamic_params; return auth_dynamic_params;
} }

View File

@@ -122,7 +122,7 @@ void URLRequestBufferJob::Kill() {
void URLRequestBufferJob::GetResponseInfo(net::HttpResponseInfo* info) { void URLRequestBufferJob::GetResponseInfo(net::HttpResponseInfo* info) {
std::string status("HTTP/1.1 "); std::string status("HTTP/1.1 ");
status.append(base::IntToString(status_code_)); status.append(base::NumberToString(status_code_));
status.append(" "); status.append(" ");
status.append(net::GetHttpReasonPhrase(status_code_)); status.append(net::GetHttpReasonPhrase(status_code_));
status.append("\0\0", 2); status.append("\0\0", 2);

View File

@@ -296,7 +296,7 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
const auto& custom_standard_schemes = atom::api::GetStandardSchemes(); const auto& custom_standard_schemes = atom::api::GetStandardSchemes();
cookie_schemes.insert(cookie_schemes.end(), custom_standard_schemes.begin(), cookie_schemes.insert(cookie_schemes.end(), custom_standard_schemes.begin(),
custom_standard_schemes.end()); custom_standard_schemes.end());
cookie_monster->SetCookieableSchemes(cookie_schemes); cookie_monster->SetCookieableSchemes(cookie_schemes, base::NullCallback());
// Setup handlers for custom job factory. // Setup handlers for custom job factory.
top_job_factory_.reset(new AtomURLRequestJobFactory); top_job_factory_.reset(new AtomURLRequestJobFactory);

View File

@@ -48,7 +48,7 @@ void BeforeStartInUI(base::WeakPtr<URLRequestStreamJob> job,
status_code = 200; status_code = 200;
} }
std::string status("HTTP/1.1 "); std::string status("HTTP/1.1 ");
status.append(base::IntToString(status_code)); status.append(base::NumberToString(status_code));
status.append(" "); status.append(" ");
status.append( status.append(
net::GetHttpReasonPhrase(static_cast<net::HttpStatusCode>(status_code))); net::GetHttpReasonPhrase(static_cast<net::HttpStatusCode>(status_code)));

View File

@@ -37,13 +37,13 @@ void NodeDebugger::Start() {
} }
node::DebugOptions options; node::DebugOptions options;
node::options_parser::DebugOptionsParser options_parser;
std::vector<std::string> exec_args; std::vector<std::string> exec_args;
std::vector<std::string> v8_args; std::vector<std::string> v8_args;
std::vector<std::string> errors; std::vector<std::string> errors;
node::options_parser::DebugOptionsParser::instance.Parse( options_parser.Parse(&args, &exec_args, &v8_args, &options,
&args, &exec_args, &v8_args, &options, node::options_parser::kDisallowedInEnvironment, &errors);
node::options_parser::kDisallowedInEnvironment, &errors);
if (!errors.empty()) { if (!errors.empty()) {
// TODO(jeremy): what's the appropriate behaviour here? // TODO(jeremy): what's the appropriate behaviour here?
@@ -51,13 +51,6 @@ void NodeDebugger::Start() {
<< base::JoinString(errors, " "); << base::JoinString(errors, " ");
} }
// Set process._debugWaitConnect if --inspect-brk was specified to stop
// the debugger on the first line
if (options.wait_for_connect()) {
mate::Dictionary process(env_->isolate(), env_->process_object());
process.Set("_breakFirstLine", true);
}
const char* path = ""; const char* path = "";
if (inspector->Start(path, options, if (inspector->Start(path, options,
std::make_shared<node::HostPort>(options.host_port), std::make_shared<node::HostPort>(options.host_port),
@@ -65,4 +58,10 @@ void NodeDebugger::Start() {
DCHECK(env_->inspector_agent()->IsListening()); DCHECK(env_->inspector_agent()->IsListening());
} }
void NodeDebugger::Stop() {
auto* inspector = env_->inspector_agent();
if (inspector && inspector->IsListening())
inspector->Stop();
}
} // namespace atom } // namespace atom

View File

@@ -20,6 +20,7 @@ class NodeDebugger {
~NodeDebugger(); ~NodeDebugger();
void Start(); void Start();
void Stop();
private: private:
node::Environment* env_; node::Environment* env_;

View File

@@ -79,7 +79,6 @@ PlatformNotificationService::~PlatformNotificationService() {}
void PlatformNotificationService::DisplayNotification( void PlatformNotificationService::DisplayNotification(
content::RenderProcessHost* render_process_host, content::RenderProcessHost* render_process_host,
content::BrowserContext* browser_context,
const std::string& notification_id, const std::string& notification_id,
const GURL& origin, const GURL& origin,
const blink::PlatformNotificationData& notification_data, const blink::PlatformNotificationData& notification_data,
@@ -100,7 +99,6 @@ void PlatformNotificationService::DisplayNotification(
} }
void PlatformNotificationService::DisplayPersistentNotification( void PlatformNotificationService::DisplayPersistentNotification(
content::BrowserContext* browser_context,
const std::string& notification_id, const std::string& notification_id,
const GURL& service_worker_scope, const GURL& service_worker_scope,
const GURL& origin, const GURL& origin,
@@ -108,11 +106,9 @@ void PlatformNotificationService::DisplayPersistentNotification(
const blink::NotificationResources& notification_resources) {} const blink::NotificationResources& notification_resources) {}
void PlatformNotificationService::ClosePersistentNotification( void PlatformNotificationService::ClosePersistentNotification(
content::BrowserContext* browser_context,
const std::string& notification_id) {} const std::string& notification_id) {}
void PlatformNotificationService::CloseNotification( void PlatformNotificationService::CloseNotification(
content::BrowserContext* browser_context,
const std::string& notification_id) { const std::string& notification_id) {
auto* presenter = browser_client_->GetNotificationPresenter(); auto* presenter = browser_client_->GetNotificationPresenter();
if (!presenter) if (!presenter)
@@ -121,25 +117,19 @@ void PlatformNotificationService::CloseNotification(
} }
void PlatformNotificationService::GetDisplayedNotifications( void PlatformNotificationService::GetDisplayedNotifications(
content::BrowserContext* browser_context,
DisplayedNotificationsCallback callback) {} DisplayedNotificationsCallback callback) {}
int64_t PlatformNotificationService::ReadNextPersistentNotificationId( int64_t PlatformNotificationService::ReadNextPersistentNotificationId() {
content::BrowserContext* browser_context) {
// Electron doesn't support persistent notifications. // Electron doesn't support persistent notifications.
return 0; return 0;
} }
void PlatformNotificationService::RecordNotificationUkmEvent( void PlatformNotificationService::RecordNotificationUkmEvent(
content::BrowserContext* browser_context,
const content::NotificationDatabaseData& data) {} const content::NotificationDatabaseData& data) {}
void PlatformNotificationService::ScheduleTrigger( void PlatformNotificationService::ScheduleTrigger(base::Time timestamp) {}
content::BrowserContext* browser_context,
base::Time timestamp) {}
base::Time PlatformNotificationService::ReadNextTriggerTimestamp( base::Time PlatformNotificationService::ReadNextTriggerTimestamp() {
content::BrowserContext* browser_context) {
return base::Time::Max(); return base::Time::Max();
} }

View File

@@ -8,7 +8,6 @@
#include <set> #include <set>
#include <string> #include <string>
#include "content/public/browser/browser_context.h"
#include "content/public/browser/platform_notification_service.h" #include "content/public/browser/platform_notification_service.h"
namespace atom { namespace atom {
@@ -25,34 +24,25 @@ class PlatformNotificationService
// content::PlatformNotificationService: // content::PlatformNotificationService:
void DisplayNotification( void DisplayNotification(
content::RenderProcessHost* render_process_host, content::RenderProcessHost* render_process_host,
content::BrowserContext* browser_context,
const std::string& notification_id, const std::string& notification_id,
const GURL& origin, const GURL& origin,
const blink::PlatformNotificationData& notification_data, const blink::PlatformNotificationData& notification_data,
const blink::NotificationResources& notification_resources) override; const blink::NotificationResources& notification_resources) override;
void DisplayPersistentNotification( void DisplayPersistentNotification(
content::BrowserContext* browser_context,
const std::string& notification_id, const std::string& notification_id,
const GURL& service_worker_scope, const GURL& service_worker_scope,
const GURL& origin, const GURL& origin,
const blink::PlatformNotificationData& notification_data, const blink::PlatformNotificationData& notification_data,
const blink::NotificationResources& notification_resources) override; const blink::NotificationResources& notification_resources) override;
void ClosePersistentNotification(content::BrowserContext* browser_context, void ClosePersistentNotification(const std::string& notification_id) override;
const std::string& notification_id) override; void CloseNotification(const std::string& notification_id) override;
void CloseNotification(content::BrowserContext* browser_context,
const std::string& notification_id) override;
void GetDisplayedNotifications( void GetDisplayedNotifications(
content::BrowserContext* browser_context,
DisplayedNotificationsCallback callback) override; DisplayedNotificationsCallback callback) override;
int64_t ReadNextPersistentNotificationId( int64_t ReadNextPersistentNotificationId() override;
content::BrowserContext* browser_context) override;
void RecordNotificationUkmEvent( void RecordNotificationUkmEvent(
content::BrowserContext* browser_context,
const content::NotificationDatabaseData& data) override; const content::NotificationDatabaseData& data) override;
void ScheduleTrigger(content::BrowserContext* browser_context, void ScheduleTrigger(base::Time timestamp) override;
base::Time timestamp) override; base::Time ReadNextTriggerTimestamp() override;
base::Time ReadNextTriggerTimestamp(
content::BrowserContext* browser_context) override;
private: private:
AtomBrowserClient* browser_client_; AtomBrowserClient* browser_client_;

View File

@@ -14,7 +14,7 @@
#include "atom/browser/notifications/win/windows_toast_notification.h" #include "atom/browser/notifications/win/windows_toast_notification.h"
#include "base/environment.h" #include "base/environment.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/md5.h" #include "base/hash/md5.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "base/time/time.h" #include "base/time/time.h"
@@ -47,7 +47,7 @@ bool SaveIconToPath(const SkBitmap& bitmap, const base::FilePath& path) {
// static // static
NotificationPresenter* NotificationPresenter::Create() { NotificationPresenter* NotificationPresenter::Create() {
auto version = base::win::GetVersion(); auto version = base::win::GetVersion();
if (version < base::win::VERSION_WIN8) if (version < base::win::Version::WIN8)
return new NotificationPresenterWin7; return new NotificationPresenterWin7;
if (!WindowsToastNotification::Initialize()) if (!WindowsToastNotification::Initialize())
return nullptr; return nullptr;

View File

@@ -6,6 +6,7 @@
#include <utility> #include <utility>
#include "base/memory/shared_memory.h"
#include "components/viz/common/resources/resource_format.h" #include "components/viz/common/resources/resource_format.h"
#include "components/viz/common/resources/resource_sizes.h" #include "components/viz/common/resources/resource_sizes.h"
#include "mojo/public/cpp/system/platform_handle.h" #include "mojo/public/cpp/system/platform_handle.h"

View File

@@ -8,7 +8,7 @@
#include <memory> #include <memory>
#include "base/callback.h" #include "base/callback.h"
#include "base/memory/shared_memory.h" #include "base/memory/shared_memory_mapping.h"
#include "components/viz/host/host_display_client.h" #include "components/viz/host/host_display_client.h"
#include "services/viz/privileged/interfaces/compositing/layered_window_updater.mojom.h" #include "services/viz/privileged/interfaces/compositing/layered_window_updater.mojom.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"

View File

@@ -351,7 +351,7 @@ void OffScreenRenderWidgetHostView::SetBounds(const gfx::Rect& new_bounds) {
SetSize(new_bounds.size()); SetSize(new_bounds.size());
} }
gfx::NativeView OffScreenRenderWidgetHostView::GetNativeView() const { gfx::NativeView OffScreenRenderWidgetHostView::GetNativeView() {
return gfx::NativeView(); return gfx::NativeView();
} }
@@ -366,11 +366,11 @@ ui::TextInputClient* OffScreenRenderWidgetHostView::GetTextInputClient() {
void OffScreenRenderWidgetHostView::Focus() {} void OffScreenRenderWidgetHostView::Focus() {}
bool OffScreenRenderWidgetHostView::HasFocus() const { bool OffScreenRenderWidgetHostView::HasFocus() {
return false; return false;
} }
bool OffScreenRenderWidgetHostView::IsSurfaceAvailableForCopy() const { bool OffScreenRenderWidgetHostView::IsSurfaceAvailableForCopy() {
return GetDelegatedFrameHost()->CanCopyFromCompositingSurface(); return GetDelegatedFrameHost()->CanCopyFromCompositingSurface();
} }
@@ -411,7 +411,7 @@ void OffScreenRenderWidgetHostView::EnsureSurfaceSynchronizedForWebTest() {
SynchronizeVisualProperties(); SynchronizeVisualProperties();
} }
gfx::Rect OffScreenRenderWidgetHostView::GetViewBounds() const { gfx::Rect OffScreenRenderWidgetHostView::GetViewBounds() {
if (IsPopupWidget()) if (IsPopupWidget())
return popup_position_; return popup_position_;
@@ -429,8 +429,7 @@ void OffScreenRenderWidgetHostView::SetBackgroundColor(SkColor color) {
} }
} }
base::Optional<SkColor> OffScreenRenderWidgetHostView::GetBackgroundColor() base::Optional<SkColor> OffScreenRenderWidgetHostView::GetBackgroundColor() {
const {
return background_color_; return background_color_;
} }
@@ -438,7 +437,7 @@ void OffScreenRenderWidgetHostView::UpdateBackgroundColor() {
NOTREACHED(); NOTREACHED();
} }
gfx::Size OffScreenRenderWidgetHostView::GetVisibleViewportSize() const { gfx::Size OffScreenRenderWidgetHostView::GetVisibleViewportSize() {
return size_; return size_;
} }
@@ -532,8 +531,7 @@ void OffScreenRenderWidgetHostView::TextInputStateChanged(
void OffScreenRenderWidgetHostView::ImeCancelComposition() {} void OffScreenRenderWidgetHostView::ImeCancelComposition() {}
void OffScreenRenderWidgetHostView::RenderProcessGone(base::TerminationStatus, void OffScreenRenderWidgetHostView::RenderProcessGone() {
int) {
Destroy(); Destroy();
} }
@@ -580,7 +578,7 @@ void OffScreenRenderWidgetHostView::CopyFromSurface(
} }
void OffScreenRenderWidgetHostView::GetScreenInfo( void OffScreenRenderWidgetHostView::GetScreenInfo(
content::ScreenInfo* screen_info) const { content::ScreenInfo* screen_info) {
screen_info->depth = 24; screen_info->depth = 24;
screen_info->depth_per_component = 8; screen_info->depth_per_component = 8;
screen_info->orientation_angle = 0; screen_info->orientation_angle = 0;
@@ -621,8 +619,7 @@ void OffScreenRenderWidgetHostView::ImeCompositionRangeChanged(
const gfx::Range&, const gfx::Range&,
const std::vector<gfx::Rect>&) {} const std::vector<gfx::Rect>&) {}
gfx::Size OffScreenRenderWidgetHostView::GetCompositorViewportPixelSize() gfx::Size OffScreenRenderWidgetHostView::GetCompositorViewportPixelSize() {
const {
return gfx::ScaleToCeiledSize(GetRequestedRendererSize(), return gfx::ScaleToCeiledSize(GetRequestedRendererSize(),
current_device_scale_factor_); current_device_scale_factor_);
} }

View File

@@ -84,22 +84,22 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase,
void InitAsChild(gfx::NativeView) override; void InitAsChild(gfx::NativeView) override;
void SetSize(const gfx::Size&) override; void SetSize(const gfx::Size&) override;
void SetBounds(const gfx::Rect&) override; void SetBounds(const gfx::Rect&) override;
gfx::NativeView GetNativeView(void) const override; gfx::NativeView GetNativeView(void) override;
gfx::NativeViewAccessible GetNativeViewAccessible(void) override; gfx::NativeViewAccessible GetNativeViewAccessible(void) override;
ui::TextInputClient* GetTextInputClient() override; ui::TextInputClient* GetTextInputClient() override;
void Focus(void) override; void Focus(void) override;
bool HasFocus(void) const override; bool HasFocus(void) override;
uint32_t GetCaptureSequenceNumber() const override; uint32_t GetCaptureSequenceNumber() const override;
bool IsSurfaceAvailableForCopy(void) const override; bool IsSurfaceAvailableForCopy(void) override;
void Show(void) override; void Show(void) override;
void Hide(void) override; void Hide(void) override;
bool IsShowing(void) override; bool IsShowing(void) override;
void EnsureSurfaceSynchronizedForWebTest() override; void EnsureSurfaceSynchronizedForWebTest() override;
gfx::Rect GetViewBounds(void) const override; gfx::Rect GetViewBounds(void) override;
gfx::Size GetVisibleViewportSize() const override; gfx::Size GetVisibleViewportSize() override;
void SetInsets(const gfx::Insets&) override; void SetInsets(const gfx::Insets&) override;
void SetBackgroundColor(SkColor color) override; void SetBackgroundColor(SkColor color) override;
base::Optional<SkColor> GetBackgroundColor() const override; base::Optional<SkColor> GetBackgroundColor() override;
void UpdateBackgroundColor() override; void UpdateBackgroundColor() override;
bool LockMouse(void) override; bool LockMouse(void) override;
void UnlockMouse(void) override; void UnlockMouse(void) override;
@@ -131,7 +131,7 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase,
void SetIsLoading(bool is_loading) override; void SetIsLoading(bool is_loading) override;
void TextInputStateChanged(const content::TextInputState& params) override; void TextInputStateChanged(const content::TextInputState& params) override;
void ImeCancelComposition(void) override; void ImeCancelComposition(void) override;
void RenderProcessGone(base::TerminationStatus, int) override; void RenderProcessGone() override;
void Destroy(void) override; void Destroy(void) override;
void SetTooltipText(const base::string16&) override; void SetTooltipText(const base::string16&) override;
content::CursorManager* GetCursorManager() override; content::CursorManager* GetCursorManager() override;
@@ -139,7 +139,7 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase,
const gfx::Rect& src_rect, const gfx::Rect& src_rect,
const gfx::Size& output_size, const gfx::Size& output_size,
base::OnceCallback<void(const SkBitmap&)> callback) override; base::OnceCallback<void(const SkBitmap&)> callback) override;
void GetScreenInfo(content::ScreenInfo* results) const override; void GetScreenInfo(content::ScreenInfo* results) override;
void InitAsGuest(content::RenderWidgetHostView*, void InitAsGuest(content::RenderWidgetHostView*,
content::RenderWidgetHostViewGuest*) override; content::RenderWidgetHostViewGuest*) override;
void TransformPointToRootSurface(gfx::PointF* point) override; void TransformPointToRootSurface(gfx::PointF* point) override;
@@ -149,7 +149,7 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase,
CreateSyntheticGestureTarget() override; CreateSyntheticGestureTarget() override;
void ImeCompositionRangeChanged(const gfx::Range&, void ImeCompositionRangeChanged(const gfx::Range&,
const std::vector<gfx::Rect>&) override; const std::vector<gfx::Rect>&) override;
gfx::Size GetCompositorViewportPixelSize() const override; gfx::Size GetCompositorViewportPixelSize() override;
content::RenderWidgetHostViewBase* CreateViewForWidget( content::RenderWidgetHostViewBase* CreateViewForWidget(
content::RenderWidgetHost*, content::RenderWidgetHost*,

View File

@@ -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>6.0.0-nightly.20190404</string> <string>6.0.0-beta.4</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>6.0.0-nightly.20190404</string> <string>6.0.0-beta.4</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>

View File

@@ -50,8 +50,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 6,0,0,20190404 FILEVERSION 6,0,0,4
PRODUCTVERSION 6,0,0,20190404 PRODUCTVERSION 6,0,0,4
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L

View File

@@ -10,6 +10,8 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
@interface NSColor (Hex) @interface NSColor (Hex)
- (NSString*)hexadecimalValue;
- (NSString*)RGBAValue;
+ (NSColor*)colorWithHexColorString:(NSString*)hex; + (NSColor*)colorWithHexColorString:(NSString*)hex;
@end @end

View File

@@ -8,17 +8,65 @@
@implementation NSColor (Hex) @implementation NSColor (Hex)
- (NSString*)RGBAValue {
double redFloatValue, greenFloatValue, blueFloatValue, alphaFloatValue;
NSColor* convertedColor =
[self colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
if (convertedColor) {
[convertedColor getRed:&redFloatValue
green:&greenFloatValue
blue:&blueFloatValue
alpha:&alphaFloatValue];
int redIntValue = redFloatValue * 255.99999f;
int greenIntValue = greenFloatValue * 255.99999f;
int blueIntValue = blueFloatValue * 255.99999f;
int alphaIntValue = alphaFloatValue * 255.99999f;
return
[NSString stringWithFormat:@"%02x%02x%02x%02x", redIntValue,
greenIntValue, blueIntValue, alphaIntValue];
}
return nil;
}
- (NSString*)hexadecimalValue {
double redFloatValue, greenFloatValue, blueFloatValue;
NSColor* convertedColor =
[self colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
if (convertedColor) {
[convertedColor getRed:&redFloatValue
green:&greenFloatValue
blue:&blueFloatValue
alpha:NULL];
int redIntValue = redFloatValue * 255.99999f;
int greenIntValue = greenFloatValue * 255.99999f;
int blueIntValue = blueFloatValue * 255.99999f;
return [NSString stringWithFormat:@"#%02x%02x%02x", redIntValue,
greenIntValue, blueIntValue];
}
return nil;
}
+ (NSColor*)colorWithHexColorString:(NSString*)inColorString { + (NSColor*)colorWithHexColorString:(NSString*)inColorString {
unsigned colorCode = 0; unsigned colorCode = 0;
unsigned char redByte, greenByte, blueByte;
if (inColorString) { if (inColorString) {
NSScanner* scanner = [NSScanner scannerWithString:inColorString]; NSScanner* scanner = [NSScanner scannerWithString:inColorString];
(void)[scanner scanHexInt:&colorCode]; // ignore error (void)[scanner scanHexInt:&colorCode]; // ignore error
} }
redByte = (unsigned char)(colorCode >> 16);
greenByte = (unsigned char)(colorCode >> 8); unsigned char redByte = (unsigned char)(colorCode >> 16);
blueByte = (unsigned char)(colorCode); // masks off high bits unsigned char greenByte = (unsigned char)(colorCode >> 8);
unsigned char blueByte = (unsigned char)(colorCode); // masks off high bits
return [NSColor colorWithCalibratedRed:(CGFloat)redByte / 0xff return [NSColor colorWithCalibratedRed:(CGFloat)redByte / 0xff
green:(CGFloat)greenByte / 0xff green:(CGFloat)greenByte / 0xff

View File

@@ -117,7 +117,7 @@ void RunSaveDialogInNewThread(const RunState& run_state,
bool result = ShowSaveDialogSync(settings, &path); bool result = ShowSaveDialogSync(settings, &path);
run_state.ui_task_runner->PostTask( run_state.ui_task_runner->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&OnSaveDialogDone, std::move(promise), result, path)); base::BindOnce(&OnSaveDialogDone, std::move(promise), !result, path));
run_state.ui_task_runner->DeleteSoon(FROM_HERE, run_state.dialog_thread); run_state.ui_task_runner->DeleteSoon(FROM_HERE, run_state.dialog_thread);
} }
@@ -320,7 +320,7 @@ void ShowSaveDialog(const DialogSettings& settings,
RunState run_state; RunState run_state;
if (!CreateDialogThread(&run_state)) { if (!CreateDialogThread(&run_state)) {
mate::Dictionary dict = mate::Dictionary::CreateEmpty(promise.isolate()); mate::Dictionary dict = mate::Dictionary::CreateEmpty(promise.isolate());
dict.Set("canceled", false); dict.Set("canceled", true);
dict.Set("filePath", base::FilePath()); dict.Set("filePath", base::FilePath());
promise.Resolve(dict.GetHandle()); promise.Resolve(dict.GetHandle());
} else { } else {

View File

@@ -41,6 +41,7 @@
#include "net/http/http_response_headers.h" #include "net/http/http_response_headers.h"
#include "services/network/public/cpp/simple_url_loader.h" #include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/cpp/simple_url_loader_stream_consumer.h" #include "services/network/public/cpp/simple_url_loader_stream_consumer.h"
#include "third_party/blink/public/common/logging/logging_utils.h"
#include "ui/display/display.h" #include "ui/display/display.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
@@ -779,11 +780,13 @@ void InspectableWebContentsImpl::WebContentsDestroyed() {
bool InspectableWebContentsImpl::DidAddMessageToConsole( bool InspectableWebContentsImpl::DidAddMessageToConsole(
content::WebContents* source, content::WebContents* source,
int32_t level, blink::mojom::ConsoleMessageLevel level,
const base::string16& message, const base::string16& message,
int32_t line_no, int32_t line_no,
const base::string16& source_id) { const base::string16& source_id) {
logging::LogMessage("CONSOLE", line_no, level).stream() logging::LogMessage("CONSOLE", line_no,
blink::ConsoleMessageLevelToLogSeverity(level))
.stream()
<< "\"" << message << "\", source: " << source_id << " (" << line_no << "\"" << message << "\", source: " << source_id << " (" << line_no
<< ")"; << ")";
return true; return true;

View File

@@ -143,6 +143,9 @@ class InspectableWebContentsImpl
int boundary_value) override {} int boundary_value) override {}
void ReadyForTest() override {} void ReadyForTest() override {}
void SetOpenNewWindowForPopups(bool value) override {} void SetOpenNewWindowForPopups(bool value) override {}
void RecordPerformanceHistogram(const std::string& name,
double duration) override {}
void RecordUserMetricsAction(const std::string& name) override {}
// content::DevToolsFrontendHostDelegate: // content::DevToolsFrontendHostDelegate:
void HandleMessageFromDevToolsFrontend(const std::string& message); void HandleMessageFromDevToolsFrontend(const std::string& message);
@@ -165,7 +168,7 @@ class InspectableWebContentsImpl
// content::WebContentsDelegate: // content::WebContentsDelegate:
bool DidAddMessageToConsole(content::WebContents* source, bool DidAddMessageToConsole(content::WebContents* source,
int32_t level, blink::mojom::ConsoleMessageLevel level,
const base::string16& message, const base::string16& message,
int32_t line_no, int32_t line_no,
const base::string16& source_id) override; const base::string16& source_id) override;

View File

@@ -150,10 +150,10 @@ void AutofillPopupView::OnSelectedRowChanged(
if (current_row_selection) { if (current_row_selection) {
int selected = current_row_selection.value_or(-1); int selected = current_row_selection.value_or(-1);
if (selected == -1 || selected >= child_count()) if (selected == -1 || static_cast<size_t>(selected) >= children().size())
return; return;
child_at(selected)->NotifyAccessibilityEvent(ax::mojom::Event::kSelection, children().at(selected)->NotifyAccessibilityEvent(
true); ax::mojom::Event::kSelection, true);
} }
} }
@@ -232,7 +232,8 @@ void AutofillPopupView::DoUpdateBoundsAndRedrawPopup() {
} }
void AutofillPopupView::OnPaint(gfx::Canvas* canvas) { void AutofillPopupView::OnPaint(gfx::Canvas* canvas) {
if (!popup_ || popup_->GetLineCount() != child_count()) if (!popup_ ||
static_cast<size_t>(popup_->GetLineCount()) != children().size())
return; return;
gfx::Canvas* draw_canvas = canvas; gfx::Canvas* draw_canvas = canvas;
SkBitmap bitmap; SkBitmap bitmap;

View File

@@ -255,7 +255,7 @@ const char* MenuBar::GetClassName() const {
return kViewClassName; return kViewClassName;
} }
void MenuBar::OnMenuButtonClicked(views::MenuButton* source, void MenuBar::OnMenuButtonClicked(views::Button* source,
const gfx::Point& point, const gfx::Point& point,
const ui::Event* event) { const ui::Event* event) {
// Hide the accelerator when a submenu is activated. // Hide the accelerator when a submenu is activated.

View File

@@ -16,8 +16,9 @@
#include "ui/views/view.h" #include "ui/views/view.h"
namespace views { namespace views {
class Button;
class MenuButton; class MenuButton;
} } // namespace views
namespace atom { namespace atom {
@@ -78,7 +79,7 @@ class MenuBar : public views::AccessiblePaneView,
const char* GetClassName() const override; const char* GetClassName() const override;
// views::MenuButtonListener: // views::MenuButtonListener:
void OnMenuButtonClicked(views::MenuButton* source, void OnMenuButtonClicked(views::Button* source,
const gfx::Point& point, const gfx::Point& point,
const ui::Event* event) override; const ui::Event* event) override;
void OnNativeThemeChanged(const ui::NativeTheme* theme) override; void OnNativeThemeChanged(const ui::NativeTheme* theme) override;

View File

@@ -22,7 +22,7 @@ MenuDelegate::MenuDelegate(MenuBar* menu_bar)
MenuDelegate::~MenuDelegate() {} MenuDelegate::~MenuDelegate() {}
void MenuDelegate::RunMenu(AtomMenuModel* model, void MenuDelegate::RunMenu(AtomMenuModel* model,
views::MenuButton* button, views::Button* button,
ui::MenuSourceType source_type) { ui::MenuSourceType source_type) {
gfx::Point screen_loc; gfx::Point screen_loc;
views::View::ConvertPointToScreen(button, &screen_loc); views::View::ConvertPointToScreen(button, &screen_loc);
@@ -43,8 +43,10 @@ void MenuDelegate::RunMenu(AtomMenuModel* model,
menu_runner_.reset(new views::MenuRunner( menu_runner_.reset(new views::MenuRunner(
item, item,
views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS)); views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS));
menu_runner_->RunMenuAt(button->GetWidget()->GetTopLevelWidget(), button, menu_runner_->RunMenuAt(
bounds, views::MENU_ANCHOR_TOPRIGHT, source_type); button->GetWidget()->GetTopLevelWidget(),
static_cast<views::MenuButton*>(button)->button_controller(), bounds,
views::MenuAnchorPosition::kTopRight, source_type);
} }
void MenuDelegate::ExecuteCommand(int id) { void MenuDelegate::ExecuteCommand(int id) {

View File

@@ -13,7 +13,8 @@
namespace views { namespace views {
class MenuRunner; class MenuRunner;
} class Button;
} // namespace views
namespace atom { namespace atom {
@@ -25,7 +26,7 @@ class MenuDelegate : public views::MenuDelegate {
~MenuDelegate() override; ~MenuDelegate() override;
void RunMenu(AtomMenuModel* model, void RunMenu(AtomMenuModel* model,
views::MenuButton* button, views::Button* button,
ui::MenuSourceType source_type); ui::MenuSourceType source_type);
class Observer { class Observer {

View File

@@ -92,10 +92,10 @@ void RootView::SetMenuBarVisibility(bool visible) {
menu_bar_visible_ = visible; menu_bar_visible_ = visible;
if (visible) { if (visible) {
DCHECK_EQ(child_count(), 1); DCHECK_EQ(children().size(), 1ul);
AddChildView(menu_bar_.get()); AddChildView(menu_bar_.get());
} else { } else {
DCHECK_EQ(child_count(), 2); DCHECK_EQ(children().size(), 2ul);
RemoveChildView(menu_bar_.get()); RemoveChildView(menu_bar_.get());
} }

View File

@@ -23,6 +23,7 @@ bool AppendTask(const JumpListItem& item, IObjectCollection* collection) {
if (FAILED(link.CoCreateInstance(CLSID_ShellLink)) || if (FAILED(link.CoCreateInstance(CLSID_ShellLink)) ||
FAILED(link->SetPath(item.path.value().c_str())) || FAILED(link->SetPath(item.path.value().c_str())) ||
FAILED(link->SetArguments(item.arguments.c_str())) || FAILED(link->SetArguments(item.arguments.c_str())) ||
FAILED(link->SetWorkingDirectory(item.working_dir.value().c_str())) ||
FAILED(link->SetDescription(item.description.c_str()))) FAILED(link->SetDescription(item.description.c_str())))
return false; return false;
@@ -86,6 +87,8 @@ bool ConvertShellLinkToJumpListItem(IShellLink* shell_link,
if (FAILED(shell_link->GetPath(path, MAX_PATH, nullptr, 0))) if (FAILED(shell_link->GetPath(path, MAX_PATH, nullptr, 0)))
return false; return false;
item->path = base::FilePath(path);
CComQIPtr<IPropertyStore> property_store = shell_link; CComQIPtr<IPropertyStore> property_store = shell_link;
base::win::ScopedPropVariant prop; base::win::ScopedPropVariant prop;
if (SUCCEEDED( if (SUCCEEDED(
@@ -99,6 +102,9 @@ bool ConvertShellLinkToJumpListItem(IShellLink* shell_link,
item->title = prop.get().pwszVal; item->title = prop.get().pwszVal;
} }
if (SUCCEEDED(shell_link->GetWorkingDirectory(path, base::size(path))))
item->working_dir = base::FilePath(path);
int icon_index; int icon_index;
if (SUCCEEDED(shell_link->GetIconLocation(path, MAX_PATH, &icon_index))) { if (SUCCEEDED(shell_link->GetIconLocation(path, MAX_PATH, &icon_index))) {
item->icon_path = base::FilePath(path); item->icon_path = base::FilePath(path);

View File

@@ -49,6 +49,7 @@ struct JumpListItem {
base::string16 arguments; base::string16 arguments;
base::string16 title; base::string16 title;
base::string16 description; base::string16 description;
base::FilePath working_dir;
base::FilePath icon_path; base::FilePath icon_path;
int icon_index = 0; int icon_index = 0;

View File

@@ -169,7 +169,8 @@ void NotifyIcon::PopUpContextMenu(const gfx::Point& pos,
views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS, views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS,
base::Bind(&NotifyIcon::OnContextMenuClosed, base::Bind(&NotifyIcon::OnContextMenuClosed,
weak_factory_.GetWeakPtr()))); weak_factory_.GetWeakPtr())));
menu_runner_->RunMenuAt(widget_.get(), NULL, rect, views::MENU_ANCHOR_TOPLEFT, menu_runner_->RunMenuAt(widget_.get(), NULL, rect,
views::MenuAnchorPosition::kTopLeft,
ui::MENU_SOURCE_MOUSE); ui::MENU_SOURCE_MOUSE);
} }

View File

@@ -128,10 +128,10 @@ WebContentsPreferences::WebContentsPreferences(
SetDefaultBoolIfUndefined(options::kNativeWindowOpen, false); SetDefaultBoolIfUndefined(options::kNativeWindowOpen, false);
SetDefaultBoolIfUndefined(options::kEnableRemoteModule, true); SetDefaultBoolIfUndefined(options::kEnableRemoteModule, true);
SetDefaultBoolIfUndefined(options::kContextIsolation, false); SetDefaultBoolIfUndefined(options::kContextIsolation, false);
SetDefaultBoolIfUndefined("javascript", true); SetDefaultBoolIfUndefined(options::kJavaScript, true);
SetDefaultBoolIfUndefined("images", true); SetDefaultBoolIfUndefined(options::kImages, true);
SetDefaultBoolIfUndefined("textAreasAreResizable", true); SetDefaultBoolIfUndefined(options::kTextAreasAreResizable, true);
SetDefaultBoolIfUndefined("webgl", true); SetDefaultBoolIfUndefined(options::kWebGL, true);
bool webSecurity = true; bool webSecurity = true;
SetDefaultBoolIfUndefined(options::kWebSecurity, webSecurity); SetDefaultBoolIfUndefined(options::kWebSecurity, webSecurity);
// If webSecurity was explicity set to false, let's inherit that into // If webSecurity was explicity set to false, let's inherit that into
@@ -335,13 +335,13 @@ void WebContentsPreferences::AppendCommandLineSwitches(
int guest_instance_id = 0; int guest_instance_id = 0;
if (GetAsInteger(&preference_, options::kGuestInstanceID, &guest_instance_id)) if (GetAsInteger(&preference_, options::kGuestInstanceID, &guest_instance_id))
command_line->AppendSwitchASCII(switches::kGuestInstanceID, command_line->AppendSwitchASCII(switches::kGuestInstanceID,
base::IntToString(guest_instance_id)); base::NumberToString(guest_instance_id));
// Pass the opener's window id. // Pass the opener's window id.
int opener_id; int opener_id;
if (GetAsInteger(&preference_, options::kOpenerID, &opener_id)) if (GetAsInteger(&preference_, options::kOpenerID, &opener_id))
command_line->AppendSwitchASCII(switches::kOpenerID, command_line->AppendSwitchASCII(switches::kOpenerID,
base::IntToString(opener_id)); base::NumberToString(opener_id));
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
// Enable scroll bounce. // Enable scroll bounce.
@@ -405,19 +405,20 @@ void WebContentsPreferences::AppendCommandLineSwitches(
void WebContentsPreferences::OverrideWebkitPrefs( void WebContentsPreferences::OverrideWebkitPrefs(
content::WebPreferences* prefs) { content::WebPreferences* prefs) {
prefs->javascript_enabled = IsEnabled("javascript", true /* default_value */); prefs->javascript_enabled =
prefs->images_enabled = IsEnabled("images", true /* default_value */); IsEnabled(options::kJavaScript, true /* default_value */);
prefs->images_enabled = IsEnabled(options::kImages, true /* default_value */);
prefs->text_areas_are_resizable = prefs->text_areas_are_resizable =
IsEnabled("textAreasAreResizable", true /* default_value */); IsEnabled(options::kTextAreasAreResizable, true /* default_value */);
prefs->navigate_on_drag_drop = prefs->navigate_on_drag_drop =
IsEnabled("navigateOnDragDrop", false /* default_value */); IsEnabled(options::kNavigateOnDragDrop, false /* default_value */);
if (!GetAsAutoplayPolicy(&preference_, "autoplayPolicy", if (!GetAsAutoplayPolicy(&preference_, "autoplayPolicy",
&prefs->autoplay_policy)) { &prefs->autoplay_policy)) {
prefs->autoplay_policy = content::AutoplayPolicy::kNoUserGestureRequired; prefs->autoplay_policy = content::AutoplayPolicy::kNoUserGestureRequired;
} }
// Check if webgl should be enabled. // Check if webgl should be enabled.
bool is_webgl_enabled = IsEnabled("webgl", true /* default_value */); bool is_webgl_enabled = IsEnabled(options::kWebGL, true /* default_value */);
prefs->webgl1_enabled = is_webgl_enabled; prefs->webgl1_enabled = is_webgl_enabled;
prefs->webgl2_enabled = is_webgl_enabled; prefs->webgl2_enabled = is_webgl_enabled;

View File

@@ -24,6 +24,7 @@
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_observer.h"
#include "native_mate/dictionary.h"
#include "net/base/mime_util.h" #include "net/base/mime_util.h"
#include "ui/shell_dialogs/selected_file_info.h" #include "ui/shell_dialogs/selected_file_info.h"
@@ -51,9 +52,10 @@ class FileSelectHelper : public base::RefCounted<FileSelectHelper>,
v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::Isolate* isolate = v8::Isolate::GetCurrent();
atom::util::Promise promise(isolate); atom::util::Promise promise(isolate);
file_dialog::ShowOpenDialog(settings, std::move(promise));
auto callback = base::Bind(&FileSelectHelper::OnOpenDialogDone, this); auto callback = base::Bind(&FileSelectHelper::OnOpenDialogDone, this);
ignore_result(promise.Then(callback)); ignore_result(promise.Then(callback));
file_dialog::ShowOpenDialog(settings, std::move(promise));
} }
void ShowSaveDialog(const file_dialog::DialogSettings& settings) { void ShowSaveDialog(const file_dialog::DialogSettings& settings) {
@@ -74,45 +76,43 @@ class FileSelectHelper : public base::RefCounted<FileSelectHelper>,
~FileSelectHelper() override {} ~FileSelectHelper() override {}
#if defined(MAS_BUILD) void OnOpenDialogDone(mate::Dictionary result) {
void OnOpenDialogDone(bool result,
const std::vector<base::FilePath>& paths,
const std::vector<std::string>& bookmarks)
#else
void OnOpenDialogDone(bool result, const std::vector<base::FilePath>& paths)
#endif
{
std::vector<FileChooserFileInfoPtr> file_info; std::vector<FileChooserFileInfoPtr> file_info;
if (result) { bool canceled = true;
for (auto& path : paths) { result.Get("canceled", &canceled);
file_info.push_back(FileChooserFileInfo::NewNativeFile(
blink::mojom::NativeFileInfo::New(
path, path.BaseName().AsUTF16Unsafe())));
}
if (render_frame_host_ && !paths.empty()) { if (!canceled) {
auto* browser_context = static_cast<atom::AtomBrowserContext*>( std::vector<base::FilePath> paths;
render_frame_host_->GetProcess()->GetBrowserContext()); if (result.Get("filePaths", &paths)) {
browser_context->prefs()->SetFilePath(prefs::kSelectFileLastDirectory, for (auto& path : paths) {
paths[0].DirName()); file_info.push_back(FileChooserFileInfo::NewNativeFile(
blink::mojom::NativeFileInfo::New(
path, path.BaseName().AsUTF16Unsafe())));
}
if (render_frame_host_ && !paths.empty()) {
auto* browser_context = static_cast<atom::AtomBrowserContext*>(
render_frame_host_->GetProcess()->GetBrowserContext());
browser_context->prefs()->SetFilePath(prefs::kSelectFileLastDirectory,
paths[0].DirName());
}
} }
} }
OnFilesSelected(std::move(file_info)); OnFilesSelected(std::move(file_info));
} }
#if defined(MAS_BUILD) void OnSaveDialogDone(mate::Dictionary result) {
void OnSaveDialogDone(bool result,
const base::FilePath& path,
const std::string& bookmark)
#else
void OnSaveDialogDone(bool result, const base::FilePath& path)
#endif
{
std::vector<FileChooserFileInfoPtr> file_info; std::vector<FileChooserFileInfoPtr> file_info;
if (result) { bool canceled = true;
file_info.push_back( result.Get("canceled", &canceled);
FileChooserFileInfo::NewNativeFile(blink::mojom::NativeFileInfo::New(
path, path.BaseName().AsUTF16Unsafe()))); if (!canceled) {
base::FilePath path;
if (result.Get("filePath", &path)) {
file_info.push_back(FileChooserFileInfo::NewNativeFile(
blink::mojom::NativeFileInfo::New(
path, path.BaseName().AsUTF16Unsafe())));
}
} }
OnFilesSelected(std::move(file_info)); OnFilesSelected(std::move(file_info));
} }
@@ -123,7 +123,6 @@ class FileSelectHelper : public base::RefCounted<FileSelectHelper>,
listener_.reset(); listener_.reset();
} }
render_frame_host_ = nullptr; render_frame_host_ = nullptr;
Release();
} }
// content::WebContentsObserver: // content::WebContentsObserver:

View File

@@ -18,7 +18,7 @@
// The message starter should be declared in ipc/ipc_message_start.h. Since // The message starter should be declared in ipc/ipc_message_start.h. Since
// we don't want to patch Chromium, we just pretend to be Content Shell. // we don't want to patch Chromium, we just pretend to be Content Shell.
#define IPC_MESSAGE_START ShellMsgStart #define IPC_MESSAGE_START ElectronMsgStart
IPC_STRUCT_TRAITS_BEGIN(atom::DraggableRegion) IPC_STRUCT_TRAITS_BEGIN(atom::DraggableRegion)
IPC_STRUCT_TRAITS_MEMBER(draggable) IPC_STRUCT_TRAITS_MEMBER(draggable)

View File

@@ -117,16 +117,11 @@ class Archive : public mate::Wrappable<Archive> {
DISALLOW_COPY_AND_ASSIGN(Archive); DISALLOW_COPY_AND_ASSIGN(Archive);
}; };
void InitAsarSupport(v8::Isolate* isolate, void InitAsarSupport(v8::Isolate* isolate, v8::Local<v8::Value> require) {
v8::Local<v8::Value> source,
v8::Local<v8::Value> require) {
// Evaluate asar_init.js. // Evaluate asar_init.js.
std::vector<v8::Local<v8::String>> asar_init_params = { std::vector<v8::Local<v8::String>> asar_init_params = {
node::FIXED_ONE_BYTE_STRING(isolate, "source"),
node::FIXED_ONE_BYTE_STRING(isolate, "require")}; node::FIXED_ONE_BYTE_STRING(isolate, "require")};
std::vector<v8::Local<v8::Value>> asar_init_args = {require};
std::vector<v8::Local<v8::Value>> asar_init_args = {source, require};
node::per_process::native_module_loader.CompileAndCall( node::per_process::native_module_loader.CompileAndCall(
isolate->GetCurrentContext(), "electron/js2c/asar_init", isolate->GetCurrentContext(), "electron/js2c/asar_init",
&asar_init_params, &asar_init_args, nullptr); &asar_init_params, &asar_init_args, nullptr);

View File

@@ -11,7 +11,7 @@
#include "atom/common/native_mate_converters/content_converter.h" #include "atom/common/native_mate_converters/content_converter.h"
#include "atom/common/native_mate_converters/gurl_converter.h" #include "atom/common/native_mate_converters/gurl_converter.h"
#include "atom/common/node_includes.h" #include "atom/common/node_includes.h"
#include "base/hash.h" #include "base/hash/hash.h"
#include "native_mate/dictionary.h" #include "native_mate/dictionary.h"
#include "url/origin.h" #include "url/origin.h"
#include "v8/include/v8-profiler.h" #include "v8/include/v8-profiler.h"
@@ -41,8 +41,12 @@ struct Converter<std::pair<Type1, Type2>> {
v8::Local<v8::Array> array(v8::Local<v8::Array>::Cast(val)); v8::Local<v8::Array> array(v8::Local<v8::Array>::Cast(val));
if (array->Length() != 2) if (array->Length() != 2)
return false; return false;
return Converter<Type1>::FromV8(isolate, array->Get(0), &out->first) &&
Converter<Type2>::FromV8(isolate, array->Get(1), &out->second); auto context = isolate->GetCurrentContext();
return Converter<Type1>::FromV8(
isolate, array->Get(context, 0).ToLocalChecked(), &out->first) &&
Converter<Type2>::FromV8(
isolate, array->Get(context, 1).ToLocalChecked(), &out->second);
} }
}; };

View File

@@ -9,7 +9,7 @@
#define ATOM_MINOR_VERSION 0 #define ATOM_MINOR_VERSION 0
#define ATOM_PATCH_VERSION 0 #define ATOM_PATCH_VERSION 0
// clang-format off // clang-format off
#define ATOM_PRE_RELEASE_VERSION -nightly.20190404 #define ATOM_PRE_RELEASE_VERSION -beta.4
// clang-format on // clang-format on
#ifndef ATOM_STRINGIFY #ifndef ATOM_STRINGIFY

View File

@@ -139,6 +139,7 @@ void UnregisterNonABICompliantCodeRange(void* start) {
RtlDeleteFunctionTable(&record->runtime_function); RtlDeleteFunctionTable(&record->runtime_function);
} }
#endif // _WIN64 #endif // _WIN64
} // namespace } // namespace
@@ -193,6 +194,7 @@ void CrashReporterWin::InitBreakpad(const std::string& product_name,
v8::Isolate::GetCurrent()->GetCodeRange(&code_range, &size); v8::Isolate::GetCurrent()->GetCodeRange(&code_range, &size);
if (code_range && size && if (code_range && size &&
RegisterNonABICompliantCodeRange(code_range, size)) { RegisterNonABICompliantCodeRange(code_range, size)) {
// FIXME(nornagon): This broke with https://crrev.com/c/1474703
gin::Debug::SetCodeRangeDeletedCallback( gin::Debug::SetCodeRangeDeletedCallback(
UnregisterNonABICompliantCodeRange); UnregisterNonABICompliantCodeRange);
} }

View File

@@ -92,7 +92,7 @@ bool WriteReportIDToFile(const std::wstring& dump_path,
int64_t seconds_since_epoch = int64_t seconds_since_epoch =
(base::Time::Now() - base::Time::UnixEpoch()).InSeconds(); (base::Time::Now() - base::Time::UnixEpoch()).InSeconds();
std::wstring line = base::Int64ToString16(seconds_since_epoch); std::wstring line = base::NumberToString16(seconds_since_epoch);
line += L','; line += L',';
line += report_id; line += report_id;
line += L'\n'; line += L'\n';

View File

@@ -147,7 +147,8 @@ v8::Local<v8::Value> BindFunctionWith(v8::Isolate* isolate,
v8::Local<v8::Function> func, v8::Local<v8::Function> func,
v8::Local<v8::Value> arg1, v8::Local<v8::Value> arg1,
v8::Local<v8::Value> arg2) { v8::Local<v8::Value> arg2) {
v8::MaybeLocal<v8::Value> bind = func->Get(mate::StringToV8(isolate, "bind")); v8::MaybeLocal<v8::Value> bind =
func->Get(context, mate::StringToV8(isolate, "bind"));
CHECK(!bind.IsEmpty()); CHECK(!bind.IsEmpty());
v8::Local<v8::Function> bind_func = v8::Local<v8::Function> bind_func =
v8::Local<v8::Function>::Cast(bind.ToLocalChecked()); v8::Local<v8::Function>::Cast(bind.ToLocalChecked());

View File

@@ -50,15 +50,15 @@ bool CertFromData(const std::string& data,
} // namespace } // namespace
// static // static
v8::Local<v8::Value> Converter<const net::AuthChallengeInfo*>::ToV8( v8::Local<v8::Value> Converter<net::AuthChallengeInfo>::ToV8(
v8::Isolate* isolate, v8::Isolate* isolate,
const net::AuthChallengeInfo* val) { const net::AuthChallengeInfo& val) {
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate); mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
dict.Set("isProxy", val->is_proxy); dict.Set("isProxy", val.is_proxy);
dict.Set("scheme", val->scheme); dict.Set("scheme", val.scheme);
dict.Set("host", val->challenger.host()); dict.Set("host", val.challenger.host());
dict.Set("port", static_cast<uint32_t>(val->challenger.port())); dict.Set("port", static_cast<uint32_t>(val.challenger.port()));
dict.Set("realm", val->realm); dict.Set("realm", val.realm);
return mate::ConvertToV8(isolate, dict); return mate::ConvertToV8(isolate, dict);
} }
@@ -210,7 +210,8 @@ bool Converter<net::HttpResponseHeaders*>::FromV8(
if (localVal->IsArray()) { if (localVal->IsArray()) {
auto values = v8::Local<v8::Array>::Cast(localVal); auto values = v8::Local<v8::Array>::Cast(localVal);
for (uint32_t j = 0; j < values->Length(); j++) { for (uint32_t j = 0; j < values->Length(); j++) {
if (!addHeaderFromValue(key, values->Get(j))) { if (!addHeaderFromValue(key,
values->Get(context, j).ToLocalChecked())) {
return false; return false;
} }
} }

View File

@@ -24,9 +24,9 @@ struct CertPrincipal;
namespace mate { namespace mate {
template <> template <>
struct Converter<const net::AuthChallengeInfo*> { struct Converter<net::AuthChallengeInfo> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const net::AuthChallengeInfo* val); const net::AuthChallengeInfo& val);
}; };
template <> template <>

View File

@@ -15,8 +15,9 @@ struct Converter<base::string16> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const base::string16& val) { const base::string16& val) {
return v8::String::NewFromTwoByte( return v8::String::NewFromTwoByte(
isolate, reinterpret_cast<const uint16_t*>(val.data()), isolate, reinterpret_cast<const uint16_t*>(val.data()),
v8::String::kNormalString, val.size()); v8::NewStringType::kNormal, val.size())
.ToLocalChecked();
} }
static bool FromV8(v8::Isolate* isolate, static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val, v8::Local<v8::Value> val,

View File

@@ -204,6 +204,7 @@ v8::Local<v8::Value> V8ValueConverter::ToV8Array(
v8::Isolate* isolate, v8::Isolate* isolate,
const base::ListValue* val) const { const base::ListValue* val) const {
v8::Local<v8::Array> result(v8::Array::New(isolate, val->GetSize())); v8::Local<v8::Array> result(v8::Array::New(isolate, val->GetSize()));
auto context = isolate->GetCurrentContext();
for (size_t i = 0; i < val->GetSize(); ++i) { for (size_t i = 0; i < val->GetSize(); ++i) {
const base::Value* child = nullptr; const base::Value* child = nullptr;
@@ -212,7 +213,7 @@ v8::Local<v8::Value> V8ValueConverter::ToV8Array(
v8::Local<v8::Value> child_v8 = ToV8ValueImpl(isolate, child); v8::Local<v8::Value> child_v8 = ToV8ValueImpl(isolate, child);
v8::TryCatch try_catch(isolate); v8::TryCatch try_catch(isolate);
result->Set(static_cast<uint32_t>(i), child_v8); result->Set(context, static_cast<uint32_t>(i), child_v8).Check();
if (try_catch.HasCaught()) if (try_catch.HasCaught())
LOG(ERROR) << "Setter for index " << i << " threw an exception."; LOG(ERROR) << "Setter for index " << i << " threw an exception.";
} }
@@ -330,9 +331,10 @@ std::unique_ptr<base::Value> V8ValueConverter::FromV8ValueImpl(
if (val->IsDate()) { if (val->IsDate()) {
v8::Date* date = v8::Date::Cast(*val); v8::Date* date = v8::Date::Cast(*val);
v8::Local<v8::Value> toISOString = v8::Local<v8::Value> toISOString =
date->Get(v8::String::NewFromUtf8(isolate, "toISOString", date->Get(context, v8::String::NewFromUtf8(isolate, "toISOString",
v8::NewStringType::kNormal) v8::NewStringType::kNormal)
.ToLocalChecked()); .ToLocalChecked())
.ToLocalChecked();
if (toISOString->IsFunction()) { if (toISOString->IsFunction()) {
v8::MaybeLocal<v8::Value> result = v8::MaybeLocal<v8::Value> result =
toISOString.As<v8::Function>()->Call(context, val, 0, nullptr); toISOString.As<v8::Function>()->Call(context, val, 0, nullptr);

View File

@@ -130,7 +130,7 @@ namespace {
// is not modified. // is not modified.
std::unique_ptr<const char* []> StringVectorToArgArray( std::unique_ptr<const char* []> StringVectorToArgArray(
const std::vector<std::string>& vector) { const std::vector<std::string>& vector) {
std::unique_ptr<const char* []> array(new const char*[vector.size()]); std::unique_ptr<const char*[]> array(new const char*[vector.size()]);
for (size_t i = 0; i < vector.size(); ++i) { for (size_t i = 0; i < vector.size(); ++i) {
array[i] = vector[i].c_str(); array[i] = vector[i].c_str();
} }
@@ -324,7 +324,7 @@ node::Environment* NodeBindings::CreateEnvironment(
.Append(FILE_PATH_LITERAL("init.js")); .Append(FILE_PATH_LITERAL("init.js"));
args.insert(args.begin() + 1, script_path.AsUTF8Unsafe()); args.insert(args.begin() + 1, script_path.AsUTF8Unsafe());
std::unique_ptr<const char* []> c_argv = StringVectorToArgArray(args); std::unique_ptr<const char*[]> c_argv = StringVectorToArgArray(args);
node::Environment* env = node::CreateEnvironment( node::Environment* env = node::CreateEnvironment(
node::CreateIsolateData(context->GetIsolate(), uv_loop_, platform), node::CreateIsolateData(context->GetIsolate(), uv_loop_, platform),
context, args.size(), c_argv.get(), 0, nullptr); context, args.size(), c_argv.get(), 0, nullptr);

View File

@@ -25,6 +25,13 @@
#pragma push_macro("CHECK_LE") #pragma push_macro("CHECK_LE")
#pragma push_macro("CHECK_LT") #pragma push_macro("CHECK_LT")
#pragma push_macro("CHECK_NE") #pragma push_macro("CHECK_NE")
#pragma push_macro("DCHECK")
#pragma push_macro("DCHECK_EQ")
#pragma push_macro("DCHECK_GE")
#pragma push_macro("DCHECK_GT")
#pragma push_macro("DCHECK_LE")
#pragma push_macro("DCHECK_LT")
#pragma push_macro("DCHECK_NE")
#pragma push_macro("DISALLOW_COPY_AND_ASSIGN") #pragma push_macro("DISALLOW_COPY_AND_ASSIGN")
#pragma push_macro("LIKELY") #pragma push_macro("LIKELY")
#pragma push_macro("NO_RETURN") #pragma push_macro("NO_RETURN")
@@ -38,6 +45,13 @@
#undef CHECK_LE #undef CHECK_LE
#undef CHECK_LT #undef CHECK_LT
#undef CHECK_NE #undef CHECK_NE
#undef DCHECK
#undef DCHECK_EQ
#undef DCHECK_GE
#undef DCHECK_GT
#undef DCHECK_LE
#undef DCHECK_LT
#undef DCHECK_NE
#undef DISALLOW_COPY_AND_ASSIGN #undef DISALLOW_COPY_AND_ASSIGN
#undef LIKELY #undef LIKELY
#undef NO_RETURN #undef NO_RETURN
@@ -67,6 +81,13 @@
#pragma pop_macro("CHECK_LE") #pragma pop_macro("CHECK_LE")
#pragma pop_macro("CHECK_LT") #pragma pop_macro("CHECK_LT")
#pragma pop_macro("CHECK_NE") #pragma pop_macro("CHECK_NE")
#pragma pop_macro("DCHECK")
#pragma pop_macro("DCHECK_EQ")
#pragma pop_macro("DCHECK_GE")
#pragma pop_macro("DCHECK_GT")
#pragma pop_macro("DCHECK_LE")
#pragma pop_macro("DCHECK_LT")
#pragma pop_macro("DCHECK_NE")
#pragma pop_macro("DISALLOW_COPY_AND_ASSIGN") #pragma pop_macro("DISALLOW_COPY_AND_ASSIGN")
#pragma pop_macro("LIKELY") #pragma pop_macro("LIKELY")
#pragma pop_macro("NO_RETURN") #pragma pop_macro("NO_RETURN")

View File

@@ -160,6 +160,22 @@ const char kNodeIntegrationInSubFrames[] = "nodeIntegrationInSubFrames";
const char kDisableHtmlFullscreenWindowResize[] = const char kDisableHtmlFullscreenWindowResize[] =
"disableHtmlFullscreenWindowResize"; "disableHtmlFullscreenWindowResize";
// Enables JavaScript support.
const char kJavaScript[] = "javascript";
// Enables image support.
const char kImages[] = "images";
// Make TextArea elements resizable.
const char kTextAreasAreResizable[] = "textAreasAreResizable";
// Enables WebGL support.
const char kWebGL[] = "webgl";
// Whether dragging and dropping a file or link onto the page causes a
// navigation.
const char kNavigateOnDragDrop[] = "navigateOnDragDrop";
} // namespace options } // namespace options
namespace switches { namespace switches {
@@ -247,6 +263,9 @@ const char kAuthServerWhitelist[] = "auth-server-whitelist";
const char kAuthNegotiateDelegateWhitelist[] = const char kAuthNegotiateDelegateWhitelist[] =
"auth-negotiate-delegate-whitelist"; "auth-negotiate-delegate-whitelist";
// If set, include the port in generated Kerberos SPNs.
const char kEnableAuthNegotiatePort[] = "enable-auth-negotiate-port";
} // namespace switches } // namespace switches
} // namespace atom } // namespace atom

View File

@@ -77,6 +77,11 @@ extern const char kAllowRunningInsecureContent[];
extern const char kOffscreen[]; extern const char kOffscreen[];
extern const char kNodeIntegrationInSubFrames[]; extern const char kNodeIntegrationInSubFrames[];
extern const char kDisableHtmlFullscreenWindowResize[]; extern const char kDisableHtmlFullscreenWindowResize[];
extern const char kJavaScript[];
extern const char kImages[];
extern const char kTextAreasAreResizable[];
extern const char kWebGL[];
extern const char kNavigateOnDragDrop[];
} // namespace options } // namespace options
@@ -121,6 +126,7 @@ extern const char kDiskCacheSize[];
extern const char kIgnoreConnectionsLimit[]; extern const char kIgnoreConnectionsLimit[];
extern const char kAuthServerWhitelist[]; extern const char kAuthServerWhitelist[];
extern const char kAuthNegotiateDelegateWhitelist[]; extern const char kAuthNegotiateDelegateWhitelist[];
extern const char kEnableAuthNegotiatePort[];
} // namespace switches } // namespace switches

View File

@@ -341,7 +341,7 @@ bool MoveItemToTrash(const base::FilePath& path) {
// Elevation prompt enabled for UAC protected files. This overrides the // Elevation prompt enabled for UAC protected files. This overrides the
// SILENT, NO_UI and NOERRORUI flags. // SILENT, NO_UI and NOERRORUI flags.
if (base::win::GetVersion() >= base::win::VERSION_WIN8) { if (base::win::GetVersion() >= base::win::Version::WIN8) {
// Windows 8 introduces the flag RECYCLEONDELETE and deprecates the // Windows 8 introduces the flag RECYCLEONDELETE and deprecates the
// ALLOWUNDO in favor of ADDUNDORECORD. // ALLOWUNDO in favor of ADDUNDORECORD.
if (FAILED(pfo->SetOperationFlags( if (FAILED(pfo->SetOperationFlags(

View File

@@ -103,8 +103,24 @@ class Promise {
return GetInner()->Reject(GetContext(), v8::Undefined(isolate())); return GetInner()->Reject(GetContext(), v8::Undefined(isolate()));
} }
template <typename ReturnType, typename... ArgTypes> // Please note that using Then is effectively the same as calling .then
v8::MaybeLocal<v8::Promise> Then(base::Callback<ReturnType(ArgTypes...)> cb) { // in javascript. This means (a) it is not type safe and (b) please note
// it is NOT type safe.
// If the base::Callback you provide here is of type void(boolean) and you
// resolve the promise with a string, Electron will compile successfully and
// then that promise will be rejected as soon as you try to use it as the
// mate converters doing work behind the scenes will throw an error for you.
// This can be really hard to trace so until either
// * This helper becomes typesafe (by templating the class instead of each
// method)
// * or the world goes mad
// Please try your hardest not to use this method
// The world thanks you
template <typename... ResolveType>
v8::MaybeLocal<v8::Promise> Then(base::Callback<void(ResolveType...)> cb) {
static_assert(sizeof...(ResolveType) <= 1,
"A promise's 'Then' callback should only receive at most one "
"parameter");
v8::HandleScope handle_scope(isolate()); v8::HandleScope handle_scope(isolate());
v8::Context::Scope context_scope( v8::Context::Scope context_scope(
v8::Local<v8::Context>::New(isolate(), GetContext())); v8::Local<v8::Context>::New(isolate(), GetContext()));

View File

@@ -372,6 +372,9 @@ v8::Local<v8::Promise> ExecuteJavaScriptInIsolatedWorld(
blink::WebLocalFrame::kSynchronous; blink::WebLocalFrame::kSynchronous;
args->GetNext(&scriptExecutionType); args->GetNext(&scriptExecutionType);
// Debugging tip: if you see a crash stack trace beginning from this call,
// then it is very likely that some exception happened when executing the
// "content_script/init.js" script.
GetRenderFrame(window)->GetWebFrame()->RequestExecuteScriptInIsolatedWorld( GetRenderFrame(window)->GetWebFrame()->RequestExecuteScriptInIsolatedWorld(
world_id, &sources.front(), sources.size(), has_user_gesture, world_id, &sources.front(), sources.size(), has_user_gesture,
scriptExecutionType, new ScriptExecutionCallback(std::move(promise))); scriptExecutionType, new ScriptExecutionCallback(std::move(promise)));

View File

@@ -44,7 +44,8 @@ bool IsDevToolsExtension(content::RenderFrame* render_frame) {
} }
v8::Local<v8::Object> GetModuleCache(v8::Isolate* isolate) { v8::Local<v8::Object> GetModuleCache(v8::Isolate* isolate) {
mate::Dictionary global(isolate, isolate->GetCurrentContext()->Global()); auto context = isolate->GetCurrentContext();
mate::Dictionary global(isolate, context->Global());
v8::Local<v8::Value> cache; v8::Local<v8::Value> cache;
if (!global.GetHidden(kModuleCacheKey, &cache)) { if (!global.GetHidden(kModuleCacheKey, &cache)) {
@@ -52,7 +53,7 @@ v8::Local<v8::Object> GetModuleCache(v8::Isolate* isolate) {
global.SetHidden(kModuleCacheKey, cache); global.SetHidden(kModuleCacheKey, cache);
} }
return cache->ToObject(isolate); return cache->ToObject(context).ToLocalChecked();
} }
// adapted from node.cc // adapted from node.cc
@@ -95,7 +96,9 @@ void InvokeHiddenCallback(v8::Handle<v8::Context> context,
const std::string& hidden_key, const std::string& hidden_key,
const std::string& callback_name) { const std::string& callback_name) {
auto* isolate = context->GetIsolate(); auto* isolate = context->GetIsolate();
auto binding_key = mate::ConvertToV8(isolate, hidden_key)->ToString(isolate); auto binding_key = mate::ConvertToV8(isolate, hidden_key)
->ToString(context)
.ToLocalChecked();
auto private_binding_key = v8::Private::ForApi(isolate, binding_key); auto private_binding_key = v8::Private::ForApi(isolate, binding_key);
auto global_object = context->Global(); auto global_object = context->Global();
v8::Local<v8::Value> value; v8::Local<v8::Value> value;
@@ -103,10 +106,11 @@ void InvokeHiddenCallback(v8::Handle<v8::Context> context,
return; return;
if (value.IsEmpty() || !value->IsObject()) if (value.IsEmpty() || !value->IsObject())
return; return;
auto binding = value->ToObject(isolate); auto binding = value->ToObject(context).ToLocalChecked();
auto callback_key = auto callback_key = mate::ConvertToV8(isolate, callback_name)
mate::ConvertToV8(isolate, callback_name)->ToString(isolate); ->ToString(context)
auto callback_value = binding->Get(callback_key); .ToLocalChecked();
auto callback_value = binding->Get(context, callback_key).ToLocalChecked();
DCHECK(callback_value->IsFunction()); // set by sandboxed_renderer/init.js DCHECK(callback_value->IsFunction()); // set by sandboxed_renderer/init.js
auto callback = v8::Handle<v8::Function>::Cast(callback_value); auto callback = v8::Handle<v8::Function>::Cast(callback_value);
ignore_result(callback->Call(context, binding, 0, nullptr)); ignore_result(callback->Call(context, binding, 0, nullptr));
@@ -241,7 +245,7 @@ void AtomSandboxedRendererClient::SetupMainWorldOverrides(
auto* isolate = context->GetIsolate(); auto* isolate = context->GetIsolate();
mate::Dictionary process = mate::Dictionary::CreateEmpty(isolate); mate::Dictionary process = mate::Dictionary::CreateEmpty(isolate);
process.SetMethod("binding", GetBinding); process.SetMethod("_linkedBinding", GetBinding);
std::vector<v8::Local<v8::String>> isolated_bundle_params = { std::vector<v8::Local<v8::String>> isolated_bundle_params = {
node::FIXED_ONE_BYTE_STRING(isolate, "nodeProcess"), node::FIXED_ONE_BYTE_STRING(isolate, "nodeProcess"),
@@ -263,7 +267,7 @@ void AtomSandboxedRendererClient::SetupExtensionWorldOverrides(
auto* isolate = context->GetIsolate(); auto* isolate = context->GetIsolate();
mate::Dictionary process = mate::Dictionary::CreateEmpty(isolate); mate::Dictionary process = mate::Dictionary::CreateEmpty(isolate);
process.SetMethod("binding", GetBinding); process.SetMethod("_linkedBinding", GetBinding);
std::vector<v8::Local<v8::String>> isolated_bundle_params = { std::vector<v8::Local<v8::String>> isolated_bundle_params = {
node::FIXED_ONE_BYTE_STRING(isolate, "nodeProcess"), node::FIXED_ONE_BYTE_STRING(isolate, "nodeProcess"),

View File

@@ -31,13 +31,14 @@ const char kIpcKey[] = "ipcNative";
// Gets the private object under kIpcKey // Gets the private object under kIpcKey
v8::Local<v8::Object> GetIpcObject(v8::Local<v8::Context> context) { v8::Local<v8::Object> GetIpcObject(v8::Local<v8::Context> context) {
auto* isolate = context->GetIsolate(); auto* isolate = context->GetIsolate();
auto binding_key = mate::ConvertToV8(isolate, kIpcKey)->ToString(isolate); auto binding_key =
mate::ConvertToV8(isolate, kIpcKey)->ToString(context).ToLocalChecked();
auto private_binding_key = v8::Private::ForApi(isolate, binding_key); auto private_binding_key = v8::Private::ForApi(isolate, binding_key);
auto global_object = context->Global(); auto global_object = context->Global();
auto value = auto value =
global_object->GetPrivate(context, private_binding_key).ToLocalChecked(); global_object->GetPrivate(context, private_binding_key).ToLocalChecked();
DCHECK(!value.IsEmpty() && value->IsObject()); DCHECK(!value.IsEmpty() && value->IsObject());
return value->ToObject(isolate); return value->ToObject(context).ToLocalChecked();
} }
void InvokeIpcCallback(v8::Local<v8::Context> context, void InvokeIpcCallback(v8::Local<v8::Context> context,
@@ -56,9 +57,10 @@ void InvokeIpcCallback(v8::Local<v8::Context> context,
callback_scope.reset(new node::CallbackScope(isolate, ipcNative, {0, 0})); callback_scope.reset(new node::CallbackScope(isolate, ipcNative, {0, 0}));
} }
auto callback_key = auto callback_key = mate::ConvertToV8(isolate, callback_name)
mate::ConvertToV8(isolate, callback_name)->ToString(isolate); ->ToString(context)
auto callback_value = ipcNative->Get(callback_key); .ToLocalChecked();
auto callback_value = ipcNative->Get(context, callback_key).ToLocalChecked();
DCHECK(callback_value->IsFunction()); // set by init.ts DCHECK(callback_value->IsFunction()); // set by init.ts
auto callback = v8::Local<v8::Function>::Cast(callback_value); auto callback = v8::Local<v8::Function>::Cast(callback_value);
ignore_result(callback->Call(context, ipcNative, args.size(), args.data())); ignore_result(callback->Call(context, ipcNative, args.size(), args.data()));

View File

@@ -2,14 +2,21 @@ is_electron_build = true
use_jumbo_build = true use_jumbo_build = true
root_extra_deps = [ "//electron" ] root_extra_deps = [ "//electron" ]
# Registry of NMVs --> https://github.com/nodejs/node/blob/master/doc/abi_version_registry.json
node_module_version = 73
v8_promise_internal_field_count = 1 v8_promise_internal_field_count = 1
v8_typed_array_max_size_in_heap = 0 v8_typed_array_max_size_in_heap = 0
v8_embedder_string = "-electron.0" v8_embedder_string = "-electron.0"
# TODO: this breaks mksnapshot
v8_enable_snapshot_native_code_counters = false
enable_cdm_host_verification = false enable_cdm_host_verification = false
proprietary_codecs = true proprietary_codecs = true
ffmpeg_branding = "Chrome" ffmpeg_branding = "Chrome"
enable_basic_printing = true enable_basic_printing = true
angle_enable_vulkan_validation_layers = false
is_cfi = false is_cfi = false

View File

@@ -6,7 +6,7 @@ template("npm_action") {
action("npm_pre_flight_" + target_name) { action("npm_pre_flight_" + target_name) {
inputs = [ inputs = [
"package.json", "package.json",
"package-lock.json", "yarn.lock",
] ]
script = "//electron/build/npm-run.py" script = "//electron/build/npm-run.py"

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