#include "components/page_content_annotations/core/page_visibility_model_handler.h"
#include <algorithm>
#include "base/containers/contains.h"
#include "base/task/sequenced_task_runner.h"
#include "components/optimization_guide/core/optimization_guide_features.h"
#include "components/optimization_guide/core/optimization_guide_model_provider.h"
#include "components/optimization_guide/core/page_visibility_model_executor.h"
#include "components/optimization_guide/proto/models.pb.h"
#include "components/page_content_annotations/core/page_content_annotations_common.h"
namespace page_content_annotations {
namespace {
const char kNotSensitiveCategory[] = …;
}
PageVisibilityModelHandler::PageVisibilityModelHandler(
optimization_guide::OptimizationGuideModelProvider* model_provider,
scoped_refptr<base::SequencedTaskRunner> background_task_runner,
const std::optional<optimization_guide::proto::Any>& model_metadata)
: … { … }
PageVisibilityModelHandler::~PageVisibilityModelHandler() = default;
void PageVisibilityModelHandler::ExecuteOnSingleInput(
AnnotationType annotation_type,
const std::string& input,
base::OnceCallback<void(const BatchAnnotationResult&)> callback) { … }
void PageVisibilityModelHandler::PostprocessCategoriesToBatchAnnotationResult(
base::OnceCallback<void(const BatchAnnotationResult&)> callback,
AnnotationType annotation_type,
const std::string& input,
const std::optional<std::vector<tflite::task::core::Category>>& output) { … }
std::optional<double>
PageVisibilityModelHandler::ExtractContentVisibilityFromModelOutput(
const std::vector<tflite::task::core::Category>& model_output) const { … }
}