- add sources.
[platform/framework/web/crosswalk.git] / src / tools / telemetry / telemetry / core / extension_dict.py
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 from telemetry.core import extension_to_load
5
6 class ExtensionDict(object):
7   """Dictionary of ExtensionPage instances, with extension_id as key"""
8
9   def __init__(self, extension_dict_backend):
10     self._extension_dict_backend = extension_dict_backend
11
12   def __getitem__(self, load_extension):
13     """Given an ExtensionToLoad instance, returns the corresponding
14     ExtensionPage instance."""
15     if not isinstance(load_extension, extension_to_load.ExtensionToLoad):
16       raise Exception("Input param must be of type ExtensionToLoad")
17     return self._extension_dict_backend.__getitem__(
18         load_extension.extension_id)
19
20   def __contains__(self, load_extension):
21     """Checks if this ExtensionToLoad instance has been loaded"""
22     if not isinstance(load_extension, extension_to_load.ExtensionToLoad):
23       raise Exception("Input param must be of type ExtensionToLoad")
24     return self._extension_dict_backend.__contains__(
25         load_extension.extension_id)