mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Compare commits
13 Commits
v8.1.0
...
v8.0.0-nig
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8d85b6ded | ||
|
|
8f1ad8a4e5 | ||
|
|
57883eed0f | ||
|
|
4ec6d10969 | ||
|
|
0fe6767d6b | ||
|
|
0e0d4fe990 | ||
|
|
e196a397ad | ||
|
|
510a916f82 | ||
|
|
be955a9721 | ||
|
|
77414813b4 | ||
|
|
cc278cea00 | ||
|
|
fadd7e056d | ||
|
|
6dc101ffec |
@@ -704,6 +704,51 @@ step-save-src-cache: &step-save-src-cache
|
||||
key: v5-src-cache-{{ arch }}-{{ checksum "src/electron/.depshash" }}
|
||||
name: Persisting src cache
|
||||
|
||||
# Check for doc only change
|
||||
step-check-for-doc-only-change: &step-check-for-doc-only-change
|
||||
run:
|
||||
name: Check if commit is doc only change
|
||||
command: |
|
||||
cd src/electron
|
||||
node script/yarn install --frozen-lockfile
|
||||
if node script/doc-only-change.js --prNumber=$CIRCLE_PR_NUMBER --prURL=$CIRCLE_PULL_REQUEST; then
|
||||
#PR is doc only change; save file with value true to indicate doc only change
|
||||
echo "true" > .skip-ci-build
|
||||
else
|
||||
#PR is not a doc only change; create empty file to indicate check has been done
|
||||
touch .skip-ci-build
|
||||
fi
|
||||
|
||||
step-persist-doc-only-change: &step-persist-doc-only-change
|
||||
persist_to_workspace:
|
||||
root: .
|
||||
paths:
|
||||
- src/electron/.skip-ci-build
|
||||
|
||||
step-maybe-early-exit-doc-only-change: &step-maybe-early-exit-doc-only-change
|
||||
run:
|
||||
name: Shortcircuit build if doc only change
|
||||
command: |
|
||||
if [ -s src/electron/.skip-ci-build ]; then
|
||||
circleci-agent step halt
|
||||
fi
|
||||
|
||||
step-maybe-early-exit-no-doc-change: &step-maybe-early-exit-no-doc-change
|
||||
run:
|
||||
name: Shortcircuit job if change is not doc only
|
||||
command: |
|
||||
if [ ! -s src/electron/.skip-ci-build ]; then
|
||||
circleci-agent step halt
|
||||
fi
|
||||
|
||||
step-ts-compile: &step-ts-compile
|
||||
run:
|
||||
name: Run TS/JS compile on doc only change
|
||||
command: |
|
||||
cd src
|
||||
ninja -C out/Default electron:default_app_js -j $NUMBER_OF_NINJA_PROCESSES
|
||||
ninja -C out/Default electron:atom_js2c -j $NUMBER_OF_NINJA_PROCESSES
|
||||
|
||||
# Lists of steps.
|
||||
steps-lint: &steps-lint
|
||||
steps:
|
||||
@@ -752,6 +797,9 @@ steps-lint: &steps-lint
|
||||
steps-checkout-fast: &steps-checkout-fast
|
||||
steps:
|
||||
- *step-checkout-electron
|
||||
- *step-check-for-doc-only-change
|
||||
- *step-persist-doc-only-change
|
||||
- *step-maybe-early-exit-doc-only-change
|
||||
- *step-depot-tools-get
|
||||
- *step-depot-tools-add-to-path
|
||||
- *step-restore-brew-cache
|
||||
@@ -783,6 +831,9 @@ steps-checkout-fast: &steps-checkout-fast
|
||||
steps-checkout-and-save-cache: &steps-checkout-and-save-cache
|
||||
steps:
|
||||
- *step-checkout-electron
|
||||
- *step-check-for-doc-only-change
|
||||
- *step-persist-doc-only-change
|
||||
- *step-maybe-early-exit-doc-only-change
|
||||
- *step-depot-tools-get
|
||||
- *step-depot-tools-add-to-path
|
||||
- *step-restore-brew-cache
|
||||
@@ -813,6 +864,7 @@ steps-electron-gn-check: &steps-electron-gn-check
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- *step-maybe-early-exit-doc-only-change
|
||||
- *step-depot-tools-add-to-path
|
||||
- *step-setup-env-for-build
|
||||
- *step-gn-gen-default
|
||||
@@ -822,6 +874,7 @@ steps-electron-build: &steps-electron-build
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- *step-maybe-early-exit-doc-only-change
|
||||
- *step-depot-tools-add-to-path
|
||||
- *step-setup-env-for-build
|
||||
- *step-restore-brew-cache
|
||||
@@ -875,6 +928,9 @@ steps-electron-build-with-inline-checkout-for-tests: &steps-electron-build-with-
|
||||
steps:
|
||||
# Checkout - Copied ffrom steps-checkout
|
||||
- *step-checkout-electron
|
||||
- *step-check-for-doc-only-change
|
||||
- *step-persist-doc-only-change
|
||||
- *step-maybe-early-exit-doc-only-change
|
||||
- *step-depot-tools-get
|
||||
- *step-depot-tools-add-to-path
|
||||
- *step-restore-brew-cache
|
||||
@@ -946,6 +1002,45 @@ steps-electron-build-with-inline-checkout-for-tests: &steps-electron-build-with-
|
||||
|
||||
- *step-maybe-notify-slack-failure
|
||||
|
||||
steps-electron-ts-compile-for-doc-change: &steps-electron-ts-compile-for-doc-change
|
||||
steps:
|
||||
# Checkout - Copied ffrom steps-checkout
|
||||
- *step-checkout-electron
|
||||
- *step-check-for-doc-only-change
|
||||
- *step-maybe-early-exit-no-doc-change
|
||||
- *step-depot-tools-get
|
||||
- *step-depot-tools-add-to-path
|
||||
- *step-restore-brew-cache
|
||||
- *step-get-more-space-on-mac
|
||||
- *step-install-gnutar-on-mac
|
||||
- *step-generate-deps-hash
|
||||
- *step-touch-sync-done
|
||||
- *step-maybe-restore-src-cache
|
||||
- *step-maybe-restore-git-cache
|
||||
- *step-set-git-cache-path
|
||||
# This sync call only runs if .circle-sync-done is an EMPTY file
|
||||
- *step-gclient-sync
|
||||
# These next few steps reset Electron to the correct commit regardless of which cache was restored
|
||||
- run:
|
||||
name: Wipe Electron
|
||||
command: rm -rf src/electron
|
||||
- *step-checkout-electron
|
||||
- *step-run-electron-only-hooks
|
||||
- *step-generate-deps-hash-cleanly
|
||||
- *step-mark-sync-done
|
||||
- *step-minimize-workspace-size-from-checkout
|
||||
|
||||
- *step-depot-tools-add-to-path
|
||||
- *step-setup-env-for-build
|
||||
- *step-restore-brew-cache
|
||||
- *step-get-more-space-on-mac
|
||||
- *step-install-npm-deps-on-mac
|
||||
- *step-fix-sync-on-mac
|
||||
- *step-gn-gen-default
|
||||
|
||||
#Compile ts/js to verify doc change didn't break anything
|
||||
- *step-ts-compile
|
||||
|
||||
steps-electron-build-for-publish: &steps-electron-build-for-publish
|
||||
steps:
|
||||
- *step-checkout-electron
|
||||
@@ -1064,6 +1159,7 @@ steps-tests: &steps-tests
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- *step-maybe-early-exit-doc-only-change
|
||||
- *step-depot-tools-add-to-path
|
||||
- *step-electron-dist-unzip
|
||||
- *step-mksnapshot-unzip
|
||||
@@ -1106,6 +1202,7 @@ steps-test-nan: &steps-test-nan
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- *step-maybe-early-exit-doc-only-change
|
||||
- *step-depot-tools-add-to-path
|
||||
- *step-electron-dist-unzip
|
||||
- *step-setup-linux-for-headless-testing
|
||||
@@ -1121,6 +1218,7 @@ steps-test-node: &steps-test-node
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- *step-maybe-early-exit-doc-only-change
|
||||
- *step-depot-tools-add-to-path
|
||||
- *step-electron-dist-unzip
|
||||
- *step-setup-linux-for-headless-testing
|
||||
@@ -1146,6 +1244,13 @@ jobs:
|
||||
<<: *env-linux-medium
|
||||
<<: *steps-lint
|
||||
|
||||
ts-compile-doc-change:
|
||||
<<: *machine-linux-medium
|
||||
environment:
|
||||
<<: *env-linux-medium
|
||||
<<: *env-testing-build
|
||||
<<: *steps-electron-ts-compile-for-doc-change
|
||||
|
||||
# Layer 1: Checkout.
|
||||
linux-checkout-fast:
|
||||
<<: *machine-linux-2xlarge
|
||||
@@ -1917,6 +2022,7 @@ workflows:
|
||||
- linux-arm64-testing-gn-check:
|
||||
requires:
|
||||
- linux-checkout-fast
|
||||
- ts-compile-doc-change
|
||||
|
||||
build-mac:
|
||||
when: << pipeline.parameters.run-build-mac >>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.0.0-nightly.20191023
|
||||
8.0.0-nightly.20191027
|
||||
@@ -50,6 +50,12 @@ build_script:
|
||||
- ps: >-
|
||||
if(($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME -split "/")[0] -eq ($env:APPVEYOR_REPO_NAME -split "/")[0]) {
|
||||
Write-warning "Skipping PR build for branch"; Exit-AppveyorBuild
|
||||
} else {
|
||||
node script/yarn.js install --frozen-lockfile
|
||||
|
||||
if ($(node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER --prBranch=$env:APPVEYOR_REPO_BRANCH;$LASTEXITCODE -eq 0)) {
|
||||
Write-warning "Skipping build for doc only change"; Exit-AppveyorBuild
|
||||
}
|
||||
}
|
||||
- echo "Building $env:GN_CONFIG build"
|
||||
- git config --global core.longpaths true
|
||||
|
||||
@@ -39,6 +39,7 @@ an issue:
|
||||
* [Using Electron's APIs](tutorial/application-architecture.md#using-electron-apis)
|
||||
* [Using Node.js APIs](tutorial/application-architecture.md#using-nodejs-apis)
|
||||
* [Using Native Node.js Modules](tutorial/using-native-node-modules.md)
|
||||
* [Performance Strategies](tutorial/performance.md)
|
||||
* Adding Features to Your App
|
||||
* [Notifications](tutorial/notifications.md)
|
||||
* [Recent Documents](tutorial/recent-documents.md)
|
||||
|
||||
@@ -79,8 +79,8 @@ filenames = {
|
||||
"shell/browser/api/atom_api_power_monitor.h",
|
||||
"shell/browser/api/atom_api_power_save_blocker.cc",
|
||||
"shell/browser/api/atom_api_power_save_blocker.h",
|
||||
"shell/browser/api/atom_api_protocol_ns.cc",
|
||||
"shell/browser/api/atom_api_protocol_ns.h",
|
||||
"shell/browser/api/atom_api_protocol.cc",
|
||||
"shell/browser/api/atom_api_protocol.h",
|
||||
"shell/browser/api/atom_api_screen.cc",
|
||||
"shell/browser/api/atom_api_screen.h",
|
||||
"shell/browser/api/atom_api_session.cc",
|
||||
@@ -93,8 +93,8 @@ filenames = {
|
||||
"shell/browser/api/atom_api_top_level_window.h",
|
||||
"shell/browser/api/atom_api_tray.cc",
|
||||
"shell/browser/api/atom_api_tray.h",
|
||||
"shell/browser/api/atom_api_url_request_ns.cc",
|
||||
"shell/browser/api/atom_api_url_request_ns.h",
|
||||
"shell/browser/api/atom_api_url_request.cc",
|
||||
"shell/browser/api/atom_api_url_request.h",
|
||||
"shell/browser/api/atom_api_view.cc",
|
||||
"shell/browser/api/atom_api_view.h",
|
||||
"shell/browser/api/atom_api_web_contents.cc",
|
||||
@@ -103,8 +103,8 @@ filenames = {
|
||||
"shell/browser/api/atom_api_web_contents_mac.mm",
|
||||
"shell/browser/api/atom_api_web_contents_view.cc",
|
||||
"shell/browser/api/atom_api_web_contents_view.h",
|
||||
"shell/browser/api/atom_api_web_request_ns.cc",
|
||||
"shell/browser/api/atom_api_web_request_ns.h",
|
||||
"shell/browser/api/atom_api_web_request.cc",
|
||||
"shell/browser/api/atom_api_web_request.h",
|
||||
"shell/browser/api/atom_api_web_view_manager.cc",
|
||||
"shell/browser/api/atom_api_browser_window.cc",
|
||||
"shell/browser/api/atom_api_browser_window.h",
|
||||
@@ -112,10 +112,6 @@ filenames = {
|
||||
"shell/browser/api/atom_api_browser_window_views.cc",
|
||||
"shell/browser/api/event.cc",
|
||||
"shell/browser/api/event.h",
|
||||
"shell/browser/api/event_emitter_deprecated.cc",
|
||||
"shell/browser/api/event_emitter_deprecated.h",
|
||||
"shell/browser/api/trackable_object.cc",
|
||||
"shell/browser/api/trackable_object.h",
|
||||
"shell/browser/api/frame_subscriber.cc",
|
||||
"shell/browser/api/frame_subscriber.h",
|
||||
"shell/browser/api/gpu_info_enumerator.cc",
|
||||
@@ -468,7 +464,11 @@ filenames = {
|
||||
"shell/common/crash_reporter/linux/crash_dump_handler.h",
|
||||
"shell/common/crash_reporter/win/crash_service_main.cc",
|
||||
"shell/common/crash_reporter/win/crash_service_main.h",
|
||||
"shell/common/gin_converters/accelerator_converter.cc",
|
||||
"shell/common/gin_converters/accelerator_converter.h",
|
||||
"shell/common/gin_converters/callback_converter.h",
|
||||
"shell/common/gin_converters/content_converter.cc",
|
||||
"shell/common/gin_converters/content_converter.h",
|
||||
"shell/common/gin_converters/file_dialog_converter.cc",
|
||||
"shell/common/gin_converters/file_dialog_converter.h",
|
||||
"shell/common/gin_converters/file_path_converter.h",
|
||||
@@ -502,6 +502,8 @@ filenames = {
|
||||
"shell/common/gin_helper/function_template.h",
|
||||
"shell/common/gin_helper/object_template_builder.cc",
|
||||
"shell/common/gin_helper/object_template_builder.h",
|
||||
"shell/common/gin_helper/trackable_object.cc",
|
||||
"shell/common/gin_helper/trackable_object.h",
|
||||
"shell/common/heap_snapshot.cc",
|
||||
"shell/common/heap_snapshot.h",
|
||||
"shell/common/key_weak_map.h",
|
||||
@@ -513,25 +515,18 @@ filenames = {
|
||||
"shell/common/mouse_util.h",
|
||||
"shell/common/mac/main_application_bundle.h",
|
||||
"shell/common/mac/main_application_bundle.mm",
|
||||
"shell/common/native_mate_converters/accelerator_converter.cc",
|
||||
"shell/common/native_mate_converters/accelerator_converter.h",
|
||||
"shell/common/native_mate_converters/blink_converter.cc",
|
||||
"shell/common/native_mate_converters/blink_converter.h",
|
||||
"shell/common/native_mate_converters/callback_converter_deprecated.cc",
|
||||
"shell/common/native_mate_converters/callback_converter_deprecated.h",
|
||||
"shell/common/native_mate_converters/content_converter.cc",
|
||||
"shell/common/native_mate_converters/content_converter.h",
|
||||
"shell/common/native_mate_converters/file_dialog_converter.h",
|
||||
"shell/common/native_mate_converters/file_path_converter.h",
|
||||
"shell/common/native_mate_converters/gurl_converter.h",
|
||||
"shell/common/native_mate_converters/image_converter.h",
|
||||
"shell/common/native_mate_converters/native_window_converter.h",
|
||||
"shell/common/native_mate_converters/net_converter.h",
|
||||
"shell/common/native_mate_converters/network_converter.cc",
|
||||
"shell/common/native_mate_converters/network_converter.h",
|
||||
"shell/common/native_mate_converters/once_callback.h",
|
||||
"shell/common/native_mate_converters/string16_converter.h",
|
||||
"shell/common/native_mate_converters/ui_base_types_converter.h",
|
||||
"shell/common/native_mate_converters/v8_value_converter.cc",
|
||||
"shell/common/native_mate_converters/v8_value_converter.h",
|
||||
"shell/common/native_mate_converters/value_converter.cc",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "electron",
|
||||
"version": "8.0.0-nightly.20191023",
|
||||
"version": "8.0.0-nightly.20191027",
|
||||
"repository": "https://github.com/electron/electron",
|
||||
"description": "Build cross platform desktop apps with JavaScript, HTML, and CSS",
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
expose_ripemd160.patch
|
||||
expose_aes-cfb.patch
|
||||
fix_add_RSA-PSS_keygen_functions.patch
|
||||
|
||||
57
patches/boringssl/fix_add_RSA-PSS_keygen_functions.patch
Normal file
57
patches/boringssl/fix_add_RSA-PSS_keygen_functions.patch
Normal file
@@ -0,0 +1,57 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shelley Vohr <shelley.vohr@gmail.com>
|
||||
Date: Wed, 23 Oct 2019 12:54:32 -0700
|
||||
Subject: fix: add RSA-PSS keygen functions
|
||||
|
||||
This adds support for missing RSA_PSS key generation functions.
|
||||
Refs https://github.com/nodejs/node/pull/26960.
|
||||
|
||||
Upstreamed at https://boringssl-review.googlesource.com/c/boringssl/+/38524.
|
||||
|
||||
diff --git a/crypto/evp/p_rsa.c b/crypto/evp/p_rsa.c
|
||||
index 865b36af9b830302fb1068c4965133213c1507dc..71b342f13db5f446aa15f070b6e4aef9b8c25939 100644
|
||||
--- a/crypto/evp/p_rsa.c
|
||||
+++ b/crypto/evp/p_rsa.c
|
||||
@@ -569,6 +569,19 @@ int EVP_PKEY_CTX_get_rsa_padding(EVP_PKEY_CTX *ctx, int *out_padding) {
|
||||
0, out_padding);
|
||||
}
|
||||
|
||||
+int EVP_PKEY_CTX_set_rsa_pss_keygen_md(EVP_PKEY_CTX *ctx, const EVP_MD *md) {
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen(EVP_PKEY_CTX *ctx, int salt_len) {
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md(EVP_PKEY_CTX *ctx,
|
||||
+ const EVP_MD *md) {
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
int EVP_PKEY_CTX_set_rsa_pss_saltlen(EVP_PKEY_CTX *ctx, int salt_len) {
|
||||
return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA,
|
||||
(EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY),
|
||||
diff --git a/include/openssl/evp.h b/include/openssl/evp.h
|
||||
index ad9c05e052756715e3fe67bf9517863ede027d5b..d1729cfc8beefd2cb20abf05043fed43e566a312 100644
|
||||
--- a/include/openssl/evp.h
|
||||
+++ b/include/openssl/evp.h
|
||||
@@ -723,6 +723,18 @@ OPENSSL_EXPORT int EVP_PKEY_CTX_set_rsa_padding(EVP_PKEY_CTX *ctx, int padding);
|
||||
OPENSSL_EXPORT int EVP_PKEY_CTX_get_rsa_padding(EVP_PKEY_CTX *ctx,
|
||||
int *out_padding);
|
||||
|
||||
+// EVP_PKEY_CTX_set_rsa_pss_keygen_md() always returns 0.
|
||||
+OPENSSL_EXPORT int EVP_PKEY_CTX_set_rsa_pss_keygen_md(EVP_PKEY_CTX *ctx,
|
||||
+ const EVP_MD *md);
|
||||
+
|
||||
+// EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen() always returns 0.
|
||||
+OPENSSL_EXPORT int EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen(EVP_PKEY_CTX *ctx,
|
||||
+ int salt_len);
|
||||
+
|
||||
+// EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md() always returns 0.
|
||||
+OPENSSL_EXPORT int EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md(EVP_PKEY_CTX *ctx,
|
||||
+ const EVP_MD *md);
|
||||
+
|
||||
// EVP_PKEY_CTX_set_rsa_pss_saltlen sets the length of the salt in a PSS-padded
|
||||
// signature. A value of -1 cause the salt to be the same length as the digest
|
||||
// in the signature. A value of -2 causes the salt to be the maximum length
|
||||
@@ -27,7 +27,6 @@ refactor_allow_embedder_overriding_of_internal_fs_calls.patch
|
||||
chore_prevent_warn_non_context-aware_native_modules_being_loaded.patch
|
||||
chore_allow_the_node_entrypoint_to_be_a_builtin_module.patch
|
||||
inherit_electron_crashpad_pipe_name_in_child_process.patch
|
||||
fixme_revert_crypto_add_support_for_rsa-pss_keys.patch
|
||||
fix_extern_the_nativemoduleenv_and_options_parser_for_debug_builds.patch
|
||||
chore_read_nobrowserglobals_from_global_not_process.patch
|
||||
chore_split_createenvironment_into_createenvironment_and.patch
|
||||
|
||||
@@ -10,10 +10,19 @@ THe fix for this should land in node-gyp as discussed in above issue,
|
||||
landing this as temporary patch.
|
||||
|
||||
diff --git a/common.gypi b/common.gypi
|
||||
index f07e65f719a1a5939997dfcae7bc787ee6391f4d..69b5439a5c19230e5568450c3aca9ce27661d77c 100644
|
||||
index bde7d7300f44596abe5cdfac0639ecb1bb4d885f..412f613e7cfcf563fa6a000b932723166ab567da 100644
|
||||
--- a/common.gypi
|
||||
+++ b/common.gypi
|
||||
@@ -180,6 +180,26 @@
|
||||
@@ -19,7 +19,7 @@
|
||||
'node_use_v8_platform%': 'true',
|
||||
'node_use_bundled_v8%': 'true',
|
||||
'node_module_version%': '',
|
||||
- 'node_with_ltcg%': '',
|
||||
+ 'node_with_ltcg%': 'true',
|
||||
'node_shared_openssl%': 'false',
|
||||
|
||||
'node_tag%': '',
|
||||
@@ -240,6 +240,26 @@
|
||||
'cflags': [ '-fPIE' ],
|
||||
'ldflags': [ '-fPIE', '-pie' ]
|
||||
}],
|
||||
|
||||
@@ -1,912 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samuel Attard <sattard@slack-corp.com>
|
||||
Date: Fri, 28 Jun 2019 16:52:24 -0700
|
||||
Subject: fixme: Revert "crypto: add support for RSA-PSS keys"
|
||||
|
||||
This reverts commit 969bd1eb7b56fda3573ad3d41745a491f2b06dde.
|
||||
|
||||
diff --git a/lib/internal/crypto/keygen.js b/lib/internal/crypto/keygen.js
|
||||
index 0a4bde77fa369b788bd7e2976441358254b13955..37835db411f7577d39e5e2af10590b6fa1b13489 100644
|
||||
--- a/lib/internal/crypto/keygen.js
|
||||
+++ b/lib/internal/crypto/keygen.js
|
||||
@@ -5,7 +5,6 @@ const { Object } = primordials;
|
||||
const { AsyncWrap, Providers } = internalBinding('async_wrap');
|
||||
const {
|
||||
generateKeyPairRSA,
|
||||
- generateKeyPairRSAPSS,
|
||||
generateKeyPairDSA,
|
||||
generateKeyPairEC,
|
||||
generateKeyPairNid,
|
||||
@@ -143,7 +142,6 @@ function check(type, options, callback) {
|
||||
let impl;
|
||||
switch (type) {
|
||||
case 'rsa':
|
||||
- case 'rsa-pss':
|
||||
{
|
||||
const { modulusLength } = needOptions();
|
||||
if (!isUint32(modulusLength))
|
||||
@@ -156,27 +154,10 @@ function check(type, options, callback) {
|
||||
throw new ERR_INVALID_OPT_VALUE('publicExponent', publicExponent);
|
||||
}
|
||||
|
||||
- if (type === 'rsa') {
|
||||
- impl = (wrap) => generateKeyPairRSA(modulusLength, publicExponent,
|
||||
- publicFormat, publicType,
|
||||
- privateFormat, privateType,
|
||||
- cipher, passphrase, wrap);
|
||||
- break;
|
||||
- }
|
||||
-
|
||||
- const { hash, mgf1Hash, saltLength } = options;
|
||||
- if (hash !== undefined && typeof hash !== 'string')
|
||||
- throw new ERR_INVALID_OPT_VALUE('hash', hash);
|
||||
- if (mgf1Hash !== undefined && typeof mgf1Hash !== 'string')
|
||||
- throw new ERR_INVALID_OPT_VALUE('mgf1Hash', mgf1Hash);
|
||||
- if (saltLength !== undefined && !isUint32(saltLength))
|
||||
- throw new ERR_INVALID_OPT_VALUE('saltLength', saltLength);
|
||||
-
|
||||
- impl = (wrap) => generateKeyPairRSAPSS(modulusLength, publicExponent,
|
||||
- hash, mgf1Hash, saltLength,
|
||||
- publicFormat, publicType,
|
||||
- privateFormat, privateType,
|
||||
- cipher, passphrase, wrap);
|
||||
+ impl = (wrap) => generateKeyPairRSA(modulusLength, publicExponent,
|
||||
+ publicFormat, publicType,
|
||||
+ privateFormat, privateType,
|
||||
+ cipher, passphrase, wrap);
|
||||
}
|
||||
break;
|
||||
case 'dsa':
|
||||
@@ -245,7 +226,8 @@ function check(type, options, callback) {
|
||||
break;
|
||||
default:
|
||||
throw new ERR_INVALID_ARG_VALUE('type', type,
|
||||
- 'must be a supported key type');
|
||||
+ "must be one of 'rsa', 'dsa', 'ec', " +
|
||||
+ "'ed25519', 'ed448', 'x25519', 'x448'");
|
||||
}
|
||||
|
||||
if (options) {
|
||||
diff --git a/lib/internal/crypto/sig.js b/lib/internal/crypto/sig.js
|
||||
index b6a3376e735094f970ef61a52ef9bb6d6101647a..bb70c2305fd44cfea46a8df5e65d1af5a86d40db 100644
|
||||
--- a/lib/internal/crypto/sig.js
|
||||
+++ b/lib/internal/crypto/sig.js
|
||||
@@ -14,6 +14,10 @@ const {
|
||||
signOneShot: _signOneShot,
|
||||
verifyOneShot: _verifyOneShot
|
||||
} = internalBinding('crypto');
|
||||
+const {
|
||||
+ RSA_PSS_SALTLEN_AUTO,
|
||||
+ RSA_PKCS1_PADDING
|
||||
+} = internalBinding('constants').crypto;
|
||||
const {
|
||||
getDefaultEncoding,
|
||||
kHandle,
|
||||
@@ -54,14 +58,14 @@ Sign.prototype.update = function update(data, encoding) {
|
||||
};
|
||||
|
||||
function getPadding(options) {
|
||||
- return getIntOption('padding', options);
|
||||
+ return getIntOption('padding', RSA_PKCS1_PADDING, options);
|
||||
}
|
||||
|
||||
function getSaltLength(options) {
|
||||
- return getIntOption('saltLength', options);
|
||||
+ return getIntOption('saltLength', RSA_PSS_SALTLEN_AUTO, options);
|
||||
}
|
||||
|
||||
-function getIntOption(name, options) {
|
||||
+function getIntOption(name, defaultValue, options) {
|
||||
const value = options[name];
|
||||
if (value !== undefined) {
|
||||
if (value === value >> 0) {
|
||||
@@ -70,7 +74,7 @@ function getIntOption(name, options) {
|
||||
throw new ERR_INVALID_OPT_VALUE(name, value);
|
||||
}
|
||||
}
|
||||
- return undefined;
|
||||
+ return defaultValue;
|
||||
}
|
||||
|
||||
Sign.prototype.sign = function sign(options, encoding) {
|
||||
diff --git a/src/env.h b/src/env.h
|
||||
index ecb845803776f5ff6e7eec712ec7a5ebea2e8d0a..1516d77be8514ce55d8d21b78a7cd85ead2cb95f 100644
|
||||
--- a/src/env.h
|
||||
+++ b/src/env.h
|
||||
@@ -173,7 +173,6 @@ constexpr size_t kFsStatsBufferLength = kFsStatsFieldsNumber * 2;
|
||||
V(crypto_x25519_string, "x25519") \
|
||||
V(crypto_x448_string, "x448") \
|
||||
V(crypto_rsa_string, "rsa") \
|
||||
- V(crypto_rsa_pss_string, "rsa-pss") \
|
||||
V(cwd_string, "cwd") \
|
||||
V(data_string, "data") \
|
||||
V(dest_string, "dest") \
|
||||
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
|
||||
index 1cc2372fe2e385e9a9db27e38f0da61d62de2e81..cd09cdb3f2244825f6631891b94e61eeb6bc60bf 100644
|
||||
--- a/src/node_crypto.cc
|
||||
+++ b/src/node_crypto.cc
|
||||
@@ -3727,8 +3727,6 @@ Local<Value> KeyObject::GetAsymmetricKeyType() const {
|
||||
switch (EVP_PKEY_id(this->asymmetric_key_.get())) {
|
||||
case EVP_PKEY_RSA:
|
||||
return env()->crypto_rsa_string();
|
||||
- case EVP_PKEY_RSA_PSS:
|
||||
- return env()->crypto_rsa_pss_string();
|
||||
case EVP_PKEY_DSA:
|
||||
return env()->crypto_dsa_string();
|
||||
case EVP_PKEY_EC:
|
||||
@@ -4775,14 +4773,13 @@ void SignBase::CheckThrow(SignBase::Error error) {
|
||||
static bool ApplyRSAOptions(const ManagedEVPPKey& pkey,
|
||||
EVP_PKEY_CTX* pkctx,
|
||||
int padding,
|
||||
- const Maybe<int>& salt_len) {
|
||||
+ int salt_len) {
|
||||
if (EVP_PKEY_id(pkey.get()) == EVP_PKEY_RSA ||
|
||||
- EVP_PKEY_id(pkey.get()) == EVP_PKEY_RSA2 ||
|
||||
- EVP_PKEY_id(pkey.get()) == EVP_PKEY_RSA_PSS) {
|
||||
+ EVP_PKEY_id(pkey.get()) == EVP_PKEY_RSA2) {
|
||||
if (EVP_PKEY_CTX_set_rsa_padding(pkctx, padding) <= 0)
|
||||
return false;
|
||||
- if (padding == RSA_PKCS1_PSS_PADDING && salt_len.IsJust()) {
|
||||
- if (EVP_PKEY_CTX_set_rsa_pss_saltlen(pkctx, salt_len.FromJust()) <= 0)
|
||||
+ if (padding == RSA_PKCS1_PSS_PADDING) {
|
||||
+ if (EVP_PKEY_CTX_set_rsa_pss_saltlen(pkctx, salt_len) <= 0)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -4833,16 +4830,11 @@ void Sign::SignUpdate(const FunctionCallbackInfo<Value>& args) {
|
||||
sign->CheckThrow(err);
|
||||
}
|
||||
|
||||
-static int GetDefaultSignPadding(const ManagedEVPPKey& key) {
|
||||
- return EVP_PKEY_id(key.get()) == EVP_PKEY_RSA_PSS ? RSA_PKCS1_PSS_PADDING :
|
||||
- RSA_PKCS1_PADDING;
|
||||
-}
|
||||
-
|
||||
static AllocatedBuffer Node_SignFinal(Environment* env,
|
||||
EVPMDPointer&& mdctx,
|
||||
const ManagedEVPPKey& pkey,
|
||||
int padding,
|
||||
- Maybe<int> pss_salt_len) {
|
||||
+ int pss_salt_len) {
|
||||
unsigned char m[EVP_MAX_MD_SIZE];
|
||||
unsigned int m_len;
|
||||
|
||||
@@ -4875,7 +4867,7 @@ static AllocatedBuffer Node_SignFinal(Environment* env,
|
||||
Sign::SignResult Sign::SignFinal(
|
||||
const ManagedEVPPKey& pkey,
|
||||
int padding,
|
||||
- const Maybe<int>& salt_len) {
|
||||
+ int salt_len) {
|
||||
if (!mdctx_)
|
||||
return SignResult(kSignNotInitialised);
|
||||
|
||||
@@ -4926,17 +4918,11 @@ void Sign::SignFinal(const FunctionCallbackInfo<Value>& args) {
|
||||
if (!key)
|
||||
return;
|
||||
|
||||
- int padding = GetDefaultSignPadding(key);
|
||||
- if (!args[offset]->IsUndefined()) {
|
||||
- CHECK(args[offset]->IsInt32());
|
||||
- padding = args[offset].As<Int32>()->Value();
|
||||
- }
|
||||
+ CHECK(args[offset]->IsInt32());
|
||||
+ int padding = args[offset].As<Int32>()->Value();
|
||||
|
||||
- Maybe<int> salt_len = Nothing<int>();
|
||||
- if (!args[offset + 1]->IsUndefined()) {
|
||||
- CHECK(args[offset + 1]->IsInt32());
|
||||
- salt_len = Just<int>(args[offset + 1].As<Int32>()->Value());
|
||||
- }
|
||||
+ CHECK(args[offset + 1]->IsInt32());
|
||||
+ int salt_len = args[offset + 1].As<Int32>()->Value();
|
||||
|
||||
SignResult ret = sign->SignFinal(
|
||||
key,
|
||||
@@ -4997,17 +4983,11 @@ void SignOneShot(const FunctionCallbackInfo<Value>& args) {
|
||||
return CheckThrow(env, SignBase::Error::kSignUnknownDigest);
|
||||
}
|
||||
|
||||
- int rsa_padding = GetDefaultSignPadding(key);
|
||||
- if (!args[offset + 2]->IsUndefined()) {
|
||||
- CHECK(args[offset + 2]->IsInt32());
|
||||
- rsa_padding = args[offset + 2].As<Int32>()->Value();
|
||||
- }
|
||||
+ CHECK(args[offset + 2]->IsInt32());
|
||||
+ int rsa_padding = args[offset + 2].As<Int32>()->Value();
|
||||
|
||||
- Maybe<int> rsa_salt_len = Nothing<int>();
|
||||
- if (!args[offset + 3]->IsUndefined()) {
|
||||
- CHECK(args[offset + 3]->IsInt32());
|
||||
- rsa_salt_len = Just<int>(args[offset + 3].As<Int32>()->Value());
|
||||
- }
|
||||
+ CHECK(args[offset + 3]->IsInt32());
|
||||
+ int rsa_salt_len = args[offset + 3].As<Int32>()->Value();
|
||||
|
||||
EVP_PKEY_CTX* pkctx = nullptr;
|
||||
EVPMDPointer mdctx(EVP_MD_CTX_new());
|
||||
@@ -5085,7 +5065,7 @@ SignBase::Error Verify::VerifyFinal(const ManagedEVPPKey& pkey,
|
||||
const char* sig,
|
||||
int siglen,
|
||||
int padding,
|
||||
- const Maybe<int>& saltlen,
|
||||
+ int saltlen,
|
||||
bool* verify_result) {
|
||||
if (!mdctx_)
|
||||
return kSignNotInitialised;
|
||||
@@ -5129,17 +5109,11 @@ void Verify::VerifyFinal(const FunctionCallbackInfo<Value>& args) {
|
||||
|
||||
ArrayBufferViewContents<char> hbuf(args[offset]);
|
||||
|
||||
- int padding = GetDefaultSignPadding(pkey);
|
||||
- if (!args[offset + 1]->IsUndefined()) {
|
||||
- CHECK(args[offset + 1]->IsInt32());
|
||||
- padding = args[offset + 1].As<Int32>()->Value();
|
||||
- }
|
||||
+ CHECK(args[offset + 1]->IsInt32());
|
||||
+ int padding = args[offset + 1].As<Int32>()->Value();
|
||||
|
||||
- Maybe<int> salt_len = Nothing<int>();
|
||||
- if (!args[offset + 2]->IsUndefined()) {
|
||||
- CHECK(args[offset + 2]->IsInt32());
|
||||
- salt_len = Just<int>(args[offset + 2].As<Int32>()->Value());
|
||||
- }
|
||||
+ CHECK(args[offset + 2]->IsInt32());
|
||||
+ int salt_len = args[offset + 2].As<Int32>()->Value();
|
||||
|
||||
bool verify_result;
|
||||
Error err = verify->VerifyFinal(pkey, hbuf.data(), hbuf.length(), padding,
|
||||
@@ -5172,17 +5146,11 @@ void VerifyOneShot(const FunctionCallbackInfo<Value>& args) {
|
||||
return CheckThrow(env, SignBase::Error::kSignUnknownDigest);
|
||||
}
|
||||
|
||||
- int rsa_padding = GetDefaultSignPadding(key);
|
||||
- if (!args[offset + 3]->IsUndefined()) {
|
||||
- CHECK(args[offset + 3]->IsInt32());
|
||||
- rsa_padding = args[offset + 3].As<Int32>()->Value();
|
||||
- }
|
||||
+ CHECK(args[offset + 3]->IsInt32());
|
||||
+ int rsa_padding = args[offset + 3].As<Int32>()->Value();
|
||||
|
||||
- Maybe<int> rsa_salt_len = Nothing<int>();
|
||||
- if (!args[offset + 4]->IsUndefined()) {
|
||||
- CHECK(args[offset + 4]->IsInt32());
|
||||
- rsa_salt_len = Just<int>(args[offset + 4].As<Int32>()->Value());
|
||||
- }
|
||||
+ CHECK(args[offset + 4]->IsInt32());
|
||||
+ int rsa_salt_len = args[offset + 4].As<Int32>()->Value();
|
||||
|
||||
EVP_PKEY_CTX* pkctx = nullptr;
|
||||
EVPMDPointer mdctx(EVP_MD_CTX_new());
|
||||
@@ -6181,48 +6149,6 @@ class RSAKeyPairGenerationConfig : public KeyPairGenerationConfig {
|
||||
const unsigned int exponent_;
|
||||
};
|
||||
|
||||
-class RSAPSSKeyPairGenerationConfig : public RSAKeyPairGenerationConfig {
|
||||
- public:
|
||||
- RSAPSSKeyPairGenerationConfig(unsigned int modulus_bits,
|
||||
- unsigned int exponent,
|
||||
- const EVP_MD* md,
|
||||
- const EVP_MD* mgf1_md,
|
||||
- int saltlen)
|
||||
- : RSAKeyPairGenerationConfig(modulus_bits, exponent),
|
||||
- md_(md), mgf1_md_(mgf1_md), saltlen_(saltlen) {}
|
||||
-
|
||||
- EVPKeyCtxPointer Setup() override {
|
||||
- return EVPKeyCtxPointer(EVP_PKEY_CTX_new_id(EVP_PKEY_RSA_PSS, nullptr));
|
||||
- }
|
||||
-
|
||||
- bool Configure(const EVPKeyCtxPointer& ctx) override {
|
||||
- if (!RSAKeyPairGenerationConfig::Configure(ctx))
|
||||
- return false;
|
||||
-
|
||||
- if (md_ != nullptr) {
|
||||
- if (EVP_PKEY_CTX_set_rsa_pss_keygen_md(ctx.get(), md_) <= 0)
|
||||
- return false;
|
||||
- }
|
||||
-
|
||||
- if (mgf1_md_ != nullptr) {
|
||||
- if (EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md(ctx.get(), mgf1_md_) <= 0)
|
||||
- return false;
|
||||
- }
|
||||
-
|
||||
- if (saltlen_ >= 0) {
|
||||
- if (EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen(ctx.get(), saltlen_) <= 0)
|
||||
- return false;
|
||||
- }
|
||||
-
|
||||
- return true;
|
||||
- }
|
||||
-
|
||||
- private:
|
||||
- const EVP_MD* md_;
|
||||
- const EVP_MD* mgf1_md_;
|
||||
- const int saltlen_;
|
||||
-};
|
||||
-
|
||||
class DSAKeyPairGenerationConfig : public KeyPairGenerationConfig {
|
||||
public:
|
||||
DSAKeyPairGenerationConfig(unsigned int modulus_bits, int divisor_bits)
|
||||
@@ -6456,44 +6382,6 @@ void GenerateKeyPairRSA(const FunctionCallbackInfo<Value>& args) {
|
||||
GenerateKeyPair(args, 2, std::move(config));
|
||||
}
|
||||
|
||||
-void GenerateKeyPairRSAPSS(const FunctionCallbackInfo<Value>& args) {
|
||||
- Environment* env = Environment::GetCurrent(args);
|
||||
-
|
||||
- CHECK(args[0]->IsUint32());
|
||||
- const uint32_t modulus_bits = args[0].As<Uint32>()->Value();
|
||||
- CHECK(args[1]->IsUint32());
|
||||
- const uint32_t exponent = args[1].As<Uint32>()->Value();
|
||||
-
|
||||
- const EVP_MD* md = nullptr;
|
||||
- if (!args[2]->IsUndefined()) {
|
||||
- CHECK(args[2]->IsString());
|
||||
- String::Utf8Value md_name(env->isolate(), args[2].As<String>());
|
||||
- md = EVP_get_digestbyname(*md_name);
|
||||
- if (md == nullptr)
|
||||
- return env->ThrowTypeError("Digest method not supported");
|
||||
- }
|
||||
-
|
||||
- const EVP_MD* mgf1_md = nullptr;
|
||||
- if (!args[3]->IsUndefined()) {
|
||||
- CHECK(args[3]->IsString());
|
||||
- String::Utf8Value mgf1_md_name(env->isolate(), args[3].As<String>());
|
||||
- mgf1_md = EVP_get_digestbyname(*mgf1_md_name);
|
||||
- if (mgf1_md == nullptr)
|
||||
- return env->ThrowTypeError("Digest method not supported");
|
||||
- }
|
||||
-
|
||||
- int saltlen = -1;
|
||||
- if (!args[4]->IsUndefined()) {
|
||||
- CHECK(args[4]->IsInt32());
|
||||
- saltlen = args[4].As<Int32>()->Value();
|
||||
- }
|
||||
-
|
||||
- std::unique_ptr<KeyPairGenerationConfig> config(
|
||||
- new RSAPSSKeyPairGenerationConfig(modulus_bits, exponent,
|
||||
- md, mgf1_md, saltlen));
|
||||
- GenerateKeyPair(args, 5, std::move(config));
|
||||
-}
|
||||
-
|
||||
void GenerateKeyPairDSA(const FunctionCallbackInfo<Value>& args) {
|
||||
CHECK(args[0]->IsUint32());
|
||||
const uint32_t modulus_bits = args[0].As<Uint32>()->Value();
|
||||
@@ -6945,7 +6833,6 @@ void Initialize(Local<Object> target,
|
||||
|
||||
env->SetMethod(target, "pbkdf2", PBKDF2);
|
||||
env->SetMethod(target, "generateKeyPairRSA", GenerateKeyPairRSA);
|
||||
- env->SetMethod(target, "generateKeyPairRSAPSS", GenerateKeyPairRSAPSS);
|
||||
env->SetMethod(target, "generateKeyPairDSA", GenerateKeyPairDSA);
|
||||
env->SetMethod(target, "generateKeyPairEC", GenerateKeyPairEC);
|
||||
env->SetMethod(target, "generateKeyPairNid", GenerateKeyPairNid);
|
||||
diff --git a/src/node_crypto.h b/src/node_crypto.h
|
||||
index 07ca412e8f7fc6281553ca90a4c3c8c18726c526..04a06affce1de8c567034d084c43b1a016076353 100644
|
||||
--- a/src/node_crypto.h
|
||||
+++ b/src/node_crypto.h
|
||||
@@ -660,7 +660,7 @@ class Sign : public SignBase {
|
||||
SignResult SignFinal(
|
||||
const ManagedEVPPKey& pkey,
|
||||
int padding,
|
||||
- const v8::Maybe<int>& saltlen);
|
||||
+ int saltlen);
|
||||
|
||||
protected:
|
||||
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
@@ -681,7 +681,7 @@ class Verify : public SignBase {
|
||||
const char* sig,
|
||||
int siglen,
|
||||
int padding,
|
||||
- const v8::Maybe<int>& saltlen,
|
||||
+ int saltlen,
|
||||
bool* verify_result);
|
||||
|
||||
protected:
|
||||
diff --git a/test/fixtures/keys/Makefile b/test/fixtures/keys/Makefile
|
||||
index 824704c7241b0ae58f5b4f2768b429f465aafb9b..28afa6685955b1ad57901c776c268cd3aef7d508 100644
|
||||
--- a/test/fixtures/keys/Makefile
|
||||
+++ b/test/fixtures/keys/Makefile
|
||||
@@ -61,12 +61,6 @@ all: \
|
||||
rsa_public_1024.pem \
|
||||
rsa_public_2048.pem \
|
||||
rsa_public_4096.pem \
|
||||
- rsa_pss_private_2048.pem \
|
||||
- rsa_pss_private_2048_sha256_sha256_16.pem \
|
||||
- rsa_pss_private_2048_sha512_sha256_20.pem \
|
||||
- rsa_pss_public_2048.pem \
|
||||
- rsa_pss_public_2048_sha256_sha256_16.pem \
|
||||
- rsa_pss_public_2048_sha512_sha256_20.pem \
|
||||
ed25519_private.pem \
|
||||
ed25519_public.pem \
|
||||
x25519_private.pem \
|
||||
@@ -691,24 +685,6 @@ rsa_public_2048.pem: rsa_private_2048.pem
|
||||
rsa_public_4096.pem: rsa_private_4096.pem
|
||||
openssl rsa -in rsa_private_4096.pem -pubout -out rsa_public_4096.pem
|
||||
|
||||
-rsa_pss_private_2048.pem:
|
||||
- openssl genpkey -algorithm RSA-PSS -pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:65537 -out rsa_pss_private_2048.pem
|
||||
-
|
||||
-rsa_pss_private_2048_sha256_sha256_16.pem:
|
||||
- openssl genpkey -algorithm RSA-PSS -pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:65537 -pkeyopt rsa_pss_keygen_md:sha256 -pkeyopt rsa_pss_keygen_mgf1_md:sha256 -pkeyopt rsa_pss_keygen_saltlen:16 -out rsa_pss_private_2048_sha256_sha256_16.pem
|
||||
-
|
||||
-rsa_pss_private_2048_sha512_sha256_20.pem:
|
||||
- openssl genpkey -algorithm RSA-PSS -pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:65537 -pkeyopt rsa_pss_keygen_md:sha512 -pkeyopt rsa_pss_keygen_mgf1_md:sha256 -pkeyopt rsa_pss_keygen_saltlen:20 -out rsa_pss_private_2048_sha512_sha256_20.pem
|
||||
-
|
||||
-rsa_pss_public_2048.pem: rsa_pss_private_2048.pem
|
||||
- openssl pkey -in rsa_pss_private_2048.pem -pubout -out rsa_pss_public_2048.pem
|
||||
-
|
||||
-rsa_pss_public_2048_sha256_sha256_16.pem: rsa_pss_private_2048_sha256_sha256_16.pem
|
||||
- openssl pkey -in rsa_pss_private_2048_sha256_sha256_16.pem -pubout -out rsa_pss_public_2048_sha256_sha256_16.pem
|
||||
-
|
||||
-rsa_pss_public_2048_sha512_sha256_20.pem: rsa_pss_private_2048_sha512_sha256_20.pem
|
||||
- openssl pkey -in rsa_pss_private_2048_sha512_sha256_20.pem -pubout -out rsa_pss_public_2048_sha512_sha256_20.pem
|
||||
-
|
||||
ed25519_private.pem:
|
||||
openssl genpkey -algorithm ED25519 -out ed25519_private.pem
|
||||
|
||||
diff --git a/test/fixtures/keys/rsa_pss_private_2048.pem b/test/fixtures/keys/rsa_pss_private_2048.pem
|
||||
deleted file mode 100644
|
||||
index ffca137a71219fb6a801c7a905f6607672acb168..0000000000000000000000000000000000000000
|
||||
--- a/test/fixtures/keys/rsa_pss_private_2048.pem
|
||||
+++ /dev/null
|
||||
@@ -1,28 +0,0 @@
|
||||
------BEGIN PRIVATE KEY-----
|
||||
-MIIEvAIBADALBgkqhkiG9w0BAQoEggSoMIIEpAIBAAKCAQEAy4OMdS84PlgI5CRL
|
||||
-bdbud9Ru7vprFr2YNNUmdT7D3YgApiv8CjzKXLiVDnbMET+lwmtag/EcZsxVCKov
|
||||
-su30pYASBriHOiMVYui9+ZaJoQ9yI6lOjG1RbuUBJXNSjHBJxqBqmcgZOb1mdRr/
|
||||
-eXzpAMWJ3hfuLojU2+zUSJ3/rvepepcLFG2q9nA0+PJskJ7Pnh3L0ydnv3U3hduM
|
||||
-n5OVfm/Jx1FPyZpD184tJff+N+MY3s3hIcfuOnL9Pl4RPGeaTC4T1o460NaG6bG7
|
||||
-c2Whg6NOaVgaFIaiNbrTTNCpVjeTyalsTXYlQQ3hiKjst0Q7pfFEkJDo8qiqLad1
|
||||
-Msl59wIDAQABAoIBAQC6G8aqs0/f02nuGDLSc6cH9kCsUlz0ItW6GuJcfdVoFSNi
|
||||
-0v5d7lGwkSveWk0ryOSw8rOHzUqHx3xLvDZ6jpkXcBMMClu/kq3QEb8JK90YaKOc
|
||||
-cQvf52h83Pc7ZEatH1KYTcKudwp6fvXfSZ0vYEdD6WG2tHOgIollxSIsdjCHs1qi
|
||||
-7baNHdK9T4DveuEZNcZ+LraZ1haHmFeqIPcy+KvpGuTaLCg5FPhH2jsIkw9apr7i
|
||||
-iFLi+IJ7S5Bn/8XShmJWk4hPyx0jtIkC5r2iJnHf4x+XYWZfdo7oew3Dg6Pa7T6r
|
||||
-I164Nnaw0u0LvO4gQdvYaJ/j9A602nHTp7Tsq8chAoGBAOtVHgIqpmdzwR5KjotW
|
||||
-LuGXDdO9X6Xfge9ca2MlWH1jOj+zqEV7JtrjnZAzzOgP2kgqzpIR71Njs8wkaxTJ
|
||||
-Tle0Ke6R/ghU9YOQgRByKjqJfQXHZnYFPsMg0diNYLroJ4SG8LO4+2SygTYZ4eKL
|
||||
-qU0bda3QvQ7FL+rTNQBy01b9AoGBAN1jEQI80JxCT7AMvXE6nObIhbkASHte4yOE
|
||||
-1CBwcOuBEGcuvMOvQVMzKITgea6+kgsu4ids4dM5PTPapQgpKqIIQ2/eSesaf56g
|
||||
-73clGGSTPHJP0v+EfKg4+GYJf8o2swT0xDHkgWLgjjdsncB9hATc2j6DvHeau18d
|
||||
-pgCLz9kDAoGAXl/SGvhTp2UqayVnKMW1I07agrGNLA4II5+iiS4u4InskCNSNhr/
|
||||
-KATj6TJ82AuTdCGGmdmLapuvPQzVzI42VsGvlzcA8wJvOwW2XIwMF1GPy8N9eZL8
|
||||
-6m+89+Uqh4oWXvVmjgx+9JEJdFLI3Xs4t+1tMfll+AhoAPoWZUmnK1kCgYAvEBxR
|
||||
-iXQfg8lE97BeHcO1G/OxfGnsMCPBLT+bFcwrhGhkRv9B6kPM2BdJCB9WEpUhY3oY
|
||||
-P4FSUdy85UIoFfhGMdOEOJEmNZ/jrPq7LVueJd63vlhwkU2exV2o82QDLNWpvA7p
|
||||
-PFZ1Gp+hEKoIfaZPElQi7gZmtrIWaksb2pz42QKBgQCct9NP2qJfqeS4206RDnfv
|
||||
-M238/O2lNhLWdSwY0g+tcN+I1sGs3+4vvrm95cxwAmXZyIM11wjdMcAPNxibodY7
|
||||
-vufsebPHDBA0j0yuTjGkXefUKd1GdO88i5fppzxB7prDX9//DsWWrFhIMMRNYe0Q
|
||||
-aeHd/NPuHcjZKcnaVBgukQ==
|
||||
------END PRIVATE KEY-----
|
||||
diff --git a/test/fixtures/keys/rsa_pss_private_2048_sha256_sha256_16.pem b/test/fixtures/keys/rsa_pss_private_2048_sha256_sha256_16.pem
|
||||
deleted file mode 100644
|
||||
index ea4597015401d52dcfdf23c73ee9403b1a0dbbaf..0000000000000000000000000000000000000000
|
||||
--- a/test/fixtures/keys/rsa_pss_private_2048_sha256_sha256_16.pem
|
||||
+++ /dev/null
|
||||
@@ -1,29 +0,0 @@
|
||||
------BEGIN PRIVATE KEY-----
|
||||
-MIIE7wIBADA9BgkqhkiG9w0BAQowMKANMAsGCWCGSAFlAwQCAaEaMBgGCSqGSIb3
|
||||
-DQEBCDALBglghkgBZQMEAgGiAwIBEASCBKkwggSlAgEAAoIBAQDfqNM4C+QtD73i
|
||||
-ILqOkqfV8ha3O19jpX8UujIk1Z72bbbuwEzh0+sBw0dD0N8CgkXnePOEEd6q7HNm
|
||||
-byCNqRpDK6NDvaCMDWgEaD/PlHkRntvKh81IXSMC5imjRfOcZIE/Gnw7h8tanab0
|
||||
-n75+ODvLJrmEWUG2q79Im1mWMx7Spod+Np6XEY+7I7nAUUWivr35Yx5DeyxY8rxF
|
||||
-GpsLtGsi7JNQO4aHyeBpj8tz0Fhv23uPywE2nGmPHfnkXWbrTcHGbzYBgEbeSH9K
|
||||
-UkRwczqDXNOPhtfaEHEFTm0MoeKCnJe1VOjSywev77dV1KZfpVh3Kh0ZRQIe9YOV
|
||||
-Jhj4lMx3AgMBAAECggEBAIc+IgK5Bg/NfgeXvNdrjPuM+PlxeHvb3h1dfebSGd5v
|
||||
-d3elZpgDug6F07kJO2Db/4M5mx7YY2m9swZU2j1u7MeDQqU6rDMkBCruEu/lmtPx
|
||||
-2Hv+ZD6Gux4MqU7mhKmkCJds34Rr16aCwCsZ0WmnfViZoQKLqnXYIsG31pNBdDjx
|
||||
-gke0HhX1LkA9yTVwlk8xOaHPqI4KfsFAyoiiHzyttGDexzb1PzmM0pybAPDMhpN/
|
||||
-wXp2kLjyzmUmPe2Y2yva69WVWo7qS6joKjY75MQ1t20HYgEL69IApvCPu4CANfi9
|
||||
-j3FAaV/+WrnhKCi6QyUi5PCI/+AJLsjNQmqTXIdBEoECgYEA+XsgFbeZ6+ZzEHa7
|
||||
-HyFH6kiyBLd0q7w+ZLPsoOmEApDaP3yXSC7eJU7M/tPUPj8VQMMSK2D6fgmUDwhb
|
||||
-3mEXFZxf67UlPFsFjweYcBihwy4r8QKBwury6dEbHPSUq4mXFJF5XRQdGqRGkr/F
|
||||
-8OLZ0MwmHLUzczA67PxP/wF8TsECgYEA5YD4RxxJJYfAk1rFbqHRhNB8UeYVL+Wo
|
||||
-wsRET1JeFg+S5grLGUga+KBB8Jn7Ahaip7MVE0Iud1cgaDi4WBEJsbJ6oJTlHJEg
|
||||
-Jq7QAaBafwjeSCSnaEsVBVNvriy2WF7uAomLSKmW6uSUOBBFFt4+G+akG56EfOPc
|
||||
-7YKBfsf5ITcCgYBvjVZzX307tfeNTQmuibsWTxsKcN2CTNG5RZpw+PlGDG8KJDOg
|
||||
-2xQJqoqPBzjH/H0MUC03qE1ZPf8uGZa6gL9JsnpRctYLfselhMfsl5b9JxAO3AgZ
|
||||
-l+S2GAH/mH1BlmwvjjyuGehJmVrVE1r2sviiHCaOf5dZ0h8HCGrco1VqAQKBgQCf
|
||||
-fYkMofOTSUvjG2mpAHuCOQCsSaDfsFIfSBXQqgUIf7ouc8HAyAM2VOh+NAPj56cR
|
||||
-s7opsAxqkvnKc+BoEy8Rdl8RyWeO+qvFNicHelBph9gxeod8SvFIyjsKZ7gwoYf1
|
||||
-63AIBxMCGeeHLodU5Q10hkv1hau8vv2BcPhdCstu8QKBgQDgO4Rr36Pa5rjbNbGN
|
||||
-PsJqALjthTeU0yaU8hdC7Hc7B/T6npEIhw3s1eNq7e0eeDltqz7tDnY8qysazbQZ
|
||||
-p1cV5TJ8+gtwGmDoADBnU1NXqX4Squfml6OhNEucpTdjux7JdLVmmQFraOT2Eu5f
|
||||
-9uuNtA+d8uhBEXhskuvEC552ug==
|
||||
------END PRIVATE KEY-----
|
||||
diff --git a/test/fixtures/keys/rsa_pss_private_2048_sha512_sha256_20.pem b/test/fixtures/keys/rsa_pss_private_2048_sha512_sha256_20.pem
|
||||
deleted file mode 100644
|
||||
index f8e898980ad25fd03dda0401fe4f18a148d7fb9f..0000000000000000000000000000000000000000
|
||||
--- a/test/fixtures/keys/rsa_pss_private_2048_sha512_sha256_20.pem
|
||||
+++ /dev/null
|
||||
@@ -1,29 +0,0 @@
|
||||
------BEGIN PRIVATE KEY-----
|
||||
-MIIE5wIBADA4BgkqhkiG9w0BAQowK6ANMAsGCWCGSAFlAwQCA6EaMBgGCSqGSIb3
|
||||
-DQEBCDALBglghkgBZQMEAgEEggSmMIIEogIBAAKCAQEAvM9NgMCDqy5dqj5Ua2cZ
|
||||
-cc4zVr+fCF34bZn63OBeYG8RTJKM3j36lO/yamtfDctDhb87b45CS6ipEr8J57I9
|
||||
-WF55TNngsn6GNpXgwAe0eFXUnKonuqnGEC7x8r3vkAg99PBKhAtFc5oTaaZDAFKM
|
||||
-zc5dIC/J0Y+kxhqjCPNI0ydQgZmKBrmYjM9cvbOYgRQL10GrWeJ+XHk2E33endaF
|
||||
-+4dwjgyrzInt/l6OTkiCL8F59J/htk1GPru9BT6w5yOS/vH6q6FD6uizULVznytd
|
||||
-lHjgnrVaHJmsqVjrYQa9OAZj9GBrTelBWvQ9b6+FBHUFHBp8HSp82lWCZThPrcZ/
|
||||
-QwIDAQABAoIBADDzUfWic8CKuc/sbviVdzxRKHBCJ9oEeub3d9mR9gXsZcDDcfAg
|
||||
-g3nfp6q9gZxS6YOga6llaXyyEnuAufGu/UaO38Xz6tR8BxHZ07YViU11ezTOzJQR
|
||||
-df82HJZBdf2SlXWOYtNPFMd+16+ZYl+QB19INE6m9Rz2r9KIj2I/qM7NPPVhDRF0
|
||||
-G4O0Yf2vaPhjoIaewn7xtQ6wmX7pAGcd8dmYEIGGkBi8aY3BVwrRK1X4AmD+oSmE
|
||||
-wXqR6MQIzD4KdypL4UD1Cb4GoFeVRclXvegOG+EKl0iD+mjTodB4yjoJh98NYe3+
|
||||
-GtpR/2u3Ltq8RqWpIg8ryShQk/MIqGJ5KpkCgYEA80uNEYWlBt6QGNvVIYrhnw+V
|
||||
-2nLJWedioKV4H1sr9OLF/7WFOUfsaflpVybnmwfNV15lEyHb/m/sCM9jTrNk1t/q
|
||||
-qhRnvtmy3kntxWBeoA2o0TRg/XZKWjabZsr/4UE/Ztws2opOvl9x05IYeZlU+PbZ
|
||||
-B1lX2e+vtMOpllvRr28CgYEAxqtfrYv8brp/fAUqGu/MtdHxQdU1+vE+auN17gam
|
||||
-ZM6ojIeasX4k2z0Rd/+8Dga9wPgO7hjtFZ2NWD5UwfBiw5U2PVZ6bp3iKSBPGHEh
|
||||
-RsIR+nw8pFIgsQKoYnVK58tEnfQ31GSupKpYybHbaL5SdId+mfXU86SbKX/MefZX
|
||||
-g20CgYBjn8hAKI2O5ovy4fHALnJ9A5DFRsOUgN8uERPDIz44pLOXJelLr1vreSnd
|
||||
-ehzUqrk20Xxp/S9sXMA2S1XK4EKmikI5KungiJxp0bP/Yprcxzsdj2k34LxJfJrd
|
||||
-2Lo2rtUbdYUYaBIeek7N58EF6feVit8L11XV9APq7UQAQdD3GQKBgBmxuGIdpLw9
|
||||
-apeDo3pwYS1yxZ0aEi0uXkA8wtfSDFslTy89qogiJGomb8fxT0URIiF+849fseoF
|
||||
-wm4TQasDiAJ7ndQ5BwSfbsya3R/wIbmhB+o5fy5RYOED0vtI6DMqWumC2GWjz+KE
|
||||
-FY+gbRwS4V8o1vrajHwmYdrwKGXtskvRAoGADe/EdlCj98r6Zle9giF1C0GDIDTx
|
||||
-8bR2m+Ogh9ZO218GpDMNaQ/WmbYVPDYMbRSOEA7y2gVkd1OeYhJMF6aYffp3aWhN
|
||||
-t9g0uojLY0jfEpWBLBQdlYOTl7hOnLWRRcOAKTlHVg+OuD/O/GmdQ2Rg2H/hAWlI
|
||||
-muuTQPuQTCV1aTc=
|
||||
------END PRIVATE KEY-----
|
||||
diff --git a/test/fixtures/keys/rsa_pss_public_2048.pem b/test/fixtures/keys/rsa_pss_public_2048.pem
|
||||
deleted file mode 100644
|
||||
index ade38f20a44353a88a28cee53fcdb3e13d25f5f7..0000000000000000000000000000000000000000
|
||||
--- a/test/fixtures/keys/rsa_pss_public_2048.pem
|
||||
+++ /dev/null
|
||||
@@ -1,9 +0,0 @@
|
||||
------BEGIN PUBLIC KEY-----
|
||||
-MIIBIDALBgkqhkiG9w0BAQoDggEPADCCAQoCggEBAMuDjHUvOD5YCOQkS23W7nfU
|
||||
-bu76axa9mDTVJnU+w92IAKYr/Ao8yly4lQ52zBE/pcJrWoPxHGbMVQiqL7Lt9KWA
|
||||
-Ega4hzojFWLovfmWiaEPciOpToxtUW7lASVzUoxwScagapnIGTm9ZnUa/3l86QDF
|
||||
-id4X7i6I1Nvs1Eid/673qXqXCxRtqvZwNPjybJCez54dy9MnZ791N4XbjJ+TlX5v
|
||||
-ycdRT8maQ9fOLSX3/jfjGN7N4SHH7jpy/T5eETxnmkwuE9aOOtDWhumxu3NloYOj
|
||||
-TmlYGhSGojW600zQqVY3k8mpbE12JUEN4Yio7LdEO6XxRJCQ6PKoqi2ndTLJefcC
|
||||
-AwEAAQ==
|
||||
------END PUBLIC KEY-----
|
||||
diff --git a/test/fixtures/keys/rsa_pss_public_2048_sha256_sha256_16.pem b/test/fixtures/keys/rsa_pss_public_2048_sha256_sha256_16.pem
|
||||
deleted file mode 100644
|
||||
index 9f8e15bbe0f8f1805c8cc62239a73d390df41b2a..0000000000000000000000000000000000000000
|
||||
--- a/test/fixtures/keys/rsa_pss_public_2048_sha256_sha256_16.pem
|
||||
+++ /dev/null
|
||||
@@ -1,10 +0,0 @@
|
||||
------BEGIN PUBLIC KEY-----
|
||||
-MIIBUjA9BgkqhkiG9w0BAQowMKANMAsGCWCGSAFlAwQCAaEaMBgGCSqGSIb3DQEB
|
||||
-CDALBglghkgBZQMEAgGiAwIBEAOCAQ8AMIIBCgKCAQEA36jTOAvkLQ+94iC6jpKn
|
||||
-1fIWtztfY6V/FLoyJNWe9m227sBM4dPrAcNHQ9DfAoJF53jzhBHequxzZm8gjaka
|
||||
-QyujQ72gjA1oBGg/z5R5EZ7byofNSF0jAuYpo0XznGSBPxp8O4fLWp2m9J++fjg7
|
||||
-yya5hFlBtqu/SJtZljMe0qaHfjaelxGPuyO5wFFFor69+WMeQ3ssWPK8RRqbC7Rr
|
||||
-IuyTUDuGh8ngaY/Lc9BYb9t7j8sBNpxpjx355F1m603Bxm82AYBG3kh/SlJEcHM6
|
||||
-g1zTj4bX2hBxBU5tDKHigpyXtVTo0ssHr++3VdSmX6VYdyodGUUCHvWDlSYY+JTM
|
||||
-dwIDAQAB
|
||||
------END PUBLIC KEY-----
|
||||
diff --git a/test/fixtures/keys/rsa_pss_public_2048_sha512_sha256_20.pem b/test/fixtures/keys/rsa_pss_public_2048_sha512_sha256_20.pem
|
||||
deleted file mode 100644
|
||||
index 9ace7d6d2db7945fbe7ad78a059da0fdc7d9b365..0000000000000000000000000000000000000000
|
||||
--- a/test/fixtures/keys/rsa_pss_public_2048_sha512_sha256_20.pem
|
||||
+++ /dev/null
|
||||
@@ -1,10 +0,0 @@
|
||||
------BEGIN PUBLIC KEY-----
|
||||
-MIIBTTA4BgkqhkiG9w0BAQowK6ANMAsGCWCGSAFlAwQCA6EaMBgGCSqGSIb3DQEB
|
||||
-CDALBglghkgBZQMEAgEDggEPADCCAQoCggEBALzPTYDAg6suXao+VGtnGXHOM1a/
|
||||
-nwhd+G2Z+tzgXmBvEUySjN49+pTv8mprXw3LQ4W/O2+OQkuoqRK/CeeyPVheeUzZ
|
||||
-4LJ+hjaV4MAHtHhV1JyqJ7qpxhAu8fK975AIPfTwSoQLRXOaE2mmQwBSjM3OXSAv
|
||||
-ydGPpMYaowjzSNMnUIGZiga5mIzPXL2zmIEUC9dBq1niflx5NhN93p3WhfuHcI4M
|
||||
-q8yJ7f5ejk5Igi/BefSf4bZNRj67vQU+sOcjkv7x+quhQ+ros1C1c58rXZR44J61
|
||||
-WhyZrKlY62EGvTgGY/Rga03pQVr0PW+vhQR1BRwafB0qfNpVgmU4T63Gf0MCAwEA
|
||||
-AQ==
|
||||
------END PUBLIC KEY-----
|
||||
diff --git a/test/fixtures/test_unknown_privkey.pem b/test/fixtures/test_unknown_privkey.pem
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..4e8e46f04133422128eea2b88a8f378f8b8f842d
|
||||
--- /dev/null
|
||||
+++ b/test/fixtures/test_unknown_privkey.pem
|
||||
@@ -0,0 +1,28 @@
|
||||
+-----BEGIN PRIVATE KEY-----
|
||||
+MIIEugIBADALBgkqhkiG9w0BAQoEggSmMIIEogIBAAKCAQEAwMSNbT9SbSHvXmPt
|
||||
+j1x2Ipk1tUM06301UD91xGcA0232zrIQcKjsPM7bE6YXN0zRxfLJUqalewCk80Ct
|
||||
+6V+E5XtMHUFQt1Ne8HW9U930KnfnQEyU8UwRPoWWeZQhs+sa8ZfggtfN7gq4/wiS
|
||||
+KFNNtSJb24NKoLis31P0nILGC4/JewgE0QaFUoOL+Oc3dMhwWg9/H64sSjhI/SGW
|
||||
+9Sv3M6WcSn7vQCe8oM2vslf3Xm8rHNqZMlXujs7zhRtcr5alKz9BwMJIoGouQrk9
|
||||
+9cgupdYsddgNh2bC4TQR9BMKHj8tV5Uf3Pbf4EoZOFffCbyBZxmKtsYsmhh2FDLA
|
||||
+RzNhKwIDAQABAoIBAHBRlj4ziSmBfmG3Q/ImY8chEkQ9lpYn7GqHr2zyv25yQj6J
|
||||
+Tj72jj+YH9pBCoH0Rr5aCqgX5Y/X/kSmSS8TsvGrd9wL9KX88/KUB+7YAq7EEoBK
|
||||
+nvZB5kJRwC2y/DhDIv3mCrDyYVDz+nrPWaoZb8u861zqEQ+4yzGNT5fqMs8Ewm8A
|
||||
+hxg3GA2R6FC2CymZO884XOxlVac6SNURfA+U+xrcMIXbXpok2Z5eh/kMOeIKwmL0
|
||||
+QEO0U6DEnZm4rJjywu8fEkKbX00YfaDQaiGzRZfvmzkTPIQemXPWARdIvFtJU8Fx
|
||||
+OWWeMumJD1KiU9ISW4e76l7F8UOviT6jEg9rxFECgYEA96WCEIB+O4aO7+s56kOv
|
||||
+vQkEXn959lz7e++S9AV3R19PpBCh50l5v9NSjGQlA4FU4AdBB5EmiX/bLZRHFwHI
|
||||
+KLDsMFuq9id3OPHYIzFP4YjVHTGRPZToJHwy4ePIdZEaeJHY39EEz8oHsSSJlLdm
|
||||
+o0417RsFAfApW2VN63c3JFcCgYEAx0Um/ATsT4ELguVQ+XlquLQdS12XS7zjcwWv
|
||||
+PL8UyooSxcjcbLcJB6DRWXM0NOry7KPUCIF4m3KSjIZypV/v2KVFPCfD3vxZcdB7
|
||||
+xgccqXJMUx7MSs9AMZXTtv5hG7RS5z+ig7Yi/6nzBm21jKYKbFDbqfq8MSfiR6cT
|
||||
+KjR+RU0CgYAm/iFnlcPKfZpd/mylDTlLi3Lrqii6+NMEJam+0GmCjGhOzeugLjqE
|
||||
+ULLLtiz5y1Bg4eOEXH9z4PTSzWkQH1Czz3+w8Y4OqhIknjfI+se4HEJqEVbsGlke
|
||||
+/YtJdAMpN8qyN0ytmQyn5wilBLrA9surZPIqvjlgn77zTBUjwSamiwKBgAqIVS8s
|
||||
+83CgWYNpq4YELOfmXUYGhGC0czE5M7H6R5cNBUD/BOeaJRgKIAaiWDgT0xM+9Y4d
|
||||
+icptm+Fhmd2z3HGPCsHLOEco/3FMm74z0ggCypX6IsIxgiscyDv75hYYyej/LA/a
|
||||
+KK9qxDWqxtXQUOy4uWOapSfT+9ndst2gOKxhAoGAVFcfedCLxummgTtZE91n59pL
|
||||
+TWTk4GgYpWyv6XbHjYrFW2y18qmn0hmEpO+440So0NmGGDtNnPYNUKY/MPjHScwC
|
||||
+FoZMFqqnkmshXz0uDx3gMQK2JDmdF+s3VwZq4Rtb3NJ9v4/WMgWftxaUpAm1/aRC
|
||||
+IHc67mAAez4i8fg2wTQ=
|
||||
+-----END PRIVATE KEY-----
|
||||
diff --git a/test/parallel/test-crypto-key-objects.js b/test/parallel/test-crypto-key-objects.js
|
||||
index 558f7dc1f4b67331629a92cbdd8b1734fdfc5980..a47083b3ace5bb6c27b71adcf65b3769c63994e7 100644
|
||||
--- a/test/parallel/test-crypto-key-objects.js
|
||||
+++ b/test/parallel/test-crypto-key-objects.js
|
||||
@@ -8,8 +8,6 @@ const assert = require('assert');
|
||||
const {
|
||||
createCipheriv,
|
||||
createDecipheriv,
|
||||
- createSign,
|
||||
- createVerify,
|
||||
createSecretKey,
|
||||
createPublicKey,
|
||||
createPrivateKey,
|
||||
@@ -202,6 +200,13 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
|
||||
});
|
||||
}
|
||||
|
||||
+{
|
||||
+ // This should not cause a crash: https://github.com/nodejs/node/pull/26786
|
||||
+ const pem = fixtures.readSync('test_unknown_privkey.pem', 'ascii');
|
||||
+ const key = createPrivateKey(pem);
|
||||
+ assert.strictEqual(key.asymmetricKeyType, undefined);
|
||||
+}
|
||||
+
|
||||
[
|
||||
{ private: fixtures.readKey('ed25519_private.pem', 'ascii'),
|
||||
public: fixtures.readKey('ed25519_public.pem', 'ascii'),
|
||||
@@ -281,146 +286,6 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
|
||||
assert.strictEqual(privateKey.type, 'private');
|
||||
assert.strictEqual(privateKey.asymmetricKeyType, 'dsa');
|
||||
assert.strictEqual(privateKey.symmetricKeySize, undefined);
|
||||
-
|
||||
-}
|
||||
-
|
||||
-{
|
||||
- // Test RSA-PSS.
|
||||
- {
|
||||
- // This key pair does not restrict the message digest algorithm or salt
|
||||
- // length.
|
||||
- const publicPem = fixtures.readKey('rsa_pss_public_2048.pem');
|
||||
- const privatePem = fixtures.readKey('rsa_pss_private_2048.pem');
|
||||
-
|
||||
- const publicKey = createPublicKey(publicPem);
|
||||
- const privateKey = createPrivateKey(privatePem);
|
||||
-
|
||||
- assert.strictEqual(publicKey.type, 'public');
|
||||
- assert.strictEqual(publicKey.asymmetricKeyType, 'rsa-pss');
|
||||
-
|
||||
- assert.strictEqual(privateKey.type, 'private');
|
||||
- assert.strictEqual(privateKey.asymmetricKeyType, 'rsa-pss');
|
||||
-
|
||||
- for (const key of [privatePem, privateKey]) {
|
||||
- // Any algorithm should work.
|
||||
- for (const algo of ['sha1', 'sha256']) {
|
||||
- // Any salt length should work.
|
||||
- for (const saltLength of [undefined, 8, 10, 12, 16, 18, 20]) {
|
||||
- const signature = createSign(algo)
|
||||
- .update('foo')
|
||||
- .sign({ key, saltLength });
|
||||
-
|
||||
- for (const pkey of [key, publicKey, publicPem]) {
|
||||
- const okay = createVerify(algo)
|
||||
- .update('foo')
|
||||
- .verify({ key: pkey, saltLength }, signature);
|
||||
-
|
||||
- assert.ok(okay);
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- // Exporting the key using PKCS#1 should not work since this would discard
|
||||
- // any algorithm restrictions.
|
||||
- common.expectsError(() => {
|
||||
- publicKey.export({ format: 'pem', type: 'pkcs1' });
|
||||
- }, {
|
||||
- code: 'ERR_CRYPTO_INCOMPATIBLE_KEY_OPTIONS'
|
||||
- });
|
||||
- }
|
||||
-
|
||||
- {
|
||||
- // This key pair enforces sha256 as the message digest and the MGF1
|
||||
- // message digest and a salt length of at least 16 bytes.
|
||||
- const publicPem =
|
||||
- fixtures.readKey('rsa_pss_public_2048_sha256_sha256_16.pem');
|
||||
- const privatePem =
|
||||
- fixtures.readKey('rsa_pss_private_2048_sha256_sha256_16.pem');
|
||||
-
|
||||
- const publicKey = createPublicKey(publicPem);
|
||||
- const privateKey = createPrivateKey(privatePem);
|
||||
-
|
||||
- assert.strictEqual(publicKey.type, 'public');
|
||||
- assert.strictEqual(publicKey.asymmetricKeyType, 'rsa-pss');
|
||||
-
|
||||
- assert.strictEqual(privateKey.type, 'private');
|
||||
- assert.strictEqual(privateKey.asymmetricKeyType, 'rsa-pss');
|
||||
-
|
||||
- for (const key of [privatePem, privateKey]) {
|
||||
- // Signing with anything other than sha256 should fail.
|
||||
- assert.throws(() => {
|
||||
- createSign('sha1').sign(key);
|
||||
- }, /digest not allowed/);
|
||||
-
|
||||
- // Signing with salt lengths less than 16 bytes should fail.
|
||||
- for (const saltLength of [8, 10, 12]) {
|
||||
- assert.throws(() => {
|
||||
- createSign('sha1').sign({ key, saltLength });
|
||||
- }, /pss saltlen too small/);
|
||||
- }
|
||||
-
|
||||
- // Signing with sha256 and appropriate salt lengths should work.
|
||||
- for (const saltLength of [undefined, 16, 18, 20]) {
|
||||
- const signature = createSign('sha256')
|
||||
- .update('foo')
|
||||
- .sign({ key, saltLength });
|
||||
-
|
||||
- for (const pkey of [key, publicKey, publicPem]) {
|
||||
- const okay = createVerify('sha256')
|
||||
- .update('foo')
|
||||
- .verify({ key: pkey, saltLength }, signature);
|
||||
-
|
||||
- assert.ok(okay);
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- {
|
||||
- // This key enforces sha512 as the message digest and sha256 as the MGF1
|
||||
- // message digest.
|
||||
- const publicPem =
|
||||
- fixtures.readKey('rsa_pss_public_2048_sha512_sha256_20.pem');
|
||||
- const privatePem =
|
||||
- fixtures.readKey('rsa_pss_private_2048_sha512_sha256_20.pem');
|
||||
-
|
||||
- const publicKey = createPublicKey(publicPem);
|
||||
- const privateKey = createPrivateKey(privatePem);
|
||||
-
|
||||
- assert.strictEqual(publicKey.type, 'public');
|
||||
- assert.strictEqual(publicKey.asymmetricKeyType, 'rsa-pss');
|
||||
-
|
||||
- assert.strictEqual(privateKey.type, 'private');
|
||||
- assert.strictEqual(privateKey.asymmetricKeyType, 'rsa-pss');
|
||||
-
|
||||
- // Node.js usually uses the same hash function for the message and for MGF1.
|
||||
- // However, when a different MGF1 message digest algorithm has been
|
||||
- // specified as part of the key, it should automatically switch to that.
|
||||
- // This behavior is required by sections 3.1 and 3.3 of RFC4055.
|
||||
- for (const key of [privatePem, privateKey]) {
|
||||
- // sha256 matches the MGF1 hash function and should be used internally,
|
||||
- // but it should not be permitted as the main message digest algorithm.
|
||||
- for (const algo of ['sha1', 'sha256']) {
|
||||
- assert.throws(() => {
|
||||
- createSign(algo).sign(key);
|
||||
- }, /digest not allowed/);
|
||||
- }
|
||||
-
|
||||
- // sha512 should produce a valid signature.
|
||||
- const signature = createSign('sha512')
|
||||
- .update('foo')
|
||||
- .sign(key);
|
||||
-
|
||||
- for (const pkey of [key, publicKey, publicPem]) {
|
||||
- const okay = createVerify('sha512')
|
||||
- .update('foo')
|
||||
- .verify(pkey, signature);
|
||||
-
|
||||
- assert.ok(okay);
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
}
|
||||
|
||||
{
|
||||
diff --git a/test/parallel/test-crypto-keygen.js b/test/parallel/test-crypto-keygen.js
|
||||
index 8c3432e06cb6471b0fa0f042cfb0efdedab603f5..ab86c10ef1ea7e4b582db683b90a375ba6e5d2fc 100644
|
||||
--- a/test/parallel/test-crypto-keygen.js
|
||||
+++ b/test/parallel/test-crypto-keygen.js
|
||||
@@ -6,15 +6,12 @@ if (!common.hasCrypto)
|
||||
|
||||
const assert = require('assert');
|
||||
const {
|
||||
- constants,
|
||||
createSign,
|
||||
createVerify,
|
||||
generateKeyPair,
|
||||
generateKeyPairSync,
|
||||
publicEncrypt,
|
||||
- privateDecrypt,
|
||||
- sign,
|
||||
- verify
|
||||
+ privateDecrypt
|
||||
} = require('crypto');
|
||||
const { promisify } = require('util');
|
||||
|
||||
@@ -43,24 +40,13 @@ function testEncryptDecrypt(publicKey, privateKey) {
|
||||
|
||||
// Tests that a key pair can be used for signing / verification.
|
||||
function testSignVerify(publicKey, privateKey) {
|
||||
- const message = Buffer.from('Hello Node.js world!');
|
||||
-
|
||||
- function oldSign(algo, data, key) {
|
||||
- return createSign(algo).update(data).sign(key);
|
||||
- }
|
||||
-
|
||||
- function oldVerify(algo, data, key, signature) {
|
||||
- return createVerify(algo).update(data).verify(key, signature);
|
||||
- }
|
||||
-
|
||||
- for (const signFn of [sign, oldSign]) {
|
||||
- const signature = signFn('SHA256', message, privateKey);
|
||||
- for (const verifyFn of [verify, oldVerify]) {
|
||||
- for (const key of [publicKey, privateKey]) {
|
||||
- const okay = verifyFn('SHA256', message, key, signature);
|
||||
- assert(okay);
|
||||
- }
|
||||
- }
|
||||
+ const message = 'Hello Node.js world!';
|
||||
+ const signature = createSign('SHA256').update(message)
|
||||
+ .sign(privateKey, 'hex');
|
||||
+ for (const key of [publicKey, privateKey]) {
|
||||
+ const okay = createVerify('SHA256').update(message)
|
||||
+ .verify(key, signature, 'hex');
|
||||
+ assert(okay);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,43 +251,6 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
|
||||
}));
|
||||
}
|
||||
|
||||
-{
|
||||
- // Test RSA-PSS.
|
||||
- generateKeyPair('rsa-pss', {
|
||||
- modulusLength: 512,
|
||||
- saltLength: 16,
|
||||
- hash: 'sha256',
|
||||
- mgf1Hash: 'sha256'
|
||||
- }, common.mustCall((err, publicKey, privateKey) => {
|
||||
- assert.ifError(err);
|
||||
-
|
||||
- assert.strictEqual(publicKey.type, 'public');
|
||||
- assert.strictEqual(publicKey.asymmetricKeyType, 'rsa-pss');
|
||||
-
|
||||
- assert.strictEqual(privateKey.type, 'private');
|
||||
- assert.strictEqual(privateKey.asymmetricKeyType, 'rsa-pss');
|
||||
-
|
||||
- // Unlike RSA, RSA-PSS does not allow encryption.
|
||||
- assert.throws(() => {
|
||||
- testEncryptDecrypt(publicKey, privateKey);
|
||||
- }, /operation not supported for this keytype/);
|
||||
-
|
||||
- // RSA-PSS also does not permit signing with PKCS1 padding.
|
||||
- assert.throws(() => {
|
||||
- testSignVerify({
|
||||
- key: publicKey,
|
||||
- padding: constants.RSA_PKCS1_PADDING
|
||||
- }, {
|
||||
- key: privateKey,
|
||||
- padding: constants.RSA_PKCS1_PADDING
|
||||
- });
|
||||
- }, /illegal or unsupported padding mode/);
|
||||
-
|
||||
- // The padding should correctly default to RSA_PKCS1_PSS_PADDING now.
|
||||
- testSignVerify(publicKey, privateKey);
|
||||
- }));
|
||||
-}
|
||||
-
|
||||
{
|
||||
const privateKeyEncoding = {
|
||||
type: 'pkcs8',
|
||||
@@ -606,7 +555,9 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
|
||||
common.expectsError(() => generateKeyPairSync('rsa2', {}), {
|
||||
type: TypeError,
|
||||
code: 'ERR_INVALID_ARG_VALUE',
|
||||
- message: "The argument 'type' must be a supported key type. Received 'rsa2'"
|
||||
+ message: "The argument 'type' must be one of " +
|
||||
+ "'rsa', 'dsa', 'ec', 'ed25519', 'ed448'," +
|
||||
+ " 'x25519', 'x448'. Received 'rsa2'"
|
||||
});
|
||||
}
|
||||
|
||||
58
script/doc-only-change.js
Normal file
58
script/doc-only-change.js
Normal file
@@ -0,0 +1,58 @@
|
||||
const args = require('minimist')(process.argv.slice(2))
|
||||
const octokit = require('@octokit/rest')()
|
||||
const path = require('path')
|
||||
|
||||
const SOURCE_ROOT = path.normalize(path.dirname(__dirname))
|
||||
|
||||
async function checkIfDocOnlyChange () {
|
||||
if (args.prNumber || args.prBranch || args.prURL) {
|
||||
try {
|
||||
let pullRequestNumber = args.prNumber
|
||||
if (!pullRequestNumber || isNaN(pullRequestNumber)) {
|
||||
if (args.prBranch) {
|
||||
// AppVeyor doesn't provide a PR number for branch builds - figure it out from the branch
|
||||
const prsForBranch = await octokit.pulls.list({
|
||||
owner: 'electron',
|
||||
repo: 'electron',
|
||||
state: 'open',
|
||||
head: `electron:${args.prBranch}`
|
||||
})
|
||||
if (prsForBranch.data.length === 1) {
|
||||
pullRequestNumber = prsForBranch.data[0].number
|
||||
} else {
|
||||
// If there is more than one PR on a branch, just assume that this is more than a doc change
|
||||
process.exit(0)
|
||||
}
|
||||
} else if (args.prURL) {
|
||||
// CircleCI doesn't provide the PR number for branch builds, but it does provide the PR URL
|
||||
const pullRequestParts = args.prURL.split('/')
|
||||
pullRequestNumber = pullRequestParts[pullRequestParts.length - 1]
|
||||
}
|
||||
}
|
||||
const filesChanged = await octokit.pulls.listFiles({
|
||||
owner: 'electron', repo: 'electron', pull_number: pullRequestNumber
|
||||
})
|
||||
|
||||
const nonDocChange = filesChanged.data.find((fileInfo) => {
|
||||
const fileDirs = fileInfo.filename.split('/')
|
||||
if (fileDirs[0] !== 'docs') {
|
||||
return true
|
||||
}
|
||||
})
|
||||
if (nonDocChange) {
|
||||
process.exit(1)
|
||||
} else {
|
||||
process.exit(0)
|
||||
}
|
||||
} catch (ex) {
|
||||
console.error('Error getting list of files changed: ', ex)
|
||||
process.exit(-1)
|
||||
}
|
||||
} else {
|
||||
console.error(`Check if only the docs were changed for a commit.
|
||||
Usage: doc-only-change.js --prNumber=PR_NUMBER || --prBranch=PR_BRANCH || --prURL=PR_URL`)
|
||||
process.exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
checkIfDocOnlyChange()
|
||||
@@ -54,7 +54,7 @@ async function handleGitCall (args, gitDir) {
|
||||
|
||||
async function getCurrentBranch (gitDir) {
|
||||
let branch = await handleGitCall(['rev-parse', '--abbrev-ref', 'HEAD'], gitDir)
|
||||
if (branch !== 'master' && !branch.match(/[0-9]+-[0-9]+-x/)) {
|
||||
if (branch !== 'master' && !branch.match(/[0-9]+-[0-9]+-x$/) && !branch.match(/[0-9]+-x-y$/)) {
|
||||
const lastCommit = await handleGitCall(['rev-parse', 'HEAD'], gitDir)
|
||||
const branches = (await handleGitCall([
|
||||
'branch',
|
||||
@@ -63,7 +63,7 @@ async function getCurrentBranch (gitDir) {
|
||||
'--remote'
|
||||
], gitDir)).split('\n')
|
||||
|
||||
branch = branches.filter(b => b.trim() === 'master' || b.match(/[0-9]+-[0-9]+-x/))[0]
|
||||
branch = branches.filter(b => b.trim() === 'master' || b.trim().match(/^[0-9]+-[0-9]+-x$/) || b.trim().match(/^[0-9]+-x-y$/))[0]
|
||||
if (!branch) {
|
||||
console.log(`${fail} no release branch exists for this ref`)
|
||||
process.exit(1)
|
||||
|
||||
@@ -28,9 +28,7 @@
|
||||
#include "content/public/browser/gpu_data_manager.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "gin/arguments.h"
|
||||
#include "media/audio/audio_manager.h"
|
||||
#include "native_mate/object_template_builder_deprecated.h"
|
||||
#include "net/ssl/client_cert_identity.h"
|
||||
#include "net/ssl/ssl_cert_request_info.h"
|
||||
#include "services/service_manager/sandbox/switches.h"
|
||||
@@ -45,15 +43,14 @@
|
||||
#include "shell/browser/relauncher.h"
|
||||
#include "shell/common/application_info.h"
|
||||
#include "shell/common/atom_command_line.h"
|
||||
#include "shell/common/gin_converters/callback_converter.h"
|
||||
#include "shell/common/gin_converters/file_path_converter.h"
|
||||
#include "shell/common/gin_converters/gurl_converter.h"
|
||||
#include "shell/common/gin_converters/image_converter.h"
|
||||
#include "shell/common/gin_converters/net_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/native_mate_converters/callback_converter_deprecated.h"
|
||||
#include "shell/common/native_mate_converters/file_path_converter.h"
|
||||
#include "shell/common/native_mate_converters/gurl_converter.h"
|
||||
#include "shell/common/native_mate_converters/image_converter.h"
|
||||
#include "shell/common/native_mate_converters/net_converter.h"
|
||||
#include "shell/common/native_mate_converters/network_converter.h"
|
||||
#include "shell/common/native_mate_converters/once_callback.h"
|
||||
#include "shell/common/native_mate_converters/value_converter.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "shell/common/options_switches.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
@@ -70,7 +67,7 @@
|
||||
|
||||
using electron::Browser;
|
||||
|
||||
namespace mate {
|
||||
namespace gin {
|
||||
|
||||
#if defined(OS_WIN)
|
||||
template <>
|
||||
@@ -79,15 +76,15 @@ struct Converter<electron::ProcessIntegrityLevel> {
|
||||
electron::ProcessIntegrityLevel value) {
|
||||
switch (value) {
|
||||
case electron::ProcessIntegrityLevel::Untrusted:
|
||||
return mate::StringToV8(isolate, "untrusted");
|
||||
return StringToV8(isolate, "untrusted");
|
||||
case electron::ProcessIntegrityLevel::Low:
|
||||
return mate::StringToV8(isolate, "low");
|
||||
return StringToV8(isolate, "low");
|
||||
case electron::ProcessIntegrityLevel::Medium:
|
||||
return mate::StringToV8(isolate, "medium");
|
||||
return StringToV8(isolate, "medium");
|
||||
case electron::ProcessIntegrityLevel::High:
|
||||
return mate::StringToV8(isolate, "high");
|
||||
return StringToV8(isolate, "high");
|
||||
default:
|
||||
return mate::StringToV8(isolate, "unknown");
|
||||
return StringToV8(isolate, "unknown");
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -97,7 +94,7 @@ struct Converter<Browser::UserTask> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
Browser::UserTask* out) {
|
||||
mate::Dictionary dict;
|
||||
gin_helper::Dictionary dict;
|
||||
if (!ConvertFromV8(isolate, val, &dict))
|
||||
return false;
|
||||
if (!dict.Get("program", &(out->program)) ||
|
||||
@@ -154,7 +151,7 @@ struct Converter<JumpListItem::Type> {
|
||||
item_type = "file";
|
||||
break;
|
||||
}
|
||||
return mate::ConvertToV8(isolate, item_type);
|
||||
return gin::ConvertToV8(isolate, item_type);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -163,7 +160,7 @@ struct Converter<JumpListItem> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
JumpListItem* out) {
|
||||
mate::Dictionary dict;
|
||||
gin_helper::Dictionary dict;
|
||||
if (!ConvertFromV8(isolate, val, &dict))
|
||||
return false;
|
||||
|
||||
@@ -198,7 +195,7 @@ struct Converter<JumpListItem> {
|
||||
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const JumpListItem& val) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("type", val.type);
|
||||
|
||||
switch (val.type) {
|
||||
@@ -266,7 +263,7 @@ struct Converter<JumpListCategory::Type> {
|
||||
category_type = "custom";
|
||||
break;
|
||||
}
|
||||
return mate::ConvertToV8(isolate, category_type);
|
||||
return gin::ConvertToV8(isolate, category_type);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -275,7 +272,7 @@ struct Converter<JumpListCategory> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
JumpListCategory* out) {
|
||||
mate::Dictionary dict;
|
||||
gin_helper::Dictionary dict;
|
||||
if (!ConvertFromV8(isolate, val, &dict))
|
||||
return false;
|
||||
|
||||
@@ -339,7 +336,7 @@ struct Converter<Browser::LoginItemSettings> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
Browser::LoginItemSettings* out) {
|
||||
mate::Dictionary dict;
|
||||
gin_helper::Dictionary dict;
|
||||
if (!ConvertFromV8(isolate, val, &dict))
|
||||
return false;
|
||||
|
||||
@@ -352,7 +349,7 @@ struct Converter<Browser::LoginItemSettings> {
|
||||
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
Browser::LoginItemSettings val) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("openAtLogin", val.open_at_login);
|
||||
dict.Set("openAsHidden", val.open_as_hidden);
|
||||
dict.Set("restoreState", val.restore_state);
|
||||
@@ -376,7 +373,7 @@ struct Converter<content::CertificateRequestResultType> {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
} // namespace gin
|
||||
|
||||
namespace electron {
|
||||
|
||||
@@ -460,7 +457,7 @@ void OnClientCertificateSelected(
|
||||
v8::Isolate* isolate,
|
||||
std::shared_ptr<content::ClientCertificateDelegate> delegate,
|
||||
std::shared_ptr<net::ClientCertIdentityList> identities,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
if (args->Length() == 2) {
|
||||
delegate->ContinueWithCertificate(nullptr, nullptr);
|
||||
return;
|
||||
@@ -473,8 +470,8 @@ void OnClientCertificateSelected(
|
||||
return;
|
||||
}
|
||||
|
||||
mate::Dictionary cert_data;
|
||||
if (!mate::ConvertFromV8(isolate, val, &cert_data)) {
|
||||
gin_helper::Dictionary cert_data;
|
||||
if (!gin::ConvertFromV8(isolate, val, &cert_data)) {
|
||||
args->ThrowError("Must pass valid certificate object.");
|
||||
return;
|
||||
}
|
||||
@@ -499,7 +496,7 @@ void OnClientCertificateSelected(
|
||||
}
|
||||
|
||||
void PassLoginInformation(scoped_refptr<LoginHandler> login_handler,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
base::string16 username, password;
|
||||
if (args->GetNext(&username) && args->GetNext(&password))
|
||||
login_handler->Login(username, password);
|
||||
@@ -537,7 +534,7 @@ int ImportIntoCertStore(CertificateManagerModel* model,
|
||||
|
||||
void OnIconDataAvailable(util::Promise<gfx::Image> promise, gfx::Image icon) {
|
||||
if (!icon.IsEmpty()) {
|
||||
promise.Resolve(icon);
|
||||
promise.ResolveWithGin(icon);
|
||||
} else {
|
||||
promise.RejectWithErrorMessage("Failed to get file icon.");
|
||||
}
|
||||
@@ -1001,13 +998,13 @@ void App::ReleaseSingleInstanceLock() {
|
||||
}
|
||||
}
|
||||
|
||||
bool App::Relaunch(mate::Arguments* js_args) {
|
||||
bool App::Relaunch(gin_helper::Arguments* js_args) {
|
||||
// Parse parameters.
|
||||
bool override_argv = false;
|
||||
base::FilePath exec_path;
|
||||
relauncher::StringVector args;
|
||||
|
||||
mate::Dictionary options;
|
||||
gin_helper::Dictionary options;
|
||||
if (js_args->GetNext(&options)) {
|
||||
if (options.Get("execPath", &exec_path) | options.Get("args", &args))
|
||||
override_argv = true;
|
||||
@@ -1078,7 +1075,8 @@ void App::SetAccessibilitySupportEnabled(gin_helper::ErrorThrower thrower,
|
||||
Browser::Get()->OnAccessibilitySupportChanged();
|
||||
}
|
||||
|
||||
Browser::LoginItemSettings App::GetLoginItemSettings(mate::Arguments* args) {
|
||||
Browser::LoginItemSettings App::GetLoginItemSettings(
|
||||
gin_helper::Arguments* args) {
|
||||
Browser::LoginItemSettings options;
|
||||
args->GetNext(&options);
|
||||
return Browser::Get()->GetLoginItemSettings(options);
|
||||
@@ -1127,18 +1125,18 @@ v8::Local<v8::Value> App::GetJumpListSettings() {
|
||||
LOG(ERROR) << "Failed to begin Jump List transaction.";
|
||||
}
|
||||
|
||||
auto dict = mate::Dictionary::CreateEmpty(isolate());
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate());
|
||||
dict.Set("minItems", min_items);
|
||||
dict.Set("removedItems", mate::ConvertToV8(isolate(), removed_items));
|
||||
dict.Set("removedItems", gin::ConvertToV8(isolate(), removed_items));
|
||||
return dict.GetHandle();
|
||||
}
|
||||
|
||||
JumpListResult App::SetJumpList(v8::Local<v8::Value> val,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
std::vector<JumpListCategory> categories;
|
||||
bool delete_jump_list = val->IsNull();
|
||||
if (!delete_jump_list &&
|
||||
!mate::ConvertFromV8(args->isolate(), val, &categories)) {
|
||||
!gin::ConvertFromV8(args->isolate(), val, &categories)) {
|
||||
args->ThrowError("Argument must be null or an array of categories");
|
||||
return JumpListResult::ARGUMENT_ERROR;
|
||||
}
|
||||
@@ -1171,13 +1169,13 @@ JumpListResult App::SetJumpList(v8::Local<v8::Value> val,
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
v8::Local<v8::Promise> App::GetFileIcon(const base::FilePath& path,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
util::Promise<gfx::Image> promise(isolate());
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
base::FilePath normalized_path = path.NormalizePathSeparators();
|
||||
|
||||
IconLoader::IconSize icon_size;
|
||||
mate::Dictionary options;
|
||||
gin_helper::Dictionary options;
|
||||
if (!args->GetNext(&options)) {
|
||||
icon_size = IconLoader::IconSize::NORMAL;
|
||||
} else {
|
||||
@@ -1190,7 +1188,7 @@ v8::Local<v8::Promise> App::GetFileIcon(const base::FilePath& path,
|
||||
gfx::Image* icon =
|
||||
icon_manager->LookupIconFromFilepath(normalized_path, icon_size);
|
||||
if (icon) {
|
||||
promise.Resolve(*icon);
|
||||
promise.ResolveWithGin(*icon);
|
||||
} else {
|
||||
icon_manager->LoadIcon(
|
||||
normalized_path, icon_size,
|
||||
@@ -1200,14 +1198,14 @@ v8::Local<v8::Promise> App::GetFileIcon(const base::FilePath& path,
|
||||
return handle;
|
||||
}
|
||||
|
||||
std::vector<mate::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
|
||||
std::vector<mate::Dictionary> result;
|
||||
std::vector<gin_helper::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
|
||||
std::vector<gin_helper::Dictionary> result;
|
||||
result.reserve(app_metrics_.size());
|
||||
int processor_count = base::SysInfo::NumberOfProcessors();
|
||||
|
||||
for (const auto& process_metric : app_metrics_) {
|
||||
mate::Dictionary pid_dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
mate::Dictionary cpu_dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
gin_helper::Dictionary pid_dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
gin_helper::Dictionary cpu_dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
|
||||
// TODO(zcbenz): Just call SetHidden when this file is converted to gin.
|
||||
gin_helper::Dictionary(isolate, pid_dict.GetHandle())
|
||||
@@ -1240,7 +1238,7 @@ std::vector<mate::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
|
||||
#if !defined(OS_LINUX)
|
||||
auto memory_info = process_metric.second->GetMemoryInfo();
|
||||
|
||||
mate::Dictionary memory_dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
gin_helper::Dictionary memory_dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
// TODO(zcbenz): Just call SetHidden when this file is converted to gin.
|
||||
gin_helper::Dictionary(isolate, memory_dict.GetHandle())
|
||||
.SetHidden("simple", true);
|
||||
@@ -1276,7 +1274,7 @@ std::vector<mate::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
|
||||
v8::Local<v8::Value> App::GetGPUFeatureStatus(v8::Isolate* isolate) {
|
||||
auto status = content::GetFeatureStatus();
|
||||
base::DictionaryValue temp;
|
||||
return mate::ConvertToV8(isolate, status ? *status : temp);
|
||||
return gin::ConvertToV8(isolate, status ? *status : temp);
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> App::GetGPUInfo(v8::Isolate* isolate,
|
||||
@@ -1352,16 +1350,15 @@ bool App::CanBrowserClientUseCustomSiteInstance() {
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
bool App::MoveToApplicationsFolder(gin_helper::ErrorThrower thrower,
|
||||
mate::Arguments* args) {
|
||||
gin::Arguments gin_args(args->info());
|
||||
return AtomBundleMover::Move(thrower, &gin_args);
|
||||
gin::Arguments* args) {
|
||||
return AtomBundleMover::Move(thrower, args);
|
||||
}
|
||||
|
||||
bool App::IsInApplicationsFolder() {
|
||||
return AtomBundleMover::IsCurrentAppInApplicationsFolder();
|
||||
}
|
||||
|
||||
int DockBounce(mate::Arguments* args) {
|
||||
int DockBounce(gin_helper::Arguments* args) {
|
||||
int request_id = -1;
|
||||
std::string type = "informational";
|
||||
args->GetNext(&type);
|
||||
@@ -1382,7 +1379,7 @@ v8::Local<v8::Value> App::GetDockAPI(v8::Isolate* isolate) {
|
||||
// Initialize the Dock API, the methods are bound to "dock" which exists
|
||||
// for the lifetime of "app"
|
||||
auto browser = base::Unretained(Browser::Get());
|
||||
mate::Dictionary dock_obj = mate::Dictionary::CreateEmpty(isolate);
|
||||
gin_helper::Dictionary dock_obj = gin::Dictionary::CreateEmpty(isolate);
|
||||
dock_obj.SetMethod("bounce", &DockBounce);
|
||||
dock_obj.SetMethod(
|
||||
"cancelBounce",
|
||||
@@ -1411,16 +1408,16 @@ v8::Local<v8::Value> App::GetDockAPI(v8::Isolate* isolate) {
|
||||
#endif
|
||||
|
||||
// static
|
||||
mate::Handle<App> App::Create(v8::Isolate* isolate) {
|
||||
return mate::CreateHandle(isolate, new App(isolate));
|
||||
gin::Handle<App> App::Create(v8::Isolate* isolate) {
|
||||
return gin::CreateHandle(isolate, new App(isolate));
|
||||
}
|
||||
|
||||
// static
|
||||
void App::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "App"));
|
||||
prototype->SetClassName(gin::StringToV8(isolate, "App"));
|
||||
auto browser = base::Unretained(Browser::Get());
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("quit", base::BindRepeating(&Browser::Quit, browser))
|
||||
.SetMethod("exit", base::BindRepeating(&Browser::Exit, browser))
|
||||
.SetMethod("focus", base::BindRepeating(&Browser::Focus, browser))
|
||||
@@ -1552,7 +1549,7 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
gin_helper::Dictionary dict(isolate, exports);
|
||||
dict.Set("App", electron::api::App::GetConstructor(isolate)
|
||||
->GetFunction(context)
|
||||
.ToLocalChecked());
|
||||
|
||||
@@ -17,17 +17,17 @@
|
||||
#include "content/public/browser/browser_child_process_observer.h"
|
||||
#include "content/public/browser/gpu_data_manager_observer.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "gin/handle.h"
|
||||
#include "net/base/completion_once_callback.h"
|
||||
#include "net/base/completion_repeating_callback.h"
|
||||
#include "net/ssl/client_cert_identity.h"
|
||||
#include "shell/browser/api/event_emitter_deprecated.h"
|
||||
#include "shell/browser/api/process_metric.h"
|
||||
#include "shell/browser/atom_browser_client.h"
|
||||
#include "shell/browser/browser.h"
|
||||
#include "shell/browser/browser_observer.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/error_thrower.h"
|
||||
#include "shell/common/gin_helper/event_emitter.h"
|
||||
#include "shell/common/promise_util.h"
|
||||
|
||||
#if defined(USE_NSS_CERTS)
|
||||
@@ -38,10 +38,6 @@ namespace base {
|
||||
class FilePath;
|
||||
}
|
||||
|
||||
namespace mate {
|
||||
class Arguments;
|
||||
} // namespace mate
|
||||
|
||||
namespace electron {
|
||||
|
||||
#if defined(OS_WIN)
|
||||
@@ -51,7 +47,7 @@ enum class JumpListResult : int;
|
||||
namespace api {
|
||||
|
||||
class App : public AtomBrowserClient::Delegate,
|
||||
public mate::EventEmitter<App>,
|
||||
public gin_helper::EventEmitter<App>,
|
||||
public BrowserObserver,
|
||||
public content::GpuDataManagerObserver,
|
||||
public content::BrowserChildProcessObserver {
|
||||
@@ -59,7 +55,7 @@ class App : public AtomBrowserClient::Delegate,
|
||||
using FileIconCallback =
|
||||
base::RepeatingCallback<void(v8::Local<v8::Value>, const gfx::Image&)>;
|
||||
|
||||
static mate::Handle<App> Create(v8::Isolate* isolate);
|
||||
static gin::Handle<App> Create(v8::Isolate* isolate);
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
@@ -182,21 +178,21 @@ class App : public AtomBrowserClient::Delegate,
|
||||
bool HasSingleInstanceLock() const;
|
||||
bool RequestSingleInstanceLock();
|
||||
void ReleaseSingleInstanceLock();
|
||||
bool Relaunch(mate::Arguments* args);
|
||||
bool Relaunch(gin_helper::Arguments* args);
|
||||
void DisableHardwareAcceleration(gin_helper::ErrorThrower thrower);
|
||||
void DisableDomainBlockingFor3DAPIs(gin_helper::ErrorThrower thrower);
|
||||
bool IsAccessibilitySupportEnabled();
|
||||
void SetAccessibilitySupportEnabled(gin_helper::ErrorThrower thrower,
|
||||
bool enabled);
|
||||
Browser::LoginItemSettings GetLoginItemSettings(mate::Arguments* args);
|
||||
Browser::LoginItemSettings GetLoginItemSettings(gin_helper::Arguments* args);
|
||||
#if defined(USE_NSS_CERTS)
|
||||
void ImportCertificate(const base::DictionaryValue& options,
|
||||
net::CompletionRepeatingCallback callback);
|
||||
#endif
|
||||
v8::Local<v8::Promise> GetFileIcon(const base::FilePath& path,
|
||||
mate::Arguments* args);
|
||||
gin_helper::Arguments* args);
|
||||
|
||||
std::vector<mate::Dictionary> GetAppMetrics(v8::Isolate* isolate);
|
||||
std::vector<gin_helper::Dictionary> GetAppMetrics(v8::Isolate* isolate);
|
||||
v8::Local<v8::Value> GetGPUFeatureStatus(v8::Isolate* isolate);
|
||||
v8::Local<v8::Promise> GetGPUInfo(v8::Isolate* isolate,
|
||||
const std::string& info_type);
|
||||
@@ -207,8 +203,7 @@ class App : public AtomBrowserClient::Delegate,
|
||||
bool CanBrowserClientUseCustomSiteInstance();
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
bool MoveToApplicationsFolder(gin_helper::ErrorThrower,
|
||||
mate::Arguments* args);
|
||||
bool MoveToApplicationsFolder(gin_helper::ErrorThrower, gin::Arguments* args);
|
||||
bool IsInApplicationsFolder();
|
||||
v8::Local<v8::Value> GetDockAPI(v8::Isolate* isolate);
|
||||
v8::Global<v8::Value> dock_;
|
||||
@@ -216,7 +211,7 @@ class App : public AtomBrowserClient::Delegate,
|
||||
|
||||
#if defined(MAS_BUILD)
|
||||
base::RepeatingCallback<void()> StartAccessingSecurityScopedResource(
|
||||
mate::Arguments* args);
|
||||
gin_helper::Arguments* args);
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
@@ -224,7 +219,8 @@ class App : public AtomBrowserClient::Delegate,
|
||||
v8::Local<v8::Value> GetJumpListSettings();
|
||||
|
||||
// Set or remove a custom Jump List for the application.
|
||||
JumpListResult SetJumpList(v8::Local<v8::Value> val, mate::Arguments* args);
|
||||
JumpListResult SetJumpList(v8::Local<v8::Value> val,
|
||||
gin_helper::Arguments* args);
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
std::unique_ptr<ProcessSingleton> process_singleton_;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "base/path_service.h"
|
||||
#include "shell/browser/api/atom_api_app.h"
|
||||
#include "shell/browser/atom_paths.h"
|
||||
#include "shell/common/native_mate_converters/file_path_converter.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ void OnStopAccessingSecurityScopedResource(NSURL* bookmarkUrl) {
|
||||
|
||||
// Get base64 encoded NSData, create a bookmark for it and start accessing it.
|
||||
base::RepeatingCallback<void()> App::StartAccessingSecurityScopedResource(
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
std::string data;
|
||||
args->GetNext(&data);
|
||||
NSString* base64str = base::SysUTF8ToNSString(data);
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <string>
|
||||
|
||||
#include "gin/handle.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
#include "shell/browser/auto_updater.h"
|
||||
#include "shell/browser/window_list_observer.h"
|
||||
#include "shell/common/gin_helper/event_emitter.h"
|
||||
@@ -17,10 +16,9 @@ namespace electron {
|
||||
|
||||
namespace api {
|
||||
|
||||
class AutoUpdater
|
||||
: public gin_helper::EventEmitter<mate::Wrappable<AutoUpdater>>,
|
||||
public auto_updater::Delegate,
|
||||
public WindowListObserver {
|
||||
class AutoUpdater : public gin_helper::EventEmitter<AutoUpdater>,
|
||||
public auto_updater::Delegate,
|
||||
public WindowListObserver {
|
||||
public:
|
||||
static gin::Handle<AutoUpdater> Create(v8::Isolate* isolate);
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "shell/browser/api/atom_api_browser_view.h"
|
||||
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "shell/browser/api/atom_api_web_contents.h"
|
||||
#include "shell/browser/browser.h"
|
||||
#include "shell/browser/native_browser_view.h"
|
||||
@@ -64,11 +63,8 @@ BrowserView::BrowserView(gin::Arguments* args,
|
||||
gin::Dictionary::CreateEmpty(isolate);
|
||||
options.Get(options::kWebPreferences, &web_preferences);
|
||||
web_preferences.Set("type", "browserView");
|
||||
mate::Handle<class WebContents> web_contents = WebContents::Create(
|
||||
isolate,
|
||||
// TODO(zcbenz): No need to do convertion after converting constructor
|
||||
// of WebContents to gin.
|
||||
mate::Dictionary(isolate, web_preferences.GetHandle()));
|
||||
gin::Handle<class WebContents> web_contents =
|
||||
WebContents::Create(isolate, web_preferences);
|
||||
|
||||
web_contents_.Reset(isolate, web_contents.ToV8());
|
||||
api_web_contents_ = web_contents.get();
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "gin/handle.h"
|
||||
#include "shell/browser/api/trackable_object.h"
|
||||
#include "shell/browser/native_browser_view.h"
|
||||
#include "shell/common/gin_helper/error_thrower.h"
|
||||
#include "shell/common/gin_helper/trackable_object.h"
|
||||
|
||||
namespace gfx {
|
||||
class Rect;
|
||||
@@ -30,7 +30,7 @@ namespace api {
|
||||
|
||||
class WebContents;
|
||||
|
||||
class BrowserView : public mate::TrackableObject<BrowserView>,
|
||||
class BrowserView : public gin_helper::TrackableObject<BrowserView>,
|
||||
public content::WebContentsObserver {
|
||||
public:
|
||||
static mate::WrappableBase* New(gin_helper::ErrorThrower thrower,
|
||||
|
||||
@@ -12,15 +12,15 @@
|
||||
#include "content/browser/web_contents/web_contents_impl.h" // nogncheck
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "gin/converter.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "shell/browser/browser.h"
|
||||
#include "shell/browser/unresponsive_suppressor.h"
|
||||
#include "shell/browser/web_contents_preferences.h"
|
||||
#include "shell/browser/window_list.h"
|
||||
#include "shell/common/api/constructor.h"
|
||||
#include "shell/common/color_util.h"
|
||||
#include "shell/common/native_mate_converters/value_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "shell/common/options_switches.h"
|
||||
#include "ui/gl/gpu_switching_manager.h"
|
||||
@@ -30,13 +30,14 @@ namespace electron {
|
||||
namespace api {
|
||||
|
||||
BrowserWindow::BrowserWindow(gin::Arguments* args,
|
||||
const mate::Dictionary& options)
|
||||
const gin_helper::Dictionary& options)
|
||||
: TopLevelWindow(args->isolate(), options), weak_factory_(this) {
|
||||
mate::Handle<class WebContents> web_contents;
|
||||
gin::Handle<class WebContents> web_contents;
|
||||
|
||||
// Use options.webPreferences in WebContents.
|
||||
v8::Isolate* isolate = args->isolate();
|
||||
mate::Dictionary web_preferences = mate::Dictionary::CreateEmpty(isolate);
|
||||
gin_helper::Dictionary web_preferences =
|
||||
gin::Dictionary::CreateEmpty(isolate);
|
||||
options.Get(options::kWebPreferences, &web_preferences);
|
||||
|
||||
// Copy the backgroundColor to webContents.
|
||||
@@ -66,8 +67,8 @@ BrowserWindow::BrowserWindow(gin::Arguments* args,
|
||||
auto* existing_preferences =
|
||||
WebContentsPreferences::From(web_contents->web_contents());
|
||||
base::DictionaryValue web_preferences_dict;
|
||||
if (mate::ConvertFromV8(isolate, web_preferences.GetHandle(),
|
||||
&web_preferences_dict)) {
|
||||
if (gin::ConvertFromV8(isolate, web_preferences.GetHandle(),
|
||||
&web_preferences_dict)) {
|
||||
existing_preferences->Clear();
|
||||
existing_preferences->Merge(web_preferences_dict);
|
||||
}
|
||||
@@ -82,7 +83,7 @@ BrowserWindow::BrowserWindow(gin::Arguments* args,
|
||||
Observe(api_web_contents_->web_contents());
|
||||
|
||||
// Keep a copy of the options for later use.
|
||||
mate::Dictionary(isolate, web_contents->GetWrapper())
|
||||
gin_helper::Dictionary(isolate, web_contents->GetWrapper())
|
||||
.Set("browserWindowOptions", options);
|
||||
|
||||
// Associate with BrowserWindow.
|
||||
@@ -195,8 +196,8 @@ void BrowserWindow::OnCloseContents() {
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
for (v8::Local<v8::Value> value : child_windows_.Values(isolate())) {
|
||||
mate::Handle<BrowserWindow> child;
|
||||
if (mate::ConvertFromV8(isolate(), value, &child) && !child.IsEmpty())
|
||||
gin::Handle<BrowserWindow> child;
|
||||
if (gin::ConvertFromV8(isolate(), value, &child) && !child.IsEmpty())
|
||||
child->window()->CloseImmediately();
|
||||
}
|
||||
|
||||
@@ -456,9 +457,9 @@ mate::WrappableBase* BrowserWindow::New(gin_helper::ErrorThrower thrower,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mate::Dictionary options;
|
||||
gin_helper::Dictionary options;
|
||||
if (!(args->Length() == 1 && args->GetNext(&options))) {
|
||||
options = mate::Dictionary::CreateEmpty(args->isolate());
|
||||
options = gin::Dictionary::CreateEmpty(args->isolate());
|
||||
}
|
||||
|
||||
return new BrowserWindow(args, options);
|
||||
@@ -467,8 +468,8 @@ mate::WrappableBase* BrowserWindow::New(gin_helper::ErrorThrower thrower,
|
||||
// static
|
||||
void BrowserWindow::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "BrowserWindow"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
prototype->SetClassName(gin::StringToV8(isolate, "BrowserWindow"));
|
||||
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("focusOnWebView", &BrowserWindow::FocusOnWebView)
|
||||
.SetMethod("blurWebView", &BrowserWindow::BlurWebView)
|
||||
.SetMethod("isWebViewFocused", &BrowserWindow::IsWebViewFocused)
|
||||
@@ -499,7 +500,7 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
gin_helper::Dictionary dict(isolate, exports);
|
||||
dict.Set("BrowserWindow",
|
||||
mate::CreateConstructor<BrowserWindow>(
|
||||
isolate, base::BindRepeating(&BrowserWindow::New)));
|
||||
|
||||
@@ -38,7 +38,7 @@ class BrowserWindow : public TopLevelWindow,
|
||||
}
|
||||
|
||||
protected:
|
||||
BrowserWindow(gin::Arguments* args, const mate::Dictionary& options);
|
||||
BrowserWindow(gin::Arguments* args, const gin_helper::Dictionary& options);
|
||||
~BrowserWindow() override;
|
||||
|
||||
// content::RenderWidgetHost::InputEventObserver:
|
||||
|
||||
@@ -15,14 +15,15 @@
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
#include "gin/dictionary.h"
|
||||
#include "gin/object_template_builder.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "net/cookies/canonical_cookie.h"
|
||||
#include "net/cookies/cookie_store.h"
|
||||
#include "net/cookies/cookie_util.h"
|
||||
#include "shell/browser/atom_browser_context.h"
|
||||
#include "shell/browser/cookie_change_notifier.h"
|
||||
#include "shell/common/native_mate_converters/gurl_converter.h"
|
||||
#include "shell/common/native_mate_converters/value_converter.h"
|
||||
#include "shell/common/gin_converters/gurl_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
@@ -175,7 +176,7 @@ Cookies::Cookies(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
||||
|
||||
Cookies::~Cookies() = default;
|
||||
|
||||
v8::Local<v8::Promise> Cookies::Get(const mate::Dictionary& filter) {
|
||||
v8::Local<v8::Promise> Cookies::Get(const gin_helper::Dictionary& filter) {
|
||||
util::Promise<net::CookieList> promise(isolate());
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
@@ -184,7 +185,7 @@ v8::Local<v8::Promise> Cookies::Get(const mate::Dictionary& filter) {
|
||||
auto* manager = storage_partition->GetCookieManagerForBrowserProcess();
|
||||
|
||||
base::DictionaryValue dict;
|
||||
mate::ConvertFromV8(isolate(), filter.GetHandle(), &dict);
|
||||
gin::ConvertFromV8(isolate(), filter.GetHandle(), &dict);
|
||||
|
||||
std::string url;
|
||||
filter.Get("url", &url);
|
||||
@@ -339,7 +340,7 @@ gin::Handle<Cookies> Cookies::Create(v8::Isolate* isolate,
|
||||
void Cookies::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(gin::StringToV8(isolate, "Cookies"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("get", &Cookies::Get)
|
||||
.SetMethod("remove", &Cookies::Remove)
|
||||
.SetMethod("set", &Cookies::Set)
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
#include "base/callback_list.h"
|
||||
#include "gin/handle.h"
|
||||
#include "net/cookies/canonical_cookie.h"
|
||||
#include "shell/browser/api/trackable_object.h"
|
||||
#include "shell/browser/net/cookie_details.h"
|
||||
#include "shell/common/gin_helper/trackable_object.h"
|
||||
#include "shell/common/promise_util.h"
|
||||
|
||||
namespace base {
|
||||
class DictionaryValue;
|
||||
}
|
||||
|
||||
namespace mate {
|
||||
namespace gin_helper {
|
||||
class Dictionary;
|
||||
}
|
||||
|
||||
@@ -33,12 +33,12 @@ class AtomBrowserContext;
|
||||
|
||||
namespace api {
|
||||
|
||||
class Cookies : public mate::TrackableObject<Cookies> {
|
||||
class Cookies : public gin_helper::TrackableObject<Cookies> {
|
||||
public:
|
||||
static gin::Handle<Cookies> Create(v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context);
|
||||
|
||||
// mate::TrackableObject:
|
||||
// gin_helper::TrackableObject:
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
@@ -46,7 +46,7 @@ class Cookies : public mate::TrackableObject<Cookies> {
|
||||
Cookies(v8::Isolate* isolate, AtomBrowserContext* browser_context);
|
||||
~Cookies() override;
|
||||
|
||||
v8::Local<v8::Promise> Get(const mate::Dictionary& filter);
|
||||
v8::Local<v8::Promise> Get(const gin_helper::Dictionary& filter);
|
||||
v8::Local<v8::Promise> Set(const base::DictionaryValue& details);
|
||||
v8::Local<v8::Promise> Remove(const GURL& url, const std::string& name);
|
||||
v8::Local<v8::Promise> FlushStore();
|
||||
|
||||
@@ -12,8 +12,9 @@
|
||||
#include "base/json/json_writer.h"
|
||||
#include "content/public/browser/devtools_agent_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "shell/common/native_mate_converters/value_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
||||
using content::DevToolsAgentHost;
|
||||
@@ -93,7 +94,7 @@ void Debugger::RenderFrameHostChanged(content::RenderFrameHost* old_rfh,
|
||||
}
|
||||
}
|
||||
|
||||
void Debugger::Attach(mate::Arguments* args) {
|
||||
void Debugger::Attach(gin_helper::Arguments* args) {
|
||||
std::string protocol_version;
|
||||
args->GetNext(&protocol_version);
|
||||
|
||||
@@ -128,7 +129,7 @@ void Debugger::Detach() {
|
||||
AgentHostClosed(agent_host_.get());
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> Debugger::SendCommand(mate::Arguments* args) {
|
||||
v8::Local<v8::Promise> Debugger::SendCommand(gin_helper::Arguments* args) {
|
||||
electron::util::Promise<base::DictionaryValue> promise(isolate());
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
@@ -168,16 +169,16 @@ void Debugger::ClearPendingRequests() {
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<Debugger> Debugger::Create(v8::Isolate* isolate,
|
||||
content::WebContents* web_contents) {
|
||||
return mate::CreateHandle(isolate, new Debugger(isolate, web_contents));
|
||||
gin::Handle<Debugger> Debugger::Create(v8::Isolate* isolate,
|
||||
content::WebContents* web_contents) {
|
||||
return gin::CreateHandle(isolate, new Debugger(isolate, web_contents));
|
||||
}
|
||||
|
||||
// static
|
||||
void Debugger::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "Debugger"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
prototype->SetClassName(gin::StringToV8(isolate, "Debugger"));
|
||||
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("attach", &Debugger::Attach)
|
||||
.SetMethod("isAttached", &Debugger::IsAttached)
|
||||
.SetMethod("detach", &Debugger::Detach)
|
||||
@@ -197,7 +198,7 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary(isolate, exports)
|
||||
gin_helper::Dictionary(isolate, exports)
|
||||
.Set("Debugger", Debugger::GetConstructor(isolate)
|
||||
->GetFunction(context)
|
||||
.ToLocalChecked());
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
#include "base/values.h"
|
||||
#include "content/public/browser/devtools_agent_host_client.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "shell/browser/api/trackable_object.h"
|
||||
#include "gin/handle.h"
|
||||
#include "shell/common/gin_helper/trackable_object.h"
|
||||
#include "shell/common/promise_util.h"
|
||||
|
||||
namespace content {
|
||||
@@ -21,22 +21,18 @@ class DevToolsAgentHost;
|
||||
class WebContents;
|
||||
} // namespace content
|
||||
|
||||
namespace mate {
|
||||
class Arguments;
|
||||
}
|
||||
|
||||
namespace electron {
|
||||
|
||||
namespace api {
|
||||
|
||||
class Debugger : public mate::TrackableObject<Debugger>,
|
||||
class Debugger : public gin_helper::TrackableObject<Debugger>,
|
||||
public content::DevToolsAgentHostClient,
|
||||
public content::WebContentsObserver {
|
||||
public:
|
||||
static mate::Handle<Debugger> Create(v8::Isolate* isolate,
|
||||
content::WebContents* web_contents);
|
||||
static gin::Handle<Debugger> Create(v8::Isolate* isolate,
|
||||
content::WebContents* web_contents);
|
||||
|
||||
// mate::TrackableObject:
|
||||
// gin_helper::TrackableObject:
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
@@ -57,10 +53,10 @@ class Debugger : public mate::TrackableObject<Debugger>,
|
||||
using PendingRequestMap =
|
||||
std::map<int, electron::util::Promise<base::DictionaryValue>>;
|
||||
|
||||
void Attach(mate::Arguments* args);
|
||||
void Attach(gin_helper::Arguments* args);
|
||||
bool IsAttached();
|
||||
void Detach();
|
||||
v8::Local<v8::Promise> SendCommand(mate::Arguments* args);
|
||||
v8::Local<v8::Promise> SendCommand(gin_helper::Arguments* args);
|
||||
void ClearPendingRequests();
|
||||
|
||||
content::WebContents* web_contents_; // Weak Reference.
|
||||
|
||||
@@ -12,17 +12,13 @@
|
||||
#include "chrome/browser/media/webrtc/desktop_media_list_observer.h"
|
||||
#include "chrome/browser/media/webrtc/native_desktop_media_list.h"
|
||||
#include "gin/handle.h"
|
||||
#include "shell/browser/api/trackable_object.h"
|
||||
#include "shell/common/gin_helper/event_emitter.h"
|
||||
#include "shell/common/gin_helper/trackable_object.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
namespace api {
|
||||
|
||||
class DesktopCapturer
|
||||
: public mate::TrackableObject<
|
||||
DesktopCapturer,
|
||||
gin_helper::EventEmitter<mate::Wrappable<DesktopCapturer>>> {
|
||||
class DesktopCapturer : public gin_helper::TrackableObject<DesktopCapturer> {
|
||||
public:
|
||||
struct Source {
|
||||
DesktopMediaList::Source media_list_source;
|
||||
|
||||
@@ -8,15 +8,16 @@
|
||||
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "net/base/filename_util.h"
|
||||
#include "shell/browser/atom_browser_main_parts.h"
|
||||
#include "shell/common/native_mate_converters/file_dialog_converter.h"
|
||||
#include "shell/common/native_mate_converters/file_path_converter.h"
|
||||
#include "shell/common/native_mate_converters/gurl_converter.h"
|
||||
#include "shell/common/gin_converters/file_dialog_converter.h"
|
||||
#include "shell/common/gin_converters/file_path_converter.h"
|
||||
#include "shell/common/gin_converters/gurl_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
||||
namespace mate {
|
||||
namespace gin {
|
||||
|
||||
template <>
|
||||
struct Converter<download::DownloadItem::DownloadState> {
|
||||
@@ -44,7 +45,7 @@ struct Converter<download::DownloadItem::DownloadState> {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
} // namespace gin
|
||||
|
||||
namespace electron {
|
||||
|
||||
@@ -52,7 +53,7 @@ namespace api {
|
||||
|
||||
namespace {
|
||||
|
||||
std::map<uint32_t, v8::Global<v8::Object>> g_download_item_objects;
|
||||
std::map<uint32_t, v8::Global<v8::Value>> g_download_item_objects;
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -188,9 +189,9 @@ double DownloadItem::GetStartTime() const {
|
||||
// static
|
||||
void DownloadItem::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "DownloadItem"));
|
||||
prototype->SetClassName(gin::StringToV8(isolate, "DownloadItem"));
|
||||
gin_helper::Destroyable::MakeDestroyable(isolate, prototype);
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("pause", &DownloadItem::Pause)
|
||||
.SetMethod("isPaused", &DownloadItem::IsPaused)
|
||||
.SetMethod("resume", &DownloadItem::Resume)
|
||||
@@ -218,17 +219,17 @@ void DownloadItem::BuildPrototype(v8::Isolate* isolate,
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<DownloadItem> DownloadItem::Create(v8::Isolate* isolate,
|
||||
download::DownloadItem* item) {
|
||||
gin::Handle<DownloadItem> DownloadItem::Create(v8::Isolate* isolate,
|
||||
download::DownloadItem* item) {
|
||||
auto* existing = TrackableObject::FromWrappedClass(isolate, item);
|
||||
if (existing)
|
||||
return mate::CreateHandle(isolate, static_cast<DownloadItem*>(existing));
|
||||
return gin::CreateHandle(isolate, static_cast<DownloadItem*>(existing));
|
||||
|
||||
auto handle = mate::CreateHandle(isolate, new DownloadItem(isolate, item));
|
||||
auto handle = gin::CreateHandle(isolate, new DownloadItem(isolate, item));
|
||||
|
||||
// Reference this object in case it got garbage collected.
|
||||
g_download_item_objects[handle->weak_map_id()] =
|
||||
v8::Global<v8::Object>(isolate, handle.ToV8());
|
||||
v8::Global<v8::Value>(isolate, handle.ToV8());
|
||||
return handle;
|
||||
}
|
||||
|
||||
@@ -243,7 +244,7 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary(isolate, exports)
|
||||
gin_helper::Dictionary(isolate, exports)
|
||||
.Set("DownloadItem", electron::api::DownloadItem::GetConstructor(isolate)
|
||||
->GetFunction(context)
|
||||
.ToLocalChecked());
|
||||
|
||||
@@ -10,20 +10,20 @@
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include "components/download/public/common/download_item.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "shell/browser/api/trackable_object.h"
|
||||
#include "gin/handle.h"
|
||||
#include "shell/browser/ui/file_dialog.h"
|
||||
#include "shell/common/gin_helper/trackable_object.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
namespace api {
|
||||
|
||||
class DownloadItem : public mate::TrackableObject<DownloadItem>,
|
||||
class DownloadItem : public gin_helper::TrackableObject<DownloadItem>,
|
||||
public download::DownloadItem::Observer {
|
||||
public:
|
||||
static mate::Handle<DownloadItem> Create(v8::Isolate* isolate,
|
||||
download::DownloadItem* item);
|
||||
static gin::Handle<DownloadItem> Create(v8::Isolate* isolate,
|
||||
download::DownloadItem* item);
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
@@ -2,28 +2,25 @@
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "shell/browser/api/event_emitter_deprecated.h"
|
||||
#include "shell/browser/api/event.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/event_emitter.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
||||
namespace {
|
||||
|
||||
v8::Local<v8::Object> CreateWithSender(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> sender) {
|
||||
return mate::internal::CreateJSEvent(isolate, sender, nullptr, base::nullopt);
|
||||
}
|
||||
|
||||
v8::Local<v8::Object> CreateEmpty(v8::Isolate* isolate) {
|
||||
return mate::internal::CreateEmptyJSEvent(isolate);
|
||||
return gin_helper::internal::CreateEvent(isolate, sender);
|
||||
}
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
gin_helper::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("createWithSender", &CreateWithSender);
|
||||
dict.SetMethod("createEmpty", &CreateEmpty);
|
||||
dict.SetMethod("createEmpty", &mate::Event::Create);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -9,10 +9,11 @@
|
||||
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "shell/browser/api/atom_api_system_preferences.h"
|
||||
#include "shell/common/native_mate_converters/accelerator_converter.h"
|
||||
#include "shell/common/native_mate_converters/callback_converter_deprecated.h"
|
||||
#include "shell/common/gin_converters/accelerator_converter.h"
|
||||
#include "shell/common/gin_converters/callback_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
@@ -131,15 +132,15 @@ void GlobalShortcut::UnregisterAll() {
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<GlobalShortcut> GlobalShortcut::Create(v8::Isolate* isolate) {
|
||||
return mate::CreateHandle(isolate, new GlobalShortcut(isolate));
|
||||
gin::Handle<GlobalShortcut> GlobalShortcut::Create(v8::Isolate* isolate) {
|
||||
return gin::CreateHandle(isolate, new GlobalShortcut(isolate));
|
||||
}
|
||||
|
||||
// static
|
||||
void GlobalShortcut::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "GlobalShortcut"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
prototype->SetClassName(gin::StringToV8(isolate, "GlobalShortcut"));
|
||||
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("registerAll", &GlobalShortcut::RegisterAll)
|
||||
.SetMethod("register", &GlobalShortcut::Register)
|
||||
.SetMethod("isRegistered", &GlobalShortcut::IsRegistered)
|
||||
@@ -158,7 +159,7 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
gin_helper::Dictionary dict(isolate, exports);
|
||||
dict.Set("globalShortcut", electron::api::GlobalShortcut::Create(isolate));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "chrome/browser/extensions/global_shortcut_listener.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "shell/browser/api/trackable_object.h"
|
||||
#include "gin/handle.h"
|
||||
#include "shell/common/gin_helper/trackable_object.h"
|
||||
#include "ui/base/accelerators/accelerator.h"
|
||||
|
||||
namespace electron {
|
||||
@@ -20,9 +20,9 @@ namespace electron {
|
||||
namespace api {
|
||||
|
||||
class GlobalShortcut : public extensions::GlobalShortcutListener::Observer,
|
||||
public mate::TrackableObject<GlobalShortcut> {
|
||||
public gin_helper::TrackableObject<GlobalShortcut> {
|
||||
public:
|
||||
static mate::Handle<GlobalShortcut> Create(v8::Isolate* isolate);
|
||||
static gin::Handle<GlobalShortcut> Create(v8::Isolate* isolate);
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "gin/handle.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
#include "shell/browser/mac/in_app_purchase.h"
|
||||
#include "shell/browser/mac/in_app_purchase_observer.h"
|
||||
#include "shell/browser/mac/in_app_purchase_product.h"
|
||||
@@ -20,9 +19,8 @@ namespace electron {
|
||||
|
||||
namespace api {
|
||||
|
||||
class InAppPurchase
|
||||
: public gin_helper::EventEmitter<mate::Wrappable<InAppPurchase>>,
|
||||
public in_app_purchase::TransactionObserver {
|
||||
class InAppPurchase : public gin_helper::EventEmitter<InAppPurchase>,
|
||||
public in_app_purchase::TransactionObserver {
|
||||
public:
|
||||
static gin::Handle<InAppPurchase> Create(v8::Isolate* isolate);
|
||||
|
||||
|
||||
@@ -6,13 +6,12 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "native_mate/constructor.h"
|
||||
#include "shell/browser/native_window.h"
|
||||
#include "shell/common/gin_converters/accelerator_converter.h"
|
||||
#include "shell/common/gin_converters/callback_converter.h"
|
||||
#include "shell/common/gin_converters/image_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/native_mate_converters/accelerator_converter.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
||||
namespace {
|
||||
@@ -88,7 +87,7 @@ bool Menu::GetAcceleratorForCommandIdWithParams(
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
v8::Local<v8::Value> val =
|
||||
get_accelerator_.Run(GetWrapper(), command_id, use_default_accelerator);
|
||||
return mate::ConvertFromV8(isolate(), val, accelerator);
|
||||
return gin::ConvertFromV8(isolate(), val, accelerator);
|
||||
}
|
||||
|
||||
bool Menu::ShouldRegisterAcceleratorForCommandId(int command_id) const {
|
||||
@@ -100,9 +99,9 @@ bool Menu::ShouldRegisterAcceleratorForCommandId(int command_id) const {
|
||||
void Menu::ExecuteCommand(int command_id, int flags) {
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
execute_command_.Run(GetWrapper(),
|
||||
mate::internal::CreateEventFromFlags(isolate(), flags),
|
||||
command_id);
|
||||
execute_command_.Run(
|
||||
GetWrapper(),
|
||||
gin_helper::internal::CreateEventFromFlags(isolate(), flags), command_id);
|
||||
}
|
||||
|
||||
void Menu::OnMenuWillShow(ui::SimpleMenuModel* source) {
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
#include "base/callback.h"
|
||||
#include "gin/arguments.h"
|
||||
#include "shell/browser/api/atom_api_top_level_window.h"
|
||||
#include "shell/browser/api/trackable_object.h"
|
||||
#include "shell/browser/ui/atom_menu_model.h"
|
||||
#include "shell/common/gin_helper/trackable_object.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
namespace api {
|
||||
|
||||
class Menu : public mate::TrackableObject<Menu>,
|
||||
class Menu : public gin_helper::TrackableObject<Menu>,
|
||||
public AtomMenuModel::Delegate,
|
||||
public AtomMenuModel::Observer {
|
||||
public:
|
||||
@@ -122,7 +122,7 @@ class Menu : public mate::TrackableObject<Menu>,
|
||||
|
||||
} // namespace electron
|
||||
|
||||
namespace mate {
|
||||
namespace gin {
|
||||
|
||||
template <>
|
||||
struct Converter<electron::AtomMenuModel*> {
|
||||
@@ -143,6 +143,19 @@ struct Converter<electron::AtomMenuModel*> {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace gin
|
||||
|
||||
namespace mate {
|
||||
|
||||
template <>
|
||||
struct Converter<electron::AtomMenuModel*> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
electron::AtomMenuModel** out) {
|
||||
return gin::ConvertFromV8(isolate, val, out);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
#endif // SHELL_BROWSER_API_ATOM_API_MENU_H_
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef SHELL_BROWSER_API_ATOM_API_NATIVE_THEME_H_
|
||||
#define SHELL_BROWSER_API_ATOM_API_NATIVE_THEME_H_
|
||||
|
||||
#include "shell/browser/api/event_emitter_deprecated.h"
|
||||
#include "shell/common/gin_helper/event_emitter.h"
|
||||
#include "ui/native_theme/native_theme.h"
|
||||
#include "ui/native_theme/native_theme_observer.h"
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace electron {
|
||||
|
||||
namespace api {
|
||||
|
||||
class NativeTheme : public mate::EventEmitter<NativeTheme>,
|
||||
class NativeTheme : public gin_helper::EventEmitter<NativeTheme>,
|
||||
public ui::NativeThemeObserver {
|
||||
public:
|
||||
static v8::Local<v8::Value> Create(v8::Isolate* isolate);
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
|
||||
#include "shell/browser/api/atom_api_net.h"
|
||||
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "gin/handle.h"
|
||||
#include "services/network/public/cpp/features.h"
|
||||
#include "shell/browser/api/atom_api_url_request_ns.h"
|
||||
#include "shell/browser/api/atom_api_url_request.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
|
||||
#include "shell/common/node_includes.h"
|
||||
|
||||
@@ -23,20 +24,20 @@ Net::~Net() = default;
|
||||
|
||||
// static
|
||||
v8::Local<v8::Value> Net::Create(v8::Isolate* isolate) {
|
||||
return mate::CreateHandle(isolate, new Net(isolate)).ToV8();
|
||||
return gin::CreateHandle(isolate, new Net(isolate)).ToV8();
|
||||
}
|
||||
|
||||
// static
|
||||
void Net::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "Net"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
prototype->SetClassName(gin::StringToV8(isolate, "Net"));
|
||||
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetProperty("URLRequest", &Net::URLRequest);
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> Net::URLRequest(v8::Isolate* isolate) {
|
||||
v8::Local<v8::FunctionTemplate> constructor;
|
||||
constructor = URLRequestNS::GetConstructor(isolate);
|
||||
constructor = URLRequest::GetConstructor(isolate);
|
||||
return constructor->GetFunction(isolate->GetCurrentContext())
|
||||
.ToLocalChecked();
|
||||
}
|
||||
@@ -48,7 +49,7 @@ v8::Local<v8::Value> Net::URLRequest(v8::Isolate* isolate) {
|
||||
namespace {
|
||||
|
||||
using electron::api::Net;
|
||||
using electron::api::URLRequestNS;
|
||||
using electron::api::URLRequest;
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
@@ -56,9 +57,9 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
|
||||
URLRequestNS::SetConstructor(isolate, base::BindRepeating(URLRequestNS::New));
|
||||
URLRequest::SetConstructor(isolate, base::BindRepeating(URLRequest::New));
|
||||
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
gin_helper::Dictionary dict(isolate, exports);
|
||||
dict.Set("net", Net::Create(isolate));
|
||||
dict.Set("Net",
|
||||
Net::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
#ifndef SHELL_BROWSER_API_ATOM_API_NET_H_
|
||||
#define SHELL_BROWSER_API_ATOM_API_NET_H_
|
||||
|
||||
#include "shell/browser/api/event_emitter_deprecated.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
namespace api {
|
||||
|
||||
class Net : public mate::EventEmitter<Net> {
|
||||
class Net : public mate::Wrappable<Net> {
|
||||
public:
|
||||
static v8::Local<v8::Value> Create(v8::Isolate* isolate);
|
||||
|
||||
|
||||
@@ -11,15 +11,14 @@
|
||||
#include "components/net_log/chrome_net_log.h"
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
#include "electron/electron_version.h"
|
||||
#include "native_mate/converter.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "shell/browser/atom_browser_context.h"
|
||||
#include "shell/browser/net/system_network_context_manager.h"
|
||||
#include "shell/common/native_mate_converters/file_path_converter.h"
|
||||
#include "shell/common/gin_converters/file_path_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
||||
namespace mate {
|
||||
namespace gin {
|
||||
|
||||
template <>
|
||||
struct Converter<net::NetLogCaptureMode> {
|
||||
@@ -41,7 +40,7 @@ struct Converter<net::NetLogCaptureMode> {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
} // namespace gin
|
||||
|
||||
namespace electron {
|
||||
|
||||
@@ -84,7 +83,7 @@ NetLog::NetLog(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
||||
NetLog::~NetLog() = default;
|
||||
|
||||
v8::Local<v8::Promise> NetLog::StartLogging(base::FilePath log_path,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
if (log_path.empty()) {
|
||||
args->ThrowError("The first parameter must be a valid string");
|
||||
return v8::Local<v8::Promise>();
|
||||
@@ -93,20 +92,20 @@ v8::Local<v8::Promise> NetLog::StartLogging(base::FilePath log_path,
|
||||
net::NetLogCaptureMode capture_mode = net::NetLogCaptureMode::kDefault;
|
||||
uint64_t max_file_size = network::mojom::NetLogExporter::kUnlimitedFileSize;
|
||||
|
||||
mate::Dictionary dict;
|
||||
gin_helper::Dictionary dict;
|
||||
if (args->GetNext(&dict)) {
|
||||
v8::Local<v8::Value> capture_mode_v8;
|
||||
if (dict.Get("captureMode", &capture_mode_v8)) {
|
||||
if (!mate::ConvertFromV8(args->isolate(), capture_mode_v8,
|
||||
&capture_mode)) {
|
||||
if (!gin::ConvertFromV8(args->isolate(), capture_mode_v8,
|
||||
&capture_mode)) {
|
||||
args->ThrowError("Invalid value for captureMode");
|
||||
return v8::Local<v8::Promise>();
|
||||
}
|
||||
}
|
||||
v8::Local<v8::Value> max_file_size_v8;
|
||||
if (dict.Get("maxFileSize", &max_file_size_v8)) {
|
||||
if (!mate::ConvertFromV8(args->isolate(), max_file_size_v8,
|
||||
&max_file_size)) {
|
||||
if (!gin::ConvertFromV8(args->isolate(), max_file_size_v8,
|
||||
&max_file_size)) {
|
||||
args->ThrowError("Invalid value for maxFileSize");
|
||||
return v8::Local<v8::Promise>();
|
||||
}
|
||||
@@ -187,7 +186,7 @@ bool NetLog::IsCurrentlyLogging() const {
|
||||
return !!net_log_exporter_;
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> NetLog::StopLogging(mate::Arguments* args) {
|
||||
v8::Local<v8::Promise> NetLog::StopLogging(gin_helper::Arguments* args) {
|
||||
util::Promise<void*> promise(isolate());
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
@@ -211,16 +210,16 @@ v8::Local<v8::Promise> NetLog::StopLogging(mate::Arguments* args) {
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<NetLog> NetLog::Create(v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context) {
|
||||
return mate::CreateHandle(isolate, new NetLog(isolate, browser_context));
|
||||
gin::Handle<NetLog> NetLog::Create(v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context) {
|
||||
return gin::CreateHandle(isolate, new NetLog(isolate, browser_context));
|
||||
}
|
||||
|
||||
// static
|
||||
void NetLog::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "NetLog"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
prototype->SetClassName(gin::StringToV8(isolate, "NetLog"));
|
||||
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetProperty("currentlyLogging", &NetLog::IsCurrentlyLogging)
|
||||
.SetMethod("startLogging", &NetLog::StartLogging)
|
||||
.SetMethod("stopLogging", &NetLog::StopLogging);
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
#include "base/callback.h"
|
||||
#include "base/optional.h"
|
||||
#include "base/values.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "gin/handle.h"
|
||||
#include "services/network/public/mojom/net_log.mojom.h"
|
||||
#include "shell/browser/api/trackable_object.h"
|
||||
#include "shell/common/gin_helper/trackable_object.h"
|
||||
#include "shell/common/promise_util.h"
|
||||
|
||||
namespace electron {
|
||||
@@ -23,17 +23,17 @@ class AtomBrowserContext;
|
||||
|
||||
namespace api {
|
||||
|
||||
class NetLog : public mate::TrackableObject<NetLog> {
|
||||
class NetLog : public gin_helper::TrackableObject<NetLog> {
|
||||
public:
|
||||
static mate::Handle<NetLog> Create(v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context);
|
||||
static gin::Handle<NetLog> Create(v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context);
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
v8::Local<v8::Promise> StartLogging(base::FilePath log_path,
|
||||
mate::Arguments* args);
|
||||
v8::Local<v8::Promise> StopLogging(mate::Arguments* args);
|
||||
gin_helper::Arguments* args);
|
||||
v8::Local<v8::Promise> StopLogging(gin_helper::Arguments* args);
|
||||
bool IsCurrentlyLogging() const;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include "base/guid.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "native_mate/constructor.h"
|
||||
#include "shell/browser/api/atom_api_menu.h"
|
||||
#include "shell/browser/atom_browser_client.h"
|
||||
#include "shell/browser/browser.h"
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
#include <vector>
|
||||
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "shell/browser/api/trackable_object.h"
|
||||
#include "shell/browser/notifications/notification.h"
|
||||
#include "shell/browser/notifications/notification_delegate.h"
|
||||
#include "shell/browser/notifications/notification_presenter.h"
|
||||
#include "shell/common/gin_helper/error_thrower.h"
|
||||
#include "shell/common/gin_helper/trackable_object.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
|
||||
namespace gin {
|
||||
@@ -25,7 +25,7 @@ namespace electron {
|
||||
|
||||
namespace api {
|
||||
|
||||
class Notification : public mate::TrackableObject<Notification>,
|
||||
class Notification : public gin_helper::TrackableObject<Notification>,
|
||||
public NotificationDelegate {
|
||||
public:
|
||||
static mate::WrappableBase* New(gin_helper::ErrorThrower thrower,
|
||||
|
||||
@@ -7,29 +7,33 @@
|
||||
#include "base/power_monitor/power_monitor.h"
|
||||
#include "base/power_monitor/power_monitor_device_source.h"
|
||||
#include "gin/dictionary.h"
|
||||
#include "gin/handle.h"
|
||||
#include "shell/browser/browser.h"
|
||||
#include "shell/common/gin_converters/callback_converter.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
||||
namespace mate {
|
||||
namespace gin {
|
||||
|
||||
template <>
|
||||
struct Converter<ui::IdleState> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const ui::IdleState& in) {
|
||||
switch (in) {
|
||||
case ui::IDLE_STATE_ACTIVE:
|
||||
return mate::StringToV8(isolate, "active");
|
||||
return StringToV8(isolate, "active");
|
||||
case ui::IDLE_STATE_IDLE:
|
||||
return mate::StringToV8(isolate, "idle");
|
||||
return StringToV8(isolate, "idle");
|
||||
case ui::IDLE_STATE_LOCKED:
|
||||
return mate::StringToV8(isolate, "locked");
|
||||
return StringToV8(isolate, "locked");
|
||||
case ui::IDLE_STATE_UNKNOWN:
|
||||
default:
|
||||
return mate::StringToV8(isolate, "unknown");
|
||||
return StringToV8(isolate, "unknown");
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace mate
|
||||
|
||||
} // namespace gin
|
||||
|
||||
namespace electron {
|
||||
|
||||
@@ -88,7 +92,7 @@ ui::IdleState PowerMonitor::GetSystemIdleState(v8::Isolate* isolate,
|
||||
if (idle_threshold > 0) {
|
||||
return ui::CalculateIdleState(idle_threshold);
|
||||
} else {
|
||||
isolate->ThrowException(v8::Exception::TypeError(mate::StringToV8(
|
||||
isolate->ThrowException(v8::Exception::TypeError(gin::StringToV8(
|
||||
isolate, "Invalid idle threshold, must be greater than 0")));
|
||||
return ui::IDLE_STATE_UNKNOWN;
|
||||
}
|
||||
@@ -102,21 +106,21 @@ int PowerMonitor::GetSystemIdleTime() {
|
||||
v8::Local<v8::Value> PowerMonitor::Create(v8::Isolate* isolate) {
|
||||
if (!Browser::Get()->is_ready()) {
|
||||
isolate->ThrowException(v8::Exception::Error(
|
||||
mate::StringToV8(isolate,
|
||||
"The 'powerMonitor' module can't be used before the "
|
||||
"app 'ready' event")));
|
||||
gin::StringToV8(isolate,
|
||||
"The 'powerMonitor' module can't be used before the "
|
||||
"app 'ready' event")));
|
||||
return v8::Null(isolate);
|
||||
}
|
||||
|
||||
return mate::CreateHandle(isolate, new PowerMonitor(isolate)).ToV8();
|
||||
return gin::CreateHandle(isolate, new PowerMonitor(isolate)).ToV8();
|
||||
}
|
||||
|
||||
// static
|
||||
void PowerMonitor::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "PowerMonitor"));
|
||||
prototype->SetClassName(gin::StringToV8(isolate, "PowerMonitor"));
|
||||
gin_helper::Destroyable::MakeDestroyable(isolate, prototype);
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
#if defined(OS_LINUX)
|
||||
.SetMethod("blockShutdown", &PowerMonitor::BlockShutdown)
|
||||
.SetMethod("unblockShutdown", &PowerMonitor::UnblockShutdown)
|
||||
|
||||
@@ -6,16 +6,15 @@
|
||||
#define SHELL_BROWSER_API_ATOM_API_POWER_MONITOR_H_
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "shell/browser/api/trackable_object.h"
|
||||
#include "shell/browser/lib/power_observer.h"
|
||||
#include "shell/common/gin_helper/trackable_object.h"
|
||||
#include "ui/base/idle/idle.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
namespace api {
|
||||
|
||||
class PowerMonitor : public mate::TrackableObject<PowerMonitor>,
|
||||
class PowerMonitor : public gin_helper::TrackableObject<PowerMonitor>,
|
||||
public PowerObserver {
|
||||
public:
|
||||
static v8::Local<v8::Value> Create(v8::Isolate* isolate);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/api/atom_api_protocol_ns.h"
|
||||
#include "shell/browser/api/atom_api_protocol.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
@@ -159,15 +159,14 @@ std::string ErrorCodeToString(ProtocolError error) {
|
||||
|
||||
} // namespace
|
||||
|
||||
ProtocolNS::ProtocolNS(v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context) {
|
||||
Protocol::Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context) {
|
||||
Init(isolate);
|
||||
AttachAsUserData(browser_context);
|
||||
}
|
||||
|
||||
ProtocolNS::~ProtocolNS() = default;
|
||||
Protocol::~Protocol() = default;
|
||||
|
||||
void ProtocolNS::RegisterURLLoaderFactories(
|
||||
void Protocol::RegisterURLLoaderFactories(
|
||||
content::ContentBrowserClient::NonNetworkURLLoaderFactoryMap* factories) {
|
||||
for (const auto& it : handlers_) {
|
||||
factories->emplace(it.first, std::make_unique<AtomURLLoaderFactory>(
|
||||
@@ -175,47 +174,47 @@ void ProtocolNS::RegisterURLLoaderFactories(
|
||||
}
|
||||
}
|
||||
|
||||
ProtocolError ProtocolNS::RegisterProtocol(ProtocolType type,
|
||||
const std::string& scheme,
|
||||
const ProtocolHandler& handler) {
|
||||
ProtocolError Protocol::RegisterProtocol(ProtocolType type,
|
||||
const std::string& scheme,
|
||||
const ProtocolHandler& handler) {
|
||||
const bool added = base::TryEmplace(handlers_, scheme, type, handler).second;
|
||||
return added ? ProtocolError::OK : ProtocolError::REGISTERED;
|
||||
}
|
||||
|
||||
void ProtocolNS::UnregisterProtocol(const std::string& scheme,
|
||||
gin::Arguments* args) {
|
||||
void Protocol::UnregisterProtocol(const std::string& scheme,
|
||||
gin::Arguments* args) {
|
||||
const bool removed = handlers_.erase(scheme) != 0;
|
||||
const auto error =
|
||||
removed ? ProtocolError::OK : ProtocolError::NOT_REGISTERED;
|
||||
HandleOptionalCallback(args, error);
|
||||
}
|
||||
|
||||
bool ProtocolNS::IsProtocolRegistered(const std::string& scheme) {
|
||||
bool Protocol::IsProtocolRegistered(const std::string& scheme) {
|
||||
return base::Contains(handlers_, scheme);
|
||||
}
|
||||
|
||||
ProtocolError ProtocolNS::InterceptProtocol(ProtocolType type,
|
||||
const std::string& scheme,
|
||||
const ProtocolHandler& handler) {
|
||||
ProtocolError Protocol::InterceptProtocol(ProtocolType type,
|
||||
const std::string& scheme,
|
||||
const ProtocolHandler& handler) {
|
||||
const bool added =
|
||||
base::TryEmplace(intercept_handlers_, scheme, type, handler).second;
|
||||
return added ? ProtocolError::OK : ProtocolError::INTERCEPTED;
|
||||
}
|
||||
|
||||
void ProtocolNS::UninterceptProtocol(const std::string& scheme,
|
||||
gin::Arguments* args) {
|
||||
void Protocol::UninterceptProtocol(const std::string& scheme,
|
||||
gin::Arguments* args) {
|
||||
const bool removed = intercept_handlers_.erase(scheme) != 0;
|
||||
const auto error =
|
||||
removed ? ProtocolError::OK : ProtocolError::NOT_INTERCEPTED;
|
||||
HandleOptionalCallback(args, error);
|
||||
}
|
||||
|
||||
bool ProtocolNS::IsProtocolIntercepted(const std::string& scheme) {
|
||||
bool Protocol::IsProtocolIntercepted(const std::string& scheme) {
|
||||
return base::Contains(intercept_handlers_, scheme);
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> ProtocolNS::IsProtocolHandled(const std::string& scheme,
|
||||
gin::Arguments* args) {
|
||||
v8::Local<v8::Promise> Protocol::IsProtocolHandled(const std::string& scheme,
|
||||
gin::Arguments* args) {
|
||||
node::Environment* env = node::Environment::GetCurrent(args->isolate());
|
||||
EmitDeprecationWarning(
|
||||
env,
|
||||
@@ -236,8 +235,8 @@ v8::Local<v8::Promise> ProtocolNS::IsProtocolHandled(const std::string& scheme,
|
||||
base::Contains(kBuiltinSchemes, scheme));
|
||||
}
|
||||
|
||||
void ProtocolNS::HandleOptionalCallback(gin::Arguments* args,
|
||||
ProtocolError error) {
|
||||
void Protocol::HandleOptionalCallback(gin::Arguments* args,
|
||||
ProtocolError error) {
|
||||
CompletionCallback callback;
|
||||
if (args->GetNext(&callback)) {
|
||||
node::Environment* env = node::Environment::GetCurrent(args->isolate());
|
||||
@@ -254,46 +253,45 @@ void ProtocolNS::HandleOptionalCallback(gin::Arguments* args,
|
||||
}
|
||||
|
||||
// static
|
||||
gin::Handle<ProtocolNS> ProtocolNS::Create(
|
||||
v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context) {
|
||||
return gin::CreateHandle(isolate, new ProtocolNS(isolate, browser_context));
|
||||
gin::Handle<Protocol> Protocol::Create(v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context) {
|
||||
return gin::CreateHandle(isolate, new Protocol(isolate, browser_context));
|
||||
}
|
||||
|
||||
// static
|
||||
void ProtocolNS::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
void Protocol::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(gin::StringToV8(isolate, "Protocol"));
|
||||
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("registerStringProtocol",
|
||||
&ProtocolNS::RegisterProtocolFor<ProtocolType::kString>)
|
||||
&Protocol::RegisterProtocolFor<ProtocolType::kString>)
|
||||
.SetMethod("registerBufferProtocol",
|
||||
&ProtocolNS::RegisterProtocolFor<ProtocolType::kBuffer>)
|
||||
&Protocol::RegisterProtocolFor<ProtocolType::kBuffer>)
|
||||
.SetMethod("registerFileProtocol",
|
||||
&ProtocolNS::RegisterProtocolFor<ProtocolType::kFile>)
|
||||
&Protocol::RegisterProtocolFor<ProtocolType::kFile>)
|
||||
.SetMethod("registerHttpProtocol",
|
||||
&ProtocolNS::RegisterProtocolFor<ProtocolType::kHttp>)
|
||||
&Protocol::RegisterProtocolFor<ProtocolType::kHttp>)
|
||||
.SetMethod("registerStreamProtocol",
|
||||
&ProtocolNS::RegisterProtocolFor<ProtocolType::kStream>)
|
||||
&Protocol::RegisterProtocolFor<ProtocolType::kStream>)
|
||||
.SetMethod("registerProtocol",
|
||||
&ProtocolNS::RegisterProtocolFor<ProtocolType::kFree>)
|
||||
.SetMethod("unregisterProtocol", &ProtocolNS::UnregisterProtocol)
|
||||
.SetMethod("isProtocolRegistered", &ProtocolNS::IsProtocolRegistered)
|
||||
.SetMethod("isProtocolHandled", &ProtocolNS::IsProtocolHandled)
|
||||
&Protocol::RegisterProtocolFor<ProtocolType::kFree>)
|
||||
.SetMethod("unregisterProtocol", &Protocol::UnregisterProtocol)
|
||||
.SetMethod("isProtocolRegistered", &Protocol::IsProtocolRegistered)
|
||||
.SetMethod("isProtocolHandled", &Protocol::IsProtocolHandled)
|
||||
.SetMethod("interceptStringProtocol",
|
||||
&ProtocolNS::InterceptProtocolFor<ProtocolType::kString>)
|
||||
&Protocol::InterceptProtocolFor<ProtocolType::kString>)
|
||||
.SetMethod("interceptBufferProtocol",
|
||||
&ProtocolNS::InterceptProtocolFor<ProtocolType::kBuffer>)
|
||||
&Protocol::InterceptProtocolFor<ProtocolType::kBuffer>)
|
||||
.SetMethod("interceptFileProtocol",
|
||||
&ProtocolNS::InterceptProtocolFor<ProtocolType::kFile>)
|
||||
&Protocol::InterceptProtocolFor<ProtocolType::kFile>)
|
||||
.SetMethod("interceptHttpProtocol",
|
||||
&ProtocolNS::InterceptProtocolFor<ProtocolType::kHttp>)
|
||||
&Protocol::InterceptProtocolFor<ProtocolType::kHttp>)
|
||||
.SetMethod("interceptStreamProtocol",
|
||||
&ProtocolNS::InterceptProtocolFor<ProtocolType::kStream>)
|
||||
&Protocol::InterceptProtocolFor<ProtocolType::kStream>)
|
||||
.SetMethod("interceptProtocol",
|
||||
&ProtocolNS::InterceptProtocolFor<ProtocolType::kFree>)
|
||||
.SetMethod("uninterceptProtocol", &ProtocolNS::UninterceptProtocol)
|
||||
.SetMethod("isProtocolIntercepted", &ProtocolNS::IsProtocolIntercepted);
|
||||
&Protocol::InterceptProtocolFor<ProtocolType::kFree>)
|
||||
.SetMethod("uninterceptProtocol", &Protocol::UninterceptProtocol)
|
||||
.SetMethod("isProtocolIntercepted", &Protocol::IsProtocolIntercepted);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
@@ -2,17 +2,17 @@
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_BROWSER_API_ATOM_API_PROTOCOL_NS_H_
|
||||
#define SHELL_BROWSER_API_ATOM_API_PROTOCOL_NS_H_
|
||||
#ifndef SHELL_BROWSER_API_ATOM_API_PROTOCOL_H_
|
||||
#define SHELL_BROWSER_API_ATOM_API_PROTOCOL_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "content/public/browser/content_browser_client.h"
|
||||
#include "gin/handle.h"
|
||||
#include "shell/browser/api/trackable_object.h"
|
||||
#include "shell/browser/net/atom_url_loader_factory.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/trackable_object.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
@@ -35,10 +35,10 @@ enum class ProtocolError {
|
||||
};
|
||||
|
||||
// Protocol implementation based on network services.
|
||||
class ProtocolNS : public mate::TrackableObject<ProtocolNS> {
|
||||
class Protocol : public gin_helper::TrackableObject<Protocol> {
|
||||
public:
|
||||
static gin::Handle<ProtocolNS> Create(v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context);
|
||||
static gin::Handle<Protocol> Create(v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context);
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
@@ -50,8 +50,8 @@ class ProtocolNS : public mate::TrackableObject<ProtocolNS> {
|
||||
const HandlersMap& intercept_handlers() const { return intercept_handlers_; }
|
||||
|
||||
private:
|
||||
ProtocolNS(v8::Isolate* isolate, AtomBrowserContext* browser_context);
|
||||
~ProtocolNS() override;
|
||||
Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context);
|
||||
~Protocol() override;
|
||||
|
||||
// Callback types.
|
||||
using CompletionCallback =
|
||||
@@ -99,4 +99,4 @@ class ProtocolNS : public mate::TrackableObject<ProtocolNS> {
|
||||
|
||||
} // namespace electron
|
||||
|
||||
#endif // SHELL_BROWSER_API_ATOM_API_PROTOCOL_NS_H_
|
||||
#endif // SHELL_BROWSER_API_ATOM_API_PROTOCOL_H_
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "native_mate/wrappable.h"
|
||||
#include "shell/common/gin_helper/error_thrower.h"
|
||||
#include "shell/common/gin_helper/event_emitter.h"
|
||||
#include "ui/display/display_observer.h"
|
||||
@@ -23,7 +22,7 @@ namespace electron {
|
||||
|
||||
namespace api {
|
||||
|
||||
class Screen : public gin_helper::EventEmitter<mate::Wrappable<Screen>>,
|
||||
class Screen : public gin_helper::EventEmitter<Screen>,
|
||||
public display::DisplayObserver {
|
||||
public:
|
||||
static v8::Local<v8::Value> Create(gin_helper::ErrorThrower error_thrower);
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
#include "mojo/public/cpp/bindings/pending_remote.h"
|
||||
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder_deprecated.h"
|
||||
#include "net/base/completion_repeating_callback.h"
|
||||
#include "net/base/load_flags.h"
|
||||
#include "net/http/http_auth_handler_factory.h"
|
||||
@@ -45,8 +43,8 @@
|
||||
#include "shell/browser/api/atom_api_data_pipe_holder.h"
|
||||
#include "shell/browser/api/atom_api_download_item.h"
|
||||
#include "shell/browser/api/atom_api_net_log.h"
|
||||
#include "shell/browser/api/atom_api_protocol_ns.h"
|
||||
#include "shell/browser/api/atom_api_web_request_ns.h"
|
||||
#include "shell/browser/api/atom_api_protocol.h"
|
||||
#include "shell/browser/api/atom_api_web_request.h"
|
||||
#include "shell/browser/atom_browser_context.h"
|
||||
#include "shell/browser/atom_browser_main_parts.h"
|
||||
#include "shell/browser/atom_permission_manager.h"
|
||||
@@ -54,13 +52,14 @@
|
||||
#include "shell/browser/media/media_device_id_salt.h"
|
||||
#include "shell/browser/net/cert_verifier_client.h"
|
||||
#include "shell/browser/session_preferences.h"
|
||||
#include "shell/common/native_mate_converters/callback_converter_deprecated.h"
|
||||
#include "shell/common/native_mate_converters/content_converter.h"
|
||||
#include "shell/common/native_mate_converters/file_path_converter.h"
|
||||
#include "shell/common/native_mate_converters/gurl_converter.h"
|
||||
#include "shell/common/native_mate_converters/net_converter.h"
|
||||
#include "shell/common/native_mate_converters/once_callback.h"
|
||||
#include "shell/common/native_mate_converters/value_converter.h"
|
||||
#include "shell/common/gin_converters/callback_converter.h"
|
||||
#include "shell/common/gin_converters/content_converter.h"
|
||||
#include "shell/common/gin_converters/file_path_converter.h"
|
||||
#include "shell/common/gin_converters/gurl_converter.h"
|
||||
#include "shell/common/gin_converters/net_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "shell/common/options_switches.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
@@ -122,14 +121,14 @@ uint32_t GetQuotaMask(const std::vector<std::string>& quota_types) {
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace mate {
|
||||
namespace gin {
|
||||
|
||||
template <>
|
||||
struct Converter<ClearStorageDataOptions> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
ClearStorageDataOptions* out) {
|
||||
mate::Dictionary options;
|
||||
gin_helper::Dictionary options;
|
||||
if (!ConvertFromV8(isolate, val, &options))
|
||||
return false;
|
||||
options.Get("origin", &out->origin);
|
||||
@@ -142,7 +141,7 @@ struct Converter<ClearStorageDataOptions> {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
} // namespace gin
|
||||
|
||||
namespace electron {
|
||||
|
||||
@@ -153,7 +152,7 @@ namespace {
|
||||
const char kPersistPrefix[] = "persist:";
|
||||
|
||||
// Referenced session objects.
|
||||
std::map<uint32_t, v8::Global<v8::Object>> g_sessions;
|
||||
std::map<uint32_t, v8::Global<v8::Value>> g_sessions;
|
||||
|
||||
void DownloadIdCallback(content::DownloadManager* download_manager,
|
||||
const base::FilePath& path,
|
||||
@@ -239,7 +238,7 @@ void Session::OnDownloadCreated(content::DownloadManager* manager,
|
||||
}
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> Session::ResolveProxy(mate::Arguments* args) {
|
||||
v8::Local<v8::Promise> Session::ResolveProxy(gin_helper::Arguments* args) {
|
||||
v8::Isolate* isolate = args->isolate();
|
||||
util::Promise<std::string> promise(isolate);
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
@@ -292,7 +291,7 @@ v8::Local<v8::Promise> Session::ClearCache() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> Session::ClearStorageData(mate::Arguments* args) {
|
||||
v8::Local<v8::Promise> Session::ClearStorageData(gin_helper::Arguments* args) {
|
||||
v8::Isolate* isolate = args->isolate();
|
||||
util::Promise<void*> promise(isolate);
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
@@ -322,12 +321,12 @@ void Session::FlushStorageData() {
|
||||
storage_partition->Flush();
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> Session::SetProxy(mate::Arguments* args) {
|
||||
v8::Local<v8::Promise> Session::SetProxy(gin_helper::Arguments* args) {
|
||||
v8::Isolate* isolate = args->isolate();
|
||||
util::Promise<void*> promise(isolate);
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
mate::Dictionary options;
|
||||
gin_helper::Dictionary options;
|
||||
args->GetNext(&options);
|
||||
|
||||
if (!browser_context_->in_memory_pref_store()) {
|
||||
@@ -368,7 +367,7 @@ void Session::SetDownloadPath(const base::FilePath& path) {
|
||||
path);
|
||||
}
|
||||
|
||||
void Session::EnableNetworkEmulation(const mate::Dictionary& options) {
|
||||
void Session::EnableNetworkEmulation(const gin_helper::Dictionary& options) {
|
||||
auto conditions = network::mojom::NetworkConditions::New();
|
||||
|
||||
options.Get("offline", &conditions->offline);
|
||||
@@ -395,9 +394,9 @@ void Session::DisableNetworkEmulation() {
|
||||
}
|
||||
|
||||
void Session::SetCertVerifyProc(v8::Local<v8::Value> val,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
CertVerifierClient::CertVerifyProc proc;
|
||||
if (!(val->IsNull() || mate::ConvertFromV8(args->isolate(), val, &proc))) {
|
||||
if (!(val->IsNull() || gin::ConvertFromV8(args->isolate(), val, &proc))) {
|
||||
args->ThrowError("Must pass null or function");
|
||||
return;
|
||||
}
|
||||
@@ -418,7 +417,7 @@ void Session::SetCertVerifyProc(v8::Local<v8::Value> val,
|
||||
}
|
||||
|
||||
void Session::SetPermissionRequestHandler(v8::Local<v8::Value> val,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
auto* permission_manager = static_cast<AtomPermissionManager*>(
|
||||
browser_context()->GetPermissionControllerDelegate());
|
||||
if (val->IsNull()) {
|
||||
@@ -427,7 +426,7 @@ void Session::SetPermissionRequestHandler(v8::Local<v8::Value> val,
|
||||
return;
|
||||
}
|
||||
auto handler = std::make_unique<AtomPermissionManager::RequestHandler>();
|
||||
if (!mate::ConvertFromV8(args->isolate(), val, handler.get())) {
|
||||
if (!gin::ConvertFromV8(args->isolate(), val, handler.get())) {
|
||||
args->ThrowError("Must pass null or function");
|
||||
return;
|
||||
}
|
||||
@@ -445,9 +444,9 @@ void Session::SetPermissionRequestHandler(v8::Local<v8::Value> val,
|
||||
}
|
||||
|
||||
void Session::SetPermissionCheckHandler(v8::Local<v8::Value> val,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
AtomPermissionManager::CheckHandler handler;
|
||||
if (!(val->IsNull() || mate::ConvertFromV8(args->isolate(), val, &handler))) {
|
||||
if (!(val->IsNull() || gin::ConvertFromV8(args->isolate(), val, &handler))) {
|
||||
args->ThrowError("Must pass null or function");
|
||||
return;
|
||||
}
|
||||
@@ -456,7 +455,8 @@ void Session::SetPermissionCheckHandler(v8::Local<v8::Value> val,
|
||||
permission_manager->SetPermissionCheckHandler(handler);
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> Session::ClearHostResolverCache(mate::Arguments* args) {
|
||||
v8::Local<v8::Promise> Session::ClearHostResolverCache(
|
||||
gin_helper::Arguments* args) {
|
||||
v8::Isolate* isolate = args->isolate();
|
||||
util::Promise<void*> promise(isolate);
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
@@ -494,7 +494,7 @@ void Session::AllowNTLMCredentialsForDomains(const std::string& domains) {
|
||||
}
|
||||
|
||||
void Session::SetUserAgent(const std::string& user_agent,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
browser_context_->SetUserAgent(user_agent);
|
||||
content::BrowserContext::GetDefaultStoragePartition(browser_context_.get())
|
||||
->GetNetworkContext()
|
||||
@@ -525,7 +525,7 @@ void Session::DownloadURL(const GURL& url) {
|
||||
download_manager->DownloadUrl(std::move(download_params));
|
||||
}
|
||||
|
||||
void Session::CreateInterruptedDownload(const mate::Dictionary& options) {
|
||||
void Session::CreateInterruptedDownload(const gin_helper::Dictionary& options) {
|
||||
int64_t offset = 0, length = 0;
|
||||
double start_time = base::Time::Now().ToDoubleT();
|
||||
std::string mime_type, last_modified, etag;
|
||||
@@ -540,12 +540,12 @@ void Session::CreateInterruptedDownload(const mate::Dictionary& options) {
|
||||
options.Get("eTag", &etag);
|
||||
options.Get("startTime", &start_time);
|
||||
if (path.empty() || url_chain.empty() || length == 0) {
|
||||
isolate()->ThrowException(v8::Exception::Error(mate::StringToV8(
|
||||
isolate()->ThrowException(v8::Exception::Error(gin::StringToV8(
|
||||
isolate(), "Must pass non-empty path, urlChain and length.")));
|
||||
return;
|
||||
}
|
||||
if (offset >= length) {
|
||||
isolate()->ThrowException(v8::Exception::Error(mate::StringToV8(
|
||||
isolate()->ThrowException(v8::Exception::Error(gin::StringToV8(
|
||||
isolate(), "Must pass an offset value less than length.")));
|
||||
return;
|
||||
}
|
||||
@@ -588,7 +588,7 @@ v8::Local<v8::Value> Session::Cookies(v8::Isolate* isolate) {
|
||||
v8::Local<v8::Value> Session::Protocol(v8::Isolate* isolate) {
|
||||
if (protocol_.IsEmpty()) {
|
||||
v8::Local<v8::Value> handle;
|
||||
handle = ProtocolNS::Create(isolate, browser_context()).ToV8();
|
||||
handle = Protocol::Create(isolate, browser_context()).ToV8();
|
||||
protocol_.Reset(isolate, handle);
|
||||
}
|
||||
return v8::Local<v8::Value>::New(isolate, protocol_);
|
||||
@@ -596,7 +596,7 @@ v8::Local<v8::Value> Session::Protocol(v8::Isolate* isolate) {
|
||||
|
||||
v8::Local<v8::Value> Session::WebRequest(v8::Isolate* isolate) {
|
||||
if (web_request_.IsEmpty()) {
|
||||
auto handle = WebRequestNS::Create(isolate, browser_context());
|
||||
auto handle = WebRequest::Create(isolate, browser_context());
|
||||
web_request_.Reset(isolate, handle.ToV8());
|
||||
}
|
||||
return v8::Local<v8::Value>::New(isolate, web_request_);
|
||||
@@ -619,8 +619,8 @@ static void StartPreconnectOnUI(
|
||||
browser_context->GetPreconnectManager()->Start(url, requests);
|
||||
}
|
||||
|
||||
void Session::Preconnect(const mate::Dictionary& options,
|
||||
mate::Arguments* args) {
|
||||
void Session::Preconnect(const gin_helper::Dictionary& options,
|
||||
gin_helper::Arguments* args) {
|
||||
GURL url;
|
||||
if (!options.Get("url", &url) || !url.is_valid()) {
|
||||
args->ThrowError("Must pass non-empty valid url to session.preconnect.");
|
||||
@@ -647,25 +647,25 @@ void Session::Preconnect(const mate::Dictionary& options,
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<Session> Session::CreateFrom(v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context) {
|
||||
gin::Handle<Session> Session::CreateFrom(v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context) {
|
||||
auto* existing = TrackableObject::FromWrappedClass(isolate, browser_context);
|
||||
if (existing)
|
||||
return mate::CreateHandle(isolate, static_cast<Session*>(existing));
|
||||
return gin::CreateHandle(isolate, static_cast<Session*>(existing));
|
||||
|
||||
auto handle =
|
||||
mate::CreateHandle(isolate, new Session(isolate, browser_context));
|
||||
gin::CreateHandle(isolate, new Session(isolate, browser_context));
|
||||
|
||||
// The Sessions should never be garbage collected, since the common pattern is
|
||||
// to use partition strings, instead of using the Session object directly.
|
||||
g_sessions[handle->weak_map_id()] =
|
||||
v8::Global<v8::Object>(isolate, handle.ToV8());
|
||||
v8::Global<v8::Value>(isolate, handle.ToV8());
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<Session> Session::FromPartition(
|
||||
gin::Handle<Session> Session::FromPartition(
|
||||
v8::Isolate* isolate,
|
||||
const std::string& partition,
|
||||
const base::DictionaryValue& options) {
|
||||
@@ -685,9 +685,9 @@ mate::Handle<Session> Session::FromPartition(
|
||||
// static
|
||||
void Session::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "Session"));
|
||||
prototype->SetClassName(gin::StringToV8(isolate, "Session"));
|
||||
gin_helper::Destroyable::MakeDestroyable(isolate, prototype);
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("resolveProxy", &Session::ResolveProxy)
|
||||
.SetMethod("getCacheSize", &Session::GetCacheSize)
|
||||
.SetMethod("clearCache", &Session::ClearCache)
|
||||
@@ -732,11 +732,11 @@ namespace {
|
||||
|
||||
using electron::api::Cookies;
|
||||
using electron::api::NetLog;
|
||||
using electron::api::ProtocolNS;
|
||||
using electron::api::Protocol;
|
||||
using electron::api::Session;
|
||||
|
||||
v8::Local<v8::Value> FromPartition(const std::string& partition,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
if (!electron::Browser::Get()->is_ready()) {
|
||||
args->ThrowError("Session can only be received when app is ready");
|
||||
return v8::Null(args->isolate());
|
||||
@@ -751,7 +751,7 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
gin_helper::Dictionary dict(isolate, exports);
|
||||
dict.Set(
|
||||
"Session",
|
||||
Session::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
|
||||
@@ -761,9 +761,9 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
dict.Set(
|
||||
"NetLog",
|
||||
NetLog::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
|
||||
dict.Set("Protocol", ProtocolNS::GetConstructor(isolate)
|
||||
->GetFunction(context)
|
||||
.ToLocalChecked());
|
||||
dict.Set(
|
||||
"Protocol",
|
||||
Protocol::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
|
||||
dict.SetMethod("fromPartition", &FromPartition);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
#include "base/values.h"
|
||||
#include "content/public/browser/download_manager.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "shell/browser/api/trackable_object.h"
|
||||
#include "gin/handle.h"
|
||||
#include "shell/browser/net/resolve_proxy_helper.h"
|
||||
#include "shell/common/gin_helper/trackable_object.h"
|
||||
#include "shell/common/promise_util.h"
|
||||
|
||||
class GURL;
|
||||
@@ -22,10 +22,9 @@ namespace base {
|
||||
class FilePath;
|
||||
}
|
||||
|
||||
namespace mate {
|
||||
class Arguments;
|
||||
namespace gin_helper {
|
||||
class Dictionary;
|
||||
} // namespace mate
|
||||
}
|
||||
|
||||
namespace net {
|
||||
class ProxyConfig;
|
||||
@@ -37,56 +36,58 @@ class AtomBrowserContext;
|
||||
|
||||
namespace api {
|
||||
|
||||
class Session : public mate::TrackableObject<Session>,
|
||||
class Session : public gin_helper::TrackableObject<Session>,
|
||||
public content::DownloadManager::Observer {
|
||||
public:
|
||||
// Gets or creates Session from the |browser_context|.
|
||||
static mate::Handle<Session> CreateFrom(v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context);
|
||||
static gin::Handle<Session> CreateFrom(v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context);
|
||||
|
||||
// Gets the Session of |partition|.
|
||||
static mate::Handle<Session> FromPartition(
|
||||
static gin::Handle<Session> FromPartition(
|
||||
v8::Isolate* isolate,
|
||||
const std::string& partition,
|
||||
const base::DictionaryValue& options = base::DictionaryValue());
|
||||
|
||||
AtomBrowserContext* browser_context() const { return browser_context_.get(); }
|
||||
|
||||
// mate::TrackableObject:
|
||||
// gin_helper::TrackableObject:
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
// Methods.
|
||||
v8::Local<v8::Promise> ResolveProxy(mate::Arguments* args);
|
||||
v8::Local<v8::Promise> ResolveProxy(gin_helper::Arguments* args);
|
||||
v8::Local<v8::Promise> GetCacheSize();
|
||||
v8::Local<v8::Promise> ClearCache();
|
||||
v8::Local<v8::Promise> ClearStorageData(mate::Arguments* args);
|
||||
v8::Local<v8::Promise> ClearStorageData(gin_helper::Arguments* args);
|
||||
void FlushStorageData();
|
||||
v8::Local<v8::Promise> SetProxy(mate::Arguments* args);
|
||||
v8::Local<v8::Promise> SetProxy(gin_helper::Arguments* args);
|
||||
void SetDownloadPath(const base::FilePath& path);
|
||||
void EnableNetworkEmulation(const mate::Dictionary& options);
|
||||
void EnableNetworkEmulation(const gin_helper::Dictionary& options);
|
||||
void DisableNetworkEmulation();
|
||||
void SetCertVerifyProc(v8::Local<v8::Value> proc, mate::Arguments* args);
|
||||
void SetCertVerifyProc(v8::Local<v8::Value> proc,
|
||||
gin_helper::Arguments* args);
|
||||
void SetPermissionRequestHandler(v8::Local<v8::Value> val,
|
||||
mate::Arguments* args);
|
||||
gin_helper::Arguments* args);
|
||||
void SetPermissionCheckHandler(v8::Local<v8::Value> val,
|
||||
mate::Arguments* args);
|
||||
v8::Local<v8::Promise> ClearHostResolverCache(mate::Arguments* args);
|
||||
gin_helper::Arguments* args);
|
||||
v8::Local<v8::Promise> ClearHostResolverCache(gin_helper::Arguments* args);
|
||||
v8::Local<v8::Promise> ClearAuthCache();
|
||||
void AllowNTLMCredentialsForDomains(const std::string& domains);
|
||||
void SetUserAgent(const std::string& user_agent, mate::Arguments* args);
|
||||
void SetUserAgent(const std::string& user_agent, gin_helper::Arguments* args);
|
||||
std::string GetUserAgent();
|
||||
v8::Local<v8::Promise> GetBlobData(v8::Isolate* isolate,
|
||||
const std::string& uuid);
|
||||
void DownloadURL(const GURL& url);
|
||||
void CreateInterruptedDownload(const mate::Dictionary& options);
|
||||
void CreateInterruptedDownload(const gin_helper::Dictionary& options);
|
||||
void SetPreloads(const std::vector<base::FilePath::StringType>& preloads);
|
||||
std::vector<base::FilePath::StringType> GetPreloads() const;
|
||||
v8::Local<v8::Value> Cookies(v8::Isolate* isolate);
|
||||
v8::Local<v8::Value> Protocol(v8::Isolate* isolate);
|
||||
v8::Local<v8::Value> WebRequest(v8::Isolate* isolate);
|
||||
v8::Local<v8::Value> NetLog(v8::Isolate* isolate);
|
||||
void Preconnect(const mate::Dictionary& options, mate::Arguments* args);
|
||||
void Preconnect(const gin_helper::Dictionary& options,
|
||||
gin_helper::Arguments* args);
|
||||
|
||||
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
||||
void LoadChromeExtension(const base::FilePath extension_path);
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
|
||||
#include "shell/browser/api/atom_api_system_preferences.h"
|
||||
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "shell/common/gin_converters/callback_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/native_mate_converters/callback_converter_deprecated.h"
|
||||
#include "shell/common/native_mate_converters/value_converter.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "ui/gfx/animation/animation.h"
|
||||
#include "ui/gfx/color_utils.h"
|
||||
@@ -58,17 +58,16 @@ v8::Local<v8::Value> SystemPreferences::GetAnimationSettings(
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<SystemPreferences> SystemPreferences::Create(
|
||||
v8::Isolate* isolate) {
|
||||
return mate::CreateHandle(isolate, new SystemPreferences(isolate));
|
||||
gin::Handle<SystemPreferences> SystemPreferences::Create(v8::Isolate* isolate) {
|
||||
return gin::CreateHandle(isolate, new SystemPreferences(isolate));
|
||||
}
|
||||
|
||||
// static
|
||||
void SystemPreferences::BuildPrototype(
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "SystemPreferences"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
prototype->SetClassName(gin::StringToV8(isolate, "SystemPreferences"));
|
||||
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
#if defined(OS_WIN) || defined(OS_MACOSX)
|
||||
.SetMethod("getColor", &SystemPreferences::GetColor)
|
||||
.SetMethod("getAccentColor", &SystemPreferences::GetAccentColor)
|
||||
@@ -142,7 +141,7 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
gin_helper::Dictionary dict(isolate, exports);
|
||||
dict.Set("systemPreferences", SystemPreferences::Create(isolate));
|
||||
dict.Set("SystemPreferences", SystemPreferences::GetConstructor(isolate)
|
||||
->GetFunction(context)
|
||||
|
||||
@@ -8,12 +8,9 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "base/values.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "shell/browser/api/event_emitter_deprecated.h"
|
||||
#include "gin/handle.h"
|
||||
#include "shell/common/gin_helper/error_thrower.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "shell/common/gin_helper/event_emitter.h"
|
||||
#include "shell/common/promise_util.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
@@ -38,7 +35,7 @@ enum NotificationCenterKind {
|
||||
};
|
||||
#endif
|
||||
|
||||
class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||
class SystemPreferences : public gin_helper::EventEmitter<SystemPreferences>
|
||||
#if defined(OS_WIN)
|
||||
,
|
||||
public BrowserObserver,
|
||||
@@ -46,7 +43,7 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
static mate::Handle<SystemPreferences> Create(v8::Isolate* isolate);
|
||||
static gin::Handle<SystemPreferences> Create(v8::Isolate* isolate);
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
@@ -75,7 +72,7 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||
|
||||
void PostNotification(const std::string& name,
|
||||
const base::DictionaryValue& user_info,
|
||||
mate::Arguments* args);
|
||||
gin_helper::Arguments* args);
|
||||
int SubscribeNotification(const std::string& name,
|
||||
const NotificationCallback& callback);
|
||||
void UnsubscribeNotification(int id);
|
||||
@@ -91,10 +88,10 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||
void UnsubscribeWorkspaceNotification(int request_id);
|
||||
v8::Local<v8::Value> GetUserDefault(const std::string& name,
|
||||
const std::string& type);
|
||||
void RegisterDefaults(mate::Arguments* args);
|
||||
void RegisterDefaults(gin_helper::Arguments* args);
|
||||
void SetUserDefault(const std::string& name,
|
||||
const std::string& type,
|
||||
mate::Arguments* args);
|
||||
gin_helper::Arguments* args);
|
||||
void RemoveUserDefault(const std::string& name);
|
||||
bool IsSwipeTrackingFromScrollEventsEnabled();
|
||||
|
||||
@@ -110,7 +107,7 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||
// TODO(codebytere): Write tests for these methods once we
|
||||
// are running tests on a Mojave machine
|
||||
std::string GetMediaAccessStatus(const std::string& media_type,
|
||||
mate::Arguments* args);
|
||||
gin_helper::Arguments* args);
|
||||
v8::Local<v8::Promise> AskForMediaAccess(v8::Isolate* isolate,
|
||||
const std::string& media_type);
|
||||
|
||||
@@ -118,7 +115,7 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||
// are running tests on a Mojave machine
|
||||
v8::Local<v8::Value> GetEffectiveAppearance(v8::Isolate* isolate);
|
||||
v8::Local<v8::Value> GetAppLevelAppearance(v8::Isolate* isolate);
|
||||
void SetAppLevelAppearance(mate::Arguments* args);
|
||||
void SetAppLevelAppearance(gin_helper::Arguments* args);
|
||||
#endif
|
||||
bool IsDarkMode();
|
||||
bool IsInvertedColorScheme();
|
||||
|
||||
@@ -21,17 +21,17 @@
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "base/threading/sequenced_task_runner_handle.h"
|
||||
#include "base/values.h"
|
||||
#include "native_mate/object_template_builder_deprecated.h"
|
||||
#include "net/base/mac/url_conversions.h"
|
||||
#include "shell/browser/mac/atom_application.h"
|
||||
#include "shell/browser/mac/dict_util.h"
|
||||
#include "shell/browser/ui/cocoa/NSColor+Hex.h"
|
||||
#include "shell/common/deprecate_util.h"
|
||||
#include "shell/common/native_mate_converters/gurl_converter.h"
|
||||
#include "shell/common/native_mate_converters/value_converter.h"
|
||||
#include "shell/common/gin_converters/gurl_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "ui/native_theme/native_theme.h"
|
||||
|
||||
namespace mate {
|
||||
namespace gin {
|
||||
|
||||
template <>
|
||||
struct Converter<NSAppearance*> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
@@ -43,7 +43,7 @@ struct Converter<NSAppearance*> {
|
||||
}
|
||||
|
||||
std::string name;
|
||||
if (!mate::ConvertFromV8(isolate, val, &name)) {
|
||||
if (!gin::ConvertFromV8(isolate, val, &name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -68,18 +68,19 @@ struct Converter<NSAppearance*> {
|
||||
}
|
||||
|
||||
if ([val.name isEqualToString:NSAppearanceNameAqua]) {
|
||||
return mate::ConvertToV8(isolate, "light");
|
||||
return gin::ConvertToV8(isolate, "light");
|
||||
}
|
||||
if (@available(macOS 10.14, *)) {
|
||||
if ([val.name isEqualToString:NSAppearanceNameDarkAqua]) {
|
||||
return mate::ConvertToV8(isolate, "dark");
|
||||
return gin::ConvertToV8(isolate, "dark");
|
||||
}
|
||||
}
|
||||
|
||||
return mate::ConvertToV8(isolate, "unknown");
|
||||
return gin::ConvertToV8(isolate, "unknown");
|
||||
}
|
||||
};
|
||||
} // namespace mate
|
||||
|
||||
} // namespace gin
|
||||
|
||||
namespace electron {
|
||||
|
||||
@@ -121,7 +122,7 @@ std::string ConvertAuthorizationStatus(AVAuthorizationStatusMac status) {
|
||||
|
||||
void SystemPreferences::PostNotification(const std::string& name,
|
||||
const base::DictionaryValue& user_info,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
bool immediate = false;
|
||||
args->GetNext(&immediate);
|
||||
|
||||
@@ -261,7 +262,7 @@ v8::Local<v8::Value> SystemPreferences::GetUserDefault(
|
||||
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
|
||||
NSString* key = base::SysUTF8ToNSString(name);
|
||||
if (type == "string") {
|
||||
return mate::StringToV8(
|
||||
return gin::StringToV8(
|
||||
isolate(), base::SysNSStringToUTF8([defaults stringForKey:key]));
|
||||
} else if (type == "boolean") {
|
||||
return v8::Boolean::New(isolate(), [defaults boolForKey:key]);
|
||||
@@ -272,26 +273,26 @@ v8::Local<v8::Value> SystemPreferences::GetUserDefault(
|
||||
} else if (type == "double") {
|
||||
return v8::Number::New(isolate(), [defaults doubleForKey:key]);
|
||||
} else if (type == "url") {
|
||||
return mate::ConvertToV8(isolate(),
|
||||
net::GURLWithNSURL([defaults URLForKey:key]));
|
||||
return gin::ConvertToV8(isolate(),
|
||||
net::GURLWithNSURL([defaults URLForKey:key]));
|
||||
} else if (type == "array") {
|
||||
std::unique_ptr<base::ListValue> list =
|
||||
NSArrayToListValue([defaults arrayForKey:key]);
|
||||
if (list == nullptr)
|
||||
list.reset(new base::ListValue());
|
||||
return mate::ConvertToV8(isolate(), *list);
|
||||
return gin::ConvertToV8(isolate(), *list);
|
||||
} else if (type == "dictionary") {
|
||||
std::unique_ptr<base::DictionaryValue> dictionary =
|
||||
NSDictionaryToDictionaryValue([defaults dictionaryForKey:key]);
|
||||
if (dictionary == nullptr)
|
||||
dictionary.reset(new base::DictionaryValue());
|
||||
return mate::ConvertToV8(isolate(), *dictionary);
|
||||
return gin::ConvertToV8(isolate(), *dictionary);
|
||||
} else {
|
||||
return v8::Undefined(isolate());
|
||||
}
|
||||
}
|
||||
|
||||
void SystemPreferences::RegisterDefaults(mate::Arguments* args) {
|
||||
void SystemPreferences::RegisterDefaults(gin_helper::Arguments* args) {
|
||||
base::DictionaryValue value;
|
||||
|
||||
if (!args->GetNext(&value)) {
|
||||
@@ -315,7 +316,7 @@ void SystemPreferences::RegisterDefaults(mate::Arguments* args) {
|
||||
|
||||
void SystemPreferences::SetUserDefault(const std::string& name,
|
||||
const std::string& type,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
const auto throwConversionError = [&] {
|
||||
args->ThrowError("Unable to convert value to: " + type);
|
||||
};
|
||||
@@ -596,7 +597,7 @@ std::string SystemPreferences::GetColor(gin_helper::ErrorThrower thrower,
|
||||
|
||||
std::string SystemPreferences::GetMediaAccessStatus(
|
||||
const std::string& media_type,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
if (auto type = ParseMediaType(media_type)) {
|
||||
if (@available(macOS 10.14, *)) {
|
||||
return ConvertAuthorizationStatus(
|
||||
@@ -658,7 +659,7 @@ bool SystemPreferences::IsSwipeTrackingFromScrollEventsEnabled() {
|
||||
v8::Local<v8::Value> SystemPreferences::GetEffectiveAppearance(
|
||||
v8::Isolate* isolate) {
|
||||
if (@available(macOS 10.14, *)) {
|
||||
return mate::ConvertToV8(
|
||||
return gin::ConvertToV8(
|
||||
isolate, [NSApplication sharedApplication].effectiveAppearance);
|
||||
}
|
||||
return v8::Null(isolate);
|
||||
@@ -667,13 +668,13 @@ v8::Local<v8::Value> SystemPreferences::GetEffectiveAppearance(
|
||||
v8::Local<v8::Value> SystemPreferences::GetAppLevelAppearance(
|
||||
v8::Isolate* isolate) {
|
||||
if (@available(macOS 10.14, *)) {
|
||||
return mate::ConvertToV8(isolate,
|
||||
[NSApplication sharedApplication].appearance);
|
||||
return gin::ConvertToV8(isolate,
|
||||
[NSApplication sharedApplication].appearance);
|
||||
}
|
||||
return v8::Null(isolate);
|
||||
}
|
||||
|
||||
void SystemPreferences::SetAppLevelAppearance(mate::Arguments* args) {
|
||||
void SystemPreferences::SetAppLevelAppearance(gin_helper::Arguments* args) {
|
||||
if (@available(macOS 10.14, *)) {
|
||||
NSAppearance* appearance;
|
||||
if (args->GetNext(&appearance)) {
|
||||
|
||||
@@ -74,10 +74,10 @@ v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
|
||||
} // namespace
|
||||
|
||||
TopLevelWindow::TopLevelWindow(v8::Isolate* isolate,
|
||||
const mate::Dictionary& options)
|
||||
const gin_helper::Dictionary& options)
|
||||
: weak_factory_(this) {
|
||||
// The parent window.
|
||||
mate::Handle<TopLevelWindow> parent;
|
||||
gin::Handle<TopLevelWindow> parent;
|
||||
if (options.Get("parent", &parent) && !parent.IsEmpty())
|
||||
parent_window_.Reset(isolate, parent.ToV8());
|
||||
|
||||
@@ -98,14 +98,14 @@ TopLevelWindow::TopLevelWindow(v8::Isolate* isolate,
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
// Sets the window icon.
|
||||
mate::Handle<NativeImage> icon;
|
||||
gin::Handle<NativeImage> icon;
|
||||
if (options.Get(options::kIcon, &icon) && !icon.IsEmpty())
|
||||
SetIcon(icon);
|
||||
#endif
|
||||
}
|
||||
|
||||
TopLevelWindow::TopLevelWindow(gin_helper::Arguments* args,
|
||||
const mate::Dictionary& options)
|
||||
const gin_helper::Dictionary& options)
|
||||
: TopLevelWindow(args->isolate(), options) {
|
||||
InitWithArgs(args);
|
||||
// Init window after everything has been setup.
|
||||
@@ -124,15 +124,12 @@ TopLevelWindow::~TopLevelWindow() {
|
||||
void TopLevelWindow::InitWith(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> wrapper) {
|
||||
AttachAsUserData(window_.get());
|
||||
mate::TrackableObject<
|
||||
TopLevelWindow, gin_helper::EventEmitter<
|
||||
mate::Wrappable<TopLevelWindow>>>::InitWith(isolate,
|
||||
wrapper);
|
||||
gin_helper::TrackableObject<TopLevelWindow>::InitWith(isolate, wrapper);
|
||||
|
||||
// We can only append this window to parent window's child windows after this
|
||||
// window's JS wrapper gets initialized.
|
||||
if (!parent_window_.IsEmpty()) {
|
||||
mate::Handle<TopLevelWindow> parent;
|
||||
gin::Handle<TopLevelWindow> parent;
|
||||
gin::ConvertFromV8(isolate, GetParentWindow(), &parent);
|
||||
DCHECK(!parent.IsEmpty());
|
||||
parent->child_windows_.Set(isolate, weak_map_id(), wrapper);
|
||||
@@ -299,7 +296,7 @@ void TopLevelWindow::OnWindowMessage(UINT message,
|
||||
}
|
||||
#endif
|
||||
|
||||
void TopLevelWindow::SetContentView(mate::Handle<View> view) {
|
||||
void TopLevelWindow::SetContentView(gin::Handle<View> view) {
|
||||
ResetBrowserViews();
|
||||
content_view_.Reset(isolate(), view.ToV8());
|
||||
window_->SetContentView(view->view());
|
||||
@@ -676,7 +673,7 @@ void TopLevelWindow::SetFocusable(bool focusable) {
|
||||
|
||||
void TopLevelWindow::SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> value) {
|
||||
auto context = isolate->GetCurrentContext();
|
||||
mate::Handle<Menu> menu;
|
||||
gin::Handle<Menu> menu;
|
||||
v8::Local<v8::Object> object;
|
||||
if (value->IsObject() && value->ToObject(context).ToLocal(&object) &&
|
||||
gin::V8ToString(isolate, object->GetConstructorName()) == "Menu" &&
|
||||
@@ -704,12 +701,12 @@ void TopLevelWindow::SetParentWindow(v8::Local<v8::Value> value,
|
||||
return;
|
||||
}
|
||||
|
||||
mate::Handle<TopLevelWindow> parent;
|
||||
gin::Handle<TopLevelWindow> parent;
|
||||
if (value->IsNull() || value->IsUndefined()) {
|
||||
RemoveFromParentChildWindows();
|
||||
parent_window_.Reset();
|
||||
window_->SetParentWindow(nullptr);
|
||||
} else if (mate::ConvertFromV8(isolate(), value, &parent)) {
|
||||
} else if (gin::ConvertFromV8(isolate(), value, &parent)) {
|
||||
RemoveFromParentChildWindows();
|
||||
parent_window_.Reset(isolate(), value);
|
||||
window_->SetParentWindow(parent->window_.get());
|
||||
@@ -725,7 +722,7 @@ void TopLevelWindow::SetBrowserView(v8::Local<v8::Value> value) {
|
||||
}
|
||||
|
||||
void TopLevelWindow::AddBrowserView(v8::Local<v8::Value> value) {
|
||||
mate::Handle<BrowserView> browser_view;
|
||||
gin::Handle<BrowserView> browser_view;
|
||||
if (value->IsObject() &&
|
||||
gin::ConvertFromV8(isolate(), value, &browser_view)) {
|
||||
auto get_that_view = browser_views_.find(browser_view->weak_map_id());
|
||||
@@ -738,7 +735,7 @@ void TopLevelWindow::AddBrowserView(v8::Local<v8::Value> value) {
|
||||
}
|
||||
|
||||
void TopLevelWindow::RemoveBrowserView(v8::Local<v8::Value> value) {
|
||||
mate::Handle<BrowserView> browser_view;
|
||||
gin::Handle<BrowserView> browser_view;
|
||||
if (value->IsObject() &&
|
||||
gin::ConvertFromV8(isolate(), value, &browser_view)) {
|
||||
auto get_that_view = browser_views_.find(browser_view->weak_map_id());
|
||||
@@ -960,7 +957,7 @@ bool TopLevelWindow::SetThumbarButtons(gin_helper::Arguments* args) {
|
||||
}
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
void TopLevelWindow::SetIcon(mate::Handle<NativeImage> icon) {
|
||||
void TopLevelWindow::SetIcon(gin::Handle<NativeImage> icon) {
|
||||
#if defined(OS_WIN)
|
||||
static_cast<NativeWindowViews*>(window_.get())
|
||||
->SetIcon(icon->GetHICON(GetSystemMetrics(SM_CXSMICON)),
|
||||
@@ -1028,7 +1025,7 @@ int32_t TopLevelWindow::GetID() const {
|
||||
|
||||
void TopLevelWindow::ResetBrowserViews() {
|
||||
for (auto& item : browser_views_) {
|
||||
mate::Handle<BrowserView> browser_view;
|
||||
gin::Handle<BrowserView> browser_view;
|
||||
if (gin::ConvertFromV8(isolate(),
|
||||
v8::Local<v8::Value>::New(isolate(), item.second),
|
||||
&browser_view) &&
|
||||
@@ -1047,7 +1044,7 @@ void TopLevelWindow::RemoveFromParentChildWindows() {
|
||||
if (parent_window_.IsEmpty())
|
||||
return;
|
||||
|
||||
mate::Handle<TopLevelWindow> parent;
|
||||
gin::Handle<TopLevelWindow> parent;
|
||||
if (!gin::ConvertFromV8(isolate(), GetParentWindow(), &parent) ||
|
||||
parent.IsEmpty()) {
|
||||
return;
|
||||
@@ -1058,7 +1055,8 @@ void TopLevelWindow::RemoveFromParentChildWindows() {
|
||||
|
||||
// static
|
||||
mate::WrappableBase* TopLevelWindow::New(gin_helper::Arguments* args) {
|
||||
mate::Dictionary options = mate::Dictionary::CreateEmpty(args->isolate());
|
||||
gin_helper::Dictionary options =
|
||||
gin::Dictionary::CreateEmpty(args->isolate());
|
||||
args->GetNext(&options);
|
||||
|
||||
return new TopLevelWindow(args, options);
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "shell/browser/api/trackable_object.h"
|
||||
#include "gin/handle.h"
|
||||
#include "shell/browser/native_window.h"
|
||||
#include "shell/browser/native_window_observer.h"
|
||||
#include "shell/common/api/atom_api_native_image.h"
|
||||
#include "shell/common/gin_helper/event_emitter.h"
|
||||
#include "shell/common/gin_helper/trackable_object.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
@@ -25,11 +25,8 @@ namespace api {
|
||||
|
||||
class View;
|
||||
|
||||
class TopLevelWindow
|
||||
: public mate::TrackableObject<
|
||||
TopLevelWindow,
|
||||
gin_helper::EventEmitter<mate::Wrappable<TopLevelWindow>>>,
|
||||
public NativeWindowObserver {
|
||||
class TopLevelWindow : public gin_helper::TrackableObject<TopLevelWindow>,
|
||||
public NativeWindowObserver {
|
||||
public:
|
||||
static mate::WrappableBase* New(gin_helper::Arguments* args);
|
||||
|
||||
@@ -44,9 +41,10 @@ class TopLevelWindow
|
||||
|
||||
protected:
|
||||
// Common constructor.
|
||||
TopLevelWindow(v8::Isolate* isolate, const mate::Dictionary& options);
|
||||
TopLevelWindow(v8::Isolate* isolate, const gin_helper::Dictionary& options);
|
||||
// Creating independent TopLevelWindow instance.
|
||||
TopLevelWindow(gin_helper::Arguments* args, const mate::Dictionary& options);
|
||||
TopLevelWindow(gin_helper::Arguments* args,
|
||||
const gin_helper::Dictionary& options);
|
||||
~TopLevelWindow() override;
|
||||
|
||||
// TrackableObject:
|
||||
@@ -91,7 +89,7 @@ class TopLevelWindow
|
||||
#endif
|
||||
|
||||
// Public APIs of NativeWindow.
|
||||
void SetContentView(mate::Handle<View> view);
|
||||
void SetContentView(gin::Handle<View> view);
|
||||
void Close();
|
||||
virtual void Focus();
|
||||
virtual void Blur();
|
||||
@@ -215,7 +213,7 @@ class TopLevelWindow
|
||||
// Extra APIs added in JS.
|
||||
bool SetThumbarButtons(gin_helper::Arguments* args);
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
void SetIcon(mate::Handle<NativeImage> icon);
|
||||
void SetIcon(gin::Handle<NativeImage> icon);
|
||||
#endif
|
||||
#if defined(OS_WIN)
|
||||
typedef base::RepeatingCallback<void(v8::Local<v8::Value>,
|
||||
|
||||
@@ -10,11 +10,10 @@
|
||||
#include <vector>
|
||||
|
||||
#include "gin/handle.h"
|
||||
#include "shell/browser/api/trackable_object.h"
|
||||
#include "shell/browser/ui/tray_icon.h"
|
||||
#include "shell/browser/ui/tray_icon_observer.h"
|
||||
#include "shell/common/gin_helper/error_thrower.h"
|
||||
#include "shell/common/gin_helper/event_emitter.h"
|
||||
#include "shell/common/gin_helper/trackable_object.h"
|
||||
|
||||
namespace gfx {
|
||||
class Image;
|
||||
@@ -33,10 +32,7 @@ namespace api {
|
||||
class Menu;
|
||||
class NativeImage;
|
||||
|
||||
class Tray : public mate::TrackableObject<
|
||||
Tray,
|
||||
gin_helper::EventEmitter<mate::Wrappable<Tray>>>,
|
||||
public TrayIconObserver {
|
||||
class Tray : public gin_helper::TrackableObject<Tray>, public TrayIconObserver {
|
||||
public:
|
||||
static mate::WrappableBase* New(gin_helper::ErrorThrower thrower,
|
||||
gin::Handle<NativeImage> image,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/api/atom_api_url_request_ns.h"
|
||||
#include "shell/browser/api/atom_api_url_request.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
@@ -84,7 +84,7 @@ const net::NetworkTrafficAnnotationTag kTrafficAnnotation =
|
||||
// Common class for streaming data.
|
||||
class UploadDataPipeGetter {
|
||||
public:
|
||||
explicit UploadDataPipeGetter(URLRequestNS* request) : request_(request) {}
|
||||
explicit UploadDataPipeGetter(URLRequest* request) : request_(request) {}
|
||||
virtual ~UploadDataPipeGetter() = default;
|
||||
|
||||
virtual void AttachToRequestBody(network::ResourceRequestBody* body) = 0;
|
||||
@@ -101,7 +101,7 @@ class UploadDataPipeGetter {
|
||||
}
|
||||
|
||||
private:
|
||||
URLRequestNS* request_;
|
||||
URLRequest* request_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(UploadDataPipeGetter);
|
||||
};
|
||||
@@ -110,7 +110,7 @@ class UploadDataPipeGetter {
|
||||
class MultipartDataPipeGetter : public UploadDataPipeGetter,
|
||||
public network::mojom::DataPipeGetter {
|
||||
public:
|
||||
explicit MultipartDataPipeGetter(URLRequestNS* request)
|
||||
explicit MultipartDataPipeGetter(URLRequest* request)
|
||||
: UploadDataPipeGetter(request) {}
|
||||
~MultipartDataPipeGetter() override = default;
|
||||
|
||||
@@ -141,7 +141,7 @@ class MultipartDataPipeGetter : public UploadDataPipeGetter,
|
||||
class ChunkedDataPipeGetter : public UploadDataPipeGetter,
|
||||
public network::mojom::ChunkedDataPipeGetter {
|
||||
public:
|
||||
explicit ChunkedDataPipeGetter(URLRequestNS* request)
|
||||
explicit ChunkedDataPipeGetter(URLRequest* request)
|
||||
: UploadDataPipeGetter(request) {}
|
||||
~ChunkedDataPipeGetter() override = default;
|
||||
|
||||
@@ -166,7 +166,7 @@ class ChunkedDataPipeGetter : public UploadDataPipeGetter,
|
||||
mojo::ReceiverSet<network::mojom::ChunkedDataPipeGetter> receiver_set_;
|
||||
};
|
||||
|
||||
URLRequestNS::URLRequestNS(gin::Arguments* args) : weak_factory_(this) {
|
||||
URLRequest::URLRequest(gin::Arguments* args) : weak_factory_(this) {
|
||||
request_ = std::make_unique<network::ResourceRequest>();
|
||||
gin_helper::Dictionary dict;
|
||||
if (args->GetNext(&dict)) {
|
||||
@@ -177,7 +177,7 @@ URLRequestNS::URLRequestNS(gin::Arguments* args) : weak_factory_(this) {
|
||||
}
|
||||
|
||||
std::string partition;
|
||||
mate::Handle<api::Session> session;
|
||||
gin::Handle<api::Session> session;
|
||||
if (!dict.Get("session", &session)) {
|
||||
if (dict.Get("partition", &partition))
|
||||
session = Session::FromPartition(args->isolate(), partition);
|
||||
@@ -190,17 +190,17 @@ URLRequestNS::URLRequestNS(gin::Arguments* args) : weak_factory_(this) {
|
||||
InitWithArgs(args);
|
||||
}
|
||||
|
||||
URLRequestNS::~URLRequestNS() = default;
|
||||
URLRequest::~URLRequest() = default;
|
||||
|
||||
bool URLRequestNS::NotStarted() const {
|
||||
bool URLRequest::NotStarted() const {
|
||||
return request_state_ == 0;
|
||||
}
|
||||
|
||||
bool URLRequestNS::Finished() const {
|
||||
bool URLRequest::Finished() const {
|
||||
return request_state_ & STATE_FINISHED;
|
||||
}
|
||||
|
||||
void URLRequestNS::Cancel() {
|
||||
void URLRequest::Cancel() {
|
||||
// Cancel only once.
|
||||
if (request_state_ & (STATE_CANCELED | STATE_CLOSED))
|
||||
return;
|
||||
@@ -215,7 +215,7 @@ void URLRequestNS::Cancel() {
|
||||
Close();
|
||||
}
|
||||
|
||||
void URLRequestNS::Close() {
|
||||
void URLRequest::Close() {
|
||||
if (!(request_state_ & STATE_CLOSED)) {
|
||||
request_state_ |= STATE_CLOSED;
|
||||
if (response_state_ & STATE_STARTED) {
|
||||
@@ -228,7 +228,7 @@ void URLRequestNS::Close() {
|
||||
loader_.reset();
|
||||
}
|
||||
|
||||
bool URLRequestNS::Write(v8::Local<v8::Value> data, bool is_last) {
|
||||
bool URLRequest::Write(v8::Local<v8::Value> data, bool is_last) {
|
||||
if (request_state_ & (STATE_FINISHED | STATE_ERROR))
|
||||
return false;
|
||||
|
||||
@@ -243,12 +243,12 @@ bool URLRequestNS::Write(v8::Local<v8::Value> data, bool is_last) {
|
||||
network::ResourceRequest* request_ref = request_.get();
|
||||
loader_ = network::SimpleURLLoader::Create(std::move(request_),
|
||||
kTrafficAnnotation);
|
||||
loader_->SetOnResponseStartedCallback(base::Bind(
|
||||
&URLRequestNS::OnResponseStarted, weak_factory_.GetWeakPtr()));
|
||||
loader_->SetOnResponseStartedCallback(
|
||||
base::Bind(&URLRequest::OnResponseStarted, weak_factory_.GetWeakPtr()));
|
||||
loader_->SetOnRedirectCallback(
|
||||
base::Bind(&URLRequestNS::OnRedirect, weak_factory_.GetWeakPtr()));
|
||||
loader_->SetOnUploadProgressCallback(base::Bind(
|
||||
&URLRequestNS::OnUploadProgress, weak_factory_.GetWeakPtr()));
|
||||
base::Bind(&URLRequest::OnRedirect, weak_factory_.GetWeakPtr()));
|
||||
loader_->SetOnUploadProgressCallback(
|
||||
base::Bind(&URLRequest::OnUploadProgress, weak_factory_.GetWeakPtr()));
|
||||
|
||||
// Create upload data pipe if we have data to write.
|
||||
if (length > 0) {
|
||||
@@ -286,14 +286,14 @@ bool URLRequestNS::Write(v8::Local<v8::Value> data, bool is_last) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void URLRequestNS::FollowRedirect() {
|
||||
void URLRequest::FollowRedirect() {
|
||||
if (request_state_ & (STATE_CANCELED | STATE_CLOSED))
|
||||
return;
|
||||
follow_redirect_ = true;
|
||||
}
|
||||
|
||||
bool URLRequestNS::SetExtraHeader(const std::string& name,
|
||||
const std::string& value) {
|
||||
bool URLRequest::SetExtraHeader(const std::string& name,
|
||||
const std::string& value) {
|
||||
if (!request_)
|
||||
return false;
|
||||
if (!net::HttpUtil::IsValidHeaderName(name))
|
||||
@@ -304,17 +304,17 @@ bool URLRequestNS::SetExtraHeader(const std::string& name,
|
||||
return true;
|
||||
}
|
||||
|
||||
void URLRequestNS::RemoveExtraHeader(const std::string& name) {
|
||||
void URLRequest::RemoveExtraHeader(const std::string& name) {
|
||||
if (request_)
|
||||
request_->headers.RemoveHeader(name);
|
||||
}
|
||||
|
||||
void URLRequestNS::SetChunkedUpload(bool is_chunked_upload) {
|
||||
void URLRequest::SetChunkedUpload(bool is_chunked_upload) {
|
||||
if (request_)
|
||||
is_chunked_upload_ = is_chunked_upload;
|
||||
}
|
||||
|
||||
gin::Dictionary URLRequestNS::GetUploadProgress() {
|
||||
gin::Dictionary URLRequest::GetUploadProgress() {
|
||||
gin::Dictionary progress = gin::Dictionary::CreateEmpty(isolate());
|
||||
if (loader_) {
|
||||
if (request_)
|
||||
@@ -330,36 +330,36 @@ gin::Dictionary URLRequestNS::GetUploadProgress() {
|
||||
return progress;
|
||||
}
|
||||
|
||||
int URLRequestNS::StatusCode() const {
|
||||
int URLRequest::StatusCode() const {
|
||||
if (response_headers_)
|
||||
return response_headers_->response_code();
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::string URLRequestNS::StatusMessage() const {
|
||||
std::string URLRequest::StatusMessage() const {
|
||||
if (response_headers_)
|
||||
return response_headers_->GetStatusText();
|
||||
return "";
|
||||
}
|
||||
|
||||
net::HttpResponseHeaders* URLRequestNS::RawResponseHeaders() const {
|
||||
net::HttpResponseHeaders* URLRequest::RawResponseHeaders() const {
|
||||
return response_headers_.get();
|
||||
}
|
||||
|
||||
uint32_t URLRequestNS::ResponseHttpVersionMajor() const {
|
||||
uint32_t URLRequest::ResponseHttpVersionMajor() const {
|
||||
if (response_headers_)
|
||||
return response_headers_->GetHttpVersion().major_value();
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t URLRequestNS::ResponseHttpVersionMinor() const {
|
||||
uint32_t URLRequest::ResponseHttpVersionMinor() const {
|
||||
if (response_headers_)
|
||||
return response_headers_->GetHttpVersion().minor_value();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void URLRequestNS::OnDataReceived(base::StringPiece data,
|
||||
base::OnceClosure resume) {
|
||||
void URLRequest::OnDataReceived(base::StringPiece data,
|
||||
base::OnceClosure resume) {
|
||||
// In case we received an unexpected event from Chromium net, don't emit any
|
||||
// data event after request cancel/error/close.
|
||||
if (!(request_state_ & STATE_ERROR) && !(response_state_ & STATE_ERROR)) {
|
||||
@@ -372,9 +372,9 @@ void URLRequestNS::OnDataReceived(base::StringPiece data,
|
||||
std::move(resume).Run();
|
||||
}
|
||||
|
||||
void URLRequestNS::OnRetry(base::OnceClosure start_retry) {}
|
||||
void URLRequest::OnRetry(base::OnceClosure start_retry) {}
|
||||
|
||||
void URLRequestNS::OnComplete(bool success) {
|
||||
void URLRequest::OnComplete(bool success) {
|
||||
if (success) {
|
||||
// In case we received an unexpected event from Chromium net, don't emit any
|
||||
// data event after request cancel/error/close.
|
||||
@@ -400,7 +400,7 @@ void URLRequestNS::OnComplete(bool success) {
|
||||
Close();
|
||||
}
|
||||
|
||||
void URLRequestNS::OnResponseStarted(
|
||||
void URLRequest::OnResponseStarted(
|
||||
const GURL& final_url,
|
||||
const network::mojom::URLResponseHead& response_head) {
|
||||
// Don't emit any event after request cancel.
|
||||
@@ -412,7 +412,7 @@ void URLRequestNS::OnResponseStarted(
|
||||
Emit("response");
|
||||
}
|
||||
|
||||
void URLRequestNS::OnRedirect(
|
||||
void URLRequest::OnRedirect(
|
||||
const net::RedirectInfo& redirect_info,
|
||||
const network::mojom::URLResponseHead& response_head,
|
||||
std::vector<std::string>* to_be_removed_headers) {
|
||||
@@ -455,12 +455,12 @@ void URLRequestNS::OnRedirect(
|
||||
}
|
||||
}
|
||||
|
||||
void URLRequestNS::OnUploadProgress(uint64_t position, uint64_t total) {
|
||||
void URLRequest::OnUploadProgress(uint64_t position, uint64_t total) {
|
||||
upload_position_ = position;
|
||||
upload_total_ = total;
|
||||
}
|
||||
|
||||
void URLRequestNS::OnWrite(MojoResult result) {
|
||||
void URLRequest::OnWrite(MojoResult result) {
|
||||
if (result != MOJO_RESULT_OK)
|
||||
return;
|
||||
|
||||
@@ -470,17 +470,17 @@ void URLRequestNS::OnWrite(MojoResult result) {
|
||||
DoWrite();
|
||||
}
|
||||
|
||||
void URLRequestNS::DoWrite() {
|
||||
void URLRequest::DoWrite() {
|
||||
DCHECK(producer_);
|
||||
DCHECK(!pending_writes_.empty());
|
||||
producer_->Write(
|
||||
std::make_unique<mojo::StringDataSource>(
|
||||
pending_writes_.front(), mojo::StringDataSource::AsyncWritingMode::
|
||||
STRING_STAYS_VALID_UNTIL_COMPLETION),
|
||||
base::BindOnce(&URLRequestNS::OnWrite, weak_factory_.GetWeakPtr()));
|
||||
base::BindOnce(&URLRequest::OnWrite, weak_factory_.GetWeakPtr()));
|
||||
}
|
||||
|
||||
void URLRequestNS::StartWriting() {
|
||||
void URLRequest::StartWriting() {
|
||||
if (!last_chunk_written_ || size_callback_.is_null())
|
||||
return;
|
||||
|
||||
@@ -491,17 +491,17 @@ void URLRequestNS::StartWriting() {
|
||||
DoWrite();
|
||||
}
|
||||
|
||||
void URLRequestNS::Pin() {
|
||||
void URLRequest::Pin() {
|
||||
if (wrapper_.IsEmpty()) {
|
||||
wrapper_.Reset(isolate(), GetWrapper());
|
||||
}
|
||||
}
|
||||
|
||||
void URLRequestNS::Unpin() {
|
||||
void URLRequest::Unpin() {
|
||||
wrapper_.Reset();
|
||||
}
|
||||
|
||||
void URLRequestNS::EmitError(EventType type, base::StringPiece message) {
|
||||
void URLRequest::EmitError(EventType type, base::StringPiece message) {
|
||||
if (type == EventType::kRequest)
|
||||
request_state_ |= STATE_FAILED;
|
||||
else
|
||||
@@ -512,7 +512,7 @@ void URLRequestNS::EmitError(EventType type, base::StringPiece message) {
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void URLRequestNS::EmitEvent(EventType type, Args... args) {
|
||||
void URLRequest::EmitEvent(EventType type, Args... args) {
|
||||
const char* method =
|
||||
type == EventType::kRequest ? "_emitRequestEvent" : "_emitResponseEvent";
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
@@ -520,30 +520,30 @@ void URLRequestNS::EmitEvent(EventType type, Args... args) {
|
||||
}
|
||||
|
||||
// static
|
||||
mate::WrappableBase* URLRequestNS::New(gin::Arguments* args) {
|
||||
return new URLRequestNS(args);
|
||||
mate::WrappableBase* URLRequest::New(gin::Arguments* args) {
|
||||
return new URLRequest(args);
|
||||
}
|
||||
|
||||
// static
|
||||
void URLRequestNS::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
void URLRequest::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(gin::StringToV8(isolate, "URLRequest"));
|
||||
gin_helper::Destroyable::MakeDestroyable(isolate, prototype);
|
||||
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("write", &URLRequestNS::Write)
|
||||
.SetMethod("cancel", &URLRequestNS::Cancel)
|
||||
.SetMethod("setExtraHeader", &URLRequestNS::SetExtraHeader)
|
||||
.SetMethod("removeExtraHeader", &URLRequestNS::RemoveExtraHeader)
|
||||
.SetMethod("setChunkedUpload", &URLRequestNS::SetChunkedUpload)
|
||||
.SetMethod("followRedirect", &URLRequestNS::FollowRedirect)
|
||||
.SetMethod("getUploadProgress", &URLRequestNS::GetUploadProgress)
|
||||
.SetProperty("notStarted", &URLRequestNS::NotStarted)
|
||||
.SetProperty("finished", &URLRequestNS::Finished)
|
||||
.SetProperty("statusCode", &URLRequestNS::StatusCode)
|
||||
.SetProperty("statusMessage", &URLRequestNS::StatusMessage)
|
||||
.SetProperty("rawResponseHeaders", &URLRequestNS::RawResponseHeaders)
|
||||
.SetProperty("httpVersionMajor", &URLRequestNS::ResponseHttpVersionMajor)
|
||||
.SetProperty("httpVersionMinor", &URLRequestNS::ResponseHttpVersionMinor);
|
||||
.SetMethod("write", &URLRequest::Write)
|
||||
.SetMethod("cancel", &URLRequest::Cancel)
|
||||
.SetMethod("setExtraHeader", &URLRequest::SetExtraHeader)
|
||||
.SetMethod("removeExtraHeader", &URLRequest::RemoveExtraHeader)
|
||||
.SetMethod("setChunkedUpload", &URLRequest::SetChunkedUpload)
|
||||
.SetMethod("followRedirect", &URLRequest::FollowRedirect)
|
||||
.SetMethod("getUploadProgress", &URLRequest::GetUploadProgress)
|
||||
.SetProperty("notStarted", &URLRequest::NotStarted)
|
||||
.SetProperty("finished", &URLRequest::Finished)
|
||||
.SetProperty("statusCode", &URLRequest::StatusCode)
|
||||
.SetProperty("statusMessage", &URLRequest::StatusMessage)
|
||||
.SetProperty("rawResponseHeaders", &URLRequest::RawResponseHeaders)
|
||||
.SetProperty("httpVersionMajor", &URLRequest::ResponseHttpVersionMajor)
|
||||
.SetProperty("httpVersionMinor", &URLRequest::ResponseHttpVersionMinor);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
@@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_BROWSER_API_ATOM_API_URL_REQUEST_NS_H_
|
||||
#define SHELL_BROWSER_API_ATOM_API_URL_REQUEST_NS_H_
|
||||
#ifndef SHELL_BROWSER_API_ATOM_API_URL_REQUEST_H_
|
||||
#define SHELL_BROWSER_API_ATOM_API_URL_REQUEST_H_
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "services/network/public/cpp/simple_url_loader.h"
|
||||
#include "services/network/public/cpp/simple_url_loader_stream_consumer.h"
|
||||
#include "services/network/public/mojom/data_pipe_getter.mojom.h"
|
||||
#include "shell/browser/api/event_emitter_deprecated.h"
|
||||
#include "shell/common/gin_helper/event_emitter.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
@@ -25,8 +25,8 @@ namespace api {
|
||||
|
||||
class UploadDataPipeGetter;
|
||||
|
||||
class URLRequestNS : public mate::EventEmitter<URLRequestNS>,
|
||||
public network::SimpleURLLoaderStreamConsumer {
|
||||
class URLRequest : public gin_helper::EventEmitter<URLRequest>,
|
||||
public network::SimpleURLLoaderStreamConsumer {
|
||||
public:
|
||||
static mate::WrappableBase* New(gin::Arguments* args);
|
||||
|
||||
@@ -34,8 +34,8 @@ class URLRequestNS : public mate::EventEmitter<URLRequestNS>,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
protected:
|
||||
explicit URLRequestNS(gin::Arguments* args);
|
||||
~URLRequestNS() override;
|
||||
explicit URLRequest(gin::Arguments* args);
|
||||
~URLRequest() override;
|
||||
|
||||
bool NotStarted() const;
|
||||
bool Finished() const;
|
||||
@@ -132,13 +132,13 @@ class URLRequestNS : public mate::EventEmitter<URLRequestNS>,
|
||||
// Used by pin/unpin to manage lifetime.
|
||||
v8::Global<v8::Object> wrapper_;
|
||||
|
||||
base::WeakPtrFactory<URLRequestNS> weak_factory_;
|
||||
base::WeakPtrFactory<URLRequest> weak_factory_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(URLRequestNS);
|
||||
DISALLOW_COPY_AND_ASSIGN(URLRequest);
|
||||
};
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace electron
|
||||
|
||||
#endif // SHELL_BROWSER_API_ATOM_API_URL_REQUEST_NS_H_
|
||||
#endif // SHELL_BROWSER_API_ATOM_API_URL_REQUEST_H_
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include "shell/browser/api/atom_api_view.h"
|
||||
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
||||
namespace electron {
|
||||
@@ -23,16 +24,16 @@ View::~View() {
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_VIEW_API)
|
||||
void View::SetLayoutManager(mate::Handle<LayoutManager> layout_manager) {
|
||||
void View::SetLayoutManager(gin::Handle<LayoutManager> layout_manager) {
|
||||
layout_manager_.Reset(isolate(), layout_manager->GetWrapper());
|
||||
view()->SetLayoutManager(layout_manager->TakeOver());
|
||||
}
|
||||
|
||||
void View::AddChildView(mate::Handle<View> child) {
|
||||
void View::AddChildView(gin::Handle<View> child) {
|
||||
AddChildViewAt(child, child_views_.size());
|
||||
}
|
||||
|
||||
void View::AddChildViewAt(mate::Handle<View> child, size_t index) {
|
||||
void View::AddChildViewAt(gin::Handle<View> child, size_t index) {
|
||||
if (index > child_views_.size())
|
||||
return;
|
||||
child_views_.emplace(child_views_.begin() + index, // index
|
||||
@@ -51,9 +52,9 @@ mate::WrappableBase* View::New(gin::Arguments* args) {
|
||||
// static
|
||||
void View::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "View"));
|
||||
prototype->SetClassName(gin::StringToV8(isolate, "View"));
|
||||
#if BUILDFLAG(ENABLE_VIEW_API)
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("setLayoutManager", &View::SetLayoutManager)
|
||||
.SetMethod("addChildView", &View::AddChildView)
|
||||
.SetMethod("addChildViewAt", &View::AddChildViewAt);
|
||||
@@ -75,11 +76,11 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
View::SetConstructor(isolate, base::BindRepeating(&View::New));
|
||||
|
||||
mate::Dictionary constructor(
|
||||
gin_helper::Dictionary constructor(
|
||||
isolate,
|
||||
View::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
|
||||
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
gin_helper::Dictionary dict(isolate, exports);
|
||||
dict.Set("View", constructor);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "gin/handle.h"
|
||||
#include "shell/browser/api/views/atom_api_layout_manager.h"
|
||||
#include "ui/views/view.h"
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace electron {
|
||||
|
||||
namespace api {
|
||||
|
||||
class View : public mate::TrackableObject<View> {
|
||||
class View : public gin_helper::TrackableObject<View> {
|
||||
public:
|
||||
static mate::WrappableBase* New(gin::Arguments* args);
|
||||
|
||||
@@ -25,9 +25,9 @@ class View : public mate::TrackableObject<View> {
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
#if BUILDFLAG(ENABLE_VIEW_API)
|
||||
void SetLayoutManager(mate::Handle<LayoutManager> layout_manager);
|
||||
void AddChildView(mate::Handle<View> view);
|
||||
void AddChildViewAt(mate::Handle<View> view, size_t index);
|
||||
void SetLayoutManager(gin::Handle<LayoutManager> layout_manager);
|
||||
void AddChildView(gin::Handle<View> view);
|
||||
void AddChildViewAt(gin::Handle<View> view, size_t index);
|
||||
#endif
|
||||
|
||||
views::View* view() const { return view_; }
|
||||
@@ -54,7 +54,7 @@ class View : public mate::TrackableObject<View> {
|
||||
|
||||
} // namespace electron
|
||||
|
||||
namespace mate {
|
||||
namespace gin {
|
||||
|
||||
template <>
|
||||
struct Converter<views::View*> {
|
||||
@@ -69,6 +69,6 @@ struct Converter<views::View*> {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
} // namespace gin
|
||||
|
||||
#endif // SHELL_BROWSER_API_ATOM_API_VIEW_H_
|
||||
|
||||
@@ -45,9 +45,6 @@
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "electron/shell/common/api/api.mojom.h"
|
||||
#include "mojo/public/cpp/system/platform_handle.h"
|
||||
#include "native_mate/converter.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder_deprecated.h"
|
||||
#include "ppapi/buildflags/buildflags.h"
|
||||
#include "shell/browser/api/atom_api_browser_window.h"
|
||||
#include "shell/browser/api/atom_api_debugger.h"
|
||||
@@ -72,20 +69,18 @@
|
||||
#include "shell/browser/web_view_guest_delegate.h"
|
||||
#include "shell/common/api/atom_api_native_image.h"
|
||||
#include "shell/common/color_util.h"
|
||||
#include "shell/common/gin_converters/blink_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_converters/callback_converter.h"
|
||||
#include "shell/common/gin_converters/content_converter.h"
|
||||
#include "shell/common/gin_converters/file_path_converter.h"
|
||||
#include "shell/common/gin_converters/gfx_converter.h"
|
||||
#include "shell/common/gin_converters/gurl_converter.h"
|
||||
#include "shell/common/gin_converters/image_converter.h"
|
||||
#include "shell/common/gin_converters/net_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/mouse_util.h"
|
||||
#include "shell/common/native_mate_converters/blink_converter.h"
|
||||
#include "shell/common/native_mate_converters/content_converter.h"
|
||||
#include "shell/common/native_mate_converters/file_path_converter.h"
|
||||
#include "shell/common/native_mate_converters/gurl_converter.h"
|
||||
#include "shell/common/native_mate_converters/image_converter.h"
|
||||
#include "shell/common/native_mate_converters/net_converter.h"
|
||||
#include "shell/common/native_mate_converters/network_converter.h"
|
||||
#include "shell/common/native_mate_converters/once_callback.h"
|
||||
#include "shell/common/native_mate_converters/string16_converter.h"
|
||||
#include "shell/common/native_mate_converters/value_converter.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "shell/common/options_switches.h"
|
||||
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
|
||||
@@ -125,7 +120,7 @@
|
||||
#include "shell/browser/extensions/atom_extension_web_contents_observer.h"
|
||||
#endif
|
||||
|
||||
namespace mate {
|
||||
namespace gin {
|
||||
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
template <>
|
||||
@@ -221,7 +216,7 @@ struct Converter<WindowOpenDisposition> {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return mate::ConvertToV8(isolate, disposition);
|
||||
return gin::ConvertToV8(isolate, disposition);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -275,7 +270,7 @@ struct Converter<electron::api::WebContents::Type> {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return mate::ConvertToV8(isolate, type);
|
||||
return gin::ConvertToV8(isolate, type);
|
||||
}
|
||||
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
@@ -307,14 +302,14 @@ struct Converter<scoped_refptr<content::DevToolsAgentHost>> {
|
||||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const scoped_refptr<content::DevToolsAgentHost>& val) {
|
||||
mate::Dictionary dict(isolate, v8::Object::New(isolate));
|
||||
gin_helper::Dictionary dict(isolate, v8::Object::New(isolate));
|
||||
dict.Set("id", val->GetId());
|
||||
dict.Set("url", val->GetURL().spec());
|
||||
return dict.GetHandle();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
} // namespace gin
|
||||
|
||||
namespace electron {
|
||||
|
||||
@@ -326,7 +321,7 @@ namespace {
|
||||
void OnCapturePageDone(util::Promise<gfx::Image> promise,
|
||||
const SkBitmap& bitmap) {
|
||||
// Hack to enable transparency in captured image
|
||||
promise.Resolve(gfx::Image::CreateFrom1xBitmap(bitmap));
|
||||
promise.ResolveWithGin(gfx::Image::CreateFrom1xBitmap(bitmap));
|
||||
}
|
||||
|
||||
base::Optional<base::TimeDelta> GetCursorBlinkInterval() {
|
||||
@@ -359,7 +354,7 @@ WebContents::WebContents(v8::Isolate* isolate,
|
||||
false);
|
||||
Init(isolate);
|
||||
AttachAsUserData(web_contents);
|
||||
InitZoomController(web_contents, mate::Dictionary::CreateEmpty(isolate));
|
||||
InitZoomController(web_contents, gin::Dictionary::CreateEmpty(isolate));
|
||||
registry_.AddInterface(base::BindRepeating(&WebContents::BindElectronBrowser,
|
||||
base::Unretained(this)));
|
||||
bindings_.set_connection_error_handler(base::BindRepeating(
|
||||
@@ -377,10 +372,11 @@ WebContents::WebContents(v8::Isolate* isolate,
|
||||
auto session = Session::CreateFrom(isolate, GetBrowserContext());
|
||||
session_.Reset(isolate, session.ToV8());
|
||||
InitWithSessionAndOptions(isolate, std::move(web_contents), session,
|
||||
mate::Dictionary::CreateEmpty(isolate));
|
||||
gin::Dictionary::CreateEmpty(isolate));
|
||||
}
|
||||
|
||||
WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
|
||||
WebContents::WebContents(v8::Isolate* isolate,
|
||||
const gin_helper::Dictionary& options)
|
||||
: weak_factory_(this) {
|
||||
// Read options.
|
||||
options.Get("backgroundThrottling", &background_throttling_);
|
||||
@@ -405,7 +401,7 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
|
||||
|
||||
// Obtain the session.
|
||||
std::string partition;
|
||||
mate::Handle<api::Session> session;
|
||||
gin::Handle<api::Session> session;
|
||||
if (options.Get("session", &session) && !session.IsEmpty()) {
|
||||
} else if (options.Get("partition", &partition)) {
|
||||
session = Session::FromPartition(isolate, partition);
|
||||
@@ -465,7 +461,7 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
|
||||
}
|
||||
|
||||
void WebContents::InitZoomController(content::WebContents* web_contents,
|
||||
const mate::Dictionary& options) {
|
||||
const gin_helper::Dictionary& options) {
|
||||
WebContentsZoomController::CreateForWebContents(web_contents);
|
||||
zoom_controller_ = WebContentsZoomController::FromWebContents(web_contents);
|
||||
double zoom_factor;
|
||||
@@ -476,8 +472,8 @@ void WebContents::InitZoomController(content::WebContents* web_contents,
|
||||
void WebContents::InitWithSessionAndOptions(
|
||||
v8::Isolate* isolate,
|
||||
std::unique_ptr<content::WebContents> owned_web_contents,
|
||||
mate::Handle<api::Session> session,
|
||||
const mate::Dictionary& options) {
|
||||
gin::Handle<api::Session> session,
|
||||
const gin_helper::Dictionary& options) {
|
||||
Observe(owned_web_contents.get());
|
||||
// TODO(zcbenz): Make InitWithWebContents take unique_ptr.
|
||||
// At the time of writing we are going through a refactoring and I don't want
|
||||
@@ -672,8 +668,7 @@ void WebContents::BeforeUnloadFired(content::WebContents* tab,
|
||||
|
||||
void WebContents::SetContentsBounds(content::WebContents* source,
|
||||
const gfx::Rect& pos) {
|
||||
// TODO(zcbenz): Use implicit convertion after removing mate::EventEmitter.
|
||||
Emit("move", gin::ConvertToV8(isolate(), pos));
|
||||
Emit("move", pos);
|
||||
}
|
||||
|
||||
void WebContents::CloseContents(content::WebContents* source) {
|
||||
@@ -1054,7 +1049,7 @@ void WebContents::MessageTo(bool internal,
|
||||
int32_t web_contents_id,
|
||||
const std::string& channel,
|
||||
blink::CloneableMessage arguments) {
|
||||
auto* web_contents = mate::TrackableObject<WebContents>::FromWeakMapID(
|
||||
auto* web_contents = gin_helper::TrackableObject<WebContents>::FromWeakMapID(
|
||||
isolate(), web_contents_id);
|
||||
|
||||
if (web_contents) {
|
||||
@@ -1346,7 +1341,8 @@ bool WebContents::Equal(const WebContents* web_contents) const {
|
||||
return ID() == web_contents->ID();
|
||||
}
|
||||
|
||||
void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
|
||||
void WebContents::LoadURL(const GURL& url,
|
||||
const gin_helper::Dictionary& options) {
|
||||
if (!url.is_valid() || url.spec().size() > url::kMaxURLChars) {
|
||||
Emit("did-fail-load", static_cast<int>(net::ERR_INVALID_URL),
|
||||
net::ErrorToShortString(net::ERR_INVALID_URL),
|
||||
@@ -1487,7 +1483,7 @@ bool WebContents::IsCrashed() const {
|
||||
}
|
||||
|
||||
void WebContents::SetUserAgent(const std::string& user_agent,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
web_contents()->SetUserAgentOverride(user_agent, false);
|
||||
}
|
||||
|
||||
@@ -1507,7 +1503,7 @@ v8::Local<v8::Promise> WebContents::SavePage(
|
||||
return handle;
|
||||
}
|
||||
|
||||
void WebContents::OpenDevTools(mate::Arguments* args) {
|
||||
void WebContents::OpenDevTools(gin_helper::Arguments* args) {
|
||||
if (type_ == Type::REMOTE)
|
||||
return;
|
||||
|
||||
@@ -1520,7 +1516,7 @@ void WebContents::OpenDevTools(mate::Arguments* args) {
|
||||
}
|
||||
bool activate = true;
|
||||
if (args && args->Length() == 1) {
|
||||
mate::Dictionary options;
|
||||
gin_helper::Dictionary options;
|
||||
if (args->GetNext(&options)) {
|
||||
options.Get("mode", &state);
|
||||
options.Get("activate", &activate);
|
||||
@@ -1693,8 +1689,9 @@ bool WebContents::IsCurrentlyAudible() {
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
void WebContents::Print(mate::Arguments* args) {
|
||||
mate::Dictionary options = mate::Dictionary::CreateEmpty(args->isolate());
|
||||
void WebContents::Print(gin_helper::Arguments* args) {
|
||||
gin_helper::Dictionary options =
|
||||
gin::Dictionary::CreateEmpty(args->isolate());
|
||||
base::DictionaryValue settings;
|
||||
|
||||
if (args->Length() >= 1 && !args->GetNext(&options)) {
|
||||
@@ -1719,7 +1716,8 @@ void WebContents::Print(mate::Arguments* args) {
|
||||
print_background);
|
||||
|
||||
// Set custom margin settings
|
||||
mate::Dictionary margins = mate::Dictionary::CreateEmpty(args->isolate());
|
||||
gin_helper::Dictionary margins =
|
||||
gin::Dictionary::CreateEmpty(args->isolate());
|
||||
if (options.Get("margins", &margins)) {
|
||||
printing::MarginType margin_type = printing::DEFAULT_MARGINS;
|
||||
margins.Get("marginType", &margin_type);
|
||||
@@ -1805,7 +1803,7 @@ void WebContents::Print(mate::Arguments* args) {
|
||||
settings.SetBoolean(printing::kSettingRasterizePdf, false);
|
||||
|
||||
// Set custom page ranges to print
|
||||
std::vector<mate::Dictionary> page_ranges;
|
||||
std::vector<gin_helper::Dictionary> page_ranges;
|
||||
if (options.Get("pageRanges", &page_ranges)) {
|
||||
std::unique_ptr<base::ListValue> page_range_list(new base::ListValue());
|
||||
for (auto& range : page_ranges) {
|
||||
@@ -1830,7 +1828,7 @@ void WebContents::Print(mate::Arguments* args) {
|
||||
settings.SetInteger(printing::kSettingDuplexMode, duplex_mode);
|
||||
|
||||
// Set custom dots per inch (dpi)
|
||||
mate::Dictionary dpi_settings;
|
||||
gin_helper::Dictionary dpi_settings;
|
||||
int dpi = 72;
|
||||
if (options.Get("dpi", &dpi_settings)) {
|
||||
int horizontal = 72;
|
||||
@@ -1878,7 +1876,7 @@ v8::Local<v8::Promise> WebContents::PrintToPDF(
|
||||
}
|
||||
#endif
|
||||
|
||||
void WebContents::AddWorkSpace(mate::Arguments* args,
|
||||
void WebContents::AddWorkSpace(gin_helper::Arguments* args,
|
||||
const base::FilePath& path) {
|
||||
if (path.empty()) {
|
||||
args->ThrowError("path cannot be empty");
|
||||
@@ -1887,7 +1885,7 @@ void WebContents::AddWorkSpace(mate::Arguments* args,
|
||||
DevToolsAddFileSystem(std::string(), path);
|
||||
}
|
||||
|
||||
void WebContents::RemoveWorkSpace(mate::Arguments* args,
|
||||
void WebContents::RemoveWorkSpace(gin_helper::Arguments* args,
|
||||
const base::FilePath& path) {
|
||||
if (path.empty()) {
|
||||
args->ThrowError("path cannot be empty");
|
||||
@@ -1940,7 +1938,7 @@ void WebContents::ReplaceMisspelling(const base::string16& word) {
|
||||
web_contents()->ReplaceMisspelling(word);
|
||||
}
|
||||
|
||||
uint32_t WebContents::FindInPage(mate::Arguments* args) {
|
||||
uint32_t WebContents::FindInPage(gin_helper::Arguments* args) {
|
||||
base::string16 search_text;
|
||||
if (!args->GetNext(&search_text) || search_text.empty()) {
|
||||
args->ThrowError("Must provide a non-empty search content");
|
||||
@@ -1948,7 +1946,7 @@ uint32_t WebContents::FindInPage(mate::Arguments* args) {
|
||||
}
|
||||
|
||||
uint32_t request_id = GetNextRequestId();
|
||||
mate::Dictionary dict;
|
||||
gin_helper::Dictionary dict;
|
||||
auto options = blink::mojom::FindOptions::New();
|
||||
if (args->GetNext(&dict)) {
|
||||
dict.Get("forward", &options->forward);
|
||||
@@ -2007,9 +2005,9 @@ bool WebContents::SendIPCMessage(bool internal,
|
||||
const std::string& channel,
|
||||
v8::Local<v8::Value> args) {
|
||||
blink::CloneableMessage message;
|
||||
if (!mate::ConvertFromV8(isolate(), args, &message)) {
|
||||
if (!gin::ConvertFromV8(isolate(), args, &message)) {
|
||||
isolate()->ThrowException(v8::Exception::Error(
|
||||
mate::StringToV8(isolate(), "Failed to serialize arguments")));
|
||||
gin::StringToV8(isolate(), "Failed to serialize arguments")));
|
||||
return false;
|
||||
}
|
||||
return SendIPCMessageWithSender(internal, send_to_all, channel,
|
||||
@@ -2046,9 +2044,9 @@ bool WebContents::SendIPCMessageToFrame(bool internal,
|
||||
const std::string& channel,
|
||||
v8::Local<v8::Value> args) {
|
||||
blink::CloneableMessage message;
|
||||
if (!mate::ConvertFromV8(isolate(), args, &message)) {
|
||||
if (!gin::ConvertFromV8(isolate(), args, &message)) {
|
||||
isolate()->ThrowException(v8::Exception::Error(
|
||||
mate::StringToV8(isolate(), "Failed to serialize arguments")));
|
||||
gin::StringToV8(isolate(), "Failed to serialize arguments")));
|
||||
return false;
|
||||
}
|
||||
auto frames = web_contents()->GetAllFrames();
|
||||
@@ -2094,7 +2092,7 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
|
||||
content::NativeWebKeyboardEvent keyboard_event(
|
||||
blink::WebKeyboardEvent::kRawKeyDown,
|
||||
blink::WebInputEvent::kNoModifiers, ui::EventTimeForNow());
|
||||
if (mate::ConvertFromV8(isolate, input_event, &keyboard_event)) {
|
||||
if (gin::ConvertFromV8(isolate, input_event, &keyboard_event)) {
|
||||
rwh->ForwardKeyboardEvent(keyboard_event);
|
||||
return;
|
||||
}
|
||||
@@ -2127,14 +2125,10 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
|
||||
}
|
||||
|
||||
isolate->ThrowException(
|
||||
v8::Exception::Error(mate::StringToV8(isolate, "Invalid event object")));
|
||||
v8::Exception::Error(gin::StringToV8(isolate, "Invalid event object")));
|
||||
}
|
||||
|
||||
void WebContents::BeginFrameSubscription(mate::Arguments* mate_args) {
|
||||
// TODO(zcbenz): Remove this after converting WebContents to gin.
|
||||
gin::Arguments gin_args(mate_args->info());
|
||||
gin_helper::Arguments* args = static_cast<gin_helper::Arguments*>(&gin_args);
|
||||
|
||||
void WebContents::BeginFrameSubscription(gin_helper::Arguments* args) {
|
||||
bool only_dirty = false;
|
||||
FrameSubscriber::FrameCaptureCallback callback;
|
||||
|
||||
@@ -2152,32 +2146,19 @@ void WebContents::EndFrameSubscription() {
|
||||
frame_subscriber_.reset();
|
||||
}
|
||||
|
||||
void WebContents::StartDrag(const mate::Dictionary& item,
|
||||
mate::Arguments* args) {
|
||||
void WebContents::StartDrag(const gin_helper::Dictionary& item,
|
||||
gin_helper::Arguments* args) {
|
||||
base::FilePath file;
|
||||
std::vector<base::FilePath> files;
|
||||
if (!item.Get("files", &files) && item.Get("file", &file)) {
|
||||
files.push_back(file);
|
||||
}
|
||||
|
||||
mate::Handle<NativeImage> icon;
|
||||
if (!item.Get("icon", &icon) && !file.empty()) {
|
||||
// TODO(zcbenz): Set default icon from file.
|
||||
}
|
||||
|
||||
// Error checking.
|
||||
if (icon.IsEmpty()) {
|
||||
args->ThrowError("Must specify 'icon' option");
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
// NSWindow.dragImage requires a non-empty NSImage
|
||||
if (icon->image().IsEmpty()) {
|
||||
gin::Handle<NativeImage> icon;
|
||||
if (!item.Get("icon", &icon)) {
|
||||
args->ThrowError("Must specify non-empty 'icon' option");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Start dragging.
|
||||
if (!files.empty()) {
|
||||
@@ -2188,11 +2169,7 @@ void WebContents::StartDrag(const mate::Dictionary& item,
|
||||
}
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> WebContents::CapturePage(mate::Arguments* mate_args) {
|
||||
// TODO(zcbenz): Remove this after converting WebContents to gin.
|
||||
gin::Arguments gin_args(mate_args->info());
|
||||
gin::Arguments* args = &gin_args;
|
||||
|
||||
v8::Local<v8::Promise> WebContents::CapturePage(gin_helper::Arguments* args) {
|
||||
gfx::Rect rect;
|
||||
util::Promise<gfx::Image> promise(isolate());
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
@@ -2202,7 +2179,7 @@ v8::Local<v8::Promise> WebContents::CapturePage(mate::Arguments* mate_args) {
|
||||
|
||||
auto* const view = web_contents()->GetRenderWidgetHostView();
|
||||
if (!view) {
|
||||
promise.Resolve(gfx::Image());
|
||||
promise.ResolveWithGin(gfx::Image());
|
||||
return handle;
|
||||
}
|
||||
|
||||
@@ -2233,11 +2210,8 @@ void WebContents::OnCursorChange(const content::WebCursor& cursor) {
|
||||
Emit("cursor-changed", CursorTypeToString(info),
|
||||
gfx::Image::CreateFrom1xBitmap(info.custom_image),
|
||||
info.image_scale_factor,
|
||||
// TODO(zcbenz): Use implicit convertion after removing
|
||||
// mate::EventEmitter.
|
||||
gin::ConvertToV8(isolate(), gfx::Size(info.custom_image.width(),
|
||||
info.custom_image.height())),
|
||||
gin::ConvertToV8(isolate(), info.hotspot));
|
||||
gfx::Size(info.custom_image.width(), info.custom_image.height()),
|
||||
info.hotspot);
|
||||
} else {
|
||||
Emit("cursor-changed", CursorTypeToString(info));
|
||||
}
|
||||
@@ -2374,7 +2348,7 @@ v8::Local<v8::Value> WebContents::GetWebPreferences(
|
||||
auto* web_preferences = WebContentsPreferences::From(web_contents());
|
||||
if (!web_preferences)
|
||||
return v8::Null(isolate);
|
||||
return mate::ConvertToV8(isolate, *web_preferences->preference());
|
||||
return gin::ConvertToV8(isolate, *web_preferences->preference());
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> WebContents::GetLastWebPreferences(
|
||||
@@ -2382,7 +2356,7 @@ v8::Local<v8::Value> WebContents::GetLastWebPreferences(
|
||||
auto* web_preferences = WebContentsPreferences::From(web_contents());
|
||||
if (!web_preferences)
|
||||
return v8::Null(isolate);
|
||||
return mate::ConvertToV8(isolate, *web_preferences->last_preference());
|
||||
return gin::ConvertToV8(isolate, *web_preferences->last_preference());
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> WebContents::GetOwnerBrowserWindow() const {
|
||||
@@ -2505,9 +2479,9 @@ v8::Local<v8::Promise> WebContents::TakeHeapSnapshot(
|
||||
// static
|
||||
void WebContents::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "WebContents"));
|
||||
prototype->SetClassName(gin::StringToV8(isolate, "WebContents"));
|
||||
gin_helper::Destroyable::MakeDestroyable(isolate, prototype);
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("setBackgroundThrottling",
|
||||
&WebContents::SetBackgroundThrottling)
|
||||
.SetMethod("getProcessId", &WebContents::GetProcessID)
|
||||
@@ -2631,40 +2605,40 @@ AtomBrowserContext* WebContents::GetBrowserContext() const {
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<WebContents> WebContents::Create(v8::Isolate* isolate,
|
||||
const mate::Dictionary& options) {
|
||||
return mate::CreateHandle(isolate, new WebContents(isolate, options));
|
||||
gin::Handle<WebContents> WebContents::Create(
|
||||
v8::Isolate* isolate,
|
||||
const gin_helper::Dictionary& options) {
|
||||
return gin::CreateHandle(isolate, new WebContents(isolate, options));
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<WebContents> WebContents::CreateAndTake(
|
||||
gin::Handle<WebContents> WebContents::CreateAndTake(
|
||||
v8::Isolate* isolate,
|
||||
std::unique_ptr<content::WebContents> web_contents,
|
||||
Type type) {
|
||||
return mate::CreateHandle(
|
||||
return gin::CreateHandle(
|
||||
isolate, new WebContents(isolate, std::move(web_contents), type));
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<WebContents> WebContents::From(
|
||||
v8::Isolate* isolate,
|
||||
content::WebContents* web_contents) {
|
||||
gin::Handle<WebContents> WebContents::From(v8::Isolate* isolate,
|
||||
content::WebContents* web_contents) {
|
||||
auto* existing = TrackableObject::FromWrappedClass(isolate, web_contents);
|
||||
if (existing)
|
||||
return mate::CreateHandle(isolate, static_cast<WebContents*>(existing));
|
||||
return gin::CreateHandle(isolate, static_cast<WebContents*>(existing));
|
||||
else
|
||||
return mate::Handle<WebContents>();
|
||||
return gin::Handle<WebContents>();
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<WebContents> WebContents::FromOrCreate(
|
||||
gin::Handle<WebContents> WebContents::FromOrCreate(
|
||||
v8::Isolate* isolate,
|
||||
content::WebContents* web_contents) {
|
||||
auto existing = From(isolate, web_contents);
|
||||
if (!existing.IsEmpty())
|
||||
return existing;
|
||||
else
|
||||
return mate::CreateHandle(isolate, new WebContents(isolate, web_contents));
|
||||
return gin::CreateHandle(isolate, new WebContents(isolate, web_contents));
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
@@ -2680,7 +2654,7 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
gin_helper::Dictionary dict(isolate, exports);
|
||||
dict.Set("WebContents", WebContents::GetConstructor(isolate)
|
||||
->GetFunction(context)
|
||||
.ToLocalChecked());
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
#include "content/public/common/favicon_url.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "electron/shell/common/api/api.mojom.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "gin/handle.h"
|
||||
#include "printing/buildflags/buildflags.h"
|
||||
#include "services/service_manager/public/cpp/binder_registry.h"
|
||||
#include "shell/browser/api/frame_subscriber.h"
|
||||
#include "shell/browser/api/save_page_handler.h"
|
||||
#include "shell/browser/api/trackable_object.h"
|
||||
#include "shell/browser/common_web_contents_delegate.h"
|
||||
#include "shell/common/gin_helper/trackable_object.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
@@ -40,10 +40,9 @@ namespace blink {
|
||||
struct WebDeviceEmulationParams;
|
||||
}
|
||||
|
||||
namespace mate {
|
||||
class Arguments;
|
||||
namespace gin_helper {
|
||||
class Dictionary;
|
||||
} // namespace mate
|
||||
}
|
||||
|
||||
namespace network {
|
||||
class ResourceRequestBody;
|
||||
@@ -78,7 +77,7 @@ class ExtendedWebContentsObserver : public base::CheckedObserver {
|
||||
};
|
||||
|
||||
// Wrapper around the content::WebContents.
|
||||
class WebContents : public mate::TrackableObject<WebContents>,
|
||||
class WebContents : public gin_helper::TrackableObject<WebContents>,
|
||||
public CommonWebContentsDelegate,
|
||||
public content::WebContentsObserver,
|
||||
public mojom::ElectronBrowser {
|
||||
@@ -93,26 +92,26 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
};
|
||||
|
||||
// Create a new WebContents and return the V8 wrapper of it.
|
||||
static mate::Handle<WebContents> Create(v8::Isolate* isolate,
|
||||
const mate::Dictionary& options);
|
||||
static gin::Handle<WebContents> Create(v8::Isolate* isolate,
|
||||
const gin_helper::Dictionary& options);
|
||||
|
||||
// Create a new V8 wrapper for an existing |web_content|.
|
||||
//
|
||||
// The lifetime of |web_contents| will be managed by this class.
|
||||
static mate::Handle<WebContents> CreateAndTake(
|
||||
static gin::Handle<WebContents> CreateAndTake(
|
||||
v8::Isolate* isolate,
|
||||
std::unique_ptr<content::WebContents> web_contents,
|
||||
Type type);
|
||||
|
||||
// Get the V8 wrapper of |web_content|, return empty handle if not wrapped.
|
||||
static mate::Handle<WebContents> From(v8::Isolate* isolate,
|
||||
content::WebContents* web_content);
|
||||
static gin::Handle<WebContents> From(v8::Isolate* isolate,
|
||||
content::WebContents* web_content);
|
||||
|
||||
// Get the V8 wrapper of the |web_contents|, or create one if not existed.
|
||||
//
|
||||
// The lifetime of |web_contents| is NOT managed by this class, and the type
|
||||
// of this wrapper is always REMOTE.
|
||||
static mate::Handle<WebContents> FromOrCreate(
|
||||
static gin::Handle<WebContents> FromOrCreate(
|
||||
v8::Isolate* isolate,
|
||||
content::WebContents* web_contents);
|
||||
|
||||
@@ -143,7 +142,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
const std::string& document_url) const;
|
||||
Type GetType() const;
|
||||
bool Equal(const WebContents* web_contents) const;
|
||||
void LoadURL(const GURL& url, const mate::Dictionary& options);
|
||||
void LoadURL(const GURL& url, const gin_helper::Dictionary& options);
|
||||
void DownloadURL(const GURL& url);
|
||||
GURL GetURL() const;
|
||||
base::string16 GetTitle() const;
|
||||
@@ -158,12 +157,12 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
const std::string GetWebRTCIPHandlingPolicy() const;
|
||||
void SetWebRTCIPHandlingPolicy(const std::string& webrtc_ip_handling_policy);
|
||||
bool IsCrashed() const;
|
||||
void SetUserAgent(const std::string& user_agent, mate::Arguments* args);
|
||||
void SetUserAgent(const std::string& user_agent, gin_helper::Arguments* args);
|
||||
std::string GetUserAgent();
|
||||
void InsertCSS(const std::string& css);
|
||||
v8::Local<v8::Promise> SavePage(const base::FilePath& full_file_path,
|
||||
const content::SavePageType& save_type);
|
||||
void OpenDevTools(mate::Arguments* args);
|
||||
void OpenDevTools(gin_helper::Arguments* args);
|
||||
void CloseDevTools();
|
||||
bool IsDevToolsOpened();
|
||||
bool IsDevToolsFocused();
|
||||
@@ -184,15 +183,15 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
v8::Local<v8::Value> GetNativeView() const;
|
||||
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
void Print(mate::Arguments* args);
|
||||
void Print(gin_helper::Arguments* args);
|
||||
std::vector<printing::PrinterBasicInfo> GetPrinterList();
|
||||
// Print current page as PDF.
|
||||
v8::Local<v8::Promise> PrintToPDF(const base::DictionaryValue& settings);
|
||||
#endif
|
||||
|
||||
// DevTools workspace api.
|
||||
void AddWorkSpace(mate::Arguments* args, const base::FilePath& path);
|
||||
void RemoveWorkSpace(mate::Arguments* args, const base::FilePath& path);
|
||||
void AddWorkSpace(gin_helper::Arguments* args, const base::FilePath& path);
|
||||
void RemoveWorkSpace(gin_helper::Arguments* args, const base::FilePath& path);
|
||||
|
||||
// Editing commands.
|
||||
void Undo();
|
||||
@@ -206,7 +205,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
void Unselect();
|
||||
void Replace(const base::string16& word);
|
||||
void ReplaceMisspelling(const base::string16& word);
|
||||
uint32_t FindInPage(mate::Arguments* args);
|
||||
uint32_t FindInPage(gin_helper::Arguments* args);
|
||||
void StopFindInPage(content::StopFindAction action);
|
||||
void ShowDefinitionForSelection();
|
||||
void CopyImageAt(int x, int y);
|
||||
@@ -238,15 +237,16 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
void SendInputEvent(v8::Isolate* isolate, v8::Local<v8::Value> input_event);
|
||||
|
||||
// Subscribe to the frame updates.
|
||||
void BeginFrameSubscription(mate::Arguments* args);
|
||||
void BeginFrameSubscription(gin_helper::Arguments* args);
|
||||
void EndFrameSubscription();
|
||||
|
||||
// Dragging native items.
|
||||
void StartDrag(const mate::Dictionary& item, mate::Arguments* args);
|
||||
void StartDrag(const gin_helper::Dictionary& item,
|
||||
gin_helper::Arguments* args);
|
||||
|
||||
// Captures the page with |rect|, |callback| would be called when capturing is
|
||||
// done.
|
||||
v8::Local<v8::Promise> CapturePage(mate::Arguments* args);
|
||||
v8::Local<v8::Promise> CapturePage(gin_helper::Arguments* args);
|
||||
|
||||
// Methods for creating <webview>.
|
||||
bool IsGuest() const;
|
||||
@@ -335,14 +335,14 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
std::unique_ptr<content::WebContents> web_contents,
|
||||
Type type);
|
||||
// Creates a new content::WebContents.
|
||||
WebContents(v8::Isolate* isolate, const mate::Dictionary& options);
|
||||
WebContents(v8::Isolate* isolate, const gin_helper::Dictionary& options);
|
||||
~WebContents() override;
|
||||
|
||||
void InitWithSessionAndOptions(
|
||||
v8::Isolate* isolate,
|
||||
std::unique_ptr<content::WebContents> web_contents,
|
||||
mate::Handle<class Session> session,
|
||||
const mate::Dictionary& options);
|
||||
gin::Handle<class Session> session,
|
||||
const gin_helper::Dictionary& options);
|
||||
|
||||
// content::WebContentsDelegate:
|
||||
bool DidAddMessageToConsole(content::WebContents* source,
|
||||
@@ -526,7 +526,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
IPC::Message* reply_msg);
|
||||
|
||||
void InitZoomController(content::WebContents* web_contents,
|
||||
const mate::Dictionary& options);
|
||||
const gin_helper::Dictionary& options);
|
||||
|
||||
v8::Global<v8::Value> session_;
|
||||
v8::Global<v8::Value> devtools_web_contents_;
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
#include "shell/browser/api/atom_api_web_contents_view.h"
|
||||
|
||||
#include "content/public/browser/web_contents_user_data.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "shell/browser/api/atom_api_web_contents.h"
|
||||
#include "shell/browser/browser.h"
|
||||
#include "shell/browser/ui/inspectable_web_contents_view.h"
|
||||
#include "shell/common/api/constructor.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
@@ -44,7 +44,7 @@ namespace electron {
|
||||
namespace api {
|
||||
|
||||
WebContentsView::WebContentsView(v8::Isolate* isolate,
|
||||
mate::Handle<WebContents> web_contents,
|
||||
gin::Handle<WebContents> web_contents,
|
||||
InspectableWebContents* iwc)
|
||||
#if defined(OS_MACOSX)
|
||||
: View(new DelayedNativeViewHost(iwc->GetView()->GetNativeView())),
|
||||
@@ -80,22 +80,18 @@ void WebContentsView::WebContentsDestroyed() {
|
||||
|
||||
// static
|
||||
mate::WrappableBase* WebContentsView::New(
|
||||
gin::Arguments* args,
|
||||
mate::Handle<WebContents> web_contents) {
|
||||
gin_helper::Arguments* args,
|
||||
gin::Handle<WebContents> web_contents) {
|
||||
// Currently we only support InspectableWebContents, e.g. the WebContents
|
||||
// created by users directly. To support devToolsWebContents we need to create
|
||||
// a wrapper view.
|
||||
if (!web_contents->managed_web_contents()) {
|
||||
const char* error = "The WebContents must be created by user";
|
||||
args->isolate()->ThrowException(
|
||||
v8::Exception::Error(mate::StringToV8(args->isolate(), error)));
|
||||
args->ThrowError("The WebContents must be created by user");
|
||||
return nullptr;
|
||||
}
|
||||
// Check if the WebContents has already been added to a view.
|
||||
if (WebContentsViewRelay::FromWebContents(web_contents->web_contents())) {
|
||||
const char* error = "The WebContents has already been added to a View";
|
||||
args->isolate()->ThrowException(
|
||||
v8::Exception::Error(mate::StringToV8(args->isolate(), error)));
|
||||
args->ThrowError("The WebContents has already been added to a View");
|
||||
return nullptr;
|
||||
}
|
||||
// Constructor call.
|
||||
@@ -123,7 +119,7 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
gin_helper::Dictionary dict(isolate, exports);
|
||||
dict.Set("WebContentsView",
|
||||
mate::CreateConstructor<WebContentsView>(
|
||||
isolate, base::BindRepeating(&WebContentsView::New)));
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#define SHELL_BROWSER_API_ATOM_API_WEB_CONTENTS_VIEW_H_
|
||||
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "shell/browser/api/atom_api_view.h"
|
||||
|
||||
namespace electron {
|
||||
@@ -19,15 +18,15 @@ class WebContents;
|
||||
|
||||
class WebContentsView : public View, public content::WebContentsObserver {
|
||||
public:
|
||||
static mate::WrappableBase* New(gin::Arguments* args,
|
||||
mate::Handle<WebContents> web_contents);
|
||||
static mate::WrappableBase* New(gin_helper::Arguments* args,
|
||||
gin::Handle<WebContents> web_contents);
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
protected:
|
||||
WebContentsView(v8::Isolate* isolate,
|
||||
mate::Handle<WebContents> web_contents,
|
||||
gin::Handle<WebContents> web_contents,
|
||||
InspectableWebContents* iwc);
|
||||
~WebContentsView() override;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/api/atom_api_web_request_ns.h"
|
||||
#include "shell/browser/api/atom_api_web_request.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -79,12 +79,12 @@ namespace api {
|
||||
|
||||
namespace {
|
||||
|
||||
const char* kUserDataKey = "WebRequestNS";
|
||||
const char* kUserDataKey = "WebRequest";
|
||||
|
||||
// BrowserContext <=> WebRequestNS relationship.
|
||||
// BrowserContext <=> WebRequest relationship.
|
||||
struct UserData : public base::SupportsUserData::Data {
|
||||
explicit UserData(WebRequestNS* data) : data(data) {}
|
||||
WebRequestNS* data;
|
||||
explicit UserData(WebRequest* data) : data(data) {}
|
||||
WebRequest* data;
|
||||
};
|
||||
|
||||
// Test whether the URL of |request| matches |patterns|.
|
||||
@@ -212,72 +212,72 @@ void ReadFromResponse(v8::Isolate* isolate,
|
||||
|
||||
} // namespace
|
||||
|
||||
gin::WrapperInfo WebRequestNS::kWrapperInfo = {gin::kEmbedderNativeGin};
|
||||
gin::WrapperInfo WebRequest::kWrapperInfo = {gin::kEmbedderNativeGin};
|
||||
|
||||
WebRequestNS::SimpleListenerInfo::SimpleListenerInfo(
|
||||
WebRequest::SimpleListenerInfo::SimpleListenerInfo(
|
||||
std::set<URLPattern> patterns_,
|
||||
SimpleListener listener_)
|
||||
: url_patterns(std::move(patterns_)), listener(listener_) {}
|
||||
WebRequestNS::SimpleListenerInfo::SimpleListenerInfo() = default;
|
||||
WebRequestNS::SimpleListenerInfo::~SimpleListenerInfo() = default;
|
||||
WebRequest::SimpleListenerInfo::SimpleListenerInfo() = default;
|
||||
WebRequest::SimpleListenerInfo::~SimpleListenerInfo() = default;
|
||||
|
||||
WebRequestNS::ResponseListenerInfo::ResponseListenerInfo(
|
||||
WebRequest::ResponseListenerInfo::ResponseListenerInfo(
|
||||
std::set<URLPattern> patterns_,
|
||||
ResponseListener listener_)
|
||||
: url_patterns(std::move(patterns_)), listener(listener_) {}
|
||||
WebRequestNS::ResponseListenerInfo::ResponseListenerInfo() = default;
|
||||
WebRequestNS::ResponseListenerInfo::~ResponseListenerInfo() = default;
|
||||
WebRequest::ResponseListenerInfo::ResponseListenerInfo() = default;
|
||||
WebRequest::ResponseListenerInfo::~ResponseListenerInfo() = default;
|
||||
|
||||
WebRequestNS::WebRequestNS(v8::Isolate* isolate,
|
||||
content::BrowserContext* browser_context)
|
||||
WebRequest::WebRequest(v8::Isolate* isolate,
|
||||
content::BrowserContext* browser_context)
|
||||
: browser_context_(browser_context) {
|
||||
browser_context_->SetUserData(kUserDataKey, std::make_unique<UserData>(this));
|
||||
}
|
||||
|
||||
WebRequestNS::~WebRequestNS() {
|
||||
WebRequest::~WebRequest() {
|
||||
browser_context_->RemoveUserData(kUserDataKey);
|
||||
}
|
||||
|
||||
gin::ObjectTemplateBuilder WebRequestNS::GetObjectTemplateBuilder(
|
||||
gin::ObjectTemplateBuilder WebRequest::GetObjectTemplateBuilder(
|
||||
v8::Isolate* isolate) {
|
||||
return gin::Wrappable<WebRequestNS>::GetObjectTemplateBuilder(isolate)
|
||||
return gin::Wrappable<WebRequest>::GetObjectTemplateBuilder(isolate)
|
||||
.SetMethod("onBeforeRequest",
|
||||
&WebRequestNS::SetResponseListener<kOnBeforeRequest>)
|
||||
&WebRequest::SetResponseListener<kOnBeforeRequest>)
|
||||
.SetMethod("onBeforeSendHeaders",
|
||||
&WebRequestNS::SetResponseListener<kOnBeforeSendHeaders>)
|
||||
&WebRequest::SetResponseListener<kOnBeforeSendHeaders>)
|
||||
.SetMethod("onHeadersReceived",
|
||||
&WebRequestNS::SetResponseListener<kOnHeadersReceived>)
|
||||
&WebRequest::SetResponseListener<kOnHeadersReceived>)
|
||||
.SetMethod("onSendHeaders",
|
||||
&WebRequestNS::SetSimpleListener<kOnSendHeaders>)
|
||||
&WebRequest::SetSimpleListener<kOnSendHeaders>)
|
||||
.SetMethod("onBeforeRedirect",
|
||||
&WebRequestNS::SetSimpleListener<kOnBeforeRedirect>)
|
||||
&WebRequest::SetSimpleListener<kOnBeforeRedirect>)
|
||||
.SetMethod("onResponseStarted",
|
||||
&WebRequestNS::SetSimpleListener<kOnResponseStarted>)
|
||||
&WebRequest::SetSimpleListener<kOnResponseStarted>)
|
||||
.SetMethod("onErrorOccurred",
|
||||
&WebRequestNS::SetSimpleListener<kOnErrorOccurred>)
|
||||
.SetMethod("onCompleted", &WebRequestNS::SetSimpleListener<kOnCompleted>);
|
||||
&WebRequest::SetSimpleListener<kOnErrorOccurred>)
|
||||
.SetMethod("onCompleted", &WebRequest::SetSimpleListener<kOnCompleted>);
|
||||
}
|
||||
|
||||
const char* WebRequestNS::GetTypeName() {
|
||||
const char* WebRequest::GetTypeName() {
|
||||
return "WebRequest";
|
||||
}
|
||||
|
||||
bool WebRequestNS::HasListener() const {
|
||||
bool WebRequest::HasListener() const {
|
||||
return !(simple_listeners_.empty() && response_listeners_.empty());
|
||||
}
|
||||
|
||||
int WebRequestNS::OnBeforeRequest(extensions::WebRequestInfo* info,
|
||||
const network::ResourceRequest& request,
|
||||
net::CompletionOnceCallback callback,
|
||||
GURL* new_url) {
|
||||
int WebRequest::OnBeforeRequest(extensions::WebRequestInfo* info,
|
||||
const network::ResourceRequest& request,
|
||||
net::CompletionOnceCallback callback,
|
||||
GURL* new_url) {
|
||||
return HandleResponseEvent(kOnBeforeRequest, info, std::move(callback),
|
||||
new_url, request);
|
||||
}
|
||||
|
||||
int WebRequestNS::OnBeforeSendHeaders(extensions::WebRequestInfo* info,
|
||||
const network::ResourceRequest& request,
|
||||
BeforeSendHeadersCallback callback,
|
||||
net::HttpRequestHeaders* headers) {
|
||||
int WebRequest::OnBeforeSendHeaders(extensions::WebRequestInfo* info,
|
||||
const network::ResourceRequest& request,
|
||||
BeforeSendHeadersCallback callback,
|
||||
net::HttpRequestHeaders* headers) {
|
||||
return HandleResponseEvent(
|
||||
kOnBeforeSendHeaders, info,
|
||||
base::BindOnce(std::move(callback), std::set<std::string>(),
|
||||
@@ -285,7 +285,7 @@ int WebRequestNS::OnBeforeSendHeaders(extensions::WebRequestInfo* info,
|
||||
headers, request, *headers);
|
||||
}
|
||||
|
||||
int WebRequestNS::OnHeadersReceived(
|
||||
int WebRequest::OnHeadersReceived(
|
||||
extensions::WebRequestInfo* info,
|
||||
const network::ResourceRequest& request,
|
||||
net::CompletionOnceCallback callback,
|
||||
@@ -299,53 +299,53 @@ int WebRequestNS::OnHeadersReceived(
|
||||
request);
|
||||
}
|
||||
|
||||
void WebRequestNS::OnSendHeaders(extensions::WebRequestInfo* info,
|
||||
const network::ResourceRequest& request,
|
||||
const net::HttpRequestHeaders& headers) {
|
||||
void WebRequest::OnSendHeaders(extensions::WebRequestInfo* info,
|
||||
const network::ResourceRequest& request,
|
||||
const net::HttpRequestHeaders& headers) {
|
||||
HandleSimpleEvent(kOnSendHeaders, info, request, headers);
|
||||
}
|
||||
|
||||
void WebRequestNS::OnBeforeRedirect(extensions::WebRequestInfo* info,
|
||||
const network::ResourceRequest& request,
|
||||
const GURL& new_location) {
|
||||
void WebRequest::OnBeforeRedirect(extensions::WebRequestInfo* info,
|
||||
const network::ResourceRequest& request,
|
||||
const GURL& new_location) {
|
||||
HandleSimpleEvent(kOnBeforeRedirect, info, request, new_location);
|
||||
}
|
||||
|
||||
void WebRequestNS::OnResponseStarted(extensions::WebRequestInfo* info,
|
||||
const network::ResourceRequest& request) {
|
||||
void WebRequest::OnResponseStarted(extensions::WebRequestInfo* info,
|
||||
const network::ResourceRequest& request) {
|
||||
HandleSimpleEvent(kOnResponseStarted, info, request);
|
||||
}
|
||||
|
||||
void WebRequestNS::OnErrorOccurred(extensions::WebRequestInfo* info,
|
||||
const network::ResourceRequest& request,
|
||||
int net_error) {
|
||||
void WebRequest::OnErrorOccurred(extensions::WebRequestInfo* info,
|
||||
const network::ResourceRequest& request,
|
||||
int net_error) {
|
||||
callbacks_.erase(info->id);
|
||||
|
||||
HandleSimpleEvent(kOnErrorOccurred, info, request, net_error);
|
||||
}
|
||||
|
||||
void WebRequestNS::OnCompleted(extensions::WebRequestInfo* info,
|
||||
const network::ResourceRequest& request,
|
||||
int net_error) {
|
||||
void WebRequest::OnCompleted(extensions::WebRequestInfo* info,
|
||||
const network::ResourceRequest& request,
|
||||
int net_error) {
|
||||
callbacks_.erase(info->id);
|
||||
|
||||
HandleSimpleEvent(kOnCompleted, info, request, net_error);
|
||||
}
|
||||
|
||||
template <WebRequestNS::SimpleEvent event>
|
||||
void WebRequestNS::SetSimpleListener(gin::Arguments* args) {
|
||||
template <WebRequest::SimpleEvent event>
|
||||
void WebRequest::SetSimpleListener(gin::Arguments* args) {
|
||||
SetListener<SimpleListener>(event, &simple_listeners_, args);
|
||||
}
|
||||
|
||||
template <WebRequestNS::ResponseEvent event>
|
||||
void WebRequestNS::SetResponseListener(gin::Arguments* args) {
|
||||
template <WebRequest::ResponseEvent event>
|
||||
void WebRequest::SetResponseListener(gin::Arguments* args) {
|
||||
SetListener<ResponseListener>(event, &response_listeners_, args);
|
||||
}
|
||||
|
||||
template <typename Listener, typename Listeners, typename Event>
|
||||
void WebRequestNS::SetListener(Event event,
|
||||
Listeners* listeners,
|
||||
gin::Arguments* args) {
|
||||
void WebRequest::SetListener(Event event,
|
||||
Listeners* listeners,
|
||||
gin::Arguments* args) {
|
||||
v8::Local<v8::Value> arg;
|
||||
|
||||
// { urls }.
|
||||
@@ -393,9 +393,9 @@ void WebRequestNS::SetListener(Event event,
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void WebRequestNS::HandleSimpleEvent(SimpleEvent event,
|
||||
extensions::WebRequestInfo* request_info,
|
||||
Args... args) {
|
||||
void WebRequest::HandleSimpleEvent(SimpleEvent event,
|
||||
extensions::WebRequestInfo* request_info,
|
||||
Args... args) {
|
||||
const auto iter = simple_listeners_.find(event);
|
||||
if (iter == std::end(simple_listeners_))
|
||||
return;
|
||||
@@ -412,11 +412,11 @@ void WebRequestNS::HandleSimpleEvent(SimpleEvent event,
|
||||
}
|
||||
|
||||
template <typename Out, typename... Args>
|
||||
int WebRequestNS::HandleResponseEvent(ResponseEvent event,
|
||||
extensions::WebRequestInfo* request_info,
|
||||
net::CompletionOnceCallback callback,
|
||||
Out out,
|
||||
Args... args) {
|
||||
int WebRequest::HandleResponseEvent(ResponseEvent event,
|
||||
extensions::WebRequestInfo* request_info,
|
||||
net::CompletionOnceCallback callback,
|
||||
Out out,
|
||||
Args... args) {
|
||||
const auto iter = response_listeners_.find(event);
|
||||
if (iter == std::end(response_listeners_))
|
||||
return net::OK;
|
||||
@@ -433,16 +433,16 @@ int WebRequestNS::HandleResponseEvent(ResponseEvent event,
|
||||
FillDetails(&details, request_info, args...);
|
||||
|
||||
ResponseCallback response =
|
||||
base::BindOnce(&WebRequestNS::OnListenerResult<Out>,
|
||||
base::Unretained(this), request_info->id, out);
|
||||
base::BindOnce(&WebRequest::OnListenerResult<Out>, base::Unretained(this),
|
||||
request_info->id, out);
|
||||
info.listener.Run(gin::ConvertToV8(isolate, details), std::move(response));
|
||||
return net::ERR_IO_PENDING;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void WebRequestNS::OnListenerResult(uint64_t id,
|
||||
T out,
|
||||
v8::Local<v8::Value> response) {
|
||||
void WebRequest::OnListenerResult(uint64_t id,
|
||||
T out,
|
||||
v8::Local<v8::Value> response) {
|
||||
const auto iter = callbacks_.find(id);
|
||||
if (iter == std::end(callbacks_))
|
||||
return;
|
||||
@@ -468,10 +468,10 @@ void WebRequestNS::OnListenerResult(uint64_t id,
|
||||
}
|
||||
|
||||
// static
|
||||
gin::Handle<WebRequestNS> WebRequestNS::FromOrCreate(
|
||||
gin::Handle<WebRequest> WebRequest::FromOrCreate(
|
||||
v8::Isolate* isolate,
|
||||
content::BrowserContext* browser_context) {
|
||||
gin::Handle<WebRequestNS> handle = From(isolate, browser_context);
|
||||
gin::Handle<WebRequest> handle = From(isolate, browser_context);
|
||||
if (handle.IsEmpty()) {
|
||||
// Make sure the |Session| object has the |webRequest| property created.
|
||||
v8::Local<v8::Value> web_request =
|
||||
@@ -485,24 +485,24 @@ gin::Handle<WebRequestNS> WebRequestNS::FromOrCreate(
|
||||
}
|
||||
|
||||
// static
|
||||
gin::Handle<WebRequestNS> WebRequestNS::Create(
|
||||
gin::Handle<WebRequest> WebRequest::Create(
|
||||
v8::Isolate* isolate,
|
||||
content::BrowserContext* browser_context) {
|
||||
DCHECK(From(isolate, browser_context).IsEmpty())
|
||||
<< "WebRequestNS already created";
|
||||
return gin::CreateHandle(isolate, new WebRequestNS(isolate, browser_context));
|
||||
<< "WebRequest already created";
|
||||
return gin::CreateHandle(isolate, new WebRequest(isolate, browser_context));
|
||||
}
|
||||
|
||||
// static
|
||||
gin::Handle<WebRequestNS> WebRequestNS::From(
|
||||
gin::Handle<WebRequest> WebRequest::From(
|
||||
v8::Isolate* isolate,
|
||||
content::BrowserContext* browser_context) {
|
||||
if (!browser_context)
|
||||
return gin::Handle<WebRequestNS>();
|
||||
return gin::Handle<WebRequest>();
|
||||
auto* user_data =
|
||||
static_cast<UserData*>(browser_context->GetUserData(kUserDataKey));
|
||||
if (!user_data)
|
||||
return gin::Handle<WebRequestNS>();
|
||||
return gin::Handle<WebRequest>();
|
||||
return gin::CreateHandle(isolate, user_data->data);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_BROWSER_API_ATOM_API_WEB_REQUEST_NS_H_
|
||||
#define SHELL_BROWSER_API_ATOM_API_WEB_REQUEST_NS_H_
|
||||
#ifndef SHELL_BROWSER_API_ATOM_API_WEB_REQUEST_H_
|
||||
#define SHELL_BROWSER_API_ATOM_API_WEB_REQUEST_H_
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
@@ -23,7 +23,7 @@ namespace electron {
|
||||
|
||||
namespace api {
|
||||
|
||||
class WebRequestNS : public gin::Wrappable<WebRequestNS>, public WebRequestAPI {
|
||||
class WebRequest : public gin::Wrappable<WebRequest>, public WebRequestAPI {
|
||||
public:
|
||||
static gin::WrapperInfo kWrapperInfo;
|
||||
|
||||
@@ -31,19 +31,18 @@ class WebRequestNS : public gin::Wrappable<WebRequestNS>, public WebRequestAPI {
|
||||
// is no one.
|
||||
// Note that the lifetime of WebRequest object is managed by Session, instead
|
||||
// of the caller.
|
||||
static gin::Handle<WebRequestNS> FromOrCreate(
|
||||
static gin::Handle<WebRequest> FromOrCreate(
|
||||
v8::Isolate* isolate,
|
||||
content::BrowserContext* browser_context);
|
||||
|
||||
// Return a new WebRequest object, this should only be called by Session.
|
||||
static gin::Handle<WebRequestNS> Create(
|
||||
static gin::Handle<WebRequest> Create(
|
||||
v8::Isolate* isolate,
|
||||
content::BrowserContext* browser_context);
|
||||
|
||||
// Find the WebRequest object attached to |browser_context|.
|
||||
static gin::Handle<WebRequestNS> From(
|
||||
v8::Isolate* isolate,
|
||||
content::BrowserContext* browser_context);
|
||||
static gin::Handle<WebRequest> From(v8::Isolate* isolate,
|
||||
content::BrowserContext* browser_context);
|
||||
|
||||
// gin::Wrappable:
|
||||
gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
|
||||
@@ -51,8 +50,8 @@ class WebRequestNS : public gin::Wrappable<WebRequestNS>, public WebRequestAPI {
|
||||
const char* GetTypeName() override;
|
||||
|
||||
private:
|
||||
WebRequestNS(v8::Isolate* isolate, content::BrowserContext* browser_context);
|
||||
~WebRequestNS() override;
|
||||
WebRequest(v8::Isolate* isolate, content::BrowserContext* browser_context);
|
||||
~WebRequest() override;
|
||||
|
||||
// WebRequestAPI:
|
||||
bool HasListener() const override;
|
||||
@@ -155,4 +154,4 @@ class WebRequestNS : public gin::Wrappable<WebRequestNS>, public WebRequestAPI {
|
||||
|
||||
} // namespace electron
|
||||
|
||||
#endif // SHELL_BROWSER_API_ATOM_API_WEB_REQUEST_NS_H_
|
||||
#endif // SHELL_BROWSER_API_ATOM_API_WEB_REQUEST_H_
|
||||
@@ -3,12 +3,12 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "shell/browser/web_contents_preferences.h"
|
||||
#include "shell/browser/web_contents_zoom_controller.h"
|
||||
#include "shell/browser/web_view_manager.h"
|
||||
#include "shell/common/native_mate_converters/content_converter.h"
|
||||
#include "shell/common/native_mate_converters/value_converter.h"
|
||||
#include "shell/common/gin_converters/content_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "shell/common/options_switches.h"
|
||||
|
||||
@@ -45,7 +45,7 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
gin_helper::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("addGuest", &AddGuest);
|
||||
dict.SetMethod("removeGuest", &RemoveGuest);
|
||||
}
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
// Copyright (c) 2014 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/api/event_emitter_deprecated.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "native_mate/arguments.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder_deprecated.h"
|
||||
#include "shell/browser/api/event.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "ui/events/event_constants.h"
|
||||
|
||||
namespace mate {
|
||||
|
||||
namespace {
|
||||
|
||||
v8::Persistent<v8::ObjectTemplate> event_template;
|
||||
|
||||
void PreventDefault(mate::Arguments* args) {
|
||||
mate::Dictionary self(args->isolate(), args->GetThis());
|
||||
self.Set("defaultPrevented", true);
|
||||
}
|
||||
|
||||
// Create a pure JavaScript Event object.
|
||||
v8::Local<v8::Object> CreateEventObject(v8::Isolate* isolate) {
|
||||
if (event_template.IsEmpty()) {
|
||||
event_template.Reset(
|
||||
isolate,
|
||||
ObjectTemplateBuilder(isolate, v8::ObjectTemplate::New(isolate))
|
||||
.SetMethod("preventDefault", &PreventDefault)
|
||||
.Build());
|
||||
}
|
||||
|
||||
return v8::Local<v8::ObjectTemplate>::New(isolate, event_template)
|
||||
->NewInstance(isolate->GetCurrentContext())
|
||||
.ToLocalChecked();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace internal {
|
||||
|
||||
v8::Local<v8::Object> CreateJSEvent(
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> object,
|
||||
content::RenderFrameHost* sender,
|
||||
base::Optional<electron::mojom::ElectronBrowser::MessageSyncCallback>
|
||||
callback) {
|
||||
v8::Local<v8::Object> event;
|
||||
bool use_native_event = sender && callback;
|
||||
|
||||
if (use_native_event) {
|
||||
mate::Handle<mate::Event> native_event = mate::Event::Create(isolate);
|
||||
native_event->SetCallback(std::move(callback));
|
||||
event = v8::Local<v8::Object>::Cast(native_event.ToV8());
|
||||
} else {
|
||||
event = CreateEventObject(isolate);
|
||||
}
|
||||
mate::Dictionary dict(isolate, event);
|
||||
dict.Set("sender", object);
|
||||
if (sender)
|
||||
dict.Set("frameId", sender->GetRoutingID());
|
||||
return event;
|
||||
}
|
||||
|
||||
v8::Local<v8::Object> CreateEmptyJSEvent(v8::Isolate* isolate) {
|
||||
mate::Handle<mate::Event> native_event = mate::Event::Create(isolate);
|
||||
v8::Local<v8::Object> event =
|
||||
v8::Local<v8::Object>::Cast(native_event.ToV8());
|
||||
return event;
|
||||
}
|
||||
|
||||
v8::Local<v8::Object> CreateCustomEvent(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> object,
|
||||
v8::Local<v8::Object> custom_event) {
|
||||
v8::Local<v8::Object> event = CreateEventObject(isolate);
|
||||
(void)event->SetPrototype(custom_event->CreationContext(), custom_event);
|
||||
mate::Dictionary(isolate, event).Set("sender", object);
|
||||
return event;
|
||||
}
|
||||
|
||||
v8::Local<v8::Object> CreateEventFromFlags(v8::Isolate* isolate, int flags) {
|
||||
const int mouse_button_flags =
|
||||
(ui::EF_RIGHT_MOUSE_BUTTON | ui::EF_LEFT_MOUSE_BUTTON |
|
||||
ui::EF_MIDDLE_MOUSE_BUTTON | ui::EF_BACK_MOUSE_BUTTON |
|
||||
ui::EF_FORWARD_MOUSE_BUTTON);
|
||||
const int is_mouse_click = static_cast<bool>(flags & mouse_button_flags);
|
||||
mate::Dictionary obj = mate::Dictionary::CreateEmpty(isolate);
|
||||
obj.Set("shiftKey", static_cast<bool>(flags & ui::EF_SHIFT_DOWN));
|
||||
obj.Set("ctrlKey", static_cast<bool>(flags & ui::EF_CONTROL_DOWN));
|
||||
obj.Set("altKey", static_cast<bool>(flags & ui::EF_ALT_DOWN));
|
||||
obj.Set("metaKey", static_cast<bool>(flags & ui::EF_COMMAND_DOWN));
|
||||
obj.Set("triggeredByAccelerator", !is_mouse_click);
|
||||
return obj.GetHandle();
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
} // namespace mate
|
||||
@@ -1,129 +0,0 @@
|
||||
// Copyright (c) 2014 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_BROWSER_API_EVENT_EMITTER_DEPRECATED_H_
|
||||
#define SHELL_BROWSER_API_EVENT_EMITTER_DEPRECATED_H_
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "base/optional.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "electron/shell/common/api/api.mojom.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
#include "shell/common/api/event_emitter_caller_deprecated.h"
|
||||
|
||||
namespace content {
|
||||
class RenderFrameHost;
|
||||
}
|
||||
|
||||
namespace mate {
|
||||
|
||||
namespace internal {
|
||||
|
||||
v8::Local<v8::Object> CreateJSEvent(
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> object,
|
||||
content::RenderFrameHost* sender,
|
||||
base::Optional<electron::mojom::ElectronBrowser::MessageSyncCallback>
|
||||
callback);
|
||||
v8::Local<v8::Object> CreateEmptyJSEvent(v8::Isolate* isolate);
|
||||
v8::Local<v8::Object> CreateCustomEvent(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> object,
|
||||
v8::Local<v8::Object> event);
|
||||
v8::Local<v8::Object> CreateEventFromFlags(v8::Isolate* isolate, int flags);
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// Provide helperers to emit event in JavaScript.
|
||||
template <typename T>
|
||||
class EventEmitter : public Wrappable<T> {
|
||||
public:
|
||||
typedef std::vector<v8::Local<v8::Value>> ValueArray;
|
||||
|
||||
// Make the convinient methods visible:
|
||||
// https://isocpp.org/wiki/faq/templates#nondependent-name-lookup-members
|
||||
v8::Isolate* isolate() const { return Wrappable<T>::isolate(); }
|
||||
v8::Local<v8::Object> GetWrapper() const {
|
||||
return Wrappable<T>::GetWrapper();
|
||||
}
|
||||
v8::MaybeLocal<v8::Object> GetWrapper(v8::Isolate* isolate) const {
|
||||
return Wrappable<T>::GetWrapper(isolate);
|
||||
}
|
||||
|
||||
// this.emit(name, event, args...);
|
||||
template <typename... Args>
|
||||
bool EmitCustomEvent(base::StringPiece name,
|
||||
v8::Local<v8::Object> event,
|
||||
Args&&... args) {
|
||||
return EmitWithEvent(
|
||||
name, internal::CreateCustomEvent(isolate(), GetWrapper(), event),
|
||||
std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// this.emit(name, new Event(flags), args...);
|
||||
template <typename... Args>
|
||||
bool EmitWithFlags(base::StringPiece name, int flags, Args&&... args) {
|
||||
return EmitCustomEvent(name,
|
||||
internal::CreateEventFromFlags(isolate(), flags),
|
||||
std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// this.emit(name, new Event(), args...);
|
||||
template <typename... Args>
|
||||
bool Emit(base::StringPiece name, Args&&... args) {
|
||||
return EmitWithSender(name, nullptr, base::nullopt,
|
||||
std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// this.emit(name, new Event(sender, message), args...);
|
||||
template <typename... Args>
|
||||
bool EmitWithSender(
|
||||
base::StringPiece name,
|
||||
content::RenderFrameHost* sender,
|
||||
base::Optional<electron::mojom::ElectronBrowser::InvokeCallback> callback,
|
||||
Args&&... args) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
v8::Local<v8::Object> wrapper = GetWrapper();
|
||||
if (wrapper.IsEmpty()) {
|
||||
return false;
|
||||
}
|
||||
v8::Local<v8::Object> event = internal::CreateJSEvent(
|
||||
isolate(), wrapper, sender, std::move(callback));
|
||||
return EmitWithEvent(name, event, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
protected:
|
||||
EventEmitter() {}
|
||||
|
||||
private:
|
||||
// this.emit(name, event, args...);
|
||||
template <typename... Args>
|
||||
bool EmitWithEvent(base::StringPiece name,
|
||||
v8::Local<v8::Object> event,
|
||||
Args&&... args) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
// It's possible that |this| will be deleted by EmitEvent, so save anything
|
||||
// we need from |this| before calling EmitEvent.
|
||||
auto* isolate = this->isolate();
|
||||
v8::Locker locker(isolate);
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
auto context = isolate->GetCurrentContext();
|
||||
EmitEvent(isolate, GetWrapper(), name, event, std::forward<Args>(args)...);
|
||||
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);
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
#endif // SHELL_BROWSER_API_EVENT_EMITTER_DEPRECATED_H_
|
||||
@@ -7,14 +7,14 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "shell/browser/api/trackable_object.h"
|
||||
#include "shell/common/gin_helper/trackable_object.h"
|
||||
#include "ui/views/layout/layout_manager.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
namespace api {
|
||||
|
||||
class LayoutManager : public mate::TrackableObject<LayoutManager> {
|
||||
class LayoutManager : public gin_helper::TrackableObject<LayoutManager> {
|
||||
public:
|
||||
static mate::WrappableBase* New(mate::Arguments* args);
|
||||
|
||||
|
||||
@@ -50,10 +50,10 @@
|
||||
#include "services/network/public/cpp/resource_request_body.h"
|
||||
#include "shell/app/manifests.h"
|
||||
#include "shell/browser/api/atom_api_app.h"
|
||||
#include "shell/browser/api/atom_api_protocol_ns.h"
|
||||
#include "shell/browser/api/atom_api_protocol.h"
|
||||
#include "shell/browser/api/atom_api_session.h"
|
||||
#include "shell/browser/api/atom_api_web_contents.h"
|
||||
#include "shell/browser/api/atom_api_web_request_ns.h"
|
||||
#include "shell/browser/api/atom_api_web_request.h"
|
||||
#include "shell/browser/atom_autofill_driver_factory.h"
|
||||
#include "shell/browser/atom_browser_context.h"
|
||||
#include "shell/browser/atom_browser_main_parts.h"
|
||||
@@ -956,7 +956,7 @@ void AtomBrowserClient::RegisterNonNetworkNavigationURLLoaderFactories(
|
||||
NonNetworkURLLoaderFactoryMap* factories) {
|
||||
content::WebContents* web_contents =
|
||||
content::WebContents::FromFrameTreeNodeId(frame_tree_node_id);
|
||||
api::ProtocolNS* protocol = api::ProtocolNS::FromWrappedClass(
|
||||
api::Protocol* protocol = api::Protocol::FromWrappedClass(
|
||||
v8::Isolate::GetCurrent(), web_contents->GetBrowserContext());
|
||||
if (protocol)
|
||||
protocol->RegisterURLLoaderFactories(factories);
|
||||
@@ -972,7 +972,7 @@ void AtomBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
|
||||
content::WebContents* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(frame_host);
|
||||
if (web_contents) {
|
||||
api::ProtocolNS* protocol = api::ProtocolNS::FromWrappedClass(
|
||||
api::Protocol* protocol = api::Protocol::FromWrappedClass(
|
||||
v8::Isolate::GetCurrent(), web_contents->GetBrowserContext());
|
||||
if (protocol)
|
||||
protocol->RegisterURLLoaderFactories(factories);
|
||||
@@ -990,10 +990,10 @@ bool AtomBrowserClient::WillCreateURLLoaderFactory(
|
||||
header_client,
|
||||
bool* bypass_redirect_checks) {
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
api::ProtocolNS* protocol =
|
||||
api::ProtocolNS::FromWrappedClass(isolate, browser_context);
|
||||
api::Protocol* protocol =
|
||||
api::Protocol::FromWrappedClass(isolate, browser_context);
|
||||
DCHECK(protocol);
|
||||
auto web_request = api::WebRequestNS::FromOrCreate(isolate, browser_context);
|
||||
auto web_request = api::WebRequest::FromOrCreate(isolate, browser_context);
|
||||
DCHECK(web_request.get());
|
||||
|
||||
auto proxied_receiver = std::move(*factory_receiver);
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include "services/service_manager/public/cpp/connector.h"
|
||||
#include "shell/app/atom_main_delegate.h"
|
||||
#include "shell/browser/api/atom_api_app.h"
|
||||
#include "shell/browser/api/trackable_object.h"
|
||||
#include "shell/browser/atom_browser_client.h"
|
||||
#include "shell/browser/atom_browser_context.h"
|
||||
#include "shell/browser/atom_paths.h"
|
||||
@@ -49,6 +48,7 @@
|
||||
#include "shell/common/api/electron_bindings.h"
|
||||
#include "shell/common/application_info.h"
|
||||
#include "shell/common/asar/asar_util.h"
|
||||
#include "shell/common/gin_helper/trackable_object.h"
|
||||
#include "shell/common/node_bindings.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "ui/base/idle/idle.h"
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "shell/browser/native_window.h"
|
||||
#include "shell/browser/window_list.h"
|
||||
#include "shell/common/application_info.h"
|
||||
#include "shell/common/gin_helper/arguments.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
@@ -57,7 +58,7 @@ void Browser::Quit() {
|
||||
electron::WindowList::CloseAllWindows();
|
||||
}
|
||||
|
||||
void Browser::Exit(mate::Arguments* args) {
|
||||
void Browser::Exit(gin_helper::Arguments* args) {
|
||||
int code = 0;
|
||||
args->GetNext(&code);
|
||||
|
||||
@@ -165,14 +166,14 @@ void Browser::DidFinishLaunching(const base::DictionaryValue& launch_info) {
|
||||
observer.OnFinishLaunching(launch_info);
|
||||
}
|
||||
|
||||
const util::Promise<void*>& Browser::WhenReady(v8::Isolate* isolate) {
|
||||
v8::Local<v8::Value> Browser::WhenReady(v8::Isolate* isolate) {
|
||||
if (!ready_promise_) {
|
||||
ready_promise_ = std::make_unique<util::Promise<void*>>(isolate);
|
||||
if (is_ready()) {
|
||||
ready_promise_->Resolve();
|
||||
}
|
||||
}
|
||||
return *ready_promise_;
|
||||
return ready_promise_->GetHandle();
|
||||
}
|
||||
|
||||
void Browser::OnAccessibilitySupportChanged() {
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include "base/observer_list.h"
|
||||
#include "base/strings/string16.h"
|
||||
#include "base/values.h"
|
||||
#include "native_mate/arguments.h"
|
||||
#include "shell/browser/browser_observer.h"
|
||||
#include "shell/browser/window_list_observer.h"
|
||||
#include "shell/common/promise_util.h"
|
||||
@@ -32,6 +31,10 @@ namespace gfx {
|
||||
class Image;
|
||||
}
|
||||
|
||||
namespace gin_helper {
|
||||
class Arguments;
|
||||
}
|
||||
|
||||
namespace electron {
|
||||
|
||||
class AtomMenuModel;
|
||||
@@ -48,7 +51,7 @@ class Browser : public WindowListObserver {
|
||||
void Quit();
|
||||
|
||||
// Exit the application immediately and set exit code.
|
||||
void Exit(mate::Arguments* args);
|
||||
void Exit(gin_helper::Arguments* args);
|
||||
|
||||
// Cleanup everything and shutdown the application gracefully.
|
||||
void Shutdown();
|
||||
@@ -79,15 +82,15 @@ class Browser : public WindowListObserver {
|
||||
|
||||
// Remove the default protocol handler registry key
|
||||
bool RemoveAsDefaultProtocolClient(const std::string& protocol,
|
||||
mate::Arguments* args);
|
||||
gin_helper::Arguments* args);
|
||||
|
||||
// Set as default handler for a protocol.
|
||||
bool SetAsDefaultProtocolClient(const std::string& protocol,
|
||||
mate::Arguments* args);
|
||||
gin_helper::Arguments* args);
|
||||
|
||||
// Query the current state of default handler for a protocol.
|
||||
bool IsDefaultProtocolClient(const std::string& protocol,
|
||||
mate::Arguments* args);
|
||||
gin_helper::Arguments* args);
|
||||
|
||||
// Set/Get the badge count.
|
||||
bool SetBadgeCount(int count);
|
||||
@@ -123,7 +126,7 @@ class Browser : public WindowListObserver {
|
||||
// Creates an activity and sets it as the one currently in use.
|
||||
void SetUserActivity(const std::string& type,
|
||||
const base::DictionaryValue& user_info,
|
||||
mate::Arguments* args);
|
||||
gin_helper::Arguments* args);
|
||||
|
||||
// Returns the type name of the current user activity.
|
||||
std::string GetCurrentActivityType();
|
||||
@@ -262,7 +265,7 @@ class Browser : public WindowListObserver {
|
||||
bool is_shutting_down() const { return is_shutdown_; }
|
||||
bool is_quiting() const { return is_quiting_; }
|
||||
bool is_ready() const { return is_ready_; }
|
||||
const util::Promise<void*>& WhenReady(v8::Isolate* isolate);
|
||||
v8::Local<v8::Value> WhenReady(v8::Isolate* isolate);
|
||||
|
||||
protected:
|
||||
// Returns the version of application bundle or executable file.
|
||||
|
||||
@@ -76,12 +76,12 @@ void Browser::ClearRecentDocuments() {}
|
||||
void Browser::SetAppUserModelID(const base::string16& name) {}
|
||||
|
||||
bool Browser::SetAsDefaultProtocolClient(const std::string& protocol,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
return SetDefaultWebClient(protocol);
|
||||
}
|
||||
|
||||
bool Browser::IsDefaultProtocolClient(const std::string& protocol,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
std::unique_ptr<base::Environment> env(base::Environment::Create());
|
||||
|
||||
if (protocol.empty())
|
||||
@@ -109,7 +109,7 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol,
|
||||
|
||||
// Todo implement
|
||||
bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "shell/browser/native_window.h"
|
||||
#include "shell/browser/window_list.h"
|
||||
#include "shell/common/application_info.h"
|
||||
#include "shell/common/gin_helper/arguments.h"
|
||||
#include "shell/common/platform_util.h"
|
||||
#include "shell/common/promise_util.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
@@ -58,7 +59,7 @@ void Browser::ClearRecentDocuments() {
|
||||
}
|
||||
|
||||
bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
NSString* identifier = [base::mac::MainBundle() bundleIdentifier];
|
||||
if (!identifier)
|
||||
return false;
|
||||
@@ -93,7 +94,7 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
|
||||
}
|
||||
|
||||
bool Browser::SetAsDefaultProtocolClient(const std::string& protocol,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
if (protocol.empty())
|
||||
return false;
|
||||
|
||||
@@ -108,7 +109,7 @@ bool Browser::SetAsDefaultProtocolClient(const std::string& protocol,
|
||||
}
|
||||
|
||||
bool Browser::IsDefaultProtocolClient(const std::string& protocol,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
if (protocol.empty())
|
||||
return false;
|
||||
|
||||
@@ -141,7 +142,7 @@ bool Browser::SetBadgeCount(int count) {
|
||||
|
||||
void Browser::SetUserActivity(const std::string& type,
|
||||
const base::DictionaryValue& user_info,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
std::string url_string;
|
||||
args->GetNext(&url_string);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "shell/browser/ui/message_box.h"
|
||||
#include "shell/browser/ui/win/jump_list.h"
|
||||
#include "shell/common/application_info.h"
|
||||
#include "shell/common/native_mate_converters/string16_converter.h"
|
||||
#include "shell/common/gin_helper/arguments.h"
|
||||
#include "shell/common/skia_util.h"
|
||||
#include "ui/events/keycodes/keyboard_code_conversion_win.h"
|
||||
|
||||
@@ -56,7 +56,7 @@ bool GetProcessExecPath(base::string16* exe) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetProtocolLaunchPath(mate::Arguments* args, base::string16* exe) {
|
||||
bool GetProtocolLaunchPath(gin_helper::Arguments* args, base::string16* exe) {
|
||||
if (!args->GetNext(exe) && !GetProcessExecPath(exe)) {
|
||||
return false;
|
||||
}
|
||||
@@ -153,7 +153,7 @@ bool Browser::SetUserTasks(const std::vector<UserTask>& tasks) {
|
||||
}
|
||||
|
||||
bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
if (protocol.empty())
|
||||
return false;
|
||||
|
||||
@@ -215,7 +215,7 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
|
||||
}
|
||||
|
||||
bool Browser::SetAsDefaultProtocolClient(const std::string& protocol,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
// HKEY_CLASSES_ROOT
|
||||
// $PROTOCOL
|
||||
// (Default) = "URL:$NAME"
|
||||
@@ -259,7 +259,7 @@ bool Browser::SetAsDefaultProtocolClient(const std::string& protocol,
|
||||
}
|
||||
|
||||
bool Browser::IsDefaultProtocolClient(const std::string& protocol,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
if (protocol.empty())
|
||||
return false;
|
||||
|
||||
|
||||
@@ -3,25 +3,25 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/lib/bluetooth_chooser.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "shell/common/native_mate_converters/once_callback.h"
|
||||
#include "shell/common/native_mate_converters/string16_converter.h"
|
||||
|
||||
namespace mate {
|
||||
#include "shell/common/gin_converters/callback_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
|
||||
namespace gin {
|
||||
|
||||
template <>
|
||||
struct Converter<electron::BluetoothChooser::DeviceInfo> {
|
||||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const electron::BluetoothChooser::DeviceInfo& val) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("deviceName", val.device_name);
|
||||
dict.Set("deviceId", val.device_id);
|
||||
return mate::ConvertToV8(isolate, dict);
|
||||
return gin::ConvertToV8(isolate, dict);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
} // namespace gin
|
||||
|
||||
namespace electron {
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "shell/browser/browser.h"
|
||||
#include "shell/browser/window_list.h"
|
||||
#include "shell/common/color_util.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/options_switches.h"
|
||||
#include "ui/views/widget/widget.h"
|
||||
|
||||
@@ -45,7 +45,7 @@ gfx::Size GetExpandedWindowSize(const NativeWindow* window, gfx::Size size) {
|
||||
|
||||
} // namespace
|
||||
|
||||
NativeWindow::NativeWindow(const mate::Dictionary& options,
|
||||
NativeWindow::NativeWindow(const gin_helper::Dictionary& options,
|
||||
NativeWindow* parent)
|
||||
: widget_(new views::Widget), parent_(parent), weak_factory_(this) {
|
||||
options.Get(options::kFrame, &has_frame_);
|
||||
@@ -67,7 +67,7 @@ NativeWindow::~NativeWindow() {
|
||||
NotifyWindowClosed();
|
||||
}
|
||||
|
||||
void NativeWindow::InitFromOptions(const mate::Dictionary& options) {
|
||||
void NativeWindow::InitFromOptions(const gin_helper::Dictionary& options) {
|
||||
// Setup window from options.
|
||||
int x = -1, y = -1;
|
||||
bool center;
|
||||
|
||||
@@ -37,10 +37,13 @@ class RectF;
|
||||
class Size;
|
||||
} // namespace gfx
|
||||
|
||||
namespace mate {
|
||||
namespace gin_helper {
|
||||
class Dictionary;
|
||||
}
|
||||
|
||||
namespace mate {
|
||||
class PersistentDictionary;
|
||||
} // namespace mate
|
||||
}
|
||||
|
||||
namespace electron {
|
||||
|
||||
@@ -60,10 +63,10 @@ class NativeWindow : public base::SupportsUserData,
|
||||
|
||||
// Create window with existing WebContents, the caller is responsible for
|
||||
// managing the window's live.
|
||||
static NativeWindow* Create(const mate::Dictionary& options,
|
||||
static NativeWindow* Create(const gin_helper::Dictionary& options,
|
||||
NativeWindow* parent = nullptr);
|
||||
|
||||
void InitFromOptions(const mate::Dictionary& options);
|
||||
void InitFromOptions(const gin_helper::Dictionary& options);
|
||||
|
||||
virtual void SetContentView(views::View* view) = 0;
|
||||
|
||||
@@ -304,7 +307,7 @@ class NativeWindow : public base::SupportsUserData,
|
||||
std::list<NativeBrowserView*> browser_views() const { return browser_views_; }
|
||||
|
||||
protected:
|
||||
NativeWindow(const mate::Dictionary& options, NativeWindow* parent);
|
||||
NativeWindow(const gin_helper::Dictionary& options, NativeWindow* parent);
|
||||
|
||||
// views::WidgetDelegate:
|
||||
views::Widget* GetWidget() override;
|
||||
|
||||
@@ -28,7 +28,7 @@ class RootViewMac;
|
||||
|
||||
class NativeWindowMac : public NativeWindow {
|
||||
public:
|
||||
NativeWindowMac(const mate::Dictionary& options, NativeWindow* parent);
|
||||
NativeWindowMac(const gin_helper::Dictionary& options, NativeWindow* parent);
|
||||
~NativeWindowMac() override;
|
||||
|
||||
// NativeWindow:
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h"
|
||||
#include "content/public/browser/browser_accessibility_state.h"
|
||||
#include "content/public/browser/desktop_media_id.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "shell/browser/native_browser_view_mac.h"
|
||||
#include "shell/browser/ui/cocoa/atom_native_widget_mac.h"
|
||||
#include "shell/browser/ui/cocoa/atom_ns_window.h"
|
||||
@@ -29,6 +28,7 @@
|
||||
#include "shell/browser/ui/inspectable_web_contents_view.h"
|
||||
#include "shell/browser/window_list.h"
|
||||
#include "shell/common/deprecate_util.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/options_switches.h"
|
||||
#include "skia/ext/skia_utils_mac.h"
|
||||
#include "third_party/webrtc/modules/desktop_capture/mac/window_list_utils.h"
|
||||
@@ -244,7 +244,7 @@
|
||||
|
||||
@end
|
||||
|
||||
namespace mate {
|
||||
namespace gin {
|
||||
|
||||
template <>
|
||||
struct Converter<electron::NativeWindowMac::TitleBarStyle> {
|
||||
@@ -268,7 +268,7 @@ struct Converter<electron::NativeWindowMac::TitleBarStyle> {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
} // namespace gin
|
||||
|
||||
namespace electron {
|
||||
|
||||
@@ -318,7 +318,7 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
|
||||
|
||||
} // namespace
|
||||
|
||||
NativeWindowMac::NativeWindowMac(const mate::Dictionary& options,
|
||||
NativeWindowMac::NativeWindowMac(const gin_helper::Dictionary& options,
|
||||
NativeWindow* parent)
|
||||
: NativeWindow(options, parent), root_view_(new RootViewMac(this)) {
|
||||
int width = 800, height = 600;
|
||||
@@ -1659,7 +1659,7 @@ void NativeWindowMac::SetCollectionBehavior(bool on, NSUInteger flag) {
|
||||
}
|
||||
|
||||
// static
|
||||
NativeWindow* NativeWindow::Create(const mate::Dictionary& options,
|
||||
NativeWindow* NativeWindow::Create(const gin_helper::Dictionary& options,
|
||||
NativeWindow* parent) {
|
||||
return new NativeWindowMac(options, parent);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/desktop_media_id.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "shell/browser/api/atom_api_web_contents.h"
|
||||
#include "shell/browser/native_browser_view_views.h"
|
||||
#include "shell/browser/ui/inspectable_web_contents.h"
|
||||
@@ -28,7 +27,8 @@
|
||||
#include "shell/browser/web_view_manager.h"
|
||||
#include "shell/browser/window_list.h"
|
||||
#include "shell/common/atom_constants.h"
|
||||
#include "shell/common/native_mate_converters/image_converter.h"
|
||||
#include "shell/common/gin_converters/image_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/options_switches.h"
|
||||
#include "ui/aura/window_tree_host.h"
|
||||
#include "ui/base/hit_test.h"
|
||||
@@ -126,7 +126,7 @@ class NativeWindowClientView : public views::ClientView {
|
||||
|
||||
} // namespace
|
||||
|
||||
NativeWindowViews::NativeWindowViews(const mate::Dictionary& options,
|
||||
NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options,
|
||||
NativeWindow* parent)
|
||||
: NativeWindow(options, parent),
|
||||
root_view_(new RootView(this)),
|
||||
@@ -1204,11 +1204,13 @@ gfx::Rect NativeWindowViews::ContentBoundsToWindowBounds(
|
||||
|
||||
gfx::Rect window_bounds(bounds);
|
||||
#if defined(OS_WIN)
|
||||
HWND hwnd = GetAcceleratedWidget();
|
||||
gfx::Rect dpi_bounds = DIPToScreenRect(hwnd, bounds);
|
||||
window_bounds = ScreenToDIPRect(
|
||||
hwnd,
|
||||
widget()->non_client_view()->GetWindowBoundsForClientBounds(dpi_bounds));
|
||||
if (widget()->non_client_view()) {
|
||||
HWND hwnd = GetAcceleratedWidget();
|
||||
gfx::Rect dpi_bounds = DIPToScreenRect(hwnd, bounds);
|
||||
window_bounds = ScreenToDIPRect(
|
||||
hwnd, widget()->non_client_view()->GetWindowBoundsForClientBounds(
|
||||
dpi_bounds));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (root_view_->HasMenu() && root_view_->IsMenuBarVisible()) {
|
||||
@@ -1452,7 +1454,7 @@ void NativeWindowViews::MoveBehindTaskBarIfNeeded() {
|
||||
}
|
||||
|
||||
// static
|
||||
NativeWindow* NativeWindow::Create(const mate::Dictionary& options,
|
||||
NativeWindow* NativeWindow::Create(const gin_helper::Dictionary& options,
|
||||
NativeWindow* parent) {
|
||||
return new NativeWindowViews(options, parent);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,8 @@ class NativeWindowViews : public NativeWindow,
|
||||
public views::WidgetObserver,
|
||||
public ui::EventHandler {
|
||||
public:
|
||||
NativeWindowViews(const mate::Dictionary& options, NativeWindow* parent);
|
||||
NativeWindowViews(const gin_helper::Dictionary& options,
|
||||
NativeWindow* parent);
|
||||
~NativeWindowViews() override;
|
||||
|
||||
// NativeWindow:
|
||||
|
||||
@@ -356,14 +356,18 @@ bool NativeWindowViews::PreHandleMSG(UINT message,
|
||||
display::Screen::GetScreen()->GetDisplayNearestPoint(
|
||||
last_normal_placement_bounds_.origin());
|
||||
|
||||
const gfx::Size widget_min_size = widget()->GetMinimumSize();
|
||||
const gfx::Size widget_max_size = widget()->GetMaximumSize();
|
||||
gfx::Size min_size = gfx::ScaleToCeiledSize(
|
||||
widget()->GetMinimumSize(), display.device_scale_factor());
|
||||
ContentBoundsToWindowBounds(gfx::Rect(widget_min_size)).size(),
|
||||
display.device_scale_factor());
|
||||
gfx::Size max_size = gfx::ScaleToCeiledSize(
|
||||
widget()->GetMaximumSize(), display.device_scale_factor());
|
||||
ContentBoundsToWindowBounds(gfx::Rect(widget_max_size)).size(),
|
||||
display.device_scale_factor());
|
||||
|
||||
info->ptMinTrackSize.x = min_size.width();
|
||||
info->ptMinTrackSize.y = min_size.height();
|
||||
if (max_size.width() || max_size.height()) {
|
||||
if (widget_max_size.width() || widget_max_size.height()) {
|
||||
if (!max_size.width())
|
||||
max_size.set_width(GetSystemMetrics(SM_CXMAXTRACK));
|
||||
if (!max_size.height())
|
||||
|
||||
@@ -388,8 +388,8 @@ void AtomURLLoaderFactory::StartLoadingHttp(
|
||||
if (value->IsNull()) {
|
||||
browser_context = AtomBrowserContext::From(base::GenerateGUID(), true);
|
||||
} else {
|
||||
mate::Handle<api::Session> session;
|
||||
if (mate::ConvertFromV8(dict.isolate(), value, &session) &&
|
||||
gin::Handle<api::Session> session;
|
||||
if (gin::ConvertFromV8(dict.isolate(), value, &session) &&
|
||||
!session.IsEmpty()) {
|
||||
browser_context = session->browser_context();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
namespace electron {
|
||||
|
||||
// Defines the interface for WebRequest API, implemented by api::WebRequestNS.
|
||||
// Defines the interface for WebRequest API, implemented by api::WebRequest.
|
||||
class WebRequestAPI {
|
||||
public:
|
||||
virtual ~WebRequestAPI() {}
|
||||
@@ -236,12 +236,12 @@ class ProxyingURLLoaderFactory
|
||||
void RemoveRequest(int32_t network_service_request_id, uint64_t request_id);
|
||||
void MaybeDeleteThis();
|
||||
|
||||
// Passed from api::WebRequestNS.
|
||||
// Passed from api::WebRequest.
|
||||
WebRequestAPI* web_request_api_;
|
||||
|
||||
// This is passed from api::ProtocolNS.
|
||||
// This is passed from api::Protocol.
|
||||
//
|
||||
// The ProtocolNS instance lives through the lifetime of BrowserContenxt,
|
||||
// The Protocol instance lives through the lifetime of BrowserContenxt,
|
||||
// which is guarenteed to cover the lifetime of URLLoaderFactory, so the
|
||||
// reference is guarenteed to be valid.
|
||||
//
|
||||
|
||||
@@ -50,8 +50,8 @@ END
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 8,0,0,20191023
|
||||
PRODUCTVERSION 8,0,0,20191023
|
||||
FILEVERSION 8,0,0,20191027
|
||||
PRODUCTVERSION 8,0,0,20191027
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "content/public/common/web_preferences.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "net/base/filename_util.h"
|
||||
#include "services/service_manager/sandbox/switches.h"
|
||||
#include "shell/browser/native_window.h"
|
||||
#include "shell/browser/web_view_manager.h"
|
||||
#include "shell/common/native_mate_converters/value_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/options_switches.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
@@ -101,16 +101,16 @@ std::vector<WebContentsPreferences*> WebContentsPreferences::instances_;
|
||||
|
||||
WebContentsPreferences::WebContentsPreferences(
|
||||
content::WebContents* web_contents,
|
||||
const mate::Dictionary& web_preferences)
|
||||
const gin_helper::Dictionary& web_preferences)
|
||||
: web_contents_(web_contents) {
|
||||
v8::Isolate* isolate = web_preferences.isolate();
|
||||
mate::Dictionary copied(isolate, web_preferences.GetHandle()->Clone());
|
||||
gin_helper::Dictionary copied(isolate, web_preferences.GetHandle()->Clone());
|
||||
// Following fields should not be stored.
|
||||
copied.Delete("embedder");
|
||||
copied.Delete("session");
|
||||
copied.Delete("type");
|
||||
|
||||
mate::ConvertFromV8(isolate, copied.GetHandle(), &preference_);
|
||||
gin::ConvertFromV8(isolate, copied.GetHandle(), &preference_);
|
||||
web_contents->SetUserData(UserDataKey(), base::WrapUnique(this));
|
||||
|
||||
instances_.push_back(this);
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace content {
|
||||
struct WebPreferences;
|
||||
}
|
||||
|
||||
namespace mate {
|
||||
namespace gin_helper {
|
||||
class Dictionary;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class WebContentsPreferences
|
||||
static WebContentsPreferences* From(content::WebContents* web_contents);
|
||||
|
||||
WebContentsPreferences(content::WebContents* web_contents,
|
||||
const mate::Dictionary& web_preferences);
|
||||
const gin_helper::Dictionary& web_preferences);
|
||||
~WebContentsPreferences() override;
|
||||
|
||||
// Set WebPreferences defaults onto the JS object.
|
||||
|
||||
@@ -259,7 +259,7 @@ float NativeImage::GetAspectRatio() {
|
||||
return static_cast<float>(size.width()) / static_cast<float>(size.height());
|
||||
}
|
||||
|
||||
mate::Handle<NativeImage> NativeImage::Resize(
|
||||
gin::Handle<NativeImage> NativeImage::Resize(
|
||||
v8::Isolate* isolate,
|
||||
const base::DictionaryValue& options) {
|
||||
gfx::Size size = GetSize();
|
||||
@@ -290,16 +290,16 @@ mate::Handle<NativeImage> NativeImage::Resize(
|
||||
|
||||
gfx::ImageSkia resized = gfx::ImageSkiaOperations::CreateResizedImage(
|
||||
image_.AsImageSkia(), method, size);
|
||||
return mate::CreateHandle(isolate,
|
||||
new NativeImage(isolate, gfx::Image(resized)));
|
||||
return gin::CreateHandle(isolate,
|
||||
new NativeImage(isolate, gfx::Image(resized)));
|
||||
}
|
||||
|
||||
mate::Handle<NativeImage> NativeImage::Crop(v8::Isolate* isolate,
|
||||
const gfx::Rect& rect) {
|
||||
gin::Handle<NativeImage> NativeImage::Crop(v8::Isolate* isolate,
|
||||
const gfx::Rect& rect) {
|
||||
gfx::ImageSkia cropped =
|
||||
gfx::ImageSkiaOperations::ExtractSubset(image_.AsImageSkia(), rect);
|
||||
return mate::CreateHandle(isolate,
|
||||
new NativeImage(isolate, gfx::Image(cropped)));
|
||||
return gin::CreateHandle(isolate,
|
||||
new NativeImage(isolate, gfx::Image(cropped)));
|
||||
}
|
||||
|
||||
void NativeImage::AddRepresentation(const gin_helper::Dictionary& options) {
|
||||
@@ -350,48 +350,48 @@ bool NativeImage::IsTemplateImage() {
|
||||
#endif
|
||||
|
||||
// static
|
||||
mate::Handle<NativeImage> NativeImage::CreateEmpty(v8::Isolate* isolate) {
|
||||
return mate::CreateHandle(isolate, new NativeImage(isolate, gfx::Image()));
|
||||
gin::Handle<NativeImage> NativeImage::CreateEmpty(v8::Isolate* isolate) {
|
||||
return gin::CreateHandle(isolate, new NativeImage(isolate, gfx::Image()));
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<NativeImage> NativeImage::Create(v8::Isolate* isolate,
|
||||
const gfx::Image& image) {
|
||||
return mate::CreateHandle(isolate, new NativeImage(isolate, image));
|
||||
gin::Handle<NativeImage> NativeImage::Create(v8::Isolate* isolate,
|
||||
const gfx::Image& image) {
|
||||
return gin::CreateHandle(isolate, new NativeImage(isolate, image));
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<NativeImage> NativeImage::CreateFromPNG(v8::Isolate* isolate,
|
||||
const char* buffer,
|
||||
size_t length) {
|
||||
gin::Handle<NativeImage> NativeImage::CreateFromPNG(v8::Isolate* isolate,
|
||||
const char* buffer,
|
||||
size_t length) {
|
||||
gfx::Image image = gfx::Image::CreateFrom1xPNGBytes(
|
||||
reinterpret_cast<const unsigned char*>(buffer), length);
|
||||
return Create(isolate, image);
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<NativeImage> NativeImage::CreateFromJPEG(v8::Isolate* isolate,
|
||||
const char* buffer,
|
||||
size_t length) {
|
||||
gin::Handle<NativeImage> NativeImage::CreateFromJPEG(v8::Isolate* isolate,
|
||||
const char* buffer,
|
||||
size_t length) {
|
||||
gfx::Image image = gfx::ImageFrom1xJPEGEncodedData(
|
||||
reinterpret_cast<const unsigned char*>(buffer), length);
|
||||
return Create(isolate, image);
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<NativeImage> NativeImage::CreateFromPath(
|
||||
gin::Handle<NativeImage> NativeImage::CreateFromPath(
|
||||
v8::Isolate* isolate,
|
||||
const base::FilePath& path) {
|
||||
base::FilePath image_path = NormalizePath(path);
|
||||
#if defined(OS_WIN)
|
||||
if (image_path.MatchesExtension(FILE_PATH_LITERAL(".ico"))) {
|
||||
return mate::CreateHandle(isolate, new NativeImage(isolate, image_path));
|
||||
return gin::CreateHandle(isolate, new NativeImage(isolate, image_path));
|
||||
}
|
||||
#endif
|
||||
gfx::ImageSkia image_skia;
|
||||
electron::util::PopulateImageSkiaRepsFromPath(&image_skia, image_path);
|
||||
gfx::Image image(image_skia);
|
||||
mate::Handle<NativeImage> handle = Create(isolate, image);
|
||||
gin::Handle<NativeImage> handle = Create(isolate, image);
|
||||
#if defined(OS_MACOSX)
|
||||
if (IsTemplateFilename(image_path))
|
||||
handle->SetTemplateImage(true);
|
||||
@@ -400,13 +400,13 @@ mate::Handle<NativeImage> NativeImage::CreateFromPath(
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<NativeImage> NativeImage::CreateFromBitmap(
|
||||
gin::Handle<NativeImage> NativeImage::CreateFromBitmap(
|
||||
gin_helper::ErrorThrower thrower,
|
||||
v8::Local<v8::Value> buffer,
|
||||
const gin_helper::Dictionary& options) {
|
||||
if (!node::Buffer::HasInstance(buffer)) {
|
||||
thrower.ThrowError("buffer must be a node Buffer");
|
||||
return mate::Handle<NativeImage>();
|
||||
return gin::Handle<NativeImage>();
|
||||
}
|
||||
|
||||
unsigned int width = 0;
|
||||
@@ -415,12 +415,12 @@ mate::Handle<NativeImage> NativeImage::CreateFromBitmap(
|
||||
|
||||
if (!options.Get("width", &width)) {
|
||||
thrower.ThrowError("width is required");
|
||||
return mate::Handle<NativeImage>();
|
||||
return gin::Handle<NativeImage>();
|
||||
}
|
||||
|
||||
if (!options.Get("height", &height)) {
|
||||
thrower.ThrowError("height is required");
|
||||
return mate::Handle<NativeImage>();
|
||||
return gin::Handle<NativeImage>();
|
||||
}
|
||||
|
||||
auto info = SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType);
|
||||
@@ -428,7 +428,7 @@ mate::Handle<NativeImage> NativeImage::CreateFromBitmap(
|
||||
|
||||
if (size_bytes != node::Buffer::Length(buffer)) {
|
||||
thrower.ThrowError("invalid buffer size");
|
||||
return mate::Handle<NativeImage>();
|
||||
return gin::Handle<NativeImage>();
|
||||
}
|
||||
|
||||
options.Get("scaleFactor", &scale_factor);
|
||||
@@ -448,13 +448,13 @@ mate::Handle<NativeImage> NativeImage::CreateFromBitmap(
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<NativeImage> NativeImage::CreateFromBuffer(
|
||||
gin::Handle<NativeImage> NativeImage::CreateFromBuffer(
|
||||
gin_helper::ErrorThrower thrower,
|
||||
v8::Local<v8::Value> buffer,
|
||||
gin::Arguments* args) {
|
||||
if (!node::Buffer::HasInstance(buffer)) {
|
||||
thrower.ThrowError("buffer must be a node Buffer");
|
||||
return mate::Handle<NativeImage>();
|
||||
return gin::Handle<NativeImage>();
|
||||
}
|
||||
|
||||
int width = 0;
|
||||
@@ -476,8 +476,8 @@ mate::Handle<NativeImage> NativeImage::CreateFromBuffer(
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<NativeImage> NativeImage::CreateFromDataURL(v8::Isolate* isolate,
|
||||
const GURL& url) {
|
||||
gin::Handle<NativeImage> NativeImage::CreateFromDataURL(v8::Isolate* isolate,
|
||||
const GURL& url) {
|
||||
std::string mime_type, charset, data;
|
||||
if (net::DataURL::Parse(url, &mime_type, &charset, &data)) {
|
||||
if (mime_type == "image/png")
|
||||
@@ -490,7 +490,7 @@ mate::Handle<NativeImage> NativeImage::CreateFromDataURL(v8::Isolate* isolate,
|
||||
}
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
mate::Handle<NativeImage> NativeImage::CreateFromNamedImage(
|
||||
gin::Handle<NativeImage> NativeImage::CreateFromNamedImage(
|
||||
gin::Arguments* args,
|
||||
const std::string& name) {
|
||||
return CreateEmpty(args->isolate());
|
||||
@@ -526,32 +526,31 @@ void NativeImage::BuildPrototype(v8::Isolate* isolate,
|
||||
|
||||
namespace gin {
|
||||
|
||||
v8::Local<v8::Value> Converter<mate::Handle<electron::api::NativeImage>>::ToV8(
|
||||
v8::Local<v8::Value> Converter<electron::api::NativeImage*>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const mate::Handle<electron::api::NativeImage>& val) {
|
||||
return val.ToV8();
|
||||
electron::api::NativeImage* val) {
|
||||
if (val)
|
||||
return val->GetWrapper();
|
||||
else
|
||||
return v8::Null(isolate);
|
||||
}
|
||||
|
||||
bool Converter<mate::Handle<electron::api::NativeImage>>::FromV8(
|
||||
bool Converter<electron::api::NativeImage*>::FromV8(
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
mate::Handle<electron::api::NativeImage>* out) {
|
||||
electron::api::NativeImage** out) {
|
||||
// Try converting from file path.
|
||||
base::FilePath path;
|
||||
if (ConvertFromV8(isolate, val, &path)) {
|
||||
*out = electron::api::NativeImage::CreateFromPath(isolate, path);
|
||||
*out = electron::api::NativeImage::CreateFromPath(isolate, path).get();
|
||||
// Should throw when failed to initialize from path.
|
||||
return !(*out)->image().IsEmpty();
|
||||
}
|
||||
|
||||
auto* wrapper = static_cast<mate::WrappableBase*>(
|
||||
mate::internal::FromV8Impl(isolate, val));
|
||||
if (!wrapper)
|
||||
return false;
|
||||
|
||||
*out = mate::CreateHandle(isolate,
|
||||
static_cast<electron::api::NativeImage*>(wrapper));
|
||||
return true;
|
||||
*out = static_cast<electron::api::NativeImage*>(
|
||||
static_cast<mate::WrappableBase*>(
|
||||
mate::internal::FromV8Impl(isolate, val)));
|
||||
return *out != nullptr;
|
||||
}
|
||||
|
||||
} // namespace gin
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "base/values.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "gin/handle.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
#include "shell/common/gin_helper/error_thrower.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
@@ -40,30 +40,29 @@ namespace api {
|
||||
|
||||
class NativeImage : public mate::Wrappable<NativeImage> {
|
||||
public:
|
||||
static mate::Handle<NativeImage> CreateEmpty(v8::Isolate* isolate);
|
||||
static mate::Handle<NativeImage> Create(v8::Isolate* isolate,
|
||||
const gfx::Image& image);
|
||||
static mate::Handle<NativeImage> CreateFromPNG(v8::Isolate* isolate,
|
||||
static gin::Handle<NativeImage> CreateEmpty(v8::Isolate* isolate);
|
||||
static gin::Handle<NativeImage> Create(v8::Isolate* isolate,
|
||||
const gfx::Image& image);
|
||||
static gin::Handle<NativeImage> CreateFromPNG(v8::Isolate* isolate,
|
||||
const char* buffer,
|
||||
size_t length);
|
||||
static gin::Handle<NativeImage> CreateFromJPEG(v8::Isolate* isolate,
|
||||
const char* buffer,
|
||||
size_t length);
|
||||
static mate::Handle<NativeImage> CreateFromJPEG(v8::Isolate* isolate,
|
||||
const char* buffer,
|
||||
size_t length);
|
||||
static mate::Handle<NativeImage> CreateFromPath(v8::Isolate* isolate,
|
||||
const base::FilePath& path);
|
||||
static mate::Handle<NativeImage> CreateFromBitmap(
|
||||
static gin::Handle<NativeImage> CreateFromPath(v8::Isolate* isolate,
|
||||
const base::FilePath& path);
|
||||
static gin::Handle<NativeImage> CreateFromBitmap(
|
||||
gin_helper::ErrorThrower thrower,
|
||||
v8::Local<v8::Value> buffer,
|
||||
const gin_helper::Dictionary& options);
|
||||
static mate::Handle<NativeImage> CreateFromBuffer(
|
||||
static gin::Handle<NativeImage> CreateFromBuffer(
|
||||
gin_helper::ErrorThrower thrower,
|
||||
v8::Local<v8::Value> buffer,
|
||||
gin::Arguments* args);
|
||||
static mate::Handle<NativeImage> CreateFromDataURL(v8::Isolate* isolate,
|
||||
const GURL& url);
|
||||
static mate::Handle<NativeImage> CreateFromNamedImage(
|
||||
gin::Arguments* args,
|
||||
const std::string& name);
|
||||
static gin::Handle<NativeImage> CreateFromDataURL(v8::Isolate* isolate,
|
||||
const GURL& url);
|
||||
static gin::Handle<NativeImage> CreateFromNamedImage(gin::Arguments* args,
|
||||
const std::string& name);
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
@@ -87,9 +86,9 @@ class NativeImage : public mate::Wrappable<NativeImage> {
|
||||
v8::Local<v8::Value> ToBitmap(gin::Arguments* args);
|
||||
v8::Local<v8::Value> GetBitmap(gin::Arguments* args);
|
||||
v8::Local<v8::Value> GetNativeHandle(gin_helper::ErrorThrower thrower);
|
||||
mate::Handle<NativeImage> Resize(v8::Isolate* isolate,
|
||||
const base::DictionaryValue& options);
|
||||
mate::Handle<NativeImage> Crop(v8::Isolate* isolate, const gfx::Rect& rect);
|
||||
gin::Handle<NativeImage> Resize(v8::Isolate* isolate,
|
||||
const base::DictionaryValue& options);
|
||||
gin::Handle<NativeImage> Crop(v8::Isolate* isolate, const gfx::Rect& rect);
|
||||
std::string ToDataURL(gin::Arguments* args);
|
||||
bool IsEmpty();
|
||||
gfx::Size GetSize();
|
||||
@@ -119,36 +118,14 @@ namespace gin {
|
||||
|
||||
// A custom converter that allows converting path to NativeImage.
|
||||
template <>
|
||||
struct Converter<mate::Handle<electron::api::NativeImage>> {
|
||||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const mate::Handle<electron::api::NativeImage>& val);
|
||||
struct Converter<electron::api::NativeImage*> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
electron::api::NativeImage* val);
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
mate::Handle<electron::api::NativeImage>* out);
|
||||
electron::api::NativeImage** out);
|
||||
};
|
||||
|
||||
} // namespace gin
|
||||
|
||||
namespace mate {
|
||||
|
||||
// Keep compatibility with native_mate code.
|
||||
//
|
||||
// TODO(zcbenz): Remove this after removing native_mate.
|
||||
template <>
|
||||
struct Converter<mate::Handle<electron::api::NativeImage>> {
|
||||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const mate::Handle<electron::api::NativeImage>& val) {
|
||||
return gin::ConvertToV8(isolate, val);
|
||||
}
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
mate::Handle<electron::api::NativeImage>* out) {
|
||||
return gin::ConvertFromV8(isolate, val, out);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
#endif // SHELL_COMMON_API_ATOM_API_NATIVE_IMAGE_H_
|
||||
|
||||
@@ -33,7 +33,7 @@ double safeShift(double in, double def) {
|
||||
return def;
|
||||
}
|
||||
|
||||
mate::Handle<NativeImage> NativeImage::CreateFromNamedImage(
|
||||
gin::Handle<NativeImage> NativeImage::CreateFromNamedImage(
|
||||
gin::Arguments* args,
|
||||
const std::string& name) {
|
||||
@autoreleasepool {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "base/hash/hash.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "shell/common/gin_converters/content_converter.h"
|
||||
#include "shell/common/gin_converters/gurl_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
@@ -19,10 +20,6 @@
|
||||
#include "shell/common/api/remote/remote_object_freer.h"
|
||||
#endif
|
||||
|
||||
// TODO(zcbenz): Remove the includes after removing native_mate.
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "shell/common/native_mate_converters/content_converter.h"
|
||||
|
||||
namespace std {
|
||||
|
||||
// The hash function used by DoubleIDWeakMap.
|
||||
@@ -125,11 +122,8 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
dict.SetMethod("getObjectHash", &GetObjectHash);
|
||||
dict.SetMethod("takeHeapSnapshot", &TakeHeapSnapshot);
|
||||
#if BUILDFLAG(ENABLE_REMOTE_MODULE)
|
||||
// TODO(zcbenz): Use gin_helper::Dictionary when content_converter.h is moved
|
||||
// to gin.
|
||||
mate::Dictionary mdict(context->GetIsolate(), exports);
|
||||
mdict.SetMethod("setRemoteCallbackFreer",
|
||||
&electron::RemoteCallbackFreer::BindTo);
|
||||
dict.SetMethod("setRemoteCallbackFreer",
|
||||
&electron::RemoteCallbackFreer::BindTo);
|
||||
dict.SetMethod("setRemoteObjectFreer", &electron::RemoteObjectFreer::BindTo);
|
||||
dict.SetMethod("addRemoteObjectRef", &electron::RemoteObjectFreer::AddRef);
|
||||
dict.SetMethod("createIDWeakMap",
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/common/native_mate_converters/accelerator_converter.h"
|
||||
#include "shell/common/gin_converters/accelerator_converter.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "shell/browser/ui/accelerator_util.h"
|
||||
|
||||
namespace mate {
|
||||
namespace gin {
|
||||
|
||||
// static
|
||||
bool Converter<ui::Accelerator>::FromV8(v8::Isolate* isolate,
|
||||
@@ -20,4 +20,4 @@ bool Converter<ui::Accelerator>::FromV8(v8::Isolate* isolate,
|
||||
return accelerator_util::StringToAccelerator(keycode, out);
|
||||
}
|
||||
|
||||
} // namespace mate
|
||||
} // namespace gin
|
||||
@@ -2,16 +2,16 @@
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_COMMON_NATIVE_MATE_CONVERTERS_ACCELERATOR_CONVERTER_H_
|
||||
#define SHELL_COMMON_NATIVE_MATE_CONVERTERS_ACCELERATOR_CONVERTER_H_
|
||||
#ifndef SHELL_COMMON_GIN_CONVERTERS_ACCELERATOR_CONVERTER_H_
|
||||
#define SHELL_COMMON_GIN_CONVERTERS_ACCELERATOR_CONVERTER_H_
|
||||
|
||||
#include "native_mate/converter.h"
|
||||
#include "gin/converter.h"
|
||||
|
||||
namespace ui {
|
||||
class Accelerator;
|
||||
}
|
||||
|
||||
namespace mate {
|
||||
namespace gin {
|
||||
|
||||
template <>
|
||||
struct Converter<ui::Accelerator> {
|
||||
@@ -20,6 +20,6 @@ struct Converter<ui::Accelerator> {
|
||||
ui::Accelerator* out);
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
} // namespace gin
|
||||
|
||||
#endif // SHELL_COMMON_NATIVE_MATE_CONVERTERS_ACCELERATOR_CONVERTER_H_
|
||||
#endif // SHELL_COMMON_GIN_CONVERTERS_ACCELERATOR_CONVERTER_H_
|
||||
@@ -12,6 +12,15 @@
|
||||
|
||||
namespace gin {
|
||||
|
||||
template <>
|
||||
struct Converter<blink::WebKeyboardEvent> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
blink::WebKeyboardEvent* out) {
|
||||
return mate::ConvertFromV8(isolate, val, out);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<blink::CloneableMessage> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
@@ -25,6 +34,46 @@ struct Converter<blink::CloneableMessage> {
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<blink::WebDeviceEmulationParams> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
blink::WebDeviceEmulationParams* out) {
|
||||
return mate::ConvertFromV8(isolate, val, out);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<blink::WebContextMenuData::MediaType> {
|
||||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const blink::WebContextMenuData::MediaType& in) {
|
||||
return mate::ConvertToV8(isolate, in);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<blink::WebContextMenuData::InputFieldType> {
|
||||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const blink::WebContextMenuData::InputFieldType& in) {
|
||||
return mate::ConvertToV8(isolate, in);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<network::mojom::ReferrerPolicy> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const network::mojom::ReferrerPolicy& in) {
|
||||
return mate::ConvertToV8(isolate, in);
|
||||
}
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
network::mojom::ReferrerPolicy* out) {
|
||||
return mate::ConvertFromV8(isolate, val, out);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace gin
|
||||
|
||||
#endif // SHELL_COMMON_GIN_CONVERTERS_BLINK_CONVERTER_GIN_ADAPTER_H_
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/common/native_mate_converters/content_converter.h"
|
||||
#include "shell/common/gin_converters/content_converter.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "content/public/browser/native_web_keyboard_event.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/context_menu_params.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "shell/browser/api/atom_api_web_contents.h"
|
||||
#include "shell/browser/web_contents_permission_helper.h"
|
||||
#include "shell/common/native_mate_converters/blink_converter.h"
|
||||
#include "shell/common/native_mate_converters/callback_converter_deprecated.h"
|
||||
#include "shell/common/native_mate_converters/gurl_converter.h"
|
||||
#include "shell/common/native_mate_converters/string16_converter.h"
|
||||
#include "shell/common/native_mate_converters/ui_base_types_converter.h"
|
||||
#include "shell/common/native_mate_converters/value_converter.h"
|
||||
#include "shell/common/gin_converters/blink_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_converters/callback_converter.h"
|
||||
#include "shell/common/gin_converters/gurl_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "ui/events/keycodes/dom/keycode_converter.h"
|
||||
#include "ui/events/keycodes/keyboard_code_conversion.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -38,7 +38,7 @@ v8::Local<v8::Value> MenuItemToV8(
|
||||
content::WebContents* web_contents,
|
||||
const content::CustomContextMenuContext& context,
|
||||
const content::MenuItem& item) {
|
||||
mate::Dictionary v8_item = mate::Dictionary::CreateEmpty(isolate);
|
||||
gin_helper::Dictionary v8_item = gin::Dictionary::CreateEmpty(isolate);
|
||||
switch (item.type) {
|
||||
case content::MenuItem::CHECKABLE_OPTION:
|
||||
case content::MenuItem::GROUP:
|
||||
@@ -69,12 +69,31 @@ v8::Local<v8::Value> MenuToV8(v8::Isolate* isolate,
|
||||
v8_menu.reserve(menu.size());
|
||||
for (const auto& menu_item : menu)
|
||||
v8_menu.push_back(MenuItemToV8(isolate, web_contents, context, menu_item));
|
||||
return mate::ConvertToV8(isolate, v8_menu);
|
||||
return gin::ConvertToV8(isolate, v8_menu);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace mate {
|
||||
namespace gin {
|
||||
|
||||
template <>
|
||||
struct Converter<ui::MenuSourceType> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const ui::MenuSourceType& in) {
|
||||
switch (in) {
|
||||
case ui::MENU_SOURCE_MOUSE:
|
||||
return StringToV8(isolate, "mouse");
|
||||
case ui::MENU_SOURCE_KEYBOARD:
|
||||
return StringToV8(isolate, "keyboard");
|
||||
case ui::MENU_SOURCE_TOUCH:
|
||||
return StringToV8(isolate, "touch");
|
||||
case ui::MENU_SOURCE_TOUCH_EDIT_MENU:
|
||||
return StringToV8(isolate, "touchMenu");
|
||||
default:
|
||||
return StringToV8(isolate, "none");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// static
|
||||
v8::Local<v8::Value> Converter<content::MenuItem::Type>::ToV8(
|
||||
@@ -100,7 +119,7 @@ v8::Local<v8::Value> Converter<ContextMenuParamsWithWebContents>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const ContextMenuParamsWithWebContents& val) {
|
||||
const auto& params = val.first;
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("x", params.x);
|
||||
dict.Set("y", params.y);
|
||||
dict.Set("linkURL", params.link_url);
|
||||
@@ -109,13 +128,13 @@ v8::Local<v8::Value> Converter<ContextMenuParamsWithWebContents>::ToV8(
|
||||
dict.Set("frameURL", params.frame_url);
|
||||
dict.Set("srcURL", params.src_url);
|
||||
dict.Set("mediaType", params.media_type);
|
||||
dict.Set("mediaFlags", MediaFlagsToV8(isolate, params.media_flags));
|
||||
dict.Set("mediaFlags", mate::MediaFlagsToV8(isolate, params.media_flags));
|
||||
bool has_image_contents =
|
||||
(params.media_type == blink::WebContextMenuData::kMediaTypeImage) &&
|
||||
params.has_image_contents;
|
||||
dict.Set("hasImageContents", has_image_contents);
|
||||
dict.Set("isEditable", params.is_editable);
|
||||
dict.Set("editFlags", EditFlagsToV8(isolate, params.edit_flags));
|
||||
dict.Set("editFlags", mate::EditFlagsToV8(isolate, params.edit_flags));
|
||||
dict.Set("selectionText", params.selection_text);
|
||||
dict.Set("titleText", params.title_text);
|
||||
dict.Set("misspelledWord", params.misspelled_word);
|
||||
@@ -126,7 +145,7 @@ v8::Local<v8::Value> Converter<ContextMenuParamsWithWebContents>::ToV8(
|
||||
if (params.custom_context.is_pepper_menu)
|
||||
dict.Set("menu", MenuToV8(isolate, val.second, params.custom_context,
|
||||
params.custom_items));
|
||||
return mate::ConvertToV8(isolate, dict);
|
||||
return gin::ConvertToV8(isolate, dict);
|
||||
}
|
||||
|
||||
// static
|
||||
@@ -215,7 +234,7 @@ bool Converter<content::WebContents*>::FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
content::WebContents** out) {
|
||||
electron::api::WebContents* web_contents = nullptr;
|
||||
if (!ConvertFromV8(isolate, val, &web_contents) || !web_contents)
|
||||
if (!gin::ConvertFromV8(isolate, val, &web_contents) || !web_contents)
|
||||
return false;
|
||||
|
||||
*out = web_contents->web_contents();
|
||||
@@ -226,17 +245,17 @@ bool Converter<content::WebContents*>::FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> Converter<content::Referrer>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const content::Referrer& val) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("url", ConvertToV8(isolate, val.url));
|
||||
dict.Set("policy", ConvertToV8(isolate, val.policy));
|
||||
return mate::ConvertToV8(isolate, dict);
|
||||
return gin::ConvertToV8(isolate, dict);
|
||||
}
|
||||
|
||||
// static
|
||||
bool Converter<content::Referrer>::FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
content::Referrer* out) {
|
||||
mate::Dictionary dict;
|
||||
gin_helper::Dictionary dict;
|
||||
if (!ConvertFromV8(isolate, val, &dict))
|
||||
return false;
|
||||
|
||||
@@ -249,4 +268,42 @@ bool Converter<content::Referrer>::FromV8(v8::Isolate* isolate,
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace mate
|
||||
// static
|
||||
bool Converter<content::NativeWebKeyboardEvent>::FromV8(
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
content::NativeWebKeyboardEvent* out) {
|
||||
gin_helper::Dictionary dict;
|
||||
if (!ConvertFromV8(isolate, val, &dict))
|
||||
return false;
|
||||
if (!ConvertFromV8(isolate, val, static_cast<blink::WebKeyboardEvent*>(out)))
|
||||
return false;
|
||||
dict.Get("skipInBrowser", &out->skip_in_browser);
|
||||
return true;
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Local<v8::Value> Converter<content::NativeWebKeyboardEvent>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const content::NativeWebKeyboardEvent& in) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
|
||||
if (in.GetType() == blink::WebInputEvent::Type::kRawKeyDown)
|
||||
dict.Set("type", "keyDown");
|
||||
else if (in.GetType() == blink::WebInputEvent::Type::kKeyUp)
|
||||
dict.Set("type", "keyUp");
|
||||
dict.Set("key", ui::KeycodeConverter::DomKeyToKeyString(in.dom_key));
|
||||
dict.Set("code", ui::KeycodeConverter::DomCodeToCodeString(
|
||||
static_cast<ui::DomCode>(in.dom_code)));
|
||||
|
||||
using Modifiers = blink::WebInputEvent::Modifiers;
|
||||
dict.Set("isAutoRepeat", (in.GetModifiers() & Modifiers::kIsAutoRepeat) != 0);
|
||||
dict.Set("shift", (in.GetModifiers() & Modifiers::kShiftKey) != 0);
|
||||
dict.Set("control", (in.GetModifiers() & Modifiers::kControlKey) != 0);
|
||||
dict.Set("alt", (in.GetModifiers() & Modifiers::kAltKey) != 0);
|
||||
dict.Set("meta", (in.GetModifiers() & Modifiers::kMetaKey) != 0);
|
||||
|
||||
return dict.GetHandle();
|
||||
}
|
||||
|
||||
} // namespace gin
|
||||
@@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_COMMON_NATIVE_MATE_CONVERTERS_CONTENT_CONVERTER_H_
|
||||
#define SHELL_COMMON_NATIVE_MATE_CONVERTERS_CONTENT_CONVERTER_H_
|
||||
#ifndef SHELL_COMMON_GIN_CONVERTERS_CONTENT_CONVERTER_H_
|
||||
#define SHELL_COMMON_GIN_CONVERTERS_CONTENT_CONVERTER_H_
|
||||
|
||||
#include <utility>
|
||||
|
||||
@@ -11,18 +11,19 @@
|
||||
#include "content/public/common/menu_item.h"
|
||||
#include "content/public/common/referrer.h"
|
||||
#include "content/public/common/stop_find_action.h"
|
||||
#include "native_mate/converter.h"
|
||||
#include "gin/converter.h"
|
||||
#include "third_party/blink/public/mojom/permissions/permission_status.mojom.h"
|
||||
|
||||
namespace content {
|
||||
struct ContextMenuParams;
|
||||
struct NativeWebKeyboardEvent;
|
||||
class WebContents;
|
||||
} // namespace content
|
||||
|
||||
using ContextMenuParamsWithWebContents =
|
||||
std::pair<content::ContextMenuParams, content::WebContents*>;
|
||||
|
||||
namespace mate {
|
||||
namespace gin {
|
||||
|
||||
template <>
|
||||
struct Converter<content::MenuItem::Type> {
|
||||
@@ -74,6 +75,15 @@ struct Converter<content::Referrer> {
|
||||
content::Referrer* out);
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
template <>
|
||||
struct Converter<content::NativeWebKeyboardEvent> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
content::NativeWebKeyboardEvent* out);
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const content::NativeWebKeyboardEvent& in);
|
||||
};
|
||||
|
||||
#endif // SHELL_COMMON_NATIVE_MATE_CONVERTERS_CONTENT_CONVERTER_H_
|
||||
} // namespace gin
|
||||
|
||||
#endif // SHELL_COMMON_GIN_CONVERTERS_CONTENT_CONVERTER_H_
|
||||
@@ -27,9 +27,8 @@ bool Converter<gfx::Image>::FromV8(v8::Isolate* isolate,
|
||||
if (val->IsNull())
|
||||
return true;
|
||||
|
||||
// TODO(deermichel): remove mate:: after dropping mate
|
||||
mate::Handle<electron::api::NativeImage> native_image;
|
||||
if (!mate::ConvertFromV8(isolate, val, &native_image))
|
||||
gin::Handle<electron::api::NativeImage> native_image;
|
||||
if (!gin::ConvertFromV8(isolate, val, &native_image))
|
||||
return false;
|
||||
|
||||
*out = native_image->image();
|
||||
@@ -38,7 +37,8 @@ bool Converter<gfx::Image>::FromV8(v8::Isolate* isolate,
|
||||
|
||||
v8::Local<v8::Value> Converter<gfx::Image>::ToV8(v8::Isolate* isolate,
|
||||
const gfx::Image& val) {
|
||||
return ConvertToV8(isolate, electron::api::NativeImage::Create(isolate, val));
|
||||
return gin::ConvertToV8(isolate,
|
||||
electron::api::NativeImage::Create(isolate, val));
|
||||
}
|
||||
|
||||
} // namespace gin
|
||||
|
||||
@@ -285,6 +285,58 @@ v8::Local<v8::Value> Converter<network::ResourceRequestBody>::ToV8(
|
||||
return arr;
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Local<v8::Value>
|
||||
Converter<scoped_refptr<network::ResourceRequestBody>>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const scoped_refptr<network::ResourceRequestBody>& val) {
|
||||
if (!val)
|
||||
return v8::Null(isolate);
|
||||
return ConvertToV8(isolate, *val);
|
||||
}
|
||||
|
||||
// static
|
||||
bool Converter<scoped_refptr<network::ResourceRequestBody>>::FromV8(
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
scoped_refptr<network::ResourceRequestBody>* out) {
|
||||
auto list = std::make_unique<base::ListValue>();
|
||||
if (!ConvertFromV8(isolate, val, list.get()))
|
||||
return false;
|
||||
*out = new network::ResourceRequestBody();
|
||||
for (size_t i = 0; i < list->GetSize(); ++i) {
|
||||
base::DictionaryValue* dict = nullptr;
|
||||
std::string type;
|
||||
if (!list->GetDictionary(i, &dict))
|
||||
return false;
|
||||
dict->GetString("type", &type);
|
||||
if (type == "rawData") {
|
||||
base::Value* bytes = nullptr;
|
||||
dict->GetBinary("bytes", &bytes);
|
||||
(*out)->AppendBytes(
|
||||
reinterpret_cast<const char*>(bytes->GetBlob().data()),
|
||||
base::checked_cast<int>(bytes->GetBlob().size()));
|
||||
} else if (type == "file") {
|
||||
std::string file;
|
||||
int offset = 0, length = -1;
|
||||
double modification_time = 0.0;
|
||||
dict->GetStringWithoutPathExpansion("filePath", &file);
|
||||
dict->GetInteger("offset", &offset);
|
||||
dict->GetInteger("file", &length);
|
||||
dict->GetDouble("modificationTime", &modification_time);
|
||||
(*out)->AppendFileRange(base::FilePath::FromUTF8Unsafe(file),
|
||||
static_cast<uint64_t>(offset),
|
||||
static_cast<uint64_t>(length),
|
||||
base::Time::FromDoubleT(modification_time));
|
||||
} else if (type == "blob") {
|
||||
std::string uuid;
|
||||
dict->GetString("blobUUID", &uuid);
|
||||
(*out)->AppendBlob(uuid);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Local<v8::Value> Converter<network::ResourceRequest>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user