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

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

Issue 2021343003: MD Site Settings: Add five new top level categories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback and add icons Created 4 years, 6 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 #include "chrome/browser/ui/webui/site_settings_helper.h" 5 #include "chrome/browser/ui/webui/site_settings_helper.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
11 #include "components/content_settings/core/browser/host_content_settings_map.h" 11 #include "components/content_settings/core/browser/host_content_settings_map.h"
12 #include "components/prefs/pref_service.h" 12 #include "components/prefs/pref_service.h"
13 13
14 namespace site_settings { 14 namespace site_settings {
15 15
16 const char kSetting[] = "setting"; 16 const char kSetting[] = "setting";
17 const char kOrigin[] = "origin"; 17 const char kOrigin[] = "origin";
18 const char kPolicyProviderId[] = "policy"; 18 const char kPolicyProviderId[] = "policy";
19 const char kSource[] = "source"; 19 const char kSource[] = "source";
20 const char kEmbeddingOrigin[] = "embeddingOrigin"; 20 const char kEmbeddingOrigin[] = "embeddingOrigin";
21 const char kPreferencesSource[] = "preference"; 21 const char kPreferencesSource[] = "preference";
22 22
23 struct ContentSettingsTypeNameEntry {
24 ContentSettingsType type;
25 const char* name;
26 };
27
28 const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = {
29 {CONTENT_SETTINGS_TYPE_COOKIES, "cookies"},
30 {CONTENT_SETTINGS_TYPE_IMAGES, "images"},
31 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, "javascript"},
32 {CONTENT_SETTINGS_TYPE_PLUGINS, "plugins"},
33 {CONTENT_SETTINGS_TYPE_POPUPS, "popups"},
34 {CONTENT_SETTINGS_TYPE_GEOLOCATION, "location"},
35 {CONTENT_SETTINGS_TYPE_NOTIFICATIONS, "notifications"},
36 {CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, "auto-select-certificate"},
37 {CONTENT_SETTINGS_TYPE_FULLSCREEN, "fullscreen"},
38 {CONTENT_SETTINGS_TYPE_MOUSELOCK, "mouselock"},
39 {CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, "register-protocol-handler"},
40 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, "media-stream-mic"},
41 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, "media-stream-camera"},
42 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, "ppapi-broker"},
43 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, "multiple-automatic-downloads"},
44 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, "midi-sysex"},
45 {CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, "push-messaging"},
46 {CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, "ssl-cert-decisions"},
47 #if defined(OS_CHROMEOS)
48 {CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, "protectedContent"},
49 #endif
50 {CONTENT_SETTINGS_TYPE_KEYGEN, "keygen"},
51 {CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, "background-sync"},
52 };
53
54 ContentSettingsType ContentSettingsTypeFromGroupName(const std::string& name) {
55 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) {
56 if (name == kContentSettingsTypeGroupNames[i].name)
57 return kContentSettingsTypeGroupNames[i].type;
58 }
59
60 NOTREACHED() << name << " is not a recognized content settings type.";
61 return CONTENT_SETTINGS_TYPE_DEFAULT;
62 }
63
64 std::string ContentSettingsTypeToGroupName(ContentSettingsType type) {
65 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) {
66 if (type == kContentSettingsTypeGroupNames[i].type)
67 return kContentSettingsTypeGroupNames[i].name;
68 }
69
70 NOTREACHED();
71 return std::string();
72 }
73
23 // Create a DictionaryValue* that will act as a data source for a single row 74 // Create a DictionaryValue* that will act as a data source for a single row
24 // in a HostContentSettingsMap-controlled exceptions table (e.g., cookies). 75 // in a HostContentSettingsMap-controlled exceptions table (e.g., cookies).
25 std::unique_ptr<base::DictionaryValue> GetExceptionForPage( 76 std::unique_ptr<base::DictionaryValue> GetExceptionForPage(
26 const ContentSettingsPattern& pattern, 77 const ContentSettingsPattern& pattern,
27 const ContentSettingsPattern& secondary_pattern, 78 const ContentSettingsPattern& secondary_pattern,
28 const ContentSetting& setting, 79 const ContentSetting& setting,
29 const std::string& provider_name) { 80 const std::string& provider_name) {
30 base::DictionaryValue* exception = new base::DictionaryValue(); 81 base::DictionaryValue* exception = new base::DictionaryValue();
31 exception->SetString(kOrigin, pattern.ToString()); 82 exception->SetString(kOrigin, pattern.ToString());
32 exception->SetString(kEmbeddingOrigin, 83 exception->SetString(kEmbeddingOrigin,
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 patterns.begin(), patterns.end(), std::greater<ContentSettingsPattern>()); 219 patterns.begin(), patterns.end(), std::greater<ContentSettingsPattern>());
169 220
170 for (const ContentSettingsPattern& pattern : patterns) { 221 for (const ContentSettingsPattern& pattern : patterns) {
171 exceptions->push_back(GetExceptionForPage(pattern, ContentSettingsPattern(), 222 exceptions->push_back(GetExceptionForPage(pattern, ContentSettingsPattern(),
172 CONTENT_SETTING_ALLOW, 223 CONTENT_SETTING_ALLOW,
173 kPolicyProviderId)); 224 kPolicyProviderId));
174 } 225 }
175 } 226 }
176 227
177 } // namespace site_settings 228 } // namespace site_settings
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/site_settings_helper.h ('k') | chrome/test/data/webui/settings/site_details_permission_tests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698