22
22
namespace OpenQA . Selenium . DevTools
23
23
{
24
24
/// <summary>
25
- /// Interface providing functionality for manipulating network calls using DevTools Protocol commands
25
+ /// Class providing functionality for manipulating network calls using DevTools Protocol commands
26
26
/// </summary>
27
- public interface INetwork
27
+ public abstract class Network
28
28
{
29
29
/// <summary>
30
30
/// Occurs when a network request requires authorization.
31
31
/// </summary>
32
- event EventHandler < AuthRequiredEventArgs > AuthRequired ;
32
+ public event EventHandler < AuthRequiredEventArgs > AuthRequired ;
33
33
34
34
/// <summary>
35
35
/// Occurs when a network request is intercepted.
36
36
/// </summary>
37
- event EventHandler < RequestPausedEventArgs > RequestPaused ;
37
+ public event EventHandler < RequestPausedEventArgs > RequestPaused ;
38
38
39
39
/// <summary>
40
40
/// Asynchronously disables network caching.
41
41
/// </summary>
42
42
/// <returns>A task that represents the asynchronous operation.</returns>
43
- Task DisableNetworkCaching ( ) ;
43
+ public abstract Task DisableNetworkCaching ( ) ;
44
44
45
45
/// <summary>
46
46
/// Asynchronously enables network caching.
47
47
/// </summary>
48
48
/// <returns>A task that represents the asynchronous operation.</returns>
49
- Task EnableNetworkCaching ( ) ;
49
+ public abstract Task EnableNetworkCaching ( ) ;
50
50
51
51
/// <summary>
52
52
/// Asynchronously enables the fetch domain for all URL patterns.
53
53
/// </summary>
54
54
/// <returns>A task that represents the asynchronous operation.</returns>
55
- Task EnableFetchForAllPatterns ( ) ;
55
+ public abstract Task EnableFetchForAllPatterns ( ) ;
56
56
57
57
/// <summary>
58
58
/// Asynchronously diables the fetch domain.
59
59
/// </summary>
60
60
/// <returns>A task that represents the asynchronous operation.</returns>
61
- Task DisableFetch ( ) ;
61
+ public abstract Task DisableFetch ( ) ;
62
62
63
63
/// <summary>
64
64
/// Asynchronously continues an intercepted network request.
65
65
/// </summary>
66
66
/// <param name="requestData">The <see cref="HttpRequestData"/> of the request.</param>
67
67
/// <param name="responseData">The <see cref="HttpResponseData"/> with which to respond to the request</param>
68
68
/// <returns>A task that represents the asynchronous operation.</returns>
69
- Task ContinueRequest ( HttpRequestData requestData , HttpResponseData responseData ) ;
69
+ public abstract Task ContinueRequest ( HttpRequestData requestData , HttpResponseData responseData ) ;
70
70
71
71
/// <summary>
72
72
/// Asynchronously contines an intercepted network call without modification.
73
73
/// </summary>
74
74
/// <param name="requestData">The <see cref="HttpRequestData"/> of the network request.</param>
75
75
/// <returns>A task that represents the asynchronous operation.</returns>
76
- Task ContinueWithoutModification ( HttpRequestData requestData ) ;
76
+ public abstract Task ContinueWithoutModification ( HttpRequestData requestData ) ;
77
77
78
78
/// <summary>
79
79
/// Asynchronously continues an intercepted network call using authentication.
@@ -82,13 +82,29 @@ public interface INetwork
82
82
/// <param name="userName">The user name with which to authenticate.</param>
83
83
/// <param name="password">The password with which to authenticate.</param>
84
84
/// <returns>A task that represents the asynchronous operation.</returns>
85
- Task ContinueWithAuth ( HttpRequestData requestData , string userName , string password ) ;
85
+ public abstract Task ContinueWithAuth ( HttpRequestData requestData , string userName , string password ) ;
86
86
87
87
/// <summary>
88
88
/// Asynchronously cancels authorization of an intercepted network request.
89
89
/// </summary>
90
90
/// <param name="requestData">The <see cref="HttpRequestData"/> of the network request.</param>
91
91
/// <returns>A task that represents the asynchronous operation.</returns>
92
- Task CancelAuth ( HttpRequestData requestData ) ;
92
+ public abstract Task CancelAuth ( HttpRequestData requestData ) ;
93
+
94
+ protected virtual void OnAuthRequired ( AuthRequiredEventArgs e )
95
+ {
96
+ if ( this . AuthRequired != null )
97
+ {
98
+ this . AuthRequired ( this , e ) ;
99
+ }
100
+ }
101
+
102
+ protected virtual void OnRequestPaused ( RequestPausedEventArgs e )
103
+ {
104
+ if ( this . RequestPaused != null )
105
+ {
106
+ this . RequestPaused ( this , e ) ;
107
+ }
108
+ }
93
109
}
94
110
}
0 commit comments