OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/navigation_gesture.h" | 7 #include "chrome/common/navigation_gesture.h" |
8 #include "chrome/common/common_param_traits.h" | 8 #include "chrome/common/common_param_traits.h" |
| 9 #include "chrome/common/extensions/extension_constants.h" |
9 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
10 #include "net/base/upload_data.h" | 11 #include "net/base/upload_data.h" |
11 | 12 |
12 ViewMsg_Navigate_Params::ViewMsg_Navigate_Params() | 13 ViewMsg_Navigate_Params::ViewMsg_Navigate_Params() |
13 : page_id(-1), | 14 : page_id(-1), |
14 pending_history_list_offset(-1), | 15 pending_history_list_offset(-1), |
15 current_history_list_offset(-1), | 16 current_history_list_offset(-1), |
16 current_history_list_length(0), | 17 current_history_list_length(0), |
17 transition(PageTransition::LINK), | 18 transition(PageTransition::LINK), |
18 navigation_type(NORMAL) { | 19 navigation_type(NORMAL) { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 ViewHostMsg_CreateWindow_Params::~ViewHostMsg_CreateWindow_Params() { | 242 ViewHostMsg_CreateWindow_Params::~ViewHostMsg_CreateWindow_Params() { |
242 } | 243 } |
243 | 244 |
244 ViewHostMsg_RunFileChooser_Params::ViewHostMsg_RunFileChooser_Params() | 245 ViewHostMsg_RunFileChooser_Params::ViewHostMsg_RunFileChooser_Params() |
245 : mode(Open) { | 246 : mode(Open) { |
246 } | 247 } |
247 | 248 |
248 ViewHostMsg_RunFileChooser_Params::~ViewHostMsg_RunFileChooser_Params() { | 249 ViewHostMsg_RunFileChooser_Params::~ViewHostMsg_RunFileChooser_Params() { |
249 } | 250 } |
250 | 251 |
251 ViewMsg_ExtensionRendererInfo::ViewMsg_ExtensionRendererInfo() | |
252 : location(Extension::INVALID), | |
253 allowed_to_execute_script_everywhere(false) { | |
254 } | |
255 | |
256 ViewMsg_ExtensionRendererInfo::~ViewMsg_ExtensionRendererInfo() { | |
257 } | |
258 | |
259 ViewMsg_ExtensionsUpdated_Params::ViewMsg_ExtensionsUpdated_Params() { | |
260 } | |
261 | |
262 ViewMsg_ExtensionsUpdated_Params::~ViewMsg_ExtensionsUpdated_Params() { | |
263 } | |
264 | |
265 ViewMsg_DeviceOrientationUpdated_Params:: | 252 ViewMsg_DeviceOrientationUpdated_Params:: |
266 ViewMsg_DeviceOrientationUpdated_Params() | 253 ViewMsg_DeviceOrientationUpdated_Params() |
267 : can_provide_alpha(false), | 254 : can_provide_alpha(false), |
268 alpha(0), | 255 alpha(0), |
269 can_provide_beta(false), | 256 can_provide_beta(false), |
270 beta(0), | 257 beta(0), |
271 can_provide_gamma(false), | 258 can_provide_gamma(false), |
272 gamma(0) { | 259 gamma(0) { |
273 } | 260 } |
274 | 261 |
275 ViewMsg_DeviceOrientationUpdated_Params:: | 262 ViewMsg_DeviceOrientationUpdated_Params:: |
276 ~ViewMsg_DeviceOrientationUpdated_Params() { | 263 ~ViewMsg_DeviceOrientationUpdated_Params() { |
277 } | 264 } |
278 | 265 |
279 ViewHostMsg_DomMessage_Params::ViewHostMsg_DomMessage_Params() | 266 ViewHostMsg_DomMessage_Params::ViewHostMsg_DomMessage_Params() |
280 : request_id(0), | 267 : request_id(0), |
281 has_callback(false), | 268 has_callback(false), |
282 user_gesture(false) { | 269 user_gesture(false) { |
283 } | 270 } |
284 | 271 |
285 ViewHostMsg_DomMessage_Params::~ViewHostMsg_DomMessage_Params() { | 272 ViewHostMsg_DomMessage_Params::~ViewHostMsg_DomMessage_Params() { |
286 } | 273 } |
287 | 274 |
| 275 ViewMsg_ExtensionLoaded_Params::ViewMsg_ExtensionLoaded_Params() { |
| 276 } |
| 277 |
| 278 ViewMsg_ExtensionLoaded_Params::~ViewMsg_ExtensionLoaded_Params() { |
| 279 } |
| 280 |
| 281 ViewMsg_ExtensionLoaded_Params::ViewMsg_ExtensionLoaded_Params( |
| 282 const ViewMsg_ExtensionLoaded_Params& other) |
| 283 : manifest(other.manifest->DeepCopy()), |
| 284 location(other.location), |
| 285 path(other.path), |
| 286 id(other.id) { |
| 287 } |
| 288 |
| 289 ViewMsg_ExtensionLoaded_Params::ViewMsg_ExtensionLoaded_Params( |
| 290 const Extension* extension) |
| 291 : manifest(new DictionaryValue()), |
| 292 location(extension->location()), |
| 293 path(extension->path()), |
| 294 id(extension->id()) { |
| 295 // As we need more bits of extension data in the renderer, add more keys to |
| 296 // this list. |
| 297 const char* kRendererExtensionKeys[] = { |
| 298 extension_manifest_keys::kPublicKey, |
| 299 extension_manifest_keys::kName, |
| 300 extension_manifest_keys::kVersion, |
| 301 extension_manifest_keys::kIcons, |
| 302 extension_manifest_keys::kPermissions, |
| 303 extension_manifest_keys::kApp |
| 304 }; |
| 305 |
| 306 // Copy only the data we need. |
| 307 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRendererExtensionKeys); ++i) { |
| 308 Value* temp = NULL; |
| 309 if (extension->manifest_value()->Get(kRendererExtensionKeys[i], &temp)) |
| 310 manifest->Set(kRendererExtensionKeys[i], temp->DeepCopy()); |
| 311 } |
| 312 } |
| 313 |
| 314 scoped_refptr<Extension> |
| 315 ViewMsg_ExtensionLoaded_Params::ConvertToExtension() const { |
| 316 // Extensions that are loaded unpacked won't have a key. |
| 317 const bool kRequireKey = false; |
| 318 std::string error; |
| 319 |
| 320 scoped_refptr<Extension> extension( |
| 321 Extension::Create(path, location, *manifest, kRequireKey, &error)); |
| 322 if (!extension.get()) |
| 323 LOG(ERROR) << "Error deserializing extension: " << error; |
| 324 |
| 325 return extension; |
| 326 } |
| 327 |
288 namespace IPC { | 328 namespace IPC { |
289 | 329 |
290 // Self contained templates which are only used inside serializing Params | 330 // Self contained templates which are only used inside serializing Params |
291 // structs. | 331 // structs. |
292 template<> | 332 template<> |
293 struct ParamTraits<ViewMsg_Navigate_Params::NavigationType> { | 333 struct ParamTraits<ViewMsg_Navigate_Params::NavigationType> { |
294 typedef ViewMsg_Navigate_Params::NavigationType param_type; | 334 typedef ViewMsg_Navigate_Params::NavigationType param_type; |
295 static void Write(Message* m, const param_type& p) { | 335 static void Write(Message* m, const param_type& p) { |
296 m->WriteInt(p); | 336 m->WriteInt(p); |
297 } | 337 } |
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1448 default: | 1488 default: |
1449 l->append("(UNKNOWN, "); | 1489 l->append("(UNKNOWN, "); |
1450 } | 1490 } |
1451 LogParam(p.title, l); | 1491 LogParam(p.title, l); |
1452 l->append(", "); | 1492 l->append(", "); |
1453 LogParam(p.default_file_name, l); | 1493 LogParam(p.default_file_name, l); |
1454 l->append(", "); | 1494 l->append(", "); |
1455 LogParam(p.accept_types, l); | 1495 LogParam(p.accept_types, l); |
1456 } | 1496 } |
1457 | 1497 |
1458 void ParamTraits<ViewMsg_ExtensionRendererInfo>::Write(Message* m, | 1498 void ParamTraits<ViewMsg_ExtensionLoaded_Params>::Write(Message* m, |
1459 const param_type& p) { | 1499 const param_type& p) { |
1460 WriteParam(m, p.id); | |
1461 WriteParam(m, p.web_extent); | |
1462 WriteParam(m, p.name); | |
1463 WriteParam(m, p.icon_url); | |
1464 WriteParam(m, p.location); | 1500 WriteParam(m, p.location); |
1465 WriteParam(m, p.allowed_to_execute_script_everywhere); | 1501 WriteParam(m, p.path); |
1466 WriteParam(m, p.host_permissions); | 1502 WriteParam(m, *(p.manifest)); |
1467 } | 1503 } |
1468 | 1504 |
1469 bool ParamTraits<ViewMsg_ExtensionRendererInfo>::Read(const Message* m, | 1505 bool ParamTraits<ViewMsg_ExtensionLoaded_Params>::Read(const Message* m, |
1470 void** iter, | 1506 void** iter, |
1471 param_type* p) { | 1507 param_type* p) { |
1472 return ReadParam(m, iter, &p->id) && | 1508 p->manifest.reset(new DictionaryValue()); |
1473 ReadParam(m, iter, &p->web_extent) && | 1509 return ReadParam(m, iter, &p->location) && |
1474 ReadParam(m, iter, &p->name) && | 1510 ReadParam(m, iter, &p->path) && |
1475 ReadParam(m, iter, &p->icon_url) && | 1511 ReadParam(m, iter, p->manifest.get()); |
1476 ReadParam(m, iter, &p->location) && | |
1477 ReadParam(m, iter, &p->allowed_to_execute_script_everywhere) && | |
1478 ReadParam(m, iter, &p->host_permissions); | |
1479 } | 1512 } |
1480 | 1513 |
1481 void ParamTraits<ViewMsg_ExtensionRendererInfo>::Log(const param_type& p, | 1514 void ParamTraits<ViewMsg_ExtensionLoaded_Params>::Log(const param_type& p, |
1482 std::string* l) { | 1515 std::string* l) { |
1483 LogParam(p.id, l); | 1516 l->append(p.id); |
1484 } | |
1485 | |
1486 void ParamTraits<ViewMsg_ExtensionsUpdated_Params>::Write( | |
1487 Message* m, | |
1488 const param_type& p) { | |
1489 WriteParam(m, p.extensions); | |
1490 } | |
1491 | |
1492 bool ParamTraits<ViewMsg_ExtensionsUpdated_Params>::Read( | |
1493 const Message* m, | |
1494 void** iter, | |
1495 param_type* p) { | |
1496 return ReadParam(m, iter, &p->extensions); | |
1497 } | |
1498 | |
1499 void ParamTraits<ViewMsg_ExtensionsUpdated_Params>::Log( | |
1500 const param_type& p, | |
1501 std::string* l) { | |
1502 LogParam(p.extensions, l); | |
1503 } | 1517 } |
1504 | 1518 |
1505 void ParamTraits<ViewMsg_DeviceOrientationUpdated_Params>::Write( | 1519 void ParamTraits<ViewMsg_DeviceOrientationUpdated_Params>::Write( |
1506 Message* m, | 1520 Message* m, |
1507 const param_type& p) { | 1521 const param_type& p) { |
1508 WriteParam(m, p.can_provide_alpha); | 1522 WriteParam(m, p.can_provide_alpha); |
1509 WriteParam(m, p.alpha); | 1523 WriteParam(m, p.alpha); |
1510 WriteParam(m, p.can_provide_beta); | 1524 WriteParam(m, p.can_provide_beta); |
1511 WriteParam(m, p.beta); | 1525 WriteParam(m, p.beta); |
1512 WriteParam(m, p.can_provide_gamma); | 1526 WriteParam(m, p.can_provide_gamma); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1629 const param_type& p, | 1643 const param_type& p, |
1630 std::string* l) { | 1644 std::string* l) { |
1631 l->append("("); | 1645 l->append("("); |
1632 LogParam(p.notification_type, l); | 1646 LogParam(p.notification_type, l); |
1633 l->append(", "); | 1647 l->append(", "); |
1634 LogParam(p.acc_obj, l); | 1648 LogParam(p.acc_obj, l); |
1635 l->append(")"); | 1649 l->append(")"); |
1636 } | 1650 } |
1637 | 1651 |
1638 } // namespace IPC | 1652 } // namespace IPC |
OLD | NEW |