OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_blacklist_client.h" | 5 #include "chrome/browser/permissions/permission_blacklist_client.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 const GURL& url, | 68 const GURL& url, |
69 const safe_browsing::ThreatMetadata& metadata) { | 69 const safe_browsing::ThreatMetadata& metadata) { |
70 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 70 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
71 | 71 |
72 if (timer_->IsRunning()) | 72 if (timer_->IsRunning()) |
73 timer_->Stop(); | 73 timer_->Stop(); |
74 else | 74 else |
75 db_manager_->CancelApiCheck(this); | 75 db_manager_->CancelApiCheck(this); |
76 timer_.reset(nullptr); | 76 timer_.reset(nullptr); |
77 | 77 |
78 // TODO(meredithl): Convert the strings returned from Safe Browsing to the | |
79 // ones used by PermissionUtil for comparison. | |
80 bool permission_blocked = | 78 bool permission_blocked = |
81 metadata.api_permissions.find(PermissionUtil::GetPermissionString( | 79 metadata.api_permissions.find( |
82 permission_type_)) != metadata.api_permissions.end(); | 80 PermissionUtil::ConvertPermissionTypeToSafeBrowsingName( |
| 81 permission_type_)) != metadata.api_permissions.end(); |
83 | 82 |
84 content::BrowserThread::PostTask( | 83 content::BrowserThread::PostTask( |
85 content::BrowserThread::UI, FROM_HERE, | 84 content::BrowserThread::UI, FROM_HERE, |
86 base::Bind(&PermissionBlacklistClient::EvaluateBlacklistResultOnUiThread, | 85 base::Bind(&PermissionBlacklistClient::EvaluateBlacklistResultOnUiThread, |
87 this, permission_blocked)); | 86 this, permission_blocked)); |
88 } | 87 } |
89 | 88 |
90 void PermissionBlacklistClient::EvaluateBlacklistResultOnUiThread( | 89 void PermissionBlacklistClient::EvaluateBlacklistResultOnUiThread( |
91 bool permission_blocked) { | 90 bool permission_blocked) { |
92 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 91 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
93 | 92 |
94 if (is_active_) | 93 if (is_active_) |
95 callback_.Run(permission_blocked); | 94 callback_.Run(permission_blocked); |
96 Release(); | 95 Release(); |
97 } | 96 } |
98 | 97 |
99 void PermissionBlacklistClient::WebContentsDestroyed() { | 98 void PermissionBlacklistClient::WebContentsDestroyed() { |
100 is_active_ = false; | 99 is_active_ = false; |
101 Observe(nullptr); | 100 Observe(nullptr); |
102 } | 101 } |
OLD | NEW |