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.
4
5from telemetry.core import exceptions
6from telemetry.internal.backends.chrome import oobe
7from telemetry.internal.backends.chrome_inspector import inspector_backend_list
8
9
10class MiscWebContentsBackend(inspector_backend_list.InspectorBackendList):
11  """A dynamic sequence of web contents not related to tabs and extensions.
12
13  Provides acccess to chrome://oobe/login page.
14  """
15
16  def __init__(self, browser_backend):
17    super(MiscWebContentsBackend, self).__init__(browser_backend)
18
19  @property
20  def oobe_exists(self):
21    """Lightweight property to determine if the oobe webui is visible."""
22    try:
23      return bool(len(self))
24    except exceptions.Error:
25      return False
26
27  def GetOobe(self):
28    if not len(self):
29      return None
30    return self[0]
31
32  def ShouldIncludeContext(self, context):
33    return context.get('url').startswith('chrome://oobe')
34
35  def CreateWrapper(self, inspector_backend):
36    return oobe.Oobe(inspector_backend)
37