Skip to content

Commit 37ef2b4

Browse files
committed
Add IRequest.ResourceType
1 parent ad5eef2 commit 37ef2b4

File tree

5 files changed

+90
-0
lines changed

5 files changed

+90
-0
lines changed

CefSharp.Core/Internals/CefRequestWrapper.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ namespace CefSharp
6565
return StringUtils::ToClr(_wrappedRequest->GetReferrerURL());
6666
}
6767

68+
CefSharp::ResourceType CefRequestWrapper::ResourceType::get()
69+
{
70+
ThrowIfDisposed();
71+
72+
return (CefSharp::ResourceType)_wrappedRequest->GetResourceType();
73+
}
74+
6875
CefSharp::ReferrerPolicy CefRequestWrapper::ReferrerPolicy::get()
6976
{
7077
ThrowIfDisposed();

CefSharp.Core/Internals/CefRequestWrapper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ namespace CefSharp
4444
virtual property String^ Method { String^ get(); void set(String^ method); }
4545
virtual void SetReferrer(String^ referrerUrl, CefSharp::ReferrerPolicy policy);
4646
virtual property String^ ReferrerUrl { String^ get(); }
47+
virtual property ResourceType ResourceType { CefSharp::ResourceType get(); }
4748
virtual property ReferrerPolicy ReferrerPolicy { CefSharp::ReferrerPolicy get(); }
4849
virtual property NameValueCollection^ Headers { NameValueCollection^ get(); void set(NameValueCollection^ url); }
4950
virtual property TransitionType TransitionType { CefSharp::TransitionType get(); }

CefSharp/CefSharp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@
178178
<Compile Include="ReferrerPolicy.cs" />
179179
<Compile Include="ResourceHandler.cs" />
180180
<Compile Include="ResourceHandlerType.cs" />
181+
<Compile Include="ResourceType.cs" />
181182
<Compile Include="ResponseAction.cs" />
182183
<Compile Include="Internals\ScreenInfo.cs" />
183184
<Compile Include="TaskCompletionHandler.cs" />

CefSharp/IRequest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ public interface IRequest : IDisposable
3333
/// </summary>
3434
string ReferrerUrl { get; }
3535

36+
/// <summary>
37+
/// Get the resource type for this request.
38+
/// </summary>
39+
ResourceType ResourceType { get; }
3640

3741
/// <summary>
3842
/// Get the referrer policy.

CefSharp/ResourceType.cs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// Copyright © 2010-2016 The CefSharp Authors. All rights reserved.
2+
//
3+
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4+
5+
namespace CefSharp
6+
{
7+
/// <summary>
8+
/// Resource type for a request.
9+
/// </summary>
10+
public enum ResourceType
11+
{
12+
/// <summary>
13+
/// Top level page.
14+
/// </summary>
15+
MainFrame = 0,
16+
/// <summary>
17+
/// Frame or iframe.
18+
/// </summary>
19+
SubFrame,
20+
/// <summary>
21+
/// CSS stylesheet.
22+
/// </summary>
23+
Stylesheet,
24+
/// <summary>
25+
/// External script.
26+
/// </summary>
27+
Script,
28+
/// <summary>
29+
/// Image (jpg/gif/png/etc).
30+
/// </summary>
31+
Image,
32+
/// <summary>
33+
/// Font.
34+
/// </summary>
35+
FontResource,
36+
/// <summary>
37+
/// Some other subresource. This is the default type if the actual type is unknown.
38+
/// </summary>
39+
SubResource,
40+
/// <summary>
41+
/// Object (or embed) tag for a plugin, or a resource that a plugin requested.
42+
/// </summary>
43+
Object,
44+
/// <summary>
45+
/// Media resource.
46+
/// </summary>
47+
Media,
48+
/// <summary>
49+
/// Main resource of a dedicated worker.
50+
/// </summary>
51+
Worker,
52+
/// <summary>
53+
/// Main resource of a shared worker.
54+
/// </summary>
55+
SharedWorker,
56+
/// <summary>
57+
/// Explicitly requested prefetch.
58+
/// </summary>
59+
Prefetch,
60+
/// <summary>
61+
/// Favicon.
62+
/// </summary>
63+
Favicon,
64+
/// <summary>
65+
/// XMLHttpRequest.
66+
/// </summary>
67+
Xhr,
68+
/// <summary>
69+
/// A request for a ping
70+
/// </summary>
71+
Ping,
72+
/// <summary>
73+
/// Main resource of a service worker.
74+
/// </summary>
75+
ServiceWorker,
76+
}
77+
}

0 commit comments

Comments
 (0)