OLD | NEW |
(Empty) | |
| 1 # Copyright (c) 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 |
| 5 from telemetry import extension_to_load |
| 6 |
| 7 class ExtensionDict(object): |
| 8 """Dictionary of ExtensionPage instances, with extension_id as key""" |
| 9 |
| 10 def __init__(self, extension_dict_backend): |
| 11 self._extension_dict_backend = extension_dict_backend |
| 12 |
| 13 def __getitem__(self, load_extension): |
| 14 """Given an ExtensionToLoad instance, returns the corresponding |
| 15 ExtensionPage instance.""" |
| 16 if not isinstance(load_extension, extension_to_load.ExtensionToLoad): |
| 17 raise Exception("Input param must be of type ExtensionToLoad") |
| 18 return self._extension_dict_backend.__getitem__( |
| 19 load_extension.extension_id()) |
| 20 |
| 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 Exception("Input param must be of type ExtensionToLoad") |
| 25 return self._extension_dict_backend.__contains__( |
| 26 load_extension.extension_id()) |
OLD | NEW |