Index: chrome/browser/ui/page_info/page_info_unittest.cc |
diff --git a/chrome/browser/ui/page_info/website_settings_unittest.cc b/chrome/browser/ui/page_info/page_info_unittest.cc |
similarity index 64% |
rename from chrome/browser/ui/page_info/website_settings_unittest.cc |
rename to chrome/browser/ui/page_info/page_info_unittest.cc |
index efcb7a626061af9fd642942091ad604be291e5a3..7ede55e2f4f63bf4cd4309551475d5b20462d712 100644 |
--- a/chrome/browser/ui/page_info/website_settings_unittest.cc |
+++ b/chrome/browser/ui/page_info/page_info_unittest.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/ui/page_info/website_settings.h" |
+#include "chrome/browser/ui/page_info/page_info.h" |
#include <string> |
#include <vector> |
@@ -17,7 +17,7 @@ |
#include "build/build_config.h" |
#include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
#include "chrome/browser/infobars/infobar_service.h" |
-#include "chrome/browser/ui/page_info/website_settings_ui.h" |
+#include "chrome/browser/ui/page_info/page_info_ui.h" |
#include "chrome/browser/usb/usb_chooser_context.h" |
#include "chrome/browser/usb/usb_chooser_context_factory.h" |
#include "chrome/grit/theme_resources.h" |
@@ -68,9 +68,9 @@ int SetSSLCipherSuite(int connection_status, int cipher_suite) { |
return cipher_suite | connection_status; |
} |
-class MockWebsiteSettingsUI : public WebsiteSettingsUI { |
+class MockPageInfoUI : public PageInfoUI { |
public: |
- virtual ~MockWebsiteSettingsUI() {} |
+ virtual ~MockPageInfoUI() {} |
MOCK_METHOD1(SetCookieInfo, void(const CookieInfoList& cookie_info_list)); |
MOCK_METHOD0(SetPermissionInfoStub, void()); |
MOCK_METHOD1(SetIdentityInfo, void(const IdentityInfo& identity_info)); |
@@ -90,11 +90,11 @@ class MockWebsiteSettingsUI : public WebsiteSettingsUI { |
set_permission_info_callback_; |
}; |
-class WebsiteSettingsTest : public ChromeRenderViewHostTestHarness { |
+class PageInfoTest : public ChromeRenderViewHostTestHarness { |
public: |
- WebsiteSettingsTest() : url_("http://www.example.com") {} |
+ PageInfoTest() : url_("http://www.example.com") {} |
- ~WebsiteSettingsTest() override {} |
+ ~PageInfoTest() override {} |
void SetUp() override { |
ChromeRenderViewHostTestHarness::SetUp(); |
@@ -111,22 +111,21 @@ class WebsiteSettingsTest : public ChromeRenderViewHostTestHarness { |
InfoBarService::CreateForWebContents(web_contents()); |
// Setup mock ui. |
- mock_ui_.reset(new MockWebsiteSettingsUI()); |
+ mock_ui_.reset(new MockPageInfoUI()); |
// Use this rather than gmock's ON_CALL.WillByDefault(Invoke(... because |
// gmock doesn't handle move-only types well. |
- mock_ui_->set_permission_info_callback_ = base::Bind( |
- &WebsiteSettingsTest::SetPermissionInfo, base::Unretained(this)); |
+ mock_ui_->set_permission_info_callback_ = |
+ base::Bind(&PageInfoTest::SetPermissionInfo, base::Unretained(this)); |
} |
void TearDown() override { |
- ASSERT_TRUE(website_settings_.get()) |
- << "No WebsiteSettings instance created."; |
+ ASSERT_TRUE(page_info_.get()) << "No PageInfo instance created."; |
RenderViewHostTestHarness::TearDown(); |
- website_settings_.reset(); |
+ page_info_.reset(); |
} |
- void SetDefaultUIExpectations(MockWebsiteSettingsUI* mock_ui) { |
- // During creation |WebsiteSettings| makes the following calls to the ui. |
+ void SetDefaultUIExpectations(MockPageInfoUI* mock_ui) { |
+ // During creation |PageInfo| makes the following calls to the ui. |
EXPECT_CALL(*mock_ui, SetPermissionInfoStub()); |
EXPECT_CALL(*mock_ui, SetIdentityInfo(_)); |
EXPECT_CALL(*mock_ui, SetCookieInfo(_)); |
@@ -141,15 +140,15 @@ class WebsiteSettingsTest : public ChromeRenderViewHostTestHarness { |
last_chosen_object_info_.push_back(std::move(chosen_object_info)); |
} |
- void ResetMockUI() { mock_ui_.reset(new MockWebsiteSettingsUI()); } |
+ void ResetMockUI() { mock_ui_.reset(new MockPageInfoUI()); } |
- void ClearWebsiteSettings() { website_settings_.reset(nullptr); } |
+ void ClearPageInfo() { page_info_.reset(nullptr); } |
const GURL& url() const { return url_; } |
scoped_refptr<net::X509Certificate> cert() { return cert_; } |
- MockWebsiteSettingsUI* mock_ui() { return mock_ui_.get(); } |
+ MockPageInfoUI* mock_ui() { return mock_ui_.get(); } |
const security_state::SecurityInfo& security_info() { return security_info_; } |
- const std::vector<std::unique_ptr<WebsiteSettingsUI::ChosenObjectInfo>>& |
+ const std::vector<std::unique_ptr<PageInfoUI::ChosenObjectInfo>>& |
last_chosen_object_info() { |
return last_chosen_object_info_; |
} |
@@ -160,13 +159,13 @@ class WebsiteSettingsTest : public ChromeRenderViewHostTestHarness { |
return InfoBarService::FromWebContents(web_contents()); |
} |
- WebsiteSettings* website_settings() { |
- if (!website_settings_.get()) { |
- website_settings_.reset(new WebsiteSettings( |
- mock_ui(), profile(), tab_specific_content_settings(), web_contents(), |
- url(), security_info())); |
+ PageInfo* page_info() { |
+ if (!page_info_.get()) { |
+ page_info_.reset(new PageInfo(mock_ui(), profile(), |
+ tab_specific_content_settings(), |
+ web_contents(), url(), security_info())); |
} |
- return website_settings_.get(); |
+ return page_info_.get(); |
} |
device::MockUsbService& usb_service() { |
@@ -177,17 +176,17 @@ class WebsiteSettingsTest : public ChromeRenderViewHostTestHarness { |
private: |
device::MockDeviceClient device_client_; |
- std::unique_ptr<WebsiteSettings> website_settings_; |
- std::unique_ptr<MockWebsiteSettingsUI> mock_ui_; |
+ std::unique_ptr<PageInfo> page_info_; |
+ std::unique_ptr<MockPageInfoUI> mock_ui_; |
scoped_refptr<net::X509Certificate> cert_; |
GURL url_; |
- std::vector<std::unique_ptr<WebsiteSettingsUI::ChosenObjectInfo>> |
+ std::vector<std::unique_ptr<PageInfoUI::ChosenObjectInfo>> |
last_chosen_object_info_; |
}; |
} // namespace |
-TEST_F(WebsiteSettingsTest, OnPermissionsChanged) { |
+TEST_F(PageInfoTest, OnPermissionsChanged) { |
// Setup site permissions. |
HostContentSettingsMap* content_settings = |
HostContentSettingsMapFactory::GetForProfile(profile()); |
@@ -225,20 +224,20 @@ TEST_F(WebsiteSettingsTest, OnPermissionsChanged) { |
#endif |
// Execute code under tests. |
- website_settings()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_POPUPS, |
- CONTENT_SETTING_ALLOW); |
+ page_info()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_POPUPS, |
+ CONTENT_SETTING_ALLOW); |
#if BUILDFLAG(ENABLE_PLUGINS) |
- website_settings()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_PLUGINS, |
- CONTENT_SETTING_BLOCK); |
+ page_info()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_PLUGINS, |
+ CONTENT_SETTING_BLOCK); |
#endif |
- website_settings()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_GEOLOCATION, |
- CONTENT_SETTING_ALLOW); |
- website_settings()->OnSitePermissionChanged( |
- CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTING_ALLOW); |
- website_settings()->OnSitePermissionChanged( |
- CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, CONTENT_SETTING_ALLOW); |
- website_settings()->OnSitePermissionChanged( |
- CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, CONTENT_SETTING_ALLOW); |
+ page_info()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_GEOLOCATION, |
+ CONTENT_SETTING_ALLOW); |
+ page_info()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
+ CONTENT_SETTING_ALLOW); |
+ page_info()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, |
+ CONTENT_SETTING_ALLOW); |
+ page_info()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, |
+ CONTENT_SETTING_ALLOW); |
// Verify that the site permissions were changed correctly. |
setting = content_settings->GetContentSetting( |
@@ -263,15 +262,15 @@ TEST_F(WebsiteSettingsTest, OnPermissionsChanged) { |
EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); |
} |
-TEST_F(WebsiteSettingsTest, OnSiteDataAccessed) { |
+TEST_F(PageInfoTest, OnSiteDataAccessed) { |
EXPECT_CALL(*mock_ui(), SetPermissionInfoStub()); |
EXPECT_CALL(*mock_ui(), SetIdentityInfo(_)); |
EXPECT_CALL(*mock_ui(), SetCookieInfo(_)).Times(2); |
- website_settings()->OnSiteDataAccessed(); |
+ page_info()->OnSiteDataAccessed(); |
} |
-TEST_F(WebsiteSettingsTest, OnChosenObjectDeleted) { |
+TEST_F(PageInfoTest, OnChosenObjectDeleted) { |
scoped_refptr<device::UsbDevice> device = |
new device::MockUsbDevice(0, 0, "Google", "Gizmo", "1234567890"); |
usb_service().AddDevice(device); |
@@ -281,67 +280,66 @@ TEST_F(WebsiteSettingsTest, OnChosenObjectDeleted) { |
EXPECT_CALL(*mock_ui(), SetIdentityInfo(_)); |
EXPECT_CALL(*mock_ui(), SetCookieInfo(_)); |
- // Access WebsiteSettings so that SetPermissionInfo is called once to populate |
+ // Access PageInfo so that SetPermissionInfo is called once to populate |
// |last_chosen_object_info_|. It will be called again by |
// OnSiteChosenObjectDeleted. |
EXPECT_CALL(*mock_ui(), SetPermissionInfoStub()).Times(2); |
- website_settings(); |
+ page_info(); |
ASSERT_EQ(1u, last_chosen_object_info().size()); |
- const WebsiteSettingsUI::ChosenObjectInfo* info = |
- last_chosen_object_info()[0].get(); |
- website_settings()->OnSiteChosenObjectDeleted(info->ui_info, *info->object); |
+ const PageInfoUI::ChosenObjectInfo* info = last_chosen_object_info()[0].get(); |
+ page_info()->OnSiteChosenObjectDeleted(info->ui_info, *info->object); |
EXPECT_FALSE(store->HasDevicePermission(url(), url(), device)); |
EXPECT_EQ(0u, last_chosen_object_info().size()); |
} |
-TEST_F(WebsiteSettingsTest, Malware) { |
+TEST_F(PageInfoTest, Malware) { |
security_info_.security_level = security_state::DANGEROUS; |
security_info_.malicious_content_status = |
security_state::MALICIOUS_CONTENT_STATUS_MALWARE; |
SetDefaultUIExpectations(mock_ui()); |
- EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_UNENCRYPTED, |
- website_settings()->site_connection_status()); |
- EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_MALWARE, |
- website_settings()->site_identity_status()); |
+ EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_UNENCRYPTED, |
+ page_info()->site_connection_status()); |
+ EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_MALWARE, |
+ page_info()->site_identity_status()); |
} |
-TEST_F(WebsiteSettingsTest, SocialEngineering) { |
+TEST_F(PageInfoTest, SocialEngineering) { |
security_info_.security_level = security_state::DANGEROUS; |
security_info_.malicious_content_status = |
security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING; |
SetDefaultUIExpectations(mock_ui()); |
- EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_UNENCRYPTED, |
- website_settings()->site_connection_status()); |
- EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING, |
- website_settings()->site_identity_status()); |
+ EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_UNENCRYPTED, |
+ page_info()->site_connection_status()); |
+ EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING, |
+ page_info()->site_identity_status()); |
} |
-TEST_F(WebsiteSettingsTest, UnwantedSoftware) { |
+TEST_F(PageInfoTest, UnwantedSoftware) { |
security_info_.security_level = security_state::DANGEROUS; |
security_info_.malicious_content_status = |
security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE; |
SetDefaultUIExpectations(mock_ui()); |
- EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_UNENCRYPTED, |
- website_settings()->site_connection_status()); |
- EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE, |
- website_settings()->site_identity_status()); |
+ EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_UNENCRYPTED, |
+ page_info()->site_connection_status()); |
+ EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE, |
+ page_info()->site_identity_status()); |
} |
-TEST_F(WebsiteSettingsTest, HTTPConnection) { |
+TEST_F(PageInfoTest, HTTPConnection) { |
SetDefaultUIExpectations(mock_ui()); |
- EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_UNENCRYPTED, |
- website_settings()->site_connection_status()); |
- EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_NO_CERT, |
- website_settings()->site_identity_status()); |
- EXPECT_EQ(base::string16(), website_settings()->organization_name()); |
+ EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_UNENCRYPTED, |
+ page_info()->site_connection_status()); |
+ EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_NO_CERT, |
+ page_info()->site_identity_status()); |
+ EXPECT_EQ(base::string16(), page_info()->organization_name()); |
} |
-TEST_F(WebsiteSettingsTest, HTTPSConnection) { |
+TEST_F(PageInfoTest, HTTPSConnection) { |
security_info_.security_level = security_state::SECURE; |
security_info_.scheme_is_cryptographic = true; |
security_info_.certificate = cert(); |
@@ -354,21 +352,21 @@ TEST_F(WebsiteSettingsTest, HTTPSConnection) { |
SetDefaultUIExpectations(mock_ui()); |
- EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED, |
- website_settings()->site_connection_status()); |
- EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_CERT, |
- website_settings()->site_identity_status()); |
- EXPECT_EQ(base::string16(), website_settings()->organization_name()); |
+ EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_ENCRYPTED, |
+ page_info()->site_connection_status()); |
+ EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_CERT, |
+ page_info()->site_identity_status()); |
+ EXPECT_EQ(base::string16(), page_info()->organization_name()); |
} |
-TEST_F(WebsiteSettingsTest, InsecureContent) { |
+TEST_F(PageInfoTest, InsecureContent) { |
struct TestCase { |
security_state::SecurityLevel security_level; |
net::CertStatus cert_status; |
security_state::ContentStatus mixed_content_status; |
security_state::ContentStatus content_with_cert_errors_status; |
- WebsiteSettings::SiteConnectionStatus expected_site_connection_status; |
- WebsiteSettings::SiteIdentityStatus expected_site_identity_status; |
+ PageInfo::SiteConnectionStatus expected_site_connection_status; |
+ PageInfo::SiteIdentityStatus expected_site_identity_status; |
int expected_connection_icon_id; |
}; |
@@ -376,43 +374,43 @@ TEST_F(WebsiteSettingsTest, InsecureContent) { |
// Passive mixed content. |
{security_state::NONE, 0, security_state::CONTENT_STATUS_DISPLAYED, |
security_state::CONTENT_STATUS_NONE, |
- WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, |
- WebsiteSettings::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_WARNING_MINOR}, |
+ PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, |
+ PageInfo::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_WARNING_MINOR}, |
// Passive mixed content with a cert error on the main resource. |
{security_state::DANGEROUS, net::CERT_STATUS_DATE_INVALID, |
security_state::CONTENT_STATUS_DISPLAYED, |
security_state::CONTENT_STATUS_NONE, |
- WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, |
- WebsiteSettings::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_WARNING_MINOR}, |
+ PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, |
+ PageInfo::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_WARNING_MINOR}, |
// Active and passive mixed content. |
{security_state::DANGEROUS, 0, |
security_state::CONTENT_STATUS_DISPLAYED_AND_RAN, |
security_state::CONTENT_STATUS_NONE, |
- WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
- WebsiteSettings::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, |
+ PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
+ PageInfo::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, |
// Active and passive mixed content with a cert error on the main |
// resource. |
{security_state::DANGEROUS, net::CERT_STATUS_DATE_INVALID, |
security_state::CONTENT_STATUS_DISPLAYED_AND_RAN, |
security_state::CONTENT_STATUS_NONE, |
- WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
- WebsiteSettings::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_BAD}, |
+ PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
+ PageInfo::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_BAD}, |
// Active mixed content. |
{security_state::DANGEROUS, 0, security_state::CONTENT_STATUS_RAN, |
security_state::CONTENT_STATUS_NONE, |
- WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
- WebsiteSettings::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, |
+ PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
+ PageInfo::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, |
// Active mixed content with a cert error on the main resource. |
{security_state::DANGEROUS, net::CERT_STATUS_DATE_INVALID, |
security_state::CONTENT_STATUS_RAN, security_state::CONTENT_STATUS_NONE, |
- WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
- WebsiteSettings::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_BAD}, |
+ PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
+ PageInfo::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_BAD}, |
// Passive subresources with cert errors. |
{security_state::NONE, 0, security_state::CONTENT_STATUS_NONE, |
security_state::CONTENT_STATUS_DISPLAYED, |
- WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, |
- WebsiteSettings::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_WARNING_MINOR}, |
+ PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, |
+ PageInfo::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_WARNING_MINOR}, |
// Passive subresources with cert errors, with a cert error on the |
// main resource also. In this case, the subresources with |
// certificate errors are ignored: if the main resource had a cert |
@@ -421,59 +419,59 @@ TEST_F(WebsiteSettingsTest, InsecureContent) { |
{security_state::DANGEROUS, net::CERT_STATUS_DATE_INVALID, |
security_state::CONTENT_STATUS_NONE, |
security_state::CONTENT_STATUS_DISPLAYED, |
- WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED, |
- WebsiteSettings::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_GOOD}, |
+ PageInfo::SITE_CONNECTION_STATUS_ENCRYPTED, |
+ PageInfo::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_GOOD}, |
// Passive and active subresources with cert errors. |
{security_state::DANGEROUS, 0, security_state::CONTENT_STATUS_NONE, |
security_state::CONTENT_STATUS_DISPLAYED_AND_RAN, |
- WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
- WebsiteSettings::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, |
+ PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
+ PageInfo::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, |
// Passive and active subresources with cert errors, with a cert |
// error on the main resource also. |
{security_state::DANGEROUS, net::CERT_STATUS_DATE_INVALID, |
security_state::CONTENT_STATUS_NONE, |
security_state::CONTENT_STATUS_DISPLAYED_AND_RAN, |
- WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED, |
- WebsiteSettings::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_GOOD}, |
+ PageInfo::SITE_CONNECTION_STATUS_ENCRYPTED, |
+ PageInfo::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_GOOD}, |
// Active subresources with cert errors. |
{security_state::DANGEROUS, 0, security_state::CONTENT_STATUS_NONE, |
security_state::CONTENT_STATUS_RAN, |
- WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
- WebsiteSettings::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, |
+ PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
+ PageInfo::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, |
// Active subresources with cert errors, with a cert error on the main |
// resource also. |
{security_state::DANGEROUS, net::CERT_STATUS_DATE_INVALID, |
security_state::CONTENT_STATUS_NONE, security_state::CONTENT_STATUS_RAN, |
- WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED, |
- WebsiteSettings::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_GOOD}, |
+ PageInfo::SITE_CONNECTION_STATUS_ENCRYPTED, |
+ PageInfo::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_GOOD}, |
// Passive mixed content and subresources with cert errors. |
{security_state::NONE, 0, security_state::CONTENT_STATUS_DISPLAYED, |
security_state::CONTENT_STATUS_DISPLAYED, |
- WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, |
- WebsiteSettings::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_WARNING_MINOR}, |
+ PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, |
+ PageInfo::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_WARNING_MINOR}, |
// Passive mixed content and active subresources with cert errors. |
{security_state::DANGEROUS, 0, security_state::CONTENT_STATUS_DISPLAYED, |
security_state::CONTENT_STATUS_RAN, |
- WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
- WebsiteSettings::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, |
+ PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
+ PageInfo::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, |
// Active mixed content and passive subresources with cert errors. |
{security_state::DANGEROUS, 0, security_state::CONTENT_STATUS_RAN, |
security_state::CONTENT_STATUS_DISPLAYED, |
- WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
- WebsiteSettings::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, |
+ PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
+ PageInfo::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, |
// Passive mixed content, active subresources with cert errors, and a cert |
// error on the main resource. |
{security_state::DANGEROUS, net::CERT_STATUS_DATE_INVALID, |
security_state::CONTENT_STATUS_DISPLAYED, |
security_state::CONTENT_STATUS_RAN, |
- WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, |
- WebsiteSettings::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_WARNING_MINOR}, |
+ PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, |
+ PageInfo::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_WARNING_MINOR}, |
}; |
for (const auto& test : kTestCases) { |
ResetMockUI(); |
- ClearWebsiteSettings(); |
+ ClearPageInfo(); |
security_info_ = security_state::SecurityInfo(); |
security_info_.security_level = test.security_level; |
security_info_.scheme_is_cryptographic = true; |
@@ -491,17 +489,17 @@ TEST_F(WebsiteSettingsTest, InsecureContent) { |
SetDefaultUIExpectations(mock_ui()); |
EXPECT_EQ(test.expected_site_connection_status, |
- website_settings()->site_connection_status()); |
+ page_info()->site_connection_status()); |
EXPECT_EQ(test.expected_site_identity_status, |
- website_settings()->site_identity_status()); |
- EXPECT_EQ(test.expected_connection_icon_id, |
- WebsiteSettingsUI::GetConnectionIconID( |
- website_settings()->site_connection_status())); |
- EXPECT_EQ(base::string16(), website_settings()->organization_name()); |
+ page_info()->site_identity_status()); |
+ EXPECT_EQ( |
+ test.expected_connection_icon_id, |
+ PageInfoUI::GetConnectionIconID(page_info()->site_connection_status())); |
+ EXPECT_EQ(base::string16(), page_info()->organization_name()); |
} |
} |
-TEST_F(WebsiteSettingsTest, HTTPSEVCert) { |
+TEST_F(PageInfoTest, HTTPSEVCert) { |
scoped_refptr<net::X509Certificate> ev_cert = |
net::X509Certificate::CreateFromBytes( |
reinterpret_cast<const char*>(google_der), sizeof(google_der)); |
@@ -521,16 +519,14 @@ TEST_F(WebsiteSettingsTest, HTTPSEVCert) { |
SetDefaultUIExpectations(mock_ui()); |
- EXPECT_EQ( |
- WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, |
- website_settings()->site_connection_status()); |
- EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT, |
- website_settings()->site_identity_status()); |
- EXPECT_EQ(base::UTF8ToUTF16("Google Inc"), |
- website_settings()->organization_name()); |
+ EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, |
+ page_info()->site_connection_status()); |
+ EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_EV_CERT, |
+ page_info()->site_identity_status()); |
+ EXPECT_EQ(base::UTF8ToUTF16("Google Inc"), page_info()->organization_name()); |
} |
-TEST_F(WebsiteSettingsTest, HTTPSRevocationError) { |
+TEST_F(PageInfoTest, HTTPSRevocationError) { |
security_info_.security_level = security_state::SECURE; |
security_info_.scheme_is_cryptographic = true; |
security_info_.certificate = cert(); |
@@ -543,14 +539,14 @@ TEST_F(WebsiteSettingsTest, HTTPSRevocationError) { |
SetDefaultUIExpectations(mock_ui()); |
- EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED, |
- website_settings()->site_connection_status()); |
- EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN, |
- website_settings()->site_identity_status()); |
- EXPECT_EQ(base::string16(), website_settings()->organization_name()); |
+ EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_ENCRYPTED, |
+ page_info()->site_connection_status()); |
+ EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN, |
+ page_info()->site_identity_status()); |
+ EXPECT_EQ(base::string16(), page_info()->organization_name()); |
} |
-TEST_F(WebsiteSettingsTest, HTTPSConnectionError) { |
+TEST_F(PageInfoTest, HTTPSConnectionError) { |
security_info_.security_level = security_state::SECURE; |
security_info_.scheme_is_cryptographic = true; |
security_info_.certificate = cert(); |
@@ -563,14 +559,14 @@ TEST_F(WebsiteSettingsTest, HTTPSConnectionError) { |
SetDefaultUIExpectations(mock_ui()); |
- EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED_ERROR, |
- website_settings()->site_connection_status()); |
- EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_CERT, |
- website_settings()->site_identity_status()); |
- EXPECT_EQ(base::string16(), website_settings()->organization_name()); |
+ EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_ENCRYPTED_ERROR, |
+ page_info()->site_connection_status()); |
+ EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_CERT, |
+ page_info()->site_identity_status()); |
+ EXPECT_EQ(base::string16(), page_info()->organization_name()); |
} |
-TEST_F(WebsiteSettingsTest, HTTPSPolicyCertConnection) { |
+TEST_F(PageInfoTest, HTTPSPolicyCertConnection) { |
security_info_.security_level = |
security_state::SECURE_WITH_POLICY_INSTALLED_CERT; |
security_info_.scheme_is_cryptographic = true; |
@@ -584,14 +580,14 @@ TEST_F(WebsiteSettingsTest, HTTPSPolicyCertConnection) { |
SetDefaultUIExpectations(mock_ui()); |
- EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED, |
- website_settings()->site_connection_status()); |
- EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT, |
- website_settings()->site_identity_status()); |
- EXPECT_EQ(base::string16(), website_settings()->organization_name()); |
+ EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_ENCRYPTED, |
+ page_info()->site_connection_status()); |
+ EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT, |
+ page_info()->site_identity_status()); |
+ EXPECT_EQ(base::string16(), page_info()->organization_name()); |
} |
-TEST_F(WebsiteSettingsTest, HTTPSSHA1) { |
+TEST_F(PageInfoTest, HTTPSSHA1) { |
security_info_.security_level = security_state::NONE; |
security_info_.scheme_is_cryptographic = true; |
security_info_.certificate = cert(); |
@@ -605,68 +601,66 @@ TEST_F(WebsiteSettingsTest, HTTPSSHA1) { |
SetDefaultUIExpectations(mock_ui()); |
- EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED, |
- website_settings()->site_connection_status()); |
- EXPECT_EQ( |
- WebsiteSettings::SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM, |
- website_settings()->site_identity_status()); |
- EXPECT_EQ(base::string16(), website_settings()->organization_name()); |
+ EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_ENCRYPTED, |
+ page_info()->site_connection_status()); |
+ EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM, |
+ page_info()->site_identity_status()); |
+ EXPECT_EQ(base::string16(), page_info()->organization_name()); |
EXPECT_EQ(IDR_PAGEINFO_WARNING_MINOR, |
- WebsiteSettingsUI::GetIdentityIconID( |
- website_settings()->site_identity_status())); |
+ PageInfoUI::GetIdentityIconID(page_info()->site_identity_status())); |
} |
#if !defined(OS_ANDROID) |
-TEST_F(WebsiteSettingsTest, NoInfoBar) { |
+TEST_F(PageInfoTest, NoInfoBar) { |
SetDefaultUIExpectations(mock_ui()); |
EXPECT_EQ(0u, infobar_service()->infobar_count()); |
- website_settings()->OnUIClosing(); |
+ page_info()->OnUIClosing(); |
EXPECT_EQ(0u, infobar_service()->infobar_count()); |
} |
-TEST_F(WebsiteSettingsTest, ShowInfoBar) { |
+TEST_F(PageInfoTest, ShowInfoBar) { |
EXPECT_CALL(*mock_ui(), SetIdentityInfo(_)); |
EXPECT_CALL(*mock_ui(), SetCookieInfo(_)); |
EXPECT_CALL(*mock_ui(), SetPermissionInfoStub()).Times(2); |
EXPECT_EQ(0u, infobar_service()->infobar_count()); |
- website_settings()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_GEOLOCATION, |
- CONTENT_SETTING_ALLOW); |
- website_settings()->OnUIClosing(); |
+ page_info()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_GEOLOCATION, |
+ CONTENT_SETTING_ALLOW); |
+ page_info()->OnUIClosing(); |
ASSERT_EQ(1u, infobar_service()->infobar_count()); |
infobar_service()->RemoveInfoBar(infobar_service()->infobar_at(0)); |
} |
#endif |
-TEST_F(WebsiteSettingsTest, AboutBlankPage) { |
+TEST_F(PageInfoTest, AboutBlankPage) { |
SetURL("about:blank"); |
SetDefaultUIExpectations(mock_ui()); |
- EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_UNENCRYPTED, |
- website_settings()->site_connection_status()); |
- EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_NO_CERT, |
- website_settings()->site_identity_status()); |
- EXPECT_EQ(base::string16(), website_settings()->organization_name()); |
+ EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_UNENCRYPTED, |
+ page_info()->site_connection_status()); |
+ EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_NO_CERT, |
+ page_info()->site_identity_status()); |
+ EXPECT_EQ(base::string16(), page_info()->organization_name()); |
} |
-// On desktop, internal URLs aren't handled by WebsiteSettings class. Instead, a |
+// On desktop, internal URLs aren't handled by PageInfo class. Instead, a |
// custom and simpler popup is shown, so no need to test. |
#if defined(OS_ANDROID) || defined(OS_IOS) |
-TEST_F(WebsiteSettingsTest, InternalPage) { |
+TEST_F(PageInfoTest, InternalPage) { |
SetURL("chrome://bookmarks"); |
SetDefaultUIExpectations(mock_ui()); |
- EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_INTERNAL_PAGE, |
- website_settings()->site_connection_status()); |
- EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_INTERNAL_PAGE, |
- website_settings()->site_identity_status()); |
- EXPECT_EQ(base::string16(), website_settings()->organization_name()); |
+ EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_INTERNAL_PAGE, |
+ page_info()->site_connection_status()); |
+ EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_INTERNAL_PAGE, |
+ page_info()->site_identity_status()); |
+ EXPECT_EQ(base::string16(), page_info()->organization_name()); |
} |
#endif |
-// Tests that metrics are recorded on a WebsiteSettings for pages with |
+// Tests that metrics are recorded on a PageInfo for pages with |
// various security levels. |
-TEST_F(WebsiteSettingsTest, SecurityLevelMetrics) { |
+TEST_F(PageInfoTest, SecurityLevelMetrics) { |
struct TestCase { |
const std::string url; |
const security_state::SecurityLevel security_level; |
@@ -696,26 +690,24 @@ TEST_F(WebsiteSettingsTest, SecurityLevelMetrics) { |
SetURL(test.url); |
security_info_.security_level = test.security_level; |
ResetMockUI(); |
- ClearWebsiteSettings(); |
+ ClearPageInfo(); |
SetDefaultUIExpectations(mock_ui()); |
histograms.ExpectTotalCount(kGenericHistogram, 0); |
histograms.ExpectTotalCount(test.histogram_name, 0); |
- website_settings()->RecordWebsiteSettingsAction( |
- WebsiteSettings::WebsiteSettingsAction::WEBSITE_SETTINGS_OPENED); |
+ page_info()->RecordPageInfoAction( |
+ PageInfo::PageInfoAction::PAGE_INFO_OPENED); |
- // RecordWebsiteSettingsAction() is called during WebsiteSettings |
- // creation in addition to the explicit RecordWebsiteSettingsAction() |
+ // RecordPageInfoAction() is called during PageInfo |
+ // creation in addition to the explicit RecordPageInfoAction() |
// call, so it is called twice in total. |
histograms.ExpectTotalCount(kGenericHistogram, 2); |
- histograms.ExpectBucketCount( |
- kGenericHistogram, |
- WebsiteSettings::WebsiteSettingsAction::WEBSITE_SETTINGS_OPENED, 2); |
+ histograms.ExpectBucketCount(kGenericHistogram, |
+ PageInfo::PageInfoAction::PAGE_INFO_OPENED, 2); |
histograms.ExpectTotalCount(test.histogram_name, 2); |
- histograms.ExpectBucketCount( |
- test.histogram_name, |
- WebsiteSettings::WebsiteSettingsAction::WEBSITE_SETTINGS_OPENED, 2); |
+ histograms.ExpectBucketCount(test.histogram_name, |
+ PageInfo::PageInfoAction::PAGE_INFO_OPENED, 2); |
} |
} |