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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 void PermissionBlacklistClient::OnCheckApiBlacklistUrlResult( | 67 void PermissionBlacklistClient::OnCheckApiBlacklistUrlResult( |
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 std::set<content::PermissionType> permission_types; | |
78 for (const auto& i : metadata.api_permissions) { | |
raymes
2017/01/24 05:15:16
nit: auto can be helpful sometimes, but in other c
meredithl
2017/01/24 23:20:21
Done.
| |
79 permission_types.insert( | |
80 PermissionUtil::ConvertSafeBrowsingNameToPermissionType(i)); | |
81 } | |
77 | 82 |
78 // TODO(meredithl): Convert the strings returned from Safe Browsing to the | |
79 // ones used by PermissionUtil for comparison. | |
80 bool permission_blocked = | 83 bool permission_blocked = |
81 metadata.api_permissions.find(PermissionUtil::GetPermissionString( | 84 permission_types.find(permission_type_) != permission_types.end(); |
raymes
2017/01/24 05:15:16
Would this be simpler if we just converted in the
meredithl
2017/01/24 23:20:21
Done.
| |
82 permission_type_)) != metadata.api_permissions.end(); | |
83 | 85 |
84 content::BrowserThread::PostTask( | 86 content::BrowserThread::PostTask( |
85 content::BrowserThread::UI, FROM_HERE, | 87 content::BrowserThread::UI, FROM_HERE, |
86 base::Bind(&PermissionBlacklistClient::EvaluateBlacklistResultOnUiThread, | 88 base::Bind(&PermissionBlacklistClient::EvaluateBlacklistResultOnUiThread, |
87 this, permission_blocked)); | 89 this, permission_blocked)); |
88 } | 90 } |
89 | 91 |
90 void PermissionBlacklistClient::EvaluateBlacklistResultOnUiThread( | 92 void PermissionBlacklistClient::EvaluateBlacklistResultOnUiThread( |
91 bool permission_blocked) { | 93 bool permission_blocked) { |
92 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 94 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
93 | 95 |
94 if (is_active_) | 96 if (is_active_) |
95 callback_.Run(permission_blocked); | 97 callback_.Run(permission_blocked); |
96 Release(); | 98 Release(); |
97 } | 99 } |
98 | 100 |
99 void PermissionBlacklistClient::WebContentsDestroyed() { | 101 void PermissionBlacklistClient::WebContentsDestroyed() { |
100 is_active_ = false; | 102 is_active_ = false; |
101 Observe(nullptr); | 103 Observe(nullptr); |
102 } | 104 } |
OLD | NEW |