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

Side by Side Diff: chrome/browser/content_settings/content_settings_policy_provider_unittest.cc

Issue 388963002: Get rid of the rest of CreateStringValue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bad rebase Created 6 years, 5 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_policy_provider.h" 5 #include "chrome/browser/content_settings/content_settings_policy_provider.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // Remove the managed default-content-setting. 131 // Remove the managed default-content-setting.
132 prefs->RemoveManagedPref(prefs::kManagedDefaultImagesSetting); 132 prefs->RemoveManagedPref(prefs::kManagedDefaultImagesSetting);
133 provider.ShutdownOnUIThread(); 133 provider.ShutdownOnUIThread();
134 } 134 }
135 135
136 TEST_F(PolicyProviderTest, GettingManagedContentSettings) { 136 TEST_F(PolicyProviderTest, GettingManagedContentSettings) {
137 TestingProfile profile; 137 TestingProfile profile;
138 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService(); 138 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService();
139 139
140 base::ListValue* value = new base::ListValue(); 140 base::ListValue* value = new base::ListValue();
141 value->Append(base::Value::CreateStringValue("[*.]google.com")); 141 value->Append(new base::StringValue("[*.]google.com"));
142 prefs->SetManagedPref(prefs::kManagedImagesBlockedForUrls, 142 prefs->SetManagedPref(prefs::kManagedImagesBlockedForUrls,
143 value); 143 value);
144 144
145 PolicyProvider provider(prefs); 145 PolicyProvider provider(prefs);
146 146
147 ContentSettingsPattern yt_url_pattern = 147 ContentSettingsPattern yt_url_pattern =
148 ContentSettingsPattern::FromString("www.youtube.com"); 148 ContentSettingsPattern::FromString("www.youtube.com");
149 GURL youtube_url("http://www.youtube.com"); 149 GURL youtube_url("http://www.youtube.com");
150 GURL google_url("http://mail.google.com"); 150 GURL google_url("http://mail.google.com");
151 151
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 false)); 203 false));
204 204
205 provider.ShutdownOnUIThread(); 205 provider.ShutdownOnUIThread();
206 } 206 }
207 207
208 TEST_F(PolicyProviderTest, ResourceIdentifier) { 208 TEST_F(PolicyProviderTest, ResourceIdentifier) {
209 TestingProfile profile; 209 TestingProfile profile;
210 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService(); 210 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService();
211 211
212 base::ListValue* value = new base::ListValue(); 212 base::ListValue* value = new base::ListValue();
213 value->Append(base::Value::CreateStringValue("[*.]google.com")); 213 value->Append(new base::StringValue("[*.]google.com"));
214 prefs->SetManagedPref(prefs::kManagedPluginsAllowedForUrls, 214 prefs->SetManagedPref(prefs::kManagedPluginsAllowedForUrls,
215 value); 215 value);
216 216
217 PolicyProvider provider(prefs); 217 PolicyProvider provider(prefs);
218 218
219 GURL youtube_url("http://www.youtube.com"); 219 GURL youtube_url("http://www.youtube.com");
220 GURL google_url("http://mail.google.com"); 220 GURL google_url("http://mail.google.com");
221 221
222 EXPECT_EQ(CONTENT_SETTING_DEFAULT, 222 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
223 GetContentSetting( 223 GetContentSetting(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 google_url, 256 google_url,
257 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 257 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
258 std::string(), 258 std::string(),
259 false)); 259 false));
260 260
261 // Set the content settings pattern list for origins to auto select 261 // Set the content settings pattern list for origins to auto select
262 // certificates. 262 // certificates.
263 std::string pattern_str("\"pattern\":\"[*.]google.com\""); 263 std::string pattern_str("\"pattern\":\"[*.]google.com\"");
264 std::string filter_str("\"filter\":{\"ISSUER\":{\"CN\":\"issuer name\"}}"); 264 std::string filter_str("\"filter\":{\"ISSUER\":{\"CN\":\"issuer name\"}}");
265 base::ListValue* value = new base::ListValue(); 265 base::ListValue* value = new base::ListValue();
266 value->Append(base::Value::CreateStringValue( 266 value->Append(
267 "{" + pattern_str + "," + filter_str + "}")); 267 new base::StringValue("{" + pattern_str + "," + filter_str + "}"));
268 prefs->SetManagedPref(prefs::kManagedAutoSelectCertificateForUrls, 268 prefs->SetManagedPref(prefs::kManagedAutoSelectCertificateForUrls,
269 value); 269 value);
270 GURL youtube_url("https://www.youtube.com"); 270 GURL youtube_url("https://www.youtube.com");
271 EXPECT_EQ( 271 EXPECT_EQ(
272 NULL, 272 NULL,
273 GetContentSettingValue(&provider, 273 GetContentSettingValue(&provider,
274 youtube_url, 274 youtube_url,
275 youtube_url, 275 youtube_url,
276 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 276 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
277 std::string(), 277 std::string(),
278 false)); 278 false));
279 scoped_ptr<base::Value> cert_filter( 279 scoped_ptr<base::Value> cert_filter(
280 GetContentSettingValue(&provider, 280 GetContentSettingValue(&provider,
281 google_url, 281 google_url,
282 google_url, 282 google_url,
283 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 283 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
284 std::string(), 284 std::string(),
285 false)); 285 false));
286 286
287 ASSERT_EQ(base::Value::TYPE_DICTIONARY, cert_filter->GetType()); 287 ASSERT_EQ(base::Value::TYPE_DICTIONARY, cert_filter->GetType());
288 base::DictionaryValue* dict_value = 288 base::DictionaryValue* dict_value =
289 static_cast<base::DictionaryValue*>(cert_filter.get()); 289 static_cast<base::DictionaryValue*>(cert_filter.get());
290 std::string actual_common_name; 290 std::string actual_common_name;
291 ASSERT_TRUE(dict_value->GetString("ISSUER.CN", &actual_common_name)); 291 ASSERT_TRUE(dict_value->GetString("ISSUER.CN", &actual_common_name));
292 EXPECT_EQ("issuer name", actual_common_name); 292 EXPECT_EQ("issuer name", actual_common_name);
293 provider.ShutdownOnUIThread(); 293 provider.ShutdownOnUIThread();
294 } 294 }
295 295
296 } // namespace content_settings 296 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698