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.
5 // Multiply-included message file, so no include guard.
9 #endif // defined(OS_WIN)
14 #include "base/files/file_path.h"
15 #include "base/strings/string16.h"
16 #include "base/tuple.h"
17 #include "base/values.h"
18 #include "chrome/common/safe_browsing/zip_analyzer.h"
19 #include "ipc/ipc_message_macros.h"
20 #include "ipc/ipc_platform_file.h"
21 #include "third_party/skia/include/core/SkBitmap.h"
22 #include "ui/gfx/ipc/gfx_param_traits.h"
24 #define IPC_MESSAGE_START ChromeUtilityMsgStart
26 #ifndef CHROME_COMMON_CHROME_UTILITY_MESSAGES_H_
27 #define CHROME_COMMON_CHROME_UTILITY_MESSAGES_H_
29 typedef std::vector
<Tuple2
<SkBitmap
, base::FilePath
> > DecodedImages
;
31 #endif // CHROME_COMMON_CHROME_UTILITY_MESSAGES_H_
33 IPC_STRUCT_TRAITS_BEGIN(safe_browsing::zip_analyzer::Results
)
34 IPC_STRUCT_TRAITS_MEMBER(success
)
35 IPC_STRUCT_TRAITS_MEMBER(has_executable
)
36 IPC_STRUCT_TRAITS_MEMBER(has_archive
)
37 IPC_STRUCT_TRAITS_END()
41 // A vector of filters, each being a Tuple2 containing a display string (i.e.
42 // "Text Files") and a filter pattern (i.e. "*.txt").
43 typedef std::vector
<Tuple2
<base::string16
, base::string16
> >
44 GetOpenFileNameFilter
;
46 IPC_STRUCT_BEGIN(ChromeUtilityMsg_GetSaveFileName_Params
)
47 IPC_STRUCT_MEMBER(HWND
, owner
)
48 IPC_STRUCT_MEMBER(DWORD
, flags
)
49 IPC_STRUCT_MEMBER(GetOpenFileNameFilter
, filters
)
50 IPC_STRUCT_MEMBER(int, one_based_filter_index
)
51 IPC_STRUCT_MEMBER(base::FilePath
, suggested_filename
)
52 IPC_STRUCT_MEMBER(base::FilePath
, initial_directory
)
53 IPC_STRUCT_MEMBER(base::string16
, default_extension
)
58 //------------------------------------------------------------------------------
59 // Utility process messages:
60 // These are messages from the browser to the utility process.
62 // Tell the utility process to parse the given JSON data and verify its
64 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_UnpackWebResource
,
65 std::string
/* JSON data */)
67 // Tell the utility process to decode the given image data.
68 IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_DecodeImage
,
69 std::vector
<unsigned char> /* encoded image contents */,
70 bool /* shrink image if needed for IPC msg limit */)
72 // Tell the utility process to decode the given JPEG image data with a robust
74 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_RobustJPEGDecodeImage
,
75 std::vector
<unsigned char>) // encoded image contents
77 // Tell the utility process to patch the given |input_file| using |patch_file|
78 // and place the output in |output_file|. The patch should use the bsdiff
79 // algorithm (Courgette's version).
80 IPC_MESSAGE_CONTROL3(ChromeUtilityMsg_PatchFileBsdiff
,
81 base::FilePath
/* input_file */,
82 base::FilePath
/* patch_file */,
83 base::FilePath
/* output_file */)
85 // Tell the utility process to patch the given |input_file| using |patch_file|
86 // and place the output in |output_file|. The patch should use the Courgette
88 IPC_MESSAGE_CONTROL3(ChromeUtilityMsg_PatchFileCourgette
,
89 base::FilePath
/* input_file */,
90 base::FilePath
/* patch_file */,
91 base::FilePath
/* output_file */)
93 #if defined(OS_CHROMEOS)
94 // Tell the utility process to create a zip file on the given list of files.
95 IPC_MESSAGE_CONTROL3(ChromeUtilityMsg_CreateZipFile
,
96 base::FilePath
/* src_dir */,
97 std::vector
<base::FilePath
> /* src_relative_paths */,
98 base::FileDescriptor
/* dest_fd */)
99 #endif // defined(OS_CHROMEOS)
101 // Requests the utility process to respond with a
102 // ChromeUtilityHostMsg_ProcessStarted message once it has started. This may
103 // be used if the host process needs a handle to the running utility process.
104 IPC_MESSAGE_CONTROL0(ChromeUtilityMsg_StartupPing
)
106 #if defined(FULL_SAFE_BROWSING)
107 // Tells the utility process to analyze a zip file for malicious download
109 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection
,
110 IPC::PlatformFileForTransit
/* zip_file */)
114 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_OpenItemViaShell
,
115 base::FilePath
/* full_path */)
117 // Instructs the utility process to invoke GetOpenFileName. |owner| is the
118 // parent of the modal dialog, |flags| are OFN_* flags. |filter| constrains the
119 // user's file choices. |initial_directory| and |filename| select the directory
120 // to be displayed and the file to be initially selected.
122 // Either ChromeUtilityHostMsg_GetOpenFileName_Failed or
123 // ChromeUtilityHostMsg_GetOpenFileName_Result will be returned when the
124 // operation completes whether due to error or user action.
125 IPC_MESSAGE_CONTROL5(ChromeUtilityMsg_GetOpenFileName
,
128 GetOpenFileNameFilter
/* filter */,
129 base::FilePath
/* initial_directory */,
130 base::FilePath
/* filename */)
131 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_GetSaveFileName
,
132 ChromeUtilityMsg_GetSaveFileName_Params
/* params */)
133 #endif // defined(OS_WIN)
135 //------------------------------------------------------------------------------
136 // Utility process host messages:
137 // These are messages from the utility process to the browser.
139 // Reply when the utility process is done unpacking and parsing JSON data
140 // from a web resource.
141 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnpackWebResource_Succeeded
,
142 base::DictionaryValue
/* json data */)
144 // Reply when the utility process has failed while unpacking and parsing a
145 // web resource. |error_message| is a user-readable explanation of what
147 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnpackWebResource_Failed
,
148 std::string
/* error_message, if any */)
150 // Reply when the utility process has succeeded in decoding the image.
151 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_DecodeImage_Succeeded
,
152 SkBitmap
) // decoded image
154 // Reply when an error occurred decoding the image.
155 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_DecodeImage_Failed
)
157 // Reply when a file has been patched.
158 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_PatchFile_Finished
, int /* result */)
160 #if defined(OS_CHROMEOS)
161 // Reply when the utility process has succeeded in creating the zip file.
162 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_CreateZipFile_Succeeded
)
164 // Reply when an error occured in creating the zip file.
165 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_CreateZipFile_Failed
)
166 #endif // defined(OS_CHROMEOS)
168 // Reply when the utility process has started.
169 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_ProcessStarted
)
171 #if defined(FULL_SAFE_BROWSING)
172 // Reply when a zip file has been analyzed for malicious download protection.
173 IPC_MESSAGE_CONTROL1(
174 ChromeUtilityHostMsg_AnalyzeZipFileForDownloadProtection_Finished
,
175 safe_browsing::zip_analyzer::Results
)
179 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_GetOpenFileName_Failed
)
180 IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_GetOpenFileName_Result
,
181 base::FilePath
/* directory */,
182 std::vector
<base::FilePath
> /* filenames */)
183 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_GetSaveFileName_Failed
)
184 IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_GetSaveFileName_Result
,
185 base::FilePath
/* path */,
186 int /* one_based_filter_index */)
187 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_BuildDirectWriteFontCache
,
188 base::FilePath
/* cache file path */)
189 #endif // defined(OS_WIN)