blob: 6af944519c4b39dc62a139d6bcb9c3c3ae0d352f [file] [log] [blame]
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include <vector>
#include "chrome/chrome_cleaner/chrome_utils/force_installed_extension.h"
#include "chrome/chrome_cleaner/constants/uws_id.h"
#include "chrome/chrome_cleaner/proto/uwe_matcher.pb.h"
#include "chrome/chrome_cleaner/scanner/scanner.h"
namespace chrome_cleaner {
// Scans for Unwanted Extensions whenever a UwS is found.
class UwEScannerWrapper : public Scanner {
// |scanner| is the scanner that this scanner will wrap.
// It will drive all the interactions with the only change being that the
// found uws callback will trigger a search for UwE whenever a UwS is found.
// The |matchers| will match the UwS with the UwE from the
// |force_installed_extensions| list
std::unique_ptr<Scanner> scanner,
UwEMatchers* matchers,
const std::vector<ForceInstalledExtension>& force_installed_extensions);
UwEScannerWrapper(UwEScannerWrapper&& wrapper);
UwEScannerWrapper& operator=(UwEScannerWrapper&& other);
~UwEScannerWrapper() override;
// Scanner implementation.
// Will simply call the wrapped scanner's start method.
bool Start(const FoundUwSCallback& found_uws_callback,
DoneCallback done_callback) override;
void Stop() override;
bool IsCompletelyDone() const override;
// Finds the UwE associated with the UwS and stores in in the PUP data.
void FindUwE(UwSId found_uws);
std::unique_ptr<Scanner> scanner_;
UwEMatchers* matchers_;
std::vector<ForceInstalledExtension> force_installed_extensions_;
FoundUwSCallback found_uws_callback_;
} // namespace chrome_cleaner