| 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 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_BLACKLIST_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_BLACKLIST_CLIENT_H_ |
| 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_BLACKLIST_CLIENT_H_ | 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_BLACKLIST_CLIENT_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // This class must be created and destroyed on the UI thread. | 30 // This class must be created and destroyed on the UI thread. |
| 31 class PermissionBlacklistClient | 31 class PermissionBlacklistClient |
| 32 : public safe_browsing::SafeBrowsingDatabaseManager::Client, | 32 : public safe_browsing::SafeBrowsingDatabaseManager::Client, |
| 33 public base::RefCountedThreadSafe<PermissionBlacklistClient>, | 33 public base::RefCountedThreadSafe<PermissionBlacklistClient>, |
| 34 public content::WebContentsObserver { | 34 public content::WebContentsObserver { |
| 35 public: | 35 public: |
| 36 // |callback| will not be called if |web_contents| is destroyed. Thus if the | 36 // |callback| will not be called if |web_contents| is destroyed. Thus if the |
| 37 // callback is run, the profile associated with |web_contents| is guaranteed | 37 // callback is run, the profile associated with |web_contents| is guaranteed |
| 38 // to be alive. | 38 // to be alive. |
| 39 static void CheckSafeBrowsingBlacklist( | 39 static void CheckSafeBrowsingBlacklist( |
| 40 content::WebContents* web_contents, |
| 40 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager, | 41 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager, |
| 42 const GURL& request_origin, |
| 41 ContentSettingsType content_settings_type, | 43 ContentSettingsType content_settings_type, |
| 42 const GURL& request_origin, | |
| 43 content::WebContents* web_contents, | |
| 44 int timeout, | 44 int timeout, |
| 45 base::Callback<void(bool)> callback); | 45 base::Callback<void(bool)> callback); |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 friend class base::RefCountedThreadSafe<PermissionBlacklistClient>; | 48 friend class base::RefCountedThreadSafe<PermissionBlacklistClient>; |
| 49 | 49 |
| 50 PermissionBlacklistClient( | 50 PermissionBlacklistClient( |
| 51 content::WebContents* web_contents, |
| 51 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager, | 52 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager, |
| 53 const GURL& request_origin, |
| 52 ContentSettingsType content_settings_type, | 54 ContentSettingsType content_settings_type, |
| 53 const GURL& request_origin, | |
| 54 content::WebContents* web_contents, | |
| 55 int timeout, | 55 int timeout, |
| 56 base::Callback<void(bool)> callback); | 56 base::Callback<void(bool)> callback); |
| 57 | 57 |
| 58 ~PermissionBlacklistClient() override; | 58 ~PermissionBlacklistClient() override; |
| 59 | 59 |
| 60 void StartCheck(const GURL& request_origin); | 60 void StartCheck(const GURL& request_origin); |
| 61 | 61 |
| 62 // SafeBrowsingDatabaseManager::Client implementation. | 62 // SafeBrowsingDatabaseManager::Client implementation. |
| 63 void OnCheckApiBlacklistUrlResult( | 63 void OnCheckApiBlacklistUrlResult( |
| 64 const GURL& url, | 64 const GURL& url, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 84 int timeout_; | 84 int timeout_; |
| 85 | 85 |
| 86 // True if |callback_| should be invoked, if web_contents() is destroyed, this | 86 // True if |callback_| should be invoked, if web_contents() is destroyed, this |
| 87 // is set to false. | 87 // is set to false. |
| 88 bool is_active_; | 88 bool is_active_; |
| 89 | 89 |
| 90 DISALLOW_COPY_AND_ASSIGN(PermissionBlacklistClient); | 90 DISALLOW_COPY_AND_ASSIGN(PermissionBlacklistClient); |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_BLACKLIST_CLIENT_H_ | 93 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_BLACKLIST_CLIENT_H_ |
| OLD | NEW |