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