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 "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/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/content_settings/host_content_settings_map.h" | 8 #include "chrome/browser/content_settings/host_content_settings_map.h" |
9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
10 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 10 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 TabSpecificContentSettings::FromWebContents(web_contents()); | 449 TabSpecificContentSettings::FromWebContents(web_contents()); |
450 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS); | 450 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS); |
451 | 451 |
452 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( | 452 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( |
453 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 453 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
454 NULL, web_contents(), profile(), | 454 NULL, web_contents(), profile(), |
455 CONTENT_SETTINGS_TYPE_PLUGINS)); | 455 CONTENT_SETTINGS_TYPE_PLUGINS)); |
456 const ContentSettingBubbleModel::BubbleContent& bubble_content = | 456 const ContentSettingBubbleModel::BubbleContent& bubble_content = |
457 content_setting_bubble_model->bubble_content(); | 457 content_setting_bubble_model->bubble_content(); |
458 EXPECT_FALSE(bubble_content.title.empty()); | 458 EXPECT_FALSE(bubble_content.title.empty()); |
459 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); | 459 EXPECT_FALSE(bubble_content.learn_more_link.empty()); |
460 EXPECT_FALSE(bubble_content.custom_link.empty()); | 460 EXPECT_EQ(3U, bubble_content.radio_group.radio_items.size()); |
461 EXPECT_TRUE(bubble_content.custom_link_enabled); | 461 EXPECT_TRUE(bubble_content.custom_link.empty()); |
462 EXPECT_FALSE(bubble_content.manage_link.empty()); | 462 EXPECT_FALSE(bubble_content.manage_link.empty()); |
| 463 |
| 464 // Test to see that the default radio item is set to Block. |
| 465 EXPECT_EQ(2, bubble_content.radio_group.default_item); |
| 466 } |
| 467 |
| 468 TEST_F(ContentSettingBubbleModelTest, BlockedPluginsPermissionChange) { |
| 469 TabSpecificContentSettings* content_settings = |
| 470 TabSpecificContentSettings::FromWebContents(web_contents()); |
| 471 std::string file_url("file:///plugin/quicktime.html"); |
| 472 NavigateAndCommit(GURL(file_url)); |
| 473 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS); |
| 474 { |
| 475 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( |
| 476 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| 477 NULL, web_contents(), profile(), |
| 478 CONTENT_SETTINGS_TYPE_PLUGINS)); |
| 479 } |
| 480 |
| 481 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 482 content_settings->plugin_bubble_setting()); |
| 483 |
| 484 { |
| 485 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( |
| 486 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| 487 NULL, web_contents(), profile(), |
| 488 CONTENT_SETTINGS_TYPE_PLUGINS)); |
| 489 // Change the radio setting. |
| 490 content_setting_bubble_model->OnRadioClicked(0); |
| 491 } |
| 492 |
| 493 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 494 content_settings->plugin_bubble_setting()); |
| 495 |
| 496 { |
| 497 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( |
| 498 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| 499 NULL, web_contents(), profile(), |
| 500 CONTENT_SETTINGS_TYPE_PLUGINS)); |
| 501 // Change the radio setting. |
| 502 content_setting_bubble_model->OnRadioClicked(1); |
| 503 } |
| 504 |
| 505 EXPECT_EQ(CONTENT_SETTING_DEFAULT, |
| 506 content_settings->plugin_bubble_setting()); |
463 } | 507 } |
464 | 508 |
465 TEST_F(ContentSettingBubbleModelTest, PepperBroker) { | 509 TEST_F(ContentSettingBubbleModelTest, PepperBroker) { |
466 TabSpecificContentSettings* content_settings = | 510 TabSpecificContentSettings* content_settings = |
467 TabSpecificContentSettings::FromWebContents(web_contents()); | 511 TabSpecificContentSettings::FromWebContents(web_contents()); |
468 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PPAPI_BROKER); | 512 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PPAPI_BROKER); |
469 | 513 |
470 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( | 514 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( |
471 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 515 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
472 NULL, web_contents(), profile(), | 516 NULL, web_contents(), profile(), |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 { | 704 { |
661 ProtocolHandler handler = registry.GetHandlerFor("mailto"); | 705 ProtocolHandler handler = registry.GetHandlerFor("mailto"); |
662 ASSERT_FALSE(handler.IsEmpty()); | 706 ASSERT_FALSE(handler.IsEmpty()); |
663 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 707 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
664 content_settings->pending_protocol_handler_setting()); | 708 content_settings->pending_protocol_handler_setting()); |
665 EXPECT_FALSE(registry.IsIgnored(test_handler)); | 709 EXPECT_FALSE(registry.IsIgnored(test_handler)); |
666 } | 710 } |
667 | 711 |
668 registry.Shutdown(); | 712 registry.Shutdown(); |
669 } | 713 } |
OLD | NEW |