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 chrome_remote_control.""" | 4 """Finds desktop browsers that can be controlled by chrome_remote_control.""" |
5 | 5 |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import subprocess | 8 import subprocess |
9 import sys | 9 import sys |
10 | 10 |
11 from chrome_remote_control import browser | 11 from chrome_remote_control import browser |
12 from chrome_remote_control import desktop_browser_backend | 12 from chrome_remote_control import desktop_browser_backend |
| 13 from chrome_remote_control import platform |
13 from chrome_remote_control import possible_browser | 14 from chrome_remote_control import possible_browser |
14 | 15 |
15 ALL_BROWSER_TYPES = ','.join([ | 16 ALL_BROWSER_TYPES = ','.join([ |
16 'exact', | 17 'exact', |
17 'release', | 18 'release', |
18 'debug', | 19 'debug', |
19 'canary', | 20 'canary', |
20 'content-shell-debug', | 21 'content-shell-debug', |
21 'content-shell-release', | 22 'content-shell-release', |
22 'system']) | 23 'system']) |
23 | 24 |
24 class PossibleDesktopBrowser(possible_browser.PossibleBrowser): | 25 class PossibleDesktopBrowser(possible_browser.PossibleBrowser): |
25 """A desktop browser that can be controlled.""" | 26 """A desktop browser that can be controlled.""" |
26 | 27 |
27 def __init__(self, browser_type, options, executable, is_content_shell): | 28 def __init__(self, browser_type, options, executable, is_content_shell): |
28 super(PossibleDesktopBrowser, self).__init__(browser_type, options) | 29 super(PossibleDesktopBrowser, self).__init__(browser_type, options) |
29 self._local_executable = executable | 30 self._local_executable = executable |
30 self._is_content_shell = is_content_shell | 31 self._is_content_shell = is_content_shell |
31 | 32 |
32 def __repr__(self): | 33 def __repr__(self): |
33 return 'PossibleDesktopBrowser(browser_type=%s)' % self.browser_type | 34 return 'PossibleDesktopBrowser(browser_type=%s)' % self.browser_type |
34 | 35 |
35 def Create(self): | 36 def Create(self): |
36 backend = desktop_browser_backend.DesktopBrowserBackend( | 37 backend = desktop_browser_backend.DesktopBrowserBackend( |
37 self._options, self._local_executable, self._is_content_shell) | 38 self._options, self._local_executable, self._is_content_shell) |
38 return browser.Browser(backend) | 39 return browser.Browser(backend, platform.Platform()) |
39 | 40 |
40 def FindAllAvailableBrowsers(options): | 41 def FindAllAvailableBrowsers(options): |
41 """Finds all the desktop browsers available on this machine.""" | 42 """Finds all the desktop browsers available on this machine.""" |
42 browsers = [] | 43 browsers = [] |
43 | 44 |
44 has_display = True | 45 has_display = True |
45 if (sys.platform.startswith('linux') and | 46 if (sys.platform.startswith('linux') and |
46 os.getenv('DISPLAY') == None): | 47 os.getenv('DISPLAY') == None): |
47 has_display = False | 48 has_display = False |
48 | 49 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 browsers.append(PossibleDesktopBrowser('system', options, | 130 browsers.append(PossibleDesktopBrowser('system', options, |
130 win_system, False)) | 131 win_system, False)) |
131 | 132 |
132 if len(browsers) and not has_display: | 133 if len(browsers) and not has_display: |
133 logging.warning( | 134 logging.warning( |
134 'Found (%s), but you do not have a DISPLAY environment set.' % | 135 'Found (%s), but you do not have a DISPLAY environment set.' % |
135 ','.join([b.browser_type for b in browsers])) | 136 ','.join([b.browser_type for b in browsers])) |
136 return [] | 137 return [] |
137 | 138 |
138 return browsers | 139 return browsers |
OLD | NEW |