Chromium Code Reviews| Index: chrome/common/extensions/docs/server2/manifest_data_source.py |
| diff --git a/chrome/common/extensions/docs/server2/manifest_data_source.py b/chrome/common/extensions/docs/server2/manifest_data_source.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6168571da26a0248086497e4b9b7e3fe6167d8b5 |
| --- /dev/null |
| +++ b/chrome/common/extensions/docs/server2/manifest_data_source.py |
| @@ -0,0 +1,43 @@ |
| +# Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +from copy import deepcopy |
| +import json |
| +import os |
| + |
| +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.
|
| + |
| +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.
|
| + manifest['required'][0]['example'] = 'My Application' |
| + |
| +def apply_extensions_transformations(manifest): |
| + 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
|
| + |
| +class ManifestDataSource(object): |
| + """ Provides a template with access to manifest properties specific to apps or |
| + extensions. |
| + """ |
| + def __init__(self, compiled_fs_factory, store_type): |
| + self._compiled_fs = compiled_fs_factory.Create( |
| + 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.
|
| + |
| + self.loaded = False |
| + |
| + def get(self, key): |
| + 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.
|
| + manifest_json = self._compiled_fs.GetFromFile( |
| + os.path.join(JSON_PATH, 'manifest.json')) |
| + self.extensions = deepcopy(manifest_json) |
| + self.apps = deepcopy(manifest_json) |
| + |
| + apply_apps_transformations(self.apps) |
| + apply_extensions_transformations(self.extensions) |
| + self.loaded = True |
| + |
| + if key == 'apps': |
| + return self.apps |
| + elif key == 'extensions': |
| + return self.extensions |
| + else: |
| + raise KeyError |