| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/content_settings/host_content_settings_map.h" | 7 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" | 10 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 EXPECT_FALSE(bubble_content.manage_link.empty()); | 42 EXPECT_FALSE(bubble_content.manage_link.empty()); |
| 43 } | 43 } |
| 44 | 44 |
| 45 BrowserThread ui_thread_; | 45 BrowserThread ui_thread_; |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 TEST_F(ContentSettingBubbleModelTest, ImageRadios) { | 48 TEST_F(ContentSettingBubbleModelTest, ImageRadios) { |
| 49 TabSpecificContentSettings* content_settings = | 49 TabSpecificContentSettings* content_settings = |
| 50 contents_wrapper()->content_settings(); | 50 contents_wrapper()->content_settings(); |
| 51 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES, | 51 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES, |
| 52 std::string()); | 52 std::string(), CONTENT_SETTING_BLOCK); |
| 53 | 53 |
| 54 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( | 54 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( |
| 55 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 55 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| 56 NULL, contents_wrapper(), profile_.get(), | 56 NULL, contents_wrapper(), profile_.get(), |
| 57 CONTENT_SETTINGS_TYPE_IMAGES)); | 57 CONTENT_SETTINGS_TYPE_IMAGES)); |
| 58 const ContentSettingBubbleModel::BubbleContent& bubble_content = | 58 const ContentSettingBubbleModel::BubbleContent& bubble_content = |
| 59 content_setting_bubble_model->bubble_content(); | 59 content_setting_bubble_model->bubble_content(); |
| 60 EXPECT_FALSE(bubble_content.title.empty()); | 60 EXPECT_FALSE(bubble_content.title.empty()); |
| 61 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); | 61 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); |
| 62 EXPECT_EQ(0, bubble_content.radio_group.default_item); | 62 EXPECT_EQ(0, bubble_content.radio_group.default_item); |
| 63 EXPECT_TRUE(bubble_content.custom_link.empty()); | 63 EXPECT_TRUE(bubble_content.custom_link.empty()); |
| 64 EXPECT_FALSE(bubble_content.manage_link.empty()); | 64 EXPECT_FALSE(bubble_content.manage_link.empty()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 TEST_F(ContentSettingBubbleModelTest, Cookies) { | 67 TEST_F(ContentSettingBubbleModelTest, Cookies) { |
| 68 TabSpecificContentSettings* content_settings = | 68 TabSpecificContentSettings* content_settings = |
| 69 contents_wrapper()->content_settings(); | 69 contents_wrapper()->content_settings(); |
| 70 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, | 70 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, |
| 71 std::string()); | 71 std::string(), CONTENT_SETTING_BLOCK); |
| 72 | 72 |
| 73 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( | 73 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( |
| 74 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 74 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| 75 NULL, contents_wrapper(), profile_.get(), | 75 NULL, contents_wrapper(), profile_.get(), |
| 76 CONTENT_SETTINGS_TYPE_COOKIES)); | 76 CONTENT_SETTINGS_TYPE_COOKIES)); |
| 77 const ContentSettingBubbleModel::BubbleContent& bubble_content = | 77 const ContentSettingBubbleModel::BubbleContent& bubble_content = |
| 78 content_setting_bubble_model->bubble_content(); | 78 content_setting_bubble_model->bubble_content(); |
| 79 EXPECT_FALSE(bubble_content.title.empty()); | 79 EXPECT_FALSE(bubble_content.title.empty()); |
| 80 EXPECT_FALSE(bubble_content.radio_group.radio_items.empty()); | 80 EXPECT_FALSE(bubble_content.radio_group.radio_items.empty()); |
| 81 EXPECT_FALSE(bubble_content.custom_link.empty()); | 81 EXPECT_FALSE(bubble_content.custom_link.empty()); |
| 82 EXPECT_TRUE(bubble_content.custom_link_enabled); | 82 EXPECT_TRUE(bubble_content.custom_link_enabled); |
| 83 EXPECT_FALSE(bubble_content.manage_link.empty()); | 83 EXPECT_FALSE(bubble_content.manage_link.empty()); |
| 84 } | 84 } |
| 85 | 85 |
| 86 TEST_F(ContentSettingBubbleModelTest, Plugins) { | 86 TEST_F(ContentSettingBubbleModelTest, Plugins) { |
| 87 TabSpecificContentSettings* content_settings = | 87 TabSpecificContentSettings* content_settings = |
| 88 contents_wrapper()->content_settings(); | 88 contents_wrapper()->content_settings(); |
| 89 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS, | 89 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS, |
| 90 std::string()); | 90 std::string(), CONTENT_SETTING_BLOCK); |
| 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, contents_wrapper(), profile_.get(), | 94 NULL, contents_wrapper(), profile_.get(), |
| 95 CONTENT_SETTINGS_TYPE_PLUGINS)); | 95 CONTENT_SETTINGS_TYPE_PLUGINS)); |
| 96 const ContentSettingBubbleModel::BubbleContent& bubble_content = | 96 const ContentSettingBubbleModel::BubbleContent& bubble_content = |
| 97 content_setting_bubble_model->bubble_content(); | 97 content_setting_bubble_model->bubble_content(); |
| 98 EXPECT_FALSE(bubble_content.title.empty()); | 98 EXPECT_FALSE(bubble_content.title.empty()); |
| 99 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); | 99 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); |
| 100 EXPECT_FALSE(bubble_content.custom_link.empty()); | 100 EXPECT_FALSE(bubble_content.custom_link.empty()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 123 CONTENT_SETTING_ALLOW); | 123 CONTENT_SETTING_ALLOW); |
| 124 map->AddExceptionForURL(url, | 124 map->AddExceptionForURL(url, |
| 125 url, | 125 url, |
| 126 CONTENT_SETTINGS_TYPE_PLUGINS, | 126 CONTENT_SETTINGS_TYPE_PLUGINS, |
| 127 barPlugin, | 127 barPlugin, |
| 128 CONTENT_SETTING_ASK); | 128 CONTENT_SETTING_ASK); |
| 129 | 129 |
| 130 TabSpecificContentSettings* content_settings = | 130 TabSpecificContentSettings* content_settings = |
| 131 contents_wrapper()->content_settings(); | 131 contents_wrapper()->content_settings(); |
| 132 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS, | 132 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS, |
| 133 fooPlugin); | 133 fooPlugin, CONTENT_SETTING_BLOCK); |
| 134 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS, | 134 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS, |
| 135 barPlugin); | 135 barPlugin, CONTENT_SETTING_BLOCK); |
| 136 | 136 |
| 137 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( | 137 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( |
| 138 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 138 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| 139 NULL, contents_wrapper(), profile_.get(), | 139 NULL, contents_wrapper(), profile_.get(), |
| 140 CONTENT_SETTINGS_TYPE_PLUGINS)); | 140 CONTENT_SETTINGS_TYPE_PLUGINS)); |
| 141 const ContentSettingBubbleModel::BubbleContent& bubble_content = | 141 const ContentSettingBubbleModel::BubbleContent& bubble_content = |
| 142 content_setting_bubble_model->bubble_content(); | 142 content_setting_bubble_model->bubble_content(); |
| 143 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); | 143 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); |
| 144 EXPECT_EQ(1, bubble_content.radio_group.default_item); | 144 EXPECT_EQ(1, bubble_content.radio_group.default_item); |
| 145 | 145 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 std::string file_url("file:///tmp/test.html"); | 208 std::string file_url("file:///tmp/test.html"); |
| 209 NavigateAndCommit(GURL(file_url)); | 209 NavigateAndCommit(GURL(file_url)); |
| 210 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( | 210 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( |
| 211 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 211 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| 212 NULL, contents_wrapper(), profile_.get(), | 212 NULL, contents_wrapper(), profile_.get(), |
| 213 CONTENT_SETTINGS_TYPE_IMAGES)); | 213 CONTENT_SETTINGS_TYPE_IMAGES)); |
| 214 std::string title = | 214 std::string title = |
| 215 content_setting_bubble_model->bubble_content().radio_group.radio_items[0]; | 215 content_setting_bubble_model->bubble_content().radio_group.radio_items[0]; |
| 216 ASSERT_NE(std::string::npos, title.find(file_url)); | 216 ASSERT_NE(std::string::npos, title.find(file_url)); |
| 217 } | 217 } |
| OLD | NEW |