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

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

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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 | Annotate | Revision Log
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 <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 case CONTENT_SETTING_BLOCK: 116 case CONTENT_SETTING_BLOCK:
117 return "block"; 117 return "block";
118 case CONTENT_SETTING_SESSION_ONLY: 118 case CONTENT_SETTING_SESSION_ONLY:
119 return "session"; 119 return "session";
120 case CONTENT_SETTING_DEFAULT: 120 case CONTENT_SETTING_DEFAULT:
121 return "default"; 121 return "default";
122 case CONTENT_SETTING_NUM_SETTINGS: 122 case CONTENT_SETTING_NUM_SETTINGS:
123 NOTREACHED(); 123 NOTREACHED();
124 } 124 }
125 125
126 return ""; 126 return std::string();
127 } 127 }
128 128
129 ContentSetting ContentSettingFromString(const std::string& name) { 129 ContentSetting ContentSettingFromString(const std::string& name) {
130 if (name == "allow") 130 if (name == "allow")
131 return CONTENT_SETTING_ALLOW; 131 return CONTENT_SETTING_ALLOW;
132 if (name == "ask") 132 if (name == "ask")
133 return CONTENT_SETTING_ASK; 133 return CONTENT_SETTING_ASK;
134 if (name == "block") 134 if (name == "block")
135 return CONTENT_SETTING_BLOCK; 135 return CONTENT_SETTING_BLOCK;
136 if (name == "session") 136 if (name == "session")
137 return CONTENT_SETTING_SESSION_ONLY; 137 return CONTENT_SETTING_SESSION_ONLY;
138 138
139 NOTREACHED() << name << " is not a recognized content setting."; 139 NOTREACHED() << name << " is not a recognized content setting.";
140 return CONTENT_SETTING_DEFAULT; 140 return CONTENT_SETTING_DEFAULT;
141 } 141 }
142 142
143 // Create a DictionaryValue* that will act as a data source for a single row 143 // Create a DictionaryValue* that will act as a data source for a single row
144 // in a HostContentSettingsMap-controlled exceptions table (e.g., cookies). 144 // in a HostContentSettingsMap-controlled exceptions table (e.g., cookies).
145 // Ownership of the pointer is passed to the caller. 145 // Ownership of the pointer is passed to the caller.
146 DictionaryValue* GetExceptionForPage( 146 DictionaryValue* GetExceptionForPage(
147 const ContentSettingsPattern& pattern, 147 const ContentSettingsPattern& pattern,
148 const ContentSettingsPattern& secondary_pattern, 148 const ContentSettingsPattern& secondary_pattern,
149 const ContentSetting& setting, 149 const ContentSetting& setting,
150 const std::string& provider_name) { 150 const std::string& provider_name) {
151 DictionaryValue* exception = new DictionaryValue(); 151 DictionaryValue* exception = new DictionaryValue();
152 exception->SetString(kOrigin, pattern.ToString()); 152 exception->SetString(kOrigin, pattern.ToString());
153 exception->SetString(kEmbeddingOrigin, 153 exception->SetString(kEmbeddingOrigin,
154 secondary_pattern == ContentSettingsPattern::Wildcard() ? "" : 154 secondary_pattern == ContentSettingsPattern::Wildcard()
155 secondary_pattern.ToString()); 155 ? std::string()
156 : secondary_pattern.ToString());
156 exception->SetString(kSetting, ContentSettingToString(setting)); 157 exception->SetString(kSetting, ContentSettingToString(setting));
157 exception->SetString(kSource, provider_name); 158 exception->SetString(kSource, provider_name);
158 return exception; 159 return exception;
159 } 160 }
160 161
161 // Create a DictionaryValue* that will act as a data source for a single row 162 // Create a DictionaryValue* that will act as a data source for a single row
162 // in the Geolocation exceptions table. Ownership of the pointer is passed to 163 // in the Geolocation exceptions table. Ownership of the pointer is passed to
163 // the caller. 164 // the caller.
164 DictionaryValue* GetGeolocationExceptionForPage( 165 DictionaryValue* GetGeolocationExceptionForPage(
165 const ContentSettingsPattern& origin, 166 const ContentSettingsPattern& origin,
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 filter_settings.SetString(group_name + ".value", 598 filter_settings.SetString(group_name + ".value",
598 ContentSettingToString(CONTENT_SETTING_BLOCK)); 599 ContentSettingToString(CONTENT_SETTING_BLOCK));
599 filter_settings.SetString(group_name + ".managedBy", "policy"); 600 filter_settings.SetString(group_name + ".managedBy", "policy");
600 web_ui()->CallJavascriptFunction( 601 web_ui()->CallJavascriptFunction(
601 "ContentSettings.setContentFilterSettingsValue", filter_settings); 602 "ContentSettings.setContentFilterSettingsValue", filter_settings);
602 } 603 }
603 604
604 media_ui_settings.SetString("askText", "mediaStreamAsk"); 605 media_ui_settings.SetString("askText", "mediaStreamAsk");
605 media_ui_settings.SetString("blockText", "mediaStreamBlock"); 606 media_ui_settings.SetString("blockText", "mediaStreamBlock");
606 media_ui_settings.SetBoolean("showBubble", false); 607 media_ui_settings.SetBoolean("showBubble", false);
607 media_ui_settings.SetString("bubbleText", ""); 608 media_ui_settings.SetString("bubbleText", std::string());
608 609
609 web_ui()->CallJavascriptFunction("ContentSettings.updateMediaUI", 610 web_ui()->CallJavascriptFunction("ContentSettings.updateMediaUI",
610 media_ui_settings); 611 media_ui_settings);
611 } 612 }
612 613
613 std::string ContentSettingsHandler::GetSettingDefaultFromModel( 614 std::string ContentSettingsHandler::GetSettingDefaultFromModel(
614 ContentSettingsType type, std::string* provider_id) { 615 ContentSettingsType type, std::string* provider_id) {
615 Profile* profile = Profile::FromWebUI(web_ui()); 616 Profile* profile = Profile::FromWebUI(web_ui());
616 ContentSetting default_setting; 617 ContentSetting default_setting;
617 if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { 618 if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 DCHECK(rv); 1046 DCHECK(rv);
1046 1047
1047 std::string pattern; 1048 std::string pattern;
1048 rv = args->GetString(arg_index++, &pattern); 1049 rv = args->GetString(arg_index++, &pattern);
1049 DCHECK(rv); 1050 DCHECK(rv);
1050 1051
1051 HostContentSettingsMap* settings_map = 1052 HostContentSettingsMap* settings_map =
1052 mode == "normal" ? GetContentSettingsMap() : 1053 mode == "normal" ? GetContentSettingsMap() :
1053 GetOTRContentSettingsMap(); 1054 GetOTRContentSettingsMap();
1054 if (settings_map) { 1055 if (settings_map) {
1055 settings_map->SetWebsiteSetting( 1056 settings_map->SetWebsiteSetting(ContentSettingsPattern::FromString(pattern),
1056 ContentSettingsPattern::FromString(pattern), 1057 ContentSettingsPattern::Wildcard(),
1057 ContentSettingsPattern::Wildcard(), 1058 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
1058 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, 1059 std::string(),
1059 "", 1060 NULL);
1060 NULL); 1061 settings_map->SetWebsiteSetting(ContentSettingsPattern::FromString(pattern),
1061 settings_map->SetWebsiteSetting( 1062 ContentSettingsPattern::Wildcard(),
1062 ContentSettingsPattern::FromString(pattern), 1063 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
1063 ContentSettingsPattern::Wildcard(), 1064 std::string(),
1064 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, 1065 NULL);
1065 "",
1066 NULL);
1067 } 1066 }
1068 } 1067 }
1069 1068
1070 void ContentSettingsHandler::RemoveExceptionFromHostContentSettingsMap( 1069 void ContentSettingsHandler::RemoveExceptionFromHostContentSettingsMap(
1071 const ListValue* args, size_t arg_index, 1070 const ListValue* args, size_t arg_index,
1072 ContentSettingsType type) { 1071 ContentSettingsType type) {
1073 std::string mode; 1072 std::string mode;
1074 bool rv = args->GetString(arg_index++, &mode); 1073 bool rv = args->GetString(arg_index++, &mode);
1075 DCHECK(rv); 1074 DCHECK(rv);
1076 1075
1077 std::string pattern; 1076 std::string pattern;
1078 rv = args->GetString(arg_index++, &pattern); 1077 rv = args->GetString(arg_index++, &pattern);
1079 DCHECK(rv); 1078 DCHECK(rv);
1080 1079
1081 std::string secondary_pattern; 1080 std::string secondary_pattern;
1082 rv = args->GetString(arg_index++, &secondary_pattern); 1081 rv = args->GetString(arg_index++, &secondary_pattern);
1083 DCHECK(rv); 1082 DCHECK(rv);
1084 1083
1085 HostContentSettingsMap* settings_map = 1084 HostContentSettingsMap* settings_map =
1086 mode == "normal" ? GetContentSettingsMap() : 1085 mode == "normal" ? GetContentSettingsMap() :
1087 GetOTRContentSettingsMap(); 1086 GetOTRContentSettingsMap();
1088 if (settings_map) { 1087 if (settings_map) {
1089 settings_map->SetWebsiteSetting( 1088 settings_map->SetWebsiteSetting(
1090 ContentSettingsPattern::FromString(pattern), 1089 ContentSettingsPattern::FromString(pattern),
1091 secondary_pattern.empty() ? ContentSettingsPattern::Wildcard() : 1090 secondary_pattern.empty()
1092 ContentSettingsPattern::FromString(secondary_pattern), 1091 ? ContentSettingsPattern::Wildcard()
1092 : ContentSettingsPattern::FromString(secondary_pattern),
1093 type, 1093 type,
1094 "", 1094 std::string(),
1095 NULL); 1095 NULL);
1096 } 1096 }
1097 } 1097 }
1098 1098
1099 void ContentSettingsHandler::RegisterMessages() { 1099 void ContentSettingsHandler::RegisterMessages() {
1100 web_ui()->RegisterMessageCallback("setContentFilter", 1100 web_ui()->RegisterMessageCallback("setContentFilter",
1101 base::Bind(&ContentSettingsHandler::SetContentFilter, 1101 base::Bind(&ContentSettingsHandler::SetContentFilter,
1102 base::Unretained(this))); 1102 base::Unretained(this)));
1103 web_ui()->RegisterMessageCallback("removeException", 1103 web_ui()->RegisterMessageCallback("removeException",
1104 base::Bind(&ContentSettingsHandler::RemoveException, 1104 base::Bind(&ContentSettingsHandler::RemoveException,
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 mode == "normal" ? GetContentSettingsMap() : 1252 mode == "normal" ? GetContentSettingsMap() :
1253 GetOTRContentSettingsMap(); 1253 GetOTRContentSettingsMap();
1254 1254
1255 // The settings map could be null if the mode was OTR but the OTR profile 1255 // The settings map could be null if the mode was OTR but the OTR profile
1256 // got destroyed before we received this message. 1256 // got destroyed before we received this message.
1257 if (!settings_map) 1257 if (!settings_map)
1258 return; 1258 return;
1259 settings_map->SetContentSetting(ContentSettingsPattern::FromString(pattern), 1259 settings_map->SetContentSetting(ContentSettingsPattern::FromString(pattern),
1260 ContentSettingsPattern::Wildcard(), 1260 ContentSettingsPattern::Wildcard(),
1261 type, 1261 type,
1262 "", 1262 std::string(),
1263 ContentSettingFromString(setting)); 1263 ContentSettingFromString(setting));
1264 } 1264 }
1265 } 1265 }
1266 1266
1267 void ContentSettingsHandler::CheckExceptionPatternValidity( 1267 void ContentSettingsHandler::CheckExceptionPatternValidity(
1268 const ListValue* args) { 1268 const ListValue* args) {
1269 size_t arg_i = 0; 1269 size_t arg_i = 0;
1270 std::string type_string; 1270 std::string type_string;
1271 CHECK(args->GetString(arg_i++, &type_string)); 1271 CHECK(args->GetString(arg_i++, &type_string));
1272 std::string mode_string; 1272 std::string mode_string;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 media_settings_.flash_default_setting, 1386 media_settings_.flash_default_setting,
1387 media_settings_.flash_exceptions, 1387 media_settings_.flash_exceptions,
1388 media_settings_.policy_disable_audio, 1388 media_settings_.policy_disable_audio,
1389 media_settings_.policy_disable_video)) { 1389 media_settings_.policy_disable_video)) {
1390 ShowFlashMediaLink(EXCEPTIONS, true); 1390 ShowFlashMediaLink(EXCEPTIONS, true);
1391 } 1391 }
1392 } 1392 }
1393 } 1393 }
1394 1394
1395 } // namespace options 1395 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698