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

Side by Side Diff: chrome/common/render_messages_params.cc

Issue 6735004: Move extension messages to their own file and add a RenderViewObserver to start moving the extens... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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
« no previous file with comments | « chrome/common/render_messages_params.h ('k') | chrome/renderer/extensions/event_bindings.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/common/render_messages_params.h" 5 #include "chrome/common/render_messages_params.h"
6 6
7 #include "chrome/common/extensions/extension_constants.h"
8 #include "chrome/common/render_messages.h" 7 #include "chrome/common/render_messages.h"
9 8
10 ViewMsg_ExecuteCode_Params::ViewMsg_ExecuteCode_Params() {
11 }
12
13 ViewMsg_ExecuteCode_Params::ViewMsg_ExecuteCode_Params(
14 int request_id,
15 const std::string& extension_id,
16 bool is_javascript,
17 const std::string& code,
18 bool all_frames)
19 : request_id(request_id), extension_id(extension_id),
20 is_javascript(is_javascript),
21 code(code), all_frames(all_frames) {
22 }
23
24 ViewMsg_ExecuteCode_Params::~ViewMsg_ExecuteCode_Params() {
25 }
26
27 ViewHostMsg_DomMessage_Params::ViewHostMsg_DomMessage_Params()
28 : request_id(0),
29 has_callback(false),
30 user_gesture(false) {
31 }
32
33 ViewHostMsg_DomMessage_Params::~ViewHostMsg_DomMessage_Params() {
34 }
35
36 ViewMsg_ExtensionLoaded_Params::ViewMsg_ExtensionLoaded_Params()
37 : location(Extension::INVALID) {
38 }
39
40 ViewMsg_ExtensionLoaded_Params::~ViewMsg_ExtensionLoaded_Params() {
41 }
42
43 ViewMsg_ExtensionLoaded_Params::ViewMsg_ExtensionLoaded_Params(
44 const ViewMsg_ExtensionLoaded_Params& other)
45 : manifest(other.manifest->DeepCopy()),
46 location(other.location),
47 path(other.path),
48 id(other.id) {
49 }
50
51 ViewMsg_ExtensionLoaded_Params::ViewMsg_ExtensionLoaded_Params(
52 const Extension* extension)
53 : manifest(new DictionaryValue()),
54 location(extension->location()),
55 path(extension->path()),
56 id(extension->id()) {
57 // As we need more bits of extension data in the renderer, add more keys to
58 // this list.
59 const char* kRendererExtensionKeys[] = {
60 extension_manifest_keys::kPublicKey,
61 extension_manifest_keys::kName,
62 extension_manifest_keys::kVersion,
63 extension_manifest_keys::kIcons,
64 extension_manifest_keys::kPermissions,
65 extension_manifest_keys::kApp
66 };
67
68 // Copy only the data we need.
69 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRendererExtensionKeys); ++i) {
70 Value* temp = NULL;
71 if (extension->manifest_value()->Get(kRendererExtensionKeys[i], &temp))
72 manifest->Set(kRendererExtensionKeys[i], temp->DeepCopy());
73 }
74 }
75
76 scoped_refptr<Extension>
77 ViewMsg_ExtensionLoaded_Params::ConvertToExtension() const {
78 // Extensions that are loaded unpacked won't have a key.
79 const bool kRequireKey = false;
80
81 // The extension may have been loaded in a way that does not require
82 // strict error checks to pass. Do not do strict checks here.
83 const bool kStrictErrorChecks = false;
84 std::string error;
85
86 scoped_refptr<Extension> extension(
87 Extension::Create(path, location, *manifest, kRequireKey,
88 kStrictErrorChecks, &error));
89 if (!extension.get())
90 LOG(ERROR) << "Error deserializing extension: " << error;
91
92 return extension;
93 }
94
95 namespace IPC { 9 namespace IPC {
96 10
97 template <>
98 struct ParamTraits<Extension::Location> {
99 typedef Extension::Location param_type;
100 static void Write(Message* m, const param_type& p) {
101 int val = static_cast<int>(p);
102 WriteParam(m, val);
103 }
104 static bool Read(const Message* m, void** iter, param_type* p) {
105 int val = 0;
106 if (!ReadParam(m, iter, &val) ||
107 val < Extension::INVALID ||
108 val >= Extension::NUM_LOCATIONS)
109 return false;
110 *p = static_cast<param_type>(val);
111 return true;
112 }
113 static void Log(const param_type& p, std::string* l) {
114 ParamTraits<int>::Log(static_cast<int>(p), l);
115 }
116 };
117
118 void ParamTraits<ViewHostMsg_PageHasOSDD_Type>::Write(Message* m, 11 void ParamTraits<ViewHostMsg_PageHasOSDD_Type>::Write(Message* m,
119 const param_type& p) { 12 const param_type& p) {
120 m->WriteInt(p.type); 13 m->WriteInt(p.type);
121 } 14 }
122 15
123 bool ParamTraits<ViewHostMsg_PageHasOSDD_Type>::Read(const Message* m, 16 bool ParamTraits<ViewHostMsg_PageHasOSDD_Type>::Read(const Message* m,
124 void** iter, 17 void** iter,
125 param_type* p) { 18 param_type* p) {
126 int type; 19 int type;
127 if (!m->ReadInt(iter, &type)) 20 if (!m->ReadInt(iter, &type))
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 state = "ViewHostMsg_GetSearchProviderInstallState_Params::" 78 state = "ViewHostMsg_GetSearchProviderInstallState_Params::"
186 "INSTALLED_AS_DEFAULT"; 79 "INSTALLED_AS_DEFAULT";
187 break; 80 break;
188 default: 81 default:
189 state = "UNKNOWN"; 82 state = "UNKNOWN";
190 break; 83 break;
191 } 84 }
192 LogParam(state, l); 85 LogParam(state, l);
193 } 86 }
194 87
195 void ParamTraits<ViewMsg_ExecuteCode_Params>::Write(Message* m,
196 const param_type& p) {
197 WriteParam(m, p.request_id);
198 WriteParam(m, p.extension_id);
199 WriteParam(m, p.is_javascript);
200 WriteParam(m, p.code);
201 WriteParam(m, p.all_frames);
202 }
203
204 bool ParamTraits<ViewMsg_ExecuteCode_Params>::Read(const Message* m,
205 void** iter,
206 param_type* p) {
207 return
208 ReadParam(m, iter, &p->request_id) &&
209 ReadParam(m, iter, &p->extension_id) &&
210 ReadParam(m, iter, &p->is_javascript) &&
211 ReadParam(m, iter, &p->code) &&
212 ReadParam(m, iter, &p->all_frames);
213 }
214
215 void ParamTraits<ViewMsg_ExecuteCode_Params>::Log(const param_type& p,
216 std::string* l) {
217 l->append("<ViewMsg_ExecuteCode_Params>");
218 }
219
220 void ParamTraits<ViewMsg_ExtensionLoaded_Params>::Write(Message* m,
221 const param_type& p) {
222 WriteParam(m, p.location);
223 WriteParam(m, p.path);
224 WriteParam(m, *(p.manifest));
225 }
226
227 bool ParamTraits<ViewMsg_ExtensionLoaded_Params>::Read(const Message* m,
228 void** iter,
229 param_type* p) {
230 p->manifest.reset(new DictionaryValue());
231 return ReadParam(m, iter, &p->location) &&
232 ReadParam(m, iter, &p->path) &&
233 ReadParam(m, iter, p->manifest.get());
234 }
235
236 void ParamTraits<ViewMsg_ExtensionLoaded_Params>::Log(const param_type& p,
237 std::string* l) {
238 l->append(p.id);
239 }
240
241 void ParamTraits<ViewHostMsg_DomMessage_Params>::Write(Message* m,
242 const param_type& p) {
243 WriteParam(m, p.name);
244 WriteParam(m, p.arguments);
245 WriteParam(m, p.source_url);
246 WriteParam(m, p.request_id);
247 WriteParam(m, p.has_callback);
248 WriteParam(m, p.user_gesture);
249 }
250
251 bool ParamTraits<ViewHostMsg_DomMessage_Params>::Read(const Message* m,
252 void** iter,
253 param_type* p) {
254 return
255 ReadParam(m, iter, &p->name) &&
256 ReadParam(m, iter, &p->arguments) &&
257 ReadParam(m, iter, &p->source_url) &&
258 ReadParam(m, iter, &p->request_id) &&
259 ReadParam(m, iter, &p->has_callback) &&
260 ReadParam(m, iter, &p->user_gesture);
261 }
262
263 void ParamTraits<ViewHostMsg_DomMessage_Params>::Log(const param_type& p,
264 std::string* l) {
265 l->append("(");
266 LogParam(p.name, l);
267 l->append(", ");
268 LogParam(p.arguments, l);
269 l->append(", ");
270 LogParam(p.source_url, l);
271 l->append(", ");
272 LogParam(p.request_id, l);
273 l->append(", ");
274 LogParam(p.has_callback, l);
275 l->append(", ");
276 LogParam(p.user_gesture, l);
277 l->append(")");
278 }
279
280 } // namespace IPC 88 } // namespace IPC
OLDNEW
« no previous file with comments | « chrome/common/render_messages_params.h ('k') | chrome/renderer/extensions/event_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698