| OLD | NEW |
| (Empty) |
| 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 | |
| 3 # found in the LICENSE file. | |
| 4 """Finds android browsers that can be controlled by chrome_remote_control.""" | |
| 5 | |
| 6 import logging | |
| 7 | |
| 8 from chrome_remote_control import browser | |
| 9 from chrome_remote_control import platform | |
| 10 from chrome_remote_control import possible_browser | |
| 11 from chrome_remote_control import cros_browser_backend | |
| 12 from chrome_remote_control import cros_interface | |
| 13 | |
| 14 ALL_BROWSER_TYPES = ','.join([ | |
| 15 'cros-chrome', | |
| 16 ]) | |
| 17 | |
| 18 class PossibleCrOSBrowser(possible_browser.PossibleBrowser): | |
| 19 """A launchable android browser instance.""" | |
| 20 def __init__(self, browser_type, options, *args): | |
| 21 super(PossibleCrOSBrowser, self).__init__( | |
| 22 browser_type, options) | |
| 23 self._args = args | |
| 24 | |
| 25 def __repr__(self): | |
| 26 return 'PossibleCrOSBrowser(browser_type=%s)' % self.browser_type | |
| 27 | |
| 28 def Create(self): | |
| 29 backend = cros_browser_backend.CrOSBrowserBackend( | |
| 30 self.browser_type, self._options, *self._args) | |
| 31 return browser.Browser(backend, platform.Platform()) | |
| 32 | |
| 33 def FindAllAvailableBrowsers(options): | |
| 34 """Finds all the desktop browsers available on this machine.""" | |
| 35 if options.cros_remote == None: | |
| 36 logging.debug('No --remote specified, will not probe for CrOS.') | |
| 37 return [] | |
| 38 | |
| 39 if not cros_interface.HasSSH(): | |
| 40 logging.debug('ssh not found. Cannot talk to CrOS devices.') | |
| 41 return [] | |
| 42 cri = cros_interface.CrOSInterface(options.cros_remote, | |
| 43 options.cros_ssh_identity) | |
| 44 | |
| 45 # Check ssh | |
| 46 try: | |
| 47 cri.TryLogin() | |
| 48 except cros_interface.LoginException, ex: | |
| 49 if isinstance(ex, cros_interface.KeylessLoginRequiredException): | |
| 50 logging.warn('Could not ssh into %s. Your device must be configured', | |
| 51 options.cros_remote) | |
| 52 logging.warn('to allow passwordless login as root.') | |
| 53 logging.warn('For a test-build device, pass this to your script:') | |
| 54 logging.warn(' --identity $(CHROMITE)/ssh_keys/id_testing:') | |
| 55 logging.warn('') | |
| 56 logging.warn('For a developer-mode device, the steps are:') | |
| 57 logging.warn(' - Ensure you have an id_rsa.pub (etc) on this computer') | |
| 58 logging.warn(' - On the chromebook:') | |
| 59 logging.warn(' - Control-Alt-T; shell; sudo -s') | |
| 60 logging.warn(' - openssh-server start') | |
| 61 logging.warn(' - scp <this machine>:.ssh/id_rsa.pub /tmp/') | |
| 62 logging.warn(' - mkdir /root/.ssh') | |
| 63 logging.warn(' - chown go-rx /root/.ssh') | |
| 64 logging.warn(' - cat /tmp/id_rsa.pub >> /root/.ssh/authorized_keys') | |
| 65 logging.warn(' - chown 0600 /root/.ssh/authorized_keys') | |
| 66 logging.warn('There, that was easy!') | |
| 67 logging.warn('') | |
| 68 logging.warn('P.S. Please, tell your manager how INANE this is.') | |
| 69 else: | |
| 70 logging.warn(str(ex)) | |
| 71 return [] | |
| 72 | |
| 73 if not cri.FileExistsOnDevice('/opt/google/chrome/chrome'): | |
| 74 logging.warn('Could not find a chrome on ' % cri.hostname) | |
| 75 | |
| 76 return [PossibleCrOSBrowser('cros-chrome', options, False, cri)] | |
| OLD | NEW |