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