blob: a3ec225098f510d307f3d9592f5d1965012f1788 [file] [log] [blame]
michaelpgc0145e62017-03-18 03:00:151// Copyright 2017 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/extensions/blacklist_check.h"
6
7#include "base/bind.h"
8#include "chrome/browser/extensions/blacklist.h"
9#include "extensions/common/extension.h"
10
11namespace extensions {
12
13BlacklistCheck::BlacklistCheck(Blacklist* blacklist,
14 scoped_refptr<const Extension> extension)
Jeremy Roman495db682019-07-12 16:03:2415 : PreloadCheck(extension), blacklist_(blacklist) {}
michaelpgc0145e62017-03-18 03:00:1516
17BlacklistCheck::~BlacklistCheck() {}
18
19void BlacklistCheck::Start(ResultCallback callback) {
20 callback_ = std::move(callback);
21
22 blacklist_->IsBlacklisted(
23 extension()->id(),
24 base::Bind(&BlacklistCheck::OnBlacklistedStateRetrieved,
25 weak_ptr_factory_.GetWeakPtr()));
26}
27
28void BlacklistCheck::OnBlacklistedStateRetrieved(
29 BlacklistState blacklist_state) {
30 Errors errors;
31 if (blacklist_state == BlacklistState::BLACKLISTED_MALWARE)
32 errors.insert(PreloadCheck::BLACKLISTED_ID);
33 else if (blacklist_state == BlacklistState::BLACKLISTED_UNKNOWN)
34 errors.insert(PreloadCheck::BLACKLISTED_UNKNOWN);
35 std::move(callback_).Run(errors);
36}
37
38} // namespace extensions