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/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 TabSpecificContentSettings::FromWebContents(web_contents()); | 89 TabSpecificContentSettings::FromWebContents(web_contents()); |
90 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES); | 90 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES); |
91 | 91 |
92 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( | 92 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( |
93 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 93 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
94 NULL, web_contents(), profile(), CONTENT_SETTINGS_TYPE_COOKIES)); | 94 NULL, web_contents(), profile(), CONTENT_SETTINGS_TYPE_COOKIES)); |
95 const ContentSettingBubbleModel::BubbleContent& bubble_content = | 95 const ContentSettingBubbleModel::BubbleContent& bubble_content = |
96 content_setting_bubble_model->bubble_content(); | 96 content_setting_bubble_model->bubble_content(); |
97 std::string title = bubble_content.title; | 97 std::string title = bubble_content.title; |
98 EXPECT_FALSE(title.empty()); | 98 EXPECT_FALSE(title.empty()); |
| 99 EXPECT_TRUE(bubble_content.plugin_names.empty()); |
99 ASSERT_EQ(2U, bubble_content.radio_group.radio_items.size()); | 100 ASSERT_EQ(2U, bubble_content.radio_group.radio_items.size()); |
100 std::string radio1 = bubble_content.radio_group.radio_items[0]; | 101 std::string radio1 = bubble_content.radio_group.radio_items[0]; |
101 std::string radio2 = bubble_content.radio_group.radio_items[1]; | 102 std::string radio2 = bubble_content.radio_group.radio_items[1]; |
102 EXPECT_FALSE(bubble_content.custom_link.empty()); | 103 EXPECT_FALSE(bubble_content.custom_link.empty()); |
103 EXPECT_TRUE(bubble_content.custom_link_enabled); | 104 EXPECT_TRUE(bubble_content.custom_link_enabled); |
104 EXPECT_FALSE(bubble_content.manage_link.empty()); | 105 EXPECT_FALSE(bubble_content.manage_link.empty()); |
105 | 106 |
106 content_settings->ClearCookieSpecificContentSettings(); | 107 content_settings->ClearCookieSpecificContentSettings(); |
107 content_settings->OnContentAllowed(CONTENT_SETTINGS_TYPE_COOKIES); | 108 content_settings->OnContentAllowed(CONTENT_SETTINGS_TYPE_COOKIES); |
108 content_setting_bubble_model.reset( | 109 content_setting_bubble_model.reset( |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 EXPECT_EQ(new_bubble_content.radio_group.radio_items[1], | 723 EXPECT_EQ(new_bubble_content.radio_group.radio_items[1], |
723 l10n_util::GetStringUTF8( | 724 l10n_util::GetStringUTF8( |
724 IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_BLOCK)); | 725 IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_BLOCK)); |
725 EXPECT_EQ(0, new_bubble_content.radio_group.default_item); | 726 EXPECT_EQ(0, new_bubble_content.radio_group.default_item); |
726 EXPECT_EQ(2U, new_bubble_content.media_menus.size()); | 727 EXPECT_EQ(2U, new_bubble_content.media_menus.size()); |
727 } | 728 } |
728 | 729 |
729 TEST_F(ContentSettingBubbleModelTest, Plugins) { | 730 TEST_F(ContentSettingBubbleModelTest, Plugins) { |
730 TabSpecificContentSettings* content_settings = | 731 TabSpecificContentSettings* content_settings = |
731 TabSpecificContentSettings::FromWebContents(web_contents()); | 732 TabSpecificContentSettings::FromWebContents(web_contents()); |
732 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS); | 733 const base::string16 plugin_name = base::ASCIIToUTF16("plugin_name"); |
| 734 |
| 735 content_settings->OnContentBlockedWithDetail(CONTENT_SETTINGS_TYPE_PLUGINS, |
| 736 plugin_name); |
733 | 737 |
734 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( | 738 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( |
735 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 739 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
736 NULL, web_contents(), profile(), | 740 NULL, web_contents(), profile(), |
737 CONTENT_SETTINGS_TYPE_PLUGINS)); | 741 CONTENT_SETTINGS_TYPE_PLUGINS)); |
738 const ContentSettingBubbleModel::BubbleContent& bubble_content = | 742 const ContentSettingBubbleModel::BubbleContent& bubble_content = |
739 content_setting_bubble_model->bubble_content(); | 743 content_setting_bubble_model->bubble_content(); |
740 EXPECT_FALSE(bubble_content.title.empty()); | 744 EXPECT_FALSE(bubble_content.title.empty()); |
| 745 EXPECT_FALSE(bubble_content.plugin_names.empty()); |
| 746 EXPECT_NE(base::string16::npos, |
| 747 bubble_content.plugin_names.find(plugin_name)); |
741 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); | 748 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); |
742 EXPECT_FALSE(bubble_content.custom_link.empty()); | 749 EXPECT_FALSE(bubble_content.custom_link.empty()); |
743 EXPECT_TRUE(bubble_content.custom_link_enabled); | 750 EXPECT_TRUE(bubble_content.custom_link_enabled); |
744 EXPECT_FALSE(bubble_content.manage_link.empty()); | 751 EXPECT_FALSE(bubble_content.manage_link.empty()); |
745 EXPECT_FALSE(bubble_content.learn_more_link.empty()); | 752 EXPECT_FALSE(bubble_content.learn_more_link.empty()); |
746 } | 753 } |
747 | 754 |
748 TEST_F(ContentSettingBubbleModelTest, PepperBroker) { | 755 TEST_F(ContentSettingBubbleModelTest, PepperBroker) { |
749 TabSpecificContentSettings* content_settings = | 756 TabSpecificContentSettings* content_settings = |
750 TabSpecificContentSettings::FromWebContents(web_contents()); | 757 TabSpecificContentSettings::FromWebContents(web_contents()); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 { | 950 { |
944 ProtocolHandler handler = registry.GetHandlerFor("mailto"); | 951 ProtocolHandler handler = registry.GetHandlerFor("mailto"); |
945 ASSERT_FALSE(handler.IsEmpty()); | 952 ASSERT_FALSE(handler.IsEmpty()); |
946 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 953 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
947 content_settings->pending_protocol_handler_setting()); | 954 content_settings->pending_protocol_handler_setting()); |
948 EXPECT_FALSE(registry.IsIgnored(test_handler)); | 955 EXPECT_FALSE(registry.IsIgnored(test_handler)); |
949 } | 956 } |
950 | 957 |
951 registry.Shutdown(); | 958 registry.Shutdown(); |
952 } | 959 } |
OLD | NEW |