Skip to content

Commit 6b9aeba

Browse files
committed
Merge branch 'CefSharp3' of https://github.com/uowzd01/CefSharp into uowzd01-CefSharp3
2 parents 4c958cd + 9fdb3fd commit 6b9aeba

File tree

13 files changed

+674
-124
lines changed

13 files changed

+674
-124
lines changed

CefSharp.Example/ExamplePresenter.cs

Lines changed: 117 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
using System;
2+
using System.ComponentModel;
3+
using System.IO;
24
using System.Linq;
5+
using System.Net;
6+
using System.Text;
37

48
namespace CefSharp.Example
59
{
6-
public class ExamplePresenter
10+
public class ExamplePresenter : IRequestHandler
711
{
812
// Use when debugging the actual SubProcess, to make breakpoints etc. inside that project work.
913
private const bool debuggingSubProcess = false;
@@ -43,7 +47,7 @@ public static void Init()
4347
}
4448

4549
public static string DefaultUrl = "custom://cefsharp/home";
46-
// private static readonly Uri resource_url = new Uri("http://test/resource/load");
50+
private static readonly Uri resource_url = new Uri("http://test/resource/load");
4751
// private static readonly Uri scheme_url = new Uri("test://test/SchemeTest.html");
4852
// private static readonly Uri bind_url = new Uri("test://test/BindingTest.html");
4953
// private static readonly Uri tooltip_url = new Uri("test://test/TooltipTest.html");
@@ -57,84 +61,88 @@ public static void Init()
5761
// "green",
5862
// };
5963

60-
// private readonly IWebBrowser model;
61-
// private readonly IExampleView view;
62-
// private readonly Action<Action> uiThreadInvoke;
64+
private readonly IWebBrowser model;
65+
private readonly IExampleView view;
66+
private readonly Action<Action> uiThreadInvoke;
6367

64-
// public ExamplePresenter(IWebBrowser model, IExampleView view, Action<Action> uiThreadInvoke)
65-
// {
66-
// this.model = model;
67-
// this.view = view;
68-
// this.uiThreadInvoke = uiThreadInvoke;
69-
70-
// model.RequestHandler = this;
71-
// model.PropertyChanged += OnModelPropertyChanged;
72-
// model.ConsoleMessage += OnModelConsoleMessage;
73-
74-
// // file
75-
// view.ShowDevToolsActivated += OnViewShowDevToolsActivated;
76-
// view.CloseDevToolsActivated += OnViewCloseDevToolsActivated;
77-
// view.ExitActivated += OnViewExitActivated;
78-
79-
// // edit
80-
// view.UndoActivated += OnViewUndoActivated;
81-
// view.RedoActivated += OnViewRedoActivated;
82-
// view.CutActivated += OnViewCutActivated;
83-
// view.CopyActivated += OnViewCopyActivated;
84-
// view.PasteActivated += OnViewPasteActivated;
85-
// view.DeleteActivated += OnViewDeleteActivated;
86-
// view.SelectAllActivated += OnViewSelectAllActivated;
87-
88-
// // test
89-
// view.TestResourceLoadActivated += OnViewTestResourceLoadActivated;
90-
// view.TestSchemeLoadActivated += OnViewTestSchemeLoadActivated;
91-
// view.TestExecuteScriptActivated += OnViewTestExecuteScriptActivated;
92-
// view.TestEvaluateScriptActivated += OnViewTestEvaluateScriptActivated;
93-
// view.TestBindActivated += OnViewTestBindActivated;
94-
// view.TestConsoleMessageActivated += OnViewTestConsoleMessageActivated;
95-
// view.TestTooltipActivated += OnViewTestTooltipActivated;
96-
// view.TestPopupActivated += OnViewTestPopupActivated;
97-
// view.TestLoadStringActivated += OnViewTestLoadStringActivated;
98-
// view.TestCookieVisitorActivated += OnViewTestCookieVisitorActivated;
99-
100-
// // navigation
101-
// view.UrlActivated += OnViewUrlActivated;
102-
// view.ForwardActivated += OnViewForwardActivated;
103-
// view.BackActivated += OnViewBackActivated;
104-
// }
68+
public ExamplePresenter(IWebBrowser model, IExampleView view, Action<Action> uiThreadInvoke)
69+
{
70+
this.model = model;
71+
this.view = view;
72+
this.uiThreadInvoke = uiThreadInvoke;
73+
74+
var version = String.Format("Chromium: {0}, CEF: {1}, CefSharp: {2}",
75+
Cef.ChromiumVersion, Cef.CefVersion, Cef.CefSharpVersion);
76+
view.DisplayOutput(version);
77+
78+
model.RequestHandler = this;
79+
model.PropertyChanged += OnModelPropertyChanged;
80+
//model.ConsoleMessage += OnModelConsoleMessage;
81+
82+
//// file
83+
//view.ShowDevToolsActivated += OnViewShowDevToolsActivated;
84+
//view.CloseDevToolsActivated += OnViewCloseDevToolsActivated;
85+
//view.ExitActivated += OnViewExitActivated;
86+
87+
//// edit
88+
//view.UndoActivated += OnViewUndoActivated;
89+
//view.RedoActivated += OnViewRedoActivated;
90+
//view.CutActivated += OnViewCutActivated;
91+
//view.CopyActivated += OnViewCopyActivated;
92+
//view.PasteActivated += OnViewPasteActivated;
93+
//view.DeleteActivated += OnViewDeleteActivated;
94+
//view.SelectAllActivated += OnViewSelectAllActivated;
95+
96+
//// test
97+
//view.TestResourceLoadActivated += OnViewTestResourceLoadActivated;
98+
//view.TestSchemeLoadActivated += OnViewTestSchemeLoadActivated;
99+
//view.TestExecuteScriptActivated += OnViewTestExecuteScriptActivated;
100+
//view.TestEvaluateScriptActivated += OnViewTestEvaluateScriptActivated;
101+
//view.TestBindActivated += OnViewTestBindActivated;
102+
//view.TestConsoleMessageActivated += OnViewTestConsoleMessageActivated;
103+
//view.TestTooltipActivated += OnViewTestTooltipActivated;
104+
//view.TestPopupActivated += OnViewTestPopupActivated;
105+
//view.TestLoadStringActivated += OnViewTestLoadStringActivated;
106+
//view.TestCookieVisitorActivated += OnViewTestCookieVisitorActivated;
107+
108+
//// navigation
109+
view.UrlActivated += OnViewUrlActivated;
110+
//view.ForwardActivated += OnViewForwardActivated;
111+
//view.BackActivated += OnViewBackActivated;
112+
}
105113

106-
// private void OnModelPropertyChanged(object sender, PropertyChangedEventArgs e)
107-
// {
108-
// switch (e.PropertyName)
109-
// {
110-
// case "IsBrowserInitialized":
111-
// if (model.IsBrowserInitialized)
112-
// {
113-
// //model.Load(DefaultUrl);
114-
// }
115-
// break;
116-
117-
// case "Title":
118-
// uiThreadInvoke(() => view.SetTitle(model.Title));
119-
// break;
120-
121-
// case "Uri":
122-
// uiThreadInvoke(() => view.SetAddress(model.Address));
123-
// break;
124-
125-
// case "CanGoBack":
126-
// uiThreadInvoke(() => view.SetCanGoBack(model.CanGoBack));
127-
// break;
128-
129-
// case "CanGoForward":
130-
// uiThreadInvoke(() => view.SetCanGoForward(model.CanGoForward));
131-
// break;
132-
133-
// case "IsLoading":
134-
// uiThreadInvoke(() => view.SetIsLoading(model.IsLoading));
135-
// break;
136-
// }
137-
// }
114+
private void OnModelPropertyChanged(object sender, PropertyChangedEventArgs e)
115+
{
116+
switch (e.PropertyName)
117+
{
118+
//case "IsBrowserInitialized":
119+
// if (model.IsBrowserInitialized)
120+
// {
121+
// //model.Load(DefaultUrl);
122+
// }
123+
// break;
124+
125+
case "Title":
126+
uiThreadInvoke(() => view.SetTitle(model.Title));
127+
break;
128+
129+
case "Address":
130+
uiThreadInvoke(() => view.SetAddress(model.Address));
131+
break;
132+
133+
case "CanGoBack":
134+
uiThreadInvoke(() => view.SetCanGoBack(model.CanGoBack));
135+
break;
136+
137+
case "CanGoForward":
138+
uiThreadInvoke(() => view.SetCanGoForward(model.CanGoForward));
139+
break;
140+
141+
case "IsLoading":
142+
uiThreadInvoke(() => view.SetIsLoading(model.IsLoading));
143+
break;
144+
}
145+
}
138146

139147
// private void OnModelConsoleMessage(object sender, ConsoleMessageEventArgs e)
140148
// {
@@ -265,10 +273,10 @@ public static void Init()
265273
// Cef.VisitAllCookies(this);
266274
// }
267275

268-
// private void OnViewUrlActivated(object sender, string address)
269-
// {
270-
// //model.Load(address);
271-
// }
276+
private void OnViewUrlActivated(object sender, string address)
277+
{
278+
model.Load(address);
279+
}
272280

273281
// private void OnViewBackActivated(object sender, EventArgs e)
274282
// {
@@ -280,39 +288,39 @@ public static void Init()
280288
// model.Forward();
281289
// }
282290

283-
// bool IRequestHandler.OnBeforeBrowse(IWebBrowser browser, IRequest request, NavigationType naigationvType, bool isRedirect)
284-
// {
285-
// return false;
286-
// }
291+
bool IRequestHandler.OnBeforeBrowse(IWebBrowser browser, IRequest request, NavigationType naigationvType, bool isRedirect)
292+
{
293+
return false;
294+
}
287295

288-
// bool IRequestHandler.OnBeforeResourceLoad(IWebBrowser browser, IRequestResponse requestResponse)
289-
// {
290-
// IRequest request = requestResponse.Request;
291-
// if (request.Url.StartsWith(resource_url.ToString()))
292-
// {
293-
// Stream resourceStream = new MemoryStream(Encoding.UTF8.GetBytes(
294-
// "<html><body><h1>Success</h1><p>This document is loaded from a System.IO.Stream</p></body></html>"));
295-
// requestResponse.RespondWith(resourceStream, "text/html");
296-
// }
296+
bool IRequestHandler.OnBeforeResourceLoad(IWebBrowser browser, IRequestResponse requestResponse)
297+
{
298+
IRequest request = requestResponse.Request;
299+
if (request.Url.StartsWith(resource_url.ToString()))
300+
{
301+
Stream resourceStream = new MemoryStream(Encoding.UTF8.GetBytes(
302+
"<html><body><h1>Success</h1><p>This document is loaded from a System.IO.Stream</p></body></html>"));
303+
requestResponse.RespondWith(resourceStream, "text/html");
304+
}
297305

298-
// return false;
299-
// }
306+
return false;
307+
}
300308

301-
// void IRequestHandler.OnResourceResponse(IWebBrowser browser, string url, int status, string statusText, string mimeType, WebHeaderCollection headers)
302-
// {
309+
void IRequestHandler.OnResourceResponse(IWebBrowser browser, string url, int status, string statusText, string mimeType, WebHeaderCollection headers)
310+
{
303311

304-
// }
312+
}
305313

306-
// bool IRequestHandler.GetDownloadHandler(IWebBrowser browser, out IDownloadHandler handler)
307-
// {
308-
// handler = new DownloadHandler();
309-
// return true;
310-
// }
314+
bool IRequestHandler.GetDownloadHandler(IWebBrowser browser, out IDownloadHandler handler)
315+
{
316+
handler = new DownloadHandler();
317+
return true;
318+
}
311319

312-
// bool IRequestHandler.GetAuthCredentials(IWebBrowser browser, bool isProxy, string host, int port, string realm, string scheme, ref string username, ref string password)
313-
// {
314-
// return false;
315-
// }
320+
bool IRequestHandler.GetAuthCredentials(IWebBrowser browser, bool isProxy, string host, int port, string realm, string scheme, ref string username, ref string password)
321+
{
322+
return false;
323+
}
316324

317325
// bool ICookieVisitor.Visit(Cookie cookie, int count, int total, ref bool deleteCookie)
318326
// {
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{882505AD-246D-402A-8414-347EFB8E2C8D}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>CefSharp.WinForm</RootNamespace>
11+
<AssemblyName>CefSharp.WinForm</AssemblyName>
12+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
<PlatformTarget>x86</PlatformTarget>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
35+
<PlatformTarget>x64</PlatformTarget>
36+
<OutputPath>bin\x64\Debug\</OutputPath>
37+
</PropertyGroup>
38+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
39+
<PlatformTarget>x64</PlatformTarget>
40+
<OutputPath>bin\x64\Release\</OutputPath>
41+
</PropertyGroup>
42+
<PropertyGroup>
43+
<SignAssembly>true</SignAssembly>
44+
</PropertyGroup>
45+
<PropertyGroup>
46+
<AssemblyOriginatorKeyFile>..\CefSharp.snk</AssemblyOriginatorKeyFile>
47+
</PropertyGroup>
48+
<ItemGroup>
49+
<Reference Include="System" />
50+
<Reference Include="System.Core" />
51+
<Reference Include="System.Windows.Forms" />
52+
<Reference Include="System.Xml.Linq" />
53+
<Reference Include="System.Data.DataSetExtensions" />
54+
<Reference Include="Microsoft.CSharp" />
55+
<Reference Include="System.Data" />
56+
<Reference Include="System.Xml" />
57+
</ItemGroup>
58+
<ItemGroup>
59+
<Compile Include="Properties\AssemblyInfo.cs" />
60+
<Compile Include="WebView.cs">
61+
<SubType>Component</SubType>
62+
</Compile>
63+
</ItemGroup>
64+
<ItemGroup>
65+
<ProjectReference Include="..\CefSharp\CefSharp.vcxproj">
66+
<Project>{7b495581-2271-4f41-9476-acb86e8c864f}</Project>
67+
<Name>CefSharp</Name>
68+
</ProjectReference>
69+
</ItemGroup>
70+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
71+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
72+
Other similar extension points exist, see Microsoft.Common.targets.
73+
<Target Name="BeforeBuild">
74+
</Target>
75+
<Target Name="AfterBuild">
76+
</Target>
77+
-->
78+
</Project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("CefSharp.WinForm")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("Health Communication Network")]
12+
[assembly: AssemblyProduct("CefSharp.WinForm")]
13+
[assembly: AssemblyCopyright("Copyright © Health Communication Network 2013")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("eee96178-7e5c-49a2-854c-b2fabe0b8ecf")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)