Upstream version 5.34.104.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 "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h"
11 #include "base/platform_file.h"
12 #include "chrome/common/media_galleries/picasa_types.h"
13 #include "content/public/utility/content_utility_client.h"
14 #include "ipc/ipc_platform_file.h"
15
16 namespace base {
17 class FilePath;
18 struct FileDescriptor;
19 }
20
21 namespace gfx {
22 class Rect;
23 }
24
25 namespace metadata {
26 class MediaMetadataParser;
27 }
28
29 namespace printing {
30 class PdfRenderSettings;
31 struct PageRange;
32 }
33
34 namespace chrome {
35
36 class UtilityMessageHandler;
37
38 class ChromeContentUtilityClient : public content::ContentUtilityClient {
39  public:
40   ChromeContentUtilityClient();
41   virtual ~ChromeContentUtilityClient();
42
43   virtual void UtilityThreadStarted() OVERRIDE;
44   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
45
46   static void PreSandboxStartup();
47
48  private:
49   // IPC message handlers.
50   void OnUnpackExtension(const base::FilePath& extension_path,
51                          const std::string& extension_id,
52                          int location, int creation_flags);
53   void OnUnpackWebResource(const std::string& resource_data);
54   void OnParseUpdateManifest(const std::string& xml);
55   void OnDecodeImage(const std::vector<unsigned char>& encoded_data);
56   void OnDecodeImageBase64(const std::string& encoded_data);
57   void OnRenderPDFPagesToMetafile(
58       base::PlatformFile pdf_file,
59       const base::FilePath& metafile_path,
60       const printing::PdfRenderSettings& settings,
61       const std::vector<printing::PageRange>& page_ranges);
62   void OnRenderPDFPagesToPWGRaster(
63       IPC::PlatformFileForTransit pdf_transit,
64       const printing::PdfRenderSettings& settings,
65       IPC::PlatformFileForTransit bitmap_transit);
66   void OnRobustJPEGDecodeImage(
67       const std::vector<unsigned char>& encoded_data);
68   void OnParseJSON(const std::string& json);
69
70 #if defined(OS_CHROMEOS)
71   void OnCreateZipFile(const base::FilePath& src_dir,
72                        const std::vector<base::FilePath>& src_relative_paths,
73                        const base::FileDescriptor& dest_fd);
74 #endif  // defined(OS_CHROMEOS)
75
76 #if defined(OS_WIN)
77   // Helper method for Windows.
78   // |highest_rendered_page_number| is set to -1 on failure to render any page.
79   bool RenderPDFToWinMetafile(
80       base::PlatformFile pdf_file,
81       const base::FilePath& metafile_path,
82       const printing::PdfRenderSettings& settings,
83       const std::vector<printing::PageRange>& page_ranges,
84       int* highest_rendered_page_number,
85       double* scale_factor);
86 #endif   // defined(OS_WIN)
87
88   bool RenderPDFPagesToPWGRaster(
89       base::PlatformFile pdf_file,
90       const printing::PdfRenderSettings& settings,
91       base::PlatformFile bitmap_file);
92
93   void OnGetPrinterCapsAndDefaults(const std::string& printer_name);
94   void OnGetPrinterSemanticCapsAndDefaults(const std::string& printer_name);
95   void OnStartupPing();
96   void OnAnalyzeZipFileForDownloadProtection(
97       const IPC::PlatformFileForTransit& zip_file);
98 #if !defined(OS_ANDROID) && !defined(OS_IOS)
99   void OnCheckMediaFile(int64 milliseconds_of_decoding,
100                         const IPC::PlatformFileForTransit& media_file);
101   void OnParseMediaMetadata(const std::string& mime_type, int64 total_size);
102 #endif  // !defined(OS_ANDROID) && !defined(OS_IOS)
103
104 #if defined(OS_WIN)
105   void OnParseITunesPrefXml(const std::string& itunes_xml_data);
106 #endif  // defined(OS_WIN)
107
108 #if defined(OS_MACOSX)
109   void OnParseIPhotoLibraryXmlFile(
110       const IPC::PlatformFileForTransit& iphoto_library_file);
111 #endif  // defined(OS_MACOSX)
112
113 #if defined(OS_WIN) || defined(OS_MACOSX)
114   void OnParseITunesLibraryXmlFile(
115       const IPC::PlatformFileForTransit& itunes_library_file);
116
117   void OnParsePicasaPMPDatabase(
118       const picasa::AlbumTableFilesForTransit& album_table_files);
119
120   void OnIndexPicasaAlbumsContents(
121       const picasa::AlbumUIDSet& album_uids,
122       const std::vector<picasa::FolderINIContents>& folders_inis);
123 #endif  // defined(OS_WIN) || defined(OS_MACOSX)
124
125   typedef ScopedVector<UtilityMessageHandler> Handlers;
126   Handlers handlers_;
127
128 #if !defined(OS_ANDROID) && !defined(OS_IOS)
129   scoped_ptr<metadata::MediaMetadataParser> media_metadata_parser_;
130 #endif  // !defined(OS_ANDROID) && !defined(OS_IOS)
131
132   // Flag to enable whitelisting.
133   bool filter_messages_;
134   // A list of message_ids to filter.
135   std::set<int> message_id_whitelist_;
136
137   DISALLOW_COPY_AND_ASSIGN(ChromeContentUtilityClient);
138 };
139
140 }  // namespace chrome
141
142 #endif  // CHROME_UTILITY_CHROME_CONTENT_UTILITY_CLIENT_H_