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

Side by Side Diff: chrome/common/extensions/api/extension_api.h

Issue 9460002: Convert app_bindings.js to the schema_generated_bindings.js infrastructure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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) 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 <set>
11 #include <string> 11 #include <string>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/memory/linked_ptr.h" 14 #include "base/memory/linked_ptr.h"
15 #include "base/memory/singleton.h" 15 #include "base/memory/singleton.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "chrome/common/extensions/url_pattern_set.h"
17 18
18 namespace base { 19 namespace base {
19 class DictionaryValue; 20 class DictionaryValue;
20 class ListValue; 21 class ListValue;
21 class Value; 22 class Value;
22 } 23 }
23 24
25 class GURL;
24 class Extension; 26 class Extension;
25 class ExtensionPermissionSet; 27 class ExtensionPermissionSet;
26 28
27 namespace extensions { 29 namespace extensions {
28 30
29 // C++ Wrapper for the JSON API definitions in chrome/common/extensions/api/. 31 // C++ Wrapper for the JSON API definitions in chrome/common/extensions/api/.
30 class ExtensionAPI { 32 class ExtensionAPI {
31 public: 33 public:
32 // Filtering option for the GetSchemas functions. 34 // Filtering option for the GetSchemas functions.
33 enum GetSchemasFilter { 35 enum GetSchemasFilter {
(...skipping 14 matching lines...) Expand all
48 // be called from extension code which is running in its own designated 50 // be called from extension code which is running in its own designated
49 // extension process. They cannot be called from extension code running in 51 // extension process. They cannot be called from extension code running in
50 // content scripts, or other low-privileged contexts. 52 // content scripts, or other low-privileged contexts.
51 bool IsPrivileged(const std::string& name) const; 53 bool IsPrivileged(const std::string& name) const;
52 54
53 // Returns whether *every* path in the API is privileged. This will be false 55 // Returns whether *every* path in the API is privileged. This will be false
54 // for APIs such as "storage" which is entirely unprivileged, and "test" 56 // for APIs such as "storage" which is entirely unprivileged, and "test"
55 // which has unprivileged components. 57 // which has unprivileged components.
56 bool IsWholeAPIPrivileged(const std::string& api_name) const; 58 bool IsWholeAPIPrivileged(const std::string& api_name) const;
57 59
60 // Returns whether an API matches |url|.
61 bool MatchesURL(const std::string& api_name, const GURL& url) const;
62
58 // Gets a map of API name (aka namespace) to API schema. 63 // Gets a map of API name (aka namespace) to API schema.
59 const SchemaMap& schemas() { return schemas_; } 64 const SchemaMap& schemas() { return schemas_; }
60 65
61 // Gets the schema for the extension API with namespace |api_name|. 66 // Gets the schema for the extension API with namespace |api_name|.
62 // Ownership remains with this object. 67 // Ownership remains with this object.
63 const base::DictionaryValue* GetSchema(const std::string& api_name) const; 68 const base::DictionaryValue* GetSchema(const std::string& api_name) const;
64 69
65 // Gets the API schemas that are available to an Extension. 70 // Gets the API schemas that are available to an Extension.
66 void GetSchemasForExtension(const Extension& extension, 71 void GetSchemasForExtension(const Extension& extension,
67 GetSchemasFilter filter, 72 GetSchemasFilter filter,
68 SchemaMap* out) const; 73 SchemaMap* out) const;
69 74
70 // Gets the schemas for the default set of APIs that are available to every 75 // Gets the schemas for the default set of APIs that are available to every
71 // extension. 76 // extension.
72 void GetDefaultSchemas(GetSchemasFilter filter, SchemaMap* out) const; 77 void GetDefaultSchemas(GetSchemasFilter filter, SchemaMap* out) const;
73 78
79 // Gets the APIs exposed to |url|.
80 void GetSchemasForURL(const GURL& url, SchemaMap* out) const;
81
74 private: 82 private:
75 friend struct DefaultSingletonTraits<ExtensionAPI>; 83 friend struct DefaultSingletonTraits<ExtensionAPI>;
76 84
77 ExtensionAPI(); 85 ExtensionAPI();
78 ~ExtensionAPI(); 86 ~ExtensionAPI();
79 87
80 // Loads a schema from a resource. 88 // Loads a schema from a resource.
81 void LoadSchemaFromResource(int resource_id); 89 void LoadSchemaFromResource(int resource_id);
82 90
83 // Find an item in |list| with the specified property name and value, or NULL 91 // Find an item in |list| with the specified property name and value, or NULL
(...skipping 22 matching lines...) Expand all
106 114
107 // Schemas for each namespace. 115 // Schemas for each namespace.
108 SchemaMap schemas_; 116 SchemaMap schemas_;
109 117
110 // APIs that are entirely unprivileged. 118 // APIs that are entirely unprivileged.
111 std::set<std::string> completely_unprivileged_apis_; 119 std::set<std::string> completely_unprivileged_apis_;
112 120
113 // APIs that are not entirely unprivileged, but have unprivileged components. 121 // APIs that are not entirely unprivileged, but have unprivileged components.
114 std::set<std::string> partially_unprivileged_apis_; 122 std::set<std::string> partially_unprivileged_apis_;
115 123
124 // APIs that have URL matching permissions.
125 std::map<std::string, URLPatternSet> url_matching_apis_;
126
116 DISALLOW_COPY_AND_ASSIGN(ExtensionAPI); 127 DISALLOW_COPY_AND_ASSIGN(ExtensionAPI);
117 }; 128 };
118 129
119 } // extensions 130 } // extensions
120 131
121 #endif // CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_ 132 #endif // CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698