Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Unified Diff: tools/telemetry/telemetry/core/extension_to_load.py

Issue 12379034: Fixes for how extension ids are calculated, especially for component extensions. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: dtu feedback Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 MissingPublicKeyException(Exception):
+ 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 MissingPublicKeyException(
+ '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):
« no previous file with comments | « tools/telemetry/telemetry/core/chrome/crx_id.py ('k') | tools/telemetry/telemetry/core/extension_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698