| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/test/chromedriver/chrome_launcher.h" | 5 #include "chrome/test/chromedriver/chrome_launcher.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 } | 78 } |
| 79 | 79 |
| 80 base::FilePath extension_dir = temp_dir.AppendASCII("internal"); | 80 base::FilePath extension_dir = temp_dir.AppendASCII("internal"); |
| 81 if (!zip::Unzip(extension_zip, extension_dir)) | 81 if (!zip::Unzip(extension_zip, extension_dir)) |
| 82 return Status(kUnknownError, "failed to unzip automation extension"); | 82 return Status(kUnknownError, "failed to unzip automation extension"); |
| 83 | 83 |
| 84 *automation_extension = extension_dir; | 84 *automation_extension = extension_dir; |
| 85 return Status(kOk); | 85 return Status(kOk); |
| 86 } | 86 } |
| 87 | 87 |
| 88 Status PrepareCommandLine(int port, | 88 Status PrepareCommandLine(uint16 port, |
| 89 const Capabilities& capabilities, | 89 const Capabilities& capabilities, |
| 90 CommandLine* prepared_command, | 90 CommandLine* prepared_command, |
| 91 base::ScopedTempDir* user_data_dir, | 91 base::ScopedTempDir* user_data_dir, |
| 92 base::ScopedTempDir* extension_dir, | 92 base::ScopedTempDir* extension_dir, |
| 93 std::vector<std::string>* extension_bg_pages) { | 93 std::vector<std::string>* extension_bg_pages) { |
| 94 base::FilePath program = capabilities.binary; | 94 base::FilePath program = capabilities.binary; |
| 95 if (program.empty()) { | 95 if (program.empty()) { |
| 96 if (!FindChrome(&program)) | 96 if (!FindChrome(&program)) |
| 97 return Status(kUnknownError, "cannot find Chrome binary"); | 97 return Status(kUnknownError, "cannot find Chrome binary"); |
| 98 } else if (!base::PathExists(program)) { | 98 } else if (!base::PathExists(program)) { |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 } | 261 } |
| 262 | 262 |
| 263 chrome->reset(new ChromeRemoteImpl(devtools_http_client.Pass(), | 263 chrome->reset(new ChromeRemoteImpl(devtools_http_client.Pass(), |
| 264 devtools_websocket_client.Pass(), | 264 devtools_websocket_client.Pass(), |
| 265 *devtools_event_listeners)); | 265 *devtools_event_listeners)); |
| 266 return Status(kOk); | 266 return Status(kOk); |
| 267 } | 267 } |
| 268 | 268 |
| 269 Status LaunchDesktopChrome( | 269 Status LaunchDesktopChrome( |
| 270 URLRequestContextGetter* context_getter, | 270 URLRequestContextGetter* context_getter, |
| 271 int port, | 271 uint16 port, |
| 272 scoped_ptr<PortReservation> port_reservation, | 272 scoped_ptr<PortReservation> port_reservation, |
| 273 const SyncWebSocketFactory& socket_factory, | 273 const SyncWebSocketFactory& socket_factory, |
| 274 const Capabilities& capabilities, | 274 const Capabilities& capabilities, |
| 275 ScopedVector<DevToolsEventListener>* devtools_event_listeners, | 275 ScopedVector<DevToolsEventListener>* devtools_event_listeners, |
| 276 scoped_ptr<Chrome>* chrome) { | 276 scoped_ptr<Chrome>* chrome) { |
| 277 CommandLine command(CommandLine::NO_PROGRAM); | 277 CommandLine command(CommandLine::NO_PROGRAM); |
| 278 base::ScopedTempDir user_data_dir; | 278 base::ScopedTempDir user_data_dir; |
| 279 base::ScopedTempDir extension_dir; | 279 base::ScopedTempDir extension_dir; |
| 280 std::vector<std::string> extension_bg_pages; | 280 std::vector<std::string> extension_bg_pages; |
| 281 Status status = PrepareCommandLine(port, | 281 Status status = PrepareCommandLine(port, |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 extension_bg_pages[i], | 425 extension_bg_pages[i], |
| 426 status); | 426 status); |
| 427 } | 427 } |
| 428 } | 428 } |
| 429 *chrome = chrome_desktop.Pass(); | 429 *chrome = chrome_desktop.Pass(); |
| 430 return Status(kOk); | 430 return Status(kOk); |
| 431 } | 431 } |
| 432 | 432 |
| 433 Status LaunchAndroidChrome( | 433 Status LaunchAndroidChrome( |
| 434 URLRequestContextGetter* context_getter, | 434 URLRequestContextGetter* context_getter, |
| 435 int port, | 435 uint16 port, |
| 436 scoped_ptr<PortReservation> port_reservation, | 436 scoped_ptr<PortReservation> port_reservation, |
| 437 const SyncWebSocketFactory& socket_factory, | 437 const SyncWebSocketFactory& socket_factory, |
| 438 const Capabilities& capabilities, | 438 const Capabilities& capabilities, |
| 439 ScopedVector<DevToolsEventListener>* devtools_event_listeners, | 439 ScopedVector<DevToolsEventListener>* devtools_event_listeners, |
| 440 DeviceManager* device_manager, | 440 DeviceManager* device_manager, |
| 441 scoped_ptr<Chrome>* chrome) { | 441 scoped_ptr<Chrome>* chrome) { |
| 442 Status status(kOk); | 442 Status status(kOk); |
| 443 scoped_ptr<Device> device; | 443 scoped_ptr<Device> device; |
| 444 if (capabilities.android_device_serial.empty()) { | 444 if (capabilities.android_device_serial.empty()) { |
| 445 status = device_manager->AcquireDevice(&device); | 445 status = device_manager->AcquireDevice(&device); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 PortManager* port_manager, | 504 PortManager* port_manager, |
| 505 const Capabilities& capabilities, | 505 const Capabilities& capabilities, |
| 506 ScopedVector<DevToolsEventListener>* devtools_event_listeners, | 506 ScopedVector<DevToolsEventListener>* devtools_event_listeners, |
| 507 scoped_ptr<Chrome>* chrome) { | 507 scoped_ptr<Chrome>* chrome) { |
| 508 if (capabilities.IsRemoteBrowser()) { | 508 if (capabilities.IsRemoteBrowser()) { |
| 509 return LaunchRemoteChromeSession( | 509 return LaunchRemoteChromeSession( |
| 510 context_getter, socket_factory, | 510 context_getter, socket_factory, |
| 511 capabilities, devtools_event_listeners, chrome); | 511 capabilities, devtools_event_listeners, chrome); |
| 512 } | 512 } |
| 513 | 513 |
| 514 int port = 0; | 514 uint16 port = 0; |
| 515 scoped_ptr<PortReservation> port_reservation; | 515 scoped_ptr<PortReservation> port_reservation; |
| 516 Status port_status(kOk); | 516 Status port_status(kOk); |
| 517 | 517 |
| 518 if (capabilities.IsAndroid()) { | 518 if (capabilities.IsAndroid()) { |
| 519 if (port_server) | 519 if (port_server) |
| 520 port_status = port_server->ReservePort(&port, &port_reservation); | 520 port_status = port_server->ReservePort(&port, &port_reservation); |
| 521 else | 521 else |
| 522 port_status = port_manager->ReservePortFromPool(&port, &port_reservation); | 522 port_status = port_manager->ReservePortFromPool(&port, &port_reservation); |
| 523 if (port_status.IsError()) | 523 if (port_status.IsError()) |
| 524 return Status(kUnknownError, "cannot reserve port for Chrome", | 524 return Status(kUnknownError, "cannot reserve port for Chrome", |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 // Write empty "First Run" file, otherwise Chrome will wipe the default | 835 // Write empty "First Run" file, otherwise Chrome will wipe the default |
| 836 // profile that was written. | 836 // profile that was written. |
| 837 if (base::WriteFile( | 837 if (base::WriteFile( |
| 838 user_data_dir.Append(chrome::kFirstRunSentinel), "", 0) != 0) { | 838 user_data_dir.Append(chrome::kFirstRunSentinel), "", 0) != 0) { |
| 839 return Status(kUnknownError, "failed to write first run file"); | 839 return Status(kUnknownError, "failed to write first run file"); |
| 840 } | 840 } |
| 841 return Status(kOk); | 841 return Status(kOk); |
| 842 } | 842 } |
| 843 | 843 |
| 844 } // namespace internal | 844 } // namespace internal |
| OLD | NEW |