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 #ifndef CHROME_UTILITY_CHROME_CONTENT_UTILITY_CLIENT_H_
6 #define CHROME_UTILITY_CHROME_CONTENT_UTILITY_CLIENT_H_
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_vector.h"
14 #include "content/public/utility/content_utility_client.h"
15 #include "ipc/ipc_platform_file.h"
19 struct FileDescriptor
;
22 class UtilityMessageHandler
;
24 class ChromeContentUtilityClient
: public content::ContentUtilityClient
{
26 ChromeContentUtilityClient();
27 ~ChromeContentUtilityClient() override
;
29 void UtilityThreadStarted() override
;
30 bool OnMessageReceived(const IPC::Message
& message
) override
;
31 void RegisterMojoServices(content::ServiceRegistry
* registry
) override
;
33 static void PreSandboxStartup();
35 // Shared with extensions::ExtensionsHandler.
36 static SkBitmap
DecodeImage(const std::vector
<unsigned char>& encoded_data
,
38 static void DecodeImageAndSend(const std::vector
<unsigned char>& encoded_data
,
42 static void set_max_ipc_message_size_for_test(int64_t max_message_size
) {
43 max_ipc_message_size_
= max_message_size
;
47 // IPC message handlers.
48 void OnUnpackWebResource(const std::string
& resource_data
);
49 void OnDecodeImage(const std::vector
<unsigned char>& encoded_data
,
52 #if defined(OS_CHROMEOS)
53 void OnRobustJPEGDecodeImage(const std::vector
<unsigned char>& encoded_data
,
56 void OnCreateZipFile(const base::FilePath
& src_dir
,
57 const std::vector
<base::FilePath
>& src_relative_paths
,
58 const base::FileDescriptor
& dest_fd
);
59 #endif // defined(OS_CHROMEOS)
61 void OnPatchFileBsdiff(const base::FilePath
& input_file
,
62 const base::FilePath
& patch_file
,
63 const base::FilePath
& output_file
);
64 void OnPatchFileCourgette(const base::FilePath
& input_file
,
65 const base::FilePath
& patch_file
,
66 const base::FilePath
& output_file
);
68 #if defined(FULL_SAFE_BROWSING)
69 void OnAnalyzeZipFileForDownloadProtection(
70 const IPC::PlatformFileForTransit
& zip_file
,
71 const IPC::PlatformFileForTransit
& temp_file
);
72 #if defined(OS_MACOSX)
73 void OnAnalyzeDmgFileForDownloadProtection(
74 const IPC::PlatformFileForTransit
& dmg_file
);
77 #if defined(ENABLE_EXTENSIONS)
78 void OnParseMediaMetadata(const std::string
& mime_type
,
80 bool get_attached_images
);
83 typedef ScopedVector
<UtilityMessageHandler
> Handlers
;
86 // Flag to enable whitelisting.
87 bool filter_messages_
;
88 // A list of message_ids to filter.
89 std::set
<int> message_id_whitelist_
;
90 // Maximum IPC msg size (default to kMaximumMessageSize; override for testing)
91 static int64_t max_ipc_message_size_
;
93 DISALLOW_COPY_AND_ASSIGN(ChromeContentUtilityClient
);
96 #endif // CHROME_UTILITY_CHROME_CONTENT_UTILITY_CLIENT_H_