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

Method FindDialogWindowForProcess

cpp/iedriver/BrowserFactory.cpp:1237–1280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1235}
1236
1237BOOL CALLBACK BrowserFactory::FindDialogWindowForProcess(HWND hwnd, LPARAM arg) {
1238 ProcessWindowInfo* process_win_info = reinterpret_cast<ProcessWindowInfo*>(arg);
1239
1240 // Could this be an dialog window?
1241 // 7 == "#32770\0"
1242 // 29 == "Credential Dialog Xaml Host\0"
1243 // 34 == "Internet Explorer_TridentDlgFrame\0"
1244 char name[34];
1245 if (::GetClassNameA(hwnd, name, 34) == 0) {
1246 // No match found. Skip
1247 return TRUE;
1248 }
1249
1250 if (strcmp(ALERT_WINDOW_CLASS, name) != 0 &&
1251 strcmp(HTML_DIALOG_WINDOW_CLASS, name) != 0 &&
1252 strcmp(SECURITY_DIALOG_WINDOW_CLASS, name) != 0) {
1253 return TRUE;
1254 } else {
1255 // If the window style has the WS_DISABLED bit set or the
1256 // WS_VISIBLE bit unset, it can't be handled via the UI,
1257 // and must not be a visible dialog. Furthermore, if the
1258 // window style does not display a caption bar, it's not a
1259 // dialog displayed by the browser, but likely by an add-on
1260 // (like an antivirus toolbar). Note that checking the caption
1261 // window style is a hack, and may begin to fail if IE ever
1262 // changes the style of its alert windows.
1263 long window_long_style = ::GetWindowLong(hwnd, GWL_STYLE);
1264 if ((window_long_style & WS_DISABLED) != 0 ||
1265 (window_long_style & WS_VISIBLE) == 0 ||
1266 (window_long_style & WS_CAPTION) == 0) {
1267 return TRUE;
1268 }
1269 DWORD process_id = NULL;
1270 ::GetWindowThreadProcessId(hwnd, &process_id);
1271 if (process_win_info->dwProcessId == process_id) {
1272 // Once we've found the first dialog (#32770) window
1273 // for the process we want, we can stop.
1274 process_win_info->hwndBrowser = hwnd;
1275 return FALSE;
1276 }
1277 }
1278
1279 return TRUE;
1280}
1281
1282void BrowserFactory::GetIEExecutableLocation() {
1283 LOG(TRACE) << "Entering BrowserFactory::GetIEExecutableLocation";

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected