1 // Copyright 2014 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, so no include guard.
10 #include "base/basictypes.h"
11 #include "base/files/file_path.h"
12 #include "chrome/common/media_galleries/iphoto_library.h"
13 #include "chrome/common/media_galleries/itunes_library.h"
14 #include "chrome/common/media_galleries/metadata_types.h"
15 #include "chrome/common/media_galleries/picasa_types.h"
16 #include "ipc/ipc_message_macros.h"
17 #include "ipc/ipc_platform_file.h"
19 #if !defined(ENABLE_EXTENSIONS)
20 #error "Extensions must be enabled"
23 #define IPC_MESSAGE_START ChromeUtilityExtensionsMsgStart
25 #if defined(OS_MACOSX)
26 IPC_STRUCT_TRAITS_BEGIN(iphoto::parser::Photo)
27 IPC_STRUCT_TRAITS_MEMBER(id)
28 IPC_STRUCT_TRAITS_MEMBER(location)
29 IPC_STRUCT_TRAITS_MEMBER(original_location)
30 IPC_STRUCT_TRAITS_END()
32 IPC_STRUCT_TRAITS_BEGIN(iphoto::parser::Library)
33 IPC_STRUCT_TRAITS_MEMBER(albums)
34 IPC_STRUCT_TRAITS_MEMBER(all_photos)
35 IPC_STRUCT_TRAITS_END()
36 #endif // defined(OS_MACOSX)
38 #if defined(OS_WIN) || defined(OS_MACOSX)
39 IPC_STRUCT_TRAITS_BEGIN(itunes::parser::Track)
40 IPC_STRUCT_TRAITS_MEMBER(id)
41 IPC_STRUCT_TRAITS_MEMBER(location)
42 IPC_STRUCT_TRAITS_END()
44 IPC_STRUCT_TRAITS_BEGIN(picasa::AlbumInfo)
45 IPC_STRUCT_TRAITS_MEMBER(name)
46 IPC_STRUCT_TRAITS_MEMBER(timestamp)
47 IPC_STRUCT_TRAITS_MEMBER(uid)
48 IPC_STRUCT_TRAITS_MEMBER(path)
49 IPC_STRUCT_TRAITS_END()
51 // These files are opened read-only. Please see the constructor for
52 // picasa::AlbumTableFiles for details.
53 IPC_STRUCT_TRAITS_BEGIN(picasa::AlbumTableFilesForTransit)
54 IPC_STRUCT_TRAITS_MEMBER(indicator_file)
55 IPC_STRUCT_TRAITS_MEMBER(category_file)
56 IPC_STRUCT_TRAITS_MEMBER(date_file)
57 IPC_STRUCT_TRAITS_MEMBER(filename_file)
58 IPC_STRUCT_TRAITS_MEMBER(name_file)
59 IPC_STRUCT_TRAITS_MEMBER(token_file)
60 IPC_STRUCT_TRAITS_MEMBER(uid_file)
61 IPC_STRUCT_TRAITS_END()
63 IPC_STRUCT_TRAITS_BEGIN(picasa::FolderINIContents)
64 IPC_STRUCT_TRAITS_MEMBER(folder_path)
65 IPC_STRUCT_TRAITS_MEMBER(ini_contents)
66 IPC_STRUCT_TRAITS_END()
67 #endif // defined(OS_WIN) || defined(OS_MACOSX)
69 IPC_STRUCT_TRAITS_BEGIN(metadata::AttachedImage)
70 IPC_STRUCT_TRAITS_MEMBER(type)
71 IPC_STRUCT_TRAITS_MEMBER(data)
72 IPC_STRUCT_TRAITS_END()
74 //------------------------------------------------------------------------------
75 // Utility process messages:
76 // These are messages from the browser to the utility process.
78 // Tells the utility process to unpack the given extension file in its
79 // directory and verify that it is valid.
80 IPC_MESSAGE_CONTROL4(ChromeUtilityMsg_UnpackExtension,
81 base::FilePath /* extension_filename */,
82 std::string /* extension_id */,
83 int /* Manifest::Location */,
84 int /* InitFromValue flags */)
86 IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_UnzipToDir,
87 base::FilePath /* zip_file */,
88 base::FilePath /* dir */)
90 // Tell the utility process to decode the given image data, which is base64
92 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_DecodeImageBase64,
93 std::string) // base64 encoded image contents
95 // Tell the utility process to parse a JSON string into a Value object.
96 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseJSON,
97 std::string /* JSON to parse */)
100 // Tell the utility process to parse the iTunes preference XML file contents
101 // and return the path to the iTunes directory.
102 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseITunesPrefXml,
103 std::string /* XML to parse */)
104 #endif // defined(OS_WIN)
106 #if defined(OS_MACOSX)
107 // Tell the utility process to parse the iPhoto library XML file and
108 // return the parse result as well as the iPhoto library as an iphoto::Library.
109 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseIPhotoLibraryXmlFile,
110 IPC::PlatformFileForTransit /* XML file to parse */)
111 #endif // defined(OS_MACOSX)
113 #if defined(OS_WIN) || defined(OS_MACOSX)
114 // Tell the utility process to parse the iTunes library XML file and
115 // return the parse result as well as the iTunes library as an itunes::Library.
116 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseITunesLibraryXmlFile,
117 IPC::PlatformFileForTransit /* XML file to parse */)
119 // Tells the utility process to parse the Picasa PMP database and return a
120 // listing of the user's Picasa albums and folders, along with metadata.
121 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParsePicasaPMPDatabase,
122 picasa::AlbumTableFilesForTransit /* album_table_files */)
124 // Tells the utility process to index the Picasa user-created Album contents
125 // by parsing all the INI files in Picasa Folders.
126 IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_IndexPicasaAlbumsContents,
127 picasa::AlbumUIDSet /* album_uids */,
128 std::vector<picasa::FolderINIContents> /* folders_inis */)
129 #endif // defined(OS_WIN) || defined(OS_MACOSX)
131 // Tell the utility process to attempt to validate the passed media file. The
132 // file will undergo basic sanity checks and will be decoded for up to
133 // |milliseconds_of_decoding| wall clock time. It is still not safe to decode
134 // the file in the browser process after this check.
135 IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_CheckMediaFile,
136 int64 /* milliseconds_of_decoding */,
137 IPC::PlatformFileForTransit /* Media file to parse */)
139 IPC_MESSAGE_CONTROL3(ChromeUtilityMsg_ParseMediaMetadata,
140 std::string /* mime_type */,
141 int64 /* total_size */,
142 bool /* get_attached_images */)
144 IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_RequestBlobBytes_Finished,
145 int64 /* request_id */,
146 std::string /* bytes */)
148 // Requests that the utility process write the contents of the source file to
149 // the removable drive listed in the target file. The target will be restricted
150 // to removable drives by the utility process.
151 IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_ImageWriter_Write,
152 base::FilePath /* source file */,
153 base::FilePath /* target file */)
155 // Requests that the utility process verify that the contents of the source file
156 // was written to the target. As above the target will be restricted to
157 // removable drives by the utility process.
158 IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_ImageWriter_Verify,
159 base::FilePath /* source file */,
160 base::FilePath /* target file */)
162 // Cancels a pending write or verify operation.
163 IPC_MESSAGE_CONTROL0(ChromeUtilityMsg_ImageWriter_Cancel)
165 //------------------------------------------------------------------------------
166 // Utility process host messages:
167 // These are messages from the utility process to the browser.
169 // Reply when the utility process is done unpacking an extension. |manifest|
170 // is the parsed manifest.json file.
171 // The unpacker should also have written out files containing the decoded
172 // images and message catalogs from the extension. The data is written into a
173 // DecodedImages struct into a file named kDecodedImagesFilename in the
174 // directory that was passed in. This is done because the data is too large to
176 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnpackExtension_Succeeded,
177 base::DictionaryValue /* manifest */)
179 // Reply when the utility process has failed while unpacking an extension.
180 // |error_message| is a user-displayable explanation of what went wrong.
181 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnpackExtension_Failed,
182 base::string16 /* error_message, if any */)
184 // Reply when the utility process is done unzipping a file. |unpacked_path|
185 // is the directory which contains the unzipped contents.
186 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnzipToDir_Succeeded,
187 base::FilePath /* unpacked_path */)
189 // Reply when the utility process failed to unzip a file. |error| contains
190 // an error string to be reported to the user.
191 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnzipToDir_Failed,
192 std::string /* error */)
194 // Reply when the utility process successfully parsed a JSON string.
196 // WARNING: The result can be of any Value subclass type, but we can't easily
197 // pass indeterminate value types by const object reference with our IPC macros,
198 // so we put the result Value into a ListValue. Handlers should examine the
199 // first (and only) element of the ListValue for the actual result.
200 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ParseJSON_Succeeded,
203 // Reply when the utility process failed in parsing a JSON string.
204 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ParseJSON_Failed,
205 std::string /* error message, if any*/)
208 // Reply after parsing the iTunes preferences XML file contents with either the
209 // path to the iTunes directory or an empty FilePath.
210 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_GotITunesDirectory,
211 base::FilePath /* Path to iTunes library */)
212 #endif // defined(OS_WIN)
214 #if defined(OS_MACOSX)
215 // Reply after parsing the iPhoto library XML file with the parser result and
216 // an iphoto::Library data structure.
217 IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_GotIPhotoLibrary,
218 bool /* Parser result */,
219 iphoto::parser::Library /* iPhoto library */)
220 #endif // defined(OS_MACOSX)
222 #if defined(OS_WIN) || defined(OS_MACOSX)
223 // Reply after parsing the iTunes library XML file with the parser result and
224 // an itunes::Library data structure.
225 IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_GotITunesLibrary,
226 bool /* Parser result */,
227 itunes::parser::Library /* iTunes library */)
229 // Reply after parsing the Picasa PMP Database with the parser result and a
230 // listing of the user's Picasa albums and folders, along with metadata.
231 IPC_MESSAGE_CONTROL3(ChromeUtilityHostMsg_ParsePicasaPMPDatabase_Finished,
232 bool /* parse_success */,
233 std::vector<picasa::AlbumInfo> /* albums */,
234 std::vector<picasa::AlbumInfo> /* folders */)
236 // Reply after indexing the Picasa user-created Album contents by parsing all
237 // the INI files in Picasa Folders.
238 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished,
239 picasa::AlbumImagesMap /* albums_images */)
240 #endif // defined(OS_WIN) || defined(OS_MACOSX)
242 // Reply after checking the passed media file. A true result indicates that
243 // the file appears to be a well formed media file.
244 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_CheckMediaFile_Finished,
245 bool /* passed_checks */)
247 IPC_MESSAGE_CONTROL3(
248 ChromeUtilityHostMsg_ParseMediaMetadata_Finished,
249 bool /* parse_success */,
250 base::DictionaryValue /* metadata */,
251 std::vector<metadata::AttachedImage> /* attached_images */)
253 IPC_MESSAGE_CONTROL3(ChromeUtilityHostMsg_RequestBlobBytes,
254 int64 /* request_id */,
255 int64 /* start_byte */,
258 // Reply when a write or verify operation succeeds.
259 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_ImageWriter_Succeeded)
261 // Reply when a write or verify operation has been fully cancelled.
262 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_ImageWriter_Cancelled)
264 // Reply when a write or verify operation fails to complete.
265 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ImageWriter_Failed,
266 std::string /* message */)
268 // Periodic status update about the progress of an operation.
269 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ImageWriter_Progress,
270 int64 /* number of bytes processed */)
273 // Get plain-text WiFi credentials from the system (requires UAC privilege
275 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_GetWiFiCredentials,
276 std::string /* ssid */)
278 // Reply after getting WiFi credentials from the system. |success| is false if
280 IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_GotWiFiCredentials,
281 std::string /* key_data */,
283 #endif // defined(OS_WIN)