MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / RestoreProxySettings

Method RestoreProxySettings

cpp/iedriver/ProxyManager.cpp:189–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187}
188
189void ProxyManager::RestoreProxySettings() {
190 LOG(TRACE) << "ProxyManager::RestoreProxySettings";
191 bool settings_restored = (!this->use_per_process_proxy_ && this->is_proxy_modified_) || this->is_proxy_authorization_modified_;
192 if (!this->use_per_process_proxy_ && this->is_proxy_modified_) {
193 INTERNET_PER_CONN_OPTION_LIST option_list;
194 std::vector<INTERNET_PER_CONN_OPTION> restore_options(5);
195 unsigned long list_size = sizeof(INTERNET_PER_CONN_OPTION_LIST);
196
197 std::vector<wchar_t> autoconfig_url_buffer;
198 StringUtilities::ToBuffer(this->current_autoconfig_url_, &autoconfig_url_buffer);
199 restore_options[0].dwOption = INTERNET_PER_CONN_AUTOCONFIG_URL;
200 restore_options[0].Value.pszValue = &autoconfig_url_buffer[0];
201
202 restore_options[1].dwOption = INTERNET_PER_CONN_AUTODISCOVERY_FLAGS;
203 restore_options[1].Value.dwValue = this->current_proxy_auto_detect_flags_;
204
205 restore_options[2].dwOption = INTERNET_PER_CONN_FLAGS;
206 restore_options[2].Value.dwValue = this->current_proxy_type_;
207
208 std::vector<wchar_t> proxy_bypass_buffer;
209 StringUtilities::ToBuffer(this->current_proxy_bypass_list_, &proxy_bypass_buffer);
210 restore_options[3].dwOption = INTERNET_PER_CONN_PROXY_BYPASS;
211 restore_options[3].Value.pszValue = &proxy_bypass_buffer[0];
212
213 std::vector<wchar_t> proxy_server_buffer;
214 StringUtilities::ToBuffer(this->current_proxy_server_, &proxy_server_buffer);
215 restore_options[4].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
216 restore_options[4].Value.pszValue = &proxy_server_buffer[0];
217
218 option_list.dwSize = sizeof(INTERNET_PER_CONN_OPTION_LIST);
219 option_list.pszConnection = NULL;
220 option_list.dwOptionCount = static_cast<int>(restore_options.size());
221 option_list.dwOptionError = 0;
222 option_list.pOptions = &restore_options[0];
223
224 BOOL success = ::InternetSetOption(NULL,
225 INTERNET_OPTION_PER_CONNECTION_OPTION,
226 &option_list,
227 list_size);
228 if (!success) {
229 LOGERR(WARN) << "InternetSetOption failed setting INTERNET_OPTION_PER_CONNECTION_OPTION";
230 }
231 this->is_proxy_modified_ = false;
232 }
233 if (this->is_proxy_authorization_modified_) {
234 this->SetProxyAuthentication(this->current_socks_user_name_,
235 this->current_socks_password_);
236 this->is_proxy_authorization_modified_ = false;
237 }
238 if (settings_restored) {
239 BOOL notify_success = ::InternetSetOption(NULL,
240 INTERNET_OPTION_PROXY_SETTINGS_CHANGED,
241 NULL,
242 0);
243 if (!notify_success) {
244 LOGERR(WARN) << "InternetSetOption failed setting INTERNET_OPTION_PROXY_SETTINGS_CHANGED";
245 }
246 }

Callers 1

~ProxyManagerMethod · 0.95

Calls 3

LOGClass · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected