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