OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/extensions/blacklist.h" | 5 #include "chrome/browser/extensions/blacklist.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 BrowserThread::PostTask( | 77 BrowserThread::PostTask( |
78 BrowserThread::IO, | 78 BrowserThread::IO, |
79 FROM_HERE, | 79 FROM_HERE, |
80 base::Bind(&SafeBrowsingClientImpl::StartCheck, this, | 80 base::Bind(&SafeBrowsingClientImpl::StartCheck, this, |
81 g_database_manager.Get().get(), | 81 g_database_manager.Get().get(), |
82 extension_ids)); | 82 extension_ids)); |
83 } | 83 } |
84 | 84 |
85 private: | 85 private: |
86 friend class base::RefCountedThreadSafe<SafeBrowsingClientImpl>; | 86 friend class base::RefCountedThreadSafe<SafeBrowsingClientImpl>; |
87 virtual ~SafeBrowsingClientImpl() {} | 87 ~SafeBrowsingClientImpl() override {} |
88 | 88 |
89 // Pass |database_manager| as a parameter to avoid touching | 89 // Pass |database_manager| as a parameter to avoid touching |
90 // SafeBrowsingService on the IO thread. | 90 // SafeBrowsingService on the IO thread. |
91 void StartCheck(scoped_refptr<SafeBrowsingDatabaseManager> database_manager, | 91 void StartCheck(scoped_refptr<SafeBrowsingDatabaseManager> database_manager, |
92 const std::set<std::string>& extension_ids) { | 92 const std::set<std::string>& extension_ids) { |
93 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 93 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
94 if (database_manager->CheckExtensionIDs(extension_ids, this)) { | 94 if (database_manager->CheckExtensionIDs(extension_ids, this)) { |
95 // Definitely not blacklisted. Callback immediately. | 95 // Definitely not blacklisted. Callback immediately. |
96 callback_message_loop_->PostTask( | 96 callback_message_loop_->PostTask( |
97 FROM_HERE, | 97 FROM_HERE, |
98 base::Bind(callback_, std::set<std::string>())); | 98 base::Bind(callback_, std::set<std::string>())); |
99 return; | 99 return; |
100 } | 100 } |
101 // Something might be blacklisted, response will come in | 101 // Something might be blacklisted, response will come in |
102 // OnCheckExtensionsResult. | 102 // OnCheckExtensionsResult. |
103 AddRef(); // Balanced in OnCheckExtensionsResult | 103 AddRef(); // Balanced in OnCheckExtensionsResult |
104 } | 104 } |
105 | 105 |
106 virtual void OnCheckExtensionsResult( | 106 void OnCheckExtensionsResult(const std::set<std::string>& hits) override { |
107 const std::set<std::string>& hits) override { | |
108 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 107 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
109 callback_message_loop_->PostTask(FROM_HERE, base::Bind(callback_, hits)); | 108 callback_message_loop_->PostTask(FROM_HERE, base::Bind(callback_, hits)); |
110 Release(); // Balanced in StartCheck. | 109 Release(); // Balanced in StartCheck. |
111 } | 110 } |
112 | 111 |
113 scoped_refptr<base::MessageLoopProxy> callback_message_loop_; | 112 scoped_refptr<base::MessageLoopProxy> callback_message_loop_; |
114 OnResultCallback callback_; | 113 OnResultCallback callback_; |
115 | 114 |
116 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingClientImpl); | 115 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingClientImpl); |
117 }; | 116 }; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 } | 342 } |
344 | 343 |
345 void Blacklist::Observe(int type, | 344 void Blacklist::Observe(int type, |
346 const content::NotificationSource& source, | 345 const content::NotificationSource& source, |
347 const content::NotificationDetails& details) { | 346 const content::NotificationDetails& details) { |
348 DCHECK_EQ(chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, type); | 347 DCHECK_EQ(chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, type); |
349 FOR_EACH_OBSERVER(Observer, observers_, OnBlacklistUpdated()); | 348 FOR_EACH_OBSERVER(Observer, observers_, OnBlacklistUpdated()); |
350 } | 349 } |
351 | 350 |
352 } // namespace extensions | 351 } // namespace extensions |
OLD | NEW |