| 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 "chrome/browser/ui/website_settings/website_settings.h" | 5 #include "chrome/browser/ui/website_settings/website_settings.h" | 
| 6 | 6 | 
| 7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" | 
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" | 
| 9 #include "base/string16.h" | 9 #include "base/string16.h" | 
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" | 
| 11 #include "chrome/browser/content_settings/content_settings_provider.h" | 11 #include "chrome/browser/content_settings/content_settings_provider.h" | 
| 12 #include "chrome/browser/content_settings/content_settings_utils.h" | 12 #include "chrome/browser/content_settings/content_settings_utils.h" | 
| 13 #include "chrome/browser/content_settings/host_content_settings_map.h" | 13 #include "chrome/browser/content_settings/host_content_settings_map.h" | 
| 14 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 14 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 
| 15 #include "chrome/browser/infobars/infobar_delegate.h" | 15 #include "chrome/browser/infobars/infobar_delegate.h" | 
| 16 #include "chrome/browser/infobars/infobar_service.h" | 16 #include "chrome/browser/infobars/infobar_service.h" | 
| 17 #include "chrome/browser/ui/website_settings/website_settings_ui.h" | 17 #include "chrome/browser/ui/website_settings/website_settings_ui.h" | 
| 18 #include "chrome/common/content_settings.h" | 18 #include "chrome/common/content_settings.h" | 
| 19 #include "chrome/common/content_settings_types.h" | 19 #include "chrome/common/content_settings_types.h" | 
| 20 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 20 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 
| 21 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" | 
| 22 #include "content/public/browser/cert_store.h" | 22 #include "content/public/browser/cert_store.h" | 
| 23 #include "content/public/common/ssl_status.h" | 23 #include "content/public/common/ssl_status.h" | 
| 24 #include "content/public/test/test_browser_thread.h" |  | 
| 25 #include "net/cert/cert_status_flags.h" | 24 #include "net/cert/cert_status_flags.h" | 
| 26 #include "net/cert/x509_certificate.h" | 25 #include "net/cert/x509_certificate.h" | 
| 27 #include "net/ssl/ssl_connection_status_flags.h" | 26 #include "net/ssl/ssl_connection_status_flags.h" | 
| 28 #include "net/test/test_certificate_data.h" | 27 #include "net/test/test_certificate_data.h" | 
| 29 #include "testing/gmock/include/gmock/gmock.h" | 28 #include "testing/gmock/include/gmock/gmock.h" | 
| 30 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" | 
| 31 | 30 | 
| 32 using content::SSLStatus; | 31 using content::SSLStatus; | 
| 33 using namespace testing; | 32 using testing::_; | 
|  | 33 using testing::AnyNumber; | 
|  | 34 using testing::Return; | 
|  | 35 using testing::SetArgPointee; | 
| 34 | 36 | 
| 35 namespace { | 37 namespace { | 
| 36 | 38 | 
| 37 // SSL cipher suite like specified in RFC5246 Appendix A.5. "The Cipher Suite". | 39 // SSL cipher suite like specified in RFC5246 Appendix A.5. "The Cipher Suite". | 
| 38 // Without the CR_ prefix, this clashes with the OS X 10.8 headers. | 40 // Without the CR_ prefix, this clashes with the OS X 10.8 headers. | 
| 39 int CR_TLS_RSA_WITH_AES_256_CBC_SHA256 = 0x3D; | 41 int CR_TLS_RSA_WITH_AES_256_CBC_SHA256 = 0x3D; | 
| 40 | 42 | 
| 41 int SetSSLVersion(int connection_status, int version) { | 43 int SetSSLVersion(int connection_status, int version) { | 
| 42   // Clear SSL version bits (Bits 20, 21 and 22). | 44   // Clear SSL version bits (Bits 20, 21 and 22). | 
| 43   connection_status &= | 45   connection_status &= | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 69   MOCK_METHOD1(SetFirstVisit, void(const string16& first_visit)); | 71   MOCK_METHOD1(SetFirstVisit, void(const string16& first_visit)); | 
| 70   MOCK_METHOD1(SetSelectedTab, void(TabId tab_id)); | 72   MOCK_METHOD1(SetSelectedTab, void(TabId tab_id)); | 
| 71 }; | 73 }; | 
| 72 | 74 | 
| 73 class WebsiteSettingsTest : public ChromeRenderViewHostTestHarness { | 75 class WebsiteSettingsTest : public ChromeRenderViewHostTestHarness { | 
| 74  public: | 76  public: | 
| 75   WebsiteSettingsTest() | 77   WebsiteSettingsTest() | 
| 76       : website_settings_(NULL), | 78       : website_settings_(NULL), | 
| 77         mock_ui_(NULL), | 79         mock_ui_(NULL), | 
| 78         cert_id_(0), | 80         cert_id_(0), | 
| 79         browser_thread_(content::BrowserThread::UI, &message_loop_), |  | 
| 80         url_("http://www.example.com") { | 81         url_("http://www.example.com") { | 
| 81   } | 82   } | 
| 82 | 83 | 
| 83   virtual ~WebsiteSettingsTest() { | 84   virtual ~WebsiteSettingsTest() { | 
| 84   } | 85   } | 
| 85 | 86 | 
| 86   virtual void SetUp() { | 87   virtual void SetUp() { | 
| 87     ChromeRenderViewHostTestHarness::SetUp(); | 88     ChromeRenderViewHostTestHarness::SetUp(); | 
| 88     // Setup stub SSLStatus. | 89     // Setup stub SSLStatus. | 
| 89     ssl_.security_style = content::SECURITY_STYLE_UNAUTHENTICATED; | 90     ssl_.security_style = content::SECURITY_STYLE_UNAUTHENTICATED; | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 146     return website_settings_.get(); | 147     return website_settings_.get(); | 
| 147   } | 148   } | 
| 148 | 149 | 
| 149   SSLStatus ssl_; | 150   SSLStatus ssl_; | 
| 150 | 151 | 
| 151  private: | 152  private: | 
| 152   scoped_ptr<WebsiteSettings> website_settings_; | 153   scoped_ptr<WebsiteSettings> website_settings_; | 
| 153   scoped_ptr<MockWebsiteSettingsUI> mock_ui_; | 154   scoped_ptr<MockWebsiteSettingsUI> mock_ui_; | 
| 154   int cert_id_; | 155   int cert_id_; | 
| 155   scoped_refptr<net::X509Certificate> cert_; | 156   scoped_refptr<net::X509Certificate> cert_; | 
| 156   content::TestBrowserThread browser_thread_; |  | 
| 157   MockCertStore cert_store_; | 157   MockCertStore cert_store_; | 
| 158   GURL url_; | 158   GURL url_; | 
| 159 }; | 159 }; | 
| 160 | 160 | 
| 161 }  // namespace | 161 }  // namespace | 
| 162 | 162 | 
| 163 TEST_F(WebsiteSettingsTest, OnPermissionsChanged) { | 163 TEST_F(WebsiteSettingsTest, OnPermissionsChanged) { | 
| 164   // Setup site permissions. | 164   // Setup site permissions. | 
| 165   HostContentSettingsMap* content_settings = | 165   HostContentSettingsMap* content_settings = | 
| 166       profile()->GetHostContentSettingsMap(); | 166       profile()->GetHostContentSettingsMap(); | 
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 395       CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ALLOW); | 395       CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ALLOW); | 
| 396   website_settings()->OnUIClosing(); | 396   website_settings()->OnUIClosing(); | 
| 397   EXPECT_EQ(1u, infobar_service()->infobar_count()); | 397   EXPECT_EQ(1u, infobar_service()->infobar_count()); | 
| 398 | 398 | 
| 399   // Removing an |InfoBarDelegate| from the |InfoBarService| does not delete | 399   // Removing an |InfoBarDelegate| from the |InfoBarService| does not delete | 
| 400   // it. Hence the |delegate| must be cleaned up after it was removed from the | 400   // it. Hence the |delegate| must be cleaned up after it was removed from the | 
| 401   // |infobar_service|. | 401   // |infobar_service|. | 
| 402   scoped_ptr<InfoBarDelegate> delegate(infobar_service()->infobar_at(0)); | 402   scoped_ptr<InfoBarDelegate> delegate(infobar_service()->infobar_at(0)); | 
| 403   infobar_service()->RemoveInfoBar(delegate.get()); | 403   infobar_service()->RemoveInfoBar(delegate.get()); | 
| 404 } | 404 } | 
| OLD | NEW | 
|---|