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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
// 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_UI_WEBUI_OPTIONS_CONTENT_SETTINGS_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_OPTIONS_CONTENT_SETTINGS_HANDLER_H_
#include <stdint.h>
#include <string>
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/scoped_observer.h"
#include "base/values.h"
#include "chrome/browser/pepper_flash_settings_manager.h"
#include "chrome/browser/ui/webui/options/options_ui.h"
#include "chrome/browser/ui/webui/options/pepper_flash_content_settings_utils.h"
#include "components/content_settings/core/browser/content_settings_observer.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/prefs/pref_change_registrar.h"
#include "content/public/browser/host_zoom_map.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
class HostContentSettingsMap;
class ProtocolHandlerRegistry;
namespace options {
class ContentSettingsHandler : public OptionsPageUIHandler,
public content_settings::Observer,
public content::NotificationObserver,
public PepperFlashSettingsManager::Client {
public:
struct ChooserTypeNameEntry;
ContentSettingsHandler();
~ContentSettingsHandler() override;
// OptionsPageUIHandler implementation.
void GetLocalizedValues(base::DictionaryValue* localized_strings) override;
void InitializeHandler() override;
void InitializePage() override;
void RegisterMessages() override;
// content_settings::Observer implementation.
void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
std::string resource_identifier) override;
// content::NotificationObserver implementation.
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
// PepperFlashSettingsManager::Client implementation.
void OnGetPermissionSettingsCompleted(
uint32_t request_id,
bool success,
PP_Flash_BrowserOperations_Permission default_permission,
const ppapi::FlashSiteSettings& sites) override;
// Gets a string identifier for the group name, for use in HTML.
static std::string ContentSettingsTypeToGroupName(ContentSettingsType type);
private:
// Used to determine whether we should show links to Flash camera and
// microphone settings.
class MediaSettingsInfo {
public:
MediaSettingsInfo();
~MediaSettingsInfo();
// Cached Pepper Flash settings.
struct ForFlash {
ForFlash();
~ForFlash();
ContentSetting default_setting;
MediaExceptions exceptions;
bool initialized;
uint32_t last_refresh_request_id;
};
struct ForOneType {
ForOneType();
~ForOneType();
// Whether the links to Flash settings pages are showed.
bool show_flash_default_link;
bool show_flash_exceptions_link;
// Cached Chrome media settings.
ContentSetting default_setting;
bool policy_disable;
bool default_setting_initialized;
MediaExceptions exceptions;
bool exceptions_initialized;
};
ForOneType& forType(ContentSettingsType type);
ForFlash& forFlash();
private:
ForOneType mic_settings_;
ForOneType camera_settings_;
ForFlash flash_settings_;
DISALLOW_COPY_AND_ASSIGN(MediaSettingsInfo);
};
// Used by ShowFlashMediaLink() to specify which link to show/hide.
enum LinkType {
DEFAULT_SETTING = 0,
EXCEPTIONS,
};
// Functions that call into the page -----------------------------------------
// Updates the page with the default settings (allow, ask, block, etc.)
void UpdateSettingDefaultFromModel(ContentSettingsType type);
// Compares the microphone or camera |type| default settings with Flash
// and updates the Flash links' visibility accordingly.
void UpdateMediaSettingsFromPrefs(ContentSettingsType type);
// Clobbers and rebuilds the specific content setting type exceptions table.
void UpdateExceptionsViewFromModel(ContentSettingsType type);
// Clobbers and rebuilds the specific content setting type exceptions
// OTR table.
void UpdateOTRExceptionsViewFromModel(ContentSettingsType type);
// Clobbers and rebuilds all the exceptions tables in the page (both normal
// and OTR tables).
void UpdateAllExceptionsViewsFromModel();
// As above, but only OTR tables.
void UpdateAllOTRExceptionsViewsFromModel();
// Clobbers and rebuilds just the geolocation exception table.
void UpdateGeolocationExceptionsView();
// Clobbers and rebuilds just the desktop notification exception table.
void UpdateNotificationExceptionsView();
// Compares the exceptions of the camera or microphone |type| with its Flash
// counterparts and updates the Flash links' visibility accordingly.
void CompareMediaExceptionsWithFlash(ContentSettingsType type);
// Clobbers and rebuilds just the MIDI SysEx exception table.
void UpdateMIDISysExExceptionsView();
// Clobbers and rebuilds all chooser-based exception tables.
void UpdateAllChooserExceptionsViewsFromModel();
// As above, but only OTR tables.
void UpdateAllOTRChooserExceptionsViewsFromModel();
// Clobbers and rebuilds the exception table for a particular chooser-based
// permission.
void UpdateChooserExceptionsViewFromModel(
const ChooserTypeNameEntry& chooser_type);
// As above, but only OTR tables.
void UpdateOTRChooserExceptionsViewFromModel(
const ChooserTypeNameEntry& chooser_type);
// Modifies the zoom level exceptions list to display correct chrome
// signin page entry. When the legacy (non-WebView-based) signin page
// goes away, this function can be removed.
void AdjustZoomLevelsListForSigninPageIfNecessary(
content::HostZoomMap::ZoomLevelVector* zoom_levels);
// Clobbers and rebuilds just the zoom levels exception table.
void UpdateZoomLevelsExceptionsView();
// Clobbers and rebuilds an exception table that's managed by the host content
// settings map.
void UpdateExceptionsViewFromHostContentSettingsMap(ContentSettingsType type);
// As above, but acts on the OTR table for the content setting type.
void UpdateExceptionsViewFromOTRHostContentSettingsMap(
ContentSettingsType type);
// Updates the radio buttons for enabling / disabling handlers.
void UpdateHandlersEnabledRadios();
// Removes one geolocation exception. |args| contains the parameters passed to
// RemoveException().
void RemoveGeolocationException(const base::ListValue* args);
// Removes one notification exception. |args| contains the parameters passed
// to RemoveException().
void RemoveNotificationException(const base::ListValue* args);
// Removes one exception of |type| from the host content settings map. |args|
// contains the parameters passed to RemoveException().
void RemoveExceptionFromHostContentSettingsMap(
const base::ListValue* args,
ContentSettingsType type);
// Removes one zoom level exception. |args| contains the parameters passed to
// RemoveException().
void RemoveZoomLevelException(const base::ListValue* args);
// Removes one exception for a chooser-based permission. |args| contains the
// parameters passed to RemoveException().
void RemoveChooserException(const ChooserTypeNameEntry* chooser_type,
const base::ListValue* args);
// Callbacks used by the page ------------------------------------------------
// Sets the default value for a specific content type. |args| includes the
// content type and a string describing the new default the user has
// chosen.
void SetContentFilter(const base::ListValue* args);
// Removes the given row from the table. The first entry in |args| is the
// content type, and the rest of the arguments depend on the content type
// to be removed.
void RemoveException(const base::ListValue* args);
// Changes the value of an exception. Called after the user is done editing an
// exception.
void SetException(const base::ListValue* args);
// Called to decide whether a given pattern is valid, or if it should be
// rejected. Called while the user is editing an exception pattern.
void CheckExceptionPatternValidity(const base::ListValue* args);
// Utility functions ---------------------------------------------------------
// Applies content settings whitelists to reduce breakage / user confusion.
void ApplyWhitelist(ContentSettingsType content_type,
ContentSetting default_setting);
// Gets the HostContentSettingsMap for the normal profile.
HostContentSettingsMap* GetContentSettingsMap();
// Gets the HostContentSettingsMap for the incognito profile, or NULL if there
// is no active incognito session.
HostContentSettingsMap* GetOTRContentSettingsMap();
// Gets the ProtocolHandlerRegistry for the normal profile.
ProtocolHandlerRegistry* GetProtocolHandlerRegistry();
void RefreshFlashMediaSettings();
// Fills in |exceptions| with Values for the given |type| from |map|.
void GetChooserExceptionsFromProfile(bool incognito,
const ChooserTypeNameEntry& type,
base::ListValue* exceptions);
void OnPepperFlashPrefChanged();
// content::HostZoomMap subscription.
void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change);
void ShowFlashMediaLink(
LinkType link_type, ContentSettingsType content_type, bool show);
void UpdateFlashMediaLinksVisibility(ContentSettingsType type);
void UpdateMediaDeviceDropdownVisibility(ContentSettingsType type);
void UpdateProtectedContentExceptionsButton();
// Member variables ---------------------------------------------------------
content::NotificationRegistrar notification_registrar_;
PrefChangeRegistrar pref_change_registrar_;
scoped_ptr<PepperFlashSettingsManager> flash_settings_manager_;
scoped_ptr<MediaSettingsInfo> media_settings_;
scoped_ptr<content::HostZoomMap::Subscription> host_zoom_map_subscription_;
scoped_ptr<content::HostZoomMap::Subscription>
signin_host_zoom_map_subscription_;
ScopedObserver<HostContentSettingsMap, content_settings::Observer> observer_;
DISALLOW_COPY_AND_ASSIGN(ContentSettingsHandler);
};
} // namespace options
#endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CONTENT_SETTINGS_HANDLER_H_
|