| 493 | } |
| 494 | |
| 495 | bool BrowserFactory::AttachToBrowser(ProcessWindowInfo* process_window_info, |
| 496 | std::string* error_message) { |
| 497 | LOG(TRACE) << "Entering BrowserFactory::AttachToBrowser"; |
| 498 | bool attached = false; |
| 499 | |
| 500 | // Attempt to attach to the browser using ActiveAccessibility API |
| 501 | // first, if this fails fallback to using ShellWindows API. |
| 502 | // ActiveAccessibility fails if the Windows Desktop runs out of |
| 503 | // free space for GlobalAtoms. |
| 504 | // ShellWindows might fail if there is an IE modal dialog blocking |
| 505 | // execution (unverified). |
| 506 | if (!this->force_shell_windows_api_) { |
| 507 | LOG(DEBUG) << "Using Active Accessibility to find IWebBrowser2 interface"; |
| 508 | attached = this->AttachToBrowserUsingActiveAccessibility(process_window_info, |
| 509 | error_message); |
| 510 | if (!attached) { |
| 511 | LOG(DEBUG) << "Failed to find IWebBrowser2 using ActiveAccessibility: " |
| 512 | << *error_message; |
| 513 | // Reset the browser window handle to NULL, since we didn't attach |
| 514 | // using Active Accessibility. |
| 515 | process_window_info->hwndBrowser = NULL; |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | if (!attached) { |
| 520 | LOG(DEBUG) << "Using IShellWindows to find IWebBrowser2 interface"; |
| 521 | attached = this->AttachToBrowserUsingShellWindows(process_window_info, |
| 522 | error_message); |
| 523 | } |
| 524 | |
| 525 | if (attached) { |
| 526 | // Test for zoom level = 100% |
| 527 | int zoom_level = 100; |
| 528 | LOG(DEBUG) << "Ignoring zoom setting: " << this->ignore_zoom_setting_; |
| 529 | if (!this->ignore_zoom_setting_) { |
| 530 | zoom_level = this->GetBrowserZoomLevel(process_window_info->pBrowser); |
| 531 | } |
| 532 | if (zoom_level != 100) { |
| 533 | std::string zoom_level_error = |
| 534 | StringUtilities::Format(ZOOM_SETTING_ERROR_MESSAGE, zoom_level); |
| 535 | LOG(WARN) << zoom_level_error; |
| 536 | *error_message = zoom_level_error; |
| 537 | return false; |
| 538 | } |
| 539 | } |
| 540 | return attached; |
| 541 | } |
| 542 | |
| 543 | |
| 544 | bool BrowserFactory::IsBrowserProcessInitialized(DWORD process_id) { |
no test coverage detected