| 152 | } |
| 153 | |
| 154 | DWORD BrowserFactory::LaunchBrowserProcess(std::string* error_message) { |
| 155 | LOG(TRACE) << "Entering BrowserFactory::LaunchBrowserProcess"; |
| 156 | |
| 157 | DWORD process_id = NULL; |
| 158 | bool has_valid_protected_mode_settings = false; |
| 159 | LOG(DEBUG) << "Ignoring Protected Mode Settings: " |
| 160 | << this->ignore_protected_mode_settings_; |
| 161 | if (!this->ignore_protected_mode_settings_) { |
| 162 | LOG(DEBUG) << "Checking validity of Protected Mode settings."; |
| 163 | has_valid_protected_mode_settings = this->ProtectedModeSettingsAreValid(); |
| 164 | } |
| 165 | LOG(DEBUG) << "Has Valid Protected Mode Settings: " |
| 166 | << has_valid_protected_mode_settings; |
| 167 | if (this->ignore_protected_mode_settings_ || has_valid_protected_mode_settings) { |
| 168 | // Determine which launch API to use. |
| 169 | bool use_createprocess_api = false; |
| 170 | if (this->force_createprocess_api_) { |
| 171 | if (this->IsCreateProcessApiAvailable()) { |
| 172 | use_createprocess_api = true; |
| 173 | } else { |
| 174 | // The only time IsCreateProcessApiAvailable will return false |
| 175 | // is when the user is using IE 8 or higher, and does not have |
| 176 | // the correct registry key setting to force the same process |
| 177 | // for the enclosing window and tab processes. |
| 178 | *error_message = CREATEPROCESS_REGISTRY_ERROR_MESSAGE; |
| 179 | return NULL; |
| 180 | } |
| 181 | } else { |
| 182 | // If we have the IELaunchURL API, expressly use it. Otherwise, |
| 183 | // fall back to using CreateProcess(). |
| 184 | if (!this->IsIELaunchURLAvailable()) { |
| 185 | use_createprocess_api = true; |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | this->ClearCache(); |
| 190 | |
| 191 | PROCESS_INFORMATION proc_info; |
| 192 | ::ZeroMemory(&proc_info, sizeof(proc_info)); |
| 193 | |
| 194 | if (this->edge_ie_mode_) { |
| 195 | this->LaunchEdgeInIEMode(&proc_info, error_message); |
| 196 | } else if (!use_createprocess_api) { |
| 197 | this->LaunchBrowserUsingIELaunchURL(&proc_info, error_message); |
| 198 | } else { |
| 199 | this->LaunchBrowserUsingCreateProcess(&proc_info, error_message); |
| 200 | } |
| 201 | |
| 202 | process_id = proc_info.dwProcessId; |
| 203 | if (process_id == NULL) { |
| 204 | // If whatever API we are using failed to launch the browser, we should |
| 205 | // have a NULL value in the dwProcessId member of the PROCESS_INFORMATION |
| 206 | // structure. In that case, we will have already set the approprate error |
| 207 | // message. On the off chance that we haven't yet set the appropriate |
| 208 | // error message, that means we successfully launched the browser (i.e., |
| 209 | // the browser launch API returned a success code), but we still have a |
| 210 | // NULL process ID. |
| 211 | if (error_message->size() == 0) { |
no test coverage detected