CN114721745A - Method and device for loading and using local plug-in by browser and computing equipment - Google Patents
Method and device for loading and using local plug-in by browser and computing equipment Download PDFInfo
- Publication number
- CN114721745A CN114721745A CN202210566153.7A CN202210566153A CN114721745A CN 114721745 A CN114721745 A CN 114721745A CN 202210566153 A CN202210566153 A CN 202210566153A CN 114721745 A CN114721745 A CN 114721745A
- Authority
- CN
- China
- Prior art keywords
- plug
- target plug
- information
- target
- local server
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 251
- 238000004891 communication Methods 0.000 claims description 19
- 238000012545 processing Methods 0.000 claims description 15
- 230000001360 synchronised effect Effects 0.000 claims description 13
- 238000004806 packaging method and process Methods 0.000 claims description 7
- 238000010276 construction Methods 0.000 claims description 5
- 230000006870 function Effects 0.000 description 27
- 230000008569 process Effects 0.000 description 12
- 238000010586 diagram Methods 0.000 description 7
- 238000005516 engineering process Methods 0.000 description 5
- 238000011161 development Methods 0.000 description 3
- VYZAMTAEIAYCRO-UHFFFAOYSA-N Chromium Chemical compound [Cr] VYZAMTAEIAYCRO-UHFFFAOYSA-N 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 2
- 230000008901 benefit Effects 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 238000013519 translation Methods 0.000 description 2
- 244000035744 Hura crepitans Species 0.000 description 1
- 238000004458 analytical method Methods 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 230000000903 blocking effect Effects 0.000 description 1
- 238000005538 encapsulation Methods 0.000 description 1
- 238000009434 installation Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
- 230000007723 transport mechanism Effects 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44521—Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
- G06F9/44526—Plug-ins; Add-ons
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
- G06F9/4488—Object-oriented
- G06F9/449—Object-oriented method invocation or resolution
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45504—Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
- G06F9/45529—Embedded in an application, e.g. JavaScript in a Web browser
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The invention discloses a method and a device for loading and using a local plug-in by a browser and computing equipment, and relates to the technical field of plug-in loading. The method comprises the following steps: sending plug-in information of a target plug-in required by starting a browser page to a local server as an initialization message; after the initialization message is successfully verified, the local server loads an object of the target plug-in to obtain method information corresponding to the target plug-in; assembling the obtained method information corresponding to the target plug-in, and constructing a proxy object of the target plug-in; calling parameters of the target plug-in from a browser page through a proxy object of the target plug-in; identifying the parameters of the target plug-in, determining the identification information of the target plug-in corresponding to the parameters of the target plug-in, and sending the identification information to the local server; and the local server calls the corresponding plug-in method through the identification information of the target plug-in and returns a return value of the plug-in method. The method for loading and using the plug-in at the front end of the browser is simplified.
Description
Technical Field
The invention relates to the technical field of plug-in loading, in particular to a method and a device for loading and using a local plug-in by a browser and computing equipment.
Background
Plug-ins are an important component of browsers. In the past, the browser calls the plug-in, and the browser needs more loading codes and interface using codes. The NPAPI (Netscape plug-in Application Programming Interface) published by Netscape has long been an industry standard commonly supported by other browsers besides IEs. However, the NPAPI is abandoned by mainstream browsers (Chrome, FireFox) as an insecure factor, and the native plug-in is still a functional application that the browser cannot bypass, most typically Flash. A plug-in mechanism of PPAPPI (PeerPlugin API) is developed on the basis of the original netscape NPAPI, currently, PPAPPI technology is used for carrying out plug-in ActiveX under IE (Internet Explorer), which is based on COM specification, but is not plug-in standard in the browser industry, and runs in a sandbox environment of a Chrome browser.
In the current PPAPI technology, plug-ins need to be written, js files contain plug-in variables, receiving variables, plug-in information, receiving methods, sending methods, declaration of the plug-in methods in browsers and sending function bodies, and the like, and the problems of data redundancy and poor compatibility exist.
Disclosure of Invention
To this end, the present invention provides a method, apparatus and computing device for browser loading using native plug-ins in an effort to solve or at least alleviate at least one of the problems identified above.
According to one aspect of the invention, a method for loading and using a native plug-in by a browser is provided, which comprises the following steps:
sending plug-in information of a target plug-in required by starting a browser page to a local server as an initialization message;
after the initialization message is successfully verified, the local server loads an object of the target plug-in to obtain method information corresponding to the target plug-in, wherein the method information comprises a method, a method parameter type and a return value type of the target plug-in;
assembling the obtained method information corresponding to the target plug-in, and constructing a proxy object of the target plug-in;
calling parameters of the target plug-in from the browser page through the proxy object of the target plug-in; identifying the parameters of the target plug-in, determining the identification information of the target plug-in corresponding to the parameters of the target plug-in, and sending the identification information of the target plug-in to the local server;
and the local server calls the corresponding plug-in method through the identification information of the target plug-in and returns the return value of the plug-in method.
Preferably, the step of loading the object of the target plug-in and obtaining the method information corresponding to the target plug-in includes:
the local server starts a local plug-in according to the plug-in information of the target plug-in, establishes communication and reads an interface information list of the plug-in; the interface information list includes the following information for each plug-in: an interface identifier, a parameter list and a return value type;
acquiring an object of the target plug-in through the interface information list;
and feeding back the method information corresponding to the target plug-in.
Preferably, the method information corresponding to the target plug-in is assembled, and the step of constructing the proxy object of the target plug-in includes:
and constructing a method list of the proxy object of the target plug-in according to the acquired method information corresponding to the target plug-in, and performing synchronous control by using a WebAssembly packaged ES6 standard Promise object, wherein the method of each proxy object corresponds to the method corresponding to the target plug-in one to one.
Preferably, the step of performing synchronization control by using the WebAssembly packaged ES6 standard Promise object includes:
packaging a Promise object containing plug-in information of an ES6 standard by using WebAssembly;
processing the method list of the proxy object of the target plug-in, constructing a method proxy, circularly processing the information in the method list, adding a proxy method for the proxy object, and then adding the implementation logic of the proxy method; the implementation logic contains the following information: the system comprises plug-in identification information, method information, parameter processing information, encryption and decryption information and communication connection information.
Preferably, after identifying the parameter of the target plug-in and determining the identification information of the target plug-in corresponding to the parameter of the target plug-in, the method further includes:
determining a proxy method corresponding to the target plug-in, and calling the proxy method through a proxy object of the target plug-in to realize calling of the target plug-in.
Preferably, the method further includes the following step of checking, by the local server, the initialization message:
the local server checks the version number and UUID (Universal Unique Identifier) of the target plug-in carried in the initialization message;
and verifying whether the target plug-in exists or not according to the version number of the target plug-in and the UUID, opening the target plug-in under a protocol path when the target plug-in exists, verifying the running state of the target plug-in, and successfully verifying when the running state of the target plug-in meets the running environment of the browser.
In a second aspect, the present invention further provides an apparatus for loading a native plug-in by a browser, including:
the initialization module is suitable for sending plug-in information of a target plug-in required by starting a browser page to a local server as initialization information so that the local server loads an object of the target plug-in after the initialization information is verified successfully to obtain method information corresponding to the target plug-in, wherein the method information comprises a method, a method parameter type and a return value type of the target plug-in;
the construction module is suitable for assembling the obtained method information corresponding to the target plug-in and constructing a proxy object of the target plug-in;
the calling module is suitable for calling the parameters of the target plug-in from the browser page through the proxy object of the target plug-in, identifying the parameters of the target plug-in, determining the identification information of the target plug-in corresponding to the parameters of the target plug-in, and sending the identification information of the target plug-in to the local server so that the local server can call the corresponding plug-in method through the identification information of the target plug-in and return the return value of the plug-in method.
Preferably, the building module assembles the obtained method information corresponding to the target plug-in, and the proxy object for building the target plug-in is adapted to:
and constructing a method list of the proxy object of the target plug-in according to the acquired method information corresponding to the target plug-in, and performing synchronous control by using a WebAssembly packaged ES6 standard Promise object, wherein the method of each proxy object corresponds to the method corresponding to the target plug-in one to one.
A computing device of the present invention comprises:
at least one processor and a memory storing program instructions;
the program instructions, when read and executed by the processor, cause the computing device to perform the method for browser loading using native plug-ins as described above.
A readable storage medium of the present invention stores program instructions that, when read and executed by a computing device, cause the computing device to execute a method for loading a native plug-in for use by a browser as described above.
According to the method, the device and the computing equipment for loading and using the local plug-in by the browser, the following beneficial effects can be realized:
the method and the device for creating the plug-in package the plug-in creating interface and the communication function, create the interface when the browser calls the plug-in, and send the required plug-in information to the local server as an initialization message. The method comprises the steps that a local server loads the plug-in after checking the plug-in, reads method information of the plug-in and returns the method information. And calling the plug-in method through the plug-in proxy object to communicate with the local server, and completing plug-in calling and returning a return value by the local server through the method for calling the plug-in. According to the method, the browser front-end loading and plug-in using method is simplified through the functions of package creation of the instance interface and package of the plug-in proxy object. According to the plug-in calling process, the plug-in method definition and part of method realization are generated, and the plug-in agent object is constructed after the local server calls the plug-in, so that the plug-in development protocol and the tool simplify the plug-in development, the process of front-end loading and plug-in use is simplified, and the plug-in development process is simplified. And loading a plug-in at the front end of the browser, and generating a part of source codes developed by the plug-in according to a plug-in method list written by a protocol, wherein the source codes comprise method definitions, interface realization of part of service reading and the like. The method can also simplify the calling of the front-end plug-in method, and can be called in a synchronous mode and an asynchronous mode.
Drawings
To the accomplishment of the foregoing and related ends, certain illustrative aspects are described herein in connection with the following description and the annexed drawings, which are indicative of various ways in which the principles disclosed herein may be practiced, and all aspects and equivalents thereof are intended to be within the scope of the claimed subject matter. The above and other objects, features and advantages of the present disclosure will become more apparent from the following detailed description read in conjunction with the accompanying drawings. Throughout this disclosure, like reference numerals generally refer to like parts or elements.
FIG. 1 shows a schematic diagram of a computing device 100, according to one embodiment of the invention;
FIG. 2 illustrates a flow diagram of a method 200 for a browser to load a native plug-in for use, according to one embodiment of the invention;
FIG. 3 illustrates a flow diagram for obtaining method information corresponding to the target plug-in, according to one embodiment of the invention;
FIG. 4 is a flowchart illustrating obtaining method information corresponding to the target plug-in according to one embodiment of the invention;
FIG. 5 illustrates a flow diagram for obtaining method information corresponding to the translation plug-in, according to one embodiment of the invention;
fig. 6 is a schematic structural diagram illustrating an apparatus 600 for loading a native plug-in by a browser according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
According to the method for loading and using the local plug-in by the browser, aiming at the problem that the process of replacing the plug-in by the PPAPPI technology is complex, the plug-in interface can be called conveniently when the browser records the plug-in, and the user experience is improved.
In the embodiment of the present invention, taking loading a plug-in of a browser as an example, how to load and use a native plug-in is specifically described.
FIG. 1 shows a schematic block diagram of a computing device 100, according to an embodiment of the invention. It should be noted that the computing device 100 shown in fig. 1 is only an example, and in practice, the computing device 100 for implementing the method 200 for loading the browser using the native plug-in according to the present invention may be any type of device, and the hardware configuration thereof may be the same as the computing device 100 shown in fig. 1 or different from the computing device 100 shown in fig. 1. In practice, the computing device 100 for implementing the method 200 for loading and using a native plug-in by a browser of the present invention may add or delete hardware components of the computing device 100 shown in fig. 1, the present invention is not limited to a specific hardware configuration of the computing device 100, and the method 200 for loading and using a native plug-in by a browser of the present invention may dynamically call each hardware component in the computing device 100 during execution.
As shown in FIG. 1, computing device 100 includes system memory 110, processor 120, and display device 130.
The system memory 110 stores a plurality of program instructions for performing the method 200, and the system memory 110 may be any type of memory including, but not limited to: volatile memory (such as RAM), non-volatile memory (such as ROM, flash memory, etc.), or any combination thereof. Processor 120 may be any type of process including, but not limited to: a microprocessor (μ P), a microcontroller (μ C), a digital information processor (DSP), or any combination thereof. When the user loads and uses the native plug-in the process of using the browser, the processor 120 reads the program instructions stored in the system memory 110 and executes the program instructions, and then returns the execution result of the program instructions (the result of executing the native plug-in 201) to the browser 301 and displays the execution result through the display device 130.
According to the method 200 for loading and using the local plug-in by the browser, an interface is created when the browser calls the plug-in, and required plug-in information is sent to a local server as an initialization message. The method comprises the steps that a local server loads the plug-in after checking the plug-in, reads method information of the plug-in and returns the method information. And calling the plug-in method through the plug-in proxy object to communicate with the local server, and completing plug-in calling and returning a return value by the local server through the method for calling the plug-in.
FIG. 2 shows a flow diagram of a method 200 for a browser to load a native plug-in for use, according to one embodiment of the invention. Method 200 is performed in a computing device (e.g., computing device 100 described above) for loading for use native plug-ins. As shown in fig. 2, the method 200 begins at step S210.
In step S210, plug-in information of the target plug-in required to start the browser page is transmitted to the local server as an initialization message.
In the embodiment of the present invention, after the user starts the browser, in step S210 of the present invention, a target plug-in required for starting a browser page is obtained, where the target plug-in may be one or multiple, or may be a plug-in formed by integrating multiple functions.
When the target plug-in is a plurality of plug-ins, the local plug-ins can be loaded by the method of the embodiment of the invention for a plurality of times, one target plug-in is loaded each time, and the local plug-ins are loaded by communicating plug-in information (information carried by the initialization information) of one target plug-in, which is transmitted each time, with the local server.
In the embodiment of the invention, the plug-in information of the target plug-in calls the plug-in creation interface Create through the browser, and the required plug-in information is used as an initialization message to be sent to the local server. The local server in the embodiment of the invention belongs to a processing module for realizing the services corresponding to the plug-ins, such as plug-in loading, plug-in calling and the like.
In step S220, after the initialization message is successfully verified, the local server loads the object of the target plug-in, and obtains method information corresponding to the target plug-in, where the method information includes a method, a method parameter type, and a return value type of the target plug-in.
In this embodiment of the present invention, the step of verifying the initialization message by the local server in step S220 includes:
the local server checks the version number and UUID of the target plug-in carried in the initialization message;
and verifying whether the target plug-in exists or not according to the version number of the target plug-in and the UUID, opening the target plug-in under the protocol path when the target plug-in exists, verifying the running state of the target plug-in, and successfully verifying when the running state of the target plug-in meets the running environment of the browser.
In the embodiment of the invention, the local server checks the version number and the UUID of the target plug-in, verifies that the target plug-in does not exist, opens the plug-in under the path of the protocol, checks whether the target plug-in can be opened, and if the target plug-in can be opened, the local server obtains the method information of the target plug-in and returns the method information.
As shown in fig. 3, in the embodiment of the present invention, the step of loading the object of the target plug-in step S220 and obtaining the method information corresponding to the target plug-in includes:
step S310, the local server starts the local plug-in according to the plug-in information of the target plug-in, establishes communication and reads an interface information list of the plug-in; the interface information list includes the following information for each plug-in: an interface identification, a parameter list, and a return value type.
And step S320, acquiring the object of the target plug-in through the interface information list.
And S330, feeding back method information corresponding to the target plug-in.
In the embodiment of the invention, the method information corresponding to the target plug-in returned by the local plug-in to the local server comprises the method, the method parameter type and the return value type.
In the embodiment of the invention, the interface information list comprises the interface identifier, the parameter list and the return value type of each plug-in, and the three kinds of information can be simplified and expanded by defining a transmission protocol.
In step S230, the method information corresponding to the obtained target plug-in is assembled, and a proxy object of the target plug-in is constructed.
In this embodiment of the present invention, the step S230 is to assemble the obtained method information corresponding to the target plug-in, and the step of constructing the proxy object of the target plug-in includes:
and constructing a method list of the proxy object of the target plug-in according to the acquired method information corresponding to the target plug-in, and performing synchronous control by using a WebAssembly packaged ES6 standard Promise object, wherein the method of each proxy object corresponds to the method corresponding to the target plug-in one to one.
In the embodiment of the invention, the step of performing synchronous control by using the WebAssembly packaged ES6 standard Promise object comprises the following steps:
packaging a Promise object containing plug-in information of an ES6 standard by using WebAssembly;
processing a method list of a proxy object of the target plug-in, constructing a method proxy, circularly processing information in the method list, adding a proxy method for the proxy object, and then adding implementation logic of the proxy method; the implementation logic contains the following information: the system comprises plug-in identification information, method information, parameter processing information, encryption and decryption information and communication connection information.
In the embodiment of the invention, firstly, WebAssembly is used for packaging the proxy object containing the plug-in information, and then a proxy method is added for the proxy object; because the browser front-end is asynchronous (e.g., a simple service, the browser asks the user for the user's name, the user answers the browser, and the browser records the user's name. Asynchronous calls mean that the browser front-end does not actively wait for a reply. The use of WebAssembly to encapsulate the Promise object of the ES6 standard achieves a synchronization effect, returning a complete proxy object in js format.
In the embodiment of the invention, when the method information list is processed, the method agent is constructed, after the reply is waited, the information in the method list is circularly processed, the agent method is added for the agent object, and then the implementation logic of the agent method is added. The implementation logic comprises plug-in identification information, method information, parameter processing, encryption and decryption, communication connection and the like.
In step S240, a parameter of the target plug-in is called from the browser page through the proxy object of the target plug-in; and identifying the parameters of the target plug-in, determining the identification information of the target plug-in corresponding to the parameters of the target plug-in, and sending the identification information of the target plug-in to the local server.
Identifying the parameters of the target plug-in, and after determining the identification information of the target plug-in corresponding to the parameters of the target plug-in, the method further comprises the following steps:
and determining a proxy method corresponding to the target plug-in, and calling the proxy method through the proxy object of the target plug-in to realize the calling of the target plug-in.
In the embodiment of the invention, when the plug-in identification is used for constructing the plug-in proxy object, the plug-in identification information and the processing method parameter are sent to the local server, and the local server is used when the plug-in is called. After the plug-in is installed, which plug-in needs to be called for starting a browser page can be locked through the name and version information of the plug-in, the path and installation information of the plug-in are part of the whole system protocol, and a configuration file or a conventional rule exists where the plug-in is installed. When the plug-in is called through the known plug-in information, the method information returned by the plug-in and the plug-in can be bound in the functional module. And establishing association conditions for subsequent method calls.
In the embodiment of the invention, one plug-in proxy object corresponds to one plug-in. The implementation logic of the proxy method of the proxy object comprises the plug-in information, and the local server calls the corresponding plug-in through checking and searching after obtaining the plug-in information.
In step S250, the local server calls a corresponding plug-in method through the identification information of the target plug-in, and returns a return value of the plug-in method.
As shown in fig. 4, in the functional module, the plug-in creating interface and the communication function are encapsulated, and when the browser front-end calls the plug-in creating interface, the plug-in information of the required target plug-in is sent to the local server as an initialization message. The local server loads the target plug-in after checking the initialization message of the target plug-in, reads the method list (the method identification information in fig. 4) of the target plug-in, and returns the method list to the function module. And the function module dynamically creates a proxy object of the target plug-in through the method list, adds the method attribute to the proxy object, adds a function for interaction with the local server to realize the method, and returns the function to the front end of the browser. At this point, the target plug-in loading and the proxy object creation of the target plug-in are completed. The browser front end can create the proxy object of the target plug-in by calling the plug-in creation interface through the functional module.
When the front end of the browser calls the target plug-in, the target plug-in method is called through the proxy object of the target plug-in, the interactive function of the target plug-in method is called in the function module and communicated with the local server, the local server completes calling of the target plug-in through the method for calling the target plug-in, and a return value is returned to the function module. And the function module returns the result to the front end of the browser in the form of JavaScript Promise. The browser front end can display, process and operate the returned results. And the browser front end calls a target plug-in to process the return value in a synchronous or asynchronous mode according to the scene selection.
As shown in fig. 5, taking translation as an example, the process of loading and using native plug-in by the browser according to the embodiment of the present invention is described:
the browser calls the local plug-in to contain three parts, the browser (service client), the local server (one), and the local plug-in (there may be multiple).
The browser contains a browser front end (service H5) and a function module (js code or js file). The module function js file is a js file packaged by using a WebAssembly technology. The module function has a communication function from the browser front end to the local server, a data processing (encryption/decryption, packaging and analysis), an object and a method construction function. And the js file is not visible to the front end of the browser, and the front end cannot check the source code of the functional module.
The function module js provides the global method Create to the front end H5, and the parameter is plug-in information, which may be a name, version, or other data component as a plug-in identifier. The front end H5 calls the Create method to the function module, the function module sends the plug-in information to the local server to start the plug-in, the local server starts the local plug-in according to the plug-in information and establishes communication, and the plug-in interface information list is obtained. The interface information contains an interface identification, a parameter list, and a return value type. The function module constructs a plug-in agent object containing plug-in identification information after acquiring plug-in interface information returned by the local server, constructs a method list of the plug-in agent object according to the plug-in interface information list, and uses WebAssembly to package ES6 standard Promise object for synchronous control, thereby achieving the synchronous effect of blocking and waiting for return after being called by the front end H5. And realizing a method for constructing the proxy object. The method of each proxy object corresponds to the method of the plug-in object one to one. The method enables messaging with local services through communication. The message content contains method information, message identification, and other authentication messages. After the plug-in proxy object returned by the front end H5 through the Create interface makes a method call, in the functional module, the method in the proxy object realizes that the method information, the method parameters, the plug-in information, the message identifier, and the like are sent to the local server. And the local server searches and verifies the plug-in according to the plug-in information and the verification information. After finding the plug-in, the method parameter is called through rpc mode to obtain the return value. And returning the return value and the necessary message identifier to the function module, calling the function module by the message identifier searching method, returning the return value to the called method, and completing the method calling of the local plug-in. The proxy object and the proxy method are constructed by packaging the object in the functional module through the WebAssembly technology and returning the packaged object to the front end. By storing the plug-in information in the proxy object, the plug-in information is sent to the local server in the implementation of the proxy method, and the interface calls of different plug-ins are distinguished. And acquiring a return value called by the plug-in interface through the message identifier.
In the embodiment of the invention, the front end H5 only needs to establish a communication connection with the local server, so that the communication port resource is saved, the conflict is avoided, and the reasonable layering is performed in a one-to-one communication mode relative to the front end H5 and the plug-ins, thereby being beneficial to the expansion. By carrying out protocol encapsulation on the local server and the plug-in, the method for unifying the external functions provided by the plug-in is standardized. The universality of the system is improved, and the popularization is facilitated.
As shown in fig. 6, the present invention further provides an apparatus 600 for loading a native plug-in for a browser, including: an initialization module 610, a build module 620, and a call module 630.
The initialization module is suitable for sending the plug-in information of the target plug-in required by starting the browser page to the local server as an initialization message; after the initialization message is successfully verified, the local server loads an object of the target plug-in to obtain method information corresponding to the target plug-in, wherein the method information comprises a method, a method parameter type and a return value type of the target plug-in; the construction module is suitable for assembling the obtained method information corresponding to the target plug-in and constructing a proxy object of the target plug-in; the calling module is suitable for calling the parameters of the target plug-in from the browser page through the proxy object of the target plug-in; identifying the parameters of the target plug-in, determining the identification information of the target plug-in corresponding to the parameters of the target plug-in, and sending the identification information of the target plug-in to a local server; and the local server calls the corresponding plug-in method through the identification information of the target plug-in and returns a return value of the plug-in method.
In the embodiment of the present invention, the loading, by the local server, the object of the target plug-in, and the obtaining of the method information corresponding to the target plug-in includes: the local server starts a local plug-in according to the plug-in information of the target plug-in, establishes communication and reads an interface information list of the plug-in; the interface information list includes the following information for each plug-in: an interface identifier, a parameter list and a return value type; acquiring the object of the target plug-in through the interface information list; and feeding back the method information corresponding to the target plug-in.
The constructing module 620 assembles the obtained method information corresponding to the target plug-in, and constructing the proxy object of the target plug-in includes: and constructing a method list of the proxy object of the target plug-in according to the acquired method information corresponding to the target plug-in, and performing synchronous control by using a WebAssembly packaged ES6 standard Promise object, wherein the method of each proxy object corresponds to the method corresponding to the target plug-in one to one.
Specifically, the synchronous control by using the WebAssembly packaged ES6 standard Promise object includes: packaging a Promise object containing plug-in information of an ES6 standard by using WebAssembly; processing the method list of the proxy object of the target plug-in, constructing a method proxy, circularly processing the information in the method list, adding a proxy method for the proxy object, and then adding the implementation logic of the proxy method; the implementation logic contains the following information: the system comprises plug-in identification information, method information, parameter processing information, encryption and decryption information and communication connection information.
The invoking module 630 identifies the parameter of the target plug-in, and after determining the identification information of the target plug-in corresponding to the parameter of the target plug-in, the method further includes: determining a proxy method corresponding to the target plug-in, and calling the proxy method through a proxy object of the target plug-in to realize calling of the target plug-in.
In this embodiment of the present invention, the verifying the initialization message by the local server includes: the local server checks the version number and UUID of the target plug-in carried in the initialization message; and verifying whether the target plug-in exists or not according to the version number of the target plug-in and the UUID, opening the target plug-in under a protocol path when the target plug-in exists, verifying the running state of the target plug-in, and successfully verifying when the running state of the target plug-in meets the running environment of the browser.
In this embodiment of the present invention, the building module 620 assembles the obtained method information corresponding to the target plug-in, and the proxy object for building the target plug-in is adapted to: and constructing a method list of the proxy object of the target plug-in according to the acquired method information corresponding to the target plug-in, and performing synchronous control by using a WebAssembly packaged ES6 standard Promise object, wherein the method of each proxy object corresponds to the method corresponding to the target plug-in one to one.
An embodiment of the present invention further provides a computing device, including: at least one processor and a memory storing program instructions; the program instructions, when read and executed by a processor, cause the computing device to perform a method for browser loading using native plug-ins as described above.
Embodiments of the present invention further provide a readable storage medium storing program instructions, which, when read and executed by a computing device, cause the computing device to execute the above method for loading and using a native plug-in by a browser.
The various techniques described herein may be implemented in connection with hardware or software or, alternatively, with a combination of both. Thus, the methods and apparatus of the present invention, or certain aspects or portions thereof, may take the form of program code (i.e., instructions) embodied in tangible media, such as removable hard drives, U.S. disks, floppy disks, CD-ROMs, or any other machine-readable storage medium, wherein, when the program is loaded into and executed by a machine, such as a computer, the machine becomes an apparatus for practicing the invention.
In the case of program code execution on programmable computers, the computing device will generally include a processor, a storage medium readable by the processor (including volatile and non-volatile memory and/or storage elements), at least one input device, and at least one output device. Wherein the memory is configured to store program code; the processor is configured to execute the scheduling method of the process of accessing the non-VMA zone file cache of the present invention according to instructions in the program code stored in the memory.
By way of example, and not limitation, readable media may comprise readable storage media and communication media. Readable storage media store information such as computer readable instructions, data structures, program modules or other data. Communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. Combinations of any of the above are also included within the scope of readable media.
In the description provided herein, algorithms and displays are not inherently related to any particular computer, virtual system, or other apparatus. Various general purpose systems may also be used with examples of this invention. The required structure for constructing such a system will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose preferred embodiments of the invention.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim.
Those skilled in the art will appreciate that the modules or units or components of the devices in the examples disclosed herein may be arranged in a device as described in this embodiment or alternatively may be located in one or more devices different from the devices in this example. The modules in the foregoing examples may be combined into one module or may be further divided into multiple sub-modules.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments.
Additionally, some of the embodiments are described herein as a method or combination of method elements that can be implemented by a processor of a computer system or by other means of performing the described functions. A processor with the necessary instructions for carrying out the method or the method elements thus forms a device for carrying out the method or the method elements. Further, the elements of the apparatus embodiments described herein are examples of the following apparatus: the apparatus is used to implement the functions performed by the elements for the purpose of carrying out the invention.
As used herein, unless otherwise specified the use of the ordinal adjectives "first", "second", "third", etc., to describe a common object, merely indicate that different instances of like objects are being referred to, and are not intended to imply that the objects so described must be in a given sequence, either temporally, spatially, in ranking, or in any other manner.
While the invention has been described with respect to a limited number of embodiments, those skilled in the art, having benefit of this description, will appreciate that other embodiments can be devised which do not depart from the scope of the invention as disclosed herein. Furthermore, it should be noted that the language used in the specification has been principally selected for readability and instructional purposes, and may not have been selected to delineate or circumscribe the inventive subject matter.
Claims (10)
1. A method for loading and using native plug-in by a browser comprises the following steps:
sending plug-in information of a target plug-in required by starting a browser page to a local server as an initialization message;
after the initialization message is successfully verified, the local server loads an object of the target plug-in to obtain method information corresponding to the target plug-in, wherein the method information comprises a method, a method parameter type and a return value type of the target plug-in;
assembling the obtained method information corresponding to the target plug-in, and constructing a proxy object of the target plug-in;
calling parameters of the target plug-in from the browser page through the proxy object of the target plug-in; identifying the parameters of the target plug-in, determining the identification information of the target plug-in corresponding to the parameters of the target plug-in, and sending the identification information of the target plug-in to the local server;
and the local server calls the corresponding plug-in method through the identification information of the target plug-in and returns the return value of the plug-in method.
2. The method of claim 1, wherein the step of loading the object of the target plug-in and obtaining the method information corresponding to the target plug-in comprises:
the local server starts a local plug-in according to the plug-in information of the target plug-in, establishes communication and reads an interface information list of the plug-in; the interface information list includes the following information for each plug-in: an interface identifier, a parameter list and a return value type;
acquiring the object of the target plug-in through the interface information list;
and feeding back the method information corresponding to the target plug-in.
3. The method of claim 1, wherein the method information corresponding to the target plug-in is assembled, and the step of constructing the proxy object of the target plug-in comprises:
and constructing a method list of the proxy object of the target plug-in according to the acquired method information corresponding to the target plug-in, and performing synchronous control by using a WebAssembly packaged ES6 standard Promise object, wherein the method of each proxy object corresponds to the method corresponding to the target plug-in one to one.
4. The method as claimed in claim 3, wherein the step of performing synchronization control using the WebAssembly packaged ES6 standard Promise object comprises:
packaging a Promise object containing plug-in information of an ES6 standard by using WebAssembly;
processing the method list of the proxy object of the target plug-in, constructing a method proxy, circularly processing the information in the method list, adding a proxy method for the proxy object, and then adding the implementation logic of the proxy method; the implementation logic contains the following information: the system comprises plug-in identification information, method information, parameter processing information, encryption and decryption information and communication connection information.
5. The method of claim 1, wherein identifying the parameters of the target plug-in, and determining the identification information of the target plug-in corresponding to the parameters of the target plug-in further comprises:
and determining a proxy method corresponding to the target plug-in, and calling the proxy method through a proxy object of the target plug-in to realize the calling of the target plug-in.
6. The method of claim 1, further comprising the step of the local server verifying the initialization message by:
the local server checks the version number and UUID of the target plug-in carried in the initialization message;
and verifying whether the target plug-in exists or not according to the version number of the target plug-in and the UUID, opening the target plug-in under a protocol path when the target plug-in exists, verifying the running state of the target plug-in, and successfully verifying when the running state of the target plug-in meets the running environment of the browser.
7. An apparatus for loading native plug-ins for use with a browser, comprising:
the initialization module is suitable for sending plug-in information of a target plug-in required by starting a browser page to a local server as initialization information so that the local server loads an object of the target plug-in after the initialization information is verified successfully to obtain method information corresponding to the target plug-in, wherein the method information comprises a method, a method parameter type and a return value type of the target plug-in;
the construction module is suitable for assembling the obtained method information corresponding to the target plug-in and constructing a proxy object of the target plug-in;
the calling module is suitable for calling the parameters of the target plug-in from the browser page through the proxy object of the target plug-in, identifying the parameters of the target plug-in, determining the identification information of the target plug-in corresponding to the parameters of the target plug-in, and sending the identification information of the target plug-in to the local server so that the local server can call the corresponding plug-in method through the identification information of the target plug-in and return the return value of the plug-in method.
8. The apparatus of claim 7, wherein the construction module assembles the obtained method information corresponding to the target plug-in, and the proxy object constructing the target plug-in is adapted to:
and constructing a method list of the proxy object of the target plug-in according to the acquired method information corresponding to the target plug-in, and performing synchronous control by using a WebAssembly packaged ES6 standard Promise object, wherein the method of each proxy object corresponds to the method corresponding to the target plug-in one to one.
9. A computing device, comprising:
at least one processor and a memory storing program instructions;
the program instructions, when read and executed by the processor, cause the computing device to perform the method of browser loading using native plug-ins of any of claims 1-6.
10. A readable storage medium storing program instructions that, when read and executed by a computing device, cause the computing device to perform a method of browser loading for use with native plug-ins as claimed in any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210566153.7A CN114721745B (en) | 2022-05-24 | 2022-05-24 | Method and device for loading and using local plug-in by browser and computing equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210566153.7A CN114721745B (en) | 2022-05-24 | 2022-05-24 | Method and device for loading and using local plug-in by browser and computing equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114721745A true CN114721745A (en) | 2022-07-08 |
CN114721745B CN114721745B (en) | 2022-10-25 |
Family
ID=82231921
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210566153.7A Active CN114721745B (en) | 2022-05-24 | 2022-05-24 | Method and device for loading and using local plug-in by browser and computing equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114721745B (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20090288098A1 (en) * | 2008-05-13 | 2009-11-19 | Google Inc. | Separate Plug-In Processes In Browsers and Applications Thereof |
CN102625182A (en) * | 2012-03-31 | 2012-08-01 | 百视通网络电视技术发展有限责任公司 | Method and system for integrating and controlling video player in Connected TV |
CN103617092A (en) * | 2013-11-21 | 2014-03-05 | 北京奇虎科技有限公司 | Browser based plug-in running method and device |
CN112988409A (en) * | 2019-12-18 | 2021-06-18 | 腾讯科技(深圳)有限公司 | Interface calling method and device, computer equipment and storage medium |
CN113535275A (en) * | 2021-08-06 | 2021-10-22 | 统信软件技术有限公司 | Hybrid application construction method and device and computing equipment |
-
2022
- 2022-05-24 CN CN202210566153.7A patent/CN114721745B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20090288098A1 (en) * | 2008-05-13 | 2009-11-19 | Google Inc. | Separate Plug-In Processes In Browsers and Applications Thereof |
CN102625182A (en) * | 2012-03-31 | 2012-08-01 | 百视通网络电视技术发展有限责任公司 | Method and system for integrating and controlling video player in Connected TV |
CN103617092A (en) * | 2013-11-21 | 2014-03-05 | 北京奇虎科技有限公司 | Browser based plug-in running method and device |
CN112988409A (en) * | 2019-12-18 | 2021-06-18 | 腾讯科技(深圳)有限公司 | Interface calling method and device, computer equipment and storage medium |
CN113535275A (en) * | 2021-08-06 | 2021-10-22 | 统信软件技术有限公司 | Hybrid application construction method and device and computing equipment |
Also Published As
Publication number | Publication date |
---|---|
CN114721745B (en) | 2022-10-25 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP4959715B2 (en) | Web service compliance with updated contracts | |
CN110908738B (en) | Method and device for running small program | |
CN113986515B (en) | Method and device for creating sandbox environment for plug-in operation and computing equipment | |
TW200937188A (en) | Contract programming for code error reduction | |
US9189300B2 (en) | Dynamic service discovery | |
CN111813385B (en) | Page plug-in method, device and equipment based on Web application | |
CN111506366B (en) | Plug-in calling method, device, electronic equipment and storage medium | |
CN109933350B (en) | Method and device for embedding codes in application and electronic equipment | |
EP3974960B1 (en) | Method and system for automated testing of web service apis | |
WO1999034286A1 (en) | Method and apparatus capable of embedding, extracting and processing data within a file having an html format | |
CN112769706A (en) | Componentized routing method and system | |
CN114721745B (en) | Method and device for loading and using local plug-in by browser and computing equipment | |
CN114895935A (en) | Method and device for flashing vehicle ECU, electronic equipment and storage medium | |
US20100228772A1 (en) | Method and apparatus for performing an information search and retrieval by submitting an electronic form over e-mail | |
CN113742235A (en) | Method and device for checking codes | |
CN109388770B (en) | Web page generation method and device | |
CN109144595B (en) | Method and device for starting assembly based on plug-in framework | |
CN116051218A (en) | Client billing method and system based on embedded browser | |
CN113626001B (en) | API dynamic arrangement method and device based on script | |
CN111459819B (en) | Software testing method and device, electronic equipment and computer readable medium | |
CN110399161B (en) | Mapping relation generation method, calling method and device | |
CN114860204A (en) | Program processing method, program operating device, terminal, smart card and storage medium | |
CN115022387B (en) | Cross-domain pre-inspection request processing method, device, equipment and medium | |
CN107943539B (en) | Application page starting method and application page starting device | |
CN111611507A (en) | Modularization-based in-application page jump method and computing device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CB03 | Change of inventor or designer information | ||
CB03 | Change of inventor or designer information |
Inventor after: Cao Can Inventor before: Zhang Wenbin |