| 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 "base/path_service.h" | 5 #include "base/path_service.h" |
| 6 #include "base/test/test_timeouts.h" | 6 #include "base/test/test_timeouts.h" |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 8 #include "chrome/browser/extensions/extension_browsertest.h" | 9 #include "chrome/browser/extensions/extension_browsertest.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/browser_navigator.h" | 12 #include "chrome/browser/ui/browser_navigator.h" |
| 12 #include "chrome/browser/ui/extensions/app_launch_params.h" | 13 #include "chrome/browser/ui/extensions/app_launch_params.h" |
| 13 #include "chrome/browser/ui/extensions/application_launch.h" | 14 #include "chrome/browser/ui/extensions/application_launch.h" |
| 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 15 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
| 16 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
| 17 #include "chrome/test/nacl/nacl_browsertest_util.h" | 18 #include "chrome/test/nacl/nacl_browsertest_util.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 137 |
| 137 // PPB_Broker_Trusted::IsAllowed should return false before the infobar is | 138 // PPB_Broker_Trusted::IsAllowed should return false before the infobar is |
| 138 // popped and true after the infobar is popped. | 139 // popped and true after the infobar is popped. |
| 139 RunTest("Broker_IsAllowedPermissionDenied"); | 140 RunTest("Broker_IsAllowedPermissionDenied"); |
| 140 RunTest("Broker_ConnectPermissionGranted"); | 141 RunTest("Broker_ConnectPermissionGranted"); |
| 141 RunTest("Broker_IsAllowedPermissionGranted"); | 142 RunTest("Broker_IsAllowedPermissionGranted"); |
| 142 | 143 |
| 143 // It should also set a content settings exception for the site. | 144 // It should also set a content settings exception for the site. |
| 144 GURL url = GetTestFileUrl("Broker_ConnectPermissionGranted"); | 145 GURL url = GetTestFileUrl("Broker_ConnectPermissionGranted"); |
| 145 HostContentSettingsMap* content_settings = | 146 HostContentSettingsMap* content_settings = |
| 146 browser()->profile()->GetHostContentSettingsMap(); | 147 HostContentSettingsMapFactory::GetForProfile(browser()->profile()); |
| 147 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 148 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 148 content_settings->GetContentSetting( | 149 content_settings->GetContentSetting( |
| 149 url, url, CONTENT_SETTINGS_TYPE_PPAPI_BROKER, std::string())); | 150 url, url, CONTENT_SETTINGS_TYPE_PPAPI_BROKER, std::string())); |
| 150 } | 151 } |
| 151 | 152 |
| 152 IN_PROC_BROWSER_TEST_F(PPAPIBrokerInfoBarTest, Deny) { | 153 IN_PROC_BROWSER_TEST_F(PPAPIBrokerInfoBarTest, Deny) { |
| 153 // Canceling the infobar should deny permission to access the PPAPI broker. | 154 // Canceling the infobar should deny permission to access the PPAPI broker. |
| 154 InfoBarObserver observer(this); | 155 InfoBarObserver observer(this); |
| 155 observer.ExpectInfoBarAndAccept(false); | 156 observer.ExpectInfoBarAndAccept(false); |
| 156 | 157 |
| 157 // PPB_Broker_Trusted::IsAllowed should return false before and after the | 158 // PPB_Broker_Trusted::IsAllowed should return false before and after the |
| 158 // infobar is popped. | 159 // infobar is popped. |
| 159 RunTest("Broker_IsAllowedPermissionDenied"); | 160 RunTest("Broker_IsAllowedPermissionDenied"); |
| 160 RunTest("Broker_ConnectPermissionDenied"); | 161 RunTest("Broker_ConnectPermissionDenied"); |
| 161 RunTest("Broker_IsAllowedPermissionDenied"); | 162 RunTest("Broker_IsAllowedPermissionDenied"); |
| 162 | 163 |
| 163 // It should also set a content settings exception for the site. | 164 // It should also set a content settings exception for the site. |
| 164 GURL url = GetTestFileUrl("Broker_ConnectPermissionDenied"); | 165 GURL url = GetTestFileUrl("Broker_ConnectPermissionDenied"); |
| 165 HostContentSettingsMap* content_settings = | 166 HostContentSettingsMap* content_settings = |
| 166 browser()->profile()->GetHostContentSettingsMap(); | 167 HostContentSettingsMapFactory::GetForProfile(browser()->profile()); |
| 167 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 168 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 168 content_settings->GetContentSetting( | 169 content_settings->GetContentSetting( |
| 169 url, url, CONTENT_SETTINGS_TYPE_PPAPI_BROKER, std::string())); | 170 url, url, CONTENT_SETTINGS_TYPE_PPAPI_BROKER, std::string())); |
| 170 } | 171 } |
| 171 | 172 |
| 172 IN_PROC_BROWSER_TEST_F(PPAPIBrokerInfoBarTest, Blocked) { | 173 IN_PROC_BROWSER_TEST_F(PPAPIBrokerInfoBarTest, Blocked) { |
| 173 // Block access to the PPAPI broker. | 174 // Block access to the PPAPI broker. |
| 174 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( | 175 HostContentSettingsMapFactory::GetForProfile(browser()->profile()) |
| 175 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, CONTENT_SETTING_BLOCK); | 176 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PPAPI_BROKER, |
| 177 CONTENT_SETTING_BLOCK); |
| 176 | 178 |
| 177 // We shouldn't see an infobar. | 179 // We shouldn't see an infobar. |
| 178 InfoBarObserver observer(this); | 180 InfoBarObserver observer(this); |
| 179 | 181 |
| 180 RunTest("Broker_ConnectPermissionDenied"); | 182 RunTest("Broker_ConnectPermissionDenied"); |
| 181 RunTest("Broker_IsAllowedPermissionDenied"); | 183 RunTest("Broker_IsAllowedPermissionDenied"); |
| 182 } | 184 } |
| 183 | 185 |
| 184 IN_PROC_BROWSER_TEST_F(PPAPIBrokerInfoBarTest, Allowed) { | 186 IN_PROC_BROWSER_TEST_F(PPAPIBrokerInfoBarTest, Allowed) { |
| 185 // Always allow access to the PPAPI broker. | 187 // Always allow access to the PPAPI broker. |
| 186 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( | 188 HostContentSettingsMapFactory::GetForProfile(browser()->profile()) |
| 187 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, CONTENT_SETTING_ALLOW); | 189 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PPAPI_BROKER, |
| 190 CONTENT_SETTING_ALLOW); |
| 188 | 191 |
| 189 // We shouldn't see an infobar. | 192 // We shouldn't see an infobar. |
| 190 InfoBarObserver observer(this); | 193 InfoBarObserver observer(this); |
| 191 | 194 |
| 192 RunTest("Broker_ConnectPermissionGranted"); | 195 RunTest("Broker_ConnectPermissionGranted"); |
| 193 RunTest("Broker_IsAllowedPermissionGranted"); | 196 RunTest("Broker_IsAllowedPermissionGranted"); |
| 194 } | 197 } |
| 195 | 198 |
| 196 TEST_PPAPI_NACL(Console) | 199 TEST_PPAPI_NACL(Console) |
| 197 | 200 |
| (...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 MAYBE_PPAPI_NACL(NoSocketPermissions)) { | 1273 MAYBE_PPAPI_NACL(NoSocketPermissions)) { |
| 1271 RunTests("no_socket_permissions"); | 1274 RunTests("no_socket_permissions"); |
| 1272 } | 1275 } |
| 1273 | 1276 |
| 1274 IN_PROC_BROWSER_TEST_F(NewlibPackagedAppTest, | 1277 IN_PROC_BROWSER_TEST_F(NewlibPackagedAppTest, |
| 1275 MAYBE_PPAPI_NACL(SocketPermissions)) { | 1278 MAYBE_PPAPI_NACL(SocketPermissions)) { |
| 1276 RunTests("socket_permissions"); | 1279 RunTests("socket_permissions"); |
| 1277 } | 1280 } |
| 1278 | 1281 |
| 1279 #endif | 1282 #endif |
| OLD | NEW |