| 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 browsers that can be controlled by telemetry.""" | 4 """Finds browsers that can be controlled by telemetry.""" |
| 5 | 5 |
| 6 import logging | 6 import logging |
| 7 | 7 |
| 8 from telemetry import android_browser_finder | 8 from telemetry import android_browser_finder |
| 9 from telemetry import cros_browser_finder | 9 from telemetry import cros_browser_finder |
| 10 from telemetry import desktop_browser_finder | 10 from telemetry import desktop_browser_finder |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 x_idx = types.index(x.browser_type) | 46 x_idx = types.index(x.browser_type) |
| 47 y_idx = types.index(y.browser_type) | 47 y_idx = types.index(y.browser_type) |
| 48 return x_idx - y_idx | 48 return x_idx - y_idx |
| 49 browsers.sort(compare_browsers_on_type_priority) | 49 browsers.sort(compare_browsers_on_type_priority) |
| 50 if len(browsers) >= 1: | 50 if len(browsers) >= 1: |
| 51 return browsers[0] | 51 return browsers[0] |
| 52 else: | 52 else: |
| 53 return None | 53 return None |
| 54 | 54 |
| 55 matching_browsers = [b for b in browsers | 55 matching_browsers = [b for b in browsers |
| 56 if b.browser_type == options.browser_type] | 56 if b.browser_type == options.browser_type and |
| 57 (len(options.extensions_to_load) == 0 or b.supports_extensions)] |
| 57 | 58 |
| 58 if len(matching_browsers) == 1: | 59 if len(matching_browsers) == 1: |
| 59 return matching_browsers[0] | 60 return matching_browsers[0] |
| 60 elif len(matching_browsers) > 1: | 61 elif len(matching_browsers) > 1: |
| 61 logging.warning('Multiple browsers of the same type found: %s' % ( | 62 logging.warning('Multiple browsers of the same type found: %s' % ( |
| 62 repr(matching_browsers))) | 63 repr(matching_browsers))) |
| 63 return matching_browsers[0] | 64 return matching_browsers[0] |
| 64 else: | 65 else: |
| 65 return None | 66 return None |
| 66 | 67 |
| 67 def GetAllAvailableBrowserTypes(options): | 68 def GetAllAvailableBrowserTypes(options): |
| 68 """Returns an array of browser types supported on this system.""" | 69 """Returns an array of browser types supported on this system.""" |
| 69 browsers = [] | 70 browsers = [] |
| 70 browsers.extend(desktop_browser_finder.FindAllAvailableBrowsers(options)) | 71 browsers.extend(desktop_browser_finder.FindAllAvailableBrowsers(options)) |
| 71 browsers.extend(android_browser_finder.FindAllAvailableBrowsers(options)) | 72 browsers.extend(android_browser_finder.FindAllAvailableBrowsers(options)) |
| 72 browsers.extend(cros_browser_finder.FindAllAvailableBrowsers(options)) | 73 browsers.extend(cros_browser_finder.FindAllAvailableBrowsers(options)) |
| 73 | 74 |
| 74 type_list = set([browser.browser_type for browser in browsers]) | 75 type_list = set([browser.browser_type for browser in browsers]) |
| 75 type_list = list(type_list) | 76 type_list = list(type_list) |
| 76 type_list.sort() | 77 type_list.sort() |
| 77 return type_list | 78 return type_list |
| OLD | NEW |