| 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" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/timer/elapsed_timer.h" | 12 #include "base/timer/elapsed_timer.h" |
| 13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
| 14 #include "chrome/browser/permissions/permission_uma_util.h" | 14 #include "chrome/browser/permissions/permission_uma_util.h" |
| 15 #include "chrome/browser/permissions/permission_util.h" | 15 #include "chrome/browser/permissions/permission_util.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 19 | 19 |
| 20 // static | 20 // static |
| 21 void PermissionBlacklistClient::CheckSafeBrowsingBlacklist( | 21 void PermissionBlacklistClient::CheckSafeBrowsingBlacklist( |
| 22 content::WebContents* web_contents, |
| 22 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager, | 23 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager, |
| 24 const GURL& request_origin, |
| 23 ContentSettingsType content_settings_type, | 25 ContentSettingsType content_settings_type, |
| 24 const GURL& request_origin, | |
| 25 content::WebContents* web_contents, | |
| 26 int timeout, | 26 int timeout, |
| 27 base::Callback<void(bool)> callback) { | 27 base::Callback<void(bool)> callback) { |
| 28 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 28 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 29 | 29 |
| 30 new PermissionBlacklistClient(db_manager, content_settings_type, | 30 new PermissionBlacklistClient(web_contents, db_manager, request_origin, |
| 31 request_origin, web_contents, timeout, | 31 content_settings_type, timeout, callback); |
| 32 callback); | |
| 33 } | 32 } |
| 34 | 33 |
| 35 PermissionBlacklistClient::PermissionBlacklistClient( | 34 PermissionBlacklistClient::PermissionBlacklistClient( |
| 35 content::WebContents* web_contents, |
| 36 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager, | 36 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager, |
| 37 const GURL& request_origin, |
| 37 ContentSettingsType content_settings_type, | 38 ContentSettingsType content_settings_type, |
| 38 const GURL& request_origin, | |
| 39 content::WebContents* web_contents, | |
| 40 int timeout, | 39 int timeout, |
| 41 base::Callback<void(bool)> callback) | 40 base::Callback<void(bool)> callback) |
| 42 : content::WebContentsObserver(web_contents), | 41 : content::WebContentsObserver(web_contents), |
| 43 db_manager_(db_manager), | 42 db_manager_(db_manager), |
| 44 content_settings_type_(content_settings_type), | 43 content_settings_type_(content_settings_type), |
| 45 callback_(callback), | 44 callback_(callback), |
| 46 timeout_(timeout), | 45 timeout_(timeout), |
| 47 is_active_(true) { | 46 is_active_(true) { |
| 48 // Balanced by a call to Release() in EvaluateBlacklistResultOnUiThread(). | 47 // Balanced by a call to Release() in EvaluateBlacklistResultOnUiThread(). |
| 49 AddRef(); | 48 AddRef(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 107 |
| 109 if (is_active_) | 108 if (is_active_) |
| 110 callback_.Run(response); | 109 callback_.Run(response); |
| 111 Release(); | 110 Release(); |
| 112 } | 111 } |
| 113 | 112 |
| 114 void PermissionBlacklistClient::WebContentsDestroyed() { | 113 void PermissionBlacklistClient::WebContentsDestroyed() { |
| 115 is_active_ = false; | 114 is_active_ = false; |
| 116 Observe(nullptr); | 115 Observe(nullptr); |
| 117 } | 116 } |
| OLD | NEW |