Chromium Code Reviews| Index: tools/telemetry/telemetry/core/extension_to_load.py |
| =================================================================== |
| --- tools/telemetry/telemetry/core/extension_to_load.py (revision 185386) |
| +++ tools/telemetry/telemetry/core/extension_to_load.py (working copy) |
| @@ -8,6 +8,9 @@ |
| class ExtensionPathNonExistentException(Exception): |
| pass |
| +class ComponentExtensionMissingPublicKey(Exception): |
|
dtu
2013/03/01 23:17:47
MissingPublicKeyException
achuithb
2013/03/01 23:28:02
Done.
|
| + pass |
| + |
| class ExtensionToLoad(object): |
| def __init__(self, path, is_component=False): |
| if not os.path.isdir(path): |
| @@ -16,12 +19,20 @@ |
| self._path = path |
| self._local_path = path |
| self._is_component = is_component |
| + if is_component and not crx_id.HasPublicKey(path): |
| + raise ComponentExtensionMissingPublicKey( |
| + 'Component extension %s must have a public key' % path) |
| @property |
| def extension_id(self): |
| """Unique extension id of this extension.""" |
| - return crx_id.GetCRXAppID(os.path.abspath(self._local_path), |
| - from_test_path=True) |
| + if crx_id.HasPublicKey(self._path): |
| + # Calculate extension id from the public key. |
| + return crx_id.GetCRXAppID(os.path.abspath(self._path)) |
| + else: |
| + # Calculate extension id based on the path on the device. |
| + return crx_id.GetCRXAppID(os.path.abspath(self._local_path), |
| + from_file_path=True) |
| @property |
| def path(self): |