| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 task.Run(); | 152 task.Run(); |
| 153 task_queue_.pop_front(); | 153 task_queue_.pop_front(); |
| 154 if (!task_queue_.empty()) | 154 if (!task_queue_.empty()) |
| 155 task_queue_.front().timer->Reset(); | 155 task_queue_.front().timer->Reset(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 } // namespace | 158 } // namespace |
| 159 | 159 |
| 160 DEFINE_WEB_CONTENTS_USER_DATA_KEY(VisibilityTimerTabHelper); | 160 DEFINE_WEB_CONTENTS_USER_DATA_KEY(VisibilityTimerTabHelper); |
| 161 | 161 |
| 162 NotificationPermissionContext::NotificationPermissionContext( | 162 NotificationPermissionContext::NotificationPermissionContext(Profile* profile) |
| 163 Profile* profile, | |
| 164 content::PermissionType permission_type) | |
| 165 : PermissionContextBase(profile, | 163 : PermissionContextBase(profile, |
| 166 permission_type, | 164 content::PermissionType::NOTIFICATIONS, |
| 167 CONTENT_SETTINGS_TYPE_NOTIFICATIONS), | 165 CONTENT_SETTINGS_TYPE_NOTIFICATIONS), |
| 168 weak_factory_ui_thread_(this) { | 166 weak_factory_ui_thread_(this) {} |
| 169 DCHECK(permission_type == content::PermissionType::NOTIFICATIONS || | |
| 170 permission_type == content::PermissionType::PUSH_MESSAGING); | |
| 171 } | |
| 172 | 167 |
| 173 NotificationPermissionContext::~NotificationPermissionContext() {} | 168 NotificationPermissionContext::~NotificationPermissionContext() {} |
| 174 | 169 |
| 175 ContentSetting NotificationPermissionContext::GetPermissionStatus( | |
| 176 const GURL& requesting_origin, | |
| 177 const GURL& embedding_origin) const { | |
| 178 // Push messaging is only allowed to be granted on top-level origins. | |
| 179 if (permission_type() == content::PermissionType::PUSH_MESSAGING && | |
| 180 requesting_origin != embedding_origin) { | |
| 181 return CONTENT_SETTING_BLOCK; | |
| 182 } | |
| 183 | |
| 184 return PermissionContextBase::GetPermissionStatus(requesting_origin, | |
| 185 embedding_origin); | |
| 186 } | |
| 187 | |
| 188 void NotificationPermissionContext::ResetPermission( | 170 void NotificationPermissionContext::ResetPermission( |
| 189 const GURL& requesting_origin, | 171 const GURL& requesting_origin, |
| 190 const GURL& embedder_origin) { | 172 const GURL& embedder_origin) { |
| 191 DesktopNotificationProfileUtil::ClearSetting(profile(), requesting_origin); | 173 DesktopNotificationProfileUtil::ClearSetting(profile(), requesting_origin); |
| 192 } | 174 } |
| 193 | 175 |
| 194 void NotificationPermissionContext::CancelPermissionRequest( | 176 void NotificationPermissionContext::CancelPermissionRequest( |
| 195 content::WebContents* web_contents, | 177 content::WebContents* web_contents, |
| 196 const PermissionRequestID& id) { | 178 const PermissionRequestID& id) { |
| 197 if (profile()->IsOffTheRecord()) { | 179 if (profile()->IsOffTheRecord()) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 if (content_setting == CONTENT_SETTING_ALLOW) { | 234 if (content_setting == CONTENT_SETTING_ALLOW) { |
| 253 DesktopNotificationProfileUtil::GrantPermission(profile(), | 235 DesktopNotificationProfileUtil::GrantPermission(profile(), |
| 254 requesting_origin); | 236 requesting_origin); |
| 255 } else { | 237 } else { |
| 256 DesktopNotificationProfileUtil::DenyPermission(profile(), | 238 DesktopNotificationProfileUtil::DenyPermission(profile(), |
| 257 requesting_origin); | 239 requesting_origin); |
| 258 } | 240 } |
| 259 } | 241 } |
| 260 | 242 |
| 261 bool NotificationPermissionContext::IsRestrictedToSecureOrigins() const { | 243 bool NotificationPermissionContext::IsRestrictedToSecureOrigins() const { |
| 262 return permission_type() == content::PermissionType::PUSH_MESSAGING; | 244 return false; |
| 263 } | 245 } |
| OLD | NEW |