OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/push_messaging/push_messaging_permission_context.h" | 5 #include "chrome/browser/push_messaging/push_messaging_permission_context.h" |
6 | 6 |
7 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 7 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
8 #include "chrome/browser/permissions/permission_request_id.h" | 8 #include "chrome/browser/permissions/permission_request_id.h" |
9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 context.GetPermissionStatus(GURL(kOriginA), GURL(kOriginA))); | 157 context.GetPermissionStatus(GURL(kOriginA), GURL(kOriginA))); |
158 } | 158 } |
159 | 159 |
160 TEST_F(PushMessagingPermissionContextTest, DecidePushPermission) { | 160 TEST_F(PushMessagingPermissionContextTest, DecidePushPermission) { |
161 TestingProfile profile; | 161 TestingProfile profile; |
162 TestPushMessagingPermissionContext context(&profile); | 162 TestPushMessagingPermissionContext context(&profile); |
163 PermissionRequestID request_id(-1, -1, -1); | 163 PermissionRequestID request_id(-1, -1, -1); |
164 BrowserPermissionCallback callback = base::Bind(DoNothing); | 164 BrowserPermissionCallback callback = base::Bind(DoNothing); |
165 | 165 |
166 context.DecidePushPermission(request_id, GURL(kOriginA), GURL(kOriginA), | 166 context.DecidePushPermission(request_id, GURL(kOriginA), GURL(kOriginA), |
167 callback, CONTENT_SETTING_DEFAULT); | 167 callback, |
168 blink::mojom::PermissionStatus::DENIED); | |
mlamouri (slow - plz ping)
2016/04/12 11:36:40
Should that be PROMPT?
raymes
2016/04/13 00:35:07
In production code, I don't think this function wi
| |
168 EXPECT_FALSE(context.was_persisted()); | 169 EXPECT_FALSE(context.was_persisted()); |
169 EXPECT_FALSE(context.was_granted()); | 170 EXPECT_FALSE(context.was_granted()); |
170 | 171 |
171 SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, | 172 SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, |
172 CONTENT_SETTING_ALLOW); | 173 CONTENT_SETTING_ALLOW); |
173 context.DecidePushPermission(request_id, GURL(kOriginA), GURL(kOriginA), | 174 context.DecidePushPermission(request_id, GURL(kOriginA), GURL(kOriginA), |
174 callback, CONTENT_SETTING_ALLOW); | 175 callback, |
176 blink::mojom::PermissionStatus::GRANTED); | |
175 EXPECT_TRUE(context.was_persisted()); | 177 EXPECT_TRUE(context.was_persisted()); |
176 EXPECT_TRUE(context.was_granted()); | 178 EXPECT_TRUE(context.was_granted()); |
177 | 179 |
178 SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, | 180 SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, |
179 CONTENT_SETTING_BLOCK); | 181 CONTENT_SETTING_BLOCK); |
180 context.DecidePushPermission(request_id, GURL(kOriginA), GURL(kOriginA), | 182 context.DecidePushPermission(request_id, GURL(kOriginA), GURL(kOriginA), |
181 callback, CONTENT_SETTING_ALLOW); | 183 callback, |
184 blink::mojom::PermissionStatus::GRANTED); | |
182 EXPECT_TRUE(context.was_persisted()); | 185 EXPECT_TRUE(context.was_persisted()); |
183 EXPECT_FALSE(context.was_granted()); | 186 EXPECT_FALSE(context.was_granted()); |
184 | 187 |
185 SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, | 188 SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, |
186 CONTENT_SETTING_ASK); | 189 CONTENT_SETTING_ASK); |
187 context.DecidePushPermission(request_id, GURL(kOriginA), GURL(kOriginA), | 190 context.DecidePushPermission(request_id, GURL(kOriginA), GURL(kOriginA), |
188 callback, CONTENT_SETTING_ALLOW); | 191 callback, |
192 blink::mojom::PermissionStatus::GRANTED); | |
189 EXPECT_TRUE(context.was_persisted()); | 193 EXPECT_TRUE(context.was_persisted()); |
190 EXPECT_TRUE(context.was_granted()); | 194 EXPECT_TRUE(context.was_granted()); |
191 } | 195 } |
192 | 196 |
193 TEST_F(PushMessagingPermissionContextTest, DecidePermission) { | 197 TEST_F(PushMessagingPermissionContextTest, DecidePermission) { |
194 TestingProfile profile; | 198 TestingProfile profile; |
195 TestPushMessagingPermissionContext context(&profile); | 199 TestPushMessagingPermissionContext context(&profile); |
196 PermissionRequestID request_id(-1, -1, -1); | 200 PermissionRequestID request_id(-1, -1, -1); |
197 BrowserPermissionCallback callback = base::Bind(DoNothing); | 201 BrowserPermissionCallback callback = base::Bind(DoNothing); |
198 | 202 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
301 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 305 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
302 context.GetPermissionStatus(GURL(kInsecureOrigin), | 306 context.GetPermissionStatus(GURL(kInsecureOrigin), |
303 GURL(kInsecureOrigin))); | 307 GURL(kInsecureOrigin))); |
304 | 308 |
305 SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, | 309 SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, |
306 CONTENT_SETTING_ASK); | 310 CONTENT_SETTING_ASK); |
307 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 311 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
308 context.GetPermissionStatus(GURL(kInsecureOrigin), | 312 context.GetPermissionStatus(GURL(kInsecureOrigin), |
309 GURL(kInsecureOrigin))); | 313 GURL(kInsecureOrigin))); |
310 } | 314 } |
OLD | NEW |