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 19 matching lines...) Expand all Loading... |
30 #include "content/public/browser/ssl_status.h" | 30 #include "content/public/browser/ssl_status.h" |
31 #include "device/base/mock_device_client.h" | 31 #include "device/base/mock_device_client.h" |
32 #include "device/usb/mock_usb_device.h" | 32 #include "device/usb/mock_usb_device.h" |
33 #include "device/usb/mock_usb_service.h" | 33 #include "device/usb/mock_usb_service.h" |
34 #include "net/cert/cert_status_flags.h" | 34 #include "net/cert/cert_status_flags.h" |
35 #include "net/cert/x509_certificate.h" | 35 #include "net/cert/x509_certificate.h" |
36 #include "net/ssl/ssl_connection_status_flags.h" | 36 #include "net/ssl/ssl_connection_status_flags.h" |
37 #include "net/test/cert_test_util.h" | 37 #include "net/test/cert_test_util.h" |
38 #include "net/test/test_certificate_data.h" | 38 #include "net/test/test_certificate_data.h" |
39 #include "net/test/test_data_directory.h" | 39 #include "net/test/test_data_directory.h" |
| 40 #include "ppapi/features/features.h" |
40 #include "testing/gmock/include/gmock/gmock.h" | 41 #include "testing/gmock/include/gmock/gmock.h" |
41 #include "testing/gtest/include/gtest/gtest.h" | 42 #include "testing/gtest/include/gtest/gtest.h" |
42 | 43 |
43 using content::SSLStatus; | 44 using content::SSLStatus; |
44 using testing::_; | 45 using testing::_; |
45 using testing::AnyNumber; | 46 using testing::AnyNumber; |
46 using testing::Invoke; | 47 using testing::Invoke; |
47 using testing::Return; | 48 using testing::Return; |
48 using testing::SetArgPointee; | 49 using testing::SetArgPointee; |
49 | 50 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 190 |
190 } // namespace | 191 } // namespace |
191 | 192 |
192 TEST_F(WebsiteSettingsTest, OnPermissionsChanged) { | 193 TEST_F(WebsiteSettingsTest, OnPermissionsChanged) { |
193 // Setup site permissions. | 194 // Setup site permissions. |
194 HostContentSettingsMap* content_settings = | 195 HostContentSettingsMap* content_settings = |
195 HostContentSettingsMapFactory::GetForProfile(profile()); | 196 HostContentSettingsMapFactory::GetForProfile(profile()); |
196 ContentSetting setting = content_settings->GetContentSetting( | 197 ContentSetting setting = content_settings->GetContentSetting( |
197 url(), url(), CONTENT_SETTINGS_TYPE_POPUPS, std::string()); | 198 url(), url(), CONTENT_SETTINGS_TYPE_POPUPS, std::string()); |
198 EXPECT_EQ(setting, CONTENT_SETTING_BLOCK); | 199 EXPECT_EQ(setting, CONTENT_SETTING_BLOCK); |
199 #if defined(ENABLE_PLUGINS) | 200 #if BUILDFLAG(ENABLE_PLUGINS) |
200 setting = content_settings->GetContentSetting( | 201 setting = content_settings->GetContentSetting( |
201 url(), url(), CONTENT_SETTINGS_TYPE_PLUGINS, std::string()); | 202 url(), url(), CONTENT_SETTINGS_TYPE_PLUGINS, std::string()); |
202 EXPECT_EQ(setting, CONTENT_SETTING_DETECT_IMPORTANT_CONTENT); | 203 EXPECT_EQ(setting, CONTENT_SETTING_DETECT_IMPORTANT_CONTENT); |
203 #endif | 204 #endif |
204 setting = content_settings->GetContentSetting( | 205 setting = content_settings->GetContentSetting( |
205 url(), url(), CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string()); | 206 url(), url(), CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string()); |
206 EXPECT_EQ(setting, CONTENT_SETTING_ASK); | 207 EXPECT_EQ(setting, CONTENT_SETTING_ASK); |
207 setting = content_settings->GetContentSetting( | 208 setting = content_settings->GetContentSetting( |
208 url(), url(), CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string()); | 209 url(), url(), CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string()); |
209 EXPECT_EQ(setting, CONTENT_SETTING_ASK); | 210 EXPECT_EQ(setting, CONTENT_SETTING_ASK); |
210 setting = content_settings->GetContentSetting( | 211 setting = content_settings->GetContentSetting( |
211 url(), url(), CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, std::string()); | 212 url(), url(), CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, std::string()); |
212 EXPECT_EQ(setting, CONTENT_SETTING_ASK); | 213 EXPECT_EQ(setting, CONTENT_SETTING_ASK); |
213 setting = content_settings->GetContentSetting( | 214 setting = content_settings->GetContentSetting( |
214 url(), url(), CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string()); | 215 url(), url(), CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string()); |
215 EXPECT_EQ(setting, CONTENT_SETTING_ASK); | 216 EXPECT_EQ(setting, CONTENT_SETTING_ASK); |
216 | 217 |
217 EXPECT_CALL(*mock_ui(), SetIdentityInfo(_)); | 218 EXPECT_CALL(*mock_ui(), SetIdentityInfo(_)); |
218 EXPECT_CALL(*mock_ui(), SetCookieInfo(_)); | 219 EXPECT_CALL(*mock_ui(), SetCookieInfo(_)); |
219 | 220 |
220 // SetPermissionInfo() is called once initially, and then again every time | 221 // SetPermissionInfo() is called once initially, and then again every time |
221 // OnSitePermissionChanged() is called. | 222 // OnSitePermissionChanged() is called. |
222 #if !defined(ENABLE_PLUGINS) | 223 #if !BUILDFLAG(ENABLE_PLUGINS) |
223 // SetPermissionInfo for plugins didn't get called. | 224 // SetPermissionInfo for plugins didn't get called. |
224 EXPECT_CALL(*mock_ui(), SetPermissionInfoStub()).Times(6); | 225 EXPECT_CALL(*mock_ui(), SetPermissionInfoStub()).Times(6); |
225 #else | 226 #else |
226 EXPECT_CALL(*mock_ui(), SetPermissionInfoStub()).Times(7); | 227 EXPECT_CALL(*mock_ui(), SetPermissionInfoStub()).Times(7); |
227 #endif | 228 #endif |
228 EXPECT_CALL(*mock_ui(), SetSelectedTab( | 229 EXPECT_CALL(*mock_ui(), SetSelectedTab( |
229 WebsiteSettingsUI::TAB_ID_PERMISSIONS)); | 230 WebsiteSettingsUI::TAB_ID_PERMISSIONS)); |
230 | 231 |
231 // Execute code under tests. | 232 // Execute code under tests. |
232 website_settings()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_POPUPS, | 233 website_settings()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_POPUPS, |
233 CONTENT_SETTING_ALLOW); | 234 CONTENT_SETTING_ALLOW); |
234 #if defined(ENABLE_PLUGINS) | 235 #if BUILDFLAG(ENABLE_PLUGINS) |
235 website_settings()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_PLUGINS, | 236 website_settings()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_PLUGINS, |
236 CONTENT_SETTING_BLOCK); | 237 CONTENT_SETTING_BLOCK); |
237 #endif | 238 #endif |
238 website_settings()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_GEOLOCATION, | 239 website_settings()->OnSitePermissionChanged(CONTENT_SETTINGS_TYPE_GEOLOCATION, |
239 CONTENT_SETTING_ALLOW); | 240 CONTENT_SETTING_ALLOW); |
240 website_settings()->OnSitePermissionChanged( | 241 website_settings()->OnSitePermissionChanged( |
241 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTING_ALLOW); | 242 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTING_ALLOW); |
242 website_settings()->OnSitePermissionChanged( | 243 website_settings()->OnSitePermissionChanged( |
243 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, CONTENT_SETTING_ALLOW); | 244 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, CONTENT_SETTING_ALLOW); |
244 website_settings()->OnSitePermissionChanged( | 245 website_settings()->OnSitePermissionChanged( |
245 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, CONTENT_SETTING_ALLOW); | 246 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, CONTENT_SETTING_ALLOW); |
246 | 247 |
247 // Verify that the site permissions were changed correctly. | 248 // Verify that the site permissions were changed correctly. |
248 setting = content_settings->GetContentSetting( | 249 setting = content_settings->GetContentSetting( |
249 url(), url(), CONTENT_SETTINGS_TYPE_POPUPS, std::string()); | 250 url(), url(), CONTENT_SETTINGS_TYPE_POPUPS, std::string()); |
250 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); | 251 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); |
251 #if defined(ENABLE_PLUGINS) | 252 #if BUILDFLAG(ENABLE_PLUGINS) |
252 setting = content_settings->GetContentSetting( | 253 setting = content_settings->GetContentSetting( |
253 url(), url(), CONTENT_SETTINGS_TYPE_PLUGINS, std::string()); | 254 url(), url(), CONTENT_SETTINGS_TYPE_PLUGINS, std::string()); |
254 EXPECT_EQ(setting, CONTENT_SETTING_BLOCK); | 255 EXPECT_EQ(setting, CONTENT_SETTING_BLOCK); |
255 #endif | 256 #endif |
256 setting = content_settings->GetContentSetting( | 257 setting = content_settings->GetContentSetting( |
257 url(), url(), CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string()); | 258 url(), url(), CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string()); |
258 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); | 259 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); |
259 setting = content_settings->GetContentSetting( | 260 setting = content_settings->GetContentSetting( |
260 url(), url(), CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string()); | 261 url(), url(), CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string()); |
261 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); | 262 EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 histograms.ExpectTotalCount(test.histogram_name, 2); | 779 histograms.ExpectTotalCount(test.histogram_name, 2); |
779 histograms.ExpectBucketCount( | 780 histograms.ExpectBucketCount( |
780 test.histogram_name, | 781 test.histogram_name, |
781 WebsiteSettings::WebsiteSettingsAction::WEBSITE_SETTINGS_OPENED, 1); | 782 WebsiteSettings::WebsiteSettingsAction::WEBSITE_SETTINGS_OPENED, 1); |
782 histograms.ExpectBucketCount(test.histogram_name, | 783 histograms.ExpectBucketCount(test.histogram_name, |
783 WebsiteSettings::WebsiteSettingsAction:: | 784 WebsiteSettings::WebsiteSettingsAction:: |
784 WEBSITE_SETTINGS_PERMISSIONS_TAB_SELECTED, | 785 WEBSITE_SETTINGS_PERMISSIONS_TAB_SELECTED, |
785 1); | 786 1); |
786 } | 787 } |
787 } | 788 } |
OLD | NEW |