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

Side by Side Diff: chrome/browser/ui/webui/options/content_settings_handler.cc

Issue 475193002: Add a single site view page to view and modify content settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 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 (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 #include "chrome/browser/ui/webui/options/content_settings_handler.h" 5 #include "chrome/browser/ui/webui/options/content_settings_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "extensions/common/permissions/permissions_data.h" 49 #include "extensions/common/permissions/permissions_data.h"
50 #include "grit/generated_resources.h" 50 #include "grit/generated_resources.h"
51 #include "grit/locale_settings.h" 51 #include "grit/locale_settings.h"
52 #include "ui/base/l10n/l10n_util.h" 52 #include "ui/base/l10n/l10n_util.h"
53 53
54 #if defined(OS_CHROMEOS) 54 #if defined(OS_CHROMEOS)
55 #include "components/user_manager/user_manager.h" 55 #include "components/user_manager/user_manager.h"
56 #endif 56 #endif
57 57
58 using base::UserMetricsAction; 58 using base::UserMetricsAction;
59 using content_settings::ContentSettingToString;
60 using content_settings::ContentSettingFromString;
59 using extensions::APIPermission; 61 using extensions::APIPermission;
60 62
61 namespace { 63 namespace {
62 64
63 struct ContentSettingsTypeNameEntry { 65 struct ContentSettingsTypeNameEntry {
64 ContentSettingsType type; 66 ContentSettingsType type;
65 const char* name; 67 const char* name;
66 }; 68 };
67 69
68 // Maps from a secondary pattern to a setting. 70 // Maps from a secondary pattern to a setting.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 ContentSettingsType ContentSettingsTypeFromGroupName(const std::string& name) { 130 ContentSettingsType ContentSettingsTypeFromGroupName(const std::string& name) {
129 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) { 131 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) {
130 if (name == kContentSettingsTypeGroupNames[i].name) 132 if (name == kContentSettingsTypeGroupNames[i].name)
131 return kContentSettingsTypeGroupNames[i].type; 133 return kContentSettingsTypeGroupNames[i].type;
132 } 134 }
133 135
134 NOTREACHED() << name << " is not a recognized content settings type."; 136 NOTREACHED() << name << " is not a recognized content settings type.";
135 return CONTENT_SETTINGS_TYPE_DEFAULT; 137 return CONTENT_SETTINGS_TYPE_DEFAULT;
136 } 138 }
137 139
138 std::string ContentSettingToString(ContentSetting setting) {
139 switch (setting) {
140 case CONTENT_SETTING_ALLOW:
141 return "allow";
142 case CONTENT_SETTING_ASK:
143 return "ask";
144 case CONTENT_SETTING_BLOCK:
145 return "block";
146 case CONTENT_SETTING_SESSION_ONLY:
147 return "session";
148 case CONTENT_SETTING_DEFAULT:
149 return "default";
150 case CONTENT_SETTING_NUM_SETTINGS:
151 NOTREACHED();
152 }
153
154 return std::string();
155 }
156
157 ContentSetting ContentSettingFromString(const std::string& name) {
158 if (name == "allow")
159 return CONTENT_SETTING_ALLOW;
160 if (name == "ask")
161 return CONTENT_SETTING_ASK;
162 if (name == "block")
163 return CONTENT_SETTING_BLOCK;
164 if (name == "session")
165 return CONTENT_SETTING_SESSION_ONLY;
166
167 NOTREACHED() << name << " is not a recognized content setting.";
168 return CONTENT_SETTING_DEFAULT;
169 }
170
171 // Create a DictionaryValue* that will act as a data source for a single row 140 // Create a DictionaryValue* that will act as a data source for a single row
172 // in a HostContentSettingsMap-controlled exceptions table (e.g., cookies). 141 // in a HostContentSettingsMap-controlled exceptions table (e.g., cookies).
173 // Ownership of the pointer is passed to the caller. 142 // Ownership of the pointer is passed to the caller.
174 base::DictionaryValue* GetExceptionForPage( 143 base::DictionaryValue* GetExceptionForPage(
175 const ContentSettingsPattern& pattern, 144 const ContentSettingsPattern& pattern,
176 const ContentSettingsPattern& secondary_pattern, 145 const ContentSettingsPattern& secondary_pattern,
177 const ContentSetting& setting, 146 const ContentSetting& setting,
178 const std::string& provider_name) { 147 const std::string& provider_name) {
179 base::DictionaryValue* exception = new base::DictionaryValue(); 148 base::DictionaryValue* exception = new base::DictionaryValue();
180 exception->SetString(kOrigin, pattern.ToString()); 149 exception->SetString(kOrigin, pattern.ToString());
(...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { 1536 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() {
1568 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 1537 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
1569 // Exceptions apply only when the feature is enabled. 1538 // Exceptions apply only when the feature is enabled.
1570 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); 1539 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM);
1571 web_ui()->CallJavascriptFunction( 1540 web_ui()->CallJavascriptFunction(
1572 "ContentSettings.enableProtectedContentExceptions", 1541 "ContentSettings.enableProtectedContentExceptions",
1573 base::FundamentalValue(enable_exceptions)); 1542 base::FundamentalValue(enable_exceptions));
1574 } 1543 }
1575 1544
1576 } // namespace options 1545 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/website_settings/website_settings.cc ('k') | chrome/browser/ui/webui/options/website_settings_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698