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/page_info/website_settings.h" | 5 #include "chrome/browser/ui/page_info/page_info.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "base/test/histogram_tester.h" | 16 #include "base/test/histogram_tester.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 18 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
19 #include "chrome/browser/infobars/infobar_service.h" | 19 #include "chrome/browser/infobars/infobar_service.h" |
20 #include "chrome/browser/ui/page_info/website_settings_ui.h" | 20 #include "chrome/browser/ui/page_info/page_info_ui.h" |
21 #include "chrome/browser/usb/usb_chooser_context.h" | 21 #include "chrome/browser/usb/usb_chooser_context.h" |
22 #include "chrome/browser/usb/usb_chooser_context_factory.h" | 22 #include "chrome/browser/usb/usb_chooser_context_factory.h" |
23 #include "chrome/grit/theme_resources.h" | 23 #include "chrome/grit/theme_resources.h" |
24 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 24 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
25 #include "chrome/test/base/testing_profile.h" | 25 #include "chrome/test/base/testing_profile.h" |
26 #include "components/content_settings/core/browser/host_content_settings_map.h" | 26 #include "components/content_settings/core/browser/host_content_settings_map.h" |
27 #include "components/content_settings/core/common/content_settings.h" | 27 #include "components/content_settings/core/common/content_settings.h" |
28 #include "components/content_settings/core/common/content_settings_types.h" | 28 #include "components/content_settings/core/common/content_settings_types.h" |
29 #include "components/infobars/core/infobar.h" | 29 #include "components/infobars/core/infobar.h" |
30 #include "content/public/browser/ssl_status.h" | 30 #include "content/public/browser/ssl_status.h" |
(...skipping 30 matching lines...) Expand all Loading... |
61 int bitmask = version << net::SSL_CONNECTION_VERSION_SHIFT; | 61 int bitmask = version << net::SSL_CONNECTION_VERSION_SHIFT; |
62 return bitmask | connection_status; | 62 return bitmask | connection_status; |
63 } | 63 } |
64 | 64 |
65 int SetSSLCipherSuite(int connection_status, int cipher_suite) { | 65 int SetSSLCipherSuite(int connection_status, int cipher_suite) { |
66 // Clear cipher suite bits (the 16 lowest bits). | 66 // Clear cipher suite bits (the 16 lowest bits). |
67 connection_status &= ~net::SSL_CONNECTION_CIPHERSUITE_MASK; | 67 connection_status &= ~net::SSL_CONNECTION_CIPHERSUITE_MASK; |
68 return cipher_suite | connection_status; | 68 return cipher_suite | connection_status; |
69 } | 69 } |
70 | 70 |
71 class MockWebsiteSettingsUI : public WebsiteSettingsUI { | 71 class MockPageInfoUI : public PageInfoUI { |
72 public: | 72 public: |
73 virtual ~MockWebsiteSettingsUI() {} | 73 virtual ~MockPageInfoUI() {} |
74 MOCK_METHOD1(SetCookieInfo, void(const CookieInfoList& cookie_info_list)); | 74 MOCK_METHOD1(SetCookieInfo, void(const CookieInfoList& cookie_info_list)); |
75 MOCK_METHOD0(SetPermissionInfoStub, void()); | 75 MOCK_METHOD0(SetPermissionInfoStub, void()); |
76 MOCK_METHOD1(SetIdentityInfo, void(const IdentityInfo& identity_info)); | 76 MOCK_METHOD1(SetIdentityInfo, void(const IdentityInfo& identity_info)); |
77 | 77 |
78 void SetPermissionInfo( | 78 void SetPermissionInfo( |
79 const PermissionInfoList& permission_info_list, | 79 const PermissionInfoList& permission_info_list, |
80 ChosenObjectInfoList chosen_object_info_list) override { | 80 ChosenObjectInfoList chosen_object_info_list) override { |
81 SetPermissionInfoStub(); | 81 SetPermissionInfoStub(); |
82 if (set_permission_info_callback_) { | 82 if (set_permission_info_callback_) { |
83 set_permission_info_callback_.Run(permission_info_list, | 83 set_permission_info_callback_.Run(permission_info_list, |
84 std::move(chosen_object_info_list)); | 84 std::move(chosen_object_info_list)); |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 base::Callback<void(const PermissionInfoList& permission_info_list, | 88 base::Callback<void(const PermissionInfoList& permission_info_list, |
89 ChosenObjectInfoList chosen_object_info_list)> | 89 ChosenObjectInfoList chosen_object_info_list)> |
90 set_permission_info_callback_; | 90 set_permission_info_callback_; |
91 }; | 91 }; |
92 | 92 |
93 class WebsiteSettingsTest : public ChromeRenderViewHostTestHarness { | 93 class PageInfoTest : public ChromeRenderViewHostTestHarness { |
94 public: | 94 public: |
95 WebsiteSettingsTest() : url_("http://www.example.com") {} | 95 PageInfoTest() : url_("http://www.example.com") {} |
96 | 96 |
97 ~WebsiteSettingsTest() override {} | 97 ~PageInfoTest() override {} |
98 | 98 |
99 void SetUp() override { | 99 void SetUp() override { |
100 ChromeRenderViewHostTestHarness::SetUp(); | 100 ChromeRenderViewHostTestHarness::SetUp(); |
101 | 101 |
102 // Setup stub SecurityInfo. | 102 // Setup stub SecurityInfo. |
103 security_info_.security_level = security_state::NONE; | 103 security_info_.security_level = security_state::NONE; |
104 | 104 |
105 // Create the certificate. | 105 // Create the certificate. |
106 cert_ = | 106 cert_ = |
107 net::ImportCertFromFile(net::GetTestCertsDirectory(), "ok_cert.pem"); | 107 net::ImportCertFromFile(net::GetTestCertsDirectory(), "ok_cert.pem"); |
108 ASSERT_TRUE(cert_); | 108 ASSERT_TRUE(cert_); |
109 | 109 |
110 TabSpecificContentSettings::CreateForWebContents(web_contents()); | 110 TabSpecificContentSettings::CreateForWebContents(web_contents()); |
111 InfoBarService::CreateForWebContents(web_contents()); | 111 InfoBarService::CreateForWebContents(web_contents()); |
112 | 112 |
113 // Setup mock ui. | 113 // Setup mock ui. |
114 mock_ui_.reset(new MockWebsiteSettingsUI()); | 114 mock_ui_.reset(new MockPageInfoUI()); |
115 // Use this rather than gmock's ON_CALL.WillByDefault(Invoke(... because | 115 // Use this rather than gmock's ON_CALL.WillByDefault(Invoke(... because |
116 // gmock doesn't handle move-only types well. | 116 // gmock doesn't handle move-only types well. |
117 mock_ui_->set_permission_info_callback_ = base::Bind( | 117 mock_ui_->set_permission_info_callback_ = |
118 &WebsiteSettingsTest::SetPermissionInfo, base::Unretained(this)); | 118 base::Bind(&PageInfoTest::SetPermissionInfo, base::Unretained(this)); |
119 } | 119 } |
120 | 120 |
121 void TearDown() override { | 121 void TearDown() override { |
122 ASSERT_TRUE(website_settings_.get()) | 122 ASSERT_TRUE(page_info_.get()) << "No PageInfo instance created."; |
123 << "No WebsiteSettings instance created."; | |
124 RenderViewHostTestHarness::TearDown(); | 123 RenderViewHostTestHarness::TearDown(); |
125 website_settings_.reset(); | 124 page_info_.reset(); |
126 } | 125 } |
127 | 126 |
128 void SetDefaultUIExpectations(MockWebsiteSettingsUI* mock_ui) { | 127 void SetDefaultUIExpectations(MockPageInfoUI* mock_ui) { |
129 // During creation |WebsiteSettings| makes the following calls to the ui. | 128 // During creation |PageInfo| makes the following calls to the ui. |
130 EXPECT_CALL(*mock_ui, SetPermissionInfoStub()); | 129 EXPECT_CALL(*mock_ui, SetPermissionInfoStub()); |
131 EXPECT_CALL(*mock_ui, SetIdentityInfo(_)); | 130 EXPECT_CALL(*mock_ui, SetIdentityInfo(_)); |
132 EXPECT_CALL(*mock_ui, SetCookieInfo(_)); | 131 EXPECT_CALL(*mock_ui, SetCookieInfo(_)); |
133 } | 132 } |
134 | 133 |
135 void SetURL(const std::string& url) { url_ = GURL(url); } | 134 void SetURL(const std::string& url) { url_ = GURL(url); } |
136 | 135 |
137 void SetPermissionInfo(const PermissionInfoList& permission_info_list, | 136 void SetPermissionInfo(const PermissionInfoList& permission_info_list, |
138 ChosenObjectInfoList chosen_object_info_list) { | 137 ChosenObjectInfoList chosen_object_info_list) { |
139 last_chosen_object_info_.clear(); | 138 last_chosen_object_info_.clear(); |
140 for (auto& chosen_object_info : chosen_object_info_list) | 139 for (auto& chosen_object_info : chosen_object_info_list) |
141 last_chosen_object_info_.push_back(std::move(chosen_object_info)); | 140 last_chosen_object_info_.push_back(std::move(chosen_object_info)); |
142 } | 141 } |
143 | 142 |
144 void ResetMockUI() { mock_ui_.reset(new MockWebsiteSettingsUI()); } | 143 void ResetMockUI() { mock_ui_.reset(new MockPageInfoUI()); } |
145 | 144 |
146 void ClearWebsiteSettings() { website_settings_.reset(nullptr); } | 145 void ClearPageInfo() { page_info_.reset(nullptr); } |
147 | 146 |
148 const GURL& url() const { return url_; } | 147 const GURL& url() const { return url_; } |
149 scoped_refptr<net::X509Certificate> cert() { return cert_; } | 148 scoped_refptr<net::X509Certificate> cert() { return cert_; } |
150 MockWebsiteSettingsUI* mock_ui() { return mock_ui_.get(); } | 149 MockPageInfoUI* mock_ui() { return mock_ui_.get(); } |
151 const security_state::SecurityInfo& security_info() { return security_info_; } | 150 const security_state::SecurityInfo& security_info() { return security_info_; } |
152 const std::vector<std::unique_ptr<WebsiteSettingsUI::ChosenObjectInfo>>& | 151 const std::vector<std::unique_ptr<PageInfoUI::ChosenObjectInfo>>& |
153 last_chosen_object_info() { | 152 last_chosen_object_info() { |
154 return last_chosen_object_info_; | 153 return last_chosen_object_info_; |
155 } | 154 } |
156 TabSpecificContentSettings* tab_specific_content_settings() { | 155 TabSpecificContentSettings* tab_specific_content_settings() { |
157 return TabSpecificContentSettings::FromWebContents(web_contents()); | 156 return TabSpecificContentSettings::FromWebContents(web_contents()); |
158 } | 157 } |
159 InfoBarService* infobar_service() { | 158 InfoBarService* infobar_service() { |
160 return InfoBarService::FromWebContents(web_contents()); | 159 return InfoBarService::FromWebContents(web_contents()); |
161 } | 160 } |
162 | 161 |
163 WebsiteSettings* website_settings() { | 162 PageInfo* page_info() { |
164 if (!website_settings_.get()) { | 163 if (!page_info_.get()) { |
165 website_settings_.reset(new WebsiteSettings( | 164 page_info_.reset(new PageInfo(mock_ui(), profile(), |
166 mock_ui(), profile(), tab_specific_content_settings(), web_contents(), | 165 tab_specific_content_settings(), |
167 url(), security_info())); | 166 web_contents(), url(), security_info())); |
168 } | 167 } |
169 return website_settings_.get(); | 168 return page_info_.get(); |
170 } | 169 } |
171 | 170 |
172 device::MockUsbService& usb_service() { | 171 device::MockUsbService& usb_service() { |
173 return *device_client_.usb_service(); | 172 return *device_client_.usb_service(); |
174 } | 173 } |
175 | 174 |
176 security_state::SecurityInfo security_info_; | 175 security_state::SecurityInfo security_info_; |
177 | 176 |
178 private: | 177 private: |
179 device::MockDeviceClient device_client_; | 178 device::MockDeviceClient device_client_; |
180 std::unique_ptr<WebsiteSettings> website_settings_; | 179 std::unique_ptr<PageInfo> page_info_; |
181 std::unique_ptr<MockWebsiteSettingsUI> mock_ui_; | 180 std::unique_ptr<MockPageInfoUI> mock_ui_; |
182 scoped_refptr<net::X509Certificate> cert_; | 181 scoped_refptr<net::X509Certificate> cert_; |
183 GURL url_; | 182 GURL url_; |
184 std::vector<std::unique_ptr<WebsiteSettingsUI::ChosenObjectInfo>> | 183 std::vector<std::unique_ptr<PageInfoUI::ChosenObjectInfo>> |
185 last_chosen_object_info_; | 184 last_chosen_object_info_; |
186 }; | 185 }; |
187 | 186 |
188 } // namespace | 187 } // namespace |
189 | 188 |
190 TEST_F(WebsiteSettingsTest, OnPermissionsChanged) { | 189 TEST_F(PageInfoTest, OnPermissionsChanged) { |
191 // Setup site permissions. | 190 // Setup site permissions. |
192 HostContentSettingsMap* content_settings = | 191 HostContentSettingsMap* content_settings = |
193 HostContentSettingsMapFactory::GetForProfile(profile()); | 192 HostContentSettingsMapFactory::GetForProfile(profile()); |
194 ContentSetting setting = content_settings->GetContentSetting( | 193 ContentSetting setting = content_settings->GetContentSetting( |
195 url(), url(), CONTENT_SETTINGS_TYPE_POPUPS, std::string()); | 194 url(), url(), CONTENT_SETTINGS_TYPE_POPUPS, std::string()); |
196 EXPECT_EQ(setting, CONTENT_SETTING_BLOCK); | 195 EXPECT_EQ(setting, CONTENT_SETTING_BLOCK); |
197 #if BUILDFLAG(ENABLE_PLUGINS) | 196 #if BUILDFLAG(ENABLE_PLUGINS) |
198 setting = content_settings->GetContentSetting( | 197 setting = content_settings->GetContentSetting( |
199 url(), url(), CONTENT_SETTINGS_TYPE_PLUGINS, std::string()); | 198 url(), url(), CONTENT_SETTINGS_TYPE_PLUGINS, std::string()); |
200 EXPECT_EQ(setting, CONTENT_SETTING_DETECT_IMPORTANT_CONTENT); | 199 EXPECT_EQ(setting, CONTENT_SETTING_DETECT_IMPORTANT_CONTENT); |
(...skipping 17 matching lines...) Expand all Loading... |
218 // SetPermissionInfo() is called once initially, and then again every time | 217 // SetPermissionInfo() is called once initially, and then again every time |
219 // OnSitePermissionChanged() is called. | 218 // OnSitePermissionChanged() is called. |
220 #if !BUILDFLAG(ENABLE_PLUGINS) | 219 #if !BUILDFLAG(ENABLE_PLUGINS) |
221 // SetPermissionInfo for plugins didn't get called. | 220 // SetPermissionInfo for plugins didn't get called. |
222 EXPECT_CALL(*mock_ui(), SetPermissionInfoStub()).Times(6); | 221 EXPECT_CALL(*mock_ui(), SetPermissionInfoStub()).Times(6); |
223 #else | 222 #else |
224 EXPECT_CALL(*mock_ui(), SetPermissionInfoStub()).Times(7); | 223 EXPECT_CALL(*mock_ui(), SetPermissionInfoStub()).Times(7); |
225 #endif | 224 #endif |
226 | 225 |
227 // Execute code under tests. | 226 // Execute code under tests. |
228 website_settings()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_POPUPS, | 227 page_info()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_POPUPS, |
229 CONTENT_SETTING_ALLOW); | 228 CONTENT_SETTING_ALLOW); |
230 #if BUILDFLAG(ENABLE_PLUGINS) | 229 #if BUILDFLAG(ENABLE_PLUGINS) |
231 website_settings()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_PLUGINS, | 230 page_info()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_PLUGINS, |
232 CONTENT_SETTING_BLOCK); | 231 CONTENT_SETTING_BLOCK); |
233 #endif | 232 #endif |
234 website_settings()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_GEOLOCATION, | 233 page_info()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_GEOLOCATION, |
235 CONTENT_SETTING_ALLOW); | 234 CONTENT_SETTING_ALLOW); |
236 website_settings()->OnSitePermissionChanged( | 235 page_info()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
237 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTING_ALLOW); | 236 CONTENT_SETTING_ALLOW); |
238 website_settings()->OnSitePermissionChanged( | 237 page_info()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, |
239 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, CONTENT_SETTING_ALLOW); | 238 CONTENT_SETTING_ALLOW); |
240 website_settings()->OnSitePermissionChanged( | 239 page_info()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, |
241 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, CONTENT_SETTING_ALLOW); | 240 CONTENT_SETTING_ALLOW); |
242 | 241 |
243 // Verify that the site permissions were changed correctly. | 242 // Verify that the site permissions were changed correctly. |
244 setting = content_settings->GetContentSetting( | 243 setting = content_settings->GetContentSetting( |
245 url(), url(), CONTENT_SETTINGS_TYPE_POPUPS, std::string()); | 244 url(), url(), CONTENT_SETTINGS_TYPE_POPUPS, std::string()); |
246 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); | 245 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); |
247 #if BUILDFLAG(ENABLE_PLUGINS) | 246 #if BUILDFLAG(ENABLE_PLUGINS) |
248 setting = content_settings->GetContentSetting( | 247 setting = content_settings->GetContentSetting( |
249 url(), url(), CONTENT_SETTINGS_TYPE_PLUGINS, std::string()); | 248 url(), url(), CONTENT_SETTINGS_TYPE_PLUGINS, std::string()); |
250 EXPECT_EQ(setting, CONTENT_SETTING_BLOCK); | 249 EXPECT_EQ(setting, CONTENT_SETTING_BLOCK); |
251 #endif | 250 #endif |
252 setting = content_settings->GetContentSetting( | 251 setting = content_settings->GetContentSetting( |
253 url(), url(), CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string()); | 252 url(), url(), CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string()); |
254 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); | 253 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); |
255 setting = content_settings->GetContentSetting( | 254 setting = content_settings->GetContentSetting( |
256 url(), url(), CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string()); | 255 url(), url(), CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string()); |
257 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); | 256 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); |
258 setting = content_settings->GetContentSetting( | 257 setting = content_settings->GetContentSetting( |
259 url(), url(), CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, std::string()); | 258 url(), url(), CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, std::string()); |
260 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); | 259 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); |
261 setting = content_settings->GetContentSetting( | 260 setting = content_settings->GetContentSetting( |
262 url(), url(), CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string()); | 261 url(), url(), CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string()); |
263 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); | 262 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); |
264 } | 263 } |
265 | 264 |
266 TEST_F(WebsiteSettingsTest, OnSiteDataAccessed) { | 265 TEST_F(PageInfoTest, OnSiteDataAccessed) { |
267 EXPECT_CALL(*mock_ui(), SetPermissionInfoStub()); | 266 EXPECT_CALL(*mock_ui(), SetPermissionInfoStub()); |
268 EXPECT_CALL(*mock_ui(), SetIdentityInfo(_)); | 267 EXPECT_CALL(*mock_ui(), SetIdentityInfo(_)); |
269 EXPECT_CALL(*mock_ui(), SetCookieInfo(_)).Times(2); | 268 EXPECT_CALL(*mock_ui(), SetCookieInfo(_)).Times(2); |
270 | 269 |
271 website_settings()->OnSiteDataAccessed(); | 270 page_info()->OnSiteDataAccessed(); |
272 } | 271 } |
273 | 272 |
274 TEST_F(WebsiteSettingsTest, OnChosenObjectDeleted) { | 273 TEST_F(PageInfoTest, OnChosenObjectDeleted) { |
275 scoped_refptr<device::UsbDevice> device = | 274 scoped_refptr<device::UsbDevice> device = |
276 new device::MockUsbDevice(0, 0, "Google", "Gizmo", "1234567890"); | 275 new device::MockUsbDevice(0, 0, "Google", "Gizmo", "1234567890"); |
277 usb_service().AddDevice(device); | 276 usb_service().AddDevice(device); |
278 UsbChooserContext* store = UsbChooserContextFactory::GetForProfile(profile()); | 277 UsbChooserContext* store = UsbChooserContextFactory::GetForProfile(profile()); |
279 store->GrantDevicePermission(url(), url(), device->guid()); | 278 store->GrantDevicePermission(url(), url(), device->guid()); |
280 | 279 |
281 EXPECT_CALL(*mock_ui(), SetIdentityInfo(_)); | 280 EXPECT_CALL(*mock_ui(), SetIdentityInfo(_)); |
282 EXPECT_CALL(*mock_ui(), SetCookieInfo(_)); | 281 EXPECT_CALL(*mock_ui(), SetCookieInfo(_)); |
283 | 282 |
284 // Access WebsiteSettings so that SetPermissionInfo is called once to populate | 283 // Access PageInfo so that SetPermissionInfo is called once to populate |
285 // |last_chosen_object_info_|. It will be called again by | 284 // |last_chosen_object_info_|. It will be called again by |
286 // OnSiteChosenObjectDeleted. | 285 // OnSiteChosenObjectDeleted. |
287 EXPECT_CALL(*mock_ui(), SetPermissionInfoStub()).Times(2); | 286 EXPECT_CALL(*mock_ui(), SetPermissionInfoStub()).Times(2); |
288 website_settings(); | 287 page_info(); |
289 | 288 |
290 ASSERT_EQ(1u, last_chosen_object_info().size()); | 289 ASSERT_EQ(1u, last_chosen_object_info().size()); |
291 const WebsiteSettingsUI::ChosenObjectInfo* info = | 290 const PageInfoUI::ChosenObjectInfo* info = last_chosen_object_info()[0].get(); |
292 last_chosen_object_info()[0].get(); | 291 page_info()->OnSiteChosenObjectDeleted(info->ui_info, *info->object); |
293 website_settings()->OnSiteChosenObjectDeleted(info->ui_info, *info->object); | |
294 | 292 |
295 EXPECT_FALSE(store->HasDevicePermission(url(), url(), device)); | 293 EXPECT_FALSE(store->HasDevicePermission(url(), url(), device)); |
296 EXPECT_EQ(0u, last_chosen_object_info().size()); | 294 EXPECT_EQ(0u, last_chosen_object_info().size()); |
297 } | 295 } |
298 | 296 |
299 TEST_F(WebsiteSettingsTest, Malware) { | 297 TEST_F(PageInfoTest, Malware) { |
300 security_info_.security_level = security_state::DANGEROUS; | 298 security_info_.security_level = security_state::DANGEROUS; |
301 security_info_.malicious_content_status = | 299 security_info_.malicious_content_status = |
302 security_state::MALICIOUS_CONTENT_STATUS_MALWARE; | 300 security_state::MALICIOUS_CONTENT_STATUS_MALWARE; |
303 SetDefaultUIExpectations(mock_ui()); | 301 SetDefaultUIExpectations(mock_ui()); |
304 | 302 |
305 EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_UNENCRYPTED, | 303 EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_UNENCRYPTED, |
306 website_settings()->site_connection_status()); | 304 page_info()->site_connection_status()); |
307 EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_MALWARE, | 305 EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_MALWARE, |
308 website_settings()->site_identity_status()); | 306 page_info()->site_identity_status()); |
309 } | 307 } |
310 | 308 |
311 TEST_F(WebsiteSettingsTest, SocialEngineering) { | 309 TEST_F(PageInfoTest, SocialEngineering) { |
312 security_info_.security_level = security_state::DANGEROUS; | 310 security_info_.security_level = security_state::DANGEROUS; |
313 security_info_.malicious_content_status = | 311 security_info_.malicious_content_status = |
314 security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING; | 312 security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING; |
315 SetDefaultUIExpectations(mock_ui()); | 313 SetDefaultUIExpectations(mock_ui()); |
316 | 314 |
317 EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_UNENCRYPTED, | 315 EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_UNENCRYPTED, |
318 website_settings()->site_connection_status()); | 316 page_info()->site_connection_status()); |
319 EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING, | 317 EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING, |
320 website_settings()->site_identity_status()); | 318 page_info()->site_identity_status()); |
321 } | 319 } |
322 | 320 |
323 TEST_F(WebsiteSettingsTest, UnwantedSoftware) { | 321 TEST_F(PageInfoTest, UnwantedSoftware) { |
324 security_info_.security_level = security_state::DANGEROUS; | 322 security_info_.security_level = security_state::DANGEROUS; |
325 security_info_.malicious_content_status = | 323 security_info_.malicious_content_status = |
326 security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE; | 324 security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE; |
327 SetDefaultUIExpectations(mock_ui()); | 325 SetDefaultUIExpectations(mock_ui()); |
328 | 326 |
329 EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_UNENCRYPTED, | 327 EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_UNENCRYPTED, |
330 website_settings()->site_connection_status()); | 328 page_info()->site_connection_status()); |
331 EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE, | 329 EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE, |
332 website_settings()->site_identity_status()); | 330 page_info()->site_identity_status()); |
333 } | 331 } |
334 | 332 |
335 TEST_F(WebsiteSettingsTest, HTTPConnection) { | 333 TEST_F(PageInfoTest, HTTPConnection) { |
336 SetDefaultUIExpectations(mock_ui()); | 334 SetDefaultUIExpectations(mock_ui()); |
337 EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_UNENCRYPTED, | 335 EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_UNENCRYPTED, |
338 website_settings()->site_connection_status()); | 336 page_info()->site_connection_status()); |
339 EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_NO_CERT, | 337 EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_NO_CERT, |
340 website_settings()->site_identity_status()); | 338 page_info()->site_identity_status()); |
341 EXPECT_EQ(base::string16(), website_settings()->organization_name()); | 339 EXPECT_EQ(base::string16(), page_info()->organization_name()); |
342 } | 340 } |
343 | 341 |
344 TEST_F(WebsiteSettingsTest, HTTPSConnection) { | 342 TEST_F(PageInfoTest, HTTPSConnection) { |
345 security_info_.security_level = security_state::SECURE; | 343 security_info_.security_level = security_state::SECURE; |
346 security_info_.scheme_is_cryptographic = true; | 344 security_info_.scheme_is_cryptographic = true; |
347 security_info_.certificate = cert(); | 345 security_info_.certificate = cert(); |
348 security_info_.cert_status = 0; | 346 security_info_.cert_status = 0; |
349 security_info_.security_bits = 81; // No error if > 80. | 347 security_info_.security_bits = 81; // No error if > 80. |
350 int status = 0; | 348 int status = 0; |
351 status = SetSSLVersion(status, net::SSL_CONNECTION_VERSION_TLS1); | 349 status = SetSSLVersion(status, net::SSL_CONNECTION_VERSION_TLS1); |
352 status = SetSSLCipherSuite(status, CR_TLS_RSA_WITH_AES_256_CBC_SHA256); | 350 status = SetSSLCipherSuite(status, CR_TLS_RSA_WITH_AES_256_CBC_SHA256); |
353 security_info_.connection_status = status; | 351 security_info_.connection_status = status; |
354 | 352 |
355 SetDefaultUIExpectations(mock_ui()); | 353 SetDefaultUIExpectations(mock_ui()); |
356 | 354 |
357 EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED, | 355 EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_ENCRYPTED, |
358 website_settings()->site_connection_status()); | 356 page_info()->site_connection_status()); |
359 EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_CERT, | 357 EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_CERT, |
360 website_settings()->site_identity_status()); | 358 page_info()->site_identity_status()); |
361 EXPECT_EQ(base::string16(), website_settings()->organization_name()); | 359 EXPECT_EQ(base::string16(), page_info()->organization_name()); |
362 } | 360 } |
363 | 361 |
364 TEST_F(WebsiteSettingsTest, InsecureContent) { | 362 TEST_F(PageInfoTest, InsecureContent) { |
365 struct TestCase { | 363 struct TestCase { |
366 security_state::SecurityLevel security_level; | 364 security_state::SecurityLevel security_level; |
367 net::CertStatus cert_status; | 365 net::CertStatus cert_status; |
368 security_state::ContentStatus mixed_content_status; | 366 security_state::ContentStatus mixed_content_status; |
369 security_state::ContentStatus content_with_cert_errors_status; | 367 security_state::ContentStatus content_with_cert_errors_status; |
370 WebsiteSettings::SiteConnectionStatus expected_site_connection_status; | 368 PageInfo::SiteConnectionStatus expected_site_connection_status; |
371 WebsiteSettings::SiteIdentityStatus expected_site_identity_status; | 369 PageInfo::SiteIdentityStatus expected_site_identity_status; |
372 int expected_connection_icon_id; | 370 int expected_connection_icon_id; |
373 }; | 371 }; |
374 | 372 |
375 const TestCase kTestCases[] = { | 373 const TestCase kTestCases[] = { |
376 // Passive mixed content. | 374 // Passive mixed content. |
377 {security_state::NONE, 0, security_state::CONTENT_STATUS_DISPLAYED, | 375 {security_state::NONE, 0, security_state::CONTENT_STATUS_DISPLAYED, |
378 security_state::CONTENT_STATUS_NONE, | 376 security_state::CONTENT_STATUS_NONE, |
379 WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, | 377 PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, |
380 WebsiteSettings::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_WARNING_MINOR}, | 378 PageInfo::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_WARNING_MINOR}, |
381 // Passive mixed content with a cert error on the main resource. | 379 // Passive mixed content with a cert error on the main resource. |
382 {security_state::DANGEROUS, net::CERT_STATUS_DATE_INVALID, | 380 {security_state::DANGEROUS, net::CERT_STATUS_DATE_INVALID, |
383 security_state::CONTENT_STATUS_DISPLAYED, | 381 security_state::CONTENT_STATUS_DISPLAYED, |
384 security_state::CONTENT_STATUS_NONE, | 382 security_state::CONTENT_STATUS_NONE, |
385 WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, | 383 PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, |
386 WebsiteSettings::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_WARNING_MINOR}, | 384 PageInfo::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_WARNING_MINOR}, |
387 // Active and passive mixed content. | 385 // Active and passive mixed content. |
388 {security_state::DANGEROUS, 0, | 386 {security_state::DANGEROUS, 0, |
389 security_state::CONTENT_STATUS_DISPLAYED_AND_RAN, | 387 security_state::CONTENT_STATUS_DISPLAYED_AND_RAN, |
390 security_state::CONTENT_STATUS_NONE, | 388 security_state::CONTENT_STATUS_NONE, |
391 WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, | 389 PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
392 WebsiteSettings::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, | 390 PageInfo::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, |
393 // Active and passive mixed content with a cert error on the main | 391 // Active and passive mixed content with a cert error on the main |
394 // resource. | 392 // resource. |
395 {security_state::DANGEROUS, net::CERT_STATUS_DATE_INVALID, | 393 {security_state::DANGEROUS, net::CERT_STATUS_DATE_INVALID, |
396 security_state::CONTENT_STATUS_DISPLAYED_AND_RAN, | 394 security_state::CONTENT_STATUS_DISPLAYED_AND_RAN, |
397 security_state::CONTENT_STATUS_NONE, | 395 security_state::CONTENT_STATUS_NONE, |
398 WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, | 396 PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
399 WebsiteSettings::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_BAD}, | 397 PageInfo::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_BAD}, |
400 // Active mixed content. | 398 // Active mixed content. |
401 {security_state::DANGEROUS, 0, security_state::CONTENT_STATUS_RAN, | 399 {security_state::DANGEROUS, 0, security_state::CONTENT_STATUS_RAN, |
402 security_state::CONTENT_STATUS_NONE, | 400 security_state::CONTENT_STATUS_NONE, |
403 WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, | 401 PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
404 WebsiteSettings::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, | 402 PageInfo::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, |
405 // Active mixed content with a cert error on the main resource. | 403 // Active mixed content with a cert error on the main resource. |
406 {security_state::DANGEROUS, net::CERT_STATUS_DATE_INVALID, | 404 {security_state::DANGEROUS, net::CERT_STATUS_DATE_INVALID, |
407 security_state::CONTENT_STATUS_RAN, security_state::CONTENT_STATUS_NONE, | 405 security_state::CONTENT_STATUS_RAN, security_state::CONTENT_STATUS_NONE, |
408 WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, | 406 PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
409 WebsiteSettings::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_BAD}, | 407 PageInfo::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_BAD}, |
410 | 408 |
411 // Passive subresources with cert errors. | 409 // Passive subresources with cert errors. |
412 {security_state::NONE, 0, security_state::CONTENT_STATUS_NONE, | 410 {security_state::NONE, 0, security_state::CONTENT_STATUS_NONE, |
413 security_state::CONTENT_STATUS_DISPLAYED, | 411 security_state::CONTENT_STATUS_DISPLAYED, |
414 WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, | 412 PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, |
415 WebsiteSettings::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_WARNING_MINOR}, | 413 PageInfo::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_WARNING_MINOR}, |
416 // Passive subresources with cert errors, with a cert error on the | 414 // Passive subresources with cert errors, with a cert error on the |
417 // main resource also. In this case, the subresources with | 415 // main resource also. In this case, the subresources with |
418 // certificate errors are ignored: if the main resource had a cert | 416 // certificate errors are ignored: if the main resource had a cert |
419 // error, it's not that useful to warn about subresources with cert | 417 // error, it's not that useful to warn about subresources with cert |
420 // errors as well. | 418 // errors as well. |
421 {security_state::DANGEROUS, net::CERT_STATUS_DATE_INVALID, | 419 {security_state::DANGEROUS, net::CERT_STATUS_DATE_INVALID, |
422 security_state::CONTENT_STATUS_NONE, | 420 security_state::CONTENT_STATUS_NONE, |
423 security_state::CONTENT_STATUS_DISPLAYED, | 421 security_state::CONTENT_STATUS_DISPLAYED, |
424 WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED, | 422 PageInfo::SITE_CONNECTION_STATUS_ENCRYPTED, |
425 WebsiteSettings::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_GOOD}, | 423 PageInfo::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_GOOD}, |
426 // Passive and active subresources with cert errors. | 424 // Passive and active subresources with cert errors. |
427 {security_state::DANGEROUS, 0, security_state::CONTENT_STATUS_NONE, | 425 {security_state::DANGEROUS, 0, security_state::CONTENT_STATUS_NONE, |
428 security_state::CONTENT_STATUS_DISPLAYED_AND_RAN, | 426 security_state::CONTENT_STATUS_DISPLAYED_AND_RAN, |
429 WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, | 427 PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
430 WebsiteSettings::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, | 428 PageInfo::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, |
431 // Passive and active subresources with cert errors, with a cert | 429 // Passive and active subresources with cert errors, with a cert |
432 // error on the main resource also. | 430 // error on the main resource also. |
433 {security_state::DANGEROUS, net::CERT_STATUS_DATE_INVALID, | 431 {security_state::DANGEROUS, net::CERT_STATUS_DATE_INVALID, |
434 security_state::CONTENT_STATUS_NONE, | 432 security_state::CONTENT_STATUS_NONE, |
435 security_state::CONTENT_STATUS_DISPLAYED_AND_RAN, | 433 security_state::CONTENT_STATUS_DISPLAYED_AND_RAN, |
436 WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED, | 434 PageInfo::SITE_CONNECTION_STATUS_ENCRYPTED, |
437 WebsiteSettings::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_GOOD}, | 435 PageInfo::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_GOOD}, |
438 // Active subresources with cert errors. | 436 // Active subresources with cert errors. |
439 {security_state::DANGEROUS, 0, security_state::CONTENT_STATUS_NONE, | 437 {security_state::DANGEROUS, 0, security_state::CONTENT_STATUS_NONE, |
440 security_state::CONTENT_STATUS_RAN, | 438 security_state::CONTENT_STATUS_RAN, |
441 WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, | 439 PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
442 WebsiteSettings::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, | 440 PageInfo::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, |
443 // Active subresources with cert errors, with a cert error on the main | 441 // Active subresources with cert errors, with a cert error on the main |
444 // resource also. | 442 // resource also. |
445 {security_state::DANGEROUS, net::CERT_STATUS_DATE_INVALID, | 443 {security_state::DANGEROUS, net::CERT_STATUS_DATE_INVALID, |
446 security_state::CONTENT_STATUS_NONE, security_state::CONTENT_STATUS_RAN, | 444 security_state::CONTENT_STATUS_NONE, security_state::CONTENT_STATUS_RAN, |
447 WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED, | 445 PageInfo::SITE_CONNECTION_STATUS_ENCRYPTED, |
448 WebsiteSettings::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_GOOD}, | 446 PageInfo::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_GOOD}, |
449 | 447 |
450 // Passive mixed content and subresources with cert errors. | 448 // Passive mixed content and subresources with cert errors. |
451 {security_state::NONE, 0, security_state::CONTENT_STATUS_DISPLAYED, | 449 {security_state::NONE, 0, security_state::CONTENT_STATUS_DISPLAYED, |
452 security_state::CONTENT_STATUS_DISPLAYED, | 450 security_state::CONTENT_STATUS_DISPLAYED, |
453 WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, | 451 PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, |
454 WebsiteSettings::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_WARNING_MINOR}, | 452 PageInfo::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_WARNING_MINOR}, |
455 // Passive mixed content and active subresources with cert errors. | 453 // Passive mixed content and active subresources with cert errors. |
456 {security_state::DANGEROUS, 0, security_state::CONTENT_STATUS_DISPLAYED, | 454 {security_state::DANGEROUS, 0, security_state::CONTENT_STATUS_DISPLAYED, |
457 security_state::CONTENT_STATUS_RAN, | 455 security_state::CONTENT_STATUS_RAN, |
458 WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, | 456 PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
459 WebsiteSettings::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, | 457 PageInfo::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, |
460 // Active mixed content and passive subresources with cert errors. | 458 // Active mixed content and passive subresources with cert errors. |
461 {security_state::DANGEROUS, 0, security_state::CONTENT_STATUS_RAN, | 459 {security_state::DANGEROUS, 0, security_state::CONTENT_STATUS_RAN, |
462 security_state::CONTENT_STATUS_DISPLAYED, | 460 security_state::CONTENT_STATUS_DISPLAYED, |
463 WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, | 461 PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, |
464 WebsiteSettings::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, | 462 PageInfo::SITE_IDENTITY_STATUS_CERT, IDR_PAGEINFO_BAD}, |
465 // Passive mixed content, active subresources with cert errors, and a cert | 463 // Passive mixed content, active subresources with cert errors, and a cert |
466 // error on the main resource. | 464 // error on the main resource. |
467 {security_state::DANGEROUS, net::CERT_STATUS_DATE_INVALID, | 465 {security_state::DANGEROUS, net::CERT_STATUS_DATE_INVALID, |
468 security_state::CONTENT_STATUS_DISPLAYED, | 466 security_state::CONTENT_STATUS_DISPLAYED, |
469 security_state::CONTENT_STATUS_RAN, | 467 security_state::CONTENT_STATUS_RAN, |
470 WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, | 468 PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, |
471 WebsiteSettings::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_WARNING_MINOR}, | 469 PageInfo::SITE_IDENTITY_STATUS_ERROR, IDR_PAGEINFO_WARNING_MINOR}, |
472 }; | 470 }; |
473 | 471 |
474 for (const auto& test : kTestCases) { | 472 for (const auto& test : kTestCases) { |
475 ResetMockUI(); | 473 ResetMockUI(); |
476 ClearWebsiteSettings(); | 474 ClearPageInfo(); |
477 security_info_ = security_state::SecurityInfo(); | 475 security_info_ = security_state::SecurityInfo(); |
478 security_info_.security_level = test.security_level; | 476 security_info_.security_level = test.security_level; |
479 security_info_.scheme_is_cryptographic = true; | 477 security_info_.scheme_is_cryptographic = true; |
480 security_info_.certificate = cert(); | 478 security_info_.certificate = cert(); |
481 security_info_.cert_status = test.cert_status; | 479 security_info_.cert_status = test.cert_status; |
482 security_info_.security_bits = 81; // No error if > 80. | 480 security_info_.security_bits = 81; // No error if > 80. |
483 security_info_.mixed_content_status = test.mixed_content_status; | 481 security_info_.mixed_content_status = test.mixed_content_status; |
484 security_info_.content_with_cert_errors_status = | 482 security_info_.content_with_cert_errors_status = |
485 test.content_with_cert_errors_status; | 483 test.content_with_cert_errors_status; |
486 int status = 0; | 484 int status = 0; |
487 status = SetSSLVersion(status, net::SSL_CONNECTION_VERSION_TLS1); | 485 status = SetSSLVersion(status, net::SSL_CONNECTION_VERSION_TLS1); |
488 status = SetSSLCipherSuite(status, CR_TLS_RSA_WITH_AES_256_CBC_SHA256); | 486 status = SetSSLCipherSuite(status, CR_TLS_RSA_WITH_AES_256_CBC_SHA256); |
489 security_info_.connection_status = status; | 487 security_info_.connection_status = status; |
490 | 488 |
491 SetDefaultUIExpectations(mock_ui()); | 489 SetDefaultUIExpectations(mock_ui()); |
492 | 490 |
493 EXPECT_EQ(test.expected_site_connection_status, | 491 EXPECT_EQ(test.expected_site_connection_status, |
494 website_settings()->site_connection_status()); | 492 page_info()->site_connection_status()); |
495 EXPECT_EQ(test.expected_site_identity_status, | 493 EXPECT_EQ(test.expected_site_identity_status, |
496 website_settings()->site_identity_status()); | 494 page_info()->site_identity_status()); |
497 EXPECT_EQ(test.expected_connection_icon_id, | 495 EXPECT_EQ( |
498 WebsiteSettingsUI::GetConnectionIconID( | 496 test.expected_connection_icon_id, |
499 website_settings()->site_connection_status())); | 497 PageInfoUI::GetConnectionIconID(page_info()->site_connection_status())); |
500 EXPECT_EQ(base::string16(), website_settings()->organization_name()); | 498 EXPECT_EQ(base::string16(), page_info()->organization_name()); |
501 } | 499 } |
502 } | 500 } |
503 | 501 |
504 TEST_F(WebsiteSettingsTest, HTTPSEVCert) { | 502 TEST_F(PageInfoTest, HTTPSEVCert) { |
505 scoped_refptr<net::X509Certificate> ev_cert = | 503 scoped_refptr<net::X509Certificate> ev_cert = |
506 net::X509Certificate::CreateFromBytes( | 504 net::X509Certificate::CreateFromBytes( |
507 reinterpret_cast<const char*>(google_der), sizeof(google_der)); | 505 reinterpret_cast<const char*>(google_der), sizeof(google_der)); |
508 ASSERT_TRUE(ev_cert); | 506 ASSERT_TRUE(ev_cert); |
509 | 507 |
510 security_info_.security_level = security_state::NONE; | 508 security_info_.security_level = security_state::NONE; |
511 security_info_.scheme_is_cryptographic = true; | 509 security_info_.scheme_is_cryptographic = true; |
512 security_info_.certificate = ev_cert; | 510 security_info_.certificate = ev_cert; |
513 security_info_.cert_status = net::CERT_STATUS_IS_EV; | 511 security_info_.cert_status = net::CERT_STATUS_IS_EV; |
514 security_info_.security_bits = 81; // No error if > 80. | 512 security_info_.security_bits = 81; // No error if > 80. |
515 security_info_.mixed_content_status = | 513 security_info_.mixed_content_status = |
516 security_state::CONTENT_STATUS_DISPLAYED; | 514 security_state::CONTENT_STATUS_DISPLAYED; |
517 int status = 0; | 515 int status = 0; |
518 status = SetSSLVersion(status, net::SSL_CONNECTION_VERSION_TLS1); | 516 status = SetSSLVersion(status, net::SSL_CONNECTION_VERSION_TLS1); |
519 status = SetSSLCipherSuite(status, CR_TLS_RSA_WITH_AES_256_CBC_SHA256); | 517 status = SetSSLCipherSuite(status, CR_TLS_RSA_WITH_AES_256_CBC_SHA256); |
520 security_info_.connection_status = status; | 518 security_info_.connection_status = status; |
521 | 519 |
522 SetDefaultUIExpectations(mock_ui()); | 520 SetDefaultUIExpectations(mock_ui()); |
523 | 521 |
524 EXPECT_EQ( | 522 EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, |
525 WebsiteSettings::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, | 523 page_info()->site_connection_status()); |
526 website_settings()->site_connection_status()); | 524 EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_EV_CERT, |
527 EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT, | 525 page_info()->site_identity_status()); |
528 website_settings()->site_identity_status()); | 526 EXPECT_EQ(base::UTF8ToUTF16("Google Inc"), page_info()->organization_name()); |
529 EXPECT_EQ(base::UTF8ToUTF16("Google Inc"), | |
530 website_settings()->organization_name()); | |
531 } | 527 } |
532 | 528 |
533 TEST_F(WebsiteSettingsTest, HTTPSRevocationError) { | 529 TEST_F(PageInfoTest, HTTPSRevocationError) { |
534 security_info_.security_level = security_state::SECURE; | 530 security_info_.security_level = security_state::SECURE; |
535 security_info_.scheme_is_cryptographic = true; | 531 security_info_.scheme_is_cryptographic = true; |
536 security_info_.certificate = cert(); | 532 security_info_.certificate = cert(); |
537 security_info_.cert_status = net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION; | 533 security_info_.cert_status = net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION; |
538 security_info_.security_bits = 81; // No error if > 80. | 534 security_info_.security_bits = 81; // No error if > 80. |
539 int status = 0; | 535 int status = 0; |
540 status = SetSSLVersion(status, net::SSL_CONNECTION_VERSION_TLS1); | 536 status = SetSSLVersion(status, net::SSL_CONNECTION_VERSION_TLS1); |
541 status = SetSSLCipherSuite(status, CR_TLS_RSA_WITH_AES_256_CBC_SHA256); | 537 status = SetSSLCipherSuite(status, CR_TLS_RSA_WITH_AES_256_CBC_SHA256); |
542 security_info_.connection_status = status; | 538 security_info_.connection_status = status; |
543 | 539 |
544 SetDefaultUIExpectations(mock_ui()); | 540 SetDefaultUIExpectations(mock_ui()); |
545 | 541 |
546 EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED, | 542 EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_ENCRYPTED, |
547 website_settings()->site_connection_status()); | 543 page_info()->site_connection_status()); |
548 EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN, | 544 EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN, |
549 website_settings()->site_identity_status()); | 545 page_info()->site_identity_status()); |
550 EXPECT_EQ(base::string16(), website_settings()->organization_name()); | 546 EXPECT_EQ(base::string16(), page_info()->organization_name()); |
551 } | 547 } |
552 | 548 |
553 TEST_F(WebsiteSettingsTest, HTTPSConnectionError) { | 549 TEST_F(PageInfoTest, HTTPSConnectionError) { |
554 security_info_.security_level = security_state::SECURE; | 550 security_info_.security_level = security_state::SECURE; |
555 security_info_.scheme_is_cryptographic = true; | 551 security_info_.scheme_is_cryptographic = true; |
556 security_info_.certificate = cert(); | 552 security_info_.certificate = cert(); |
557 security_info_.cert_status = 0; | 553 security_info_.cert_status = 0; |
558 security_info_.security_bits = -1; | 554 security_info_.security_bits = -1; |
559 int status = 0; | 555 int status = 0; |
560 status = SetSSLVersion(status, net::SSL_CONNECTION_VERSION_TLS1); | 556 status = SetSSLVersion(status, net::SSL_CONNECTION_VERSION_TLS1); |
561 status = SetSSLCipherSuite(status, CR_TLS_RSA_WITH_AES_256_CBC_SHA256); | 557 status = SetSSLCipherSuite(status, CR_TLS_RSA_WITH_AES_256_CBC_SHA256); |
562 security_info_.connection_status = status; | 558 security_info_.connection_status = status; |
563 | 559 |
564 SetDefaultUIExpectations(mock_ui()); | 560 SetDefaultUIExpectations(mock_ui()); |
565 | 561 |
566 EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED_ERROR, | 562 EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_ENCRYPTED_ERROR, |
567 website_settings()->site_connection_status()); | 563 page_info()->site_connection_status()); |
568 EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_CERT, | 564 EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_CERT, |
569 website_settings()->site_identity_status()); | 565 page_info()->site_identity_status()); |
570 EXPECT_EQ(base::string16(), website_settings()->organization_name()); | 566 EXPECT_EQ(base::string16(), page_info()->organization_name()); |
571 } | 567 } |
572 | 568 |
573 TEST_F(WebsiteSettingsTest, HTTPSPolicyCertConnection) { | 569 TEST_F(PageInfoTest, HTTPSPolicyCertConnection) { |
574 security_info_.security_level = | 570 security_info_.security_level = |
575 security_state::SECURE_WITH_POLICY_INSTALLED_CERT; | 571 security_state::SECURE_WITH_POLICY_INSTALLED_CERT; |
576 security_info_.scheme_is_cryptographic = true; | 572 security_info_.scheme_is_cryptographic = true; |
577 security_info_.certificate = cert(); | 573 security_info_.certificate = cert(); |
578 security_info_.cert_status = 0; | 574 security_info_.cert_status = 0; |
579 security_info_.security_bits = 81; // No error if > 80. | 575 security_info_.security_bits = 81; // No error if > 80. |
580 int status = 0; | 576 int status = 0; |
581 status = SetSSLVersion(status, net::SSL_CONNECTION_VERSION_TLS1); | 577 status = SetSSLVersion(status, net::SSL_CONNECTION_VERSION_TLS1); |
582 status = SetSSLCipherSuite(status, CR_TLS_RSA_WITH_AES_256_CBC_SHA256); | 578 status = SetSSLCipherSuite(status, CR_TLS_RSA_WITH_AES_256_CBC_SHA256); |
583 security_info_.connection_status = status; | 579 security_info_.connection_status = status; |
584 | 580 |
585 SetDefaultUIExpectations(mock_ui()); | 581 SetDefaultUIExpectations(mock_ui()); |
586 | 582 |
587 EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED, | 583 EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_ENCRYPTED, |
588 website_settings()->site_connection_status()); | 584 page_info()->site_connection_status()); |
589 EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT, | 585 EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT, |
590 website_settings()->site_identity_status()); | 586 page_info()->site_identity_status()); |
591 EXPECT_EQ(base::string16(), website_settings()->organization_name()); | 587 EXPECT_EQ(base::string16(), page_info()->organization_name()); |
592 } | 588 } |
593 | 589 |
594 TEST_F(WebsiteSettingsTest, HTTPSSHA1) { | 590 TEST_F(PageInfoTest, HTTPSSHA1) { |
595 security_info_.security_level = security_state::NONE; | 591 security_info_.security_level = security_state::NONE; |
596 security_info_.scheme_is_cryptographic = true; | 592 security_info_.scheme_is_cryptographic = true; |
597 security_info_.certificate = cert(); | 593 security_info_.certificate = cert(); |
598 security_info_.cert_status = 0; | 594 security_info_.cert_status = 0; |
599 security_info_.security_bits = 81; // No error if > 80. | 595 security_info_.security_bits = 81; // No error if > 80. |
600 int status = 0; | 596 int status = 0; |
601 status = SetSSLVersion(status, net::SSL_CONNECTION_VERSION_TLS1); | 597 status = SetSSLVersion(status, net::SSL_CONNECTION_VERSION_TLS1); |
602 status = SetSSLCipherSuite(status, CR_TLS_RSA_WITH_AES_256_CBC_SHA256); | 598 status = SetSSLCipherSuite(status, CR_TLS_RSA_WITH_AES_256_CBC_SHA256); |
603 security_info_.connection_status = status; | 599 security_info_.connection_status = status; |
604 security_info_.sha1_in_chain = true; | 600 security_info_.sha1_in_chain = true; |
605 | 601 |
606 SetDefaultUIExpectations(mock_ui()); | 602 SetDefaultUIExpectations(mock_ui()); |
607 | 603 |
608 EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED, | 604 EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_ENCRYPTED, |
609 website_settings()->site_connection_status()); | 605 page_info()->site_connection_status()); |
610 EXPECT_EQ( | 606 EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM, |
611 WebsiteSettings::SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM, | 607 page_info()->site_identity_status()); |
612 website_settings()->site_identity_status()); | 608 EXPECT_EQ(base::string16(), page_info()->organization_name()); |
613 EXPECT_EQ(base::string16(), website_settings()->organization_name()); | |
614 EXPECT_EQ(IDR_PAGEINFO_WARNING_MINOR, | 609 EXPECT_EQ(IDR_PAGEINFO_WARNING_MINOR, |
615 WebsiteSettingsUI::GetIdentityIconID( | 610 PageInfoUI::GetIdentityIconID(page_info()->site_identity_status())); |
616 website_settings()->site_identity_status())); | |
617 } | 611 } |
618 | 612 |
619 #if !defined(OS_ANDROID) | 613 #if !defined(OS_ANDROID) |
620 TEST_F(WebsiteSettingsTest, NoInfoBar) { | 614 TEST_F(PageInfoTest, NoInfoBar) { |
621 SetDefaultUIExpectations(mock_ui()); | 615 SetDefaultUIExpectations(mock_ui()); |
622 EXPECT_EQ(0u, infobar_service()->infobar_count()); | 616 EXPECT_EQ(0u, infobar_service()->infobar_count()); |
623 website_settings()->OnUIClosing(); | 617 page_info()->OnUIClosing(); |
624 EXPECT_EQ(0u, infobar_service()->infobar_count()); | 618 EXPECT_EQ(0u, infobar_service()->infobar_count()); |
625 } | 619 } |
626 | 620 |
627 TEST_F(WebsiteSettingsTest, ShowInfoBar) { | 621 TEST_F(PageInfoTest, ShowInfoBar) { |
628 EXPECT_CALL(*mock_ui(), SetIdentityInfo(_)); | 622 EXPECT_CALL(*mock_ui(), SetIdentityInfo(_)); |
629 EXPECT_CALL(*mock_ui(), SetCookieInfo(_)); | 623 EXPECT_CALL(*mock_ui(), SetCookieInfo(_)); |
630 | 624 |
631 EXPECT_CALL(*mock_ui(), SetPermissionInfoStub()).Times(2); | 625 EXPECT_CALL(*mock_ui(), SetPermissionInfoStub()).Times(2); |
632 | 626 |
633 EXPECT_EQ(0u, infobar_service()->infobar_count()); | 627 EXPECT_EQ(0u, infobar_service()->infobar_count()); |
634 website_settings()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_GEOLOCATION, | 628 page_info()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_GEOLOCATION, |
635 CONTENT_SETTING_ALLOW); | 629 CONTENT_SETTING_ALLOW); |
636 website_settings()->OnUIClosing(); | 630 page_info()->OnUIClosing(); |
637 ASSERT_EQ(1u, infobar_service()->infobar_count()); | 631 ASSERT_EQ(1u, infobar_service()->infobar_count()); |
638 | 632 |
639 infobar_service()->RemoveInfoBar(infobar_service()->infobar_at(0)); | 633 infobar_service()->RemoveInfoBar(infobar_service()->infobar_at(0)); |
640 } | 634 } |
641 #endif | 635 #endif |
642 | 636 |
643 TEST_F(WebsiteSettingsTest, AboutBlankPage) { | 637 TEST_F(PageInfoTest, AboutBlankPage) { |
644 SetURL("about:blank"); | 638 SetURL("about:blank"); |
645 SetDefaultUIExpectations(mock_ui()); | 639 SetDefaultUIExpectations(mock_ui()); |
646 EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_UNENCRYPTED, | 640 EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_UNENCRYPTED, |
647 website_settings()->site_connection_status()); | 641 page_info()->site_connection_status()); |
648 EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_NO_CERT, | 642 EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_NO_CERT, |
649 website_settings()->site_identity_status()); | 643 page_info()->site_identity_status()); |
650 EXPECT_EQ(base::string16(), website_settings()->organization_name()); | 644 EXPECT_EQ(base::string16(), page_info()->organization_name()); |
651 } | 645 } |
652 | 646 |
653 // On desktop, internal URLs aren't handled by WebsiteSettings class. Instead, a | 647 // On desktop, internal URLs aren't handled by PageInfo class. Instead, a |
654 // custom and simpler popup is shown, so no need to test. | 648 // custom and simpler popup is shown, so no need to test. |
655 #if defined(OS_ANDROID) || defined(OS_IOS) | 649 #if defined(OS_ANDROID) || defined(OS_IOS) |
656 TEST_F(WebsiteSettingsTest, InternalPage) { | 650 TEST_F(PageInfoTest, InternalPage) { |
657 SetURL("chrome://bookmarks"); | 651 SetURL("chrome://bookmarks"); |
658 SetDefaultUIExpectations(mock_ui()); | 652 SetDefaultUIExpectations(mock_ui()); |
659 EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_INTERNAL_PAGE, | 653 EXPECT_EQ(PageInfo::SITE_CONNECTION_STATUS_INTERNAL_PAGE, |
660 website_settings()->site_connection_status()); | 654 page_info()->site_connection_status()); |
661 EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_INTERNAL_PAGE, | 655 EXPECT_EQ(PageInfo::SITE_IDENTITY_STATUS_INTERNAL_PAGE, |
662 website_settings()->site_identity_status()); | 656 page_info()->site_identity_status()); |
663 EXPECT_EQ(base::string16(), website_settings()->organization_name()); | 657 EXPECT_EQ(base::string16(), page_info()->organization_name()); |
664 } | 658 } |
665 #endif | 659 #endif |
666 | 660 |
667 // Tests that metrics are recorded on a WebsiteSettings for pages with | 661 // Tests that metrics are recorded on a PageInfo for pages with |
668 // various security levels. | 662 // various security levels. |
669 TEST_F(WebsiteSettingsTest, SecurityLevelMetrics) { | 663 TEST_F(PageInfoTest, SecurityLevelMetrics) { |
670 struct TestCase { | 664 struct TestCase { |
671 const std::string url; | 665 const std::string url; |
672 const security_state::SecurityLevel security_level; | 666 const security_state::SecurityLevel security_level; |
673 const std::string histogram_name; | 667 const std::string histogram_name; |
674 }; | 668 }; |
675 const char kGenericHistogram[] = "WebsiteSettings.Action"; | 669 const char kGenericHistogram[] = "WebsiteSettings.Action"; |
676 | 670 |
677 const TestCase kTestCases[] = { | 671 const TestCase kTestCases[] = { |
678 {"https://example.test", security_state::SECURE, | 672 {"https://example.test", security_state::SECURE, |
679 "Security.PageInfo.Action.HttpsUrl.Valid"}, | 673 "Security.PageInfo.Action.HttpsUrl.Valid"}, |
680 {"https://example.test", security_state::EV_SECURE, | 674 {"https://example.test", security_state::EV_SECURE, |
681 "Security.PageInfo.Action.HttpsUrl.Valid"}, | 675 "Security.PageInfo.Action.HttpsUrl.Valid"}, |
682 {"https://example2.test", security_state::NONE, | 676 {"https://example2.test", security_state::NONE, |
683 "Security.PageInfo.Action.HttpsUrl.Downgraded"}, | 677 "Security.PageInfo.Action.HttpsUrl.Downgraded"}, |
684 {"https://example.test", security_state::DANGEROUS, | 678 {"https://example.test", security_state::DANGEROUS, |
685 "Security.PageInfo.Action.HttpsUrl.Dangerous"}, | 679 "Security.PageInfo.Action.HttpsUrl.Dangerous"}, |
686 {"http://example.test", security_state::HTTP_SHOW_WARNING, | 680 {"http://example.test", security_state::HTTP_SHOW_WARNING, |
687 "Security.PageInfo.Action.HttpUrl.Warning"}, | 681 "Security.PageInfo.Action.HttpUrl.Warning"}, |
688 {"http://example.test", security_state::DANGEROUS, | 682 {"http://example.test", security_state::DANGEROUS, |
689 "Security.PageInfo.Action.HttpUrl.Dangerous"}, | 683 "Security.PageInfo.Action.HttpUrl.Dangerous"}, |
690 {"http://example.test", security_state::NONE, | 684 {"http://example.test", security_state::NONE, |
691 "Security.PageInfo.Action.HttpUrl.Neutral"}, | 685 "Security.PageInfo.Action.HttpUrl.Neutral"}, |
692 }; | 686 }; |
693 | 687 |
694 for (const auto& test : kTestCases) { | 688 for (const auto& test : kTestCases) { |
695 base::HistogramTester histograms; | 689 base::HistogramTester histograms; |
696 SetURL(test.url); | 690 SetURL(test.url); |
697 security_info_.security_level = test.security_level; | 691 security_info_.security_level = test.security_level; |
698 ResetMockUI(); | 692 ResetMockUI(); |
699 ClearWebsiteSettings(); | 693 ClearPageInfo(); |
700 SetDefaultUIExpectations(mock_ui()); | 694 SetDefaultUIExpectations(mock_ui()); |
701 | 695 |
702 histograms.ExpectTotalCount(kGenericHistogram, 0); | 696 histograms.ExpectTotalCount(kGenericHistogram, 0); |
703 histograms.ExpectTotalCount(test.histogram_name, 0); | 697 histograms.ExpectTotalCount(test.histogram_name, 0); |
704 | 698 |
705 website_settings()->RecordWebsiteSettingsAction( | 699 page_info()->RecordPageInfoAction( |
706 WebsiteSettings::WebsiteSettingsAction::WEBSITE_SETTINGS_OPENED); | 700 PageInfo::PageInfoAction::PAGE_INFO_OPENED); |
707 | 701 |
708 // RecordWebsiteSettingsAction() is called during WebsiteSettings | 702 // RecordPageInfoAction() is called during PageInfo |
709 // creation in addition to the explicit RecordWebsiteSettingsAction() | 703 // creation in addition to the explicit RecordPageInfoAction() |
710 // call, so it is called twice in total. | 704 // call, so it is called twice in total. |
711 histograms.ExpectTotalCount(kGenericHistogram, 2); | 705 histograms.ExpectTotalCount(kGenericHistogram, 2); |
712 histograms.ExpectBucketCount( | 706 histograms.ExpectBucketCount(kGenericHistogram, |
713 kGenericHistogram, | 707 PageInfo::PageInfoAction::PAGE_INFO_OPENED, 2); |
714 WebsiteSettings::WebsiteSettingsAction::WEBSITE_SETTINGS_OPENED, 2); | |
715 | 708 |
716 histograms.ExpectTotalCount(test.histogram_name, 2); | 709 histograms.ExpectTotalCount(test.histogram_name, 2); |
717 histograms.ExpectBucketCount( | 710 histograms.ExpectBucketCount(test.histogram_name, |
718 test.histogram_name, | 711 PageInfo::PageInfoAction::PAGE_INFO_OPENED, 2); |
719 WebsiteSettings::WebsiteSettingsAction::WEBSITE_SETTINGS_OPENED, 2); | |
720 } | 712 } |
721 } | 713 } |
OLD | NEW |