OLD | NEW |
1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_IMPORTER_IMPORTER_MESSAGES_H_ | 5 #ifndef CHROME_BROWSER_IMPORTER_IMPORTER_MESSAGES_H_ |
6 #define CHROME_BROWSER_IMPORTER_IMPORTER_MESSAGES_H_ | 6 #define CHROME_BROWSER_IMPORTER_IMPORTER_MESSAGES_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 template <> | 215 template <> |
216 struct ParamTraits<TemplateURL::ImageRef> { | 216 struct ParamTraits<TemplateURL::ImageRef> { |
217 typedef TemplateURL::ImageRef param_type; | 217 typedef TemplateURL::ImageRef param_type; |
218 static void Write(Message* m, const param_type& p) { | 218 static void Write(Message* m, const param_type& p) { |
219 WriteParam(m, p.type); | 219 WriteParam(m, p.type); |
220 WriteParam(m, p.width); | 220 WriteParam(m, p.width); |
221 WriteParam(m, p.height); | 221 WriteParam(m, p.height); |
222 WriteParam(m, p.url); | 222 WriteParam(m, p.url); |
223 } | 223 } |
224 static bool Read(const Message* m, void** iter, param_type* p) { | 224 static bool Read(const Message* m, void** iter, param_type* p) { |
225 std::string type; | 225 std::wstring type; |
226 int width; | 226 int width; |
227 int height; | 227 int height; |
228 GURL url; | 228 GURL url; |
229 if (!ReadParam(m, iter, &type) || | 229 if (!ReadParam(m, iter, &type) || |
230 !ReadParam(m, iter, &width) || | 230 !ReadParam(m, iter, &width) || |
231 !ReadParam(m, iter, &height) || | 231 !ReadParam(m, iter, &height) || |
232 !ReadParam(m, iter, &url)) | 232 !ReadParam(m, iter, &url)) |
233 return false; | 233 return false; |
234 *p = TemplateURL::ImageRef(type, width, height, url); // here in | 234 *p = TemplateURL::ImageRef(type, width, height, url); // here in |
235 return true; | 235 return true; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 WriteParam(m, iter->url); | 268 WriteParam(m, iter->url); |
269 } | 269 } |
270 | 270 |
271 WriteParam(m, p.languages()); | 271 WriteParam(m, p.languages()); |
272 WriteParam(m, p.input_encodings()); | 272 WriteParam(m, p.input_encodings()); |
273 WriteParam(m, p.date_created()); | 273 WriteParam(m, p.date_created()); |
274 WriteParam(m, p.usage_count()); | 274 WriteParam(m, p.usage_count()); |
275 WriteParam(m, p.prepopulate_id()); | 275 WriteParam(m, p.prepopulate_id()); |
276 } | 276 } |
277 static bool Read(const Message* m, void** iter, param_type* p) { | 277 static bool Read(const Message* m, void** iter, param_type* p) { |
278 string16 short_name; | 278 std::wstring short_name; |
279 string16 description; | 279 std::wstring description; |
280 bool includes_suggestions_url; | 280 bool includes_suggestions_url; |
281 TemplateURLRef suggestions_url; | 281 TemplateURLRef suggestions_url; |
282 TemplateURLRef url; | 282 TemplateURLRef url; |
283 GURL originating_url; | 283 GURL originating_url; |
284 string16 keyword; | 284 std::wstring keyword; |
285 bool autogenerate_keyword; | 285 bool autogenerate_keyword; |
286 bool show_in_default_list; | 286 bool show_in_default_list; |
287 bool safe_for_autoreplace; | 287 bool safe_for_autoreplace; |
288 std::vector<string16> languages; | 288 std::vector<std::wstring> languages; |
289 std::vector<std::string> input_encodings; | 289 std::vector<std::string> input_encodings; |
290 base::Time date_created; | 290 base::Time date_created; |
291 int usage_count; | 291 int usage_count; |
292 int prepopulate_id; | 292 int prepopulate_id; |
293 | 293 |
294 if (!ReadParam(m, iter, &short_name) || | 294 if (!ReadParam(m, iter, &short_name) || |
295 !ReadParam(m, iter, &description)) | 295 !ReadParam(m, iter, &description)) |
296 return false; | 296 return false; |
297 | 297 |
298 if (!ReadParam(m, iter, &includes_suggestions_url)) | 298 if (!ReadParam(m, iter, &includes_suggestions_url)) |
299 return false; | 299 return false; |
300 if (includes_suggestions_url) { | 300 if (includes_suggestions_url) { |
301 if (!ReadParam(m, iter, &suggestions_url)) | 301 if (!ReadParam(m, iter, &suggestions_url)) |
302 return false; | 302 return false; |
303 } | 303 } |
304 | 304 |
305 size_t image_refs_size = 0; | 305 size_t image_refs_size = 0; |
306 if (!ReadParam(m, iter, &url) || | 306 if (!ReadParam(m, iter, &url) || |
307 !ReadParam(m, iter, &originating_url) || | 307 !ReadParam(m, iter, &originating_url) || |
308 !ReadParam(m, iter, &keyword) || | 308 !ReadParam(m, iter, &keyword) || |
309 !ReadParam(m, iter, &autogenerate_keyword) || | 309 !ReadParam(m, iter, &autogenerate_keyword) || |
310 !ReadParam(m, iter, &show_in_default_list) || | 310 !ReadParam(m, iter, &show_in_default_list) || |
311 !ReadParam(m, iter, &safe_for_autoreplace) || | 311 !ReadParam(m, iter, &safe_for_autoreplace) || |
312 !ReadParam(m, iter, &image_refs_size)) | 312 !ReadParam(m, iter, &image_refs_size)) |
313 return false; | 313 return false; |
314 | 314 |
315 *p = TemplateURL(); | 315 *p = TemplateURL(); |
316 for (size_t i = 0; i < image_refs_size; ++i) { | 316 for (size_t i = 0; i < image_refs_size; ++i) { |
317 std::string type; | 317 std::wstring type; |
318 int width; | 318 int width; |
319 int height; | 319 int height; |
320 GURL url; | 320 GURL url; |
321 if (!ReadParam(m, iter, &type) || | 321 if (!ReadParam(m, iter, &type) || |
322 !ReadParam(m, iter, &width) || | 322 !ReadParam(m, iter, &width) || |
323 !ReadParam(m, iter, &height) || | 323 !ReadParam(m, iter, &height) || |
324 !ReadParam(m, iter, &url)) | 324 !ReadParam(m, iter, &url)) |
325 return false; | 325 return false; |
326 p->add_image_ref(TemplateURL::ImageRef(type, width, height, url)); | 326 p->add_image_ref(TemplateURL::ImageRef(type, width, height, url)); |
327 } | 327 } |
328 | 328 |
329 if (!ReadParam(m, iter, &languages) || | 329 if (!ReadParam(m, iter, &languages) || |
330 !ReadParam(m, iter, &input_encodings) || | 330 !ReadParam(m, iter, &input_encodings) || |
331 !ReadParam(m, iter, &date_created) || | 331 !ReadParam(m, iter, &date_created) || |
332 !ReadParam(m, iter, &usage_count) || | 332 !ReadParam(m, iter, &usage_count) || |
333 !ReadParam(m, iter, &prepopulate_id)) | 333 !ReadParam(m, iter, &prepopulate_id)) |
334 return false; | 334 return false; |
335 | 335 |
336 p->set_short_name(short_name); | 336 p->set_short_name(short_name); |
337 p->set_description(description); | 337 p->set_description(description); |
338 p->SetSuggestionsURL(suggestions_url.url(), suggestions_url.index_offset(), | 338 p->SetSuggestionsURL(suggestions_url.url(), suggestions_url.index_offset(), |
339 suggestions_url.page_offset()); | 339 suggestions_url.page_offset()); |
340 p->SetURL(url.url(), url.index_offset(), url.page_offset()); | 340 p->SetURL(url.url(), url.index_offset(), url.page_offset()); |
341 p->set_originating_url(originating_url); | 341 p->set_originating_url(originating_url); |
342 p->set_keyword(keyword); | 342 p->set_keyword(keyword); |
343 p->set_autogenerate_keyword(autogenerate_keyword); | 343 p->set_autogenerate_keyword(autogenerate_keyword); |
344 p->set_show_in_default_list(show_in_default_list); | 344 p->set_show_in_default_list(show_in_default_list); |
345 p->set_safe_for_autoreplace(safe_for_autoreplace); | 345 p->set_safe_for_autoreplace(safe_for_autoreplace); |
346 | 346 |
347 std::vector<string16>::const_iterator lang_iter; | 347 std::vector<std::wstring>::const_iterator lang_iter; |
348 for (lang_iter = languages.begin(); | 348 for (lang_iter = languages.begin(); |
349 lang_iter != languages.end(); | 349 lang_iter != languages.end(); |
350 ++lang_iter) { | 350 ++lang_iter) { |
351 p->add_language(*lang_iter); | 351 p->add_language(*lang_iter); |
352 } | 352 } |
353 p->set_input_encodings(input_encodings); | 353 p->set_input_encodings(input_encodings); |
354 p->set_date_created(date_created); | 354 p->set_date_created(date_created); |
355 p->set_usage_count(usage_count); | 355 p->set_usage_count(usage_count); |
356 p->set_prepopulate_id(prepopulate_id); | 356 p->set_prepopulate_id(prepopulate_id); |
357 return true; | 357 return true; |
358 } | 358 } |
359 static void Log(const param_type& p, std::string* l) { | 359 static void Log(const param_type& p, std::string* l) { |
360 l->append("<TemplateURL>"); | 360 l->append("<TemplateURL>"); |
361 } | 361 } |
362 }; | 362 }; |
363 | 363 |
364 } // namespace IPC | 364 } // namespace IPC |
365 | 365 |
366 #include "chrome/browser/importer/importer_messages_internal.h" | 366 #include "chrome/browser/importer/importer_messages_internal.h" |
367 | 367 |
368 #endif // CHROME_BROWSER_IMPORTER_IMPORTER_MESSAGES_H_ | 368 #endif // CHROME_BROWSER_IMPORTER_IMPORTER_MESSAGES_H_ |
OLD | NEW |