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 <algorithm> | 7 #include <algorithm> |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 : PermissionContextBase(profile, | 165 : PermissionContextBase(profile, |
166 permission_type, | 166 permission_type, |
167 CONTENT_SETTINGS_TYPE_NOTIFICATIONS), | 167 CONTENT_SETTINGS_TYPE_NOTIFICATIONS), |
168 weak_factory_ui_thread_(this) { | 168 weak_factory_ui_thread_(this) { |
169 DCHECK(permission_type == content::PermissionType::NOTIFICATIONS || | 169 DCHECK(permission_type == content::PermissionType::NOTIFICATIONS || |
170 permission_type == content::PermissionType::PUSH_MESSAGING); | 170 permission_type == content::PermissionType::PUSH_MESSAGING); |
171 } | 171 } |
172 | 172 |
173 NotificationPermissionContext::~NotificationPermissionContext() {} | 173 NotificationPermissionContext::~NotificationPermissionContext() {} |
174 | 174 |
175 ContentSetting NotificationPermissionContext::GetPermissionStatus( | 175 ContentSetting NotificationPermissionContext::GetPermissionStatusInternal( |
176 const GURL& requesting_origin, | 176 const GURL& requesting_origin, |
177 const GURL& embedding_origin) const { | 177 const GURL& embedding_origin) const { |
178 // Push messaging is only allowed to be granted on top-level origins. | 178 // Push messaging is only allowed to be granted on top-level origins. |
179 if (permission_type() == content::PermissionType::PUSH_MESSAGING && | 179 if (permission_type() == content::PermissionType::PUSH_MESSAGING && |
180 requesting_origin != embedding_origin) { | 180 requesting_origin != embedding_origin) { |
181 return CONTENT_SETTING_BLOCK; | 181 return CONTENT_SETTING_BLOCK; |
182 } | 182 } |
183 | 183 |
184 return PermissionContextBase::GetPermissionStatus(requesting_origin, | 184 return PermissionContextBase::GetPermissionStatusInternal(requesting_origin, |
185 embedding_origin); | 185 embedding_origin); |
186 } | 186 } |
187 | 187 |
188 void NotificationPermissionContext::ResetPermission( | 188 void NotificationPermissionContext::ResetPermission( |
189 const GURL& requesting_origin, | 189 const GURL& requesting_origin, |
190 const GURL& embedder_origin) { | 190 const GURL& embedder_origin) { |
191 DesktopNotificationProfileUtil::ClearSetting(profile(), requesting_origin); | 191 DesktopNotificationProfileUtil::ClearSetting(profile(), requesting_origin); |
192 } | 192 } |
193 | 193 |
194 void NotificationPermissionContext::CancelPermissionRequest( | 194 void NotificationPermissionContext::CancelPermissionRequest( |
195 content::WebContents* web_contents, | 195 content::WebContents* web_contents, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 requesting_origin); | 254 requesting_origin); |
255 } else { | 255 } else { |
256 DesktopNotificationProfileUtil::DenyPermission(profile(), | 256 DesktopNotificationProfileUtil::DenyPermission(profile(), |
257 requesting_origin); | 257 requesting_origin); |
258 } | 258 } |
259 } | 259 } |
260 | 260 |
261 bool NotificationPermissionContext::IsRestrictedToSecureOrigins() const { | 261 bool NotificationPermissionContext::IsRestrictedToSecureOrigins() const { |
262 return permission_type() == content::PermissionType::PUSH_MESSAGING; | 262 return permission_type() == content::PermissionType::PUSH_MESSAGING; |
263 } | 263 } |
OLD | NEW |