Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_API_EXTENSION_API_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_ | 6 #define CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | |
| 10 #include <string> | 11 #include <string> |
| 11 | 12 |
| 12 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 13 #include "base/memory/linked_ptr.h" | 14 #include "base/memory/linked_ptr.h" |
| 14 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 | 17 |
| 17 namespace base { | 18 namespace base { |
| 18 class DictionaryValue; | 19 class DictionaryValue; |
| 19 class ListValue; | 20 class ListValue; |
| 20 class Value; | 21 class Value; |
| 21 } | 22 } |
| 22 | 23 |
| 23 class Extension; | 24 class Extension; |
| 24 class ExtensionPermissionSet; | 25 class ExtensionPermissionSet; |
| 25 | 26 |
| 26 namespace extensions { | 27 namespace extensions { |
| 27 | 28 |
| 28 // C++ Wrapper for the JSON API definitions in chrome/common/extensions/api/. | 29 // C++ Wrapper for the JSON API definitions in chrome/common/extensions/api/. |
| 29 class ExtensionAPI { | 30 class ExtensionAPI { |
| 30 public: | 31 public: |
| 31 typedef std::map<std::string, linked_ptr<const DictionaryValue> > SchemaMap; | 32 typedef std::map<std::string, linked_ptr<const DictionaryValue> > SchemaMap; |
| 32 | 33 |
| 33 // Returns the single instance of this class. | 34 // Returns the single instance of this class. |
| 34 static ExtensionAPI* GetInstance(); | 35 static ExtensionAPI* GetInstance(); |
| 35 | 36 |
| 36 // Returns ture if |name| is a privileged API. Privileged APIs can only be | 37 // Returns true if |name| is a privileged API path. Privileged paths can only |
| 37 // called from extension code which is running in its own designated extension | 38 // be called from extension code which is running in its own designated |
| 38 // process. They cannot be called from extension code running in content | 39 // extension process. They cannot be called from extension code running in |
| 39 // scripts, or other low-privileged processes. | 40 // content scripts, or other low-privileged processes. |
|
Aaron Boodman
2012/02/16 00:17:13
nit: last word would be better as "contexts".
not at google - send to devlin
2012/02/16 01:45:53
Done.
| |
| 40 bool IsPrivileged(const std::string& name) const; | 41 bool IsPrivileged(const std::string& name) const; |
| 41 | 42 |
| 43 // Gets whether *every* path in the API is privileged. This will be false for | |
|
koz (OOO until 15th September)
2012/02/15 23:43:11
nit: "Gets whether" -> "Returns whether"
not at google - send to devlin
2012/02/16 00:06:27
Done.
| |
| 44 // APIs such as "storage" which is entirely unprivileged, and "test" which | |
| 45 // has unprivileged components. | |
| 46 bool IsWholeAPIPrivileged(const std::string& api_name) const; | |
| 47 | |
| 42 // Gets a map of API name (aka namespace) to API schema. | 48 // Gets a map of API name (aka namespace) to API schema. |
| 43 const SchemaMap& schemas() { return schemas_; } | 49 const SchemaMap& schemas() { return schemas_; } |
| 44 | 50 |
| 45 // Gets the schema for the extension API with namespace |api_name|. | 51 // Gets the schema for the extension API with namespace |api_name|. |
| 46 // Ownership remains with this object. | 52 // Ownership remains with this object. |
| 47 const base::DictionaryValue* GetSchema(const std::string& api_name) const; | 53 const base::DictionaryValue* GetSchema(const std::string& api_name) const; |
| 48 | 54 |
| 49 // Gets the API schemas that are available to an Extension. | 55 // Gets the API schemas that are available to an Extension. |
| 50 void GetSchemasForExtension(const Extension& extension, SchemaMap* out) const; | 56 void GetSchemasForExtension(const Extension& extension, SchemaMap* out) const; |
| 51 | 57 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 81 | 87 |
| 82 // Adds dependent schemas to |out| as determined by the "dependencies" | 88 // Adds dependent schemas to |out| as determined by the "dependencies" |
| 83 // property. | 89 // property. |
| 84 void ResolveDependencies(SchemaMap* out) const; | 90 void ResolveDependencies(SchemaMap* out) const; |
| 85 | 91 |
| 86 static ExtensionAPI* instance_; | 92 static ExtensionAPI* instance_; |
| 87 | 93 |
| 88 // Schemas for each namespace. | 94 // Schemas for each namespace. |
| 89 SchemaMap schemas_; | 95 SchemaMap schemas_; |
| 90 | 96 |
| 97 // APIs that are entirely unprivileged. | |
| 98 std::set<std::string> completely_unprivileged_apis_; | |
| 99 | |
| 100 // APIs that are not entirely unprivileged, but have unprivileged components. | |
| 101 std::set<std::string> partially_unprivileged_apis_; | |
| 102 | |
| 91 DISALLOW_COPY_AND_ASSIGN(ExtensionAPI); | 103 DISALLOW_COPY_AND_ASSIGN(ExtensionAPI); |
| 92 }; | 104 }; |
| 93 | 105 |
| 94 } // extensions | 106 } // extensions |
| 95 | 107 |
| 96 #endif // CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_ | 108 #endif // CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_ |
| OLD | NEW |