Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: chrome/browser/ui/webui/options2/content_settings_handler2.h

Issue 10698140: Remove "2" suffixes from options2 code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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_UI_WEBUI_OPTIONS2_CONTENT_SETTINGS_HANDLER2_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_CONTENT_SETTINGS_HANDLER2_H_
7 #pragma once
8
9 #include <map>
10 #include <string>
11
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/pepper_flash_settings_manager.h"
14 #include "chrome/browser/prefs/pref_change_registrar.h"
15 #include "chrome/browser/ui/webui/options2/options_ui2.h"
16 #include "chrome/common/content_settings_types.h"
17 #include "chrome/common/content_settings.h"
18 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h"
20
21 class HostContentSettingsMap;
22 class ProtocolHandlerRegistry;
23
24 namespace options2 {
25
26 class ContentSettingsHandler : public OptionsPageUIHandler,
27 public PepperFlashSettingsManager::Client {
28 public:
29 ContentSettingsHandler();
30 virtual ~ContentSettingsHandler();
31
32 // OptionsPageUIHandler implementation.
33 virtual void GetLocalizedValues(
34 base::DictionaryValue* localized_strings) OVERRIDE;
35 virtual void InitializeHandler() OVERRIDE;
36 virtual void InitializePage() OVERRIDE;
37 virtual void RegisterMessages() OVERRIDE;
38
39 // content::NotificationObserver implementation.
40 virtual void Observe(int type,
41 const content::NotificationSource& source,
42 const content::NotificationDetails& details) OVERRIDE;
43
44 // PepperFlashSettingsManager::Client implementation.
45 virtual void OnGetPermissionSettingsCompleted(
46 uint32 request_id,
47 bool success,
48 PP_Flash_BrowserOperations_Permission default_permission,
49 const ppapi::FlashSiteSettings& sites) OVERRIDE;
50
51 // Gets a string identifier for the group name, for use in HTML.
52 static std::string ContentSettingsTypeToGroupName(ContentSettingsType type);
53
54 private:
55 // Extends ContentSettingsType with some other types that will be also
56 // displayed in the content settings UI.
57 class ExContentSettingsType;
58 struct ExContentSettingsTypeNameEntry;
59
60 struct CachedPepperFlashSettings {
61 CachedPepperFlashSettings();
62 ~CachedPepperFlashSettings();
63
64 PP_Flash_BrowserOperations_Permission default_permission;
65
66 typedef std::map<std::string, PP_Flash_BrowserOperations_Permission>
67 SiteMap;
68 SiteMap sites;
69
70 bool initialized;
71 uint32_t last_refresh_request_id;
72 };
73
74 // Functions that call into the page -----------------------------------------
75
76 // Updates the page with the default settings (allow, ask, block, etc.)
77 void UpdateSettingDefaultFromModel(const ExContentSettingsType& type);
78
79 // Clobbers and rebuilds the specific content setting type exceptions table.
80 void UpdateExceptionsViewFromModel(const ExContentSettingsType& type);
81 // Clobbers and rebuilds the specific content setting type exceptions
82 // OTR table.
83 void UpdateOTRExceptionsViewFromModel(
84 const ExContentSettingsType& type);
85 // Clobbers and rebuilds all the exceptions tables in the page (both normal
86 // and OTR tables).
87 void UpdateAllExceptionsViewsFromModel();
88 // As above, but only OTR tables.
89 void UpdateAllOTRExceptionsViewsFromModel();
90 // Clobbers and rebuilds just the geolocation exception table.
91 void UpdateGeolocationExceptionsView();
92 // Clobbers and rebuilds just the desktop notification exception table.
93 void UpdateNotificationExceptionsView();
94 // Clobbers and rebuilds just the Pepper Flash camera and microphone exception
95 // table.
96 void UpdateFlashCameraMicExceptionsView();
97 // Clobbers and rebuilds just the Media Stream device exception table.
98 void UpdateMediaStreamExceptionsView();
99 // Clobbers and rebuilds an exception table that's managed by the host content
100 // settings map.
101 void UpdateExceptionsViewFromHostContentSettingsMap(ContentSettingsType type);
102 // As above, but acts on the OTR table for the content setting type.
103 void UpdateExceptionsViewFromOTRHostContentSettingsMap(
104 ContentSettingsType type);
105 // Updates the radio buttons for enabling / disabling handlers.
106 void UpdateHandlersEnabledRadios();
107 // Removes one geolocation exception.
108 void RemoveGeolocationException(const base::ListValue* args,
109 size_t arg_index);
110 // Removes one notification exception.
111 void RemoveNotificationException(const base::ListValue* args,
112 size_t arg_index);
113 // Removes one Pepper Flash camera and microphone exception.
114 void RemoveFlashCameraMicException(const base::ListValue* args,
115 size_t arg_index);
116 // Removes one exception of |type| from the host content settings map.
117 void RemoveExceptionFromHostContentSettingsMap(
118 const base::ListValue* args,
119 size_t arg_index,
120 const ExContentSettingsType& type);
121
122 // Callbacks used by the page ------------------------------------------------
123
124 // Sets the default value for a specific content type. |args| includes the
125 // content type and a string describing the new default the user has
126 // chosen.
127 void SetContentFilter(const base::ListValue* args);
128
129 // Removes the given row from the table. The first entry in |args| is the
130 // content type, and the rest of the arguments depend on the content type
131 // to be removed.
132 void RemoveException(const base::ListValue* args);
133
134 // Changes the value of an exception. Called after the user is done editing an
135 // exception.
136 void SetException(const base::ListValue* args);
137
138 // Called to decide whether a given pattern is valid, or if it should be
139 // rejected. Called while the user is editing an exception pattern.
140 void CheckExceptionPatternValidity(const base::ListValue* args);
141
142 // Utility functions ---------------------------------------------------------
143
144 // Applies content settings whitelists to reduce breakage / user confusion.
145 void ApplyWhitelist(ContentSettingsType content_type,
146 ContentSetting default_setting);
147
148 // Gets the HostContentSettingsMap for the normal profile.
149 HostContentSettingsMap* GetContentSettingsMap();
150
151 // Gets the HostContentSettingsMap for the incognito profile, or NULL if there
152 // is no active incognito session.
153 HostContentSettingsMap* GetOTRContentSettingsMap();
154
155 // Gets the default setting in string form. If |provider_id| is not NULL, the
156 // id of the provider which provided the default setting is assigned to it.
157 std::string GetSettingDefaultFromModel(const ExContentSettingsType& type,
158 std::string* provider_id);
159
160 // Gets the ProtocolHandlerRegistry for the normal profile.
161 ProtocolHandlerRegistry* GetProtocolHandlerRegistry();
162
163 // The method does nothing if |force| is false and the cache has been
164 // initialized.
165 void RefreshFlashSettingsCache(bool force);
166
167 static ExContentSettingsType ExContentSettingsTypeFromGroupName(
168 const std::string& name);
169 static std::string ExContentSettingsTypeToGroupName(
170 const ExContentSettingsType& type);
171
172 // Member variables ---------------------------------------------------------
173
174 content::NotificationRegistrar notification_registrar_;
175 PrefChangeRegistrar pref_change_registrar_;
176 scoped_ptr<PepperFlashSettingsManager> flash_settings_manager_;
177 CachedPepperFlashSettings flash_cameramic_settings_;
178
179 static const ExContentSettingsTypeNameEntry
180 kExContentSettingsTypeGroupNames[];
181
182 DISALLOW_COPY_AND_ASSIGN(ContentSettingsHandler);
183 };
184
185 } // namespace options2
186
187 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_CONTENT_SETTINGS_HANDLER2_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698