| 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 #include "chrome/common/common_param_traits.h" | 5 #include "chrome/common/common_param_traits.h" |
| 6 | 6 |
| 7 #include "base/time.h" | 7 #include "base/time.h" |
| 8 #include "chrome/common/chrome_constants.h" | 8 #include "chrome/common/chrome_constants.h" |
| 9 #include "chrome/common/content_settings.h" | 9 #include "chrome/common/content_settings.h" |
| 10 #include "chrome/common/geoposition.h" | 10 #include "chrome/common/geoposition.h" |
| 11 #include "chrome/common/thumbnail_score.h" | 11 #include "chrome/common/thumbnail_score.h" |
| 12 #include "chrome/common/web_apps.h" | 12 #include "chrome/common/web_apps.h" |
| 13 #include "content/common/common_param_traits.h" | 13 #include "content/common/common_param_traits.h" |
| 14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 15 #include "printing/backend/print_backend.h" | 15 #include "printing/backend/print_backend.h" |
| 16 #include "printing/native_metafile.h" | 16 #include "printing/native_metafile.h" |
| 17 #include "printing/page_range.h" | 17 #include "printing/page_range.h" |
| 18 #include "ui/gfx/rect.h" | |
| 19 | 18 |
| 20 #ifndef EXCLUDE_SKIA_DEPENDENCIES | 19 #ifndef EXCLUDE_SKIA_DEPENDENCIES |
| 21 #include "third_party/skia/include/core/SkBitmap.h" | 20 #include "third_party/skia/include/core/SkBitmap.h" |
| 22 #endif | 21 #endif |
| 23 #include "webkit/glue/password_form.h" | 22 #include "webkit/glue/password_form.h" |
| 24 | 23 |
| 25 namespace IPC { | 24 namespace IPC { |
| 26 | 25 |
| 27 #ifndef EXCLUDE_SKIA_DEPENDENCIES | 26 #ifndef EXCLUDE_SKIA_DEPENDENCIES |
| 28 | 27 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 reinterpret_cast<const SkBitmap_Data*>(fixed_data); | 95 reinterpret_cast<const SkBitmap_Data*>(fixed_data); |
| 97 return bmp_data->InitSkBitmapFromData(r, variable_data, variable_data_size); | 96 return bmp_data->InitSkBitmapFromData(r, variable_data, variable_data_size); |
| 98 } | 97 } |
| 99 | 98 |
| 100 void ParamTraits<SkBitmap>::Log(const SkBitmap& p, std::string* l) { | 99 void ParamTraits<SkBitmap>::Log(const SkBitmap& p, std::string* l) { |
| 101 l->append("<SkBitmap>"); | 100 l->append("<SkBitmap>"); |
| 102 } | 101 } |
| 103 | 102 |
| 104 #endif // EXCLUDE_SKIA_DEPENDENCIES | 103 #endif // EXCLUDE_SKIA_DEPENDENCIES |
| 105 | 104 |
| 106 void ParamTraits<gfx::Point>::Write(Message* m, const gfx::Point& p) { | |
| 107 m->WriteInt(p.x()); | |
| 108 m->WriteInt(p.y()); | |
| 109 } | |
| 110 | |
| 111 bool ParamTraits<gfx::Point>::Read(const Message* m, void** iter, | |
| 112 gfx::Point* r) { | |
| 113 int x, y; | |
| 114 if (!m->ReadInt(iter, &x) || | |
| 115 !m->ReadInt(iter, &y)) | |
| 116 return false; | |
| 117 r->set_x(x); | |
| 118 r->set_y(y); | |
| 119 return true; | |
| 120 } | |
| 121 | |
| 122 void ParamTraits<gfx::Point>::Log(const gfx::Point& p, std::string* l) { | |
| 123 l->append(base::StringPrintf("(%d, %d)", p.x(), p.y())); | |
| 124 } | |
| 125 | |
| 126 | |
| 127 void ParamTraits<gfx::Rect>::Write(Message* m, const gfx::Rect& p) { | |
| 128 m->WriteInt(p.x()); | |
| 129 m->WriteInt(p.y()); | |
| 130 m->WriteInt(p.width()); | |
| 131 m->WriteInt(p.height()); | |
| 132 } | |
| 133 | |
| 134 bool ParamTraits<gfx::Rect>::Read(const Message* m, void** iter, gfx::Rect* r) { | |
| 135 int x, y, w, h; | |
| 136 if (!m->ReadInt(iter, &x) || | |
| 137 !m->ReadInt(iter, &y) || | |
| 138 !m->ReadInt(iter, &w) || | |
| 139 !m->ReadInt(iter, &h)) | |
| 140 return false; | |
| 141 r->set_x(x); | |
| 142 r->set_y(y); | |
| 143 r->set_width(w); | |
| 144 r->set_height(h); | |
| 145 return true; | |
| 146 } | |
| 147 | |
| 148 void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::string* l) { | |
| 149 l->append(base::StringPrintf("(%d, %d, %d, %d)", p.x(), p.y(), | |
| 150 p.width(), p.height())); | |
| 151 } | |
| 152 | |
| 153 | |
| 154 void ParamTraits<gfx::Size>::Write(Message* m, const gfx::Size& p) { | |
| 155 m->WriteInt(p.width()); | |
| 156 m->WriteInt(p.height()); | |
| 157 } | |
| 158 | |
| 159 bool ParamTraits<gfx::Size>::Read(const Message* m, void** iter, gfx::Size* r) { | |
| 160 int w, h; | |
| 161 if (!m->ReadInt(iter, &w) || | |
| 162 !m->ReadInt(iter, &h)) | |
| 163 return false; | |
| 164 r->set_width(w); | |
| 165 r->set_height(h); | |
| 166 return true; | |
| 167 } | |
| 168 | |
| 169 void ParamTraits<gfx::Size>::Log(const gfx::Size& p, std::string* l) { | |
| 170 l->append(base::StringPrintf("(%d, %d)", p.width(), p.height())); | |
| 171 } | |
| 172 | |
| 173 void ParamTraits<ContentSetting>::Write(Message* m, const param_type& p) { | 105 void ParamTraits<ContentSetting>::Write(Message* m, const param_type& p) { |
| 174 WriteParam(m, static_cast<int>(p)); | 106 WriteParam(m, static_cast<int>(p)); |
| 175 } | 107 } |
| 176 | 108 |
| 177 bool ParamTraits<ContentSetting>::Read(const Message* m, void** iter, | 109 bool ParamTraits<ContentSetting>::Read(const Message* m, void** iter, |
| 178 param_type* r) { | 110 param_type* r) { |
| 179 int value; | 111 int value; |
| 180 if (!ReadParam(m, iter, &value)) | 112 if (!ReadParam(m, iter, &value)) |
| 181 return false; | 113 return false; |
| 182 if (value < 0 || value >= static_cast<int>(CONTENT_SETTING_NUM_SETTINGS)) | 114 if (value < 0 || value >= static_cast<int>(CONTENT_SETTING_NUM_SETTINGS)) |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 l->append(","); | 400 l->append(","); |
| 469 LogParam(p.caps_mime_type, l); | 401 LogParam(p.caps_mime_type, l); |
| 470 l->append(","); | 402 l->append(","); |
| 471 LogParam(p.printer_defaults, l); | 403 LogParam(p.printer_defaults, l); |
| 472 l->append(","); | 404 l->append(","); |
| 473 LogParam(p.defaults_mime_type, l); | 405 LogParam(p.defaults_mime_type, l); |
| 474 l->append(")"); | 406 l->append(")"); |
| 475 } | 407 } |
| 476 | 408 |
| 477 } // namespace IPC | 409 } // namespace IPC |
| OLD | NEW |