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_UI_WEBUI_OPTIONS2_CONTENT_SETTINGS_HANDLER2_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_CONTENT_SETTINGS_HANDLER2_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_CONTENT_SETTINGS_HANDLER2_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_CONTENT_SETTINGS_HANDLER2_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include "chrome/browser/plugin_data_remover_helper.h" |
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" | 10 #include "chrome/browser/prefs/pref_change_registrar.h" |
15 #include "chrome/browser/ui/webui/options2/options_ui2.h" | 11 #include "chrome/browser/ui/webui/options2/options_ui2.h" |
16 #include "chrome/common/content_settings_types.h" | 12 #include "chrome/common/content_settings_types.h" |
17 #include "chrome/common/content_settings.h" | 13 #include "chrome/common/content_settings.h" |
18 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
19 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
20 | 16 |
21 class HostContentSettingsMap; | 17 class HostContentSettingsMap; |
22 class ProtocolHandlerRegistry; | 18 class ProtocolHandlerRegistry; |
23 | 19 |
24 namespace options2 { | 20 namespace options2 { |
25 | 21 |
26 class ContentSettingsHandler : public OptionsPageUIHandler, | 22 class ContentSettingsHandler : public OptionsPageUIHandler { |
27 public PepperFlashSettingsManager::Client { | |
28 public: | 23 public: |
29 ContentSettingsHandler(); | 24 ContentSettingsHandler(); |
30 virtual ~ContentSettingsHandler(); | 25 virtual ~ContentSettingsHandler(); |
31 | 26 |
32 // OptionsPageUIHandler implementation. | 27 // OptionsPageUIHandler implementation. |
33 virtual void GetLocalizedValues(DictionaryValue* localized_strings) OVERRIDE; | 28 virtual void GetLocalizedValues(DictionaryValue* localized_strings) OVERRIDE; |
34 virtual void InitializeHandler() OVERRIDE; | 29 virtual void InitializeHandler() OVERRIDE; |
35 virtual void InitializePage() OVERRIDE; | 30 virtual void InitializePage() OVERRIDE; |
36 virtual void RegisterMessages() OVERRIDE; | 31 virtual void RegisterMessages() OVERRIDE; |
37 | 32 |
38 // content::NotificationObserver implementation. | 33 // content::NotificationObserver implementation. |
39 virtual void Observe(int type, | 34 virtual void Observe(int type, |
40 const content::NotificationSource& source, | 35 const content::NotificationSource& source, |
41 const content::NotificationDetails& details) OVERRIDE; | 36 const content::NotificationDetails& details) OVERRIDE; |
42 | 37 |
43 // PepperFlashSettingsManager::Client implementation. | |
44 virtual void OnGetPermissionSettingsCompleted( | |
45 uint32 request_id, | |
46 bool success, | |
47 PP_Flash_BrowserOperations_Permission default_permission, | |
48 const ppapi::FlashSiteSettings& sites) OVERRIDE; | |
49 | |
50 // Gets a string identifier for the group name, for use in HTML. | 38 // Gets a string identifier for the group name, for use in HTML. |
51 static std::string ContentSettingsTypeToGroupName(ContentSettingsType type); | 39 static std::string ContentSettingsTypeToGroupName(ContentSettingsType type); |
52 | 40 |
53 private: | 41 private: |
54 // Extends ContentSettingsType with some other types that will be also | |
55 // displayed in the content settings UI. | |
56 class ExContentSettingsType; | |
57 struct ExContentSettingsTypeNameEntry; | |
58 | |
59 struct CachedPepperFlashSettings { | |
60 CachedPepperFlashSettings(); | |
61 ~CachedPepperFlashSettings(); | |
62 | |
63 PP_Flash_BrowserOperations_Permission default_permission; | |
64 | |
65 typedef std::map<std::string, PP_Flash_BrowserOperations_Permission> | |
66 SiteMap; | |
67 SiteMap sites; | |
68 | |
69 bool initialized; | |
70 }; | |
71 | |
72 // Functions that call into the page ----------------------------------------- | 42 // Functions that call into the page ----------------------------------------- |
73 | 43 |
74 // Updates the page with the default settings (allow, ask, block, etc.) | 44 // Updates the page with the default settings (allow, ask, block, etc.) |
75 void UpdateSettingDefaultFromModel(const ExContentSettingsType& type); | 45 void UpdateSettingDefaultFromModel(ContentSettingsType type); |
76 | 46 |
77 // Clobbers and rebuilds the specific content setting type exceptions table. | 47 // Clobbers and rebuilds the specific content setting type exceptions table. |
78 void UpdateExceptionsViewFromModel(const ExContentSettingsType& type); | 48 void UpdateExceptionsViewFromModel(ContentSettingsType type); |
79 // Clobbers and rebuilds the specific content setting type exceptions | 49 // Clobbers and rebuilds the specific content setting type exceptions |
80 // OTR table. | 50 // OTR table. |
81 void UpdateOTRExceptionsViewFromModel( | 51 void UpdateOTRExceptionsViewFromModel(ContentSettingsType type); |
82 const ExContentSettingsType& type); | |
83 // Clobbers and rebuilds all the exceptions tables in the page (both normal | 52 // Clobbers and rebuilds all the exceptions tables in the page (both normal |
84 // and OTR tables). | 53 // and OTR tables). |
85 void UpdateAllExceptionsViewsFromModel(); | 54 void UpdateAllExceptionsViewsFromModel(); |
86 // As above, but only OTR tables. | 55 // As above, but only OTR tables. |
87 void UpdateAllOTRExceptionsViewsFromModel(); | 56 void UpdateAllOTRExceptionsViewsFromModel(); |
88 // Clobbers and rebuilds just the geolocation exception table. | 57 // Clobbers and rebuilds just the geolocation exception table. |
89 void UpdateGeolocationExceptionsView(); | 58 void UpdateGeolocationExceptionsView(); |
90 // Clobbers and rebuilds just the desktop notification exception table. | 59 // Clobbers and rebuilds just the desktop notification exception table. |
91 void UpdateNotificationExceptionsView(); | 60 void UpdateNotificationExceptionsView(); |
92 // Clobbers and rebuilds just the Pepper Flash camera and microphone exception | |
93 // table. | |
94 void UpdateFlashCameraMicExceptionsView(); | |
95 // Clobbers and rebuilds an exception table that's managed by the host content | 61 // Clobbers and rebuilds an exception table that's managed by the host content |
96 // settings map. | 62 // settings map. |
97 void UpdateExceptionsViewFromHostContentSettingsMap(ContentSettingsType type); | 63 void UpdateExceptionsViewFromHostContentSettingsMap(ContentSettingsType type); |
98 // As above, but acts on the OTR table for the content setting type. | 64 // As above, but acts on the OTR table for the content setting type. |
99 void UpdateExceptionsViewFromOTRHostContentSettingsMap( | 65 void UpdateExceptionsViewFromOTRHostContentSettingsMap( |
100 ContentSettingsType type); | 66 ContentSettingsType type); |
101 // Updates the radio buttons for enabling / disabling handlers. | 67 // Updates the radio buttons for enabling / disabling handlers. |
102 void UpdateHandlersEnabledRadios(); | 68 void UpdateHandlersEnabledRadios(); |
103 | 69 |
104 // Callbacks used by the page ------------------------------------------------ | 70 // Callbacks used by the page ------------------------------------------------ |
(...skipping 24 matching lines...) Expand all Loading... |
129 | 95 |
130 // Gets the HostContentSettingsMap for the normal profile. | 96 // Gets the HostContentSettingsMap for the normal profile. |
131 HostContentSettingsMap* GetContentSettingsMap(); | 97 HostContentSettingsMap* GetContentSettingsMap(); |
132 | 98 |
133 // Gets the HostContentSettingsMap for the incognito profile, or NULL if there | 99 // Gets the HostContentSettingsMap for the incognito profile, or NULL if there |
134 // is no active incognito session. | 100 // is no active incognito session. |
135 HostContentSettingsMap* GetOTRContentSettingsMap(); | 101 HostContentSettingsMap* GetOTRContentSettingsMap(); |
136 | 102 |
137 // Gets the default setting in string form. If |provider_id| is not NULL, the | 103 // Gets the default setting in string form. If |provider_id| is not NULL, the |
138 // id of the provider which provided the default setting is assigned to it. | 104 // id of the provider which provided the default setting is assigned to it. |
139 std::string GetSettingDefaultFromModel(const ExContentSettingsType& type, | 105 std::string GetSettingDefaultFromModel(ContentSettingsType type, |
140 std::string* provider_id); | 106 std::string* provider_id); |
141 | 107 |
142 // Gets the ProtocolHandlerRegistry for the normal profile. | 108 // Gets the ProtocolHandlerRegistry for the normal profile. |
143 ProtocolHandlerRegistry* GetProtocolHandlerRegistry(); | 109 ProtocolHandlerRegistry* GetProtocolHandlerRegistry(); |
144 | 110 |
145 static ExContentSettingsType ExContentSettingsTypeFromGroupName( | |
146 const std::string& name); | |
147 static std::string ExContentSettingsTypeToGroupName( | |
148 const ExContentSettingsType& type); | |
149 | |
150 // Member variables --------------------------------------------------------- | 111 // Member variables --------------------------------------------------------- |
151 | 112 |
152 content::NotificationRegistrar notification_registrar_; | 113 content::NotificationRegistrar notification_registrar_; |
153 PrefChangeRegistrar pref_change_registrar_; | 114 PrefChangeRegistrar pref_change_registrar_; |
154 scoped_ptr<PepperFlashSettingsManager> flash_settings_manager_; | |
155 CachedPepperFlashSettings flash_cameramic_settings_; | |
156 | |
157 static const ExContentSettingsTypeNameEntry | |
158 kExContentSettingsTypeGroupNames[]; | |
159 | 115 |
160 DISALLOW_COPY_AND_ASSIGN(ContentSettingsHandler); | 116 DISALLOW_COPY_AND_ASSIGN(ContentSettingsHandler); |
161 }; | 117 }; |
162 | 118 |
163 } // namespace options2 | 119 } // namespace options2 |
164 | 120 |
165 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_CONTENT_SETTINGS_HANDLER2_H_ | 121 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_CONTENT_SETTINGS_HANDLER2_H_ |
OLD | NEW |