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

Side by Side Diff: chrome/browser/ui/webui/site_settings_helper.h

Issue 2237823003: Site Settings Desktop: Implement USB devices section. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 4 years, 4 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_SITE_SETTINGS_HELPER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_SITE_SETTINGS_HELPER_H_
6 #define CHROME_BROWSER_UI_WEBUI_SITE_SETTINGS_HELPER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_SITE_SETTINGS_HELPER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
11 11
12 #include "components/content_settings/core/common/content_settings.h" 12 #include "components/content_settings/core/common/content_settings.h"
13 #include "components/content_settings/core/common/content_settings_pattern.h" 13 #include "components/content_settings/core/common/content_settings_pattern.h"
14 #include "components/content_settings/core/common/content_settings_types.h" 14 #include "components/content_settings/core/common/content_settings_types.h"
15 #include "content/public/browser/web_ui.h" 15 #include "content/public/browser/web_ui.h"
16 16
17 class ChooserContextBase;
17 class HostContentSettingsMap; 18 class HostContentSettingsMap;
19 class Profile;
18 20
19 namespace base { 21 namespace base {
20 class DictionaryValue; 22 class DictionaryValue;
21 class ListValue; 23 class ListValue;
22 } 24 }
23 25
24 namespace site_settings { 26 namespace site_settings {
25 27
26 // Maps from a secondary pattern to a setting. 28 // Maps from a secondary pattern to a setting.
27 typedef std::map<ContentSettingsPattern, ContentSetting> 29 typedef std::map<ContentSettingsPattern, ContentSetting>
28 OnePatternSettings; 30 OnePatternSettings;
29 // Maps from a primary pattern/source pair to a OnePatternSettings. All the 31 // Maps from a primary pattern/source pair to a OnePatternSettings. All the
30 // mappings in OnePatternSettings share the given primary pattern and source. 32 // mappings in OnePatternSettings share the given primary pattern and source.
31 typedef std::map<std::pair<ContentSettingsPattern, std::string>, 33 typedef std::map<std::pair<ContentSettingsPattern, std::string>,
32 OnePatternSettings> 34 OnePatternSettings>
33 AllPatternsSettings; 35 AllPatternsSettings;
34 36
35 extern const char kSetting[]; 37 extern const char kSetting[];
36 extern const char kOrigin[]; 38 extern const char kOrigin[];
37 extern const char kPolicyProviderId[]; 39 extern const char kPolicyProviderId[];
38 extern const char kSource[]; 40 extern const char kSource[];
39 extern const char kEmbeddingOrigin[]; 41 extern const char kEmbeddingOrigin[];
40 extern const char kPreferencesSource[]; 42 extern const char kPreferencesSource[];
41 43
44 // Group types.
45 extern const char kGroupTypeUsb[];
46
42 // Returns whether a group name has been registered for the given type. 47 // Returns whether a group name has been registered for the given type.
43 bool HasRegisteredGroupName(ContentSettingsType type); 48 bool HasRegisteredGroupName(ContentSettingsType type);
44 49
45 // Gets a content settings type from the group name identifier. 50 // Gets a content settings type from the group name identifier.
46 ContentSettingsType ContentSettingsTypeFromGroupName(const std::string& name); 51 ContentSettingsType ContentSettingsTypeFromGroupName(const std::string& name);
47 52
48 // Gets a string identifier for the group name. 53 // Gets a string identifier for the group name.
49 std::string ContentSettingsTypeToGroupName(ContentSettingsType type); 54 std::string ContentSettingsTypeToGroupName(ContentSettingsType type);
50 55
51 // Fills in |exceptions| with Values for the given |type| from |map|. 56 // Fills in |exceptions| with Values for the given |type| from |map|.
52 void GetExceptionsFromHostContentSettingsMap( 57 void GetExceptionsFromHostContentSettingsMap(
53 const HostContentSettingsMap* map, 58 const HostContentSettingsMap* map,
54 ContentSettingsType type, 59 ContentSettingsType type,
55 content::WebUI* web_ui, 60 content::WebUI* web_ui,
56 base::ListValue* exceptions); 61 base::ListValue* exceptions);
57 62
58 // Returns exceptions constructed from the policy-set allowed URLs 63 // Returns exceptions constructed from the policy-set allowed URLs
59 // for the content settings |type| mic or camera. 64 // for the content settings |type| mic or camera.
60 void GetPolicyAllowedUrls( 65 void GetPolicyAllowedUrls(
61 ContentSettingsType type, 66 ContentSettingsType type,
62 std::vector<std::unique_ptr<base::DictionaryValue>>* exceptions, 67 std::vector<std::unique_ptr<base::DictionaryValue>>* exceptions,
63 content::WebUI* web_ui); 68 content::WebUI* web_ui);
64 69
70 // This struct facilitates lookup of a chooser context factory function by name
71 // for a given content settings type and is declared early so that it can used
72 // by functions below.
73 struct ChooserTypeNameEntry {
74 ContentSettingsType type;
75 ChooserContextBase* (*get_context)(Profile*);
76 const char* name;
77 const char* ui_name_key;
78 };
79
80 ChooserContextBase* GetUsbChooserContext(Profile* profile);
81
82 struct ContentSettingsTypeNameEntry {
83 ContentSettingsType type;
84 const char* name;
85 };
86
87 const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = {
88 {CONTENT_SETTINGS_TYPE_COOKIES, "cookies"},
89 {CONTENT_SETTINGS_TYPE_IMAGES, "images"},
90 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, "javascript"},
91 {CONTENT_SETTINGS_TYPE_PLUGINS, "plugins"},
92 {CONTENT_SETTINGS_TYPE_POPUPS, "popups"},
93 {CONTENT_SETTINGS_TYPE_GEOLOCATION, "location"},
94 {CONTENT_SETTINGS_TYPE_NOTIFICATIONS, "notifications"},
95 {CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, "auto-select-certificate"},
96 {CONTENT_SETTINGS_TYPE_FULLSCREEN, "fullscreen"},
97 {CONTENT_SETTINGS_TYPE_MOUSELOCK, "mouselock"},
98 {CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, "register-protocol-handler"},
99 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, "media-stream-mic"},
100 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, "media-stream-camera"},
101 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, "ppapi-broker"},
102 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, "multiple-automatic-downloads"},
103 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, "midi-sysex"},
104 {CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, "ssl-cert-decisions"},
105 #if defined(OS_CHROMEOS)
106 {CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, "protectedContent"},
107 #endif
108 {CONTENT_SETTINGS_TYPE_KEYGEN, "keygen"},
109 {CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, "background-sync"},
110 };
111
112 const ChooserTypeNameEntry kChooserTypeGroupNames[] = {
113 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext,
114 kGroupTypeUsb, "name"},
115 };
116
117 const ChooserTypeNameEntry* ChooserTypeFromGroupName(const std::string& name);
118
119 // Fills in |exceptions| with Values for the given |chooser_type| from map.
120 void GetChooserExceptionsFromProfile(
121 Profile* profile,
122 bool incognito,
123 const ChooserTypeNameEntry& chooser_type,
124 base::ListValue* exceptions);
125
65 } // namespace site_settings 126 } // namespace site_settings
66 127
67 #endif // CHROME_BROWSER_UI_WEBUI_SITE_SETTINGS_HELPER_H_ 128 #endif // CHROME_BROWSER_UI_WEBUI_SITE_SETTINGS_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/site_settings_handler.cc ('k') | chrome/browser/ui/webui/site_settings_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698