| 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" | 5 #include "base/utf_string_conversions.h" |
| 6 #include "chrome/browser/content_settings/host_content_settings_map.h" | 6 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 7 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 7 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 8 #include "chrome/browser/prerender/prerender_manager.h" | 8 #include "chrome/browser/prerender/prerender_manager.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" | 10 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
| 11 #include "chrome/common/chrome_notification_types.h" | 11 #include "chrome/common/chrome_notification_types.h" |
| 12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
| 13 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 13 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 14 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
| 16 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
| 17 #include "content/public/test/test_browser_thread.h" | |
| 18 #include "content/public/test/test_renderer_host.h" | 17 #include "content/public/test/test_renderer_host.h" |
| 19 #include "net/cookies/cookie_options.h" | 18 #include "net/cookies/cookie_options.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 20 |
| 22 namespace { | 21 namespace { |
| 23 | 22 |
| 24 // Forward all NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED to the specified | 23 // Forward all NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED to the specified |
| 25 // ContentSettingImageModel. | 24 // ContentSettingImageModel. |
| 26 class NotificationForwarder : public content::NotificationObserver { | 25 class NotificationForwarder : public content::NotificationObserver { |
| 27 public: | 26 public: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 47 } | 46 } |
| 48 | 47 |
| 49 private: | 48 private: |
| 50 content::NotificationRegistrar registrar_; | 49 content::NotificationRegistrar registrar_; |
| 51 ContentSettingImageModel* model_; | 50 ContentSettingImageModel* model_; |
| 52 | 51 |
| 53 DISALLOW_COPY_AND_ASSIGN(NotificationForwarder); | 52 DISALLOW_COPY_AND_ASSIGN(NotificationForwarder); |
| 54 }; | 53 }; |
| 55 | 54 |
| 56 class ContentSettingImageModelTest : public ChromeRenderViewHostTestHarness { | 55 class ContentSettingImageModelTest : public ChromeRenderViewHostTestHarness { |
| 57 public: | |
| 58 ContentSettingImageModelTest() | |
| 59 : ui_thread_(content::BrowserThread::UI, &message_loop_) {} | |
| 60 | |
| 61 private: | |
| 62 content::TestBrowserThread ui_thread_; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageModelTest); | |
| 65 }; | 56 }; |
| 66 | 57 |
| 67 TEST_F(ContentSettingImageModelTest, UpdateFromWebContents) { | 58 TEST_F(ContentSettingImageModelTest, UpdateFromWebContents) { |
| 68 TabSpecificContentSettings::CreateForWebContents(web_contents()); | 59 TabSpecificContentSettings::CreateForWebContents(web_contents()); |
| 69 TabSpecificContentSettings* content_settings = | 60 TabSpecificContentSettings* content_settings = |
| 70 TabSpecificContentSettings::FromWebContents(web_contents()); | 61 TabSpecificContentSettings::FromWebContents(web_contents()); |
| 71 scoped_ptr<ContentSettingImageModel> content_setting_image_model( | 62 scoped_ptr<ContentSettingImageModel> content_setting_image_model( |
| 72 ContentSettingImageModel::CreateContentSettingImageModel( | 63 ContentSettingImageModel::CreateContentSettingImageModel( |
| 73 CONTENT_SETTINGS_TYPE_IMAGES)); | 64 CONTENT_SETTINGS_TYPE_IMAGES)); |
| 74 EXPECT_FALSE(content_setting_image_model->is_visible()); | 65 EXPECT_FALSE(content_setting_image_model->is_visible()); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 scoped_ptr<ContentSettingImageModel> content_setting_image_model( | 122 scoped_ptr<ContentSettingImageModel> content_setting_image_model( |
| 132 ContentSettingImageModel::CreateContentSettingImageModel( | 123 ContentSettingImageModel::CreateContentSettingImageModel( |
| 133 CONTENT_SETTINGS_TYPE_IMAGES)); | 124 CONTENT_SETTINGS_TYPE_IMAGES)); |
| 134 NotificationForwarder forwarder(content_setting_image_model.get()); | 125 NotificationForwarder forwarder(content_setting_image_model.get()); |
| 135 // Should not crash. | 126 // Should not crash. |
| 136 TabSpecificContentSettings::CreateForWebContents(web_contents()); | 127 TabSpecificContentSettings::CreateForWebContents(web_contents()); |
| 137 forwarder.clear(); | 128 forwarder.clear(); |
| 138 } | 129 } |
| 139 | 130 |
| 140 } // namespace | 131 } // namespace |
| OLD | NEW |