1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/render_messages_params.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/render_messages.h"
ViewMsg_ExecuteCode_Params::ViewMsg_ExecuteCode_Params() {
}
ViewMsg_ExecuteCode_Params::ViewMsg_ExecuteCode_Params(
int request_id,
const std::string& extension_id,
bool is_javascript,
const std::string& code,
bool all_frames)
: request_id(request_id), extension_id(extension_id),
is_javascript(is_javascript),
code(code), all_frames(all_frames) {
}
ViewMsg_ExecuteCode_Params::~ViewMsg_ExecuteCode_Params() {
}
ViewHostMsg_DomMessage_Params::ViewHostMsg_DomMessage_Params()
: request_id(0),
has_callback(false),
user_gesture(false) {
}
ViewHostMsg_DomMessage_Params::~ViewHostMsg_DomMessage_Params() {
}
ViewMsg_ExtensionLoaded_Params::ViewMsg_ExtensionLoaded_Params()
: location(Extension::INVALID) {
}
ViewMsg_ExtensionLoaded_Params::~ViewMsg_ExtensionLoaded_Params() {
}
ViewMsg_ExtensionLoaded_Params::ViewMsg_ExtensionLoaded_Params(
const ViewMsg_ExtensionLoaded_Params& other)
: manifest(other.manifest->DeepCopy()),
location(other.location),
path(other.path),
id(other.id) {
}
ViewMsg_ExtensionLoaded_Params::ViewMsg_ExtensionLoaded_Params(
const Extension* extension)
: manifest(new DictionaryValue()),
location(extension->location()),
path(extension->path()),
id(extension->id()) {
// As we need more bits of extension data in the renderer, add more keys to
// this list.
const char* kRendererExtensionKeys[] = {
extension_manifest_keys::kPublicKey,
extension_manifest_keys::kName,
extension_manifest_keys::kVersion,
extension_manifest_keys::kIcons,
extension_manifest_keys::kPermissions,
extension_manifest_keys::kApp
};
// Copy only the data we need.
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRendererExtensionKeys); ++i) {
Value* temp = NULL;
if (extension->manifest_value()->Get(kRendererExtensionKeys[i], &temp))
manifest->Set(kRendererExtensionKeys[i], temp->DeepCopy());
}
}
scoped_refptr<Extension>
ViewMsg_ExtensionLoaded_Params::ConvertToExtension() const {
// Extensions that are loaded unpacked won't have a key.
const bool kRequireKey = false;
// The extension may have been loaded in a way that does not require
// strict error checks to pass. Do not do strict checks here.
const bool kStrictErrorChecks = false;
std::string error;
scoped_refptr<Extension> extension(
Extension::Create(path, location, *manifest, kRequireKey,
kStrictErrorChecks, &error));
if (!extension.get())
LOG(ERROR) << "Error deserializing extension: " << error;
return extension;
}
namespace IPC {
template <>
struct ParamTraits<Extension::Location> {
typedef Extension::Location param_type;
static void Write(Message* m, const param_type& p) {
int val = static_cast<int>(p);
WriteParam(m, val);
}
static bool Read(const Message* m, void** iter, param_type* p) {
int val = 0;
if (!ReadParam(m, iter, &val) ||
val < Extension::INVALID ||
val >= Extension::NUM_LOCATIONS)
return false;
*p = static_cast<param_type>(val);
return true;
}
static void Log(const param_type& p, std::string* l) {
ParamTraits<int>::Log(static_cast<int>(p), l);
}
};
void ParamTraits<ViewHostMsg_PageHasOSDD_Type>::Write(Message* m,
const param_type& p) {
m->WriteInt(p.type);
}
bool ParamTraits<ViewHostMsg_PageHasOSDD_Type>::Read(const Message* m,
void** iter,
param_type* p) {
int type;
if (!m->ReadInt(iter, &type))
return false;
p->type = static_cast<param_type::Type>(type);
return true;
}
void ParamTraits<ViewHostMsg_PageHasOSDD_Type>::Log(const param_type& p,
std::string* l) {
std::string type;
switch (p.type) {
case ViewHostMsg_PageHasOSDD_Type::AUTODETECTED_PROVIDER:
type = "ViewHostMsg_PageHasOSDD_Type::AUTODETECTED_PROVIDER";
break;
case ViewHostMsg_PageHasOSDD_Type::EXPLICIT_PROVIDER:
type = "ViewHostMsg_PageHasOSDD_Type::EXPLICIT_PROVIDER";
break;
case ViewHostMsg_PageHasOSDD_Type::EXPLICIT_DEFAULT_PROVIDER:
type = "ViewHostMsg_PageHasOSDD_Type::EXPLICIT_DEFAULT_PROVIDER";
break;
default:
type = "UNKNOWN";
break;
}
LogParam(type, l);
}
void ParamTraits<ViewHostMsg_GetSearchProviderInstallState_Params>::Write(
Message* m, const param_type& p) {
m->WriteInt(p.state);
}
bool ParamTraits<ViewHostMsg_GetSearchProviderInstallState_Params>::Read(
const Message* m, void** iter, param_type* p) {
int type;
if (!m->ReadInt(iter, &type))
return false;
p->state = static_cast<param_type::State>(type);
return true;
}
void ParamTraits<ViewHostMsg_GetSearchProviderInstallState_Params>::Log(
const param_type& p, std::string* l) {
std::string state;
switch (p.state) {
case ViewHostMsg_GetSearchProviderInstallState_Params::DENIED:
state = "ViewHostMsg_GetSearchProviderInstallState_Params::DENIED";
break;
case ViewHostMsg_GetSearchProviderInstallState_Params::NOT_INSTALLED:
state =
"ViewHostMsg_GetSearchProviderInstallState_Params::NOT_INSTALLED";
break;
case ViewHostMsg_GetSearchProviderInstallState_Params::
INSTALLED_BUT_NOT_DEFAULT:
state = "ViewHostMsg_GetSearchProviderInstallState_Params::"
"INSTALLED_BUT_NOT_DEFAULT";
break;
case ViewHostMsg_GetSearchProviderInstallState_Params::
INSTALLED_AS_DEFAULT:
state = "ViewHostMsg_GetSearchProviderInstallState_Params::"
"INSTALLED_AS_DEFAULT";
break;
default:
state = "UNKNOWN";
break;
}
LogParam(state, l);
}
void ParamTraits<ViewMsg_ExecuteCode_Params>::Write(Message* m,
const param_type& p) {
WriteParam(m, p.request_id);
WriteParam(m, p.extension_id);
WriteParam(m, p.is_javascript);
WriteParam(m, p.code);
WriteParam(m, p.all_frames);
}
bool ParamTraits<ViewMsg_ExecuteCode_Params>::Read(const Message* m,
void** iter,
param_type* p) {
return
ReadParam(m, iter, &p->request_id) &&
ReadParam(m, iter, &p->extension_id) &&
ReadParam(m, iter, &p->is_javascript) &&
ReadParam(m, iter, &p->code) &&
ReadParam(m, iter, &p->all_frames);
}
void ParamTraits<ViewMsg_ExecuteCode_Params>::Log(const param_type& p,
std::string* l) {
l->append("<ViewMsg_ExecuteCode_Params>");
}
void ParamTraits<ViewMsg_ExtensionLoaded_Params>::Write(Message* m,
const param_type& p) {
WriteParam(m, p.location);
WriteParam(m, p.path);
WriteParam(m, *(p.manifest));
}
bool ParamTraits<ViewMsg_ExtensionLoaded_Params>::Read(const Message* m,
void** iter,
param_type* p) {
p->manifest.reset(new DictionaryValue());
return ReadParam(m, iter, &p->location) &&
ReadParam(m, iter, &p->path) &&
ReadParam(m, iter, p->manifest.get());
}
void ParamTraits<ViewMsg_ExtensionLoaded_Params>::Log(const param_type& p,
std::string* l) {
l->append(p.id);
}
void ParamTraits<ViewHostMsg_DomMessage_Params>::Write(Message* m,
const param_type& p) {
WriteParam(m, p.name);
WriteParam(m, p.arguments);
WriteParam(m, p.source_url);
WriteParam(m, p.request_id);
WriteParam(m, p.has_callback);
WriteParam(m, p.user_gesture);
}
bool ParamTraits<ViewHostMsg_DomMessage_Params>::Read(const Message* m,
void** iter,
param_type* p) {
return
ReadParam(m, iter, &p->name) &&
ReadParam(m, iter, &p->arguments) &&
ReadParam(m, iter, &p->source_url) &&
ReadParam(m, iter, &p->request_id) &&
ReadParam(m, iter, &p->has_callback) &&
ReadParam(m, iter, &p->user_gesture);
}
void ParamTraits<ViewHostMsg_DomMessage_Params>::Log(const param_type& p,
std::string* l) {
l->append("(");
LogParam(p.name, l);
l->append(", ");
LogParam(p.arguments, l);
l->append(", ");
LogParam(p.source_url, l);
l->append(", ");
LogParam(p.request_id, l);
l->append(", ");
LogParam(p.has_callback, l);
l->append(", ");
LogParam(p.user_gesture, l);
l->append(")");
}
} // namespace IPC
|