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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 // PermissionMenuModel::PermissionMenuModel which prevents users from manually | 218 // PermissionMenuModel::PermissionMenuModel which prevents users from manually |
219 // allowing the permission. | 219 // allowing the permission. |
220 if (profile()->IsOffTheRecord()) { | 220 if (profile()->IsOffTheRecord()) { |
221 // Random number of seconds in the range [1.0, 2.0). | 221 // Random number of seconds in the range [1.0, 2.0). |
222 double delay_seconds = 1.0 + 1.0 * base::RandDouble(); | 222 double delay_seconds = 1.0 + 1.0 * base::RandDouble(); |
223 VisibilityTimerTabHelper::CreateForWebContents(web_contents); | 223 VisibilityTimerTabHelper::CreateForWebContents(web_contents); |
224 VisibilityTimerTabHelper::FromWebContents(web_contents) | 224 VisibilityTimerTabHelper::FromWebContents(web_contents) |
225 ->PostTaskAfterVisibleDelay( | 225 ->PostTaskAfterVisibleDelay( |
226 FROM_HERE, | 226 FROM_HERE, |
227 base::Bind(&NotificationPermissionContext::NotifyPermissionSet, | 227 base::Bind(&NotificationPermissionContext::NotifyPermissionSet, |
228 weak_factory_ui_thread_.GetWeakPtr(), id, | 228 weak_factory_ui_thread_.GetWeakPtr(), web_contents, id, |
229 requesting_origin, embedding_origin, callback, | 229 requesting_origin, embedding_origin, callback, |
230 true /* persist */, CONTENT_SETTING_BLOCK), | 230 true /* persist */, CONTENT_SETTING_BLOCK), |
231 base::TimeDelta::FromSecondsD(delay_seconds), id); | 231 base::TimeDelta::FromSecondsD(delay_seconds), id); |
232 return; | 232 return; |
233 } | 233 } |
234 | 234 |
235 PermissionContextBase::DecidePermission(web_contents, id, requesting_origin, | 235 PermissionContextBase::DecidePermission(web_contents, id, requesting_origin, |
236 embedding_origin, user_gesture, | 236 embedding_origin, user_gesture, |
237 callback); | 237 callback); |
238 } | 238 } |
(...skipping 15 matching lines...) Expand all 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 |