Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: chrome/browser/push_messaging/push_messaging_permission_context.cc

Issue 1816123002: Add testing for subscription from service workers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review comments incorporated and all tests working Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/push_messaging/push_messaging_permission_context.h" 5 #include "chrome/browser/push_messaging/push_messaging_permission_context.h"
6 6
7 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 7 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
8 #include "chrome/browser/notifications/notification_permission_context.h" 8 #include "chrome/browser/notifications/notification_permission_context.h"
9 #include "chrome/browser/notifications/notification_permission_context_factory.h " 9 #include "chrome/browser/notifications/notification_permission_context_factory.h "
10 #include "chrome/browser/permissions/permission_request_id.h" 10 #include "chrome/browser/permissions/permission_request_id.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 DCHECK(notification_context); 46 DCHECK(notification_context);
47 47
48 ContentSetting notifications_permission = 48 ContentSetting notifications_permission =
49 notification_context->GetPermissionStatus(requesting_origin, 49 notification_context->GetPermissionStatus(requesting_origin,
50 embedding_origin); 50 embedding_origin);
51 51
52 if (notifications_permission == CONTENT_SETTING_BLOCK || 52 if (notifications_permission == CONTENT_SETTING_BLOCK ||
53 push_content_setting == CONTENT_SETTING_BLOCK) { 53 push_content_setting == CONTENT_SETTING_BLOCK) {
54 return CONTENT_SETTING_BLOCK; 54 return CONTENT_SETTING_BLOCK;
55 } 55 }
56 if (notifications_permission == CONTENT_SETTING_ASK || 56 // If the notifications permission has already been granted,
57 push_content_setting == CONTENT_SETTING_ASK) { 57 // grant the push messaging permission.
Michael van Ouwerkerk 2016/03/30 09:50:04 Does this change any of our current behavior?
harkness 2016/03/30 10:51:49 This makes the current behavior for registering fr
58 if (notifications_permission == CONTENT_SETTING_ASK)
58 return CONTENT_SETTING_ASK; 59 return CONTENT_SETTING_ASK;
59 } 60
60 DCHECK_EQ(CONTENT_SETTING_ALLOW, notifications_permission); 61 DCHECK(push_content_setting == CONTENT_SETTING_ALLOW ||
61 DCHECK_EQ(CONTENT_SETTING_ALLOW, push_content_setting); 62 push_content_setting == CONTENT_SETTING_ASK);
62 return CONTENT_SETTING_ALLOW; 63 return CONTENT_SETTING_ALLOW;
63 #else 64 #else
64 return CONTENT_SETTING_BLOCK; 65 return CONTENT_SETTING_BLOCK;
65 #endif 66 #endif
66 } 67 }
67 68
68 // Unlike other permissions, push is decided by the following algorithm 69 // Unlike other permissions, push is decided by the following algorithm
69 // - You need to request it from a top level domain 70 // - You need to request it from a top level domain
70 // - You need to have notification permission granted. 71 // - You need to have notification permission granted.
71 // - You need to not have push permission explicitly blocked. 72 // - You need to not have push permission explicitly blocked.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 DVLOG(1) << "Notification permission has not been granted."; 130 DVLOG(1) << "Notification permission has not been granted.";
130 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, 131 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
131 false /* persist */, notification_content_setting); 132 false /* persist */, notification_content_setting);
132 return; 133 return;
133 } 134 }
134 135
135 PermissionUmaUtil::PermissionGranted(permission_type(), requesting_origin); 136 PermissionUmaUtil::PermissionGranted(permission_type(), requesting_origin);
136 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, 137 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
137 true /* persist */, CONTENT_SETTING_ALLOW); 138 true /* persist */, CONTENT_SETTING_ALLOW);
138 } 139 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698