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 IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_UnzipToDir
,
79 base::FilePath
/* zip_file */,
80 base::FilePath
/* dir */)
82 // Tell the utility process to decode the given image data, which is base64
84 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_DecodeImageBase64
,
85 std::string
) // base64 encoded image contents
88 // Tell the utility process to parse the iTunes preference XML file contents
89 // and return the path to the iTunes directory.
90 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseITunesPrefXml
,
91 std::string
/* XML to parse */)
92 #endif // defined(OS_WIN)
94 #if defined(OS_MACOSX)
95 // Tell the utility process to parse the iPhoto library XML file and
96 // return the parse result as well as the iPhoto library as an iphoto::Library.
97 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseIPhotoLibraryXmlFile
,
98 IPC::PlatformFileForTransit
/* XML file to parse */)
99 #endif // defined(OS_MACOSX)
101 #if defined(OS_WIN) || defined(OS_MACOSX)
102 // Tell the utility process to parse the iTunes library XML file and
103 // return the parse result as well as the iTunes library as an itunes::Library.
104 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseITunesLibraryXmlFile
,
105 IPC::PlatformFileForTransit
/* XML file to parse */)
107 // Tells the utility process to parse the Picasa PMP database and return a
108 // listing of the user's Picasa albums and folders, along with metadata.
109 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParsePicasaPMPDatabase
,
110 picasa::AlbumTableFilesForTransit
/* album_table_files */)
112 // Tells the utility process to index the Picasa user-created Album contents
113 // by parsing all the INI files in Picasa Folders.
114 IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_IndexPicasaAlbumsContents
,
115 picasa::AlbumUIDSet
/* album_uids */,
116 std::vector
<picasa::FolderINIContents
> /* folders_inis */)
117 #endif // defined(OS_WIN) || defined(OS_MACOSX)
119 // Tell the utility process to attempt to validate the passed media file. The
120 // file will undergo basic sanity checks and will be decoded for up to
121 // |milliseconds_of_decoding| wall clock time. It is still not safe to decode
122 // the file in the browser process after this check.
123 IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_CheckMediaFile
,
124 int64
/* milliseconds_of_decoding */,
125 IPC::PlatformFileForTransit
/* Media file to parse */)
127 IPC_MESSAGE_CONTROL3(ChromeUtilityMsg_ParseMediaMetadata
,
128 std::string
/* mime_type */,
129 int64
/* total_size */,
130 bool /* get_attached_images */)
132 IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_RequestBlobBytes_Finished
,
133 int64
/* request_id */,
134 std::string
/* bytes */)
136 // Requests that the utility process write the contents of the source file to
137 // the removable drive listed in the target file. The target will be restricted
138 // to removable drives by the utility process.
139 IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_ImageWriter_Write
,
140 base::FilePath
/* source file */,
141 base::FilePath
/* target file */)
143 // Requests that the utility process verify that the contents of the source file
144 // was written to the target. As above the target will be restricted to
145 // removable drives by the utility process.
146 IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_ImageWriter_Verify
,
147 base::FilePath
/* source file */,
148 base::FilePath
/* target file */)
150 // Cancels a pending write or verify operation.
151 IPC_MESSAGE_CONTROL0(ChromeUtilityMsg_ImageWriter_Cancel
)
153 //------------------------------------------------------------------------------
154 // Utility process host messages:
155 // These are messages from the utility process to the browser.
157 // Reply when the utility process is done unzipping a file. |unpacked_path|
158 // is the directory which contains the unzipped contents.
159 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnzipToDir_Succeeded
,
160 base::FilePath
/* unpacked_path */)
162 // Reply when the utility process failed to unzip a file. |error| contains
163 // an error string to be reported to the user.
164 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnzipToDir_Failed
,
165 std::string
/* error */)
168 // Reply after parsing the iTunes preferences XML file contents with either the
169 // path to the iTunes directory or an empty FilePath.
170 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_GotITunesDirectory
,
171 base::FilePath
/* Path to iTunes library */)
172 #endif // defined(OS_WIN)
174 #if defined(OS_MACOSX)
175 // Reply after parsing the iPhoto library XML file with the parser result and
176 // an iphoto::Library data structure.
177 IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_GotIPhotoLibrary
,
178 bool /* Parser result */,
179 iphoto::parser::Library
/* iPhoto library */)
180 #endif // defined(OS_MACOSX)
182 #if defined(OS_WIN) || defined(OS_MACOSX)
183 // Reply after parsing the iTunes library XML file with the parser result and
184 // an itunes::Library data structure.
185 IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_GotITunesLibrary
,
186 bool /* Parser result */,
187 itunes::parser::Library
/* iTunes library */)
189 // Reply after parsing the Picasa PMP Database with the parser result and a
190 // listing of the user's Picasa albums and folders, along with metadata.
191 IPC_MESSAGE_CONTROL3(ChromeUtilityHostMsg_ParsePicasaPMPDatabase_Finished
,
192 bool /* parse_success */,
193 std::vector
<picasa::AlbumInfo
> /* albums */,
194 std::vector
<picasa::AlbumInfo
> /* folders */)
196 // Reply after indexing the Picasa user-created Album contents by parsing all
197 // the INI files in Picasa Folders.
198 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished
,
199 picasa::AlbumImagesMap
/* albums_images */)
200 #endif // defined(OS_WIN) || defined(OS_MACOSX)
202 // Reply after checking the passed media file. A true result indicates that
203 // the file appears to be a well formed media file.
204 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_CheckMediaFile_Finished
,
205 bool /* passed_checks */)
207 IPC_MESSAGE_CONTROL3(
208 ChromeUtilityHostMsg_ParseMediaMetadata_Finished
,
209 bool /* parse_success */,
210 base::DictionaryValue
/* metadata */,
211 std::vector
<metadata::AttachedImage
> /* attached_images */)
213 IPC_MESSAGE_CONTROL3(ChromeUtilityHostMsg_RequestBlobBytes
,
214 int64
/* request_id */,
215 int64
/* start_byte */,
218 // Reply when a write or verify operation succeeds.
219 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_ImageWriter_Succeeded
)
221 // Reply when a write or verify operation has been fully cancelled.
222 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_ImageWriter_Cancelled
)
224 // Reply when a write or verify operation fails to complete.
225 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ImageWriter_Failed
,
226 std::string
/* message */)
228 // Periodic status update about the progress of an operation.
229 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ImageWriter_Progress
,
230 int64
/* number of bytes processed */)
233 // Get plain-text WiFi credentials from the system (requires UAC privilege
235 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_GetWiFiCredentials
,
236 std::string
/* ssid */)
238 // Reply after getting WiFi credentials from the system. |success| is false if
240 IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_GotWiFiCredentials
,
241 std::string
/* key_data */,
243 #endif // defined(OS_WIN)