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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "ppapi/c/private/ppp_flash_browser_operations.h" | |
12 #include "ppapi/shared_impl/ppp_flash_browser_operations_shared.h" | |
13 | 11 |
14 class PluginPrefs; | 12 class PluginPrefs; |
15 class PrefService; | 13 class PrefService; |
16 | 14 |
17 namespace content { | 15 namespace content { |
18 class BrowserContext; | 16 class BrowserContext; |
19 } | 17 } |
20 | 18 |
21 namespace webkit { | 19 namespace webkit { |
22 struct WebPluginInfo; | 20 struct WebPluginInfo; |
23 } | 21 } |
24 | 22 |
25 // PepperFlashSettingsManager communicates with a PPAPI broker process to | 23 // PepperFlashSettingsManager communicates with a PPAPI broker process to |
26 // read/write Pepper Flash settings. | 24 // read/write Pepper Flash settings. |
27 class PepperFlashSettingsManager { | 25 class PepperFlashSettingsManager { |
28 public: | 26 public: |
29 class Client { | 27 class Client { |
30 public: | 28 public: |
31 virtual ~Client() {} | 29 virtual ~Client() {} |
32 | 30 |
33 virtual void OnDeauthorizeContentLicensesCompleted(uint32 request_id, | 31 virtual void OnDeauthorizeContentLicensesCompleted(uint32 request_id, |
34 bool success) {} | 32 bool success) = 0; |
35 virtual void OnGetPermissionSettingsCompleted( | |
36 uint32 request_id, | |
37 bool success, | |
38 PP_Flash_BrowserOperations_Permission default_permission, | |
39 const ppapi::FlashSiteSettings& sites) {} | |
40 | |
41 virtual void OnSetDefaultPermissionCompleted(uint32 request_id, | |
42 bool success) {} | |
43 | |
44 virtual void OnSetSitePermissionCompleted(uint32 request_id, | |
45 bool success) {} | |
46 }; | 33 }; |
47 | 34 |
48 // |client| must outlive this object. It is guaranteed that |client| won't | 35 // |client| must outlive this object. It is guaranteed that |client| won't |
49 // receive any notifications after this object goes away. | 36 // receive any notifications after this object goes away. |
50 PepperFlashSettingsManager(Client* client, | 37 PepperFlashSettingsManager(Client* client, |
51 content::BrowserContext* browser_context); | 38 content::BrowserContext* browser_context); |
52 ~PepperFlashSettingsManager(); | 39 ~PepperFlashSettingsManager(); |
53 | 40 |
54 // |plugin_info| will be updated if it is not NULL and the method returns | 41 // |plugin_info| will be updated if it is not NULL and the method returns |
55 // true. | 42 // true. |
56 static bool IsPepperFlashInUse(PluginPrefs* plugin_prefs, | 43 static bool IsPepperFlashInUse(PluginPrefs* plugin_prefs, |
57 webkit::WebPluginInfo* plugin_info); | 44 webkit::WebPluginInfo* plugin_info); |
58 | 45 |
59 static void RegisterUserPrefs(PrefService* prefs); | 46 static void RegisterUserPrefs(PrefService* prefs); |
60 | 47 |
61 // Requests to deauthorize content licenses. | 48 // Requests to deauthorize content licenses. |
62 // Client::OnDeauthorizeContentLicensesCompleted() will be called when the | 49 // Client::OnDeauthorizeContentLicensesCompleted() will be called when the |
63 // operation is completed. | 50 // operation is completed. |
64 // The return value is the same as the request ID passed into | 51 // The return value is the same as the request ID passed into |
65 // Client::OnDeauthorizeContentLicensesCompleted(). | 52 // Client::OnDeauthorizeContentLicensesCompleted(). |
66 uint32 DeauthorizeContentLicenses(); | 53 uint32 DeauthorizeContentLicenses(); |
67 | 54 |
68 // Gets permission settings. | |
69 // Client::OnGetPermissionSettingsCompleted() will be called when the | |
70 // operation is completed. | |
71 uint32 GetPermissionSettings( | |
72 PP_Flash_BrowserOperations_SettingType setting_type); | |
73 | |
74 // Sets default permission. | |
75 // Client::OnSetDefaultPermissionCompleted() will be called when the | |
76 // operation is completed. | |
77 uint32 SetDefaultPermission( | |
78 PP_Flash_BrowserOperations_SettingType setting_type, | |
79 PP_Flash_BrowserOperations_Permission permission, | |
80 bool clear_site_specific); | |
81 | |
82 // Sets site-specific permission. | |
83 // Client::OnSetSitePermissionCompleted() will be called when the operation | |
84 // is completed. | |
85 uint32 SetSitePermission(PP_Flash_BrowserOperations_SettingType setting_type, | |
86 const ppapi::FlashSiteSettings& sites); | |
87 | |
88 private: | 55 private: |
89 // Core does most of the work. It is ref-counted so that its lifespan can be | 56 // Core does most of the work. It is ref-counted so that its lifespan can be |
90 // independent of the containing object's: | 57 // independent of the containing object's: |
91 // - The manager can be deleted on the UI thread while the core still being | 58 // - The manager can be deleted on the UI thread while the core still being |
92 // used on the I/O thread. | 59 // used on the I/O thread. |
93 // - The manager can delete the core when it encounters errors and create | 60 // - The manager can delete the core when it encounters errors and create |
94 // another one to handle new requests. | 61 // another one to handle new requests. |
95 class Core; | 62 class Core; |
96 | 63 |
97 uint32 GetNextRequestId(); | 64 uint32 GetNextRequestId(); |
(...skipping 10 matching lines...) Expand all Loading... |
108 content::BrowserContext* browser_context_; | 75 content::BrowserContext* browser_context_; |
109 | 76 |
110 scoped_refptr<Core> core_; | 77 scoped_refptr<Core> core_; |
111 | 78 |
112 uint32 next_request_id_; | 79 uint32 next_request_id_; |
113 | 80 |
114 DISALLOW_COPY_AND_ASSIGN(PepperFlashSettingsManager); | 81 DISALLOW_COPY_AND_ASSIGN(PepperFlashSettingsManager); |
115 }; | 82 }; |
116 | 83 |
117 #endif // CHROME_BROWSER_PEPPER_FLASH_SETTINGS_MANAGER_H_ | 84 #endif // CHROME_BROWSER_PEPPER_FLASH_SETTINGS_MANAGER_H_ |
OLD | NEW |