| 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 desktop browsers that can be controlled by telemetry.""" | 4 """Finds desktop browsers that can be controlled by telemetry.""" |
| 5 | 5 |
| 6 import logging | 6 import logging |
| 7 from operator import attrgetter | 7 from operator import attrgetter |
| 8 import os | 8 import os |
| 9 import platform | 9 import platform |
| 10 import subprocess | 10 import subprocess |
| 11 import sys | 11 import sys |
| 12 | 12 |
| 13 from telemetry.core import browser | 13 from telemetry.core import browser |
| 14 from telemetry.core import possible_browser | 14 from telemetry.core import possible_browser |
| 15 from telemetry.core import profile_types | 15 from telemetry.core import profile_types |
| 16 from telemetry.core.chrome import cros_interface | 16 from telemetry.core.chrome import cros_interface |
| 17 from telemetry.core.chrome import desktop_browser_backend | 17 from telemetry.core.chrome import desktop_browser_backend |
| 18 from telemetry.core.platform import linux_platform_backend | 18 from telemetry.core.platform import util as platform_util |
| 19 from telemetry.core.platform import mac_platform_backend | |
| 20 from telemetry.core.platform import win_platform_backend | |
| 21 | 19 |
| 22 ALL_BROWSER_TYPES = ','.join([ | 20 ALL_BROWSER_TYPES = ','.join([ |
| 23 'exact', | 21 'exact', |
| 24 'release', | 22 'release', |
| 25 'release_x64', | 23 'release_x64', |
| 26 'debug', | 24 'debug', |
| 27 'debug_x64', | 25 'debug_x64', |
| 28 'canary', | 26 'canary', |
| 29 'content-shell-debug', | 27 'content-shell-debug', |
| 30 'content-shell-release', | 28 'content-shell-release', |
| (...skipping 13 matching lines...) Expand all Loading... |
| 44 def __repr__(self): | 42 def __repr__(self): |
| 45 return 'PossibleDesktopBrowser(browser_type=%s)' % self.browser_type | 43 return 'PossibleDesktopBrowser(browser_type=%s)' % self.browser_type |
| 46 | 44 |
| 47 # Constructs a browser. | 45 # Constructs a browser. |
| 48 # Returns a touple of the form: (browser, backend) | 46 # Returns a touple of the form: (browser, backend) |
| 49 def _CreateBrowserInternal(self, delete_profile_dir_after_run): | 47 def _CreateBrowserInternal(self, delete_profile_dir_after_run): |
| 50 backend = desktop_browser_backend.DesktopBrowserBackend( | 48 backend = desktop_browser_backend.DesktopBrowserBackend( |
| 51 self._options, self._local_executable, self._flash_path, | 49 self._options, self._local_executable, self._flash_path, |
| 52 self._is_content_shell, | 50 self._is_content_shell, |
| 53 delete_profile_dir_after_run=delete_profile_dir_after_run) | 51 delete_profile_dir_after_run=delete_profile_dir_after_run) |
| 54 if sys.platform.startswith('linux'): | 52 b = browser.Browser(backend, |
| 55 p = linux_platform_backend.LinuxPlatformBackend() | 53 platform_util.CreatePlatformBackendForCurrentOS()) |
| 56 elif sys.platform == 'darwin': | |
| 57 p = mac_platform_backend.MacPlatformBackend() | |
| 58 elif sys.platform == 'win32': | |
| 59 p = win_platform_backend.WinPlatformBackend() | |
| 60 else: | |
| 61 raise NotImplementedError() | |
| 62 | |
| 63 b = browser.Browser(backend, p) | |
| 64 backend.SetBrowser(b) | 54 backend.SetBrowser(b) |
| 65 return (b, backend) | 55 return (b, backend) |
| 66 | 56 |
| 67 def Create(self): | 57 def Create(self): |
| 68 # If a dirty profile is needed, instantiate an initial browser object and | 58 # If a dirty profile is needed, instantiate an initial browser object and |
| 69 # use that to create a dirty profile. | 59 # use that to create a dirty profile. |
| 70 creator_class = profile_types.GetProfileCreator(self.options.profile_type) | 60 creator_class = profile_types.GetProfileCreator(self.options.profile_type) |
| 71 if creator_class: | 61 if creator_class: |
| 72 logging.info( | 62 logging.info( |
| 73 'Creating a dirty profile of type: %s', self.options.profile_type) | 63 'Creating a dirty profile of type: %s', self.options.profile_type) |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 chromium_app_name, False): | 233 chromium_app_name, False): |
| 244 break | 234 break |
| 245 | 235 |
| 246 if len(browsers) and not has_display: | 236 if len(browsers) and not has_display: |
| 247 logging.warning( | 237 logging.warning( |
| 248 'Found (%s), but you do not have a DISPLAY environment set.' % | 238 'Found (%s), but you do not have a DISPLAY environment set.' % |
| 249 ','.join([b.browser_type for b in browsers])) | 239 ','.join([b.browser_type for b in browsers])) |
| 250 return [] | 240 return [] |
| 251 | 241 |
| 252 return browsers | 242 return browsers |
| OLD | NEW |