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.
5 #ifndef CHROME_BROWSER_PEPPER_FLASH_SETTINGS_MANAGER_H_
6 #define CHROME_BROWSER_PEPPER_FLASH_SETTINGS_MANAGER_H_
10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "ppapi/c/private/ppp_flash_browser_operations.h"
14 #include "ppapi/shared_impl/ppp_flash_browser_operations_shared.h"
24 namespace user_prefs {
25 class PrefRegistrySyncable;
28 // PepperFlashSettingsManager communicates with a PPAPI broker process to
29 // read/write Pepper Flash settings.
30 class PepperFlashSettingsManager {
36 virtual void OnDeauthorizeFlashContentLicensesCompleted(uint32_t request_id,
38 virtual void OnGetPermissionSettingsCompleted(
41 PP_Flash_BrowserOperations_Permission default_permission,
42 const ppapi::FlashSiteSettings& sites) {}
44 virtual void OnSetDefaultPermissionCompleted(uint32_t request_id,
47 virtual void OnSetSitePermissionCompleted(uint32_t request_id,
50 virtual void OnGetSitesWithDataCompleted(
52 const std::vector<std::string>& sites) {}
54 virtual void OnClearSiteDataCompleted(uint32_t request_id, bool success) {}
57 // |client| must outlive this object. It is guaranteed that |client| won't
58 // receive any notifications after this object goes away.
59 PepperFlashSettingsManager(Client* client,
60 content::BrowserContext* browser_context);
61 ~PepperFlashSettingsManager();
63 // |plugin_info| will be updated if it is not NULL and the method returns
65 static bool IsPepperFlashInUse(PluginPrefs* plugin_prefs,
66 content::WebPluginInfo* plugin_info);
68 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
70 // Requests to deauthorize content licenses.
71 // Client::OnDeauthorizeFlashContentLicensesCompleted() will be called when
72 // the operation is completed.
73 // The return value is the same as the request ID passed into
74 // Client::OnDeauthorizeFlashContentLicensesCompleted().
75 uint32_t DeauthorizeContentLicenses(PrefService* prefs);
77 // Gets permission settings.
78 // Client::OnGetPermissionSettingsCompleted() will be called when the
79 // operation is completed.
80 uint32_t GetPermissionSettings(
81 PP_Flash_BrowserOperations_SettingType setting_type);
83 // Sets default permission.
84 // Client::OnSetDefaultPermissionCompleted() will be called when the
85 // operation is completed.
86 uint32_t SetDefaultPermission(
87 PP_Flash_BrowserOperations_SettingType setting_type,
88 PP_Flash_BrowserOperations_Permission permission,
89 bool clear_site_specific);
91 // Sets site-specific permission.
92 // Client::OnSetSitePermissionCompleted() will be called when the operation
94 uint32_t SetSitePermission(
95 PP_Flash_BrowserOperations_SettingType setting_type,
96 const ppapi::FlashSiteSettings& sites);
98 // Gets a list of sites that have stored data.
99 // Client::OnGetSitesWithDataCompleted() will be called when the operation is
101 uint32_t GetSitesWithData();
103 // Clears data for a certain site.
104 // Client::OnClearSiteDataompleted() will be called when the operation is
106 uint32_t ClearSiteData(const std::string& site,
111 // Core does most of the work. It is ref-counted so that its lifespan can be
112 // independent of the containing object's:
113 // - The manager can be deleted on the UI thread while the core still being
114 // used on the I/O thread.
115 // - The manager can delete the core when it encounters errors and create
116 // another one to handle new requests.
119 uint32_t GetNextRequestId();
121 void EnsureCoreExists();
123 // Notifies us that an error occurred in |core|.
124 void OnError(Core* core);
126 // |client_| is not owned by this object and must outlive it.
129 // The browser context for the profile.
130 content::BrowserContext* browser_context_;
132 scoped_refptr<Core> core_;
134 uint32_t next_request_id_;
136 base::WeakPtrFactory<PepperFlashSettingsManager> weak_ptr_factory_{this};
138 DISALLOW_COPY_AND_ASSIGN(PepperFlashSettingsManager);
141 #endif // CHROME_BROWSER_PEPPER_FLASH_SETTINGS_MANAGER_H_