Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "chrome/common/render_messages.h" | 7 #include "chrome/common/render_messages.h" |
| 8 #include "chrome/renderer/content_settings_observer.h" | 8 #include "chrome/renderer/content_settings_observer.h" |
| 9 #include "chrome/test/base/chrome_render_view_test.h" | 9 #include "chrome/test/base/chrome_render_view_test.h" |
| 10 #include "components/content_settings/content/common/content_settings_messages.h " | 10 #include "components/content_settings/content/common/content_settings_messages.h " |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 was_blocked = true; | 369 was_blocked = true; |
| 370 } | 370 } |
| 371 EXPECT_FALSE(was_blocked); | 371 EXPECT_FALSE(was_blocked); |
| 372 | 372 |
| 373 // Verify that images are allowed. | 373 // Verify that images are allowed. |
| 374 EXPECT_CALL(mock_observer, OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES, | 374 EXPECT_CALL(mock_observer, OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES, |
| 375 base::string16())).Times(0); | 375 base::string16())).Times(0); |
| 376 EXPECT_TRUE(observer->allowImage(true, mock_observer.image_url_)); | 376 EXPECT_TRUE(observer->allowImage(true, mock_observer.image_url_)); |
| 377 ::testing::Mock::VerifyAndClearExpectations(&observer); | 377 ::testing::Mock::VerifyAndClearExpectations(&observer); |
| 378 } | 378 } |
| 379 | |
| 380 TEST_F(ChromeRenderViewTest, AutoplayContentSettings) { | |
| 381 MockContentSettingsObserver mock_observer(view_->GetMainRenderFrame()); | |
| 382 | |
| 383 // Load some HTML. | |
| 384 LoadHTML("<html>Foo</html>"); | |
| 385 | |
| 386 // Set the default setting. | |
| 387 RendererContentSettingRules content_setting_rules; | |
| 388 ContentSettingsForOneType& autoplay_setting_rules = | |
| 389 content_setting_rules.autoplay_rules; | |
| 390 autoplay_setting_rules.push_back( | |
| 391 ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), | |
| 392 ContentSettingsPattern::Wildcard(), | |
| 393 CONTENT_SETTING_ALLOW, | |
| 394 std::string(), | |
| 395 false)); | |
| 396 | |
| 397 ContentSettingsObserver* observer = | |
| 398 ContentSettingsObserver::Get(view_->GetMainRenderFrame()); | |
| 399 observer->SetContentSettingRules(&content_setting_rules); | |
| 400 | |
| 401 EXPECT_TRUE(observer->allowAutoplay(false)); | |
| 402 ::testing::Mock::VerifyAndClearExpectations(&observer); | |
|
Bernhard Bauer
2016/04/25 14:01:49
The initial :: isn't necessary if you're in the gl
| |
| 403 | |
| 404 // Add rule to block autoplay. | |
| 405 autoplay_setting_rules.insert( | |
| 406 autoplay_setting_rules.begin(), | |
| 407 ContentSettingPatternSource( | |
| 408 ContentSettingsPattern::Wildcard(), | |
| 409 ContentSettingsPattern::Wildcard(), | |
| 410 CONTENT_SETTING_BLOCK, | |
| 411 std::string(), | |
| 412 false)); | |
| 413 | |
| 414 EXPECT_FALSE(observer->allowAutoplay(true)); | |
| 415 ::testing::Mock::VerifyAndClearExpectations(&observer); | |
| 416 } | |
| OLD | NEW |