OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // IPC messages for extensions. | 5 // IPC messages for extensions. |
6 // Multiply-included message file, hence no include guard. | 6 // Multiply-included message file, hence no include guard. |
7 | 7 |
8 #include "base/shared_memory.h" | 8 #include "base/shared_memory.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
| 11 #include "chrome/common/extensions/extension_permission_set.h" |
11 #include "chrome/common/extensions/url_pattern.h" | 12 #include "chrome/common/extensions/url_pattern.h" |
12 #include "chrome/common/extensions/url_pattern_set.h" | 13 #include "chrome/common/extensions/url_pattern_set.h" |
13 #include "chrome/common/web_apps.h" | 14 #include "chrome/common/web_apps.h" |
14 #include "content/common/view_types.h" | 15 #include "content/common/view_types.h" |
15 #include "ipc/ipc_message_macros.h" | 16 #include "ipc/ipc_message_macros.h" |
16 | 17 |
17 #define IPC_MESSAGE_START ExtensionMsgStart | 18 #define IPC_MESSAGE_START ExtensionMsgStart |
18 | 19 |
19 IPC_ENUM_TRAITS(ViewType::Type) | 20 IPC_ENUM_TRAITS(ViewType::Type) |
20 | 21 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 #define CHROME_COMMON_EXTENSIONS_EXTENSION_MESSAGES_H_ | 84 #define CHROME_COMMON_EXTENSIONS_EXTENSION_MESSAGES_H_ |
84 | 85 |
85 // IPC_MESSAGE macros choke on extra , in the std::map, when expanding. We need | 86 // IPC_MESSAGE macros choke on extra , in the std::map, when expanding. We need |
86 // to typedef it to avoid that. | 87 // to typedef it to avoid that. |
87 // Substitution map for l10n messages. | 88 // Substitution map for l10n messages. |
88 typedef std::map<std::string, std::string> SubstitutionMap; | 89 typedef std::map<std::string, std::string> SubstitutionMap; |
89 | 90 |
90 struct ExtensionMsg_Loaded_Params { | 91 struct ExtensionMsg_Loaded_Params { |
91 ExtensionMsg_Loaded_Params(); | 92 ExtensionMsg_Loaded_Params(); |
92 ~ExtensionMsg_Loaded_Params(); | 93 ~ExtensionMsg_Loaded_Params(); |
93 explicit ExtensionMsg_Loaded_Params(const Extension* extension); | 94 explicit ExtensionMsg_Loaded_Params( |
| 95 const Extension* extension, |
| 96 const ExtensionPermissionSet* active_permissions); |
94 | 97 |
95 // A copy constructor is needed because this structure can end up getting | 98 // A copy constructor is needed because this structure can end up getting |
96 // copied inside the IPC machinery on gcc <= 4.2. | 99 // copied inside the IPC machinery on gcc <= 4.2. |
97 ExtensionMsg_Loaded_Params(const ExtensionMsg_Loaded_Params& other); | 100 ExtensionMsg_Loaded_Params(const ExtensionMsg_Loaded_Params& other); |
98 | 101 |
99 // Creates a new extension from the data in this object. | 102 // Creates a new extension from the data in this object. |
100 scoped_refptr<Extension> ConvertToExtension() const; | 103 scoped_refptr<Extension> ConvertToExtension() const; |
101 | 104 |
| 105 // Passes ownership to the caller. |
| 106 const ExtensionPermissionSet* GetActivePermissions() const; |
| 107 |
102 // The subset of the extension manifest data we send to renderers. | 108 // The subset of the extension manifest data we send to renderers. |
103 scoped_ptr<DictionaryValue> manifest; | 109 scoped_ptr<DictionaryValue> manifest; |
104 | 110 |
105 // The location the extension was installed from. | 111 // The location the extension was installed from. |
106 Extension::Location location; | 112 Extension::Location location; |
107 | 113 |
108 // The path the extension was loaded from. This is used in the renderer only | 114 // The path the extension was loaded from. This is used in the renderer only |
109 // to generate the extension ID for extensions that are loaded unpacked. | 115 // to generate the extension ID for extensions that are loaded unpacked. |
110 FilePath path; | 116 FilePath path; |
111 | 117 |
| 118 // The extension's current active permissions. |
| 119 ExtensionAPIPermissionSet apis; |
| 120 URLPatternSet explicit_hosts; |
| 121 URLPatternSet scriptable_hosts; |
| 122 |
112 // We keep this separate so that it can be used in logging. | 123 // We keep this separate so that it can be used in logging. |
113 std::string id; | 124 std::string id; |
114 }; | 125 }; |
115 | 126 |
116 namespace IPC { | 127 namespace IPC { |
117 | 128 |
118 template <> | 129 template <> |
119 struct ParamTraits<URLPattern> { | 130 struct ParamTraits<URLPattern> { |
120 typedef URLPattern param_type; | 131 typedef URLPattern param_type; |
121 static void Write(Message* m, const param_type& p); | 132 static void Write(Message* m, const param_type& p); |
122 static bool Read(const Message* m, void** iter, param_type* p); | 133 static bool Read(const Message* m, void** iter, param_type* p); |
123 static void Log(const param_type& p, std::string* l); | 134 static void Log(const param_type& p, std::string* l); |
124 }; | 135 }; |
125 | 136 |
126 template <> | 137 template <> |
127 struct ParamTraits<URLPatternSet> { | 138 struct ParamTraits<URLPatternSet> { |
128 typedef URLPatternSet param_type; | 139 typedef URLPatternSet param_type; |
129 static void Write(Message* m, const param_type& p); | 140 static void Write(Message* m, const param_type& p); |
130 static bool Read(const Message* m, void** iter, param_type* p); | 141 static bool Read(const Message* m, void** iter, param_type* p); |
131 static void Log(const param_type& p, std::string* l); | 142 static void Log(const param_type& p, std::string* l); |
132 }; | 143 }; |
133 | 144 |
134 template <> | 145 template <> |
| 146 struct ParamTraits<ExtensionAPIPermission::ID> { |
| 147 typedef ExtensionAPIPermission::ID param_type; |
| 148 static void Write(Message* m, const param_type& p); |
| 149 static bool Read(const Message* m, void** iter, param_type* p); |
| 150 static void Log(const param_type& p, std::string* l); |
| 151 }; |
| 152 |
| 153 template <> |
135 struct ParamTraits<ExtensionMsg_Loaded_Params> { | 154 struct ParamTraits<ExtensionMsg_Loaded_Params> { |
136 typedef ExtensionMsg_Loaded_Params param_type; | 155 typedef ExtensionMsg_Loaded_Params param_type; |
137 static void Write(Message* m, const param_type& p); | 156 static void Write(Message* m, const param_type& p); |
138 static bool Read(const Message* m, void** iter, param_type* p); | 157 static bool Read(const Message* m, void** iter, param_type* p); |
139 static void Log(const param_type& p, std::string* l); | 158 static void Log(const param_type& p, std::string* l); |
140 }; | 159 }; |
141 | 160 |
142 } // namespace IPC | 161 } // namespace IPC |
143 | 162 |
144 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_MESSAGES_H_ | 163 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_MESSAGES_H_ |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 223 |
205 // Requests application info for the page. The renderer responds back with | 224 // Requests application info for the page. The renderer responds back with |
206 // ExtensionHostMsg_DidGetApplicationInfo. | 225 // ExtensionHostMsg_DidGetApplicationInfo. |
207 IPC_MESSAGE_ROUTED1(ExtensionMsg_GetApplicationInfo, | 226 IPC_MESSAGE_ROUTED1(ExtensionMsg_GetApplicationInfo, |
208 int32 /*page_id*/) | 227 int32 /*page_id*/) |
209 | 228 |
210 // Tell the renderer which browser window it's being attached to. | 229 // Tell the renderer which browser window it's being attached to. |
211 IPC_MESSAGE_ROUTED1(ExtensionMsg_UpdateBrowserWindowId, | 230 IPC_MESSAGE_ROUTED1(ExtensionMsg_UpdateBrowserWindowId, |
212 int /* id of browser window */) | 231 int /* id of browser window */) |
213 | 232 |
| 233 // Tell the renderer to update an extension's permission set. |
| 234 IPC_MESSAGE_CONTROL4(ExtensionMsg_UpdatePermissions, |
| 235 std::string /* extension_id*/, |
| 236 ExtensionAPIPermissionSet, |
| 237 URLPatternSet, |
| 238 URLPatternSet) |
214 // Tell the renderer which type this view is. | 239 // Tell the renderer which type this view is. |
215 IPC_MESSAGE_ROUTED1(ExtensionMsg_NotifyRenderViewType, | 240 IPC_MESSAGE_ROUTED1(ExtensionMsg_NotifyRenderViewType, |
216 ViewType::Type /* view_type */) | 241 ViewType::Type /* view_type */) |
217 | 242 |
218 // Messages sent from the renderer to the browser. | 243 // Messages sent from the renderer to the browser. |
219 | 244 |
220 // A renderer sends this message when an extension process starts an API | 245 // A renderer sends this message when an extension process starts an API |
221 // request. The browser will always respond with a ExtensionMsg_Response. | 246 // request. The browser will always respond with a ExtensionMsg_Response. |
222 IPC_MESSAGE_ROUTED1(ExtensionHostMsg_Request, | 247 IPC_MESSAGE_ROUTED1(ExtensionHostMsg_Request, |
223 ExtensionHostMsg_Request_Params) | 248 ExtensionHostMsg_Request_Params) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 bool /* whether the script ran successfully */, | 306 bool /* whether the script ran successfully */, |
282 std::string /* error message */) | 307 std::string /* error message */) |
283 | 308 |
284 IPC_MESSAGE_ROUTED2(ExtensionHostMsg_DidGetApplicationInfo, | 309 IPC_MESSAGE_ROUTED2(ExtensionHostMsg_DidGetApplicationInfo, |
285 int32 /* page_id */, | 310 int32 /* page_id */, |
286 WebApplicationInfo) | 311 WebApplicationInfo) |
287 | 312 |
288 // Sent by the renderer to implement chrome.app.installApplication(). | 313 // Sent by the renderer to implement chrome.app.installApplication(). |
289 IPC_MESSAGE_ROUTED1(ExtensionHostMsg_InstallApplication, | 314 IPC_MESSAGE_ROUTED1(ExtensionHostMsg_InstallApplication, |
290 WebApplicationInfo) | 315 WebApplicationInfo) |
OLD | NEW |