| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Multiply-included message file, no traditonal include guard. | 5 // Multiply-included message file, no traditonal include guard. |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 // Traits for TemplateURL*. | 192 // Traits for TemplateURL*. |
| 193 // WARNING: These will cause us to allocate a new TemplateURL on the heap on the | 193 // WARNING: These will cause us to allocate a new TemplateURL on the heap on the |
| 194 // receiver side. Any messages using this type must have handlers that are | 194 // receiver side. Any messages using this type must have handlers that are |
| 195 // careful to properly take ownership and avoid leaks! See warning below on | 195 // careful to properly take ownership and avoid leaks! See warning below on |
| 196 // ProfileImportProcessHostMsg_NotifyKeywordsReady. | 196 // ProfileImportProcessHostMsg_NotifyKeywordsReady. |
| 197 template <> | 197 template <> |
| 198 struct ParamTraits<TemplateURL*> { | 198 struct ParamTraits<TemplateURL*> { |
| 199 typedef TemplateURL* param_type; | 199 typedef TemplateURL* param_type; |
| 200 static void Write(Message* m, const param_type& p) { | 200 static void Write(Message* m, const param_type& p) { |
| 201 WriteParam(m, p->short_name()); | 201 WriteParam(m, p->short_name()); |
| 202 if (p->suggestions_url()) { | 202 WriteParam(m, p->url()); |
| 203 WriteParam(m, true); | 203 WriteParam(m, p->suggestions_url()); |
| 204 WriteParam(m, p->suggestions_url()->url()); | 204 WriteParam(m, p->instant_url()); |
| 205 } else { | |
| 206 WriteParam(m, false); | |
| 207 } | |
| 208 WriteParam(m, p->url()->url()); | |
| 209 WriteParam(m, p->originating_url()); | 205 WriteParam(m, p->originating_url()); |
| 210 WriteParam(m, p->keyword()); | 206 WriteParam(m, p->keyword()); |
| 211 WriteParam(m, p->autogenerate_keyword()); | 207 WriteParam(m, p->autogenerate_keyword()); |
| 212 WriteParam(m, p->show_in_default_list()); | 208 WriteParam(m, p->show_in_default_list()); |
| 213 WriteParam(m, p->safe_for_autoreplace()); | 209 WriteParam(m, p->safe_for_autoreplace()); |
| 214 WriteParam(m, p->favicon_url()); | 210 WriteParam(m, p->favicon_url()); |
| 215 WriteParam(m, p->input_encodings()); | 211 WriteParam(m, p->input_encodings()); |
| 216 WriteParam(m, p->date_created()); | 212 WriteParam(m, p->date_created()); |
| 217 WriteParam(m, p->last_modified()); | 213 WriteParam(m, p->last_modified()); |
| 218 WriteParam(m, p->usage_count()); | 214 WriteParam(m, p->usage_count()); |
| 219 WriteParam(m, p->prepopulate_id()); | 215 WriteParam(m, p->prepopulate_id()); |
| 220 } | 216 } |
| 221 static bool Read(const Message* m, PickleIterator* iter, param_type* p) { | 217 static bool Read(const Message* m, PickleIterator* iter, param_type* p) { |
| 222 *p = NULL; | |
| 223 | |
| 224 string16 short_name; | 218 string16 short_name; |
| 225 bool includes_suggestions_url; | 219 std::string url; |
| 226 std::string suggestions_url; | 220 std::string suggestions_url; |
| 227 std::string url; | 221 std::string instant_url; |
| 228 GURL originating_url; | 222 GURL originating_url; |
| 229 string16 keyword; | 223 string16 keyword; |
| 230 bool autogenerate_keyword; | 224 bool autogenerate_keyword; |
| 231 bool show_in_default_list; | 225 bool show_in_default_list; |
| 232 bool safe_for_autoreplace; | 226 bool safe_for_autoreplace; |
| 233 GURL favicon_url; | 227 GURL favicon_url; |
| 234 base::Time date_created; | 228 base::Time date_created; |
| 235 base::Time last_modified; | 229 base::Time last_modified; |
| 236 int usage_count; | 230 int usage_count; |
| 237 int prepopulate_id; | 231 int prepopulate_id; |
| 238 | 232 if (!ReadParam(m, iter, &short_name) || |
| 239 if (!ReadParam(m, iter, &short_name)) | 233 !ReadParam(m, iter, &url) || |
| 240 return false; | 234 !ReadParam(m, iter, &suggestions_url) || |
| 241 | 235 !ReadParam(m, iter, &instant_url) || |
| 242 if (!ReadParam(m, iter, &includes_suggestions_url)) | |
| 243 return false; | |
| 244 if (includes_suggestions_url) { | |
| 245 if (!ReadParam(m, iter, &suggestions_url)) | |
| 246 return false; | |
| 247 } | |
| 248 | |
| 249 if (!ReadParam(m, iter, &url) || | |
| 250 !ReadParam(m, iter, &originating_url) || | 236 !ReadParam(m, iter, &originating_url) || |
| 251 !ReadParam(m, iter, &keyword) || | 237 !ReadParam(m, iter, &keyword) || |
| 252 !ReadParam(m, iter, &autogenerate_keyword) || | 238 !ReadParam(m, iter, &autogenerate_keyword) || |
| 253 !ReadParam(m, iter, &show_in_default_list) || | 239 !ReadParam(m, iter, &show_in_default_list) || |
| 254 !ReadParam(m, iter, &safe_for_autoreplace)) | 240 !ReadParam(m, iter, &safe_for_autoreplace) || |
| 255 return false; | 241 !ReadParam(m, iter, &favicon_url) || |
| 256 | |
| 257 scoped_ptr<TemplateURL> turl(new TemplateURL()); | |
| 258 if (!ReadParam(m, iter, &favicon_url) || | |
| 259 !ReadParam(m, iter, &date_created) || | 242 !ReadParam(m, iter, &date_created) || |
| 260 !ReadParam(m, iter, &last_modified) || | 243 !ReadParam(m, iter, &last_modified) || |
| 261 !ReadParam(m, iter, &usage_count) || | 244 !ReadParam(m, iter, &usage_count) || |
| 262 !ReadParam(m, iter, &prepopulate_id)) | 245 !ReadParam(m, iter, &prepopulate_id)) |
| 263 return false; | 246 return false; |
| 264 | 247 *p = new TemplateURL(); |
| 265 turl->set_short_name(short_name); | 248 (*p)->set_short_name(short_name); |
| 266 turl->SetSuggestionsURL(suggestions_url); | 249 (*p)->SetURL(url); |
| 267 turl->SetURL(url); | 250 (*p)->SetSuggestionsURL(suggestions_url); |
| 268 turl->set_originating_url(originating_url); | 251 (*p)->SetInstantURL(suggestions_url); |
| 269 turl->set_keyword(keyword); | 252 (*p)->set_originating_url(originating_url); |
| 270 turl->set_autogenerate_keyword(autogenerate_keyword); | 253 (*p)->set_keyword(keyword); |
| 271 turl->set_show_in_default_list(show_in_default_list); | 254 (*p)->set_autogenerate_keyword(autogenerate_keyword); |
| 272 turl->set_safe_for_autoreplace(safe_for_autoreplace); | 255 (*p)->set_show_in_default_list(show_in_default_list); |
| 273 turl->set_favicon_url(favicon_url); | 256 (*p)->set_safe_for_autoreplace(safe_for_autoreplace); |
| 274 turl->set_date_created(date_created); | 257 (*p)->set_favicon_url(favicon_url); |
| 275 turl->set_last_modified(last_modified); | 258 (*p)->set_date_created(date_created); |
| 276 turl->set_usage_count(usage_count); | 259 (*p)->set_last_modified(last_modified); |
| 277 turl->SetPrepopulateId(prepopulate_id); | 260 (*p)->set_usage_count(usage_count); |
| 278 *p = turl.release(); | 261 (*p)->SetPrepopulateId(prepopulate_id); |
| 279 return true; | 262 return true; |
| 280 } | 263 } |
| 281 static void Log(const param_type& p, std::string* l) { | 264 static void Log(const param_type& p, std::string* l) { |
| 282 l->append("<TemplateURL>"); | 265 l->append("<TemplateURL>"); |
| 283 } | 266 } |
| 284 }; | 267 }; |
| 285 | 268 |
| 286 } // namespace IPC | 269 } // namespace IPC |
| 287 | 270 |
| 288 #endif // CHROME_BROWSER_IMPORTER_PROFILE_IMPORT_PROCESS_MESSAGES_H_ | 271 #endif // CHROME_BROWSER_IMPORTER_PROFILE_IMPORT_PROCESS_MESSAGES_H_ |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 | 330 |
| 348 IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyPasswordFormReady, | 331 IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyPasswordFormReady, |
| 349 webkit::forms::PasswordForm) | 332 webkit::forms::PasswordForm) |
| 350 | 333 |
| 351 // WARNING: The TemplateURL*s in the following message get heap-allocated on the | 334 // WARNING: The TemplateURL*s in the following message get heap-allocated on the |
| 352 // receiving end. The message handler for this message MUST take ownership of | 335 // receiving end. The message handler for this message MUST take ownership of |
| 353 // these pointers and ensure they're properly freed! | 336 // these pointers and ensure they're properly freed! |
| 354 IPC_MESSAGE_CONTROL2(ProfileImportProcessHostMsg_NotifyKeywordsReady, | 337 IPC_MESSAGE_CONTROL2(ProfileImportProcessHostMsg_NotifyKeywordsReady, |
| 355 std::vector<TemplateURL*>, | 338 std::vector<TemplateURL*>, |
| 356 bool /* unique on host and path */) | 339 bool /* unique on host and path */) |
| OLD | NEW |