Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 from copy import deepcopy | |
| 6 import json | |
| 7 import os | |
| 8 | |
| 9 from svn_constants import JSON_PATH | |
|
not at google - send to devlin
2013/05/03 15:56:25
this is the kind of thing to pass into the constru
jshumway
2013/05/10 02:08:36
Done.
| |
| 10 | |
| 11 def apply_apps_transformations(manifest): | |
|
not at google - send to devlin
2013/05/03 15:56:25
should be _ApplyAppsTransformations
jshumway
2013/05/10 02:08:36
Done.
| |
| 12 manifest['required'][0]['example'] = 'My Application' | |
| 13 | |
| 14 def apply_extensions_transformations(manifest): | |
| 15 pass | |
|
not at google - send to devlin
2013/05/03 15:56:25
almost there - but this needs to filter the manife
jshumway
2013/05/10 02:08:36
This was one of the major of my patch. Now the man
| |
| 16 | |
| 17 class ManifestDataSource(object): | |
| 18 """ Provides a template with access to manifest properties specific to apps or | |
| 19 extensions. | |
| 20 """ | |
| 21 def __init__(self, compiled_fs_factory, store_type): | |
| 22 self._compiled_fs = compiled_fs_factory.Create( | |
| 23 lambda _, contents: json.loads(contents), store_type) | |
|
not at google - send to devlin
2013/05/03 15:56:25
the store_type variable is so that each class can
jshumway
2013/05/10 02:08:36
Done.
| |
| 24 | |
| 25 self.loaded = False | |
| 26 | |
| 27 def get(self, key): | |
| 28 if not self.loaded: | |
|
not at google - send to devlin
2013/05/03 15:56:25
CompiledFileSystem implements this loading logic i
jshumway
2013/05/10 02:08:36
Done.
| |
| 29 manifest_json = self._compiled_fs.GetFromFile( | |
| 30 os.path.join(JSON_PATH, 'manifest.json')) | |
| 31 self.extensions = deepcopy(manifest_json) | |
| 32 self.apps = deepcopy(manifest_json) | |
| 33 | |
| 34 apply_apps_transformations(self.apps) | |
| 35 apply_extensions_transformations(self.extensions) | |
| 36 self.loaded = True | |
| 37 | |
| 38 if key == 'apps': | |
| 39 return self.apps | |
| 40 elif key == 'extensions': | |
| 41 return self.extensions | |
| 42 else: | |
| 43 raise KeyError | |
| OLD | NEW |