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

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

Issue 1906533002: Add 'autoplay' content settings and expose it to Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 "base/auto_reset.h" 5 #include "base/auto_reset.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "chrome/browser/content_settings/content_settings_mock_observer.h" 10 #include "chrome/browser/content_settings/content_settings_mock_observer.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 host_content_settings_map->GetContentSetting( 161 host_content_settings_map->GetContentSetting(
162 host, host, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string())); 162 host, host, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()));
163 163
164 host_content_settings_map->SetContentSettingDefaultScope( 164 host_content_settings_map->SetContentSettingDefaultScope(
165 host, GURL(), CONTENT_SETTINGS_TYPE_KEYGEN, std::string(), 165 host, GURL(), CONTENT_SETTINGS_TYPE_KEYGEN, std::string(),
166 CONTENT_SETTING_ALLOW); 166 CONTENT_SETTING_ALLOW);
167 EXPECT_EQ(CONTENT_SETTING_ALLOW, 167 EXPECT_EQ(CONTENT_SETTING_ALLOW,
168 host_content_settings_map->GetContentSetting( 168 host_content_settings_map->GetContentSetting(
169 host, host, CONTENT_SETTINGS_TYPE_KEYGEN, std::string())); 169 host, host, CONTENT_SETTINGS_TYPE_KEYGEN, std::string()));
170 170
171 host_content_settings_map->SetContentSettingDefaultScope(
172 host, GURL(), CONTENT_SETTINGS_TYPE_AUTOPLAY, std::string(),
173 CONTENT_SETTING_BLOCK);
174 EXPECT_EQ(CONTENT_SETTING_BLOCK,
175 host_content_settings_map->GetContentSetting(
176 host, host, CONTENT_SETTINGS_TYPE_AUTOPLAY, std::string()));
177
171 // Check returning all hosts for a setting. 178 // Check returning all hosts for a setting.
172 GURL host2("http://example.org/"); 179 GURL host2("http://example.org/");
173 host_content_settings_map->SetContentSettingDefaultScope( 180 host_content_settings_map->SetContentSettingDefaultScope(
174 host2, GURL(), CONTENT_SETTINGS_TYPE_IMAGES, std::string(), 181 host2, GURL(), CONTENT_SETTINGS_TYPE_IMAGES, std::string(),
175 CONTENT_SETTING_BLOCK); 182 CONTENT_SETTING_BLOCK);
176 #if defined(ENABLE_PLUGINS) 183 #if defined(ENABLE_PLUGINS)
177 host_content_settings_map->SetContentSettingDefaultScope( 184 host_content_settings_map->SetContentSettingDefaultScope(
178 host2, GURL(), CONTENT_SETTINGS_TYPE_PLUGINS, std::string(), 185 host2, GURL(), CONTENT_SETTINGS_TYPE_PLUGINS, std::string(),
179 CONTENT_SETTING_BLOCK); 186 CONTENT_SETTING_BLOCK);
180 #endif 187 #endif
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 host_content_settings_map->GetContentSetting( 519 host_content_settings_map->GetContentSetting(
513 host_ending_with_dot, host_ending_with_dot, 520 host_ending_with_dot, host_ending_with_dot,
514 CONTENT_SETTINGS_TYPE_KEYGEN, std::string())); 521 CONTENT_SETTINGS_TYPE_KEYGEN, std::string()));
515 host_content_settings_map->SetContentSettingDefaultScope( 522 host_content_settings_map->SetContentSettingDefaultScope(
516 host_ending_with_dot, GURL(), CONTENT_SETTINGS_TYPE_KEYGEN, std::string(), 523 host_ending_with_dot, GURL(), CONTENT_SETTINGS_TYPE_KEYGEN, std::string(),
517 CONTENT_SETTING_DEFAULT); 524 CONTENT_SETTING_DEFAULT);
518 EXPECT_EQ(CONTENT_SETTING_BLOCK, 525 EXPECT_EQ(CONTENT_SETTING_BLOCK,
519 host_content_settings_map->GetContentSetting( 526 host_content_settings_map->GetContentSetting(
520 host_ending_with_dot, host_ending_with_dot, 527 host_ending_with_dot, host_ending_with_dot,
521 CONTENT_SETTINGS_TYPE_KEYGEN, std::string())); 528 CONTENT_SETTINGS_TYPE_KEYGEN, std::string()));
529
530 EXPECT_EQ(CONTENT_SETTING_ALLOW,
531 host_content_settings_map->GetContentSetting(
532 host_ending_with_dot, host_ending_with_dot,
533 CONTENT_SETTINGS_TYPE_AUTOPLAY, std::string()));
534 host_content_settings_map->SetContentSettingDefaultScope(
535 host_ending_with_dot, GURL(), CONTENT_SETTINGS_TYPE_AUTOPLAY,
536 std::string(), CONTENT_SETTING_BLOCK);
537 EXPECT_EQ(CONTENT_SETTING_BLOCK,
538 host_content_settings_map->GetContentSetting(
539 host_ending_with_dot, host_ending_with_dot,
540 CONTENT_SETTINGS_TYPE_AUTOPLAY, std::string()));
541 host_content_settings_map->SetContentSettingDefaultScope(
542 host_ending_with_dot, GURL(), CONTENT_SETTINGS_TYPE_AUTOPLAY,
543 std::string(), CONTENT_SETTING_DEFAULT);
544 EXPECT_EQ(CONTENT_SETTING_ALLOW,
545 host_content_settings_map->GetContentSetting(
546 host_ending_with_dot, host_ending_with_dot,
547 CONTENT_SETTINGS_TYPE_AUTOPLAY, std::string()));
522 } 548 }
523 549
524 TEST_F(HostContentSettingsMapTest, NestedSettings) { 550 TEST_F(HostContentSettingsMapTest, NestedSettings) {
525 TestingProfile profile; 551 TestingProfile profile;
526 HostContentSettingsMap* host_content_settings_map = 552 HostContentSettingsMap* host_content_settings_map =
527 HostContentSettingsMapFactory::GetForProfile(&profile); 553 HostContentSettingsMapFactory::GetForProfile(&profile);
528 554
529 GURL host("http://a.b.example.com/"); 555 GURL host("http://a.b.example.com/");
530 GURL host1("http://example.com/"); 556 GURL host1("http://example.com/");
531 GURL host2("http://b.example.com/"); 557 GURL host2("http://b.example.com/");
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 host, host, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string())); 594 host, host, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string()));
569 EXPECT_EQ(CONTENT_SETTING_ASK, 595 EXPECT_EQ(CONTENT_SETTING_ASK,
570 host_content_settings_map->GetContentSetting( 596 host_content_settings_map->GetContentSetting(
571 host, host, CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string())); 597 host, host, CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string()));
572 EXPECT_EQ(CONTENT_SETTING_ASK, 598 EXPECT_EQ(CONTENT_SETTING_ASK,
573 host_content_settings_map->GetContentSetting( 599 host_content_settings_map->GetContentSetting(
574 host, host, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string())); 600 host, host, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()));
575 EXPECT_EQ(CONTENT_SETTING_BLOCK, 601 EXPECT_EQ(CONTENT_SETTING_BLOCK,
576 host_content_settings_map->GetContentSetting( 602 host_content_settings_map->GetContentSetting(
577 host, host, CONTENT_SETTINGS_TYPE_KEYGEN, std::string())); 603 host, host, CONTENT_SETTINGS_TYPE_KEYGEN, std::string()));
604 EXPECT_EQ(CONTENT_SETTING_ALLOW,
605 host_content_settings_map->GetContentSetting(
606 host, host, CONTENT_SETTINGS_TYPE_AUTOPLAY, std::string()));
578 } 607 }
579 608
580 TEST_F(HostContentSettingsMapTest, OffTheRecord) { 609 TEST_F(HostContentSettingsMapTest, OffTheRecord) {
581 TestingProfile profile; 610 TestingProfile profile;
582 Profile* otr_profile = profile.GetOffTheRecordProfile(); 611 Profile* otr_profile = profile.GetOffTheRecordProfile();
583 HostContentSettingsMap* host_content_settings_map = 612 HostContentSettingsMap* host_content_settings_map =
584 HostContentSettingsMapFactory::GetForProfile(&profile); 613 HostContentSettingsMapFactory::GetForProfile(&profile);
585 HostContentSettingsMap* otr_map = 614 HostContentSettingsMap* otr_map =
586 HostContentSettingsMapFactory::GetForProfile(otr_profile); 615 HostContentSettingsMapFactory::GetForProfile(otr_profile);
587 616
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 host, host, CONTENT_SETTINGS_TYPE_KEYGEN, std::string())); 1213 host, host, CONTENT_SETTINGS_TYPE_KEYGEN, std::string()));
1185 1214
1186 // After migrating old settings, changes to the setting works. 1215 // After migrating old settings, changes to the setting works.
1187 host_content_settings_map->SetContentSettingDefaultScope( 1216 host_content_settings_map->SetContentSettingDefaultScope(
1188 host, GURL(), CONTENT_SETTINGS_TYPE_KEYGEN, std::string(), 1217 host, GURL(), CONTENT_SETTINGS_TYPE_KEYGEN, std::string(),
1189 CONTENT_SETTING_BLOCK); 1218 CONTENT_SETTING_BLOCK);
1190 EXPECT_EQ(CONTENT_SETTING_BLOCK, 1219 EXPECT_EQ(CONTENT_SETTING_BLOCK,
1191 host_content_settings_map->GetContentSetting( 1220 host_content_settings_map->GetContentSetting(
1192 host, host, CONTENT_SETTINGS_TYPE_KEYGEN, std::string())); 1221 host, host, CONTENT_SETTINGS_TYPE_KEYGEN, std::string()));
1193 } 1222 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698