Give names to all utility processes.
[chromium-blink-merge.git] / chrome / browser / pepper_flash_settings_manager.h
blobee92fc588d2035d65e7ba5b4b5fcbe0b3a76fe07
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"
14 class PluginPrefs;
15 class PrefService;
17 namespace content {
18 class BrowserContext;
19 struct WebPluginInfo;
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 {
29 public:
30 class Client {
31 public:
32 virtual ~Client() {}
34 virtual void OnDeauthorizeContentLicensesCompleted(uint32 request_id,
35 bool success) {}
36 virtual void OnGetPermissionSettingsCompleted(
37 uint32 request_id,
38 bool success,
39 PP_Flash_BrowserOperations_Permission default_permission,
40 const ppapi::FlashSiteSettings& sites) {}
42 virtual void OnSetDefaultPermissionCompleted(uint32 request_id,
43 bool success) {}
45 virtual void OnSetSitePermissionCompleted(uint32 request_id,
46 bool success) {}
48 virtual void OnGetSitesWithDataCompleted(
49 uint32 request_id,
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
62 // true.
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
91 // is completed.
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
97 // completed.
98 uint32 GetSitesWithData();
100 // Clears data for a certain site.
101 // Client::OnClearSiteDataompleted() will be called when the operation is
102 // completed.
103 uint32 ClearSiteData(const std::string& site, uint64 flags, uint64 max_age);
105 private:
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.
112 class Core;
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.
122 Client* client_;
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_