Home | History | Annotate | Download | only in utility
      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 "chrome/common/media_galleries/picasa_types.h"
     11 #include "content/public/utility/content_utility_client.h"
     12 #include "ipc/ipc_platform_file.h"
     13 
     14 namespace base {
     15 class FilePath;
     16 struct FileDescriptor;
     17 }
     18 
     19 namespace metadata {
     20 class MediaMetadataParser;
     21 }
     22 
     23 class UtilityMessageHandler;
     24 
     25 class ChromeContentUtilityClient : public content::ContentUtilityClient {
     26  public:
     27   ChromeContentUtilityClient();
     28   virtual ~ChromeContentUtilityClient();
     29 
     30   virtual void UtilityThreadStarted() OVERRIDE;
     31   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
     32 
     33   static void PreSandboxStartup();
     34 
     35  private:
     36   // IPC message handlers.
     37   void OnUnpackExtension(const base::FilePath& extension_path,
     38                          const std::string& extension_id,
     39                          int location, int creation_flags);
     40   void OnUnpackWebResource(const std::string& resource_data);
     41   void OnParseUpdateManifest(const std::string& xml);
     42   void OnDecodeImage(const std::vector<unsigned char>& encoded_data);
     43   void OnDecodeImageBase64(const std::string& encoded_data);
     44   void OnRobustJPEGDecodeImage(
     45       const std::vector<unsigned char>& encoded_data);
     46   void OnParseJSON(const std::string& json);
     47 
     48 #if defined(OS_CHROMEOS)
     49   void OnCreateZipFile(const base::FilePath& src_dir,
     50                        const std::vector<base::FilePath>& src_relative_paths,
     51                        const base::FileDescriptor& dest_fd);
     52 #endif  // defined(OS_CHROMEOS)
     53 
     54   void OnPatchFileBsdiff(const base::FilePath& input_file,
     55                          const base::FilePath& patch_file,
     56                          const base::FilePath& output_file);
     57   void OnPatchFileCourgette(const base::FilePath& input_file,
     58                             const base::FilePath& patch_file,
     59                             const base::FilePath& output_file);
     60   void OnStartupPing();
     61   void OnAnalyzeZipFileForDownloadProtection(
     62       const IPC::PlatformFileForTransit& zip_file);
     63 #if !defined(OS_ANDROID) && !defined(OS_IOS)
     64   void OnCheckMediaFile(int64 milliseconds_of_decoding,
     65                         const IPC::PlatformFileForTransit& media_file);
     66   void OnParseMediaMetadata(const std::string& mime_type, int64 total_size,
     67                             bool get_attached_images);
     68 #endif  // !defined(OS_ANDROID) && !defined(OS_IOS)
     69 
     70 #if defined(OS_WIN)
     71   void OnParseITunesPrefXml(const std::string& itunes_xml_data);
     72 #endif  // defined(OS_WIN)
     73 
     74 #if defined(OS_MACOSX)
     75   void OnParseIPhotoLibraryXmlFile(
     76       const IPC::PlatformFileForTransit& iphoto_library_file);
     77 #endif  // defined(OS_MACOSX)
     78 
     79 #if defined(OS_WIN) || defined(OS_MACOSX)
     80   void OnParseITunesLibraryXmlFile(
     81       const IPC::PlatformFileForTransit& itunes_library_file);
     82 
     83   void OnParsePicasaPMPDatabase(
     84       const picasa::AlbumTableFilesForTransit& album_table_files);
     85 
     86   void OnIndexPicasaAlbumsContents(
     87       const picasa::AlbumUIDSet& album_uids,
     88       const std::vector<picasa::FolderINIContents>& folders_inis);
     89 #endif  // defined(OS_WIN) || defined(OS_MACOSX)
     90 
     91 #if defined(OS_WIN)
     92   void OnGetAndEncryptWiFiCredentials(const std::string& network_guid,
     93                                       const std::vector<uint8>& public_key);
     94 #endif  // defined(OS_WIN)
     95 
     96   typedef ScopedVector<UtilityMessageHandler> Handlers;
     97   Handlers handlers_;
     98 
     99   // Flag to enable whitelisting.
    100   bool filter_messages_;
    101   // A list of message_ids to filter.
    102   std::set<int> message_id_whitelist_;
    103 
    104   DISALLOW_COPY_AND_ASSIGN(ChromeContentUtilityClient);
    105 };
    106 
    107 #endif  // CHROME_UTILITY_CHROME_CONTENT_UTILITY_CLIENT_H_
    108