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

Side by Side Diff: chrome/browser/content_settings/content_settings_utils.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/content_settings/content_settings_utils.h" 5 #include "chrome/browser/content_settings/content_settings_utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 ContentSettingsType* return_setting) { 69 ContentSettingsType* return_setting) {
70 for (size_t type = 0; type < CONTENT_SETTINGS_NUM_TYPES; ++type) { 70 for (size_t type = 0; type < CONTENT_SETTINGS_NUM_TYPES; ++type) {
71 if (name.compare(kTypeNames[type]) == 0) { 71 if (name.compare(kTypeNames[type]) == 0) {
72 *return_setting = static_cast<ContentSettingsType>(type); 72 *return_setting = static_cast<ContentSettingsType>(type);
73 return true; 73 return true;
74 } 74 }
75 } 75 }
76 return false; 76 return false;
77 } 77 }
78 78
79 std::string ContentSettingToString(ContentSetting setting) {
80 switch (setting) {
81 case CONTENT_SETTING_ALLOW:
82 return "allow";
83 case CONTENT_SETTING_ASK:
84 return "ask";
85 case CONTENT_SETTING_BLOCK:
86 return "block";
87 case CONTENT_SETTING_SESSION_ONLY:
88 return "session";
89 case CONTENT_SETTING_DEFAULT:
90 return "default";
91 case CONTENT_SETTING_NUM_SETTINGS:
92 NOTREACHED();
93 }
94
95 return std::string();
96 }
97
98 ContentSetting ContentSettingFromString(const std::string& name) {
99 if (name == "allow")
100 return CONTENT_SETTING_ALLOW;
101 if (name == "ask")
102 return CONTENT_SETTING_ASK;
103 if (name == "block")
104 return CONTENT_SETTING_BLOCK;
105 if (name == "session")
106 return CONTENT_SETTING_SESSION_ONLY;
107
108 NOTREACHED() << name << " is not a recognized content setting.";
109 return CONTENT_SETTING_DEFAULT;
110 }
111
79 std::string CreatePatternString( 112 std::string CreatePatternString(
80 const ContentSettingsPattern& item_pattern, 113 const ContentSettingsPattern& item_pattern,
81 const ContentSettingsPattern& top_level_frame_pattern) { 114 const ContentSettingsPattern& top_level_frame_pattern) {
82 return item_pattern.ToString() 115 return item_pattern.ToString()
83 + std::string(kPatternSeparator) 116 + std::string(kPatternSeparator)
84 + top_level_frame_pattern.ToString(); 117 + top_level_frame_pattern.ToString();
85 } 118 }
86 119
87 PatternPair ParsePatternString(const std::string& pattern_str) { 120 PatternPair ParsePatternString(const std::string& pattern_str) {
88 std::vector<std::string> pattern_str_list; 121 std::vector<std::string> pattern_str_list;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 243
211 void GetRendererContentSettingRules(const HostContentSettingsMap* map, 244 void GetRendererContentSettingRules(const HostContentSettingsMap* map,
212 RendererContentSettingRules* rules) { 245 RendererContentSettingRules* rules) {
213 map->GetSettingsForOneType( 246 map->GetSettingsForOneType(
214 CONTENT_SETTINGS_TYPE_IMAGES, std::string(), &(rules->image_rules)); 247 CONTENT_SETTINGS_TYPE_IMAGES, std::string(), &(rules->image_rules));
215 map->GetSettingsForOneType( 248 map->GetSettingsForOneType(
216 CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string(), &(rules->script_rules)); 249 CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string(), &(rules->script_rules));
217 } 250 }
218 251
219 } // namespace content_settings 252 } // namespace content_settings
OLDNEW
« no previous file with comments | « chrome/browser/content_settings/content_settings_utils.h ('k') | chrome/browser/content_settings/host_content_settings_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698