| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/website_settings/website_settings.h" | 5 #include "chrome/browser/ui/website_settings/website_settings.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 url(), url(), CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string()); | 261 url(), url(), CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string()); |
| 262 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); | 262 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); |
| 263 setting = content_settings->GetContentSetting( | 263 setting = content_settings->GetContentSetting( |
| 264 url(), url(), CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, std::string()); | 264 url(), url(), CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, std::string()); |
| 265 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); | 265 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); |
| 266 setting = content_settings->GetContentSetting( | 266 setting = content_settings->GetContentSetting( |
| 267 url(), url(), CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string()); | 267 url(), url(), CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string()); |
| 268 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); | 268 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); |
| 269 } | 269 } |
| 270 | 270 |
| 271 TEST_F(WebsiteSettingsTest, OnPermissionsChanged_Fullscreen) { | |
| 272 // Setup site permissions. | |
| 273 HostContentSettingsMap* content_settings = | |
| 274 HostContentSettingsMapFactory::GetForProfile(profile()); | |
| 275 ContentSetting setting = content_settings->GetContentSetting( | |
| 276 url(), url(), CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string()); | |
| 277 EXPECT_EQ(setting, CONTENT_SETTING_ASK); | |
| 278 | |
| 279 EXPECT_CALL(*mock_ui(), SetIdentityInfo(_)); | |
| 280 EXPECT_CALL(*mock_ui(), SetCookieInfo(_)); | |
| 281 EXPECT_CALL(*mock_ui(), SetSelectedTab( | |
| 282 WebsiteSettingsUI::TAB_ID_PERMISSIONS)); | |
| 283 | |
| 284 // SetPermissionInfo() is called once initially, and then again every time | |
| 285 // OnSitePermissionChanged() is called. | |
| 286 EXPECT_CALL(*mock_ui(), SetPermissionInfoStub()).Times(3); | |
| 287 | |
| 288 // Execute code under tests. | |
| 289 website_settings()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_FULLSCREEN, | |
| 290 CONTENT_SETTING_ALLOW); | |
| 291 | |
| 292 // Verify that the site permissions were changed correctly. | |
| 293 setting = content_settings->GetContentSetting( | |
| 294 url(), url(), CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string()); | |
| 295 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); | |
| 296 | |
| 297 // ... and that the primary pattern must match the secondary one. | |
| 298 setting = content_settings->GetContentSetting( | |
| 299 url(), GURL("https://test.com"), | |
| 300 CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string()); | |
| 301 EXPECT_EQ(setting, CONTENT_SETTING_ASK); | |
| 302 | |
| 303 | |
| 304 // Resetting the setting should move the permission back to ASK. | |
| 305 website_settings()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_FULLSCREEN, | |
| 306 CONTENT_SETTING_ASK); | |
| 307 | |
| 308 setting = content_settings->GetContentSetting( | |
| 309 url(), url(), CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string()); | |
| 310 EXPECT_EQ(setting, CONTENT_SETTING_ASK); | |
| 311 } | |
| 312 | |
| 313 TEST_F(WebsiteSettingsTest, OnSiteDataAccessed) { | 271 TEST_F(WebsiteSettingsTest, OnSiteDataAccessed) { |
| 314 EXPECT_CALL(*mock_ui(), SetPermissionInfoStub()); | 272 EXPECT_CALL(*mock_ui(), SetPermissionInfoStub()); |
| 315 EXPECT_CALL(*mock_ui(), SetIdentityInfo(_)); | 273 EXPECT_CALL(*mock_ui(), SetIdentityInfo(_)); |
| 316 EXPECT_CALL(*mock_ui(), SetCookieInfo(_)).Times(2); | 274 EXPECT_CALL(*mock_ui(), SetCookieInfo(_)).Times(2); |
| 317 EXPECT_CALL(*mock_ui(), SetSelectedTab( | 275 EXPECT_CALL(*mock_ui(), SetSelectedTab( |
| 318 WebsiteSettingsUI::TAB_ID_PERMISSIONS)); | 276 WebsiteSettingsUI::TAB_ID_PERMISSIONS)); |
| 319 | 277 |
| 320 website_settings()->OnSiteDataAccessed(); | 278 website_settings()->OnSiteDataAccessed(); |
| 321 } | 279 } |
| 322 | 280 |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 histograms.ExpectTotalCount(test.histogram_name, 2); | 910 histograms.ExpectTotalCount(test.histogram_name, 2); |
| 953 histograms.ExpectBucketCount( | 911 histograms.ExpectBucketCount( |
| 954 test.histogram_name, | 912 test.histogram_name, |
| 955 WebsiteSettings::WebsiteSettingsAction::WEBSITE_SETTINGS_OPENED, 1); | 913 WebsiteSettings::WebsiteSettingsAction::WEBSITE_SETTINGS_OPENED, 1); |
| 956 histograms.ExpectBucketCount(test.histogram_name, | 914 histograms.ExpectBucketCount(test.histogram_name, |
| 957 WebsiteSettings::WebsiteSettingsAction:: | 915 WebsiteSettings::WebsiteSettingsAction:: |
| 958 WEBSITE_SETTINGS_PERMISSIONS_TAB_SELECTED, | 916 WEBSITE_SETTINGS_PERMISSIONS_TAB_SELECTED, |
| 959 1); | 917 1); |
| 960 } | 918 } |
| 961 } | 919 } |
| OLD | NEW |