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
3 # found in the LICENSE file.
5 from telemetry import decorators
7 from telemetry.core import web_contents
8 from telemetry.core.forwarders import do_nothing_forwarder
11 class ExtensionsNotSupportedException(Exception):
15 class BrowserBackend(object):
16 """A base class for browser backends."""
18 def __init__(self, is_content_shell, supports_extensions, browser_options,
20 assert browser_options.browser_type
21 self.browser_type = browser_options.browser_type
22 self.is_content_shell = is_content_shell
23 self._supports_extensions = supports_extensions
24 self.browser_options = browser_options
26 self._tab_list_backend_class = tab_list_backend
27 self._forwarder_factory = None
29 def AddReplayServerOptions(self, extra_wpr_args):
32 def SetBrowser(self, browser):
33 self._browser = browser
34 if (self.browser_options.netsim and
35 not browser.platform.CanLaunchApplication('ipfw')):
36 browser.platform.InstallApplication('ipfw')
43 def supports_extensions(self):
44 """True if this browser backend supports extensions."""
45 return self._supports_extensions
49 return self.browser_options.wpr_mode
52 def supports_tab_control(self):
53 raise NotImplementedError()
57 def tab_list_backend(self):
58 return self._tab_list_backend_class(self)
61 def supports_tracing(self):
62 raise NotImplementedError()
65 def supports_system_info(self):
69 def forwarder_factory(self):
70 if not self._forwarder_factory:
71 self._forwarder_factory = do_nothing_forwarder.DoNothingForwarderFactory()
72 return self._forwarder_factory
74 def StartTracing(self, custom_categories=None,
75 timeout=web_contents.DEFAULT_WEB_CONTENTS_TIMEOUT):
76 raise NotImplementedError()
79 def is_tracing_running(self):
82 def StopTracing(self):
83 raise NotImplementedError()
85 def GetRemotePort(self, port):
89 raise NotImplementedError()
91 def IsBrowserRunning(self):
92 raise NotImplementedError()
94 def GetStandardOutput(self):
95 raise NotImplementedError()
97 def GetStackTrace(self):
98 raise NotImplementedError()
100 def GetSystemInfo(self):
101 raise NotImplementedError()