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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 import os 4 import os
5 5
6 from telemetry.core.chrome import crx_id 6 from telemetry.core.chrome import crx_id
7 7
8 class ExtensionPathNonExistentException(Exception): 8 class ExtensionPathNonExistentException(Exception):
9 pass 9 pass
10 10
11 class MissingPublicKeyException(Exception):
12 pass
13
11 class ExtensionToLoad(object): 14 class ExtensionToLoad(object):
12 def __init__(self, path, is_component=False): 15 def __init__(self, path, is_component=False):
13 if not os.path.isdir(path): 16 if not os.path.isdir(path):
14 raise ExtensionPathNonExistentException( 17 raise ExtensionPathNonExistentException(
15 'Extension path not a directory %s' % path) 18 'Extension path not a directory %s' % path)
16 self._path = path 19 self._path = path
17 self._local_path = path 20 self._local_path = path
18 self._is_component = is_component 21 self._is_component = is_component
22 if is_component and not crx_id.HasPublicKey(path):
23 raise MissingPublicKeyException(
24 'Component extension %s must have a public key' % path)
19 25
20 @property 26 @property
21 def extension_id(self): 27 def extension_id(self):
22 """Unique extension id of this extension.""" 28 """Unique extension id of this extension."""
23 return crx_id.GetCRXAppID(os.path.abspath(self._local_path), 29 if crx_id.HasPublicKey(self._path):
24 from_test_path=True) 30 # Calculate extension id from the public key.
31 return crx_id.GetCRXAppID(os.path.abspath(self._path))
32 else:
33 # Calculate extension id based on the path on the device.
34 return crx_id.GetCRXAppID(os.path.abspath(self._local_path),
35 from_file_path=True)
25 36
26 @property 37 @property
27 def path(self): 38 def path(self):
28 """Path to extension source directory.""" 39 """Path to extension source directory."""
29 return self._path 40 return self._path
30 41
31 @property 42 @property
32 def local_path(self): 43 def local_path(self):
33 """Path to extension destination directory, for remote instances of 44 """Path to extension destination directory, for remote instances of
34 chrome""" 45 chrome"""
35 return self._local_path 46 return self._local_path
36 47
37 @local_path.setter 48 @local_path.setter
38 def local_path(self, local_path): 49 def local_path(self, local_path):
39 self._local_path = local_path 50 self._local_path = local_path
40 51
41 @property 52 @property
42 def is_component(self): 53 def is_component(self):
43 """Whether this extension should be loaded as a component extension.""" 54 """Whether this extension should be loaded as a component extension."""
44 return self._is_component 55 return self._is_component
OLDNEW
« 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