| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 | 4 |
| 5 from telemetry.core import platform | 5 from telemetry.core import platform |
| 6 from telemetry.util import wpr_modes | 6 from telemetry.util import wpr_modes |
| 7 from telemetry.internal.browser import browser_finder | 7 from telemetry.internal.browser import browser_finder |
| 8 from telemetry.internal.browser import browser_finder_exceptions | 8 from telemetry.internal.browser import browser_finder_exceptions |
| 9 | 9 |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 @property | 52 @property |
| 53 def profile_path(self): | 53 def profile_path(self): |
| 54 """The path of the profile that the browser will use while it's running.""" | 54 """The path of the profile that the browser will use while it's running.""" |
| 55 return self.finder_options.output_profile_path | 55 return self.finder_options.output_profile_path |
| 56 | 56 |
| 57 @property | 57 @property |
| 58 def browser(self): | 58 def browser(self): |
| 59 return self._browser | 59 return self._browser |
| 60 | 60 |
| 61 def EnabledOSList(self): |
| 62 """Returns a list of OSes that this extender can run on. |
| 63 |
| 64 Can be overridden by subclasses. |
| 65 |
| 66 Returns: |
| 67 List of OS ('win', 'mac', or 'linux') that this extender can run on. |
| 68 None if this extender can run on all platforms. |
| 69 """ |
| 70 return None |
| 71 |
| 61 def SetUpBrowser(self): | 72 def SetUpBrowser(self): |
| 62 """Finds and starts the browser. | 73 """Finds and starts the browser. |
| 63 | 74 |
| 64 Can be overridden by subclasses. The subclass implementation must call the | 75 Can be overridden by subclasses. The subclass implementation must call the |
| 65 super class implementation. | 76 super class implementation. |
| 66 | 77 |
| 67 Subclasses do not need to call this method. This method is only necessary | 78 Subclasses do not need to call this method. This method is only necessary |
| 68 if the subclass needs to start a browser. If a subclass does call this | 79 if the subclass needs to start a browser. If a subclass does call this |
| 69 method, the subclass must also call TearDownBrowser(). | 80 method, the subclass must also call TearDownBrowser(). |
| 70 """ | 81 """ |
| 71 possible_browser = self._GetPossibleBrowser(self.finder_options) | 82 possible_browser = self._GetPossibleBrowser(self.finder_options) |
| 72 | 83 |
| 84 os_name = possible_browser.platform.GetOSName() |
| 85 enabled_os_list = self.EnabledOSList() |
| 86 if enabled_os_list is not None and os_name not in enabled_os_list: |
| 87 raise NotImplementedError( |
| 88 'This profile extender on %s is not yet supported' |
| 89 % os_name) |
| 90 |
| 73 assert possible_browser.supports_tab_control | 91 assert possible_browser.supports_tab_control |
| 74 assert (platform.GetHostPlatform().GetOSName() in | 92 assert (platform.GetHostPlatform().GetOSName() in |
| 75 ["win", "mac", "linux"]) | 93 ["win", "mac", "linux"]) |
| 76 | 94 |
| 77 self._SetUpWebPageReplay(self.finder_options, possible_browser) | 95 self._SetUpWebPageReplay(self.finder_options, possible_browser) |
| 78 self._browser = possible_browser.Create(self.finder_options) | 96 self._browser = possible_browser.Create(self.finder_options) |
| 79 | 97 |
| 80 def TearDownBrowser(self): | 98 def TearDownBrowser(self): |
| 81 """Tears down the browser. | 99 """Tears down the browser. |
| 82 | 100 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 possible_browser = browser_finder.FindBrowser(finder_options) | 141 possible_browser = browser_finder.FindBrowser(finder_options) |
| 124 if not possible_browser: | 142 if not possible_browser: |
| 125 raise browser_finder_exceptions.BrowserFinderException( | 143 raise browser_finder_exceptions.BrowserFinderException( |
| 126 'No browser found.\n\nAvailable browsers:\n%s\n' % | 144 'No browser found.\n\nAvailable browsers:\n%s\n' % |
| 127 '\n'.join(browser_finder.GetAllAvailableBrowserTypes(finder_options))) | 145 '\n'.join(browser_finder.GetAllAvailableBrowserTypes(finder_options))) |
| 128 finder_options.browser_options.browser_type = ( | 146 finder_options.browser_options.browser_type = ( |
| 129 possible_browser.browser_type) | 147 possible_browser.browser_type) |
| 130 | 148 |
| 131 return possible_browser | 149 return possible_browser |
| 132 | 150 |
| OLD | NEW |