Home | History | Annotate | Download | only in ppapi_plugin
      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 CONTENT_PPAPI_PLUGIN_BROKER_PROCESS_DISPATCHER_H_
      6 #define CONTENT_PPAPI_PLUGIN_BROKER_PROCESS_DISPATCHER_H_
      7 
      8 #include "base/basictypes.h"
      9 #include "base/memory/weak_ptr.h"
     10 #include "content/child/scoped_child_process_reference.h"
     11 #include "ppapi/c/ppp.h"
     12 #include "ppapi/proxy/broker_dispatcher.h"
     13 #include "ppapi/shared_impl/ppp_flash_browser_operations_shared.h"
     14 
     15 namespace content {
     16 
     17 // Wrapper around a BrokerDispatcher that provides the necessary integration
     18 // for plugin process management. This class is to avoid direct dependencies
     19 // from the PPAPI proxy on the Chrome multiprocess infrastructure.
     20 class BrokerProcessDispatcher
     21     : public ppapi::proxy::BrokerSideDispatcher,
     22       public base::SupportsWeakPtr<BrokerProcessDispatcher> {
     23  public:
     24   BrokerProcessDispatcher(PP_GetInterface_Func get_plugin_interface,
     25                           PP_ConnectInstance_Func connect_instance);
     26   virtual ~BrokerProcessDispatcher();
     27 
     28   // IPC::Listener overrides.
     29   virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
     30 
     31   void OnGetPermissionSettingsCompleted(
     32       uint32 request_id,
     33       bool success,
     34       PP_Flash_BrowserOperations_Permission default_permission,
     35       const ppapi::FlashSiteSettings& sites);
     36 
     37  private:
     38   void OnGetSitesWithData(uint32 request_id,
     39                           const base::FilePath& plugin_data_path);
     40   void OnClearSiteData(uint32 request_id,
     41                        const base::FilePath& plugin_data_path,
     42                        const std::string& site,
     43                        uint64 flags,
     44                        uint64 max_age);
     45   void OnDeauthorizeContentLicenses(uint32 request_id,
     46                                     const base::FilePath& plugin_data_path);
     47   void OnGetPermissionSettings(
     48       uint32 request_id,
     49       const base::FilePath& plugin_data_path,
     50       PP_Flash_BrowserOperations_SettingType setting_type);
     51   void OnSetDefaultPermission(
     52       uint32 request_id,
     53       const base::FilePath& plugin_data_path,
     54       PP_Flash_BrowserOperations_SettingType setting_type,
     55       PP_Flash_BrowserOperations_Permission permission,
     56       bool clear_site_specific);
     57   void OnSetSitePermission(
     58       uint32 request_id,
     59       const base::FilePath& plugin_data_path,
     60       PP_Flash_BrowserOperations_SettingType setting_type,
     61       const ppapi::FlashSiteSettings& sites);
     62 
     63   // Returns a list of sites that have data stored.
     64   void GetSitesWithData(const base::FilePath& plugin_data_path,
     65                         std::vector<std::string>* sites);
     66 
     67   // Requests that the plugin clear data, returning true on success.
     68   bool ClearSiteData(const base::FilePath& plugin_data_path,
     69                      const std::string& site,
     70                      uint64 flags,
     71                      uint64 max_age);
     72 
     73   bool DeauthorizeContentLicenses(const base::FilePath& plugin_data_path);
     74   bool SetDefaultPermission(const base::FilePath& plugin_data_path,
     75                             PP_Flash_BrowserOperations_SettingType setting_type,
     76                             PP_Flash_BrowserOperations_Permission permission,
     77                             bool clear_site_specific);
     78   bool SetSitePermission(const base::FilePath& plugin_data_path,
     79                          PP_Flash_BrowserOperations_SettingType setting_type,
     80                          const ppapi::FlashSiteSettings& sites);
     81 
     82   ScopedChildProcessReference process_ref_;
     83 
     84   PP_GetInterface_Func get_plugin_interface_;
     85 
     86   const PPP_Flash_BrowserOperations_1_3* flash_browser_operations_1_3_;
     87   const PPP_Flash_BrowserOperations_1_2* flash_browser_operations_1_2_;
     88   const PPP_Flash_BrowserOperations_1_0* flash_browser_operations_1_0_;
     89 
     90   DISALLOW_COPY_AND_ASSIGN(BrokerProcessDispatcher);
     91 };
     92 
     93 }  // namespace content
     94 
     95 #endif  // CONTENT_PPAPI_PLUGIN_BROKER_PROCESS_DISPATCHER_H_
     96