| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_decision_auto_blocker.h" | 5 #include "chrome/browser/permissions/permission_decision_auto_blocker.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/feature_list.h" | 9 #include "base/feature_list.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 dismissal_embargo_days > 0) { | 264 dismissal_embargo_days > 0) { |
| 265 g_dismissal_embargo_days = dismissal_embargo_days; | 265 g_dismissal_embargo_days = dismissal_embargo_days; |
| 266 } | 266 } |
| 267 } | 267 } |
| 268 | 268 |
| 269 void PermissionDecisionAutoBlocker::UpdateEmbargoedStatus( | 269 void PermissionDecisionAutoBlocker::UpdateEmbargoedStatus( |
| 270 content::PermissionType permission, | 270 content::PermissionType permission, |
| 271 const GURL& request_origin, | 271 const GURL& request_origin, |
| 272 content::WebContents* web_contents, | 272 content::WebContents* web_contents, |
| 273 base::Callback<void(bool)> callback) { | 273 base::Callback<void(bool)> callback) { |
| 274 // Check if origin is currently under embargo for the requested permission. | 274 DCHECK(!IsUnderEmbargo(permission, request_origin)); |
| 275 if (IsUnderEmbargo(permission, request_origin)) { | |
| 276 callback.Run(true /* permission_blocked */); | |
| 277 return; | |
| 278 } | |
| 279 | 275 |
| 280 if (base::FeatureList::IsEnabled(features::kPermissionsBlacklist) && | 276 if (base::FeatureList::IsEnabled(features::kPermissionsBlacklist) && |
| 281 db_manager_) { | 277 db_manager_) { |
| 282 // The CheckSafeBrowsingResult callback won't be called if the profile is | 278 // The CheckSafeBrowsingResult callback won't be called if the profile is |
| 283 // destroyed before a result is received. In that case this object will have | 279 // destroyed before a result is received. In that case this object will have |
| 284 // been destroyed by that point. | 280 // been destroyed by that point. |
| 285 PermissionBlacklistClient::CheckSafeBrowsingBlacklist( | 281 PermissionBlacklistClient::CheckSafeBrowsingBlacklist( |
| 286 db_manager_, permission, request_origin, web_contents, | 282 db_manager_, permission, request_origin, web_contents, |
| 287 safe_browsing_timeout_, | 283 safe_browsing_timeout_, |
| 288 base::Bind(&PermissionDecisionAutoBlocker::CheckSafeBrowsingResult, | 284 base::Bind(&PermissionDecisionAutoBlocker::CheckSafeBrowsingResult, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager, | 362 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager, |
| 367 int timeout) { | 363 int timeout) { |
| 368 db_manager_ = db_manager; | 364 db_manager_ = db_manager; |
| 369 safe_browsing_timeout_ = timeout; | 365 safe_browsing_timeout_ = timeout; |
| 370 } | 366 } |
| 371 | 367 |
| 372 void PermissionDecisionAutoBlocker::SetClockForTesting( | 368 void PermissionDecisionAutoBlocker::SetClockForTesting( |
| 373 std::unique_ptr<base::Clock> clock) { | 369 std::unique_ptr<base::Clock> clock) { |
| 374 clock_ = std::move(clock); | 370 clock_ = std::move(clock); |
| 375 } | 371 } |
| OLD | NEW |