| 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 os | 6 import os |
| 7 import logging as real_logging | 7 import logging as real_logging |
| 8 import re | 8 import re |
| 9 import subprocess | 9 import subprocess |
| 10 | 10 |
| 11 from chrome_remote_control import adb_commands | 11 from chrome_remote_control import adb_commands |
| 12 from chrome_remote_control import android_browser_backend | 12 from chrome_remote_control import android_browser_backend |
| 13 from chrome_remote_control import android_platform |
| 13 from chrome_remote_control import browser | 14 from chrome_remote_control import browser |
| 14 from chrome_remote_control import possible_browser | 15 from chrome_remote_control import possible_browser |
| 15 | 16 |
| 16 ALL_BROWSER_TYPES = ','.join([ | 17 ALL_BROWSER_TYPES = ','.join([ |
| 17 'android-content-shell', | 18 'android-content-shell', |
| 18 'android-chrome', | 19 'android-chrome', |
| 19 'android-jb-system-chrome', | 20 'android-jb-system-chrome', |
| 20 ]) | 21 ]) |
| 21 | 22 |
| 22 CHROME_PACKAGE = 'com.google.android.apps.chrome' | 23 CHROME_PACKAGE = 'com.google.android.apps.chrome' |
| (...skipping 22 matching lines...) Expand all Loading... |
| 45 super(PossibleAndroidBrowser, self).__init__( | 46 super(PossibleAndroidBrowser, self).__init__( |
| 46 browser_type, options) | 47 browser_type, options) |
| 47 self._args = args | 48 self._args = args |
| 48 | 49 |
| 49 def __repr__(self): | 50 def __repr__(self): |
| 50 return 'PossibleAndroidBrowser(browser_type=%s)' % self.browser_type | 51 return 'PossibleAndroidBrowser(browser_type=%s)' % self.browser_type |
| 51 | 52 |
| 52 def Create(self): | 53 def Create(self): |
| 53 backend = android_browser_backend.AndroidBrowserBackend( | 54 backend = android_browser_backend.AndroidBrowserBackend( |
| 54 self._options, *self._args) | 55 self._options, *self._args) |
| 55 return browser.Browser(backend) | 56 platform = android_platform.AndroidPlatform( |
| 57 self._args[0].Adb(), self._args[1], |
| 58 self._args[1] + self._args[4]) |
| 59 return browser.Browser(backend, platform) |
| 56 | 60 |
| 57 def FindAllAvailableBrowsers(options, logging=real_logging): | 61 def FindAllAvailableBrowsers(options, logging=real_logging): |
| 58 """Finds all the desktop browsers available on this machine.""" | 62 """Finds all the desktop browsers available on this machine.""" |
| 59 if not adb_commands.IsAndroidSupported(): | 63 if not adb_commands.IsAndroidSupported(): |
| 60 return [] | 64 return [] |
| 61 | 65 |
| 62 # See if adb even works. | 66 # See if adb even works. |
| 63 try: | 67 try: |
| 64 with open(os.devnull, 'w') as devnull: | 68 with open(os.devnull, 'w') as devnull: |
| 65 proc = subprocess.Popen(['adb', 'devices'], | 69 proc = subprocess.Popen(['adb', 'devices'], |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 # but make it accessible to the device. | 140 # but make it accessible to the device. |
| 137 if len(possible_browsers) and not adb_commands.HasForwarder(adb): | 141 if len(possible_browsers) and not adb_commands.HasForwarder(adb): |
| 138 logging.warn('chrome_remote_control detected an android device. However,') | 142 logging.warn('chrome_remote_control detected an android device. However,') |
| 139 logging.warn('Chrome\'s port-forwarder app is not available.') | 143 logging.warn('Chrome\'s port-forwarder app is not available.') |
| 140 logging.warn('To build:') | 144 logging.warn('To build:') |
| 141 logging.warn(' make -j16 host_forwarder device_forwarder') | 145 logging.warn(' make -j16 host_forwarder device_forwarder') |
| 142 logging.warn('') | 146 logging.warn('') |
| 143 logging.warn('') | 147 logging.warn('') |
| 144 return [] | 148 return [] |
| 145 return possible_browsers | 149 return possible_browsers |
| OLD | NEW |