| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome_frame/chrome_frame_automation.h" | 5 #include "chrome_frame/chrome_frame_automation.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 std::string channel_id = AutomationProxy::GenerateChannelID(); | 242 std::string channel_id = AutomationProxy::GenerateChannelID(); |
| 243 ChromeFrameAutomationProxyImpl* proxy = | 243 ChromeFrameAutomationProxyImpl* proxy = |
| 244 new ChromeFrameAutomationProxyImpl(this, channel_id, | 244 new ChromeFrameAutomationProxyImpl(this, channel_id, |
| 245 params->launch_timeout()); | 245 params->launch_timeout()); |
| 246 | 246 |
| 247 // Ensure that the automation proxy actually respects our choice on whether | 247 // Ensure that the automation proxy actually respects our choice on whether |
| 248 // or not to check the version. | 248 // or not to check the version. |
| 249 proxy->set_perform_version_check(params->version_check()); | 249 proxy->set_perform_version_check(params->version_check()); |
| 250 | 250 |
| 251 // Launch browser | 251 // Launch browser |
| 252 scoped_ptr<CommandLine> command_line( | 252 std::wstring command_line_string; |
| 253 chrome_launcher::CreateLaunchCommandLine()); | 253 scoped_ptr<CommandLine> command_line; |
| 254 command_line->AppendSwitchASCII(switches::kAutomationClientChannelID, | 254 if (chrome_launcher::CreateLaunchCommandLine(&command_line)) { |
| 255 channel_id); | 255 command_line->AppendSwitchASCII(switches::kAutomationClientChannelID, |
| 256 channel_id); |
| 256 | 257 |
| 257 // Run Chrome in Chrome Frame mode. In practice, this modifies the paths | 258 // Run Chrome in Chrome Frame mode. In practice, this modifies the paths |
| 258 // and registry keys that Chrome looks in via the BrowserDistribution | 259 // and registry keys that Chrome looks in via the BrowserDistribution |
| 259 // mechanism. | 260 // mechanism. |
| 260 command_line->AppendSwitch(switches::kChromeFrame); | 261 command_line->AppendSwitch(switches::kChromeFrame); |
| 261 | 262 |
| 262 // Chrome Frame never wants Chrome to start up with a First Run UI. | 263 // Chrome Frame never wants Chrome to start up with a First Run UI. |
| 263 command_line->AppendSwitch(switches::kNoFirstRun); | 264 command_line->AppendSwitch(switches::kNoFirstRun); |
| 264 | 265 |
| 265 command_line->AppendSwitch(switches::kDisablePopupBlocking); | 266 command_line->AppendSwitch(switches::kDisablePopupBlocking); |
| 266 | 267 |
| 267 // Disable the "Whoa! Chrome has crashed." dialog, because that isn't very | 268 // Disable the "Whoa! Chrome has crashed." dialog, because that isn't very |
| 268 // useful for Chrome Frame users. | 269 // useful for Chrome Frame users. |
| 269 #ifndef NDEBUG | 270 #ifndef NDEBUG |
| 270 command_line->AppendSwitch(switches::kNoErrorDialogs); | 271 command_line->AppendSwitch(switches::kNoErrorDialogs); |
| 271 #endif | 272 #endif |
| 272 | 273 |
| 273 // In headless mode runs like reliability test runs we want full crash dumps | 274 // In headless mode runs like reliability test runs we want full crash dumps |
| 274 // from chrome. | 275 // from chrome. |
| 275 if (IsHeadlessMode()) | 276 if (IsHeadlessMode()) |
| 276 command_line->AppendSwitch(switches::kFullMemoryCrashReport); | 277 command_line->AppendSwitch(switches::kFullMemoryCrashReport); |
| 277 | 278 |
| 278 // In accessible mode automation tests expect renderer accessibility to be | 279 // In accessible mode automation tests expect renderer accessibility to be |
| 279 // enabled in chrome. | 280 // enabled in chrome. |
| 280 if (IsAccessibleMode()) | 281 if (IsAccessibleMode()) |
| 281 command_line->AppendSwitch(switches::kForceRendererAccessibility); | 282 command_line->AppendSwitch(switches::kForceRendererAccessibility); |
| 282 | 283 |
| 283 DVLOG(1) << "Profile path: " << params->profile_path().value(); | 284 DVLOG(1) << "Profile path: " << params->profile_path().value(); |
| 284 command_line->AppendSwitchPath(switches::kUserDataDir, | 285 command_line->AppendSwitchPath(switches::kUserDataDir, |
| 285 params->profile_path()); | 286 params->profile_path()); |
| 286 | 287 |
| 287 // Ensure that Chrome is running the specified version of chrome.dll. | 288 // Ensure that Chrome is running the specified version of chrome.dll. |
| 288 command_line->AppendSwitchNative(switches::kChromeVersion, | 289 command_line->AppendSwitchNative(switches::kChromeVersion, |
| 289 GetCurrentModuleVersion()); | 290 GetCurrentModuleVersion()); |
| 290 | 291 |
| 291 if (!params->language().empty()) | 292 if (!params->language().empty()) |
| 292 command_line->AppendSwitchNative(switches::kLang, params->language()); | 293 command_line->AppendSwitchNative(switches::kLang, params->language()); |
| 293 | 294 |
| 294 std::wstring command_line_string(command_line->GetCommandLineString()); | 295 command_line_string = command_line->GetCommandLineString(); |
| 295 // If there are any extra arguments, append them to the command line. | 296 // If there are any extra arguments, append them to the command line. |
| 296 if (!params->extra_arguments().empty()) { | 297 if (!params->extra_arguments().empty()) { |
| 297 command_line_string += L' ' + params->extra_arguments(); | 298 command_line_string += L' ' + params->extra_arguments(); |
| 299 } |
| 298 } | 300 } |
| 299 | 301 |
| 300 automation_server_launch_start_time_ = base::TimeTicks::Now(); | 302 automation_server_launch_start_time_ = base::TimeTicks::Now(); |
| 301 | 303 |
| 302 if (!base::LaunchProcess(command_line_string, base::LaunchOptions(), NULL)) { | 304 if (command_line_string.empty() || |
| 305 !base::LaunchProcess(command_line_string, base::LaunchOptions(), NULL)) { |
| 303 // We have no code for launch failure. | 306 // We have no code for launch failure. |
| 304 launch_result_ = AUTOMATION_LAUNCH_RESULT_INVALID; | 307 launch_result_ = AUTOMATION_LAUNCH_RESULT_INVALID; |
| 305 } else { | 308 } else { |
| 306 // Launch timeout may happen if the new instance tries to communicate | 309 // Launch timeout may happen if the new instance tries to communicate |
| 307 // with an existing Chrome instance that is hung and displays msgbox | 310 // with an existing Chrome instance that is hung and displays msgbox |
| 308 // asking to kill the previous one. This could be easily observed if the | 311 // asking to kill the previous one. This could be easily observed if the |
| 309 // already running Chrome instance is running as high-integrity process | 312 // already running Chrome instance is running as high-integrity process |
| 310 // (started with "Run as Administrator" or launched by another high | 313 // (started with "Run as Administrator" or launched by another high |
| 311 // integrity process) hence our medium-integrity process | 314 // integrity process) hence our medium-integrity process |
| 312 // cannot SendMessage to it with request to activate itself. | 315 // cannot SendMessage to it with request to activate itself. |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1259 const net::URLRequestStatus& status) { | 1262 const net::URLRequestStatus& status) { |
| 1260 automation_server_->Send(new AutomationMsg_RequestEnd( | 1263 automation_server_->Send(new AutomationMsg_RequestEnd( |
| 1261 tab_->handle(), request_id, status)); | 1264 tab_->handle(), request_id, status)); |
| 1262 } | 1265 } |
| 1263 | 1266 |
| 1264 void ChromeFrameAutomationClient::OnCookiesRetrieved(bool success, | 1267 void ChromeFrameAutomationClient::OnCookiesRetrieved(bool success, |
| 1265 const GURL& url, const std::string& cookie_string, int cookie_id) { | 1268 const GURL& url, const std::string& cookie_string, int cookie_id) { |
| 1266 automation_server_->Send(new AutomationMsg_GetCookiesHostResponse( | 1269 automation_server_->Send(new AutomationMsg_GetCookiesHostResponse( |
| 1267 tab_->handle(), success, url, cookie_string, cookie_id)); | 1270 tab_->handle(), success, url, cookie_string, cookie_id)); |
| 1268 } | 1271 } |
| OLD | NEW |