1# Copyright 2012 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
5import re
6
7from telemetry.internal.browser import web_contents
8
9
10def UrlToExtensionId(url):
11  return re.match(r"(chrome-extension://)([^/]+)", url).group(2)
12
13
14class ExtensionPage(web_contents.WebContents):
15  """Represents an extension page in the browser"""
16
17  def __init__(self, inspector_backend):
18    super(ExtensionPage, self).__init__(inspector_backend)
19    self.url = inspector_backend.url
20    self.extension_id = UrlToExtensionId(self.url)
21
22  def Reload(self):
23    """Reloading an extension page is used as a workaround for an extension
24    binding bug for old versions of Chrome (crbug.com/263162). After Navigate
25    returns, we are guaranteed that the inspected page is in the correct state.
26    """
27    self._inspector_backend.Navigate(self.url, None, 10)
28