Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / utility / chrome_content_utility_client.h
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.
4
5 #ifndef CHROME_UTILITY_CHROME_CONTENT_UTILITY_CLIENT_H_
6 #define CHROME_UTILITY_CHROME_CONTENT_UTILITY_CLIENT_H_
7
8 #include <set>
9 #include <string>
10 #include <vector>
11
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"
16
17 namespace base {
18 class FilePath;
19 struct FileDescriptor;
20 }
21
22 class UtilityMessageHandler;
23
24 class ChromeContentUtilityClient : public content::ContentUtilityClient {
25  public:
26   ChromeContentUtilityClient();
27   virtual ~ChromeContentUtilityClient();
28
29   virtual void UtilityThreadStarted() OVERRIDE;
30   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
31
32   static void PreSandboxStartup();
33
34   // Shared with extensions::ExtensionsHandler.
35   static void DecodeImage(const std::vector<unsigned char>& encoded_data);
36
37  private:
38   // IPC message handlers.
39   void OnUnpackWebResource(const std::string& resource_data);
40   void OnDecodeImage(const std::vector<unsigned char>& encoded_data);
41   void OnRobustJPEGDecodeImage(
42       const std::vector<unsigned char>& encoded_data);
43
44 #if defined(OS_CHROMEOS)
45   void OnCreateZipFile(const base::FilePath& src_dir,
46                        const std::vector<base::FilePath>& src_relative_paths,
47                        const base::FileDescriptor& dest_fd);
48 #endif  // defined(OS_CHROMEOS)
49
50   void OnPatchFileBsdiff(const base::FilePath& input_file,
51                          const base::FilePath& patch_file,
52                          const base::FilePath& output_file);
53   void OnPatchFileCourgette(const base::FilePath& input_file,
54                             const base::FilePath& patch_file,
55                             const base::FilePath& output_file);
56   void OnStartupPing();
57 #if defined(FULL_SAFE_BROWSING)
58   void OnAnalyzeZipFileForDownloadProtection(
59       const IPC::PlatformFileForTransit& zip_file);
60 #endif
61 #if defined(ENABLE_EXTENSIONS)
62   void OnParseMediaMetadata(const std::string& mime_type,
63                             int64 total_size,
64                             bool get_attached_images);
65 #endif
66
67   typedef ScopedVector<UtilityMessageHandler> Handlers;
68   Handlers handlers_;
69
70   // Flag to enable whitelisting.
71   bool filter_messages_;
72   // A list of message_ids to filter.
73   std::set<int> message_id_whitelist_;
74
75   DISALLOW_COPY_AND_ASSIGN(ChromeContentUtilityClient);
76 };
77
78 #endif  // CHROME_UTILITY_CHROME_CONTENT_UTILITY_CLIENT_H_