Chromium Code Reviews| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 54 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 55 | 55 |
| 56 // Start the timer to interrupt into the client callback method with an | 56 // Start the timer to interrupt into the client callback method with an |
| 57 // empty response if Safe Browsing times out. | 57 // empty response if Safe Browsing times out. |
| 58 safe_browsing::ThreatMetadata empty_metadata; | 58 safe_browsing::ThreatMetadata empty_metadata; |
| 59 timer_ = base::MakeUnique<base::OneShotTimer>(); | 59 timer_ = base::MakeUnique<base::OneShotTimer>(); |
| 60 timer_->Start( | 60 timer_->Start( |
| 61 FROM_HERE, base::TimeDelta::FromMilliseconds(timeout_), | 61 FROM_HERE, base::TimeDelta::FromMilliseconds(timeout_), |
| 62 base::Bind(&PermissionBlacklistClient::OnCheckApiBlacklistUrlResult, this, | 62 base::Bind(&PermissionBlacklistClient::OnCheckApiBlacklistUrlResult, this, |
| 63 request_origin, empty_metadata)); | 63 request_origin, empty_metadata)); |
| 64 db_manager_->CheckApiBlacklistUrl(request_origin, this); | 64 |
| 65 // If CheckApiBlacklistUrl returns true, no asynchronous call to |this| will | |
| 66 // be made, so just directly call through to OnCheckApiBlacklistUrlResult. | |
| 67 if (db_manager_->CheckApiBlacklistUrl(request_origin, this)) | |
| 68 this->OnCheckApiBlacklistUrlResult(request_origin, empty_metadata); | |
|
dominickn
2017/02/07 08:27:06
Nit: no need for this->
meredithl
2017/02/08 00:58:03
Done.
| |
| 65 } | 69 } |
| 66 | 70 |
| 67 void PermissionBlacklistClient::OnCheckApiBlacklistUrlResult( | 71 void PermissionBlacklistClient::OnCheckApiBlacklistUrlResult( |
| 68 const GURL& url, | 72 const GURL& url, |
| 69 const safe_browsing::ThreatMetadata& metadata) { | 73 const safe_browsing::ThreatMetadata& metadata) { |
| 70 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 74 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 71 | 75 |
| 72 if (timer_->IsRunning()) | 76 if (timer_->IsRunning()) |
| 73 timer_->Stop(); | 77 timer_->Stop(); |
| 74 else | 78 else |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 92 | 96 |
| 93 if (is_active_) | 97 if (is_active_) |
| 94 callback_.Run(permission_blocked); | 98 callback_.Run(permission_blocked); |
| 95 Release(); | 99 Release(); |
| 96 } | 100 } |
| 97 | 101 |
| 98 void PermissionBlacklistClient::WebContentsDestroyed() { | 102 void PermissionBlacklistClient::WebContentsDestroyed() { |
| 99 is_active_ = false; | 103 is_active_ = false; |
| 100 Observe(nullptr); | 104 Observe(nullptr); |
| 101 } | 105 } |
| OLD | NEW |