| 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/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "chrome/browser/chrome_notification_types.h" | 6 #include "chrome/browser/chrome_notification_types.h" |
| 7 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 7 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 8 #include "chrome/browser/prerender/prerender_manager.h" | 9 #include "chrome/browser/prerender/prerender_manager.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" | 11 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
| 11 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 12 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 12 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
| 13 #include "components/content_settings/core/browser/host_content_settings_map.h" | 14 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 14 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 16 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 ProtocolHandler::CreateProtocolHandler( | 89 ProtocolHandler::CreateProtocolHandler( |
| 89 "mailto", GURL("http://www.google.com/"))); | 90 "mailto", GURL("http://www.google.com/"))); |
| 90 content_setting_image_model->UpdateFromWebContents(web_contents()); | 91 content_setting_image_model->UpdateFromWebContents(web_contents()); |
| 91 EXPECT_TRUE(content_setting_image_model->is_visible()); | 92 EXPECT_TRUE(content_setting_image_model->is_visible()); |
| 92 } | 93 } |
| 93 | 94 |
| 94 TEST_F(ContentSettingImageModelTest, CookieAccessed) { | 95 TEST_F(ContentSettingImageModelTest, CookieAccessed) { |
| 95 TabSpecificContentSettings::CreateForWebContents(web_contents()); | 96 TabSpecificContentSettings::CreateForWebContents(web_contents()); |
| 96 TabSpecificContentSettings* content_settings = | 97 TabSpecificContentSettings* content_settings = |
| 97 TabSpecificContentSettings::FromWebContents(web_contents()); | 98 TabSpecificContentSettings::FromWebContents(web_contents()); |
| 98 profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( | 99 HostContentSettingsMapFactory::GetForProfile(profile()) |
| 99 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); | 100 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, |
| 101 CONTENT_SETTING_BLOCK); |
| 100 scoped_ptr<ContentSettingImageModel> content_setting_image_model( | 102 scoped_ptr<ContentSettingImageModel> content_setting_image_model( |
| 101 ContentSettingImageModel::CreateContentSettingImageModel( | 103 ContentSettingImageModel::CreateContentSettingImageModel( |
| 102 CONTENT_SETTINGS_TYPE_COOKIES)); | 104 CONTENT_SETTINGS_TYPE_COOKIES)); |
| 103 EXPECT_FALSE(content_setting_image_model->is_visible()); | 105 EXPECT_FALSE(content_setting_image_model->is_visible()); |
| 104 EXPECT_TRUE(content_setting_image_model->icon().IsEmpty()); | 106 EXPECT_TRUE(content_setting_image_model->icon().IsEmpty()); |
| 105 EXPECT_TRUE(content_setting_image_model->get_tooltip().empty()); | 107 EXPECT_TRUE(content_setting_image_model->get_tooltip().empty()); |
| 106 | 108 |
| 107 net::CookieOptions options; | 109 net::CookieOptions options; |
| 108 content_settings->OnCookieChanged(GURL("http://google.com"), | 110 content_settings->OnCookieChanged(GURL("http://google.com"), |
| 109 GURL("http://google.com"), | 111 GURL("http://google.com"), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 121 scoped_ptr<ContentSettingImageModel> content_setting_image_model( | 123 scoped_ptr<ContentSettingImageModel> content_setting_image_model( |
| 122 ContentSettingImageModel::CreateContentSettingImageModel( | 124 ContentSettingImageModel::CreateContentSettingImageModel( |
| 123 CONTENT_SETTINGS_TYPE_IMAGES)); | 125 CONTENT_SETTINGS_TYPE_IMAGES)); |
| 124 NotificationForwarder forwarder(content_setting_image_model.get()); | 126 NotificationForwarder forwarder(content_setting_image_model.get()); |
| 125 // Should not crash. | 127 // Should not crash. |
| 126 TabSpecificContentSettings::CreateForWebContents(web_contents()); | 128 TabSpecificContentSettings::CreateForWebContents(web_contents()); |
| 127 forwarder.clear(); | 129 forwarder.clear(); |
| 128 } | 130 } |
| 129 | 131 |
| 130 } // namespace | 132 } // namespace |
| OLD | NEW |