Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / tools / telemetry / telemetry / core / backends / chrome / misc_web_contents_backend.py
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
5 from telemetry.core import exceptions
6 from telemetry.core.backends.chrome import inspector_backend_list
7 from telemetry.core.backends.chrome import oobe
8
9 class MiscWebContentsBackend(inspector_backend_list.InspectorBackendList):
10   """A dynamic sequence of web contents not related to tabs and extensions.
11
12   Provides acccess to chrome://oobe/login page.
13   """
14
15   def __init__(self, browser_backend):
16     super(MiscWebContentsBackend, self).__init__(
17         browser_backend, backend_wrapper=oobe.Oobe)
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.BrowserGoneException,
25             exceptions.BrowserConnectionGoneException,
26             exceptions.TabCrashException):
27       return False
28
29   def GetOobe(self):
30     if not len(self):
31       return None
32     return self[0]
33
34   def ShouldIncludeContext(self, context):
35     return context.get('url').startswith('chrome://oobe')