OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/notifications/notification_permission_context.h" | 5 #include "chrome/browser/notifications/notification_permission_context.h" |
6 | 6 |
7 #include <deque> | 7 #include <deque> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 : PermissionContextBase(profile, | 162 : PermissionContextBase(profile, |
163 content_settings_type, | 163 content_settings_type, |
164 blink::WebFeaturePolicyFeature::kNotFound), | 164 blink::WebFeaturePolicyFeature::kNotFound), |
165 weak_factory_ui_thread_(this) { | 165 weak_factory_ui_thread_(this) { |
166 DCHECK(content_settings_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS || | 166 DCHECK(content_settings_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS || |
167 content_settings_type == CONTENT_SETTINGS_TYPE_PUSH_MESSAGING); | 167 content_settings_type == CONTENT_SETTINGS_TYPE_PUSH_MESSAGING); |
168 } | 168 } |
169 | 169 |
170 NotificationPermissionContext::~NotificationPermissionContext() {} | 170 NotificationPermissionContext::~NotificationPermissionContext() {} |
171 | 171 |
172 ContentSetting NotificationPermissionContext::GetPermissionStatusInternal( | 172 PermissionResult NotificationPermissionContext::GetPermissionStatusInternal( |
173 content::RenderFrameHost* render_frame_host, | 173 content::RenderFrameHost* render_frame_host, |
174 const GURL& requesting_origin, | 174 const GURL& requesting_origin, |
175 const GURL& embedding_origin) const { | 175 const GURL& embedding_origin) const { |
176 // Push messaging is only allowed to be granted on top-level origins. | 176 // Push messaging is only allowed to be granted on top-level origins. |
177 if (content_settings_type() == CONTENT_SETTINGS_TYPE_PUSH_MESSAGING | 177 if (content_settings_type() == CONTENT_SETTINGS_TYPE_PUSH_MESSAGING |
178 && requesting_origin != embedding_origin) { | 178 && requesting_origin != embedding_origin) { |
179 return CONTENT_SETTING_BLOCK; | 179 return PermissionResult(CONTENT_SETTING_BLOCK, |
| 180 PermissionStatusSource::UNSPECIFIED); |
180 } | 181 } |
181 | 182 |
182 return PermissionContextBase::GetPermissionStatusInternal( | 183 return PermissionContextBase::GetPermissionStatusInternal( |
183 render_frame_host, requesting_origin, embedding_origin); | 184 render_frame_host, requesting_origin, embedding_origin); |
184 } | 185 } |
185 | 186 |
186 void NotificationPermissionContext::ResetPermission( | 187 void NotificationPermissionContext::ResetPermission( |
187 const GURL& requesting_origin, | 188 const GURL& requesting_origin, |
188 const GURL& embedder_origin) { | 189 const GURL& embedder_origin) { |
189 DesktopNotificationProfileUtil::ClearSetting(profile(), requesting_origin); | 190 DesktopNotificationProfileUtil::ClearSetting(profile(), requesting_origin); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 requesting_origin); | 253 requesting_origin); |
253 } else { | 254 } else { |
254 DesktopNotificationProfileUtil::DenyPermission(profile(), | 255 DesktopNotificationProfileUtil::DenyPermission(profile(), |
255 requesting_origin); | 256 requesting_origin); |
256 } | 257 } |
257 } | 258 } |
258 | 259 |
259 bool NotificationPermissionContext::IsRestrictedToSecureOrigins() const { | 260 bool NotificationPermissionContext::IsRestrictedToSecureOrigins() const { |
260 return content_settings_type() == CONTENT_SETTINGS_TYPE_PUSH_MESSAGING; | 261 return content_settings_type() == CONTENT_SETTINGS_TYPE_PUSH_MESSAGING; |
261 } | 262 } |
OLD | NEW |