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_
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
11 #include "ppapi/c/private/ppp_flash_browser_operations.h"
12 #include "ppapi/shared_impl/ppp_flash_browser_operations_shared.h"
22 namespace user_prefs
{
23 class PrefRegistrySyncable
;
26 // PepperFlashSettingsManager communicates with a PPAPI broker process to
27 // read/write Pepper Flash settings.
28 class PepperFlashSettingsManager
{
34 virtual void OnDeauthorizeContentLicensesCompleted(uint32 request_id
,
36 virtual void OnGetPermissionSettingsCompleted(
39 PP_Flash_BrowserOperations_Permission default_permission
,
40 const ppapi::FlashSiteSettings
& sites
) {}
42 virtual void OnSetDefaultPermissionCompleted(uint32 request_id
,
45 virtual void OnSetSitePermissionCompleted(uint32 request_id
,
48 virtual void OnGetSitesWithDataCompleted(
50 const std::vector
<std::string
>& sites
) {}
52 virtual void OnClearSiteDataCompleted(uint32 request_id
, bool success
) {}
55 // |client| must outlive this object. It is guaranteed that |client| won't
56 // receive any notifications after this object goes away.
57 PepperFlashSettingsManager(Client
* client
,
58 content::BrowserContext
* browser_context
);
59 ~PepperFlashSettingsManager();
61 // |plugin_info| will be updated if it is not NULL and the method returns
63 static bool IsPepperFlashInUse(PluginPrefs
* plugin_prefs
,
64 content::WebPluginInfo
* plugin_info
);
66 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
);
68 // Requests to deauthorize content licenses.
69 // Client::OnDeauthorizeContentLicensesCompleted() will be called when the
70 // operation is completed.
71 // The return value is the same as the request ID passed into
72 // Client::OnDeauthorizeContentLicensesCompleted().
73 uint32
DeauthorizeContentLicenses(PrefService
* prefs
);
75 // Gets permission settings.
76 // Client::OnGetPermissionSettingsCompleted() will be called when the
77 // operation is completed.
78 uint32
GetPermissionSettings(
79 PP_Flash_BrowserOperations_SettingType setting_type
);
81 // Sets default permission.
82 // Client::OnSetDefaultPermissionCompleted() will be called when the
83 // operation is completed.
84 uint32
SetDefaultPermission(
85 PP_Flash_BrowserOperations_SettingType setting_type
,
86 PP_Flash_BrowserOperations_Permission permission
,
87 bool clear_site_specific
);
89 // Sets site-specific permission.
90 // Client::OnSetSitePermissionCompleted() will be called when the operation
92 uint32
SetSitePermission(PP_Flash_BrowserOperations_SettingType setting_type
,
93 const ppapi::FlashSiteSettings
& sites
);
95 // Gets a list of sites that have stored data.
96 // Client::OnGetSitesWithDataCompleted() will be called when the operation is
98 uint32
GetSitesWithData();
100 // Clears data for a certain site.
101 // Client::OnClearSiteDataompleted() will be called when the operation is
103 uint32
ClearSiteData(const std::string
& site
, uint64 flags
, uint64 max_age
);
106 // Core does most of the work. It is ref-counted so that its lifespan can be
107 // independent of the containing object's:
108 // - The manager can be deleted on the UI thread while the core still being
109 // used on the I/O thread.
110 // - The manager can delete the core when it encounters errors and create
111 // another one to handle new requests.
114 uint32
GetNextRequestId();
116 void EnsureCoreExists();
118 // Notifies us that an error occurred in |core|.
119 void OnError(Core
* core
);
121 // |client_| is not owned by this object and must outlive it.
124 // The browser context for the profile.
125 content::BrowserContext
* browser_context_
;
127 scoped_refptr
<Core
> core_
;
129 uint32 next_request_id_
;
131 base::WeakPtrFactory
<PepperFlashSettingsManager
> weak_ptr_factory_
;
133 DISALLOW_COPY_AND_ASSIGN(PepperFlashSettingsManager
);
136 #endif // CHROME_BROWSER_PEPPER_FLASH_SETTINGS_MANAGER_H_