Update sdk/platform-tools to version 26.0.0.
[android_tools.git] / sdk / platform-tools / systrace / catapult / telemetry / telemetry / internal / browser / extension_dict.py
blob95742b5ed341556718f2e172c8c88c1358f5343a
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.
5 from telemetry.internal.browser import extension_to_load
8 class ExtensionDict(object):
9 """Dictionary of ExtensionPage instances, with extension_id as key."""
11 def __init__(self, extension_backend):
12 self._extension_backend = extension_backend
14 def __getitem__(self, load_extension):
15 """Given an ExtensionToLoad instance, returns the corresponding
16 ExtensionPage instance."""
17 if not isinstance(load_extension, extension_to_load.ExtensionToLoad):
18 raise TypeError("Input param must be of type ExtensionToLoad")
19 return self.GetByExtensionId(load_extension.extension_id)[0]
21 def __contains__(self, load_extension):
22 """Checks if this ExtensionToLoad instance has been loaded"""
23 if not isinstance(load_extension, extension_to_load.ExtensionToLoad):
24 raise TypeError("Input param must be of type ExtensionToLoad")
25 return load_extension.extension_id in self._extension_backend
27 def keys(self):
28 return self._extension_backend.keys()
30 def GetByExtensionId(self, extension_id):
31 """Returns a list of extensions given an extension id. This is useful for
32 connecting to built-in apps and component extensions."""
33 return self._extension_backend[extension_id]