| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 import logging | 4 import logging |
| 5 import socket | 5 import socket |
| 6 import subprocess | 6 import subprocess |
| 7 import time | 7 import time |
| 8 | 8 |
| 9 from chrome_remote_control import browser_backend | 9 from chrome_remote_control import browser_backend |
| 10 from chrome_remote_control import cros_interface | 10 from chrome_remote_control import cros_interface |
| 11 | 11 |
| 12 class CrOSBrowserBackend(browser_backend.BrowserBackend): | 12 class CrOSBrowserBackend(browser_backend.BrowserBackend): |
| 13 """The backend for controlling a browser instance running on CrOS. | 13 """The backend for controlling a browser instance running on CrOS. |
| 14 """ | 14 """ |
| 15 def __init__(self, browser_type, options, is_content_shell, cri): | 15 def __init__(self, browser_type, options, extra_browser_args, |
| 16 is_content_shell, cri): |
| 16 super(CrOSBrowserBackend, self).__init__(is_content_shell) | 17 super(CrOSBrowserBackend, self).__init__(is_content_shell) |
| 17 # Initialize fields so that an explosion during init doesn't break in Close. | 18 # Initialize fields so that an explosion during init doesn't break in Close. |
| 18 self._options = options | 19 self._options = options |
| 19 assert not is_content_shell | 20 assert not is_content_shell |
| 20 self._cri = cri | 21 self._cri = cri |
| 21 self._browser_type = browser_type | 22 self._browser_type = browser_type |
| 22 | 23 |
| 23 tmp = socket.socket() | 24 tmp = socket.socket() |
| 24 tmp.bind(('', 0)) | 25 tmp.bind(('', 0)) |
| 25 self._port = tmp.getsockname()[1] | 26 self._port = tmp.getsockname()[1] |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 if options.dont_override_profile: | 59 if options.dont_override_profile: |
| 59 # TODO(nduca): Implement support for this. | 60 # TODO(nduca): Implement support for this. |
| 60 logging.critical('Feature not (yet) implemented.') | 61 logging.critical('Feature not (yet) implemented.') |
| 61 | 62 |
| 62 # Ensure a clean user_data_dir. | 63 # Ensure a clean user_data_dir. |
| 63 self._cri.GetCmdOutput(['rm', '-rf', self._tmpdir]) | 64 self._cri.GetCmdOutput(['rm', '-rf', self._tmpdir]) |
| 64 | 65 |
| 65 args.append('--user-data-dir=%s' % self._tmpdir) | 66 args.append('--user-data-dir=%s' % self._tmpdir) |
| 66 | 67 |
| 67 # Final bits of command line prep. | 68 # Final bits of command line prep. |
| 69 if extra_browser_args: |
| 70 args.extend(extra_browser_args) |
| 68 args.extend(options.extra_browser_args) | 71 args.extend(options.extra_browser_args) |
| 69 prevent_output = not options.show_stdout | 72 prevent_output = not options.show_stdout |
| 70 | 73 |
| 71 # Stop old X. | 74 # Stop old X. |
| 72 logging.info('Stoppping old X') | 75 logging.info('Stoppping old X') |
| 73 self._cri.KillAllMatching( | 76 self._cri.KillAllMatching( |
| 74 lambda name: name.startswith('/usr/bin/X ')) | 77 lambda name: name.startswith('/usr/bin/X ')) |
| 75 | 78 |
| 76 # Start X. | 79 # Start X. |
| 77 logging.info('Starting new X') | 80 logging.info('Starting new X') |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 164 |
| 162 @property | 165 @property |
| 163 def url(self): | 166 def url(self): |
| 164 assert self._proc | 167 assert self._proc |
| 165 return 'http://localhost:%i' % self._remote_port | 168 return 'http://localhost:%i' % self._remote_port |
| 166 | 169 |
| 167 def Close(self): | 170 def Close(self): |
| 168 if self._proc: | 171 if self._proc: |
| 169 self._proc.kill() | 172 self._proc.kill() |
| 170 self._proc = None | 173 self._proc = None |
| OLD | NEW |