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

Side by Side Diff: chrome/browser/permissions/permission_context_base.cc

Issue 2709213004: Make the PermissionDecisionAutoBlocker API consistent. (Closed)
Patch Set: Rebase Created 3 years, 10 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/permissions/permission_context_base.h" 5 #include "chrome/browser/permissions/permission_context_base.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // If we are under embargo, record the embargo reason for which we have 112 // If we are under embargo, record the embargo reason for which we have
113 // suppressed the prompt. 113 // suppressed the prompt.
114 PermissionUmaUtil::RecordEmbargoPromptSuppressionFromSource(result.source); 114 PermissionUmaUtil::RecordEmbargoPromptSuppressionFromSource(result.source);
115 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, 115 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
116 false /* persist */, result.content_setting); 116 false /* persist */, result.content_setting);
117 return; 117 return;
118 } 118 }
119 119
120 // Asynchronously check whether the origin should be blocked from making this 120 // Asynchronously check whether the origin should be blocked from making this
121 // permission request, e.g. it may be on the Safe Browsing API blacklist. 121 // permission request, e.g. it may be on the Safe Browsing API blacklist.
122 PermissionDecisionAutoBlocker::GetForProfile(profile_)->UpdateEmbargoedStatus( 122 PermissionDecisionAutoBlocker::GetForProfile(profile_)
123 content_settings_type_, requesting_origin, web_contents, 123 ->CheckSafeBrowsingBlacklist(
124 base::Bind(&PermissionContextBase::ContinueRequestPermission, 124 web_contents, requesting_origin, content_settings_type_,
125 weak_factory_.GetWeakPtr(), web_contents, id, 125 base::Bind(&PermissionContextBase::ContinueRequestPermission,
126 requesting_origin, embedding_origin, user_gesture, callback)); 126 weak_factory_.GetWeakPtr(), web_contents, id,
127 requesting_origin, embedding_origin, user_gesture,
128 callback));
127 } 129 }
128 130
129 void PermissionContextBase::ContinueRequestPermission( 131 void PermissionContextBase::ContinueRequestPermission(
130 content::WebContents* web_contents, 132 content::WebContents* web_contents,
131 const PermissionRequestID& id, 133 const PermissionRequestID& id,
132 const GURL& requesting_origin, 134 const GURL& requesting_origin,
133 const GURL& embedding_origin, 135 const GURL& embedding_origin,
134 bool user_gesture, 136 bool user_gesture,
135 const BrowserPermissionCallback& callback, 137 const BrowserPermissionCallback& callback,
136 bool permission_blocked) { 138 bool permission_blocked) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 !content::IsOriginSecure(requesting_origin)) { 177 !content::IsOriginSecure(requesting_origin)) {
176 return PermissionResult(CONTENT_SETTING_BLOCK, 178 return PermissionResult(CONTENT_SETTING_BLOCK,
177 PermissionStatusSource::UNSPECIFIED); 179 PermissionStatusSource::UNSPECIFIED);
178 } 180 }
179 181
180 ContentSetting content_setting = 182 ContentSetting content_setting =
181 GetPermissionStatusInternal(requesting_origin, embedding_origin); 183 GetPermissionStatusInternal(requesting_origin, embedding_origin);
182 if (content_setting == CONTENT_SETTING_ASK) { 184 if (content_setting == CONTENT_SETTING_ASK) {
183 PermissionResult result = 185 PermissionResult result =
184 PermissionDecisionAutoBlocker::GetForProfile(profile_) 186 PermissionDecisionAutoBlocker::GetForProfile(profile_)
185 ->GetEmbargoResult(content_settings_type_, requesting_origin); 187 ->GetEmbargoResult(requesting_origin, content_settings_type_);
186 DCHECK(result.content_setting == CONTENT_SETTING_ASK || 188 DCHECK(result.content_setting == CONTENT_SETTING_ASK ||
187 result.content_setting == CONTENT_SETTING_BLOCK); 189 result.content_setting == CONTENT_SETTING_BLOCK);
188 return result; 190 return result;
189 } 191 }
190 192
191 return PermissionResult(content_setting, PermissionStatusSource::UNSPECIFIED); 193 return PermissionResult(content_setting, PermissionStatusSource::UNSPECIFIED);
192 } 194 }
193 195
194 void PermissionContextBase::ResetPermission(const GURL& requesting_origin, 196 void PermissionContextBase::ResetPermission(const GURL& requesting_origin,
195 const GURL& embedding_origin) { 197 const GURL& embedding_origin) {
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 content_settings_storage_type(), 381 content_settings_storage_type(),
380 std::string(), content_setting); 382 std::string(), content_setting);
381 } 383 }
382 384
383 ContentSettingsType PermissionContextBase::content_settings_storage_type() 385 ContentSettingsType PermissionContextBase::content_settings_storage_type()
384 const { 386 const {
385 if (content_settings_type_ == CONTENT_SETTINGS_TYPE_PUSH_MESSAGING) 387 if (content_settings_type_ == CONTENT_SETTINGS_TYPE_PUSH_MESSAGING)
386 return CONTENT_SETTINGS_TYPE_NOTIFICATIONS; 388 return CONTENT_SETTINGS_TYPE_NOTIFICATIONS;
387 return content_settings_type_; 389 return content_settings_type_;
388 } 390 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698