| 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 """Finds android browsers that can be controlled by chrome_remote_control.""" | 4 """Finds android browsers that can be controlled by chrome_remote_control.""" |
| 5 | 5 |
| 6 import logging | 6 import logging |
| 7 | 7 |
| 8 from chrome_remote_control import browser | 8 from chrome_remote_control import browser |
| 9 from chrome_remote_control import possible_browser | 9 from chrome_remote_control import possible_browser |
| 10 from chrome_remote_control import cros_browser_backend | 10 from chrome_remote_control import cros_browser_backend |
| 11 from chrome_remote_control import ( | 11 from chrome_remote_control import cros_interface |
| 12 cros_interface as real_cros_interface) | |
| 13 | 12 |
| 14 ALL_BROWSER_TYPES = ','.join([ | 13 ALL_BROWSER_TYPES = ','.join([ |
| 15 'cros-chrome', | 14 'cros-chrome', |
| 16 ]) | 15 ]) |
| 17 | 16 |
| 18 class PossibleCrOSBrowser(possible_browser.PossibleBrowser): | 17 class PossibleCrOSBrowser(possible_browser.PossibleBrowser): |
| 19 """A launchable android browser instance.""" | 18 """A launchable android browser instance.""" |
| 20 def __init__(self, browser_type, options, *args): | 19 def __init__(self, browser_type, options, *args): |
| 21 super(PossibleCrOSBrowser, self).__init__( | 20 super(PossibleCrOSBrowser, self).__init__( |
| 22 browser_type, options) | 21 browser_type, options) |
| 23 self._args = args | 22 self._args = args |
| 24 | 23 |
| 25 def __repr__(self): | 24 def __repr__(self): |
| 26 return 'PossibleCrOSBrowser(browser_type=%s)' % self.browser_type | 25 return 'PossibleCrOSBrowser(browser_type=%s)' % self.browser_type |
| 27 | 26 |
| 28 def Create(self): | 27 def Create(self): |
| 29 backend = cros_browser_backend.CrOSBrowserBackend( | 28 backend = cros_browser_backend.CrOSBrowserBackend( |
| 30 self.browser_type, self._options, *self._args) | 29 self.browser_type, self._options, *self._args) |
| 31 return browser.Browser(backend) | 30 return browser.Browser(backend) |
| 32 | 31 |
| 33 def FindAllAvailableBrowsers(options, | 32 def FindAllAvailableBrowsers(options): |
| 34 cros_interface = real_cros_interface): | |
| 35 """Finds all the desktop browsers available on this machine.""" | 33 """Finds all the desktop browsers available on this machine.""" |
| 36 if options.cros_remote == None: | 34 if options.cros_remote == None: |
| 37 logging.debug('No --remote specified, will not probe for CrOS.') | 35 logging.debug('No --remote specified, will not probe for CrOS.') |
| 38 return [] | 36 return [] |
| 39 | 37 |
| 40 if not cros_interface.HasSSH(): | 38 if not cros_interface.HasSSH(): |
| 41 logging.debug('ssh not found. Cannot talk to CrOS devices.') | 39 logging.debug('ssh not found. Cannot talk to CrOS devices.') |
| 42 return [] | 40 return [] |
| 43 cri = cros_interface.CrOSInterface(options.cros_remote, | 41 cri = cros_interface.CrOSInterface(options.cros_remote, |
| 44 options.cros_ssh_identity) | 42 options.cros_ssh_identity) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 68 logging.warn('') | 66 logging.warn('') |
| 69 logging.warn('P.S. Please, make tell your manager how INANE this.') | 67 logging.warn('P.S. Please, make tell your manager how INANE this.') |
| 70 else: | 68 else: |
| 71 logging.warn(str(ex)) | 69 logging.warn(str(ex)) |
| 72 return [] | 70 return [] |
| 73 | 71 |
| 74 if not cri.FileExistsOnDevice('/opt/google/chrome/chrome'): | 72 if not cri.FileExistsOnDevice('/opt/google/chrome/chrome'): |
| 75 logging.warn('Could not find a chrome on ' % cri.hostname) | 73 logging.warn('Could not find a chrome on ' % cri.hostname) |
| 76 | 74 |
| 77 return [PossibleCrOSBrowser('cros-chrome', options, False, cri)] | 75 return [PossibleCrOSBrowser('cros-chrome', options, False, cri)] |
| OLD | NEW |