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