feat: add nativeImage.createThumbnailFromPath API (#25072)

* cherry-picking

* add documentation

* convert createThumbnailFromPath to async function

* windows impl protoype

* add tests

* clean up

* fix

* fix test

* update docs

* cleaning up code

* fix test

* refactor from app to native_image

* windows build

* lint

* lint

* add smart pointers, fix test

* change tests and update docs

* fix test, remove nolint

* add renderer-main process routing to fix tests

* lint

* thanks sam

* cherry-pick

* lint

* remove getApplicationInfoForProtocol code

* chore: fix filenames conflict

Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
This commit is contained in:
George Xu
2020-08-26 16:18:28 -07:00
committed by GitHub
parent 0b834877fe
commit d73b67f386
17 changed files with 224 additions and 7 deletions

View File

@@ -15,6 +15,7 @@ export const browserModuleList: ElectronInternal.ModuleEntry[] = [
{ name: 'Menu', loader: () => require('./menu') },
{ name: 'MenuItem', loader: () => require('./menu-item') },
{ name: 'MessageChannelMain', loader: () => require('./message-channel') },
{ name: 'nativeImage', loader: () => require('./native-image') },
{ name: 'nativeTheme', loader: () => require('./native-theme') },
{ name: 'net', loader: () => require('./net') },
{ name: 'netLog', loader: () => require('./net-log') },

View File

@@ -17,6 +17,7 @@ export const browserModuleNames = [
'inAppPurchase',
'Menu',
'MenuItem',
'nativeImage',
'nativeTheme',
'net',
'netLog',

View File

@@ -0,0 +1,3 @@
const { nativeImage } = process._linkedBinding('electron_common_native_image');
export default nativeImage;

View File

@@ -4,7 +4,6 @@ import * as fs from 'fs';
import { Socket } from 'net';
import * as path from 'path';
import * as util from 'util';
const Module = require('module');
// We modified the original process.argv to let node.js load the init.js,

View File

@@ -134,3 +134,7 @@ ipcMainUtils.handleSync('ELECTRON_CRASH_REPORTER_SET_UPLOAD_TO_SERVER', (event,
ipcMainUtils.handleSync('ELECTRON_CRASH_REPORTER_GET_CRASHES_DIRECTORY', () => {
return electron.crashReporter.getCrashesDirectory();
});
ipcMainInternal.handle('ELECTRON_NATIVE_IMAGE_CREATE_THUMBNAIL_FROM_PATH', async (_, path, size) => {
return typeUtils.serialize(await electron.nativeImage.createThumbnailFromPath(path, size));
});