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 // Send creation flags so extension is initialized identically. | 126 // Send creation flags so extension is initialized identically. |
116 int creation_flags; | 127 int creation_flags; |
117 }; | 128 }; |
118 | 129 |
119 namespace IPC { | 130 namespace IPC { |
120 | 131 |
121 template <> | 132 template <> |
122 struct ParamTraits<URLPattern> { | 133 struct ParamTraits<URLPattern> { |
123 typedef URLPattern param_type; | 134 typedef URLPattern param_type; |
124 static void Write(Message* m, const param_type& p); | 135 static void Write(Message* m, const param_type& p); |
125 static bool Read(const Message* m, void** iter, param_type* p); | 136 static bool Read(const Message* m, void** iter, param_type* p); |
126 static void Log(const param_type& p, std::string* l); | 137 static void Log(const param_type& p, std::string* l); |
127 }; | 138 }; |
128 | 139 |
129 template <> | 140 template <> |
130 struct ParamTraits<URLPatternSet> { | 141 struct ParamTraits<URLPatternSet> { |
131 typedef URLPatternSet param_type; | 142 typedef URLPatternSet param_type; |
132 static void Write(Message* m, const param_type& p); | 143 static void Write(Message* m, const param_type& p); |
133 static bool Read(const Message* m, void** iter, param_type* p); | 144 static bool Read(const Message* m, void** iter, param_type* p); |
134 static void Log(const param_type& p, std::string* l); | 145 static void Log(const param_type& p, std::string* l); |
135 }; | 146 }; |
136 | 147 |
137 template <> | 148 template <> |
| 149 struct ParamTraits<ExtensionAPIPermission::ID> { |
| 150 typedef ExtensionAPIPermission::ID param_type; |
| 151 static void Write(Message* m, const param_type& p); |
| 152 static bool Read(const Message* m, void** iter, param_type* p); |
| 153 static void Log(const param_type& p, std::string* l); |
| 154 }; |
| 155 |
| 156 template <> |
138 struct ParamTraits<ExtensionMsg_Loaded_Params> { | 157 struct ParamTraits<ExtensionMsg_Loaded_Params> { |
139 typedef ExtensionMsg_Loaded_Params param_type; | 158 typedef ExtensionMsg_Loaded_Params param_type; |
140 static void Write(Message* m, const param_type& p); | 159 static void Write(Message* m, const param_type& p); |
141 static bool Read(const Message* m, void** iter, param_type* p); | 160 static bool Read(const Message* m, void** iter, param_type* p); |
142 static void Log(const param_type& p, std::string* l); | 161 static void Log(const param_type& p, std::string* l); |
143 }; | 162 }; |
144 | 163 |
145 } // namespace IPC | 164 } // namespace IPC |
146 | 165 |
147 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_MESSAGES_H_ | 166 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_MESSAGES_H_ |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 226 |
208 // Requests application info for the page. The renderer responds back with | 227 // Requests application info for the page. The renderer responds back with |
209 // ExtensionHostMsg_DidGetApplicationInfo. | 228 // ExtensionHostMsg_DidGetApplicationInfo. |
210 IPC_MESSAGE_ROUTED1(ExtensionMsg_GetApplicationInfo, | 229 IPC_MESSAGE_ROUTED1(ExtensionMsg_GetApplicationInfo, |
211 int32 /*page_id*/) | 230 int32 /*page_id*/) |
212 | 231 |
213 // Tell the renderer which browser window it's being attached to. | 232 // Tell the renderer which browser window it's being attached to. |
214 IPC_MESSAGE_ROUTED1(ExtensionMsg_UpdateBrowserWindowId, | 233 IPC_MESSAGE_ROUTED1(ExtensionMsg_UpdateBrowserWindowId, |
215 int /* id of browser window */) | 234 int /* id of browser window */) |
216 | 235 |
| 236 // Tell the renderer to update an extension's permission set. |
| 237 IPC_MESSAGE_CONTROL4(ExtensionMsg_UpdatePermissions, |
| 238 std::string /* extension_id*/, |
| 239 ExtensionAPIPermissionSet, |
| 240 URLPatternSet, |
| 241 URLPatternSet) |
| 242 |
217 // Tell the renderer which type this view is. | 243 // Tell the renderer which type this view is. |
218 IPC_MESSAGE_ROUTED1(ExtensionMsg_NotifyRenderViewType, | 244 IPC_MESSAGE_ROUTED1(ExtensionMsg_NotifyRenderViewType, |
219 ViewType::Type /* view_type */) | 245 ViewType::Type /* view_type */) |
220 | 246 |
221 // Messages sent from the renderer to the browser. | 247 // Messages sent from the renderer to the browser. |
222 | 248 |
223 // A renderer sends this message when an extension process starts an API | 249 // A renderer sends this message when an extension process starts an API |
224 // request. The browser will always respond with a ExtensionMsg_Response. | 250 // request. The browser will always respond with a ExtensionMsg_Response. |
225 IPC_MESSAGE_ROUTED1(ExtensionHostMsg_Request, | 251 IPC_MESSAGE_ROUTED1(ExtensionHostMsg_Request, |
226 ExtensionHostMsg_Request_Params) | 252 ExtensionHostMsg_Request_Params) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 bool /* whether the script ran successfully */, | 310 bool /* whether the script ran successfully */, |
285 std::string /* error message */) | 311 std::string /* error message */) |
286 | 312 |
287 IPC_MESSAGE_ROUTED2(ExtensionHostMsg_DidGetApplicationInfo, | 313 IPC_MESSAGE_ROUTED2(ExtensionHostMsg_DidGetApplicationInfo, |
288 int32 /* page_id */, | 314 int32 /* page_id */, |
289 WebApplicationInfo) | 315 WebApplicationInfo) |
290 | 316 |
291 // Sent by the renderer to implement chrome.app.installApplication(). | 317 // Sent by the renderer to implement chrome.app.installApplication(). |
292 IPC_MESSAGE_ROUTED1(ExtensionHostMsg_InstallApplication, | 318 IPC_MESSAGE_ROUTED1(ExtensionHostMsg_InstallApplication, |
293 WebApplicationInfo) | 319 WebApplicationInfo) |
OLD | NEW |