1 // Copyright 2013 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.
5 // Multiply-included message file, no traditonal include guard.
9 #include "base/basictypes.h"
10 #include "base/strings/string16.h"
11 #include "base/values.h"
12 #include "chrome/common/common_param_traits_macros.h"
13 #include "chrome/common/importer/imported_bookmark_entry.h"
14 #include "chrome/common/importer/imported_favicon_usage.h"
15 #include "chrome/common/importer/importer_data_types.h"
16 #include "chrome/common/importer/importer_url_row.h"
17 #include "components/autofill/content/common/autofill_param_traits_macros.h"
18 #include "components/autofill/core/common/password_form.h"
19 #include "content/public/common/common_param_traits.h"
20 #include "ipc/ipc_message_macros.h"
21 #include "ipc/ipc_message_utils.h"
23 #ifndef CHROME_COMMON_IMPORTER_PROFILE_IMPORT_PROCESS_MESSAGES_H_
24 #define CHROME_COMMON_IMPORTER_PROFILE_IMPORT_PROCESS_MESSAGES_H_
28 // Traits for importer::SourceProfile struct to pack/unpack.
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
);
40 static bool Read(const Message
* m
, PickleIterator
* iter
, param_type
* p
) {
41 if (!ReadParam(m
, iter
, &p
->importer_name
))
44 int importer_type
= 0;
45 if (!ReadParam(m
, iter
, &importer_type
))
47 p
->importer_type
= static_cast<importer::ImporterType
>(importer_type
);
49 if (!ReadParam(m
, iter
, &p
->source_path
) ||
50 !ReadParam(m
, iter
, &p
->app_path
)) {
54 int services_supported
= 0;
55 if (!ReadParam(m
, iter
, &services_supported
))
57 p
->services_supported
= static_cast<uint16
>(services_supported
);
59 if (!ReadParam(m
, iter
, &p
->locale
))
64 static void Log(const param_type
& p
, std::string
* l
) {
66 LogParam(p
.importer_name
, l
);
68 LogParam(static_cast<int>(p
.importer_type
), l
);
70 LogParam(p
.source_path
, l
);
72 LogParam(p
.app_path
, l
);
74 LogParam(static_cast<int>(p
.services_supported
), l
);
76 LogParam(p
.locale
, l
);
79 }; // ParamTraits<importer::SourceProfile>
81 // Traits for ImporterURLRow to pack/unpack.
83 struct ParamTraits
<ImporterURLRow
> {
84 typedef ImporterURLRow param_type
;
85 static void Write(Message
* m
, const param_type
& p
) {
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
);
93 static bool Read(const Message
* m
, PickleIterator
* iter
, param_type
* p
) {
96 int visit_count
, typed_count
;
97 base::Time last_visit
;
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
))
106 *p
= ImporterURLRow(url
);
108 p
->visit_count
= visit_count
;
109 p
->typed_count
= typed_count
;
110 p
->last_visit
= last_visit
;
114 static void Log(const param_type
& p
, std::string
* l
) {
118 LogParam(p
.title
, l
);
120 LogParam(p
.visit_count
, l
);
122 LogParam(p
.typed_count
, l
);
124 LogParam(p
.last_visit
, l
);
126 LogParam(p
.hidden
, l
);
129 }; // ParamTraits<ImporterURLRow>
131 // Traits for ImportedBookmarkEntry to pack/unpack.
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
);
143 static bool Read(const Message
* m
, PickleIterator
* iter
, param_type
* p
) {
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
));
152 static void Log(const param_type
& p
, std::string
* l
) {
154 LogParam(p
.in_toolbar
, l
);
156 LogParam(p
.is_folder
, l
);
162 LogParam(p
.title
, l
);
164 LogParam(p
.creation_time
, l
);
167 }; // ParamTraits<ImportedBookmarkEntry>
169 // Traits for ImportedFaviconUsage.
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
);
178 static bool Read(const Message
* m
, PickleIterator
* iter
, param_type
* p
) {
180 ReadParam(m
, iter
, &p
->favicon_url
) &&
181 ReadParam(m
, iter
, &p
->png_data
) &&
182 ReadParam(m
, iter
, &p
->urls
);
184 static void Log(const param_type
& p
, std::string
* l
) {
186 LogParam(p
.favicon_url
, l
);
188 LogParam(p
.png_data
, l
);
193 }; // ParamTraits<ImportedFaviconUsage>
195 // Traits for importer::URLKeywordInfo
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
);
205 static bool Read(const Message
* m
, PickleIterator
* iter
, param_type
* p
) {
207 ReadParam(m
, iter
, &p
->url
) &&
208 ReadParam(m
, iter
, &p
->keyword
) &&
209 ReadParam(m
, iter
, &p
->display_name
);
212 static void Log(const param_type
& p
, std::string
* l
) {
216 LogParam(p
.keyword
, l
);
218 LogParam(p
.display_name
, l
);
221 }; // ParamTraits<importer::URLKeywordInfo>
224 // Traits for importer::ImporterIE7PasswordInfo
226 struct ParamTraits
<importer::ImporterIE7PasswordInfo
> {
227 typedef importer::ImporterIE7PasswordInfo param_type
;
228 static void Write(Message
* m
, const param_type
& p
) {
229 WriteParam(m
, p
.url_hash
);
230 WriteParam(m
, p
.encrypted_data
);
231 WriteParam(m
, p
.date_created
);
234 static bool Read(const Message
* m
, PickleIterator
* iter
, param_type
* p
) {
236 ReadParam(m
, iter
, &p
->url_hash
) &&
237 ReadParam(m
, iter
, &p
->encrypted_data
) &&
238 ReadParam(m
, iter
, &p
->date_created
);
241 static void Log(const param_type
& p
, std::string
* l
) {
243 LogParam(p
.url_hash
, l
);
245 LogParam(p
.encrypted_data
, l
);
247 LogParam(p
.date_created
, l
);
250 }; // ParamTraits<importer::ImporterIE7PasswordInfo>
255 #endif // CHROME_COMMON_IMPORTER_PROFILE_IMPORT_PROCESS_MESSAGES_H_
257 #define IPC_MESSAGE_START ProfileImportMsgStart
259 //-----------------------------------------------------------------------------
260 // ProfileImportProcess messages
261 // These are messages sent from the browser to the profile import process.
262 IPC_MESSAGE_CONTROL3(ProfileImportProcessMsg_StartImport
,
263 importer::SourceProfile
,
264 int /* Bitmask of items to import. */,
265 base::DictionaryValue
/* Localized strings. */)
267 IPC_MESSAGE_CONTROL0(ProfileImportProcessMsg_CancelImport
)
269 IPC_MESSAGE_CONTROL1(ProfileImportProcessMsg_ReportImportItemFinished
,
270 int /* ImportItem */)
272 //---------------------------------------------------------------------------
273 // ProfileImportProcessHost messages
274 // These are messages sent from the profile import process to the browser.
275 // These messages send information about the status of the import and
276 // individual import tasks.
277 IPC_MESSAGE_CONTROL0(ProfileImportProcessHostMsg_Import_Started
)
279 IPC_MESSAGE_CONTROL2(ProfileImportProcessHostMsg_Import_Finished
,
280 bool /* was import successful? */,
281 std::string
/* error message, if any */)
283 IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_ImportItem_Started
,
284 int /* ImportItem */)
286 IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_ImportItem_Finished
,
287 int /* ImportItem */)
289 // These messages send data from the external importer process back to
290 // the process host so it can be written to the profile.
291 IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyHistoryImportStart
,
292 int /* total number of ImporterURLRow items */)
294 IPC_MESSAGE_CONTROL2(ProfileImportProcessHostMsg_NotifyHistoryImportGroup
,
295 std::vector
<ImporterURLRow
>,
296 int /* the source of URLs as in history::VisitSource.*/
297 /* To simplify IPC call, pass as an integer */)
299 IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyHomePageImportReady
,
300 GURL
/* GURL of home page */)
302 IPC_MESSAGE_CONTROL2(ProfileImportProcessHostMsg_NotifyBookmarksImportStart
,
303 base::string16
/* first folder name */,
304 int /* total number of bookmarks */)
306 IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyBookmarksImportGroup
,
307 std::vector
<ImportedBookmarkEntry
>)
309 IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyFaviconsImportStart
,
310 int /* total number of favicons */)
312 IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyFaviconsImportGroup
,
313 std::vector
<ImportedFaviconUsage
>)
315 IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyPasswordFormReady
,
316 autofill::PasswordForm
)
318 IPC_MESSAGE_CONTROL2(ProfileImportProcessHostMsg_NotifyKeywordsReady
,
319 std::vector
<importer::URLKeywordInfo
>, // url_keywords
320 bool /* unique on host and path */)
322 IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyFirefoxSearchEngData
,
323 std::vector
<std::string
>) // search_engine_data
326 IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyIE7PasswordInfo
,
327 importer::ImporterIE7PasswordInfo
) // password_info