-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathRequestContextBuilder.cpp
More file actions
127 lines (96 loc) · 3.01 KB
/
RequestContextBuilder.cpp
File metadata and controls
127 lines (96 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Copyright © 2020 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#include "Stdafx.h"
#include "RequestContextBuilder.h"
#include "RequestContext.h"
namespace CefSharp
{
IRequestContext^ RequestContextBuilder::Create()
{
if (_otherContext != nullptr)
{
return gcnew RequestContext(_otherContext, _handler);
}
if(_settings != nullptr)
{
return gcnew RequestContext(_settings, _handler);
}
return gcnew RequestContext(_handler);
}
RequestContextBuilder^ RequestContextBuilder::OnInitialize(Action<IRequestContext^>^ action)
{
if (_handler == nullptr)
{
_handler = gcnew RequestContextHandler();
}
_handler->OnInitialize(action);
return this;
}
RequestContextBuilder^ RequestContextBuilder::WithPreference(String^ name, Object^ value)
{
if (_handler == nullptr)
{
_handler = gcnew RequestContextHandler();
}
_handler->SetPreferenceOnContextInitialized(name, value);
return this;
}
RequestContextBuilder^ RequestContextBuilder::WithProxyServer(String^ host)
{
if (_handler == nullptr)
{
_handler = gcnew RequestContextHandler();
}
_handler->SetProxyOnContextInitialized(host, Nullable<int>());
return this;
}
RequestContextBuilder^ RequestContextBuilder::WithProxyServer(String^ host, Nullable<int> port)
{
if (_handler == nullptr)
{
_handler = gcnew RequestContextHandler();
}
_handler->SetProxyOnContextInitialized(host, port);
return this;
}
RequestContextBuilder^ RequestContextBuilder::WithProxyServer(String^ scheme, String^ host, Nullable<int> port)
{
if (_handler == nullptr)
{
_handler = gcnew RequestContextHandler();
}
_handler->SetProxyOnContextInitialized(scheme, host, port);
return this;
}
RequestContextBuilder^ RequestContextBuilder::PersistUserPreferences()
{
ThrowExceptionIfContextAlreadySet();
if (_settings == nullptr)
{
_settings = gcnew RequestContextSettings();
}
_settings->PersistUserPreferences = true;
return this;
}
RequestContextBuilder^ RequestContextBuilder::WithCachePath(String^ cachePath)
{
ThrowExceptionIfContextAlreadySet();
if (_settings == nullptr)
{
_settings = gcnew RequestContextSettings();
}
_settings->CachePath = cachePath;
return this;
}
RequestContextBuilder^ RequestContextBuilder::WithSharedSettings(IRequestContext^ other)
{
if (other == nullptr)
{
throw gcnew ArgumentNullException("other");
}
ThrowExceptionIfCustomSettingSpecified();
_otherContext = other;
return this;
}
}