Chromium Code Reviews| 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(Profile* profile) | 162 NotificationPermissionContext::NotificationPermissionContext( |
| 163 Profile* profile, | |
| 164 content::PermissionType permission_type) | |
| 163 : PermissionContextBase(profile, | 165 : PermissionContextBase(profile, |
| 164 content::PermissionType::NOTIFICATIONS, | 166 permission_type, |
| 165 CONTENT_SETTINGS_TYPE_NOTIFICATIONS), | 167 CONTENT_SETTINGS_TYPE_NOTIFICATIONS), |
| 166 weak_factory_ui_thread_(this) {} | 168 weak_factory_ui_thread_(this) { |
| 169 DCHECK(permission_type == content::PermissionType::NOTIFICATIONS || | |
| 170 permission_type == content::PermissionType::PUSH_MESSAGING); | |
| 171 } | |
| 167 | 172 |
| 168 NotificationPermissionContext::~NotificationPermissionContext() {} | 173 NotificationPermissionContext::~NotificationPermissionContext() {} |
| 169 | 174 |
| 175 ContentSetting NotificationPermissionContext::GetPermissionStatus( | |
| 176 const GURL& requesting_origin, | |
| 177 const GURL& embedding_origin) const { | |
| 178 if (permission_type() == content::PermissionType::PUSH_MESSAGING && | |
|
Miguel Garcia
2016/07/14 18:02:03
perhaps it's worth adding a comment on why?
raymes
2016/07/18 07:04:51
Done.
| |
| 179 requesting_origin != embedding_origin) { | |
| 180 return CONTENT_SETTING_BLOCK; | |
|
Peter Beverloo
2016/07/14 17:15:19
Is GetPermissionStatus() always checked before Dec
Miguel Garcia
2016/07/14 18:02:03
Yes, this is enforced by the base class. The diffe
| |
| 181 } | |
| 182 | |
| 183 return PermissionContextBase::GetPermissionStatus(requesting_origin, | |
| 184 embedding_origin); | |
| 185 } | |
| 186 | |
| 170 void NotificationPermissionContext::ResetPermission( | 187 void NotificationPermissionContext::ResetPermission( |
| 171 const GURL& requesting_origin, | 188 const GURL& requesting_origin, |
| 172 const GURL& embedder_origin) { | 189 const GURL& embedder_origin) { |
| 173 DesktopNotificationProfileUtil::ClearSetting(profile(), requesting_origin); | 190 DesktopNotificationProfileUtil::ClearSetting(profile(), requesting_origin); |
| 174 } | 191 } |
| 175 | 192 |
| 176 void NotificationPermissionContext::CancelPermissionRequest( | 193 void NotificationPermissionContext::CancelPermissionRequest( |
| 177 content::WebContents* web_contents, | 194 content::WebContents* web_contents, |
| 178 const PermissionRequestID& id) { | 195 const PermissionRequestID& id) { |
| 179 if (profile()->IsOffTheRecord()) { | 196 if (profile()->IsOffTheRecord()) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 if (content_setting == CONTENT_SETTING_ALLOW) { | 249 if (content_setting == CONTENT_SETTING_ALLOW) { |
| 233 DesktopNotificationProfileUtil::GrantPermission(profile(), | 250 DesktopNotificationProfileUtil::GrantPermission(profile(), |
| 234 requesting_origin); | 251 requesting_origin); |
| 235 } else { | 252 } else { |
| 236 DesktopNotificationProfileUtil::DenyPermission(profile(), | 253 DesktopNotificationProfileUtil::DenyPermission(profile(), |
| 237 requesting_origin); | 254 requesting_origin); |
| 238 } | 255 } |
| 239 } | 256 } |
| 240 | 257 |
| 241 bool NotificationPermissionContext::IsRestrictedToSecureOrigins() const { | 258 bool NotificationPermissionContext::IsRestrictedToSecureOrigins() const { |
| 259 if (permission_type() == content::PermissionType::PUSH_MESSAGING) | |
| 260 return true; | |
| 242 return false; | 261 return false; |
|
Peter Beverloo
2016/07/14 17:15:19
nit:
return permission_type() == content::Permi
raymes
2016/07/18 07:04:51
Done.
| |
| 243 } | 262 } |
| OLD | NEW |