OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_PEPPER_FLASH_SETTINGS_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_PEPPER_FLASH_SETTINGS_MANAGER_H_ |
6 #define CHROME_BROWSER_PEPPER_FLASH_SETTINGS_MANAGER_H_ | 6 #define CHROME_BROWSER_PEPPER_FLASH_SETTINGS_MANAGER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include <stdint.h> |
| 9 |
| 10 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
10 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
11 #include "ppapi/c/private/ppp_flash_browser_operations.h" | 13 #include "ppapi/c/private/ppp_flash_browser_operations.h" |
12 #include "ppapi/shared_impl/ppp_flash_browser_operations_shared.h" | 14 #include "ppapi/shared_impl/ppp_flash_browser_operations_shared.h" |
13 | 15 |
14 class PluginPrefs; | 16 class PluginPrefs; |
15 class PrefService; | 17 class PrefService; |
16 | 18 |
17 namespace content { | 19 namespace content { |
18 class BrowserContext; | 20 class BrowserContext; |
19 struct WebPluginInfo; | 21 struct WebPluginInfo; |
20 } | 22 } |
21 | 23 |
22 namespace user_prefs { | 24 namespace user_prefs { |
23 class PrefRegistrySyncable; | 25 class PrefRegistrySyncable; |
24 } | 26 } |
25 | 27 |
26 // PepperFlashSettingsManager communicates with a PPAPI broker process to | 28 // PepperFlashSettingsManager communicates with a PPAPI broker process to |
27 // read/write Pepper Flash settings. | 29 // read/write Pepper Flash settings. |
28 class PepperFlashSettingsManager { | 30 class PepperFlashSettingsManager { |
29 public: | 31 public: |
30 class Client { | 32 class Client { |
31 public: | 33 public: |
32 virtual ~Client() {} | 34 virtual ~Client() {} |
33 | 35 |
34 virtual void OnDeauthorizeContentLicensesCompleted(uint32 request_id, | 36 virtual void OnDeauthorizeContentLicensesCompleted(uint32_t request_id, |
35 bool success) {} | 37 bool success) {} |
36 virtual void OnGetPermissionSettingsCompleted( | 38 virtual void OnGetPermissionSettingsCompleted( |
37 uint32 request_id, | 39 uint32_t request_id, |
38 bool success, | 40 bool success, |
39 PP_Flash_BrowserOperations_Permission default_permission, | 41 PP_Flash_BrowserOperations_Permission default_permission, |
40 const ppapi::FlashSiteSettings& sites) {} | 42 const ppapi::FlashSiteSettings& sites) {} |
41 | 43 |
42 virtual void OnSetDefaultPermissionCompleted(uint32 request_id, | 44 virtual void OnSetDefaultPermissionCompleted(uint32_t request_id, |
43 bool success) {} | 45 bool success) {} |
44 | 46 |
45 virtual void OnSetSitePermissionCompleted(uint32 request_id, | 47 virtual void OnSetSitePermissionCompleted(uint32_t request_id, |
46 bool success) {} | 48 bool success) {} |
47 | 49 |
48 virtual void OnGetSitesWithDataCompleted( | 50 virtual void OnGetSitesWithDataCompleted( |
49 uint32 request_id, | 51 uint32_t request_id, |
50 const std::vector<std::string>& sites) {} | 52 const std::vector<std::string>& sites) {} |
51 | 53 |
52 virtual void OnClearSiteDataCompleted(uint32 request_id, bool success) {} | 54 virtual void OnClearSiteDataCompleted(uint32_t request_id, bool success) {} |
53 }; | 55 }; |
54 | 56 |
55 // |client| must outlive this object. It is guaranteed that |client| won't | 57 // |client| must outlive this object. It is guaranteed that |client| won't |
56 // receive any notifications after this object goes away. | 58 // receive any notifications after this object goes away. |
57 PepperFlashSettingsManager(Client* client, | 59 PepperFlashSettingsManager(Client* client, |
58 content::BrowserContext* browser_context); | 60 content::BrowserContext* browser_context); |
59 ~PepperFlashSettingsManager(); | 61 ~PepperFlashSettingsManager(); |
60 | 62 |
61 // |plugin_info| will be updated if it is not NULL and the method returns | 63 // |plugin_info| will be updated if it is not NULL and the method returns |
62 // true. | 64 // true. |
63 static bool IsPepperFlashInUse(PluginPrefs* plugin_prefs, | 65 static bool IsPepperFlashInUse(PluginPrefs* plugin_prefs, |
64 content::WebPluginInfo* plugin_info); | 66 content::WebPluginInfo* plugin_info); |
65 | 67 |
66 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 68 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
67 | 69 |
68 // Requests to deauthorize content licenses. | 70 // Requests to deauthorize content licenses. |
69 // Client::OnDeauthorizeContentLicensesCompleted() will be called when the | 71 // Client::OnDeauthorizeContentLicensesCompleted() will be called when the |
70 // operation is completed. | 72 // operation is completed. |
71 // The return value is the same as the request ID passed into | 73 // The return value is the same as the request ID passed into |
72 // Client::OnDeauthorizeContentLicensesCompleted(). | 74 // Client::OnDeauthorizeContentLicensesCompleted(). |
73 uint32 DeauthorizeContentLicenses(PrefService* prefs); | 75 uint32_t DeauthorizeContentLicenses(PrefService* prefs); |
74 | 76 |
75 // Gets permission settings. | 77 // Gets permission settings. |
76 // Client::OnGetPermissionSettingsCompleted() will be called when the | 78 // Client::OnGetPermissionSettingsCompleted() will be called when the |
77 // operation is completed. | 79 // operation is completed. |
78 uint32 GetPermissionSettings( | 80 uint32_t GetPermissionSettings( |
79 PP_Flash_BrowserOperations_SettingType setting_type); | 81 PP_Flash_BrowserOperations_SettingType setting_type); |
80 | 82 |
81 // Sets default permission. | 83 // Sets default permission. |
82 // Client::OnSetDefaultPermissionCompleted() will be called when the | 84 // Client::OnSetDefaultPermissionCompleted() will be called when the |
83 // operation is completed. | 85 // operation is completed. |
84 uint32 SetDefaultPermission( | 86 uint32_t SetDefaultPermission( |
85 PP_Flash_BrowserOperations_SettingType setting_type, | 87 PP_Flash_BrowserOperations_SettingType setting_type, |
86 PP_Flash_BrowserOperations_Permission permission, | 88 PP_Flash_BrowserOperations_Permission permission, |
87 bool clear_site_specific); | 89 bool clear_site_specific); |
88 | 90 |
89 // Sets site-specific permission. | 91 // Sets site-specific permission. |
90 // Client::OnSetSitePermissionCompleted() will be called when the operation | 92 // Client::OnSetSitePermissionCompleted() will be called when the operation |
91 // is completed. | 93 // is completed. |
92 uint32 SetSitePermission(PP_Flash_BrowserOperations_SettingType setting_type, | 94 uint32_t SetSitePermission( |
93 const ppapi::FlashSiteSettings& sites); | 95 PP_Flash_BrowserOperations_SettingType setting_type, |
| 96 const ppapi::FlashSiteSettings& sites); |
94 | 97 |
95 // Gets a list of sites that have stored data. | 98 // Gets a list of sites that have stored data. |
96 // Client::OnGetSitesWithDataCompleted() will be called when the operation is | 99 // Client::OnGetSitesWithDataCompleted() will be called when the operation is |
97 // completed. | 100 // completed. |
98 uint32 GetSitesWithData(); | 101 uint32_t GetSitesWithData(); |
99 | 102 |
100 // Clears data for a certain site. | 103 // Clears data for a certain site. |
101 // Client::OnClearSiteDataompleted() will be called when the operation is | 104 // Client::OnClearSiteDataompleted() will be called when the operation is |
102 // completed. | 105 // completed. |
103 uint32 ClearSiteData(const std::string& site, uint64 flags, uint64 max_age); | 106 uint32_t ClearSiteData(const std::string& site, |
| 107 uint64_t flags, |
| 108 uint64_t max_age); |
104 | 109 |
105 private: | 110 private: |
106 // Core does most of the work. It is ref-counted so that its lifespan can be | 111 // Core does most of the work. It is ref-counted so that its lifespan can be |
107 // independent of the containing object's: | 112 // independent of the containing object's: |
108 // - The manager can be deleted on the UI thread while the core still being | 113 // - The manager can be deleted on the UI thread while the core still being |
109 // used on the I/O thread. | 114 // used on the I/O thread. |
110 // - The manager can delete the core when it encounters errors and create | 115 // - The manager can delete the core when it encounters errors and create |
111 // another one to handle new requests. | 116 // another one to handle new requests. |
112 class Core; | 117 class Core; |
113 | 118 |
114 uint32 GetNextRequestId(); | 119 uint32_t GetNextRequestId(); |
115 | 120 |
116 void EnsureCoreExists(); | 121 void EnsureCoreExists(); |
117 | 122 |
118 // Notifies us that an error occurred in |core|. | 123 // Notifies us that an error occurred in |core|. |
119 void OnError(Core* core); | 124 void OnError(Core* core); |
120 | 125 |
121 // |client_| is not owned by this object and must outlive it. | 126 // |client_| is not owned by this object and must outlive it. |
122 Client* client_; | 127 Client* client_; |
123 | 128 |
124 // The browser context for the profile. | 129 // The browser context for the profile. |
125 content::BrowserContext* browser_context_; | 130 content::BrowserContext* browser_context_; |
126 | 131 |
127 scoped_refptr<Core> core_; | 132 scoped_refptr<Core> core_; |
128 | 133 |
129 uint32 next_request_id_; | 134 uint32_t next_request_id_; |
130 | 135 |
131 base::WeakPtrFactory<PepperFlashSettingsManager> weak_ptr_factory_; | 136 base::WeakPtrFactory<PepperFlashSettingsManager> weak_ptr_factory_; |
132 | 137 |
133 DISALLOW_COPY_AND_ASSIGN(PepperFlashSettingsManager); | 138 DISALLOW_COPY_AND_ASSIGN(PepperFlashSettingsManager); |
134 }; | 139 }; |
135 | 140 |
136 #endif // CHROME_BROWSER_PEPPER_FLASH_SETTINGS_MANAGER_H_ | 141 #endif // CHROME_BROWSER_PEPPER_FLASH_SETTINGS_MANAGER_H_ |
OLD | NEW |