OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 // Multiply-included message file, no traditonal include guard. | |
6 #include <string> | |
7 #include <vector> | |
8 | |
9 #include "base/basictypes.h" | |
10 #include "base/strings/string16.h" | |
11 #include "base/values.h" | |
12 #include "chrome/browser/importer/importer_data_types.h" | |
13 #include "chrome/browser/search_engines/template_url.h" | |
14 #include "chrome/common/common_param_traits_macros.h" | |
15 #include "chrome/common/importer/imported_bookmark_entry.h" | |
16 #include "chrome/common/importer/imported_favicon_usage.h" | |
17 #include "chrome/common/importer/importer_url_row.h" | |
18 #include "content/public/common/common_param_traits.h" | |
19 #include "content/public/common/password_form.h" | |
20 #include "ipc/ipc_message_macros.h" | |
21 #include "ipc/ipc_message_utils.h" | |
22 | |
23 #ifndef CHROME_BROWSER_IMPORTER_PROFILE_IMPORT_PROCESS_MESSAGES_H_ | |
24 #define CHROME_BROWSER_IMPORTER_PROFILE_IMPORT_PROCESS_MESSAGES_H_ | |
25 | |
26 namespace IPC { | |
27 | |
28 // Traits for importer::SourceProfile struct to pack/unpack. | |
29 template <> | |
30 struct ParamTraits<importer::SourceProfile> { | |
31 typedef importer::SourceProfile param_type; | |
32 static void Write(Message* m, const param_type& p) { | |
33 WriteParam(m, p.importer_name); | |
34 WriteParam(m, static_cast<int>(p.importer_type)); | |
35 WriteParam(m, p.source_path); | |
36 WriteParam(m, p.app_path); | |
37 WriteParam(m, static_cast<int>(p.services_supported)); | |
38 WriteParam(m, p.locale); | |
39 } | |
40 static bool Read(const Message* m, PickleIterator* iter, param_type* p) { | |
41 if (!ReadParam(m, iter, &p->importer_name)) | |
42 return false; | |
43 | |
44 int importer_type = 0; | |
45 if (!ReadParam(m, iter, &importer_type)) | |
46 return false; | |
47 p->importer_type = static_cast<importer::ImporterType>(importer_type); | |
48 | |
49 if (!ReadParam(m, iter, &p->source_path) || | |
50 !ReadParam(m, iter, &p->app_path)) { | |
51 return false; | |
52 } | |
53 | |
54 int services_supported = 0; | |
55 if (!ReadParam(m, iter, &services_supported)) | |
56 return false; | |
57 p->services_supported = static_cast<uint16>(services_supported); | |
58 | |
59 if (!ReadParam(m, iter, &p->locale)) | |
60 return false; | |
61 | |
62 return true; | |
63 } | |
64 static void Log(const param_type& p, std::string* l) { | |
65 l->append("("); | |
66 LogParam(p.importer_name, l); | |
67 l->append(", "); | |
68 LogParam(static_cast<int>(p.importer_type), l); | |
69 l->append(", "); | |
70 LogParam(p.source_path, l); | |
71 l->append(", "); | |
72 LogParam(p.app_path, l); | |
73 l->append(", "); | |
74 LogParam(static_cast<int>(p.services_supported), l); | |
75 l->append(", "); | |
76 LogParam(p.locale, l); | |
77 l->append(")"); | |
78 } | |
79 }; // ParamTraits<importer::SourceProfile> | |
80 | |
81 // Traits for ImporterURLRow to pack/unpack. | |
82 template <> | |
83 struct ParamTraits<ImporterURLRow> { | |
84 typedef ImporterURLRow param_type; | |
85 static void Write(Message* m, const param_type& p) { | |
86 WriteParam(m, p.url); | |
87 WriteParam(m, p.title); | |
88 WriteParam(m, p.visit_count); | |
89 WriteParam(m, p.typed_count); | |
90 WriteParam(m, p.last_visit); | |
91 WriteParam(m, p.hidden); | |
92 } | |
93 static bool Read(const Message* m, PickleIterator* iter, param_type* p) { | |
94 GURL url; | |
95 string16 title; | |
96 int visit_count, typed_count; | |
97 base::Time last_visit; | |
98 bool hidden; | |
99 if (!ReadParam(m, iter, &url) || | |
100 !ReadParam(m, iter, &title) || | |
101 !ReadParam(m, iter, &visit_count) || | |
102 !ReadParam(m, iter, &typed_count) || | |
103 !ReadParam(m, iter, &last_visit) || | |
104 !ReadParam(m, iter, &hidden)) | |
105 return false; | |
106 *p = ImporterURLRow(url); | |
107 p->title = title; | |
108 p->visit_count = visit_count; | |
109 p->typed_count = typed_count; | |
110 p->last_visit = last_visit; | |
111 p->hidden = hidden; | |
112 return true; | |
113 } | |
114 static void Log(const param_type& p, std::string* l) { | |
115 l->append("("); | |
116 LogParam(p.url, l); | |
117 l->append(", "); | |
118 LogParam(p.title, l); | |
119 l->append(", "); | |
120 LogParam(p.visit_count, l); | |
121 l->append(", "); | |
122 LogParam(p.typed_count, l); | |
123 l->append(", "); | |
124 LogParam(p.last_visit, l); | |
125 l->append(", "); | |
126 LogParam(p.hidden, l); | |
127 l->append(")"); | |
128 } | |
129 }; // ParamTraits<ImporterURLRow> | |
130 | |
131 // Traits for ImportedBookmarkEntry to pack/unpack. | |
132 template <> | |
133 struct ParamTraits<ImportedBookmarkEntry> { | |
134 typedef ImportedBookmarkEntry param_type; | |
135 static void Write(Message* m, const param_type& p) { | |
136 WriteParam(m, p.in_toolbar); | |
137 WriteParam(m, p.is_folder); | |
138 WriteParam(m, p.url); | |
139 WriteParam(m, p.path); | |
140 WriteParam(m, p.title); | |
141 WriteParam(m, p.creation_time); | |
142 } | |
143 static bool Read(const Message* m, PickleIterator* iter, param_type* p) { | |
144 return | |
145 (ReadParam(m, iter, &p->in_toolbar)) && | |
146 (ReadParam(m, iter, &p->is_folder)) && | |
147 (ReadParam(m, iter, &p->url)) && | |
148 (ReadParam(m, iter, &p->path)) && | |
149 (ReadParam(m, iter, &p->title)) && | |
150 (ReadParam(m, iter, &p->creation_time)); | |
151 } | |
152 static void Log(const param_type& p, std::string* l) { | |
153 l->append("("); | |
154 LogParam(p.in_toolbar, l); | |
155 l->append(", "); | |
156 LogParam(p.is_folder, l); | |
157 l->append(", "); | |
158 LogParam(p.url, l); | |
159 l->append(", "); | |
160 LogParam(p.path, l); | |
161 l->append(", "); | |
162 LogParam(p.title, l); | |
163 l->append(", "); | |
164 LogParam(p.creation_time, l); | |
165 l->append(")"); | |
166 } | |
167 }; // ParamTraits<ImportedBookmarkEntry> | |
168 | |
169 // Traits for ImportedFaviconUsage. | |
170 template <> | |
171 struct ParamTraits<ImportedFaviconUsage> { | |
172 typedef ImportedFaviconUsage param_type; | |
173 static void Write(Message* m, const param_type& p) { | |
174 WriteParam(m, p.favicon_url); | |
175 WriteParam(m, p.png_data); | |
176 WriteParam(m, p.urls); | |
177 } | |
178 static bool Read(const Message* m, PickleIterator* iter, param_type* p) { | |
179 return | |
180 ReadParam(m, iter, &p->favicon_url) && | |
181 ReadParam(m, iter, &p->png_data) && | |
182 ReadParam(m, iter, &p->urls); | |
183 } | |
184 static void Log(const param_type& p, std::string* l) { | |
185 l->append("("); | |
186 LogParam(p.favicon_url, l); | |
187 l->append(", "); | |
188 LogParam(p.png_data, l); | |
189 l->append(", "); | |
190 LogParam(p.urls, l); | |
191 l->append(")"); | |
192 } | |
193 }; // ParamTraits<ImportedFaviconUsage> | |
194 | |
195 // Traits for importer::URLKeywordInfo | |
196 template <> | |
197 struct ParamTraits<importer::URLKeywordInfo> { | |
198 typedef importer::URLKeywordInfo param_type; | |
199 static void Write(Message* m, const param_type& p) { | |
200 WriteParam(m, p.url); | |
201 WriteParam(m, p.keyword); | |
202 WriteParam(m, p.display_name); | |
203 } | |
204 | |
205 static bool Read(const Message* m, PickleIterator* iter, param_type* p) { | |
206 return | |
207 ReadParam(m, iter, &p->url) && | |
208 ReadParam(m, iter, &p->keyword) && | |
209 ReadParam(m, iter, &p->display_name); | |
210 } | |
211 | |
212 static void Log(const param_type& p, std::string* l) { | |
213 l->append("("); | |
214 LogParam(p.url, l); | |
215 l->append(", "); | |
216 LogParam(p.keyword, l); | |
217 l->append(", "); | |
218 LogParam(p.display_name, l); | |
219 l->append(")"); | |
220 } | |
221 }; // ParamTraits<importer::URLKeywordInfo> | |
222 | |
223 } // namespace IPC | |
224 | |
225 #endif // CHROME_BROWSER_IMPORTER_PROFILE_IMPORT_PROCESS_MESSAGES_H_ | |
226 | |
227 #define IPC_MESSAGE_START ProfileImportMsgStart | |
228 | |
229 //----------------------------------------------------------------------------- | |
230 // ProfileImportProcess messages | |
231 // These are messages sent from the browser to the profile import process. | |
232 IPC_MESSAGE_CONTROL3(ProfileImportProcessMsg_StartImport, | |
233 importer::SourceProfile, | |
234 int /* Bitmask of items to import. */, | |
235 DictionaryValue /* Localized strings. */) | |
236 | |
237 IPC_MESSAGE_CONTROL0(ProfileImportProcessMsg_CancelImport) | |
238 | |
239 IPC_MESSAGE_CONTROL1(ProfileImportProcessMsg_ReportImportItemFinished, | |
240 int /* ImportItem */) | |
241 | |
242 //--------------------------------------------------------------------------- | |
243 // ProfileImportProcessHost messages | |
244 // These are messages sent from the profile import process to the browser. | |
245 // These messages send information about the status of the import and | |
246 // individual import tasks. | |
247 IPC_MESSAGE_CONTROL0(ProfileImportProcessHostMsg_Import_Started) | |
248 | |
249 IPC_MESSAGE_CONTROL2(ProfileImportProcessHostMsg_Import_Finished, | |
250 bool /* was import successful? */, | |
251 std::string /* error message, if any */) | |
252 | |
253 IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_ImportItem_Started, | |
254 int /* ImportItem */) | |
255 | |
256 IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_ImportItem_Finished, | |
257 int /* ImportItem */) | |
258 | |
259 // These messages send data from the external importer process back to | |
260 // the process host so it can be written to the profile. | |
261 IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyHistoryImportStart, | |
262 int /* total number of ImporterURLRow items */) | |
263 | |
264 IPC_MESSAGE_CONTROL2(ProfileImportProcessHostMsg_NotifyHistoryImportGroup, | |
265 std::vector<ImporterURLRow>, | |
266 int /* the source of URLs as in history::VisitSource.*/ | |
267 /* To simplify IPC call, pass as an integer */) | |
268 | |
269 IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyHomePageImportReady, | |
270 GURL /* GURL of home page */) | |
271 | |
272 IPC_MESSAGE_CONTROL2(ProfileImportProcessHostMsg_NotifyBookmarksImportStart, | |
273 string16 /* first folder name */, | |
274 int /* total number of bookmarks */) | |
275 | |
276 IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyBookmarksImportGroup, | |
277 std::vector<ImportedBookmarkEntry>) | |
278 | |
279 IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyFaviconsImportStart, | |
280 int /* total number of favicons */) | |
281 | |
282 IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyFaviconsImportGroup, | |
283 std::vector<ImportedFaviconUsage>) | |
284 | |
285 IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyPasswordFormReady, | |
286 content::PasswordForm) | |
287 | |
288 IPC_MESSAGE_CONTROL2(ProfileImportProcessHostMsg_NotifyKeywordsReady, | |
289 std::vector<importer::URLKeywordInfo>, // url_keywords | |
290 bool /* unique on host and path */) | |
291 | |
292 IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyFirefoxSearchEngData, | |
293 std::vector<std::string>) // search_engine_data | |
294 | |
OLD | NEW |