| 247 | } |
| 248 | |
| 249 | void ProxyManager::SetPerProcessProxySettings(HWND browser_window_handle) { |
| 250 | LOG(TRACE) << "ProxyManager::SetPerProcessProxySettings"; |
| 251 | std::wstring proxy = this->BuildProxySettingsString(); |
| 252 | |
| 253 | HookSettings hook_settings; |
| 254 | hook_settings.window_handle = browser_window_handle; |
| 255 | hook_settings.hook_procedure_name = "SetProxyWndProc"; |
| 256 | hook_settings.hook_procedure_type = WH_CALLWNDPROC; |
| 257 | hook_settings.communication_type = OneWay; |
| 258 | |
| 259 | HookProcessor hook; |
| 260 | if (!hook.CanSetWindowsHook(browser_window_handle)) { |
| 261 | LOG(WARN) << "Proxy will not be set! There is a mismatch in the " |
| 262 | << "bitness between the driver and browser. In particular, " |
| 263 | << "be sure you are not attempting to use a 64-bit " |
| 264 | << "IEDriverServer.exe against IE 10 or 11, even on 64-bit " |
| 265 | << "Windows."; |
| 266 | } |
| 267 | hook.Initialize(hook_settings); |
| 268 | hook.PushData(proxy); |
| 269 | LRESULT result = ::SendMessage(browser_window_handle, |
| 270 | WD_CHANGE_PROXY, |
| 271 | NULL, |
| 272 | NULL); |
| 273 | |
| 274 | if (this->socks_proxy_.size() > 0 && |
| 275 | (this->socks_user_name_.size() > 0 || this->socks_password_.size() > 0)) { |
| 276 | LOG(WARN) << "Windows APIs provide no way to set proxy user name and " |
| 277 | << "password on a per-process basis. Setting global setting."; |
| 278 | |
| 279 | this->SetProxyAuthentication(StringUtilities::ToWString(this->socks_user_name_), |
| 280 | StringUtilities::ToWString(this->socks_password_)); |
| 281 | this->is_proxy_authorization_modified_ = true; |
| 282 | |
| 283 | // Notify WinINet clients that the proxy options have changed. |
| 284 | BOOL success = ::InternetSetOption(NULL, |
| 285 | INTERNET_OPTION_PROXY_SETTINGS_CHANGED, |
| 286 | NULL, |
| 287 | 0); |
| 288 | if (!success) { |
| 289 | LOGERR(WARN) << "InternetSetOption failed setting INTERNET_OPTION_PROXY_SETTINGS_CHANGED"; |
| 290 | } |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | void ProxyManager::SetGlobalProxySettings() { |
| 295 | LOG(TRACE) << "ProxyManager::SetGlobalProxySettings"; |
no test coverage detected