Chromium Code Reviews| 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 const ViewMsg_ExtensionLoaded_Params& other) | |
| 280 : manifest(other.manifest->DeepCopy()), | |
| 281 location(other.location), | |
| 282 path(other.path) { | |
| 283 } | |
| 284 | |
| 285 ViewMsg_ExtensionLoaded_Params::ViewMsg_ExtensionLoaded_Params( | |
| 286 const Extension* extension) { | |
| 287 location = extension->location(); | |
| 288 path = extension->path(); | |
| 289 manifest.reset(new DictionaryValue()); | |
| 290 | |
| 291 // As we need more bits of extension data in the renderer, add more keys to | |
| 292 // this list. | |
| 293 const char* kRendererExtensionKeys[] = { | |
| 294 extension_manifest_keys::kPublicKey, | |
| 295 extension_manifest_keys::kName, | |
| 296 extension_manifest_keys::kVersion, | |
| 297 extension_manifest_keys::kIcons, | |
| 298 extension_manifest_keys::kPermissions, | |
| 299 extension_manifest_keys::kApp | |
| 300 }; | |
| 301 | |
| 302 // Copy only the data we need. | |
| 303 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRendererExtensionKeys); ++i) { | |
| 304 Value* temp = NULL; | |
| 305 if (extension->manifest_value()->Get(kRendererExtensionKeys[i], &temp)) | |
| 306 manifest->Set(kRendererExtensionKeys[i], temp->DeepCopy()); | |
| 307 } | |
| 308 } | |
| 309 | |
| 310 scoped_refptr<Extension> | |
| 311 ViewMsg_ExtensionLoaded_Params::ConvertToExtension() const { | |
| 312 // Extensions that are loaded unpacked won't have a key. | |
| 313 const bool kRequireKey = false; | |
| 314 std::string error; | |
| 315 | |
| 316 scoped_refptr<Extension> extension( | |
| 317 Extension::Create(path, location, *manifest, kRequireKey, &error)); | |
| 318 if (!extension.get()) | |
| 319 LOG(ERROR) << "Error deserializing extension: " << error; | |
| 320 | |
| 321 return extension; | |
| 322 } | |
| 323 | |
| 288 namespace IPC { | 324 namespace IPC { |
| 289 | 325 |
| 290 // Self contained templates which are only used inside serializing Params | 326 // Self contained templates which are only used inside serializing Params |
| 291 // structs. | 327 // structs. |
| 292 template<> | 328 template<> |
| 293 struct ParamTraits<ViewMsg_Navigate_Params::NavigationType> { | 329 struct ParamTraits<ViewMsg_Navigate_Params::NavigationType> { |
| 294 typedef ViewMsg_Navigate_Params::NavigationType param_type; | 330 typedef ViewMsg_Navigate_Params::NavigationType param_type; |
| 295 static void Write(Message* m, const param_type& p) { | 331 static void Write(Message* m, const param_type& p) { |
| 296 m->WriteInt(p); | 332 m->WriteInt(p); |
| 297 } | 333 } |
| (...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1448 default: | 1484 default: |
| 1449 l->append("(UNKNOWN, "); | 1485 l->append("(UNKNOWN, "); |
| 1450 } | 1486 } |
| 1451 LogParam(p.title, l); | 1487 LogParam(p.title, l); |
| 1452 l->append(", "); | 1488 l->append(", "); |
| 1453 LogParam(p.default_file_name, l); | 1489 LogParam(p.default_file_name, l); |
| 1454 l->append(", "); | 1490 l->append(", "); |
| 1455 LogParam(p.accept_types, l); | 1491 LogParam(p.accept_types, l); |
| 1456 } | 1492 } |
| 1457 | 1493 |
| 1458 void ParamTraits<ViewMsg_ExtensionRendererInfo>::Write(Message* m, | 1494 void ParamTraits<ViewMsg_ExtensionLoaded_Params>::Write(Message* m, |
| 1459 const param_type& p) { | 1495 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); | 1496 WriteParam(m, p.location); |
| 1465 WriteParam(m, p.allowed_to_execute_script_everywhere); | 1497 WriteParam(m, p.path); |
| 1466 WriteParam(m, p.host_permissions); | 1498 WriteParam(m, *(p.manifest)); |
| 1467 } | 1499 } |
| 1468 | 1500 |
| 1469 bool ParamTraits<ViewMsg_ExtensionRendererInfo>::Read(const Message* m, | 1501 bool ParamTraits<ViewMsg_ExtensionLoaded_Params>::Read(const Message* m, |
| 1470 void** iter, | 1502 void** iter, |
| 1471 param_type* p) { | 1503 param_type* p) { |
| 1472 return ReadParam(m, iter, &p->id) && | 1504 p->manifest.reset(new DictionaryValue()); |
| 1473 ReadParam(m, iter, &p->web_extent) && | 1505 return ReadParam(m, iter, &p->location) && |
| 1474 ReadParam(m, iter, &p->name) && | 1506 ReadParam(m, iter, &p->path) && |
| 1475 ReadParam(m, iter, &p->icon_url) && | 1507 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 } | 1508 } |
| 1480 | 1509 |
| 1481 void ParamTraits<ViewMsg_ExtensionRendererInfo>::Log(const param_type& p, | 1510 void ParamTraits<ViewMsg_ExtensionLoaded_Params>::Log(const param_type& p, |
| 1482 std::string* l) { | 1511 std::string* l) { |
| 1483 LogParam(p.id, l); | 1512 l->append("<ViewMsg_ExtensionLoaded_Params>"); |
|
Matt Perry
2011/01/24 20:08:34
nit: might also put the extension ID here
Aaron Boodman
2011/01/25 00:27:33
We do not have the ID handy, all we have is the ke
Matt Perry
2011/01/25 00:45:54
In that case, I don't think it's really needed, ju
| |
| 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 } | 1513 } |
| 1504 | 1514 |
| 1505 void ParamTraits<ViewMsg_DeviceOrientationUpdated_Params>::Write( | 1515 void ParamTraits<ViewMsg_DeviceOrientationUpdated_Params>::Write( |
| 1506 Message* m, | 1516 Message* m, |
| 1507 const param_type& p) { | 1517 const param_type& p) { |
| 1508 WriteParam(m, p.can_provide_alpha); | 1518 WriteParam(m, p.can_provide_alpha); |
| 1509 WriteParam(m, p.alpha); | 1519 WriteParam(m, p.alpha); |
| 1510 WriteParam(m, p.can_provide_beta); | 1520 WriteParam(m, p.can_provide_beta); |
| 1511 WriteParam(m, p.beta); | 1521 WriteParam(m, p.beta); |
| 1512 WriteParam(m, p.can_provide_gamma); | 1522 WriteParam(m, p.can_provide_gamma); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1629 const param_type& p, | 1639 const param_type& p, |
| 1630 std::string* l) { | 1640 std::string* l) { |
| 1631 l->append("("); | 1641 l->append("("); |
| 1632 LogParam(p.notification_type, l); | 1642 LogParam(p.notification_type, l); |
| 1633 l->append(", "); | 1643 l->append(", "); |
| 1634 LogParam(p.acc_obj, l); | 1644 LogParam(p.acc_obj, l); |
| 1635 l->append(")"); | 1645 l->append(")"); |
| 1636 } | 1646 } |
| 1637 | 1647 |
| 1638 } // namespace IPC | 1648 } // namespace IPC |
| OLD | NEW |