| 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/utf_string_conversions.h" | |
| 6 #include "chrome/browser/content_settings/host_content_settings_map.h" | 5 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 7 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 6 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 8 #include "chrome/browser/prerender/prerender_manager.h" | 7 #include "chrome/browser/prerender/prerender_manager.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" | 9 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
| 11 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 10 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 12 #include "chrome/browser/ui/tab_contents/test_tab_contents.h" | 11 #include "chrome/browser/ui/tab_contents/test_tab_contents.h" |
| 13 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
| 14 #include "content/public/test/test_browser_thread.h" | 13 #include "content/public/test/test_browser_thread.h" |
| 15 #include "content/public/test/test_renderer_host.h" | 14 #include "content/public/test/test_renderer_host.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 41 | 40 |
| 42 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES, | 41 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES, |
| 43 std::string()); | 42 std::string()); |
| 44 content_setting_image_model->UpdateFromWebContents(contents()); | 43 content_setting_image_model->UpdateFromWebContents(contents()); |
| 45 | 44 |
| 46 EXPECT_TRUE(content_setting_image_model->is_visible()); | 45 EXPECT_TRUE(content_setting_image_model->is_visible()); |
| 47 EXPECT_NE(0, content_setting_image_model->get_icon()); | 46 EXPECT_NE(0, content_setting_image_model->get_icon()); |
| 48 EXPECT_FALSE(content_setting_image_model->get_tooltip().empty()); | 47 EXPECT_FALSE(content_setting_image_model->get_tooltip().empty()); |
| 49 } | 48 } |
| 50 | 49 |
| 51 TEST_F(ContentSettingImageModelTest, RPHUpdateFromWebContents) { | |
| 52 scoped_ptr<ContentSettingImageModel> content_setting_image_model( | |
| 53 ContentSettingImageModel::CreateContentSettingImageModel( | |
| 54 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS)); | |
| 55 content_setting_image_model->UpdateFromWebContents(contents()); | |
| 56 EXPECT_FALSE(content_setting_image_model->is_visible()); | |
| 57 | |
| 58 TabSpecificContentSettings* content_settings = | |
| 59 tab_contents()->content_settings(); | |
| 60 content_settings->set_pending_protocol_handler( | |
| 61 ProtocolHandler::CreateProtocolHandler( | |
| 62 "mailto", GURL("http://www.google.com/"), ASCIIToUTF16("Handler"))); | |
| 63 content_setting_image_model->UpdateFromWebContents(contents()); | |
| 64 EXPECT_TRUE(content_setting_image_model->is_visible()); | |
| 65 } | |
| 66 | |
| 67 TEST_F(ContentSettingImageModelTest, CookieAccessed) { | 50 TEST_F(ContentSettingImageModelTest, CookieAccessed) { |
| 68 TabSpecificContentSettings* content_settings = | 51 TabSpecificContentSettings* content_settings = |
| 69 tab_contents()->content_settings(); | 52 tab_contents()->content_settings(); |
| 70 profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( | 53 profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( |
| 71 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); | 54 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); |
| 72 scoped_ptr<ContentSettingImageModel> content_setting_image_model( | 55 scoped_ptr<ContentSettingImageModel> content_setting_image_model( |
| 73 ContentSettingImageModel::CreateContentSettingImageModel( | 56 ContentSettingImageModel::CreateContentSettingImageModel( |
| 74 CONTENT_SETTINGS_TYPE_COOKIES)); | 57 CONTENT_SETTINGS_TYPE_COOKIES)); |
| 75 EXPECT_FALSE(content_setting_image_model->is_visible()); | 58 EXPECT_FALSE(content_setting_image_model->is_visible()); |
| 76 EXPECT_EQ(0, content_setting_image_model->get_icon()); | 59 EXPECT_EQ(0, content_setting_image_model->get_icon()); |
| 77 EXPECT_TRUE(content_setting_image_model->get_tooltip().empty()); | 60 EXPECT_TRUE(content_setting_image_model->get_tooltip().empty()); |
| 78 | 61 |
| 79 net::CookieOptions options; | 62 net::CookieOptions options; |
| 80 content_settings->OnCookieChanged(GURL("http://google.com"), | 63 content_settings->OnCookieChanged(GURL("http://google.com"), |
| 81 GURL("http://google.com"), | 64 GURL("http://google.com"), |
| 82 "A=B", | 65 "A=B", |
| 83 options, | 66 options, |
| 84 false); | 67 false); |
| 85 content_setting_image_model->UpdateFromWebContents(contents()); | 68 content_setting_image_model->UpdateFromWebContents(contents()); |
| 86 EXPECT_TRUE(content_setting_image_model->is_visible()); | 69 EXPECT_TRUE(content_setting_image_model->is_visible()); |
| 87 EXPECT_NE(0, content_setting_image_model->get_icon()); | 70 EXPECT_NE(0, content_setting_image_model->get_icon()); |
| 88 EXPECT_FALSE(content_setting_image_model->get_tooltip().empty()); | 71 EXPECT_FALSE(content_setting_image_model->get_tooltip().empty()); |
| 89 } | 72 } |
| OLD | NEW |