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"
25 // PepperFlashSettingsManager communicates with a PPAPI broker process to
26 // read/write Pepper Flash settings.
27 class PepperFlashSettingsManager
{
33 virtual void OnDeauthorizeContentLicensesCompleted(uint32 request_id
,
35 virtual void OnGetPermissionSettingsCompleted(
38 PP_Flash_BrowserOperations_Permission default_permission
,
39 const ppapi::FlashSiteSettings
& sites
) {}
41 virtual void OnSetDefaultPermissionCompleted(uint32 request_id
,
44 virtual void OnSetSitePermissionCompleted(uint32 request_id
,
47 virtual void OnGetSitesWithDataCompleted(
49 const std::vector
<std::string
>& sites
) {}
51 virtual void OnClearSiteDataCompleted(uint32 request_id
, bool success
) {}
54 // |client| must outlive this object. It is guaranteed that |client| won't
55 // receive any notifications after this object goes away.
56 PepperFlashSettingsManager(Client
* client
,
57 content::BrowserContext
* browser_context
);
58 ~PepperFlashSettingsManager();
60 // |plugin_info| will be updated if it is not NULL and the method returns
62 static bool IsPepperFlashInUse(PluginPrefs
* plugin_prefs
,
63 webkit::WebPluginInfo
* plugin_info
);
65 static void RegisterUserPrefs(PrefService
* prefs
);
67 // Requests to deauthorize content licenses.
68 // Client::OnDeauthorizeContentLicensesCompleted() will be called when the
69 // operation is completed.
70 // The return value is the same as the request ID passed into
71 // Client::OnDeauthorizeContentLicensesCompleted().
72 uint32
DeauthorizeContentLicenses();
74 // Gets permission settings.
75 // Client::OnGetPermissionSettingsCompleted() will be called when the
76 // operation is completed.
77 uint32
GetPermissionSettings(
78 PP_Flash_BrowserOperations_SettingType setting_type
);
80 // Sets default permission.
81 // Client::OnSetDefaultPermissionCompleted() will be called when the
82 // operation is completed.
83 uint32
SetDefaultPermission(
84 PP_Flash_BrowserOperations_SettingType setting_type
,
85 PP_Flash_BrowserOperations_Permission permission
,
86 bool clear_site_specific
);
88 // Sets site-specific permission.
89 // Client::OnSetSitePermissionCompleted() will be called when the operation
91 uint32
SetSitePermission(PP_Flash_BrowserOperations_SettingType setting_type
,
92 const ppapi::FlashSiteSettings
& sites
);
94 // Gets a list of sites that have stored data.
95 // Client::OnGetSitesWithDataCompleted() will be called when the operation is
97 uint32
GetSitesWithData();
99 // Clears data for a certain site.
100 // Client::OnClearSiteDataompleted() will be called when the operation is
102 uint32
ClearSiteData(const std::string
& site
, uint64 flags
, uint64 max_age
);
105 // Core does most of the work. It is ref-counted so that its lifespan can be
106 // independent of the containing object's:
107 // - The manager can be deleted on the UI thread while the core still being
108 // used on the I/O thread.
109 // - The manager can delete the core when it encounters errors and create
110 // another one to handle new requests.
113 uint32
GetNextRequestId();
115 void EnsureCoreExists();
117 // Notifies us that an error occurred in |core|.
118 void OnError(Core
* core
);
120 base::WeakPtrFactory
<PepperFlashSettingsManager
> weak_ptr_factory_
;
122 // |client_| is not owned by this object and must outlive it.
125 // The browser context for the profile.
126 content::BrowserContext
* browser_context_
;
128 scoped_refptr
<Core
> core_
;
130 uint32 next_request_id_
;
132 DISALLOW_COPY_AND_ASSIGN(PepperFlashSettingsManager
);
135 #endif // CHROME_BROWSER_PEPPER_FLASH_SETTINGS_MANAGER_H_