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 "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 29 matching lines...) Expand all Loading... | |
| 40 bool expect_clear_link, | 40 bool expect_clear_link, |
| 41 bool expect_reload_hint) { | 41 bool expect_reload_hint) { |
| 42 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( | 42 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( |
| 43 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 43 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| 44 NULL, web_contents(), profile(), | 44 NULL, web_contents(), profile(), |
| 45 CONTENT_SETTINGS_TYPE_GEOLOCATION)); | 45 CONTENT_SETTINGS_TYPE_GEOLOCATION)); |
| 46 const ContentSettingBubbleModel::BubbleContent& bubble_content = | 46 const ContentSettingBubbleModel::BubbleContent& bubble_content = |
| 47 content_setting_bubble_model->bubble_content(); | 47 content_setting_bubble_model->bubble_content(); |
| 48 EXPECT_TRUE(bubble_content.title.empty()); | 48 EXPECT_TRUE(bubble_content.title.empty()); |
| 49 EXPECT_TRUE(bubble_content.radio_group.radio_items.empty()); | 49 EXPECT_TRUE(bubble_content.radio_group.radio_items.empty()); |
| 50 EXPECT_TRUE(bubble_content.popup_items.empty()); | 50 EXPECT_TRUE(bubble_content.list_items.empty()); |
| 51 EXPECT_EQ(expected_domains, bubble_content.domain_lists.size()); | 51 EXPECT_EQ(expected_domains, bubble_content.domain_lists.size()); |
| 52 EXPECT_NE(expect_clear_link || expect_reload_hint, | 52 EXPECT_NE(expect_clear_link || expect_reload_hint, |
| 53 bubble_content.custom_link.empty()); | 53 bubble_content.custom_link.empty()); |
| 54 EXPECT_EQ(expect_clear_link, bubble_content.custom_link_enabled); | 54 EXPECT_EQ(expect_clear_link, bubble_content.custom_link_enabled); |
| 55 EXPECT_FALSE(bubble_content.manage_link.empty()); | 55 EXPECT_FALSE(bubble_content.manage_link.empty()); |
| 56 } | 56 } |
| 57 | 57 |
| 58 std::string GetDefaultAudioDevice() { | 58 std::string GetDefaultAudioDevice() { |
| 59 PrefService* prefs = profile()->GetPrefs(); | 59 PrefService* prefs = profile()->GetPrefs(); |
| 60 return prefs->GetString(prefs::kDefaultAudioCaptureDevice); | 60 return prefs->GetString(prefs::kDefaultAudioCaptureDevice); |
| (...skipping 28 matching lines...) Expand all 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()); | |
| 100 ASSERT_EQ(2U, bubble_content.radio_group.radio_items.size()); | 99 ASSERT_EQ(2U, bubble_content.radio_group.radio_items.size()); |
| 101 std::string radio1 = bubble_content.radio_group.radio_items[0]; | 100 std::string radio1 = bubble_content.radio_group.radio_items[0]; |
| 102 std::string radio2 = bubble_content.radio_group.radio_items[1]; | 101 std::string radio2 = bubble_content.radio_group.radio_items[1]; |
| 103 EXPECT_FALSE(bubble_content.custom_link.empty()); | 102 EXPECT_FALSE(bubble_content.custom_link.empty()); |
| 104 EXPECT_TRUE(bubble_content.custom_link_enabled); | 103 EXPECT_TRUE(bubble_content.custom_link_enabled); |
| 105 EXPECT_FALSE(bubble_content.manage_link.empty()); | 104 EXPECT_FALSE(bubble_content.manage_link.empty()); |
| 106 | 105 |
| 107 content_settings->ClearCookieSpecificContentSettings(); | 106 content_settings->ClearCookieSpecificContentSettings(); |
| 108 content_settings->OnContentAllowed(CONTENT_SETTINGS_TYPE_COOKIES); | 107 content_settings->OnContentAllowed(CONTENT_SETTINGS_TYPE_COOKIES); |
| 109 content_setting_bubble_model.reset( | 108 content_setting_bubble_model.reset( |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 735 content_settings->OnContentBlockedWithDetail(CONTENT_SETTINGS_TYPE_PLUGINS, | 734 content_settings->OnContentBlockedWithDetail(CONTENT_SETTINGS_TYPE_PLUGINS, |
| 736 plugin_name); | 735 plugin_name); |
| 737 | 736 |
| 738 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( | 737 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( |
| 739 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 738 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| 740 NULL, web_contents(), profile(), | 739 NULL, web_contents(), profile(), |
| 741 CONTENT_SETTINGS_TYPE_PLUGINS)); | 740 CONTENT_SETTINGS_TYPE_PLUGINS)); |
| 742 const ContentSettingBubbleModel::BubbleContent& bubble_content = | 741 const ContentSettingBubbleModel::BubbleContent& bubble_content = |
| 743 content_setting_bubble_model->bubble_content(); | 742 content_setting_bubble_model->bubble_content(); |
| 744 EXPECT_FALSE(bubble_content.title.empty()); | 743 EXPECT_FALSE(bubble_content.title.empty()); |
| 745 EXPECT_FALSE(bubble_content.plugin_names.empty()); | 744 EXPECT_EQ(1U, bubble_content.list_items.size()); |
|
Bernhard Bauer
2015/03/23 22:30:46
ASSERT so you fail somewhat gracefully instead of
meacer
2015/03/23 23:44:46
Done.
| |
| 746 EXPECT_NE(base::string16::npos, | 745 EXPECT_EQ(plugin_name, |
| 747 bubble_content.plugin_names.find(plugin_name)); | 746 base::ASCIIToUTF16(bubble_content.list_items[0].title)); |
| 748 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); | 747 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); |
| 749 EXPECT_FALSE(bubble_content.custom_link.empty()); | 748 EXPECT_FALSE(bubble_content.custom_link.empty()); |
| 750 EXPECT_TRUE(bubble_content.custom_link_enabled); | 749 EXPECT_TRUE(bubble_content.custom_link_enabled); |
| 751 EXPECT_FALSE(bubble_content.manage_link.empty()); | 750 EXPECT_FALSE(bubble_content.manage_link.empty()); |
| 752 EXPECT_FALSE(bubble_content.learn_more_link.empty()); | 751 EXPECT_FALSE(bubble_content.learn_more_link.empty()); |
| 753 } | 752 } |
| 754 | 753 |
| 755 TEST_F(ContentSettingBubbleModelTest, PepperBroker) { | 754 TEST_F(ContentSettingBubbleModelTest, PepperBroker) { |
| 756 TabSpecificContentSettings* content_settings = | 755 TabSpecificContentSettings* content_settings = |
| 757 TabSpecificContentSettings::FromWebContents(web_contents()); | 756 TabSpecificContentSettings::FromWebContents(web_contents()); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 853 "mailto", GURL("http://www.toplevel.example/"))); | 852 "mailto", GURL("http://www.toplevel.example/"))); |
| 854 | 853 |
| 855 ContentSettingRPHBubbleModel content_setting_bubble_model( | 854 ContentSettingRPHBubbleModel content_setting_bubble_model( |
| 856 NULL, web_contents(), profile(), NULL, | 855 NULL, web_contents(), profile(), NULL, |
| 857 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS); | 856 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS); |
| 858 | 857 |
| 859 const ContentSettingBubbleModel::BubbleContent& bubble_content = | 858 const ContentSettingBubbleModel::BubbleContent& bubble_content = |
| 860 content_setting_bubble_model.bubble_content(); | 859 content_setting_bubble_model.bubble_content(); |
| 861 EXPECT_FALSE(bubble_content.title.empty()); | 860 EXPECT_FALSE(bubble_content.title.empty()); |
| 862 EXPECT_FALSE(bubble_content.radio_group.radio_items.empty()); | 861 EXPECT_FALSE(bubble_content.radio_group.radio_items.empty()); |
| 863 EXPECT_TRUE(bubble_content.popup_items.empty()); | 862 EXPECT_TRUE(bubble_content.list_items.empty()); |
| 864 EXPECT_TRUE(bubble_content.domain_lists.empty()); | 863 EXPECT_TRUE(bubble_content.domain_lists.empty()); |
| 865 EXPECT_TRUE(bubble_content.custom_link.empty()); | 864 EXPECT_TRUE(bubble_content.custom_link.empty()); |
| 866 EXPECT_FALSE(bubble_content.custom_link_enabled); | 865 EXPECT_FALSE(bubble_content.custom_link_enabled); |
| 867 EXPECT_FALSE(bubble_content.manage_link.empty()); | 866 EXPECT_FALSE(bubble_content.manage_link.empty()); |
| 868 } | 867 } |
| 869 | 868 |
| 870 class FakeDelegate : public ProtocolHandlerRegistry::Delegate { | 869 class FakeDelegate : public ProtocolHandlerRegistry::Delegate { |
| 871 public: | 870 public: |
| 872 void RegisterExternalHandler(const std::string& protocol) override { | 871 void RegisterExternalHandler(const std::string& protocol) override { |
| 873 // Overrides in order to not register the handler with the | 872 // Overrides in order to not register the handler with the |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 950 { | 949 { |
| 951 ProtocolHandler handler = registry.GetHandlerFor("mailto"); | 950 ProtocolHandler handler = registry.GetHandlerFor("mailto"); |
| 952 ASSERT_FALSE(handler.IsEmpty()); | 951 ASSERT_FALSE(handler.IsEmpty()); |
| 953 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 952 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 954 content_settings->pending_protocol_handler_setting()); | 953 content_settings->pending_protocol_handler_setting()); |
| 955 EXPECT_FALSE(registry.IsIgnored(test_handler)); | 954 EXPECT_FALSE(registry.IsIgnored(test_handler)); |
| 956 } | 955 } |
| 957 | 956 |
| 958 registry.Shutdown(); | 957 registry.Shutdown(); |
| 959 } | 958 } |
| OLD | NEW |