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

Side by Side Diff: chrome/common/extensions/manifest_handler.h

Issue 12084034: Change manifest handler interface to always (implicitly) pass the entire manifest to handlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 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 4
5 #ifndef CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLER_H_ 5 #ifndef CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLER_H_
6 #define CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLER_H_ 6 #define CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLER_H_
7 7
8 #include <set>
8 #include <string> 9 #include <string>
9 #include <vector>
10 10
11 #include "base/string16.h" 11 #include "base/string16.h"
12 12 #include "chrome/common/extensions/extension.h"
13 namespace base {
14 class Value;
15 }
16 13
17 namespace extensions { 14 namespace extensions {
18 15
19 class Extension; 16 class Manifest;
20 17
21 class ManifestHandler { 18 class ManifestHandler {
22 public: 19 public:
23 ManifestHandler(); 20 ManifestHandler();
24 virtual ~ManifestHandler(); 21 virtual ~ManifestHandler();
25 22
26 // Attempts to parse the manifest value. 23 // Attempts to parse the extension's manifest.
27 // Returns true on success or false on failure; if false, |error| will 24 // Returns true on success or false on failure; if false, |error| will
28 // be set to a failure message. 25 // be set to a failure message.
29 virtual bool Parse(const base::Value* value, 26 virtual bool Parse(Extension* extension, string16* error) = 0;
30 Extension* extension,
31 string16* error) = 0;
32 27
33 // Perform any initialization which is necessary when the Handler's key is 28 // If false (the default), only parse the manifest if a registered
34 // not present in the manifest. 29 // key is present in the manifest. If true, always attempt to parse
35 // Returns true on success or false on failure; if false, |error| will 30 // the manifest for this extension type, even if no registered keys
36 // be set to a failure message. 31 // are present.
Matt Perry 2013/01/29 00:58:47 Could you add a sentence or two on when this would
Yoyo Zhou 2013/01/29 04:32:42 Done.
37 virtual bool HasNoKey(Extension* extension, string16* error); 32 virtual bool AlwaysParseForType(Extension::Type type);
38 33
39 // Associate |handler| with |key| in the manifest. Takes ownership 34 // Associate |handler| with |key| in the manifest. A handler can register
40 // of |handler|. TODO(yoz): Decide how to handle dotted subkeys. 35 // for multiple keys. The global registry takes ownership of |handler|;
36 // if it has an existing handler for |key|, it replaces it with this one.
37 //
41 // WARNING: Manifest handlers registered only in the browser process 38 // WARNING: Manifest handlers registered only in the browser process
42 // are not available to renderers. 39 // are not available to renderers or utility processes.
43 static void Register(const std::string& key, ManifestHandler* handler); 40 static void Register(const std::string& key, ManifestHandler* handler);
44 41
45 // Get the manifest handler associated with |key|, or NULL 42 // Get all registered manifest handlers that should parse |manifest|.
46 // if there is none. 43 static std::set<ManifestHandler*> GetHandlers(const Manifest* manifest);
47 static ManifestHandler* Get(const std::string& key);
48
49 // If the handler is not handling most of the keys, it may be
50 // more efficient to have a list of keys to iterate over.
51 // TODO(yoz): this isn't the long-term solution.
52 static std::vector<std::string> GetKeys();
53 }; 44 };
54 45
55
56 } // namespace extensions 46 } // namespace extensions
57 47
58 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLER_H_ 48 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698