Building an chromium-based application
Chromium is the kernel used by Google Chrome, which started out with Apple's WebKit, because of WebKit's divergence in development and Google's desire for greater freedom in development, 2013 Google decided to develop its own branch of WebCore, called the Blink engine, and then Google to the BSD Berkeley Licensing Open source, BSD licensing restrictions more lenient, many browsers are based on chromium development, for example, after the omission of 100 words. Google on the basis of further streamlined optimization, and developed the V8 JavaScript engine, 2010 Google acquired WEBRTC Technology then opened the source code, WEBRTC using VP Code, compatible with HTML5 standards, the same year Google has introduced Chrome OS cloud OS, browser derivative products.
Not much nonsense to say, retrieve the chromium Embedded Framework, called CEF, you can see the current chromium the latest release of the Cefbuilds, you can also download on Google Code, It includes the browser's core library and the underlying API, support for C and C + + programming languages, and third-party include. Net/mono, Java, Python, Delphi and other open source projects.
We downloaded the Win32 C + + library from Google Code and opened the release folder.
Here is a description:
LIBCEF.DLL:CEF Core Library.
Icudt.dll: Encoded format Library.
Ffmpegsumo.dll: Video decoder, including VP8 VP9 encoding library.
D3dcompiler_43.dll, D3dcompiler_46.dll, LibEGL.dll, LibGLESv2.dll
These are the 3d graphics libraries, D3dcompiler_43.dll applies to xp,d3dcompiler_46 for versions above XP.
The Include folder is the CEF C + + header file that you can go to github to download. NET called Project, called Cefsharp, which provides a complete demo of WinForm and WPF.
Cefsharp: Encapsulation is the portal and data acceptance class for the C # call API.
Cefsharp.browsersubprocess: A companion process written by. NET that is primarily responsible for working with JavaScript and background threads.
CefSharp.BrowserSubprocess.Core: is a C + + project that needs to refer to the CEF C + + header file, mainly JavaScript related operations.
Cefsharp.core: Also a C + + project, including the initial configuration of CEF, accepting events, and so on.
Cefsharp.example:c# invokes the init configuration of CEF.
CefSharp.WinForm.Example: wrote a custom control as a window for the Cef browser.
ChromimumWebBrowser.cs the implementation of all interfaces can be placed here, see Cefsharp Demo.
Class Chromiumwebbrowser:control, Iwebbrowserinternal, Iwinformswebbrowser{ ... 4}
Add a custom control Browserusercontrol. Customize a constructor.
1public Browserusercontrol (string URL) { 3 InitializeComponent (); 5 var browser = new Chromiumwebbrowser (URL) 6 { 7 Dock = Dockstyle.fill}; 9 Span style= "color: #0000ff;" >this10}
Create a Form1 startup window to add the created user control.
1PublicForm1 (){ 3 InitializeComponent (); 5 var browser = new Browserusercontrol (cefexample.defaulturl) 6 Span style= "color: #000000;" > { DockStyle.Fill, }; browser. CreateControl (); 10 this11}
Take a look at the Main method entry in Program.cs, and Cefexample calls an Init initialization method.
1///<summary>2///The main entry point for the application.3///</summary> 4 [ Stathread] 5 static Void Main () 6 { 7 Cefexample.init (); 8 Application.enablevisualstyles (); 10 Application.setcompatibletextrenderingdefault (false ); 11 Application.Run (new Form1 ()); 12}
In the Cefsharp.example project, Defaulturl is the default home page URL address.
1PublicStaticClassCefexample2{3PublicConstString Defaulturl ="http://www.google.com/";4PrivateStaticReadOnlyBOOL Debuggingsubprocess =debugger.isattached;56PublicStaticvoidInit ()7{8var settings =NewCefsettings ();9 settings. Remotedebuggingport =8088;Ten settings. Cefcommandlineargs.add ("Enable-media-stream","Enable-media-stream");One by one settings. Ignorecertificateerrors =True;Settings. LogSeverity =Logseverity.verbose;1314If(debuggingsubprocess)15{16//var architecture = environment.is64bitprocess? "x64": "x86";17//Settings. Browsersubprocesspath = ". \\.. \\.. \\.. \\CefSharp.BrowserSubprocess\\bin\\ "+ architecture +" \\Debug\\CefSharp.BrowserSubprocess.exe ";18}19Settings. Registerscheme (NewCefcustomscheme21st{Schemename =Cefsharpschemehandlerfactory.schemename,Schemehandlerfactory =NewCefsharpschemehandlerfactory ()24});2526if (!Cef.initialize (Settings))27{28if (Environment.getcommandlineargs (). Contains ("--type=renderer) Span style= "color: #008080;" >29 {30 Environment.exit ( 0); 31 }32 else33 {34 return; }36 }37 }38}
Let's put in a release version, which probably has these files. Locales inside the localization resource pack, including cef_100_percent/cef_200_percent, if deleted, will appear such as window scroll bar appearance exception, Degug.log will record the operation record.
Run it and open a webpage.
Let's write another HTML page.
1<!DOCTYPE html>23<Html>4<Head>5<MetaHttp-equiv= "Content-type"Content= "text/html; Charset=utf-8 ">6<MetaId= "Viewport"Name= "Viewport"Content= "Width=device-width, initial-scale=1">7<Title></Title>8</Head>9<Body>10<VideoAutoPlay></Video>11<Script>12‘Use strict‘;1314VarVideo=Document.queryselector (‘Video‘);15VarConstraints={16AudioFalse,17VideoTrue18};1920Navigator.getusermedia=Navigator.getusermedia||Navigator.webkitgetusermedia||21stNavigator.mozgetusermedia;2223functionSuccesscallback (Stream) {24Window.stream=Stream25If(Window. URL) {26Video.src=Window. Url.createobjecturl (stream);27}Else{28Video.src=Stream29}30}3132functionErrorcallback (Error) {33 Console.log ( Navigator.getusermedia Error: ' error); 34 }35 36 Navigator.getusermedia (constraints, Successcallback, errorcallback); 37 </script>38 </body< Span style= "color: #0000ff;" >>39 </html< Span style= "color: #0000ff;" >>
Modify Cefexample's defaulturl to point to this page.
One thing to note is that the Enable-media-stream parameter is added to Cefcommandlineargs, which means to turn on Chrome's media stream. Look at the effect.
Here we use the HTML5 WEBRTC technology based on the chromium kernel, and the page opens the camera.
Here is a rough list of a small demo, as well as some basic mouse events, page redirection and other functions, in addition to chromium very functional API is worth learning and digging.
LIBCEF.DLL:CEF Core Library.
Icudt.dll: Encoded format Library.
Ffmpegsumo.dll: Video decoder, including VP8 VP9 encoding library.
D3dcompiler_43.dll, D3dcompiler_46.dll, LibEGL.dll, LibGLESv2.dll
These are the 3d graphics libraries, D3dcompiler_43.dll applies to xp,d3dcompiler_46 for versions above XP.
The Include folder is the CEF C + + header file that you can go to github to download. NET called Project, called Cefsharp, which provides a complete demo of WinForm and WPF.
Cefsharp: Encapsulation is the portal and data acceptance class for the C # call API.
Cefsharp.browsersubprocess: A companion process written by. NET that is primarily responsible for working with JavaScript and background threads.
CefSharp.BrowserSubprocess.Core: is a C + + project that needs to refer to the CEF C + + header file, mainly JavaScript related operations.
Cefsharp.core: Also a C + + project, including the initial configuration of CEF, accepting events, and so on.
Cefsharp.example:c# invokes the init configuration of CEF.
CefSharp.WinForm.Example: wrote a custom control as a window for the Cef browser.
ChromimumWebBrowser.cs the implementation of all interfaces can be placed here, see Cefsharp Demo.
Http://www.cnblogs.com/yuefei/p/4123597.html
1. Create a project
2. Modifying the properties target platform X64
3. Build
3. Copy the file to the x64 file
3. Add 3 references. Generated
5. Add a XMLN namespace
6. Add controls to generate
Cefsharp. Net